@websline/system-components 0.0.4 → 0.0.5

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 (83) hide show
  1. package/dist/components/atoms/actions/closeButton/CloseButton.svelte +8 -5
  2. package/dist/components/atoms/actions/closeButton/CloseButton.svelte.d.ts +2 -2
  3. package/dist/components/atoms/feedback/progressBar/ProgressBar.svelte +47 -0
  4. package/dist/components/atoms/feedback/progressBar/ProgressBar.svelte.d.ts +41 -0
  5. package/dist/components/atoms/feedback/progressBar/progressBar.variants.d.ts +29 -0
  6. package/dist/components/atoms/feedback/progressBar/progressBar.variants.js +11 -0
  7. package/dist/components/molecules/formActions/formActions.svelte +25 -0
  8. package/dist/components/molecules/formActions/formActions.svelte.d.ts +41 -0
  9. package/dist/components/molecules/formActions/formActions.variants.d.ts +22 -0
  10. package/dist/components/molecules/formActions/formActions.variants.js +16 -0
  11. package/dist/components/{atoms/form → molecules}/formField/FormField.svelte +2 -2
  12. package/dist/components/{atoms/form → molecules}/formField/FormField.svelte.d.ts +2 -2
  13. package/dist/components/molecules/formLayout/FormLayout.svelte +17 -0
  14. package/dist/components/molecules/formLayout/FormLayout.svelte.d.ts +33 -0
  15. package/dist/components/molecules/formLayout/formLayout.variants.d.ts +31 -0
  16. package/dist/components/molecules/formLayout/formLayout.variants.js +18 -0
  17. package/dist/components/organisms/dialog/Dialog.svelte +17 -0
  18. package/dist/components/organisms/dialog/Dialog.svelte.d.ts +34 -0
  19. package/dist/components/organisms/dialog/DialogAction.svelte +72 -0
  20. package/dist/components/organisms/dialog/DialogAction.svelte.d.ts +33 -0
  21. package/dist/components/organisms/dialog/DialogActions.svelte +19 -0
  22. package/dist/components/organisms/dialog/DialogActions.svelte.d.ts +25 -0
  23. package/dist/components/organisms/dialog/DialogBody.svelte +18 -0
  24. package/dist/components/organisms/dialog/DialogBody.svelte.d.ts +25 -0
  25. package/dist/components/organisms/dialog/DialogContent.svelte +57 -0
  26. package/dist/components/organisms/dialog/DialogContent.svelte.d.ts +57 -0
  27. package/dist/components/organisms/dialog/DialogTrigger.svelte +14 -0
  28. package/dist/components/organisms/dialog/DialogTrigger.svelte.d.ts +17 -0
  29. package/dist/components/organisms/dialog/dialog.variants.d.ts +85 -0
  30. package/dist/components/organisms/dialog/dialog.variants.js +30 -0
  31. package/dist/components/organisms/dialog/index.d.ts +7 -0
  32. package/dist/components/organisms/dialog/index.js +8 -0
  33. package/dist/components/organisms/modal/Modal.svelte +17 -0
  34. package/dist/components/organisms/modal/Modal.svelte.d.ts +33 -0
  35. package/dist/components/organisms/modal/ModalBody.svelte +19 -0
  36. package/dist/components/organisms/modal/ModalBody.svelte.d.ts +33 -0
  37. package/dist/components/organisms/modal/ModalContent.svelte +70 -0
  38. package/dist/components/organisms/modal/ModalContent.svelte.d.ts +57 -0
  39. package/dist/components/organisms/modal/ModalHeader.svelte +28 -0
  40. package/dist/components/organisms/modal/ModalHeader.svelte.d.ts +33 -0
  41. package/dist/components/organisms/modal/ModalTrigger.svelte +14 -0
  42. package/dist/components/organisms/modal/ModalTrigger.svelte.d.ts +17 -0
  43. package/dist/components/organisms/modal/index.d.ts +6 -0
  44. package/dist/components/organisms/modal/index.js +7 -0
  45. package/dist/components/organisms/modal/modal.variants.d.ts +112 -0
  46. package/dist/components/organisms/modal/modal.variants.js +30 -0
  47. package/dist/index.d.ts +13 -8
  48. package/dist/index.js +13 -8
  49. package/dist/utils/a11y.d.ts +1 -0
  50. package/dist/utils/a11y.js +5 -0
  51. package/dist/utils/index.d.ts +1 -0
  52. package/dist/utils/index.js +1 -0
  53. package/package.json +3 -3
  54. /package/dist/components/atoms/{form/helperText → helperText}/HelperText.svelte +0 -0
  55. /package/dist/components/atoms/{form/helperText → helperText}/HelperText.svelte.d.ts +0 -0
  56. /package/dist/components/atoms/{form/helperText → helperText}/helperText.variants.d.ts +0 -0
  57. /package/dist/components/atoms/{form/helperText → helperText}/helperText.variants.js +0 -0
  58. /package/dist/components/atoms/{form/input → input}/Input.svelte +0 -0
  59. /package/dist/components/atoms/{form/input → input}/Input.svelte.d.ts +0 -0
  60. /package/dist/components/atoms/{form/input → input}/input.variants.d.ts +0 -0
  61. /package/dist/components/atoms/{form/input → input}/input.variants.js +0 -0
  62. /package/dist/components/atoms/{form/label → label}/Label.svelte +0 -0
  63. /package/dist/components/atoms/{form/label → label}/Label.svelte.d.ts +0 -0
  64. /package/dist/components/atoms/{form/label → label}/label.variants.d.ts +0 -0
  65. /package/dist/components/atoms/{form/label → label}/label.variants.js +0 -0
  66. /package/dist/components/atoms/{form/radio → radio}/Radio.svelte +0 -0
  67. /package/dist/components/atoms/{form/radio → radio}/Radio.svelte.d.ts +0 -0
  68. /package/dist/components/atoms/{form/radio → radio}/radio.variants.d.ts +0 -0
  69. /package/dist/components/atoms/{form/radio → radio}/radio.variants.js +0 -0
  70. /package/dist/components/atoms/{form/select → select}/Select.svelte +0 -0
  71. /package/dist/components/atoms/{form/select → select}/Select.svelte.d.ts +0 -0
  72. /package/dist/components/atoms/{form/select → select}/select.variants.d.ts +0 -0
  73. /package/dist/components/atoms/{form/select → select}/select.variants.js +0 -0
  74. /package/dist/components/atoms/{form/switch → switch}/Switch.svelte +0 -0
  75. /package/dist/components/atoms/{form/switch → switch}/Switch.svelte.d.ts +0 -0
  76. /package/dist/components/atoms/{form/switch → switch}/switch.variants.d.ts +0 -0
  77. /package/dist/components/atoms/{form/switch → switch}/switch.variants.js +0 -0
  78. /package/dist/components/atoms/{form/textarea → textarea}/Textarea.svelte +0 -0
  79. /package/dist/components/atoms/{form/textarea → textarea}/Textarea.svelte.d.ts +0 -0
  80. /package/dist/components/atoms/{form/textarea → textarea}/textarea.variants.d.ts +0 -0
  81. /package/dist/components/atoms/{form/textarea → textarea}/textarea.variants.js +0 -0
  82. /package/dist/components/{atoms/form → molecules}/formField/formField.variants.d.ts +0 -0
  83. /package/dist/components/{atoms/form → molecules}/formField/formField.variants.js +0 -0
