@soleil-se/config-svelte 1.27.18 → 1.28.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
@@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
8
8
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
9
9
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10
10
 
11
+ ## [1.28.0] - 2025-05-15
12
+
13
+ - Add a `description` prop and slot to most components.
14
+
11
15
  ## [1.27.17] - 2025-05-08
12
16
 
13
17
  - Update type definitions.
@@ -13,6 +13,10 @@
13
13
  export let options;
14
14
  /** @type {string} */
15
15
  export let legend;
16
+ /** @type {string} */
17
+ export let label;
18
+ /** @type {string} */
19
+ export let description;
16
20
  /** @type {boolean} */
17
21
  export let legendVisuallyHidden = false;
18
22
  /** @type {boolean} */
@@ -27,6 +31,8 @@
27
31
  /** @type {string} */
28
32
  export { className as class };
29
33
 
34
+ $: legend = legend || label;
35
+
30
36
  function isChecked(option) {
31
37
  return value.includes(option.value || option);
32
38
  }
@@ -60,6 +66,11 @@
60
66
  </select>
61
67
  <legend class:sr-only={legendVisuallyHidden}>
62
68
  <slot name="legend">{legend}</slot>
69
+ {#if description}
70
+ <p class="help-block">{description}</p>
71
+ {:else if $$slots.description}
72
+ <p class="help-block"><slot name="description"></slot></p>
73
+ {/if}
63
74
  </legend>
64
75
  {#each options as option, index}
65
76
  <input
@@ -15,6 +15,8 @@
15
15
 
16
16
  /** @type {string} */
17
17
  export let label;
18
+ /** @type {string} */
19
+ export let description;
18
20
  /** @type {boolean} */
19
21
  export let required = false;
20
22
  /** @type {string} */
@@ -122,6 +124,11 @@
122
124
  <label class="control-label {required ? 'control-label--required' : ''}" for={domId}>
123
125
  <slot name="label">{label}</slot>
124
126
  </label>
127
+ {#if description}
128
+ <p class="help-block">{description}</p>
129
+ {:else if $$slots.description}
130
+ <p class="help-block"><slot name="description"></slot></p>
131
+ {/if}
125
132
  <div class="list-component">
126
133
  <div class="list-component__list-wrapper ui-resizable">
127
134
  <Sortable {dragDisabled} {items} on:finalize={onFinalize} let:item>
@@ -11,6 +11,8 @@
11
11
  /** @type {string} */
12
12
  export let label;
13
13
  /** @type {string} */
14
+ export let description;
15
+ /** @type {string} */
14
16
  export let name = undefined;
15
17
  /** @type {string} */
16
18
  export let placeholder = i18n('placeholder');
@@ -105,7 +107,7 @@
105
107
  {label}
106
108
  </slot>
107
109
  </label>
108
- <select bind:this={element} {id} name={!multiple ? name : undefined} {disabled} {required}>
110
+ <select bind:this={element} {id} name={!multiple ? name : undefined} aria-describedby={description ? `${id}_description` : undefined} {disabled} {required}>
109
111
  <option></option>
110
112
  {#each options as option}
111
113
  <option value={option.value ?? option}>
@@ -120,5 +122,10 @@
120
122
  {/each}
121
123
  </select>
122
124
  {/if}
125
+ {#if description}
126
+ <p id="{id}_description" class="help-block">{description}</p>
127
+ {:else if $$slots.description}
128
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
129
+ {/if}
123
130
  <slot />
124
131
  </div>
@@ -10,6 +10,8 @@
10
10
  /** @type {string} */
11
11
  export let label;
12
12
  /** @type {string} */
13
+ export let description;
14
+ /** @type {string} */
13
15
  export let name = undefined;
14
16
  /** @type {import('./types.d.ts').Type} */
15
17
  export let type = 'metadata';
@@ -34,10 +36,10 @@
34
36
 
35
37
  $: component = type.endsWith('-selector') ? type : `${type}-selector`;
36
38
 
37
- const setValue = (target) => {
39
+ function setValue(target) {
38
40
  hidden = false;
39
- jQuery(target).val(value).trigger('change');
40
- };
41
+ window.jQuery(target).val(value).trigger('change');
42
+ }
41
43
 
42
44
  onMount(() => {
43
45
  const [el] = setupComponent(id)
@@ -64,7 +66,7 @@
64
66
  @component
65
67
  Wrapper component for Sitevision [selects](https://developer.sitevision.se/docs/webapps/webapps-2/configuration/sitevision-components).
66
68
 
67
- [README](https://docs.soleilit.se/03.packages/@soleil&svelte-config/components/DropdownSelector/)
69
+ [README](https://docs.soleil.se/packages/config-svelte/components/dropdownselector/)
68
70
  -->
69
71
 
70
72
  <div class="form-group {className}" class:hidden={!show} {hidden}>
@@ -74,11 +76,17 @@
74
76
  <select
75
77
  {id}
76
78
  {name}
79
+ aria-describedby={description ? `${id}_description` : undefined}
77
80
  data-component={component}
78
81
  data-removable
79
82
  data-types={selectable}
80
83
  {disabled}
81
84
  {required}
82
85
  ></select>
86
+ {#if description}
87
+ <p id="{id}_description" class="help-block">{description}</p>
88
+ {:else if $$slots.description}
89
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
90
+ {/if}
83
91
  <slot />
84
92
  </div>
@@ -11,6 +11,8 @@
11
11
  /** @type {string} */
12
12
  export let label;
13
13
  /** @type {string} */
14
+ export let description;
15
+ /** @type {string} */
14
16
  export let type = 'text';
15
17
  /** @type {string} */
16
18
  export let name = undefined;
@@ -22,7 +24,6 @@
22
24
  export let readonly = false;
23
25
  /** @type {number} */
24
26
  export let rows = 3;
25
-
26
27
  /** @type {function} */
27
28
  export let action = prefixHttps;
28
29
  /** @type {boolean} */
@@ -62,6 +63,7 @@
62
63
  {id}
63
64
  {name}
64
65
  class="form-control"
66
+ aria-describedby={description ? `${id}_description` : undefined}
65
67
  {disabled}
66
68
  {readonly}
67
69
  required={isRequired}
@@ -75,6 +77,7 @@
75
77
  {id}
76
78
  {name}
77
79
  class="form-control"
80
+ aria-describedby={description ? `${id}_description` : undefined}
78
81
  {disabled}
79
82
  {readonly}
80
83
  required={isRequired}
@@ -85,6 +88,11 @@
85
88
  use:action
86
89
  />
87
90
  {/if}
91
+ {#if description}
92
+ <p id="{id}_description" class="help-block">{description}</p>
93
+ {:else if $$slots.description}
94
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
95
+ {/if}
88
96
  <slot />
89
97
  </div>
90
98
 
@@ -11,6 +11,8 @@
11
11
  export let name;
12
12
  /** @type {string} */
13
13
  export let label;
14
+ /** @type {string} */
15
+ export let description;
14
16
  /** @type {import('./types.d.ts').Type} */
15
17
  export let type = 'page';
16
18
  /** @type {boolean} */
@@ -64,9 +66,16 @@
64
66
  <label class="control-label {required ? 'control-label--required' : ''}" for={id}>
65
67
  <slot name="label">{label}</slot>
66
68
  </label>
69
+ {#if description}
70
+ <p id="{id}_description" class="help-block">{description}</p>
71
+ {:else if $$slots.description}
72
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
73
+ {/if}
67
74
  <input
68
75
  {id}
69
76
  {name}
77
+ aria-describedby={description ? `${id}_description` : undefined}
78
+ aria-required={required || undefined}
70
79
  data-component={component}
71
80
  data-sortable={sortable || undefined}
72
81
  data-types={selectable}
@@ -1,5 +1,5 @@
1
1
  <script>
2
- /* eslint-disable no-undef-init */
2
+
3
3
  import { createEventDispatcher, onMount } from 'svelte';
4
4
  import { generateId, setupComponent } from '../../utils';
5
5
 
@@ -8,7 +8,10 @@
8
8
 
9
9
  /** @type {string} */
10
10
  export let id = generateId();
11
+ /** @type {string} */
11
12
  export let label;
13
+ /** @type {string} */
14
+ export let description;
12
15
  /** @type {import('./types.d.ts').Type} */
13
16
  export let type = 'page';
14
17
  /** @type {string} */
@@ -80,6 +83,7 @@
80
83
  {id}
81
84
  {name}
82
85
  class="form-control"
86
+ aria-describedby={description ? `${id}_description` : undefined}
83
87
  data-component={component}
84
88
  data-removable={removable ? '' : undefined}
85
89
  data-types={selectable}
@@ -89,6 +93,11 @@
89
93
  required={isRequired}
90
94
  value={displayName}
91
95
  />
96
+ {#if description}
97
+ <p id="{id}_description" class="help-block">{description}</p>
98
+ {:else if $$slots.description}
99
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
100
+ {/if}
92
101
  {#if disabled}
93
102
  <div class="disabled-overlay"></div>
94
103
  {/if}
@@ -11,6 +11,8 @@
11
11
  export let name;
12
12
  /** @type {string} */
13
13
  export let label;
14
+ /** @type {string} */
15
+ export let description;
14
16
  /** @type {number} */
15
17
  export let min;
16
18
  /** @type {number} */
@@ -69,6 +71,7 @@
69
71
  {id}
70
72
  {name}
71
73
  class="form-control"
74
+ aria-describedby={description ? `${id}_description` : undefined}
72
75
  data-component="number-spinner"
73
76
  data-decimals={decimals}
74
77
  data-max={max}
@@ -78,6 +81,11 @@
78
81
  {readonly}
79
82
  {value}
80
83
  />
84
+ {#if description}
85
+ <p id="{id}_description" class="help-block">{description}</p>
86
+ {:else if $$slots.description}
87
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
88
+ {/if}
81
89
  {#if disabled}
82
90
  <div class="disabled-overlay"></div>
83
91
  {/if}
@@ -98,7 +98,17 @@
98
98
  border-left: 1px solid #aaa;
99
99
  }
100
100
 
101
+ label + .help-block {
102
+ margin-block: 0 5px;
103
+ }
104
+
105
+ legend .help-block {
106
+ margin-block: 3px 0;
107
+ font-weight: normal;
108
+ }
109
+
101
110
  .form-group .help-block:last-child {
102
111
  margin-bottom: 0;
103
112
  }
113
+
104
114
  </style>
@@ -15,6 +15,8 @@
15
15
  export let legend;
16
16
  /** @type {string} */
17
17
  export let label;
18
+ /** @type {string} */
19
+ export let description;
18
20
  /** @type {boolean} */
19
21
  export let legendVisuallyHidden = false;
20
22
  /** @type {boolean} */
@@ -48,6 +50,11 @@
48
50
  <fieldset class="form-group" class:hidden={!show}>
49
51
  <legend class:sr-only={legendVisuallyHidden}>
50
52
  <slot name="legend">{legend}</slot>
53
+ {#if description}
54
+ <p class="help-block">{description}</p>
55
+ {:else if $$slots.description}
56
+ <p class="help-block"><slot name="description"></slot></p>
57
+ {/if}
51
58
  </legend>
52
59
  {#each options as option, index}
53
60
  <input
@@ -10,6 +10,8 @@
10
10
  /** @type {string} */
11
11
  export let label;
12
12
  /** @type {string} */
13
+ export let description;
14
+ /** @type {string} */
13
15
  export let name;
14
16
  /** @type {boolean} */
15
17
  export let searchable;
@@ -71,6 +73,7 @@
71
73
  <CustomSelector
72
74
  {id}
73
75
  {name}
76
+ {description}
74
77
  {disabled}
75
78
  {label}
76
79
  {multiple}
@@ -10,6 +10,8 @@
10
10
  /** @type {string} */
11
11
  export let label;
12
12
  /** @type {string} */
13
+ export let description;
14
+ /** @type {string} */
13
15
  export let name;
14
16
  /** @type {string} */
15
17
  export let required = false;
@@ -37,7 +39,7 @@
37
39
  <label class="control-label {required ? 'control-label--required' : ''}" for={id}>
38
40
  <slot name="label">{label}</slot>
39
41
  </label>
40
- <select {id} {name} class="form-control" {disabled} {required} bind:value on:change={onChange}>
42
+ <select {id} {name} class="form-control" aria-describedby={description ? `${id}_description` : undefined} {disabled} {required} bind:value on:change={onChange}>
41
43
  <option disabled hidden selected value=""></option>
42
44
  {#each options as option}
43
45
  <option value={option.value ?? option}>
@@ -45,6 +47,11 @@
45
47
  </option>
46
48
  {/each}
47
49
  </select>
50
+ {#if description}
51
+ <p id="{id}_description" class="help-block">{description}</p>
52
+ {:else if $$slots.description}
53
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
54
+ {/if}
48
55
  <slot />
49
56
  </div>
50
57
 
@@ -1,5 +1,4 @@
1
1
  <script>
2
- /* eslint-disable no-undef-init */
3
2
  import { createEventDispatcher, onMount } from 'svelte';
4
3
  import { generateId, setupComponent } from '../../utils';
5
4
 
@@ -11,6 +10,8 @@
11
10
  /** @type {string} */
12
11
  export let label;
13
12
  /** @type {string} */
13
+ export let description;
14
+ /** @type {string} */
14
15
  export let name;
15
16
  /** @type {boolean} */
16
17
  export let required = false;
@@ -65,6 +66,7 @@
65
66
  {id}
66
67
  {name}
67
68
  class="form-control"
69
+ aria-describedby={description ? `${id}_description` : undefined}
68
70
  data-component="tags-selector"
69
71
  {disabled}
70
72
  required={isRequired}
@@ -73,6 +75,11 @@
73
75
  {#if disabled}
74
76
  <div class="disabled-overlay"></div>
75
77
  {/if}
78
+ {#if description}
79
+ <p id="{id}_description" class="help-block">{description}</p>
80
+ {:else if $$slots.description}
81
+ <p id="{id}_description" class="help-block"><slot name="description"></slot></p>
82
+ {/if}
76
83
  <slot />
77
84
  </div>
78
85
 
@@ -15,6 +15,8 @@
15
15
  export let id = generateId();
16
16
  /** @type {string} */
17
17
  export let label;
18
+ /** @type {string} */
19
+ export let description;
18
20
  /** @type {boolean} */
19
21
  export let required = false;
20
22
  /** @type {string} */
@@ -87,6 +89,11 @@
87
89
  <label class="control-label {required ? 'control-label--required' : ''}" for={id}>
88
90
  <slot name="label">{label}</slot>
89
91
  </label>
92
+ {#if description}
93
+ <p class="help-block">{description}</p>
94
+ {:else if $$slots.description}
95
+ <p class="help-block"><slot name="description"></slot></p>
96
+ {/if}
90
97
  <div class="list-component">
91
98
  <div class="list-component__list-wrapper ui-resizable">
92
99
  <Sortable {items} on:finalize={onFinalize} let:item>
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "svelte"
10
10
  ],
11
11
  "homepage": "https://docs.soleil.se/packages/config-svelte",
12
- "version": "1.27.18",
12
+ "version": "1.28.0",
13
13
  "main": "./index.js",
14
14
  "module": "./index.js",
15
15
  "svelte": "./index.js",
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "4465a8e439b30cb04ff0655759e26eb802a30805"
62
+ "gitHead": "0c28ddb7659269ecba2b09a79da9ba44e0ef35d4"
63
63
  }