@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,175 @@
|
|
|
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 _polarisicons = require("@shopify/polaris-icons");
|
|
15
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
16
|
+
base: "Litho-Checkbox group flex gap-2 py-1",
|
|
17
|
+
variants: {
|
|
18
|
+
disabled: {
|
|
19
|
+
false: "cursor-pointer"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var checkboxStyles = (0, _tailwindvariants.tv)({
|
|
24
|
+
base: "Litho-Checkbox__Control w-4.5 h-4.5 pt-px rounded-sm border flex items-center justify-center",
|
|
25
|
+
variants: {
|
|
26
|
+
disabled: {
|
|
27
|
+
true: "bg-form-bg-disabled border-form-border"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
compoundVariants: [
|
|
31
|
+
{
|
|
32
|
+
hasError: true,
|
|
33
|
+
disabled: false,
|
|
34
|
+
checked: false,
|
|
35
|
+
class: "bg-form-bg-error border-form-border-error hover:bg-form-bg-error-low hover:ring hover:ring-form-focus-error"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
hasError: true,
|
|
39
|
+
disabled: false,
|
|
40
|
+
checked: true,
|
|
41
|
+
class: "bg-critical border-form-border-error hover:ring hover:ring-form-focus-error"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
hasError: false,
|
|
45
|
+
disabled: false,
|
|
46
|
+
checked: false,
|
|
47
|
+
class: "bg-form-bg border-form-border hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
hasError: false,
|
|
51
|
+
disabled: false,
|
|
52
|
+
checked: true,
|
|
53
|
+
class: "bg-form-accent border-form-border-focus hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Checkbox Component
|
|
59
|
+
*
|
|
60
|
+
* A custom checkbox component with support for labels, help text, and extensive styling using Tailwind Variants (tv).
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
*
|
|
64
|
+
* @param {Object} props - Props for the Checkbox component.
|
|
65
|
+
* @param {string} [props.label] - The text label for the checkbox.
|
|
66
|
+
* @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it available for screen readers.
|
|
67
|
+
* @param {string} [props.id] - The unique identifier for the checkbox input.
|
|
68
|
+
* @param {string} [props.name] - The name attribute for the checkbox input.
|
|
69
|
+
* @param {string} [props.value] - The value attribute for the checkbox input.
|
|
70
|
+
* @param {string} [props.error] - An error message associated with the checkbox, if any.
|
|
71
|
+
* @param {boolean} [props.checked=false] - Indicates whether the checkbox is checked.
|
|
72
|
+
* @param {boolean} [props.disabled=false] - Indicates whether the checkbox is disabled.
|
|
73
|
+
* @param {string} [props.helpText] - Additional descriptive text for the checkbox.
|
|
74
|
+
* @param {function} [props.onChange] - Callback function called when the checkbox state changes.
|
|
75
|
+
* @param {function} [props.onFocus] - Callback function called when the checkbox gains focus.
|
|
76
|
+
* @param {function} [props.onBlur] - Callback function called when the checkbox loses focus.
|
|
77
|
+
*
|
|
78
|
+
* @returns {JSX.Element} The rendered Checkbox component.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* <Checkbox
|
|
82
|
+
* label="Accept Terms"
|
|
83
|
+
* id="accept-terms"
|
|
84
|
+
* name="terms"
|
|
85
|
+
* checked={true}
|
|
86
|
+
* disabled={false}
|
|
87
|
+
* helpText="You must accept the terms to proceed."
|
|
88
|
+
* onChange={(e) => console.log('Checkbox changed:', e.target.checked)}
|
|
89
|
+
* />
|
|
90
|
+
*/ function Checkbox() {
|
|
91
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
92
|
+
var label = props.label, tooltip = props.tooltip, labelHidden = props.labelHidden, id = props.id, name = props.name, value = props.value, error = props.error, tmp = props.checked, _checked = tmp === void 0 ? false : tmp, _props_indeterminate = props.indeterminate, indeterminate = _props_indeterminate === void 0 ? false : _props_indeterminate, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, helpText = props.helpText, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, className = props.className;
|
|
93
|
+
var checked = !!_checked;
|
|
94
|
+
var hasError = !!error;
|
|
95
|
+
var classes = styles({
|
|
96
|
+
disabled: disabled
|
|
97
|
+
});
|
|
98
|
+
var checkboxClasses = checkboxStyles({
|
|
99
|
+
checked: checked || indeterminate,
|
|
100
|
+
disabled: disabled,
|
|
101
|
+
hasError: hasError
|
|
102
|
+
});
|
|
103
|
+
var handleChange = function() {
|
|
104
|
+
if (onChange) {
|
|
105
|
+
onChange(!checked);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var handleFocus = function(event) {
|
|
109
|
+
if (onFocus) {
|
|
110
|
+
onFocus(event);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var handleBlur = function(event) {
|
|
114
|
+
if (onBlur) {
|
|
115
|
+
onBlur(event);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
119
|
+
className: "Litho-CheckboxContainer flex flex-col gap-0",
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("label", {
|
|
122
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
125
|
+
type: "checkbox",
|
|
126
|
+
id: id,
|
|
127
|
+
name: name,
|
|
128
|
+
value: value,
|
|
129
|
+
checked: checked,
|
|
130
|
+
disabled: disabled,
|
|
131
|
+
onChange: handleChange,
|
|
132
|
+
onFocus: handleFocus,
|
|
133
|
+
onBlur: handleBlur,
|
|
134
|
+
className: "Litho-Checkbox__Input sr-only"
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
137
|
+
className: "Litho-Checkbox__ControlContainer w-5 h-5 flex items-center justify-center",
|
|
138
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
139
|
+
className: checkboxClasses,
|
|
140
|
+
children: [
|
|
141
|
+
checked && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
142
|
+
color: disabled ? "inputFgDisabled" : hasError ? "white" : "inputFg",
|
|
143
|
+
source: _polarisicons.TickMinor,
|
|
144
|
+
className: "pointer-events-none"
|
|
145
|
+
}),
|
|
146
|
+
!checked && indeterminate && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
147
|
+
color: disabled ? "inputFgDisabled" : hasError ? "white" : "inputFg",
|
|
148
|
+
source: _polarisicons.MinusMajor,
|
|
149
|
+
className: "pointer-events-none"
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
}),
|
|
154
|
+
label && !labelHidden && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Label, {
|
|
155
|
+
tooltip: tooltip,
|
|
156
|
+
disabled: disabled,
|
|
157
|
+
as: "p",
|
|
158
|
+
children: label
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
helpText && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
163
|
+
color: "subdued",
|
|
164
|
+
className: "pl-7",
|
|
165
|
+
children: helpText
|
|
166
|
+
}),
|
|
167
|
+
error && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
168
|
+
color: "critical",
|
|
169
|
+
className: "pl-7",
|
|
170
|
+
children: error
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
var _default = Checkbox;
|
|
@@ -0,0 +1,160 @@
|
|
|
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 _Checkbox = /*#__PURE__*/ _interop_require_default(require("./Checkbox"));
|
|
14
|
+
var _Icon = /*#__PURE__*/ _interop_require_default(require("./Icon"));
|
|
15
|
+
var _Label = /*#__PURE__*/ _interop_require_default(require("./Label"));
|
|
16
|
+
var _RadioButton = /*#__PURE__*/ _interop_require_default(require("./RadioButton"));
|
|
17
|
+
var _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
18
|
+
var _VerticalStack = /*#__PURE__*/ _interop_require_default(require("./VerticalStack"));
|
|
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_without_holes(arr) {
|
|
26
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_default(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function _iterable_to_array(iter) {
|
|
34
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
35
|
+
}
|
|
36
|
+
function _non_iterable_spread() {
|
|
37
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38
|
+
}
|
|
39
|
+
function _to_consumable_array(arr) {
|
|
40
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
41
|
+
}
|
|
42
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
43
|
+
if (!o) return;
|
|
44
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
45
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
46
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
47
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
48
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
49
|
+
}
|
|
50
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
51
|
+
base: "Litho-ChoiceList flex flex-col gap-1"
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* A ChoiceList component for rendering a list of selectable options.
|
|
55
|
+
*
|
|
56
|
+
* @component
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} props - The properties object.
|
|
59
|
+
* @param {string} [props.title] - The title of the choice list.
|
|
60
|
+
* @param {boolean} [props.titleHidden=false] - Whether to hide the title visually.
|
|
61
|
+
* @param {boolean} [props.allowMultiple=false] - Whether multiple selections are allowed.
|
|
62
|
+
* @param {Array} props.choices - The available choices for selection.
|
|
63
|
+
* @param {string} props.choices[].value - The value of the choice.
|
|
64
|
+
* @param {string} props.choices[].label - The display label of the choice.
|
|
65
|
+
* @param {boolean} [props.choices[].disabled=false] - Whether the choice is disabled.
|
|
66
|
+
* @param {Array} props.selected - The currently selected values.
|
|
67
|
+
* @param {Function} props.onChange - Callback when the selection changes. Receives the updated array of selected values.
|
|
68
|
+
* @param {string} [props.error] - Error message to display, if any.
|
|
69
|
+
* @param {boolean} [props.disabled=false] - Whether the entire choice list is disabled.
|
|
70
|
+
* @param {string} [props.name] - The name attribute for the choice inputs (used for grouping radio buttons).
|
|
71
|
+
*
|
|
72
|
+
* @returns {JSX.Element} A rendered choice list component.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* <ChoiceList
|
|
76
|
+
* title="Select your options"
|
|
77
|
+
* allowMultiple={true}
|
|
78
|
+
* choices={[
|
|
79
|
+
* { value: "option1", label: "Option 1" },
|
|
80
|
+
* { value: "option2", label: "Option 2" },
|
|
81
|
+
* ]}
|
|
82
|
+
* selected={["option1"]}
|
|
83
|
+
* onChange={(selected) => console.log(selected)}
|
|
84
|
+
* error="Please select at least one option."
|
|
85
|
+
* />
|
|
86
|
+
*/ function ChoiceList() {
|
|
87
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
88
|
+
var title = props.title, tooltip = props.tooltip, titleHidden = props.titleHidden, allowMultiple = props.allowMultiple, choices = props.choices, selected = props.selected, onChange = props.onChange, error = props.error, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, name = props.name;
|
|
89
|
+
var classes = styles();
|
|
90
|
+
var ControlElement = allowMultiple ? _Checkbox.default : _RadioButton.default;
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
92
|
+
className: classes,
|
|
93
|
+
children: [
|
|
94
|
+
title && !titleHidden && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.default, {
|
|
95
|
+
as: "p",
|
|
96
|
+
tooltip: tooltip,
|
|
97
|
+
children: title
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_VerticalStack.default, {
|
|
100
|
+
children: choices.map(function(choice, index) {
|
|
101
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(ControlElement, {
|
|
104
|
+
label: choice.label,
|
|
105
|
+
tooltip: choice.tooltip,
|
|
106
|
+
value: choice.value,
|
|
107
|
+
disabled: choice.disabled || disabled,
|
|
108
|
+
name: name,
|
|
109
|
+
helpText: choice.helpText,
|
|
110
|
+
checked: selected.includes(choice.value),
|
|
111
|
+
onChange: function() {
|
|
112
|
+
if (allowMultiple) {
|
|
113
|
+
if (selected.includes(choice.value)) {
|
|
114
|
+
onChange(selected.filter(function(value) {
|
|
115
|
+
return value !== choice.value;
|
|
116
|
+
}));
|
|
117
|
+
} else {
|
|
118
|
+
if (typeof selected === "string") {
|
|
119
|
+
onChange([
|
|
120
|
+
selected,
|
|
121
|
+
choice.value
|
|
122
|
+
]);
|
|
123
|
+
} else {
|
|
124
|
+
onChange(_to_consumable_array(selected).concat([
|
|
125
|
+
choice.value
|
|
126
|
+
]));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
onChange([
|
|
131
|
+
choice.value
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
choice.renderChildren && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
137
|
+
className: "pl-7",
|
|
138
|
+
children: choice.renderChildren()
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}, index);
|
|
142
|
+
})
|
|
143
|
+
}),
|
|
144
|
+
error && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
145
|
+
className: "flex gap-2",
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Icon.default, {
|
|
148
|
+
source: _polarisicons.CircleAlertMajor,
|
|
149
|
+
color: "critical"
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
152
|
+
color: "critical",
|
|
153
|
+
children: error
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
var _default = ChoiceList;
|
|
@@ -0,0 +1,42 @@
|
|
|
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-Collapsible",
|
|
15
|
+
variants: {
|
|
16
|
+
open: {
|
|
17
|
+
true: "max-h-screen",
|
|
18
|
+
false: "max-h-0 overflow-hidden"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Collapsible Component
|
|
24
|
+
*
|
|
25
|
+
* @component
|
|
26
|
+
* @param {Object} props - Properties passed to component.
|
|
27
|
+
* @param {boolean} props.open - If true, the collapsible is open (expanded); otherwise, it's closed (collapsed).
|
|
28
|
+
* @param {React.ReactNode} props.children - Content displayed inside the collapsible component.
|
|
29
|
+
* @param {string} [props.className] - Additional CSS classes to append to the generated styles.
|
|
30
|
+
* @returns {JSX.Element} A collapsible container that shows or hides its children based on the `open` state.
|
|
31
|
+
*/ function Collapsible() {
|
|
32
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
33
|
+
var open = props.open, children = props.children, className = props.className;
|
|
34
|
+
var classes = styles({
|
|
35
|
+
open: open
|
|
36
|
+
});
|
|
37
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
38
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var _default = Collapsible;
|
|
@@ -0,0 +1,159 @@
|
|
|
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 _reactcolor = require("react-color");
|
|
15
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
16
|
+
var _index = require("../index");
|
|
17
|
+
function _array_like_to_array(arr, len) {
|
|
18
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
20
|
+
return arr2;
|
|
21
|
+
}
|
|
22
|
+
function _array_with_holes(arr) {
|
|
23
|
+
if (Array.isArray(arr)) return arr;
|
|
24
|
+
}
|
|
25
|
+
function _iterable_to_array_limit(arr, i) {
|
|
26
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
+
if (_i == null) return;
|
|
28
|
+
var _arr = [];
|
|
29
|
+
var _n = true;
|
|
30
|
+
var _d = false;
|
|
31
|
+
var _s, _e;
|
|
32
|
+
try {
|
|
33
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
34
|
+
_arr.push(_s.value);
|
|
35
|
+
if (i && _arr.length === i) break;
|
|
36
|
+
}
|
|
37
|
+
} catch (err) {
|
|
38
|
+
_d = true;
|
|
39
|
+
_e = err;
|
|
40
|
+
} finally{
|
|
41
|
+
try {
|
|
42
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
43
|
+
} finally{
|
|
44
|
+
if (_d) throw _e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return _arr;
|
|
48
|
+
}
|
|
49
|
+
function _non_iterable_rest() {
|
|
50
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
51
|
+
}
|
|
52
|
+
function _sliced_to_array(arr, i) {
|
|
53
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
54
|
+
}
|
|
55
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
56
|
+
if (!o) return;
|
|
57
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
58
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
59
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
60
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
61
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
62
|
+
}
|
|
63
|
+
var colorContainer = (0, _tailwindvariants.tv)({
|
|
64
|
+
base: "Litho-ColorField relative flex items-center gap-2 cursor-pointer px-1 py-1 rounded-md w-full-plus-2 -left-1",
|
|
65
|
+
variants: {
|
|
66
|
+
hoverable: {
|
|
67
|
+
true: "hover"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
var colorCell = (0, _tailwindvariants.tv)({
|
|
72
|
+
base: "w-8 h-8 min-w-8 min-h-8 rounded-md border border-tint-5"
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* ColorField component provides a UI for selecting colors using the SketchPicker.
|
|
76
|
+
* It displays the currently selected color and allows toggling a color picker popover.
|
|
77
|
+
* Useful for choosing solid colors in forms or design tools.
|
|
78
|
+
*
|
|
79
|
+
* @component
|
|
80
|
+
* @example
|
|
81
|
+
* <ColorField
|
|
82
|
+
* label="Primary Color"
|
|
83
|
+
* name="primary"
|
|
84
|
+
* value="#ff0000"
|
|
85
|
+
* onChange={(newColor) => setColor(newColor)}
|
|
86
|
+
* zIndexOverride={100}
|
|
87
|
+
* presetColors={['#ff0000', '#00ff00', '#0000ff']}
|
|
88
|
+
* />
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} props - Component props
|
|
91
|
+
* @param {string} props.label - The label displayed above the color value
|
|
92
|
+
* @param {string} props.name - The name associated with the color field, used as a key
|
|
93
|
+
* @param {string} props.value - The currently selected color value; can be a hex string or CSS variable
|
|
94
|
+
* @param {function} props.onChange - Callback function that receives the new color value when changed
|
|
95
|
+
* @param {number} [props.zIndexOverride] - Optional z-index value to override the default popover z-index
|
|
96
|
+
* @param {string[]} [props.presetColors=[]] - Optional array of preset colors shown in the picker
|
|
97
|
+
*
|
|
98
|
+
* @returns {JSX.Element} A color picker field with label and current value preview
|
|
99
|
+
*/ var ColorField = function(param) {
|
|
100
|
+
var label = param.label, name = param.name, _value = param.value, onChange = param.onChange, zIndexOverride = param.zIndexOverride, _param_presetColors = param.presetColors, presetColors = _param_presetColors === void 0 ? [] : _param_presetColors;
|
|
101
|
+
var value = _value.startsWith("var(--") ? getComputedStyle(document.documentElement).getPropertyValue(_value.replace("var(", "").replace(")", "")).trim() : _value;
|
|
102
|
+
var _useState = _sliced_to_array((0, _react.useState)(false), 2), displayColorPicker = _useState[0], setDisplayColorPicker = _useState[1];
|
|
103
|
+
var toggleDisplayColorPicker = function() {
|
|
104
|
+
return setDisplayColorPicker(!displayColorPicker);
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
107
|
+
className: colorContainer({
|
|
108
|
+
hoverable: true
|
|
109
|
+
}),
|
|
110
|
+
onClick: function() {
|
|
111
|
+
if (!displayColorPicker) {
|
|
112
|
+
toggleDisplayColorPicker();
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
117
|
+
className: colorCell(),
|
|
118
|
+
style: {
|
|
119
|
+
backgroundColor: value
|
|
120
|
+
},
|
|
121
|
+
onClick: toggleDisplayColorPicker
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
124
|
+
className: "flex flex-col gap-0",
|
|
125
|
+
children: [
|
|
126
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
127
|
+
variant: "bodySm",
|
|
128
|
+
children: label
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
131
|
+
variant: "bodySm",
|
|
132
|
+
color: "subdued",
|
|
133
|
+
children: value ? value.toUpperCase() : value
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}),
|
|
137
|
+
displayColorPicker && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
138
|
+
className: "Litho-ColorField__Activator fixed inset-0",
|
|
139
|
+
onClick: toggleDisplayColorPicker
|
|
140
|
+
}),
|
|
141
|
+
displayColorPicker && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
142
|
+
className: "Litho-ColorField__Popover absolute z-10 left-0 top-0",
|
|
143
|
+
style: zIndexOverride ? {
|
|
144
|
+
zIndex: zIndexOverride
|
|
145
|
+
} : {},
|
|
146
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactcolor.SketchPicker, {
|
|
147
|
+
color: value,
|
|
148
|
+
onChange: function(param) {
|
|
149
|
+
var hex = param.hex;
|
|
150
|
+
return onChange(hex);
|
|
151
|
+
},
|
|
152
|
+
disableAlpha: true,
|
|
153
|
+
presetColors: presetColors
|
|
154
|
+
}, name)
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
var _default = ColorField;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 _react = require("react");
|
|
13
|
+
var _AppProvider = require("../components/AppProvider");
|
|
14
|
+
/**
|
|
15
|
+
* ContextualSaveBar Component
|
|
16
|
+
*
|
|
17
|
+
* This component manages and displays a global contextual save bar with custom save and discard actions.
|
|
18
|
+
* It uses the `FormContext` to control the visibility and configuration of the save bar.
|
|
19
|
+
* When mounted, it sets the provided message, save action, and discard action.
|
|
20
|
+
* When unmounted, it cleans up by resetting these values.
|
|
21
|
+
*
|
|
22
|
+
* @component
|
|
23
|
+
* @param {Object} props - Component properties.
|
|
24
|
+
* @param {Object} [props.saveAction] - The action for the "Save" button. Contains `onAction`, `loading`, `accessibilityLabel`, and `disabled`.
|
|
25
|
+
* @param {Object} [props.discardAction] - The action for the "Discard" button. Contains `onAction`, `loading`, `accessibilityLabel`, and `disabled`.
|
|
26
|
+
* @param {string} [props.message="Unsaved changes"] - The message to display on the contextual save bar.
|
|
27
|
+
* @returns {null} This component does not render anything; it only manages the save bar state.
|
|
28
|
+
*/ function ContextualSaveBar(param) {
|
|
29
|
+
var saveAction = param.saveAction, discardAction = param.discardAction, _param_message = param.message, message = _param_message === void 0 ? "Unsaved changes" : _param_message;
|
|
30
|
+
var _useContext = (0, _react.useContext)(_AppProvider.FormContext), setShowGlobalContextualSaveBar = _useContext.setShowGlobalContextualSaveBar, setMessage = _useContext.setMessage, setSaveAction = _useContext.setSaveAction, setDiscardAction = _useContext.setDiscardAction;
|
|
31
|
+
(0, _react.useEffect)(function() {
|
|
32
|
+
setSaveAction(saveAction);
|
|
33
|
+
setDiscardAction(discardAction);
|
|
34
|
+
setMessage(message);
|
|
35
|
+
setShowGlobalContextualSaveBar(true);
|
|
36
|
+
return function() {
|
|
37
|
+
setShowGlobalContextualSaveBar(false);
|
|
38
|
+
setMessage(null);
|
|
39
|
+
setSaveAction(null);
|
|
40
|
+
setDiscardAction(null);
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
setShowGlobalContextualSaveBar,
|
|
44
|
+
setMessage,
|
|
45
|
+
setSaveAction,
|
|
46
|
+
setDiscardAction,
|
|
47
|
+
message,
|
|
48
|
+
saveAction,
|
|
49
|
+
discardAction
|
|
50
|
+
]);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
var _default = ContextualSaveBar;
|