@zayne-labs/ui-react 0.0.3

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.
Files changed (36) hide show
  1. package/dist/esm/For-BmvZgK9J.d.ts +17 -0
  2. package/dist/esm/chunk-7TYZVYD6.js +42 -0
  3. package/dist/esm/chunk-7TYZVYD6.js.map +1 -0
  4. package/dist/esm/chunk-ABOA7YOO.js +9 -0
  5. package/dist/esm/chunk-ABOA7YOO.js.map +1 -0
  6. package/dist/esm/common/For/index.d.ts +9 -0
  7. package/dist/esm/common/For/index.js +3 -0
  8. package/dist/esm/common/For/index.js.map +1 -0
  9. package/dist/esm/common/Show/index.d.ts +22 -0
  10. package/dist/esm/common/Show/index.js +38 -0
  11. package/dist/esm/common/Show/index.js.map +1 -0
  12. package/dist/esm/common/Slot/index.d.ts +8 -0
  13. package/dist/esm/common/Slot/index.js +47 -0
  14. package/dist/esm/common/Slot/index.js.map +1 -0
  15. package/dist/esm/common/Switch/index.d.ts +20 -0
  16. package/dist/esm/common/Switch/index.js +26 -0
  17. package/dist/esm/common/Switch/index.js.map +1 -0
  18. package/dist/esm/common/Teleport/index.d.ts +12 -0
  19. package/dist/esm/common/Teleport/index.js +31 -0
  20. package/dist/esm/common/Teleport/index.js.map +1 -0
  21. package/dist/esm/index.d.ts +2 -0
  22. package/dist/esm/index.js +3 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/ui/carousel/index.d.ts +96 -0
  25. package/dist/esm/ui/carousel/index.js +263 -0
  26. package/dist/esm/ui/carousel/index.js.map +1 -0
  27. package/dist/esm/ui/drag-scroll/index.d.ts +25 -0
  28. package/dist/esm/ui/drag-scroll/index.js +104 -0
  29. package/dist/esm/ui/drag-scroll/index.js.map +1 -0
  30. package/dist/esm/ui/drop-zone/index.d.ts +655 -0
  31. package/dist/esm/ui/drop-zone/index.js +125 -0
  32. package/dist/esm/ui/drop-zone/index.js.map +1 -0
  33. package/dist/esm/ui/form/index.d.ts +159 -0
  34. package/dist/esm/ui/form/index.js +336 -0
  35. package/dist/esm/ui/form/index.js.map +1 -0
  36. package/package.json +113 -0
