@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 2.01 kB
Source Map (JSON)
{"version":3,"file":"factory.cjs","names":["createStyled"],"sources":["../../../../src/core/system/factory.ts"],"sourcesContent":["import type { ComponentType, FC } from \"react\"\nimport type { As, DOMElement, StyledComponent } from \"../components\"\nimport type { CSSModifierObject, CSSPropObject } from \"../css\"\nimport type { ComponentStyle, ThemeProps } from \"./index.types\"\nimport type { StyledOptions } from \"./styled\"\nimport { createStyled } from \"./styled\"\n\ntype Components = {\n [Y in DOMElement]: StyledComponent<Y>\n}\n\ninterface Factory extends Components {\n <\n Y extends As,\n M extends object = {},\n D extends CSSPropObject = CSSPropObject,\n H extends CSSModifierObject = CSSModifierObject,\n R extends CSSModifierObject = CSSModifierObject,\n >(\n el: FC<M> | Y,\n options?: StyledOptions<D, H, R, keyof M>,\n ): StyledComponent<Y, M & ThemeProps<ComponentStyle<D, H, R>>>\n}\n\nfunction factory() {\n const cache = new Map<DOMElement, ComponentType>()\n\n return new Proxy(createStyled, {\n apply: function (\n _target,\n _thisArg,\n [el, options]: [DOMElement, StyledOptions],\n ) {\n return createStyled(el, options)\n },\n\n get: function (_target, el: DOMElement): ComponentType | undefined {\n if (!cache.has(el)) cache.set(el, createStyled(el))\n\n return cache.get(el)\n },\n }) as Factory\n}\n\n/**\n * `styled` is an object of JSX elements enabled with Yamada UI's style system,\n * and can also be used as a function for custom components to receive Yamada UI's style system.\n *\n * @see https://yamada-ui.com/docs/components/styled\n */\nexport const styled = factory()\n"],"mappings":";;;AAwBA,SAAS,UAAU;CACjB,MAAM,wBAAQ,IAAI,KAAgC;AAElD,QAAO,IAAI,MAAMA,6BAAc;EAC7B,OAAO,SACL,SACA,UACA,CAAC,IAAI,UACL;AACA,UAAOA,4BAAa,IAAI,QAAQ;;EAGlC,KAAK,SAAU,SAAS,IAA2C;AACjE,OAAI,CAAC,MAAM,IAAI,GAAG,CAAE,OAAM,IAAI,IAAIA,4BAAa,GAAG,CAAC;AAEnD,UAAO,MAAM,IAAI,GAAG;;EAEvB,CAAC;;;;;;;;AASJ,MAAa,SAAS,SAAS"}