@zayne-labs/ui-react 0.6.3 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/esm/{chunk-ENDWJXPF.js → chunk-L2SROZYQ.js} +2 -2
  2. package/dist/esm/{chunk-ENDWJXPF.js.map → chunk-L2SROZYQ.js.map} +1 -1
  3. package/dist/esm/common/await/index.js +37 -3
  4. package/dist/esm/common/await/index.js.map +1 -1
  5. package/dist/esm/common/show/index.d.ts +1 -1
  6. package/dist/esm/common/show/index.js +48 -2
  7. package/dist/esm/common/show/index.js.map +1 -1
  8. package/dist/esm/common/slot/index.js +1 -1
  9. package/dist/esm/common/suspense-with-boundary/index.js +11 -2
  10. package/dist/esm/common/suspense-with-boundary/index.js.map +1 -1
  11. package/dist/esm/common/switch/index.js +38 -2
  12. package/dist/esm/common/switch/index.js.map +1 -1
  13. package/dist/esm/common/teleport/index.js +28 -1
  14. package/dist/esm/common/teleport/index.js.map +1 -1
  15. package/dist/esm/ui/card/index.js +43 -4
  16. package/dist/esm/ui/card/index.js.map +1 -1
  17. package/dist/esm/ui/carousel/index.js +272 -4
  18. package/dist/esm/ui/carousel/index.js.map +1 -1
  19. package/dist/esm/ui/drag-scroll/index.js +117 -2
  20. package/dist/esm/ui/drag-scroll/index.js.map +1 -1
  21. package/dist/esm/ui/drop-zone/index.js +137 -2
  22. package/dist/esm/ui/drop-zone/index.js.map +1 -1
  23. package/dist/esm/ui/form/index.js +508 -12
  24. package/dist/esm/ui/form/index.js.map +1 -1
  25. package/package.json +6 -9
  26. package/dist/esm/chunk-CB2EZJYW.js +0 -31
  27. package/dist/esm/chunk-CB2EZJYW.js.map +0 -1
  28. package/dist/esm/chunk-CWUEUCR5.js +0 -3
  29. package/dist/esm/chunk-CWUEUCR5.js.map +0 -1
  30. package/dist/esm/chunk-E42DOTGX.js +0 -119
  31. package/dist/esm/chunk-E42DOTGX.js.map +0 -1
  32. package/dist/esm/chunk-EOI2VNGP.js +0 -39
  33. package/dist/esm/chunk-EOI2VNGP.js.map +0 -1
  34. package/dist/esm/chunk-FPCKBOJN.js +0 -50
  35. package/dist/esm/chunk-FPCKBOJN.js.map +0 -1
  36. package/dist/esm/chunk-GVL6BLX5.js +0 -274
  37. package/dist/esm/chunk-GVL6BLX5.js.map +0 -1
  38. package/dist/esm/chunk-IJUYDZCZ.js +0 -510
  39. package/dist/esm/chunk-IJUYDZCZ.js.map +0 -1
  40. package/dist/esm/chunk-NPIJ4XZP.js +0 -13
  41. package/dist/esm/chunk-NPIJ4XZP.js.map +0 -1
  42. package/dist/esm/chunk-PNYEIX7F.js +0 -3
  43. package/dist/esm/chunk-PNYEIX7F.js.map +0 -1
  44. package/dist/esm/chunk-PXYYL2LL.js +0 -45
  45. package/dist/esm/chunk-PXYYL2LL.js.map +0 -1
  46. package/dist/esm/chunk-RQZL6ZG6.js +0 -139
  47. package/dist/esm/chunk-RQZL6ZG6.js.map +0 -1
  48. package/dist/esm/chunk-SVQ4WBSO.js +0 -40
  49. package/dist/esm/chunk-SVQ4WBSO.js.map +0 -1
  50. package/dist/esm/common/index.d.ts +0 -12
  51. package/dist/esm/common/index.js +0 -12
  52. package/dist/esm/common/index.js.map +0 -1
  53. package/dist/esm/index.d.ts +0 -20
  54. package/dist/esm/index.js +0 -19
  55. package/dist/esm/index.js.map +0 -1
  56. package/dist/esm/ui/index.d.ts +0 -11
  57. package/dist/esm/ui/index.js +0 -19
  58. package/dist/esm/ui/index.js.map +0 -1
@@ -43,5 +43,5 @@ function SlotClone(props) {
43
43
  }
44
44
 
45
45
  export { Slot, Slottable };
46
- //# sourceMappingURL=chunk-ENDWJXPF.js.map
47
- //# sourceMappingURL=chunk-ENDWJXPF.js.map
46
+ //# sourceMappingURL=chunk-L2SROZYQ.js.map
47
+ //# sourceMappingURL=chunk-L2SROZYQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/common/slot/slot.tsx"],"names":[],"mappings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AA;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":"chunk-ENDWJXPF.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\tif (Children.count(newElement) > 1) {\n\t\t\treturn Children.only(null);\n\t\t}\n\n\t\tconst newElementChildren = childrenArray.map((child) => {\n\t\t\tif (child === slottable) {\n\t\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\t\treturn isValidElement<SlotProps>(newElement) && newElement.props.children;\n\t\t\t}\n\n\t\t\treturn child;\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"]}
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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I,IAAI,QAAS,CAAA,IAAA,CAAK,IAAI,CAAI,GAAA,IAAA;AAAA;AAG7D,EAAA,MAAM,QAAY,GAAA,QAAA,CAAS,KAAM,CAAA,GAAA,IAC5B,QAAqC,CAAA,GAAA;AAE1C,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,QAAQ,CAAC,CAAI,GAAA;AAAA,GAC7D;AAEA,EAAO,OAAA,YAAA,CAAa,UAAU,WAAW,CAAA;AAC1C","file":"chunk-L2SROZYQ.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\tif (Children.count(newElement) > 1) {\n\t\t\treturn Children.only(null);\n\t\t}\n\n\t\tconst newElementChildren = childrenArray.map((child) => {\n\t\t\tif (child === slottable) {\n\t\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\t\treturn isValidElement<SlotProps>(newElement) && newElement.props.children;\n\t\t\t}\n\n\t\t\treturn child;\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\n\t\t?? (children as unknown as UnknownProps).ref) as React.Ref<HTMLElement>;\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, children.props),\n\t\tref: forwardedRef ? composeRefs([forwardedRef, childRef]) : childRef,\n\t};\n\n\treturn cloneElement(children, clonedProps);\n}\n"]}
@@ -1,6 +1,40 @@
1
- export { Await } from '../../chunk-EOI2VNGP.js';
2
- import '../../chunk-OM4ZFFQS.js';
3
- import '../../chunk-ENDWJXPF.js';
1
+ import { Slot } from '../../chunk-L2SROZYQ.js';
2
+ import { ErrorBoundary } from '../../chunk-OM4ZFFQS.js';
4
3
  import '../../chunk-PZ5AY32C.js';
