@zayne-labs/ui-react 0.9.20 → 0.10.0

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 (97) hide show
  1. package/dist/esm/{await-Fe4LFRKd.js → await-fjas2Q-C.js} +6 -8
  2. package/dist/esm/await-fjas2Q-C.js.map +1 -0
  3. package/dist/esm/{card-BBTJxmWt.js → card-TD60Xux0.js} +3 -3
  4. package/dist/esm/card-TD60Xux0.js.map +1 -0
  5. package/dist/esm/{carousel-Dvp-qURP.js → carousel-YXXtZ85s.js} +120 -102
  6. package/dist/esm/carousel-YXXtZ85s.js.map +1 -0
  7. package/dist/esm/cn-_FbtIrlZ.js.map +1 -1
  8. package/dist/esm/components/common/await/index.d.ts +4 -5
  9. package/dist/esm/components/common/await/index.js +5 -5
  10. package/dist/esm/components/common/error-boundary/index.d.ts +1 -1
  11. package/dist/esm/components/common/error-boundary/index.js +1 -1
  12. package/dist/esm/components/common/for/index.d.ts +1 -1
  13. package/dist/esm/components/common/for/index.js +1 -1
  14. package/dist/esm/components/common/index.d.ts +9 -10
  15. package/dist/esm/components/common/index.js +10 -10
  16. package/dist/esm/components/common/show/index.d.ts +1 -1
  17. package/dist/esm/components/common/show/index.js +2 -2
  18. package/dist/esm/components/common/slot/index.d.ts +1 -1
  19. package/dist/esm/components/common/slot/index.js +1 -1
  20. package/dist/esm/components/common/suspense-with-boundary/index.d.ts +2 -2
  21. package/dist/esm/components/common/suspense-with-boundary/index.js +2 -2
  22. package/dist/esm/components/common/switch/index.d.ts +1 -1
  23. package/dist/esm/components/common/switch/index.js +2 -2
  24. package/dist/esm/components/common/teleport/index.d.ts +1 -1
  25. package/dist/esm/components/common/teleport/index.js +1 -1
  26. package/dist/esm/components/ui/card/index.d.ts +1 -1
  27. package/dist/esm/components/ui/card/index.js +2 -2
  28. package/dist/esm/components/ui/carousel/index.d.ts +2 -2
  29. package/dist/esm/components/ui/carousel/index.js +12 -12
  30. package/dist/esm/components/ui/drag-scroll/index.d.ts +1 -1
  31. package/dist/esm/components/ui/drag-scroll/index.js +1 -1
  32. package/dist/esm/components/ui/drop-zone/index.d.ts +2 -3
  33. package/dist/esm/components/ui/drop-zone/index.js +12 -12
  34. package/dist/esm/components/ui/form/index.d.ts +1 -1
  35. package/dist/esm/components/ui/form/index.js +4 -4
  36. package/dist/esm/components/ui/index.d.ts +5 -6
  37. package/dist/esm/components/ui/index.js +15 -15
  38. package/dist/esm/{drag-scroll-BLjij7aI.js → drag-scroll-De6-soln.js} +16 -9
  39. package/dist/esm/drag-scroll-De6-soln.js.map +1 -0
  40. package/dist/esm/drop-zone-BPfSu99L.js +381 -0
  41. package/dist/esm/drop-zone-BPfSu99L.js.map +1 -0
  42. package/dist/esm/{error-boundary-B3ycUZ1t.js → error-boundary-xM9An3gz.js} +3 -4
  43. package/dist/esm/error-boundary-xM9An3gz.js.map +1 -0
  44. package/dist/esm/{for-aTw1TgJo.js → for-DGs2XZ21.js} +6 -6
  45. package/dist/esm/for-DGs2XZ21.js.map +1 -0
  46. package/dist/esm/{form-6RV0u4YT.js → form-Bkj1QWwb.js} +10 -10
  47. package/dist/esm/form-Bkj1QWwb.js.map +1 -0
  48. package/dist/esm/{getSlot-D1_uG-Ym.js → getSlot-Cf5ON6lE.js} +2 -2
  49. package/dist/esm/getSlot-Cf5ON6lE.js.map +1 -0
  50. package/dist/esm/index-BBGuBbI_.d.ts +183 -0
  51. package/dist/esm/{index-BwnMUHzm.d.ts → index-BBJzo-WC.d.ts} +2 -3
  52. package/dist/esm/{getSlotMap-DZlQN8--.d.ts → index-BNrCAe9Y.d.ts} +58 -2
  53. package/dist/esm/{index-gT9tVHv1.d.ts → index-BYhH4Fm0.d.ts} +1 -1
  54. package/dist/esm/{index-XYFc-mmy.d.ts → index-BeDmH7lX.d.ts} +1 -2
  55. package/dist/esm/{index-CIM4YPg5.d.ts → index-CMwCQ8qR.d.ts} +6 -7
  56. package/dist/esm/{index-B3N6YbN8.d.ts → index-CWKQ5V4B.d.ts} +2 -2
  57. package/dist/esm/{index-YFi-sIuR.d.ts → index-Ci8USVIW.d.ts} +6 -6
  58. package/dist/esm/{index-CNE9Cime.d.ts → index-CnvH74ea.d.ts} +4 -4
  59. package/dist/esm/{index-UX3DaMVe.d.ts → index-DJjxpXUk.d.ts} +1 -2
  60. package/dist/esm/{index-CFNg1R-m.d.ts → index-DM-Rbcq2.d.ts} +4 -4
  61. package/dist/esm/{index-CGI7EVlK.d.ts → index-DVr1tbxh.d.ts} +1 -2
  62. package/dist/esm/{index-DT8F8QKc.d.ts → index-DqutTJQB.d.ts} +25 -32
  63. package/dist/esm/{index-BsjcsNQh.d.ts → index-lKxE9WPi.d.ts} +2 -2
  64. package/dist/esm/lib/utils/index.d.ts +1 -2
  65. package/dist/esm/lib/utils/index.js +2 -2
  66. package/dist/esm/{show-DNPzdLi-.js → show-BabiXbf7.js} +3 -3
  67. package/dist/esm/show-BabiXbf7.js.map +1 -0
  68. package/dist/esm/{slot-RXTKo4L7.js → slot-D1062oA5.js} +29 -28
  69. package/dist/esm/slot-D1062oA5.js.map +1 -0
  70. package/dist/esm/{suspense-with-boundary-TrQxYRG6.js → suspense-with-boundary-CEVORL8K.js} +2 -2
  71. package/dist/esm/suspense-with-boundary-CEVORL8K.js.map +1 -0
  72. package/dist/esm/{switch-B2gKl94R.js → switch-CCMD01Rs.js} +3 -3
  73. package/dist/esm/switch-CCMD01Rs.js.map +1 -0
  74. package/dist/esm/{teleport-dlSjWj_t.js → teleport-DfuYOzsj.js} +2 -2
  75. package/dist/esm/teleport-DfuYOzsj.js.map +1 -0
  76. package/dist/esm/{utils-D4YNWj2X.js → utils-ChjmDoRe.js} +2 -2
  77. package/dist/esm/utils-ChjmDoRe.js.map +1 -0
  78. package/dist/style.css +39 -5
  79. package/package.json +20 -21
  80. package/dist/esm/await-Fe4LFRKd.js.map +0 -1
  81. package/dist/esm/card-BBTJxmWt.js.map +0 -1
  82. package/dist/esm/carousel-Dvp-qURP.js.map +0 -1
  83. package/dist/esm/drag-scroll-BLjij7aI.js.map +0 -1
  84. package/dist/esm/drop-zone-Beip1k4x.js +0 -313
  85. package/dist/esm/drop-zone-Beip1k4x.js.map +0 -1
  86. package/dist/esm/error-boundary-B3ycUZ1t.js.map +0 -1
  87. package/dist/esm/for-aTw1TgJo.js.map +0 -1
  88. package/dist/esm/form-6RV0u4YT.js.map +0 -1
  89. package/dist/esm/getSlot-D1_uG-Ym.js.map +0 -1
  90. package/dist/esm/index-BilTdK_M.d.ts +0 -193
  91. package/dist/esm/index-DRiwJkJC.d.ts +0 -60
  92. package/dist/esm/show-DNPzdLi-.js.map +0 -1
  93. package/dist/esm/slot-RXTKo4L7.js.map +0 -1
  94. package/dist/esm/suspense-with-boundary-TrQxYRG6.js.map +0 -1
  95. package/dist/esm/switch-B2gKl94R.js.map +0 -1
  96. package/dist/esm/teleport-dlSjWj_t.js.map +0 -1
  97. package/dist/esm/utils-D4YNWj2X.js.map +0 -1
