@websline/system-components 0.0.1 → 0.0.3

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 (137) hide show
  1. package/dist/components/atoms/{form → actions}/button/Button.svelte +33 -11
  2. package/dist/components/atoms/{form → actions}/button/Button.svelte.d.ts +28 -4
  3. package/dist/components/atoms/actions/button/button.variants.d.ts +151 -0
  4. package/dist/components/atoms/actions/button/button.variants.js +143 -0
  5. package/dist/components/atoms/{closeButton → actions/closeButton}/CloseButton.svelte +8 -7
  6. package/dist/components/atoms/actions/closeButton/CloseButton.svelte.d.ts +49 -0
  7. package/dist/components/atoms/avatar/Avatar.svelte +4 -4
  8. package/dist/components/atoms/badge/Badge.svelte +44 -0
  9. package/dist/components/atoms/badge/Badge.svelte.d.ts +65 -0
  10. package/dist/components/atoms/badge/badge.variants.d.ts +85 -0
  11. package/dist/components/atoms/badge/badge.variants.js +59 -0
  12. package/dist/components/atoms/chip/Chip.svelte +52 -0
  13. package/dist/components/atoms/chip/Chip.svelte.d.ts +81 -0
  14. package/dist/components/atoms/chip/chip.variants.d.ts +61 -0
  15. package/dist/components/atoms/chip/chip.variants.js +118 -0
  16. package/dist/components/atoms/colorChip/ColorChip.svelte +33 -0
  17. package/dist/components/atoms/colorChip/ColorChip.svelte.d.ts +57 -0
  18. package/dist/components/atoms/colorChip/colorChip.variants.d.ts +40 -0
  19. package/dist/components/atoms/colorChip/colorChip.variants.js +27 -0
  20. package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte +2 -16
  21. package/dist/components/atoms/feedback/spinner/spinner.variants.d.ts +19 -0
  22. package/dist/components/atoms/feedback/spinner/spinner.variants.js +17 -0
  23. package/dist/components/atoms/form/formField/FormField.svelte +2 -10
  24. package/dist/components/atoms/form/formField/FormField.svelte.d.ts +8 -0
  25. package/dist/components/atoms/form/formField/formField.variants.d.ts +13 -0
  26. package/dist/components/atoms/form/formField/formField.variants.js +12 -0
  27. package/dist/components/atoms/form/helperText/HelperText.svelte +9 -10
  28. package/dist/components/atoms/form/helperText/HelperText.svelte.d.ts +22 -4
  29. package/dist/components/atoms/form/helperText/helperText.variants.d.ts +13 -0
  30. package/dist/components/atoms/form/helperText/helperText.variants.js +12 -0
  31. package/dist/components/atoms/form/label/Label.svelte +6 -14
  32. package/dist/components/atoms/form/label/Label.svelte.d.ts +8 -0
  33. package/dist/components/atoms/form/label/label.variants.d.ts +22 -0
  34. package/dist/components/atoms/form/label/label.variants.js +15 -0
  35. package/dist/components/atoms/form/radio/Radio.svelte +58 -0
  36. package/dist/components/atoms/form/radio/Radio.svelte.d.ts +65 -0
  37. package/dist/components/atoms/form/radio/radio.variants.d.ts +22 -0
  38. package/dist/components/atoms/form/radio/radio.variants.js +15 -0
  39. package/dist/components/atoms/form/select/Select.svelte +91 -0
  40. package/dist/components/atoms/form/select/Select.svelte.d.ts +81 -0
  41. package/dist/components/atoms/form/select/select.variants.d.ts +58 -0
  42. package/dist/components/atoms/form/select/select.variants.js +66 -0
  43. package/dist/components/atoms/form/switch/Switch.svelte +57 -0
  44. package/dist/components/atoms/form/switch/Switch.svelte.d.ts +65 -0
  45. package/dist/components/atoms/form/switch/switch.variants.d.ts +22 -0
  46. package/dist/components/atoms/form/switch/switch.variants.js +15 -0
  47. package/dist/components/atoms/icon/Icon.svelte +8 -1
  48. package/dist/components/atoms/icon/components/Add.svelte +27 -0
  49. package/dist/components/atoms/icon/components/Add.svelte.d.ts +41 -0
  50. package/dist/components/atoms/icon/components/Check.svelte +27 -0
  51. package/dist/components/atoms/icon/components/Check.svelte.d.ts +41 -0
  52. package/dist/components/atoms/icon/components/ChevronDown.svelte +27 -0
  53. package/dist/components/atoms/icon/components/ChevronDown.svelte.d.ts +41 -0
  54. package/dist/components/atoms/icon/components/CloseSmall.svelte +27 -0
  55. package/dist/components/atoms/icon/components/CloseSmall.svelte.d.ts +41 -0
  56. package/dist/components/atoms/icon/components/Page.svelte +27 -0
  57. package/dist/components/atoms/icon/components/Page.svelte.d.ts +41 -0
  58. package/dist/components/atoms/icon/components/Redo.svelte +27 -0
  59. package/dist/components/atoms/icon/components/Redo.svelte.d.ts +41 -0
  60. package/dist/components/atoms/icon/components/Undo.svelte +27 -0
  61. package/dist/components/atoms/icon/components/Undo.svelte.d.ts +41 -0
  62. package/dist/components/atoms/icon/index.d.ts +14 -0
  63. package/dist/components/atoms/icon/index.js +14 -0
  64. package/dist/components/molecules/navigationItem/NavigationItem.svelte +80 -0
  65. package/dist/components/molecules/navigationItem/NavigationItem.svelte.d.ts +81 -0
  66. package/dist/components/molecules/navigationItem/navigationItem.variants.d.ts +61 -0
  67. package/dist/components/molecules/navigationItem/navigationItem.variants.js +29 -0
  68. package/dist/components/molecules/notification/Notification.svelte +1 -1
  69. package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte +99 -0
  70. package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte.d.ts +57 -0
  71. package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte +13 -0
  72. package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte.d.ts +11 -0
  73. package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.d.ts +49 -0
  74. package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.js +46 -0
  75. package/dist/components/molecules/pickers/colorSwatch/index.d.ts +3 -0
  76. package/dist/components/molecules/pickers/colorSwatch/index.js +4 -0
  77. package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +50 -21
  78. package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +56 -0
  79. package/dist/components/molecules/richTextEditor/richTextEditor.variants.js +25 -3
  80. package/dist/components/molecules/richTextEditor/toolbar/RichTextEditorToolbar.svelte +49 -0
  81. package/dist/components/molecules/richTextEditor/{RichTextEditorToolbar.svelte.d.ts → toolbar/RichTextEditorToolbar.svelte.d.ts} +2 -0
  82. package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte +13 -0
  83. package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte.d.ts +11 -0
  84. package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte +27 -0
  85. package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte.d.ts +15 -0
  86. package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte +13 -0
  87. package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte.d.ts +11 -0
  88. package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte +34 -0
  89. package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte.d.ts +13 -0
  90. package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte +13 -0
  91. package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte.d.ts +11 -0
  92. package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte +13 -0
  93. package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte.d.ts +11 -0
  94. package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte +13 -0
  95. package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte.d.ts +11 -0
  96. package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte +13 -0
  97. package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte.d.ts +11 -0
  98. package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte +13 -0
  99. package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte.d.ts +11 -0
  100. package/dist/components/molecules/selectorCard/SelectorCard.svelte +78 -0
  101. package/dist/components/molecules/selectorCard/SelectorCard.svelte.d.ts +105 -0
  102. package/dist/components/molecules/selectorCard/selectorCard.variants.d.ts +61 -0
  103. package/dist/components/molecules/selectorCard/selectorCard.variants.js +32 -0
  104. package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +1 -0
  105. package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +8 -0
  106. package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +1 -0
  107. package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte.d.ts +8 -0
  108. package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +1 -1
  109. package/dist/components/organisms/popover/Popover.svelte +15 -0
  110. package/dist/components/organisms/popover/Popover.svelte.d.ts +18 -0
  111. package/dist/components/organisms/popover/PopoverContent.svelte +84 -0
  112. package/dist/components/organisms/popover/PopoverContent.svelte.d.ts +89 -0
  113. package/dist/components/organisms/popover/PopoverTrigger.svelte +14 -0
  114. package/dist/components/{atoms/closeButton/CloseButton.svelte.d.ts → organisms/popover/PopoverTrigger.svelte.d.ts} +3 -11
  115. package/dist/components/organisms/popover/index.d.ts +4 -0
  116. package/dist/components/organisms/popover/index.js +5 -0
  117. package/dist/components/organisms/popover/popover.variants.d.ts +39 -0
  118. package/dist/components/organisms/popover/popover.variants.js +15 -0
  119. package/dist/index.d.ts +14 -4
  120. package/dist/index.js +14 -4
  121. package/dist/utils/colors.d.ts +9 -0
  122. package/dist/utils/colors.js +119 -0
  123. package/dist/utils/index.d.ts +2 -0
  124. package/dist/utils/index.js +2 -0
  125. package/dist/utils/theme.svelte.d.ts +10 -0
  126. package/dist/utils/theme.svelte.js +31 -0
  127. package/package.json +31 -31
  128. package/dist/components/atoms/form/button/button.variants.d.ts +0 -58
  129. package/dist/components/atoms/form/button/button.variants.js +0 -82
  130. package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte +0 -5
  131. package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.d.ts +0 -0
  132. package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.js +0 -0
  133. package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte +0 -0
  134. package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte.d.ts +0 -0
  135. package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.d.ts +0 -0
  136. package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.js +0 -0
  137. package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte.d.ts +6 -6
