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.
Potentially problematic release.
This version of svelte-comp might be problematic. Click here for more details.
- 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,192 +0,0 @@
|
|
|
1
|
-
<!-- src/lib/ProgressCircle.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* @component ProgressCircle
|
|
5
|
-
* @description Circular progress indicator for visualizing completion or load state (0-100). Supports indeterminate mode.
|
|
6
|
-
* @prop value {number} - Current progress value
|
|
7
|
-
* @default 0
|
|
8
|
-
* @prop indeterminate {boolean} - Enables spinning infinite mode
|
|
9
|
-
* @default false
|
|
10
|
-
* @prop size {number} - Diameter in px
|
|
11
|
-
* @default 48
|
|
12
|
-
* @prop stroke {number} - Stroke width in px
|
|
13
|
-
* @default 4
|
|
14
|
-
* @prop variant {ComponentVariant} - Color/style variant
|
|
15
|
-
* @options default|neutral|success|warning|error
|
|
16
|
-
* @default default
|
|
17
|
-
* @prop label {string} - Optional text shown in center
|
|
18
|
-
* @default ""
|
|
19
|
-
* @prop max {number} - Max progress value for normalization
|
|
20
|
-
* @default 100
|
|
21
|
-
* @prop class {string} - Extra wrapper classes
|
|
22
|
-
* @default ""
|
|
23
|
-
* @note Clamps value between 0-max
|
|
24
|
-
* @note Uses SVG stroke-dashoffset animation
|
|
25
|
-
* @note Accessible role=progressbar with aria-valuenow
|
|
26
|
-
* @note Works in both determinate/indeterminate modes
|
|
27
|
-
*/
|
|
28
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
29
|
-
import { type SizeKey, type ComponentVariant, TEXT } from "./types";
|
|
30
|
-
import { cx, clamp } from "../utils";
|
|
31
|
-
|
|
32
|
-
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
33
|
-
value?: number;
|
|
34
|
-
indeterminate?: boolean;
|
|
35
|
-
sz?: SizeKey;
|
|
36
|
-
variant?: ComponentVariant;
|
|
37
|
-
class?: string;
|
|
38
|
-
label?: string;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
let {
|
|
43
|
-
value = 0,
|
|
44
|
-
indeterminate = false,
|
|
45
|
-
sz = "md",
|
|
46
|
-
variant = "default",
|
|
47
|
-
class: externalClass = "",
|
|
48
|
-
label = "",
|
|
49
|
-
disabled = false,
|
|
50
|
-
...rest
|
|
51
|
-
}: Props = $props();
|
|
52
|
-
|
|
53
|
-
const sizes: Record<SizeKey, { diameter: number; stroke: number }> = {
|
|
54
|
-
xs: { diameter: 40, stroke: 4 },
|
|
55
|
-
sm: { diameter: 48, stroke: 5 },
|
|
56
|
-
md: { diameter: 56, stroke: 6 },
|
|
57
|
-
lg: { diameter: 64, stroke: 7 },
|
|
58
|
-
xl: { diameter: 72, stroke: 8 },
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const pctValue = $derived(clamp(value, 0, 100));
|
|
62
|
-
const pctText = $derived(Math.round(pctValue));
|
|
63
|
-
|
|
64
|
-
const geometry = $derived(sizes[sz]);
|
|
65
|
-
const center = $derived(geometry.diameter / 2);
|
|
66
|
-
const radius = $derived(center - geometry.stroke / 2);
|
|
67
|
-
const circumference = $derived(2 * Math.PI * radius);
|
|
68
|
-
|
|
69
|
-
const dashOffset = $derived(((100 - pctValue) / 100) * circumference);
|
|
70
|
-
const dashArray = $derived(`${circumference} ${circumference}`);
|
|
71
|
-
const indeterminateDash = $derived(`${circumference * 0.3} ${circumference}`);
|
|
72
|
-
|
|
73
|
-
const strokeColor = $derived(
|
|
74
|
-
variant === "neutral"
|
|
75
|
-
? "stroke-[var(--color-bg-secondary)]"
|
|
76
|
-
: "stroke-[var(--color-bg-primary)]"
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const rootClass = $derived(
|
|
80
|
-
cx(
|
|
81
|
-
"inline-flex flex-col items-center gap-1 data-[disabled=true]:opacity-[var(--opacity-disabled)] data-[disabled=true]:cursor-not-allowed",
|
|
82
|
-
externalClass
|
|
83
|
-
)
|
|
84
|
-
);
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<div
|
|
88
|
-
class={rootClass}
|
|
89
|
-
role="progressbar"
|
|
90
|
-
aria-valuemin="0"
|
|
91
|
-
aria-valuemax="100"
|
|
92
|
-
aria-valuenow={indeterminate ? undefined : pctText}
|
|
93
|
-
data-disabled={disabled ? "true" : undefined}
|
|
94
|
-
{...rest}
|
|
95
|
-
>
|
|
96
|
-
{#if label}
|
|
97
|
-
<span class={cx("text-[var(--color-text-muted)] select-none", TEXT[sz])}>
|
|
98
|
-
{label}
|
|
99
|
-
</span>
|
|
100
|
-
{/if}
|
|
101
|
-
|
|
102
|
-
<div
|
|
103
|
-
class="relative inline-flex items-center justify-center"
|
|
104
|
-
style={`width:${geometry.diameter}px;height:${geometry.diameter}px;`}
|
|
105
|
-
>
|
|
106
|
-
<svg
|
|
107
|
-
class="pc-svg"
|
|
108
|
-
viewBox={`0 0 ${geometry.diameter} ${geometry.diameter}`}
|
|
109
|
-
role="presentation"
|
|
110
|
-
aria-hidden="true"
|
|
111
|
-
>
|
|
112
|
-
<g class="pc-rot">
|
|
113
|
-
<circle
|
|
114
|
-
class="pc-track"
|
|
115
|
-
cx={center}
|
|
116
|
-
cy={center}
|
|
117
|
-
r={radius}
|
|
118
|
-
stroke-width={geometry.stroke}
|
|
119
|
-
></circle>
|
|
120
|
-
|
|
121
|
-
{#if indeterminate}
|
|
122
|
-
<circle
|
|
123
|
-
class={cx("pc-bar pc-indet", strokeColor)}
|
|
124
|
-
cx={center}
|
|
125
|
-
cy={center}
|
|
126
|
-
r={radius}
|
|
127
|
-
stroke-width={geometry.stroke}
|
|
128
|
-
stroke-dasharray={indeterminateDash}
|
|
129
|
-
></circle>
|
|
130
|
-
{:else}
|
|
131
|
-
<circle
|
|
132
|
-
class={cx("pc-bar", strokeColor)}
|
|
133
|
-
cx={center}
|
|
134
|
-
cy={center}
|
|
135
|
-
r={radius}
|
|
136
|
-
stroke-width={geometry.stroke}
|
|
137
|
-
stroke-dasharray={dashArray}
|
|
138
|
-
stroke-dashoffset={dashOffset}
|
|
139
|
-
></circle>
|
|
140
|
-
{/if}
|
|
141
|
-
</g>
|
|
142
|
-
</svg>
|
|
143
|
-
|
|
144
|
-
{#if !indeterminate}
|
|
145
|
-
<div
|
|
146
|
-
class={cx(
|
|
147
|
-
"absolute inset-0 flex items-center justify-center text-[var(--color-text-muted)] font-medium select-none",
|
|
148
|
-
TEXT[sz]
|
|
149
|
-
)}
|
|
150
|
-
>
|
|
151
|
-
{pctText}%
|
|
152
|
-
</div>
|
|
153
|
-
{/if}
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
|
|
157
|
-
<style>
|
|
158
|
-
.pc-svg {
|
|
159
|
-
width: 100%;
|
|
160
|
-
height: 100%;
|
|
161
|
-
}
|
|
162
|
-
.pc-rot {
|
|
163
|
-
transform: rotate(-90deg);
|
|
164
|
-
transform-origin: center;
|
|
165
|
-
}
|
|
166
|
-
.pc-track {
|
|
167
|
-
fill: none;
|
|
168
|
-
stroke: var(--border-color-default);
|
|
169
|
-
}
|
|
170
|
-
.pc-bar {
|
|
171
|
-
fill: none;
|
|
172
|
-
stroke-linecap: round;
|
|
173
|
-
transition:
|
|
174
|
-
stroke-dashoffset 0.25s ease,
|
|
175
|
-
stroke 0.2s ease;
|
|
176
|
-
transform-origin: center;
|
|
177
|
-
}
|
|
178
|
-
.pc-indet {
|
|
179
|
-
animation: pc-spin 1.2s linear infinite;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
:global {
|
|
183
|
-
@keyframes pc-spin {
|
|
184
|
-
0% {
|
|
185
|
-
transform: rotate(0deg);
|
|
186
|
-
}
|
|
187
|
-
100% {
|
|
188
|
-
transform: rotate(360deg);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
</style>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @component ProgressCircle
|
|
3
|
-
* @description Circular progress indicator for visualizing completion or load state (0-100). Supports indeterminate mode.
|
|
4
|
-
* @prop value {number} - Current progress value
|
|
5
|
-
* @default 0
|
|
6
|
-
* @prop indeterminate {boolean} - Enables spinning infinite mode
|
|
7
|
-
* @default false
|
|
8
|
-
* @prop size {number} - Diameter in px
|
|
9
|
-
* @default 48
|
|
10
|
-
* @prop stroke {number} - Stroke width in px
|
|
11
|
-
* @default 4
|
|
12
|
-
* @prop variant {ComponentVariant} - Color/style variant
|
|
13
|
-
* @options default|neutral|success|warning|error
|
|
14
|
-
* @default default
|
|
15
|
-
* @prop label {string} - Optional text shown in center
|
|
16
|
-
* @default ""
|
|
17
|
-
* @prop max {number} - Max progress value for normalization
|
|
18
|
-
* @default 100
|
|
19
|
-
* @prop class {string} - Extra wrapper classes
|
|
20
|
-
* @default ""
|
|
21
|
-
* @note Clamps value between 0-max
|
|
22
|
-
* @note Uses SVG stroke-dashoffset animation
|
|
23
|
-
* @note Accessible role=progressbar with aria-valuenow
|
|
24
|
-
* @note Works in both determinate/indeterminate modes
|
|
25
|
-
*/
|
|
26
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
27
|
-
import { type SizeKey, type ComponentVariant } from "./types";
|
|
28
|
-
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
29
|
-
value?: number;
|
|
30
|
-
indeterminate?: boolean;
|
|
31
|
-
sz?: SizeKey;
|
|
32
|
-
variant?: ComponentVariant;
|
|
33
|
-
class?: string;
|
|
34
|
-
label?: string;
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
};
|
|
37
|
-
declare const ProgressCircle: import("svelte").Component<Props, {}, "">;
|
|
38
|
-
type ProgressCircle = ReturnType<typeof ProgressCircle>;
|
|
39
|
-
export default ProgressCircle;
|
package/dist/lib/Radio.svelte
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
<!-- src/lib/Radio.svelte -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* @component Radio
|
|
5
|
-
* @description Single choice input with optional label, custom sizing and theme variants.
|
|
6
|
-
*
|
|
7
|
-
* @prop label {string} - Text label shown next to the radio
|
|
8
|
-
*
|
|
9
|
-
* @prop children {Snippet} - Custom label content
|
|
10
|
-
*
|
|
11
|
-
* @prop sz {SizeKey} - Size option
|
|
12
|
-
* @options xs|sm|md|lg|xl
|
|
13
|
-
* @default md
|
|
14
|
-
*
|
|
15
|
-
* @prop variant {ComponentVariant} - Visual style preset
|
|
16
|
-
* @options default|neutral
|
|
17
|
-
* @default default
|
|
18
|
-
*
|
|
19
|
-
* @prop checked {boolean} - Controlled checked state
|
|
20
|
-
* @default false
|
|
21
|
-
*
|
|
22
|
-
* @prop group {unknown} - Native radio group binding (`bind:group`)
|
|
23
|
-
*
|
|
24
|
-
* @prop onChange {(checked: boolean) => void} - Fired when the radio toggles
|
|
25
|
-
*
|
|
26
|
-
* @prop class {string} - Extra classes applied to the root container
|
|
27
|
-
* @default ""
|
|
28
|
-
*
|
|
29
|
-
* @prop describedBy {string} - ID of helper or error text for accessibility
|
|
30
|
-
*
|
|
31
|
-
* @prop value {string} - Radio value
|
|
32
|
-
* @default "on"
|
|
33
|
-
*
|
|
34
|
-
* @note Fully supports native radio grouping through `bind:group`
|
|
35
|
-
* @note Works as a controlled component when `checked` and `onChange` are used together
|
|
36
|
-
* @note `children` takes priority over `label`
|
|
37
|
-
* @note Size and variant affect circle size, dot size and colors
|
|
38
|
-
* @note Hidden native input is focusable and exposes full accessibility attributes
|
|
39
|
-
* @note Uses data-state attributes to enable custom styling
|
|
40
|
-
*/
|
|
41
|
-
import type { Snippet } from "svelte";
|
|
42
|
-
import type { HTMLInputAttributes } from "svelte/elements";
|
|
43
|
-
import { type SizeKey, type ComponentVariant, TEXT } from "./types";
|
|
44
|
-
import { cx, uid } from "../utils";
|
|
45
|
-
|
|
46
|
-
type Props = HTMLInputAttributes & {
|
|
47
|
-
label?: string;
|
|
48
|
-
children?: Snippet;
|
|
49
|
-
sz?: SizeKey;
|
|
50
|
-
variant?: ComponentVariant;
|
|
51
|
-
checked?: boolean;
|
|
52
|
-
group?: unknown;
|
|
53
|
-
onChange?: (checked: boolean) => void;
|
|
54
|
-
class?: string;
|
|
55
|
-
describedBy?: string;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
let {
|
|
59
|
-
label,
|
|
60
|
-
children,
|
|
61
|
-
sz = "md",
|
|
62
|
-
variant = "default",
|
|
63
|
-
checked = $bindable(false),
|
|
64
|
-
group = $bindable<unknown>(undefined),
|
|
65
|
-
onChange,
|
|
66
|
-
class: externalClass = "",
|
|
67
|
-
describedBy,
|
|
68
|
-
value = "on",
|
|
69
|
-
...rest
|
|
70
|
-
}: Props = $props();
|
|
71
|
-
|
|
72
|
-
const inputId = $derived(rest.id ?? uid("rd-"));
|
|
73
|
-
|
|
74
|
-
const sizeClasses = {
|
|
75
|
-
xs: "w-3 h-3",
|
|
76
|
-
sm: "w-3.5 h-3.5",
|
|
77
|
-
md: "w-4 h-4",
|
|
78
|
-
lg: "w-[18px] h-[18px]",
|
|
79
|
-
xl: "w-5 h-5",
|
|
80
|
-
} as const;
|
|
81
|
-
|
|
82
|
-
const dotSizes: Record<SizeKey, string> = {
|
|
83
|
-
xs: "w-1.5 h-1.5",
|
|
84
|
-
sm: "w-2 h-2",
|
|
85
|
-
md: "w-2.5 h-2.5",
|
|
86
|
-
lg: "w-3 h-3",
|
|
87
|
-
xl: "w-3.5 h-3.5",
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const gapBySize: Record<SizeKey, string> = {
|
|
91
|
-
xs: "gap-1.5",
|
|
92
|
-
sm: "gap-2",
|
|
93
|
-
md: "gap-2.5",
|
|
94
|
-
lg: "gap-3",
|
|
95
|
-
xl: "gap-3.5",
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const variants = $derived(
|
|
99
|
-
variant === "neutral"
|
|
100
|
-
? {
|
|
101
|
-
checked: "bg-transparent border-[var(--border-color-strong)]",
|
|
102
|
-
unchecked: "bg-transparent border-[var(--border-color-default)]",
|
|
103
|
-
}
|
|
104
|
-
: {
|
|
105
|
-
checked: "bg-transparent border-[var(--color-bg-primary)]",
|
|
106
|
-
unchecked: "bg-transparent border-[var(--border-color-default)]",
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const baseCircle =
|
|
111
|
-
"rounded-full border border-solid cursor-pointer transition-all duration-[var(--transition-fast)] ease-[var(--timing-default)] flex items-center justify-center";
|
|
112
|
-
|
|
113
|
-
const focusFromPeer =
|
|
114
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--border-color-focus)] peer-focus-visible:border-[var(--border-color-focus)]";
|
|
115
|
-
|
|
116
|
-
const dotColor = $derived(
|
|
117
|
-
variant === "neutral"
|
|
118
|
-
? "bg-[var(--border-color-strong)]"
|
|
119
|
-
: "bg-[var(--color-bg-primary)]"
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
const isUsingGroup = $derived(typeof group !== "undefined");
|
|
123
|
-
const isChecked = $derived(isUsingGroup ? group === value : checked);
|
|
124
|
-
const state = $derived(isChecked ? "checked" : "unchecked");
|
|
125
|
-
|
|
126
|
-
const rootClass = $derived(
|
|
127
|
-
cx(
|
|
128
|
-
"inline-flex items-center cursor-pointer select-none",
|
|
129
|
-
gapBySize[sz],
|
|
130
|
-
externalClass
|
|
131
|
-
)
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const radioClass = $derived(
|
|
135
|
-
cx(
|
|
136
|
-
baseCircle,
|
|
137
|
-
focusFromPeer,
|
|
138
|
-
sizeClasses[sz],
|
|
139
|
-
isChecked && variants.checked,
|
|
140
|
-
!isChecked && variants.unchecked,
|
|
141
|
-
"peer-disabled:opacity-[var(--opacity-disabled)] peer-disabled:cursor-not-allowed"
|
|
142
|
-
)
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
const dotClass = $derived(
|
|
146
|
-
cx(
|
|
147
|
-
"rounded-full transition-transform duration-[var(--transition-fast)] ease-[var(--timing-default)]",
|
|
148
|
-
dotSizes[sz],
|
|
149
|
-
dotColor,
|
|
150
|
-
isChecked ? "scale-100 opacity-100" : "scale-50 opacity-0"
|
|
151
|
-
)
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
const labelClass = $derived(
|
|
155
|
-
cx(
|
|
156
|
-
TEXT[sz],
|
|
157
|
-
"[color:var(--color-text-muted)] font-medium peer-disabled:cursor-not-allowed"
|
|
158
|
-
)
|
|
159
|
-
);
|
|
160
|
-
</script>
|
|
161
|
-
|
|
162
|
-
<label class={rootClass} for={inputId}>
|
|
163
|
-
<input
|
|
164
|
-
id={inputId}
|
|
165
|
-
type="radio"
|
|
166
|
-
{value}
|
|
167
|
-
bind:group
|
|
168
|
-
checked={isChecked}
|
|
169
|
-
{...rest}
|
|
170
|
-
class="sr-only peer"
|
|
171
|
-
aria-checked={isChecked}
|
|
172
|
-
aria-describedby={describedBy}
|
|
173
|
-
onchange={(event) => {
|
|
174
|
-
const next = (event.currentTarget as HTMLInputElement).checked;
|
|
175
|
-
checked = next;
|
|
176
|
-
onChange?.(next);
|
|
177
|
-
}}
|
|
178
|
-
/>
|
|
179
|
-
|
|
180
|
-
<span data-state={state} class={radioClass} aria-hidden="true">
|
|
181
|
-
<span class={dotClass}></span>
|
|
182
|
-
</span>
|
|
183
|
-
|
|
184
|
-
{#if children}
|
|
185
|
-
<span class={labelClass}>{@render children?.()}</span>
|
|
186
|
-
{:else if label}
|
|
187
|
-
<span class={labelClass}>{label}</span>
|
|
188
|
-
{/if}
|
|
189
|
-
</label>
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @component Radio
|
|
3
|
-
* @description Single choice input with optional label, custom sizing and theme variants.
|
|
4
|
-
*
|
|
5
|
-
* @prop label {string} - Text label shown next to the radio
|
|
6
|
-
*
|
|
7
|
-
* @prop children {Snippet} - Custom label content
|
|
8
|
-
*
|
|
9
|
-
* @prop sz {SizeKey} - Size option
|
|
10
|
-
* @options xs|sm|md|lg|xl
|
|
11
|
-
* @default md
|
|
12
|
-
*
|
|
13
|
-
* @prop variant {ComponentVariant} - Visual style preset
|
|
14
|
-
* @options default|neutral
|
|
15
|
-
* @default default
|
|
16
|
-
*
|
|
17
|
-
* @prop checked {boolean} - Controlled checked state
|
|
18
|
-
* @default false
|
|
19
|
-
*
|
|
20
|
-
* @prop group {unknown} - Native radio group binding (`bind:group`)
|
|
21
|
-
*
|
|
22
|
-
* @prop onChange {(checked: boolean) => void} - Fired when the radio toggles
|
|
23
|
-
*
|
|
24
|
-
* @prop class {string} - Extra classes applied to the root container
|
|
25
|
-
* @default ""
|
|
26
|
-
*
|
|
27
|
-
* @prop describedBy {string} - ID of helper or error text for accessibility
|
|
28
|
-
*
|
|
29
|
-
* @prop value {string} - Radio value
|
|
30
|
-
* @default "on"
|
|
31
|
-
*
|
|
32
|
-
* @note Fully supports native radio grouping through `bind:group`
|
|
33
|
-
* @note Works as a controlled component when `checked` and `onChange` are used together
|
|
34
|
-
* @note `children` takes priority over `label`
|
|
35
|
-
* @note Size and variant affect circle size, dot size and colors
|
|
36
|
-
* @note Hidden native input is focusable and exposes full accessibility attributes
|
|
37
|
-
* @note Uses data-state attributes to enable custom styling
|
|
38
|
-
*/
|
|
39
|
-
import type { Snippet } from "svelte";
|
|
40
|
-
import type { HTMLInputAttributes } from "svelte/elements";
|
|
41
|
-
import { type SizeKey, type ComponentVariant } from "./types";
|
|
42
|
-
type Props = HTMLInputAttributes & {
|
|
43
|
-
label?: string;
|
|
44
|
-
children?: Snippet;
|
|
45
|
-
sz?: SizeKey;
|
|
46
|
-
variant?: ComponentVariant;
|
|
47
|
-
checked?: boolean;
|
|
48
|
-
group?: unknown;
|
|
49
|
-
onChange?: (checked: boolean) => void;
|
|
50
|
-
class?: string;
|
|
51
|
-
describedBy?: string;
|
|
52
|
-
};
|
|
53
|
-
declare const Radio: import("svelte").Component<Props, {}, "group" | "checked">;
|
|
54
|
-
type Radio = ReturnType<typeof Radio>;
|
|
55
|
-
export default Radio;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* @component SearchInput
|
|
4
|
-
* @description Search input field with a leading search icon.
|
|
5
|
-
*
|
|
6
|
-
* @prop label {string} - Label text rendered above the field
|
|
7
|
-
*
|
|
8
|
-
* @prop placeholder {string} - Placeholder text (localized by default)
|
|
9
|
-
*
|
|
10
|
-
* @prop value {string} - Controlled field value (bindable)
|
|
11
|
-
* @default ""
|
|
12
|
-
*
|
|
13
|
-
* @prop sz {SizeKey} - Size preset for spacing and typography
|
|
14
|
-
* @options xs|sm|md|lg|xl
|
|
15
|
-
* @default sm
|
|
16
|
-
*
|
|
17
|
-
* @prop variant {FieldVariant} - Visual style variant
|
|
18
|
-
* @options default|filled|neutral
|
|
19
|
-
* @default filled
|
|
20
|
-
*
|
|
21
|
-
* @prop class {string} - Additional classes applied to the Field root
|
|
22
|
-
* @default ""
|
|
23
|
-
*
|
|
24
|
-
* @note Renders a leading search icon and uses `Field` with `type="search"` and `clearable`.
|
|
25
|
-
*/
|
|
26
|
-
import { getContext } from "svelte";
|
|
27
|
-
import Field from "./Field.svelte";
|
|
28
|
-
import type { FieldVariant, SizeKey } from "./types";
|
|
29
|
-
import { TEXTS } from "./lang";
|
|
30
|
-
|
|
31
|
-
type Props = {
|
|
32
|
-
label?: string;
|
|
33
|
-
placeholder?: string;
|
|
34
|
-
value?: string;
|
|
35
|
-
sz?: SizeKey;
|
|
36
|
-
variant?: FieldVariant;
|
|
37
|
-
class?: string;
|
|
38
|
-
[key: string]: unknown;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
let {
|
|
42
|
-
label,
|
|
43
|
-
placeholder,
|
|
44
|
-
value = $bindable(''),
|
|
45
|
-
sz = 'sm',
|
|
46
|
-
variant = 'filled',
|
|
47
|
-
class: externalClass = '',
|
|
48
|
-
...rest
|
|
49
|
-
}: Props = $props();
|
|
50
|
-
|
|
51
|
-
const langCtx =
|
|
52
|
-
getContext<{ value: keyof typeof TEXTS } | undefined>("lang") ?? null;
|
|
53
|
-
const langKey = $derived(langCtx?.value ?? "en");
|
|
54
|
-
const L = $derived(TEXTS[langKey].components.searchInput);
|
|
55
|
-
|
|
56
|
-
const placeholderFinal = $derived(placeholder ?? L.placeholder);
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
{#snippet leading()}
|
|
60
|
-
<span class="ml-1 inline-flex h-6 w-6 items-center justify-center text-[var(--color-text-muted)]">
|
|
61
|
-
<svg
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
width="20"
|
|
64
|
-
height="20"
|
|
65
|
-
viewBox="0 0 24 24"
|
|
66
|
-
fill="none"
|
|
67
|
-
stroke="currentColor"
|
|
68
|
-
stroke-width="2"
|
|
69
|
-
stroke-linecap="round"
|
|
70
|
-
stroke-linejoin="round"
|
|
71
|
-
class="lucide lucide-search-icon lucide-search"
|
|
72
|
-
>
|
|
73
|
-
<path d="m21 21-4.34-4.34" />
|
|
74
|
-
<circle cx="11" cy="11" r="8" />
|
|
75
|
-
</svg>
|
|
76
|
-
</span>
|
|
77
|
-
{/snippet}
|
|
78
|
-
|
|
79
|
-
<Field
|
|
80
|
-
{label}
|
|
81
|
-
bind:value
|
|
82
|
-
{sz}
|
|
83
|
-
{variant}
|
|
84
|
-
type="search"
|
|
85
|
-
clearable={true}
|
|
86
|
-
{leading}
|
|
87
|
-
placeholder={placeholderFinal}
|
|
88
|
-
class={`search-input w-full max-w-[520px] [&_input]:pl-10 ${externalClass}`}
|
|
89
|
-
{...rest}
|
|
90
|
-
/>
|
|
91
|
-
|
|
92
|
-
<style>
|
|
93
|
-
:global(.search-input input[type="search"]) {
|
|
94
|
-
-webkit-appearance: none;
|
|
95
|
-
appearance: none;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
:global(.search-input input[type="search"]::-webkit-search-cancel-button),
|
|
99
|
-
:global(.search-input input[type="search"]::-webkit-search-decoration),
|
|
100
|
-
:global(.search-input input[type="search"]::-webkit-search-results-button),
|
|
101
|
-
:global(.search-input input[type="search"]::-webkit-search-results-decoration) {
|
|
102
|
-
-webkit-appearance: none;
|
|
103
|
-
appearance: none;
|
|
104
|
-
display: none;
|
|
105
|
-
}
|
|
106
|
-
</style>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FieldVariant, SizeKey } from "./types";
|
|
2
|
-
type Props = {
|
|
3
|
-
label?: string;
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
value?: string;
|
|
6
|
-
sz?: SizeKey;
|
|
7
|
-
variant?: FieldVariant;
|
|
8
|
-
class?: string;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
};
|
|
11
|
-
declare const SearchInput: import("svelte").Component<Props, {}, "value">;
|
|
12
|
-
type SearchInput = ReturnType<typeof SearchInput>;
|
|
13
|
-
export default SearchInput;
|