@soleil-se/config-svelte 1.5.2 → 1.7.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 +15 -0
- package/components/Checkbox/Component.svelte +7 -0
- package/components/Checkbox/README.md +5 -0
- package/components/CheckboxGroup/Component.svelte +7 -1
- package/components/CheckboxGroup/README.md +7 -0
- package/components/DropdownSelector/Component.svelte +7 -0
- package/components/DropdownSelector/README.md +21 -2
- package/components/ImageSelector/Component.svelte +13 -14
- package/components/ImageSelector/README.md +3 -1
- package/components/ImageSelector/i18n.js +25 -0
- package/components/InputField/Component.svelte +23 -7
- package/components/InputField/README.md +18 -11
- package/components/LinkSelector/Component.svelte +20 -12
- package/components/LinkSelector/README.md +42 -13
- package/components/LinkSelector/i18n.js +31 -0
- package/components/ListSelector/Component.svelte +11 -3
- package/components/ListSelector/README.md +14 -11
- package/components/NodeSelector/Component.svelte +7 -0
- package/components/NodeSelector/README.md +12 -11
- package/components/NumberSpinner/Component.svelte +7 -0
- package/components/NumberSpinner/README.md +16 -9
- package/components/Panel/Component.svelte +10 -1
- package/components/Panel/README.md +6 -3
- package/components/Panel/i18n.js +13 -0
- package/components/RadioGroup/Component.svelte +26 -21
- package/components/RadioGroup/README.md +6 -0
- package/components/SelectField/Component.svelte +7 -0
- package/components/SelectField/README.md +17 -9
- package/components/TagSelector/Component.svelte +7 -0
- package/components/TagSelector/README.md +11 -10
- package/components/TextList/Component.svelte +10 -2
- package/components/TextList/README.md +9 -0
- package/components/TextList/i18n.js +13 -0
- package/package.json +1 -1
- package/utils/createI18n.js +29 -0
- package/utils/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ 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.7.0] - 2021-09-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `sortable` prop for `ListSelector`.
|
|
13
|
+
|
|
14
|
+
## [1.6.0] - 2021-08-25
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- I18n utility.
|
|
19
|
+
- Translations for components with translatable text.
|
|
20
|
+
- Spread rest props on input element in InputField.
|
|
21
|
+
- Docs with links to readme for each component.
|
|
22
|
+
|
|
8
23
|
## [1.5.2] - 2021-08-18
|
|
9
24
|
|
|
10
25
|
### Fixed
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Checkbox
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
4
6
|
|
|
5
7
|
```javascript
|
|
@@ -12,10 +14,13 @@ export let value;
|
|
|
12
14
|
```
|
|
13
15
|
|
|
14
16
|
## Default value
|
|
17
|
+
|
|
15
18
|
Use checked attribute if the checkbox should be checked as default
|
|
19
|
+
|
|
16
20
|
```svelte
|
|
17
21
|
<Checkbox name="checkbox" label="Checkbox" checked />
|
|
18
22
|
```
|
|
23
|
+
|
|
19
24
|
## Examples
|
|
20
25
|
|
|
21
26
|
### Standard
|
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
};
|
|
30
30
|
</script>
|
|
31
31
|
|
|
32
|
+
<!--
|
|
33
|
+
@component
|
|
34
|
+
A checkbox group component.
|
|
35
|
+
|
|
36
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/CheckboxGroup/)
|
|
37
|
+
-->
|
|
38
|
+
|
|
32
39
|
<fieldset class="form-group {className}">
|
|
33
40
|
<legend>{legend}</legend>
|
|
34
41
|
{#each options as option, index}
|
|
@@ -104,5 +111,4 @@
|
|
|
104
111
|
input {
|
|
105
112
|
margin: -1px;
|
|
106
113
|
}
|
|
107
|
-
|
|
108
114
|
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# CheckboxGroup
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
## Props
|
|
6
|
+
|
|
4
7
|
```javascript
|
|
5
8
|
// ID, generates automatically if nothing is passed
|
|
6
9
|
export let id = generateId();
|
|
@@ -17,7 +20,9 @@ export let value;
|
|
|
17
20
|
```
|
|
18
21
|
|
|
19
22
|
## Default value
|
|
23
|
+
|
|
20
24
|
Use the value prop to set a default value when not binding the value:
|
|
25
|
+
|
|
21
26
|
```svelte
|
|
22
27
|
<CheckboxGroup
|
|
23
28
|
name="checkboxGroup1"
|
|
@@ -30,6 +35,7 @@ Use the value prop to set a default value when not binding the value:
|
|
|
30
35
|
## Example
|
|
31
36
|
|
|
32
37
|
### Standard
|
|
38
|
+
|
|
33
39
|
```svelte
|
|
34
40
|
<script>
|
|
35
41
|
import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
@@ -55,6 +61,7 @@ import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
### Advanced
|
|
64
|
+
|
|
58
65
|
```svelte
|
|
59
66
|
<script>
|
|
60
67
|
import { Panel, CheckboxGroup } from '@soleil-se/svelte-config';
|
|
@@ -50,6 +50,13 @@
|
|
|
50
50
|
});
|
|
51
51
|
</script>
|
|
52
52
|
|
|
53
|
+
<!--
|
|
54
|
+
@component
|
|
55
|
+
Wrapper component for Sitevision [dropdown selectors](https://developer.sitevision.se/docs/webapps/configuration#h-Sitevisioncomponents).
|
|
56
|
+
|
|
57
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/DropdownSelector/)
|
|
58
|
+
-->
|
|
59
|
+
|
|
53
60
|
<div class="form-group {className}" {hidden}>
|
|
54
61
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
55
62
|
<select
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
# DropdownSelector
|
|
2
2
|
|
|
3
|
+
Wrapper component for Sitevision [dropdown selectors](https://developer.sitevision.se/docs/webapps/configuration#h-Sitevisioncomponents).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
# DropdownSelector
|
|
8
|
+
|
|
3
9
|
<!-- TOC -->
|
|
4
10
|
|
|
5
11
|
- [Props](#props)
|
|
12
|
+
- [Type](#type)
|
|
6
13
|
- [Example](#example)
|
|
7
14
|
- [Standard](#standard)
|
|
8
15
|
- [Advanced](#advanced)
|
|
@@ -24,6 +31,18 @@ export let disabled = false;
|
|
|
24
31
|
export let value = '';
|
|
25
32
|
```
|
|
26
33
|
|
|
34
|
+
### Type
|
|
35
|
+
|
|
36
|
+
Possible values for `type`:
|
|
37
|
+
|
|
38
|
+
- `metadata`
|
|
39
|
+
- `template`
|
|
40
|
+
- `oauth2-configuration`
|
|
41
|
+
- `virtual-group`
|
|
42
|
+
- `search-index`
|
|
43
|
+
- `font`
|
|
44
|
+
- `color`
|
|
45
|
+
|
|
27
46
|
## Example
|
|
28
47
|
|
|
29
48
|
### Standard
|
|
@@ -34,7 +53,7 @@ import { Panel, DropdownSelector } from '@soleil-se/svelte-config';
|
|
|
34
53
|
</script>
|
|
35
54
|
|
|
36
55
|
<Panel heading="Inställningar">
|
|
37
|
-
<DropdownSelector name="metadata" type="metadata
|
|
56
|
+
<DropdownSelector name="metadata" type="metadata" label="Metadata" />
|
|
38
57
|
</Panel>
|
|
39
58
|
```
|
|
40
59
|
|
|
@@ -55,7 +74,7 @@ onSave(() => values);
|
|
|
55
74
|
</script>
|
|
56
75
|
|
|
57
76
|
<Panel heading="Inställningar">
|
|
58
|
-
<DropdownSelector bind:value={values.metadata} type="metadata
|
|
77
|
+
<DropdownSelector bind:value={values.metadata} type="metadata" label="Metadata" />
|
|
59
78
|
</Panel>
|
|
60
79
|
```
|
|
61
80
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
4
|
|
|
5
5
|
import { triggerInput } from '../../utils';
|
|
6
|
+
import i18n from './i18n';
|
|
6
7
|
import Panel from '../Panel';
|
|
7
8
|
import NodeSelector from '../NodeSelector';
|
|
8
9
|
import InputField from '../InputField';
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
const values = window.CONFIG_VALUES || {};
|
|
12
13
|
|
|
13
14
|
export let name = undefined;
|
|
14
|
-
export let heading = '
|
|
15
|
+
export let heading = i18n('heading');
|
|
15
16
|
export let required = false;
|
|
16
17
|
export let node;
|
|
17
18
|
export let alt;
|
|
@@ -56,30 +57,28 @@
|
|
|
56
57
|
|
|
57
58
|
</script>
|
|
58
59
|
|
|
60
|
+
<!--
|
|
61
|
+
@component
|
|
62
|
+
Custom panel component for selecting an image.
|
|
63
|
+
|
|
64
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/ImageSelector/)
|
|
65
|
+
-->
|
|
66
|
+
|
|
59
67
|
<Panel {heading}>
|
|
60
68
|
<NodeSelector
|
|
61
69
|
name="{name}Node"
|
|
62
|
-
label=
|
|
70
|
+
label={i18n('selectImage')}
|
|
63
71
|
type="image"
|
|
64
72
|
bind:value={node}
|
|
65
73
|
on:change={onChange}
|
|
66
74
|
{required}
|
|
67
75
|
/>
|
|
68
76
|
{#if useCustomAlt}
|
|
69
|
-
<InputField name="{name}Alt" label=
|
|
77
|
+
<InputField name="{name}Alt" label={i18n('altText')} required bind:value={alt} />
|
|
70
78
|
{:else}
|
|
71
|
-
<InputField label=
|
|
79
|
+
<InputField label={i18n('altFromCaption')} value={imageArchiveAlt} readonly disabled>
|
|
72
80
|
<input bind:this={validationEl} class="sr-only" />
|
|
73
81
|
</InputField>
|
|
74
82
|
{/if}
|
|
75
|
-
<
|
|
76
|
-
<Checkbox bind:value={useCustomAlt} label="Ange egen alt-text" on:change={onUseCustomToggle} />
|
|
77
|
-
</div>
|
|
83
|
+
<Checkbox bind:value={useCustomAlt} label={i18n('customAltText')} on:change={onUseCustomToggle} />
|
|
78
84
|
</Panel>
|
|
79
|
-
|
|
80
|
-
<style>
|
|
81
|
-
div {
|
|
82
|
-
margin-top: -10px;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# ImageSelector
|
|
2
2
|
|
|
3
3
|
Custom panel component for selecting an image.
|
|
4
|
+
|
|
5
|
+

|
|
4
6
|
<!-- TOC -->
|
|
5
7
|
|
|
6
8
|
- [AppData](#appdata)
|
|
@@ -13,7 +15,7 @@ Custom panel component for selecting an image.
|
|
|
13
15
|
|
|
14
16
|
## AppData
|
|
15
17
|
|
|
16
|
-
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
18
|
+
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
17
19
|
For example if `name="image"` the values will be available as `imageNode` and `imageAlt` (if custom alt-text is set).
|
|
18
20
|
|
|
19
21
|
```js
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import createI18n from '../../utils/createI18n';
|
|
2
|
+
|
|
3
|
+
export default createI18n({
|
|
4
|
+
sv: {
|
|
5
|
+
heading: 'Bild',
|
|
6
|
+
selectImage: 'Välj bild',
|
|
7
|
+
altText: 'Alt-text',
|
|
8
|
+
altFromCaption: 'Alt-text (från bildbeskrivning)',
|
|
9
|
+
customAltText: 'Ange egen alt-text',
|
|
10
|
+
},
|
|
11
|
+
no: {
|
|
12
|
+
heading: 'Bilde',
|
|
13
|
+
selectImage: 'Velg bilde',
|
|
14
|
+
altText: 'Alt-tekst',
|
|
15
|
+
altFromCaption: 'Alt-tekst (fra bildebeskrivelse)',
|
|
16
|
+
customAltText: 'Skriv inn din egen alt-tekst',
|
|
17
|
+
},
|
|
18
|
+
en: {
|
|
19
|
+
heading: 'Image',
|
|
20
|
+
selectImage: 'Select image',
|
|
21
|
+
altText: 'Alt text',
|
|
22
|
+
altFromCaption: 'Alt text (from image caption)',
|
|
23
|
+
customAltText: 'Use custom alt text',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -7,22 +7,32 @@
|
|
|
7
7
|
const values = window.CONFIG_VALUES || {};
|
|
8
8
|
const dispatch = createEventDispatcher();
|
|
9
9
|
|
|
10
|
+
/** @type {string} */
|
|
10
11
|
export let id = generateId();
|
|
12
|
+
/** @type {string} */
|
|
11
13
|
export let label;
|
|
14
|
+
/** @type {string} */
|
|
12
15
|
export let type = 'text';
|
|
16
|
+
/** @type {string} */
|
|
13
17
|
export let name = undefined;
|
|
18
|
+
/** @type {boolean} */
|
|
14
19
|
export let required = false;
|
|
20
|
+
/** @type {boolean} */
|
|
15
21
|
export let disabled = false;
|
|
22
|
+
/** @type {boolean} */
|
|
16
23
|
export let readonly = false;
|
|
17
|
-
|
|
18
|
-
export let pattern = undefined;
|
|
24
|
+
/** @type {number} */
|
|
19
25
|
export let rows = 3;
|
|
26
|
+
/** @type {string} */
|
|
20
27
|
export let value = '';
|
|
28
|
+
/** @type {function} */
|
|
21
29
|
export let action = prefixHttps;
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
|
|
24
31
|
let className = '';
|
|
32
|
+
/** @type {string} */
|
|
25
33
|
export { className as class };
|
|
34
|
+
|
|
35
|
+
value = name ? values[name] ?? value : value;
|
|
26
36
|
|
|
27
37
|
$: isTextarea = type === 'textarea';
|
|
28
38
|
$: required = required && !disabled && !readonly;
|
|
@@ -34,6 +44,13 @@
|
|
|
34
44
|
};
|
|
35
45
|
</script>
|
|
36
46
|
|
|
47
|
+
<!--
|
|
48
|
+
@component
|
|
49
|
+
Component for input fields and textareas.
|
|
50
|
+
|
|
51
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/InputField/)
|
|
52
|
+
-->
|
|
53
|
+
|
|
37
54
|
<div class="form-group {className}">
|
|
38
55
|
<label for={id} class="control-label {required ? 'control-label--required' : ''}">{label}</label>
|
|
39
56
|
{#if isTextarea}
|
|
@@ -42,11 +59,11 @@
|
|
|
42
59
|
{id}
|
|
43
60
|
{name}
|
|
44
61
|
{required}
|
|
45
|
-
{maxlength}
|
|
46
62
|
{disabled}
|
|
47
63
|
{readonly}
|
|
48
64
|
{value}
|
|
49
65
|
{rows}
|
|
66
|
+
{...$$restProps}
|
|
50
67
|
on:input={onInput}
|
|
51
68
|
/>
|
|
52
69
|
{:else}
|
|
@@ -56,11 +73,10 @@
|
|
|
56
73
|
{name}
|
|
57
74
|
{type}
|
|
58
75
|
{required}
|
|
59
|
-
{maxlength}
|
|
60
76
|
{disabled}
|
|
61
77
|
{readonly}
|
|
62
|
-
{pattern}
|
|
63
78
|
{value}
|
|
79
|
+
{...$$restProps}
|
|
64
80
|
use:action
|
|
65
81
|
on:input={onInput}
|
|
66
82
|
/>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# InputField
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Wrapper for input fields.
|
|
3
4
|
Automatically prefixes https:// if field type is `url`.
|
|
5
|
+
|
|
6
|
+

|
|
4
7
|
<!-- TOC -->
|
|
5
8
|
|
|
6
9
|
- [Props](#props)
|
|
@@ -42,9 +45,10 @@ export let value = '';
|
|
|
42
45
|
## Example
|
|
43
46
|
|
|
44
47
|
### Standard
|
|
48
|
+
|
|
45
49
|
```svelte
|
|
46
50
|
<script>
|
|
47
|
-
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
51
|
+
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
48
52
|
</script>
|
|
49
53
|
|
|
50
54
|
<Panel heading="Inställningar">
|
|
@@ -56,15 +60,15 @@ import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
|
56
60
|
|
|
57
61
|
```svelte
|
|
58
62
|
<script>
|
|
59
|
-
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
60
|
-
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
63
|
+
import { Panel, InputField } from '@soleil-se/svelte-config';
|
|
64
|
+
import { onSave } from '@soleil-se/svelte-config/utils';
|
|
61
65
|
|
|
62
|
-
const values = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
+
const values = {
|
|
67
|
+
text: '',
|
|
68
|
+
...window.CONFIG_VALUES
|
|
69
|
+
};
|
|
66
70
|
|
|
67
|
-
onSave(() => values);
|
|
71
|
+
onSave(() => values);
|
|
68
72
|
|
|
69
73
|
</script>
|
|
70
74
|
|
|
@@ -74,16 +78,19 @@ onSave(() => values);
|
|
|
74
78
|
```
|
|
75
79
|
|
|
76
80
|
## Slots
|
|
81
|
+
|
|
77
82
|
Default slot after input field.
|
|
83
|
+
|
|
78
84
|
```svelte
|
|
79
85
|
<InputField name="text" label="Text">
|
|
80
86
|
<p class="help-block">Some helpful text</p>
|
|
81
87
|
</InputField>
|
|
82
88
|
```
|
|
89
|
+
|
|
83
90
|
## Default value
|
|
91
|
+
|
|
84
92
|
Use the value attribute to set a default value:
|
|
93
|
+
|
|
85
94
|
```svelte
|
|
86
95
|
<InputField name="text" label="Text" value="Default text" />
|
|
87
96
|
```
|
|
88
|
-
|
|
89
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
3
|
import { show, prefixMail, prefixTel } from '../../actions';
|
|
4
|
+
import i18n from './i18n';
|
|
4
5
|
|
|
5
6
|
import Panel from '../Panel';
|
|
6
7
|
import RadioGroup from '../RadioGroup';
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
const dispatch = createEventDispatcher();
|
|
13
14
|
|
|
14
|
-
export let heading;
|
|
15
|
+
export let heading = i18n('heading');
|
|
15
16
|
export let name;
|
|
16
17
|
export let disabled = false;
|
|
17
18
|
export let required = false;
|
|
@@ -23,11 +24,11 @@
|
|
|
23
24
|
export { className as class };
|
|
24
25
|
|
|
25
26
|
$: selectableTypes = [
|
|
26
|
-
{ label: '
|
|
27
|
-
{ label: '
|
|
28
|
-
{ label: '
|
|
29
|
-
{ label: '
|
|
30
|
-
{ label: '
|
|
27
|
+
{ label: i18n('internal'), value: 'internal' },
|
|
28
|
+
{ label: i18n('external'), value: 'external' },
|
|
29
|
+
{ label: i18n('file'), value: 'file' },
|
|
30
|
+
{ label: i18n('mail'), value: 'mail' },
|
|
31
|
+
{ label: i18n('tel'), value: 'tel' },
|
|
31
32
|
].filter((type) => types.includes(type.value));
|
|
32
33
|
|
|
33
34
|
$: isInternal = value.type === 'internal';
|
|
@@ -51,6 +52,13 @@
|
|
|
51
52
|
};
|
|
52
53
|
</script>
|
|
53
54
|
|
|
55
|
+
<!--
|
|
56
|
+
@component
|
|
57
|
+
Custom panel component for selecting a link.
|
|
58
|
+
|
|
59
|
+
[README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/LinkSelector/)
|
|
60
|
+
-->
|
|
61
|
+
|
|
54
62
|
<Panel {heading} class={className} {required}>
|
|
55
63
|
<slot name="top" />
|
|
56
64
|
{#if name}<input type="hidden" name={`${name}Value`} value={value.value} />{/if}
|
|
@@ -72,7 +80,7 @@
|
|
|
72
80
|
bind:value={selected.internal}
|
|
73
81
|
{disabled}
|
|
74
82
|
type="page-selector"
|
|
75
|
-
label=
|
|
83
|
+
label={i18n('internal')}
|
|
76
84
|
on:change={onChange}
|
|
77
85
|
required={required && isInternal}
|
|
78
86
|
/>
|
|
@@ -81,7 +89,7 @@
|
|
|
81
89
|
<InputField
|
|
82
90
|
bind:value={selected.external}
|
|
83
91
|
{disabled}
|
|
84
|
-
label=
|
|
92
|
+
label={i18n('external')}
|
|
85
93
|
type="url"
|
|
86
94
|
on:change={onChange}
|
|
87
95
|
required={required && isExternal}
|
|
@@ -92,7 +100,7 @@
|
|
|
92
100
|
bind:value={selected.file}
|
|
93
101
|
{disabled}
|
|
94
102
|
type="file-selector"
|
|
95
|
-
label=
|
|
103
|
+
label={i18n('file')}
|
|
96
104
|
on:change={onChange}
|
|
97
105
|
required={required && isFile}
|
|
98
106
|
/>
|
|
@@ -102,7 +110,7 @@
|
|
|
102
110
|
<InputField
|
|
103
111
|
bind:value={selected.mail}
|
|
104
112
|
{disabled}
|
|
105
|
-
label=
|
|
113
|
+
label={i18n('mail')}
|
|
106
114
|
action={prefixMail}
|
|
107
115
|
on:change={onChange}
|
|
108
116
|
required={required && isMail}
|
|
@@ -112,7 +120,7 @@
|
|
|
112
120
|
<InputField
|
|
113
121
|
bind:value={selected.tel}
|
|
114
122
|
{disabled}
|
|
115
|
-
label=
|
|
123
|
+
label={i18n('tel')}
|
|
116
124
|
type="tel"
|
|
117
125
|
action={prefixTel}
|
|
118
126
|
on:change={onChange}
|
|
@@ -124,7 +132,7 @@
|
|
|
124
132
|
bind:value={value.newWindow}
|
|
125
133
|
name={name ? `${name}NewWindow` : ''}
|
|
126
134
|
{disabled}
|
|
127
|
-
label=
|
|
135
|
+
label={i18n('newTab')}
|
|
128
136
|
on:change={onChange}
|
|
129
137
|
/>
|
|
130
138
|
<slot name="bottom" />
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
# LinkSelector
|
|
2
|
-
|
|
1
|
+
# LinkSelector (DEPRECATED)
|
|
2
|
+
|
|
3
|
+
Custom panel component for selecting a link.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
::: warning DEPRECATED
|
|
8
|
+
Since Sitevision 9.1 a new type of node selector is avaliable for selecting links.
|
|
9
|
+
[NodeSelector](/03.packages/@soleil&svelte-config/components/NodeSelector/) should be used instead of this component.
|
|
10
|
+
|
|
11
|
+
`App.svelte`
|
|
12
|
+
|
|
13
|
+
```svelte
|
|
14
|
+
<NodeSelector label="Link" type="link" name="link" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
A [sv:link](https://developer.sitevision.se/docs/public-api/node-types/node-types/2018-01-12-svlink) will be returned.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import appData from '@sitevision/api/server/appData';
|
|
21
|
+
|
|
22
|
+
const uri = appData.get('link', 'rawURI');
|
|
23
|
+
const newWindow = appData.get('link', 'openInNewWindow');
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
:::
|
|
3
27
|
|
|
4
28
|
## AppData
|
|
5
|
-
|
|
29
|
+
|
|
30
|
+
If used with standard name all values will be prefixed with the name property provided to the component.
|
|
6
31
|
For example if `name="link"` the values will be available as `linkValue`, `linkType` and `linkNewWindow`.
|
|
7
32
|
|
|
8
33
|
```js
|
|
9
|
-
import appData from 'appData';
|
|
34
|
+
import appData from '@sitevision/api/server/appData';
|
|
10
35
|
|
|
11
36
|
const getLink = () => ({
|
|
12
37
|
value: appData.get('linkValue', 'URI'),
|
|
@@ -15,6 +40,7 @@ const getLink = () => ({
|
|
|
15
40
|
});
|
|
16
41
|
|
|
17
42
|
```
|
|
43
|
+
|
|
18
44
|
## Props
|
|
19
45
|
|
|
20
46
|
```javascript
|
|
@@ -33,7 +59,9 @@ export let value;
|
|
|
33
59
|
```
|
|
34
60
|
|
|
35
61
|
## Slots
|
|
62
|
+
|
|
36
63
|
Top and bottom slots before and after link selector.
|
|
64
|
+
|
|
37
65
|
```svelte
|
|
38
66
|
<LinkSelector
|
|
39
67
|
name="link"
|
|
@@ -62,9 +90,10 @@ Top and bottom slots before and after link selector.
|
|
|
62
90
|
## Example
|
|
63
91
|
|
|
64
92
|
### Standard
|
|
93
|
+
|
|
65
94
|
```svelte
|
|
66
95
|
<script>
|
|
67
|
-
import { LinkSelector } from '@soleil-se/svelte-config';
|
|
96
|
+
import { LinkSelector } from '@soleil-se/svelte-config';
|
|
68
97
|
</script>
|
|
69
98
|
|
|
70
99
|
<LinkSelector name="link" heading="Länk" />
|
|
@@ -75,16 +104,16 @@ import { LinkSelector } from '@soleil-se/svelte-config';
|
|
|
75
104
|
|
|
76
105
|
```svelte
|
|
77
106
|
<script>
|
|
78
|
-
import { LinkSelector } from '@soleil-se/svelte-config';
|
|
79
|
-
import { pluckPrefix, addPrefix, onSave } from '@soleil-se/svelte-config/utils';
|
|
107
|
+
import { LinkSelector } from '@soleil-se/svelte-config';
|
|
108
|
+
import { pluckPrefix, addPrefix, onSave } from '@soleil-se/svelte-config/utils';
|
|
80
109
|
|
|
81
|
-
// Plucks object properties with keys prefixed with 'link' and removes the prefix.
|
|
82
|
-
// { linkType, linkValue, linkNewWindow } -> { type, value, newWindow }
|
|
83
|
-
let link = pluckPrefix('link');
|
|
110
|
+
// Plucks object properties with keys prefixed with 'link' and removes the prefix.
|
|
111
|
+
// { linkType, linkValue, linkNewWindow } -> { type, value, newWindow }
|
|
112
|
+
let link = pluckPrefix('link');
|
|
84
113
|
|
|
85
|
-
// Prefixes keys in an object
|
|
86
|
-
// { type, value, newWindow } -> { linkType, linkValue, linkNewWindow }
|
|
87
|
-
onSave(() => addPrefix('link', link)))
|
|
114
|
+
// Prefixes keys in an object
|
|
115
|
+
// { type, value, newWindow } -> { linkType, linkValue, linkNewWindow }
|
|
116
|
+
onSave(() => addPrefix('link', link)))
|
|
88
117
|
|
|
89
118
|
</script>
|
|
90
119
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import createI18n from '../../utils/createI18n';
|
|
2
|
+
|
|
3
|
+
export default createI18n({
|
|
4
|
+
sv: {
|
|
5
|
+
heading: 'Länk',
|
|
6
|
+
internal: 'Intern',
|
|
7
|
+
external: 'Extern',
|
|
8
|
+
file: 'Fil',
|
|
9
|
+
mail: 'E-post',
|
|
10
|
+
tel: 'Telefonnummer',
|
|
11
|
+
newTab: 'Öppna i ny flik',
|
|
12
|
+
},
|
|
13
|
+
no: {
|
|
14
|
+
heading: 'Lenke',
|
|
15
|
+
internal: 'Intern',
|
|
16
|
+
external: 'Ekstern',
|
|
17
|
+
file: 'Fil',
|
|
18
|
+
mail: 'E-post',
|
|
19
|
+
tel: 'Telefonnummer',
|
|
20
|
+
newTab: 'Åpne i en ny fane',
|
|
21
|
+
},
|
|
22
|
+
en: {
|
|
23
|
+
heading: 'Link',
|
|
24
|
+
internal: 'Internal',
|
|
25
|
+
external: 'External',
|
|
26
|
+
file: 'File',
|
|
27
|
+
mail: 'Mail',
|
|
28
|
+
tel: 'Phone',
|
|
29
|
+
newTab: 'Open in new tab',
|
|
30
|
+
},
|
|
31
|
+
});
|