@@ -1,10 +1,11 @@
1
1
  <script>
2
2
  import { setContext } from "svelte";
3
- import { tv } from "tailwind-variants";
3
+ import { formFieldVariants } from "./formField.variants.js";
4
4
  import { HelperText, Label } from "../../../../index.js";
5
5
 
6
6
  /**
7
7
  * @typedef {Object} Props
8
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
8
9
  * @property {string} [class=""] Additional CSS classes for the form field
9
10
  * @property {boolean} [error=false] Whether the form field has an error
10
11
  * @property {string} [errorText=""] The error text for the form field
@@ -28,15 +29,6 @@
28
29
  required = false,
29
30
  } = $props();
30
31
 
31
- const formFieldVariants = tv({
32
- base: "grid gap-2",
33
- variants: {
34
- layout: {
35
- inline: "sm:grid-cols-[minmax(120px,auto)_1fr] items-center",
36
- },
37
- },
38
- });
39
-
40
32
  setContext("form-field-store", () => {
41
33
  return {
42
34
  error,
@@ -4,6 +4,10 @@ type FormField = {
4
4
  $set?(props: Partial<Props>): void;
5
5
  };
6
6
  declare const FormField: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
7
11
  /**
8
12
  * Additional CSS classes for the form field
9
13
  */
