@itwin/quantity-formatting-react
Version:
React components and utilities for quantity formatting
36 lines • 1.65 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 * as React from "react";
import { Select } from "@itwin/itwinui-react";
import { useTranslation } from "../../../../useTranslation.js";
/** Component use to set Quantity Format thousand group separator.
* @internal
*/
export function ThousandsSelector(props) {
const { separator, onChange, id } = props;
const { translate } = useTranslation();
const separatorOptions = React.useMemo(() => {
const uomDefaultEntries = [
{
value: ",",
label: translate("QuantityFormat:thousand_separator.comma"),
},
{
value: ".",
label: translate("QuantityFormat:thousand_separator.point"),
},
];
const completeListOfEntries = [];
if (undefined ===
uomDefaultEntries.find((option) => option.value === separator)) {
completeListOfEntries.push({ value: separator, label: separator });
}
completeListOfEntries.push(...uomDefaultEntries);
return completeListOfEntries;
}, [separator, translate]);
return (_jsx(Select, { options: separatorOptions, value: separator, size: "small", onChange: onChange, id: id }));
}
//# sourceMappingURL=ThousandsSelector.js.map