@onsvisual/svelte-components 1.0.20 → 1.0.22

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.
Files changed (95) hide show
  1. package/README.md +1 -1
  2. package/dist/datavis/DataCard/DataCard.svelte +14 -14
  3. package/dist/datavis/DataCard/DataCard.svelte.d.ts +14 -14
  4. package/dist/datavis/Table/Table.svelte +4 -4
  5. package/dist/datavis/Table/Table.svelte.d.ts +4 -4
  6. package/dist/decorators/Blockquote/Blockquote.svelte +2 -2
  7. package/dist/decorators/Blockquote/Blockquote.svelte.d.ts +2 -2
  8. package/dist/decorators/Divider/Divider.svelte +2 -2
  9. package/dist/decorators/Divider/Divider.svelte.d.ts +2 -2
  10. package/dist/decorators/Em/Em.svelte +2 -2
  11. package/dist/decorators/Em/Em.svelte.d.ts +2 -2
  12. package/dist/inputs/Button/Button.svelte +117 -117
  13. package/dist/inputs/Button/Button.svelte.d.ts +6 -6
  14. package/dist/inputs/Checkbox/Checkbox.svelte +6 -6
  15. package/dist/inputs/Checkbox/Checkbox.svelte.d.ts +6 -6
  16. package/dist/inputs/Checkboxes/Checkboxes.svelte +6 -6
  17. package/dist/inputs/Checkboxes/Checkboxes.svelte.d.ts +6 -6
  18. package/dist/inputs/Dropdown/Dropdown.svelte +6 -6
  19. package/dist/inputs/Dropdown/Dropdown.svelte.d.ts +6 -6
  20. package/dist/inputs/ErrorPanel/ErrorPanel.svelte +4 -4
  21. package/dist/inputs/ErrorPanel/ErrorPanel.svelte.d.ts +4 -4
  22. package/dist/inputs/ErrorSummary/ErrorSummary.svelte +4 -4
  23. package/dist/inputs/ErrorSummary/ErrorSummary.svelte.d.ts +4 -4
  24. package/dist/inputs/Input/Input.svelte +14 -14
  25. package/dist/inputs/Input/Input.svelte.d.ts +14 -14
  26. package/dist/inputs/Radios/Radio.svelte +6 -6
  27. package/dist/inputs/Radios/Radio.svelte.d.ts +6 -6
  28. package/dist/inputs/Radios/Radios.svelte +6 -6
  29. package/dist/inputs/Radios/Radios.svelte.d.ts +6 -6
  30. package/dist/inputs/Select/Select.stories.svelte +3 -1
  31. package/dist/inputs/Select/Select.svelte +32 -16
  32. package/dist/inputs/Select/Select.svelte.d.ts +4 -4
  33. package/dist/inputs/Textarea/Textarea.svelte +8 -8
  34. package/dist/inputs/Textarea/Textarea.svelte.d.ts +8 -8
  35. package/dist/layout/Accordion/Accordion.svelte +2 -2
  36. package/dist/layout/Accordion/Accordion.svelte.d.ts +2 -2
  37. package/dist/layout/Accordion/AccordionItem.svelte +2 -2
  38. package/dist/layout/Accordion/AccordionItem.svelte.d.ts +2 -2
  39. package/dist/layout/BackLink/BackLink.svelte +2 -2
  40. package/dist/layout/BackLink/BackLink.svelte.d.ts +2 -2
  41. package/dist/layout/Breadcrumb/Breadcrumb.svelte +4 -4
  42. package/dist/layout/Breadcrumb/Breadcrumb.svelte.d.ts +4 -4
  43. package/dist/layout/Card/Card.svelte +12 -12
  44. package/dist/layout/Card/Card.svelte.d.ts +12 -12
  45. package/dist/layout/Contents/Contents.svelte +4 -4
  46. package/dist/layout/Contents/Contents.svelte.d.ts +4 -4
  47. package/dist/layout/DescriptionList/DescriptionList.svelte +4 -4
  48. package/dist/layout/DescriptionList/DescriptionList.svelte.d.ts +4 -4
  49. package/dist/layout/Details/Details.svelte +2 -2
  50. package/dist/layout/Details/Details.svelte.d.ts +2 -2
  51. package/dist/layout/DocumentList/Document.svelte +8 -8
  52. package/dist/layout/DocumentList/Document.svelte.d.ts +8 -8
  53. package/dist/layout/DocumentList/DocumentList.svelte +2 -2
  54. package/dist/layout/DocumentList/DocumentList.svelte.d.ts +2 -2
  55. package/dist/layout/Grid/Grid.svelte +8 -8
  56. package/dist/layout/Grid/Grid.svelte.d.ts +8 -8
  57. package/dist/layout/Header/Header.svelte +4 -4
  58. package/dist/layout/Header/Header.svelte.d.ts +4 -4
  59. package/dist/layout/Hero/Hero.svelte +11 -8
  60. package/dist/layout/Hero/Hero.svelte.d.ts +6 -6
  61. package/dist/layout/Highlight/Highlight.svelte +4 -4
  62. package/dist/layout/Highlight/Highlight.svelte.d.ts +4 -4
  63. package/dist/layout/Image/Image.svelte +8 -8
  64. package/dist/layout/Image/Image.svelte.d.ts +8 -8
  65. package/dist/layout/List/List.svelte +2 -2
  66. package/dist/layout/List/List.svelte.d.ts +2 -2
  67. package/dist/layout/NavSections/NavSection.svelte +2 -2
  68. package/dist/layout/NavSections/NavSection.svelte.d.ts +2 -2
  69. package/dist/layout/NavSections/NavSections.svelte +2 -2
  70. package/dist/layout/NavSections/NavSections.svelte.d.ts +2 -2
  71. package/dist/layout/Notice/Notice.svelte +2 -2
  72. package/dist/layout/Notice/Notice.svelte.d.ts +2 -2
  73. package/dist/layout/PhaseBanner/PhaseBanner.svelte +2 -2
  74. package/dist/layout/PhaseBanner/PhaseBanner.svelte.d.ts +2 -2
  75. package/dist/layout/RelatedContent/RelatedContent.svelte +2 -2
  76. package/dist/layout/RelatedContent/RelatedContent.svelte.d.ts +2 -2
  77. package/dist/layout/Scroller/Scroller.svelte +2 -2
  78. package/dist/layout/Scroller/Scroller.svelte.d.ts +2 -2
  79. package/dist/layout/Scroller/ScrollerSection.svelte +6 -6
  80. package/dist/layout/Scroller/ScrollerSection.svelte.d.ts +6 -6
  81. package/dist/layout/Section/Section.svelte +6 -6
  82. package/dist/layout/Section/Section.svelte.d.ts +6 -6
  83. package/dist/layout/ShareButtons/ShareButtons.svelte +2 -2
  84. package/dist/layout/ShareButtons/ShareButtons.svelte.d.ts +2 -2
  85. package/dist/layout/Summary/Summary.svelte +6 -6
  86. package/dist/layout/Summary/Summary.svelte.d.ts +6 -6
  87. package/dist/layout/Tabs/Tabs.svelte +2 -2
  88. package/dist/layout/Tabs/Tabs.svelte.d.ts +2 -2
  89. package/dist/layout/Timeline/TimelineItem.svelte +2 -2
  90. package/dist/layout/Timeline/TimelineItem.svelte.d.ts +2 -2
  91. package/dist/wrappers/Container/Container.svelte +4 -4
  92. package/dist/wrappers/Container/Container.svelte.d.ts +4 -4
  93. package/dist/wrappers/Theme/Theme.svelte +2 -2
  94. package/dist/wrappers/Theme/Theme.svelte.d.ts +2 -2
  95. package/package.json +4 -1
