@sepale/components 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +65 -3
- package/dist/components/Accordion.svelte +48 -0
- package/dist/components/Accordion.svelte.d.ts +24 -0
- package/dist/components/Alert.svelte +107 -0
- package/dist/components/Alert.svelte.d.ts +40 -0
- package/dist/components/Avatar.svelte +75 -0
- package/dist/components/Avatar.svelte.d.ts +37 -0
- package/dist/components/Badge.svelte +46 -0
- package/dist/components/Badge.svelte.d.ts +22 -0
- package/dist/components/Breadcrumbs.svelte +36 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +18 -0
- package/dist/components/Bubble.svelte +43 -0
- package/dist/components/Bubble.svelte.d.ts +23 -0
- package/dist/components/Button.svelte +132 -0
- package/dist/components/Button.svelte.d.ts +40 -0
- package/dist/components/Calendar.svelte +193 -0
- package/dist/components/Calendar.svelte.d.ts +60 -0
- package/dist/components/Card.svelte +69 -0
- package/dist/components/Card.svelte.d.ts +37 -0
- package/dist/components/Carousel.svelte +550 -0
- package/dist/components/Carousel.svelte.d.ts +124 -0
- package/dist/components/Checkbox.svelte +48 -0
- package/dist/components/Checkbox.svelte.d.ts +26 -0
- package/dist/components/Chip.svelte +60 -0
- package/dist/components/Chip.svelte.d.ts +26 -0
- package/dist/components/ChipsInput.svelte +158 -0
- package/dist/components/ChipsInput.svelte.d.ts +64 -0
- package/dist/components/Collapse.svelte +101 -0
- package/dist/components/Collapse.svelte.d.ts +46 -0
- package/dist/components/ColorPicker.svelte +135 -0
- package/dist/components/ColorPicker.svelte.d.ts +44 -0
- package/dist/components/Combobox.svelte +496 -0
- package/dist/components/Combobox.svelte.d.ts +96 -0
- package/dist/components/DataControl.svelte +754 -0
- package/dist/components/DataControl.svelte.d.ts +143 -0
- package/dist/components/DataHandler.svelte +67 -0
- package/dist/components/DataHandler.svelte.d.ts +44 -0
- package/dist/components/DatePicker.svelte +185 -0
- package/dist/components/DatePicker.svelte.d.ts +56 -0
- package/dist/components/Dialog.svelte +194 -0
- package/dist/components/Dialog.svelte.d.ts +51 -0
- package/dist/components/Divider.svelte +54 -0
- package/dist/components/Divider.svelte.d.ts +27 -0
- package/dist/components/Dock.svelte +34 -0
- package/dist/components/Dock.svelte.d.ts +18 -0
- package/dist/components/Drawer.svelte +174 -0
- package/dist/components/Drawer.svelte.d.ts +51 -0
- package/dist/components/Dropdown.svelte +183 -0
- package/dist/components/Dropdown.svelte.d.ts +52 -0
- package/dist/components/Editable.svelte +292 -0
- package/dist/components/Editable.svelte.d.ts +113 -0
- package/dist/components/EmptyState.svelte +64 -0
- package/dist/components/EmptyState.svelte.d.ts +29 -0
- package/dist/components/Fieldset.svelte +42 -0
- package/dist/components/Fieldset.svelte.d.ts +20 -0
- package/dist/components/FileDropzone.svelte +154 -0
- package/dist/components/FileDropzone.svelte.d.ts +45 -0
- package/dist/components/FileExplorer.svelte +643 -0
- package/dist/components/FileExplorer.svelte.d.ts +114 -0
- package/dist/components/FileInput.svelte +125 -0
- package/dist/components/FileInput.svelte.d.ts +51 -0
- package/dist/components/FloatingLabel.svelte +38 -0
- package/dist/components/FloatingLabel.svelte.d.ts +24 -0
- package/dist/components/Footer.svelte +68 -0
- package/dist/components/Footer.svelte.d.ts +37 -0
- package/dist/components/Grid.svelte +122 -0
- package/dist/components/Grid.svelte.d.ts +72 -0
- package/dist/components/Hero.svelte +62 -0
- package/dist/components/Hero.svelte.d.ts +33 -0
- package/dist/components/Input.svelte +184 -0
- package/dist/components/Input.svelte.d.ts +65 -0
- package/dist/components/Join.svelte +38 -0
- package/dist/components/Join.svelte.d.ts +21 -0
- package/dist/components/Kanban.svelte +284 -0
- package/dist/components/Kanban.svelte.d.ts +93 -0
- package/dist/components/Label.svelte +32 -0
- package/dist/components/Label.svelte.d.ts +21 -0
- package/dist/components/LaptopFrame.svelte +44 -0
- package/dist/components/LaptopFrame.svelte.d.ts +21 -0
- package/dist/components/List.svelte +95 -0
- package/dist/components/List.svelte.d.ts +69 -0
- package/dist/components/Loading.svelte +37 -0
- package/dist/components/Loading.svelte.d.ts +17 -0
- package/dist/components/Menu.svelte +144 -0
- package/dist/components/Menu.svelte.d.ts +53 -0
- package/dist/components/MobileFrame.svelte +41 -0
- package/dist/components/MobileFrame.svelte.d.ts +21 -0
- package/dist/components/Navbar.svelte +49 -0
- package/dist/components/Navbar.svelte.d.ts +25 -0
- package/dist/components/NumberInput.svelte +255 -0
- package/dist/components/NumberInput.svelte.d.ts +68 -0
- package/dist/components/Pagination.svelte +169 -0
- package/dist/components/Pagination.svelte.d.ts +50 -0
- package/dist/components/Progress.svelte +65 -0
- package/dist/components/Progress.svelte.d.ts +28 -0
- package/dist/components/RadialProgress.svelte +48 -0
- package/dist/components/RadialProgress.svelte.d.ts +20 -0
- package/dist/components/Radio.svelte +50 -0
- package/dist/components/Radio.svelte.d.ts +28 -0
- package/dist/components/Range.svelte +53 -0
- package/dist/components/Range.svelte.d.ts +26 -0
- package/dist/components/Rating.svelte +90 -0
- package/dist/components/Rating.svelte.d.ts +41 -0
- package/dist/components/Select.svelte +338 -0
- package/dist/components/Select.svelte.d.ts +74 -0
- package/dist/components/Sidebar.svelte +100 -0
- package/dist/components/Sidebar.svelte.d.ts +54 -0
- package/dist/components/Skeleton.svelte +40 -0
- package/dist/components/Skeleton.svelte.d.ts +18 -0
- package/dist/components/Stat.svelte +71 -0
- package/dist/components/Stat.svelte.d.ts +35 -0
- package/dist/components/Stats.svelte +38 -0
- package/dist/components/Stats.svelte.d.ts +22 -0
- package/dist/components/Steps.svelte +204 -0
- package/dist/components/Steps.svelte.d.ts +66 -0
- package/dist/components/Subtitle.svelte +44 -0
- package/dist/components/Subtitle.svelte.d.ts +26 -0
- package/dist/components/Swatch.svelte +61 -0
- package/dist/components/Swatch.svelte.d.ts +27 -0
- package/dist/components/Switch.svelte +105 -0
- package/dist/components/Switch.svelte.d.ts +44 -0
- package/dist/components/Table.svelte +243 -0
- package/dist/components/Table.svelte.d.ts +121 -0
- package/dist/components/Tabs.svelte +142 -0
- package/dist/components/Tabs.svelte.d.ts +80 -0
- package/dist/components/Text.svelte +43 -0
- package/dist/components/Text.svelte.d.ts +25 -0
- package/dist/components/Textarea.svelte +76 -0
- package/dist/components/Textarea.svelte.d.ts +39 -0
- package/dist/components/Title.svelte +46 -0
- package/dist/components/Title.svelte.d.ts +29 -0
- package/dist/components/Toast.svelte +154 -0
- package/dist/components/Toast.svelte.d.ts +49 -0
- package/dist/components/Toggle.svelte +48 -0
- package/dist/components/Toggle.svelte.d.ts +25 -0
- package/dist/components/Tooltip.svelte +70 -0
- package/dist/components/Tooltip.svelte.d.ts +34 -0
- package/dist/components/WindowFrame.svelte +53 -0
- package/dist/components/WindowFrame.svelte.d.ts +24 -0
- package/dist/components/accordion-context.d.ts +8 -0
- package/dist/components/accordion-context.js +25 -0
- package/dist/components/color.d.ts +39 -0
- package/dist/components/color.js +92 -0
- package/dist/components/data-handler.svelte.d.ts +362 -0
- package/dist/components/data-handler.svelte.js +690 -0
- package/dist/components/file-icons.d.ts +25 -0
- package/dist/components/file-icons.js +46 -0
- package/dist/family-types.d.ts +45 -0
- package/dist/family-types.js +73 -0
- package/dist/generated/classes.d.ts +17 -0
- package/dist/generated/classes.js +2511 -0
- package/dist/generated/components.d.ts +39 -0
- package/dist/generated/components.js +28666 -0
- package/dist/generated/registry.d.ts +35 -0
- package/dist/generated/registry.js +2658 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +99 -0
- package/dist/sepale-types.d.ts +8 -0
- package/dist/sepale-types.js +200 -0
- package/dist/theme.d.ts +123 -0
- package/dist/theme.js +226 -0
- package/dist/variants.d.ts +124 -0
- package/dist/variants.js +70 -0
- package/dist/vendor/air-datepicker/LICENSE.md +21 -0
- package/dist/vendor/air-datepicker/README.md +19 -0
- package/dist/vendor/air-datepicker/buttonPresets.d.ts +13 -0
- package/dist/vendor/air-datepicker/buttonPresets.js +12 -0
- package/dist/vendor/air-datepicker/consts.d.ts +18 -0
- package/dist/vendor/air-datepicker/consts.js +35 -0
- package/dist/vendor/air-datepicker/datepicker.d.ts +289 -0
- package/dist/vendor/air-datepicker/datepicker.js +1435 -0
- package/dist/vendor/air-datepicker/datepickerBody.d.ts +46 -0
- package/dist/vendor/air-datepicker/datepickerBody.js +386 -0
- package/dist/vendor/air-datepicker/datepickerButtons.d.ts +25 -0
- package/dist/vendor/air-datepicker/datepickerButtons.js +85 -0
- package/dist/vendor/air-datepicker/datepickerCell.d.ts +35 -0
- package/dist/vendor/air-datepicker/datepickerCell.js +297 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.d.ts +26 -0
- package/dist/vendor/air-datepicker/datepickerKeyboard.js +207 -0
- package/dist/vendor/air-datepicker/datepickerNav.d.ts +31 -0
- package/dist/vendor/air-datepicker/datepickerNav.js +200 -0
- package/dist/vendor/air-datepicker/datepickerTime.d.ts +60 -0
- package/dist/vendor/air-datepicker/datepickerTime.js +276 -0
- package/dist/vendor/air-datepicker/defaults.d.ts +65 -0
- package/dist/vendor/air-datepicker/defaults.js +79 -0
- package/dist/vendor/air-datepicker/index.d.ts +168 -0
- package/dist/vendor/air-datepicker/index.js +3 -0
- package/dist/vendor/air-datepicker/locale/ar.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ar.js +14 -0
- package/dist/vendor/air-datepicker/locale/bg.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/bg.js +14 -0
- package/dist/vendor/air-datepicker/locale/ca.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ca.js +14 -0
- package/dist/vendor/air-datepicker/locale/cs.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/cs.js +14 -0
- package/dist/vendor/air-datepicker/locale/da.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/da.js +14 -0
- package/dist/vendor/air-datepicker/locale/de.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/de.js +14 -0
- package/dist/vendor/air-datepicker/locale/el.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/el.js +14 -0
- package/dist/vendor/air-datepicker/locale/en.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/en.js +14 -0
- package/dist/vendor/air-datepicker/locale/es.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/es.js +14 -0
- package/dist/vendor/air-datepicker/locale/eu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/eu.js +14 -0
- package/dist/vendor/air-datepicker/locale/fi.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fi.js +14 -0
- package/dist/vendor/air-datepicker/locale/fr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/fr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hr.js +14 -0
- package/dist/vendor/air-datepicker/locale/hu.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/hu.js +14 -0
- package/dist/vendor/air-datepicker/locale/id.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/id.js +14 -0
- package/dist/vendor/air-datepicker/locale/it.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/it.js +14 -0
- package/dist/vendor/air-datepicker/locale/ja.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ja.js +14 -0
- package/dist/vendor/air-datepicker/locale/ko.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ko.js +14 -0
- package/dist/vendor/air-datepicker/locale/nb.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nb.js +14 -0
- package/dist/vendor/air-datepicker/locale/nl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/nl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pl.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt-BR.js +14 -0
- package/dist/vendor/air-datepicker/locale/pt.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/pt.js +14 -0
- package/dist/vendor/air-datepicker/locale/ro.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ro.js +14 -0
- package/dist/vendor/air-datepicker/locale/ru.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/ru.js +14 -0
- package/dist/vendor/air-datepicker/locale/si.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/si.js +14 -0
- package/dist/vendor/air-datepicker/locale/sk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sk.js +14 -0
- package/dist/vendor/air-datepicker/locale/sl.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sl.js +14 -0
- package/dist/vendor/air-datepicker/locale/sv.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/sv.js +14 -0
- package/dist/vendor/air-datepicker/locale/th.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/th.js +14 -0
- package/dist/vendor/air-datepicker/locale/tr.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/tr.js +16 -0
- package/dist/vendor/air-datepicker/locale/uk.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/uk.js +14 -0
- package/dist/vendor/air-datepicker/locale/zh.d.ts +4 -0
- package/dist/vendor/air-datepicker/locale/zh.js +14 -0
- package/dist/vendor/air-datepicker/typedefs.d.ts +3 -0
- package/dist/vendor/air-datepicker/typedefs.js +15 -0
- package/dist/vendor/air-datepicker/utils.d.ts +155 -0
- package/dist/vendor/air-datepicker/utils.js +395 -0
- package/dist/vendor/air-datepicker/withEvents.d.ts +1 -0
- package/dist/vendor/air-datepicker/withEvents.js +39 -0
- package/package.json +44 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a file looks like in a FileExplorer, by extension.
|
|
3
|
+
*
|
|
4
|
+
* An icon is a glyph — SVG markup drawn in a 24×24 box, stroked in
|
|
5
|
+
* `currentColor` — set inside a page outline, and the colour of the whole.
|
|
6
|
+
* The table maps a lower-case extension, without its dot, to an icon; the
|
|
7
|
+
* explorer merges yours over this one, so a single entry overrides a single
|
|
8
|
+
* extension.
|
|
9
|
+
*/
|
|
10
|
+
export interface FileIcon {
|
|
11
|
+
/** SVG markup inside the page, in a 24×24 box. Empty: the bare page. */
|
|
12
|
+
glyph: string;
|
|
13
|
+
/** Any CSS colour. Defaults to the explorer's muted ink. */
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Draw the glyph alone, without the page around it. */
|
|
16
|
+
bare?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The page every file icon is drawn on. */
|
|
19
|
+
export declare const PAGE = "<path d=\"M6 3h8l4 4v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z\"/><path d=\"M14 3v4h4\"/>";
|
|
20
|
+
/** The default table: the usual extensions, by family of file. */
|
|
21
|
+
export declare const FILE_ICONS: Record<string, FileIcon>;
|
|
22
|
+
/** Extensions shown as a picture when the file has a URL. */
|
|
23
|
+
export declare const IMAGE_EXTENSIONS: Set<string>;
|
|
24
|
+
/** `photo.JPG` → `jpg`; no dot → `''`. */
|
|
25
|
+
export declare function extensionOf(name: string): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a file looks like in a FileExplorer, by extension.
|
|
3
|
+
*
|
|
4
|
+
* An icon is a glyph — SVG markup drawn in a 24×24 box, stroked in
|
|
5
|
+
* `currentColor` — set inside a page outline, and the colour of the whole.
|
|
6
|
+
* The table maps a lower-case extension, without its dot, to an icon; the
|
|
7
|
+
* explorer merges yours over this one, so a single entry overrides a single
|
|
8
|
+
* extension.
|
|
9
|
+
*/
|
|
10
|
+
/** The page every file icon is drawn on. */
|
|
11
|
+
export const PAGE = '<path d="M6 3h8l4 4v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z"/><path d="M14 3v4h4"/>';
|
|
12
|
+
const group = (exts, icon) => Object.fromEntries(exts.split(' ').map((e) => [e, icon]));
|
|
13
|
+
const IMAGE = { color: '#a855f7', glyph: '<circle cx="9.5" cy="11" r="1.3"/><path d="m7.5 18 3-3.2 2 2 1.8-1.8 2.2 3"/>' };
|
|
14
|
+
const VIDEO = { color: '#ef4444', glyph: '<path d="M10 11.5v5l4-2.5z"/>' };
|
|
15
|
+
const AUDIO = { color: '#ec4899', glyph: '<path d="M10.5 17V11l4-1v5.5"/><circle cx="9.3" cy="17" r="1.2"/><circle cx="13.3" cy="15.5" r="1.2"/>' };
|
|
16
|
+
const ARCHIVE = { color: '#d97706', glyph: '<path d="M11 4v2m0 2v2m0 2v2"/><rect x="9.8" y="14" width="2.4" height="3" rx=".6"/>' };
|
|
17
|
+
const PDF = { color: '#dc2626', glyph: '<path d="M8.5 17.5c2-1 4.5-5.5 4-7.5-.4-1.4-2-.6-1.3 1.2.8 2.2 3 4.7 4.8 4.8 1.4.1 1.2-1.4-.6-1.4-1.7 0-4.8 1-6.9 2.9"/>' };
|
|
18
|
+
const DOC = { color: '#2563eb', glyph: '<path d="M8.5 11h7M8.5 14h7M8.5 17h4.5"/>' };
|
|
19
|
+
const SHEET = { color: '#16a34a', glyph: '<path d="M8.5 11h7v6h-7zM8.5 14h7M12 11v6"/>' };
|
|
20
|
+
const SLIDES = { color: '#ea580c', glyph: '<rect x="8.5" y="11" width="7" height="5" rx=".6"/><path d="M12 16v2"/>' };
|
|
21
|
+
const CODE = { color: '#0d9488', glyph: '<path d="m10 11.5-2 2 2 2m4-4 2 2-2 2"/>' };
|
|
22
|
+
const DATA = { color: '#0891b2', glyph: '<path d="M10.5 11c-1 0-1 .8-1 1.6s-.6 1.4-1 1.4c.4 0 1 .6 1 1.4s0 1.6 1 1.6m3-6c1 0 1 .8 1 1.6s.6 1.4 1 1.4c-.4 0-1 .6-1 1.4s0 1.6-1 1.6"/>' };
|
|
23
|
+
const TEXT = { color: '#64748b', glyph: '<path d="M8.5 11h7M8.5 14h7M8.5 17h7"/>' };
|
|
24
|
+
const FONT = { color: '#7c3aed', glyph: '<path d="m9 17.5 3-7 3 7m-5-2.2h4"/>' };
|
|
25
|
+
/** The default table: the usual extensions, by family of file. */
|
|
26
|
+
export const FILE_ICONS = {
|
|
27
|
+
...group('png jpg jpeg gif webp avif svg bmp ico tif tiff heic', IMAGE),
|
|
28
|
+
...group('mp4 mov webm mkv avi m4v', VIDEO),
|
|
29
|
+
...group('mp3 wav ogg flac m4a aac', AUDIO),
|
|
30
|
+
...group('zip rar 7z tar gz tgz bz2 xz', ARCHIVE),
|
|
31
|
+
...group('pdf', PDF),
|
|
32
|
+
...group('doc docx odt rtf pages', DOC),
|
|
33
|
+
...group('xls xlsx ods numbers', SHEET),
|
|
34
|
+
...group('ppt pptx odp key', SLIDES),
|
|
35
|
+
...group('js mjs cjs ts tsx jsx svelte vue html css scss py rb go rs java c cpp h php sh', CODE),
|
|
36
|
+
...group('json csv tsv xml yaml yml toml sql', DATA),
|
|
37
|
+
...group('txt md log ini env', TEXT),
|
|
38
|
+
...group('ttf otf woff woff2', FONT)
|
|
39
|
+
};
|
|
40
|
+
/** Extensions shown as a picture when the file has a URL. */
|
|
41
|
+
export const IMAGE_EXTENSIONS = new Set('png jpg jpeg gif webp avif svg bmp ico'.split(' '));
|
|
42
|
+
/** `photo.JPG` → `jpg`; no dot → `''`. */
|
|
43
|
+
export function extensionOf(name) {
|
|
44
|
+
const dot = name.lastIndexOf('.');
|
|
45
|
+
return dot > 0 ? name.slice(dot + 1).toLowerCase() : '';
|
|
46
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* family-types.ts — the `.d.ts` a family's stylesheet carries (ADR 0015).
|
|
3
|
+
*
|
|
4
|
+
* One function, three callers: the build (scripts/gen-components.mjs, for every
|
|
5
|
+
* family in src/scss), the app (a family loaded from disk, in its bundle), and
|
|
6
|
+
* anyone holding only a stylesheet. The text is DERIVED from the family's
|
|
7
|
+
* classification — which axis value, flag or part each of its classes is — and
|
|
8
|
+
* never written by hand: a hand-written declaration could promise a variant the
|
|
9
|
+
* stylesheet does not draw.
|
|
10
|
+
*
|
|
11
|
+
* Plain TypeScript with no imports and no syntax beyond annotations, so Node
|
|
12
|
+
* runs it as it is (type stripping) and the browser gets it through Vite.
|
|
13
|
+
*/
|
|
14
|
+
/** How a component accounts for one class (src/lib/generated/components.ts). */
|
|
15
|
+
export interface ClassKind {
|
|
16
|
+
kind: string;
|
|
17
|
+
component?: string;
|
|
18
|
+
axis?: string;
|
|
19
|
+
value?: string;
|
|
20
|
+
}
|
|
21
|
+
/** What one component declares: its namespace and its flag suffixes. */
|
|
22
|
+
export interface ComponentDecl {
|
|
23
|
+
prefix: string;
|
|
24
|
+
flags: string[];
|
|
25
|
+
}
|
|
26
|
+
/** What a family ships, per component namespace. */
|
|
27
|
+
export type FamilyShape = Record<string, {
|
|
28
|
+
/** axis → the values whose class the family draws. */
|
|
29
|
+
axes: Record<string, string[]>;
|
|
30
|
+
/** Flag class suffixes the family draws (`image-full`). */
|
|
31
|
+
flags: string[];
|
|
32
|
+
/** Whether the family reads the `--<prefix>-bg` slot `background` writes. */
|
|
33
|
+
background: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* A family's shape, from its classified classes and its stylesheet. A component
|
|
37
|
+
* appears as soon as the family draws any class of it; one it does not style at
|
|
38
|
+
* all is absent, and so are its props.
|
|
39
|
+
*/
|
|
40
|
+
export declare function familyShape(classes: Record<string, ClassKind>, schema: Record<string, ComponentDecl>, css: string): FamilyShape;
|
|
41
|
+
/**
|
|
42
|
+
* The text of `<family>.css.d.ts`: the family registered in the global
|
|
43
|
+
* `Sepale.Families` interface that `AxisProps` (variants.ts) reads.
|
|
44
|
+
*/
|
|
45
|
+
export declare function familyTypes(family: string, shape: FamilyShape): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* family-types.ts — the `.d.ts` a family's stylesheet carries (ADR 0015).
|
|
3
|
+
*
|
|
4
|
+
* One function, three callers: the build (scripts/gen-components.mjs, for every
|
|
5
|
+
* family in src/scss), the app (a family loaded from disk, in its bundle), and
|
|
6
|
+
* anyone holding only a stylesheet. The text is DERIVED from the family's
|
|
7
|
+
* classification — which axis value, flag or part each of its classes is — and
|
|
8
|
+
* never written by hand: a hand-written declaration could promise a variant the
|
|
9
|
+
* stylesheet does not draw.
|
|
10
|
+
*
|
|
11
|
+
* Plain TypeScript with no imports and no syntax beyond annotations, so Node
|
|
12
|
+
* runs it as it is (type stripping) and the browser gets it through Vite.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* A family's shape, from its classified classes and its stylesheet. A component
|
|
16
|
+
* appears as soon as the family draws any class of it; one it does not style at
|
|
17
|
+
* all is absent, and so are its props.
|
|
18
|
+
*/
|
|
19
|
+
export function familyShape(classes, schema, css) {
|
|
20
|
+
const shape = {};
|
|
21
|
+
for (const [cls, info] of Object.entries(classes)) {
|
|
22
|
+
const decl = info.component ? schema[info.component] : undefined;
|
|
23
|
+
if (!decl)
|
|
24
|
+
continue;
|
|
25
|
+
const { prefix } = decl;
|
|
26
|
+
const e = (shape[prefix] ??= { axes: {}, flags: [], background: css.includes(`var(--${prefix}-bg`) });
|
|
27
|
+
if (info.kind === 'axis' && info.axis && info.value !== undefined) {
|
|
28
|
+
(e.axes[info.axis] ??= []).push(info.value);
|
|
29
|
+
}
|
|
30
|
+
else if (info.kind === 'flag') {
|
|
31
|
+
const suffix = cls.slice(prefix.length + 1);
|
|
32
|
+
if (decl.flags.includes(suffix))
|
|
33
|
+
e.flags.push(suffix);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const e of Object.values(shape)) {
|
|
37
|
+
for (const values of Object.values(e.axes))
|
|
38
|
+
values.sort();
|
|
39
|
+
e.flags.sort();
|
|
40
|
+
}
|
|
41
|
+
return shape;
|
|
42
|
+
}
|
|
43
|
+
const q = (s) => `'${s.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;
|
|
44
|
+
const union = (values) => (values.length ? values.map(q).join(' | ') : 'never');
|
|
45
|
+
/**
|
|
46
|
+
* The text of `<family>.css.d.ts`: the family registered in the global
|
|
47
|
+
* `Sepale.Families` interface that `AxisProps` (variants.ts) reads.
|
|
48
|
+
*/
|
|
49
|
+
export function familyTypes(family, shape) {
|
|
50
|
+
const T = '\t';
|
|
51
|
+
const lines = [
|
|
52
|
+
`// ${family}.css — what this family draws, for @sepale/components.`,
|
|
53
|
+
`// Generated from the stylesheet (ADR 0015): do not edit, regenerate it.`,
|
|
54
|
+
`//`,
|
|
55
|
+
`// Importing the stylesheet registers it: \`import '<path>/${family}.css'\` in any`,
|
|
56
|
+
`// file narrows every component's props to what ${family} ships. To register it`,
|
|
57
|
+
`// for its types only: \`import type {} from '<path>/${family}.css'\`.`,
|
|
58
|
+
``,
|
|
59
|
+
`declare global {`,
|
|
60
|
+
`${T}namespace Sepale {`,
|
|
61
|
+
`${T}${T}interface Families {`,
|
|
62
|
+
`${T}${T}${T}${q(family)}: {`
|
|
63
|
+
];
|
|
64
|
+
for (const [prefix, { axes, flags, background }] of Object.entries(shape).sort(([a], [b]) => a.localeCompare(b))) {
|
|
65
|
+
const axisText = Object.entries(axes)
|
|
66
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
67
|
+
.map(([axis, values]) => `${q(axis)}: ${union(values)}`)
|
|
68
|
+
.join('; ');
|
|
69
|
+
lines.push(`${T}${T}${T}${T}${q(prefix)}: { axes: { ${axisText}${axisText ? ' ' : ''}}; flags: ${union(flags)}; background: ${background} };`);
|
|
70
|
+
}
|
|
71
|
+
lines.push(`${T}${T}${T}};`, `${T}${T}}`, `${T}}`, `}`, ``, `export {};`, ``);
|
|
72
|
+
return lines.join('\n');
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** How a component accounts for one of its classes. */
|
|
2
|
+
export interface ClassInfo {
|
|
3
|
+
kind: 'root' | 'axis' | 'flag' | 'part' | 'unclassified';
|
|
4
|
+
/** The wrapper that owns it, if there is one. */
|
|
5
|
+
component?: string;
|
|
6
|
+
/** kind 'axis': the axis it belongs to, and the prop value that writes it. */
|
|
7
|
+
axis?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
/** kind 'flag': the boolean prop that writes it. */
|
|
10
|
+
prop?: string;
|
|
11
|
+
}
|
|
12
|
+
/** class name → what that class is. */
|
|
13
|
+
export declare const classes: Record<string, ClassInfo>;
|
|
14
|
+
/** component → axis → the values it accepts. */
|
|
15
|
+
export declare const axes: Record<string, Record<string, string[]>>;
|
|
16
|
+
/** component → the boolean props it accepts. */
|
|
17
|
+
export declare const flags: Record<string, string[]>;
|