@bccampus/ui-components 0.4.3 → 0.5.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/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.12.0.cjs +942 -0
- package/.yarnrc.yml +3 -0
- package/dist/_chunks/createLucideIcon.js +79 -0
- package/dist/_chunks/index.js +103 -0
- package/dist/_chunks/index2.js +44 -0
- package/dist/_chunks/index3.js +39 -0
- package/dist/_chunks/index4.js +615 -0
- package/dist/{utils-CRiPKpXj.js → _chunks/utils.js} +828 -544
- package/dist/components/index.d.ts +16 -0
- package/dist/components/index.js +84 -0
- package/dist/components/ui/banner.d.ts +10 -0
- package/dist/components/ui/banner.js +39 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/{button.js → components/ui/button.js} +11 -10
- package/dist/components/ui/card.d.ts +27 -0
- package/dist/components/ui/card.js +109 -0
- package/dist/components/ui/composite/CompositeData.d.ts +20 -0
- package/dist/components/ui/composite/CompositeData.js +89 -0
- package/dist/components/ui/composite/CompositeDataItem.d.ts +28 -0
- package/dist/components/ui/composite/CompositeDataItem.js +111 -0
- package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.d.ts +41 -0
- package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.js +36 -0
- package/dist/components/ui/composite/FocusProvider/ListboxFocusProvider.d.ts +16 -0
- package/dist/components/ui/composite/FocusProvider/ListboxFocusProvider.js +67 -0
- package/dist/components/ui/composite/FocusProvider/index.d.ts +2 -0
- package/dist/components/ui/composite/FocusProvider/index.js +6 -0
- package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.d.ts +23 -0
- package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.js +21 -0
- package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.d.ts +9 -0
- package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.js +20 -0
- package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.d.ts +9 -0
- package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.js +25 -0
- package/dist/components/ui/composite/SelectionProvider/index.d.ts +3 -0
- package/dist/components/ui/composite/SelectionProvider/index.js +8 -0
- package/dist/components/ui/composite/composite-component-item.d.ts +2 -0
- package/dist/components/ui/composite/composite-component-item.js +52 -0
- package/dist/components/ui/composite/composite-component.d.ts +2 -0
- package/dist/components/ui/composite/composite-component.js +66 -0
- package/dist/components/ui/composite/index.d.ts +8 -0
- package/dist/components/ui/composite/index.js +22 -0
- package/dist/components/ui/composite/listbox.d.ts +2 -0
- package/dist/components/ui/composite/listbox.js +59 -0
- package/dist/components/ui/composite/types.d.ts +82 -0
- package/dist/components/ui/composite/types.js +1 -0
- package/dist/components/ui/horizontal-list.d.ts +10 -0
- package/dist/components/ui/horizontal-list.js +70 -0
- package/dist/components/ui/icon-generator/generate-tiles.d.ts +4 -0
- package/dist/components/ui/icon-generator/generate-tiles.js +223 -0
- package/dist/components/ui/icon-generator/icon-generator.d.ts +3 -0
- package/dist/components/ui/icon-generator/icon-generator.js +82 -0
- package/dist/components/ui/icon-generator/index.d.ts +4 -0
- package/dist/components/ui/icon-generator/index.js +11 -0
- package/dist/components/ui/icon-generator/masked-image-generator.d.ts +3 -0
- package/dist/components/ui/icon-generator/masked-image-generator.js +31 -0
- package/dist/{masked-image-generator.d.ts → components/ui/icon-generator/types.d.ts} +48 -58
- package/dist/components/ui/icon-generator/types.js +30 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/{input.js → components/ui/input.js} +8 -8
- package/dist/components/ui/navigation-menu.d.ts +16 -0
- package/dist/components/ui/navigation-menu.js +1117 -0
- package/dist/components/ui/overlay.d.ts +7 -0
- package/dist/{overlay.js → components/ui/overlay.js} +7 -7
- package/dist/components/ui/page-header.d.ts +5 -0
- package/dist/{page-header.js → components/ui/page-header.js} +189 -181
- package/dist/components/ui/page-section.d.ts +8 -0
- package/dist/{page-section.js → components/ui/page-section.js} +7 -7
- package/dist/components/ui/page.d.ts +3 -0
- package/dist/components/ui/page.js +8 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/popover.js +3614 -0
- package/dist/components/ui/search-input.d.ts +3 -0
- package/dist/components/ui/search-input.js +18 -0
- package/dist/components/ui/tag.d.ts +10 -0
- package/dist/{tag.js → components/ui/tag.js} +10 -9
- package/dist/components/ui/typography/caption.d.ts +8 -0
- package/dist/components/ui/typography/caption.js +28 -0
- package/dist/components/ui/typography/index.d.ts +1 -0
- package/dist/components/ui/typography/index.js +5 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/use-effect-after-mount.d.ts +2 -0
- package/dist/hooks/use-effect-after-mount.js +24 -0
- package/dist/hooks/use-id.d.ts +1 -0
- package/dist/hooks/use-id.js +7 -0
- package/dist/hooks/use-keyboard-event.d.ts +59 -0
- package/dist/hooks/use-keyboard-event.js +52 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +16 -0
- package/dist/lib/object.d.ts +5 -0
- package/dist/lib/object.js +38 -0
- package/dist/lib/set-operations.d.ts +5 -0
- package/dist/lib/set-operations.js +51 -0
- package/dist/{utils.d.ts → lib/utils.d.ts} +2 -5
- package/dist/lib/utils.js +4 -0
- package/package.json +76 -146
- package/src/App.tsx +44 -14
- package/src/components/index.ts +17 -0
- package/src/components/ui/composite/FocusProvider/index.ts +2 -0
- package/src/components/ui/composite/SelectionProvider/MultipleSelectionProvider.ts +1 -1
- package/src/components/ui/composite/SelectionProvider/index.ts +3 -0
- package/src/components/ui/composite/index.ts +6 -5
- package/src/components/ui/icon-generator/index.ts +2 -0
- package/src/components/ui/typography/index.ts +1 -0
- package/src/hooks/index.ts +3 -0
- package/src/index.ts +3 -0
- package/src/lib/index.ts +3 -0
- package/src/main.tsx +12 -12
- package/tsconfig.lib.json +44 -0
- package/vite.config.ts +34 -33
- package/dist/AbstractFocusProvider-CxvlcEki.js +0 -29
- package/dist/AbstractSelectionProvider-BtaROstC.js +0 -30
- package/dist/CompositeDataItem-DuHOHCWy.js +0 -158
- package/dist/ListboxFocusProvider.d.ts +0 -149
- package/dist/ListboxFocusProvider.js +0 -53
- package/dist/MultipleSelectionProvider.d.ts +0 -141
- package/dist/MultipleSelectionProvider.js +0 -19
- package/dist/SingleSelectionProvider.d.ts +0 -141
- package/dist/SingleSelectionProvider.js +0 -23
- package/dist/banner.d.ts +0 -16
- package/dist/banner.js +0 -42
- package/dist/button.d.ts +0 -17
- package/dist/caption.d.ts +0 -13
- package/dist/caption.js +0 -27
- package/dist/card.d.ts +0 -46
- package/dist/card.js +0 -108
- package/dist/composite-component-DSUbd1XS.js +0 -122
- package/dist/composite.d.ts +0 -208
- package/dist/composite.js +0 -82
- package/dist/createLucideIcon-CzehbSja.js +0 -94
- package/dist/generate-tiles-DuagGD1d.js +0 -244
- package/dist/generate-tiles.d.ts +0 -43
- package/dist/generate-tiles.js +0 -7
- package/dist/horizontal-list.d.ts +0 -16
- package/dist/horizontal-list.js +0 -77
- package/dist/icon-generator-tuhuqdpL.js +0 -76
- package/dist/icon-generator.d.ts +0 -58
- package/dist/icon-generator.js +0 -6
- package/dist/index-CQhYMnjT.js +0 -34
- package/dist/index-U7DVCmS_.js +0 -76
- package/dist/input.d.ts +0 -7
- package/dist/listbox.d.ts +0 -171
- package/dist/listbox.js +0 -76
- package/dist/masked-image-generator.js +0 -29
- package/dist/navigation-menu.d.ts +0 -27
- package/dist/navigation-menu.js +0 -1139
- package/dist/overlay.d.ts +0 -13
- package/dist/page-header.d.ts +0 -9
- package/dist/page-section.d.ts +0 -14
- package/dist/page.d.ts +0 -7
- package/dist/page.js +0 -8
- package/dist/search-input.d.ts +0 -7
- package/dist/search-input.js +0 -23
- package/dist/tag.d.ts +0 -16
- package/dist/ui-components.d.ts +0 -215
- package/dist/ui-components.js +0 -54
- package/dist/utils.js +0 -4
- package/src/assets/icons/icon_01.svg +0 -6
- package/src/assets/icons/icon_02.svg +0 -6
- package/src/assets/icons/icon_03.svg +0 -6
- package/src/assets/icons/icon_04.svg +0 -6
- package/src/assets/icons/icon_05.svg +0 -4
- package/src/assets/icons/icon_06.svg +0 -4
- package/src/assets/images/image_01.jpg +0 -0
- package/src/assets/images/image_02.jpg +0 -0
- package/src/assets/images/image_03.webp +0 -0
- package/src/assets/images/image_04.png +0 -0
- package/src/assets/images/image_05.jpg +0 -0
- package/src/assets/images/image_06.jpg +0 -0
- package/src/components/ui/index.ts +0 -15
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { forwardRef, createElement } from "react";
|
|
2
|
+
const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3
|
+
const toCamelCase = (string) => string.replace(
|
|
4
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
5
|
+
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
6
|
+
);
|
|
7
|
+
const toPascalCase = (string) => {
|
|
8
|
+
const camelCase = toCamelCase(string);
|
|
9
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
10
|
+
};
|
|
11
|
+
const mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
12
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
13
|
+
}).join(" ").trim();
|
|
14
|
+
const hasA11yProp = (props) => {
|
|
15
|
+
for (const prop in props) {
|
|
16
|
+
if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var defaultAttributes = {
|
|
22
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
23
|
+
width: 24,
|
|
24
|
+
height: 24,
|
|
25
|
+
viewBox: "0 0 24 24",
|
|
26
|
+
fill: "none",
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
strokeWidth: 2,
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
strokeLinejoin: "round"
|
|
31
|
+
};
|
|
32
|
+
const Icon = forwardRef(
|
|
33
|
+
({
|
|
34
|
+
color = "currentColor",
|
|
35
|
+
size = 24,
|
|
36
|
+
strokeWidth = 2,
|
|
37
|
+
absoluteStrokeWidth,
|
|
38
|
+
className = "",
|
|
39
|
+
children,
|
|
40
|
+
iconNode,
|
|
41
|
+
...rest
|
|
42
|
+
}, ref) => createElement(
|
|
43
|
+
"svg",
|
|
44
|
+
{
|
|
45
|
+
ref,
|
|
46
|
+
...defaultAttributes,
|
|
47
|
+
width: size,
|
|
48
|
+
height: size,
|
|
49
|
+
stroke: color,
|
|
50
|
+
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
51
|
+
className: mergeClasses("lucide", className),
|
|
52
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
53
|
+
...rest
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
57
|
+
...Array.isArray(children) ? children : [children]
|
|
58
|
+
]
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
const createLucideIcon = (iconName, iconNode) => {
|
|
62
|
+
const Component = forwardRef(
|
|
63
|
+
({ className, ...props }, ref) => createElement(Icon, {
|
|
64
|
+
ref,
|
|
65
|
+
iconNode,
|
|
66
|
+
className: mergeClasses(
|
|
67
|
+
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
68
|
+
`lucide-${iconName}`,
|
|
69
|
+
className
|
|
70
|
+
),
|
|
71
|
+
...props
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
Component.displayName = toPascalCase(iconName);
|
|
75
|
+
return Component;
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
createLucideIcon as c
|
|
79
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { c as composeRefs } from "./index3.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
5
|
+
var use = React[" use ".trim().toString()];
|
|
6
|
+
function isPromiseLike(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && "then" in value;
|
|
8
|
+
}
|
|
9
|
+
function isLazyComponent(element) {
|
|
10
|
+
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
11
|
+
}
|
|
12
|
+
// @__NO_SIDE_EFFECTS__
|
|
13
|
+
function createSlot(ownerName) {
|
|
14
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
15
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
16
|
+
let { children, ...slotProps } = props;
|
|
17
|
+
if (isLazyComponent(children) && typeof use === "function") {
|
|
18
|
+
children = use(children._payload);
|
|
19
|
+
}
|
|
20
|
+
const childrenArray = React.Children.toArray(children);
|
|
21
|
+
const slottable = childrenArray.find(isSlottable);
|
|
22
|
+
if (slottable) {
|
|
23
|
+
const newElement = slottable.props.children;
|
|
24
|
+
const newChildren = childrenArray.map((child) => {
|
|
25
|
+
if (child === slottable) {
|
|
26
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
27
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
28
|
+
} else {
|
|
29
|
+
return child;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
35
|
+
});
|
|
36
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
37
|
+
return Slot2;
|
|
38
|
+
}
|
|
39
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
40
|
+
// @__NO_SIDE_EFFECTS__
|
|
41
|
+
function createSlotClone(ownerName) {
|
|
42
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
43
|
+
let { children, ...slotProps } = props;
|
|
44
|
+
if (isLazyComponent(children) && typeof use === "function") {
|
|
45
|
+
children = use(children._payload);
|
|
46
|
+
}
|
|
47
|
+
if (React.isValidElement(children)) {
|
|
48
|
+
const childrenRef = getElementRef(children);
|
|
49
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
50
|
+
if (children.type !== React.Fragment) {
|
|
51
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
52
|
+
}
|
|
53
|
+
return React.cloneElement(children, props2);
|
|
54
|
+
}
|
|
55
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
56
|
+
});
|
|
57
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
58
|
+
return SlotClone;
|
|
59
|
+
}
|
|
60
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
61
|
+
function isSlottable(child) {
|
|
62
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
63
|
+
}
|
|
64
|
+
function mergeProps(slotProps, childProps) {
|
|
65
|
+
const overrideProps = { ...childProps };
|
|
66
|
+
for (const propName in childProps) {
|
|
67
|
+
const slotPropValue = slotProps[propName];
|
|
68
|
+
const childPropValue = childProps[propName];
|
|
69
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
70
|
+
if (isHandler) {
|
|
71
|
+
if (slotPropValue && childPropValue) {
|
|
72
|
+
overrideProps[propName] = (...args) => {
|
|
73
|
+
const result = childPropValue(...args);
|
|
74
|
+
slotPropValue(...args);
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
} else if (slotPropValue) {
|
|
78
|
+
overrideProps[propName] = slotPropValue;
|
|
79
|
+
}
|
|
80
|
+
} else if (propName === "style") {
|
|
81
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
82
|
+
} else if (propName === "className") {
|
|
83
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { ...slotProps, ...overrideProps };
|
|
87
|
+
}
|
|
88
|
+
function getElementRef(element) {
|
|
89
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
90
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
91
|
+
if (mayWarn) {
|
|
92
|
+
return element.ref;
|
|
93
|
+
}
|
|
94
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
95
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
96
|
+
if (mayWarn) {
|
|
97
|
+
return element.props.ref;
|
|
98
|
+
}
|
|
99
|
+
return element.props.ref || element.ref;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
Slot as S
|
|
103
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { a as clsx } from "./utils.js";
|
|
2
|
+
const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
3
|
+
const cx = clsx;
|
|
4
|
+
const cva = (base, config) => (props) => {
|
|
5
|
+
var _config_compoundVariants;
|
|
6
|
+
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
7
|
+
const { variants, defaultVariants } = config;
|
|
8
|
+
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
9
|
+
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
10
|
+
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
11
|
+
if (variantProp === null) return null;
|
|
12
|
+
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
13
|
+
return variants[variant][variantKey];
|
|
14
|
+
});
|
|
15
|
+
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
|
|
16
|
+
let [key, value] = param;
|
|
17
|
+
if (value === void 0) {
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
20
|
+
acc[key] = value;
|
|
21
|
+
return acc;
|
|
22
|
+
}, {});
|
|
23
|
+
const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
|
|
24
|
+
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
25
|
+
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
26
|
+
let [key, value] = param2;
|
|
27
|
+
return Array.isArray(value) ? value.includes({
|
|
28
|
+
...defaultVariants,
|
|
29
|
+
...propsWithoutUndefined
|
|
30
|
+
}[key]) : {
|
|
31
|
+
...defaultVariants,
|
|
32
|
+
...propsWithoutUndefined
|
|
33
|
+
}[key] === value;
|
|
34
|
+
}) ? [
|
|
35
|
+
...acc,
|
|
36
|
+
cvClass,
|
|
37
|
+
cvClassName
|
|
38
|
+
] : acc;
|
|
39
|
+
}, []);
|
|
40
|
+
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
cva as c
|
|
44
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
function setRef(ref, value) {
|
|
3
|
+
if (typeof ref === "function") {
|
|
4
|
+
return ref(value);
|
|
5
|
+
} else if (ref !== null && ref !== void 0) {
|
|
6
|
+
ref.current = value;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function composeRefs(...refs) {
|
|
10
|
+
return (node) => {
|
|
11
|
+
let hasCleanup = false;
|
|
12
|
+
const cleanups = refs.map((ref) => {
|
|
13
|
+
const cleanup = setRef(ref, node);
|
|
14
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
15
|
+
hasCleanup = true;
|
|
16
|
+
}
|
|
17
|
+
return cleanup;
|
|
18
|
+
});
|
|
19
|
+
if (hasCleanup) {
|
|
20
|
+
return () => {
|
|
21
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
22
|
+
const cleanup = cleanups[i];
|
|
23
|
+
if (typeof cleanup == "function") {
|
|
24
|
+
cleanup();
|
|
25
|
+
} else {
|
|
26
|
+
setRef(refs[i], null);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useComposedRefs(...refs) {
|
|
34
|
+
return React.useCallback(composeRefs(...refs), refs);
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
composeRefs as c,
|
|
38
|
+
useComposedRefs as u
|
|
39
|
+
};
|