@onsvisual/svelte-components 1.0.32 → 1.0.34

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.
@@ -8,6 +8,11 @@
8
8
  * @type {string|null}
9
9
  */
10
10
  export let id = null;
11
+ /**
12
+ * Name for the <select> element
13
+ * @type {string|null}
14
+ */
15
+ export let name = id;
11
16
  /**
12
17
  * A label to describe the <select> element (expected for accessibility)
13
18
  * @type {string|null}
@@ -46,7 +51,7 @@
46
51
  {/if}
47
52
  <select
48
53
  {id}
49
- name={id}
54
+ {name}
50
55
  class="ons-input ons-input--select"
51
56
  bind:value
52
57
  on:change={(e) => dispatch("change", e)}
@@ -5,6 +5,7 @@ export default class Dropdown extends SvelteComponentTyped<{
5
5
  cls?: string | null | undefined;
6
6
  id?: string | null | undefined;
7
7
  label?: string | null | undefined;
8
+ name?: string | null | undefined;
8
9
  value?: object | null | undefined;
9
10
  hideLabel?: boolean | undefined;
10
11
  placeholder?: string | undefined;
@@ -24,6 +25,7 @@ declare const __propDef: {
24
25
  cls?: string | null | undefined;
25
26
  id?: string | null | undefined;
26
27
  label?: string | null | undefined;
28
+ name?: string | null | undefined;
27
29
  value?: object | null | undefined;
28
30
  hideLabel?: boolean | undefined;
29
31
  placeholder?: string | undefined;
@@ -8,6 +8,11 @@
8
8
  * @type {string|null}
9
9
  */
10
10
  export let id = null;
11
+ /**
12
+ * Name attribute for &lt;input&gt; element
13
+ * @type {string|null}
14
+ */
15
+ export let name = id;
11
16
  /**
12
17
  * A prop to bind to for the entered value
13
18
  * @type {string|null}
@@ -103,6 +108,7 @@
103
108
  <input
104
109
  type="text"
105
110
  {id}
111
+ {name}
106
112
  bind:value
107
113
  maxlength={charLimit}
108
114
  pattern={pattern ? pattern : numeric ? "[0-9]*" : null}
@@ -129,6 +135,7 @@
129
135
  <input
130
136
  type="text"
131
137
  {id}
138
+ {name}
132
139
  bind:value
133
140
  pattern={pattern ? pattern : numeric ? "[0-9]*" : null}
134
141
  inputmode={numeric ? "numeric" : null}
@@ -7,6 +7,7 @@ export default class Input extends SvelteComponentTyped<{
7
7
  width?: number | undefined;
8
8
  label?: string | undefined;
9
9
  pattern?: string | null | undefined;
10
+ name?: string | null | undefined;
10
11
  error?: boolean | undefined;
11
12
  numeric?: boolean | undefined;
12
13
  value?: string | null | undefined;
@@ -34,6 +35,7 @@ declare const __propDef: {
34
35
  width?: number | undefined;
35
36
  label?: string | undefined;
36
37
  pattern?: string | null | undefined;
38
+ name?: string | null | undefined;
37
39
  error?: boolean | undefined;
38
40
  numeric?: boolean | undefined;
39
41
  value?: string | null | undefined;
@@ -24,7 +24,7 @@
24
24
  */
25
25
  export let item = { id, label, description };
26
26
  /**
27
- * ID for radio group (required)
27
+ * ID/name for radio group (required)
28
28
  * @type {string}
29
29
  */
30
30
  export let groupId;
@@ -12,10 +12,10 @@
12
12
  */
13
13
  export let hideTitle = false;
14
14
  /**
15
- * Unique ID for radio group (required)
15
+ * Unique ID/name for radio group (required)
16
16
  * @type {string}
17
17
  */
18
- export let id = "name";
18
+ export let id = "radios";
19
19
  /**
20
20
  * Descriptive "how to" label for inputs
21
21
  * @type {string|null}
@@ -16,10 +16,15 @@
16
16
  let hideMenu = false;
17
17
 
18
18
  /**
19
- * Unique id for the element
19
+ * Unique id for the HTML element
20
20
  * @type {string}
21
21
  */
22
22
  export let id = "autocomplete";
23
+ /**
24
+ * Name for the HTML element
25
+ * @type {string}
26
+ */
27
+ export let name = id;
23
28
  /**
24
29
  * The mode can be either "default" or "search"
25
30
  * @type {"default"|"search"}
@@ -173,7 +178,7 @@
173
178
  accessibleAutocomplete({
174
179
  element,
175
180
  id,
176
- name: `${id}-input`,
181
+ name,
177
182
  source: loadOptions,
178
183
  autoselect: true,
179
184
  onConfirm: select,
@@ -212,9 +217,9 @@
212
217
 
213
218
  {#if renderFallback && !scriptLoaded}
214
219
  {#if mode === "search"}
215
- <Input {id} {label} {hideLabel} value={value?.[labelKey]} />
220
+ <Input {id} {name} {label} {hideLabel} value={value?.[labelKey]} />
216
221
  {:else}
217
- <Dropdown {id} {options} {label} {hideLabel} {placeholder} {value} />
222
+ <Dropdown {id} {name} {options} {label} {hideLabel} {placeholder} {value} />
218
223
  {/if}
219
224
  {:else}
220
225
  <div class="ons-field {cls}">
@@ -5,6 +5,7 @@ export default class Select extends SvelteComponentTyped<{
5
5
  cls?: string | null | undefined;
6
6
  id?: string | undefined;
7
7
  label?: string | undefined;
8
+ name?: string | undefined;
8
9
  mode?: "default" | "search" | undefined;
9
10
  value?: object | undefined;
10
11
  hideLabel?: boolean | undefined;
@@ -35,6 +36,7 @@ declare const __propDef: {
35
36
  cls?: string | null | undefined;
36
37
  id?: string | undefined;
37
38
  label?: string | undefined;
39
+ name?: string | undefined;
38
40
  mode?: "default" | "search" | undefined;
39
41
  value?: object | undefined;
40
42
  hideLabel?: boolean | undefined;
@@ -8,6 +8,11 @@
8
8
  * @type {string|null}
9
9
  */