4
+ import * as React from 'react';
5
+ import { Fragment, Suspense, use } from 'react';
6
+
7
+ function Await(props) {
8
+ const { errorFallback, fallback, wrapperVariant = "suspense-and-boundary", ...restOfProps } = props;
9
+ const WithErrorBoundary = wrapperVariant === "only-boundary" || wrapperVariant === "suspense-and-boundary" ? ErrorBoundary : Fragment;
10
+ const WithSuspense = wrapperVariant === "only-suspense" || wrapperVariant === "suspense-and-boundary" ? Suspense : Fragment;
11
+ const errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };
12
+ const suspenseProps = Boolean(fallback) && { fallback };
13
+ return /* @__PURE__ */ React.createElement(WithErrorBoundary, { ...errorBoundaryProps }, /* @__PURE__ */ React.createElement(WithSuspense, { ...suspenseProps }, /* @__PURE__ */ React.createElement(AwaitInner, { ...restOfProps })));
14
+ }
15
+ function AwaitInner(props) {
16
+ const { asChild, children, promise, render } = props;
17
+ const result = use(promise);
18
+ const Component = asChild ? Slot : Fragment;
19
+ const componentProps = asChild && { promise };
20
+ let resolvedChildren;
21
+ switch (true) {
22
+ case typeof children === "function": {
23
+ resolvedChildren = children(result);
24
+ break;
25
+ }
26
+ case typeof render === "function": {
27
+ resolvedChildren = render(result);
28
+ break;
29
+ }
30
+ default: {
31
+ resolvedChildren = children ?? render;
32
+ break;
33
+ }
34
+ }
35
+ return /* @__PURE__ */ React.createElement(Component, { ...componentProps }, resolvedChildren);
36
+ }
37
+
38
+ export { Await };
5
39
  //# sourceMappingURL=index.js.map
6
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/common/await/await.tsx"],"names":["ReactFragment"],"mappings":";;;;;;AAkBO,SAAS,MAAc,KAA2B,EAAA;AACxD,EAAA,MAAM,EAAE,aAAe,EAAA,QAAA,EAAU,iBAAiB,uBAAyB,EAAA,GAAG,aAAgB,GAAA,KAAA;AAE9F,EAAA,MAAM,iBACL,GAAA,cAAA,KAAmB,eAAmB,IAAA,cAAA,KAAmB,0BACtD,aACA,GAAAA,QAAA;AAEJ,EAAA,MAAM,YACL,GAAA,cAAA,KAAmB,eAAmB,IAAA,cAAA,KAAmB,0BACtD,QACA,GAAAA,QAAA;AAEJ,EAAA,MAAM,qBAAqB,OAAQ,CAAA,aAAa,CAAK,IAAA,EAAE,UAAU,aAAc,EAAA;AAE/E,EAAA,MAAM,aAAgB,GAAA,OAAA,CAAQ,QAAQ,CAAA,IAAK,EAAE,QAAS,EAAA;AAEtD,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAmB,GAAG,kBAAA,EAAA,kBACrB,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAc,GAAG,aAAA,EAAA,kBAChB,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAY,GAAG,WAAA,EAAa,CAC9B,CACD,CAAA;AAEF;AAOA,SAAS,WAAmB,KAAgC,EAAA;AAC3D,EAAA,MAAM,EAAE,OAAA,EAAS,QAAU,EAAA,OAAA,EAAS,QAAW,GAAA,KAAA;AAE/C,EAAM,MAAA,MAAA,GAAS,IAAI,OAAO,CAAA;AAE1B,EAAM,MAAA,SAAA,GAAY,UAAU,IAAO,GAAAA,QAAA;AAEnC,EAAM,MAAA,cAAA,GAAiB,OAAW,IAAA,EAAE,OAAQ,EAAA;AAE5C,EAAI,IAAA,gBAAA;AAEJ,EAAA,QAAQ,IAAM;AAAA,IACb,KAAK,OAAO,QAAA,KAAa,UAAY,EAAA;AACpC,MAAA,gBAAA,GAAmB,SAAS,MAAM,CAAA;AAClC,MAAA;AAAA;AACD,IACA,KAAK,OAAO,MAAA,KAAW,UAAY,EAAA;AAClC,MAAA,gBAAA,GAAmB,OAAO,MAAM,CAAA;AAChC,MAAA;AAAA;AACD,IACA,SAAS;AACR,MAAA,gBAAA,GAAmB,QAAY,IAAA,MAAA;AAC/B,MAAA;AAAA;AACD;AAGD,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,cAAA,EAAA,EAAiB,gBAAiB,CAAA;AACzD","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport type { DiscriminatedRenderProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { Fragment as ReactFragment, Suspense, use } from \"react\";\nimport { ErrorBoundary } from \"../error-boundary\";\nimport { Slot } from \"../slot\";\nimport type { SuspenseWithBoundaryProps } from \"../suspense-with-boundary\";\n\ntype RenderPropFn<TValue> = (result: TValue) => React.ReactNode;\n\ntype AwaitProps<TValue> = AwaitInnerProps<TValue>\n\t& Pick<SuspenseWithBoundaryProps, \"errorFallback\" | \"fallback\"> & {\n\t\tasChild?: boolean;\n\t\twrapperVariant?: \"none\" | \"only-boundary\" | \"only-suspense\" | \"suspense-and-boundary\";\n\t};\n\nexport function Await<TValue>(props: AwaitProps<TValue>) {\n\tconst { errorFallback, fallback, wrapperVariant = \"suspense-and-boundary\", ...restOfProps } = props;\n\n\tconst WithErrorBoundary =\n\t\twrapperVariant === \"only-boundary\" || wrapperVariant === \"suspense-and-boundary\"\n\t\t\t? ErrorBoundary\n\t\t\t: ReactFragment;\n\n\tconst WithSuspense =\n\t\twrapperVariant === \"only-suspense\" || wrapperVariant === \"suspense-and-boundary\"\n\t\t\t? Suspense\n\t\t\t: ReactFragment;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<WithErrorBoundary {...errorBoundaryProps}>\n\t\t\t<WithSuspense {...suspenseProps}>\n\t\t\t\t<AwaitInner {...restOfProps} />\n\t\t\t</WithSuspense>\n\t\t</WithErrorBoundary>\n\t);\n}\n\nexport type AwaitInnerProps<TValue> = DiscriminatedRenderProps<React.ReactNode | RenderPropFn<TValue>> & {\n\tasChild?: boolean;\n\tpromise: Promise<TValue>;\n};\n\nfunction AwaitInner<TValue>(props: AwaitInnerProps<TValue>) {\n\tconst { asChild, children, promise, render } = props;\n\n\tconst result = use(promise);\n\n\tconst Component = asChild ? Slot : ReactFragment;\n\n\tconst componentProps = asChild && { promise };\n\n\tlet resolvedChildren: React.ReactNode;\n\n\tswitch (true) {\n\t\tcase typeof children === \"function\": {\n\t\t\tresolvedChildren = children(result);\n\t\t\tbreak;\n\t\t}\n\t\tcase typeof render === \"function\": {\n\t\t\tresolvedChildren = render(result);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tresolvedChildren = children ?? render;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn <Component {...componentProps}>{resolvedChildren}</Component>;\n}\n"]}
@@ -20,7 +20,7 @@ declare namespace ShowFallback {
20
20
  }
