UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

1 lines 1.37 kB
{"version":3,"file":"system-provider.cjs","names":["defaultSystem","SystemProvider: FC<SystemProviderProps>","createSystem"],"sources":["../../../../src/core/system/system-provider.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { System, ThemeConfig, UsageTheme } from \"./index.types\"\nimport { createContext, use, useMemo } from \"react\"\nimport { createSystem, defaultSystem } from \"./create-system\"\n\ninterface SystemContext extends System {}\n\nconst SystemContext = createContext<SystemContext>(defaultSystem)\n\nexport interface SystemProviderProps extends PropsWithChildren {\n /**\n * The config of the yamada ui.\n */\n config?: ThemeConfig\n /**\n * The theme of the yamada ui.\n */\n theme?: UsageTheme\n}\n\nexport const SystemProvider: FC<SystemProviderProps> = ({\n children,\n config,\n theme = {},\n}) => {\n const system = useMemo(() => createSystem(theme, config), [theme, config])\n\n return <SystemContext value={system}>{children}</SystemContext>\n}\n\nexport const useSystem = () => {\n const system = use(SystemContext)\n\n return system\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,yCAA6CA,oCAAc;AAajE,MAAaC,kBAA2C,EACtD,UACA,QACA,QAAQ,EAAE,OACN;AAGJ,QAAO,2CAAC;EAAc,gCAFOC,mCAAa,OAAO,OAAO,EAAE,CAAC,OAAO,OAAO,CAAC;EAEpC;GAAyB;;AAGjE,MAAa,kBAAkB;AAG7B,uBAFmB,cAAc"}