@itwin/imodel-components-react 4.16.5 → 4.17.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.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +2 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +1 -0
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +2 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +1 -0
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +1 -0
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAK/B,wDAO8B;AAO9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CACtC,GAAW,EACX,KAAa,EACb,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,G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,cAAc,EAAE,qBAAqB,KACjC,UAAU,EACd,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,yBAAS,CAAC,iBAAiB,CAAC,aAAa,EACxD,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CACG,CACP,CAAC;AACJ,CAAC;AAtKD,kDAsKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const { quantityType, onFormatChange, ...otherProps } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n onFormatChange={handleOnFormatChanged}\n {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAK/B,wDAO8B;AAO9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CACtC,GAAW,EACX,KAAa,EACb,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,GAAG,EAAE;QAC3B,8BAAM,GAAG,EAAE,GAAG,GAAG,QAAQ,EAAE,SAAS,EAAE,cAAc,IACjD,KAAK,CACD;QACP,oBAAC,qBAAK,mBACS,GAAG,GAAG,SAAS,EAC5B,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC3D,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,GACD,CACa,CAClB,CAAC;AACJ,CAAC;AACD,SAAS,4BAA4B,CACnC,GAAW,EACX,KAAa,EACb,OAA2C,EAC3C,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAA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CAAC,wBAAwB;gBACjD,OAAO,uBAAuB,CAC5B,sBAAsB,CAAC,wBAAwB,EAC/C,OAAO,EACP,gBAAgB,CACjB,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EACD,CAAC,uBAAuB,EAAE,YAAY,CAAC,CACxC,CAAC;IAEF,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,KAAK,EACH,OAAoB,EACpB,gBAA2B,EAC3B,cAA6B,EAC7B,EAAE;QACF,OAAO,yBAAS,CAAC,iBAAiB,CAAC,2BAA2B,CAC5D,YAAY,EACZ,OAAO,CACR,CAAC;IACJ,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC,IACrD,eAAe,IAAI,WAAW,IAAI,CACjC,oBAAC,yBAAW,IACV,cAAc,EAAE,qBAAqB,KACjC,UAAU,EACd,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,yBAAS,CAAC,iBAAiB,CAAC,aAAa,EACxD,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CACG,CACP,CAAC;AACJ,CAAC;AAtKD,kDAsKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof QuantityFormatPanel>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const { quantityType, onFormatChange, ...otherProps } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n onFormatChange={handleOnFormatChanged}\n {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import { FormatterSpec } from "@itwin/core-quantity";
|
|
|
8
8
|
import type { CommonProps } from "@itwin/core-react";
|
|
9
9
|
/** Properties of [[FormatPanel]] component.
|
|
10
10
|
* @alpha
|
|
11
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatPanel>`
|
|
11
12
|
*/
|
|
12
13
|
export interface FormatPanelProps extends CommonProps {
|
|
13
14
|
initialFormat: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPanel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPanel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,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AC;IACrB,wBAAwB,CAAC,EAAE,CACzB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,WAAW,KAAK,IAAI,KAC9C,KAAK,CAAC,SAAS,CAAC;CACtB;AAoBD;;GAEG;AAEH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAkHlD"}
|
|
@@ -21,6 +21,7 @@ async function generateFormatSpec(formatProps, persistenceUnit, unitsProvider) {
|
|
|
21
21
|
/** Component to show/edit Quantity Format.
|
|
22
22
|
* @alpha
|
|
23
23
|
*/
|
|
24
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
24
25
|
export function FormatPanel(props) {
|
|
25
26
|
const [formatSpec, setFormatSpec] = React.useState();
|
|
26
27
|
const { initialFormat, showSample, initialMagnitude, unitsProvider, persistenceUnit, onFormatChange, provideFormatSpec, enableMinimumProperties, } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPanel.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPanel.t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AC,CAC/C,CAChB,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport \"./FormatPanel.scss\";\nimport * as React from \"react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Format, FormatterSpec } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { FormatPrecision } from \"./FormatPrecision\";\nimport { FormatSample } from \"./FormatSample\";\nimport { FormatTypeOption } from \"./FormatType\";\nimport { FormatUnitLabel } from \"./FormatUnitLabel\";\nimport { FormatUnits } from \"./FormatUnits\";\nimport { MiscFormatOptions } from \"./MiscFormatOptions\";\n\n/** Properties of [[FormatPanel]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatPanel>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatPanelProps extends CommonProps {\n initialFormat: FormatProps;\n unitsProvider: UnitsProvider;\n persistenceUnit: Promise<UnitProps> | UnitProps;\n showSample?: boolean;\n initialMagnitude?: number;\n // if true a only primary format properties are initially displayed and a \"More/Less\" link is added.\n enableMinimumProperties?: boolean;\n onFormatChange?: (format: FormatProps) => void;\n provideFormatSpec?: (\n formatProps: FormatProps,\n persistenceUnit: UnitProps,\n unitsProvider: UnitsProvider\n ) => Promise<FormatterSpec>;\n providePrimaryChildren?: (\n formatProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => React.ReactNode;\n provideSecondaryChildren?: (\n formatProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => React.ReactNode;\n}\n\nasync function generateFormatSpec(\n formatProps: FormatProps,\n persistenceUnit: UnitProps,\n unitsProvider: UnitsProvider\n) {\n const actualFormat = await Format.createFromJSON(\n \"custom\",\n unitsProvider,\n formatProps\n );\n return FormatterSpec.create(\n actualFormat.name,\n actualFormat,\n unitsProvider,\n persistenceUnit\n );\n}\n\n/** Component to show/edit Quantity Format.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatPanel(props: FormatPanelProps) {\n const [formatSpec, setFormatSpec] = React.useState<FormatterSpec>();\n const {\n initialFormat,\n showSample,\n initialMagnitude,\n unitsProvider,\n persistenceUnit,\n onFormatChange,\n provideFormatSpec,\n enableMinimumProperties,\n } = props;\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n const [showOptions, setShowOptions] = React.useState(false);\n\n React.useEffect(() => {\n setFormatProps(initialFormat);\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\n }, [initialFormat]);\n\n const handleUserFormatChanges = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const isMounted = React.useRef(false);\n\n // runs returned function only when component is unmounted.\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n React.useEffect(() => {\n async function fetchFormatSpec() {\n const pu = await persistenceUnit;\n let newFormatSpec: FormatterSpec;\n if (provideFormatSpec) {\n newFormatSpec = await provideFormatSpec(formatProps, pu, unitsProvider);\n } else {\n newFormatSpec = await generateFormatSpec(\n formatProps,\n pu,\n unitsProvider\n );\n }\n isMounted.current && setFormatSpec(newFormatSpec);\n }\n if (!formatSpec) void fetchFormatSpec();\n }, [\n formatProps,\n formatSpec,\n persistenceUnit,\n provideFormatSpec,\n unitsProvider,\n ]);\n\n const handleFormatChange = React.useCallback(\n (newFormatProps: FormatProps) => {\n handleUserFormatChanges(newFormatProps);\n },\n [handleUserFormatChanges]\n );\n\n const handleShowOptions = React.useCallback((show: boolean) => {\n setShowOptions(show);\n }, []);\n\n return (\n <div className=\"components-quantityFormat-panel\">\n {showSample && (\n <FormatSample\n formatSpec={formatSpec}\n initialMagnitude={initialMagnitude}\n />\n )}\n <FormatUnits\n unitsProvider={unitsProvider}\n persistenceUnit={formatSpec?.persistenceUnit}\n initialFormat={formatProps}\n onUnitsChange={handleFormatChange}\n />\n <FormatUnitLabel\n formatProps={formatProps}\n onUnitLabelChange={handleFormatChange}\n />\n <FormatTypeOption\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n <FormatPrecision\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n {props.providePrimaryChildren &&\n props.providePrimaryChildren(formatProps, handleFormatChange)}\n <MiscFormatOptions\n formatProps={formatProps}\n onChange={handleFormatChange}\n enableMinimumProperties={enableMinimumProperties}\n showOptions={showOptions}\n onShowHideOptions={handleShowOptions}\n >\n {props.provideSecondaryChildren &&\n props.provideSecondaryChildren(formatProps, handleFormatChange)}\n </MiscFormatOptions>\n </div>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
import type { FormatProps } from "@itwin/core-quantity";
|
|
7
7
|
/** Properties of [[FormatPrecision]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatPrecision>`
|
|
9
10
|
*/
|
|
10
11
|
export interface FormatPrecisionProps extends CommonProps {
|
|
11
12
|
formatProps: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPrecision.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD
|
|
1
|
+
{"version":3,"file":"FormatPrecision.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;;GAGG;AAEH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAkC1D"}
|
|
@@ -13,6 +13,7 @@ import { useTranslation } from "../useTranslation";
|
|
|
13
13
|
/** Component to show/edit Quantity Format Precision.
|
|
14
14
|
* @alpha
|
|
15
15
|
*/
|
|
16
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
16
17
|
export function FormatPrecision(props) {
|
|
17
18
|
const { formatProps, onChange } = props;
|
|
18
19
|
const { translate } = useTranslation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;A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":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { FormatType, parseFormatType } from \"@itwin/core-quantity\";\nimport { DecimalPrecisionSelector } from \"./misc/DecimalPrecision\";\nimport { FractionPrecisionSelector } from \"./misc/FractionPrecision\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatPrecision]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatPrecision>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatPrecisionProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Quantity Format Precision.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatPrecision(props: FormatPrecisionProps) {\n const { formatProps, onChange } = props;\n const { translate } = useTranslation();\n\n const handlePrecisionChange = React.useCallback(\n (precision: number) => {\n const newFormatProps = { ...formatProps, precision };\n onChange && onChange(newFormatProps);\n },\n [formatProps, onChange]\n );\n\n const formatType = parseFormatType(formatProps.type, \"format\");\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.precision\")}\n </span>\n {formatType === FormatType.Fractional ? (\n <FractionPrecisionSelector\n data-testid=\"fraction-precision-selector\"\n precision={formatProps.precision ?? 0}\n onChange={handlePrecisionChange}\n />\n ) : (\n <DecimalPrecisionSelector\n data-testid=\"decimal-precision-selector\"\n precision={formatProps.precision ?? 0}\n onChange={handlePrecisionChange}\n />\n )}\n </>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { FormatterSpec } from "@itwin/core-quantity";
|
|
|
6
6
|
import type { CommonProps } from "@itwin/core-react";
|
|
7
7
|
/** Properties of [[FormatSample]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatSample>`
|
|
9
10
|
*/
|
|
10
11
|
export interface FormatSampleProps extends CommonProps {
|
|
11
12
|
formatSpec?: FormatterSpec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatSample.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD
|
|
1
|
+
{"version":3,"file":"FormatSample.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD;;;GAGG;AAEH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBAqFpD"}
|
|
@@ -14,6 +14,7 @@ import { useTranslation } from "../useTranslation";
|
|
|
14
14
|
/** Component to show the persistence value and formatted value given a FormatterSpec.
|
|
15
15
|
* @alpha
|
|
16
16
|
*/
|
|
17
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
17
18
|
export function FormatSample(props) {
|
|
18
19
|
const { initialMagnitude, formatSpec, hideLabels } = props;
|
|
19
20
|
const { translate } = useTranslation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatSample.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatSample.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAanD;;GAEG;AACH,mDAAmD;AACnD,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3D,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,YAAY,GAAG,gBAAgB,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,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,CAAC,CAAC;YACvB,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpC,CAAC,CAAC,cAAc,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,MAAM,0BAA0B,GAAG,UAAU;QAC3C,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK;QAClC,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,SAAS,CAAC;QACvC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,CACL;QACG,CAAC,UAAU,IAAI,CACd,8BAAM,SAAS,EAAE,cAAc,IAC5B,SAAS,CAAC,6BAA6B,CAAC,CACpC,CACR;QACD,8BAAM,SAAS,EAAC,mBAAmB;YACjC,oBAAC,KAAK,mBACQ,qBAAqB,EACjC,SAAS,EAAC,uCAAuC,EACjD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAC,OAAO,GACZ;YACD,0BAA0B,CACtB;QACN,CAAC,UAAU,IAAI,CACd,8BAAM,SAAS,EAAE,cAAc,IAC5B,SAAS,CAAC,iCAAiC,CAAC,CACxC,CACR;QACD,6CAAkB,kBAAkB;YACjC,UAAU,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI;YAC1C,mDAAmD;YACnD,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,kBAAkB,OAAG,GAAI,CAC3C;YACD,6CACc,yBAAyB,EACrC,SAAS,EAAE,mDAAmD,IAE7D,cAAc,CACV,CACF,CACN,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { FormatterSpec } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { SvgProgressForward } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatSample]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatSample>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatSampleProps extends CommonProps {\n formatSpec?: FormatterSpec;\n initialMagnitude?: number;\n hideLabels?: boolean;\n}\n\n/** Component to show the persistence value and formatted value given a FormatterSpec.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatSample(props: FormatSampleProps) {\n const { initialMagnitude, formatSpec, hideLabels } = props;\n const { translate } = useTranslation();\n const initialValue = initialMagnitude ?? 0;\n const [magnitude, setMagnitude] = React.useState(initialValue);\n const [sampleValue, setSampleValue] = React.useState(initialValue.toString());\n\n React.useEffect(() => {\n const value = initialMagnitude ?? 0;\n setMagnitude(value);\n setSampleValue(value.toString());\n }, [initialMagnitude]);\n\n const handleOnValueBlur = React.useCallback(() => {\n let newValue = Number.parseFloat(sampleValue);\n if (Number.isNaN(newValue)) newValue = 0;\n setMagnitude(newValue);\n setSampleValue(newValue.toString());\n }, [sampleValue]);\n\n const handleOnValueChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setSampleValue(event.target.value);\n },\n []\n );\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === Key.Enter.valueOf()) {\n let newValue = Number.parseFloat(sampleValue);\n if (Number.isNaN(newValue)) newValue = 0;\n setMagnitude(newValue);\n setSampleValue(newValue.toString());\n e.preventDefault();\n }\n },\n [sampleValue]\n );\n\n const activePersistenceUnitLabel = formatSpec\n ? formatSpec.persistenceUnit.label\n : \"\";\n const formattedValue = formatSpec\n ? formatSpec.applyFormatting(magnitude)\n : \"\";\n\n return (\n <>\n {!hideLabels && (\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.value\")}\n </span>\n )}\n <span className=\"components-inline\">\n <Input\n data-testid=\"format-sample-input\"\n className=\"components-quantity-persistence-input\"\n value={sampleValue}\n onChange={handleOnValueChange}\n onKeyDown={handleKeyDown}\n onBlur={handleOnValueBlur}\n size=\"small\"\n />\n {activePersistenceUnitLabel}\n </span>\n {!hideLabels && (\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.formatted\")}\n </span>\n )}\n <span data-testid=\"progress-forward\">\n {hideLabels && formattedValue.length > 0 && (\n // eslint-disable-next-line deprecation/deprecation\n <Icon iconSpec={<SvgProgressForward />} />\n )}\n <span\n data-testid=\"format-sample-formatted\"\n className={\"uicore-label components-quantity-formatted-sample\"}\n >\n {formattedValue}\n </span>\n </span>\n </>\n );\n}\n"]}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import type { CommonProps } from "@itwin/core-react";
|
|
6
6
|
import type { FormatProps } from "@itwin/core-quantity";
|
|
7
|
-
/** Properties of [[
|
|
7
|
+
/** Properties of [[FormatTypeOption]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatTypeOption>`
|
|
9
10
|
*/
|
|
10
11
|
export interface FormatTypeOptionProps extends CommonProps {
|
|
11
12
|
formatProps: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatType.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAkExD
|
|
1
|
+
{"version":3,"file":"FormatType.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAkExD;;;GAGG;AAEH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,qBAwD5D"}
|
|
@@ -41,6 +41,7 @@ function FormatTypeSelector(props) {
|
|
|
41
41
|
/** Component to set the Quantity Format type.
|
|
42
42
|
* @alpha
|
|
43
43
|
*/
|
|
44
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
44
45
|
export function FormatTypeOption(props) {
|
|
45
46
|
const { formatProps, onChange } = props;
|
|
46
47
|
const { translate } = useTranslation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAWnD;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAChD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAA6B;QAC7D;YACE,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,KAAK,EAAE,SAAS,CAAC,wBAAwB,CAAC;SAC3C;QACD;YACE,KAAK,EAAE,UAAU,CAAC,UAAU;YAC5B,KAAK,EAAE,SAAS,CAAC,2BAA2B,CAAC;SAC9C;QACD;YACE,KAAK,EAAE,UAAU,CAAC,OAAO;YACzB,KAAK,EAAE,SAAS,CAAC,wBAAwB,CAAC;SAC3C;QACD;YACE,KAAK,EAAE,UAAU,CAAC,UAAU;YAC5B,KAAK,EAAE,SAAS,CAAC,2BAA2B,CAAC;SAC9C;KACF,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAoB,EAAE,EAAE;QACvB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,OAAO,EAAE,aAAa,CAAC,OAAO,EAC9B,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,sBAAsB,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AM,SAAS,EAAE,sBAAsB,IACpC,SAAS,CAAC,4BAA4B,CAAC,CACnC;QACP,oBAAC,kBAAkB,mBACL,sBAAsB,EAClC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,sBAAsB,GAChC,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport {\n DecimalPrecision,\n FormatType,\n formatTypeToString,\n FractionalPrecision,\n parseFormatType,\n ScientificType,\n scientificTypeToString,\n} from \"@itwin/core-quantity\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatTypeSelector]] component.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\ninterface FormatTypeSelectorProps extends CommonProps {\n type: FormatType;\n onChange: (value: FormatType) => void;\n}\n\n/** Component to select the format type.\n * @alpha\n */\nfunction FormatTypeSelector(props: FormatTypeSelectorProps) {\n const { type, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n const formatOptions = React.useRef<SelectOption<FormatType>[]>([\n {\n value: FormatType.Decimal,\n label: translate(\"QuantityFormat.decimal\"),\n },\n {\n value: FormatType.Scientific,\n label: translate(\"QuantityFormat.scientific\"),\n },\n {\n value: FormatType.Station,\n label: translate(\"QuantityFormat.station\"),\n },\n {\n value: FormatType.Fractional,\n label: translate(\"QuantityFormat.fractional\"),\n },\n ]);\n\n const handleOnChange = React.useCallback(\n (newValue: FormatType) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <Select\n options={formatOptions.current}\n value={type}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n\n/** Properties of [[FormatTypeOption]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatTypeOption>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatTypeOptionProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component to set the Quantity Format type.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatTypeOption(props: FormatTypeOptionProps) {\n const { formatProps, onChange } = props;\n const { translate } = useTranslation();\n const handleFormatTypeChange = React.useCallback(\n (newType: FormatType) => {\n const type = formatTypeToString(newType);\n let precision: number | undefined;\n let stationOffsetSize: number | undefined;\n let scientificType: string | undefined;\n switch (\n newType // type must be decimal, fractional, scientific, or station\n ) {\n case FormatType.Scientific:\n precision = DecimalPrecision.Six;\n scientificType = scientificTypeToString(ScientificType.Normalized);\n break;\n case FormatType.Decimal:\n precision = DecimalPrecision.Four;\n break;\n case FormatType.Station:\n precision = DecimalPrecision.Two;\n stationOffsetSize = formatProps.composite?.units[0].name\n .toLocaleLowerCase()\n .endsWith(\"m\")\n ? 3\n : 2;\n break;\n case FormatType.Fractional:\n precision = FractionalPrecision.Eight;\n break;\n }\n const newFormatProps = {\n ...formatProps,\n type,\n precision,\n scientificType,\n stationOffsetSize,\n };\n onChange && onChange(newFormatProps);\n },\n [formatProps, onChange]\n );\n\n const formatType = parseFormatType(formatProps.type, \"format\");\n return (\n <>\n <span className={\"uicore-label.current\"}>\n {translate(\"QuantityFormat.labels.type\")}\n </span>\n <FormatTypeSelector\n data-testid=\"format-type-selector\"\n type={formatType}\n onChange={handleFormatTypeChange}\n />\n </>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
import type { FormatProps } from "@itwin/core-quantity";
|
|
7
7
|
/** Properties of [[FormatUnitLabel]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatUnitLabel>`
|
|
9
10
|
*/
|
|
10
11
|
export interface FormatUnitLabelProps extends CommonProps {
|
|
11
12
|
formatProps: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnitLabel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAqDxD
|
|
1
|
+
{"version":3,"file":"FormatUnitLabel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAqDxD;;;GAGG;AAEH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CACnD;AAED;;GAEG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAuF1D"}
|
|
@@ -35,6 +35,7 @@ function UomSeparatorSelector(props) {
|
|
|
35
35
|
/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.
|
|
36
36
|
* @alpha
|
|
37
37
|
*/
|
|
38
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
38
39
|
export function FormatUnitLabel(props) {
|
|
39
40
|
const { formatProps, onUnitLabelChange } = props;
|
|
40
41
|
const { translate } = useTranslation();
|
|
@@ -1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AAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,MAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AASnD,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IAEvC,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,gB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,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Checkbox, Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n// eslint-disable-next-line deprecation/deprecation\ninterface UomSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled?: boolean;\n onChange: (value: string) => void;\n}\n\nfunction UomSeparatorSelector(props: UomSeparatorSelectorProps) {\n const { separator, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n { value: \"\", label: translate(\"QuantityFormat.none\") },\n { value: \" \", label: translate(\"QuantityFormat.space\") },\n { value: \"-\", label: translate(\"QuantityFormat.dash\") },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n\n/** Properties of [[FormatUnitLabel]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatUnitLabel>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatUnitLabelProps extends CommonProps {\n formatProps: FormatProps;\n onUnitLabelChange?: (format: FormatProps) => void;\n}\n\n/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatUnitLabel(props: FormatUnitLabelProps) {\n const { formatProps, onUnitLabelChange } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onUnitLabelChange && onUnitLabelChange(newProps);\n },\n [onUnitLabelChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUomSeparatorChange = React.useCallback(\n (newSeparator: string) => {\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowUnitLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\n },\n [setFormatTrait]\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.appendUnitLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-unit-label-checkbox\"\n checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n onChange={handleShowUnitLabelChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.labelSeparator\")}\n </span>\n <UomSeparatorSelector\n data-testid=\"uom-separator-select\"\n separator={formatProps.uomSeparator ?? \"\"}\n onChange={handleUomSeparatorChange}\n disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n />\n </>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
import type { FormatProps, UnitProps, UnitsProvider } from "@itwin/core-quantity";
|
|
7
7
|
/** Properties of [[FormatUnits]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatUnits>`
|
|
9
10
|
*/
|
|
10
11
|
export interface FormatUnitsProps extends CommonProps {
|
|
11
12
|
initialFormat: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnits.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAK9B
|
|
1
|
+
{"version":3,"file":"FormatUnits.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAK9B;;;GAGG;AAEH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,aAAa,EAAE,WAAW,CAAC;IAC3B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC/C;AAED;;GAEG;AAEH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAuJlD"}
|
|
@@ -12,6 +12,7 @@ import { useTranslation } from "../useTranslation";
|
|
|
12
12
|
/** Component to show/edit Units used for Quantity Formatting.
|
|
13
13
|
* @alpha
|
|
14
14
|
*/
|
|
15
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
15
16
|
export function FormatUnits(props) {
|
|
16
17
|
const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } = props;
|
|
17
18
|
const { translate } = useTranslation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAanD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GACpE,KAAK,CAAC;IACR,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,gBAAgB,G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R,GAAG,EAAE,eAAe,CAAC,IAAI,EACzB,IAAI,EAAE,eAAe,CAAC,IAAI,EAC1B,KAAK,EAAE,eAAe,CAAC,KAAK,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,CAAC,EACR,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,GACpC,CACH;QAEJ,WAAW,CAAC,SAAS,EAAE,KAAK;YAC3B,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC;YACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAC3D,SAAS,CAAC,uCAAuC,CAAC,CAC9C;YACP,oBAAC,KAAK,IACJ,GAAG,EAAE,kBAAkB,iBACX,kBAAkB,EAC9B,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EACzC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CACF,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const { translate } = useTranslation();\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : [{ name: unitParts[1], label: unitParts[2] }];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n if (formatProps.composite) {\n const spacerValue = e.target.value.length ? e.target.value[0] : \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.compositeSpacer\")}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat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AE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EACxB,cAAc,EACZ,KAAK,GAAG,CAAC;oBACP,CAAC,CAAC,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI;oBAC9C,CAAC,CAAC,SAAS,EAEf,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,EACpC,QAAQ,EAAE,KAAK,GAAG,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GACzD,CACH,CAAC;YACJ,CAAC,CAAC,eAAe,IAAI,CACjB,oBAAC,SAAS,IACR,GAAG,EAAE,eAAe,CAAC,IAAI,EACzB,IAAI,EAAE,eAAe,CAAC,IAAI,EAC1B,KAAK,EAAE,eAAe,CAAC,KAAK,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,CAAC,EACR,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,GACpC,CACH;QAEJ,WAAW,CAAC,SAAS,EAAE,KAAK;YAC3B,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC;YACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAC3D,SAAS,CAAC,uCAAuC,CAAC,CAC9C;YACP,oBAAC,KAAK,IACJ,GAAG,EAAE,kBAAkB,iBACX,kBAAkB,EAC9B,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EACzC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CACF,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof FormatUnits>`\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const { translate } = useTranslation();\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : [{ name: unitParts[1], label: unitParts[2] }];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n if (formatProps.composite) {\n const spacerValue = e.target.value.length ? e.target.value[0] : \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.compositeSpacer\")}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
import type { FormatProps } from "@itwin/core-quantity";
|
|
7
7
|
/** Properties of [[MiscFormatOptions]] component.
|
|
8
8
|
* @alpha
|
|
9
|
+
* @deprecated in 4.17.0. Use `React.ComponentProps<typeof MiscFormatOptions>`
|
|
9
10
|
*/
|
|
10
11
|
export interface MiscFormatOptionsProps extends CommonProps {
|
|
11
12
|
formatProps: FormatProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAqBxE
|
|
1
|
+
{"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAqBxE;;;GAGG;AAEH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAmW9D"}
|
|
@@ -20,6 +20,7 @@ import { useTranslation } from "../useTranslation";
|
|
|
20
20
|
/** Component use to set miscellaneous properties is a Formatted Quantity.
|
|
21
21
|
* @alpha
|
|
22
22
|
*/
|
|
23
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
23
24
|
export function MiscFormatOptions(props) {
|
|
24
25
|
const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties, } = props;
|
|
25
26
|
const { translate } = useTranslation();
|