@functionalcms/svelte-components 4.36.9 → 5.0.0-beta1

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 (127) hide show
  1. package/css/functional.css +48 -1
  2. package/dist/auth/getMachineAccessToken.d.ts +1 -1
  3. package/dist/auth/getMachineAccessToken.js +1 -2
  4. package/dist/auth/machineAuthenticationProvider.d.ts +1 -1
  5. package/dist/auth/machineAuthenticationProvider.js +1 -2
  6. package/dist/auth/tokenRefresh.d.ts +1 -1
  7. package/dist/auth/tokenRefresh.js +4 -5
  8. package/dist/auth/types.js +4 -8
  9. package/dist/auth/userAuthenticationProvider.d.ts +1 -1
  10. package/dist/auth/userAuthenticationProvider.js +1 -2
  11. package/dist/components/Icon.svelte +16 -0
  12. package/dist/components/Icon.svelte.d.ts +9 -0
  13. package/dist/components/content/Markdown.svelte +2 -2
  14. package/dist/components/content/Markdown.svelte.d.ts +17 -4
  15. package/dist/components/form/Dropzone.svelte +2 -5
  16. package/dist/components/form/SmartForm.svelte +206 -60
  17. package/dist/components/form/SmartForm.svelte.d.ts +2 -2
  18. package/dist/components/form/form.d.ts +87 -17
  19. package/dist/components/form/form.js +86 -6
  20. package/dist/components/icons.d.ts +763 -0
  21. package/dist/components/icons.js +765 -0
  22. package/dist/components/integrations/EasyTools.svelte +1 -1
  23. package/dist/components/layouts/DefaultLayout.svelte +92 -41
  24. package/dist/components/layouts/DefaultLayout.svelte.d.ts +17 -8
  25. package/dist/components/layouts/FlexBox.svelte +73 -0
  26. package/dist/components/layouts/FlexBox.svelte.d.ts +17 -0
  27. package/dist/components/layouts/MenuLayout.svelte +39 -201
  28. package/dist/components/layouts/MenuLayout.svelte.d.ts +2 -10
  29. package/dist/components/layouts/StyleBox.svelte +17 -0
  30. package/dist/components/layouts/StyleBox.svelte.d.ts +7 -0
  31. package/dist/components/layouts/Well.svelte +8 -34
  32. package/dist/components/layouts/Well.svelte.d.ts +4 -8
  33. package/dist/components/layouts/menuItems.d.ts +29 -0
  34. package/dist/components/layouts/menuItems.js +28 -0
  35. package/dist/index-server.d.ts +2 -1
  36. package/dist/index-server.js +2 -1
  37. package/dist/index.d.ts +9 -47
  38. package/dist/index.js +8 -59
  39. package/dist/server-side/getServices.d.ts +8 -8
  40. package/dist/server-side/getServices.js +16 -27
  41. package/dist/server-side/handlers/paraglideHandler.d.ts +2 -0
  42. package/dist/server-side/handlers/paraglideHandler.js +13 -0
  43. package/dist/server-side/handlers/redirectPipelineHandler.d.ts +5 -0
  44. package/dist/server-side/{getRedirectPipeline.js → handlers/redirectPipelineHandler.js} +1 -2
  45. package/dist/utils/stringHash.d.ts +1 -0
  46. package/dist/utils/stringHash.js +7 -0
  47. package/package.json +28 -39
  48. package/css/functional.css.map +0 -1
  49. package/dist/components/MaterialIconSet.d.ts +0 -3819
  50. package/dist/components/MaterialIconSet.js +0 -3823
  51. package/dist/components/Styling.d.ts +0 -59
  52. package/dist/components/Styling.js +0 -66
  53. package/dist/components/blog/blog.d.ts +0 -20
  54. package/dist/components/blog/blog.js +0 -29
  55. package/dist/components/dynamic/CopyToClipboard.svelte +0 -16
  56. package/dist/components/dynamic/CopyToClipboard.svelte.d.ts +0 -36
  57. package/dist/components/dynamic/DynamicButton.d.ts +0 -1
  58. package/dist/components/dynamic/DynamicButton.js +0 -10
  59. package/dist/components/dynamic/DynamicButton.svelte +0 -33
  60. package/dist/components/dynamic/DynamicButton.svelte.d.ts +0 -9
  61. package/dist/components/form/Button.svelte +0 -389
  62. package/dist/components/form/Button.svelte.d.ts +0 -30
  63. package/dist/components/form/ChoiceInput.svelte +0 -375
  64. package/dist/components/form/ChoiceInput.svelte.d.ts +0 -3
  65. package/dist/components/form/Input.svelte +0 -461
  66. package/dist/components/form/Input.svelte.d.ts +0 -30
  67. package/dist/components/form/Select.svelte +0 -163
  68. package/dist/components/form/Select.svelte.d.ts +0 -21
  69. package/dist/components/form/Switch.svelte +0 -293
  70. package/dist/components/form/Switch.svelte.d.ts +0 -14
  71. package/dist/components/indicators/Loader.svelte +0 -114
  72. package/dist/components/indicators/Loader.svelte.d.ts +0 -30
  73. package/dist/components/indicators/Spinner.svelte +0 -109
  74. package/dist/components/indicators/Spinner.svelte.d.ts +0 -28
  75. package/dist/components/layouts/Banner.svelte +0 -26
  76. package/dist/components/layouts/Banner.svelte.d.ts +0 -8
  77. package/dist/components/layouts/FoldablePanel.svelte +0 -16
  78. package/dist/components/layouts/FoldablePanel.svelte.d.ts +0 -7
  79. package/dist/components/layouts/SimpleFooter.svelte +0 -23
  80. package/dist/components/layouts/SimpleFooter.svelte.d.ts +0 -8
  81. package/dist/components/layouts/Tabs.svelte +0 -362
  82. package/dist/components/layouts/Tabs.svelte.d.ts +0 -11
  83. package/dist/components/layouts/TwoColumnsLayout.svelte +0 -44
  84. package/dist/components/layouts/TwoColumnsLayout.svelte.d.ts +0 -13
  85. package/dist/components/layouts/menuLayout.d.ts +0 -12
  86. package/dist/components/layouts/menuLayout.js +0 -1
  87. package/dist/components/layouts/tabs.d.ts +0 -21
  88. package/dist/components/layouts/tabs.js +0 -13
  89. package/dist/components/menu/CollapsibleMenu.svelte +0 -66
  90. package/dist/components/menu/CollapsibleMenu.svelte.d.ts +0 -18
  91. package/dist/components/menu/DynamicMenu.svelte +0 -55
  92. package/dist/components/menu/DynamicMenu.svelte.d.ts +0 -13
  93. package/dist/components/menu/HamburgerMenu.svelte +0 -62
  94. package/dist/components/menu/HamburgerMenu.svelte.d.ts +0 -14
  95. package/dist/components/menu/ListMenu.svelte +0 -61
  96. package/dist/components/menu/ListMenu.svelte.d.ts +0 -17
  97. package/dist/components/menu/NavigationDrawer.svelte +0 -53
  98. package/dist/components/menu/NavigationDrawer.svelte.d.ts +0 -18
  99. package/dist/components/menu/types.d.ts +0 -23
  100. package/dist/components/menu/types.js +0 -35
  101. package/dist/components/presentation/Accordion.svelte +0 -82
  102. package/dist/components/presentation/Accordion.svelte.d.ts +0 -11
  103. package/dist/components/presentation/Card.svelte +0 -147
  104. package/dist/components/presentation/Card.svelte.d.ts +0 -15
  105. package/dist/components/presentation/Carousel.d.ts +0 -5
  106. package/dist/components/presentation/Carousel.js +0 -1
  107. package/dist/components/presentation/Carousel.svelte +0 -119
  108. package/dist/components/presentation/Carousel.svelte.d.ts +0 -17
  109. package/dist/components/presentation/Dialog.svelte +0 -75
  110. package/dist/components/presentation/Dialog.svelte.d.ts +0 -22
  111. package/dist/components/presentation/Disclose.svelte +0 -116
  112. package/dist/components/presentation/Disclose.svelte.d.ts +0 -11
  113. package/dist/components/presentation/Drawer.svelte +0 -118
  114. package/dist/components/presentation/Drawer.svelte.d.ts +0 -13
  115. package/dist/components/presentation/EmptyState.svelte +0 -67
  116. package/dist/components/presentation/EmptyState.svelte.d.ts +0 -10
  117. package/dist/components/presentation/Gallery.svelte +0 -35
  118. package/dist/components/presentation/Gallery.svelte.d.ts +0 -14
  119. package/dist/components/presentation/Link.svelte +0 -362
  120. package/dist/components/presentation/Link.svelte.d.ts +0 -27
  121. package/dist/components/utils.d.ts +0 -3
  122. package/dist/components/utils.js +0 -1
  123. package/dist/index.server.d.ts +0 -11
  124. package/dist/index.server.js +0 -10
  125. package/dist/server-side/getRedirectPipeline.d.ts +0 -6
  126. package/dist/utils.d.ts +0 -1
  127. package/dist/utils.js +0 -3
