@itwin/components-react 5.28.1 → 5.29.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 +16 -0
- package/lib/components-react/editors/BooleanEditor.d.ts.map +1 -1
- package/lib/components-react/editors/BooleanEditor.js +1 -1
- package/lib/components-react/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.d.ts.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.js +1 -1
- package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/editors/EnumEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumEditor.js +1 -0
- package/lib/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/editors/IconEditor.d.ts.map +1 -1
- package/lib/components-react/editors/IconEditor.js +1 -1
- package/lib/components-react/editors/IconEditor.js.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.js +1 -1
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/PopupButton.d.ts +2 -0
- package/lib/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/components-react/editors/PopupButton.js +1 -1
- package/lib/components-react/editors/PopupButton.js.map +1 -1
- package/lib/components-react/editors/SliderEditor.d.ts.map +1 -1
- package/lib/components-react/editors/SliderEditor.js +1 -1
- package/lib/components-react/editors/SliderEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextareaEditor.js +1 -1
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ToggleEditor.js +1 -1
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/new-editors/ConstraintUtils.d.ts +62 -0
- package/lib/components-react/new-editors/ConstraintUtils.d.ts.map +1 -0
- package/lib/components-react/new-editors/ConstraintUtils.js +49 -0
- package/lib/components-react/new-editors/ConstraintUtils.js.map +1 -0
- package/lib/components-react/new-editors/Types.d.ts +6 -0
- package/lib/components-react/new-editors/Types.d.ts.map +1 -1
- package/lib/components-react/new-editors/Types.js.map +1 -1
- package/lib/components-react/new-editors/UseCommittableValue.d.ts +2 -5
- package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -1
- package/lib/components-react/new-editors/UseCommittableValue.js +4 -1
- package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.js +2 -2
- package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.js +2 -2
- package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateInput.d.ts +2 -1
- package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateInput.js +2 -2
- package/lib/components-react/new-editors/editors/DateInput.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.js +2 -2
- package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.js +2 -2
- package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.js +2 -2
- package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts +2 -2
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/NumericEditor.js +7 -3
- package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/TextEditor.d.ts +2 -2
- package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/TextEditor.js +4 -2
- package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.js +2 -2
- package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts +4 -3
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.js +1 -0
- package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -1
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +14 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +4 -3
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/Color.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +3 -2
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +9 -3
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +7 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +19 -4
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/Slider.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -1
- package/lib/components-react/new-editors/values/Metadata.d.ts +22 -0
- package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -1
- package/lib/components-react/new-editors/values/Metadata.js.map +1 -1
- package/lib/components-react.d.ts +1 -1
- package/lib/components-react.d.ts.map +1 -1
- package/lib/components-react.js.map +1 -1
- package/lib/internal.d.ts +1 -0
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +1 -0
- package/lib/internal.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultEditors.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/DefaultEditors.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AA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AA2C;IAC3C,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,cAAc;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,uBAAuB;IACvB,gCAAgC;IAChC,6BAA6B;IAC7B,6BAA6B;IAC7B,sBAAsB;IACtB,0BAA0B;IAE1B,qBAAqB;CACtB,CAAC;AAEF,qBAAqB","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\nimport { StandardEditorNames } from \"@itwin/appui-abstract\";\nimport { BooleanEditor } from \"../editors/BooleanEditor.js\";\nimport { DateTimeEditor } from \"../editors/DateTimeEditor.js\";\nimport { EnumEditor } from \"../editors/EnumEditor.js\";\nimport { NumericEditor } from \"../editors/NumericEditor.js\";\nimport { TextEditor } from \"../editors/TextEditor.js\";\n\nimport { ColorEditorSpec as InteropColorEditorSpec } from \"../interop/old-editors/Color.js\";\nimport { CustomNumberEditorSpec as InteropCustomNumberEditorSpec } from \"../interop/old-editors/CustomNumber.js\";\nimport { EnumEditorSpec as InteropEnumEditorSpec } from \"../interop/old-editors/Enum.js\";\nimport { EnumButtonGroupEditorSpec as InteropEnumButtonGroupEditorSpec } from \"../interop/old-editors/EnumButtonGroup.js\";\nimport { MultilineEditorSpec as InteropMultilineEditorSpec } from \"../interop/old-editors/TextArea.js\";\nimport { SliderEditorSpec as InteropSliderEditorSpec } from \"../interop/old-editors/Slider.js\";\nimport { NumericInputEditorSpec as InteropNumericInputEditorSpec } from \"../interop/old-editors/NumericInput.js\";\n\nimport { createEditorSpec, type EditorSpec } from \"../Types.js\";\nimport type {\n EnumValueMetadata,\n NumericValueMetadata,\n TextValueMetadata,\n ValueMetadata,\n} from \"../values/Metadata.js\";\nimport { ToggleEditor } from \"../editors/ToggleEditor.js\";\nimport { DateEditor } from \"../editors/DateEditor.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\n\n/** v8 ignore start */\n\n/**\n * Specification for default text editor. It applies for values whose type is \"string\".\n * @internal\n */\nexport const TextEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is TextValueMetadata =>\n metadata.type === \"string\",\n isValueSupported: isText,\n Editor: TextEditor,\n});\n\n/**\n * Specification for default date editor. It applies for values whose type is \"date\".\n * @internal\n */\nexport const DateEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"date\",\n isValueSupported: isDate,\n Editor: DateEditor,\n});\n\n/**\n * Specification for default date time editor. It applies for values whose type is \"dateTime\".\n * @internal\n */\nexport const DateTimeEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"dateTime\",\n isValueSupported: isDate,\n Editor: DateTimeEditor,\n});\n\n/**\n * Specification for default boolean editor. It applies for values whose type is \"bool\".\n * @internal\n */\nexport const BoolEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"bool\",\n isValueSupported: isBoolean,\n Editor: BooleanEditor,\n});\n\n/**\n * Specification for default numeric editor. It applies for values whose type is \"number\".\n * @internal\n */\nexport const NumericEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is NumericValueMetadata =>\n metadata.type === \"number\",\n isValueSupported: isNumeric,\n Editor: NumericEditor,\n});\n\n/**\n * Specification for default toggle editor. It applies for values whose type is \"bool\" when preferred editor set to `toggle`.\n * @internal\n */\nexport const EnumEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is EnumValueMetadata =>\n metadata.type === \"enum\",\n isValueSupported: isEnum,\n Editor: EnumEditor,\n});\n\n/**\n * Specification for default enum editor. It applies for values whose type is \"enum\".\n * @internal\n */\nexport const ToggleEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"bool\" &&\n metadata.preferredEditor === StandardEditorNames.Toggle,\n isValueSupported: isBoolean,\n Editor: ToggleEditor,\n});\n\n/**\n * List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.\n * @internal\n */\nexport const defaultEditorSpecs: EditorSpec[] = [\n // list editors with preferred editor check first\n ToggleEditorSpec,\n\n // list editors that checks only value type\n TextEditorSpec,\n BoolEditorSpec,\n NumericEditorSpec,\n DateEditorSpec,\n DateTimeEditorSpec,\n EnumEditorSpec,\n];\n\n/**\n * List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support\n * editing customizations used through `PropertyRecord`.\n * @internal\n */\nexport const interopEditorSpecs: EditorSpec[] = [\n InteropSliderEditorSpec,\n InteropEnumButtonGroupEditorSpec,\n InteropNumericInputEditorSpec,\n InteropCustomNumberEditorSpec,\n InteropColorEditorSpec,\n InteropMultilineEditorSpec,\n\n InteropEnumEditorSpec,\n];\n\n/** v8 ignore stop */\n"]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { PrimitiveValue
|
|
1
|
+
import type { PrimitiveValue } from "@itwin/appui-abstract";
|
|
2
2
|
import type { Value as NewEditorValue } from "../values/Values.js";
|
|
3
3
|
import type { OldEditorMetadata } from "./Metadata.js";
|
|
4
|
+
import type { PropertyRecordWithConstraints, WithConstraints } from "../ConstraintUtils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Interop utilities for converting between old and new editor values.
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
9
|
export declare namespace EditorInterop {
|
|
9
10
|
/** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */
|
|
10
|
-
function getMetadataAndValue(propertyRecord:
|
|
11
|
-
metadata: OldEditorMetadata | undefined;
|
|
11
|
+
function getMetadataAndValue(propertyRecord: PropertyRecordWithConstraints): {
|
|
12
|
+
metadata: WithConstraints<OldEditorMetadata> | undefined;
|
|
12
13
|
value: NewEditorValue | undefined;
|
|
13
14
|
};
|
|
14
15
|
/** Converts new editors system `Value` into old `PrimitiveValue` */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAUxE,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQvD,OAAO,KAAK,EACV,6BAA6B,EAC7B,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAAc,EAAE,6BAA6B,GAC5C;QACD,QAAQ,EAAE,eAAe,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;QACzD,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CAiGA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CAuChB;CACF"}
|
|
@@ -20,6 +20,7 @@ export var EditorInterop;
|
|
|
20
20
|
typename: propertyRecord.property.typename,
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
22
22
|
quantityType: propertyRecord.property.quantityType,
|
|
23
|
+
constraints: propertyRecord.property.constraints,
|
|
23
24
|
};
|
|
24
25
|
const primitiveValue = propertyRecord.value;
|
|
25
26
|
switch (propertyRecord.property.typename) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;
|
|
1
|
+
{"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAMrC;;;GAGG;AACH,MAAM,KAAW,aAAa,CAqJ7B;AArJD,WAAiB,aAAa;IAC5B,6EAA6E;IAC7E,SAAgB,mBAAmB,CACjC,cAA6C;QAK7C,MAAM,YAAY,GAAqD;YACrE,eAAe,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI;YACrD,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;YAC9C,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC,IAAI;YAClC,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,QAAQ;YAC1C,4DAA4D;YAC5D,YAAY,EAAE,cAAc,CAAC,QAAQ,CAAC,YAAY;YAClD,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC,WAAW;SACjD,CAAC;QAEF,MAAM,cAAc,GAAG,cAAc,CAAC,KAAuB,CAAC;QAC9D,QAAQ,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACzC,KAAK,MAAM,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO;oBACL,QAAQ,EAAE;wBACR,GAAG,YAAY;wBACf,IAAI,EAAE,QAAQ;qBACf;oBACD,KAAK,EAAE;wBACL,KAAK,EAAG,cAAc,CAAC,KAAgB,IAAI,EAAE;qBAC1B;iBACtB,CAAC;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C;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,MAAM;aACvB,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAzCe,qCAAuB,0BAyCtC,CAAA;AACH,CAAC,EArJgB,aAAa,KAAb,aAAa,QAqJ7B","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\nimport type { Primitives, PrimitiveValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type {\n BooleanValue,\n DateValue,\n EnumValue,\n InstanceKeyValue,\n NumericValue,\n TextValue,\n} from \"../values/Values.js\";\nimport type { Value as NewEditorValue } from \"../values/Values.js\";\nimport type { OldEditorMetadata } from \"./Metadata.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\nimport type {\n PropertyRecordWithConstraints,\n WithConstraints,\n} from \"../ConstraintUtils.js\";\n\n/**\n * Interop utilities for converting between old and new editor values.\n * @internal\n */\nexport namespace EditorInterop {\n /** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */\n export function getMetadataAndValue(\n propertyRecord: PropertyRecordWithConstraints\n ): {\n metadata: WithConstraints<OldEditorMetadata> | undefined;\n value: NewEditorValue | undefined;\n } {\n const baseMetadata: Omit<WithConstraints<OldEditorMetadata>, \"type\"> = {\n preferredEditor: propertyRecord.property.editor?.name,\n params: propertyRecord.property.editor?.params,\n extendedData: propertyRecord.extendedData,\n enum: propertyRecord.property.enum,\n typename: propertyRecord.property.typename,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n quantityType: propertyRecord.property.quantityType,\n constraints: propertyRecord.property.constraints,\n };\n\n const primitiveValue = propertyRecord.value as PrimitiveValue;\n switch (propertyRecord.property.typename) {\n case \"text\":\n case \"string\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"string\",\n },\n value: {\n value: (primitiveValue.value as string) ?? \"\",\n } satisfies TextValue,\n };\n case \"dateTime\":\n case \"shortdate\":\n return {\n metadata: {\n ...baseMetadata,\n type:\n propertyRecord.property.typename === \"shortdate\"\n ? \"date\"\n : \"dateTime\",\n },\n value: {\n value: (primitiveValue.value as Date) ?? new Date(),\n } satisfies DateValue,\n };\n case \"boolean\":\n case \"bool\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"bool\",\n },\n value: {\n value: (primitiveValue.value as boolean) ?? false,\n } satisfies BooleanValue,\n };\n case \"float\":\n case \"double\":\n case \"int\":\n case \"integer\":\n case \"number\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"number\",\n },\n value: {\n rawValue: primitiveValue.value as number,\n displayValue: primitiveValue.displayValue\n ? primitiveValue.displayValue\n : primitiveValue.value !== undefined\n ? `${primitiveValue.value as number}`\n : \"\",\n roundingError: primitiveValue.roundingError,\n } satisfies NumericValue,\n };\n case \"enum\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"enum\",\n },\n value: {\n choice: primitiveValue.value as number | string,\n } satisfies EnumValue,\n };\n case \"navigation\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"instanceKey\",\n },\n value: {\n key: primitiveValue.value as Primitives.InstanceKey,\n label: primitiveValue.displayValue ?? \"\",\n } satisfies InstanceKeyValue,\n };\n }\n\n return {\n metadata: undefined,\n value: undefined,\n };\n }\n\n /** Converts new editors system `Value` into old `PrimitiveValue` */\n export function convertToPrimitiveValue(\n newValue: NewEditorValue\n ): PrimitiveValue {\n if (isText(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value,\n };\n }\n if (isNumeric(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.rawValue,\n displayValue: newValue.displayValue,\n roundingError: newValue.roundingError,\n };\n }\n if (isBoolean(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n if (isDate(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n\n if (isEnum(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.choice,\n };\n }\n\n throw new Error(\"Unsupported value type\");\n }\n}\n"]}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { type PropertyRecord } from "@itwin/appui-abstract";
|
|
6
6
|
import { type PropertyUpdatedArgs } from "../../editors/EditorContainer.js";
|
|
7
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
8
|
+
import type { Value } from "../values/Values.js";
|
|
9
|
+
import type { WithConstraints } from "../ConstraintUtils.js";
|
|
7
10
|
interface PropertyRecordEditorProps {
|
|
8
11
|
propertyRecord: PropertyRecord;
|
|
9
12
|
onCommit: (args: PropertyUpdatedArgs) => void;
|
|
@@ -18,5 +21,16 @@ interface PropertyRecordEditorProps {
|
|
|
18
21
|
* @beta
|
|
19
22
|
*/
|
|
20
23
|
export declare function PropertyRecordEditor({ propertyRecord, onCommit, onCancel, onClick, setFocus, size, editorSystem, }: PropertyRecordEditorProps): React.JSX.Element;
|
|
24
|
+
/** @internal */
|
|
25
|
+
export declare function CommittingEditor({ metadata, initialValue, onCancel, onCommit, onClick, disabled, size, id, }: {
|
|
26
|
+
metadata: WithConstraints<ValueMetadata>;
|
|
27
|
+
initialValue?: Value;
|
|
28
|
+
onCommit: (value?: Value) => void;
|
|
29
|
+
onCancel: () => void;
|
|
30
|
+
onClick?: () => void;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
size?: "small" | "large";
|
|
33
|
+
id?: string;
|
|
34
|
+
}): React.JSX.Element;
|
|
21
35
|
export {};
|
|
22
36
|
//# sourceMappingURL=PropertyRecordEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRecordEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/PropertyRecordEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyRecordEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/PropertyRecordEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,UAAU,yBAAyB;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,YAAY,GACb,EAAE,yBAAyB,qBAkC3B;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,EAAE,GACH,EAAE;IACD,QAAQ,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,qBA0BA"}
|
|
@@ -25,17 +25,18 @@ export function PropertyRecordEditor({ propertyRecord, onCommit, onCancel, onCli
|
|
|
25
25
|
? { valueFormat: PropertyValueFormat.Primitive }
|
|
26
26
|
: EditorInterop.convertToPrimitiveValue(newValue),
|
|
27
27
|
});
|
|
28
|
-
}, onCancel: onCancel, onClick: onClick, disabled: propertyRecord.isDisabled || propertyRecord.isReadonly, size: size }));
|
|
28
|
+
}, onCancel: onCancel, onClick: onClick, disabled: propertyRecord.isDisabled || propertyRecord.isReadonly, size: size, id: propertyRecord.property.name }));
|
|
29
29
|
}
|
|
30
30
|
return (React.createElement(EditorContainer, { propertyRecord: propertyRecord, onCommit: onCommit, onCancel: onCancel, onClick: onClick, setFocus: setFocus }));
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
/** @internal */
|
|
33
|
+
export function CommittingEditor({ metadata, initialValue, onCancel, onCommit, onClick, disabled, size, id, }) {
|
|
33
34
|
const { value, onChange, onKeydown, commit, cancel } = useCommittableValue({
|
|
34
35
|
initialValue,
|
|
35
36
|
onCommit,
|
|
36
37
|
onCancel,
|
|
37
38
|
});
|
|
38
39
|
return (React.createElement("div", { onKeyDown: onKeydown, onBlur: commit, onClick: onClick, role: "presentation" },
|
|
39
|
-
React.createElement(EditorRenderer, { metadata: metadata, value: value, onChange: onChange, commit: commit, cancel: cancel, disabled: disabled, size: size })));
|
|
40
|
+
React.createElement(EditorRenderer, { metadata: metadata, value: value, onChange: onChange, commit: commit, cancel: cancel, disabled: disabled, size: size, id: id })));
|
|
40
41
|
}
|
|
41
42
|
//# sourceMappingURL=PropertyRecordEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRecordEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/PropertyRecordEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,GAEhB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyRecordEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/PropertyRecordEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,GAEhB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2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ACJ,EAAE,GAUH;IACC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC;QACzE,YAAY;QACZ,QAAQ;QACR,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO,CACL,6BACE,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,cAAc;QAEnB,oBAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,GACN,CACE,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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport {\n type PropertyRecord,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { EditorInterop } from \"./EditorInterop.js\";\nimport {\n EditorContainer,\n type PropertyUpdatedArgs,\n} from \"../../editors/EditorContainer.js\";\nimport { useCommittableValue } from \"../UseCommittableValue.js\";\nimport { EditorRenderer } from \"../EditorRenderer.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { Value } from \"../values/Values.js\";\nimport type { WithConstraints } from \"../ConstraintUtils.js\";\n\ninterface PropertyRecordEditorProps {\n propertyRecord: PropertyRecord;\n onCommit: (args: PropertyUpdatedArgs) => void;\n onCancel: () => void;\n onClick?: () => void;\n setFocus?: boolean;\n size?: \"small\" | \"large\";\n editorSystem?: \"legacy\" | \"new\";\n}\n\n/**\n * Editor component for editing property values represented by `PropertyRecord`.\n * @beta\n */\nexport function PropertyRecordEditor({\n propertyRecord,\n onCommit,\n onCancel,\n onClick,\n setFocus,\n size,\n editorSystem,\n}: PropertyRecordEditorProps) {\n const { metadata, value } = EditorInterop.getMetadataAndValue(propertyRecord);\n if (editorSystem === \"new\" && metadata && value) {\n return (\n <CommittingEditor\n metadata={metadata}\n initialValue={value}\n onCommit={(newValue) => {\n onCommit({\n propertyRecord,\n newValue:\n newValue === undefined\n ? { valueFormat: PropertyValueFormat.Primitive }\n : EditorInterop.convertToPrimitiveValue(newValue),\n });\n }}\n onCancel={onCancel}\n onClick={onClick}\n disabled={propertyRecord.isDisabled || propertyRecord.isReadonly}\n size={size}\n id={propertyRecord.property.name}\n />\n );\n }\n\n return (\n <EditorContainer\n propertyRecord={propertyRecord}\n onCommit={onCommit}\n onCancel={onCancel}\n onClick={onClick}\n setFocus={setFocus}\n />\n );\n}\n\n/** @internal */\nexport function CommittingEditor({\n metadata,\n initialValue,\n onCancel,\n onCommit,\n onClick,\n disabled,\n size,\n id,\n}: {\n metadata: WithConstraints<ValueMetadata>;\n initialValue?: Value;\n onCommit: (value?: Value) => void;\n onCancel: () => void;\n onClick?: () => void;\n disabled?: boolean;\n size?: \"small\" | \"large\";\n id?: string;\n}) {\n const { value, onChange, onKeydown, commit, cancel } = useCommittableValue({\n initialValue,\n onCommit,\n onCancel,\n });\n\n return (\n <div\n onKeyDown={onKeydown}\n onBlur={commit}\n onClick={onClick}\n role=\"presentation\"\n >\n <EditorRenderer\n metadata={metadata}\n value={value}\n onChange={onChange}\n commit={commit}\n cancel={cancel}\n disabled={disabled}\n size={size}\n id={id}\n />\n </div>\n );\n}\n"]}
|
|
@@ -22,7 +22,7 @@ export const ColorEditorSpec = createEditorSpec({
|
|
|
22
22
|
isValueSupported: isNumeric,
|
|
23
23
|
Editor: ColorEditor,
|
|
24
24
|
});
|
|
25
|
-
function ColorEditor({ value, metadata, onChange, commit, size, }) {
|
|
25
|
+
function ColorEditor({ value, metadata, onChange, commit, size, id, }) {
|
|
26
26
|
const colorParams = useColorEditorParams(metadata);
|
|
27
27
|
const colors = colorParams?.colorValues ?? [];
|
|
28
28
|
const currentValue = value
|
|
@@ -41,7 +41,7 @@ function ColorEditor({ value, metadata, onChange, commit, size, }) {
|
|
|
41
41
|
commit?.();
|
|
42
42
|
}
|
|
43
43
|
} },
|
|
44
|
-
React.createElement(IconButton, { size: size },
|
|
44
|
+
React.createElement(IconButton, { id: id, size: size },
|
|
45
45
|
React.createElement(ColorSwatch, { color: activeColor }))));
|
|
46
46
|
}
|
|
47
47
|
/* v8 ignore stop */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/Color.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,qBAAqB;AAErB;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAe,gBAAgB,CAAC;IAC1D,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,wBAAwB,CAAC,SAAS,CAAC,OAAO,EAAE,CACvE;QACD,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,WAAW;IAC9D,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,EACnB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAI,
|
|
1
|
+
{"version":3,"file":"Color.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/Color.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,OAAO,GACR,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,qBAAqB;AAErB;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAe,gBAAgB,CAAC;IAC1D,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CACrB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,wBAAwB,CAAC,SAAS,CAAC,OAAO,EAAE,CACvE;QACD,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,WAAW;IAC9D,gBAAgB,EAAE,SAAS;IAC3B,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AAI,EAAE,IAAI;YAC5B,oBAAC,WAAW,IAAC,KAAK,EAAE,WAAW,GAAI,CACxB,CACL,CACX,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport {\n PropertyEditorParamTypes,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport {\n ColorPalette,\n ColorPicker,\n ColorSwatch,\n ColorValue,\n IconButton,\n Popover,\n} from \"@itwin/itwinui-react\";\nimport type { EditorProps, EditorSpec } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport { useColorEditorParams } from \"./UseEditorParams.js\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/**\n * Editor specification for color editor.\n * @internal\n */\nexport const ColorEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n !!metadata.params?.find(\n (param) => param.type === PropertyEditorParamTypes.ColorData.valueOf()\n ) &&\n metadata.preferredEditor === StandardEditorNames.ColorPicker,\n isValueSupported: isNumeric,\n Editor: ColorEditor,\n});\n\nfunction ColorEditor({\n value,\n metadata,\n onChange,\n commit,\n size,\n id,\n}: EditorProps<OldEditorMetadata, NumericValue>) {\n const colorParams = useColorEditorParams(metadata);\n const colors = colorParams?.colorValues ?? [];\n\n const currentValue = value\n ? value\n : { rawValue: colors[0], displayValue: \"\" };\n const colorsList = colors.map((color) => ColorValue.fromTbgr(color));\n const activeColor =\n currentValue.rawValue !== undefined\n ? ColorValue.fromTbgr(currentValue.rawValue)\n : colorsList[0];\n\n const onColorChanged = (color: ColorValue) => {\n onChange({ rawValue: color.toTbgr(), displayValue: \"\" });\n };\n\n return (\n <Popover\n content={\n <ColorPicker\n selectedColor={activeColor}\n onChangeComplete={onColorChanged}\n >\n <ColorPalette colors={colorsList} />\n </ColorPicker>\n }\n onVisibleChange={(visible) => {\n if (!visible) {\n commit?.();\n }\n }}\n >\n <IconButton id={id} size={size}>\n <ColorSwatch color={activeColor} />\n </IconButton>\n </Popover>\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -2,12 +2,13 @@ import * as React from "react";
|
|
|
2
2
|
import type { EditorProps } from "../../Types.js";
|
|
3
3
|
import type { OldEditorMetadata } from "../Metadata.js";
|
|
4
4
|
import type { NumericValue } from "../../values/Values.js";
|
|
5
|
+
import type { WithConstraints } from "../../ConstraintUtils.js";
|
|
5
6
|
/** @internal */
|
|
6
7
|
export declare const CustomNumberEditorSpec: import("../../Types.js").EditorSpec;
|
|
7
|
-
interface CustomNumberEditorProps extends EditorProps<OldEditorMetadata
|
|
8
|
+
interface CustomNumberEditorProps extends EditorProps<WithConstraints<OldEditorMetadata>, NumericValue> {
|
|
8
9
|
decoration?: React.ReactNode;
|
|
9
10
|
}
|
|
10
11
|
/** @internal */
|
|
11
|
-
export declare function CustomNumberEditor({ metadata, value, onChange, size, disabled, decoration, }: CustomNumberEditorProps): React.JSX.Element | null;
|
|
12
|
+
export declare function CustomNumberEditor({ metadata, value, onChange, size, disabled, decoration, id, }: CustomNumberEditorProps): React.JSX.Element | null;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=CustomNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQ3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAOhE,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,qCAWjC,CAAC;AAEH,UAAU,uBACR,SAAQ,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,YAAY,CAAC;IACrE,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,EAAE,GACH,EAAE,uBAAuB,4BAiEzB"}
|
|
@@ -10,6 +10,7 @@ import { isOldEditorMetadata } from "../Metadata.js";
|
|
|
10
10
|
import { useCustomFormattedNumberParams, useIconEditorParams, useInputEditorSizeParams, } from "./UseEditorParams.js";
|
|
11
11
|
import { findIcon } from "../IconsRegistry.js";
|
|
12
12
|
import { isNumeric } from "../../values/ValueUtilities.js";
|
|
13
|
+
import { applyNumericConstraints, getNumericConstraints, } from "../../ConstraintUtils.js";
|
|
13
14
|
/* v8 ignore start */
|
|
14
15
|
/** @internal */
|
|
15
16
|
export const CustomNumberEditorSpec = createEditorSpec({
|
|
@@ -21,7 +22,7 @@ export const CustomNumberEditorSpec = createEditorSpec({
|
|
|
21
22
|
Editor: CustomNumberEditor,
|
|
22
23
|
});
|
|
23
24
|
/** @internal */
|
|
24
|
-
export function CustomNumberEditor({ metadata, value, onChange, size, disabled, decoration, }) {
|
|
25
|
+
export function CustomNumberEditor({ metadata, value, onChange, size, disabled, decoration, id, }) {
|
|
25
26
|
const formatParams = useCustomFormattedNumberParams(metadata);
|
|
26
27
|
const sizeParams = useInputEditorSizeParams(metadata);
|
|
27
28
|
const iconParams = useIconEditorParams(metadata);
|
|
@@ -48,7 +49,12 @@ export function CustomNumberEditor({ metadata, value, onChange, size, disabled,
|
|
|
48
49
|
const handleChange = (e) => {
|
|
49
50
|
const currentValue = e.target.value;
|
|
50
51
|
const result = formatParams.parseFunction(currentValue);
|
|
51
|
-
const parsedValue = typeof result.value === "number"
|
|
52
|
+
const parsedValue = typeof result.value === "number"
|
|
53
|
+
? applyNumericConstraints({
|
|
54
|
+
...getNumericConstraints(metadata.constraints),
|
|
55
|
+
value: result.value,
|
|
56
|
+
})
|
|
57
|
+
: undefined;
|
|
52
58
|
setInputValue(currentValue);
|
|
53
59
|
onChange({
|
|
54
60
|
rawValue: parsedValue,
|
|
@@ -57,7 +63,7 @@ export function CustomNumberEditor({ metadata, value, onChange, size, disabled,
|
|
|
57
63
|
};
|
|
58
64
|
return (React.createElement(InputWithDecorations, { size: size },
|
|
59
65
|
icon !== undefined ? (React.createElement(InputWithDecorations.Icon, null, icon)) : null,
|
|
60
|
-
React.createElement(InputWithDecorations.Input, { ref: inputRef, style: style, disabled: disabled, onChange: handleChange, value: inputValue }),
|
|
66
|
+
React.createElement(InputWithDecorations.Input, { id: id, ref: inputRef, style: style, disabled: disabled, onChange: handleChange, value: inputValue }),
|
|
61
67
|
decoration));
|
|
62
68
|
}
|
|
63
69
|
/* v8 ignore stop */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumber.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,8BAA8B,EAC9B,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,qBAAqB;AAErB,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;IACrD,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CACrB,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,wBAAwB,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAC1E;QACD,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,YAAY;IAC/D,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAOH,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,
|
|
1
|
+
{"version":3,"file":"CustomNumber.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAAA;;;gGA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AAC;gBACtB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAC9C,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;QAEhB,aAAa,CAAC,YAAY,CAAC,CAAC;QAE5B,QAAQ,CAAC;YACP,QAAQ,EAAE,WAAW;YACrB,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI;QAC7B,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CACpB,oBAAC,oBAAoB,CAAC,IAAI,QAAE,IAAI,CAA6B,CAC9D,CAAC,CAAC,CAAC,IAAI;QACR,oBAAC,oBAAoB,CAAC,KAAK,IACzB,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,UAAU,GACjB;QACD,UAAU,CACU,CACxB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport {\n PropertyEditorParamTypes,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useCustomFormattedNumberParams,\n useIconEditorParams,\n useInputEditorSizeParams,\n} from \"./UseEditorParams.js\";\nimport { findIcon } from \"../IconsRegistry.js\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\nimport type { WithConstraints } from \"../../ConstraintUtils.js\";\nimport {\n applyNumericConstraints,\n getNumericConstraints,\n} from \"../../ConstraintUtils.js\";\n/* v8 ignore start */\n\n/** @internal */\nexport const CustomNumberEditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n !!metadata.params?.find(\n (param) =>\n param.type === PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) &&\n metadata.preferredEditor === StandardEditorNames.NumberCustom,\n isValueSupported: isNumeric,\n Editor: CustomNumberEditor,\n});\n\ninterface CustomNumberEditorProps\n extends EditorProps<WithConstraints<OldEditorMetadata>, NumericValue> {\n decoration?: React.ReactNode;\n}\n\n/** @internal */\nexport function CustomNumberEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n decoration,\n id,\n}: CustomNumberEditorProps) {\n const formatParams = useCustomFormattedNumberParams(metadata);\n const sizeParams = useInputEditorSizeParams(metadata);\n const iconParams = useIconEditorParams(metadata);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [inputValue, setInputValue] = React.useState(() => {\n return value?.rawValue !== undefined && formatParams\n ? formatParams.formatFunction(value.rawValue)\n : \"\";\n });\n\n if (!formatParams) {\n return null;\n }\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n maxWidth:\n sizeParams?.maxSize !== undefined\n ? `${sizeParams?.maxSize * 0.75}em`\n : undefined,\n }\n : undefined;\n const icon =\n iconParams?.definition?.iconSpec !== undefined\n ? findIcon(iconParams.definition.iconSpec)\n : undefined;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = e.target.value;\n const result = formatParams.parseFunction(currentValue);\n const parsedValue =\n typeof result.value === \"number\"\n ? applyNumericConstraints({\n ...getNumericConstraints(metadata.constraints),\n value: result.value,\n })\n : undefined;\n\n setInputValue(currentValue);\n\n onChange({\n rawValue: parsedValue,\n displayValue: currentValue,\n });\n };\n\n return (\n <InputWithDecorations size={size}>\n {icon !== undefined ? (\n <InputWithDecorations.Icon>{icon}</InputWithDecorations.Icon>\n ) : null}\n <InputWithDecorations.Input\n id={id}\n ref={inputRef}\n style={style}\n disabled={disabled}\n onChange={handleChange}\n value={inputValue}\n />\n {decoration}\n </InputWithDecorations>\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -20,7 +20,7 @@ export const EnumButtonGroupEditorSpec = createEditorSpec({
|
|
|
20
20
|
isValueSupported: isEnum,
|
|
21
21
|
Editor: EnumButtonGroupEditor,
|
|
22
22
|
});
|
|
23
|
-
function EnumButtonGroupEditor({ value, onChange, commit, size, disabled, metadata, }) {
|
|
23
|
+
function EnumButtonGroupEditor({ value, onChange, commit, size, disabled, metadata, id, }) {
|
|
24
24
|
const enumMetadata = useEnumMetadata(metadata);
|
|
25
25
|
const buttonGroupParams = useButtonGroupEditorParams(metadata);
|
|
26
26
|
const enumIcons = React.useMemo(() => {
|
|
@@ -30,7 +30,7 @@ function EnumButtonGroupEditor({ value, onChange, commit, size, disabled, metada
|
|
|
30
30
|
}, [enumMetadata, buttonGroupParams]);
|
|
31
31
|
const firstChoice = enumMetadata.choices[0];
|
|
32
32
|
const currentValue = value ? value : { choice: firstChoice?.value ?? "" };
|
|
33
|
-
return (React.createElement(ButtonGroup, { orientation: "horizontal" }, enumMetadata.choices.map((choice) => {
|
|
33
|
+
return (React.createElement(ButtonGroup, { id: id, orientation: "horizontal" }, enumMetadata.choices.map((choice) => {
|
|
34
34
|
const icon = findIcon(enumIcons?.get(choice.value));
|
|
35
35
|
return (React.createElement(IconButton, { key: choice.value, onClick: () => {
|
|
36
36
|
onChange({ choice: choice.value });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumButtonGroup.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/EnumButtonGroup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,qBAAqB;AAErB,gBAAgB;AAChB,MAAM,CAAC,MAAM,yBAAyB,GAAe,gBAAgB,CAAC;IACpE,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,MAAM;QACxB,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,eAAe;IAClE,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,qBAAqB;CAC9B,CAAC,CAAC;AAEH,SAAS,qBAAqB,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,
|
|
1
|
+
{"version":3,"file":"EnumButtonGroup.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/EnumButtonGroup.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gB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,MAAM,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;IAE1E,OAAO,CACL,oBAAC,WAAW,IAAC,EAAE,EAAE,EAAE,EAAE,WAAW,EAAC,YAAY,IAC1C,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACnC,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,OAAO,CACL,oBAAC,UAAU,IACT,GAAG,EAAE,MAAM,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;gBACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;gBACnC,MAAM,EAAE,EAAE,CAAC;YACb,CAAC,EACD,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,MAAM,CAAC,KAAK,KAAK,YAAY,CAAC,MAAM,EAC9C,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,IAEjB,IAAI,CACM,CACd,CAAC;IACJ,CAAC,CAAC,CACU,CACf,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,OAA4B,EAC5B,MAA+B;IAE/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport type { ButtonGroupEditorParams } from \"@itwin/appui-abstract\";\nimport {\n type EnumerationChoice,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport type { EditorProps, EditorSpec } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { EnumValue } from \"../../values/Values.js\";\nimport { useEnumMetadata } from \"./UseEnumMetadata.js\";\nimport { useButtonGroupEditorParams } from \"./UseEditorParams.js\";\nimport { ButtonGroup, IconButton } from \"@itwin/itwinui-react\";\nimport { findIcon } from \"../IconsRegistry.js\";\nimport { isEnum } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const EnumButtonGroupEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"enum\" &&\n metadata.preferredEditor === StandardEditorNames.EnumButtonGroup,\n isValueSupported: isEnum,\n Editor: EnumButtonGroupEditor,\n});\n\nfunction EnumButtonGroupEditor({\n value,\n onChange,\n commit,\n size,\n disabled,\n metadata,\n id,\n}: EditorProps<OldEditorMetadata, EnumValue>) {\n const enumMetadata = useEnumMetadata(metadata);\n const buttonGroupParams = useButtonGroupEditorParams(metadata);\n\n const enumIcons = React.useMemo(() => {\n return buttonGroupParams\n ? createIconsMap(enumMetadata.choices, buttonGroupParams)\n : undefined;\n }, [enumMetadata, buttonGroupParams]);\n\n const firstChoice = enumMetadata.choices[0] as EnumerationChoice | undefined;\n const currentValue = value ? value : { choice: firstChoice?.value ?? \"\" };\n\n return (\n <ButtonGroup id={id} orientation=\"horizontal\">\n {enumMetadata.choices.map((choice) => {\n const icon = findIcon(enumIcons?.get(choice.value));\n return (\n <IconButton\n key={choice.value}\n onClick={() => {\n onChange({ choice: choice.value });\n commit?.();\n }}\n label={choice.label}\n isActive={choice.value === currentValue.choice}\n size={size}\n disabled={disabled}\n >\n {icon}\n </IconButton>\n );\n })}\n </ButtonGroup>\n );\n}\n\nfunction createIconsMap(\n choices: EnumerationChoice[],\n params: ButtonGroupEditorParams\n) {\n const icons = new Map<string | number, string>();\n for (let i = 0; i < choices.length; i++) {\n const iconDef = params.buttons[i];\n icons.set(choices[i].value, iconDef.iconSpec);\n }\n return icons;\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorProps, EditorSpec } from "../../Types.js";
|
|
3
|
+
import type { OldEditorMetadata } from "../Metadata.js";
|
|
4
|
+
import type { NumericValue } from "../../values/Values.js";
|
|
5
|
+
import type { WithConstraints } from "../../ConstraintUtils.js";
|
|
2
6
|
/** @internal */
|
|
3
7
|
export declare const NumericInputEditorSpec: EditorSpec;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare function NumericInputEditor({ metadata, value, onChange, size, disabled, id, }: EditorProps<WithConstraints<OldEditorMetadata>, NumericValue>): React.JSX.Element;
|
|
4
10
|
//# sourceMappingURL=NumericInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInput.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/NumericInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NumericInput.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/NumericInput.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAO3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKhE,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,EAAE,UAOnC,CAAC;AAEH,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,EAAE,GACH,EAAE,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,YAAY,CAAC,qBA2D/D"}
|
|
@@ -9,6 +9,7 @@ import { isOldEditorMetadata } from "../Metadata.js";
|
|
|
9
9
|
import { useInputEditorSizeParams, useRangeEditorParams, } from "./UseEditorParams.js";
|
|
10
10
|
import { Input } from "@itwin/itwinui-react";
|
|
11
11
|
import { isNumeric } from "../../values/ValueUtilities.js";
|
|
12
|
+
import { getNumericConstraints } from "../../ConstraintUtils.js";
|
|
12
13
|
/* v8 ignore start */
|
|
13
14
|
/** @internal */
|
|
14
15
|
export const NumericInputEditorSpec = createEditorSpec({
|
|
@@ -18,9 +19,23 @@ export const NumericInputEditorSpec = createEditorSpec({
|
|
|
18
19
|
isValueSupported: isNumeric,
|
|
19
20
|
Editor: NumericInputEditor,
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
/** @internal */
|
|
23
|
+
export function NumericInputEditor({ metadata, value, onChange, size, disabled, id, }) {
|
|
22
24
|
const sizeParams = useInputEditorSizeParams(metadata);
|
|
23
25
|
const rangeParams = useRangeEditorParams(metadata);
|
|
26
|
+
const { min: constraintMin, max: constraintMax } = getNumericConstraints(metadata.constraints);
|
|
27
|
+
// Larger minimum value takes precedence
|
|
28
|
+
const effectiveMin = rangeParams?.minimum !== undefined
|
|
29
|
+
? constraintMin !== undefined
|
|
30
|
+
? Math.max(rangeParams.minimum, constraintMin)
|
|
31
|
+
: rangeParams.minimum
|
|
32
|
+
: constraintMin;
|
|
33
|
+
// Smaller maximum value takes precedence
|
|
34
|
+
const effectiveMax = rangeParams?.maximum !== undefined
|
|
35
|
+
? constraintMax !== undefined
|
|
36
|
+
? Math.min(rangeParams.maximum, constraintMax)
|
|
37
|
+
: rangeParams.maximum
|
|
38
|
+
: constraintMax;
|
|
24
39
|
const handleChange = (newValue) => {
|
|
25
40
|
onChange({
|
|
26
41
|
displayValue: newValue,
|
|
@@ -36,15 +51,15 @@ function NumericInputEditor({ metadata, value, onChange, size, disabled, }) {
|
|
|
36
51
|
}
|
|
37
52
|
: undefined;
|
|
38
53
|
const inputProps = useNumericInput({
|
|
39
|
-
min:
|
|
40
|
-
max:
|
|
54
|
+
min: effectiveMin,
|
|
55
|
+
max: effectiveMax,
|
|
41
56
|
precision: rangeParams?.precision,
|
|
42
57
|
step: rangeParams?.step,
|
|
43
58
|
maxLength: sizeParams?.maxLength,
|
|
44
59
|
onChange: handleChange,
|
|
45
60
|
value: value?.displayValue ?? "",
|
|
46
61
|
});
|
|
47
|
-
return (React.createElement(Input, { style: style, size: size, disabled: disabled, ...inputProps }));
|
|
62
|
+
return (React.createElement(Input, { id: id, style: style, size: size, disabled: disabled, ...inputProps }));
|
|
48
63
|
}
|
|
49
64
|
function useNumericInput({ min, max, step, precision, maxLength, value, onChange, }) {
|
|
50
65
|
const formatValue = (val) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/NumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,sB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EAAE;QAC9D,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACxC,IAAI,SAAS,IAAI,YAAY,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;YACjD,OAAO;QACT,CAAC;QACD,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAChC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YAC9D,IAAI,iBAAiB,KAAK,cAAc,EAAE,CAAC;gBACzC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;gBACrC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,GAAG;QACH,GAAG;QACH,IAAI;QACJ,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport { StandardEditorNames } from \"@itwin/appui-abstract\";\nimport type { EditorProps, EditorSpec } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useInputEditorSizeParams,\n useRangeEditorParams,\n} from \"./UseEditorParams.js\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\nimport type { WithConstraints } from \"../../ConstraintUtils.js\";\nimport { getNumericConstraints } from \"../../ConstraintUtils.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const NumericInputEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n metadata.preferredEditor === StandardEditorNames.NumericInput,\n isValueSupported: isNumeric,\n Editor: NumericInputEditor,\n});\n\n/** @internal */\nexport function NumericInputEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n id,\n}: EditorProps<WithConstraints<OldEditorMetadata>, NumericValue>) {\n const sizeParams = useInputEditorSizeParams(metadata);\n const rangeParams = useRangeEditorParams(metadata);\n const { min: constraintMin, max: constraintMax } = getNumericConstraints(\n metadata.constraints\n );\n\n // Larger minimum value takes precedence\n const effectiveMin =\n rangeParams?.minimum !== undefined\n ? constraintMin !== undefined\n ? Math.max(rangeParams.minimum, constraintMin)\n : rangeParams.minimum\n : constraintMin;\n // Smaller maximum value takes precedence\n const effectiveMax =\n rangeParams?.maximum !== undefined\n ? constraintMax !== undefined\n ? Math.min(rangeParams.maximum, constraintMax)\n : rangeParams.maximum\n : constraintMax;\n\n const handleChange = (newValue: string) => {\n onChange({\n displayValue: newValue,\n rawValue: parseFloat(newValue),\n });\n };\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n maxWidth:\n sizeParams?.maxSize !== undefined\n ? `${sizeParams?.maxSize * 0.75}em`\n : undefined,\n }\n : undefined;\n\n const inputProps = useNumericInput({\n min: effectiveMin,\n max: effectiveMax,\n precision: rangeParams?.precision,\n step: rangeParams?.step,\n maxLength: sizeParams?.maxLength,\n onChange: handleChange,\n value: value?.displayValue ?? \"\",\n });\n\n return (\n <Input\n id={id}\n style={style}\n size={size}\n disabled={disabled}\n {...inputProps}\n />\n );\n}\n\ninterface UseNumericInputProps {\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n maxLength?: number;\n value: string;\n onChange: (newValue: string) => void;\n}\n\nfunction useNumericInput({\n min,\n max,\n step,\n precision,\n maxLength,\n value,\n onChange,\n}: UseNumericInputProps) {\n const formatValue = (val: number) => {\n const appliedMin = min ?? Number.MIN_VALUE;\n const appliedMax = max ?? Number.MAX_VALUE;\n const valueInRange = Math.min(appliedMax, Math.max(appliedMin, val));\n\n return precision\n ? valueInRange.toFixed(precision)\n : valueInRange.toString();\n };\n\n const [formattedValue, setFormattedValue] = React.useState(() => {\n return value.length !== 0 ? formatValue(Number(value)) : value;\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = event.target.value;\n if (maxLength && currentValue.length > maxLength) {\n return;\n }\n setFormattedValue(currentValue);\n onChange(currentValue);\n };\n\n const handleBlur = () => {\n if (precision) {\n const newFormattedValue = formatValue(Number(formattedValue));\n if (newFormattedValue !== formattedValue) {\n setFormattedValue(newFormattedValue);\n onChange(newFormattedValue);\n }\n }\n };\n\n return {\n type: \"number\",\n min,\n max,\n step,\n value: formattedValue,\n onChange: handleChange,\n onBlur: handleBlur,\n };\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -20,7 +20,7 @@ export const SliderEditorSpec = createEditorSpec({
|
|
|
20
20
|
isValueSupported: isNumeric,
|
|
21
21
|
Editor: SliderEditor,
|
|
22
22
|
});
|
|
23
|
-
function SliderEditor({ metadata, value, disabled, onChange, commit, size, }) {
|
|
23
|
+
function SliderEditor({ metadata, value, disabled, onChange, commit, size, id, }) {
|
|
24
24
|
const sliderParams = useSliderEditorParams(metadata);
|
|
25
25
|
if (!sliderParams) {
|
|
26
26
|
return null;
|
|
@@ -44,7 +44,7 @@ function SliderEditor({ metadata, value, disabled, onChange, commit, size, }) {
|
|
|
44
44
|
commit?.();
|
|
45
45
|
}
|
|
46
46
|
}, applyBackground: true },
|
|
47
|
-
React.createElement(Button, { style: { width: "100%" }, size: size, disabled: disabled }, currentValue)));
|
|
47
|
+
React.createElement(Button, { id: id, style: { width: "100%" }, size: size, disabled: disabled }, currentValue)));
|
|
48
48
|
}
|
|
49
49
|
function getTickLabels(sliderParams) {
|
|
50
50
|
if (!sliderParams.showTicks || !sliderParams.showTickLabels) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/Slider.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,qBAAqB;AAErB,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;IAC/C,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CACrB,CAAC,KAAK,EAAE,EAAE,CAAC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,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,SAAS,GAAG,CAAC,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;QACxE,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChD,eAAe,CAAC,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,YAAY;SAChB,aAAa,EAAE,EAAE;SACjB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,eAAe,CAAC,KAAa,EAAE,MAA0B;IAChE,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;AACzE,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport type { EditorProps } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport type { SliderEditorParams } from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport { Button, Icon, Popover, Slider } from \"@itwin/itwinui-react\";\nimport { useSliderEditorParams } from \"./UseEditorParams.js\";\nimport { findIcon } from \"../IconsRegistry.js\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const SliderEditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n !!metadata.params?.find(\n (param) => param.type === PropertyEditorParamTypes.Slider.valueOf()\n ) &&\n metadata.preferredEditor === StandardEditorNames.Slider,\n isValueSupported: isNumeric,\n Editor: SliderEditor,\n});\n\nfunction SliderEditor({\n metadata,\n value,\n disabled,\n onChange,\n commit,\n size,\n id,\n}: EditorProps<OldEditorMetadata, NumericValue>) {\n const sliderParams = useSliderEditorParams(metadata);\n if (!sliderParams) {\n return null;\n }\n\n const minLabel =\n sliderParams.showMinMax && sliderParams.minIconSpec ? (\n <Icon>{findIcon(sliderParams.minIconSpec)}</Icon>\n ) : undefined;\n const maxLabel =\n sliderParams.showMinMax && sliderParams.maxIconSpec ? (\n <Icon>{findIcon(sliderParams.maxIconSpec)}</Icon>\n ) : undefined;\n\n const handleChange = (values: ReadonlyArray<number>): void => {\n const newValue = values[0];\n onChange({ rawValue: newValue, displayValue: `${newValue}` });\n };\n\n const currentValue = value?.rawValue ?? sliderParams.minimum;\n const slider = (\n <Slider\n values={[currentValue]}\n min={sliderParams.minimum}\n max={sliderParams.maximum}\n step={sliderParams.step}\n thumbMode={\n 1 === sliderParams.mode ? \"allow-crossing\" : \"inhibit-crossing\"\n }\n trackDisplayMode={!sliderParams.reversed ? \"auto\" : \"odd-segments\"}\n minLabel={minLabel}\n maxLabel={maxLabel}\n tooltipProps={(_index, tooltipValue) => {\n return {\n placement: sliderParams.tooltipBelow ? \"bottom\" : \"top\",\n content: formatTickLabel(tooltipValue, sliderParams),\n visible: sliderParams.showTooltip,\n };\n }}\n tickLabels={getTickLabels(sliderParams)}\n onChange={handleChange}\n disabled={disabled}\n />\n );\n return (\n <Popover\n placement=\"bottom\"\n style={{ minWidth: \"300px\", padding: \"8px\" }}\n content={slider}\n onVisibleChange={(visible) => {\n if (!visible) {\n commit?.();\n }\n }}\n applyBackground={true}\n >\n <Button id={id} style={{ width: \"100%\" }} size={size} disabled={disabled}>\n {currentValue}\n </Button>\n </Popover>\n );\n}\n\nfunction getTickLabels(sliderParams: SliderEditorParams) {\n if (!sliderParams.showTicks || !sliderParams.showTickLabels) {\n return undefined;\n }\n const count = sliderParams.getTickCount ? sliderParams.getTickCount() : 0;\n if (count > 0) {\n const increment = (sliderParams.maximum - sliderParams.minimum) / count;\n return Array.from({ length: count + 1 }, (_, i) =>\n formatTickLabel(i * increment + sliderParams.minimum, sliderParams)\n );\n }\n return sliderParams\n .getTickValues?.()\n .map((val) => formatTickLabel(val, sliderParams));\n}\n\nfunction formatTickLabel(value: number, params: SliderEditorParams) {\n return params.formatTooltip ? params.formatTooltip(value) : `${value}`;\n}\n\n/* v8 ignore stop */\n"]}
|