@eightshift/ui-components 0.0.1
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 +27 -0
- package/dist/Checkbox-BLcVbhiO.js +178 -0
- package/dist/ColorSwatch-Cmlex_kT.js +66 -0
- package/dist/FieldError-wtMA4667.js +42 -0
- package/dist/FocusScope-1u9yyfIN.js +725 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/GridList-BZPXp3_O.js +1256 -0
- package/dist/Group-DyqpTRPe.js +49 -0
- package/dist/Input-jsbb4ugq.js +130 -0
- package/dist/Label-BPzS-sR7.js +17 -0
- package/dist/ListBox-w9gDaJkV.js +4423 -0
- package/dist/LiveAnnouncer-IsokfWQ5.js +73 -0
- package/dist/NumberFormatter-LzoKy975.js +160 -0
- package/dist/RSPContexts-CrNYmadY.js +14 -0
- package/dist/Select-49a62830.esm-C-RFtLiD.js +2541 -0
- package/dist/SelectionManager-mefd0ThJ.js +2155 -0
- package/dist/Separator-DHn0CwdK.js +325 -0
- package/dist/Slider-Pyh2V4bY.js +885 -0
- package/dist/Text-BM136LvS.js +17 -0
- package/dist/VisuallyHidden-BYRI1Lfo.js +51 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/ariaHideOutside-ByKBPHmX.js +113 -0
- package/dist/assets/style.css +1 -0
- package/dist/button-BkkdyHfJ.js +307 -0
- package/dist/components/animated-visibility/animated-visibility.js +7165 -0
- package/dist/components/base-control/base-control.js +97 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +218 -0
- package/dist/components/button/button.js +10 -0
- package/dist/components/checkbox/checkbox.js +119 -0
- package/dist/components/color-pickers/color-picker.js +242 -0
- package/dist/components/color-pickers/color-swatch.js +62 -0
- package/dist/components/color-pickers/gradient-editor.js +516 -0
- package/dist/components/color-pickers/solid-color-picker.js +1633 -0
- package/dist/components/component-toggle/component-toggle.js +71 -0
- package/dist/components/container-panel/container-panel.js +39 -0
- package/dist/components/expandable/expandable.js +144 -0
- package/dist/components/input-field/input-field.js +224 -0
- package/dist/components/link-input/link-input.js +937 -0
- package/dist/components/list-box/list-box.js +152 -0
- package/dist/components/matrix-align/matrix-align.js +185 -0
- package/dist/components/menu/menu.js +1608 -0
- package/dist/components/notice/notice.js +119 -0
- package/dist/components/number-picker/number-picker.js +277 -0
- package/dist/components/popover/popover.js +9 -0
- package/dist/components/radio/radio.js +552 -0
- package/dist/components/repeater/repeater-item.js +127 -0
- package/dist/components/repeater/repeater.js +248 -0
- package/dist/components/responsive/responsive-legacy.js +326 -0
- package/dist/components/responsive/responsive.js +499 -0
- package/dist/components/responsive-preview/responsive-preview.js +119 -0
- package/dist/components/rich-label/rich-label.js +56 -0
- package/dist/components/select/async-multi-select.js +144 -0
- package/dist/components/select/async-single-select.js +126 -0
- package/dist/components/select/custom-select-default-components.js +38 -0
- package/dist/components/select/multi-select-components.js +8 -0
- package/dist/components/select/multi-select.js +134 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +45 -0
- package/dist/components/select/single-select.js +116 -0
- package/dist/components/select/styles.js +55 -0
- package/dist/components/slider/column-config-slider.js +225 -0
- package/dist/components/slider/slider.js +362 -0
- package/dist/components/slider/utils.js +45 -0
- package/dist/components/spacer/spacer.js +93 -0
- package/dist/components/tabs/tabs.js +626 -0
- package/dist/components/toggle/switch.js +140 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle-button/toggle-button.js +206 -0
- package/dist/components/tooltip/tooltip.js +10 -0
- package/dist/context-jMy6xdVq.js +98 -0
- package/dist/default-i18n-BhE-OUmt.js +873 -0
- package/dist/filterDOMProps-DG2RfOUr.js +30 -0
- package/dist/focusSafely-C3K8zAKj.js +743 -0
- package/dist/hooks/use-cell-edit-mode.js +35 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +21 -0
- package/dist/icons/icons.js +3636 -0
- package/dist/index-Bfb9bWcb.js +28844 -0
- package/dist/index-a301f526.esm-Bioi4cGX.js +3576 -0
- package/dist/index.js +109 -0
- package/dist/intlStrings-CUhoK9EN.js +2484 -0
- package/dist/isScrollable-PcyglExV.js +10 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-CjVpCNko.js +3677 -0
- package/dist/number-rWqELA8W.js +39 -0
- package/dist/popover-Dx3vKXUX.js +1061 -0
- package/dist/react-select-async.esm-TFb_ZX6C.js +111 -0
- package/dist/react-select.esm-BjRWqf0E.js +15 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-BosCCRVE.js +89 -0
- package/dist/tooltip-CkCndvTI.js +1094 -0
- package/dist/useButton-CuG5UzUw.js +74 -0
- package/dist/useEvent-DHv-yhOH.js +24 -0
- package/dist/useFocusRing-Cc-4eouh.js +41 -0
- package/dist/useFocusable-5q1Gek1J.js +81 -0
- package/dist/useFormReset-Buc9YJcv.js +23 -0
- package/dist/useFormValidationState-BAPPNXic.js +238 -0
- package/dist/useHasTabbableChild-D3uUNhJ0.js +37 -0
- package/dist/useLabel-CGlkoFG0.js +28 -0
- package/dist/useLabels-Dg62M_3P.js +25 -0
- package/dist/useListData-BelKu4kx.js +211 -0
- package/dist/useListState-Domq0blV.js +137 -0
- package/dist/useLocalizedStringFormatter-Prmz0h0A.js +130 -0
- package/dist/useNumberFieldState-BLU3uhSR.js +1253 -0
- package/dist/useNumberFormatter-BLc2xjZn.js +13 -0
- package/dist/usePress-BQgVor4T.js +698 -0
- package/dist/useToggle-C9ETOBaZ.js +58 -0
- package/dist/useToggleState-DJ_z5E2S.js +21 -0
- package/dist/utilities/classnames.js +16 -0
- package/dist/utilities/text-helpers.js +79 -0
- package/dist/utils-BsiH7-5Y.js +488 -0
- package/package.json +71 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../ListBox-w9gDaJkV.js";
|
|
3
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
4
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
5
|
+
import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
|
|
6
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
7
|
+
/**
|
|
8
|
+
* A component that allows selecting a single or multiple options from a list.
|
|
9
|
+
*
|
|
10
|
+
* @component
|
|
11
|
+
* @param {Object} props - Component props.
|
|
12
|
+
* @param {JSX.Element} [props.icon] - Icon to display in the label.
|
|
13
|
+
* @param {string} [props.label] - Label to display.
|
|
14
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
15
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display in the header.
|
|
16
|
+
* @param {string} [props.help] - Help text to display below the list.
|
|
17
|
+
* @param {boolean} [props.inline] - If `true`, the list is displayed inline with the label.
|
|
18
|
+
* @param {Object[]} props.options - The list of options to display.
|
|
19
|
+
* @param {string} props.options[].value - The value of the option. Should be unique!
|
|
20
|
+
* @param {string} [props.options[].label] - The label of the option.
|
|
21
|
+
* @param {JSX.Element} [props.options[].icon] - The icon of the option.
|
|
22
|
+
* @param {string} [props.options[].subtitle] - The subtitle of the option.
|
|
23
|
+
* @param {string} [props.options[].tooltip] - The tooltip text of the option.
|
|
24
|
+
* @param {boolean} [props.options[].disabled] - If `true`, the option is cannot be selected.
|
|
25
|
+
* @param {ListBoxSelectionMode} [props.selectionMode='single'] - The selection mode.
|
|
26
|
+
* @param {string} props.value - The currently selected value.
|
|
27
|
+
* @param {Function} props.onChange - Function to run when the selection changes.
|
|
28
|
+
* @param {boolean} [props.canDeselect=false] - If `true`, the selected value can be deselected (`null` is set in that case).
|
|
29
|
+
* @param {ListBoxOrientation} [props.orientation='horizontal'] - The orientation of the list. If all options have only an icon set, the orientation is forced to be horizontal.
|
|
30
|
+
* @param {string} [props.className] - Classes to pass to the list.
|
|
31
|
+
*
|
|
32
|
+
* @returns {JSX.Element} The ListBox component.
|
|
33
|
+
*
|
|
34
|
+
* @typedef {'single' | 'multiple'} ListBoxSelectionMode
|
|
35
|
+
* @typedef {'horizontal' | 'vertical' | 'horizontal-tiles'} ListBoxOrientation
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* <ListBox
|
|
39
|
+
* label='My list'
|
|
40
|
+
* options={[
|
|
41
|
+
* { value: 'option1', label: 'Option 1' },
|
|
42
|
+
* { value: 'option2', label: 'Option 2' },
|
|
43
|
+
* ]}
|
|
44
|
+
* value={selectedValue}
|
|
45
|
+
* onChange={setSelectedValue}
|
|
46
|
+
* />
|
|
47
|
+
*
|
|
48
|
+
* @preserve
|
|
49
|
+
*/
|
|
50
|
+
const ListBox = (props) => {
|
|
51
|
+
const {
|
|
52
|
+
icon,
|
|
53
|
+
label,
|
|
54
|
+
subtitle,
|
|
55
|
+
actions,
|
|
56
|
+
help,
|
|
57
|
+
inline,
|
|
58
|
+
options,
|
|
59
|
+
"aria-label": ariaLabel,
|
|
60
|
+
selectionMode = "single",
|
|
61
|
+
value,
|
|
62
|
+
onChange,
|
|
63
|
+
canDeselect = false,
|
|
64
|
+
orientation: setOrientation = "horizontal",
|
|
65
|
+
className,
|
|
66
|
+
...rest
|
|
67
|
+
} = props;
|
|
68
|
+
const mappedOptions = options.map((option) => ({
|
|
69
|
+
...option,
|
|
70
|
+
id: option.id ?? option.value
|
|
71
|
+
}));
|
|
72
|
+
let orientation = setOrientation;
|
|
73
|
+
if (options.every(({ icon: icon2, label: label2, subtitle: subtitle2 }) => icon2 && !label2 && !subtitle2)) {
|
|
74
|
+
orientation = "horizontal";
|
|
75
|
+
}
|
|
76
|
+
let orientationPropValue = orientation;
|
|
77
|
+
if (orientation === "horizontal-tiles") {
|
|
78
|
+
orientationPropValue = "horizontal";
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ jsx(
|
|
81
|
+
BaseControl,
|
|
82
|
+
{
|
|
83
|
+
icon,
|
|
84
|
+
label,
|
|
85
|
+
subtitle,
|
|
86
|
+
actions,
|
|
87
|
+
inline,
|
|
88
|
+
help,
|
|
89
|
+
children: /* @__PURE__ */ jsx(
|
|
90
|
+
$eed445e0843c11d0$export$41f133550aa26f48,
|
|
91
|
+
{
|
|
92
|
+
selectionMode,
|
|
93
|
+
className: classnames(
|
|
94
|
+
"es-uic-rounded-lg es-uic-border es-uic-border-gray-300 es-uic-p-1 es-uic-text-sm es-uic-shadow-sm es-uic-transition",
|
|
95
|
+
"focus:es-uic-outline-none",
|
|
96
|
+
orientation === "horizontal" && "es-uic-flex es-uic-w-fit es-uic-max-w-full es-uic-gap-0.5",
|
|
97
|
+
orientation === "vertical" && "es-uic-flex es-uic-flex-col es-uic-gap-0.5",
|
|
98
|
+
orientation === "horizontal-tiles" && "es-uic-grid es-uic-min-h-20 es-uic-w-fit es-uic-max-w-full es-uic-auto-cols-[fit-content(6rem)] es-uic-grid-rows-[1fr,_minmax(auto,_0.5fr),_auto] es-uic-gap-x-0.5",
|
|
99
|
+
className
|
|
100
|
+
),
|
|
101
|
+
"aria-label": ariaLabel ?? __("Choose", "eightshift-ui-components"),
|
|
102
|
+
items: mappedOptions,
|
|
103
|
+
disallowEmptySelection: !canDeselect,
|
|
104
|
+
orientation: orientationPropValue,
|
|
105
|
+
selectedKeys: [value],
|
|
106
|
+
onSelectionChange: (key) => {
|
|
107
|
+
onChange((key == null ? void 0 : key.currentKey) ?? (key == null ? void 0 : key.anchorKey));
|
|
108
|
+
},
|
|
109
|
+
...rest,
|
|
110
|
+
children: (item) => {
|
|
111
|
+
const { label: label2, icon: icon2, subtitle: subtitle2, tooltip, disabled } = item;
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
$eed445e0843c11d0$export$a11e76429ed99b4,
|
|
114
|
+
{
|
|
115
|
+
textValue: label2 ?? tooltip,
|
|
116
|
+
isDisabled: disabled,
|
|
117
|
+
className: ({ isDisabled, isSelected }) => {
|
|
118
|
+
return classnames(
|
|
119
|
+
"es-uic-flex es-uic-min-h-9 es-uic-select-none es-uic-rounded-md es-uic-border es-uic-transition",
|
|
120
|
+
"focus:es-uic-outline-none focus-visible:es-uic-outline-none focus-visible:es-uic-ring focus-visible:es-uic-ring-teal-500 focus-visible:es-uic-ring-opacity-50",
|
|
121
|
+
isSelected && !disabled && "es-uic-bg-teal-600 es-uic-text-white es-uic-border-teal-600 after:es-uic-opacity-45 es-uic-border es-uic-shadow-md es-uic-shadow-teal-500/25",
|
|
122
|
+
isSelected && !disabled && "es-uic-text-white [&_svg]:es-uic-text-white [&_span]:es-uic-text-white [&_span_+_span]:es-uic-text-white/80",
|
|
123
|
+
isSelected && !disabled && 'es-uic-relative es-uic-isolate after:es-uic-absolute after:es-uic-inset-0 after:-es-uic-z-10 after:es-uic-rounded-[0.3125rem] after:es-uic-bg-gradient-to-br after:es-uic-from-teal-100/40 after:es-uic-via-transparent after:es-uic-to-teal-200/50 after:es-uic-opacity-0 after:es-uic-transition-opacity after:es-uic-content-[""]',
|
|
124
|
+
!isSelected && !disabled && "es-uic-border-transparent hover:es-uic-bg-gray-100",
|
|
125
|
+
isDisabled && "es-uic-border-transparent es-uic-opacity-30 es-uic-grayscale",
|
|
126
|
+
orientation !== "horizontal-tiles" && "es-uic-px-2 es-uic-py-1.5",
|
|
127
|
+
icon2 && !label2 && !subtitle2 && "es-uic-size-9 !es-uic-p-1.5",
|
|
128
|
+
orientation === "horizontal-tiles" && "es-uic-row-start-1 es-uic-row-end-4 es-uic-grid es-uic-min-w-18 es-uic-grid-rows-subgrid es-uic-items-center es-uic-justify-items-center es-uic-p-1.5 es-uic-text-center es-uic-leading-tight",
|
|
129
|
+
orientation === "horizontal-tiles" && subtitle2 && "[&_svg]:es-uic-mb-1"
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
children: /* @__PURE__ */ jsx(
|
|
133
|
+
RichLabel,
|
|
134
|
+
{
|
|
135
|
+
icon: icon2,
|
|
136
|
+
label: label2,
|
|
137
|
+
subtitle: subtitle2,
|
|
138
|
+
className: classnames(orientation === "horizontal" && "leading-none"),
|
|
139
|
+
contentsOnly: orientation === "horizontal-tiles"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
export {
|
|
151
|
+
ListBox
|
|
152
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import { _ as __ } from "../../default-i18n-BhE-OUmt.js";
|
|
4
|
+
import { P as Popover } from "../../popover-Dx3vKXUX.js";
|
|
5
|
+
import { B as Button } from "../../button-BkkdyHfJ.js";
|
|
6
|
+
import { icons } from "../../icons/icons.js";
|
|
7
|
+
import { upperFirst, camelCase } from "../../utilities/text-helpers.js";
|
|
8
|
+
import { classnames } from "../../utilities/classnames.js";
|
|
9
|
+
import { T as Tooltip } from "../../tooltip-CkCndvTI.js";
|
|
10
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
11
|
+
/**
|
|
12
|
+
* A component that can provide a 3x3 or a 2x2 grid of positions to pick from.
|
|
13
|
+
* Replaces the default Gutenberg `AlignmentMatrixControl`/`BlockAlignmentMatrixControl`/`BlockAlignmentMatrixToolbar`.
|
|
14
|
+
*
|
|
15
|
+
* @component
|
|
16
|
+
* @param {Object} props - Component props.
|
|
17
|
+
* @param {MatrixSize} [props.size='3x3'] - The size of the matrix. Can be either '3x3' or '2x2'.
|
|
18
|
+
* @param {string} props.value - The currently selected value.
|
|
19
|
+
* @param {Function} props.onChange - Function to run when the selection changes.
|
|
20
|
+
* @param {string} [props.tooltip='Position'] - Tooltip text to display on the trigger button.
|
|
21
|
+
* @param {string} [props.label] - Label to display.
|
|
22
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the button.
|
|
23
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
24
|
+
* @param {string} [props.popoverPosition='bottom'] - The position of the popover.
|
|
25
|
+
*
|
|
26
|
+
* @returns {JSX.Element} The MatrixAlign component.
|
|
27
|
+
*
|
|
28
|
+
* @typedef {'3x3' | '2x2'} MatrixSize
|
|
29
|
+
* @typedef {'bottom' | 'bottom left' | 'bottom right' | 'bottom start' | 'bottom end' | 'top' | 'top left' | 'top right' | 'top start' | 'top end' | 'left' | 'left top' | 'left bottom' | 'start' | 'start top' | 'start bottom' | 'right' | 'right top' | 'right bottom' | 'end' | 'end top' | 'end bottom'} PopoverPosition
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <MatrixAlign
|
|
33
|
+
* size='3x3'
|
|
34
|
+
* value='top left'
|
|
35
|
+
* onChange={setAlignment}
|
|
36
|
+
* />
|
|
37
|
+
*
|
|
38
|
+
* @preserve
|
|
39
|
+
*/
|
|
40
|
+
const MatrixAlign = (props) => {
|
|
41
|
+
const {
|
|
42
|
+
size = "3x3",
|
|
43
|
+
value,
|
|
44
|
+
onChange,
|
|
45
|
+
tooltip = __("Position", "eightshift-ui-components"),
|
|
46
|
+
label,
|
|
47
|
+
icon,
|
|
48
|
+
subtitle,
|
|
49
|
+
"aria-label": ariaLabel,
|
|
50
|
+
popoverPosition
|
|
51
|
+
} = props;
|
|
52
|
+
const [currentValue, setCurrentValue] = useState(value);
|
|
53
|
+
const [tooltipText, setTooltipText] = useState(null);
|
|
54
|
+
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
55
|
+
const ref = useRef(null);
|
|
56
|
+
const innerRef = useRef(null);
|
|
57
|
+
const allSizeOptions = [
|
|
58
|
+
{
|
|
59
|
+
value: "top left",
|
|
60
|
+
label: __("Top-left", "eightshift-ui-components"),
|
|
61
|
+
availableOn: ["3x3", "2x2"]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: "top center",
|
|
65
|
+
label: __("Top-center", "eightshift-ui-components"),
|
|
66
|
+
availableOn: ["3x3"]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: "top right",
|
|
70
|
+
label: __("Top-right", "eightshift-ui-components"),
|
|
71
|
+
availableOn: ["3x3", "2x2"]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: "center left",
|
|
75
|
+
label: __("Center-left", "eightshift-ui-components"),
|
|
76
|
+
availableOn: ["3x3"]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: "center center",
|
|
80
|
+
label: __("Center", "eightshift-ui-components"),
|
|
81
|
+
availableOn: ["3x3"]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "center right",
|
|
85
|
+
label: __("Center-right", "eightshift-ui-components"),
|
|
86
|
+
availableOn: ["3x3"]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: "bottom left",
|
|
90
|
+
label: __("Bottom-left", "eightshift-ui-components"),
|
|
91
|
+
availableOn: ["3x3", "2x2"]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: "bottom center",
|
|
95
|
+
label: __("Bottom-center", "eightshift-ui-components"),
|
|
96
|
+
availableOn: ["3x3"]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: "bottom right",
|
|
100
|
+
label: __("Bottom-right", "eightshift-ui-components"),
|
|
101
|
+
availableOn: ["3x3", "2x2"]
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
const sizeOptions = allSizeOptions.filter(({ availableOn }) => availableOn.includes(size)).map((item) => ({
|
|
105
|
+
...item,
|
|
106
|
+
icon: item.value === currentValue ? icons.matrixAlignControlDotActive : icons.matrixAlignControlDotInactive
|
|
107
|
+
}));
|
|
108
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
BaseControl,
|
|
111
|
+
{
|
|
112
|
+
icon,
|
|
113
|
+
label,
|
|
114
|
+
subtitle,
|
|
115
|
+
inline: true,
|
|
116
|
+
children: /* @__PURE__ */ jsx(
|
|
117
|
+
Button,
|
|
118
|
+
{
|
|
119
|
+
icon: icons[`position${size}${upperFirst(camelCase(currentValue))}`],
|
|
120
|
+
onPress: () => {
|
|
121
|
+
setPopoverOpen(true);
|
|
122
|
+
},
|
|
123
|
+
forwardedRef: ref,
|
|
124
|
+
tooltip,
|
|
125
|
+
children: !(icon || subtitle) && label
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
Popover,
|
|
132
|
+
{
|
|
133
|
+
"aria-label": ariaLabel ?? __("Select position", "eightshift-ui-components"),
|
|
134
|
+
position: popoverPosition,
|
|
135
|
+
triggerRef: ref,
|
|
136
|
+
onOpenChange: setPopoverOpen,
|
|
137
|
+
isOpen: popoverOpen,
|
|
138
|
+
ariaLabel: label ?? tooltip,
|
|
139
|
+
children: /* @__PURE__ */ jsx(
|
|
140
|
+
Tooltip,
|
|
141
|
+
{
|
|
142
|
+
text: tooltipText,
|
|
143
|
+
placement: "bottom",
|
|
144
|
+
delayDuration: 200,
|
|
145
|
+
open: popoverOpen && tooltipText !== null,
|
|
146
|
+
offset: 10,
|
|
147
|
+
triggerRef: innerRef,
|
|
148
|
+
className: tooltipText === null ? "es-uic-opacity-0" : "",
|
|
149
|
+
children: /* @__PURE__ */ jsx(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
ref: innerRef,
|
|
153
|
+
className: classnames(
|
|
154
|
+
"es-uic-grid",
|
|
155
|
+
size === "3x3" && "es-uic-grid-cols-3 es-uic-grid-rows-3",
|
|
156
|
+
size === "2x2" && "es-uic-grid-cols-2 es-uic-grid-rows-2"
|
|
157
|
+
),
|
|
158
|
+
children: sizeOptions.map(({ value: value2, label: label2, icon: icon2 }) => /* @__PURE__ */ jsx(
|
|
159
|
+
Button,
|
|
160
|
+
{
|
|
161
|
+
icon: icon2,
|
|
162
|
+
type: "ghost",
|
|
163
|
+
onHoverStart: () => setTooltipText(label2),
|
|
164
|
+
onHoverEnd: () => setTooltipText(null),
|
|
165
|
+
onFocus: () => setTooltipText(label2),
|
|
166
|
+
onPress: () => {
|
|
167
|
+
setCurrentValue(value2);
|
|
168
|
+
setTooltipText(null);
|
|
169
|
+
setPopoverOpen(false);
|
|
170
|
+
onChange(value2);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
value2
|
|
174
|
+
))
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] });
|
|
182
|
+
};
|
|
183
|
+
export {
|
|
184
|
+
MatrixAlign
|
|
185
|
+
};
|