@zayne-labs/ui-react 0.10.4 → 0.10.6

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 (122) hide show
  1. package/css/animation.css +47 -0
  2. package/css/theme.css +10 -4
  3. package/dist/esm/{await-fjas2Q-C.js → await-Da5w2vIc.js} +14 -15
  4. package/dist/esm/await-Da5w2vIc.js.map +1 -0
  5. package/dist/esm/{card-TD60Xux0.js → card-gWNDcZV0.js} +8 -9
  6. package/dist/esm/card-gWNDcZV0.js.map +1 -0
  7. package/dist/esm/{carousel-YXXtZ85s.js → carousel-BY9RvR71.js} +20 -23
  8. package/dist/esm/carousel-BY9RvR71.js.map +1 -0
  9. package/dist/esm/{chunk-Cl8Af3a2.js → chunk-CTAAG5j7.js} +3 -1
  10. package/dist/esm/{cn-_FbtIrlZ.js → cn-s-D7vHW1.js} +1 -1
  11. package/dist/esm/{cn-_FbtIrlZ.js.map → cn-s-D7vHW1.js.map} +1 -1
  12. package/dist/esm/common/await/index.d.ts +4 -0
  13. package/dist/esm/common/await/index.js +8 -0
  14. package/dist/esm/common/client-gate/index.d.ts +33 -0
  15. package/dist/esm/common/client-gate/index.js +35 -0
  16. package/dist/esm/common/client-gate/index.js.map +1 -0
  17. package/dist/esm/{components/common → common}/error-boundary/index.d.ts +1 -1
  18. package/dist/esm/{components/common → common}/error-boundary/index.js +1 -1
  19. package/dist/esm/common/for/index.d.ts +2 -0
  20. package/dist/esm/common/for/index.js +3 -0
  21. package/dist/esm/common/index.d.ts +9 -0
  22. package/dist/esm/common/index.js +11 -0
  23. package/dist/esm/common/presence/index.d.ts +22 -0
  24. package/dist/esm/common/presence/index.js +6 -0
  25. package/dist/esm/{components/common → common}/show/index.d.ts +1 -1
  26. package/dist/esm/{components/common → common}/show/index.js +1 -2
  27. package/dist/esm/{components/common → common}/slot/index.d.ts +1 -1
  28. package/dist/esm/common/slot/index.js +3 -0
  29. package/dist/esm/common/suspense-with-boundary/index.d.ts +3 -0
  30. package/dist/esm/common/suspense-with-boundary/index.js +4 -0
  31. package/dist/esm/{components/common → common}/switch/index.d.ts +1 -1
  32. package/dist/esm/{components/common → common}/switch/index.js +1 -2
  33. package/dist/esm/common/teleport/index.d.ts +2 -0
  34. package/dist/esm/common/teleport/index.js +3 -0
  35. package/dist/esm/{drag-scroll-De6-soln.js → drag-scroll-Bb1SG4On.js} +9 -12
  36. package/dist/esm/{drag-scroll-De6-soln.js.map → drag-scroll-Bb1SG4On.js.map} +1 -1
  37. package/dist/esm/drop-zone-5dDyxv_f.js +987 -0
  38. package/dist/esm/drop-zone-5dDyxv_f.js.map +1 -0
  39. package/dist/esm/{error-boundary-xM9An3gz.js → error-boundary-y9Samt_s.js} +1 -1
  40. package/dist/esm/error-boundary-y9Samt_s.js.map +1 -0
  41. package/dist/esm/{for-DGs2XZ21.js → for-Dfh7e9Z4.js} +2 -3
  42. package/dist/esm/{for-DGs2XZ21.js.map → for-Dfh7e9Z4.js.map} +1 -1
  43. package/dist/esm/{form-BHfmbX32.js → form-DDSlHq5t.js} +61 -73
  44. package/dist/esm/form-DDSlHq5t.js.map +1 -0
  45. package/dist/esm/{index-BBJzo-WC.d.ts → index-B53RIFft.d.ts} +4 -3
  46. package/dist/esm/index-BBHGVe_0.d.ts +336 -0
  47. package/dist/esm/{index-CnvH74ea.d.ts → index-Bra0UlL_.d.ts} +4 -3
  48. package/dist/esm/{index-DVr1tbxh.d.ts → index-BsGxDKlt.d.ts} +10 -9
  49. package/dist/esm/{index-BYhH4Fm0.d.ts → index-C1GPFYKG.d.ts} +1 -1
  50. package/dist/esm/{index-lKxE9WPi.d.ts → index-CJLZEhIo.d.ts} +4 -2
  51. package/dist/esm/{index-CWKQ5V4B.d.ts → index-CZjeBSoQ.d.ts} +1 -1
  52. package/dist/esm/{index-DJjxpXUk.d.ts → index-CffEFE66.d.ts} +1 -1
  53. package/dist/esm/{index-BaONHZq0.d.ts → index-CvjRPnhb.d.ts} +13 -16
  54. package/dist/esm/{index-eCX5RJ41.d.ts → index-D259PHNG.d.ts} +5 -4
  55. package/dist/esm/{index-DqutTJQB.d.ts → index-DoRAzdDN.d.ts} +13 -12
  56. package/dist/esm/{index-BeDmH7lX.d.ts → index-GHA8HNcd.d.ts} +10 -9
  57. package/dist/esm/{index-CMwCQ8qR.d.ts → index-RnqeaSJm.d.ts} +22 -21
  58. package/dist/esm/presence-CRZsP1Jk.js +156 -0
  59. package/dist/esm/presence-CRZsP1Jk.js.map +1 -0
  60. package/dist/esm/{show-BabiXbf7.js → show-N1ZXBhoA.js} +18 -9
  61. package/dist/esm/show-N1ZXBhoA.js.map +1 -0
  62. package/dist/esm/{slot-D1062oA5.js → slot-WVWfOlr3.js} +5 -6
  63. package/dist/esm/{slot-D1062oA5.js.map → slot-WVWfOlr3.js.map} +1 -1
  64. package/dist/esm/{suspense-with-boundary-CEVORL8K.js → suspense-with-boundary-D-1NYDV4.js} +2 -2
  65. package/dist/esm/suspense-with-boundary-D-1NYDV4.js.map +1 -0
  66. package/dist/esm/{switch-CCMD01Rs.js → switch-Ch22z21e.js} +7 -11
  67. package/dist/esm/switch-Ch22z21e.js.map +1 -0
  68. package/dist/esm/{teleport-DfuYOzsj.js → teleport-C8TzRm4M.js} +1 -1
  69. package/dist/esm/teleport-C8TzRm4M.js.map +1 -0
  70. package/dist/esm/{components/ui → ui}/card/index.d.ts +1 -1
  71. package/dist/esm/{components/ui → ui}/card/index.js +3 -3
  72. package/dist/esm/ui/carousel/index.d.ts +2 -0
  73. package/dist/esm/ui/carousel/index.js +16 -0
  74. package/dist/esm/ui/drag-scroll/index.d.ts +2 -0
  75. package/dist/esm/ui/drag-scroll/index.js +4 -0
  76. package/dist/esm/ui/drop-zone/index.d.ts +2 -0
  77. package/dist/esm/ui/drop-zone/index.js +17 -0
  78. package/dist/esm/{components/ui → ui}/form/index.d.ts +1 -1
  79. package/dist/esm/{components/ui → ui}/form/index.js +4 -5
  80. package/dist/esm/ui/index.d.ts +6 -0
  81. package/dist/esm/ui/index.js +18 -0
  82. package/dist/style.css +385 -25
  83. package/package.json +20 -17
  84. package/dist/esm/await-fjas2Q-C.js.map +0 -1
  85. package/dist/esm/card-TD60Xux0.js.map +0 -1
  86. package/dist/esm/carousel-YXXtZ85s.js.map +0 -1
  87. package/dist/esm/components/common/await/index.d.ts +0 -5
  88. package/dist/esm/components/common/await/index.js +0 -10
  89. package/dist/esm/components/common/for/index.d.ts +0 -2
  90. package/dist/esm/components/common/for/index.js +0 -3
  91. package/dist/esm/components/common/index.d.ts +0 -10
  92. package/dist/esm/components/common/index.js +0 -13
  93. package/dist/esm/components/common/slot/index.js +0 -3
  94. package/dist/esm/components/common/suspense-with-boundary/index.d.ts +0 -3
  95. package/dist/esm/components/common/suspense-with-boundary/index.js +0 -4
  96. package/dist/esm/components/common/teleport/index.d.ts +0 -2
  97. package/dist/esm/components/common/teleport/index.js +0 -3
  98. package/dist/esm/components/ui/carousel/index.d.ts +0 -2
  99. package/dist/esm/components/ui/carousel/index.js +0 -18
  100. package/dist/esm/components/ui/drag-scroll/index.d.ts +0 -2
  101. package/dist/esm/components/ui/drag-scroll/index.js +0 -4
  102. package/dist/esm/components/ui/drop-zone/index.d.ts +0 -2
  103. package/dist/esm/components/ui/drop-zone/index.js +0 -18
  104. package/dist/esm/components/ui/index.d.ts +0 -6
  105. package/dist/esm/components/ui/index.js +0 -19
  106. package/dist/esm/drop-zone-BPfSu99L.js +0 -381
  107. package/dist/esm/drop-zone-BPfSu99L.js.map +0 -1
  108. package/dist/esm/error-boundary-xM9An3gz.js.map +0 -1
  109. package/dist/esm/form-BHfmbX32.js.map +0 -1
  110. package/dist/esm/getSlot-Cf5ON6lE.js +0 -85
  111. package/dist/esm/getSlot-Cf5ON6lE.js.map +0 -1
  112. package/dist/esm/index-BNrCAe9Y.d.ts +0 -142
  113. package/dist/esm/index-D361IX3V.d.ts +0 -183
  114. package/dist/esm/lib/utils/index.d.ts +0 -2
  115. package/dist/esm/lib/utils/index.js +0 -4
  116. package/dist/esm/show-BabiXbf7.js.map +0 -1
  117. package/dist/esm/suspense-with-boundary-CEVORL8K.js.map +0 -1
  118. package/dist/esm/switch-CCMD01Rs.js.map +0 -1
  119. package/dist/esm/teleport-DfuYOzsj.js.map +0 -1
  120. package/dist/esm/utils-ChjmDoRe.js +0 -89
  121. package/dist/esm/utils-ChjmDoRe.js.map +0 -1
  122. /package/dist/esm/{common-BYWy8Q78.js → common-PS3X58Pj.js} +0 -0
