svelte-comp 1.2.5 → 1.2.6

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 (84) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/dist/App.svelte +0 -551
  4. package/dist/App.svelte.d.ts +0 -3
  5. package/dist/Container.svelte +0 -60
  6. package/dist/Container.svelte.d.ts +0 -12
  7. package/dist/app.css +0 -235
  8. package/dist/index.d.ts +0 -5
  9. package/dist/index.js +0 -6
  10. package/dist/lang.d.ts +0 -1081
  11. package/dist/lang.js +0 -1096
  12. package/dist/lib/Accordion.svelte +0 -155
  13. package/dist/lib/Accordion.svelte.d.ts +0 -40
  14. package/dist/lib/Button.svelte +0 -170
  15. package/dist/lib/Button.svelte.d.ts +0 -53
  16. package/dist/lib/Card.svelte +0 -103
  17. package/dist/lib/Card.svelte.d.ts +0 -42
  18. package/dist/lib/Carousel.svelte +0 -293
  19. package/dist/lib/Carousel.svelte.d.ts +0 -13
  20. package/dist/lib/CheckBox.svelte +0 -210
  21. package/dist/lib/CheckBox.svelte.d.ts +0 -53
  22. package/dist/lib/CodeView.svelte +0 -307
  23. package/dist/lib/CodeView.svelte.d.ts +0 -64
  24. package/dist/lib/ColorPicker.svelte +0 -161
  25. package/dist/lib/ColorPicker.svelte.d.ts +0 -40
  26. package/dist/lib/DatePicker.svelte +0 -170
  27. package/dist/lib/DatePicker.svelte.d.ts +0 -53
  28. package/dist/lib/Dialog.svelte +0 -235
  29. package/dist/lib/Dialog.svelte.d.ts +0 -58
  30. package/dist/lib/Field.svelte +0 -299
  31. package/dist/lib/Field.svelte.d.ts +0 -8
  32. package/dist/lib/FilePicker.svelte +0 -241
  33. package/dist/lib/FilePicker.svelte.d.ts +0 -52
  34. package/dist/lib/Form.svelte +0 -438
  35. package/dist/lib/Form.svelte.d.ts +0 -20
  36. package/dist/lib/Hamburger.svelte +0 -211
  37. package/dist/lib/Hamburger.svelte.d.ts +0 -52
  38. package/dist/lib/Menu.svelte +0 -623
  39. package/dist/lib/Menu.svelte.d.ts +0 -33
  40. package/dist/lib/PaginatedCard.svelte +0 -73
  41. package/dist/lib/PaginatedCard.svelte.d.ts +0 -11
  42. package/dist/lib/Pagination.svelte +0 -119
  43. package/dist/lib/Pagination.svelte.d.ts +0 -9
  44. package/dist/lib/PrimaryColorSelect.svelte +0 -113
  45. package/dist/lib/PrimaryColorSelect.svelte.d.ts +0 -9
  46. package/dist/lib/ProgressBar.svelte +0 -141
  47. package/dist/lib/ProgressBar.svelte.d.ts +0 -48
  48. package/dist/lib/ProgressCircle.svelte +0 -192
  49. package/dist/lib/ProgressCircle.svelte.d.ts +0 -39
  50. package/dist/lib/Radio.svelte +0 -189
  51. package/dist/lib/Radio.svelte.d.ts +0 -55
  52. package/dist/lib/SearchInput.svelte +0 -106
  53. package/dist/lib/SearchInput.svelte.d.ts +0 -13
  54. package/dist/lib/Select.svelte +0 -524
  55. package/dist/lib/Select.svelte.d.ts +0 -21
  56. package/dist/lib/Slider.svelte +0 -253
  57. package/dist/lib/Slider.svelte.d.ts +0 -56
  58. package/dist/lib/Splitter.svelte +0 -150
  59. package/dist/lib/Splitter.svelte.d.ts +0 -43
  60. package/dist/lib/Switch.svelte +0 -167
  61. package/dist/lib/Switch.svelte.d.ts +0 -42
  62. package/dist/lib/Table.svelte +0 -299
  63. package/dist/lib/Table.svelte.d.ts +0 -17
  64. package/dist/lib/Tabs.svelte +0 -213
  65. package/dist/lib/Tabs.svelte.d.ts +0 -48
  66. package/dist/lib/ThemeToggle.svelte +0 -127
  67. package/dist/lib/ThemeToggle.svelte.d.ts +0 -32
  68. package/dist/lib/TimePicker.svelte +0 -269
  69. package/dist/lib/TimePicker.svelte.d.ts +0 -48
  70. package/dist/lib/Toast.svelte +0 -226
  71. package/dist/lib/Toast.svelte.d.ts +0 -14
  72. package/dist/lib/Tooltip.svelte +0 -110
  73. package/dist/lib/Tooltip.svelte.d.ts +0 -40
  74. package/dist/lib/index.d.ts +0 -32
  75. package/dist/lib/index.js +0 -33
  76. package/dist/lib/lang.d.ts +0 -158
  77. package/dist/lib/lang.js +0 -150
  78. package/dist/lib/types/index.d.ts +0 -111
  79. package/dist/lib/types/index.js +0 -26
  80. package/dist/main.d.ts +0 -3
  81. package/dist/main.js +0 -7
  82. package/dist/styles.css +0 -232
  83. package/dist/utils/index.d.ts +0 -34
  84. package/dist/utils/index.js +0 -268
