@soleil-se/config-svelte 1.2.0 → 1.2.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 +28 -0
- package/actions/index.js +1 -1
- package/actions/inputPrefix.js +31 -0
- package/components/InputField/Component.svelte +3 -2
- package/components/LinkSelector/Component.svelte +15 -22
- package/components/LinkSelector/api/getSavedValue.js +19 -0
- package/package.json +1 -1
- package/actions/httpPrefix.js +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,45 +1,73 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.2.1] - 2021-04-09
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Mail and tel values in LinkSelector are prefixed with `mailto:` and `tel:`.
|
|
13
|
+
|
|
6
14
|
## [1.2.0] - 2021-03-30
|
|
15
|
+
|
|
7
16
|
### Added
|
|
17
|
+
|
|
8
18
|
- Mail and tel types to LinkSelector.
|
|
9
19
|
- Value in NumberSpinner is now left aligned.
|
|
20
|
+
|
|
10
21
|
### Fixed
|
|
22
|
+
|
|
11
23
|
- Unable to clear value in LinkSelector.
|
|
12
24
|
|
|
13
25
|
## [1.1.2] - 2021-03-11
|
|
26
|
+
|
|
14
27
|
### Fixed
|
|
28
|
+
|
|
15
29
|
- Unable to remove last item in TextList.
|
|
16
30
|
- TextList is not validated when `required` prop is used
|
|
31
|
+
|
|
17
32
|
## [1.1.1] - 2021-02-02
|
|
33
|
+
|
|
18
34
|
### Fixed
|
|
35
|
+
|
|
19
36
|
- Missing docs NumberSpinner.
|
|
20
37
|
|
|
21
38
|
## [1.1.0] - 2021-01-29
|
|
39
|
+
|
|
22
40
|
### Added
|
|
41
|
+
|
|
23
42
|
- `suffix` prop to NumberSpinner.
|
|
24
43
|
|
|
25
44
|
## [1.0.4] - 2021-01-15
|
|
45
|
+
|
|
26
46
|
### Fixed
|
|
47
|
+
|
|
27
48
|
- ListSelector inifity loop.
|
|
28
49
|
|
|
29
50
|
## [1.0.3] - 2021-01-11
|
|
51
|
+
|
|
30
52
|
### Fixed
|
|
53
|
+
|
|
31
54
|
- Remove debug output.
|
|
32
55
|
|
|
33
56
|
## [1.0.2] - 2021-01-11
|
|
57
|
+
|
|
34
58
|
### Fixed
|
|
59
|
+
|
|
35
60
|
- Array destructuring not working in TextList for IE11.
|
|
36
61
|
- RadioGroup value not working in IE11.
|
|
37
62
|
- Added missing polyfills for IE11 in docs and demo.
|
|
38
63
|
|
|
39
64
|
## [1.0.1] - 2020-12-08
|
|
65
|
+
|
|
40
66
|
### Fixed
|
|
67
|
+
|
|
41
68
|
- Selectable props in NodeSelector, ListSelector and DropdownSelector now also accepts a string.
|
|
42
69
|
- Margin on CheckboxGroup and RadioGroup controls.
|
|
43
70
|
|
|
44
71
|
## [1.0.0] - 2020-11-20
|
|
72
|
+
|
|
45
73
|
- Initial release!
|
package/actions/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function prefixHttps(node) {
|
|
2
|
+
const addPrefix = () => {
|
|
3
|
+
const { type, value } = node;
|
|
4
|
+
if (type === 'url' && value && !/^(https?):\/\//i.test(value) && ('http://'.indexOf(value) === -1 && 'https://'.indexOf(value) === -1)) {
|
|
5
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
6
|
+
node.value = `https://${value}`;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
node.addEventListener('input', addPrefix);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function prefixMail(node) {
|
|
13
|
+
const addPrefix = () => {
|
|
14
|
+
const { value } = node;
|
|
15
|
+
|
|
16
|
+
if (value && !/^(mailto?):/i.test(value) && 'mailto:'.indexOf(value) === -1) {
|
|
17
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
18
|
+
node.value = `mailto:${value}`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
node.addEventListener('input', addPrefix);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function prefixTel(node) {
|
|
25
|
+
const addPrefix = () => {
|
|
26
|
+
const { value } = node;
|
|
27
|
+
/* eslint-disable-next-line no-param-reassign */
|
|
28
|
+
node.value = `tel:${value.replace(/\s/g, '').replace(/[^0-9$\\+]/g, '')}`;
|
|
29
|
+
};
|
|
30
|
+
node.addEventListener('input', addPrefix);
|
|
31
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/* eslint-disable no-undef-init */
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { prefixHttps } from '../../actions';
|
|
5
5
|
import { generateId } from '../../utils';
|
|
6
6
|
|
|
7
7
|
const values = window.CONFIG_VALUES || {};
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
export let pattern = undefined;
|
|
19
19
|
export let rows = 3;
|
|
20
20
|
export let value = '';
|
|
21
|
+
export let action = prefixHttps;
|
|
21
22
|
value = name ? values[name] ?? value : value;
|
|
22
23
|
|
|
23
24
|
let className = '';
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
{readonly}
|
|
61
62
|
{pattern}
|
|
62
63
|
{value}
|
|
63
|
-
use:
|
|
64
|
+
use:action
|
|
64
65
|
on:input={onInput}
|
|
65
66
|
/>
|
|
66
67
|
{/if}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { createEventDispatcher } from 'svelte';
|
|
3
|
-
import { show } from '../../actions';
|
|
3
|
+
import { show, prefixMail, prefixTel } from '../../actions';
|
|
4
4
|
|
|
5
5
|
import Panel from '../Panel';
|
|
6
6
|
import RadioGroup from '../RadioGroup';
|
|
7
7
|
import NodeSelector from '../NodeSelector';
|
|
8
8
|
import InputField from '../InputField';
|
|
9
9
|
import Checkbox from '../Checkbox';
|
|
10
|
+
import getSavedValue from './api/getSavedValue';
|
|
10
11
|
|
|
11
|
-
const values = window.CONFIG_VALUES || {};
|
|
12
12
|
const dispatch = createEventDispatcher();
|
|
13
13
|
|
|
14
14
|
export let heading;
|
|
@@ -17,20 +17,7 @@
|
|
|
17
17
|
export let required = false;
|
|
18
18
|
export let types = ['internal', 'external', 'file'];
|
|
19
19
|
export let value;
|
|
20
|
-
|
|
21
|
-
if (!value || Object.keys(value).length === 0) {
|
|
22
|
-
value = {
|
|
23
|
-
type: types[0],
|
|
24
|
-
newWindow: false,
|
|
25
|
-
value: '',
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (name) {
|
|
30
|
-
value.type = values[`${name}Type`] || value.type;
|
|
31
|
-
value.newWindow = values[`${name}NewWindow`] || value.newWindow;
|
|
32
|
-
value.value = values[`${name}Value`] || value.value || '';
|
|
33
|
-
}
|
|
20
|
+
value = getSavedValue({ value, name, types });
|
|
34
21
|
|
|
35
22
|
let className = '';
|
|
36
23
|
export { className as class };
|
|
@@ -110,12 +97,13 @@
|
|
|
110
97
|
required={required && isFile}
|
|
111
98
|
/>
|
|
112
99
|
</div>
|
|
100
|
+
|
|
113
101
|
<div class="sr-label form-group form-group--mail" use:show={isMail}>
|
|
114
102
|
<InputField
|
|
115
103
|
bind:value={selected.mail}
|
|
116
104
|
{disabled}
|
|
117
105
|
label="E-post"
|
|
118
|
-
|
|
106
|
+
action={prefixMail}
|
|
119
107
|
on:change={onChange}
|
|
120
108
|
required={required && isMail}
|
|
121
109
|
/>
|
|
@@ -124,8 +112,9 @@
|
|
|
124
112
|
<InputField
|
|
125
113
|
bind:value={selected.tel}
|
|
126
114
|
{disabled}
|
|
127
|
-
label="
|
|
128
|
-
type="
|
|
115
|
+
label="Telefonnummer"
|
|
116
|
+
type="tel"
|
|
117
|
+
action={prefixTel}
|
|
129
118
|
on:change={onChange}
|
|
130
119
|
required={required && isTel}
|
|
131
120
|
/>
|
|
@@ -141,7 +130,7 @@
|
|
|
141
130
|
<slot name="bottom" />
|
|
142
131
|
</Panel>
|
|
143
132
|
|
|
144
|
-
<style>
|
|
133
|
+
<style lang="scss">
|
|
145
134
|
.sr-label :global(label),
|
|
146
135
|
.sr-legend :global(legend) {
|
|
147
136
|
position: absolute;
|
|
@@ -154,7 +143,11 @@
|
|
|
154
143
|
clip: rect(0, 0, 0, 0);
|
|
155
144
|
}
|
|
156
145
|
|
|
157
|
-
.form-group--external
|
|
158
|
-
|
|
146
|
+
.form-group--external,
|
|
147
|
+
.form-group--mail,
|
|
148
|
+
.form-group--tel {
|
|
149
|
+
:global(.form-control-feedback) {
|
|
150
|
+
top: 0;
|
|
151
|
+
}
|
|
159
152
|
}
|
|
160
153
|
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const getDefaultValue = (types) => ({
|
|
2
|
+
type: types[0],
|
|
3
|
+
newWindow: false,
|
|
4
|
+
value: '',
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export default function getSavedValue({ value, name, types }) {
|
|
8
|
+
const values = window.CONFIG_VALUES || {};
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
...getDefaultValue(types),
|
|
12
|
+
...value,
|
|
13
|
+
...(name ? {
|
|
14
|
+
type: values[`${name}Type`],
|
|
15
|
+
newWindow: values[`${name}NewWindow`],
|
|
16
|
+
value: values[`${name}Value`],
|
|
17
|
+
} : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
package/package.json
CHANGED
package/actions/httpPrefix.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default function httpPrefix(node) {
|
|
2
|
-
const addPrefix = () => {
|
|
3
|
-
const { type, value } = node;
|
|
4
|
-
if (type === 'url' && value && !/^(https?):\/\//i.test(value) && ('http://'.indexOf(value) === -1 && 'https://'.indexOf(value) === -1)) {
|
|
5
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
6
|
-
node.value = `https://${value}`;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
node.addEventListener('input', addPrefix);
|
|
10
|
-
}
|