@soleil-se/config-svelte 1.4.0 → 1.5.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 +6 -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,6 +5,12 @@ 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.0] - 2021-06-29
|
|
9
|
+
|
|
10
|
+
## Added
|
|
11
|
+
|
|
12
|
+
- TagSelector component
|
|
13
|
+
|
|
8
14
|
## [1.4.0] - 2021-05-19
|
|
9
15
|
|
|
10
16
|
## Changed
|
|
@@ -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
|
|