@@ -38,6 +42,10 @@ declare const FormField: import("svelte").Component<{
38
42
  required?: boolean;
39
43
  }, {}, "">;
40
44
  type Props = {
45
+ /**
46
+ * Children content – can be text, HTML, or other Svelte components
47
+ */
48
+ children?: import("svelte").Snippet;
41
49
  /**
42
50
  * Additional CSS classes for the form field
43
51
  */
@@ -0,0 +1,13 @@
1
+ export const formFieldVariants: import("tailwind-variants").TVReturnType<{
2
+ layout: {
3
+ inline: string;
4
+ };
5
+ }, undefined, "grid gap-2", {
6
+ layout: {
7
+ inline: string;
8
+ };
9
+ }, undefined, import("tailwind-variants").TVReturnType<{
10
+ layout: {
11
+ inline: string;
12
+ };
13
+ }, undefined, "grid gap-2", unknown, unknown, undefined>>;
@@ -0,0 +1,12 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const formFieldVariants = tv({
4
+ base: "grid gap-2",
5
+ variants: {
6
+ layout: {
7
+ inline: "sm:grid-cols-[minmax(120px,auto)_1fr] items-center",
8
+ },
9
+ },
10
+ });
11
+
12
+ export { formFieldVariants };
@@ -1,16 +1,15 @@
1
1
  <script>
2
- import { tv } from "tailwind-variants";
2
+ import { helperTextVariants } from "./helperText.variants.js";
3
3
 
4
- let { children, class: className = "", error = false } = $props();
4
+ /**
5
+ * @typedef {Object} Props
6
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
7
+ * @property {string} [class=""] Additional CSS classes for the form field
8
+ * @property {boolean} [error=false] Whether the helperText has an error
9
+ */
5
10
 
6
- const helperTextVariants = tv({
7
- base: "body-extra-small text-neutral-500",
8
- variants: {
9
- error: {
10
- true: "text-red-500",
11
- },
12
- },
13
- });
11
+ /** @type {Props} */
12
+ let { children, class: className = "", error = false } = $props();
14
13
  </script>
15
14
 
16
15
  <p class={helperTextVariants({ class: className, error })}>
@@ -1,15 +1,33 @@
1
1
  export default HelperText;
2
2
  type HelperText = {
3
3
  $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<$$ComponentProps>): void;
4
+ $set?(props: Partial<Props>): void;
5
5
  };
