@eightshift/ui-components 5.0.0 → 5.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/dist/Button-wERNNG0T.js +185 -0
- package/dist/Collection-CKsHTyhc.js +2363 -0
- package/dist/Color-BhgbJF5x.js +2452 -0
- package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
- package/dist/ComboBox-D1LPUwWP.js +1906 -0
- package/dist/Dialog-D190gMbE.js +2298 -0
- package/dist/FieldError-DeUh5Wkw.js +42 -0
- package/dist/FocusScope-C-plSxbS.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-C5iZpSAM.js +48 -0
- package/dist/Heading-D-Pboe4p.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input--mF4XVE1.js +133 -0
- package/dist/Label-Fp6AwSRn.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-4oW9kh3R.js +582 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-BpB9uB_I.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-B88tj5YD.js +323 -0
- package/dist/Slider-CyJzC1bp.js +853 -0
- package/dist/Text-DRpwWot2.js +16 -0
- package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5864 -0
- package/dist/assets/style-editor.css +5864 -0
- package/dist/assets/style.css +5870 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +377 -0
- package/dist/components/animated-visibility/animated-visibility.js +105 -0
- package/dist/components/base-control/base-control.js +86 -0
- package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
- package/dist/components/button/button.js +387 -0
- package/dist/components/checkbox/checkbox.js +320 -0
- package/dist/components/color-pickers/color-picker.js +272 -0
- package/dist/components/color-pickers/color-swatch.js +59 -0
- package/dist/components/color-pickers/gradient-editor.js +534 -0
- package/dist/components/color-pickers/solid-color-picker.js +1567 -0
- package/dist/components/component-toggle/component-toggle.js +161 -0
- package/dist/components/container-panel/container-panel.js +131 -0
- package/dist/components/draggable/draggable-context.js +5 -0
- package/dist/components/draggable/draggable-handle.js +46 -0
- package/dist/components/draggable/draggable.js +6979 -0
- package/dist/components/draggable-list/draggable-list-context.js +5 -0
- package/dist/components/draggable-list/draggable-list-item.js +77 -0
- package/dist/components/draggable-list/draggable-list.js +151 -0
- package/dist/components/expandable/expandable.js +342 -0
- package/dist/components/index.js +137 -0
- package/dist/components/input-field/input-field.js +231 -0
- package/dist/components/item-collection/item-collection.js +59 -0
- package/dist/components/layout/hstack.js +30 -0
- package/dist/components/layout/vstack.js +30 -0
- package/dist/components/link-input/link-input.js +291 -0
- package/dist/components/matrix-align/matrix-align.js +134 -0
- package/dist/components/menu/menu.js +285 -0
- package/dist/components/modal/modal.js +305 -0
- package/dist/components/notice/notice.js +123 -0
- package/dist/components/number-picker/number-picker.js +292 -0
- package/dist/components/option-select/option-select.js +264 -0
- package/dist/components/options-panel/options-panel.js +158 -0
- package/dist/components/placeholders/file-placeholder.js +42 -0
- package/dist/components/placeholders/image-placeholder.js +88 -0
- package/dist/components/placeholders/media-placeholder.js +63 -0
- package/dist/components/popover/popover.js +207 -0
- package/dist/components/radio/radio.js +579 -0
- package/dist/components/repeater/repeater-context.js +5 -0
- package/dist/components/repeater/repeater-item.js +119 -0
- package/dist/components/repeater/repeater.js +280 -0
- package/dist/components/responsive/mini-responsive.js +498 -0
- package/dist/components/responsive/responsive-legacy.js +343 -0
- package/dist/components/responsive/responsive.js +583 -0
- package/dist/components/responsive-preview/responsive-preview.js +123 -0
- package/dist/components/rich-label/rich-label.js +66 -0
- package/dist/components/select/async-multi-select.js +157 -0
- package/dist/components/select/async-single-select.js +137 -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 +151 -0
- package/dist/components/select/react-select-component-wrappers.js +90 -0
- package/dist/components/select/shared.js +26 -0
- package/dist/components/select/single-select.js +131 -0
- package/dist/components/select/styles.js +49 -0
- package/dist/components/select/v2/async-select.js +297 -0
- package/dist/components/select/v2/shared.js +24 -0
- package/dist/components/select/v2/single-select.js +991 -0
- package/dist/components/slider/column-config-slider.js +210 -0
- package/dist/components/slider/slider.js +345 -0
- package/dist/components/slider/utils.js +94 -0
- package/dist/components/spacer/spacer.js +97 -0
- package/dist/components/tabs/tabs.js +704 -0
- package/dist/components/toggle/switch.js +156 -0
- package/dist/components/toggle/toggle.js +64 -0
- package/dist/components/toggle-button/toggle-button.js +343 -0
- package/dist/components/tooltip/tooltip.js +527 -0
- package/dist/context-BYWrbm1z.js +92 -0
- package/dist/default-i18n-CT_oS1Fy.js +922 -0
- package/dist/filterDOMProps-EDDcM64A.js +28 -0
- package/dist/icons/block-icon.js +42 -0
- package/dist/icons/generic-color-swatch.js +113 -0
- package/dist/icons/icons.js +30371 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/jsx-svg.js +50 -0
- package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
- package/dist/index-CFozsmNS.js +28321 -0
- package/dist/index-wl5606BX.js +44 -0
- package/dist/index.js +139 -0
- package/dist/lite-DVmmD_-j.js +7 -0
- package/dist/modifiers.esm-BuJQPI1X.js +31 -0
- package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
- package/dist/number-GajL10e1.js +36 -0
- package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
- package/dist/react-select-async.esm-D937XTWW.js +107 -0
- package/dist/react-select.esm-Ciai3aKf.js +15 -0
- package/dist/style-admin.js +1 -0
- package/dist/style-editor.js +1 -0
- package/dist/style.js +1 -0
- package/dist/textSelection-CCcyjiRP.js +46 -0
- package/dist/useButton-BOHxkGQF.js +50 -0
- package/dist/useEvent-D5o_CqDH.js +23 -0
- package/dist/useFocusRing-nMG2uzxS.js +107 -0
- package/dist/useFormReset-DlmRL87g.js +22 -0
- package/dist/useFormValidation-D0_aaK-e.js +224 -0
- package/dist/useHover-VO5tcIli.js +890 -0
- package/dist/useLabel-BKH4fVA4.js +27 -0
- package/dist/useLabels-ntF3rFY0.js +23 -0
- package/dist/useListState-Cq2Nvr-v.js +161 -0
- package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
- package/dist/useNumberField-C9dmERhP.js +1207 -0
- package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
- package/dist/usePress-DjNo5790.js +677 -0
- package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
- package/dist/useToggle-CQaXLe-O.js +59 -0
- package/dist/useToggleState-C3DLdez5.js +19 -0
- package/dist/utilities/array-helpers.js +56 -0
- package/dist/utilities/debounce-throttle.js +123 -0
- package/dist/utilities/es-dash.js +382 -0
- package/dist/utilities/index.js +27 -0
- package/dist/utilities/text-helpers.js +136 -0
- package/dist/utils-B94NDG0v.js +370 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-wERNNG0T.js";
|
|
3
|
+
import { $ as $f86e6c1ec7da6ebb$export$bc3384a35de93d66, a as $d01f2c01039c0eec$export$72b9695b8216309a } from "../../ComboBox-D1LPUwWP.js";
|
|
4
|
+
import { $ as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../../Group-C5iZpSAM.js";
|
|
5
|
+
import { $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input--mF4XVE1.js";
|
|
6
|
+
import { $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-Fp6AwSRn.js";
|
|
7
|
+
import { $ as $eed445e0843c11d0$export$41f133550aa26f48, a as $eed445e0843c11d0$export$a11e76429ed99b4 } from "../../ListBox-4oW9kh3R.js";
|
|
8
|
+
import { $ as $07b14b47974efb58$export$5b6b19405a83ff9d } from "../../Dialog-D190gMbE.js";
|
|
9
|
+
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
10
|
+
import { icons } from "../../icons/icons.js";
|
|
11
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
12
|
+
import { useRef, useState, useEffect, cloneElement } from "react";
|
|
13
|
+
import { Spacer } from "../spacer/spacer.js";
|
|
14
|
+
import { Tooltip } from "../tooltip/tooltip.js";
|
|
15
|
+
import { AnimatedVisibility } from "../animated-visibility/animated-visibility.js";
|
|
16
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
17
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
18
|
+
/**
|
|
19
|
+
* Component that allows URL selection, with a suggestionList of suggestions and type-to-search.
|
|
20
|
+
*
|
|
21
|
+
* @component
|
|
22
|
+
* @param {Object} props - Component props.
|
|
23
|
+
* @param {string} [props.url] - The current URL.
|
|
24
|
+
* @param {Function} [props.onChange] - Function to run when the URL changes.
|
|
25
|
+
* @param {string} [props.label] - Label to display.
|
|
26
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
27
|
+
* @param {string} [props.help] - Help text to display below the input.
|
|
28
|
+
* @param {string} [props.placeholder] - Placeholder to show in the input field.
|
|
29
|
+
* @param {JSX.Element|JSX.Element[]} [props.actions] - Actions to display to the right of the label.
|
|
30
|
+
* @param {JSX.Element} [props.icon=icons.globe] - Icon to display in the label.
|
|
31
|
+
* @param {JSX.Element} [props.removeIcon=icons.clearAlt] - Icon to display in the input's clear button.
|
|
32
|
+
* @param {boolean} [props.disabled=false] - If `true`, the input is disabled.
|
|
33
|
+
* @param {Function} [props.fetchSuggestions] - A function that fetches suggestions based on the input value.
|
|
34
|
+
* @param {string} [props.className] - Classes to pass to the input field.
|
|
35
|
+
* @param {number} [props.inputDebounceDelay=500] - The delay in milliseconds before the input value is considered final.
|
|
36
|
+
* @param {Function} [props.suggestionTypeIconOverride] - Allows overriding the default icon for the suggestion type, e.g. when using CPTs. Should be in the format: `(type) => icon or React component`.
|
|
37
|
+
* @param {boolean} [props.showSuggestionsWhenEmpty] - If `true`, the suggestion list will be shown when down arrow is pressed even the input is empty.
|
|
38
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
39
|
+
*
|
|
40
|
+
* @returns {JSX.Element} The LinkInput component.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* <LinkInput
|
|
44
|
+
* url={url}
|
|
45
|
+
* onChange={setUrl}
|
|
46
|
+
* />
|
|
47
|
+
*
|
|
48
|
+
* @preserve
|
|
49
|
+
*/
|
|
50
|
+
const LinkInput = (props) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const {
|
|
53
|
+
url = "",
|
|
54
|
+
onChange,
|
|
55
|
+
label = __("Link", "eightshift-ui-components"),
|
|
56
|
+
subtitle,
|
|
57
|
+
help,
|
|
58
|
+
actions,
|
|
59
|
+
placeholder = __("Type to search or enter URL", "eightshift-ui-components"),
|
|
60
|
+
icon = icons.globe,
|
|
61
|
+
removeIcon = icons.clearAlt,
|
|
62
|
+
disabled = false,
|
|
63
|
+
suggestionTypeIconOverride,
|
|
64
|
+
showSuggestionsWhenEmpty,
|
|
65
|
+
fetchSuggestions,
|
|
66
|
+
className,
|
|
67
|
+
hidden
|
|
68
|
+
} = props;
|
|
69
|
+
const canShowSuggestions = typeof fetchSuggestions !== "undefined";
|
|
70
|
+
const triggerRef = useRef(null);
|
|
71
|
+
const suggestionList = $f86e6c1ec7da6ebb$export$bc3384a35de93d66({
|
|
72
|
+
initialFilterText: url,
|
|
73
|
+
async load({ signal, filterText }) {
|
|
74
|
+
if (!canShowSuggestions) {
|
|
75
|
+
return {
|
|
76
|
+
items: []
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const items = await fetchSuggestions(filterText, signal);
|
|
80
|
+
return {
|
|
81
|
+
items: items ?? []
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const [shouldShowSuggestions, setShouldShowSuggestions] = useState(false);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
suggestionList.setFilterText(url);
|
|
88
|
+
if (!canShowSuggestions) {
|
|
89
|
+
setShouldShowSuggestions(false);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!showSuggestionsWhenEmpty && url.length < 1) {
|
|
93
|
+
setShouldShowSuggestions(false);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setShouldShowSuggestions(
|
|
97
|
+
!(showSuggestionsWhenEmpty !== true && url.trim().length < 3 || url.startsWith("#") || url.startsWith(":") || url.startsWith("mailto") || url.startsWith("tel") || url.startsWith("http") || url.startsWith("www"))
|
|
98
|
+
);
|
|
99
|
+
}, [url]);
|
|
100
|
+
if (hidden) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ jsxs(
|
|
104
|
+
$d01f2c01039c0eec$export$72b9695b8216309a,
|
|
105
|
+
{
|
|
106
|
+
items: suggestionList.items,
|
|
107
|
+
inputValue: suggestionList.filterText,
|
|
108
|
+
onInputChange: (value) => {
|
|
109
|
+
onChange({ url: value, isAnchor: value == null ? void 0 : value.includes("#") });
|
|
110
|
+
suggestionList.setFilterText(value);
|
|
111
|
+
},
|
|
112
|
+
allowsCustomValue: true,
|
|
113
|
+
allowsEmptyCollection: true,
|
|
114
|
+
isDisabled: disabled,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx(
|
|
117
|
+
BaseControl,
|
|
118
|
+
{
|
|
119
|
+
as: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
120
|
+
icon,
|
|
121
|
+
label,
|
|
122
|
+
subtitle,
|
|
123
|
+
actions,
|
|
124
|
+
labelAs: $01b77f81d0f07f68$export$b04be29aa201d4f5,
|
|
125
|
+
help,
|
|
126
|
+
children: /* @__PURE__ */ jsxs(
|
|
127
|
+
$a049562f99e7db0e$export$eb2fcfdbd7ba97d4,
|
|
128
|
+
{
|
|
129
|
+
className: "es:relative",
|
|
130
|
+
ref: triggerRef,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
$3985021b0ad6602f$export$f5b8910cec6cf069,
|
|
134
|
+
{
|
|
135
|
+
placeholder: disabled ? null : placeholder,
|
|
136
|
+
className: clsx(
|
|
137
|
+
"es:min-h-10 es:w-full es:rounded-lg es:border es:border-secondary-300 es:py-2 es:pl-2 es:pr-1 es:text-sm es:shadow-xs es:transition es:selection:bg-accent-500/20 es:selection:text-accent-950 es:bg-white",
|
|
138
|
+
"es:any-focus:outline-hidden",
|
|
139
|
+
"es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
140
|
+
"es:focus-visible:border-accent-500",
|
|
141
|
+
"es:inset-ring es:inset-ring-secondary-100",
|
|
142
|
+
"es:disabled:shadow-none! es:disabled:border-secondary-200 es:disabled:bg-secondary-50 es:disabled:text-secondary-500 es:disabled:cursor-default es:readonly:bg-secondary-50",
|
|
143
|
+
(url == null ? void 0 : url.length) > 0 && "es:pr-10",
|
|
144
|
+
className
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
AnimatedVisibility,
|
|
150
|
+
{
|
|
151
|
+
visible: !disabled && (url == null ? void 0 : url.length) > 0,
|
|
152
|
+
className: "es:absolute es:inset-y-1 es:right-1",
|
|
153
|
+
transition: "fade",
|
|
154
|
+
children: /* @__PURE__ */ jsxs(
|
|
155
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
156
|
+
{
|
|
157
|
+
slot: null,
|
|
158
|
+
onPress: () => {
|
|
159
|
+
suggestionList.setFilterText("");
|
|
160
|
+
onChange({ url: void 0, isAnchor: false });
|
|
161
|
+
},
|
|
162
|
+
className: "es:any-focus:outline-hidden",
|
|
163
|
+
children: [
|
|
164
|
+
!(shouldShowSuggestions && suggestionList.isLoading) && /* @__PURE__ */ jsx(Tooltip, { text: __("Clear", "eightshift-ui-components"), children: /* @__PURE__ */ jsx(
|
|
165
|
+
"div",
|
|
166
|
+
{
|
|
167
|
+
className: clsx(
|
|
168
|
+
"es:flex es:size-8 es:items-center es:justify-center es:rounded es:bg-white/85 es:text-secondary-600 es:backdrop-blur es:transition es:cursor-pointer",
|
|
169
|
+
"es:hover:bg-red-600/5 es:hover:text-red-600",
|
|
170
|
+
"es:icon:size-6"
|
|
171
|
+
),
|
|
172
|
+
children: removeIcon
|
|
173
|
+
}
|
|
174
|
+
) }),
|
|
175
|
+
shouldShowSuggestions && suggestionList.isLoading && /* @__PURE__ */ jsx("div", { className: "es:p-1.5", children: cloneElement(icons.loader, { className: "es:text-accent-600! es:stroke-2 es:motion-preset-spin es:motion-duration-1500" }) })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
canShowSuggestions && shouldShowSuggestions && /* @__PURE__ */ jsxs(
|
|
187
|
+
$07b14b47974efb58$export$5b6b19405a83ff9d,
|
|
188
|
+
{
|
|
189
|
+
"aria-label": __("URL suggestions", "eightshift-ui-components"),
|
|
190
|
+
className: ({ isEntering, isExiting }) => clsx(
|
|
191
|
+
"es:border es:rounded-lg es:border-secondary-300 es:bg-white es:shadow-lg es:outline-hidden es:min-w-72",
|
|
192
|
+
isEntering || !(suggestionList.isLoading || !shouldShowSuggestions) && "es:not-motion-reduce:motion-preset-slide-down-sm es:motion-reduce:motion-preset-fade es:motion-duration-300",
|
|
193
|
+
isExiting && "es:not-motion-reduce:motion-translate-y-out-[-2.5%] es:motion-opacity-out-0 es:motion-duration-200",
|
|
194
|
+
(suggestionList.isLoading || !shouldShowSuggestions) && "es:invisible"
|
|
195
|
+
),
|
|
196
|
+
offset: 3,
|
|
197
|
+
style: {
|
|
198
|
+
width: `${(_a = triggerRef.current) == null ? void 0 : _a.offsetWidth}px`
|
|
199
|
+
},
|
|
200
|
+
children: [
|
|
201
|
+
shouldShowSuggestions && !suggestionList.isLoading && suggestionList.items.length === 0 && /* @__PURE__ */ jsx(
|
|
202
|
+
RichLabel,
|
|
203
|
+
{
|
|
204
|
+
icon: icons.searchEmpty,
|
|
205
|
+
label: __("No results", "eightshift-ui-components"),
|
|
206
|
+
subtitle: __("Try a different search term.", "eightshift-ui-components"),
|
|
207
|
+
className: "es:min-h-12 es:p-2"
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
suggestionList.items.length > 0 && !suggestionList.isLoading && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
211
|
+
/* @__PURE__ */ jsx($eed445e0843c11d0$export$41f133550aa26f48, { className: "es:space-y-1 es:p-1", children: (item) => {
|
|
212
|
+
const {
|
|
213
|
+
label: title,
|
|
214
|
+
value: url2,
|
|
215
|
+
metadata: { subtype: rawSubtype }
|
|
216
|
+
} = item;
|
|
217
|
+
const subtype = rawSubtype ?? "page";
|
|
218
|
+
let typeIcon = icons.file;
|
|
219
|
+
if (subtype.toLowerCase() === "url") {
|
|
220
|
+
typeIcon = icons.externalLink;
|
|
221
|
+
} else if (subtype.toLowerCase() === "attachment") {
|
|
222
|
+
typeIcon = icons.file;
|
|
223
|
+
} else if (subtype.toLowerCase() === "category") {
|
|
224
|
+
typeIcon = icons.layoutAlt;
|
|
225
|
+
} else if (subtype.toLowerCase() === "internal") {
|
|
226
|
+
typeIcon = icons.anchor;
|
|
227
|
+
} else if (subtype.toLowerCase() === "eightshift-forms") {
|
|
228
|
+
typeIcon = icons.formAlt;
|
|
229
|
+
}
|
|
230
|
+
if (suggestionTypeIconOverride) {
|
|
231
|
+
const overrideIcon = suggestionTypeIconOverride(subtype);
|
|
232
|
+
if (overrideIcon) {
|
|
233
|
+
typeIcon = overrideIcon;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ jsx(
|
|
237
|
+
$eed445e0843c11d0$export$a11e76429ed99b4,
|
|
238
|
+
{
|
|
239
|
+
id: item.value,
|
|
240
|
+
className: clsx(
|
|
241
|
+
"es:rounded es:p-1 es:text-sm es:transition",
|
|
242
|
+
"es:hover:border-secondary-300 es:hover:bg-secondary-100",
|
|
243
|
+
"es:focus-visible:border-secondary-300 es:focus-visible:bg-secondary-100",
|
|
244
|
+
"selected:es:bg-accent-600/10 selected:es:text-accent-900 selected:focus-visible:es:bg-accent-600/15"
|
|
245
|
+
),
|
|
246
|
+
textValue: url2,
|
|
247
|
+
children: /* @__PURE__ */ jsx(
|
|
248
|
+
RichLabel,
|
|
249
|
+
{
|
|
250
|
+
icon: typeIcon,
|
|
251
|
+
label: title,
|
|
252
|
+
subtitle: url2 == null ? void 0 : url2.replace(location.origin, "").replace(/\/$/, ""),
|
|
253
|
+
noColor: true
|
|
254
|
+
}
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
} }),
|
|
259
|
+
/* @__PURE__ */ jsx(
|
|
260
|
+
Spacer,
|
|
261
|
+
{
|
|
262
|
+
border: true,
|
|
263
|
+
className: "es:opacity-40"
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ jsxs("div", { className: "es:flex es:flex-wrap es:items-center es:justify-end es:gap-x-3 es:gap-y-1.5 es:p-2 es:text-sm es:text-secondary-500", children: [
|
|
267
|
+
/* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
|
|
268
|
+
/* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↓" }),
|
|
269
|
+
/* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↑" }),
|
|
270
|
+
__("Navigate", "eightshift-ui-components")
|
|
271
|
+
] }),
|
|
272
|
+
/* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
|
|
273
|
+
/* @__PURE__ */ jsx("kbd", { className: "es:flex es:size-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:text-secondary-600", children: "↵" }),
|
|
274
|
+
__("Select", "eightshift-ui-components")
|
|
275
|
+
] }),
|
|
276
|
+
/* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-1", children: [
|
|
277
|
+
/* @__PURE__ */ jsx("kbd", { className: "es:flex es:h-4 es:items-center es:justify-center es:rounded es:bg-radial es:from-secondary-100 es:to-secondary-200 es:font-mono es:text-xs es:tracking-tighter es:px-0.5 es:text-secondary-600", children: "Esc" }),
|
|
278
|
+
__("Hide", "eightshift-ui-components")
|
|
279
|
+
] })
|
|
280
|
+
] })
|
|
281
|
+
] })
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
};
|
|
289
|
+
export {
|
|
290
|
+
LinkInput
|
|
291
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
3
|
+
import { icons } from "../../icons/icons.js";
|
|
4
|
+
import { pascalCase, upperFirst, camelCase } from "../../utilities/es-dash.js";
|
|
5
|
+
import { Menu, MenuItem } from "../menu/menu.js";
|
|
6
|
+
import { BaseControl } from "../base-control/base-control.js";
|
|
7
|
+
/**
|
|
8
|
+
* A component that can provide a 3x3 or a 2x2 grid of positions to pick from.
|
|
9
|
+
* Replaces the default Gutenberg `AlignmentMatrixControl`/`BlockAlignmentMatrixControl`/`BlockAlignmentMatrixToolbar`.
|
|
10
|
+
*
|
|
11
|
+
* @component
|
|
12
|
+
* @param {Object} props - Component props.
|
|
13
|
+
* @param {MatrixSize} [props.size='3x3'] - The size of the matrix. Can be either '3x3' or '2x2'.
|
|
14
|
+
* @param {string} props.value - The currently selected value.
|
|
15
|
+
* @param {Function} props.onChange - Function to run when the selection changes.
|
|
16
|
+
* @param {string} [props.tooltip='Position'] - Tooltip text to display on the trigger button.
|
|
17
|
+
* @param {string} [props.label] - Label to display.
|
|
18
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the button.
|
|
19
|
+
* @param {string} [props.subtitle] - Subtitle to display.
|
|
20
|
+
* @param {string} [props.popoverPosition='bottom'] - The position of the popover.
|
|
21
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
22
|
+
*
|
|
23
|
+
* @returns {JSX.Element} The MatrixAlign component.
|
|
24
|
+
*
|
|
25
|
+
* @typedef {'3x3' | '2x2'} MatrixSize
|
|
26
|
+
* @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
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <MatrixAlign
|
|
30
|
+
* size='3x3'
|
|
31
|
+
* value='top left'
|
|
32
|
+
* onChange={setAlignment}
|
|
33
|
+
* />
|
|
34
|
+
*
|
|
35
|
+
* @preserve
|
|
36
|
+
*/
|
|
37
|
+
const MatrixAlign = (props) => {
|
|
38
|
+
const {
|
|
39
|
+
size = "3x3",
|
|
40
|
+
value,
|
|
41
|
+
onChange,
|
|
42
|
+
tooltip = __("Position", "eightshift-ui-components"),
|
|
43
|
+
label,
|
|
44
|
+
icon,
|
|
45
|
+
subtitle,
|
|
46
|
+
"aria-label": ariaLabel,
|
|
47
|
+
hidden
|
|
48
|
+
} = props;
|
|
49
|
+
if (hidden) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const allSizeOptions = [
|
|
53
|
+
{
|
|
54
|
+
value: "top left",
|
|
55
|
+
label: __("Top-left", "eightshift-ui-components"),
|
|
56
|
+
availableOn: ["3x3", "2x2"]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: "top center",
|
|
60
|
+
label: __("Top-center", "eightshift-ui-components"),
|
|
61
|
+
availableOn: ["3x3"]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: "top right",
|
|
65
|
+
label: __("Top-right", "eightshift-ui-components"),
|
|
66
|
+
availableOn: ["3x3", "2x2"]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: "center left",
|
|
70
|
+
label: __("Center-left", "eightshift-ui-components"),
|
|
71
|
+
availableOn: ["3x3"]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: "center center",
|
|
75
|
+
label: __("Center", "eightshift-ui-components"),
|
|
76
|
+
availableOn: ["3x3"]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: "center right",
|
|
80
|
+
label: __("Center-right", "eightshift-ui-components"),
|
|
81
|
+
availableOn: ["3x3"]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "bottom left",
|
|
85
|
+
label: __("Bottom-left", "eightshift-ui-components"),
|
|
86
|
+
availableOn: ["3x3", "2x2"]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
value: "bottom center",
|
|
90
|
+
label: __("Bottom-center", "eightshift-ui-components"),
|
|
91
|
+
availableOn: ["3x3"]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: "bottom right",
|
|
95
|
+
label: __("Bottom-right", "eightshift-ui-components"),
|
|
96
|
+
availableOn: ["3x3", "2x2"]
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
const sizeOptions = allSizeOptions.filter(({ availableOn }) => availableOn.includes(size));
|
|
100
|
+
return /* @__PURE__ */ jsx(
|
|
101
|
+
BaseControl,
|
|
102
|
+
{
|
|
103
|
+
icon,
|
|
104
|
+
label,
|
|
105
|
+
subtitle,
|
|
106
|
+
inline: true,
|
|
107
|
+
children: /* @__PURE__ */ jsx(
|
|
108
|
+
Menu,
|
|
109
|
+
{
|
|
110
|
+
triggerIcon: icons[`position${size}${upperFirst(camelCase(value))}`],
|
|
111
|
+
triggerProps: { "aria-label": ariaLabel },
|
|
112
|
+
tooltip,
|
|
113
|
+
keepOpen: true,
|
|
114
|
+
children: sizeOptions.map(({ value: itemValue, label: label2 }) => {
|
|
115
|
+
var _a;
|
|
116
|
+
return /* @__PURE__ */ jsx(
|
|
117
|
+
MenuItem,
|
|
118
|
+
{
|
|
119
|
+
endIcon: (_a = icons) == null ? void 0 : _a[`position${size}${pascalCase(itemValue)}`],
|
|
120
|
+
selected: value === itemValue,
|
|
121
|
+
onClick: () => onChange(itemValue),
|
|
122
|
+
children: label2
|
|
123
|
+
},
|
|
124
|
+
itemValue
|
|
125
|
+
);
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
export {
|
|
133
|
+
MatrixAlign
|
|
134
|
+
};
|