@soleil-se/config-svelte 1.4.0 → 1.5.1
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 +17 -5
- package/components/DropdownSelector/Component.svelte +16 -5
- package/components/InputField/Component.svelte +1 -0
- package/components/NodeSelector/Component.svelte +4 -0
- package/components/TagSelector/Component.svelte +73 -0
- package/components/TagSelector/README.md +71 -0
- package/components/TagSelector/index.js +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/yarn-error.log +605 -1345
package/CHANGELOG.md
CHANGED
|
@@ -5,33 +5,45 @@ 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.5.1] - 2021-08-12
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Initialization when rerendering or conditionally render DropdownSelectors.
|
|
13
|
+
|
|
14
|
+
## [1.5.0] - 2021-06-29
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- TagSelector component
|
|
19
|
+
|
|
8
20
|
## [1.4.0] - 2021-05-19
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
### Changed
|
|
11
23
|
|
|
12
24
|
- TextList component rewrite.
|
|
13
25
|
- Remove CheckboxGroup value workaround as it's not needed.
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
### Fixed
|
|
16
28
|
|
|
17
29
|
- Type shorthand for ListSelector.
|
|
18
30
|
- Was possible to circumvent alt-text requirement in ImageSelector
|
|
19
31
|
|
|
20
32
|
## [1.3.1] - 2021-04-29
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
### Fixed
|
|
23
35
|
|
|
24
36
|
- Default value for LinkSelector type is not set.
|
|
25
37
|
- ImageSelector does not clear alt-text from image archive.
|
|
26
38
|
|
|
27
39
|
## [1.3.0] - 2021-04-28
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
### Added
|
|
30
42
|
|
|
31
43
|
- Type shorthands for DropdownSelector, NodeSelector and ListSelector.
|
|
32
44
|
- ImageSelector component.
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
### Fixed
|
|
35
47
|
|
|
36
48
|
- Scroll problems.
|
|
37
49
|
|
|
@@ -24,19 +24,30 @@
|
|
|
24
24
|
|
|
25
25
|
$: component = type.endsWith('-selector') ? type : `${type}-selector`;
|
|
26
26
|
|
|
27
|
+
const setValue = (target) => {
|
|
28
|
+
hidden = false;
|
|
29
|
+
jQuery(target).val(value).trigger('change');
|
|
30
|
+
};
|
|
31
|
+
|
|
27
32
|
onMount(() => {
|
|
28
|
-
setupComponent(id)
|
|
33
|
+
const [el] = setupComponent(id)
|
|
29
34
|
.on('change', (e) => {
|
|
30
35
|
value = e.val || value;
|
|
36
|
+
if (name) values[name] = value;
|
|
31
37
|
dispatch('input', value);
|
|
32
38
|
dispatch('change', value);
|
|
33
39
|
})
|
|
34
40
|
.on('sv:loaded', ({ target }) => {
|
|
35
|
-
|
|
36
|
-
jQuery(target)
|
|
37
|
-
.val(value)
|
|
38
|
-
.trigger('change');
|
|
41
|
+
setValue(target);
|
|
39
42
|
});
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* The sv:loaded event is only triggered on initial load, if the component rerenders check if any
|
|
46
|
+
* children are present and set value of select element.
|
|
47
|
+
*/
|
|
48
|
+
if (el?.childElementCount > 0) {
|
|
49
|
+
setValue(el);
|
|
50
|
+
}
|
|
40
51
|
});
|
|
41
52
|
</script>
|
|
42
53
|
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
dispatch('change', value);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
if (type.startsWith('tags')) {
|
|
37
|
+
throw new Error('Type \'tags-selector\' is not supported, use TagsSelector component.');
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
onMount(async () => {
|
|
37
41
|
setupComponent(id).on('change', ({ target }) => {
|
|
38
42
|
value = target.dataset.value;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/* eslint-disable no-undef-init */
|
|
3
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
4
|
+
import { generateId, setupComponent } from '../../utils';
|
|
5
|
+
|
|
6
|
+
const values = window.CONFIG_VALUES || {};
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
|
|
9
|
+
export let id = generateId();
|
|
10
|
+
export let label;
|
|
11
|
+
export let name;
|
|
12
|
+
export let required = false;
|
|
13
|
+
export let disabled = false;
|
|
14
|
+
|
|
15
|
+
export let selectable = [];
|
|
16
|
+
export let value = '';
|
|
17
|
+
|
|
18
|
+
selectable = Array.isArray(selectable) ? selectable.join(',') : selectable;
|
|
19
|
+
value = name ? values[name] ?? value : value;
|
|
20
|
+
|
|
21
|
+
let className = '';
|
|
22
|
+
export { className as class };
|
|
23
|
+
|
|
24
|
+
$: required = required && !disabled;
|
|
25
|
+
|
|
26
|
+
const onChange = () => {
|
|
27
|
+
dispatch('input', value);
|
|
28
|
+
dispatch('change', value);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
onMount(async () => {
|
|
32
|
+
setupComponent(id).on('change', ({ target }) => {
|
|
33
|
+
value = target.value.split(',');
|
|
34
|
+
|
|
35
|
+
onChange();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// When component is mounted the value from SiteVision will be an object.
|
|
39
|
+
// However when the value is saved to the server SiteVision expects an id.
|
|
40
|
+
if (value) {
|
|
41
|
+
value = value.map((tag) => tag.value);
|
|
42
|
+
onChange();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class="form-group {className}">
|
|
48
|
+
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
49
|
+
<input
|
|
50
|
+
class="form-control"
|
|
51
|
+
{id}
|
|
52
|
+
{name}
|
|
53
|
+
{required}
|
|
54
|
+
{disabled}
|
|
55
|
+
data-component="tags-selector"
|
|
56
|
+
{value}
|
|
57
|
+
/>
|
|
58
|
+
{#if disabled}
|
|
59
|
+
<div class="disabled-overlay" />
|
|
60
|
+
{/if}
|
|
61
|
+
<slot />
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<style>
|
|
65
|
+
.disabled-overlay {
|
|
66
|
+
position: relative;
|
|
67
|
+
z-index: 3;
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 34px;
|
|
70
|
+
margin-top: -34px;
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# TagSelector
|
|
2
|
+
|
|
3
|
+
Wrapper for tag selector.
|
|
4
|
+
<https://developer.sitevision.se/docs/webapps/configuration#h-SiteVisioncomponents>
|
|
5
|
+
|
|
6
|
+
<!-- TOC -->
|
|
7
|
+
|
|
8
|
+
- [Props](#props)
|
|
9
|
+
- [Example](#example)
|
|
10
|
+
- [Standard](#standard)
|
|
11
|
+
- [Advanced](#advanced)
|
|
12
|
+
- [Slots](#slots)
|
|
13
|
+
|
|
14
|
+
<!-- /TOC -->
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
export let id = generateId();
|
|
19
|
+
export let label; // Required
|
|
20
|
+
export let name; // Required
|
|
21
|
+
export let required = false;
|
|
22
|
+
export let disabled = false;
|
|
23
|
+
export let value = [];
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
### Standard
|
|
29
|
+
|
|
30
|
+
```svelte
|
|
31
|
+
<script>
|
|
32
|
+
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<Panel heading="Inställningar">
|
|
36
|
+
<TagSelector name="tags" label="Etiketter" />
|
|
37
|
+
</Panel>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Advanced
|
|
41
|
+
|
|
42
|
+
Name prop is required here as well since Sitevision uses this to initialize the component.
|
|
43
|
+
|
|
44
|
+
```svelte
|
|
45
|
+
<script>
|
|
46
|
+
import { Panel, TagSelector } from '@soleil-se/svelte-config';
|
|
47
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
48
|
+
|
|
49
|
+
const values = {
|
|
50
|
+
tags: [],
|
|
51
|
+
...window.CONFIG_VALUES
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
onSave(() => values);
|
|
55
|
+
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<Panel heading="Inställningar">
|
|
59
|
+
<TagSelector bind:value={values.tags} label="Etiketter" name="tags" />
|
|
60
|
+
</Panel>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Slots
|
|
64
|
+
|
|
65
|
+
Default slot after selector.
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<TagSelector name="tags" label="Etiketter" />
|
|
69
|
+
<p class="help-block">Some helpful text.</p>
|
|
70
|
+
</TagSelector>
|
|
71
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Component.svelte';
|
package/index.js
CHANGED
|
@@ -11,6 +11,7 @@ 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
13
|
export { default as ImageSelector } from './components/ImageSelector';
|
|
14
|
+
export { default as TagSelector } from './components/TagSelector';
|
|
14
15
|
|
|
15
16
|
export { default as createConfigApp } from './createConfigApp';
|
|
16
17
|
|