21
21
 
22
22
  declare namespace showParts {
23
- export { ShowContent as Content, ShowFallback as Fallback, ShowFallback as OtherWise, ShowRoot as Root };
23
+ export { ShowContent as Content, ShowFallback as Fallback, ShowFallback as Otherwise, ShowRoot as Root };
24
24
  }
25
25
 
26
26
  export { showParts as Show, ShowContent, ShowFallback, ShowRoot };
@@ -1,4 +1,50 @@
1
- export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot } from '../../chunk-FPCKBOJN.js';
2
- import '../../chunk-PZ5AY32C.js';
1
+ import { __export } from '../../chunk-PZ5AY32C.js';
2
+ import 'react';
3
+ import { getSingleSlot, getRegularChildren } from '@zayne-labs/toolkit-react/utils';
4
+ import { isFunction, AssertionError } from '@zayne-labs/toolkit-type-helpers';
5
+
6
+ function ShowRoot({ children, fallback, when }) {
7
+ if ((when == null || when === false) && !isFunction(children)) {
8
+ const fallBackSlot = getSingleSlot(children, ShowFallback, {
9
+ errorMessage: "Only one <Show.Fallback> or <Show.OtherWise> component is allowed",
10
+ throwOnMultipleSlotMatch: true
11
+ });
12
+ if (fallBackSlot && fallback) {
13
+ throw new AssertionError(`
14
+ The fallback prop and <Show.Fallback>/<Show.OtherWise> cannot be used at the same time.
15
+ `);
16
+ }
17
+ return fallBackSlot ?? fallback;
18
+ }
19
+ if (when == null || when === false) {
20
+ return fallback;
21
+ }
22
+ const resolvedChildren = isFunction(children) ? children(when) : children;
23
+ const contentSlot = getSingleSlot(resolvedChildren, ShowContent, {
24
+ errorMessage: "Only one <Show.Content> component is allowed",
25
+ throwOnMultipleSlotMatch: true
26
+ });
27
+ const regularChildren = getRegularChildren(resolvedChildren, [ShowFallback, ShowContent]);
28
+ return contentSlot ?? regularChildren;
29
+ }
30
+ function ShowContent({ children }) {
31
+ return children;
32
+ }
33
+ ShowContent.slotSymbol = Symbol("content");
34
+ function ShowFallback({ children }) {
35
+ return children;
36
+ }
37
+ ShowFallback.slotSymbol = Symbol("show-fallback");
38
+
39
+ // src/components/common/show/show-parts.ts
40
+ var show_parts_exports = {};
41
+ __export(show_parts_exports, {
42
+ Content: () => ShowContent,
43
+ Fallback: () => ShowFallback,
44
+ Otherwise: () => ShowFallback,
45
+ Root: () => ShowRoot
46
+ });
47
+
48
+ export { show_parts_exports as Show, ShowContent, ShowFallback, ShowRoot };
3
49
  //# sourceMappingURL=index.js.map
