New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ti.growingform

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ti.growingform

A growing ("stepper") form for Appcelerator Titanium.

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Growing ("Stepper") Form for Titanium

Example

A form that expands / collapses based on the current input field. Also known as "growing form" or "stepper form".

Requirements

  • Titanium SDK (npm i titanium)
  • ES6+ enabled (<transpile>true</transpile>)

Installation

  1. Via npm: npm i ti.growingform
  2. Manually: Copy to app/lib/ (Alloy) or Resources/ (classic)

Example

import { GrowingForm, GrowingFormValidationRule, GrowingFormFieldType } from 'ti.growingform';

const config = {
	cells: [{
		title: 'Your Username',
		identifier: 'username',
		type: GrowingFormFieldType.TEXT,
		validate: GrowingFormValidationRule.LIVE,
		throttle: handleUsernameThrottle,
		options: {
			hintText: 'Enter username ...'
		}
	}, {
		title: 'Your Mail address',
		identifier: 'email',
		type: GrowingFormFieldType.TEXT,
		validate: GrowingFormValidationRule.EMAIL,
		options: {
			keyboardType: Ti.UI.KEYBOARD_TYPE_EMAIL,
			hintText: 'Enter mail address ...'
		}
	}, {
		title: 'Your Password',
		identifier: 'password',
		type: GrowingFormFieldType.TEXT,
		validate: value => {
			// CREDITS: https://www.thepolyglotdeveloper.com/2015/05/use-regex-to-test-password-strength-in-javascript/
			const strongRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})");
			return strongRegex.test(value);
		},
		options: {
			passwordMask: true,
			hintText: 'Enter password ...'
		}
	}],
	options: {
    		// Style the underlaying table-view via it's header-view
    		tableTopMargin: 50,

		// Bullets
		bulletInactiveBackgroundColor: '#666',
		bulletInactiveTextColor: '#fff',
		bulletActiveBackgroundColor: '#000',
		bulletActiveTextColor: '#fff',

		// Step button (aka "Continue")
		stepButtonTitle: L('Continue', 'Continue'),
		stepButtonBackgroundColor: '#333',
		stepButtonTextColor: '#fff',
		stepButtonBorderRadius: 20,

		// Step button (aka "Submit")
		submitButtonTitle: L('Submit', 'Submit'),
		submitButtonBackgroundColor: 'orange',
		submitButtonTextColor: '#fff',
		submitButtonBorderRadius: 20
	},
	overrides: {
		// backgroundColor: 'green'
	} 
};

function handleUsernameThrottle(textField, submitButton) {
	// Do a HTTP request to validate the text-field value
 	// and enable / disable the submit button as below
	submitButton.enabled = true;
	submitButton.opacity = 1.0
}

const growingForm = new GrowingForm({ configuration: config });

growingForm.on('submit', data => {
	Ti.API.info(`Finished form! Data: ${JSON.stringify(data)}`)
});

growingForm.on('step', (textField, index, isValid) => {
  Ti.API.info(`Stepped to ${index}, valid = ${isValid}`);
});

growingForm.render({ view: $.index });

API

All methods and properties are accessed from the GrowingForm instance

Methods

NameArgumentsDescription
lockLocks the form
unlockUnlocks the form
openStepidentifierMoves back to a step, crawled by it's identifier
focusFocuses the current field (only if the field is a text-field)
blurBlurs the current field (only if the field is a text-field)
submitSubmits the form programmatically

License

MIT

Author

Hans Knöchel (Lambus GmbH)

Keywords

FAQs

Package last updated on 02 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc