j-Properties2
The component uses j-DatePicker, j-TimePicker, j-Directory, j-Emoji, j-ColorPicker and j-Icons components.
Configuration:
dateformat {String}a date format (default:yyyy-MM-dd)timeformat {String}a time format (default:HH:mm)datetimeformat {String}a date/time format (default:yyyy-MM-dd HH:mm)change {String}a path to methodmethod(item, replace_text(new_text))(executed if some value is changed) andreplace_textargument is optionalmodalalign {String}aligment for modal windows (default:center)style {Number}supports a new style2likeiOSsettings (default:1)validation {Boolean}enables validation for required fields (default:true)defaultgroup {String}a default group name (default:Default)
Data declaration:
var form = [];
form.push({ group: 'Personal', label: 'First name', name: 'user.firstname', type: 'string', value: 'Peter', transform: 'capitalize' });
form.push({ group: 'Personal', label: 'Last name', name: 'user.lastname', type: 'string', value: 'Širka', placeholder: 'String' });
form.push({ group: 'Personal', label: 'Age', name: 'user.age', type: 'number', value: 33, min: 30 });
form.push({ group: 'Personal', label: 'Birth date', name: 'user.birth', type: 'date', value: NOW });
form.push({ group: 'Additional', label: 'Newsletter', name: 'user.newsletter', type: 'bool', value: true });
form.push({ group: 'Additional', label: 'City', name: 'user.city', type: 'list', value: 2, items: 'items', dirsearch: 'Search city', dircustom: true });
form.push({ group: 'Additional', label: 'Color', name: 'user.color', type: 'color', value: '#e73323' });
form.push({ group: 'Additional', label: 'Icon', name: 'user.icon', type: 'fontawesome', value: 'ti ti-home' });
form.push({ group: 'Additional', label: 'Emoji', name: 'user.emoji', type: 'emoji', value: '', show: 'n => n.age === 33' });Data properties in data declaration:
name {String}an item identifier (required)label {String}a label (required)group {String}a group name (required)note {String}a small note under controltype {String}a type (required)placeholder {String}a placeholder (supports few types only)transform {String}forstringtype only, can containcapitalize,uppercase,lowercaseorslugmaxlength {Number}forstringtype onlyvalidate {RegExp/String}forstringtype only, can containemail,phoneorurlmin {Number}fornumbertype onlymax {Number}fornumbertype onlyinc {Number/String}increments a value according to the value, targeted fornumberordate(can contain1 dayor-1 day) type onlyrequired {Boolean}for typestring,numberordatedirsearch {String/Boolean}a placeholder forlisttype only, boolean disables searchdircustom {Boolean}enables a custom value forlisttype onlydirkey {String}a key name for label/name, targeted forlisttype only (default:name)dirvalue {String}a key name for value, targeted forlisttype only (default:id)detail {String}URL address for obtaining of data forlisttype, example:/users/{0}/and{0}will be replaced with the value from listitems {Object Array/String}items forlisttype only, string can contain a path toArrayorURL addressto searchshow {Arrow function}, example:data => data.KEY === 'SOMETHING'--> will show the item if the condition will validicon {String}Total icon, can contain a color e.g.ti ti-home #00000ricon {String}Right Font-Awesome icon or text e.g.!HTML textriconclick {String}a path to the methodfunction(item, set(new_val))camouflage {Boolean}only forstringtypemonospace {Boolean}it uses a monospace font
Allowed types in data:
stringboolnumberdatelistcoloremojifontawesomeexec(can execexecmethod)text(readonly value)menu(it's similar to list but the component will executej-Menu)
Missing types:
datetimetimefilemonths
Good to know
The component extends the Array by adding:
invalid {Boolean}field determines if thevalueis invalid (default:undefined)changed {Boolean}field determines if thevaluehas been changed (default:undefined)prev{???} field contains an initial value
Use it with <ui-component name="properties2">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.
<ui-component name="LAZY directory"></ui-component>
<ui-component name="LAZY colorpicker"></ui-component>
<ui-component name="LAZY faicons"></ui-component>
<ui-component name="LAZY datepicker"></ui-component>
<ui-component name="LAZY timepicker"></ui-component>
<ui-component name="LAZY emoji"></ui-component>
<ui-component name="LAZY menu"></ui-component>
<div style="width:600px;padding:20px;background-color:#F0F0F0">
<ui-component name="properties2" path="form" class="m"></ui-component>
<ui-component name="properties2" path="form2" config="style:2" class="m"></ui-component>
<!-- PERSISTENT MODE -->
<ui-component name="properties2" path="form3" config="style:2">
<script type="text/plain">
[
{ group: 'Personal', name: 'First name', id: 'firstname', type: 'string',transform: 'capitalize', note: 'Type your name' },
{ group: 'Personal', name: 'Last name', id: 'lastname', type: 'string', placeholder: 'String' },
{ group: 'Personal', name: 'Token', id: 'token', type: 'string', placeholder: 'String', camouflage: true }
]
</script>
</ui-component>
</div>
<script>
var items = [{ id: 2, name: 'Banská Bystrica' }, { id: 3, name: 'Bratislava' }];
var form = [];
form.push({ group: 'Personal', name: 'First name', id: 'firstname', type: 'string', value: 'Peter', transform: 'capitalize', note: 'Type your name' });
form.push({ group: 'Personal', name: 'Last name', id: 'lastname', type: 'string', value: 'Širka', placeholder: 'String' });
form.push({ group: 'Personal', name: 'Age', id: 'age', type: 'number', value: 33, min: 30 });
form.push({ group: 'Personal', name: 'Birth date', id: 'birth', type: 'date', value: NOW });
form.push({ group: 'Additional', name: 'Newsletter', id: 'newsletter', type: 'bool', value: true });
form.push({ group: 'Additional', name: 'City', id: 'city', type: 'list', value: 2, items: 'items', dirsearch: 'Search city', dircustom: true });
form.push({ group: 'Additional', name: 'Color', id: 'color', type: 'color', value: '#e73323' });
form.push({ group: 'Additional', name: 'Icon', id: 'icon', type: 'fontawesome', value: 'ti ti-home' });
form.push({ group: 'Additional', name: 'Emoji', id: 'emoji', type: 'emoji', value: '', show: 'n => n.age === 33' });
form.push({ group: 'Additional', name: 'Exec', exec: 'myexec', type: 'exec', value: 'Some text to exec' });
form.push({ group: 'Additional', name: 'Readonly', id: 'something', type: 'text', value: 'Readonly value' });
var form2 = [];
form2.push({ group: 'Personal', name: 'First name', id: 'firstname', type: 'string', value: 'Peter', transform: 'capitalize', note: 'Type your name' });
form2.push({ group: 'Personal', name: 'Last name', id: 'lastname', type: 'string', value: 'Širka', placeholder: 'String' });
form2.push({ group: 'Personal', name: 'Age', id: 'age', type: 'number', value: 33, min: 30 });
form2.push({ group: 'Personal', name: 'Birth date', id: 'birth', type: 'date', value: NOW });
form2.push({ group: 'Additional', name: 'Newsletter', id: 'newsletter', type: 'bool', value: true });
form2.push({ group: 'Additional', name: 'City', id: 'city', type: 'list', value: 2, items: 'items', dirsearch: 'Search city', dircustom: true });
form2.push({ group: 'Additional', name: 'Color', id: 'color', type: 'color', value: '#e73323' });
form2.push({ group: 'Additional', name: 'Icon', id: 'icon', type: 'fontawesome', value: 'ti ti-home' });
form2.push({ group: 'Additional', name: 'Emoji', id: 'emoji', type: 'emoji', value: '', show: 'n => n.age === 33' });
form2.push({ group: 'Additional', name: 'Exec', exec: 'myexec', type: 'exec', value: 'Some text to exec' });
form2.push({ group: 'Additional', name: 'Readonly', id: 'something', type: 'text', value: 'Readonly value', icon: 'ti ti-home #000' });
var form3 = {};
form3.firstname = 'Peter';
form3.lastname = 'Širka';
form3.token = GUID(30);
function myexec(item, el) {
console.log(item, el);
}
</script>