@@ -1,461 +0,0 @@
1
- <script lang="ts">
2
- import { cn } from '../../utils.js';
3
- import type { Snippet } from 'svelte';
4
- import { InputType, LabelSize } from './form.js';
5
-
6
- interface Props{
7
- label: string;
8
- labelSize: LabelSize;
9
- labelCss: string;
10
- isLabelHidden: boolean;
11
-
12
- id: string;
13
- name: string;
14
- helpText: string;
15
-
16
- isInvalid: boolean;
17
- invalidText: string;
18
-
19
- isInline: boolean;
20
- isRounded: boolean;
21
- isSkinned: boolean;
22
- isUnderlinedWithBackground: boolean;
23
- isUnderlined: boolean;
24
-
25
- isDisabled: boolean | undefined;
26
- isRequired: boolean | undefined;
27
-
28
- css: string;
29
-
30
- placeholder: string;
31
-
32
- type: InputType;
33
-
34
- maxLength: number | undefined;
35
- minLength: number | undefined;
36
-
37
- value: string | any;
38
- addonLeft: Snippet;
39
- addonRight: Snippet;
40
- }
41
-
42
- let {
43
- addonLeft,
44
- addonRight,
45
- label = '',
46
- id = '',
47
- name = '',
48
- labelCss = '',
49
- isLabelHidden = false,
50
- helpText = '',
51
- isInvalid = false,
52
- invalidText = '',
53
- isInline = false,
54
- isRounded = false,
55
- isDisabled = undefined,
56
- isRequired = undefined,
57
- css = '',
58
- isSkinned = true,
59
- isUnderlinedWithBackground = false,
60
- isUnderlined = false,
61
- labelSize = LabelSize.None,
62
- type = InputType.Text,
63
- value = '',
64
- placeholder= '',
65
- ...restProps
66
- }: Partial<Props> = $props();
67
-
68
- let labelClasses = $derived(
69
- cn(
70
- 'label',
71
- isInvalid ? 'label-error' : '',
72
- isInline ? 'label-inline' : '',
73
- labelSize ? `label-${labelSize}` : '',
74
- isLabelHidden ? 'screenreader-only' : '',
75
- labelCss ? labelCss : ''
76
- )
77
- );
78
-
79
- let inputClasses = $derived(
80
- cn(
81
- isSkinned ? 'input' : 'input-base',
82
- isRounded ? 'input-rounded' : '',
83
- isUnderlined ? 'input-underlined' : '',
84
- addonLeft ? 'input-has-left-addon' : '',
85
- addonRight ? 'input-has-right-addon' : '',
86
- isDisabled ? 'disabled' : '',
87
- isInvalid ? 'input-error' : '',
88
- isInline ? 'input-inline' : '',
89
- isUnderlinedWithBackground ? 'input-underlined-bg' : '',
90
- css ? css : '',
91
- labelSize ? `input-${labelSize}` : ''
92
- )
93
- );
94
-
95
- let invalidClasses = $derived(labelSize ? `field-error-${labelSize}` : 'field-error');
96
-
97
- let helpClasses = $derived(labelSize ? `field-help-${labelSize}` : 'field-help');
98
-
99
- let addonContainerClasses = () => 'input-addon-container';
100
-
101
- const handleInput = (e: Event) => {
102
- value = (e.target as HTMLInputElement).value;
103
- };
104
- </script>
105
-
106
- {#snippet input()}
107
- <input
108
- {id}
109
- {name}
110
- {type}
111
- {placeholder}
112
- bind:value
113
- class={inputClasses}
114
- disabled={isDisabled}
115
- required={isRequired}
116
- oninput={handleInput}
117
- {...restProps}
118
- />
119
- {/snippet}
120
-
121
- <div class="w-100">
122
- <label class={labelClasses} for={id}>{label}</label>
123
- {#if type == InputType.Textarea}
124
- <textarea
125
- {id}
126
- {name}
127
- {placeholder}
128
- class={inputClasses}
129
- bind:value
130
- oninput={handleInput}
131
- required={isRequired}
132
- {...restProps}></textarea>
133
- {:else if addonLeft || addonRight}
134
- <div class={addonContainerClasses()}>
135
- {#if addonLeft}
136
- {@render addonLeft()}
137
- {/if}
138
- {@render input()}
139
- {#if addonRight}
140
- {@render addonRight()}
141
- {/if}
142
- </div>
143
- {:else}
144
- {@render input()}
145
- {/if}
146
- {#if isInvalid}
147
- <span role="status" aria-live="polite" class={invalidClasses}>
148
- {invalidText}
149
- </span>
150
- {:else if helpText}<span class={helpClasses}>{helpText}</span>{/if}
151
- </div>
152
-
153
- <style>
154
- .input-base,
155
- .input {
156
- /* Note this cannot be user-select: none else mobile safari won't accept input:
157
- https://stackoverflow.com/questions/49889003/cannot-write-into-input-field-on-safari/49901069
158
- */
159
- user-select: initial;
160
- appearance: none;
161
- box-sizing: border-box;
162
-
163
- /* Use the same color for the cursor */
164
- caret-color: currentColor;
165
- }
166
-
167
- .label,
168
- .label-base {
169
- padding: 0;
170
- border: 0;
171
- box-sizing: border-box;
172
- font-family: inherit;
173
- }
174
-
175
- /* Electing to scope these as opposed to doing :root level definitions */
176
- .field-help,
177
- .field-help-large,
178
- .field-help-small,
179
- .field-error,
180
- .field-error-large,
181
- .field-error-small,
182
- .label-skin,
183
- .label,
184
- .input-addon-container,
185
- .input-small,
186
- .input-large,
187
- .input-skin,
188
- .input-underlined,
189
- .input-underlined-bg,
190
- .input {
191
- color: var(--font-color, var(--dark));
192
- font-family: var(--font-family-body);
193
- font-weight: var(--font-weight, 300);
194
- font-size: var(--font-size, 1rem);
195
- line-height: var(--line-height, var(--fluid-20, 1.25rem));
196
- width: 100%;
197
- max-width: 100%;
198
- }
199
-
200
- .input-skin,
201
- .input {
202
- /* seems like a reasonable default as chrome picks `outset` which results in a weird 3d effect */
203
- border-style: solid;
204
-
205
- /* this can be overriden, but it might mess with the balance of the button heights across variants */
206
- border-width: var(--input-border-size, 1px);
207
- border-color: var(--input-border-color, var(--gray-light));
208
-
209
- /* these can be overriden, but it might mess with the balance of the inputheights across variants */
210
- padding-block-start: var(--input-vertical-pad, 0.5rem);
211
- padding-block-end: var(--input-vertical-pad, 0.5rem);
212
- padding-inline-start: var(--input-side-padding, 0.75rem);
213
- padding-inline-end: var(--input-side-padding, 0.75rem);
214
-
215
- /* Note we only want to set properties that we actually want
216
- to transition in. For example, if we transition "all", the
217
- inputs will "grow in" on page load—not a happy effect :) */
218
- transition-property: box-shadow;
219
- transition-duration: var(--input-timing, var(--timing-medium));
220
- }
221
-
222
- .label {
223
- display: inline-block;
224
-
225
- /* Provided --input-vertical-pad isn't overriden we'll get 20px
226
- label w/a 6px margin then a 38px input = 64 which is on the 8pt grid */
227
- margin-block-start: 0;
228
- margin-inline-start: 0;
229
- margin-inline-end: 0;
230
- margin-block-end: var(--input-label-pad, 0.375rem);
231
- vertical-align: initial;
232
- }
233
-
234
- /* Reset field errors and help text to be 2px less then input font size */
235
- .field-help,
236
- .field-error {
237
- font-size: calc(var(--font-size, 1rem) - 2px);
238
- }
239
-
240
- .label-inline,
241
- .input-inline {
242
- width: auto;
243
- }
244
-
245
- /* When inlined, the margin-block-end will throw the label off-center with adjacent input */
246
- .label-inline {
247
- margin-block-start: 0;
248
- margin-block-end: 0;
249
- margin-inline-start: 0;
250
- margin-inline-end: var(--input-side-padding, 0.75rem);
251
- }
252
-
253
- /**
254
- * Placeholder
255
- */
256
-
257
- /* stylelint-disable-next-line */
258
- .input::-webkit-input-placeholder {
259
- color: currentColor;
260
- opacity: 50%;
261
- transition: opacity var(--timing-fast) ease-out;
262
- }
263
-
264
- /* stylelint-disable-next-line */
265
- .input::placeholder {
266
- color: currentColor;
267
- opacity: 50%;
268
- transition: opacity var(--timing-fast) ease-out;
269
- }
270
-
271
- /* stylelint-disable-next-line */
272
- .input::-ms-placeholder {
273
- color: currentColor;
274
- opacity: 50%;
275
- transition: opacity var(--timing-fast) ease-out;
276
- }
277
-
278
- /* stylelint-disable-next-line */
279
- .input:-ms-placeholder {
280
- color: currentColor;
281
- opacity: 50%;
282
- transition: opacity var(--timing-fast) ease-out;
283
- }
284
-
285
- /**
286
- * Underlined inputs
287
- */
288
- .input-underlined {
289
- border-top: 0;
290
- border-left: 0;
291
- border-right: 0;
292
- border-color: var(--input-underlined-color, var(--gray-mid-dark));
293
- background-color: transparent;
294
- }
295
-
296
- .input-underlined-bg {
297
- background-color: var(--input-underlined-bg-color, var(--gray-extra-light));
298
- }
299
-
300
- /**
301
- * Rounded inputs
302
- */
303
- .input-rounded {
304
- border-radius: var(--radius, 0.25rem);
305
- }
306
-
307
- /**
308
- * Errors
309
- * We provide a class-based approach to setting errors which means we do
310
- * not support :invalid, so it requires custom use of html4 validation API
311
- * (see https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation
312
- * of the example in corresponding input.html file). The reason I elected to
313
- * not include :invalid, is it seems to result in "shouting" at the user as
314
- * I did not find an easy way to only kick in errors after a certain number
315
- * of characters have been type (blur is actually better but I did not
316
- * implement that in the contrived example).
317
- */
318
- .label-error {
319
- color: var(--input-error-color, var(--error));
320
- }
321
-
322
- .input-error {
323
- border-color: var(--input-error-color, var(--error));
324
- }
325
-
326
- .label-error,
327
- .field-error,
328
- .field-error-small,
329
- .field-error-large {
330
- color: var(--input-error-color, var(--error));
331
- }
332
-
333
- .field-help,
334
- .field-help-small,
335
- .field-help-large {
336
- color: var(--input-help-color, var(--gray-dark));
337
- }
338
-
339
- .field-help,
340
- .field-help-small,
341
- .field-help-large,
342
- .field-error,
343
- .field-error-small,
344
- .field-error-large {
345
- display: inline-block;
346
- width: 100%;
347
- margin-block-start: calc(var(--input-vertical-pad, 0.5rem) / 2);
348
- }
349
-
350
- /**
351
- * Sizes
352
- */
353
- .input-large {
354
- font-size: calc(var(--font-size, 1rem) + 0.25rem);
355
- line-height: 1.6rem;
356
- }
357
-
358
- .field-help-large,
359
- .field-error-large {
360
- /* We initially remove -2px from font-size so setting to font-size essentially adds the 2px back */
361
- font-size: var(--font-size, 1rem);
362
- }
363
-
364
- .label-large {
365
- font-size: calc(var(--font-size, 1rem) + 0.25rem);
366
- }
367
-
368
- .input-small {
369
- font-size: calc(var(--font-size, 1rem) - 0.25rem);
370
- line-height: 1rem;
371
- }
372
-
373
- .field-help-small,
374
- .field-error-small,
375
- .label-small {
376
- font-size: calc(var(--font-size, 1rem) - 0.25rem);
377
- }
378
-
379
- .input:focus {
380
- box-shadow: 0 0 0 var(--focus-ring-outline-width) var(--focus-ring-color);
381
-
382
- /* Needed for High Contrast mode */
383
- outline: var(--focus-ring-outline-width) var(--focus-ring-outline-style)
384
- var(--focus-ring-outline-color);
385
- transition: box-shadow var(--timing-fast) ease-out;
386
- }
387
-
388
- /* Set the focus to transparent when there's an error since we use
389
- borders that visually conflict. */
390
- .input-error:focus {
391
- box-shadow: 0 0 0 3px transparent;
392
- }
393
-
394
- /*
395
- * Disabled State
396
- *
397
- * The disabled state uses the class .disabled,
398
- * and the form attribute disabled="disabled".
399
- * The use of !important is only added because this is a state
400
- * that must be applied to all inputs when in a disabled state.
401
- */
402
- .input.disabled, /* DEPRECATED -- TODO remove class based disabled */
403
- .input:disabled {
404
- background: var(--input-disabled-bg, var(--disabled-bg)) !important;
405
- color: var(--input-disabled-color, var(--disabled-color)) !important;
406
- appearance: none !important;
407
- box-shadow: none !important;
408
- cursor: not-allowed !important;
409
- opacity: 80% !important;
410
- }
411
-
412
- @media screen and (-ms-high-contrast: active) {
413
- /* High contrast mode outline hacks */
414
-
415
- /* styleint-disable-next-line no-descending-specificity */
416
- .input:disabled {
417
- outline: 2px solid transparent;
418
- outline-offset: -2px;
419
- }
420
- }
421
-
422
- /**
423
- * Input "has addon"
424
- */
425
-
426
- .input-addon-container {
427
- display: flex;
428
- position: relative;
429
- width: 100%;
430
- min-height: 100%;
431
- }
432
-
433
- .input-has-left-addon {
434
- padding-left: calc(var(--side-padding) * 3);
435
- }
436
-
437
- .input-has-right-addon {
438
- padding-right: calc(var(--side-padding) * 3);
439
- }
440
-
441
- .input-addon-left {
442
- left: var(--input-side-padding);
443
- }
444
-
445
- .input-addon-right {
446
- right: var(--input-side-padding);
447
- }
448
-
449
- @media (prefers-reduced-motion), (update: slow) {
450
- /* stylelint-disable selector-no-vendor-prefix */
451
- .input-skin,
452
- .input,
453
- .input::placeholder,
454
- .input::-webkit-input-placeholder,
455
- .input::-ms-placeholder,
456
- .input:-ms-placeholder,
457
- .input:focus {
458
- transition-duration: 0.001ms !important;
459
- }
460
- }
461
- </style>
@@ -1,30 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import { InputType, LabelSize } from './form.js';
3
- declare const Input: import("svelte").Component<Partial<{
4
- label: string;
5
- labelSize: LabelSize;
6
- labelCss: string;
7
- isLabelHidden: boolean;
8
- id: string;
9
- name: string;
10
- helpText: string;
11
- isInvalid: boolean;
12
- invalidText: string;
13
- isInline: boolean;
14
- isRounded: boolean;
15
- isSkinned: boolean;
16
- isUnderlinedWithBackground: boolean;
17
- isUnderlined: boolean;
18
- isDisabled: boolean | undefined;
19
- isRequired: boolean | undefined;
20
- css: string;
21
- placeholder: string;
22
- type: InputType;
23
- maxLength: number | undefined;
24
- minLength: number | undefined;
25
- value: string | any;
26
- addonLeft: Snippet;
27
- addonRight: Snippet;
28
- }>, {}, "">;
29
- type Input = ReturnType<typeof Input>;
30
- export default Input;
@@ -1,163 +0,0 @@
1
- <script lang="ts">
2
- import { cn } from "../../utils.js";
3
-
4
- interface Props {
5
- id: string;
6
- name: string;
7
- label: string;
8
- options: Array<{ value: string; label: string }>;
9
- size: string;
10
- multipleSize: number;
11
- isMultiple: boolean;
12
- defaultOptionLabel: string;
13
- isDisabled: boolean;
14
- isSkinned: boolean;
15
- css: string;
16
- singleSelected?: string; // singleSelected can be used for two-way bindings
17
- multiSelected?: Array<string>; // If we don't make it seems Svelte gets confused:
18
- selected: (value: string | Array<string>) => void;
19
- }
20
-
21
- let {
22
- id = '',
23
- name = '',
24
- label = '',
25
- options = [],
26
- size = '',
27
- multipleSize = 1,
28
- isMultiple = false,
29
- defaultOptionLabel = 'Please select an option',
30
- isDisabled = false,
31
- isSkinned = true,
32
- css = '',
33
- singleSelected = $bindable(''),
34
- multiSelected = $bindable([]), // multiSelected can be used for two-way bindings
35
- selected = () => {},
36
- }: Partial<Props> = $props();
37
-
38
- const changeHandler = () => {
39
- // dispatch('selected', isMultiple ? multiSelected : singleSelected);
40
- selected(isMultiple ? multiSelected : singleSelected);
41
- };
42
-
43
- let disable = isDisabled;
44
- let classes = $derived(
45
- cn(
46
- isSkinned ? 'select' : 'select-base',
47
- size ? `select-${size}` : '',
48
- css ? `${css}` : ''));
49
- </script>
50
-
51
- <label class="screenreader-only" for={id}> {label} </label>
52
- {#if isMultiple}
53
- <select
54
- id={id}
55
- class={classes}
56
- {name}
57
- disabled={disable}
58
- multiple
59
- size={multipleSize}
60
- bind:value={multiSelected}
61
- onchange={changeHandler}
62
- >
63
- {#each options as { value, label }}
64
- <option {value}>{label}</option>
65
- {/each}
66
- </select>
67
- {:else}
68
- <select
69
- id={id}
70
- class={classes}
71
- {name}
72
- disabled={disable}
73
- bind:value={singleSelected}
74
- onchange={changeHandler}
75
- >
76
- <option value="" disabled selected>
77
- {defaultOptionLabel}
78
- </option>
79
- {#each options as { value, label }}
80
- <option {value}>{label}</option>
81
- {/each}
82
- </select>
83
- {/if}
84
-
85
- <style>
86
- .select,
87
- .select-base {
88
- display: block;
89
- width: 100%;
90
- /* stylelint-disable-next-line property-no-vendor-prefix */
91
- -webkit-appearance: none;
92
- /* stylelint-disable-next-line property-no-vendor-prefix */
93
- -moz-appearance: none;
94
- appearance: none;
95
- }
96
-
97
- .select,
98
- .select-skin {
99
- padding: var(--fluid-6) var(--fluid-32) var(--fluid-6) var(--fluid-12);
100
- -moz-padding-start: calc(var(--fluid-12) - 3px);
101
- font-size: var(--fluid-16);
102
- font-weight: 400;
103
- line-height: 1.5;
104
- color: var(--agnostic-dark);
105
- border: 1px solid var(--agnostic-select-border-color, var(--agnostic-gray-light));
106
- border-radius: var(--agnostic-radius);
107
- transition:
108
- border-color var(--agnostic-timing-fast) ease-in-out,
109
- box-shadow var(--agnostic-timing-fast) ease-in-out;
110
- }
111
-
112
- /* Only shows the down arrow SVG if in single mode */
113
- .select:not([multiple]) {
114
- background-color: inherit;
115
- background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23333330' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
116
- background-repeat: no-repeat;
117
- background-position: right var(--fluid-12) center;
118
- background-size: var(--fluid-16) var(--fluid-12);
119
- }
120
-
121
- .select:focus {
122
- border-color: var(--agnostic-focus-ring-color);
123
- box-shadow: 0 0 0 var(--agnostic-focus-ring-outline-width) var(--agnostic-focus-ring-color);
124
-
125
- /* Needed for High Contrast mode */
126
- outline: var(--agnostic-focus-ring-outline-width) var(--agnostic-focus-ring-outline-style)
127
- var(--agnostic-focus-ring-outline-color);
128
- transition: box-shadow var(--agnostic-timing-fast) ease-out;
129
- }
130
-
131
- .select-base,
132
- .select:disabled {
133
- background-color: var(--agnostic-disabled-bg);
134
- }
135
-
136
- .select-base,
137
- .select:-moz-focusring {
138
- color: transparent;
139
- text-shadow: 0 0 0 var(--agnostic-dark);
140
- }
141
-
142
- @media (prefers-reduced-motion), (update: slow) {
143
- .select,
144
- .select-base,
145
- .select:focus {
146
- transition: none;
147
- }
148
- }
149
-
150
- .select-small {
151
- padding-top: var(--fluid-4);
152
- padding-bottom: var(--fluid-4);
153
- padding-left: var(--fluid-8);
154
- font-size: var(--fluid-14);
155
- }
156
-
157
- .select-large {
158
- padding-top: var(--fluid-8);
159
- padding-bottom: var(--fluid-8);
160
- padding-left: var(--fluid-16);
161
- font-size: var(--fluid-18);
162
- }
163
- </style>
@@ -1,21 +0,0 @@
1
- declare const Select: import("svelte").Component<Partial<{
2
- id: string;
3
- name: string;
4
- label: string;
5
- options: Array<{
6
- value: string;
7
- label: string;
8
- }>;
9
- size: string;
10
- multipleSize: number;
11
- isMultiple: boolean;
12
- defaultOptionLabel: string;
13
- isDisabled: boolean;
14
- isSkinned: boolean;
15
- css: string;
16
- singleSelected?: string;
17
- multiSelected?: Array<string>;
18
- selected: (value: string | Array<string>) => void;
19
- }>, {}, "singleSelected" | "multiSelected">;
20
- type Select = ReturnType<typeof Select>;
21
- export default Select;