@liveblocks/react-ui
Version:
A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.
1 lines • 3.46 kB
Source Map (JSON)
{"version":3,"file":"config.cjs","sources":["../src/config.tsx"],"sourcesContent":["\"use client\";\n\nimport type { PropsWithChildren } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\n\nimport { type Components, ComponentsProvider } from \"./components\";\nimport type { Overrides } from \"./overrides\";\nimport { OverridesProvider } from \"./overrides\";\n\ntype LiveblocksUIConfigProps = PropsWithChildren<{\n /**\n * Override the components' strings.\n */\n overrides?: Partial<Overrides>;\n\n /**\n * Override the components' components.\n */\n components?: Partial<Components>;\n\n /**\n * The container to render the portal into.\n */\n portalContainer?: HTMLElement;\n\n /**\n * When `preventUnsavedChanges` is set on your Liveblocks client (or set on\n * <LiveblocksProvider>), then closing a browser tab will be prevented when\n * there are unsaved changes.\n *\n * By default, that will include draft texts or attachments that are (being)\n * uploaded via comments/threads composers, but not submitted yet.\n *\n * If you want to prevent unsaved changes with Liveblocks, but not for\n * composers, you can opt-out by setting this option to `false`.\n */\n preventUnsavedComposerChanges?: boolean;\n\n /**\n * The Liveblocks emoji picker (visible when adding reactions in `Comment`) is built with\n * {@link https://github.com/liveblocks/frimousse | Frimousse}, which fetches its data from\n * {@link https://emojibase.dev/docs/datasets/ | Emojibase}.\n *\n * This option allows you to change the base URL of where the {@link https://www.npmjs.com/package/emojibase-data | `emojibase-data`}\n * files should be fetched from, used as follows: `${emojibaseUrl}/${locale}/${file}.json`.\n * (e.g. `${emojibaseUrl}/en/data.json`).\n *\n * @example \"https://unpkg.com/emojibase-data\"\n *\n * @example \"https://example.com/self-hosted-emojibase-data\"\n */\n emojibaseUrl?: string;\n}>;\n\ninterface LiveblocksUIConfigContext {\n portalContainer?: HTMLElement;\n preventUnsavedComposerChanges?: boolean;\n emojibaseUrl?: string;\n}\n\nconst LiveblocksUIConfigContext = createContext<LiveblocksUIConfigContext>({});\n\nexport function useLiveblocksUIConfig() {\n return useContext(LiveblocksUIConfigContext);\n}\n\n/**\n * Set configuration options for all components.\n *\n * @example\n * <LiveblocksUIConfig overrides={{ locale: \"fr\", USER_UNKNOWN: \"Anonyme\", ... }}>\n * <App />\n * </LiveblocksUIConfig>\n */\nexport function LiveblocksUIConfig({\n overrides,\n components,\n portalContainer,\n preventUnsavedComposerChanges = true,\n emojibaseUrl,\n children,\n}: LiveblocksUIConfigProps) {\n const liveblocksUIConfig = useMemo(\n () => ({\n portalContainer,\n preventUnsavedComposerChanges,\n emojibaseUrl,\n }),\n [portalContainer, preventUnsavedComposerChanges, emojibaseUrl]\n );\n\n return (\n <LiveblocksUIConfigContext.Provider value={liveblocksUIConfig}>\n <OverridesProvider overrides={overrides}>\n <ComponentsProvider components={components}>\n {children}\n </ComponentsProvider>\n </OverridesProvider>\n </LiveblocksUIConfigContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AA4DA;AAEO;AACL;AACF;AAUO;AAA4B;AACjC;AACA;AACA;AACgC;AAChC;AAEF;AACE;AAA2B;AAClB;AACL;AACA;AACA;AACF;AAC6D;AAG/D;AACG;AAA0C;AACxC;AAAkB;AAChB;AAAmB;AACjB;AACH;AACF;AAGN;;;"}