@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,172 @@
|
|
|
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 _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
14
|
+
var _Label = /*#__PURE__*/ _interop_require_default(require("./Label"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
21
|
+
base: "Litho-RadioButton group flex gap-2",
|
|
22
|
+
variants: {
|
|
23
|
+
disabled: {
|
|
24
|
+
false: "cursor-pointer"
|
|
25
|
+
},
|
|
26
|
+
alignItems: {
|
|
27
|
+
stretch: "items-stretch",
|
|
28
|
+
center: "items-center"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
alignItems: "stretch"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var radioStyles = (0, _tailwindvariants.tv)({
|
|
36
|
+
base: "Litho-RadioButton__Control w-4.5 h-4.5 rounded-full border border-form-border flex items-center justify-center",
|
|
37
|
+
variants: {
|
|
38
|
+
disabled: {
|
|
39
|
+
true: "bg-form-bg-disabled border-form-border"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
{
|
|
44
|
+
hasError: true,
|
|
45
|
+
disabled: false,
|
|
46
|
+
checked: false,
|
|
47
|
+
class: "bg-form-bg-error border-form-border-error hover:bg-form-bg-error-low hover:ring hover:ring-form-focus-error"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
hasError: true,
|
|
51
|
+
disabled: false,
|
|
52
|
+
checked: true,
|
|
53
|
+
class: "bg-critical border-form-border-error hover:ring hover:ring-form-focus-error"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
hasError: false,
|
|
57
|
+
disabled: false,
|
|
58
|
+
checked: false,
|
|
59
|
+
class: "bg-form-bg border-form-border hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
hasError: false,
|
|
63
|
+
disabled: false,
|
|
64
|
+
checked: true,
|
|
65
|
+
class: "bg-form-accent border-form-border-focus hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* RadioButton Component
|
|
71
|
+
*
|
|
72
|
+
* A custom radio button component with support for labels, help text, and extensive styling using Tailwind Variants (tv).
|
|
73
|
+
*
|
|
74
|
+
* @component
|
|
75
|
+
*
|
|
76
|
+
* @param {Object} props - Props for the RadioButton component.
|
|
77
|
+
* @param {string} [props.label] - The text label for the radio button.
|
|
78
|
+
* @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it available for screen readers.
|
|
79
|
+
* @param {string} [props.id] - The unique identifier for the radio input.
|
|
80
|
+
* @param {string} [props.name] - The name attribute for the radio input (must be the same for grouped buttons).
|
|
81
|
+
* @param {string} [props.value] - The value attribute for the radio input.
|
|
82
|
+
* @param {string} [props.error] - An error message associated with the radio button, if any.
|
|
83
|
+
* @param {boolean} [props.checked=false] - Indicates whether the radio button is checked.
|
|
84
|
+
* @param {boolean} [props.disabled=false] - Indicates whether the radio button is disabled.
|
|
85
|
+
* @param {string} [props.helpText] - Additional descriptive text for the radio button.
|
|
86
|
+
* @param {function} [props.onChange] - Callback function called when the radio button state changes.
|
|
87
|
+
* @param {function} [props.onFocus] - Callback function called when the radio button gains focus.
|
|
88
|
+
* @param {function} [props.onBlur] - Callback function called when the radio button loses focus.
|
|
89
|
+
*
|
|
90
|
+
* @returns {JSX.Element} The rendered RadioButton component.
|
|
91
|
+
*/ function RadioButton() {
|
|
92
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
93
|
+
var label = props.label, tooltip = props.tooltip, labelHidden = props.labelHidden, id = props.id, name = props.name, value = props.value, error = props.error, _props_checked = props.checked, checked = _props_checked === void 0 ? false : _props_checked, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, helpText = props.helpText, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur, _props_alignItems = props.alignItems, alignItems = _props_alignItems === void 0 ? "stretch" : _props_alignItems;
|
|
94
|
+
var hasError = !!error;
|
|
95
|
+
var classes = styles({
|
|
96
|
+
disabled: disabled,
|
|
97
|
+
alignItems: alignItems
|
|
98
|
+
});
|
|
99
|
+
var radioClasses = radioStyles({
|
|
100
|
+
checked: checked,
|
|
101
|
+
disabled: disabled,
|
|
102
|
+
hasError: hasError
|
|
103
|
+
});
|
|
104
|
+
var handleChange = function(event) {
|
|
105
|
+
if (onChange) {
|
|
106
|
+
onChange(event);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var handleFocus = function(event) {
|
|
110
|
+
if (onFocus) {
|
|
111
|
+
onFocus(event);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var handleBlur = function(event) {
|
|
115
|
+
if (onBlur) {
|
|
116
|
+
onBlur(event);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
120
|
+
className: "Litho-RadioButtonContainer py-1",
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("label", {
|
|
123
|
+
className: classes,
|
|
124
|
+
children: [
|
|
125
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
126
|
+
type: "radio",
|
|
127
|
+
id: id,
|
|
128
|
+
name: name,
|
|
129
|
+
value: value,
|
|
130
|
+
checked: checked,
|
|
131
|
+
disabled: disabled,
|
|
132
|
+
onChange: handleChange,
|
|
133
|
+
onFocus: handleFocus,
|
|
134
|
+
onBlur: handleBlur,
|
|
135
|
+
className: "sr-only"
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
138
|
+
className: "Litho-RadioButton__ControlContainer w-5 h-5 flex items-center",
|
|
139
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
140
|
+
className: radioClasses,
|
|
141
|
+
children: [
|
|
142
|
+
checked && !hasError && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
143
|
+
className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-input-fg-light")
|
|
144
|
+
}),
|
|
145
|
+
checked && hasError && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
146
|
+
className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-bg")
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
label && !labelHidden && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.default, {
|
|
152
|
+
tooltip: tooltip,
|
|
153
|
+
disabled: disabled,
|
|
154
|
+
as: "p",
|
|
155
|
+
children: label
|
|
156
|
+
})
|
|
157
|
+
]
|
|
158
|
+
}),
|
|
159
|
+
helpText && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
160
|
+
color: "subdued",
|
|
161
|
+
className: "pl-7",
|
|
162
|
+
children: helpText
|
|
163
|
+
}),
|
|
164
|
+
error && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
165
|
+
color: "critical",
|
|
166
|
+
className: "pl-7",
|
|
167
|
+
children: error
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
var _default = RadioButton;
|
|
@@ -0,0 +1,193 @@
|
|
|
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 _Text = /*#__PURE__*/ _interop_require_default(require("./Text"));
|
|
14
|
+
var _Label = /*#__PURE__*/ _interop_require_default(require("./Label"));
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
21
|
+
base: "Litho-RadioButtonCardContainer border border-transparent rounded-lg p-3 pl-4 flex justify-between gap-2",
|
|
22
|
+
variants: {
|
|
23
|
+
disabled: {
|
|
24
|
+
true: "bg-tint-1",
|
|
25
|
+
false: "cursor-pointer"
|
|
26
|
+
},
|
|
27
|
+
checked: {
|
|
28
|
+
true: "",
|
|
29
|
+
false: "border-edge-subdued"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
compoundVariants: [
|
|
33
|
+
{
|
|
34
|
+
disabled: false,
|
|
35
|
+
checked: true,
|
|
36
|
+
class: "border-form-border-focus ring-1 ring-inset ring-form-border-focus"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
disabled: false,
|
|
40
|
+
checked: false,
|
|
41
|
+
class: "hover:border-edge-default"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
var radioStyles = (0, _tailwindvariants.tv)({
|
|
46
|
+
base: "Litho-RadioButton__Control w-4.5 h-4.5 rounded-full border border-form-border flex items-center justify-center",
|
|
47
|
+
variants: {
|
|
48
|
+
disabled: {
|
|
49
|
+
true: "bg-form-bg-disabled border-form-border"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
compoundVariants: [
|
|
53
|
+
{
|
|
54
|
+
hasError: true,
|
|
55
|
+
disabled: false,
|
|
56
|
+
checked: false,
|
|
57
|
+
class: "bg-form-bg-error border-form-border-error hover:bg-form-bg-error-low hover:ring hover:ring-form-focus-error"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
hasError: true,
|
|
61
|
+
disabled: false,
|
|
62
|
+
checked: true,
|
|
63
|
+
class: "bg-critical border-form-border-error hover:ring hover:ring-form-focus-error"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
hasError: false,
|
|
67
|
+
disabled: false,
|
|
68
|
+
checked: false,
|
|
69
|
+
class: "bg-form-bg border-form-border hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
hasError: false,
|
|
73
|
+
disabled: false,
|
|
74
|
+
checked: true,
|
|
75
|
+
class: "bg-form-accent border-form-border-focus hover:border-form-border-focus hover:ring hover:ring-form-focus"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* RadioButton Component
|
|
81
|
+
*
|
|
82
|
+
* A custom radio button component with support for labels, help text, and extensive styling using Tailwind Variants (tv).
|
|
83
|
+
*
|
|
84
|
+
* @component
|
|
85
|
+
*
|
|
86
|
+
* @param {Object} props - Props for the RadioButton component.
|
|
87
|
+
* @param {string} [props.label] - The text label for the radio button.
|
|
88
|
+
* @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it available for screen readers.
|
|
89
|
+
* @param {string} [props.id] - The unique identifier for the radio input.
|
|
90
|
+
* @param {string} [props.name] - The name attribute for the radio input (must be the same for grouped buttons).
|
|
91
|
+
* @param {string} [props.description] - A description of the radio button.
|
|
92
|
+
* @param {string} [props.value] - The value attribute for the radio input.
|
|
93
|
+
* @param {string} [props.error] - An error message associated with the radio button, if any.
|
|
94
|
+
* @param {boolean} [props.checked=false] - Indicates whether the radio button is checked.
|
|
95
|
+
* @param {boolean} [props.disabled=false] - Indicates whether the radio button is disabled.
|
|
96
|
+
* @param {string} [props.helpText] - Additional descriptive text for the radio button.
|
|
97
|
+
* @param {function} [props.onChange] - Callback function called when the radio button state changes.
|
|
98
|
+
* @param {function} [props.onFocus] - Callback function called when the radio button gains focus.
|
|
99
|
+
* @param {function} [props.onBlur] - Callback function called when the radio button loses focus.
|
|
100
|
+
*
|
|
101
|
+
* @returns {JSX.Element} The rendered RadioButton component.
|
|
102
|
+
*/ function RadioButtonCard() {
|
|
103
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
104
|
+
var label = props.label, tooltip = props.tooltip, labelHidden = props.labelHidden, id = props.id, name = props.name, description = props.description, value = props.value, error = props.error, _props_checked = props.checked, checked = _props_checked === void 0 ? false : _props_checked, _props_disabled = props.disabled, disabled = _props_disabled === void 0 ? false : _props_disabled, helpText = props.helpText, onChange = props.onChange, onFocus = props.onFocus, onBlur = props.onBlur;
|
|
105
|
+
var hasError = !!error;
|
|
106
|
+
var classes = styles({
|
|
107
|
+
checked: checked,
|
|
108
|
+
disabled: disabled,
|
|
109
|
+
hasError: hasError
|
|
110
|
+
});
|
|
111
|
+
var radioClasses = radioStyles({
|
|
112
|
+
checked: checked,
|
|
113
|
+
disabled: disabled,
|
|
114
|
+
hasError: hasError
|
|
115
|
+
});
|
|
116
|
+
var handleChange = function(event) {
|
|
117
|
+
if (onChange) {
|
|
118
|
+
onChange(event);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var handleFocus = function(event) {
|
|
122
|
+
if (onFocus) {
|
|
123
|
+
onFocus(event);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var handleBlur = function(event) {
|
|
127
|
+
if (onBlur) {
|
|
128
|
+
onBlur(event);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
132
|
+
className: "flex flex-col gap-1",
|
|
133
|
+
children: [
|
|
134
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("label", {
|
|
135
|
+
className: classes,
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
138
|
+
className: "flex flex-col gap-1",
|
|
139
|
+
children: [
|
|
140
|
+
label && !labelHidden && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Label.default, {
|
|
141
|
+
tooltip: tooltip,
|
|
142
|
+
disabled: disabled,
|
|
143
|
+
fontWeight: "semibold",
|
|
144
|
+
as: "p",
|
|
145
|
+
children: label
|
|
146
|
+
}),
|
|
147
|
+
description && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
148
|
+
color: disabled ? "disabled" : "subdued",
|
|
149
|
+
children: description
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
156
|
+
type: "radio",
|
|
157
|
+
id: id,
|
|
158
|
+
name: name,
|
|
159
|
+
value: value,
|
|
160
|
+
checked: checked,
|
|
161
|
+
disabled: disabled,
|
|
162
|
+
onChange: handleChange,
|
|
163
|
+
onFocus: handleFocus,
|
|
164
|
+
onBlur: handleBlur,
|
|
165
|
+
className: "sr-only"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
168
|
+
className: "Litho-RadioButton__ControlContainer w-5 h-5 flex items-center",
|
|
169
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
170
|
+
className: radioClasses,
|
|
171
|
+
children: [
|
|
172
|
+
checked && !hasError && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
173
|
+
className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-input-fg-light")
|
|
174
|
+
}),
|
|
175
|
+
checked && hasError && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
176
|
+
className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-bg")
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
}),
|
|
185
|
+
helpText && typeof helpText === "string" && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Text.default, {
|
|
186
|
+
color: disabled ? "disabled" : "subdued",
|
|
187
|
+
children: helpText
|
|
188
|
+
}),
|
|
189
|
+
helpText && typeof helpText !== "string" && helpText
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
var _default = RadioButtonCard;
|
|
@@ -0,0 +1,235 @@
|
|
|
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 _index = require("../index");
|
|
15
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
16
|
+
function _array_like_to_array(arr, len) {
|
|
17
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
18
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
19
|
+
return arr2;
|
|
20
|
+
}
|
|
21
|
+
function _array_with_holes(arr) {
|
|
22
|
+
if (Array.isArray(arr)) return arr;
|
|
23
|
+
}
|
|
24
|
+
function _iterable_to_array_limit(arr, i) {
|
|
25
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
26
|
+
if (_i == null) return;
|
|
27
|
+
var _arr = [];
|
|
28
|
+
var _n = true;
|
|
29
|
+
var _d = false;
|
|
30
|
+
var _s, _e;
|
|
31
|
+
try {
|
|
32
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
33
|
+
_arr.push(_s.value);
|
|
34
|
+
if (i && _arr.length === i) break;
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
_d = true;
|
|
38
|
+
_e = err;
|
|
39
|
+
} finally{
|
|
40
|
+
try {
|
|
41
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
42
|
+
} finally{
|
|
43
|
+
if (_d) throw _e;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return _arr;
|
|
47
|
+
}
|
|
48
|
+
function _non_iterable_rest() {
|
|
49
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
function _sliced_to_array(arr, i) {
|
|
52
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
53
|
+
}
|
|
54
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
55
|
+
if (!o) return;
|
|
56
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
57
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
58
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
59
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
60
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
61
|
+
}
|
|
62
|
+
var rangeStyles = (0, _tailwindvariants.tv)({
|
|
63
|
+
base: "Litho-RangeSlider__ActiveRange absolute left-0 top-1/2 -translate-y-1/2 rounded-l-full h-1 pointer-events-none",
|
|
64
|
+
variants: {
|
|
65
|
+
disabled: {
|
|
66
|
+
true: "bg-surface-lowest",
|
|
67
|
+
false: "bg-form-accent"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
defaultVariants: {
|
|
71
|
+
disabled: false
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
var inactiveRangeStyles = (0, _tailwindvariants.tv)({
|
|
75
|
+
base: "Litho-RangeSlider__InActiveRange absolute left-0 right-0 top-1/2 -translate-y-1/2 rounded-full w-full h-1 bg-tint-2 dark:bg-tint-alt-2 pointer-events-none",
|
|
76
|
+
variants: {
|
|
77
|
+
disabled: {
|
|
78
|
+
true: "",
|
|
79
|
+
false: "group-hover:bg-tint-3 group-active:bg-tint-4 group-focus:bg-tint-4 dark:group-hover:bg-tint-alt-3 dark:group-active:bg-tint-alt-4 dark:group-focus:bg-tint-alt-4"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
disabled: false
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
function useSyncedState(externalValue) {
|
|
87
|
+
var _useState = _sliced_to_array((0, _react.useState)(externalValue), 2), value = _useState[0], setValue = _useState[1];
|
|
88
|
+
(0, _react.useEffect)(function() {
|
|
89
|
+
setValue(externalValue);
|
|
90
|
+
}, [
|
|
91
|
+
externalValue
|
|
92
|
+
]);
|
|
93
|
+
return [
|
|
94
|
+
value,
|
|
95
|
+
setValue
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* RangeSlider Component
|
|
100
|
+
*
|
|
101
|
+
* A range slider component that allows users to select a numeric value within a defined range.
|
|
102
|
+
*
|
|
103
|
+
* @component
|
|
104
|
+
* @param {Object} props - The properties for the RangeSlider component.
|
|
105
|
+
* @param {string} [props.id] - The unique ID for the slider. If not provided, a UUID will be generated.
|
|
106
|
+
* @param {string} [props.label] - The label text displayed for the slider.
|
|
107
|
+
* @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it accessible for screen readers.
|
|
108
|
+
* @param {string} [props.labelVariant] - Variant of the label style.
|
|
109
|
+
* @param {string} [props.tooltip] - Tooltip text for the label.
|
|
110
|
+
* @param {boolean} [props.disabled=false] - Disables the slider if true.
|
|
111
|
+
* @param {number} [props.step=1] - Step value for the slider increments.
|
|
112
|
+
* @param {string} [props.prefix] - Text to display before the slider input.
|
|
113
|
+
* @param {string} [props.prefixClasses=""] - Additional classes for the prefix text.
|
|
114
|
+
* @param {string} [props.suffix] - Text to display after the slider value input.
|
|
115
|
+
* @param {number} [props.value] - Initial value for the slider. Defaults to the minimum value.
|
|
116
|
+
* @param {number} [props.min=0] - Minimum value of the slider.
|
|
117
|
+
* @param {number} [props.max=100] - Maximum value of the slider.
|
|
118
|
+
* @param {boolean} [props.output=true] - Whether to display an output field for the slider value.
|
|
119
|
+
* @param {function} [props.onChange] - Callback function triggered when the slider value changes.
|
|
120
|
+
*
|
|
121
|
+
* @returns {JSX.Element} The rendered RangeSlider component.
|
|
122
|
+
*/ function RangeSlider() {
|
|
123
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
124
|
+
var _id = props.id, label = props.label, labelHidden = props.labelHidden, labelVariant = props.labelVariant, tooltip = props.tooltip, disabled = props.disabled, _props_step = props.step, step = _props_step === void 0 ? 1 : _props_step, prefix = props.prefix, _props_prefixClasses = props.prefixClasses, prefixClasses = _props_prefixClasses === void 0 ? "" : _props_prefixClasses, suffix = props.suffix, initialValue = props.value, _props_min = props.min, min = _props_min === void 0 ? 0 : _props_min, _props_max = props.max, max = _props_max === void 0 ? 100 : _props_max, _props_output = props.output, output = _props_output === void 0 ? true : _props_output, onChange = props.onChange;
|
|
125
|
+
var idValue = (0, _react.useId)();
|
|
126
|
+
var idRef = (0, _react.useRef)(_id || idValue);
|
|
127
|
+
var id = idRef.current;
|
|
128
|
+
var _useSyncedState = _sliced_to_array(useSyncedState(initialValue !== null && initialValue !== void 0 ? initialValue : min), 2), value = _useSyncedState[0], setValue = _useSyncedState[1];
|
|
129
|
+
var _useSyncedState1 = _sliced_to_array(useSyncedState(initialValue !== null && initialValue !== void 0 ? initialValue : min), 2), tempValue = _useSyncedState1[0], setTempValue = _useSyncedState1[1];
|
|
130
|
+
var handleChange = function(v) {
|
|
131
|
+
var updateOnPartialChange = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
132
|
+
if (v === null || v === "") {
|
|
133
|
+
setTempValue(min);
|
|
134
|
+
setValue(min);
|
|
135
|
+
if (onChange) {
|
|
136
|
+
onChange(min);
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
var stringValue = String(v);
|
|
141
|
+
var strippedValue = stringValue.replace(/^0+(?=\d)/, "");
|
|
142
|
+
var numericValue = Number(strippedValue);
|
|
143
|
+
var tempNumericValue = Number(strippedValue);
|
|
144
|
+
if (isNaN(numericValue)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (updateOnPartialChange) {
|
|
148
|
+
numericValue = Math.max(min, Math.min(max, numericValue));
|
|
149
|
+
numericValue = Math.round(numericValue / step) * step;
|
|
150
|
+
}
|
|
151
|
+
tempNumericValue = Math.max(min, Math.min(max, tempNumericValue));
|
|
152
|
+
tempNumericValue = Math.round(tempNumericValue / step) * step;
|
|
153
|
+
setTempValue(tempNumericValue);
|
|
154
|
+
setValue(numericValue);
|
|
155
|
+
if (onChange) {
|
|
156
|
+
onChange(numericValue);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
160
|
+
className: "Litho-RangeSlider",
|
|
161
|
+
children: [
|
|
162
|
+
label && !labelHidden && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Label, {
|
|
163
|
+
id: id,
|
|
164
|
+
hidden: labelHidden,
|
|
165
|
+
disabled: disabled,
|
|
166
|
+
tooltip: tooltip,
|
|
167
|
+
variant: labelVariant,
|
|
168
|
+
children: label
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
171
|
+
className: "flex items-center gap-2",
|
|
172
|
+
children: [
|
|
173
|
+
prefix && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
174
|
+
color: "subdued",
|
|
175
|
+
as: "div",
|
|
176
|
+
className: prefixClasses,
|
|
177
|
+
children: prefix
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
180
|
+
className: "Litho-RangeSlider__Container group relative w-full h-8 overflow-hidden",
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
183
|
+
className: inactiveRangeStyles({
|
|
184
|
+
disabled: disabled
|
|
185
|
+
})
|
|
186
|
+
}),
|
|
187
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
188
|
+
className: rangeStyles({
|
|
189
|
+
disabled: disabled
|
|
190
|
+
}),
|
|
191
|
+
style: {
|
|
192
|
+
width: "".concat((tempValue - min) / (max - min) * 100, "%")
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
196
|
+
id: id,
|
|
197
|
+
type: "range",
|
|
198
|
+
className: "Litho-RangeSlider__Slider relative w-full appearance-none bg-transparent h-8 ".concat(disabled ? "cursor-not-allowed" : "cursor-pointer"),
|
|
199
|
+
disabled: disabled,
|
|
200
|
+
min: min,
|
|
201
|
+
max: max,
|
|
202
|
+
step: step,
|
|
203
|
+
value: value,
|
|
204
|
+
onChange: function(e) {
|
|
205
|
+
return handleChange(e.target.value, true);
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
}),
|
|
210
|
+
output && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
211
|
+
className: "max-w-21",
|
|
212
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.TextField, {
|
|
213
|
+
transparent: true,
|
|
214
|
+
type: "number",
|
|
215
|
+
disabled: disabled,
|
|
216
|
+
placeholder: value,
|
|
217
|
+
value: value,
|
|
218
|
+
suffix: suffix,
|
|
219
|
+
onChange: function(value) {
|
|
220
|
+
return handleChange(value);
|
|
221
|
+
},
|
|
222
|
+
onBlur: function(e) {
|
|
223
|
+
return handleChange(e.target.value, true);
|
|
224
|
+
},
|
|
225
|
+
selectTextOnFocus: true,
|
|
226
|
+
align: "right",
|
|
227
|
+
showNumberSteppers: false
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
var _default = RangeSlider;
|