@websline/system-components 0.0.2 → 0.0.4

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 +38 -39
  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
@@ -0,0 +1,27 @@
1
+ <script>
2
+ /**
3
+ * @typedef {Object} Props
4
+ * @property {string} [color=""] Icon color
5
+ * @property {number} [height=24] Icon height
6
+ * @property {number} [strokeWidth=24] Icon StrokeWidth
7
+ * @property {number} [width=24] Icon width
8
+ */
9
+
10
+ /** @type {Props} */
11
+ let { color, height, width, strokeWidth, ...rest } = $props();
12
+ </script>
13
+
14
+ <svg
15
+ {height}
16
+ {width}
17
+ viewBox="0 0 24 24"
18
+ fill="none"
19
+ xmlns="http://www.w3.org/2000/svg"
20
+ {...rest}>
21
+ <path
22
+ d="M5.63605 18.364C7.2647 19.9927 9.5147 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02945 16.9706 3 12 3C9.5147 3 7.2647 4.00736 5.63605 5.63605C4.80704 6.46505 3 8.5 3 8.5M3 8.5V4.5M3 8.5H7"
23
+ stroke={color}
24
+ stroke-width={strokeWidth}
25
+ stroke-linecap="round"
26
+ stroke-linejoin="round" />
27
+ </svg>
@@ -0,0 +1,41 @@
1
+ export default Undo;
2
+ type Undo = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const Undo: import("svelte").Component<{
7
+ /**
8
+ * Icon color
9
+ */
10
+ color?: string;
11
+ /**
12
+ * Icon height
13
+ */
14
+ height?: number;
15
+ /**
16
+ * Icon StrokeWidth
17
+ */
18
+ strokeWidth?: number;
19
+ /**
20
+ * Icon width
21
+ */
22
+ width?: number;
23
+ }, {}, "">;
24
+ type Props = {
25
+ /**
26
+ * Icon color
27
+ */
28
+ color?: string;
29
+ /**
30
+ * Icon height
31
+ */
32
+ height?: number;
33
+ /**
34
+ * Icon StrokeWidth
35
+ */
36
+ strokeWidth?: number;
37
+ /**
38
+ * Icon width
39
+ */
40
+ width?: number;
41
+ };
@@ -1,20 +1,34 @@
1
1
  export namespace registry {
2
2
  export { Academy as academy };
3
+ export { Add as add };
3
4
  export { Bold as bold };
5
+ export { Check as check };
6
+ export { ChevronDown as chevronDown };
4
7
  export { Close as close };
8
+ export { CloseSmall as closeSmall };
5
9
  export { Italic as italic };
6
10
  export { Link as link };
7
11
  export { ListOrdered as listOrdered };
8
12
  export { ListUnordered as listUnordered };
13
+ export { Page as page };
14
+ export { Redo as redo };
9
15
  export { Refresh as refresh };
10
16
  export { Underline as underline };
17
+ export { Undo as undo };
11
18
  }
12
19
  import Academy from "./components/Academy.svelte";
20
+ import Add from "./components/Add.svelte";
13
21
  import Bold from "./components/Bold.svelte";
22
+ import Check from "./components/Check.svelte";
23
+ import ChevronDown from "./components/ChevronDown.svelte";
14
24
  import Close from "./components/Close.svelte";
25
+ import CloseSmall from "./components/CloseSmall.svelte";
15
26
  import Italic from "./components/Italic.svelte";
16
27
  import Link from "./components/Link.svelte";
17
28
  import ListOrdered from "./components/ListOrdered.svelte";
18
29
  import ListUnordered from "./components/ListUnordered.svelte";
30
+ import Page from "./components/Page.svelte";
31
+ import Redo from "./components/Redo.svelte";
19
32
  import Refresh from "./components/Refresh.svelte";
20
33
  import Underline from "./components/Underline.svelte";
34
+ import Undo from "./components/Undo.svelte";
@@ -1,21 +1,35 @@
1
1
  import Academy from "./components/Academy.svelte";
2
+ import Add from "./components/Add.svelte";
2
3
  import Bold from "./components/Bold.svelte";
4
+ import Check from "./components/Check.svelte";
5
+ import ChevronDown from "./components/ChevronDown.svelte";
3
6
  import Close from "./components/Close.svelte";
7
+ import CloseSmall from "./components/CloseSmall.svelte";
4
8
  import Italic from "./components/Italic.svelte";
5
9
  import Link from "./components/Link.svelte";
