@soleil-se/config-svelte 1.10.0 → 1.11.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
CHANGED
|
@@ -5,6 +5,16 @@ 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.11.0] - 2022-03-29
|
|
9
|
+
|
|
10
|
+
- Add settings for decorative images in [ImageSelector](./components/ImageSelector).
|
|
11
|
+
- Fetch image alt text in offline mode in [ImageSelector](./components/ImageSelector).
|
|
12
|
+
|
|
13
|
+
## [1.10.1] - 2022-03-08
|
|
14
|
+
|
|
15
|
+
- Cast saved value to Number in [NumberSpinner](./components/NumberSpinner).
|
|
16
|
+
- Fix reactivity for `suffix` prop in [NumberSpinner](./components/NumberSpinner).
|
|
17
|
+
|
|
8
18
|
## [1.10.0] - 2022-03-07
|
|
9
19
|
|
|
10
20
|
- Added `multiple` prop for [CustomSelector](./components/CustomSelector).
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
export let node;
|
|
18
18
|
export let alt;
|
|
19
19
|
alt = name ? values[`${name}Alt`] ?? alt : alt;
|
|
20
|
+
export let hideDecorative = false;
|
|
21
|
+
export let decorative = false;
|
|
22
|
+
$: decorative = hideDecorative ? false : decorative;
|
|
20
23
|
|
|
21
24
|
let imageArchiveAlt = '';
|
|
22
25
|
let useCustomAlt = !!alt;
|
|
@@ -26,12 +29,12 @@
|
|
|
26
29
|
const dispatch = createEventDispatcher();
|
|
27
30
|
|
|
28
31
|
const setCustomValidity = () => {
|
|
29
|
-
validationEl?.setCustomValidity(imageArchiveAlt ? '' :
|
|
32
|
+
validationEl?.setCustomValidity(imageArchiveAlt ? '' : i18n('validation'));
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
const onChange = async () => {
|
|
33
36
|
if (node) {
|
|
34
|
-
const response = await fetch(`/rest-api/1/
|
|
37
|
+
const response = await fetch(`/rest-api/1/0/${node}/properties`).then((res) => res.json());
|
|
35
38
|
imageArchiveAlt = response.alt || '';
|
|
36
39
|
|
|
37
40
|
setCustomValidity();
|
|
@@ -73,12 +76,37 @@
|
|
|
73
76
|
on:change={onChange}
|
|
74
77
|
{required}
|
|
75
78
|
/>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
<div>
|
|
80
|
+
{#if !hideDecorative}
|
|
81
|
+
<Checkbox
|
|
82
|
+
class="checkbox-group"
|
|
83
|
+
bind:value={decorative}
|
|
84
|
+
name="{name}Decorative"
|
|
85
|
+
label={i18n('imageIsDecorative')}
|
|
86
|
+
on:change={onChange}
|
|
87
|
+
/>
|
|
88
|
+
{/if}
|
|
89
|
+
{#if !decorative}
|
|
90
|
+
{#if useCustomAlt}
|
|
91
|
+
<InputField name="{name}Alt" label={i18n('altText')} required bind:value={alt} />
|
|
92
|
+
{:else}
|
|
93
|
+
<InputField label={i18n('altFromCaption')} value={imageArchiveAlt} readonly disabled>
|
|
94
|
+
<input bind:this={validationEl} class="sr-only" />
|
|
95
|
+
</InputField>
|
|
96
|
+
{/if}
|
|
97
|
+
|
|
98
|
+
<Checkbox
|
|
99
|
+
class="checkbox-group"
|
|
100
|
+
bind:value={useCustomAlt}
|
|
101
|
+
label={i18n('customAltText')}
|
|
102
|
+
on:change={onUseCustomToggle}
|
|
103
|
+
/>
|
|
104
|
+
{/if}
|
|
105
|
+
</div>
|
|
84
106
|
</Panel>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
div > :global(.checkbox-group) {
|
|
110
|
+
margin-top: -5px;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
@@ -16,14 +16,14 @@ Custom panel component for selecting an image.
|
|
|
16
16
|
## AppData
|
|
17
17
|
|
|
18
18
|
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
19
|
-
For example if `name="image"` the values will be available as `imageNode
|
|
19
|
+
For example if `name="image"` the values will be available as `imageNode`, `imageAlt` (if custom alt-text is set) and `imageDecorative` (if image is set as decorative, since 1.11.0).
|
|
20
20
|
|
|
21
21
|
```js
|
|
22
22
|
import appData from 'appData';
|
|
23
23
|
|
|
24
24
|
const getImage = () => ({
|
|
25
25
|
uri: appData.get('imageNode', 'URI'),
|
|
26
|
-
alt: appData.get('imageAlt') || appData.get('imageNode', 'alt'),
|
|
26
|
+
alt: appData.get('imageDecorative') ? '' : appData.get('imageAlt') || appData.get('imageNode', 'alt'),
|
|
27
27
|
});
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -38,8 +38,12 @@ export let name = undefined;
|
|
|
38
38
|
export let required = false;
|
|
39
39
|
// Node ID of selected image.
|
|
40
40
|
export let node;
|
|
41
|
-
// Custom alt text
|
|
41
|
+
// Custom alt text.
|
|
42
42
|
export let alt;
|
|
43
|
+
// If image is decorative, since 1.11.0
|
|
44
|
+
export let decorative = false;
|
|
45
|
+
// If the checkbox for decorative image should be hidden, since 1.11.0
|
|
46
|
+
export let hideDecorative = false;
|
|
43
47
|
```
|
|
44
48
|
|
|
45
49
|
## Example
|
|
@@ -52,6 +56,9 @@ export let alt;
|
|
|
52
56
|
</script>
|
|
53
57
|
|
|
54
58
|
<ImageSelector name="image" heading="Bild" />
|
|
59
|
+
|
|
60
|
+
<!-- If decorative should be checked from the start, since 1.11.0 -->
|
|
61
|
+
<ImageSelector name="image" heading="Bild" decorative />
|
|
55
62
|
```
|
|
56
63
|
|
|
57
64
|
### Advanced
|
|
@@ -7,6 +7,8 @@ export default createI18n({
|
|
|
7
7
|
altText: 'Alt-text',
|
|
8
8
|
altFromCaption: 'Alt-text (från bildbeskrivning)',
|
|
9
9
|
customAltText: 'Ange egen alt-text',
|
|
10
|
+
validation: 'Bilden saknar beskrivning (alt-text). Klicka på bilden ovan och skriv texten i fältet Bildbeskrivning.',
|
|
11
|
+
imageIsDecorative: 'Bilden är dekorativ',
|
|
10
12
|
},
|
|
11
13
|
no: {
|
|
12
14
|
heading: 'Bilde',
|
|
@@ -14,6 +16,8 @@ export default createI18n({
|
|
|
14
16
|
altText: 'Alt-tekst',
|
|
15
17
|
altFromCaption: 'Alt-tekst (fra bildebeskrivelse)',
|
|
16
18
|
customAltText: 'Skriv inn din egen alt-tekst',
|
|
19
|
+
validation: 'Bildet mangler beskrivelse (alt-tekst). Klikk på bildet over og skriv inn teksten i feltet Bildebeskrivelse.',
|
|
20
|
+
imageIsDecorative: 'Bildet er dekorativt',
|
|
17
21
|
},
|
|
18
22
|
en: {
|
|
19
23
|
heading: 'Image',
|
|
@@ -21,5 +25,7 @@ export default createI18n({
|
|
|
21
25
|
altText: 'Alt text',
|
|
22
26
|
altFromCaption: 'Alt text (from image caption)',
|
|
23
27
|
customAltText: 'Use custom alt text',
|
|
28
|
+
validation: 'The image lacks description (alt-text). Click on the image above and enter the text in the Image description field.',
|
|
29
|
+
imageIsDecorative: 'Image is decorative',
|
|
24
30
|
},
|
|
25
31
|
});
|
|
@@ -15,20 +15,24 @@
|
|
|
15
15
|
export let readonly = false;
|
|
16
16
|
export let suffix;
|
|
17
17
|
export let value = min || 1;
|
|
18
|
-
value = name ? values[name] ?? value : value;
|
|
18
|
+
value = Number(name ? values[name] ?? value : value);
|
|
19
19
|
value = min && value < Number(min) ? min : value;
|
|
20
20
|
value = max && value > Number(max) ? max : value;
|
|
21
21
|
|
|
22
|
+
let element;
|
|
23
|
+
|
|
24
|
+
$: {
|
|
25
|
+
if (element && suffix) {
|
|
26
|
+
element.parentNode.querySelector('.input-group-addon').innerHTML = suffix;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
onMount(() => {
|
|
23
|
-
|
|
31
|
+
[element] = setupComponent(id).on('change', ({ target }) => {
|
|
24
32
|
value = Number(target.value);
|
|
25
33
|
dispatch('input', value);
|
|
26
34
|
dispatch('change', value);
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
if (suffix) {
|
|
30
|
-
el.parentNode.querySelector('.input-group-addon').innerHTML = suffix;
|
|
31
|
-
}
|
|
35
|
+
});
|
|
32
36
|
});
|
|
33
37
|
</script>
|
|
34
38
|
|
|
@@ -71,8 +75,8 @@
|
|
|
71
75
|
width: 100%;
|
|
72
76
|
height: 34px;
|
|
73
77
|
margin-top: -34px;
|
|
74
|
-
background-color: rgb(255 255 255 / 30%);
|
|
75
78
|
cursor: not-allowed;
|
|
79
|
+
background-color: rgb(255 255 255 / 30%);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
.form-group :global(.input-group-addon) {
|