@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,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
13
|
+
var _index = require("../index");
|
|
14
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
15
|
+
base: "Litho-ResourceList flex flex-col min-w-72",
|
|
16
|
+
variants: {
|
|
17
|
+
divider: {
|
|
18
|
+
true: "divide-y divide-edge-default",
|
|
19
|
+
false: ""
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* ResourceList component displays a list of items with loading and empty states.
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
* @param {Object} props - The component props.
|
|
28
|
+
* @param {Array} [props.items=[]] - List of items to display.
|
|
29
|
+
* @param {boolean} [props.loading=false] - Whether the list is in a loading state.
|
|
30
|
+
* @param {string|React.ReactNode} [props.emptyState="No results found."] - Content to display when the list is empty.
|
|
31
|
+
* @param {Function} props.renderItem - Function to render each item in the list.
|
|
32
|
+
* @param {Object} [props.resourceName] - Object containing singular and plural resource names.
|
|
33
|
+
* @param {string} [props.resourceName.singular] - Singular resource name.
|
|
34
|
+
* @param {string} [props.resourceName.plural] - Plural resource name.
|
|
35
|
+
* @param {boolean} [props.divider=true] - Whether to show dividers between items.
|
|
36
|
+
* @param {"none"|"small"|"large"} [props.gap="none"] - Gap size between items.
|
|
37
|
+
* @returns {JSX.Element} The rendered component.
|
|
38
|
+
*/ function ResourceList() {
|
|
39
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
40
|
+
var _props_items = props.items, items = _props_items === void 0 ? [] : _props_items, _props_loading = props.loading, loading = _props_loading === void 0 ? false : _props_loading, _props_emptyState = props.emptyState, emptyState = _props_emptyState === void 0 ? "No results found." : _props_emptyState, renderItem = props.renderItem, _props_resourceName = props.resourceName, resourceName = _props_resourceName === void 0 ? {
|
|
41
|
+
singular: "item",
|
|
42
|
+
plural: "items"
|
|
43
|
+
} : _props_resourceName, _props_divider = props.divider, divider = _props_divider === void 0 ? true : _props_divider, _props_gap = props.gap, gap = _props_gap === void 0 ? "none" : _props_gap;
|
|
44
|
+
var gapMap = {
|
|
45
|
+
none: "0",
|
|
46
|
+
small: "2",
|
|
47
|
+
large: "4"
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.VerticalStack, {
|
|
50
|
+
gap: gapMap[gap],
|
|
51
|
+
className: styles({
|
|
52
|
+
divider: divider
|
|
53
|
+
}),
|
|
54
|
+
children: loading && items.length === 0 ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
55
|
+
className: "flex justify-center items-center p-3",
|
|
56
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Spinner, {
|
|
57
|
+
size: "small"
|
|
58
|
+
})
|
|
59
|
+
}, "".concat(resourceName.singular, "-loading")) : items.length > 0 ? items.map(function(item, index) {
|
|
60
|
+
return renderItem(item, index);
|
|
61
|
+
}) : typeof emptyState === "string" ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
62
|
+
className: "py-3 px-4 text-center",
|
|
63
|
+
children: emptyState
|
|
64
|
+
}, "".concat(resourceName.plural, "-empty")) : emptyState
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
var itemStyles = (0, _tailwindvariants.tv)({
|
|
68
|
+
base: "Litho-ResourceList-Item py-3 px-4 cursor-pointer",
|
|
69
|
+
variants: {
|
|
70
|
+
selected: {
|
|
71
|
+
true: "bg-surface-higher",
|
|
72
|
+
false: "hover:bg-surface-higher"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Item component represents a single item in the ResourceList.
|
|
78
|
+
*
|
|
79
|
+
* @component
|
|
80
|
+
* @param {Object} props - The component props.
|
|
81
|
+
* @param {string} [props.id] - The ID of the item.
|
|
82
|
+
* @param {string} [props.accessibilityLabel] - Accessibility label for the item.
|
|
83
|
+
* @param {Function} [props.onClick] - Callback function when the item is clicked.
|
|
84
|
+
* @param {boolean} [props.selected] - Whether the item is selected.
|
|
85
|
+
* @param {React.ReactNode} props.children - The content inside the item.
|
|
86
|
+
* @param {string} [props.className] - Additional CSS classes for styling.
|
|
87
|
+
* @returns {JSX.Element} The rendered component.
|
|
88
|
+
*/ function Item() {
|
|
89
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
90
|
+
var id = props.id, accessibilityLabel = props.accessibilityLabel, onClick = props.onClick, selected = props.selected, children = props.children, className = props.className;
|
|
91
|
+
var classes = itemStyles({
|
|
92
|
+
selected: selected
|
|
93
|
+
});
|
|
94
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
95
|
+
id: id,
|
|
96
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
97
|
+
role: "button",
|
|
98
|
+
tabIndex: 0,
|
|
99
|
+
onClick: onClick,
|
|
100
|
+
"aria-label": accessibilityLabel,
|
|
101
|
+
children: children
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
ResourceList.Item = Item;
|
|
105
|
+
var _default = ResourceList;
|
|
@@ -0,0 +1,300 @@
|
|
|
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
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
15
|
+
var _Icon = /*#__PURE__*/ _interop_require_default(require("./Icon"));
|
|
16
|
+
var _Label = /*#__PURE__*/ _interop_require_default(require("./Label"));
|
|
17
|
+
var _Link = /*#__PURE__*/ _interop_require_default(require("./Link"));
|
|
18
|
+
var _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
19
|
+
var _polarisicons = require("@shopify/polaris-icons");
|
|
20
|
+
function _array_like_to_array(arr, len) {
|
|
21
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
22
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
23
|
+
return arr2;
|
|
24
|
+
}
|
|
25
|
+
function _array_with_holes(arr) {
|
|
26
|
+
if (Array.isArray(arr)) return arr;
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_default(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function _iterable_to_array_limit(arr, i) {
|
|
34
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
35
|
+
if (_i == null) return;
|
|
36
|
+
var _arr = [];
|
|
37
|
+
var _n = true;
|
|
38
|
+
var _d = false;
|
|
39
|
+
var _s, _e;
|
|
40
|
+
try {
|
|
41
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
42
|
+
_arr.push(_s.value);
|
|
43
|
+
if (i && _arr.length === i) break;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_d = true;
|
|
47
|
+
_e = err;
|
|
48
|
+
} finally{
|
|
49
|
+
try {
|
|
50
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
51
|
+
} finally{
|
|
52
|
+
if (_d) throw _e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _arr;
|
|
56
|
+
}
|
|
57
|
+
function _non_iterable_rest() {
|
|
58
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
59
|
+
}
|
|
60
|
+
function _sliced_to_array(arr, i) {
|
|
61
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
62
|
+
}
|
|
63
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
64
|
+
if (!o) return;
|
|
65
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
66
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
67
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
68
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
69
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
70
|
+
}
|
|
71
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
72
|
+
base: "Litho-Select relative border border-form-border rounded-md",
|
|
73
|
+
variants: {
|
|
74
|
+
disabled: {
|
|
75
|
+
false: ""
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
compoundVariants: [
|
|
79
|
+
{
|
|
80
|
+
focused: true,
|
|
81
|
+
hasError: false,
|
|
82
|
+
class: "ring ring-form-focus border-form-border-focus"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
focused: true,
|
|
86
|
+
hasError: true,
|
|
87
|
+
class: "ring ring-form-focus-error border-form-border-error"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
disabled: false,
|
|
91
|
+
focused: false,
|
|
92
|
+
class: "hover:border-form-border-hover"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
disabled: true,
|
|
96
|
+
hasError: true,
|
|
97
|
+
class: "bg-surface-higher"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
disabled: true,
|
|
101
|
+
hasError: false,
|
|
102
|
+
class: "bg-form-bg-disabled"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
disabled: false,
|
|
106
|
+
hasError: true,
|
|
107
|
+
class: "border-form-border-error focus:ring-form-focus-error bg-form-bg-error hover:border-form-border-error-hover"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
disabled: false,
|
|
111
|
+
hasError: false,
|
|
112
|
+
class: "bg-form-bg"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
var contentStyles = (0, _tailwindvariants.tv)({
|
|
117
|
+
base: "Litho-Select__Content min-h-7.5 pl-3 pr-2 flex items-center justify-between gap-2"
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* @function Select
|
|
121
|
+
* @description A dropdown component that allows users to select an option from a list.
|
|
122
|
+
* @param {Object} props - The properties for the Select component.
|
|
123
|
+
* @param {Array} props.options - Array of option objects for the select dropdown. Options can include groups.
|
|
124
|
+
* @param {string} [props.label] - Label for the select input.
|
|
125
|
+
* @param {Object} [props.labelAction] - An action object for the label. Includes `onAction` and `content`.
|
|
126
|
+
* @param {boolean} [props.labelHidden] - Whether to hide the label visually.
|
|
127
|
+
* @param {boolean} [props.labelInline] - Whether to display the label inline with the select.
|
|
128
|
+
* @param {boolean} [props.disabled=false] - Whether the select is disabled.
|
|
129
|
+
* @param {string} [props.helpText] - Optional help text displayed below the select.
|
|
130
|
+
* @param {string} [props.placeholder] - Placeholder text for the select input.
|
|
131
|
+
* @param {string} props.id - The ID for the select input.
|
|
132
|
+
* @param {string} props.name - The name for the select input.
|
|
133
|
+
* @param {string} props.value - The selected value.
|
|
134
|
+
* @param {React.ReactNode|import("./Tooltip").TooltipContentObject} props.tooltip - Tooltip content for the select.
|
|
135
|
+
* @param {string|boolean} [props.error] - Error message or flag indicating the select has an error.
|
|
136
|
+
* @param {function} props.onChange - Callback for when the selected value changes.
|
|
137
|
+
* @param {function} props.onFocus - Callback for when the select gains focus.
|
|
138
|
+
* @param {function} props.onBlur - Callback for when the select loses focus.
|
|
139
|
+
* @param {boolean} [props.requiredIndicator] - Whether to show a required indicator next to the label.
|
|
140
|
+
* @returns {JSX.Element} The rendered Select component.
|
|
141
|
+
*/ function Select() {
|
|
142
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
143
|
+
var options = props.options, label = props.label, tooltip = props.tooltip, labelAction = props.labelAction, labelHidden = props.labelHidden, labelInline = props.labelInline, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, helpText = props.helpText, placeholder = props.placeholder, id = props.id, name = props.name, value = props.value, error = props.error, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, requiredIndicator = props.requiredIndicator, className = props.className, contentClassName = props.contentClassName;
|
|
144
|
+
var _useState = _sliced_to_array((0, _react.useState)(false), 2), focused = _useState[0], setFocused = _useState[1];
|
|
145
|
+
var handleFocus = function(event) {
|
|
146
|
+
setFocused(true);
|
|
147
|
+
if (onFocus) {
|
|
148
|
+
onFocus(event);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var handleBlur = function(event) {
|
|
152
|
+
setFocused(false);
|
|
153
|
+
if (onBlur) {
|
|
154
|
+
onBlur(event);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var hasError = !!error;
|
|
158
|
+
var classes = styles({
|
|
159
|
+
disabled: disabled,
|
|
160
|
+
hasError: hasError,
|
|
161
|
+
focused: focused
|
|
162
|
+
});
|
|
163
|
+
var contentClasses = contentStyles();
|
|
164
|
+
var selectedOption = options.reduce(function(found, option) {
|
|
165
|
+
if (found) return found;
|
|
166
|
+
if (option.options) {
|
|
167
|
+
return option.options.find(function(subOption) {
|
|
168
|
+
return subOption.value === value;
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
return option.value === value ? option : null;
|
|
172
|
+
}
|
|
173
|
+
}, null);
|
|
174
|
+
var firstOption = options.reduce(function(found, option) {
|
|
175
|
+
if (found) return found;
|
|
176
|
+
if (option.options) {
|
|
177
|
+
return option.options[0];
|
|
178
|
+
} else {
|
|
179
|
+
return option;
|
|
180
|
+
}
|
|
181
|
+
}, null);
|
|
182
|
+
var handleContentClick = function(e) {
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
var selectElement = e.currentTarget.previousElementSibling;
|
|
185
|
+
selectElement === null || selectElement === void 0 ? void 0 : selectElement.focus();
|
|
186
|
+
selectElement === null || selectElement === void 0 ? void 0 : selectElement.click();
|
|
187
|
+
};
|
|
188
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
189
|
+
className: "Litho-SelectContainer flex flex-col gap-1",
|
|
190
|
+
children: [
|
|
191
|
+
label && !labelHidden && !labelInline && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
192
|
+
className: "flex justify-between items-end",
|
|
193
|
+
children: [
|
|
194
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.default, {
|
|
195
|
+
id: id,
|
|
196
|
+
hidden: labelHidden,
|
|
197
|
+
disabled: disabled,
|
|
198
|
+
requiredIndicator: requiredIndicator,
|
|
199
|
+
tooltip: tooltip,
|
|
200
|
+
children: label
|
|
201
|
+
}),
|
|
202
|
+
labelAction && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Link.default, {
|
|
203
|
+
onClick: labelAction.onAction,
|
|
204
|
+
removeUnderline: true,
|
|
205
|
+
children: labelAction.content
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
210
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
211
|
+
children: [
|
|
212
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("select", {
|
|
213
|
+
className: "Litho-Select__Input opacity-0 absolute inset-0",
|
|
214
|
+
name: name,
|
|
215
|
+
id: id,
|
|
216
|
+
value: value || "",
|
|
217
|
+
onChange: function(e) {
|
|
218
|
+
return onChange(e.target.value);
|
|
219
|
+
},
|
|
220
|
+
onFocus: handleFocus,
|
|
221
|
+
onBlur: handleBlur,
|
|
222
|
+
placeholder: placeholder,
|
|
223
|
+
disabled: disabled,
|
|
224
|
+
children: [
|
|
225
|
+
placeholder && /*#__PURE__*/ (0, _jsxruntime.jsx)("option", {
|
|
226
|
+
value: "",
|
|
227
|
+
disabled: focused,
|
|
228
|
+
children: placeholder
|
|
229
|
+
}),
|
|
230
|
+
options.map(function(option) {
|
|
231
|
+
if (option.options) {
|
|
232
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("optgroup", {
|
|
233
|
+
label: option.title,
|
|
234
|
+
children: option.options.map(function(subOption) {
|
|
235
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("option", {
|
|
236
|
+
value: subOption.value,
|
|
237
|
+
disabled: subOption.disabled,
|
|
238
|
+
children: subOption.label
|
|
239
|
+
}, subOption.value);
|
|
240
|
+
})
|
|
241
|
+
}, option.title);
|
|
242
|
+
} else {
|
|
243
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("option", {
|
|
244
|
+
value: option.value,
|
|
245
|
+
disabled: option.disabled,
|
|
246
|
+
children: option.label
|
|
247
|
+
}, option.value);
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
}),
|
|
252
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
253
|
+
className: "".concat(contentClasses).concat(contentClassName ? " ".concat(contentClassName) : ""),
|
|
254
|
+
onClick: handleContentClick,
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
257
|
+
className: "flex gap-2",
|
|
258
|
+
children: [
|
|
259
|
+
label && !labelHidden && labelInline && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
260
|
+
color: disabled ? "disabled" : "subdued",
|
|
261
|
+
className: "line-clamp-1!",
|
|
262
|
+
children: label
|
|
263
|
+
}),
|
|
264
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
265
|
+
color: disabled ? "disabled" : "default",
|
|
266
|
+
className: "line-clamp-1!",
|
|
267
|
+
children: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || placeholder || (firstOption === null || firstOption === void 0 ? void 0 : firstOption.label)
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
}),
|
|
271
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Icon.default, {
|
|
272
|
+
source: _polarisicons.CaretDownMinor,
|
|
273
|
+
color: disabled ? "disabled" : "subdued",
|
|
274
|
+
className: "pointer-events-none"
|
|
275
|
+
})
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
}),
|
|
280
|
+
error && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
281
|
+
className: "flex gap-2",
|
|
282
|
+
children: [
|
|
283
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Icon.default, {
|
|
284
|
+
source: _polarisicons.CircleAlertMajor,
|
|
285
|
+
color: "critical"
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
288
|
+
color: "critical",
|
|
289
|
+
children: error
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
}),
|
|
293
|
+
helpText && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
294
|
+
color: "subdued",
|
|
295
|
+
children: helpText
|
|
296
|
+
})
|
|
297
|
+
]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
var _default = Select;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
15
|
+
base: "Litho-SkeletonText flex flex-col",
|
|
16
|
+
variants: {
|
|
17
|
+
gap: {
|
|
18
|
+
small: "gap-2",
|
|
19
|
+
medium: "gap-3",
|
|
20
|
+
large: "gap-4"
|
|
21
|
+
},
|
|
22
|
+
align: {
|
|
23
|
+
start: "items-start",
|
|
24
|
+
center: "items-center",
|
|
25
|
+
end: "items-end"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var lineStyles = (0, _tailwindvariants.tv)({
|
|
30
|
+
base: "Litho-SkeletonText__Line rounded-sm bg-tint-4 dark:bg-tint-alt-4",
|
|
31
|
+
variants: {
|
|
32
|
+
type: {
|
|
33
|
+
body: "h-3"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
compoundVariants: [
|
|
37
|
+
{
|
|
38
|
+
type: "body",
|
|
39
|
+
size: "md",
|
|
40
|
+
class: "h-3"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "body",
|
|
44
|
+
size: "lg",
|
|
45
|
+
class: "h-4"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "body",
|
|
49
|
+
size: "xl",
|
|
50
|
+
class: "h-5"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "heading",
|
|
54
|
+
size: "xs",
|
|
55
|
+
class: "h-5"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "heading",
|
|
59
|
+
size: "sm",
|
|
60
|
+
class: "h-7"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "heading",
|
|
64
|
+
size: "md",
|
|
65
|
+
class: "h-8"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "heading",
|
|
69
|
+
size: "lg",
|
|
70
|
+
class: "h-9"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* SkeletonText component for displaying placeholder text content.
|
|
76
|
+
*
|
|
77
|
+
* @param {Object} props - The component properties.
|
|
78
|
+
* @param {number} [props.lines=3] - The number of lines to render. Defaults to 3 for body text.
|
|
79
|
+
* @param {"body"|"heading"} [props.type="body"] - The type of skeleton text
|
|
80
|
+
* @param {"xs"|"sm"|"md"|"lg"|"xl"} [props.size="md"] - The size of the skeleton text
|
|
81
|
+
* @param {number} [props.width] - The width of the skeleton text lines. If not provided, random widths are generated.
|
|
82
|
+
* @param {boolean} [props.fullWidth=false] - Whether the skeleton text lines should be full width.
|
|
83
|
+
* @param {"start"|"center"|"end"} [props.align="start"] - The alignment of the skeleton text lines.
|
|
84
|
+
* @param {string} [props.className] - Additional class names to apply to the root element.
|
|
85
|
+
*
|
|
86
|
+
* @returns {JSX.Element} A JSX element rendering a skeleton placeholder text block.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* <SkeletonText lines={5} type="heading" size="lg" width={80} className="custom-class" />
|
|
90
|
+
*/ function SkeletonText() {
|
|
91
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
92
|
+
var tmp = props.lines, _lines = tmp === void 0 ? 3 : tmp, _props_type = props.type, type = _props_type === void 0 ? "body" : _props_type, _props_size = props.size, size = _props_size === void 0 ? "md" : _props_size, _width = props.width, _props_fullWidth = props.fullWidth, fullWidth = _props_fullWidth === void 0 ? false : _props_fullWidth, className = props.className, _props_gap = props.gap, gap = _props_gap === void 0 ? "medium" : _props_gap, _props_align = props.align, align = _props_align === void 0 ? "start" : _props_align;
|
|
93
|
+
var lines = type === "heading" ? 1 : _lines;
|
|
94
|
+
var classes = styles({
|
|
95
|
+
lines: lines,
|
|
96
|
+
type: type,
|
|
97
|
+
size: size,
|
|
98
|
+
gap: gap,
|
|
99
|
+
align: align
|
|
100
|
+
});
|
|
101
|
+
var lineClasses = lineStyles({
|
|
102
|
+
type: type,
|
|
103
|
+
size: size
|
|
104
|
+
});
|
|
105
|
+
var randomWidths = (0, _react.useMemo)(function() {
|
|
106
|
+
return Array.from({
|
|
107
|
+
length: lines
|
|
108
|
+
}, function() {
|
|
109
|
+
return Math.floor(Math.random() * (70 - 40 + 1)) + 40;
|
|
110
|
+
});
|
|
111
|
+
}, [
|
|
112
|
+
lines
|
|
113
|
+
]);
|
|
114
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
115
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
116
|
+
children: Array.from({
|
|
117
|
+
length: lines
|
|
118
|
+
}, function(_, i) {
|
|
119
|
+
var lastLine = i === lines - 1;
|
|
120
|
+
var width = _width || ((type === "heading" || lastLine) && !fullWidth ? "".concat(randomWidths[i], "%") : "100%");
|
|
121
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
122
|
+
className: lineClasses,
|
|
123
|
+
style: {
|
|
124
|
+
width: width
|
|
125
|
+
}
|
|
126
|
+
}, i);
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
var _default = SkeletonText;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
13
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
14
|
+
base: "Litho-Spinner",
|
|
15
|
+
variants: {
|
|
16
|
+
size: {
|
|
17
|
+
small: "w-4 h-4",
|
|
18
|
+
medium: "w-5 h-5",
|
|
19
|
+
large: "w-7 h-7"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var svgStyles = (0, _tailwindvariants.tv)({
|
|
24
|
+
base: "Litho-Spinner__Svg animate-spin-fast",
|
|
25
|
+
variants: {
|
|
26
|
+
color: {
|
|
27
|
+
default: "fill-brand",
|
|
28
|
+
subdued: "fill-tint-10"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Spinner Component
|
|
34
|
+
*
|
|
35
|
+
* This component renders a loading spinner with customizable size, color, and accessibility label.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} props - The props object.
|
|
38
|
+
* @param {('small'|'large')} [props.size='large'] - The size of the spinner, either "small" or "large".
|
|
39
|
+
* @param {('default'|'subdued')} [props.color='default'] - The color variant of the spinner.
|
|
40
|
+
* @param {string} [props.accessibilityLabel='Loading...'] - The accessible label for screen readers, describing the spinner's purpose.
|
|
41
|
+
* @returns {JSX.Element} The rendered Spinner component.
|
|
42
|
+
*/ function Spinner() {
|
|
43
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
44
|
+
var _props_size = props.size, size = _props_size === void 0 ? "large" : _props_size, _props_color = props.color, color = _props_color === void 0 ? "default" : _props_color, _props_accessibilityLabel = props.accessibilityLabel, accessibilityLabel = _props_accessibilityLabel === void 0 ? "Loading..." : _props_accessibilityLabel;
|
|
45
|
+
var classes = styles({
|
|
46
|
+
size: size
|
|
47
|
+
});
|
|
48
|
+
var svgClasses = svgStyles({
|
|
49
|
+
color: color
|
|
50
|
+
});
|
|
51
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
52
|
+
className: classes,
|
|
53
|
+
"aria-label": accessibilityLabel,
|
|
54
|
+
role: "status",
|
|
55
|
+
children: size === 'large' ? /*#__PURE__*/ (0, _jsxruntime.jsx)("svg", {
|
|
56
|
+
className: svgClasses,
|
|
57
|
+
viewBox: "0 0 44 44",
|
|
58
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
59
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("path", {
|
|
60
|
+
d: "M15.542 1.487A21.507 21.507 0 00.5 22c0 11.874 9.626 21.5 21.5 21.5 9.847 0 18.364-6.675 20.809-16.072a1.5 1.5 0 00-2.904-.756C37.803 34.755 30.473 40.5 22 40.5 11.783 40.5 3.5 32.217 3.5 22c0-8.137 5.3-15.247 12.942-17.65a1.5 1.5 0 10-.9-2.863z"
|
|
61
|
+
})
|
|
62
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)("svg", {
|
|
63
|
+
className: svgClasses,
|
|
64
|
+
viewBox: "0 0 20 20",
|
|
65
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("path", {
|
|
67
|
+
d: "M7.229 1.173a9.25 9.25 0 1011.655 11.412 1.25 1.25 0 10-2.4-.698 6.75 6.75 0 11-8.506-8.329 1.25 1.25 0 10-.75-2.385z"
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var _default = Spinner;
|