@itwin/presentation-hierarchies-react
Version:
React components based on `@itwin/presentation-hierarchies`
34 lines • 1.9 kB
JavaScript
import { jsx as _jsx } from "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.
*--------------------------------------------------------------------------------------------*/
import { createContext, useContext, useEffect, useState } from "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 = createContext({ localizedStrings: defaultLocalizedStrings });
/**
* Context provider for localized strings used in the components.
* @public
*/
export function LocalizationContextProvider({ localizedStrings, children }) {
const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
useEffect(() => {
setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });
}, [localizedStrings]);
return _jsx(localizationContext.Provider, { value: state, children: children });
}
/** @internal */
export function useLocalizationContext() {
return useContext(localizationContext);
}
//# sourceMappingURL=LocalizationContext.js.map