@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,703 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c as $880e95eb8b93ba9a$export$ecf600387e221c37, i as $ae20dd8cbca75726$export$d6daf82dcd84e87c, d as $e1995378a142960e$export$18af5c7a9e9b3664, f as $e1995378a142960e$export$fb8073518f34e6ec, g as $7135fc7d473fd974$export$4feb769f8ddf26c5, j as $7135fc7d473fd974$export$a164736487e3f0ae, e as $e1995378a142960e$export$bf788dd355e3a401, k as $7135fc7d473fd974$export$90e00781bc59d8f9 } from "../../Collection-n5d0zIgb.js";
|
|
3
|
+
import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, d as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, l as $df56164dff5785e2$export$4338b53315abf666, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, a as $64fa3d84918910a7$export$29f1550f4b0d4415, $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../../utils-CZt7LCbO.js";
|
|
4
|
+
import { $ as $f39a9eba43920ace$export$86427a43e3e48ebb } from "../../Hidden-rE6uR-lr.js";
|
|
5
|
+
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
|
|
6
|
+
import { b as $cdc5a6778b766db2$export$a9d04c5684123369 } from "../../useListState-DkyH7elT.js";
|
|
7
|
+
import React__default, { useState, useMemo, useRef, useEffect, forwardRef, useContext, createContext, isValidElement, useId, cloneElement } from "react";
|
|
8
|
+
import { a as $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 } from "../../usePress-BrJylgPR.js";
|
|
9
|
+
import { a as $f645667febf57a63$export$4c014de7c8940b4c, $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-C2SkI1Fn.js";
|
|
10
|
+
import { $ as $313b98861ee5dd6c$export$d6875122194c7b44 } from "../../useLabels-B7-lUnAF.js";
|
|
11
|
+
import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "../../FocusScope-BEPI2m7u.js";
|
|
12
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-BbYZoHvX.js";
|
|
13
|
+
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-Bv0UJQl8.js";
|
|
14
|
+
import { $ as $a0d645289fe9b86b$export$e7f05e985daf4b5f } from "../../useSingleSelectListState-C4sorv2p.js";
|
|
15
|
+
import { _ as __, s as sprintf } from "../../default-i18n-CT_oS1Fy.js";
|
|
16
|
+
import { c as clsx } from "../../lite-DVmmD_-j.js";
|
|
17
|
+
import { c as cva } from "../../index-BljRBEr_.js";
|
|
18
|
+
import { Notice } from "../notice/notice.js";
|
|
19
|
+
import { RichLabel } from "../rich-label/rich-label.js";
|
|
20
|
+
function $83013635b024ae3d$export$eac1895992b9f3d6(ref, options) {
|
|
21
|
+
let isDisabled = options === null || options === void 0 ? void 0 : options.isDisabled;
|
|
22
|
+
let [hasTabbableChild, setHasTabbableChild] = useState(false);
|
|
23
|
+
$f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
|
|
24
|
+
if ((ref === null || ref === void 0 ? void 0 : ref.current) && !isDisabled) {
|
|
25
|
+
let update = () => {
|
|
26
|
+
if (ref.current) {
|
|
27
|
+
let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ref.current, {
|
|
28
|
+
tabbable: true
|
|
29
|
+
});
|
|
30
|
+
setHasTabbableChild(!!walker.nextNode());
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
update();
|
|
34
|
+
let observer = new MutationObserver(update);
|
|
35
|
+
observer.observe(ref.current, {
|
|
36
|
+
subtree: true,
|
|
37
|
+
childList: true,
|
|
38
|
+
attributes: true,
|
|
39
|
+
attributeFilter: [
|
|
40
|
+
"tabIndex",
|
|
41
|
+
"disabled"
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
observer.disconnect();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return isDisabled ? false : hasTabbableChild;
|
|
50
|
+
}
|
|
51
|
+
const $99b62ae3ff97ec45$export$c5f62239608282b6 = /* @__PURE__ */ new WeakMap();
|
|
52
|
+
function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
|
|
53
|
+
if (!state)
|
|
54
|
+
return "";
|
|
55
|
+
if (typeof key === "string") key = key.replace(/\s+/g, "");
|
|
56
|
+
let baseId = $99b62ae3ff97ec45$export$c5f62239608282b6.get(state);
|
|
57
|
+
return `${baseId}-${role}-${key}`;
|
|
58
|
+
}
|
|
59
|
+
function $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
60
|
+
let { key, isDisabled: propsDisabled, shouldSelectOnPressUp } = props;
|
|
61
|
+
let { selectionManager: manager, selectedKey } = state;
|
|
62
|
+
let isSelected = key === selectedKey;
|
|
63
|
+
let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
|
|
64
|
+
let { itemProps, isPressed } = $880e95eb8b93ba9a$export$ecf600387e221c37({
|
|
65
|
+
selectionManager: manager,
|
|
66
|
+
key,
|
|
67
|
+
ref,
|
|
68
|
+
isDisabled,
|
|
69
|
+
shouldSelectOnPressUp,
|
|
70
|
+
linkBehavior: "selection"
|
|
71
|
+
});
|
|
72
|
+
let tabId = $99b62ae3ff97ec45$export$567fc7097e064344(state, key, "tab");
|
|
73
|
+
let tabPanelId = $99b62ae3ff97ec45$export$567fc7097e064344(state, key, "tabpanel");
|
|
74
|
+
let { tabIndex } = itemProps;
|
|
75
|
+
let item = state.collection.getItem(key);
|
|
76
|
+
let domProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(item === null || item === void 0 ? void 0 : item.props, {
|
|
77
|
+
labelable: true
|
|
78
|
+
});
|
|
79
|
+
delete domProps.id;
|
|
80
|
+
let linkProps = $ea8dcbcb9ea1b556$export$7e924b3091a3bd18(item === null || item === void 0 ? void 0 : item.props);
|
|
81
|
+
let { focusableProps } = $f645667febf57a63$export$4c014de7c8940b4c({
|
|
82
|
+
isDisabled
|
|
83
|
+
}, ref);
|
|
84
|
+
return {
|
|
85
|
+
tabProps: $3ef42575df84b30b$export$9d1611c77c2fe928(domProps, focusableProps, linkProps, itemProps, {
|
|
86
|
+
id: tabId,
|
|
87
|
+
"aria-selected": isSelected,
|
|
88
|
+
"aria-disabled": isDisabled || void 0,
|
|
89
|
+
"aria-controls": isSelected ? tabPanelId : void 0,
|
|
90
|
+
tabIndex: isDisabled ? void 0 : tabIndex,
|
|
91
|
+
role: "tab"
|
|
92
|
+
}),
|
|
93
|
+
isSelected,
|
|
94
|
+
isDisabled,
|
|
95
|
+
isPressed
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref) {
|
|
99
|
+
let tabIndex = $83013635b024ae3d$export$eac1895992b9f3d6(ref) ? void 0 : 0;
|
|
100
|
+
var _props_id;
|
|
101
|
+
const id = $99b62ae3ff97ec45$export$567fc7097e064344(state, (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : state === null || state === void 0 ? void 0 : state.selectedKey, "tabpanel");
|
|
102
|
+
const tabPanelProps = $313b98861ee5dd6c$export$d6875122194c7b44({
|
|
103
|
+
...props,
|
|
104
|
+
id,
|
|
105
|
+
"aria-labelledby": $99b62ae3ff97ec45$export$567fc7097e064344(state, state === null || state === void 0 ? void 0 : state.selectedKey, "tab")
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
tabPanelProps: $3ef42575df84b30b$export$9d1611c77c2fe928(tabPanelProps, {
|
|
109
|
+
tabIndex,
|
|
110
|
+
role: "tabpanel",
|
|
111
|
+
"aria-describedby": props["aria-describedby"],
|
|
112
|
+
"aria-details": props["aria-details"]
|
|
113
|
+
})
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
class $bfc6f2d60b8a4c40$export$15010ca3c1abe90b {
|
|
117
|
+
getKeyLeftOf(key) {
|
|
118
|
+
if (this.flipDirection) return this.getNextKey(key);
|
|
119
|
+
return this.getPreviousKey(key);
|
|
120
|
+
}
|
|
121
|
+
getKeyRightOf(key) {
|
|
122
|
+
if (this.flipDirection) return this.getPreviousKey(key);
|
|
123
|
+
return this.getNextKey(key);
|
|
124
|
+
}
|
|
125
|
+
isDisabled(key) {
|
|
126
|
+
var _this_collection_getItem_props, _this_collection_getItem;
|
|
127
|
+
return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
|
|
128
|
+
}
|
|
129
|
+
getFirstKey() {
|
|
130
|
+
let key = this.collection.getFirstKey();
|
|
131
|
+
if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
|
|
132
|
+
return key;
|
|
133
|
+
}
|
|
134
|
+
getLastKey() {
|
|
135
|
+
let key = this.collection.getLastKey();
|
|
136
|
+
if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
|
|
137
|
+
return key;
|
|
138
|
+
}
|
|
139
|
+
getKeyAbove(key) {
|
|
140
|
+
if (this.tabDirection) return null;
|
|
141
|
+
return this.getPreviousKey(key);
|
|
142
|
+
}
|
|
143
|
+
getKeyBelow(key) {
|
|
144
|
+
if (this.tabDirection) return null;
|
|
145
|
+
return this.getNextKey(key);
|
|
146
|
+
}
|
|
147
|
+
getNextKey(startKey) {
|
|
148
|
+
let key = startKey;
|
|
149
|
+
do {
|
|
150
|
+
key = this.collection.getKeyAfter(key);
|
|
151
|
+
if (key == null) key = this.collection.getFirstKey();
|
|
152
|
+
} while (key != null && this.isDisabled(key));
|
|
153
|
+
return key;
|
|
154
|
+
}
|
|
155
|
+
getPreviousKey(startKey) {
|
|
156
|
+
let key = startKey;
|
|
157
|
+
do {
|
|
158
|
+
key = this.collection.getKeyBefore(key);
|
|
159
|
+
if (key == null) key = this.collection.getLastKey();
|
|
160
|
+
} while (key != null && this.isDisabled(key));
|
|
161
|
+
return key;
|
|
162
|
+
}
|
|
163
|
+
constructor(collection, direction, orientation, disabledKeys = /* @__PURE__ */ new Set()) {
|
|
164
|
+
this.collection = collection;
|
|
165
|
+
this.flipDirection = direction === "rtl" && orientation === "horizontal";
|
|
166
|
+
this.disabledKeys = disabledKeys;
|
|
167
|
+
this.tabDirection = orientation === "horizontal";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function $58d314389b21fa3f$export$773e389e644c5874(props, state, ref) {
|
|
171
|
+
let { orientation = "horizontal", keyboardActivation = "automatic" } = props;
|
|
172
|
+
let { collection, selectionManager: manager, disabledKeys } = state;
|
|
173
|
+
let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
174
|
+
let delegate = useMemo(() => new $bfc6f2d60b8a4c40$export$15010ca3c1abe90b(collection, direction, orientation, disabledKeys), [
|
|
175
|
+
collection,
|
|
176
|
+
disabledKeys,
|
|
177
|
+
orientation,
|
|
178
|
+
direction
|
|
179
|
+
]);
|
|
180
|
+
let { collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
|
|
181
|
+
ref,
|
|
182
|
+
selectionManager: manager,
|
|
183
|
+
keyboardDelegate: delegate,
|
|
184
|
+
selectOnFocus: keyboardActivation === "automatic",
|
|
185
|
+
disallowEmptySelection: true,
|
|
186
|
+
scrollRef: ref,
|
|
187
|
+
linkBehavior: "selection"
|
|
188
|
+
});
|
|
189
|
+
let tabsId = $bdb11010cef70236$export$f680877a34711e37();
|
|
190
|
+
$99b62ae3ff97ec45$export$c5f62239608282b6.set(state, tabsId);
|
|
191
|
+
let tabListLabelProps = $313b98861ee5dd6c$export$d6875122194c7b44({
|
|
192
|
+
...props,
|
|
193
|
+
id: tabsId
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
tabListProps: {
|
|
197
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(collectionProps, tabListLabelProps),
|
|
198
|
+
role: "tablist",
|
|
199
|
+
"aria-orientation": orientation,
|
|
200
|
+
tabIndex: void 0
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function $76f919a04c5a7d14$export$4ba071daf4e486(props) {
|
|
205
|
+
var _props_defaultSelectedKey, _ref;
|
|
206
|
+
let state = $a0d645289fe9b86b$export$e7f05e985daf4b5f({
|
|
207
|
+
...props,
|
|
208
|
+
onSelectionChange: props.onSelectionChange ? (key) => {
|
|
209
|
+
var _props_onSelectionChange;
|
|
210
|
+
if (key != null) (_props_onSelectionChange = props.onSelectionChange) === null || _props_onSelectionChange === void 0 ? void 0 : _props_onSelectionChange.call(props, key);
|
|
211
|
+
} : void 0,
|
|
212
|
+
suppressTextValueWarning: true,
|
|
213
|
+
defaultSelectedKey: (_ref = (_props_defaultSelectedKey = props.defaultSelectedKey) !== null && _props_defaultSelectedKey !== void 0 ? _props_defaultSelectedKey : $76f919a04c5a7d14$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set())) !== null && _ref !== void 0 ? _ref : void 0
|
|
214
|
+
});
|
|
215
|
+
let { selectionManager, collection, selectedKey: currentSelectedKey } = state;
|
|
216
|
+
let lastSelectedKey = useRef(currentSelectedKey);
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
let selectedKey = currentSelectedKey;
|
|
219
|
+
if (props.selectedKey == null && (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey))) {
|
|
220
|
+
selectedKey = $76f919a04c5a7d14$var$findDefaultSelectedKey(collection, state.disabledKeys);
|
|
221
|
+
if (selectedKey != null)
|
|
222
|
+
selectionManager.setSelectedKeys([
|
|
223
|
+
selectedKey
|
|
224
|
+
]);
|
|
225
|
+
}
|
|
226
|
+
if (selectedKey != null && selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
|
|
227
|
+
lastSelectedKey.current = selectedKey;
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
...state,
|
|
231
|
+
isDisabled: props.isDisabled || false
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function $76f919a04c5a7d14$var$findDefaultSelectedKey(collection, disabledKeys) {
|
|
235
|
+
let selectedKey = null;
|
|
236
|
+
if (collection) {
|
|
237
|
+
var _collection_getItem_props, _collection_getItem, _collection_getItem_props1, _collection_getItem1;
|
|
238
|
+
selectedKey = collection.getFirstKey();
|
|
239
|
+
while (selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem = collection.getItem(selectedKey)) === null || _collection_getItem === void 0 ? void 0 : (_collection_getItem_props = _collection_getItem.props) === null || _collection_getItem_props === void 0 ? void 0 : _collection_getItem_props.isDisabled)) && selectedKey !== collection.getLastKey()) selectedKey = collection.getKeyAfter(selectedKey);
|
|
240
|
+
if (selectedKey != null && (disabledKeys.has(selectedKey) || ((_collection_getItem1 = collection.getItem(selectedKey)) === null || _collection_getItem1 === void 0 ? void 0 : (_collection_getItem_props1 = _collection_getItem1.props) === null || _collection_getItem_props1 === void 0 ? void 0 : _collection_getItem_props1.isDisabled)) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
|
|
241
|
+
}
|
|
242
|
+
return selectedKey;
|
|
243
|
+
}
|
|
244
|
+
const $5e8ad37a45e1c704$export$cfa7aa87c26e7d1f = /* @__PURE__ */ createContext(null);
|
|
245
|
+
const $5e8ad37a45e1c704$export$364712098d2aa57c = /* @__PURE__ */ createContext(null);
|
|
246
|
+
const $5e8ad37a45e1c704$export$b2539bed5023c21c = /* @__PURE__ */ forwardRef(function Tabs(props, ref) {
|
|
247
|
+
[props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $5e8ad37a45e1c704$export$cfa7aa87c26e7d1f);
|
|
248
|
+
let { children, orientation = "horizontal" } = props;
|
|
249
|
+
children = useMemo(() => typeof children === "function" ? children({
|
|
250
|
+
orientation,
|
|
251
|
+
defaultChildren: null
|
|
252
|
+
}) : children, [
|
|
253
|
+
children,
|
|
254
|
+
orientation
|
|
255
|
+
]);
|
|
256
|
+
return /* @__PURE__ */ React__default.createElement($e1995378a142960e$export$bf788dd355e3a401, {
|
|
257
|
+
content: children
|
|
258
|
+
}, (collection) => /* @__PURE__ */ React__default.createElement($5e8ad37a45e1c704$var$TabsInner, {
|
|
259
|
+
props,
|
|
260
|
+
collection,
|
|
261
|
+
tabsRef: ref
|
|
262
|
+
}));
|
|
263
|
+
});
|
|
264
|
+
function $5e8ad37a45e1c704$var$TabsInner({ props, tabsRef: ref, collection }) {
|
|
265
|
+
let { orientation = "horizontal" } = props;
|
|
266
|
+
let state = $76f919a04c5a7d14$export$4ba071daf4e486({
|
|
267
|
+
...props,
|
|
268
|
+
collection,
|
|
269
|
+
children: void 0
|
|
270
|
+
});
|
|
271
|
+
let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f({
|
|
272
|
+
within: true
|
|
273
|
+
});
|
|
274
|
+
let values = useMemo(() => ({
|
|
275
|
+
orientation,
|
|
276
|
+
isFocusWithin: isFocused,
|
|
277
|
+
isFocusVisible
|
|
278
|
+
}), [
|
|
279
|
+
orientation,
|
|
280
|
+
isFocused,
|
|
281
|
+
isFocusVisible
|
|
282
|
+
]);
|
|
283
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
284
|
+
...props,
|
|
285
|
+
defaultClassName: "react-aria-Tabs",
|
|
286
|
+
values
|
|
287
|
+
});
|
|
288
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
289
|
+
...$65484d02dcb7eb3e$export$457c3d6518dd4c6f(props),
|
|
290
|
+
...focusProps,
|
|
291
|
+
...renderProps,
|
|
292
|
+
ref,
|
|
293
|
+
slot: props.slot || void 0,
|
|
294
|
+
"data-focused": isFocused || void 0,
|
|
295
|
+
"data-orientation": orientation,
|
|
296
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
297
|
+
"data-disabled": state.isDisabled || void 0
|
|
298
|
+
}, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
299
|
+
values: [
|
|
300
|
+
[
|
|
301
|
+
$5e8ad37a45e1c704$export$cfa7aa87c26e7d1f,
|
|
302
|
+
props
|
|
303
|
+
],
|
|
304
|
+
[
|
|
305
|
+
$5e8ad37a45e1c704$export$364712098d2aa57c,
|
|
306
|
+
state
|
|
307
|
+
]
|
|
308
|
+
]
|
|
309
|
+
}, renderProps.children));
|
|
310
|
+
}
|
|
311
|
+
const $5e8ad37a45e1c704$export$e51a686c67fdaa2d = /* @__PURE__ */ forwardRef(function TabList(props, ref) {
|
|
312
|
+
let state = useContext($5e8ad37a45e1c704$export$364712098d2aa57c);
|
|
313
|
+
return state ? /* @__PURE__ */ React__default.createElement($5e8ad37a45e1c704$var$TabListInner, {
|
|
314
|
+
props,
|
|
315
|
+
forwardedRef: ref
|
|
316
|
+
}) : /* @__PURE__ */ React__default.createElement($e1995378a142960e$export$fb8073518f34e6ec, props);
|
|
317
|
+
});
|
|
318
|
+
function $5e8ad37a45e1c704$var$TabListInner({ props, forwardedRef: ref }) {
|
|
319
|
+
let state = useContext($5e8ad37a45e1c704$export$364712098d2aa57c);
|
|
320
|
+
let { CollectionRoot } = useContext($7135fc7d473fd974$export$4feb769f8ddf26c5);
|
|
321
|
+
let { orientation = "horizontal", keyboardActivation = "automatic" } = $64fa3d84918910a7$export$fabf2dc03a41866e($5e8ad37a45e1c704$export$cfa7aa87c26e7d1f);
|
|
322
|
+
let objectRef = $df56164dff5785e2$export$4338b53315abf666(ref);
|
|
323
|
+
let { tabListProps } = $58d314389b21fa3f$export$773e389e644c5874({
|
|
324
|
+
...props,
|
|
325
|
+
orientation,
|
|
326
|
+
keyboardActivation
|
|
327
|
+
}, state, objectRef);
|
|
328
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
329
|
+
...props,
|
|
330
|
+
children: null,
|
|
331
|
+
defaultClassName: "react-aria-TabList",
|
|
332
|
+
values: {
|
|
333
|
+
orientation,
|
|
334
|
+
state
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
338
|
+
delete DOMProps.id;
|
|
339
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
340
|
+
...DOMProps,
|
|
341
|
+
...tabListProps,
|
|
342
|
+
ref: objectRef,
|
|
343
|
+
...renderProps,
|
|
344
|
+
"data-orientation": orientation || void 0
|
|
345
|
+
}, /* @__PURE__ */ React__default.createElement(CollectionRoot, {
|
|
346
|
+
collection: state.collection,
|
|
347
|
+
persistedKeys: $7135fc7d473fd974$export$90e00781bc59d8f9(state.selectionManager.focusedKey)
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
const $5e8ad37a45e1c704$export$3e41faf802a29e71 = /* @__PURE__ */ $e1995378a142960e$export$18af5c7a9e9b3664("item", (props, forwardedRef, item) => {
|
|
351
|
+
let state = useContext($5e8ad37a45e1c704$export$364712098d2aa57c);
|
|
352
|
+
let ref = $df56164dff5785e2$export$4338b53315abf666(forwardedRef);
|
|
353
|
+
let { tabProps, isSelected, isDisabled, isPressed } = $0175d55c2a017ebc$export$fdf4756d5b8ef90a({
|
|
354
|
+
key: item.key,
|
|
355
|
+
...props
|
|
356
|
+
}, state, ref);
|
|
357
|
+
let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f();
|
|
358
|
+
let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
|
|
359
|
+
isDisabled,
|
|
360
|
+
onHoverStart: props.onHoverStart,
|
|
361
|
+
onHoverEnd: props.onHoverEnd,
|
|
362
|
+
onHoverChange: props.onHoverChange
|
|
363
|
+
});
|
|
364
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
365
|
+
...props,
|
|
366
|
+
id: void 0,
|
|
367
|
+
children: item.rendered,
|
|
368
|
+
defaultClassName: "react-aria-Tab",
|
|
369
|
+
values: {
|
|
370
|
+
isSelected,
|
|
371
|
+
isDisabled,
|
|
372
|
+
isFocused,
|
|
373
|
+
isFocusVisible,
|
|
374
|
+
isPressed,
|
|
375
|
+
isHovered
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
let ElementType = item.props.href ? "a" : "div";
|
|
379
|
+
return /* @__PURE__ */ React__default.createElement(ElementType, {
|
|
380
|
+
...$3ef42575df84b30b$export$9d1611c77c2fe928(tabProps, focusProps, hoverProps, renderProps),
|
|
381
|
+
ref,
|
|
382
|
+
"data-selected": isSelected || void 0,
|
|
383
|
+
"data-disabled": isDisabled || void 0,
|
|
384
|
+
"data-focused": isFocused || void 0,
|
|
385
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
386
|
+
"data-pressed": isPressed || void 0,
|
|
387
|
+
"data-hovered": isHovered || void 0
|
|
388
|
+
}, renderProps.children);
|
|
389
|
+
});
|
|
390
|
+
const $5e8ad37a45e1c704$export$3d96ec278d3efce4 = /* @__PURE__ */ $f39a9eba43920ace$export$86427a43e3e48ebb(function TabPanel(props, forwardedRef) {
|
|
391
|
+
const state = useContext($5e8ad37a45e1c704$export$364712098d2aa57c);
|
|
392
|
+
let ref = $df56164dff5785e2$export$4338b53315abf666(forwardedRef);
|
|
393
|
+
let { tabPanelProps } = $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref);
|
|
394
|
+
let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f();
|
|
395
|
+
let isSelected = state.selectedKey === props.id;
|
|
396
|
+
let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
|
|
397
|
+
...props,
|
|
398
|
+
defaultClassName: "react-aria-TabPanel",
|
|
399
|
+
values: {
|
|
400
|
+
isFocused,
|
|
401
|
+
isFocusVisible,
|
|
402
|
+
isInert: !isSelected,
|
|
403
|
+
state
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
if (!isSelected && !props.shouldForceMount) return null;
|
|
407
|
+
let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
|
|
408
|
+
delete DOMProps.id;
|
|
409
|
+
let domProps = isSelected ? $3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, tabPanelProps, focusProps, renderProps) : renderProps;
|
|
410
|
+
return /* @__PURE__ */ React__default.createElement("div", {
|
|
411
|
+
...domProps,
|
|
412
|
+
ref,
|
|
413
|
+
"data-focused": isFocused || void 0,
|
|
414
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
415
|
+
// @ts-ignore
|
|
416
|
+
inert: $cdc5a6778b766db2$export$a9d04c5684123369(!isSelected),
|
|
417
|
+
"data-inert": !isSelected ? "true" : void 0
|
|
418
|
+
}, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
|
|
419
|
+
values: [
|
|
420
|
+
[
|
|
421
|
+
$5e8ad37a45e1c704$export$cfa7aa87c26e7d1f,
|
|
422
|
+
null
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
$5e8ad37a45e1c704$export$364712098d2aa57c,
|
|
426
|
+
null
|
|
427
|
+
]
|
|
428
|
+
]
|
|
429
|
+
}, /* @__PURE__ */ React__default.createElement($7135fc7d473fd974$export$4feb769f8ddf26c5.Provider, {
|
|
430
|
+
value: $7135fc7d473fd974$export$a164736487e3f0ae
|
|
431
|
+
}, renderProps.children)));
|
|
432
|
+
});
|
|
433
|
+
/**
|
|
434
|
+
* Main tab container.
|
|
435
|
+
*
|
|
436
|
+
* @component
|
|
437
|
+
* @param {Object} props - Component props.
|
|
438
|
+
* @param {boolean} [props.vertical=false] - Whether the tabs are vertical.
|
|
439
|
+
* @param {string} [props.className] - Classes to pass to the tabs container.
|
|
440
|
+
* @param {TabsType} [props.type='underline'] - Design of the tabs.
|
|
441
|
+
* @param {boolean} [props.hidden] - If `true`, the component is not rendered.
|
|
442
|
+
*
|
|
443
|
+
* @returns {JSX.Element} The Tabs component.
|
|
444
|
+
*
|
|
445
|
+
* @typedef {'underline' | 'pill' | 'pillInverse' | 'pillCompact' | 'pillCompactInverse'} TabsType
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* <Tabs>
|
|
449
|
+
* <TabList>
|
|
450
|
+
* <Tab>Tab 1</Tab>
|
|
451
|
+
* <Tab>Tab 2</Tab>
|
|
452
|
+
* </TabList>
|
|
453
|
+
* <TabPanel>Content 1</TabPanel>
|
|
454
|
+
* <TabPanel>Content 2</TabPanel>
|
|
455
|
+
* </Tabs>
|
|
456
|
+
*
|
|
457
|
+
* @preserve
|
|
458
|
+
*/
|
|
459
|
+
const Tabs2 = (props) => {
|
|
460
|
+
const { children, vertical, className, hidden, type = "underline", ...rest } = props;
|
|
461
|
+
const baseId = useId();
|
|
462
|
+
if (hidden) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
let tabPanelCounter = 1;
|
|
466
|
+
let tabCounter = 1;
|
|
467
|
+
const preparedChildren = Array.isArray(children) ? children : [children];
|
|
468
|
+
const childrenWithIds = preparedChildren.reduce((acc, child, index) => {
|
|
469
|
+
var _a, _b, _c;
|
|
470
|
+
if (child.type.displayName === "TabList") {
|
|
471
|
+
const childItems = Array.isArray((_a = child == null ? void 0 : child.props) == null ? void 0 : _a.children) ? (_b = child == null ? void 0 : child.props) == null ? void 0 : _b.children : [(_c = child == null ? void 0 : child.props) == null ? void 0 : _c.children].filter(Boolean);
|
|
472
|
+
tabCounter = ((childItems == null ? void 0 : childItems.length) ?? 0) + 1;
|
|
473
|
+
if (childItems.length < 1) {
|
|
474
|
+
return acc;
|
|
475
|
+
}
|
|
476
|
+
return [
|
|
477
|
+
...acc,
|
|
478
|
+
cloneElement(
|
|
479
|
+
child,
|
|
480
|
+
{
|
|
481
|
+
key: index,
|
|
482
|
+
type
|
|
483
|
+
},
|
|
484
|
+
childItems == null ? void 0 : childItems.map(
|
|
485
|
+
(innerChild, i) => cloneElement(innerChild, {
|
|
486
|
+
id: `tab-${baseId}-${i + 1}`,
|
|
487
|
+
key: i,
|
|
488
|
+
isParentVertical: vertical,
|
|
489
|
+
type
|
|
490
|
+
})
|
|
491
|
+
)
|
|
492
|
+
)
|
|
493
|
+
];
|
|
494
|
+
}
|
|
495
|
+
if (child.type.displayName === "TabPanel") {
|
|
496
|
+
return [
|
|
497
|
+
...acc,
|
|
498
|
+
cloneElement(child, {
|
|
499
|
+
id: `tab-${baseId}-${tabPanelCounter++}`,
|
|
500
|
+
key: index,
|
|
501
|
+
className: clsx(child.props.className, vertical && "es:pl-3")
|
|
502
|
+
})
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
return acc;
|
|
506
|
+
}, []);
|
|
507
|
+
if (tabCounter !== tabPanelCounter) {
|
|
508
|
+
return /* @__PURE__ */ jsx(
|
|
509
|
+
Notice,
|
|
510
|
+
{
|
|
511
|
+
type: "error",
|
|
512
|
+
label: __("Component is not configured correctly. Skipping render to prevent errors.", "eightshift-ui-components"),
|
|
513
|
+
subtitle: sprintf(
|
|
514
|
+
__("Number of <Tab>s (%s) and <TabPanel>s (%s) should be the same. <Tab>s should be within a <TabList>.", "eightshift-ui-components"),
|
|
515
|
+
tabCounter - 1,
|
|
516
|
+
tabPanelCounter - 1
|
|
517
|
+
),
|
|
518
|
+
alignIconToTitle: true
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
return /* @__PURE__ */ jsx(
|
|
523
|
+
$5e8ad37a45e1c704$export$b2539bed5023c21c,
|
|
524
|
+
{
|
|
525
|
+
...rest,
|
|
526
|
+
orientation: vertical ? "vertical" : "horizontal",
|
|
527
|
+
className: clsx(vertical ? "es:grid es:size-full es:min-h-40 es:grid-cols-[minmax(0,15rem)_2fr] es:gap-4" : "es:flex-col", className),
|
|
528
|
+
children: childrenWithIds
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
};
|
|
532
|
+
Tabs2.displayName = "Tabs";
|
|
533
|
+
/**
|
|
534
|
+
* Container for tabs within the Tabs component.
|
|
535
|
+
*
|
|
536
|
+
* @component
|
|
537
|
+
* @param {Object} props - Component props.
|
|
538
|
+
* @param {string} [props.className] - Classes to pass to the tab list.
|
|
539
|
+
*
|
|
540
|
+
* @returns {JSX.Element} The TabList component.
|
|
541
|
+
*
|
|
542
|
+
* @see {@link Tabs} for usage example.
|
|
543
|
+
*
|
|
544
|
+
* @preserve
|
|
545
|
+
*/
|
|
546
|
+
const TabList2 = (props) => {
|
|
547
|
+
const { children, "aria-label": ariaLabel, className, type, ...other } = props;
|
|
548
|
+
return /* @__PURE__ */ jsx(
|
|
549
|
+
$5e8ad37a45e1c704$export$e51a686c67fdaa2d,
|
|
550
|
+
{
|
|
551
|
+
"aria-label": ariaLabel ?? __("tabs", "eightshift-ui-components"),
|
|
552
|
+
className: ({ orientation }) => {
|
|
553
|
+
const horizontal = orientation === "horizontal";
|
|
554
|
+
const vertical = orientation === "vertical";
|
|
555
|
+
return clsx(
|
|
556
|
+
"es:flex es:p-0.5 es:-m-0.5",
|
|
557
|
+
vertical && "es:h-full es:flex-col es:gap-1.5 es:pr-1.5 es:overflow-y-auto es:overflow-x-visible",
|
|
558
|
+
horizontal && "es:w-full es:items-stretch es:gap-1.5 es:overflow-x-auto es:overflow-y-visible es:mb-3",
|
|
559
|
+
horizontal && type === "underline" && 'es:relative es:isolate es:after:content-[""] es:after:-z-10 es:after:absolute es:after:bottom-0.5 es:after:left-0 es:after:w-full es:after:h-px es:after:bg-secondary-300',
|
|
560
|
+
className
|
|
561
|
+
);
|
|
562
|
+
},
|
|
563
|
+
...other,
|
|
564
|
+
children
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
};
|
|
568
|
+
TabList2.displayName = "TabList";
|
|
569
|
+
/**
|
|
570
|
+
* A tab within the TabList component, in the Tabs component.
|
|
571
|
+
*
|
|
572
|
+
* @component
|
|
573
|
+
* @param {Object} props - Component props.
|
|
574
|
+
* @param {boolean} [props.disabled] - Whether the tab is disabled.
|
|
575
|
+
* @param {string} [props.className] - Classes to pass to the tab.
|
|
576
|
+
* @param {JSX.Element} [props.icon] - Icon to show on the tab.
|
|
577
|
+
* @param {string|JSX.Element} [props.badge] - Badge to render besides the label.
|
|
578
|
+
* @param {boolean} [props.invisible] - If `true`, the tab is disabled and not rendered, but is not unmounted from the DOM.
|
|
579
|
+
* @param {string} [props.label] - Tab label. **Note**: overrides inner items!
|
|
580
|
+
* @param {string} [props.subtitle] - Tab subtitle. **Note**: overrides inner items!
|
|
581
|
+
*
|
|
582
|
+
* @returns {JSX.Element} The Tab component.
|
|
583
|
+
*
|
|
584
|
+
* @see {@link Tabs} for usage example.
|
|
585
|
+
*
|
|
586
|
+
* @preserve
|
|
587
|
+
*/
|
|
588
|
+
const Tab = (props) => {
|
|
589
|
+
const { children, disabled, isParentVertical, className, icon, label, subtitle, type, badge, invisible, ...other } = props;
|
|
590
|
+
const componentClasses = cva(
|
|
591
|
+
[
|
|
592
|
+
"es:group es:flex es:items-center es:gap-1.5 es:relative es:shrink-0",
|
|
593
|
+
"es:select-none es:text-sm es:transition es:not-disabled:cursor-pointer",
|
|
594
|
+
"es:any-focus:outline-hidden es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50",
|
|
595
|
+
!(type === "pillCompact" || type === "pillCompactInverse") && "es:min-h-9.5",
|
|
596
|
+
isParentVertical && (type === "pillCompact" || type === "pillCompactInverse") && "es:min-h-8",
|
|
597
|
+
invisible && "es:hidden",
|
|
598
|
+
className
|
|
599
|
+
],
|
|
600
|
+
{
|
|
601
|
+
variants: {
|
|
602
|
+
type: {
|
|
603
|
+
underline: "es:disabled:text-secondary-400 es:selected:text-accent-950",
|
|
604
|
+
pill: "es:font-[450] es:border es:border-transparent es:px-3 es:py-2 es:rounded-lg es:not-disabled:not-selected:hover:text-secondary-900 es:not-disabled:not-selected:hover:bg-secondary-100 es:text-secondary-500 es:selected:text-accent-900 es:selected:bg-accent-400/15 es:has-icon:pl-2.5 es:focus-visible:border-accent-500 es:disabled:text-secondary-400/75",
|
|
605
|
+
pillInverse: "es:font-[450] es:border es:border-transparent es:px-3 es:py-2 es:rounded-lg es:not-disabled:not-selected:hover:text-secondary-900 es:not-disabled:not-selected:hover:bg-secondary-100 es:text-secondary-500 es:selected:text-white es:selected:bg-accent-600 es:has-icon:pl-2.5 es:focus-visible:border-accent-500 es:disabled:text-secondary-400/75",
|
|
606
|
+
pillCompact: "es:icon:size-4 es:font-[450] es:border es:border-transparent es:px-1.5 es:py-1 es:rounded-lg es:not-disabled:not-selected:hover:text-secondary-900 es:not-disabled:not-selected:hover:bg-secondary-100 es:text-secondary-500 es:selected:text-accent-900 es:selected:bg-accent-400/15 es:has-icon:pl-1 es:focus-visible:border-accent-500 es:disabled:text-secondary-400/75",
|
|
607
|
+
pillCompactInverse: "es:icon:size-4 es:font-[450] es:border es:border-transparent es:px-1.5 es:py-1 es:rounded-lg es:not-disabled:not-selected:hover:text-secondary-900 es:not-disabled:not-selected:hover:bg-secondary-100 es:text-secondary-500 es:selected:text-white es:selected:bg-accent-600 es:has-icon:pl-1 es:focus-visible:border-accent-500 es:disabled:text-secondary-400/75"
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
compoundVariants: [
|
|
611
|
+
{
|
|
612
|
+
vertical: false,
|
|
613
|
+
type: "underline",
|
|
614
|
+
class: [
|
|
615
|
+
"es:px-2 es:py-2.5 es:rounded-lg",
|
|
616
|
+
'es:after:content-[""] es:after:absolute es:after:bottom-px es:after:left-0 es:after:right-0 es:after:w-5/6 es:after:mx-auto es:after:h-0.75',
|
|
617
|
+
"es:after:bg-linear-to-b es:hover:not-selected:not-disabled:after:from-secondary-200 es:hover:not-selected:not-disabled:after:to-secondary-300 es:selected:after:from-accent-500 es:selected:after:to-accent-600",
|
|
618
|
+
"es:after:rounded-t-full es:selected:after:shadow-xs es:selected:after:shadow-accent-700/30 es:after:transition"
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
vertical: true,
|
|
623
|
+
type: "underline",
|
|
624
|
+
class: [
|
|
625
|
+
"es:pl-3 es:pr-2 es:py-2.5 es:rounded-lg es:selected:bg-accent-50/50 es:selected:text-accent-950 es:transition",
|
|
626
|
+
'es:after:content-[""] es:after:absolute es:after:-left-0 es:after:top-0 es:after:bottom-0 es:after:h-5/6 es:after:my-auto es:after:w-1',
|
|
627
|
+
"es:after:bg-linear-to-r es:hover:not-selected:not-disabled:after:from-secondary-200 es:hover:not-selected:not-disabled:after:to-secondary-300 es:selected:after:from-accent-500 es:selected:after:to-accent-600",
|
|
628
|
+
"es:after:rounded-full es:selected:after:shadow-xs es:selected:after:shadow-accent-700/30 es:after:transition"
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
return /* @__PURE__ */ jsxs(
|
|
635
|
+
$5e8ad37a45e1c704$export$3e41faf802a29e71,
|
|
636
|
+
{
|
|
637
|
+
...other,
|
|
638
|
+
isDisabled: disabled || invisible,
|
|
639
|
+
className: componentClasses({ vertical: Boolean(isParentVertical), type }),
|
|
640
|
+
children: [
|
|
641
|
+
(icon || subtitle) && /* @__PURE__ */ jsx(
|
|
642
|
+
RichLabel,
|
|
643
|
+
{
|
|
644
|
+
icon,
|
|
645
|
+
label: label ?? children,
|
|
646
|
+
subtitle,
|
|
647
|
+
noColor: true,
|
|
648
|
+
iconClassName: clsx((type === "pillCompact" || type === "pillCompactInverse") && "es:icon:size-4!")
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
!(icon || subtitle) && (label ?? children),
|
|
652
|
+
badge && !isValidElement(badge) && /* @__PURE__ */ jsx(
|
|
653
|
+
"span",
|
|
654
|
+
{
|
|
655
|
+
className: clsx(
|
|
656
|
+
"es:transition-colors es:px-1.5 es:py-1 es:leading-none es:rounded-md es:text-xs es:font-medium",
|
|
657
|
+
type === "underline" && "es:inset-ring es:inset-ring-secondary-200/20 es:bg-secondary-100 es:group-selected:bg-accent-500/10 es:group-selected:text-accent-900 es:group-selected:inset-ring-accent-500/10",
|
|
658
|
+
type === "pill" && "es:bg-secondary-100 es:group-selected:bg-accent-600 es:group-selected:text-white",
|
|
659
|
+
type === "pillInverse" && "es:bg-secondary-100 es:group-selected:bg-accent-50 es:group-selected:text-accent-900",
|
|
660
|
+
type === "pillCompact" && "es:bg-secondary-100 es:group-selected:bg-accent-600 es:group-selected:text-white",
|
|
661
|
+
type === "pillCompactInverse" && "es:bg-secondary-100 es:group-selected:bg-accent-50 es:group-selected:text-accent-900",
|
|
662
|
+
(type === "pillCompact" || type === "pillCompactInverse") && "es:[&_svg]:size-4!"
|
|
663
|
+
),
|
|
664
|
+
children: badge
|
|
665
|
+
}
|
|
666
|
+
),
|
|
667
|
+
badge && isValidElement(badge) && /* @__PURE__ */ jsx("div", { children: badge })
|
|
668
|
+
]
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
};
|
|
672
|
+
Tab.displayName = "Tab";
|
|
673
|
+
/**
|
|
674
|
+
* Container for tab content within the Tabs component.
|
|
675
|
+
*
|
|
676
|
+
* @component
|
|
677
|
+
* @param {Object} props - Component props.
|
|
678
|
+
* @param {string} [props.className] - Classes to pass to the tab content container.
|
|
679
|
+
*
|
|
680
|
+
* @returns {JSX.Element} The TabPanel component.
|
|
681
|
+
*
|
|
682
|
+
* @see {@link Tabs} for usage example.
|
|
683
|
+
*
|
|
684
|
+
* @preserve
|
|
685
|
+
*/
|
|
686
|
+
const TabPanel2 = (props) => {
|
|
687
|
+
const { children, className, ...other } = props;
|
|
688
|
+
return /* @__PURE__ */ jsx(
|
|
689
|
+
$5e8ad37a45e1c704$export$3d96ec278d3efce4,
|
|
690
|
+
{
|
|
691
|
+
...other,
|
|
692
|
+
className: clsx("es:space-y-2.5 es:text-sm es:any-focus:outline-hidden", className),
|
|
693
|
+
children
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
};
|
|
697
|
+
TabPanel2.displayName = "TabPanel";
|
|
698
|
+
export {
|
|
699
|
+
Tab,
|
|
700
|
+
TabList2 as TabList,
|
|
701
|
+
TabPanel2 as TabPanel,
|
|
702
|
+
Tabs2 as Tabs
|
|
703
|
+
};
|