@octans/ui 1.0.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 +226 -0
- package/bin/octans-icons.mjs +208 -0
- package/dist/components/ActionList/ActionList.vue.d.ts +77 -0
- package/dist/components/ActionList/ActionListButton.vue.d.ts +85 -0
- package/dist/components/ActionList/ActionListMenu.vue.d.ts +18 -0
- package/dist/components/ActionList/index.d.ts +1 -0
- package/dist/components/AppFrame/AppFrame.vue.d.ts +26 -0
- package/dist/components/AppFrame/context.d.ts +40 -0
- package/dist/components/AppFrame/index.d.ts +3 -0
- package/dist/components/AppFrame/types.d.ts +52 -0
- package/dist/components/Badge/Badge.vue.d.ts +125 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Banner/Banner.vue.d.ts +239 -0
- package/dist/components/Banner/index.d.ts +1 -0
- package/dist/components/Button/Button.vue.d.ts +284 -0
- package/dist/components/Button/ButtonGroup.vue.d.ts +44 -0
- package/dist/components/Button/ButtonGroupItem.vue.d.ts +5 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Calendar/Calendar.vue.d.ts +15 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/Calendar/types.d.ts +39 -0
- package/dist/components/CalendarHeatmap/CalendarHeatmap.vue.d.ts +21 -0
- package/dist/components/CalendarHeatmap/index.d.ts +2 -0
- package/dist/components/CalendarHeatmap/types.d.ts +168 -0
- package/dist/components/Caption/Caption.vue.d.ts +5 -0
- package/dist/components/Caption/index.d.ts +1 -0
- package/dist/components/Card/Card.vue.d.ts +82 -0
- package/dist/components/Card/CardSection.vue.d.ts +89 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Card/utils.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.vue.d.ts +171 -0
- package/dist/components/Checkbox/CheckboxControl.vue.d.ts +59 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Choice/Choice.vue.d.ts +102 -0
- package/dist/components/Choice/index.d.ts +1 -0
- package/dist/components/ChoiceList/ChoiceList.vue.d.ts +199 -0
- package/dist/components/ChoiceList/index.d.ts +2 -0
- package/dist/components/ChoiceList/types.d.ts +31 -0
- package/dist/components/ColorPicker/ColorPicker.vue.d.ts +18 -0
- package/dist/components/ColorPicker/index.d.ts +2 -0
- package/dist/components/ColorPicker/types.d.ts +62 -0
- package/dist/components/ColorSelector/ColorSelector.vue.d.ts +34 -0
- package/dist/components/ColorSelector/index.d.ts +2 -0
- package/dist/components/ColorSelector/types.d.ts +143 -0
- package/dist/components/DataTable/BulkActions.vue.d.ts +282 -0
- package/dist/components/DataTable/DataTable.vue.d.ts +40 -0
- package/dist/components/DataTable/DataTableFooter.vue.d.ts +22 -0
- package/dist/components/DataTable/index.d.ts +2 -0
- package/dist/components/DataTable/types.d.ts +249 -0
- package/dist/components/DatePicker/DatePicker.vue.d.ts +17 -0
- package/dist/components/DatePicker/index.d.ts +4 -0
- package/dist/components/DatePicker/types.d.ts +57 -0
- package/dist/components/Divider/Divider.vue.d.ts +20 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Divider/types.d.ts +76 -0
- package/dist/components/EventDelegator/EventDelegator.vue.d.ts +18 -0
- package/dist/components/EventDelegator/index.d.ts +1 -0
- package/dist/components/EventDelegator/utils.d.ts +25 -0
- package/dist/components/FileInput/DropZone.vue.d.ts +67 -0
- package/dist/components/FileInput/FileInput.vue.d.ts +422 -0
- package/dist/components/FileInput/ItemList.vue.d.ts +109 -0
- package/dist/components/FileInput/index.d.ts +1 -0
- package/dist/components/FileInput/utils.d.ts +15 -0
- package/dist/components/Filters/FilterActions.vue.d.ts +236 -0
- package/dist/components/Filters/FilterItem.vue.d.ts +813 -0
- package/dist/components/Filters/Filters.vue.d.ts +1627 -0
- package/dist/components/Filters/index.d.ts +1 -0
- package/dist/components/Filters/utils.d.ts +1 -0
- package/dist/components/FooterHelp/FooterHelp.vue.d.ts +16 -0
- package/dist/components/FooterHelp/index.d.ts +1 -0
- package/dist/components/FormLayout/FormLayout.vue.d.ts +5 -0
- package/dist/components/FormLayout/FormLayoutGroup.vue.d.ts +17 -0
- package/dist/components/FormLayout/index.d.ts +2 -0
- package/dist/components/Formatter/Formatter.vue.d.ts +42 -0
- package/dist/components/Formatter/index.d.ts +1 -0
- package/dist/components/GlobalNav/GlobalNav.vue.d.ts +33 -0
- package/dist/components/GlobalNav/index.d.ts +2 -0
- package/dist/components/GlobalNav/types.d.ts +64 -0
- package/dist/components/GradientPicker/GradientPicker.vue.d.ts +20 -0
- package/dist/components/GradientPicker/index.d.ts +2 -0
- package/dist/components/GradientPicker/types.d.ts +74 -0
- package/dist/components/Heading/Heading.vue.d.ts +18 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/Icon/Icon.vue.d.ts +112 -0
- package/dist/components/Icon/iconBundle.d.ts +1 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/InlineError/InlineError.vue.d.ts +6 -0
- package/dist/components/InlineError/index.d.ts +1 -0
- package/dist/components/Labelled/Labelled.vue.d.ts +110 -0
- package/dist/components/Labelled/index.d.ts +1 -0
- package/dist/components/Layout/Layout.vue.d.ts +13 -0
- package/dist/components/Layout/LayoutSection.vue.d.ts +16 -0
- package/dist/components/Layout/LayoutSectionAnnotated.vue.d.ts +34 -0
- package/dist/components/Layout/index.d.ts +3 -0
- package/dist/components/LineClamper/LineClamper.vue.d.ts +16 -0
- package/dist/components/LineClamper/index.d.ts +2 -0
- package/dist/components/LineClamper/types.d.ts +7 -0
- package/dist/components/Link/Link.vue.d.ts +19 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/List/List.vue.d.ts +15 -0
- package/dist/components/List/ListItem.vue.d.ts +16 -0
- package/dist/components/List/index.d.ts +3 -0
- package/dist/components/List/types.d.ts +51 -0
- package/dist/components/LoaderOverlay/LoaderOverlay.vue.d.ts +18 -0
- package/dist/components/LoaderOverlay/host.d.ts +6 -0
- package/dist/components/LoaderOverlay/index.d.ts +26 -0
- package/dist/components/LoaderOverlay/store.d.ts +7 -0
- package/dist/components/LoaderOverlay/types.d.ts +24 -0
- package/dist/components/LoadingBar/LoadingBar.vue.d.ts +7 -0
- package/dist/components/LoadingBar/host.d.ts +6 -0
- package/dist/components/LoadingBar/index.d.ts +28 -0
- package/dist/components/LoadingBar/store.d.ts +6 -0
- package/dist/components/LoadingBar/types.d.ts +16 -0
- package/dist/components/MaybeMountingPortal/MaybeMountingPortal.vue.d.ts +53 -0
- package/dist/components/MaybeMountingPortal/index.d.ts +1 -0
- package/dist/components/MaybeRouterLink/MaybeRouterLink.vue.d.ts +34 -0
- package/dist/components/MaybeRouterLink/index.d.ts +2 -0
- package/dist/components/MaybeRouterLink/types.d.ts +49 -0
- package/dist/components/Modal/Modal.vue.d.ts +28 -0
- package/dist/components/Modal/ModalBackdrop.vue.d.ts +12 -0
- package/dist/components/Modal/ModalHost.vue.d.ts +3 -0
- package/dist/components/Modal/ModalStackItem.vue.d.ts +14 -0
- package/dist/components/Modal/api/AlertModal.vue.d.ts +10 -0
- package/dist/components/Modal/api/Base.d.ts +12 -0
- package/dist/components/Modal/api/ConfirmModal.vue.d.ts +10 -0
- package/dist/components/Modal/api/GenericModal.vue.d.ts +10 -0
- package/dist/components/Modal/api/PromptModal.vue.d.ts +10 -0
- package/dist/components/Modal/api/types.d.ts +110 -0
- package/dist/components/Modal/host.d.ts +2 -0
- package/dist/components/Modal/index.d.ts +10 -0
- package/dist/components/Modal/manager.d.ts +80 -0
- package/dist/components/Modal/types.d.ts +49 -0
- package/dist/components/NavField/NavField.vue.d.ts +223 -0
- package/dist/components/NavField/index.d.ts +1 -0
- package/dist/components/Navigation/Navigation.vue.d.ts +47 -0
- package/dist/components/Navigation/components/Item.vue.d.ts +10 -0
- package/dist/components/Navigation/components/Section.vue.d.ts +13 -0
- package/dist/components/Navigation/index.d.ts +2 -0
- package/dist/components/Navigation/types.d.ts +117 -0
- package/dist/components/OtpInput/OtpInput.vue.d.ts +21 -0
- package/dist/components/OtpInput/index.d.ts +2 -0
- package/dist/components/OtpInput/types.d.ts +87 -0
- package/dist/components/Page/Page.vue.d.ts +34 -0
- package/dist/components/Page/index.d.ts +2 -0
- package/dist/components/Page/types.d.ts +75 -0
- package/dist/components/PageActions/PageActions.vue.d.ts +6 -0
- package/dist/components/PageActions/index.d.ts +2 -0
- package/dist/components/PageActions/types.d.ts +17 -0
- package/dist/components/Pagination/Pagination.vue.d.ts +22 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Popper/Popper.vue.d.ts +45 -0
- package/dist/components/Popper/index.d.ts +2 -0
- package/dist/components/Popper/types.d.ts +29 -0
- package/dist/components/PreventAutoComplete/PreventAutoComplete.vue.d.ts +24 -0
- package/dist/components/PreventAutoComplete/index.d.ts +1 -0
- package/dist/components/ProgressBar/ProgressBar.vue.d.ts +48 -0
- package/dist/components/ProgressBar/index.d.ts +2 -0
- package/dist/components/RadioButton/RadioButton.vue.d.ts +143 -0
- package/dist/components/RadioButton/RadioButtonControl.vue.d.ts +50 -0
- package/dist/components/RadioButton/index.d.ts +2 -0
- package/dist/components/RangeSlider/RangeSlider.vue.d.ts +303 -0
- package/dist/components/RangeSlider/index.d.ts +1 -0
- package/dist/components/Rating/Rating.vue.d.ts +20 -0
- package/dist/components/Rating/index.d.ts +2 -0
- package/dist/components/Rating/types.d.ts +78 -0
- package/dist/components/ResourceList/ResourceItem.vue.d.ts +17 -0
- package/dist/components/ResourceList/ResourceList.vue.d.ts +19 -0
- package/dist/components/ResourceList/index.d.ts +3 -0
- package/dist/components/ResourceList/types.d.ts +19 -0
- package/dist/components/SaveBar/SaveBar.vue.d.ts +15 -0
- package/dist/components/SaveBar/index.d.ts +4 -0
- package/dist/components/SaveBar/store.d.ts +56 -0
- package/dist/components/SaveBar/types.d.ts +42 -0
- package/dist/components/SaveBarController/SaveBarController.vue.d.ts +40 -0
- package/dist/components/SaveBarController/index.d.ts +1 -0
- package/dist/components/ScrollPane/ScrollPane.vue.d.ts +24 -0
- package/dist/components/ScrollPane/index.d.ts +2 -0
- package/dist/components/ScrollPane/types.d.ts +64 -0
- package/dist/components/SegmentedControl/SegmentedControl.vue.d.ts +39 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SegmentedControl/types.d.ts +119 -0
- package/dist/components/Select/Select.vue.d.ts +901 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Sheet/Sheet.vue.d.ts +41 -0
- package/dist/components/Sheet/index.d.ts +2 -0
- package/dist/components/Sheet/manager.d.ts +34 -0
- package/dist/components/Sheet/types.d.ts +92 -0
- package/dist/components/SkeletonBodyText/SkeletonBodyText.vue.d.ts +17 -0
- package/dist/components/SkeletonBodyText/index.d.ts +1 -0
- package/dist/components/SkeletonCard/SkeletonCard.vue.d.ts +34 -0
- package/dist/components/SkeletonCard/index.d.ts +1 -0
- package/dist/components/SkeletonDisplayText/SkeletonDisplayText.vue.d.ts +17 -0
- package/dist/components/SkeletonDisplayText/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.vue.d.ts +52 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Splitter/Splitter.vue.d.ts +60 -0
- package/dist/components/Splitter/index.d.ts +2 -0
- package/dist/components/Splitter/types.d.ts +177 -0
- package/dist/components/Stack/Stack.vue.d.ts +130 -0
- package/dist/components/Stack/StackItem.vue.d.ts +23 -0
- package/dist/components/Stack/index.d.ts +2 -0
- package/dist/components/StatGroup/Stat.vue.d.ts +16 -0
- package/dist/components/StatGroup/StatGroup.vue.d.ts +17 -0
- package/dist/components/StatGroup/index.d.ts +3 -0
- package/dist/components/StatGroup/types.d.ts +42 -0
- package/dist/components/Sticky/Sticky.vue.d.ts +27 -0
- package/dist/components/Sticky/index.d.ts +2 -0
- package/dist/components/Sticky/types.d.ts +24 -0
- package/dist/components/SyntaxHighlighter/SyntaxHighlighter.vue.d.ts +12 -0
- package/dist/components/SyntaxHighlighter/index.d.ts +2 -0
- package/dist/components/SyntaxHighlighter/types.d.ts +10 -0
- package/dist/components/Tabs/Tabs.vue.d.ts +23 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/types.d.ts +19 -0
- package/dist/components/Tag/Tag.vue.d.ts +29 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/TextContainer/TextContainer.vue.d.ts +13 -0
- package/dist/components/TextContainer/index.d.ts +1 -0
- package/dist/components/TextField/TextField.vue.d.ts +38 -0
- package/dist/components/TextField/index.d.ts +2 -0
- package/dist/components/TextField/types.d.ts +130 -0
- package/dist/components/TextStyle/TextStyle.vue.d.ts +15 -0
- package/dist/components/TextStyle/index.d.ts +1 -0
- package/dist/components/Thumbnail/Thumbnail.vue.d.ts +17 -0
- package/dist/components/Thumbnail/index.d.ts +2 -0
- package/dist/components/Thumbnail/types.d.ts +32 -0
- package/dist/components/TimePicker/TimePicker.vue.d.ts +25 -0
- package/dist/components/TimePicker/index.d.ts +2 -0
- package/dist/components/TimePicker/types.d.ts +90 -0
- package/dist/components/TimezonePicker/TimezonePicker.vue.d.ts +15 -0
- package/dist/components/TimezonePicker/index.d.ts +2 -0
- package/dist/components/TimezonePicker/types.d.ts +50 -0
- package/dist/components/TimezonePicker/zoneCountries.d.ts +2 -0
- package/dist/components/ToastManager/ProgressBar.vue.d.ts +8 -0
- package/dist/components/ToastManager/Toast.vue.d.ts +14 -0
- package/dist/components/ToastManager/ToastManager.vue.d.ts +19 -0
- package/dist/components/ToastManager/host.d.ts +14 -0
- package/dist/components/ToastManager/index.d.ts +24 -0
- package/dist/components/ToastManager/manager.d.ts +45 -0
- package/dist/components/ToastManager/types.d.ts +44 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.vue.d.ts +35 -0
- package/dist/components/ToggleSwitch/index.d.ts +2 -0
- package/dist/components/ToggleSwitch/types.d.ts +84 -0
- package/dist/components/Tooltip/Tooltip.vue.d.ts +20 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/UiProvider/UiProvider.vue.d.ts +16 -0
- package/dist/components/UiProvider/index.d.ts +2 -0
- package/dist/components/UiProvider/types.d.ts +2 -0
- package/dist/components/UiProvider/utils.d.ts +5 -0
- package/dist/components/UnstyledLink/UnstyledLink.vue.d.ts +5 -0
- package/dist/components/UnstyledLink/index.d.ts +1 -0
- package/dist/components/all.d.ts +92 -0
- package/dist/components/types.d.ts +74 -0
- package/dist/globalExtensions.d.ts +7 -0
- package/dist/i18n/en.json.d.ts +60 -0
- package/dist/lib.d.ts +67 -0
- package/dist/lib.umd.d.ts +1 -0
- package/dist/style.css +2 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/ui.js +20051 -0
- package/dist/ui.umd.js +10 -0
- package/dist/utils/autoHost.d.ts +27 -0
- package/dist/utils/color.d.ts +112 -0
- package/dist/utils/colorRamp.d.ts +51 -0
- package/dist/utils/createTheme.d.ts +52 -0
- package/dist/utils/customTheme.d.ts +73 -0
- package/dist/utils/date.d.ts +4 -0
- package/dist/utils/debounce.d.ts +3 -0
- package/dist/utils/deferredPromise.d.ts +6 -0
- package/dist/utils/format.d.ts +9 -0
- package/dist/utils/fuzzy.d.ts +33 -0
- package/dist/utils/gradient.d.ts +83 -0
- package/dist/utils/index.d.ts +31 -0
- package/dist/utils/loader.d.ts +1 -0
- package/dist/utils/positionPanel.d.ts +32 -0
- package/dist/utils/radix.d.ts +6 -0
- package/dist/utils/theme.d.ts +42 -0
- package/dist/utils/timezone.d.ts +66 -0
- package/dist/utils/tokens.d.ts +62 -0
- package/dist/utils/translate.d.ts +27 -0
- package/dist/zoneCountries-CWZGMHyp.js +353 -0
- package/package.json +120 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* The bookkeeping behind "works with nothing mounted": counts how many outlet
|
|
4
|
+
* components are currently rendering a piece of global UI, so the auto-mounted
|
|
5
|
+
* fallback host knows when it is needed and when to stand down. The pattern
|
|
6
|
+
* comes from `ToastManager` — see the comments in its `host.ts`.
|
|
7
|
+
*/
|
|
8
|
+
export interface HostRegistryType {
|
|
9
|
+
readonly count: number;
|
|
10
|
+
add(): void;
|
|
11
|
+
remove(): void;
|
|
12
|
+
/** Notified whenever an outlet mounts. Returns an unsubscribe function. */
|
|
13
|
+
watch(fn: () => void): () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function createHostRegistry(): HostRegistryType;
|
|
16
|
+
/**
|
|
17
|
+
* An auto-mounted host for one outlet component. `ensure()` mounts it on first
|
|
18
|
+
* use so the imperative API works with nothing placed in the page; an outlet
|
|
19
|
+
* the consumer mounts themselves takes over, and the auto host retires.
|
|
20
|
+
*
|
|
21
|
+
* `app.unmount()` is a real teardown — every `onUnmounted` runs — so nothing
|
|
22
|
+
* is left behind on the page or in memory.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createAutoHost(registry: HostRegistryType, id: string, component: Component, props?: Record<string, unknown>): {
|
|
25
|
+
ensure: () => void;
|
|
26
|
+
teardown: () => void;
|
|
27
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colour values: parsing, formatting and conversion.
|
|
3
|
+
*
|
|
4
|
+
* Everything here works on one shape — `Rgba`, with channels in 0–255 and
|
|
5
|
+
* alpha in 0–1 — and converts in and out of it. That keeps the conversions to
|
|
6
|
+
* a hub-and-spoke set rather than a mesh, and means a colour picker only ever
|
|
7
|
+
* holds one representation.
|
|
8
|
+
*
|
|
9
|
+
* Channels are kept as floats internally and only rounded when formatted.
|
|
10
|
+
* Rounding on every conversion is what makes a picker drift: drag the hue
|
|
11
|
+
* slider back and forth and the colour slowly changes under you.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately NOT supported: named colours (`rebeccapurple`), `var()`,
|
|
14
|
+
* `color-mix()` and `color()`. Resolving those needs either a large table or a
|
|
15
|
+
* live document, and guessing is worse than refusing — a silently wrong colour
|
|
16
|
+
* is much harder to notice than a colour that plainly did not apply. Callers
|
|
17
|
+
* get `null` and can fall back to a text field.
|
|
18
|
+
*/
|
|
19
|
+
export interface Rgba {
|
|
20
|
+
/** 0–255. */
|
|
21
|
+
r: number;
|
|
22
|
+
/** 0–255. */
|
|
23
|
+
g: number;
|
|
24
|
+
/** 0–255. */
|
|
25
|
+
b: number;
|
|
26
|
+
/** 0–1. */
|
|
27
|
+
a: number;
|
|
28
|
+
}
|
|
29
|
+
/** How a colour is written out. Parsing accepts all of these regardless. */
|
|
30
|
+
export type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'oklch';
|
|
31
|
+
export interface ColorFormatOption {
|
|
32
|
+
value: ColorFormat;
|
|
33
|
+
label: string;
|
|
34
|
+
/** One line, for a tooltip or helper text. */
|
|
35
|
+
description: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const COLOR_FORMATS: ColorFormatOption[];
|
|
38
|
+
/**
|
|
39
|
+
* Parses any colour form this module understands into `Rgba`.
|
|
40
|
+
*
|
|
41
|
+
* Accepts `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()`, `rgba()`, `hsl()`,
|
|
42
|
+
* `hsla()`, `oklab()`, `oklch()` and the keyword `transparent`. Returns `null`
|
|
43
|
+
* for anything else — see the note at the top of the file.
|
|
44
|
+
*
|
|
45
|
+
* Colours outside sRGB (which `oklch()` can easily express) are clamped into
|
|
46
|
+
* gamut on the way in, since the whole module works in sRGB.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseColor(value: string): Rgba | null;
|
|
49
|
+
/** `{ r: 255, g: 0, b: 128 }` → `#ff0080`. Alpha is ignored. */
|
|
50
|
+
export declare function formatHex(c: Rgba): string;
|
|
51
|
+
/**
|
|
52
|
+
* Writes a colour out in the given format.
|
|
53
|
+
*
|
|
54
|
+
* `alpha` controls whether transparency may be expressed at all: with it off
|
|
55
|
+
* the colour is written opaque, which is what a picker in "no alpha" mode
|
|
56
|
+
* needs so that a stray transparent value cannot leak into the output.
|
|
57
|
+
* Otherwise alpha is only included when it is actually below 1 — nobody wants
|
|
58
|
+
* `#5f63e8ff` back when they typed `#5f63e8`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function formatColor(c: Rgba, format?: ColorFormat, alpha?: boolean): string;
|
|
61
|
+
/**
|
|
62
|
+
* The format a string was written in, so an editor can keep using it rather
|
|
63
|
+
* than rewriting the user's value into its own preferred form. Returns `null`
|
|
64
|
+
* for anything unparseable.
|
|
65
|
+
*/
|
|
66
|
+
export declare function detectFormat(value: string): ColorFormat | null;
|
|
67
|
+
/** Returns `[hue 0–360, saturation 0–1, lightness 0–1]`. */
|
|
68
|
+
export declare function rgbToHsl({ r, g, b }: Rgba): [number, number, number];
|
|
69
|
+
/** `h` in degrees, `s` and `l` in 0–1. Alpha is left to the caller. */
|
|
70
|
+
export declare function hslToRgb(h: number, s: number, l: number): Omit<Rgba, 'a'>;
|
|
71
|
+
/**
|
|
72
|
+
* Returns `[hue 0–360, saturation 0–1, value 0–1]`.
|
|
73
|
+
*
|
|
74
|
+
* HSV rather than HSL because it is what a picker's square is: x is saturation
|
|
75
|
+
* and y is value, so the top-right corner is the pure hue. The same square in
|
|
76
|
+
* HSL would put the pure hue in the middle of the right edge and waste half the
|
|
77
|
+
* area on colours the user rarely wants.
|
|
78
|
+
*/
|
|
79
|
+
export declare function rgbToHsv({ r, g, b }: Rgba): [number, number, number];
|
|
80
|
+
/** `h` in degrees, `s` and `v` in 0–1. */
|
|
81
|
+
export declare function hsvToRgb(h: number, s: number, v: number): Omit<Rgba, 'a'>;
|
|
82
|
+
export declare function toLinear(c: number): number;
|
|
83
|
+
export declare function fromLinear(c: number): number;
|
|
84
|
+
/** Returns `[L 0–1, a, b]`. */
|
|
85
|
+
export declare function rgbToOklab({ r, g, b }: Rgba): [number, number, number];
|
|
86
|
+
/**
|
|
87
|
+
* OKLab back to sRGB, clamped into gamut.
|
|
88
|
+
*
|
|
89
|
+
* OKLab describes far more colours than sRGB holds, so an out-of-gamut result
|
|
90
|
+
* has to go somewhere. Clamping each channel is what a browser effectively does
|
|
91
|
+
* when it has to produce a legacy `rgb()` output, so a colour generated here
|
|
92
|
+
* matches what CSS would have shown. Proper gamut mapping (reducing chroma
|
|
93
|
+
* until the colour fits) would be more faithful but would no longer agree with
|
|
94
|
+
* the browser.
|
|
95
|
+
*/
|
|
96
|
+
export declare function oklabToRgb(L: number, A: number, B: number): Omit<Rgba, 'a'>;
|
|
97
|
+
/** Returns `[L 0–1, chroma, hue in degrees]`. */
|
|
98
|
+
export declare function rgbToOklch(c: Rgba): [number, number, number];
|
|
99
|
+
/** Below this a colour is grey, and its hue is meaningless noise. */
|
|
100
|
+
export declare const ACHROMATIC = 0.0001;
|
|
101
|
+
/**
|
|
102
|
+
* WCAG relative luminance, 0–1. Alpha is ignored — a colour has to be composited
|
|
103
|
+
* against something before its contrast means anything.
|
|
104
|
+
*/
|
|
105
|
+
export declare function relativeLuminance({ r, g, b }: Rgba): number;
|
|
106
|
+
/**
|
|
107
|
+
* Whether black text reads better than white on this colour. Used to keep a
|
|
108
|
+
* swatch's own label legible whatever colour it is showing.
|
|
109
|
+
*/
|
|
110
|
+
export declare function prefersDarkText(c: Rgba): boolean;
|
|
111
|
+
/** Composites a colour over an opaque backdrop, so its alpha can be seen. */
|
|
112
|
+
export declare function flatten(c: Rgba, backdrop: Rgba): Rgba;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ColorFormat, Rgba } from './color';
|
|
2
|
+
import { Gradient } from './gradient';
|
|
3
|
+
export interface RampStepPosition {
|
|
4
|
+
/** The step's number, e.g. `200`. */
|
|
5
|
+
step: number;
|
|
6
|
+
/** Where it samples the gradient, 0–1. */
|
|
7
|
+
t: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Maps step numbers onto positions along a gradient.
|
|
11
|
+
*
|
|
12
|
+
* The numbers are spread across 0–1 by VALUE, not by index: on a `[0, 50, 100,
|
|
13
|
+
* 200, … 950]` ramp the gap from 500 to 600 is a tenth of the gap from 100 to
|
|
14
|
+
* 300, and the generated colours honour that. That is what makes a generated
|
|
15
|
+
* ramp line up with a hand-authored one, where the number has always meant "how
|
|
16
|
+
* far along". A generator that spaced these evenly would put `500` at 6/11 and
|
|
17
|
+
* quietly stop matching the ramp it replaced.
|
|
18
|
+
*
|
|
19
|
+
* Exported because a caller may want the mapping without the colours — to label
|
|
20
|
+
* a step with where it sits, or to check a ramp lines up with an existing one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stepPositions(steps: number[]): RampStepPosition[];
|
|
23
|
+
/**
|
|
24
|
+
* Samples a gradient at each step, returning `{ [step]: '#rrggbb' }`.
|
|
25
|
+
*
|
|
26
|
+
* The lowest and highest steps land exactly on whatever the gradient holds at
|
|
27
|
+
* its two ends. Returns `null` if any stop is not a colour that can be parsed,
|
|
28
|
+
* or if there are no steps — a caller should treat that as "not a ramp" rather
|
|
29
|
+
* than substituting black, since a silently wrong ramp is much harder to notice
|
|
30
|
+
* than one that plainly did not generate.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rampColors(gradient: Gradient, steps: number[], format?: ColorFormat): Record<number, string> | null;
|
|
33
|
+
/**
|
|
34
|
+
* Builds the three-stop gradient a seed colour implies.
|
|
35
|
+
*
|
|
36
|
+
* The seed always sits at the domain's midpoint — step 500 — exactly as Ant
|
|
37
|
+
* Design's generator pins the seed to its palette slot. The colour you picked
|
|
38
|
+
* IS `<role>-500`, whatever its lightness; a pastel seed simply yields a pale
|
|
39
|
+
* upper half. Predictability beats cleverness here: "your colour is 500" is a
|
|
40
|
+
* rule a theme author can hold in their head.
|
|
41
|
+
*
|
|
42
|
+
* Returns `null` for an unparseable seed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function seedGradient(seed: string | Rgba): Gradient | null;
|
|
45
|
+
/**
|
|
46
|
+
* The whole derivation in one call: seed in, `{ step: '#rrggbb' }` out.
|
|
47
|
+
*
|
|
48
|
+
* Steps sample the gradient at `step / 1000` — see `RAMP_DOMAIN`. Returns
|
|
49
|
+
* `null` if the seed cannot be parsed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function seedRampColors(seed: string | Rgba, steps: number[], format?: ColorFormat): Record<number, string> | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CustomTheme } from './customTheme';
|
|
2
|
+
import { ThemeType } from './theme';
|
|
3
|
+
/** The ramp prefixes a seed can be given for, in display order. */
|
|
4
|
+
export declare const THEME_SEED_ROLES: readonly ["neutral", "primary", "secondary", "tertiary", "info", "success", "warning", "error"];
|
|
5
|
+
export type ThemeSeedRoleType = (typeof THEME_SEED_ROLES)[number];
|
|
6
|
+
export type ThemeRadiusPresetType = 'none' | 'small' | 'medium' | 'large';
|
|
7
|
+
export interface CreateThemeOptions {
|
|
8
|
+
/** Human-readable name, shown in the Theme Builder. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Storage id. Generated from the name when omitted. */
|
|
11
|
+
id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Which built-in theme to layer on. `'light'` unless stated — but note the
|
|
14
|
+
* ramps generated here feed BOTH themes; `base` only picks the starting
|
|
15
|
+
* point for anything you did not seed.
|
|
16
|
+
*/
|
|
17
|
+
base?: ThemeType;
|
|
18
|
+
/** Tints every grey — surfaces, text and borders follow. */
|
|
19
|
+
neutral?: string;
|
|
20
|
+
/** The brand colour. The single highest-leverage seed. */
|
|
21
|
+
primary?: string;
|
|
22
|
+
secondary?: string;
|
|
23
|
+
tertiary?: string;
|
|
24
|
+
info?: string;
|
|
25
|
+
success?: string;
|
|
26
|
+
warning?: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Corner rounding, as a preset or explicit `{ field, box }` lengths.
|
|
30
|
+
* `medium` is the built-in default (4px controls / 8px containers).
|
|
31
|
+
*/
|
|
32
|
+
radius?: ThemeRadiusPresetType | {
|
|
33
|
+
field: string;
|
|
34
|
+
box: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates a sparse `CustomTheme` from seed colours.
|
|
39
|
+
*
|
|
40
|
+
* Each seed becomes a full ramp via `seedGradient` — the seed itself lands
|
|
41
|
+
* exactly on step 500. `text-on-<role>` is chosen by measuring the generated
|
|
42
|
+
* fill: white unless the fill is light enough to want dark text.
|
|
43
|
+
*
|
|
44
|
+
* Throws on an unparseable seed rather than skipping it — a silently missing
|
|
45
|
+
* ramp looks like the theme applied and did nothing.
|
|
46
|
+
*
|
|
47
|
+
* One honest limitation: a very light seed (a pastel) generates a light upper
|
|
48
|
+
* half, and the `text-<role>` tokens that point at steps 600–700 can land
|
|
49
|
+
* under WCAG's 4.5:1 for text. `pnpm run check:contrast` guards the built-in
|
|
50
|
+
* palette only; check generated themes with the Theme Builder's preview.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createTheme(options: CreateThemeOptions): CustomTheme;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ThemeType } from './theme';
|
|
2
|
+
import { Gradient } from './gradient';
|
|
3
|
+
export interface CustomTheme {
|
|
4
|
+
/** Unique identifier, also used as the storage key suffix. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Human-readable name. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Which built-in theme this is layered on top of. */
|
|
9
|
+
base: ThemeType;
|
|
10
|
+
/** Sparse map of token name (no `--octans-` prefix) → value. */
|
|
11
|
+
tokens: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* The gradient each ramp was generated from, keyed by ramp prefix
|
|
14
|
+
* (`neutral`, `primary`, …).
|
|
15
|
+
*
|
|
16
|
+
* Purely editor state: `tokens` already holds every colour, so anything
|
|
17
|
+
* applying a theme can ignore this entirely. It is stored because a gradient
|
|
18
|
+
* is NOT recoverable from the steps it produced — a five-stop gradient and a
|
|
19
|
+
* two-stop one can pass through the same dozen samples — so without it,
|
|
20
|
+
* reopening a theme would offer you a ramp you could no longer edit as the
|
|
21
|
+
* thing you built.
|
|
22
|
+
*/
|
|
23
|
+
ramps?: Record<string, Gradient>;
|
|
24
|
+
}
|
|
25
|
+
/** Every saved theme, newest last. */
|
|
26
|
+
export declare function listCustomThemes(): CustomTheme[];
|
|
27
|
+
export declare function getCustomTheme(id: string): CustomTheme | undefined;
|
|
28
|
+
/** Creates or replaces a saved theme, matched by `id`. */
|
|
29
|
+
export declare function saveCustomTheme(theme: CustomTheme): CustomTheme[];
|
|
30
|
+
export declare function deleteCustomTheme(id: string): CustomTheme[];
|
|
31
|
+
export declare function getActiveCustomThemeId(): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Applies a theme's overrides to the document, switching to its base theme
|
|
34
|
+
* first so unset tokens resolve correctly.
|
|
35
|
+
*
|
|
36
|
+
* Pass `target` to scope the overrides to one subtree instead. The base theme
|
|
37
|
+
* still switches document-wide — it is an attribute on `<html>`, not a set of
|
|
38
|
+
* properties — so the rest of the page follows light/dark but keeps its
|
|
39
|
+
* untouched token values.
|
|
40
|
+
*
|
|
41
|
+
* Scoped application is deliberately not remembered: `restoreCustomTheme()`
|
|
42
|
+
* would have nowhere to put it on the next page load.
|
|
43
|
+
*/
|
|
44
|
+
export declare function applyCustomTheme(theme: CustomTheme, target?: HTMLElement): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes any custom overrides, returning to the plain base theme. Pass the
|
|
47
|
+
* same `target` that was given to `applyCustomTheme` to clear a scoped theme.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clearCustomTheme(target?: HTMLElement): void;
|
|
50
|
+
/**
|
|
51
|
+
* Re-applies whichever custom theme was last active. Call once at startup, the
|
|
52
|
+
* same way you'd call `persistTheme()`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function restoreCustomTheme(): CustomTheme | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The value a token currently resolves to, as the browser computes it —
|
|
57
|
+
* including inherited and overridden values. Used to seed the editor with real
|
|
58
|
+
* starting values rather than blanks.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getResolvedTokenValue(name: string): string;
|
|
61
|
+
export declare function exportCustomTheme(theme: CustomTheme): string;
|
|
62
|
+
export declare class ThemeImportError extends Error {
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parses and validates a theme JSON string.
|
|
66
|
+
*
|
|
67
|
+
* Deliberately strict: unknown token names are rejected rather than silently
|
|
68
|
+
* dropped, because a typo would otherwise look like it applied and simply do
|
|
69
|
+
* nothing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function importCustomTheme(json: string): CustomTheme;
|
|
72
|
+
/** Slug + short suffix, so two themes named the same don't collide. */
|
|
73
|
+
export declare function createThemeId(name: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FormatContextInterface {
|
|
2
|
+
locale?: string;
|
|
3
|
+
currency?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const emptyValuePlaceholder = "\u2014";
|
|
6
|
+
export declare const formatters: Record<string, any>;
|
|
7
|
+
export declare function format(value: string | number, format: string, context?: FormatContextInterface): any;
|
|
8
|
+
export declare function isNumericType(type: string): boolean;
|
|
9
|
+
export declare function isSummableNumericType(type: string): type is "decimal" | "currency" | "integer";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy (subsequence) matching, used by `Select`'s `fuzzy` prop and exported so
|
|
3
|
+
* applications can use the same behaviour in their own filters.
|
|
4
|
+
*
|
|
5
|
+
* The rule is simply that every character of the query appears in the text, in
|
|
6
|
+
* order, but not necessarily together — so `gwp` finds "Girl **w**ith a
|
|
7
|
+
* **P**earl Earring" and `strnght` finds "The Starry Night".
|
|
8
|
+
*
|
|
9
|
+
* Scoring exists so the good matches float to the top. Without it, fuzzy
|
|
10
|
+
* matching is worse than a plain substring filter: it returns far more rows and
|
|
11
|
+
* puts them in an arbitrary order.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Scores `query` against `text`. Higher is better; `null` means no match.
|
|
15
|
+
*
|
|
16
|
+
* An empty query matches everything with a score of `0`, which keeps
|
|
17
|
+
* "no filter typed yet" from being a special case at every call site.
|
|
18
|
+
*
|
|
19
|
+
* Greedy left-to-right rather than optimal: finding the genuinely best
|
|
20
|
+
* alignment is quadratic, and for option-list lengths the difference in
|
|
21
|
+
* ordering is not worth the cost.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fuzzyScore(query: string, text: string): number | null;
|
|
24
|
+
/** Whether `query` fuzzy-matches `text` at all, ignoring how well. */
|
|
25
|
+
export declare function fuzzyMatch(query: string, text: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Filters and re-orders `items` by how well they match `query`.
|
|
28
|
+
*
|
|
29
|
+
* `getText` may return several strings — a label and a description, say — and
|
|
30
|
+
* the item scores as its best one. Ties keep their original order, so a list
|
|
31
|
+
* that was already meaningfully sorted stays that way.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fuzzyFilter<T>(query: string, items: T[], getText: (item: T) => string | (string | undefined | null)[]): T[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Rgba } from './color';
|
|
2
|
+
export type InterpolationSpace = 'oklch' | 'oklab' | 'srgb' | 'hsl';
|
|
3
|
+
export interface InterpolationSpaceOption {
|
|
4
|
+
value: InterpolationSpace;
|
|
5
|
+
label: string;
|
|
6
|
+
/** One line, for a tooltip or helper text. */
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
/** The offered interpolation spaces, best-first. */
|
|
10
|
+
export declare const INTERPOLATION_SPACES: InterpolationSpaceOption[];
|
|
11
|
+
/**
|
|
12
|
+
* One colour `t` of the way from `a` to `b`, interpolated in `space`.
|
|
13
|
+
*
|
|
14
|
+
* `t` is clamped, so callers do not have to guard against a gradient whose
|
|
15
|
+
* samples run outside its endpoints.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mixColors(a: Rgba, b: Rgba, t: number, space?: InterpolationSpace): Rgba;
|
|
18
|
+
export type GradientType = 'linear' | 'radial' | 'conic';
|
|
19
|
+
export interface GradientTypeOption {
|
|
20
|
+
value: GradientType;
|
|
21
|
+
label: string;
|
|
22
|
+
description: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const GRADIENT_TYPES: GradientTypeOption[];
|
|
25
|
+
export interface GradientStop {
|
|
26
|
+
/** Any colour `parseColor` understands. */
|
|
27
|
+
color: string;
|
|
28
|
+
/** Where along the gradient it sits, 0–100. */
|
|
29
|
+
position: number;
|
|
30
|
+
}
|
|
31
|
+
export interface Gradient {
|
|
32
|
+
type: GradientType;
|
|
33
|
+
/** Degrees. Used by `linear` and `conic`; ignored by `radial`. */
|
|
34
|
+
angle: number;
|
|
35
|
+
/** At least two, in any order — sampling and CSS output sort them. */
|
|
36
|
+
stops: GradientStop[];
|
|
37
|
+
space: InterpolationSpace;
|
|
38
|
+
}
|
|
39
|
+
/** A sensible two-stop gradient, as a starting point for an editor. */
|
|
40
|
+
export declare function createGradient(partial?: Partial<Gradient>): Gradient;
|
|
41
|
+
interface ResolvedStop {
|
|
42
|
+
color: Rgba;
|
|
43
|
+
position: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses and sorts the stops, or returns `null` if any colour is unusable.
|
|
47
|
+
*
|
|
48
|
+
* All-or-nothing on purpose: dropping the one stop that failed would silently
|
|
49
|
+
* produce a different gradient from the one that was asked for.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveStops(stops: GradientStop[]): ResolvedStop[] | null;
|
|
52
|
+
/**
|
|
53
|
+
* The colour at `t` (0–1) along the gradient, or `null` if a stop is unusable.
|
|
54
|
+
*
|
|
55
|
+
* Only the stops and the interpolation space matter here — `type` and `angle`
|
|
56
|
+
* describe how the gradient is *painted*, which is a separate question from
|
|
57
|
+
* what colour sits at a given fraction of the way along it. That is why a ramp
|
|
58
|
+
* can be generated from a conic gradient and still make sense.
|
|
59
|
+
*/
|
|
60
|
+
export declare function sampleGradient(gradient: Gradient, t: number): Rgba | null;
|
|
61
|
+
/**
|
|
62
|
+
* The gradient as a CSS `*-gradient()` value.
|
|
63
|
+
*
|
|
64
|
+
* The stops are baked out as our own samples rather than handed to the browser
|
|
65
|
+
* as two endpoints and an `in oklch` hint. Two reasons: the result is then
|
|
66
|
+
* identical to what `sampleGradient` produces, so a preview cannot disagree
|
|
67
|
+
* with the values it is previewing; and it renders the same in browsers that do
|
|
68
|
+
* not support interpolation hints, instead of silently falling back to sRGB and
|
|
69
|
+
* looking muddy.
|
|
70
|
+
*
|
|
71
|
+
* Real stop positions are always emitted exactly, so a hard stop (two stops at
|
|
72
|
+
* the same position) stays hard rather than being blurred across a sample.
|
|
73
|
+
*/
|
|
74
|
+
export declare function gradientCss(gradient: Gradient, resolution?: number): string;
|
|
75
|
+
/**
|
|
76
|
+
* Validates an unknown value as a `Gradient`.
|
|
77
|
+
*
|
|
78
|
+
* Used when importing a saved theme, where the JSON is whatever someone pasted
|
|
79
|
+
* in. Strict rather than forgiving: a gradient that is half-understood would
|
|
80
|
+
* regenerate a ramp into colours nobody chose.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isGradient(value: unknown): value is Gradient;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { VNode, Slot } from 'vue';
|
|
2
|
+
import { default as isEqual } from 'lodash-es/isEqual';
|
|
3
|
+
import { default as orderBy } from 'lodash-es/orderBy';
|
|
4
|
+
import { default as memoize } from 'lodash-es/memoize';
|
|
5
|
+
export { isEqual, orderBy, memoize };
|
|
6
|
+
export * from './deferredPromise';
|
|
7
|
+
export * from './date';
|
|
8
|
+
export * from './loader';
|
|
9
|
+
export declare function capitalize(str: string): string;
|
|
10
|
+
export declare function flattenSlotChildren(children: VNode[]): VNode[];
|
|
11
|
+
export declare function isEmptyValue(value: any): boolean;
|
|
12
|
+
export declare function nonEmptyChildren(vnodes: VNode[]): VNode[];
|
|
13
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
14
|
+
export declare function pad(value: number): string;
|
|
15
|
+
export declare function inputToNumber(value: any): any;
|
|
16
|
+
export declare function scrollIntoViewIfNeeded(el?: HTMLElement & {
|
|
17
|
+
scrollIntoViewIfNeeded?: () => void;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare function cloneDeep(value: any): any;
|
|
20
|
+
export declare function escapeRegExp(string: string): string;
|
|
21
|
+
export declare function createWildcardRegExp(string: string): RegExp;
|
|
22
|
+
export declare function isEqualUnordered(array1: any[] | any, array2: any[] | any): boolean;
|
|
23
|
+
export declare function isVNode(value: any): value is VNode;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a VNode has meaningful content (not just comments, whitespace, or empty fragments)
|
|
26
|
+
*/
|
|
27
|
+
export declare function vnodeHasContent(vnode: VNode): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a slot has meaningful content (not just comments, empty templates, or whitespace)
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasSlotContent(slot: Slot | undefined, props?: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function load(urls: string[]): Promise<void[]>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Placement } from '@floating-ui/dom';
|
|
2
|
+
export type { Placement };
|
|
3
|
+
export interface PositionPanelOptions {
|
|
4
|
+
/** Preferred placement. Flips to the opposite side when it does not fit. */
|
|
5
|
+
placement?: Placement;
|
|
6
|
+
/** Gap between the reference and the panel, in pixels. */
|
|
7
|
+
offset?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Called with the placement actually used, and again whenever it changes —
|
|
10
|
+
* a panel that flips to `top-start` usually needs different styling.
|
|
11
|
+
*/
|
|
12
|
+
onPlacement?: (placement: Placement) => void;
|
|
13
|
+
/** Called once, after the first position lands. */
|
|
14
|
+
onFirstUpdate?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface PanelPosition {
|
|
17
|
+
/** Reposition now. `autoUpdate` covers scroll and resize on its own. */
|
|
18
|
+
update: () => void;
|
|
19
|
+
/** Stops tracking and releases the observers. */
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Positions a floating panel against a reference element and keeps it there
|
|
24
|
+
* while the page scrolls or either element resizes.
|
|
25
|
+
*
|
|
26
|
+
* This is the only imperative positioning in the library. `<Popper>` — and so
|
|
27
|
+
* `ActionList`, `DatePicker`, `TimePicker` and `ColorSelector` — goes through
|
|
28
|
+
* reka-ui, which does its own on the same floating-ui underneath. This exists
|
|
29
|
+
* for `Select`, whose dropdown is hand-rolled rather than a `<Popper>`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function positionPanel(reference: HTMLElement, panel: HTMLElement, options?: PositionPanelOptions): PanelPosition;
|
|
32
|
+
export default positionPanel;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PopperPlacementType } from '../components/Popper';
|
|
2
|
+
import { PopoverContentProps } from 'reka-ui';
|
|
3
|
+
export declare function getRadixPopperPlacement(placement: PopperPlacementType | ''): {
|
|
4
|
+
side: PopoverContentProps['side'];
|
|
5
|
+
align: PopoverContentProps['align'];
|
|
6
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Light/dark theme control.
|
|
3
|
+
*
|
|
4
|
+
* Themes are driven by a `data-octans-theme` attribute on `<html>`:
|
|
5
|
+
*
|
|
6
|
+
* - `'light'` / `'dark'` — an explicit choice, which always wins.
|
|
7
|
+
* - `'system'` — remove the attribute and let `prefers-color-scheme` decide.
|
|
8
|
+
*
|
|
9
|
+
* The token stylesheet is written so that all three work without JavaScript;
|
|
10
|
+
* these helpers only set the attribute.
|
|
11
|
+
*/
|
|
12
|
+
export type ThemeType = 'light' | 'dark';
|
|
13
|
+
export type ThemePreferenceType = ThemeType | 'system';
|
|
14
|
+
/** The preference as set — may be `'system'`. */
|
|
15
|
+
export declare function getThemePreference(): ThemePreferenceType;
|
|
16
|
+
/**
|
|
17
|
+
* The theme actually in effect. Resolves `'system'` against
|
|
18
|
+
* `prefers-color-scheme`, defaulting to light where that can't be determined.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getResolvedTheme(): ThemeType;
|
|
21
|
+
/**
|
|
22
|
+
* Sets the theme. Pass `'system'` to follow the operating system.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* setTheme('dark')
|
|
26
|
+
* setTheme('system')
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function setTheme(next: ThemePreferenceType): void;
|
|
30
|
+
/** Flips between light and dark, resolving `'system'` first. */
|
|
31
|
+
export declare function toggleTheme(): ThemeType;
|
|
32
|
+
/**
|
|
33
|
+
* Subscribes to theme changes — including system changes while the preference
|
|
34
|
+
* is `'system'`. Returns an unsubscribe function.
|
|
35
|
+
*/
|
|
36
|
+
export declare function onThemeChange(fn: (theme: ThemeType) => void): () => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Restores a previously persisted preference and starts saving future changes
|
|
39
|
+
* to `localStorage`. Entirely optional — call it once at startup if you want
|
|
40
|
+
* the choice to survive a reload.
|
|
41
|
+
*/
|
|
42
|
+
export declare function persistTheme(storageKey?: string): void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone helpers built on the platform's `Intl` APIs.
|
|
3
|
+
*
|
|
4
|
+
* The library ships no timezone database. Zone ids, display names and country
|
|
5
|
+
* names all come from `Intl`, which means they are always current with the
|
|
6
|
+
* host's tzdata and localised for free.
|
|
7
|
+
*
|
|
8
|
+
* The one thing `Intl` has no API for is mapping a zone to a country, so that
|
|
9
|
+
* map is generated into `TimezonePicker/zoneCountries.ts` (~10 kB) and imported
|
|
10
|
+
* *dynamically* — apps that don't group by country never download it.
|
|
11
|
+
*/
|
|
12
|
+
export interface TimezoneOptionType {
|
|
13
|
+
/** IANA id, e.g. `Australia/Sydney`. */
|
|
14
|
+
value: string;
|
|
15
|
+
/** e.g. `Sydney, Australia`. */
|
|
16
|
+
label: string;
|
|
17
|
+
/** e.g. `Australian Eastern Time (GMT+10)`. */
|
|
18
|
+
description: string;
|
|
19
|
+
/** Region prefix of the id, e.g. `Australia`. Used for grouping. */
|
|
20
|
+
region: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Every zone the runtime knows about.
|
|
24
|
+
*
|
|
25
|
+
* `Intl.supportedValuesOf` is ES2022. Older engines get a small fallback list
|
|
26
|
+
* rather than an empty picker — enough to be usable, and `guessTimezone()`
|
|
27
|
+
* still resolves the user's actual zone either way.
|
|
28
|
+
*/
|
|
29
|
+
export declare function listTimezones(): string[];
|
|
30
|
+
/** The user's current zone, or `UTC` if it can't be determined. */
|
|
31
|
+
export declare function guessTimezone(): string;
|
|
32
|
+
export declare function isValidTimezone(zone: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* A human name for the zone, localised — `Australian Eastern Time`,
|
|
35
|
+
* `India Standard Time`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTimezoneName(zone: string, locale?: string): string;
|
|
38
|
+
/** Current UTC offset as a short label — `GMT+10`, `GMT-4`, `GMT+5:30`. */
|
|
39
|
+
export declare function getTimezoneOffset(zone: string, locale?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Turns an IANA id into something readable: `Australia/Sydney` →
|
|
42
|
+
* `Sydney, Australia`. Underscores become spaces and the path is reversed, so
|
|
43
|
+
* the city — the part people search for — leads.
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatTimezoneId(zone: string): string;
|
|
46
|
+
/** The leading region of an id: `Australia/Sydney` → `Australia`. */
|
|
47
|
+
export declare function getTimezoneRegion(zone: string): string;
|
|
48
|
+
/** Builds the option list the picker renders. */
|
|
49
|
+
export declare function getTimezoneOptions(locale?: string): TimezoneOptionType[];
|
|
50
|
+
export interface TimezoneCountryType {
|
|
51
|
+
/** ISO 3166-1 alpha-2 code. */
|
|
52
|
+
value: string;
|
|
53
|
+
/** Localised country name. */
|
|
54
|
+
label: string;
|
|
55
|
+
/** Zones belonging to this country, sorted by label. */
|
|
56
|
+
zones: string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Loads the zone → country map and inverts it into a country list.
|
|
60
|
+
*
|
|
61
|
+
* Dynamically imported on purpose: it is the only bundled timezone data, and
|
|
62
|
+
* only country grouping needs it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function loadTimezoneCountries(locale?: string): Promise<TimezoneCountryType[]>;
|
|
65
|
+
/** Looks up the country code for a zone, without loading the whole list. */
|
|
66
|
+
export declare function getTimezoneCountry(zone: string): Promise<string | undefined>;
|