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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/dist/App.svelte +0 -551
- package/dist/App.svelte.d.ts +0 -3
- package/dist/Container.svelte +0 -60
- package/dist/Container.svelte.d.ts +0 -12
- package/dist/app.css +0 -235
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -6
- package/dist/lang.d.ts +0 -1081
- package/dist/lang.js +0 -1096
- package/dist/lib/Accordion.svelte +0 -155
- package/dist/lib/Accordion.svelte.d.ts +0 -40
- package/dist/lib/Button.svelte +0 -170
- package/dist/lib/Button.svelte.d.ts +0 -53
- package/dist/lib/Card.svelte +0 -103
- package/dist/lib/Card.svelte.d.ts +0 -42
- package/dist/lib/Carousel.svelte +0 -293
- package/dist/lib/Carousel.svelte.d.ts +0 -13
- package/dist/lib/CheckBox.svelte +0 -210
- package/dist/lib/CheckBox.svelte.d.ts +0 -53
- package/dist/lib/CodeView.svelte +0 -307
- package/dist/lib/CodeView.svelte.d.ts +0 -64
- package/dist/lib/ColorPicker.svelte +0 -161
- package/dist/lib/ColorPicker.svelte.d.ts +0 -40
- package/dist/lib/DatePicker.svelte +0 -170
- package/dist/lib/DatePicker.svelte.d.ts +0 -53
- package/dist/lib/Dialog.svelte +0 -235
- package/dist/lib/Dialog.svelte.d.ts +0 -58
- package/dist/lib/Field.svelte +0 -299
- package/dist/lib/Field.svelte.d.ts +0 -8
- package/dist/lib/FilePicker.svelte +0 -241
- package/dist/lib/FilePicker.svelte.d.ts +0 -52
- package/dist/lib/Form.svelte +0 -438
- package/dist/lib/Form.svelte.d.ts +0 -20
- package/dist/lib/Hamburger.svelte +0 -211
- package/dist/lib/Hamburger.svelte.d.ts +0 -52
- package/dist/lib/Menu.svelte +0 -623
- package/dist/lib/Menu.svelte.d.ts +0 -33
- package/dist/lib/PaginatedCard.svelte +0 -73
- package/dist/lib/PaginatedCard.svelte.d.ts +0 -11
- package/dist/lib/Pagination.svelte +0 -119
- package/dist/lib/Pagination.svelte.d.ts +0 -9
- package/dist/lib/PrimaryColorSelect.svelte +0 -113
- package/dist/lib/PrimaryColorSelect.svelte.d.ts +0 -9
- package/dist/lib/ProgressBar.svelte +0 -141
- package/dist/lib/ProgressBar.svelte.d.ts +0 -48
- package/dist/lib/ProgressCircle.svelte +0 -192
- package/dist/lib/ProgressCircle.svelte.d.ts +0 -39
- package/dist/lib/Radio.svelte +0 -189
- package/dist/lib/Radio.svelte.d.ts +0 -55
- package/dist/lib/SearchInput.svelte +0 -106
- package/dist/lib/SearchInput.svelte.d.ts +0 -13
- package/dist/lib/Select.svelte +0 -524
- package/dist/lib/Select.svelte.d.ts +0 -21
- package/dist/lib/Slider.svelte +0 -253
- package/dist/lib/Slider.svelte.d.ts +0 -56
- package/dist/lib/Splitter.svelte +0 -150
- package/dist/lib/Splitter.svelte.d.ts +0 -43
- package/dist/lib/Switch.svelte +0 -167
- package/dist/lib/Switch.svelte.d.ts +0 -42
- package/dist/lib/Table.svelte +0 -299
- package/dist/lib/Table.svelte.d.ts +0 -17
- package/dist/lib/Tabs.svelte +0 -213
- package/dist/lib/Tabs.svelte.d.ts +0 -48
- package/dist/lib/ThemeToggle.svelte +0 -127
- package/dist/lib/ThemeToggle.svelte.d.ts +0 -32
- package/dist/lib/TimePicker.svelte +0 -269
- package/dist/lib/TimePicker.svelte.d.ts +0 -48
- package/dist/lib/Toast.svelte +0 -226
- package/dist/lib/Toast.svelte.d.ts +0 -14
- package/dist/lib/Tooltip.svelte +0 -110
- package/dist/lib/Tooltip.svelte.d.ts +0 -40
- package/dist/lib/index.d.ts +0 -32
- package/dist/lib/index.js +0 -33
- package/dist/lib/lang.d.ts +0 -158
- package/dist/lib/lang.js +0 -150
- package/dist/lib/types/index.d.ts +0 -111
- package/dist/lib/types/index.js +0 -26
- package/dist/main.d.ts +0 -3
- package/dist/main.js +0 -7
- package/dist/styles.css +0 -232
- package/dist/utils/index.d.ts +0 -34
- package/dist/utils/index.js +0 -268
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
<!-- src/lib/Accordion.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* @component Accordion
|
|
5
|
-
* @description Collapsible content container with flexible sizing and optional multi-open behavior.
|
|
6
|
-
*
|
|
7
|
-
* @prop items {AccordionItem[]} - Array of sections `{ id?, title, content }`
|
|
8
|
-
* @default []
|
|
9
|
-
*
|
|
10
|
-
* @prop multiple {boolean} - Allow more than one section to be open at the same time
|
|
11
|
-
* @default false
|
|
12
|
-
*
|
|
13
|
-
* @prop defaultOpen {number[]} - Indexes of initially opened sections
|
|
14
|
-
* @default []
|
|
15
|
-
*
|
|
16
|
-
* @prop onToggle {(index: number, open: boolean) => void} - Callback fired when a section is toggled
|
|
17
|
-
*
|
|
18
|
-
* @prop sz {SizeKey} - Size variant
|
|
19
|
-
* @options xs|sm|md|lg|xl
|
|
20
|
-
* @default md
|
|
21
|
-
*
|
|
22
|
-
* @prop class {string} - Additional classes for the outer container
|
|
23
|
-
* @default ""
|
|
24
|
-
*
|
|
25
|
-
* @note Smooth expand/collapse via CSS grid transitions
|
|
26
|
-
* @note Accessible triggers (button + aria-expanded)
|
|
27
|
-
* @note For full ARIA compliance, pair triggers with aria-controls and hide collapsed panels using aria-hidden or inert
|
|
28
|
-
* @note State is index-based; reordering items will change which panels start open
|
|
29
|
-
* @note AccordionItem.content is a plain string; wrap HTML inside the string or fork the component if you need custom nodes
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
import { type AccordionItem, type SizeKey, TEXT } from "./types";
|
|
33
|
-
import { cx } from "../utils";
|
|
34
|
-
|
|
35
|
-
type Props = {
|
|
36
|
-
items?: AccordionItem[];
|
|
37
|
-
multiple?: boolean;
|
|
38
|
-
defaultOpen?: number[];
|
|
39
|
-
onToggle?: (index: number, open: boolean) => void;
|
|
40
|
-
sz?: SizeKey;
|
|
41
|
-
class?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
let {
|
|
45
|
-
items = [],
|
|
46
|
-
multiple = false,
|
|
47
|
-
defaultOpen = [],
|
|
48
|
-
onToggle,
|
|
49
|
-
sz = "md",
|
|
50
|
-
class: externalClass = "",
|
|
51
|
-
}: Props = $props();
|
|
52
|
-
|
|
53
|
-
const base =
|
|
54
|
-
"w-full border border-[var(--border-color-default)] bg-[var(--color-bg-surface)] shadow-sm";
|
|
55
|
-
|
|
56
|
-
const sizes: Record<SizeKey, string> = {
|
|
57
|
-
xs: "rounded-[var(--radius-md)] text-sm",
|
|
58
|
-
sm: "rounded-[var(--radius-md)] text-base",
|
|
59
|
-
md: "rounded-[var(--radius-lg)] text-lg",
|
|
60
|
-
lg: "rounded-[var(--radius-lg)] text-xl",
|
|
61
|
-
xl: "rounded-[var(--radius-xl)] text-2xl",
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const contentSize: Record<SizeKey, string> = {
|
|
65
|
-
xs: "px-4 pb-4 mt-1",
|
|
66
|
-
sm: "px-5 pb-5 mt-2",
|
|
67
|
-
md: "px-6 pb-6 mt-3",
|
|
68
|
-
lg: "px-8 pb-8 mt-4",
|
|
69
|
-
xl: "px-10 pb-10 mt-5",
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const iconSize: Record<SizeKey, string> = {
|
|
73
|
-
xs: "w-3 h-3",
|
|
74
|
-
sm: "w-3.5 h-3.5",
|
|
75
|
-
md: "w-4 h-4",
|
|
76
|
-
lg: "w-[18px] h-[18px]",
|
|
77
|
-
xl: "w-5 h-5",
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const componentClass = $derived(cx(base, sizes[sz], externalClass));
|
|
81
|
-
|
|
82
|
-
const iconClass = $derived(iconSize[sz]);
|
|
83
|
-
|
|
84
|
-
const contentClass = $derived(cx(contentSize[sz], TEXT[sz]));
|
|
85
|
-
|
|
86
|
-
let open = $derived(defaultOpen);
|
|
87
|
-
|
|
88
|
-
const isOpen = (i: number) => open.includes(i);
|
|
89
|
-
|
|
90
|
-
const toggle = (i: number) => {
|
|
91
|
-
const opened = isOpen(i);
|
|
92
|
-
open = multiple
|
|
93
|
-
? opened
|
|
94
|
-
? open.filter((x) => x !== i)
|
|
95
|
-
: [...open, i]
|
|
96
|
-
: opened
|
|
97
|
-
? []
|
|
98
|
-
: [i];
|
|
99
|
-
onToggle?.(i, !opened);
|
|
100
|
-
};
|
|
101
|
-
</script>
|
|
102
|
-
|
|
103
|
-
<div class={componentClass}>
|
|
104
|
-
{#each items as item, i (item.id ?? i)}
|
|
105
|
-
<section
|
|
106
|
-
class="group border-b border-[var(--border-color-default)] last:border-b-0 overflow-hidden"
|
|
107
|
-
class:first-of-type:rounded-t={items.length > 1}
|
|
108
|
-
class:last-of-type:rounded-b={items.length > 1}
|
|
109
|
-
>
|
|
110
|
-
<h3>
|
|
111
|
-
<button
|
|
112
|
-
type="button"
|
|
113
|
-
class="flex w-full items-center justify-between gap-3 p-2 text-left font-medium text-[var(--color-text-default)] bg-transparent transition-colors hover:bg-[var(--color-bg-hover)] active:bg-[var(--color-bg-active)] focus:outline-none focus:ring-2 focus:ring-[var(--border-color-focus)] focus:ring-inset"
|
|
114
|
-
aria-expanded={isOpen(i)}
|
|
115
|
-
onclick={() => toggle(i)}
|
|
116
|
-
>
|
|
117
|
-
<span>{item.title}</span>
|
|
118
|
-
<svg
|
|
119
|
-
class={cx(
|
|
120
|
-
"shrink-0 transition-transform duration-200 text-[var(--color-text-muted)]",
|
|
121
|
-
iconClass
|
|
122
|
-
)}
|
|
123
|
-
class:rotate-180={isOpen(i)}
|
|
124
|
-
viewBox="0 0 20 20"
|
|
125
|
-
fill="currentColor"
|
|
126
|
-
aria-hidden="true"
|
|
127
|
-
>
|
|
128
|
-
<path
|
|
129
|
-
fill-rule="evenodd"
|
|
130
|
-
d="M5.23 7.21a.75.75 0 011.06.02L10 11.135l3.71-3.904a.75.75 0 111.08 1.04l-4.24 4.46a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z"
|
|
131
|
-
clip-rule="evenodd"
|
|
132
|
-
/>
|
|
133
|
-
</svg>
|
|
134
|
-
</button>
|
|
135
|
-
</h3>
|
|
136
|
-
|
|
137
|
-
<div
|
|
138
|
-
class="grid overflow-hidden transition-[grid-template-rows] duration-200"
|
|
139
|
-
class:grid-rows-[1fr]={isOpen(i)}
|
|
140
|
-
class:grid-rows-[0fr]={!isOpen(i)}
|
|
141
|
-
>
|
|
142
|
-
<div class="min-h-0">
|
|
143
|
-
<div
|
|
144
|
-
class={cx(
|
|
145
|
-
"leading-relaxed text-[var(--color-text-default)]",
|
|
146
|
-
contentClass
|
|
147
|
-
)}
|
|
148
|
-
>
|
|
149
|
-
{item.content}
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
</section>
|
|
154
|
-
{/each}
|
|
155
|
-
</div>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @component Accordion
|
|
3
|
-
* @description Collapsible content container with flexible sizing and optional multi-open behavior.
|
|
4
|
-
*
|
|
5
|
-
* @prop items {AccordionItem[]} - Array of sections `{ id?, title, content }`
|
|
6
|
-
* @default []
|
|
7
|
-
*
|
|
8
|
-
* @prop multiple {boolean} - Allow more than one section to be open at the same time
|
|
9
|
-
* @default false
|
|
10
|
-
*
|
|
11
|
-
* @prop defaultOpen {number[]} - Indexes of initially opened sections
|
|
12
|
-
* @default []
|
|
13
|
-
*
|
|
14
|
-
* @prop onToggle {(index: number, open: boolean) => void} - Callback fired when a section is toggled
|
|
15
|
-
*
|
|
16
|
-
* @prop sz {SizeKey} - Size variant
|
|
17
|
-
* @options xs|sm|md|lg|xl
|
|
18
|
-
* @default md
|
|
19
|
-
*
|
|
20
|
-
* @prop class {string} - Additional classes for the outer container
|
|
21
|
-
* @default ""
|
|
22
|
-
*
|
|
23
|
-
* @note Smooth expand/collapse via CSS grid transitions
|
|
24
|
-
* @note Accessible triggers (button + aria-expanded)
|
|
25
|
-
* @note For full ARIA compliance, pair triggers with aria-controls and hide collapsed panels using aria-hidden or inert
|
|
26
|
-
* @note State is index-based; reordering items will change which panels start open
|
|
27
|
-
* @note AccordionItem.content is a plain string; wrap HTML inside the string or fork the component if you need custom nodes
|
|
28
|
-
*/
|
|
29
|
-
import { type AccordionItem, type SizeKey } from "./types";
|
|
30
|
-
type Props = {
|
|
31
|
-
items?: AccordionItem[];
|
|
32
|
-
multiple?: boolean;
|
|
33
|
-
defaultOpen?: number[];
|
|
34
|
-
onToggle?: (index: number, open: boolean) => void;
|
|
35
|
-
sz?: SizeKey;
|
|
36
|
-
class?: string;
|
|
37
|
-
};
|
|
38
|
-
declare const Accordion: import("svelte").Component<Props, {}, "">;
|
|
39
|
-
type Accordion = ReturnType<typeof Accordion>;
|
|
40
|
-
export default Accordion;
|
package/dist/lib/Button.svelte
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
<!-- src/lib/Button.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* @component Button
|
|
5
|
-
* @description Versatile button supporting multiple variants, sizes, loading state, and link behavior.
|
|
6
|
-
*
|
|
7
|
-
* @prop disabled {boolean} - Disables interaction
|
|
8
|
-
* @default false
|
|
9
|
-
*
|
|
10
|
-
* @prop children {Snippet} - Content rendered inside the button
|
|
11
|
-
*
|
|
12
|
-
* @prop onClick {(e: MouseEvent) => void} - Click handler
|
|
13
|
-
*
|
|
14
|
-
* @prop sz {SizeKey} - Button size variant
|
|
15
|
-
* @options xs|sm|md|lg|xl
|
|
16
|
-
* @default md
|
|
17
|
-
*
|
|
18
|
-
* @prop variant {ButtonVariant} - Visual style preset
|
|
19
|
-
* @options primary|secondary|pill|danger|success|warning|ghost|link|info
|
|
20
|
-
* @default primary
|
|
21
|
-
*
|
|
22
|
-
* @prop type {"button" | "submit" | "reset"} - Button type attribute
|
|
23
|
-
* @default "button"
|
|
24
|
-
*
|
|
25
|
-
* @prop loaded {boolean} - Shows loading spinner and blocks clicks
|
|
26
|
-
* @default false
|
|
27
|
-
*
|
|
28
|
-
* @prop link {string} - Navigates to a URL when clicked
|
|
29
|
-
*
|
|
30
|
-
* @prop class {string} - Additional classes for the button
|
|
31
|
-
* @default ""
|
|
32
|
-
*
|
|
33
|
-
* @note `disabled` and `loaded` both prevent click events.
|
|
34
|
-
* @note Automatically shows a centered spinner when `loaded` is `true`.
|
|
35
|
-
* @note Link navigation supports `target` and `rel` attributes.
|
|
36
|
-
* @note Accessible with `aria-disabled` and `aria-busy` states.
|
|
37
|
-
* @note The component uses CSS variables for colors, spacing, and transitions.
|
|
38
|
-
*/
|
|
39
|
-
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
40
|
-
import type { Snippet } from "svelte";
|
|
41
|
-
import { type SizeKey, type ButtonVariant, TEXT } from "./types";
|
|
42
|
-
import { cx } from "../utils";
|
|
43
|
-
|
|
44
|
-
type Props = HTMLButtonAttributes & {
|
|
45
|
-
disabled?: boolean;
|
|
46
|
-
children?: Snippet;
|
|
47
|
-
onClick?: (e: MouseEvent) => void;
|
|
48
|
-
sz?: SizeKey;
|
|
49
|
-
variant?: ButtonVariant;
|
|
50
|
-
type?: "button" | "submit" | "reset";
|
|
51
|
-
loaded?: boolean;
|
|
52
|
-
link?: string;
|
|
53
|
-
class?: string;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
let {
|
|
57
|
-
disabled,
|
|
58
|
-
children,
|
|
59
|
-
onClick,
|
|
60
|
-
sz = "md",
|
|
61
|
-
variant = "primary",
|
|
62
|
-
type = "button",
|
|
63
|
-
loaded = false,
|
|
64
|
-
link,
|
|
65
|
-
class: externalClass = "",
|
|
66
|
-
...rest
|
|
67
|
-
}: Props = $props();
|
|
68
|
-
|
|
69
|
-
const base = `
|
|
70
|
-
relative inline-flex items-center justify-center gap-2 rounded-[var(--radius-md)] border font-medium
|
|
71
|
-
transition-all duration-[var(--transition-fast)] ease-[var(--timing-default)] whitespace-nowrap select-none
|
|
72
|
-
focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--border-color-focus)]
|
|
73
|
-
disabled:opacity-[var(--opacity-disabled)]
|
|
74
|
-
disabled:cursor-not-allowed
|
|
75
|
-
disabled:brightness-100
|
|
76
|
-
disabled:active:scale-100
|
|
77
|
-
disabled:hover:brightness-100
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
const sizes: Record<SizeKey, string> = {
|
|
81
|
-
xs: "px-2 py-0.5 h-6",
|
|
82
|
-
sm: "px-3 py-1 h-7",
|
|
83
|
-
md: "px-4 py-2 h-8",
|
|
84
|
-
lg: "px-5 py-2.5 h-9",
|
|
85
|
-
xl: "px-6 py-3 h-10",
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const variants: Record<ButtonVariant, string> = {
|
|
89
|
-
primary:
|
|
90
|
-
"bg-[var(--color-bg-primary)] text-white border-[var(--border-color-primary)] hover:brightness-110 active:scale-95",
|
|
91
|
-
secondary:
|
|
92
|
-
"bg-[var(--color-bg-secondary)] [color:var(--color-text-default)] border-[var(--border-color-default)] hover:bg-[var(--color-bg-hover)] active:scale-95",
|
|
93
|
-
pill: "bg-[var(--color-bg-primary)] text-white border-[var(--border-color-primary)] rounded-full hover:brightness-110 active:scale-95",
|
|
94
|
-
danger:
|
|
95
|
-
"bg-[var(--color-bg-danger)] text-white border-[var(--color-bg-danger)] hover:brightness-110 active:scale-95",
|
|
96
|
-
success:
|
|
97
|
-
"bg-[var(--color-bg-success)] text-white border-[var(--color-bg-success)] hover:brightness-110 active:scale-95",
|
|
98
|
-
warning:
|
|
99
|
-
"bg-[var(--color-bg-warning)] text-white border-[var(--color-bg-warning)] hover:brightness-110 active:scale-95",
|
|
100
|
-
ghost:
|
|
101
|
-
"bg-transparent [color:var(--color-text-default)] border-transparent hover:bg-[var(--color-bg-hover)] active:bg-[var(--color-bg-active)] active:scale-95",
|
|
102
|
-
link: "bg-transparent underline border-transparent [color:var(--color-text-link)] hover:brightness-110 active:scale-95 transition-transform ",
|
|
103
|
-
info: "bg-[var(--color-bg-secondary)] text-white border-[var(--border-color-default)] hover:bg-[var(--color-bg-hover)] active:scale-95",
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const buttonClass = $derived(
|
|
107
|
-
cx(base, sizes[sz], TEXT[sz], variants[variant], externalClass)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const state = $derived(loaded ? "loading" : disabled ? "disabled" : "idle");
|
|
111
|
-
|
|
112
|
-
function handleClick(e: MouseEvent) {
|
|
113
|
-
if (disabled || loaded) {
|
|
114
|
-
e.preventDefault();
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (type === "submit" || type === "reset") {
|
|
119
|
-
onClick?.(e);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
onClick?.(e);
|
|
124
|
-
if (!link || e.defaultPrevented) return;
|
|
125
|
-
|
|
126
|
-
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
navigateToLink();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function navigateToLink() {
|
|
134
|
-
if (!link || typeof window === "undefined") return;
|
|
135
|
-
|
|
136
|
-
const restAttrs = rest as Record<string, unknown>;
|
|
137
|
-
const target =
|
|
138
|
-
typeof restAttrs.target === "string" ? restAttrs.target : undefined;
|
|
139
|
-
|
|
140
|
-
if (target === "_blank") {
|
|
141
|
-
window.open(link, "_blank", "noopener,noreferrer");
|
|
142
|
-
} else {
|
|
143
|
-
window.location.assign(link);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
</script>
|
|
147
|
-
|
|
148
|
-
<button
|
|
149
|
-
{type}
|
|
150
|
-
{disabled}
|
|
151
|
-
data-state={state}
|
|
152
|
-
aria-disabled={disabled || loaded || undefined}
|
|
153
|
-
aria-busy={loaded || undefined}
|
|
154
|
-
onclick={handleClick}
|
|
155
|
-
class={buttonClass}
|
|
156
|
-
{...rest}
|
|
157
|
-
>
|
|
158
|
-
<span class={cx({ "opacity-0 pointer-events-none": loaded })}>
|
|
159
|
-
{@render children?.()}
|
|
160
|
-
</span>
|
|
161
|
-
|
|
162
|
-
{#if loaded}
|
|
163
|
-
<span
|
|
164
|
-
class={cx(
|
|
165
|
-
"absolute inset-0 m-auto w-[1em] h-[1em] border-2 [border-color:var(--color-spinner,currentColor)] border-r-transparent rounded-full motion-safe:[animation:spin_0.6s_linear_infinite]"
|
|
166
|
-
)}
|
|
167
|
-
aria-hidden="true"
|
|
168
|
-
></span>
|
|
169
|
-
{/if}
|
|
170
|
-
</button>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @component Button
|
|
3
|
-
* @description Versatile button supporting multiple variants, sizes, loading state, and link behavior.
|
|
4
|
-
*
|
|
5
|
-
* @prop disabled {boolean} - Disables interaction
|
|
6
|
-
* @default false
|
|
7
|
-
*
|
|
8
|
-
* @prop children {Snippet} - Content rendered inside the button
|
|
9
|
-
*
|
|
10
|
-
* @prop onClick {(e: MouseEvent) => void} - Click handler
|
|
11
|
-
*
|
|
12
|
-
* @prop sz {SizeKey} - Button size variant
|
|
13
|
-
* @options xs|sm|md|lg|xl
|
|
14
|
-
* @default md
|
|
15
|
-
*
|
|
16
|
-
* @prop variant {ButtonVariant} - Visual style preset
|
|
17
|
-
* @options primary|secondary|pill|danger|success|warning|ghost|link|info
|
|
18
|
-
* @default primary
|
|
19
|
-
*
|
|
20
|
-
* @prop type {"button" | "submit" | "reset"} - Button type attribute
|
|
21
|
-
* @default "button"
|
|
22
|
-
*
|
|
23
|
-
* @prop loaded {boolean} - Shows loading spinner and blocks clicks
|
|
24
|
-
* @default false
|
|
25
|
-
*
|
|
26
|
-
* @prop link {string} - Navigates to a URL when clicked
|
|
27
|
-
*
|
|
28
|
-
* @prop class {string} - Additional classes for the button
|
|
29
|
-
* @default ""
|
|
30
|
-
*
|
|
31
|
-
* @note `disabled` and `loaded` both prevent click events.
|
|
32
|
-
* @note Automatically shows a centered spinner when `loaded` is `true`.
|
|
33
|
-
* @note Link navigation supports `target` and `rel` attributes.
|
|
34
|
-
* @note Accessible with `aria-disabled` and `aria-busy` states.
|
|
35
|
-
* @note The component uses CSS variables for colors, spacing, and transitions.
|
|
36
|
-
*/
|
|
37
|
-
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
38
|
-
import type { Snippet } from "svelte";
|
|
39
|
-
import { type SizeKey, type ButtonVariant } from "./types";
|
|
40
|
-
type Props = HTMLButtonAttributes & {
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
children?: Snippet;
|
|
43
|
-
onClick?: (e: MouseEvent) => void;
|
|
44
|
-
sz?: SizeKey;
|
|
45
|
-
variant?: ButtonVariant;
|
|
46
|
-
type?: "button" | "submit" | "reset";
|
|
47
|
-
loaded?: boolean;
|
|
48
|
-
link?: string;
|
|
49
|
-
class?: string;
|
|
50
|
-
};
|
|
51
|
-
declare const Button: import("svelte").Component<Props, {}, "">;
|
|
52
|
-
type Button = ReturnType<typeof Button>;
|
|
53
|
-
export default Button;
|
package/dist/lib/Card.svelte
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
<!-- src/lib/Card.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* @component Card
|
|
5
|
-
* @description Flexible layout component with optional `header` and `footer` sections. Supports predefined size variants (xs to xl) through the `sz` prop.
|
|
6
|
-
*
|
|
7
|
-
* @prop header {Snippet} - Content rendered in the card header
|
|
8
|
-
*
|
|
9
|
-
* @prop footer {Snippet} - Content rendered in the card footer
|
|
10
|
-
*
|
|
11
|
-
* @prop children {Snippet} - Main body content of the card
|
|
12
|
-
*
|
|
13
|
-
* @prop class {string} - Additional CSS classes for the card
|
|
14
|
-
* @default ""
|
|
15
|
-
*
|
|
16
|
-
* @prop sz {SizeKey} - Padding and typography preset
|
|
17
|
-
* @options xs|sm|md|lg|xl
|
|
18
|
-
* @default md
|
|
19
|
-
*
|
|
20
|
-
* @prop flushHeader {boolean} - Removes padding and border from the header
|
|
21
|
-
* @default false
|
|
22
|
-
*
|
|
23
|
-
* @prop flushFooter {boolean} - Removes padding and border from the footer
|
|
24
|
-
* @default false
|
|
25
|
-
*
|
|
26
|
-
* @note Theme-aware: uses CSS variables (`--color-bg-surface`, `--border-color-default`).
|
|
27
|
-
* @note Rounded corners, subtle shadow, and border for a clean visual hierarchy.
|
|
28
|
-
* @note Padding and typography scale automatically with `sz`.
|
|
29
|
-
* @note Uses `{@render}` snippets instead of legacy `slots`.
|
|
30
|
-
*/
|
|
31
|
-
import type { Snippet } from "svelte";
|
|
32
|
-
import { type SizeKey, TEXT } from "./types";
|
|
33
|
-
import { cx } from "../utils";
|
|
34
|
-
|
|
35
|
-
type Props = {
|
|
36
|
-
header?: Snippet;
|
|
37
|
-
footer?: Snippet;
|
|
38
|
-
children?: Snippet;
|
|
39
|
-
class?: string;
|
|
40
|
-
sz?: SizeKey;
|
|
41
|
-
flushHeader?: boolean;
|
|
42
|
-
flushFooter?: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
let {
|
|
46
|
-
header,
|
|
47
|
-
footer,
|
|
48
|
-
children,
|
|
49
|
-
class: externalClass = "",
|
|
50
|
-
sz = "md",
|
|
51
|
-
flushHeader = false,
|
|
52
|
-
flushFooter = false,
|
|
53
|
-
}: Props = $props();
|
|
54
|
-
|
|
55
|
-
const paddingSizes: Record<SizeKey, string> = {
|
|
56
|
-
xs: "px-3 py-2",
|
|
57
|
-
sm: "px-4 py-2",
|
|
58
|
-
md: "px-5 py-3",
|
|
59
|
-
lg: "px-6 py-4",
|
|
60
|
-
xl: "px-7 py-5",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const cardClass = $derived(
|
|
64
|
-
cx(
|
|
65
|
-
"bg-[var(--color-bg-surface)] border border-[var(--border-color-default)] rounded-xl shadow-sm overflow-hidden",
|
|
66
|
-
TEXT[sz],
|
|
67
|
-
"flex flex-col",
|
|
68
|
-
externalClass
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const headerClass = $derived(
|
|
73
|
-
flushHeader
|
|
74
|
-
? ""
|
|
75
|
-
: cx("border-b border-[var(--border-color-default)]", paddingSizes[sz])
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const contentClass = $derived(cx(paddingSizes[sz], "flex-1 min-h-0"));
|
|
79
|
-
|
|
80
|
-
const footerClass = $derived(
|
|
81
|
-
flushFooter
|
|
82
|
-
? ""
|
|
83
|
-
: cx("border-t border-[var(--border-color-default)]", paddingSizes[sz])
|
|
84
|
-
);
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<div class={cardClass}>
|
|
88
|
-
{#if header}
|
|
89
|
-
<div class={headerClass}>
|
|
90
|
-
{@render header?.()}
|
|
91
|
-
</div>
|
|
92
|
-
{/if}
|
|
93
|
-
|
|
94
|
-
<div class={contentClass}>
|
|
95
|
-
{@render children?.()}
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
{#if footer}
|
|
99
|
-
<div class={footerClass}>
|
|
100
|
-
{@render footer?.()}
|
|
101
|
-
</div>
|
|
102
|
-
{/if}
|
|
103
|
-
</div>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @component Card
|
|
3
|
-
* @description Flexible layout component with optional `header` and `footer` sections. Supports predefined size variants (xs to xl) through the `sz` prop.
|
|
4
|
-
*
|
|
5
|
-
* @prop header {Snippet} - Content rendered in the card header
|
|
6
|
-
*
|
|
7
|
-
* @prop footer {Snippet} - Content rendered in the card footer
|
|
8
|
-
*
|
|
9
|
-
* @prop children {Snippet} - Main body content of the card
|
|
10
|
-
*
|
|
11
|
-
* @prop class {string} - Additional CSS classes for the card
|
|
12
|
-
* @default ""
|
|
13
|
-
*
|
|
14
|
-
* @prop sz {SizeKey} - Padding and typography preset
|
|
15
|
-
* @options xs|sm|md|lg|xl
|
|
16
|
-
* @default md
|
|
17
|
-
*
|
|
18
|
-
* @prop flushHeader {boolean} - Removes padding and border from the header
|
|
19
|
-
* @default false
|
|
20
|
-
*
|
|
21
|
-
* @prop flushFooter {boolean} - Removes padding and border from the footer
|
|
22
|
-
* @default false
|
|
23
|
-
*
|
|
24
|
-
* @note Theme-aware: uses CSS variables (`--color-bg-surface`, `--border-color-default`).
|
|
25
|
-
* @note Rounded corners, subtle shadow, and border for a clean visual hierarchy.
|
|
26
|
-
* @note Padding and typography scale automatically with `sz`.
|
|
27
|
-
* @note Uses `{@render}` snippets instead of legacy `slots`.
|
|
28
|
-
*/
|
|
29
|
-
import type { Snippet } from "svelte";
|
|
30
|
-
import { type SizeKey } from "./types";
|
|
31
|
-
type Props = {
|
|
32
|
-
header?: Snippet;
|
|
33
|
-
footer?: Snippet;
|
|
34
|
-
children?: Snippet;
|
|
35
|
-
class?: string;
|
|
36
|
-
sz?: SizeKey;
|
|
37
|
-
flushHeader?: boolean;
|
|
38
|
-
flushFooter?: boolean;
|
|
39
|
-
};
|
|
40
|
-
declare const Card: import("svelte").Component<Props, {}, "">;
|
|
41
|
-
type Card = ReturnType<typeof Card>;
|
|
42
|
-
export default Card;
|