@heymantle/litho 0.0.9 → 0.0.12
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/cjs/components/Banner.js +6 -1
- package/dist/cjs/components/Button.js +33 -4
- package/dist/cjs/components/ButtonGroup.js +19 -4
- package/dist/cjs/components/Card.js +39 -3
- package/dist/cjs/components/Checkbox.js +13 -2
- package/dist/cjs/components/ChoiceList.js +3 -2
- package/dist/cjs/components/Code.js +227 -0
- package/dist/cjs/components/Filters.js +1 -1
- package/dist/cjs/components/Frame.js +2 -2
- package/dist/cjs/components/Layout.js +16 -4
- package/dist/cjs/components/Link.js +35 -4
- package/dist/cjs/components/Modal.js +4 -0
- package/dist/cjs/components/Page.js +5 -2
- package/dist/cjs/components/Pane.js +669 -84
- package/dist/cjs/components/ResourceList.js +2 -2
- package/dist/cjs/components/TabNavigation.js +300 -0
- package/dist/cjs/components/TextField.js +3 -0
- package/dist/cjs/components/Tip.js +3 -0
- package/dist/cjs/components/Tooltip.js +12 -13
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/stories/Checkbox.stories.js +172 -1
- package/dist/cjs/stories/Pane.stories.js +352 -3
- package/dist/cjs/utilities/useBodyScrollLock.js +63 -0
- package/dist/cjs/utilities/useKeyboardAction.js +19 -0
- package/dist/cjs/utilities/useLocalStorage.js +126 -0
- package/dist/cjs/utilities/useMobile.js +92 -0
- package/dist/cjs/utilities/usePaneState.js +340 -0
- package/dist/cjs/utilities/useTabStorage.js +325 -0
- package/dist/esm/components/Banner.js +7 -2
- package/dist/esm/components/Button.js +33 -4
- package/dist/esm/components/ButtonGroup.js +19 -4
- package/dist/esm/components/Card.js +39 -3
- package/dist/esm/components/Checkbox.js +13 -2
- package/dist/esm/components/ChoiceList.js +3 -2
- package/dist/esm/components/Code.js +212 -0
- package/dist/esm/components/Filters.js +2 -2
- package/dist/esm/components/Frame.js +2 -2
- package/dist/esm/components/Layout.js +16 -4
- package/dist/esm/components/Link.js +31 -5
- package/dist/esm/components/Modal.js +4 -0
- package/dist/esm/components/Page.js +5 -2
- package/dist/esm/components/Pane.js +619 -83
- package/dist/esm/components/ResourceList.js +2 -2
- package/dist/esm/components/TabNavigation.js +285 -0
- package/dist/esm/components/TextField.js +4 -1
- package/dist/esm/components/Tip.js +4 -1
- package/dist/esm/components/Tooltip.js +12 -13
- package/dist/esm/index.js +1 -0
- package/dist/esm/stories/Checkbox.stories.js +166 -1
- package/dist/esm/stories/Pane.stories.js +346 -3
- package/dist/esm/utilities/useBodyScrollLock.js +53 -0
- package/dist/esm/utilities/useKeyboardAction.js +25 -0
- package/dist/esm/utilities/useLocalStorage.js +115 -0
- package/dist/esm/utilities/useMobile.js +79 -0
- package/dist/esm/utilities/usePaneState.js +334 -0
- package/dist/esm/utilities/useTabStorage.js +311 -0
- package/dist/types/components/Banner.d.ts.map +1 -1
- package/dist/types/components/Button.d.ts +2 -2
- package/dist/types/components/Button.d.ts.map +1 -1
- package/dist/types/components/ButtonGroup.d.ts.map +1 -1
- package/dist/types/components/Card.d.ts +34 -1
- package/dist/types/components/Card.d.ts.map +1 -1
- package/dist/types/components/Checkbox.d.ts +11 -2
- package/dist/types/components/Checkbox.d.ts.map +1 -1
- package/dist/types/components/Code.d.ts +28 -0
- package/dist/types/components/Code.d.ts.map +1 -0
- package/dist/types/components/Filters.d.ts.map +1 -1
- package/dist/types/components/Layout.d.ts +2 -0
- package/dist/types/components/Layout.d.ts.map +1 -1
- package/dist/types/components/Link.d.ts +4 -0
- package/dist/types/components/Link.d.ts.map +1 -1
- package/dist/types/components/Modal.d.ts +2 -0
- package/dist/types/components/Modal.d.ts.map +1 -1
- package/dist/types/components/Page.d.ts.map +1 -1
- package/dist/types/components/Pane.d.ts +2 -0
- package/dist/types/components/Pane.d.ts.map +1 -1
- package/dist/types/components/TabNavigation.d.ts +3 -0
- package/dist/types/components/TabNavigation.d.ts.map +1 -0
- package/dist/types/components/TextField.d.ts.map +1 -1
- package/dist/types/components/Tip.d.ts.map +1 -1
- package/dist/types/components/Tooltip.d.ts +2 -0
- package/dist/types/components/Tooltip.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utilities/useBodyScrollLock.d.ts +12 -0
- package/dist/types/utilities/useBodyScrollLock.d.ts.map +1 -0
- package/dist/types/utilities/useKeyboardAction.d.ts +2 -0
- package/dist/types/utilities/useKeyboardAction.d.ts.map +1 -0
- package/dist/types/utilities/useLocalStorage.d.ts +13 -0
- package/dist/types/utilities/useLocalStorage.d.ts.map +1 -0
- package/dist/types/utilities/useMobile.d.ts +9 -0
- package/dist/types/utilities/useMobile.d.ts.map +1 -0
- package/dist/types/utilities/usePaneState.d.ts +2 -0
- package/dist/types/utilities/usePaneState.d.ts.map +1 -0
- package/dist/types/utilities/useTabStorage.d.ts +8 -0
- package/dist/types/utilities/useTabStorage.d.ts.map +1 -0
- package/index.css +77 -6
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "default", {
|
|
|
11
11
|
var _jsxruntime = require("react/jsx-runtime");
|
|
12
12
|
var _tailwindvariants = require("tailwind-variants");
|
|
13
13
|
var _Spinner = /*#__PURE__*/ _interop_require_default(require("./Spinner"));
|
|
14
|
-
var
|
|
14
|
+
var _Stack = /*#__PURE__*/ _interop_require_default(require("./Stack"));
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
17
17
|
default: obj
|
|
@@ -52,7 +52,7 @@ var styles = (0, _tailwindvariants.tv)({
|
|
|
52
52
|
small: "2",
|
|
53
53
|
large: "4"
|
|
54
54
|
};
|
|
55
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
55
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Stack.default, {
|
|
56
56
|
gap: gapMap[gap],
|
|
57
57
|
className: styles({
|
|
58
58
|
divider: divider
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _polarisicons = require("@shopify/polaris-icons");
|
|
15
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
16
|
+
var _Button = /*#__PURE__*/ _interop_require_default(require("./Button"));
|
|
17
|
+
var _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
18
|
+
var _Spinner = /*#__PURE__*/ _interop_require_default(require("./Spinner"));
|
|
19
|
+
var _Tooltip = /*#__PURE__*/ _interop_require_default(require("./Tooltip"));
|
|
20
|
+
function _array_like_to_array(arr, len) {
|
|
21
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
22
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
23
|
+
return arr2;
|
|
24
|
+
}
|
|
25
|
+
function _array_with_holes(arr) {
|
|
26
|
+
if (Array.isArray(arr)) return arr;
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_default(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function _iterable_to_array_limit(arr, i) {
|
|
34
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
35
|
+
if (_i == null) return;
|
|
36
|
+
var _arr = [];
|
|
37
|
+
var _n = true;
|
|
38
|
+
var _d = false;
|
|
39
|
+
var _s, _e;
|
|
40
|
+
try {
|
|
41
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
42
|
+
_arr.push(_s.value);
|
|
43
|
+
if (i && _arr.length === i) break;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_d = true;
|
|
47
|
+
_e = err;
|
|
48
|
+
} finally{
|
|
49
|
+
try {
|
|
50
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
51
|
+
} finally{
|
|
52
|
+
if (_d) throw _e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _arr;
|
|
56
|
+
}
|
|
57
|
+
function _non_iterable_rest() {
|
|
58
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
59
|
+
}
|
|
60
|
+
function _sliced_to_array(arr, i) {
|
|
61
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
62
|
+
}
|
|
63
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
64
|
+
if (!o) return;
|
|
65
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
66
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
67
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
68
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
69
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
70
|
+
}
|
|
71
|
+
var AVG_CHAR_WIDTH = 5.5;
|
|
72
|
+
var tabStyles = (0, _tailwindvariants.tv)({
|
|
73
|
+
base: "relative group cursor-pointer rounded-t-sm items-center px-2 pt-2 gap-0.5 overflow-hidden min-w-[60px] max-w-[160px] pointer-coarse:pb-1 pointer-coarse:pt-3 transition-colors",
|
|
74
|
+
variants: {
|
|
75
|
+
isActive: {
|
|
76
|
+
true: "bg-surface-lowest",
|
|
77
|
+
false: "bg-transparent hover:bg-surface-lower"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
isActive: false
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var textStyles = (0, _tailwindvariants.tv)({
|
|
85
|
+
base: "leading-none break-all",
|
|
86
|
+
variants: {
|
|
87
|
+
isActive: {
|
|
88
|
+
true: "",
|
|
89
|
+
false: "text-low"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
var gradientOverlayStyles = (0, _tailwindvariants.tv)({
|
|
94
|
+
base: "sm:opacity-0 sm:group-hover:opacity-100 transition-opacity absolute pointer-events-none pointer-coarse:hidden",
|
|
95
|
+
variants: {
|
|
96
|
+
isActive: {
|
|
97
|
+
true: "bg-surface-lowest",
|
|
98
|
+
false: "bg-surface-lower"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
// Component to handle truncation detection and tooltip
|
|
103
|
+
function TabTitle(param) {
|
|
104
|
+
var title = param.title, isActive = param.isActive, tabContainerRef = param.tabContainerRef;
|
|
105
|
+
var _useState = _sliced_to_array((0, _react.useState)(false), 2), shouldShowTooltip = _useState[0], setShouldShowTooltip = _useState[1];
|
|
106
|
+
(0, _react.useLayoutEffect)(function() {
|
|
107
|
+
if (!title || !(tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current)) {
|
|
108
|
+
setShouldShowTooltip(false);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
var checkOverflow = function() {
|
|
112
|
+
if (!(tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current)) return;
|
|
113
|
+
var tabElement = tabContainerRef.current;
|
|
114
|
+
if (!tabElement) return;
|
|
115
|
+
// Get the actual tab width
|
|
116
|
+
var tabWidth = tabElement.offsetWidth;
|
|
117
|
+
var estimatedCharCapacity = Math.floor(tabWidth / AVG_CHAR_WIDTH);
|
|
118
|
+
// Show tooltip if title length exceeds estimated capacity
|
|
119
|
+
setShouldShowTooltip(title.length > estimatedCharCapacity);
|
|
120
|
+
};
|
|
121
|
+
var resizeObserver = null;
|
|
122
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
123
|
+
var rafId = requestAnimationFrame(function() {
|
|
124
|
+
checkOverflow();
|
|
125
|
+
// Watch for size changes
|
|
126
|
+
if (tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current) {
|
|
127
|
+
resizeObserver = new ResizeObserver(checkOverflow);
|
|
128
|
+
resizeObserver.observe(tabContainerRef.current);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return function() {
|
|
132
|
+
cancelAnimationFrame(rafId);
|
|
133
|
+
if (resizeObserver) {
|
|
134
|
+
resizeObserver.disconnect();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}, [
|
|
138
|
+
title,
|
|
139
|
+
tabContainerRef
|
|
140
|
+
]);
|
|
141
|
+
var textElement = /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
142
|
+
className: "overflow-hidden",
|
|
143
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
144
|
+
variant: "bodyXs",
|
|
145
|
+
className: textStyles({
|
|
146
|
+
isActive: isActive
|
|
147
|
+
}),
|
|
148
|
+
clampLines: 1,
|
|
149
|
+
children: title
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
// Only show tooltip if text is likely truncated based on character count vs tab width
|
|
153
|
+
if (shouldShowTooltip) {
|
|
154
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Tooltip.default, {
|
|
155
|
+
content: title,
|
|
156
|
+
className: "align-top",
|
|
157
|
+
children: textElement
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return textElement;
|
|
161
|
+
}
|
|
162
|
+
function TabNavigation() {
|
|
163
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
164
|
+
var _props_tabs = props.tabs, tabs = _props_tabs === void 0 ? [] : _props_tabs, activeTabId = props.activeTabId, onTabClick = props.onTabClick, onTabClose = props.onTabClose, _props_className = props.className, className = _props_className === void 0 ? "" : _props_className;
|
|
165
|
+
var scrollContainerRef = (0, _react.useRef)(null);
|
|
166
|
+
var tabRefsMap = (0, _react.useRef)(new Map());
|
|
167
|
+
// Function to scroll the active tab into view and center it
|
|
168
|
+
var scrollToActiveTab = (0, _react.useCallback)(function() {
|
|
169
|
+
if (!scrollContainerRef.current || !activeTabId) return;
|
|
170
|
+
var container = scrollContainerRef.current;
|
|
171
|
+
var activeTabElement = container.querySelector('[data-tab-id="'.concat(activeTabId, '"]'));
|
|
172
|
+
if (!activeTabElement) return;
|
|
173
|
+
// Calculate the scroll position to center the tab
|
|
174
|
+
var tabOffsetLeft = activeTabElement.offsetLeft;
|
|
175
|
+
var tabWidth = activeTabElement.offsetWidth;
|
|
176
|
+
var containerWidth = container.offsetWidth;
|
|
177
|
+
// Center the tab in the container: position of tab - (container width - tab width) / 2
|
|
178
|
+
var scrollLeft = tabOffsetLeft - (containerWidth - tabWidth) / 2;
|
|
179
|
+
// Calculate max scroll to prevent over-scrolling
|
|
180
|
+
var maxScroll = container.scrollWidth - containerWidth;
|
|
181
|
+
container.scrollTo({
|
|
182
|
+
left: Math.max(0, Math.min(scrollLeft, maxScroll)),
|
|
183
|
+
behavior: 'smooth'
|
|
184
|
+
});
|
|
185
|
+
}, [
|
|
186
|
+
activeTabId
|
|
187
|
+
]);
|
|
188
|
+
// Scroll to active tab when it changes or when tabs are updated
|
|
189
|
+
(0, _react.useEffect)(function() {
|
|
190
|
+
if (!activeTabId || tabs.length === 0) return;
|
|
191
|
+
// Use double requestAnimationFrame to ensure DOM is fully updated and rendered
|
|
192
|
+
requestAnimationFrame(function() {
|
|
193
|
+
requestAnimationFrame(function() {
|
|
194
|
+
scrollToActiveTab();
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}, [
|
|
198
|
+
activeTabId,
|
|
199
|
+
tabs,
|
|
200
|
+
scrollToActiveTab
|
|
201
|
+
]);
|
|
202
|
+
// Clean up refs for removed tabs
|
|
203
|
+
(0, _react.useEffect)(function() {
|
|
204
|
+
var currentTabIds = new Set(tabs.map(function(tab) {
|
|
205
|
+
return tab.id;
|
|
206
|
+
}));
|
|
207
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
208
|
+
try {
|
|
209
|
+
for(var _iterator = tabRefsMap.current[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
210
|
+
var _step_value = _sliced_to_array(_step.value, 1), tabId = _step_value[0];
|
|
211
|
+
if (!currentTabIds.has(tabId)) {
|
|
212
|
+
tabRefsMap.current.delete(tabId);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_didIteratorError = true;
|
|
217
|
+
_iteratorError = err;
|
|
218
|
+
} finally{
|
|
219
|
+
try {
|
|
220
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
221
|
+
_iterator.return();
|
|
222
|
+
}
|
|
223
|
+
} finally{
|
|
224
|
+
if (_didIteratorError) {
|
|
225
|
+
throw _iteratorError;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}, [
|
|
230
|
+
tabs
|
|
231
|
+
]);
|
|
232
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
233
|
+
className: "Litho-TabNavigation ".concat(className),
|
|
234
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
235
|
+
ref: scrollContainerRef,
|
|
236
|
+
className: "scroll-container flex overflow-x-scroll overflow-y-hidden items-center px-1 pt-1 w-full gap-0.5 bg-tint-2",
|
|
237
|
+
children: tabs.map(function(tab) {
|
|
238
|
+
var isActive = activeTabId === tab.id;
|
|
239
|
+
// Get or create ref for this tab
|
|
240
|
+
if (!tabRefsMap.current.has(tab.id)) {
|
|
241
|
+
tabRefsMap.current.set(tab.id, {
|
|
242
|
+
current: null
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
var tabRef = tabRefsMap.current.get(tab.id);
|
|
246
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
247
|
+
ref: function(el) {
|
|
248
|
+
tabRef.current = el;
|
|
249
|
+
},
|
|
250
|
+
"data-tab-id": tab.id,
|
|
251
|
+
className: tabStyles({
|
|
252
|
+
isActive: isActive
|
|
253
|
+
}),
|
|
254
|
+
onClick: function() {
|
|
255
|
+
return onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(tab.id);
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
259
|
+
className: "h-5 relative",
|
|
260
|
+
children: [
|
|
261
|
+
tab.loading ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
262
|
+
className: "flex items-center justify-center h-5",
|
|
263
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Spinner.default, {
|
|
264
|
+
size: "small"
|
|
265
|
+
})
|
|
266
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(TabTitle, {
|
|
267
|
+
title: tab.title,
|
|
268
|
+
isActive: isActive,
|
|
269
|
+
tabContainerRef: tabRef
|
|
270
|
+
}),
|
|
271
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
272
|
+
className: "".concat(gradientOverlayStyles({
|
|
273
|
+
isActive: isActive
|
|
274
|
+
}), " right-[-4px] top-[-4px] w-4.5 h-6")
|
|
275
|
+
}),
|
|
276
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
277
|
+
className: "".concat(gradientOverlayStyles({
|
|
278
|
+
isActive: isActive
|
|
279
|
+
}), " w-2 h-6 bg-gradient-to-l ").concat(isActive ? 'from-surface-lowest' : 'from-surface-lower', " right-[14px] top-[-4px]")
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
}),
|
|
283
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Button.default, {
|
|
284
|
+
size: "mini",
|
|
285
|
+
iconSize: "sm",
|
|
286
|
+
plain: true,
|
|
287
|
+
icon: _polarisicons.CancelMinor,
|
|
288
|
+
onClick: function(e) {
|
|
289
|
+
e.stopPropagation();
|
|
290
|
+
onTabClose === null || onTabClose === void 0 ? void 0 : onTabClose(tab.id);
|
|
291
|
+
},
|
|
292
|
+
className: "sm:opacity-0 sm:group-hover:opacity-100 transition-all !absolute right-[3px] top-[4px] ".concat(isActive ? 'bg-surface-lowest' : 'bg-surface-lower')
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
}, tab.id);
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
var _default = TabNavigation;
|
|
@@ -564,6 +564,9 @@ var clearButtonStyles = (0, _tailwindvariants.tv)({
|
|
|
564
564
|
}),
|
|
565
565
|
labelAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Link.default, {
|
|
566
566
|
onClick: labelAction.onAction,
|
|
567
|
+
insight: labelAction.insight,
|
|
568
|
+
icon: labelAction.insight ? _polarisicons.MagicMajor : undefined,
|
|
569
|
+
color: labelAction.insight ? "insight" : undefined,
|
|
567
570
|
removeUnderline: true,
|
|
568
571
|
children: labelAction.content
|
|
569
572
|
})
|
|
@@ -14,7 +14,7 @@ var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
|
14
14
|
var _reactdom = require("react-dom");
|
|
15
15
|
var _tailwindvariants = require("tailwind-variants");
|
|
16
16
|
var _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
17
|
-
var
|
|
17
|
+
var _Stack = /*#__PURE__*/ _interop_require_default(require("./Stack"));
|
|
18
18
|
var _List = /*#__PURE__*/ _interop_require_default(require("./List"));
|
|
19
19
|
var _Icon = /*#__PURE__*/ _interop_require_default(require("./Icon"));
|
|
20
20
|
var _polarisicons = require("@shopify/polaris-icons");
|
|
@@ -148,7 +148,9 @@ var styles = (0, _tailwindvariants.tv)({
|
|
|
148
148
|
display: {
|
|
149
149
|
inline: "inline",
|
|
150
150
|
"inline-block": "inline-block",
|
|
151
|
-
block: "block"
|
|
151
|
+
block: "block",
|
|
152
|
+
flex: "flex",
|
|
153
|
+
"inline-flex": "inline-flex"
|
|
152
154
|
},
|
|
153
155
|
hasUnderline: {
|
|
154
156
|
true: "Litho-TooltipContainer--HasUnderline border-b border-dotted",
|
|
@@ -180,7 +182,7 @@ var wrapperStyles = (0, _tailwindvariants.tv)({
|
|
|
180
182
|
}
|
|
181
183
|
});
|
|
182
184
|
var tooltipStyles = (0, _tailwindvariants.tv)({
|
|
183
|
-
base: "Litho-Tooltip
|
|
185
|
+
base: "Litho-Tooltip block w-auto max-w-60 whitespace-normal overflow-hidden bg-surface-alternate text-alternate dark:text-highest py-1.5 px-3 rounded-md",
|
|
184
186
|
variants: {
|
|
185
187
|
alignment: {
|
|
186
188
|
center: "text-center",
|
|
@@ -193,21 +195,15 @@ var tooltipStyles = (0, _tailwindvariants.tv)({
|
|
|
193
195
|
}
|
|
194
196
|
});
|
|
195
197
|
var arrowStyles = (0, _tailwindvariants.tv)({
|
|
196
|
-
base: "Litho-TooltipArrow absolute w-0 h-0 border-l-transparent border-r-transparent border-l-6 border-r-6",
|
|
198
|
+
base: "Litho-TooltipArrow absolute w-0 h-0 border-l-transparent border-r-transparent border-l-6 border-r-6 left-1/2 -translate-x-1/2",
|
|
197
199
|
variants: {
|
|
198
200
|
preferredPosition: {
|
|
199
201
|
above: "Litho-TooltipArrow--Above mb-0.5 bottom-full border-b-0 border-t-6 border-t-surface-alternate",
|
|
200
202
|
below: "Litho-TooltipArrow--Below mt-0.5 top-full border-t-0 border-b-6 border-b-surface-alternate"
|
|
201
|
-
},
|
|
202
|
-
alignment: {
|
|
203
|
-
center: "left-1/2 -translate-x-1/2",
|
|
204
|
-
left: "left-2.5",
|
|
205
|
-
right: "right-2.5"
|
|
206
203
|
}
|
|
207
204
|
},
|
|
208
205
|
defaultVariants: {
|
|
209
|
-
preferredPosition: "below"
|
|
210
|
-
alignment: "center"
|
|
206
|
+
preferredPosition: "below"
|
|
211
207
|
}
|
|
212
208
|
});
|
|
213
209
|
/**
|
|
@@ -236,6 +232,7 @@ var arrowStyles = (0, _tailwindvariants.tv)({
|
|
|
236
232
|
* @param {boolean} [props.hasUnderline=false] - Whether the activator should have an underline.
|
|
237
233
|
* @param {number | boolean} [props.zIndexOverride] - Override for the z-index of the tooltip.
|
|
238
234
|
* @param {"inline" | "inline-block" | "block"} [props.display="inline-block"] - The display property of the tooltip container.
|
|
235
|
+
* @param {string} [props.className] - Additional class name for the tooltip container.
|
|
239
236
|
*
|
|
240
237
|
* @returns {React.ReactElement} The rendered Tooltip component.
|
|
241
238
|
*
|
|
@@ -258,7 +255,7 @@ var arrowStyles = (0, _tailwindvariants.tv)({
|
|
|
258
255
|
* </Tooltip>
|
|
259
256
|
*/ function Tooltip() {
|
|
260
257
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
261
|
-
var _props_display = props.display, display = _props_display === void 0 ? "inline-block" : _props_display, children = props.children, content = props.content, _props_dismissOnMouseOut = props.dismissOnMouseOut, dismissOnMouseOut = _props_dismissOnMouseOut === void 0 ? true : _props_dismissOnMouseOut, _props_dismissOnActivatorClick = props.dismissOnActivatorClick, dismissOnActivatorClick = _props_dismissOnActivatorClick === void 0 ? true : _props_dismissOnActivatorClick, _props_preferredPosition = props.preferredPosition, preferredPosition = _props_preferredPosition === void 0 ? "below" : _props_preferredPosition, _props_alignment = props.alignment, alignment = _props_alignment === void 0 ? "center" : _props_alignment, _props_hoverDelay = props.hoverDelay, hoverDelay = _props_hoverDelay === void 0 ? 0 : _props_hoverDelay, _props_hasUnderline = props.hasUnderline, hasUnderline = _props_hasUnderline === void 0 ? false : _props_hasUnderline, zIndexOverride = props.zIndexOverride;
|
|
258
|
+
var _props_display = props.display, display = _props_display === void 0 ? "inline-block" : _props_display, children = props.children, content = props.content, _props_dismissOnMouseOut = props.dismissOnMouseOut, dismissOnMouseOut = _props_dismissOnMouseOut === void 0 ? true : _props_dismissOnMouseOut, _props_dismissOnActivatorClick = props.dismissOnActivatorClick, dismissOnActivatorClick = _props_dismissOnActivatorClick === void 0 ? true : _props_dismissOnActivatorClick, _props_preferredPosition = props.preferredPosition, preferredPosition = _props_preferredPosition === void 0 ? "below" : _props_preferredPosition, _props_alignment = props.alignment, alignment = _props_alignment === void 0 ? "center" : _props_alignment, _props_hoverDelay = props.hoverDelay, hoverDelay = _props_hoverDelay === void 0 ? 0 : _props_hoverDelay, _props_hasUnderline = props.hasUnderline, hasUnderline = _props_hasUnderline === void 0 ? false : _props_hasUnderline, zIndexOverride = props.zIndexOverride, className = props.className;
|
|
262
259
|
var activatorRef = (0, _react.useRef)(null);
|
|
263
260
|
var tooltipRef = (0, _react.useRef)(null);
|
|
264
261
|
var _useState = _sliced_to_array((0, _react.useState)({
|
|
@@ -270,6 +267,7 @@ var arrowStyles = (0, _tailwindvariants.tv)({
|
|
|
270
267
|
var classes = styles({
|
|
271
268
|
hasUnderline: hasUnderline,
|
|
272
269
|
display: display,
|
|
270
|
+
className: className,
|
|
273
271
|
alignment: alignment
|
|
274
272
|
});
|
|
275
273
|
var wrapperClasses = wrapperStyles({
|
|
@@ -360,9 +358,10 @@ var arrowStyles = (0, _tailwindvariants.tv)({
|
|
|
360
358
|
children: item.content
|
|
361
359
|
}, key);
|
|
362
360
|
} else if (item.type == "list") {
|
|
363
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
361
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Stack.default, {
|
|
364
362
|
inlineAlign: "start",
|
|
365
363
|
align: "start",
|
|
364
|
+
gap: "0",
|
|
366
365
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_List.default, {
|
|
367
366
|
type: "bullet",
|
|
368
367
|
children: item.content.map(function(item) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -45,6 +45,9 @@ _export(exports, {
|
|
|
45
45
|
get ChoiceList () {
|
|
46
46
|
return _ChoiceList.default;
|
|
47
47
|
},
|
|
48
|
+
get Code () {
|
|
49
|
+
return _Code.default;
|
|
50
|
+
},
|
|
48
51
|
get Collapsible () {
|
|
49
52
|
return _Collapsible.default;
|
|
50
53
|
},
|
|
@@ -217,6 +220,7 @@ var _ButtonGroup = /*#__PURE__*/ _interop_require_default(require("./components/
|
|
|
217
220
|
var _Card = /*#__PURE__*/ _interop_require_default(require("./components/Card"));
|
|
218
221
|
var _Checkbox = /*#__PURE__*/ _interop_require_default(require("./components/Checkbox"));
|
|
219
222
|
var _ChoiceList = /*#__PURE__*/ _interop_require_default(require("./components/ChoiceList"));
|
|
223
|
+
var _Code = /*#__PURE__*/ _interop_require_default(require("./components/Code"));
|
|
220
224
|
var _Collapsible = /*#__PURE__*/ _interop_require_default(require("./components/Collapsible"));
|
|
221
225
|
var _ColorField = /*#__PURE__*/ _interop_require_default(require("./components/ColorField"));
|
|
222
226
|
var _ContextualSaveBar = /*#__PURE__*/ _interop_require_default(require("./components/ContextualSaveBar"));
|
|
@@ -36,6 +36,12 @@ _export(exports, {
|
|
|
36
36
|
get WithHelpText () {
|
|
37
37
|
return WithHelpText;
|
|
38
38
|
},
|
|
39
|
+
get WithReactElementLabel () {
|
|
40
|
+
return WithReactElementLabel;
|
|
41
|
+
},
|
|
42
|
+
get WithReactElementLabelAndHelpText () {
|
|
43
|
+
return WithReactElementLabelAndHelpText;
|
|
44
|
+
},
|
|
39
45
|
get default () {
|
|
40
46
|
return _default;
|
|
41
47
|
}
|
|
@@ -44,6 +50,7 @@ var _jsxruntime = require("react/jsx-runtime");
|
|
|
44
50
|
var _Card = /*#__PURE__*/ _interop_require_default(require("../components/Card.js"));
|
|
45
51
|
var _Checkbox = /*#__PURE__*/ _interop_require_default(require("../components/Checkbox.js"));
|
|
46
52
|
var _Stack = /*#__PURE__*/ _interop_require_default(require("../components/Stack.js"));
|
|
53
|
+
var _Badge = /*#__PURE__*/ _interop_require_default(require("../components/Badge.js"));
|
|
47
54
|
var _transformers = require("../utilities/transformers.js");
|
|
48
55
|
function _interop_require_default(obj) {
|
|
49
56
|
return obj && obj.__esModule ? obj : {
|
|
@@ -79,7 +86,7 @@ var _default = {
|
|
|
79
86
|
argTypes: {
|
|
80
87
|
label: {
|
|
81
88
|
control: 'text',
|
|
82
|
-
description: 'The
|
|
89
|
+
description: 'The label for the checkbox. Can be a string or a React element.'
|
|
83
90
|
},
|
|
84
91
|
checked: {
|
|
85
92
|
control: 'boolean',
|
|
@@ -264,3 +271,167 @@ var MultipleCheckboxes = {
|
|
|
264
271
|
}
|
|
265
272
|
}
|
|
266
273
|
};
|
|
274
|
+
var WithReactElementLabel = {
|
|
275
|
+
render: function() {
|
|
276
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
277
|
+
gap: "md",
|
|
278
|
+
children: [
|
|
279
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
280
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
281
|
+
horizontal: true,
|
|
282
|
+
gap: "xs",
|
|
283
|
+
blockAlign: "center",
|
|
284
|
+
children: [
|
|
285
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
286
|
+
children: "Premium Feature"
|
|
287
|
+
}),
|
|
288
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
289
|
+
size: "small",
|
|
290
|
+
tone: "success",
|
|
291
|
+
children: "Pro"
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
}),
|
|
295
|
+
onChange: function(checked) {
|
|
296
|
+
return console.log('Premium feature:', checked);
|
|
297
|
+
}
|
|
298
|
+
}),
|
|
299
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
300
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
301
|
+
horizontal: true,
|
|
302
|
+
gap: "xs",
|
|
303
|
+
blockAlign: "center",
|
|
304
|
+
children: [
|
|
305
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
306
|
+
children: "Beta Access"
|
|
307
|
+
}),
|
|
308
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
309
|
+
size: "small",
|
|
310
|
+
tone: "attention",
|
|
311
|
+
children: "Beta"
|
|
312
|
+
})
|
|
313
|
+
]
|
|
314
|
+
}),
|
|
315
|
+
checked: true,
|
|
316
|
+
onChange: function(checked) {
|
|
317
|
+
return console.log('Beta access:', checked);
|
|
318
|
+
}
|
|
319
|
+
}),
|
|
320
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
321
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
322
|
+
horizontal: true,
|
|
323
|
+
gap: "xs",
|
|
324
|
+
blockAlign: "center",
|
|
325
|
+
children: [
|
|
326
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
327
|
+
children: "Enterprise Only"
|
|
328
|
+
}),
|
|
329
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
330
|
+
size: "small",
|
|
331
|
+
tone: "info",
|
|
332
|
+
children: "Enterprise"
|
|
333
|
+
})
|
|
334
|
+
]
|
|
335
|
+
}),
|
|
336
|
+
onChange: function(checked) {
|
|
337
|
+
return console.log('Enterprise only:', checked);
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
]
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
parameters: {
|
|
344
|
+
docs: {
|
|
345
|
+
description: {
|
|
346
|
+
story: 'Checkbox labels can be React elements, allowing for rich content like badges alongside text.'
|
|
347
|
+
},
|
|
348
|
+
source: {
|
|
349
|
+
transform: _transformers.transformStorySource
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var WithReactElementLabelAndHelpText = {
|
|
355
|
+
render: function() {
|
|
356
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
357
|
+
gap: "md",
|
|
358
|
+
children: [
|
|
359
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
360
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
361
|
+
horizontal: true,
|
|
362
|
+
gap: "xs",
|
|
363
|
+
blockAlign: "center",
|
|
364
|
+
children: [
|
|
365
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
366
|
+
children: "Advanced Analytics"
|
|
367
|
+
}),
|
|
368
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
369
|
+
size: "small",
|
|
370
|
+
tone: "info",
|
|
371
|
+
children: "Pro"
|
|
372
|
+
})
|
|
373
|
+
]
|
|
374
|
+
}),
|
|
375
|
+
helpText: "Get detailed insights into your data with advanced visualization tools",
|
|
376
|
+
onChange: function(checked) {
|
|
377
|
+
return console.log('Advanced analytics:', checked);
|
|
378
|
+
}
|
|
379
|
+
}),
|
|
380
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
381
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
382
|
+
horizontal: true,
|
|
383
|
+
gap: "xs",
|
|
384
|
+
blockAlign: "center",
|
|
385
|
+
children: [
|
|
386
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
387
|
+
children: "API Access"
|
|
388
|
+
}),
|
|
389
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
390
|
+
size: "small",
|
|
391
|
+
tone: "attention",
|
|
392
|
+
children: "Beta"
|
|
393
|
+
})
|
|
394
|
+
]
|
|
395
|
+
}),
|
|
396
|
+
helpText: "Enable programmatic access to your account (currently in beta testing)",
|
|
397
|
+
checked: true,
|
|
398
|
+
onChange: function(checked) {
|
|
399
|
+
return console.log('API access:', checked);
|
|
400
|
+
}
|
|
401
|
+
}),
|
|
402
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Checkbox.default, {
|
|
403
|
+
label: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_Stack.default, {
|
|
404
|
+
horizontal: true,
|
|
405
|
+
gap: "xs",
|
|
406
|
+
blockAlign: "center",
|
|
407
|
+
children: [
|
|
408
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
409
|
+
children: "Priority Support"
|
|
410
|
+
}),
|
|
411
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Badge.default, {
|
|
412
|
+
size: "small",
|
|
413
|
+
tone: "success",
|
|
414
|
+
children: "Enterprise"
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
}),
|
|
418
|
+
helpText: "Get 24/7 dedicated support from our enterprise team",
|
|
419
|
+
disabled: true,
|
|
420
|
+
onChange: function(checked) {
|
|
421
|
+
return console.log('Priority support:', checked);
|
|
422
|
+
}
|
|
423
|
+
})
|
|
424
|
+
]
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
parameters: {
|
|
428
|
+
docs: {
|
|
429
|
+
description: {
|
|
430
|
+
story: 'React element labels work seamlessly with help text, error states, and disabled states.'
|
|
431
|
+
},
|
|
432
|
+
source: {
|
|
433
|
+
transform: _transformers.transformStorySource
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|