@heymantle/litho 0.0.13 → 0.0.15
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/README.md +52 -0
- package/dist/cjs/components/Card.js +1 -1
- package/dist/cjs/components/Disclosure.js +46 -15
- package/dist/cjs/components/DropZone.js +93 -37
- package/dist/cjs/components/Layout.js +4 -2
- package/dist/cjs/components/Modal.js +14 -3
- package/dist/cjs/components/Navigation.js +4 -3
- package/dist/cjs/components/Popover.js +58 -13
- package/dist/cjs/components/Select.js +4 -0
- package/dist/cjs/components/TabNavigation.js +65 -11
- package/dist/cjs/components/Table.js +27 -11
- package/dist/cjs/components/Tabs.js +33 -2
- package/dist/cjs/components/TextField.js +4 -2
- package/dist/cjs/components/ToastNotification.js +368 -0
- package/dist/cjs/components/ToastProvider.js +342 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/playwright.config.js +114 -0
- package/dist/cjs/styles/Table.js +2 -7
- package/dist/cjs/tests/visual/stories.spec.js +637 -0
- package/dist/cjs/utilities/dates.js +7 -7
- package/dist/esm/components/Card.js +1 -1
- package/dist/esm/components/Disclosure.js +36 -5
- package/dist/esm/components/DropZone.js +94 -38
- package/dist/esm/components/Layout.js +4 -2
- package/dist/esm/components/Modal.js +14 -3
- package/dist/esm/components/Navigation.js +4 -3
- package/dist/esm/components/Popover.js +58 -13
- package/dist/esm/components/Select.js +5 -1
- package/dist/esm/components/TabNavigation.js +65 -11
- package/dist/esm/components/Table.js +27 -11
- package/dist/esm/components/Tabs.js +33 -2
- package/dist/esm/components/TextField.js +4 -2
- package/dist/esm/components/ToastNotification.js +353 -0
- package/dist/esm/components/ToastProvider.js +336 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/playwright.config.js +104 -0
- package/dist/esm/styles/Table.js +2 -7
- package/dist/esm/tests/visual/stories.spec.js +633 -0
- package/dist/esm/utilities/dates.js +7 -7
- package/dist/types/components/Disclosure.d.ts.map +1 -1
- package/dist/types/components/DropZone.d.ts +2 -0
- package/dist/types/components/DropZone.d.ts.map +1 -1
- package/dist/types/components/Layout.d.ts.map +1 -1
- package/dist/types/components/Modal.d.ts.map +1 -1
- package/dist/types/components/Navigation.d.ts +1 -0
- package/dist/types/components/Navigation.d.ts.map +1 -1
- package/dist/types/components/Popover.d.ts +2 -0
- package/dist/types/components/Popover.d.ts.map +1 -1
- package/dist/types/components/Select.d.ts.map +1 -1
- package/dist/types/components/TabNavigation.d.ts.map +1 -1
- package/dist/types/components/Table.d.ts.map +1 -1
- package/dist/types/components/Tabs.d.ts +45 -1
- package/dist/types/components/Tabs.d.ts.map +1 -1
- package/dist/types/components/TextField.d.ts +2 -0
- package/dist/types/components/TextField.d.ts.map +1 -1
- package/dist/types/components/ToastNotification.d.ts +36 -0
- package/dist/types/components/ToastNotification.d.ts.map +1 -0
- package/dist/types/components/ToastProvider.d.ts +21 -0
- package/dist/types/components/ToastProvider.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/styles/Table.d.ts.map +1 -1
- package/index.css +3 -0
- package/package.json +12 -3
|
@@ -139,7 +139,7 @@ var HOURLY_RANGE_PRESETS = [
|
|
|
139
139
|
id: "last_30_minutes",
|
|
140
140
|
label: "Last 30 minutes",
|
|
141
141
|
value: {
|
|
142
|
-
start: (0, _dayjs.default)().
|
|
142
|
+
start: (0, _dayjs.default)().subtract(30, "minutes").startOf("minute").toDate(),
|
|
143
143
|
end: (0, _dayjs.default)().endOf("minute").toDate()
|
|
144
144
|
}
|
|
145
145
|
},
|
|
@@ -173,7 +173,7 @@ var RANGE_PRESETS = [
|
|
|
173
173
|
id: "last_12_hours",
|
|
174
174
|
label: "Last 12 hours",
|
|
175
175
|
value: {
|
|
176
|
-
start: (0, _dayjs.default)().subtract(
|
|
176
|
+
start: (0, _dayjs.default)().subtract(12, "hours").startOf("hour").toDate(),
|
|
177
177
|
end: (0, _dayjs.default)().endOf("hour").toDate()
|
|
178
178
|
}
|
|
179
179
|
},
|
|
@@ -182,7 +182,7 @@ var RANGE_PRESETS = [
|
|
|
182
182
|
hideCalendar: true,
|
|
183
183
|
label: "Last 24 hours",
|
|
184
184
|
value: {
|
|
185
|
-
start: (0, _dayjs.default)().subtract(
|
|
185
|
+
start: (0, _dayjs.default)().subtract(24, "hours").startOf("hour").toDate(),
|
|
186
186
|
end: (0, _dayjs.default)().endOf("hour").toDate()
|
|
187
187
|
}
|
|
188
188
|
},
|
|
@@ -190,7 +190,7 @@ var RANGE_PRESETS = [
|
|
|
190
190
|
id: "last_7_days",
|
|
191
191
|
label: "Last 7 days",
|
|
192
192
|
value: {
|
|
193
|
-
start: (0, _dayjs.default)().subtract(
|
|
193
|
+
start: (0, _dayjs.default)().subtract(7, "day").startOf("day").toDate(),
|
|
194
194
|
end: (0, _dayjs.default)().endOf("day").toDate()
|
|
195
195
|
}
|
|
196
196
|
},
|
|
@@ -198,7 +198,7 @@ var RANGE_PRESETS = [
|
|
|
198
198
|
id: "last_14_days",
|
|
199
199
|
label: "Last 14 days",
|
|
200
200
|
value: {
|
|
201
|
-
start: (0, _dayjs.default)().subtract(
|
|
201
|
+
start: (0, _dayjs.default)().subtract(14, "day").startOf("day").toDate(),
|
|
202
202
|
end: (0, _dayjs.default)().endOf("day").toDate()
|
|
203
203
|
}
|
|
204
204
|
},
|
|
@@ -206,7 +206,7 @@ var RANGE_PRESETS = [
|
|
|
206
206
|
id: "last_30_days",
|
|
207
207
|
label: "Last 30 days",
|
|
208
208
|
value: {
|
|
209
|
-
start: (0, _dayjs.default)().subtract(
|
|
209
|
+
start: (0, _dayjs.default)().subtract(30, "day").startOf("day").toDate(),
|
|
210
210
|
end: (0, _dayjs.default)().endOf("day").toDate()
|
|
211
211
|
}
|
|
212
212
|
},
|
|
@@ -214,7 +214,7 @@ var RANGE_PRESETS = [
|
|
|
214
214
|
id: "last_90_days",
|
|
215
215
|
label: "Last 90 days",
|
|
216
216
|
value: {
|
|
217
|
-
start: (0, _dayjs.default)().subtract(
|
|
217
|
+
start: (0, _dayjs.default)().subtract(90, "day").startOf("day").toDate(),
|
|
218
218
|
end: (0, _dayjs.default)().endOf("day").toDate()
|
|
219
219
|
}
|
|
220
220
|
},
|
|
@@ -501,7 +501,7 @@ var sectionBodyStyles = tv({
|
|
|
501
501
|
};
|
|
502
502
|
Card.Section.displayName = "Card.Section";
|
|
503
503
|
var clickableRowStyles = tv({
|
|
504
|
-
base: "Litho-Card__Row py-1.5 px-2.5 cursor-pointer rounded-md hover:bg-tint-2 active:bg-tint-3",
|
|
504
|
+
base: "Litho-Card__Row py-1.5 px-2.5 @md:px-3 cursor-pointer rounded-md hover:bg-tint-2 active:bg-tint-3",
|
|
505
505
|
variants: {
|
|
506
506
|
disabled: {
|
|
507
507
|
true: "opacity-50 cursor-not-allowed pointer-events-none"
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
var styles = tv({
|
|
4
|
+
base: "Litho-Disclosure relative",
|
|
5
|
+
variants: {
|
|
6
|
+
flush: {
|
|
7
|
+
true: "pl-4",
|
|
8
|
+
false: "pl-7.5 @md:pl-7"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
defaultVariants: {
|
|
12
|
+
flush: false
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var borderStyles = tv({
|
|
16
|
+
base: "Litho-Disclosure__Border absolute top-0 w-px h-full bg-tint-5 dark:bg-tint-alt-5",
|
|
17
|
+
variants: {
|
|
18
|
+
flush: {
|
|
19
|
+
true: "left-0.5",
|
|
20
|
+
false: "left-[9px]"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
flush: false
|
|
25
|
+
}
|
|
26
|
+
});
|
|
1
27
|
/**
|
|
2
28
|
* Renders a Disclosure component that displays content with disclosure styling.
|
|
3
29
|
*
|
|
@@ -18,15 +44,20 @@
|
|
|
18
44
|
* <Disclosure className="mt-4">
|
|
19
45
|
* <Text>This is disclosure content with margin</Text>
|
|
20
46
|
* </Disclosure>
|
|
21
|
-
*/
|
|
22
|
-
function Disclosure() {
|
|
47
|
+
*/ function Disclosure() {
|
|
23
48
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
24
|
-
var children = props.children, className = props.className;
|
|
49
|
+
var children = props.children, className = props.className, _props_flush = props.flush, flush = _props_flush === void 0 ? false : _props_flush;
|
|
50
|
+
var classes = styles({
|
|
51
|
+
flush: flush
|
|
52
|
+
});
|
|
53
|
+
var borderClasses = borderStyles({
|
|
54
|
+
flush: flush
|
|
55
|
+
});
|
|
25
56
|
return /*#__PURE__*/ _jsxs("div", {
|
|
26
|
-
className: "
|
|
57
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
27
58
|
children: [
|
|
28
59
|
/*#__PURE__*/ _jsx("div", {
|
|
29
|
-
className:
|
|
60
|
+
className: borderClasses
|
|
30
61
|
}),
|
|
31
62
|
/*#__PURE__*/ _jsx("div", {
|
|
32
63
|
children: children
|
|
@@ -68,7 +68,43 @@ import Link from "./Link.js";
|
|
|
68
68
|
import SkeletonText from "./SkeletonText.js";
|
|
69
69
|
import Spinner from "./Spinner.js";
|
|
70
70
|
import Text from "./Text.js";
|
|
71
|
-
import { CancelMajor, CircleAlertMajor, FileMinor, ImageMajor, ImagesMajor } from "@shopify/polaris-icons";
|
|
71
|
+
import { CancelMajor, CircleAlertMajor, FileMinor, ImageMajor, ImagesMajor, MagicMajor } from "@shopify/polaris-icons";
|
|
72
|
+
var normalizeDropZoneAccept = function(accept) {
|
|
73
|
+
if (!accept) return [];
|
|
74
|
+
return typeof accept === "string" ? [
|
|
75
|
+
accept
|
|
76
|
+
] : accept;
|
|
77
|
+
};
|
|
78
|
+
var isFileAcceptedForDropZone = function(file) {
|
|
79
|
+
var accept = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
80
|
+
if (!accept || accept.length === 0) return true;
|
|
81
|
+
return accept.some(function(type) {
|
|
82
|
+
if (!type) return false;
|
|
83
|
+
if (type === "*/*") return true;
|
|
84
|
+
if (type.endsWith("/*")) {
|
|
85
|
+
var _type_split = _sliced_to_array(type.split("/"), 1), prefix = _type_split[0];
|
|
86
|
+
if (prefix === "*") return true;
|
|
87
|
+
return !!(file === null || file === void 0 ? void 0 : file.type) && file.type.startsWith("".concat(prefix, "/"));
|
|
88
|
+
}
|
|
89
|
+
return (file === null || file === void 0 ? void 0 : file.type) === type;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
var partitionFilesByDropZoneAccept = function(files) {
|
|
93
|
+
var accept = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
94
|
+
var acceptedFiles = [];
|
|
95
|
+
var rejectedFiles = [];
|
|
96
|
+
files.forEach(function(file) {
|
|
97
|
+
if (isFileAcceptedForDropZone(file, accept)) {
|
|
98
|
+
acceptedFiles.push(file);
|
|
99
|
+
} else {
|
|
100
|
+
rejectedFiles.push(file);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
acceptedFiles: acceptedFiles,
|
|
105
|
+
rejectedFiles: rejectedFiles
|
|
106
|
+
};
|
|
107
|
+
};
|
|
72
108
|
var dropZoneStyles = tv({
|
|
73
109
|
base: "Litho-DropZone w-full flex items-center justify-center p-4 border border-form-border border-dashed rounded-md focus:outline-hidden",
|
|
74
110
|
variants: {
|
|
@@ -130,11 +166,7 @@ var dropZoneStyles = tv({
|
|
|
130
166
|
*/ function DropZone() {
|
|
131
167
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
132
168
|
var id = props.id, label = props.label, labelHidden = props.labelHidden, labelAction = props.labelAction, tooltip = props.tooltip, labelVariant = props.labelVariant, _props_type = props.type, type = _props_type === void 0 ? "file" : _props_type, _accept = props.accept, _props_allowMultiple = props.allowMultiple, allowMultiple = _props_allowMultiple === void 0 ? false : _props_allowMultiple, _props_showDropZoneWhenDisabled = props.showDropZoneWhenDisabled, showDropZoneWhenDisabled = _props_showDropZoneWhenDisabled === void 0 ? true : _props_showDropZoneWhenDisabled, _disabled = props.disabled, onDrop = props.onDrop, onDropAccepted = props.onDropAccepted, onDropRejected = props.onDropRejected, helpText = props.helpText, error = props.error, _props_uploading = props.uploading, uploading = _props_uploading === void 0 ? false : _props_uploading, _props_uploadedFiles = props.uploadedFiles, uploadedFiles = _props_uploadedFiles === void 0 ? [] : _props_uploadedFiles, _props_uploadLabel = props.uploadLabel, uploadLabel = _props_uploadLabel === void 0 ? "Drag and drop files or click to upload" : _props_uploadLabel, _props_uploadingLabel = props.uploadingLabel, uploadingLabel = _props_uploadingLabel === void 0 ? "Uploading..." : _props_uploadingLabel, _props_dragLabel = props.dragLabel, dragLabel = _props_dragLabel === void 0 ? "Release to upload" : _props_dragLabel, tmp = props.showFilePreview, _showFilePreview = tmp === void 0 ? true : tmp, previewLoading = props.previewLoading, _props_previewRows = props.previewRows, previewRows = _props_previewRows === void 0 ? 2 : _props_previewRows, onRemove = props.onRemove, onFilePreviewClick = props.onFilePreviewClick, filename = props.filename;
|
|
133
|
-
var accept = _accept
|
|
134
|
-
_accept
|
|
135
|
-
] : _accept : [
|
|
136
|
-
"*/*"
|
|
137
|
-
];
|
|
169
|
+
var accept = normalizeDropZoneAccept(_accept);
|
|
138
170
|
var inputRef = useRef(null);
|
|
139
171
|
var _useState = _sliced_to_array(useState(false), 2), hasFocusWithin = _useState[0], setHasFocusWithin = _useState[1];
|
|
140
172
|
var _useState1 = _sliced_to_array(useState(false), 2), isDraggingOver = _useState1[0], setIsDraggingOver = _useState1[1];
|
|
@@ -195,22 +227,7 @@ var dropZoneStyles = tv({
|
|
|
195
227
|
setDragFileCount(0);
|
|
196
228
|
if (disabled) return;
|
|
197
229
|
var droppedFiles = Array.from(event.dataTransfer.files);
|
|
198
|
-
var acceptedFiles =
|
|
199
|
-
var rejectedFiles = [];
|
|
200
|
-
droppedFiles.forEach(function(file) {
|
|
201
|
-
var isValidType = typeAccept.length === 0 || typeAccept.some(function(type) {
|
|
202
|
-
if (type.endsWith("/*")) {
|
|
203
|
-
return file.type.startsWith("".concat(type.split("/")[0], "/"));
|
|
204
|
-
}
|
|
205
|
-
return file.type === type;
|
|
206
|
-
});
|
|
207
|
-
var isValid = isValidType;
|
|
208
|
-
if (isValid) {
|
|
209
|
-
acceptedFiles.push(file);
|
|
210
|
-
} else {
|
|
211
|
-
rejectedFiles.push(file);
|
|
212
|
-
}
|
|
213
|
-
});
|
|
230
|
+
var _partitionFilesByDropZoneAccept = partitionFilesByDropZoneAccept(droppedFiles, typeAccept), acceptedFiles = _partitionFilesByDropZoneAccept.acceptedFiles, rejectedFiles = _partitionFilesByDropZoneAccept.rejectedFiles;
|
|
214
231
|
if (onDrop) {
|
|
215
232
|
onDrop(droppedFiles);
|
|
216
233
|
}
|
|
@@ -223,22 +240,7 @@ var dropZoneStyles = tv({
|
|
|
223
240
|
};
|
|
224
241
|
var handleFileChange = function(event) {
|
|
225
242
|
var selectedFiles = Array.from(event.target.files);
|
|
226
|
-
var acceptedFiles =
|
|
227
|
-
var rejectedFiles = [];
|
|
228
|
-
selectedFiles.forEach(function(file) {
|
|
229
|
-
var isValidType = typeAccept.length === 0 || typeAccept.some(function(type) {
|
|
230
|
-
if (type.endsWith("/*")) {
|
|
231
|
-
return file.type.startsWith("".concat(type.split("/")[0], "/"));
|
|
232
|
-
}
|
|
233
|
-
return file.type === type;
|
|
234
|
-
});
|
|
235
|
-
var isValid = isValidType;
|
|
236
|
-
if (isValid) {
|
|
237
|
-
acceptedFiles.push(file);
|
|
238
|
-
} else {
|
|
239
|
-
rejectedFiles.push(file);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
243
|
+
var _partitionFilesByDropZoneAccept = partitionFilesByDropZoneAccept(selectedFiles, typeAccept), acceptedFiles = _partitionFilesByDropZoneAccept.acceptedFiles, rejectedFiles = _partitionFilesByDropZoneAccept.rejectedFiles;
|
|
242
244
|
if (onDrop) {
|
|
243
245
|
onDrop(selectedFiles);
|
|
244
246
|
}
|
|
@@ -276,6 +278,10 @@ var dropZoneStyles = tv({
|
|
|
276
278
|
}),
|
|
277
279
|
labelAction && /*#__PURE__*/ _jsx(Link, {
|
|
278
280
|
onClick: labelAction.onAction,
|
|
281
|
+
insight: labelAction.insight,
|
|
282
|
+
icon: labelAction.insight ? MagicMajor : undefined,
|
|
283
|
+
color: labelAction.insight ? "insight" : undefined,
|
|
284
|
+
disabled: labelAction.disabled,
|
|
279
285
|
removeUnderline: true,
|
|
280
286
|
children: labelAction.content
|
|
281
287
|
})
|
|
@@ -354,6 +360,56 @@ var dropZoneStyles = tv({
|
|
|
354
360
|
]
|
|
355
361
|
});
|
|
356
362
|
}
|
|
363
|
+
var DropTarget = function() {
|
|
364
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
365
|
+
var _accept = props.accept, _props_allowMultiple = props.allowMultiple, allowMultiple = _props_allowMultiple === void 0 ? true : _props_allowMultiple, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, onDrop = props.onDrop, onDropAccepted = props.onDropAccepted, onDropRejected = props.onDropRejected, className = props.className, dragOverClassName = props.dragOverClassName, children = props.children;
|
|
366
|
+
var accept = normalizeDropZoneAccept(_accept);
|
|
367
|
+
var _useState = _sliced_to_array(useState(false), 2), isDraggingOver = _useState[0], setIsDraggingOver = _useState[1];
|
|
368
|
+
var handleDragOver = function(event) {
|
|
369
|
+
event.preventDefault();
|
|
370
|
+
event.stopPropagation();
|
|
371
|
+
if (!disabled) {
|
|
372
|
+
setIsDraggingOver(true);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
var handleDragLeave = function(event) {
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
event.stopPropagation();
|
|
378
|
+
setIsDraggingOver(false);
|
|
379
|
+
};
|
|
380
|
+
var handleDrop = function(event) {
|
|
381
|
+
event.preventDefault();
|
|
382
|
+
event.stopPropagation();
|
|
383
|
+
setIsDraggingOver(false);
|
|
384
|
+
if (disabled) return;
|
|
385
|
+
var droppedFiles = Array.from(event.dataTransfer.files);
|
|
386
|
+
if (allowMultiple === false) {
|
|
387
|
+
droppedFiles = droppedFiles.slice(0, 1);
|
|
388
|
+
}
|
|
389
|
+
var _partitionFilesByDropZoneAccept = partitionFilesByDropZoneAccept(droppedFiles, accept), acceptedFiles = _partitionFilesByDropZoneAccept.acceptedFiles, rejectedFiles = _partitionFilesByDropZoneAccept.rejectedFiles;
|
|
390
|
+
if (onDrop) {
|
|
391
|
+
onDrop(droppedFiles);
|
|
392
|
+
}
|
|
393
|
+
if (onDropAccepted && acceptedFiles.length > 0) {
|
|
394
|
+
onDropAccepted(acceptedFiles);
|
|
395
|
+
}
|
|
396
|
+
if (onDropRejected && rejectedFiles.length > 0) {
|
|
397
|
+
onDropRejected(rejectedFiles);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
var dropTargetClassName = [
|
|
401
|
+
className,
|
|
402
|
+
isDraggingOver && dragOverClassName
|
|
403
|
+
].filter(Boolean).join(" ");
|
|
404
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
405
|
+
className: dropTargetClassName,
|
|
406
|
+
onDragOver: handleDragOver,
|
|
407
|
+
onDragLeave: handleDragLeave,
|
|
408
|
+
onDrop: handleDrop,
|
|
409
|
+
children: children
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
DropZone.DropTarget = DropTarget;
|
|
357
413
|
var previewContainerStyles = tv({
|
|
358
414
|
base: "flex flex-col",
|
|
359
415
|
variants: {
|
|
@@ -147,11 +147,13 @@ var annotatedSectionStyles = tv({
|
|
|
147
147
|
var annotatedSectionClasses = annotatedSectionStyles({
|
|
148
148
|
embedded: embedded
|
|
149
149
|
});
|
|
150
|
+
var annotationColSpan = embedded ? "@md-embed:col-span-4" : "@md:col-span-4";
|
|
151
|
+
var contentColSpan = embedded ? "@md-embed:col-span-8" : "@md:col-span-8";
|
|
150
152
|
return /*#__PURE__*/ _jsxs("div", {
|
|
151
153
|
className: annotatedSectionClasses,
|
|
152
154
|
children: [
|
|
153
155
|
/*#__PURE__*/ _jsxs("div", {
|
|
154
|
-
className: "Litho-Layout__Annotation flex flex-col gap-1
|
|
156
|
+
className: "Litho-Layout__Annotation flex flex-col gap-1 ".concat(annotationColSpan, " py-2"),
|
|
155
157
|
children: [
|
|
156
158
|
title && (typeof title === "string" ? /*#__PURE__*/ _jsx(Text, {
|
|
157
159
|
variant: "headingMd",
|
|
@@ -164,7 +166,7 @@ var annotatedSectionStyles = tv({
|
|
|
164
166
|
]
|
|
165
167
|
}),
|
|
166
168
|
/*#__PURE__*/ _jsx("div", {
|
|
167
|
-
className: "Litho-Layout__AnnotationContent
|
|
169
|
+
className: "Litho-Layout__AnnotationContent ".concat(contentColSpan),
|
|
168
170
|
children: children
|
|
169
171
|
})
|
|
170
172
|
]
|
|
@@ -63,7 +63,16 @@ import { useFrame } from "./Frame.js";
|
|
|
63
63
|
import { useBodyScrollLock } from "../utilities/useBodyScrollLock.js";
|
|
64
64
|
export var ModalContext = /*#__PURE__*/ createContext(false);
|
|
65
65
|
var containerStyles = tv({
|
|
66
|
-
base: "Litho-ModalContainer fixed inset-0 block flex flex-col justify-end md:justify-center items-center pointer-events-none"
|
|
66
|
+
base: "Litho-ModalContainer fixed inset-0 block flex flex-col justify-end md:justify-center items-center pointer-events-none",
|
|
67
|
+
variants: {
|
|
68
|
+
hidden: {
|
|
69
|
+
true: "hidden opacity-0 pointer-events-none",
|
|
70
|
+
false: ""
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
defaultVariants: {
|
|
74
|
+
hidden: false
|
|
75
|
+
}
|
|
67
76
|
});
|
|
68
77
|
var styles = tv({
|
|
69
78
|
base: "Litho-Modal relative bg-surface-highest shadow-modal dark:shadow-modal-dark w-full mx-auto pointer-events-auto flex flex-col overflow-hidden",
|
|
@@ -142,7 +151,7 @@ var sectionStyles = tv({
|
|
|
142
151
|
* @returns {React.ReactPortal|null} The rendered modal component or null if not open.
|
|
143
152
|
*/ function Modal() {
|
|
144
153
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
145
|
-
var children = props.children, title = props.title, subtitle = props.subtitle, open = props.open, onClose = props.onClose, sectioned = props.sectioned, primaryAction = props.primaryAction, secondaryAction = props.secondaryAction, _props_secondaryActions = props.secondaryActions, secondaryActions = _props_secondaryActions === void 0 ? [] : _props_secondaryActions, destructiveAction = props.destructiveAction, loading = props.loading, _props_size = props.size, size = _props_size === void 0 ? "default" : _props_size, leftAccessory = props.leftAccessory, _props_hideCloseButton = props.hideCloseButton, hideCloseButton = _props_hideCloseButton === void 0 ? false : _props_hideCloseButton, backAction = props.backAction, zIndexOverride = props.zIndexOverride, _props_autoFocusFirstInput = props.autoFocusFirstInput, autoFocusFirstInput = _props_autoFocusFirstInput === void 0 ? true : _props_autoFocusFirstInput, bodyClassName = props.bodyClassName;
|
|
154
|
+
var children = props.children, title = props.title, subtitle = props.subtitle, open = props.open, _props_hidden = props.hidden, hidden = _props_hidden === void 0 ? false : _props_hidden, onClose = props.onClose, sectioned = props.sectioned, primaryAction = props.primaryAction, secondaryAction = props.secondaryAction, _props_secondaryActions = props.secondaryActions, secondaryActions = _props_secondaryActions === void 0 ? [] : _props_secondaryActions, destructiveAction = props.destructiveAction, loading = props.loading, _props_size = props.size, size = _props_size === void 0 ? "default" : _props_size, leftAccessory = props.leftAccessory, _props_hideCloseButton = props.hideCloseButton, hideCloseButton = _props_hideCloseButton === void 0 ? false : _props_hideCloseButton, backAction = props.backAction, zIndexOverride = props.zIndexOverride, _props_autoFocusFirstInput = props.autoFocusFirstInput, autoFocusFirstInput = _props_autoFocusFirstInput === void 0 ? true : _props_autoFocusFirstInput, bodyClassName = props.bodyClassName;
|
|
146
155
|
var setModalIsOpen = useFrame().setModalIsOpen;
|
|
147
156
|
var modalContentRef = useRef(null);
|
|
148
157
|
var hasChildren = !!children;
|
|
@@ -150,7 +159,9 @@ var sectionStyles = tv({
|
|
|
150
159
|
sectioned: sectioned,
|
|
151
160
|
size: size
|
|
152
161
|
});
|
|
153
|
-
var containerClasses = containerStyles(
|
|
162
|
+
var containerClasses = containerStyles({
|
|
163
|
+
hidden: hidden
|
|
164
|
+
});
|
|
154
165
|
var headerClasses = headerStyles({
|
|
155
166
|
hasChildren: hasChildren
|
|
156
167
|
});
|
|
@@ -27,6 +27,7 @@ function _object_spread(target) {
|
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
29
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
30
|
+
import React from "react";
|
|
30
31
|
import { tv } from "tailwind-variants";
|
|
31
32
|
import Badge from "./Badge.js";
|
|
32
33
|
import Icon from "./Icon.js";
|
|
@@ -225,7 +226,7 @@ var linkStyles = tv({
|
|
|
225
226
|
})
|
|
226
227
|
]
|
|
227
228
|
}),
|
|
228
|
-
badge ? /*#__PURE__*/ _jsx(Badge, {
|
|
229
|
+
badge ? /*#__PURE__*/ React.isValidElement(badge) ? badge : /*#__PURE__*/ _jsx(Badge, {
|
|
229
230
|
status: badge.status,
|
|
230
231
|
children: badge.label
|
|
231
232
|
}) : external ? /*#__PURE__*/ _jsx(Icon, {
|
|
@@ -314,10 +315,10 @@ var subLinkStyles = tv({
|
|
|
314
315
|
})
|
|
315
316
|
]
|
|
316
317
|
}),
|
|
317
|
-
badge && /*#__PURE__*/ _jsx(Badge, {
|
|
318
|
+
badge && /*#__PURE__*/ (React.isValidElement(badge) ? badge : /*#__PURE__*/ _jsx(Badge, {
|
|
318
319
|
status: badge.status,
|
|
319
320
|
children: badge.label
|
|
320
|
-
}),
|
|
321
|
+
})),
|
|
321
322
|
accessory
|
|
322
323
|
]
|
|
323
324
|
});
|
|
@@ -133,18 +133,23 @@ var styles = tv({
|
|
|
133
133
|
* @param {boolean} [props.sectioned=false] - Whether the popover content is sectioned with padding.
|
|
134
134
|
* @param {string} [props.preferredAlignment="center"] - Preferred alignment for the popover (left, center, right).
|
|
135
135
|
* @param {string} [props.preferredPosition="below"] - Preferred position for the popover (above, below, cover, left, right).
|
|
136
|
+
* @param {number} [props.horizontalOffset] - Custom horizontal offset in pixels to adjust the popover position.
|
|
136
137
|
* @param {string} [props.className] - Additional class name for the popover.
|
|
137
138
|
* @param {string} [props.containerClassName] - Additional class name for the popover container.
|
|
138
139
|
* @returns {JSX.Element} The rendered popover component.
|
|
139
140
|
*/ function Popover() {
|
|
140
141
|
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
141
|
-
var activatorWrapper = props.activatorWrapper, _props_activatorDisplayType = props.activatorDisplayType, activatorDisplayType = _props_activatorDisplayType === void 0 ? "inline-block" : _props_activatorDisplayType, activator = props.activator, children = props.children, onClose = props.onClose,
|
|
142
|
+
var activatorWrapper = props.activatorWrapper, _props_activatorDisplayType = props.activatorDisplayType, activatorDisplayType = _props_activatorDisplayType === void 0 ? "inline-block" : _props_activatorDisplayType, activator = props.activator, children = props.children, onClose = props.onClose, activeProp = props.active, fixed = props.fixed, zIndexOverride = props.zIndexOverride, _props_sectioned = props.sectioned, sectioned = _props_sectioned === void 0 ? false : _props_sectioned, _props_preferredAlignment = props.preferredAlignment, preferredAlignment = _props_preferredAlignment === void 0 ? "center" : _props_preferredAlignment, _props_preferredPosition = props.preferredPosition, preferredPosition = _props_preferredPosition === void 0 ? "below" : _props_preferredPosition, _props_horizontalOffset = props.horizontalOffset, horizontalOffset = _props_horizontalOffset === void 0 ? 0 : _props_horizontalOffset, _props_matchActivatorWidth = props.matchActivatorWidth, matchActivatorWidth = _props_matchActivatorWidth === void 0 ? false : _props_matchActivatorWidth, _props_maxWidth = props.maxWidth, maxWidth = _props_maxWidth === void 0 ? "default" : _props_maxWidth, className = props.className, containerClassName = props.containerClassName, _props_closeOnResize = props.closeOnResize, closeOnResize = _props_closeOnResize === void 0 ? true : _props_closeOnResize, _props_debounceResizeObserver = props.debounceResizeObserver, debounceResizeObserver = _props_debounceResizeObserver === void 0 ? false : _props_debounceResizeObserver, _props_usePortal = props.usePortal, usePortal = _props_usePortal === void 0 ? true : _props_usePortal;
|
|
142
143
|
var ActivatorWrapper = activatorWrapper || "div";
|
|
143
144
|
var idValue = useId();
|
|
144
145
|
var idRef = useRef(idValue);
|
|
145
146
|
var initialWidthRef = useRef(null);
|
|
146
147
|
var popoverRef = useRef(null);
|
|
147
148
|
var activatorRef = useRef(null);
|
|
149
|
+
// Check if the activator is inside an inert element (e.g., table cells covered by fixed columns)
|
|
150
|
+
var isActivatorInert = activatorRef.current ? activatorRef.current.closest('[inert]') !== null : false;
|
|
151
|
+
// When disabled, prevent popover from opening
|
|
152
|
+
var active = isActivatorInert ? false : activeProp;
|
|
148
153
|
var _useState = _sliced_to_array(useState(_object_spread({
|
|
149
154
|
visibility: "hidden",
|
|
150
155
|
opacity: 0,
|
|
@@ -154,6 +159,25 @@ var styles = tv({
|
|
|
154
159
|
}, zIndexOverride ? {
|
|
155
160
|
zIndex: zIndexOverride
|
|
156
161
|
} : {})), 2), popoverStyle = _useState[0], setPopoverStyle = _useState[1];
|
|
162
|
+
// Reset popover style to hidden when it becomes active - this prevents flash
|
|
163
|
+
// of stale position from previous open. useLayoutEffect ensures this happens
|
|
164
|
+
// synchronously before paint.
|
|
165
|
+
useLayoutEffect(function() {
|
|
166
|
+
if (active) {
|
|
167
|
+
setPopoverStyle(_object_spread({
|
|
168
|
+
visibility: "hidden",
|
|
169
|
+
opacity: 0,
|
|
170
|
+
position: "absolute",
|
|
171
|
+
top: 0,
|
|
172
|
+
left: 0
|
|
173
|
+
}, zIndexOverride ? {
|
|
174
|
+
zIndex: zIndexOverride
|
|
175
|
+
} : {}));
|
|
176
|
+
}
|
|
177
|
+
}, [
|
|
178
|
+
active,
|
|
179
|
+
zIndexOverride
|
|
180
|
+
]);
|
|
157
181
|
useEffect(function() {
|
|
158
182
|
if (active) {
|
|
159
183
|
PopoverManager.open(idRef.current);
|
|
@@ -208,7 +232,7 @@ var styles = tv({
|
|
|
208
232
|
} else if (preferredAlignment === "right") {
|
|
209
233
|
left = fixed ? activatorRect.right - popoverRect.width : activatorRect.right + window.scrollX - popoverRect.width;
|
|
210
234
|
} else if (preferredAlignment === "center") {
|
|
211
|
-
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2;
|
|
235
|
+
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset;
|
|
212
236
|
}
|
|
213
237
|
} else if (position === "above") {
|
|
214
238
|
top = fixed ? activatorRect.top - popoverRect.height - TOP_SPACING : activatorRect.top + window.scrollY - popoverRect.height - TOP_SPACING;
|
|
@@ -217,7 +241,7 @@ var styles = tv({
|
|
|
217
241
|
} else if (preferredAlignment === "right") {
|
|
218
242
|
left = fixed ? activatorRect.right - popoverRect.width : activatorRect.right + window.scrollX - popoverRect.width;
|
|
219
243
|
} else if (preferredAlignment === "center") {
|
|
220
|
-
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2;
|
|
244
|
+
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset;
|
|
221
245
|
}
|
|
222
246
|
} else if (position === "cover") {
|
|
223
247
|
top = fixed ? activatorRect.top : activatorRect.top + window.scrollY;
|
|
@@ -226,7 +250,7 @@ var styles = tv({
|
|
|
226
250
|
} else if (preferredAlignment === "right") {
|
|
227
251
|
left = fixed ? activatorRect.right - popoverRect.width : activatorRect.right + window.scrollX - popoverRect.width;
|
|
228
252
|
} else if (preferredAlignment === "center") {
|
|
229
|
-
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2;
|
|
253
|
+
left = fixed ? activatorRect.left + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset : activatorRect.left + window.scrollX + activatorRect.width / 2 - popoverRect.width / 2 + horizontalOffset;
|
|
230
254
|
}
|
|
231
255
|
}
|
|
232
256
|
// Fallback adjustments for vertical positioning (when not in left/right mode)
|
|
@@ -239,11 +263,23 @@ var styles = tv({
|
|
|
239
263
|
}
|
|
240
264
|
}
|
|
241
265
|
// Fallback adjustments for horizontal positioning
|
|
242
|
-
if
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
266
|
+
// Only apply edge constraints if we're not using center alignment with custom offset
|
|
267
|
+
// This allows center alignment to work even near edges
|
|
268
|
+
if (preferredAlignment !== "center" || horizontalOffset === 0) {
|
|
269
|
+
if (left + popoverRect.width > windowWidth) {
|
|
270
|
+
left = windowWidth - popoverRect.width - EDGE_SPACING;
|
|
271
|
+
}
|
|
272
|
+
if (left < 0) {
|
|
273
|
+
left = EDGE_SPACING;
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
// For center alignment with offset, still respect edges but try to maintain centering
|
|
277
|
+
if (left + popoverRect.width > windowWidth) {
|
|
278
|
+
left = Math.max(EDGE_SPACING, windowWidth - popoverRect.width - EDGE_SPACING);
|
|
279
|
+
}
|
|
280
|
+
if (left < 0) {
|
|
281
|
+
left = EDGE_SPACING;
|
|
282
|
+
}
|
|
247
283
|
}
|
|
248
284
|
// Fallback adjustments for vertical positioning (when in left/right mode)
|
|
249
285
|
if (position === "left" || position === "right") {
|
|
@@ -283,7 +319,8 @@ var styles = tv({
|
|
|
283
319
|
observer.disconnect();
|
|
284
320
|
};
|
|
285
321
|
}, [
|
|
286
|
-
active
|
|
322
|
+
active,
|
|
323
|
+
debounceResizeObserver
|
|
287
324
|
]);
|
|
288
325
|
useLayoutEffect(function() {
|
|
289
326
|
if (!active || !popoverRef.current) return;
|
|
@@ -328,7 +365,7 @@ var styles = tv({
|
|
|
328
365
|
}
|
|
329
366
|
};
|
|
330
367
|
var handleResize = function handleResize() {
|
|
331
|
-
if (onClose) {
|
|
368
|
+
if (onClose && closeOnResize) {
|
|
332
369
|
onClose();
|
|
333
370
|
}
|
|
334
371
|
};
|
|
@@ -371,7 +408,15 @@ var styles = tv({
|
|
|
371
408
|
className: "Litho-PopoverActivator ".concat(activatorDisplayType),
|
|
372
409
|
children: memoizedActivator
|
|
373
410
|
}),
|
|
374
|
-
active && typeof children !== "undefined" && /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsx("div", {
|
|
411
|
+
active && typeof children !== "undefined" && (usePortal ? /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsx("div", {
|
|
412
|
+
className: "@container",
|
|
413
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
414
|
+
ref: popoverRef,
|
|
415
|
+
style: popoverStyle,
|
|
416
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
417
|
+
children: children
|
|
418
|
+
})
|
|
419
|
+
}), document.body) : /*#__PURE__*/ _jsx("div", {
|
|
375
420
|
className: "@container",
|
|
376
421
|
children: /*#__PURE__*/ _jsx("div", {
|
|
377
422
|
ref: popoverRef,
|
|
@@ -379,7 +424,7 @@ var styles = tv({
|
|
|
379
424
|
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
380
425
|
children: children
|
|
381
426
|
})
|
|
382
|
-
})
|
|
427
|
+
}))
|
|
383
428
|
]
|
|
384
429
|
});
|
|
385
430
|
}
|
|
@@ -52,7 +52,7 @@ import Icon from "./Icon.js";
|
|
|
52
52
|
import Label from "./Label.js";
|
|
53
53
|
import Link from "./Link.js";
|
|
54
54
|
import Text from "./Text.js";
|
|
55
|
-
import { CaretDownMinor, CircleAlertMajor } from "@shopify/polaris-icons";
|
|
55
|
+
import { CaretDownMinor, CircleAlertMajor, MagicMajor } from "@shopify/polaris-icons";
|
|
56
56
|
var styles = tv({
|
|
57
57
|
base: "Litho-Select relative border border-form-border rounded-md",
|
|
58
58
|
variants: {
|
|
@@ -188,6 +188,10 @@ var contentStyles = tv({
|
|
|
188
188
|
}),
|
|
189
189
|
labelAction && /*#__PURE__*/ _jsx(Link, {
|
|
190
190
|
onClick: labelAction.onAction,
|
|
191
|
+
insight: labelAction.insight,
|
|
192
|
+
icon: labelAction.insight ? MagicMajor : undefined,
|
|
193
|
+
color: labelAction.insight ? "insight" : undefined,
|
|
194
|
+
disabled: labelAction.disabled,
|
|
191
195
|
removeUnderline: true,
|
|
192
196
|
children: labelAction.content
|
|
193
197
|
})
|