@@ -0,0 +1,17 @@
1
+ import * as react from 'react';
2
+ import { DiscriminatedRenderProps, PolymorphicProps } from '@zayne-labs/toolkit-react/utils';
3
+
4
+ type RenderPropFn<TArrayItem> = (item: TArrayItem, index: number, array: TArrayItem[]) => react.ReactNode;
5
+ type EachProp<TArrayItem> = {
6
+ each: TArrayItem[];
7
+ };
8
+ type ForRenderProps<TArrayItem> = DiscriminatedRenderProps<RenderPropFn<TArrayItem>>;
9
+ type ForProps<TArrayItem> = EachProp<TArrayItem> & ForRenderProps<TArrayItem>;
10
+ declare function ForBase<TArrayItem>(props: ForProps<TArrayItem>): react.ReactNode[];
11
+ declare function ForList<TArrayItem, TElement extends react.ElementType = "ul">(props: PolymorphicProps<TElement, ForProps<TArrayItem> & {
12
+ className?: string;
13
+ }>): react.JSX.Element;
14
+ declare const Base: typeof ForBase;
15
+ declare const List: typeof ForList;
16
+
17
+ export { Base as B, type EachProp as E, type ForRenderProps as F, List as L, ForBase as a, ForList as b };
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { isArray } from '@zayne-labs/toolkit-type-helpers';
3
+
4
+ // src/components/common/For/For.tsx
5
+ function ForBase(props) {
6
+ const { children, each, render } = props;
7
+ if (!isArray(each)) {
8
+ return each;
9
+ }
10
+ const JSXElementList = each.map((...params) => {
11
+ if (typeof children === "function") {
12
+ return children(...params);
13
+ }
14
+ return render(...params);
15
+ });
16
+ return JSXElementList;
17
+ }
18
+ function ForList(props) {
19
+ const { as: ListContainer = "ul", children, className, each, ref, render, ...restOfListProps } = props;
20
+ return /* @__PURE__ */ React.createElement(ListContainer, { ref, className, ...restOfListProps }, /* @__PURE__ */ React.createElement(ForBase, { ...{ children, each, render } }));
21
+ }
22
+ var Base = ForBase;
23
+ var List = ForList;
24
+
25
+ // src/components/common/For/getElementList.ts
26
+ var getElementList = (variant) => {
27
+ switch (variant) {
28
+ case "base": {
29
+ return [Base];
30
+ }
31
+ case "withWrapper": {
32
+ return [List];
33
+ }
34
+ default: {
35
+ return [List];
36
+ }
37
+ }
38
+ };
39
+
40
+ export { Base, ForBase, ForList, List, getElementList };
41
+ //# sourceMappingURL=chunk-7TYZVYD6.js.map
42
+ //# sourceMappingURL=chunk-7TYZVYD6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/common/For/For.tsx","../../src/components/common/For/getElementList.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,QAAoB,KAA6B,EAAA;AAChE,EAAA,MAAM,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,EAAW,GAAA,KAAA;AAEnC,EAAI,IAAA,CAAC,OAAQ,CAAA,IAAI,CAAG,EAAA;AACnB,IAAO,OAAA,IAAA;AAAA;AAGR,EAAA,MAAM,cAAiB,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,GAAI,MAAiD,KAAA;AACpF,IAAI,IAAA,OAAO,aAAa,UAAY,EAAA;AACnC,MAAO,OAAA,QAAA,CAAS,GAAG,MAAM,CAAA;AAAA;AAG1B,IAAO,OAAA,MAAA,CAAO,GAAG,MAAM,CAAA;AAAA,GACvB,CAAA;AAED,EAAO,OAAA,cAAA;AACR;AAEO,SAAS,QACf,KACC,EAAA;AACD,EAAM,MAAA,EAAE,EAAI,EAAA,aAAA,GAAgB,IAAM,EAAA,QAAA,EAAU,SAAW,EAAA,IAAA,EAAM,GAAK,EAAA,MAAA,EAAQ,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEjG,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAc,GAAU,EAAA,SAAA,EAAuB,GAAG,eAClD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAI,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,IAAmC,CACpE,CAAA;AAEF;AAEO,IAAM,IAAO,GAAA;AAEb,IAAM,IAAO,GAAA;;;AC5Cd,IAAA,cAAA,GAAiB,CACtB,OACoC,KAAA;AACpC,EAAA,QAAQ,OAAS;AAAA,IAChB,KAAK,MAAQ,EAAA;AACZ,MAAA,OAAO,CAAK,IAAI,CAAA;AAAA;AACjB,IACA,KAAK,aAAe,EAAA;AACnB,MAAA,OAAO,CAAK,IAAI,CAAA;AAAA;AACjB,IACA,SAAS;AACR,MAAA,OAAO,CAAK,IAAI,CAAA;AAAA;AACjB;AAEF","file":"chunk-7TYZVYD6.js","sourcesContent":["import * as React from \"react\";\n\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray } from \"@zayne-labs/toolkit-type-helpers\";\n\n// prettier-ignore\ntype RenderPropFn<TArrayItem> = (\n\titem: TArrayItem,\n\tindex: number,\n\tarray: TArrayItem[]\n) => React.ReactNode;\n\nexport type EachProp<TArrayItem> = { each: TArrayItem[] };\n\nexport type ForRenderProps<TArrayItem> = DiscriminatedRenderProps<RenderPropFn<TArrayItem>>;\n\ntype ForProps<TArrayItem> = EachProp<TArrayItem> & ForRenderProps<TArrayItem>;\n\nexport function ForBase<TArrayItem>(props: ForProps<TArrayItem>) {\n\tconst { children, each, render } = props;\n\n\tif (!isArray(each)) {\n\t\treturn each;\n\t}\n\n\tconst JSXElementList = each.map((...params: Parameters<RenderPropFn<TArrayItem>>) => {\n\t\tif (typeof children === \"function\") {\n\t\t\treturn children(...params);\n\t\t}\n\n\t\treturn render(...params);\n\t});\n\n\treturn JSXElementList;\n}\n\nexport function ForList<TArrayItem, TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicProps<TElement, ForProps<TArrayItem> & { className?: string }>\n) {\n\tconst { as: ListContainer = \"ul\", children, className, each, ref, render, ...restOfListProps } = props;\n\n\treturn (\n\t\t<ListContainer ref={ref} className={className} {...restOfListProps}>\n\t\t\t<ForBase {...({ children, each, render } as ForProps<TArrayItem>)} />\n\t\t</ListContainer>\n\t);\n}\n\nexport const Base = ForBase;\n\nexport const List = ForList;\n","import * as For from \"./For\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> = TVariant extends \"base\"\n\t? [typeof For.Base]\n\t: [typeof For.List];\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.Base] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [For.List] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [For.List] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"]}
@@ -0,0 +1,9 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+
4
+ // src/lib/utils/cn.ts
5
+ var cnMerge = (...classNames) => twMerge(clsx(classNames));
6
+
7
+ export { cnMerge };
8
+ //# sourceMappingURL=chunk-ABOA7YOO.js.map
9
+ //# sourceMappingURL=chunk-ABOA7YOO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/utils/cn.ts"],"names":[],"mappings":";;;;AAGO,IAAM,UAAU,CAAI,GAAA,UAAA,KAA6B,OAAQ,CAAA,IAAA,CAAK,UAAU,CAAC","file":"chunk-ABOA7YOO.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport const cnMerge = (...classNames: ClassValue[]) => twMerge(clsx(classNames));\n"]}
@@ -0,0 +1,9 @@
1
+ import { B as Base, L as List } from '../../For-BmvZgK9J.js';
2
+ export { E as EachProp, a as ForBase, b as ForList, F as ForRenderProps } from '../../For-BmvZgK9J.js';
3
+ import 'react';
4
+ import '@zayne-labs/toolkit-react/utils';
5
+
6
+ type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof Base] : [typeof List];
7
+ declare const getElementList: <TVariant extends "base" | "withWrapper" = "withWrapper">(variant?: TVariant) => GetElementListResult<TVariant>;
8
+
9
+ export { Base, List, getElementList };
@@ -0,0 +1,3 @@
1
+ export { Base, ForBase, ForList, List, getElementList } from '../../chunk-7TYZVYD6.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+
3
+ type ShowProps = {
4
+ children: react.ReactNode;
5
+ fallback?: react.ReactNode;
6
+ when: boolean;
7
+ };
8
+ declare function Show({ children, fallback, when }: ShowProps): react.ReactNode;
9
+ declare function ShowContent({ children }: Pick<ShowProps, "children">): react.ReactNode;
10
+ declare namespace ShowContent {
11
+ var slot: symbol;
12
+ }
13
+ declare function ShowFallback({ children }: Pick<ShowProps, "children">): react.ReactNode;
14
+ declare namespace ShowFallback {
15
+ var slot: symbol;
16
+ }
17
+ declare const Root: typeof Show;
18
+ declare const Fallback: typeof ShowFallback;
19
+ declare const Content: typeof ShowContent;
20
+ declare const OtherWise: typeof ShowFallback;
21
+
22
+ export { Content, Fallback, OtherWise, Root, Show, ShowContent, ShowFallback };
@@ -0,0 +1,38 @@
1
+ import 'react';
2
+ import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/utils';
3
+ import { AssertionError } from '@zayne-labs/toolkit-type-helpers';
4
+
5
+ // src/components/common/Show/Show.tsx
6
+ function Show({ children, fallback, when }) {
7
+ const fallBackSlot = getSlotElement(children, ShowFallback, {
8
+ errorMessage: "Only one <Show.Fallback> or <Show.OtherWise> component is allowed",
9
+ throwOnMultipleSlotMatch: true
10
+ });
11
+ const contentSlot = getSlotElement(children, ShowContent, {
12
+ errorMessage: "Only one <Show.Content> component is allowed",
13
+ throwOnMultipleSlotMatch: true
14
+ });
15
+ const otherChildren = getOtherChildren(children, [ShowFallback, ShowContent]);
16
+ if (fallBackSlot && fallback) {
17
+ throw new AssertionError(`
18
+ The fallback prop and <Show.Fallback>/<Show.OtherWise> cannot be used at the same time.
19
+ `);
20
+ }
21
+ return when ? contentSlot ?? otherChildren : fallBackSlot ?? fallback;
22
+ }
23
+ function ShowContent({ children }) {
24
+ return children;
25
+ }
26
+ ShowContent.slot = Symbol.for("content");
27
+ function ShowFallback({ children }) {
28
+ return children;
29
+ }
30
+ ShowFallback.slot = Symbol.for("fallback");
31
+ var Root = Show;
32
+ var Fallback = ShowFallback;
33
+ var Content = ShowContent;
34
+ var OtherWise = ShowFallback;
35
+
36
+ export { Content, Fallback, OtherWise, Root, Show, ShowContent, ShowFallback };
37
+ //# sourceMappingURL=index.js.map
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/common/Show/Show.tsx"],"names":[],"mappings":";;;;;AAaO,SAAS,IAAK,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,MAAmB,EAAA;AAC7D,EAAM,MAAA,YAAA,GAAe,cAAe,CAAA,QAAA,EAAU,YAAc,EAAA;AAAA,IAC3D,YAAc,EAAA,mEAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,WAAa,EAAA;AAAA,IACzD,YAAc,EAAA,8CAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAA,MAAM,gBAAgB,gBAAiB,CAAA,QAAA,EAAU,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAE5E,EAAA,IAAI,gBAAgB,QAAU,EAAA;AAC7B,IAAA,MAAM,IAAI,cAAe,CAAA;AAAA;AAAA,EAExB,CAAA,CAAA;AAAA;AAGF,EAAO,OAAA,IAAA,GAAQ,WAAe,IAAA,aAAA,GAAkB,YAAgB,IAAA,QAAA;AACjE;AAEO,SAAS,WAAA,CAAY,EAAE,QAAA,EAAyC,EAAA;AACtE,EAAO,OAAA,QAAA;AACR;AACA,WAAY,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,SAAS,CAAA;AAEhC,SAAS,YAAA,CAAa,EAAE,QAAA,EAAyC,EAAA;AACvE,EAAO,OAAA,QAAA;AACR;AACA,YAAa,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,UAAU,CAAA;AAElC,IAAM,IAAO,GAAA;AAEb,IAAM,QAAW,GAAA;AAEjB,IAAM,OAAU,GAAA;AAEhB,IAAM,SAAY,GAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getOtherChildren, getSlotElement } from \"@zayne-labs/toolkit-react/utils\";\nimport { AssertionError } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ShowProps = {\n\tchildren: React.ReactNode;\n\tfallback?: React.ReactNode;\n\twhen: boolean;\n};\n\nexport function Show({ children, fallback, when }: ShowProps) {\n\tconst fallBackSlot = getSlotElement(children, ShowFallback, {\n\t\terrorMessage: \"Only one <Show.Fallback> or <Show.OtherWise> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst contentSlot = getSlotElement(children, ShowContent, {\n\t\terrorMessage: \"Only one <Show.Content> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst otherChildren = getOtherChildren(children, [ShowFallback, ShowContent]);\n\n\tif (fallBackSlot && fallback) {\n\t\tthrow new AssertionError(`\n\t\t\tThe fallback prop and <Show.Fallback>/<Show.OtherWise> cannot be used at the same time.\n\t\t`);\n\t}\n\n\treturn when ? (contentSlot ?? otherChildren) : (fallBackSlot ?? fallback);\n}\n\nexport function ShowContent({ children }: Pick<ShowProps, \"children\">) {\n\treturn children;\n}\nShowContent.slot = Symbol.for(\"content\");\n\nexport function ShowFallback({ children }: Pick<ShowProps, \"children\">) {\n\treturn children;\n}\nShowFallback.slot = Symbol.for(\"fallback\");\n\nexport const Root = Show;\n\nexport const Fallback = ShowFallback;\n\nexport const Content = ShowContent;\n\nexport const OtherWise = ShowFallback;\n"]}
@@ -0,0 +1,8 @@
1
+ import * as react from 'react';
2
+ import { InferProps } from '@zayne-labs/toolkit-react/utils';
3
+
4
+ type SlotProps = InferProps<HTMLElement>;
5
+ declare function Slottable({ children }: Pick<SlotProps, "children">): react.ReactNode;
6
+ declare function Slot(props: SlotProps): react.JSX.Element;
7
+
8
+ export { Slot, Slottable };
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { Children, isValidElement, cloneElement } from 'react';
3
+ import { mergeProps, composeRefs } from '@zayne-labs/toolkit-react/utils';
4
+ import { isArray } from '@zayne-labs/toolkit-type-helpers';
5
+
6
+ // src/components/common/Slot/Slot.tsx
7
+ function Slottable({ children }) {
8
+ return children;
9
+ }
10
+ var isSlottable = (child) => {
11
+ return isValidElement(child) && child.type === Slottable;
12
+ };
13
+ function Slot(props) {
14
+ const { children, ...restOfSlotProps } = props;
15
+ const childrenArray = isArray(children) ? children : [children];
16
+ const slottable = childrenArray.find((element) => isSlottable(element));
17
+ if (slottable) {
18
+ const newElement = slottable.props.children;
19
+ const newElementChildren = childrenArray.map((child) => {
20
+ if (child !== slottable) {
21
+ return child;
22
+ }
23
+ if (Children.count(newElement) > 1) {
24
+ return Children.only(null);
25
+ }
26
+ return isValidElement(newElement) && newElement.props.children;
27
+ });
28
+ return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, isValidElement(newElement) && cloneElement(newElement, void 0, newElementChildren));
29
+ }
30
+ return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, children);
31
+ }
32
+ function SlotClone(props) {
33
+ const { children, ref: forwardedRef, ...restOfSlotProps } = props;
34
+ if (!isValidElement(children)) {
35
+ return Children.count(children) > 1 ? Children.only(null) : null;
36
+ }
37
+ const childRef = children.props.ref ?? children.ref;
38
+ const clonedProps = {
39
+ ...mergeProps(restOfSlotProps, children.props),
40
+ ref: forwardedRef ? composeRefs([forwardedRef, childRef]) : childRef
41
+ };
42
+ return cloneElement(children, clonedProps);
43
+ }
44
+
45
+ export { Slot, Slottable };
46
+ //# sourceMappingURL=index.js.map
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/common/Slot/Slot.tsx"],"names":[],"mappings":";;;;;;AAYO,SAAS,SAAA,CAAU,EAAE,QAAA,EAAyC,EAAA;AACpE,EAAO,OAAA,QAAA;AACR;AAEA,IAAM,WAAA,GAAc,CAAC,KAAwD,KAAA;AAC5E,EAAA,OAAO,cAAe,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,IAAS,KAAA,SAAA;AAChD,CAAA;AAMO,SAAS,KAAK,KAAkB,EAAA;AACtC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEzC,EAAA,MAAM,gBAAgB,OAAyB,CAAA,QAAQ,CAAI,GAAA,QAAA,GAAW,CAAC,QAAQ,CAAA;AAC/E,EAAA,MAAM,YAAY,aAAc,CAAA,IAAA,CAAK,CAAC,OAAY,KAAA,WAAA,CAAY,OAAO,CAAC,CAAA;AAEtE,EAAA,IAAI,SAAW,EAAA;AAEd,IAAM,MAAA,UAAA,GAAc,UAAU,KAAoB,CAAA,QAAA;AAElD,IAAA,MAAM,kBAAqB,GAAA,aAAA,CAAc,GAAI,CAAA,CAAC,KAAU,KAAA;AACvD,MAAA,IAAI,UAAU,SAAW,EAAA;AACxB,QAAO,OAAA,KAAA;AAAA;AAGR,MAAA,IAAI,QAAS,CAAA,KAAA,CAAM,UAAU,CAAA,GAAI,CAAG,EAAA;AACnC,QAAO,OAAA,QAAA,CAAS,KAAK,IAAI,CAAA;AAAA;AAI1B,MAAA,OAAO,cAA4C,CAAA,UAAU,CAAK,IAAA,UAAA,CAAW,KAAM,CAAA,QAAA;AAAA,KACnF,CAAA;AAED,IACC,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,eACb,EAAA,EAAA,cAAA,CAAe,UAAU,CAAA,IAAK,YAAa,CAAA,UAAA,EAAY,KAAW,CAAA,EAAA,kBAAkB,CACtF,CAAA;AAAA;AAIF,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,eAAA,EAAA,EAAkB,QAAS,CAAA;AAClD;AASA,SAAS,UAAU,KAAuB,EAAA;AACzC,EAAA,MAAM,EAAE,QAAU,EAAA,GAAA,EAAK,YAAc,EAAA,GAAG,iBAAoB,GAAA,KAAA;AAE5D,EAAI,IAAA,CAAC,cAA6B,CAAA,QAAQ,CAAG,EAAA;AAC5C,IAAO,OAAA,QAAA,CAAS,MAAM,QAAQ,CAAA,GAAI,IAAI,QAAS,CAAA,IAAA,CAAK,IAAI,CAAI,GAAA,IAAA;AAAA;AAG7D,EAAA,MAAM,QAAW,GAAA,QAAA,CAAS,KAAM,CAAA,GAAA,IAAQ,QAAqC,CAAA,GAAA;AAE7E,EAAA,MAAM,WAAc,GAAA;AAAA,IACnB,GAAG,UAAA,CAAW,eAAiB,EAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAC7C,KAAK,YAAe,GAAA,WAAA,CAAY,CAAC,YAAc,EAAA,QAA8B,CAAC,CAAI,GAAA;AAAA,GACnF;AAEA,EAAO,OAAA,YAAA,CAAa,UAAU,WAAW,CAAA;AAC1C","file":"index.js","sourcesContent":["import * as React from \"react\";\n\nimport { type InferProps, composeRefs, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement>;\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === Slottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (slottable) {\n\t\t// == The new element to render is the one passed as a child of `Slottable`\n\t\tconst newElement = (slottable.props as SlotProps).children;\n\n\t\tconst newElementChildren = childrenArray.map((child) => {\n\t\t\tif (child !== slottable) {\n\t\t\t\treturn child;\n\t\t\t}\n\n\t\t\tif (Children.count(newElement) > 1) {\n\t\t\t\treturn Children.only(null);\n\t\t\t}\n\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 isValidElement<Pick<SlotProps, \"children\">>(newElement) && newElement.props.children;\n\t\t});\n\n\t\treturn (\n\t\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t\t{isValidElement(newElement) && cloneElement(newElement, undefined, newElementChildren)}\n\t\t\t</SlotClone>\n\t\t);\n\t}\n\n\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n}\n\ntype SlotCloneProps = {\n\tchildren: React.ReactNode;\n\tref?: React.RefObject<HTMLElement>;\n};\n\ntype UnknownProps = Record<string, unknown>;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (!isValidElement<UnknownProps>(children)) {\n\t\treturn Children.count(children) > 1 ? Children.only(null) : null;\n\t}\n\n\tconst childRef = children.props.ref ?? (children as unknown as UnknownProps).ref;\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, children.props),\n\t\tref: forwardedRef ? composeRefs([forwardedRef, childRef as React.Ref<unknown>]) : childRef,\n\t};\n\n\treturn cloneElement(children, clonedProps);\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import * as react from 'react';
2
+
3
+ type ValidSwitchComponentType = react.ReactElement<SwitchMatchProps>;
4
+ type SwitchProps<TCondition> = {
5
+ children: ValidSwitchComponentType | ValidSwitchComponentType[];
6
+ condition?: TCondition;
7
+ };
8
+ type SwitchMatchProps<TWhen = boolean> = {
9
+ children: react.ReactNode;
10
+ when: TWhen;
11
+ };
12
+ declare function Switch<TCondition = true>(props: SwitchProps<TCondition>): react.ReactElement<Pick<SwitchMatchProps<boolean>, "children">, string | react.JSXElementConstructor<any>> | undefined;
13
+ declare function Match<TWhen>({ children }: SwitchMatchProps<TWhen>): react.ReactNode;
14
+ declare function Default({ children }: Pick<SwitchMatchProps, "children">): react.ReactNode;
15
+ declare namespace Default {
16
+ var slot: symbol;
17
+ }
18
+ declare const Root: typeof Switch;
19
+
20
+ export { Default, Match, Root, Switch };
@@ -0,0 +1,26 @@
1
+ import 'react';
2
+ import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/utils';
3
+
4
+ // src/components/common/Switch/Switch.tsx
5
+ function Switch(props) {
6
+ const { children, condition = true } = props;
7
+ const defaultCase = getSlotElement(children, Default, {
8
+ errorMessage: "Only one <Switch.Default> component is allowed",
9
+ throwOnMultipleSlotMatch: true
10
+ });
11
+ const childrenCasesArray = getOtherChildren(children, Default);
12
+ const matchedCase = childrenCasesArray.find((child) => child.props.when === condition);
13
+ return matchedCase ?? defaultCase;
14
+ }
15
+ function Match({ children }) {
16
+ return children;
17
+ }
18
+ function Default({ children }) {
19
+ return children;
20
+ }
21
+ Default.slot = Symbol.for("default-case");
22
+ var Root = Switch;
23
+
24
+ export { Default, Match, Root, Switch };
25
+ //# sourceMappingURL=index.js.map
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/common/Switch/Switch.tsx"],"names":[],"mappings":";;;;AAkBO,SAAS,OAA0B,KAAgC,EAAA;AACzE,EAAA,MAAM,EAAE,QAAA,EAAU,SAAY,GAAA,IAAA,EAAS,GAAA,KAAA;AAEvC,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,OAAS,EAAA;AAAA,IACrD,YAAc,EAAA,gDAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,gBAAiB,CAAA,QAAA,EAAU,OAAO,CAAA;AAE7D,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAK,CAAA,CAAC,UAAU,KAAM,CAAA,KAAA,CAAM,SAAS,SAAS,CAAA;AAErF,EAAA,OAAO,WAAe,IAAA,WAAA;AACvB;AAEO,SAAS,KAAA,CAAa,EAAE,QAAA,EAAqC,EAAA;AACnE,EAAO,OAAA,QAAA;AACR;AAEO,SAAS,OAAA,CAAQ,EAAE,QAAA,EAAgD,EAAA;AACzE,EAAO,OAAA,QAAA;AACR;AACA,OAAQ,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,cAAc,CAAA;AAEjC,IAAM,IAAO,GAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getOtherChildren, getSlotElement } from \"@zayne-labs/toolkit-react/utils\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps>;\n\ntype SwitchProps<TCondition> = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tcondition?: TCondition;\n};\n\ntype SwitchMatchProps<TWhen = boolean> = {\n\tchildren: React.ReactNode;\n\twhen: TWhen;\n};\n\nexport function Switch<TCondition = true>(props: SwitchProps<TCondition>) {\n\tconst { children, condition = true } = props;\n\n\tconst defaultCase = getSlotElement(children, Default, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getOtherChildren(children, Default);\n\n\tconst matchedCase = childrenCasesArray.find((child) => child.props.when === condition);\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport function Match<TWhen>({ children }: SwitchMatchProps<TWhen>) {\n\treturn children;\n}\n\nexport function Default({ children }: Pick<SwitchMatchProps, \"children\">) {\n\treturn children;\n}\nDefault.slot = Symbol.for(\"default-case\");\n\nexport const Root = Switch;\n"]}
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { AnyString } from '@zayne-labs/toolkit-type-helpers';
3
+
4
+ type ValidHtmlTags = keyof HTMLElementTagNameMap;
5
+ type PortalProps = {
6
+ children: react.ReactNode;
7
+ insertPosition?: InsertPosition;
8
+ to?: AnyString | HTMLElement | ValidHtmlTags | null;
9
+ };
10
+ declare function Teleport(props: PortalProps): react.ReactPortal | null;
11
+
12
+ export { Teleport };
@@ -0,0 +1,31 @@
1
+ import { useState } from 'react';
2
+ import { useEffectOnce, useMountEffect } from '@zayne-labs/toolkit-react';
3
+ import { isString } from '@zayne-labs/toolkit-type-helpers';
4
+ import { createPortal } from 'react-dom';
5
+
6
+ // src/components/common/Teleport/Teleport.tsx
7
+ function Teleport(props) {
8
+ const { children, insertPosition, to } = props;
9
+ const [reactPortal, setReactPortal] = useState(null);
10
+ useEffectOnce(() => {
11
+ if (!to || !insertPosition) return;
12
+ const destination = isString(to) ? document.querySelector(to) : to;
13
+ const tempWrapper = document.createElement("div");
14
+ tempWrapper.style.display = "contents";
15
+ destination?.insertAdjacentElement(insertPosition, tempWrapper);
16
+ setReactPortal(createPortal(children, tempWrapper));
17
+ return () => {
18
+ tempWrapper.remove();
19
+ };
20
+ });
21
+ useMountEffect(() => {
22
+ if (!to || insertPosition) return;
23
+ const destination = isString(to) ? document.querySelector(to) : to;
24
+ destination && setReactPortal(createPortal(children, destination));
25
+ });
26
+ return reactPortal;
27
+ }
28
+
29
+ export { Teleport };
30
+ //# sourceMappingURL=index.js.map
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/common/Teleport/Teleport.tsx"],"names":[],"mappings":";;;;;;AAeA,SAAS,SAAS,KAAoB,EAAA;AACrC,EAAA,MAAM,EAAE,QAAA,EAAU,cAAgB,EAAA,EAAA,EAAO,GAAA,KAAA;AAEzC,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAmC,IAAI,CAAA;AAE7E,EAAA,aAAA,CAAc,MAAM;AACnB,IAAI,IAAA,CAAC,EAAM,IAAA,CAAC,cAAgB,EAAA;AAE5B,IAAA,MAAM,cAAc,QAAS,CAAA,EAAE,IAAI,QAAS,CAAA,aAAA,CAA2B,EAAE,CAAI,GAAA,EAAA;AAE7E,IAAM,MAAA,WAAA,GAAc,QAAS,CAAA,aAAA,CAAc,KAAK,CAAA;AAChD,IAAA,WAAA,CAAY,MAAM,OAAU,GAAA,UAAA;AAE5B,IAAa,WAAA,EAAA,qBAAA,CAAsB,gBAAgB,WAAW,CAAA;AAE9D,IAAe,cAAA,CAAA,YAAA,CAAa,QAAU,EAAA,WAAW,CAAC,CAAA;AAElD,IAAA,OAAO,MAAM;AACZ,MAAA,WAAA,CAAY,MAAO,EAAA;AAAA,KACpB;AAAA,GACA,CAAA;AAED,EAAA,cAAA,CAAe,MAAM;AACpB,IAAI,IAAA,CAAC,MAAM,cAAgB,EAAA;AAE3B,IAAA,MAAM,cAAc,QAAS,CAAA,EAAE,IAAI,QAAS,CAAA,aAAA,CAA2B,EAAE,CAAI,GAAA,EAAA;AAE7E,IAAA,WAAA,IAAe,cAAe,CAAA,YAAA,CAAa,QAAU,EAAA,WAAW,CAAC,CAAA;AAAA,GACjE,CAAA;AAED,EAAO,OAAA,WAAA;AACR","file":"index.js","sourcesContent":["import * as React from \"react\";\n\nimport { useEffectOnce, useMountEffect } from \"@zayne-labs/toolkit-react\";\nimport { type AnyString, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useState } from \"react\";\nimport { createPortal } from \"react-dom\";\n\ntype ValidHtmlTags = keyof HTMLElementTagNameMap;\n\ntype PortalProps = {\n\tchildren: React.ReactNode;\n\tinsertPosition?: InsertPosition;\n\tto?: AnyString | HTMLElement | ValidHtmlTags | null;\n};\n\nfunction Teleport(props: PortalProps) {\n\tconst { children, insertPosition, to } = props;\n\n\tconst [reactPortal, setReactPortal] = useState<React.ReactPortal | null>(null);\n\n\tuseEffectOnce(() => {\n\t\tif (!to || !insertPosition) return;\n\n\t\tconst destination = isString(to) ? document.querySelector<HTMLElement>(to) : to;\n\n\t\tconst tempWrapper = document.createElement(\"div\");\n\t\ttempWrapper.style.display = \"contents\";\n\n\t\tdestination?.insertAdjacentElement(insertPosition, tempWrapper);\n\n\t\tsetReactPortal(createPortal(children, tempWrapper));\n\n\t\treturn () => {\n\t\t\ttempWrapper.remove();\n\t\t};\n\t});\n\n\tuseMountEffect(() => {\n\t\tif (!to || insertPosition) return;\n\n\t\tconst destination = isString(to) ? document.querySelector<HTMLElement>(to) : to;\n\n\t\tdestination && setReactPortal(createPortal(children, destination));\n\t});\n\n\treturn reactPortal;\n}\n\nexport { Teleport };\n"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,96 @@
1
+ import * as react from 'react';
2
+ import { PolymorphicProps } from '@zayne-labs/toolkit-react/utils';
3
+ import { F as ForRenderProps, E as EachProp } from '../../For-BmvZgK9J.js';
4
+ import { Prettify } from '@zayne-labs/toolkit-type-helpers';
5
+ import { StoreApi } from 'zustand';
6
+
7
+ type ImagesType = Array<Record<string, string>> | string[];
8
+ type CarouselStore<TImages extends ImagesType = ImagesType> = {
9
+ actions: {
10
+ goToNextSlide: () => void;
11
+ goToPreviousSlide: () => void;
12
+ goToSlide: (newValue: number) => void;
13
+ };
14
+ currentSlide: number;
15
+ images: TImages;
16
+ maxSlide: number;
17
+ };
18
+ type CarouselStoreApi<TImages extends ImagesType = ImagesType> = StoreApi<CarouselStore<TImages>>;
19
+ type CarouselProviderProps<TImages extends ImagesType = ImagesType> = {
20
+ children: React.ReactNode;
21
+ images: CarouselStore<TImages>["images"];
22
+ onSlideBtnClick?: () => void;
23
+ };
24
+ type CarouselContentProps = {
25
+ autoSlideInterval?: number;
26
+ children: React.ReactNode;
27
+ classNames?: {
28
+ base?: string;
29
+ scrollContainer?: string;
30
+ };
31
+ hasAutoSlide?: boolean;
32
+ shouldPauseOnHover?: boolean;
33
+ };
34
+ type CarouselButtonsProps = {
35
+ classNames?: {
36
+ base?: string;
37
+ defaultIcon?: string;
38
+ iconContainer?: string;
39
+ };
40
+ icon?: React.ReactElement;
41
+ variant: "next" | "prev";
42
+ };
43
+ type CarouselControlProps = {
44
+ classNames?: {
45
+ base?: string;
46
+ defaultIcon?: string;
47
+ iconContainer?: string;
48
+ };
49
+ icon?: {
50
+ icon?: React.ReactElement;
51
+ iconType: "nextIcon" | "prevIcon";
52
+ } | {
53
+ iconType?: null;
54
+ next?: React.ReactElement;
55
+ prev?: React.ReactElement;
56
+ };
57
+ };
58
+ type CarouselIndicatorProps = {
59
+ classNames?: {
60
+ activeBtn?: string;
61
+ base?: string;
62
+ button?: string;
63
+ };
64
+ currentIndex: number;
65
+ };
66
+ type BaseWrapperProps<TArrayItem> = Prettify<ForRenderProps<TArrayItem> & Partial<EachProp<TArrayItem>>>;
67
+ type CarouselWrapperProps<TArrayItem> = BaseWrapperProps<TArrayItem> & {
68
+ className?: string;
69
+ };
70
+ type OtherCarouselProps = {
71
+ children?: React.ReactNode;
72
+ className?: string;
73
+ style?: React.CSSProperties;
74
+ };
75
+
76
+ declare function CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>): react.JSX.Element;
77
+
78
+ declare function CarouselContent<TElement extends react.ElementType = "article">(props: PolymorphicProps<TElement, CarouselContentProps>): react.JSX.Element;
79
+ declare function CarouselButton(props: CarouselButtonsProps): react.JSX.Element;
80
+ declare function CarouselControls(props: CarouselControlProps): react.JSX.Element;
81
+ declare function CarouselItemWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): react.JSX.Element;
82
+ declare function CarouselItem({ children, className, ...restOfProps }: OtherCarouselProps): react.JSX.Element;
83
+ declare function CarouselCaption<TElement extends react.ElementType = "div">(props: PolymorphicProps<TElement, OtherCarouselProps>): react.JSX.Element;
84
+ declare function CarouselIndicatorWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): react.JSX.Element;
85
+ declare function CarouselIndicator(props: CarouselIndicatorProps): react.JSX.Element;
86
+
87
+ declare const Content: typeof CarouselContent;
88
+ declare const Controls: typeof CarouselControls;
89
+ declare const Button: typeof CarouselButton;
90
+ declare const Item: typeof CarouselItem;
91
+ declare const ItemWrapper: typeof CarouselItemWrapper;
92
+ declare const Caption: typeof CarouselCaption;
93
+ declare const Indicator: typeof CarouselIndicator;
94
+ declare const IndicatorWrapper: typeof CarouselIndicatorWrapper;
95
+
96
+ export { Button, Caption, CarouselButton, type CarouselButtonsProps, CarouselCaption, CarouselContent, type CarouselContentProps, type CarouselControlProps, CarouselControls, CarouselIndicator, type CarouselIndicatorProps, CarouselIndicatorWrapper, CarouselItem, CarouselItemWrapper, type CarouselProviderProps, type CarouselStore, type CarouselStoreApi, type CarouselWrapperProps, Content, Controls, type ImagesType, Indicator, IndicatorWrapper, Item, ItemWrapper, type OtherCarouselProps, CarouselContextProvider as Root };