@soleil-se/config-svelte 1.2.0 → 1.3.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 +39 -0
- package/actions/index.js +1 -1
- package/actions/inputPrefix.js +31 -0
- package/components/DropdownSelector/Component.svelte +4 -2
- package/components/DropdownSelector/README.md +15 -3
- package/components/ImageSelector/Component.svelte +78 -0
- package/components/ImageSelector/README.md +68 -0
- package/components/ImageSelector/index.js +1 -0
- package/components/InputField/Component.svelte +3 -2
- package/components/LinkSelector/Component.svelte +15 -22
- package/components/LinkSelector/api/getSavedValue.js +19 -0
- package/components/ListSelector/Component.svelte +3 -1
- package/components/ListSelector/README.md +21 -7
- package/components/NodeSelector/Component.svelte +2 -1
- package/components/NodeSelector/README.md +22 -6
- package/components/Panel/Component.svelte +7 -0
- package/components/SelectField/Component.svelte +1 -0
- package/components/TextList/Component.svelte +0 -4
- package/components/TextList/internal/DataHolder.svelte +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/utils/index.js +1 -0
- package/utils/triggerInput.js +8 -0
- package/actions/httpPrefix.js +0 -10
- package/components/TextList/internal/triggerInput.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,45 +1,84 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.3.0] - 2021-04.28
|
|
9
|
+
|
|
10
|
+
## Added
|
|
11
|
+
|
|
12
|
+
- Type shorthands for DropdownSelector, NodeSelector and ListSelector.
|
|
13
|
+
- ImageSelector component.
|
|
14
|
+
|
|
15
|
+
## Fixed
|
|
16
|
+
|
|
17
|
+
- Scroll problems.
|
|
18
|
+
|
|
19
|
+
## [1.2.1] - 2021-04-09
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Mail and tel values in LinkSelector are prefixed with `mailto:` and `tel:`.
|
|
24
|
+
|
|
6
25
|
## [1.2.0] - 2021-03-30
|
|
26
|
+
|
|
7
27
|
### Added
|
|
28
|
+
|
|
8
29
|
- Mail and tel types to LinkSelector.
|
|
9
30
|
- Value in NumberSpinner is now left aligned.
|
|
31
|
+
|
|
10
32
|
### Fixed
|
|
33
|
+
|
|
11
34
|
- Unable to clear value in LinkSelector.
|
|
12
35
|
|
|
13
36
|
## [1.1.2] - 2021-03-11
|
|
37
|
+
|
|
14
38
|
### Fixed
|
|
39
|
+
|
|
15
40
|
- Unable to remove last item in TextList.
|
|
16
41
|
- TextList is not validated when `required` prop is used
|
|
42
|
+
|
|
17
43
|
## [1.1.1] - 2021-02-02
|
|
44
|
+
|
|
18
45
|
### Fixed
|
|
46
|
+
|
|
19
47
|
- Missing docs NumberSpinner.
|
|
20
48
|
|
|
21
49
|
## [1.1.0] - 2021-01-29
|
|
50
|
+
|
|
22
51
|
### Added
|
|
52
|
+
|
|
23
53
|
- `suffix` prop to NumberSpinner.
|
|
24
54
|
|
|
25
55
|
## [1.0.4] - 2021-01-15
|
|
56
|
+
|
|
26
57
|
### Fixed
|
|
58
|
+
|
|
27
59
|
- ListSelector inifity loop.
|
|
28
60
|
|
|
29
61
|
## [1.0.3] - 2021-01-11
|
|
62
|
+
|
|
30
63
|
### Fixed
|
|
64
|
+
|
|
31
65
|
- Remove debug output.
|
|
32
66
|
|
|
33
67
|
## [1.0.2] - 2021-01-11
|
|
68
|
+
|
|
34
69
|
### Fixed
|
|
70
|
+
|
|
35
71
|
- Array destructuring not working in TextList for IE11.
|
|
36
72
|
- RadioGroup value not working in IE11.
|
|
37
73
|
- Added missing polyfills for IE11 in docs and demo.
|
|
38
74
|
|
|
39
75
|
## [1.0.1] - 2020-12-08
|
|
76
|
+
|
|
40
77
|
### Fixed
|
|
78
|
+
|
|
41
79
|
- Selectable props in NodeSelector, ListSelector and DropdownSelector now also accepts a string.
|
|
42
80
|
- Margin on CheckboxGroup and RadioGroup controls.
|
|
43
81
|
|
|
44
82
|
## [1.0.0] - 2020-11-20
|
|
83
|
+
|
|
45
84
|
- Initial release!
|
package/actions/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function prefixHttps(node) {
|
|
2
|
+
const addPrefix = () => {
|
|
3
|
+
const { type, value } = node;
|
|
4
|
+
if (type === 'url' && value && !/^(https?):\/\//i.test(value) && ('http://'.indexOf(value) === -1 && 'https://'.indexOf(value) === -1)) {
|
|
5
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
6
|
+
node.value = `https://${value}`;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
node.addEventListener('input', addPrefix);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function prefixMail(node) {
|
|
13
|
+
const addPrefix = () => {
|
|
14
|
+
const { value } = node;
|
|
15
|
+
|
|
16
|
+
if (value && !/^(mailto?):/i.test(value) && 'mailto:'.indexOf(value) === -1) {
|
|
17
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
18
|
+
node.value = `mailto:${value}`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
node.addEventListener('input', addPrefix);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function prefixTel(node) {
|
|
25
|
+
const addPrefix = () => {
|
|
26
|
+
const { value } = node;
|
|
27
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
28
|
+
node.value = `tel:${value.replace(/\s/g, '').replace(/[^0-9$\\+]/g, '')}`;
|
|
29
|
+
};
|
|
30
|
+
node.addEventListener('input', addPrefix);
|
|
31
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export let id = generateId();
|
|
9
9
|
export let label;
|
|
10
10
|
export let name = undefined;
|
|
11
|
-
export let type;
|
|
11
|
+
export let type = 'metadata-selector';
|
|
12
12
|
export let selectable = [];
|
|
13
13
|
export let required = false;
|
|
14
14
|
export let disabled = false;
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
let hidden = true;
|
|
24
24
|
|
|
25
|
+
$: component = type.endsWith('-selector') ? type : `${type}-selector`;
|
|
26
|
+
|
|
25
27
|
onMount(() => {
|
|
26
28
|
setupComponent(id)
|
|
27
29
|
.on('change', (e) => {
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
{name}
|
|
46
48
|
{required}
|
|
47
49
|
{disabled}
|
|
48
|
-
data-component={
|
|
50
|
+
data-component={component}
|
|
49
51
|
data-removable
|
|
50
52
|
data-types={selectable}
|
|
51
53
|
/>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
- [Example](#example)
|
|
7
7
|
- [Standard](#standard)
|
|
8
8
|
- [Advanced](#advanced)
|
|
9
|
+
- [Type prop shorthand (since 1.3.0)](#type-prop-shorthand-since-130)
|
|
9
10
|
- [Selectable types](#selectable-types)
|
|
10
11
|
|
|
11
12
|
<!-- /TOC -->
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
export let id = generateId();
|
|
17
18
|
export let label; // Required
|
|
18
19
|
export let name = undefined;
|
|
19
|
-
export let type
|
|
20
|
+
export let type = 'metadata';
|
|
20
21
|
export let selectable = [];
|
|
21
22
|
export let required = false;
|
|
22
23
|
export let disabled = false;
|
|
@@ -26,6 +27,7 @@ export let value = '';
|
|
|
26
27
|
## Example
|
|
27
28
|
|
|
28
29
|
### Standard
|
|
30
|
+
|
|
29
31
|
```svelte
|
|
30
32
|
<script>
|
|
31
33
|
import { Panel, DropdownSelector } from '@soleil-se/svelte-config';
|
|
@@ -57,13 +59,23 @@ onSave(() => values);
|
|
|
57
59
|
</Panel>
|
|
58
60
|
```
|
|
59
61
|
|
|
62
|
+
## Type prop shorthand (since 1.3.0)
|
|
63
|
+
|
|
64
|
+
You can omnit the `-selector` suffix for the type prop.
|
|
65
|
+
|
|
66
|
+
```svelte
|
|
67
|
+
<DropdownSelector name="metadata" type="metadata" label="Metadata" />
|
|
68
|
+
```
|
|
69
|
+
|
|
60
70
|
## Selectable types
|
|
71
|
+
|
|
61
72
|
> :exclamation: Since SiteVision 7.0 :exclamation:
|
|
62
73
|
|
|
63
|
-
Filter what types should be selectable. See available types here:
|
|
64
|
-
https://developer.sitevision.se/docs/webapps/configuration#h-Types
|
|
74
|
+
Filter what types should be selectable. See available types here:
|
|
75
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-Types>
|
|
65
76
|
|
|
66
77
|
Accepts an Array or String.
|
|
78
|
+
|
|
67
79
|
```svelte
|
|
68
80
|
<DropdownSelector
|
|
69
81
|
name="metadata"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!-- prettier-ignore -->
|
|
2
|
+
<script>
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
|
|
5
|
+
import { triggerInput } from '../../utils';
|
|
6
|
+
import Panel from '../Panel';
|
|
7
|
+
import NodeSelector from '../NodeSelector';
|
|
8
|
+
import InputField from '../InputField';
|
|
9
|
+
import Checkbox from '../Checkbox';
|
|
10
|
+
|
|
11
|
+
const values = window.CONFIG_VALUES || {};
|
|
12
|
+
|
|
13
|
+
export let name = undefined;
|
|
14
|
+
export let heading = 'Bild';
|
|
15
|
+
export let required = false;
|
|
16
|
+
export let node;
|
|
17
|
+
export let alt;
|
|
18
|
+
alt = name ? values[`${name}Alt`] ?? alt : alt;
|
|
19
|
+
|
|
20
|
+
let imageArchiveAlt = '';
|
|
21
|
+
let useCustomAlt = !!alt;
|
|
22
|
+
let customAlt = alt;
|
|
23
|
+
let validationEl;
|
|
24
|
+
|
|
25
|
+
const dispatch = createEventDispatcher();
|
|
26
|
+
|
|
27
|
+
const onChange = async () => {
|
|
28
|
+
if (node) {
|
|
29
|
+
const response = await fetch(`/rest-api/1/1/${node}/properties`).then((res) => res.json());
|
|
30
|
+
imageArchiveAlt = response.alt || '';
|
|
31
|
+
|
|
32
|
+
validationEl?.setCustomValidity(imageArchiveAlt ? '' : 'Bilden saknar beskrivning (alt-text). Klicka på bilden ovan och skriv texten i fältet Bildbeskrivning.');
|
|
33
|
+
} else {
|
|
34
|
+
validationEl?.setCustomValidity('');
|
|
35
|
+
}
|
|
36
|
+
triggerInput(validationEl);
|
|
37
|
+
|
|
38
|
+
dispatch('input', { node, alt });
|
|
39
|
+
dispatch('change', { node, alt });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const onUseCustomToggle = () => {
|
|
43
|
+
if (useCustomAlt) {
|
|
44
|
+
alt = customAlt || '';
|
|
45
|
+
} else {
|
|
46
|
+
customAlt = alt;
|
|
47
|
+
alt = undefined;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<Panel {heading}>
|
|
54
|
+
<NodeSelector
|
|
55
|
+
name="{name}Node"
|
|
56
|
+
label="Välj bild"
|
|
57
|
+
type="image"
|
|
58
|
+
bind:value={node}
|
|
59
|
+
on:change={onChange}
|
|
60
|
+
{required}
|
|
61
|
+
/>
|
|
62
|
+
{#if useCustomAlt}
|
|
63
|
+
<InputField name="{name}Alt" label="Alt-text" required bind:value={alt} />
|
|
64
|
+
{:else}
|
|
65
|
+
<InputField label="Alt-text (från bildbeskrivning)" value={imageArchiveAlt} readonly disabled>
|
|
66
|
+
<input bind:this={validationEl} class="sr-only" />
|
|
67
|
+
</InputField>
|
|
68
|
+
{/if}
|
|
69
|
+
<div>
|
|
70
|
+
<Checkbox bind:value={useCustomAlt} label="Ange egen alt-text" on:change={onUseCustomToggle} />
|
|
71
|
+
</div>
|
|
72
|
+
</Panel>
|
|
73
|
+
|
|
74
|
+
<style>
|
|
75
|
+
div {
|
|
76
|
+
margin-top: -10px;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# ImageSelector
|
|
2
|
+
|
|
3
|
+
Custom panel component for selecting an image.
|
|
4
|
+
<!-- TOC -->
|
|
5
|
+
|
|
6
|
+
- [AppData](#appdata)
|
|
7
|
+
- [Props](#props)
|
|
8
|
+
- [Example](#example)
|
|
9
|
+
- [Standard](#standard)
|
|
10
|
+
- [Advanced](#advanced)
|
|
11
|
+
|
|
12
|
+
<!-- /TOC -->
|
|
13
|
+
|
|
14
|
+
## AppData
|
|
15
|
+
|
|
16
|
+
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
17
|
+
For example if `name="image"` the values will be available as `imageNode` and `imageAlt` (if custom alt-text is set).
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import appData from 'appData';
|
|
21
|
+
|
|
22
|
+
const getImage = () => ({
|
|
23
|
+
uri: appData.get('imageNode', 'URI'),
|
|
24
|
+
alt: appData.get('imageAlt') || appData.get('imageNode', 'alt'),
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Props
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
// Panel heading
|
|
32
|
+
export let heading = 'Bild';
|
|
33
|
+
// Name attribute.
|
|
34
|
+
export let name = undefined;
|
|
35
|
+
// If field is required.
|
|
36
|
+
export let required = false;
|
|
37
|
+
// Node ID of selected image.
|
|
38
|
+
export let node;
|
|
39
|
+
// Custom alt text it's set.
|
|
40
|
+
export let alt;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Example
|
|
44
|
+
|
|
45
|
+
### Standard
|
|
46
|
+
|
|
47
|
+
```svelte
|
|
48
|
+
<script>
|
|
49
|
+
import { ImageSelector } from '@soleil-se/svelte-config';
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<ImageSelector name="image" heading="Bild" />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Advanced
|
|
56
|
+
|
|
57
|
+
```svelte
|
|
58
|
+
<script>
|
|
59
|
+
import { ImageSelector } from '@soleil-se/svelte-config';
|
|
60
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
61
|
+
|
|
62
|
+
const values = window.CONFIG_VALUES || {};
|
|
63
|
+
|
|
64
|
+
onSave(() => values);
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<ImageSelector bind:node={values.imageNode} bind:alt={values.imageAlt} />
|
|
68
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Component.svelte';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/* eslint-disable no-undef-init */
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { prefixHttps } from '../../actions';
|
|
5
5
|
import { generateId } from '../../utils';
|
|
6
6
|
|
|
7
7
|
const values = window.CONFIG_VALUES || {};
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
export let pattern = undefined;
|
|
19
19
|
export let rows = 3;
|
|
20
20
|
export let value = '';
|
|
21
|
+
export let action = prefixHttps;
|
|
21
22
|
value = name ? values[name] ?? value : value;
|
|
22
23
|
|
|
23
24
|
let className = '';
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
{readonly}
|
|
61
62
|
{pattern}
|
|
62
63
|
{value}
|
|
63
|
-
use:
|
|
64
|
+
use:action
|
|
64
65
|
on:input={onInput}
|
|
65
66
|
/>
|
|
66
67
|
{/if}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
|
-
import { show } from '../../actions';
|
|
3
|
+
import { show, prefixMail, prefixTel } from '../../actions';
|
|
4
4
|
|
|
5
5
|
import Panel from '../Panel';
|
|
6
6
|
import RadioGroup from '../RadioGroup';
|
|
7
7
|
import NodeSelector from '../NodeSelector';
|
|
8
8
|
import InputField from '../InputField';
|
|
9
9
|
import Checkbox from '../Checkbox';
|
|
10
|
+
import getSavedValue from './api/getSavedValue';
|
|
10
11
|
|
|
11
|
-
const values = window.CONFIG_VALUES || {};
|
|
12
12
|
const dispatch = createEventDispatcher();
|
|
13
13
|
|
|
14
14
|
export let heading;
|
|
@@ -17,20 +17,7 @@
|
|
|
17
17
|
export let required = false;
|
|
18
18
|
export let types = ['internal', 'external', 'file'];
|
|
19
19
|
export let value;
|
|
20
|
-
|
|
21
|
-
if (!value || Object.keys(value).length === 0) {
|
|
22
|
-
value = {
|
|
23
|
-
type: types[0],
|
|
24
|
-
newWindow: false,
|
|
25
|
-
value: '',
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (name) {
|
|
30
|
-
value.type = values[`${name}Type`] || value.type;
|
|
31
|
-
value.newWindow = values[`${name}NewWindow`] || value.newWindow;
|
|
32
|
-
value.value = values[`${name}Value`] || value.value || '';
|
|
33
|
-
}
|
|
20
|
+
value = getSavedValue({ value, name, types });
|
|
34
21
|
|
|
35
22
|
let className = '';
|
|
36
23
|
export { className as class };
|
|
@@ -110,12 +97,13 @@
|
|
|
110
97
|
required={required && isFile}
|
|
111
98
|
/>
|
|
112
99
|
</div>
|
|
100
|
+
|
|
113
101
|
<div class="sr-label form-group form-group--mail" use:show={isMail}>
|
|
114
102
|
<InputField
|
|
115
103
|
bind:value={selected.mail}
|
|
116
104
|
{disabled}
|
|
117
105
|
label="E-post"
|
|
118
|
-
|
|
106
|
+
action={prefixMail}
|
|
119
107
|
on:change={onChange}
|
|
120
108
|
required={required && isMail}
|
|
121
109
|
/>
|
|
@@ -124,8 +112,9 @@
|
|
|
124
112
|
<InputField
|
|
125
113
|
bind:value={selected.tel}
|
|
126
114
|
{disabled}
|
|
127
|
-
label="
|
|
128
|
-
type="
|
|
115
|
+
label="Telefonnummer"
|
|
116
|
+
type="tel"
|
|
117
|
+
action={prefixTel}
|
|
129
118
|
on:change={onChange}
|
|
130
119
|
required={required && isTel}
|
|
131
120
|
/>
|
|
@@ -141,7 +130,7 @@
|
|
|
141
130
|
<slot name="bottom" />
|
|
142
131
|
</Panel>
|
|
143
132
|
|
|
144
|
-
<style>
|
|
133
|
+
<style lang="scss">
|
|
145
134
|
.sr-label :global(label),
|
|
146
135
|
.sr-legend :global(legend) {
|
|
147
136
|
position: absolute;
|
|
@@ -154,7 +143,11 @@
|
|
|
154
143
|
clip: rect(0, 0, 0, 0);
|
|
155
144
|
}
|
|
156
145
|
|
|
157
|
-
.form-group--external
|
|
158
|
-
|
|
146
|
+
.form-group--external,
|
|
147
|
+
.form-group--mail,
|
|
148
|
+
.form-group--tel {
|
|
149
|
+
:global(.form-control-feedback) {
|
|
150
|
+
top: 0;
|
|
151
|
+
}
|
|
159
152
|
}
|
|
160
153
|
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const getDefaultValue = (types) => ({
|
|
2
|
+
type: types[0],
|
|
3
|
+
newWindow: false,
|
|
4
|
+
value: '',
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export default function getSavedValue({ value, name, types }) {
|
|
8
|
+
const values = window.CONFIG_VALUES || {};
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
...getDefaultValue(types),
|
|
12
|
+
...value,
|
|
13
|
+
...(name ? {
|
|
14
|
+
type: values[`${name}Type`],
|
|
15
|
+
newWindow: values[`${name}NewWindow`],
|
|
16
|
+
value: values[`${name}Value`],
|
|
17
|
+
} : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
dispatch('change', value);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
$: component = type.endsWith('-list') ? type : `${type}-page`;
|
|
27
|
+
|
|
26
28
|
onMount(() => {
|
|
27
29
|
const element = setupComponent(id)[0];
|
|
28
30
|
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
{id}
|
|
45
47
|
{name}
|
|
46
48
|
type="hidden"
|
|
47
|
-
data-component={
|
|
49
|
+
data-component={component}
|
|
48
50
|
{required}
|
|
49
51
|
data-types={selectable}
|
|
50
52
|
value={value.join(',')}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# ListSelector
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Wrapper for list components
|
|
4
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-Listcomponents>
|
|
4
5
|
|
|
5
6
|
<!-- TOC -->
|
|
6
7
|
|
|
@@ -9,6 +10,7 @@ https://developer.sitevision.se/docs/webapps/configuration#h-Listcomponents
|
|
|
9
10
|
- [Standard](#standard)
|
|
10
11
|
- [Advanced](#advanced)
|
|
11
12
|
- [Slots](#slots)
|
|
13
|
+
- [Type prop shorthand (since 1.3.0)](#type-prop-shorthand-since-130)
|
|
12
14
|
- [Selectable types](#selectable-types)
|
|
13
15
|
|
|
14
16
|
<!-- /TOC -->
|
|
@@ -23,7 +25,7 @@ export let name;
|
|
|
23
25
|
// Field label
|
|
24
26
|
export let label;
|
|
25
27
|
// List component type.
|
|
26
|
-
export let type = 'page
|
|
28
|
+
export let type = 'page';
|
|
27
29
|
// Used if bound to v-model, falls back to provided values object when name attribute is used.
|
|
28
30
|
export let value = [];
|
|
29
31
|
// If list is required.
|
|
@@ -37,15 +39,15 @@ export let selectable = [];
|
|
|
37
39
|
|
|
38
40
|
## Example
|
|
39
41
|
|
|
40
|
-
|
|
41
42
|
### Standard
|
|
43
|
+
|
|
42
44
|
```svelte
|
|
43
45
|
<script>
|
|
44
46
|
import { Panel, ListSelector } from '@soleil-se/svelte-config';
|
|
45
47
|
</script>
|
|
46
48
|
|
|
47
49
|
<Panel heading="Inställningar">
|
|
48
|
-
<ListSelector name="pages" type="page
|
|
50
|
+
<ListSelector name="pages" type="page" label="Sidor" />
|
|
49
51
|
</Panel>
|
|
50
52
|
```
|
|
51
53
|
|
|
@@ -71,20 +73,32 @@ onSave(() => values);
|
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
## Slots
|
|
76
|
+
|
|
74
77
|
Default slot after list.
|
|
78
|
+
|
|
75
79
|
```svelte
|
|
76
80
|
<ListSelector name="pages" type="page-list" label="Sidor" />
|
|
77
81
|
<p class="help-block">Some helpful text.</p>
|
|
78
82
|
</ListSelector>
|
|
79
83
|
```
|
|
80
84
|
|
|
85
|
+
## Type prop shorthand (since 1.3.0)
|
|
86
|
+
|
|
87
|
+
You can omnit the `-list` suffix for the type prop.
|
|
88
|
+
|
|
89
|
+
```svelte
|
|
90
|
+
<ListSelector name="pages" type="page" label="Sidor" />
|
|
91
|
+
```
|
|
92
|
+
|
|
81
93
|
## Selectable types
|
|
94
|
+
|
|
82
95
|
> :exclamation: Since SiteVision 7.0 :exclamation:
|
|
83
96
|
|
|
84
|
-
Filter what types should be selectable. See available types here:
|
|
85
|
-
https://developer.sitevision.se/docs/webapps/configuration#h-Types-0
|
|
97
|
+
Filter what types should be selectable. See available types here:
|
|
98
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-Types-0>
|
|
86
99
|
|
|
87
100
|
Accepts an Array or String.
|
|
101
|
+
|
|
88
102
|
```svelte
|
|
89
103
|
<ListSelector
|
|
90
104
|
name="pages"
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
export { className as class };
|
|
25
25
|
|
|
26
26
|
$: required = required && !disabled && !readonly;
|
|
27
|
+
$: component = type.endsWith('-selector') ? type : `${type}-selector`;
|
|
27
28
|
|
|
28
29
|
let displayName = '';
|
|
29
30
|
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
{disabled}
|
|
60
61
|
{readonly}
|
|
61
62
|
data-removable={removable}
|
|
62
|
-
data-component={
|
|
63
|
+
data-component={component}
|
|
63
64
|
data-types={selectable}
|
|
64
65
|
value={displayName}
|
|
65
66
|
data-value={value}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# NodeSelector
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Wrapper for node selectors.
|
|
4
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents>
|
|
4
5
|
|
|
5
6
|
<!-- TOC -->
|
|
6
7
|
|
|
@@ -9,6 +10,7 @@ https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponent
|
|
|
9
10
|
- [Standard](#standard)
|
|
10
11
|
- [Advanced](#advanced)
|
|
11
12
|
- [Slots](#slots)
|
|
13
|
+
- [Type prop shorthand (since 1.3.0)](#type-prop-shorthand-since-130)
|
|
12
14
|
- [Selectable types](#selectable-types)
|
|
13
15
|
|
|
14
16
|
<!-- /TOC -->
|
|
@@ -30,12 +32,14 @@ export let value = '';
|
|
|
30
32
|
## Example
|
|
31
33
|
|
|
32
34
|
### Standard
|
|
35
|
+
|
|
33
36
|
```svelte
|
|
34
37
|
<script>
|
|
35
38
|
import { Panel, NodeSelector } from '@soleil-se/svelte-config';
|
|
36
39
|
</script>
|
|
37
40
|
```
|
|
38
|
-
|
|
41
|
+
|
|
42
|
+
<Panel heading="Inställningar">
|
|
39
43
|
<NodeSelector
|
|
40
44
|
name="page"
|
|
41
45
|
type="page-selector"
|
|
@@ -65,20 +69,32 @@ onSave(() => values);
|
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
## Slots
|
|
72
|
+
|
|
68
73
|
Default slot after selector.
|
|
74
|
+
|
|
69
75
|
```svelte
|
|
70
76
|
<NodeSelector name="page" label="Page" type="page-selector" />
|
|
71
77
|
<p class="help-block">Some helpful text.</p>
|
|
72
78
|
</NodeSelector>
|
|
73
79
|
```
|
|
74
80
|
|
|
81
|
+
## Type prop shorthand (since 1.3.0)
|
|
82
|
+
|
|
83
|
+
You can omnit the `-selector` suffix for the type prop.
|
|
84
|
+
|
|
85
|
+
```svelte
|
|
86
|
+
<NodeSelector name="page" type="page" label="Sida" />
|
|
87
|
+
```
|
|
88
|
+
|
|
75
89
|
## Selectable types
|
|
90
|
+
|
|
76
91
|
> :exclamation: Since SiteVision 7.0 :exclamation:
|
|
77
|
-
|
|
78
|
-
Filter what types should be selectable. See available types here:
|
|
79
|
-
https://developer.sitevision.se/docs/webapps/configuration#h-Types
|
|
92
|
+
|
|
93
|
+
Filter what types should be selectable. See available types here:
|
|
94
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-Types>
|
|
80
95
|
|
|
81
96
|
Accepts an Array or String.
|
|
97
|
+
|
|
82
98
|
```svelte
|
|
83
99
|
<NodeSelector
|
|
84
100
|
name="page"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
<div class="form-group">
|
|
23
23
|
<label class="control-label {required ? 'control-label--required' : ''}" for={id}>{label}</label>
|
|
24
|
+
<!-- svelte-ignore a11y-no-onchange -->
|
|
24
25
|
<select class="form-control" bind:value {id} {disabled} {required} {name} on:change={onChange}>
|
|
25
26
|
{#each options as option}
|
|
26
27
|
<option value={option.value || option}>{option.label || option}</option>
|
package/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as NumberSpinner } from './components/NumberSpinner';
|
|
|
10
10
|
export { default as RadioGroup } from './components/RadioGroup';
|
|
11
11
|
export { default as SelectField } from './components/SelectField';
|
|
12
12
|
export { default as TextList } from './components/TextList';
|
|
13
|
+
export { default as ImageSelector } from './components/ImageSelector';
|
|
13
14
|
|
|
14
15
|
export { default as createConfigApp } from './createConfigApp';
|
|
15
16
|
|
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { default as onSave } from './onSave';
|
|
|
3
3
|
export { default as setupComponent } from './setupComponent';
|
|
4
4
|
export { default as addPrefix } from './addPrefix';
|
|
5
5
|
export { default as pluckPrefix } from './pluckPrefix';
|
|
6
|
+
export { default as triggerInput } from './triggerInput';
|
package/actions/httpPrefix.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default function httpPrefix(node) {
|
|
2
|
-
const addPrefix = () => {
|
|
3
|
-
const { type, value } = node;
|
|
4
|
-
if (type === 'url' && value && !/^(https?):\/\//i.test(value) && ('http://'.indexOf(value) === -1 && 'https://'.indexOf(value) === -1)) {
|
|
5
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
6
|
-
node.value = `https://${value}`;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
node.addEventListener('input', addPrefix);
|
|
10
|
-
}
|