UNPKG

@itwin/presentation-hierarchies-react

Version:

React components based on `@itwin/presentation-hierarchies`

38 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalizationContextProvider = LocalizationContextProvider; exports.useLocalizationContext = useLocalizationContext; const jsx_runtime_1 = require("react/jsx-runtime"); /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const react_1 = require("react"); const defaultLocalizedStrings = { loading: "Loading...", filterHierarchyLevel: "Apply filter", clearHierarchyLevelFilter: "Clear active filter", noFilteredChildren: "No child nodes match current filter", resultLimitExceeded: "There are more items than allowed limit of {{limit}}.", resultLimitExceededWithFiltering: "Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.", increaseHierarchyLimit: "<link>Increase the hierarchy level size limit to {{limit}}.</link>", increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>", retry: "Retry", }; const localizationContext = (0, react_1.createContext)({ localizedStrings: defaultLocalizedStrings }); /** * Context provider for localized strings used in the components. * @public */ function LocalizationContextProvider({ localizedStrings, children }) { const [state, setState] = (0, react_1.useState)({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } }); (0, react_1.useEffect)(() => { setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } }); }, [localizedStrings]); return (0, jsx_runtime_1.jsx)(localizationContext.Provider, { value: state, children: children }); } /** @internal */ function useLocalizationContext() { return (0, react_1.useContext)(localizationContext); } //# sourceMappingURL=LocalizationContext.js.map