@inkra/react 0.3.0 → 0.5.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/README.md +113 -3
- package/dist/Button.js +3 -2
- package/dist/PencilIcon.d.ts +10 -0
- package/dist/PencilIcon.js +83 -39
- package/dist/PencilLine.js +9 -1
- package/dist/PencilText.js +15 -9
- package/dist/accordion/Accordion.js +65 -5
- package/dist/alert-dialog/index.js +14 -4
- package/dist/audio-player/index.d.ts +2 -0
- package/dist/audio-player/index.js +131 -34
- package/dist/breadcrumb/index.js +4 -1
- package/dist/calendar/index.d.ts +4 -1
- package/dist/calendar/index.js +37 -12
- package/dist/calendar/locales.d.ts +7 -0
- package/dist/calendar/locales.js +2 -0
- package/dist/carousel/index.js +20 -10
- package/dist/choice-grid/index.d.ts +6 -1
- package/dist/choice-grid/index.js +63 -33
- package/dist/color-picker/GradientEditor.d.ts +40 -0
- package/dist/color-picker/GradientEditor.js +64 -0
- package/dist/color-picker/gradient.d.ts +25 -0
- package/dist/color-picker/gradient.js +60 -0
- package/dist/color-picker/index.d.ts +27 -7
- package/dist/color-picker/index.js +144 -40
- package/dist/color-swatch/index.d.ts +10 -0
- package/dist/color-swatch/index.js +9 -0
- package/dist/command/index.js +27 -4
- package/dist/content/index.d.ts +5 -0
- package/dist/content/index.js +15 -3
- package/dist/context-menu/index.js +1 -1
- package/dist/data-table/index.d.ts +7 -1
- package/dist/data-table/index.js +67 -16
- package/dist/data-table/model.d.ts +2 -0
- package/dist/data-table/model.js +7 -0
- package/dist/date-picker/index.d.ts +2 -0
- package/dist/date-picker/index.js +20 -21
- package/dist/day-agenda/index.d.ts +6 -1
- package/dist/day-agenda/index.js +49 -21
- package/dist/day-agenda/layout.js +65 -9
- package/dist/display/ProgressRing.js +7 -3
- package/dist/display/index.d.ts +4 -1
- package/dist/display/index.js +3 -2
- package/dist/dockable-panel/index.js +15 -13
- package/dist/drawer/index.js +11 -5
- package/dist/editable/index.d.ts +24 -2
- package/dist/editable/index.js +148 -40
- package/dist/empty/illustrations.d.ts +8 -0
- package/dist/empty/illustrations.js +78 -0
- package/dist/empty/index.d.ts +6 -1
- package/dist/empty/index.js +11 -3
- package/dist/flip/index.js +28 -8
- package/dist/form/Field.js +11 -10
- package/dist/form/Input.js +4 -1
- package/dist/form/Textarea.d.ts +3 -1
- package/dist/form/Textarea.js +9 -5
- package/dist/heatmap/index.js +4 -1
- package/dist/hotkey/index.d.ts +1 -0
- package/dist/hotkey/index.js +9 -4
- package/dist/hover-card/index.js +1 -1
- package/dist/i18n/catalog.d.ts +5 -0
- package/dist/i18n/catalog.js +289 -0
- package/dist/i18n/index.d.ts +23 -0
- package/dist/i18n/index.js +50 -0
- package/dist/image-cropper/index.js +21 -17
- package/dist/image-viewer/VideoResource.d.ts +21 -0
- package/dist/image-viewer/VideoResource.js +196 -0
- package/dist/image-viewer/index.d.ts +14 -0
- package/dist/image-viewer/index.js +141 -86
- package/dist/image-viewer/lucideGeometry.d.ts +3 -0
- package/dist/image-viewer/lucideGeometry.js +19 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/input-number/index.js +13 -5
- package/dist/internal/cache.d.ts +4 -0
- package/dist/internal/cache.js +18 -1
- package/dist/internal/iconGeometry.d.ts +2 -0
- package/dist/internal/iconGeometry.js +32 -0
- package/dist/internal/renderTokens.d.ts +4 -0
- package/dist/internal/renderTokens.js +4 -0
- package/dist/internal/stroke.d.ts +7 -0
- package/dist/internal/stroke.js +63 -7
- package/dist/internal/surfaceBudget.d.ts +20 -0
- package/dist/internal/surfaceBudget.js +69 -0
- package/dist/internal/surfaceRenderer.js +87 -28
- package/dist/internal/surfaceVisibility.d.ts +3 -0
- package/dist/internal/surfaceVisibility.js +60 -0
- package/dist/internal/textRenderer.d.ts +3 -0
- package/dist/internal/textRenderer.js +13 -5
- package/dist/internal/usePencilSurface.js +17 -1
- package/dist/internal/wash.js +4 -3
- package/dist/journey-map/index.d.ts +1 -1
- package/dist/journey-map/index.js +6 -3
- package/dist/journey-map/terrain.js +10 -5
- package/dist/keypad/index.js +4 -1
- package/dist/layout/index.js +1 -1
- package/dist/log/index.js +42 -33
- package/dist/markdown/CodeBlock.d.ts +19 -0
- package/dist/markdown/CodeBlock.js +86 -0
- package/dist/markdown/Deletion.d.ts +2 -0
- package/dist/markdown/Deletion.js +69 -0
- package/dist/markdown/icons.d.ts +14 -0
- package/dist/markdown/icons.js +16 -0
- package/dist/markdown/index.d.ts +17 -0
- package/dist/markdown/index.js +177 -0
- package/dist/node-graph/index.d.ts +3 -1
- package/dist/node-graph/index.js +63 -28
- package/dist/number-ticker/index.js +4 -1
- package/dist/number-ticker/precision.js +9 -2
- package/dist/overflow-list/index.js +9 -6
- package/dist/overlay/Overlay.js +8 -3
- package/dist/overlay/Popover.js +3 -3
- package/dist/overlay/themeBridge.js +14 -2
- package/dist/pagination/index.d.ts +10 -1
- package/dist/pagination/index.js +13 -9
- package/dist/pan-zoom/index.d.ts +2 -0
- package/dist/pan-zoom/index.js +12 -8
- package/dist/pencil.d.ts +1 -0
- package/dist/pencil.js +4 -4
- package/dist/radar/index.d.ts +2 -0
- package/dist/radar/index.js +44 -21
- package/dist/range-slider/index.js +4 -3
- package/dist/rating/index.d.ts +4 -0
- package/dist/rating/index.js +131 -24
- package/dist/resizable/index.d.ts +1 -1
- package/dist/resizable/index.js +5 -2
- package/dist/scroll-area/index.d.ts +1 -1
- package/dist/scroll-area/index.js +5 -2
- package/dist/select/MultipleSelect.js +5 -4
- package/dist/select/SearchableSelect.js +64 -7
- package/dist/select/Select.d.ts +1 -0
- package/dist/select/Select.js +6 -2
- package/dist/select/StepperSelect.d.ts +29 -0
- package/dist/select/StepperSelect.js +122 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +1 -0
- package/dist/select/stepperModel.d.ts +7 -0
- package/dist/select/stepperModel.js +29 -0
- package/dist/selection/Checkbox.js +4 -3
- package/dist/selection/RadioGroup.js +29 -13
- package/dist/selection/Switch.js +4 -3
- package/dist/selection/useNativeChecked.d.ts +2 -1
- package/dist/selection/useNativeChecked.js +26 -8
- package/dist/slider/index.js +50 -6
- package/dist/sortable/index.js +17 -11
- package/dist/sparkline/index.js +21 -6
- package/dist/sparkline/model.js +11 -4
- package/dist/steps/index.js +4 -1
- package/dist/styles/accordion.css +228 -0
- package/dist/styles/alert-dialog.css +139 -0
- package/dist/styles/audio-player.css +22 -0
- package/dist/styles/base.css +638 -0
- package/dist/styles/breadcrumb.css +7 -0
- package/dist/styles/calendar.css +62 -0
- package/dist/styles/carousel.css +173 -0
- package/dist/styles/choice-grid.css +226 -0
- package/dist/styles/color-picker.css +281 -0
- package/dist/styles/color-swatch.css +47 -0
- package/dist/styles/command.css +52 -0
- package/dist/styles/content.css +79 -0
- package/dist/styles/context-menu.css +35 -0
- package/dist/styles/data-table.css +31 -0
- package/dist/styles/date-picker.css +107 -0
- package/dist/styles/day-agenda.css +30 -0
- package/dist/styles/display.css +304 -0
- package/dist/styles/dockable-panel.css +110 -0
- package/dist/styles/drawer.css +133 -0
- package/dist/styles/dropdown-menu.css +68 -0
- package/dist/styles/editable.css +145 -0
- package/dist/styles/empty.css +108 -0
- package/dist/styles/flip.css +101 -0
- package/dist/styles/form.css +634 -0
- package/dist/styles/heatmap.css +256 -0
- package/dist/styles/hotkey.css +189 -0
- package/dist/styles/hover-card.css +27 -0
- package/dist/styles/image-cropper.css +205 -0
- package/dist/styles/image-viewer.css +422 -0
- package/dist/styles/input-number.css +21 -0
- package/dist/styles/journey-map.css +19 -0
- package/dist/styles/keypad.css +92 -0
- package/dist/styles/layout.css +72 -0
- package/dist/styles/leaflet.css +661 -0
- package/dist/styles/log.css +203 -0
- package/dist/styles/markdown.css +379 -0
- package/dist/styles/node-graph.css +142 -0
- package/dist/styles/number-ticker.css +83 -0
- package/dist/styles/overflow-list.css +51 -0
- package/dist/styles/overlay.css +284 -0
- package/dist/styles/pagination.css +21 -0
- package/dist/styles/pan-zoom.css +136 -0
- package/dist/styles/radar.css +1 -0
- package/dist/styles/rating.css +121 -0
- package/dist/styles/resizable.css +108 -0
- package/dist/styles/scroll-area.css +122 -0
- package/dist/styles/select.css +554 -0
- package/dist/styles/selection.css +264 -0
- package/dist/styles/slider.css +145 -0
- package/dist/styles/slot.css +109 -0
- package/dist/styles/sortable.css +159 -0
- package/dist/styles/sparkline.css +24 -0
- package/dist/styles/steps.css +27 -0
- package/dist/styles/tabs.css +79 -0
- package/dist/styles/tag-input.css +213 -0
- package/dist/styles/time-picker.css +66 -0
- package/dist/styles/timeline.css +24 -0
- package/dist/styles/toast.css +160 -0
- package/dist/styles/toggle-group.css +107 -0
- package/dist/styles/tooltip.css +78 -0
- package/dist/styles/transfer.css +148 -0
- package/dist/styles/tree-select.css +131 -0
- package/dist/styles/tree.css +59 -0
- package/dist/styles/typewriter.css +62 -0
- package/dist/styles/upload.css +60 -0
- package/dist/styles/virtual-list.css +112 -0
- package/dist/styles.css +2091 -421
- package/dist/tabs/index.d.ts +9 -0
- package/dist/tabs/index.js +69 -16
- package/dist/tabs/useOverflow.d.ts +20 -0
- package/dist/tabs/useOverflow.js +145 -0
- package/dist/tag-input/index.d.ts +7 -2
- package/dist/tag-input/index.js +81 -42
- package/dist/theme/index.d.ts +11 -0
- package/dist/theme/index.js +23 -0
- package/dist/time-picker/index.js +45 -27
- package/dist/timeline/index.js +4 -1
- package/dist/toast/index.d.ts +19 -11
- package/dist/toast/index.js +51 -8
- package/dist/toast/manager.d.ts +42 -0
- package/dist/toast/manager.js +85 -0
- package/dist/toast/useToastNavigation.d.ts +3 -0
- package/dist/toast/useToastNavigation.js +75 -0
- package/dist/tokens.css +4 -0
- package/dist/tooltip/Tooltip.js +3 -3
- package/dist/transfer/index.d.ts +5 -0
- package/dist/transfer/index.js +120 -53
- package/dist/transfer/model.d.ts +4 -0
- package/dist/transfer/model.js +37 -11
- package/dist/tree/index.d.ts +5 -1
- package/dist/tree/index.js +11 -6
- package/dist/tree-select/index.js +70 -31
- package/dist/tree-select/model.d.ts +11 -5
- package/dist/tree-select/model.js +111 -83
- package/dist/typewriter/index.js +10 -10
- package/dist/upload/index.js +50 -33
- package/dist/virtual-list/index.js +11 -6
- package/package.json +423 -3
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useInkraLocale } from '../i18n/index.js';
|
|
3
|
+
import { Children, createContext, forwardRef, memo, isValidElement, useContext, useCallback, useMemo, useId, useImperativeHandle, useRef, useState, } from 'react';
|
|
4
|
+
import { Button } from '../Button.js';
|
|
3
5
|
import { PencilSurface } from '../PencilSurface.js';
|
|
4
6
|
import { PencilText } from '../PencilText.js';
|
|
5
7
|
import { Checkbox } from '../selection/Checkbox.js';
|
|
6
8
|
import { RadioGroup, RadioGroupItem } from '../selection/RadioGroup.js';
|
|
7
9
|
const classes = (...values) => values.filter(Boolean).join(' ');
|
|
10
|
+
const noPagedOptions = [];
|
|
8
11
|
function mergeIds(...values) {
|
|
9
12
|
const merged = Array.from(new Set(values.flatMap(value => value?.split(/\s+/).filter(Boolean) ?? [])));
|
|
10
13
|
return merged.length ? merged.join(' ') : undefined;
|
|
@@ -24,8 +27,9 @@ function gridStyle(style, columns, minItemWidth) {
|
|
|
24
27
|
'--inkra-choice-grid-min-item': minItemWidth,
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
|
-
export const ChoiceGrid = forwardRef(function ChoiceGrid(props, forwardedRef) {
|
|
28
|
-
const {
|
|
30
|
+
export const ChoiceGrid = memo(forwardRef(function ChoiceGrid(props, forwardedRef) {
|
|
31
|
+
const { t } = useInkraLocale();
|
|
32
|
+
const { 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, children, className, columns, description, disabled = false, error, form, label, minItemWidth = '13rem', name, pageSize, previousPageLabel = t('common.previousPage'), nextPageLabel = t('common.nextPage'), pageLabel = (page, pages) => `${page} / ${pages}`, style, type = 'single', ...rest } = props;
|
|
29
33
|
const generatedId = useId();
|
|
30
34
|
const descriptionId = description == null ? undefined : `inkra-choice-grid-${generatedId}-description`;
|
|
31
35
|
const errorId = error == null ? undefined : `inkra-choice-grid-${generatedId}-error`;
|
|
@@ -34,31 +38,50 @@ export const ChoiceGrid = forwardRef(function ChoiceGrid(props, forwardedRef) {
|
|
|
34
38
|
const invalid = Boolean(error) || rest['aria-invalid'] === true || rest['aria-invalid'] === 'true';
|
|
35
39
|
const rootRef = useRef(null);
|
|
36
40
|
useImperativeHandle(forwardedRef, () => rootRef.current);
|
|
41
|
+
const multipleValues = props.type === 'multiple' ? props.values : undefined;
|
|
42
|
+
const multipleDefaults = props.type === 'multiple' ? props.defaultValues : undefined;
|
|
43
|
+
const onValuesChange = props.type === 'multiple' ? props.onValuesChange : undefined;
|
|
44
|
+
const values = useMemo(() => multipleValues === undefined ? undefined : new Set(multipleValues), [multipleValues]);
|
|
45
|
+
const defaultValues = useMemo(() => multipleDefaults === undefined ? undefined : new Set(multipleDefaults), [multipleDefaults]);
|
|
46
|
+
const [page, setPage] = useState(0);
|
|
47
|
+
const directOptions = useMemo(() => pageSize === undefined ? noPagedOptions : Children.toArray(children), [children, pageSize]);
|
|
48
|
+
const controlled = props.type === 'multiple' ? props.values !== undefined : props.value !== undefined;
|
|
49
|
+
const paged = controlled && pageSize !== undefined && Number.isFinite(pageSize) && directOptions.length > 0
|
|
50
|
+
&& directOptions.every(child => isValidElement(child) && child.type === ChoiceGridOption && !child.props.required);
|
|
51
|
+
const pageLength = paged ? Math.max(1, Math.floor(pageSize)) : 1;
|
|
52
|
+
const pageCount = paged ? Math.ceil(directOptions.length / pageLength) : 0;
|
|
53
|
+
const currentPage = Math.min(page, Math.max(0, pageCount - 1));
|
|
54
|
+
const pageChildren = paged ? directOptions.map((child, index) => {
|
|
55
|
+
const option = child;
|
|
56
|
+
if (index >= currentPage * pageLength && index < (currentPage + 1) * pageLength)
|
|
57
|
+
return child;
|
|
58
|
+
const selected = props.type === 'multiple' ? values?.has(option.props.value) : props.value === option.props.value;
|
|
59
|
+
return selected ? _jsx("input", { type: "hidden", name: name, value: option.props.value, disabled: disabled || option.props.disabled, form: option.props.form ?? form }, option.key) : null;
|
|
60
|
+
}) : children;
|
|
61
|
+
const pageControls = paged ? _jsxs("nav", { "aria-label": typeof label === 'string' ? label : undefined, children: [_jsx(Button, { size: "sm", variant: "ghost", "aria-label": previousPageLabel, disabled: disabled || currentPage === 0, onClick: () => setPage(currentPage - 1), children: previousPageLabel }), _jsx("span", { "aria-live": "polite", children: pageLabel(currentPage + 1, pageCount) }), _jsx(Button, { size: "sm", variant: "ghost", "aria-label": nextPageLabel, disabled: disabled || currentPage >= pageCount - 1, onClick: () => setPage(currentPage + 1), children: nextPageLabel })] }) : null;
|
|
62
|
+
const pagingValues = paged ? values : undefined;
|
|
63
|
+
const onMultipleChange = useCallback((optionValue, checked) => {
|
|
64
|
+
if (!onValuesChange)
|
|
65
|
+
return;
|
|
66
|
+
if (paged) {
|
|
67
|
+
onValuesChange(directOptions.filter(option => option.props.value === optionValue ? checked : pagingValues?.has(option.props.value)).map(option => option.props.value));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const selected = Array.from(rootRef.current?.querySelectorAll('input[type="checkbox"][data-choice-grid-value]') ?? []).filter(input => input.value === optionValue ? checked : input.checked)
|
|
71
|
+
.map(input => input.value);
|
|
72
|
+
onValuesChange(selected);
|
|
73
|
+
}, [onValuesChange, paged, directOptions, pagingValues]);
|
|
74
|
+
const context = useMemo(() => ({
|
|
75
|
+
defaultValues, disabled, form, mode: type, name, onMultipleChange, values,
|
|
76
|
+
}), [defaultValues, disabled, form, type, name, onMultipleChange, values]);
|
|
37
77
|
if (type === 'single') {
|
|
38
78
|
const single = props;
|
|
39
79
|
const { defaultValue: _defaultValue, onValueChange: _onValueChange, value: _value, ...singleFieldsetProps } = rest;
|
|
40
|
-
return (_jsxs("div", { className: classes('inkra-choice-grid', className), "data-columns": columns, "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-type": "single", style: gridStyle(style, columns, minItemWidth), children: [
|
|
80
|
+
return (_jsxs("div", { className: classes('inkra-choice-grid', className), "data-columns": columns, "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-type": "single", style: gridStyle(style, columns, minItemWidth), children: [_jsxs(ChoiceGridContext.Provider, { value: context, children: [_jsx(RadioGroup, { ...singleFieldsetProps, "aria-describedby": describedBy, "aria-errormessage": errorMessage, "aria-invalid": invalid || undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, defaultValue: single.defaultValue, disabled: disabled, form: form, label: label, name: name, onValueChange: single.onValueChange, ref: rootRef, value: single.value, children: pageChildren }), pageControls] }), _jsx(GroupMessages, { description: description, descriptionId: descriptionId, error: error, errorId: errorId })] }));
|
|
41
81
|
}
|
|
42
|
-
const multiple = props;
|
|
43
82
|
const { defaultValues: _defaultValues, onValuesChange: _onValuesChange, values: _values, ...multipleFieldsetProps } = rest;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return;
|
|
47
|
-
const selected = Array.from(rootRef.current?.querySelectorAll('input[type="checkbox"][data-choice-grid-value]') ?? []).filter(input => input.value === optionValue ? checked : input.checked)
|
|
48
|
-
.map(input => input.value);
|
|
49
|
-
multiple.onValuesChange(selected);
|
|
50
|
-
};
|
|
51
|
-
const context = {
|
|
52
|
-
defaultValues: multiple.defaultValues,
|
|
53
|
-
disabled,
|
|
54
|
-
form,
|
|
55
|
-
mode: 'multiple',
|
|
56
|
-
name,
|
|
57
|
-
onMultipleChange,
|
|
58
|
-
values: multiple.values,
|
|
59
|
-
};
|
|
60
|
-
return (_jsxs("fieldset", { ...multipleFieldsetProps, "aria-describedby": describedBy, "aria-errormessage": errorMessage, "aria-invalid": invalid || undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: classes('inkra-choice-grid', className), "data-columns": columns, "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-type": "multiple", disabled: disabled, form: form, ref: rootRef, style: gridStyle(style, columns, minItemWidth), children: [label == null ? null : typeof label === 'string' ? (_jsx(PencilText, { as: "legend", className: "inkra-choice-grid__legend", seed: `inkra-choice-grid-${generatedId}-label`, children: label })) : _jsx("legend", { className: "inkra-choice-grid__legend", children: label }), _jsx(ChoiceGridContext.Provider, { value: context, children: _jsx("div", { className: "inkra-choice-grid__items", children: children }) }), _jsx(GroupMessages, { description: description, descriptionId: descriptionId, error: error, errorId: errorId })] }));
|
|
61
|
-
});
|
|
83
|
+
return (_jsxs("fieldset", { ...multipleFieldsetProps, "aria-describedby": describedBy, "aria-errormessage": errorMessage, "aria-invalid": invalid || undefined, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className: classes('inkra-choice-grid', className), "data-columns": columns, "data-disabled": disabled || undefined, "data-invalid": invalid || undefined, "data-type": "multiple", disabled: disabled, form: form, ref: rootRef, style: gridStyle(style, columns, minItemWidth), children: [label == null ? null : typeof label === 'string' ? (_jsx(PencilText, { as: "legend", className: "inkra-choice-grid__legend", seed: `inkra-choice-grid-${generatedId}-label`, children: label })) : _jsx("legend", { className: "inkra-choice-grid__legend", children: label }), _jsxs(ChoiceGridContext.Provider, { value: context, children: [_jsx("div", { className: "inkra-choice-grid__items", children: pageChildren }), pageControls] }), _jsx(GroupMessages, { description: description, descriptionId: descriptionId, error: error, errorId: errorId })] }));
|
|
84
|
+
}));
|
|
62
85
|
function OptionMedia({ icon, image }) {
|
|
63
86
|
if (image) {
|
|
64
87
|
return (_jsx("span", { "aria-hidden": "true", className: "inkra-choice-grid__media", "data-kind": "image", children: _jsx("img", { ...image, alt: "" }) }));
|
|
@@ -68,18 +91,25 @@ function OptionMedia({ icon, image }) {
|
|
|
68
91
|
}
|
|
69
92
|
return null;
|
|
70
93
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
throw new Error('ChoiceGridOption must be rendered inside ChoiceGrid');
|
|
94
|
+
// Resolve context in a small adapter. A membership change must not rebuild the
|
|
95
|
+
// paper, text and controls of every option whose own checked state is unchanged.
|
|
96
|
+
const ChoiceGridOptionView = memo(function ChoiceGridOptionView({ className, description, disabled = false, form, icon, id, image, label, mode, inputRef, groupName, multipleChecked, multipleDefaultChecked, onMultipleChange, onChange, required = false, seed, value, ...props }) {
|
|
75
97
|
const generatedId = useId();
|
|
76
98
|
const inputId = id ?? `inkra-choice-grid-option-${generatedId}`;
|
|
77
99
|
const resolvedSeed = seed ?? inputId;
|
|
78
|
-
const itemDisabled =
|
|
79
|
-
const content = (_jsxs(_Fragment, { children: [_jsx(OptionMedia, { icon: icon, image: image }), _jsx("span", { className: "inkra-choice-grid__option-label", children: label
|
|
80
|
-
|
|
100
|
+
const itemDisabled = disabled;
|
|
101
|
+
const content = (_jsxs(_Fragment, { children: [_jsx(OptionMedia, { icon: icon, image: image }), _jsx("span", { className: "inkra-choice-grid__option-label", children: typeof label === 'string'
|
|
102
|
+
? _jsx(PencilText, { seed: `${resolvedSeed}-label`, children: label })
|
|
103
|
+
: label })] }));
|
|
104
|
+
const control = mode === 'single' ? (_jsx(RadioGroupItem, { ...props, className: "inkra-choice-grid__control", description: description, disabled: itemDisabled, form: form, id: inputId, label: content, onChange: onChange, ref: inputRef, required: required, seed: resolvedSeed, value: value })) : (_jsx(Checkbox, { ...props, checked: multipleChecked, className: "inkra-choice-grid__control", "data-choice-grid-value": "", defaultChecked: multipleDefaultChecked, description: description, disabled: itemDisabled, form: form, id: inputId, label: content, name: groupName, onChange: (event) => {
|
|
81
105
|
onChange?.(event);
|
|
82
|
-
|
|
83
|
-
}, ref:
|
|
84
|
-
return (_jsxs(PencilSurface, { as: "div", className: classes('inkra-choice-grid__option', className), "data-disabled": itemDisabled || undefined, radius: 8, seed: `${resolvedSeed}-paper`, variant: "paper", children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-choice-grid__selection", radius: 8, seed: `${resolvedSeed}-selection`, variant: "selection" }), control, _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-choice-grid__outline", radius: 8, seed: `${resolvedSeed}-outline`, variant: "outline" })] }));
|
|
106
|
+
onMultipleChange?.(value, event.currentTarget.checked);
|
|
107
|
+
}, ref: inputRef, required: required, seed: resolvedSeed, value: value }));
|
|
108
|
+
return (_jsxs(PencilSurface, { as: "div", className: classes('inkra-choice-grid__option', className), "data-disabled": itemDisabled || undefined, radius: 8, seed: `${resolvedSeed}-paper`, variant: "paper", children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-choice-grid__selection", radius: 8, seed: `${resolvedSeed}-selection`, variant: "selection" }), _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-choice-grid__focus", radius: 8, seed: `${resolvedSeed}-focus`, variant: "outline" }), control, _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-choice-grid__outline", radius: 8, seed: `${resolvedSeed}-outline`, variant: "outline" })] }));
|
|
109
|
+
});
|
|
110
|
+
export const ChoiceGridOption = forwardRef(function ChoiceGridOption(props, ref) {
|
|
111
|
+
const context = useContext(ChoiceGridContext);
|
|
112
|
+
if (!context)
|
|
113
|
+
throw new Error('ChoiceGridOption must be rendered inside ChoiceGrid');
|
|
114
|
+
return _jsx(ChoiceGridOptionView, { ...props, disabled: context.disabled || props.disabled, form: props.form ?? context.form, groupName: context.name, mode: context.mode, multipleChecked: context.values === undefined ? undefined : context.values.has(props.value), multipleDefaultChecked: context.values === undefined ? context.defaultValues?.has(props.value) : undefined, onMultipleChange: context.onMultipleChange, inputRef: ref });
|
|
85
115
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type InkraTranslate } from '../i18n/index.js';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ColorGradient } from './gradient.js';
|
|
4
|
+
import type { ColorValue } from './color.js';
|
|
5
|
+
export interface ColorGradientLabels {
|
|
6
|
+
type?: string;
|
|
7
|
+
solid?: string;
|
|
8
|
+
linear?: string;
|
|
9
|
+
radial?: string;
|
|
10
|
+
conic?: string;
|
|
11
|
+
preview?: string;
|
|
12
|
+
stops?: string;
|
|
13
|
+
stop?: string;
|
|
14
|
+
stopColor?: string;
|
|
15
|
+
addStop?: string;
|
|
16
|
+
removeStop?: string;
|
|
17
|
+
reverse?: string;
|
|
18
|
+
position?: string;
|
|
19
|
+
angle?: string;
|
|
20
|
+
centerX?: string;
|
|
21
|
+
centerY?: string;
|
|
22
|
+
shape?: string;
|
|
23
|
+
circle?: string;
|
|
24
|
+
ellipse?: string;
|
|
25
|
+
extent?: string;
|
|
26
|
+
closestSide?: string;
|
|
27
|
+
closestCorner?: string;
|
|
28
|
+
farthestSide?: string;
|
|
29
|
+
farthestCorner?: string;
|
|
30
|
+
repeating?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const defaultGradientLabels: (t: InkraTranslate) => Required<ColorGradientLabels>;
|
|
33
|
+
export declare function GradientEditor({ value, disabled, maxStops, labels, onChange, renderColorEditor }: {
|
|
34
|
+
value: ColorGradient;
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
maxStops: number;
|
|
37
|
+
labels: Required<ColorGradientLabels>;
|
|
38
|
+
onChange: (value: ColorGradient, source: 'stop' | 'geometry') => void;
|
|
39
|
+
renderColorEditor: (value: ColorValue, onChange: (value: ColorValue) => void) => ReactNode;
|
|
40
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import {} from '../i18n/index.js';
|
|
3
|
+
import { useId, useRef, useState } from 'react';
|
|
4
|
+
import { __iconData as addIcon } from 'lucide-react/dist/esm/icons/plus.mjs';
|
|
5
|
+
import { __iconData as removeIcon } from 'lucide-react/dist/esm/icons/minus.mjs';
|
|
6
|
+
import { __iconData as reverseIcon } from 'lucide-react/dist/esm/icons/arrow-left-right.mjs';
|
|
7
|
+
import { Button } from '../Button.js';
|
|
8
|
+
import { ColorSwatch } from '../color-swatch/index.js';
|
|
9
|
+
import { Field } from '../form/Field.js';
|
|
10
|
+
import { InputNumber } from '../input-number/index.js';
|
|
11
|
+
import { PencilIcon } from '../PencilIcon.js';
|
|
12
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
13
|
+
import { PencilText } from '../PencilText.js';
|
|
14
|
+
import { Select } from '../select/index.js';
|
|
15
|
+
import { Slider } from '../slider/index.js';
|
|
16
|
+
import { Switch } from '../selection/Switch.js';
|
|
17
|
+
import { ToggleGroup } from '../toggle-group/index.js';
|
|
18
|
+
import { formatColorPaint } from './gradient.js';
|
|
19
|
+
export const defaultGradientLabels = (t) => ({
|
|
20
|
+
type: t('gradient.type'), solid: t('gradient.solid'), linear: t('gradient.linear'), radial: t('gradient.radial'), conic: t('gradient.conic'),
|
|
21
|
+
preview: t('gradient.preview'), stops: t('gradient.stops'), stop: t('gradient.stop'), stopColor: t('gradient.stopColor'),
|
|
22
|
+
addStop: t('gradient.add'), removeStop: t('gradient.remove'), reverse: t('gradient.reverse'),
|
|
23
|
+
position: t('gradient.position'), angle: t('gradient.angle'), centerX: t('gradient.centerX'), centerY: t('gradient.centerY'),
|
|
24
|
+
shape: t('gradient.shape'), circle: t('gradient.circle'), ellipse: t('gradient.ellipse'), extent: t('gradient.extent'),
|
|
25
|
+
closestSide: t('gradient.closestSide'), closestCorner: t('gradient.closestCorner'),
|
|
26
|
+
farthestSide: t('gradient.farthestSide'), farthestCorner: t('gradient.farthestCorner'), repeating: t('gradient.repeat'),
|
|
27
|
+
});
|
|
28
|
+
const iconPaths = (data) => data.node.filter(([tag]) => tag === 'path').map(([, attrs]) => ({ d: attrs.d }));
|
|
29
|
+
const actions = { add: iconPaths(addIcon), remove: iconPaths(removeIcon), reverse: iconPaths(reverseIcon) };
|
|
30
|
+
export function GradientEditor({ value, disabled, maxStops, labels, onChange, renderColorEditor }) {
|
|
31
|
+
const id = useId();
|
|
32
|
+
const counter = useRef(0);
|
|
33
|
+
const [selected, setSelected] = useState();
|
|
34
|
+
const stop = value.stops.find(stop => stop.id === selected) ?? value.stops[0];
|
|
35
|
+
const updateStop = (patch) => onChange({
|
|
36
|
+
...value, stops: value.stops.map(item => item.id === stop.id ? { ...item, ...patch } : item),
|
|
37
|
+
}, 'stop');
|
|
38
|
+
const numberField = (label, current, max, update) => _jsx(Field, { label: label, disabled: disabled, children: _jsx(InputNumber, { controls: false, min: 0, max: max, value: current, onValueChange: next => { if (next !== null)
|
|
39
|
+
update(Math.min(max, Math.max(0, next))); } }) });
|
|
40
|
+
function addStop() {
|
|
41
|
+
// Insert in the widest interval, preserving existing stops and their identities.
|
|
42
|
+
let left = value.stops[0];
|
|
43
|
+
let right = value.stops[1];
|
|
44
|
+
for (let index = 1; index < value.stops.length - 1; index++) {
|
|
45
|
+
if (value.stops[index + 1].position - value.stops[index].position > right.position - left.position) {
|
|
46
|
+
left = value.stops[index];
|
|
47
|
+
right = value.stops[index + 1];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let nextId;
|
|
51
|
+
do {
|
|
52
|
+
nextId = `${id}-${counter.current++}`;
|
|
53
|
+
} while (value.stops.some(item => item.id === nextId));
|
|
54
|
+
onChange({ ...value, stops: [...value.stops, { id: nextId, color: stop.color, position: (left.position + right.position) / 2 }] }, 'stop');
|
|
55
|
+
setSelected(nextId);
|
|
56
|
+
}
|
|
57
|
+
return _jsxs("div", { className: "inkra-color-picker__gradient", children: [_jsxs("div", { className: "inkra-color-picker__gradient-preview", role: "img", "aria-label": `${labels.preview}: ${formatColorPaint(value)}`, children: [_jsx("span", { className: "inkra-color-picker__checker", "aria-hidden": "true" }), _jsx("span", { className: "inkra-color-picker__current", "aria-hidden": "true", style: { background: formatColorPaint(value) } }), _jsx(PencilSurface, { as: "span", "aria-hidden": "true", variant: "outline", className: "inkra-color-picker__palette-outline" })] }), _jsxs("div", { className: "inkra-color-picker__stop-toolbar", children: [_jsx("div", { className: "inkra-color-picker__stops", role: "group", "aria-label": labels.stops, children: value.stops.map((item, index) => _jsxs("span", { className: "inkra-color-picker__stop", children: [_jsx(ColorSwatch, { color: item.color, selected: item.id === stop.id, disabled: disabled, label: `${labels.stop} ${index + 1}: ${item.color} (${item.position}%)`, onClick: () => setSelected(item.id) }), _jsx(PencilText, { "aria-hidden": "true", children: `${item.position}%` })] }, item.id)) }), _jsxs("div", { className: "inkra-color-picker__stop-actions", children: [_jsx(Button, { size: "icon", variant: "ghost", "aria-label": labels.addStop, title: labels.addStop, disabled: disabled || value.stops.length >= maxStops, onClick: addStop, children: _jsx(PencilIcon, { paths: actions.add, size: 20 }) }), _jsx(Button, { size: "icon", variant: "ghost", "aria-label": labels.removeStop, title: labels.removeStop, disabled: disabled || value.stops.length <= 2, onClick: () => {
|
|
58
|
+
const index = value.stops.indexOf(stop);
|
|
59
|
+
const stops = value.stops.filter(item => item.id !== stop.id);
|
|
60
|
+
onChange({ ...value, stops }, 'stop');
|
|
61
|
+
setSelected(stops[Math.min(index, stops.length - 1)].id);
|
|
62
|
+
}, children: _jsx(PencilIcon, { paths: actions.remove, size: 20 }) }), _jsx(Button, { size: "icon", variant: "ghost", "aria-label": labels.reverse, title: labels.reverse, disabled: disabled, onClick: () => onChange({ ...value, stops: [...value.stops].reverse().map(item => ({ ...item, position: 100 - item.position })) }, 'stop'), children: _jsx(PencilIcon, { paths: actions.reverse, size: 20 }) })] })] }), _jsxs("div", { className: "inkra-color-picker__stop-position", children: [numberField(labels.position, stop.position, 100, position => updateStop({ position })), _jsx(Slider, { "aria-label": labels.position, disabled: disabled, value: [stop.position], min: 0, max: 100, step: 1, getValueLabel: value => `${value}%`, onValueChange: ([position]) => updateStop({ position }) })] }), renderColorEditor(stop.color, color => updateStop({ color })), _jsxs("div", { className: "inkra-color-picker__geometry", children: [value.type !== 'radial' && numberField(labels.angle, value.angle ?? 0, 359, angle => onChange({ ...value, angle }, 'geometry')), value.type !== 'linear' && _jsxs(_Fragment, { children: [numberField(labels.centerX, value.center?.x ?? 50, 100, x => onChange({ ...value, center: { x, y: value.center?.y ?? 50 } }, 'geometry')), numberField(labels.centerY, value.center?.y ?? 50, 100, y => onChange({ ...value, center: { x: value.center?.x ?? 50, y } }, 'geometry'))] })] }), value.type === 'radial' && _jsxs("div", { className: "inkra-color-picker__radial-options", children: [_jsxs(ToggleGroup.Root, { "aria-label": labels.shape, disabled: disabled, value: [value.shape ?? 'ellipse'], size: "sm", onValueChange: values => { if (values[0])
|
|
63
|
+
onChange({ ...value, shape: values[0] }, 'geometry'); }, children: [_jsx(ToggleGroup.Item, { value: "circle", children: labels.circle }), _jsx(ToggleGroup.Item, { value: "ellipse", children: labels.ellipse })] }), _jsxs(Select.Root, { disabled: disabled, value: value.extent ?? 'farthest-corner', onValueChange: extent => onChange({ ...value, extent: extent }, 'geometry'), children: [_jsx(Select.Trigger, { "aria-label": labels.extent, children: _jsx(Select.Value, {}) }), _jsx(Select.Portal, { children: _jsx(Select.Content, { position: "popper", children: _jsx(Select.Viewport, { children: [['closest-side', labels.closestSide], ['closest-corner', labels.closestCorner], ['farthest-side', labels.farthestSide], ['farthest-corner', labels.farthestCorner]].map(([key, label]) => _jsxs(Select.Item, { value: key, children: [_jsx(Select.ItemText, { children: label }), _jsx(Select.ItemIndicator, {})] }, key)) }) }) })] })] }), _jsx(Switch, { label: labels.repeating, disabled: disabled, checked: value.repeating ?? false, onCheckedChange: repeating => onChange({ ...value, repeating }, 'geometry') })] });
|
|
64
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ColorValue } from './color.js';
|
|
2
|
+
export type ColorPaintType = 'solid' | 'linear' | 'radial' | 'conic';
|
|
3
|
+
export interface ColorGradientStop {
|
|
4
|
+
id?: string;
|
|
5
|
+
color: string;
|
|
6
|
+
position: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ColorGradient {
|
|
9
|
+
type: Exclude<ColorPaintType, 'solid'>;
|
|
10
|
+
stops: readonly ColorGradientStop[];
|
|
11
|
+
angle?: number;
|
|
12
|
+
center?: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
shape?: 'circle' | 'ellipse';
|
|
17
|
+
extent?: 'closest-side' | 'closest-corner' | 'farthest-side' | 'farthest-corner';
|
|
18
|
+
repeating?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type ColorPaint = ColorValue | ColorGradient;
|
|
21
|
+
export declare const colorPaintTypes: readonly ColorPaintType[];
|
|
22
|
+
export declare function normalizeColorPaint(input: string | ColorGradient): ColorPaint | null;
|
|
23
|
+
/** Serialize structured paint only; arbitrary CSS expressions are not parsed. */
|
|
24
|
+
export declare function formatColorPaint(input: string | ColorGradient): string;
|
|
25
|
+
export declare function createColorGradient(type: ColorGradient['type'], color?: string): ColorGradient;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DEFAULT_COLOR_VALUE, normalizeColorValue } from './color.js';
|
|
2
|
+
export const colorPaintTypes = ['solid', 'linear', 'radial', 'conic'];
|
|
3
|
+
const extents = ['closest-side', 'closest-corner', 'farthest-side', 'farthest-corner'];
|
|
4
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
5
|
+
const percent = (value) => Math.round(Math.min(100, Math.max(0, value)) * 100) / 100;
|
|
6
|
+
export function normalizeColorPaint(input) {
|
|
7
|
+
if (typeof input === 'string')
|
|
8
|
+
return normalizeColorValue(input);
|
|
9
|
+
if (!input || !['linear', 'radial', 'conic'].includes(input.type)
|
|
10
|
+
|| !Array.isArray(input.stops) || input.stops.length < 2 || input.stops.length > 64
|
|
11
|
+
|| (input.angle !== undefined && !finite(input.angle))
|
|
12
|
+
|| (input.center !== undefined && (!input.center || !finite(input.center.x) || !finite(input.center.y)))
|
|
13
|
+
|| (input.shape !== undefined && !['circle', 'ellipse'].includes(input.shape))
|
|
14
|
+
|| (input.extent !== undefined && !extents.includes(input.extent)))
|
|
15
|
+
return null;
|
|
16
|
+
const ids = new Set();
|
|
17
|
+
const stops = [];
|
|
18
|
+
for (const [index, stop] of input.stops.entries()) {
|
|
19
|
+
if (!stop || typeof stop.color !== 'string' || !finite(stop.position))
|
|
20
|
+
return null;
|
|
21
|
+
const color = normalizeColorValue(stop.color);
|
|
22
|
+
if (!color)
|
|
23
|
+
return null;
|
|
24
|
+
let id = typeof stop.id === 'string' && stop.id ? stop.id : `stop-${index}`;
|
|
25
|
+
while (ids.has(id))
|
|
26
|
+
id += '-duplicate';
|
|
27
|
+
ids.add(id);
|
|
28
|
+
stops.push({ id, color, position: percent(stop.position) });
|
|
29
|
+
}
|
|
30
|
+
stops.sort((a, b) => a.position - b.position);
|
|
31
|
+
const angle = input.angle ?? (input.type === 'linear' ? 90 : 0);
|
|
32
|
+
return {
|
|
33
|
+
type: input.type, stops,
|
|
34
|
+
angle: (Math.round(((angle % 360 + 360) % 360) * 100) / 100) % 360,
|
|
35
|
+
center: { x: percent(input.center?.x ?? 50), y: percent(input.center?.y ?? 50) },
|
|
36
|
+
shape: input.shape ?? 'ellipse', extent: input.extent ?? 'farthest-corner',
|
|
37
|
+
repeating: input.repeating === true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Serialize structured paint only; arbitrary CSS expressions are not parsed. */
|
|
41
|
+
export function formatColorPaint(input) {
|
|
42
|
+
const value = normalizeColorPaint(input);
|
|
43
|
+
if (!value)
|
|
44
|
+
return DEFAULT_COLOR_VALUE;
|
|
45
|
+
if (typeof value === 'string')
|
|
46
|
+
return value;
|
|
47
|
+
const stops = value.stops.map(stop => `${stop.color} ${stop.position}%`).join(', ');
|
|
48
|
+
const at = `at ${value.center.x}% ${value.center.y}%`;
|
|
49
|
+
const geometry = value.type === 'linear' ? `${value.angle}deg`
|
|
50
|
+
: value.type === 'radial' ? `${value.shape} ${value.extent} ${at}`
|
|
51
|
+
: `from ${value.angle}deg ${at}`;
|
|
52
|
+
return `${value.repeating ? 'repeating-' : ''}${value.type}-gradient(${geometry}, ${stops})`;
|
|
53
|
+
}
|
|
54
|
+
export function createColorGradient(type, color = DEFAULT_COLOR_VALUE) {
|
|
55
|
+
const start = normalizeColorValue(color) ?? DEFAULT_COLOR_VALUE;
|
|
56
|
+
return normalizeColorPaint({ type, stops: [
|
|
57
|
+
{ id: 'start', color: start, position: 0 },
|
|
58
|
+
{ id: 'end', color: start === '#e6c17bff' ? DEFAULT_COLOR_VALUE : '#e6c17bff', position: 100 },
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { FieldsetHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { ColorGradientLabels } from './GradientEditor.js';
|
|
3
|
+
import type { ColorGradient, ColorPaint, ColorPaintType } from './gradient.js';
|
|
2
4
|
import type { ColorValue } from './color.js';
|
|
3
5
|
export interface ColorPreset {
|
|
4
|
-
value: string;
|
|
6
|
+
value: string | ColorGradient;
|
|
5
7
|
label?: string;
|
|
6
8
|
}
|
|
7
9
|
export interface ColorPickerLabels {
|
|
@@ -12,20 +14,38 @@ export interface ColorPickerLabels {
|
|
|
12
14
|
invalid?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface ColorPickerChangeDetails {
|
|
15
|
-
source: 'palette' | 'alpha' | 'input' | 'preset';
|
|
17
|
+
source: 'palette' | 'alpha' | 'input' | 'preset' | 'type' | 'stop' | 'geometry';
|
|
16
18
|
}
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
defaultValue?: string;
|
|
20
|
-
onValueChange?: (value: ColorValue, details: ColorPickerChangeDetails) => void;
|
|
19
|
+
export type ColorPickerPresentation = 'inline' | 'compact' | 'popover' | 'swatches';
|
|
20
|
+
export interface ColorPickerBaseProps extends Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, 'defaultValue' | 'onChange' | 'value'> {
|
|
21
21
|
onInvalidInput?: (input: string) => void;
|
|
22
22
|
presets?: readonly (string | ColorPreset)[];
|
|
23
23
|
label?: ReactNode;
|
|
24
24
|
labels?: ColorPickerLabels;
|
|
25
|
+
gradientLabels?: ColorGradientLabels;
|
|
25
26
|
name?: string;
|
|
26
27
|
showAlpha?: boolean;
|
|
28
|
+
presentation?: ColorPickerPresentation;
|
|
27
29
|
seed?: string | number;
|
|
28
30
|
}
|
|
29
|
-
export
|
|
31
|
+
export type ColorPickerProps = ColorPickerBaseProps & ({
|
|
32
|
+
allowGradient?: false;
|
|
33
|
+
value?: string;
|
|
34
|
+
defaultValue?: string;
|
|
35
|
+
onValueChange?: (value: ColorValue, details: ColorPickerChangeDetails) => void;
|
|
36
|
+
colorTypes?: never;
|
|
37
|
+
maxStops?: never;
|
|
38
|
+
} | {
|
|
39
|
+
allowGradient: true;
|
|
40
|
+
value?: string | ColorGradient;
|
|
41
|
+
defaultValue?: string | ColorGradient;
|
|
42
|
+
onValueChange?: (value: ColorPaint, details: ColorPickerChangeDetails) => void;
|
|
43
|
+
colorTypes?: readonly ColorPaintType[];
|
|
44
|
+
maxStops?: number;
|
|
45
|
+
});
|
|
46
|
+
export declare function ColorPicker(options: ColorPickerProps): import("react").JSX.Element;
|
|
30
47
|
export { DEFAULT_COLOR_VALUE, colorAlphaPercent, colorRgbValue, formatColorValue, normalizeColorValue, parseColorValue, withColorAlpha, withColorRgb, } from './color.js';
|
|
31
48
|
export type { ColorChannels, ColorValue } from './color.js';
|
|
49
|
+
export { createColorGradient, formatColorPaint, normalizeColorPaint } from './gradient.js';
|
|
50
|
+
export type { ColorGradient, ColorGradientStop, ColorPaint, ColorPaintType } from './gradient.js';
|
|
51
|
+
export type { ColorGradientLabels } from './GradientEditor.js';
|