@orz/ui 0.1.1 → 0.1.2-master.20261030020651.g906eefa
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 +35 -8
- package/dist/components/avatar.js +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.js +9 -9
- package/dist/components/button.js.map +1 -1
- package/dist/components/card.js +4 -4
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/color-picker.js +14 -14
- package/dist/components/color-picker.js.map +1 -1
- package/dist/components/dialog.js +4 -4
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dropdown-menu.js +6 -6
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/filter-menu.js +3 -3
- package/dist/components/filter-menu.js.map +1 -1
- package/dist/components/highlighted-input.js +1 -1
- package/dist/components/highlighted-input.js.map +1 -1
- package/dist/components/hover-card.js +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/link-chip.d.ts +1 -1
- package/dist/components/link-chip.d.ts.map +1 -1
- package/dist/components/link-chip.js +1 -1
- package/dist/components/link-chip.js.map +1 -1
- package/dist/components/media-controls.js +2 -2
- package/dist/components/media-controls.js.map +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/query-box.js +2 -2
- package/dist/components/query-box.js.map +1 -1
- package/dist/components/query-highlight.d.ts.map +1 -1
- package/dist/components/query-highlight.js +3 -3
- package/dist/components/query-highlight.js.map +1 -1
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/select.js +3 -3
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +4 -4
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +3 -3
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme-editor/draft.d.ts +5 -0
- package/dist/components/theme-editor/draft.d.ts.map +1 -1
- package/dist/components/theme-editor/draft.js +9 -2
- package/dist/components/theme-editor/draft.js.map +1 -1
- package/dist/components/theme-editor/form.d.ts.map +1 -1
- package/dist/components/theme-editor/form.js +6 -5
- package/dist/components/theme-editor/form.js.map +1 -1
- package/dist/components/theme-editor/import-panel.js +2 -2
- package/dist/components/theme-editor/import-panel.js.map +1 -1
- package/dist/components/theme-editor/token-list.js +7 -7
- package/dist/components/theme-editor/token-list.js.map +1 -1
- package/dist/components/theme-editor.d.ts.map +1 -1
- package/dist/components/theme-editor.js +4 -2
- package/dist/components/theme-editor.js.map +1 -1
- package/dist/components/theme-menu.d.ts.map +1 -1
- package/dist/components/theme-menu.js +33 -10
- package/dist/components/theme-menu.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/lib/theme-file.d.ts.map +1 -1
- package/dist/lib/theme-file.js +8 -0
- package/dist/lib/theme-file.js.map +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +24 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/theme/custom.d.ts.map +1 -1
- package/dist/theme/custom.js +3 -1
- package/dist/theme/custom.js.map +1 -1
- package/dist/theme/index.d.ts +3 -3
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +2 -2
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/paint-guard.d.ts +12 -2
- package/dist/theme/paint-guard.d.ts.map +1 -1
- package/dist/theme/paint-guard.js +17 -3
- package/dist/theme/paint-guard.js.map +1 -1
- package/dist/theme/picks.d.ts +8 -2
- package/dist/theme/picks.d.ts.map +1 -1
- package/dist/theme/picks.js +32 -1
- package/dist/theme/picks.js.map +1 -1
- package/dist/theme/pref.d.ts +17 -3
- package/dist/theme/pref.d.ts.map +1 -1
- package/dist/theme/pref.js +51 -5
- package/dist/theme/pref.js.map +1 -1
- package/dist/theme/provider.d.ts +13 -1
- package/dist/theme/provider.d.ts.map +1 -1
- package/dist/theme/provider.js +37 -1
- package/dist/theme/provider.js.map +1 -1
- package/dist/theme/store.d.ts +26 -2
- package/dist/theme/store.d.ts.map +1 -1
- package/dist/theme/store.js +69 -25
- package/dist/theme/store.js.map +1 -1
- package/package.json +3 -3
- package/styles.css +1 -1
- package/theme.css +105 -2
package/README.md
CHANGED
|
@@ -46,8 +46,12 @@ shares a document with someone else's UI, and must not restyle it, imports
|
|
|
46
46
|
`@orz/ui/theme.css` instead: the tokens, `.dark`, `tw-animate-css` and shadcn's variants, nothing
|
|
47
47
|
global. `theme.css` carries no `@source`, so that surface names the files Tailwind scans itself.
|
|
48
48
|
|
|
49
|
-
`
|
|
50
|
-
|
|
49
|
+
`theme.css` also declares the style tokens every component draws its shape from: control and row
|
|
50
|
+
heights (`--spacing-control`), corners (`--radius-control`, `--radius-surface`), shadows, text
|
|
51
|
+
sizes, fonts, the focus ring and overlay motion. Their values are the default style's.
|
|
52
|
+
|
|
53
|
+
`styles.css` does not load a font. `--font-ui` names `'Geist Variable'` first and falls back to
|
|
54
|
+
the system UI font, so install `@fontsource-variable/geist` (or define `--font-ui`) if you want it.
|
|
51
55
|
`useOverlayScrollbars` needs the library's own stylesheet, which you import yourself:
|
|
52
56
|
`@import "overlayscrollbars/overlayscrollbars.css";`.
|
|
53
57
|
|
|
@@ -106,9 +110,22 @@ store.setPref({
|
|
|
106
110
|
- `setThemes(list)` and `setTerminalThemes(list)` replace those lists at runtime. A pick whose theme
|
|
107
111
|
leaves the list comes back when the theme returns.
|
|
108
112
|
|
|
113
|
+
A **style** draws the components (radii, edges, type, density, focus, motion) and is picked beside
|
|
114
|
+
the theme. `createThemeStore({ styles, defaultStyle })` takes the styles the app offers, each a
|
|
115
|
+
`Style` from `@orz/themes` whose stylesheet the app imports; without `styles` it offers the default
|
|
116
|
+
style alone. A theme belongs to the styles it lists in `styles` (the default style when it lists
|
|
117
|
+
none), and the UI pick is always one of the current style's themes.
|
|
118
|
+
|
|
119
|
+
- `pref.style` is the picked style, absent for the store's default one.
|
|
120
|
+
- `store.setStyle(id)` switches it, remembering the UI pick under the style it leaves
|
|
121
|
+
(`pref.uiByStyle`) and returning to the one remembered under `id`, or to that style's first
|
|
122
|
+
theme. The terminal pick is not tied to a style.
|
|
123
|
+
- A custom theme belongs to its base theme's styles; a fully custom one records the style it was
|
|
124
|
+
made under (`CustomTheme.style`).
|
|
125
|
+
|
|
109
126
|
The store paints through one `<style data-orz-theme>` element in `<head>`, holding a single
|
|
110
|
-
`:root { … }` rule rendered from the data
|
|
111
|
-
`data-variant` and `data-terminal-theme` on the root. Given a `root` other than `<html>`, the store
|
|
127
|
+
`:root { … }` rule rendered from the data, the palette's own `styleTokens` included. It also toggles
|
|
128
|
+
`.dark` and sets `data-theme`, `data-variant`, `data-style` and `data-terminal-theme` on the root. Given a `root` other than `<html>`, the store
|
|
112
129
|
keeps an element of its own, sets `data-orz-theme-root` on that root to an id unique to the store,
|
|
113
130
|
and scopes the rule to it, so stores on different roots never repaint each other. The rule has
|
|
114
131
|
plain `:root` specificity, so a stylesheet loaded later, or a `:root:root` selector, can still
|
|
@@ -123,6 +140,9 @@ retune a token for every theme.
|
|
|
123
140
|
list is empty and the two calls are ignored.
|
|
124
141
|
- `useThemeSlots()` returns `{ ui, terminal }`: which slots the store has. The two hooks fall back
|
|
125
142
|
where theirs is missing, so they cannot tell you.
|
|
143
|
+
- `useStyle()` returns `{ style, committed, styles, setStyle }`: the style on screen (a hovered one
|
|
144
|
+
included), the picked one, the styles offered, and the switch. Outside a provider it reports the
|
|
145
|
+
default style alone.
|
|
126
146
|
|
|
127
147
|
### Theme menu
|
|
128
148
|
|
|
@@ -138,6 +158,8 @@ Whatever is highlighted previews on the whole page after resting 80 ms, and a pi
|
|
|
138
158
|
|
|
139
159
|
- `slot` is `"ui"` (default) or `"terminal"`. A picker whose slot the store lacks renders nothing.
|
|
140
160
|
The terminal picker adds a "Same as UI" row and a Terminal only group.
|
|
161
|
+
- With more than one style offered, the UI picker adds a Style row above the modes, previewing a
|
|
162
|
+
style while it is hovered or focused, and lists only the picked style's themes.
|
|
141
163
|
- `onCustomize` adds a "Custom themes…" row, which calls it with no id, and an edit button on each
|
|
142
164
|
custom theme's row, which calls it with that theme's id. The second argument is the menu's slot,
|
|
143
165
|
so a new theme opened from the terminal menu is a terminal theme; a callback that takes only the
|
|
@@ -341,12 +363,17 @@ side it can show to that cookie (path `/`, one year, `SameSite=Lax`). `themePain
|
|
|
341
363
|
turns the cookie's value, URL-encoded or not, into CSS for a `<style>` in `<head>`: the background
|
|
342
364
|
and `color-scheme` on `html`, with the dark side under `@media (prefers-color-scheme: dark)` when
|
|
343
365
|
both are stored. A side whose colour could break out of the rule is dropped, and a missing or
|
|
344
|
-
malformed value gives `""`.
|
|
366
|
+
malformed value gives `""`. The cookie holds the committed style too, and
|
|
367
|
+
`themePaintCookieRootAttributes(value)` returns `{ "data-style": id }` for `<html>`, or `{}`, so
|
|
368
|
+
the page has the style's shapes before any script runs. The guard script sets `data-style` from
|
|
369
|
+
its cache the same way.
|
|
345
370
|
|
|
346
371
|
```ts
|
|
347
372
|
// a server template
|
|
348
|
-
const
|
|
349
|
-
|
|
373
|
+
const value = request.cookies["app-theme-paint"];
|
|
374
|
+
const css = themePaintCookieStyle(value);
|
|
375
|
+
const { "data-style": style } = themePaintCookieRootAttributes(value);
|
|
376
|
+
html`<html${style ? ` data-style="${style}"` : ""}><head><style>${css}</style>…</head>`;
|
|
350
377
|
```
|
|
351
378
|
|
|
352
379
|
## Query input
|
|
@@ -538,7 +565,7 @@ import { MediaControls } from "@orz/ui/components/media-controls";
|
|
|
538
565
|
| `@orz/ui/components/<name>` | `avatar`, `badge`, `button`, `card`, `checkbox`, `color-picker`, `confirm-dialog`, `dialog`, `dropdown-menu`, `filter-menu`, `highlighted-input`, `hover-card`, `input`, `label`, `link-chip`, `load-failure`, `load-more`, `media-controls`, `popover`, `query-box`, `query-highlight`, `radio-group`, `select`, `separator`, `sheet`, `skeleton`, `slider`, `sonner`, `switch`, `table`, `tabs`, `textarea`, `theme-editor`, `theme-menu`, `tooltip`, `unsaved-changes-dialog` |
|
|
539
566
|
| `@orz/ui/hooks/<name>` | `scroll-insets`, `use-element-height`, `use-media-query`, `use-overlay-scrollbars`, `use-paged-append`, `use-query-completion`, `use-slash-shortcut`, `viewport-chrome` |
|
|
540
567
|
| `@orz/ui/lib/<name>` | `cell-width`, `cell-width-table`, `clipboard`, `color`, `scroll-map`, `text-metrics`, `theme-file`, `unsaved-guard`, `utils` |
|
|
541
|
-
| `@orz/ui/theme` | `createThemeStore`, `ThemeProvider`, `useTheme`, `useTerminalTheme`, `useThemeSlots`, `themePaintGuardScript`, `normalizePref`, `parseStoredPref`, types (the theme data types re-exported from `@orz/themes`) |
|
|
568
|
+
| `@orz/ui/theme` | `createThemeStore`, `ThemeProvider`, `useTheme`, `useTerminalTheme`, `useThemeSlots`, `useStyle`, `themePaintGuardScript`, `themePaintCookieStyle`, `themePaintCookieRootAttributes`, `normalizePref`, `parseStoredPref`, types (the theme data types re-exported from `@orz/themes`) |
|
|
542
569
|
| `@orz/ui/styles.css` | baseline tokens (the `default` theme), base layer |
|
|
543
570
|
| `@orz/ui/theme.css` | baseline tokens and custom variants, without the base layer or @source |
|
|
544
571
|
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Avatar as AvatarPrimitive } from "radix-ui";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
4
|
function Avatar({ className, size = "default", shape = "circle", ...props }) {
|
|
5
|
-
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, "data-shape": shape, className: cn("group/avatar relative flex size-8 shrink-0 select-none after:absolute after:inset-0 after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten", "data-[shape=circle]:rounded-full data-[shape=circle]:after:rounded-full data-[shape=square]:rounded-
|
|
5
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, "data-shape": shape, className: cn("group/avatar relative flex size-8 shrink-0 select-none after:absolute after:inset-0 after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten", "data-[shape=circle]:rounded-full data-[shape=circle]:after:rounded-full data-[shape=square]:rounded-item data-[shape=square]:after:rounded-item", className), ...props }));
|
|
6
6
|
}
|
|
7
7
|
function AvatarImage({ className, ...props }) {
|
|
8
8
|
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", className: cn("aspect-square size-full rounded-[inherit] object-cover", className), ...props }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/components/avatar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,SAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,KAAK,GAAG,QAAQ,EAChB,GAAG,KAAK,EAKT;IACC,OAAO,CACL,KAAC,eAAe,CAAC,IAAI,iBACT,QAAQ,eACP,IAAI,gBACH,KAAK,EACjB,SAAS,EAAE,EAAE,CACX,uNAAuN,EACvN,
|
|
1
|
+
{"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../src/components/avatar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,SAAS,MAAM,CAAC,EACd,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,KAAK,GAAG,QAAQ,EAChB,GAAG,KAAK,EAKT;IACC,OAAO,CACL,KAAC,eAAe,CAAC,IAAI,iBACT,QAAQ,eACP,IAAI,gBACH,KAAK,EACjB,SAAS,EAAE,EAAE,CACX,uNAAuN,EACvN,iJAAiJ,EACjJ,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EACnB,SAAS,EACT,GAAG,KAAK,EAC2C;IACnD,OAAO,CACL,KAAC,eAAe,CAAC,KAAK,iBACV,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,wDAAwD,EACxD,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,EACtB,SAAS,EACT,GAAG,KAAK,EAC8C;IACtD,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,iBACb,iBAAiB,EAC3B,SAAS,EAAE,EAAE,CACX,yIAAyI,EACzI,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAgC;IACxE,OAAO,CACL,4BACY,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,0KAA0K,EAC1K,+EAA+E,EAC/E,2FAA2F,EAC3F,+EAA+E,EAC/E,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACvE,OAAO,CACL,2BACY,cAAc,EACxB,SAAS,EAAE,EAAE,CACX,qGAAqG,EACrG,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACoB;IAC5B,OAAO,CACL,2BACY,oBAAoB,EAC9B,SAAS,EAAE,EAAE,CACX,0VAA0V,EAC1V,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,OAAO,EACL,MAAM,EACN,WAAW,EACX,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,GACZ,CAAC"}
|
package/dist/components/badge.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
import { Slot } from "radix-ui";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
const badgeVariants = cva("group/badge inline-flex h-
|
|
5
|
+
const badgeVariants = cva("group/badge inline-flex h-chip w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-chip border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:focus-ring has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
8
|
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.js","sourceRoot":"","sources":["../../src/components/badge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,MAAM,aAAa,GAAG,GAAG,CACvB,
|
|
1
|
+
{"version":3,"file":"badge.js","sourceRoot":"","sources":["../../src/components/badge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,MAAM,aAAa,GAAG,GAAG,CACvB,2bAA2b,EAC3b;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,4DAA4D;YACrE,SAAS,EACP,kEAAkE;YACpE,0EAA0E;YAC1E,WAAW,EACT,4KAA4K;YAC9K,OAAO,EACL,wJAAwJ;YAC1J,OAAO,EACL,wJAAwJ;YAC1J,OAAO,EACL,kFAAkF;YACpF,KAAK,EACH,mEAAmE;YACrE,IAAI,EAAE,iDAAiD;SACxD;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;CACF,CACF,CAAC;AAEF,SAAS,KAAK,CAAC,EACb,SAAS,EACT,OAAO,GAAG,SAAS,EACnB,OAAO,GAAG,KAAK,EACf,GAAG,KAAK,EAEkD;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IAE1C,OAAO,CACL,KAAC,IAAI,iBACO,OAAO,kBACH,OAAO,EACrB,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,KAChD,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
import { Slot } from "radix-ui";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
const buttonVariants = cva("group/button relative inline-flex shrink-0 items-center justify-center rounded-
|
|
5
|
+
const buttonVariants = cva("group/button relative inline-flex shrink-0 items-center justify-center rounded-control border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:focus-ring active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 touch:hit-area", {
|
|
6
6
|
variants: {
|
|
7
7
|
variant: {
|
|
8
8
|
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
@@ -17,14 +17,14 @@ const buttonVariants = cva("group/button relative inline-flex shrink-0 items-cen
|
|
|
17
17
|
link: "text-primary underline-offset-4 hover:underline",
|
|
18
18
|
},
|
|
19
19
|
size: {
|
|
20
|
-
default: "h-
|
|
21
|
-
xs: "h-
|
|
22
|
-
sm: "h-
|
|
23
|
-
lg: "h-
|
|
24
|
-
icon: "size-
|
|
25
|
-
"icon-xs": "size-
|
|
26
|
-
"icon-sm": "size-
|
|
27
|
-
"icon-lg": "size-
|
|
20
|
+
default: "h-control gap-1.5 px-2.5 touch:h-10 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
21
|
+
xs: "h-control-xs gap-1 rounded-[min(var(--radius-control),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-control has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
22
|
+
sm: "h-control-sm gap-1 rounded-[min(var(--radius-control),8px)] px-2.5 text-ui-sm in-data-[slot=button-group]:rounded-control has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
23
|
+
lg: "h-control-lg gap-1.5 px-2.5 touch:h-11 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
24
|
+
icon: "size-control",
|
|
25
|
+
"icon-xs": "size-control-xs rounded-[min(var(--radius-control),8px)] in-data-[slot=button-group]:rounded-control [&_svg:not([class*='size-'])]:size-3",
|
|
26
|
+
"icon-sm": "size-control-sm rounded-[min(var(--radius-control),8px)] in-data-[slot=button-group]:rounded-control",
|
|
27
|
+
"icon-lg": "size-control-lg",
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
defaultVariants: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/components/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,MAAM,cAAc,GAAG,GAAG,CACxB,
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/components/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAGhC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,MAAM,cAAc,GAAG,GAAG,CACxB,wkBAAwkB,EACxkB;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,wDAAwD;YACjE,OAAO,EACL,iLAAiL;YACnL,SAAS,EACP,gLAAgL;YAClL,KAAK,EACH,kHAAkH;YACpH,kEAAkE;YAClE,kEAAkE;YAClE,uEAAuE;YACvE,kDAAkD;YAClD,WAAW,EACT,qMAAqM;YACvM,IAAI,EAAE,iDAAiD;SACxD;QACD,IAAI,EAAE;YACJ,OAAO,EACL,uGAAuG;YACzG,EAAE,EAAE,iOAAiO;YACrO,EAAE,EAAE,wOAAwO;YAC5O,EAAE,EAAE,0GAA0G;YAC9G,IAAI,EAAE,cAAc;YACpB,SAAS,EACP,2IAA2I;YAC7I,SAAS,EACP,sGAAsG;YACxG,SAAS,EAAE,iBAAiB;SAC7B;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;KAChB;CACF,CACF,CAAC;AAEF,SAAS,MAAM,CAAC,EACd,SAAS,EACT,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,SAAS,EAChB,OAAO,GAAG,KAAK,EACf,GAAG,KAAK,EAIP;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE5C,OAAO,CACL,KAAC,IAAI,iBACO,QAAQ,kBACJ,OAAO,eACV,IAAI,EACf,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,KACvD,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/components/card.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
function Card({ className, size = "default", ...props }) {
|
|
4
|
-
return (_jsx("div", { "data-slot": "card", "data-size": size, className: cn("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-
|
|
4
|
+
return (_jsx("div", { "data-slot": "card", "data-size": size, className: cn("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-surface bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-surface *:[img:last-child]:rounded-b-surface", className), ...props }));
|
|
5
5
|
}
|
|
6
6
|
function CardHeader({ className, ...props }) {
|
|
7
|
-
return (_jsx("div", { "data-slot": "card-header", className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-
|
|
7
|
+
return (_jsx("div", { "data-slot": "card-header", className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-surface px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)", className), ...props }));
|
|
8
8
|
}
|
|
9
9
|
function CardTitle({ className, ...props }) {
|
|
10
|
-
return (_jsx("div", { "data-slot": "card-title", className: cn("font-heading text-
|
|
10
|
+
return (_jsx("div", { "data-slot": "card-title", className: cn("font-heading text-title leading-snug font-medium group-data-[size=sm]/card:text-sm", className), ...props }));
|
|
11
11
|
}
|
|
12
12
|
function CardDescription({ className, ...props }) {
|
|
13
13
|
return (_jsx("div", { "data-slot": "card-description", className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
@@ -19,7 +19,7 @@ function CardContent({ className, ...props }) {
|
|
|
19
19
|
return (_jsx("div", { "data-slot": "card-content", className: cn("px-(--card-spacing)", className), ...props }));
|
|
20
20
|
}
|
|
21
21
|
function CardFooter({ className, ...props }) {
|
|
22
|
-
return (_jsx("div", { "data-slot": "card-footer", className: cn("flex items-center rounded-b-
|
|
22
|
+
return (_jsx("div", { "data-slot": "card-footer", className: cn("flex items-center rounded-b-surface border-t bg-muted/50 p-(--card-spacing)", className), ...props }));
|
|
23
23
|
}
|
|
24
24
|
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
|
|
25
25
|
//# sourceMappingURL=card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../src/components/card.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,SAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EACkD;IAC1D,OAAO,CACL,2BACY,MAAM,eACL,IAAI,EACf,SAAS,EAAE,EAAE,CACX,
|
|
1
|
+
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../src/components/card.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,SAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,GAAG,SAAS,EAChB,GAAG,KAAK,EACkD;IAC1D,OAAO,CACL,2BACY,MAAM,eACL,IAAI,EACf,SAAS,EAAE,EAAE,CACX,qaAAqa,EACra,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACtE,OAAO,CACL,2BACY,aAAa,EACvB,SAAS,EAAE,EAAE,CACX,6PAA6P,EAC7P,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACrE,OAAO,CACL,2BACY,YAAY,EACtB,SAAS,EAAE,EAAE,CACX,oFAAoF,EACpF,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IAC3E,OAAO,CACL,2BACY,kBAAkB,EAC5B,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,SAAS,CAAC,KACrD,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACtE,OAAO,CACL,2BACY,aAAa,EACvB,SAAS,EAAE,EAAE,CACX,gEAAgE,EAChE,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACvE,OAAO,CACL,2BACY,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,KAC3C,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAA+B;IACtE,OAAO,CACL,2BACY,aAAa,EACvB,SAAS,EAAE,EAAE,CACX,6EAA6E,EAC7E,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { cn } from "../lib/utils.js";
|
|
|
7
7
|
* `checked="indeterminate"` marks the parent of a partly checked list.
|
|
8
8
|
*/
|
|
9
9
|
function Checkbox({ className, ...props }) {
|
|
10
|
-
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn("peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[4px] border border-input shadow-
|
|
10
|
+
return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn("peer relative flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-[min(var(--radius-control),4px)] border border-input shadow-raised transition-colors outline-none focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 dark:bg-input/15 dark:aria-invalid:ring-destructive/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground touch:hit-area", className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", className: "group grid place-content-center text-current [&>svg]:size-3.5", children: [_jsx(CheckIcon, { className: "group-data-[state=indeterminate]:hidden" }), _jsx(MinusIcon, { className: "hidden group-data-[state=indeterminate]:block" })] }) }));
|
|
11
11
|
}
|
|
12
12
|
export { Checkbox };
|
|
13
13
|
//# sourceMappingURL=checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC;;;GAGG;AACH,SAAS,QAAQ,CAAC,EAChB,SAAS,EACT,GAAG,KAAK,EAC4C;IACpD,OAAO,CACL,KAAC,iBAAiB,CAAC,IAAI,iBACX,UAAU,EACpB,SAAS,EAAE,EAAE,CACX,
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC;;;GAGG;AACH,SAAS,QAAQ,CAAC,EAChB,SAAS,EACT,GAAG,KAAK,EAC4C;IACpD,OAAO,CACL,KAAC,iBAAiB,CAAC,IAAI,iBACX,UAAU,EACpB,SAAS,EAAE,EAAE,CACX,qpBAAqpB,EACrpB,SAAS,CACV,KACG,KAAK,YAET,MAAC,iBAAiB,CAAC,SAAS,iBAChB,oBAAoB,EAC9B,SAAS,EAAC,+DAA+D,aAEzE,KAAC,SAAS,IAAC,SAAS,EAAC,yCAAyC,GAAG,EACjE,KAAC,SAAS,IAAC,SAAS,EAAC,+CAA+C,GAAG,IAC3C,GACP,CAC1B,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -730,15 +730,15 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
730
730
|
h: parsed.color.c < ACHROMATIC ? cur.color.h : parsed.color.h,
|
|
731
731
|
}, true, { draft: null });
|
|
732
732
|
};
|
|
733
|
-
return (_jsxs("div", { "data-slot": "color-picker", className: cn("grid w-64 gap-2 text-xs", className), children: [offered.length > 1 && (_jsx("fieldset", { "aria-label": "Picking surface", className: "grid gap-0.5 rounded-
|
|
733
|
+
return (_jsxs("div", { "data-slot": "color-picker", className: cn("grid w-64 gap-2 text-xs", className), children: [offered.length > 1 && (_jsx("fieldset", { "aria-label": "Picking surface", className: "grid gap-0.5 rounded-[min(var(--radius-control),8px)] bg-muted p-0.5", style: {
|
|
734
734
|
gridTemplateColumns: `repeat(${offered.length}, minmax(0, 1fr))`,
|
|
735
|
-
}, children: offered.map((s) => (_jsx("button", { type: "button", "aria-pressed": shown === s, disabled: disabled, onClick: () => pickSurface(s), className: "h-
|
|
735
|
+
}, children: offered.map((s) => (_jsx("button", { type: "button", "aria-pressed": shown === s, disabled: disabled, onClick: () => pickSurface(s), className: "h-control-xs rounded-[min(var(--radius-control),5px)] text-ui-xs font-medium text-muted-foreground outline-none focus-visible:focus-ring disabled:opacity-50 aria-pressed:bg-background aria-pressed:text-foreground aria-pressed:shadow-raised", children: SURFACE_LABELS[s] }, s))) })), _jsxs("div", { ref: areaRef, role: "slider", tabIndex: disabled ? -1 : 0, "aria-label": "Colour", "aria-roledescription": "2D slider", "aria-disabled": disabled || undefined, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round((1 - areaY) * 100), "aria-valuetext": shown === "hsv"
|
|
736
736
|
? `saturation ${round(hsv.s * 100, 1)}%, value ${round(hsv.v * 100, 1)}%`
|
|
737
737
|
: shown === "absolute"
|
|
738
738
|
? `lightness ${round(color.l * 100, 1)}%, chroma ${round(color.c, 3)}`
|
|
739
739
|
: pinned
|
|
740
740
|
? `lightness ${round(color.l * 100, 1)}%, chroma ${round(color.c, 3)}, beyond the ${gamutName} edge`
|
|
741
|
-
: `lightness ${round(color.l * 100, 1)}%, chroma ${round(color.c, 3)} (${Math.round(rel * 100)}% of ${gamutName} max)`, className: cn("relative h-42 cursor-crosshair touch-none overflow-hidden rounded-
|
|
741
|
+
: `lightness ${round(color.l * 100, 1)}%, chroma ${round(color.c, 3)} (${Math.round(rel * 100)}% of ${gamutName} max)`, className: cn("relative h-42 cursor-crosshair touch-none overflow-hidden rounded-item outline-none focus-visible:focus-ring", disabled && "pointer-events-none opacity-50"), style: shown === "hsv"
|
|
742
742
|
? {
|
|
743
743
|
background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${hsv.h} 100% 50%))`,
|
|
744
744
|
}
|
|
@@ -767,7 +767,7 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
767
767
|
update(latest.current, true);
|
|
768
768
|
}, onKeyDown: disabled ? undefined : onAreaKey, children: [shown !== "hsv" && (_jsx("canvas", { ref: areaCanvas, className: "block size-full" })), edges.length > 0 && (_jsx("svg", { "aria-hidden": true, "data-gamut-edges": true, width: areaSize.w, height: areaSize.h, className: "pointer-events-none absolute inset-0", children: edges.map((edge) => (_jsx("polyline", { "data-edge": edge.gamut, points: edge.points
|
|
769
769
|
.map(([x, y]) => `${round(x * areaSize.w, 2)},${round(y * areaSize.h, 2)}`)
|
|
770
|
-
.join(" "), fill: "none", stroke: "rgb(255 255 255 / 0.9)", strokeWidth: 1, strokeLinejoin: "round", strokeDasharray: edge.dashed ? "6 4" : undefined }, edge.gamut))) })), _jsx("span", { "aria-hidden": true, "data-thumb": true, "data-pinned": pinned || undefined, className: "pointer-events-none absolute -mt-[7px] -ml-[7px] size-3.5 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(0_0_0/0.3)] data-pinned:outline-[1.5px] data-pinned:outline-offset-2 data-pinned:outline-destructive/70 data-pinned:outline-dashed", style: { left: `${areaX * 100}%`, top: `${areaY * 100}%` } }), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute top-1 left-1 rounded-
|
|
770
|
+
.join(" "), fill: "none", stroke: "rgb(255 255 255 / 0.9)", strokeWidth: 1, strokeLinejoin: "round", strokeDasharray: edge.dashed ? "6 4" : undefined }, edge.gamut))) })), _jsx("span", { "aria-hidden": true, "data-thumb": true, "data-pinned": pinned || undefined, className: "pointer-events-none absolute -mt-[7px] -ml-[7px] size-3.5 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(0_0_0/0.3)] data-pinned:outline-[1.5px] data-pinned:outline-offset-2 data-pinned:outline-destructive/70 data-pinned:outline-dashed", style: { left: `${areaX * 100}%`, top: `${areaY * 100}%` } }), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute top-1 left-1 rounded-[min(var(--radius-item),6px)] bg-black/45 px-1 text-ui-3xs text-white", children: shown === "hsv" ? "V ↑" : "L ↑" }), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute right-1 bottom-1 rounded-[min(var(--radius-item),6px)] bg-black/45 px-1 text-ui-3xs text-white", children: shown === "oklch" ? "C/max →" : shown === "absolute" ? "C →" : "S →" })] }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(TrackSlider, { label: "Hue", value: hueValue, max: 360, disabled: disabled, onChange: (v) => setHue(v, false), onCommit: (v) => setHue(v, true), trackStyle: shown === "hsv"
|
|
771
771
|
? {
|
|
772
772
|
background: "linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)",
|
|
773
773
|
}
|
|
@@ -775,7 +775,7 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
775
775
|
? `Hue and lightness keep the share of the ${gamutName} maximum chroma`
|
|
776
776
|
: `Keep the share of the ${gamutName} maximum chroma when hue or lightness changes`, disabled: disabled, onClick: toggleLock, children: locked ? _jsx(LockIcon, {}) : _jsx(LockOpenIcon, {}) }))] }), alpha && (_jsx(TrackSlider, { label: "Alpha", value: color.alpha * 100, max: 100, disabled: disabled, onChange: (v) => setAlpha(v, false), onCommit: (v) => setAlpha(v, true), trackStyle: CHECKERBOARD, children: _jsx("span", { className: "absolute inset-0", style: {
|
|
777
777
|
background: `linear-gradient(to right, ${css(color, 0)}, ${css(color, 1)})`,
|
|
778
|
-
} }) })), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsxs("div", { role: "img", "aria-label": "Before and after", title: "Before / after", className: "grid h-
|
|
778
|
+
} }) })), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsxs("div", { role: "img", "aria-label": "Before and after", title: "Before / after", className: "grid h-control-sm w-9 shrink-0 grid-cols-2 overflow-hidden rounded-[min(var(--radius-control),8px)] border", style: CHECKERBOARD, children: [_jsx("span", { style: {
|
|
779
779
|
background: initial === null
|
|
780
780
|
? "transparent"
|
|
781
781
|
: css(initial, alpha ? initial.alpha : 1),
|
|
@@ -791,9 +791,9 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
791
791
|
}, onBlur: () => {
|
|
792
792
|
endText();
|
|
793
793
|
commitPending();
|
|
794
|
-
}, className: "h-
|
|
794
|
+
}, className: "h-control-sm flex-1 px-1.5 font-mono text-base md:text-xs" }), showEyeDropper && (_jsx(Button, { type: "button", variant: "outline", size: "icon-sm", "aria-label": "Pick from screen", title: "Pick from screen", onClick: pickFromScreen, children: _jsx(PipetteIcon, {}) })), reset !== null && (_jsx(Button, { type: "button", variant: "outline", size: "icon-sm", "aria-label": "Reset", title: `Reset to ${resetValue}`, disabled: disabled || atReset, onClick: resetTo, children: _jsx(RotateCcwIcon, {}) }))] }), _jsx(ChannelFields, { color: color, format: outFormat, alpha: alpha, disabled: disabled, idPrefix: id, onSet: setChannel }), _jsxs("div", { className: "grid gap-1 text-ui-2xs", children: [_jsxs("div", { className: "flex h-5 items-center gap-1.5", children: [_jsx("span", { "data-gamut": colorGamut, title: colorGamut !== "srgb" && outFormat !== "oklch"
|
|
795
795
|
? `Mapped to sRGB in ${outFormat}`
|
|
796
|
-
: undefined, className: cn("min-w-0 truncate rounded-
|
|
796
|
+
: undefined, className: cn("min-w-0 truncate rounded-chip border px-1.5 py-px", colorGamut === "srgb"
|
|
797
797
|
? "border-success/60 text-success"
|
|
798
798
|
: colorGamut === "p3"
|
|
799
799
|
? "border-warning/70 text-warning"
|
|
@@ -806,7 +806,7 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
806
806
|
}), className: "ml-auto shrink-0 underline underline-offset-2 disabled:opacity-50",
|
|
807
807
|
// visibility rather than unmounting, for the space; inline rather than a class, so
|
|
808
808
|
// jsdom sees it too and the button leaves the accessibility tree there as well.
|
|
809
|
-
style: colorGamut === "srgb" ? { visibility: "hidden" } : undefined, children: "map to sRGB" })] }), ratio !== null && (_jsx("div", { className: "flex h-5 items-center", children: _jsx("span", { "data-contrast": true, title: `WCAG 2 contrast against ${contrastWith}`, className: cn("min-w-0 truncate rounded-
|
|
809
|
+
style: colorGamut === "srgb" ? { visibility: "hidden" } : undefined, children: "map to sRGB" })] }), ratio !== null && (_jsx("div", { className: "flex h-5 items-center", children: _jsx("span", { "data-contrast": true, title: `WCAG 2 contrast against ${contrastWith}`, className: cn("min-w-0 truncate rounded-chip border px-1.5 py-px", ratio >= 4.5
|
|
810
810
|
? "border-success/60 text-success"
|
|
811
811
|
: ratio >= 3
|
|
812
812
|
? "border-warning/70 text-warning"
|
|
@@ -817,9 +817,9 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
817
817
|
});
|
|
818
818
|
if (usable.length === 0)
|
|
819
819
|
return null;
|
|
820
|
-
return (_jsxs("div", { className: "grid gap-1", children: [_jsx("div", { className: "text-
|
|
820
|
+
return (_jsxs("div", { className: "grid gap-1", children: [_jsx("div", { className: "text-ui-3xs tracking-wide text-muted-foreground uppercase", children: group.label }), _jsx("div", { className: "grid grid-cols-10 gap-1", children: usable.map(({ text, parsed }) => {
|
|
821
821
|
const pressed = isCurrent(parsed.color);
|
|
822
|
-
return (_jsx("button", { type: "button", "aria-label": text, title: text, "aria-pressed": pressed, disabled: disabled, onClick: () => pickSwatch(text), className: "aspect-square rounded-full border border-black/15 outline-none focus-visible:
|
|
822
|
+
return (_jsx("button", { type: "button", "aria-label": text, title: text, "aria-pressed": pressed, disabled: disabled, onClick: () => pickSwatch(text), className: "aspect-square rounded-full border border-black/15 outline-none focus-visible:focus-ring focus-visible:outline-offset-0 disabled:opacity-50 aria-pressed:ring-2 aria-pressed:ring-foreground aria-pressed:ring-offset-2 aria-pressed:ring-offset-popover", style: {
|
|
823
823
|
...CHECKERBOARD,
|
|
824
824
|
backgroundImage: `linear-gradient(${css(parsed.color)}, ${css(parsed.color)}), ${CHECKERBOARD.backgroundImage}`,
|
|
825
825
|
backgroundSize: `auto, ${CHECKERBOARD.backgroundSize}`,
|
|
@@ -828,7 +828,7 @@ export function ColorPicker({ value, onValueChange, onValueCommit, format, alpha
|
|
|
828
828
|
}), extra] }));
|
|
829
829
|
}
|
|
830
830
|
function TrackSlider({ label, value, max, disabled, onChange, onCommit, trackStyle, children, }) {
|
|
831
|
-
return (_jsxs(SliderPrimitive.Root, { value: [value], min: 0, max: max, step: 1, disabled: disabled, onValueChange: ([v]) => onChange(v), onValueCommit: ([v]) => onCommit(v), className: "relative flex h-3 w-full touch-none items-center select-none data-disabled:opacity-50", children: [_jsx(SliderPrimitive.Track, { className: "relative h-3 grow overflow-hidden rounded-full", style: trackStyle, children: children }), _jsx(SliderPrimitive.Thumb, { "aria-label": label, className: "block size-3.5 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(0_0_0/0.3)] outline-none focus-visible:
|
|
831
|
+
return (_jsxs(SliderPrimitive.Root, { value: [value], min: 0, max: max, step: 1, disabled: disabled, onValueChange: ([v]) => onChange(v), onValueCommit: ([v]) => onCommit(v), className: "relative flex h-3 w-full touch-none items-center select-none data-disabled:opacity-50", children: [_jsx(SliderPrimitive.Track, { className: "relative h-3 grow overflow-hidden rounded-full", style: trackStyle, children: children }), _jsx(SliderPrimitive.Thumb, { "aria-label": label, className: "block size-3.5 rounded-full border-2 border-white shadow-[0_0_0_1px_rgb(0_0_0/0.5),inset_0_0_0_1px_rgb(0_0_0/0.3)] outline-none focus-visible:focus-ring" })] }));
|
|
832
832
|
}
|
|
833
833
|
function channelSpecs(color, format, alpha) {
|
|
834
834
|
const specs = [];
|
|
@@ -933,17 +933,17 @@ function ChannelField({ id, spec, disabled, onSet, }) {
|
|
|
933
933
|
return;
|
|
934
934
|
onSet(spec.apply(n), spec.key);
|
|
935
935
|
};
|
|
936
|
-
return (_jsxs("div", { className: "grid gap-px text-center", children: [_jsx("label", { htmlFor: id, className: "text-
|
|
936
|
+
return (_jsxs("div", { className: "grid gap-px text-center", children: [_jsx("label", { htmlFor: id, className: "text-ui-3xs text-muted-foreground", children: spec.label }), _jsx(Input, { id: id, "aria-label": spec.name, inputMode: "decimal", spellCheck: false, autoComplete: "off", disabled: disabled, value: draft ?? spec.text, onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
|
|
937
937
|
if (event.key === "Enter")
|
|
938
938
|
settle();
|
|
939
939
|
else if (event.key === "Escape")
|
|
940
940
|
setDraft(null);
|
|
941
|
-
}, onBlur: settle, className: "h-
|
|
941
|
+
}, onBlur: settle, className: "h-control-xs px-1 text-center font-mono text-base md:text-ui-2xs" })] }));
|
|
942
942
|
}
|
|
943
943
|
/** The panel in a popover, behind a trigger showing the value. */
|
|
944
944
|
export function ColorPickerPopover({ open, defaultOpen, onOpenChange, align, side, children, "aria-label": ariaLabel = "Pick colour", ...picker }) {
|
|
945
945
|
const parsed = parseColor(picker.value);
|
|
946
|
-
return (_jsxs(Popover, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, children: [_jsx(PopoverTrigger, { asChild: true, "aria-label": ariaLabel, disabled: picker.disabled, children: children ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "pl-1 font-mono text-xs", children: [_jsx("span", { "aria-hidden": true, className: "size-5 shrink-0 overflow-hidden rounded-
|
|
946
|
+
return (_jsxs(Popover, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, children: [_jsx(PopoverTrigger, { asChild: true, "aria-label": ariaLabel, disabled: picker.disabled, children: children ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "pl-1 font-mono text-xs", children: [_jsx("span", { "aria-hidden": true, className: "size-5 shrink-0 overflow-hidden rounded-[min(var(--radius-item),6px)] border border-black/15", style: CHECKERBOARD, children: _jsx("span", { className: "block size-full", style: {
|
|
947
947
|
background: parsed === null ? "transparent" : css(parsed.color),
|
|
948
948
|
} }) }), picker.value] })) }), _jsx(PopoverContent, { align: align, side: side, className: "w-auto p-2", children: _jsx(ColorPicker, { ...picker }) })] }));
|
|
949
949
|
}
|