@soleil-se/config-svelte 1.2.1 → 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 +11 -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/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/components/TextList/internal/triggerInput.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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.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
|
+
|
|
8
19
|
## [1.2.1] - 2021-04-09
|
|
9
20
|
|
|
10
21
|
### Fixed
|
|
@@ -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';
|
|
@@ -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';
|