@@ -2,9 +2,9 @@
2
2
  /** @typedef {typeof __propDef.events} CheckboxesEvents */
3
3
  /** @typedef {typeof __propDef.slots} CheckboxesSlots */
4
4
  export default class Checkboxes extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- label?: string | undefined;
7
- title?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ label?: string | null | undefined;
7
+ title?: string | null | undefined;
8
8
  compact?: boolean | undefined;
9
9
  hideTitle?: boolean | undefined;
10
10
  items?: object[] | null | undefined;
@@ -23,9 +23,9 @@ export type CheckboxesSlots = typeof __propDef.slots;
23
23
  import { SvelteComponentTyped } from "svelte";
24
24
  declare const __propDef: {
25
25
  props: {
26
- cls?: string | undefined;
27
- label?: string | undefined;
28
- title?: string | undefined;
26
+ cls?: string | null | undefined;
27
+ label?: string | null | undefined;
28
+ title?: string | null | undefined;
29
29
  compact?: boolean | undefined;
30
30
  hideTitle?: boolean | undefined;
31
31
  items?: object[] | null | undefined;
@@ -5,14 +5,14 @@
5
5
 
6
6
  /**
7
7
  * Unique id for the &lt;select&gt; element
8
- * @type {string}
8
+ * @type {string|null}
9
9
  */
10
- export let id = "";
10
+ export let id = null;
11
11
  /**
12
12
  * A label to describe the &lt;select&gt; element (expected for accessibility)
13
- * @type {string}
13
+ * @type {string|null}
14
14
  */
15
- export let label = "";
15
+ export let label = null;
16
16
  /**
17
17
  * Visually hide the label
18
18
  * @type {boolean}
@@ -35,9 +35,9 @@
35
35
  export let options = [];
36
36
  /**
37
37
  * Optional: Set an additional CSS class for the component
38
- * @type {string}
38
+ * @type {string|null}
39
39
  */
40
- export let cls = "";
40
+ export let cls = null;
41
41
  </script>
42
42
 
43
43
  <div class="ons-field {cls}">
@@ -2,9 +2,9 @@
2
2
  /** @typedef {typeof __propDef.events} DropdownEvents */
3
3
  /** @typedef {typeof __propDef.slots} DropdownSlots */
4
4
  export default class Dropdown extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- id?: string | undefined;
7
- label?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ id?: string | null | undefined;
7
+ label?: string | null | undefined;
8
8
  value?: object | null | undefined;
9
9
  hideLabel?: boolean | undefined;
10
10
  placeholder?: string | undefined;
@@ -21,9 +21,9 @@ export type DropdownSlots = typeof __propDef.slots;
21
21
  import { SvelteComponentTyped } from "svelte";
22
22
  declare const __propDef: {
23
23
  props: {
24
- cls?: string | undefined;
25
- id?: string | undefined;
26
- label?: string | undefined;
24
+ cls?: string | null | undefined;
25
+ id?: string | null | undefined;
26
+ label?: string | null | undefined;
27
27
  value?: object | null | undefined;
28
28
  hideLabel?: boolean | undefined;
29
29
  placeholder?: string | undefined;
@@ -1,14 +1,14 @@
1
1
  <script>
2
2
  /**
3
3
  * Set an error message
4
- * @type {string}
4
+ * @type {string|null}
5
5
  */
6
- export let message = "";
6
+ export let message = null;
7
7
  /**
8
8
  * Optional: Set an additional CSS class for the component
9
- * @type {string}
9
+ * @type {string|null}
10
10
  */
11
- export let cls = "";
11
+ export let cls = null;
12
12
  </script>
13
13
 
14
14
  <div class="ons-panel ons-panel--error ons-panel--no-title {cls}" id="number-of-employees-error">
@@ -2,8 +2,8 @@
2
2
  /** @typedef {typeof __propDef.events} ErrorPanelEvents */
3
3
  /** @typedef {typeof __propDef.slots} ErrorPanelSlots */
4
4
  export default class ErrorPanel extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- message?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ message?: string | null | undefined;
7
7
  }, {
8
8
  [evt: string]: CustomEvent<any>;
9
9
  }, {
@@ -16,8 +16,8 @@ export type ErrorPanelSlots = typeof __propDef.slots;
16
16
  import { SvelteComponentTyped } from "svelte";
17
17
  declare const __propDef: {
18
18
  props: {
19
- cls?: string | undefined;
20
- message?: string | undefined;
19
+ cls?: string | null | undefined;
20
+ message?: string | null | undefined;
21
21
  };
22
22
  events: {
23
23
  [evt: string]: CustomEvent<any>;
@@ -3,9 +3,9 @@
3
3
 
4
4
  /**
5
5
  * Defines the title of the error
6
- * @type {string}
6
+ * @type {string|null}
7
7
  */
8
- export let title = "";
8
+ export let title = null;
9
9
  /**
10
10
  * Define an array of errors/issues in the format {label, href?}
11
11
  * @type {object[]}
@@ -13,9 +13,9 @@
13
13
  export let items = [];
14
14
  /**
15
15
  * Optional: Set an additional CSS class for the component
16
- * @type {string}
16
+ * @type {string|null}
17
17
  */
18
- export let cls = "";
18
+ export let cls = null;
19
19
  </script>
20
20
 
21
21
  <div aria-labelledby="alert" role="alert" tabindex="-1" class="ons-panel ons-panel--error {cls}">
@@ -2,8 +2,8 @@
2
2
  /** @typedef {typeof __propDef.events} ErrorSummaryEvents */
3
3
  /** @typedef {typeof __propDef.slots} ErrorSummarySlots */
4
4
  export default class ErrorSummary extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- title?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ title?: string | null | undefined;
7
7
  items?: object[] | undefined;
8
8
  }, {
9
9
  [evt: string]: CustomEvent<any>;
@@ -17,8 +17,8 @@ export type ErrorSummarySlots = typeof __propDef.slots;
17
17
  import { SvelteComponentTyped } from "svelte";
18
18
  declare const __propDef: {
19
19
  props: {
20
- cls?: string | undefined;
21
- title?: string | undefined;
20
+ cls?: string | null | undefined;
21
+ title?: string | null | undefined;
22
22
  items?: object[] | undefined;
23
23
  };
24
24
  events: {
@@ -5,14 +5,14 @@
5
5
 
6
6
  /**
7
7
  * ID for &lt;input&gt; element
8
- * @type {string}
8
+ * @type {string|null}
9
9
  */
10
- export let id = "";
10
+ export let id = null;
11
11
  /**
12
12
  * A prop to bind to for the entered value
13
- * @type {string}
13
+ * @type {string|null}
14
14
  */
15
- export let value = "";
15
+ export let value = null;
16
16
  /**
17
17
  * A label to describe the &lt;input&gt; element (expected for accessibility)
18
18
  * @type {string}
@@ -25,9 +25,9 @@
25
25
  export let hideLabel = false;
26
26
  /**
27
27
  * An optional description to help users know what to enter
28
- * @type {string}
28
+ * @type {string|null}
29
29
  */
30
- export let description = "";
30
+ export let description = null;
31
31
  /**
32
32
  * The maximum number of characters that can be entered (optional)
33
33
  * @type {number}
@@ -40,14 +40,14 @@
40
40
  export let width = null;
41
41
  /**
42
42
  * An optional prefix (eg. £) to appear on the left of the input
43
- * @type {string}
43
+ * @type {string|null}
44
44
  */
45
- export let prefix = "";
45
+ export let prefix = null;
46
46
  /**
47
47
  * An optional suffix (eg. %) to appear on the right of the input
48
- * @type {string}
48
+ * @type {string|null}
49
49
  */
50
- export let suffix = "";
50
+ export let suffix = null;
51
51
  /**
52
52
  * An optional hidden description of the prefix (for accessibility)
53
53
  * @type {string}
@@ -55,9 +55,9 @@
55
55
  export let unitLabel = prefix || suffix || "";
56
56
  /**
57
57
  * An optional regex pattern foto limit the input (not currently used)
58
- * @type {string}
58
+ * @type {string|null}
59
59
  */
60
- export let pattern = "";
60
+ export let pattern = null;
61
61
  /**
62
62
  * Set to `true` if the value should be a number
63
63
  * @type {boolean}
@@ -75,9 +75,9 @@
75
75
  export let error = false;
76
76
  /**
77
77
  * Optional: Set an additional CSS class for the component
78
- * @type {string}
78
+ * @type {string|null}
79
79
  */
80
- export let cls = "";
80
+ export let cls = null;
81
81
  </script>
82
82
 
83
83
  <div class="ons-field {cls}">
@@ -2,20 +2,20 @@
2
2
  /** @typedef {typeof __propDef.events} InputEvents */
3
3
  /** @typedef {typeof __propDef.slots} InputSlots */
4
4
  export default class Input extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- id?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ id?: string | null | undefined;
7
7
  width?: number | undefined;
8
8
  label?: string | undefined;
9
- pattern?: string | undefined;
9
+ pattern?: string | null | undefined;
10
10
  error?: boolean | undefined;
11
11
  numeric?: boolean | undefined;
12
- value?: string | undefined;
13
- description?: string | undefined;
12
+ value?: string | null | undefined;
13
+ description?: string | null | undefined;
14
14
  disabled?: boolean | undefined;
15
15
  hideLabel?: boolean | undefined;
16
16
  charLimit?: number | undefined;
17
- prefix?: string | undefined;
18
- suffix?: string | undefined;
17
+ prefix?: string | null | undefined;
18
+ suffix?: string | null | undefined;
19
19
  unitLabel?: string | undefined;
20
20
  }, {
21
21
  change: CustomEvent<any>;
@@ -29,20 +29,20 @@ export type InputSlots = typeof __propDef.slots;
29
29
  import { SvelteComponentTyped } from "svelte";
30
30
  declare const __propDef: {
31
31
  props: {
32
- cls?: string | undefined;
33
- id?: string | undefined;
32
+ cls?: string | null | undefined;
33
+ id?: string | null | undefined;
34
34
  width?: number | undefined;
35
35
  label?: string | undefined;
36
- pattern?: string | undefined;
36
+ pattern?: string | null | undefined;
37
37
  error?: boolean | undefined;
38
38
  numeric?: boolean | undefined;
39
- value?: string | undefined;
40
- description?: string | undefined;
39
+ value?: string | null | undefined;
40
+ description?: string | null | undefined;
41
41
  disabled?: boolean | undefined;
42
42
  hideLabel?: boolean | undefined;
43
43
  charLimit?: number | undefined;
44
- prefix?: string | undefined;
45
- suffix?: string | undefined;
44
+ prefix?: string | null | undefined;
45
+ suffix?: string | null | undefined;
46
46
  unitLabel?: string | undefined;
47
47
  };
48
48
  events: {
@@ -5,19 +5,19 @@
5
5
 
6
6
  /**
7
7
  * Unique ID input
8
- * @type {string}
8
+ * @type {string|null}
9
9
  */
10
- export let id = "";
10
+ export let id = null;
11
11
  /**
12
12
  * Label for input
13
- * @type {string}
13
+ * @type {string|null}
14
14
  */
15
- export let label = "";
15
+ export let label = null;
16
16
  /**
17
17
  * Optional: Extended description for element
18
- * @type {string}
18
+ * @type {string|null}
19
19
  */
20
- export let description = "";
20
+ export let description = null;
21
21
  /**
22
22
  * Optional: Define the item as an object in the form {id, label, description?}
23
23
  * @type {object}
@@ -3,11 +3,11 @@
3
3
  /** @typedef {typeof __propDef.slots} RadioSlots */
4
4
  export default class Radio extends SvelteComponentTyped<{
5
5
  groupId: string;
6
- id?: string | undefined;
7
- label?: string | undefined;
6
+ id?: string | null | undefined;
7
+ label?: string | null | undefined;
8
8
  compact?: boolean | undefined;
9
9
  value?: object | null | undefined;
10
- description?: string | undefined;
10
+ description?: string | null | undefined;
11
11
  item?: object | undefined;
12
12
  }, {
13
13
  change: CustomEvent<any>;
@@ -22,11 +22,11 @@ import { SvelteComponentTyped } from "svelte";
22
22
  declare const __propDef: {
23
23
  props: {
24
24
  groupId: string;
25
- id?: string | undefined;
26
- label?: string | undefined;
25
+ id?: string | null | undefined;
26
+ label?: string | null | undefined;
27
27
  compact?: boolean | undefined;
28
28
  value?: object | null | undefined;
29
- description?: string | undefined;
29
+ description?: string | null | undefined;
30
30
  item?: object | undefined;
31
31
  };
32
32
  events: {
@@ -3,9 +3,9 @@
3
3
 
4
4
  /**
5
5
  * Title/legend for parent <fieldset>
6
- * @type {string}
6
+ * @type {string|null}
7
7
  */
8
- export let title = "";
8
+ export let title = null;
9
9
  /**
10
10
  * Visually hide the title/legend
11
11
  * @type {boolean}
@@ -18,9 +18,9 @@
18
18
  export let id = "name";
19
19
  /**
20
20
  * Descriptive "how to" label for inputs
21
- * @type {string}
21
+ * @type {string|null}
22
22
  */
23
- export let label = "";
23
+ export let label = null;
24
24
  /**
25
25
  * Binding for ID of selected option
26
26
  * @type {object|null}
@@ -37,9 +37,9 @@
37
37
  export let compact = false;
38
38
  /**
39
39
  * Optional: Set an additional CSS class for the component
40
- * @type {string}
40
+ * @type {string|null}
41
41
  */
42
- export let cls = "";
42
+ export let cls = null;
43
43
  </script>
44
44
 
45
45
  <fieldset class="ons-fieldset {cls}">
@@ -2,10 +2,10 @@
2
2
  /** @typedef {typeof __propDef.events} RadiosEvents */
3
3
  /** @typedef {typeof __propDef.slots} RadiosSlots */
4
4
  export default class Radios extends SvelteComponentTyped<{
5
- cls?: string | undefined;
5
+ cls?: string | null | undefined;
6
6
  id?: string | undefined;
7
- label?: string | undefined;
8
- title?: string | undefined;
7
+ label?: string | null | undefined;
8
+ title?: string | null | undefined;
9
9
  compact?: boolean | undefined;
10
10
  hideTitle?: boolean | undefined;
11
11
  items?: object[] | undefined;
@@ -24,10 +24,10 @@ export type RadiosSlots = typeof __propDef.slots;
24
24
  import { SvelteComponentTyped } from "svelte";
25
25
  declare const __propDef: {
26
26
  props: {
27
- cls?: string | undefined;
27
+ cls?: string | null | undefined;
28
28
  id?: string | undefined;
29
- label?: string | undefined;
30
- title?: string | undefined;
29
+ label?: string | null | undefined;
30
+ title?: string | null | undefined;
31
31
  compact?: boolean | undefined;
32
32
  hideTitle?: boolean | undefined;
33
33
  items?: object[] | undefined;
@@ -26,8 +26,10 @@
26
26
  </div>
27
27
  {/snippet}
28
28
 
29
+ <Story name="Default" args={{ id: "default", label: "Select an option", options }} {template} />
30
+
29
31
  <Story
30
- name="Default"
32
+ name="Pre-selected value"
31
33
  args={{ id: "default", value: options[0], label: "Select an option", options }}
32
34
  {template}
33
35
  />
@@ -65,9 +65,9 @@
65
65
  export let labelKey = "label";
66
66
  /**
67
67
  * The attribute of an option that defines its group (optional)
68
- * @type {string}
68
+ * @type {string|null}
69
69
  */
70
- export let groupKey = "";
70
+ export let groupKey = null;
71
71
  /**
72
72
  * Optional: Minimum query length to return results
73
73
  * @type {number}
@@ -100,19 +100,23 @@
100
100
  * @type {function}
101
101
  */
102
102
  export async function clearInput() {
103
+ await setInputValue(null);
104
+ dispatch("clear", null);
105
+ }
106
+ /**
107
+ * Optional: Set an additional CSS class for the component
108
+ * @type {string|null}
109
+ */
110
+ export let cls = null;
111
+
112
+ async function setInputValue(textValue) {
103
113
  hideMenu = true;
104
- inputElement.value = "";
114
+ inputElement.value = textValue || "";
105
115
  await sleep(110);
106
116
  inputElement.focus({ preventScroll: true });
107
117
  inputElement.blur();
108
118
  hideMenu = false;
109
- dispatch("clear", value);
110
119
  }
111
- /**
112
- * Optional: Set an additional CSS class for the component
113
- * @type {string}
114
- */
115
- export let cls = "";
116
120
 
117
121
  function inputValueTemplate(result) {
118
122
  return result && result[labelKey];
@@ -138,11 +142,13 @@
138
142
  }
139
143
 
140
144
  async function select(option) {
141
- value = option;
142
- dispatch("change", value);
143
- if (value && autoClear) {
144
- await sleep(0);
145
- clearInput();
145
+ if (option && value !== option) {
146
+ value = option;
147
+ dispatch("change", value);
148
+ if (value && autoClear) {
149
+ await sleep(0);
150
+ clearInput();
151
+ }
146
152
  }
147
153
  }
148
154
 
@@ -163,7 +169,6 @@
163
169
  id,
164
170
  name: `${id}-input`,
165
171
  source: loadOptions,
166
- defaultValue: value?.[labelKey] || "",
167
172
  autoselect: true,
168
173
  onConfirm: select,
169
174
  confirmOnBlur: false,
@@ -177,10 +182,21 @@
177
182
  suggestion: suggestionTemplate
178
183
  }
179
184
  });
180
- inputElement = document.getElementById(id);
185
+ inputElement = element.querySelector(`#${id}`);
186
+ setInputValue(value?.[labelKey] || "");
181
187
  inputElement.addEventListener("blur", inputChange);
182
188
  }
183
189
 
190
+ // In case input value is updated from outside component
191
+ function bindInputValue(value) {
192
+ if (inputElement) {
193
+ const textValue = value?.[labelKey];
194
+ if (textValue && inputElement.value !== textValue) setInputValue(textValue);
195
+ else if (!value && inputElement.value) setInputValue("");
196
+ }
197
+ }
198
+ $: bindInputValue(value);
199
+
184
200
  onMount(handleScriptLoad);
185
201
  </script>
186
202
 
@@ -2,7 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} SelectEvents */
3
3
  /** @typedef {typeof __propDef.slots} SelectSlots */
4
4
  export default class Select extends SvelteComponentTyped<{
5
- cls?: string | undefined;
5
+ cls?: string | null | undefined;
6
6
  id?: string | undefined;
7
7
  label?: string | undefined;
8
8
  mode?: "default" | "search" | undefined;
@@ -13,7 +13,7 @@ export default class Select extends SvelteComponentTyped<{
13
13
  clearable?: boolean | undefined;
14
14
  autoClear?: boolean | undefined;
15
15
  labelKey?: string | undefined;
16
- groupKey?: string | undefined;
16
+ groupKey?: string | null | undefined;
17
17
  minLength?: number | undefined;
18
18
  loadOptions?: Function | undefined;
19
19
  scriptUrl?: string | undefined;
@@ -32,7 +32,7 @@ export type SelectSlots = typeof __propDef.slots;
32
32
  import { SvelteComponentTyped } from "svelte";
33
33
  declare const __propDef: {
34
34
  props: {
35
- cls?: string | undefined;
35
+ cls?: string | null | undefined;
36
36
  id?: string | undefined;
37
37
  label?: string | undefined;
38
38
  mode?: "default" | "search" | undefined;
@@ -43,7 +43,7 @@ declare const __propDef: {
43
43
  clearable?: boolean | undefined;
44
44
  autoClear?: boolean | undefined;
45
45
  labelKey?: string | undefined;
46
- groupKey?: string | undefined;
46
+ groupKey?: string | null | undefined;
47
47
  minLength?: number | undefined;
48
48
  loadOptions?: Function | undefined;
49
49
  scriptUrl?: string | undefined;
@@ -5,14 +5,14 @@
5
5
 
6
6
  /**
7
7
  * ID for &lt;textarea&gt; element
8
- * @type {string}
8
+ * @type {string|null}
9
9
  */
10
- export let id = "";
10
+ export let id = null;
11
11
  /**
12
12
  * A prop to bind to for the entered value
13
- * @type {string}
13
+ * @type {string|null}
14
14
  */
15
- export let value = "";
15
+ export let value = null;
16
16
  /**
17
17
  * A label to describe the &lt;textarea&gt; element (expected for accessibility)
18
18
  * @type {string}
@@ -25,9 +25,9 @@
25
25
  export let hideLabel = false;
26
26
  /**
27
27
  * An optional description to help users know what to enter
28
- * @type {string}
28
+ * @type {string|null}
29
29
  */
30
- export let description = "";
30
+ export let description = null;
31
31
  /**
32
32
  * The maximum number of characters that can be entered (optional)
33
33
  * @type {number|null}
@@ -45,9 +45,9 @@
45
45
  export let width = 30;
46
46
  /**
47
47
  * Optional: Set an additional CSS class for the component
48
- * @type {string}
48
+ * @type {string|null}
49
49
  */
50
- export let cls = "";
50
+ export let cls = null;
51
51
 
52
52
  $: remaining = charLimit && value.length ? charLimit - value.length : charLimit || null;
53
53
  </script>
@@ -2,12 +2,12 @@
2
2
  /** @typedef {typeof __propDef.events} TextareaEvents */
3
3
  /** @typedef {typeof __propDef.slots} TextareaSlots */
4
4
  export default class Textarea extends SvelteComponentTyped<{
5
- cls?: string | undefined;
6
- id?: string | undefined;
5
+ cls?: string | null | undefined;
6
+ id?: string | null | undefined;
7
7
  width?: number | undefined;
8
8
  label?: string | undefined;
9
- value?: string | undefined;
10
- description?: string | undefined;
9
+ value?: string | null | undefined;
10
+ description?: string | null | undefined;
11
11
  hideLabel?: boolean | undefined;
12
12
  charLimit?: number | null | undefined;
13
13
  rows?: number | undefined;
@@ -21,12 +21,12 @@ export type TextareaSlots = typeof __propDef.slots;
21
21
  import { SvelteComponentTyped } from "svelte";
22
22
  declare const __propDef: {
23
23
  props: {
24
- cls?: string | undefined;
25
- id?: string | undefined;
24
+ cls?: string | null | undefined;
25
+ id?: string | null | undefined;
26
26
  width?: number | undefined;
27
27
  label?: string | undefined;
28
- value?: string | undefined;
29
- description?: string | undefined;
28
+ value?: string | null | undefined;
29
+ description?: string | null | undefined;
30
30
  hideLabel?: boolean | undefined;
31
31
  charLimit?: number | null | undefined;
32
32
  rows?: number | undefined;
@@ -11,9 +11,9 @@
11
11
  export let id = slugify();
12
12
  /**
13
13
  * Optional: Set an additional CSS class for the component
14
- * @type {string}
14
+ * @type {string|null}
15
15
  */
16
- export let cls = "";
16
+ export let cls = null;
17
17
  /**
18
18
  * Option to include a "show all" toggle above the accordion
19
19
  * @type {boolean}
@@ -2,7 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} AccordionEvents */
3
3
  /** @typedef {typeof __propDef.slots} AccordionSlots */
4
4
  export default class Accordion extends SvelteComponentTyped<{
5
- cls?: string | undefined;
5
+ cls?: string | null | undefined;
6
6
  id?: string | undefined;
7
7
  showToggle?: boolean | undefined;
8
8
  }, {
@@ -17,7 +17,7 @@ export type AccordionSlots = typeof __propDef.slots;
17
17
  import { SvelteComponentTyped } from "svelte";
18
18
  declare const __propDef: {
19
19
  props: {
20
- cls?: string | undefined;
20
+ cls?: string | null | undefined;
21
21
  id?: string | undefined;
22
22
  showToggle?: boolean | undefined;
23
23
  };