@@ -1,193 +0,0 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
2
- import { GetSlotComponentProps } from "./getSlotMap-DZlQN8--.js";
3
- import * as React$1 from "react";
4
- import * as react6 from "react";
5
- import { FileMeta, FileValidationErrorContext, FileValidationOptions } from "@zayne-labs/toolkit-core";
6
- import { Prettify } from "@zayne-labs/toolkit-type-helpers";
7
- import { DiscriminatedRenderProps, InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
8
-
9
- //#region src/components/ui/drop-zone/use-drop-zone.d.ts
10
- type ContainerProps = InferProps<HTMLElement> & {
11
- classNames?: {
12
- base?: string;
13
- isDragging?: string;
14
- };
15
- };
16
- type InputProps = InferProps<"input">;
17
- type FileWithPreview = {
18
- /**
19
- * File object or file metadata
20
- */
21
- file: File | FileMeta;
22
- /**
23
- * Unique ID for the file
24
- */
25
- id: string;
26
- /**
27
- * Preview URL for the file
28
- * - Will be undefined if `disallowPreviewForNonImageFiles` is set to `true` and the file is not an image
29
- * - Can also be undefined if `URL.createObjectURL` fails
30
- */
31
- preview: string | undefined;
32
- };
33
- type DropZoneState = {
34
- /**
35
- * List of validation errors
36
- */
37
- errors: FileValidationErrorContext[];
38
- /**
39
- * List of files with their preview URLs and unique IDs
40
- */
41
- filesWithPreview: FileWithPreview[];
42
- /**
43
- * Whether or not a file is currently being dragged over the drop zone
44
- */
45
- isDragging: boolean;
46
- };
47
- type ChangeOrDragEvent = React.ChangeEvent<HTMLInputElement> | React.DragEvent<HTMLElement>;
48
- type DropZoneActions = {
49
- addFiles: (fileList: File[] | FileList | null, event?: ChangeOrDragEvent) => void;
50
- clearErrors: () => void;
51
- clearFiles: () => void;
52
- handleDragEnter: (event: React.DragEvent<HTMLElement>) => void;
53
- handleDragLeave: (event: React.DragEvent<HTMLElement>) => void;
54
- handleDragOver: (event: React.DragEvent<HTMLElement>) => void;
55
- handleFileUpload: (event: ChangeOrDragEvent) => void;
56
- openFilePicker: () => void;
57
- removeFile: (fileToRemoveOrId: string | FileWithPreview) => void;
58
- };
59
- type UseDropZoneResult = {
60
- dropZoneActions: DropZoneActions;
61
- dropZoneState: DropZoneState;
62
- getContainerProps: (containerProps?: ContainerProps) => ContainerProps;
63
- getInputProps: (inputProps?: InputProps) => InputProps;
64
- inputRef: React.RefObject<HTMLInputElement | null>;
65
- };
66
- type UseDropZoneProps = {
67
- /**
68
- * Allowed file types to be uploaded.
69
- */
70
- allowedFileTypes?: string[];
71
- /**
72
- * CSS classes to apply to the various parts of the drop zone
73
- */
74
- classNames?: Prettify<ContainerProps["classNames"] & {
75
- input?: string;
76
- }>;
77
- /**
78
- * Whether to disallow duplicate files
79
- * @default true
80
- */
81
- disallowDuplicates?: boolean;
82
- /**
83
- * Whether to disallow preview for non-image files
84
- * @default true
85
- */
86
- disallowPreviewForNonImageFiles?: boolean;
87
- /**
88
- * Extra props to pass to the container element
89
- */
90
- extraContainerProps?: ContainerProps;
91
- /**
92
- * Extra props to pass to the input element
93
- */
94
- extraInputProps?: InputProps;
95
- /**
96
- * Initial files to populate the drop zone
97
- */
98
- initialFiles?: FileMeta | FileMeta[] | null;
99
- /**
100
- * Maximum number of files that can be uploaded.
101
- */
102
- maxFileCount?: number;
103
- /**
104
- * Maximum file size in MB
105
- */
106
- maxFileSize?: number;
107
- /**
108
- * Whether to allow multiple files to be uploaded
109
- */
110
- multiple?: boolean;
111
- /**
112
- * Callback function to be called when internal files state changes
113
- */
114
- onFilesChange?: (context: {
115
- filesWithPreview: FileWithPreview[];
116
- }) => void;
117
- /**
118
- * Callback function to be called when the render props change
119
- */
120
- onRenderPropsChange?: (props: UseDropZoneResult) => void;
121
- /**
122
- * Callback function to be called when new files are uploaded
123
- */
124
- onUpload?: (context: {
125
- event: ChangeOrDragEvent;
126
- filesWithPreview: FileWithPreview[];
127
- }) => void;
128
- /**
129
- * Callback function to be called on each file upload as they occur
130
- */
131
- onUploadError?: FileValidationOptions["onError"];
132
- /**
133
- * Callback function to be called once after all file upload errors have occurred
134
- */
135
- onUploadErrors?: FileValidationOptions["onErrors"];
136
- /**
137
- * Callback function to be called on file upload success
138
- */
139
- onUploadSuccess?: FileValidationOptions["onSuccess"];
140
- /**
141
- * Custom validation function.
142
- *
143
- * If the function returns false, the file will be rejected
144
- */
145
- validator?: NonNullable<FileValidationOptions["validationSettings"]>["validator"];
146
- /**
147
- * Custom validation function that runs after all file validation has occurred
148
- */
149
- validatorForAllFiles?: FileValidationOptions["validatorForAllFiles"];
150
- /**
151
- * Whether to allow the default file picker via the file input element
152
- * @default true
153
- */
154
- withDefaultFilePicker?: boolean;
155
- };
156
- declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult;
157
- //#endregion
158
- //#region src/components/ui/drop-zone/drop-zone.d.ts
159
- type DropZoneRenderPropType = DiscriminatedRenderProps<React$1.ReactNode | ((props: UseDropZoneResult) => React$1.ReactNode)>;
160
- type DropZoneRootProps = DropZoneRenderPropType & UseDropZoneProps & {
161
- /**
162
- * Controls whether to include internal elements (root and input) or not.
163
- */
164
- withInternalElements?: boolean;
165
- };
166
- declare function DropZoneRoot(props: DropZoneRootProps): React$1.JSX.Element;
167
- type DropZoneInputProps = InputProps & {
168
- asChild?: boolean;
169
- };
170
- declare function DropZoneInput(props: DropZoneInputProps): React$1.JSX.Element;
171
- type DropZoneContainerProps = ContainerProps & {
172
- asChild?: boolean;
173
- };
174
- declare function DropZoneContainer<TElement extends React$1.ElementType = "div">(props: PolymorphicProps<TElement, DropZoneContainerProps>): React$1.JSX.Element;
175
- type RenderPropFn = (props: UseDropZoneResult) => React$1.ReactNode;
176
- type SlotComponentProps = GetSlotComponentProps<"preview", React$1.ReactNode | RenderPropFn>;
177
- declare function DropZoneContext(props: {
178
- children: RenderPropFn;
179
- }): React$1.ReactNode;
180
- declare const DropZoneImagePreview: {
181
- (props: Pick<SlotComponentProps, "children">): React$1.ReactNode;
182
- readonly slotName?: "preview" | undefined;
183
- readonly slotSymbol?: symbol;
184
- };
185
- declare namespace drop_zone_parts_d_exports {
186
- export { DropZoneContainer as Container, DropZoneContext as Context, DropZoneImagePreview as ImagePreview, DropZoneInput as Input, DropZoneRoot as Root };
187
- }
188
- //#endregion
189
- //#region src/components/ui/drop-zone/drop-context.d.ts
190
- declare const DropZoneContextProvider: react6.Context<UseDropZoneResult | null>, useDropZoneContext: () => UseDropZoneResult;
191
- //#endregion
192
- export { ContainerProps, DropZoneActions, DropZoneContainer, DropZoneContext, DropZoneImagePreview, DropZoneInput, DropZoneRenderPropType, DropZoneRoot, DropZoneRootProps, DropZoneState, FileWithPreview, InputProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneContext };
193
- //# sourceMappingURL=index-BilTdK_M.d.ts.map
@@ -1,60 +0,0 @@
1
- import * as react7 from "react";
2
- import { Prettify, UnknownObject } from "@zayne-labs/toolkit-type-helpers";
3
-
4
- //#region src/lib/utils/getSlot/getSlot.d.ts
5
- type FunctionalComponent<TProps extends UnknownObject = never> = React.FunctionComponent<TProps>;
6
- /**
7
- * @description Checks if a react child (within the children array) matches the provided SlotComponent using multiple matching strategies:
8
- * 1. Matches by slot symbol property
9
- * 2. Matches by component name
10
- */
11
- declare const matchesSlotComponent: (child: React.ReactNode, SlotComponent: FunctionalComponent) => boolean;
12
- /**
13
- * @description Checks if a react child (within the children array) matches any of the provided SlotComponents.
14
- */
15
- declare const matchesAnySlotComponent: (child: React.ReactNode, SlotComponents: FunctionalComponent[]) => boolean;
16
- type SlotOptions = {
17
- /**
18
- * @description The error message to throw when multiple slots are found for a given slot component
19
- */
20
- errorMessage?: string;
21
- /**
22
- * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
23
- */
24
- throwOnMultipleSlotMatch?: boolean;
25
- };
26
- /**
27
- * @description Retrieves a single slot element from a collection of React children that matches the provided SlotComponent component.
28
- *
29
- * @throws { AssertionError } when throwOnMultipleSlotMatch is true and multiple slots are found
30
- */
31
- declare const getSingleSlot: (children: React.ReactNode, SlotComponent: FunctionalComponent, options?: SlotOptions) => react7.ReactNode;
32
- type MultipleSlotsOptions = {
33
- /**
34
- * @description The error message to throw when multiple slots are found for a given slot component
35
- * If a string is provided, the same message will be used for all slot components
36
- * If an array is provided, each string in the array will be used as the errorMessage for the corresponding slot component
37
- */
38
- errorMessage?: string | string[];
39
- /**
40
- * @description When true, an AssertionError will be thrown if multiple slots are found for a given slot component
41
- * If a boolean is provided, the same value will be used for all slot components
42
- * If an array is provided, each boolean in the array will be used as the throwOnMultipleSlotMatch value for the corresponding slot component
43
- */
44
- throwOnMultipleSlotMatch?: boolean | boolean[];
45
- };
46
- type GetMultipleSlotsResult<TSlotComponents extends FunctionalComponent[]> = {
47
- regularChildren: React.ReactNode[];
48
- slots: { [Key in keyof TSlotComponents]: ReturnType<TSlotComponents[Key]> };
49
- };
50
- /**
51
- * @description The same as getSingleSlot, but for multiple slot components
52
- */
53
- declare const getMultipleSlots: <const TSlotComponents extends FunctionalComponent[]>(children: React.ReactNode, SlotComponents: TSlotComponents, options?: MultipleSlotsOptions) => Prettify<GetMultipleSlotsResult<TSlotComponents>>;
54
- /**
55
- * @description Returns all children that are not slot elements (i.e., don't match any of the provided slot components)
56
- */
57
- declare const getRegularChildren: (children: React.ReactNode, SlotComponentOrComponents: FunctionalComponent | FunctionalComponent[]) => react7.ReactNode[];
58
- //#endregion
59
- export { FunctionalComponent, getMultipleSlots, getRegularChildren, getSingleSlot, matchesAnySlotComponent, matchesSlotComponent };
60
- //# sourceMappingURL=index-DRiwJkJC.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"show-DNPzdLi-.js","names":["props: ShowProps<TWhen>"],"sources":["../../src/components/common/show/show.tsx","../../src/components/common/show/show-parts.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getMultipleSlots } from \"@/lib/utils/getSlot\";\nimport { assert, isFunction } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ShowProps<TWhen> = {\n\tchildren: React.ReactNode | ((value: TWhen) => React.ReactNode);\n\tfallback?: React.ReactNode;\n\twhen: false | TWhen | null | undefined;\n};\n\nexport function ShowRoot<TWhen>(props: ShowProps<TWhen>) {\n\tconst { children, fallback = null, when } = props;\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\nexport function ShowContent({ children }: { children: React.ReactNode }) {\n\treturn children;\n}\nShowContent.slotSymbol = Symbol(\"show-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"],"mappings":";;;;;;AAaA,SAAgB,SAAgBA,OAAyB;CACxD,MAAM,EAAE,UAAU,WAAW,MAAM,MAAM,GAAG;CAE5C,MAAM,mBAAmB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;CAE1E,MAAM,EACL,iBACA,OAAO,CAAC,aAAa,aAAa,EAClC,GAAG,iBAAiB,kBAAkB,CAAC,aAAa,YAAa,GAAE;EACnE,cAAc,CACb,gDACA,mEACA;EACD,0BAA0B;CAC1B,EAAC;AAEF,MAAK,MAAM;AACV,WACG,gBAAgB,WAClB,yEACA;AAED,SAAO,gBAAgB;CACvB;AAED,QAAO,eAAe;AACtB;AAED,SAAgB,YAAY,EAAE,UAAyC,EAAE;AACxE,QAAO;AACP;AACD,YAAY,aAAa,OAAO,eAAe;AAE/C,SAAgB,aAAa,EAAE,UAAyC,EAAE;AACzE,QAAO;AACP;AACD,aAAa,aAAa,OAAO,gBAAgB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"slot-RXTKo4L7.js","names":["child: React.ReactNode","props: SlotProps","props: SlotCloneProps","ReactFragment"],"sources":["../../src/components/common/slot/slot.tsx","../../src/components/common/slot/slot-parts.ts"],"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, Fragment as ReactFragment, cloneElement, isValidElement } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement>;\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 * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function SlotRoot(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\tconst resolvedChildren = isArray(children) && children.length === 1 ? children[0] : children;\n\n\tif (!isValidElement<UnknownProps>(resolvedChildren)) {\n\t\treturn Children.count(resolvedChildren) > 1 ? Children.only(null) : null;\n\t}\n\n\tconst childRef = (resolvedChildren.props.ref\n\t\t?? (resolvedChildren as unknown as UnknownProps).ref) as React.Ref<HTMLElement>;\n\n\tconst mergedRef = forwardedRef ? composeRefs(forwardedRef, childRef) : childRef;\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, resolvedChildren.props),\n\t\t...(resolvedChildren.type !== ReactFragment && { ref: mergedRef }),\n\t};\n\n\treturn cloneElement(resolvedChildren, clonedProps);\n}\n","export { SlotRoot as Root, SlotSlottable as Slottable } from \"./slot\";\n"],"mappings":";;;;;;;AAYA,SAAgB,cAAc,EAAE,UAAuC,EAAE;AACxE,QAAO;AACP;AAED,MAAM,cAAc,CAACA,UAAwD;AAC5E,QAAO,eAAe,MAAM,IAAI,MAAM,SAAS;AAC/C;AAMD,SAAgB,SAASC,OAAkB;CAC1C,MAAM,EAAE,SAAU,GAAG,iBAAiB,GAAG;CAEzC,MAAM,gBAAgB,QAAyB,SAAS,GAAG,WAAW,CAAC,QAAS;CAChF,MAAM,YAAY,cAAc,KAAK,CAAC,YAAY,YAAY,QAAQ,CAAC;AAEvE,KAAI,WAAW;EAEd,MAAM,aAAc,UAAU,MAAoB;AAElD,MAAI,SAAS,MAAM,WAAW,GAAG,EAChC,QAAO,SAAS,KAAK,KAAK;EAG3B,MAAM,qBAAqB,cAAc,IAAI,CAAC,UAAU;AACvD,OAAI,UAAU,UAEb,QAAO,eAA0B,WAAW,IAAI,WAAW,MAAM;AAGlE,UAAO;EACP,EAAC;AAEF,yBACC,IAAC;GAAU,GAAI;aACb,eAAe,WAAW,IAAI,aAAa,oBAAuB,mBAAmB;IAC3E;CAEb;AAED,wBAAO,IAAC;EAAU,GAAI;EAAkB;GAAqB;AAC7D;AASD,SAAS,UAAUC,OAAuB;CACzC,MAAM,EAAE,UAAU,KAAK,aAAc,GAAG,iBAAiB,GAAG;CAE5D,MAAM,mBAAmB,QAAQ,SAAS,IAAI,SAAS,WAAW,IAAI,SAAS,KAAK;AAEpF,MAAK,eAA6B,iBAAiB,CAClD,QAAO,SAAS,MAAM,iBAAiB,GAAG,IAAI,SAAS,KAAK,KAAK,GAAG;CAGrE,MAAM,WAAY,iBAAiB,MAAM,OACpC,iBAA6C;CAElD,MAAM,YAAY,eAAe,YAAY,cAAc,SAAS,GAAG;CAEvE,MAAM,cAAc;EACnB,GAAG,WAAW,iBAAiB,iBAAiB,MAAM;EACtD,GAAI,iBAAiB,SAASC,YAAiB,EAAE,KAAK,UAAW;CACjE;AAED,QAAO,aAAa,kBAAkB,YAAY;AAClD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"suspense-with-boundary-TrQxYRG6.js","names":["props: SuspenseWithBoundaryProps"],"sources":["../../src/components/common/suspense-with-boundary/suspense-with-boundary.tsx"],"sourcesContent":["import { Suspense } from \"react\";\nimport { ErrorBoundary, type ErrorBoundaryProps } from \"../error-boundary\";\n\nexport type SuspenseWithBoundaryProps = {\n\tchildren: React.ReactNode;\n\terrorFallback?: ErrorBoundaryProps[\"fallback\"];\n\tfallback?: React.ReactNode;\n};\n\nexport function SuspenseWithBoundary(props: SuspenseWithBoundaryProps) {\n\tconst { children, errorFallback, fallback } = props;\n\n\tconst errorBoundaryProps = Boolean(errorFallback) && { fallback: errorFallback };\n\tconst suspenseProps = Boolean(fallback) && { fallback };\n\n\treturn (\n\t\t<ErrorBoundary {...errorBoundaryProps}>\n\t\t\t<Suspense {...suspenseProps}>{children}</Suspense>\n\t\t</ErrorBoundary>\n\t);\n}\n"],"mappings":";;;;;AASA,SAAgB,qBAAqBA,OAAkC;CACtE,MAAM,EAAE,UAAU,eAAe,UAAU,GAAG;CAE9C,MAAM,qBAAqB,QAAQ,cAAc,IAAI,EAAE,UAAU,cAAe;CAChF,MAAM,gBAAgB,QAAQ,SAAS,IAAI,EAAE,SAAU;AAEvD,wBACC,IAAC;EAAc,GAAI;4BAClB,IAAC;GAAS,GAAI;GAAgB;IAAoB;GACnC;AAEjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"switch-B2gKl94R.js","names":["props: SwitchProps","props: SwitchMatchProps<TWhen>"],"sources":["../../src/components/common/switch/switch.tsx","../../src/components/common/switch/switch-parts.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getRegularChildren, getSingleSlot } from \"@/lib/utils/getSlot\";\nimport { isFunction } from \"@zayne-labs/toolkit-type-helpers\";\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":";;;;;;AAcA,MAAM,qBAAqB,OAAO,gBAAgB;AAElD,SAAgB,WAAWA,OAAoB;CAC9C,MAAM,EAAE,UAAU,QAAQ,oBAAoB,GAAG;CAEjD,MAAM,cAAc,cAAc,UAAU,eAAe;EAC1D,cAAc;EACd,0BAA0B;CAC1B,EAAC;CAEF,MAAM,qBAAqB,mBAAmB,UAAU,cAAc;CAEtE,MAAM,cAAc,mBAAmB,KAAK,CAAC,UAAU;AAEtD,MAAI,UAAU,mBACb,QAAO,QAAQ,MAAM,MAAM,KAAK;AAIjC,SAAO,MAAM,MAAM,SAAS;CAC5B,EAAC;AAEF,QAAO,eAAe;AACtB;AAOD,SAAgB,YAAmBC,OAAgC;CAClE,MAAM,EAAE,UAAU,MAAM,GAAG;CAE3B,MAAM,mBAAmB,WAAW,SAAS,GAAG,SAAS,KAAc,GAAG;AAE1E,QAAO;AACP;AAED,SAAgB,cAAc,EAAE,UAAyC,EAAE;AAC1E,QAAO;AACP;AACD,cAAc,aAAa,OAAO,iBAAiB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"teleport-dlSjWj_t.js","names":["props: PortalProps"],"sources":["../../src/components/common/teleport/teleport.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { type AnyString, isString } from \"@zayne-labs/toolkit-type-helpers\";\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":";;;;;AAgBA,SAAS,SAASA,OAAoB;CACrC,MAAM,EAAE,UAAU,gBAAgB,IAAI,GAAG;CAEzC,MAAM,CAAC,iBAAiB,mBAAmB,GAAG,SAA6B,KAAK;AAIhF,WAAU,MAAM;AACf,OAAK,GAAI;AAET,MAAI,eAAgB;EAEpB,MAAM,cAAc,SAAS,GAAG,GAAG,SAAS,cAA2B,GAAG,GAAG;AAE7E,iBAAe,mBAAmB,YAAY;CAC9C,GAAE,CAAC,IAAI,cAAe,EAAC;AAExB,WAAU,MAAM;AACf,OAAK,GAAI;AAET,OAAK,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,SAAO,MAAM;AACZ,eAAY,QAAQ;EACpB;CACD,GAAE,CAAC,IAAI,cAAe,EAAC;AAIxB,QAAO,mBAAmB,aAAa,UAAU,gBAAgB;AACjE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-D4YNWj2X.js","names":["children: React.ReactNode","slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] }","ReactFragment","props: TSlotComponentProps","props: Pick<GetSlotComponentProps, \"children\">","name: TSlotComponentProps[\"name\"]","SlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps>"],"sources":["../../src/lib/utils/getSlotMap/getSlotMap.ts"],"sourcesContent":["import { toArray } from \"@zayne-labs/toolkit-core\";\nimport type { InferProps } from \"@zayne-labs/toolkit-react/utils\";\nimport {\n\ttype CallbackFn,\n\ttype EmptyObject,\n\ttype Prettify,\n\ttype UnionToIntersection,\n\ttype UnknownObject,\n\tisFunction,\n} from \"@zayne-labs/toolkit-type-helpers\";\nimport { Fragment as ReactFragment, isValidElement } from \"react\";\n\ntype GetSlotName<TSlotComponentProps extends GetSlotComponentProps> =\n\tstring extends TSlotComponentProps[\"name\"]\n\t\t? never\n\t\t: \"default\" extends TSlotComponentProps[\"name\"]\n\t\t\t? never\n\t\t\t: TSlotComponentProps[\"name\"];\n\ntype GetSpecificSlotsType<TSlotComponentProps extends GetSlotComponentProps> = {\n\t// This conditional before the remapping will prevent an Indexed Record type from showing up if the props are not passed, enhancing type safety\n\t[TName in keyof TSlotComponentProps as GetSlotName<TSlotComponentProps>]: Extract<\n\t\tTSlotComponentProps[\"children\"],\n\t\tReact.ReactNode\n\t>;\n};\n\n/**\n * Maps slot names to their corresponding children types\n */\nexport type GetSlotMapResult<TSlotComponentProps extends GetSlotComponentProps> = UnionToIntersection<\n\tGetSpecificSlotsType<TSlotComponentProps>\n> & { default: React.ReactNode[] };\n\n/**\n * Symbol used to identify SlotComponent instances\n */\nexport const slotComponentSymbol = Symbol(\"slot-component\");\n\n/**\n * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,\n * with a default slot for unmatched children.\n *\n * @example\n * ```tsx\n * import { type GetSlotComponentProps, SlotComponent } from \"@zayne-labs/toolkit-react/utils\"\n *\n * type SlotProps = GetSlotComponentProps<\"header\" | \"footer\">;\n *\n * function Parent({ children }: { children: React.ReactNode }) {\n * const slots = getSlotMap<SlotProps>(children);\n *\n * return (\n * <div>\n * <header>{slots.header}</header>\n * <main>{slots.default}</main>\n * <footer>{slots.footer}</footer>\n * </div>\n * );\n * }\n * ```\n *\n * Usage:\n * ```tsx\n * <Parent>\n * <SlotComponent name=\"header\">Header Content</SlotComponent>\n * <div>Random stuff</div>\n * <SlotComponent name=\"footer\">Footer Content</SlotComponent>\n * </Parent>\n * ```\n */\nexport const getSlotMap = <TSlotComponentProps extends GetSlotComponentProps>(\n\tchildren: React.ReactNode\n): Prettify<GetSlotMapResult<TSlotComponentProps>> => {\n\tconst slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] } = {\n\t\tdefault: [],\n\t};\n\n\tconst isFragment = isValidElement<InferProps<HTMLElement>>(children) && children.type === ReactFragment;\n\n\tconst actualChildren = isFragment ? children.props.children : children;\n\n\tconst childrenArray = toArray<React.ReactNode>(actualChildren);\n\n\tfor (const child of childrenArray) {\n\t\tif (!isValidElement<TSlotComponentProps>(child) || !isFunction(child.type)) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst childType = child.type as SlotWithNameAndSymbol;\n\n\t\tconst isSlotElement =\n\t\t\tchildType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name);\n\n\t\tif (!isSlotElement) {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst slotName = childType.slotName ?? child.props.name;\n\n\t\tif (slotName === \"default\") {\n\t\t\tslots.default.push(child);\n\t\t\tcontinue;\n\t\t}\n\n\t\tslots[slotName] = child;\n\t}\n\n\treturn slots as GetSlotMapResult<TSlotComponentProps>;\n};\n\n/**\n * @description Produce props for the SlotComponent\n *\n * @example\n * ```ts\n * // Pattern One (slot or slots have same children type, which is just React.ReactNode by default)\n * type SlotProps = GetSlotComponentProps<\"header\" | \"content\" | \"footer\">;\n *\n * // Pattern Two (some slots can have different children type)\n * type SlotProps = GetSlotComponentProps<\"header\", React.ReactNode> | GetSlotComponentProps<\"header\", (renderProp: RenderProp) => React.ReactNode>;\n * ```\n */\nexport type GetSlotComponentProps<\n\tTName extends string = string,\n\tTChildren extends CallbackFn<never, React.ReactNode> | React.ReactNode =\n\t\t| CallbackFn<never, React.ReactNode>\n\t\t| React.ReactNode,\n> = {\n\tchildren: TChildren;\n\t/**\n\t * Name of the slot where content should be rendered\n\t */\n\tname: TName;\n};\n\n/**\n * @description Creates a slot component\n */\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children as React.ReactNode;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotWithNameAndSymbol<\n\tTSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n> = {\n\t(props: Pick<TSlotComponentProps, \"children\"> & TOtherProps): React.ReactNode;\n\treadonly slotName?: TSlotComponentProps[\"name\"];\n\treadonly slotSymbol?: symbol;\n};\n\nfunction DefaultSlotComponent(props: Pick<GetSlotComponentProps, \"children\">): React.ReactNode {\n\treturn props.children as React.ReactNode;\n}\n\n/**\n * @description Adds a slot symbol and name to a slot component passed in\n */\nexport const withSlotNameAndSymbol = <\n\tTSlotComponentProps extends GetSlotComponentProps,\n\tTOtherProps extends UnknownObject = EmptyObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TOtherProps> = DefaultSlotComponent\n) => {\n\t/* eslint-disable no-param-reassign -- This is necessary */\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\t// @ts-expect-error -- This is necessary for the time being, to prevent type errors and accidental overrides on consumer side\n\tSlotComponent.slotName = name;\n\n\t/* eslint-enable no-param-reassign -- This is necessary */\n\n\treturn SlotComponent;\n};\n"],"mappings":";;;;;;;;AAqCA,MAAa,sBAAsB,OAAO,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC3D,MAAa,aAAa,CACzBA,aACqD;CACrD,MAAMC,QAA0F,EAC/F,SAAS,CAAE,EACX;CAED,MAAM,aAAa,eAAwC,SAAS,IAAI,SAAS,SAASC;CAE1F,MAAM,iBAAiB,aAAa,SAAS,MAAM,WAAW;CAE9D,MAAM,gBAAgB,QAAyB,eAAe;AAE9D,MAAK,MAAM,SAAS,eAAe;AAClC,OAAK,eAAoC,MAAM,KAAK,WAAW,MAAM,KAAK,EAAE;AAC3E,SAAM,QAAQ,KAAK,MAAM;AACzB;EACA;EAED,MAAM,YAAY,MAAM;EAExB,MAAM,gBACL,UAAU,eAAe,uBAAuB,QAAQ,UAAU,YAAY,MAAM,MAAM,KAAK;AAEhG,OAAK,eAAe;AACnB,SAAM,QAAQ,KAAK,MAAM;AACzB;EACA;EAED,MAAM,WAAW,UAAU,YAAY,MAAM,MAAM;AAEnD,MAAI,aAAa,WAAW;AAC3B,SAAM,QAAQ,KAAK,MAAM;AACzB;EACA;AAED,QAAM,YAAY;CAClB;AAED,QAAO;AACP;;;;AA8BD,MAAa,sBAAsB,MAAyD;CAC3F,MAAM,gBAAgB,CAACC,UAA+B,MAAM;AAE5D,eAAc,aAAa;AAE3B,QAAO;AACP;AAWD,SAAS,qBAAqBC,OAAiE;AAC9F,QAAO,MAAM;AACb;;;;AAKD,MAAa,wBAAwB,CAIpCC,MACAC,gBAAyE,yBACrE;AAGJ,eAAc,aAAa;AAE3B,eAAc,WAAW;AAIzB,QAAO;AACP"}