@@ -1,5 +1,6 @@
1
- import { ErrorBoundaryProps } from "./index-lKxE9WPi.js";
2
- import * as react0 from "react";
1
+ import { ErrorBoundaryProps } from "./index-CJLZEhIo.js";
2
+ import * as React from "react";
3
+ import * as react_jsx_runtime18 from "react/jsx-runtime";
3
4
 
4
5
  //#region src/components/common/suspense-with-boundary/suspense-with-boundary.d.ts
5
6
  type SuspenseWithBoundaryProps = {
@@ -7,7 +8,7 @@ type SuspenseWithBoundaryProps = {
7
8
  errorFallback?: ErrorBoundaryProps["fallback"];
8
9
  fallback?: React.ReactNode;
9
10
  };
10
- declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react0.JSX.Element;
11
+ declare function SuspenseWithBoundary(props: SuspenseWithBoundaryProps): react_jsx_runtime18.JSX.Element;
11
12
  //#endregion
12
13
  export { SuspenseWithBoundary, SuspenseWithBoundaryProps };
13
- //# sourceMappingURL=index-eCX5RJ41.d.ts.map
14
+ //# sourceMappingURL=index-D259PHNG.d.ts.map
@@ -1,7 +1,8 @@
1
+ import { PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
1
2
  import { UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
2
3
  import * as React$1 from "react";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
5
  import { StoreApi } from "@zayne-labs/toolkit-core";
4
- import { PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
5
6
 
6
7
  //#region src/components/ui/carousel/types.d.ts
7
8
  type ImagesType = Array<Record<string, string>> | string[];
@@ -78,17 +79,17 @@ type OtherCarouselProps = {
78
79
  };
79
80
  //#endregion
80
81
  //#region src/components/ui/carousel/carousel.d.ts
81
- declare function CarouselRoot<TImages extends ImagesType, TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, CarouselRootProps<TImages>>): React$1.JSX.Element;
82
- declare function CarouselButton(props: CarouselButtonsProps): React$1.JSX.Element;
83
- declare function CarouselControls(props: CarouselControlProps): React$1.JSX.Element;
84
- declare function CarouselItemGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): React$1.JSX.Element;
85
- declare function CarouselItem(props: OtherCarouselProps): React$1.JSX.Element;
86
- declare function CarouselCaption<TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, OtherCarouselProps>): React$1.JSX.Element;
87
- declare function CarouselIndicatorGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): React$1.JSX.Element;
88
- declare function CarouselIndicator(props: CarouselIndicatorProps): React$1.JSX.Element;
82
+ declare function CarouselRoot<TImages extends ImagesType, TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, CarouselRootProps<TImages>>): react_jsx_runtime0.JSX.Element;
83
+ declare function CarouselButton(props: CarouselButtonsProps): react_jsx_runtime0.JSX.Element;
84
+ declare function CarouselControls(props: CarouselControlProps): react_jsx_runtime0.JSX.Element;
85
+ declare function CarouselItemList<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): react_jsx_runtime0.JSX.Element;
86
+ declare function CarouselItem(props: OtherCarouselProps): react_jsx_runtime0.JSX.Element;
87
+ declare function CarouselCaption<TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, OtherCarouselProps>): react_jsx_runtime0.JSX.Element;
88
+ declare function CarouselIndicatorList<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): react_jsx_runtime0.JSX.Element;
89
+ declare function CarouselIndicator(props: CarouselIndicatorProps): react_jsx_runtime0.JSX.Element;
89
90
  declare namespace carousel_parts_d_exports {
90
- export { CarouselButton as Button, CarouselCaption as Caption, CarouselControls as Controls, CarouselIndicator as Indicator, CarouselIndicatorGroup as IndicatorGroup, CarouselItem as Item, CarouselItemGroup as ItemGroup, CarouselRoot as Root };
91
+ export { CarouselButton as Button, CarouselCaption as Caption, CarouselControls as Controls, CarouselIndicator as Indicator, CarouselIndicatorList as IndicatorGroup, CarouselItem as Item, CarouselItemList as ItemGroup, CarouselRoot as Root };
91
92
  }
92
93
  //#endregion
93
- export { CarouselButton, CarouselButtonsProps, CarouselCaption, CarouselControlProps, CarouselControls, CarouselIndicator, CarouselIndicatorGroup, CarouselIndicatorProps, CarouselItem, CarouselItemGroup, CarouselRoot, CarouselRootProps, CarouselStore, CarouselStoreApi, CarouselWrapperProps, ImagesType, OtherCarouselProps, carousel_parts_d_exports };
94
- //# sourceMappingURL=index-DqutTJQB.d.ts.map
94
+ export { CarouselButton, CarouselButtonsProps, CarouselCaption, CarouselControlProps, CarouselControls, CarouselIndicator, CarouselIndicatorList, CarouselIndicatorProps, CarouselItem, CarouselItemList, CarouselRoot, CarouselRootProps, CarouselStore, CarouselStoreApi, CarouselWrapperProps, ImagesType, OtherCarouselProps, carousel_parts_d_exports };
95
+ //# sourceMappingURL=index-DoRAzdDN.d.ts.map
@@ -1,19 +1,20 @@
1
- import * as React from "react";
2
1
  import { PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
2
+ import * as React from "react";
3
+ import * as react_jsx_runtime10 from "react/jsx-runtime";
3
4
 
4
5
  //#region src/components/ui/card/card.d.ts
5
- declare function CardRoot<TElement extends React.ElementType = "article">(props: PolymorphicProps<TElement>): React.JSX.Element;
6
- declare function CardHeader<TElement extends React.ElementType = "header">(props: PolymorphicProps<TElement>): React.JSX.Element;
7
- declare function CardTitle<TElement extends React.ElementType = "h3">(props: PolymorphicProps<TElement>): React.JSX.Element;
8
- declare function CardDescription<TElement extends React.ElementType = "p">(props: PolymorphicProps<TElement>): React.JSX.Element;
9
- declare function CardContent<TElement extends React.ElementType = "div">(props: PolymorphicProps<TElement>): React.JSX.Element;
10
- declare function CardAction<TElement extends React.ElementType = "div">(props: PolymorphicProps<TElement>): React.JSX.Element;
6
+ declare function CardRoot<TElement extends React.ElementType = "article">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
7
+ declare function CardHeader<TElement extends React.ElementType = "header">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
8
+ declare function CardTitle<TElement extends React.ElementType = "h3">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
9
+ declare function CardDescription<TElement extends React.ElementType = "p">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
10
+ declare function CardContent<TElement extends React.ElementType = "div">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
11
+ declare function CardAction<TElement extends React.ElementType = "div">(props: PolymorphicProps<TElement>): react_jsx_runtime10.JSX.Element;
11
12
  declare function CardFooter<TElement extends React.ElementType = "footer">(props: PolymorphicProps<TElement, {
12
13
  asChild?: boolean;
13
- }>): React.JSX.Element;
14
+ }>): react_jsx_runtime10.JSX.Element;
14
15
  declare namespace card_parts_d_exports {
15
16
  export { CardAction as Action, CardContent as Content, CardDescription as Description, CardFooter as Footer, CardHeader as Header, CardRoot as Root, CardTitle as Title };
16
17
  }
