# j-Configuration

> j-Configuration: supports dark mode; NEW: datasource {String} optional, a path to the data-source for config items

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: e93c0ff449451c5bba8dafdccd0988c86f601e073a23db266833de9ba94913b9
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- supports __dark mode__

__Configuration__:

- `dateformat {String}` a default date format (default: `DEF.dateformat`)

### Declaration

__Allowed properties__:

- `type {String}` supports:
	- `string`
	- `number`
	- `date`
	- `boolean`
	- `dropdown`
	- `color`
	- `icon`
	- `multiline`
	- `selectable`
- `text {String}` a text/title
- `name {String}` a name of property in the model
- `align {Number}` align for inputs (`0` left (default), `1` center, `2` right)
- `icon {String}` optional, Total JS or font-awesome icon identifier
- `summary {String}` optional, a summarization
- `note {String}` optional, a note
- `required {Boolean}` optional, is the property required?
- `disable {String}` optional, declaration of arrow function in the form `value.interval === 100`
- `visible {String}` optional, declaration of arrow function in the form `value.interval === 100`
- `button {String}` optional, creates a small button
- `click {String}` optional, a link to the method (depends on the `button`)
- `maxlength {Number}` optional, supports only `string` type
- `min {Number}` optional, supports only `number` type
- `max {Number}` optional, supports only `number` type
- `increment {Number}` optional, an increment count - supports only `number` type (default: `1`)
- `multiple {Boolean}` optional, works with `selectable` type (a value will be array)
- `monospace {Boolean}` optional, works with `string` and `number` types
- `bold {Boolean}` optional, works with `string` and `number` types
- `placeholder {String}` optional
- `items {String/Object Array}` optional for `dropdown` and `selectable` in the form `[{ id: 'VALUE', name: 'TEXT' }]`
	 - type `string` a path to the `Object Array` (works with scopes)
	 - type `Object Array` fixed defined array
- `dirplaceholder {String}` optional, placeholder for `j-Directory`
- `dirsearch {Boolean}` optional, enables/disables `search` field in `j-Directory` (default: `true`)
- __NEW__: `datasource {String}` optional, a path to the data-source for config items

Declaration must be defined in the component's element body wrapped in the `<script type="text/plain">` element. Example:

```js
[
	{
		name: 'My group label',
		type: 'group',
		// summary: 'Lorem ipsum dolor, sit amet consectetur adipisicing elit. Numquam, nostrum.',
		// icon: 'ti ti-home'
	},
	{
		id: 'name',
		name: 'Application name',
		type: 'string',
		icon: 'ti ti-home',
		disable: 'model => model.interval < 100',
		summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.',
		required: true
	},
	... other items
]
```

Use it with `<ui-component name="configuration">`. 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.

```html example.html
<ui-component name="LAZY colorpicker"></ui-component>
<ui-component name="LAZY datepicker"></ui-component>
<ui-component name="LAZY directory"></ui-component>
<ui-component name="LAZY icons"></ui-component>

<ui-component name="configuration" path="config" class="invisible">
	<script type="name/plain">
		[
			{
				name: 'My group',
				type: 'group',
				summary: 'Lorem ipsum dolor, sit amet consectetur adipisicing elit. Numquam, nostrum.',
				icon: 'ti ti-home'
			},
			{
				id: 'name',
				name: 'Application name',
				type: 'string',
				icon: 'ti ti-home',
				disable: 'model => model.interval < 100',
				button: 'Verify',
				note: 'ajldksasdljsalj',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.',
				required: true
			},
			{
				id: 'name',
				name: 'Application name',
				type: 'string',
				icon: 'ti ti-home',
				note: 'ajldksasdljsalj',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.',
				camouflage: true,
				required: true
			},
			{
				id: 'date',
				name: 'Date',
				type: 'date',
				disable: 'model => model.interval < 100',
				placeholder: 'Test',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			},
			{
				id: 'interval',
				name: 'Backup interval',
				type: 'number',
				min: 1,
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			},
			{
				id: 'color',
				name: 'Color',
				type: 'color',
				disable: 'model => model.interval < 100',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			},
			{
				id: 'icon',
				name: 'Icon',
				type: 'icon',
				disable: 'model => model.interval < 100',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			},
			{
				id: 'interval',
				name: 'Backup interval',
				type: 'number'
			},
			{
				id: 'interval',
				disable: 'model => model.interval < 100',
				name: 'Backup interval',
				type: 'number'
			},
			{
				id: 'city2',
				items: [{ id: 'bb', name: 'BB', icon: 'ti ti-map-pin' }, { id: 'ba', name: 'BA', icon: 'ti ti-map-pin' }, { id: 'zv', name: 'ZV', icon: 'ti ti-map-pin' }, { id: 'se', name: 'SE', icon: 'ti ti-map-pin' }],
				name: 'City',
				multiple: true,
				dirempty: 'Empty',
				type: 'selectable'
			},
			{
				id: 'city',
				items: [{ id: 'bb', name: 'Banská Bystrica' }, { id: 'ba', name: 'Bratislava' }, { id: 'zv', name: 'Zvolen' }],
				name: 'City',
				noborder: 1,
				dirempty: 'Empty',
				placeholder: 'Choose city',
				disable: 'model => model.interval < 100',
				type: 'dropdown'
			},
			{
				name: 'System',
				type: 'group',
				summary: 'Lorem ipsum dolor, sit amet consectetur adipisicing elit. Numquam, nostrum.',
				icon: 'ti ti-home'
			},
			{
				id: 'notes',
				name: 'Multiline',
				type: 'multiline',
				placeholder: 'Test placeholder',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			},
			{
				id: 'newsletter',
				name: 'Allow newsletter',
				type: 'boolean',
				disable: 'model => model.interval < 100',
				summary: 'Lorem, ipsum dolor sit amet consectetur, adipisicing elit. Iste eos, illum voluptas assumenda sunt possimus necessitatibus nobis provident dicta deserunt.'
			}
		]
	</script>
</ui-component>

<script>
	var config = { interval: 100, icon: 'ti ti-home', color: '#A0A0A0', newsletter: false, name: 'Peter Širka', city: '' };
</script>
```
