@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,533 @@
1
+ "use client";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _iterable_to_array_limit(arr, i) {
11
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
+ if (_i == null) return;
13
+ var _arr = [];
14
+ var _n = true;
15
+ var _d = false;
16
+ var _s, _e;
17
+ try {
18
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
19
+ _arr.push(_s.value);
20
+ if (i && _arr.length === i) break;
21
+ }
22
+ } catch (err) {
23
+ _d = true;
24
+ _e = err;
25
+ } finally{
26
+ try {
27
+ if (!_n && _i["return"] != null) _i["return"]();
28
+ } finally{
29
+ if (_d) throw _e;
30
+ }
31
+ }
32
+ return _arr;
33
+ }
34
+ function _non_iterable_rest() {
35
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
+ }
37
+ function _sliced_to_array(arr, i) {
38
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
+ }
40
+ function _unsupported_iterable_to_array(o, minLen) {
41
+ if (!o) return;
42
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
43
+ var n = Object.prototype.toString.call(o).slice(8, -1);
44
+ if (n === "Object" && o.constructor) n = o.constructor.name;
45
+ if (n === "Map" || n === "Set") return Array.from(n);
46
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
47
+ }
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import { CancelSmallMinor, CaretDownMinor, CaretUpMinor, CircleAlertMajor } from "@shopify/polaris-icons";
50
+ import React, { useEffect, useId, useMemo, useRef, useState } from "react";
51
+ import { tv } from "tailwind-variants";
52
+ import { Button, Icon, InlineError, Label, Link, Text } from "../index.js";
53
+ var styles = tv({
54
+ base: "Litho-TextField group relative rounded-md border min-h-8 cursor-text",
55
+ variants: {
56
+ disabled: {
57
+ true: "bg-form-bg-disabled border-form-border"
58
+ },
59
+ hasError: {
60
+ true: "bg-form-bg-error border-form-border-error",
61
+ false: ""
62
+ },
63
+ subdued: {
64
+ true: "border-transparent",
65
+ false: ""
66
+ },
67
+ transparent: {
68
+ true: "border-transparent",
69
+ false: ""
70
+ }
71
+ },
72
+ compoundVariants: [
73
+ {
74
+ focused: true,
75
+ hasError: false,
76
+ class: "bg-form-bg-focus ring ring-form-focus border-form-border-focus"
77
+ },
78
+ {
79
+ focused: true,
80
+ hasError: true,
81
+ class: "ring ring-form-focus-error"
82
+ },
83
+ {
84
+ disabled: false,
85
+ hasError: false,
86
+ subdued: false,
87
+ focused: false,
88
+ class: "bg-form-bg border-form-border"
89
+ },
90
+ {
91
+ disabled: false,
92
+ hasError: false,
93
+ subdued: false,
94
+ focused: false,
95
+ class: "bg-form-bg hover:border-form-border-hover"
96
+ },
97
+ {
98
+ focused: false,
99
+ disabled: false,
100
+ hasError: false,
101
+ subdued: true,
102
+ class: "bg-tint-2 border-transparent hover:bg-tint-3 active:bg-tint-4"
103
+ },
104
+ {
105
+ focused: false,
106
+ disabled: false,
107
+ hasError: false,
108
+ transparent: true,
109
+ class: "bg-transparent hover:border-transparent hover:bg-tint-2 dark:hover:bg-tint-12 border-transparent"
110
+ },
111
+ {
112
+ focused: true,
113
+ disabled: false,
114
+ hasError: false,
115
+ subdued: true,
116
+ class: "bg-form-bg"
117
+ }
118
+ ],
119
+ defaultVariants: {
120
+ disabled: false,
121
+ hasError: false,
122
+ focused: false
123
+ }
124
+ });
125
+ var inputStyles = tv({
126
+ base: "Litho-TextField__Input appearance-none block bg-transparent border-0 outline-hidden h-full w-full",
127
+ variants: {
128
+ align: {
129
+ left: "",
130
+ center: "text-center",
131
+ right: "text-right"
132
+ },
133
+ hasSuffix: {
134
+ true: "pr-2",
135
+ false: "pr-2"
136
+ },
137
+ hasPrefix: {
138
+ true: "pl-2",
139
+ false: "pl-3"
140
+ },
141
+ hasMultiline: {
142
+ true: "py-[5px] h-full resize-none leading-5",
143
+ false: "h-7.5 py-[5px] leading-7.5"
144
+ },
145
+ disabled: {
146
+ true: "text-lowest",
147
+ false: "text-highest dark:text-higher"
148
+ },
149
+ hasError: {
150
+ true: "placeholder-form-placeholder-error",
151
+ false: "placeholder-form-placeholder"
152
+ },
153
+ type: {
154
+ time: "hide-time-picker"
155
+ }
156
+ }
157
+ });
158
+ var iconStyles = tv({
159
+ base: "Litho-TextField__Icon pl-0.5"
160
+ });
161
+ var clearButtonStyles = tv({
162
+ base: "Litho-TextField__ClearButton mr-1 rounded-md h-6 w-6 flex self-center items-center justify-center cursor-pointer bg-btn-outline hover:bg-btn-outline-low active:bg-btn-outline-lower",
163
+ variants: {
164
+ visible: {
165
+ true: "opacity-70 hover:opacity-100 ",
166
+ false: "pointer-events-none opacity-0 group-hover:opacity-0"
167
+ }
168
+ }
169
+ });
170
+ /**
171
+ * Renders a TextField component.
172
+ *
173
+ * @function TextField
174
+ * @param {Object} props - The properties for the TextField component.
175
+ * @param {string} [props.prefix] - Text content to display before the input.
176
+ * @param {string} [props.suffix] - Text content to display after the input.
177
+ * @param {string} [props.placeholder] - Placeholder text for the input.
178
+ * @param {string} [props.value=''] - The current value of the input.
179
+ * @param {string} [props.helpText] - Helper text to display below the input.
180
+ * @param {string} [props.label] - Label text for the input field.
181
+ * @param {string} [props.labelVariant='bodyMd'] - Visual variant for the label text.
182
+ * @param {Object} [props.labelAction] - Action button to display next to the label.
183
+ * @param {boolean} [props.labelHidden] - Whether to visually hide the label.
184
+ * @param {boolean} [props.disabled=false] - Whether the input is disabled. Defaults to false.
185
+ * @param {boolean} [props.clearButton] - Whether to show a clear button.
186
+ * @param {boolean} [props.readOnly] - Whether the input is read-only.
187
+ * @param {boolean} [props.autoFocus] - Whether to focus the input on mount.
188
+ * @param {boolean} [props.focused] - Whether the input is focused.
189
+ * @param {number} [props.multiline=1] - Number of lines for multiline input (1 for single line). Defaults to 1.
190
+ * @param {boolean} [props.autoGrow=false] - Whether textarea should automatically grow with content. Only applies when multiline > 1.
191
+ * @param {number} [props.maxHeight] - Maximum height in pixels before scrolling starts. Only applies when autoGrow is true.
192
+ * @param {string} [props.error] - Error message to display.
193
+ * @param {ReactNode} [props.connectedRight] - React element to connect to the right of the input.
194
+ * @param {ReactNode} [props.connectedLeft] - React element to connect to the left of the input.
195
+ * @param {string} [props.type='text'] - HTML input type. Defaults to 'text'.
196
+ * @param {boolean} [props.subdued=false] - Whether to use subdued styling.
197
+ * @param {string} [props.name] - Name attribute for the input.
198
+ * @param {string} [props.id] - ID for the input element.
199
+ * @param {string} [props.role] - ARIA role.
200
+ * @param {number} [props.step] - Step value for number inputs.
201
+ * @param {number} [props.largeStep=10] - Large step value when using shift + arrows.
202
+ * @param {string} [props.autoComplete] - HTML autocomplete attribute.
203
+ * @param {number} [props.max] - Maximum value for number inputs.
204
+ * @param {number} [props.maxLength] - Maximum length for text input.
205
+ * @param {number} [props.min] - Minimum value for number inputs.
206
+ * @param {number} [props.minLength] - Minimum length for text input.
207
+ * @param {string} [props.pattern] - Input validation pattern.
208
+ * @param {boolean} [props.spellCheck] - Whether to enable spell checking.
209
+ * @param {string} [props.ariaOwns] - ARIA owns attribute.
210
+ * @param {string} [props.ariaControls] - ARIA controls attribute.
211
+ * @param {boolean} [props.ariaExpanded] - ARIA expanded attribute.
212
+ * @param {string} [props.ariaActiveDescendant] - ARIA active descendant attribute.
213
+ * @param {string} [props.ariaAutocomplete] - ARIA autocomplete attribute.
214
+ * @param {('left'|'center'|'right')} [props.align='left'] - Text alignment within the input.
215
+ * @param {boolean} [props.requiredIndicator] - Whether to show a required field indicator.
216
+ * @param {boolean} [props.selectTextOnFocus] - Whether to select all text when focused.
217
+ * @param {Function} [props.onClearButtonClick] - Handler for clear button click.
218
+ * @param {Function} [props.onChange] - Handler for value changes.
219
+ * @param {Function} [props.onFocus] - Handler for input focus.
220
+ * @param {Function} [props.onBlur] - Handler for input blur.
221
+ * @param {Function} [props.onKeyDown] - Handler for key down.
222
+ * @param {ReactNode} [props.tooltip] - Tooltip content for the label.
223
+ * @param {string} [props.className] - Additional CSS classes.
224
+ * @returns {JSX.Element} The rendered TextField component.
225
+ */ function TextField() {
226
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
227
+ var prefix = props.prefix, _suffix = props.suffix, placeholder = props.placeholder, _props_value = props.value, value = _props_value === void 0 ? "" : _props_value, helpText = props.helpText, label = props.label, _props_labelVariant = props.labelVariant, labelVariant = _props_labelVariant === void 0 ? "bodyMd" : _props_labelVariant, labelAction = props.labelAction, labelHidden = props.labelHidden, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, clearButton = props.clearButton, readOnly = props.readOnly, autoFocus = props.autoFocus, _focused = props.focused, _props_multiline = props.multiline, multiline = _props_multiline === void 0 ? 1 : _props_multiline, _props_autoGrow = props.autoGrow, autoGrow = _props_autoGrow === void 0 ? false : _props_autoGrow, maxHeight = props.maxHeight, error = props.error, connectedRight = props.connectedRight, connectedLeft = props.connectedLeft, _props_type = props.type, type = _props_type === void 0 ? "text" : _props_type, _props_subdued = props.subdued, subdued = _props_subdued === void 0 ? false : _props_subdued, name = props.name, _id = props.id, role = props.role, step = props.step, _props_largeStep = props.largeStep, largeStep = _props_largeStep === void 0 ? 10 : _props_largeStep, autoComplete = props.autoComplete, max = props.max, maxLength = props.maxLength, min = props.min, minLength = props.minLength, _props_showCharacterCount = props.showCharacterCount, showCharacterCount = _props_showCharacterCount === void 0 ? false : _props_showCharacterCount, pattern = props.pattern, spellCheck = props.spellCheck, ariaOwns = props.ariaOwns, ariaControls = props.ariaControls, ariaExpanded = props.ariaExpanded, ariaActiveDescendant = props.ariaActiveDescendant, ariaAutocomplete = props.ariaAutocomplete, _props_align = props.align, align = _props_align === void 0 ? "left" : _props_align, requiredIndicator = props.requiredIndicator, selectTextOnFocus = props.selectTextOnFocus, onClearButtonClick = props.onClearButtonClick, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, tooltip = props.tooltip, className = props.className, _inputRef = props.inputRef, icon = props.icon, _props_transparent = props.transparent, transparent = _props_transparent === void 0 ? false : _props_transparent, _props_showNumberSteppers = props.showNumberSteppers, showNumberSteppers = _props_showNumberSteppers === void 0 ? true : _props_showNumberSteppers, onKeyDown = props.onKeyDown;
228
+ var suffix = maxLength && showCharacterCount ? "".concat(value.length, " / ").concat(maxLength) : _suffix;
229
+ var _internalRef = useRef(null);
230
+ var inputRef = _inputRef || _internalRef;
231
+ var _useState = _sliced_to_array(useState(null), 2), textareaHeight = _useState[0], setTextareaHeight = _useState[1];
232
+ var _useState1 = _sliced_to_array(useState(_focused), 2), focused = _useState1[0], setFocused = _useState1[1];
233
+ var hasError = !!error;
234
+ var hasSuffix = !!suffix || maxLength && showCharacterCount;
235
+ var hasPrefix = !!prefix || !!icon;
236
+ var hasMultiline = multiline > 1;
237
+ var hasConnectedLeft = !!connectedLeft;
238
+ var hasConnectedRight = !!connectedRight;
239
+ var idValue = useId();
240
+ var idRef = useRef(_id || idValue);
241
+ var id = idRef.current;
242
+ var _useState2 = _sliced_to_array(useState(false), 2), isShiftPressed = _useState2[0], setIsShiftPressed = _useState2[1];
243
+ useEffect(function() {
244
+ var handleKeyDown = function(e) {
245
+ if (e.key === "Shift") {
246
+ setIsShiftPressed(true);
247
+ }
248
+ };
249
+ var handleKeyUp = function(e) {
250
+ if (e.key === "Shift") {
251
+ setIsShiftPressed(false);
252
+ }
253
+ };
254
+ window.addEventListener("keydown", handleKeyDown);
255
+ window.addEventListener("keyup", handleKeyUp);
256
+ return function() {
257
+ window.removeEventListener("keydown", handleKeyDown);
258
+ window.removeEventListener("keyup", handleKeyUp);
259
+ };
260
+ }, []);
261
+ var handleFocus = function(event) {
262
+ setFocused(true);
263
+ if (selectTextOnFocus && inputRef.current) {
264
+ var _inputRef_current;
265
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.select();
266
+ }
267
+ if (onFocus) {
268
+ onFocus(event);
269
+ }
270
+ };
271
+ useEffect(function() {
272
+ if (autoFocus && inputRef.current) {
273
+ setTimeout(function() {
274
+ var _inputRef_current;
275
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
276
+ if (selectTextOnFocus) {
277
+ var _inputRef_current1;
278
+ (_inputRef_current1 = inputRef.current) === null || _inputRef_current1 === void 0 ? void 0 : _inputRef_current1.select();
279
+ }
280
+ }, 0);
281
+ }
282
+ }, []);
283
+ var classes = styles({
284
+ disabled: Boolean(disabled || readOnly),
285
+ hasError: hasError,
286
+ focused: Boolean(focused && !readOnly),
287
+ subdued: subdued,
288
+ transparent: transparent
289
+ });
290
+ var iconClasses = iconStyles();
291
+ var inputClasses = inputStyles({
292
+ hasSuffix: hasSuffix,
293
+ hasPrefix: hasPrefix,
294
+ hasMultiline: hasMultiline,
295
+ disabled: disabled,
296
+ hasError: hasError,
297
+ readOnly: readOnly,
298
+ align: align,
299
+ type: type
300
+ });
301
+ var clearButtonClasses = clearButtonStyles({
302
+ visible: (value === null || value === void 0 ? void 0 : value.length) > 0 && !readOnly && !disabled
303
+ });
304
+ var handleBlur = function(event) {
305
+ setFocused(false);
306
+ if (onBlur) {
307
+ onBlur(event);
308
+ }
309
+ };
310
+ var InputElement = hasMultiline ? "textarea" : "input";
311
+ var leftContent = hasConnectedLeft ? connectedLeft : null;
312
+ var rightContent = hasConnectedRight ? connectedRight : null;
313
+ var inputHeight = parseInt(multiline) * 20 + 10;
314
+ var focusInput = function() {
315
+ var _inputRef_current;
316
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
317
+ };
318
+ var adjustValue = function(delta) {
319
+ var increment = isShiftPressed ? largeStep : step || 1;
320
+ var newValue = Number(value || 0) + delta * increment;
321
+ if (!focused) {
322
+ var _inputRef_current;
323
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
324
+ }
325
+ if ((max === undefined || newValue <= max) && (min === undefined || newValue >= min)) {
326
+ onChange(String(newValue));
327
+ }
328
+ };
329
+ var memoizedIcon = useMemo(function() {
330
+ return icon;
331
+ }, [
332
+ icon
333
+ ]);
334
+ useEffect(function() {
335
+ // Handle auto-growing textarea
336
+ if (hasMultiline && autoGrow && inputRef.current) {
337
+ var updateHeight = function() {
338
+ // Reset height to allow proper scrollHeight calculation
339
+ inputRef.current.style.height = 'auto';
340
+ // Get the scroll height (content height)
341
+ var scrollHeight = inputRef.current.scrollHeight;
342
+ // Apply the height with a minimum based on multiline prop
343
+ var minHeight = parseInt(multiline) * 20 + 10;
344
+ var newHeight = Math.max(minHeight, scrollHeight);
345
+ // If maxHeight is provided, cap the height and enable scrolling
346
+ if (maxHeight && newHeight > maxHeight) {
347
+ inputRef.current.style.height = "".concat(maxHeight, "px");
348
+ inputRef.current.style.overflowY = 'auto';
349
+ } else {
350
+ inputRef.current.style.height = "".concat(newHeight, "px");
351
+ inputRef.current.style.overflowY = 'hidden';
352
+ }
353
+ setTextareaHeight(newHeight);
354
+ };
355
+ updateHeight();
356
+ }
357
+ }, [
358
+ value,
359
+ hasMultiline,
360
+ autoGrow,
361
+ multiline,
362
+ maxHeight
363
+ ]);
364
+ var inputContent = /*#__PURE__*/ _jsx("div", {
365
+ className: "".concat(classes).concat(className ? " ".concat(className) : ""),
366
+ onClick: focusInput,
367
+ children: /*#__PURE__*/ _jsxs("div", {
368
+ className: "flex justify-stretch items-center",
369
+ onClick: focusInput,
370
+ children: [
371
+ hasPrefix && /*#__PURE__*/ _jsx("div", {
372
+ className: "min-h-7.5 pl-2 flex items-center cursor-text self-start",
373
+ children: /*#__PURE__*/ _jsx(Text, {
374
+ color: "subdued",
375
+ className: "pointer-events-none whitespace-nowrap",
376
+ as: typeof prefix === "string" ? "p" : "div",
377
+ children: prefix
378
+ })
379
+ }),
380
+ memoizedIcon && /*#__PURE__*/ _jsx("span", {
381
+ className: iconClasses,
382
+ children: /*#__PURE__*/ _jsx(Icon, {
383
+ source: memoizedIcon,
384
+ color: "subdued"
385
+ })
386
+ }),
387
+ /*#__PURE__*/ _jsx(InputElement, {
388
+ ref: inputRef,
389
+ className: inputClasses,
390
+ name: name,
391
+ id: id,
392
+ value: value,
393
+ onChange: function(e) {
394
+ if (onChange) {
395
+ onChange(e.target.value);
396
+ }
397
+ },
398
+ onKeyDownCapture: onKeyDown,
399
+ onFocus: handleFocus,
400
+ onBlur: handleBlur,
401
+ placeholder: placeholder,
402
+ disabled: disabled,
403
+ type: hasMultiline ? undefined : type,
404
+ style: hasMultiline ? autoGrow ? {} // Height will be managed by the useEffect hook
405
+ : {
406
+ height: "".concat(inputHeight, "px")
407
+ } : {},
408
+ readOnly: readOnly,
409
+ max: max,
410
+ maxLength: maxLength,
411
+ min: min,
412
+ minLength: minLength,
413
+ pattern: pattern,
414
+ spellCheck: spellCheck,
415
+ autoComplete: autoComplete,
416
+ step: type === "number" ? step : undefined,
417
+ "aria-owns": ariaOwns,
418
+ "aria-controls": ariaControls,
419
+ "aria-expanded": ariaExpanded,
420
+ "aria-activedescendant": ariaActiveDescendant,
421
+ "aria-autocomplete": ariaAutocomplete,
422
+ role: role,
423
+ onKeyDown: function(e) {
424
+ if (type === "number" && !readOnly) {
425
+ if (e.key === "ArrowUp") {
426
+ e.preventDefault();
427
+ adjustValue(1);
428
+ } else if (e.key === "ArrowDown") {
429
+ e.preventDefault();
430
+ adjustValue(-1);
431
+ }
432
+ }
433
+ }
434
+ }),
435
+ hasSuffix && /*#__PURE__*/ _jsx("div", {
436
+ className: "min-h-7.5 pr-3 flex items-center cursor-text self-start",
437
+ children: /*#__PURE__*/ _jsx(Text, {
438
+ color: "subdued",
439
+ className: "pointer-events-none whitespace-nowrap",
440
+ children: suffix
441
+ })
442
+ }),
443
+ type === "number" && showNumberSteppers && !readOnly && !disabled && /*#__PURE__*/ _jsxs("div", {
444
+ className: "flex flex-col h-full max-h-7.5 border border-transparent",
445
+ children: [
446
+ /*#__PURE__*/ _jsx(Button, {
447
+ plain: true,
448
+ size: "stepper",
449
+ className: max !== undefined && value >= max ? "opacity-0 group-hover:opacity-20 pointer-events-none" : "opacity-0 group-hover:opacity-100",
450
+ contentClassName: "px-0.5!",
451
+ onMouseDown: function(e) {
452
+ e.preventDefault();
453
+ adjustValue(1);
454
+ },
455
+ children: /*#__PURE__*/ _jsx(Icon, {
456
+ source: CaretUpMinor,
457
+ color: "subdued",
458
+ className: "pointer-events-none"
459
+ })
460
+ }),
461
+ /*#__PURE__*/ _jsx(Button, {
462
+ plain: true,
463
+ size: "stepper",
464
+ className: min !== undefined && value <= min ? "opacity-0 group-hover:opacity-20 pointer-events-none" : "opacity-0 group-hover:opacity-100",
465
+ contentClassName: "px-0.5!",
466
+ onMouseDown: function(e) {
467
+ e.preventDefault();
468
+ adjustValue(-1);
469
+ },
470
+ children: /*#__PURE__*/ _jsx(Icon, {
471
+ source: CaretDownMinor,
472
+ color: "subdued",
473
+ className: "pointer-events-none"
474
+ })
475
+ })
476
+ ]
477
+ }),
478
+ clearButton && onClearButtonClick && /*#__PURE__*/ _jsx("div", {
479
+ className: clearButtonClasses,
480
+ onClick: onClearButtonClick,
481
+ children: /*#__PURE__*/ _jsx(Icon, {
482
+ source: CancelSmallMinor,
483
+ color: "subdued"
484
+ })
485
+ })
486
+ ]
487
+ })
488
+ });
489
+ return /*#__PURE__*/ _jsxs("div", {
490
+ className: "Litho-TextFieldContainer flex flex-col gap-1",
491
+ children: [
492
+ label && !labelHidden && /*#__PURE__*/ _jsxs("div", {
493
+ className: "flex justify-between items-end",
494
+ children: [
495
+ /*#__PURE__*/ _jsx(Label, {
496
+ id: id,
497
+ hidden: labelHidden,
498
+ disabled: disabled,
499
+ requiredIndicator: requiredIndicator,
500
+ tooltip: tooltip,
501
+ variant: labelVariant,
502
+ children: label
503
+ }),
504
+ labelAction && /*#__PURE__*/ _jsx(Link, {
505
+ onClick: labelAction.onAction,
506
+ removeUnderline: true,
507
+ children: labelAction.content
508
+ })
509
+ ]
510
+ }),
511
+ /*#__PURE__*/ _jsxs("div", {
512
+ className: "flex items-center gap-1",
513
+ children: [
514
+ leftContent,
515
+ /*#__PURE__*/ _jsx("div", {
516
+ className: "flex-1",
517
+ children: inputContent
518
+ }),
519
+ rightContent
520
+ ]
521
+ }),
522
+ error && /*#__PURE__*/ _jsx(InlineError, {
523
+ message: error,
524
+ icon: CircleAlertMajor
525
+ }),
526
+ helpText && /*#__PURE__*/ _jsx(Text, {
527
+ color: "subdued",
528
+ children: helpText
529
+ })
530
+ ]
531
+ });
532
+ }
533
+ export default TextField;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import { Icon } from "../index.js";
4
+ import { ImageMajor } from "@shopify/polaris-icons";
5
+ var imageContainerStyles = tv({
6
+ base: "relative flex items-center justify-center overflow-hidden rounded-lg border border-tint-4 bg-surface-higher group",
7
+ variants: {
8
+ size: {
9
+ small: "w-6 h-6",
10
+ medium: "w-10 h-10",
11
+ large: "w-12 h-12"
12
+ },
13
+ skeleton: {
14
+ true: "Litho-Thumbnail-Skeleton"
15
+ }
16
+ }
17
+ });
18
+ var imageStyles = tv({
19
+ base: "w-full max-w-full max-h-full h-auto object-cover object-top transition-transform duration-500 group-hover:translate-y-[-20%]",
20
+ defaultVariants: {
21
+ size: "medium"
22
+ }
23
+ });
24
+ /**
25
+ * Thumbnail component to display an image or a placeholder icon.
26
+ *
27
+ * @param {Object} props - The component props.
28
+ * @param {string} [props.src] - The image source URL.
29
+ * @param {string} [props.alt] - The alternative text for the image.
30
+ * @param {("small"|"medium"|"large"|number)} [props.size="medium"] - The size of the thumbnail. Can be "small", "medium", "large", or a numeric pixel value.
31
+ * @param {boolean} [props.skeleton=false] - Whether to show a skeleton loader instead of the image.
32
+ * @returns {JSX.Element} The rendered Thumbnail component.
33
+ */ function Thumbnail() {
34
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
35
+ var src = props.src, alt = props.alt, _props_size = props.size, size = _props_size === void 0 ? "medium" : _props_size, _props_skeleton = props.skeleton, skeleton = _props_skeleton === void 0 ? false : _props_skeleton;
36
+ var sizeIsInteger = Number.isInteger(size);
37
+ var hasImage = Boolean(src);
38
+ return /*#__PURE__*/ _jsx("div", {
39
+ className: imageContainerStyles({
40
+ skeleton: skeleton,
41
+ size: sizeIsInteger ? undefined : size
42
+ }),
43
+ style: sizeIsInteger ? {
44
+ width: "".concat(size, "px"),
45
+ height: "".concat(size, "px")
46
+ } : {},
47
+ children: skeleton ? null : hasImage ? /*#__PURE__*/ _jsx("img", {
48
+ src: src,
49
+ alt: alt,
50
+ className: imageStyles({
51
+ size: sizeIsInteger ? undefined : size
52
+ }),
53
+ style: sizeIsInteger ? {
54
+ width: "".concat(size, "px"),
55
+ height: "".concat(size, "px")
56
+ } : {}
57
+ }) : /*#__PURE__*/ _jsx(Icon, {
58
+ source: ImageMajor,
59
+ color: "subdued"
60
+ })
61
+ });
62
+ }
63
+ export default Thumbnail;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { TextField } from "../index.js";
3
+ function TimePicker() {
4
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5
+ var _props_label = props.label, label = _props_label === void 0 ? "Time:" : _props_label, _props_labelInline = props.labelInline, labelInline = _props_labelInline === void 0 ? true : _props_labelInline, value = props.value, onChange = props.onChange;
6
+ return /*#__PURE__*/ _jsx(TextField, {
7
+ type: "time",
8
+ prefix: labelInline ? label : null,
9
+ value: value,
10
+ onChange: onChange
11
+ });
12
+ }
13
+ export default TimePicker;