@ansh-ui/react 0.2.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/LICENSE +21 -0
- package/dist/chunk-5CFQFMP5.js +178 -0
- package/dist/chunk-5CFQFMP5.js.map +1 -0
- package/dist/chunk-6VRF7X5C.cjs +164 -0
- package/dist/chunk-6VRF7X5C.cjs.map +1 -0
- package/dist/chunk-AVPEA5PB.cjs +718 -0
- package/dist/chunk-AVPEA5PB.cjs.map +1 -0
- package/dist/chunk-C32LKF23.cjs +198 -0
- package/dist/chunk-C32LKF23.cjs.map +1 -0
- package/dist/chunk-C5JG6TMM.cjs +1200 -0
- package/dist/chunk-C5JG6TMM.cjs.map +1 -0
- package/dist/chunk-DATBU46V.cjs +614 -0
- package/dist/chunk-DATBU46V.cjs.map +1 -0
- package/dist/chunk-EGG4CP7C.js +320 -0
- package/dist/chunk-EGG4CP7C.js.map +1 -0
- package/dist/chunk-H34OXXJU.js +55 -0
- package/dist/chunk-H34OXXJU.js.map +1 -0
- package/dist/chunk-HO2YSF5O.js +187 -0
- package/dist/chunk-HO2YSF5O.js.map +1 -0
- package/dist/chunk-HPGCILO4.js +760 -0
- package/dist/chunk-HPGCILO4.js.map +1 -0
- package/dist/chunk-IBXLC5IE.js +154 -0
- package/dist/chunk-IBXLC5IE.js.map +1 -0
- package/dist/chunk-LDCZQP3R.js +1185 -0
- package/dist/chunk-LDCZQP3R.js.map +1 -0
- package/dist/chunk-LXCIXR5T.js +27 -0
- package/dist/chunk-LXCIXR5T.js.map +1 -0
- package/dist/chunk-O2PX54KX.js +94 -0
- package/dist/chunk-O2PX54KX.js.map +1 -0
- package/dist/chunk-OHBWBXLO.cjs +101 -0
- package/dist/chunk-OHBWBXLO.cjs.map +1 -0
- package/dist/chunk-OJN5JBNP.cjs +776 -0
- package/dist/chunk-OJN5JBNP.cjs.map +1 -0
- package/dist/chunk-OLTS6G5M.js +606 -0
- package/dist/chunk-OLTS6G5M.js.map +1 -0
- package/dist/chunk-PO5DU3FU.cjs +29 -0
- package/dist/chunk-PO5DU3FU.cjs.map +1 -0
- package/dist/chunk-QO3E7TJS.js +2940 -0
- package/dist/chunk-QO3E7TJS.js.map +1 -0
- package/dist/chunk-RHTLNSVW.cjs +2976 -0
- package/dist/chunk-RHTLNSVW.cjs.map +1 -0
- package/dist/chunk-SFU5EPSN.cjs +61 -0
- package/dist/chunk-SFU5EPSN.cjs.map +1 -0
- package/dist/chunk-T4AK2KLM.js +699 -0
- package/dist/chunk-T4AK2KLM.js.map +1 -0
- package/dist/chunk-WGYNCSTP.cjs +333 -0
- package/dist/chunk-WGYNCSTP.cjs.map +1 -0
- package/dist/chunk-XEP6P7E6.js +279 -0
- package/dist/chunk-XEP6P7E6.js.map +1 -0
- package/dist/chunk-XMXECSQO.cjs +286 -0
- package/dist/chunk-XMXECSQO.cjs.map +1 -0
- package/dist/chunk-ZWAFLHC2.cjs +181 -0
- package/dist/chunk-ZWAFLHC2.cjs.map +1 -0
- package/dist/data.cjs +71 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +316 -0
- package/dist/data.d.ts +316 -0
- package/dist/data.js +6 -0
- package/dist/data.js.map +1 -0
- package/dist/form.cjs +153 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +660 -0
- package/dist/form.d.ts +660 -0
- package/dist/form.js +8 -0
- package/dist/form.js.map +1 -0
- package/dist/index.cjs +1641 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +552 -0
- package/dist/index.d.ts +552 -0
- package/dist/index.js +956 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.cjs +68 -0
- package/dist/layout.cjs.map +1 -0
- package/dist/layout.d.cts +169 -0
- package/dist/layout.d.ts +169 -0
- package/dist/layout.js +7 -0
- package/dist/layout.js.map +1 -0
- package/dist/motion-CQmCq6_k.d.ts +395 -0
- package/dist/motion-CSX4g2N8.d.cts +395 -0
- package/dist/motion.cjs +79 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +4 -0
- package/dist/motion.d.ts +4 -0
- package/dist/motion.js +6 -0
- package/dist/motion.js.map +1 -0
- package/dist/navigation.cjs +48 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.cts +210 -0
- package/dist/navigation.d.ts +210 -0
- package/dist/navigation.js +7 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlay.cjs +69 -0
- package/dist/overlay.cjs.map +1 -0
- package/dist/overlay.d.cts +330 -0
- package/dist/overlay.d.ts +330 -0
- package/dist/overlay.js +8 -0
- package/dist/overlay.js.map +1 -0
- package/dist/position-DVScKcaa.d.cts +66 -0
- package/dist/position-DVScKcaa.d.ts +66 -0
- package/dist/primitives.cjs +162 -0
- package/dist/primitives.cjs.map +1 -0
- package/dist/primitives.d.cts +294 -0
- package/dist/primitives.d.ts +294 -0
- package/dist/primitives.js +9 -0
- package/dist/primitives.js.map +1 -0
- package/dist/sidebar-D-PafAXw.d.cts +71 -0
- package/dist/sidebar-D-PafAXw.d.ts +71 -0
- package/dist/styles.css +5575 -0
- package/dist/use-observers-B9qtimrk.d.cts +99 -0
- package/dist/use-observers-B9qtimrk.d.ts +99 -0
- package/package.json +92 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('react');
|
|
4
|
+
|
|
5
|
+
// src/primitives/compose.ts
|
|
6
|
+
function composeEventHandlers(theirs, ours, options = {}) {
|
|
7
|
+
const { checkForDefaultPrevented = true } = options;
|
|
8
|
+
return (event) => {
|
|
9
|
+
theirs?.(event);
|
|
10
|
+
if (checkForDefaultPrevented && event.defaultPrevented) return;
|
|
11
|
+
ours(event);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function assignRef(ref, node) {
|
|
15
|
+
if (!ref) return;
|
|
16
|
+
if (typeof ref === "function") ref(node);
|
|
17
|
+
else ref.current = node;
|
|
18
|
+
}
|
|
19
|
+
function mergeRefs(...refs) {
|
|
20
|
+
return (node) => {
|
|
21
|
+
for (const ref of refs) assignRef(ref, node);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function mergeProps(slotProps, childProps) {
|
|
25
|
+
const merged = { ...slotProps, ...childProps };
|
|
26
|
+
for (const key of Object.keys(slotProps)) {
|
|
27
|
+
const slotValue = slotProps[key];
|
|
28
|
+
const childValue = childProps[key];
|
|
29
|
+
if (/^on[A-Z]/.test(key) && typeof slotValue === "function") {
|
|
30
|
+
if (typeof childValue === "function") {
|
|
31
|
+
merged[key] = (...args) => {
|
|
32
|
+
childValue(...args);
|
|
33
|
+
slotValue(...args);
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
merged[key] = slotValue;
|
|
37
|
+
}
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (key === "style") {
|
|
41
|
+
merged[key] = { ...slotValue, ...childValue };
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (key === "className") {
|
|
45
|
+
merged[key] = [slotValue, childValue].filter(Boolean).join(" ");
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return merged;
|
|
50
|
+
}
|
|
51
|
+
function cx(...parts) {
|
|
52
|
+
return parts.filter(Boolean).join(" ");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.assignRef = assignRef;
|
|
56
|
+
exports.composeEventHandlers = composeEventHandlers;
|
|
57
|
+
exports.cx = cx;
|
|
58
|
+
exports.mergeProps = mergeProps;
|
|
59
|
+
exports.mergeRefs = mergeRefs;
|
|
60
|
+
//# sourceMappingURL=chunk-SFU5EPSN.cjs.map
|
|
61
|
+
//# sourceMappingURL=chunk-SFU5EPSN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/primitives/compose.ts"],"names":[],"mappings":";;;;;AASO,SAAS,oBAAA,CACd,MAAA,EACA,IAAA,EACA,OAAA,GAAkD,EAAC,EAC/B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ACL,QAAA,MAAA,CAAO,GAAG,CAAA,GAAI,SAAA;AAAA,MAChB;AACA,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,EAAE,GAAI,SAAA,EAAsB,GAAI,UAAA,EAAsB;AACpE,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,CAAC,SAAA,EAAW,UAAU,EAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAC9D,MAAA;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,MAAM,KAAA,EAAyD;AAC7E,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACvC","file":"chunk-SFU5EPSN.cjs","sourcesContent":["import { type Ref, type SyntheticEvent } from 'react'\n\n/**\n * Run a component's own handler after the consumer's, unless the consumer prevented default.\n *\n * The order matters and so does the check. A consumer's `onClick` on a `<Dialog.Close>` should be\n * able to call `event.preventDefault()` to stop the dialog closing — that is the escape hatch that\n * keeps composed components usable. Calling the internal handler first would make it impossible.\n */\nexport function composeEventHandlers<E extends SyntheticEvent | Event>(\n theirs: ((event: E) => void) | undefined,\n ours: (event: E) => void,\n options: { checkForDefaultPrevented?: boolean } = {},\n): (event: E) => void {\n const { checkForDefaultPrevented = true } = options\n return (event: E) => {\n theirs?.(event)\n if (checkForDefaultPrevented && event.defaultPrevented) return\n ours(event)\n }\n}\n\n/** Assign a node to any ref shape — callback, object, or nothing. */\nexport function assignRef<T>(ref: Ref<T> | undefined | null, node: T | null): void {\n if (!ref) return\n if (typeof ref === 'function') ref(node)\n else (ref as React.MutableRefObject<T | null>).current = node\n}\n\n/**\n * Merge refs without a hook.\n *\n * `useMergedRef` is the hook form and should be preferred inside components. This exists for the\n * places a ref must be merged outside of a render — cloning an element in a `Slot`, for instance.\n */\nexport function mergeRefs<T>(...refs: Array<Ref<T> | undefined | null>): (node: T | null) => void {\n return (node: T | null) => {\n for (const ref of refs) assignRef(ref, node)\n }\n}\n\n/**\n * Merge two sets of props, with the child's winning for everything except handlers, `className`\n * and `style`, which compose.\n *\n * This is the merge strategy `asChild` needs. A naive spread would let a child's `onClick`\n * silently delete a `Popover.Trigger`'s open handler, producing a trigger that renders perfectly\n * and does nothing.\n */\nexport function mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps, ...childProps }\n\n for (const key of Object.keys(slotProps)) {\n const slotValue = slotProps[key]\n const childValue = childProps[key]\n\n // `onClick`, `onKeyDown`, … — chain them, child first.\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function') {\n if (typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n ;(childValue as (...a: unknown[]) => void)(...args)\n ;(slotValue as (...a: unknown[]) => void)(...args)\n }\n } else {\n merged[key] = slotValue\n }\n continue\n }\n\n if (key === 'style') {\n merged[key] = { ...(slotValue as object), ...(childValue as object) }\n continue\n }\n\n if (key === 'className') {\n merged[key] = [slotValue, childValue].filter(Boolean).join(' ')\n continue\n }\n }\n\n return merged\n}\n\n/** Join class names, dropping falsy entries. The whole of `clsx` that this library actually uses. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ')\n}\n"]}
|