@zayne-labs/ui-react 0.9.8 → 0.9.12
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.
- package/dist/esm/await-parts-BJ6C-y1f.d.ts +36 -0
- package/dist/esm/chunk-CLGH26AQ.js +337 -0
- package/dist/esm/chunk-CLGH26AQ.js.map +1 -0
- package/dist/esm/chunk-CWUEUCR5.js +3 -0
- package/dist/esm/chunk-CWUEUCR5.js.map +1 -0
- package/dist/esm/chunk-EYWTW54R.js +42 -0
- package/dist/esm/chunk-EYWTW54R.js.map +1 -0
- package/dist/esm/chunk-G5BNZM66.js +32 -0
- package/dist/esm/chunk-G5BNZM66.js.map +1 -0
- package/dist/esm/{chunk-IREUBYDK.js → chunk-JC52CA2O.js} +26 -23
- package/dist/esm/chunk-JC52CA2O.js.map +1 -0
- package/dist/esm/chunk-KLEJZWKY.js +45 -0
- package/dist/esm/chunk-KLEJZWKY.js.map +1 -0
- package/dist/esm/{chunk-V5DSTESN.js → chunk-M7YXNGT6.js} +3 -3
- package/dist/esm/{chunk-V5DSTESN.js.map → chunk-M7YXNGT6.js.map} +1 -1
- package/dist/esm/chunk-MT2MQDK2.js +13 -0
- package/dist/esm/chunk-MT2MQDK2.js.map +1 -0
- package/dist/esm/chunk-MY5NL5PB.js +627 -0
- package/dist/esm/chunk-MY5NL5PB.js.map +1 -0
- package/dist/esm/{chunk-XZRSR3EM.js → chunk-N4274N5K.js} +6 -2
- package/dist/esm/chunk-N4274N5K.js.map +1 -0
- package/dist/esm/chunk-V5ZPMMIH.js +121 -0
- package/dist/esm/chunk-V5ZPMMIH.js.map +1 -0
- package/dist/esm/{chunk-2P3P5AXH.js → chunk-Y5VBSXZS.js} +14 -7
- package/dist/esm/chunk-Y5VBSXZS.js.map +1 -0
- package/dist/esm/{chunk-IUEPHHGO.js → chunk-YO5LJ7ZJ.js} +2 -2
- package/dist/esm/{chunk-IUEPHHGO.js.map → chunk-YO5LJ7ZJ.js.map} +1 -1
- package/dist/esm/chunk-Z6JJE4G6.js +68 -0
- package/dist/esm/chunk-Z6JJE4G6.js.map +1 -0
- package/dist/esm/chunk-ZSDYJOYB.js +274 -0
- package/dist/esm/chunk-ZSDYJOYB.js.map +1 -0
- package/dist/esm/components/common/await/index.d.ts +10 -12
- package/dist/esm/components/common/await/index.js +5 -24
- package/dist/esm/components/common/await/index.js.map +1 -1
- package/dist/esm/components/common/error-boundary/index.d.ts +6 -30
- package/dist/esm/components/common/error-boundary/index.js +1 -2
- package/dist/esm/components/common/for/index.d.ts +6 -20
- package/dist/esm/components/common/index.d.ts +13 -0
- package/dist/esm/components/common/index.js +14 -0
- package/dist/esm/components/common/show/index.js +2 -2
- package/dist/esm/components/common/slot/index.d.ts +7 -3
- package/dist/esm/components/common/slot/index.js +1 -1
- package/dist/esm/components/common/suspense-with-boundary/index.d.ts +3 -3
- package/dist/esm/components/common/suspense-with-boundary/index.js +2 -12
- package/dist/esm/components/common/suspense-with-boundary/index.js.map +1 -1
- package/dist/esm/components/common/switch/index.js +3 -40
- package/dist/esm/components/common/switch/index.js.map +1 -1
- package/dist/esm/components/common/teleport/index.js +1 -29
- package/dist/esm/components/common/teleport/index.js.map +1 -1
- package/dist/esm/components/ui/card/index.js +4 -43
- package/dist/esm/components/ui/card/index.js.map +1 -1
- package/dist/esm/components/ui/carousel/index.js +14 -273
- package/dist/esm/components/ui/carousel/index.js.map +1 -1
- package/dist/esm/components/ui/drag-scroll/index.js +2 -119
- package/dist/esm/components/ui/drag-scroll/index.js.map +1 -1
- package/dist/esm/components/ui/drop-zone/index.d.ts +8 -181
- package/dist/esm/components/ui/drop-zone/index.js +15 -327
- package/dist/esm/components/ui/drop-zone/index.js.map +1 -1
- package/dist/esm/components/ui/form/index.js +7 -625
- package/dist/esm/components/ui/form/index.js.map +1 -1
- package/dist/esm/components/ui/index.d.ts +11 -0
- package/dist/esm/components/ui/index.js +21 -0
- package/dist/esm/drop-zone-parts-CvseSoXA.d.ts +186 -0
- package/dist/esm/error-boundary-BD0X61Sg.d.ts +28 -0
- package/dist/esm/for-8C6fFbN6.d.ts +21 -0
- package/dist/esm/{lib/utils/getSlotMap/index.d.ts → getSlotMap-DTkxtGhd.d.ts} +10 -8
- package/dist/esm/lib/utils/{getSlot/index.d.ts → index.d.ts} +1 -0
- package/dist/esm/lib/utils/index.js +5 -0
- package/dist/esm/lib/utils/index.js.map +1 -0
- package/dist/esm/{types-CeWumkhm.d.ts → types-mdfDDNrr.d.ts} +9 -6
- package/dist/style.css +1 -1
- package/package.json +17 -16
- package/dist/esm/chunk-2P3P5AXH.js.map +0 -1
- package/dist/esm/chunk-IREUBYDK.js.map +0 -1
- package/dist/esm/chunk-XZRSR3EM.js.map +0 -1
- package/dist/esm/lib/utils/getSlot/index.js +0 -4
- package/dist/esm/lib/utils/getSlotMap/index.js +0 -4
- /package/dist/esm/{lib/utils/getSlot → components/common}/index.js.map +0 -0
- /package/dist/esm/{lib/utils/getSlotMap → components/ui}/index.js.map +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/utils/getSlotMap/getSlotMap.ts"],"names":["ReactFragment"],"mappings":";;;;;AA4Ba,IAAA,mBAAA,GAAsB,OAAO,gBAAgB;AAkC7C,IAAA,UAAA,GAAa,CACzB,QACqD,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,MAAW,SAAS,aAAe,EAAA;AAClC,IAAI,IAAA,CAAC,eAAoC,KAAK,CAAA,IAAK,CAAC,UAAW,CAAA,KAAA,CAAM,IAAI,CAAG,EAAA;AAC3E,MAAM,KAAA,CAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AACxB,MAAA;AAAA;AAGD,IAAA,MAAM,YAAY,KAAM,CAAA,IAAA;AAExB,IAAM,MAAA,aAAA,GACL,UAAU,UAAe,KAAA,mBAAA,IAAuB,QAAQ,SAAU,CAAA,QAAA,IAAY,KAAM,CAAA,KAAA,CAAM,IAAI,CAAA;AAE/F,IAAA,IAAI,CAAC,aAAe,EAAA;AACnB,MAAM,KAAA,CAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AACxB,MAAA;AAAA;AAGD,IAAA,MAAM,QAAW,GAAA,SAAA,CAAU,QAAY,IAAA,KAAA,CAAM,KAAM,CAAA,IAAA;AAEnD,IAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,KAAA;AAAA;AAGnB,EAAO,OAAA,KAAA;AACR;AA6BO,IAAM,sBAAsB,MAAyD;AAC3F,EAAM,MAAA,aAAA,GAAgB,CAAC,KAAA,KAA+B,KAAM,CAAA,QAAA;AAE5D,EAAA,aAAA,CAAc,UAAa,GAAA,mBAAA;AAE3B,EAAO,OAAA,aAAA;AACR;AAWA,SAAS,qBAAqB,KAAiE,EAAA;AAC9F,EAAA,OAAO,KAAM,CAAA,QAAA;AACd;AAKO,IAAM,qBAAwB,GAAA,CAIpC,IACA,EAAA,aAAA,GAA0E,oBACtE,KAAA;AAGJ,EAAA,aAAA,CAAc,UAAa,GAAA,mBAAA;AAE3B,EAAA,aAAA,CAAc,QAAW,GAAA,IAAA;AAIzB,EAAO,OAAA,aAAA;AACR","file":"chunk-XZRSR3EM.js","sourcesContent":["import { toArray } from \"@zayne-labs/toolkit-core\";\nimport type { InferProps } from \"@zayne-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\"]]: Extract<TSlotComponentProps[\"children\"], React.ReactNode>;\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\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\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 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\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\n/**\n * @description Adds a slot symbol and name to a slot component passed in\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"]}
|
|
File without changes
|
|
File without changes
|