17
18
  //#endregion
18
19
  export { CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle, card_parts_d_exports };
19
- //# sourceMappingURL=index-BeDmH7lX.d.ts.map
20
+ //# sourceMappingURL=index-GHA8HNcd.d.ts.map
@@ -1,6 +1,8 @@
1
+ import { DiscriminatedRenderItemProps, DiscriminatedRenderProps, InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
1
2
  import { UnionDiscriminator } from "@zayne-labs/toolkit-type-helpers";
2
3
  import * as React$1 from "react";
3
- import { DiscriminatedRenderItemProps, DiscriminatedRenderProps, InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
4
+ import "@zayne-labs/toolkit-react";
5
+ import * as react_jsx_runtime32 from "react/jsx-runtime";
4
6
  import { Control, ControllerFieldState, ControllerProps, ControllerRenderProps, FieldPath, FieldPathValue, FieldPathValues, RegisterOptions, UseFormReturn, UseFormStateReturn, useFormContext as useFormRootContext } from "react-hook-form";
5
7
 
6
8
  //#region src/components/ui/form/form-context.d.ts
@@ -32,11 +34,11 @@ type FieldState = {
32
34
  //#endregion
33
35
  //#region src/components/ui/form/form.d.ts
34
36
  type FieldValues = Record<string, any>;
35
- type FormRootProps<TFieldValues extends FieldValues> = Partial<FormRootContext> & React$1.ComponentPropsWithoutRef<"form"> & {
37
+ type FormRootProps<TFieldValues extends FieldValues> = InferProps<"form"> & Partial<FormRootContext> & {
36
38
  children: React$1.ReactNode;
37
39
  methods: UseFormReturn<TFieldValues>;
38
40
  };
39
- declare function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>): React$1.JSX.Element;
41
+ declare function FormRoot<TValues extends FieldValues>(props: FormRootProps<TValues>): react_jsx_runtime32.JSX.Element;
40
42
  type FormFieldProps<TControl, TFieldValues extends FieldValues> = (TControl extends (Control<infer TValues>) ? {
41
43
  control?: never;
42
44
  name: FieldPath<TValues>;
@@ -50,7 +52,7 @@ type FormFieldProps<TControl, TFieldValues extends FieldValues> = (TControl exte
50
52
  className?: never;
51
53
  withWrapper: false;
52
54
  });
53
- declare function FormField<TControl, TFieldValues extends FieldValues = FieldValues>(props: FormFieldProps<TControl, TFieldValues>): React$1.JSX.Element;
55
+ declare function FormField<TControl, TFieldValues extends FieldValues = FieldValues>(props: FormFieldProps<TControl, TFieldValues>): react_jsx_runtime32.JSX.Element;
54
56
  type FormFieldControllerRenderFn = (props: {
55
57
  field: Omit<ControllerRenderProps, "value"> & {
56
58
  value: never;
@@ -61,20 +63,20 @@ type FormFieldControllerRenderFn = (props: {
61
63
  type FormFieldControllerProps = Omit<ControllerProps<FieldValues, FieldPath<FieldValues>>, "control" | "name" | "render"> & {
62
64
  render: FormFieldControllerRenderFn;
63
65
  };
64
- declare function FormFieldController(props: FormFieldControllerProps): React$1.JSX.Element;
65
- declare function FormFieldControlledField<TFieldValues extends FieldValues>(props: ControllerProps<TFieldValues>): React$1.JSX.Element;
66
+ declare function FormFieldController(props: FormFieldControllerProps): react_jsx_runtime32.JSX.Element;
67
+ declare function FormFieldControlledField<TFieldValues extends FieldValues>(props: ControllerProps<TFieldValues>): react_jsx_runtime32.JSX.Element;
66
68
  declare function FormFieldContext(props: FormFieldContextProps): React$1.ReactNode;
67
- declare function FormLabel(props: InferProps<"label">): React$1.JSX.Element;
68
- declare function FormInputGroup(props: InferProps<"div">): React$1.JSX.Element;
69
+ declare function FormLabel(props: InferProps<"label">): react_jsx_runtime32.JSX.Element;
70
+ declare function FormInputGroup(props: InferProps<"div">): react_jsx_runtime32.JSX.Element;
69
71
  type FormSideItemProps = {
70
72
  children?: React$1.ReactNode;
71
73
  className?: string;
72
74
  };
73
- declare function FormInputLeftItem<TElement extends React$1.ElementType = "span">(props: PolymorphicProps<TElement, FormSideItemProps>): React$1.JSX.Element;
75
+ declare function FormInputLeftItem<TElement extends React$1.ElementType = "span">(props: PolymorphicProps<TElement, FormSideItemProps>): react_jsx_runtime32.JSX.Element;
74
76
  declare namespace FormInputLeftItem {
75
77
  var slotSymbol: symbol;
76
78
  }
77
- declare function FormInputRightItem<TElement extends React$1.ElementType = "span">(props: PolymorphicProps<TElement, FormSideItemProps>): React$1.JSX.Element;
79
+ declare function FormInputRightItem<TElement extends React$1.ElementType = "span">(props: PolymorphicProps<TElement, FormSideItemProps>): react_jsx_runtime32.JSX.Element;
78
80
  declare namespace FormInputRightItem {
79
81
  var slotSymbol: symbol;
80
82
  }
@@ -110,13 +112,13 @@ type FormSelectPrimitiveProps<TFieldValues extends FieldValues = FieldValues> =
110
112
  };
111
113
  declare function FormInputPrimitive<TFieldValues extends FieldValues>(props: FormInputPrimitiveProps<TFieldValues> & {
112
114
  rules?: RegisterOptions;
113
- }): React$1.JSX.Element;
115
+ }): react_jsx_runtime32.JSX.Element;
114
116
  declare function FormTextAreaPrimitive<TFieldValues extends FieldValues>(props: FormTextAreaPrimitiveProps<TFieldValues> & {
115
117
  rules?: RegisterOptions;
116
- }): React$1.JSX.Element;
118
+ }): react_jsx_runtime32.JSX.Element;
117
119
  declare function FormSelectPrimitive<TFieldValues extends FieldValues>(props: FormSelectPrimitiveProps<TFieldValues> & {
118
120
  rules?: RegisterOptions;
119
- }): React$1.JSX.Element;
121
+ }): react_jsx_runtime32.JSX.Element;
120
122
  type PrimitivePropsToOmit = "control" | "formState" | "name";
121
123
  type FormInputProps = Omit<FormInputPrimitiveProps, PrimitivePropsToOmit> & {
122
124
  rules?: RegisterOptions;
@@ -134,10 +136,10 @@ type CombinedFormInputProps = (FormSelectProps & {
134
136
  }) | FormInputProps;
135
137
  declare function FormInput(props: CombinedFormInputProps & {
136
138
  rules?: RegisterOptions;
137
- }): React$1.JSX.Element;
138
- declare function FormTextArea(props: FormTextAreaProps): React$1.JSX.Element;
139
- declare function FormSelect(props: FormSelectProps): React$1.JSX.Element;
140
- declare function FormDescription(props: InferProps<"p">): React$1.JSX.Element;
139
+ }): react_jsx_runtime32.JSX.Element;
140
+ declare function FormTextArea(props: FormTextAreaProps): react_jsx_runtime32.JSX.Element;
141
+ declare function FormSelect(props: FormSelectProps): react_jsx_runtime32.JSX.Element;
142
+ declare function FormDescription(props: InferProps<"p">): react_jsx_runtime32.JSX.Element;
141
143
  type ErrorMessageRenderProps = {
142
144
  className: string;
143
145
  "data-index": number;
@@ -145,7 +147,6 @@ type ErrorMessageRenderProps = {
145
147
  "data-scope": "form";
146
148
  "data-slot": "form-error-message";
147
149
  id: string | undefined;
148
- ref: React$1.RefCallback<HTMLElement>;
149
150
  };
150
151
  type ErrorMessageRenderState = {
151
152
  errorMessage: string;
@@ -198,11 +199,11 @@ type FormErrorMessageProps<TControl, TFieldValues extends FieldValues> = (TContr
198
199
  errorField: string;
199
200
  type: "root";
200
201
  };
201
- declare function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues>(props: FormErrorMessageProps<TControl, TFieldValues>): React$1.JSX.Element;
202
+ declare function FormErrorMessage<TControl, TFieldValues extends FieldValues = FieldValues>(props: FormErrorMessageProps<TControl, TFieldValues>): react_jsx_runtime32.JSX.Element;
202
203
  type FormSubmitProps = InferProps<"button"> & {
203
204
  asChild?: boolean;
204
205
  };
205
- declare function FormSubmit<TElement extends React$1.ElementType = "button">(props: PolymorphicProps<TElement, FormSubmitProps>): React$1.JSX.Element;
206
+ declare function FormSubmit<TElement extends React$1.ElementType = "button">(props: PolymorphicProps<TElement, FormSubmitProps>): react_jsx_runtime32.JSX.Element;
206
207
  type GetFieldValue<TFieldPathOrPaths, TFieldValues extends FieldValues> = TFieldPathOrPaths extends Array<FieldPath<TFieldValues>> ? FieldPathValues<TFieldValues, TFieldPathOrPaths> : TFieldPathOrPaths extends FieldPath<TFieldValues> ? FieldPathValue<TFieldValues, TFieldPathOrPaths> : unknown;
207
208
  type FormSubscribeToFieldValueRenderFn<TFieldValues extends FieldValues, TFieldPathOrPaths> = (props: {
208
209
  value: GetFieldValue<TFieldPathOrPaths, TFieldValues>;
@@ -223,4 +224,4 @@ declare namespace form_parts_d_exports {
223
224
  }
224
225
  //#endregion
225
226
  export { FieldValues, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormErrorMessagePrimitiveProps, FormField, FormFieldContext, FormFieldControlledField, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputProps, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSelectProps, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, FormTextAreaProps, form_parts_d_exports, useFormRootContext, useStrictFormFieldContext };
226
- //# sourceMappingURL=index-CMwCQ8qR.d.ts.map
227
+ //# sourceMappingURL=index-RnqeaSJm.d.ts.map
@@ -0,0 +1,156 @@
1
+ import { isFunction } from "@zayne-labs/toolkit-type-helpers";
2
+ import { Children, cloneElement, useEffect, useLayoutEffect, useReducer, useRef, useState } from "react";
3
+ import { useCallbackRef, useComposeRefs } from "@zayne-labs/toolkit-react";
4
+ import { on } from "@zayne-labs/toolkit-core";
5
+
6
+ //#region src/components/common/presence/use-presence.ts
7
+ const useStateMachine = (config) => {
8
+ const reducer = (prevState, event) => {
9
+ return config.states[prevState][event] ?? prevState;
10
+ };
11
+ return useReducer(reducer, config.initial);
12
+ };
13
+ const getAnimationName = (styles) => styles?.animationName ?? "none";
14
+ /**
15
+ * React hook that provides the ability to animate the mount/unmount of a component.
16
+ * @see https://github.com/radix-ui/primitives/blob/main/packages/react/presence/src/presence.tsx
17
+ */
18
+ const usePresence = (options) => {
19
+ const { onExitComplete, present } = options;
20
+ const saveOnExitComplete = useCallbackRef(onExitComplete);
21
+ const [node, setNode] = useState(null);
22
+ const stylesRef = useRef(null);
23
+ const prevPresentRef = useRef(present);
24
+ const prevAnimationNameRef = useRef("none");
25
+ const [state, send] = useStateMachine({
26
+ initial: present ? "mounted" : "unmounted",
27
+ states: {
28
+ mounted: {
29
+ ANIMATION_OUT: "unmountSuspended",
30
+ UNMOUNT: "unmounted"
31
+ },
32
+ unmounted: { MOUNT: "mounted" },
33
+ unmountSuspended: {
34
+ ANIMATION_END: "unmounted",
35
+ MOUNT: "mounted"
36
+ }
37
+ }
38
+ });
39
+ useEffect(() => {
40
+ const currentAnimationName = getAnimationName(stylesRef.current);
41
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
42
+ }, [state]);
43
+ useLayoutEffect(() => {
44
+ const styles = stylesRef.current;
45
+ const wasPresent = prevPresentRef.current;
46
+ if (!(wasPresent !== present)) return;
47
+ const prevAnimationName = prevAnimationNameRef.current;
48
+ const currentAnimationName = getAnimationName(styles);
49
+ switch (true) {
50
+ case present:
51
+ send("MOUNT");
52
+ break;
53
+ case Boolean(node):
54
+ if (!(currentAnimationName !== "none" && styles?.display !== "none" || styles?.transitionProperty !== "none" && Number(styles?.transitionDuration) > 0)) {
55
+ send("UNMOUNT");
56
+ break;
57
+ }
58
+ if (!(wasPresent && prevAnimationName !== currentAnimationName)) {
59
+ send("UNMOUNT");
60
+ break;
61
+ }
62
+ send("ANIMATION_OUT");
63
+ break;
64
+ default:
65
+ send("UNMOUNT");
66
+ break;
67
+ }
68
+ prevPresentRef.current = present;
69
+ }, [
70
+ present,
71
+ node,
72
+ send
73
+ ]);
74
+ useLayoutEffect(() => {
75
+ if (!node) {
76
+ send("ANIMATION_END");
77
+ return;
78
+ }
79
+ let timeoutId;
80
+ const ownerWindow = node.ownerDocument.defaultView ?? globalThis;
81
+ /**
82
+ * @description Triggering an ANIMATION_OUT during an ANIMATION_IN will fire an `animationcancel`
83
+ * event for ANIMATION_IN after we have entered `unmountSuspended` state. So, we
84
+ * make sure we only trigger ANIMATION_END for the currently active animation.
85
+ */
86
+ const handleAnimationEnd = (event) => {
87
+ const isCurrentAnimation = getAnimationName(stylesRef.current).includes(CSS.escape(event.animationName));
88
+ if (!(event.target === node && isCurrentAnimation)) return;
89
+ send("ANIMATION_END");
90
+ if (!prevPresentRef.current) {
91
+ const currentFillMode = node.style.animationFillMode;
92
+ node.style.animationFillMode = "forwards";
93
+ timeoutId = ownerWindow.setTimeout(() => {
94
+ if (node.style.animationFillMode === "forwards") node.style.animationFillMode = currentFillMode;
95
+ });
96
+ }
97
+ };
98
+ const handleTransitionEnd = (event) => {
99
+ if (!(event.target === node && !prevPresentRef.current)) return;
100
+ send("ANIMATION_END");
101
+ };
102
+ const handleAnimationStart = (event) => {
103
+ if (!(event.target === node)) return;
104
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
105
+ };
106
+ const onAnimationStartCleanup = on("animationstart", node, handleAnimationStart);
107
+ const onAnimationEndCleanup = on("animationend", node, handleAnimationEnd);
108
+ const onAnimationCancelCleanup = on("animationcancel", node, handleAnimationEnd);
109
+ const onTransitionEndCleanup = on("transitionend", node, handleTransitionEnd);
110
+ const onTransitionCancelCleanup = on("transitioncancel", node, handleTransitionEnd);
111
+ return () => {
112
+ ownerWindow.clearTimeout(timeoutId);
113
+ onAnimationStartCleanup();
114
+ onAnimationEndCleanup();
115
+ onAnimationCancelCleanup();
116
+ onTransitionEndCleanup();
117
+ onTransitionCancelCleanup();
118
+ };
119
+ }, [node, send]);
120
+ useEffect(() => {
121
+ if (!(state === "unmounted" && !present)) return;
122
+ saveOnExitComplete();
123
+ }, [
124
+ state,
125
+ present,
126
+ saveOnExitComplete
127
+ ]);
128
+ const isPresent = ["mounted", "unmountSuspended"].includes(state);
129
+ const ref = useCallbackRef((refNode) => {
130
+ refNode && (stylesRef.current = getComputedStyle(refNode));
131
+ setNode(refNode);
132
+ });
133
+ return {
134
+ isPresent,
135
+ ref
136
+ };
137
+ };
138
+
139
+ //#endregion
140
+ //#region src/components/common/presence/presence.tsx
141
+ function Presence(props) {
142
+ const { children, forceMount = isFunction(children), onExitComplete, present } = props;
143
+ const presence = usePresence({
144
+ onExitComplete,
145
+ present
146
+ });
147
+ const resolvedChild = isFunction(children) ? children({ isPresent: presence.isPresent }) : Children.only(children);
148
+ const childRef = resolvedChild?.props.ref ?? resolvedChild.ref;
149
+ const ref = useComposeRefs(presence.ref, childRef);
150
+ if (!(forceMount || presence.isPresent)) return null;
151
+ return resolvedChild && cloneElement(resolvedChild, { ref });
152
+ }
153
+
154
+ //#endregion
155
+ export { Presence };
156
+ //# sourceMappingURL=presence-CRZsP1Jk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence-CRZsP1Jk.js","names":["timeoutId: number"],"sources":["../../src/components/common/presence/use-presence.ts","../../src/components/common/presence/presence.tsx"],"sourcesContent":["import { on } from \"@zayne-labs/toolkit-core\";\nimport { useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useEffect, useLayoutEffect, 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};\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) => {\n\tconst { onExitComplete, present } = options;\n\n\tconst saveOnExitComplete = useCallbackRef(onExitComplete);\n\n\tconst [node, setNode] = useState<HTMLElement | null>(null);\n\n\tconst stylesRef = useRef<CSSStyleDeclaration | null>(null);\n\n\tconst prevPresentRef = useRef(present);\n\tconst prevAnimationNameRef = useRef<string>(\"none\");\n\n\tconst initialState = present ? \"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\t\tprevAnimationNameRef.current = state === \"mounted\" ? currentAnimationName : \"none\";\n\t}, [state]);\n\n\tuseLayoutEffect(() => {\n\t\tconst styles = stylesRef.current;\n\t\tconst wasPresent = prevPresentRef.current;\n\t\tconst hasPresentChanged = wasPresent !== present;\n\n\t\tif (!hasPresentChanged) return;\n\n\t\tconst prevAnimationName = prevAnimationNameRef.current;\n\t\tconst currentAnimationName = getAnimationName(styles);\n\n\t\tswitch (true) {\n\t\t\tcase present: {\n\t\t\t\tsend(\"MOUNT\");\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase Boolean(node): {\n\t\t\t\tconst hasAnimation =\n\t\t\t\t\t(currentAnimationName !== \"none\" && styles?.display !== \"none\")\n\t\t\t\t\t|| (styles?.transitionProperty !== \"none\" && Number(styles?.transitionDuration) > 0);\n\n\t\t\t\t/* If there is no exit animation or the element is hidden, animations won't run, so we unmount instantly */\n\t\t\t\tif (!hasAnimation) {\n\t\t\t\t\tsend(\"UNMOUNT\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\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 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 isAnimating = prevAnimationName !== currentAnimationName;\n\n\t\t\t\tconst isAnimatingOut = wasPresent && isAnimating;\n\n\t\t\t\tif (!isAnimatingOut) {\n\t\t\t\t\tsend(\"UNMOUNT\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tsend(\"ANIMATION_OUT\");\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\tprevPresentRef.current = present;\n\t}, [present, node, send]);\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\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 (!prevPresentRef.current) {\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 handleTransitionEnd = (event: TransitionEvent) => {\n\t\t\tconst isTargetTransitioningNode = event.target === node && !prevPresentRef.current;\n\n\t\t\tif (!isTargetTransitioningNode) return;\n\n\t\t\tsend(\"ANIMATION_END\");\n\t\t};\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\tprevAnimationNameRef.current = getAnimationName(stylesRef.current);\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\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\t\t\tonTransitionEndCleanup();\n\t\t\tonTransitionCancelCleanup();\n\t\t};\n\t}, [node, send]);\n\n\tuseEffect(() => {\n\t\tconst isExitCompleted = state === \"unmounted\" && !present;\n\n\t\tif (!isExitCompleted) return;\n\n\t\tsaveOnExitComplete();\n\t}, [state, present, saveOnExitComplete]);\n\n\tconst isPresent = ([\"mounted\", \"unmountSuspended\"] satisfies Array<typeof state>).includes(state);\n\n\tconst ref = useCallbackRef((refNode: HTMLElement | null) => {\n\t\trefNode && (stylesRef.current = getComputedStyle(refNode));\n\t\tsetNode(refNode);\n\t});\n\n\treturn {\n\t\tisPresent,\n\t\tref,\n\t};\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 * as React from \"react\";\nimport { Children, cloneElement } from \"react\";\nimport { type UsePresenceOptions, usePresence } from \"./use-presence\";\n\ntype RefProp = { ref?: React.Ref<HTMLElement> };\n\ntype PresenceProps = UsePresenceOptions & {\n\tchildren?:\n\t\t| React.ReactElement<RefProp>\n\t\t| ((props: { isPresent: boolean }) => React.ReactElement<RefProp>);\n\tforceMount?: boolean;\n};\n\nfunction Presence(props: PresenceProps) {\n\tconst { children, forceMount = isFunction(children), onExitComplete, present } = props;\n\n\tconst presence = usePresence({ onExitComplete, present });\n\n\tconst resolvedChild =\n\t\tisFunction(children) ? children({ isPresent: presence.isPresent }) : Children.only(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(presence.ref, childRef);\n\n\tconst shouldRender = forceMount || presence.isPresent;\n\n\tif (!shouldRender) {\n\t\treturn null;\n\t}\n\n\treturn resolvedChild && cloneElement(resolvedChild, { ref });\n}\n\nexport { Presence };\n"],"mappings":";;;;;;AASA,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;;;;;AAY1F,MAAM,eAAe,YAAgC;CACpD,MAAM,EAAE,gBAAgB,YAAY;CAEpC,MAAM,qBAAqB,eAAe,eAAe;CAEzD,MAAM,CAAC,MAAM,WAAW,SAA6B,KAAK;CAE1D,MAAM,YAAY,OAAmC,KAAK;CAE1D,MAAM,iBAAiB,OAAO,QAAQ;CACtC,MAAM,uBAAuB,OAAe,OAAO;CAInD,MAAM,CAAC,OAAO,QAAQ,gBAAgB;EACrC,SAHoB,UAAU,YAAY;EAI1C,QAAQ;GACP,SAAS;IACR,eAAe;IACf,SAAS;IACT;GACD,WAAW,EACV,OAAO,WACP;GACD,kBAAkB;IACjB,eAAe;IACf,OAAO;IACP;GACD;EACD,CAAC;AAEF,iBAAgB;EACf,MAAM,uBAAuB,iBAAiB,UAAU,QAAQ;AAChE,uBAAqB,UAAU,UAAU,YAAY,uBAAuB;IAC1E,CAAC,MAAM,CAAC;AAEX,uBAAsB;EACrB,MAAM,SAAS,UAAU;EACzB,MAAM,aAAa,eAAe;AAGlC,MAAI,EAFsB,eAAe,SAEjB;EAExB,MAAM,oBAAoB,qBAAqB;EAC/C,MAAM,uBAAuB,iBAAiB,OAAO;AAErD,UAAQ,MAAR;GACC,KAAK;AACJ,SAAK,QAAQ;AACb;GAGD,KAAK,QAAQ,KAAK;AAMjB,QAAI,EAJF,yBAAyB,UAAU,QAAQ,YAAY,UACpD,QAAQ,uBAAuB,UAAU,OAAO,QAAQ,mBAAmB,GAAG,IAGhE;AAClB,UAAK,UAAU;AACf;;AAcD,QAAI,EAFmB,cAFH,sBAAsB,uBAIrB;AACpB,UAAK,UAAU;AACf;;AAGD,SAAK,gBAAgB;AACrB;GAGD;AACC,SAAK,UAAU;AACf;;AAIF,iBAAe,UAAU;IACvB;EAAC;EAAS;EAAM;EAAK,CAAC;AAEzB,uBAAsB;AACrB,MAAI,CAAC,MAAM;AAGV,QAAK,gBAAgB;AACrB;;EAGD,IAAIA;EAEJ,MAAM,cAAc,KAAK,cAAc,eAAe;;;;;;EAOtD,MAAM,sBAAsB,UAA0B;GAIrD,MAAM,qBAHuB,iBAAiB,UAAU,QAAQ,CAGhB,SAAS,IAAI,OAAO,MAAM,cAAc,CAAC;AAIzF,OAAI,EAF0B,MAAM,WAAW,QAAQ,oBAE3B;AAY5B,QAAK,gBAAgB;AAErB,OAAI,CAAC,eAAe,SAAS;IAC5B,MAAM,kBAAkB,KAAK,MAAM;AACnC,SAAK,MAAM,oBAAoB;AAM/B,gBAAY,YAAY,iBAAiB;AACxC,SAAI,KAAK,MAAM,sBAAsB,WACpC,MAAK,MAAM,oBAAoB;MAE/B;;;EAIJ,MAAM,uBAAuB,UAA2B;AAGvD,OAAI,EAF8B,MAAM,WAAW,QAAQ,CAAC,eAAe,SAE3C;AAEhC,QAAK,gBAAgB;;EAGtB,MAAM,wBAAwB,UAA0B;AAGvD,OAAI,EAF0B,MAAM,WAAW,MAEnB;AAE5B,wBAAqB,UAAU,iBAAiB,UAAU,QAAQ;;EAGnE,MAAM,0BAA0B,GAAG,kBAAkB,MAAM,qBAAqB;EAChF,MAAM,wBAAwB,GAAG,gBAAgB,MAAM,mBAAmB;EAC1E,MAAM,2BAA2B,GAAG,mBAAmB,MAAM,mBAAmB;EAChF,MAAM,yBAAyB,GAAG,iBAAiB,MAAM,oBAAoB;EAC7E,MAAM,4BAA4B,GAAG,oBAAoB,MAAM,oBAAoB;AAEnF,eAAa;AACZ,eAAY,aAAa,UAAU;AACnC,4BAAyB;AACzB,0BAAuB;AACvB,6BAA0B;AAC1B,2BAAwB;AACxB,8BAA2B;;IAE1B,CAAC,MAAM,KAAK,CAAC;AAEhB,iBAAgB;AAGf,MAAI,EAFoB,UAAU,eAAe,CAAC,SAE5B;AAEtB,sBAAoB;IAClB;EAAC;EAAO;EAAS;EAAmB,CAAC;CAExC,MAAM,YAAa,CAAC,WAAW,mBAAmB,CAAgC,SAAS,MAAM;CAEjG,MAAM,MAAM,gBAAgB,YAAgC;AAC3D,cAAY,UAAU,UAAU,iBAAiB,QAAQ;AACzD,UAAQ,QAAQ;GACf;AAEF,QAAO;EACN;EACA;EACA;;;;;ACrNF,SAAS,SAAS,OAAsB;CACvC,MAAM,EAAE,UAAU,aAAa,WAAW,SAAS,EAAE,gBAAgB,YAAY;CAEjF,MAAM,WAAW,YAAY;EAAE;EAAgB;EAAS,CAAC;CAEzD,MAAM,gBACL,WAAW,SAAS,GAAG,SAAS,EAAE,WAAW,SAAS,WAAW,CAAC,GAAG,SAAS,KAAK,SAAS;CAE7F,MAAM,WAAY,eAAe,MAAM,OAClC,cAA2C;CAEhD,MAAM,MAAM,eAAe,SAAS,KAAK,SAAS;AAIlD,KAAI,EAFiB,cAAc,SAAS,WAG3C,QAAO;AAGR,QAAO,iBAAiB,aAAa,eAAe,EAAE,KAAK,CAAC"}
@@ -1,11 +1,19 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
2
- import { getMultipleSlots } from "./getSlot-Cf5ON6lE.js";
1
+ import { __export } from "./chunk-CTAAG5j7.js";
2
+ import { getMultipleSlots, getSingleSlot } from "@zayne-labs/toolkit-react/utils";
3
3
  import { assert, isFunction } from "@zayne-labs/toolkit-type-helpers";
4
4
  import "react";
5
+ import { toArray } from "@zayne-labs/toolkit-core";
5
6
 
6
7
  //#region src/components/common/show/show.tsx
7
8
  function ShowRoot(props) {
8
- const { children, fallback = null, when } = props;
9
+ const { children, control = "root", fallback = null, when } = props;
10
+ if (control === "content" && !isFunction(children)) {
11
+ const childrenArray = toArray(children);
12
+ const foundContentSlot = childrenArray.find((child) => Boolean(child.props.when));
13
+ const fallBackSlot$1 = getSingleSlot(childrenArray, ShowFallback);
14
+ assert(!(fallBackSlot$1 && fallback), "The fallback prop and <Show.Fallback> cannot be used at the same time.");
15
+ return foundContentSlot ?? fallBackSlot$1 ?? fallback;
16
+ }
9
17
  const resolvedChildren = isFunction(children) ? children(when) : children;
10
18
  const { regularChildren, slots: [contentSlot, fallBackSlot] } = getMultipleSlots(resolvedChildren, [ShowContent, ShowFallback], {
11
19
  errorMessage: ["Only one <Show.Content> component is allowed", "Only one <Show.Fallback> or <Show.OtherWise> component is allowed"],
@@ -17,19 +25,20 @@ function ShowRoot(props) {
17
25
  }
18
26
  return contentSlot ?? regularChildren;
19
27
  }
20
- function ShowContent({ children }) {
21
- return children;
28
+ function ShowContent(props) {
29
+ const { children, when } = props;
30
+ return isFunction(children) ? children(when) : children;
22
31
  }
23
32
  ShowContent.slotSymbol = Symbol("show-content");
24
- function ShowFallback({ children }) {
33
+ function ShowFallback(props) {
34
+ const { children } = props;
25
35
  return children;
26
36
  }
27
37
  ShowFallback.slotSymbol = Symbol("show-fallback");
28
38
 
29
39
  //#endregion
30
40
  //#region src/components/common/show/show-parts.ts
31
- var show_parts_exports = {};
32
- __export(show_parts_exports, {
41
+ var show_parts_exports = __export({
33
42
  Content: () => ShowContent,
34
43
  Fallback: () => ShowFallback,
35
44
  Otherwise: () => ShowFallback,
@@ -38,4 +47,4 @@ __export(show_parts_exports, {
38
47
 
39
48
  //#endregion
40
49
  export { ShowContent, ShowFallback, ShowRoot, show_parts_exports };
41
- //# sourceMappingURL=show-BabiXbf7.js.map
50
+ //# sourceMappingURL=show-N1ZXBhoA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show-N1ZXBhoA.js","names":["fallBackSlot"],"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\";\nimport * as React from \"react\";\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}\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":";;;;;;;AAqBA,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,MAAMA,iBAAe,cAAc,eAAe,aAAa;AAE/D,SACC,EAAEA,kBAAgB,WAClB,yEACA;AAED,SAAO,oBAAoBA,kBAAgB;;CAG5C,MAAM,mBAAmB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;CAE1E,MAAM,EACL,iBACA,OAAO,CAAC,aAAa,kBAClB,iBAAiB,kBAAkB,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;;AAK3E,YAAY,aAAa,OAAO,eAAe;AAE/C,SAAgB,aAAa,OAAsC;CAClE,MAAM,EAAE,aAAa;AAErB,QAAO;;AAER,aAAa,aAAa,OAAO,gBAAgB"}
@@ -1,8 +1,8 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
1
+ import { __export } from "./chunk-CTAAG5j7.js";
2
+ import { composeRefs, mergeProps } from "@zayne-labs/toolkit-react/utils";
2
3
  import { isArray } from "@zayne-labs/toolkit-type-helpers";
3
4
  import { Children, Fragment, cloneElement, isValidElement } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
- import { composeRefs, mergeProps } from "@zayne-labs/toolkit-react/utils";
6
6
 
7
7
  //#region src/components/common/slot/slot.tsx
8
8
  function SlotRoot(props) {
@@ -34,7 +34,7 @@ const isSlottable = (child) => {
34
34
  };
35
35
  function SlotClone(props) {
36
36
  const { children, ref: forwardedRef,...restOfSlotProps } = props;
37
- const resolvedChild = isArray(children) && children.length === 1 ? children[0] : children;
37
+ const resolvedChild = Children.only(children);
38
38
  if (!isValidElement(resolvedChild)) return null;
39
39
  if (Children.count(resolvedChild) > 1) return Children.only(null);
40
40
  const childRef = resolvedChild.props.ref ?? resolvedChild.ref;
@@ -48,12 +48,11 @@ function SlotClone(props) {
48
48
 
49
49
  //#endregion
50
50
  //#region src/components/common/slot/slot-parts.ts
51
- var slot_parts_exports = {};
52
- __export(slot_parts_exports, {
51
+ var slot_parts_exports = __export({
53
52
  Root: () => SlotRoot,
54
53
  Slottable: () => SlotSlottable
55
54
  });
56
55
 
57
56
  //#endregion
58
57
  export { SlotRoot, SlotSlottable, slot_parts_exports };
59
- //# sourceMappingURL=slot-D1062oA5.js.map
58
+ //# sourceMappingURL=slot-WVWfOlr3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slot-D1062oA5.js","names":["ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"sourcesContent":["import { composeRefs, type InferProps, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Children, cloneElement, isValidElement, Fragment as ReactFragment } from \"react\";\n\ntype SlotProps = InferProps<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 (!isValidElement(newElement)) {\n\t\treturn null;\n\t}\n\n\tif (Children.count(newElement) > 1) {\n\t\treturn Children.only(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 (newElement.props as SlotProps).children;\n\t\t}\n\n\t\treturn child;\n\t});\n\n\treturn <SlotClone {...restOfSlotProps}>{cloneElement(newElement, undefined, newChildren)}</SlotClone>;\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 = {\n\tchildren: React.ReactNode;\n\tref?: React.RefObject<HTMLElement>;\n};\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tconst resolvedChild = isArray(children) && children.length === 1 ? children[0] : children;\n\n\tif (!isValidElement<UnknownObject>(resolvedChild)) {\n\t\treturn null;\n\t}\n\n\tif (Children.count(resolvedChild) > 1) {\n\t\treturn Children.only(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 = forwardedRef ? composeRefs(forwardedRef, childRef) : 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":";;;;;;;AAWA,SAAgB,SAAS,OAAkB;CAC1C,MAAM,EAAE,SAAU,GAAG,iBAAiB,GAAG;CAEzC,MAAM,gBAAgB,QAAyB,YAAY,WAAW,CAAC,SAAS;CAEhF,MAAM,YAAY,cAAc,MAAM,YAAY,YAAY;AAE9D,KAAI,CAAC,UACJ,QAAO,oBAAC;EAAU,GAAI;EAAkB;;AAGzC,KAAI,CAAC,eAA0B,WAC9B,QAAO;CAIR,MAAM,aAAa,UAAU,MAAM;AAEnC,KAAI,CAAC,eAAe,YACnB,QAAO;AAGR,KAAI,SAAS,MAAM,cAAc,EAChC,QAAO,SAAS,KAAK;CAGtB,MAAM,cAAc,cAAc,KAAK,UAAU;AAChD,MAAI,UAAU,UAEb,QAAQ,WAAW,MAAoB;AAGxC,SAAO;CACP;AAED,QAAO,oBAAC;EAAU,GAAI;YAAkB,aAAa,YAAY,QAAW;;AAC5E;AAMD,SAAgB,cAAc,EAAE,UAAuC,EAAE;AACxE,QAAO;AACP;AAED,MAAM,eAAe,UAAwD;AAC5E,QAAO,eAAe,UAAU,MAAM,SAAS;AAC/C;AAUD,SAAS,UAAU,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,aAAc,GAAG,iBAAiB,GAAG;CAE5D,MAAM,gBAAgB,QAAQ,aAAa,SAAS,WAAW,IAAI,SAAS,KAAK;AAEjF,KAAI,CAAC,eAA8B,eAClC,QAAO;AAGR,KAAI,SAAS,MAAM,iBAAiB,EACnC,QAAO,SAAS,KAAK;CAGtB,MAAM,WAAY,cAAc,MAAM,OACjC,cAA2C;CAEhD,MAAM,MAAM,eAAe,YAAY,cAAc,YAAY;CAEjE,MAAM,cAAc;EACnB,GAAG,WAAW,iBAAiB,cAAc;EAC7C,GAAI,cAAc,SAASA,YAAiB,EAAE,KAAK;EACnD;AAED,QAAO,aAAa,eAAe;AACnC"}
1
+ {"version":3,"file":"slot-WVWfOlr3.js","names":["ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"sourcesContent":["import { composeRefs, type InferProps, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray, type UnknownObject } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { Children, cloneElement, isValidElement, Fragment as ReactFragment } from \"react\";\n\ntype SlotProps = InferProps<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 (!isValidElement(newElement)) {\n\t\treturn null;\n\t}\n\n\tif (Children.count(newElement) > 1) {\n\t\treturn Children.only(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 (newElement.props as SlotProps).children;\n\t\t}\n\n\t\treturn child;\n\t});\n\n\treturn <SlotClone {...restOfSlotProps}>{cloneElement(newElement, undefined, newChildren)}</SlotClone>;\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 = {\n\tchildren: React.ReactNode;\n\tref?: React.RefObject<HTMLElement>;\n};\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tconst resolvedChild = Children.only(children);\n\n\tif (!isValidElement<UnknownObject>(resolvedChild)) {\n\t\treturn null;\n\t}\n\n\tif (Children.count(resolvedChild) > 1) {\n\t\treturn Children.only(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 = forwardedRef ? composeRefs(forwardedRef, childRef) : 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":";;;;;;;AAWA,SAAgB,SAAS,OAAkB;CAC1C,MAAM,EAAE,SAAU,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,CAAC,eAAe,WAAW,CAC9B,QAAO;AAGR,KAAI,SAAS,MAAM,WAAW,GAAG,EAChC,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,cAAc,cAAc,KAAK,UAAU;AAChD,MAAI,UAAU,UAEb,QAAQ,WAAW,MAAoB;AAGxC,SAAO;GACN;AAEF,QAAO,oBAAC;EAAU,GAAI;YAAkB,aAAa,YAAY,QAAW,YAAY;GAAa;;AAOtG,SAAgB,cAAc,EAAE,YAAyC;AACxE,QAAO;;AAGR,MAAM,eAAe,UAAwD;AAC5E,QAAO,eAAe,MAAM,IAAI,MAAM,SAAS;;AAWhD,SAAS,UAAU,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,aAAc,GAAG,oBAAoB;CAE5D,MAAM,gBAAgB,SAAS,KAAK,SAAS;AAE7C,KAAI,CAAC,eAA8B,cAAc,CAChD,QAAO;AAGR,KAAI,SAAS,MAAM,cAAc,GAAG,EACnC,QAAO,SAAS,KAAK,KAAK;CAG3B,MAAM,WAAY,cAAc,MAAM,OACjC,cAA2C;CAEhD,MAAM,MAAM,eAAe,YAAY,cAAc,SAAS,GAAG;CAEjE,MAAM,cAAc;EACnB,GAAG,WAAW,iBAAiB,cAAc,MAAM;EACnD,GAAI,cAAc,SAASA,YAAiB,EAAE,KAAK;EACnD;AAED,QAAO,aAAa,eAAe,YAAY"}
@@ -1,4 +1,4 @@
1
- import { ErrorBoundary } from "./error-boundary-xM9An3gz.js";
1
+ import { ErrorBoundary } from "./error-boundary-y9Samt_s.js";
2
2
  import { Suspense } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
 
@@ -18,4 +18,4 @@ function SuspenseWithBoundary(props) {
18
18
 
19
19
  //#endregion
20
20
  export { SuspenseWithBoundary };
21
- //# sourceMappingURL=suspense-with-boundary-CEVORL8K.js.map
21
+ //# sourceMappingURL=suspense-with-boundary-D-1NYDV4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suspense-with-boundary-D-1NYDV4.js","names":[],"sources":["../../src/components/common/suspense-with-boundary/suspense-with-boundary.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Suspense } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\nexport type SuspenseWithBoundaryProps = {\n\tchildren: React.ReactNode;\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function SuspenseWithBoundary(props: SuspenseWithBoundaryProps) {\n\tconst { children, errorFallback, fallback } = props;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<ErrorBoundary {...errorBoundaryProps}>\n\t\t\t<Suspense {...suspenseProps}>{children}</Suspense>\n\t\t</ErrorBoundary>\n\t);\n}\n"],"mappings":";;;;;AAUA,SAAgB,qBAAqB,OAAkC;CACtE,MAAM,EAAE,UAAU,eAAe,aAAa;CAE9C,MAAM,qBAAqB,QAAQ,cAAc,IAAI,EAAE,UAAU,eAAe;CAChF,MAAM,gBAAgB,QAAQ,SAAS,IAAI,EAAE,UAAU;AAEvD,QACC,oBAAC;EAAc,GAAI;YAClB,oBAAC;GAAS,GAAI;GAAgB;IAAoB;GACnC"}
@@ -1,5 +1,5 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
2
- import { getRegularChildren, getSingleSlot } from "./getSlot-Cf5ON6lE.js";
1
+ import { __export } from "./chunk-CTAAG5j7.js";
2
+ import { getRegularChildren, getSingleSlot } from "@zayne-labs/toolkit-react/utils";
3
3
  import { isFunction } from "@zayne-labs/toolkit-type-helpers";
4
4
  import "react";
5
5
 
@@ -11,17 +11,14 @@ function SwitchRoot(props) {
11
11
  errorMessage: "Only one <Switch.Default> component is allowed",
12
12
  throwOnMultipleSlotMatch: true
13
13
  });
14
- const childrenCasesArray = getRegularChildren(children, SwitchDefault);
15
- const matchedCase = childrenCasesArray.find((child) => {
14
+ return getRegularChildren(children, SwitchDefault).find((child) => {
16
15
  if (value === defaultValueSymbol) return Boolean(child.props.when);
17
16
  return child.props.when === value;
18
- });
19
- return matchedCase ?? defaultCase;
17
+ }) ?? defaultCase;
20
18
  }
21
19
  function SwitchMatch(props) {
22
20
  const { children, when } = props;
23
- const resolvedChildren = isFunction(children) ? children(when) : children;
24
- return resolvedChildren;
21
+ return isFunction(children) ? children(when) : children;
25
22
  }
26
23
  function SwitchDefault({ children }) {
27
24
  return children;
@@ -30,8 +27,7 @@ SwitchDefault.slotSymbol = Symbol("switch-default");
30
27
 
31
28
  //#endregion
32
29
  //#region src/components/common/switch/switch-parts.ts
33
- var switch_parts_exports = {};
34
- __export(switch_parts_exports, {
30
+ var switch_parts_exports = __export({
35
31
  Default: () => SwitchDefault,
36
32
  Match: () => SwitchMatch,
37
33
  Root: () => SwitchRoot
@@ -39,4 +35,4 @@ __export(switch_parts_exports, {
39
35
 
40
36
  //#endregion
41
37
  export { SwitchDefault, SwitchMatch, SwitchRoot, switch_parts_exports };
42
- //# sourceMappingURL=switch-CCMD01Rs.js.map
38
+ //# sourceMappingURL=switch-Ch22z21e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-Ch22z21e.js","names":[],"sources":["../../src/components/common/switch/switch.tsx","../../src/components/common/switch/switch-parts.ts"],"sourcesContent":["\"use client\";\n\nimport { getRegularChildren, getSingleSlot } from \"@zayne-labs/toolkit-react/utils\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps<unknown>>;\n\ntype SwitchProps = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tvalue?: unknown;\n};\n\nconst defaultValueSymbol = Symbol(\"default-value\");\n\nexport function SwitchRoot(props: SwitchProps) {\n\tconst { children, value = defaultValueSymbol } = props;\n\n\tconst defaultCase = getSingleSlot(children, SwitchDefault, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getRegularChildren(children, SwitchDefault) as ValidSwitchComponentType[];\n\n\tconst matchedCase = childrenCasesArray.find((child) => {\n\t\t// == If value is defaultValueSymbol, match the cases in order like switch(true)\n\t\tif (value === defaultValueSymbol) {\n\t\t\treturn Boolean(child.props.when);\n\t\t}\n\n\t\t// == Otherwise, match the cases like switch(value)\n\t\treturn child.props.when === value;\n\t});\n\n\treturn matchedCase ?? defaultCase;\n}\n\ntype SwitchMatchProps<TWhen> = {\n\tchildren: React.ReactNode | ((value: TWhen) => React.ReactNode);\n\twhen: false | TWhen | null | undefined;\n};\n\nexport function SwitchMatch<TWhen>(props: SwitchMatchProps<TWhen>) {\n\tconst { children, when } = props;\n\n\tconst resolvedChildren = isFunction(children) ? children(when as TWhen) : children;\n\n\treturn resolvedChildren;\n}\n\nexport function SwitchDefault({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nSwitchDefault.slotSymbol = Symbol(\"switch-default\");\n","export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root } from \"./switch\";\n"],"mappings":";;;;;;AAaA,MAAM,qBAAqB,OAAO,gBAAgB;AAElD,SAAgB,WAAW,OAAoB;CAC9C,MAAM,EAAE,UAAU,QAAQ,uBAAuB;CAEjD,MAAM,cAAc,cAAc,UAAU,eAAe;EAC1D,cAAc;EACd,0BAA0B;EAC1B,CAAC;AAcF,QAZ2B,mBAAmB,UAAU,cAAc,CAE/B,MAAM,UAAU;AAEtD,MAAI,UAAU,mBACb,QAAO,QAAQ,MAAM,MAAM,KAAK;AAIjC,SAAO,MAAM,MAAM,SAAS;GAC3B,IAEoB;;AAQvB,SAAgB,YAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,SAAS;AAI3B,QAFyB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;;AAK3E,SAAgB,cAAc,EAAE,YAA2C;AAC1E,QAAO;;AAER,cAAc,aAAa,OAAO,iBAAiB"}
@@ -29,4 +29,4 @@ function Teleport(props) {
29
29
 
30
30
  //#endregion
31
31
  export { Teleport };
32
- //# sourceMappingURL=teleport-DfuYOzsj.js.map
32
+ //# sourceMappingURL=teleport-C8TzRm4M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teleport-C8TzRm4M.js","names":[],"sources":["../../src/components/common/teleport/teleport.tsx"],"sourcesContent":["\"use client\";\n\nimport { type AnyString, isString } from \"@zayne-labs/toolkit-type-helpers\";\nimport * as React from \"react\";\nimport { useEffect, 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 [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);\n\n\t/* eslint-disable react-hooks-extra/no-direct-set-state-in-use-effect -- Allow */\n\n\tuseEffect(() => {\n\t\tif (!to) return;\n\n\t\tif (insertPosition) return;\n\n\t\tconst destination = isString(to) ? document.querySelector<HTMLElement>(to) : to;\n\n\t\tdestination && setPortalContainer(destination);\n\t}, [to, insertPosition]);\n\n\tuseEffect(() => {\n\t\tif (!to) return;\n\n\t\tif (!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\tsetPortalContainer(tempWrapper);\n\n\t\treturn () => {\n\t\t\ttempWrapper.remove();\n\t\t};\n\t}, [to, insertPosition]);\n\n\t/* eslint-enable react-hooks-extra/no-direct-set-state-in-use-effect -- Allow */\n\n\treturn portalContainer && createPortal(children, portalContainer);\n}\n\nexport { Teleport };\n"],"mappings":";;;;;AAeA,SAAS,SAAS,OAAoB;CACrC,MAAM,EAAE,UAAU,gBAAgB,OAAO;CAEzC,MAAM,CAAC,iBAAiB,sBAAsB,SAA6B,KAAK;AAIhF,iBAAgB;AACf,MAAI,CAAC,GAAI;AAET,MAAI,eAAgB;EAEpB,MAAM,cAAc,SAAS,GAAG,GAAG,SAAS,cAA2B,GAAG,GAAG;AAE7E,iBAAe,mBAAmB,YAAY;IAC5C,CAAC,IAAI,eAAe,CAAC;AAExB,iBAAgB;AACf,MAAI,CAAC,GAAI;AAET,MAAI,CAAC,eAAgB;EAErB,MAAM,cAAc,SAAS,GAAG,GAAG,SAAS,cAA2B,GAAG,GAAG;EAE7E,MAAM,cAAc,SAAS,cAAc,MAAM;AACjD,cAAY,MAAM,UAAU;AAE5B,eAAa,sBAAsB,gBAAgB,YAAY;AAE/D,qBAAmB,YAAY;AAE/B,eAAa;AACZ,eAAY,QAAQ;;IAEnB,CAAC,IAAI,eAAe,CAAC;AAIxB,QAAO,mBAAmB,aAAa,UAAU,gBAAgB"}
@@ -1,2 +1,2 @@
1
- import { CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle, card_parts_d_exports } from "../../../index-BeDmH7lX.js";
1
+ import { CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle, card_parts_d_exports } from "../../index-GHA8HNcd.js";
2
2
  export { card_parts_d_exports as Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle };