@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,183 +0,0 @@
1
- import * as _zayne_labs_toolkit_type_helpers0 from "@zayne-labs/toolkit-type-helpers";
2
- import { Awaitable, SelectorFn } from "@zayne-labs/toolkit-type-helpers";
3
- import * as react5 from "react";
4
- import * as _zayne_labs_toolkit_core0 from "@zayne-labs/toolkit-core";
5
- import { FileMeta, FileValidationErrorContext, FileValidationHooksAsync, FileValidationSettingsAsync } from "@zayne-labs/toolkit-core";
6
- import { InferProps, PolymorphicProps } from "@zayne-labs/toolkit-react/utils";
7
-
8
- //#region src/components/ui/drop-zone/drop-zone-context.d.ts
9
- declare const DropZoneStoreContextProvider: (props: {
10
- children: React.ReactNode;
11
- store: _zayne_labs_toolkit_core0.StoreApi<DropZoneStore>;
12
- }) => react5.FunctionComponentElement<react5.ProviderProps<_zayne_labs_toolkit_core0.StoreApi<DropZoneStore> | null>>, useDropZoneStoreContext: <TResult = DropZoneStore>(selector?: _zayne_labs_toolkit_type_helpers0.SelectorFn<DropZoneStore, TResult> | undefined) => TResult;
13
- //#endregion
14
- //#region src/components/ui/drop-zone/use-drop-zone.d.ts
15
- type ExtraProps = {
16
- container?: InferProps<HTMLElement>;
17
- input?: InferProps<"input">;
18
- trigger?: InferProps<"button">;
19
- };
20
- type ClassNames = { [key in keyof ExtraProps]: string };
21
- type UseDropZoneResult = {
22
- inputRef: React.RefObject<HTMLInputElement | null>;
23
- propGetters: DropZonePropGetters;
24
- storeApi: ReturnType<typeof createDropZoneStore>;
25
- useDropZoneStore: typeof useDropZoneStoreContext;
26
- };
27
- type UseDropZoneProps = FileValidationSettingsAsync & {
28
- /**
29
- * CSS classes to apply to the various parts of the drop zone
30
- */
31
- classNames?: ClassNames;
32
- /**
33
- * Whether to disallow preview for non-image files
34
- * @default true
35
- */
36
- disablePreviewForNonImageFiles?: boolean;
37
- /**
38
- * Extra props to pass to various parts of the dropzone
39
- */
40
- extraProps?: ExtraProps;
41
- /**
42
- * Initial files to populate the drop zone
43
- */
44
- initialFiles?: FileMeta | FileMeta[] | null;
45
- /**
46
- * Whether to allow multiple files to be uploaded
47
- */
48
- multiple?: boolean;
49
- /**
50
- * Callback function to be called when internal files state changes
51
- */
52
- onFilesChange?: (context: Pick<DropZoneState, "fileStateArray">) => void;
53
- /**
54
- * Callback function to be called when new files are uploaded
55
- */
56
- onUpload?: (context: Pick<DropZoneState, "fileStateArray">) => Awaitable<void>;
57
- /**
58
- * Callback function to be called on each file upload as they occur
59
- */
60
- onUploadError?: FileValidationHooksAsync["onError"];
61
- /**
62
- * Callback function to be called once after all file upload errors have occurred
63
- */
64
- onUploadErrorCollection?: FileValidationHooksAsync["onErrorCollection"];
65
- /**
66
- * Callback function to be called on file upload success
67
- */
68
- onUploadSuccess?: FileValidationHooksAsync["onSuccess"];
69
- /**
70
- * Whether clicking the drop zone area will open the default file picker or not
71
- *
72
- * @default true
73
- */
74
- shouldOpenFilePickerOnAreaClick?: boolean;
75
- /**
76
- * Custom validation function.
77
- *
78
- * If the function returns false, the file will be rejected
79
- *
80
- */
81
- validator?: FileValidationSettingsAsync["validator"];
82
- };
83
- declare const useDropZone: (props?: UseDropZoneProps) => UseDropZoneResult;
84
- //#endregion
85
- //#region src/components/ui/drop-zone/types.d.ts
86
- type FileState = {
87
- /**
88
- * File object or file metadata
89
- */
90
- file: File | FileMeta;
91
- /**
92
- * Unique ID for the file
93
- */
94
- id: string;
95
- /**
96
- * Preview URL for the file
97
- * - Will be undefined if `disallowPreviewForNonImageFiles` is set to `true` and the file is not an image
98
- * - Can also be undefined if `URL.createObjectURL` fails
99
- */
100
- preview: string | undefined;
101
- };
102
- type DropZonePropGetters = {
103
- getContainerProps: (containerProps?: ExtraProps["container"]) => ExtraProps["container"];
104
- getInputProps: (inputProps?: ExtraProps["input"]) => ExtraProps["input"];
105
- getTriggerProps: (triggerProps?: ExtraProps["trigger"]) => ExtraProps["trigger"];
106
- };
107
- type DropZoneState = {
108
- /**
109
- * List of validation errors
110
- */
111
- errors: FileValidationErrorContext[];
112
- /**
113
- * List of files with their preview URLs and unique IDs
114
- */
115
- fileStateArray: FileState[];
116
- /**
117
- * Whether or not a file is currently being dragged over the drop zone
118
- */
119
- isDraggingOver: boolean;
120
- };
121
- type DropZoneActions = {
122
- addFiles: (files: File[] | FileList | null) => Awaitable<void>;
123
- clearErrors: () => void;
124
- clearFiles: () => void;
125
- handleChange: (event: React.ChangeEvent<HTMLInputElement>) => Awaitable<void>;
126
- handleDragEnter: (event: React.DragEvent<HTMLElement>) => void;
127
- handleDragLeave: (event: React.DragEvent<HTMLElement>) => void;
128
- handleDragOver: (event: React.DragEvent<HTMLElement>) => void;
129
- handleDrop: (event: React.DragEvent<HTMLElement>) => Awaitable<void>;
130
- openFilePicker: () => void;
131
- removeFile: (fileToRemoveOrFileId: string | FileState) => void;
132
- };
133
- //#endregion
134
- //#region src/components/ui/drop-zone/drop-zone-store.d.ts
135
- type DropZoneStore = DropZoneState & {
136
- actions: DropZoneActions;
137
- };
138
- declare const createDropZoneStore: (initStoreValues: Pick<UseDropZoneProps, "allowedFileTypes" | "disablePreviewForNonImageFiles" | "initialFiles" | "maxFileCount" | "maxFileSize" | "multiple" | "onFilesChange" | "onUpload" | "onUploadError" | "onUploadErrorCollection" | "onUploadSuccess" | "rejectDuplicateFiles" | "validator"> & {
139
- inputRef: React.RefObject<HTMLInputElement | null>;
140
- }) => _zayne_labs_toolkit_core0.StoreApi<DropZoneStore>;
141
- //#endregion
142
- //#region src/components/ui/drop-zone/drop-zone.d.ts
143
- type DropZoneRootProps = UseDropZoneProps & {
144
- children: react5.ReactNode;
145
- };
146
- declare function DropZoneRoot(props: DropZoneRootProps): react5.JSX.Element;
147
- type DropZoneContextProps<TSlice> = {
148
- children: react5.ReactNode | ((props: TSlice) => react5.ReactNode);
149
- selector?: SelectorFn<DropZoneStore, TSlice>;
150
- };
151
- declare function DropZoneContext<TSlice = DropZoneStore>(props: DropZoneContextProps<TSlice>): react5.ReactNode;
152
- type DropZoneContainerProps = ExtraProps["container"] & {
153
- asChild?: boolean;
154
- };
155
- declare function DropZoneContainer<TElement extends react5.ElementType = "div">(props: PolymorphicProps<TElement, DropZoneContainerProps>): react5.JSX.Element;
156
- type DropZoneInputProps = ExtraProps["input"] & {
157
- asChild?: boolean;
158
- };
159
- declare function DropZoneInput(props: DropZoneInputProps): react5.JSX.Element;
160
- type DropZoneAreaProps<TSlice> = {
161
- children: react5.ReactNode | ((props: TSlice) => react5.ReactNode);
162
- extraProps?: Pick<ExtraProps, "container" | "input">;
163
- selector?: SelectorFn<DropZoneStore, TSlice>;
164
- };
165
- declare function DropZoneArea<TSlice = DropZoneStore>(props: DropZoneAreaProps<TSlice>): react5.JSX.Element;
166
- type DropZoneTriggerProps = ExtraProps["trigger"] & {
167
- asChild?: boolean;
168
- };
169
- declare function DropZoneTrigger(props: DropZoneTriggerProps): react5.JSX.Element;
170
- type DropZoneFilePreviewProps = {
171
- children: react5.ReactNode | ((props: Pick<DropZoneStore, "actions" | "fileStateArray">) => react5.ReactNode);
172
- };
173
- declare function DropZoneFilePreview(props: DropZoneFilePreviewProps): react5.ReactNode;
174
- type DropZoneErrorPreviewProps = {
175
- children: react5.ReactNode | ((props: Pick<DropZoneStore, "actions" | "errors">) => react5.ReactNode);
176
- };
177
- declare function DropZoneErrorPreview(props: DropZoneErrorPreviewProps): react5.ReactNode;
178
- declare namespace drop_zone_parts_d_exports {
179
- export { DropZoneArea as Area, DropZoneContainer as Container, DropZoneContext as Context, DropZoneErrorPreview as ErrorPreview, DropZoneFilePreview as FilePreview, DropZoneInput as Input, DropZoneRoot as Root, DropZoneTrigger as Trigger };
180
- }
181
- //#endregion
182
- export { ClassNames, DropZoneArea, DropZoneContainer, DropZoneContext, DropZoneContextProps, DropZoneErrorPreview, DropZoneFilePreview, DropZoneInput, DropZoneRoot, DropZoneRootProps, DropZoneTrigger, ExtraProps, UseDropZoneProps, UseDropZoneResult, drop_zone_parts_d_exports, useDropZone, useDropZoneStoreContext };
183
- //# sourceMappingURL=index-D361IX3V.d.ts.map
@@ -1,2 +0,0 @@
1
- import { FunctionalComponent, GetSlotComponentProps, GetSlotMapResult, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, slotComponentSymbol, withSlotNameAndSymbol } from "../../index-BNrCAe9Y.js";
2
- export { FunctionalComponent, GetSlotComponentProps, GetSlotMapResult, createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, slotComponentSymbol, withSlotNameAndSymbol };
@@ -1,4 +0,0 @@
1
- import { createSlotComponent, getSlotMap, slotComponentSymbol, withSlotNameAndSymbol } from "../../utils-ChjmDoRe.js";
2
- import { getMultipleSlots, getRegularChildren, getSingleSlot, matchesAnySlotComponent, matchesSlotComponent } from "../../getSlot-Cf5ON6lE.js";
3
-
4
- export { createSlotComponent, getMultipleSlots, getRegularChildren, getSingleSlot, getSlotMap, matchesAnySlotComponent, matchesSlotComponent, slotComponentSymbol, withSlotNameAndSymbol };
@@ -1 +0,0 @@
1
- {"version":3,"file":"show-BabiXbf7.js","names":[],"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,SAAgB,OAAyB;CACxD,MAAM,EAAE,UAAU,WAAW,MAAM,MAAM,GAAG;CAE5C,MAAM,mBAAmB,WAAW,YAAY,SAAS,QAAiB;CAE1E,MAAM,EACL,iBACA,OAAO,CAAC,aAAa,aAAa,EAClC,GAAG,iBAAiB,kBAAkB,CAAC,aAAa,aAAa,EAAE;EACnE,cAAc,CACb,gDACA,oEACA;EACD,0BAA0B;EAC1B;AAED,KAAI,CAAC,MAAM;AACV,SACC,EAAE,gBAAgB,WAClB;AAGD,SAAO,gBAAgB;CACvB;AAED,QAAO,eAAe;AACtB;AAED,SAAgB,YAAY,EAAE,UAAyC,EAAE;AACxE,QAAO;AACP;AACD,YAAY,aAAa,OAAO;AAEhC,SAAgB,aAAa,EAAE,UAAyC,EAAE;AACzE,QAAO;AACP;AACD,aAAa,aAAa,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"suspense-with-boundary-CEVORL8K.js","names":[],"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,qBAAqB,OAAkC;CACtE,MAAM,EAAE,UAAU,eAAe,UAAU,GAAG;CAE9C,MAAM,qBAAqB,QAAQ,kBAAkB,EAAE,UAAU,eAAe;CAChF,MAAM,gBAAgB,QAAQ,aAAa,EAAE,UAAU;AAEvD,QACC,oBAAC;EAAc,GAAI;YAClB,oBAAC;GAAS,GAAI;GAAgB;;;AAGhC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"switch-CCMD01Rs.js","names":[],"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;AAElC,SAAgB,WAAW,OAAoB;CAC9C,MAAM,EAAE,UAAU,QAAQ,oBAAoB,GAAG;CAEjD,MAAM,cAAc,cAAc,UAAU,eAAe;EAC1D,cAAc;EACd,0BAA0B;EAC1B;CAED,MAAM,qBAAqB,mBAAmB,UAAU;CAExD,MAAM,cAAc,mBAAmB,MAAM,UAAU;AAEtD,MAAI,UAAU,mBACb,QAAO,QAAQ,MAAM,MAAM;AAI5B,SAAO,MAAM,MAAM,SAAS;CAC5B;AAED,QAAO,eAAe;AACtB;AAOD,SAAgB,YAAmB,OAAgC;CAClE,MAAM,EAAE,UAAU,MAAM,GAAG;CAE3B,MAAM,mBAAmB,WAAW,YAAY,SAAS,QAAiB;AAE1E,QAAO;AACP;AAED,SAAgB,cAAc,EAAE,UAAyC,EAAE;AAC1E,QAAO;AACP;AACD,cAAc,aAAa,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"teleport-DfuYOzsj.js","names":[],"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,SAAS,OAAoB;CACrC,MAAM,EAAE,UAAU,gBAAgB,IAAI,GAAG;CAEzC,MAAM,CAAC,iBAAiB,mBAAmB,GAAG,SAA6B;AAI3E,iBAAgB;AACf,MAAI,CAAC,GAAI;AAET,MAAI,eAAgB;EAEpB,MAAM,cAAc,SAAS,MAAM,SAAS,cAA2B,MAAM;AAE7E,iBAAe,mBAAmB;CAClC,GAAE,CAAC,IAAI,eAAe;AAEvB,iBAAgB;AACf,MAAI,CAAC,GAAI;AAET,MAAI,CAAC,eAAgB;EAErB,MAAM,cAAc,SAAS,MAAM,SAAS,cAA2B,MAAM;EAE7E,MAAM,cAAc,SAAS,cAAc;AAC3C,cAAY,MAAM,UAAU;AAE5B,eAAa,sBAAsB,gBAAgB;AAEnD,qBAAmB;AAEnB,eAAa;AACZ,eAAY;EACZ;CACD,GAAE,CAAC,IAAI,eAAe;AAIvB,QAAO,mBAAmB,aAAa,UAAU;AACjD"}
@@ -1,89 +0,0 @@
1
- import { isFunction } from "@zayne-labs/toolkit-type-helpers";
2
- import { Fragment, isValidElement } from "react";
3
- import { toArray } from "@zayne-labs/toolkit-core";
4
-
5
- //#region src/lib/utils/getSlotMap/getSlotMap.ts
6
- /**
7
- * Symbol used to identify SlotComponent instances
8
- */
9
- const slotComponentSymbol = Symbol("slot-component");
10
- /**
11
- * @description Creates a map of named slots from React children. Returns an object mapping slot names to their children,
12
- * with a default slot for unmatched children.
13
- *
14
- * @example
15
- * ```tsx
16
- * import { type GetSlotComponentProps, SlotComponent } from "@zayne-labs/toolkit-react/utils"
17
- *
18
- * type SlotProps = GetSlotComponentProps<"header" | "footer">;
19
- *
20
- * function Parent({ children }: { children: React.ReactNode }) {
21
- * const slots = getSlotMap<SlotProps>(children);
22
- *
23
- * return (
24
- * <div>
25
- * <header>{slots.header}</header>
26
- * <main>{slots.default}</main>
27
- * <footer>{slots.footer}</footer>
28
- * </div>
29
- * );
30
- * }
31
- * ```
32
- *
33
- * Usage:
34
- * ```tsx
35
- * <Parent>
36
- * <SlotComponent name="header">Header Content</SlotComponent>
37
- * <div>Random stuff</div>
38
- * <SlotComponent name="footer">Footer Content</SlotComponent>
39
- * </Parent>
40
- * ```
41
- */
42
- const getSlotMap = (children) => {
43
- const slots = { default: [] };
44
- const isFragment = isValidElement(children) && children.type === Fragment;
45
- const actualChildren = isFragment ? children.props.children : children;
46
- const childrenArray = toArray(actualChildren);
47
- for (const child of childrenArray) {
48
- if (!isValidElement(child) || !isFunction(child.type)) {
49
- slots.default.push(child);
50
- continue;
51
- }
52
- const childType = child.type;
53
- const isSlotElement = childType.slotSymbol === slotComponentSymbol && Boolean(childType.slotName ?? child.props.name);
54
- if (!isSlotElement) {
55
- slots.default.push(child);
56
- continue;
57
- }
58
- const slotName = childType.slotName ?? child.props.name;
59
- if (slotName === "default") {
60
- slots.default.push(child);
61
- continue;
62
- }
63
- slots[slotName] = child;
64
- }
65
- return slots;
66
- };
67
- /**
68
- * @description Creates a slot component
69
- */
70
- const createSlotComponent = () => {
71
- const SlotComponent = (props) => props.children;
72
- SlotComponent.slotSymbol = slotComponentSymbol;
73
- return SlotComponent;
74
- };
75
- function DefaultSlotComponent(props) {
76
- return props.children;
77
- }
78
- /**
79
- * @description Adds a slot symbol and name to a slot component passed in
80
- */
81
- const withSlotNameAndSymbol = (name, SlotComponent = DefaultSlotComponent) => {
82
- SlotComponent.slotSymbol = slotComponentSymbol;
83
- SlotComponent.slotName = name;
84
- return SlotComponent;
85
- };
86
-
87
- //#endregion
88
- export { createSlotComponent, getSlotMap, slotComponentSymbol, withSlotNameAndSymbol };
89
- //# sourceMappingURL=utils-ChjmDoRe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-ChjmDoRe.js","names":["slots: Record<string, TSlotComponentProps[\"children\"]> & { default: React.ReactNode[] }","ReactFragment"],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC1C,MAAa,cACZ,aACqD;CACrD,MAAMA,QAA0F,EAC/F,SAAS,EAAE,EACX;CAED,MAAM,aAAa,eAAwC,aAAa,SAAS,SAASC;CAE1F,MAAM,iBAAiB,aAAa,SAAS,MAAM,WAAW;CAE9D,MAAM,gBAAgB,QAAyB;AAE/C,MAAK,MAAM,SAAS,eAAe;AAClC,MAAI,CAAC,eAAoC,UAAU,CAAC,WAAW,MAAM,OAAO;AAC3E,SAAM,QAAQ,KAAK;AACnB;EACA;EAED,MAAM,YAAY,MAAM;EAExB,MAAM,gBACL,UAAU,eAAe,uBAAuB,QAAQ,UAAU,YAAY,MAAM,MAAM;AAE3F,MAAI,CAAC,eAAe;AACnB,SAAM,QAAQ,KAAK;AACnB;EACA;EAED,MAAM,WAAW,UAAU,YAAY,MAAM,MAAM;AAEnD,MAAI,aAAa,WAAW;AAC3B,SAAM,QAAQ,KAAK;AACnB;EACA;AAED,QAAM,YAAY;CAClB;AAED,QAAO;AACP;;;;AA8BD,MAAa,4BAA+E;CAC3F,MAAM,iBAAiB,UAA+B,MAAM;AAE5D,eAAc,aAAa;AAE3B,QAAO;AACP;AAWD,SAAS,qBAAqB,OAAiE;AAC9F,QAAO,MAAM;AACb;;;;AAKD,MAAa,yBAIZ,MACA,gBAAyE,yBACrE;AAGJ,eAAc,aAAa;AAE3B,eAAc,WAAW;AAIzB,QAAO;AACP"}