@pickle-ui/react 1.0.0-beta.8 → 1.0.0-beta.9
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/README.md +11 -10
- package/dist/components/Alert.d.ts +4 -6
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +4 -6
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/_internal/VisuallyHiddenInput.d.ts.map +1 -1
- package/dist/components/_internal/VisuallyHiddenInput.js +24 -42
- package/dist/components/_internal/VisuallyHiddenInput.js.map +1 -1
- package/dist/components/form/Form.context.d.ts.map +1 -1
- package/dist/components/form/Form.context.js +2 -3
- package/dist/components/form/Form.context.js.map +1 -1
- package/dist/components/form/FormField.js +2 -2
- package/dist/components/form/FormField.js.map +1 -1
- package/dist/components/form/Input.d.ts.map +1 -1
- package/dist/components/form/Input.js +22 -7
- package/dist/components/form/Input.js.map +1 -1
- package/dist/components/form/Slider.d.ts +1 -1
- package/dist/components/form/Slider.d.ts.map +1 -1
- package/dist/hooks/use-lazy-ref.d.ts.map +1 -1
- package/dist/hooks/use-lazy-ref.js +3 -4
- package/dist/hooks/use-lazy-ref.js.map +1 -1
- package/dist/lib/compose-refs.d.ts +0 -8
- package/dist/lib/compose-refs.d.ts.map +1 -1
- package/dist/lib/compose-refs.js +6 -19
- package/dist/lib/compose-refs.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Alert.tsx +4 -6
- package/src/components/_internal/VisuallyHiddenInput.tsx +33 -51
- package/src/components/form/ColorPickerPrimitive.tsx +1 -1
- package/src/components/form/Form.context.ts +2 -3
- package/src/components/form/FormField.tsx +2 -2
- package/src/components/form/Input.tsx +65 -28
- package/src/components/form/RadioGroup.test.tsx +1 -3
- package/src/components/form/Slider.tsx +1 -1
- package/src/hooks/use-lazy-ref.ts +3 -5
- package/src/lib/color.test.ts +1 -3
- package/src/lib/compose-refs.ts +7 -19
package/README.md
CHANGED
|
@@ -125,6 +125,7 @@ the element they render, for example
|
|
|
125
125
|
`Text` and the layout primitives take `as` to change their tag. Parts are
|
|
126
126
|
reached through their component (`Popover.Title`), never imported under their
|
|
127
127
|
own names.
|
|
128
|
+
|
|
128
129
|
Icons are plain SVG children: any icon library works, and buttons, badges and
|
|
129
130
|
input addons size and space the SVG for you.
|
|
130
131
|
|
|
@@ -230,9 +231,10 @@ own:
|
|
|
230
231
|
the light and dark values. Import it to share Pickle's palette in a project
|
|
231
232
|
that does not use the components. It re-exports `@pickle-ui/tokens/theme.css`,
|
|
232
233
|
which `@pickle-ui/react` installs as a dependency.
|
|
233
|
-
- `@pickle-ui/react/base.css` holds everything else: animation and variant
|
|
234
|
-
the `.dark` variant, the `Text` type scale (from
|
|
235
|
-
`@pickle-ui/tokens/typography.css`), shared utilities, and element resets.
|
|
234
|
+
- `@pickle-ui/react/base.css` holds everything else: animation and variant
|
|
235
|
+
plugins, the `.dark` variant, the `Text` type scale (from
|
|
236
|
+
`@pickle-ui/tokens/typography.css`), shared utilities, and element resets.
|
|
237
|
+
Import it with a token set of your own instead of `theme.css`.
|
|
236
238
|
|
|
237
239
|
Tokens follow one naming rule: `--x` is a fill and `--x-foreground` is the text
|
|
238
240
|
placed on that fill. Status colors (`destructive`, `info`, `success`,
|
|
@@ -445,8 +447,8 @@ breaking change.
|
|
|
445
447
|
|
|
446
448
|
## Upgrading from 0.x
|
|
447
449
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
+
Version 1.0 renames a few styling APIs. Search your code for these and update
|
|
451
|
+
them:
|
|
450
452
|
|
|
451
453
|
- **Package name.** `pickle-ui` is now published as `@pickle-ui/react`.
|
|
452
454
|
Replace the dependency and every import, stylesheets included:
|
|
@@ -485,11 +487,10 @@ pnpm run lint
|
|
|
485
487
|
|
|
486
488
|
## Releasing
|
|
487
489
|
|
|
488
|
-
Releases use [Changesets](https://changesets.dev)
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
new `@pickle-ui/tokens` release always comes with a new `@pickle-ui/react`.
|
|
490
|
+
Releases use [Changesets](https://changesets.dev): every pull request that
|
|
491
|
+
changes a package adds one (`pnpm changeset`), and merging the "Version
|
|
492
|
+
Packages" pull request on `main` publishes. The repository's
|
|
493
|
+
`.changeset/README.md` has the rules.
|
|
493
494
|
|
|
494
495
|
## License
|
|
495
496
|
|
|
@@ -18,12 +18,10 @@ declare function AlertDescription({ className, ...props }: AlertDescriptionProps
|
|
|
18
18
|
*/
|
|
19
19
|
declare function AlertIcon({ className, ...props }: AlertIconProps): React.JSX.Element;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* pass `role="alert"` for urgent messages (failures) or `role="status"` for
|
|
26
|
-
* polite ones (confirmations, info).
|
|
21
|
+
* No live-region role by default, so static notices are not announced on page
|
|
22
|
+
* load. When the alert appears in response to a user action, pass
|
|
23
|
+
* `role="alert"` for urgent messages (failures) or `role="status"` for polite
|
|
24
|
+
* ones (confirmations, info).
|
|
27
25
|
*/
|
|
28
26
|
declare function AlertRoot({ className, variant, ...props }: AlertProps): React.JSX.Element;
|
|
29
27
|
declare function AlertTitle({ className, ...props }: AlertTitleProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAA,MAAM,aAAa;;8EAoBlB,CAAC;AAEF,KAAK,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACpD,KAAK,qBAAqB,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AACxE,KA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AS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,qBAW7D;AAED,iBAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,qBAAqB,qBAcvE;AAED;;;;GAIG;AACH,iBAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,qBAYzD;AAED;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,EAAE,SAAS,EAAE,OAAmB,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,qBAS1E;AAED,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,qBAa3D;AAED,QAAA,MAAM,KAAK;;;;;CAKT,CAAC;AAEH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACvE,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,eAAe,GAChB,CAAC"}
|
package/dist/components/Alert.js
CHANGED
|
@@ -31,12 +31,10 @@ function AlertIcon({ className, ...props }) {
|
|
|
31
31
|
return (_jsx("div", { "aria-hidden": true, className: cn("col-start-1 row-start-1 flex h-5 items-center [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className), "data-slot": "alert-icon", ...props }));
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* pass `role="alert"` for urgent messages (failures) or `role="status"` for
|
|
39
|
-
* polite ones (confirmations, info).
|
|
34
|
+
* No live-region role by default, so static notices are not announced on page
|
|
35
|
+
* load. When the alert appears in response to a user action, pass
|
|
36
|
+
* `role="alert"` for urgent messages (failures) or `role="status"` for polite
|
|
37
|
+
* ones (confirmations, info).
|
|
40
38
|
*/
|
|
41
39
|
function AlertRoot({ className, variant = 'default', ...props }) {
|
|
42
40
|
return (_jsx("div", { className: cn(alertVariants({ variant }), className), "data-slot": "alert", "data-variant": variant, ...props }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAC;AAE9C,MAAM,aAAa,GAAG,GAAG,CACvB,0SAA0S,EAC1S;IACE,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EACL,6EAA6E;YAC/E,WAAW,EACT,uGAAuG;YACzG,IAAI,EAAE,kFAAkF;YACxF,OAAO,EACL,2FAA2F;YAC7F,OAAO,EACL,2FAA2F;SAC9F;KACF;CACF,CACF,CAAC;AASF,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAoB;IAC5D,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CACX,iHAAiH,EACjH,SAAS,CACV,eACS,cAAc,KACpB,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAyB;IACtE,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAC,KAAK,EACR,SAAS,EAAE,EAAE,CACX,gFAAgF,EAChF,SAAS,CACV,eACS,mBAAmB,EAC7B,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,MAAM,KACV,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IACxD,OAAO,CACL,mCAEE,SAAS,EAAE,EAAE,CACX,iIAAiI,EACjI,SAAS,CACV,eACS,YAAY,KAClB,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAC;AAE9C,MAAM,aAAa,GAAG,GAAG,CACvB,0SAA0S,EAC1S;IACE,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EACL,6EAA6E;YAC/E,WAAW,EACT,uGAAuG;YACzG,IAAI,EAAE,kFAAkF;YACxF,OAAO,EACL,2FAA2F;YAC7F,OAAO,EACL,2FAA2F;SAC9F;KACF;CACF,CACF,CAAC;AASF,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAoB;IAC5D,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CACX,iHAAiH,EACjH,SAAS,CACV,eACS,cAAc,KACpB,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAyB;IACtE,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAC,KAAK,EACR,SAAS,EAAE,EAAE,CACX,gFAAgF,EAChF,SAAS,CACV,eACS,mBAAmB,EAC7B,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,MAAM,KACV,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAkB;IACxD,OAAO,CACL,mCAEE,SAAS,EAAE,EAAE,CACX,iIAAiI,EACjI,SAAS,CACV,eACS,YAAY,KAClB,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,KAAK,EAAc;IACzE,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,eAC1C,OAAO,kBACH,OAAO,KACjB,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmB;IAC1D,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAC,KAAK,EACR,SAAS,EAAE,EAAE,CACX,kFAAkF,EAClF,SAAS,CACV,eACS,aAAa,EACvB,OAAO,EAAC,MAAM,KACV,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;IACrC,MAAM,EAAE,WAAW;IACnB,WAAW,EAAE,gBAAgB;IAC7B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,UAAU;CAClB,CAAC,CAAC;AAEH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisuallyHiddenInput.d.ts","sourceRoot":"","sources":["../../../src/components/_internal/VisuallyHiddenInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEpC,UAAU,wBAAwB,CAAC,CAAC,GAAG,UAAU,CAAE,SAAQ,IAAI,CAC7D,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,SAAS,GAAG,SAAS,GAAG,OAAO,CAChC;IACC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,CAAC,CAAC;CACX;
|
|
1
|
+
{"version":3,"file":"VisuallyHiddenInput.d.ts","sourceRoot":"","sources":["../../../src/components/_internal/VisuallyHiddenInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEpC,UAAU,wBAAwB,CAAC,CAAC,GAAG,UAAU,CAAE,SAAQ,IAAI,CAC7D,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAC3C,SAAS,GAAG,SAAS,GAAG,OAAO,CAChC;IACC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,CAAC,CAAC;CACX;AAgCD,iBAAS,mBAAmB,CAAC,CAAC,GAAG,UAAU,EACzC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,qBA8FnC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
const noSize = {};
|
|
5
|
+
// The snapshot is a string so React can compare it by value; an object would be
|
|
6
|
+
// a new snapshot on every read and re-render forever.
|
|
7
|
+
function useElementSize(element) {
|
|
8
|
+
const subscribe = React.useCallback((onChange) => {
|
|
9
|
+
if (!element)
|
|
10
|
+
return () => { };
|
|
11
|
+
const resizeObserver = new ResizeObserver(onChange);
|
|
12
|
+
resizeObserver.observe(element, { box: 'border-box' });
|
|
13
|
+
return () => {
|
|
14
|
+
resizeObserver.disconnect();
|
|
15
|
+
};
|
|
16
|
+
}, [element]);
|
|
17
|
+
const getSnapshot = () => element ? `${element.offsetWidth}x${element.offsetHeight}` : '';
|
|
18
|
+
const snapshot = React.useSyncExternalStore(subscribe, getSnapshot, () => '');
|
|
19
|
+
return React.useMemo(() => {
|
|
20
|
+
if (!snapshot)
|
|
21
|
+
return noSize;
|
|
22
|
+
const [width, height] = snapshot.split('x').map(Number);
|
|
23
|
+
return { height, width };
|
|
24
|
+
}, [snapshot]);
|
|
25
|
+
}
|
|
4
26
|
function VisuallyHiddenInput(props) {
|
|
5
27
|
const { bubbles = true, checked, control, style, type = 'hidden', value, ...inputProps
|
|
6
|
-
// react-doctor-disable-next-line react-doctor/no-event-handler --
|
|
28
|
+
// react-doctor-disable-next-line react-doctor/no-event-handler -- an effect mirrors value/checked into the native input and dispatches its event: prop changes drive it, not a user event
|
|
7
29
|
} = props;
|
|
8
30
|
const isCheckInput = React.useMemo(() => type === 'checkbox' || type === 'radio' || type === 'switch', [type]);
|
|
9
31
|
const inputRef = React.useRef(null);
|
|
@@ -19,47 +41,7 @@ function VisuallyHiddenInput(props) {
|
|
|
19
41
|
}
|
|
20
42
|
return prevValueRef.current.previous;
|
|
21
43
|
}, [isCheckInput, value, checked]);
|
|
22
|
-
const
|
|
23
|
-
// react-doctor-disable-next-line react-doctor/no-cascading-set-state -- this effect measures the control element and only calls setControlSize in mutually exclusive branches (or inside an async ResizeObserver callback), not as a synchronous render cascade
|
|
24
|
-
React.useLayoutEffect(() => {
|
|
25
|
-
if (!control) {
|
|
26
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect -- reset measured size synchronously when the control is removed so the hidden input does not retain a stale size
|
|
27
|
-
setControlSize({});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
setControlSize({
|
|
31
|
-
height: control.offsetHeight,
|
|
32
|
-
width: control.offsetWidth,
|
|
33
|
-
});
|
|
34
|
-
if (typeof window === 'undefined')
|
|
35
|
-
return;
|
|
36
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
37
|
-
if (!Array.isArray(entries) || !entries.length)
|
|
38
|
-
return;
|
|
39
|
-
const entry = entries[0];
|
|
40
|
-
if (!entry)
|
|
41
|
-
return;
|
|
42
|
-
let width;
|
|
43
|
-
let height;
|
|
44
|
-
if ('borderBoxSize' in entry) {
|
|
45
|
-
const borderSizeEntry = entry.borderBoxSize;
|
|
46
|
-
const borderSize = Array.isArray(borderSizeEntry)
|
|
47
|
-
? borderSizeEntry[0]
|
|
48
|
-
: borderSizeEntry;
|
|
49
|
-
width = borderSize.inlineSize;
|
|
50
|
-
height = borderSize.blockSize;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
width = control.offsetWidth;
|
|
54
|
-
height = control.offsetHeight;
|
|
55
|
-
}
|
|
56
|
-
setControlSize({ height, width });
|
|
57
|
-
});
|
|
58
|
-
resizeObserver.observe(control, { box: 'border-box' });
|
|
59
|
-
return () => {
|
|
60
|
-
resizeObserver.disconnect();
|
|
61
|
-
};
|
|
62
|
-
}, [control]);
|
|
44
|
+
const controlSize = useElementSize(control);
|
|
63
45
|
React.useEffect(() => {
|
|
64
46
|
const input = inputRef.current;
|
|
65
47
|
if (!input)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisuallyHiddenInput.js","sourceRoot":"","sources":["../../../src/components/_internal/VisuallyHiddenInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,
|
|
1
|
+
{"version":3,"file":"VisuallyHiddenInput.js","sourceRoot":"","sources":["../../../src/components/_internal/VisuallyHiddenInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAgB/B,MAAM,MAAM,GAAwC,EAAE,CAAC;AAEvD,gFAAgF;AAChF,sDAAsD;AACtD,SAAS,cAAc,CAAC,OAA2B;IACjD,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CACjC,CAAC,QAAoB,EAAE,EAAE;QACvB,IAAI,CAAC,OAAO;YAAE,OAA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b,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,gBACE,IAAI,EAAE,IAAI,KACN,UAAU,iBACD,YAAY,EACzB,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAClD,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,CAAC,CAAC,GACZ,CACH,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.context.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,gBAAgB,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AACF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF,KAAK,0BAA0B,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AACF,KAAK,kBAAkB,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG;IAC7D,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,gBAAgB,6CAErB,CAAC;AACF,QAAA,MAAM,qBAAqB,wBAA6B,CAAC;AAEzD,iBAAS,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,SAAS,CAgBxD;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,sBAI7C;
|
|
1
|
+
{"version":3,"file":"Form.context.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,KAAK,gBAAgB,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AACF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF,KAAK,0BAA0B,GAAG;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AACF,KAAK,kBAAkB,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG;IAC7D,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,gBAAgB,6CAErB,CAAC;AACF,QAAA,MAAM,qBAAqB,wBAA6B,CAAC;AAEzD,iBAAS,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,SAAS,CAgBxD;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,sBAI7C;AAID,iBAAS,mBAAmB,CAC1B,KAAK,GAAE,gBAAqB,EAC5B,EAAE,OAAc,EAAE,GAAE,0BAA+B;;;EAkBpD;AAED,iBAAS,cAAc,kBAUtB;AAED,iBAAS,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,UAU5E;AAED,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GACrB,CAAC;AACF,YAAY,EACV,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,GACnB,CAAC"}
|
|
@@ -18,9 +18,8 @@ function useFieldName(name) {
|
|
|
18
18
|
const field = React.useContext(FormFieldContext);
|
|
19
19
|
return name ?? field?.name;
|
|
20
20
|
}
|
|
21
|
-
// React Hook Form
|
|
22
|
-
//
|
|
23
|
-
// visible control.
|
|
21
|
+
// React Hook Form tracks field state but attaches no aria or id props to
|
|
22
|
+
// custom controls: this maps the current Form.Field onto its visible control.
|
|
24
23
|
function useFormControlProps(props = {}, { enabled = true } = {}) {
|
|
25
24
|
const field = React.useContext(FormFieldContext);
|
|
26
25
|
const { control, getFieldState } = useFormMethods();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.context.js","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,cAAc,EAEd,YAAY,GACb,MAAM,iBAAiB,CAAC;AAgBzB,MAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAC1C,IAAI,CACL,CAAC;AACF,MAAM,qBAAqB,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAEzD,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAI,KAA+B,CAAC,OAAO,CAAC;IAEzD,IACE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;QAC7B,OAAO,OAAO,KAAK,QAAQ;QAC3B,OAAO,OAAO,KAAK,QAAQ,EAC3B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,IAAwB;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAEjD,OAAO,IAAI,IAAI,KAAK,EAAE,IAAI,CAAC;AAC7B,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"Form.context.js","sourceRoot":"","sources":["../../../src/components/form/Form.context.ts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AAK,EAAE,IAAI;QACX,IAAI;KACL,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAEtE,OAAO;QACL,cAAc,EAAE,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACvD,EAAE,EAAE,SAAS,IAAI,KAAK,CAAC,EAAE;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,OAAO,GAAG,cAAc,EAA0B,CAAC;IAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAwB,EAAE,aAAqB;IAC3E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,aAAa,4DAA4D,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,oBAAoB,GACrB,CAAC"}
|
|
@@ -21,8 +21,8 @@ function FormField({ children, className, controlId: controlIdProp, description,
|
|
|
21
21
|
});
|
|
22
22
|
const fieldError = name ? getFieldState(name, formState).error : undefined;
|
|
23
23
|
const errorMessage = error ?? getErrorMessage(fieldError);
|
|
24
|
-
// The
|
|
25
|
-
//
|
|
24
|
+
// The label focuses the control by this id; `useId` keeps it unique across
|
|
25
|
+
// forms and rows.
|
|
26
26
|
const generatedControlId = React.useId();
|
|
27
27
|
const controlId = controlIdProp ?? generatedControlId;
|
|
28
28
|
const nativeLabel = shouldUseNativeFieldLabel(children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/form/FormField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAA4B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAwB,cAAc,EAAE,MAAM,cAAc,CAAC;AAapE,SAAS,SAAS,CAAC,EACjB,QAAQ,EACR,SAAS,EACT,SAAS,EAAE,aAAa,EACxB,WAAW,EACX,KAAK,EACL,KAAK,EACL,GAAG,KAAK,EACO;IACf,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE,CAAC;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,MAAM,SAAS,GAAG,YAAY,CAAC;QAC7B,OAAO;QACP,QAAQ,EAAE,CAAC,IAAI;QACf,KAAK,EAAE,IAAI;QACX,IAAI;KACL,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,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S,mBAAmB,CAC1B,KAAsB;IAEtB,OAAO,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC;AACtE,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAyB;IAC1D,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC3C,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,CACxE,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/form/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAS1D,KAAK,UAAU,GAAG,IAAI,CACpB,cAAc,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAC5D,MAAM,CACP,GAAG;IACF,qFAAqF;IACrF,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/form/Input.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAS1D,KAAK,UAAU,GAAG,IAAI,CACpB,cAAc,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAC5D,MAAM,CACP,GAAG;IACF,qFAAqF;IACrF,UAAU,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAyDF,iBAAS,KAAK,CAAC,EACb,SAAS,EACT,UAAU,EACV,WAAmB,EACnB,IAAW,EACX,KAAK,EACL,QAAgB,EAChB,GAAG,KAAK,EACT,EAAE,UAAU,qBAsCZ;AAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -8,15 +8,30 @@ const inputControlHeights = {
|
|
|
8
8
|
md: 'h-8',
|
|
9
9
|
sm: 'h-7',
|
|
10
10
|
};
|
|
11
|
+
function getControlClassName({ className, size, unstyled, }) {
|
|
12
|
+
return (cn(!unstyled &&
|
|
13
|
+
cn(inputControlHeights[size], 'border-input bg-background text-foreground ring-ring/24 has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 relative inline-flex w-full rounded-lg border text-base shadow-xs/5 transition-shadow not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:ring-[3px] has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none sm:text-sm dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]'), className) || undefined);
|
|
14
|
+
}
|
|
15
|
+
function getInputClassName({ inputClassNames, size, type, unstyled, }) {
|
|
16
|
+
return cn(unstyled
|
|
17
|
+
? cn('w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72', inputControlHeights[size], size === 'sm' && 'px-[calc(--spacing(2.5)-1px)]', size === 'lg' && 'px-[calc(--spacing(3.5)-1px)]')
|
|
18
|
+
: cn('h-full min-h-0 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72', size === 'sm' && 'px-[calc(--spacing(2.5)-1px)]', size === 'lg' && 'px-[calc(--spacing(3.5)-1px)]'), type === 'search' &&
|
|
19
|
+
'[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none', type === 'file' &&
|
|
20
|
+
'text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm', inputClassNames);
|
|
21
|
+
}
|
|
11
22
|
function Input({ className, classNames, nativeInput = false, size = 'md', style, unstyled = false, ...props }) {
|
|
12
23
|
const resolvedSize = typeof size === 'number' ? 'md' : size;
|
|
13
|
-
const inputClassName =
|
|
14
|
-
|
|
15
|
-
:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const inputClassName = getInputClassName({
|
|
25
|
+
inputClassNames: classNames?.input,
|
|
26
|
+
size: resolvedSize,
|
|
27
|
+
type: props.type,
|
|
28
|
+
unstyled,
|
|
29
|
+
});
|
|
30
|
+
return (_jsx("span", { className: getControlClassName({
|
|
31
|
+
className,
|
|
32
|
+
size: resolvedSize,
|
|
33
|
+
unstyled,
|
|
34
|
+
}), "data-size": resolvedSize, "data-slot": "input-control", children: nativeInput ? (_jsx("input", { className: inputClassName, "data-slot": "input", size: typeof size === 'number' ? size : undefined, style: typeof style === 'function' ? undefined : style, ...props })) : (_jsx(InputPrimitive, { className: inputClassName, "data-slot": "input", size: typeof size === 'number' ? size : undefined, style: style, ...props })) }));
|
|
20
35
|
}
|
|
21
36
|
export { Input, InputPrimitive };
|
|
22
37
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/form/Input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,EAAE,EAAuB,MAAM,iBAAiB,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG;IAC1B,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;CACD,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/form/Input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,EAAE,EAAuB,MAAM,iBAAiB,CAAC;AAE1D,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG;IAC1B,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;CACD,CAAC;AAeX,SAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,IAAI,EACJ,QAAQ,GAKT;IACC,OAAO,CACL,EAAE,CACA,CAAC,QAAQ;QACP,EAAE,CACA,mBAAmB,CAAC,IAAI,CAAC,EACzB,q5BAAq5B,CACt5B,EACH,SAAS,CACV,IAAI,SAAS,CACf,CAAC;AACJ,C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AAK,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,KAClD,KAAK,GACT,CACH,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IACb,SAAS,EAAE,cAAc,eACf,OAAO,EACjB,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACjD,KAAK,EAAE,KAAK,KACR,KAAK,GACT,CACH,GACI,CACR,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -15,7 +15,7 @@ type SliderProps = SliderPrimitive.Root.Props & {
|
|
|
15
15
|
classNames?: SlotClassNames<'control' | 'indicator' | 'thumb' | 'track'>;
|
|
16
16
|
getAriaLabel?: SliderPrimitive.Thumb.Props['getAriaLabel'];
|
|
17
17
|
getAriaValueText?: SliderPrimitive.Thumb.Props['getAriaValueText'];
|
|
18
|
-
/**
|
|
18
|
+
/** Draws the filled track. `false` for a custom track, as in the color picker. Defaults to `true`. */
|
|
19
19
|
indicator?: boolean;
|
|
20
20
|
ref?: Ref<HTMLDivElement>;
|
|
21
21
|
trackStyle?: CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/components/form/Slider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAM,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE1D,KAAK,gBAAgB,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,GAAG;IACpD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,SAAS,CAAC,EAAE,MAA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+1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lazy-ref.d.ts","sourceRoot":"","sources":["../../src/hooks/use-lazy-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,iBAAS,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"use-lazy-ref.d.ts","sourceRoot":"","sources":["../../src/hooks/use-lazy-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,iBAAS,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAKlB,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACjC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
function useLazyRef(fn) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
// `useState` runs its initializer once, so `fn` is never called again and the
|
|
4
|
+
// `{ current }` box stays stable; render itself never writes to a ref.
|
|
5
|
+
const [ref] = React.useState(() => ({ current: fn() }));
|
|
7
6
|
return ref;
|
|
8
7
|
}
|
|
9
8
|
export { useLazyRef };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lazy-ref.js","sourceRoot":"","sources":["../../src/hooks/use-lazy-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,SAAS,UAAU,CAAI,EAAW;IAChC,
|
|
1
|
+
{"version":3,"file":"use-lazy-ref.js","sourceRoot":"","sources":["../../src/hooks/use-lazy-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,SAAS,UAAU,CAAI,EAAW;IAChC,8EAA8E;IAC9E,uEAAuE;IACvE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAExD,OAAO,GAAyB,CAAC;AACnC,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* A utility to compose multiple refs together
|
|
5
|
-
* Accepts callback refs and RefObject(s)
|
|
6
|
-
*/
|
|
7
3
|
declare function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T>;
|
|
8
|
-
/**
|
|
9
|
-
* A custom hook that composes multiple refs
|
|
10
|
-
* Accepts callback refs and RefObject(s)
|
|
11
|
-
*/
|
|
12
4
|
declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T>;
|
|
13
5
|
export { composeRefs, useComposedRefs };
|
|
14
6
|
//# sourceMappingURL=compose-refs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-refs.d.ts","sourceRoot":"","sources":["../../src/lib/compose-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"compose-refs.d.ts","sourceRoot":"","sources":["../../src/lib/compose-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAK/C,iBAAS,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CA0BvE;AAYD,iBAAS,eAAe,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAG3E;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/lib/compose-refs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Accepts callback refs and RefObject(s)
|
|
5
|
-
*/
|
|
2
|
+
// Radix UI's compose-refs (MIT): callback refs and ref objects merged into one
|
|
3
|
+
// callback ref, with React 19 ref cleanups.
|
|
6
4
|
function composeRefs(...refs) {
|
|
7
5
|
return (node) => {
|
|
8
6
|
let hasCleanup = false;
|
|
@@ -13,10 +11,8 @@ function composeRefs(...refs) {
|
|
|
13
11
|
}
|
|
14
12
|
return cleanup;
|
|
15
13
|
});
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// user's ref callback returns a value, which we only expect if they are
|
|
19
|
-
// using the cleanup functionality added in React 19.
|
|
14
|
+
// Only return a cleanup when a ref returned one: React 18 logs an error
|
|
15
|
+
// for a callback ref that returns a value.
|
|
20
16
|
if (hasCleanup) {
|
|
21
17
|
return () => {
|
|
22
18
|
for (let i = 0; i < cleanups.length; i++) {
|
|
@@ -32,10 +28,6 @@ function composeRefs(...refs) {
|
|
|
32
28
|
}
|
|
33
29
|
};
|
|
34
30
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Set a given ref to a given value
|
|
37
|
-
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
|
38
|
-
*/
|
|
39
31
|
function setRef(ref, value) {
|
|
40
32
|
if (typeof ref === 'function') {
|
|
41
33
|
return ref(value);
|
|
@@ -44,14 +36,9 @@ function setRef(ref, value) {
|
|
|
44
36
|
ref.current = value;
|
|
45
37
|
}
|
|
46
38
|
}
|
|
47
|
-
/**
|
|
48
|
-
* A custom hook that composes multiple refs
|
|
49
|
-
* Accepts callback refs and RefObject(s)
|
|
50
|
-
*/
|
|
51
39
|
function useComposedRefs(...refs) {
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
return React.useCallback(composeRefs(...refs), refs); // react-doctor-disable-line react-doctor/exhaustive-deps -- same intentional memo: the dependency list is the spread `refs` array on purpose
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo -- memoized by every ref: the spread `refs` is the dependency list
|
|
41
|
+
return React.useCallback(composeRefs(...refs), refs); // react-doctor-disable-line react-doctor/exhaustive-deps -- memoized by every ref: the spread `refs` is the dependency list
|
|
55
42
|
}
|
|
56
43
|
export { composeRefs, useComposedRefs };
|
|
57
44
|
//# sourceMappingURL=compose-refs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-refs.js","sourceRoot":"","sources":["../../src/lib/compose-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B
|
|
1
|
+
{"version":3,"file":"compose-refs.js","sourceRoot":"","sources":["../../src/lib/compose-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,+EAA+E;AAC/E,4CAA4C;AAE5C,SAAS,WAAW,CAAI,GAAG,IAAsB;IAC/C,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClC,IAAI,CAAC,UAAU,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBACjD,UAAU,GAAG,IAAI,CAAC;YACpB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QAEH,wEAAwE;QACxE,2CAA2C;QAC3C,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,GAAG,EAAE;gBACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;oBAC5B,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;wBAClC,OAAO,EAAE,CAAC;oBACZ,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAI,GAAmB,EAAE,KAAQ;IAC9C,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAI,GAAG,IAAsB;IACnD,gJAAgJ;IAChJ,OAAO,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,4HAA4H;AACpL,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickle-ui/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React component library built with Base UI, shadcn/ui, Tailwind CSS, and reui.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"jsdom": "^29.1.1",
|
|
79
79
|
"postcss": "^8.5.15",
|
|
80
80
|
"react": "^19.2.7",
|
|
81
|
-
"react-doctor": "^0.
|
|
81
|
+
"react-doctor": "^0.9.18",
|
|
82
82
|
"react-dom": "^19.2.7",
|
|
83
83
|
"react-hook-form": "^7.79.0",
|
|
84
84
|
"storybook": "^10.6.3",
|
package/src/components/Alert.tsx
CHANGED
|
@@ -82,12 +82,10 @@ function AlertIcon({ className, ...props }: AlertIconProps) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* pass `role="alert"` for urgent messages (failures) or `role="status"` for
|
|
90
|
-
* polite ones (confirmations, info).
|
|
85
|
+
* No live-region role by default, so static notices are not announced on page
|
|
86
|
+
* load. When the alert appears in response to a user action, pass
|
|
87
|
+
* `role="alert"` for urgent messages (failures) or `role="status"` for polite
|
|
88
|
+
* ones (confirmations, info).
|
|
91
89
|
*/
|
|
92
90
|
function AlertRoot({ className, variant = 'default', ...props }: AlertProps) {
|
|
93
91
|
return (
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
|
-
/* eslint-disable react-hooks/refs --
|
|
5
|
+
/* eslint-disable react-hooks/refs -- prevValueRef is read during render on purpose: it holds the previous value and never affects the output. */
|
|
6
6
|
|
|
7
7
|
type InputValue = string | string[];
|
|
8
8
|
|
|
@@ -16,6 +16,36 @@ interface VisuallyHiddenInputProps<T = InputValue> extends Omit<
|
|
|
16
16
|
value?: T;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
const noSize: { height?: number; width?: number } = {};
|
|
20
|
+
|
|
21
|
+
// The snapshot is a string so React can compare it by value; an object would be
|
|
22
|
+
// a new snapshot on every read and re-render forever.
|
|
23
|
+
function useElementSize(element: HTMLElement | null) {
|
|
24
|
+
const subscribe = React.useCallback(
|
|
25
|
+
(onChange: () => void) => {
|
|
26
|
+
if (!element) return () => {};
|
|
27
|
+
|
|
28
|
+
const resizeObserver = new ResizeObserver(onChange);
|
|
29
|
+
resizeObserver.observe(element, { box: 'border-box' });
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
resizeObserver.disconnect();
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
[element],
|
|
36
|
+
);
|
|
37
|
+
const getSnapshot = () =>
|
|
38
|
+
element ? `${element.offsetWidth}x${element.offsetHeight}` : '';
|
|
39
|
+
const snapshot = React.useSyncExternalStore(subscribe, getSnapshot, () => '');
|
|
40
|
+
|
|
41
|
+
return React.useMemo(() => {
|
|
42
|
+
if (!snapshot) return noSize;
|
|
43
|
+
|
|
44
|
+
const [width, height] = snapshot.split('x').map(Number);
|
|
45
|
+
return { height, width };
|
|
46
|
+
}, [snapshot]);
|
|
47
|
+
}
|
|
48
|
+
|
|
19
49
|
function VisuallyHiddenInput<T = InputValue>(
|
|
20
50
|
props: VisuallyHiddenInputProps<T>,
|
|
21
51
|
) {
|
|
@@ -27,7 +57,7 @@ function VisuallyHiddenInput<T = InputValue>(
|
|
|
27
57
|
type = 'hidden',
|
|
28
58
|
value,
|
|
29
59
|
...inputProps
|
|
30
|
-
// react-doctor-disable-next-line react-doctor/no-event-handler --
|
|
60
|
+
// react-doctor-disable-next-line react-doctor/no-event-handler -- an effect mirrors value/checked into the native input and dispatches its event: prop changes drive it, not a user event
|
|
31
61
|
} = props;
|
|
32
62
|
|
|
33
63
|
const isCheckInput = React.useMemo(
|
|
@@ -53,55 +83,7 @@ function VisuallyHiddenInput<T = InputValue>(
|
|
|
53
83
|
return prevValueRef.current.previous;
|
|
54
84
|
}, [isCheckInput, value, checked]);
|
|
55
85
|
|
|
56
|
-
const
|
|
57
|
-
height?: number;
|
|
58
|
-
width?: number;
|
|
59
|
-
}>({});
|
|
60
|
-
|
|
61
|
-
// react-doctor-disable-next-line react-doctor/no-cascading-set-state -- this effect measures the control element and only calls setControlSize in mutually exclusive branches (or inside an async ResizeObserver callback), not as a synchronous render cascade
|
|
62
|
-
React.useLayoutEffect(() => {
|
|
63
|
-
if (!control) {
|
|
64
|
-
// eslint-disable-next-line react-hooks/set-state-in-effect -- reset measured size synchronously when the control is removed so the hidden input does not retain a stale size
|
|
65
|
-
setControlSize({});
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
setControlSize({
|
|
70
|
-
height: control.offsetHeight,
|
|
71
|
-
width: control.offsetWidth,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (typeof window === 'undefined') return;
|
|
75
|
-
|
|
76
|
-
const resizeObserver = new ResizeObserver((entries) => {
|
|
77
|
-
if (!Array.isArray(entries) || !entries.length) return;
|
|
78
|
-
|
|
79
|
-
const entry = entries[0];
|
|
80
|
-
if (!entry) return;
|
|
81
|
-
|
|
82
|
-
let width: number;
|
|
83
|
-
let height: number;
|
|
84
|
-
|
|
85
|
-
if ('borderBoxSize' in entry) {
|
|
86
|
-
const borderSizeEntry = entry.borderBoxSize;
|
|
87
|
-
const borderSize = Array.isArray(borderSizeEntry)
|
|
88
|
-
? borderSizeEntry[0]
|
|
89
|
-
: borderSizeEntry;
|
|
90
|
-
width = borderSize.inlineSize;
|
|
91
|
-
height = borderSize.blockSize;
|
|
92
|
-
} else {
|
|
93
|
-
width = control.offsetWidth;
|
|
94
|
-
height = control.offsetHeight;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setControlSize({ height, width });
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
resizeObserver.observe(control, { box: 'border-box' });
|
|
101
|
-
return () => {
|
|
102
|
-
resizeObserver.disconnect();
|
|
103
|
-
};
|
|
104
|
-
}, [control]);
|
|
86
|
+
const controlSize = useElementSize(control);
|
|
105
87
|
|
|
106
88
|
React.useEffect(() => {
|
|
107
89
|
const input = inputRef.current;
|
|
@@ -146,7 +146,7 @@ interface ColorPickerFormatSelectProps
|
|
|
146
146
|
Omit<React.ComponentProps<typeof Select>, 'onValueChange' | 'value'>,
|
|
147
147
|
Pick<React.ComponentProps<typeof SelectTrigger>, 'className'> {}
|
|
148
148
|
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- a named
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- a named alias of the Omit below
|
|
150
150
|
interface ColorPickerImplProps extends Omit<
|
|
151
151
|
ColorPickerProps,
|
|
152
152
|
| 'defaultFormat'
|
|
@@ -48,9 +48,8 @@ function useFieldName(name: string | undefined) {
|
|
|
48
48
|
return name ?? field?.name;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// React Hook Form
|
|
52
|
-
//
|
|
53
|
-
// visible control.
|
|
51
|
+
// React Hook Form tracks field state but attaches no aria or id props to
|
|
52
|
+
// custom controls: this maps the current Form.Field onto its visible control.
|
|
54
53
|
function useFormControlProps(
|
|
55
54
|
props: FormControlProps = {},
|
|
56
55
|
{ enabled = true }: UseFormControlPropsOptions = {},
|
|
@@ -46,8 +46,8 @@ function FormField({
|
|
|
46
46
|
});
|
|
47
47
|
const fieldError = name ? getFieldState(name, formState).error : undefined;
|
|
48
48
|
const errorMessage = error ?? getErrorMessage(fieldError);
|
|
49
|
-
// The
|
|
50
|
-
//
|
|
49
|
+
// The label focuses the control by this id; `useId` keeps it unique across
|
|
50
|
+
// forms and rows.
|
|
51
51
|
const generatedControlId = React.useId();
|
|
52
52
|
const controlId = controlIdProp ?? generatedControlId;
|
|
53
53
|
const nativeLabel = shouldUseNativeFieldLabel(children);
|
|
@@ -23,48 +23,85 @@ type InputProps = Omit<
|
|
|
23
23
|
unstyled?: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
type ResolvedSize = keyof typeof inputControlHeights;
|
|
27
|
+
|
|
28
|
+
function getControlClassName({
|
|
27
29
|
className,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
size,
|
|
31
|
+
unstyled,
|
|
32
|
+
}: {
|
|
33
|
+
className: InputProps['className'];
|
|
34
|
+
size: ResolvedSize;
|
|
35
|
+
unstyled: boolean;
|
|
36
|
+
}) {
|
|
37
|
+
return (
|
|
38
|
+
cn(
|
|
39
|
+
!unstyled &&
|
|
40
|
+
cn(
|
|
41
|
+
inputControlHeights[size],
|
|
42
|
+
'border-input bg-background text-foreground ring-ring/24 has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 relative inline-flex w-full rounded-lg border text-base shadow-xs/5 transition-shadow not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:ring-[3px] has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none sm:text-sm dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]',
|
|
43
|
+
),
|
|
44
|
+
className,
|
|
45
|
+
) || undefined
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getInputClassName({
|
|
50
|
+
inputClassNames,
|
|
51
|
+
size,
|
|
52
|
+
type,
|
|
53
|
+
unstyled,
|
|
54
|
+
}: {
|
|
55
|
+
inputClassNames: string | undefined;
|
|
56
|
+
size: ResolvedSize;
|
|
57
|
+
type: React.HTMLInputTypeAttribute | undefined;
|
|
58
|
+
unstyled: boolean;
|
|
59
|
+
}) {
|
|
60
|
+
return cn(
|
|
37
61
|
unstyled
|
|
38
62
|
? cn(
|
|
39
63
|
'w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72',
|
|
40
|
-
inputControlHeights[
|
|
41
|
-
|
|
42
|
-
|
|
64
|
+
inputControlHeights[size],
|
|
65
|
+
size === 'sm' && 'px-[calc(--spacing(2.5)-1px)]',
|
|
66
|
+
size === 'lg' && 'px-[calc(--spacing(3.5)-1px)]',
|
|
43
67
|
)
|
|
44
68
|
: cn(
|
|
45
69
|
'h-full min-h-0 w-full rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-none outline-none [transition:background-color_5000000s_ease-in-out_0s] placeholder:text-muted-foreground/72',
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
size === 'sm' && 'px-[calc(--spacing(2.5)-1px)]',
|
|
71
|
+
size === 'lg' && 'px-[calc(--spacing(3.5)-1px)]',
|
|
48
72
|
),
|
|
49
|
-
|
|
73
|
+
type === 'search' &&
|
|
50
74
|
'[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none',
|
|
51
|
-
|
|
75
|
+
type === 'file' &&
|
|
52
76
|
'text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm',
|
|
53
|
-
|
|
77
|
+
inputClassNames,
|
|
54
78
|
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function Input({
|
|
82
|
+
className,
|
|
83
|
+
classNames,
|
|
84
|
+
nativeInput = false,
|
|
85
|
+
size = 'md',
|
|
86
|
+
style,
|
|
87
|
+
unstyled = false,
|
|
88
|
+
...props
|
|
89
|
+
}: InputProps) {
|
|
90
|
+
const resolvedSize = typeof size === 'number' ? 'md' : size;
|
|
91
|
+
const inputClassName = getInputClassName({
|
|
92
|
+
inputClassNames: classNames?.input,
|
|
93
|
+
size: resolvedSize,
|
|
94
|
+
type: props.type,
|
|
95
|
+
unstyled,
|
|
96
|
+
});
|
|
55
97
|
|
|
56
98
|
return (
|
|
57
99
|
<span
|
|
58
|
-
className={
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'border-input bg-background text-foreground ring-ring/24 has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 relative inline-flex w-full rounded-lg border text-base shadow-xs/5 transition-shadow not-dark:bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:ring-[3px] has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none sm:text-sm dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]',
|
|
64
|
-
),
|
|
65
|
-
className,
|
|
66
|
-
) || undefined
|
|
67
|
-
}
|
|
100
|
+
className={getControlClassName({
|
|
101
|
+
className,
|
|
102
|
+
size: resolvedSize,
|
|
103
|
+
unstyled,
|
|
104
|
+
})}
|
|
68
105
|
data-size={resolvedSize}
|
|
69
106
|
data-slot="input-control"
|
|
70
107
|
>
|
|
@@ -109,13 +109,11 @@ describe('RadioGroup', () => {
|
|
|
109
109
|
<RadioGroup.Item label="Option C" value="c" />
|
|
110
110
|
</RadioGroup>,
|
|
111
111
|
);
|
|
112
|
-
// All radios in a group are reachable via keyboard.
|
|
113
112
|
const radios = screen.getAllByRole('radio');
|
|
114
113
|
expect(radios).toHaveLength(3);
|
|
115
|
-
// The group element exists and has roving-tabindex structure (tabIndex 0 on selected).
|
|
116
114
|
const radioA = screen.getByRole('radio', { name: 'Option A' });
|
|
117
115
|
expect(radioA).toHaveAttribute('aria-checked', 'true');
|
|
118
|
-
//
|
|
116
|
+
// Arrow-key roving focus is browser behavior jsdom lacks, so click.
|
|
119
117
|
fireEvent.click(screen.getByRole('radio', { name: 'Option C' }));
|
|
120
118
|
expect(screen.getByRole('radio', { name: 'Option C' })).toHaveAttribute(
|
|
121
119
|
'aria-checked',
|
|
@@ -20,7 +20,7 @@ type SliderProps = SliderPrimitive.Root.Props & {
|
|
|
20
20
|
classNames?: SlotClassNames<'control' | 'indicator' | 'thumb' | 'track'>;
|
|
21
21
|
getAriaLabel?: SliderPrimitive.Thumb.Props['getAriaLabel'];
|
|
22
22
|
getAriaValueText?: SliderPrimitive.Thumb.Props['getAriaValueText'];
|
|
23
|
-
/**
|
|
23
|
+
/** Draws the filled track. `false` for a custom track, as in the color picker. Defaults to `true`. */
|
|
24
24
|
indicator?: boolean;
|
|
25
25
|
ref?: Ref<HTMLDivElement>;
|
|
26
26
|
trackStyle?: CSSProperties;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
function useLazyRef<T>(fn: () => T) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ref.current = fn();
|
|
8
|
-
}
|
|
4
|
+
// `useState` runs its initializer once, so `fn` is never called again and the
|
|
5
|
+
// `{ current }` box stays stable; render itself never writes to a ref.
|
|
6
|
+
const [ref] = React.useState(() => ({ current: fn() }));
|
|
9
7
|
|
|
10
8
|
return ref as React.RefObject<T>;
|
|
11
9
|
}
|
package/src/lib/color.test.ts
CHANGED
|
@@ -48,9 +48,7 @@ describe('rgb <-> hsv', () => {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
//
|
|
52
|
-
// Plan 004 changes this to preserve a caller-supplied hue. When 004 lands,
|
|
53
|
-
// this assertion is expected to be updated there.
|
|
51
|
+
// Without a fallback hue, an achromatic color reports hue 0.
|
|
54
52
|
it('reports hue 0 for white (achromatic)', () => {
|
|
55
53
|
expect(rgbToHsv({ a: 1, b: 255, g: 255, r: 255 })).toEqual({
|
|
56
54
|
a: 1,
|
package/src/lib/compose-refs.ts
CHANGED
|
@@ -2,10 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
type PossibleRef<T> = React.Ref<T> | undefined;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
5
|
+
// Radix UI's compose-refs (MIT): callback refs and ref objects merged into one
|
|
6
|
+
// callback ref, with React 19 ref cleanups.
|
|
7
|
+
|
|
9
8
|
function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
|
10
9
|
return (node) => {
|
|
11
10
|
let hasCleanup = false;
|
|
@@ -17,10 +16,8 @@ function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
|
|
17
16
|
return cleanup;
|
|
18
17
|
});
|
|
19
18
|
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// user's ref callback returns a value, which we only expect if they are
|
|
23
|
-
// using the cleanup functionality added in React 19.
|
|
19
|
+
// Only return a cleanup when a ref returned one: React 18 logs an error
|
|
20
|
+
// for a callback ref that returns a value.
|
|
24
21
|
if (hasCleanup) {
|
|
25
22
|
return () => {
|
|
26
23
|
for (let i = 0; i < cleanups.length; i++) {
|
|
@@ -36,10 +33,6 @@ function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
/**
|
|
40
|
-
* Set a given ref to a given value
|
|
41
|
-
* This utility takes care of different types of refs: callback refs and RefObject(s)
|
|
42
|
-
*/
|
|
43
36
|
function setRef<T>(ref: PossibleRef<T>, value: T) {
|
|
44
37
|
if (typeof ref === 'function') {
|
|
45
38
|
return ref(value);
|
|
@@ -50,14 +43,9 @@ function setRef<T>(ref: PossibleRef<T>, value: T) {
|
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
/**
|
|
54
|
-
* A custom hook that composes multiple refs
|
|
55
|
-
* Accepts callback refs and RefObject(s)
|
|
56
|
-
*/
|
|
57
46
|
function useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
return React.useCallback(composeRefs(...refs), refs); // react-doctor-disable-line react-doctor/exhaustive-deps -- same intentional memo: the dependency list is the spread `refs` array on purpose
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo -- memoized by every ref: the spread `refs` is the dependency list
|
|
48
|
+
return React.useCallback(composeRefs(...refs), refs); // react-doctor-disable-line react-doctor/exhaustive-deps -- memoized by every ref: the spread `refs` is the dependency list
|
|
61
49
|
}
|
|
62
50
|
|
|
63
51
|
export { composeRefs, useComposedRefs };
|