@tinybigui/react 0.1.0-rc.1 → 0.1.0
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/dist/index.cjs +48 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -360
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
3
|
import { argbFromHex, themeFromSourceColor } from '@material/material-color-utilities';
|
|
4
4
|
export { argbFromHex, hexFromArgb } from '@material/material-color-utilities';
|
|
5
|
-
import
|
|
6
|
-
import { useButton, useTextField, useFocusRing, useCheckbox, VisuallyHidden, mergeProps, useSwitch, useRadioGroup, useRadio } from 'react-aria';
|
|
5
|
+
import { forwardRef, useRef, useEffect, createContext, useContext, useState, useCallback } from 'react';
|
|
6
|
+
import { useButton, useTextField, useFocusRing, useCheckbox, VisuallyHidden, mergeProps as mergeProps$1, useSwitch, useRadioGroup, useRadio } from 'react-aria';
|
|
7
|
+
import { mergeProps, filterDOMProps } from '@react-aria/utils';
|
|
7
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
9
|
import { cva } from 'class-variance-authority';
|
|
10
|
+
import { useToggleState, useRadioGroupState } from 'react-stately';
|
|
9
11
|
|
|
10
12
|
// src/utils/cn.ts
|
|
11
13
|
function cn(...inputs) {
|
|
@@ -128,157 +130,6 @@ function truncateText(lines = 1) {
|
|
|
128
130
|
textOverflow: "ellipsis"
|
|
129
131
|
};
|
|
130
132
|
}
|
|
131
|
-
var $bdb11010cef70236$export$d41a04c74483c6ef = /* @__PURE__ */ new Map();
|
|
132
|
-
if (typeof FinalizationRegistry !== "undefined") new FinalizationRegistry((heldValue) => {
|
|
133
|
-
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);
|
|
134
|
-
});
|
|
135
|
-
function $bdb11010cef70236$export$cd8c9cb68f842629(idA, idB) {
|
|
136
|
-
if (idA === idB) return idA;
|
|
137
|
-
let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA);
|
|
138
|
-
if (setIdsA) {
|
|
139
|
-
setIdsA.forEach((ref) => ref.current = idB);
|
|
140
|
-
return idB;
|
|
141
|
-
}
|
|
142
|
-
let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB);
|
|
143
|
-
if (setIdsB) {
|
|
144
|
-
setIdsB.forEach((ref) => ref.current = idA);
|
|
145
|
-
return idA;
|
|
146
|
-
}
|
|
147
|
-
return idB;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ../../node_modules/.pnpm/@react-aria+utils@3.32.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@react-aria/utils/dist/chain.mjs
|
|
151
|
-
function $ff5963eb1fccf552$export$e08e3b67e392101e(...callbacks) {
|
|
152
|
-
return (...args) => {
|
|
153
|
-
for (let callback of callbacks) if (typeof callback === "function") callback(...args);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function $3ef42575df84b30b$export$9d1611c77c2fe928(...args) {
|
|
157
|
-
let result = {
|
|
158
|
-
...args[0]
|
|
159
|
-
};
|
|
160
|
-
for (let i = 1; i < args.length; i++) {
|
|
161
|
-
let props = args[i];
|
|
162
|
-
for (let key in props) {
|
|
163
|
-
let a = result[key];
|
|
164
|
-
let b = props[key];
|
|
165
|
-
if (typeof a === "function" && typeof b === "function" && // This is a lot faster than a regex.
|
|
166
|
-
key[0] === "o" && key[1] === "n" && key.charCodeAt(2) >= /* 'A' */
|
|
167
|
-
65 && key.charCodeAt(2) <= /* 'Z' */
|
|
168
|
-
90) result[key] = ($ff5963eb1fccf552$export$e08e3b67e392101e)(a, b);
|
|
169
|
-
else if ((key === "className" || key === "UNSAFE_className") && typeof a === "string" && typeof b === "string") result[key] = ($7jXr9$clsx)(a, b);
|
|
170
|
-
else if (key === "id" && a && b) result.id = ($bdb11010cef70236$export$cd8c9cb68f842629)(a, b);
|
|
171
|
-
else result[key] = b !== void 0 ? b : a;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ../../node_modules/.pnpm/@react-aria+utils@3.32.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@react-aria/utils/dist/filterDOMProps.mjs
|
|
178
|
-
var $65484d02dcb7eb3e$var$DOMPropNames = /* @__PURE__ */ new Set([
|
|
179
|
-
"id"
|
|
180
|
-
]);
|
|
181
|
-
var $65484d02dcb7eb3e$var$labelablePropNames = /* @__PURE__ */ new Set([
|
|
182
|
-
"aria-label",
|
|
183
|
-
"aria-labelledby",
|
|
184
|
-
"aria-describedby",
|
|
185
|
-
"aria-details"
|
|
186
|
-
]);
|
|
187
|
-
var $65484d02dcb7eb3e$var$linkPropNames = /* @__PURE__ */ new Set([
|
|
188
|
-
"href",
|
|
189
|
-
"hrefLang",
|
|
190
|
-
"target",
|
|
191
|
-
"rel",
|
|
192
|
-
"download",
|
|
193
|
-
"ping",
|
|
194
|
-
"referrerPolicy"
|
|
195
|
-
]);
|
|
196
|
-
var $65484d02dcb7eb3e$var$globalAttrs = /* @__PURE__ */ new Set([
|
|
197
|
-
"dir",
|
|
198
|
-
"lang",
|
|
199
|
-
"hidden",
|
|
200
|
-
"inert",
|
|
201
|
-
"translate"
|
|
202
|
-
]);
|
|
203
|
-
var $65484d02dcb7eb3e$var$globalEvents = /* @__PURE__ */ new Set([
|
|
204
|
-
"onClick",
|
|
205
|
-
"onAuxClick",
|
|
206
|
-
"onContextMenu",
|
|
207
|
-
"onDoubleClick",
|
|
208
|
-
"onMouseDown",
|
|
209
|
-
"onMouseEnter",
|
|
210
|
-
"onMouseLeave",
|
|
211
|
-
"onMouseMove",
|
|
212
|
-
"onMouseOut",
|
|
213
|
-
"onMouseOver",
|
|
214
|
-
"onMouseUp",
|
|
215
|
-
"onTouchCancel",
|
|
216
|
-
"onTouchEnd",
|
|
217
|
-
"onTouchMove",
|
|
218
|
-
"onTouchStart",
|
|
219
|
-
"onPointerDown",
|
|
220
|
-
"onPointerMove",
|
|
221
|
-
"onPointerUp",
|
|
222
|
-
"onPointerCancel",
|
|
223
|
-
"onPointerEnter",
|
|
224
|
-
"onPointerLeave",
|
|
225
|
-
"onPointerOver",
|
|
226
|
-
"onPointerOut",
|
|
227
|
-
"onGotPointerCapture",
|
|
228
|
-
"onLostPointerCapture",
|
|
229
|
-
"onScroll",
|
|
230
|
-
"onWheel",
|
|
231
|
-
"onAnimationStart",
|
|
232
|
-
"onAnimationEnd",
|
|
233
|
-
"onAnimationIteration",
|
|
234
|
-
"onTransitionCancel",
|
|
235
|
-
"onTransitionEnd",
|
|
236
|
-
"onTransitionRun",
|
|
237
|
-
"onTransitionStart"
|
|
238
|
-
]);
|
|
239
|
-
var $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/;
|
|
240
|
-
function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts = {}) {
|
|
241
|
-
let { labelable, isLink, global, events = global, propNames } = opts;
|
|
242
|
-
let filteredProps = {};
|
|
243
|
-
for (const prop in props) if (Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || isLink && $65484d02dcb7eb3e$var$linkPropNames.has(prop) || global && $65484d02dcb7eb3e$var$globalAttrs.has(prop) || events && ($65484d02dcb7eb3e$var$globalEvents.has(prop) || prop.endsWith("Capture") && $65484d02dcb7eb3e$var$globalEvents.has(prop.slice(0, -7))) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $65484d02dcb7eb3e$var$propRe.test(prop))) filteredProps[prop] = props[prop];
|
|
244
|
-
return filteredProps;
|
|
245
|
-
}
|
|
246
|
-
var $458b0a5536c1a7cf$var$_React_useInsertionEffect;
|
|
247
|
-
var $458b0a5536c1a7cf$var$useEarlyEffect = typeof document !== "undefined" ? ($458b0a5536c1a7cf$var$_React_useInsertionEffect = ($3whtM$react)["useInsertionEffect"]) !== null && $458b0a5536c1a7cf$var$_React_useInsertionEffect !== void 0 ? $458b0a5536c1a7cf$var$_React_useInsertionEffect : ($3whtM$react).useLayoutEffect : () => {
|
|
248
|
-
};
|
|
249
|
-
function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
250
|
-
let [stateValue, setStateValue] = (useState)(value || defaultValue);
|
|
251
|
-
let valueRef = (useRef)(stateValue);
|
|
252
|
-
let isControlledRef = (useRef)(value !== void 0);
|
|
253
|
-
let isControlled = value !== void 0;
|
|
254
|
-
(useEffect)(() => {
|
|
255
|
-
let wasControlled = isControlledRef.current;
|
|
256
|
-
if (wasControlled !== isControlled && process.env.NODE_ENV !== "production") console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
|
|
257
|
-
isControlledRef.current = isControlled;
|
|
258
|
-
}, [
|
|
259
|
-
isControlled
|
|
260
|
-
]);
|
|
261
|
-
let currentValue = isControlled ? value : stateValue;
|
|
262
|
-
$458b0a5536c1a7cf$var$useEarlyEffect(() => {
|
|
263
|
-
valueRef.current = currentValue;
|
|
264
|
-
});
|
|
265
|
-
let [, forceUpdate] = (useReducer)(() => ({}), {});
|
|
266
|
-
let setValue = (useCallback)((value2, ...args) => {
|
|
267
|
-
let newValue = typeof value2 === "function" ? value2(valueRef.current) : value2;
|
|
268
|
-
if (!Object.is(valueRef.current, newValue)) {
|
|
269
|
-
valueRef.current = newValue;
|
|
270
|
-
setStateValue(newValue);
|
|
271
|
-
forceUpdate();
|
|
272
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, ...args);
|
|
273
|
-
}
|
|
274
|
-
}, [
|
|
275
|
-
onChange
|
|
276
|
-
]);
|
|
277
|
-
return [
|
|
278
|
-
currentValue,
|
|
279
|
-
setValue
|
|
280
|
-
];
|
|
281
|
-
}
|
|
282
133
|
var ButtonHeadless = forwardRef(
|
|
283
134
|
({ className, children, tabIndex = 0, onMouseDown, type, ...restProps }, forwardedRef) => {
|
|
284
135
|
const internalRef = useRef(null);
|
|
@@ -300,7 +151,7 @@ var ButtonHeadless = forwardRef(
|
|
|
300
151
|
onPressUp: _onPressUp,
|
|
301
152
|
...htmlAttrs
|
|
302
153
|
} = restProps;
|
|
303
|
-
const mergedProps =
|
|
154
|
+
const mergedProps = mergeProps(
|
|
304
155
|
buttonProps,
|
|
305
156
|
{
|
|
306
157
|
tabIndex,
|
|
@@ -697,8 +548,8 @@ var IconButtonHeadless = forwardRef(
|
|
|
697
548
|
},
|
|
698
549
|
ref
|
|
699
550
|
);
|
|
700
|
-
const domProps =
|
|
701
|
-
const mergedProps =
|
|
551
|
+
const domProps = filterDOMProps(props);
|
|
552
|
+
const mergedProps = mergeProps(
|
|
702
553
|
buttonProps,
|
|
703
554
|
domProps,
|
|
704
555
|
{
|
|
@@ -956,7 +807,7 @@ var IconButton = forwardRef(
|
|
|
956
807
|
onMouseDown?.(e);
|
|
957
808
|
handleRipple(e);
|
|
958
809
|
};
|
|
959
|
-
const mergedPropsValue =
|
|
810
|
+
const mergedPropsValue = mergeProps(props, {
|
|
960
811
|
...onPress && { onPress },
|
|
961
812
|
onMouseDown: mergedOnMouseDown,
|
|
962
813
|
isDisabled
|
|
@@ -1016,8 +867,8 @@ var FABHeadless = forwardRef(
|
|
|
1016
867
|
},
|
|
1017
868
|
ref
|
|
1018
869
|
);
|
|
1019
|
-
const domProps =
|
|
1020
|
-
const mergedProps =
|
|
870
|
+
const domProps = filterDOMProps(props);
|
|
871
|
+
const mergedProps = mergeProps(buttonProps, domProps, {
|
|
1021
872
|
tabIndex,
|
|
1022
873
|
className,
|
|
1023
874
|
onMouseDown,
|
|
@@ -1284,7 +1135,7 @@ var FAB = forwardRef(
|
|
|
1284
1135
|
onMouseDown?.(e);
|
|
1285
1136
|
handleRipple(e);
|
|
1286
1137
|
};
|
|
1287
|
-
const mergedPropsValue =
|
|
1138
|
+
const mergedPropsValue = mergeProps(props, {
|
|
1288
1139
|
...onPress && { onPress },
|
|
1289
1140
|
onMouseDown: mergedOnMouseDown,
|
|
1290
1141
|
isDisabled
|
|
@@ -1644,7 +1495,7 @@ var TextFieldHeadless = forwardRef(
|
|
|
1644
1495
|
const displayErrorMessage = errorMessage ?? validationErrors.join(" ");
|
|
1645
1496
|
const currentValue = typeof inputProps.value === "string" ? inputProps.value : typeof inputProps.defaultValue === "string" ? inputProps.defaultValue : "";
|
|
1646
1497
|
if (typeof children === "function") {
|
|
1647
|
-
const mergedInputProps2 =
|
|
1498
|
+
const mergedInputProps2 = mergeProps(
|
|
1648
1499
|
inputProps,
|
|
1649
1500
|
focusProps
|
|
1650
1501
|
);
|
|
@@ -1686,7 +1537,7 @@ var TextFieldHeadless = forwardRef(
|
|
|
1686
1537
|
onFocusChange: _onFocusChange,
|
|
1687
1538
|
...htmlAttrs
|
|
1688
1539
|
} = restProps;
|
|
1689
|
-
const mergedInputProps =
|
|
1540
|
+
const mergedInputProps = mergeProps(inputProps, focusProps, htmlAttrs, {
|
|
1690
1541
|
className: inputClassName
|
|
1691
1542
|
});
|
|
1692
1543
|
return /* @__PURE__ */ jsxs("div", { className, style: fullWidth ? { width: "100%" } : void 0, children: [
|
|
@@ -1903,196 +1754,6 @@ var TextField = forwardRef(
|
|
|
1903
1754
|
}
|
|
1904
1755
|
);
|
|
1905
1756
|
TextField.displayName = "TextField";
|
|
1906
|
-
var $e5be200c675c3b3a$export$aca958c65c314e6c = {
|
|
1907
|
-
badInput: false,
|
|
1908
|
-
customError: false,
|
|
1909
|
-
patternMismatch: false,
|
|
1910
|
-
rangeOverflow: false,
|
|
1911
|
-
rangeUnderflow: false,
|
|
1912
|
-
stepMismatch: false,
|
|
1913
|
-
tooLong: false,
|
|
1914
|
-
tooShort: false,
|
|
1915
|
-
typeMismatch: false,
|
|
1916
|
-
valueMissing: false,
|
|
1917
|
-
valid: true
|
|
1918
|
-
};
|
|
1919
|
-
var $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE = {
|
|
1920
|
-
...$e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
1921
|
-
customError: true,
|
|
1922
|
-
valid: false
|
|
1923
|
-
};
|
|
1924
|
-
var $e5be200c675c3b3a$export$dad6ae84456c676a = {
|
|
1925
|
-
isInvalid: false,
|
|
1926
|
-
validationDetails: $e5be200c675c3b3a$export$aca958c65c314e6c,
|
|
1927
|
-
validationErrors: []
|
|
1928
|
-
};
|
|
1929
|
-
var $e5be200c675c3b3a$export$571b5131b7e65c11 = (createContext)({});
|
|
1930
|
-
var $e5be200c675c3b3a$export$a763b9476acd3eb = "__formValidationState" + Date.now();
|
|
1931
|
-
function $e5be200c675c3b3a$export$fc1a364ae1f3ff10(props) {
|
|
1932
|
-
if (props[$e5be200c675c3b3a$export$a763b9476acd3eb]) {
|
|
1933
|
-
let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$e5be200c675c3b3a$export$a763b9476acd3eb];
|
|
1934
|
-
return {
|
|
1935
|
-
realtimeValidation,
|
|
1936
|
-
displayValidation,
|
|
1937
|
-
updateValidation,
|
|
1938
|
-
resetValidation,
|
|
1939
|
-
commitValidation
|
|
1940
|
-
};
|
|
1941
|
-
}
|
|
1942
|
-
return $e5be200c675c3b3a$var$useFormValidationStateImpl(props);
|
|
1943
|
-
}
|
|
1944
|
-
function $e5be200c675c3b3a$var$useFormValidationStateImpl(props) {
|
|
1945
|
-
let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
|
|
1946
|
-
if (validationState) isInvalid || (isInvalid = validationState === "invalid");
|
|
1947
|
-
let controlledError = isInvalid !== void 0 ? {
|
|
1948
|
-
isInvalid,
|
|
1949
|
-
validationErrors: [],
|
|
1950
|
-
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
1951
|
-
} : null;
|
|
1952
|
-
let clientError = (useMemo)(() => {
|
|
1953
|
-
if (!validate || value == null) return null;
|
|
1954
|
-
let validateErrors = $e5be200c675c3b3a$var$runValidate(validate, value);
|
|
1955
|
-
return $e5be200c675c3b3a$var$getValidationResult(validateErrors);
|
|
1956
|
-
}, [
|
|
1957
|
-
validate,
|
|
1958
|
-
value
|
|
1959
|
-
]);
|
|
1960
|
-
if (builtinValidation === null || builtinValidation === void 0 ? void 0 : builtinValidation.validationDetails.valid) builtinValidation = void 0;
|
|
1961
|
-
let serverErrors = (useContext)($e5be200c675c3b3a$export$571b5131b7e65c11);
|
|
1962
|
-
let serverErrorMessages = (useMemo)(() => {
|
|
1963
|
-
if (name) return Array.isArray(name) ? name.flatMap((name2) => $e5be200c675c3b3a$var$asArray(serverErrors[name2])) : $e5be200c675c3b3a$var$asArray(serverErrors[name]);
|
|
1964
|
-
return [];
|
|
1965
|
-
}, [
|
|
1966
|
-
serverErrors,
|
|
1967
|
-
name
|
|
1968
|
-
]);
|
|
1969
|
-
let [lastServerErrors, setLastServerErrors] = (useState)(serverErrors);
|
|
1970
|
-
let [isServerErrorCleared, setServerErrorCleared] = (useState)(false);
|
|
1971
|
-
if (serverErrors !== lastServerErrors) {
|
|
1972
|
-
setLastServerErrors(serverErrors);
|
|
1973
|
-
setServerErrorCleared(false);
|
|
1974
|
-
}
|
|
1975
|
-
let serverError = (useMemo)(() => $e5be200c675c3b3a$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
|
|
1976
|
-
isServerErrorCleared,
|
|
1977
|
-
serverErrorMessages
|
|
1978
|
-
]);
|
|
1979
|
-
let nextValidation = (useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1980
|
-
let [currentValidity, setCurrentValidity] = (useState)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1981
|
-
let lastError = (useRef)($e5be200c675c3b3a$export$dad6ae84456c676a);
|
|
1982
|
-
let commitValidation = () => {
|
|
1983
|
-
if (!commitQueued) return;
|
|
1984
|
-
setCommitQueued(false);
|
|
1985
|
-
let error = clientError || builtinValidation || nextValidation.current;
|
|
1986
|
-
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
1987
|
-
lastError.current = error;
|
|
1988
|
-
setCurrentValidity(error);
|
|
1989
|
-
}
|
|
1990
|
-
};
|
|
1991
|
-
let [commitQueued, setCommitQueued] = (useState)(false);
|
|
1992
|
-
(useEffect)(commitValidation);
|
|
1993
|
-
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
1994
|
-
let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
1995
|
-
return {
|
|
1996
|
-
realtimeValidation,
|
|
1997
|
-
displayValidation,
|
|
1998
|
-
updateValidation(value2) {
|
|
1999
|
-
if (validationBehavior === "aria" && !$e5be200c675c3b3a$var$isEqualValidation(currentValidity, value2)) setCurrentValidity(value2);
|
|
2000
|
-
else nextValidation.current = value2;
|
|
2001
|
-
},
|
|
2002
|
-
resetValidation() {
|
|
2003
|
-
let error = $e5be200c675c3b3a$export$dad6ae84456c676a;
|
|
2004
|
-
if (!$e5be200c675c3b3a$var$isEqualValidation(error, lastError.current)) {
|
|
2005
|
-
lastError.current = error;
|
|
2006
|
-
setCurrentValidity(error);
|
|
2007
|
-
}
|
|
2008
|
-
if (validationBehavior === "native") setCommitQueued(false);
|
|
2009
|
-
setServerErrorCleared(true);
|
|
2010
|
-
},
|
|
2011
|
-
commitValidation() {
|
|
2012
|
-
if (validationBehavior === "native") setCommitQueued(true);
|
|
2013
|
-
setServerErrorCleared(true);
|
|
2014
|
-
}
|
|
2015
|
-
};
|
|
2016
|
-
}
|
|
2017
|
-
function $e5be200c675c3b3a$var$asArray(v) {
|
|
2018
|
-
if (!v) return [];
|
|
2019
|
-
return Array.isArray(v) ? v : [
|
|
2020
|
-
v
|
|
2021
|
-
];
|
|
2022
|
-
}
|
|
2023
|
-
function $e5be200c675c3b3a$var$runValidate(validate, value) {
|
|
2024
|
-
if (typeof validate === "function") {
|
|
2025
|
-
let e = validate(value);
|
|
2026
|
-
if (e && typeof e !== "boolean") return $e5be200c675c3b3a$var$asArray(e);
|
|
2027
|
-
}
|
|
2028
|
-
return [];
|
|
2029
|
-
}
|
|
2030
|
-
function $e5be200c675c3b3a$var$getValidationResult(errors) {
|
|
2031
|
-
return errors.length ? {
|
|
2032
|
-
isInvalid: true,
|
|
2033
|
-
validationErrors: errors,
|
|
2034
|
-
validationDetails: $e5be200c675c3b3a$var$CUSTOM_VALIDITY_STATE
|
|
2035
|
-
} : null;
|
|
2036
|
-
}
|
|
2037
|
-
function $e5be200c675c3b3a$var$isEqualValidation(a, b) {
|
|
2038
|
-
if (a === b) return true;
|
|
2039
|
-
return !!a && !!b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
|
|
2040
|
-
}
|
|
2041
|
-
var $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 1e10);
|
|
2042
|
-
var $a54cdc5c1942b639$var$i = 0;
|
|
2043
|
-
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
2044
|
-
let name = (useMemo)(() => props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
2045
|
-
props.name
|
|
2046
|
-
]);
|
|
2047
|
-
var _props_defaultValue;
|
|
2048
|
-
let [selectedValue, setSelected] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
2049
|
-
let [initialValue] = (useState)(selectedValue);
|
|
2050
|
-
let [lastFocusedValue, setLastFocusedValue] = (useState)(null);
|
|
2051
|
-
let validation = ($e5be200c675c3b3a$export$fc1a364ae1f3ff10)({
|
|
2052
|
-
...props,
|
|
2053
|
-
value: selectedValue
|
|
2054
|
-
});
|
|
2055
|
-
let setSelectedValue = (value) => {
|
|
2056
|
-
if (!props.isReadOnly && !props.isDisabled) {
|
|
2057
|
-
setSelected(value);
|
|
2058
|
-
validation.commitValidation();
|
|
2059
|
-
}
|
|
2060
|
-
};
|
|
2061
|
-
let isInvalid = validation.displayValidation.isInvalid;
|
|
2062
|
-
var _props_defaultValue1;
|
|
2063
|
-
return {
|
|
2064
|
-
...validation,
|
|
2065
|
-
name,
|
|
2066
|
-
selectedValue,
|
|
2067
|
-
defaultSelectedValue: props.value !== void 0 ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
|
|
2068
|
-
setSelectedValue,
|
|
2069
|
-
lastFocusedValue,
|
|
2070
|
-
setLastFocusedValue,
|
|
2071
|
-
isDisabled: props.isDisabled || false,
|
|
2072
|
-
isReadOnly: props.isReadOnly || false,
|
|
2073
|
-
isRequired: props.isRequired || false,
|
|
2074
|
-
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
2075
|
-
isInvalid
|
|
2076
|
-
};
|
|
2077
|
-
}
|
|
2078
|
-
function $3017fa7ffdddec74$export$8042c6c013fd5226(props = {}) {
|
|
2079
|
-
let { isReadOnly } = props;
|
|
2080
|
-
let [isSelected, setSelected] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.isSelected, props.defaultSelected || false, props.onChange);
|
|
2081
|
-
let [initialValue] = (useState)(isSelected);
|
|
2082
|
-
function updateSelected(value) {
|
|
2083
|
-
if (!isReadOnly) setSelected(value);
|
|
2084
|
-
}
|
|
2085
|
-
function toggleState() {
|
|
2086
|
-
if (!isReadOnly) setSelected(!isSelected);
|
|
2087
|
-
}
|
|
2088
|
-
var _props_defaultSelected;
|
|
2089
|
-
return {
|
|
2090
|
-
isSelected,
|
|
2091
|
-
defaultSelected: (_props_defaultSelected = props.defaultSelected) !== null && _props_defaultSelected !== void 0 ? _props_defaultSelected : initialValue,
|
|
2092
|
-
setSelected: updateSelected,
|
|
2093
|
-
toggle: toggleState
|
|
2094
|
-
};
|
|
2095
|
-
}
|
|
2096
1757
|
var checkboxVariants = cva(
|
|
2097
1758
|
[
|
|
2098
1759
|
// Base classes (always applied to label wrapper)
|
|
@@ -2308,7 +1969,7 @@ var Checkbox = forwardRef(
|
|
|
2308
1969
|
title: _htmlTitle,
|
|
2309
1970
|
...restPropsWithoutHtmlAttrs
|
|
2310
1971
|
} = props;
|
|
2311
|
-
const state =
|
|
1972
|
+
const state = useToggleState(restPropsWithoutHtmlAttrs);
|
|
2312
1973
|
const { inputProps, labelProps } = useCheckbox(
|
|
2313
1974
|
restPropsWithoutHtmlAttrs,
|
|
2314
1975
|
state,
|
|
@@ -2346,7 +2007,7 @@ var Checkbox = forwardRef(
|
|
|
2346
2007
|
"data-testid": dataTestId,
|
|
2347
2008
|
title: htmlTitle,
|
|
2348
2009
|
children: [
|
|
2349
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps(inputProps, focusProps), ref, id: htmlId }) }),
|
|
2010
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps$1(inputProps, focusProps), ref, id: htmlId }) }),
|
|
2350
2011
|
/* @__PURE__ */ jsxs(
|
|
2351
2012
|
"div",
|
|
2352
2013
|
{
|
|
@@ -2725,7 +2386,7 @@ var Switch = forwardRef(
|
|
|
2725
2386
|
title: _htmlTitle,
|
|
2726
2387
|
...restPropsWithoutHtmlAttrs
|
|
2727
2388
|
} = props;
|
|
2728
|
-
const state =
|
|
2389
|
+
const state = useToggleState(restPropsWithoutHtmlAttrs);
|
|
2729
2390
|
const { inputProps, labelProps, isPressed } = useSwitch(
|
|
2730
2391
|
restPropsWithoutHtmlAttrs,
|
|
2731
2392
|
state,
|
|
@@ -2757,7 +2418,7 @@ var Switch = forwardRef(
|
|
|
2757
2418
|
"data-testid": dataTestId,
|
|
2758
2419
|
title: htmlTitle,
|
|
2759
2420
|
children: [
|
|
2760
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps(inputProps, focusProps), ref, id: htmlId }) }),
|
|
2421
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps$1(inputProps, focusProps), ref, id: htmlId }) }),
|
|
2761
2422
|
/* @__PURE__ */ jsxs(
|
|
2762
2423
|
"div",
|
|
2763
2424
|
{
|
|
@@ -2856,7 +2517,7 @@ var RadioGroupHeadless = forwardRef(
|
|
|
2856
2517
|
({ className, children, renderLabel, ...props }, forwardedRef) => {
|
|
2857
2518
|
const internalRef = useRef(null);
|
|
2858
2519
|
const ref = forwardedRef ?? internalRef;
|
|
2859
|
-
const state =
|
|
2520
|
+
const state = useRadioGroupState(props);
|
|
2860
2521
|
const { radioGroupProps, labelProps } = useRadioGroup(props, state);
|
|
2861
2522
|
const dataTestId = props["data-testid"];
|
|
2862
2523
|
return /* @__PURE__ */ jsxs("div", { ...radioGroupProps, ref, className, "data-testid": dataTestId, children: [
|
|
@@ -3152,7 +2813,7 @@ var Radio = forwardRef(
|
|
|
3152
2813
|
"data-testid": dataTestId,
|
|
3153
2814
|
title: htmlTitle,
|
|
3154
2815
|
children: [
|
|
3155
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps(inputProps, focusProps), ref, id: htmlId }) }),
|
|
2816
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...mergeProps$1(inputProps, focusProps), ref, id: htmlId }) }),
|
|
3156
2817
|
/* @__PURE__ */ jsxs(
|
|
3157
2818
|
"div",
|
|
3158
2819
|
{
|
|
@@ -3245,7 +2906,7 @@ var RadioGroup = forwardRef(
|
|
|
3245
2906
|
children,
|
|
3246
2907
|
// State props
|
|
3247
2908
|
orientation = "vertical",
|
|
3248
|
-
isInvalid = false,
|
|
2909
|
+
isInvalid: _isInvalid = false,
|
|
3249
2910
|
isDisabled = false,
|
|
3250
2911
|
// Styling
|
|
3251
2912
|
className,
|