4
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/common/show/show.tsx","../../../../src/components/common/show/show-parts.ts"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAgB,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,MAA0B,EAAA;AAC/E,EAAA,IAAA,CAAK,QAAQ,IAAQ,IAAA,IAAA,KAAS,UAAU,CAAC,UAAA,CAAW,QAAQ,CAAG,EAAA;AAC9D,IAAM,MAAA,YAAA,GAAe,aAAc,CAAA,QAAA,EAAU,YAAc,EAAA;AAAA,MAC1D,YAAc,EAAA,mEAAA;AAAA,MACd,wBAA0B,EAAA;AAAA,KAC1B,CAAA;AAED,IAAA,IAAI,gBAAgB,QAAU,EAAA;AAC7B,MAAA,MAAM,IAAI,cAAe,CAAA;AAAA;AAAA,EAEzB,CAAA,CAAA;AAAA;AAGD,IAAA,OAAO,YAAgB,IAAA,QAAA;AAAA;AAGxB,EAAI,IAAA,IAAA,IAAQ,IAAQ,IAAA,IAAA,KAAS,KAAO,EAAA;AACnC,IAAO,OAAA,QAAA;AAAA;AAGR,EAAA,MAAM,mBAAmB,UAAW,CAAA,QAAQ,CAAI,GAAA,QAAA,CAAS,IAAI,CAAI,GAAA,QAAA;AAEjE,EAAM,MAAA,WAAA,GAAc,aAAc,CAAA,gBAAA,EAAkB,WAAa,EAAA;AAAA,IAChE,YAAc,EAAA,8CAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAA,MAAM,kBAAkB,kBAAmB,CAAA,gBAAA,EAAkB,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAExF,EAAA,OAAO,WAAe,IAAA,eAAA;AACvB;AAEO,SAAS,WAAA,CAAY,EAAE,QAAA,EAA2C,EAAA;AACxE,EAAO,OAAA,QAAA;AACR;AACA,WAAY,CAAA,UAAA,GAAa,OAAO,SAAS,CAAA;AAElC,SAAS,YAAA,CAAa,EAAE,QAAA,EAA2C,EAAA;AACzE,EAAO,OAAA,QAAA;AACR;AACA,YAAa,CAAA,UAAA,GAAa,OAAO,eAAe,CAAA;;;ACrDhD,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA,WAAA;AAAA,EAAA,QAAA,EAAA,MAAA,YAAA;AAAA,EAAA,SAAA,EAAA,MAAA,YAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { AssertionError, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ShowProps<TWhen> = {\n\tchildren: React.ReactNode | ((whenValue: TWhen) => React.ReactNode);\n\tfallback?: React.ReactNode;\n\twhen: false | TWhen | null | undefined;\n};\n\nexport function ShowRoot<TWhen>({ children, fallback, when }: ShowProps<TWhen>) {\n\tif ((when == null || when === false) && !isFunction(children)) {\n\t\tconst fallBackSlot = getSingleSlot(children, ShowFallback, {\n\t\t\terrorMessage: \"Only one <Show.Fallback> or <Show.OtherWise> component is allowed\",\n\t\t\tthrowOnMultipleSlotMatch: true,\n\t\t});\n\n\t\tif (fallBackSlot && fallback) {\n\t\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\t}\n\n\t\treturn fallBackSlot ?? fallback;\n\t}\n\n\tif (when == null || when === false) {\n\t\treturn fallback;\n\t}\n\n\tconst resolvedChildren = isFunction(children) ? children(when) : children;\n\n\tconst contentSlot = getSingleSlot(resolvedChildren, ShowContent, {\n\t\terrorMessage: \"Only one <Show.Content> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst regularChildren = getRegularChildren(resolvedChildren, [ShowFallback, ShowContent]);\n\n\treturn contentSlot ?? regularChildren;\n}\n\nexport function ShowContent({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nShowContent.slotSymbol = Symbol(\"content\");\n\nexport function ShowFallback({ children }: { children: React.ReactNode }) {\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"]}
@@ -1,4 +1,4 @@
1
- export { Slot, Slottable } from '../../chunk-ENDWJXPF.js';
1
+ export { Slot, Slottable } from '../../chunk-L2SROZYQ.js';
2
2
  import '../../chunk-PZ5AY32C.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,14 @@
1
- export { SuspenseWithBoundary } from '../../chunk-NPIJ4XZP.js';
2
- import '../../chunk-OM4ZFFQS.js';
1
+ import { ErrorBoundary } from '../../chunk-OM4ZFFQS.js';
3
2
  import '../../chunk-PZ5AY32C.js';
3
+ import { Suspense } from 'react';
4
+
5
+ function SuspenseWithBoundary(props) {
6
+ const { children, errorFallback, fallback } = props;
7
+ const errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };
8
+ const suspenseProps = Boolean(fallback) && { fallback };
9
+ return /* @__PURE__ */ React.createElement(ErrorBoundary, { ...errorBoundaryProps }, /* @__PURE__ */ React.createElement(Suspense, { ...suspenseProps }, children));
10
+ }
11
+
12
+ export { SuspenseWithBoundary };
4
13
  //# sourceMappingURL=index.js.map
