@itwin/components-react 5.3.1 → 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 +9 -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 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GAC8B;IACtC,OAAO,CACL,oBAAC,SAAS,IACR,KAAK,EAAE,KAAK,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE;YACrB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChC,CAAC,EACD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,IAAI,GACpB,CACH,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 type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { DateValue } from \"../values/Values.js\";\nimport { DateInput } from \"./DateInput.js\";\n\n/* v8 ignore start */\n\n/**\n * Date time value editor that render `DatePicker` component with time selector for changing value.\n * @internal\n */\nexport function DateTimeEditor({\n value,\n onChange,\n commit,\n size,\n disabled,\n}: EditorProps<ValueMetadata, DateValue>) {\n return (\n <DateInput\n value={value?.value}\n onChange={(newValue) => {\n onChange({ value: newValue });\n }}\n onClose={commit}\n size={size}\n disabled={disabled}\n showTimePicker={true}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorProps } from "../Types.js";
|
|
3
|
+
import type { EnumValueMetadata } from "../values/Metadata.js";
|
|
4
|
+
import type { EnumValue } from "../values/Values.js";
|
|
5
|
+
/**
|
|
6
|
+
* Enum value editor that renders `Select` component for changing value.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function EnumEditor({ metadata, value, onChange, commit, size, disabled, }: EditorProps<EnumValueMetadata, EnumValue>): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=EnumEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/EnumEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,iBAAiB,EAAE,SAAS,CAAC,qBAoB3C"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { Select } from "@itwin/itwinui-react";
|
|
7
|
+
/* v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* Enum value editor that renders `Select` component for changing value.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function EnumEditor({ metadata, value, onChange, commit, size, disabled, }) {
|
|
13
|
+
const choices = metadata.choices;
|
|
14
|
+
const currentValue = getEnumValue(value, choices);
|
|
15
|
+
const handleChange = (newChoice) => {
|
|
16
|
+
const choice = choices.find((c) => c.value === newChoice);
|
|
17
|
+
const newValue = { choice: newChoice, label: choice?.label ?? "" };
|
|
18
|
+
onChange(newValue);
|
|
19
|
+
commit?.();
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(Select, { size: size, value: currentValue.choice, onChange: handleChange, options: choices.map((c) => ({ value: c.value, label: c.label })), disabled: disabled }));
|
|
22
|
+
}
|
|
23
|
+
function getEnumValue(value, choices) {
|
|
24
|
+
const defaultValue = choices.length > 0
|
|
25
|
+
? { choice: choices[0].value, label: choices[0].label }
|
|
26
|
+
: { choice: "", label: "" };
|
|
27
|
+
return value ? value : defaultValue;
|
|
28
|
+
}
|
|
29
|
+
/* v8 ignore stop */
|
|
30
|
+
//# sourceMappingURL=EnumEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/EnumEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACkC;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IACjC,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElD,MAAM,YAAY,GAAG,CAAC,SAA0B,EAAE,EAAE;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QACnE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,YAAY,CAAC,MAAM,EAC1B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EACjE,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,KAA4B,EAC5B,OAAqB;IAErB,MAAM,YAAY,GAChB,OAAO,CAAC,MAAM,GAAG,CAAC;QAChB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;QACvD,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AACtC,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 { Select } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { EnumChoice, EnumValueMetadata } from \"../values/Metadata.js\";\nimport type { EnumValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Enum value editor that renders `Select` component for changing value.\n * @internal\n */\nexport function EnumEditor({\n metadata,\n value,\n onChange,\n commit,\n size,\n disabled,\n}: EditorProps<EnumValueMetadata, EnumValue>) {\n const choices = metadata.choices;\n const currentValue = getEnumValue(value, choices);\n\n const handleChange = (newChoice: number | string) => {\n const choice = choices.find((c) => c.value === newChoice);\n const newValue = { choice: newChoice, label: choice?.label ?? \"\" };\n onChange(newValue);\n commit?.();\n };\n\n return (\n <Select\n size={size}\n value={currentValue.choice}\n onChange={handleChange}\n options={choices.map((c) => ({ value: c.value, label: c.label }))}\n disabled={disabled}\n />\n );\n}\n\nfunction getEnumValue(\n value: EnumValue | undefined,\n choices: EnumChoice[]\n): EnumValue {\n const defaultValue =\n choices.length > 0\n ? { choice: choices[0].value, label: choices[0].label }\n : { choice: \"\", label: \"\" };\n return value ? value : defaultValue;\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorProps } from "../Types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fallback editor that renders readonly value if no editor is found.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare function FallbackEditor({ value, size }: EditorProps): React.JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FallbackEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FallbackEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FallbackEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAa/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,WAAW,qBAE1D"}
|
|
@@ -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 * as React from "react";
|
|
6
|
+
import { Input } from "@itwin/itwinui-react";
|
|
7
|
+
import { isBoolean, isDate, isEnum, isInstanceKey, isNumeric, isText, } from "../values/ValueUtilities.js";
|
|
8
|
+
/* v8 ignore start */
|
|
9
|
+
/**
|
|
10
|
+
* Fallback editor that renders readonly value if no editor is found.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export function FallbackEditor({ value, size }) {
|
|
14
|
+
return React.createElement(Input, { readOnly: true, value: getTextValue(value), size: size });
|
|
15
|
+
}
|
|
16
|
+
function getTextValue(value) {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (isBoolean(value)) {
|
|
21
|
+
return value.value ? "true" : "false";
|
|
22
|
+
}
|
|
23
|
+
if (isDate(value)) {
|
|
24
|
+
return value.value.toDateString();
|
|
25
|
+
}
|
|
26
|
+
if (isEnum(value)) {
|
|
27
|
+
return value.choice;
|
|
28
|
+
}
|
|
29
|
+
if (isNumeric(value)) {
|
|
30
|
+
return value.displayValue;
|
|
31
|
+
}
|
|
32
|
+
if (isText(value)) {
|
|
33
|
+
return value.value;
|
|
34
|
+
}
|
|
35
|
+
if (isInstanceKey(value)) {
|
|
36
|
+
return value.label;
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
/* v8 ignore stop */
|
|
41
|
+
//# sourceMappingURL=FallbackEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FallbackEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FallbackEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAe;IACzD,OAAO,oBAAC,KAAK,IAAC,QAAQ,QAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;AACpE,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,YAAY,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { Input } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { Value } from \"../values/Values.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isInstanceKey,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/**\n * Fallback editor that renders readonly value if no editor is found.\n * @internal\n */\nexport function FallbackEditor({ value, size }: EditorProps) {\n return <Input readOnly value={getTextValue(value)} size={size} />;\n}\n\nfunction getTextValue(value?: Value) {\n if (value === undefined) {\n return value;\n }\n if (isBoolean(value)) {\n return value.value ? \"true\" : \"false\";\n }\n if (isDate(value)) {\n return value.value.toDateString();\n }\n if (isEnum(value)) {\n return value.choice;\n }\n if (isNumeric(value)) {\n return value.displayValue;\n }\n if (isText(value)) {\n return value.value;\n }\n if (isInstanceKey(value)) {\n return value.label;\n }\n return \"\";\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module PropertyEditors
|
|
3
|
+
*/
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import type { NumericValue } from "../values/Values.js";
|
|
6
|
+
/**
|
|
7
|
+
* Props for FormattedNumericInput component.
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
interface FormattedNumericInputProps {
|
|
11
|
+
value: NumericValue;
|
|
12
|
+
onChange: (value: NumericValue) => void;
|
|
13
|
+
parseValue: (value: string) => number | undefined;
|
|
14
|
+
formatValue: (num: number) => string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
size?: "small" | "large";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
export declare function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }: FormattedNumericInputProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=FormattedNumericInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormattedNumericInput.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,UAAU,0BAA0B;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAClD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,GACL,EAAE,0BAA0B,qBAgB5B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { Input } from "@itwin/itwinui-react";
|
|
10
|
+
/**
|
|
11
|
+
* A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }) {
|
|
15
|
+
const { currentValue, inputProps } = useParsedNumberInput({
|
|
16
|
+
initialValue: value.rawValue,
|
|
17
|
+
parseValue,
|
|
18
|
+
formatValue,
|
|
19
|
+
});
|
|
20
|
+
const onChangeRef = React.useRef(onChange);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
onChangeRef.current = onChange;
|
|
23
|
+
}, [onChange]);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
onChangeRef.current(currentValue);
|
|
26
|
+
}, [currentValue]);
|
|
27
|
+
return React.createElement(Input, { disabled: disabled, size: size, ...inputProps });
|
|
28
|
+
}
|
|
29
|
+
function useParsedNumberInput({ initialValue, formatValue, parseValue, }) {
|
|
30
|
+
const [state, setState] = React.useState(() => {
|
|
31
|
+
return {
|
|
32
|
+
value: {
|
|
33
|
+
rawValue: initialValue,
|
|
34
|
+
displayValue: initialValue !== undefined ? formatValue(initialValue) : "",
|
|
35
|
+
},
|
|
36
|
+
placeholder: formatValue(initialValue ?? 123.45),
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
setState((prevState) => {
|
|
41
|
+
return {
|
|
42
|
+
...prevState,
|
|
43
|
+
value: {
|
|
44
|
+
...prevState.value,
|
|
45
|
+
displayValue: prevState.value.rawValue !== undefined
|
|
46
|
+
? formatValue(prevState.value.rawValue)
|
|
47
|
+
: "",
|
|
48
|
+
},
|
|
49
|
+
placeholder: formatValue(123.45),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}, [formatValue]);
|
|
53
|
+
const handleChange = (e) => {
|
|
54
|
+
const newValue = e.target.value;
|
|
55
|
+
const rawValue = parseValue(newValue);
|
|
56
|
+
setState((prevState) => {
|
|
57
|
+
return {
|
|
58
|
+
...prevState,
|
|
59
|
+
value: {
|
|
60
|
+
...prevState.value,
|
|
61
|
+
rawValue,
|
|
62
|
+
displayValue: newValue,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
currentValue: state.value,
|
|
69
|
+
inputProps: {
|
|
70
|
+
value: state.value.displayValue,
|
|
71
|
+
placeholder: state.placeholder,
|
|
72
|
+
onChange: handleChange,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/* v8 ignore stop */
|
|
77
|
+
//# sourceMappingURL=FormattedNumericInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormattedNumericInput.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAkB7C;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,GACuB;IAC3B,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC;QACxD,YAAY,EAAE,KAAK,CAAC,QAAQ;QAC5B,UAAU;QACV,WAAW;KACZ,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,KAAM,UAAU,GAAI,CAAC;AACnE,CAAC;AAED,SAAS,oBAAoB,CAAC,EAC5B,YAAY,EACZ,WAAW,EACX,UAAU,GAKX;IAMC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAQ,GAAG,EAAE;QACnD,OAAO;YACL,KAAK,EAAE;gBACL,QAAQ,EAAE,YAAY;gBACtB,YAAY,EACV,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;aAC9D;YACD,WAAW,EAAE,WAAW,CAAC,YAAY,IAAI,MAAM,CAAC;SACjD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,YAAY,EACV,SAAS,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS;wBACpC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;wBACvC,CAAC,CAAC,EAAE;iBACT;gBACD,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;aACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAEtC,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,QAAQ;oBACR,YAAY,EAAE,QAAQ;iBACvB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,KAAK;QACzB,UAAU,EAAE;YACV,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY;YAC/B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,QAAQ,EAAE,YAAY;SACvB;KACF,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/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { NumericValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Props for FormattedNumericInput component.\n * @beta\n */\ninterface FormattedNumericInputProps {\n value: NumericValue;\n onChange: (value: NumericValue) => void;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n disabled?: boolean;\n size?: \"small\" | \"large\";\n}\n\n/**\n * A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.\n * @beta\n */\nexport function FormattedNumericInput({\n onChange,\n value,\n parseValue,\n formatValue,\n disabled,\n size,\n}: FormattedNumericInputProps) {\n const { currentValue, inputProps } = useParsedNumberInput({\n initialValue: value.rawValue,\n parseValue,\n formatValue,\n });\n const onChangeRef = React.useRef(onChange);\n React.useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n React.useEffect(() => {\n onChangeRef.current(currentValue);\n }, [currentValue]);\n\n return <Input disabled={disabled} size={size} {...inputProps} />;\n}\n\nfunction useParsedNumberInput({\n initialValue,\n formatValue,\n parseValue,\n}: {\n initialValue: number | undefined;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n}) {\n interface State {\n value: NumericValue;\n placeholder: string;\n }\n\n const [state, setState] = React.useState<State>(() => {\n return {\n value: {\n rawValue: initialValue,\n displayValue:\n initialValue !== undefined ? formatValue(initialValue) : \"\",\n },\n placeholder: formatValue(initialValue ?? 123.45),\n };\n });\n\n React.useEffect(() => {\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n displayValue:\n prevState.value.rawValue !== undefined\n ? formatValue(prevState.value.rawValue)\n : \"\",\n },\n placeholder: formatValue(123.45),\n };\n });\n }, [formatValue]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n const rawValue = parseValue(newValue);\n\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n rawValue,\n displayValue: newValue,\n },\n };\n });\n };\n\n return {\n currentValue: state.value,\n inputProps: {\n value: state.value.displayValue,\n placeholder: state.placeholder,\n onChange: handleChange,\n },\n };\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorProps } from "../Types.js";
|
|
3
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
4
|
+
import type { NumericValue } from "../values/Values.js";
|
|
5
|
+
/**
|
|
6
|
+
* Numeric value editor that renders `Input` components for changing value.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function NumericEditor({ value, onChange, size, disabled, }: EditorProps<ValueMetadata, NumericValue>): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=NumericEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/NumericEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAe1C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { Input } from "@itwin/itwinui-react";
|
|
7
|
+
/* v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* Numeric value editor that renders `Input` components for changing value.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function NumericEditor({ value, onChange, size, disabled, }) {
|
|
13
|
+
const currentValue = getNumericValue(value);
|
|
14
|
+
return (React.createElement(Input, { value: currentValue.displayValue, onChange: (e) => onChange({
|
|
15
|
+
rawValue: parseFloat(e.target.value),
|
|
16
|
+
displayValue: e.target.value,
|
|
17
|
+
}), size: size, disabled: disabled }));
|
|
18
|
+
}
|
|
19
|
+
function getNumericValue(value) {
|
|
20
|
+
return value ? value : { rawValue: undefined, displayValue: "" };
|
|
21
|
+
}
|
|
22
|
+
/* v8 ignore stop */
|
|
23
|
+
//# sourceMappingURL=NumericEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumericEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/NumericEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK7C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACiC;IACzC,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO,CACL,oBAAC,KAAK,IACJ,KAAK,EAAE,YAAY,CAAC,YAAY,EAChC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACd,QAAQ,CAAC;YACP,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YACpC,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK;SAC7B,CAAC,EAEJ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAA+B;IACtD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AACnE,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 { Input } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { NumericValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Numeric value editor that renders `Input` components for changing value.\n * @internal\n */\nexport function NumericEditor({\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<ValueMetadata, NumericValue>) {\n const currentValue = getNumericValue(value);\n return (\n <Input\n value={currentValue.displayValue}\n onChange={(e) =>\n onChange({\n rawValue: parseFloat(e.target.value),\n displayValue: e.target.value,\n })\n }\n size={size}\n disabled={disabled}\n />\n );\n}\n\nfunction getNumericValue(value: NumericValue | undefined): NumericValue {\n return value ? value : { rawValue: undefined, displayValue: \"\" };\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorProps } from "../Types.js";
|
|
3
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
4
|
+
import type { TextValue } from "../values/Values.js";
|
|
5
|
+
/**
|
|
6
|
+
* Text value editor that renders `Input` component for changing value.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function TextEditor({ value, onChange, size, disabled, }: EditorProps<ValueMetadata, TextValue>): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=TextEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/TextEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAWvC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { Input } from "@itwin/itwinui-react";
|
|
7
|
+
/* v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* Text value editor that renders `Input` component for changing value.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function TextEditor({ value, onChange, size, disabled, }) {
|
|
13
|
+
const currentValue = value ? value : { value: "" };
|
|
14
|
+
return (React.createElement(Input, { value: currentValue.value, onChange: (e) => onChange({ value: e.target.value }), size: size, disabled: disabled }));
|
|
15
|
+
}
|
|
16
|
+
/* v8 ignore stop */
|
|
17
|
+
//# sourceMappingURL=TextEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK7C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GAC8B;IACtC,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAEnD,OAAO,CACL,oBAAC,KAAK,IACJ,KAAK,EAAE,YAAY,CAAC,KAAK,EACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EACpD,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,GAClB,CACH,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 { Input } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { TextValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Text value editor that renders `Input` component for changing value.\n * @internal\n */\nexport function TextEditor({\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<ValueMetadata, TextValue>) {\n const currentValue = value ? value : { value: \"\" };\n\n return (\n <Input\n value={currentValue.value}\n onChange={(e) => onChange({ value: e.target.value })}\n size={size}\n disabled={disabled}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ValueMetadata } from "../values/Metadata.js";
|
|
3
|
+
import type { BooleanValue } from "../values/Values.js";
|
|
4
|
+
import type { EditorProps } from "../Types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Boolean value editor that renders `ToggleSwitch` component for changing value.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function ToggleEditor({ value, onChange, commit, disabled, size, }: EditorProps<ValueMetadata, BooleanValue>): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=ToggleEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,GACL,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAgB1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { ToggleSwitch } from "@itwin/itwinui-react";
|
|
7
|
+
/* v8 ignore start */
|
|
8
|
+
/**
|
|
9
|
+
* Boolean value editor that renders `ToggleSwitch` component for changing value.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function ToggleEditor({ value, onChange, commit, disabled, size, }) {
|
|
13
|
+
const currentValue = value ?? { value: false };
|
|
14
|
+
const handleChange = (e) => {
|
|
15
|
+
const newValue = { value: e.target.checked };
|
|
16
|
+
onChange(newValue);
|
|
17
|
+
commit?.();
|
|
18
|
+
};
|
|
19
|
+
return (React.createElement(ToggleSwitch, { checked: currentValue.value, onChange: handleChange, disabled: disabled, size: size === "small" ? "small" : undefined }));
|
|
20
|
+
}
|
|
21
|
+
/* v8 ignore stop */
|
|
22
|
+
//# sourceMappingURL=ToggleEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,GACqC;IACzC,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC/C,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC7C,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,YAAY,IACX,OAAO,EAAE,YAAY,CAAC,KAAK,EAC3B,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAC5C,CACH,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 type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { BooleanValue } from \"../values/Values.js\";\nimport type { EditorProps } from \"../Types.js\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\n\n/* v8 ignore start */\n\n/**\n * Boolean value editor that renders `ToggleSwitch` component for changing value.\n * @internal\n */\nexport function ToggleEditor({\n value,\n onChange,\n commit,\n disabled,\n size,\n}: EditorProps<ValueMetadata, BooleanValue>) {\n const currentValue = value ?? { value: false };\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = { value: e.target.checked };\n onChange(newValue);\n commit?.();\n };\n\n return (\n <ToggleSwitch\n checked={currentValue.value}\n onChange={handleChange}\n disabled={disabled}\n size={size === \"small\" ? \"small\" : undefined}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type EditorSpec } from "../Types.js";
|
|
2
|
+
/** v8 ignore start */
|
|
3
|
+
/**
|
|
4
|
+
* Specification for default text editor. It applies for values whose type is "string".
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const TextEditorSpec: EditorSpec;
|
|
8
|
+
/**
|
|
9
|
+
* Specification for default date editor. It applies for values whose type is "date".
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const DateEditorSpec: EditorSpec;
|
|
13
|
+
/**
|
|
14
|
+
* Specification for default date time editor. It applies for values whose type is "dateTime".
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare const DateTimeEditorSpec: EditorSpec;
|
|
18
|
+
/**
|
|
19
|
+
* Specification for default boolean editor. It applies for values whose type is "bool".
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare const BoolEditorSpec: EditorSpec;
|
|
23
|
+
/**
|
|
24
|
+
* Specification for default numeric editor. It applies for values whose type is "number".
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare const NumericEditorSpec: EditorSpec;
|
|
28
|
+
/**
|
|
29
|
+
* Specification for default toggle editor. It applies for values whose type is "bool" when preferred editor set to `toggle`.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const EnumEditorSpec: EditorSpec;
|
|
33
|
+
/**
|
|
34
|
+
* Specification for default enum editor. It applies for values whose type is "enum".
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare const ToggleEditorSpec: EditorSpec;
|
|
38
|
+
/**
|
|
39
|
+
* List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare const defaultEditorSpecs: EditorSpec[];
|
|
43
|
+
/**
|
|
44
|
+
* List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support
|
|
45
|
+
* editing customizations used through `PropertyRecord`.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare const interopEditorSpecs: EditorSpec[];
|
|
49
|
+
/** v8 ignore stop */
|
|
50
|
+
//# sourceMappingURL=DefaultEditors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultEditors.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/DefaultEditors.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAYhE,sBAAsB;AAEtB;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAK/B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAK9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAM7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAW1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAS1C,CAAC;AAEF,qBAAqB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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 { StandardEditorNames } from "@itwin/appui-abstract";
|
|
6
|
+
import { BooleanEditor } from "../editors/BooleanEditor.js";
|
|
7
|
+
import { DateTimeEditor } from "../editors/DateTimeEditor.js";
|
|
8
|
+
import { EnumEditor } from "../editors/EnumEditor.js";
|
|
9
|
+
import { NumericEditor } from "../editors/NumericEditor.js";
|
|
10
|
+
import { TextEditor } from "../editors/TextEditor.js";
|
|
11
|
+
import { ColorEditorSpec as InteropColorEditorSpec } from "../interop/old-editors/Color.js";
|
|
12
|
+
import { CustomNumberEditorSpec as InteropCustomNumberEditorSpec } from "../interop/old-editors/CustomNumber.js";
|
|
13
|
+
import { EnumEditorSpec as InteropEnumEditorSpec } from "../interop/old-editors/Enum.js";
|
|
14
|
+
import { EnumButtonGroupEditorSpec as InteropEnumButtonGroupEditorSpec } from "../interop/old-editors/EnumButtonGroup.js";
|
|
15
|
+
import { MultilineEditorSpec as InteropMultilineEditorSpec } from "../interop/old-editors/TextArea.js";
|
|
16
|
+
import { SliderEditorSpec as InteropSliderEditorSpec } from "../interop/old-editors/Slider.js";
|
|
17
|
+
import { NumericInputEditorSpec as InteropNumericInputEditorSpec } from "../interop/old-editors/NumericInput.js";
|
|
18
|
+
import { createEditorSpec } from "../Types.js";
|
|
19
|
+
import { ToggleEditor } from "../editors/ToggleEditor.js";
|
|
20
|
+
import { DateEditor } from "../editors/DateEditor.js";
|
|
21
|
+
import { isBoolean, isDate, isEnum, isNumeric, isText, } from "../values/ValueUtilities.js";
|
|
22
|
+
/** v8 ignore start */
|
|
23
|
+
/**
|
|
24
|
+
* Specification for default text editor. It applies for values whose type is "string".
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export const TextEditorSpec = createEditorSpec({
|
|
28
|
+
isMetadataSupported: (metadata) => metadata.type === "string",
|
|
29
|
+
isValueSupported: isText,
|
|
30
|
+
Editor: TextEditor,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Specification for default date editor. It applies for values whose type is "date".
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export const DateEditorSpec = createEditorSpec({
|
|
37
|
+
isMetadataSupported: (metadata) => metadata.type === "date",
|
|
38
|
+
isValueSupported: isDate,
|
|
39
|
+
Editor: DateEditor,
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Specification for default date time editor. It applies for values whose type is "dateTime".
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export const DateTimeEditorSpec = createEditorSpec({
|
|
46
|
+
isMetadataSupported: (metadata) => metadata.type === "dateTime",
|
|
47
|
+
isValueSupported: isDate,
|
|
48
|
+
Editor: DateTimeEditor,
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Specification for default boolean editor. It applies for values whose type is "bool".
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const BoolEditorSpec = createEditorSpec({
|
|
55
|
+
isMetadataSupported: (metadata) => metadata.type === "bool",
|
|
56
|
+
isValueSupported: isBoolean,
|
|
57
|
+
Editor: BooleanEditor,
|
|
58
|
+
});
|
|
59
|
+
/**
|
|
60
|
+
* Specification for default numeric editor. It applies for values whose type is "number".
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
export const NumericEditorSpec = createEditorSpec({
|
|
64
|
+
isMetadataSupported: (metadata) => metadata.type === "number",
|
|
65
|
+
isValueSupported: isNumeric,
|
|
66
|
+
Editor: NumericEditor,
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Specification for default toggle editor. It applies for values whose type is "bool" when preferred editor set to `toggle`.
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export const EnumEditorSpec = createEditorSpec({
|
|
73
|
+
isMetadataSupported: (metadata) => metadata.type === "enum",
|
|
74
|
+
isValueSupported: isEnum,
|
|
75
|
+
Editor: EnumEditor,
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* Specification for default enum editor. It applies for values whose type is "enum".
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export const ToggleEditorSpec = createEditorSpec({
|
|
82
|
+
isMetadataSupported: (metadata) => metadata.type === "bool" &&
|
|
83
|
+
metadata.preferredEditor === StandardEditorNames.Toggle,
|
|
84
|
+
isValueSupported: isBoolean,
|
|
85
|
+
Editor: ToggleEditor,
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
export const defaultEditorSpecs = [
|
|
92
|
+
// list editors with preferred editor check first
|
|
93
|
+
ToggleEditorSpec,
|
|
94
|
+
// list editors that checks only value type
|
|
95
|
+
TextEditorSpec,
|
|
96
|
+
BoolEditorSpec,
|
|
97
|
+
NumericEditorSpec,
|
|
98
|
+
DateEditorSpec,
|
|
99
|
+
DateTimeEditorSpec,
|
|
100
|
+
EnumEditorSpec,
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support
|
|
104
|
+
* editing customizations used through `PropertyRecord`.
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
export const interopEditorSpecs = [
|
|
108
|
+
InteropSliderEditorSpec,
|
|
109
|
+
InteropEnumButtonGroupEditorSpec,
|
|
110
|
+
InteropNumericInputEditorSpec,
|
|
111
|
+
InteropCustomNumberEditorSpec,
|
|
112
|
+
InteropColorEditorSpec,
|
|
113
|
+
InteropMultilineEditorSpec,
|
|
114
|
+
InteropEnumEditorSpec,
|
|
115
|
+
];
|
|
116
|
+
/** v8 ignore stop */
|
|
117
|
+
//# sourceMappingURL=DefaultEditors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultEditors.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/DefaultEditors.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACjH,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,yBAAyB,IAAI,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC1H,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACvG,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEjH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC,sBAAsB;AAEtB;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,QAAQ;IAC5B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe,gBAAgB,CAAC;IAC7D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,UAAU;IAC9B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAe,gBAAgB,CAAC;IAC5D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,QAAQ;IAC5B,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAe,gBAAgB,CAAC;IAC3D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;QACxB,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,MAAM;IACzD,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,YAAY;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,iDAAiD;IACjD,gBAAgB;IAEhB,2CAA2C;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 { EnumValueMetadata, ValueMetadata } 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 ValueMetadata =>\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 ValueMetadata =>\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { EditorSpec } from "../Types.js";
|
|
3
|
+
interface EditorsRegistry {
|
|
4
|
+
editors: EditorSpec[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Context for storing registered editors.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const EditorsRegistryContext: React.Context<EditorsRegistry>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=EditorsRegistryContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorsRegistryContext.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryContext.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,UAAU,eAAe;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAEjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Context for storing registered editors.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const EditorsRegistryContext = React.createContext({
|
|
11
|
+
editors: [],
|
|
12
|
+
});
|
|
13
|
+
EditorsRegistryContext.displayName = "uifw:EditorsRegistryContext";
|
|
14
|
+
//# sourceMappingURL=EditorsRegistryContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorsRegistryContext.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,aAAa,CAAkB;IACzE,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC;AACH,sBAAsB,CAAC,WAAW,GAAG,6BAA6B,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\nimport * as React from \"react\";\nimport type { EditorSpec } from \"../Types.js\";\n\ninterface EditorsRegistry {\n editors: EditorSpec[];\n}\n\n/**\n * Context for storing registered editors.\n * @internal\n */\nexport const EditorsRegistryContext = React.createContext<EditorsRegistry>({\n editors: [],\n});\nEditorsRegistryContext.displayName = \"uifw:EditorsRegistryContext\";\n"]}
|