@heymantle/litho 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/dist/cjs/components/ActionList.js +267 -0
  4. package/dist/cjs/components/AnnouncementBar.js +73 -0
  5. package/dist/cjs/components/AppProvider.js +245 -0
  6. package/dist/cjs/components/Autocomplete.js +351 -0
  7. package/dist/cjs/components/Badge.js +234 -0
  8. package/dist/cjs/components/Banner.js +264 -0
  9. package/dist/cjs/components/Box.js +247 -0
  10. package/dist/cjs/components/Button.js +1018 -0
  11. package/dist/cjs/components/ButtonGroup.js +196 -0
  12. package/dist/cjs/components/Card.js +593 -0
  13. package/dist/cjs/components/Checkbox.js +175 -0
  14. package/dist/cjs/components/ChoiceList.js +160 -0
  15. package/dist/cjs/components/Collapsible.js +42 -0
  16. package/dist/cjs/components/ColorField.js +159 -0
  17. package/dist/cjs/components/ContextualSaveBar.js +53 -0
  18. package/dist/cjs/components/DatePicker.js +547 -0
  19. package/dist/cjs/components/Divider.js +50 -0
  20. package/dist/cjs/components/DropZone.js +547 -0
  21. package/dist/cjs/components/EmptyState.js +111 -0
  22. package/dist/cjs/components/Filters.js +874 -0
  23. package/dist/cjs/components/FooterHelp.js +48 -0
  24. package/dist/cjs/components/Form.js +44 -0
  25. package/dist/cjs/components/Frame.js +386 -0
  26. package/dist/cjs/components/FrameSaveBar.js +239 -0
  27. package/dist/cjs/components/Grid.js +151 -0
  28. package/dist/cjs/components/HorizontalStack.js +180 -0
  29. package/dist/cjs/components/Icon.js +346 -0
  30. package/dist/cjs/components/Image.js +191 -0
  31. package/dist/cjs/components/InlineError.js +57 -0
  32. package/dist/cjs/components/Label.js +78 -0
  33. package/dist/cjs/components/Layout.js +228 -0
  34. package/dist/cjs/components/LayoutSection.js +133 -0
  35. package/dist/cjs/components/Link.js +128 -0
  36. package/dist/cjs/components/List.js +69 -0
  37. package/dist/cjs/components/Listbox.js +211 -0
  38. package/dist/cjs/components/Loading.js +103 -0
  39. package/dist/cjs/components/Modal.js +449 -0
  40. package/dist/cjs/components/Navigation.js +331 -0
  41. package/dist/cjs/components/Page.js +529 -0
  42. package/dist/cjs/components/Pagination.js +109 -0
  43. package/dist/cjs/components/Pane.js +128 -0
  44. package/dist/cjs/components/Popover.js +365 -0
  45. package/dist/cjs/components/PopoverManager.js +34 -0
  46. package/dist/cjs/components/ProgressBar.js +124 -0
  47. package/dist/cjs/components/RadioButton.js +172 -0
  48. package/dist/cjs/components/RadioButtonCard.js +193 -0
  49. package/dist/cjs/components/RangeSlider.js +235 -0
  50. package/dist/cjs/components/ResourceList.js +105 -0
  51. package/dist/cjs/components/Select.js +300 -0
  52. package/dist/cjs/components/SkeletonText.js +130 -0
  53. package/dist/cjs/components/Spinner.js +72 -0
  54. package/dist/cjs/components/Table.js +1184 -0
  55. package/dist/cjs/components/Tabs.js +421 -0
  56. package/dist/cjs/components/Tag.js +165 -0
  57. package/dist/cjs/components/Text.js +274 -0
  58. package/dist/cjs/components/TextField.js +584 -0
  59. package/dist/cjs/components/Thumbnail.js +73 -0
  60. package/dist/cjs/components/TimePicker.js +23 -0
  61. package/dist/cjs/components/Tip.js +220 -0
  62. package/dist/cjs/components/Tooltip.js +431 -0
  63. package/dist/cjs/components/TopBar.js +210 -0
  64. package/dist/cjs/components/VerticalStack.js +161 -0
  65. package/dist/cjs/index.js +308 -0
  66. package/dist/cjs/styles/Table.js +591 -0
  67. package/dist/cjs/utilities/dates.js +339 -0
  68. package/dist/cjs/utilities/useIndexResourceState.js +175 -0
  69. package/dist/cjs/utilities/useMounted.js +67 -0
  70. package/dist/cjs/utilities/useTableScrollState.js +142 -0
  71. package/dist/esm/components/ActionList.js +216 -0
  72. package/dist/esm/components/AnnouncementBar.js +63 -0
  73. package/dist/esm/components/AppProvider.js +185 -0
  74. package/dist/esm/components/Autocomplete.js +300 -0
  75. package/dist/esm/components/Badge.js +225 -0
  76. package/dist/esm/components/Banner.js +254 -0
  77. package/dist/esm/components/Box.js +238 -0
  78. package/dist/esm/components/Button.js +967 -0
  79. package/dist/esm/components/ButtonGroup.js +137 -0
  80. package/dist/esm/components/Card.js +537 -0
  81. package/dist/esm/components/Checkbox.js +165 -0
  82. package/dist/esm/components/ChoiceList.js +145 -0
  83. package/dist/esm/components/Collapsible.js +32 -0
  84. package/dist/esm/components/ColorField.js +149 -0
  85. package/dist/esm/components/ContextualSaveBar.js +43 -0
  86. package/dist/esm/components/DatePicker.js +532 -0
  87. package/dist/esm/components/Divider.js +41 -0
  88. package/dist/esm/components/DropZone.js +537 -0
  89. package/dist/esm/components/EmptyState.js +101 -0
  90. package/dist/esm/components/Filters.js +823 -0
  91. package/dist/esm/components/FooterHelp.js +38 -0
  92. package/dist/esm/components/Form.js +35 -0
  93. package/dist/esm/components/Frame.js +376 -0
  94. package/dist/esm/components/FrameSaveBar.js +229 -0
  95. package/dist/esm/components/Grid.js +142 -0
  96. package/dist/esm/components/HorizontalStack.js +171 -0
  97. package/dist/esm/components/Icon.js +296 -0
  98. package/dist/esm/components/Image.js +141 -0
  99. package/dist/esm/components/InlineError.js +43 -0
  100. package/dist/esm/components/Label.js +63 -0
  101. package/dist/esm/components/Layout.js +164 -0
  102. package/dist/esm/components/LayoutSection.js +82 -0
  103. package/dist/esm/components/Link.js +119 -0
  104. package/dist/esm/components/List.js +61 -0
  105. package/dist/esm/components/Listbox.js +201 -0
  106. package/dist/esm/components/Loading.js +93 -0
  107. package/dist/esm/components/Modal.js +390 -0
  108. package/dist/esm/components/Navigation.js +321 -0
  109. package/dist/esm/components/Page.js +473 -0
  110. package/dist/esm/components/Pagination.js +99 -0
  111. package/dist/esm/components/Pane.js +118 -0
  112. package/dist/esm/components/Popover.js +350 -0
  113. package/dist/esm/components/PopoverManager.js +24 -0
  114. package/dist/esm/components/ProgressBar.js +114 -0
  115. package/dist/esm/components/RadioButton.js +157 -0
  116. package/dist/esm/components/RadioButtonCard.js +178 -0
  117. package/dist/esm/components/RangeSlider.js +225 -0
  118. package/dist/esm/components/ResourceList.js +95 -0
  119. package/dist/esm/components/Select.js +285 -0
  120. package/dist/esm/components/SkeletonText.js +120 -0
  121. package/dist/esm/components/Spinner.js +63 -0
  122. package/dist/esm/components/Table.js +1129 -0
  123. package/dist/esm/components/Tabs.js +366 -0
  124. package/dist/esm/components/Tag.js +151 -0
  125. package/dist/esm/components/Text.js +265 -0
  126. package/dist/esm/components/TextField.js +533 -0
  127. package/dist/esm/components/Thumbnail.js +63 -0
  128. package/dist/esm/components/TimePicker.js +13 -0
  129. package/dist/esm/components/Tip.js +169 -0
  130. package/dist/esm/components/Tooltip.js +380 -0
  131. package/dist/esm/components/TopBar.js +200 -0
  132. package/dist/esm/components/VerticalStack.js +152 -0
  133. package/dist/esm/index.js +61 -0
  134. package/dist/esm/styles/Table.js +581 -0
  135. package/dist/esm/utilities/dates.js +289 -0
  136. package/dist/esm/utilities/useIndexResourceState.js +158 -0
  137. package/dist/esm/utilities/useMounted.js +57 -0
  138. package/dist/esm/utilities/useTableScrollState.js +132 -0
  139. package/index.css +1137 -0
  140. package/package.json +53 -0
