@zayne-labs/ui-react 0.10.47 → 0.10.48
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/css/animation.css +0 -2
- package/dist/esm/{client-gate-Ch5I9_pc.js → client-gate-BhR-cK58.js} +1 -1
- package/dist/esm/{client-gate-Ch5I9_pc.js.map → client-gate-BhR-cK58.js.map} +1 -1
- package/dist/esm/{cn-pbJoeyH6.js → cn-2hIN1AQ7.js} +1 -1
- package/dist/esm/{cn-pbJoeyH6.js.map → cn-2hIN1AQ7.js.map} +1 -1
- package/dist/esm/common/await/index.d.ts +6 -6
- package/dist/esm/common/await/index.js +3 -3
- package/dist/esm/common/client-gate/index.d.ts +2 -2
- package/dist/esm/common/client-gate/index.js +1 -1
- package/dist/esm/common/error-boundary/index.d.ts +1 -1
- package/dist/esm/common/error-boundary/index.js +1 -1
- package/dist/esm/common/for/index.d.ts +4 -4
- package/dist/esm/common/for/index.js +1 -1
- package/dist/esm/common/presence/index.d.ts +2 -2
- package/dist/esm/common/presence/index.js +1 -1
- package/dist/esm/common/show/index.d.ts +4 -4
- package/dist/esm/common/show/index.js +1 -1
- package/dist/esm/common/slot/index.d.ts +4 -4
- package/dist/esm/common/slot/index.js +1 -1
- package/dist/esm/common/suspense-with-boundary/index.d.ts +2 -2
- package/dist/esm/common/suspense-with-boundary/index.js +1 -1
- package/dist/esm/common/teleport/index.d.ts +2 -2
- package/dist/esm/common/teleport/index.js +2 -2
- package/dist/esm/{error-boundary-pMMeMfwH.js → error-boundary-BwGXKuLC.js} +2 -2
- package/dist/esm/{error-boundary-pMMeMfwH.js.map → error-boundary-BwGXKuLC.js.map} +1 -1
- package/dist/esm/{for-IenHovla.js → for-DAM4xYij.js} +1 -1
- package/dist/esm/{for-IenHovla.js.map → for-DAM4xYij.js.map} +1 -1
- package/dist/esm/{index-DtJyivJH.d.ts → index-C-H0yigJ.d.ts} +6 -6
- package/dist/esm/{index-CW1qt3Kq.d.ts → index-CgqbRWLA.d.ts} +4 -4
- package/dist/esm/{presence-BbOLyzEd.js → presence-DpApdmSc.js} +3 -3
- package/dist/esm/{presence-BbOLyzEd.js.map → presence-DpApdmSc.js.map} +1 -1
- package/dist/esm/{show-CWSAcfVL.js → show-CtivYwYS.js} +1 -1
- package/dist/esm/{show-CWSAcfVL.js.map → show-CtivYwYS.js.map} +1 -1
- package/dist/esm/{slot-C56gqKvk.js → slot-C7TE8pEK.js} +1 -1
- package/dist/esm/{slot-C56gqKvk.js.map → slot-C7TE8pEK.js.map} +1 -1
- package/dist/esm/ui/card/index.js +2 -2
- package/dist/esm/ui/carousel/index.d.ts +9 -9
- package/dist/esm/ui/carousel/index.js +4 -4
- package/dist/esm/ui/drag-scroll/index.d.ts +4 -4
- package/dist/esm/ui/drag-scroll/index.js +2 -2
- package/dist/esm/ui/drop-zone/index.d.ts +17 -17
- package/dist/esm/ui/drop-zone/index.js +5 -5
- package/dist/esm/ui/form/index.d.ts +22 -22
- package/dist/esm/ui/form/index.js +4 -4
- package/dist/style.css +0 -101
- package/package.json +5 -10
package/css/animation.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-gate-
|
|
1
|
+
{"version":3,"file":"client-gate-BhR-cK58.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\ntype 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cn-
|
|
1
|
+
{"version":3,"file":"cn-2hIN1AQ7.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,8 +1,8 @@
|
|
|
1
|
-
import { a as ErrorBoundaryProps } from "../../index-
|
|
2
|
-
import { n as SuspenseWithBoundaryProps } from "../../index-
|
|
1
|
+
import { a as ErrorBoundaryProps } from "../../index-C-H0yigJ.js";
|
|
2
|
+
import { n as SuspenseWithBoundaryProps } from "../../index-CgqbRWLA.js";
|
|
3
3
|
import { GetSlotComponentProps } from "@zayne-labs/toolkit-react/utils";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
4
|
+
import * as react4 from "react";
|
|
5
|
+
import * as react_jsx_runtime16 from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/common/await/await.d.ts
|
|
8
8
|
type RenderPropFn<TValue> = (result: TValue) => React.ReactNode;
|
|
@@ -14,9 +14,9 @@ type AwaitRootProps<TValue> = Pick<SuspenseWithBoundaryProps, "errorFallback" |
|
|
|
14
14
|
withErrorBoundary?: boolean;
|
|
15
15
|
withSuspense?: boolean;
|
|
16
16
|
};
|
|
17
|
-
declare function AwaitRoot<TValue>(props: AwaitRootProps<TValue>):
|
|
17
|
+
declare function AwaitRoot<TValue>(props: AwaitRootProps<TValue>): react_jsx_runtime16.JSX.Element;
|
|
18
18
|
type AwaitSuccessProps<TValue = unknown> = GetSlotComponentProps<"default", ChildrenType<TValue>>;
|
|
19
|
-
declare function AwaitSuccess<TPromiseOrValue, TValue = Awaited<TPromiseOrValue>>(props: Pick<AwaitSuccessProps<TValue>, "children">):
|
|
19
|
+
declare function AwaitSuccess<TPromiseOrValue, TValue = Awaited<TPromiseOrValue>>(props: Pick<AwaitSuccessProps<TValue>, "children">): react4.ReactNode;
|
|
20
20
|
type AwaitErrorProps = GetSlotComponentProps<"error", ErrorBoundaryProps["fallback"]>;
|
|
21
21
|
declare const AwaitError: {
|
|
22
22
|
(props: Pick<AwaitErrorProps, "children"> & {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
4
|
-
import { n as
|
|
5
|
-
import { n as
|
|
4
|
+
import { n as ErrorBoundary, r as useErrorBoundaryContext } from "../../error-boundary-BwGXKuLC.js";
|
|
5
|
+
import { n as SlotRoot } from "../../slot-C7TE8pEK.js";
|
|
6
6
|
import { getSlotMap, withSlotNameAndSymbol } from "@zayne-labs/toolkit-react/utils";
|
|
7
7
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
8
8
|
import { Fragment, Suspense, use, useMemo } from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
9
|
import { createCustomContext } from "@zayne-labs/toolkit-react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/components/common/await/await-context.ts
|
|
13
13
|
const [AwaitContextProvider, useAwaitContextImpl] = createCustomContext({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react3 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/common/client-gate/client-gate.d.ts
|
|
4
4
|
type ClientGateProps = {
|
|
@@ -27,7 +27,7 @@ type ClientGateProps = {
|
|
|
27
27
|
* );
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
declare function ClientGate(props: ClientGateProps):
|
|
30
|
+
declare function ClientGate(props: ClientGateProps): react3.ReactNode;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { ClientGate };
|
|
33
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ErrorBoundaryProps, i as ErrorBoundary, n as ErrorBoundaryContextType, o as ErrorFallbackProps, r as useErrorBoundaryContext, t as useErrorBoundary } from "../../index-
|
|
1
|
+
import { a as ErrorBoundaryProps, i as ErrorBoundary, n as ErrorBoundaryContextType, o as ErrorFallbackProps, r as useErrorBoundaryContext, t as useErrorBoundary } from "../../index-C-H0yigJ.js";
|
|
2
2
|
export { ErrorBoundary, ErrorBoundaryContextType, ErrorBoundaryProps, ErrorFallbackProps, useErrorBoundary, useErrorBoundaryContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { n as ErrorBoundary, r as useErrorBoundaryContext, t as useErrorBoundary } from "../../error-boundary-
|
|
3
|
+
import { n as ErrorBoundary, r as useErrorBoundaryContext, t as useErrorBoundary } from "../../error-boundary-BwGXKuLC.js";
|
|
4
4
|
|
|
5
5
|
export { ErrorBoundary, useErrorBoundary, useErrorBoundaryContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DiscriminatedRenderItemProps, PolymorphicPropsStrict } from "@zayne-labs/toolkit-react/utils";
|
|
2
2
|
import { Prettify } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
3
|
+
import * as react6 from "react";
|
|
4
|
+
import * as react_jsx_runtime19 from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/common/for/for.d.ts
|
|
7
7
|
type ArrayOrNumber = number | readonly unknown[];
|
|
@@ -12,10 +12,10 @@ type ForProps<TArray extends ArrayOrNumber> = Prettify<{
|
|
|
12
12
|
each: TArray;
|
|
13
13
|
fallback?: React.ReactNode;
|
|
14
14
|
} & ForRenderProps<TArray>>;
|
|
15
|
-
declare function For<const TArray extends ArrayOrNumber>(props: ForProps<TArray>): string | number | bigint | boolean |
|
|
15
|
+
declare function For<const TArray extends ArrayOrNumber>(props: ForProps<TArray>): string | number | bigint | boolean | react6.ReactElement<unknown, string | react6.JSXElementConstructor<any>> | Iterable<react6.ReactNode> | Promise<string | number | bigint | boolean | react6.ReactPortal | react6.ReactElement<unknown, string | react6.JSXElementConstructor<any>> | Iterable<react6.ReactNode> | null | undefined> | null;
|
|
16
16
|
declare function ForWithWrapper<const TArray extends ArrayOrNumber, TElement extends React.ElementType = "ul">(props: PolymorphicPropsStrict<TElement, ForProps<TArray>> & {
|
|
17
17
|
displayFallBackWhenEmpty?: boolean;
|
|
18
|
-
}): string | number | bigint | boolean |
|
|
18
|
+
}): string | number | bigint | boolean | react_jsx_runtime19.JSX.Element | Iterable<react6.ReactNode> | Promise<string | number | bigint | boolean | react6.ReactPortal | react6.ReactElement<unknown, string | react6.JSXElementConstructor<any>> | Iterable<react6.ReactNode> | null | undefined> | null;
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/components/common/for/getElementList.d.ts
|
|
21
21
|
type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof For] : [typeof ForWithWrapper];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InferProps } from "@zayne-labs/toolkit-react/utils";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime17 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/presence/use-presence.d.ts
|
|
5
5
|
type UsePresenceOptions = {
|
|
@@ -30,7 +30,7 @@ type PresenceProps = UsePresenceOptions & {
|
|
|
30
30
|
className?: string;
|
|
31
31
|
forceMount?: boolean;
|
|
32
32
|
};
|
|
33
|
-
declare function Presence(props: PresenceProps):
|
|
33
|
+
declare function Presence(props: PresenceProps): react_jsx_runtime17.JSX.Element | null;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { Presence };
|
|
36
36
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react26 from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/components/common/show/show.d.ts
|
|
4
4
|
type ShowProps<TWhen> = {
|
|
@@ -12,15 +12,15 @@ type ShowProps<TWhen> = {
|
|
|
12
12
|
fallback?: React.ReactNode;
|
|
13
13
|
when: false | TWhen | null | undefined;
|
|
14
14
|
};
|
|
15
|
-
declare function ShowRoot<TWhen>(props: ShowProps<TWhen>): string | number | bigint | boolean |
|
|
15
|
+
declare function ShowRoot<TWhen>(props: ShowProps<TWhen>): string | number | bigint | boolean | react26.ReactElement<unknown, string | react26.JSXElementConstructor<any>> | Iterable<react26.ReactNode> | Promise<string | number | bigint | boolean | react26.ReactPortal | react26.ReactElement<unknown, string | react26.JSXElementConstructor<any>> | Iterable<react26.ReactNode> | null | undefined> | null;
|
|
16
16
|
type ShowContentProps<TWhen> = Pick<ShowProps<TWhen>, "children" | "when">;
|
|
17
|
-
declare function ShowContent<TWhen>(props: ShowContentProps<TWhen>):
|
|
17
|
+
declare function ShowContent<TWhen>(props: ShowContentProps<TWhen>): react26.ReactNode;
|
|
18
18
|
declare namespace ShowContent {
|
|
19
19
|
var slotSymbol: symbol;
|
|
20
20
|
}
|
|
21
21
|
declare function ShowFallback(props: {
|
|
22
22
|
children: React.ReactNode;
|
|
23
|
-
}):
|
|
23
|
+
}): react26.ReactNode;
|
|
24
24
|
declare namespace ShowFallback {
|
|
25
25
|
var slotSymbol: symbol;
|
|
26
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { i as ShowRoot, n as ShowContent, r as ShowFallback, t as show_parts_exports } from "../../show-
|
|
3
|
+
import { i as ShowRoot, n as ShowContent, r as ShowFallback, t as show_parts_exports } from "../../show-CtivYwYS.js";
|
|
4
4
|
|
|
5
5
|
export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { InferProps } from "@zayne-labs/toolkit-react/utils";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as react21 from "react";
|
|
3
|
+
import * as react_jsx_runtime20 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/common/slot/slot.d.ts
|
|
6
6
|
type SlotProps = InferProps<HTMLElement> & {
|
|
7
7
|
ref?: React.Ref<HTMLElement>;
|
|
8
8
|
};
|
|
9
|
-
declare function SlotRoot(props: SlotProps):
|
|
9
|
+
declare function SlotRoot(props: SlotProps): react_jsx_runtime20.JSX.Element | null;
|
|
10
10
|
declare function SlotSlottable({
|
|
11
11
|
children
|
|
12
|
-
}: Pick<SlotProps, "children">):
|
|
12
|
+
}: Pick<SlotProps, "children">): react21.ReactNode;
|
|
13
13
|
declare namespace slot_parts_d_exports {
|
|
14
14
|
export { SlotRoot as Root, SlotSlottable as Slottable };
|
|
15
15
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import { n as SuspenseWithBoundaryProps, t as SuspenseWithBoundary } from "../../index-
|
|
1
|
+
import "../../index-C-H0yigJ.js";
|
|
2
|
+
import { n as SuspenseWithBoundaryProps, t as SuspenseWithBoundary } from "../../index-CgqbRWLA.js";
|
|
3
3
|
export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyString } from "@zayne-labs/toolkit-type-helpers";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime18 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/common/teleport/teleport.d.ts
|
|
5
5
|
type ValidHtmlTags = keyof HTMLElementTagNameMap;
|
|
@@ -8,7 +8,7 @@ type PortalProps = {
|
|
|
8
8
|
insertPosition?: InsertPosition;
|
|
9
9
|
to: AnyString | HTMLElement | React.RefObject<HTMLElement> | ValidHtmlTags | null;
|
|
10
10
|
};
|
|
11
|
-
declare function Teleport(props: PortalProps):
|
|
11
|
+
declare function Teleport(props: PortalProps): react_jsx_runtime18.JSX.Element;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { Teleport };
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as ClientGate } from "../../client-gate-
|
|
1
|
+
import { t as ClientGate } from "../../client-gate-BhR-cK58.js";
|
|
2
2
|
import { isString } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { useLayoutEffect, useState } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { useCallbackRef } from "@zayne-labs/toolkit-react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
|
|
8
8
|
//#region src/components/common/teleport/teleport.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import { Component, useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
import { createCustomContext, useCallbackRef } from "@zayne-labs/toolkit-react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/common/error-boundary/error-boundary-context.ts
|
|
7
7
|
const [ErrorBoundaryContext, useErrorBoundaryContext] = createCustomContext({
|
|
@@ -117,4 +117,4 @@ const useErrorBoundary = () => {
|
|
|
117
117
|
|
|
118
118
|
//#endregion
|
|
119
119
|
export { ErrorBoundary as n, useErrorBoundaryContext as r, useErrorBoundary as t };
|
|
120
|
-
//# sourceMappingURL=error-boundary-
|
|
120
|
+
//# sourceMappingURL=error-boundary-BwGXKuLC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-boundary-
|
|
1
|
+
{"version":3,"file":"error-boundary-BwGXKuLC.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"],"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,m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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"for-
|
|
1
|
+
{"version":3,"file":"for-DAM4xYij.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 */\ntype 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 function ForWithWrapper<\n\tconst TArray extends ArrayOrNumber,\n\tTElement extends React.ElementType = \"ul\",\n>(props: PolymorphicPropsStrict<TElement, ForProps<TArray>> & { displayFallBackWhenEmpty?: boolean }) {\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;;AAKH,SAAgB,eAGd,OAAoG;CACrG,MAAM,EACL,IAAI,gBAAgB,MACpB,UACA,2BAA2B,OAC3B,MACA,WAAW,MACX,YACA,GAAG,gBACA;AAEJ,KAAI,4BAA4B,aAAa,KAAK,CACjD,QAAO;AAGR,QACC,oBAAC;EAAc,GAAI;YAClB,oBAAC;GAAW;GAAU;GAAM;GAAU;IAAqC;GAC5D;;;;;ACzElB,MAAM,kBACL,YACoC;AACpC,SAAQ,SAAR;EACC,KAAK,OACJ,QAAO,CAAC,IAAI;EAEb,KAAK,cACJ,QAAO,CAAC,eAAe;EAExB,QACC,QAAO,CAAC,eAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react2 from "react";
|
|
2
2
|
import { Component } from "react";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
3
|
+
import * as _zayne_labs_toolkit_react0 from "@zayne-labs/toolkit-react";
|
|
4
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/common/error-boundary/types.d.ts
|
|
7
7
|
type ErrorFallbackProps = {
|
|
@@ -49,7 +49,7 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
|
|
|
49
49
|
};
|
|
50
50
|
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
51
51
|
componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
|
|
52
|
-
render():
|
|
52
|
+
render(): react_jsx_runtime7.JSX.Element;
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/components/common/error-boundary/error-boundary-context.d.ts
|
|
@@ -58,7 +58,7 @@ type ErrorBoundaryContextType = {
|
|
|
58
58
|
hasError: boolean;
|
|
59
59
|
resetErrorBoundary: (...args: unknown[]) => void;
|
|
60
60
|
};
|
|
61
|
-
declare const ErrorBoundaryContext:
|
|
61
|
+
declare const ErrorBoundaryContext: react2.Context<ErrorBoundaryContextType>, useErrorBoundaryContext: _zayne_labs_toolkit_react0.UseCustomContext<ErrorBoundaryContextType, true>;
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/components/common/error-boundary/useErrorBoundary.d.ts
|
|
64
64
|
declare const useErrorBoundary: <TError extends Error>() => {
|
|
@@ -67,4 +67,4 @@ declare const useErrorBoundary: <TError extends Error>() => {
|
|
|
67
67
|
};
|
|
68
68
|
//#endregion
|
|
69
69
|
export { ErrorBoundaryProps as a, ErrorBoundary as i, ErrorBoundaryContextType as n, ErrorFallbackProps as o, useErrorBoundaryContext as r, useErrorBoundary as t };
|
|
70
|
-
//# sourceMappingURL=index-
|
|
70
|
+
//# sourceMappingURL=index-C-H0yigJ.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ErrorBoundaryProps } from "./index-
|
|
2
|
-
import * as
|
|
1
|
+
import { a as ErrorBoundaryProps } from "./index-C-H0yigJ.js";
|
|
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
|
|
5
5
|
type SuspenseWithBoundaryProps = {
|
|
@@ -7,7 +7,7 @@ type SuspenseWithBoundaryProps = {
|
|
|
7
7
|
errorFallback?: ErrorBoundaryProps["fallback"];
|
|
8
8
|
fallback?: React.ReactNode;
|
|
9
9
|
};
|
|
10
|
-
declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps):
|
|
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=index-
|
|
13
|
+
//# sourceMappingURL=index-CgqbRWLA.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as SlotRoot } from "./slot-
|
|
1
|
+
import { n as SlotRoot } from "./slot-C7TE8pEK.js";
|
|
2
2
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
4
|
+
import { useCallbackRef, useComposeRefs, useToggle } from "@zayne-labs/toolkit-react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
import { dataAttr, on } from "@zayne-labs/toolkit-core";
|
|
6
|
-
import { useCallbackRef, useComposeRefs, useToggle } from "@zayne-labs/toolkit-react";
|
|
7
7
|
|
|
8
8
|
//#region src/components/common/presence/use-presence.ts
|
|
9
9
|
const useStateMachine = (config) => {
|
|
@@ -208,4 +208,4 @@ function Presence(props) {
|
|
|
208
208
|
|
|
209
209
|
//#endregion
|
|
210
210
|
export { Presence as t };
|
|
211
|
-
//# sourceMappingURL=presence-
|
|
211
|
+
//# sourceMappingURL=presence-DpApdmSc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presence-BbOLyzEd.js","names":["Slot.Root"],"sources":["../../src/components/common/presence/use-presence.ts","../../src/components/common/presence/presence.tsx"],"sourcesContent":["import { dataAttr, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from \"react\";\n\ntype StateMachineConfig<TState extends string, TEvent extends string> = {\n\tinitial: TState;\n\tstates: Record<TState, Partial<Record<TEvent, TState>>>;\n};\n\nconst useStateMachine = <TState extends string, TEvent extends string>(\n\tconfig: StateMachineConfig<TState, TEvent>\n) => {\n\tconst reducer = (prevState: TState, event: TEvent): TState => {\n\t\tconst newState = config.states[prevState][event] ?? prevState;\n\n\t\treturn newState;\n\t};\n\n\treturn useReducer(reducer, config.initial);\n};\n\nconst getAnimationName = (styles: CSSStyleDeclaration | null) => styles?.animationName ?? \"none\";\n\nexport type UsePresenceOptions = {\n\tonExitComplete?: () => void;\n\tpresent: boolean;\n\t/**\n\t * @default \"animation\"\n\t */\n\tvariant?: \"animation\" | \"transition\";\n};\n\nexport type UsePresenceResult = {\n\tisPresent: boolean;\n\tisPresentOrIsTransitionComplete: boolean;\n\tpropGetters: {\n\t\tgetPresenceProps: (innerProps: InferProps<HTMLElement>) => InferProps<HTMLElement>;\n\t};\n\tref: React.Ref<HTMLElement>;\n\tshouldStartTransition: boolean;\n};\n\n/**\n * React hook that provides the ability to animate the mount/unmount of a component.\n * @see https://github.com/radix-ui/primitives/blob/main/packages/react/presence/src/presence.tsx\n */\n\nconst usePresence = (options: UsePresenceOptions): UsePresenceResult => {\n\tconst { onExitComplete, present: presentProp, variant = \"animation\" } = options;\n\n\tconst stableOnExitComplete = useCallbackRef(onExitComplete);\n\n\tconst [node, setNode] = useState<HTMLElement | null>(null);\n\n\tconst [hasTransitioned, toggleHasTransitioned] = useToggle(false);\n\n\tconst stylesRef = useRef<CSSStyleDeclaration | null>(null);\n\n\tconst prevNodeStateRef = useRef<{\n\t\tprevAnimationName: string;\n\t\tprevPresent: boolean;\n\t}>({\n\t\tprevAnimationName: \"none\",\n\t\tprevPresent: presentProp,\n\t});\n\n\tconst initialState = presentProp ? \"mounted\" : \"unmounted\";\n\n\tconst [state, send] = useStateMachine({\n\t\tinitial: initialState,\n\t\tstates: {\n\t\t\tmounted: {\n\t\t\t\tANIMATION_OUT: \"unmountSuspended\",\n\t\t\t\tUNMOUNT: \"unmounted\",\n\t\t\t},\n\t\t\tunmounted: {\n\t\t\t\tMOUNT: \"mounted\",\n\t\t\t},\n\t\t\tunmountSuspended: {\n\t\t\t\tANIMATION_END: \"unmounted\",\n\t\t\t\tMOUNT: \"mounted\",\n\t\t\t},\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst currentAnimationName = getAnimationName(stylesRef.current);\n\n\t\tprevNodeStateRef.current.prevAnimationName = state === \"mounted\" ? currentAnimationName : \"none\";\n\t}, [state]);\n\n\tuseLayoutEffect(() => {\n\t\tconst styles = stylesRef.current;\n\t\tconst wasPresent = prevNodeStateRef.current.prevPresent;\n\t\tconst hasPresentChanged = wasPresent !== presentProp;\n\n\t\tif (!hasPresentChanged) return;\n\n\t\tconst prevAnimationName = prevNodeStateRef.current.prevAnimationName;\n\t\tconst currentAnimationName = getAnimationName(styles);\n\n\t\tswitch (true) {\n\t\t\tcase presentProp: {\n\t\t\t\tsend(\"MOUNT\");\n\n\t\t\t\tif (variant === \"transition\") {\n\t\t\t\t\trequestAnimationFrame(() => toggleHasTransitioned(true));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line react-hooks/todo -- Ignore\n\t\t\tcase Boolean(node) && variant === \"animation\": {\n\t\t\t\tconst hasAnimation = currentAnimationName !== \"none\" && styles?.display !== \"none\";\n\n\t\t\t\t/**\n\t\t\t\t * When `present` changes to `false`, we check changes to animation-name to\n\t\t\t\t * determine whether an animation has started. We chose this approach (reading\n\t\t\t\t * computed styles) because there is no `animationrun` event (like the `transitionrun` event) and `animationstart`\n\t\t\t\t * fires after `animation-delay` has expired which would be too late.\n\t\t\t\t */\n\n\t\t\t\tconst isAnimationStarted = hasAnimation && prevAnimationName !== currentAnimationName;\n\n\t\t\t\tconst isAnimatingOut = wasPresent && isAnimationStarted;\n\n\t\t\t\tsend(isAnimatingOut ? \"ANIMATION_OUT\" : \"UNMOUNT\");\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tsend(\"UNMOUNT\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tprevNodeStateRef.current.prevPresent = presentProp;\n\t}, [presentProp, node, send, variant, toggleHasTransitioned]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!node) {\n\t\t\t// Transition to the unmounted state if the node is removed prematurely.\n\t\t\t// We avoid doing so during cleanup as the node may change but still exist.\n\t\t\tsend(\"ANIMATION_END\");\n\t\t\treturn;\n\t\t}\n\n\t\tlet timeoutId: number;\n\n\t\tconst ownerWindow = node.ownerDocument.defaultView ?? globalThis;\n\n\t\tconst handleAnimationStart = (event: AnimationEvent) => {\n\t\t\tconst isTargetAnimatingNode = event.target === node;\n\n\t\t\tif (!isTargetAnimatingNode) return;\n\n\t\t\tprevNodeStateRef.current.prevAnimationName = getAnimationName(stylesRef.current);\n\t\t};\n\n\t\t/**\n\t\t * @description Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n\t\t * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n\t\t * make sure we only trigger ANIMATION_END for the currently active animation.\n\t\t */\n\t\tconst handleAnimationEnd = (event: AnimationEvent) => {\n\t\t\tconst currentAnimationName = getAnimationName(stylesRef.current);\n\n\t\t\t// The event.animationName is unescaped for CSS syntax, so we need to escape it to compare with the animationName computed from the style.\n\t\t\tconst isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));\n\n\t\t\tconst isTargetAnimatingNode = event.target === node && isCurrentAnimation;\n\n\t\t\tif (!isTargetAnimatingNode) return;\n\n\t\t\t// With React 18 concurrency this update is applied a frame after the\n\t\t\t// animation ends, creating a flash of visible content. By setting the\n\t\t\t// animation fill mode to \"forwards\", we force the node to keep the\n\t\t\t// styles of the last keyframe, removing the flash.\n\n\t\t\t// Previously we flushed the update via ReactDom.flushSync, but with\n\t\t\t// exit animations this resulted in the node being removed from the\n\t\t\t// DOM before the synthetic animationEnd event was dispatched, meaning\n\t\t\t// user-provided event handlers would not be called.\n\t\t\t// https://github.com/radix-ui/primitives/pull/1849\n\t\t\tsend(\"ANIMATION_END\");\n\n\t\t\tif (!prevNodeStateRef.current.prevPresent) {\n\t\t\t\tconst currentFillMode = node.style.animationFillMode;\n\t\t\t\tnode.style.animationFillMode = \"forwards\";\n\n\t\t\t\t// Reset the style after the node had time to unmount (for cases\n\t\t\t\t// where the component chooses not to unmount). Doing this any\n\t\t\t\t// sooner than `setTimeout` (e.g. with `requestAnimationFrame`)\n\t\t\t\t// still causes a flash.\n\t\t\t\ttimeoutId = ownerWindow.setTimeout(() => {\n\t\t\t\t\tif (node.style.animationFillMode === \"forwards\") {\n\t\t\t\t\t\tnode.style.animationFillMode = currentFillMode;\n\t\t\t\t\t}\n\t\t\t\t}) as never;\n\t\t\t}\n\t\t};\n\n\t\tconst handleTransitionRun = (event: TransitionEvent) => {\n\t\t\tconst isTargetTransitioningNode = event.target === node;\n\n\t\t\tif (!isTargetTransitioningNode) return;\n\n\t\t\tsend(\"ANIMATION_OUT\");\n\t\t};\n\n\t\tconst handleTransitionEnd = (event: TransitionEvent) => {\n\t\t\tconst isTargetTransitioningNode = event.target === node && !prevNodeStateRef.current.prevPresent;\n\n\t\t\tif (!isTargetTransitioningNode) return;\n\n\t\t\tsend(\"ANIMATION_END\");\n\t\t};\n\n\t\tconst onAnimationStartCleanup = on(\"animationstart\", node, handleAnimationStart);\n\t\tconst onAnimationEndCleanup = on(\"animationend\", node, handleAnimationEnd);\n\t\tconst onAnimationCancelCleanup = on(\"animationcancel\", node, handleAnimationEnd);\n\n\t\tconst onTransitionRunCleanup = on(\"transitionrun\", node, handleTransitionRun);\n\t\tconst onTransitionEndCleanup = on(\"transitionend\", node, handleTransitionEnd);\n\t\tconst onTransitionCancelCleanup = on(\"transitioncancel\", node, handleTransitionEnd);\n\n\t\treturn () => {\n\t\t\townerWindow.clearTimeout(timeoutId);\n\t\t\tonAnimationStartCleanup();\n\t\t\tonAnimationEndCleanup();\n\t\t\tonAnimationCancelCleanup();\n\n\t\t\tonTransitionRunCleanup();\n\t\t\tonTransitionEndCleanup();\n\t\t\tonTransitionCancelCleanup();\n\t\t};\n\t}, [node, send]);\n\n\tuseEffect(() => {\n\t\tconst isExitCompleted = state === \"unmounted\" && !presentProp;\n\n\t\tif (isExitCompleted) {\n\t\t\ttoggleHasTransitioned(false);\n\t\t\tstableOnExitComplete?.();\n\t\t}\n\t}, [state, presentProp, stableOnExitComplete, toggleHasTransitioned]);\n\n\tconst ref = useCallbackRef((refNode: HTMLElement | null) => {\n\t\tsetNode(refNode);\n\n\t\tif (refNode) {\n\t\t\tstylesRef.current = getComputedStyle(refNode);\n\t\t}\n\t});\n\n\tconst MOUNTED_STATES = [\"mounted\", \"unmountSuspended\"] satisfies Array<typeof state>;\n\tconst isPresent = MOUNTED_STATES.includes(state);\n\tconst isPresentOrIsTransitionComplete = isPresent || hasTransitioned;\n\tconst shouldStartTransition = presentProp && hasTransitioned;\n\n\tconst getPresenceProps: UsePresenceResult[\"propGetters\"][\"getPresenceProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst transitionState = shouldStartTransition ? \"active\" : \"inactive\";\n\n\t\t\treturn {\n\t\t\t\t\"data-present\": dataAttr(isPresent),\n\t\t\t\t\"data-present-or-transition-complete\": dataAttr(isPresentOrIsTransitionComplete),\n\t\t\t\t\"data-state\": state,\n\t\t\t\t...(variant === \"transition\" && { \"data-transition\": transitionState }),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: innerProps.className,\n\t\t\t};\n\t\t},\n\t\t[isPresent, isPresentOrIsTransitionComplete, shouldStartTransition, state, variant]\n\t);\n\n\tconst propGetters = useMemo(() => ({ getPresenceProps }), [getPresenceProps]);\n\n\tconst result = useMemo<UsePresenceResult>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tisPresent,\n\t\t\t\tisPresentOrIsTransitionComplete,\n\t\t\t\tpropGetters,\n\t\t\t\tref,\n\t\t\t\tshouldStartTransition,\n\t\t\t}) satisfies UsePresenceResult,\n\t\t[isPresent, isPresentOrIsTransitionComplete, propGetters, ref, shouldStartTransition]\n\t);\n\n\treturn result;\n};\n\nexport { usePresence };\n","\"use client\";\n\nimport { useComposeRefs } from \"@zayne-labs/toolkit-react\";\nimport { isFunction, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Slot } from \"../slot\";\nimport { usePresence, type UsePresenceOptions, type UsePresenceResult } from \"./use-presence\";\n\ntype RefProp = { ref?: React.Ref<HTMLElement> };\n\ntype RenderPropContext = Omit<UsePresenceResult, \"propGetters\" | \"ref\">;\n\ntype PresenceProps = UsePresenceOptions & {\n\tchildren?: React.ReactElement<RefProp> | ((props: RenderPropContext) => React.ReactElement<RefProp>);\n\tclassName?: string;\n\tforceMount?: boolean;\n};\n\nfunction Presence(props: PresenceProps) {\n\tconst { children, className, forceMount = false, onExitComplete, present, variant } = props;\n\n\tconst {\n\t\tisPresent,\n\t\tisPresentOrIsTransitionComplete,\n\t\tpropGetters,\n\t\tref: presenceRef,\n\t\tshouldStartTransition,\n\t} = usePresence({ onExitComplete, present, variant });\n\n\tconst context = {\n\t\tisPresent,\n\t\tisPresentOrIsTransitionComplete,\n\t\tshouldStartTransition,\n\t} satisfies RenderPropContext;\n\n\tconst resolvedChild = isFunction(children) ? children(context) : children;\n\n\tconst childRef = (resolvedChild?.props.ref\n\t\t?? (resolvedChild as unknown as UnknownObject).ref) as React.Ref<HTMLElement>;\n\n\tconst ref = useComposeRefs(presenceRef, childRef);\n\n\tconst shouldRender =\n\t\tforceMount || (variant === \"transition\" ? isPresentOrIsTransitionComplete : isPresent);\n\n\tif (!shouldRender) {\n\t\treturn null;\n\t}\n\n\treturn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AAM,EACL,WACA,iCACA,aACA,KAAK,aACL,0BACG,YAAY;EAAE;EAAgB;EAAS;EAAS,CAAC;CAErD,MAAM,UAAU;EACf;EACA;EACA;EACA;CAED,MAAM,gBAAgB,WAAW,SAAS,GAAG,SAAS,QAAQ,GAAG;CAKjE,MAAM,MAAM,eAAe,aAHT,eAAe,MAAM,OAClC,cAA2C,IAEC;AAKjD,KAAI,EAFH,eAAe,YAAY,eAAe,kCAAkC,YAG5E,QAAO;AAGR,QACC,oBAACA;EAAe;EAAK,GAAI,YAAY,iBAAiB,EAAE,WAAW,CAAC;YAClE;GACU"}
|
|
1
|
+
{"version":3,"file":"presence-DpApdmSc.js","names":["Slot.Root"],"sources":["../../src/components/common/presence/use-presence.ts","../../src/components/common/presence/presence.tsx"],"sourcesContent":["import { dataAttr, on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef, useToggle } from \"@zayne-labs/toolkit-react\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from \"react\";\n\ntype StateMachineConfig<TState extends string, TEvent extends string> = {\n\tinitial: TState;\n\tstates: Record<TState, Partial<Record<TEvent, TState>>>;\n};\n\nconst useStateMachine = <TState extends string, TEvent extends string>(\n\tconfig: StateMachineConfig<TState, TEvent>\n) => {\n\tconst reducer = (prevState: TState, event: TEvent): TState => {\n\t\tconst newState = config.states[prevState][event] ?? prevState;\n\n\t\treturn newState;\n\t};\n\n\treturn useReducer(reducer, config.initial);\n};\n\nconst getAnimationName = (styles: CSSStyleDeclaration | null) => styles?.animationName ?? \"none\";\n\nexport type UsePresenceOptions = {\n\tonExitComplete?: () => void;\n\tpresent: boolean;\n\t/**\n\t * @default \"animation\"\n\t */\n\tvariant?: \"animation\" | \"transition\";\n};\n\nexport type UsePresenceResult = {\n\tisPresent: boolean;\n\tisPresentOrIsTransitionComplete: boolean;\n\tpropGetters: {\n\t\tgetPresenceProps: (innerProps: InferProps<HTMLElement>) => InferProps<HTMLElement>;\n\t};\n\tref: React.Ref<HTMLElement>;\n\tshouldStartTransition: boolean;\n};\n\n/**\n * React hook that provides the ability to animate the mount/unmount of a component.\n * @see https://github.com/radix-ui/primitives/blob/main/packages/react/presence/src/presence.tsx\n */\n\nconst usePresence = (options: UsePresenceOptions): UsePresenceResult => {\n\tconst { onExitComplete, present: presentProp, variant = \"animation\" } = options;\n\n\tconst stableOnExitComplete = useCallbackRef(onExitComplete);\n\n\tconst [node, setNode] = useState<HTMLElement | null>(null);\n\n\tconst [hasTransitioned, toggleHasTransitioned] = useToggle(false);\n\n\tconst stylesRef = useRef<CSSStyleDeclaration | null>(null);\n\n\tconst prevNodeStateRef = useRef<{\n\t\tprevAnimationName: string;\n\t\tprevPresent: boolean;\n\t}>({\n\t\tprevAnimationName: \"none\",\n\t\tprevPresent: presentProp,\n\t});\n\n\tconst initialState = presentProp ? \"mounted\" : \"unmounted\";\n\n\tconst [state, send] = useStateMachine({\n\t\tinitial: initialState,\n\t\tstates: {\n\t\t\tmounted: {\n\t\t\t\tANIMATION_OUT: \"unmountSuspended\",\n\t\t\t\tUNMOUNT: \"unmounted\",\n\t\t\t},\n\t\t\tunmounted: {\n\t\t\t\tMOUNT: \"mounted\",\n\t\t\t},\n\t\t\tunmountSuspended: {\n\t\t\t\tANIMATION_END: \"unmounted\",\n\t\t\t\tMOUNT: \"mounted\",\n\t\t\t},\n\t\t},\n\t});\n\n\tuseEffect(() => {\n\t\tconst currentAnimationName = getAnimationName(stylesRef.current);\n\n\t\tprevNodeStateRef.current.prevAnimationName = state === \"mounted\" ? currentAnimationName : \"none\";\n\t}, [state]);\n\n\tuseLayoutEffect(() => {\n\t\tconst styles = stylesRef.current;\n\t\tconst wasPresent = prevNodeStateRef.current.prevPresent;\n\t\tconst hasPresentChanged = wasPresent !== presentProp;\n\n\t\tif (!hasPresentChanged) return;\n\n\t\tconst prevAnimationName = prevNodeStateRef.current.prevAnimationName;\n\t\tconst currentAnimationName = getAnimationName(styles);\n\n\t\tswitch (true) {\n\t\t\tcase presentProp: {\n\t\t\t\tsend(\"MOUNT\");\n\n\t\t\t\tif (variant === \"transition\") {\n\t\t\t\t\trequestAnimationFrame(() => toggleHasTransitioned(true));\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line react-hooks/todo -- Ignore\n\t\t\tcase Boolean(node) && variant === \"animation\": {\n\t\t\t\tconst hasAnimation = currentAnimationName !== \"none\" && styles?.display !== \"none\";\n\n\t\t\t\t/**\n\t\t\t\t * When `present` changes to `false`, we check changes to animation-name to\n\t\t\t\t * determine whether an animation has started. We chose this approach (reading\n\t\t\t\t * computed styles) because there is no `animationrun` event (like the `transitionrun` event) and `animationstart`\n\t\t\t\t * fires after `animation-delay` has expired which would be too late.\n\t\t\t\t */\n\n\t\t\t\tconst isAnimationStarted = hasAnimation && prevAnimationName !== currentAnimationName;\n\n\t\t\t\tconst isAnimatingOut = wasPresent && isAnimationStarted;\n\n\t\t\t\tsend(isAnimatingOut ? \"ANIMATION_OUT\" : \"UNMOUNT\");\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tsend(\"UNMOUNT\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tprevNodeStateRef.current.prevPresent = presentProp;\n\t}, [presentProp, node, send, variant, toggleHasTransitioned]);\n\n\tuseLayoutEffect(() => {\n\t\tif (!node) {\n\t\t\t// Transition to the unmounted state if the node is removed prematurely.\n\t\t\t// We avoid doing so during cleanup as the node may change but still exist.\n\t\t\tsend(\"ANIMATION_END\");\n\t\t\treturn;\n\t\t}\n\n\t\tlet timeoutId: number;\n\n\t\tconst ownerWindow = node.ownerDocument.defaultView ?? globalThis;\n\n\t\tconst handleAnimationStart = (event: AnimationEvent) => {\n\t\t\tconst isTargetAnimatingNode = event.target === node;\n\n\t\t\tif (!isTargetAnimatingNode) return;\n\n\t\t\tprevNodeStateRef.current.prevAnimationName = getAnimationName(stylesRef.current);\n\t\t};\n\n\t\t/**\n\t\t * @description Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`\n\t\t * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we\n\t\t * make sure we only trigger ANIMATION_END for the currently active animation.\n\t\t */\n\t\tconst handleAnimationEnd = (event: AnimationEvent) => {\n\t\t\tconst currentAnimationName = getAnimationName(stylesRef.current);\n\n\t\t\t// The event.animationName is unescaped for CSS syntax, so we need to escape it to compare with the animationName computed from the style.\n\t\t\tconst isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));\n\n\t\t\tconst isTargetAnimatingNode = event.target === node && isCurrentAnimation;\n\n\t\t\tif (!isTargetAnimatingNode) return;\n\n\t\t\t// With React 18 concurrency this update is applied a frame after the\n\t\t\t// animation ends, creating a flash of visible content. By setting the\n\t\t\t// animation fill mode to \"forwards\", we force the node to keep the\n\t\t\t// styles of the last keyframe, removing the flash.\n\n\t\t\t// Previously we flushed the update via ReactDom.flushSync, but with\n\t\t\t// exit animations this resulted in the node being removed from the\n\t\t\t// DOM before the synthetic animationEnd event was dispatched, meaning\n\t\t\t// user-provided event handlers would not be called.\n\t\t\t// https://github.com/radix-ui/primitives/pull/1849\n\t\t\tsend(\"ANIMATION_END\");\n\n\t\t\tif (!prevNodeStateRef.current.prevPresent) {\n\t\t\t\tconst currentFillMode = node.style.animationFillMode;\n\t\t\t\tnode.style.animationFillMode = \"forwards\";\n\n\t\t\t\t// Reset the style after the node had time to unmount (for cases\n\t\t\t\t// where the component chooses not to unmount). Doing this any\n\t\t\t\t// sooner than `setTimeout` (e.g. with `requestAnimationFrame`)\n\t\t\t\t// still causes a flash.\n\t\t\t\ttimeoutId = ownerWindow.setTimeout(() => {\n\t\t\t\t\tif (node.style.animationFillMode === \"forwards\") {\n\t\t\t\t\t\tnode.style.animationFillMode = currentFillMode;\n\t\t\t\t\t}\n\t\t\t\t}) as never;\n\t\t\t}\n\t\t};\n\n\t\tconst handleTransitionRun = (event: TransitionEvent) => {\n\t\t\tconst isTargetTransitioningNode = event.target === node;\n\n\t\t\tif (!isTargetTransitioningNode) return;\n\n\t\t\tsend(\"ANIMATION_OUT\");\n\t\t};\n\n\t\tconst handleTransitionEnd = (event: TransitionEvent) => {\n\t\t\tconst isTargetTransitioningNode = event.target === node && !prevNodeStateRef.current.prevPresent;\n\n\t\t\tif (!isTargetTransitioningNode) return;\n\n\t\t\tsend(\"ANIMATION_END\");\n\t\t};\n\n\t\tconst onAnimationStartCleanup = on(\"animationstart\", node, handleAnimationStart);\n\t\tconst onAnimationEndCleanup = on(\"animationend\", node, handleAnimationEnd);\n\t\tconst onAnimationCancelCleanup = on(\"animationcancel\", node, handleAnimationEnd);\n\n\t\tconst onTransitionRunCleanup = on(\"transitionrun\", node, handleTransitionRun);\n\t\tconst onTransitionEndCleanup = on(\"transitionend\", node, handleTransitionEnd);\n\t\tconst onTransitionCancelCleanup = on(\"transitioncancel\", node, handleTransitionEnd);\n\n\t\treturn () => {\n\t\t\townerWindow.clearTimeout(timeoutId);\n\t\t\tonAnimationStartCleanup();\n\t\t\tonAnimationEndCleanup();\n\t\t\tonAnimationCancelCleanup();\n\n\t\t\tonTransitionRunCleanup();\n\t\t\tonTransitionEndCleanup();\n\t\t\tonTransitionCancelCleanup();\n\t\t};\n\t}, [node, send]);\n\n\tuseEffect(() => {\n\t\tconst isExitCompleted = state === \"unmounted\" && !presentProp;\n\n\t\tif (isExitCompleted) {\n\t\t\ttoggleHasTransitioned(false);\n\t\t\tstableOnExitComplete?.();\n\t\t}\n\t}, [state, presentProp, stableOnExitComplete, toggleHasTransitioned]);\n\n\tconst ref = useCallbackRef((refNode: HTMLElement | null) => {\n\t\tsetNode(refNode);\n\n\t\tif (refNode) {\n\t\t\tstylesRef.current = getComputedStyle(refNode);\n\t\t}\n\t});\n\n\tconst MOUNTED_STATES = [\"mounted\", \"unmountSuspended\"] satisfies Array<typeof state>;\n\tconst isPresent = MOUNTED_STATES.includes(state);\n\tconst isPresentOrIsTransitionComplete = isPresent || hasTransitioned;\n\tconst shouldStartTransition = presentProp && hasTransitioned;\n\n\tconst getPresenceProps: UsePresenceResult[\"propGetters\"][\"getPresenceProps\"] = useCallback(\n\t\t(innerProps) => {\n\t\t\tconst transitionState = shouldStartTransition ? \"active\" : \"inactive\";\n\n\t\t\treturn {\n\t\t\t\t\"data-present\": dataAttr(isPresent),\n\t\t\t\t\"data-present-or-transition-complete\": dataAttr(isPresentOrIsTransitionComplete),\n\t\t\t\t\"data-state\": state,\n\t\t\t\t...(variant === \"transition\" && { \"data-transition\": transitionState }),\n\t\t\t\t...innerProps,\n\t\t\t\tclassName: innerProps.className,\n\t\t\t};\n\t\t},\n\t\t[isPresent, isPresentOrIsTransitionComplete, shouldStartTransition, state, variant]\n\t);\n\n\tconst propGetters = useMemo(() => ({ getPresenceProps }), [getPresenceProps]);\n\n\tconst result = useMemo<UsePresenceResult>(\n\t\t() =>\n\t\t\t({\n\t\t\t\tisPresent,\n\t\t\t\tisPresentOrIsTransitionComplete,\n\t\t\t\tpropGetters,\n\t\t\t\tref,\n\t\t\t\tshouldStartTransition,\n\t\t\t}) satisfies UsePresenceResult,\n\t\t[isPresent, isPresentOrIsTransitionComplete, propGetters, ref, shouldStartTransition]\n\t);\n\n\treturn result;\n};\n\nexport { usePresence };\n","\"use client\";\n\nimport { useComposeRefs } from \"@zayne-labs/toolkit-react\";\nimport { isFunction, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Slot } from \"../slot\";\nimport { usePresence, type UsePresenceOptions, type UsePresenceResult } from \"./use-presence\";\n\ntype RefProp = { ref?: React.Ref<HTMLElement> };\n\ntype RenderPropContext = Omit<UsePresenceResult, \"propGetters\" | \"ref\">;\n\ntype PresenceProps = UsePresenceOptions & {\n\tchildren?: React.ReactElement<RefProp> | ((props: RenderPropContext) => React.ReactElement<RefProp>);\n\tclassName?: string;\n\tforceMount?: boolean;\n};\n\nfunction Presence(props: PresenceProps) {\n\tconst { children, className, forceMount = false, onExitComplete, present, variant } = props;\n\n\tconst {\n\t\tisPresent,\n\t\tisPresentOrIsTransitionComplete,\n\t\tpropGetters,\n\t\tref: presenceRef,\n\t\tshouldStartTransition,\n\t} = usePresence({ onExitComplete, present, variant });\n\n\tconst context = {\n\t\tisPresent,\n\t\tisPresentOrIsTransitionComplete,\n\t\tshouldStartTransition,\n\t} satisfies RenderPropContext;\n\n\tconst resolvedChild = isFunction(children) ? children(context) : children;\n\n\tconst childRef = (resolvedChild?.props.ref\n\t\t?? (resolvedChild as unknown as UnknownObject).ref) as React.Ref<HTMLElement>;\n\n\tconst ref = useComposeRefs(presenceRef, childRef);\n\n\tconst shouldRender =\n\t\tforceMount || (variant === \"transition\" ? isPresentOrIsTransitionComplete : isPresent);\n\n\tif (!shouldRender) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Slot.Root ref={ref} {...propGetters.getPresenceProps({ className })}>\n\t\t\t{resolvedChild}\n\t\t</Slot.Root>\n\t);\n}\n\nexport { Presence };\n"],"mappings":";;;;;;;;AAUA,MAAM,mBACL,WACI;CACJ,MAAM,WAAW,WAAmB,UAA0B;AAG7D,SAFiB,OAAO,OAAO,WAAW,UAAU;;AAKrD,QAAO,WAAW,SAAS,OAAO,QAAQ;;AAG3C,MAAM,oBAAoB,WAAuC,QAAQ,iBAAiB;;;;;AA0B1F,MAAM,eAAe,YAAmD;CACvE,MAAM,EAAE,gBAAgB,SAAS,aAAa,UAAU,gBAAgB;CAExE,MAAM,uBAAuB,eAAe,eAAe;CAE3D,MAAM,CAAC,MAAM,WAAW,SAA6B,KAAK;CAE1D,MAAM,CAAC,iBAAiB,yBAAyB,UAAU,MAAM;CAEjE,MAAM,YAAY,OAAmC,KAAK;CAE1D,MAAM,mBAAmB,OAGtB;EACF,mBAAmB;EACnB,aAAa;EACb,CAAC;CAIF,MAAM,CAAC,OAAO,QAAQ,gBAAgB;EACrC,SAHoB,cAAc,YAAY;EAI9C,QAAQ;GACP,SAAS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yE,aAC7E,eAAe;EACf,MAAM,kBAAkB,wBAAwB,WAAW;AAE3D,SAAO;GACN,gBAAgB,SAAS,UAAU;GACnC,uCAAuC,SAAS,gCAAgC;GAChF,cAAc;GACd,GAAI,YAAY,gBAAgB,EAAE,mBAAmB,iBAAiB;GACtE,GAAG;GACH,WAAW,WAAW;GACtB;IAEF;EAAC;EAAW;EAAiC;EAAuB;EAAO;EAAQ,CACnF;CAED,MAAM,cAAc,eAAe,EAAE,kBAAkB,GAAG,CAAC,iBAAiB,CAAC;AAc7E,QAZe,eAEZ;EACA;EACA;EACA;EACA;EACA;EACA,GACF;EAAC;EAAW;EAAiC;EAAa;EAAK;EAAsB,CACrF;;;;;AChRF,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,UAAU,WAAW,aAAa,OAAO,gBAAgB,SAAS,YAAY;CAEtF,MAAM,EACL,WACA,iCACA,aACA,KAAK,aACL,0BACG,YAAY;EAAE;EAAgB;EAAS;EAAS,CAAC;CAErD,MAAM,UAAU;EACf;EACA;EACA;EACA;CAED,MAAM,gBAAgB,WAAW,SAAS,GAAG,SAAS,QAAQ,GAAG;CAKjE,MAAM,MAAM,eAAe,aAHT,eAAe,MAAM,OAClC,cAA2C,IAEC;AAKjD,KAAI,EAFH,eAAe,YAAY,eAAe,kCAAkC,YAG5E,QAAO;AAGR,QACC,oBAACA;EAAe;EAAK,GAAI,YAAY,iBAAiB,EAAE,WAAW,CAAC;YAClE;GACU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show-
|
|
1
|
+
{"version":3,"file":"show-CtivYwYS.js","names":[],"sources":["../../src/components/common/show/show.tsx","../../src/components/common/show/show-parts.ts"],"sourcesContent":["\"use client\";\n\nimport { toArray } from \"@zayne-labs/toolkit-core\";\nimport { getMultipleSlots, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { assert, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ShowProps<TWhen> =\n\t| {\n\t\t\tchildren: React.ReactNode;\n\t\t\tcontrol: \"content\";\n\t\t\tfallback?: React.ReactNode;\n\t\t\twhen?: never;\n\t }\n\t| {\n\t\t\tchildren: React.ReactNode | ((value: TWhen) => React.ReactNode);\n\t\t\tcontrol?: \"root\";\n\t\t\tfallback?: React.ReactNode;\n\t\t\twhen: false | TWhen | null | undefined;\n\t };\n\nexport function ShowRoot<TWhen>(props: ShowProps<TWhen>) {\n\tconst { children, control = \"root\", fallback = null, when } = props;\n\n\tif (control === \"content\" && !isFunction(children)) {\n\t\tconst childrenArray = toArray(children) as Array<React.ReactElement<ShowContentProps<TWhen>>>;\n\n\t\tconst foundContentSlot = childrenArray.find((child) => Boolean(child.props.when));\n\n\t\tconst fallBackSlot = getSingleSlot(childrenArray, ShowFallback);\n\n\t\tassert(\n\t\t\t!(fallBackSlot && fallback),\n\t\t\t\"The fallback prop and <Show.Fallback> cannot be used at the same time.\"\n\t\t);\n\n\t\treturn foundContentSlot ?? fallBackSlot ?? fallback;\n\t}\n\n\tconst resolvedChildren = isFunction(children) ? children(when as TWhen) : children;\n\n\tconst {\n\t\tregularChildren,\n\t\tslots: [contentSlot, fallBackSlot],\n\t} = getMultipleSlots(resolvedChildren, [ShowContent, ShowFallback], {\n\t\terrorMessage: [\n\t\t\t\"Only one <Show.Content> component is allowed\",\n\t\t\t\"Only one <Show.Fallback> or <Show.OtherWise> component is allowed\",\n\t\t],\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tif (!when) {\n\t\tassert(\n\t\t\t!(fallBackSlot && fallback),\n\t\t\t\"The fallback prop and <Show.Fallback> cannot be used at the same time.\"\n\t\t);\n\n\t\treturn fallBackSlot ?? fallback;\n\t}\n\n\treturn contentSlot ?? regularChildren;\n}\n\ntype ShowContentProps<TWhen> = Pick<ShowProps<TWhen>, \"children\" | \"when\">;\n\nexport function ShowContent<TWhen>(props: ShowContentProps<TWhen>) {\n\tconst { children, when } = props;\n\n\tconst resolvedChildren = isFunction(children) ? children(when as TWhen) : children;\n\n\treturn resolvedChildren;\n}\nShowContent.slotSymbol = Symbol(\"show-content\");\n\nexport function ShowFallback(props: { children: React.ReactNode }) {\n\tconst { children } = props;\n\n\treturn children;\n}\nShowFallback.slotSymbol = Symbol(\"show-fallback\");\n","export {\n\tShowContent as Content,\n\tShowFallback as Fallback,\n\tShowFallback as Otherwise,\n\tShowRoot as Root,\n} from \"./show\";\n"],"mappings":";;;;;;AAoBA,SAAgB,SAAgB,OAAyB;CACxD,MAAM,EAAE,UAAU,UAAU,QAAQ,WAAW,MAAM,SAAS;AAE9D,KAAI,YAAY,aAAa,CAAC,WAAW,SAAS,EAAE;EACnD,MAAM,gBAAgB,QAAQ,SAAS;EAEvC,MAAM,mBAAmB,cAAc,MAAM,UAAU,QAAQ,MAAM,MAAM,KAAK,CAAC;EAEjF,MAAM,eAAe,cAAc,eAAe,aAAa;AAE/D,SACC,EAAE,gBAAgB,WAClB,yEACA;AAED,SAAO,oBAAoB,gBAAgB;;CAK5C,MAAM,EACL,iBACA,OAAO,CAAC,aAAa,kBAClB,iBALqB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG,UAKnC,CAAC,aAAa,aAAa,EAAE;EACnE,cAAc,CACb,gDACA,oEACA;EACD,0BAA0B;EAC1B,CAAC;AAEF,KAAI,CAAC,MAAM;AACV,SACC,EAAE,gBAAgB,WAClB,yEACA;AAED,SAAO,gBAAgB;;AAGxB,QAAO,eAAe;;AAKvB,SAAgB,YAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,SAAS;AAI3B,QAFyB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;;AAI3E,YAAY,aAAa,OAAO,eAAe;AAE/C,SAAgB,aAAa,OAAsC;CAClE,MAAM,EAAE,aAAa;AAErB,QAAO;;AAER,aAAa,aAAa,OAAO,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-
|
|
1
|
+
{"version":3,"file":"slot-C7TE8pEK.js","names":["ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"sourcesContent":["import { composeRefs, mergeProps, type InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement, Fragment as ReactFragment } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement> & { ref?: React.Ref<HTMLElement> };\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotRoot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (!slottable) {\n\t\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n\t}\n\n\tif (!isValidElement<SlotProps>(slottable)) {\n\t\treturn null;\n\t}\n\n\t// == The new element to render is the one passed as a child of `Slot.Slottable`\n\tconst newElement = slottable.props.children;\n\n\tif (Children.count(newElement) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedNewElement = isArray(newElement) ? newElement[0] : newElement;\n\n\tif (!isValidElement(resolvedNewElement)) {\n\t\treturn null;\n\t}\n\n\tconst newChildren = childrenArray.map((child) => {\n\t\tif (child === slottable) {\n\t\t\t// == Because the new element will be the one rendered, we are only interested in grabbing its children (`newElement.props.children`)\n\t\t\treturn (resolvedNewElement.props as SlotProps).children;\n\t\t}\n\n\t\treturn child;\n\t});\n\n\treturn (\n\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t{cloneElement(resolvedNewElement, undefined, newChildren)}\n\t\t</SlotClone>\n\t);\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotSlottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === SlotSlottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * ----------------------------------------------------------------------------------------------- */\ntype SlotCloneProps = Pick<SlotProps, \"children\" | \"ref\">;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (Children.count(children) > 1) {\n\t\treturn Children.only(null);\n\t}\n\n\tconst resolvedChild = isArray(children) ? children[0] : children;\n\n\tif (!isValidElement<UnknownObject>(resolvedChild)) {\n\t\treturn null;\n\t}\n\n\tconst childRef = (resolvedChild.props.ref\n\t\t?? (resolvedChild as unknown as UnknownObject).ref) as React.Ref<HTMLElement>;\n\n\tconst ref = composeRefs(forwardedRef, childRef);\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, resolvedChild.props),\n\t\t...(resolvedChild.type !== ReactFragment && { ref }),\n\t};\n\n\treturn cloneElement(resolvedChild, clonedProps);\n}\n","export { SlotRoot as Root, SlotSlottable as Slottable } from \"./slot\";\n"],"mappings":";;;;;;;AAUA,SAAgB,SAAS,OAAkB;CAC1C,MAAM,EAAE,UAAU,GAAG,oBAAoB;CAEzC,MAAM,gBAAgB,QAAyB,SAAS,GAAG,WAAW,CAAC,SAAS;CAEhF,MAAM,YAAY,cAAc,MAAM,YAAY,YAAY,QAAQ,CAAC;AAEvE,KAAI,CAAC,UACJ,QAAO,oBAAC;EAAU,GAAI;EAAkB;GAAqB;AAG9D,KAAI,CAAC,eAA0B,UAAU,CACxC,QAAO;CAIR,MAAM,aAAa,UAAU,MAAM;AAEnC,KAAI,SAAS,MAAM,WAAW,GAAG,EAChC,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,qBAAqB,QAAQ,WAAW,GAAG,WAAW,KAAK;AAEjE,KAAI,CAAC,eAAe,mBAAmB,CACtC,QAAO;CAGR,MAAM,cAAc,cAAc,KAAK,UAAU;AAChD,MAAI,UAAU,UAEb,QAAQ,mBAAmB,MAAoB;AAGhD,SAAO;GACN;AAEF,QACC,oBAAC;EAAU,GAAI;YACb,aAAa,oBAAoB,QAAW,YAAY;GAC9C;;AAQd,SAAgB,cAAc,EAAE,YAAyC;AACxE,QAAO;;AAGR,MAAM,eAAe,UAAwD;AAC5E,QAAO,eAAe,MAAM,IAAI,MAAM,SAAS;;AAQhD,SAAS,UAAU,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,cAAc,GAAG,oBAAoB;AAE5D,KAAI,SAAS,MAAM,SAAS,GAAG,EAC9B,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,gBAAgB,QAAQ,SAAS,GAAG,SAAS,KAAK;AAExD,KAAI,CAAC,eAA8B,cAAc,CAChD,QAAO;CAMR,MAAM,MAAM,YAAY,cAHN,cAAc,MAAM,OACjC,cAA2C,IAED;AAO/C,QAAO,aAAa,eALA;EACnB,GAAG,WAAW,iBAAiB,cAAc,MAAM;EACnD,GAAI,cAAc,SAASA,YAAiB,EAAE,KAAK;EACnD,CAE8C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
2
|
-
import { n as SlotRoot } from "../../slot-
|
|
3
|
-
import { t as cnMerge } from "../../cn-
|
|
2
|
+
import { n as SlotRoot } from "../../slot-C7TE8pEK.js";
|
|
3
|
+
import { t as cnMerge } from "../../cn-2hIN1AQ7.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/ui/card/card.tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PolymorphicPropsStrict } from "@zayne-labs/toolkit-react/utils";
|
|
2
2
|
import { UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
4
4
|
import { StoreApi } from "@zayne-labs/toolkit-core";
|
|
5
5
|
|
|
6
6
|
//#region src/components/ui/carousel/types.d.ts
|
|
@@ -78,14 +78,14 @@ type OtherCarouselProps = {
|
|
|
78
78
|
};
|
|
79
79
|
//#endregion
|
|
80
80
|
//#region src/components/ui/carousel/carousel.d.ts
|
|
81
|
-
declare function CarouselRoot<TImages extends ImagesType, TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, CarouselRootProps<TImages>>):
|
|
82
|
-
declare function CarouselButton(props: CarouselButtonsProps):
|
|
83
|
-
declare function CarouselControls(props: CarouselControlProps):
|
|
84
|
-
declare function CarouselItemList<TArray extends unknown[]>(props: CarouselWrapperProps<TArray[number]>):
|
|
85
|
-
declare function CarouselItem(props: OtherCarouselProps):
|
|
86
|
-
declare function CarouselCaption<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, OtherCarouselProps>):
|
|
87
|
-
declare function CarouselIndicatorList<TArray extends unknown[]>(props: CarouselWrapperProps<TArray[number]>):
|
|
88
|
-
declare function CarouselIndicator(props: CarouselIndicatorProps):
|
|
81
|
+
declare function CarouselRoot<TImages extends ImagesType, TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, CarouselRootProps<TImages>>): react_jsx_runtime8.JSX.Element;
|
|
82
|
+
declare function CarouselButton(props: CarouselButtonsProps): react_jsx_runtime8.JSX.Element;
|
|
83
|
+
declare function CarouselControls(props: CarouselControlProps): react_jsx_runtime8.JSX.Element;
|
|
84
|
+
declare function CarouselItemList<TArray extends unknown[]>(props: CarouselWrapperProps<TArray[number]>): react_jsx_runtime8.JSX.Element;
|
|
85
|
+
declare function CarouselItem(props: OtherCarouselProps): react_jsx_runtime8.JSX.Element;
|
|
86
|
+
declare function CarouselCaption<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, OtherCarouselProps>): react_jsx_runtime8.JSX.Element;
|
|
87
|
+
declare function CarouselIndicatorList<TArray extends unknown[]>(props: CarouselWrapperProps<TArray[number]>): react_jsx_runtime8.JSX.Element;
|
|
88
|
+
declare function CarouselIndicator(props: CarouselIndicatorProps): react_jsx_runtime8.JSX.Element;
|
|
89
89
|
declare namespace carousel_parts_d_exports {
|
|
90
90
|
export { CarouselButton as Button, CarouselCaption as Caption, CarouselControls as Controls, CarouselIndicator as Indicator, CarouselIndicatorList as IndicatorList, CarouselItem as Item, CarouselItemList as ItemList, CarouselRoot as Root };
|
|
91
91
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
4
|
-
import {
|
|
5
|
-
import { n as For } from "../../for-
|
|
6
|
-
import {
|
|
4
|
+
import { i as ShowRoot, n as ShowContent, r as ShowFallback } from "../../show-CtivYwYS.js";
|
|
5
|
+
import { n as For } from "../../for-DAM4xYij.js";
|
|
6
|
+
import { t as cnMerge } from "../../cn-2hIN1AQ7.js";
|
|
7
7
|
import { isFunction } from "@zayne-labs/toolkit-type-helpers";
|
|
8
8
|
import { useMemo, useState } from "react";
|
|
9
|
+
import { useAnimationInterval, useCallbackRef, useStore } from "@zayne-labs/toolkit-react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { createStore } from "@zayne-labs/toolkit-core";
|
|
11
|
-
import { useAnimationInterval, useCallbackRef, useStore } from "@zayne-labs/toolkit-react";
|
|
12
12
|
import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
|
|
13
13
|
|
|
14
14
|
//#region src/components/ui/carousel/carousel-store-context.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InferProps } from "@zayne-labs/toolkit-react/utils";
|
|
2
2
|
import * as _zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import * as react40 from "react";
|
|
4
|
-
import * as _zayne_labs_toolkit_core3 from "@zayne-labs/toolkit-core";
|
|
5
4
|
import "@zayne-labs/toolkit-react";
|
|
5
|
+
import * as _zayne_labs_toolkit_core2 from "@zayne-labs/toolkit-core";
|
|
6
6
|
|
|
7
7
|
//#region src/components/ui/drag-scroll/drag-scroll-context.d.ts
|
|
8
8
|
declare const DragScrollStoreContextProvider: (props: {
|
|
@@ -28,7 +28,7 @@ declare const DragScrollStoreContextProvider: (props: {
|
|
|
28
28
|
shouldReplace: true;
|
|
29
29
|
}) | undefined): void;
|
|
30
30
|
};
|
|
31
|
-
subscribe:
|
|
31
|
+
subscribe: _zayne_labs_toolkit_core2.SubscribeFn<DragScrollStore<HTMLElement>>;
|
|
32
32
|
};
|
|
33
33
|
}) => react40.FunctionComponentElement<react40.ProviderProps<{
|
|
34
34
|
getInitialState: () => DragScrollStore<HTMLElement>;
|
|
@@ -51,7 +51,7 @@ declare const DragScrollStoreContextProvider: (props: {
|
|
|
51
51
|
shouldReplace: true;
|
|
52
52
|
}) | undefined): void;
|
|
53
53
|
};
|
|
54
|
-
subscribe:
|
|
54
|
+
subscribe: _zayne_labs_toolkit_core2.SubscribeFn<DragScrollStore<HTMLElement>>;
|
|
55
55
|
}>>, useDragScrollStoreContext: <TResult = DragScrollStore<HTMLElement>>(selector?: _zayne_labs_toolkit_type_helpers0.SelectorFn<DragScrollStore<HTMLElement>, TResult> | undefined) => TResult;
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/components/ui/drag-scroll/drag-scroll-store.d.ts
|
|
@@ -78,7 +78,7 @@ declare const createDragScrollStore: <TElement extends HTMLElement = HTMLElement
|
|
|
78
78
|
shouldReplace: true;
|
|
79
79
|
}) | undefined): void;
|
|
80
80
|
};
|
|
81
|
-
subscribe:
|
|
81
|
+
subscribe: _zayne_labs_toolkit_core2.SubscribeFn<DragScrollStore<TElement>>;
|
|
82
82
|
};
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/components/ui/drag-scroll/types.d.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as cnMerge } from "../../cn-
|
|
1
|
+
import { t as cnMerge } from "../../cn-2hIN1AQ7.js";
|
|
2
2
|
import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
|
|
3
3
|
import { isNumber } from "@zayne-labs/toolkit-type-helpers";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
5
|
-
import { checkIsDeviceMobile, createStore, dataAttr, on, throttleByFrame } from "@zayne-labs/toolkit-core";
|
|
6
5
|
import { useCallbackRef, useStore } from "@zayne-labs/toolkit-react";
|
|
6
|
+
import { checkIsDeviceMobile, createStore, dataAttr, on, throttleByFrame } from "@zayne-labs/toolkit-core";
|
|
7
7
|
|
|
8
8
|
//#region src/components/ui/drag-scroll/utils.ts
|
|
9
9
|
const updateCursor = (element) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { InferProps, PolymorphicPropsStrict } from "@zayne-labs/toolkit-react/utils";
|
|
2
2
|
import * as _zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
|
|
3
3
|
import { Awaitable, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
4
|
+
import * as react36 from "react";
|
|
5
|
+
import "@zayne-labs/toolkit-react";
|
|
6
|
+
import * as react_jsx_runtime38 from "react/jsx-runtime";
|
|
6
7
|
import * as _zayne_labs_toolkit_core1 from "@zayne-labs/toolkit-core";
|
|
7
8
|
import { FileMeta, FileOrFileMeta, FileValidationErrorContextEach, FileValidationHooksAsync, FileValidationSettingsAsync } from "@zayne-labs/toolkit-core";
|
|
8
|
-
import "@zayne-labs/toolkit-react";
|
|
9
9
|
|
|
10
10
|
//#region src/components/ui/drop-zone/drop-zone-store.d.ts
|
|
11
11
|
type RequiredUseDropZoneProps = { [Key in keyof Required<UseDropZoneProps>]: UseDropZoneProps[Key] | undefined };
|
|
@@ -272,7 +272,7 @@ declare const DropZoneStoreContextProvider: (props: {
|
|
|
272
272
|
};
|
|
273
273
|
subscribe: _zayne_labs_toolkit_core1.SubscribeFn<DropZoneStore>;
|
|
274
274
|
};
|
|
275
|
-
}) =>
|
|
275
|
+
}) => react36.FunctionComponentElement<react36.ProviderProps<{
|
|
276
276
|
getInitialState: () => DropZoneStore;
|
|
277
277
|
getListeners: () => Set<(state: DropZoneStore, prevState: DropZoneStore) => void>;
|
|
278
278
|
getState: () => DropZoneStore;
|
|
@@ -303,29 +303,29 @@ type FileItemContextType = {
|
|
|
303
303
|
type DropZoneRootProps = UseDropZoneProps & {
|
|
304
304
|
children: React.ReactNode;
|
|
305
305
|
};
|
|
306
|
-
declare function DropZoneRoot(props: DropZoneRootProps):
|
|
306
|
+
declare function DropZoneRoot(props: DropZoneRootProps): react_jsx_runtime38.JSX.Element;
|
|
307
307
|
type DropZoneContextProps<TSlice> = {
|
|
308
308
|
children: React.ReactNode | ((context: TSlice) => React.ReactNode);
|
|
309
309
|
selector?: SelectorFn<DropZoneStore, TSlice>;
|
|
310
310
|
};
|
|
311
|
-
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>):
|
|
311
|
+
declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>): react36.ReactNode;
|
|
312
312
|
type DropZoneContainerProps = PartInputProps["container"] & {
|
|
313
313
|
asChild?: boolean;
|
|
314
314
|
};
|
|
315
|
-
declare function DropZoneContainer<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, DropZoneContainerProps>):
|
|
315
|
+
declare function DropZoneContainer<TElement extends React.ElementType = "div">(props: PolymorphicPropsStrict<TElement, DropZoneContainerProps>): react_jsx_runtime38.JSX.Element;
|
|
316
316
|
type DropZoneInputProps = PartInputProps["input"] & {
|
|
317
317
|
asChild?: boolean;
|
|
318
318
|
};
|
|
319
|
-
declare function DropZoneInput(props: DropZoneInputProps):
|
|
319
|
+
declare function DropZoneInput(props: DropZoneInputProps): react_jsx_runtime38.JSX.Element;
|
|
320
320
|
type DropZoneAreaProps<TSlice> = DropZoneContextProps<TSlice> & PartInputProps["container"] & {
|
|
321
321
|
classNames?: Partial<Record<Extract<keyof PartInputProps, "container" | "input">, string>>;
|
|
322
322
|
extraProps?: Partial<Pick<PartInputProps, "container" | "input">>;
|
|
323
323
|
};
|
|
324
|
-
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>):
|
|
324
|
+
declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>): react_jsx_runtime38.JSX.Element;
|
|
325
325
|
type DropZoneTriggerProps = PartInputProps["trigger"] & {
|
|
326
326
|
asChild?: boolean;
|
|
327
327
|
};
|
|
328
|
-
declare function DropZoneTrigger(props: DropZoneTriggerProps):
|
|
328
|
+
declare function DropZoneTrigger(props: DropZoneTriggerProps): react_jsx_runtime38.JSX.Element;
|
|
329
329
|
type ListPerItemContext = Pick<DropZoneStore, "actions"> & {
|
|
330
330
|
array: DropZoneStore["fileStateArray"];
|
|
331
331
|
fileState: DropZoneStore["fileStateArray"][number];
|
|
@@ -344,21 +344,21 @@ type DropZoneFileListProps = Omit<PartInputProps["fileList"], "children"> & {
|
|
|
344
344
|
asChild?: boolean;
|
|
345
345
|
forceMount?: boolean;
|
|
346
346
|
} & (FileListManualListVariant | FileListPerItemVariant);
|
|
347
|
-
declare function DropZoneFileList<TElement extends React.ElementType = "ul">(props: PolymorphicPropsStrict<TElement, DropZoneFileListProps>):
|
|
347
|
+
declare function DropZoneFileList<TElement extends React.ElementType = "ul">(props: PolymorphicPropsStrict<TElement, DropZoneFileListProps>): react_jsx_runtime38.JSX.Element;
|
|
348
348
|
type DropZoneFileItemProps = FileItemContextType & PartInputProps["fileItem"] & {
|
|
349
349
|
asChild?: boolean;
|
|
350
350
|
};
|
|
351
|
-
declare function DropZoneFileItem<TElement extends React.ElementType = "li">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProps>):
|
|
351
|
+
declare function DropZoneFileItem<TElement extends React.ElementType = "li">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProps>): react_jsx_runtime38.JSX.Element;
|
|
352
352
|
type DropZoneFileItemDeleteProps = PartInputProps["fileItemDelete"] & {
|
|
353
353
|
asChild?: boolean;
|
|
354
354
|
};
|
|
355
|
-
declare function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps):
|
|
355
|
+
declare function DropZoneFileItemDelete(props: DropZoneFileItemDeleteProps): react_jsx_runtime38.JSX.Element;
|
|
356
356
|
type DropZoneFileItemProgressProps = PartInputProps["fileItemProgress"] & {
|
|
357
357
|
asChild?: boolean;
|
|
358
358
|
forceMount?: boolean;
|
|
359
359
|
size?: number;
|
|
360
360
|
};
|
|
361
|
-
declare function DropZoneFileItemProgress<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>):
|
|
361
|
+
declare function DropZoneFileItemProgress<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, DropZoneFileItemProgressProps>): react_jsx_runtime38.JSX.Element | null;
|
|
362
362
|
type RenderPreviewDetails<TElement extends React.ElementType = "svg"> = {
|
|
363
363
|
node?: React.ReactNode;
|
|
364
364
|
} & {
|
|
@@ -387,7 +387,7 @@ type DropZoneFileItemPreviewProps = Omit<PartInputProps["fileItemPreview"], "chi
|
|
|
387
387
|
}) => React.ReactNode);
|
|
388
388
|
renderPreview?: boolean | RenderPreview;
|
|
389
389
|
};
|
|
390
|
-
declare function DropZoneFileItemPreview<TElement extends React.ElementType>(props: PolymorphicPropsStrict<TElement, DropZoneFileItemPreviewProps>):
|
|
390
|
+
declare function DropZoneFileItemPreview<TElement extends React.ElementType>(props: PolymorphicPropsStrict<TElement, DropZoneFileItemPreviewProps>): react_jsx_runtime38.JSX.Element | null;
|
|
391
391
|
type DropZoneFileItemMetadataProps = Omit<PartInputProps["fileItemMetadata"], "children"> & Partial<Pick<FileItemContextType, "fileState">> & {
|
|
392
392
|
asChild?: boolean;
|
|
393
393
|
children?: React.ReactNode | ((context: Pick<FileItemContextType, "fileState">) => React.ReactNode);
|
|
@@ -397,12 +397,12 @@ type DropZoneFileItemMetadataProps = Omit<PartInputProps["fileItemMetadata"], "c
|
|
|
397
397
|
};
|
|
398
398
|
size?: "default" | "sm";
|
|
399
399
|
};
|
|
400
|
-
declare function DropZoneFileItemMetadata(props: DropZoneFileItemMetadataProps):
|
|
400
|
+
declare function DropZoneFileItemMetadata(props: DropZoneFileItemMetadataProps): react_jsx_runtime38.JSX.Element | null;
|
|
401
401
|
type DropZoneFileClearProps = PartInputProps["fileItemClear"] & {
|
|
402
402
|
asChild?: boolean;
|
|
403
403
|
forceMount?: boolean;
|
|
404
404
|
};
|
|
405
|
-
declare function DropZoneFileClear(props: DropZoneFileClearProps):
|
|
405
|
+
declare function DropZoneFileClear(props: DropZoneFileClearProps): react_jsx_runtime38.JSX.Element | null;
|
|
406
406
|
declare namespace drop_zone_parts_d_exports {
|
|
407
407
|
export { DropZoneArea as Area, DropZoneContainer as Container, DropZoneContext as Context, DropZoneFileClear as FileClear, DropZoneFileItem as FileItem, DropZoneFileItemDelete as FileItemDelete, DropZoneFileItemMetadata as FileItemMetadata, DropZoneFileItemPreview as FileItemPreview, DropZoneFileItemProgress as FileItemProgress, DropZoneFileList as FileList, DropZoneInput as Input, DropZoneRoot as Root, DropZoneTrigger as Trigger };
|
|
408
408
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
4
|
-
import { n as SlotRoot } from "../../slot-
|
|
5
|
-
import { t as
|
|
6
|
-
import { n as For } from "../../for-
|
|
7
|
-
import { t as
|
|
4
|
+
import { n as SlotRoot } from "../../slot-C7TE8pEK.js";
|
|
5
|
+
import { t as Presence } from "../../presence-DpApdmSc.js";
|
|
6
|
+
import { n as For } from "../../for-DAM4xYij.js";
|
|
7
|
+
import { t as cnMerge } from "../../cn-2hIN1AQ7.js";
|
|
8
8
|
import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
|
|
9
9
|
import { isBoolean, isFile, isFunction, isNumber, isObject, isString } from "@zayne-labs/toolkit-type-helpers";
|
|
10
10
|
import { useCallback, useMemo, useRef } from "react";
|
|
11
|
+
import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
|
|
11
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { createFileURL, createStore, dataAttr, formatBytes, generateFileID, handleFileValidationAsync, toArray } from "@zayne-labs/toolkit-core";
|
|
13
|
-
import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
|
|
14
14
|
import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
|
|
15
15
|
|
|
16
16
|
//#region src/components/ui/drop-zone/drop-zone-context.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DiscriminatedRenderItemProps, DiscriminatedRenderProps, InferProps, PolymorphicPropsStrict } from "@zayne-labs/toolkit-react/utils";
|
|
2
2
|
import { UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
import * as
|
|
4
|
-
import * as react_jsx_runtime23 from "react/jsx-runtime";
|
|
3
|
+
import * as react22 from "react";
|
|
5
4
|
import "@zayne-labs/toolkit-react";
|
|
5
|
+
import * as react_jsx_runtime21 from "react/jsx-runtime";
|
|
6
6
|
import { Control, ControllerProps, FieldPath, FormStateSubscribeProps, RegisterOptions, UseFormReturn, UseFormStateReturn, WatchProps, useFormContext as useFormRootContext } from "react-hook-form";
|
|
7
7
|
|
|
8
8
|
//#region src/components/ui/form/form-context.d.ts
|
|
@@ -37,7 +37,7 @@ type FormRootProps<TFieldValues extends FieldValues, TTransformedValues> = Infer
|
|
|
37
37
|
children: React.ReactNode;
|
|
38
38
|
form: UseFormReturn<TFieldValues, unknown, TTransformedValues>;
|
|
39
39
|
};
|
|
40
|
-
declare function FormRoot<TFieldValues extends FieldValues, TTransformedValues = TFieldValues>(props: FormRootProps<TFieldValues, TTransformedValues>):
|
|
40
|
+
declare function FormRoot<TFieldValues extends FieldValues, TTransformedValues = TFieldValues>(props: FormRootProps<TFieldValues, TTransformedValues>): react_jsx_runtime21.JSX.Element;
|
|
41
41
|
type FormFieldProps<TControl, TFieldValues extends FieldValues, TTransformedValues> = (TControl extends (Control<infer TValues>) ? {
|
|
42
42
|
control?: never;
|
|
43
43
|
name: FieldPath<TValues>;
|
|
@@ -51,23 +51,23 @@ type FormFieldProps<TControl, TFieldValues extends FieldValues, TTransformedValu
|
|
|
51
51
|
className?: never;
|
|
52
52
|
withWrapper: false;
|
|
53
53
|
});
|
|
54
|
-
declare function FormField<TControl, TFieldValues extends FieldValues = FieldValues, TTransformedValues = TFieldValues>(props: FormFieldProps<TControl, TFieldValues, TTransformedValues>):
|
|
54
|
+
declare function FormField<TControl, TFieldValues extends FieldValues = FieldValues, TTransformedValues = TFieldValues>(props: FormFieldProps<TControl, TFieldValues, TTransformedValues>): react_jsx_runtime21.JSX.Element;
|
|
55
55
|
type FormFieldControlledFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>, TTransformedValues = TFieldValues> = ControllerProps<TFieldValues, TName, TTransformedValues>;
|
|
56
|
-
declare function FormFieldWithController<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>, TTransformedValues = TFieldValues>(props: FormFieldControlledFieldProps<TFieldValues, TName, TTransformedValues>):
|
|
56
|
+
declare function FormFieldWithController<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>, TTransformedValues = TFieldValues>(props: FormFieldControlledFieldProps<TFieldValues, TName, TTransformedValues>): react_jsx_runtime21.JSX.Element;
|
|
57
57
|
type FormFieldBoundControllerProps<TFieldValues extends FieldValues, TTransformedValues> = Omit<ControllerProps<TFieldValues, never, TTransformedValues>, "control" | "name">;
|
|
58
|
-
declare function FormFieldBoundController<TFieldValues extends FieldValues = Record<string, never>, TTransformedValues = TFieldValues>(props: FormFieldBoundControllerProps<TFieldValues, TTransformedValues>):
|
|
59
|
-
declare function FormFieldContext(props: FormFieldContextProps):
|
|
60
|
-
declare function FormLabel(props: InferProps<"label">):
|
|
61
|
-
declare function FormInputGroup(props: InferProps<"div">):
|
|
58
|
+
declare function FormFieldBoundController<TFieldValues extends FieldValues = Record<string, never>, TTransformedValues = TFieldValues>(props: FormFieldBoundControllerProps<TFieldValues, TTransformedValues>): react_jsx_runtime21.JSX.Element;
|
|
59
|
+
declare function FormFieldContext(props: FormFieldContextProps): react22.ReactNode;
|
|
60
|
+
declare function FormLabel(props: InferProps<"label">): react_jsx_runtime21.JSX.Element;
|
|
61
|
+
declare function FormInputGroup(props: InferProps<"div">): react_jsx_runtime21.JSX.Element;
|
|
62
62
|
type FormSideItemProps = {
|
|
63
63
|
children?: React.ReactNode;
|
|
64
64
|
className?: string;
|
|
65
65
|
};
|
|
66
|
-
declare function FormInputLeftItem<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, FormSideItemProps>):
|
|
66
|
+
declare function FormInputLeftItem<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, FormSideItemProps>): react_jsx_runtime21.JSX.Element;
|
|
67
67
|
declare namespace FormInputLeftItem {
|
|
68
68
|
var slotSymbol: symbol;
|
|
69
69
|
}
|
|
70
|
-
declare function FormInputRightItem<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, FormSideItemProps>):
|
|
70
|
+
declare function FormInputRightItem<TElement extends React.ElementType = "span">(props: PolymorphicPropsStrict<TElement, FormSideItemProps>): react_jsx_runtime21.JSX.Element;
|
|
71
71
|
declare namespace FormInputRightItem {
|
|
72
72
|
var slotSymbol: symbol;
|
|
73
73
|
}
|
|
@@ -103,13 +103,13 @@ type FormSelectPrimitiveProps<TFieldValues extends FieldValues> = React.Componen
|
|
|
103
103
|
};
|
|
104
104
|
declare function FormInputPrimitive<TFieldValues extends FieldValues>(props: FormInputPrimitiveProps<TFieldValues> & {
|
|
105
105
|
rules?: RegisterOptions;
|
|
106
|
-
}):
|
|
106
|
+
}): react_jsx_runtime21.JSX.Element;
|
|
107
107
|
declare function FormTextAreaPrimitive<TFieldValues extends FieldValues>(props: FormTextAreaPrimitiveProps<TFieldValues> & {
|
|
108
108
|
rules?: RegisterOptions;
|
|
109
|
-
}):
|
|
109
|
+
}): react_jsx_runtime21.JSX.Element;
|
|
110
110
|
declare function FormSelectPrimitive<TFieldValues extends FieldValues>(props: FormSelectPrimitiveProps<TFieldValues> & {
|
|
111
111
|
rules?: RegisterOptions;
|
|
112
|
-
}):
|
|
112
|
+
}): react_jsx_runtime21.JSX.Element;
|
|
113
113
|
type PrimitivePropsToOmit = "control" | "formState" | "name";
|
|
114
114
|
type FormInputProps = Omit<FormInputPrimitiveProps<FieldValues>, PrimitivePropsToOmit> & {
|
|
115
115
|
rules?: RegisterOptions;
|
|
@@ -127,10 +127,10 @@ type CombinedFormInputProps = (FormSelectProps & {
|
|
|
127
127
|
}) | FormInputProps;
|
|
128
128
|
declare function FormInput(props: CombinedFormInputProps & {
|
|
129
129
|
rules?: RegisterOptions;
|
|
130
|
-
}):
|
|
131
|
-
declare function FormTextArea(props: FormTextAreaProps):
|
|
132
|
-
declare function FormSelect(props: FormSelectProps):
|
|
133
|
-
declare function FormDescription(props: InferProps<"p">):
|
|
130
|
+
}): react_jsx_runtime21.JSX.Element;
|
|
131
|
+
declare function FormTextArea(props: FormTextAreaProps): react_jsx_runtime21.JSX.Element;
|
|
132
|
+
declare function FormSelect(props: FormSelectProps): react_jsx_runtime21.JSX.Element;
|
|
133
|
+
declare function FormDescription(props: InferProps<"p">): react_jsx_runtime21.JSX.Element;
|
|
134
134
|
type ErrorMessageRenderProps = {
|
|
135
135
|
className: string;
|
|
136
136
|
"data-index": number;
|
|
@@ -189,15 +189,15 @@ type FormErrorMessageProps<TControl, TFieldValues extends FieldValues, TTransfor
|
|
|
189
189
|
errorField: string;
|
|
190
190
|
type: "root";
|
|
191
191
|
};
|
|
192
|
-
declare function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues, TTransformedValues = TFieldValues>(props: FormErrorMessageProps<TControl, TFieldValues, TTransformedValues>):
|
|
192
|
+
declare function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues, TTransformedValues = TFieldValues>(props: FormErrorMessageProps<TControl, TFieldValues, TTransformedValues>): react_jsx_runtime21.JSX.Element;
|
|
193
193
|
type FormSubmitProps = InferProps<"button"> & {
|
|
194
194
|
asChild?: boolean;
|
|
195
195
|
};
|
|
196
|
-
declare function FormSubmit<TElement extends React.ElementType = "button">(props: PolymorphicPropsStrict<TElement, FormSubmitProps>):
|
|
196
|
+
declare function FormSubmit<TElement extends React.ElementType = "button">(props: PolymorphicPropsStrict<TElement, FormSubmitProps>): react_jsx_runtime21.JSX.Element;
|
|
197
197
|
type FormWatchProps<TFieldValues extends FieldValues, TFieldName extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues> | ReadonlyArray<FieldPath<TFieldValues>> | undefined, TTransformedValues, TComputeValue, TComputedProps extends Omit<WatchProps<TFieldName, TFieldValues, unknown, TTransformedValues, TComputeValue>, "names"> = Omit<WatchProps<TFieldName, TFieldValues, unknown, TTransformedValues, TComputeValue>, "names">> = DiscriminatedRenderProps<TComputedProps["render"]> & Omit<TComputedProps, "render">;
|
|
198
|
-
declare function FormWatch<TFieldValues extends FieldValues = FieldValues, const TFieldName extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues> | ReadonlyArray<FieldPath<TFieldValues>> | undefined = undefined, TTransformedValues = TFieldValues, TComputeValue = undefined>(props: FormWatchProps<TFieldValues, TFieldName, TTransformedValues, TComputeValue>):
|
|
198
|
+
declare function FormWatch<TFieldValues extends FieldValues = FieldValues, const TFieldName extends Array<FieldPath<TFieldValues>> | FieldPath<TFieldValues> | ReadonlyArray<FieldPath<TFieldValues>> | undefined = undefined, TTransformedValues = TFieldValues, TComputeValue = undefined>(props: FormWatchProps<TFieldValues, TFieldName, TTransformedValues, TComputeValue>): react22.ReactNode | react22.ReactNode[];
|
|
199
199
|
type FormStateSubscribeProps$1<TFieldValues extends FieldValues, TTransformedValues, TComputedProps extends FormStateSubscribeProps<TFieldValues, TTransformedValues> = FormStateSubscribeProps<TFieldValues, TTransformedValues>> = DiscriminatedRenderProps<TComputedProps["render"]> & Omit<TComputedProps, "render">;
|
|
200
|
-
declare function FormStateSubscribe<TFieldValues extends FieldValues, TTransformedValues = TFieldValues>(props: FormStateSubscribeProps$1<TFieldValues, TTransformedValues>):
|
|
200
|
+
declare function FormStateSubscribe<TFieldValues extends FieldValues, TTransformedValues = TFieldValues>(props: FormStateSubscribeProps$1<TFieldValues, TTransformedValues>): react22.ReactNode;
|
|
201
201
|
declare namespace form_parts_d_exports {
|
|
202
202
|
export { FormDescription as Description, FormErrorMessage as ErrorMessage, FormErrorMessagePrimitive as ErrorMessagePrimitive, FormField as Field, FormFieldBoundController as FieldBoundController, FormFieldContext as FieldContext, FormFieldWithController as FieldWithController, FormInput as Input, FormInputGroup as InputGroup, FormInputLeftItem as InputLeftItem, FormInputPrimitive as InputPrimitive, FormInputRightItem as InputRightItem, FormLabel as Label, FormRoot as Root, FormSelect as Select, FormStateSubscribe as StateSubscribe, FormSubmit as Submit, FormTextArea as TextArea, FormTextAreaPrimitive as TextAreaPrimitive, FormWatch as Watch };
|
|
203
203
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
4
|
-
import { n as SlotRoot } from "../../slot-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { n as SlotRoot } from "../../slot-C7TE8pEK.js";
|
|
5
|
+
import { r as ForWithWrapper } from "../../for-DAM4xYij.js";
|
|
6
|
+
import { t as cnMerge } from "../../cn-2hIN1AQ7.js";
|
|
7
7
|
import { composeRefs, composeTwoEventHandlers, getMultipleSlots } from "@zayne-labs/toolkit-react/utils";
|
|
8
8
|
import { defineEnum, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
9
9
|
import { Fragment, createElement, useEffect, useId, useMemo, useRef } from "react";
|
|
10
|
+
import { ContextError, createCustomContext, useCallbackRef, useCompareValue, useToggle } from "@zayne-labs/toolkit-react";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { dataAttr, on, toArray } from "@zayne-labs/toolkit-core";
|
|
12
|
-
import { ContextError, createCustomContext, useCallbackRef, useCompareValue, useToggle } from "@zayne-labs/toolkit-react";
|
|
13
13
|
import { Controller, FormProvider, useFormContext, useFormContext as useFormRootContext, useFormState, useWatch } from "react-hook-form";
|
|
14
14
|
|
|
15
15
|
//#region src/components/ui/form/icons.tsx
|
package/dist/style.css
CHANGED
|
@@ -736,90 +736,6 @@
|
|
|
736
736
|
--color-zu-primary-foreground: oklch(0.205 0 0);
|
|
737
737
|
--color-zu-ring: oklch(0.552 0.016 285.938);
|
|
738
738
|
}
|
|
739
|
-
@property --tw-animation-delay {
|
|
740
|
-
syntax: "*";
|
|
741
|
-
inherits: false;
|
|
742
|
-
initial-value: 0s;
|
|
743
|
-
}
|
|
744
|
-
@property --tw-animation-direction {
|
|
745
|
-
syntax: "*";
|
|
746
|
-
inherits: false;
|
|
747
|
-
initial-value: normal;
|
|
748
|
-
}
|
|
749
|
-
@property --tw-animation-duration {
|
|
750
|
-
syntax: "*";
|
|
751
|
-
inherits: false;
|
|
752
|
-
}
|
|
753
|
-
@property --tw-animation-fill-mode {
|
|
754
|
-
syntax: "*";
|
|
755
|
-
inherits: false;
|
|
756
|
-
initial-value: none;
|
|
757
|
-
}
|
|
758
|
-
@property --tw-animation-iteration-count {
|
|
759
|
-
syntax: "*";
|
|
760
|
-
inherits: false;
|
|
761
|
-
initial-value: 1;
|
|
762
|
-
}
|
|
763
|
-
@property --tw-enter-blur {
|
|
764
|
-
syntax: "*";
|
|
765
|
-
inherits: false;
|
|
766
|
-
initial-value: 0;
|
|
767
|
-
}
|
|
768
|
-
@property --tw-enter-opacity {
|
|
769
|
-
syntax: "*";
|
|
770
|
-
inherits: false;
|
|
771
|
-
initial-value: 1;
|
|
772
|
-
}
|
|
773
|
-
@property --tw-enter-rotate {
|
|
774
|
-
syntax: "*";
|
|
775
|
-
inherits: false;
|
|
776
|
-
initial-value: 0;
|
|
777
|
-
}
|
|
778
|
-
@property --tw-enter-scale {
|
|
779
|
-
syntax: "*";
|
|
780
|
-
inherits: false;
|
|
781
|
-
initial-value: 1;
|
|
782
|
-
}
|
|
783
|
-
@property --tw-enter-translate-x {
|
|
784
|
-
syntax: "*";
|
|
785
|
-
inherits: false;
|
|
786
|
-
initial-value: 0;
|
|
787
|
-
}
|
|
788
|
-
@property --tw-enter-translate-y {
|
|
789
|
-
syntax: "*";
|
|
790
|
-
inherits: false;
|
|
791
|
-
initial-value: 0;
|
|
792
|
-
}
|
|
793
|
-
@property --tw-exit-blur {
|
|
794
|
-
syntax: "*";
|
|
795
|
-
inherits: false;
|
|
796
|
-
initial-value: 0;
|
|
797
|
-
}
|
|
798
|
-
@property --tw-exit-opacity {
|
|
799
|
-
syntax: "*";
|
|
800
|
-
inherits: false;
|
|
801
|
-
initial-value: 1;
|
|
802
|
-
}
|
|
803
|
-
@property --tw-exit-rotate {
|
|
804
|
-
syntax: "*";
|
|
805
|
-
inherits: false;
|
|
806
|
-
initial-value: 0;
|
|
807
|
-
}
|
|
808
|
-
@property --tw-exit-scale {
|
|
809
|
-
syntax: "*";
|
|
810
|
-
inherits: false;
|
|
811
|
-
initial-value: 1;
|
|
812
|
-
}
|
|
813
|
-
@property --tw-exit-translate-x {
|
|
814
|
-
syntax: "*";
|
|
815
|
-
inherits: false;
|
|
816
|
-
initial-value: 0;
|
|
817
|
-
}
|
|
818
|
-
@property --tw-exit-translate-y {
|
|
819
|
-
syntax: "*";
|
|
820
|
-
inherits: false;
|
|
821
|
-
initial-value: 0;
|
|
822
|
-
}
|
|
823
739
|
@property --tw-translate-x {
|
|
824
740
|
syntax: "*";
|
|
825
741
|
inherits: false;
|
|
@@ -919,23 +835,6 @@
|
|
|
919
835
|
--tw-font-weight: initial;
|
|
920
836
|
--tw-duration: initial;
|
|
921
837
|
--tw-ease: initial;
|
|
922
|
-
--tw-animation-delay: 0s;
|
|
923
|
-
--tw-animation-direction: normal;
|
|
924
|
-
--tw-animation-duration: initial;
|
|
925
|
-
--tw-animation-fill-mode: none;
|
|
926
|
-
--tw-animation-iteration-count: 1;
|
|
927
|
-
--tw-enter-blur: 0;
|
|
928
|
-
--tw-enter-opacity: 1;
|
|
929
|
-
--tw-enter-rotate: 0;
|
|
930
|
-
--tw-enter-scale: 1;
|
|
931
|
-
--tw-enter-translate-x: 0;
|
|
932
|
-
--tw-enter-translate-y: 0;
|
|
933
|
-
--tw-exit-blur: 0;
|
|
934
|
-
--tw-exit-opacity: 1;
|
|
935
|
-
--tw-exit-rotate: 0;
|
|
936
|
-
--tw-exit-scale: 1;
|
|
937
|
-
--tw-exit-translate-x: 0;
|
|
938
|
-
--tw-exit-translate-y: 0;
|
|
939
838
|
}
|
|
940
839
|
}
|
|
941
840
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/ui-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.48",
|
|
5
5
|
"description": "A composable UI/UI-utilities components library. ",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
"react-dom": "19.x.x",
|
|
35
35
|
"react-hook-form": "7.x.x",
|
|
36
36
|
"tailwind-merge": "^2.5.0 || ^3.0.0",
|
|
37
|
-
"tailwindcss": "4.x.x"
|
|
38
|
-
"tw-animate-css": "1.x.x"
|
|
37
|
+
"tailwindcss": "4.x.x"
|
|
39
38
|
},
|
|
40
39
|
"peerDependenciesMeta": {
|
|
41
40
|
"react-hook-form": {
|
|
@@ -43,9 +42,6 @@
|
|
|
43
42
|
},
|
|
44
43
|
"tailwindcss": {
|
|
45
44
|
"optional": true
|
|
46
|
-
},
|
|
47
|
-
"tw-animate-css": {
|
|
48
|
-
"optional": true
|
|
49
45
|
}
|
|
50
46
|
},
|
|
51
47
|
"dependencies": {
|
|
@@ -59,7 +55,7 @@
|
|
|
59
55
|
"@size-limit/preset-small-lib": "12.0.0",
|
|
60
56
|
"@tailwindcss/cli": "4.1.18",
|
|
61
57
|
"@total-typescript/ts-reset": "0.6.1",
|
|
62
|
-
"@types/react": "19.2.
|
|
58
|
+
"@types/react": "19.2.10",
|
|
63
59
|
"@types/react-dom": "19.2.3",
|
|
64
60
|
"@zayne-labs/prettier-config": "0.11.21",
|
|
65
61
|
"@zayne-labs/tsconfig": "0.11.21",
|
|
@@ -71,14 +67,13 @@
|
|
|
71
67
|
"prettier-plugin-tailwindcss": "0.7.2",
|
|
72
68
|
"publint": "0.3.17",
|
|
73
69
|
"publish": "0.6.0",
|
|
74
|
-
"react": "19.2.
|
|
75
|
-
"react-dom": "19.2.
|
|
70
|
+
"react": "19.2.4",
|
|
71
|
+
"react-dom": "19.2.4",
|
|
76
72
|
"react-hook-form": "7.71.1",
|
|
77
73
|
"size-limit": "12.0.0",
|
|
78
74
|
"tailwind-merge": "3.4.0",
|
|
79
75
|
"tailwindcss": "4.1.18",
|
|
80
76
|
"tsdown": "0.20.1",
|
|
81
|
-
"tw-animate-css": "1.4.0",
|
|
82
77
|
"typescript": "5.9.3"
|
|
83
78
|
},
|
|
84
79
|
"publishConfig": {
|