@adaptabletools/adaptable 24.0.0-canary.6 → 24.0.0-canary.7
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/index.css +29 -173
- package/package.json +1 -1
- package/src/AdaptableOptions/UserInterfaceOptions.d.ts +4 -6
- package/src/AdaptableState/StyledColumns/GradientStyle.d.ts +4 -0
- package/src/Api/Implementation/QuickSearchApiImpl.js +2 -2
- package/src/Api/Implementation/UserInterfaceApiImpl.d.ts +0 -1
- package/src/Api/Implementation/UserInterfaceApiImpl.js +9 -15
- package/src/Api/Internal/AdaptableInternalApi.js +5 -3
- package/src/Api/Internal/StateInternalApi.js +4 -3
- package/src/Api/UserInterfaceApi.d.ts +0 -4
- package/src/Redux/ActionsReducers/QuickSearchRedux.d.ts +9 -0
- package/src/Redux/ActionsReducers/QuickSearchRedux.js +9 -0
- package/src/Redux/Store/AdaptableStore.js +4 -2
- package/src/Utilities/Helpers/UIHelper.d.ts +6 -11
- package/src/Utilities/Helpers/UIHelper.js +6 -33
- package/src/View/Components/Popups/AdaptablePopup/Navigation.js +9 -11
- package/src/View/Components/StyleComponent.js +2 -2
- package/src/View/Dashboard/Dashboard.d.ts +1 -1
- package/src/View/Dashboard/Dashboard.js +1 -1
- package/src/View/QuickSearch/QuickSearchInput.js +1 -1
- package/src/View/QuickSearch/QuickSearchPopup.d.ts +1 -1
- package/src/View/QuickSearch/QuickSearchPopup.js +1 -1
- package/src/View/QuickSearch/Utilities/useQuickSearchDebounced.d.ts +2 -2
- package/src/View/StyledColumn/RangesComponent.js +8 -11
- package/src/View/StyledColumn/Wizard/BadgePillStyleEditor.d.ts +0 -2
- package/src/View/StyledColumn/Wizard/BadgePillStyleEditor.js +2 -2
- package/src/View/StyledColumn/Wizard/StyledColumnBadgeSection.js +2 -3
- package/src/View/StyledColumn/Wizard/StyledColumnSliceStyleEditors.d.ts +0 -3
- package/src/View/StyledColumn/Wizard/StyledColumnSliceStyleEditors.js +3 -3
- package/src/View/StyledColumn/Wizard/StyledColumnSparklineSettingsSection.js +7 -11
- package/src/View/StyledColumn/Wizard/StyledColumnWizardBulletSection.js +4 -4
- package/src/View/StyledColumn/Wizard/StyledColumnWizardGradientSection.js +2 -2
- package/src/View/StyledColumn/Wizard/StyledColumnWizardIconSection.js +2 -2
- package/src/View/StyledColumn/Wizard/StyledColumnWizardRangeBarSection.js +7 -7
- package/src/View/StyledColumn/Wizard/StyledColumnWizardRatingSection.js +4 -4
- package/src/View/StyledColumn/Wizard/StyledColumnWizardStyleSection/StyledColumnWizardStyleSection.js +3 -3
- package/src/components/ColorField/index.d.ts +14 -0
- package/src/components/ColorField/index.js +6 -0
- package/src/env.js +2 -2
- package/src/migration/VersionUpgrade24.d.ts +9 -0
- package/src/migration/VersionUpgrade24.js +27 -0
- package/src/setupDevTools.js +163 -9
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/vendor/components/ColorField/index.d.ts +43 -0
- package/vendor/components/ColorField/index.d.ts.map +1 -0
- package/vendor/components/ColorField/index.js +81 -0
- package/vendor/components/ColorField/index.js.map +1 -0
- package/vendor/components/ColorPicker/colorPickerTab.d.ts +2 -2
- package/vendor/components/ColorPicker/colorPickerTab.d.ts.map +1 -1
- package/vendor/components/ColorPicker/colorPickerTab.js +6 -28
- package/vendor/components/ColorPicker/colorPickerTab.js.map +1 -1
- package/vendor/components/ColorPicker/index.d.ts +36 -8
- package/vendor/components/ColorPicker/index.d.ts.map +1 -1
- package/vendor/components/ColorPicker/index.js +97 -25
- package/vendor/components/ColorPicker/index.js.map +1 -1
- package/vendor/components/ColorPicker/themeColors.d.ts +33 -4
- package/vendor/components/ColorPicker/themeColors.d.ts.map +1 -1
- package/vendor/components/ColorPicker/themeColors.js +76 -18
- package/vendor/components/ColorPicker/themeColors.js.map +1 -1
- package/vendor/components/NumberInput/index.d.ts +51 -0
- package/vendor/components/NumberInput/index.d.ts.map +1 -0
- package/vendor/components/NumberInput/index.js +82 -0
- package/vendor/components/NumberInput/index.js.map +1 -0
- package/vendor/components/index.css +67 -24
- package/vendor/components/index.d.ts +6 -2
- package/vendor/components/index.d.ts.map +1 -1
- package/vendor/components/index.js +3 -1
- package/vendor/components/index.js.map +1 -1
- package/vendor/components/ui/input-group.d.ts.map +1 -1
- package/vendor/components/ui/input-group.js +5 -4
- package/vendor/components/ui/input-group.js.map +1 -1
- package/src/components/ColorPicker/ColorPicker.d.ts +0 -12
- package/src/components/ColorPicker/ColorPicker.js +0 -48
- package/src/components/ColorPicker/OptionalColorPicker.d.ts +0 -12
- package/src/components/ColorPicker/OptionalColorPicker.js +0 -13
- package/src/components/ColorPicker/index.d.ts +0 -2
- package/src/components/ColorPicker/index.js +0 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ColorPickerTab } from '../ColorPicker';
|
|
3
|
+
export type ColorFieldProps = {
|
|
4
|
+
/**
|
|
5
|
+
* CSS colour — a theme token as `var(--ab-color-…)` or a custom hex;
|
|
6
|
+
* `undefined` means "not set" (the cell keeps its default).
|
|
7
|
+
*/
|
|
8
|
+
value: string | undefined;
|
|
9
|
+
onChange: (value: string | undefined) => void;
|
|
10
|
+
/** Whether the colour can go back to "not set"; default `true`. */
|
|
11
|
+
clearable?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Where the precise picker starts while nothing is set (a hex or a theme token). */
|
|
14
|
+
defaultColor?: string;
|
|
15
|
+
/** Whether a custom colour can have opacity; default `true`. */
|
|
16
|
+
includeAlpha?: boolean;
|
|
17
|
+
/** Default `'Precise'`. */
|
|
18
|
+
preciseTabLabel?: ReactNode;
|
|
19
|
+
/** Default `'Palette'`. */
|
|
20
|
+
colorsTabLabel?: ReactNode;
|
|
21
|
+
/** The tab the picker opens on; see `ColorPickerProps.defaultTab`. */
|
|
22
|
+
defaultTab?: ColorPickerTab;
|
|
23
|
+
/** The picker tab shown, for a controlled picker; see `ColorPickerProps.tab`. */
|
|
24
|
+
tab?: ColorPickerTab;
|
|
25
|
+
/** When the user switches picker tabs. */
|
|
26
|
+
onTabChange?: (tab: ColorPickerTab) => void;
|
|
27
|
+
/** Mount node for the picker popover; the overlay host's by default. */
|
|
28
|
+
container?: HTMLElement | null;
|
|
29
|
+
/** Tooltip on the swatch button. */
|
|
30
|
+
title?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
'data-name': string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The colour input: a swatch that opens the {@link ColorPicker} — the
|
|
37
|
+
* Adaptable theme colours (stored as `var(--ab-color-…)` so they follow the
|
|
38
|
+
* theme) or a precise colour — with a clear button so a colour can go back to
|
|
39
|
+
* "not set" instead of being stuck on the last pick. Unset shows a
|
|
40
|
+
* transparency checkerboard rather than a fake grey.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ColorField(props: ColorFieldProps): import("react").JSX.Element;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ColorField/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAIpE,OAAO,EAGL,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC9C,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2BAA2B;IAC3B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,2BAA2B;IAC3B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,sEAAsE;IACtE,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,iFAAiF;IACjF,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IAC5C,wEAAwE;IACxE,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAwEF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,+BAwFhD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { X } from 'lucide-react';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
import { CHECKERBOARD, ColorPicker, describeColor, HEX_COLOR, } from '../ColorPicker';
|
|
6
|
+
import { cn } from '../lib/utils';
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
|
8
|
+
/**
|
|
9
|
+
* Dragging in the precise picker fires a change for every pixel. Committing
|
|
10
|
+
* each one restyles the grid (and persists state) at 60 Hz, which is what
|
|
11
|
+
* makes the swatch lag behind the cursor. Instead the field shows its own
|
|
12
|
+
* draft immediately and hands the latest colour to the host at most once per
|
|
13
|
+
* `COMMIT_INTERVAL`, plus once more when it unmounts mid-drag.
|
|
14
|
+
*/
|
|
15
|
+
const COMMIT_INTERVAL = 100;
|
|
16
|
+
function useDraftColor(value, onChange) {
|
|
17
|
+
const [draft, setDraft] = useState(value);
|
|
18
|
+
const pending = useRef(null);
|
|
19
|
+
const timer = useRef(null);
|
|
20
|
+
const latestOnChange = useRef(onChange);
|
|
21
|
+
latestOnChange.current = onChange;
|
|
22
|
+
const flush = () => {
|
|
23
|
+
timer.current = null;
|
|
24
|
+
if (pending.current) {
|
|
25
|
+
const { value: next } = pending.current;
|
|
26
|
+
pending.current = null;
|
|
27
|
+
latestOnChange.current(next);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const cancel = () => {
|
|
31
|
+
if (timer.current) {
|
|
32
|
+
clearTimeout(timer.current);
|
|
33
|
+
timer.current = null;
|
|
34
|
+
}
|
|
35
|
+
pending.current = null;
|
|
36
|
+
};
|
|
37
|
+
// Follow the host (clear button, undo, another editor) — but not while a
|
|
38
|
+
// newer draft is still waiting to be committed.
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!pending.current) {
|
|
41
|
+
setDraft(value);
|
|
42
|
+
}
|
|
43
|
+
}, [value]);
|
|
44
|
+
useEffect(() => () => {
|
|
45
|
+
if (timer.current) {
|
|
46
|
+
clearTimeout(timer.current);
|
|
47
|
+
flush();
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
/** Continuous input: shown now, committed on the interval. */
|
|
51
|
+
const setColor = (next) => {
|
|
52
|
+
setDraft(next);
|
|
53
|
+
pending.current = { value: next };
|
|
54
|
+
if (timer.current === null) {
|
|
55
|
+
timer.current = setTimeout(flush, COMMIT_INTERVAL);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** Discrete choice (a swatch, a typed hex, clear): committed right away. */
|
|
59
|
+
const commit = (next) => {
|
|
60
|
+
cancel();
|
|
61
|
+
setDraft(next);
|
|
62
|
+
latestOnChange.current(next);
|
|
63
|
+
};
|
|
64
|
+
return { draft, setColor, commit };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The colour input: a swatch that opens the {@link ColorPicker} — the
|
|
68
|
+
* Adaptable theme colours (stored as `var(--ab-color-…)` so they follow the
|
|
69
|
+
* theme) or a precise colour — with a clear button so a colour can go back to
|
|
70
|
+
* "not set" instead of being stuck on the last pick. Unset shows a
|
|
71
|
+
* transparency checkerboard rather than a fake grey.
|
|
72
|
+
*/
|
|
73
|
+
export function ColorField(props) {
|
|
74
|
+
const { clearable = true, disabled = false } = props;
|
|
75
|
+
const dataName = props['data-name'];
|
|
76
|
+
const { draft: value, setColor, commit } = useDraftColor(props.value, props.onChange);
|
|
77
|
+
const [open, setOpen] = useState(false);
|
|
78
|
+
const isCustom = !!value && HEX_COLOR.test(value);
|
|
79
|
+
return (_jsxs("div", { className: cn('twa:flex twa:h-input twa:min-w-0 twa:items-center twa:gap-1.5', disabled && 'twa:opacity-50', props.className), children: [_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { id: props.id, title: props.title, disabled: disabled, "data-name": dataName, "data-value": value, "aria-label": value ? `Colour: ${describeColor(value)}` : 'Colour: not set', className: cn('twa:relative twa:block twa:h-input twa:w-12 twa:shrink-0 twa:cursor-pointer twa:overflow-hidden twa:rounded-md twa:border twa:border-input twa:p-0', 'twa:focus-visible:outline-none twa:focus-visible:ring-2 twa:focus-visible:ring-ring/50', 'twa:disabled:cursor-not-allowed'), children: _jsx("span", { "data-name": `${dataName}-swatch`, "data-value": value, style: value ? { backgroundColor: value } : CHECKERBOARD, className: "twa:absolute twa:inset-0" }) }), _jsx(PopoverContent, { align: "start", container: props.container, "data-name": `${dataName}-popover`, className: "twa:w-[300px] twa:p-3", children: _jsx(ColorPicker, { "data-name": dataName, value: value, onInput: setColor, onCommit: commit, onSwatchPicked: () => setOpen(false), defaultColor: props.defaultColor, includeAlpha: props.includeAlpha, preciseTabLabel: props.preciseTabLabel, colorsTabLabel: props.colorsTabLabel, defaultTab: props.defaultTab, tab: props.tab, onTabChange: props.onTabChange }) })] }), value ? (_jsxs(_Fragment, { children: [_jsx("span", { title: value, "data-name": `${dataName}-label`, className: cn('twa:min-w-0 twa:truncate twa:text-xs twa:text-muted-foreground', isCustom && 'twa:font-mono'), children: describeColor(value) }), clearable ? (_jsx(Button, { variant: "ghost", size: "icon-xs", disabled: disabled, "data-name": `${dataName}-clear`, tooltip: "Clear", onClick: () => commit(undefined), children: _jsx(X, { "aria-hidden": true }) })) : null] })) : (_jsx("span", { className: "twa:text-xs twa:text-muted-foreground", children: "Not set" }))] }));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ColorField/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,WAAW,EAEX,aAAa,EACb,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmCxE;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,SAAS,aAAa,CAAC,KAAyB,EAAE,QAA6C;IAC7F,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;IACjE,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,cAAc,CAAC,OAAO,GAAG,QAAQ,CAAC;IAElC,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;Q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AAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,uCAAuC,wBAAe,CACvE,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ColorPickerTab = '
|
|
1
|
+
export type ColorPickerTab = 'colors' | 'precise';
|
|
2
2
|
export declare function setColorPickerTab(tab: ColorPickerTab): void;
|
|
3
|
-
export declare function useColorPickerTab(): [ColorPickerTab, (tab: ColorPickerTab) => void];
|
|
3
|
+
export declare function useColorPickerTab(): [ColorPickerTab | null, (tab: ColorPickerTab) => void];
|
|
4
4
|
//# sourceMappingURL=colorPickerTab.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPickerTab.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/colorPickerTab.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"colorPickerTab.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/colorPickerTab.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAalD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,QAMpD;AASD,wBAAgB,iBAAiB,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC,CAG1F"}
|
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'react';
|
|
2
|
-
const DEFAULT_TAB = 'precise';
|
|
3
|
-
const STORAGE_KEY = 'adaptable.colorPicker.tab';
|
|
4
2
|
/**
|
|
5
|
-
* The tab the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* The tab the user last picked, shared by every colour picker on the page (not
|
|
4
|
+
* kept across reloads): a user who works from the palette should not have to
|
|
5
|
+
* switch to them in every field. `null` until the user picks one, so the
|
|
6
|
+
* picker's own default applies.
|
|
8
7
|
*/
|
|
9
8
|
let currentTab = null;
|
|
10
9
|
const listeners = new Set();
|
|
11
|
-
|
|
12
|
-
return value === 'swatches' || value === 'precise';
|
|
13
|
-
}
|
|
14
|
-
function readTab() {
|
|
15
|
-
if (currentTab === null) {
|
|
16
|
-
let stored = null;
|
|
17
|
-
try {
|
|
18
|
-
stored = window.localStorage.getItem(STORAGE_KEY);
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
// storage blocked — the in-memory value still covers this page
|
|
22
|
-
}
|
|
23
|
-
currentTab = isTab(stored) ? stored : DEFAULT_TAB;
|
|
24
|
-
}
|
|
25
|
-
return currentTab;
|
|
26
|
-
}
|
|
10
|
+
const readTab = () => currentTab;
|
|
27
11
|
export function setColorPickerTab(tab) {
|
|
28
12
|
if (tab === currentTab) {
|
|
29
13
|
return;
|
|
30
14
|
}
|
|
31
15
|
currentTab = tab;
|
|
32
|
-
try {
|
|
33
|
-
window.localStorage.setItem(STORAGE_KEY, tab);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// see above
|
|
37
|
-
}
|
|
38
16
|
listeners.forEach((listener) => listener());
|
|
39
17
|
}
|
|
40
18
|
function subscribe(listener) {
|
|
@@ -44,7 +22,7 @@ function subscribe(listener) {
|
|
|
44
22
|
};
|
|
45
23
|
}
|
|
46
24
|
export function useColorPickerTab() {
|
|
47
|
-
const tab = useSyncExternalStore(subscribe, readTab,
|
|
25
|
+
const tab = useSyncExternalStore(subscribe, readTab, readTab);
|
|
48
26
|
return [tab, setColorPickerTab];
|
|
49
27
|
}
|
|
50
28
|
//# sourceMappingURL=colorPickerTab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorPickerTab.js","sourceRoot":"","sources":["../../src/ColorPicker/colorPickerTab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI7C
|
|
1
|
+
{"version":3,"file":"colorPickerTab.js","sourceRoot":"","sources":["../../src/ColorPicker/colorPickerTab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI7C;;;;;GAKG;AACH,IAAI,UAAU,GAA0B,IAAI,CAAC;AAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;AAExC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;AAEjC,MAAM,UAAU,iBAAiB,CAAC,GAAmB;IACnD,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;QACvB,OAAO;IACT,CAAC;IACD,UAAU,GAAG,GAAG,CAAC;IACjB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,QAAoB;IACrC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,GAAG,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type CSSProperties } from 'react';
|
|
2
|
-
import { type
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type ColorPickerTab } from './colorPickerTab';
|
|
3
3
|
export { setColorPickerTab, useColorPickerTab } from './colorPickerTab';
|
|
4
4
|
export type { ColorPickerTab } from './colorPickerTab';
|
|
5
|
-
export { describeColor,
|
|
6
|
-
export type { ThemeColor, ThemeColorGroup } from './themeColors';
|
|
5
|
+
export { ALLOWED_COLORS_VAR, describeColor, PALETTE_COUNT_VAR, parseTabs, readAllowedColors, readPaletteColors, readTabs, TABS_VAR, THEME_COLOR_GROUP, } from './themeColors';
|
|
6
|
+
export type { AllowedColors, ThemeColor, ThemeColorGroup } from './themeColors';
|
|
7
7
|
export type ColorPickerProps = {
|
|
8
8
|
/** A theme token as `var(--ab-color-…)`, a hex, or nothing. */
|
|
9
9
|
value: string | undefined;
|
|
@@ -13,8 +13,28 @@ export type ColorPickerProps = {
|
|
|
13
13
|
onCommit: (value: string) => void;
|
|
14
14
|
/** After a swatch is picked — the one choice that ends the interaction. */
|
|
15
15
|
onSwatchPicked?: () => void;
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** A colour left out of the swatches, e.g. `var(--ab-color-x)` while editing `--ab-color-x`. */
|
|
17
|
+
excludeColor?: string;
|
|
18
|
+
/** Where the precise picker starts while nothing is set (a hex or a theme token); mid-grey by default. */
|
|
19
|
+
defaultColor?: string;
|
|
20
|
+
/** Whether a custom colour can have opacity; default `true`. */
|
|
21
|
+
includeAlpha?: boolean;
|
|
22
|
+
/** Default `'Precise'`. */
|
|
23
|
+
preciseTabLabel?: ReactNode;
|
|
24
|
+
/** Default `'Palette'`. */
|
|
25
|
+
colorsTabLabel?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* The tab to open on; wins over the tab the user last picked and the first
|
|
28
|
+
* tab in `--ab-cmp-color-picker__tabs`. Ignored when that tab is not shown.
|
|
29
|
+
*/
|
|
30
|
+
defaultTab?: ColorPickerTab;
|
|
31
|
+
/**
|
|
32
|
+
* The tab shown, for a controlled picker; wins over `defaultTab`. Ignored
|
|
33
|
+
* when that tab is not shown.
|
|
34
|
+
*/
|
|
35
|
+
tab?: ColorPickerTab;
|
|
36
|
+
/** When the user switches tabs. */
|
|
37
|
+
onTabChange?: (tab: ColorPickerTab) => void;
|
|
18
38
|
'data-name': string;
|
|
19
39
|
};
|
|
20
40
|
/** `#rrggbb`, or `#rrggbbaa` when the colour has opacity. */
|
|
@@ -22,10 +42,18 @@ export declare const HEX_COLOR: RegExp;
|
|
|
22
42
|
/** Transparency checkerboard — the "no colour" preview. */
|
|
23
43
|
export declare const CHECKERBOARD: CSSProperties;
|
|
24
44
|
/**
|
|
25
|
-
* The colour picker's popover body: a
|
|
45
|
+
* The colour picker's popover body: a palette tab with the Adaptable theme
|
|
26
46
|
* colours and a Precise tab with a free picker, over a footer shared by both —
|
|
27
47
|
* the current colour, an eyedropper where the browser has one, and a hex
|
|
28
|
-
* field.
|
|
48
|
+
* field.
|
|
49
|
+
*
|
|
50
|
+
* `--ab-cmp-color-picker__tabs` sets which tabs show and in what order. The
|
|
51
|
+
* picker shows `tab` when controlled; otherwise it opens on `defaultTab`, else
|
|
52
|
+
* on the tab the user last picked in any picker on the page (see
|
|
53
|
+
* `colorPickerTab.ts`), else on the first listed tab.
|
|
54
|
+
*
|
|
55
|
+
* `--ab-cmp-color-picker__allowed-colors: predefined` drops the Precise tab,
|
|
56
|
+
* so no custom colour can be picked; `palette` also drops the theme colours.
|
|
29
57
|
*/
|
|
30
58
|
export declare function ColorPicker(props: ColorPickerProps): import("react").JSX.Element;
|
|
31
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAUf,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAY1E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ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
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
3
3
|
import { Check, Grid2x2, Pipette, SlidersHorizontal } from 'lucide-react';
|
|
4
|
-
import { HexAlphaColorPicker } from 'react-colorful';
|
|
4
|
+
import { HexAlphaColorPicker, HexColorPicker } from 'react-colorful';
|
|
5
5
|
import { Button } from '../Button';
|
|
6
6
|
import { Tooltip } from '../Tooltip';
|
|
7
7
|
import { cn } from '../lib/utils';
|
|
8
8
|
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from '../ui/input-group';
|
|
9
9
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';
|
|
10
10
|
import { useColorPickerTab } from './colorPickerTab';
|
|
11
|
-
import { describeColor,
|
|
11
|
+
import { describeColor, readAllowedColors, readPaletteColors, readTabs, THEME_COLOR_GROUP, } from './themeColors';
|
|
12
12
|
export { setColorPickerTab, useColorPickerTab } from './colorPickerTab';
|
|
13
|
-
export { describeColor,
|
|
13
|
+
export { ALLOWED_COLORS_VAR, describeColor, PALETTE_COUNT_VAR, parseTabs, readAllowedColors, readPaletteColors, readTabs, TABS_VAR, THEME_COLOR_GROUP, } from './themeColors';
|
|
14
14
|
/** `#rrggbb`, or `#rrggbbaa` when the colour has opacity. */
|
|
15
15
|
export const HEX_COLOR = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
16
16
|
const HEX_DIGITS = /^([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
17
|
+
const OPAQUE_HEX_DIGITS = /^([0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
17
18
|
/**
|
|
18
19
|
* Both tabs' content is this tall, so switching tabs never resizes the
|
|
19
20
|
* popover. `flex-none` undoes the panel's default `flex-1`, which in the
|
|
20
21
|
* column-flex root would size it to its content instead.
|
|
21
22
|
*/
|
|
22
23
|
const CONTENT_HEIGHT = 'twa:h-52 twa:flex-none twa:p-1';
|
|
23
|
-
/** Where the precise picker starts while nothing is set. */
|
|
24
24
|
const PICKER_START = '#808080';
|
|
25
25
|
/** Transparency checkerboard — the "no colour" preview. */
|
|
26
26
|
export const CHECKERBOARD = {
|
|
@@ -62,17 +62,63 @@ function useResolvedHex(value, previewRef) {
|
|
|
62
62
|
}
|
|
63
63
|
const eyeDropperSupported = () => typeof window !== 'undefined' && typeof window.EyeDropper === 'function';
|
|
64
64
|
/**
|
|
65
|
-
* The
|
|
65
|
+
* The palette, the allowed colours and the tabs in effect where the picker
|
|
66
|
+
* renders, read from CSS once it is in the document (see `readPaletteColors`).
|
|
67
|
+
*/
|
|
68
|
+
function usePalette(elementRef) {
|
|
69
|
+
const [palette, setPalette] = useState({
|
|
70
|
+
colors: [],
|
|
71
|
+
allowed: 'any',
|
|
72
|
+
tabs: ['precise', 'colors'],
|
|
73
|
+
});
|
|
74
|
+
useLayoutEffect(() => {
|
|
75
|
+
if (elementRef.current) {
|
|
76
|
+
setPalette({
|
|
77
|
+
colors: readPaletteColors(elementRef.current),
|
|
78
|
+
allowed: readAllowedColors(elementRef.current),
|
|
79
|
+
tabs: readTabs(elementRef.current),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}, [elementRef]);
|
|
83
|
+
return palette;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The colour picker's popover body: a palette tab with the Adaptable theme
|
|
66
87
|
* colours and a Precise tab with a free picker, over a footer shared by both —
|
|
67
88
|
* the current colour, an eyedropper where the browser has one, and a hex
|
|
68
|
-
* field.
|
|
89
|
+
* field.
|
|
90
|
+
*
|
|
91
|
+
* `--ab-cmp-color-picker__tabs` sets which tabs show and in what order. The
|
|
92
|
+
* picker shows `tab` when controlled; otherwise it opens on `defaultTab`, else
|
|
93
|
+
* on the tab the user last picked in any picker on the page (see
|
|
94
|
+
* `colorPickerTab.ts`), else on the first listed tab.
|
|
95
|
+
*
|
|
96
|
+
* `--ab-cmp-color-picker__allowed-colors: predefined` drops the Precise tab,
|
|
97
|
+
* so no custom colour can be picked; `palette` also drops the theme colours.
|
|
69
98
|
*/
|
|
70
99
|
export function ColorPicker(props) {
|
|
71
|
-
const { value, onInput, onCommit,
|
|
100
|
+
const { value, onInput, onCommit, excludeColor, defaultColor = PICKER_START, includeAlpha = true, preciseTabLabel = 'Precise', colorsTabLabel = 'Palette', defaultTab, onTabChange, } = props;
|
|
72
101
|
const dataName = props['data-name'];
|
|
73
|
-
const [
|
|
102
|
+
const [lastPickedTab, setLastPickedTab] = useColorPickerTab();
|
|
103
|
+
// so a picker with `defaultTab` can still switch tabs while it is open
|
|
104
|
+
const [ownTab, setOwnTab] = useState(null);
|
|
74
105
|
const previewRef = useRef(null);
|
|
75
|
-
const
|
|
106
|
+
const resolvedHex = useResolvedHex(value, previewRef);
|
|
107
|
+
const hex = includeAlpha ? resolvedHex : resolvedHex?.slice(0, 7);
|
|
108
|
+
const palette = usePalette(previewRef);
|
|
109
|
+
const tab = [props.tab, ownTab, defaultTab, lastPickedTab].find((t) => t != null && palette.tabs.includes(t)) ?? palette.tabs[0];
|
|
110
|
+
const defaultRef = useRef(null);
|
|
111
|
+
const startHex = useResolvedHex(defaultColor, defaultRef) ?? PICKER_START;
|
|
112
|
+
const groups = useMemo(() => {
|
|
113
|
+
const paletteGroup = { id: 'palette', label: 'Palette', colors: palette.colors };
|
|
114
|
+
const all = palette.allowed === 'palette' ? [paletteGroup] : [THEME_COLOR_GROUP, paletteGroup];
|
|
115
|
+
return all
|
|
116
|
+
.map((group) => ({
|
|
117
|
+
...group,
|
|
118
|
+
colors: group.colors.filter((color) => color.value !== excludeColor),
|
|
119
|
+
}))
|
|
120
|
+
.filter((group) => group.colors.length > 0);
|
|
121
|
+
}, [palette, excludeColor]);
|
|
76
122
|
// the hex field is free text until it parses; it snaps back to the colour on blur
|
|
77
123
|
const [hexDraft, setHexDraft] = useState(null);
|
|
78
124
|
useEffect(() => setHexDraft(null), [value]);
|
|
@@ -82,7 +128,8 @@ export function ColorPicker(props) {
|
|
|
82
128
|
// at the third digit
|
|
83
129
|
const commitHexDraft = (text, options) => {
|
|
84
130
|
const digits = text.trim().replace(/^#/, '');
|
|
85
|
-
|
|
131
|
+
const valid = includeAlpha ? HEX_DIGITS : OPAQUE_HEX_DIGITS;
|
|
132
|
+
if (valid.test(digits) && (options.allowShort || digits.length !== 3)) {
|
|
86
133
|
const next = normalizeHex(digits);
|
|
87
134
|
if (next !== hex) {
|
|
88
135
|
onCommit(next);
|
|
@@ -103,20 +150,35 @@ export function ColorPicker(props) {
|
|
|
103
150
|
// cancelled with Escape
|
|
104
151
|
}
|
|
105
152
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
153
|
+
const swatches = (_jsx(SwatchGroups, { groups: groups, value: value, "data-name": dataName, onPick: (color) => {
|
|
154
|
+
onCommit(color);
|
|
155
|
+
props.onSwatchPicked?.();
|
|
156
|
+
} }));
|
|
157
|
+
const preview = (_jsx(Tooltip, { label: value ? describeColor(value) : 'Not set', children: _jsx("span", { ref: previewRef, "data-name": `${dataName}-preview`, "data-value": value, style: value ? { backgroundColor: value } : CHECKERBOARD, className: "twa:block twa:size-9 twa:shrink-0 twa:rounded-full twa:border twa:border-foreground/10" }) }));
|
|
158
|
+
if (palette.allowed !== 'any') {
|
|
159
|
+
return (_jsxs("div", { "data-name": `${dataName}-picker`, className: "twa:flex twa:flex-col twa:gap-3", children: [_jsx("div", { className: cn(CONTENT_HEIGHT, SWATCHES_LAYOUT), children: swatches }), _jsxs("div", { className: FOOTER_LAYOUT, children: [preview, _jsx("span", { className: "twa:min-w-0 twa:truncate twa:text-xs twa:text-muted-foreground", children: value ? describeColor(value) : 'Not set' })] })] }));
|
|
160
|
+
}
|
|
161
|
+
const PrecisePicker = includeAlpha ? HexAlphaColorPicker : HexColorPicker;
|
|
162
|
+
const triggers = {
|
|
163
|
+
precise: (_jsxs(TabsTrigger, { value: "precise", "data-name": `${dataName}-tab-precise`, children: [_jsx(SlidersHorizontal, { "aria-hidden": true }), preciseTabLabel] }, "precise")),
|
|
164
|
+
colors: (_jsxs(TabsTrigger, { value: "colors", "data-name": `${dataName}-tab-colors`, children: [_jsx(Grid2x2, { "aria-hidden": true }), colorsTabLabel] }, "colors")),
|
|
165
|
+
};
|
|
166
|
+
const contents = {
|
|
167
|
+
precise: (_jsx(TabsContent, { value: "precise", className: CONTENT_HEIGHT, children: _jsx(PrecisePicker, { color: hex ?? startHex, onChange: onInput, "data-name": `${dataName}-precise`,
|
|
168
|
+
// react-colorful injects unlayered styles, which beat our layered
|
|
169
|
+
// utilities whatever the specificity — hence `!`. Its parts are
|
|
170
|
+
// addressed by position (saturation area, then the hue and alpha
|
|
171
|
+
// strips) and by the `…__pointer` class suffix, so the selectors
|
|
172
|
+
// survive minified class-name scanning.
|
|
173
|
+
className: cn('twa:w-full! twa:h-full!', 'twa:*:first:rounded-md! twa:*:first:border-0!', 'twa:*:not-first:mt-2.5! twa:*:not-first:h-3! twa:*:not-first:rounded-full!', 'twa:**:[[class$=pointer]]:size-4! twa:**:[[class$=pointer]]:border-2!') }) }, "precise")),
|
|
174
|
+
// scrolls inside the same height as the precise tab, so the popover keeps its size
|
|
175
|
+
colors: (_jsx(TabsContent, { value: "colors", className: cn(CONTENT_HEIGHT, SWATCHES_LAYOUT), children: swatches }, "colors")),
|
|
176
|
+
};
|
|
177
|
+
return (_jsxs(Tabs, { value: tab, onValueChange: (next) => {
|
|
178
|
+
setOwnTab(next);
|
|
179
|
+
setLastPickedTab(next);
|
|
180
|
+
onTabChange?.(next);
|
|
181
|
+
}, "data-name": `${dataName}-picker`, className: "twa:gap-3", children: [palette.tabs.length > 1 ? (_jsx(TabsList, { className: "twa:grid twa:w-full twa:grid-cols-2", children: palette.tabs.map((id) => triggers[id]) })) : null, palette.tabs.map((id) => contents[id]), _jsxs("div", { className: FOOTER_LAYOUT, children: [preview, _jsx("span", { ref: defaultRef, hidden: true, style: { backgroundColor: defaultColor } }), canPickFromScreen ? (_jsx(Button, { variant: "outline", size: "icon-sm", "data-name": `${dataName}-eyedropper`, tooltip: "Pick a colour from the screen", onClick: pickFromScreen, className: "twa:shrink-0 twa:rounded-full", children: _jsx(Pipette, { "aria-hidden": true }) })) : null, _jsxs(InputGroup, { className: "twa:h-8 twa:min-h-8 twa:min-w-0 twa:flex-1", children: [_jsx(InputGroupAddon, { children: _jsx(InputGroupText, { className: "twa:font-mono", children: "#" }) }), _jsx(InputGroupInput, { "data-name": `${dataName}-hex`, "aria-label": "Hex colour", value: hexText, placeholder: hex ? undefined : '000000', spellCheck: false, autoComplete: "off", maxLength: includeAlpha ? 9 : 7, className: "twa:font-mono twa:text-xs", onChange: (event) => {
|
|
120
182
|
setHexDraft(event.target.value);
|
|
121
183
|
commitHexDraft(event.target.value, { allowShort: false });
|
|
122
184
|
}, onBlur: (event) => {
|
|
@@ -129,4 +191,14 @@ export function ColorPicker(props) {
|
|
|
129
191
|
}
|
|
130
192
|
} })] })] })] }));
|
|
131
193
|
}
|
|
194
|
+
const SWATCHES_LAYOUT = 'twa:flex twa:flex-col twa:gap-2.5 twa:overflow-y-auto twa:overscroll-contain twa:pr-1';
|
|
195
|
+
const FOOTER_LAYOUT = 'twa:flex twa:items-center twa:gap-2 twa:border-t twa:border-foreground/10 twa:pt-3';
|
|
196
|
+
function SwatchGroups(props) {
|
|
197
|
+
const { groups, value, onPick } = props;
|
|
198
|
+
const dataName = props['data-name'];
|
|
199
|
+
return groups.map((group) => (_jsxs("div", { className: "twa:flex twa:flex-col twa:gap-1", children: [_jsx("div", { className: "twa:text-xs twa:font-medium twa:text-muted-foreground", children: group.label }), _jsx("div", { role: "listbox", "aria-label": `${group.label} colours`, "data-name": `${dataName}-options`, "data-group": group.id, className: "twa:grid twa:grid-cols-8 twa:gap-1", children: group.colors.map((color) => {
|
|
200
|
+
const selected = color.value === value;
|
|
201
|
+
return (_jsx(Tooltip, { label: color.label, className: "twa:min-w-0", children: _jsx("button", { type: "button", role: "option", "aria-selected": selected, "aria-label": color.label, "data-name": `${dataName}-option`, "data-value": color.value, onClick: () => onPick(color.value), style: { backgroundColor: color.value }, className: cn('twa:flex twa:h-7 twa:w-full twa:items-center twa:justify-center twa:rounded-md twa:border twa:border-foreground/10 twa:transition-[box-shadow,transform]', 'twa:hover:scale-105 twa:hover:ring-2 twa:hover:ring-ring/40 twa:focus-visible:outline-none twa:focus-visible:ring-2 twa:focus-visible:ring-ring/50', selected && 'twa:ring-2 twa:ring-accent twa:ring-offset-1 twa:ring-offset-popover'), children: selected ? (_jsx(Check, { "aria-hidden": true, className: "twa:size-3.5 twa:text-white twa:drop-shadow-[0_0_1px_rgba(0,0,0,0.9)]" })) : null }) }, color.value));
|
|
202
|
+
}) })] }, group.id)));
|
|
203
|
+
}
|
|
132
204
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ColorPicker/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,M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AK,EAAE,EAAE,CAAC,CAC3B,eAAoB,SAAS,EAAC,iCAAiC,aAC7D,cAAK,SAAS,EAAC,uDAAuD,YAAE,KAAK,CAAC,KAAK,GAAO,EAC1F,cACE,IAAI,EAAC,SAAS,gBACF,GAAG,KAAK,CAAC,KAAK,UAAU,eACzB,GAAG,QAAQ,UAAU,gBACpB,KAAK,CAAC,EAAE,EACpB,SAAS,EAAC,oCAAoC,YAE7C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC;oBACvC,OAAO,CACL,KAAC,OAAO,IAAmB,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAC,aAAa,YACpE,iBACE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,mBACE,QAAQ,gBACX,KAAK,CAAC,KAAK,eACZ,GAAG,QAAQ,SAAS,gBACnB,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAClC,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,CAAC,KAAK,EAAE,EACvC,SAAS,EAAE,EAAE,CACX,0JAA0J,EAC1J,oJAAoJ,EACpJ,QAAQ,IAAI,sEAAsE,CACnF,YAEA,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,KAAK,yBAEJ,SAAS,EAAC,uEAAuE,GACjF,CACH,CAAC,CAAC,CAAC,IAAI,GACD,IAtBG,KAAK,CAAC,KAAK,CAuBf,CACX,CAAC;gBACJ,CAAC,CAAC,GACE,KAtCE,KAAK,CAAC,EAAE,CAuCZ,CACP,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* `var(--ab-color-…)` so a styled cell, alert or dashboard bar follows the
|
|
5
5
|
* light / dark theme and any host overrides of those variables.
|
|
6
6
|
*/
|
|
7
|
+
import type { ColorPickerTab } from './colorPickerTab';
|
|
7
8
|
export type ThemeColor = {
|
|
8
9
|
/** The CSS value that gets stored, e.g. `var(--ab-color-success)`. */
|
|
9
10
|
value: string;
|
|
@@ -11,14 +12,42 @@ export type ThemeColor = {
|
|
|
11
12
|
label: string;
|
|
12
13
|
};
|
|
13
14
|
export type ThemeColorGroup = {
|
|
14
|
-
id: 'theme' | 'palette'
|
|
15
|
+
id: 'theme' | 'palette';
|
|
15
16
|
label: string;
|
|
16
17
|
colors: ThemeColor[];
|
|
17
18
|
};
|
|
18
|
-
export declare const
|
|
19
|
+
export declare const THEME_COLOR_GROUP: ThemeColorGroup;
|
|
20
|
+
export declare const PALETTE_COUNT_VAR = "--ab-cmp-color-picker__palette-count";
|
|
21
|
+
export declare const ALLOWED_COLORS_VAR = "--ab-cmp-color-picker__allowed-colors";
|
|
22
|
+
export declare const TABS_VAR = "--ab-cmp-color-picker__tabs";
|
|
23
|
+
/**
|
|
24
|
+
* - `any`: theme colours, palette and a custom colour (the Precise tab)
|
|
25
|
+
* - `predefined`: theme colours and palette only
|
|
26
|
+
* - `palette`: palette only
|
|
27
|
+
*/
|
|
28
|
+
export type AllowedColors = 'any' | 'predefined' | 'palette';
|
|
29
|
+
/**
|
|
30
|
+
* The palette colours in effect on `element`: `--ab-color-palette-1` upwards
|
|
31
|
+
* until one is not defined, capped by `--ab-cmp-color-picker__palette-count`
|
|
32
|
+
* when that is a positive integer.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readPaletteColors(element: Element): ThemeColor[];
|
|
35
|
+
/** `--ab-cmp-color-picker__allowed-colors` on `element`; `any` when unset or unrecognised. */
|
|
36
|
+
export declare function readAllowedColors(element: Element): AllowedColors;
|
|
37
|
+
/**
|
|
38
|
+
* `--ab-cmp-color-picker__tabs` on `element`: the tabs to show, in order, the
|
|
39
|
+
* first being the default (e.g. `colors precise`; `colours` is also
|
|
40
|
+
* accepted). Unknown and repeated ids are dropped; `precise colors` when
|
|
41
|
+
* nothing valid is left.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readTabs(element: Element): ColorPickerTab[];
|
|
44
|
+
/** A `--ab-cmp-color-picker__tabs` value as tab ids; see `readTabs`. */
|
|
45
|
+
export declare function parseTabs(value: string): ColorPickerTab[];
|
|
19
46
|
/**
|
|
20
47
|
* The picker's name for a stored colour: the token label for a theme colour
|
|
21
|
-
* (`var(--ab-color-success)` → "Success"
|
|
48
|
+
* (`var(--ab-color-success)` → "Success", `var(--ab-color-palette-3)` →
|
|
49
|
+
* "Palette 3"), a name derived from any other `--ab-color-*` token
|
|
50
|
+
* (`var(--ab-color-badge-foreground)` → "Badge text"), the value itself otherwise.
|
|
22
51
|
*/
|
|
23
|
-
export declare function describeColor(value: string
|
|
52
|
+
export declare function describeColor(value: string): string;
|
|
24
53
|
//# sourceMappingURL=themeColors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeColors.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/themeColors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,UAAU,GAAG;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,OAAO,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"themeColors.d.ts","sourceRoot":"","sources":["../../src/ColorPicker/themeColors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,UAAU,GAAG;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,OAAO,GAAG,SAAS,CAAC;IACxB,K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