# j-MultiOptions

> MultiOptions component uses this color scheme: <http://codepen.io/devi8/pen/lvIeh> and the declaration below will show all colors in the widget settings.

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

- it expects the whole object with `key`: `value`
- HTML body of the jComponent has to be `<script type="text/plain>` with (JavaScript) mapping

__Configuration__:

- `rebind` {Boolean} rebinds a path value according to the MultiOptions schema (default: `true`)

__Mapping__:

- it's provided on immediately when the component is ready
- it has to wrapped in `<script type="text/plain">option();option();...</script>`
- mapping method: `option(key, label, value, [type], [max], [min], [step])`

__Basic types__:

- type: `string` (when is the value `string` you don't need to define the type)
- type: `number` (when is the value `number` you don't need to define the type)
- type: `boolean` (when is the value `boolean` you don't need to define the type)
- type: `date` (when is the value `date` you don't need to define the type)
- __NEW__ type: `multiline` renders `textarea` instead of `input`

__Simple Array__:

```js
option('language', 'Language', 'sk', ['sk', 'en', 'de']);
```

__Advanced Array__:

```js
option('language', 'Language', 1, [{ text: 'sk', value: 1}, { text: 'en', value: 2}, { text: 'de', value: 3}]);
```

__Array from URL__:

```js
option('language', 'Language', 1, '/my/api/codelist/');
// It expects some "Array"
```

__Colors__:

MultiOptions component uses this color scheme: <http://codepen.io/devi8/pen/lvIeh> and the declaration below will show all colors in the widget settings.

```js
option('background', 'Background', '#FC6E51', 'Color');
```

__Good to know__:
- all properties not defined in mapping won't be shown
- `date` type is linked by `Calendar` component
- follow example
- `component.remap(js_code)` can remap new configuration
- `component.dependencies()` returns `Object` with all items `key/value` from dropdown lists

Use it with `<ui-component name="multioptions">`. 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
<div style="width:600px;margin:30px auto">
	<ui-component name="multioptions" path="options" class="block">
		<script type="text/plain">
			option('background', 'Background Color', '#8CC152', 'Color');
			option('type', 'Type', 'days', ['hours', 'days', 'months', 'years']);
			option('showArea', 'Show area', true);
			option('body', 'Body', 'Here is enabled\nmultiline.', 'MultiLine');
			option('showPoint', 'Show point', true);
			option('showLine', 'Show line', true);
			option('smoothCurves', 'Smooth curves', true);
			option('YshowLabel', 'Axis Y: Show Label', true);
			option('YshowGrid', 'Axis Y: Show Grid', false);
			option('onlyInteger', 'Whole numbers', true);
			option('decimals', 'Decimals', 1);
		</script>
	</ui-component>
</div>

<script>
	var options = {};
	options.background = '#8CC152';
	options.type = 'years';
	options.decimals = 2;
</script>
```
