@heymantle/litho 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/components/ActionList.js +267 -0
- package/dist/cjs/components/AnnouncementBar.js +73 -0
- package/dist/cjs/components/AppProvider.js +245 -0
- package/dist/cjs/components/Autocomplete.js +351 -0
- package/dist/cjs/components/Badge.js +234 -0
- package/dist/cjs/components/Banner.js +264 -0
- package/dist/cjs/components/Box.js +247 -0
- package/dist/cjs/components/Button.js +1018 -0
- package/dist/cjs/components/ButtonGroup.js +196 -0
- package/dist/cjs/components/Card.js +593 -0
- package/dist/cjs/components/Checkbox.js +175 -0
- package/dist/cjs/components/ChoiceList.js +160 -0
- package/dist/cjs/components/Collapsible.js +42 -0
- package/dist/cjs/components/ColorField.js +159 -0
- package/dist/cjs/components/ContextualSaveBar.js +53 -0
- package/dist/cjs/components/DatePicker.js +547 -0
- package/dist/cjs/components/Divider.js +50 -0
- package/dist/cjs/components/DropZone.js +547 -0
- package/dist/cjs/components/EmptyState.js +111 -0
- package/dist/cjs/components/Filters.js +874 -0
- package/dist/cjs/components/FooterHelp.js +48 -0
- package/dist/cjs/components/Form.js +44 -0
- package/dist/cjs/components/Frame.js +386 -0
- package/dist/cjs/components/FrameSaveBar.js +239 -0
- package/dist/cjs/components/Grid.js +151 -0
- package/dist/cjs/components/HorizontalStack.js +180 -0
- package/dist/cjs/components/Icon.js +346 -0
- package/dist/cjs/components/Image.js +191 -0
- package/dist/cjs/components/InlineError.js +57 -0
- package/dist/cjs/components/Label.js +78 -0
- package/dist/cjs/components/Layout.js +228 -0
- package/dist/cjs/components/LayoutSection.js +133 -0
- package/dist/cjs/components/Link.js +128 -0
- package/dist/cjs/components/List.js +69 -0
- package/dist/cjs/components/Listbox.js +211 -0
- package/dist/cjs/components/Loading.js +103 -0
- package/dist/cjs/components/Modal.js +449 -0
- package/dist/cjs/components/Navigation.js +331 -0
- package/dist/cjs/components/Page.js +529 -0
- package/dist/cjs/components/Pagination.js +109 -0
- package/dist/cjs/components/Pane.js +128 -0
- package/dist/cjs/components/Popover.js +365 -0
- package/dist/cjs/components/PopoverManager.js +34 -0
- package/dist/cjs/components/ProgressBar.js +124 -0
- package/dist/cjs/components/RadioButton.js +172 -0
- package/dist/cjs/components/RadioButtonCard.js +193 -0
- package/dist/cjs/components/RangeSlider.js +235 -0
- package/dist/cjs/components/ResourceList.js +105 -0
- package/dist/cjs/components/Select.js +300 -0
- package/dist/cjs/components/SkeletonText.js +130 -0
- package/dist/cjs/components/Spinner.js +72 -0
- package/dist/cjs/components/Table.js +1184 -0
- package/dist/cjs/components/Tabs.js +421 -0
- package/dist/cjs/components/Tag.js +165 -0
- package/dist/cjs/components/Text.js +274 -0
- package/dist/cjs/components/TextField.js +584 -0
- package/dist/cjs/components/Thumbnail.js +73 -0
- package/dist/cjs/components/TimePicker.js +23 -0
- package/dist/cjs/components/Tip.js +220 -0
- package/dist/cjs/components/Tooltip.js +431 -0
- package/dist/cjs/components/TopBar.js +210 -0
- package/dist/cjs/components/VerticalStack.js +161 -0
- package/dist/cjs/index.js +308 -0
- package/dist/cjs/styles/Table.js +591 -0
- package/dist/cjs/utilities/dates.js +339 -0
- package/dist/cjs/utilities/useIndexResourceState.js +175 -0
- package/dist/cjs/utilities/useMounted.js +67 -0
- package/dist/cjs/utilities/useTableScrollState.js +142 -0
- package/dist/esm/components/ActionList.js +216 -0
- package/dist/esm/components/AnnouncementBar.js +63 -0
- package/dist/esm/components/AppProvider.js +185 -0
- package/dist/esm/components/Autocomplete.js +300 -0
- package/dist/esm/components/Badge.js +225 -0
- package/dist/esm/components/Banner.js +254 -0
- package/dist/esm/components/Box.js +238 -0
- package/dist/esm/components/Button.js +967 -0
- package/dist/esm/components/ButtonGroup.js +137 -0
- package/dist/esm/components/Card.js +537 -0
- package/dist/esm/components/Checkbox.js +165 -0
- package/dist/esm/components/ChoiceList.js +145 -0
- package/dist/esm/components/Collapsible.js +32 -0
- package/dist/esm/components/ColorField.js +149 -0
- package/dist/esm/components/ContextualSaveBar.js +43 -0
- package/dist/esm/components/DatePicker.js +532 -0
- package/dist/esm/components/Divider.js +41 -0
- package/dist/esm/components/DropZone.js +537 -0
- package/dist/esm/components/EmptyState.js +101 -0
- package/dist/esm/components/Filters.js +823 -0
- package/dist/esm/components/FooterHelp.js +38 -0
- package/dist/esm/components/Form.js +35 -0
- package/dist/esm/components/Frame.js +376 -0
- package/dist/esm/components/FrameSaveBar.js +229 -0
- package/dist/esm/components/Grid.js +142 -0
- package/dist/esm/components/HorizontalStack.js +171 -0
- package/dist/esm/components/Icon.js +296 -0
- package/dist/esm/components/Image.js +141 -0
- package/dist/esm/components/InlineError.js +43 -0
- package/dist/esm/components/Label.js +63 -0
- package/dist/esm/components/Layout.js +164 -0
- package/dist/esm/components/LayoutSection.js +82 -0
- package/dist/esm/components/Link.js +119 -0
- package/dist/esm/components/List.js +61 -0
- package/dist/esm/components/Listbox.js +201 -0
- package/dist/esm/components/Loading.js +93 -0
- package/dist/esm/components/Modal.js +390 -0
- package/dist/esm/components/Navigation.js +321 -0
- package/dist/esm/components/Page.js +473 -0
- package/dist/esm/components/Pagination.js +99 -0
- package/dist/esm/components/Pane.js +118 -0
- package/dist/esm/components/Popover.js +350 -0
- package/dist/esm/components/PopoverManager.js +24 -0
- package/dist/esm/components/ProgressBar.js +114 -0
- package/dist/esm/components/RadioButton.js +157 -0
- package/dist/esm/components/RadioButtonCard.js +178 -0
- package/dist/esm/components/RangeSlider.js +225 -0
- package/dist/esm/components/ResourceList.js +95 -0
- package/dist/esm/components/Select.js +285 -0
- package/dist/esm/components/SkeletonText.js +120 -0
- package/dist/esm/components/Spinner.js +63 -0
- package/dist/esm/components/Table.js +1129 -0
- package/dist/esm/components/Tabs.js +366 -0
- package/dist/esm/components/Tag.js +151 -0
- package/dist/esm/components/Text.js +265 -0
- package/dist/esm/components/TextField.js +533 -0
- package/dist/esm/components/Thumbnail.js +63 -0
- package/dist/esm/components/TimePicker.js +13 -0
- package/dist/esm/components/Tip.js +169 -0
- package/dist/esm/components/Tooltip.js +380 -0
- package/dist/esm/components/TopBar.js +200 -0
- package/dist/esm/components/VerticalStack.js +152 -0
- package/dist/esm/index.js +61 -0
- package/dist/esm/styles/Table.js +581 -0
- package/dist/esm/utilities/dates.js +289 -0
- package/dist/esm/utilities/useIndexResourceState.js +158 -0
- package/dist/esm/utilities/useMounted.js +57 -0
- package/dist/esm/utilities/useTableScrollState.js +132 -0
- package/index.css +1137 -0
- package/package.json +53 -0
|
@@ -0,0 +1,366 @@
|
|
|
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 _define_property(obj, key, value) {
|
|
11
|
+
if (key in obj) {
|
|
12
|
+
Object.defineProperty(obj, key, {
|
|
13
|
+
value: value,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
obj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
function _iterable_to_array_limit(arr, i) {
|
|
24
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
25
|
+
if (_i == null) return;
|
|
26
|
+
var _arr = [];
|
|
27
|
+
var _n = true;
|
|
28
|
+
var _d = false;
|
|
29
|
+
var _s, _e;
|
|
30
|
+
try {
|
|
31
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
32
|
+
_arr.push(_s.value);
|
|
33
|
+
if (i && _arr.length === i) break;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = true;
|
|
37
|
+
_e = err;
|
|
38
|
+
} finally{
|
|
39
|
+
try {
|
|
40
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
41
|
+
} finally{
|
|
42
|
+
if (_d) throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
function _non_iterable_rest() {
|
|
48
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
+
}
|
|
50
|
+
function _object_spread(target) {
|
|
51
|
+
for(var i = 1; i < arguments.length; i++){
|
|
52
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_define_property(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
if (enumerableOnly) {
|
|
70
|
+
symbols = symbols.filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
keys.push.apply(keys, symbols);
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
function _object_spread_props(target, source) {
|
|
79
|
+
source = source != null ? source : {};
|
|
80
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
81
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
82
|
+
} else {
|
|
83
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
84
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
89
|
+
function _sliced_to_array(arr, i) {
|
|
90
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
91
|
+
}
|
|
92
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
93
|
+
if (!o) return;
|
|
94
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
95
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
96
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
97
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
98
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
99
|
+
}
|
|
100
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
101
|
+
import React, { useEffect, useLayoutEffect, useRef, useState, useCallback } from "react";
|
|
102
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
103
|
+
import { tv } from "tailwind-variants";
|
|
104
|
+
import ActionList from "./ActionList.js";
|
|
105
|
+
import Icon from "./Icon.js";
|
|
106
|
+
import Popover from "./Popover.js";
|
|
107
|
+
import { CaretDownMinor, CaretUpMinor } from "@shopify/polaris-icons";
|
|
108
|
+
import * as PolarisIcons from "@shopify/polaris-icons";
|
|
109
|
+
var styles = tv({
|
|
110
|
+
base: "Litho-Tabs flex overflow-x-hidden whitespace-nowrap",
|
|
111
|
+
variants: {
|
|
112
|
+
borderBottom: {
|
|
113
|
+
true: "border-b",
|
|
114
|
+
false: ""
|
|
115
|
+
},
|
|
116
|
+
padded: {
|
|
117
|
+
true: "p-2",
|
|
118
|
+
false: ""
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
var containerStyles = tv({
|
|
123
|
+
base: "Litho-Tabs__TabContainer flex flex-1 overflow-x-hidden whitespace-nowrap space-x-1"
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Tabs component that displays a set of tab items with selectable states.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} props - Component props.
|
|
129
|
+
* @param {Object[]} props.tabs - List of tabs to display.
|
|
130
|
+
* @param {string} props.tabs[].id - Unique identifier for the tab.
|
|
131
|
+
* @param {string} props.tabs[].content - Content or label to display for the tab.
|
|
132
|
+
* @param {string} [props.tabs[].icon] - Optional icon to display for the tab.
|
|
133
|
+
* @param {boolean} [props.tabs[].disclosure=false] - Whether the tab is part of a "More" disclosure group.
|
|
134
|
+
* @param {number} props.selected - Index of the currently selected tab.
|
|
135
|
+
* @param {Function} props.onSelect - Callback fired when a tab is selected, receives the tab's index.
|
|
136
|
+
* @param {boolean} [props.fullWidth=false] - Whether the tabs should expand to fit the container width.
|
|
137
|
+
* @param {string} [props.disclosureText="More"] - Label for the "More" disclosure tab.
|
|
138
|
+
* @param {boolean} [props.disclosure=false] - Whether the "More" disclosure is enabled.
|
|
139
|
+
* @param {boolean} [props.activeDisclosure=false] - Whether the "More" disclosure is currently active.
|
|
140
|
+
* @param {boolean} [props.padded=true] - If true, applies padding to the Tabs container.
|
|
141
|
+
* @param {boolean} [props.borderBottom=true] - If true, applies a bottom border to the Tabs container.
|
|
142
|
+
* @returns {JSX.Element} The Tabs component.
|
|
143
|
+
*/ function Tabs() {
|
|
144
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
145
|
+
var tmp = props.tabs, _tabs = tmp === void 0 ? [] : tmp, _selectedIndex = props.selected, onSelect = props.onSelect, fullWidth = props.fullWidth, _props_disclosureText = props.disclosureText, disclosureText = _props_disclosureText === void 0 ? "More" : _props_disclosureText, _props_disclosure = props.disclosure, disclosure = _props_disclosure === void 0 ? false : _props_disclosure, _props_activeDisclosure = props.activeDisclosure, activeDisclosure = _props_activeDisclosure === void 0 ? false : _props_activeDisclosure, _props_padded = props.padded, padded = _props_padded === void 0 ? true : _props_padded, _props_borderBottom = props.borderBottom, borderBottom = _props_borderBottom === void 0 ? true : _props_borderBottom;
|
|
146
|
+
var selectedIndex = parseInt(_selectedIndex);
|
|
147
|
+
var containerRef = useRef(null);
|
|
148
|
+
var disclosureRef = useRef(null);
|
|
149
|
+
var _useState = _sliced_to_array(useState([]), 2), tabs = _useState[0], setTabs = _useState[1];
|
|
150
|
+
var normalizedTabs = JSON.stringify(_tabs.map(function(param) {
|
|
151
|
+
var id = param.id, content = param.content;
|
|
152
|
+
return {
|
|
153
|
+
id: id,
|
|
154
|
+
content: content
|
|
155
|
+
};
|
|
156
|
+
}));
|
|
157
|
+
useEffect(function() {
|
|
158
|
+
setTabs(_tabs.map(function(tab, index) {
|
|
159
|
+
return _object_spread_props(_object_spread({}, tab), {
|
|
160
|
+
originalIndex: index,
|
|
161
|
+
hidden: false
|
|
162
|
+
});
|
|
163
|
+
}));
|
|
164
|
+
}, [
|
|
165
|
+
normalizedTabs
|
|
166
|
+
]);
|
|
167
|
+
var _useState1 = _sliced_to_array(useState(false), 2), containerHasOverflow = _useState1[0], setContainerHasOverflow = _useState1[1];
|
|
168
|
+
var _useState2 = _sliced_to_array(useState(false), 2), showMoreTabsPopover = _useState2[0], setShowMoreTabsPopover = _useState2[1];
|
|
169
|
+
var updateTabVisibility = useCallback(function() {
|
|
170
|
+
var container = containerRef.current;
|
|
171
|
+
if (tabs.length === 0 || !container) return;
|
|
172
|
+
var hasOverflow = container.scrollWidth > container.clientWidth;
|
|
173
|
+
setContainerHasOverflow(hasOverflow);
|
|
174
|
+
if (!hasOverflow) {
|
|
175
|
+
setTabs(tabs.map(function(tab) {
|
|
176
|
+
return _object_spread_props(_object_spread({}, tab), {
|
|
177
|
+
hidden: false
|
|
178
|
+
});
|
|
179
|
+
}));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (selectedIndex > tabs.length - 1) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var containerWidth = container.offsetWidth;
|
|
186
|
+
var selectedTab = selectedIndex ? document.getElementById("tab-".concat(tabs[selectedIndex].id)) : null;
|
|
187
|
+
if (!selectedTab) return;
|
|
188
|
+
var newTabs = [];
|
|
189
|
+
var selectedTabWidth = document.getElementById("tab-".concat(tabs[selectedIndex].id)).offsetWidth;
|
|
190
|
+
var availableSpace = containerWidth - selectedTabWidth - 20;
|
|
191
|
+
tabs.forEach(function(tab) {
|
|
192
|
+
var $el = document.getElementById("tab-".concat(tab.id));
|
|
193
|
+
if ($el) {
|
|
194
|
+
var tabRect = $el.getBoundingClientRect();
|
|
195
|
+
var tabWidth = tabRect.right - tabRect.left;
|
|
196
|
+
var isSelected = tab.originalIndex === selectedIndex;
|
|
197
|
+
var hidden = !isSelected && availableSpace < tabWidth;
|
|
198
|
+
if (!hidden && !isSelected) {
|
|
199
|
+
availableSpace -= tabWidth;
|
|
200
|
+
}
|
|
201
|
+
newTabs.push(_object_spread_props(_object_spread({}, tab), {
|
|
202
|
+
hidden: hidden
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
newTabs.sort(function(a, b) {
|
|
207
|
+
if (a.hidden !== b.hidden) {
|
|
208
|
+
return a.hidden - b.hidden;
|
|
209
|
+
}
|
|
210
|
+
return a.hidden ? 0 : a.originalIndex - b.originalIndex;
|
|
211
|
+
});
|
|
212
|
+
setTabs(newTabs);
|
|
213
|
+
}, [
|
|
214
|
+
tabs.length,
|
|
215
|
+
selectedIndex
|
|
216
|
+
]);
|
|
217
|
+
var debouncedUpdateTabVisibility = useDebouncedCallback(updateTabVisibility, 100);
|
|
218
|
+
useLayoutEffect(function() {
|
|
219
|
+
window.addEventListener("resize", debouncedUpdateTabVisibility);
|
|
220
|
+
updateTabVisibility();
|
|
221
|
+
return function() {
|
|
222
|
+
window.removeEventListener("resize", debouncedUpdateTabVisibility);
|
|
223
|
+
};
|
|
224
|
+
}, [
|
|
225
|
+
debouncedUpdateTabVisibility,
|
|
226
|
+
updateTabVisibility
|
|
227
|
+
]);
|
|
228
|
+
var classes = styles({
|
|
229
|
+
borderBottom: borderBottom,
|
|
230
|
+
padded: padded
|
|
231
|
+
});
|
|
232
|
+
var containerClasses = containerStyles({
|
|
233
|
+
containerHasOverflow: containerHasOverflow
|
|
234
|
+
});
|
|
235
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
236
|
+
className: classes,
|
|
237
|
+
children: [
|
|
238
|
+
/*#__PURE__*/ _jsx("div", {
|
|
239
|
+
ref: containerRef,
|
|
240
|
+
className: containerClasses,
|
|
241
|
+
children: tabs.map(function(tab) {
|
|
242
|
+
return /*#__PURE__*/ _jsx(Tab, {
|
|
243
|
+
id: tab.id,
|
|
244
|
+
index: tab.originalIndex,
|
|
245
|
+
selected: selectedIndex === tab.originalIndex,
|
|
246
|
+
active: activeDisclosure && selectedIndex === tab.originalIndex,
|
|
247
|
+
onSelect: function() {
|
|
248
|
+
return onSelect(tab.originalIndex);
|
|
249
|
+
},
|
|
250
|
+
disclosure: disclosure && tab.disclosure,
|
|
251
|
+
icon: tab.icon,
|
|
252
|
+
fullWidth: fullWidth,
|
|
253
|
+
hidden: tab.hidden,
|
|
254
|
+
children: tab.content
|
|
255
|
+
}, "tab-".concat(tab.originalIndex));
|
|
256
|
+
})
|
|
257
|
+
}),
|
|
258
|
+
/*#__PURE__*/ _jsx("div", {
|
|
259
|
+
ref: disclosureRef,
|
|
260
|
+
className: "Litho-Tabs__DisclosureContainer pl-1",
|
|
261
|
+
children: containerHasOverflow && /*#__PURE__*/ _jsx(Popover, {
|
|
262
|
+
active: showMoreTabsPopover,
|
|
263
|
+
preferredAlignment: "right",
|
|
264
|
+
preferredPosition: "below",
|
|
265
|
+
onClose: function() {
|
|
266
|
+
return setShowMoreTabsPopover(false);
|
|
267
|
+
},
|
|
268
|
+
activator: /*#__PURE__*/ _jsx(Tab, {
|
|
269
|
+
disclosure: true,
|
|
270
|
+
alwaysShowDisclosureIcon: true,
|
|
271
|
+
onClick: function() {
|
|
272
|
+
return setShowMoreTabsPopover(!showMoreTabsPopover);
|
|
273
|
+
},
|
|
274
|
+
children: disclosureText
|
|
275
|
+
}),
|
|
276
|
+
children: /*#__PURE__*/ _jsx(ActionList, {
|
|
277
|
+
items: tabs.filter(function(t) {
|
|
278
|
+
return t.hidden;
|
|
279
|
+
}).map(function(tab) {
|
|
280
|
+
return {
|
|
281
|
+
content: tab.content,
|
|
282
|
+
onAction: function() {
|
|
283
|
+
onSelect(tab.originalIndex);
|
|
284
|
+
setShowMoreTabsPopover(false);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}),
|
|
288
|
+
onActionAnyItem: function() {
|
|
289
|
+
return setShowMoreTabsPopover(false);
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
var tabStyles = tv({
|
|
298
|
+
base: "Litho-Tabs__Tab text-sm font-semibold rounded-md inline-grid py-1 min-h-8 flex gap-0.5 items-center justify-center",
|
|
299
|
+
variants: {
|
|
300
|
+
disclosure: {
|
|
301
|
+
true: "pl-3 pr-1",
|
|
302
|
+
false: "px-3"
|
|
303
|
+
},
|
|
304
|
+
selected: {
|
|
305
|
+
true: "text-tab-active-fg bg-tab-active-bg hover:bg-tab-active-bg-hover active:bg-tab-active-bg-active",
|
|
306
|
+
false: "text-tab-inactive-fg bg-tab-inactive-bg hover:bg-tab-inactive-bg-hover active:bg-tab-inactive-bg-active"
|
|
307
|
+
},
|
|
308
|
+
disabled: {
|
|
309
|
+
true: "cursor-not-allowed",
|
|
310
|
+
false: "cursor-pointer"
|
|
311
|
+
},
|
|
312
|
+
fullWidth: {
|
|
313
|
+
true: "flex-1",
|
|
314
|
+
false: ""
|
|
315
|
+
},
|
|
316
|
+
hidden: {
|
|
317
|
+
true: "invisible"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
function Tab() {
|
|
322
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
323
|
+
var id = props.id, active = props.active, selected = props.selected, index = props.index, icon = props.icon, onSelect = props.onSelect, onClick = props.onClick, children = props.children, fullWidth = props.fullWidth, hidden = props.hidden, _props_disclosure = props.disclosure, disclosure = _props_disclosure === void 0 ? false : _props_disclosure, _props_alwaysShowDisclosureIcon = props.alwaysShowDisclosureIcon, alwaysShowDisclosureIcon = _props_alwaysShowDisclosureIcon === void 0 ? false : _props_alwaysShowDisclosureIcon, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled;
|
|
324
|
+
var polarisIcon = typeof icon === "string" ? PolarisIcons[icon] : PolarisIcons[icon === null || icon === void 0 ? void 0 : icon.displayName];
|
|
325
|
+
var showDisclosure = disclosure && (selected || alwaysShowDisclosureIcon);
|
|
326
|
+
var tabClasses = tabStyles({
|
|
327
|
+
selected: selected,
|
|
328
|
+
disclosure: showDisclosure,
|
|
329
|
+
disabled: disabled,
|
|
330
|
+
fullWidth: fullWidth,
|
|
331
|
+
hidden: hidden
|
|
332
|
+
});
|
|
333
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
334
|
+
id: id ? "tab-".concat(id) : undefined,
|
|
335
|
+
className: tabClasses,
|
|
336
|
+
onClick: onClick ? onClick : onSelect ? function() {
|
|
337
|
+
return onSelect(index);
|
|
338
|
+
} : undefined,
|
|
339
|
+
children: [
|
|
340
|
+
icon && !!polarisIcon && /*#__PURE__*/ _jsx("span", {
|
|
341
|
+
className: "Litho-Tabs__Tab-Icon mr-1",
|
|
342
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
343
|
+
source: polarisIcon,
|
|
344
|
+
color: selected ? "active" : "subdued"
|
|
345
|
+
})
|
|
346
|
+
}),
|
|
347
|
+
icon && !!polarisIcon === false && /*#__PURE__*/ _jsx("span", {
|
|
348
|
+
className: "Litho-Tabs__Tab-Icon mr-1",
|
|
349
|
+
children: icon
|
|
350
|
+
}),
|
|
351
|
+
/*#__PURE__*/ _jsx("span", {
|
|
352
|
+
className: "Litho-Tabs__Tab-Content block min-h-5 leading-5",
|
|
353
|
+
children: children
|
|
354
|
+
}),
|
|
355
|
+
showDisclosure && /*#__PURE__*/ _jsx("span", {
|
|
356
|
+
className: "Litho-Tabs__Tab-Disclosure",
|
|
357
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
358
|
+
source: active ? CaretUpMinor : CaretDownMinor,
|
|
359
|
+
color: selected ? "active" : "subdued"
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
]
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
Tabs.Tab = Tab;
|
|
366
|
+
export default Tabs;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import Icon from "./Icon.js";
|
|
4
|
+
import { CancelSmallMinor, TickSmallMinor } from "@shopify/polaris-icons";
|
|
5
|
+
var styles = tv({
|
|
6
|
+
base: "Litho-Tag text-xs rounded-md inline-grid pl-1 whitespace-nowrap",
|
|
7
|
+
variants: {
|
|
8
|
+
disabled: {
|
|
9
|
+
true: "bg-tag-bg-disabled"
|
|
10
|
+
},
|
|
11
|
+
interactive: {
|
|
12
|
+
true: "cursor-pointer focus:outline-hidden focus:ring-2 focus:ring-offset-1 focus:ring-form-focus-active",
|
|
13
|
+
false: "cursor-text"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
compoundVariants: [
|
|
17
|
+
{
|
|
18
|
+
disabled: false,
|
|
19
|
+
interactive: true,
|
|
20
|
+
selected: false,
|
|
21
|
+
class: "bg-tag-bg hover:bg-tag-bg-hover"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
disabled: false,
|
|
25
|
+
interactive: false,
|
|
26
|
+
selected: false,
|
|
27
|
+
class: "bg-tag-bg"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
selected: true,
|
|
31
|
+
interactive: true,
|
|
32
|
+
disabled: false,
|
|
33
|
+
class: "bg-tab-active-bg hover:bg-tab-active-bg-hover"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
selected: true,
|
|
37
|
+
interactive: false,
|
|
38
|
+
disabled: false,
|
|
39
|
+
class: "bg-tab-active-bg text-tab-active-fg"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
var contentStyles = tv({
|
|
44
|
+
base: "Litho-Tag__Content py-0.5 px-1",
|
|
45
|
+
variants: {
|
|
46
|
+
hasRemoveAction: {
|
|
47
|
+
false: "pr-2"
|
|
48
|
+
},
|
|
49
|
+
hasIcon: {
|
|
50
|
+
true: "pl-0"
|
|
51
|
+
},
|
|
52
|
+
disabled: {
|
|
53
|
+
true: "text-tag-fg-disabled",
|
|
54
|
+
false: "text-tag-fg"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
compoundVariants: [
|
|
58
|
+
{
|
|
59
|
+
selected: true,
|
|
60
|
+
disabled: false,
|
|
61
|
+
class: "text-tab-active-fg-low"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
hasRemoveAction: false,
|
|
66
|
+
disabled: false
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
var actionStyles = tv({
|
|
70
|
+
base: "Litho-Tag__Action block h-full rounded-r-md group",
|
|
71
|
+
variants: {
|
|
72
|
+
disabled: {
|
|
73
|
+
false: "cursor-pointer hover:bg-tag-bg-hover",
|
|
74
|
+
true: "pointer-events-none"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Renders a Tag component with optional interactive and removable features.
|
|
80
|
+
*
|
|
81
|
+
* @function Tag
|
|
82
|
+
* @param {Object} props - The properties for the Tag component.
|
|
83
|
+
* @param {React.ReactNode} props.children - The content to be displayed inside the Tag.
|
|
84
|
+
* @param {boolean} [props.disabled=false] - Whether the tag is disabled.
|
|
85
|
+
* @param {Function} [props.onClick] - The callback function to execute on tag click.
|
|
86
|
+
* @param {Function} [props.onRemove] - The callback function to execute when the remove icon is clicked.
|
|
87
|
+
* @param {string} [props.accessibilityLabel] - The accessibility label for the tag.
|
|
88
|
+
* @param {string} [props.url] - The URL to open when the tag is clicked.
|
|
89
|
+
* @param {string} [props.target="_self"] - Specifies where to open the URL.
|
|
90
|
+
*
|
|
91
|
+
* @returns {JSX.Element} The rendered Tag component.
|
|
92
|
+
*/ function Tag() {
|
|
93
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
94
|
+
var children = props.children, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, icon = props.icon, onClick = props.onClick, onRemove = props.onRemove, accessibilityLabel = props.accessibilityLabel, url = props.url, _props_target = props.target, target = _props_target === void 0 ? "_self" : _props_target, className = props.className, _props_selected = props.selected, selected = _props_selected === void 0 ? false : _props_selected;
|
|
95
|
+
var interactive = !!url || !!onClick;
|
|
96
|
+
var hasRemoveAction = !!onRemove;
|
|
97
|
+
var hasIcon = !!icon || selected;
|
|
98
|
+
var classes = styles({
|
|
99
|
+
interactive: interactive,
|
|
100
|
+
disabled: disabled,
|
|
101
|
+
selected: selected
|
|
102
|
+
});
|
|
103
|
+
var contentClasses = contentStyles({
|
|
104
|
+
disabled: disabled,
|
|
105
|
+
hasRemoveAction: hasRemoveAction,
|
|
106
|
+
hasIcon: hasIcon,
|
|
107
|
+
selected: selected
|
|
108
|
+
});
|
|
109
|
+
var actionClasses = actionStyles({
|
|
110
|
+
disabled: disabled
|
|
111
|
+
});
|
|
112
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
113
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
114
|
+
"aria-label": accessibilityLabel,
|
|
115
|
+
role: "button",
|
|
116
|
+
tabIndex: interactive ? "0" : undefined,
|
|
117
|
+
onClick: interactive ? function() {
|
|
118
|
+
if (onClick) {
|
|
119
|
+
onClick();
|
|
120
|
+
}
|
|
121
|
+
if (url) {
|
|
122
|
+
window.open(url, target);
|
|
123
|
+
}
|
|
124
|
+
} : undefined,
|
|
125
|
+
children: /*#__PURE__*/ _jsxs("span", {
|
|
126
|
+
className: "flex justify-center items-center",
|
|
127
|
+
children: [
|
|
128
|
+
(selected || icon) && /*#__PURE__*/ _jsx(Icon, {
|
|
129
|
+
source: icon === true ? TickSmallMinor : icon,
|
|
130
|
+
color: disabled ? "disabled" : selected ? "active" : "subdued"
|
|
131
|
+
}),
|
|
132
|
+
/*#__PURE__*/ _jsx("span", {
|
|
133
|
+
className: contentClasses,
|
|
134
|
+
children: children
|
|
135
|
+
}),
|
|
136
|
+
hasRemoveAction && /*#__PURE__*/ _jsx("div", {
|
|
137
|
+
className: actionClasses,
|
|
138
|
+
onClick: onRemove,
|
|
139
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
140
|
+
source: CancelSmallMinor,
|
|
141
|
+
color: disabled ? "disabled" : "default",
|
|
142
|
+
display: "flex",
|
|
143
|
+
className: "h-full opacity-50 group-hover:opacity-100"
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
;
|
|
151
|
+
export default Tag;
|