@zayne-labs/ui-react 0.10.51 → 0.10.53
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/esm/chunk-pbuEa-1d.js +13 -0
- package/dist/esm/{cn-2hIN1AQ7.js → cn-Bbh2G587.js} +2 -3
- package/dist/esm/cn-Bbh2G587.js.map +1 -0
- package/dist/esm/common/await/index.d.ts +3 -5
- package/dist/esm/common/await/index.js +4 -8
- package/dist/esm/common/await/index.js.map +1 -1
- package/dist/esm/common/client-gate/index.d.ts +1 -1
- package/dist/esm/common/client-gate/index.js +29 -3
- package/dist/esm/common/client-gate/index.js.map +1 -0
- package/dist/esm/common/error-boundary/index.d.ts +2 -2
- package/dist/esm/common/error-boundary/index.js +2 -4
- package/dist/esm/common/for/index.d.ts +4 -3
- package/dist/esm/common/for/index.js +2 -3
- package/dist/esm/common/presence/index.d.ts +1 -1
- package/dist/esm/common/presence/index.js +2 -4
- package/dist/esm/common/show/index.d.ts +4 -4
- package/dist/esm/common/show/index.js +2 -4
- package/dist/esm/common/slot/index.js +2 -3
- package/dist/esm/common/suspense-with-boundary/index.d.ts +1 -2
- package/dist/esm/common/suspense-with-boundary/index.js +2 -3
- package/dist/esm/common/suspense-with-boundary/index.js.map +1 -1
- package/dist/esm/common/switch/index.d.ts +3 -3
- package/dist/esm/common/switch/index.js +2 -5
- package/dist/esm/common/switch/index.js.map +1 -1
- package/dist/esm/common/teleport/index.d.ts +3 -3
- package/dist/esm/common/teleport/index.js +2 -3
- package/dist/esm/common/teleport/index.js.map +1 -1
- package/dist/esm/{useErrorBoundary-CIUZVY-G.js → error-boundary-C4btQhu_.js} +2 -5
- package/dist/esm/error-boundary-C4btQhu_.js.map +1 -0
- package/dist/esm/{getElementList-CtQvQXjS.js → for-DGTMIS0w.js} +2 -4
- package/dist/esm/for-DGTMIS0w.js.map +1 -0
- package/dist/esm/{useErrorBoundary-DhOgXZDB.d.ts → index-BUIvQ2wP.d.ts} +6 -2
- package/dist/esm/{suspense-with-boundary-CAT0Jm5m.d.ts → index-ClV6w6nv.d.ts} +2 -2
- package/dist/esm/{presence-BjbQUjhT.js → presence-CWOGx-be.js} +9 -11
- package/dist/esm/{presence-BjbQUjhT.js.map → presence-CWOGx-be.js.map} +1 -1
- package/dist/esm/{show-parts-BsJLZhNL.js → show-BzfAw7y3.js} +3 -5
- package/dist/esm/show-BzfAw7y3.js.map +1 -0
- package/dist/esm/{slot-parts-Da1BsS7u.js → slot-DuwoiC2C.js} +19 -14
- package/dist/esm/slot-DuwoiC2C.js.map +1 -0
- package/dist/esm/ui/card/index.js +5 -7
- package/dist/esm/ui/card/index.js.map +1 -1
- package/dist/esm/ui/carousel/index.js +5 -11
- package/dist/esm/ui/carousel/index.js.map +1 -1
- package/dist/esm/ui/drag-scroll/index.d.ts +0 -1
- package/dist/esm/ui/drag-scroll/index.js +24 -27
- package/dist/esm/ui/drag-scroll/index.js.map +1 -1
- package/dist/esm/ui/drop-zone/index.d.ts +39 -40
- package/dist/esm/ui/drop-zone/index.js +7 -15
- package/dist/esm/ui/drop-zone/index.js.map +1 -1
- package/dist/esm/ui/form/index.d.ts +35 -43
- package/dist/esm/ui/form/index.js +13 -19
- package/dist/esm/ui/form/index.js.map +1 -1
- package/dist/style.css +9 -9
- package/package.json +18 -19
- package/dist/esm/chunk-BYypO7fO.js +0 -18
- package/dist/esm/client-gate-BhR-cK58.js +0 -31
- package/dist/esm/client-gate-BhR-cK58.js.map +0 -1
- package/dist/esm/cn-2hIN1AQ7.js.map +0 -1
- package/dist/esm/getElementList-CtQvQXjS.js.map +0 -1
- package/dist/esm/show-parts-BsJLZhNL.js.map +0 -1
- package/dist/esm/slot-parts-Da1BsS7u.js.map +0 -1
- package/dist/esm/useErrorBoundary-CIUZVY-G.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { twMerge } from "tailwind-merge";
|
|
2
|
-
|
|
3
2
|
//#region src/lib/utils/cn.ts
|
|
4
3
|
const cnMerge = (...classNames) => twMerge(classNames);
|
|
5
|
-
|
|
6
4
|
//#endregion
|
|
7
5
|
export { cnMerge as t };
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=cn-Bbh2G587.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn-Bbh2G587.js","names":[],"sources":["../../src/lib/utils/cn.ts"],"sourcesContent":["import { twMerge } from \"tailwind-merge\";\n\nexport const cnMerge: typeof twMerge = (...classNames) => twMerge(classNames);\n"],"mappings":";;AAEA,MAAa,WAA2B,GAAG,eAAe,QAAQ,WAAW"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import { n as SuspenseWithBoundaryProps } from "../../suspense-with-boundary-CAT0Jm5m.js";
|
|
4
|
-
import "../suspense-with-boundary/index.js";
|
|
1
|
+
import { o as ErrorBoundaryProps } from "../../index-BUIvQ2wP.js";
|
|
2
|
+
import { n as SuspenseWithBoundaryProps } from "../../index-ClV6w6nv.js";
|
|
5
3
|
import { GetSlotComponentProps } from "@zayne-labs/toolkit-react/utils";
|
|
6
4
|
import * as react from "react";
|
|
7
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -44,5 +42,5 @@ declare namespace await_parts_d_exports {
|
|
|
44
42
|
export { AwaitError as Error, AwaitPending as Pending, AwaitRoot as Root, AwaitSuccess as Success };
|
|
45
43
|
}
|
|
46
44
|
//#endregion
|
|
47
|
-
export { await_parts_d_exports as Await, AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, useAwaitContext };
|
|
45
|
+
export { await_parts_d_exports as Await, AwaitError, AwaitPending, AwaitRoot, AwaitRootProps, AwaitSuccess, useAwaitContext };
|
|
48
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as SlotRoot } from "../../slot-parts-Da1BsS7u.js";
|
|
2
|
+
import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
|
|
3
|
+
import { n as ErrorBoundary, r as useErrorBoundaryContext } from "../../error-boundary-C4btQhu_.js";
|
|
4
|
+
import { n as SlotRoot } from "../../slot-DuwoiC2C.js";
|
|
6
5
|
import { getSlotMap, withSlotNameAndSymbol } from "@zayne-labs/toolkit-react/utils";
|
|
7
6
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
8
7
|
import { Fragment, Suspense, use, useMemo } from "react";
|
|
9
8
|
import { createCustomContext } from "@zayne-labs/toolkit-react";
|
|
10
9
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
10
|
//#region src/components/common/await/await-context.ts
|
|
13
11
|
const [AwaitContextProvider, useAwaitContextImpl] = createCustomContext({
|
|
14
12
|
hookName: "useAwaitContext",
|
|
@@ -16,7 +14,6 @@ const [AwaitContextProvider, useAwaitContextImpl] = createCustomContext({
|
|
|
16
14
|
providerName: "AwaitInner"
|
|
17
15
|
});
|
|
18
16
|
const useAwaitContext = () => useAwaitContextImpl();
|
|
19
|
-
|
|
20
17
|
//#endregion
|
|
21
18
|
//#region src/components/common/await/await.tsx
|
|
22
19
|
function AwaitRoot(props) {
|
|
@@ -74,7 +71,6 @@ const AwaitError = withSlotNameAndSymbol("error", (props) => {
|
|
|
74
71
|
});
|
|
75
72
|
});
|
|
76
73
|
const AwaitPending = withSlotNameAndSymbol("pending");
|
|
77
|
-
|
|
78
74
|
//#endregion
|
|
79
75
|
//#region src/components/common/await/await-parts.ts
|
|
80
76
|
var await_parts_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -83,7 +79,7 @@ var await_parts_exports = /* @__PURE__ */ __exportAll({
|
|
|
83
79
|
Root: () => AwaitRoot,
|
|
84
80
|
Success: () => AwaitSuccess
|
|
85
81
|
});
|
|
86
|
-
|
|
87
82
|
//#endregion
|
|
88
83
|
export { await_parts_exports as Await, AwaitError, AwaitPending, AwaitRoot, AwaitSuccess, useAwaitContext };
|
|
84
|
+
|
|
89
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReactFragment","Slot.Root"],"sources":["../../../../src/components/common/await/await-context.ts","../../../../src/components/common/await/await.tsx","../../../../src/components/common/await/await-parts.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type AwaitContextType<TValue = unknown> = {\n\tpromise: Promise<TValue>;\n\tresult: TValue;\n};\n\nconst [AwaitContextProvider, useAwaitContextImpl] = createCustomContext<AwaitContextType>({\n\thookName: \"useAwaitContext\",\n\tname: \"AwaitContext\",\n\tproviderName: \"AwaitInner\",\n});\n\nconst useAwaitContext = <TValue>() => useAwaitContextImpl() as AwaitContextType<TValue>;\n\nexport { useAwaitContext, AwaitContextProvider };\n","\"use client\";\n\nimport {\n\tgetSlotMap,\n\twithSlotNameAndSymbol,\n\ttype GetSlotComponentProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, Suspense, use, useMemo } from \"react\";\nimport { ErrorBoundary, useErrorBoundaryContext, type ErrorBoundaryProps } from \"../error-boundary\";\nimport { Slot } from \"../slot\";\nimport type { SuspenseWithBoundaryProps } from \"../suspense-with-boundary\";\nimport { AwaitContextProvider, useAwaitContext } from \"./await-context\";\n\ntype RenderPropFn<TValue> = (result: TValue) => React.ReactNode;\n\ntype ChildrenType<TValue> = React.ReactNode | RenderPropFn<TValue>;\n\
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReactFragment","Slot.Root"],"sources":["../../../../src/components/common/await/await-context.ts","../../../../src/components/common/await/await.tsx","../../../../src/components/common/await/await-parts.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type AwaitContextType<TValue = unknown> = {\n\tpromise: Promise<TValue>;\n\tresult: TValue;\n};\n\nconst [AwaitContextProvider, useAwaitContextImpl] = createCustomContext<AwaitContextType>({\n\thookName: \"useAwaitContext\",\n\tname: \"AwaitContext\",\n\tproviderName: \"AwaitInner\",\n});\n\nconst useAwaitContext = <TValue>() => useAwaitContextImpl() as AwaitContextType<TValue>;\n\nexport { useAwaitContext, AwaitContextProvider };\n","\"use client\";\n\nimport {\n\tgetSlotMap,\n\twithSlotNameAndSymbol,\n\ttype GetSlotComponentProps,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, Suspense, use, useMemo } from \"react\";\nimport { ErrorBoundary, useErrorBoundaryContext, type ErrorBoundaryProps } from \"../error-boundary\";\nimport { Slot } from \"../slot\";\nimport type { SuspenseWithBoundaryProps } from \"../suspense-with-boundary\";\nimport { AwaitContextProvider, useAwaitContext } from \"./await-context\";\n\ntype RenderPropFn<TValue> = (result: TValue) => React.ReactNode;\n\ntype ChildrenType<TValue> = React.ReactNode | RenderPropFn<TValue>;\n\nexport type AwaitRootProps<TValue> = Pick<SuspenseWithBoundaryProps, \"errorFallback\" | \"fallback\"> & {\n\tasChild?: boolean;\n\tchildren: ChildrenType<TValue>;\n\tpromise: Promise<TValue>;\n\twithErrorBoundary?: boolean;\n\twithSuspense?: boolean;\n};\n\nexport function AwaitRoot<TValue>(props: AwaitRootProps<TValue>) {\n\tconst {\n\t\tchildren,\n\t\terrorFallback,\n\t\tfallback,\n\t\twithErrorBoundary = true,\n\t\twithSuspense = true,\n\t\t...restOfProps\n\t} = props;\n\n\tconst WithErrorBoundary = withErrorBoundary ? ErrorBoundary : ReactFragment;\n\tconst WithSuspense = withSuspense ? Suspense : ReactFragment;\n\n\tconst slots =\n\t\t!isFunction(children) ?\n\t\t\tgetSlotMap<SlotComponentProps>(children)\n\t\t:\t({ default: children } as unknown as ReturnType<typeof getSlotMap<SlotComponentProps>>);\n\n\tconst selectedPendingFallback = slots.pending ?? fallback;\n\tconst selectedErrorFallback = slots.error ?? errorFallback;\n\n\treturn (\n\t\t<WithErrorBoundary {...(Boolean(selectedErrorFallback) && { fallback: selectedErrorFallback })}>\n\t\t\t<WithSuspense {...(Boolean(selectedPendingFallback) && { fallback: selectedPendingFallback })}>\n\t\t\t\t<AwaitRootInner {...restOfProps}>{slots.default}</AwaitRootInner>\n\t\t\t</WithSuspense>\n\t\t</WithErrorBoundary>\n\t);\n}\n\ntype AwaitRootInnerProps<TValue> = Pick<AwaitRootProps<TValue>, \"asChild\" | \"children\" | \"promise\">;\n\nfunction AwaitRootInner<TValue>(props: AwaitRootInnerProps<TValue>) {\n\tconst { asChild, children, promise } = props;\n\n\tconst result = use(promise);\n\n\tconst resolvedChildren = isFunction(children) ? children(result) : children;\n\n\tconst Component = asChild ? Slot.Root : ReactFragment;\n\n\tconst contextValue = useMemo(() => ({ promise, result }), [promise, result]);\n\n\treturn (\n\t\t<AwaitContextProvider value={contextValue}>\n\t\t\t<Component {...(asChild && contextValue)}>{resolvedChildren}</Component>\n\t\t</AwaitContextProvider>\n\t);\n}\n\ntype SlotComponentProps = AwaitErrorProps | AwaitPendingProps | AwaitSuccessProps;\n\ntype AwaitSuccessProps<TValue = unknown> = GetSlotComponentProps<\"default\", ChildrenType<TValue>>;\n\nexport function AwaitSuccess<TPromiseOrValue, TValue = Awaited<TPromiseOrValue>>(\n\tprops: Pick<AwaitSuccessProps<TValue>, \"children\">\n) {\n\tconst { children } = props;\n\n\tif (isFunction(children)) {\n\t\t// eslint-disable-next-line react-x/rules-of-hooks, react-hooks/hooks -- This hook only uses `use` under the hood so this is safe\n\t\tconst { result } = useAwaitContext<TValue>();\n\n\t\treturn children(result);\n\t}\n\n\treturn children;\n}\n\nObject.assign(AwaitSuccess, withSlotNameAndSymbol<AwaitSuccessProps>(\"default\"));\n\ntype AwaitErrorProps = GetSlotComponentProps<\"error\", ErrorBoundaryProps[\"fallback\"]>;\n\nexport const AwaitError = withSlotNameAndSymbol<AwaitErrorProps, { asChild?: boolean }>(\n\t\"error\",\n\t(props) => {\n\t\tconst { asChild, children } = props;\n\n\t\tconst errorBoundaryContext = useErrorBoundaryContext();\n\n\t\tconst Component = asChild ? Slot.Root : ReactFragment;\n\n\t\tconst resolvedChildren = isFunction(children) ? children(errorBoundaryContext) : children;\n\n\t\treturn <Component {...(asChild && errorBoundaryContext)}>{resolvedChildren}</Component>;\n\t}\n);\n\ntype AwaitPendingProps = GetSlotComponentProps<\"pending\", React.SuspenseProps[\"fallback\"]>;\n\nexport const AwaitPending = withSlotNameAndSymbol<AwaitPendingProps>(\"pending\");\n","export {\n\tAwaitRoot as Root,\n\tAwaitError as Error,\n\tAwaitPending as Pending,\n\tAwaitSuccess as Success,\n} from \"./await\";\n"],"mappings":";;;;;;;;;;AAOA,MAAM,CAAC,sBAAsB,uBAAuB,oBAAsC;CACzF,UAAU;CACV,MAAM;CACN,cAAc;CACd,CAAC;AAEF,MAAM,wBAAgC,qBAAqB;;;ACa3D,SAAgB,UAAkB,OAA+B;CAChE,MAAM,EACL,UACA,eACA,UACA,oBAAoB,MACpB,eAAe,MACf,GAAG,gBACA;CAEJ,MAAM,oBAAoB,oBAAoB,gBAAgBA;CAC9D,MAAM,eAAe,eAAe,WAAWA;CAE/C,MAAM,QACL,CAAC,WAAW,SAAS,GACpB,WAA+B,SAAS,GACtC,EAAE,SAAS,UAAU;CAEzB,MAAM,0BAA0B,MAAM,WAAW;CACjD,MAAM,wBAAwB,MAAM,SAAS;AAE7C,QACC,oBAAC,mBAAD;EAAmB,GAAK,QAAQ,sBAAsB,IAAI,EAAE,UAAU,uBAAuB;YAC5F,oBAAC,cAAD;GAAc,GAAK,QAAQ,wBAAwB,IAAI,EAAE,UAAU,yBAAyB;aAC3F,oBAAC,gBAAD;IAAgB,GAAI;cAAc,MAAM;IAAyB,CAAA;GACnD,CAAA;EACI,CAAA;;AAMtB,SAAS,eAAuB,OAAoC;CACnE,MAAM,EAAE,SAAS,UAAU,YAAY;CAEvC,MAAM,SAAS,IAAI,QAAQ;CAE3B,MAAM,mBAAmB,WAAW,SAAS,GAAG,SAAS,OAAO,GAAG;CAEnE,MAAM,YAAY,UAAUC,WAAYD;CAExC,MAAM,eAAe,eAAe;EAAE;EAAS;EAAQ,GAAG,CAAC,SAAS,OAAO,CAAC;AAE5E,QACC,oBAAC,sBAAD;EAAsB,OAAO;YAC5B,oBAAC,WAAD;GAAW,GAAK,WAAW;aAAgB;GAA6B,CAAA;EAClD,CAAA;;AAQzB,SAAgB,aACf,OACC;CACD,MAAM,EAAE,aAAa;AAErB,KAAI,WAAW,SAAS,EAAE;EAEzB,MAAM,EAAE,WAAW,iBAAyB;AAE5C,SAAO,SAAS,OAAO;;AAGxB,QAAO;;AAGR,OAAO,OAAO,cAAc,sBAAyC,UAAU,CAAC;AAIhF,MAAa,aAAa,sBACzB,UACC,UAAU;CACV,MAAM,EAAE,SAAS,aAAa;CAE9B,MAAM,uBAAuB,yBAAyB;CAEtD,MAAM,YAAY,UAAUC,WAAYD;CAExC,MAAM,mBAAmB,WAAW,SAAS,GAAG,SAAS,qBAAqB,GAAG;AAEjF,QAAO,oBAAC,WAAD;EAAW,GAAK,WAAW;YAAwB;EAA6B,CAAA;EAExF;AAID,MAAa,eAAe,sBAAyC,UAAU"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
+
import { useIsHydrated } from "@zayne-labs/toolkit-react";
|
|
4
|
+
//#region src/components/common/client-gate/client-gate.tsx
|
|
5
|
+
/**
|
|
6
|
+
* @description Render the children only after the JS has loaded client-side. Use an optional
|
|
7
|
+
* fallback component if the JS is not yet loaded.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* **Render a Chart component if JS loads, renders a simple FakeChart
|
|
11
|
+
* component server-side or if there is no JS. The FakeChart can have only the
|
|
12
|
+
* UI without the behavior or be a loading spinner or skeleton.**
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* return (
|
|
16
|
+
* <ClientOnly fallback={<FakeChart />}>
|
|
17
|
+
* {() => <Chart />}
|
|
18
|
+
* </ClientOnly>
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function ClientGate(props) {
|
|
23
|
+
const { children, fallback } = props;
|
|
24
|
+
const isHydrated = useIsHydrated();
|
|
25
|
+
const resolvedChildren = () => isFunction(children) ? children() : children;
|
|
26
|
+
return isHydrated ? resolvedChildren() : fallback;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ClientGate };
|
|
2
30
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { ClientGate };
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/client-gate/client-gate.tsx"],"sourcesContent":["\"use client\";\n\nimport { useIsHydrated } from \"@zayne-labs/toolkit-react\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\nexport type ClientGateProps = {\n\t/**\n\t * You are encouraged to add a fallback that is the same dimensions\n\t * as the client rendered children. This will avoid content layout\n\t * shift which is disgusting 🥲\n\t */\n\tchildren: React.ReactNode | (() => React.ReactNode);\n\tfallback?: React.ReactNode;\n};\n\n/**\n * @description Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * **Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.**\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * {() => <Chart />}\n * </ClientOnly>\n * );\n * ```\n */\nfunction ClientGate(props: ClientGateProps) {\n\tconst { children, fallback } = props;\n\n\tconst isHydrated = useIsHydrated();\n\n\tconst resolvedChildren = () => (isFunction(children) ? children() : children);\n\n\treturn isHydrated ? resolvedChildren() : fallback;\n}\n\nexport { ClientGate };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,WAAW,OAAwB;CAC3C,MAAM,EAAE,UAAU,aAAa;CAE/B,MAAM,aAAa,eAAe;CAElC,MAAM,yBAA0B,WAAW,SAAS,GAAG,UAAU,GAAG;AAEpE,QAAO,aAAa,kBAAkB,GAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { ErrorBoundary,
|
|
1
|
+
import { a as ErrorBoundary, i as useErrorBoundaryContext, n as useErrorBoundary, o as ErrorBoundaryProps, r as ErrorBoundaryContextType, s as ErrorFallbackProps, t as UseErrorBoundaryReturn } from "../../index-BUIvQ2wP.js";
|
|
2
|
+
export { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, ErrorFallbackProps, UseErrorBoundaryReturn, useErrorBoundary, useErrorBoundaryContext };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { ErrorBoundary, useErrorBoundary, useErrorBoundaryContext };
|
|
2
|
+
import { n as ErrorBoundary, r as useErrorBoundaryContext, t as useErrorBoundary } from "../../error-boundary-C4btQhu_.js";
|
|
3
|
+
export { ErrorBoundary, useErrorBoundary, useErrorBoundaryContext };
|
|
@@ -13,13 +13,14 @@ type ForProps<TArray extends ArrayOrNumber> = Prettify<{
|
|
|
13
13
|
fallback?: React.ReactNode;
|
|
14
14
|
} & ForRenderProps<TArray>>;
|
|
15
15
|
declare function For<const TArray extends ArrayOrNumber>(props: ForProps<TArray>): string | number | bigint | boolean | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
|
|
16
|
-
|
|
16
|
+
type ForWithWrapperProps<TArray extends ArrayOrNumber, TElement extends React.ElementType = "ul"> = PolymorphicPropsStrict<TElement, ForProps<TArray>> & {
|
|
17
17
|
displayFallBackWhenEmpty?: boolean;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
|
+
declare function ForWithWrapper<const TArray extends ArrayOrNumber, TElement extends React.ElementType = "ul">(props: ForWithWrapperProps<TArray, TElement>): string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
|
|
19
20
|
//#endregion
|
|
20
21
|
//#region src/components/common/for/getElementList.d.ts
|
|
21
22
|
type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof For] : [typeof ForWithWrapper];
|
|
22
23
|
declare const getElementList: <TVariant extends "base" | "withWrapper" = "withWrapper">(variant?: TVariant) => GetElementListResult<TVariant>;
|
|
23
24
|
//#endregion
|
|
24
|
-
export { For, ForRenderProps, ForWithWrapper, getElementList };
|
|
25
|
+
export { For, ForProps, ForRenderProps, ForWithWrapper, ForWithWrapperProps, getElementList };
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as For, r as ForWithWrapper, t as getElementList } from "../../
|
|
2
|
-
|
|
3
|
-
export { For, ForWithWrapper, getElementList };
|
|
1
|
+
import { n as For, r as ForWithWrapper, t as getElementList } from "../../for-DGTMIS0w.js";
|
|
2
|
+
export { For, ForWithWrapper, getElementList };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/common/show/show.d.ts
|
|
4
|
-
type
|
|
4
|
+
type ShowRootProps<TWhen> = {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
control: "content";
|
|
7
7
|
fallback?: React.ReactNode;
|
|
@@ -12,8 +12,8 @@ type ShowProps<TWhen> = {
|
|
|
12
12
|
fallback?: React.ReactNode;
|
|
13
13
|
when: false | TWhen | null | undefined;
|
|
14
14
|
};
|
|
15
|
-
declare function ShowRoot<TWhen>(props:
|
|
16
|
-
type ShowContentProps<TWhen> = Pick<
|
|
15
|
+
declare function ShowRoot<TWhen>(props: ShowRootProps<TWhen>): string | number | bigint | boolean | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
|
|
16
|
+
type ShowContentProps<TWhen> = Pick<ShowRootProps<TWhen>, "children" | "when">;
|
|
17
17
|
declare function ShowContent<TWhen>(props: ShowContentProps<TWhen>): react.ReactNode;
|
|
18
18
|
declare namespace ShowContent {
|
|
19
19
|
var slotSymbol: symbol;
|
|
@@ -28,5 +28,5 @@ declare namespace show_parts_d_exports {
|
|
|
28
28
|
export { ShowContent as Content, ShowFallback as Fallback, ShowFallback as Otherwise, ShowRoot as Root };
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
export { show_parts_d_exports as Show, ShowContent, ShowFallback, ShowRoot };
|
|
31
|
+
export { show_parts_d_exports as Show, ShowContent, ShowContentProps, ShowFallback, ShowRoot, ShowRootProps };
|
|
32
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot };
|
|
2
|
+
import { i as ShowRoot, n as ShowContent, r as ShowFallback, t as show_parts_exports } from "../../show-BzfAw7y3.js";
|
|
3
|
+
export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as SlotRoot, r as SlotSlottable, t as slot_parts_exports } from "../../slot-
|
|
2
|
-
|
|
3
|
-
export { slot_parts_exports as Slot, SlotRoot, SlotSlottable };
|
|
1
|
+
import { n as SlotRoot, r as SlotSlottable, t as slot_parts_exports } from "../../slot-DuwoiC2C.js";
|
|
2
|
+
export { slot_parts_exports as Slot, SlotRoot, SlotSlottable };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import { n as SuspenseWithBoundaryProps, t as SuspenseWithBoundary } from "../../suspense-with-boundary-CAT0Jm5m.js";
|
|
1
|
+
import { n as SuspenseWithBoundaryProps, t as SuspenseWithBoundary } from "../../index-ClV6w6nv.js";
|
|
3
2
|
export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as ErrorBoundary } from "../../
|
|
1
|
+
import { n as ErrorBoundary } from "../../error-boundary-C4btQhu_.js";
|
|
2
2
|
import { Suspense } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
4
|
//#region src/components/common/suspense-with-boundary/suspense-with-boundary.tsx
|
|
6
5
|
function SuspenseWithBoundary(props) {
|
|
7
6
|
const { children, errorFallback, fallback } = props;
|
|
@@ -15,7 +14,7 @@ function SuspenseWithBoundary(props) {
|
|
|
15
14
|
})
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
18
|
export { SuspenseWithBoundary };
|
|
19
|
+
|
|
21
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/suspense-with-boundary/suspense-with-boundary.tsx"],"sourcesContent":["import { Suspense } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\nexport type SuspenseWithBoundaryProps = {\n\tchildren: React.ReactNode;\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function SuspenseWithBoundary(props: SuspenseWithBoundaryProps) {\n\tconst { children, errorFallback, fallback } = props;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<ErrorBoundary {...errorBoundaryProps}>\n\t\t\t<Suspense {...suspenseProps}>{children}</Suspense>\n\t\t</ErrorBoundary>\n\t);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/suspense-with-boundary/suspense-with-boundary.tsx"],"sourcesContent":["import { Suspense } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\nexport type SuspenseWithBoundaryProps = {\n\tchildren: React.ReactNode;\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function SuspenseWithBoundary(props: SuspenseWithBoundaryProps) {\n\tconst { children, errorFallback, fallback } = props;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<ErrorBoundary {...errorBoundaryProps}>\n\t\t\t<Suspense {...suspenseProps}>{children}</Suspense>\n\t\t</ErrorBoundary>\n\t);\n}\n"],"mappings":";;;;AASA,SAAgB,qBAAqB,OAAkC;CACtE,MAAM,EAAE,UAAU,eAAe,aAAa;CAE9C,MAAM,qBAAqB,QAAQ,cAAc,IAAI,EAAE,UAAU,eAAe;CAChF,MAAM,gBAAgB,QAAQ,SAAS,IAAI,EAAE,UAAU;AAEvD,QACC,oBAAC,eAAD;EAAe,GAAI;YAClB,oBAAC,UAAD;GAAU,GAAI;GAAgB;GAAoB,CAAA;EACnC,CAAA"}
|
|
@@ -2,11 +2,11 @@ import * as react from "react";
|
|
|
2
2
|
|
|
3
3
|
//#region src/components/common/switch/switch.d.ts
|
|
4
4
|
type ValidSwitchComponentType = React.ReactElement<SwitchMatchProps<unknown>>;
|
|
5
|
-
type
|
|
5
|
+
type SwitchRootProps<TValue> = {
|
|
6
6
|
children: ValidSwitchComponentType | ValidSwitchComponentType[];
|
|
7
7
|
value?: TValue;
|
|
8
8
|
};
|
|
9
|
-
declare function SwitchRoot<TValue>(props:
|
|
9
|
+
declare function SwitchRoot<TValue>(props: SwitchRootProps<TValue>): react.ReactNode;
|
|
10
10
|
type SwitchMatchProps<TWhen> = {
|
|
11
11
|
children: React.ReactNode | ((value: TWhen) => React.ReactNode);
|
|
12
12
|
when: false | TWhen | null | undefined;
|
|
@@ -24,5 +24,5 @@ declare namespace switch_parts_d_exports {
|
|
|
24
24
|
export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root };
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
-
export { switch_parts_d_exports as Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
27
|
+
export { switch_parts_d_exports as Switch, SwitchDefault, SwitchMatch, SwitchMatchProps, SwitchRoot, SwitchRootProps };
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { t as __exportAll } from "../../chunk-BYypO7fO.js";
|
|
2
|
+
import { t as __exportAll } from "../../chunk-pbuEa-1d.js";
|
|
4
3
|
import { getRegularChildren, getSingleSlot } from "@zayne-labs/toolkit-react/utils";
|
|
5
4
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
6
|
-
|
|
7
5
|
//#region src/components/common/switch/switch.tsx
|
|
8
6
|
const defaultValueSymbol = Symbol("default-value");
|
|
9
7
|
function SwitchRoot(props) {
|
|
@@ -25,7 +23,6 @@ function SwitchDefault({ children }) {
|
|
|
25
23
|
return children;
|
|
26
24
|
}
|
|
27
25
|
SwitchDefault.slotSymbol = Symbol("switch-default");
|
|
28
|
-
|
|
29
26
|
//#endregion
|
|
30
27
|
//#region src/components/common/switch/switch-parts.ts
|
|
31
28
|
var switch_parts_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -33,7 +30,7 @@ var switch_parts_exports = /* @__PURE__ */ __exportAll({
|
|
|
33
30
|
Match: () => SwitchMatch,
|
|
34
31
|
Root: () => SwitchRoot
|
|
35
32
|
});
|
|
36
|
-
|
|
37
33
|
//#endregion
|
|
38
34
|
export { switch_parts_exports as Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
35
|
+
|
|
39
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/switch/switch.tsx","../../../../src/components/common/switch/switch-parts.ts"],"sourcesContent":["\"use client\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps<unknown>>;\n\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/switch/switch.tsx","../../../../src/components/common/switch/switch-parts.ts"],"sourcesContent":["\"use client\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps<unknown>>;\n\nexport type SwitchRootProps<TValue> = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tvalue?: TValue;\n};\n\nconst defaultValueSymbol = Symbol(\"default-value\");\n\n// TODO - Add a factory to make this 'when' and 'value' type-safe later following the link below\n// LINK - https://tkdodo.eu/blog/building-type-safe-compound-components#component-factory-pattern\nexport function SwitchRoot<TValue>(props: SwitchRootProps<TValue>) {\n\tconst { children, value = defaultValueSymbol } = props;\n\n\tconst defaultCase = getSingleSlot(children, SwitchDefault, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getRegularChildren(children, SwitchDefault) as ValidSwitchComponentType[];\n\n\tconst matchedCase = childrenCasesArray.find((child) => {\n\t\t// == If value is defaultValueSymbol, match the cases in order like switch(true)\n\t\tif (value === defaultValueSymbol) {\n\t\t\treturn Boolean(child.props.when);\n\t\t}\n\n\t\t// == Otherwise, match the cases like switch(value)\n\t\treturn child.props.when === value;\n\t});\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport type SwitchMatchProps<TWhen> = {\n\tchildren: React.ReactNode | ((value: TWhen) => React.ReactNode);\n\twhen: false | TWhen | null | undefined;\n};\n\nexport function SwitchMatch<TWhen>(props: SwitchMatchProps<TWhen>) {\n\tconst { children, when } = props;\n\n\tconst resolvedChildren = isFunction(children) ? children(when as TWhen) : children;\n\n\treturn resolvedChildren;\n}\n\nexport function SwitchDefault({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nSwitchDefault.slotSymbol = Symbol(\"switch-default\");\n","export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root } from \"./switch\";\n"],"mappings":";;;;;AAYA,MAAM,qBAAqB,OAAO,gBAAgB;AAIlD,SAAgB,WAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,QAAQ,uBAAuB;CAEjD,MAAM,cAAc,cAAc,UAAU,eAAe;EAC1D,cAAc;EACd,0BAA0B;EAC1B,CAAC;AAcF,QAZ2B,mBAAmB,UAAU,cAAc,CAE/B,MAAM,UAAU;AAEtD,MAAI,UAAU,mBACb,QAAO,QAAQ,MAAM,MAAM,KAAK;AAIjC,SAAO,MAAM,MAAM,SAAS;GAC3B,IAEoB;;AAQvB,SAAgB,YAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,SAAS;AAI3B,QAFyB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;;AAK3E,SAAgB,cAAc,EAAE,YAA2C;AAC1E,QAAO;;AAER,cAAc,aAAa,OAAO,iBAAiB"}
|
|
@@ -3,12 +3,12 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/teleport/teleport.d.ts
|
|
5
5
|
type ValidHtmlTags = keyof HTMLElementTagNameMap;
|
|
6
|
-
type
|
|
6
|
+
type TeleportProps = {
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
insertPosition?: InsertPosition;
|
|
9
9
|
to: AnyString | HTMLElement | React.RefObject<HTMLElement> | ValidHtmlTags | null;
|
|
10
10
|
};
|
|
11
|
-
declare function Teleport(props:
|
|
11
|
+
declare function Teleport(props: TeleportProps): react_jsx_runtime0.JSX.Element;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { Teleport };
|
|
13
|
+
export { Teleport, type TeleportProps };
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientGate } from "../client-gate/index.js";
|
|
2
2
|
import { isString } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { useLayoutEffect, useState } from "react";
|
|
4
4
|
import { useCallbackRef } from "@zayne-labs/toolkit-react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
|
-
|
|
8
7
|
//#region src/components/common/teleport/teleport.tsx
|
|
9
8
|
const TELEPORT_KEY = "teleport-wrapper";
|
|
10
9
|
const getDestination = (to) => {
|
|
@@ -44,7 +43,7 @@ function Teleport(props) {
|
|
|
44
43
|
]);
|
|
45
44
|
return /* @__PURE__ */ jsx(ClientGate, { children: () => portalContainer && createPortal(children, portalContainer, TELEPORT_KEY) });
|
|
46
45
|
}
|
|
47
|
-
|
|
48
46
|
//#endregion
|
|
49
47
|
export { Teleport };
|
|
48
|
+
|
|
50
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/teleport/teleport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { isString, type AnyString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLayoutEffect, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ClientGate } from \"../client-gate\";\n\ntype ValidHtmlTags = keyof HTMLElementTagNameMap;\n\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/common/teleport/teleport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { isString, type AnyString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useLayoutEffect, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ClientGate } from \"../client-gate\";\n\ntype ValidHtmlTags = keyof HTMLElementTagNameMap;\n\nexport type TeleportProps = {\n\tchildren: React.ReactNode;\n\tinsertPosition?: InsertPosition;\n\tto: AnyString | HTMLElement | React.RefObject<HTMLElement> | ValidHtmlTags | null;\n};\n\nconst TELEPORT_KEY = \"teleport-wrapper\";\n\nconst getDestination = (to: NonNullable<TeleportProps[\"to\"]>) => {\n\tif (isString(to)) {\n\t\treturn document.querySelector<HTMLElement>(to);\n\t}\n\n\tif (to instanceof HTMLElement) {\n\t\treturn to;\n\t}\n\n\treturn to.current;\n};\n\nfunction Teleport(props: TeleportProps) {\n\tconst { children, insertPosition, to } = props;\n\n\tconst [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);\n\n\tconst stableUpdatePortalContainer = useCallbackRef((destination: HTMLElement | null) => {\n\t\t// eslint-disable-next-line react-x/set-state-in-effect -- Ignore\n\t\tsetPortalContainer(destination);\n\t});\n\n\tuseLayoutEffect(() => {\n\t\tif (!to) return;\n\n\t\tconst destination = getDestination(to);\n\n\t\tif (!insertPosition) {\n\t\t\tdestination && stableUpdatePortalContainer(destination);\n\t\t\treturn;\n\t\t}\n\n\t\tconst tempWrapper = document.createElement(\"div\");\n\t\ttempWrapper.id = TELEPORT_KEY;\n\t\ttempWrapper.style.display = \"contents\";\n\n\t\tdestination?.insertAdjacentElement(insertPosition, tempWrapper);\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\ttempWrapper.replaceWith(...tempWrapper.children);\n\t\t}, 0);\n\n\t\tstableUpdatePortalContainer(tempWrapper);\n\n\t\treturn () => {\n\t\t\ttempWrapper.remove();\n\t\t\tclearTimeout(timeoutId);\n\t\t};\n\t}, [to, insertPosition, stableUpdatePortalContainer]);\n\n\treturn (\n\t\t<ClientGate>\n\t\t\t{() => portalContainer && createPortal(children, portalContainer, TELEPORT_KEY)}\n\t\t</ClientGate>\n\t);\n}\n\nexport { Teleport };\n"],"mappings":";;;;;;;AAgBA,MAAM,eAAe;AAErB,MAAM,kBAAkB,OAAyC;AAChE,KAAI,SAAS,GAAG,CACf,QAAO,SAAS,cAA2B,GAAG;AAG/C,KAAI,cAAc,YACjB,QAAO;AAGR,QAAO,GAAG;;AAGX,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,UAAU,gBAAgB,OAAO;CAEzC,MAAM,CAAC,iBAAiB,sBAAsB,SAA6B,KAAK;CAEhF,MAAM,8BAA8B,gBAAgB,gBAAoC;AAEvF,qBAAmB,YAAY;GAC9B;AAEF,uBAAsB;AACrB,MAAI,CAAC,GAAI;EAET,MAAM,cAAc,eAAe,GAAG;AAEtC,MAAI,CAAC,gBAAgB;AACpB,kBAAe,4BAA4B,YAAY;AACvD;;EAGD,MAAM,cAAc,SAAS,cAAc,MAAM;AACjD,cAAY,KAAK;AACjB,cAAY,MAAM,UAAU;AAE5B,eAAa,sBAAsB,gBAAgB,YAAY;EAE/D,MAAM,YAAY,iBAAiB;AAClC,eAAY,YAAY,GAAG,YAAY,SAAS;KAC9C,EAAE;AAEL,8BAA4B,YAAY;AAExC,eAAa;AACZ,eAAY,QAAQ;AACpB,gBAAa,UAAU;;IAEtB;EAAC;EAAI;EAAgB;EAA4B,CAAC;AAErD,QACC,oBAAC,YAAD,EAAA,gBACQ,mBAAmB,aAAa,UAAU,iBAAiB,aAAa,EACnE,CAAA"}
|
|
@@ -2,14 +2,12 @@ import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
|
2
2
|
import { Component, useState } from "react";
|
|
3
3
|
import { createCustomContext, useCallbackRef } from "@zayne-labs/toolkit-react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
5
|
//#region src/components/common/error-boundary/error-boundary-context.ts
|
|
7
6
|
const [ErrorBoundaryContext, useErrorBoundaryContext] = createCustomContext({
|
|
8
7
|
hookName: "useErrorBoundaryContext",
|
|
9
8
|
name: "ErrorBoundaryContext",
|
|
10
9
|
providerName: "ErrorBoundaryContextProvider"
|
|
11
10
|
});
|
|
12
|
-
|
|
13
11
|
//#endregion
|
|
14
12
|
//#region src/components/common/error-boundary/error-boundary.tsx
|
|
15
13
|
const initialState = {
|
|
@@ -88,7 +86,6 @@ var ErrorBoundary = class extends Component {
|
|
|
88
86
|
}
|
|
89
87
|
};
|
|
90
88
|
};
|
|
91
|
-
|
|
92
89
|
//#endregion
|
|
93
90
|
//#region src/components/common/error-boundary/useErrorBoundary.ts
|
|
94
91
|
const useErrorBoundary = () => {
|
|
@@ -114,7 +111,7 @@ const useErrorBoundary = () => {
|
|
|
114
111
|
})
|
|
115
112
|
};
|
|
116
113
|
};
|
|
117
|
-
|
|
118
114
|
//#endregion
|
|
119
115
|
export { ErrorBoundary as n, useErrorBoundaryContext as r, useErrorBoundary as t };
|
|
120
|
-
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=error-boundary-C4btQhu_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary-C4btQhu_.js","names":["#resetErrorBoundary"],"sources":["../../src/components/common/error-boundary/error-boundary-context.ts","../../src/components/common/error-boundary/error-boundary.tsx","../../src/components/common/error-boundary/useErrorBoundary.ts"],"sourcesContent":["import { createCustomContext } from \"@zayne-labs/toolkit-react\";\n\nexport type ErrorBoundaryContextType = {\n\terror: unknown;\n\thasError: boolean;\n\tresetErrorBoundary: (...args: unknown[]) => void;\n};\n\nconst [ErrorBoundaryContext, useErrorBoundaryContext] = createCustomContext<ErrorBoundaryContextType>({\n\thookName: \"useErrorBoundaryContext\",\n\tname: \"ErrorBoundaryContext\",\n\tproviderName: \"ErrorBoundaryContextProvider\",\n});\n\nexport { ErrorBoundaryContext, useErrorBoundaryContext };\n","\"use client\";\n\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Component } from \"react\";\nimport { ErrorBoundaryContext, type ErrorBoundaryContextType } from \"./error-boundary-context\";\nimport type { ErrorBoundaryProps, ErrorFallbackProps } from \"./types\";\n\ntype ErrorBoundaryState =\n\t| {\n\t\t\terror: Error;\n\t\t\thasError: true;\n\t }\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t };\n\nconst initialState: ErrorBoundaryState = {\n\terror: null,\n\thasError: false,\n};\n\nconst hasArrayChanged = (arrayOne: unknown[] = [], arrayTwo: unknown[] = []) => {\n\treturn (\n\t\tarrayOne.length !== arrayTwo.length\n\t\t|| arrayOne.some((item, index) => !Object.is(item, arrayTwo[index]))\n\t);\n};\n\n/**\n * Copied from react-error-boundary package\n * @see https://github.com/bvaughn/react-error-boundary\n */\n\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n\tconstructor(props: ErrorBoundaryProps) {\n\t\tsuper(props);\n\n\t\tthis.state = initialState;\n\t}\n\n\tstatic getDerivedStateFromError(error: Error) {\n\t\treturn { error, hasError: true };\n\t}\n\n\toverride componentDidCatch(error: Error, info: React.ErrorInfo) {\n\t\tthis.props.onError?.({ error, info });\n\t}\n\n\toverride componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState) {\n\t\tconst { hasError } = this.state;\n\t\tconst { resetKeys } = this.props;\n\n\t\t// == There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array, we'd end up resetting the error boundary immediately.\n\t\t// == This would likely trigger a second error to be thrown.\n\t\t// == So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n\t\tif (hasError && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\tnext: resetKeys,\n\t\t\t\tprev: prevProps.resetKeys,\n\t\t\t\treason: \"keys\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t}\n\n\toverride render() {\n\t\tconst { children, fallback } = this.props;\n\t\tconst { error, hasError } = this.state;\n\n\t\tlet childToRender = children;\n\n\t\tif (hasError) {\n\t\t\tswitch (true) {\n\t\t\t\tcase isFunction(fallback): {\n\t\t\t\t\tconst fallbackRenderProps = {\n\t\t\t\t\t\terror,\n\t\t\t\t\t\tresetErrorBoundary: this.#resetErrorBoundary,\n\t\t\t\t\t} satisfies ErrorFallbackProps;\n\n\t\t\t\t\tchildToRender = fallback(fallbackRenderProps);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase Boolean(fallback): {\n\t\t\t\t\tchildToRender = fallback;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tconsole.warn(\"No fallback provided to error boundary\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst contextValue = {\n\t\t\terror,\n\t\t\thasError,\n\t\t\tresetErrorBoundary: this.#resetErrorBoundary,\n\t\t} satisfies ErrorBoundaryContextType;\n\n\t\treturn <ErrorBoundaryContext value={contextValue}>{childToRender}</ErrorBoundaryContext>;\n\t}\n\n\t#resetErrorBoundary = (...parameters: unknown[]) => {\n\t\tconst { error } = this.state;\n\n\t\tif (error !== null) {\n\t\t\tthis.props.onReset?.({\n\t\t\t\targs: parameters,\n\t\t\t\treason: \"imperative-api\",\n\t\t\t});\n\n\t\t\tthis.setState(initialState);\n\t\t}\n\t};\n}\n","import { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useErrorBoundaryContext } from \"./error-boundary-context\";\n\ntype UseErrorBoundaryState<TError extends Error> =\n\t| {\n\t\t\terror: null;\n\t\t\thasError: false;\n\t }\n\t| {\n\t\t\terror: TError;\n\t\t\thasError: true;\n\t };\n\nexport const useErrorBoundary = <TError extends Error>() => {\n\tconst { resetErrorBoundary } = useErrorBoundaryContext();\n\n\tconst [state, setState] = useState<UseErrorBoundaryState<TError>>({\n\t\terror: null,\n\t\thasError: false,\n\t});\n\n\tif (state.hasError) {\n\t\tthrow state.error;\n\t}\n\n\tconst resetBoundary = useCallbackRef(() => {\n\t\tresetErrorBoundary();\n\n\t\tsetState({\n\t\t\terror: null,\n\t\t\thasError: false,\n\t\t});\n\t});\n\n\tconst showBoundary = useCallbackRef((error: TError) => {\n\t\tsetState({\n\t\t\terror,\n\t\t\thasError: true,\n\t\t});\n\t});\n\n\treturn { resetBoundary, showBoundary };\n};\n\nexport type UseErrorBoundaryReturn = {\n\tresetBoundary: () => void;\n\tshowBoundary: (error: Error) => void;\n};\n"],"mappings":";;;;;AAQA,MAAM,CAAC,sBAAsB,2BAA2B,oBAA8C;CACrG,UAAU;CACV,MAAM;CACN,cAAc;CACd,CAAC;;;ACKF,MAAM,eAAmC;CACxC,OAAO;CACP,UAAU;CACV;AAED,MAAM,mBAAmB,WAAsB,EAAE,EAAE,WAAsB,EAAE,KAAK;AAC/E,QACC,SAAS,WAAW,SAAS,UAC1B,SAAS,MAAM,MAAM,UAAU,CAAC,OAAO,GAAG,MAAM,SAAS,OAAO,CAAC;;;;;;AAStE,IAAa,gBAAb,cAAmC,UAAkD;CACpF,YAAY,OAA2B;AACtC,QAAM,MAAM;AAEZ,OAAK,QAAQ;;CAGd,OAAO,yBAAyB,OAAc;AAC7C,SAAO;GAAE;GAAO,UAAU;GAAM;;CAGjC,kBAA2B,OAAc,MAAuB;AAC/D,OAAK,MAAM,UAAU;GAAE;GAAO;GAAM,CAAC;;CAGtC,mBAA4B,WAA+B,WAA+B;EACzF,MAAM,EAAE,aAAa,KAAK;EAC1B,MAAM,EAAE,cAAc,KAAK;AAM3B,MAAI,YAAY,UAAU,UAAU,QAAQ,gBAAgB,UAAU,WAAW,UAAU,EAAE;AAC5F,QAAK,MAAM,UAAU;IACpB,MAAM;IACN,MAAM,UAAU;IAChB,QAAQ;IACR,CAAC;AAEF,QAAK,SAAS,aAAa;;;CAI7B,SAAkB;EACjB,MAAM,EAAE,UAAU,aAAa,KAAK;EACpC,MAAM,EAAE,OAAO,aAAa,KAAK;EAEjC,IAAI,gBAAgB;AAEpB,MAAI,SACH,SAAQ,MAAR;GACC,KAAK,WAAW,SAAS;AAMxB,oBAAgB,SALY;KAC3B;KACA,oBAAoB,MAAA;KACpB,CAE4C;AAC7C;GAGD,KAAK,QAAQ,SAAS;AACrB,oBAAgB;AAChB;GAGD,QACC,SAAQ,KAAK,yCAAyC;;AAWzD,SAAO,oBAAC,sBAAD;GAAsB,OANR;IACpB;IACA;IACA,oBAAoB,MAAA;IACpB;aAEkD;GAAqC,CAAA;;CAGzF,uBAAuB,GAAG,eAA0B;EACnD,MAAM,EAAE,UAAU,KAAK;AAEvB,MAAI,UAAU,MAAM;AACnB,QAAK,MAAM,UAAU;IACpB,MAAM;IACN,QAAQ;IACR,CAAC;AAEF,QAAK,SAAS,aAAa;;;;;;ACrG9B,MAAa,yBAA+C;CAC3D,MAAM,EAAE,uBAAuB,yBAAyB;CAExD,MAAM,CAAC,OAAO,YAAY,SAAwC;EACjE,OAAO;EACP,UAAU;EACV,CAAC;AAEF,KAAI,MAAM,SACT,OAAM,MAAM;AAmBb,QAAO;EAAE,eAhBa,qBAAqB;AAC1C,uBAAoB;AAEpB,YAAS;IACR,OAAO;IACP,UAAU;IACV,CAAC;IACD;EASsB,cAPH,gBAAgB,UAAkB;AACtD,YAAS;IACR;IACA,UAAU;IACV,CAAC;IACD;EAEoC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isArray, isNumber } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
3
|
//#region src/components/common/for/for.tsx
|
|
5
4
|
const isArrayEmpty = (each) => {
|
|
6
5
|
return each == null || isNumber(each) && each === 0 || isArray(each) && each.length === 0;
|
|
@@ -27,7 +26,6 @@ function ForWithWrapper(props) {
|
|
|
27
26
|
})
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
30
|
//#region src/components/common/for/getElementList.ts
|
|
33
31
|
const getElementList = (variant) => {
|
|
@@ -37,7 +35,7 @@ const getElementList = (variant) => {
|
|
|
37
35
|
default: return [ForWithWrapper];
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
|
-
|
|
41
38
|
//#endregion
|
|
42
39
|
export { For as n, ForWithWrapper as r, getElementList as t };
|
|
43
|
-
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=for-DGTMIS0w.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for-DGTMIS0w.js","names":[],"sources":["../../src/components/common/for/for.tsx","../../src/components/common/for/getElementList.ts"],"sourcesContent":["import type {\n\tDiscriminatedRenderItemProps,\n\tPolymorphicPropsStrict,\n} from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, isNumber, type Prettify } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ArrayOrNumber = number | readonly unknown[];\n\ntype GetArrayItemType<TArray extends ArrayOrNumber> =\n\tTArray extends readonly unknown[] ? TArray[number]\n\t: TArray extends number ? number\n\t: unknown;\n\ntype RenderPropFn<TArray extends ArrayOrNumber> = (\n\titem: GetArrayItemType<TArray>,\n\tindex: number,\n\tarray: Array<GetArrayItemType<TArray>>\n) => React.ReactNode;\n\nexport type ForRenderProps<TArray extends ArrayOrNumber> = DiscriminatedRenderItemProps<\n\tRenderPropFn<TArray>\n>;\n\n/* eslint-disable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\nexport type ForProps<TArray extends ArrayOrNumber> = Prettify<\n\t{\n\t\teach: TArray;\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TArray>\n>;\n/* eslint-enable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\n\nconst isArrayEmpty = <TArray extends ArrayOrNumber>(each: TArray) => {\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- Allow\n\treturn each == null || (isNumber(each) && each === 0) || (isArray(each) && each.length === 0);\n};\n\nexport function For<const TArray extends ArrayOrNumber>(props: ForProps<TArray>) {\n\tconst { children, each, fallback = null, renderItem } = props;\n\n\tif (isArrayEmpty(each)) {\n\t\treturn fallback;\n\t}\n\n\tconst resolvedArray = isNumber(each) ? [...Array(each).keys()] : (each as unknown[]);\n\n\tconst selectedChildren = typeof children === \"function\" ? children : renderItem;\n\n\tconst elementList = resolvedArray.map((...params) => {\n\t\ttype Params = Parameters<RenderPropFn<TArray>>;\n\n\t\treturn selectedChildren(...(params as Params));\n\t});\n\n\treturn elementList;\n}\n\nexport type ForWithWrapperProps<\n\tTArray extends ArrayOrNumber,\n\tTElement extends React.ElementType = \"ul\",\n> = PolymorphicPropsStrict<TElement, ForProps<TArray>> & { displayFallBackWhenEmpty?: boolean };\n\nexport function ForWithWrapper<\n\tconst TArray extends ArrayOrNumber,\n\tTElement extends React.ElementType = \"ul\",\n>(props: ForWithWrapperProps<TArray, TElement>) {\n\tconst {\n\t\tas: ListContainer = \"ul\",\n\t\tchildren,\n\t\tdisplayFallBackWhenEmpty = false,\n\t\teach,\n\t\tfallback = null,\n\t\trenderItem,\n\t\t...restOfProps\n\t} = props;\n\n\tif (displayFallBackWhenEmpty && isArrayEmpty(each)) {\n\t\treturn fallback;\n\t}\n\n\treturn (\n\t\t<ListContainer {...restOfProps}>\n\t\t\t<For {...({ children, each, fallback, renderItem } as ForProps<TArray>)} />\n\t\t</ListContainer>\n\t);\n}\n","import { For, ForWithWrapper } from \"./for\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> =\n\tTVariant extends \"base\" ? [typeof For] : [typeof ForWithWrapper];\n\nconst getElementList = <TVariant extends \"base\" | \"withWrapper\" = \"withWrapper\">(\n\tvariant?: TVariant\n): GetElementListResult<TVariant> => {\n\tswitch (variant) {\n\t\tcase \"base\": {\n\t\t\treturn [For] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [ForWithWrapper] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [ForWithWrapper] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"],"mappings":";;;AAgCA,MAAM,gBAA8C,SAAiB;AAEpE,QAAO,QAAQ,QAAS,SAAS,KAAK,IAAI,SAAS,KAAO,QAAQ,KAAK,IAAI,KAAK,WAAW;;AAG5F,SAAgB,IAAwC,OAAyB;CAChF,MAAM,EAAE,UAAU,MAAM,WAAW,MAAM,eAAe;AAExD,KAAI,aAAa,KAAK,CACrB,QAAO;CAGR,MAAM,gBAAgB,SAAS,KAAK,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,GAAI;CAElE,MAAM,mBAAmB,OAAO,aAAa,aAAa,WAAW;AAQrE,QANoB,cAAc,KAAK,GAAG,WAAW;AAGpD,SAAO,iBAAiB,GAAI,OAAkB;GAC7C;;AAUH,SAAgB,eAGd,OAA8C;CAC/C,MAAM,EACL,IAAI,gBAAgB,MACpB,UACA,2BAA2B,OAC3B,MACA,WAAW,MACX,YACA,GAAG,gBACA;AAEJ,KAAI,4BAA4B,aAAa,KAAK,CACjD,QAAO;AAGR,QACC,oBAAC,eAAD;EAAe,GAAI;YAClB,oBAAC,KAAD;GAAY;GAAU;GAAM;GAAU;GAAqC,CAAA;EAC5D,CAAA;;;;AC9ElB,MAAM,kBACL,YACoC;AACpC,SAAQ,SAAR;EACC,KAAK,OACJ,QAAO,CAAC,IAAI;EAEb,KAAK,cACJ,QAAO,CAAC,eAAe;EAExB,QACC,QAAO,CAAC,eAAe"}
|
|
@@ -65,6 +65,10 @@ declare const useErrorBoundary: <TError extends Error>() => {
|
|
|
65
65
|
resetBoundary: () => void;
|
|
66
66
|
showBoundary: (error: TError) => void;
|
|
67
67
|
};
|
|
68
|
+
type UseErrorBoundaryReturn = {
|
|
69
|
+
resetBoundary: () => void;
|
|
70
|
+
showBoundary: (error: Error) => void;
|
|
71
|
+
};
|
|
68
72
|
//#endregion
|
|
69
|
-
export {
|
|
70
|
-
//# sourceMappingURL=
|
|
73
|
+
export { ErrorBoundary as a, useErrorBoundaryContext as i, useErrorBoundary as n, ErrorBoundaryProps as o, ErrorBoundaryContextType as r, ErrorFallbackProps as s, UseErrorBoundaryReturn as t };
|
|
74
|
+
//# sourceMappingURL=index-BUIvQ2wP.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as ErrorBoundaryProps } from "./index-BUIvQ2wP.js";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/suspense-with-boundary/suspense-with-boundary.d.ts
|
|
@@ -10,4 +10,4 @@ type SuspenseWithBoundaryProps = {
|
|
|
10
10
|
declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react_jsx_runtime0.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { SuspenseWithBoundaryProps as n, SuspenseWithBoundary as t };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=index-ClV6w6nv.d.ts.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { n as SlotRoot } from "./slot-
|
|
1
|
+
import { n as SlotRoot } from "./slot-DuwoiC2C.js";
|
|
2
2
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
4
4
|
import { useCallbackRef, useComposeRefs, useToggle } from "@zayne-labs/toolkit-react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { dataAttr, on } from "@zayne-labs/toolkit-core";
|
|
7
|
-
|
|
8
7
|
//#region src/components/common/presence/use-presence.ts
|
|
9
8
|
const useStateMachine = (config) => {
|
|
10
9
|
const reducer = (prevState, event) => {
|
|
@@ -115,12 +114,12 @@ const usePresence = (options) => {
|
|
|
115
114
|
if (!(event.target === node && !prevNodeStateRef.current.prevPresent)) return;
|
|
116
115
|
send("ANIMATION_END");
|
|
117
116
|
};
|
|
118
|
-
const onAnimationStartCleanup = on("animationstart",
|
|
119
|
-
const onAnimationEndCleanup = on("animationend",
|
|
120
|
-
const onAnimationCancelCleanup = on("animationcancel",
|
|
121
|
-
const onTransitionRunCleanup = on("transitionrun",
|
|
122
|
-
const onTransitionEndCleanup = on("transitionend",
|
|
123
|
-
const onTransitionCancelCleanup = on("transitioncancel",
|
|
117
|
+
const onAnimationStartCleanup = on(node, "animationstart", handleAnimationStart);
|
|
118
|
+
const onAnimationEndCleanup = on(node, "animationend", handleAnimationEnd);
|
|
119
|
+
const onAnimationCancelCleanup = on(node, "animationcancel", handleAnimationEnd);
|
|
120
|
+
const onTransitionRunCleanup = on(node, "transitionrun", handleTransitionRun);
|
|
121
|
+
const onTransitionEndCleanup = on(node, "transitionend", handleTransitionEnd);
|
|
122
|
+
const onTransitionCancelCleanup = on(node, "transitioncancel", handleTransitionEnd);
|
|
124
123
|
return () => {
|
|
125
124
|
ownerWindow.clearTimeout(timeoutId);
|
|
126
125
|
onAnimationStartCleanup();
|
|
@@ -181,7 +180,6 @@ const usePresence = (options) => {
|
|
|
181
180
|
shouldStartTransition
|
|
182
181
|
]);
|
|
183
182
|
};
|
|
184
|
-
|
|
185
183
|
//#endregion
|
|
186
184
|
//#region src/components/common/presence/presence.tsx
|
|
187
185
|
function Presence(props) {
|
|
@@ -205,7 +203,7 @@ function Presence(props) {
|
|
|
205
203
|
children: resolvedChild
|
|
206
204
|
});
|
|
207
205
|
}
|
|
208
|
-
|
|
209
206
|
//#endregion
|
|
210
207
|
export { Presence as t };
|
|
211
|
-
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=presence-CWOGx-be.js.map
|