@eightshift/ui-components 5.0.0 → 5.0.2
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-BpwTmkAe.js +185 -0
- package/dist/Collection-n5d0zIgb.js +2398 -0
- package/dist/Color-lVhk8V_G.js +2452 -0
- package/dist/ColorSwatch-DntWEAC3.js +64 -0
- package/dist/ComboBox-BJpTEATT.js +1915 -0
- package/dist/Dialog-O9uw63D7.js +2317 -0
- package/dist/FieldError-DHrSdE_Q.js +42 -0
- package/dist/FocusScope-BEPI2m7u.js +831 -0
- package/dist/Form-Cq3fu75_.js +5 -0
- package/dist/Group-DDPhPPTQ.js +48 -0
- package/dist/Heading-ba38ScjJ.js +16 -0
- package/dist/Hidden-rE6uR-lr.js +41 -0
- package/dist/Input-BmDS8Juy.js +133 -0
- package/dist/Label-JS_ob-kh.js +17 -0
- package/dist/List-CZMUbkFU.js +593 -0
- package/dist/ListBox-BTxlCGcc.js +664 -0
- package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
- package/dist/OverlayArrow-5aDgmImj.js +637 -0
- package/dist/RSPContexts-2lR5GG9p.js +14 -0
- package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
- package/dist/Separator-CaTBkETC.js +332 -0
- package/dist/Slider-C-S1oEH9.js +853 -0
- package/dist/Text-BuJgePCv.js +16 -0
- package/dist/VisuallyHidden-BYi0pekx.js +48 -0
- package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
- package/dist/assets/index.css +57 -0
- package/dist/assets/style-admin.css +5908 -0
- package/dist/assets/style-editor.css +5908 -0
- package/dist/assets/style.css +5914 -0
- package/dist/assets/wp-font-enhancements.css +8 -0
- package/dist/assets/wp-ui-enhancements.css +396 -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 +323 -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 +7320 -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 +284 -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 +582 -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 +1004 -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 +703 -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-BbYZoHvX.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 +30495 -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-BljRBEr_.js +44 -0
- package/dist/index-CFozsmNS.js +28321 -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-8DpK8fJl.js +46 -0
- package/dist/useButton-Bt3BffJm.js +50 -0
- package/dist/useEvent-ICdlokG-.js +23 -0
- package/dist/useFocusRing-Bv0UJQl8.js +107 -0
- package/dist/useFormReset-D2YaWRIA.js +22 -0
- package/dist/useFormValidation-Dy0PXJg5.js +224 -0
- package/dist/useHover-C2SkI1Fn.js +895 -0
- package/dist/useLabel-BPCd5c7-.js +27 -0
- package/dist/useLabels-B7-lUnAF.js +23 -0
- package/dist/useListState-DkyH7elT.js +168 -0
- package/dist/useLocalizedStringFormatter-C9GO0IDB.js +121 -0
- package/dist/useNumberField-CU1_u8ze.js +1215 -0
- package/dist/useNumberFormatter-CZ9QUnRt.js +13 -0
- package/dist/usePress-BrJylgPR.js +688 -0
- package/dist/useSingleSelectListState-C4sorv2p.js +38 -0
- package/dist/useToggle-CDa3YAZI.js +59 -0
- package/dist/useToggleState-ibcBUHnB.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-CZt7LCbO.js +403 -0
- package/dist/wp/wp-font-enhancements.js +1 -0
- package/dist/wp/wp-ui-enhancements.js +1 -0
- package/package.json +24 -24
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as Fragment$1 } from "react";
|
|
3
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
4
|
+
import { upperFirst } from "../../utilities/es-dash.js";
|
|
5
|
+
/**
|
|
6
|
+
* Component that renders a preview of the breakpoints to help users visualize the options they set.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @param {Object} props - Component props.
|
|
10
|
+
* @param {Object[]} [props.blocks] - Blocks to display.
|
|
11
|
+
* @param {string} [props.blocks[].width] - Current breakpoint width. Left-aligned with the block.
|
|
12
|
+
* @param {string} [props.blocks[].widthEnd] - Current breakpoint width. Right-aligned with the block.
|
|
13
|
+
* @param {string} [props.blocks[].breakpoint] - Breakpoint name.
|
|
14
|
+
* @param {string} [props.blocks[].value] - Current value at the breakpoint.
|
|
15
|
+
* @param {boolean} [props.blocks[].dotsStart=false] - If `true`, dots are displayed at the start of the block.
|
|
16
|
+
* @param {boolean} [props.blocks[].dotsEnd=false] - If `true`, dots are displayed at the end of the block.
|
|
17
|
+
* @param {boolean} [props.blocks[].active=false] - If `true`, the block is active.
|
|
18
|
+
* @param {boolean} [props.blocks[].alignEnd=false] - If `true`, the block is aligned to the end.
|
|
19
|
+
* @param {BreakpointColor} [props.blocks[].color] - Color of the block.
|
|
20
|
+
* @param {boolean} [props.dotsStart=false] - If `true`, dots are displayed at the start of the preview.
|
|
21
|
+
* @param {boolean} [props.dotsEnd=false] - If `true`, dots are displayed at the end of the preview.
|
|
22
|
+
* *
|
|
23
|
+
* @returns {JSX.Element} The BreakpointPreview component.
|
|
24
|
+
*
|
|
25
|
+
* @typedef {'blue' | 'green' | 'yellow' | 'red' | 'indigo' | 'orange' | 'cyan' | 'teal' | 'fuchsia' | 'black' | 'default'} BreakpointColor
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <BreakpointPreview
|
|
29
|
+
* blocks={[
|
|
30
|
+
* {
|
|
31
|
+
* breakpoint: 'Mobile',
|
|
32
|
+
* widthEnd: '480px',
|
|
33
|
+
* value: 'Regular',
|
|
34
|
+
* dotsStart: true,
|
|
35
|
+
* alignEnd: true,
|
|
36
|
+
* active: true,
|
|
37
|
+
* },
|
|
38
|
+
* {
|
|
39
|
+
* breakpoint: 'Default',
|
|
40
|
+
* value: 'Small',
|
|
41
|
+
* dotsEnd: true,
|
|
42
|
+
* },
|
|
43
|
+
* ]}
|
|
44
|
+
* />
|
|
45
|
+
*
|
|
46
|
+
* @preserve
|
|
47
|
+
*/
|
|
48
|
+
const BreakpointPreview = (props) => {
|
|
49
|
+
const { blocks: rawBlocks, dotsStart = false, dotsEnd = false } = props;
|
|
50
|
+
const blocks = rawBlocks.filter(Boolean);
|
|
51
|
+
if (!blocks || blocks.length < 1) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const hasActive = (blocks == null ? void 0 : blocks.some(({ active }) => active)) ?? false;
|
|
55
|
+
const activeColors = {
|
|
56
|
+
blue: {
|
|
57
|
+
text: "es:text-blue-500",
|
|
58
|
+
bg: "es:bg-blue-500"
|
|
59
|
+
},
|
|
60
|
+
green: {
|
|
61
|
+
text: "es:text-lime-500",
|
|
62
|
+
bg: "es:bg-lime-500"
|
|
63
|
+
},
|
|
64
|
+
yellow: {
|
|
65
|
+
text: "es:text-yellow-400",
|
|
66
|
+
bg: "es:bg-yellow-400"
|
|
67
|
+
},
|
|
68
|
+
red: {
|
|
69
|
+
text: "es:text-red-500",
|
|
70
|
+
bg: "es:bg-red-500"
|
|
71
|
+
},
|
|
72
|
+
indigo: {
|
|
73
|
+
text: "es:text-indigo-500",
|
|
74
|
+
bg: "es:bg-indigo-500"
|
|
75
|
+
},
|
|
76
|
+
orange: {
|
|
77
|
+
text: "es:text-orange-500",
|
|
78
|
+
bg: "es:bg-orange-500"
|
|
79
|
+
},
|
|
80
|
+
cyan: {
|
|
81
|
+
text: "es:text-cyan-500",
|
|
82
|
+
bg: "es:bg-cyan-500"
|
|
83
|
+
},
|
|
84
|
+
teal: {
|
|
85
|
+
text: "es:text-accent-500",
|
|
86
|
+
bg: "es:bg-accent-500"
|
|
87
|
+
},
|
|
88
|
+
fuchsia: {
|
|
89
|
+
text: "es:text-fuchsia-500",
|
|
90
|
+
bg: "es:bg-fuchsia-500"
|
|
91
|
+
},
|
|
92
|
+
black: {
|
|
93
|
+
text: "es:text-black",
|
|
94
|
+
bg: "es:bg-black"
|
|
95
|
+
},
|
|
96
|
+
default: {
|
|
97
|
+
text: "es:text-secondary-600",
|
|
98
|
+
bg: "es:bg-secondary-600"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return /* @__PURE__ */ jsxs("div", { className: clsx("es:mx-auto es:grid es:w-fit es:shrink-0 es:auto-cols-auto es:grid-rows-[auto_auto] es:gap-x-2 es:gap-y-0.5"), children: [
|
|
102
|
+
dotsStart && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
/* @__PURE__ */ jsx("div", { className: "es:row-start-1 es:flex es:shrink-0 es:translate-x-1 es:items-center es:gap-1 es:justify-self-end es:text-secondary-400", children: /* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-0.5 es:text-secondary-300", children: [
|
|
104
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
105
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
106
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" })
|
|
107
|
+
] }) }),
|
|
108
|
+
/* @__PURE__ */ jsx("div", { className: "es:row-start-2 es:size-px es:justify-self-end" })
|
|
109
|
+
] }),
|
|
110
|
+
blocks.map(({ width, widthEnd, breakpoint, value, dotsStart: dotsStart2 = false, dotsEnd: dotsEnd2 = false, active = false, alignEnd = false, color }, i) => {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
const activeTextColor = ((_a = activeColors == null ? void 0 : activeColors[color]) == null ? void 0 : _a.text) ?? activeColors.default.text;
|
|
113
|
+
const activeBgColor = ((_b = activeColors == null ? void 0 : activeColors[color]) == null ? void 0 : _b.bg) ?? activeColors.default.bg;
|
|
114
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
115
|
+
/* @__PURE__ */ jsxs("div", { className: "es:row-start-1 es:flex es:min-w-28 es:items-center es:gap-1 es:font-mono es:font-medium es:text-secondary-400", children: [
|
|
116
|
+
dotsStart2 && /* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:gap-0.5", active ? activeTextColor : "text-secondary-300"), children: [
|
|
117
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
118
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
119
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" })
|
|
120
|
+
] }),
|
|
121
|
+
width && /* @__PURE__ */ jsx("span", { children: width }),
|
|
122
|
+
/* @__PURE__ */ jsx("div", { className: clsx("es:grow es:rounded", active ? "es:h-0.5" : "es:h-px es:bg-secondary-300", active && activeBgColor) }),
|
|
123
|
+
widthEnd && /* @__PURE__ */ jsx("span", { children: widthEnd }),
|
|
124
|
+
dotsEnd2 && /* @__PURE__ */ jsxs("div", { className: clsx("es:flex es:gap-0.5", active ? activeTextColor : "es:text-secondary-300"), children: [
|
|
125
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
126
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
127
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" })
|
|
128
|
+
] })
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ jsxs("div", { className: "es:row-start-2 es:flex es:w-full es:min-w-28 es:flex-col es:items-start es:gap-1", children: [
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
"span",
|
|
133
|
+
{
|
|
134
|
+
className: clsx(
|
|
135
|
+
"es:rounded es:px-1 es:py-0.5",
|
|
136
|
+
hasActive && active && "es:text-white",
|
|
137
|
+
hasActive && active && activeBgColor,
|
|
138
|
+
hasActive && !active && "es:bg-secondary-200 es:text-secondary-500",
|
|
139
|
+
!hasActive && "es:bg-secondary-600 es:text-white",
|
|
140
|
+
alignEnd && "es:ml-auto"
|
|
141
|
+
),
|
|
142
|
+
children: upperFirst(breakpoint)
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
value && /* @__PURE__ */ jsx("span", { className: clsx("es:-mt-0.5 es:px-1", active ? "es:text-secondary-400" : "es:text-secondary-400", alignEnd && "es:ml-auto"), children: value })
|
|
146
|
+
] })
|
|
147
|
+
] }, i);
|
|
148
|
+
}),
|
|
149
|
+
dotsEnd && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
150
|
+
/* @__PURE__ */ jsx("div", { className: "es:row-start-1 es:flex es:shrink-0 es:-translate-x-1 es:items-center es:gap-1 es:font-mono es:font-medium es:text-secondary-400", children: /* @__PURE__ */ jsxs("div", { className: "es:flex es:gap-0.5 es:text-secondary-300", children: [
|
|
151
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
152
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" }),
|
|
153
|
+
/* @__PURE__ */ jsx("div", { className: "es:size-0.5 es:rounded es:bg-current" })
|
|
154
|
+
] }) }),
|
|
155
|
+
/* @__PURE__ */ jsx("div", { className: "es:row-start-2 es:size-px" })
|
|
156
|
+
] })
|
|
157
|
+
] });
|
|
158
|
+
};
|
|
159
|
+
export {
|
|
160
|
+
BreakpointPreview
|
|
161
|
+
};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../../Button-BpwTmkAe.js";
|
|
3
|
+
import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, a as $64fa3d84918910a7$export$29f1550f4b0d4415, b as $64fa3d84918910a7$export$4d86445c2cf5e3, d as $3ef42575df84b30b$export$9d1611c77c2fe928, l as $df56164dff5785e2$export$4338b53315abf666 } from "../../utils-CZt7LCbO.js";
|
|
4
|
+
import { $ as $9bf71ea28793e738$export$c5251b9e124bf29 } from "../../FocusScope-BEPI2m7u.js";
|
|
5
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
|
|
6
|
+
import React__default, { useState, useRef, forwardRef, createContext } from "react";
|
|
7
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-BbYZoHvX.js";
|
|
8
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
9
|
+
import { c as cva } from "../../index-BljRBEr_.js";
|
|
10
|
+
import { Tooltip } from "../tooltip/tooltip.js";
|
|
11
|
+
import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
|
|
12
|
+
function $2680b1829e803644$export$fa142eb1681c520(props, ref) {
|
|
13
|
+
const { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, orientation = "horizontal" } = props;
|
|
14
|
+
let [isInToolbar, setInToolbar] = useState(false);
|
|
15
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
|
16
|
+
var _ref_current_parentElement;
|
|
17
|
+
setInToolbar(!!(ref.current && ((_ref_current_parentElement = ref.current.parentElement) === null || _ref_current_parentElement === void 0 ? void 0 : _ref_current_parentElement.closest('[role="toolbar"]'))));
|
|
18
|
+
});
|
|
19
|
+
const { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
20
|
+
const shouldReverse = direction === "rtl" && orientation === "horizontal";
|
|
21
|
+
let focusManager = $9bf71ea28793e738$export$c5251b9e124bf29(ref);
|
|
22
|
+
const onKeyDown = (e) => {
|
|
23
|
+
if (!e.currentTarget.contains(e.target)) return;
|
|
24
|
+
if (orientation === "horizontal" && e.key === "ArrowRight" || orientation === "vertical" && e.key === "ArrowDown") {
|
|
25
|
+
if (shouldReverse) focusManager.focusPrevious();
|
|
26
|
+
else focusManager.focusNext();
|
|
27
|
+
} else if (orientation === "horizontal" && e.key === "ArrowLeft" || orientation === "vertical" && e.key === "ArrowUp") {
|
|
28
|
+
if (shouldReverse) focusManager.focusNext();
|
|
29
|
+
else focusManager.focusPrevious();
|
|
30
|
+
} else if (e.key === "Tab") {
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
lastFocused.current = document.activeElement;
|
|
33
|
+
if (e.shiftKey) focusManager.focusFirst();
|
|
34
|
+
else focusManager.focusLast();
|
|
35
|
+
return;
|
|
36
|
+
} else
|
|
37
|
+
return;
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
};
|
|
41
|
+
const lastFocused = useRef(null);
|
|
42
|
+
const onBlur = (e) => {
|
|
43
|
+
if (!e.currentTarget.contains(e.relatedTarget) && !lastFocused.current) lastFocused.current = e.target;
|
|
44
|
+
};
|
|
45
|
+
const onFocus = (e) => {
|
|
46
|
+
var _ref_current;
|
|
47
|
+
if (lastFocused.current && !e.currentTarget.contains(e.relatedTarget) && ((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(e.target))) {
|
|
48
|
+
var _lastFocused_current;
|
|
49
|
+
(_lastFocused_current = lastFocused.current) === null || _lastFocused_current === void 0 ? void 0 : _lastFocused_current.focus();
|
|
50
|
+
lastFocused.current = null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
toolbarProps: {
|
|
55
|
+
...$65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
|
|
56
|
+
labelable: true
|
|
57
|
+
}),
|
|
58
|
+
role: !isInToolbar ? "toolbar" : "group",
|
|
59
|
+
"aria-orientation": orientation,
|
|
60
|
+
"aria-label": ariaLabel,
|
|
61
|
+
"aria-labelledby": ariaLabel == null ? ariaLabelledBy : void 0,
|
|
62
|
+
onKeyDownCapture: !isInToolbar ? onKeyDown : void 0,
|
|
63
|
+
onFocusCapture: !isInToolbar ? onFocus : void 0,
|
|
64
|
+
onBlurCapture: !isInToolbar ? onBlur : void 0
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const $13c3c67164f4d5be$export$6311e7ab80ef752f = /* @__PURE__ */ createContext({});
|
|
69
|
+
const $13c3c67164f4d5be$export$4c260019440d418f = /* @__PURE__ */ forwardRef(function Toolbar(props, ref) {
|
|
70
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $13c3c67164f4d5be$export$6311e7ab80ef752f);
|
|
71
|
+
let { toolbarProps } = $2680b1829e803644$export$fa142eb1681c520(props, ref);
|
|
72
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
73
|
+
...props,
|
|
74
|
+
values: {
|
|
75
|
+
orientation: props.orientation || "horizontal"
|
|
76
|
+
},
|
|
77
|
+
defaultClassName: "react-aria-Toolbar"
|
|
78
|
+
});
|
|
79
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
80
|
+
delete DOMProps.id;
|
|
81
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
82
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(toolbarProps, DOMProps),
|
|
83
|
+
...renderProps,
|
|
84
|
+
ref,
|
|
85
|
+
slot: props.slot || void 0,
|
|
86
|
+
"data-orientation": props.orientation || "horizontal"
|
|
87
|
+
}, renderProps.children);
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* A simple button component.
|
|
91
|
+
*
|
|
92
|
+
* @component
|
|
93
|
+
* @param {Object} props - Component props.
|
|
94
|
+
* @param {JSX.Element} [props.icon] - Icon to display within the button.
|
|
95
|
+
* @param {ButtonSize} [props.size='default'] - The size of the button.
|
|
96
|
+
* @param {ButtonType} [props.type='default'] - The type of the button.
|
|
97
|
+
* @param {boolean} [props.disabled] - If `true`, the button is disabled.
|
|
98
|
+
* @param {string} [props.className] - Classes to pass to the button.
|
|
99
|
+
* @param {string|boolean} [props.tooltip] - Tooltip text to display on hover. If set to `true` and an `aria-label` is not provided, the tooltip text will be used as the `aria-label`.
|
|
100
|
+
* @param {Function} [props.onPress] - Function to run when the button is pressed.
|
|
101
|
+
* @param {React.Ref} [props.forwardedRef] - Ref to forward to the button. Use the same as the `ref` prop.
|
|
102
|
+
* @param {string} [props.wrapperClassName] - Classes to pass to the tooltip wrapper.
|
|
103
|
+
* @param {Object} [props.tooltipProps] - Props to pass to the tooltip.
|
|
104
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
105
|
+
*
|
|
106
|
+
* @returns {JSX.Element} The Button component.
|
|
107
|
+
*
|
|
108
|
+
* @typedef {'small' | 'default' | 'large'} ButtonSize
|
|
109
|
+
* @typedef {'default' | 'selected' | 'ghost' | 'danger' | 'dangerGhost'} ButtonType
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* <Button onPress={() => console.log('Hi!')} icon={icons.myIcon} />
|
|
113
|
+
*
|
|
114
|
+
* <Button onPress={() => console.log('Hi!')} icon={icons.myIcon}>My button</Button>
|
|
115
|
+
*
|
|
116
|
+
* @preserve
|
|
117
|
+
*/
|
|
118
|
+
const Button = (props) => {
|
|
119
|
+
const {
|
|
120
|
+
children,
|
|
121
|
+
icon,
|
|
122
|
+
size = "default",
|
|
123
|
+
type = "default",
|
|
124
|
+
disabled,
|
|
125
|
+
className,
|
|
126
|
+
tooltip: rawTooltip,
|
|
127
|
+
onPress,
|
|
128
|
+
forwardedRef,
|
|
129
|
+
wrapperClassName,
|
|
130
|
+
tooltipProps,
|
|
131
|
+
"aria-label": ariaLabel = typeof children === "string" ? children : __("Menu item", "eightshift-ui-components"),
|
|
132
|
+
hidden,
|
|
133
|
+
...other
|
|
134
|
+
} = props;
|
|
135
|
+
let tooltip = rawTooltip;
|
|
136
|
+
if (rawTooltip === true && (ariaLabel == null ? void 0 : ariaLabel.length) > 0) {
|
|
137
|
+
tooltip = ariaLabel;
|
|
138
|
+
}
|
|
139
|
+
const objRef = $df56164dff5785e2$export$4338b53315abf666(forwardedRef);
|
|
140
|
+
if (hidden) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const componentClasses = cva(
|
|
144
|
+
[
|
|
145
|
+
"es:flex es:items-center es:gap-1",
|
|
146
|
+
"es:transition es:duration-300 es:border es:text-sm",
|
|
147
|
+
"es:any-focus:outline-hidden es:focus-visible:z-10",
|
|
148
|
+
"es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
149
|
+
"es:focus-visible:border-accent-500",
|
|
150
|
+
"es:btn-group-mid:rounded-none",
|
|
151
|
+
"es:btn-group-h-start:rounded-r-none es:btn-group-v-start:rounded-b-none",
|
|
152
|
+
"es:btn-group-h-end:rounded-l-none es:btn-group-v-end:rounded-t-none",
|
|
153
|
+
"es:not-disabled:cursor-pointer",
|
|
154
|
+
"es:shrink-0",
|
|
155
|
+
icon && children ? "es:justify-start" : "es:justify-center",
|
|
156
|
+
className
|
|
157
|
+
],
|
|
158
|
+
{
|
|
159
|
+
variants: {
|
|
160
|
+
size: {
|
|
161
|
+
small: "es:icon:size-4.5 es:rounded-md",
|
|
162
|
+
default: "es:icon:size-5.5 es:rounded-lg",
|
|
163
|
+
large: "es:icon:size-6 es:rounded-lg"
|
|
164
|
+
},
|
|
165
|
+
type: {
|
|
166
|
+
default: "es:bg-radial-[at_50%_125%] es:inset-ring es:inset-shadow-xs",
|
|
167
|
+
selected: "es:bg-radial-[at_50%_125%] es:inset-ring es:inset-shadow-xs",
|
|
168
|
+
danger: "es:bg-radial-[at_50%_125%] es:inset-ring es:inset-shadow-xs",
|
|
169
|
+
ghost: "es:border-transparent es:text-secondary-700 es:not-disabled:hover:bg-secondary-100 es:disabled:border-transparent!",
|
|
170
|
+
dangerGhost: [
|
|
171
|
+
"es:border-transparent es:text-red-600",
|
|
172
|
+
"es:not-disabled:hover:bg-red-500/5",
|
|
173
|
+
"es:focus-visible:text-red-700",
|
|
174
|
+
"es:focus-visible:ring-red-500/30 es:focus-visible:border-red-600 es:focus-visible:inset-ring-red-100",
|
|
175
|
+
"es:disabled:border-transparent!"
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
compoundVariants: [
|
|
180
|
+
// Styles.
|
|
181
|
+
{
|
|
182
|
+
type: "default",
|
|
183
|
+
disabled: false,
|
|
184
|
+
class: [
|
|
185
|
+
"es:text-black",
|
|
186
|
+
"es:from-secondary-50 es:to-white",
|
|
187
|
+
"es:border-secondary-300",
|
|
188
|
+
"es:inset-ring-secondary-100",
|
|
189
|
+
"es:inset-shadow-secondary-100/50",
|
|
190
|
+
"es:shadow-xs",
|
|
191
|
+
"es:hover:inset-shadow-secondary-100 es:hover:to-secondary-100 es:hover:inset-ring-secondary-100",
|
|
192
|
+
"es:hover:text-accent-950",
|
|
193
|
+
"es:focus-visible:text-accent-950"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: "selected",
|
|
198
|
+
disabled: false,
|
|
199
|
+
class: [
|
|
200
|
+
"es:text-white",
|
|
201
|
+
"es:from-accent-500 es:to-accent-600",
|
|
202
|
+
"es:border-accent-700",
|
|
203
|
+
"es:inset-ring es:inset-ring-accent-600",
|
|
204
|
+
"es:inset-shadow-xs es:inset-shadow-accent-400/75",
|
|
205
|
+
"es:focus-visible:border-accent-700",
|
|
206
|
+
"es:focus-visible:inset-ring es:focus-visible:inset-ring-accent-600",
|
|
207
|
+
"es:focus-visible:inset-shadow-xs es:focus-visible:inset-shadow-accent-400",
|
|
208
|
+
"es:shadow es:shadow-accent-600/30"
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
type: "danger",
|
|
213
|
+
disabled: false,
|
|
214
|
+
class: [
|
|
215
|
+
"es:text-red-800",
|
|
216
|
+
"es:from-red-50/75 es:to-white",
|
|
217
|
+
"es:border-red-600/50",
|
|
218
|
+
"es:inset-ring-red-100",
|
|
219
|
+
"es:inset-shadow-red-50",
|
|
220
|
+
"es:hover:inset-shadow-red-100 es:hover:inset-ring-red-100 es:hover:text-red-800 es:hover:border-red-600",
|
|
221
|
+
"es:focus-visible:text-red-900",
|
|
222
|
+
"es:focus-visible:ring-red-500/30 es:focus-visible:border-red-600 es:focus-visible:inset-ring-red-100",
|
|
223
|
+
"es:shadow"
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
disabled: true,
|
|
228
|
+
class: "es:disabled:border-zinc-300 es:disabled:text-zinc-400 es:border es:shadow-none es:disabled:inset-shadow-transparent es:disabled:inset-ring-0"
|
|
229
|
+
},
|
|
230
|
+
// Sizes.
|
|
231
|
+
{
|
|
232
|
+
size: "small",
|
|
233
|
+
iconOnly: false,
|
|
234
|
+
class: "es:h-7 es:min-w-7"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
size: "small",
|
|
238
|
+
iconOnly: true,
|
|
239
|
+
class: "es:size-7"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
size: "small",
|
|
243
|
+
hasIcon: false,
|
|
244
|
+
iconOnly: false,
|
|
245
|
+
class: "es:px-2"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
size: "small",
|
|
249
|
+
hasIcon: true,
|
|
250
|
+
iconOnly: false,
|
|
251
|
+
class: "es:px-1"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
size: "default",
|
|
255
|
+
iconOnly: false,
|
|
256
|
+
class: "es:h-9 es:min-w-9"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
size: "default",
|
|
260
|
+
iconOnly: true,
|
|
261
|
+
class: "es:size-9"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
size: "default",
|
|
265
|
+
hasIcon: false,
|
|
266
|
+
iconOnly: false,
|
|
267
|
+
class: "es:px-2"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
size: "default",
|
|
271
|
+
hasIcon: true,
|
|
272
|
+
iconOnly: false,
|
|
273
|
+
class: "es:px-1.5"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
size: "large",
|
|
277
|
+
iconOnly: false,
|
|
278
|
+
class: "es:h-10 es:min-w-10"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
size: "large",
|
|
282
|
+
iconOnly: true,
|
|
283
|
+
class: "es:size-10"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
size: "large",
|
|
287
|
+
hasIcon: false,
|
|
288
|
+
iconOnly: false,
|
|
289
|
+
class: "es:px-4"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
size: "large",
|
|
293
|
+
hasIcon: true,
|
|
294
|
+
iconOnly: false,
|
|
295
|
+
class: "es:px-2"
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
defaultVariants: {
|
|
299
|
+
disabled: false
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
const component = /* @__PURE__ */ jsxs(
|
|
304
|
+
$d2b4bc8c273e7be6$export$353f5b6fc5456de1,
|
|
305
|
+
{
|
|
306
|
+
onPress,
|
|
307
|
+
isDisabled: disabled,
|
|
308
|
+
className: componentClasses({
|
|
309
|
+
disabled,
|
|
310
|
+
hasIcon: Boolean(icon),
|
|
311
|
+
iconOnly: Boolean(icon && !children),
|
|
312
|
+
size,
|
|
313
|
+
type
|
|
314
|
+
}),
|
|
315
|
+
ref: objRef,
|
|
316
|
+
"aria-label": ariaLabel,
|
|
317
|
+
...other,
|
|
318
|
+
children: [
|
|
319
|
+
icon,
|
|
320
|
+
children
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
if (!tooltip) {
|
|
325
|
+
return component;
|
|
326
|
+
}
|
|
327
|
+
return /* @__PURE__ */ jsx(
|
|
328
|
+
Tooltip,
|
|
329
|
+
{
|
|
330
|
+
text: tooltip,
|
|
331
|
+
wrapperClassName,
|
|
332
|
+
...tooltipProps,
|
|
333
|
+
children: component
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* A wrapper for `Button` or `ToggleButton` components that visually groups them and ensures proper keyboard navigation.
|
|
339
|
+
*
|
|
340
|
+
* **Note**: Only intended for horizontal groups of buttons that don't wrap.
|
|
341
|
+
*
|
|
342
|
+
* @component
|
|
343
|
+
* @param {Object} props - Component props.
|
|
344
|
+
* @param {string} [props.className] - Classes to pass to the button group container.
|
|
345
|
+
* @param {boolean} [props.vertical] - If `true`, the buttons are displayed vertically.
|
|
346
|
+
* @param {ButtonGroupType} [props.type='segmented'] - The way the button group is laid out.
|
|
347
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
348
|
+
*
|
|
349
|
+
* @returns {JSX.Element} The ButtonGroup component.
|
|
350
|
+
*
|
|
351
|
+
* @typedef {'segmented' | 'split'} ButtonGroupType
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* <ButtonGroup>
|
|
355
|
+
* <Button />
|
|
356
|
+
* <Button />
|
|
357
|
+
* <Button />
|
|
358
|
+
* </ButtonGroup>
|
|
359
|
+
*
|
|
360
|
+
* @preserve
|
|
361
|
+
*/
|
|
362
|
+
const ButtonGroup = ({ children, className, vertical, hidden, type = "segmented", ...rest }) => {
|
|
363
|
+
if (hidden) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
return /* @__PURE__ */ jsx(
|
|
367
|
+
$13c3c67164f4d5be$export$4c260019440d418f,
|
|
368
|
+
{
|
|
369
|
+
className: clsx(
|
|
370
|
+
"es:flex",
|
|
371
|
+
vertical && "es:flex-col",
|
|
372
|
+
type === "segmented" && vertical && "es-button-group-v es:-space-y-px!",
|
|
373
|
+
type === "segmented" && !vertical && "es-button-group-h es:-space-x-px!",
|
|
374
|
+
type === "split" && vertical && "es:space-y-1",
|
|
375
|
+
type === "split" && !vertical && "es:space-x-1.5",
|
|
376
|
+
className
|
|
377
|
+
),
|
|
378
|
+
orientation: vertical ? "vertical" : "horizontal",
|
|
379
|
+
...rest,
|
|
380
|
+
children
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
};
|
|
384
|
+
export {
|
|
385
|
+
Button,
|
|
386
|
+
ButtonGroup
|
|
387
|
+
};
|