@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.
Files changed (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/dist/cjs/components/ActionList.js +267 -0
  4. package/dist/cjs/components/AnnouncementBar.js +73 -0
  5. package/dist/cjs/components/AppProvider.js +245 -0
  6. package/dist/cjs/components/Autocomplete.js +351 -0
  7. package/dist/cjs/components/Badge.js +234 -0
  8. package/dist/cjs/components/Banner.js +264 -0
  9. package/dist/cjs/components/Box.js +247 -0
  10. package/dist/cjs/components/Button.js +1018 -0
  11. package/dist/cjs/components/ButtonGroup.js +196 -0
  12. package/dist/cjs/components/Card.js +593 -0
  13. package/dist/cjs/components/Checkbox.js +175 -0
  14. package/dist/cjs/components/ChoiceList.js +160 -0
  15. package/dist/cjs/components/Collapsible.js +42 -0
  16. package/dist/cjs/components/ColorField.js +159 -0
  17. package/dist/cjs/components/ContextualSaveBar.js +53 -0
  18. package/dist/cjs/components/DatePicker.js +547 -0
  19. package/dist/cjs/components/Divider.js +50 -0
  20. package/dist/cjs/components/DropZone.js +547 -0
  21. package/dist/cjs/components/EmptyState.js +111 -0
  22. package/dist/cjs/components/Filters.js +874 -0
  23. package/dist/cjs/components/FooterHelp.js +48 -0
  24. package/dist/cjs/components/Form.js +44 -0
  25. package/dist/cjs/components/Frame.js +386 -0
  26. package/dist/cjs/components/FrameSaveBar.js +239 -0
  27. package/dist/cjs/components/Grid.js +151 -0
  28. package/dist/cjs/components/HorizontalStack.js +180 -0
  29. package/dist/cjs/components/Icon.js +346 -0
  30. package/dist/cjs/components/Image.js +191 -0
  31. package/dist/cjs/components/InlineError.js +57 -0
  32. package/dist/cjs/components/Label.js +78 -0
  33. package/dist/cjs/components/Layout.js +228 -0
  34. package/dist/cjs/components/LayoutSection.js +133 -0
  35. package/dist/cjs/components/Link.js +128 -0
  36. package/dist/cjs/components/List.js +69 -0
  37. package/dist/cjs/components/Listbox.js +211 -0
  38. package/dist/cjs/components/Loading.js +103 -0
  39. package/dist/cjs/components/Modal.js +449 -0
  40. package/dist/cjs/components/Navigation.js +331 -0
  41. package/dist/cjs/components/Page.js +529 -0
  42. package/dist/cjs/components/Pagination.js +109 -0
  43. package/dist/cjs/components/Pane.js +128 -0
  44. package/dist/cjs/components/Popover.js +365 -0
  45. package/dist/cjs/components/PopoverManager.js +34 -0
  46. package/dist/cjs/components/ProgressBar.js +124 -0
  47. package/dist/cjs/components/RadioButton.js +172 -0
  48. package/dist/cjs/components/RadioButtonCard.js +193 -0
  49. package/dist/cjs/components/RangeSlider.js +235 -0
  50. package/dist/cjs/components/ResourceList.js +105 -0
  51. package/dist/cjs/components/Select.js +300 -0
  52. package/dist/cjs/components/SkeletonText.js +130 -0
  53. package/dist/cjs/components/Spinner.js +72 -0
  54. package/dist/cjs/components/Table.js +1184 -0
  55. package/dist/cjs/components/Tabs.js +421 -0
  56. package/dist/cjs/components/Tag.js +165 -0
  57. package/dist/cjs/components/Text.js +274 -0
  58. package/dist/cjs/components/TextField.js +584 -0
  59. package/dist/cjs/components/Thumbnail.js +73 -0
  60. package/dist/cjs/components/TimePicker.js +23 -0
  61. package/dist/cjs/components/Tip.js +220 -0
  62. package/dist/cjs/components/Tooltip.js +431 -0
  63. package/dist/cjs/components/TopBar.js +210 -0
  64. package/dist/cjs/components/VerticalStack.js +161 -0
  65. package/dist/cjs/index.js +308 -0
  66. package/dist/cjs/styles/Table.js +591 -0
  67. package/dist/cjs/utilities/dates.js +339 -0
  68. package/dist/cjs/utilities/useIndexResourceState.js +175 -0
  69. package/dist/cjs/utilities/useMounted.js +67 -0
  70. package/dist/cjs/utilities/useTableScrollState.js +142 -0
  71. package/dist/esm/components/ActionList.js +216 -0
  72. package/dist/esm/components/AnnouncementBar.js +63 -0
  73. package/dist/esm/components/AppProvider.js +185 -0
  74. package/dist/esm/components/Autocomplete.js +300 -0
  75. package/dist/esm/components/Badge.js +225 -0
  76. package/dist/esm/components/Banner.js +254 -0
  77. package/dist/esm/components/Box.js +238 -0
  78. package/dist/esm/components/Button.js +967 -0
  79. package/dist/esm/components/ButtonGroup.js +137 -0
  80. package/dist/esm/components/Card.js +537 -0
  81. package/dist/esm/components/Checkbox.js +165 -0
  82. package/dist/esm/components/ChoiceList.js +145 -0
  83. package/dist/esm/components/Collapsible.js +32 -0
  84. package/dist/esm/components/ColorField.js +149 -0
  85. package/dist/esm/components/ContextualSaveBar.js +43 -0
  86. package/dist/esm/components/DatePicker.js +532 -0
  87. package/dist/esm/components/Divider.js +41 -0
  88. package/dist/esm/components/DropZone.js +537 -0
  89. package/dist/esm/components/EmptyState.js +101 -0
  90. package/dist/esm/components/Filters.js +823 -0
  91. package/dist/esm/components/FooterHelp.js +38 -0
  92. package/dist/esm/components/Form.js +35 -0
  93. package/dist/esm/components/Frame.js +376 -0
  94. package/dist/esm/components/FrameSaveBar.js +229 -0
  95. package/dist/esm/components/Grid.js +142 -0
  96. package/dist/esm/components/HorizontalStack.js +171 -0
  97. package/dist/esm/components/Icon.js +296 -0
  98. package/dist/esm/components/Image.js +141 -0
  99. package/dist/esm/components/InlineError.js +43 -0
  100. package/dist/esm/components/Label.js +63 -0
  101. package/dist/esm/components/Layout.js +164 -0
  102. package/dist/esm/components/LayoutSection.js +82 -0
  103. package/dist/esm/components/Link.js +119 -0
  104. package/dist/esm/components/List.js +61 -0
  105. package/dist/esm/components/Listbox.js +201 -0
  106. package/dist/esm/components/Loading.js +93 -0
  107. package/dist/esm/components/Modal.js +390 -0
  108. package/dist/esm/components/Navigation.js +321 -0
  109. package/dist/esm/components/Page.js +473 -0
  110. package/dist/esm/components/Pagination.js +99 -0
  111. package/dist/esm/components/Pane.js +118 -0
  112. package/dist/esm/components/Popover.js +350 -0
  113. package/dist/esm/components/PopoverManager.js +24 -0
  114. package/dist/esm/components/ProgressBar.js +114 -0
  115. package/dist/esm/components/RadioButton.js +157 -0
  116. package/dist/esm/components/RadioButtonCard.js +178 -0
  117. package/dist/esm/components/RangeSlider.js +225 -0
  118. package/dist/esm/components/ResourceList.js +95 -0
  119. package/dist/esm/components/Select.js +285 -0
  120. package/dist/esm/components/SkeletonText.js +120 -0
  121. package/dist/esm/components/Spinner.js +63 -0
  122. package/dist/esm/components/Table.js +1129 -0
  123. package/dist/esm/components/Tabs.js +366 -0
  124. package/dist/esm/components/Tag.js +151 -0
  125. package/dist/esm/components/Text.js +265 -0
  126. package/dist/esm/components/TextField.js +533 -0
  127. package/dist/esm/components/Thumbnail.js +63 -0
  128. package/dist/esm/components/TimePicker.js +13 -0
  129. package/dist/esm/components/Tip.js +169 -0
  130. package/dist/esm/components/Tooltip.js +380 -0
  131. package/dist/esm/components/TopBar.js +200 -0
  132. package/dist/esm/components/VerticalStack.js +152 -0
  133. package/dist/esm/index.js +61 -0
  134. package/dist/esm/styles/Table.js +581 -0
  135. package/dist/esm/utilities/dates.js +289 -0
  136. package/dist/esm/utilities/useIndexResourceState.js +158 -0
  137. package/dist/esm/utilities/useMounted.js +57 -0
  138. package/dist/esm/utilities/useTableScrollState.js +132 -0
  139. package/index.css +1137 -0
  140. package/package.json +53 -0
@@ -0,0 +1,473 @@
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 _array_without_holes(arr) {
11
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
12
+ }
13
+ function _define_property(obj, key, value) {
14
+ if (key in obj) {
15
+ Object.defineProperty(obj, key, {
16
+ value: value,
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true
20
+ });
21
+ } else {
22
+ obj[key] = value;
23
+ }
24
+ return obj;
25
+ }
26
+ function _iterable_to_array(iter) {
27
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
28
+ }
29
+ function _iterable_to_array_limit(arr, i) {
30
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
31
+ if (_i == null) return;
32
+ var _arr = [];
33
+ var _n = true;
34
+ var _d = false;
35
+ var _s, _e;
36
+ try {
37
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
38
+ _arr.push(_s.value);
39
+ if (i && _arr.length === i) break;
40
+ }
41
+ } catch (err) {
42
+ _d = true;
43
+ _e = err;
44
+ } finally{
45
+ try {
46
+ if (!_n && _i["return"] != null) _i["return"]();
47
+ } finally{
48
+ if (_d) throw _e;
49
+ }
50
+ }
51
+ return _arr;
52
+ }
53
+ function _non_iterable_rest() {
54
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55
+ }
56
+ function _non_iterable_spread() {
57
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
58
+ }
59
+ function _object_spread(target) {
60
+ for(var i = 1; i < arguments.length; i++){
61
+ var source = arguments[i] != null ? arguments[i] : {};
62
+ var ownKeys = Object.keys(source);
63
+ if (typeof Object.getOwnPropertySymbols === "function") {
64
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
65
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
66
+ }));
67
+ }
68
+ ownKeys.forEach(function(key) {
69
+ _define_property(target, key, source[key]);
70
+ });
71
+ }
72
+ return target;
73
+ }
74
+ function ownKeys(object, enumerableOnly) {
75
+ var keys = Object.keys(object);
76
+ if (Object.getOwnPropertySymbols) {
77
+ var symbols = Object.getOwnPropertySymbols(object);
78
+ if (enumerableOnly) {
79
+ symbols = symbols.filter(function(sym) {
80
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
81
+ });
82
+ }
83
+ keys.push.apply(keys, symbols);
84
+ }
85
+ return keys;
86
+ }
87
+ function _object_spread_props(target, source) {
88
+ source = source != null ? source : {};
89
+ if (Object.getOwnPropertyDescriptors) {
90
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
91
+ } else {
92
+ ownKeys(Object(source)).forEach(function(key) {
93
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
94
+ });
95
+ }
96
+ return target;
97
+ }
98
+ function _sliced_to_array(arr, i) {
99
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
100
+ }
101
+ function _to_consumable_array(arr) {
102
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
103
+ }
104
+ function _unsupported_iterable_to_array(o, minLen) {
105
+ if (!o) return;
106
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
107
+ var n = Object.prototype.toString.call(o).slice(8, -1);
108
+ if (n === "Object" && o.constructor) n = o.constructor.name;
109
+ if (n === "Map" || n === "Set") return Array.from(n);
110
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
111
+ }
112
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
113
+ import React, { useContext, useRef, useState } from "react";
114
+ import { tv } from "tailwind-variants";
115
+ import { FrameContext } from "./AppProvider.js";
116
+ import Text from "./Text.js";
117
+ import Button from "./Button.js";
118
+ import Popover from "./Popover.js";
119
+ import ActionList from "./ActionList.js";
120
+ import { ArrowLeftMinor, MobileHorizontalDotsMajor } from "@shopify/polaris-icons";
121
+ var styles = tv({
122
+ base: "Litho-Page w-full mx-auto",
123
+ variants: {
124
+ narrowWidth: {
125
+ true: "max-w-160"
126
+ },
127
+ fullWidth: {
128
+ true: "max-w-full"
129
+ }
130
+ },
131
+ compoundVariants: [
132
+ {
133
+ fullWidth: false,
134
+ narrowWidth: false,
135
+ className: "max-w-250"
136
+ }
137
+ ],
138
+ defaultVariants: {
139
+ narrowWidth: false,
140
+ fullWidth: false
141
+ }
142
+ });
143
+ var headerStyles = tv({
144
+ base: "Litho-Page__Header flex items-center pt-4 px-4 @lg:px-5",
145
+ variants: {
146
+ showTitleInTopBar: {
147
+ true: "@md:top-[var(--litho-header-offset)] @md:fixed @md:h-14 right-0 left-0 @md:left-53.5 @md:pt-0",
148
+ false: "@md:pt-8"
149
+ },
150
+ paneIsOpen: {
151
+ true: "@md:mr-[var(--litho-pane-width)]"
152
+ }
153
+ },
154
+ defaultVariants: {
155
+ showTitleInTopBar: true
156
+ }
157
+ });
158
+ var innerHeaderStyles = tv({
159
+ base: "Litho-Page__HeaderInner mx-auto w-full flex justify-between flex-1 items-center gap-2",
160
+ variants: {
161
+ narrowWidth: {
162
+ true: "max-w-150.5"
163
+ }
164
+ },
165
+ compoundVariants: [
166
+ {
167
+ fullWidth: false,
168
+ narrowWidth: false,
169
+ className: "max-w-240"
170
+ }
171
+ ],
172
+ defaultVariants: {
173
+ fullWidth: false,
174
+ narrowWidth: false
175
+ }
176
+ });
177
+ var contentStyles = tv({
178
+ base: "Litho-Page__Content relative",
179
+ variants: {
180
+ showHeader: {
181
+ true: "py-4 @lg:pb-5"
182
+ },
183
+ wrapInContentContainer: {
184
+ true: "px-4 @lg:px-5",
185
+ false: ""
186
+ }
187
+ },
188
+ defaultVariants: {
189
+ showHeader: true,
190
+ wrapInContentContainer: true
191
+ }
192
+ });
193
+ /**
194
+ * Page component that provides a structured layout with a header, primary and secondary actions, and content.
195
+ *
196
+ * @param {Object} props - Props for the component.
197
+ * @param {string|React.ReactNode} props.title - The title of the page. Can be a string or React element.
198
+ * @param {string|React.ReactNode} props.subtitle - The subtitle of the page. Can be a string or React element.
199
+ * @param {Object} [props.backAction] - Configuration for the back action button.
200
+ * @param {Function} [props.backAction.onAction] - Callback when the back action is triggered.
201
+ * @param {string} [props.backAction.accessibilityLabel] - Accessibility label for the back action button.
202
+ * @param {boolean} [props.narrowWidth=false] - Whether to use a narrow width layout.
203
+ * @param {boolean} [props.fullWidth=false] - Whether to use a full-width layout.
204
+ * @param {Object} [props.primaryAction] - Configuration for the primary action button.
205
+ * @param {Function} [props.primaryAction.onAction] - Callback when the primary action is triggered.
206
+ * @param {boolean} [props.primaryAction.loading] - Whether the primary action button is in a loading state.
207
+ * @param {boolean} [props.primaryAction.disabled] - Whether the primary action button is disabled.
208
+ * @param {boolean} [props.primaryAction.destructive] - Whether the primary action button is styled as destructive.
209
+ * @param {string} [props.primaryAction.tooltip] - Tooltip to show when hovering over the primary action button.
210
+ * @param {React.ReactNode} [props.primaryAction.content="Save"] - Content for the primary action button.
211
+ * @param {Object[]} [props.secondaryActions=[]] - List of secondary actions.
212
+ * @param {string} [props.moreActionsLabel="Actions"] - Label for the "More Actions" button in mobile view.
213
+ * @param {React.ReactNode} [props.titleMetadata] - Metadata displayed alongside the title.
214
+ * @param {React.ReactNode} [props.children] - Content for the main section of the page.
215
+ * @param {Object} [props.footerActions] - Configuration for the footer actions.
216
+ * @param {string} [props.className] - Additional CSS classes for the Page.
217
+ * @returns {React.ReactElement} Rendered Page component.
218
+ */ function Page() {
219
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
220
+ var title = props.title, subtitle = props.subtitle, _props_showTitleInTopBar = props.showTitleInTopBar, showTitleInTopBar = _props_showTitleInTopBar === void 0 ? true : _props_showTitleInTopBar, tmp = props.backAction, _backAction = tmp === void 0 ? null : tmp, children = props.children, narrowWidth = props.narrowWidth, fullWidth = props.fullWidth, primaryAction = props.primaryAction, _props_secondaryActions = props.secondaryActions, secondaryActions = _props_secondaryActions === void 0 ? [] : _props_secondaryActions, titleMetadata = props.titleMetadata, _props_moreActionsLabel = props.moreActionsLabel, moreActionsLabel = _props_moreActionsLabel === void 0 ? "Actions" : _props_moreActionsLabel, _props_wrapInContentContainer = props.wrapInContentContainer, wrapInContentContainer = _props_wrapInContentContainer === void 0 ? true : _props_wrapInContentContainer, footerActions = props.footerActions, className = props.className;
221
+ var paneIsOpen = useContext(FrameContext).paneIsOpen;
222
+ var detailsRef = useRef(null);
223
+ var classes = styles({
224
+ narrowWidth: narrowWidth,
225
+ fullWidth: fullWidth,
226
+ paneIsOpen: paneIsOpen
227
+ });
228
+ var headerClasses = headerStyles({
229
+ showTitleInTopBar: showTitleInTopBar,
230
+ paneIsOpen: paneIsOpen
231
+ });
232
+ var titleIsString = typeof title === "string";
233
+ var subtitleIsString = typeof subtitle === "string";
234
+ var hasSecondaryActions = (secondaryActions === null || secondaryActions === void 0 ? void 0 : secondaryActions.length) > 0;
235
+ var secondaryActionsWithItems = secondaryActions.filter(function(action) {
236
+ return action.items;
237
+ });
238
+ var secondaryActionsWithoutItems = secondaryActions.filter(function(action) {
239
+ return !action.items;
240
+ });
241
+ var _useState = _sliced_to_array(useState(false), 2), showMobileActionsPopover = _useState[0], setShowMobileActionsPopover = _useState[1];
242
+ var _useState1 = _sliced_to_array(useState(Array(secondaryActionsWithItems.length).fill(false)), 2), popovers = _useState1[0], setPopovers = _useState1[1];
243
+ var togglePopover = function(index) {
244
+ setPopovers(function(prev) {
245
+ return _object_spread_props(_object_spread({}, prev), _define_property({}, index, !prev[index]));
246
+ });
247
+ };
248
+ var closePopover = function(index) {
249
+ setPopovers(function(prev) {
250
+ return _object_spread_props(_object_spread({}, prev), _define_property({}, index, false));
251
+ });
252
+ };
253
+ var secondaryActionsSections = _to_consumable_array(secondaryActionsWithoutItems.length > 0 ? [
254
+ {
255
+ title: "",
256
+ items: secondaryActionsWithoutItems
257
+ }
258
+ ] : []).concat(_to_consumable_array(secondaryActionsWithItems.map(function(action) {
259
+ return {
260
+ title: action.title,
261
+ items: action.items
262
+ };
263
+ })));
264
+ var backAction = /*#__PURE__*/ _jsx("div", {
265
+ className: "Litho-Page__Header--BackAction",
266
+ children: /*#__PURE__*/ _jsx(Button, {
267
+ plain: true,
268
+ bordered: true,
269
+ icon: ArrowLeftMinor,
270
+ onClick: function() {
271
+ return _backAction === null || _backAction === void 0 ? void 0 : _backAction.onAction();
272
+ },
273
+ accessibilityLabel: _backAction === null || _backAction === void 0 ? void 0 : _backAction.accessibilityLabel
274
+ })
275
+ });
276
+ var titleMarkup = /*#__PURE__*/ _jsxs("div", {
277
+ className: "flex flex-col justify-center max-w-full min-h-8",
278
+ children: [
279
+ /*#__PURE__*/ _jsxs("div", {
280
+ className: "flex items-center gap-2",
281
+ children: [
282
+ title && titleIsString && /*#__PURE__*/ _jsx(Text, {
283
+ variant: showTitleInTopBar ? "headingLg" : "headingXl",
284
+ className: showTitleInTopBar ? "@md:leading-5" : "",
285
+ children: title
286
+ }),
287
+ title && !titleIsString && title,
288
+ titleMetadata
289
+ ]
290
+ }),
291
+ subtitle && subtitleIsString && /*#__PURE__*/ _jsx(Text, {
292
+ color: "subdued",
293
+ children: subtitle
294
+ }),
295
+ subtitle && !subtitleIsString && subtitle
296
+ ]
297
+ });
298
+ var showHeader = !!(title || subtitle || titleMetadata || _backAction || hasSecondaryActions || primaryAction);
299
+ return /*#__PURE__*/ _jsxs("div", {
300
+ className: "".concat(classes).concat(className ? " ".concat(className) : ""),
301
+ children: [
302
+ showHeader && /*#__PURE__*/ _jsx("div", {
303
+ className: headerClasses,
304
+ children: /*#__PURE__*/ _jsxs("div", {
305
+ className: innerHeaderStyles({
306
+ fullWidth: fullWidth,
307
+ narrowWidth: narrowWidth,
308
+ showTitleInTopBar: showTitleInTopBar
309
+ }),
310
+ children: [
311
+ /*#__PURE__*/ _jsxs("div", {
312
+ className: "Litho-Page__Header--Details flex items-center gap-3 overflow-hidden",
313
+ ref: detailsRef,
314
+ children: [
315
+ _backAction && backAction,
316
+ /*#__PURE__*/ _jsx("div", {
317
+ className: "transition-none!",
318
+ children: titleMarkup
319
+ })
320
+ ]
321
+ }),
322
+ /*#__PURE__*/ _jsxs("div", {
323
+ className: "Litho-Page__Header--Actions flex shrink-0 gap-2 items-center justify-end",
324
+ children: [
325
+ hasSecondaryActions && /*#__PURE__*/ _jsxs("div", {
326
+ className: "flex gap-0 items-center",
327
+ children: [
328
+ /*#__PURE__*/ _jsx("div", {
329
+ className: "@lg:hidden",
330
+ children: /*#__PURE__*/ _jsx(Popover, {
331
+ fixed: true,
332
+ active: showMobileActionsPopover,
333
+ preferredAlignment: "right",
334
+ onClose: function() {
335
+ return setShowMobileActionsPopover(false);
336
+ },
337
+ activator: /*#__PURE__*/ _jsxs(_Fragment, {
338
+ children: [
339
+ /*#__PURE__*/ _jsx(Button, {
340
+ plain: true,
341
+ icon: MobileHorizontalDotsMajor,
342
+ onClick: function() {
343
+ return setShowMobileActionsPopover(!showMobileActionsPopover);
344
+ },
345
+ className: "flex @sm:hidden"
346
+ }),
347
+ /*#__PURE__*/ _jsx(Button, {
348
+ plain: true,
349
+ onClick: function() {
350
+ return setShowMobileActionsPopover(!showMobileActionsPopover);
351
+ },
352
+ disclosure: true,
353
+ className: "hidden @sm:flex",
354
+ children: moreActionsLabel
355
+ })
356
+ ]
357
+ }),
358
+ children: /*#__PURE__*/ _jsx(ActionList, {
359
+ sections: secondaryActionsSections,
360
+ onActionAnyItem: function() {
361
+ return setShowMobileActionsPopover(false);
362
+ }
363
+ })
364
+ })
365
+ }),
366
+ /*#__PURE__*/ _jsxs("div", {
367
+ className: "hidden @lg:flex gap-0 items-center",
368
+ children: [
369
+ secondaryActionsWithItems.map(function(action, index) {
370
+ return /*#__PURE__*/ _jsx(Popover, {
371
+ fixed: true,
372
+ active: popovers[index],
373
+ preferredAlignment: "right",
374
+ onClose: function() {
375
+ return closePopover(index);
376
+ },
377
+ activator: /*#__PURE__*/ _jsx(Button, {
378
+ plain: true,
379
+ disclosure: true,
380
+ onClick: function() {
381
+ return togglePopover(index);
382
+ },
383
+ children: action.title
384
+ }),
385
+ children: /*#__PURE__*/ _jsx(ActionList, {
386
+ items: action.items,
387
+ onActionAnyItem: function() {
388
+ return closePopover(index);
389
+ }
390
+ })
391
+ }, index);
392
+ }),
393
+ secondaryActionsWithoutItems.map(function(action, index) {
394
+ return /*#__PURE__*/ _jsx(Button, {
395
+ plain: !action.destructive,
396
+ onClick: action.onAction || action.onClick,
397
+ disabled: action.disabled,
398
+ icon: action.icon,
399
+ loading: action.loading,
400
+ external: action.external,
401
+ url: action.url,
402
+ destructive: action.destructive,
403
+ tooltip: action.tooltip,
404
+ children: action.content
405
+ }, index);
406
+ })
407
+ ]
408
+ })
409
+ ]
410
+ }),
411
+ primaryAction && /*#__PURE__*/ _jsx(Button, {
412
+ primary: true,
413
+ icon: primaryAction.icon,
414
+ onClick: primaryAction.onAction || primaryAction.onClick,
415
+ url: primaryAction.url,
416
+ loading: primaryAction.loading,
417
+ disabled: primaryAction.disabled,
418
+ destructive: primaryAction.destructive,
419
+ tooltip: primaryAction.tooltip,
420
+ connectedDisclosure: primaryAction.connectedDisclosure,
421
+ children: primaryAction.content || "Save"
422
+ })
423
+ ]
424
+ })
425
+ ]
426
+ })
427
+ }),
428
+ /*#__PURE__*/ _jsx("div", {
429
+ className: contentStyles({
430
+ showHeader: showHeader,
431
+ wrapInContentContainer: wrapInContentContainer
432
+ }),
433
+ children: children
434
+ }),
435
+ footerActions && /*#__PURE__*/ _jsx("div", {
436
+ className: "Litho-Page__Footer px-4 @lg:px-5",
437
+ children: /*#__PURE__*/ _jsxs("div", {
438
+ className: "border-t flex items center justify-between py-4",
439
+ children: [
440
+ footerActions.destructiveAction && /*#__PURE__*/ _jsx(Button, {
441
+ destructive: true,
442
+ onClick: footerActions.destructiveAction.onAction,
443
+ loading: footerActions.destructiveAction.loading,
444
+ disabled: footerActions.destructiveAction.disabled,
445
+ children: footerActions.destructiveAction.content
446
+ }),
447
+ (footerActions.secondaryAction || footerActions.primaryAction) && /*#__PURE__*/ _jsxs("div", {
448
+ className: "flex gap-2",
449
+ children: [
450
+ footerActions.secondaryAction && /*#__PURE__*/ _jsx(Button, {
451
+ onClick: footerActions.secondaryAction.onAction,
452
+ disabled: footerActions.secondaryAction.disabled,
453
+ loading: footerActions.secondaryAction.loading,
454
+ url: footerActions.secondaryAction.url,
455
+ children: footerActions.secondaryAction.content
456
+ }),
457
+ footerActions.primaryAction && /*#__PURE__*/ _jsx(Button, {
458
+ primary: true,
459
+ onClick: footerActions.primaryAction.onAction,
460
+ loading: footerActions.primaryAction.loading,
461
+ disabled: footerActions.primaryAction.disabled,
462
+ url: footerActions.primaryAction.url,
463
+ children: footerActions.primaryAction.content
464
+ })
465
+ ]
466
+ })
467
+ ]
468
+ })
469
+ })
470
+ ]
471
+ });
472
+ }
473
+ export default Page;
@@ -0,0 +1,99 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
+ import { ChevronLeftMinor, ChevronRightMinor } from "@shopify/polaris-icons";
31
+ import { Button, ButtonGroup, Tooltip } from "../index.js";
32
+ /**
33
+ * Pagination component for navigating between pages or steps.
34
+ * Provides support for next and previous navigation with optional tooltips.
35
+ *
36
+ * @component
37
+ * @param {Object} props - The properties for the Pagination component.
38
+ * @param {boolean} [props.hasNext] - Indicates whether there is a next page/step.
39
+ * @param {boolean} [props.hasPrevious] - Indicates whether there is a previous page/step.
40
+ * @param {string} [props.nextURL] - URL to navigate to for the next page/step.
41
+ * @param {string} [props.previousURL] - URL to navigate to for the previous page/step.
42
+ * @param {function} [props.onNext] - Callback function to handle next button clicks.
43
+ * @param {function} [props.onPrevious] - Callback function to handle previous button clicks.
44
+ * @param {string} [props.nextTooltip] - Tooltip content for the next button.
45
+ * @param {string} [props.previousTooltip] - Tooltip content for the previous button.
46
+ *
47
+ * @example
48
+ * <Pagination
49
+ * hasNext={true}
50
+ * hasPrevious={true}
51
+ * nextURL="/next"
52
+ * previousURL="/previous"
53
+ * onNext={() => console.log('Next clicked')}
54
+ * onPrevious={() => console.log('Previous clicked')}
55
+ * nextTooltip="Go to next page"
56
+ * previousTooltip="Go to previous page"
57
+ * />
58
+ */ function Pagination() {
59
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
60
+ var hasNext = props.hasNext, hasPrevious = props.hasPrevious, nextURL = props.nextURL, previousURL = props.previousURL, onNext = props.onNext, onPrevious = props.onPrevious, nextTooltip = props.nextTooltip, previousTooltip = props.previousTooltip;
61
+ var renderButtonWithTooltip = function(tooltip, buttonProps) {
62
+ var button = /*#__PURE__*/ _jsx(Button, _object_spread({}, buttonProps));
63
+ return tooltip ? /*#__PURE__*/ _jsx(Tooltip, {
64
+ content: tooltip,
65
+ children: button
66
+ }) : button;
67
+ };
68
+ return /*#__PURE__*/ _jsx("div", {
69
+ className: "Litho-Pagination",
70
+ children: /*#__PURE__*/ _jsxs(ButtonGroup, {
71
+ segmented: true,
72
+ children: [
73
+ renderButtonWithTooltip(previousTooltip, {
74
+ icon: ChevronLeftMinor,
75
+ disabled: !hasPrevious,
76
+ onClick: hasPrevious ? function() {
77
+ if (onPrevious) {
78
+ onPrevious();
79
+ } else if (previousURL) {
80
+ window.location.href = previousURL;
81
+ }
82
+ } : undefined
83
+ }),
84
+ renderButtonWithTooltip(nextTooltip, {
85
+ icon: ChevronRightMinor,
86
+ disabled: !hasNext,
87
+ onClick: hasNext ? function() {
88
+ if (onNext) {
89
+ onNext();
90
+ } else if (nextURL) {
91
+ window.location.href = nextURL;
92
+ }
93
+ } : undefined
94
+ })
95
+ ]
96
+ })
97
+ });
98
+ }
99
+ export default Pagination;