6
6
  declare const HelperText: import("svelte").Component<{
7
- children: any;
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Additional CSS classes for the form field
13
+ */
8
14
  class?: string;
15
+ /**
16
+ * Whether the helperText has an error
17
+ */
9
18
  error?: boolean;
10
19
  }, {}, "">;
11
- type $$ComponentProps = {
12
- children: any;
20
+ type Props = {
21
+ /**
22
+ * Children content – can be text, HTML, or other Svelte components
23
+ */
24
+ children?: import("svelte").Snippet;
25
+ /**
26
+ * Additional CSS classes for the form field
27
+ */
13
28
  class?: string;
29
+ /**
30
+ * Whether the helperText has an error
31
+ */
14
32
  error?: boolean;
15
33
  };
@@ -0,0 +1,13 @@
1
+ export const helperTextVariants: import("tailwind-variants").TVReturnType<{
2
+ error: {
3
+ true: string;
4
+ };
5
+ }, undefined, "body-extra-small text-neutral-500", {
6
+ error: {
7
+ true: string;
8
+ };
9
+ }, undefined, import("tailwind-variants").TVReturnType<{
10
+ error: {
11
+ true: string;
12
+ };
13
+ }, undefined, "body-extra-small text-neutral-500", unknown, unknown, undefined>>;
@@ -0,0 +1,12 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const helperTextVariants = tv({
4
+ base: "body-extra-small text-neutral-500",
5
+ variants: {
6
+ error: {
7
+ true: "text-red-500",
8
+ },
9
+ },
10
+ });
11
+
12
+ export { helperTextVariants };
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { tv } from "tailwind-variants";
2
+ import { labelVariants } from "./label.variants.js";
3
3
 
4
4
  /**
5
5
  * @typedef {Object} Props
@@ -7,6 +7,7 @@
7
7
  * @property {string} [class=""] Additional CSS classes to apply to the component
8
8
  * @property {boolean} [error=false] Whether the label is in an error state
9
9
  * @property {boolean} [hidden=false] Whether the label should be visually hidden
10
+ * @property {boolean} [required=false] Whether to show a required asterisk
10
11
  */
11
12
 
12
13
  /** @type {Props} */
@@ -15,22 +16,13 @@
15
16
  class: className = "",
16
17
  hidden = false,
17
18
  error = false,
19
+ required = false,
18
20
  ...rest
19
21
  } = $props();
20
-
21
- const labelVariants = tv({
22
- base: "body-small text-neutral-500",
23
- variants: {
24
- error: {
25
- true: "text-red-500",
26
- },
27
- hidden: {
28
- true: "sr-only",
29
- },
30
- },
31
- });
32
22
  </script>
33
23
 
34
24
  <label class={labelVariants({ class: className, hidden, error })} {...rest}>
