@slurp-ui/react 1.1.0 → 1.2.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/CHANGELOG.md +56 -0
- package/dist/Bloom/Bloom.js +3 -2
- package/dist/Bloom/Bloom.js.map +1 -1
- package/dist/Calendar/Calendar.d.ts +42 -0
- package/dist/Calendar/Calendar.js +178 -0
- package/dist/Calendar/Calendar.js.map +1 -0
- package/dist/Calendar/dates.d.ts +3 -0
- package/dist/Calendar/dates.js +46 -0
- package/dist/Calendar/dates.js.map +1 -0
- package/dist/Calendar/index.d.ts +3 -0
- package/dist/Calendar/index.js +2 -0
- package/dist/Card/Card.d.ts +1 -1
- package/dist/Card/Card.js.map +1 -1
- package/dist/Carousel/Carousel.js +2 -0
- package/dist/Carousel/Carousel.js.map +1 -1
- package/dist/Choice/Choice.js +2 -0
- package/dist/Choice/Choice.js.map +1 -1
- package/dist/Code/Code.d.ts +38 -0
- package/dist/Code/Code.js +82 -0
- package/dist/Code/Code.js.map +1 -0
- package/dist/Code/index.d.ts +3 -0
- package/dist/Code/index.js +2 -0
- package/dist/Contents/Contents.d.ts +35 -0
- package/dist/Contents/Contents.js +63 -0
- package/dist/Contents/Contents.js.map +1 -0
- package/dist/Contents/index.d.ts +3 -0
- package/dist/Contents/index.js +2 -0
- package/dist/DateField/DateField.d.ts +29 -0
- package/dist/DateField/DateField.js +118 -0
- package/dist/DateField/DateField.js.map +1 -0
- package/dist/DateField/index.d.ts +3 -0
- package/dist/DateField/index.js +2 -0
- package/dist/Dialog/Dialog.js +73 -25
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dock/Dock.d.ts +6 -1
- package/dist/Dock/Dock.js +13 -2
- package/dist/Dock/Dock.js.map +1 -1
- package/dist/ErrorSummary/ErrorSummary.d.ts +26 -0
- package/dist/ErrorSummary/ErrorSummary.js +68 -0
- package/dist/ErrorSummary/ErrorSummary.js.map +1 -0
- package/dist/ErrorSummary/index.d.ts +3 -0
- package/dist/ErrorSummary/index.js +2 -0
- package/dist/FileDrop/FileDrop.d.ts +34 -0
- package/dist/FileDrop/FileDrop.js +145 -0
- package/dist/FileDrop/FileDrop.js.map +1 -0
- package/dist/FileDrop/index.d.ts +3 -0
- package/dist/FileDrop/index.js +2 -0
- package/dist/Filters/Filters.js +2 -0
- package/dist/Filters/Filters.js.map +1 -1
- package/dist/Footer/Footer.d.ts +37 -0
- package/dist/Footer/Footer.js +63 -0
- package/dist/Footer/Footer.js.map +1 -0
- package/dist/Footer/index.d.ts +3 -0
- package/dist/Footer/index.js +2 -0
- package/dist/Hairline/Hairline.d.ts +16 -0
- package/dist/Hairline/Hairline.js +23 -0
- package/dist/Hairline/Hairline.js.map +1 -0
- package/dist/Hairline/index.d.ts +3 -0
- package/dist/Hairline/index.js +2 -0
- package/dist/Hint/Hint.js +20 -1
- package/dist/Hint/Hint.js.map +1 -1
- package/dist/Kbd/Kbd.d.ts +7 -0
- package/dist/Kbd/Kbd.js +20 -0
- package/dist/Kbd/Kbd.js.map +1 -0
- package/dist/Kbd/index.d.ts +3 -0
- package/dist/Kbd/index.js +2 -0
- package/dist/ListRow/ListRow.d.ts +6 -2
- package/dist/ListRow/ListRow.js +5 -1
- package/dist/ListRow/ListRow.js.map +1 -1
- package/dist/Media/Media.d.ts +28 -0
- package/dist/Media/Media.js +65 -0
- package/dist/Media/Media.js.map +1 -0
- package/dist/Media/index.d.ts +3 -0
- package/dist/Media/index.js +2 -0
- package/dist/Notice/Notice.js +2 -0
- package/dist/Notice/Notice.js.map +1 -1
- package/dist/NumberField/NumberField.d.ts +32 -0
- package/dist/NumberField/NumberField.js +126 -0
- package/dist/NumberField/NumberField.js.map +1 -0
- package/dist/NumberField/index.d.ts +3 -0
- package/dist/NumberField/index.js +2 -0
- package/dist/PageNav/PageNav.d.ts +25 -0
- package/dist/PageNav/PageNav.js +57 -0
- package/dist/PageNav/PageNav.js.map +1 -0
- package/dist/PageNav/index.d.ts +3 -0
- package/dist/PageNav/index.js +2 -0
- package/dist/Pages/Pages.js +2 -0
- package/dist/Pages/Pages.js.map +1 -1
- package/dist/PinField/PinField.d.ts +26 -0
- package/dist/PinField/PinField.js +73 -0
- package/dist/PinField/PinField.js.map +1 -0
- package/dist/PinField/index.d.ts +3 -0
- package/dist/PinField/index.js +2 -0
- package/dist/Prose/Prose.d.ts +15 -0
- package/dist/Prose/Prose.js +25 -0
- package/dist/Prose/Prose.js.map +1 -0
- package/dist/Prose/index.d.ts +3 -0
- package/dist/Prose/index.js +2 -0
- package/dist/Quote/Quote.d.ts +19 -0
- package/dist/Quote/Quote.js +52 -0
- package/dist/Quote/Quote.js.map +1 -0
- package/dist/Quote/index.d.ts +3 -0
- package/dist/Quote/index.js +2 -0
- package/dist/Rail/Rail.d.ts +37 -0
- package/dist/Rail/Rail.js +61 -0
- package/dist/Rail/Rail.js.map +1 -0
- package/dist/Rail/index.d.ts +3 -0
- package/dist/Rail/index.js +2 -0
- package/dist/Range/Range.d.ts +1 -1
- package/dist/Range/Range.js.map +1 -1
- package/dist/Rating/Rating.js +2 -0
- package/dist/Rating/Rating.js.map +1 -1
- package/dist/Search/Search.d.ts +1 -1
- package/dist/Search/Search.js +2 -0
- package/dist/Search/Search.js.map +1 -1
- package/dist/SecretField/SecretField.d.ts +17 -0
- package/dist/SecretField/SecretField.js +59 -0
- package/dist/SecretField/SecretField.js.map +1 -0
- package/dist/SecretField/index.d.ts +3 -0
- package/dist/SecretField/index.js +2 -0
- package/dist/Settings/Settings.js +2 -0
- package/dist/Settings/Settings.js.map +1 -1
- package/dist/SkipLink/SkipLink.d.ts +22 -0
- package/dist/SkipLink/SkipLink.js +32 -0
- package/dist/SkipLink/SkipLink.js.map +1 -0
- package/dist/SkipLink/index.d.ts +3 -0
- package/dist/SkipLink/index.js +2 -0
- package/dist/SlurpProvider/SlurpProvider.d.ts +7 -1
- package/dist/SlurpProvider/SlurpProvider.js +14 -6
- package/dist/SlurpProvider/SlurpProvider.js.map +1 -1
- package/dist/Steps/Steps.js +2 -0
- package/dist/Steps/Steps.js.map +1 -1
- package/dist/Suggest/Suggest.js +2 -0
- package/dist/Suggest/Suggest.js.map +1 -1
- package/dist/Table/Table.js +2 -0
- package/dist/Table/Table.js.map +1 -1
- package/dist/Tag/Tag.d.ts +14 -0
- package/dist/Tag/Tag.js +26 -0
- package/dist/Tag/Tag.js.map +1 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/Tag/index.js +2 -0
- package/dist/Toast/Toast.js +31 -7
- package/dist/Toast/Toast.js.map +1 -1
- package/dist/index.d.ts +45 -4
- package/dist/index.js +23 -1
- package/dist/internal/labels.js +12 -0
- package/dist/internal/labels.js.map +1 -0
- package/dist/lib/labels.d.ts +175 -0
- package/dist/lib/labels.js +116 -0
- package/dist/lib/labels.js.map +1 -0
- package/dist/lib/theme.d.ts +98 -3
- package/dist/lib/theme.js.map +1 -1
- package/dist/styles.css +1435 -127
- package/dist/tokens.css +10 -0
- package/dist/utils/focus.d.ts +1 -1
- package/dist/utils/focus.js +2 -2
- package/dist/utils/focus.js.map +1 -1
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/useClipboard.d.ts +14 -0
- package/dist/utils/useClipboard.js +30 -0
- package/dist/utils/useClipboard.js.map +1 -0
- package/dist/utils/useScrollSpy.d.ts +14 -0
- package/dist/utils/useScrollSpy.js +27 -0
- package/dist/utils/useScrollSpy.js.map +1 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { CONTRAST_MIN, alpha, contrast, meetsContrast, onColor, vivid } from "./lib/color.js";
|
|
3
3
|
import { DEFAULT_STORAGE_KEY, createTheme } from "./lib/theme.js";
|
|
4
4
|
import { useColorScheme, useTheme } from "./internal/context.js";
|
|
5
|
+
import { labelsEn, labelsIt } from "./lib/labels.js";
|
|
5
6
|
import { SlurpProvider } from "./SlurpProvider/SlurpProvider.js";
|
|
6
7
|
import { ColorSchemeScript } from "./SlurpProvider/ColorSchemeScript.js";
|
|
7
8
|
import { AnimationGroup } from "./motion/AnimationGroup.js";
|
|
@@ -60,6 +61,27 @@ import { ResultRow } from "./ResultRow/ResultRow.js";
|
|
|
60
61
|
import { Mark } from "./Mark/Mark.js";
|
|
61
62
|
import { Empty } from "./Empty/Empty.js";
|
|
62
63
|
import { Link } from "./Link/Link.js";
|
|
64
|
+
import { CALENDAR_LABELS, Calendar } from "./Calendar/Calendar.js";
|
|
65
|
+
import { DATEFIELD_LABELS, DateField } from "./DateField/DateField.js";
|
|
66
|
+
import { FILEDROP_LABELS, FileDrop } from "./FileDrop/FileDrop.js";
|
|
67
|
+
import { ERRORSUMMARY_LABELS, ErrorSummary } from "./ErrorSummary/ErrorSummary.js";
|
|
68
|
+
import { PinField } from "./PinField/PinField.js";
|
|
69
|
+
import { NUMBERFIELD_LABELS, NumberField } from "./NumberField/NumberField.js";
|
|
70
|
+
import { SECRETFIELD_LABELS, SecretField } from "./SecretField/SecretField.js";
|
|
71
|
+
import { Footer, FooterBottom, FooterGroup, FooterLink } from "./Footer/Footer.js";
|
|
72
|
+
import { Media } from "./Media/Media.js";
|
|
73
|
+
import { Quote } from "./Quote/Quote.js";
|
|
74
|
+
import { Kbd } from "./Kbd/Kbd.js";
|
|
75
|
+
import { Tag } from "./Tag/Tag.js";
|
|
76
|
+
import { Hairline } from "./Hairline/Hairline.js";
|
|
77
|
+
import { SKIPLINK_LABELS, SkipLink } from "./SkipLink/SkipLink.js";
|
|
78
|
+
import { Prose } from "./Prose/Prose.js";
|
|
79
|
+
import { useClipboard } from "./utils/useClipboard.js";
|
|
80
|
+
import { CODE_LABELS, Code } from "./Code/Code.js";
|
|
81
|
+
import { useScrollSpy } from "./utils/useScrollSpy.js";
|
|
82
|
+
import { CONTENTS_LABELS, Contents } from "./Contents/Contents.js";
|
|
83
|
+
import { Rail, RailGroup, RailLink } from "./Rail/Rail.js";
|
|
84
|
+
import { PAGENAV_LABELS, PageNav } from "./PageNav/PageNav.js";
|
|
63
85
|
import { crumbPath } from "./lib/crumb.js";
|
|
64
86
|
import { COMPACT_QUERY, useMediaQuery } from "./utils/useMediaQuery.js";
|
|
65
87
|
import { DOCK_LABELS, Dock } from "./Dock/Dock.js";
|
|
@@ -72,4 +94,4 @@ import { RATING_LABELS, Rating } from "./Rating/Rating.js";
|
|
|
72
94
|
import { TABLE_LABELS, Table } from "./Table/Table.js";
|
|
73
95
|
import { CAROUSEL_LABELS, Carousel } from "./Carousel/Carousel.js";
|
|
74
96
|
import { focusHit, useFindInPage } from "./utils/useFindInPage.js";
|
|
75
|
-
export { AccentScope, AnimationGroup, Avatar, Bento, Bloom, Bubble, Button, CAROUSEL_LABELS, CHOICE_LABELS, COMPACT_QUERY, CONTRAST_MIN, Card, Carousel, Cell, Checkbox, Chip, Choice, ColorSchemeScript, Count, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, Dialog, Dock, Empty, FILTERS_LABELS, FOCUSABLE, Fact, Field, Filters, Flow, Fold, Frame, Ground, Hint, Link, List, ListRow, Mark, Menu, MenuItem, NOTICE_LABELS, Notice, PAGES_LABELS, Pages, Placeholder, Portal, Progress, RATING_LABELS, Radio, RadioGroup, Range, Rating, ResultRow, SEARCH_LABELS, SETTINGS_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, Search, Segmented, Settings, Sheet, Shelf, SlurpProvider, Stage, Steps, Suggest, Surface, Swatch, SwatchGroup, Switch, TABLE_LABELS, TOAST_LABELS, Table, Tabs, Text, Tile, ToastProvider, VisuallyHidden, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
|
97
|
+
export { AccentScope, AnimationGroup, Avatar, Bento, Bloom, Bubble, Button, CALENDAR_LABELS, CAROUSEL_LABELS, CHOICE_LABELS, CODE_LABELS, COMPACT_QUERY, CONTENTS_LABELS, CONTRAST_MIN, Calendar, Card, Carousel, Cell, Checkbox, Chip, Choice, Code, ColorSchemeScript, Contents, Count, DATEFIELD_LABELS, DEFAULT_STORAGE_KEY, DIALOG_LABELS, DOCK_LABELS, DateField, Dialog, Dock, ERRORSUMMARY_LABELS, Empty, ErrorSummary, FILEDROP_LABELS, FILTERS_LABELS, FOCUSABLE, Fact, Field, FileDrop, Filters, Flow, Fold, Footer, FooterBottom, FooterGroup, FooterLink, Frame, Ground, Hairline, Hint, Kbd, Link, List, ListRow, Mark, Media, Menu, MenuItem, NOTICE_LABELS, NUMBERFIELD_LABELS, Notice, NumberField, PAGENAV_LABELS, PAGES_LABELS, PageNav, Pages, PinField, Placeholder, Portal, Progress, Prose, Quote, RATING_LABELS, Radio, RadioGroup, Rail, RailGroup, RailLink, Range, Rating, ResultRow, SEARCH_LABELS, SECRETFIELD_LABELS, SETTINGS_LABELS, SKIPLINK_LABELS, STEPS_LABELS, SUGGEST_LABELS, Score, Search, SecretField, Segmented, Settings, Sheet, Shelf, SkipLink, SlurpProvider, Stage, Steps, Suggest, Surface, Swatch, SwatchGroup, Switch, TABLE_LABELS, TOAST_LABELS, Table, Tabs, Tag, Text, Tile, ToastProvider, VisuallyHidden, alpha, bentoLayout, contrast, createTheme, crumbPath, focusFirst, focusHit, labelsEn, labelsIt, matchRanges, matchesAll, meetsContrast, moveFocus, normalizeText, onColor, pageItems, useAnimationTarget, useClipboard, useColorScheme, useControlled, useDismiss, useFindInPage, useForkRef, useMediaQuery, useRovingFocus, useScrollSpy, useSlurp, useSlurpEnter, useSlurpNavigate, useTheme, useToast, vivid };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
// src/internal/labels.ts
|
|
4
|
+
/** Texts set by the nearest SlurpProvider with `labels` (none: the components' Italian defaults). */
|
|
5
|
+
const LabelsContext = createContext({});
|
|
6
|
+
/** This component's texts from the provider; spread between its defaults and its own `labels` prop. */
|
|
7
|
+
function useLabels(name) {
|
|
8
|
+
return useContext(LabelsContext)[name] ?? {};
|
|
9
|
+
}
|
|
10
|
+
export { LabelsContext, useLabels };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","names":[],"sources":["../../src/internal/labels.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport type { SlurpLabels } from '../lib/labels';\n\n/** Texts set by the nearest SlurpProvider with `labels` (none: the components' Italian defaults). */\nexport const LabelsContext = createContext<SlurpLabels>({});\n\n/** This component's texts from the provider; spread between its defaults and its own `labels` prop. */\nexport function useLabels<K extends keyof SlurpLabels>(name: K): NonNullable<SlurpLabels[K]> {\n return (useContext(LabelsContext)[name] ?? {}) as NonNullable<SlurpLabels[K]>;\n}\n"],"mappings":";;;;AAKA,MAAa,gBAAgB,cAA2B,CAAC,CAAC;;AAG1D,SAAgB,UAAuC,MAAsC;CAC3F,OAAQ,WAAW,aAAa,CAAC,CAAC,SAAS,CAAC;AAC9C"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
import { CalendarLabels } from "../Calendar/Calendar.js";
|
|
3
|
+
import { CarouselLabels } from "../Carousel/Carousel.js";
|
|
4
|
+
import { ChoiceLabels } from "../Choice/Choice.js";
|
|
5
|
+
import { CodeLabels } from "../Code/Code.js";
|
|
6
|
+
import { ContentsLabels } from "../Contents/Contents.js";
|
|
7
|
+
import { DateFieldLabels } from "../DateField/DateField.js";
|
|
8
|
+
import { DialogLabels } from "../Dialog/Dialog.js";
|
|
9
|
+
import { DockLabels } from "../Dock/Dock.js";
|
|
10
|
+
import { ErrorSummaryLabels } from "../ErrorSummary/ErrorSummary.js";
|
|
11
|
+
import { FileDropLabels } from "../FileDrop/FileDrop.js";
|
|
12
|
+
import { FiltersLabels } from "../Filters/Filters.js";
|
|
13
|
+
import { NoticeLabels } from "../Notice/Notice.js";
|
|
14
|
+
import { NumberFieldLabels } from "../NumberField/NumberField.js";
|
|
15
|
+
import { PageNavLabels } from "../PageNav/PageNav.js";
|
|
16
|
+
import { PagesLabels } from "../Pages/Pages.js";
|
|
17
|
+
import { RatingLabels } from "../Rating/Rating.js";
|
|
18
|
+
import { SearchLabels } from "../Search/Search.js";
|
|
19
|
+
import { SecretFieldLabels } from "../SecretField/SecretField.js";
|
|
20
|
+
import { SettingsLabels } from "../Settings/Settings.js";
|
|
21
|
+
import { SkipLinkLabels } from "../SkipLink/SkipLink.js";
|
|
22
|
+
import { StepsLabels } from "../Steps/Steps.js";
|
|
23
|
+
import { SuggestLabels } from "../Suggest/Suggest.js";
|
|
24
|
+
import { TableLabels } from "../Table/Table.js";
|
|
25
|
+
import { ToastLabels } from "../Toast/Toast.js";
|
|
26
|
+
/** The texts of every component that has some, by component. Dialog's also apply to Sheet. */
|
|
27
|
+
export interface SlurpLabels {
|
|
28
|
+
SecretField?: Partial<SecretFieldLabels>;
|
|
29
|
+
NumberField?: Partial<NumberFieldLabels>;
|
|
30
|
+
FileDrop?: Partial<FileDropLabels>;
|
|
31
|
+
ErrorSummary?: Partial<ErrorSummaryLabels>;
|
|
32
|
+
DateField?: Partial<DateFieldLabels>;
|
|
33
|
+
Calendar?: Partial<CalendarLabels>;
|
|
34
|
+
Carousel?: Partial<CarouselLabels>;
|
|
35
|
+
Choice?: Partial<ChoiceLabels>;
|
|
36
|
+
Code?: Partial<CodeLabels>;
|
|
37
|
+
Contents?: Partial<ContentsLabels>;
|
|
38
|
+
Dialog?: Partial<DialogLabels>;
|
|
39
|
+
Dock?: Partial<DockLabels>;
|
|
40
|
+
Filters?: Partial<FiltersLabels>;
|
|
41
|
+
Notice?: Partial<NoticeLabels>;
|
|
42
|
+
PageNav?: Partial<PageNavLabels>;
|
|
43
|
+
Pages?: Partial<PagesLabels>;
|
|
44
|
+
Rating?: Partial<RatingLabels>;
|
|
45
|
+
Search?: Partial<SearchLabels>;
|
|
46
|
+
Settings?: Partial<SettingsLabels>;
|
|
47
|
+
SkipLink?: Partial<SkipLinkLabels>;
|
|
48
|
+
Steps?: Partial<StepsLabels>;
|
|
49
|
+
Suggest?: Partial<SuggestLabels>;
|
|
50
|
+
Table?: Partial<TableLabels>;
|
|
51
|
+
Toast?: Partial<ToastLabels>;
|
|
52
|
+
}
|
|
53
|
+
/** A built-in language (a plain string, so a server component can pass it) or your own texts. */
|
|
54
|
+
export type LabelsInput = 'it' | 'en' | SlurpLabels;
|
|
55
|
+
/** English texts for every component. Italian is the components' own default. */
|
|
56
|
+
export declare const labelsEn: {
|
|
57
|
+
Calendar: {
|
|
58
|
+
previous: string;
|
|
59
|
+
next: string;
|
|
60
|
+
};
|
|
61
|
+
DateField: {
|
|
62
|
+
placeholder: string;
|
|
63
|
+
};
|
|
64
|
+
ErrorSummary: {
|
|
65
|
+
title: (n: number) => string;
|
|
66
|
+
};
|
|
67
|
+
FileDrop: {
|
|
68
|
+
browse: string;
|
|
69
|
+
drop: string;
|
|
70
|
+
remove: (name: string) => string;
|
|
71
|
+
};
|
|
72
|
+
NumberField: {
|
|
73
|
+
decrement: string;
|
|
74
|
+
increment: string;
|
|
75
|
+
};
|
|
76
|
+
SecretField: {
|
|
77
|
+
show: string;
|
|
78
|
+
};
|
|
79
|
+
Carousel: {
|
|
80
|
+
previous: string;
|
|
81
|
+
next: string;
|
|
82
|
+
slide: (i: number, n: number) => string;
|
|
83
|
+
show: (i: number, n: number) => string;
|
|
84
|
+
picker: string;
|
|
85
|
+
};
|
|
86
|
+
Choice: {
|
|
87
|
+
placeholder: string;
|
|
88
|
+
};
|
|
89
|
+
Code: {
|
|
90
|
+
copy: string;
|
|
91
|
+
copied: string;
|
|
92
|
+
region: string;
|
|
93
|
+
};
|
|
94
|
+
Contents: {
|
|
95
|
+
title: string;
|
|
96
|
+
};
|
|
97
|
+
Dialog: {
|
|
98
|
+
close: string;
|
|
99
|
+
};
|
|
100
|
+
Dock: {
|
|
101
|
+
navigation: string;
|
|
102
|
+
crumbs: string;
|
|
103
|
+
back: string;
|
|
104
|
+
search: string;
|
|
105
|
+
searchPlaceholder: string;
|
|
106
|
+
noResults: string;
|
|
107
|
+
matches: (i: number, n: number) => string;
|
|
108
|
+
nextMatch: (i: number, n: number) => string;
|
|
109
|
+
resultsHint: string;
|
|
110
|
+
};
|
|
111
|
+
Filters: {
|
|
112
|
+
title: string;
|
|
113
|
+
reset: string;
|
|
114
|
+
};
|
|
115
|
+
Notice: {
|
|
116
|
+
neutral: string;
|
|
117
|
+
success: string;
|
|
118
|
+
warning: string;
|
|
119
|
+
danger: string;
|
|
120
|
+
dismiss: string;
|
|
121
|
+
};
|
|
122
|
+
PageNav: {
|
|
123
|
+
label: string;
|
|
124
|
+
previous: string;
|
|
125
|
+
next: string;
|
|
126
|
+
};
|
|
127
|
+
Pages: {
|
|
128
|
+
label: string;
|
|
129
|
+
previous: string;
|
|
130
|
+
next: string;
|
|
131
|
+
page: (n: number) => string;
|
|
132
|
+
status: (n: number, count: number) => string;
|
|
133
|
+
};
|
|
134
|
+
Rating: {
|
|
135
|
+
value: (v: string, max: number) => string;
|
|
136
|
+
star: (n: number) => string;
|
|
137
|
+
};
|
|
138
|
+
Search: {
|
|
139
|
+
label: string;
|
|
140
|
+
placeholder: string;
|
|
141
|
+
clear: string;
|
|
142
|
+
results: (n: number) => string;
|
|
143
|
+
};
|
|
144
|
+
Settings: {
|
|
145
|
+
open: string;
|
|
146
|
+
close: string;
|
|
147
|
+
title: string;
|
|
148
|
+
theme: string;
|
|
149
|
+
system: string;
|
|
150
|
+
light: string;
|
|
151
|
+
dark: string;
|
|
152
|
+
language: string;
|
|
153
|
+
};
|
|
154
|
+
SkipLink: {
|
|
155
|
+
label: string;
|
|
156
|
+
};
|
|
157
|
+
Steps: {
|
|
158
|
+
label: string;
|
|
159
|
+
done: string;
|
|
160
|
+
};
|
|
161
|
+
Suggest: {
|
|
162
|
+
results: (n: number) => string;
|
|
163
|
+
empty: string;
|
|
164
|
+
};
|
|
165
|
+
Table: {
|
|
166
|
+
empty: string;
|
|
167
|
+
};
|
|
168
|
+
Toast: {
|
|
169
|
+
region: string;
|
|
170
|
+
dismiss: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
/** Italian, the components' own defaults: nothing to swap. */
|
|
174
|
+
export declare const labelsIt: SlurpLabels;
|
|
175
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
// src/lib/labels.ts
|
|
3
|
+
/** English texts for every component. Italian is the components' own default. */
|
|
4
|
+
const labelsEn = {
|
|
5
|
+
Calendar: {
|
|
6
|
+
previous: "Previous month",
|
|
7
|
+
next: "Next month"
|
|
8
|
+
},
|
|
9
|
+
DateField: { placeholder: "Pick a date" },
|
|
10
|
+
ErrorSummary: { title: (n) => n === 1 ? "There is 1 error to fix" : `There are ${n} errors to fix` },
|
|
11
|
+
FileDrop: {
|
|
12
|
+
browse: "Choose files",
|
|
13
|
+
drop: "or drop them here",
|
|
14
|
+
remove: (name) => `Remove ${name}`
|
|
15
|
+
},
|
|
16
|
+
NumberField: {
|
|
17
|
+
decrement: "Decrease",
|
|
18
|
+
increment: "Increase"
|
|
19
|
+
},
|
|
20
|
+
SecretField: { show: "Show the password" },
|
|
21
|
+
Carousel: {
|
|
22
|
+
previous: "Previous",
|
|
23
|
+
next: "Next",
|
|
24
|
+
slide: (i, n) => `${i} of ${n}`,
|
|
25
|
+
show: (i, n) => `Show ${i} of ${n}`,
|
|
26
|
+
picker: "Choose what to show"
|
|
27
|
+
},
|
|
28
|
+
Choice: { placeholder: "Choose…" },
|
|
29
|
+
Code: {
|
|
30
|
+
copy: "Copy the code",
|
|
31
|
+
copied: "Copied",
|
|
32
|
+
region: "Code"
|
|
33
|
+
},
|
|
34
|
+
Contents: { title: "On this page" },
|
|
35
|
+
Dialog: { close: "Close" },
|
|
36
|
+
Dock: {
|
|
37
|
+
navigation: "Navigation",
|
|
38
|
+
crumbs: "Path",
|
|
39
|
+
back: "Back",
|
|
40
|
+
search: "Search",
|
|
41
|
+
searchPlaceholder: "Search…",
|
|
42
|
+
noResults: "No results",
|
|
43
|
+
matches: (i, n) => `${n === 1 ? "1 match" : `${n} matches`}, ${i} of ${n}`,
|
|
44
|
+
nextMatch: (i, n) => `Go to the next match: ${i} of ${n}`,
|
|
45
|
+
resultsHint: "Arrow down to browse the results, Escape to close them."
|
|
46
|
+
},
|
|
47
|
+
Filters: {
|
|
48
|
+
title: "Filters",
|
|
49
|
+
reset: "Reset filters"
|
|
50
|
+
},
|
|
51
|
+
Notice: {
|
|
52
|
+
neutral: "Note",
|
|
53
|
+
success: "Done",
|
|
54
|
+
warning: "Warning",
|
|
55
|
+
danger: "Error",
|
|
56
|
+
dismiss: "Dismiss notice"
|
|
57
|
+
},
|
|
58
|
+
PageNav: {
|
|
59
|
+
label: "Previous and next page",
|
|
60
|
+
previous: "Previous",
|
|
61
|
+
next: "Next"
|
|
62
|
+
},
|
|
63
|
+
Pages: {
|
|
64
|
+
label: "Pages",
|
|
65
|
+
previous: "Previous page",
|
|
66
|
+
next: "Next page",
|
|
67
|
+
page: (n) => `Page ${n}`,
|
|
68
|
+
status: (n, count) => `${n} of ${count}`
|
|
69
|
+
},
|
|
70
|
+
Rating: {
|
|
71
|
+
value: (v, max) => `${v} out of ${max}`,
|
|
72
|
+
star: (n) => n === 1 ? "1 star" : `${n} stars`
|
|
73
|
+
},
|
|
74
|
+
Search: {
|
|
75
|
+
label: "Search",
|
|
76
|
+
placeholder: "Search…",
|
|
77
|
+
clear: "Clear the search",
|
|
78
|
+
results: (n) => n === 0 ? "No results" : n === 1 ? "1 result" : `${n} results`
|
|
79
|
+
},
|
|
80
|
+
Settings: {
|
|
81
|
+
open: "Settings",
|
|
82
|
+
close: "Close settings",
|
|
83
|
+
title: "Settings",
|
|
84
|
+
theme: "Theme",
|
|
85
|
+
system: "Automatic",
|
|
86
|
+
light: "Light",
|
|
87
|
+
dark: "Dark",
|
|
88
|
+
language: "Language"
|
|
89
|
+
},
|
|
90
|
+
SkipLink: { label: "Skip to content" },
|
|
91
|
+
Steps: {
|
|
92
|
+
label: "Steps",
|
|
93
|
+
done: "completed"
|
|
94
|
+
},
|
|
95
|
+
Suggest: {
|
|
96
|
+
results: (n) => n === 1 ? "1 suggestion" : `${n} suggestions`,
|
|
97
|
+
empty: "No suggestions"
|
|
98
|
+
},
|
|
99
|
+
Table: { empty: "No items" },
|
|
100
|
+
Toast: {
|
|
101
|
+
region: "Notifications",
|
|
102
|
+
dismiss: "Dismiss notification"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/** Italian, the components' own defaults: nothing to swap. */
|
|
106
|
+
const labelsIt = {};
|
|
107
|
+
/** Resolves a provider's `labels` prop to texts by component. */
|
|
108
|
+
function resolveLabels(input) {
|
|
109
|
+
if (input === void 0) return void 0;
|
|
110
|
+
if (input === "en") return labelsEn;
|
|
111
|
+
if (input === "it") return labelsIt;
|
|
112
|
+
return input;
|
|
113
|
+
}
|
|
114
|
+
export { labelsEn, labelsIt, resolveLabels };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","names":[],"sources":["../../src/lib/labels.ts"],"sourcesContent":["// Texts of the components, per language. Not an i18n system: every component keeps its Italian defaults and its\n// `labels` prop; a SlurpProvider can swap them all at once with a preset ('en') or an object.\nimport type { CarouselLabels } from '../Carousel/Carousel';\nimport type { SecretFieldLabels } from '../SecretField/SecretField';\nimport type { NumberFieldLabels } from '../NumberField/NumberField';\nimport type { FileDropLabels } from '../FileDrop/FileDrop';\nimport type { ErrorSummaryLabels } from '../ErrorSummary/ErrorSummary';\nimport type { DateFieldLabels } from '../DateField/DateField';\nimport type { CalendarLabels } from '../Calendar/Calendar';\nimport type { CodeLabels } from '../Code/Code';\nimport type { ContentsLabels } from '../Contents/Contents';\nimport type { PageNavLabels } from '../PageNav/PageNav';\nimport type { SkipLinkLabels } from '../SkipLink/SkipLink';\nimport type { ChoiceLabels } from '../Choice/Choice';\nimport type { DialogLabels } from '../Dialog/Dialog';\nimport type { DockLabels } from '../Dock/Dock';\nimport type { FiltersLabels } from '../Filters/Filters';\nimport type { NoticeLabels } from '../Notice/Notice';\nimport type { PagesLabels } from '../Pages/Pages';\nimport type { RatingLabels } from '../Rating/Rating';\nimport type { SearchLabels } from '../Search/Search';\nimport type { SettingsLabels } from '../Settings/Settings';\nimport type { StepsLabels } from '../Steps/Steps';\nimport type { SuggestLabels } from '../Suggest/Suggest';\nimport type { TableLabels } from '../Table/Table';\nimport type { ToastLabels } from '../Toast/Toast';\n\n/** The texts of every component that has some, by component. Dialog's also apply to Sheet. */\nexport interface SlurpLabels {\n SecretField?: Partial<SecretFieldLabels>;\n NumberField?: Partial<NumberFieldLabels>;\n FileDrop?: Partial<FileDropLabels>;\n ErrorSummary?: Partial<ErrorSummaryLabels>;\n DateField?: Partial<DateFieldLabels>;\n Calendar?: Partial<CalendarLabels>;\n Carousel?: Partial<CarouselLabels>;\n Choice?: Partial<ChoiceLabels>;\n Code?: Partial<CodeLabels>;\n Contents?: Partial<ContentsLabels>;\n Dialog?: Partial<DialogLabels>;\n Dock?: Partial<DockLabels>;\n Filters?: Partial<FiltersLabels>;\n Notice?: Partial<NoticeLabels>;\n PageNav?: Partial<PageNavLabels>;\n Pages?: Partial<PagesLabels>;\n Rating?: Partial<RatingLabels>;\n Search?: Partial<SearchLabels>;\n Settings?: Partial<SettingsLabels>;\n SkipLink?: Partial<SkipLinkLabels>;\n Steps?: Partial<StepsLabels>;\n Suggest?: Partial<SuggestLabels>;\n Table?: Partial<TableLabels>;\n Toast?: Partial<ToastLabels>;\n}\n\n/** A built-in language (a plain string, so a server component can pass it) or your own texts. */\nexport type LabelsInput = 'it' | 'en' | SlurpLabels;\n\n/** English texts for every component. Italian is the components' own default. */\nexport const labelsEn = {\n Calendar: { previous: 'Previous month', next: 'Next month' },\n DateField: { placeholder: 'Pick a date' },\n ErrorSummary: {\n title: (n) => (n === 1 ? 'There is 1 error to fix' : `There are ${n} errors to fix`),\n },\n FileDrop: {\n browse: 'Choose files',\n drop: 'or drop them here',\n remove: (name) => `Remove ${name}`,\n },\n NumberField: { decrement: 'Decrease', increment: 'Increase' },\n SecretField: { show: 'Show the password' },\n Carousel: {\n previous: 'Previous',\n next: 'Next',\n slide: (i, n) => `${i} of ${n}`,\n show: (i, n) => `Show ${i} of ${n}`,\n picker: 'Choose what to show',\n },\n Choice: { placeholder: 'Choose…' },\n Code: { copy: 'Copy the code', copied: 'Copied', region: 'Code' },\n Contents: { title: 'On this page' },\n Dialog: { close: 'Close' },\n Dock: {\n navigation: 'Navigation',\n crumbs: 'Path',\n back: 'Back',\n search: 'Search',\n searchPlaceholder: 'Search…',\n noResults: 'No results',\n matches: (i, n) => `${n === 1 ? '1 match' : `${n} matches`}, ${i} of ${n}`,\n nextMatch: (i, n) => `Go to the next match: ${i} of ${n}`,\n resultsHint: 'Arrow down to browse the results, Escape to close them.',\n },\n Filters: { title: 'Filters', reset: 'Reset filters' },\n Notice: {\n neutral: 'Note',\n success: 'Done',\n warning: 'Warning',\n danger: 'Error',\n dismiss: 'Dismiss notice',\n },\n PageNav: { label: 'Previous and next page', previous: 'Previous', next: 'Next' },\n Pages: {\n label: 'Pages',\n previous: 'Previous page',\n next: 'Next page',\n page: (n) => `Page ${n}`,\n status: (n, count) => `${n} of ${count}`,\n },\n Rating: {\n value: (v, max) => `${v} out of ${max}`,\n star: (n) => (n === 1 ? '1 star' : `${n} stars`),\n },\n Search: {\n label: 'Search',\n placeholder: 'Search…',\n clear: 'Clear the search',\n results: (n) => (n === 0 ? 'No results' : n === 1 ? '1 result' : `${n} results`),\n },\n Settings: {\n open: 'Settings',\n close: 'Close settings',\n title: 'Settings',\n theme: 'Theme',\n system: 'Automatic',\n light: 'Light',\n dark: 'Dark',\n language: 'Language',\n },\n SkipLink: { label: 'Skip to content' },\n Steps: { label: 'Steps', done: 'completed' },\n Suggest: {\n results: (n) => (n === 1 ? '1 suggestion' : `${n} suggestions`),\n empty: 'No suggestions',\n },\n Table: { empty: 'No items' },\n Toast: { region: 'Notifications', dismiss: 'Dismiss notification' },\n} satisfies Required<SlurpLabels>;\n\n/** Italian, the components' own defaults: nothing to swap. */\nexport const labelsIt: SlurpLabels = {};\n\n/** Resolves a provider's `labels` prop to texts by component. */\nexport function resolveLabels(input: LabelsInput | undefined): SlurpLabels | undefined {\n if (input === undefined) return undefined;\n if (input === 'en') return labelsEn;\n if (input === 'it') return labelsIt;\n return input;\n}\n"],"mappings":";;;AA2DA,MAAa,WAAW;CACtB,UAAU;EAAE,UAAU;EAAkB,MAAM;CAAa;CAC3D,WAAW,EAAE,aAAa,cAAc;CACxC,cAAc,EACZ,QAAQ,MAAO,MAAM,IAAI,4BAA4B,aAAa,EAAE,gBACtE;CACA,UAAU;EACR,QAAQ;EACR,MAAM;EACN,SAAS,SAAS,UAAU;CAC9B;CACA,aAAa;EAAE,WAAW;EAAY,WAAW;CAAW;CAC5D,aAAa,EAAE,MAAM,oBAAoB;CACzC,UAAU;EACR,UAAU;EACV,MAAM;EACN,QAAQ,GAAG,MAAM,GAAG,EAAE,MAAM;EAC5B,OAAO,GAAG,MAAM,QAAQ,EAAE,MAAM;EAChC,QAAQ;CACV;CACA,QAAQ,EAAE,aAAa,UAAU;CACjC,MAAM;EAAE,MAAM;EAAiB,QAAQ;EAAU,QAAQ;CAAO;CAChE,UAAU,EAAE,OAAO,eAAe;CAClC,QAAQ,EAAE,OAAO,QAAQ;CACzB,MAAM;EACJ,YAAY;EACZ,QAAQ;EACR,MAAM;EACN,QAAQ;EACR,mBAAmB;EACnB,WAAW;EACX,UAAU,GAAG,MAAM,GAAG,MAAM,IAAI,YAAY,GAAG,EAAE,UAAU,IAAI,EAAE,MAAM;EACvE,YAAY,GAAG,MAAM,yBAAyB,EAAE,MAAM;EACtD,aAAa;CACf;CACA,SAAS;EAAE,OAAO;EAAW,OAAO;CAAgB;CACpD,QAAQ;EACN,SAAS;EACT,SAAS;EACT,SAAS;EACT,QAAQ;EACR,SAAS;CACX;CACA,SAAS;EAAE,OAAO;EAA0B,UAAU;EAAY,MAAM;CAAO;CAC/E,OAAO;EACL,OAAO;EACP,UAAU;EACV,MAAM;EACN,OAAO,MAAM,QAAQ;EACrB,SAAS,GAAG,UAAU,GAAG,EAAE,MAAM;CACnC;CACA,QAAQ;EACN,QAAQ,GAAG,QAAQ,GAAG,EAAE,UAAU;EAClC,OAAO,MAAO,MAAM,IAAI,WAAW,GAAG,EAAE;CAC1C;CACA,QAAQ;EACN,OAAO;EACP,aAAa;EACb,OAAO;EACP,UAAU,MAAO,MAAM,IAAI,eAAe,MAAM,IAAI,aAAa,GAAG,EAAE;CACxE;CACA,UAAU;EACR,MAAM;EACN,OAAO;EACP,OAAO;EACP,OAAO;EACP,QAAQ;EACR,OAAO;EACP,MAAM;EACN,UAAU;CACZ;CACA,UAAU,EAAE,OAAO,kBAAkB;CACrC,OAAO;EAAE,OAAO;EAAS,MAAM;CAAY;CAC3C,SAAS;EACP,UAAU,MAAO,MAAM,IAAI,iBAAiB,GAAG,EAAE;EACjD,OAAO;CACT;CACA,OAAO,EAAE,OAAO,WAAW;CAC3B,OAAO;EAAE,QAAQ;EAAiB,SAAS;CAAuB;AACpE;;AAGA,MAAa,WAAwB,CAAC;;AAGtC,SAAgB,cAAc,OAAyD;CACrF,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO;AACT"}
|
package/dist/lib/theme.d.ts
CHANGED
|
@@ -6,50 +6,69 @@ import { BentoProps } from "../Bento/Bento.js";
|
|
|
6
6
|
import { BloomProps } from "../Bloom/Bloom.js";
|
|
7
7
|
import { ButtonProps } from "../Button/Button.js";
|
|
8
8
|
import { BubbleProps } from "../Bubble/Bubble.js";
|
|
9
|
+
import { CalendarProps } from "../Calendar/Calendar.js";
|
|
9
10
|
import { CardProps } from "../Card/Card.js";
|
|
10
11
|
import { CarouselProps } from "../Carousel/Carousel.js";
|
|
11
12
|
import { CellProps } from "../Cell/Cell.js";
|
|
12
13
|
import { CheckboxProps } from "../Checkbox/Checkbox.js";
|
|
13
14
|
import { ChipProps } from "../Chip/Chip.js";
|
|
14
15
|
import { ChoiceProps } from "../Choice/Choice.js";
|
|
16
|
+
import { CodeProps } from "../Code/Code.js";
|
|
17
|
+
import { ContentsProps } from "../Contents/Contents.js";
|
|
15
18
|
import { CountProps } from "../Count/Count.js";
|
|
19
|
+
import { DateFieldProps } from "../DateField/DateField.js";
|
|
16
20
|
import { DialogProps } from "../Dialog/Dialog.js";
|
|
17
21
|
import { DockProps } from "../Dock/Dock.js";
|
|
18
22
|
import { EmptyProps } from "../Empty/Empty.js";
|
|
23
|
+
import { ErrorSummaryProps } from "../ErrorSummary/ErrorSummary.js";
|
|
19
24
|
import { FactProps } from "../Fact/Fact.js";
|
|
20
25
|
import { FieldProps } from "../Field/Field.js";
|
|
26
|
+
import { FileDropProps } from "../FileDrop/FileDrop.js";
|
|
21
27
|
import { FiltersProps } from "../Filters/Filters.js";
|
|
22
28
|
import { FlowProps } from "../Flow/Flow.js";
|
|
23
29
|
import { FoldProps } from "../Fold/Fold.js";
|
|
30
|
+
import { FooterProps } from "../Footer/Footer.js";
|
|
24
31
|
import { FrameProps } from "../Frame/Frame.js";
|
|
32
|
+
import { HairlineProps } from "../Hairline/Hairline.js";
|
|
25
33
|
import { HintProps } from "../Hint/Hint.js";
|
|
34
|
+
import { KbdProps } from "../Kbd/Kbd.js";
|
|
26
35
|
import { LinkProps } from "../Link/Link.js";
|
|
27
36
|
import { ListProps, ListRowProps } from "../ListRow/ListRow.js";
|
|
37
|
+
import { MediaProps } from "../Media/Media.js";
|
|
28
38
|
import { MenuProps } from "../Menu/Menu.js";
|
|
29
39
|
import { NoticeProps } from "../Notice/Notice.js";
|
|
40
|
+
import { NumberFieldProps } from "../NumberField/NumberField.js";
|
|
41
|
+
import { PageNavProps } from "../PageNav/PageNav.js";
|
|
30
42
|
import { PagesProps } from "../Pages/Pages.js";
|
|
43
|
+
import { PinFieldProps } from "../PinField/PinField.js";
|
|
31
44
|
import { PlaceholderProps } from "../Placeholder/Placeholder.js";
|
|
32
45
|
import { ProgressProps } from "../Progress/Progress.js";
|
|
46
|
+
import { ProseProps } from "../Prose/Prose.js";
|
|
47
|
+
import { QuoteProps } from "../Quote/Quote.js";
|
|
33
48
|
import { RadioGroupProps, RadioProps } from "../Radio/Radio.js";
|
|
49
|
+
import { RailProps } from "../Rail/Rail.js";
|
|
34
50
|
import { RangeProps } from "../Range/Range.js";
|
|
35
51
|
import { RatingProps } from "../Rating/Rating.js";
|
|
36
52
|
import { ResultRowProps } from "../ResultRow/ResultRow.js";
|
|
37
53
|
import { ScoreProps } from "../Score/Score.js";
|
|
38
54
|
import { SearchProps } from "../Search/Search.js";
|
|
55
|
+
import { SecretFieldProps } from "../SecretField/SecretField.js";
|
|
39
56
|
import { SegmentedProps } from "../Segmented/Segmented.js";
|
|
40
57
|
import { SettingsProps } from "../Settings/Settings.js";
|
|
41
58
|
import { SheetProps } from "../Sheet/Sheet.js";
|
|
42
59
|
import { ShelfProps } from "../Shelf/Shelf.js";
|
|
43
|
-
import {
|
|
44
|
-
import { TileProps } from "../Tile/Tile.js";
|
|
60
|
+
import { SkipLinkProps } from "../SkipLink/SkipLink.js";
|
|
45
61
|
import { StepsProps } from "../Steps/Steps.js";
|
|
46
62
|
import { SuggestProps } from "../Suggest/Suggest.js";
|
|
47
63
|
import { TableProps } from "../Table/Table.js";
|
|
64
|
+
import { StageProps } from "../Stage/Stage.js";
|
|
65
|
+
import { TileProps } from "../Tile/Tile.js";
|
|
48
66
|
import { SurfaceProps } from "../Surface/Surface.js";
|
|
49
67
|
import { SwatchGroupProps, SwatchProps } from "../Swatch/Swatch.js";
|
|
50
68
|
import { SwitchProps } from "../Switch/Switch.js";
|
|
51
69
|
import { TabsProps } from "../Tabs/Tabs.js";
|
|
52
70
|
import { TextProps } from "../Text/Text.js";
|
|
71
|
+
import { TagProps } from "../Tag/Tag.js";
|
|
53
72
|
import { GhostKind, SlurpDefaults } from "@slurp-ui/motion";
|
|
54
73
|
import { ColorToken, HueToken, RadiusToken, SpaceToken, blur, shadow } from "@slurp-ui/tokens";
|
|
55
74
|
export type ColorSchemeMode = 'light' | 'dark' | 'system';
|
|
@@ -76,10 +95,86 @@ export interface MotionOptions extends Pick<SlurpDefaults, 'duration' | 'stagger
|
|
|
76
95
|
}
|
|
77
96
|
/** Components that read defaults and `css` overrides from the theme, with their parts. */
|
|
78
97
|
export interface ThemeComponents {
|
|
98
|
+
DateField: {
|
|
99
|
+
props: DateFieldProps;
|
|
100
|
+
parts: 'root';
|
|
101
|
+
};
|
|
102
|
+
Calendar: {
|
|
103
|
+
props: CalendarProps;
|
|
104
|
+
parts: 'root';
|
|
105
|
+
};
|
|
106
|
+
FileDrop: {
|
|
107
|
+
props: FileDropProps;
|
|
108
|
+
parts: 'root';
|
|
109
|
+
};
|
|
110
|
+
ErrorSummary: {
|
|
111
|
+
props: ErrorSummaryProps;
|
|
112
|
+
parts: 'root';
|
|
113
|
+
};
|
|
114
|
+
PinField: {
|
|
115
|
+
props: PinFieldProps;
|
|
116
|
+
parts: 'root';
|
|
117
|
+
};
|
|
118
|
+
NumberField: {
|
|
119
|
+
props: NumberFieldProps;
|
|
120
|
+
parts: 'root';
|
|
121
|
+
};
|
|
122
|
+
SecretField: {
|
|
123
|
+
props: SecretFieldProps;
|
|
124
|
+
parts: 'root';
|
|
125
|
+
};
|
|
126
|
+
Footer: {
|
|
127
|
+
props: FooterProps;
|
|
128
|
+
parts: 'root';
|
|
129
|
+
};
|
|
130
|
+
Media: {
|
|
131
|
+
props: MediaProps;
|
|
132
|
+
parts: 'root' | 'frame' | 'media' | 'caption';
|
|
133
|
+
};
|
|
134
|
+
Quote: {
|
|
135
|
+
props: QuoteProps;
|
|
136
|
+
parts: 'root' | 'quote' | 'caption';
|
|
137
|
+
};
|
|
138
|
+
Kbd: {
|
|
139
|
+
props: KbdProps;
|
|
140
|
+
parts: 'root';
|
|
141
|
+
};
|
|
142
|
+
Tag: {
|
|
143
|
+
props: TagProps;
|
|
144
|
+
parts: 'root';
|
|
145
|
+
};
|
|
79
146
|
AccentScope: {
|
|
80
147
|
props: AccentScopeProps;
|
|
81
148
|
parts: 'root';
|
|
82
149
|
};
|
|
150
|
+
Code: {
|
|
151
|
+
props: CodeProps;
|
|
152
|
+
parts: 'root' | 'bar' | 'filename' | 'copy' | 'pre';
|
|
153
|
+
};
|
|
154
|
+
Contents: {
|
|
155
|
+
props: ContentsProps;
|
|
156
|
+
parts: 'root' | 'title' | 'list' | 'item' | 'link';
|
|
157
|
+
};
|
|
158
|
+
Hairline: {
|
|
159
|
+
props: HairlineProps;
|
|
160
|
+
parts: 'root';
|
|
161
|
+
};
|
|
162
|
+
PageNav: {
|
|
163
|
+
props: PageNavProps;
|
|
164
|
+
parts: 'root';
|
|
165
|
+
};
|
|
166
|
+
Prose: {
|
|
167
|
+
props: ProseProps;
|
|
168
|
+
parts: 'root';
|
|
169
|
+
};
|
|
170
|
+
Rail: {
|
|
171
|
+
props: RailProps;
|
|
172
|
+
parts: 'root';
|
|
173
|
+
};
|
|
174
|
+
SkipLink: {
|
|
175
|
+
props: SkipLinkProps;
|
|
176
|
+
parts: 'root';
|
|
177
|
+
};
|
|
83
178
|
Bento: {
|
|
84
179
|
props: BentoProps;
|
|
85
180
|
parts: 'root';
|
|
@@ -114,7 +209,7 @@ export interface ThemeComponents {
|
|
|
114
209
|
};
|
|
115
210
|
ListRow: {
|
|
116
211
|
props: ListRowProps;
|
|
117
|
-
parts: 'root' | 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action';
|
|
212
|
+
parts: 'root' | 'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action';
|
|
118
213
|
};
|
|
119
214
|
ResultRow: {
|
|
120
215
|
props: ResultRowProps;
|
package/dist/lib/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../../src/lib/theme.ts"],"sourcesContent":["// createTheme() and the stylesheet that applies a theme. Server-safe: a theme is plain, serialisable data,\n// so it can be created in a server component and passed to <SlurpProvider>.\nimport { MOTION_DEFAULTS, type GhostKind, type SlurpDefaults } from '@slurp-ui/motion';\nimport type { blur, ColorToken, HueToken, RadiusToken, shadow, SpaceToken } from '@slurp-ui/tokens';\n\nimport type { AccentScopeProps } from '../AccentScope/AccentScope';\nimport type { BentoProps } from '../Bento/Bento';\nimport type { CardProps } from '../Card/Card';\nimport type { DockProps } from '../Dock/Dock';\nimport type { EmptyProps } from '../Empty/Empty';\nimport type { FactProps } from '../Fact/Fact';\nimport type { FiltersProps } from '../Filters/Filters';\nimport type { LinkProps } from '../Link/Link';\nimport type { ListProps, ListRowProps } from '../ListRow/ListRow';\nimport type { ResultRowProps } from '../ResultRow/ResultRow';\nimport type { ScoreProps } from '../Score/Score';\nimport type { SettingsProps } from '../Settings/Settings';\nimport type { ShelfProps } from '../Shelf/Shelf';\nimport type { StageProps } from '../Stage/Stage';\nimport type { TileProps } from '../Tile/Tile';\nimport type { CarouselProps } from '../Carousel/Carousel';\nimport type { PagesProps } from '../Pages/Pages';\nimport type { RatingProps } from '../Rating/Rating';\nimport type { StepsProps } from '../Steps/Steps';\nimport type { SuggestProps } from '../Suggest/Suggest';\nimport type { TableProps } from '../Table/Table';\nimport type { AvatarProps } from '../Avatar/Avatar';\nimport type { BloomProps } from '../Bloom/Bloom';\nimport type { BubbleProps } from '../Bubble/Bubble';\nimport type { ButtonProps } from '../Button/Button';\nimport type { CellProps } from '../Cell/Cell';\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { ChipProps } from '../Chip/Chip';\nimport type { ChoiceProps } from '../Choice/Choice';\nimport type { CountProps } from '../Count/Count';\nimport type { DialogProps } from '../Dialog/Dialog';\nimport type { FieldProps } from '../Field/Field';\nimport type { FlowProps } from '../Flow/Flow';\nimport type { FoldProps } from '../Fold/Fold';\nimport type { FrameProps } from '../Frame/Frame';\nimport type { HintProps } from '../Hint/Hint';\nimport type { MenuProps } from '../Menu/Menu';\nimport type { NoticeProps } from '../Notice/Notice';\nimport type { PlaceholderProps } from '../Placeholder/Placeholder';\nimport type { ProgressProps } from '../Progress/Progress';\nimport type { RadioGroupProps, RadioProps } from '../Radio/Radio';\nimport type { RangeProps } from '../Range/Range';\nimport type { SearchProps } from '../Search/Search';\nimport type { SegmentedProps } from '../Segmented/Segmented';\nimport type { SheetProps } from '../Sheet/Sheet';\nimport type { SurfaceProps } from '../Surface/Surface';\nimport type { SwatchGroupProps, SwatchProps } from '../Swatch/Swatch';\nimport type { SwitchProps } from '../Switch/Switch';\nimport type { TabsProps } from '../Tabs/Tabs';\nimport type { TextProps } from '../Text/Text';\nimport { accentVars, resolveAccent } from './color';\nimport { hash, LAYER_ORDER, type SlurpCss } from './css';\n\nexport type ColorSchemeMode = 'light' | 'dark' | 'system';\nexport type ResolvedColorScheme = 'light' | 'dark';\n/** A `hue-*` preset (used as is) or any hex colour (turned into an accent with `vivid()`). */\nexport type AccentInput = `hue-${HueToken}` | `#${string}`;\n\ntype Themed = string | { light: string; dark: string };\ntype Length = string | number;\n\nexport interface TokenOverrides {\n color?: Partial<Record<ColorToken | `hue-${HueToken}`, Themed>>;\n space?: Partial<Record<SpaceToken, Length>>;\n radius?: Partial<Record<RadiusToken, Length>>;\n shadow?: Partial<Record<keyof typeof shadow, Themed>>;\n blur?: Partial<Record<keyof typeof blur, Length>>;\n}\n\n/** Defaults of the collapse / expand transitions started with useSlurp() (serialisable values only). */\nexport interface MotionOptions extends Pick<\n SlurpDefaults,\n 'duration' | 'stagger' | 'curve' | 'swell' | 'drop' | 'reducedMotion' | 'interrupt'\n> {\n goo: boolean | 'auto';\n ghost: GhostKind;\n order: 'distance' | 'dom';\n}\n\nconst { duration, stagger, curve, swell, drop, reducedMotion, interrupt } = MOTION_DEFAULTS;\nconst DEFAULT_MOTION: MotionOptions = {\n duration,\n stagger,\n curve,\n swell,\n drop,\n reducedMotion,\n interrupt,\n goo: 'auto',\n ghost: 'shape',\n order: 'distance',\n};\n\n/** Components that read defaults and `css` overrides from the theme, with their parts. */\nexport interface ThemeComponents {\n AccentScope: { props: AccentScopeProps; parts: 'root' };\n Bento: { props: BentoProps; parts: 'root' };\n Card: { props: CardProps; parts: 'root' | 'media' | 'badge' | 'title' | 'description' };\n Dock: { props: DockProps; parts: 'root' };\n Empty: { props: EmptyProps; parts: 'root' };\n Fact: { props: FactProps; parts: 'root' };\n Filters: { props: FiltersProps; parts: 'root' };\n Link: { props: LinkProps; parts: 'root' };\n List: { props: ListProps; parts: 'root' };\n ListRow: {\n props: ListRowProps;\n parts: 'root' | 'mark' | 'title' | 'tag' | 'meta' | 'value' | 'action';\n };\n ResultRow: { props: ResultRowProps; parts: 'root' };\n Score: { props: ScoreProps; parts: 'root' };\n Settings: { props: SettingsProps; parts: 'root' };\n Shelf: { props: ShelfProps; parts: 'root' };\n Stage: { props: StageProps; parts: 'root' };\n Tile: {\n props: TileProps;\n parts: 'root' | 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media';\n };\n Avatar: { props: AvatarProps; parts: 'root' };\n Bloom: { props: BloomProps; parts: 'root' | 'surface' | 'trigger' | 'panel' };\n Bubble: { props: BubbleProps; parts: 'root' };\n Button: { props: ButtonProps; parts: 'root' | 'icon' | 'label' | 'endIcon' };\n Cell: { props: CellProps; parts: 'root' };\n Checkbox: { props: CheckboxProps; parts: 'root' | 'input' | 'box' | 'label' };\n Chip: { props: ChipProps; parts: 'root' };\n Choice: { props: ChoiceProps; parts: 'root' };\n Count: { props: CountProps; parts: 'root' };\n Dialog: {\n props: DialogProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Field: { props: FieldProps; parts: 'root' | 'label' | 'control' | 'hint' | 'error' };\n Flow: { props: FlowProps; parts: 'root' };\n Fold: { props: FoldProps; parts: 'root' | 'heading' | 'trigger' | 'region' };\n Frame: { props: FrameProps; parts: 'root' };\n Hint: { props: HintProps; parts: 'root' };\n Menu: { props: MenuProps; parts: 'root' };\n Notice: { props: NoticeProps; parts: 'root' | 'icon' | 'title' | 'body' | 'dismiss' };\n Placeholder: { props: PlaceholderProps; parts: 'root' };\n Progress: { props: ProgressProps; parts: 'root' };\n Radio: { props: RadioProps; parts: 'root' | 'input' | 'dot' | 'label' };\n RadioGroup: { props: RadioGroupProps; parts: 'root' | 'legend' };\n Range: { props: RangeProps; parts: 'root' | 'label' | 'value' | 'control' };\n Search: { props: SearchProps; parts: 'root' | 'icon' | 'control' | 'clear' | 'status' };\n Segmented: { props: SegmentedProps; parts: 'root' | 'item' };\n Sheet: {\n props: SheetProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Surface: { props: SurfaceProps; parts: 'root' };\n Swatch: { props: SwatchProps; parts: 'root' };\n SwatchGroup: { props: SwatchGroupProps; parts: 'root' };\n Switch: { props: SwitchProps; parts: 'root' | 'input' | 'track' | 'thumb' | 'label' };\n Tabs: { props: TabsProps; parts: 'root' | 'list' | 'tab' | 'indicator' | 'panel' };\n Text: { props: TextProps; parts: 'root' };\n Suggest: {\n props: SuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'hint' | 'error';\n };\n Pages: { props: PagesProps; parts: 'root' | 'list' | 'item' | 'previous' | 'next' | 'status' };\n Steps: { props: StepsProps; parts: 'root' | 'list' | 'step' };\n Rating: { props: RatingProps; parts: 'root' };\n Table: { props: TableProps; parts: 'root' | 'table' | 'caption' };\n Carousel: {\n props: CarouselProps;\n parts: 'root' | 'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot';\n };\n}\nexport type ComponentName = keyof ThemeComponents;\n\nexport type ComponentsConfig = {\n [K in ComponentName]?: {\n defaults?: Partial<Omit<ThemeComponents[K]['props'], 'ref' | 'children' | 'css'>>;\n css?: Partial<Record<ThemeComponents[K]['parts'], SlurpCss>>;\n };\n};\n\nexport interface ThemeOptions {\n /** Initial colour scheme, until the person chooses one (default `system`). */\n colorScheme?: ColorSchemeMode;\n /** Default `hue-violet`. */\n accent?: AccentInput;\n /** Used only by Intl (numbers, prices). Not an i18n system. Default `it-IT`. */\n locale?: string;\n tokens?: TokenOverrides;\n motion?: Partial<MotionOptions>;\n components?: ComponentsConfig;\n}\n\nexport interface Theme {\n colorScheme: ColorSchemeMode;\n accent: AccentInput;\n /** The accent actually painted (hex). */\n accentColor: string;\n locale: string;\n tokens: TokenOverrides;\n motion: MotionOptions;\n components: ComponentsConfig;\n}\n\nconst DEFAULT_ACCENT: AccentInput = 'hue-violet';\n\n/** localStorage key of the chosen colour scheme (same as the design system's setTheme()). */\nexport const DEFAULT_STORAGE_KEY = 'slurp-theme';\n\nexport function createTheme(options: ThemeOptions = {}): Theme {\n const accent = options.accent ?? DEFAULT_ACCENT;\n return {\n colorScheme: options.colorScheme ?? 'system',\n accent,\n accentColor: resolveAccent(accent),\n locale: options.locale ?? 'it-IT',\n tokens: options.tokens ?? {},\n motion: { ...DEFAULT_MOTION, ...options.motion },\n components: options.components ?? {},\n };\n}\n\nexport const defaultTheme: Theme = createTheme();\n\nconst px = (v: Length) => (typeof v === 'number' ? `${v}px` : v);\n\n/** Light / dark declarations of the token overrides of a theme. */\nfunction overrideDeclarations(tokens: TokenOverrides) {\n const light: string[] = [];\n const dark: string[] = [];\n const add = (name: string, v: Themed | number) => {\n if (typeof v === 'object') {\n light.push(`--slurp-${name}:${v.light}`);\n dark.push(`--slurp-${name}:${v.dark}`);\n } else light.push(`--slurp-${name}:${px(v)}`);\n };\n for (const [k, v] of Object.entries(tokens.color ?? {})) if (v !== undefined) add(k, v);\n for (const [k, v] of Object.entries(tokens.space ?? {}))\n if (v !== undefined) add(`space-${k}`, v);\n for (const [k, v] of Object.entries(tokens.radius ?? {}))\n if (v !== undefined) add(`radius-${k}`, v);\n for (const [k, v] of Object.entries(tokens.shadow ?? {}))\n if (v !== undefined) add(`shadow-${k}`, v);\n for (const [k, v] of Object.entries(tokens.blur ?? {})) if (v !== undefined) add(`blur-${k}`, v);\n return { light, dark };\n}\n\nfunction selectors(scope: string | undefined) {\n if (!scope) {\n return {\n base: ':root,[data-theme]',\n dark: \"[data-theme='dark']\",\n systemDark: \":root:not([data-theme='light'])\",\n };\n }\n const s = `[data-slurp-theme=\"${scope}\"]`;\n return {\n base: `${s},${s} [data-theme]`,\n dark: `:root[data-theme='dark'] ${s},${s} [data-theme='dark']`,\n systemDark: `:root:not([data-theme='light']) ${s}`,\n };\n}\n\n/**\n * The stylesheet of a theme: accent variables and token overrides, on the root (or on a nested provider's `scope`)\n * and on every `data-theme` subtree, so derived values re-resolve per theme. Empty for the default theme.\n * tokens.css uses `:where()`, so these plain selectors win whatever the stylesheet order.\n */\nexport function themeCss(theme: Theme, scope?: string): string {\n const { light, dark } = overrideDeclarations(theme.tokens);\n const accent =\n theme.accent === DEFAULT_ACCENT\n ? []\n : Object.entries(accentVars(theme.accentColor)).map(([k, v]) => `${k}:${v}`);\n const base = [...accent, ...light];\n if (!base.length && !dark.length) return '';\n const sel = selectors(scope);\n const rules = [`${sel.base}{${base.join(';')}}`];\n if (dark.length) {\n rules.push(\n `${sel.dark}{${dark.join(';')}}`,\n `@media (prefers-color-scheme: dark){${sel.systemDark}{${dark.join(';')}}}`,\n );\n }\n return `${LAYER_ORDER}@layer slurp.base{${rules.join('')}}`;\n}\n\n/** Stable id of a stylesheet, for React's <style href> de-duplication. */\nexport const styleId = (prefix: string, css: string) => `slurp-${prefix}-${hash(css)}`;\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../src/lib/theme.ts"],"sourcesContent":["// createTheme() and the stylesheet that applies a theme. Server-safe: a theme is plain, serialisable data,\n// so it can be created in a server component and passed to <SlurpProvider>.\nimport { MOTION_DEFAULTS, type GhostKind, type SlurpDefaults } from '@slurp-ui/motion';\nimport type { blur, ColorToken, HueToken, RadiusToken, shadow, SpaceToken } from '@slurp-ui/tokens';\n\nimport type { AccentScopeProps } from '../AccentScope/AccentScope';\nimport type { BentoProps } from '../Bento/Bento';\nimport type { CardProps } from '../Card/Card';\nimport type { DockProps } from '../Dock/Dock';\nimport type { EmptyProps } from '../Empty/Empty';\nimport type { FactProps } from '../Fact/Fact';\nimport type { FiltersProps } from '../Filters/Filters';\nimport type { LinkProps } from '../Link/Link';\nimport type { ListProps, ListRowProps } from '../ListRow/ListRow';\nimport type { ResultRowProps } from '../ResultRow/ResultRow';\nimport type { ScoreProps } from '../Score/Score';\nimport type { SettingsProps } from '../Settings/Settings';\nimport type { ShelfProps } from '../Shelf/Shelf';\nimport type { StageProps } from '../Stage/Stage';\nimport type { TileProps } from '../Tile/Tile';\nimport type { CarouselProps } from '../Carousel/Carousel';\nimport type { PagesProps } from '../Pages/Pages';\nimport type { RatingProps } from '../Rating/Rating';\nimport type { StepsProps } from '../Steps/Steps';\nimport type { SuggestProps } from '../Suggest/Suggest';\nimport type { TableProps } from '../Table/Table';\nimport type { AvatarProps } from '../Avatar/Avatar';\nimport type { BloomProps } from '../Bloom/Bloom';\nimport type { BubbleProps } from '../Bubble/Bubble';\nimport type { ButtonProps } from '../Button/Button';\nimport type { CellProps } from '../Cell/Cell';\nimport type { CheckboxProps } from '../Checkbox/Checkbox';\nimport type { ChipProps } from '../Chip/Chip';\nimport type { ChoiceProps } from '../Choice/Choice';\nimport type { CountProps } from '../Count/Count';\nimport type { DialogProps } from '../Dialog/Dialog';\nimport type { FieldProps } from '../Field/Field';\nimport type { FlowProps } from '../Flow/Flow';\nimport type { FoldProps } from '../Fold/Fold';\nimport type { FrameProps } from '../Frame/Frame';\nimport type { HintProps } from '../Hint/Hint';\nimport type { MenuProps } from '../Menu/Menu';\nimport type { NoticeProps } from '../Notice/Notice';\nimport type { PlaceholderProps } from '../Placeholder/Placeholder';\nimport type { ProgressProps } from '../Progress/Progress';\nimport type { RadioGroupProps, RadioProps } from '../Radio/Radio';\nimport type { RangeProps } from '../Range/Range';\nimport type { SearchProps } from '../Search/Search';\nimport type { SegmentedProps } from '../Segmented/Segmented';\nimport type { SheetProps } from '../Sheet/Sheet';\nimport type { SurfaceProps } from '../Surface/Surface';\nimport type { SwatchGroupProps, SwatchProps } from '../Swatch/Swatch';\nimport type { SwitchProps } from '../Switch/Switch';\nimport type { TabsProps } from '../Tabs/Tabs';\nimport type { TextProps } from '../Text/Text';\nimport type { DateFieldProps } from '../DateField/DateField';\nimport type { CalendarProps } from '../Calendar/Calendar';\nimport type { FileDropProps } from '../FileDrop/FileDrop';\nimport type { ErrorSummaryProps } from '../ErrorSummary/ErrorSummary';\nimport type { PinFieldProps } from '../PinField/PinField';\nimport type { NumberFieldProps } from '../NumberField/NumberField';\nimport type { SecretFieldProps } from '../SecretField/SecretField';\nimport type { FooterProps } from '../Footer/Footer';\nimport type { MediaProps } from '../Media/Media';\nimport type { QuoteProps } from '../Quote/Quote';\nimport type { KbdProps } from '../Kbd/Kbd';\nimport type { TagProps } from '../Tag/Tag';\nimport type { CodeProps } from '../Code/Code';\nimport type { ContentsProps } from '../Contents/Contents';\nimport type { HairlineProps } from '../Hairline/Hairline';\nimport type { PageNavProps } from '../PageNav/PageNav';\nimport type { ProseProps } from '../Prose/Prose';\nimport type { RailProps } from '../Rail/Rail';\nimport type { SkipLinkProps } from '../SkipLink/SkipLink';\nimport { accentVars, resolveAccent } from './color';\nimport { hash, LAYER_ORDER, type SlurpCss } from './css';\n\nexport type ColorSchemeMode = 'light' | 'dark' | 'system';\nexport type ResolvedColorScheme = 'light' | 'dark';\n/** A `hue-*` preset (used as is) or any hex colour (turned into an accent with `vivid()`). */\nexport type AccentInput = `hue-${HueToken}` | `#${string}`;\n\ntype Themed = string | { light: string; dark: string };\ntype Length = string | number;\n\nexport interface TokenOverrides {\n color?: Partial<Record<ColorToken | `hue-${HueToken}`, Themed>>;\n space?: Partial<Record<SpaceToken, Length>>;\n radius?: Partial<Record<RadiusToken, Length>>;\n shadow?: Partial<Record<keyof typeof shadow, Themed>>;\n blur?: Partial<Record<keyof typeof blur, Length>>;\n}\n\n/** Defaults of the collapse / expand transitions started with useSlurp() (serialisable values only). */\nexport interface MotionOptions extends Pick<\n SlurpDefaults,\n 'duration' | 'stagger' | 'curve' | 'swell' | 'drop' | 'reducedMotion' | 'interrupt'\n> {\n goo: boolean | 'auto';\n ghost: GhostKind;\n order: 'distance' | 'dom';\n}\n\nconst { duration, stagger, curve, swell, drop, reducedMotion, interrupt } = MOTION_DEFAULTS;\nconst DEFAULT_MOTION: MotionOptions = {\n duration,\n stagger,\n curve,\n swell,\n drop,\n reducedMotion,\n interrupt,\n goo: 'auto',\n ghost: 'shape',\n order: 'distance',\n};\n\n/** Components that read defaults and `css` overrides from the theme, with their parts. */\nexport interface ThemeComponents {\n DateField: { props: DateFieldProps; parts: 'root' };\n Calendar: { props: CalendarProps; parts: 'root' };\n FileDrop: { props: FileDropProps; parts: 'root' };\n ErrorSummary: { props: ErrorSummaryProps; parts: 'root' };\n PinField: { props: PinFieldProps; parts: 'root' };\n NumberField: { props: NumberFieldProps; parts: 'root' };\n SecretField: { props: SecretFieldProps; parts: 'root' };\n Footer: { props: FooterProps; parts: 'root' };\n Media: { props: MediaProps; parts: 'root' | 'frame' | 'media' | 'caption' };\n Quote: { props: QuoteProps; parts: 'root' | 'quote' | 'caption' };\n Kbd: { props: KbdProps; parts: 'root' };\n Tag: { props: TagProps; parts: 'root' };\n AccentScope: { props: AccentScopeProps; parts: 'root' };\n Code: { props: CodeProps; parts: 'root' | 'bar' | 'filename' | 'copy' | 'pre' };\n Contents: { props: ContentsProps; parts: 'root' | 'title' | 'list' | 'item' | 'link' };\n Hairline: { props: HairlineProps; parts: 'root' };\n PageNav: { props: PageNavProps; parts: 'root' };\n Prose: { props: ProseProps; parts: 'root' };\n Rail: { props: RailProps; parts: 'root' };\n SkipLink: { props: SkipLinkProps; parts: 'root' };\n Bento: { props: BentoProps; parts: 'root' };\n Card: { props: CardProps; parts: 'root' | 'media' | 'badge' | 'title' | 'description' };\n Dock: { props: DockProps; parts: 'root' };\n Empty: { props: EmptyProps; parts: 'root' };\n Fact: { props: FactProps; parts: 'root' };\n Filters: { props: FiltersProps; parts: 'root' };\n Link: { props: LinkProps; parts: 'root' };\n List: { props: ListProps; parts: 'root' };\n ListRow: {\n props: ListRowProps;\n parts: 'root' | 'mark' | 'title' | 'link' | 'tag' | 'meta' | 'value' | 'action';\n };\n ResultRow: { props: ResultRowProps; parts: 'root' };\n Score: { props: ScoreProps; parts: 'root' };\n Settings: { props: SettingsProps; parts: 'root' };\n Shelf: { props: ShelfProps; parts: 'root' };\n Stage: { props: StageProps; parts: 'root' };\n Tile: {\n props: TileProps;\n parts: 'root' | 'blob' | 'text' | 'title' | 'subtitle' | 'badge' | 'media';\n };\n Avatar: { props: AvatarProps; parts: 'root' };\n Bloom: { props: BloomProps; parts: 'root' | 'surface' | 'trigger' | 'panel' };\n Bubble: { props: BubbleProps; parts: 'root' };\n Button: { props: ButtonProps; parts: 'root' | 'icon' | 'label' | 'endIcon' };\n Cell: { props: CellProps; parts: 'root' };\n Checkbox: { props: CheckboxProps; parts: 'root' | 'input' | 'box' | 'label' };\n Chip: { props: ChipProps; parts: 'root' };\n Choice: { props: ChoiceProps; parts: 'root' };\n Count: { props: CountProps; parts: 'root' };\n Dialog: {\n props: DialogProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Field: { props: FieldProps; parts: 'root' | 'label' | 'control' | 'hint' | 'error' };\n Flow: { props: FlowProps; parts: 'root' };\n Fold: { props: FoldProps; parts: 'root' | 'heading' | 'trigger' | 'region' };\n Frame: { props: FrameProps; parts: 'root' };\n Hint: { props: HintProps; parts: 'root' };\n Menu: { props: MenuProps; parts: 'root' };\n Notice: { props: NoticeProps; parts: 'root' | 'icon' | 'title' | 'body' | 'dismiss' };\n Placeholder: { props: PlaceholderProps; parts: 'root' };\n Progress: { props: ProgressProps; parts: 'root' };\n Radio: { props: RadioProps; parts: 'root' | 'input' | 'dot' | 'label' };\n RadioGroup: { props: RadioGroupProps; parts: 'root' | 'legend' };\n Range: { props: RangeProps; parts: 'root' | 'label' | 'value' | 'control' };\n Search: { props: SearchProps; parts: 'root' | 'icon' | 'control' | 'clear' | 'status' };\n Segmented: { props: SegmentedProps; parts: 'root' | 'item' };\n Sheet: {\n props: SheetProps;\n parts: 'root' | 'header' | 'title' | 'description' | 'body' | 'footer' | 'close';\n };\n Surface: { props: SurfaceProps; parts: 'root' };\n Swatch: { props: SwatchProps; parts: 'root' };\n SwatchGroup: { props: SwatchGroupProps; parts: 'root' };\n Switch: { props: SwitchProps; parts: 'root' | 'input' | 'track' | 'thumb' | 'label' };\n Tabs: { props: TabsProps; parts: 'root' | 'list' | 'tab' | 'indicator' | 'panel' };\n Text: { props: TextProps; parts: 'root' };\n Suggest: {\n props: SuggestProps;\n parts: 'root' | 'label' | 'control' | 'list' | 'option' | 'hint' | 'error';\n };\n Pages: { props: PagesProps; parts: 'root' | 'list' | 'item' | 'previous' | 'next' | 'status' };\n Steps: { props: StepsProps; parts: 'root' | 'list' | 'step' };\n Rating: { props: RatingProps; parts: 'root' };\n Table: { props: TableProps; parts: 'root' | 'table' | 'caption' };\n Carousel: {\n props: CarouselProps;\n parts: 'root' | 'track' | 'slide' | 'controls' | 'previous' | 'next' | 'dot';\n };\n}\nexport type ComponentName = keyof ThemeComponents;\n\nexport type ComponentsConfig = {\n [K in ComponentName]?: {\n defaults?: Partial<Omit<ThemeComponents[K]['props'], 'ref' | 'children' | 'css'>>;\n css?: Partial<Record<ThemeComponents[K]['parts'], SlurpCss>>;\n };\n};\n\nexport interface ThemeOptions {\n /** Initial colour scheme, until the person chooses one (default `system`). */\n colorScheme?: ColorSchemeMode;\n /** Default `hue-violet`. */\n accent?: AccentInput;\n /** Used only by Intl (numbers, prices). Not an i18n system. Default `it-IT`. */\n locale?: string;\n tokens?: TokenOverrides;\n motion?: Partial<MotionOptions>;\n components?: ComponentsConfig;\n}\n\nexport interface Theme {\n colorScheme: ColorSchemeMode;\n accent: AccentInput;\n /** The accent actually painted (hex). */\n accentColor: string;\n locale: string;\n tokens: TokenOverrides;\n motion: MotionOptions;\n components: ComponentsConfig;\n}\n\nconst DEFAULT_ACCENT: AccentInput = 'hue-violet';\n\n/** localStorage key of the chosen colour scheme (same as the design system's setTheme()). */\nexport const DEFAULT_STORAGE_KEY = 'slurp-theme';\n\nexport function createTheme(options: ThemeOptions = {}): Theme {\n const accent = options.accent ?? DEFAULT_ACCENT;\n return {\n colorScheme: options.colorScheme ?? 'system',\n accent,\n accentColor: resolveAccent(accent),\n locale: options.locale ?? 'it-IT',\n tokens: options.tokens ?? {},\n motion: { ...DEFAULT_MOTION, ...options.motion },\n components: options.components ?? {},\n };\n}\n\nexport const defaultTheme: Theme = createTheme();\n\nconst px = (v: Length) => (typeof v === 'number' ? `${v}px` : v);\n\n/** Light / dark declarations of the token overrides of a theme. */\nfunction overrideDeclarations(tokens: TokenOverrides) {\n const light: string[] = [];\n const dark: string[] = [];\n const add = (name: string, v: Themed | number) => {\n if (typeof v === 'object') {\n light.push(`--slurp-${name}:${v.light}`);\n dark.push(`--slurp-${name}:${v.dark}`);\n } else light.push(`--slurp-${name}:${px(v)}`);\n };\n for (const [k, v] of Object.entries(tokens.color ?? {})) if (v !== undefined) add(k, v);\n for (const [k, v] of Object.entries(tokens.space ?? {}))\n if (v !== undefined) add(`space-${k}`, v);\n for (const [k, v] of Object.entries(tokens.radius ?? {}))\n if (v !== undefined) add(`radius-${k}`, v);\n for (const [k, v] of Object.entries(tokens.shadow ?? {}))\n if (v !== undefined) add(`shadow-${k}`, v);\n for (const [k, v] of Object.entries(tokens.blur ?? {})) if (v !== undefined) add(`blur-${k}`, v);\n return { light, dark };\n}\n\nfunction selectors(scope: string | undefined) {\n if (!scope) {\n return {\n base: ':root,[data-theme]',\n dark: \"[data-theme='dark']\",\n systemDark: \":root:not([data-theme='light'])\",\n };\n }\n const s = `[data-slurp-theme=\"${scope}\"]`;\n return {\n base: `${s},${s} [data-theme]`,\n dark: `:root[data-theme='dark'] ${s},${s} [data-theme='dark']`,\n systemDark: `:root:not([data-theme='light']) ${s}`,\n };\n}\n\n/**\n * The stylesheet of a theme: accent variables and token overrides, on the root (or on a nested provider's `scope`)\n * and on every `data-theme` subtree, so derived values re-resolve per theme. Empty for the default theme.\n * tokens.css uses `:where()`, so these plain selectors win whatever the stylesheet order.\n */\nexport function themeCss(theme: Theme, scope?: string): string {\n const { light, dark } = overrideDeclarations(theme.tokens);\n const accent =\n theme.accent === DEFAULT_ACCENT\n ? []\n : Object.entries(accentVars(theme.accentColor)).map(([k, v]) => `${k}:${v}`);\n const base = [...accent, ...light];\n if (!base.length && !dark.length) return '';\n const sel = selectors(scope);\n const rules = [`${sel.base}{${base.join(';')}}`];\n if (dark.length) {\n rules.push(\n `${sel.dark}{${dark.join(';')}}`,\n `@media (prefers-color-scheme: dark){${sel.systemDark}{${dark.join(';')}}}`,\n );\n }\n return `${LAYER_ORDER}@layer slurp.base{${rules.join('')}}`;\n}\n\n/** Stable id of a stylesheet, for React's <style href> de-duplication. */\nexport const styleId = (prefix: string, css: string) => `slurp-${prefix}-${hash(css)}`;\n"],"mappings":"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"}
|