@@ -0,0 +1,157 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import Text from "./Text.js";
4
+ import Label from "./Label.js";
5
+ var styles = tv({
6
+ base: "Litho-RadioButton group flex gap-2",
7
+ variants: {
8
+ disabled: {
9
+ false: "cursor-pointer"
10
+ },
11
+ alignItems: {
12
+ stretch: "items-stretch",
13
+ center: "items-center"
14
+ }
15
+ },
16
+ defaultVariants: {
17
+ alignItems: "stretch"
18
+ }
19
+ });
20
+ var radioStyles = tv({
21
+ base: "Litho-RadioButton__Control w-4.5 h-4.5 rounded-full border border-form-border flex items-center justify-center",
22
+ variants: {
23
+ disabled: {
24
+ true: "bg-form-bg-disabled border-form-border"
25
+ }
26
+ },
27
+ compoundVariants: [
28
+ {
29
+ hasError: true,
30
+ disabled: false,
31
+ checked: false,
32
+ class: "bg-form-bg-error border-form-border-error hover:bg-form-bg-error-low hover:ring hover:ring-form-focus-error"
33
+ },
34
+ {
35
+ hasError: true,
36
+ disabled: false,
37
+ checked: true,
38
+ class: "bg-critical border-form-border-error hover:ring hover:ring-form-focus-error"
39
+ },
40
+ {
41
+ hasError: false,
42
+ disabled: false,
43
+ checked: false,
44
+ class: "bg-form-bg border-form-border hover:border-form-border-focus hover:ring hover:ring-form-focus"
45
+ },
46
+ {
47
+ hasError: false,
48
+ disabled: false,
49
+ checked: true,
50
+ class: "bg-form-accent border-form-border-focus hover:border-form-border-focus hover:ring hover:ring-form-focus"
51
+ }
52
+ ]
53
+ });
54
+ /**
55
+ * RadioButton Component
56
+ *
57
+ * A custom radio button component with support for labels, help text, and extensive styling using Tailwind Variants (tv).
58
+ *
59
+ * @component
60
+ *
61
+ * @param {Object} props - Props for the RadioButton component.
62
+ * @param {string} [props.label] - The text label for the radio button.
63
+ * @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it available for screen readers.
64
+ * @param {string} [props.id] - The unique identifier for the radio input.
65
+ * @param {string} [props.name] - The name attribute for the radio input (must be the same for grouped buttons).
66
+ * @param {string} [props.value] - The value attribute for the radio input.
67
+ * @param {string} [props.error] - An error message associated with the radio button, if any.
68
+ * @param {boolean} [props.checked=false] - Indicates whether the radio button is checked.
69
+ * @param {boolean} [props.disabled=false] - Indicates whether the radio button is disabled.
70
+ * @param {string} [props.helpText] - Additional descriptive text for the radio button.
71
+ * @param {function} [props.onChange] - Callback function called when the radio button state changes.
72
+ * @param {function} [props.onFocus] - Callback function called when the radio button gains focus.
73
+ * @param {function} [props.onBlur] - Callback function called when the radio button loses focus.
74
+ *
75
+ * @returns {JSX.Element} The rendered RadioButton component.
76
+ */ function RadioButton() {
77
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
78
+ 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;
79
+ var hasError = !!error;
80
+ var classes = styles({
81
+ disabled: disabled,
82
+ alignItems: alignItems
83
+ });
84
+ var radioClasses = radioStyles({
85
+ checked: checked,
86
+ disabled: disabled,
87
+ hasError: hasError
88
+ });
89
+ var handleChange = function(event) {
90
+ if (onChange) {
91
+ onChange(event);
92
+ }
93
+ };
94
+ var handleFocus = function(event) {
95
+ if (onFocus) {
96
+ onFocus(event);
97
+ }
98
+ };
99
+ var handleBlur = function(event) {
100
+ if (onBlur) {
101
+ onBlur(event);
102
+ }
103
+ };
104
+ return /*#__PURE__*/ _jsxs("div", {
105
+ className: "Litho-RadioButtonContainer py-1",
106
+ children: [
107
+ /*#__PURE__*/ _jsxs("label", {
108
+ className: classes,
109
+ children: [
110
+ /*#__PURE__*/ _jsx("input", {
111
+ type: "radio",
112
+ id: id,
113
+ name: name,
114
+ value: value,
115
+ checked: checked,
116
+ disabled: disabled,
117
+ onChange: handleChange,
118
+ onFocus: handleFocus,
119
+ onBlur: handleBlur,
120
+ className: "sr-only"
121
+ }),
122
+ /*#__PURE__*/ _jsx("div", {
123
+ className: "Litho-RadioButton__ControlContainer w-5 h-5 flex items-center",
124
+ children: /*#__PURE__*/ _jsxs("div", {
125
+ className: radioClasses,
126
+ children: [
127
+ checked && !hasError && /*#__PURE__*/ _jsx("div", {
128
+ className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-input-fg-light")
129
+ }),
130
+ checked && hasError && /*#__PURE__*/ _jsx("div", {
131
+ className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-bg")
132
+ })
133
+ ]
134
+ })
135
+ }),
136
+ label && !labelHidden && /*#__PURE__*/ _jsx(Label, {
137
+ tooltip: tooltip,
138
+ disabled: disabled,
139
+ as: "p",
140
+ children: label
141
+ })
142
+ ]
143
+ }),
144
+ helpText && /*#__PURE__*/ _jsx(Text, {
145
+ color: "subdued",
146
+ className: "pl-7",
147
+ children: helpText
148
+ }),
149
+ error && /*#__PURE__*/ _jsx(Text, {
150
+ color: "critical",
151
+ className: "pl-7",
152
+ children: error
153
+ })
154
+ ]
155
+ });
156
+ }
157
+ export default RadioButton;
@@ -0,0 +1,178 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import Text from "./Text.js";
4
+ import Label from "./Label.js";
5
+ var styles = tv({
6
+ base: "Litho-RadioButtonCardContainer border border-transparent rounded-lg p-3 pl-4 flex justify-between gap-2",
7
+ variants: {
8
+ disabled: {
9
+ true: "bg-tint-1",
10
+ false: "cursor-pointer"
11
+ },
12
+ checked: {
13
+ true: "",
14
+ false: "border-edge-subdued"
15
+ }
16
+ },
17
+ compoundVariants: [
18
+ {
19
+ disabled: false,
20
+ checked: true,
21
+ class: "border-form-border-focus ring-1 ring-inset ring-form-border-focus"
22
+ },
23
+ {
24
+ disabled: false,
25
+ checked: false,
26
+ class: "hover:border-edge-default"
27
+ }
28
+ ]
29
+ });
30
+ var radioStyles = tv({
31
+ base: "Litho-RadioButton__Control w-4.5 h-4.5 rounded-full border border-form-border flex items-center justify-center",
32
+ variants: {
33
+ disabled: {
34
+ true: "bg-form-bg-disabled border-form-border"
35
+ }
36
+ },
37
+ compoundVariants: [
38
+ {
39
+ hasError: true,
40
+ disabled: false,
41
+ checked: false,
42
+ class: "bg-form-bg-error border-form-border-error hover:bg-form-bg-error-low hover:ring hover:ring-form-focus-error"
43
+ },
44
+ {
45
+ hasError: true,
46
+ disabled: false,
47
+ checked: true,
48
+ class: "bg-critical border-form-border-error hover:ring hover:ring-form-focus-error"
49
+ },
50
+ {
51
+ hasError: false,
52
+ disabled: false,
53
+ checked: false,
54
+ class: "bg-form-bg border-form-border hover:border-form-border-focus hover:ring hover:ring-form-focus"
55
+ },
56
+ {
57
+ hasError: false,
58
+ disabled: false,
59
+ checked: true,
60
+ class: "bg-form-accent border-form-border-focus hover:border-form-border-focus hover:ring hover:ring-form-focus"
61
+ }
62
+ ]
63
+ });
64
+ /**
65
+ * RadioButton Component
66
+ *
67
+ * A custom radio button component with support for labels, help text, and extensive styling using Tailwind Variants (tv).
68
+ *
69
+ * @component
70
+ *
71
+ * @param {Object} props - Props for the RadioButton component.
72
+ * @param {string} [props.label] - The text label for the radio button.
73
+ * @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it available for screen readers.
74
+ * @param {string} [props.id] - The unique identifier for the radio input.
75
+ * @param {string} [props.name] - The name attribute for the radio input (must be the same for grouped buttons).
76
+ * @param {string} [props.description] - A description of the radio button.
77
+ * @param {string} [props.value] - The value attribute for the radio input.
78
+ * @param {string} [props.error] - An error message associated with the radio button, if any.
79
+ * @param {boolean} [props.checked=false] - Indicates whether the radio button is checked.
80
+ * @param {boolean} [props.disabled=false] - Indicates whether the radio button is disabled.
81
+ * @param {string} [props.helpText] - Additional descriptive text for the radio button.
82
+ * @param {function} [props.onChange] - Callback function called when the radio button state changes.
83
+ * @param {function} [props.onFocus] - Callback function called when the radio button gains focus.
84
+ * @param {function} [props.onBlur] - Callback function called when the radio button loses focus.
85
+ *
86
+ * @returns {JSX.Element} The rendered RadioButton component.
87
+ */ function RadioButtonCard() {
88
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
89
+ 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;
90
+ var hasError = !!error;
91
+ var classes = styles({
92
+ checked: checked,
93
+ disabled: disabled,
94
+ hasError: hasError
95
+ });
96
+ var radioClasses = radioStyles({
97
+ checked: checked,
98
+ disabled: disabled,
99
+ hasError: hasError
100
+ });
101
+ var handleChange = function(event) {
102
+ if (onChange) {
103
+ onChange(event);
104
+ }
105
+ };
106
+ var handleFocus = function(event) {
107
+ if (onFocus) {
108
+ onFocus(event);
109
+ }
110
+ };
111
+ var handleBlur = function(event) {
112
+ if (onBlur) {
113
+ onBlur(event);
114
+ }
115
+ };
116
+ return /*#__PURE__*/ _jsxs("div", {
117
+ className: "flex flex-col gap-1",
118
+ children: [
119
+ /*#__PURE__*/ _jsxs("label", {
120
+ className: classes,
121
+ children: [
122
+ /*#__PURE__*/ _jsxs("div", {
123
+ className: "flex flex-col gap-1",
124
+ children: [
125
+ label && !labelHidden && /*#__PURE__*/ _jsx(Label, {
126
+ tooltip: tooltip,
127
+ disabled: disabled,
128
+ fontWeight: "semibold",
129
+ as: "p",
130
+ children: label
131
+ }),
132
+ description && /*#__PURE__*/ _jsx(Text, {
133
+ color: disabled ? "disabled" : "subdued",
134
+ children: description
135
+ })
136
+ ]
137
+ }),
138
+ /*#__PURE__*/ _jsxs("div", {
139
+ children: [
140
+ /*#__PURE__*/ _jsx("input", {
141
+ type: "radio",
142
+ id: id,
143
+ name: name,
144
+ value: value,
145
+ checked: checked,
146
+ disabled: disabled,
147
+ onChange: handleChange,
148
+ onFocus: handleFocus,
149
+ onBlur: handleBlur,
150
+ className: "sr-only"
151
+ }),
152
+ /*#__PURE__*/ _jsx("div", {
153
+ className: "Litho-RadioButton__ControlContainer w-5 h-5 flex items-center",
154
+ children: /*#__PURE__*/ _jsxs("div", {
155
+ className: radioClasses,
156
+ children: [
157
+ checked && !hasError && /*#__PURE__*/ _jsx("div", {
158
+ className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-input-fg-light")
159
+ }),
160
+ checked && hasError && /*#__PURE__*/ _jsx("div", {
161
+ className: "rounded-full w-1.5 h-1.5 ".concat(disabled ? "bg-form-input-fg-disabled" : "bg-form-bg")
162
+ })
163
+ ]
164
+ })
165
+ })
166
+ ]
167
+ })
168
+ ]
169
+ }),
170
+ helpText && typeof helpText === "string" && /*#__PURE__*/ _jsx(Text, {
171
+ color: disabled ? "disabled" : "subdued",
172
+ children: helpText
173
+ }),
174
+ helpText && typeof helpText !== "string" && helpText
175
+ ]
176
+ });
177
+ }
178
+ export default RadioButtonCard;
@@ -0,0 +1,225 @@
1
+ "use client";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _iterable_to_array_limit(arr, i) {
11
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
+ if (_i == null) return;
13
+ var _arr = [];
14
+ var _n = true;
15
+ var _d = false;
16
+ var _s, _e;
17
+ try {
18
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
19
+ _arr.push(_s.value);
20
+ if (i && _arr.length === i) break;
21
+ }
22
+ } catch (err) {
23
+ _d = true;
24
+ _e = err;
25
+ } finally{
26
+ try {
27
+ if (!_n && _i["return"] != null) _i["return"]();
28
+ } finally{
29
+ if (_d) throw _e;
30
+ }
31
+ }
32
+ return _arr;
33
+ }
34
+ function _non_iterable_rest() {
35
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
+ }
37
+ function _sliced_to_array(arr, i) {
38
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
+ }
40
+ function _unsupported_iterable_to_array(o, minLen) {
41
+ if (!o) return;
42
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
43
+ var n = Object.prototype.toString.call(o).slice(8, -1);
44
+ if (n === "Object" && o.constructor) n = o.constructor.name;
45
+ if (n === "Map" || n === "Set") return Array.from(n);
46
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
47
+ }
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
+ import { useId, useRef, useState, useEffect } from "react";
50
+ import { Label, Text, TextField } from "../index.js";
51
+ import { tv } from "tailwind-variants";
52
+ var rangeStyles = tv({
53
+ base: "Litho-RangeSlider__ActiveRange absolute left-0 top-1/2 -translate-y-1/2 rounded-l-full h-1 pointer-events-none",
54
+ variants: {
55
+ disabled: {
56
+ true: "bg-surface-lowest",
57
+ false: "bg-form-accent"
58
+ }
59
+ },
60
+ defaultVariants: {
61
+ disabled: false
62
+ }
63
+ });
64
+ var inactiveRangeStyles = tv({
65
+ 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",
66
+ variants: {
67
+ disabled: {
68
+ true: "",
69
+ 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"
70
+ }
71
+ },
72
+ defaultVariants: {
73
+ disabled: false
74
+ }
75
+ });
76
+ function useSyncedState(externalValue) {
77
+ var _useState = _sliced_to_array(useState(externalValue), 2), value = _useState[0], setValue = _useState[1];
78
+ useEffect(function() {
79
+ setValue(externalValue);
80
+ }, [
81
+ externalValue
82
+ ]);
83
+ return [
84
+ value,
85
+ setValue
86
+ ];
87
+ }
88
+ /**
89
+ * RangeSlider Component
90
+ *
91
+ * A range slider component that allows users to select a numeric value within a defined range.
92
+ *
93
+ * @component
94
+ * @param {Object} props - The properties for the RangeSlider component.
95
+ * @param {string} [props.id] - The unique ID for the slider. If not provided, a UUID will be generated.
96
+ * @param {string} [props.label] - The label text displayed for the slider.
97
+ * @param {boolean} [props.labelHidden=false] - If true, hides the label visually but keeps it accessible for screen readers.
98
+ * @param {string} [props.labelVariant] - Variant of the label style.
99
+ * @param {string} [props.tooltip] - Tooltip text for the label.
100
+ * @param {boolean} [props.disabled=false] - Disables the slider if true.
101
+ * @param {number} [props.step=1] - Step value for the slider increments.
102
+ * @param {string} [props.prefix] - Text to display before the slider input.
103
+ * @param {string} [props.prefixClasses=""] - Additional classes for the prefix text.
104
+ * @param {string} [props.suffix] - Text to display after the slider value input.
105
+ * @param {number} [props.value] - Initial value for the slider. Defaults to the minimum value.
106
+ * @param {number} [props.min=0] - Minimum value of the slider.
107
+ * @param {number} [props.max=100] - Maximum value of the slider.
108
+ * @param {boolean} [props.output=true] - Whether to display an output field for the slider value.
109
+ * @param {function} [props.onChange] - Callback function triggered when the slider value changes.
110
+ *
111
+ * @returns {JSX.Element} The rendered RangeSlider component.
112
+ */ function RangeSlider() {
113
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
114
+ 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;
115
+ var idValue = useId();
116
+ var idRef = useRef(_id || idValue);
117
+ var id = idRef.current;
118
+ var _useSyncedState = _sliced_to_array(useSyncedState(initialValue !== null && initialValue !== void 0 ? initialValue : min), 2), value = _useSyncedState[0], setValue = _useSyncedState[1];
119
+ var _useSyncedState1 = _sliced_to_array(useSyncedState(initialValue !== null && initialValue !== void 0 ? initialValue : min), 2), tempValue = _useSyncedState1[0], setTempValue = _useSyncedState1[1];
120
+ var handleChange = function(v) {
121
+ var updateOnPartialChange = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
122
+ if (v === null || v === "") {
123
+ setTempValue(min);
124
+ setValue(min);
125
+ if (onChange) {
126
+ onChange(min);
127
+ }
128
+ return;
129
+ }
130
+ var stringValue = String(v);
131
+ var strippedValue = stringValue.replace(/^0+(?=\d)/, "");
132
+ var numericValue = Number(strippedValue);
133
+ var tempNumericValue = Number(strippedValue);
134
+ if (isNaN(numericValue)) {
135
+ return;
136
+ }
137
+ if (updateOnPartialChange) {
138
+ numericValue = Math.max(min, Math.min(max, numericValue));
139
+ numericValue = Math.round(numericValue / step) * step;
140
+ }
141
+ tempNumericValue = Math.max(min, Math.min(max, tempNumericValue));
142
+ tempNumericValue = Math.round(tempNumericValue / step) * step;
143
+ setTempValue(tempNumericValue);
144
+ setValue(numericValue);
145
+ if (onChange) {
146
+ onChange(numericValue);
147
+ }
148
+ };
149
+ return /*#__PURE__*/ _jsxs("div", {
150
+ className: "Litho-RangeSlider",
151
+ children: [
152
+ label && !labelHidden && /*#__PURE__*/ _jsx(Label, {
153
+ id: id,
154
+ hidden: labelHidden,
155
+ disabled: disabled,
156
+ tooltip: tooltip,
157
+ variant: labelVariant,
158
+ children: label
159
+ }),
160
+ /*#__PURE__*/ _jsxs("div", {
161
+ className: "flex items-center gap-2",
162
+ children: [
163
+ prefix && /*#__PURE__*/ _jsx(Text, {
164
+ color: "subdued",
165
+ as: "div",
166
+ className: prefixClasses,
167
+ children: prefix
168
+ }),
169
+ /*#__PURE__*/ _jsxs("div", {
170
+ className: "Litho-RangeSlider__Container group relative w-full h-8 overflow-hidden",
171
+ children: [
172
+ /*#__PURE__*/ _jsx("div", {
173
+ className: inactiveRangeStyles({
174
+ disabled: disabled
175
+ })
176
+ }),
177
+ /*#__PURE__*/ _jsx("div", {
178
+ className: rangeStyles({
179
+ disabled: disabled
180
+ }),
181
+ style: {
182
+ width: "".concat((tempValue - min) / (max - min) * 100, "%")
183
+ }
184
+ }),
185
+ /*#__PURE__*/ _jsx("input", {
186
+ id: id,
187
+ type: "range",
188
+ className: "Litho-RangeSlider__Slider relative w-full appearance-none bg-transparent h-8 ".concat(disabled ? "cursor-not-allowed" : "cursor-pointer"),
189
+ disabled: disabled,
190
+ min: min,
191
+ max: max,
192
+ step: step,
193
+ value: value,
194
+ onChange: function(e) {
195
+ return handleChange(e.target.value, true);
196
+ }
197
+ })
198
+ ]
199
+ }),
200
+ output && /*#__PURE__*/ _jsx("div", {
201
+ className: "max-w-21",
202
+ children: /*#__PURE__*/ _jsx(TextField, {
203
+ transparent: true,
204
+ type: "number",
205
+ disabled: disabled,
206
+ placeholder: value,
207
+ value: value,
208
+ suffix: suffix,
209
+ onChange: function(value) {
210
+ return handleChange(value);
211
+ },
212
+ onBlur: function(e) {
213
+ return handleChange(e.target.value, true);
214
+ },
215
+ selectTextOnFocus: true,
216
+ align: "right",
217
+ showNumberSteppers: false
218
+ })
219
+ })
220
+ ]
221
+ })
222
+ ]
223
+ });
224
+ }
225
+ export default RangeSlider;
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import { Spinner, VerticalStack } from "../index.js";
4
+ var styles = tv({
5
+ base: "Litho-ResourceList flex flex-col min-w-72",
6
+ variants: {
7
+ divider: {
8
+ true: "divide-y divide-edge-default",
9
+ false: ""
10
+ }
11
+ }
12
+ });
13
+ /**
14
+ * ResourceList component displays a list of items with loading and empty states.
15
+ *
16
+ * @component
17
+ * @param {Object} props - The component props.
18
+ * @param {Array} [props.items=[]] - List of items to display.
19
+ * @param {boolean} [props.loading=false] - Whether the list is in a loading state.
20
+ * @param {string|React.ReactNode} [props.emptyState="No results found."] - Content to display when the list is empty.
21
+ * @param {Function} props.renderItem - Function to render each item in the list.
22
+ * @param {Object} [props.resourceName] - Object containing singular and plural resource names.
23
+ * @param {string} [props.resourceName.singular] - Singular resource name.
24
+ * @param {string} [props.resourceName.plural] - Plural resource name.
25
+ * @param {boolean} [props.divider=true] - Whether to show dividers between items.
26
+ * @param {"none"|"small"|"large"} [props.gap="none"] - Gap size between items.
27
+ * @returns {JSX.Element} The rendered component.
28
+ */ function ResourceList() {
29
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
30
+ 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 ? {
31
+ singular: "item",
32
+ plural: "items"
33
+ } : _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;
34
+ var gapMap = {
35
+ none: "0",
36
+ small: "2",
37
+ large: "4"
38
+ };
39
+ return /*#__PURE__*/ _jsx(VerticalStack, {
40
+ gap: gapMap[gap],
41
+ className: styles({
42
+ divider: divider
43
+ }),
44
+ children: loading && items.length === 0 ? /*#__PURE__*/ _jsx("div", {
45
+ className: "flex justify-center items-center p-3",
46
+ children: /*#__PURE__*/ _jsx(Spinner, {
47
+ size: "small"
48
+ })
49
+ }, "".concat(resourceName.singular, "-loading")) : items.length > 0 ? items.map(function(item, index) {
50
+ return renderItem(item, index);
51
+ }) : typeof emptyState === "string" ? /*#__PURE__*/ _jsx("div", {
52
+ className: "py-3 px-4 text-center",
53
+ children: emptyState
54
+ }, "".concat(resourceName.plural, "-empty")) : emptyState
55
+ });
56
+ }
57
+ var itemStyles = tv({
58
+ base: "Litho-ResourceList-Item py-3 px-4 cursor-pointer",
59
+ variants: {
60
+ selected: {
61
+ true: "bg-surface-higher",
62
+ false: "hover:bg-surface-higher"
63
+ }
64
+ }
65
+ });
66
+ /**
67
+ * Item component represents a single item in the ResourceList.
68
+ *
69
+ * @component
70
+ * @param {Object} props - The component props.
71
+ * @param {string} [props.id] - The ID of the item.
72
+ * @param {string} [props.accessibilityLabel] - Accessibility label for the item.
73
+ * @param {Function} [props.onClick] - Callback function when the item is clicked.
74
+ * @param {boolean} [props.selected] - Whether the item is selected.
75
+ * @param {React.ReactNode} props.children - The content inside the item.
76
+ * @param {string} [props.className] - Additional CSS classes for styling.
77
+ * @returns {JSX.Element} The rendered component.
78
+ */ function Item() {
79
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
80
+ var id = props.id, accessibilityLabel = props.accessibilityLabel, onClick = props.onClick, selected = props.selected, children = props.children, className = props.className;
81
+ var classes = itemStyles({
82
+ selected: selected
83
+ });
84
+ return /*#__PURE__*/ _jsx("div", {
85
+ id: id,
86
+ className: "".concat(classes).concat(className ? " ".concat(className) : ""),
87
+ role: "button",
88
+ tabIndex: 0,
89
+ onClick: onClick,
90
+ "aria-label": accessibilityLabel,
91
+ children: children
92
+ });
93
+ }
94
+ ResourceList.Item = Item;
95
+ export default ResourceList;