@heymantle/litho 0.0.10 → 0.0.13
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/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/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/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/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/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 +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
3
|
import Spinner from "./Spinner.js";
|
|
4
|
-
import
|
|
4
|
+
import Stack from "./Stack.js";
|
|
5
5
|
var styles = tv({
|
|
6
6
|
base: "Litho-ResourceList flex flex-col min-w-72",
|
|
7
7
|
variants: {
|
|
@@ -37,7 +37,7 @@ var styles = tv({
|
|
|
37
37
|
small: "2",
|
|
38
38
|
large: "4"
|
|
39
39
|
};
|
|
40
|
-
return /*#__PURE__*/ _jsx(
|
|
40
|
+
return /*#__PURE__*/ _jsx(Stack, {
|
|
41
41
|
gap: gapMap[gap],
|
|
42
42
|
className: styles({
|
|
43
43
|
divider: divider
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
43
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
44
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
45
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
46
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
|
+
}
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { useRef, useEffect, useLayoutEffect, useCallback, useState } from "react";
|
|
50
|
+
import { CancelMinor } from "@shopify/polaris-icons";
|
|
51
|
+
import { tv } from "tailwind-variants";
|
|
52
|
+
import Button from "./Button.js";
|
|
53
|
+
import Text from "./Text.js";
|
|
54
|
+
import Spinner from "./Spinner.js";
|
|
55
|
+
import Tooltip from "./Tooltip.js";
|
|
56
|
+
var AVG_CHAR_WIDTH = 5.5;
|
|
57
|
+
var tabStyles = tv({
|
|
58
|
+
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",
|
|
59
|
+
variants: {
|
|
60
|
+
isActive: {
|
|
61
|
+
true: "bg-surface-lowest",
|
|
62
|
+
false: "bg-transparent hover:bg-surface-lower"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: {
|
|
66
|
+
isActive: false
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var textStyles = tv({
|
|
70
|
+
base: "leading-none break-all",
|
|
71
|
+
variants: {
|
|
72
|
+
isActive: {
|
|
73
|
+
true: "",
|
|
74
|
+
false: "text-low"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var gradientOverlayStyles = tv({
|
|
79
|
+
base: "sm:opacity-0 sm:group-hover:opacity-100 transition-opacity absolute pointer-events-none pointer-coarse:hidden",
|
|
80
|
+
variants: {
|
|
81
|
+
isActive: {
|
|
82
|
+
true: "bg-surface-lowest",
|
|
83
|
+
false: "bg-surface-lower"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
// Component to handle truncation detection and tooltip
|
|
88
|
+
function TabTitle(param) {
|
|
89
|
+
var title = param.title, isActive = param.isActive, tabContainerRef = param.tabContainerRef;
|
|
90
|
+
var _useState = _sliced_to_array(useState(false), 2), shouldShowTooltip = _useState[0], setShouldShowTooltip = _useState[1];
|
|
91
|
+
useLayoutEffect(function() {
|
|
92
|
+
if (!title || !(tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current)) {
|
|
93
|
+
setShouldShowTooltip(false);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
var checkOverflow = function() {
|
|
97
|
+
if (!(tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current)) return;
|
|
98
|
+
var tabElement = tabContainerRef.current;
|
|
99
|
+
if (!tabElement) return;
|
|
100
|
+
// Get the actual tab width
|
|
101
|
+
var tabWidth = tabElement.offsetWidth;
|
|
102
|
+
var estimatedCharCapacity = Math.floor(tabWidth / AVG_CHAR_WIDTH);
|
|
103
|
+
// Show tooltip if title length exceeds estimated capacity
|
|
104
|
+
setShouldShowTooltip(title.length > estimatedCharCapacity);
|
|
105
|
+
};
|
|
106
|
+
var resizeObserver = null;
|
|
107
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
108
|
+
var rafId = requestAnimationFrame(function() {
|
|
109
|
+
checkOverflow();
|
|
110
|
+
// Watch for size changes
|
|
111
|
+
if (tabContainerRef === null || tabContainerRef === void 0 ? void 0 : tabContainerRef.current) {
|
|
112
|
+
resizeObserver = new ResizeObserver(checkOverflow);
|
|
113
|
+
resizeObserver.observe(tabContainerRef.current);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return function() {
|
|
117
|
+
cancelAnimationFrame(rafId);
|
|
118
|
+
if (resizeObserver) {
|
|
119
|
+
resizeObserver.disconnect();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, [
|
|
123
|
+
title,
|
|
124
|
+
tabContainerRef
|
|
125
|
+
]);
|
|
126
|
+
var textElement = /*#__PURE__*/ _jsx("div", {
|
|
127
|
+
className: "overflow-hidden",
|
|
128
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
129
|
+
variant: "bodyXs",
|
|
130
|
+
className: textStyles({
|
|
131
|
+
isActive: isActive
|
|
132
|
+
}),
|
|
133
|
+
clampLines: 1,
|
|
134
|
+
children: title
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
// Only show tooltip if text is likely truncated based on character count vs tab width
|
|
138
|
+
if (shouldShowTooltip) {
|
|
139
|
+
return /*#__PURE__*/ _jsx(Tooltip, {
|
|
140
|
+
content: title,
|
|
141
|
+
className: "align-top",
|
|
142
|
+
children: textElement
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return textElement;
|
|
146
|
+
}
|
|
147
|
+
function TabNavigation() {
|
|
148
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
149
|
+
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;
|
|
150
|
+
var scrollContainerRef = useRef(null);
|
|
151
|
+
var tabRefsMap = useRef(new Map());
|
|
152
|
+
// Function to scroll the active tab into view and center it
|
|
153
|
+
var scrollToActiveTab = useCallback(function() {
|
|
154
|
+
if (!scrollContainerRef.current || !activeTabId) return;
|
|
155
|
+
var container = scrollContainerRef.current;
|
|
156
|
+
var activeTabElement = container.querySelector('[data-tab-id="'.concat(activeTabId, '"]'));
|
|
157
|
+
if (!activeTabElement) return;
|
|
158
|
+
// Calculate the scroll position to center the tab
|
|
159
|
+
var tabOffsetLeft = activeTabElement.offsetLeft;
|
|
160
|
+
var tabWidth = activeTabElement.offsetWidth;
|
|
161
|
+
var containerWidth = container.offsetWidth;
|
|
162
|
+
// Center the tab in the container: position of tab - (container width - tab width) / 2
|
|
163
|
+
var scrollLeft = tabOffsetLeft - (containerWidth - tabWidth) / 2;
|
|
164
|
+
// Calculate max scroll to prevent over-scrolling
|
|
165
|
+
var maxScroll = container.scrollWidth - containerWidth;
|
|
166
|
+
container.scrollTo({
|
|
167
|
+
left: Math.max(0, Math.min(scrollLeft, maxScroll)),
|
|
168
|
+
behavior: 'smooth'
|
|
169
|
+
});
|
|
170
|
+
}, [
|
|
171
|
+
activeTabId
|
|
172
|
+
]);
|
|
173
|
+
// Scroll to active tab when it changes or when tabs are updated
|
|
174
|
+
useEffect(function() {
|
|
175
|
+
if (!activeTabId || tabs.length === 0) return;
|
|
176
|
+
// Use double requestAnimationFrame to ensure DOM is fully updated and rendered
|
|
177
|
+
requestAnimationFrame(function() {
|
|
178
|
+
requestAnimationFrame(function() {
|
|
179
|
+
scrollToActiveTab();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}, [
|
|
183
|
+
activeTabId,
|
|
184
|
+
tabs,
|
|
185
|
+
scrollToActiveTab
|
|
186
|
+
]);
|
|
187
|
+
// Clean up refs for removed tabs
|
|
188
|
+
useEffect(function() {
|
|
189
|
+
var currentTabIds = new Set(tabs.map(function(tab) {
|
|
190
|
+
return tab.id;
|
|
191
|
+
}));
|
|
192
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
193
|
+
try {
|
|
194
|
+
for(var _iterator = tabRefsMap.current[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
195
|
+
var _step_value = _sliced_to_array(_step.value, 1), tabId = _step_value[0];
|
|
196
|
+
if (!currentTabIds.has(tabId)) {
|
|
197
|
+
tabRefsMap.current.delete(tabId);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch (err) {
|
|
201
|
+
_didIteratorError = true;
|
|
202
|
+
_iteratorError = err;
|
|
203
|
+
} finally{
|
|
204
|
+
try {
|
|
205
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
206
|
+
_iterator.return();
|
|
207
|
+
}
|
|
208
|
+
} finally{
|
|
209
|
+
if (_didIteratorError) {
|
|
210
|
+
throw _iteratorError;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}, [
|
|
215
|
+
tabs
|
|
216
|
+
]);
|
|
217
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
218
|
+
className: "Litho-TabNavigation ".concat(className),
|
|
219
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
220
|
+
ref: scrollContainerRef,
|
|
221
|
+
className: "scroll-container flex overflow-x-scroll overflow-y-hidden items-center px-1 pt-1 w-full gap-0.5 bg-tint-2",
|
|
222
|
+
children: tabs.map(function(tab) {
|
|
223
|
+
var isActive = activeTabId === tab.id;
|
|
224
|
+
// Get or create ref for this tab
|
|
225
|
+
if (!tabRefsMap.current.has(tab.id)) {
|
|
226
|
+
tabRefsMap.current.set(tab.id, {
|
|
227
|
+
current: null
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
var tabRef = tabRefsMap.current.get(tab.id);
|
|
231
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
232
|
+
ref: function(el) {
|
|
233
|
+
tabRef.current = el;
|
|
234
|
+
},
|
|
235
|
+
"data-tab-id": tab.id,
|
|
236
|
+
className: tabStyles({
|
|
237
|
+
isActive: isActive
|
|
238
|
+
}),
|
|
239
|
+
onClick: function() {
|
|
240
|
+
return onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(tab.id);
|
|
241
|
+
},
|
|
242
|
+
children: [
|
|
243
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
244
|
+
className: "h-5 relative",
|
|
245
|
+
children: [
|
|
246
|
+
tab.loading ? /*#__PURE__*/ _jsx("div", {
|
|
247
|
+
className: "flex items-center justify-center h-5",
|
|
248
|
+
children: /*#__PURE__*/ _jsx(Spinner, {
|
|
249
|
+
size: "small"
|
|
250
|
+
})
|
|
251
|
+
}) : /*#__PURE__*/ _jsx(TabTitle, {
|
|
252
|
+
title: tab.title,
|
|
253
|
+
isActive: isActive,
|
|
254
|
+
tabContainerRef: tabRef
|
|
255
|
+
}),
|
|
256
|
+
/*#__PURE__*/ _jsx("div", {
|
|
257
|
+
className: "".concat(gradientOverlayStyles({
|
|
258
|
+
isActive: isActive
|
|
259
|
+
}), " right-[-4px] top-[-4px] w-4.5 h-6")
|
|
260
|
+
}),
|
|
261
|
+
/*#__PURE__*/ _jsx("div", {
|
|
262
|
+
className: "".concat(gradientOverlayStyles({
|
|
263
|
+
isActive: isActive
|
|
264
|
+
}), " w-2 h-6 bg-gradient-to-l ").concat(isActive ? 'from-surface-lowest' : 'from-surface-lower', " right-[14px] top-[-4px]")
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
}),
|
|
268
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
269
|
+
size: "mini",
|
|
270
|
+
iconSize: "sm",
|
|
271
|
+
plain: true,
|
|
272
|
+
icon: CancelMinor,
|
|
273
|
+
onClick: function(e) {
|
|
274
|
+
e.stopPropagation();
|
|
275
|
+
onTabClose === null || onTabClose === void 0 ? void 0 : onTabClose(tab.id);
|
|
276
|
+
},
|
|
277
|
+
className: "sm:opacity-0 sm:group-hover:opacity-100 transition-all !absolute right-[3px] top-[4px] ".concat(isActive ? 'bg-surface-lowest' : 'bg-surface-lower')
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}, tab.id);
|
|
281
|
+
})
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
export default TabNavigation;
|
|
@@ -46,7 +46,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
46
46
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
47
|
}
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
-
import { CancelSmallMinor, CaretDownMinor, CaretUpMinor, CircleAlertMajor } from "@shopify/polaris-icons";
|
|
49
|
+
import { CancelSmallMinor, CaretDownMinor, CaretUpMinor, CircleAlertMajor, MagicMajor } from "@shopify/polaris-icons";
|
|
50
50
|
import React, { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
51
51
|
import { tv } from "tailwind-variants";
|
|
52
52
|
import Button from "./Button.js";
|
|
@@ -508,6 +508,9 @@ var clearButtonStyles = tv({
|
|
|
508
508
|
}),
|
|
509
509
|
labelAction && /*#__PURE__*/ _jsx(Link, {
|
|
510
510
|
onClick: labelAction.onAction,
|
|
511
|
+
insight: labelAction.insight,
|
|
512
|
+
icon: labelAction.insight ? MagicMajor : undefined,
|
|
513
|
+
color: labelAction.insight ? "insight" : undefined,
|
|
511
514
|
removeUnderline: true,
|
|
512
515
|
children: labelAction.content
|
|
513
516
|
})
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { cloneElement, isValidElement, useMemo } from "react";
|
|
3
3
|
import { tv } from "tailwind-variants";
|
|
4
4
|
import Icon from "./Icon.js";
|
|
5
|
-
import { AlertMinor, CancelMinor, InfoMinor } from "@shopify/polaris-icons";
|
|
5
|
+
import { AlertMinor, CancelMinor, InfoMinor, MagicMajor } from "@shopify/polaris-icons";
|
|
6
6
|
var styles = tv({
|
|
7
7
|
base: "Litho-Tip relative flex rounded-md p-2",
|
|
8
8
|
variants: {
|
|
@@ -78,6 +78,9 @@ var statusHelpers = {
|
|
|
78
78
|
},
|
|
79
79
|
attention: {},
|
|
80
80
|
highlight: {},
|
|
81
|
+
insight: {
|
|
82
|
+
icon: MagicMajor
|
|
83
|
+
},
|
|
81
84
|
neutral: {}
|
|
82
85
|
};
|
|
83
86
|
/**
|
|
@@ -82,7 +82,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
82
82
|
import { createPortal } from "react-dom";
|
|
83
83
|
import { tv } from "tailwind-variants";
|
|
84
84
|
import Text from "./Text.js";
|
|
85
|
-
import
|
|
85
|
+
import Stack from "./Stack.js";
|
|
86
86
|
import List from "./List.js";
|
|
87
87
|
import Icon from "./Icon.js";
|
|
88
88
|
import { CircleInformationMajor } from "@shopify/polaris-icons";
|
|
@@ -92,7 +92,9 @@ var styles = tv({
|
|
|
92
92
|
display: {
|
|
93
93
|
inline: "inline",
|
|
94
94
|
"inline-block": "inline-block",
|
|
95
|
-
block: "block"
|
|
95
|
+
block: "block",
|
|
96
|
+
flex: "flex",
|
|
97
|
+
"inline-flex": "inline-flex"
|
|
96
98
|
},
|
|
97
99
|
hasUnderline: {
|
|
98
100
|
true: "Litho-TooltipContainer--HasUnderline border-b border-dotted",
|
|
@@ -124,7 +126,7 @@ var wrapperStyles = tv({
|
|
|
124
126
|
}
|
|
125
127
|
});
|
|
126
128
|
var tooltipStyles = tv({
|
|
127
|
-
base: "Litho-Tooltip
|
|
129
|
+
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",
|
|
128
130
|
variants: {
|
|
129
131
|
alignment: {
|
|
130
132
|
center: "text-center",
|
|
@@ -137,21 +139,15 @@ var tooltipStyles = tv({
|
|
|
137
139
|
}
|
|
138
140
|
});
|
|
139
141
|
var arrowStyles = tv({
|
|
140
|
-
base: "Litho-TooltipArrow absolute w-0 h-0 border-l-transparent border-r-transparent border-l-6 border-r-6",
|
|
142
|
+
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",
|
|
141
143
|
variants: {
|
|
142
144
|
preferredPosition: {
|
|
143
145
|
above: "Litho-TooltipArrow--Above mb-0.5 bottom-full border-b-0 border-t-6 border-t-surface-alternate",
|
|
144
146
|
below: "Litho-TooltipArrow--Below mt-0.5 top-full border-t-0 border-b-6 border-b-surface-alternate"
|
|
145
|
-
},
|
|
146
|
-
alignment: {
|
|
147
|
-
center: "left-1/2 -translate-x-1/2",
|
|
148
|
-
left: "left-2.5",
|
|
149
|
-
right: "right-2.5"
|
|
150
147
|
}
|
|
151
148
|
},
|
|
152
149
|
defaultVariants: {
|
|
153
|
-
preferredPosition: "below"
|
|
154
|
-
alignment: "center"
|
|
150
|
+
preferredPosition: "below"
|
|
155
151
|
}
|
|
156
152
|
});
|
|
157
153
|
/**
|
|
@@ -180,6 +176,7 @@ var arrowStyles = tv({
|
|
|
180
176
|
* @param {boolean} [props.hasUnderline=false] - Whether the activator should have an underline.
|
|
181
177
|
* @param {number | boolean} [props.zIndexOverride] - Override for the z-index of the tooltip.
|
|
182
178
|
* @param {"inline" | "inline-block" | "block"} [props.display="inline-block"] - The display property of the tooltip container.
|
|
179
|
+
* @param {string} [props.className] - Additional class name for the tooltip container.
|
|
183
180
|
*
|
|
184
181
|
* @returns {React.ReactElement} The rendered Tooltip component.
|
|
185
182
|
*
|
|
@@ -202,7 +199,7 @@ var arrowStyles = tv({
|
|
|
202
199
|
* </Tooltip>
|
|
203
200
|
*/ function Tooltip() {
|
|
204
201
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
205
|
-
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;
|
|
202
|
+
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;
|
|
206
203
|
var activatorRef = useRef(null);
|
|
207
204
|
var tooltipRef = useRef(null);
|
|
208
205
|
var _useState = _sliced_to_array(useState({
|
|
@@ -214,6 +211,7 @@ var arrowStyles = tv({
|
|
|
214
211
|
var classes = styles({
|
|
215
212
|
hasUnderline: hasUnderline,
|
|
216
213
|
display: display,
|
|
214
|
+
className: className,
|
|
217
215
|
alignment: alignment
|
|
218
216
|
});
|
|
219
217
|
var wrapperClasses = wrapperStyles({
|
|
@@ -304,9 +302,10 @@ var arrowStyles = tv({
|
|
|
304
302
|
children: item.content
|
|
305
303
|
}, key);
|
|
306
304
|
} else if (item.type == "list") {
|
|
307
|
-
return /*#__PURE__*/ _jsx(
|
|
305
|
+
return /*#__PURE__*/ _jsx(Stack, {
|
|
308
306
|
inlineAlign: "start",
|
|
309
307
|
align: "start",
|
|
308
|
+
gap: "0",
|
|
310
309
|
children: /*#__PURE__*/ _jsx(List, {
|
|
311
310
|
type: "bullet",
|
|
312
311
|
children: item.content.map(function(item) {
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { default as ButtonGroup } from "./components/ButtonGroup.js";
|
|
|
10
10
|
export { default as Card } from "./components/Card.js";
|
|
11
11
|
export { default as Checkbox } from "./components/Checkbox.js";
|
|
12
12
|
export { default as ChoiceList } from "./components/ChoiceList.js";
|
|
13
|
+
export { default as Code } from "./components/Code.js";
|
|
13
14
|
export { default as Collapsible } from "./components/Collapsible.js";
|
|
14
15
|
export { default as ColorField } from "./components/ColorField.js";
|
|
15
16
|
export { default as ContextualSaveBar } from "./components/ContextualSaveBar.js";
|