@tristan2828/ui-foundation 4.68.1 → 4.69.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/conventions/docs/cell-patterns.md +58 -32
- package/conventions/docs/design-language.md +74 -23
- package/dist/components/app/color-swatch.d.ts +25 -0
- package/dist/components/app/color-swatch.js +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/stored-color.d.ts +6 -0
- package/dist/lib/stored-color.js +16 -0
- package/package.json +1 -1
|
@@ -3,38 +3,39 @@
|
|
|
3
3
|
<!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
|
-
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines
|
|
7
|
-
- [1. Plain text](#1-plain-text) · lines
|
|
8
|
-
- [2. Icon + label](#2-icon--label) · lines
|
|
9
|
-
- [3. Icon in a badge](#3-icon-in-a-badge) · lines
|
|
10
|
-
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines
|
|
11
|
-
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines
|
|
12
|
-
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines
|
|
13
|
-
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines
|
|
14
|
-
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines
|
|
15
|
-
- [8. Date, relative](#8-date-relative) · lines
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines
|
|
17
|
-
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
30
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
31
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
32
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
33
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
34
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
35
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
36
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
37
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
6
|
+
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 67–86
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 88–95
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 97–120
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 122–135
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 137–214
|
|
11
|
+
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 162–214
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 216–229
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 231–243
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 245–266
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 268–305
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 307–355
|
|
17
|
+
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 325–355
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 357–407
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 375–407
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 409–449
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 451–481
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 483–519
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 503–519
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 521–538
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 540–649
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 566–649
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 651–686
|
|
28
|
+
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 688–761
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 763–1227
|
|
30
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1043–1128
|
|
31
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1130–1215
|
|
32
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1217–1227
|
|
33
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1229–1295
|
|
34
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1297–1361
|
|
35
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1363–1431
|
|
36
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1433–1461
|
|
37
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1463–1539
|
|
38
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1541–1564
|
|
38
39
|
|
|
39
40
|
<!-- /index -->
|
|
40
41
|
|
|
@@ -1536,3 +1537,28 @@ const { grouping, setGrouping, ...table } = useTableUrlState(FILTERS, MULTI, VIE
|
|
|
1536
1537
|
add-an-entity.md "How a list opens a record").
|
|
1537
1538
|
- **The table layout's alone:** a card layout's cards don't open the
|
|
1538
1539
|
panel.
|
|
1540
|
+
|
|
1541
|
+
## 24. A stored colour beside its name
|
|
1542
|
+
|
|
1543
|
+
A colour the user stored as data (a label's colour, a paint's hex): a
|
|
1544
|
+
`ColorSwatch`, its name always beside it. design-language.md "A stored
|
|
1545
|
+
colour" has the why.
|
|
1546
|
+
|
|
1547
|
+
```tsx
|
|
1548
|
+
import { ColorSwatch } from '@tristan2828/ui-foundation'
|
|
1549
|
+
|
|
1550
|
+
{ id: 'color', header: 'Colour',
|
|
1551
|
+
cell: ({ row }) => <ColorSwatch color={row.original.color} label={row.original.colorName ?? row.original.color ?? 'No colour'} /> }
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
- **The label is required**: the colour's name, else the value (the hex),
|
|
1555
|
+
else "No colour". The swatch is decorative; the word carries it.
|
|
1556
|
+
- **A missing or invalid value** draws the empty swatch, a dashed ring,
|
|
1557
|
+
and never paints. Validate on the form with `storedColor`.
|
|
1558
|
+
- **In a badge** (a label shown as a tag): `size="sm"` inside the
|
|
1559
|
+
`Badge`, which sizes it like the badge's icons (pattern 3).
|
|
1560
|
+
- **A colour picked from a few** is a categorical slot, a tinted glyph
|
|
1561
|
+
(design-language.md "Categorical colour"), not a stored hex.
|
|
1562
|
+
|
|
1563
|
+
The package's fixture `app/ColorSwatch` "In a table" renders it; its
|
|
1564
|
+
checks measure the ring at 3:1 in both themes and every palette.
|
|
@@ -3,29 +3,30 @@
|
|
|
3
3
|
<!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
|
-
- [Palettes](#palettes) · lines
|
|
7
|
-
- [Glow](#glow) · lines
|
|
8
|
-
- [Semantic tones](#semantic-tones) · lines
|
|
9
|
-
- [The three badge styles](#the-three-badge-styles) · lines
|
|
10
|
-
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines
|
|
11
|
-
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines
|
|
12
|
-
- [Logos and brand marks](#logos-and-brand-marks) · lines
|
|
13
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
- [
|
|
18
|
-
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
|
|
24
|
-
- [
|
|
25
|
-
- [A list as
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
6
|
+
- [Palettes](#palettes) · lines 39–105
|
|
7
|
+
- [Glow](#glow) · lines 107–125
|
|
8
|
+
- [Semantic tones](#semantic-tones) · lines 127–155
|
|
9
|
+
- [The three badge styles](#the-three-badge-styles) · lines 157–174
|
|
10
|
+
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 176–205
|
|
11
|
+
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 207–220
|
|
12
|
+
- [Logos and brand marks](#logos-and-brand-marks) · lines 222–266
|
|
13
|
+
- [Categorical colour](#categorical-colour) · lines 268–338
|
|
14
|
+
- [A stored colour](#a-stored-colour) · lines 340–388
|
|
15
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 390–411
|
|
16
|
+
- [Typography](#typography) · lines 413–507
|
|
17
|
+
- [Written text (notes)](#written-text-notes) · lines 447–507
|
|
18
|
+
- [Density](#density) · lines 509–595
|
|
19
|
+
- [Rows on this device](#rows-on-this-device) · lines 568–595
|
|
20
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 597–711
|
|
21
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 713–782
|
|
22
|
+
- [Notices](#notices) · lines 784–812
|
|
23
|
+
- [A value over time](#a-value-over-time) · lines 814–900
|
|
24
|
+
- [Several values over time](#several-values-over-time) · lines 863–900
|
|
25
|
+
- [A list as a board](#a-list-as-a-board) · lines 902–953
|
|
26
|
+
- [A list as cards](#a-list-as-cards) · lines 955–1001
|
|
27
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1003–1025
|
|
28
|
+
- [Picking at random](#picking-at-random) · lines 1027–1058
|
|
29
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1060–1127
|
|
29
30
|
|
|
30
31
|
<!-- /index -->
|
|
31
32
|
|
|
@@ -336,6 +337,56 @@ If you find yourself wanting a thirteenth, that is a sign the column should
|
|
|
336
337
|
be showing a shape or a label rather than more colours: there is no more
|
|
337
338
|
room that stays readable.
|
|
338
339
|
|
|
340
|
+
## A stored colour
|
|
341
|
+
|
|
342
|
+
A colour the user stored as data (a paint's hex, a label's colour, a
|
|
343
|
+
calendar's colour) is not a design decision, so no token can hold it,
|
|
344
|
+
and the token rule rightly forbids writing a hex into code. Show it with
|
|
345
|
+
**`ColorSwatch`**: a small swatch filled with the stored value, beside its
|
|
346
|
+
name.
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
import { ColorSwatch } from '@tristan2828/ui-foundation'
|
|
350
|
+
|
|
351
|
+
<ColorSwatch color={paint.colorHex} label={paint.name} /> // 16px: a cell, a list, a line of text
|
|
352
|
+
<Badge variant="outline"><ColorSwatch size="sm" color={label.color} label={label.name} /></Badge> // 12px, a Badge's icon size
|
|
353
|
+
<ColorSwatch color={null} label="No colour" /> // the empty swatch
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
- **The value is validated.** Only a hex (`#rgb`, `#rgba`, `#rrggbb`,
|
|
357
|
+
`#rrggbbaa`, the `#` optional, as some APIs store labels' colours) is
|
|
358
|
+
painted. Anything else, missing, blank, a typo, a CSS keyword, draws
|
|
359
|
+
the **empty swatch**: a dashed ring with no fill. `storedColor(value)`
|
|
360
|
+
is the same check, returning the colour normalised (`'C0392B'` →
|
|
361
|
+
`'#c0392b'`) or `null`: use it in a form's schema so a bad value never
|
|
362
|
+
saves. Store colours as hex; another format shows as empty.
|
|
363
|
+
- **The ring is `border-muted-foreground`**, and it is what keeps any
|
|
364
|
+
stored colour visible: a white on a white card, a near-black in dark
|
|
365
|
+
mode. It clears the 3:1 non-text minimum against the page, a card, a
|
|
366
|
+
muted surface, a table row and a Badge's wash, in light, dark and every
|
|
367
|
+
palette (lowest 3.69:1, light, inside a secondary Badge). `--border`
|
|
368
|
+
and `--input` don't (2.5 to 2.9:1), so never draw a stored colour with
|
|
369
|
+
them or with no ring.
|
|
370
|
+
- **Never the colour alone.** The swatch is `aria-hidden`, and `label` is
|
|
371
|
+
a required string, so a swatch can't be written without its name: the
|
|
372
|
+
colour's name, or what it labels. Where the record has no name for the
|
|
373
|
+
colour, the label is the value itself (the hex), or "No colour". A long
|
|
374
|
+
name stays on one line, cut, its whole text in a tooltip.
|
|
375
|
+
- **The fill is the one colour that isn't a token.** The swatch's
|
|
376
|
+
`backgroundColor` is an inline style from the prop, which the ESLint
|
|
377
|
+
token rule allows (it forbids hex *literals* in a `style`). The
|
|
378
|
+
fixtures' token check exempts exactly that: a swatch's background while
|
|
379
|
+
it equals its own `data-color`. Nothing else may paint a stored colour,
|
|
380
|
+
and a stored colour never paints text, a surface or a border: a
|
|
381
|
+
colour the user picked from a few is a categorical slot (above), not a
|
|
382
|
+
hex.
|
|
383
|
+
|
|
384
|
+
The package's fixtures render it (`app/ColorSwatch`: on each surface,
|
|
385
|
+
invalid and missing, in a Badge, in a `DataTable`, a long name, every
|
|
386
|
+
palette side by side), with axe, the token check and the ring's ratio
|
|
387
|
+
measured in light, dark and every palette. Cell pattern 24 is it in a
|
|
388
|
+
column.
|
|
389
|
+
|
|
339
390
|
## Shapes and sizes
|
|
340
391
|
|
|
341
392
|
The shared style guide's, the same in every app with or without a
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const SIZES: {
|
|
2
|
+
readonly sm: {
|
|
3
|
+
readonly swatch: "size-3";
|
|
4
|
+
readonly gap: "gap-1";
|
|
5
|
+
};
|
|
6
|
+
readonly default: {
|
|
7
|
+
readonly swatch: "size-4";
|
|
8
|
+
readonly gap: "gap-2";
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export interface ColorSwatchProps {
|
|
12
|
+
/** The stored colour: a hex value (`#c0392b`, `c0392b`, `#fff`). Missing or invalid draws the empty swatch. */
|
|
13
|
+
color: string | null | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The colour's name or what it labels ("Hale Navy", "Work"), always shown
|
|
16
|
+
* beside the swatch: the swatch is hidden from screen readers and is never
|
|
17
|
+
* the only way to tell. For a missing colour, say so ("No colour").
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/** `sm` inside a Badge, `default` (16px) in a cell or a line of text. */
|
|
21
|
+
size?: keyof typeof SIZES;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function ColorSwatch({ color, label, size, className }: ColorSwatchProps): import("react").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A colour the user stored as data (a paint's hex, a label's colour, a
|
|
3
|
+
// calendar's colour), shown as a small swatch beside its name. The design
|
|
4
|
+
// language's "A stored colour" section is the why of each choice:
|
|
5
|
+
//
|
|
6
|
+
// - The fill is the stored value, as an inline style: it is data, not a
|
|
7
|
+
// design decision, so no token can hold it. Only a value `storedColor`
|
|
8
|
+
// accepts reaches the style; anything else (missing, empty, a typo, a
|
|
9
|
+
// CSS keyword, `url(...)`) draws the empty swatch, a dashed ring with no
|
|
10
|
+
// fill, so a bad value never paints and never breaks the row.
|
|
11
|
+
// - The ring is `border-muted-foreground`: it clears 3:1 against the page,
|
|
12
|
+
// a card and a muted surface in light, dark and every palette (measured
|
|
13
|
+
// in e2e/fixtures-visual.spec.ts), so a stored white on a white card, or
|
|
14
|
+
// a near-black in dark mode, still shows its edge. `--border` and
|
|
15
|
+
// `--input` don't (2.5 to 2.9:1 at best).
|
|
16
|
+
// - The swatch is aria-hidden and the name is always rendered beside it:
|
|
17
|
+
// `label` is required, so the colour is never the only way to tell.
|
|
18
|
+
import { cn } from 'cn';
|
|
19
|
+
import { storedColor } from '../../lib/stored-color.js';
|
|
20
|
+
const SIZES = {
|
|
21
|
+
// Inside a Badge: its icons' 12px (`[&>svg]:size-3`), its gap.
|
|
22
|
+
sm: { swatch: 'size-3', gap: 'gap-1' },
|
|
23
|
+
// In a cell, a list or a line of text: the 16px of a cell's icon (pattern 2).
|
|
24
|
+
default: { swatch: 'size-4', gap: 'gap-2' },
|
|
25
|
+
};
|
|
26
|
+
export function ColorSwatch({ color, label, size = 'default', className }) {
|
|
27
|
+
const fill = storedColor(color);
|
|
28
|
+
const { swatch, gap } = SIZES[size];
|
|
29
|
+
return (_jsxs("span", { "data-slot": "color-swatch-label", className: cn('inline-flex min-w-0 items-center', gap, className), children: [_jsx("span", { "aria-hidden": "true", "data-slot": "color-swatch", "data-empty": fill ? undefined : '', "data-color": fill ?? undefined, className: cn('box-border shrink-0 rounded-sm border border-muted-foreground', swatch, !fill && 'border-dashed'), style: fill ? { backgroundColor: fill } : undefined }), _jsx("span", { className: "min-w-0 truncate", title: label, children: label })] }));
|
|
30
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { pickSpinWheelIndex, type SpinWheelItem } from './components/app/spin-wh
|
|
|
6
6
|
export { FillInChoice, FillInQueue, type FillInChoiceProps, type FillInQueueGroup, type FillInQueueProgress, type FillInQueueProps, } from './components/app/fill-in-queue.js';
|
|
7
7
|
export { FillInField, FillInInput, FillInSelect, type FillInFieldKind, type FillInFieldProps, type FillInFieldSpec, type FillInInputKind, type FillInInputProps, type FillInSelectProps, type FillInSuggestion, type FillInValue, } from './components/app/fill-in-field.js';
|
|
8
8
|
export { Artwork, ArtworkTag, ArtworkToggle, type ArtworkAspect, type ArtworkProps, type ArtworkToggleProps, } from './components/app/artwork.js';
|
|
9
|
+
export { ColorSwatch, type ColorSwatchProps } from './components/app/color-swatch.js';
|
|
10
|
+
export { storedColor } from './lib/stored-color.js';
|
|
9
11
|
export { CountLink, type CountLinkProps } from './components/app/count-link.js';
|
|
10
12
|
export { DataTable, type DataTableCardLayout, type DataTableOpens, type DataTableOpensKind, type DataTableGrouping, type DataTableProps, type DataTableTotals, type DataTableWidth, type SortingState, } from './components/app/data-table.js';
|
|
11
13
|
export { type RowGroup } from './components/app/table-groups.js';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export { pickSpinWheelIndex } from './components/app/spin-wheel-pick.js';
|
|
|
10
10
|
export { FillInChoice, FillInQueue, } from './components/app/fill-in-queue.js';
|
|
11
11
|
export { FillInField, FillInInput, FillInSelect, } from './components/app/fill-in-field.js';
|
|
12
12
|
export { Artwork, ArtworkTag, ArtworkToggle, } from './components/app/artwork.js';
|
|
13
|
+
export { ColorSwatch } from './components/app/color-swatch.js';
|
|
14
|
+
export { storedColor } from './lib/stored-color.js';
|
|
13
15
|
export { CountLink } from './components/app/count-link.js';
|
|
14
16
|
export { DataTable, } from './components/app/data-table.js';
|
|
15
17
|
export {} from './components/app/table-groups.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stored colour as CSS, or `null` when it isn't one: a hex value, with or
|
|
3
|
+
* without its `#`, in 3, 4, 6 or 8 digits, trimmed and lower-cased
|
|
4
|
+
* (`'C0392B'` → `'#c0392b'`). Use it to validate a colour on a form too.
|
|
5
|
+
*/
|
|
6
|
+
export declare function storedColor(value: string | null | undefined): string | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Whether a colour stored as data can be painted (ColorSwatch's fill), and
|
|
2
|
+
// as what. Its own file so a form can validate a colour with it too.
|
|
3
|
+
// #rgb, #rgba, #rrggbb or #rrggbbaa, the leading # optional (some APIs
|
|
4
|
+
// store labels' colours without it).
|
|
5
|
+
const HEX = /^#?([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
6
|
+
/**
|
|
7
|
+
* A stored colour as CSS, or `null` when it isn't one: a hex value, with or
|
|
8
|
+
* without its `#`, in 3, 4, 6 or 8 digits, trimmed and lower-cased
|
|
9
|
+
* (`'C0392B'` → `'#c0392b'`). Use it to validate a colour on a form too.
|
|
10
|
+
*/
|
|
11
|
+
export function storedColor(value) {
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
return null;
|
|
14
|
+
const match = HEX.exec(value.trim());
|
|
15
|
+
return match ? `#${match[1].toLowerCase()}` : null;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.69.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|