6
10
  import ListOrdered from "./components/ListOrdered.svelte";
7
11
  import ListUnordered from "./components/ListUnordered.svelte";
12
+ import Page from "./components/Page.svelte";
13
+ import Redo from "./components/Redo.svelte";
8
14
  import Refresh from "./components/Refresh.svelte";
9
15
  import Underline from "./components/Underline.svelte";
16
+ import Undo from "./components/Undo.svelte";
10
17
 
11
18
  export const registry = {
12
19
  academy: Academy,
20
+ add: Add,
13
21
  bold: Bold,
22
+ check: Check,
23
+ chevronDown: ChevronDown,
14
24
  close: Close,
25
+ closeSmall: CloseSmall,
15
26
  italic: Italic,
16
27
  link: Link,
17
28
  listOrdered: ListOrdered,
18
29
  listUnordered: ListUnordered,
30
+ page: Page,
31
+ redo: Redo,
19
32
  refresh: Refresh,
20
33
  underline: Underline,
34
+ undo: Undo,
21
35
  };
@@ -0,0 +1,80 @@
1
+ <script>
2
+ import { Icon } from "../../../index.js";
3
+ import { fly } from "svelte/transition";
4
+ import { cubicOut } from "svelte/easing";
5
+ import { navigationItemVariants } from "./navigationItem.variants.js";
6
+
7
+ /**
8
+ * @typedef {Object} Props
9
+ * @property {string} [as="a"] The HTML element to use for the navigation item
10
+ * @property {string} [class=""] Additional CSS classes to apply to the component
11
+ * @property {boolean} [disabled=false] Whether the navigation item is disabled
12
+ * @property {boolean} [hasAlert=false] Whether the navigation item has an alert
13
+ * @property {string} [href=""] The URL the navigation item links to
14
+ * @property {string} [icon=""] The name of the icon to display
15
+ * @property {string} [label=""] The label of the navigation item
16
+ * @property {boolean} [selected=false] Whether the navigation item is selected
17
+ * @property {"_self" | "_blank" | "_parent" | "_top"} [target="_self"] The target attribute for the link
18
+ */
19
+
20
+ /** @type {Props} */
21
+ let {
22
+ as = "a",
23
+ class: className = "",
24
+ disabled = false,
25
+ hasAlert = false,
26
+ href = "",
27
+ icon = "",
28
+ label = "",
29
+ selected = false,
30
+ target = "_self",
31
+ ...rest
32
+ } = $props();
33
+
34
+ let styles = $derived(navigationItemVariants({ disabled }));
35
+ let hideTimer;
36
+
37
+ let showLabel = $state(false);
38
+
39
+ function enter() {
40
+ clearTimeout(hideTimer);
41
+ showLabel = true;
42
+ }
43
+
44
+ function leave() {
45
+ clearTimeout(hideTimer);
46
+ hideTimer = setTimeout(() => (showLabel = false), 50);
47
+ }
48
+ </script>
49
+
50
+ <svelte:element
51
+ this={as}
52
+ class={styles.base({ class: className })}
53
+ {href}
54
+ onmouseenter={enter}
55
+ onmouseleave={leave}
56
+ {target}
57
+ {...rest}>
58
+ {#if icon}
59
+ <div class={styles.icon({ hasAlert, selected })}>
60
+ <Icon name={icon} />
61
+ </div>
62
+ {/if}
63
+ {#if label && showLabel}
64
+ <span
65
+ class={styles.label()}
66
+ in:fly={{
67
+ x: -32,
68
+ y: 0,
69
+ duration: 300,
70
+ delay: 0,
71
+ easing: cubicOut,
72
+ }}
73
+ out:fly={{
74
+ x: -32,
75
+ y: 0,
76
+ duration: 300,
77
+ delay: 0,
78
+ }}>{label}</span>
79
+ {/if}
80
+ </svelte:element>
@@ -0,0 +1,81 @@
1
+ export default NavigationItem;
2
+ type NavigationItem = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const NavigationItem: import("svelte").Component<{
7
+ /**
8
+ * The HTML element to use for the navigation item
9
+ */
10
+ as?: string;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * Whether the navigation item is disabled
17
+ */
18
+ disabled?: boolean;
19
+ /**
20
+ * Whether the navigation item has an alert
21
+ */
22
+ hasAlert?: boolean;
23
+ /**
24
+ * The URL the navigation item links to
25
+ */
26
+ href?: string;
27
+ /**
28
+ * The name of the icon to display
29
+ */
30
+ icon?: string;
31
+ /**
32
+ * The label of the navigation item
33
+ */
34
+ label?: string;
35
+ /**
36
+ * Whether the navigation item is selected
37
+ */
38
+ selected?: boolean;
39
+ /**
40
+ * The target attribute for the link
41
+ */
42
+ target?: "_self" | "_blank" | "_parent" | "_top";
43
+ }, {}, "">;
44
+ type Props = {
45
+ /**
46
+ * The HTML element to use for the navigation item
47
+ */
48
+ as?: string;
49
+ /**
50
+ * Additional CSS classes to apply to the component
51
+ */
52
+ class?: string;
53
+ /**
54
+ * Whether the navigation item is disabled
55
+ */
56
+ disabled?: boolean;
57
+ /**
58
+ * Whether the navigation item has an alert
59
+ */
60
+ hasAlert?: boolean;
61
+ /**
62
+ * The URL the navigation item links to
63
+ */
64
+ href?: string;
65
+ /**
66
+ * The name of the icon to display
67
+ */
68
+ icon?: string;
69
+ /**
70
+ * The label of the navigation item
71
+ */
72
+ label?: string;
73
+ /**
74
+ * Whether the navigation item is selected
75
+ */
76
+ selected?: boolean;
77
+ /**
78
+ * The target attribute for the link
79
+ */
80
+ target?: "_self" | "_blank" | "_parent" | "_top";
81
+ };
@@ -0,0 +1,61 @@
1
+ export const navigationItemVariants: import("tailwind-variants").TVReturnType<{
2
+ disabled: {
3
+ true: {
4
+ base: string;
5
+ };
6
+ };
7
+ hasAlert: {
8
+ true: {
9
+ icon: string;
10
+ };
11
+ };
12
+ selected: {
13
+ true: {
14
+ icon: string;
15
+ };
16
+ };
17
+ }, {
18
+ base: string;
19
+ icon: string;
20
+ label: string;
21
+ }, undefined, {
22
+ disabled: {
23
+ true: {
24
+ base: string;
25
+ };
26
+ };
27
+ hasAlert: {
28
+ true: {
29
+ icon: string;
30
+ };
31
+ };
32
+ selected: {
33
+ true: {
34
+ icon: string;
35
+ };
36
+ };
37
+ }, {
38
+ base: string;
39
+ icon: string;
40
+ label: string;
41
+ }, import("tailwind-variants").TVReturnType<{
42
+ disabled: {
43
+ true: {
44
+ base: string;
45
+ };
46
+ };
47
+ hasAlert: {
48
+ true: {
49
+ icon: string;
50
+ };
51
+ };
52
+ selected: {
53
+ true: {
54
+ icon: string;
55
+ };
56
+ };
57
+ }, {
58
+ base: string;
59
+ icon: string;
60
+ label: string;
61
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,29 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const navigationItemVariants = tv({
4
+ slots: {
5
+ base: "inline-flex relative cursor-pointer select-none hover:pr-2 hover:[&>div]:bg-neutral-100 dark:hover:[&>div]:bg-neutral-700 dark:text-white",
6
+ icon: "bg-white dark:bg-neutral-900 p-2.5 rounded-sm transition duration-200 relative z-2",
7
+ label:
8
+ "body-small shadow-[0_2px_16px_0_rgba(0,_0,_0,_0.08)] px-2.5 flex items-center rounded-sm left-12 h-full absolute z-1",
9
+ },
10
+ variants: {
11
+ disabled: {
12
+ true: {
13
+ base: "opacity-40 pointer-events-none",
14
+ },
15
+ },
16
+ hasAlert: {
17
+ true: {
18
+ icon: "after:content-[''] after:absolute after:top-1 after:right-1 after:w-2 after:h-2 after:rounded-full after:bg-blue-500 dark:after:bg-blue-400",
19
+ },
20
+ },
21
+ selected: {
22
+ true: {
23
+ icon: "bg-neutral-300 dark:bg-neutral-700",
24
+ },
25
+ },
26
+ },
27
+ });
28
+
29
+ export { navigationItemVariants };
@@ -27,7 +27,7 @@
27
27
  </script>
28
28
 
29
29
  <div class={styles.base({ class: className })}>
30
- <div class={styles.icon({ variant })}>
30
+ <div class={styles.icon()}>
31
31
  <Icon name={icon} />
32
32
  </div>
33
33
  <div class={styles.content()}>
@@ -0,0 +1,99 @@
1
+ <script>
2
+ import { Icon, Popover, utils } from "../../../../index.js";
3
+ import { colorSwatchVariants } from "./colorSwatch.variants.js";
4
+
5
+ /**
6
+ * @typedef {Object} Props
7
+ * @property {string} [children] The color items
8
+ * @property {string} [class=""] Additional CSS classes to apply to the component
9
+ * @property {string} [selectedColor=""] Selected color value (hex, rgb, etc.)
10
+ * @property {"small" | "medium" | "large"} [size="medium"] ColorSwatch size
11
+ * @property {"text" | "background"} [type="text"] letter "A" for text -> "B" for background
12
+ * @property {"filled" | "transparent"} [variant="transparent"] ColorSwatch style
13
+ */
14
+
15
+ /** @type {Props} */
16
+ let {
17
+ children,
18
+ class: className,
19
+ isOpen = $bindable(false),
20
+ selectedColor = "#ffffff",
21
+ size = "medium",
22
+ type = "text",
23
+ variant = "transparent",
24
+ } = $props();
25
+
26
+ let styles = $derived(colorSwatchVariants({ isOpen, size, variant }));
27
+
28
+ let calculatedColors = $derived.by(() => {
29
+ let contrast = utils.getContrastColor(selectedColor);
30
+
31
+ return {
32
+ foreground: contrast,
33
+ background: selectedColor,
34
+ };
35
+ });
36
+
37
+ let style = $derived(() => {
38
+ let showBorder = utils.shouldShowBorder(
39
+ calculatedColors.background,
40
+ utils.theme.background,
41
+ );
42
+
43
+ return `
44
+ background-color: ${calculatedColors.background};
45
+ border: 1px solid ${showBorder ? "#000" : calculatedColors.background};
46
+ color: ${calculatedColors.foreground};
47
+ `;
48
+ });
49
+
50
+ let contentEl;
51
+ </script>
52
+
53
+ {#snippet content()}
54
+ {#if type === "text"}
55
+ <svg
56
+ width="8"
57
+ height="8"
58
+ viewBox="0 0 8 8"
59
+ fill="none"
60
+ xmlns="http://www.w3.org/2000/svg">
61
+ <path
62
+ d="M0.544922 7.85039V7.74039L3.25092 0.150391H4.75792L7.45292 7.74039V7.85039H6.56192L5.92392 6.04639H2.06292L1.43592 7.85039H0.544922ZM2.35992 5.22139H5.63792L4.10892 0.876391H3.87792L2.35992 5.22139Z"
63
+ fill="currentColor" />
64
+ </svg>
65
+ {/if}
66
+ {/snippet}
67
+
68
+ <Popover.Root open={isOpen} onOpenChange={(open) => (isOpen = open)}>
69
+ <Popover.Trigger>
70
+ <button class={styles.base({ class: className })}>
71
+ <div class={styles.iconText()} style={style()}>
72
+ {@render content()}
73
+ </div>
74
+ <div class={styles.iconArrow()}>
75
+ <Icon name="chevronDown" size={16} />
76
+ </div>
77
+ </button>
78
+ </Popover.Trigger>
79
+ <Popover.Content
80
+ onOpenAutoFocus={(e) => {
81
+ e.preventDefault();
82
+
83
+ if (contentEl) {
84
+ let targetEl = contentEl.querySelectorAll(
85
+ `button[data-color="${selectedColor}"]`,
86
+ )[0];
87
+
88
+ if (targetEl) {
89
+ targetEl.focus();
90
+ } else {
91
+ contentEl.querySelector("button")?.focus();
92
+ }
93
+ }
94
+ }}>
95
+ <div class="grid grid-cols-5 gap-1" bind:this={contentEl}>
96
+ {@render children()}
97
+ </div>
98
+ </Popover.Content>
99
+ </Popover.Root>
@@ -0,0 +1,57 @@
1
+ export default ColorSwatch;
2
+ type ColorSwatch = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const ColorSwatch: import("svelte").Component<{
7
+ /**
8
+ * The color items
9
+ */
10
+ children?: string;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * Selected color value (hex, rgb, etc.)
17
+ */
18
+ selectedColor?: string;
19
+ /**
20
+ * ColorSwatch size
21
+ */
22
+ size?: "small" | "medium" | "large";
23
+ /**
24
+ * letter "A" for text -> "B" for background
25
+ */
26
+ type?: "text" | "background";
27
+ /**
28
+ * ColorSwatch style
29
+ */
30
+ variant?: "filled" | "transparent";
31
+ }, {}, "isOpen">;
32
+ type Props = {
33
+ /**
34
+ * The color items
35
+ */
36
+ children?: string;
37
+ /**
38
+ * Additional CSS classes to apply to the component
39
+ */
40
+ class?: string;
41
+ /**
42
+ * Selected color value (hex, rgb, etc.)
43
+ */
44
+ selectedColor?: string;
45
+ /**
46
+ * ColorSwatch size
47
+ */
48
+ size?: "small" | "medium" | "large";
49
+ /**
50
+ * letter "A" for text -> "B" for background
51
+ */
52
+ type?: "text" | "background";
53
+ /**
54
+ * ColorSwatch style
55
+ */
56
+ variant?: "filled" | "transparent";
57
+ };
@@ -0,0 +1,13 @@
1
+ <script>
2
+ import { ColorChip, utils } from "../../../../index.js";
3
+
4
+ let { color, ...rest } = $props();
5
+
6
+ let showBorder = $derived(utils.shouldShowBorder(color, utils.theme.background));
7
+ </script>
8
+
9
+ <ColorChip
10
+ borderColor={showBorder ? "#dadad8" : null}
11
+ {color}
12
+ data-color={color}
13
+ {...rest} />
@@ -0,0 +1,11 @@
1
+ export default ColorSwatchColor;
2
+ type ColorSwatchColor = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const ColorSwatchColor: import("svelte").Component<{
7
+ color: any;
8
+ } & Record<string, any>, {}, "">;
9
+ type $$ComponentProps = {
10
+ color: any;
11
+ } & Record<string, any>;
@@ -0,0 +1,49 @@
1
+ export const colorSwatchVariants: import("tailwind-variants").TVReturnType<{
2
+ size: {
3
+ small: {
4
+ base: string;
5
+ };
6
+ medium: {
7
+ base: string;
8
+ };
9
+ large: {
10
+ base: string;
11
+ };
12
+ };
13
+ }, {
14
+ base: string;
15
+ iconText: string;
16
+ iconArrow: string;
17
+ }, undefined, {
18
+ size: {
19
+ small: {
20
+ base: string;
21
+ };
22
+ medium: {
23
+ base: string;
24
+ };
25
+ large: {
26
+ base: string;
27
+ };
28
+ };
29
+ }, {
30
+ base: string;
31
+ iconText: string;
32
+ iconArrow: string;
33
+ }, import("tailwind-variants").TVReturnType<{
34
+ size: {
35
+ small: {
36
+ base: string;
37
+ };
38
+ medium: {
39
+ base: string;
40
+ };
41
+ large: {
42
+ base: string;
43
+ };
44
+ };
45
+ }, {
46
+ base: string;
47
+ iconText: string;
48
+ iconArrow: string;
49
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,46 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const colorSwatchVariants = tv({
4
+ slots: {
5
+ base: "hover:bg-neutral-300 dark:hover:bg-neutral-700 flex items-center justify-center rounded cursor-pointer gap-1 transition duration-200 select-none cursor-pointer",
6
+ iconText: "flex items-center justify-center h-4 w-4 rounded",
7
+ iconArrow: "dark:text-white",
8
+ },
9
+ variants: {
10
+ size: {
11
+ small: {
12
+ base: "p-1",
13
+ },
14
+ medium: {
15
+ base: "p-2",
16
+ },
17
+ large: {
18
+ base: "p-4",
19
+ },
20
+ },
21
+ },
22
+ compoundVariants: [
23
+ {
24
+ variant: "filled",
25
+ class: {
26
+ base: "bg-neutral-100 dark:bg-neutral-900",
27
+ },
28
+ },
29
+ {
30
+ variant: "transparent",
31
+ isOpen: true,
32
+ class: {
33
+ base: "bg-transparent",
34
+ },
35
+ },
36
+ {
37
+ variant: "transparent",
38
+ isOpen: true,
39
+ class: {
40
+ base: "bg-neutral-100 dark:bg-neutral-800",
41
+ },
42
+ },
43
+ ],
44
+ });
45
+
46
+ export { colorSwatchVariants };
@@ -0,0 +1,3 @@
1
+ import Root from "./ColorSwatch.svelte";
2
+ import Color from "./ColorSwatchColor.svelte";
3
+ export { Root, Color };
@@ -0,0 +1,4 @@
1
+ import Root from "./ColorSwatch.svelte";
2
+ import Color from "./ColorSwatchColor.svelte";
3
+
4
+ export { Root, Color };