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