35
- {@render children?.()}
25
+ {@render children?.()}{#if required}<span aria-hidden="true" class="text-red-500"
26
+ >*</span
27
+ >{/if}
36
28
  </label>
@@ -20,6 +20,10 @@ declare const Label: import("svelte").Component<{
20
20
  * Whether the label should be visually hidden
21
21
  */
22
22
  hidden?: boolean;
23
+ /**
24
+ * Whether to show a required asterisk
25
+ */
26
+ required?: boolean;
23
27
  }, {}, "">;
24
28
  type Props = {
25
29
  /**
@@ -38,4 +42,8 @@ type Props = {
38
42
  * Whether the label should be visually hidden
39
43
  */
40
44
  hidden?: boolean;
45
+ /**
46
+ * Whether to show a required asterisk
47
+ */
48
+ required?: boolean;
41
49
  };
@@ -0,0 +1,22 @@
1
+ export const labelVariants: import("tailwind-variants").TVReturnType<{
2
+ error: {
3
+ true: string;
4
+ };
5
+ hidden: {
6
+ true: string;
7
+ };
8
+ }, undefined, "body-small text-neutral-500", {
9
+ error: {
10
+ true: string;
11
+ };
12
+ hidden: {
13
+ true: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ error: {
17
+ true: string;
18
+ };
19
+ hidden: {
20
+ true: string;
21
+ };
22
+ }, undefined, "body-small text-neutral-500", unknown, unknown, undefined>>;
@@ -0,0 +1,15 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const labelVariants = tv({
4
+ base: "body-small text-neutral-500",
5
+ variants: {
6
+ error: {
7
+ true: "text-red-500",
8
+ },
9
+ hidden: {
10
+ true: "sr-only",
11
+ },
12
+ },
13
+ });
14
+
15
+ export { labelVariants };
@@ -0,0 +1,58 @@
1
+ <script>
2
+ import { getContext } from "svelte";
3
+ import { radioVariants } from "./radio.variants.js";
4
+
5
+ /**
6
+ * @typedef {Object} Props
7
+ * @property {boolean} [checked=false] Wether this radio is checked or not, bound to the component
8
+ * @property {string} [class=""] Additional CSS classes to apply to the component
9
+ * @property {boolean} [disabled=false] Whether the radio is disabled
10
+ * @property {string} [id=""] The ID of the radio element
11
+ * @property {string} [name] The name of the radio, used for form submission
12
+ * @property {boolean} [required=false] Whether the radio is required
13
+ * @property {string} [value=""] The value of the radio
14
+ */
15
+
16
+ /** @type {Props} */
17
+ let {
18
+ checked = $bindable(),
19
+ class: className = "",
20
+ disabled = false,
21
+ id = "",
22
+ name,
23
+ required = false,
24
+ value = "",
25
+ ...rest
26
+ } = $props();
27
+
28
+ let store = getContext("form-field-store");
29
+
30
+ let localValues = $derived.by(() => {
31
+ if (store) {
32
+ return {
33
+ ...store(),
34
+ };
35
+ }
36
+
37
+ return {
38
+ id,
39
+ required,
40
+ };
41
+ });
42
+ </script>
43
+
44
+ <input
45
+ onchange={(e) => (checked = !checked ? e.target.checked : checked)}
46
+ {checked}
47
+ class={radioVariants({
48
+ checked,
49
+ class: className,
50
+ disabled,
51
+ })}
52
+ {disabled}
53
+ id={localValues.id}
54
+ {name}
55
+ required={localValues.required}
56
+ type="checkbox"
57
+ {value}
58
+ {...rest} />
@@ -0,0 +1,65 @@
1
+ export default Radio;
2
+ type Radio = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const Radio: import("svelte").Component<{
7
+ /**
8
+ * Wether this radio is checked or not, bound to the component
9
+ */
10
+ checked?: boolean;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * Whether the radio is disabled
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * The ID of the radio element
21
+ */
22
+ id?: string;
23
+ /**
24
+ * The name of the radio, used for form submission
25
+ */
26
+ name?: string;
27
+ /**
28
+ * Whether the radio is required
29
+ */
30
+ required?: boolean;
31
+ /**
32
+ * The value of the radio
33
+ */
34
+ value?: string;
35
+ }, {}, "checked">;
36
+ type Props = {
37
+ /**
38
+ * Wether this radio is checked or not, bound to the component
39
+ */
40
+ checked?: boolean;
41
+ /**
42
+ * Additional CSS classes to apply to the component
43
+ */
44
+ class?: string;
45
+ /**
46
+ * Whether the radio is disabled
47
+ */
48
+ disabled?: boolean;
49
+ /**
50
+ * The ID of the radio element
51
+ */
52
+ id?: string;
53
+ /**
54
+ * The name of the radio, used for form submission
55
+ */
56
+ name?: string;
57
+ /**
58
+ * Whether the radio is required
59
+ */
60
+ required?: boolean;
61
+ /**
62
+ * The value of the radio
63
+ */
64
+ value?: string;
65
+ };
@@ -0,0 +1,22 @@
1
+ export const radioVariants: import("tailwind-variants").TVReturnType<{
2
+ checked: {
3
+ true: string;
4
+ };
5
+ disabled: {
6
+ true: string;
7
+ };
8
+ }, undefined, "m-0.5 h-4 w-4 cursor-pointer appearance-none rounded-full border-0 bg-transparent ring-0 inset-ring-1 ring-transparent inset-ring-neutral-300 ring-offset-transparent outline-transparent duration-300 checked:bg-none focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:inset-ring-neutral-600", {
9
+ checked: {
10
+ true: string;
11
+ };
12
+ disabled: {
13
+ true: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ checked: {
17
+ true: string;
18
+ };
19
+ disabled: {
20
+ true: string;
21
+ };
22
+ }, undefined, "m-0.5 h-4 w-4 cursor-pointer appearance-none rounded-full border-0 bg-transparent ring-0 inset-ring-1 ring-transparent inset-ring-neutral-300 ring-offset-transparent outline-transparent duration-300 checked:bg-none focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:inset-ring-neutral-600", unknown, unknown, undefined>>;
@@ -0,0 +1,15 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const radioVariants = tv({
4
+ base: "m-0.5 h-4 w-4 cursor-pointer appearance-none rounded-full border-0 bg-transparent ring-0 inset-ring-1 ring-transparent inset-ring-neutral-300 ring-offset-transparent outline-transparent duration-300 checked:bg-none focus:outline-1 focus:outline-offset-1 focus:outline-blue-300 dark:inset-ring-neutral-600",
5
+ variants: {
6
+ checked: {
7
+ true: "inset-ring-4 inset-ring-neutral-900 dark:inset-ring-neutral-600",
8
+ },
9
+ disabled: {
10
+ true: "cursor-not-allowed",
11
+ },
12
+ },
13
+ });
14
+
15
+ export { radioVariants };
@@ -0,0 +1,91 @@
1
+ <script>
2
+ import { getContext } from "svelte";
3
+ import { selectVariants } from "./select.variants.js";
4
+
5
+ /**
6
+ * @typedef {Object} Props
7
+ * @property {string} [class=""] Additional CSS classes for the select
8
+ * @property {boolean} [disabled=false] Whether the select field is disabled
9
+ * @property {boolean} [error=false] Whether the select field has an error
10
+ * @property {string} [id=""] The id attr of the select field
11
+ * @property {{ disabled?: boolean, label: string, value: string }[]} [options=[]] required array of option objects for the select
12
+ * @property {string} [placeholder=""] The placeholder text that shows when no option is preselected
13
+ * @property {boolean} [required=false] Whether the select field is required
14
+ * @property {string} [value=""] The value of the input, bound to the component
15
+ */
16
+
17
+ /** @type {Props} */
18
+ let {
19
+ class: className = "",
20
+ disabled = false,
21
+ error = false,
22
+ id,
23
+ options = [],
24
+ placeholder = "",
25
+ required = false,
26
+ value = $bindable(),
27
+ ...rest
28
+ } = $props();
29
+
30
+ let store = getContext("form-field-store");
31
+
32
+ let localValues = $derived.by(() => {
33
+ if (store) {
34
+ return {
35
+ ...store(),
36
+ };
37
+ }
38
+
39
+ return {
40
+ id,
41
+ error,
42
+ required,
43
+ };
44
+ });
45
+
46
+ let styles = $derived(selectVariants());
47
+ </script>
48
+
49
+ <select
50
+ class={styles.select({
51
+ class: className,
52
+ disabled,
53
+ error: localValues.error,
54
+ })}
55
+ {disabled}
56
+ id={localValues.id}
57
+ required={localValues.required}
58
+ bind:value
59
+ {...rest}>
60
+ {#if placeholder}
61
+ <option class={styles.option({ disabled: true })} hidden readonly value=""
62
+ >{placeholder}</option>
63
+ {/if}
64
+ {#each options as { disabled, label, value: optValue } (optValue)}
65
+ <option
66
+ class={styles.option({ disabled })}
67
+ {disabled}
68
+ selected={value === optValue}
69
+ value={optValue}>{label}</option>
70
+ {/each}
71
+ </select>
72
+
73
+ <style>
74
+ select {
75
+ appearance: base-select;
76
+
77
+ &::picker(select) {
78
+ appearance: base-select;
79
+ }
80
+
81
+ &::after {
82
+ mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 25' fill='none'><path d='M18 9.5332L12 15.5332L6 9.5332' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
83
+ }
84
+ }
85
+
86
+ option {
87
+ &::checkmark {
88
+ mask: url("data:image/svg+xml;utf8,<svg height='16' width='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M20 6L9 19L4 13.0909' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' /></svg>");
89
+ }
90
+ }
91
+ </style>
@@ -0,0 +1,81 @@
1
+ export default Select;
2
+ type Select = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const Select: import("svelte").Component<{
7
+ /**
8
+ * Additional CSS classes for the select
9
+ */
10
+ class?: string;
11
+ /**
12
+ * Whether the select field is disabled
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * Whether the select field has an error
17
+ */
18
+ error?: boolean;
19
+ /**
20
+ * The id attr of the select field
21
+ */
22
+ id?: string;
23
+ /**
24
+ * required array of option objects for the select
25
+ */
26
+ options?: {
27
+ disabled?: boolean;
28
+ label: string;
29
+ value: string;
30
+ }[];
31
+ /**
32
+ * The placeholder text that shows when no option is preselected
33
+ */
34
+ placeholder?: string;
35
+ /**
36
+ * Whether the select field is required
37
+ */
38
+ required?: boolean;
39
+ /**
40
+ * The value of the input, bound to the component
41
+ */
42
+ value?: string;
43
+ }, {}, "value">;
44
+ type Props = {
45
+ /**
46
+ * Additional CSS classes for the select
47
+ */
48
+ class?: string;
49
+ /**
50
+ * Whether the select field is disabled
51
+ */
52
+ disabled?: boolean;
53
+ /**
54
+ * Whether the select field has an error
55
+ */
56
+ error?: boolean;
57
+ /**
58
+ * The id attr of the select field
59
+ */
60
+ id?: string;
61
+ /**
62
+ * required array of option objects for the select
63
+ */
64
+ options?: {
65
+ disabled?: boolean;
66
+ label: string;
67
+ value: string;
68
+ }[];
69
+ /**
70
+ * The placeholder text that shows when no option is preselected
71
+ */
72
+ placeholder?: string;
73
+ /**
74
+ * Whether the select field is required
75
+ */
76
+ required?: boolean;
77
+ /**
78
+ * The value of the input, bound to the component
79
+ */
80
+ value?: string;
81
+ };
@@ -0,0 +1,58 @@
1
+ export const selectVariants: import("tailwind-variants").TVReturnType<{
2
+ disabled: {
3
+ true: {
4
+ option: string;
5
+ select: string;
6
+ };
7
+ false: {
8
+ option: string;
9
+ select: string;
10
+ };
11
+ };
12
+ error: {
13
+ true: {
14
+ select: string;
15
+ };
16
+ };
17
+ }, {
18
+ select: string;
19
+ option: string;
20
+ }, undefined, {
21
+ disabled: {
22
+ true: {
23
+ option: string;
24
+ select: string;
25
+ };
26
+ false: {
27
+ option: string;
28
+ select: string;
29
+ };
30
+ };
31
+ error: {
32
+ true: {
33
+ select: string;
34
+ };
35
+ };
36
+ }, {
37
+ select: string;
38
+ option: string;
39
+ }, import("tailwind-variants").TVReturnType<{
40
+ disabled: {
41
+ true: {
42
+ option: string;
43
+ select: string;
44
+ };
45
+ false: {
46
+ option: string;
47
+ select: string;
48
+ };
49
+ };
50
+ error: {
51
+ true: {
52
+ select: string;
53
+ };
54
+ };
55
+ }, {
56
+ select: string;
57
+ option: string;
58
+ }, undefined, unknown, unknown, undefined>>;