@adaptabletools/adaptable 24.0.0-canary.6 → 24.0.0-canary.8
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 +36 -173
- package/package.json +1 -1
- package/src/AdaptableOptions/DefaultAdaptableOptions.js +6 -0
- package/src/AdaptableOptions/UserInterfaceOptions.d.ts +83 -4
- 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/Filter/ColumnFilter/ColumnFilterNew.js +14 -9
- 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 +13 -0
- package/src/components/ColorField/index.js +26 -0
- package/src/components/aql/QueryBuilder/GroupEditor.js +1 -1
- package/src/components/aql/QueryBuilder/QueryBuilder.d.ts +5 -0
- package/src/components/aql/QueryBuilder/QueryBuilder.js +1 -1
- package/src/components/aql/QueryBuilder/context.d.ts +7 -0
- package/src/components/aql/QueryBuilder/context.js +3 -1
- 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/src/types.d.ts +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/vendor/components/ColorField/index.d.ts +53 -0
- package/vendor/components/ColorField/index.d.ts.map +1 -0
- package/vendor/components/ColorField/index.js +80 -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 +76 -9
- package/vendor/components/ColorPicker/index.d.ts.map +1 -1
- package/vendor/components/ColorPicker/index.js +217 -27
- package/vendor/components/ColorPicker/index.js.map +1 -1
- package/vendor/components/ColorPicker/themeColors.d.ts +74 -4
- package/vendor/components/ColorPicker/themeColors.d.ts.map +1 -1
- package/vendor/components/ColorPicker/themeColors.js +206 -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 +73 -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,53 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ColorPickerColourLists, type ColorPickerTab, type ColorPickerTabName } 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 `'Custom'`. */
|
|
18
|
+
preciseTabLabel?: ReactNode;
|
|
19
|
+
/** Default `'Palette'`. */
|
|
20
|
+
colorsTabLabel?: ReactNode;
|
|
21
|
+
/** The picker tabs, in order; see `ColorPickerProps.tabs`. */
|
|
22
|
+
tabs?: readonly ColorPickerTabName[];
|
|
23
|
+
/** Order the swatches around the colour wheel; see `ColorPickerProps.orderPaletteColours`. */
|
|
24
|
+
orderPaletteColours?: boolean;
|
|
25
|
+
/** Leave out a swatch that paints the same hex as one already listed. */
|
|
26
|
+
removeDuplicates?: boolean;
|
|
27
|
+
/** Which supplied colours to show; see `ColorPickerProps.filterColours`. */
|
|
28
|
+
filterColours?: (colours: ColorPickerColourLists) => ColorPickerColourLists | void;
|
|
29
|
+
/** Theme and Palette headings when both groups have colours. */
|
|
30
|
+
showGroupLabels?: boolean;
|
|
31
|
+
/** The tab the picker opens on; see `ColorPickerProps.defaultTab`. */
|
|
32
|
+
defaultTab?: ColorPickerTab;
|
|
33
|
+
/** The picker tab shown, for a controlled picker; see `ColorPickerProps.tab`. */
|
|
34
|
+
tab?: ColorPickerTab;
|
|
35
|
+
/** When the user switches picker tabs. */
|
|
36
|
+
onTabChange?: (tab: ColorPickerTab) => void;
|
|
37
|
+
/** Mount node for the picker popover; the overlay host's by default. */
|
|
38
|
+
container?: HTMLElement | null;
|
|
39
|
+
/** Tooltip on the swatch button. */
|
|
40
|
+
title?: string;
|
|
41
|
+
id?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
'data-name': string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The colour input: a swatch that opens the {@link ColorPicker} — the
|
|
47
|
+
* Adaptable theme colours (stored as `var(--ab-color-…)` so they follow the
|
|
48
|
+
* theme) or a precise colour — with a clear button so a colour can go back to
|
|
49
|
+
* "not set" instead of being stuck on the last pick. Unset shows a
|
|
50
|
+
* transparency checkerboard rather than a fake grey.
|
|
51
|
+
*/
|
|
52
|
+
export declare function ColorField(props: ColorFieldProps): import("react").JSX.Element;
|
|
53
|
+
//# 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,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,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,0BAA0B;IAC1B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,2BAA2B;IAC3B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,8DAA8D;IAC9D,IAAI,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrC,8FAA8F;IAC9F,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,sBAAsB,GAAG,IAAI,CAAC;IACnF,gEAAgE;IAChE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,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,+BA4EhD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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, } 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
|
+
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, tabs: props.tabs, orderPaletteColours: props.orderPaletteColours, removeDuplicates: props.removeDuplicates, filterColours: props.filterColours, showGroupLabels: props.showGroupLabels, defaultTab: props.defaultTab, tab: props.tab, onTabChange: props.onTabChange }) })] }), 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] }));
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
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B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EACpC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EACxC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,WAAW,EAAE,KAAK,CAAC,WAAW,GAC9B,GACa,IACT,EACT,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CACpB,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,SAAS,EACd,QAAQ,EAAE,QAAQ,eACP,GAAG,QAAQ,QAAQ,EAC9B,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,YAEhC,KAAC,CAAC,0BAAe,GACV,CACV,CAAC,CAAC,CAAC,IAAI,IACJ,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,10 @@
|
|
|
1
|
-
import { type CSSProperties } from 'react';
|
|
2
|
-
import { type
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import { type ColorPickerTab } from './colorPickerTab';
|
|
3
|
+
import { type ColorPickerTabName, type ThemeColor } from './themeColors';
|
|
3
4
|
export { setColorPickerTab, useColorPickerTab } from './colorPickerTab';
|
|
4
5
|
export type { ColorPickerTab } from './colorPickerTab';
|
|
5
|
-
export { describeColor,
|
|
6
|
-
export type { ThemeColor, ThemeColorGroup } from './themeColors';
|
|
6
|
+
export { ALLOWED_COLORS_VAR, coloursKeptFromSource, describeColor, normalizeColorPickerTabs, PALETTE_COUNT_VAR, parseTabs, readAllowedColors, readAllPaletteColors, readPaletteColors, readTabs, TABS_VAR, THEME_COLOR_GROUP, } from './themeColors';
|
|
7
|
+
export type { AllowedColors, ColorPickerTabName, ThemeColor, ThemeColorGroup, } from './themeColors';
|
|
7
8
|
export type ColorPickerProps = {
|
|
8
9
|
/** A theme token as `var(--ab-color-…)`, a hex, or nothing. */
|
|
9
10
|
value: string | undefined;
|
|
@@ -13,19 +14,85 @@ export type ColorPickerProps = {
|
|
|
13
14
|
onCommit: (value: string) => void;
|
|
14
15
|
/** After a swatch is picked — the one choice that ends the interaction. */
|
|
15
16
|
onSwatchPicked?: () => void;
|
|
16
|
-
/**
|
|
17
|
-
|
|
17
|
+
/** A colour left out of the swatches, e.g. `var(--ab-color-x)` while editing `--ab-color-x`. */
|
|
18
|
+
excludeColor?: string;
|
|
19
|
+
/** Where the precise picker starts while nothing is set (a hex or a theme token); mid-grey by default. */
|
|
20
|
+
defaultColor?: string;
|
|
21
|
+
/** Whether a custom colour can have opacity; default `true`. */
|
|
22
|
+
includeAlpha?: boolean;
|
|
23
|
+
/** Default `'Custom'`. */
|
|
24
|
+
preciseTabLabel?: ReactNode;
|
|
25
|
+
/** Default `'Palette'`. */
|
|
26
|
+
colorsTabLabel?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The tabs to show, in this order. `Custom` is the free picker; `Palette` is
|
|
29
|
+
* the swatches. The first is the one the picker opens on, until the user
|
|
30
|
+
* picks another (or `defaultTab` / `tab` says otherwise). One tab hides the
|
|
31
|
+
* tab bar. When omitted, `--ab-cmp-color-picker__tabs` and
|
|
32
|
+
* `--ab-cmp-color-picker__allowed-colors` decide, and the default is
|
|
33
|
+
* `['Custom', 'Palette']`.
|
|
34
|
+
*/
|
|
35
|
+
tabs?: readonly ColorPickerTabName[];
|
|
36
|
+
/**
|
|
37
|
+
* Order the swatches around the colour wheel. When `false`, each colour
|
|
38
|
+
* stays in the order the theme lists it. Default `true`.
|
|
39
|
+
*/
|
|
40
|
+
orderPaletteColours?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Leave out a swatch that paints the same hex as one already listed. The
|
|
43
|
+
* first one stays. Default `true`.
|
|
44
|
+
*/
|
|
45
|
+
removeDuplicates?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Chooses which of the supplied colours to show. A returned colour whose
|
|
48
|
+
* `value` is not in that list is ignored. Return nothing to show every
|
|
49
|
+
* colour. When omitted, `--ab-cmp-color-picker__palette-count` and
|
|
50
|
+
* `--ab-cmp-color-picker__allowed-colors: palette` decide.
|
|
51
|
+
*/
|
|
52
|
+
filterColours?: (colours: ColorPickerColourLists) => ColorPickerColourLists | void;
|
|
53
|
+
/**
|
|
54
|
+
* Show Theme and Palette headings when both groups have colours. Default
|
|
55
|
+
* `false`, which is one grid.
|
|
56
|
+
*/
|
|
57
|
+
showGroupLabels?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The tab to open on; wins over the tab the user last picked and the first
|
|
60
|
+
* tab in `tabs`. Ignored when that tab is not shown.
|
|
61
|
+
*/
|
|
62
|
+
defaultTab?: ColorPickerTab;
|
|
63
|
+
/**
|
|
64
|
+
* The tab shown, for a controlled picker; wins over `defaultTab`. Ignored
|
|
65
|
+
* when that tab is not shown.
|
|
66
|
+
*/
|
|
67
|
+
tab?: ColorPickerTab;
|
|
68
|
+
/** When the user switches tabs. */
|
|
69
|
+
onTabChange?: (tab: ColorPickerTab) => void;
|
|
18
70
|
'data-name': string;
|
|
19
71
|
};
|
|
72
|
+
/** Theme colours and palette colours, the two lists a filter receives and returns. */
|
|
73
|
+
export type ColorPickerColourLists = {
|
|
74
|
+
themeColours: ThemeColor[];
|
|
75
|
+
paletteColours: ThemeColor[];
|
|
76
|
+
};
|
|
20
77
|
/** `#rrggbb`, or `#rrggbbaa` when the colour has opacity. */
|
|
21
78
|
export declare const HEX_COLOR: RegExp;
|
|
22
79
|
/** Transparency checkerboard — the "no colour" preview. */
|
|
23
80
|
export declare const CHECKERBOARD: CSSProperties;
|
|
24
81
|
/**
|
|
25
|
-
* The colour picker's popover body: a
|
|
26
|
-
* colours and a
|
|
82
|
+
* The colour picker's popover body: a palette tab with the Adaptable theme
|
|
83
|
+
* colours and a Custom tab with a free picker, over a footer shared by both —
|
|
27
84
|
* the current colour, an eyedropper where the browser has one, and a hex
|
|
28
|
-
* field.
|
|
85
|
+
* field.
|
|
86
|
+
*
|
|
87
|
+
* `tabs` sets which tabs show and in what order. The picker shows `tab` when
|
|
88
|
+
* controlled; otherwise it opens on `defaultTab`, else on the tab the user
|
|
89
|
+
* last picked in any picker on the page (see `colorPickerTab.ts`), else on
|
|
90
|
+
* the first listed tab.
|
|
91
|
+
*
|
|
92
|
+
* Without `tabs`, the CSS variables decide: `--ab-cmp-color-picker__tabs`
|
|
93
|
+
* sets the tabs, and `--ab-cmp-color-picker__allowed-colors: predefined`
|
|
94
|
+
* drops the Custom tab, so no custom colour can be picked; `palette` also
|
|
95
|
+
* drops the theme colours (unless `filterColours` is given).
|
|
29
96
|
*/
|
|
30
97
|
export declare function ColorPicker(props: ColorPickerProps): import("react").JSX.Element;
|
|
31
98
|
//# 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,EAKf,MAAM,OAAO,CAAC;AAUf,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAUL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAGhB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+DAA+D;IAC/D,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,oFAAoF;IACpF,OAAO,EA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