5
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/common/suspense-with-boundary/suspense-with-boundary.tsx"],"names":[],"mappings":";;;;AASO,SAAS,qBAAqB,KAAkC,EAAA;AACtE,EAAA,MAAM,EAAE,QAAA,EAAU,aAAe,EAAA,QAAA,EAAa,GAAA,KAAA;AAE9C,EAAA,MAAM,qBAAqB,OAAQ,CAAA,aAAa,CAAK,IAAA,EAAE,UAAU,aAAc,EAAA;AAC/E,EAAA,MAAM,aAAgB,GAAA,OAAA,CAAQ,QAAQ,CAAA,IAAK,EAAE,QAAS,EAAA;AAEtD,EACC,uBAAA,KAAA,CAAA,aAAA,CAAC,iBAAe,GAAG,kBAAA,EAAA,sCACjB,QAAU,EAAA,EAAA,GAAG,aAAgB,EAAA,EAAA,QAAS,CACxC,CAAA;AAEF","file":"index.js","sourcesContent":["import { Suspense } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\nexport type SuspenseWithBoundaryProps = {\n\tchildren: React.ReactNode;\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function SuspenseWithBoundary(props: SuspenseWithBoundaryProps) {\n\tconst { children, errorFallback, fallback } = props;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<ErrorBoundary {...errorBoundaryProps}>\n\t\t\t<Suspense {...suspenseProps}>{children}</Suspense>\n\t\t</ErrorBoundary>\n\t);\n}\n"]}
@@ -1,4 +1,40 @@
1
- export { switch_parts_exports as Switch, SwitchDefault, SwitchMatch, SwitchRoot } from '../../chunk-SVQ4WBSO.js';
2
- import '../../chunk-PZ5AY32C.js';
1
+ import { __export } from '../../chunk-PZ5AY32C.js';
2
+ import 'react';
3
+ import { getSingleSlot, getRegularChildren } from '@zayne-labs/toolkit-react/utils';
4
+ import { isFunction } from '@zayne-labs/toolkit-type-helpers';
5
+
6
+ var defaultConditionSymbol = Symbol("condition-default");
7
+ function SwitchRoot(props) {
8
+ const { children, condition = defaultConditionSymbol } = props;
9
+ const defaultCase = getSingleSlot(children, SwitchDefault, {
10
+ errorMessage: "Only one <Switch.Default> component is allowed",
11
+ throwOnMultipleSlotMatch: true
12
+ });
13
+ const childrenCasesArray = getRegularChildren(children, SwitchDefault);
14
+ const matchedCase = childrenCasesArray.find(
15
+ (child) => condition === defaultConditionSymbol ? child.props.when : child.props.when === condition
16
+ );
17
+ return matchedCase ?? defaultCase;
18
+ }
19
+ function SwitchMatch({ children, when }) {
20
+ if (when == null || when === false) {
21
+ return null;
22
+ }
23
+ return isFunction(children) ? children(when) : children;
24
+ }
25
+ function SwitchDefault({ children }) {
26
+ return children;
27
+ }
28
+ SwitchDefault.slotSymbol = Symbol("switch-default");
29
+
30
+ // src/components/common/switch/switch-parts.ts
31
+ var switch_parts_exports = {};
32
+ __export(switch_parts_exports, {
33
+ Default: () => SwitchDefault,
34
+ Match: () => SwitchMatch,
35
+ Root: () => SwitchRoot
36
+ });
37
+
38
+ export { switch_parts_exports as Switch, SwitchDefault, SwitchMatch, SwitchRoot };
3
39
  //# sourceMappingURL=index.js.map
4
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/common/switch/switch.tsx","../../../../src/components/common/switch/switch-parts.ts"],"names":[],"mappings":";;;;;AAmBA,IAAM,sBAAA,GAAyB,OAAO,mBAAmB,CAAA;AAElD,SAAS,WAA8B,KAAgC,EAAA;AAC7E,EAAA,MAAM,EAAE,QAAA,EAAU,SAAY,GAAA,sBAAA,EAA2B,GAAA,KAAA;AAEzD,EAAM,MAAA,WAAA,GAAc,aAAc,CAAA,QAAA,EAAU,aAAe,EAAA;AAAA,IAC1D,YAAc,EAAA,gDAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,kBAAmB,CAAA,QAAA,EAAU,aAAa,CAAA;AAErE,EAAA,MAAM,cAAc,kBAAmB,CAAA,IAAA;AAAA,IAAK,CAAC,UAC5C,SAAc,KAAA,sBAAA,GAAyB,MAAM,KAAM,CAAA,IAAA,GAAO,KAAM,CAAA,KAAA,CAAM,IAAS,KAAA;AAAA,GAChF;AAEA,EAAA,OAAO,WAAe,IAAA,WAAA;AACvB;AAEO,SAAS,WAAmB,CAAA,EAAE,QAAU,EAAA,IAAA,EAAiC,EAAA;AAC/E,EAAI,IAAA,IAAA,IAAQ,IAAQ,IAAA,IAAA,KAAS,KAAO,EAAA;AACnC,IAAO,OAAA,IAAA;AAAA;AAGR,EAAA,OAAO,UAAW,CAAA,QAAQ,CAAI,GAAA,QAAA,CAAS,IAAI,CAAI,GAAA,QAAA;AAChD;AAEO,SAAS,aAAA,CAAc,EAAE,QAAA,EAA2C,EAAA;AAC1E,EAAO,OAAA,QAAA;AACR;AACA,aAAc,CAAA,UAAA,GAAa,OAAO,gBAAgB,CAAA;;;ACjDlD,IAAA,oBAAA,GAAA;AAAA,QAAA,CAAA,oBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA,aAAA;AAAA,EAAA,KAAA,EAAA,MAAA,WAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps>;\n\ntype SwitchProps<TCondition> = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tcondition?: TCondition;\n};\n\ntype SwitchMatchProps<TWhen = unknown> = {\n\tchildren: React.ReactNode | ((whenValue: TWhen) => React.ReactNode);\n\twhen: false | TWhen | null | undefined;\n};\n\nconst defaultConditionSymbol = Symbol(\"condition-default\");\n\nexport function SwitchRoot<TCondition = true>(props: SwitchProps<TCondition>) {\n\tconst { children, condition = defaultConditionSymbol } = props;\n\n\tconst defaultCase = getSingleSlot(children, SwitchDefault, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getRegularChildren(children, SwitchDefault);\n\n\tconst matchedCase = childrenCasesArray.find((child) =>\n\t\tcondition === defaultConditionSymbol ? child.props.when : child.props.when === condition\n\t);\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport function SwitchMatch<TWhen>({ children, when }: SwitchMatchProps<TWhen>) {\n\tif (when == null || when === false) {\n\t\treturn null;\n\t}\n\n\treturn isFunction(children) ? children(when) : children;\n}\n\nexport function SwitchDefault({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nSwitchDefault.slotSymbol = Symbol(\"switch-default\");\n","export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root } from \"./switch\";\n"]}
@@ -1,4 +1,31 @@
1
- export { Teleport } from '../../chunk-CB2EZJYW.js';
2
1
  import '../../chunk-PZ5AY32C.js';
