@hydrateless/react 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +33 -11
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -697,6 +697,11 @@ interface FieldControl {
|
|
|
697
697
|
declare function useField(): FieldControl | null;
|
|
698
698
|
/** Props for {@link Field}. */
|
|
699
699
|
interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
700
|
+
/**
|
|
701
|
+
* Id given to the control inside the Field (the label's `htmlFor` target).
|
|
702
|
+
* Generated when omitted. Help and error text derive their ids from it.
|
|
703
|
+
*/
|
|
704
|
+
id?: string;
|
|
700
705
|
/** Label text; renders a {@link FieldLabel} before the control. */
|
|
701
706
|
label?: ReactNode;
|
|
702
707
|
/** Help text; renders a {@link FieldHelp} after the control. */
|
package/dist/index.js
CHANGED
|
@@ -67,10 +67,25 @@ function useSyncApi(api, value, sync) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// src/internal/useForwardedRef.ts
|
|
70
|
-
import {
|
|
70
|
+
import { useCallback as useCallback2, useRef as useRef3 } from "react";
|
|
71
71
|
function useForwardedRef(forwarded) {
|
|
72
|
-
const
|
|
73
|
-
|
|
72
|
+
const inner = useRef3(null);
|
|
73
|
+
const forwardedRef = useRef3(forwarded);
|
|
74
|
+
forwardedRef.current = forwarded;
|
|
75
|
+
const callback = useCallback2((node) => {
|
|
76
|
+
inner.current = node;
|
|
77
|
+
const target = forwardedRef.current;
|
|
78
|
+
if (typeof target === "function") target(node);
|
|
79
|
+
else if (target) target.current = node;
|
|
80
|
+
}, []);
|
|
81
|
+
const ref = callback;
|
|
82
|
+
Object.defineProperty(ref, "current", {
|
|
83
|
+
configurable: true,
|
|
84
|
+
get: () => inner.current,
|
|
85
|
+
set: (node) => {
|
|
86
|
+
inner.current = node;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
74
89
|
return ref;
|
|
75
90
|
}
|
|
76
91
|
|
|
@@ -381,7 +396,7 @@ var MenuSubmenu = forwardRef5(function MenuSubmenu2({ label, value, disabled, tr
|
|
|
381
396
|
children: label
|
|
382
397
|
}
|
|
383
398
|
),
|
|
384
|
-
/* @__PURE__ */ jsx5("ul", { ...rest, ref, role: "menu", "data-hl-
|
|
399
|
+
/* @__PURE__ */ jsx5("ul", { ...rest, ref, role: "menu", "data-hl-submenu": true, children })
|
|
385
400
|
] });
|
|
386
401
|
});
|
|
387
402
|
|
|
@@ -586,7 +601,7 @@ var Field = forwardRef11(function Field2({
|
|
|
586
601
|
children,
|
|
587
602
|
...rest
|
|
588
603
|
}, ref) {
|
|
589
|
-
const baseId = useHlId("field");
|
|
604
|
+
const baseId = useHlId("field", id);
|
|
590
605
|
const hasError = error != null && error !== false;
|
|
591
606
|
const value = {
|
|
592
607
|
id: baseId,
|
|
@@ -600,7 +615,6 @@ var Field = forwardRef11(function Field2({
|
|
|
600
615
|
{
|
|
601
616
|
...rest,
|
|
602
617
|
ref,
|
|
603
|
-
id,
|
|
604
618
|
className: cx("hl-field", className),
|
|
605
619
|
"data-hl-invalid": value.invalid || void 0,
|
|
606
620
|
children: [
|
|
@@ -712,7 +726,8 @@ function ensureApi() {
|
|
|
712
726
|
}
|
|
713
727
|
var facade = {
|
|
714
728
|
show: (message, options) => ensureApi().show(message, options),
|
|
715
|
-
dismiss: (toast) => ensureApi().dismiss(toast)
|
|
729
|
+
dismiss: (toast) => ensureApi().dismiss(toast),
|
|
730
|
+
dismissAll: () => ensureApi().dismissAll()
|
|
716
731
|
};
|
|
717
732
|
var ToastRegion = forwardRef15(function ToastRegion2({ duration, onOpenChange, ...props }, forwardedRef) {
|
|
718
733
|
const ref = useForwardedRef(forwardedRef);
|
|
@@ -760,15 +775,22 @@ var Combobox = forwardRef16(function Combobox2({
|
|
|
760
775
|
}, forwardedRef) {
|
|
761
776
|
const ref = useForwardedRef(forwardedRef);
|
|
762
777
|
const [value, setValue] = useControlled(valueProp, defaultValue, onValueChange);
|
|
763
|
-
const [, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
|
|
778
|
+
const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
|
|
764
779
|
const api = useEnhancer(
|
|
765
780
|
ref,
|
|
766
781
|
enhanceCombobox,
|
|
767
|
-
{
|
|
782
|
+
{
|
|
783
|
+
filter,
|
|
784
|
+
autoHighlight,
|
|
785
|
+
defaultValue: value,
|
|
786
|
+
defaultOpen: open,
|
|
787
|
+
onValueChange: setValue,
|
|
788
|
+
onOpenChange: setOpen
|
|
789
|
+
},
|
|
768
790
|
[filter, autoHighlight]
|
|
769
791
|
);
|
|
770
792
|
useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
|
|
771
|
-
useSyncApi(api, openProp
|
|
793
|
+
useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
|
|
772
794
|
return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-combobox": true, children });
|
|
773
795
|
});
|
|
774
796
|
var ComboboxInput = forwardRef16(
|
|
@@ -812,7 +834,7 @@ var Command = forwardRef17(function Command2({ hotkey, query: queryProp, default
|
|
|
812
834
|
[hotkey]
|
|
813
835
|
);
|
|
814
836
|
useSyncApi(api, queryProp, (api2, query2) => api2.setValue(query2));
|
|
815
|
-
return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command": true, "data-hl-
|
|
837
|
+
return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command": true, "data-hl-hotkey": hotkey, children });
|
|
816
838
|
});
|
|
817
839
|
var CommandInput = forwardRef17(function CommandInput2({ styled = true, className, ...rest }, ref) {
|
|
818
840
|
return /* @__PURE__ */ jsx17(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydrateless/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "React bindings for Hydrateless: components (and a useEnhancer escape hatch) that wire the framework-agnostic enhancers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hydrateless/enhancers": "^0.
|
|
31
|
+
"@hydrateless/enhancers": "^0.10.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18"
|