@@ -6,7 +6,7 @@
6
6
  * @typedef {Object} Props
7
7
  * @property {boolean} [autoClose=false] Whether the button should automatically close after a duration
8
8
  * @property {number} [durationInSeconds=6] Duration in seconds before auto-close triggers
9
- * @property {() => void} onClose Function to call when the button is clicked or auto-closed
9
+ * @property {(event) => void} [onClose] Function to call when the button is clicked or auto-closed
10
10
  * @property {string} [class=""] Additional CSS classes to apply to the component
11
11
  * @property {"circle" | "square"} [shape="round"] Button shape
12
12
  */
@@ -16,6 +16,7 @@
16
16
  autoClose = false,
17
17
  class: className = "",
18
18
  durationInSeconds = 6,
19
+ onclick,
19
20
  onClose,
20
21
  shape = "square",
21
22
  ...rest
@@ -48,12 +49,14 @@
48
49
 
49
50
  let calculatedDurationInSeconds = $derived(durationInSeconds * 1000);
50
51
 
51
- const handleClose = () => {
52
- if (onClose) onClose();
52
+ const handleClose = (e) => {
53
+ onClose?.(e);
54
+ if (e.defaultPrevented) return;
55
+ onclick?.(e);
53
56
  };
54
57
 
55
- const handleAnimationComplete = () => {
56
- if (autoClose) onClose();
58
+ const handleAnimationComplete = (e) => {
59
+ if (autoClose) handleClose(e);
57
60
  };
58
61
  </script>
59
62
 
@@ -15,7 +15,7 @@ declare const CloseButton: import("svelte").Component<{
15
15
  /**
16
16
  * Function to call when the button is clicked or auto-closed
17
17
  */
18
- onClose: () => void;
18
+ onClose?: (event: any) => void;
19
19
  /**
20
20
  * Additional CSS classes to apply to the component
21
21
  */
@@ -37,7 +37,7 @@ type Props = {
37
37
  /**
38
38
  * Function to call when the button is clicked or auto-closed
39
39
  */
40
- onClose: () => void;
40
+ onClose?: (event: any) => void;
41
41
  /**
42
42
  * Additional CSS classes to apply to the component
43
43
  */
@@ -0,0 +1,47 @@
1
+ <script>
2
+ import { generateId } from "../../../../utils";
3
+ import { progressBarVariants } from "./progressBar.variants.js";
4
+
5
+ /**
6
+ * @typedef {Object} Props
7
+ * @property {string} [class=""] Additional CSS classes to apply to the component
8
+ * @property {number} [currentStep=1] The current step in the progress
9
+ * @property {string} [label=""] Optional label to display alongside the progress bar
10
+ * @property {number} [totalSteps] The total number of steps in the progress
11
+ */
12
+
13
+ /** @type {Props} */
14
+ let {
15
+ class: className = "",
16
+ currentStep = 1,
17
+ label = "",
18
+ totalSteps,
19
+ ...rest
20
+ } = $props();
21
+
22
+ let labelId = generateId();
23
+ let styles = $derived(progressBarVariants());
24
+
25
+ // || 0 in case currentStep or totalSteps result in NaN
26
+ let steps = $derived({
27
+ current: Math.max(0, currentStep) || 0,
28
+ total: Math.max(0, totalSteps, currentStep) || 0,
29
+ });
30
+ </script>
31
+
32
+ <div
33
+ aria-valuemax={steps.total}
34
+ aria-valuemin="0"
35
+ aria-valuenow={steps.current}
36
+ aria-labelledby={!label || rest["aria-label"] ? undefined : labelId}
37
+ role="progressbar"
38
+ class={styles.base({ class: className })}
39
+ {...rest}>
40
+ {#if label}
41
+ <span class={styles.label()} id={labelId}
42
+ >{label} {steps.current}/{steps.total}</span>
43
+ {/if}
44
+ <span
45
+ class={styles.bar()}
46
+ style:--progress={`${(steps.current / steps.total) * 100}%`}></span>
47
+ </div>
@@ -0,0 +1,41 @@
1
+ export default ProgressBar;
2
+ type ProgressBar = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const ProgressBar: import("svelte").Component<{
7
+ /**
8
+ * Additional CSS classes to apply to the component
9
+ */
10
+ class?: string;
11
+ /**
12
+ * The current step in the progress
13
+ */
14
+ currentStep?: number;
15
+ /**
16
+ * Optional label to display alongside the progress bar
17
+ */
18
+ label?: string;
19
+ /**
20
+ * The total number of steps in the progress
21
+ */
22
+ totalSteps?: number;
23
+ }, {}, "">;
24
+ type Props = {
25
+ /**
26
+ * Additional CSS classes to apply to the component
27
+ */
28
+ class?: string;
29
+ /**
30
+ * The current step in the progress
31
+ */
32
+ currentStep?: number;
33
+ /**
34
+ * Optional label to display alongside the progress bar
35
+ */
36
+ label?: string;
37
+ /**
38
+ * The total number of steps in the progress
39
+ */
40
+ totalSteps?: number;
41
+ };
@@ -0,0 +1,29 @@
1
+ export const progressBarVariants: import("tailwind-variants").TVReturnType<{
2
+ [key: string]: {
3
+ [key: string]: import("tailwind-variants").ClassValue | {
4
+ base?: import("tailwind-variants").ClassValue;
5
+ bar?: import("tailwind-variants").ClassValue;
6
+ label?: import("tailwind-variants").ClassValue;
7
+ };
8
+ };
9
+ } | {
10
+ [x: string]: {
11
+ [x: string]: import("tailwind-variants").ClassValue | {
12
+ base?: import("tailwind-variants").ClassValue;
13
+ bar?: import("tailwind-variants").ClassValue;
14
+ label?: import("tailwind-variants").ClassValue;
15
+ };
16
+ };
17
+ }, {
18
+ bar: string;
19
+ base: string;
20
+ label: string;
21
+ }, undefined, any, {
22
+ bar: string;
23
+ base: string;
24
+ label: string;
25
+ }, import("tailwind-variants").TVReturnType<any, {
26
+ bar: string;
27
+ base: string;
28
+ label: string;
29
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,11 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const progressBarVariants = tv({
4
+ slots: {
5
+ bar: "h-1 w-full rounded-sm bg-neutral-100 after:block after:h-full after:w-[var(--progress)] after:rounded-sm after:bg-neutral-900 after:transition-[width] after:duration-300 after:ease-in-out dark:bg-neutral-900 dark:after:bg-neutral-100",
6
+ base: "flex items-center gap-4 p-2",
7
+ label: "body-small text-nowrap text-neutral-500",
8
+ },
9
+ });
10
+
11
+ export { progressBarVariants };
@@ -0,0 +1,25 @@
1
+ <script>
2
+ import { formActionsVariants } from "./formActions.variants.js";
3
+
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 to apply to the component
8
+ * @property {boolean} [customLayout=false] If true, the default layout is disabled
9
+ * @property {boolean} [fullWidth=false] If true, the form actions will take the full width of its container
10
+ */
11
+
12
+ /** @type {Props} */
13
+ let {
14
+ children,
15
+ class: className,
16
+ customLayout = false,
17
+ fullWidth = false,
18
+ } = $props();
19
+ </script>
20
+
21
+ <div
22
+ class={formActionsVariants({ class: className, customLayout, fullWidth })}
23
+ data-form-actions>
24
+ {@render children?.()}
25
+ </div>
@@ -0,0 +1,41 @@
1
+ export default FormActions;
2
+ type FormActions = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const FormActions: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * If true, the default layout is disabled
17
+ */
18
+ customLayout?: boolean;
19
+ /**
20
+ * If true, the form actions will take the full width of its container
21
+ */
22
+ fullWidth?: boolean;
23
+ }, {}, "">;
24
+ type Props = {
25
+ /**
26
+ * Children content – can be text, HTML, or other Svelte components
27
+ */
28
+ children?: import("svelte").Snippet;
29
+ /**
30
+ * Additional CSS classes to apply to the component
31
+ */
32
+ class?: string;
33
+ /**
34
+ * If true, the default layout is disabled
35
+ */
36
+ customLayout?: boolean;
37
+ /**
38
+ * If true, the form actions will take the full width of its container
39
+ */
40
+ fullWidth?: boolean;
41
+ };
@@ -0,0 +1,22 @@
1
+ export const formActionsVariants: import("tailwind-variants").TVReturnType<{
2
+ customLayout: {
3
+ false: string;
4
+ };
5
+ fullWidth: {
6
+ true: string;
7
+ };
8
+ }, undefined, "flex items-center justify-end gap-2", {
9
+ customLayout: {
10
+ false: string;
11
+ };
12
+ fullWidth: {
13
+ true: string;
14
+ };
15
+ }, undefined, import("tailwind-variants").TVReturnType<{
16
+ customLayout: {
17
+ false: string;
18
+ };
19
+ fullWidth: {
20
+ true: string;
21
+ };
22
+ }, undefined, "flex items-center justify-end gap-2", unknown, unknown, undefined>>;
@@ -0,0 +1,16 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const formActionsVariants = tv({
4
+ base: "flex items-center justify-end gap-2",
5
+ variants: {
6
+ customLayout: {
7
+ false:
8
+ "[&:has(>button:nth-of-type(3):last-of-type)>button:first-of-type]:mr-auto",
9
+ },
10
+ fullWidth: {
11
+ true: "[&>*]:w-full [&>*]:justify-center",
12
+ },
13
+ },
14
+ });
15
+
16
+ export { formActionsVariants };
@@ -1,12 +1,12 @@
1
1
  <script>
2
2
  import { setContext } from "svelte";
3
3
  import { formFieldVariants } from "./formField.variants.js";
4
- import { HelperText, Label } from "../../../../index.js";
4
+ import { HelperText, Label } from "../../../index.js";
5
5
 
6
6
  /**
7
7
  * @typedef {Object} Props
8
8
  * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
9
- * @property {string} [class=""] Additional CSS classes for the form field
9
+ * @property {string} [class=""] Additional CSS classes to apply to the component
10
10
  * @property {boolean} [error=false] Whether the form field has an error
11
11
  * @property {string} [errorText=""] The error text for the form field
12
12
  * @property {string} [helperText=""] The helper text for the form field
@@ -9,7 +9,7 @@ declare const FormField: import("svelte").Component<{
9
9
  */
10
10
  children?: import("svelte").Snippet;
11
11
  /**
12
- * Additional CSS classes for the form field
12
+ * Additional CSS classes to apply to the component
13
13
  */
14
14
  class?: string;
15
15
  /**
@@ -47,7 +47,7 @@ type Props = {
47
47
  */
48
48
  children?: import("svelte").Snippet;
49
49
  /**
50
- * Additional CSS classes for the form field
50
+ * Additional CSS classes to apply to the component
51
51
  */
52
52
  class?: string;
53
53
  /**
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import { formLayoutVariants } from "./formLayout.variants.js";
3
+
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 to apply to the component
8
+ * @property {0|1|2|3|4|6|8} [gap=2] Gap between form elements (in Tailwind spacing scale)
9
+ */
10
+
11
+ /** @type {Props} */
12
+ let { children, class: className, gap = 2 } = $props();
13
+ </script>
14
+
15
+ <div class={formLayoutVariants({ class: className, gap })}>
16
+ {@render children?.()}
17
+ </div>
@@ -0,0 +1,33 @@
1
+ export default FormLayout;
2
+ type FormLayout = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const FormLayout: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * Gap between form elements (in Tailwind spacing scale)
17
+ */
18
+ gap?: 0 | 1 | 2 | 3 | 4 | 6 | 8;
19
+ }, {}, "">;
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 to apply to the component
27
+ */
28
+ class?: string;
29
+ /**
30
+ * Gap between form elements (in Tailwind spacing scale)
31
+ */
32
+ gap?: 0 | 1 | 2 | 3 | 4 | 6 | 8;
33
+ };
@@ -0,0 +1,31 @@
1
+ export const formLayoutVariants: import("tailwind-variants").TVReturnType<{
2
+ gap: {
3
+ 0: string;
4
+ 1: string;
5
+ 2: string;
6
+ 3: string;
7
+ 4: string;
8
+ 6: string;
9
+ 8: string;
10
+ };
11
+ }, undefined, "grid gap-2 [&>[data-form-actions]]:mt-4", {
12
+ gap: {
13
+ 0: string;
14
+ 1: string;
15
+ 2: string;
16
+ 3: string;
17
+ 4: string;
18
+ 6: string;
19
+ 8: string;
20
+ };
21
+ }, undefined, import("tailwind-variants").TVReturnType<{
22
+ gap: {
23
+ 0: string;
24
+ 1: string;
25
+ 2: string;
26
+ 3: string;
27
+ 4: string;
28
+ 6: string;
29
+ 8: string;
30
+ };
31
+ }, undefined, "grid gap-2 [&>[data-form-actions]]:mt-4", unknown, unknown, undefined>>;
@@ -0,0 +1,18 @@
1
+ import { tv } from "tailwind-variants";
2
+
3
+ const formLayoutVariants = tv({
4
+ base: "grid gap-2 [&>[data-form-actions]]:mt-4",
5
+ variants: {
6
+ gap: {
7
+ 0: "gap-0",
8
+ 1: "gap-1",
9
+ 2: "gap-2",
10
+ 3: "gap-3",
11
+ 4: "gap-4",
12
+ 6: "gap-6",
13
+ 8: "gap-8",
14
+ },
15
+ },
16
+ });
17
+
18
+ export { formLayoutVariants };
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import { Dialog } from "bits-ui";
3
+
4
+ /**
5
+ * @typedef {Object} Props
6
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
7
+ * @property {(open: boolean) => void} [onOpenChange] Callback fired when the open state of the dialog changes
8
+ * @property {boolean} [open=false] Wether this dialog is open or not, bound to the component
9
+ */
10
+
11
+ /** @type {Props} */
12
+ let { children, onOpenChange, open = $bindable(false), ...rest } = $props();
13
+ </script>
14
+
15
+ <Dialog.Root bind:open {onOpenChange} {...rest}>
16
+ {@render children?.()}
17
+ </Dialog.Root>
@@ -0,0 +1,34 @@
1
+ export default Dialog;
2
+ type Dialog = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const Dialog: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Callback fired when the open state of the dialog changes
13
+ */
14
+ onOpenChange?: (open: boolean) => void;
15
+ /**
16
+ * Wether this dialog is open or not, bound to the component
17
+ */
18
+ open?: boolean;
19
+ }, {}, "open">;
20
+ import { Dialog } from "bits-ui";
21
+ type Props = {
22
+ /**
23
+ * Children content – can be text, HTML, or other Svelte components
24
+ */
25
+ children?: import("svelte").Snippet;
26
+ /**
27
+ * Callback fired when the open state of the dialog changes
28
+ */
29
+ onOpenChange?: (open: boolean) => void;
30
+ /**
31
+ * Wether this dialog is open or not, bound to the component
32
+ */
33
+ open?: boolean;
34
+ };
@@ -0,0 +1,72 @@
1
+ <script>
2
+ import { Dialog } from "bits-ui";
3
+ import { Button } from "../../../index.js";
4
+
5
+ /**
6
+ * Defines the semantic role of the button within a dialog.
7
+ *
8
+ * - "cta": The primary call-to-action. Represents the main decision the dialog is asking for.
9
+ * This can be constructive (e.g. "Save") or destructive (e.g. "Delete").
10
+ * There should be only one CTA per dialog.
11
+ *
12
+ * - "secondary": An alternative but relevant option besides the main action.
13
+ * Example: "Don't save" in a save confirmation dialog.
14
+ * Use only when the dialog provides more than two choices.
15
+ *
16
+ * - "dismiss": A cancel/close action that simply exits the dialog without
17
+ * committing to any of the main or secondary actions. Typically labeled
18
+ * "Cancel" or "Close". Should always be visually de-emphasized.
19
+ *
20
+ * Default: "cta"
21
+ */
22
+
23
+ /**
24
+ * @typedef {Object} Props
25
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
26
+ * @property {string} [class=""] Additional CSS classes to apply to the component
27
+ * @property {"cta" | "secondary" | "dismiss"} [role="cta"] Semantic role of the button within a dialog
28
+ */
29
+
30
+ /** @type {Props} */
31
+ let {
32
+ children,
33
+ class: className = "",
34
+ color = "secondary",
35
+ role = "cta",
36
+ ...rest
37
+ } = $props();
38
+
39
+ let buttonProps = $derived.by(
40
+ () =>
41
+ ({
42
+ cta: {
43
+ color,
44
+ tabIndex: 3,
45
+ variant: "filled",
46
+ },
47
+ secondary: {
48
+ tabIndex: 2,
49
+ variant: "outlined",
50
+ },
51
+ dismiss: {
52
+ tabIndex: 1,
53
+ variant: "text",
54
+ },
55
+ })[role] || {
56
+ variant: "filled",
57
+ },
58
+ );
59
+ </script>
60
+
61
+ <Dialog.Close
62
+ class={className}
63
+ color="secondary"
64
+ data-role={role}
65
+ size="large"
66
+ {...rest}>
67
+ {#snippet child({ props })}
68
+ <Button {...props} {...buttonProps}>
69
+ {@render children?.()}
70
+ </Button>
71
+ {/snippet}
72
+ </Dialog.Close>
@@ -0,0 +1,33 @@
1
+ export default DialogAction;
2
+ type DialogAction = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const DialogAction: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ /**
16
+ * Semantic role of the button within a dialog
17
+ */
18
+ role?: "cta" | "secondary" | "dismiss";
19
+ }, {}, "">;
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 to apply to the component
27
+ */
28
+ class?: string;
29
+ /**
30
+ * Semantic role of the button within a dialog
31
+ */
32
+ role?: "cta" | "secondary" | "dismiss";
33
+ };
@@ -0,0 +1,19 @@
1
+ <script>
2
+ import { FormActions } from "../../../index.js";
3
+ import { dialogVariants } from "./dialog.variants.js";
4
+
5
+ /**
6
+ * @typedef {Object} Props
7
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
8
+ * @property {string} [class=""] Additional CSS classes to apply to the component
9
+ */
10
+
11
+ /** @type {Props} */
12
+ let { children, class: className = "" } = $props();
13
+
14
+ let styles = $derived(dialogVariants());
15
+ </script>
16
+
17
+ <FormActions class={styles.formActions({ class: className })} customLayout>
18
+ {@render children?.()}
19
+ </FormActions>
@@ -0,0 +1,25 @@
1
+ export default DialogActions;
2
+ type DialogActions = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<Props>): void;
5
+ };
6
+ declare const DialogActions: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet;
11
+ /**
12
+ * Additional CSS classes to apply to the component
13
+ */
14
+ class?: string;
15
+ }, {}, "">;
16
+ type Props = {
17
+ /**
18
+ * Children content – can be text, HTML, or other Svelte components
19
+ */
20
+ children?: import("svelte").Snippet;
21
+ /**
22
+ * Additional CSS classes to apply to the component
23
+ */
24
+ class?: string;
25
+ };
@@ -0,0 +1,18 @@
1
+ <script>
2
+ import { dialogVariants } from "./dialog.variants.js";
3
+
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 to apply to the component
8
+ */
9
+
10
+ /** @type {Props} */
11
+ let { children, class: className = "", ...rest } = $props();
12
+
13
+ let styles = $derived(dialogVariants());
14
+ </script>
15
+
16
+ <div class={styles.body({ class: className })} {...rest}>
17
+ {@render children?.()}
18
+ </div>