@spaethtech/svelte-ui 0.1.10 → 0.3.0
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 +166 -42
- package/dist/components/Alert.svelte +119 -0
- package/dist/components/Alert.svelte.d.ts +29 -0
- package/dist/components/Badge/Badge.svelte +142 -69
- package/dist/components/Badge/Badge.svelte.d.ts +26 -6
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Banner.svelte +133 -0
- package/dist/components/Banner.svelte.d.ts +31 -0
- package/dist/components/Button.svelte +240 -0
- package/dist/components/Button.svelte.d.ts +33 -0
- package/dist/components/ButtonDropdown.svelte +145 -0
- package/dist/components/ButtonDropdown.svelte.d.ts +31 -0
- package/dist/components/Calendar.svelte +259 -0
- package/dist/components/Calendar.svelte.d.ts +27 -0
- package/dist/components/Card.svelte +78 -0
- package/dist/components/Card.svelte.d.ts +17 -0
- package/dist/components/CardBody.svelte +41 -0
- package/dist/components/CardBody.svelte.d.ts +17 -0
- package/dist/components/CardFooter.svelte +49 -0
- package/dist/components/CardFooter.svelte.d.ts +16 -0
- package/dist/components/CardHeader.svelte +49 -0
- package/dist/components/CardHeader.svelte.d.ts +16 -0
- package/dist/components/Checkbox.svelte +131 -0
- package/dist/components/Checkbox.svelte.d.ts +16 -0
- package/dist/components/DataTable.svelte +518 -0
- package/dist/components/DataTable.svelte.d.ts +74 -0
- package/dist/components/DatePicker.svelte +312 -0
- package/dist/components/DatePicker.svelte.d.ts +32 -0
- package/dist/components/DateTimeInput.svelte +93 -0
- package/dist/components/DateTimeInput.svelte.d.ts +20 -0
- package/dist/components/Dialog.svelte +132 -0
- package/dist/components/Dialog.svelte.d.ts +24 -0
- package/dist/components/{EmailInput/EmailInput.svelte → EmailInput.svelte} +17 -8
- package/dist/components/EmailInput.svelte.d.ts +21 -0
- package/dist/components/Input.svelte +369 -0
- package/dist/components/Input.svelte.d.ts +35 -0
- package/dist/components/{List/List.svelte → List.svelte} +194 -133
- package/dist/components/{List/List.svelte.d.ts → List.svelte.d.ts} +9 -1
- package/dist/components/Menu.svelte +117 -0
- package/dist/components/Menu.svelte.d.ts +20 -0
- package/dist/components/NotesEditor.svelte +127 -0
- package/dist/components/NotesEditor.svelte.d.ts +17 -0
- package/dist/components/{NumberInput/NumberInput.svelte → NumberInput.svelte} +146 -105
- package/dist/components/{NumberInput/NumberInput.svelte.d.ts → NumberInput.svelte.d.ts} +11 -4
- package/dist/components/PasswordInput.svelte +52 -0
- package/dist/components/PasswordInput.svelte.d.ts +20 -0
- package/dist/components/Popup.svelte +140 -0
- package/dist/components/Popup.svelte.d.ts +31 -0
- package/dist/components/Query.svelte +284 -0
- package/dist/components/Query.svelte.d.ts +15 -0
- package/dist/components/{Rating/Rating.svelte → Rating.svelte} +19 -10
- package/dist/components/Rating.svelte.d.ts +13 -0
- package/dist/components/{SearchInput/SearchInput.svelte → SearchInput.svelte} +19 -8
- package/dist/components/{SearchInput/SearchInput.svelte.d.ts → SearchInput.svelte.d.ts} +9 -2
- package/dist/components/{Select/Select.svelte → Select.svelte} +48 -76
- package/dist/components/{Select/Select.svelte.d.ts → Select.svelte.d.ts} +11 -1
- package/dist/components/SideBarMenu/SideBarMenu.svelte +724 -0
- package/dist/components/SideBarMenu/SideBarMenu.svelte.d.ts +109 -0
- package/dist/components/SideBarMenu/index.d.ts +2 -0
- package/dist/components/SideBarMenu/index.js +1 -0
- package/dist/components/TabStrip/TabStrip.svelte +384 -0
- package/dist/components/TabStrip/TabStrip.svelte.d.ts +50 -0
- package/dist/components/TabStrip/index.d.ts +3 -0
- package/dist/components/TabStrip/index.js +2 -0
- package/dist/components/{TextArea/TextArea.svelte → TextArea.svelte} +143 -112
- package/dist/components/TextArea.svelte.d.ts +38 -0
- package/dist/components/ThemeSelector.svelte +81 -0
- package/dist/components/ThemeSelector.svelte.d.ts +10 -0
- package/dist/components/TimePicker.svelte +148 -0
- package/dist/components/TimePicker.svelte.d.ts +28 -0
- package/dist/components/TimeRangeInput.svelte +203 -0
- package/dist/components/TimeRangeInput.svelte.d.ts +29 -0
- package/dist/components/TimeSpinner.svelte +202 -0
- package/dist/components/TimeSpinner.svelte.d.ts +26 -0
- package/dist/components/Toast/Toaster.svelte +51 -0
- package/dist/components/Toast/Toaster.svelte.d.ts +12 -0
- package/dist/components/Toast/toast.svelte.d.ts +29 -0
- package/dist/components/Toast/toast.svelte.js +27 -0
- package/dist/components/Toggle.svelte +93 -0
- package/dist/components/Toggle.svelte.d.ts +15 -0
- package/dist/data/dataset.d.ts +42 -0
- package/dist/data/dataset.js +3 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.js +3 -0
- package/dist/data/query/ast.d.ts +62 -0
- package/dist/data/query/ast.js +12 -0
- package/dist/data/query/index.d.ts +3 -0
- package/dist/data/query/index.js +3 -0
- package/dist/data/query/lexer.d.ts +33 -0
- package/dist/data/query/lexer.js +225 -0
- package/dist/data/query/parser.d.ts +11 -0
- package/dist/data/query/parser.js +252 -0
- package/dist/data/table/grid.svelte.d.ts +57 -0
- package/dist/data/table/grid.svelte.js +139 -0
- package/dist/data/table/index.d.ts +2 -0
- package/dist/data/table/index.js +2 -0
- package/dist/data/table/types.d.ts +79 -0
- package/dist/index.d.ts +48 -22
- package/dist/index.js +45 -21
- package/dist/positioning/anchored.d.ts +61 -0
- package/dist/positioning/anchored.js +122 -0
- package/dist/positioning/tooltip.d.ts +41 -0
- package/dist/positioning/tooltip.js +147 -0
- package/dist/theme.css +205 -0
- package/dist/types/breakpoints.d.ts +24 -0
- package/dist/types/breakpoints.js +13 -0
- package/dist/types/responsive.d.ts +32 -0
- package/dist/types/responsive.js +54 -0
- package/dist/types/sizes.d.ts +10 -3
- package/dist/types/time.d.ts +19 -0
- package/dist/types/time.js +10 -0
- package/dist/types/variants.d.ts +8 -1
- package/dist/types/variants.js +16 -1
- package/package.json +93 -63
- package/dist/components/Button/Button.svelte +0 -172
- package/dist/components/Button/Button.svelte.d.ts +0 -32
- package/dist/components/Button/index.d.ts +0 -1
- package/dist/components/Button/index.js +0 -1
- package/dist/components/Dialog/Dialog.svelte +0 -101
- package/dist/components/Dialog/Dialog.svelte.d.ts +0 -18
- package/dist/components/Dialog/index.d.ts +0 -1
- package/dist/components/Dialog/index.js +0 -1
- package/dist/components/ElementManager/ElementManager.svelte +0 -397
- package/dist/components/ElementManager/ElementManager.svelte.d.ts +0 -43
- package/dist/components/ElementManager/index.d.ts +0 -1
- package/dist/components/ElementManager/index.js +0 -1
- package/dist/components/EmailInput/EmailInput.svelte.d.ts +0 -14
- package/dist/components/EmailInput/index.d.ts +0 -1
- package/dist/components/EmailInput/index.js +0 -1
- package/dist/components/Icon/Icon.svelte +0 -74
- package/dist/components/Icon/Icon.svelte.d.ts +0 -13
- package/dist/components/Icon/index.d.ts +0 -1
- package/dist/components/Icon/index.js +0 -1
- package/dist/components/Input/Input.svelte +0 -268
- package/dist/components/Input/Input.svelte.d.ts +0 -18
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Input/index.js +0 -1
- package/dist/components/List/index.d.ts +0 -1
- package/dist/components/List/index.js +0 -1
- package/dist/components/ListItem/ListItem.svelte +0 -175
- package/dist/components/ListItem/ListItem.svelte.d.ts +0 -24
- package/dist/components/ListItem/index.d.ts +0 -2
- package/dist/components/ListItem/index.js +0 -2
- package/dist/components/ListView/ListView.svelte +0 -463
- package/dist/components/ListView/ListView.svelte.d.ts +0 -37
- package/dist/components/ListView/index.d.ts +0 -2
- package/dist/components/ListView/index.js +0 -2
- package/dist/components/NodeGraph/BaseNode.d.ts +0 -57
- package/dist/components/NodeGraph/BaseNode.js +0 -30
- package/dist/components/NodeGraph/Edge.svelte +0 -60
- package/dist/components/NodeGraph/Edge.svelte.d.ts +0 -16
- package/dist/components/NodeGraph/ExpressionEvaluator.d.ts +0 -82
- package/dist/components/NodeGraph/ExpressionEvaluator.js +0 -152
- package/dist/components/NodeGraph/Node.svelte +0 -100
- package/dist/components/NodeGraph/Node.svelte.d.ts +0 -10
- package/dist/components/NodeGraph/NodeGraph.svelte +0 -52
- package/dist/components/NodeGraph/NodeGraph.svelte.d.ts +0 -14
- package/dist/components/NodeGraph/NodeInstance.svelte.d.ts +0 -80
- package/dist/components/NodeGraph/NodeInstance.svelte.js +0 -241
- package/dist/components/NodeGraph/NodePort.svelte +0 -75
- package/dist/components/NodeGraph/NodePort.svelte.d.ts +0 -11
- package/dist/components/NodeGraph/decorators.d.ts +0 -81
- package/dist/components/NodeGraph/decorators.js +0 -148
- package/dist/components/NodeGraph/index.d.ts +0 -9
- package/dist/components/NodeGraph/index.js +0 -9
- package/dist/components/NodeGraph/types.d.ts +0 -94
- package/dist/components/NodeGraph/types.js +0 -33
- package/dist/components/NotesEditor/NotesEditor.svelte +0 -203
- package/dist/components/NotesEditor/NotesEditor.svelte.d.ts +0 -9
- package/dist/components/NotesEditor/index.d.ts +0 -1
- package/dist/components/NotesEditor/index.js +0 -1
- package/dist/components/NumberInput/index.d.ts +0 -1
- package/dist/components/NumberInput/index.js +0 -1
- package/dist/components/PasswordInput/PasswordInput.svelte +0 -41
- package/dist/components/PasswordInput/PasswordInput.svelte.d.ts +0 -13
- package/dist/components/PasswordInput/index.d.ts +0 -1
- package/dist/components/PasswordInput/index.js +0 -1
- package/dist/components/Popup/index.d.ts +0 -1
- package/dist/components/Popup/index.js +0 -1
- package/dist/components/Rating/Rating.svelte.d.ts +0 -7
- package/dist/components/Rating/index.d.ts +0 -1
- package/dist/components/Rating/index.js +0 -1
- package/dist/components/ScrollView/ScrollView.svelte +0 -285
- package/dist/components/ScrollView/ScrollView.svelte.d.ts +0 -19
- package/dist/components/ScrollView/index.d.ts +0 -1
- package/dist/components/ScrollView/index.js +0 -1
- package/dist/components/SearchInput/index.d.ts +0 -1
- package/dist/components/SearchInput/index.js +0 -1
- package/dist/components/Select/index.d.ts +0 -1
- package/dist/components/Select/index.js +0 -1
- package/dist/components/TextArea/TextArea.svelte.d.ts +0 -19
- package/dist/components/TextArea/index.d.ts +0 -1
- package/dist/components/TextArea/index.js +0 -1
- package/dist/components/ThemeSelector/ThemeSelector.svelte +0 -64
- package/dist/components/ThemeSelector/ThemeSelector.svelte.d.ts +0 -3
- package/dist/components/ThemeSelector/index.d.ts +0 -1
- package/dist/components/ThemeSelector/index.js +0 -1
- package/dist/components/TooltipHandler/TooltipHandler.svelte +0 -593
- package/dist/components/TooltipHandler/TooltipHandler.svelte.d.ts +0 -10
- package/dist/components/TooltipHandler/index.d.ts +0 -1
- package/dist/components/TooltipHandler/index.js +0 -1
- package/dist/styles/sizes.d.ts +0 -78
- package/dist/styles/sizes.js +0 -120
- package/dist/styles/variants.d.ts +0 -106
- package/dist/styles/variants.js +0 -194
- package/dist/types/ManagerTypes.d.ts +0 -42
- /package/dist/{types/ManagerTypes.js → data/table/types.js} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive breakpoint tiers — the single source of truth for any
|
|
3
|
+
* component that accepts per-tier configuration (modes, columns,
|
|
4
|
+
* visibility, etc.). Keys match the tier names defined in
|
|
5
|
+
* `theme.css`, with `base` for the unconditional "no min-width" case.
|
|
6
|
+
*
|
|
7
|
+
* Pixel widths are exposed alongside the type so JS-driven mode
|
|
8
|
+
* resolution (via matchMedia) can stay in sync with the CSS without
|
|
9
|
+
* a second source of truth.
|
|
10
|
+
*
|
|
11
|
+
* - `base` → 0 px (no min-width — the unconditional fallback)
|
|
12
|
+
* - `4xs` → 320 px (iPhone SE class)
|
|
13
|
+
* - `3xs` → 360 px (narrow Android)
|
|
14
|
+
* - `2xs` → 420 px (standard phone)
|
|
15
|
+
* - `xs` → 480 px (large phone / small tablet portrait)
|
|
16
|
+
* - `sm` → 640 px (Tailwind default)
|
|
17
|
+
* - `md` → 768 px (Tailwind default)
|
|
18
|
+
* - `lg` → 1024 px (Tailwind default)
|
|
19
|
+
* - `xl` → 1280 px (Tailwind default)
|
|
20
|
+
* - `2xl` → 1536 px (Tailwind default)
|
|
21
|
+
* - `3xl` → 1920 px (FHD / 1080p ultrawide)
|
|
22
|
+
*/
|
|
23
|
+
export type Breakpoint = "base" | "4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
|
|
24
|
+
export declare const BREAKPOINT_PX: Record<Breakpoint, number>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Breakpoint } from "./breakpoints.js";
|
|
2
|
+
/**
|
|
3
|
+
* A value that is either a single `T` (applied at every width) OR a per-breakpoint map.
|
|
4
|
+
* Mobile-first: `base` (or a bare `T`) is the unconditional value; each larger tier present in the
|
|
5
|
+
* map overrides from its min-width upward. Mirrors the DataTable column `breakpoints` shape so the
|
|
6
|
+
* whole library speaks one responsive language.
|
|
7
|
+
*
|
|
8
|
+
* size="lg" // always lg
|
|
9
|
+
* size={{ base: 'lg', xs: 'md' }} // lg on phones, md at >=480px
|
|
10
|
+
*/
|
|
11
|
+
export type Responsive<T extends string> = T | Partial<Record<Breakpoint, T>>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a `Responsive<T>` into a Tailwind class string, given a per-value class map.
|
|
14
|
+
*
|
|
15
|
+
* - Scalar `T` → the map entry verbatim (today's behaviour, zero overhead).
|
|
16
|
+
* - Map → the `base` entry unprefixed, then each higher tier's entry with its `bp:` prefix applied
|
|
17
|
+
* to EVERY class token (`'h-8 px-4'` at `xs` → `'xs:h-8 xs:px-4'`). Emitted low→high min-width so
|
|
18
|
+
* the CSS cascade lands on the active tier. Works for arbitrary/variant tokens too — the prefix
|
|
19
|
+
* sits in front of the whole chain (`xs:[&_svg]:w-4`, `xs:[background-color:var(--x)]`).
|
|
20
|
+
*
|
|
21
|
+
* The generated `bp:`-prefixed classes are runtime strings Tailwind can't see by scanning source —
|
|
22
|
+
* they are safelisted via `@source inline` in `theme.css` (see the `-- responsive size/variant --`
|
|
23
|
+
* block there); consuming apps inherit it through `@import 'svelte-ui/theme.css'`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function responsiveClasses<T extends string>(value: Responsive<T> | undefined, map: Record<T, string>): string;
|
|
26
|
+
/**
|
|
27
|
+
* Collapse a `Responsive<T>` to a single scalar — for the rare bits driven by JS/inline-style rather
|
|
28
|
+
* than a class (e.g. a numeric line-height for autosize math, or a CSS-var set via `style=`). Scalar
|
|
29
|
+
* passes through; a map yields its `base` tier (or `fallback`). Those aspects therefore track the
|
|
30
|
+
* mobile-first tier only — the CLASS-driven visuals still respond at every breakpoint.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveScalar<T extends string>(value: Responsive<T> | undefined, fallback: T): T;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BREAKPOINT_PX } from "./breakpoints.js";
|
|
2
|
+
/** Breakpoints ascending by min-width — so prefixed rules emit in cascade order (larger wins). */
|
|
3
|
+
const ASCENDING = Object.keys(BREAKPOINT_PX).sort((a, b) => BREAKPOINT_PX[a] - BREAKPOINT_PX[b]);
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a `Responsive<T>` into a Tailwind class string, given a per-value class map.
|
|
6
|
+
*
|
|
7
|
+
* - Scalar `T` → the map entry verbatim (today's behaviour, zero overhead).
|
|
8
|
+
* - Map → the `base` entry unprefixed, then each higher tier's entry with its `bp:` prefix applied
|
|
9
|
+
* to EVERY class token (`'h-8 px-4'` at `xs` → `'xs:h-8 xs:px-4'`). Emitted low→high min-width so
|
|
10
|
+
* the CSS cascade lands on the active tier. Works for arbitrary/variant tokens too — the prefix
|
|
11
|
+
* sits in front of the whole chain (`xs:[&_svg]:w-4`, `xs:[background-color:var(--x)]`).
|
|
12
|
+
*
|
|
13
|
+
* The generated `bp:`-prefixed classes are runtime strings Tailwind can't see by scanning source —
|
|
14
|
+
* they are safelisted via `@source inline` in `theme.css` (see the `-- responsive size/variant --`
|
|
15
|
+
* block there); consuming apps inherit it through `@import 'svelte-ui/theme.css'`.
|
|
16
|
+
*/
|
|
17
|
+
export function responsiveClasses(value, map) {
|
|
18
|
+
if (value == null)
|
|
19
|
+
return "";
|
|
20
|
+
if (typeof value === "string")
|
|
21
|
+
return map[value] ?? "";
|
|
22
|
+
let out = "";
|
|
23
|
+
for (const bp of ASCENDING) {
|
|
24
|
+
const tier = value[bp];
|
|
25
|
+
if (tier == null)
|
|
26
|
+
continue;
|
|
27
|
+
const cls = map[tier];
|
|
28
|
+
if (!cls)
|
|
29
|
+
continue;
|
|
30
|
+
out += out ? " " : "";
|
|
31
|
+
out +=
|
|
32
|
+
bp === "base"
|
|
33
|
+
? cls
|
|
34
|
+
: cls
|
|
35
|
+
.trim()
|
|
36
|
+
.split(/\s+/)
|
|
37
|
+
.map((t) => `${bp}:${t}`)
|
|
38
|
+
.join(" ");
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Collapse a `Responsive<T>` to a single scalar — for the rare bits driven by JS/inline-style rather
|
|
44
|
+
* than a class (e.g. a numeric line-height for autosize math, or a CSS-var set via `style=`). Scalar
|
|
45
|
+
* passes through; a map yields its `base` tier (or `fallback`). Those aspects therefore track the
|
|
46
|
+
* mobile-first tier only — the CLASS-driven visuals still respond at every breakpoint.
|
|
47
|
+
*/
|
|
48
|
+
export function resolveScalar(value, fallback) {
|
|
49
|
+
if (value == null)
|
|
50
|
+
return fallback;
|
|
51
|
+
if (typeof value === "string")
|
|
52
|
+
return value;
|
|
53
|
+
return value.base ?? fallback;
|
|
54
|
+
}
|
package/dist/types/sizes.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Shared sizing axis — the cross-cutting counterpart to {@link ./variants.ts | Variant}.
|
|
3
|
+
* Every sizeable component (Button, Input, Select, …) accepts `size` and maps it to a consistent
|
|
4
|
+
* control height / text / padding / icon scale. Default is always `md` (today's look).
|
|
5
|
+
*
|
|
6
|
+
* - `sm` → 24px (`--ui-height-sm`) · dense: table chrome, inline controls
|
|
7
|
+
* - `md` → 32px (`--ui-height`) · default
|
|
8
|
+
* - `lg` → 40px (`--ui-height-lg`) · prominent (0.75× / 1.0× / 1.25× around md)
|
|
9
|
+
*
|
|
10
|
+
* `--ui-height-touch` (44px) is a separate token for explicit touch targets — not `lg`.
|
|
4
11
|
*/
|
|
5
|
-
export type Size =
|
|
12
|
+
export type Size = "sm" | "md" | "lg";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step interval for the time spinner columns. A bare number is shorthand for the MINUTE step (the
|
|
3
|
+
* common case); an object sets any column independently. Unspecified columns default to 1.
|
|
4
|
+
*
|
|
5
|
+
* step={15} // minutes step by 15 (hours/seconds by 1)
|
|
6
|
+
* step={{ minute: 15, second: 30 }} // minutes by 15, seconds by 30
|
|
7
|
+
* step={{ hour: 2 }} // hours by 2
|
|
8
|
+
*/
|
|
9
|
+
export type StepSpec = number | {
|
|
10
|
+
hour?: number;
|
|
11
|
+
minute?: number;
|
|
12
|
+
second?: number;
|
|
13
|
+
};
|
|
14
|
+
/** Resolve a {@link StepSpec} to a per-column `{ hour, minute, second }` (each ≥ 1). */
|
|
15
|
+
export declare function resolveStep(step: StepSpec | undefined): {
|
|
16
|
+
hour: number;
|
|
17
|
+
minute: number;
|
|
18
|
+
second: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Resolve a {@link StepSpec} to a per-column `{ hour, minute, second }` (each ≥ 1). */
|
|
2
|
+
export function resolveStep(step) {
|
|
3
|
+
if (typeof step === "number")
|
|
4
|
+
return { hour: 1, minute: Math.max(1, step), second: 1 };
|
|
5
|
+
return {
|
|
6
|
+
hour: Math.max(1, step?.hour ?? 1),
|
|
7
|
+
minute: Math.max(1, step?.minute ?? 1),
|
|
8
|
+
second: Math.max(1, step?.second ?? 1),
|
|
9
|
+
};
|
|
10
|
+
}
|
package/dist/types/variants.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export type Variant =
|
|
1
|
+
export type Variant = "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | "danger" | "ghost";
|
|
2
|
+
/** Variant → semantic colour token, used where a variant needs an ACCENT colour (Toggle track,
|
|
3
|
+
* Checkbox, Card border, DataTable accent…). `danger` maps to `--ui-color-error`. The two non-accent
|
|
4
|
+
* variants — `ghost` (transparent, hover-tint only) and `neutral` (text-mix surface tint, = the
|
|
5
|
+
* default DataTable look) — resolve to `--ui-color-text`, so those controls read grey/uncoloured
|
|
6
|
+
* rather than borrowing an accent. The interactive tints (hover/surface/active) are text-mixes by
|
|
7
|
+
* default and re-mix off whichever colour this points at. */
|
|
8
|
+
export declare const variantToken: Record<Variant, string>;
|
package/dist/types/variants.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/** Variant → semantic colour token, used where a variant needs an ACCENT colour (Toggle track,
|
|
2
|
+
* Checkbox, Card border, DataTable accent…). `danger` maps to `--ui-color-error`. The two non-accent
|
|
3
|
+
* variants — `ghost` (transparent, hover-tint only) and `neutral` (text-mix surface tint, = the
|
|
4
|
+
* default DataTable look) — resolve to `--ui-color-text`, so those controls read grey/uncoloured
|
|
5
|
+
* rather than borrowing an accent. The interactive tints (hover/surface/active) are text-mixes by
|
|
6
|
+
* default and re-mix off whichever colour this points at. */
|
|
7
|
+
export const variantToken = {
|
|
8
|
+
neutral: "--ui-color-text",
|
|
9
|
+
primary: "--ui-color-primary",
|
|
10
|
+
secondary: "--ui-color-secondary",
|
|
11
|
+
success: "--ui-color-success",
|
|
12
|
+
info: "--ui-color-info",
|
|
13
|
+
warning: "--ui-color-warning",
|
|
14
|
+
danger: "--ui-color-error",
|
|
15
|
+
ghost: "--ui-color-text",
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,65 +1,95 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
"name": "@spaethtech/svelte-ui",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/spaethtech/svelte-ui.git"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/spaethtech/svelte-ui/issues"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/spaethtech/svelte-ui#readme",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "vite dev",
|
|
17
|
+
"build": "vite build && npm run package",
|
|
18
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
19
|
+
"package:watch": "svelte-package --watch",
|
|
20
|
+
"dev:linked": "svelte-kit sync && (npm run package:watch & npm run dev)",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
23
|
+
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
24
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
25
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
26
|
+
"format": "prettier --write .",
|
|
27
|
+
"format:check": "prettier --check .",
|
|
28
|
+
"test": "playwright test",
|
|
29
|
+
"test:ui": "playwright test --ui",
|
|
30
|
+
"test:headed": "playwright test --headed",
|
|
31
|
+
"test:debug": "playwright test --debug"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"!dist/**/*.test.*",
|
|
36
|
+
"!dist/**/*.spec.*"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"**/*.css"
|
|
40
|
+
],
|
|
41
|
+
"svelte": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"type": "module",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"svelte": "./dist/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./data": {
|
|
50
|
+
"types": "./dist/data/index.d.ts",
|
|
51
|
+
"svelte": "./dist/data/index.js",
|
|
52
|
+
"default": "./dist/data/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./theme.css": "./dist/theme.css"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
58
|
+
"svelte": "^5.0.0",
|
|
59
|
+
"tailwindcss": "^4.0.0",
|
|
60
|
+
"unplugin-icons": "^23.0.1"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@iconify-json/mdi": {
|
|
64
|
+
"optional": false
|
|
65
|
+
},
|
|
66
|
+
"unplugin-icons": {
|
|
67
|
+
"optional": false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@iconify-json/mdi": "^1.2.3",
|
|
72
|
+
"@playwright/test": "^1.54.2",
|
|
73
|
+
"@sveltejs/adapter-auto": "^6.0.0",
|
|
74
|
+
"@sveltejs/kit": "^2.22.0",
|
|
75
|
+
"@sveltejs/package": "^2.0.0",
|
|
76
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
77
|
+
"@tailwindcss/vite": "^4.1.11",
|
|
78
|
+
"prettier": "^3.9.4",
|
|
79
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
80
|
+
"publint": "^0.3.2",
|
|
81
|
+
"svelte": "^5",
|
|
82
|
+
"svelte-check": "^4.0.0",
|
|
83
|
+
"tailwindcss": "^4.1.11",
|
|
84
|
+
"typescript": "^5.0.0",
|
|
85
|
+
"unplugin-icons": "^23.0.1",
|
|
86
|
+
"vite": "^7.0.4",
|
|
87
|
+
"vite-plugin-devtools-json": "^1.0.0"
|
|
88
|
+
},
|
|
89
|
+
"keywords": [
|
|
90
|
+
"svelte"
|
|
91
|
+
],
|
|
92
|
+
"description": "Reusable Svelte 5 UI components with Tailwind CSS styling",
|
|
93
|
+
"author": "",
|
|
94
|
+
"license": "ISC"
|
|
65
95
|
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Icon from "../Icon/Icon.svelte";
|
|
3
|
-
import type { IconDefinition } from "@fortawesome/free-solid-svg-icons";
|
|
4
|
-
import type { Snippet } from "svelte";
|
|
5
|
-
import type { Variant } from "../../types/variants.js";
|
|
6
|
-
import type { Size } from "../../types/sizes.js";
|
|
7
|
-
import {
|
|
8
|
-
getVariantClasses,
|
|
9
|
-
getVariantStyles,
|
|
10
|
-
} from "../../styles/variants.js";
|
|
11
|
-
import {
|
|
12
|
-
buttonSizeClasses,
|
|
13
|
-
getComponentHeight,
|
|
14
|
-
} from "../../styles/sizes.js";
|
|
15
|
-
import { DEV } from "esm-env";
|
|
16
|
-
|
|
17
|
-
interface BaseProps {
|
|
18
|
-
icon?: IconDefinition;
|
|
19
|
-
text?: string;
|
|
20
|
-
variant?: Variant;
|
|
21
|
-
size?: Size;
|
|
22
|
-
iconPosition?: "left" | "right";
|
|
23
|
-
children?: Snippet;
|
|
24
|
-
class?: string;
|
|
25
|
-
title?: string;
|
|
26
|
-
onclick?: (event: MouseEvent) => void;
|
|
27
|
-
onmouseenter?: (event: MouseEvent) => void;
|
|
28
|
-
onmouseleave?: (event: MouseEvent) => void;
|
|
29
|
-
element?: HTMLButtonElement | HTMLAnchorElement;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface ButtonProps extends BaseProps {
|
|
33
|
-
href?: never;
|
|
34
|
-
type?: "button" | "submit" | "reset";
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface AnchorProps extends BaseProps {
|
|
39
|
-
href: string;
|
|
40
|
-
type?: never;
|
|
41
|
-
disabled?: never;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type Props = ButtonProps | AnchorProps;
|
|
45
|
-
|
|
46
|
-
let {
|
|
47
|
-
icon,
|
|
48
|
-
text,
|
|
49
|
-
variant = "secondary",
|
|
50
|
-
size = "md",
|
|
51
|
-
iconPosition = "left",
|
|
52
|
-
children,
|
|
53
|
-
disabled = false,
|
|
54
|
-
type = "button",
|
|
55
|
-
href,
|
|
56
|
-
class: additionalClass = "",
|
|
57
|
-
title,
|
|
58
|
-
onclick,
|
|
59
|
-
onmouseenter,
|
|
60
|
-
onmouseleave,
|
|
61
|
-
element = $bindable(),
|
|
62
|
-
...restProps
|
|
63
|
-
}: Props = $props();
|
|
64
|
-
|
|
65
|
-
// Development warnings for prop conflicts and empty content
|
|
66
|
-
if (DEV) {
|
|
67
|
-
if ((text || icon) && children) {
|
|
68
|
-
console.warn(
|
|
69
|
-
"Button: Props (text/icon) and children provided. Using props, ignoring children.",
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
if (!text && !icon && !children) {
|
|
73
|
-
console.warn(
|
|
74
|
-
"Button: No content provided (text, icon, or children). Button will be empty.",
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Determine content mode and styling
|
|
80
|
-
const hasProps = !!(text || icon);
|
|
81
|
-
const isIconOnly = icon && !text;
|
|
82
|
-
|
|
83
|
-
// Base classes - height is always h-8 (32px), width is h-8 for icon-only
|
|
84
|
-
const baseClasses =
|
|
85
|
-
"inline-flex items-center justify-center h-8 rounded-md text-sm font-medium transition-colors no-underline cursor-pointer focus-visible:[outline:2px_solid_color-mix(in_srgb,var(--color-text)_70%,transparent)] focus-visible:[outline-offset:0px]";
|
|
86
|
-
|
|
87
|
-
// Additional classes for disabled state (only applies to buttons)
|
|
88
|
-
const disabledClasses = href
|
|
89
|
-
? ""
|
|
90
|
-
: "disabled:opacity-50 disabled:cursor-not-allowed";
|
|
91
|
-
|
|
92
|
-
// Size classes - width and padding depend on content
|
|
93
|
-
const sizeClasses = isIconOnly ? "w-8" : "px-4 py-2";
|
|
94
|
-
|
|
95
|
-
// Ghost variant uses outline (doesn't affect layout) instead of border
|
|
96
|
-
// Other variants don't need borders since they have solid backgrounds
|
|
97
|
-
|
|
98
|
-
// Build final classes - reactive to variant changes
|
|
99
|
-
const buttonClasses = $derived(
|
|
100
|
-
[
|
|
101
|
-
baseClasses,
|
|
102
|
-
sizeClasses,
|
|
103
|
-
getVariantClasses(variant, { includeBorder: true }),
|
|
104
|
-
disabledClasses,
|
|
105
|
-
additionalClass,
|
|
106
|
-
]
|
|
107
|
-
.filter(Boolean)
|
|
108
|
-
.join(" "),
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
// Get text and icon adjustments from variant styles
|
|
112
|
-
const textAdjustment = $derived(getVariantStyles(variant).textAdjustment);
|
|
113
|
-
const iconAdjustment = $derived(getVariantStyles(variant).iconAdjustment);
|
|
114
|
-
</script>
|
|
115
|
-
|
|
116
|
-
{#if href}
|
|
117
|
-
<a
|
|
118
|
-
bind:this={element}
|
|
119
|
-
{href}
|
|
120
|
-
{title}
|
|
121
|
-
{onclick}
|
|
122
|
-
{onmouseenter}
|
|
123
|
-
{onmouseleave}
|
|
124
|
-
class={buttonClasses}
|
|
125
|
-
{...restProps}
|
|
126
|
-
>
|
|
127
|
-
<div class="flex items-center justify-center gap-2 select-none">
|
|
128
|
-
{#if hasProps}
|
|
129
|
-
{#if iconPosition === "left" && icon}
|
|
130
|
-
<span class={iconAdjustment}><Icon {icon} /></span>
|
|
131
|
-
{/if}
|
|
132
|
-
{#if text}
|
|
133
|
-
<span class={textAdjustment}>{text}</span>
|
|
134
|
-
{/if}
|
|
135
|
-
{#if iconPosition === "right" && icon}
|
|
136
|
-
<span class={iconAdjustment}><Icon {icon} /></span>
|
|
137
|
-
{/if}
|
|
138
|
-
{:else if children}
|
|
139
|
-
{@render children()}
|
|
140
|
-
{/if}
|
|
141
|
-
</div>
|
|
142
|
-
</a>
|
|
143
|
-
{:else}
|
|
144
|
-
<button
|
|
145
|
-
bind:this={element}
|
|
146
|
-
{type}
|
|
147
|
-
{disabled}
|
|
148
|
-
aria-disabled={disabled}
|
|
149
|
-
{title}
|
|
150
|
-
{onclick}
|
|
151
|
-
{onmouseenter}
|
|
152
|
-
{onmouseleave}
|
|
153
|
-
class={buttonClasses}
|
|
154
|
-
{...restProps}
|
|
155
|
-
>
|
|
156
|
-
<div class="flex items-center justify-center gap-2 select-none">
|
|
157
|
-
{#if hasProps}
|
|
158
|
-
{#if iconPosition === "left" && icon}
|
|
159
|
-
<span class={iconAdjustment}><Icon {icon} /></span>
|
|
160
|
-
{/if}
|
|
161
|
-
{#if text}
|
|
162
|
-
<span class={textAdjustment}>{text}</span>
|
|
163
|
-
{/if}
|
|
164
|
-
{#if iconPosition === "right" && icon}
|
|
165
|
-
<span class={iconAdjustment}><Icon {icon} /></span>
|
|
166
|
-
{/if}
|
|
167
|
-
{:else if children}
|
|
168
|
-
{@render children()}
|
|
169
|
-
{/if}
|
|
170
|
-
</div>
|
|
171
|
-
</button>
|
|
172
|
-
{/if}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IconDefinition } from "@fortawesome/free-solid-svg-icons";
|
|
2
|
-
import type { Snippet } from "svelte";
|
|
3
|
-
import type { Variant } from "../../types/variants.js";
|
|
4
|
-
import type { Size } from "../../types/sizes.js";
|
|
5
|
-
interface BaseProps {
|
|
6
|
-
icon?: IconDefinition;
|
|
7
|
-
text?: string;
|
|
8
|
-
variant?: Variant;
|
|
9
|
-
size?: Size;
|
|
10
|
-
iconPosition?: "left" | "right";
|
|
11
|
-
children?: Snippet;
|
|
12
|
-
class?: string;
|
|
13
|
-
title?: string;
|
|
14
|
-
onclick?: (event: MouseEvent) => void;
|
|
15
|
-
onmouseenter?: (event: MouseEvent) => void;
|
|
16
|
-
onmouseleave?: (event: MouseEvent) => void;
|
|
17
|
-
element?: HTMLButtonElement | HTMLAnchorElement;
|
|
18
|
-
}
|
|
19
|
-
interface ButtonProps extends BaseProps {
|
|
20
|
-
href?: never;
|
|
21
|
-
type?: "button" | "submit" | "reset";
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface AnchorProps extends BaseProps {
|
|
25
|
-
href: string;
|
|
26
|
-
type?: never;
|
|
27
|
-
disabled?: never;
|
|
28
|
-
}
|
|
29
|
-
export type Props = ButtonProps | AnchorProps;
|
|
30
|
-
declare const Button: import("svelte").Component<Props, {}, "element">;
|
|
31
|
-
type Button = ReturnType<typeof Button>;
|
|
32
|
-
export default Button;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Button.svelte';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Button.svelte';
|