@itwin/components-react 5.3.0 → 5.4.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 +14 -1
- package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -1
- package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.js +5 -0
- package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/components-react/new-editors/EditorRenderer.d.ts +11 -0
- package/lib/components-react/new-editors/EditorRenderer.d.ts.map +1 -0
- package/lib/components-react/new-editors/EditorRenderer.js +22 -0
- package/lib/components-react/new-editors/EditorRenderer.js.map +1 -0
- package/lib/components-react/new-editors/Types.d.ts +46 -0
- package/lib/components-react/new-editors/Types.d.ts.map +1 -0
- package/lib/components-react/new-editors/Types.js +20 -0
- package/lib/components-react/new-editors/Types.js.map +1 -0
- package/lib/components-react/new-editors/UseCommittableValue.d.ts +51 -0
- package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -0
- package/lib/components-react/new-editors/UseCommittableValue.js +85 -0
- package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -0
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/BooleanEditor.js +22 -0
- package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/DateEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/DateEditor.js +18 -0
- package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/DateInput.d.ts +15 -0
- package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/DateInput.js +23 -0
- package/lib/components-react/new-editors/editors/DateInput.js.map +1 -0
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/DateTimeEditor.js +18 -0
- package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/EnumEditor.js +30 -0
- package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +8 -0
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/FallbackEditor.js +41 -0
- package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts +24 -0
- package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/FormattedNumericInput.js +77 -0
- package/lib/components-react/new-editors/editors/FormattedNumericInput.js.map +1 -0
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/NumericEditor.js +23 -0
- package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/TextEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/TextEditor.js +17 -0
- package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +10 -0
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors/ToggleEditor.js +22 -0
- package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -0
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts +50 -0
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.js +117 -0
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts +12 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js +14 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js.map +1 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts +15 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js +25 -0
- package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js.map +1 -0
- package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts +16 -0
- package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/editors-registry/UseEditor.js +36 -0
- package/lib/components-react/new-editors/editors-registry/UseEditor.js.map +1 -0
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts +17 -0
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/EditorInterop.js +146 -0
- package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -0
- package/lib/components-react/new-editors/interop/IconsRegistry.d.ts +6 -0
- package/lib/components-react/new-editors/interop/IconsRegistry.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/IconsRegistry.js +41 -0
- package/lib/components-react/new-editors/interop/IconsRegistry.js.map +1 -0
- package/lib/components-react/new-editors/interop/Metadata.d.ts +21 -0
- package/lib/components-react/new-editors/interop/Metadata.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/Metadata.js +13 -0
- package/lib/components-react/new-editors/interop/Metadata.js.map +1 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +22 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +41 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Color.d.ts +7 -0
- package/lib/components-react/new-editors/interop/old-editors/Color.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Color.js +48 -0
- package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +3 -0
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +59 -0
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts +4 -0
- package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Enum.js +23 -0
- package/lib/components-react/new-editors/interop/old-editors/Enum.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts +4 -0
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +50 -0
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +4 -0
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +86 -0
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts +3 -0
- package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/Slider.js +66 -0
- package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts +3 -0
- package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js +33 -0
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts +31 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js +52 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts +8 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts.map +1 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js +41 -0
- package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js.map +1 -0
- package/lib/components-react/new-editors/values/Metadata.d.ts +35 -0
- package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -0
- package/lib/components-react/new-editors/values/Metadata.js +9 -0
- package/lib/components-react/new-editors/values/Metadata.js.map +1 -0
- package/lib/components-react/new-editors/values/ValueUtilities.d.ts +40 -0
- package/lib/components-react/new-editors/values/ValueUtilities.d.ts.map +1 -0
- package/lib/components-react/new-editors/values/ValueUtilities.js +84 -0
- package/lib/components-react/new-editors/values/ValueUtilities.js.map +1 -0
- package/lib/components-react/new-editors/values/Values.d.ts +58 -0
- package/lib/components-react/new-editors/values/Values.d.ts.map +1 -0
- package/lib/components-react/new-editors/values/Values.js +9 -0
- package/lib/components-react/new-editors/values/Values.js.map +1 -0
- package/lib/components-react/properties/IconNodeEditorParam.d.ts +16 -0
- package/lib/components-react/properties/IconNodeEditorParam.d.ts.map +1 -0
- package/lib/components-react/properties/IconNodeEditorParam.js +20 -0
- package/lib/components-react/properties/IconNodeEditorParam.js.map +1 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +7 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +2 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +6 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +2 -0
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +3 -3
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/components-react.d.ts +9 -0
- package/lib/components-react.d.ts.map +1 -1
- package/lib/components-react.js +7 -0
- 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 +4 -6
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyEditors
|
|
3
|
+
*/
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import type { EditorSpec } from "../Types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.
|
|
8
|
+
* Editors added through the lowest level provider will have the highest priority.
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export declare function EditorsRegistryProvider({ children, editors, }: {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
editors: EditorSpec[];
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
//# sourceMappingURL=EditorsRegistryProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorsRegistryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryProvider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB,qBAcA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module PropertyEditors
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { useContext, useMemo } from "react";
|
|
10
|
+
import { EditorsRegistryContext } from "./EditorsRegistryContext.js";
|
|
11
|
+
/**
|
|
12
|
+
* Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.
|
|
13
|
+
* Editors added through the lowest level provider will have the highest priority.
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export function EditorsRegistryProvider({ children, editors, }) {
|
|
17
|
+
const parentContext = useContext(EditorsRegistryContext);
|
|
18
|
+
const value = useMemo(() => {
|
|
19
|
+
return {
|
|
20
|
+
editors: [...editors, ...parentContext.editors],
|
|
21
|
+
};
|
|
22
|
+
}, [parentContext, editors]);
|
|
23
|
+
return (React.createElement(EditorsRegistryContext.Provider, { value: value }, children));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=EditorsRegistryProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorsRegistryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryProvider.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,aAAa,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAEzD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,OAAO;YACL,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC;SAChD,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7B,OAAO,CACL,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC1C,QAAQ,CACuB,CACnC,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 { useContext, useMemo } from \"react\";\nimport type { EditorSpec } from \"../Types.js\";\nimport { EditorsRegistryContext } from \"./EditorsRegistryContext.js\";\n\n/**\n * Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.\n * Editors added through the lowest level provider will have the highest priority.\n * @beta\n */\nexport function EditorsRegistryProvider({\n children,\n editors,\n}: {\n children: React.ReactNode;\n editors: EditorSpec[];\n}) {\n const parentContext = useContext(EditorsRegistryContext);\n\n const value = useMemo(() => {\n return {\n editors: [...editors, ...parentContext.editors],\n };\n }, [parentContext, editors]);\n\n return (\n <EditorsRegistryContext.Provider value={value}>\n {children}\n </EditorsRegistryContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyEditors
|
|
3
|
+
*/
|
|
4
|
+
import type { EditorSpec } from "../Types.js";
|
|
5
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
6
|
+
import type { Value } from "../values/Values.js";
|
|
7
|
+
/** v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.
|
|
10
|
+
* If no registered editor is found, it will use applicable default editor.
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export declare function useEditor(metadata: ValueMetadata, value: Value | undefined): EditorSpec["Editor"] | undefined;
|
|
15
|
+
/** v8 ignore stop */
|
|
16
|
+
//# sourceMappingURL=UseEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/UseEditor.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAKjD,sBAAsB;AAEtB;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,KAAK,GAAG,SAAS,GACvB,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAyBlC;AAED,qBAAqB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module PropertyEditors
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { defaultEditorSpecs, interopEditorSpecs } from "./DefaultEditors.js";
|
|
10
|
+
import { EditorsRegistryContext } from "./EditorsRegistryContext.js";
|
|
11
|
+
import { FallbackEditor } from "../editors/FallbackEditor.js";
|
|
12
|
+
/** v8 ignore start */
|
|
13
|
+
/**
|
|
14
|
+
* Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.
|
|
15
|
+
* If no registered editor is found, it will use applicable default editor.
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export function useEditor(metadata, value) {
|
|
20
|
+
const { editors } = React.useContext(EditorsRegistryContext);
|
|
21
|
+
const registeredEditor = editors.find((editor) => editor.applies(metadata, value))?.Editor;
|
|
22
|
+
if (registeredEditor) {
|
|
23
|
+
return registeredEditor;
|
|
24
|
+
}
|
|
25
|
+
const oldEditor = interopEditorSpecs.find((editor) => editor.applies(metadata, value))?.Editor;
|
|
26
|
+
if (oldEditor) {
|
|
27
|
+
return oldEditor;
|
|
28
|
+
}
|
|
29
|
+
const defaultEditor = defaultEditorSpecs.find((editor) => editor.applies(metadata, value))?.Editor;
|
|
30
|
+
if (defaultEditor) {
|
|
31
|
+
return defaultEditor;
|
|
32
|
+
}
|
|
33
|
+
return FallbackEditor;
|
|
34
|
+
}
|
|
35
|
+
/** v8 ignore stop */
|
|
36
|
+
//# sourceMappingURL=UseEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/UseEditor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,sBAAsB;AAEtB;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,QAAuB,EACvB,KAAwB;IAExB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAE7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC/C,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACnD,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACvD,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,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/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport type { EditorSpec } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { Value } from \"../values/Values.js\";\nimport { defaultEditorSpecs, interopEditorSpecs } from \"./DefaultEditors.js\";\nimport { EditorsRegistryContext } from \"./EditorsRegistryContext.js\";\nimport { FallbackEditor } from \"../editors/FallbackEditor.js\";\n\n/** v8 ignore start */\n\n/**\n * Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.\n * If no registered editor is found, it will use applicable default editor.\n *\n * @beta\n */\nexport function useEditor(\n metadata: ValueMetadata,\n value: Value | undefined\n): EditorSpec[\"Editor\"] | undefined {\n const { editors } = React.useContext(EditorsRegistryContext);\n\n const registeredEditor = editors.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (registeredEditor) {\n return registeredEditor;\n }\n\n const oldEditor = interopEditorSpecs.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (oldEditor) {\n return oldEditor;\n }\n\n const defaultEditor = defaultEditorSpecs.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (defaultEditor) {\n return defaultEditor;\n }\n\n return FallbackEditor;\n}\n\n/** v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PrimitiveValue, PropertyRecord } from "@itwin/appui-abstract";
|
|
2
|
+
import type { Value as NewEditorValue } from "../values/Values.js";
|
|
3
|
+
import type { OldEditorMetadata } from "./Metadata.js";
|
|
4
|
+
/**
|
|
5
|
+
* Interop utilities for converting between old and new editor values.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare namespace EditorInterop {
|
|
9
|
+
/** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */
|
|
10
|
+
function getMetadataAndValue(propertyRecord: PropertyRecord): {
|
|
11
|
+
metadata: OldEditorMetadata | undefined;
|
|
12
|
+
value: NewEditorValue | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** Converts new editors system `Value` into old `PrimitiveValue` */
|
|
15
|
+
function convertToPrimitiveValue(newValue: NewEditorValue): PrimitiveValue;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EditorInterop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASvD;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,GAAG;QACnE,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;QACxC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CA6FA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CAsChB;CACF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { PropertyValueFormat } from "@itwin/appui-abstract";
|
|
6
|
+
import { isBoolean, isDate, isEnum, isNumeric, isText, } from "../values/ValueUtilities.js";
|
|
7
|
+
/**
|
|
8
|
+
* Interop utilities for converting between old and new editor values.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export var EditorInterop;
|
|
12
|
+
(function (EditorInterop) {
|
|
13
|
+
/** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */
|
|
14
|
+
function getMetadataAndValue(propertyRecord) {
|
|
15
|
+
const baseMetadata = {
|
|
16
|
+
preferredEditor: propertyRecord.property.editor?.name,
|
|
17
|
+
params: propertyRecord.property.editor?.params,
|
|
18
|
+
extendedData: propertyRecord.extendedData,
|
|
19
|
+
enum: propertyRecord.property.enum,
|
|
20
|
+
typename: propertyRecord.property.typename,
|
|
21
|
+
};
|
|
22
|
+
const primitiveValue = propertyRecord.value;
|
|
23
|
+
switch (propertyRecord.property.typename) {
|
|
24
|
+
case "text":
|
|
25
|
+
case "string":
|
|
26
|
+
return {
|
|
27
|
+
metadata: {
|
|
28
|
+
...baseMetadata,
|
|
29
|
+
type: "string",
|
|
30
|
+
},
|
|
31
|
+
value: {
|
|
32
|
+
value: primitiveValue.value ?? "",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
case "dateTime":
|
|
36
|
+
case "shortdate":
|
|
37
|
+
return {
|
|
38
|
+
metadata: {
|
|
39
|
+
...baseMetadata,
|
|
40
|
+
type: propertyRecord.property.typename === "shortdate"
|
|
41
|
+
? "date"
|
|
42
|
+
: "dateTime",
|
|
43
|
+
},
|
|
44
|
+
value: {
|
|
45
|
+
value: primitiveValue.value ?? new Date(),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
case "boolean":
|
|
49
|
+
case "bool":
|
|
50
|
+
return {
|
|
51
|
+
metadata: {
|
|
52
|
+
...baseMetadata,
|
|
53
|
+
type: "bool",
|
|
54
|
+
},
|
|
55
|
+
value: {
|
|
56
|
+
value: primitiveValue.value ?? false,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
case "float":
|
|
60
|
+
case "double":
|
|
61
|
+
case "int":
|
|
62
|
+
case "integer":
|
|
63
|
+
case "number":
|
|
64
|
+
return {
|
|
65
|
+
metadata: {
|
|
66
|
+
...baseMetadata,
|
|
67
|
+
type: "number",
|
|
68
|
+
},
|
|
69
|
+
value: {
|
|
70
|
+
rawValue: primitiveValue.value,
|
|
71
|
+
displayValue: primitiveValue.displayValue
|
|
72
|
+
? primitiveValue.displayValue
|
|
73
|
+
: primitiveValue.value !== undefined
|
|
74
|
+
? `${primitiveValue.value}`
|
|
75
|
+
: "",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
case "enum":
|
|
79
|
+
return {
|
|
80
|
+
metadata: {
|
|
81
|
+
...baseMetadata,
|
|
82
|
+
type: "enum",
|
|
83
|
+
},
|
|
84
|
+
value: {
|
|
85
|
+
choice: primitiveValue.value,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
case "navigation":
|
|
89
|
+
return {
|
|
90
|
+
metadata: {
|
|
91
|
+
...baseMetadata,
|
|
92
|
+
type: "instanceKey",
|
|
93
|
+
},
|
|
94
|
+
value: {
|
|
95
|
+
key: primitiveValue.value,
|
|
96
|
+
label: primitiveValue.displayValue ?? "",
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
metadata: undefined,
|
|
102
|
+
value: undefined,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
EditorInterop.getMetadataAndValue = getMetadataAndValue;
|
|
106
|
+
/** Converts new editors system `Value` into old `PrimitiveValue` */
|
|
107
|
+
function convertToPrimitiveValue(newValue) {
|
|
108
|
+
if (isText(newValue)) {
|
|
109
|
+
return {
|
|
110
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
111
|
+
value: newValue.value,
|
|
112
|
+
displayValue: newValue.value,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (isNumeric(newValue)) {
|
|
116
|
+
return {
|
|
117
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
118
|
+
value: newValue.rawValue,
|
|
119
|
+
displayValue: newValue.displayValue,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (isBoolean(newValue)) {
|
|
123
|
+
return {
|
|
124
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
125
|
+
value: newValue.value,
|
|
126
|
+
displayValue: newValue.value.toString(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (isDate(newValue)) {
|
|
130
|
+
return {
|
|
131
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
132
|
+
value: newValue.value,
|
|
133
|
+
displayValue: newValue.value.toString(),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (isEnum(newValue)) {
|
|
137
|
+
return {
|
|
138
|
+
valueFormat: PropertyValueFormat.Primitive,
|
|
139
|
+
value: newValue.choice,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
throw new Error("Unsupported value type");
|
|
143
|
+
}
|
|
144
|
+
EditorInterop.convertToPrimitiveValue = convertToPrimitiveValue;
|
|
145
|
+
})(EditorInterop || (EditorInterop = {}));
|
|
146
|
+
//# sourceMappingURL=EditorInterop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,KAAW,aAAa,CA8I7B;AA9ID,WAAiB,aAAa;IAC5B,6EAA6E;IAC7E,SAAgB,mBAAmB,CAAC,cAA8B;QAIhE,MAAM,YAAY,GAAoC;YACpD,eAAe,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI;YACrD,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;YAC9C,Y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EAAE,CAAC;YACxB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;aACxC,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;aACxC,CAAC;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;IAxCe,qCAAuB,0BAwCtC,CAAA;AACH,CAAC,EA9IgB,aAAa,KAAb,aAAa,QA8I7B","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 {\n Primitives,\n PrimitiveValue,\n PropertyRecord,\n} 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\";\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(propertyRecord: PropertyRecord): {\n metadata: OldEditorMetadata | undefined;\n value: NewEditorValue | undefined;\n } {\n const baseMetadata: Omit<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 };\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 } 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 };\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconsRegistry.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/IconsRegistry.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,qBAOzC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { SvgPlaceholder } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
/* v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export function findIcon(iconName) {
|
|
12
|
+
if (!iconName) {
|
|
13
|
+
return React.createElement(SvgPlaceholder, null);
|
|
14
|
+
}
|
|
15
|
+
const icon = webfontIconsMap[iconName];
|
|
16
|
+
return icon ? icon : React.createElement(SvgPlaceholder, null);
|
|
17
|
+
}
|
|
18
|
+
const webfontIconsMap = {
|
|
19
|
+
"icon-select-single": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
20
|
+
React.createElement("path", { d: "m15 7h-1.0922a6.0081 6.0081 0 0 0 -4.9078-4.9078v-1.0922a1 1 0 0 0 -2 0v1.0922a6.0081 6.0081 0 0 0 -4.9078 4.9078h-1.0922a1 1 0 0 0 0 2h1.0923a6.008 6.008 0 0 0 4.9077 4.9078v1.0922a1 1 0 0 0 2 0v-1.0922a6.008 6.008 0 0 0 4.9077-4.9078h1.0923a1 1 0 0 0 0-2zm-2.4769 1.923a4.6245 4.6245 0 0 1 -3.6 3.6 4.6572 4.6572 0 0 1 -1.8462 0 4.6245 4.6245 0 0 1 -3.6-3.6 4.6617 4.6617 0 0 1 0-1.8461 4.6243 4.6243 0 0 1 3.6-3.6 4.6622 4.6622 0 0 1 1.8462 0 4.6243 4.6243 0 0 1 3.6 3.6 4.6617 4.6617 0 0 1 0 1.8461z" }))),
|
|
21
|
+
"icon-select-line": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
22
|
+
React.createElement("path", { d: "M14.35352,1.35352l-.707-.707L.64648,13.646481l.707,.707" }))),
|
|
23
|
+
"icon-select-box": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
24
|
+
React.createElement("path", { d: "m14 2v12h-12v-12zm1-1h-14v14h14z" }))),
|
|
25
|
+
"icon-replace": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
26
|
+
React.createElement("path", { d: "m0 0h7v7h-7zm16 16h-7v-7h7zm-6-1h5v-5h-5zm-6.8484-6.0734-.7425-.7424-1.7678 1.7677 1.0253.0354a3.87023 3.87023 0 0 0 1.096 3.5002 4 4 0 0 0 5.3033.3536l-.7071-.7071a3.02646 3.02646 0 0 1 -4.7023-3.076l1.6617.0354zm10.0932-6.9317a3.99992 3.99992 0 0 0 -5.2679-.3182l.7071.7071a3 3 0 0 1 3.8537.3182 2.85982 2.85982 0 0 1 .7778 2.8284h-1.4849l1.7678 1.7678 1.7678-1.7678h-.9899a4.16081 4.16081 0 0 0 -1.1315-3.5355" }))),
|
|
27
|
+
"icon-select-plus": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
28
|
+
React.createElement("path", { d: "m1 1v14h14v-14zm11 8h-3v3h-2v-3h-3v-2h3v-3h2v3h3z" }))),
|
|
29
|
+
"icon-select-minus": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
30
|
+
React.createElement("path", { d: "m8 0a8 8 0 1 0 8 8 8 8 0 0 0 -8-8zm5 9h-10v-2h10z" }))),
|
|
31
|
+
"icon-app-1": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
32
|
+
React.createElement("path", { d: "M13,1a2.0023,2.0023,0,0,1,2,2V13a2.0023,2.0023,0,0,1-2,2H3a2.0023,2.0023,0,0,1-2-2V3A2.0023,2.0023,0,0,1,3,1H13m0-1H3A3,3,0,0,0,0,3V13a3,3,0,0,0,3,3H13a3,3,0,0,0,3-3V3a3,3,0,0,0-3-3Z" }),
|
|
33
|
+
React.createElement("path", { d: "m8.695 12.223h-.87v-5.597q0-.698.043-1.321-.113.113-.252.236t-1.278 1.047l-.473-.612 2.078-1.606h.752" }))),
|
|
34
|
+
"icon-app-2": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
35
|
+
React.createElement("path", { d: "M13,1a2.0023,2.0023,0,0,1,2,2V13a2.0023,2.0023,0,0,1-2,2H3a2.0023,2.0023,0,0,1-2-2V3A2.0023,2.0023,0,0,1,3,1H13m0-1H3A3,3,0,0,0,0,3V13a3,3,0,0,0,3,3H13a3,3,0,0,0,3-3V3a3,3,0,0,0-3-3Z" }),
|
|
36
|
+
React.createElement("path", { d: "M10.5537,12.2227H5.3926v-.7676L7.46,9.376A15.0726,15.0726,0,0,0,8.7061,8.0117a3.43,3.43,0,0,0,.4512-.7949,2.2694,2.2694,0,0,0,.15-.8325,1.3218,1.3218,0,0,0-.3809-.9966A1.4635,1.4635,0,0,0,7.8682,5.02a2.6559,2.6559,0,0,0-.9258.1611,3.7028,3.7028,0,0,0-.9756.5854L5.4941,5.16a3.6219,3.6219,0,0,1,2.3633-.9023,2.4962,2.4962,0,0,1,1.7354.5669,1.9478,1.9478,0,0,1,.6279,1.5225,2.9407,2.9407,0,0,1-.4189,1.4771A9.38,9.38,0,0,1,8.2334,9.6719L6.5146,11.3525v.043h4.0391Z" }))),
|
|
37
|
+
"icon-apps-itwin": (React.createElement("svg", { viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
38
|
+
React.createElement("path", { d: "m15.99733 3.94971a1.40456 1.40456 0 0 0 -.68186-1.12171l-3.41455-2.02581a1.39719 1.39719 0 0 0 -1.42644 0l-.17514.10392-1.01734.60359-2.22207 1.3183a1.404 1.404 0 0 0 -.68443 1.20209v1.11318l-.85-.50428a1.39692 1.39692 0 0 0 -1.42644 0l-2.15676 1.2796-.99578.59082-.262.15542a1.40386 1.40386 0 0 0 -.68452 1.20205v4.103c0 .0269.00112.05367.00268.08037a1.40454 1.40454 0 0 0 .68186 1.12175l3.41454 2.02584a1.39719 1.39719 0 0 0 1.42644 0l.17515-.10391 1.01733-.60362 2.22207-1.31831a1.404 1.404 0 0 0 .68444-1.202v-1.11327l.85.50429a1.39695 1.39695 0 0 0 1.42644 0l2.15678-1.27961.99579-.59081.262-.15543a1.40386 1.40386 0 0 0 .68448-1.20205v-4.103c0-.02694-.00111-.05371-.00267-.08041zm-11.17745 2.66922a.74413.74413 0 1 1 -.74414.74413.74412.74412 0 0 1 .74414-.74413zm2.037 6.37484-.29972.18471-1.07162.66036-.3669.22609-.18956.11682a.17417.17417 0 0 1 -.04294.02113.25282.25282 0 0 1 -.17289-.013l-.01771-.00815-.10292-.06342-1.82494-1.12454v-1.13313s.00612-.2441.31679-.06657l1.12588.69234v-2.42875l-.70151-.43238v-1.13314s.00612-.24409.31679-.06657l1.58222.973v3.09173l1.1322-.69623c.31067-.17753.31678.06657.31678.06657zm8.54852-7.88831v3.02766a.80664.80664 0 0 1 -.39331.69067l-.262.15543-.99579.59078-2.1568 1.27962a.80236.80236 0 0 1 -.81962 0l-1.15337-.68428v-2.29846a1.40368 1.40368 0 0 0 -.68444-1.202l-1.12365-.66671-.84632-.50212v-1.466a.80677.80677 0 0 1 .39323-.69068l2.22205-1.3183 1.01736-.60359.17516-.10393a.8026.8026 0 0 1 .81963 0l3.41447 2.0258a.814.814 0 0 1 .39176.645c.00088.01519.00166.0304.00166.04571zm-3.95807-2.71336 2.15631 1.32879v1.33893s-.00723.28842-.37432.07866l-1.33032-.81808v2.86984l.82891.5109v1.33893s-.00723.28843-.37432.07867l-1.86959-1.14966v-3.65328l-1.33781.82268c-.3671.20976-.37432-.07866-.37432-.07866v-1.33893l.35413-.21824 1.26623-.7803.43353-.26717.224-.138a.20549.20549 0 0 1 .05074-.025.29863.29863 0 0 1 .2043.01532l.02092.00964z" }))),
|
|
39
|
+
};
|
|
40
|
+
/* v8 ignore stop */
|
|
41
|
+
//# sourceMappingURL=IconsRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconsRegistry.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/IconsRegistry.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,qBAAqB;AAErB;;GAEG;AACH,MAAM,UAAU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E,CACZ,6BAAK,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B;QACzD,8BAAM,CAAC,EAAC,wLAAwL,GAAG;QACnM,8BAAM,CAAC,EAAC,gdAAgd,GAAG,CACvd,CACP;IACD,iBAAiB,EAAE,CACjB,6BAAK,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B;QACzD,8BAAM,CAAC,EAAC,+1DAA+1D,GAAG,CACt2D,CACP;CACF,CAAC;AAEF,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 { SvgPlaceholder } from \"@itwin/itwinui-icons-react\";\nimport * as React from \"react\";\n\n/* v8 ignore start */\n\n/**\n * @internal\n */\nexport function findIcon(iconName?: string) {\n if (!iconName) {\n return <SvgPlaceholder />;\n }\n\n const icon = webfontIconsMap[iconName];\n return icon ? icon : <SvgPlaceholder />;\n}\n\nconst webfontIconsMap: {\n [key: string]: React.JSX.Element;\n} = {\n \"icon-select-single\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m15 7h-1.0922a6.0081 6.0081 0 0 0 -4.9078-4.9078v-1.0922a1 1 0 0 0 -2 0v1.0922a6.0081 6.0081 0 0 0 -4.9078 4.9078h-1.0922a1 1 0 0 0 0 2h1.0923a6.008 6.008 0 0 0 4.9077 4.9078v1.0922a1 1 0 0 0 2 0v-1.0922a6.008 6.008 0 0 0 4.9077-4.9078h1.0923a1 1 0 0 0 0-2zm-2.4769 1.923a4.6245 4.6245 0 0 1 -3.6 3.6 4.6572 4.6572 0 0 1 -1.8462 0 4.6245 4.6245 0 0 1 -3.6-3.6 4.6617 4.6617 0 0 1 0-1.8461 4.6243 4.6243 0 0 1 3.6-3.6 4.6622 4.6622 0 0 1 1.8462 0 4.6243 4.6243 0 0 1 3.6 3.6 4.6617 4.6617 0 0 1 0 1.8461z\" />\n </svg>\n ),\n \"icon-select-line\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M14.35352,1.35352l-.707-.707L.64648,13.646481l.707,.707\" />\n </svg>\n ),\n \"icon-select-box\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m14 2v12h-12v-12zm1-1h-14v14h14z\" />\n </svg>\n ),\n \"icon-replace\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m0 0h7v7h-7zm16 16h-7v-7h7zm-6-1h5v-5h-5zm-6.8484-6.0734-.7425-.7424-1.7678 1.7677 1.0253.0354a3.87023 3.87023 0 0 0 1.096 3.5002 4 4 0 0 0 5.3033.3536l-.7071-.7071a3.02646 3.02646 0 0 1 -4.7023-3.076l1.6617.0354zm10.0932-6.9317a3.99992 3.99992 0 0 0 -5.2679-.3182l.7071.7071a3 3 0 0 1 3.8537.3182 2.85982 2.85982 0 0 1 .7778 2.8284h-1.4849l1.7678 1.7678 1.7678-1.7678h-.9899a4.16081 4.16081 0 0 0 -1.1315-3.5355\" />\n </svg>\n ),\n \"icon-select-plus\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m1 1v14h14v-14zm11 8h-3v3h-2v-3h-3v-2h3v-3h2v3h3z\" />\n </svg>\n ),\n \"icon-select-minus\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m8 0a8 8 0 1 0 8 8 8 8 0 0 0 -8-8zm5 9h-10v-2h10z\" />\n </svg>\n ),\n \"icon-app-1\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M13,1a2.0023,2.0023,0,0,1,2,2V13a2.0023,2.0023,0,0,1-2,2H3a2.0023,2.0023,0,0,1-2-2V3A2.0023,2.0023,0,0,1,3,1H13m0-1H3A3,3,0,0,0,0,3V13a3,3,0,0,0,3,3H13a3,3,0,0,0,3-3V3a3,3,0,0,0-3-3Z\" />\n <path d=\"m8.695 12.223h-.87v-5.597q0-.698.043-1.321-.113.113-.252.236t-1.278 1.047l-.473-.612 2.078-1.606h.752\" />\n </svg>\n ),\n \"icon-app-2\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M13,1a2.0023,2.0023,0,0,1,2,2V13a2.0023,2.0023,0,0,1-2,2H3a2.0023,2.0023,0,0,1-2-2V3A2.0023,2.0023,0,0,1,3,1H13m0-1H3A3,3,0,0,0,0,3V13a3,3,0,0,0,3,3H13a3,3,0,0,0,3-3V3a3,3,0,0,0-3-3Z\" />\n <path d=\"M10.5537,12.2227H5.3926v-.7676L7.46,9.376A15.0726,15.0726,0,0,0,8.7061,8.0117a3.43,3.43,0,0,0,.4512-.7949,2.2694,2.2694,0,0,0,.15-.8325,1.3218,1.3218,0,0,0-.3809-.9966A1.4635,1.4635,0,0,0,7.8682,5.02a2.6559,2.6559,0,0,0-.9258.1611,3.7028,3.7028,0,0,0-.9756.5854L5.4941,5.16a3.6219,3.6219,0,0,1,2.3633-.9023,2.4962,2.4962,0,0,1,1.7354.5669,1.9478,1.9478,0,0,1,.6279,1.5225,2.9407,2.9407,0,0,1-.4189,1.4771A9.38,9.38,0,0,1,8.2334,9.6719L6.5146,11.3525v.043h4.0391Z\" />\n </svg>\n ),\n \"icon-apps-itwin\": (\n <svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"m15.99733 3.94971a1.40456 1.40456 0 0 0 -.68186-1.12171l-3.41455-2.02581a1.39719 1.39719 0 0 0 -1.42644 0l-.17514.10392-1.01734.60359-2.22207 1.3183a1.404 1.404 0 0 0 -.68443 1.20209v1.11318l-.85-.50428a1.39692 1.39692 0 0 0 -1.42644 0l-2.15676 1.2796-.99578.59082-.262.15542a1.40386 1.40386 0 0 0 -.68452 1.20205v4.103c0 .0269.00112.05367.00268.08037a1.40454 1.40454 0 0 0 .68186 1.12175l3.41454 2.02584a1.39719 1.39719 0 0 0 1.42644 0l.17515-.10391 1.01733-.60362 2.22207-1.31831a1.404 1.404 0 0 0 .68444-1.202v-1.11327l.85.50429a1.39695 1.39695 0 0 0 1.42644 0l2.15678-1.27961.99579-.59081.262-.15543a1.40386 1.40386 0 0 0 .68448-1.20205v-4.103c0-.02694-.00111-.05371-.00267-.08041zm-11.17745 2.66922a.74413.74413 0 1 1 -.74414.74413.74412.74412 0 0 1 .74414-.74413zm2.037 6.37484-.29972.18471-1.07162.66036-.3669.22609-.18956.11682a.17417.17417 0 0 1 -.04294.02113.25282.25282 0 0 1 -.17289-.013l-.01771-.00815-.10292-.06342-1.82494-1.12454v-1.13313s.00612-.2441.31679-.06657l1.12588.69234v-2.42875l-.70151-.43238v-1.13314s.00612-.24409.31679-.06657l1.58222.973v3.09173l1.1322-.69623c.31067-.17753.31678.06657.31678.06657zm8.54852-7.88831v3.02766a.80664.80664 0 0 1 -.39331.69067l-.262.15543-.99579.59078-2.1568 1.27962a.80236.80236 0 0 1 -.81962 0l-1.15337-.68428v-2.29846a1.40368 1.40368 0 0 0 -.68444-1.202l-1.12365-.66671-.84632-.50212v-1.466a.80677.80677 0 0 1 .39323-.69068l2.22205-1.3183 1.01736-.60359.17516-.10393a.8026.8026 0 0 1 .81963 0l3.41447 2.0258a.814.814 0 0 1 .39176.645c.00088.01519.00166.0304.00166.04571zm-3.95807-2.71336 2.15631 1.32879v1.33893s-.00723.28842-.37432.07866l-1.33032-.81808v2.86984l.82891.5109v1.33893s-.00723.28843-.37432.07867l-1.86959-1.14966v-3.65328l-1.33781.82268c-.3671.20976-.37432-.07866-.37432-.07866v-1.33893l.35413-.21824 1.26623-.7803.43353-.26717.224-.138a.20549.20549 0 0 1 .05074-.025.29863.29863 0 0 1 .2043.01532l.02092.00964z\" />\n </svg>\n ),\n};\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EnumerationChoicesInfo, PropertyEditorParams } from "@itwin/appui-abstract";
|
|
2
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
3
|
+
/**
|
|
4
|
+
* Metadata that is created by mapping `PropertyRecord` used to render old editor into the new editor metadata.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface OldEditorMetadata extends ValueMetadata {
|
|
8
|
+
params?: PropertyEditorParams[];
|
|
9
|
+
extendedData?: {
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
enum?: EnumerationChoicesInfo;
|
|
13
|
+
quantityType?: string;
|
|
14
|
+
typename: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Type guard for `OldEditorMetadata`.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function isOldEditorMetadata(metadata: ValueMetadata): metadata is OldEditorMetadata;
|
|
21
|
+
//# sourceMappingURL=Metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/Metadata.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1C,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,aAAa,GACtB,QAAQ,IAAI,iBAAiB,CAE/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/**
|
|
6
|
+
* Type guard for `OldEditorMetadata`.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function isOldEditorMetadata(metadata) {
|
|
10
|
+
return metadata.typename !== undefined;
|
|
11
|
+
}
|
|
12
|
+
/* v8 ignore stop */
|
|
13
|
+
//# sourceMappingURL=Metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/Metadata.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAsBhG;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAuB;IAEvB,OAAQ,QAA8B,CAAC,QAAQ,KAAK,SAAS,CAAC;AAChE,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 type {\n EnumerationChoicesInfo,\n PropertyEditorParams,\n} from \"@itwin/appui-abstract\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\n\n/* v8 ignore start */\n\n/**\n * Metadata that is created by mapping `PropertyRecord` used to render old editor into the new editor metadata.\n * @internal\n */\nexport interface OldEditorMetadata extends ValueMetadata {\n params?: PropertyEditorParams[];\n extendedData?: { [key: string]: unknown };\n enum?: EnumerationChoicesInfo;\n quantityType?: string;\n typename: string;\n}\n\n/**\n * Type guard for `OldEditorMetadata`.\n * @internal\n */\nexport function isOldEditorMetadata(\n metadata: ValueMetadata\n): metadata is OldEditorMetadata {\n return (metadata as OldEditorMetadata).typename !== undefined;\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyEditors
|
|
3
|
+
*/
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { type PropertyRecord } from "@itwin/appui-abstract";
|
|
6
|
+
import { type PropertyUpdatedArgs } from "../../editors/EditorContainer.js";
|
|
7
|
+
interface PropertyRecordEditorProps {
|
|
8
|
+
propertyRecord: PropertyRecord;
|
|
9
|
+
onCommit: (args: PropertyUpdatedArgs) => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
setFocus?: boolean;
|
|
13
|
+
size?: "small" | "large";
|
|
14
|
+
editorSystem?: "legacy" | "new";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Editor component for editing property values represented by `PropertyRecord`.
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare function PropertyRecordEditor({ propertyRecord, onCommit, onCancel, onClick, setFocus, size, editorSystem, }: PropertyRecordEditorProps): React.JSX.Element;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=PropertyRecordEditor.d.ts.map
|
|
@@ -0,0 +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;AAM1C,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,qBAiC3B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module PropertyEditors
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { PropertyValueFormat, } from "@itwin/appui-abstract";
|
|
10
|
+
import { EditorInterop } from "./EditorInterop.js";
|
|
11
|
+
import { EditorContainer, } from "../../editors/EditorContainer.js";
|
|
12
|
+
import { useCommittableValue } from "../UseCommittableValue.js";
|
|
13
|
+
import { EditorRenderer } from "../EditorRenderer.js";
|
|
14
|
+
/**
|
|
15
|
+
* Editor component for editing property values represented by `PropertyRecord`.
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
export function PropertyRecordEditor({ propertyRecord, onCommit, onCancel, onClick, setFocus, size, editorSystem, }) {
|
|
19
|
+
const { metadata, value } = EditorInterop.getMetadataAndValue(propertyRecord);
|
|
20
|
+
if (editorSystem === "new" && metadata && value) {
|
|
21
|
+
return (React.createElement(CommittingEditor, { metadata: metadata, initialValue: value, onCommit: (newValue) => {
|
|
22
|
+
onCommit({
|
|
23
|
+
propertyRecord,
|
|
24
|
+
newValue: newValue === undefined
|
|
25
|
+
? { valueFormat: PropertyValueFormat.Primitive }
|
|
26
|
+
: EditorInterop.convertToPrimitiveValue(newValue),
|
|
27
|
+
});
|
|
28
|
+
}, onCancel: onCancel, onClick: onClick, disabled: propertyRecord.isDisabled || propertyRecord.isReadonly, size: size }));
|
|
29
|
+
}
|
|
30
|
+
return (React.createElement(EditorContainer, { propertyRecord: propertyRecord, onCommit: onCommit, onCancel: onCancel, onClick: onClick, setFocus: setFocus }));
|
|
31
|
+
}
|
|
32
|
+
function CommittingEditor({ metadata, initialValue, onCancel, onCommit, onClick, disabled, size, }) {
|
|
33
|
+
const { value, onChange, onKeydown, commit, cancel } = useCommittableValue({
|
|
34
|
+
initialValue,
|
|
35
|
+
onCommit,
|
|
36
|
+
onCancel,
|
|
37
|
+
});
|
|
38
|
+
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
|
+
}
|
|
41
|
+
//# sourceMappingURL=PropertyRecordEditor.js.map
|
|
@@ -0,0 +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;AActD;;;GAGG;AACH,MAAM,UA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AEH,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,GACV,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\";\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 />\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\nfunction CommittingEditor({\n metadata,\n initialValue,\n onCancel,\n onCommit,\n onClick,\n disabled,\n size,\n}: {\n metadata: ValueMetadata;\n initialValue?: Value;\n onCommit: (value?: Value) => void;\n onCancel: () => void;\n onClick?: () => void;\n disabled?: boolean;\n size?: \"small\" | \"large\";\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 />\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/Color.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAU9D;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,UAU5B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { PropertyEditorParamTypes, StandardEditorNames, } from "@itwin/appui-abstract";
|
|
7
|
+
import { ColorPalette, ColorPicker, ColorSwatch, ColorValue, IconButton, Popover, } from "@itwin/itwinui-react";
|
|
8
|
+
import { createEditorSpec } from "../../Types.js";
|
|
9
|
+
import { isOldEditorMetadata } from "../Metadata.js";
|
|
10
|
+
import { useColorEditorParams } from "./UseEditorParams.js";
|
|
11
|
+
import { isNumeric } from "../../values/ValueUtilities.js";
|
|
12
|
+
/* v8 ignore start */
|
|
13
|
+
/**
|
|
14
|
+
* Editor specification for color editor.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const ColorEditorSpec = createEditorSpec({
|
|
18
|
+
isMetadataSupported: (metadata) => isOldEditorMetadata(metadata) &&
|
|
19
|
+
metadata.type === "number" &&
|
|
20
|
+
!!metadata.params?.find((param) => param.type === PropertyEditorParamTypes.ColorData.valueOf()) &&
|
|
21
|
+
metadata.preferredEditor === StandardEditorNames.ColorPicker,
|
|
22
|
+
isValueSupported: isNumeric,
|
|
23
|
+
Editor: ColorEditor,
|
|
24
|
+
});
|
|
25
|
+
function ColorEditor({ value, metadata, onChange, commit, size, }) {
|
|
26
|
+
const colorParams = useColorEditorParams(metadata);
|
|
27
|
+
const colors = colorParams?.colorValues ?? [];
|
|
28
|
+
const currentValue = value
|
|
29
|
+
? value
|
|
30
|
+
: { rawValue: colors[0], displayValue: "" };
|
|
31
|
+
const colorsList = colors.map((color) => ColorValue.fromTbgr(color));
|
|
32
|
+
const activeColor = currentValue.rawValue !== undefined
|
|
33
|
+
? ColorValue.fromTbgr(currentValue.rawValue)
|
|
34
|
+
: colorsList[0];
|
|
35
|
+
const onColorChanged = (color) => {
|
|
36
|
+
onChange({ rawValue: color.toTbgr(), displayValue: "" });
|
|
37
|
+
};
|
|
38
|
+
return (React.createElement(Popover, { content: React.createElement(ColorPicker, { selectedColor: activeColor, onChangeComplete: onColorChanged },
|
|
39
|
+
React.createElement(ColorPalette, { colors: colorsList })), onVisibleChange: (visible) => {
|
|
40
|
+
if (!visible) {
|
|
41
|
+
commit?.();
|
|
42
|
+
}
|
|
43
|
+
} },
|
|
44
|
+
React.createElement(IconButton, { size: size },
|
|
45
|
+
React.createElement(ColorSwatch, { color: activeColor }))));
|
|
46
|
+
}
|
|
47
|
+
/* v8 ignore stop */
|
|
48
|
+
//# sourceMappingURL=Color.js.map
|
|
@@ -0,0 +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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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}: 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 size={size}>\n <ColorSwatch color={activeColor} />\n </IconButton>\n </Popover>\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AA0BA,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,qCAWjC,CAAC"}
|