2
+ import { useState } from 'react';
3
+ import { useEffectOnce, useMountEffect } from '@zayne-labs/toolkit-react';
4
+ import { isString } from '@zayne-labs/toolkit-type-helpers';
5
+ import { createPortal } from 'react-dom';
6
+
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 };
3
30
  //# sourceMappingURL=index.js.map
4
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
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"]}
@@ -1,6 +1,45 @@
1
- export { card_parts_exports as Card, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle } from '../../chunk-PXYYL2LL.js';
2
- import '../../chunk-OHG7GB7O.js';
3
- import '../../chunk-ENDWJXPF.js';
4
- import '../../chunk-PZ5AY32C.js';
1
+ import { cnMerge } from '../../chunk-OHG7GB7O.js';
2
+ import { Slot } from '../../chunk-L2SROZYQ.js';
3
+ import { __export } from '../../chunk-PZ5AY32C.js';
4
+ import * as React from 'react';
5
+
6
+ function CardRoot(props) {
7
+ const { as: Element = "article", ...restOfProps } = props;
8
+ return /* @__PURE__ */ React.createElement(Element, { ...restOfProps });
9
+ }
10
+ function CardHeader(props) {
11
+ const { as: Element = "header", ...restOfProps } = props;
12
+ return /* @__PURE__ */ React.createElement(Element, { ...restOfProps });
13
+ }
14
+ function CardTitle(props) {
15
+ const { as: Element = "h3", className, ...restOfProps } = props;
16
+ return /* @__PURE__ */ React.createElement(Element, { className: cnMerge("font-semibold", className), ...restOfProps });
17
+ }
18
+ function CardDescription(props) {
19
+ const { as: Element = "p", className, ...restOfProps } = props;
20
+ return /* @__PURE__ */ React.createElement(Element, { className: cnMerge("text-sm text-shadcn-muted-foreground", className), ...restOfProps });
21
+ }
22
+ function CardContent(props) {
23
+ const { as: Element = "div", ...restOfProps } = props;
24
+ return /* @__PURE__ */ React.createElement(Element, { ...restOfProps });
25
+ }
26
+ function CardFooter(props) {
27
+ const { as: Element = "footer", asChild, ...restOfProps } = props;
28
+ const Component = asChild ? Slot : Element;
29
+ return /* @__PURE__ */ React.createElement(Component, { ...restOfProps });
30
+ }
31
+
32
+ // src/components/ui/card/card-parts.ts
33
+ var card_parts_exports = {};
34
+ __export(card_parts_exports, {
35
+ Content: () => CardContent,
36
+ Description: () => CardDescription,
37
+ Footer: () => CardFooter,
38
+ Header: () => CardHeader,
39
+ Root: () => CardRoot,
40
+ Title: () => CardTitle
41
+ });
42
+
43
+ export { card_parts_exports as Card, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle };
5
44
  //# sourceMappingURL=index.js.map
