UNPKG

@wordpress/global-styles-ui

Version:
1 lines • 1.52 kB
{"version":3,"file":"with-global-styles-provider.cjs","names":["GlobalStylesProvider"],"sources":["../src/with-global-styles-provider.tsx"],"sourcesContent":["import type { GlobalStylesConfig } from '@wordpress/global-styles-engine';\nimport { GlobalStylesProvider } from './provider';\n\ninterface GlobalStylesProviderProps {\n\tvalue: GlobalStylesConfig;\n\tbaseValue: GlobalStylesConfig;\n\tonChange: ( config: GlobalStylesConfig ) => void;\n}\n\n/**\n * Higher-order component that wraps a component with GlobalStylesProvider.\n * This allows components to access GlobalStylesContext without exposing\n * the provider directly in the public API.\n *\n * @param Component - The component to wrap\n * @return A wrapped component that accepts value, baseValue, and onChange props\n */\nexport function withGlobalStylesProvider< P extends object >(\n\tComponent: React.ComponentType< P >\n) {\n\treturn function WrappedComponent( {\n\t\tvalue,\n\t\tbaseValue,\n\t\tonChange,\n\t\t...props\n\t}: P & GlobalStylesProviderProps ) {\n\t\treturn (\n\t\t\t<GlobalStylesProvider\n\t\t\t\tvalue={ value }\n\t\t\t\tbaseValue={ baseValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t>\n\t\t\t\t<Component { ...( props as P ) } />\n\t\t\t</GlobalStylesProvider>\n\t\t);\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,yBACf,WACC;CACD,OAAO,SAAS,iBAAkB,EACjC,OACA,WACA,UACA,GAAG,SAC+B;EAClC,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,eAAAA,sBAAD;GACS;GACI;GACD;GAEX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD,EAAW,GAAO,MAAgB,CAAA;EACb,CAAA;CAExB;AACD"}