@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,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
get ModalContext () {
|
|
14
|
+
return ModalContext;
|
|
15
|
+
},
|
|
16
|
+
get default () {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
21
|
+
var _polarisicons = require("@shopify/polaris-icons");
|
|
22
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
23
|
+
var _reactdom = require("react-dom");
|
|
24
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
25
|
+
var _AppProvider = require("../components/AppProvider");
|
|
26
|
+
var _index = require("../index");
|
|
27
|
+
function _array_like_to_array(arr, len) {
|
|
28
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
29
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
30
|
+
return arr2;
|
|
31
|
+
}
|
|
32
|
+
function _array_with_holes(arr) {
|
|
33
|
+
if (Array.isArray(arr)) return arr;
|
|
34
|
+
}
|
|
35
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
36
|
+
if (typeof WeakMap !== "function") return null;
|
|
37
|
+
var cacheBabelInterop = new WeakMap();
|
|
38
|
+
var cacheNodeInterop = new WeakMap();
|
|
39
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
40
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
41
|
+
})(nodeInterop);
|
|
42
|
+
}
|
|
43
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
44
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
45
|
+
return obj;
|
|
46
|
+
}
|
|
47
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
48
|
+
return {
|
|
49
|
+
default: obj
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
53
|
+
if (cache && cache.has(obj)) {
|
|
54
|
+
return cache.get(obj);
|
|
55
|
+
}
|
|
56
|
+
var newObj = {
|
|
57
|
+
__proto__: null
|
|
58
|
+
};
|
|
59
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
|
+
for(var key in obj){
|
|
61
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
62
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
63
|
+
if (desc && (desc.get || desc.set)) {
|
|
64
|
+
Object.defineProperty(newObj, key, desc);
|
|
65
|
+
} else {
|
|
66
|
+
newObj[key] = obj[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
newObj.default = obj;
|
|
71
|
+
if (cache) {
|
|
72
|
+
cache.set(obj, newObj);
|
|
73
|
+
}
|
|
74
|
+
return newObj;
|
|
75
|
+
}
|
|
76
|
+
function _iterable_to_array_limit(arr, i) {
|
|
77
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
78
|
+
if (_i == null) return;
|
|
79
|
+
var _arr = [];
|
|
80
|
+
var _n = true;
|
|
81
|
+
var _d = false;
|
|
82
|
+
var _s, _e;
|
|
83
|
+
try {
|
|
84
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
85
|
+
_arr.push(_s.value);
|
|
86
|
+
if (i && _arr.length === i) break;
|
|
87
|
+
}
|
|
88
|
+
} catch (err) {
|
|
89
|
+
_d = true;
|
|
90
|
+
_e = err;
|
|
91
|
+
} finally{
|
|
92
|
+
try {
|
|
93
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
94
|
+
} finally{
|
|
95
|
+
if (_d) throw _e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return _arr;
|
|
99
|
+
}
|
|
100
|
+
function _non_iterable_rest() {
|
|
101
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
102
|
+
}
|
|
103
|
+
function _sliced_to_array(arr, i) {
|
|
104
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
105
|
+
}
|
|
106
|
+
function _type_of(obj) {
|
|
107
|
+
"@swc/helpers - typeof";
|
|
108
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
109
|
+
}
|
|
110
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
111
|
+
if (!o) return;
|
|
112
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
113
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
114
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
115
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
116
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
117
|
+
}
|
|
118
|
+
var ModalContext = /*#__PURE__*/ (0, _react.createContext)(false);
|
|
119
|
+
var containerStyles = (0, _tailwindvariants.tv)({
|
|
120
|
+
base: "Litho-ModalContainer fixed inset-0 block flex flex-col justify-end md:justify-center items-center pointer-events-none"
|
|
121
|
+
});
|
|
122
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
123
|
+
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",
|
|
124
|
+
variants: {
|
|
125
|
+
size: {
|
|
126
|
+
default: "max-w-200 md:max-w-160 md:rounded-md max-h-[calc(100vh-40px)]",
|
|
127
|
+
large: "max-w-300 md:rounded-md max-h-[calc(100vh-40px)]",
|
|
128
|
+
full: "h-full max-w-full max-h-screen"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
defaultVariants: {
|
|
132
|
+
size: "default"
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
var overlayStyles = (0, _tailwindvariants.tv)({
|
|
136
|
+
base: "Litho-ModalOverlay fixed inset-0 block bg-tint-10 dark:bg-tint-25"
|
|
137
|
+
});
|
|
138
|
+
var headerStyles = (0, _tailwindvariants.tv)({
|
|
139
|
+
base: "Litho-ModalHeader min-h-15 flex items-center py-2 pl-4 pr-3 flex-none",
|
|
140
|
+
variants: {
|
|
141
|
+
hasChildren: {
|
|
142
|
+
true: "border-b",
|
|
143
|
+
false: ""
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
defaultVariants: {
|
|
147
|
+
hasChildren: true
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
var sectionStyles = (0, _tailwindvariants.tv)({
|
|
151
|
+
base: "Litho-ModalSection border-b border-edge-default last:border-b-0",
|
|
152
|
+
variants: {
|
|
153
|
+
flush: {
|
|
154
|
+
true: "",
|
|
155
|
+
false: "p-4"
|
|
156
|
+
},
|
|
157
|
+
showHeader: {
|
|
158
|
+
true: "pt-2",
|
|
159
|
+
false: ""
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
defaultVariants: {
|
|
163
|
+
flush: false
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Modal component for displaying a customizable dialog.
|
|
168
|
+
*
|
|
169
|
+
* @param {Object} props - The component props.
|
|
170
|
+
* @param {React.ReactNode} [props.children] - The content of the modal.
|
|
171
|
+
* @param {string} [props.title] - The title of the modal.
|
|
172
|
+
* @param {string} [props.subtitle] - The subtitle of the modal.
|
|
173
|
+
* @param {boolean} [props.open=false] - Whether the modal is open.
|
|
174
|
+
* @param {Function} [props.onClose] - Callback function for closing the modal.
|
|
175
|
+
* @param {boolean} [props.sectioned=false] - Whether the modal content should be sectioned.
|
|
176
|
+
* @param {Object} [props.primaryAction] - The primary action for the modal.
|
|
177
|
+
* @param {string} [props.primaryAction.content] - Content of the primary action button.
|
|
178
|
+
* @param {Function} [props.primaryAction.onAction] - Callback for the primary action.
|
|
179
|
+
* @param {boolean} [props.primaryAction.loading=false] - Whether the primary action is loading.
|
|
180
|
+
* @param {boolean} [props.primaryAction.disabled=false] - Whether the primary action is disabled.
|
|
181
|
+
* @param {boolean} [props.primaryAction.destructive=false] - Whether the primary action is destructive.
|
|
182
|
+
* @param {Object} [props.secondaryAction] - The secondary action for the modal.
|
|
183
|
+
* @param {string} [props.secondaryAction.content] - Content of the secondary action button.
|
|
184
|
+
* @param {Function} [props.secondaryAction.onAction] - Callback for the secondary action.
|
|
185
|
+
* @param {boolean} [props.secondaryAction.disabled=false] - Whether the secondary action is disabled.
|
|
186
|
+
* @param {Object[]} [props.secondaryActions=[]] - Additional secondary actions.
|
|
187
|
+
* @param {Object} [props.destructiveAction] - A destructive action for the modal.
|
|
188
|
+
* @param {boolean} [props.loading=false] - Whether the modal is in a loading state.
|
|
189
|
+
* @param {string} [props.size="default"] - The size of the modal (default, large, or full).
|
|
190
|
+
* @param {React.ReactNode} [props.leftAccessory] - Left accessory content in the footer.
|
|
191
|
+
* @param {boolean} [props.hideCloseButton=false] - Whether to hide the close button.
|
|
192
|
+
* @param {number} [props.zIndexOverride=1000] - The z-index of the modal.
|
|
193
|
+
* @returns {React.ReactPortal|null} The rendered modal component or null if not open.
|
|
194
|
+
*/ function Modal() {
|
|
195
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
196
|
+
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;
|
|
197
|
+
var setModalIsOpen = (0, _react.useContext)(_AppProvider.FrameContext).setModalIsOpen;
|
|
198
|
+
var modalContentRef = (0, _react.useRef)(null);
|
|
199
|
+
var hasChildren = !!children;
|
|
200
|
+
var classes = styles({
|
|
201
|
+
sectioned: sectioned,
|
|
202
|
+
size: size
|
|
203
|
+
});
|
|
204
|
+
var containerClasses = containerStyles();
|
|
205
|
+
var headerClasses = headerStyles({
|
|
206
|
+
hasChildren: hasChildren
|
|
207
|
+
});
|
|
208
|
+
var overlayClasses = overlayStyles();
|
|
209
|
+
var sectionClasses = sectionStyles();
|
|
210
|
+
var _useState = _sliced_to_array((0, _react.useState)(null), 2), container = _useState[0], setContainer = _useState[1];
|
|
211
|
+
(0, _react.useEffect)(function() {
|
|
212
|
+
var div = document.createElement("div");
|
|
213
|
+
div.className = "@container Litho-ModalPortal";
|
|
214
|
+
setContainer(div);
|
|
215
|
+
document.body.appendChild(div);
|
|
216
|
+
return function() {
|
|
217
|
+
document.body.removeChild(div);
|
|
218
|
+
};
|
|
219
|
+
}, []);
|
|
220
|
+
(0, _react.useEffect)(function() {
|
|
221
|
+
setModalIsOpen(open);
|
|
222
|
+
if (!open || !onClose) return;
|
|
223
|
+
var handleKeyDown = function(event) {
|
|
224
|
+
if (event.key === "Escape") {
|
|
225
|
+
onClose();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
229
|
+
return function() {
|
|
230
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
231
|
+
};
|
|
232
|
+
}, [
|
|
233
|
+
open,
|
|
234
|
+
onClose
|
|
235
|
+
]);
|
|
236
|
+
// Focus first input when modal opens
|
|
237
|
+
(0, _react.useLayoutEffect)(function() {
|
|
238
|
+
if (open && container && modalContentRef.current) {
|
|
239
|
+
var focusable = modalContentRef.current.querySelector('input:not([type="hidden"]), select, textarea');
|
|
240
|
+
if (focusable) focusable.focus();
|
|
241
|
+
}
|
|
242
|
+
}, [
|
|
243
|
+
open,
|
|
244
|
+
container
|
|
245
|
+
]);
|
|
246
|
+
if (!open) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
var showFooter = primaryAction || secondaryActions.length > 0 || destructiveAction || leftAccessory;
|
|
250
|
+
return container && /*#__PURE__*/ (0, _reactdom.createPortal)(/*#__PURE__*/ (0, _jsxruntime.jsxs)(ModalContext.Provider, {
|
|
251
|
+
value: true,
|
|
252
|
+
children: [
|
|
253
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
254
|
+
className: containerClasses,
|
|
255
|
+
style: zIndexOverride ? {
|
|
256
|
+
zIndex: zIndexOverride
|
|
257
|
+
} : {},
|
|
258
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
259
|
+
className: classes,
|
|
260
|
+
ref: modalContentRef,
|
|
261
|
+
children: [
|
|
262
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
263
|
+
className: headerClasses,
|
|
264
|
+
children: [
|
|
265
|
+
backAction && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
266
|
+
className: "Litho-ModalHeader__BackAction pr-3",
|
|
267
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
268
|
+
plain: true,
|
|
269
|
+
onClick: backAction,
|
|
270
|
+
icon: _polarisicons.ArrowLeftMinor
|
|
271
|
+
})
|
|
272
|
+
}),
|
|
273
|
+
(title || subtitle) && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
274
|
+
className: "flex flex-1 flex-col gap-0",
|
|
275
|
+
children: [
|
|
276
|
+
title && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
277
|
+
variant: "headingLg",
|
|
278
|
+
fontWeight: "semibold",
|
|
279
|
+
children: title
|
|
280
|
+
}),
|
|
281
|
+
subtitle && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
282
|
+
variant: "bodyMd",
|
|
283
|
+
color: "subdued",
|
|
284
|
+
children: subtitle
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
}),
|
|
288
|
+
onClose && !hideCloseButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
289
|
+
plain: true,
|
|
290
|
+
icon: _polarisicons.CancelMajor,
|
|
291
|
+
onClick: onClose
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
}),
|
|
295
|
+
hasChildren && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
296
|
+
className: "Litho-ModalBody grow overflow-y-auto overscroll-contain",
|
|
297
|
+
children: loading ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
298
|
+
className: "flex justify-center items-center h-full py-12",
|
|
299
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Spinner, {})
|
|
300
|
+
}) : sectioned ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
301
|
+
className: sectionClasses,
|
|
302
|
+
children: children
|
|
303
|
+
}) : children
|
|
304
|
+
}),
|
|
305
|
+
showFooter ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
306
|
+
className: "Litho-ModalFooter min-h-15 flex items-center justify-between border-t py-2 px-4 flex-none",
|
|
307
|
+
children: [
|
|
308
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
309
|
+
className: "flex gap-2",
|
|
310
|
+
children: [
|
|
311
|
+
destructiveAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
312
|
+
destructive: destructiveAction.destructive === false ? false : true,
|
|
313
|
+
onClick: destructiveAction.onAction,
|
|
314
|
+
loading: destructiveAction.loading,
|
|
315
|
+
icon: destructiveAction.icon,
|
|
316
|
+
disabled: destructiveAction.disabled,
|
|
317
|
+
primary: destructiveAction.primary,
|
|
318
|
+
url: destructiveAction.url,
|
|
319
|
+
tooltip: destructiveAction.tooltip,
|
|
320
|
+
tooltipAlignment: destructiveAction.tooltipAlignment,
|
|
321
|
+
children: destructiveAction.content || "Delete"
|
|
322
|
+
}),
|
|
323
|
+
leftAccessory && leftAccessory
|
|
324
|
+
]
|
|
325
|
+
}),
|
|
326
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
327
|
+
className: "flex gap-2",
|
|
328
|
+
children: [
|
|
329
|
+
(secondaryActions === null || secondaryActions === void 0 ? void 0 : secondaryActions.length) > 0 && secondaryActions.map(function(action) {
|
|
330
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
331
|
+
onClick: action.onAction,
|
|
332
|
+
disabled: action.disabled,
|
|
333
|
+
url: action.url,
|
|
334
|
+
tooltip: action.tooltip,
|
|
335
|
+
tooltipAlignment: action.tooltipAlignment,
|
|
336
|
+
children: action.content
|
|
337
|
+
}, action.content);
|
|
338
|
+
}),
|
|
339
|
+
secondaryAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
340
|
+
onClick: secondaryAction.onAction,
|
|
341
|
+
disabled: secondaryAction.disabled,
|
|
342
|
+
url: secondaryAction.url,
|
|
343
|
+
tooltip: secondaryAction.tooltip,
|
|
344
|
+
tooltipAlignment: secondaryAction.tooltipAlignment,
|
|
345
|
+
children: secondaryAction.content || "Cancel"
|
|
346
|
+
}),
|
|
347
|
+
primaryAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
348
|
+
primary: true,
|
|
349
|
+
icon: primaryAction.icon,
|
|
350
|
+
onClick: primaryAction.onAction,
|
|
351
|
+
loading: primaryAction.loading,
|
|
352
|
+
disabled: primaryAction.disabled,
|
|
353
|
+
destructive: primaryAction.destructive,
|
|
354
|
+
url: primaryAction.url,
|
|
355
|
+
tooltip: primaryAction.tooltip,
|
|
356
|
+
tooltipAlignment: primaryAction.tooltipAlignment,
|
|
357
|
+
children: primaryAction.content || "Save"
|
|
358
|
+
})
|
|
359
|
+
]
|
|
360
|
+
})
|
|
361
|
+
]
|
|
362
|
+
}) : null
|
|
363
|
+
]
|
|
364
|
+
})
|
|
365
|
+
}),
|
|
366
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
367
|
+
className: overlayClasses,
|
|
368
|
+
onClick: onClose,
|
|
369
|
+
style: zIndexOverride ? {
|
|
370
|
+
zIndex: zIndexOverride - 1
|
|
371
|
+
} : {}
|
|
372
|
+
})
|
|
373
|
+
]
|
|
374
|
+
}), container);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Section component for use within the Modal.
|
|
378
|
+
*
|
|
379
|
+
* @param {Object} props - The component props.
|
|
380
|
+
* @param {React.ReactNode} [props.children] - The content of the section.
|
|
381
|
+
* @param {boolean} [props.flush=false] - Whether the section should be flush with no padding.
|
|
382
|
+
* @returns {JSX.Element} The rendered section.
|
|
383
|
+
*/ function Section() {
|
|
384
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
385
|
+
var children = props.children, flush = props.flush, title = props.title, _props_titleVariant = props.titleVariant, titleVariant = _props_titleVariant === void 0 ? "headingSm" : _props_titleVariant, description = props.description, action = props.action, icon = props.icon, accessory = props.accessory, tooltip = props.tooltip;
|
|
386
|
+
var showHeader = !!(title || action);
|
|
387
|
+
var sectionClasses = sectionStyles({
|
|
388
|
+
flush: flush,
|
|
389
|
+
showHeader: showHeader
|
|
390
|
+
});
|
|
391
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
392
|
+
className: sectionClasses,
|
|
393
|
+
children: [
|
|
394
|
+
showHeader && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
395
|
+
className: "Litho-ModalSection__SectionHeader min-h-9 md:min-h-10",
|
|
396
|
+
children: [
|
|
397
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
398
|
+
className: "flex items-center justify-between gap-1",
|
|
399
|
+
children: [
|
|
400
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
401
|
+
className: "flex items-center gap-2 min-h-8",
|
|
402
|
+
children: [
|
|
403
|
+
icon && typeof icon === "function" && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
404
|
+
source: icon,
|
|
405
|
+
color: "subdued"
|
|
406
|
+
}),
|
|
407
|
+
icon && (typeof icon === "undefined" ? "undefined" : _type_of(icon)) === "object" && icon,
|
|
408
|
+
title && typeof title === "string" ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
409
|
+
variant: titleVariant,
|
|
410
|
+
children: title
|
|
411
|
+
}) : title,
|
|
412
|
+
tooltip && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Tooltip, {
|
|
413
|
+
content: tooltip,
|
|
414
|
+
preferredPosition: "above"
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
}),
|
|
418
|
+
accessory && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
419
|
+
className: "Litho-ModalSection__HeaderAccessory pr-2",
|
|
420
|
+
children: accessory
|
|
421
|
+
}),
|
|
422
|
+
action && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
423
|
+
className: "Litho-ModalSection__HeaderAction relative left-2",
|
|
424
|
+
children: action.content ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
425
|
+
link: true,
|
|
426
|
+
onClick: action.onAction,
|
|
427
|
+
primary: action.primary,
|
|
428
|
+
destructive: action.destructive,
|
|
429
|
+
icon: action.icon,
|
|
430
|
+
loading: action.loading,
|
|
431
|
+
disabled: action.disabled,
|
|
432
|
+
connectedDisclosure: action.connectedDisclosure,
|
|
433
|
+
children: action.content
|
|
434
|
+
}) : action
|
|
435
|
+
})
|
|
436
|
+
]
|
|
437
|
+
}),
|
|
438
|
+
description && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
439
|
+
color: "subdued",
|
|
440
|
+
children: description
|
|
441
|
+
})
|
|
442
|
+
]
|
|
443
|
+
}),
|
|
444
|
+
children
|
|
445
|
+
]
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
Modal.Section = Section;
|
|
449
|
+
var _default = Modal;
|