6
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/ui/card/card.tsx","../../../../src/components/ui/card/card-parts.ts"],"names":[],"mappings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AgB,GAAA,KAAA;AAE5D,EAAM,MAAA,SAAA,GAAY,UAAU,IAAO,GAAA,OAAA;AAEnC,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AACpC;;;ACtDA,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA,WAAA;AAAA,EAAA,WAAA,EAAA,MAAA,eAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,IAAA,EAAA,MAAA,QAAA;AAAA,EAAA,KAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\n\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\n\nexport function CardRoot<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"article\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardHeader<TElement extends React.ElementType = \"header\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"header\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardTitle<TElement extends React.ElementType = \"h3\">(props: PolymorphicProps<TElement>) {\n\tconst { as: Element = \"h3\", className, ...restOfProps } = props;\n\n\treturn <Element className={cnMerge(\"font-semibold\", className)} {...restOfProps} />;\n}\n\nexport function CardDescription<TElement extends React.ElementType = \"p\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"p\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element className={cnMerge(\"text-sm text-shadcn-muted-foreground\", className)} {...restOfProps} />\n\t);\n}\n\nexport function CardContent<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"div\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardFooter<TElement extends React.ElementType = \"footer\">(\n\tprops: PolymorphicProps<TElement, { asChild?: boolean }>\n) {\n\tconst { as: Element = \"footer\", asChild, ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot : Element;\n\n\treturn <Component {...restOfProps} />;\n}\n","export {\n\tCardContent as Content,\n\tCardDescription as Description,\n\tCardFooter as Footer,\n\tCardHeader as Header,\n\tCardRoot as Root,\n\tCardTitle as Title,\n} from \"./card\";\n"]}
@@ -1,6 +1,274 @@
1
- export { carousel_parts_exports as Carousel, CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator, CarouselIndicatorGroup, CarouselItem, CarouselItemGroup } from '../../chunk-GVL6BLX5.js';
2
- import '../../chunk-OHG7GB7O.js';
3
- import '../../chunk-DW3FXTFL.js';
4
- import '../../chunk-PZ5AY32C.js';
1
+ import { cnMerge } from '../../chunk-OHG7GB7O.js';
2
+ import { getElementList } from '../../chunk-DW3FXTFL.js';
3
+ import { __export } from '../../chunk-PZ5AY32C.js';
4
+ import * as React3 from 'react';
5
+ import { useEffect, useState } from 'react';
6
+ import { useConstant, useAnimationInterval, useCallbackRef } from '@zayne-labs/toolkit-react';
7
+ import { createZustandContext } from '@zayne-labs/toolkit-react/zustand';
8
+ import { create } from 'zustand';
9
+
10
+ var ChevronLeftIcon = (props) => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React3.createElement("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" }, /* @__PURE__ */ React3.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React3.createElement("path", { d: "m14 16l-4-4l4-4" })));
11
+ var [Provider, useCarouselStoreContext] = createZustandContext({
12
+ hookName: "useCarouselStore",
13
+ name: "CarouselStoreContext",
14
+ providerName: "CarouselContextProvider"
15
+ });
16
+ var createCarouselStore = (storeValues) => {
17
+ const { images, onSlideBtnClick } = storeValues;
18
+ const useInitCarouselStore = create()((set, get) => ({
19
+ currentSlide: 0,
20
+ images,
21
+ maxSlide: images.length - 1,
22
+ /* eslint-disable perfectionist/sort-objects -- actions should be last */
23
+ actions: {
24
+ /* eslint-enable perfectionist/sort-objects -- actions should be last */
25
+ goToNextSlide: () => {
26
+ const { currentSlide, maxSlide } = get();
27
+ const { goToSlide } = get().actions;
28
+ if (currentSlide === maxSlide) {
29
+ goToSlide(0);
30
+ return;
31
+ }
32
+ goToSlide(currentSlide + 1);
33
+ },
34
+ goToPreviousSlide: () => {
35
+ const { currentSlide, maxSlide } = get();
36
+ const { goToSlide } = get().actions;
37
+ if (currentSlide === 0) {
38
+ goToSlide(maxSlide);
39
+ return;
40
+ }
41
+ goToSlide(currentSlide - 1);
42
+ },
43
+ goToSlide: (newValue) => {
44
+ onSlideBtnClick?.();
45
+ set({ currentSlide: newValue });
46
+ }
47
+ }
48
+ }));
49
+ return useInitCarouselStore;
50
+ };
51
+ var useCarousel = (props) => {
52
+ const { images, onSlideBtnClick } = props;
53
+ const useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));
54
+ useEffect(() => {
55
+ useInitCarouselStore.setState({ images });
56
+ }, [images]);
57
+ return useInitCarouselStore;
58
+ };
59
+ function CarouselContextProvider(props) {
60
+ const { children, images, onSlideBtnClick } = props;
61
+ const useInitCarouselStore = useCarousel({ images, onSlideBtnClick });
62
+ return /* @__PURE__ */ React3.createElement(Provider, { value: useInitCarouselStore }, children);
63
+ }
64
+ var useCarouselOptions = (options = {}) => {
65
+ const { autoSlideInterval = 5e3, hasAutoSlide = false, shouldPauseOnHover = false } = options;
66
+ const { goToNextSlide } = useCarouselStoreContext((state) => state.actions);
67
+ const [isPaused, setIsPaused] = useState(false);
68
+ const shouldAutoSlide = hasAutoSlide && !isPaused;
69
+ useAnimationInterval({
70
+ intervalDuration: shouldAutoSlide ? autoSlideInterval : null,
71
+ onAnimation: goToNextSlide
72
+ });
73
+ const pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));
74
+ const resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));
75
+ return { pauseAutoSlide, resumeAutoSlide };
76
+ };
77
+
78
+ // src/components/ui/carousel/carousel.tsx
79
+ function CarouselContent(props) {
80
+ const {
81
+ as: HtmlElement = "article",
82
+ autoSlideInterval,
83
+ children,
84
+ classNames,
85
+ hasAutoSlide,
86
+ shouldPauseOnHover
87
+ } = props;
88
+ const { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({
89
+ autoSlideInterval,
90
+ hasAutoSlide,
91
+ shouldPauseOnHover
92
+ });
93
+ return /* @__PURE__ */ React3.createElement(
94
+ HtmlElement,
95
+ {
96
+ "data-id": "Carousel",
97
+ className: cnMerge("relative select-none", classNames?.base),
98
+ onMouseEnter: pauseAutoSlide,
99
+ onMouseLeave: resumeAutoSlide
100
+ },
101
+ /* @__PURE__ */ React3.createElement(
102
+ "div",
103
+ {
104
+ "data-id": "Scroll Container",
105
+ className: cnMerge(
106
+ "flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
107
+ classNames?.scrollContainer
108
+ )
109
+ },
110
+ children
111
+ )
112
+ );
113
+ }
114
+ function CarouselButton(props) {
115
+ const { classNames, icon, variant } = props;
116
+ const { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);
117
+ return /* @__PURE__ */ React3.createElement(
118
+ "button",
119
+ {
120
+ type: "button",
121
+ className: cnMerge(
122
+ "z-30 flex h-full w-[15%] items-center",
123
+ variant === "prev" ? "justify-start" : "justify-end",
124
+ classNames?.base
125
+ ),
126
+ onClick: variant === "prev" ? goToPreviousSlide : goToNextSlide
127
+ },
128
+ /* @__PURE__ */ React3.createElement("span", { className: cnMerge("transition-transform active:scale-[1.06]", classNames?.iconContainer) }, icon ?? /* @__PURE__ */ React3.createElement(
129
+ ChevronLeftIcon,
130
+ {
131
+ className: cnMerge(variant === "next" && "rotate-180", classNames?.defaultIcon)
132
+ }
133
+ ))
134
+ );
135
+ }
136
+ function CarouselControls(props) {
137
+ const { classNames, icon } = props;
138
+ return /* @__PURE__ */ React3.createElement("div", { className: cnMerge("absolute inset-0 flex justify-between", classNames?.base) }, icon?.iconType ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
139
+ CarouselButton,
140
+ {
141
+ variant: "prev",
142
+ classNames: {
143
+ defaultIcon: classNames?.defaultIcon,
144
+ iconContainer: cnMerge(
145
+ icon.iconType === "nextIcon" && "rotate-180",
146
+ classNames?.iconContainer
147
+ )
148
+ },
149
+ icon: icon.icon
150
+ }
151
+ ), /* @__PURE__ */ React3.createElement(
152
+ CarouselButton,
153
+ {
154
+ variant: "next",
155
+ classNames: {
156
+ defaultIcon: classNames?.defaultIcon,
157
+ iconContainer: cnMerge(
158
+ icon.iconType === "prevIcon" && "rotate-180",
159
+ classNames?.iconContainer
160
+ )
161
+ },
162
+ icon: icon.icon
163
+ }
164
+ )) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
165
+ CarouselButton,
166
+ {
167
+ variant: "prev",
168
+ classNames: {
169
+ defaultIcon: classNames?.defaultIcon,
170
+ iconContainer: classNames?.iconContainer
171
+ },
172
+ icon: icon?.prev
173
+ }
174
+ ), /* @__PURE__ */ React3.createElement(
175
+ CarouselButton,
176
+ {
177
+ variant: "next",
178
+ classNames: {
179
+ defaultIcon: classNames?.defaultIcon,
180
+ iconContainer: classNames?.iconContainer
181
+ },
182
+ icon: icon?.next
183
+ }
184
+ )));
185
+ }
186
+ function CarouselItemGroup(props) {
187
+ const { children, className, each, render } = props;
188
+ const [ItemList] = getElementList("base");
189
+ const currentSlide = useCarouselStoreContext((state) => state.currentSlide);
190
+ const images = useCarouselStoreContext((state) => each ?? state.images);
191
+ return /* @__PURE__ */ React3.createElement(
192
+ "ul",
193
+ {
194
+ "data-id": "Carousel Image Wrapper",
195
+ className: cnMerge(
196
+ `flex w-full shrink-0 [transform:translate3d(var(--translate-distance),0,0)] snap-center
197
+ [transition:transform_800ms_ease]`,
198
+ className
199
+ ),
200
+ style: {
201
+ "--translate-distance": `-${currentSlide * 100}%`
202
+ }
203
+ },
204
+ typeof render === "function" ? /* @__PURE__ */ React3.createElement(ItemList, { each: images, render }) : /* @__PURE__ */ React3.createElement(ItemList, { each: images }, children)
205
+ );
206
+ }
207
+ function CarouselItem({ children, className, ...restOfProps }) {
208
+ return /* @__PURE__ */ React3.createElement(
209
+ "li",
210
+ {
211
+ className: cnMerge("flex w-full shrink-0 snap-center justify-center", className),
212
+ ...restOfProps
213
+ },
214
+ children
215
+ );
216
+ }
217
+ function CarouselCaption(props) {
218
+ const { as: HtmlElement = "div", children, className } = props;
219
+ return /* @__PURE__ */ React3.createElement(HtmlElement, { "data-id": "Carousel Caption", className: cnMerge("absolute z-10", className) }, children);
220
+ }
221
+ function CarouselIndicatorGroup(props) {
222
+ const { children, className, each, render } = props;
223
+ const images = useCarouselStoreContext((state) => each ?? state.images);
224
+ const [IndicatorList] = getElementList("base");
225
+ return /* @__PURE__ */ React3.createElement(
226
+ "ul",
227
+ {
228
+ "data-id": "Carousel Indicators",
229
+ className: cnMerge(
230
+ "absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6",
231
+ className
232
+ )
233
+ },
234
+ typeof render === "function" ? /* @__PURE__ */ React3.createElement(IndicatorList, { each: images, render }) : /* @__PURE__ */ React3.createElement(IndicatorList, { each: images }, children)
235
+ );
236
+ }
237
+ function CarouselIndicator(props) {
238
+ const { classNames, currentIndex } = props;
239
+ const {
240
+ actions: { goToSlide },
241
+ currentSlide
242
+ } = useCarouselStoreContext((state) => state);
243
+ return /* @__PURE__ */ React3.createElement("li", { className: cnMerge("inline-flex", classNames?.base) }, /* @__PURE__ */ React3.createElement(
244
+ "button",
245
+ {
246
+ "data-active": currentIndex === currentSlide,
247
+ type: "button",
248
+ onClick: () => goToSlide(currentIndex),
249
+ className: cnMerge(
250
+ "size-[6px] rounded-[50%]",
251
+ classNames?.button,
252
+ currentIndex === currentSlide && ["w-14 rounded-lg", classNames?.activeBtn]
253
+ )
254
+ }
255
+ ));
256
+ }
257
+
258
+ // src/components/ui/carousel/carousel-parts.ts
259
+ var carousel_parts_exports = {};
260
+ __export(carousel_parts_exports, {
261
+ Button: () => CarouselButton,
262
+ Caption: () => CarouselCaption,
263
+ Content: () => CarouselContent,
264
+ Controls: () => CarouselControls,
265
+ Indicator: () => CarouselIndicator,
266
+ IndicatorWrapper: () => CarouselIndicatorGroup,
267
+ Item: () => CarouselItem,
268
+ ItemWrapper: () => CarouselItemGroup,
269
+ Root: () => CarouselContextProvider
270
+ });
271
+
272
+ export { carousel_parts_exports as Carousel, CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator, CarouselIndicatorGroup, CarouselItem, CarouselItemGroup };
5
273
  //# sourceMappingURL=index.js.map
6
274
  //# sourceMappingURL=index.js.map