@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.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/components/ActionList.js +267 -0
- package/dist/cjs/components/AnnouncementBar.js +73 -0
- package/dist/cjs/components/AppProvider.js +245 -0
- package/dist/cjs/components/Autocomplete.js +351 -0
- package/dist/cjs/components/Badge.js +234 -0
- package/dist/cjs/components/Banner.js +264 -0
- package/dist/cjs/components/Box.js +247 -0
- package/dist/cjs/components/Button.js +1018 -0
- package/dist/cjs/components/ButtonGroup.js +196 -0
- package/dist/cjs/components/Card.js +593 -0
- package/dist/cjs/components/Checkbox.js +175 -0
- package/dist/cjs/components/ChoiceList.js +160 -0
- package/dist/cjs/components/Collapsible.js +42 -0
- package/dist/cjs/components/ColorField.js +159 -0
- package/dist/cjs/components/ContextualSaveBar.js +53 -0
- package/dist/cjs/components/DatePicker.js +547 -0
- package/dist/cjs/components/Divider.js +50 -0
- package/dist/cjs/components/DropZone.js +547 -0
- package/dist/cjs/components/EmptyState.js +111 -0
- package/dist/cjs/components/Filters.js +874 -0
- package/dist/cjs/components/FooterHelp.js +48 -0
- package/dist/cjs/components/Form.js +44 -0
- package/dist/cjs/components/Frame.js +386 -0
- package/dist/cjs/components/FrameSaveBar.js +239 -0
- package/dist/cjs/components/Grid.js +151 -0
- package/dist/cjs/components/HorizontalStack.js +180 -0
- package/dist/cjs/components/Icon.js +346 -0
- package/dist/cjs/components/Image.js +191 -0
- package/dist/cjs/components/InlineError.js +57 -0
- package/dist/cjs/components/Label.js +78 -0
- package/dist/cjs/components/Layout.js +228 -0
- package/dist/cjs/components/LayoutSection.js +133 -0
- package/dist/cjs/components/Link.js +128 -0
- package/dist/cjs/components/List.js +69 -0
- package/dist/cjs/components/Listbox.js +211 -0
- package/dist/cjs/components/Loading.js +103 -0
- package/dist/cjs/components/Modal.js +449 -0
- package/dist/cjs/components/Navigation.js +331 -0
- package/dist/cjs/components/Page.js +529 -0
- package/dist/cjs/components/Pagination.js +109 -0
- package/dist/cjs/components/Pane.js +128 -0
- package/dist/cjs/components/Popover.js +365 -0
- package/dist/cjs/components/PopoverManager.js +34 -0
- package/dist/cjs/components/ProgressBar.js +124 -0
- package/dist/cjs/components/RadioButton.js +172 -0
- package/dist/cjs/components/RadioButtonCard.js +193 -0
- package/dist/cjs/components/RangeSlider.js +235 -0
- package/dist/cjs/components/ResourceList.js +105 -0
- package/dist/cjs/components/Select.js +300 -0
- package/dist/cjs/components/SkeletonText.js +130 -0
- package/dist/cjs/components/Spinner.js +72 -0
- package/dist/cjs/components/Table.js +1184 -0
- package/dist/cjs/components/Tabs.js +421 -0
- package/dist/cjs/components/Tag.js +165 -0
- package/dist/cjs/components/Text.js +274 -0
- package/dist/cjs/components/TextField.js +584 -0
- package/dist/cjs/components/Thumbnail.js +73 -0
- package/dist/cjs/components/TimePicker.js +23 -0
- package/dist/cjs/components/Tip.js +220 -0
- package/dist/cjs/components/Tooltip.js +431 -0
- package/dist/cjs/components/TopBar.js +210 -0
- package/dist/cjs/components/VerticalStack.js +161 -0
- package/dist/cjs/index.js +308 -0
- package/dist/cjs/styles/Table.js +591 -0
- package/dist/cjs/utilities/dates.js +339 -0
- package/dist/cjs/utilities/useIndexResourceState.js +175 -0
- package/dist/cjs/utilities/useMounted.js +67 -0
- package/dist/cjs/utilities/useTableScrollState.js +142 -0
- package/dist/esm/components/ActionList.js +216 -0
- package/dist/esm/components/AnnouncementBar.js +63 -0
- package/dist/esm/components/AppProvider.js +185 -0
- package/dist/esm/components/Autocomplete.js +300 -0
- package/dist/esm/components/Badge.js +225 -0
- package/dist/esm/components/Banner.js +254 -0
- package/dist/esm/components/Box.js +238 -0
- package/dist/esm/components/Button.js +967 -0
- package/dist/esm/components/ButtonGroup.js +137 -0
- package/dist/esm/components/Card.js +537 -0
- package/dist/esm/components/Checkbox.js +165 -0
- package/dist/esm/components/ChoiceList.js +145 -0
- package/dist/esm/components/Collapsible.js +32 -0
- package/dist/esm/components/ColorField.js +149 -0
- package/dist/esm/components/ContextualSaveBar.js +43 -0
- package/dist/esm/components/DatePicker.js +532 -0
- package/dist/esm/components/Divider.js +41 -0
- package/dist/esm/components/DropZone.js +537 -0
- package/dist/esm/components/EmptyState.js +101 -0
- package/dist/esm/components/Filters.js +823 -0
- package/dist/esm/components/FooterHelp.js +38 -0
- package/dist/esm/components/Form.js +35 -0
- package/dist/esm/components/Frame.js +376 -0
- package/dist/esm/components/FrameSaveBar.js +229 -0
- package/dist/esm/components/Grid.js +142 -0
- package/dist/esm/components/HorizontalStack.js +171 -0
- package/dist/esm/components/Icon.js +296 -0
- package/dist/esm/components/Image.js +141 -0
- package/dist/esm/components/InlineError.js +43 -0
- package/dist/esm/components/Label.js +63 -0
- package/dist/esm/components/Layout.js +164 -0
- package/dist/esm/components/LayoutSection.js +82 -0
- package/dist/esm/components/Link.js +119 -0
- package/dist/esm/components/List.js +61 -0
- package/dist/esm/components/Listbox.js +201 -0
- package/dist/esm/components/Loading.js +93 -0
- package/dist/esm/components/Modal.js +390 -0
- package/dist/esm/components/Navigation.js +321 -0
- package/dist/esm/components/Page.js +473 -0
- package/dist/esm/components/Pagination.js +99 -0
- package/dist/esm/components/Pane.js +118 -0
- package/dist/esm/components/Popover.js +350 -0
- package/dist/esm/components/PopoverManager.js +24 -0
- package/dist/esm/components/ProgressBar.js +114 -0
- package/dist/esm/components/RadioButton.js +157 -0
- package/dist/esm/components/RadioButtonCard.js +178 -0
- package/dist/esm/components/RangeSlider.js +225 -0
- package/dist/esm/components/ResourceList.js +95 -0
- package/dist/esm/components/Select.js +285 -0
- package/dist/esm/components/SkeletonText.js +120 -0
- package/dist/esm/components/Spinner.js +63 -0
- package/dist/esm/components/Table.js +1129 -0
- package/dist/esm/components/Tabs.js +366 -0
- package/dist/esm/components/Tag.js +151 -0
- package/dist/esm/components/Text.js +265 -0
- package/dist/esm/components/TextField.js +533 -0
- package/dist/esm/components/Thumbnail.js +63 -0
- package/dist/esm/components/TimePicker.js +13 -0
- package/dist/esm/components/Tip.js +169 -0
- package/dist/esm/components/Tooltip.js +380 -0
- package/dist/esm/components/TopBar.js +200 -0
- package/dist/esm/components/VerticalStack.js +152 -0
- package/dist/esm/index.js +61 -0
- package/dist/esm/styles/Table.js +581 -0
- package/dist/esm/utilities/dates.js +289 -0
- package/dist/esm/utilities/useIndexResourceState.js +158 -0
- package/dist/esm/utilities/useMounted.js +57 -0
- package/dist/esm/utilities/useTableScrollState.js +132 -0
- package/index.css +1137 -0
- package/package.json +53 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
13
|
+
function _define_property(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _iterable_to_array(iter) {
|
|
27
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
28
|
+
}
|
|
29
|
+
function _iterable_to_array_limit(arr, i) {
|
|
30
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
31
|
+
if (_i == null) return;
|
|
32
|
+
var _arr = [];
|
|
33
|
+
var _n = true;
|
|
34
|
+
var _d = false;
|
|
35
|
+
var _s, _e;
|
|
36
|
+
try {
|
|
37
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
38
|
+
_arr.push(_s.value);
|
|
39
|
+
if (i && _arr.length === i) break;
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_d = true;
|
|
43
|
+
_e = err;
|
|
44
|
+
} finally{
|
|
45
|
+
try {
|
|
46
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
47
|
+
} finally{
|
|
48
|
+
if (_d) throw _e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return _arr;
|
|
52
|
+
}
|
|
53
|
+
function _non_iterable_rest() {
|
|
54
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
55
|
+
}
|
|
56
|
+
function _non_iterable_spread() {
|
|
57
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
+
}
|
|
59
|
+
function _object_spread(target) {
|
|
60
|
+
for(var i = 1; i < arguments.length; i++){
|
|
61
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
62
|
+
var ownKeys = Object.keys(source);
|
|
63
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
64
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
65
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
ownKeys.forEach(function(key) {
|
|
69
|
+
_define_property(target, key, source[key]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function ownKeys(object, enumerableOnly) {
|
|
75
|
+
var keys = Object.keys(object);
|
|
76
|
+
if (Object.getOwnPropertySymbols) {
|
|
77
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
78
|
+
if (enumerableOnly) {
|
|
79
|
+
symbols = symbols.filter(function(sym) {
|
|
80
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
keys.push.apply(keys, symbols);
|
|
84
|
+
}
|
|
85
|
+
return keys;
|
|
86
|
+
}
|
|
87
|
+
function _object_spread_props(target, source) {
|
|
88
|
+
source = source != null ? source : {};
|
|
89
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
90
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
91
|
+
} else {
|
|
92
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
93
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
function _sliced_to_array(arr, i) {
|
|
99
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
100
|
+
}
|
|
101
|
+
function _to_consumable_array(arr) {
|
|
102
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
103
|
+
}
|
|
104
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
105
|
+
if (!o) return;
|
|
106
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
107
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
108
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
109
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
110
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
111
|
+
}
|
|
112
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
113
|
+
import React, { cloneElement, isValidElement, useState } from "react";
|
|
114
|
+
import { tv } from "tailwind-variants";
|
|
115
|
+
import { Popover, TextField, Checkbox, Spinner, Text, Icon } from "../index.js";
|
|
116
|
+
import { SearchMinor } from "@shopify/polaris-icons";
|
|
117
|
+
var styles = tv({
|
|
118
|
+
base: "Litho-Autocomplete flex flex-col"
|
|
119
|
+
});
|
|
120
|
+
function attachPropToTextField(children, prop) {
|
|
121
|
+
return React.Children.map(children, function(child) {
|
|
122
|
+
if (/*#__PURE__*/ isValidElement(child)) {
|
|
123
|
+
var _child_type, _child_props;
|
|
124
|
+
if (((_child_type = child.type) === null || _child_type === void 0 ? void 0 : _child_type.displayName) === "Autocomplete.TextField") {
|
|
125
|
+
return /*#__PURE__*/ cloneElement(child, prop);
|
|
126
|
+
}
|
|
127
|
+
if ((_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.children) {
|
|
128
|
+
return /*#__PURE__*/ cloneElement(child, {
|
|
129
|
+
children: attachPropToTextField(child.props.children, prop)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return child;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Autocomplete component that provides a flexible dropdown menu with search and selection capabilities.
|
|
138
|
+
*
|
|
139
|
+
* @component
|
|
140
|
+
* @param {Object} props - The props for the Autocomplete component.
|
|
141
|
+
* @param {Array<Object>} props.options - The options to display in the dropdown. Each option should have a `label` and a `value`.
|
|
142
|
+
* @param {Array<string>} props.selected - The currently selected option values.
|
|
143
|
+
* @param {"below"|"above"} [props.preferredPosition="below"] - The preferred position of the dropdown relative to the activator.
|
|
144
|
+
* @param {"left"|"center"|"right"} [props.preferredAlignment="left"] - The preferred alignment of the dropdown.
|
|
145
|
+
* @param {boolean} [props.allowMultiple=false] - Whether multiple options can be selected.
|
|
146
|
+
* @param {boolean} [props.loading=false] - Whether to show a loading spinner in the dropdown.
|
|
147
|
+
* @param {Object} [props.emptyState] - The content to display when there are no options.
|
|
148
|
+
* @param {React.ReactNode} [props.emptyState.icon] - An optional icon to display in the empty state.
|
|
149
|
+
* @param {function(Array<string>)} props.onSelect - Callback fired when the selection changes. Receives the new selected values.
|
|
150
|
+
* @param {React.ReactNode} props.textField - The activator for the dropdown, typically a `TextField` component.
|
|
151
|
+
* @param {string} [props.className] - Additional class names to apply to the component.
|
|
152
|
+
* @param {function} [props.onClose] - Callback fired when the dropdown closes.
|
|
153
|
+
* @param {number} [props.zIndexOverride] - Custom z-index for the dropdown.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* <Autocomplete
|
|
157
|
+
* options={[{ label: "Option 1", value: "1" }, { label: "Option 2", value: "2" }]}
|
|
158
|
+
* selected={["1"]}
|
|
159
|
+
* allowMultiple
|
|
160
|
+
* onSelect={(selected) => console.log(selected)}
|
|
161
|
+
* textField={<Autocomplete.TextField placeholder="Search..." />}
|
|
162
|
+
* />
|
|
163
|
+
*/ function Autocomplete() {
|
|
164
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
165
|
+
var options = props.options, selected = props.selected, _props_preferredPosition = props.preferredPosition, preferredPosition = _props_preferredPosition === void 0 ? "below" : _props_preferredPosition, _props_preferredAlignment = props.preferredAlignment, preferredAlignment = _props_preferredAlignment === void 0 ? "left" : _props_preferredAlignment, allowMultiple = props.allowMultiple, loading = props.loading, emptyState = props.emptyState, onSelect = props.onSelect, textField = props.textField, className = props.className, zIndexOverride = props.zIndexOverride;
|
|
166
|
+
var classes = styles();
|
|
167
|
+
var _useState = _sliced_to_array(useState(false), 2), showOptionsPopover = _useState[0], setShowOptionsPopover = _useState[1];
|
|
168
|
+
var onTextFieldFocus = function() {
|
|
169
|
+
if (!showOptionsPopover) {
|
|
170
|
+
setShowOptionsPopover(true);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var showEmptyState = options.length === 0 && !!(emptyState === null || emptyState === void 0 ? void 0 : emptyState.content);
|
|
174
|
+
var OptionItem = function(param) {
|
|
175
|
+
var option = param.option, allowMultiple = param.allowMultiple, selected = param.selected, onSelect = param.onSelect, setShowOptionsPopover = param.setShowOptionsPopover;
|
|
176
|
+
var isChecked = selected.includes(option.value);
|
|
177
|
+
if (allowMultiple) {
|
|
178
|
+
return /*#__PURE__*/ _jsx(Checkbox, {
|
|
179
|
+
label: option.label,
|
|
180
|
+
checked: isChecked,
|
|
181
|
+
onChange: function() {
|
|
182
|
+
onSelect(isChecked ? selected.filter(function(v) {
|
|
183
|
+
return v !== option.value;
|
|
184
|
+
}) : _to_consumable_array(selected).concat([
|
|
185
|
+
option.value
|
|
186
|
+
]));
|
|
187
|
+
},
|
|
188
|
+
className: "px-2 py-1.5 cursor-pointer rounded-md hover-dark"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
192
|
+
className: "flex py-1.5 px-3 cursor-pointer rounded-md hover-dark",
|
|
193
|
+
onClick: function() {
|
|
194
|
+
onSelect([
|
|
195
|
+
option.value
|
|
196
|
+
]);
|
|
197
|
+
setShowOptionsPopover && setShowOptionsPopover(false);
|
|
198
|
+
},
|
|
199
|
+
children: option.label
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
203
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
204
|
+
children: /*#__PURE__*/ _jsx(Popover, {
|
|
205
|
+
active: showOptionsPopover,
|
|
206
|
+
preferredPosition: preferredPosition,
|
|
207
|
+
preferredAlignment: preferredAlignment,
|
|
208
|
+
activator: attachPropToTextField(textField, {
|
|
209
|
+
onTextFieldFocus: onTextFieldFocus
|
|
210
|
+
}),
|
|
211
|
+
activatorDisplayType: "block",
|
|
212
|
+
matchActivatorWidth: true,
|
|
213
|
+
onClose: function() {
|
|
214
|
+
setShowOptionsPopover(false);
|
|
215
|
+
if (props.onClose) {
|
|
216
|
+
props.onClose();
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
zIndexOverride: zIndexOverride,
|
|
220
|
+
children: loading ? /*#__PURE__*/ _jsx("div", {
|
|
221
|
+
className: "py-4 flex justify-center items-center",
|
|
222
|
+
children: /*#__PURE__*/ _jsx(Spinner, {
|
|
223
|
+
size: "small"
|
|
224
|
+
})
|
|
225
|
+
}) : showEmptyState ? /*#__PURE__*/ _jsxs("div", {
|
|
226
|
+
className: "py-4 flex flex-col gap-1 justify-center items-center",
|
|
227
|
+
children: [
|
|
228
|
+
emptyState.icon && /*#__PURE__*/ _jsx(Icon, {
|
|
229
|
+
source: SearchMinor,
|
|
230
|
+
color: "subdued"
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
233
|
+
children: emptyState.content
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
}) : options.length > 0 ? /*#__PURE__*/ _jsx("div", {
|
|
237
|
+
className: "p-2",
|
|
238
|
+
children: options.map(function(option, index) {
|
|
239
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
240
|
+
children: [
|
|
241
|
+
option.title && /*#__PURE__*/ _jsx(Text, {
|
|
242
|
+
variant: "bodyMd",
|
|
243
|
+
color: "subdued",
|
|
244
|
+
className: "pb-1",
|
|
245
|
+
children: option.title
|
|
246
|
+
}),
|
|
247
|
+
option.options ? option.options.map(function(subOption, subIndex) {
|
|
248
|
+
return /*#__PURE__*/ _jsx(OptionItem, {
|
|
249
|
+
option: subOption,
|
|
250
|
+
allowMultiple: allowMultiple,
|
|
251
|
+
selected: selected,
|
|
252
|
+
onSelect: onSelect,
|
|
253
|
+
setShowOptionsPopover: setShowOptionsPopover
|
|
254
|
+
}, "".concat(index, "-").concat(subIndex));
|
|
255
|
+
}) : /*#__PURE__*/ _jsx(OptionItem, {
|
|
256
|
+
option: option,
|
|
257
|
+
allowMultiple: allowMultiple,
|
|
258
|
+
selected: selected,
|
|
259
|
+
onSelect: onSelect,
|
|
260
|
+
setShowOptionsPopover: setShowOptionsPopover
|
|
261
|
+
}, index)
|
|
262
|
+
]
|
|
263
|
+
}, index);
|
|
264
|
+
})
|
|
265
|
+
}) : undefined
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
Autocomplete.displayName = "Autocomplete";
|
|
270
|
+
/**
|
|
271
|
+
* Autocomplete TextField component used as an activator for the Autocomplete dropdown.
|
|
272
|
+
*
|
|
273
|
+
* @component
|
|
274
|
+
* @param {Object} props - The props for the AutocompleteTextField component.
|
|
275
|
+
* @param {function} [props.onTextFieldFocus] - Callback fired when the TextField gains focus.
|
|
276
|
+
* @param {function} [props.onFocus] - Callback fired when the TextField gains focus (native TextField event).
|
|
277
|
+
* @param {string} [props.placeholder] - Placeholder text for the TextField.
|
|
278
|
+
* @param {string} [props.value] - The current value of the TextField.
|
|
279
|
+
* @param {function} [props.onChange] - Callback fired when the TextField value changes.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* <Autocomplete.TextField
|
|
283
|
+
* placeholder="Search..."
|
|
284
|
+
* onTextFieldFocus={() => console.log("Focused")}
|
|
285
|
+
* />
|
|
286
|
+
*/ Autocomplete.TextField = function AutocompleteTextField() {
|
|
287
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
288
|
+
return /*#__PURE__*/ _jsx(TextField, _object_spread_props(_object_spread({}, props), {
|
|
289
|
+
onFocus: function() {
|
|
290
|
+
if (props.onTextFieldFocus) {
|
|
291
|
+
props.onTextFieldFocus();
|
|
292
|
+
}
|
|
293
|
+
if (props.onFocus) {
|
|
294
|
+
props.onFocus();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
298
|
+
};
|
|
299
|
+
Autocomplete.TextField.displayName = "Autocomplete.TextField";
|
|
300
|
+
export default Autocomplete;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
var styles = tv({
|
|
4
|
+
base: "Litho-Badge inline-flex items-center gap-1.5 text-sm rounded-full leading-normal min-h-5.5",
|
|
5
|
+
variants: {
|
|
6
|
+
status: {
|
|
7
|
+
info: "bg-info-alt text-info-alt-fg",
|
|
8
|
+
success: "bg-success-alt text-success-alt-fg dark:bg-success-alt/50",
|
|
9
|
+
warning: "bg-warning-alt text-warning-alt-fg dark:bg-warning-alt/50",
|
|
10
|
+
critical: "bg-critical-alt text-critical-alt-fg dark:bg-critical-alt/50",
|
|
11
|
+
attention: "bg-attention-alt text-attention-alt-fg dark:bg-attention-alt/50",
|
|
12
|
+
highlight: "bg-highlight-alt text-highlight-alt-fg dark:bg-highlight-alt/50",
|
|
13
|
+
insight: "bg-insight-alt text-insight-alt-fg dark:bg-insight-alt/50",
|
|
14
|
+
neutral: "bg-neutral-alt text-neutral-alt-fg dark:bg-neutral-alt/50",
|
|
15
|
+
default: "bg-neutral-alt text-neutral-alt-fg dark:bg-neutral-alt/50"
|
|
16
|
+
},
|
|
17
|
+
progress: {
|
|
18
|
+
true: "pl-2 pr-2.5",
|
|
19
|
+
false: "px-2.5"
|
|
20
|
+
},
|
|
21
|
+
capitalize: {
|
|
22
|
+
true: "capitalize",
|
|
23
|
+
false: ""
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
status: "neutral",
|
|
28
|
+
progress: "null",
|
|
29
|
+
capitalize: false
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
var progressBadgeStyles = tv({
|
|
33
|
+
base: "relative overflow-hidden rounded-max w-2 h-2 border",
|
|
34
|
+
variants: {
|
|
35
|
+
status: {
|
|
36
|
+
default: "border-neutral-alt-icon",
|
|
37
|
+
info: "border-info-alt-icon",
|
|
38
|
+
success: "border-success-alt-icon",
|
|
39
|
+
warning: "border-warning-alt-icon",
|
|
40
|
+
critical: "border-critical-alt-icon",
|
|
41
|
+
attention: "border-attention-alt-icon",
|
|
42
|
+
highlight: "border-highlight-alt-icon",
|
|
43
|
+
insight: "border-insight-alt-icon",
|
|
44
|
+
neutral: "border-neutral-alt-icon"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
compoundVariants: [
|
|
48
|
+
{
|
|
49
|
+
status: "default",
|
|
50
|
+
progress: "complete",
|
|
51
|
+
class: "bg-neutral-alt-icon"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
status: "default",
|
|
55
|
+
progress: "incomplete",
|
|
56
|
+
class: "border-neutral-alt-icon"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
status: "default",
|
|
60
|
+
progress: "partiallyComplete",
|
|
61
|
+
class: "bg-neutral-alt"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
status: "info",
|
|
65
|
+
progress: "complete",
|
|
66
|
+
class: "bg-info-alt-icon"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
status: "info",
|
|
70
|
+
progress: "incomplete",
|
|
71
|
+
class: "border-info-alt-icon"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
status: "info",
|
|
75
|
+
progress: "partiallyComplete",
|
|
76
|
+
class: "bg-info-alt"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
status: "success",
|
|
80
|
+
progress: "complete",
|
|
81
|
+
class: "bg-success-alt-icon"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
status: "success",
|
|
85
|
+
progress: "incomplete",
|
|
86
|
+
class: "border-success-alt-icon"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
status: "success",
|
|
90
|
+
progress: "partiallyComplete",
|
|
91
|
+
class: "bg-success-alt"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
status: "warning",
|
|
95
|
+
progress: "complete",
|
|
96
|
+
class: "bg-warning-alt-icon"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
status: "warning",
|
|
100
|
+
progress: "incomplete",
|
|
101
|
+
class: "border-warning-alt-icon"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
status: "warning",
|
|
105
|
+
progress: "partiallyComplete",
|
|
106
|
+
class: "bg-warning-alt"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
status: "critical",
|
|
110
|
+
progress: "complete",
|
|
111
|
+
class: "bg-critical-alt-icon"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
status: "critical",
|
|
115
|
+
progress: "incomplete",
|
|
116
|
+
class: "border-critical-alt-icon"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
status: "critical",
|
|
120
|
+
progress: "partiallyComplete",
|
|
121
|
+
class: "bg-critical-alt"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
status: "attention",
|
|
125
|
+
progress: "complete",
|
|
126
|
+
class: "bg-attention-alt-icon"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
status: "attention",
|
|
130
|
+
progress: "incomplete",
|
|
131
|
+
class: "border-attention-alt-icon"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
status: "attention",
|
|
135
|
+
progress: "partiallyComplete",
|
|
136
|
+
class: "bg-attention-alt"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
status: "highlight",
|
|
140
|
+
progress: "complete",
|
|
141
|
+
class: "bg-highlight-alt-icon"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
status: "highlight",
|
|
145
|
+
progress: "incomplete",
|
|
146
|
+
class: "border-highlight-alt-icon"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
status: "highlight",
|
|
150
|
+
progress: "partiallyComplete",
|
|
151
|
+
class: "bg-highlight-alt"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
status: "insight",
|
|
155
|
+
progress: "complete",
|
|
156
|
+
class: "bg-insight-alt-icon"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
status: "insight",
|
|
160
|
+
progress: "incomplete",
|
|
161
|
+
class: "border-insight-alt-icon"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
status: "insight",
|
|
165
|
+
progress: "partiallyComplete",
|
|
166
|
+
class: "bg-insight-alt"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
status: "neutral",
|
|
170
|
+
progress: "complete",
|
|
171
|
+
class: "bg-neutral-alt-icon"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
status: "neutral",
|
|
175
|
+
progress: "incomplete",
|
|
176
|
+
class: "border-neutral-alt-icon"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
status: "neutral",
|
|
180
|
+
progress: "partiallyComplete",
|
|
181
|
+
class: "bg-neutral-alt"
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
defaultVariants: {
|
|
185
|
+
status: "default",
|
|
186
|
+
progress: "null"
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
/**
|
|
190
|
+
* Badge component with optional progress indicator.
|
|
191
|
+
*
|
|
192
|
+
* @component
|
|
193
|
+
* @param {object} props - Component properties.
|
|
194
|
+
* @param {React.ReactNode} props.children - Content to display within the badge.
|
|
195
|
+
* @param {"complete" | "incomplete" | "partiallyComplete" | null} [props.progress] - Progress state of the badge.
|
|
196
|
+
* @param {boolean} [props.capitalize] - Capitalize the first letter of the badge.
|
|
197
|
+
* @param {"default" | "info" | "success" | "warning" | "critical" | "attention" | "highlight"} [props.status="default"] - Status variant to style the badge.
|
|
198
|
+
* @returns {JSX.Element} - Rendered Badge component with optional progress indicator.
|
|
199
|
+
*/ function Badge() {
|
|
200
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
201
|
+
var children = props.children, progress = props.progress, status = props.status, capitalize = props.capitalize, className = props.className;
|
|
202
|
+
var classes = styles({
|
|
203
|
+
progress: !!progress,
|
|
204
|
+
status: status,
|
|
205
|
+
capitalize: capitalize
|
|
206
|
+
});
|
|
207
|
+
var progressBadgeClasses = progressBadgeStyles({
|
|
208
|
+
progress: progress || "null",
|
|
209
|
+
status: status
|
|
210
|
+
});
|
|
211
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
212
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
213
|
+
children: [
|
|
214
|
+
progress && /*#__PURE__*/ _jsx("div", {
|
|
215
|
+
className: progressBadgeClasses,
|
|
216
|
+
children: progress === "partiallyComplete" && /*#__PURE__*/ _jsx("div", {
|
|
217
|
+
className: "absolute inset-0 top-1/2 h-1/2 bg-".concat(status, "-alt-icon")
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
children
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
;
|
|
225
|
+
export default Badge;
|