@zayne-labs/ui-react 0.9.6 → 0.9.10

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 (84) hide show
  1. package/dist/esm/await-parts-BJ6C-y1f.d.ts +36 -0
  2. package/dist/esm/chunk-BIFY3R2A.js +627 -0
  3. package/dist/esm/chunk-BIFY3R2A.js.map +1 -0
  4. package/dist/esm/chunk-CLGH26AQ.js +337 -0
  5. package/dist/esm/chunk-CLGH26AQ.js.map +1 -0
  6. package/dist/esm/chunk-CWUEUCR5.js +3 -0
  7. package/dist/esm/chunk-CWUEUCR5.js.map +1 -0
  8. package/dist/esm/chunk-EYWTW54R.js +42 -0
  9. package/dist/esm/chunk-EYWTW54R.js.map +1 -0
  10. package/dist/esm/chunk-G5BNZM66.js +32 -0
  11. package/dist/esm/chunk-G5BNZM66.js.map +1 -0
  12. package/dist/esm/{chunk-7LEVEBD2.js → chunk-JC52CA2O.js} +30 -18
  13. package/dist/esm/chunk-JC52CA2O.js.map +1 -0
  14. package/dist/esm/chunk-KLEJZWKY.js +45 -0
  15. package/dist/esm/chunk-KLEJZWKY.js.map +1 -0
  16. package/dist/esm/{chunk-V5DSTESN.js → chunk-M7YXNGT6.js} +3 -3
  17. package/dist/esm/{chunk-V5DSTESN.js.map → chunk-M7YXNGT6.js.map} +1 -1
  18. package/dist/esm/chunk-MT2MQDK2.js +13 -0
  19. package/dist/esm/chunk-MT2MQDK2.js.map +1 -0
  20. package/dist/esm/{chunk-ET4KZBFA.js → chunk-N4274N5K.js} +7 -6
  21. package/dist/esm/chunk-N4274N5K.js.map +1 -0
  22. package/dist/esm/chunk-V5ZPMMIH.js +121 -0
  23. package/dist/esm/chunk-V5ZPMMIH.js.map +1 -0
  24. package/dist/esm/{chunk-2P3P5AXH.js → chunk-Y5VBSXZS.js} +14 -7
  25. package/dist/esm/chunk-Y5VBSXZS.js.map +1 -0
  26. package/dist/esm/{chunk-IUEPHHGO.js → chunk-YO5LJ7ZJ.js} +2 -2
  27. package/dist/esm/{chunk-IUEPHHGO.js.map → chunk-YO5LJ7ZJ.js.map} +1 -1
  28. package/dist/esm/chunk-Z6JJE4G6.js +68 -0
  29. package/dist/esm/chunk-Z6JJE4G6.js.map +1 -0
  30. package/dist/esm/{chunk-DW3FXTFL.js → chunk-ZNL6YLIM.js} +9 -9
  31. package/dist/esm/chunk-ZNL6YLIM.js.map +1 -0
  32. package/dist/esm/chunk-ZSDYJOYB.js +274 -0
  33. package/dist/esm/chunk-ZSDYJOYB.js.map +1 -0
  34. package/dist/esm/components/common/await/index.d.ts +10 -12
  35. package/dist/esm/components/common/await/index.js +5 -23
  36. package/dist/esm/components/common/await/index.js.map +1 -1
  37. package/dist/esm/components/common/error-boundary/index.d.ts +4 -28
  38. package/dist/esm/components/common/error-boundary/index.js +1 -1
  39. package/dist/esm/components/common/for/index.d.ts +7 -21
  40. package/dist/esm/components/common/for/index.js +1 -1
  41. package/dist/esm/components/common/index.d.ts +13 -0
  42. package/dist/esm/components/common/index.js +14 -0
  43. package/dist/esm/components/common/show/index.js +2 -2
  44. package/dist/esm/components/common/slot/index.d.ts +7 -3
  45. package/dist/esm/components/common/slot/index.js +1 -1
  46. package/dist/esm/components/common/suspense-with-boundary/index.d.ts +3 -3
  47. package/dist/esm/components/common/suspense-with-boundary/index.js +2 -11
  48. package/dist/esm/components/common/suspense-with-boundary/index.js.map +1 -1
  49. package/dist/esm/components/common/switch/index.d.ts +5 -5
  50. package/dist/esm/components/common/switch/index.js +3 -40
  51. package/dist/esm/components/common/switch/index.js.map +1 -1
  52. package/dist/esm/components/common/teleport/index.js +1 -29
  53. package/dist/esm/components/common/teleport/index.js.map +1 -1
  54. package/dist/esm/components/ui/card/index.js +4 -43
  55. package/dist/esm/components/ui/card/index.js.map +1 -1
  56. package/dist/esm/components/ui/carousel/index.js +14 -273
  57. package/dist/esm/components/ui/carousel/index.js.map +1 -1
  58. package/dist/esm/components/ui/drag-scroll/index.js +2 -119
  59. package/dist/esm/components/ui/drag-scroll/index.js.map +1 -1
  60. package/dist/esm/components/ui/drop-zone/index.d.ts +8 -181
  61. package/dist/esm/components/ui/drop-zone/index.js +15 -327
  62. package/dist/esm/components/ui/drop-zone/index.js.map +1 -1
  63. package/dist/esm/components/ui/form/index.js +7 -625
  64. package/dist/esm/components/ui/form/index.js.map +1 -1
  65. package/dist/esm/components/ui/index.d.ts +11 -0
  66. package/dist/esm/components/ui/index.js +21 -0
  67. package/dist/esm/drop-zone-parts-CvseSoXA.d.ts +186 -0
  68. package/dist/esm/error-boundary-BD0X61Sg.d.ts +28 -0
  69. package/dist/esm/for-8C6fFbN6.d.ts +21 -0
  70. package/dist/esm/{lib/utils/getSlotMap/index.d.ts → getSlotMap-DTkxtGhd.d.ts} +15 -11
  71. package/dist/esm/lib/utils/{getSlot/index.d.ts → index.d.ts} +1 -0
  72. package/dist/esm/lib/utils/index.js +5 -0
  73. package/dist/esm/lib/utils/index.js.map +1 -0
  74. package/dist/esm/{types-CeWumkhm.d.ts → types-mdfDDNrr.d.ts} +9 -6
  75. package/dist/style.css +1 -1
  76. package/package.json +17 -16
  77. package/dist/esm/chunk-2P3P5AXH.js.map +0 -1
  78. package/dist/esm/chunk-7LEVEBD2.js.map +0 -1
  79. package/dist/esm/chunk-DW3FXTFL.js.map +0 -1
  80. package/dist/esm/chunk-ET4KZBFA.js.map +0 -1
  81. package/dist/esm/lib/utils/getSlot/index.js +0 -4
  82. package/dist/esm/lib/utils/getSlotMap/index.js +0 -4
  83. /package/dist/esm/{lib/utils/getSlot → components/common}/index.js.map +0 -0
  84. /package/dist/esm/{lib/utils/getSlotMap → components/ui}/index.js.map +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/common/for/for.tsx","../../src/components/common/for/getElementList.ts"],"names":[],"mappings":";;;;AA+BO,SAAS,QAAoB,KAA8D,EAAA;AACjG,EAAA,MAAM,EAAE,QAAA,EAAU,IAAM,EAAA,QAAA,EAAU,QAAW,GAAA,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;AAAA;AAChB,IACA,KAAK,aAAe,EAAA;AACnB,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB,IACA,SAAS;AACR,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB;AAEF","file":"chunk-DW3FXTFL.js","sourcesContent":["import * as React from \"react\";\n\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { type Prettify, isArray, isNumber } from \"@zayne-labs/toolkit-type-helpers\";\n\n// prettier-ignore\ntype RenderPropFn<TArrayItem> = (\n\titem: TArrayItem,\n\tindex: number,\n\tarray: TArrayItem[]\n) => React.ReactNode;\n\nexport type ForRenderProps<TArrayItem> = DiscriminatedRenderProps<RenderPropFn<TArrayItem>>;\n\n/* eslint-disable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\ntype ForProps<TArrayItem> = Prettify<\n\t{\n\t\teach: TArrayItem[];\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TArrayItem>\n>;\n\ntype ForPropsWithNumber<TNumber> = Prettify<\n\t{\n\t\teach: TNumber;\n\t\tfallback?: React.ReactNode;\n\t} & ForRenderProps<TNumber>\n>;\n\n/* eslint-enable perfectionist/sort-intersection-types -- Prefer the object to come first before the render props */\n\nexport function ForBase<TArrayItem>(props: ForProps<TArrayItem> | ForPropsWithNumber<TArrayItem>) {\n\tconst { children, each, fallback, render } = props;\n\n\tif (each == null || (isNumber(each) && each === 0) || (isArray(each) && each.length === 0)) {\n\t\treturn fallback;\n\t}\n\n\tconst resolvedArray = isNumber(each)\n\t\t? ([...Array(each).keys()] as TArrayItem[])\n\t\t: (each as TArrayItem[]);\n\n\tif (resolvedArray.length === 0) {\n\t\treturn fallback;\n\t}\n\n\tconst JSXElementList = resolvedArray.map((...params: Parameters<RenderPropFn<TArrayItem>>) => {\n\t\tif (typeof children === \"function\") {\n\t\t\treturn children(...params);\n\t\t}\n\n\t\treturn render(...params);\n\t});\n\n\treturn JSXElementList;\n}\n\ntype ForListProps<TArrayItem> = {\n\tclassName?: string;\n} & (ForProps<TArrayItem> | ForPropsWithNumber<TArrayItem>);\n\nexport function ForList<TArrayItem, TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicProps<TElement, ForListProps<TArrayItem>>\n) {\n\tconst { as: ListContainer = \"ul\", children, className, each, ref, render, ...restOfListProps } = props;\n\n\treturn (\n\t\t<ListContainer ref={ref} className={className} {...restOfListProps}>\n\t\t\t<ForBase {...({ children, each, render } as ForProps<TArrayItem>)} />\n\t\t</ListContainer>\n\t);\n}\n","import { ForBase, ForList } from \"./for\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> = TVariant extends \"base\"\n\t? [typeof ForBase]\n\t: [typeof ForList];\n\nconst getElementList = <TVariant extends \"base\" | \"withWrapper\" = \"withWrapper\">(\n\tvariant?: TVariant\n): GetElementListResult<TVariant> => {\n\tswitch (variant) {\n\t\tcase \"base\": {\n\t\t\treturn [ForBase] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/utils/getSlotMap/getSlotMap.ts"],"names":["ReactFragment"],"mappings":";;;;;AA4Ba,IAAA,mBAAA,GAAsB,OAAO,gBAAgB;AA0C7C,IAAA,UAAA,GAAa,CACzB,QAEqD,KAAA;AACrD,EAAA,MAAM,KAA0F,GAAA;AAAA,IAC/F,SAAS;AAAC,GACX;AAEA,EAAA,MAAM,UAAa,GAAA,cAAA,CAAwC,QAAQ,CAAA,IAAK,SAAS,IAAS,KAAAA,QAAA;AAE1F,EAAA,MAAM,cAAiB,GAAA,UAAA,GAAa,QAAS,CAAA,KAAA,CAAM,QAAW,GAAA,QAAA;AAE9D,EAAM,MAAA,aAAA,GAAgB,QAAyB,cAAc,CAAA;AAE7D,EAAA,KAAA,MAA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-labs/toolkit-react/utils\";\nimport {\n\ttype CallbackFn,\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 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 string extends TSlotComponentProps[\"name\"]\n\t\t? never\n\t\t: TSlotComponentProps[\"name\"]]: TSlotComponentProps[\"children\"];\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// type GetSlotMapOptions = {\n// \t/**\n// \t * If false, the function will bail out early and return only the default slot with the actual children.\n// \t * @default true\n// \t */\n// \t// condition?: boolean;\n// };\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\t// options?: GetSlotMapOptions\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\tconst getSlotChild = () => {\n\t\t\treturn child;\n\t\t};\n\n\t\tslots[slotName] = getSlotChild();\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\t/** Content to render in the slot */\n\tchildren: TChildren;\n\t/** Name of the slot where content should be rendered */\n\tname: TName;\n};\n\n/**\n * @description Slot component created by createSlotComponent\n */\n\nexport const createSlotComponent = <TSlotComponentProps extends GetSlotComponentProps>() => {\n\tconst SlotComponent = (props: TSlotComponentProps) => props.children;\n\n\tSlotComponent.slotSymbol = slotComponentSymbol;\n\n\treturn SlotComponent;\n};\n\ntype SlotWithNameAndSymbol<\n\tTSlotComponentProps extends GetSlotComponentProps = GetSlotComponentProps,\n\tTActualProps extends UnknownObject = UnknownObject,\n> = {\n\t(props: Pick<TSlotComponentProps, \"children\"> & TActualProps): 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\nexport const withSlotNameAndSymbol = <\n\tTSlotComponentProps extends GetSlotComponentProps,\n\tTActualProps extends UnknownObject = UnknownObject,\n>(\n\tname: TSlotComponentProps[\"name\"],\n\tSlotComponent: SlotWithNameAndSymbol<TSlotComponentProps, TActualProps> = 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"]}
@@ -1,4 +0,0 @@
1
- export { getMultipleSlots, getRegularChildren, getSingleSlot, matchesAnySlotComponent, matchesSlotComponent } from '../../../chunk-IUEPHHGO.js';
2
- import '../../../chunk-PZ5AY32C.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map
@@ -1,4 +0,0 @@
1
- export { createSlotComponent, getSlotMap, slotComponentSymbol, withSlotNameAndSymbol } from '../../../chunk-ET4KZBFA.js';
2
- import '../../../chunk-PZ5AY32C.js';
3
- //# sourceMappingURL=index.js.map
4
- //# sourceMappingURL=index.js.map