@lingui/react 3.17.2 → 4.0.0-next.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/I18nProvider.tsx","../../src/format.ts","../../src/Trans.tsx"],"sourcesContent":["import React, { ComponentType, FunctionComponent } from \"react\"\nimport { I18n } from \"@lingui/core\"\nimport { TransRenderProps } from \"./Trans\"\n\nexport type I18nContext = {\n i18n: I18n\n defaultComponent?: ComponentType<TransRenderProps>\n}\n\nexport type withI18nProps = {\n i18n: I18n\n}\n\nexport type I18nProviderProps = I18nContext & {\n forceRenderOnLocaleChange?: boolean\n children?: React.ReactNode\n}\n\nconst LinguiContext = React.createContext<I18nContext>(null)\n\nexport function useLingui(): I18nContext {\n const context = React.useContext<I18nContext>(LinguiContext)\n\n if (process.env.NODE_ENV !== \"production\") {\n if (context == null) {\n throw new Error(\"useLingui hook was used without I18nProvider.\")\n }\n }\n\n return context\n}\n\nexport function withI18n(\n o?: object\n): <P extends withI18nProps>(\n Component: ComponentType<P>\n) => React.ComponentType<Omit<P, \"i18n\">> {\n return <P extends withI18nProps>(\n WrappedComponent: ComponentType<P>\n ): ComponentType<P> => {\n return (props) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof o === \"function\" || React.isValidElement(o)) {\n throw new Error(\n \"withI18n([options]) takes options as a first argument, \" +\n \"but received React component itself. Without options, the Component \" +\n \"should be wrapped as withI18n()(Component), not withI18n(Component).\"\n )\n }\n }\n\n const { i18n } = useLingui()\n return <WrappedComponent {...props} i18n={i18n} />\n }\n }\n}\n\nexport const I18nProvider: FunctionComponent<I18nProviderProps> = ({\n i18n,\n defaultComponent,\n forceRenderOnLocaleChange = true,\n children,\n}) => {\n /**\n * We can't pass `i18n` object directly through context, because even when locale\n * or messages are changed, i18n object is still the same. Context provider compares\n * reference identity and suggested workaround is create a wrapper object every time\n * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.\n *\n * Due to this effect we also pass `defaultComponent` in the same context, instead\n * of creating a separate Provider/Consumer pair.\n *\n * We can't use useMemo hook either, because we want to recalculate value manually.\n */\n const makeContext = () => ({\n i18n,\n defaultComponent,\n })\n const getRenderKey = () => {\n return (\n forceRenderOnLocaleChange ? i18n.locale || \"default\" : \"default\"\n ) as string\n }\n\n const [context, setContext] = React.useState<I18nContext>(makeContext()),\n [renderKey, setRenderKey] = React.useState<string>(getRenderKey())\n\n /**\n * Subscribe for locale/message changes\n *\n * I18n object from `@lingui/core` is the single source of truth for all i18n related\n * data (active locale, catalogs). When new messages are loaded or locale is changed\n * we need to trigger re-rendering of LinguiContext.Consumers.\n *\n * We call `setContext(makeContext())` after adding the observer in case the `change`\n * event would already have fired between the inital renderKey calculation and the\n * `useEffect` hook being called. This can happen if locales are loaded/activated\n * async.\n */\n React.useEffect(() => {\n const unsubscribe = i18n.on(\"change\", () => {\n setContext(makeContext())\n setRenderKey(getRenderKey())\n })\n if (renderKey === \"default\") {\n setRenderKey(getRenderKey())\n }\n if (forceRenderOnLocaleChange && renderKey === \"default\") {\n console.log(\n \"I18nProvider did not render. A call to i18n.activate still needs to happen or forceRenderOnLocaleChange must be set to false.\"\n )\n }\n return () => unsubscribe()\n }, [])\n\n if (forceRenderOnLocaleChange && renderKey === \"default\") return null\n\n return (\n <LinguiContext.Provider value={context} key={renderKey}>\n {children}\n </LinguiContext.Provider>\n )\n}\n","import React from \"react\"\n\n// match <tag>paired</tag> and <tag/> unpaired tags\nconst tagRe = /<([a-zA-Z0-9]+)>(.*?)<\\/\\1>|<([a-zA-Z0-9]+)\\/>/\nconst nlRe = /(?:\\r\\n|\\r|\\n)/g\n\n// For HTML, certain tags should omit their close tag. We keep a whitelist for\n// those special-case tags.\nconst voidElementTags = {\n area: true,\n base: true,\n br: true,\n col: true,\n embed: true,\n hr: true,\n img: true,\n input: true,\n keygen: true,\n link: true,\n meta: true,\n param: true,\n source: true,\n track: true,\n wbr: true,\n menuitem: true,\n}\n\n/**\n * `formatElements` - parse string and return tree of react elements\n *\n * `value` is string to be formatted with <tag>Paired<tag/> or <tag/> (unpaired)\n * placeholders. `elements` is a array of react elements which indexes\n * correspond to element indexes in formatted string\n */\nfunction formatElements(\n value: string,\n elements: { [key: string]: React.ReactElement<any> } = {}\n): string | Array<any> {\n const uniqueId = makeCounter(0, \"$lingui$\")\n const parts = value.replace(nlRe, \"\").split(tagRe)\n\n // no inline elements, return\n if (parts.length === 1) return value\n\n const tree = []\n\n const before = parts.shift()\n if (before) tree.push(before)\n\n for (const [index, children, after] of getElements(parts)) {\n let element = elements[index]\n\n if (!element || (voidElementTags[element.type as string] && children)) {\n if (!element) {\n console.error(\n `Can use element at index '${index}' as it is not declared in the original translation`\n )\n } else {\n console.error(\n `${element.type} is a void element tag therefore it must have no children`\n )\n }\n\n // ignore problematic element but push its children and elements after it\n element = React.createElement(React.Fragment)\n }\n\n tree.push(\n React.cloneElement(\n element,\n { key: uniqueId() },\n\n // format children for pair tags\n // unpaired tags might have children if it's a component passed as a variable\n children ? formatElements(children, elements) : element.props.children\n )\n )\n\n if (after) tree.push(after)\n }\n\n return tree\n}\n\n/*\n * `getElements` - return array of element indexes and element childrens\n *\n * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]\n * where:\n * - `pairedIndex` is index of paired element (undef for unpaired)\n * - `children` are children of paired element (undef for unpaired)\n * - `unpairedIndex` is index of unpaired element (undef for paired)\n * - `textAfter` is string after all elements (empty string, if there's nothing)\n *\n * `parts` length is always multiply of 4\n *\n * Returns: Array<[elementIndex, children, after]>\n */\nfunction getElements(parts) {\n if (!parts.length) return []\n\n const [paired, children, unpaired, after] = parts.slice(0, 4)\n\n return [[paired || unpaired, children || \"\", after]].concat(\n getElements(parts.slice(4, parts.length))\n )\n}\n\nconst makeCounter =\n (count = 0, prefix = \"\") =>\n () =>\n `${prefix}_${count++}`\n\nexport { formatElements }\n","import React from \"react\"\n\nimport { useLingui } from \"./I18nProvider\"\nimport { formatElements } from \"./format\"\n\nexport type TransRenderProps = {\n id?: string\n translation?: React.ReactNode\n children?: React.ReactNode\n message?: string | null\n isTranslated?: boolean\n}\n\nexport type TransProps = {\n id: string\n message?: string\n values: Record<string, unknown>\n context?: string\n components: { [key: string]: React.ElementType | any }\n formats?: Record<string, unknown>\n children?: React.ReactNode\n component?: React.ComponentType<TransRenderProps>\n render?: (props: TransRenderProps) => React.ReactElement<any, any> | null\n}\n\nexport function Trans(props: TransProps): React.ReactElement<any, any> | null {\n const { i18n, defaultComponent } = useLingui()\n const { render, component, id, message, formats } = props\n\n const values = { ...props.values }\n const components = { ...props.components }\n\n if (values) {\n /*\n Related discussion: https://github.com/lingui/js-lingui/issues/183\n\n Values *might* contain React elements with static content.\n They're replaced with <INDEX /> placeholders and added to `components`.\n\n Example:\n Translation: Hello {name}\n Values: { name: <strong>Jane</strong> }\n\n It'll become \"Hello <0 />\" with components=[<strong>Jane</strong>]\n */\n\n Object.keys(values).forEach((key) => {\n const value = values[key]\n if (!React.isValidElement(value)) return\n\n const index = Object.keys(components).length\n\n components[index] = value\n values[key] = `<${index}/>`\n })\n }\n\n const _translation: string =\n i18n && typeof i18n._ === \"function\"\n ? i18n._(id, values, { message, formats })\n : id // i18n provider isn't loaded at all\n\n const translation = _translation\n ? formatElements(_translation, components)\n : null\n\n if (render === null || component === null) {\n // Although `string` is a valid react element, types only allow `Element`\n // Upstream issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return translation as unknown as React.ReactElement<any, any>\n }\n\n const FallbackComponent = (defaultComponent ||\n React.Fragment) as React.ComponentType<any>\n\n const i18nProps = {\n id,\n message,\n translation,\n isTranslated: id !== translation && message !== translation,\n }\n\n // Validation of `render` and `component` props\n if (render && component) {\n console.error(\n \"You can't use both `component` and `render` prop at the same time. `component` is ignored.\"\n )\n } else if (render && typeof render !== \"function\") {\n console.error(\n `Invalid value supplied to prop \\`render\\`. It must be a function, provided ${render}`\n )\n } else if (component && typeof component !== \"function\") {\n // Apparently, both function components and class components are functions\n // See https://stackoverflow.com/a/41658173/1535540\n console.error(\n `Invalid value supplied to prop \\`component\\`. It must be a React component, provided ${component}`\n )\n return <FallbackComponent {...i18nProps}>{translation}</FallbackComponent>\n }\n\n // Rendering using a render prop\n if (typeof render === \"function\") {\n // Component: render={(props) => <a title={props.translation}>x</a>}\n return render(i18nProps)\n }\n\n // `component` prop has a higher precedence over `defaultComponent`\n const Component = (component || FallbackComponent) as React.ComponentType<any>\n const DefaultComponent = defaultComponent\n\n return DefaultComponent && !component ? (\n <DefaultComponent {...i18nProps}>{translation}</DefaultComponent>\n ) : (\n <Component>{translation}</Component>\n )\n}\n\nTrans.defaultProps = {\n values: {},\n components: {},\n}\n"],"names":["LinguiContext","React","createContext","useLingui","context","useContext","process","env","NODE_ENV","Error","withI18n","o","WrappedComponent","props","isValidElement","i18n","I18nProvider","defaultComponent","forceRenderOnLocaleChange","children","makeContext","getRenderKey","locale","setContext","useState","renderKey","setRenderKey","useEffect","unsubscribe","on","console","log","tagRe","nlRe","voidElementTags","area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","menuitem","formatElements","value","elements","uniqueId","makeCounter","parts","replace","split","length","tree","before","shift","push","index","after","getElements","element","type","error","createElement","Fragment","cloneElement","key","paired","unpaired","slice","concat","count","prefix","Trans","render","component","id","message","formats","values","components","Object","keys","forEach","_translation","_","translation","FallbackComponent","i18nProps","isTranslated","Component","DefaultComponent","defaultProps"],"mappings":";;;;;AAkBA,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAa,CAAc,IAAI,CAAC,CAAA;AAErD,SAASC,SAAS,GAAgB;AACvC,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAAcL,aAAa,CAAC,CAAA;AAE5D,EAAA,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAIJ,OAAO,IAAI,IAAI,EAAE;AACnB,MAAA,MAAM,IAAIK,KAAK,CA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AAI,OAAOZ,MAAM,KAAK,UAAU,EAAE;AAChC;IACA,OAAOA,MAAM,CAACc,SAAS,CAAC,CAAA;AAC1B,GAAA;;AAEA;AACA,EAAA,MAAME,SAAS,GAAIf,SAAS,IAAIY,iBAA8C,CAAA;EAC9E,MAAMI,gBAAgB,GAAGjF,gBAAgB,CAAA;AAEzC,EAAA,OAAOiF,gBAAgB,IAAI,CAAChB,SAAS,gBACnC,oBAAC,gBAAgB,EAAKa,SAAS,EAAGF,WAAW,CAAoB,gBAEjE,oBAAC,SAAS,EAAA,IAAA,EAAEA,WAAW,CACxB,CAAA;AACH,CAAA;AAEAb,KAAK,CAACmB,YAAY,GAAG;EACnBb,MAAM,EAAE,EAAE;AACVC,EAAAA,UAAU,EAAE,EAAC;AACf,CAAC;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/I18nProvider.tsx","../../src/format.ts","../../src/Trans.tsx"],"sourcesContent":["import React, { ComponentType, FunctionComponent } from \"react\"\nimport { I18n } from \"@lingui/core\"\nimport { TransRenderProps } from \"./Trans\"\n\nexport type I18nContext = {\n i18n: I18n\n defaultComponent?: ComponentType<TransRenderProps>\n}\n\nexport type withI18nProps = {\n i18n: I18n\n}\n\nexport type I18nProviderProps = I18nContext & {\n forceRenderOnLocaleChange?: boolean\n children?: React.ReactNode\n}\n\nconst LinguiContext = React.createContext<I18nContext>(null)\n\nexport function useLingui(): I18nContext {\n const context = React.useContext<I18nContext>(LinguiContext)\n\n if (process.env.NODE_ENV !== \"production\") {\n if (context == null) {\n throw new Error(\"useLingui hook was used without I18nProvider.\")\n }\n }\n\n return context\n}\n\nexport function withI18n(\n o?: object\n): <P extends withI18nProps>(\n Component: ComponentType<P>\n) => React.ComponentType<Omit<P, \"i18n\">> {\n return <P extends withI18nProps>(\n WrappedComponent: ComponentType<P>\n ): ComponentType<P> => {\n return (props) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof o === \"function\" || React.isValidElement(o)) {\n throw new Error(\n \"withI18n([options]) takes options as a first argument, \" +\n \"but received React component itself. Without options, the Component \" +\n \"should be wrapped as withI18n()(Component), not withI18n(Component).\"\n )\n }\n }\n\n const { i18n } = useLingui()\n return <WrappedComponent {...props} i18n={i18n} />\n }\n }\n}\n\nexport const I18nProvider: FunctionComponent<I18nProviderProps> = ({\n i18n,\n defaultComponent,\n forceRenderOnLocaleChange = true,\n children,\n}) => {\n /**\n * We can't pass `i18n` object directly through context, because even when locale\n * or messages are changed, i18n object is still the same. Context provider compares\n * reference identity and suggested workaround is create a wrapper object every time\n * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.\n *\n * Due to this effect we also pass `defaultComponent` in the same context, instead\n * of creating a separate Provider/Consumer pair.\n *\n * We can't use useMemo hook either, because we want to recalculate value manually.\n */\n const makeContext = () => ({\n i18n,\n defaultComponent,\n })\n const getRenderKey = () => {\n return (\n forceRenderOnLocaleChange ? i18n.locale || \"default\" : \"default\"\n ) as string\n }\n\n const [context, setContext] = React.useState<I18nContext>(makeContext()),\n [renderKey, setRenderKey] = React.useState<string>(getRenderKey())\n\n /**\n * Subscribe for locale/message changes\n *\n * I18n object from `@lingui/core` is the single source of truth for all i18n related\n * data (active locale, catalogs). When new messages are loaded or locale is changed\n * we need to trigger re-rendering of LinguiContext.Consumers.\n *\n * We call `setContext(makeContext())` after adding the observer in case the `change`\n * event would already have fired between the inital renderKey calculation and the\n * `useEffect` hook being called. This can happen if locales are loaded/activated\n * async.\n */\n React.useEffect(() => {\n const unsubscribe = i18n.on(\"change\", () => {\n setContext(makeContext())\n setRenderKey(getRenderKey())\n })\n if (renderKey === \"default\") {\n setRenderKey(getRenderKey())\n }\n if (forceRenderOnLocaleChange && renderKey === \"default\") {\n console.log(\n \"I18nProvider did not render. A call to i18n.activate still needs to happen or forceRenderOnLocaleChange must be set to false.\"\n )\n }\n return () => unsubscribe()\n }, [])\n\n if (forceRenderOnLocaleChange && renderKey === \"default\") return null\n\n return (\n <LinguiContext.Provider value={context} key={renderKey}>\n {children}\n </LinguiContext.Provider>\n )\n}\n","import React from \"react\"\n\n// match <tag>paired</tag> and <tag/> unpaired tags\nconst tagRe = /<([a-zA-Z0-9]+)>(.*?)<\\/\\1>|<([a-zA-Z0-9]+)\\/>/\nconst nlRe = /(?:\\r\\n|\\r|\\n)/g\n\n// For HTML, certain tags should omit their close tag. We keep a whitelist for\n// those special-case tags.\nconst voidElementTags = {\n area: true,\n base: true,\n br: true,\n col: true,\n embed: true,\n hr: true,\n img: true,\n input: true,\n keygen: true,\n link: true,\n meta: true,\n param: true,\n source: true,\n track: true,\n wbr: true,\n menuitem: true,\n}\n\n/**\n * `formatElements` - parse string and return tree of react elements\n *\n * `value` is string to be formatted with <tag>Paired<tag/> or <tag/> (unpaired)\n * placeholders. `elements` is a array of react elements which indexes\n * correspond to element indexes in formatted string\n */\nfunction formatElements(\n value: string,\n elements: { [key: string]: React.ReactElement<any> } = {}\n): string | Array<any> {\n const uniqueId = makeCounter(0, \"$lingui$\")\n const parts = value.replace(nlRe, \"\").split(tagRe)\n\n // no inline elements, return\n if (parts.length === 1) return value\n\n const tree = []\n\n const before = parts.shift()\n if (before) tree.push(before)\n\n for (const [index, children, after] of getElements(parts)) {\n let element = elements[index]\n\n if (!element || (voidElementTags[element.type as string] && children)) {\n if (!element) {\n console.error(\n `Can use element at index '${index}' as it is not declared in the original translation`\n )\n } else {\n console.error(\n `${element.type} is a void element tag therefore it must have no children`\n )\n }\n\n // ignore problematic element but push its children and elements after it\n element = React.createElement(React.Fragment)\n }\n\n tree.push(\n React.cloneElement(\n element,\n { key: uniqueId() },\n\n // format children for pair tags\n // unpaired tags might have children if it's a component passed as a variable\n children ? formatElements(children, elements) : element.props.children\n )\n )\n\n if (after) tree.push(after)\n }\n\n return tree\n}\n\n/*\n * `getElements` - return array of element indexes and element childrens\n *\n * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]\n * where:\n * - `pairedIndex` is index of paired element (undef for unpaired)\n * - `children` are children of paired element (undef for unpaired)\n * - `unpairedIndex` is index of unpaired element (undef for paired)\n * - `textAfter` is string after all elements (empty string, if there's nothing)\n *\n * `parts` length is always multiply of 4\n *\n * Returns: Array<[elementIndex, children, after]>\n */\nfunction getElements(parts) {\n if (!parts.length) return []\n\n const [paired, children, unpaired, after] = parts.slice(0, 4)\n\n return [[paired || unpaired, children || \"\", after]].concat(\n getElements(parts.slice(4, parts.length))\n )\n}\n\nconst makeCounter =\n (count = 0, prefix = \"\") =>\n () =>\n `${prefix}_${count++}`\n\nexport { formatElements }\n","import React from \"react\"\n\nimport { useLingui } from \"./I18nProvider\"\nimport { formatElements } from \"./format\"\n\nexport type TransRenderProps = {\n id?: string\n translation?: React.ReactNode\n children?: React.ReactNode\n message?: string | null\n isTranslated?: boolean\n}\n\nexport type TransProps = {\n id: string\n message?: string\n values: Record<string, unknown>\n components: { [key: string]: React.ElementType | any }\n formats?: Record<string, unknown>\n children?: React.ReactNode\n component?: React.ComponentType<TransRenderProps>\n render?: (props: TransRenderProps) => React.ReactElement<any, any> | null\n}\n\nexport function Trans(props: TransProps): React.ReactElement<any, any> | null {\n const { i18n, defaultComponent } = useLingui()\n const { render, component, id, message, formats } = props\n\n const values = { ...props.values }\n const components = { ...props.components }\n\n if (values) {\n /*\n Related discussion: https://github.com/lingui/js-lingui/issues/183\n\n Values *might* contain React elements with static content.\n They're replaced with <INDEX /> placeholders and added to `components`.\n\n Example:\n Translation: Hello {name}\n Values: { name: <strong>Jane</strong> }\n\n It'll become \"Hello <0 />\" with components=[<strong>Jane</strong>]\n */\n\n Object.keys(values).forEach((key) => {\n const value = values[key]\n if (!React.isValidElement(value)) return\n\n const index = Object.keys(components).length\n\n components[index] = value\n values[key] = `<${index}/>`\n })\n }\n\n const _translation: string =\n i18n && typeof i18n._ === \"function\"\n ? i18n._(id, values, { message, formats })\n : id // i18n provider isn't loaded at all\n\n const translation = _translation\n ? formatElements(_translation, components)\n : null\n\n if (render === null || component === null) {\n // Although `string` is a valid react element, types only allow `Element`\n // Upstream issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return translation as unknown as React.ReactElement<any, any>\n }\n\n const FallbackComponent = (defaultComponent ||\n React.Fragment) as React.ComponentType<any>\n\n const i18nProps = {\n id,\n message,\n translation,\n isTranslated: id !== translation && message !== translation,\n }\n\n // Validation of `render` and `component` props\n if (render && component) {\n console.error(\n \"You can't use both `component` and `render` prop at the same time. `component` is ignored.\"\n )\n } else if (render && typeof render !== \"function\") {\n console.error(\n `Invalid value supplied to prop \\`render\\`. It must be a function, provided ${render}`\n )\n } else if (component && typeof component !== \"function\") {\n // Apparently, both function components and class components are functions\n // See https://stackoverflow.com/a/41658173/1535540\n console.error(\n `Invalid value supplied to prop \\`component\\`. It must be a React component, provided ${component}`\n )\n return <FallbackComponent {...i18nProps}>{translation}</FallbackComponent>\n }\n\n // Rendering using a render prop\n if (typeof render === \"function\") {\n // Component: render={(props) => <a title={props.translation}>x</a>}\n return render(i18nProps)\n }\n\n // `component` prop has a higher precedence over `defaultComponent`\n const Component = (component || FallbackComponent) as React.ComponentType<any>\n const DefaultComponent = defaultComponent\n\n return DefaultComponent && !component ? (\n <DefaultComponent {...i18nProps}>{translation}</DefaultComponent>\n ) : (\n <Component>{translation}</Component>\n )\n}\n\nTrans.defaultProps = {\n values: {},\n components: {},\n}\n"],"names":["LinguiContext","React","createContext","useLingui","context","useContext","process","env","NODE_ENV","Error","withI18n","o","WrappedComponent","props","isValidElement","i18n","I18nProvider","defaultComponent","forceRenderOnLocaleChange","children","makeContext","getRenderKey","locale","setContext","useState","renderKey","setRenderKey","useEffect","unsubscribe","on","console","log","tagRe","nlRe","voidElementTags","area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","menuitem","formatElements","value","elements","uniqueId","makeCounter","parts","replace","split","length","tree","before","shift","push","index","after","getElements","element","type","error","createElement","Fragment","cloneElement","key","paired","unpaired","slice","concat","count","prefix","Trans","render","component","id","message","formats","values","components","Object","keys","forEach","_translation","_","translation","FallbackComponent","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AAU,EAAE;AACjDnD,IAAAA,OAAO,CAACuC,KAAK,CACV,CAA6EY,2EAAAA,EAAAA,MAAO,EAAC,CACvF,CAAA;GACF,MAAM,IAAIC,SAAS,IAAI,OAAOA,SAAS,KAAK,UAAU,EAAE;AACvD;AACA;AACApD,IAAAA,OAAO,CAACuC,KAAK,CACV,CAAuFa,qFAAAA,EAAAA,SAAU,EAAC,CACpG,CAAA;AACD,IAAA,oBAAO,oBAAC,iBAAiB,EAAKa,SAAS,EAAGF,WAAW,CAAqB,CAAA;AAC5E,GAAA;;AAEA;AACA,EAAA,IAAI,OAAOZ,MAAM,KAAK,UAAU,EAAE;AAChC;IACA,OAAOA,MAAM,CAACc,SAAS,CAAC,CAAA;AAC1B,GAAA;;AAEA;AACA,EAAA,MAAME,SAAS,GAAIf,SAAS,IAAIY,iBAA8C,CAAA;EAC9E,MAAMI,gBAAgB,GAAGjF,gBAAgB,CAAA;AAEzC,EAAA,OAAOiF,gBAAgB,IAAI,CAAChB,SAAS,gBACnC,oBAAC,gBAAgB,EAAKa,SAAS,EAAGF,WAAW,CAAoB,gBAEjE,oBAAC,SAAS,EAAA,IAAA,EAAEA,WAAW,CACxB,CAAA;AACH,CAAA;AAEAb,KAAK,CAACmB,YAAY,GAAG;EACnBb,MAAM,EAAE,EAAE;AACVC,EAAAA,UAAU,EAAE,EAAC;AACf,CAAC;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/I18nProvider.tsx","../../src/format.ts","../../src/Trans.tsx"],"sourcesContent":["import React, { ComponentType, FunctionComponent } from \"react\"\nimport { I18n } from \"@lingui/core\"\nimport { TransRenderProps } from \"./Trans\"\n\nexport type I18nContext = {\n i18n: I18n\n defaultComponent?: ComponentType<TransRenderProps>\n}\n\nexport type withI18nProps = {\n i18n: I18n\n}\n\nexport type I18nProviderProps = I18nContext & {\n forceRenderOnLocaleChange?: boolean\n children?: React.ReactNode\n}\n\nconst LinguiContext = React.createContext<I18nContext>(null)\n\nexport function useLingui(): I18nContext {\n const context = React.useContext<I18nContext>(LinguiContext)\n\n if (process.env.NODE_ENV !== \"production\") {\n if (context == null) {\n throw new Error(\"useLingui hook was used without I18nProvider.\")\n }\n }\n\n return context\n}\n\nexport function withI18n(\n o?: object\n): <P extends withI18nProps>(\n Component: ComponentType<P>\n) => React.ComponentType<Omit<P, \"i18n\">> {\n return <P extends withI18nProps>(\n WrappedComponent: ComponentType<P>\n ): ComponentType<P> => {\n return (props) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof o === \"function\" || React.isValidElement(o)) {\n throw new Error(\n \"withI18n([options]) takes options as a first argument, \" +\n \"but received React component itself. Without options, the Component \" +\n \"should be wrapped as withI18n()(Component), not withI18n(Component).\"\n )\n }\n }\n\n const { i18n } = useLingui()\n return <WrappedComponent {...props} i18n={i18n} />\n }\n }\n}\n\nexport const I18nProvider: FunctionComponent<I18nProviderProps> = ({\n i18n,\n defaultComponent,\n forceRenderOnLocaleChange = true,\n children,\n}) => {\n /**\n * We can't pass `i18n` object directly through context, because even when locale\n * or messages are changed, i18n object is still the same. Context provider compares\n * reference identity and suggested workaround is create a wrapper object every time\n * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.\n *\n * Due to this effect we also pass `defaultComponent` in the same context, instead\n * of creating a separate Provider/Consumer pair.\n *\n * We can't use useMemo hook either, because we want to recalculate value manually.\n */\n const makeContext = () => ({\n i18n,\n defaultComponent,\n })\n const getRenderKey = () => {\n return (\n forceRenderOnLocaleChange ? i18n.locale || \"default\" : \"default\"\n ) as string\n }\n\n const [context, setContext] = React.useState<I18nContext>(makeContext()),\n [renderKey, setRenderKey] = React.useState<string>(getRenderKey())\n\n /**\n * Subscribe for locale/message changes\n *\n * I18n object from `@lingui/core` is the single source of truth for all i18n related\n * data (active locale, catalogs). When new messages are loaded or locale is changed\n * we need to trigger re-rendering of LinguiContext.Consumers.\n *\n * We call `setContext(makeContext())` after adding the observer in case the `change`\n * event would already have fired between the inital renderKey calculation and the\n * `useEffect` hook being called. This can happen if locales are loaded/activated\n * async.\n */\n React.useEffect(() => {\n const unsubscribe = i18n.on(\"change\", () => {\n setContext(makeContext())\n setRenderKey(getRenderKey())\n })\n if (renderKey === \"default\") {\n setRenderKey(getRenderKey())\n }\n if (forceRenderOnLocaleChange && renderKey === \"default\") {\n console.log(\n \"I18nProvider did not render. A call to i18n.activate still needs to happen or forceRenderOnLocaleChange must be set to false.\"\n )\n }\n return () => unsubscribe()\n }, [])\n\n if (forceRenderOnLocaleChange && renderKey === \"default\") return null\n\n return (\n <LinguiContext.Provider value={context} key={renderKey}>\n {children}\n </LinguiContext.Provider>\n )\n}\n","import React from \"react\"\n\n// match <tag>paired</tag> and <tag/> unpaired tags\nconst tagRe = /<([a-zA-Z0-9]+)>(.*?)<\\/\\1>|<([a-zA-Z0-9]+)\\/>/\nconst nlRe = /(?:\\r\\n|\\r|\\n)/g\n\n// For HTML, certain tags should omit their close tag. We keep a whitelist for\n// those special-case tags.\nconst voidElementTags = {\n area: true,\n base: true,\n br: true,\n col: true,\n embed: true,\n hr: true,\n img: true,\n input: true,\n keygen: true,\n link: true,\n meta: true,\n param: true,\n source: true,\n track: true,\n wbr: true,\n menuitem: true,\n}\n\n/**\n * `formatElements` - parse string and return tree of react elements\n *\n * `value` is string to be formatted with <tag>Paired<tag/> or <tag/> (unpaired)\n * placeholders. `elements` is a array of react elements which indexes\n * correspond to element indexes in formatted string\n */\nfunction formatElements(\n value: string,\n elements: { [key: string]: React.ReactElement<any> } = {}\n): string | Array<any> {\n const uniqueId = makeCounter(0, \"$lingui$\")\n const parts = value.replace(nlRe, \"\").split(tagRe)\n\n // no inline elements, return\n if (parts.length === 1) return value\n\n const tree = []\n\n const before = parts.shift()\n if (before) tree.push(before)\n\n for (const [index, children, after] of getElements(parts)) {\n let element = elements[index]\n\n if (!element || (voidElementTags[element.type as string] && children)) {\n if (!element) {\n console.error(\n `Can use element at index '${index}' as it is not declared in the original translation`\n )\n } else {\n console.error(\n `${element.type} is a void element tag therefore it must have no children`\n )\n }\n\n // ignore problematic element but push its children and elements after it\n element = React.createElement(React.Fragment)\n }\n\n tree.push(\n React.cloneElement(\n element,\n { key: uniqueId() },\n\n // format children for pair tags\n // unpaired tags might have children if it's a component passed as a variable\n children ? formatElements(children, elements) : element.props.children\n )\n )\n\n if (after) tree.push(after)\n }\n\n return tree\n}\n\n/*\n * `getElements` - return array of element indexes and element childrens\n *\n * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]\n * where:\n * - `pairedIndex` is index of paired element (undef for unpaired)\n * - `children` are children of paired element (undef for unpaired)\n * - `unpairedIndex` is index of unpaired element (undef for paired)\n * - `textAfter` is string after all elements (empty string, if there's nothing)\n *\n * `parts` length is always multiply of 4\n *\n * Returns: Array<[elementIndex, children, after]>\n */\nfunction getElements(parts) {\n if (!parts.length) return []\n\n const [paired, children, unpaired, after] = parts.slice(0, 4)\n\n return [[paired || unpaired, children || \"\", after]].concat(\n getElements(parts.slice(4, parts.length))\n )\n}\n\nconst makeCounter =\n (count = 0, prefix = \"\") =>\n () =>\n `${prefix}_${count++}`\n\nexport { formatElements }\n","import React from \"react\"\n\nimport { useLingui } from \"./I18nProvider\"\nimport { formatElements } from \"./format\"\n\nexport type TransRenderProps = {\n id?: string\n translation?: React.ReactNode\n children?: React.ReactNode\n message?: string | null\n isTranslated?: boolean\n}\n\nexport type TransProps = {\n id: string\n message?: string\n values: Record<string, unknown>\n context?: string\n components: { [key: string]: React.ElementType | any }\n formats?: Record<string, unknown>\n children?: React.ReactNode\n component?: React.ComponentType<TransRenderProps>\n render?: (props: TransRenderProps) => React.ReactElement<any, any> | null\n}\n\nexport function Trans(props: TransProps): React.ReactElement<any, any> | null {\n const { i18n, defaultComponent } = useLingui()\n const { render, component, id, message, formats } = props\n\n const values = { ...props.values }\n const components = { ...props.components }\n\n if (values) {\n /*\n Related discussion: https://github.com/lingui/js-lingui/issues/183\n\n Values *might* contain React elements with static content.\n They're replaced with <INDEX /> placeholders and added to `components`.\n\n Example:\n Translation: Hello {name}\n Values: { name: <strong>Jane</strong> }\n\n It'll become \"Hello <0 />\" with components=[<strong>Jane</strong>]\n */\n\n Object.keys(values).forEach((key) => {\n const value = values[key]\n if (!React.isValidElement(value)) return\n\n const index = Object.keys(components).length\n\n components[index] = value\n values[key] = `<${index}/>`\n })\n }\n\n const _translation: string =\n i18n && typeof i18n._ === \"function\"\n ? i18n._(id, values, { message, formats })\n : id // i18n provider isn't loaded at all\n\n const translation = _translation\n ? formatElements(_translation, components)\n : null\n\n if (render === null || component === null) {\n // Although `string` is a valid react element, types only allow `Element`\n // Upstream issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return translation as unknown as React.ReactElement<any, any>\n }\n\n const FallbackComponent = (defaultComponent ||\n React.Fragment) as React.ComponentType<any>\n\n const i18nProps = {\n id,\n message,\n translation,\n isTranslated: id !== translation && message !== translation,\n }\n\n // Validation of `render` and `component` props\n if (render && component) {\n console.error(\n \"You can't use both `component` and `render` prop at the same time. `component` is ignored.\"\n )\n } else if (render && typeof render !== \"function\") {\n console.error(\n `Invalid value supplied to prop \\`render\\`. It must be a function, provided ${render}`\n )\n } else if (component && typeof component !== \"function\") {\n // Apparently, both function components and class components are functions\n // See https://stackoverflow.com/a/41658173/1535540\n console.error(\n `Invalid value supplied to prop \\`component\\`. It must be a React component, provided ${component}`\n )\n return <FallbackComponent {...i18nProps}>{translation}</FallbackComponent>\n }\n\n // Rendering using a render prop\n if (typeof render === \"function\") {\n // Component: render={(props) => <a title={props.translation}>x</a>}\n return render(i18nProps)\n }\n\n // `component` prop has a higher precedence over `defaultComponent`\n const Component = (component || FallbackComponent) as React.ComponentType<any>\n const DefaultComponent = defaultComponent\n\n return DefaultComponent && !component ? (\n <DefaultComponent {...i18nProps}>{translation}</DefaultComponent>\n ) : (\n <Component>{translation}</Component>\n )\n}\n\nTrans.defaultProps = {\n values: {},\n components: {},\n}\n"],"names":["LinguiContext","React","createContext","useLingui","context","useContext","process","env","NODE_ENV","Error","withI18n","o","WrappedComponent","props","isValidElement","i18n","I18nProvider","defaultComponent","forceRenderOnLocaleChange","children","makeContext","getRenderKey","locale","setContext","useState","renderKey","setRenderKey","useEffect","unsubscribe","on","console","log","tagRe","nlRe","voidElementTags","area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","menuitem","formatElements","value","elements","uniqueId","makeCounter","parts","replace","split","length","tree","before","shift","push","index","after","getElements","element","type","error","createElement","Fragment","cloneElement","key","paired","unpaired","slice","concat","count","prefix","Trans","render","component","id","message","formats","values","components","Object","keys","forEach","_translation","_","translation","FallbackComponent","i18nProps","isTranslated","Component","DefaultComponent","defaultProps"],"mappings":";;;AAkBA,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAa,CAAc,IAAI,CAAC,CAAA;AAErD,SAASC,SAAS,GAAgB;AACvC,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAAcL,aAAa,CAAC,CAAA;AAE5D,EAAA,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAIJ,OAAO,IAAI,IAAI,EAAE;AACnB,MAAA,MAAM,IAAIK,KAAK,CAAC,+CAA+C,CAAC,CAAA;AAClE,KAAA;AACF,GAAA;AAEA,EAAA,OAAOL,OAAO,CAAA;AAChB,CAAA;AAEO,SAASM,QAAQ,CACtBC,CAAU,EAG8B;AACxC,EAAA,OACEC,gBAAkC,IACb;AACrB,IAAA,OAAQC,KAAK,IAAK;AAChB,MAAA,IAAIP,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,OAAOG,CAAC,KAAK,UAAU,iBAAIV,KAAK,CAACa,cAAc,CAACH,CAAC,CAAC,EAAE;UACtD,MAAM,IAAIF,KAAK,CACb,yDAAyD,GACvD,sEAAsE,GACtE,sEAAsE,CACzE,CAAA;AACH,SAAA;AACF,OAAA;MAEA,MAAM;AAAEM,QAAAA,IAAAA;OAAM,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}
1
+ {"version":3,"file":"index.js","sources":["../../src/I18nProvider.tsx","../../src/format.ts","../../src/Trans.tsx"],"sourcesContent":["import React, { ComponentType, FunctionComponent } from \"react\"\nimport { I18n } from \"@lingui/core\"\nimport { TransRenderProps } from \"./Trans\"\n\nexport type I18nContext = {\n i18n: I18n\n defaultComponent?: ComponentType<TransRenderProps>\n}\n\nexport type withI18nProps = {\n i18n: I18n\n}\n\nexport type I18nProviderProps = I18nContext & {\n forceRenderOnLocaleChange?: boolean\n children?: React.ReactNode\n}\n\nconst LinguiContext = React.createContext<I18nContext>(null)\n\nexport function useLingui(): I18nContext {\n const context = React.useContext<I18nContext>(LinguiContext)\n\n if (process.env.NODE_ENV !== \"production\") {\n if (context == null) {\n throw new Error(\"useLingui hook was used without I18nProvider.\")\n }\n }\n\n return context\n}\n\nexport function withI18n(\n o?: object\n): <P extends withI18nProps>(\n Component: ComponentType<P>\n) => React.ComponentType<Omit<P, \"i18n\">> {\n return <P extends withI18nProps>(\n WrappedComponent: ComponentType<P>\n ): ComponentType<P> => {\n return (props) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (typeof o === \"function\" || React.isValidElement(o)) {\n throw new Error(\n \"withI18n([options]) takes options as a first argument, \" +\n \"but received React component itself. Without options, the Component \" +\n \"should be wrapped as withI18n()(Component), not withI18n(Component).\"\n )\n }\n }\n\n const { i18n } = useLingui()\n return <WrappedComponent {...props} i18n={i18n} />\n }\n }\n}\n\nexport const I18nProvider: FunctionComponent<I18nProviderProps> = ({\n i18n,\n defaultComponent,\n forceRenderOnLocaleChange = true,\n children,\n}) => {\n /**\n * We can't pass `i18n` object directly through context, because even when locale\n * or messages are changed, i18n object is still the same. Context provider compares\n * reference identity and suggested workaround is create a wrapper object every time\n * we need to trigger re-render. See https://reactjs.org/docs/context.html#caveats.\n *\n * Due to this effect we also pass `defaultComponent` in the same context, instead\n * of creating a separate Provider/Consumer pair.\n *\n * We can't use useMemo hook either, because we want to recalculate value manually.\n */\n const makeContext = () => ({\n i18n,\n defaultComponent,\n })\n const getRenderKey = () => {\n return (\n forceRenderOnLocaleChange ? i18n.locale || \"default\" : \"default\"\n ) as string\n }\n\n const [context, setContext] = React.useState<I18nContext>(makeContext()),\n [renderKey, setRenderKey] = React.useState<string>(getRenderKey())\n\n /**\n * Subscribe for locale/message changes\n *\n * I18n object from `@lingui/core` is the single source of truth for all i18n related\n * data (active locale, catalogs). When new messages are loaded or locale is changed\n * we need to trigger re-rendering of LinguiContext.Consumers.\n *\n * We call `setContext(makeContext())` after adding the observer in case the `change`\n * event would already have fired between the inital renderKey calculation and the\n * `useEffect` hook being called. This can happen if locales are loaded/activated\n * async.\n */\n React.useEffect(() => {\n const unsubscribe = i18n.on(\"change\", () => {\n setContext(makeContext())\n setRenderKey(getRenderKey())\n })\n if (renderKey === \"default\") {\n setRenderKey(getRenderKey())\n }\n if (forceRenderOnLocaleChange && renderKey === \"default\") {\n console.log(\n \"I18nProvider did not render. A call to i18n.activate still needs to happen or forceRenderOnLocaleChange must be set to false.\"\n )\n }\n return () => unsubscribe()\n }, [])\n\n if (forceRenderOnLocaleChange && renderKey === \"default\") return null\n\n return (\n <LinguiContext.Provider value={context} key={renderKey}>\n {children}\n </LinguiContext.Provider>\n )\n}\n","import React from \"react\"\n\n// match <tag>paired</tag> and <tag/> unpaired tags\nconst tagRe = /<([a-zA-Z0-9]+)>(.*?)<\\/\\1>|<([a-zA-Z0-9]+)\\/>/\nconst nlRe = /(?:\\r\\n|\\r|\\n)/g\n\n// For HTML, certain tags should omit their close tag. We keep a whitelist for\n// those special-case tags.\nconst voidElementTags = {\n area: true,\n base: true,\n br: true,\n col: true,\n embed: true,\n hr: true,\n img: true,\n input: true,\n keygen: true,\n link: true,\n meta: true,\n param: true,\n source: true,\n track: true,\n wbr: true,\n menuitem: true,\n}\n\n/**\n * `formatElements` - parse string and return tree of react elements\n *\n * `value` is string to be formatted with <tag>Paired<tag/> or <tag/> (unpaired)\n * placeholders. `elements` is a array of react elements which indexes\n * correspond to element indexes in formatted string\n */\nfunction formatElements(\n value: string,\n elements: { [key: string]: React.ReactElement<any> } = {}\n): string | Array<any> {\n const uniqueId = makeCounter(0, \"$lingui$\")\n const parts = value.replace(nlRe, \"\").split(tagRe)\n\n // no inline elements, return\n if (parts.length === 1) return value\n\n const tree = []\n\n const before = parts.shift()\n if (before) tree.push(before)\n\n for (const [index, children, after] of getElements(parts)) {\n let element = elements[index]\n\n if (!element || (voidElementTags[element.type as string] && children)) {\n if (!element) {\n console.error(\n `Can use element at index '${index}' as it is not declared in the original translation`\n )\n } else {\n console.error(\n `${element.type} is a void element tag therefore it must have no children`\n )\n }\n\n // ignore problematic element but push its children and elements after it\n element = React.createElement(React.Fragment)\n }\n\n tree.push(\n React.cloneElement(\n element,\n { key: uniqueId() },\n\n // format children for pair tags\n // unpaired tags might have children if it's a component passed as a variable\n children ? formatElements(children, elements) : element.props.children\n )\n )\n\n if (after) tree.push(after)\n }\n\n return tree\n}\n\n/*\n * `getElements` - return array of element indexes and element childrens\n *\n * `parts` is array of [pairedIndex, children, unpairedIndex, textAfter, ...]\n * where:\n * - `pairedIndex` is index of paired element (undef for unpaired)\n * - `children` are children of paired element (undef for unpaired)\n * - `unpairedIndex` is index of unpaired element (undef for paired)\n * - `textAfter` is string after all elements (empty string, if there's nothing)\n *\n * `parts` length is always multiply of 4\n *\n * Returns: Array<[elementIndex, children, after]>\n */\nfunction getElements(parts) {\n if (!parts.length) return []\n\n const [paired, children, unpaired, after] = parts.slice(0, 4)\n\n return [[paired || unpaired, children || \"\", after]].concat(\n getElements(parts.slice(4, parts.length))\n )\n}\n\nconst makeCounter =\n (count = 0, prefix = \"\") =>\n () =>\n `${prefix}_${count++}`\n\nexport { formatElements }\n","import React from \"react\"\n\nimport { useLingui } from \"./I18nProvider\"\nimport { formatElements } from \"./format\"\n\nexport type TransRenderProps = {\n id?: string\n translation?: React.ReactNode\n children?: React.ReactNode\n message?: string | null\n isTranslated?: boolean\n}\n\nexport type TransProps = {\n id: string\n message?: string\n values: Record<string, unknown>\n components: { [key: string]: React.ElementType | any }\n formats?: Record<string, unknown>\n children?: React.ReactNode\n component?: React.ComponentType<TransRenderProps>\n render?: (props: TransRenderProps) => React.ReactElement<any, any> | null\n}\n\nexport function Trans(props: TransProps): React.ReactElement<any, any> | null {\n const { i18n, defaultComponent } = useLingui()\n const { render, component, id, message, formats } = props\n\n const values = { ...props.values }\n const components = { ...props.components }\n\n if (values) {\n /*\n Related discussion: https://github.com/lingui/js-lingui/issues/183\n\n Values *might* contain React elements with static content.\n They're replaced with <INDEX /> placeholders and added to `components`.\n\n Example:\n Translation: Hello {name}\n Values: { name: <strong>Jane</strong> }\n\n It'll become \"Hello <0 />\" with components=[<strong>Jane</strong>]\n */\n\n Object.keys(values).forEach((key) => {\n const value = values[key]\n if (!React.isValidElement(value)) return\n\n const index = Object.keys(components).length\n\n components[index] = value\n values[key] = `<${index}/>`\n })\n }\n\n const _translation: string =\n i18n && typeof i18n._ === \"function\"\n ? i18n._(id, values, { message, formats })\n : id // i18n provider isn't loaded at all\n\n const translation = _translation\n ? formatElements(_translation, components)\n : null\n\n if (render === null || component === null) {\n // Although `string` is a valid react element, types only allow `Element`\n // Upstream issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544\n return translation as unknown as React.ReactElement<any, any>\n }\n\n const FallbackComponent = (defaultComponent ||\n React.Fragment) as React.ComponentType<any>\n\n const i18nProps = {\n id,\n message,\n translation,\n isTranslated: id !== translation && message !== translation,\n }\n\n // Validation of `render` and `component` props\n if (render && component) {\n console.error(\n \"You can't use both `component` and `render` prop at the same time. `component` is ignored.\"\n )\n } else if (render && typeof render !== \"function\") {\n console.error(\n `Invalid value supplied to prop \\`render\\`. It must be a function, provided ${render}`\n )\n } else if (component && typeof component !== \"function\") {\n // Apparently, both function components and class components are functions\n // See https://stackoverflow.com/a/41658173/1535540\n console.error(\n `Invalid value supplied to prop \\`component\\`. It must be a React component, provided ${component}`\n )\n return <FallbackComponent {...i18nProps}>{translation}</FallbackComponent>\n }\n\n // Rendering using a render prop\n if (typeof render === \"function\") {\n // Component: render={(props) => <a title={props.translation}>x</a>}\n return render(i18nProps)\n }\n\n // `component` prop has a higher precedence over `defaultComponent`\n const Component = (component || FallbackComponent) as React.ComponentType<any>\n const DefaultComponent = defaultComponent\n\n return DefaultComponent && !component ? (\n <DefaultComponent {...i18nProps}>{translation}</DefaultComponent>\n ) : (\n <Component>{translation}</Component>\n )\n}\n\nTrans.defaultProps = {\n values: {},\n components: {},\n}\n"],"names":["LinguiContext","React","createContext","useLingui","context","useContext","process","env","NODE_ENV","Error","withI18n","o","WrappedComponent","props","isValidElement","i18n","I18nProvider","defaultComponent","forceRenderOnLocaleChange","children","makeContext","getRenderKey","locale","setContext","useState","renderKey","setRenderKey","useEffect","unsubscribe","on","console","log","tagRe","nlRe","voidElementTags","area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr","menuitem","formatElements","value","elements","uniqueId","makeCounter","parts","replace","split","length","tree","before","shift","push","index","after","getElements","element","type","error","createElement","Fragment","cloneElement","key","paired","unpaired","slice","concat","count","prefix","Trans","render","component","id","message","formats","values","components","Object","keys","forEach","_translation","_","translation","FallbackComponent","i18nProps","isTranslated","Component","DefaultComponent","defaultProps"],"mappings":";;;AAkBA,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAa,CAAc,IAAI,CAAC,CAAA;AAErD,SAASC,SAAS,GAAgB;AACvC,EAAA,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAAcL,aAAa,CAAC,CAAA;AAE5D,EAAA,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAIJ,OAAO,IAAI,IAAI,EAAE;AACnB,MAAA,MAAM,IAAIK,KAAK,CAAC,+CAA+C,CAAC,CAAA;AAClE,KAAA;AACF,GAAA;AAEA,EAAA,OAAOL,OAAO,CAAA;AAChB,CAAA;AAEO,SAASM,QAAQ,CACtBC,CAAU,EAG8B;AACx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f,SAAS,IAAIY,iBAA8C,CAAA;EAC9E,MAAMI,gBAAgB,GAAGjF,gBAAgB,CAAA;AAEzC,EAAA,OAAOiF,gBAAgB,IAAI,CAAChB,SAAS,gBACnC,oBAAC,gBAAgB,EAAKa,SAAS,EAAGF,WAAW,CAAoB,gBAEjE,oBAAC,SAAS,EAAA,IAAA,EAAEA,WAAW,CACxB,CAAA;AACH,CAAA;AAEAb,KAAK,CAACmB,YAAY,GAAG;EACnBb,MAAM,EAAE,EAAE;AACVC,EAAAA,UAAU,EAAE,EAAC;AACf,CAAC;;;;"}
package/build/index.d.ts CHANGED
@@ -12,7 +12,6 @@ type TransProps = {
12
12
  id: string;
13
13
  message?: string;
14
14
  values: Record<string, unknown>;
15
- context?: string;
16
15
  components: {
17
16
  [key: string]: React.ElementType | any;
18
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/react",
3
- "version": "3.17.2",
3
+ "version": "4.0.0-next.0",
4
4
  "sideEffects": false,
5
5
  "description": "React components for translations",
6
6
  "main": "./build/cjs/index.js",
@@ -29,7 +29,7 @@
29
29
  "url": "https://github.com/lingui/js-lingui/issues"
30
30
  },
31
31
  "engines": {
32
- "node": ">=14.0.0"
32
+ "node": ">=16.0.0"
33
33
  },
34
34
  "exports": {
35
35
  ".": {
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@babel/runtime": "^7.20.13",
57
- "@lingui/core": "3.17.2"
57
+ "@lingui/core": "^4.0.0-next.0"
58
58
  },
59
59
  "devDependencies": {
60
- "react-testing-library": "^8.0.1"
60
+ "@testing-library/react": "^11.0.4"
61
61
  },
62
- "gitHead": "31dcab5a9a8f88bfa8b3a2c7cd12aa2d908a1d80"
62
+ "gitHead": "637f5cf6beda9d4ebce4e15cd9fdaa23e404b660"
63
63
  }
package/CHANGELOG.md DELETED
@@ -1,402 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [3.17.2](https://github.com/lingui/js-lingui/compare/v3.17.1...v3.17.2) (2023-02-24)
7
-
8
- **Note:** Version bump only for package @lingui/react
9
-
10
-
11
-
12
-
13
-
14
- ## [3.17.1](https://github.com/lingui/js-lingui/compare/v3.17.0...v3.17.1) (2023-02-07)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * Named components not working in Trans in @lingui/react ([#1402](https://github.com/lingui/js-lingui/issues/1402)) ([bf7f655](https://github.com/lingui/js-lingui/commit/bf7f655ccac3fc22fb7d36662ab0ec96595574e5))
20
-
21
-
22
-
23
-
24
-
25
- # [3.17.0](https://github.com/lingui/js-lingui/compare/v3.16.1...v3.17.0) (2023-02-01)
26
-
27
- **Note:** Version bump only for package @lingui/react
28
-
29
-
30
-
31
-
32
-
33
- ## [3.16.1](https://github.com/lingui/js-lingui/compare/v3.16.0...v3.16.1) (2023-01-24)
34
-
35
- **Note:** Version bump only for package @lingui/react
36
-
37
-
38
-
39
-
40
-
41
- # [3.16.0](https://github.com/lingui/js-lingui/compare/v3.15.0...v3.16.0) (2023-01-18)
42
-
43
- **Note:** Version bump only for package @lingui/react
44
-
45
-
46
-
47
-
48
-
49
- # [3.15.0](https://github.com/lingui/js-lingui/compare/v3.14.0...v3.15.0) (2022-11-07)
50
-
51
- **Note:** Version bump only for package @lingui/react
52
-
53
-
54
-
55
-
56
-
57
- # [3.14.0](https://github.com/lingui/js-lingui/compare/v3.13.3...v3.14.0) (2022-06-22)
58
-
59
-
60
- ### Bug Fixes
61
-
62
- * Add extra package.json under `/esm` ([#1258](https://github.com/lingui/js-lingui/issues/1258)) ([80cd337](https://github.com/lingui/js-lingui/commit/80cd3378ceb5677bfa50b14f67e4e31703392298))
63
-
64
-
65
- ### Features
66
-
67
- * Pass props to I18nProvider.defaultComponent in Trans.render style ([#1242](https://github.com/lingui/js-lingui/issues/1242)) ([fe4cac4](https://github.com/lingui/js-lingui/commit/fe4cac4f89ae195ad8b5216fdaede73900753686))
68
-
69
-
70
-
71
-
72
-
73
- ## [3.13.3](https://github.com/lingui/js-lingui/compare/v3.13.2...v3.13.3) (2022-04-24)
74
-
75
-
76
- ### Bug Fixes
77
-
78
- * @lingui/react compatible with React 18 ([2a235ba](https://github.com/lingui/js-lingui/commit/2a235baa093d668a0a029ec6c683e9dc00f68f42))
79
- * specify children for react v18 types ([#1230](https://github.com/lingui/js-lingui/issues/1230)) ([ee69736](https://github.com/lingui/js-lingui/commit/ee69736089d4c48117d85582b56a26c09cdf82ea))
80
-
81
-
82
-
83
-
84
-
85
- ## [3.13.2](https://github.com/lingui/js-lingui/compare/v3.13.1...v3.13.2) (2022-01-24)
86
-
87
- **Note:** Version bump only for package @lingui/react
88
-
89
-
90
-
91
-
92
-
93
- ## [3.13.1](https://github.com/lingui/js-lingui/compare/v3.13.0...v3.13.1) (2022-01-21)
94
-
95
-
96
- ### Bug Fixes
97
-
98
- * i18n.activate should load instantly new messages ([#1182](https://github.com/lingui/js-lingui/issues/1182)) ([f8f47a2](https://github.com/lingui/js-lingui/commit/f8f47a2385fe3d8dd3395c493027de2492509325))
99
-
100
-
101
-
102
-
103
-
104
- # [3.13.0](https://github.com/lingui/js-lingui/compare/v3.12.1...v3.13.0) (2021-11-26)
105
-
106
-
107
- ### Features
108
-
109
- * msgctxt support ([#1094](https://github.com/lingui/js-lingui/issues/1094)) ([8ee42cb](https://github.com/lingui/js-lingui/commit/8ee42cbfe26bc6d055748dcf2713ab8ade7ec827))
110
-
111
-
112
-
113
-
114
-
115
- ## [3.12.1](https://github.com/lingui/js-lingui/compare/v3.12.0...v3.12.1) (2021-09-28)
116
-
117
- **Note:** Version bump only for package @lingui/react
118
-
119
-
120
-
121
-
122
-
123
- # [3.12.0](https://github.com/lingui/js-lingui/compare/v3.11.1...v3.12.0) (2021-09-28)
124
-
125
- **Note:** Version bump only for package @lingui/react
126
-
127
-
128
-
129
-
130
-
131
- ## [3.11.1](https://github.com/lingui/js-lingui/compare/v3.11.0...v3.11.1) (2021-09-07)
132
-
133
- **Note:** Version bump only for package @lingui/react
134
-
135
-
136
-
137
-
138
-
139
- # [3.11.0](https://github.com/lingui/js-lingui/compare/v3.10.4...v3.11.0) (2021-09-07)
140
-
141
-
142
- ### Bug Fixes
143
-
144
- * sideEffects to false for shrinking bundle size ([#1129](https://github.com/lingui/js-lingui/issues/1129)) ([57cd2e5](https://github.com/lingui/js-lingui/commit/57cd2e576945ba30aea30d5cf5bcb27d1f77fe4c))
145
-
146
-
147
-
148
-
149
-
150
- ## [3.10.4](https://github.com/lingui/js-lingui/compare/v3.10.3...v3.10.4) (2021-06-16)
151
-
152
- **Note:** Version bump only for package @lingui/react
153
-
154
-
155
-
156
-
157
-
158
- ## [3.10.3](https://github.com/lingui/js-lingui/compare/v3.10.2...v3.10.3) (2021-06-14)
159
-
160
- **Note:** Version bump only for package @lingui/react
161
-
162
-
163
-
164
-
165
-
166
- ## [3.10.2](https://github.com/lingui/js-lingui/compare/v3.10.1...v3.10.2) (2021-06-08)
167
-
168
- **Note:** Version bump only for package @lingui/react
169
-
170
-
171
-
172
-
173
-
174
- ## [3.10.1](https://github.com/lingui/js-lingui/compare/v3.10.0...v3.10.1) (2021-06-08)
175
-
176
-
177
- ### Bug Fixes
178
-
179
- * reverts reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([3a057e0](https://github.com/lingui/js-lingui/commit/3a057e0c61224b98c93203e0d88136fa48f309ba))
180
-
181
-
182
-
183
-
184
-
185
- # [3.10.0](https://github.com/lingui/js-lingui/compare/v3.9.0...v3.10.0) (2021-06-08)
186
-
187
-
188
- ### Bug Fixes
189
-
190
- * reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([9990eba](https://github.com/lingui/js-lingui/commit/9990ebaa9d30f7e218c106a2abfd7ddbcf0e0170))
191
-
192
-
193
-
194
-
195
-
196
- # [3.9.0](https://github.com/lingui/js-lingui/compare/v3.8.10...v3.9.0) (2021-05-18)
197
-
198
- **Note:** Version bump only for package @lingui/react
199
-
200
-
201
-
202
-
203
-
204
- ## [3.8.10](https://github.com/lingui/js-lingui/compare/v3.8.9...v3.8.10) (2021-04-19)
205
-
206
- **Note:** Version bump only for package @lingui/react
207
-
208
-
209
-
210
-
211
-
212
- ## [3.8.9](https://github.com/lingui/js-lingui/compare/v3.8.8...v3.8.9) (2021-04-09)
213
-
214
-
215
- ### Bug Fixes
216
-
217
- * event emitter refactor (reverted) ([#1038](https://github.com/lingui/js-lingui/issues/1038)) ([f299493](https://github.com/lingui/js-lingui/commit/f299493999299fe9a7d0e01b9045e7f0a9813c6a))
218
-
219
-
220
-
221
-
222
-
223
- ## [3.8.8](https://github.com/lingui/js-lingui/compare/v3.8.7...v3.8.8) (2021-04-09)
224
-
225
- **Note:** Version bump only for package @lingui/react
226
-
227
-
228
-
229
-
230
-
231
- ## [3.8.7](https://github.com/lingui/js-lingui/compare/v3.8.6...v3.8.7) (2021-04-09)
232
-
233
-
234
- ### Bug Fixes
235
-
236
- * unicode chars in native environments + event emitter refactor ([#1036](https://github.com/lingui/js-lingui/issues/1036)) ([39fa90d](https://github.com/lingui/js-lingui/commit/39fa90d95c08f105f3f7feb17b65d9b8f916b73a))
237
-
238
-
239
-
240
-
241
-
242
- ## [3.8.6](https://github.com/lingui/js-lingui/compare/v3.8.5...v3.8.6) (2021-04-08)
243
-
244
- **Note:** Version bump only for package @lingui/react
245
-
246
-
247
-
248
-
249
-
250
- ## [3.8.5](https://github.com/lingui/js-lingui/compare/v3.8.4...v3.8.5) (2021-04-08)
251
-
252
- **Note:** Version bump only for package @lingui/react
253
-
254
-
255
-
256
-
257
-
258
- ## [3.8.4](https://github.com/lingui/js-lingui/compare/v3.8.3...v3.8.4) (2021-04-08)
259
-
260
- **Note:** Version bump only for package @lingui/react
261
-
262
-
263
-
264
-
265
-
266
- ## [3.8.3](https://github.com/lingui/js-lingui/compare/v3.8.2...v3.8.3) (2021-04-05)
267
-
268
- **Note:** Version bump only for package @lingui/react
269
-
270
-
271
-
272
-
273
-
274
- ## [3.8.2](https://github.com/lingui/js-lingui/compare/v3.8.1...v3.8.2) (2021-03-31)
275
-
276
- **Note:** Version bump only for package @lingui/react
277
-
278
-
279
-
280
-
281
-
282
- ## [3.8.1](https://github.com/lingui/js-lingui/compare/v3.8.0...v3.8.1) (2021-03-23)
283
-
284
- **Note:** Version bump only for package @lingui/react
285
-
286
-
287
-
288
-
289
-
290
- # [3.8.0](https://github.com/lingui/js-lingui/compare/v3.7.2...v3.8.0) (2021-03-23)
291
-
292
- **Note:** Version bump only for package @lingui/react
293
-
294
-
295
-
296
-
297
-
298
- ## [3.7.2](https://github.com/lingui/js-lingui/compare/v3.7.1...v3.7.2) (2021-03-14)
299
-
300
- **Note:** Version bump only for package @lingui/react
301
-
302
-
303
-
304
-
305
-
306
- ## [3.7.1](https://github.com/lingui/js-lingui/compare/v3.7.0...v3.7.1) (2021-03-07)
307
-
308
- **Note:** Version bump only for package @lingui/react
309
-
310
-
311
-
312
-
313
-
314
- # [3.7.0](https://github.com/lingui/js-lingui/compare/v3.6.0...v3.7.0) (2021-03-04)
315
-
316
- **Note:** Version bump only for package @lingui/react
317
-
318
-
319
-
320
-
321
-
322
- # [3.6.0](https://github.com/lingui/js-lingui/compare/v3.5.1...v3.6.0) (2021-02-23)
323
-
324
-
325
- ### Features
326
-
327
- * ship universal modules with ESM ([#979](https://github.com/lingui/js-lingui/issues/979)) ([6cd5fe0](https://github.com/lingui/js-lingui/commit/6cd5fe0a71dd5cf7e0832bd3e9902a2f6ba789f6))
328
-
329
-
330
-
331
-
332
-
333
- ## [3.5.1](https://github.com/lingui/js-lingui/compare/v3.5.0...v3.5.1) (2021-02-09)
334
-
335
- **Note:** Version bump only for package @lingui/react
336
-
337
-
338
-
339
-
340
-
341
- # [3.5.0](https://github.com/lingui/js-lingui/compare/v3.4.0...v3.5.0) (2021-02-02)
342
-
343
-
344
- ### Bug Fixes
345
-
346
- * **docs:** documentation-typos ([#955](https://github.com/lingui/js-lingui/issues/955)) ([f73cb8c](https://github.com/lingui/js-lingui/commit/f73cb8c09d9919489f5fbb9a539da30faae53004))
347
- * I18nProvider defaultComponent typing ([#953](https://github.com/lingui/js-lingui/issues/953)) ([6b08dd3](https://github.com/lingui/js-lingui/commit/6b08dd309d1ac8e0a8dc081e097e69678e822eda))
348
-
349
-
350
-
351
-
352
-
353
- # [3.4.0](https://github.com/lingui/js-lingui/compare/v3.3.0...v3.4.0) (2021-01-13)
354
-
355
- **Note:** Version bump only for package @lingui/react
356
-
357
-
358
-
359
-
360
-
361
- # [3.3.0](https://github.com/lingui/js-lingui/compare/v3.2.3...v3.3.0) (2020-12-08)
362
-
363
- **Note:** Version bump only for package @lingui/react
364
-
365
-
366
-
367
-
368
-
369
- ## [3.2.3](https://github.com/lingui/js-lingui/compare/v3.2.2...v3.2.3) (2020-11-22)
370
-
371
-
372
- ### Bug Fixes
373
-
374
- * export TransRenderProps from @lingui/react ([#877](https://github.com/lingui/js-lingui/issues/877)) ([3db9d6b](https://github.com/lingui/js-lingui/commit/3db9d6b0bfe9edae99523cd706de6826f67184ad))
375
- * omit i18n prop in withI18n typescript interface ([#879](https://github.com/lingui/js-lingui/issues/879)) ([5927d42](https://github.com/lingui/js-lingui/commit/5927d42b256d1adfb26ed03367e521bfc8f1e2e6))
376
-
377
-
378
-
379
-
380
-
381
- ## [3.2.2](https://github.com/lingui/js-lingui/compare/v3.2.1...v3.2.2) (2020-11-20)
382
-
383
- **Note:** Version bump only for package @lingui/react
384
-
385
-
386
-
387
-
388
-
389
- # [3.2.0](https://github.com/lingui/js-lingui/compare/v3.1.0...v3.2.0) (2020-11-12)
390
-
391
- **Note:** Version bump only for package @lingui/react
392
-
393
-
394
-
395
-
396
-
397
- # [3.1.0](https://github.com/lingui/js-lingui/compare/v3.0.3...v3.1.0) (2020-11-10)
398
-
399
-
400
- ### Bug Fixes
401
-
402
- * ensure render of I18nProvider in async scenarios ([#839](https://github.com/lingui/js-lingui/issues/839)) ([cd2816a](https://github.com/lingui/js-lingui/commit/cd2816a3d847042029c9b29dfb420f2ff5ae02cc))