@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,1018 @@
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 _ButtonGroup = require("./ButtonGroup");
16
+ var _index = require("../index");
17
+ var _polarisicons = require("@shopify/polaris-icons");
18
+ var _AppProvider = require("./AppProvider");
19
+ function _array_like_to_array(arr, len) {
20
+ if (len == null || len > arr.length) len = arr.length;
21
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22
+ return arr2;
23
+ }
24
+ function _array_with_holes(arr) {
25
+ if (Array.isArray(arr)) return arr;
26
+ }
27
+ function _define_property(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+ return obj;
39
+ }
40
+ function _getRequireWildcardCache(nodeInterop) {
41
+ if (typeof WeakMap !== "function") return null;
42
+ var cacheBabelInterop = new WeakMap();
43
+ var cacheNodeInterop = new WeakMap();
44
+ return (_getRequireWildcardCache = function(nodeInterop) {
45
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
+ })(nodeInterop);
47
+ }
48
+ function _interop_require_wildcard(obj, nodeInterop) {
49
+ if (!nodeInterop && obj && obj.__esModule) {
50
+ return obj;
51
+ }
52
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
+ return {
54
+ default: obj
55
+ };
56
+ }
57
+ var cache = _getRequireWildcardCache(nodeInterop);
58
+ if (cache && cache.has(obj)) {
59
+ return cache.get(obj);
60
+ }
61
+ var newObj = {
62
+ __proto__: null
63
+ };
64
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
65
+ for(var key in obj){
66
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
+ if (desc && (desc.get || desc.set)) {
69
+ Object.defineProperty(newObj, key, desc);
70
+ } else {
71
+ newObj[key] = obj[key];
72
+ }
73
+ }
74
+ }
75
+ newObj.default = obj;
76
+ if (cache) {
77
+ cache.set(obj, newObj);
78
+ }
79
+ return newObj;
80
+ }
81
+ function _iterable_to_array_limit(arr, i) {
82
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
83
+ if (_i == null) return;
84
+ var _arr = [];
85
+ var _n = true;
86
+ var _d = false;
87
+ var _s, _e;
88
+ try {
89
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
90
+ _arr.push(_s.value);
91
+ if (i && _arr.length === i) break;
92
+ }
93
+ } catch (err) {
94
+ _d = true;
95
+ _e = err;
96
+ } finally{
97
+ try {
98
+ if (!_n && _i["return"] != null) _i["return"]();
99
+ } finally{
100
+ if (_d) throw _e;
101
+ }
102
+ }
103
+ return _arr;
104
+ }
105
+ function _non_iterable_rest() {
106
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
107
+ }
108
+ function _object_spread(target) {
109
+ for(var i = 1; i < arguments.length; i++){
110
+ var source = arguments[i] != null ? arguments[i] : {};
111
+ var ownKeys = Object.keys(source);
112
+ if (typeof Object.getOwnPropertySymbols === "function") {
113
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
114
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
115
+ }));
116
+ }
117
+ ownKeys.forEach(function(key) {
118
+ _define_property(target, key, source[key]);
119
+ });
120
+ }
121
+ return target;
122
+ }
123
+ function ownKeys(object, enumerableOnly) {
124
+ var keys = Object.keys(object);
125
+ if (Object.getOwnPropertySymbols) {
126
+ var symbols = Object.getOwnPropertySymbols(object);
127
+ if (enumerableOnly) {
128
+ symbols = symbols.filter(function(sym) {
129
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
130
+ });
131
+ }
132
+ keys.push.apply(keys, symbols);
133
+ }
134
+ return keys;
135
+ }
136
+ function _object_spread_props(target, source) {
137
+ source = source != null ? source : {};
138
+ if (Object.getOwnPropertyDescriptors) {
139
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
140
+ } else {
141
+ ownKeys(Object(source)).forEach(function(key) {
142
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
143
+ });
144
+ }
145
+ return target;
146
+ }
147
+ function _object_without_properties(source, excluded) {
148
+ if (source == null) return {};
149
+ var target = _object_without_properties_loose(source, excluded);
150
+ var key, i;
151
+ if (Object.getOwnPropertySymbols) {
152
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
153
+ for(i = 0; i < sourceSymbolKeys.length; i++){
154
+ key = sourceSymbolKeys[i];
155
+ if (excluded.indexOf(key) >= 0) continue;
156
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
157
+ target[key] = source[key];
158
+ }
159
+ }
160
+ return target;
161
+ }
162
+ function _object_without_properties_loose(source, excluded) {
163
+ if (source == null) return {};
164
+ var target = {};
165
+ var sourceKeys = Object.keys(source);
166
+ var key, i;
167
+ for(i = 0; i < sourceKeys.length; i++){
168
+ key = sourceKeys[i];
169
+ if (excluded.indexOf(key) >= 0) continue;
170
+ target[key] = source[key];
171
+ }
172
+ return target;
173
+ }
174
+ function _sliced_to_array(arr, i) {
175
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
176
+ }
177
+ function _unsupported_iterable_to_array(o, minLen) {
178
+ if (!o) return;
179
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
180
+ var n = Object.prototype.toString.call(o).slice(8, -1);
181
+ if (n === "Object" && o.constructor) n = o.constructor.name;
182
+ if (n === "Map" || n === "Set") return Array.from(n);
183
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
184
+ }
185
+ var styles = (0, _tailwindvariants.tv)({
186
+ base: "Litho-Button relative flex items-center justify-center rounded-md border border-transparent overflow-hidden",
187
+ variants: {
188
+ disabled: {
189
+ true: "cursor-default",
190
+ false: ""
191
+ },
192
+ loading: {
193
+ true: "cursor-default",
194
+ false: ""
195
+ },
196
+ fullWidth: {
197
+ true: "w-full",
198
+ false: ""
199
+ },
200
+ align: {
201
+ left: "justify-start",
202
+ center: "justify-center",
203
+ right: "justify-end"
204
+ },
205
+ disclosureLeft: {
206
+ true: "border-r-0",
207
+ false: ""
208
+ },
209
+ disclosureRight: {
210
+ true: "border-l-0",
211
+ false: ""
212
+ },
213
+ plain: {
214
+ true: "",
215
+ false: ""
216
+ },
217
+ link: {
218
+ true: "",
219
+ false: ""
220
+ },
221
+ rounded: {
222
+ true: "rounded-full",
223
+ false: ""
224
+ },
225
+ size: {
226
+ stepper: "min-h-3.5 rounded-sm",
227
+ small: "min-h-7 min-w-7",
228
+ medium: "min-h-8",
229
+ large: "min-h-8"
230
+ },
231
+ shadow: {
232
+ true: "shadow-btn",
233
+ false: ""
234
+ },
235
+ darkMode: {
236
+ true: "",
237
+ false: ""
238
+ },
239
+ bordered: {
240
+ true: "border-tint-2",
241
+ false: ""
242
+ }
243
+ },
244
+ compoundVariants: [
245
+ {
246
+ bordered: true,
247
+ plain: true,
248
+ class: "border-tint-2 dark:border-tint-alt-4"
249
+ },
250
+ {
251
+ disabled: true,
252
+ plain: false,
253
+ link: false,
254
+ highlight: false,
255
+ class: "border-btn-secondary-border"
256
+ },
257
+ {
258
+ loading: true,
259
+ plain: false,
260
+ link: false,
261
+ highlight: false,
262
+ class: "border-btn-secondary-border"
263
+ },
264
+ {
265
+ loading: false,
266
+ disabled: false,
267
+ class: "cursor-pointer"
268
+ },
269
+ {
270
+ primary: true,
271
+ plain: false,
272
+ link: false,
273
+ disclosureLeft: true,
274
+ class: "rounded-r-none"
275
+ },
276
+ {
277
+ primary: false,
278
+ plain: false,
279
+ link: false,
280
+ disclosureLeft: true,
281
+ class: "rounded-r-none"
282
+ },
283
+ {
284
+ primary: true,
285
+ plain: false,
286
+ link: false,
287
+ disclosureRight: true,
288
+ class: "rounded-l-none"
289
+ },
290
+ {
291
+ disclosureRight: true,
292
+ destructive: true,
293
+ class: "rounded-l-none border-l border-l-tint-8!"
294
+ },
295
+ {
296
+ darkMode: false,
297
+ disclosureRight: true,
298
+ primary: false,
299
+ plain: false,
300
+ link: false,
301
+ destructive: false,
302
+ highlight: false,
303
+ class: "rounded-l-none border-l border-l-tint-4!"
304
+ },
305
+ {
306
+ darkMode: false,
307
+ disclosureRight: true,
308
+ highlight: true,
309
+ class: "rounded-l-none border-l border-l-tint-4!"
310
+ },
311
+ {
312
+ darkMode: false,
313
+ disclosureRight: true,
314
+ primary: true,
315
+ class: "rounded-l-none border-l border-l-tint-alt-10!"
316
+ },
317
+ {
318
+ darkMode: true,
319
+ disclosureRight: true,
320
+ primary: false,
321
+ plain: false,
322
+ link: false,
323
+ destructive: false,
324
+ highlight: false,
325
+ class: "rounded-l-none border-l border-l-tint-alt-4!"
326
+ },
327
+ {
328
+ darkMode: true,
329
+ disclosureRight: true,
330
+ highlight: true,
331
+ class: "rounded-l-none border-l border-l-tint-alt-3!"
332
+ },
333
+ {
334
+ darkMode: true,
335
+ disclosureRight: true,
336
+ primary: true,
337
+ class: "rounded-l-none border-l border-l-tint-6!"
338
+ },
339
+ // Primary buttons
340
+ {
341
+ primary: true,
342
+ disabled: false,
343
+ loading: false,
344
+ class: "bg-btn-primary hover:bg-btn-primary-low active:bg-btn-primary-lower text-btn-primary-fg hover:text-btn-primary-fg-alt border-btn-primary-border hover:border-btn-primary-border-low active:border-btn-primary-border-low\n dark:outline-hidden dark:border-transparent dark:shadow-btn-dark dark:border-t-tint-alt-6 dark:hover:border-t-tint-alt-7 dark:active:border-t-tint-alt-8"
345
+ },
346
+ {
347
+ primary: true,
348
+ disabled: true,
349
+ class: "bg-btn-primary-disabled text-btn-primary-disabled-fg"
350
+ },
351
+ {
352
+ primary: true,
353
+ loading: true,
354
+ class: "bg-btn-primary-disabled text-btn-primary-disabled-fg"
355
+ },
356
+ // Secondary buttons
357
+ {
358
+ disabled: false,
359
+ loading: false,
360
+ primary: false,
361
+ plain: false,
362
+ link: false,
363
+ destructive: false,
364
+ highlight: false,
365
+ pressed: false,
366
+ class: "bg-btn-secondary hover:bg-btn-secondary-low active:bg-btn-secondary-lower text-btn-secondary-fg hover:text-btn-secondary-fg-alt border-btn-secondary-border hover:border-btn-secondary-border-low active:border-btn-secondary-border-low\n dark:outline-hidden dark:border-transparent dark:shadow-btn-dark dark:border-t-tint-alt-3 dark:hover:border-t-tint-alt-2 dark:active:border-t-tint-alt-2"
367
+ },
368
+ {
369
+ disabled: false,
370
+ loading: false,
371
+ primary: false,
372
+ plain: false,
373
+ link: false,
374
+ destructive: false,
375
+ highlight: false,
376
+ pressed: true,
377
+ class: "bg-btn-secondary hover:bg-btn-secondary-low active:bg-btn-secondary-lower text-btn-secondary-fg hover:text-btn-secondary-fg-alt border-btn-secondary-border hover:border-btn-secondary-border-low active:border-btn-secondary-border-low\n dark:outline-hidden dark:border-tint-10 dark:shadow-btn-pressed-dark dark:hover:border-tint-10 dark:active:border-tint-10"
378
+ },
379
+ {
380
+ disabled: true,
381
+ primary: false,
382
+ plain: false,
383
+ link: false,
384
+ destructive: false,
385
+ highlight: false,
386
+ class: "bg-btn-secondary-disabled text-btn-secondary-disabled-fg"
387
+ },
388
+ {
389
+ loading: true,
390
+ primary: false,
391
+ plain: false,
392
+ link: false,
393
+ destructive: false,
394
+ highlight: false,
395
+ class: "bg-btn-secondary-disabled text-btn-secondary-disabled-fg"
396
+ },
397
+ // Plain buttons
398
+ {
399
+ plain: true,
400
+ disabled: false,
401
+ loading: false,
402
+ bordered: false,
403
+ class: "bg-btn-plain hover:bg-btn-plain-low active:bg-btn-plain-lower text-btn-plain-fg hover:text-btn-plain-fg-alt border-btn-plain-border hover:border-btn-plain-border-low active:border-btn-plain-border-low"
404
+ },
405
+ {
406
+ plain: true,
407
+ disabled: false,
408
+ loading: false,
409
+ bordered: true,
410
+ class: "bg-btn-plain hover:bg-btn-plain-low active:bg-btn-plain-lower text-btn-plain-fg hover:text-btn-plain-fg-alt border-tint-4 hover:border-tint-5 active:border-tint-6"
411
+ },
412
+ {
413
+ plain: true,
414
+ disabled: true,
415
+ class: "bg-btn-plain-disabled text-btn-plain-disabled-fg"
416
+ },
417
+ {
418
+ plain: true,
419
+ loading: true,
420
+ class: "bg-btn-plain-disabled text-btn-plain-disabled-fg"
421
+ },
422
+ // Link buttons
423
+ {
424
+ link: true,
425
+ disabled: false,
426
+ loading: false,
427
+ class: "bg-btn-link hover:bg-btn-link-low active:bg-btn-link-lower text-btn-link-fg hover:text-btn-link-fg-alt border-btn-link-border hover:border-btn-link-border-low active:border-btn-link-border-low"
428
+ },
429
+ {
430
+ link: true,
431
+ disabled: true,
432
+ class: "bg-btn-link-disabled text-btn-link-disabled-fg"
433
+ },
434
+ {
435
+ link: true,
436
+ loading: true,
437
+ class: "bg-btn-link-disabled text-btn-link-disabled-fg"
438
+ },
439
+ // Destructive buttons
440
+ {
441
+ destructive: true,
442
+ disabled: false,
443
+ loading: false,
444
+ class: "bg-btn-destructive hover:bg-btn-destructive-low active:bg-btn-destructive-lower text-btn-destructive-fg hover:text-btn-destructive-fg-alt border-btn-destructive-border hover:border-btn-destructive-border-low active:border-btn-destructive-border-low"
445
+ },
446
+ {
447
+ destructive: true,
448
+ disabled: true,
449
+ class: "bg-btn-destructive-disabled text-btn-destructive-disabled-fg"
450
+ },
451
+ {
452
+ destructive: true,
453
+ loading: true,
454
+ class: "bg-btn-destructive-disabled text-btn-destructive-disabled-fg"
455
+ },
456
+ // Highlight buttons
457
+ {
458
+ highlight: true,
459
+ disabled: false,
460
+ loading: false,
461
+ class: "bg-btn-highlight hover:bg-btn-highlight-low active:bg-btn-highlight-lower text-btn-highlight-fg hover:text-btn-highlight-fg-alt border-btn-highlight-border hover:border-btn-highlight-border-low active:border-btn-highlight-border-low"
462
+ },
463
+ {
464
+ highlight: true,
465
+ disabled: true,
466
+ class: "bg-btn-highlight-disabled text-btn-highlight-disabled-fg"
467
+ },
468
+ {
469
+ highlight: true,
470
+ loading: true,
471
+ class: "bg-btn-highlight-disabled text-btn-highlight-disabled-fg"
472
+ }
473
+ ],
474
+ defaultVariants: {
475
+ disclosureLeft: false,
476
+ disclosureRight: false,
477
+ insideButtonGroup: false,
478
+ shadow: false,
479
+ darkMode: false,
480
+ bordered: false
481
+ }
482
+ });
483
+ var contentStyles = (0, _tailwindvariants.tv)({
484
+ base: "Litho-Button__Content relative flex items-center justify-center gap-1",
485
+ variants: {
486
+ hasIcon: {
487
+ true: "",
488
+ false: ""
489
+ },
490
+ hasChildren: {
491
+ true: "",
492
+ false: ""
493
+ },
494
+ disclosure: {
495
+ true: "",
496
+ false: ""
497
+ },
498
+ size: {
499
+ small: "py-0.5",
500
+ large: "py-3",
501
+ medium: "py-1"
502
+ }
503
+ },
504
+ compoundVariants: [
505
+ {
506
+ size: "small",
507
+ iconOnly: true,
508
+ class: "!px-0.5"
509
+ },
510
+ {
511
+ size: "small",
512
+ hasIcon: false,
513
+ iconOnly: false,
514
+ class: "px-2"
515
+ },
516
+ {
517
+ size: "small",
518
+ hasIcon: true,
519
+ iconOnly: false,
520
+ class: "pl-1.5 pr-2"
521
+ },
522
+ {
523
+ size: "medium",
524
+ iconOnly: true,
525
+ class: "!px-1.25"
526
+ },
527
+ {
528
+ size: "large",
529
+ iconOnly: true,
530
+ class: "!px-3"
531
+ },
532
+ {
533
+ hasIcon: true,
534
+ hasChildren: true,
535
+ disclosure: false,
536
+ size: "large",
537
+ class: "pl-3 pr-4"
538
+ },
539
+ {
540
+ hasIcon: true,
541
+ hasChildren: true,
542
+ disclosure: true,
543
+ class: "pl-2 pr-1"
544
+ },
545
+ {
546
+ hasIcon: true,
547
+ hasChildren: true,
548
+ disclosure: false,
549
+ size: "medium",
550
+ class: "pl-2 pr-3"
551
+ },
552
+ {
553
+ hasIcon: false,
554
+ hasChildren: true,
555
+ disclosure: false,
556
+ class: "px-3"
557
+ },
558
+ {
559
+ hasIcon: false,
560
+ hasChildren: true,
561
+ disclosure: true,
562
+ class: "pl-2.5 pr-1"
563
+ }
564
+ ],
565
+ defaultVariants: {
566
+ disclosure: false,
567
+ hasIcon: false,
568
+ iconOnly: false,
569
+ hasChildren: true,
570
+ size: "medium"
571
+ }
572
+ });
573
+ var iconStyles = (0, _tailwindvariants.tv)({
574
+ base: "Litho-Button__Icon"
575
+ });
576
+ var textStyles = (0, _tailwindvariants.tv)({
577
+ base: "Litho-Button__Text whitespace-nowrap leading-5 font-medium",
578
+ variants: {
579
+ loading: {
580
+ true: "invisible"
581
+ },
582
+ disabled: {
583
+ true: "",
584
+ false: ""
585
+ },
586
+ primary: {
587
+ true: "dark:font-semibold",
588
+ false: ""
589
+ },
590
+ link: {
591
+ true: "",
592
+ false: ""
593
+ },
594
+ destructive: {
595
+ true: "",
596
+ false: ""
597
+ },
598
+ plain: {
599
+ true: "",
600
+ false: ""
601
+ },
602
+ highlight: {
603
+ true: "",
604
+ false: ""
605
+ }
606
+ },
607
+ compoundVariants: [
608
+ {
609
+ primary: true,
610
+ loading: false,
611
+ disabled: false,
612
+ class: "text-btn-primary-fg"
613
+ },
614
+ {
615
+ primary: true,
616
+ loading: true,
617
+ class: "text-btn-primary-disabled-fg"
618
+ },
619
+ {
620
+ primary: true,
621
+ disabled: true,
622
+ class: "text-btn-primary-disabled-fg"
623
+ },
624
+ {
625
+ loading: false,
626
+ disabled: false,
627
+ destructive: false,
628
+ primary: false,
629
+ plain: false,
630
+ link: false,
631
+ class: "text-btn-secondary-fg"
632
+ },
633
+ {
634
+ loading: false,
635
+ disabled: true,
636
+ destructive: false,
637
+ primary: false,
638
+ plain: false,
639
+ link: false,
640
+ class: "text-btn-secondary-disabled-fg"
641
+ },
642
+ {
643
+ loading: true,
644
+ disabled: false,
645
+ destructive: false,
646
+ primary: false,
647
+ plain: false,
648
+ link: false,
649
+ class: "text-btn-secondary-disabled-fg"
650
+ },
651
+ {
652
+ plain: true,
653
+ loading: false,
654
+ disabled: false,
655
+ class: "text-btn-plain-fg"
656
+ },
657
+ {
658
+ plain: true,
659
+ loading: true,
660
+ class: "text-btn-plain-disabled-fg"
661
+ },
662
+ {
663
+ plain: true,
664
+ disabled: true,
665
+ class: "text-btn-plain-disabled-fg"
666
+ },
667
+ {
668
+ link: true,
669
+ loading: false,
670
+ disabled: false,
671
+ class: "text-btn-link-fg"
672
+ },
673
+ {
674
+ link: true,
675
+ loading: true,
676
+ class: "text-btn-link-disabled-fg"
677
+ },
678
+ {
679
+ link: true,
680
+ disabled: true,
681
+ class: "text-btn-link-disabled-fg"
682
+ },
683
+ {
684
+ destructive: true,
685
+ loading: false,
686
+ disabled: false,
687
+ class: "text-btn-destructive-fg"
688
+ },
689
+ {
690
+ destructive: true,
691
+ loading: true,
692
+ class: "text-btn-destructive-disabled-fg"
693
+ },
694
+ {
695
+ destructive: true,
696
+ disabled: true,
697
+ class: "text-btn-destructive-disabled-fg"
698
+ },
699
+ {
700
+ highlight: true,
701
+ loading: false,
702
+ disabled: false,
703
+ class: "text-btn-highlight-fg"
704
+ },
705
+ {
706
+ highlight: true,
707
+ loading: true,
708
+ class: "text-btn-highlight-disabled-fg"
709
+ },
710
+ {
711
+ highlight: true,
712
+ disabled: true,
713
+ class: "text-btn-highlight-disabled-fg"
714
+ }
715
+ ],
716
+ defaultVariants: {
717
+ primary: false,
718
+ plain: false,
719
+ link: false,
720
+ destructive: false,
721
+ highlight: false,
722
+ loading: false,
723
+ disabled: false,
724
+ rounded: false
725
+ }
726
+ });
727
+ var connectedDisclosureStyles = (0, _tailwindvariants.tv)({
728
+ base: "Litho-Button__ConnectedDisclosure flex flex-wrap-nowrap"
729
+ });
730
+ /**
731
+ * A Button component that renders a customizable button or link with various styles and states.
732
+ * The button can be configured with different variants, sizes, and can include icons, loading states,
733
+ * and connected disclosure actions.
734
+ *
735
+ * @component
736
+ *
737
+ * @param {Object} props - The properties for configuring the Button component.
738
+ * @param {string} [props.id] - Unique identifier for the button.
739
+ * @param {React.ReactNode} [props.children] - The content to display within the button.
740
+ * @param {string} [props.url] - URL to navigate to when clicked. If provided, renders as an anchor tag.
741
+ * @param {boolean} [props.disabled=false] - Whether the button is disabled.
742
+ * @param {boolean} [props.external] - Whether the URL should open in a new tab.
743
+ * @param {string} [props.target] - Target attribute for the anchor tag when URL is provided.
744
+ * @param {boolean} [props.submit] - Whether the button should act as a form submit button.
745
+ * @param {boolean} [props.loading=false] - Whether to show a loading spinner.
746
+ * @param {boolean} [props.pressed=false] - Whether the button appears pressed.
747
+ * @param {string} [props.accessibilityLabel] - Accessible label for screen readers.
748
+ * @param {string} [props.role] - ARIA role for the button.
749
+ * @param {string} [props.ariaControls] - ID of the element controlled by the button.
750
+ * @param {boolean} [props.ariaExpanded] - Whether the controlled element is expanded.
751
+ * @param {string} [props.ariaDescribedBy] - ID of the element that describes the button.
752
+ * @param {boolean} [props.ariaChecked] - Whether the button is checked (for toggle buttons).
753
+ * @param {React.Component} [props.icon] - Icon component to display within the button.
754
+ * @param {string} [props.iconColor='default'] - Color of the icon.
755
+ * @param {boolean} [props.primary=false] - Whether to show the primary button style.
756
+ * @param {boolean} [props.highlight=false] - Whether to show the highlight button style.
757
+ * @param {boolean} [props.link=false] - Whether to show a link style.
758
+ * @param {boolean} [props.destructive=false] - Whether to show destructive styling.
759
+ * @param {boolean} [props.disclosure=false] - Whether to show a disclosure arrow.
760
+ * @param {boolean} [props.disclosureRight=false] - Whether to show the disclosure on the right.
761
+ * @param {boolean} [props.plain=false] - Whether to show plain styling without background.
762
+ * @param {string} [props.size='medium'] - Size of the button ('small', 'medium', 'large', 'stepper').
763
+ * @param {boolean} [props.fullWidth] - Whether the button should take full width.
764
+ * @param {string} [props.align='center'] - Alignment of the button content ('left', 'center', 'right').
765
+ * @param {string} [props.tooltip] - Tooltip to show when hovering over the button.
766
+ * @param {Object} [props.connectedDisclosure] - Configuration for connected disclosure menu.
767
+ * @param {Array} [props.connectedDisclosure.actions] - Actions to show in the disclosure menu.
768
+ * @param {string} [props.className] - Additional CSS classes for the button.
769
+ * @param {string} [props.contentClassName] - Additional CSS classes for the button content.
770
+ * @param {boolean} [props.rounded] - Whether to show fully rounded corners.
771
+ * @param {Function} [props.onClick] - Callback when the button is clicked.
772
+ * @param {Function} [props.onMouseDown] - Callback when the mouse is pressed on the button.
773
+ *
774
+ * @returns {JSX.Element} The rendered Button component.
775
+ *
776
+ * @example
777
+ * // Basic button
778
+ * <Button onClick={() => console.log('Clicked')}>
779
+ * Click me
780
+ * </Button>
781
+ *
782
+ * @example
783
+ * // Primary button with icon and loading state
784
+ * <Button
785
+ * primary
786
+ * loading={isLoading}
787
+ * icon={SaveMinor}
788
+ * onClick={handleSave}
789
+ * >
790
+ * Save changes
791
+ * </Button>
792
+ *
793
+ * @example
794
+ * // Button with connected disclosure
795
+ * <Button
796
+ * connectedDisclosure={{
797
+ * actions: [
798
+ * { content: 'Option 1', onAction: () => {} },
799
+ * { content: 'Option 2', onAction: () => {} }
800
+ * ]
801
+ * }}
802
+ * >
803
+ * More actions
804
+ * </Button>
805
+ */ function Button() {
806
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
807
+ var darkMode = (0, _react.useContext)(_AppProvider.DarkModeContext).darkMode;
808
+ var _useState = _sliced_to_array((0, _react.useState)(false), 2), showConnectedDisclosurePopover = _useState[0], setShowConnectedDisclosurePopover = _useState[1];
809
+ var id = props.id, children = props.children, url = props.url, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, external = props.external, target = props.target, submit = props.submit, _props_loading = props.loading, loading = _props_loading === void 0 ? false : _props_loading, _props_pressed = props.pressed, pressed = _props_pressed === void 0 ? false : _props_pressed, accessibilityLabel = props.accessibilityLabel, role = props.role, ariaControls = props.ariaControls, ariaExpanded = props.ariaExpanded, ariaDescribedBy = props.ariaDescribedBy, ariaChecked = props.ariaChecked, icon = props.icon, _iconColor = props.iconColor, _props_bordered = props.bordered, bordered = _props_bordered === void 0 ? false : _props_bordered, _props_primary = props.primary, primary = _props_primary === void 0 ? false : _props_primary, _props_highlight = props.highlight, highlight = _props_highlight === void 0 ? false : _props_highlight, _props_link = props.link, link = _props_link === void 0 ? false : _props_link, _props_destructive = props.destructive, destructive = _props_destructive === void 0 ? false : _props_destructive, _props_disclosure = props.disclosure, disclosure = _props_disclosure === void 0 ? false : _props_disclosure, _props_disclosureRight = props.disclosureRight, disclosureRight = _props_disclosureRight === void 0 ? false : _props_disclosureRight, _props_plain = props.plain, plain = _props_plain === void 0 ? false : _props_plain, _props_size = props.size, size = _props_size === void 0 ? "medium" : _props_size, fullWidth = props.fullWidth, _props_align = props.align, align = _props_align === void 0 ? "center" : _props_align, connectedDisclosure = props.connectedDisclosure, className = props.className, contentClassName = props.contentClassName, rounded = props.rounded, onClick = props.onClick, onMouseDown = props.onMouseDown, tooltip = props.tooltip, _props_tooltipAlignment = props.tooltipAlignment, tooltipAlignment = _props_tooltipAlignment === void 0 ? "right" : _props_tooltipAlignment, _props_tooltipPosition = props.tooltipPosition, tooltipPosition = _props_tooltipPosition === void 0 ? "above" : _props_tooltipPosition, shadow = props.shadow, restProps = _object_without_properties(props, [
810
+ "id",
811
+ "children",
812
+ "url",
813
+ "disabled",
814
+ "external",
815
+ "target",
816
+ "submit",
817
+ "loading",
818
+ "pressed",
819
+ "accessibilityLabel",
820
+ "role",
821
+ "ariaControls",
822
+ "ariaExpanded",
823
+ "ariaDescribedBy",
824
+ "ariaChecked",
825
+ "icon",
826
+ "iconColor",
827
+ "bordered",
828
+ "primary",
829
+ "highlight",
830
+ "link",
831
+ "destructive",
832
+ "disclosure",
833
+ "disclosureRight",
834
+ "plain",
835
+ "size",
836
+ "fullWidth",
837
+ "align",
838
+ "connectedDisclosure",
839
+ "className",
840
+ "contentClassName",
841
+ "rounded",
842
+ "onClick",
843
+ "onMouseDown",
844
+ "tooltip",
845
+ "tooltipAlignment",
846
+ "tooltipPosition",
847
+ "shadow"
848
+ ]);
849
+ var hasIcon = !!icon;
850
+ var hasChildren = !!children;
851
+ var insideButtonGroup = (0, _react.useContext)(_ButtonGroup.ButtonGroupContext);
852
+ var base = disabled || loading ? "-disabled-icon" : "-icon";
853
+ var iconColorMap = {
854
+ primary: "btn-primary".concat(base),
855
+ secondary: "btn-secondary".concat(base),
856
+ plain: "btn-plain".concat(base),
857
+ link: "btn-link".concat(base),
858
+ destructive: "btn-destructive".concat(base),
859
+ highlight: "btn-highlight".concat(base),
860
+ default: "btn-secondary".concat(base)
861
+ };
862
+ var iconColor = iconColorMap[primary ? "primary" : plain ? "plain" : link ? "link" : destructive ? "destructive" : highlight ? "highlight" : "default"];
863
+ var iconOnly = hasIcon && !hasChildren;
864
+ var connectedDisclosureActions = (connectedDisclosure === null || connectedDisclosure === void 0 ? void 0 : connectedDisclosure.actions) || [];
865
+ var showConnectedDisclosure = connectedDisclosure && connectedDisclosureActions.length > 0;
866
+ var classes = styles({
867
+ primary: primary,
868
+ plain: plain,
869
+ link: link,
870
+ destructive: destructive,
871
+ highlight: highlight,
872
+ insideButtonGroup: insideButtonGroup,
873
+ loading: loading,
874
+ disabled: disabled,
875
+ fullWidth: fullWidth,
876
+ pressed: pressed,
877
+ disclosureLeft: showConnectedDisclosure,
878
+ disclosureRight: disclosureRight,
879
+ rounded: rounded,
880
+ size: size,
881
+ shadow: shadow,
882
+ darkMode: darkMode,
883
+ bordered: bordered,
884
+ align: align
885
+ });
886
+ var contentClasses = contentStyles({
887
+ disclosure: disclosure,
888
+ hasIcon: hasIcon,
889
+ hasChildren: hasChildren,
890
+ size: size,
891
+ iconOnly: iconOnly
892
+ });
893
+ var iconClasses = iconStyles();
894
+ var textClasses = textStyles({
895
+ primary: primary,
896
+ plain: plain,
897
+ link: link,
898
+ destructive: destructive,
899
+ highlight: highlight,
900
+ pressed: pressed,
901
+ loading: loading,
902
+ disabled: disabled
903
+ });
904
+ var connectedDisclosureClasses = connectedDisclosureStyles({
905
+ primary: primary,
906
+ plain: plain,
907
+ link: link,
908
+ destructive: destructive,
909
+ highlight: highlight,
910
+ loading: loading,
911
+ disabled: disabled
912
+ });
913
+ var Element = url ? "a" : "button";
914
+ var ConnectedDisclosureWrapper = function(param) {
915
+ var condition = param.condition, wrapper = param.wrapper, children = param.children;
916
+ return condition ? wrapper(children) : children;
917
+ };
918
+ var memoizedIcon = (0, _react.useMemo)(function() {
919
+ return icon;
920
+ }, [
921
+ icon
922
+ ]);
923
+ var content = /*#__PURE__*/ (0, _jsxruntime.jsxs)(Element, _object_spread_props(_object_spread({
924
+ id: id,
925
+ href: url,
926
+ target: target ? target : external ? "_blank" : undefined,
927
+ className: "".concat(classes).concat(className ? " ".concat(className) : ""),
928
+ type: submit ? "submit" : undefined,
929
+ onClick: disabled || loading ? undefined : onClick,
930
+ onMouseDown: onMouseDown
931
+ }, restProps), {
932
+ children: [
933
+ pressed && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
934
+ className: "Litho-Button__Pressed absolute inset-0 bg-tint-10 pointer-events-none"
935
+ }),
936
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)("span", {
937
+ className: "".concat(contentClasses).concat(contentClassName ? " ".concat(contentClassName) : ""),
938
+ children: [
939
+ loading && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
940
+ className: "Litho-Button__Loading absolute inset-0 flex items-center justify-center",
941
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Spinner, {
942
+ size: "small",
943
+ color: "subdued"
944
+ })
945
+ }),
946
+ memoizedIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
947
+ className: iconClasses,
948
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
949
+ source: memoizedIcon,
950
+ color: disabled ? "disabled" : _iconColor || iconColor
951
+ })
952
+ }),
953
+ hasChildren && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
954
+ className: textClasses,
955
+ children: children
956
+ }),
957
+ disclosure && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
958
+ className: "Litho-Button__DisclosureIcon relative -left-0.5",
959
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
960
+ source: _polarisicons.CaretDownMinor,
961
+ color: disabled ? "disabled" : _iconColor || iconColor
962
+ })
963
+ })
964
+ ]
965
+ })
966
+ ]
967
+ }));
968
+ var contentWithDisclosure = /*#__PURE__*/ (0, _jsxruntime.jsxs)(ConnectedDisclosureWrapper, {
969
+ condition: showConnectedDisclosure,
970
+ wrapper: function(children) {
971
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
972
+ className: connectedDisclosureClasses,
973
+ children: children
974
+ });
975
+ },
976
+ children: [
977
+ content,
978
+ showConnectedDisclosure && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Popover, {
979
+ active: showConnectedDisclosurePopover,
980
+ onClose: function() {
981
+ return setShowConnectedDisclosurePopover(false);
982
+ },
983
+ preferredAlignment: "right",
984
+ preferredPosition: "below",
985
+ activator: /*#__PURE__*/ (0, _jsxruntime.jsx)(Button, {
986
+ primary: primary,
987
+ plain: plain,
988
+ link: link,
989
+ destructive: destructive,
990
+ highlight: highlight,
991
+ icon: _polarisicons.CaretDownMinor,
992
+ disclosureRight: true,
993
+ iconColor: _iconColor,
994
+ className: primary ? "border-l border-l-tint-alt-6!" : undefined,
995
+ onClick: function() {
996
+ return setShowConnectedDisclosurePopover(!showConnectedDisclosurePopover);
997
+ }
998
+ }),
999
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.ActionList, {
1000
+ items: connectedDisclosureActions,
1001
+ onActionAnyItem: function() {
1002
+ return setShowConnectedDisclosurePopover(false);
1003
+ }
1004
+ })
1005
+ })
1006
+ ]
1007
+ });
1008
+ if (!!tooltip) {
1009
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Tooltip, {
1010
+ content: tooltip,
1011
+ alignment: tooltipAlignment,
1012
+ preferredPosition: tooltipPosition,
1013
+ children: showConnectedDisclosure ? contentWithDisclosure : content
1014
+ });
1015
+ }
1016
+ return showConnectedDisclosure ? contentWithDisclosure : content;
1017
+ }
1018
+ var _default = Button;