@@ -1,170 +0,0 @@
1
- <!-- src/lib/DatePicker.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component DatePicker
5
- * @description Button-driven date selector that formats the chosen value and supports min/max limits.
6
- *
7
- * @prop value {string | null} - Selected date value (ISO `YYYY-MM-DD`)
8
- * @default null
9
- *
10
- * @prop min {string} - Minimum selectable date (ISO `YYYY-MM-DD`)
11
- *
12
- * @prop max {string} - Maximum selectable date (ISO `YYYY-MM-DD`)
13
- *
14
- * @prop label {string} - Label text displayed above the picker
15
- *
16
- * @prop placeholder {string} - Placeholder shown when no date is selected
17
- *
18
- * @prop locale {string} - Locale used for formatting
19
- *
20
- * @prop formatOptions {Intl.DateTimeFormatOptions} - Custom date formatting options
21
- *
22
- * @prop disabled {boolean} - Disables all interactions
23
- * @default false
24
- *
25
- * @prop clearable {boolean} - Shows a clear button to reset the value
26
- * @default true
27
- *
28
- * @prop onChange {(value: string | null) => void} - Fired when the date changes
29
- *
30
- * @prop class {string} - Additional classes for the wrapper element
31
- * @default ""
32
- *
33
- * @note Wraps a hidden `<input type="date">` so native date-pickers, keyboard, and validation work automatically.
34
- * @note `showPicker()` is used when available for a consistent trigger; fallback is focus + click.
35
- * @note Formatter uses `Intl.DateTimeFormat` (with `locale`/`formatOptions`) and gracefully falls back to `toLocaleDateString()`.
36
- * @note `clearable` resets the underlying input value and dispatches `onChange(null)`.
37
- * @note Preview card includes `aria-live="polite"` to announce updated dates.
38
- */
39
- import type { HTMLAttributes } from "svelte/elements";
40
- import { getContext } from "svelte";
41
- import Button from "./Button.svelte";
42
- import { cx, formatDate } from "../utils";
43
- import { TEXTS } from "./lang";
44
-
45
- type Props = HTMLAttributes<HTMLDivElement> & {
46
- value?: string | null;
47
- min?: string;
48
- max?: string;
49
- label?: string;
50
- placeholder?: string;
51
- locale?: string;
52
- formatOptions?: Intl.DateTimeFormatOptions;
53
- disabled?: boolean;
54
- clearable?: boolean;
55
- onChange?: (value: string | null) => void;
56
- class?: string;
57
- };
58
-
59
- let {
60
- value = $bindable<string | null>(null),
61
- min,
62
- max,
63
- label,
64
- placeholder,
65
- locale,
66
- formatOptions,
67
- disabled = false,
68
- clearable = true,
69
- onChange,
70
- class: externalClass = "",
71
- ...rest
72
- }: Props = $props();
73
-
74
- const langCtx =
75
- getContext<{ value: keyof typeof TEXTS } | undefined>("lang") ?? null;
76
- const langKey = $derived(langCtx?.value ?? "en");
77
- const L = $derived(TEXTS[langKey].components.datePicker);
78
-
79
- const labelFinal = $derived(label ?? L.text);
80
- const placeholderFinal = $derived(placeholder ?? L.placeholder);
81
-
82
- let inputEl: HTMLInputElement;
83
-
84
- const base = "inline-block w-full";
85
- const pickerClass = $derived(cx(base, externalClass));
86
-
87
- const hasValue = $derived(Boolean(value));
88
- const formattedValue = $derived(formatDate(value, locale, formatOptions));
89
-
90
- $effect(() => {
91
- if (inputEl) {
92
- inputEl.value = value ?? "";
93
- }
94
- });
95
-
96
- function openPicker() {
97
- if (disabled) return;
98
- if (typeof inputEl?.showPicker === "function") {
99
- inputEl.showPicker();
100
- } else {
101
- inputEl?.focus();
102
- inputEl?.click();
103
- }
104
- }
105
-
106
- function handleInput(event: Event) {
107
- const target = event.target as HTMLInputElement;
108
- const nextValue = target.value || null;
109
- value = nextValue;
110
- onChange?.(nextValue);
111
- }
112
-
113
- function clearSelection() {
114
- if (!clearable) return;
115
- value = null;
116
- if (inputEl) {
117
- inputEl.value = "";
118
- }
119
- onChange?.(null);
120
- }
121
- </script>
122
-
123
- <div class={pickerClass} {...rest}>
124
- <div class="text-md font-medium mb-2 [color:var(--color-text-default)]">
125
- {labelFinal}:
126
- </div>
127
- <div class="flex flex-wrap items-center gap-x-3 gap-y-2">
128
- <Button onClick={openPicker} {disabled} sz="xs">
129
- {L.date}
130
- </Button>
131
-
132
- {#if clearable}
133
- <Button
134
- onClick={clearSelection}
135
- variant="danger"
136
- disabled={!hasValue || disabled}
137
- sz="xs"
138
- >
139
- {L.clear}
140
- </Button>
141
- {/if}
142
- </div>
143
-
144
- <input
145
- bind:this={inputEl}
146
- type="date"
147
- {min}
148
- {max}
149
- {disabled}
150
- class="invisible absolute w-px h-px"
151
- onchange={handleInput}
152
- />
153
-
154
- <div
155
- class="mt-3 p-4 bg-[var(--color-bg-surface)] text-center"
156
- aria-live="polite"
157
- >
158
- <p class="text-xs uppercase tracking-wide [color:var(--color-text-muted)]">
159
- {L.selectedDate}
160
- </p>
161
-
162
- <p class="text-sm font-semibold mt-1 [color:var(--color-text-default)]">
163
- {#if hasValue}
164
- {formattedValue}
165
- {:else}
166
- {placeholderFinal}
167
- {/if}
168
- </p>
169
- </div>
170
- </div>
@@ -1,53 +0,0 @@
1
- /**
2
- * @component DatePicker
3
- * @description Button-driven date selector that formats the chosen value and supports min/max limits.
4
- *
5
- * @prop value {string | null} - Selected date value (ISO `YYYY-MM-DD`)
6
- * @default null
7
- *
8
- * @prop min {string} - Minimum selectable date (ISO `YYYY-MM-DD`)
9
- *
10
- * @prop max {string} - Maximum selectable date (ISO `YYYY-MM-DD`)
11
- *
12
- * @prop label {string} - Label text displayed above the picker
13
- *
14
- * @prop placeholder {string} - Placeholder shown when no date is selected
15
- *
16
- * @prop locale {string} - Locale used for formatting
17
- *
18
- * @prop formatOptions {Intl.DateTimeFormatOptions} - Custom date formatting options
19
- *
20
- * @prop disabled {boolean} - Disables all interactions
21
- * @default false
22
- *
23
- * @prop clearable {boolean} - Shows a clear button to reset the value
24
- * @default true
25
- *
26
- * @prop onChange {(value: string | null) => void} - Fired when the date changes
27
- *
28
- * @prop class {string} - Additional classes for the wrapper element
29
- * @default ""
30
- *
31
- * @note Wraps a hidden `<input type="date">` so native date-pickers, keyboard, and validation work automatically.
32
- * @note `showPicker()` is used when available for a consistent trigger; fallback is focus + click.
33
- * @note Formatter uses `Intl.DateTimeFormat` (with `locale`/`formatOptions`) and gracefully falls back to `toLocaleDateString()`.
34
- * @note `clearable` resets the underlying input value and dispatches `onChange(null)`.
35
- * @note Preview card includes `aria-live="polite"` to announce updated dates.
36
- */
37
- import type { HTMLAttributes } from "svelte/elements";
38
- type Props = HTMLAttributes<HTMLDivElement> & {
39
- value?: string | null;
40
- min?: string;
41
- max?: string;
42
- label?: string;
43
- placeholder?: string;
44
- locale?: string;
45
- formatOptions?: Intl.DateTimeFormatOptions;
46
- disabled?: boolean;
47
- clearable?: boolean;
48
- onChange?: (value: string | null) => void;
49
- class?: string;
50
- };
51
- declare const DatePicker: import("svelte").Component<Props, {}, "value">;
52
- type DatePicker = ReturnType<typeof DatePicker>;
53
- export default DatePicker;
@@ -1,235 +0,0 @@
1
- <!-- src/lib/Dialog.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component Dialog
5
- * @description Modal dialog for confirmations or alerts.
6
- *
7
- * @prop open {boolean} - Controls dialog visibility
8
- * @default false
9
- *
10
- * @prop title {string} - Dialog title used for labeling
11
- * @default ""
12
- *
13
- * @prop message {string} - Simple message content
14
- * @default ""
15
- *
16
- * @prop onConfirm {() => void} - Fired when the confirm action is triggered
17
- * @default () => {}
18
- *
19
- * @prop onCancel {() => void} - Fired when the cancel action is triggered
20
- * @default () => {}
21
- *
22
- * @prop onClose {() => void} - Fired after confirm or cancel to centralize cleanup
23
- * @default () => {}
24
- *
25
- * @prop modal {boolean} - Enables modal mode with overlay and focus trap
26
- * @default true
27
- *
28
- * @prop class {string} - Extra classes applied to the dialog container
29
- * @default ""
30
- *
31
- * @prop sz {SizeKey} - Size preset for padding and text
32
- * @options xs|sm|md|lg|xl
33
- * @default md
34
- *
35
- * @prop children {Snippet} - Custom dialog body content
36
- *
37
- * @note In modal mode the first interactive element is focused automatically and focus is trapped inside the dialog; `Escape` triggers cancel.
38
- * @note `onClose` runs after `onConfirm`/`onCancel`, so you can centralize cleanup.
39
- * @note Non-modal mode (`modal=false`) renders a floating panel without overlay or focus trap.
40
- * @note Buttons are labeled "OK" and "Cancel" and aren't customizable via props; provide `children` for full custom UI.
41
- * @note Set a meaningful `title` for accessibility; it's used as the dialog's `aria-label`.
42
- * @note `sz` adjusts both dialog padding and text sizes to match the rest of the system tokens.
43
- */
44
- import type { Snippet } from "svelte";
45
- import { getContext } from "svelte";
46
- import { TEXTS } from "./lang";
47
- import Button from "./Button.svelte";
48
- import { type SizeKey, TEXT } from "./types";
49
- import { cx, focusFirstInteractive, trapFocus } from "../utils";
50
-
51
- type Props = {
52
- open?: boolean;
53
- title?: string;
54
- message?: string;
55
- onConfirm?: () => void;
56
- onCancel?: () => void;
57
- onClose?: () => void;
58
- modal?: boolean;
59
- class?: string;
60
- sz?: SizeKey;
61
- children?: Snippet<[SizeKey]>;
62
- };
63
-
64
- let {
65
- open = false,
66
- title = "",
67
- message = "",
68
- onConfirm = () => {},
69
- onCancel = () => {},
70
- onClose = () => {},
71
- modal = true,
72
- class: externalClass = "",
73
- sz = "md",
74
- children,
75
- }: Props = $props();
76
-
77
- const langCtx =
78
- getContext<{ value: keyof typeof TEXTS } | undefined>("lang") ?? null;
79
- const langKey = $derived(langCtx?.value ?? "en");
80
- const L = $derived(TEXTS[langKey].components.dialog);
81
-
82
- let panelEl = $state<HTMLDivElement | null>(null);
83
- let releaseFocus: (() => void) | null = null;
84
-
85
- function handleConfirm() {
86
- onConfirm();
87
- onClose();
88
- }
89
-
90
- function handleCancel() {
91
- onCancel();
92
- onClose();
93
- }
94
-
95
- function handleKeydown(e: KeyboardEvent) {
96
- if (e.key === "Escape") {
97
- e.preventDefault();
98
- handleCancel();
99
- }
100
- }
101
-
102
- const panelBase =
103
- "fusion-dialog bg-[var(--color-bg-surface)] rounded-[var(--radius-lg)] shadow-lg min-w-80 max-w-md w-full border border-[var(--border-color-default)]";
104
-
105
- const paddingBySize: Record<SizeKey, string> = {
106
- xs: "p-[var(--spacing-sm)]",
107
- sm: "p-[var(--spacing-md)]",
108
- md: "p-[var(--spacing-lg)]",
109
- lg: "p-[var(--spacing-xl)]",
110
- xl: "p-[var(--spacing-xl)]",
111
- };
112
-
113
- const titleTextBySize: Record<SizeKey, string> = {
114
- xs: TEXT.md,
115
- sm: TEXT.md,
116
- md: TEXT.xl,
117
- lg: TEXT.xl,
118
- xl: "text-2xl",
119
- };
120
-
121
- const panelClass = $derived(cx(panelBase, externalClass));
122
- const paddingCls = $derived(paddingBySize[sz]);
123
- const footerPaddingCls = $derived(cx(paddingCls, "pt-0"));
124
- const titleTextCls = $derived(titleTextBySize[sz]);
125
- const bodyTextCls = $derived(TEXT[sz]);
126
-
127
- $effect(() => {
128
- releaseFocus?.();
129
- if (open && panelEl) {
130
- queueMicrotask(() => {
131
- focusFirstInteractive(panelEl!);
132
- if (modal) {
133
- releaseFocus = trapFocus(panelEl!);
134
- }
135
- });
136
- } else {
137
- releaseFocus = null;
138
- }
139
-
140
- return () => {
141
- releaseFocus?.();
142
- releaseFocus = null;
143
- };
144
- });
145
- </script>
146
-
147
- {#snippet titleBlock()}
148
- <h3
149
- class={cx(
150
- "mb-2 font-[var(--font-weight-semibold)] color-[var(--color-text-default)]",
151
- titleTextCls
152
- )}
153
- >
154
- {title}
155
- </h3>
156
- <p
157
- class={cx(
158
- "leading-[var(--line-height-normal)] color-[var(--color-text-muted)]",
159
- bodyTextCls
160
- )}
161
- >
162
- {message}
163
- </p>
164
- {/snippet}
165
-
166
- {#if open}
167
- {#if modal}
168
- <div
169
- class="fixed inset-0 z-[var(--z-modal)] bg-oklch(0_0_0/var(--opacity-overlay)) flex items-center justify-center p-4"
170
- role="presentation"
171
- tabindex="-1"
172
- onkeydown={handleKeydown}
173
- >
174
- <div
175
- class={panelClass}
176
- role="dialog"
177
- aria-modal="true"
178
- aria-label={title}
179
- bind:this={panelEl}
180
- >
181
- <div class={paddingCls}>
182
- {@render titleBlock()}
183
-
184
- {#if children}
185
- <div class="mt-3">
186
- {@render children?.(sz)}
187
- </div>
188
- {/if}
189
- </div>
190
-
191
- <div class={cx("flex gap-2 justify-end", footerPaddingCls)}>
192
- <Button {sz} variant="primary" onClick={handleConfirm}>{L.ok}</Button>
193
- <Button {sz} variant="secondary" onClick={handleCancel}>{L.cancel}</Button
194
- >
195
- </div>
196
- </div>
197
- </div>
198
- {:else}
199
- <div
200
- class="fixed top-4 right-4 z-[var(--z-modal)]"
201
- role="dialog"
202
- aria-modal="false"
203
- aria-label={title}
204
- tabindex="-1"
205
- onkeydown={handleKeydown}
206
- >
207
- <div class={panelClass} bind:this={panelEl}>
208
- <div class={paddingCls}>
209
- {@render titleBlock()}
210
-
211
- {#if children}
212
- <div class={cx("mt-3", bodyTextCls)}>
213
- {@render children?.(sz)}
214
- </div>
215
- {/if}
216
- </div>
217
-
218
- <div class={cx("flex gap-2 justify-end", footerPaddingCls)}>
219
- <Button {sz} variant="primary" onClick={handleConfirm}>{L.ok}</Button>
220
- <Button {sz} variant="secondary" onClick={handleCancel}>{L.cancel}</Button
221
- >
222
- </div>
223
- </div>
224
- </div>
225
- {/if}
226
- {/if}
227
- <style>
228
- :global(.fusion-dialog h3) {
229
- color: var(--color-text-default);
230
- }
231
-
232
- :global(.fusion-dialog p) {
233
- color: var(--color-text-muted);
234
- }
235
- </style>
@@ -1,58 +0,0 @@
1
- /**
2
- * @component Dialog
3
- * @description Modal dialog for confirmations or alerts.
4
- *
5
- * @prop open {boolean} - Controls dialog visibility
6
- * @default false
7
- *
8
- * @prop title {string} - Dialog title used for labeling
9
- * @default ""
10
- *
11
- * @prop message {string} - Simple message content
12
- * @default ""
13
- *
14
- * @prop onConfirm {() => void} - Fired when the confirm action is triggered
15
- * @default () => {}
16
- *
17
- * @prop onCancel {() => void} - Fired when the cancel action is triggered
18
- * @default () => {}
19
- *
20
- * @prop onClose {() => void} - Fired after confirm or cancel to centralize cleanup
21
- * @default () => {}
22
- *
23
- * @prop modal {boolean} - Enables modal mode with overlay and focus trap
24
- * @default true
25
- *
26
- * @prop class {string} - Extra classes applied to the dialog container
27
- * @default ""
28
- *
29
- * @prop sz {SizeKey} - Size preset for padding and text
30
- * @options xs|sm|md|lg|xl
31
- * @default md
32
- *
33
- * @prop children {Snippet} - Custom dialog body content
34
- *
35
- * @note In modal mode the first interactive element is focused automatically and focus is trapped inside the dialog; `Escape` triggers cancel.
36
- * @note `onClose` runs after `onConfirm`/`onCancel`, so you can centralize cleanup.
37
- * @note Non-modal mode (`modal=false`) renders a floating panel without overlay or focus trap.
38
- * @note Buttons are labeled "OK" and "Cancel" and aren't customizable via props; provide `children` for full custom UI.
39
- * @note Set a meaningful `title` for accessibility; it's used as the dialog's `aria-label`.
40
- * @note `sz` adjusts both dialog padding and text sizes to match the rest of the system tokens.
41
- */
42
- import type { Snippet } from "svelte";
43
- import { type SizeKey } from "./types";
44
- type Props = {
45
- open?: boolean;
46
- title?: string;
47
- message?: string;
48
- onConfirm?: () => void;
49
- onCancel?: () => void;
50
- onClose?: () => void;
51
- modal?: boolean;
52
- class?: string;
53
- sz?: SizeKey;
54
- children?: Snippet<[SizeKey]>;
55
- };
56
- declare const Dialog: import("svelte").Component<Props, {}, "">;
57
- type Dialog = ReturnType<typeof Dialog>;
58
- export default Dialog;