@soleil-se/config-svelte 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/components/Checkbox/Component.svelte +7 -0
- package/components/Checkbox/README.md +5 -0
- package/components/CheckboxGroup/Component.svelte +7 -1
- package/components/CheckboxGroup/README.md +7 -0
- package/components/DropdownSelector/Component.svelte +7 -1
- package/components/DropdownSelector/README.md +21 -2
- package/components/ImageSelector/Component.svelte +13 -14
- package/components/ImageSelector/README.md +3 -1
- package/components/ImageSelector/i18n.js +25 -0
- package/components/InputField/Component.svelte +23 -8
- package/components/InputField/README.md +18 -11
- package/components/LinkSelector/Component.svelte +20 -12
- package/components/LinkSelector/README.md +10 -2
- package/components/LinkSelector/i18n.js +31 -0
- package/components/ListSelector/Component.svelte +7 -1
- package/components/ListSelector/README.md +3 -2
- package/components/NodeSelector/Component.svelte +7 -0
- package/components/NodeSelector/README.md +12 -11
- package/components/NumberSpinner/Component.svelte +7 -0
- package/components/NumberSpinner/README.md +16 -9
- package/components/Panel/Component.svelte +10 -1
- package/components/Panel/README.md +6 -3
- package/components/Panel/i18n.js +13 -0
- package/components/RadioGroup/Component.svelte +26 -21
- package/components/RadioGroup/README.md +6 -0
- package/components/SelectField/Component.svelte +7 -0
- package/components/SelectField/README.md +17 -9
- package/components/TagSelector/Component.svelte +7 -0
- package/components/TagSelector/README.md +11 -10
- package/components/TextList/Component.svelte +10 -2
- package/components/TextList/README.md +9 -0
- package/components/TextList/i18n.js +13 -0
- package/package.json +1 -1
- package/utils/createI18n.js +29 -0
- package/utils/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.0] - 2021-08-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- I18n utility.
|
|
13
|
+
- Translations for components with translatable text.
|
|
14
|
+
- Spread rest props on input element in InputField.
|
|
15
|
+
- Docs with links to readme for each component.
|
|
16
|
+
|
|
17
|
+
## [1.5.2] - 2021-08-18
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- DropdownSelector values was not saved properly when set multiple times.
|
|
22
|
+
|
|
8
23
|
## [1.5.1] - 2021-08-12
|
|
9
24
|
|
|
10
25
|
### Fixed
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Checkbox
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
4
6
|
|
|
5
7
|
```javascript
|
|
@@ -12,10 +14,13 @@ export let value;
|
|
|
12
14
|
```
|
|
13
15
|
|
|
14
16
|
## Default value
|
|
17
|
+
|
|
15
18
|
Use checked attribute if the checkbox should be checked as default
|
|
19
|
+
|
|
16
20
|
```svelte
|
|
17
21
|
<Checkbox name="checkbox" label="Checkbox" checked />
|
|
18
22
|
```
|
|
23
|
+
|
|
19
24
|
## Examples
|
|
20
25
|
|
|
21
26
|
### Standard
|
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
};
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
|
+
<!--
|
|
33
|
+
@component
|
|
34
|
+
A checkbox group component.
|
|
35
|
+
|
|
36
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/CheckboxGroup/)
|
|
37
|
+
-->
|
|
38
|
+
|
|
32
39
|
<fieldset class="form-group {className}">
|
|
33
40
|
<legend>{legend}</legend>
|
|
34
41
|
{#each options as option, index}
|
|
@@ -104,5 +111,4 @@
|
|
|
104
111
|
input {
|
|
105
112
|
margin: -1px;
|
|
106
113
|
}
|
|
107
|
-
|
|
108
114
|
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# CheckboxGroup
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
6
|
+
|
|
4
7
|
```javascript
|
|
5
8
|
// ID, generates automatically if nothing is passed
|
|
6
9
|
export let id = generateId();
|
|
@@ -17,7 +20,9 @@ export let value;
|
|
|
17
20
|
```
|
|
18
21
|
|
|
19
22
|
## Default value
|
|
23
|
+
|
|
20
24
|
Use the value prop to set a default value when not binding the value:
|
|
25
|
+
|
|
21
26
|
```svelte
|
|
22
27
|
<CheckboxGroup
|
|
23
28
|
name="checkboxGroup1"
|
|
@@ -30,6 +35,7 @@ Use the value prop to set a default value when not binding the value:
|
|
|
30
35
|
## Example
|
|
31
36
|
|
|
32
37
|
### Standard
|
|
38
|
+
|
|
33
39
|
```svelte
|
|
34
40
|
<script>
|
|
35
41
|
import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
@@ -55,6 +61,7 @@ import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
### Advanced
|
|
64
|
+
|
|
58
65
|
```svelte
|
|
59
66
|
<script>
|
|
60
67
|
import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
const [el] = setupComponent(id)
|
|
34
34
|
.on('change', (e) => {
|
|
35
35
|
value = e.val || value;
|
|
36
|
-
if (name) values[name] = value;
|
|
37
36
|
dispatch('input', value);
|
|
38
37
|
dispatch('change', value);
|
|
39
38
|
})
|
|
@@ -51,6 +50,13 @@
|
|
|
51
50
|
});
|
|
52
51
|
</script>
|
|
53
52
|
|
|
53
|
+
<!--
|
|
54
|
+
@component
|
|
55
|
+
Wrapper component for Sitevision [dropdown selectors](https://developer.sitevision.se/docs/webapps/configuration#h-Sitevisioncomponents).
|
|
56
|
+
|
|
57
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/DropdownSelector/)
|
|
58
|
+
-->
|
|
59
|
+
|
|
54
60
|
<div class="form-group {className}" {hidden}>
|
|
55
61
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
56
62
|
<select
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# DropdownSelector
|
|
2
2
|
|
|
3
|
+
Wrapper component for Sitevision [dropdown selectors](https://developer.sitevision.se/docs/webapps/configuration#h-Sitevisioncomponents).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
# DropdownSelector
|
|
8
|
+
|
|
3
9
|
<!-- TOC -->
|
|
4
10
|
|
|
5
11
|
- [Props](#props)
|
|
12
|
+
- [Type](#type)
|
|
6
13
|
- [Example](#example)
|
|
7
14
|
- [Standard](#standard)
|
|
8
15
|
- [Advanced](#advanced)
|
|
@@ -24,6 +31,18 @@ export let disabled = false;
|
|
|
24
31
|
export let value = '';
|
|
25
32
|
```
|
|
26
33
|
|
|
34
|
+
### Type
|
|
35
|
+
|
|
36
|
+
Possible values for `type`:
|
|
37
|
+
|
|
38
|
+
- `metadata`
|
|
39
|
+
- `template`
|
|
40
|
+
- `oauth2-configuration`
|
|
41
|
+
- `virtual-group`
|
|
42
|
+
- `search-index`
|
|
43
|
+
- `font`
|
|
44
|
+
- `color`
|
|
45
|
+
|
|
27
46
|
## Example
|
|
28
47
|
|
|
29
48
|
### Standard
|
|
@@ -34,7 +53,7 @@ import { Panel, DropdownSelector } from '@soleil-se/svelte-config';
|
|
|
34
53
|
</script>
|
|
35
54
|
|
|
36
55
|
<Panel heading="Inställningar">
|
|
37
|
-
<DropdownSelector name="metadata" type="metadata
|
|
56
|
+
<DropdownSelector name="metadata" type="metadata" label="Metadata" />
|
|
38
57
|
</Panel>
|
|
39
58
|
```
|
|
40
59
|
|
|
@@ -55,7 +74,7 @@ onSave(() => values);
|
|
|
55
74
|
</script>
|
|
56
75
|
|
|
57
76
|
<Panel heading="Inställningar">
|
|
58
|
-
<DropdownSelector bind:value={values.metadata} type="metadata
|
|
77
|
+
<DropdownSelector bind:value={values.metadata} type="metadata" label="Metadata" />
|
|
59
78
|
</Panel>
|
|
60
79
|
```
|
|
61
80
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
4
|
|
|
5
5
|
import { triggerInput } from '../../utils';
|
|
6
|
+
import i18n from './i18n';
|
|
6
7
|
import Panel from '../Panel';
|
|
7
8
|
import NodeSelector from '../NodeSelector';
|
|
8
9
|
import InputField from '../InputField';
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
const values = window.CONFIG_VALUES || {};
|
|
12
13
|
|
|
13
14
|
export let name = undefined;
|
|
14
|
-
export let heading = '
|
|
15
|
+
export let heading = i18n('heading');
|
|
15
16
|
export let required = false;
|
|
16
17
|
export let node;
|
|
17
18
|
export let alt;
|
|
@@ -56,30 +57,28 @@
|
|
|
56
57
|
|
|
57
58
|
</script>
|
|
58
59
|
|
|
60
|
+
<!--
|
|
61
|
+
@component
|
|
62
|
+
Custom panel component for selecting an image.
|
|
63
|
+
|
|
64
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/ImageSelector/)
|
|
65
|
+
-->
|
|
66
|
+
|
|
59
67
|
<Panel {heading}>
|
|
60
68
|
<NodeSelector
|
|
61
69
|
name="{name}Node"
|
|
62
|
-
label=
|
|
70
|
+
label={i18n('selectImage')}
|
|
63
71
|
type="image"
|
|
64
72
|
bind:value={node}
|
|
65
73
|
on:change={onChange}
|
|
66
74
|
{required}
|
|
67
75
|
/>
|
|
68
76
|
{#if useCustomAlt}
|
|
69
|
-
<InputField name="{name}Alt" label=
|
|
77
|
+
<InputField name="{name}Alt" label={i18n('altText')} required bind:value={alt} />
|
|
70
78
|
{:else}
|
|
71
|
-
<InputField label=
|
|
79
|
+
<InputField label={i18n('altFromCaption')} value={imageArchiveAlt} readonly disabled>
|
|
72
80
|
<input bind:this={validationEl} class="sr-only" />
|
|
73
81
|
</InputField>
|
|
74
82
|
{/if}
|
|
75
|
-
<
|
|
76
|
-
<Checkbox bind:value={useCustomAlt} label="Ange egen alt-text" on:change={onUseCustomToggle} />
|
|
77
|
-
</div>
|
|
83
|
+
<Checkbox bind:value={useCustomAlt} label={i18n('customAltText')} on:change={onUseCustomToggle} />
|
|
78
84
|
</Panel>
|
|
79
|
-
|
|
80
|
-
<style>
|
|
81
|
-
div {
|
|
82
|
-
margin-top: -10px;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# ImageSelector
|
|
2
2
|
|
|
3
3
|
Custom panel component for selecting an image.
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
<!-- TOC -->
|
|
5
7
|
|
|
6
8
|
- [AppData](#appdata)
|
|
@@ -13,7 +15,7 @@ Custom panel component for selecting an image.
|
|
|
13
15
|
|
|
14
16
|
## AppData
|
|
15
17
|
|
|
16
|
-
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
18
|
+
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
17
19
|
For example if `name="image"` the values will be available as `imageNode` and `imageAlt` (if custom alt-text is set).
|
|
18
20
|
|
|
19
21
|
```js
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import createI18n from '../../utils/createI18n';
|
|
2
|
+
|
|
3
|
+
export default createI18n({
|
|
4
|
+
sv: {
|
|
5
|
+
heading: 'Bild',
|
|
6
|
+
selectImage: 'Välj bild',
|
|
7
|
+
altText: 'Alt-text',
|
|
8
|
+
altFromCaption: 'Alt-text (från bildbeskrivning)',
|
|
9
|
+
customAltText: 'Ange egen alt-text',
|
|
10
|
+
},
|
|
11
|
+
no: {
|
|
12
|
+
heading: 'Bilde',
|
|
13
|
+
selectImage: 'Velg bilde',
|
|
14
|
+
altText: 'Alt-tekst',
|
|
15
|
+
altFromCaption: 'Alt-tekst (fra bildebeskrivelse)',
|
|
16
|
+
customAltText: 'Skriv inn din egen alt-tekst',
|
|
17
|
+
},
|
|
18
|
+
en: {
|
|
19
|
+
heading: 'Image',
|
|
20
|
+
selectImage: 'Select image',
|
|
21
|
+
altText: 'Alt text',
|
|
22
|
+
altFromCaption: 'Alt text (from image caption)',
|
|
23
|
+
customAltText: 'Use custom alt text',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -7,34 +7,50 @@
|
|
|
7
7
|
const values = window.CONFIG_VALUES || {};
|
|
8
8
|
const dispatch = createEventDispatcher();
|
|
9
9
|
|
|
10
|
+
/** @type {string} */
|
|
10
11
|
export let id = generateId();
|
|
12
|
+
/** @type {string} */
|
|
11
13
|
export let label;
|
|
14
|
+
/** @type {string} */
|
|
12
15
|
export let type = 'text';
|
|
16
|
+
/** @type {string} */
|
|
13
17
|
export let name = undefined;
|
|
18
|
+
/** @type {boolean} */
|
|
14
19
|
export let required = false;
|
|
20
|
+
/** @type {boolean} */
|
|
15
21
|
export let disabled = false;
|
|
22
|
+
/** @type {boolean} */
|
|
16
23
|
export let readonly = false;
|
|
17
|
-
|
|
18
|
-
export let pattern = undefined;
|
|
24
|
+
/** @type {number} */
|
|
19
25
|
export let rows = 3;
|
|
26
|
+
/** @type {string} */
|
|
20
27
|
export let value = '';
|
|
28
|
+
/** @type {function} */
|
|
21
29
|
export let action = prefixHttps;
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
|
|
24
31
|
let className = '';
|
|
32
|
+
/** @type {string} */
|
|
25
33
|
export { className as class };
|
|
34
|
+
|
|
35
|
+
value = name ? values[name] ?? value : value;
|
|
26
36
|
|
|
27
37
|
$: isTextarea = type === 'textarea';
|
|
28
38
|
$: required = required && !disabled && !readonly;
|
|
29
39
|
|
|
30
40
|
const onInput = ({ target }) => {
|
|
31
41
|
value = type.match(/^(number|range)$/) ? +target.value : target.value;
|
|
32
|
-
if (name) values[name] = value;
|
|
33
42
|
dispatch('input', value);
|
|
34
43
|
dispatch('change', value);
|
|
35
44
|
};
|
|
36
45
|
</script>
|
|
37
46
|
|
|
47
|
+
<!--
|
|
48
|
+
@component
|
|
49
|
+
Component for input fields and textareas.
|
|
50
|
+
|
|
51
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/InputField/)
|
|
52
|
+
-->
|
|
53
|
+
|
|
38
54
|
<div class="form-group {className}">
|
|
39
55
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
40
56
|
{#if isTextarea}
|
|
@@ -43,11 +59,11 @@
|
|
|
43
59
|
{id}
|
|
44
60
|
{name}
|
|
45
61
|
{required}
|
|
46
|
-
{maxlength}
|
|
47
62
|
{disabled}
|
|
48
63
|
{readonly}
|
|
49
64
|
{value}
|
|
50
65
|
{rows}
|
|
66
|
+
{...$$restProps}
|
|
51
67
|
on:input={onInput}
|
|
52
68
|
/>
|
|
53
69
|
{:else}
|
|
@@ -57,11 +73,10 @@
|
|
|
57
73
|
{name}
|
|
58
74
|
{type}
|
|
59
75
|
{required}
|
|
60
|
-
{maxlength}
|
|
61
76
|
{disabled}
|
|
62
77
|
{readonly}
|
|
63
|
-
{pattern}
|
|
64
78
|
{value}
|
|
79
|
+
{...$$restProps}
|
|
65
80
|
use:action
|
|
66
81
|
on:input={onInput}
|
|
67
82
|
/>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# InputField
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Wrapper for input fields.
|
|
3
4
|
Automatically prefixes https:// if field type is `url`.
|
|
5
|
+
|
|
6
|
+

|
|
4
7
|
<!-- TOC -->
|
|
5
8
|
|
|
6
9
|
- [Props](#props)
|
|
@@ -42,9 +45,10 @@ export let value = '';
|
|
|
42
45
|
## Example
|
|
43
46
|
|
|
44
47
|
### Standard
|
|
48
|
+
|
|
45
49
|
```svelte
|
|
46
50
|
<script>
|
|
47
|
-
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
51
|
+
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
48
52
|
</script>
|
|
49
53
|
|
|
50
54
|
<Panel heading="Inställningar">
|
|
@@ -56,15 +60,15 @@ import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
|
56
60
|
|
|
57
61
|
```svelte
|
|
58
62
|
<script>
|
|
59
|
-
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
60
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
63
|
+
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
64
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
61
65
|
|
|
62
|
-
const values = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
+
const values = {
|
|
67
|
+
text: '',
|
|
68
|
+
...window.CONFIG_VALUES
|
|
69
|
+
};
|
|
66
70
|
|
|
67
|
-
onSave(() => values);
|
|
71
|
+
onSave(() => values);
|
|
68
72
|
|
|
69
73
|
</script>
|
|
70
74
|
|
|
@@ -74,16 +78,19 @@ onSave(() => values);
|
|
|
74
78
|
```
|
|
75
79
|
|
|
76
80
|
## Slots
|
|
81
|
+
|
|
77
82
|
Default slot after input field.
|
|
83
|
+
|
|
78
84
|
```svelte
|
|
79
85
|
<InputField name="text" label="Text">
|
|
80
86
|
<p class="help-block">Some helpful text</p>
|
|
81
87
|
</InputField>
|
|
82
88
|
```
|
|
89
|
+
|
|
83
90
|
## Default value
|
|
91
|
+
|
|
84
92
|
Use the value attribute to set a default value:
|
|
93
|
+
|
|
85
94
|
```svelte
|
|
86
95
|
<InputField name="text" label="Text" value="Default text" />
|
|
87
96
|
```
|
|
88
|
-
|
|
89
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import { show, prefixMail, prefixTel } from '../../actions';
|
|
4
|
+
import i18n from './i18n';
|
|
4
5
|
|
|
5
6
|
import Panel from '../Panel';
|
|
6
7
|
import RadioGroup from '../RadioGroup';
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
const dispatch = createEventDispatcher();
|
|
13
14
|
|
|
14
|
-
export let heading;
|
|
15
|
+
export let heading = i18n('heading');
|
|
15
16
|
export let name;
|
|
16
17
|
export let disabled = false;
|
|
17
18
|
export let required = false;
|
|
@@ -23,11 +24,11 @@
|
|
|
23
24
|
export { className as class };
|
|
24
25
|
|
|
25
26
|
$: selectableTypes = [
|
|
26
|
-
{ label: '
|
|
27
|
-
{ label: '
|
|
28
|
-
{ label: '
|
|
29
|
-
{ label: '
|
|
30
|
-
{ label: '
|
|
27
|
+
{ label: i18n('internal'), value: 'internal' },
|
|
28
|
+
{ label: i18n('external'), value: 'external' },
|
|
29
|
+
{ label: i18n('file'), value: 'file' },
|
|
30
|
+
{ label: i18n('mail'), value: 'mail' },
|
|
31
|
+
{ label: i18n('tel'), value: 'tel' },
|
|
31
32
|
].filter((type) => types.includes(type.value));
|
|
32
33
|
|
|
33
34
|
$: isInternal = value.type === 'internal';
|
|
@@ -51,6 +52,13 @@
|
|
|
51
52
|
};
|
|
52
53
|
</script>
|
|
53
54
|
|
|
55
|
+
<!--
|
|
56
|
+
@component
|
|
57
|
+
Custom panel component for selecting a link.
|
|
58
|
+
|
|
59
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/LinkSelector/)
|
|
60
|
+
-->
|
|
61
|
+
|
|
54
62
|
<Panel {heading} class={className} {required}>
|
|
55
63
|
<slot name="top" />
|
|
56
64
|
{#if name}<input type="hidden" name={`${name}Value`} value={value.value} />{/if}
|
|
@@ -72,7 +80,7 @@
|
|
|
72
80
|
bind:value={selected.internal}
|
|
73
81
|
{disabled}
|
|
74
82
|
type="page-selector"
|
|
75
|
-
label=
|
|
83
|
+
label={i18n('internal')}
|
|
76
84
|
on:change={onChange}
|
|
77
85
|
required={required && isInternal}
|
|
78
86
|
/>
|
|
@@ -81,7 +89,7 @@
|
|
|
81
89
|
<InputField
|
|
82
90
|
bind:value={selected.external}
|
|
83
91
|
{disabled}
|
|
84
|
-
label=
|
|
92
|
+
label={i18n('external')}
|
|
85
93
|
type="url"
|
|
86
94
|
on:change={onChange}
|
|
87
95
|
required={required && isExternal}
|
|
@@ -92,7 +100,7 @@
|
|
|
92
100
|
bind:value={selected.file}
|
|
93
101
|
{disabled}
|
|
94
102
|
type="file-selector"
|
|
95
|
-
label=
|
|
103
|
+
label={i18n('file')}
|
|
96
104
|
on:change={onChange}
|
|
97
105
|
required={required && isFile}
|
|
98
106
|
/>
|
|
@@ -102,7 +110,7 @@
|
|
|
102
110
|
<InputField
|
|
103
111
|
bind:value={selected.mail}
|
|
104
112
|
{disabled}
|
|
105
|
-
label=
|
|
113
|
+
label={i18n('mail')}
|
|
106
114
|
action={prefixMail}
|
|
107
115
|
on:change={onChange}
|
|
108
116
|
required={required && isMail}
|
|
@@ -112,7 +120,7 @@
|
|
|
112
120
|
<InputField
|
|
113
121
|
bind:value={selected.tel}
|
|
114
122
|
{disabled}
|
|
115
|
-
label=
|
|
123
|
+
label={i18n('tel')}
|
|
116
124
|
type="tel"
|
|
117
125
|
action={prefixTel}
|
|
118
126
|
on:change={onChange}
|
|
@@ -124,7 +132,7 @@
|
|
|
124
132
|
bind:value={value.newWindow}
|
|
125
133
|
name={name ? `${name}NewWindow` : ''}
|
|
126
134
|
{disabled}
|
|
127
|
-
label=
|
|
135
|
+
label={i18n('newTab')}
|
|
128
136
|
on:change={onChange}
|
|
129
137
|
/>
|
|
130
138
|
<slot name="bottom" />
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# LinkSelector
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Custom panel component for selecting a link.
|
|
4
|
+
|
|
5
|
+

|
|
3
6
|
|
|
4
7
|
## AppData
|
|
5
|
-
|
|
8
|
+
|
|
9
|
+
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
6
10
|
For example if `name="link"` the values will be available as `linkValue`, `linkType` and `linkNewWindow`.
|
|
7
11
|
|
|
8
12
|
```js
|
|
@@ -15,6 +19,7 @@ const getLink = () => ({
|
|
|
15
19
|
});
|
|
16
20
|
|
|
17
21
|
```
|
|
22
|
+
|
|
18
23
|
## Props
|
|
19
24
|
|
|
20
25
|
```javascript
|
|
@@ -33,7 +38,9 @@ export let value;
|
|
|
33
38
|
```
|
|
34
39
|
|
|
35
40
|
## Slots
|
|
41
|
+
|
|
36
42
|
Top and bottom slots before and after link selector.
|
|
43
|
+
|
|
37
44
|
```svelte
|
|
38
45
|
<LinkSelector
|
|
39
46
|
name="link"
|
|
@@ -62,6 +69,7 @@ Top and bottom slots before and after link selector.
|
|
|
62
69
|
## Example
|
|
63
70
|
|
|
64
71
|
### Standard
|
|
72
|
+
|
|
65
73
|
```svelte
|
|
66
74
|
<script>
|
|
67
75
|
import { LinkSelector } from '@soleil-se/svelte-config';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import createI18n from '../../utils/createI18n';
|
|
2
|
+
|
|
3
|
+
export default createI18n({
|
|
4
|
+
sv: {
|
|
5
|
+
heading: 'Länk',
|
|
6
|
+
internal: 'Intern',
|
|
7
|
+
external: 'Extern',
|
|
8
|
+
file: 'Fil',
|
|
9
|
+
mail: 'E-post',
|
|
10
|
+
tel: 'Telefonnummer',
|
|
11
|
+
newTab: 'Öppna i ny flik',
|
|
12
|
+
},
|
|
13
|
+
no: {
|
|
14
|
+
heading: 'Lenke',
|
|
15
|
+
internal: 'Intern',
|
|
16
|
+
external: 'Ekstern',
|
|
17
|
+
file: 'Fil',
|
|
18
|
+
mail: 'E-post',
|
|
19
|
+
tel: 'Telefonnummer',
|
|
20
|
+
newTab: 'Åpne i en ny fane',
|
|
21
|
+
},
|
|
22
|
+
en: {
|
|
23
|
+
heading: 'Link',
|
|
24
|
+
internal: 'Internal',
|
|
25
|
+
external: 'External',
|
|
26
|
+
file: 'File',
|
|
27
|
+
mail: 'Mail',
|
|
28
|
+
tel: 'Phone',
|
|
29
|
+
newTab: 'Open in new tab',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -40,6 +40,13 @@
|
|
|
40
40
|
});
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
|
+
<!--
|
|
44
|
+
@component
|
|
45
|
+
Wrapper for Sitevision [list components](https://developer.sitevision.se/docs/webapps/configuration#h-Listcomponents).
|
|
46
|
+
|
|
47
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/ListSelector/)
|
|
48
|
+
-->
|
|
49
|
+
|
|
43
50
|
<div class="form-group">
|
|
44
51
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
45
52
|
<input
|
|
@@ -71,5 +78,4 @@
|
|
|
71
78
|
background-color: rgba(255, 255, 255, 0.3);
|
|
72
79
|
cursor: not-allowed;
|
|
73
80
|
}
|
|
74
|
-
|
|
75
81
|
</style>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# ListSelector
|
|
2
2
|
|
|
3
|
-
Wrapper for list components
|
|
4
|
-
|
|
3
|
+
Wrapper for Sitevision [list components](https://developer.sitevision.se/docs/webapps/configuration#h-Listcomponents)
|
|
4
|
+
|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
<!-- TOC -->
|
|
7
8
|
|
|
@@ -54,6 +54,13 @@
|
|
|
54
54
|
});
|
|
55
55
|
</script>
|
|
56
56
|
|
|
57
|
+
<!--
|
|
58
|
+
@component
|
|
59
|
+
Wrapper for Sitevision [node selectors](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
60
|
+
|
|
61
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/NodeSelector/)
|
|
62
|
+
-->
|
|
63
|
+
|
|
57
64
|
<div class="form-group {className}">
|
|
58
65
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
59
66
|
<input
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# NodeSelector
|
|
2
2
|
|
|
3
|
-
Wrapper for node selectors.
|
|
4
|
-
|
|
3
|
+
Wrapper for Sitevision [node selectors](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
4
|
+
|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
<!-- TOC -->
|
|
7
8
|
|
|
@@ -35,9 +36,8 @@ export let value = '';
|
|
|
35
36
|
|
|
36
37
|
```svelte
|
|
37
38
|
<script>
|
|
38
|
-
import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
39
|
+
import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
39
40
|
</script>
|
|
40
|
-
```
|
|
41
41
|
|
|
42
42
|
<Panel heading="Inställningar">
|
|
43
43
|
<NodeSelector
|
|
@@ -46,20 +46,21 @@ import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
|
46
46
|
label="Sida"
|
|
47
47
|
/>
|
|
48
48
|
</Panel>
|
|
49
|
+
```
|
|
49
50
|
|
|
50
51
|
### Advanced
|
|
51
52
|
|
|
52
53
|
```svelte
|
|
53
54
|
<script>
|
|
54
|
-
import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
55
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
55
|
+
import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
56
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
56
57
|
|
|
57
|
-
const values = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
58
|
+
const values = {
|
|
59
|
+
page: '',
|
|
60
|
+
...window.CONFIG_VALUES
|
|
61
|
+
};
|
|
61
62
|
|
|
62
|
-
onSave(() => values);
|
|
63
|
+
onSave(() => values);
|
|
63
64
|
|
|
64
65
|
</script>
|
|
65
66
|
|
|
@@ -32,6 +32,13 @@
|
|
|
32
32
|
});
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
|
+
<!--
|
|
36
|
+
@component
|
|
37
|
+
Wrapper for Sitevision [number spinner](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
38
|
+
|
|
39
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/NumberSpinner/)
|
|
40
|
+
-->
|
|
41
|
+
|
|
35
42
|
<div class="form-group">
|
|
36
43
|
<label for={id} class="control-label">{label}</label>
|
|
37
44
|
<input
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# NumberSpinner
|
|
2
|
-
|
|
3
|
-
https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents
|
|
2
|
+
|
|
3
|
+
Wrapper for Sitevision [number spinner](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
|
|
5
7
|
## Props
|
|
8
|
+
|
|
6
9
|
```javascript
|
|
7
10
|
export let id = generateId();
|
|
8
11
|
export let name;
|
|
@@ -19,10 +22,12 @@ export let value = min || 1;
|
|
|
19
22
|
## Example
|
|
20
23
|
|
|
21
24
|
### Standard
|
|
25
|
+
|
|
22
26
|
```svelte
|
|
23
27
|
<script>
|
|
24
28
|
import { Panel, NumberSpinner } from '@soleil-se/svelte-config';
|
|
25
29
|
</script>
|
|
30
|
+
|
|
26
31
|
<Panel heading="Inställningar">
|
|
27
32
|
<NumberSpinner name="spinner" label="Number spinner" min="5" max="10" suffix="px" />
|
|
28
33
|
</Panel>
|
|
@@ -32,15 +37,15 @@ export let value = min || 1;
|
|
|
32
37
|
|
|
33
38
|
```svelte
|
|
34
39
|
<script>
|
|
35
|
-
import { Panel, NumberSpinner } from '@soleil-se/svelte-config';
|
|
36
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
40
|
+
import { Panel, NumberSpinner } from '@soleil-se/svelte-config';
|
|
41
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
37
42
|
|
|
38
|
-
const values = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
43
|
+
const values = {
|
|
44
|
+
spinner: '',
|
|
45
|
+
...window.CONFIG_VALUES
|
|
46
|
+
};
|
|
42
47
|
|
|
43
|
-
onSave(() => values);
|
|
48
|
+
onSave(() => values);
|
|
44
49
|
|
|
45
50
|
</script>
|
|
46
51
|
|
|
@@ -50,7 +55,9 @@ onSave(() => values);
|
|
|
50
55
|
```
|
|
51
56
|
|
|
52
57
|
## Slots
|
|
58
|
+
|
|
53
59
|
Default slot after selector.
|
|
60
|
+
|
|
54
61
|
```svelte
|
|
55
62
|
<NumberSpinner name="spinner" label="Number spinner" min="5" max="10" />
|
|
56
63
|
<p class="help-block">Some helpful text.</p>
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
2
|
+
import i18n from './i18n';
|
|
3
|
+
|
|
4
|
+
export let heading = i18n('settings');
|
|
3
5
|
export let required = false;
|
|
4
6
|
</script>
|
|
5
7
|
|
|
8
|
+
<!--
|
|
9
|
+
@component
|
|
10
|
+
A panel component.
|
|
11
|
+
|
|
12
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/Panel/)
|
|
13
|
+
-->
|
|
14
|
+
|
|
6
15
|
<div class="panel panel-default">
|
|
7
16
|
<input class="sr-only" type="text" tabindex="-1" />
|
|
8
17
|
<div class="panel-heading">
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Panel
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
6
|
+
|
|
4
7
|
```javascript
|
|
5
8
|
// Panel heading
|
|
6
9
|
export let heading = 'Inställningar';
|
|
@@ -9,17 +12,17 @@ export let required = false;
|
|
|
9
12
|
```
|
|
10
13
|
|
|
11
14
|
## Slots
|
|
15
|
+
|
|
12
16
|
Default slot for panel body.
|
|
13
17
|
|
|
14
18
|
## Example
|
|
19
|
+
|
|
15
20
|
```svelte
|
|
16
21
|
<script>
|
|
17
|
-
import { Panel } from '@soleil-se/svelte-config';
|
|
22
|
+
import { Panel } from '@soleil-se/svelte-config';
|
|
18
23
|
</script>
|
|
19
24
|
|
|
20
25
|
<Panel heading="Inställningar">
|
|
21
26
|
<!-- Panel content -->
|
|
22
27
|
</Panel>
|
|
23
28
|
```
|
|
24
|
-
|
|
25
|
-
|
|
@@ -24,27 +24,32 @@
|
|
|
24
24
|
};
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
<!--
|
|
28
|
+
@component
|
|
29
|
+
A radio group component.
|
|
30
|
+
|
|
31
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/RadioGroup/)
|
|
32
|
+
-->
|
|
33
|
+
|
|
34
|
+
<fieldset class="form-group">
|
|
35
|
+
<legend>{legend}</legend>
|
|
36
|
+
{#each options as option, index}
|
|
37
|
+
<input
|
|
38
|
+
id={`${id}_${index}`}
|
|
39
|
+
bind:group={value}
|
|
40
|
+
value={option.value || option}
|
|
41
|
+
checked={option.value || option}
|
|
42
|
+
disabled={isDisabled(option)}
|
|
43
|
+
type="radio"
|
|
44
|
+
class="sr-only"
|
|
45
|
+
on:change={onChange}
|
|
46
|
+
/>
|
|
47
|
+
<label for={`${id}_${index}`} class="radio-inline" class:disabled={isDisabled(option)}>
|
|
48
|
+
{option.label || option}
|
|
49
|
+
</label>
|
|
50
|
+
{/each}
|
|
51
|
+
</fieldset>
|
|
52
|
+
<input type="hidden" {value} {name} />
|
|
48
53
|
|
|
49
54
|
<style lang="scss">
|
|
50
55
|
legend {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# RadioGroup
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
6
|
+
|
|
4
7
|
```javascript
|
|
5
8
|
export let id = generateId();
|
|
6
9
|
// If SiteVision default functions for getting and setting config is used name must be set
|
|
@@ -18,6 +21,7 @@ export let value = '';
|
|
|
18
21
|
## Example
|
|
19
22
|
|
|
20
23
|
### Standard
|
|
24
|
+
|
|
21
25
|
```svelte
|
|
22
26
|
<script>
|
|
23
27
|
import { Panel, RadioGroup } from '@soleil-se/svelte-config';
|
|
@@ -63,7 +67,9 @@ onSave(() => values);
|
|
|
63
67
|
```
|
|
64
68
|
|
|
65
69
|
## Default value
|
|
70
|
+
|
|
66
71
|
Use the value attribute to set a default value:
|
|
72
|
+
|
|
67
73
|
```svelte
|
|
68
74
|
<RadioGroup
|
|
69
75
|
name="radioGroup"
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
};
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
|
+
<!--
|
|
23
|
+
@component
|
|
24
|
+
A select field component.
|
|
25
|
+
|
|
26
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/SelectField/)
|
|
27
|
+
-->
|
|
28
|
+
|
|
22
29
|
<div class="form-group">
|
|
23
30
|
<label class="control-label {required ? 'control-label--required' : ''}" for={id}>{label}</label>
|
|
24
31
|
<!-- svelte-ignore a11y-no-onchange -->
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# SelectField
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
6
|
+
|
|
4
7
|
```javascript
|
|
5
8
|
export let id = generateId();
|
|
6
9
|
export let label;
|
|
@@ -14,9 +17,10 @@ export let value = '';
|
|
|
14
17
|
## Example
|
|
15
18
|
|
|
16
19
|
### Standard
|
|
20
|
+
|
|
17
21
|
```svelte
|
|
18
22
|
<script>
|
|
19
|
-
import { Panel, SelectField } from '@soleil-se/svelte-config';
|
|
23
|
+
import { Panel, SelectField } from '@soleil-se/svelte-config';
|
|
20
24
|
</script>
|
|
21
25
|
|
|
22
26
|
<Panel heading="Inställningar">
|
|
@@ -33,17 +37,17 @@ import { Panel, SelectField } from '@soleil-se/svelte-config';
|
|
|
33
37
|
|
|
34
38
|
```svelte
|
|
35
39
|
<script>
|
|
36
|
-
import { Panel, SelectField } from '@soleil-se/svelte-config';
|
|
37
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
40
|
+
import { Panel, SelectField } from '@soleil-se/svelte-config';
|
|
41
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
38
42
|
|
|
39
|
-
const values = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
+
const values = {
|
|
44
|
+
select: '',
|
|
45
|
+
...window.CONFIG_VALUES
|
|
46
|
+
};
|
|
43
47
|
|
|
44
|
-
const options = ['Värde 1', 'Värde 2', 'Värde 3'];
|
|
48
|
+
const options = ['Värde 1', 'Värde 2', 'Värde 3'];
|
|
45
49
|
|
|
46
|
-
onSave(() => values);
|
|
50
|
+
onSave(() => values);
|
|
47
51
|
|
|
48
52
|
</script>
|
|
49
53
|
|
|
@@ -53,7 +57,9 @@ onSave(() => values);
|
|
|
53
57
|
```
|
|
54
58
|
|
|
55
59
|
## Slots
|
|
60
|
+
|
|
56
61
|
Default slot after select field.
|
|
62
|
+
|
|
57
63
|
```svelte
|
|
58
64
|
<SelectField name="select1" label="Select 1" options={['Värde 1', 'Värde 2', 'Värde 3']} >
|
|
59
65
|
<p class="help-block">Some helpful text</p>
|
|
@@ -61,7 +67,9 @@ Default slot after select field.
|
|
|
61
67
|
```
|
|
62
68
|
|
|
63
69
|
## Default value
|
|
70
|
+
|
|
64
71
|
Use the value attribute to set a default value:
|
|
72
|
+
|
|
65
73
|
```svelte
|
|
66
74
|
<SelectField name="select1" label="Select 1" options={['Värde 1', 'Värde 2', 'Värde 3']} value="Värde 1" />
|
|
67
75
|
```
|
|
@@ -44,6 +44,13 @@
|
|
|
44
44
|
});
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
|
+
<!--
|
|
48
|
+
@component
|
|
49
|
+
Wrapper for Sitevision [tag selector](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
50
|
+
|
|
51
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/TagSelector/)
|
|
52
|
+
-->
|
|
53
|
+
|
|
47
54
|
<div class="form-group {className}">
|
|
48
55
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
49
56
|
<input
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# TagSelector
|
|
2
2
|
|
|
3
|
-
Wrapper for tag selector.
|
|
4
|
-
|
|
3
|
+
Wrapper for Sitevision [tag selector](https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents).
|
|
4
|
+
|
|
5
|
+

|
|
5
6
|
|
|
6
7
|
<!-- TOC -->
|
|
7
8
|
|
|
@@ -29,7 +30,7 @@ export let value = [];
|
|
|
29
30
|
|
|
30
31
|
```svelte
|
|
31
32
|
<script>
|
|
32
|
-
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
33
|
+
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
33
34
|
</script>
|
|
34
35
|
|
|
35
36
|
<Panel heading="Inställningar">
|
|
@@ -43,15 +44,15 @@ Name prop is required here as well since Sitevision uses this to initialize the
|
|
|
43
44
|
|
|
44
45
|
```svelte
|
|
45
46
|
<script>
|
|
46
|
-
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
47
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
47
|
+
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
48
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
48
49
|
|
|
49
|
-
const values = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
50
|
+
const values = {
|
|
51
|
+
tags: [],
|
|
52
|
+
...window.CONFIG_VALUES
|
|
53
|
+
};
|
|
53
54
|
|
|
54
|
-
onSave(() => values);
|
|
55
|
+
onSave(() => values);
|
|
55
56
|
|
|
56
57
|
</script>
|
|
57
58
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import { generateId } from '../../utils';
|
|
4
4
|
import { resizer } from '../../actions';
|
|
5
|
+
import i18n from './i18n';
|
|
6
|
+
|
|
5
7
|
import Sortable from './internal/Sortable.svelte';
|
|
6
8
|
import Item from './internal/Item.svelte';
|
|
7
9
|
import DataHolder from './internal/DataHolder.svelte';
|
|
@@ -66,6 +68,13 @@
|
|
|
66
68
|
};
|
|
67
69
|
</script>
|
|
68
70
|
|
|
71
|
+
<!--
|
|
72
|
+
@component
|
|
73
|
+
Custom list component for adding multiple text values and sorting them.
|
|
74
|
+
|
|
75
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/TextList/)
|
|
76
|
+
-->
|
|
77
|
+
|
|
69
78
|
<div class="form-group">
|
|
70
79
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
71
80
|
<div class="list-component">
|
|
@@ -87,7 +96,7 @@
|
|
|
87
96
|
on:click={addItem}
|
|
88
97
|
>
|
|
89
98
|
<i class="glyphicons plus" aria-hidden="true" />
|
|
90
|
-
|
|
99
|
+
{i18n('add')}
|
|
91
100
|
</button>
|
|
92
101
|
</div>
|
|
93
102
|
{#if disabled}
|
|
@@ -110,5 +119,4 @@
|
|
|
110
119
|
background-color: rgba(255, 255, 255, 0.3);
|
|
111
120
|
cursor: not-allowed;
|
|
112
121
|
}
|
|
113
|
-
|
|
114
122
|
</style>
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# TextList
|
|
2
2
|
|
|
3
|
+
Custom list component for adding multiple text values and sorting them.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
3
7
|
## Props
|
|
8
|
+
|
|
4
9
|
```javascript
|
|
5
10
|
export let id = generateId();
|
|
6
11
|
export let label;
|
|
@@ -11,7 +16,9 @@ export let value = [];
|
|
|
11
16
|
```
|
|
12
17
|
|
|
13
18
|
## Default value
|
|
19
|
+
|
|
14
20
|
Use the value attribute to set a default value:
|
|
21
|
+
|
|
15
22
|
```svelte
|
|
16
23
|
<TextList
|
|
17
24
|
name="textList"
|
|
@@ -23,6 +30,7 @@ Use the value attribute to set a default value:
|
|
|
23
30
|
## Example
|
|
24
31
|
|
|
25
32
|
### Standard
|
|
33
|
+
|
|
26
34
|
```svelte
|
|
27
35
|
<script>
|
|
28
36
|
import { Panel, TextList } from '@soleil-se/svelte-config';
|
|
@@ -35,6 +43,7 @@ import { Panel, TextList } from '@soleil-se/svelte-config';
|
|
|
35
43
|
/>
|
|
36
44
|
</Panel>
|
|
37
45
|
```
|
|
46
|
+
|
|
38
47
|
### Advanced
|
|
39
48
|
|
|
40
49
|
```svelte
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const locale = document.documentElement.lang || 'en';
|
|
2
|
+
|
|
3
|
+
/* https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get */
|
|
4
|
+
const get = (obj, path, defaultValue = undefined) => {
|
|
5
|
+
const travel = (regexp) => String.prototype.split
|
|
6
|
+
.call(path, regexp)
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj);
|
|
9
|
+
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
|
|
10
|
+
return result === undefined || result === obj ? defaultValue : result;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default function createI18n(messages) {
|
|
14
|
+
return (path, values = {}) => {
|
|
15
|
+
let message = get(messages[locale], path);
|
|
16
|
+
if (message == null) {
|
|
17
|
+
console.warn(`[@soleil-se/svelte-config/utils/i18n] No translation avaliable for ${path}`);
|
|
18
|
+
return path;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.keys(values).forEach((key) => {
|
|
22
|
+
const value = values[key];
|
|
23
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
24
|
+
message = message.replace(regex, value);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return message;
|
|
28
|
+
};
|
|
29
|
+
}
|
package/utils/index.js
CHANGED
|
@@ -4,3 +4,4 @@ export { default as setupComponent } from './setupComponent';
|
|
|
4
4
|
export { default as addPrefix } from './addPrefix';
|
|
5
5
|
export { default as pluckPrefix } from './pluckPrefix';
|
|
6
6
|
export { default as triggerInput } from './triggerInput';
|
|
7
|
+
export { default as createI18n } from './createI18n';
|