svelte-comp 1.2.2 → 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.

Potentially problematic release.


This version of svelte-comp might be problematic. Click here for more details.

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 -98
  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 -97
  53. package/dist/lib/SearchInput.svelte.d.ts +0 -12
  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 -149
  77. package/dist/lib/lang.js +0 -141
  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,42 +0,0 @@
1
- /**
2
- * @component Switch
3
- * @description A compact toggle switch component built on top of a native `<input type="checkbox">`. Supports optional labels around the control and works naturally with `bind:checked`.
4
- *
5
- * @prop sz {SizeKey} - Size preset for the control
6
- * @options xs|sm|md|lg|xl
7
- * @default md
8
- *
9
- * @prop checked {boolean} - Current state (bindable)
10
- * @default false
11
- *
12
- * @prop leftLabel {string} - Optional label rendered on the left side
13
- *
14
- * @prop rightLabel {string} - Optional label rendered on the right side
15
- *
16
- * @prop topLabel {string} - Optional label placed above the switch
17
- *
18
- * @prop onChange {(v: boolean) => void} - Fired on toggle with the new value
19
- *
20
- * @prop class {string} - External wrapper classes
21
- * @default ""
22
- *
23
- * @note Built over a real checkbox so browser accessibility comes for free: keyboard (Space/Enter), focus ring, and screen reader semantics.
24
- * @note Labels do not affect the actual checkbox hitbox, but the whole area is clickable if wrapped correctly.
25
- * @note Size preset adjusts track width, knob size, and spacing.
26
- * @note Reflects `disabled` by dimming visuals and removing pointer events.
27
- * @note The component keeps no internal state besides the bound `checked` value, so it's predictable in forms and controlled UI.
28
- */
29
- import type { HTMLInputAttributes } from "svelte/elements";
30
- import type { SizeKey } from "./types";
31
- type Props = HTMLInputAttributes & {
32
- sz?: SizeKey;
33
- checked?: boolean;
34
- leftLabel?: string;
35
- rightLabel?: string;
36
- topLabel?: string;
37
- onChange?: (v: boolean) => void;
38
- class?: string;
39
- };
40
- declare const Switch: import("svelte").Component<Props, {}, "checked">;
41
- type Switch = ReturnType<typeof Switch>;
42
- export default Switch;
@@ -1,299 +0,0 @@
1
- <!-- src/lib/Table.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component Table
5
- * @description Sortable table with optional zebra striping, sticky header, and external pagination. Compact variants (`dense`, `list`) shrink horizontally to fit content.
6
- *
7
- * @prop columns {readonly Column<T>[]} - Column definitions with labels and keys
8
- * @default []
9
- *
10
- * @prop rows {readonly T[]} - Row data objects
11
- * @default []
12
- *
13
- * @prop class {string} - Custom classes for the table container
14
- * @default ""
15
- *
16
- * @prop variant {TableVariant} - Visual style variant
17
- * @options default|dense|list|noBorder|noTitle|zebra
18
- * @default default
19
- *
20
- * @prop stickyHeader {boolean} - Makes the header row sticky
21
- * @default false
22
- *
23
- * @prop sz {SizeKey} - Size preset for spacing and text
24
- * @options xs|sm|md|lg|xl
25
- * @default md
26
- *
27
- * @prop pagination {{ currentPage: number; totalPages: number; onPageChange: (p: number) => void }} - External pagination controls
28
- *
29
- * @note Click a column header to toggle ascending or descending.
30
- * @note In `dense` and `list` the table uses content width (`inline-table` + `w-fit`).
31
- * @note Column `width` is applied only in non-compact variants (`default`, `zebra`, `noBorder`, `noTitle`).
32
- * @note `list` hides the header row.
33
- * @note Integrates with `Pagination.svelte` via the `pagination` prop.
34
- * @note Works in dark mode and supports keyboard sorting (Enter or Space on headers).
35
- */
36
- import Pagination from "./Pagination.svelte";
37
- import type {
38
- CellAlign,
39
- Column,
40
- SizeKey,
41
- TableRow,
42
- TableVariant,
43
- } from "./types";
44
- import { TEXT } from "./types";
45
- import { cx } from "../utils";
46
-
47
- type Props<T extends TableRow> = {
48
- columns: readonly Column<T>[];
49
- rows: readonly T[];
50
- class?: string;
51
- variant?: TableVariant;
52
- stickyHeader?: boolean;
53
- sz?: SizeKey;
54
- pagination?: {
55
- currentPage: number;
56
- totalPages: number;
57
- onPageChange: (page: number) => void;
58
- };
59
- };
60
-
61
- let {
62
- columns = [],
63
- rows = [],
64
- class: externalClass = "",
65
- variant = "default",
66
- stickyHeader = false,
67
- sz = "md",
68
- pagination,
69
- }: Props<TableRow> = $props();
70
-
71
- let sortKey = $state<keyof TableRow | null>(null);
72
- let sortDir = $state<"asc" | "desc" | null>(null);
73
-
74
- function toggleSort(col: Column<TableRow>) {
75
- const key = col.key;
76
- if (sortKey !== key) {
77
- sortKey = key;
78
- sortDir = "asc";
79
- } else {
80
- sortDir = sortDir === "asc" ? "desc" : "asc";
81
- }
82
- }
83
-
84
- function cmp(a: unknown, b: unknown): number {
85
- const an = a == null || a === "";
86
- const bn = b == null || b === "";
87
- if (an && bn) return 0;
88
- if (an) return 1;
89
- if (bn) return -1;
90
-
91
- const na = Number(a);
92
- const nb = Number(b);
93
- const aNum = !Number.isNaN(na);
94
- const bNum = !Number.isNaN(nb);
95
-
96
- if (aNum && bNum) return na - nb;
97
-
98
- return String(a).localeCompare(String(b), undefined, {
99
- numeric: true,
100
- sensitivity: "base",
101
- });
102
- }
103
-
104
- const variants = {
105
- default: {
106
- table: "border border-[var(--border-color-default)]",
107
- header:
108
- "bg-[var(--color-bg-secondary)] border border-[var(--border-color-default)]",
109
- body: "",
110
- cell: "border-t border-r last:border-r-0 border-[var(--border-color-default)]",
111
- row: "hover:bg-[var(--color-bg-hover)]",
112
- padY: "py-2",
113
- },
114
- dense: {
115
- table: "border border-[var(--border-color-default)]",
116
- header:
117
- "bg-[var(--color-bg-secondary)] border border-[var(--border-color-default)]",
118
- body: "",
119
- cell: "border-t border-r last:border-r-0 border-[var(--border-color-default)]",
120
- row: "hover:bg-[var(--color-bg-hover)]",
121
- padY: "py-1.5",
122
- },
123
- list: {
124
- table: "border-none",
125
- header: "hidden",
126
- body: "",
127
- cell: "border-none",
128
- row: "hover:bg-[var(--color-bg-hover)]",
129
- padY: "py-1.5",
130
- },
131
- noBorder: {
132
- table: "border-none",
133
- header: "bg-transparent border-none",
134
- body: "",
135
- cell: "border-none",
136
- row: "hover:bg-[var(--color-bg-hover)]",
137
- padY: "py-2",
138
- },
139
- zebra: {
140
- table: "border border-[var(--border-color-default)]",
141
- header:
142
- "bg-[var(--color-bg-secondary)] border border-[var(--border-color-default)]",
143
- body: "",
144
- cell: "border-t border-r last:border-r-0 border-[var(--border-color-default)]",
145
- row: "even:bg-[var(--color-bg-muted)] hover:bg-[var(--color-bg-hover)]",
146
- padY: "py-2",
147
- },
148
- noTitle: {
149
- table: "border border-[var(--border-color-default)]",
150
- header: "hidden",
151
- body: "",
152
- cell: "border-t border-r last:border-r-0 border-[var(--border-color-default)]",
153
- row: "hover:bg-[var(--color-bg-hover)]",
154
- padY: "py-2",
155
- },
156
- };
157
-
158
- const displayRows = $derived.by(() => {
159
- const base = Array.isArray(rows) ? rows : [];
160
- if (!sortKey || !sortDir) return base as TableRow[];
161
- const key = sortKey;
162
- const withIdx = base.map((r, i) => [r as TableRow, i] as const);
163
- withIdx.sort(([r1, i1], [r2, i2]) => {
164
- const res = cmp(r1[key], r2[key]);
165
- if (res !== 0) return sortDir === "asc" ? res : -res;
166
- return i1 - i2;
167
- });
168
- return withIdx.map(([r]) => r);
169
- });
170
-
171
- const alignTd = (a?: CellAlign) =>
172
- a === "end" ? "text-right" : a === "start" ? "text-left" : "text-center";
173
-
174
- const alignTh = (a?: CellAlign) =>
175
- a === "end"
176
- ? "justify-end"
177
- : a === "center"
178
- ? "justify-center"
179
- : "justify-start";
180
-
181
- const wrapperClass = $derived(cx("overflow-x-auto", externalClass));
182
- const tableTextSize = $derived(TEXT[sz]);
183
- const currentVariant = $derived(variant);
184
- const isCompact = $derived(
185
- currentVariant === "list" || currentVariant === "dense"
186
- );
187
- const variantStyles = $derived(variants[currentVariant] ?? variants.default);
188
-
189
- const tableClass = $derived(
190
- cx(
191
- isCompact ? "inline-table w-fit" : "min-w-full",
192
- "border-collapse",
193
- variantStyles.table,
194
- tableTextSize,
195
- "text-[var(--color-text-default)]"
196
- )
197
- );
198
-
199
- const getRowKey = (row: TableRow, idx: number) => {
200
- const candidate =
201
- typeof row.id === "string" || typeof row.id === "number"
202
- ? row.id
203
- : typeof row.key === "string" || typeof row.key === "number"
204
- ? row.key
205
- : idx;
206
- return String(candidate);
207
- };
208
-
209
- const getColumnKey = (col: Column<TableRow>, idx: number) =>
210
- String(col.key ?? idx);
211
- </script>
212
-
213
- <div class={wrapperClass} tabindex="-1">
214
- <table class={tableClass}>
215
- <thead class={variantStyles.header}>
216
- {#if currentVariant !== "noTitle" && currentVariant !== "list"}
217
- <tr class={cx(stickyHeader && "sticky top-0 z-10")}>
218
- {#each columns as col, idx (getColumnKey(col, idx))}
219
- <th
220
- style={!isCompact && col.width ? `width:${col.width}` : undefined}
221
- class={cx(
222
- "px-3 font-semibold",
223
- variantStyles.padY,
224
- alignTd(col.align)
225
- )}
226
- aria-sort={sortKey === col.key
227
- ? sortDir === "asc"
228
- ? "ascending"
229
- : "descending"
230
- : "none"}
231
- scope="col"
232
- >
233
- <button
234
- type="button"
235
- class={cx(
236
- "flex w-full items-center gap-2 select-none hover:bg-[var(--color-bg-hover)] rounded-none px-1 py-0.5 border border-transparent focus-visible:border-[var(--border-color-focus)] focus-visible:ring-2 focus-visible:ring-[var(--border-color-focus)] focus-visible:outline-none",
237
- alignTh(col.align)
238
- )}
239
- onclick={() => toggleSort(col)}
240
- onkeydown={(e) => {
241
- if (e.key === "Enter" || e.key === " ") {
242
- e.preventDefault();
243
- toggleSort(col);
244
- }
245
- }}
246
- aria-label={`Sort by ${col.label}`}
247
- >
248
- <span class={cx("truncate min-w-0", alignTd(col.align))}>
249
- {col.label}
250
- </span>
251
- <svg
252
- class={cx(
253
- "h-4 w-4 opacity-60 transition-transform",
254
- sortKey === col.key && sortDir === "desc" && "rotate-180"
255
- )}
256
- viewBox="0 0 20 20"
257
- aria-hidden="true"
258
- >
259
- <path
260
- d="M5.23 11.77a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 0l4 4a.75.75 0 1 1-1.06 1.06L10 8.31l-3.77 3.46a.75.75 0 0 1-1 0z"
261
- fill="currentColor"
262
- />
263
- </svg>
264
- </button>
265
- </th>
266
- {/each}
267
- </tr>
268
- {/if}
269
- </thead>
270
-
271
- <tbody class={variantStyles.body}>
272
- {#each displayRows as row, rowIdx (getRowKey(row, rowIdx))}
273
- <tr class={cx("first:[&>td]:border-t-0", variantStyles.row)}>
274
- {#each columns as col, idx (getColumnKey(col, idx))}
275
- <td
276
- style={!isCompact && col.width ? `width:${col.width}` : undefined}
277
- class={cx(
278
- "px-3",
279
- variantStyles.padY,
280
- alignTd(col.align),
281
- variantStyles.cell
282
- )}
283
- >
284
- <div class={cx(isCompact && "break-words whitespace-normal")}>
285
- {row[col.key]}
286
- </div>
287
- </td>
288
- {/each}
289
- </tr>
290
- {/each}
291
- </tbody>
292
- </table>
293
-
294
- {#if pagination && pagination.totalPages > 0}
295
- <div class="mt-3 flex justify-between items-center">
296
- <Pagination {...pagination} />
297
- </div>
298
- {/if}
299
- </div>
@@ -1,17 +0,0 @@
1
- import type { Column, SizeKey, TableRow, TableVariant } from "./types";
2
- type Props<T extends TableRow> = {
3
- columns: readonly Column<T>[];
4
- rows: readonly T[];
5
- class?: string;
6
- variant?: TableVariant;
7
- stickyHeader?: boolean;
8
- sz?: SizeKey;
9
- pagination?: {
10
- currentPage: number;
11
- totalPages: number;
12
- onPageChange: (page: number) => void;
13
- };
14
- };
15
- declare const Table: import("svelte").Component<Props<TableRow>, {}, "">;
16
- type Table = ReturnType<typeof Table>;
17
- export default Table;
@@ -1,213 +0,0 @@
1
- <!-- src/lib/Tabs.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component Tabs
5
- * @description A tab navigation component for switching between sections of content.
6
- *
7
- * @prop tabs {TabItem[]} - Array of tab items with `id` and `label`
8
- * @default []
9
- *
10
- * @prop activeTab {string} - The currently active tab id
11
- * @default ""
12
- *
13
- * @prop sz {SizeKey} - Size preset for tabs and content
14
- * @options xs|sm|md|lg|xl
15
- * @default md
16
- *
17
- * @prop variant {TabsVariant} - Visual style of the tabs
18
- * @options default|pills|underline
19
- * @default default
20
- *
21
- * @prop fitted {boolean} - Stretches tabs to fill available width
22
- * @default false
23
- *
24
- * @prop onChange {(tabId: string) => void} - Callback when the active tab changes
25
- *
26
- * @prop class {string} - Custom class for the container
27
- * @default ""
28
- *
29
- * @prop children {Snippet} - Content panel rendered below the tabs
30
- *
31
- * @note Supports multiple visual styles (`default`, `pills`, `underline`).
32
- * @note Fully accessible with keyboard navigation (Arrow keys, Home, End, Enter).
33
- * @note Automatically adapts to container width.
34
- * @note The panel content (`children`) scales visually with the selected tab size.
35
- */
36
- import type { Snippet } from "svelte";
37
- import type { SizeKey, TabsVariant, TabItem } from "./types";
38
- import { TEXT } from "./types";
39
- import { cx } from "../utils";
40
-
41
- type Props = {
42
- tabs?: TabItem[];
43
- activeTab?: string;
44
- sz?: SizeKey;
45
- variant?: TabsVariant;
46
- fitted?: boolean;
47
- onChange?: (tabId: string) => void;
48
- class?: string;
49
- children?: Snippet;
50
- };
51
-
52
- let {
53
- tabs = [],
54
- activeTab = "",
55
- sz = "md",
56
- variant = "default",
57
- fitted = false,
58
- onChange,
59
- class: externalClass = "",
60
- children,
61
- ...rest
62
- }: Props = $props();
63
-
64
- $effect(() => {
65
- if (!activeTab && tabs.length) activeTab = tabs[0].id;
66
- if (activeTab && !tabs.find((t) => t.id === activeTab) && tabs.length) {
67
- activeTab = tabs[0].id;
68
- }
69
- });
70
-
71
- function focusActiveButton() {
72
- if (!activeTab) return;
73
- const btn = document.getElementById(
74
- `tab-${activeTab}`
75
- ) as HTMLButtonElement | null;
76
- btn?.focus();
77
- }
78
-
79
- function handleTabClick(tab: TabItem) {
80
- if (tab.disabled) return;
81
- activeTab = tab.id;
82
- onChange?.(tab.id);
83
- }
84
-
85
- function handleKeyDown(e: KeyboardEvent) {
86
- const enabled = tabs.filter((t) => !t.disabled);
87
- if (!enabled.length) return;
88
-
89
- const idx = Math.max(
90
- 0,
91
- enabled.findIndex((t) => t.id === activeTab)
92
- );
93
- let next = idx;
94
-
95
- if (e.key === "ArrowRight") next = (idx + 1) % enabled.length;
96
- else if (e.key === "ArrowLeft")
97
- next = (idx - 1 + enabled.length) % enabled.length;
98
- else if (e.key === "Home") next = 0;
99
- else if (e.key === "End") next = enabled.length - 1;
100
- else return;
101
-
102
- e.preventDefault();
103
- const nextId = enabled[next].id;
104
- activeTab = nextId;
105
- onChange?.(nextId);
106
- queueMicrotask(focusActiveButton);
107
- }
108
-
109
- const sizes: Record<SizeKey, string> = {
110
- xs: "px-2 py-1",
111
- sm: "px-3 py-1.5",
112
- md: "px-4 py-2",
113
- lg: "px-5 py-2.5",
114
- xl: "px-6 py-3",
115
- };
116
-
117
- const base =
118
- "inline-flex items-center justify-center font-medium transition-colors duration-150 focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-[var(--border-color-focus)] focus-visible:ring-offset-0 focus:outline-none disabled:opacity-[var(--opacity-disabled)] disabled:cursor-not-allowed";
119
-
120
- const variants = $derived({
121
- default: {
122
- base: "border-b-2 border-transparent text-[var(--color-text-muted)]",
123
- active:
124
- "bg-[var(--color-bg-secondary)] !text-[var(--color-text-default)] border-[var(--border-color-strong)]",
125
- hover:
126
- "hover:text-[var(--color-text-default)] hover:bg-[var(--color-bg-muted)]",
127
- },
128
- underline: {
129
- base: "border-b-2 border-transparent text-[var(--color-text-muted)]",
130
- active:
131
- "border-[var(--border-color-focus)] !text-[var(--color-text-default)]",
132
- hover:
133
- "hover:text-[var(--color-text-default)] hover:border-[var(--border-color-strong)]",
134
- },
135
- pills: {
136
- base: "text-[var(--color-text-muted)] border border-transparent font-medium",
137
- active:
138
- "bg-[var(--color-bg-primary)] text-white border-[var(--color-bg-primary)]",
139
- hover:
140
- "hover:bg-[var(--color-bg-secondary)] hover:text-[var(--color-text-default)]",
141
- },
142
- });
143
-
144
- const rootClass = $derived(
145
- cx("w-full self-stretch flex flex-col", TEXT[sz], externalClass)
146
- );
147
-
148
- const tablistClass = $derived(
149
- cx(
150
- "flex w-full flex-nowrap overflow-x-auto whitespace-nowrap relative z-10 bg-[var(--color-bg-surface)]",
151
- TEXT[sz],
152
- variant === "pills" && "gap-1",
153
- variant === "underline" && "gap-6",
154
- fitted ? "justify-between" : "justify-start"
155
- )
156
- );
157
- </script>
158
-
159
- <div class={rootClass} {...rest}>
160
- <div
161
- role="tablist"
162
- tabindex="0"
163
- aria-orientation="horizontal"
164
- class={tablistClass}
165
- onkeydown={handleKeyDown}
166
- onfocus={focusActiveButton}
167
- >
168
- {#each tabs as tab (tab.id)}
169
- <button
170
- id={`tab-${tab.id}`}
171
- type="button"
172
- role="tab"
173
- aria-selected={tab.id === activeTab ? "true" : "false"}
174
- aria-controls={`panel-${tab.id}`}
175
- aria-disabled={tab.disabled ? "true" : "false"}
176
- tabindex={tab.id === activeTab ? 0 : -1}
177
- disabled={tab.disabled}
178
- class={cx(
179
- "relative z-20",
180
- base,
181
- sizes[sz],
182
- TEXT[sz],
183
- fitted ? "basis-0 grow flex-1 min-w-0 text-center" : "shrink-0",
184
- variants[variant]?.base,
185
- tab.id === activeTab
186
- ? variants[variant]?.active
187
- : !tab.disabled
188
- ? variants[variant]?.hover
189
- : ""
190
- )}
191
- onclick={() => handleTabClick(tab)}
192
- onkeydown={(e) => {
193
- if (e.key === "Enter" || e.key === " ") {
194
- e.preventDefault();
195
- handleTabClick(tab);
196
- }
197
- }}
198
- >
199
- <span>{tab.label}</span>
200
- </button>
201
- {/each}
202
- </div>
203
-
204
- <div
205
- id={`panel-${activeTab}`}
206
- role="tabpanel"
207
- tabindex="-1"
208
- aria-labelledby={`tab-${activeTab}`}
209
- class="w-full min-w-0 relative z-0 border-t border-[var(--border-color-default)] bg-[var(--color-bg-surface)] p-[var(--spacing-md)] rounded-b-[var(--radius-sm)] shadow-[0_1px_2px_0_var(--shadow-color)]"
210
- >
211
- {@render children?.()}
212
- </div>
213
- </div>
@@ -1,48 +0,0 @@
1
- /**
2
- * @component Tabs
3
- * @description A tab navigation component for switching between sections of content.
4
- *
5
- * @prop tabs {TabItem[]} - Array of tab items with `id` and `label`
6
- * @default []
7
- *
8
- * @prop activeTab {string} - The currently active tab id
9
- * @default ""
10
- *
11
- * @prop sz {SizeKey} - Size preset for tabs and content
12
- * @options xs|sm|md|lg|xl
13
- * @default md
14
- *
15
- * @prop variant {TabsVariant} - Visual style of the tabs
16
- * @options default|pills|underline
17
- * @default default
18
- *
19
- * @prop fitted {boolean} - Stretches tabs to fill available width
20
- * @default false
21
- *
22
- * @prop onChange {(tabId: string) => void} - Callback when the active tab changes
23
- *
24
- * @prop class {string} - Custom class for the container
25
- * @default ""
26
- *
27
- * @prop children {Snippet} - Content panel rendered below the tabs
28
- *
29
- * @note Supports multiple visual styles (`default`, `pills`, `underline`).
30
- * @note Fully accessible with keyboard navigation (Arrow keys, Home, End, Enter).
31
- * @note Automatically adapts to container width.
32
- * @note The panel content (`children`) scales visually with the selected tab size.
33
- */
34
- import type { Snippet } from "svelte";
35
- import type { SizeKey, TabsVariant, TabItem } from "./types";
36
- type Props = {
37
- tabs?: TabItem[];
38
- activeTab?: string;
39
- sz?: SizeKey;
40
- variant?: TabsVariant;
41
- fitted?: boolean;
42
- onChange?: (tabId: string) => void;
43
- class?: string;
44
- children?: Snippet;
45
- };
46
- declare const Tabs: import("svelte").Component<Props, {}, "">;
47
- type Tabs = ReturnType<typeof Tabs>;
48
- export default Tabs;