@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,211 @@
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 _AppProvider = require("../components/AppProvider");
14
+ var _react = require("react");
15
+ var _polarisicons = require("@shopify/polaris-icons");
16
+ var _tailwindvariants = require("tailwind-variants");
17
+ var _index = require("../index");
18
+ function _array_like_to_array(arr, len) {
19
+ if (len == null || len > arr.length) len = arr.length;
20
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21
+ return arr2;
22
+ }
23
+ function _array_with_holes(arr) {
24
+ if (Array.isArray(arr)) return arr;
25
+ }
26
+ function _iterable_to_array_limit(arr, i) {
27
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
28
+ if (_i == null) return;
29
+ var _arr = [];
30
+ var _n = true;
31
+ var _d = false;
32
+ var _s, _e;
33
+ try {
34
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
35
+ _arr.push(_s.value);
36
+ if (i && _arr.length === i) break;
37
+ }
38
+ } catch (err) {
39
+ _d = true;
40
+ _e = err;
41
+ } finally{
42
+ try {
43
+ if (!_n && _i["return"] != null) _i["return"]();
44
+ } finally{
45
+ if (_d) throw _e;
46
+ }
47
+ }
48
+ return _arr;
49
+ }
50
+ function _non_iterable_rest() {
51
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
+ }
53
+ function _sliced_to_array(arr, i) {
54
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
55
+ }
56
+ function _unsupported_iterable_to_array(o, minLen) {
57
+ if (!o) return;
58
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
59
+ var n = Object.prototype.toString.call(o).slice(8, -1);
60
+ if (n === "Object" && o.constructor) n = o.constructor.name;
61
+ if (n === "Map" || n === "Set") return Array.from(n);
62
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
63
+ }
64
+ var styles = (0, _tailwindvariants.tv)({
65
+ base: "Litho-Listbox__Option rounded-md cursor-pointer min-h-8 py-1 flex items-center justify-between pl-3 focus:outline-hidden active:ring-0",
66
+ variants: {
67
+ showIcon: {
68
+ true: "gap-2 pr-2",
69
+ false: "pr-3"
70
+ },
71
+ selected: {
72
+ true: "text-tab-active-fg bg-tab-active-bg hover:bg-tab-active-bg-hover active:bg-tab-active-bg-active",
73
+ false: "text-normal hover:text-highest hover"
74
+ },
75
+ removeVisualFocus: {
76
+ true: "",
77
+ false: "focus:ring-2 focus:ring-form-accent focus:border-form-border-accent"
78
+ }
79
+ }
80
+ });
81
+ var containerStyles = (0, _tailwindvariants.tv)({
82
+ base: "flex gap-0.5",
83
+ variants: {
84
+ displayHorizontallyOnMobile: {
85
+ true: "flex-row overflow-x-auto max-w-full pb-3 @sm:pb-0 @sm:flex-col",
86
+ false: "flex-col"
87
+ }
88
+ },
89
+ defaultVariants: {
90
+ displayHorizontallyOnMobile: false
91
+ }
92
+ });
93
+ /**
94
+ * A customizable Listbox component for displaying a list of options with selectable states.
95
+ * The component supports keyboard navigation and optional icons for selected items.
96
+ *
97
+ * @component
98
+ * @param {Object} props - The properties object.
99
+ * @param {Array<Object>} props.options - Array of options to render in the listbox.
100
+ * Each option should be an object with the following properties:
101
+ * - `label` {string}: The display label of the option.
102
+ * - `value` {string | number}: The unique value of the option.
103
+ * - `selected` {boolean}: Whether the option is currently selected.
104
+ * - `onAction` {function}: A callback function invoked when the option is clicked or "Enter" is pressed.
105
+ * @param {boolean} [props.showIcon=false] - Determines whether to display an icon next to selected options.
106
+ * @param {React.ReactNode} [props.icon=MobileAcceptMajor] - The icon to display for selected options (default is `MobileAcceptMajor`).
107
+ * @param {boolean} [props.displayHorizontallyOnMobile=false] - Determines whether to display the listbox horizontally on mobile.
108
+ *
109
+ * @example
110
+ * const options = [
111
+ * { label: "Option 1", value: "opt1", selected: false, onAction: () => console.log("Option 1 clicked") },
112
+ * { label: "Option 2", value: "opt2", selected: true, onAction: () => console.log("Option 2 clicked") },
113
+ * ];
114
+ *
115
+ * <Listbox options={options} showIcon={true} icon={CustomIcon} />
116
+ *
117
+ * @returns {JSX.Element} The rendered Listbox component.
118
+ */ function Listbox() {
119
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
120
+ var options = props.options, _props_showIcon = props.showIcon, showIcon = _props_showIcon === void 0 ? false : _props_showIcon, _props_displayHorizontallyOnMobile = props.displayHorizontallyOnMobile, displayHorizontallyOnMobile = _props_displayHorizontallyOnMobile === void 0 ? false : _props_displayHorizontallyOnMobile, _props_icon = props.icon, icon = _props_icon === void 0 ? _polarisicons.MobileAcceptMajor : _props_icon;
121
+ var screenSizes = (0, _react.useContext)(_AppProvider.FrameContext).screenSizes;
122
+ var _useState = _sliced_to_array((0, _react.useState)(null), 2), removeVisualFocus = _useState[0], setRemoveVisualFocus = _useState[1];
123
+ var handleKeyDown = function(e, index) {
124
+ if (!options.length) return;
125
+ var currentElement = e.target;
126
+ var siblings = currentElement.parentNode.children;
127
+ switch(e.key){
128
+ case "ArrowDown":
129
+ e.preventDefault();
130
+ var nextElement = siblings[index + 1] || siblings[0];
131
+ nextElement.focus();
132
+ break;
133
+ case "ArrowUp":
134
+ e.preventDefault();
135
+ var prevElement = siblings[index - 1] || siblings[siblings.length - 1];
136
+ prevElement.focus();
137
+ break;
138
+ case "Enter":
139
+ var _options_index;
140
+ e.preventDefault();
141
+ if ((_options_index = options[index]) === null || _options_index === void 0 ? void 0 : _options_index.onAction) {
142
+ options[index].onAction();
143
+ }
144
+ break;
145
+ case "Escape":
146
+ e.preventDefault();
147
+ currentElement.blur();
148
+ break;
149
+ default:
150
+ break;
151
+ }
152
+ };
153
+ var handleClick = function(e, index) {
154
+ var _options_index_onAction, _options_index;
155
+ (_options_index = options[index]) === null || _options_index === void 0 ? void 0 : (_options_index_onAction = _options_index.onAction) === null || _options_index_onAction === void 0 ? void 0 : _options_index_onAction.call(_options_index);
156
+ setRemoveVisualFocus(index);
157
+ if (window.innerWidth <= screenSizes.sm) {
158
+ e.currentTarget.scrollIntoView({
159
+ behavior: "smooth",
160
+ block: "nearest",
161
+ inline: "center"
162
+ });
163
+ }
164
+ };
165
+ if (!options.length) {
166
+ return null;
167
+ }
168
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
169
+ role: "listbox",
170
+ className: containerStyles({
171
+ displayHorizontallyOnMobile: displayHorizontallyOnMobile
172
+ }),
173
+ children: options.map(function(option, index) {
174
+ var selected = option.selected, label = option.label, value = option.value, onAction = option.onAction;
175
+ var classes = styles({
176
+ selected: selected,
177
+ showIcon: showIcon,
178
+ removeVisualFocus: removeVisualFocus === index
179
+ });
180
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
181
+ role: "option",
182
+ "aria-selected": selected,
183
+ className: classes,
184
+ tabIndex: 0,
185
+ onClick: function(e) {
186
+ return handleClick(e, index);
187
+ },
188
+ onBlur: function() {
189
+ return setRemoveVisualFocus(null);
190
+ },
191
+ onKeyDown: function(e) {
192
+ return handleKeyDown(e, index);
193
+ },
194
+ children: [
195
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
196
+ className: "whitespace-nowrap pointer-events-none w-full",
197
+ children: label
198
+ }),
199
+ showIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
200
+ className: "w-5 h-5 pointer-events-none",
201
+ children: selected && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
202
+ source: icon || _polarisicons.MobileAcceptMajor,
203
+ color: "link"
204
+ })
205
+ })
206
+ ]
207
+ }, value);
208
+ })
209
+ });
210
+ }
211
+ var _default = Listbox;
@@ -0,0 +1,103 @@
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 = require("react");
14
+ function _array_like_to_array(arr, len) {
15
+ if (len == null || len > arr.length) len = arr.length;
16
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
17
+ return arr2;
18
+ }
19
+ function _array_with_holes(arr) {
20
+ if (Array.isArray(arr)) return arr;
21
+ }
22
+ function _iterable_to_array_limit(arr, i) {
23
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
24
+ if (_i == null) return;
25
+ var _arr = [];
26
+ var _n = true;
27
+ var _d = false;
28
+ var _s, _e;
29
+ try {
30
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
31
+ _arr.push(_s.value);
32
+ if (i && _arr.length === i) break;
33
+ }
34
+ } catch (err) {
35
+ _d = true;
36
+ _e = err;
37
+ } finally{
38
+ try {
39
+ if (!_n && _i["return"] != null) _i["return"]();
40
+ } finally{
41
+ if (_d) throw _e;
42
+ }
43
+ }
44
+ return _arr;
45
+ }
46
+ function _non_iterable_rest() {
47
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
+ }
49
+ function _sliced_to_array(arr, i) {
50
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
51
+ }
52
+ function _unsupported_iterable_to_array(o, minLen) {
53
+ if (!o) return;
54
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
55
+ var n = Object.prototype.toString.call(o).slice(8, -1);
56
+ if (n === "Object" && o.constructor) n = o.constructor.name;
57
+ if (n === "Map" || n === "Set") return Array.from(n);
58
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
59
+ }
60
+ /**
61
+ * A loading progress bar component that animates over a specified duration.
62
+ *
63
+ * @component
64
+ * @param {Object} props - The props object.
65
+ * @param {number} [props.maxDuration=10000] - The maximum duration (in milliseconds) for the loading progress bar to reach 100%.
66
+ * @returns {JSX.Element} A fixed progress bar displayed at the top of the page.
67
+ */ function Loading() {
68
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
69
+ var _props_maxDuration = props.maxDuration, maxDuration = _props_maxDuration === void 0 ? 10000 : _props_maxDuration;
70
+ var _useState = _sliced_to_array((0, _react.useState)(0), 2), progress = _useState[0], setProgress = _useState[1];
71
+ (0, _react.useEffect)(function() {
72
+ var startTime = Date.now();
73
+ var interval = 16;
74
+ var maxProgress = 100;
75
+ var updateProgress = function() {
76
+ var elapsedTime = Date.now() - startTime;
77
+ var fractionOfDuration = elapsedTime / maxDuration;
78
+ var easedProgress = maxProgress * (1 - Math.pow(1 - fractionOfDuration, 3));
79
+ if (elapsedTime >= maxDuration || easedProgress >= maxProgress) {
80
+ setProgress(maxProgress);
81
+ clearInterval(timer);
82
+ } else {
83
+ setProgress(easedProgress);
84
+ }
85
+ };
86
+ var timer = setInterval(updateProgress, interval);
87
+ return function() {
88
+ return clearInterval(timer);
89
+ };
90
+ }, [
91
+ maxDuration
92
+ ]);
93
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
94
+ className: "Litho-Loading fixed top-0 left-0 right-0 h-[3px]",
95
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
96
+ className: "h-full bg-brand-saturated transition-all duration-100 ease-out",
97
+ style: {
98
+ width: "".concat(progress, "%")
99
+ }
100
+ })
101
+ });
102
+ }
103
+ var _default = Loading;