10
10
  export let id = null;
11
+ /**
12
+ * Name for &lt;textarea&gt; element
13
+ * @type {string|null}
14
+ */
15
+ export let name = id;
11
16
  /**
12
17
  * A prop to bind to for the entered value
13
18
  * @type {string|null}
@@ -68,11 +73,11 @@
68
73
  {/if}
69
74
  <textarea
70
75
  {id}
76
+ {name}
71
77
  bind:value
72
78
  class="ons-input ons-input--textarea {Number.isInteger(width) ? `ons-input--w-${width}` : null}"
73
79
  class:ons-js-char-limit-input={charLimit}
74
80
  class:ons-input--limit-reached={remaining === 0}
75
- name={id}
76
81
  {rows}
77
82
  maxlength={charLimit}
78
83
  data-char-limit-ref="{id}-lim"
@@ -6,6 +6,7 @@ export default class Textarea extends SvelteComponentTyped<{
6
6
  id?: string | null | undefined;
7
7
  width?: number | undefined;
8
8
  label?: string | undefined;
9
+ name?: string | null | undefined;
9
10
  value?: string | null | undefined;
10
11
  description?: string | null | undefined;
11
12
  hideLabel?: boolean | undefined;
@@ -25,6 +26,7 @@ declare const __propDef: {
25
26
  id?: string | null | undefined;
26
27
  width?: number | undefined;
27
28
  label?: string | undefined;
29
+ name?: string | null | undefined;
28
30
  value?: string | null | undefined;
29
31
  description?: string | null | undefined;
30
32
  hideLabel?: boolean | undefined;
@@ -49,12 +49,27 @@
49
49
  "This handbook explains what the census is, why it matters to everyone and how we can work together to spread the word within your community."
50
50
  }
51
51
  ];
52
+
53
+ const items3 = [
54
+ {
55
+ title: "Including everyone in Census",
56
+ href: "#0",
57
+ meta: "Poster, PDF, 499KB, 1 page"
58
+ },
59
+ {
60
+ title: "Community handbook for Census 2021",
61
+ href: "#0",
62
+ meta: "Booklet,PDF, 3.3MB, 16 pages"
63
+ }
64
+ ];
52
65
  </script>
53
66
 
54
67
  <Story name="Document list with images" args={{ items: items1 }} />
55
68
 
56
69
  <Story name="Article list with featured item" args={{ items: items2 }} />
57
70
 
71
+ <Story name="Compact list, no description" args={{ items: items3, compact: true }} />
72
+
58
73
  <Story name="Individually defined documents" asChild parameters={withStoryDocs(exampleDocs)}>
59
74
  <DocumentList>
60
75
  <Document
@@ -5,6 +5,10 @@
5
5
  * @type {object[]|null}
6
6
  */
7
7
  export let items = null;
8
+ /** Compact mode. Removes horizonatal lines between documents
9
+ * @type {boolean}
10
+ */
11
+ export let compact = false;
8
12
  /**
9
13
  * Optional: Set an additional CSS class for the component
10
14
  * @type {string|null}
@@ -12,7 +16,7 @@
12
16
  export let cls = null;
13
17
  </script>
14
18
 
15
- <ul class="ons-document-list {cls}">
19
+ <ul class="ons-document-list {cls}" class:ons-document-list--compact={compact}>
16
20
  <slot />
17
21
  {#if Array.isArray(items)}
18
22
  {#each items as item}
@@ -20,3 +24,10 @@
20
24
  {/each}
21
25
  {/if}
22
26
  </ul>
27
+
28
+ <style>
29
+ .ons-document-list--compact > :global(.ons-document-list__item) {
30
+ padding-bottom: 0;
31
+ border: none;
32
+ }
33
+ </style>
@@ -3,6 +3,7 @@
3
3
  /** @typedef {typeof __propDef.slots} DocumentListSlots */
4
4
  export default class DocumentList extends SvelteComponentTyped<{
5
5
  cls?: string | null | undefined;
6
+ compact?: boolean | undefined;
6
7
  items?: object[] | null | undefined;
7
8
  }, {
8
9
  [evt: string]: CustomEvent<any>;
@@ -17,6 +18,7 @@ import { SvelteComponentTyped } from "svelte";
17
18
  declare const __propDef: {
18
19
  props: {
19
20
  cls?: string | null | undefined;
21
+ compact?: boolean | undefined;
20
22
  items?: object[] | null | undefined;
21
23
  };
22
24
  events: {
@@ -340,7 +340,9 @@
340
340
  </svg>
341
341
  </div>
342
342
  {/if}
343
- <DescriptionList items={meta || []} mode="inline" />
343
+ {#if Array.isArray(meta)}
344
+ <DescriptionList items={meta} mode="inline" />
345
+ {/if}
344
346
  <slot name="after" />
345
347
  </div>
346
348
  </Container>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run build:package && npm run build:docs",