@itwin/components-react 5.0.0-dev.2 → 5.0.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 +55 -1
- package/lib/cjs/components-react/_target.scss +10 -0
- package/lib/cjs/components-react/datepicker/DateField.scss +19 -0
- package/lib/cjs/components-react/datepicker/DatePicker.scss +179 -0
- package/lib/cjs/components-react/datepicker/DatePickerPopupButton.scss +56 -0
- package/lib/cjs/components-react/datepicker/TimeField.scss +72 -0
- package/lib/cjs/components-react/editors/BooleanEditor.scss +22 -0
- package/lib/cjs/components-react/editors/CustomNumberEditor.scss +19 -0
- package/lib/cjs/components-react/editors/DateTimeEditor.scss +9 -0
- package/lib/cjs/components-react/editors/EditorContainer.scss +7 -0
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.scss +141 -0
- package/lib/cjs/components-react/editors/EnumEditor.scss +21 -0
- package/lib/cjs/components-react/editors/IconEditor.scss +14 -0
- package/lib/cjs/components-react/editors/ImageCheckBoxEditor.scss +24 -0
- package/lib/cjs/components-react/editors/NumericInputEditor.scss +13 -0
- package/lib/cjs/components-react/editors/PopupButton.scss +112 -0
- package/lib/cjs/components-react/editors/SliderEditor.scss +14 -0
- package/lib/cjs/components-react/editors/TextEditor.scss +19 -0
- package/lib/cjs/components-react/editors/TextareaEditor.scss +13 -0
- package/lib/cjs/components-react/editors/ToggleEditor.scss +17 -0
- package/lib/cjs/components-react/editors/variables.scss +10 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.scss +40 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.scss +35 -0
- package/lib/cjs/components-react/filtering/FilteringInput.scss +58 -0
- package/lib/cjs/components-react/filtering/ResultSelector.scss +66 -0
- package/lib/cjs/components-react/iconpicker/IconPickerButton.scss +74 -0
- package/lib/cjs/components-react/inputs/ParsedInput.scss +20 -0
- package/lib/cjs/components-react/properties/renderers/ActionButtonList.scss +25 -0
- package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.scss +17 -0
- package/lib/cjs/components-react/properties/renderers/PropertyView.scss +110 -0
- package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.scss +87 -0
- package/lib/cjs/components-react/propertygrid/component/PropertyGrid.scss +55 -0
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +100 -0
- package/lib/cjs/components-react/selectable-content/SelectableContent.scss +20 -0
- package/lib/cjs/components-react/toolbar/Item.scss +94 -0
- package/lib/cjs/components-react/toolbar/ItemWrapper.scss +10 -0
- package/lib/cjs/components-react/toolbar/Items.scss +96 -0
- package/lib/cjs/components-react/toolbar/Overflow.scss +57 -0
- package/lib/cjs/components-react/toolbar/OverflowPanel.scss +37 -0
- package/lib/cjs/components-react/toolbar/PopupItem.scss +81 -0
- package/lib/cjs/components-react/toolbar/Toolbar.scss +16 -0
- package/lib/cjs/components-react/toolbar/_variables.scss +34 -0
- package/lib/cjs/components-react/toolbar/groupPanel/BackArrow.scss +44 -0
- package/lib/cjs/components-react/toolbar/groupPanel/Column.scss +9 -0
- package/lib/cjs/components-react/toolbar/groupPanel/Columns.scss +10 -0
- package/lib/cjs/components-react/toolbar/groupPanel/Panel.scss +15 -0
- package/lib/cjs/components-react/toolbar/groupPanel/Title.scss +33 -0
- package/lib/cjs/components-react/toolbar/groupPanel/_variables.scss +17 -0
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Expander.scss +30 -0
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.scss +117 -0
- package/lib/cjs/components-react/toolbar/groupPanel/tool/_variables.scss +15 -0
- package/lib/cjs/components-react/tree/HighlightingEngine.scss +8 -0
- package/lib/cjs/components-react/tree/controlled/component/ControlledTree.scss +102 -0
- package/lib/cjs/components-react/tree/controlled/component/NodeContent.scss +27 -0
- package/lib/components-react/common/Links.d.ts +4 -0
- package/lib/components-react/common/Links.d.ts.map +1 -1
- package/lib/components-react/common/Links.js +20 -0
- package/lib/components-react/common/Links.js.map +1 -1
- package/lib/components-react/editors/EditorContainer.d.ts +2 -0
- package/lib/components-react/editors/EditorContainer.d.ts.map +1 -1
- package/lib/components-react/editors/EditorContainer.js +7 -3
- package/lib/components-react/editors/EditorContainer.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js +3 -3
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/properties/renderers/PropertyRenderer.d.ts +4 -0
- package/lib/components-react/properties/renderers/PropertyRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/PropertyRenderer.js +12 -3
- package/lib/components-react/properties/renderers/PropertyRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.js +2 -10
- package/lib/components-react/properties/renderers/value/UrlPropertyValueRenderer.js.map +1 -1
- package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +5 -3
- package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts +2 -0
- package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js +4 -9
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +2 -0
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +3 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +3 -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 +9 -5
- package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/_target.scss +10 -0
- package/lib/esm/components-react/datepicker/DateField.scss +19 -0
- package/lib/esm/components-react/datepicker/DatePicker.scss +179 -0
- package/lib/esm/components-react/datepicker/DatePickerPopupButton.scss +56 -0
- package/lib/esm/components-react/datepicker/TimeField.scss +72 -0
- package/lib/esm/components-react/editors/BooleanEditor.scss +22 -0
- package/lib/esm/components-react/editors/CustomNumberEditor.scss +19 -0
- package/lib/esm/components-react/editors/DateTimeEditor.scss +9 -0
- package/lib/esm/components-react/editors/EditorContainer.scss +7 -0
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.scss +141 -0
- package/lib/esm/components-react/editors/EnumEditor.scss +21 -0
- package/lib/esm/components-react/editors/IconEditor.scss +14 -0
- package/lib/esm/components-react/editors/ImageCheckBoxEditor.scss +24 -0
- package/lib/esm/components-react/editors/NumericInputEditor.scss +13 -0
- package/lib/esm/components-react/editors/PopupButton.scss +112 -0
- package/lib/esm/components-react/editors/SliderEditor.scss +14 -0
- package/lib/esm/components-react/editors/TextEditor.scss +19 -0
- package/lib/esm/components-react/editors/TextareaEditor.scss +13 -0
- package/lib/esm/components-react/editors/ToggleEditor.scss +17 -0
- package/lib/esm/components-react/editors/variables.scss +10 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.scss +40 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.scss +35 -0
- package/lib/esm/components-react/filtering/FilteringInput.scss +58 -0
- package/lib/esm/components-react/filtering/ResultSelector.scss +66 -0
- package/lib/esm/components-react/iconpicker/IconPickerButton.scss +74 -0
- package/lib/esm/components-react/inputs/ParsedInput.scss +20 -0
- package/lib/esm/components-react/properties/renderers/ActionButtonList.scss +25 -0
- package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.scss +17 -0
- package/lib/esm/components-react/properties/renderers/PropertyView.scss +110 -0
- package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.scss +87 -0
- package/lib/esm/components-react/propertygrid/component/PropertyGrid.scss +55 -0
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +100 -0
- package/lib/esm/components-react/selectable-content/SelectableContent.scss +20 -0
- package/lib/esm/components-react/toolbar/Item.scss +94 -0
- package/lib/esm/components-react/toolbar/ItemWrapper.scss +10 -0
- package/lib/esm/components-react/toolbar/Items.scss +96 -0
- package/lib/esm/components-react/toolbar/Overflow.scss +57 -0
- package/lib/esm/components-react/toolbar/OverflowPanel.scss +37 -0
- package/lib/esm/components-react/toolbar/PopupItem.scss +81 -0
- package/lib/esm/components-react/toolbar/Toolbar.scss +16 -0
- package/lib/esm/components-react/toolbar/_variables.scss +34 -0
- package/lib/esm/components-react/toolbar/groupPanel/BackArrow.scss +44 -0
- package/lib/esm/components-react/toolbar/groupPanel/Column.scss +9 -0
- package/lib/esm/components-react/toolbar/groupPanel/Columns.scss +10 -0
- package/lib/esm/components-react/toolbar/groupPanel/Panel.scss +15 -0
- package/lib/esm/components-react/toolbar/groupPanel/Title.scss +33 -0
- package/lib/esm/components-react/toolbar/groupPanel/_variables.scss +17 -0
- package/lib/esm/components-react/toolbar/groupPanel/tool/Expander.scss +30 -0
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.scss +117 -0
- package/lib/esm/components-react/toolbar/groupPanel/tool/_variables.scss +15 -0
- package/lib/esm/components-react/tree/HighlightingEngine.scss +8 -0
- package/lib/esm/components-react/tree/controlled/component/ControlledTree.scss +102 -0
- package/lib/esm/components-react/tree/controlled/component/NodeContent.scss +27 -0
- package/package.json +9 -16
|
@@ -11,7 +11,7 @@ import * as React from "react";
|
|
|
11
11
|
import { PropertyEditorParamTypes, PropertyValueFormat, } from "@itwin/appui-abstract";
|
|
12
12
|
import { Icon } from "@itwin/core-react";
|
|
13
13
|
import { PropertyEditorBase } from "./PropertyEditorManager.js";
|
|
14
|
-
import
|
|
14
|
+
import { SvgPlaceholder } from "@itwin/itwinui-icons-react";
|
|
15
15
|
/** EnumButtonGroupEditor React component that is a property editor with select input
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
@@ -95,7 +95,7 @@ export class EnumButtonGroupEditor extends React.Component {
|
|
|
95
95
|
}
|
|
96
96
|
const numChoices = choices.length;
|
|
97
97
|
const enumIcons = new Array(numChoices);
|
|
98
|
-
enumIcons.fill({ iconSpec:
|
|
98
|
+
enumIcons.fill({ iconSpec: "" });
|
|
99
99
|
if (propertyRecord.property.editor &&
|
|
100
100
|
propertyRecord.property.editor.params) {
|
|
101
101
|
if (propertyRecord.property.editor &&
|
|
@@ -125,7 +125,7 @@ export class EnumButtonGroupEditor extends React.Component {
|
|
|
125
125
|
}
|
|
126
126
|
const className = classnames("components-enumbuttongroup-button", isDisabled && "nz-is-disabled", isActive && "nz-is-active");
|
|
127
127
|
return (React.createElement("button", { ref: (ref) => ref && this._btnRefs.set(choiceValue, ref), "data-testid": choice.label, className: className, title: choice.label, key: choice.label, onClick: () => this._handleButtonClick(index) },
|
|
128
|
-
React.createElement(Icon, { iconSpec: this.state.enumIcons[index].iconSpec })));
|
|
128
|
+
React.createElement(Icon, { iconSpec: this.state.enumIcons[index].iconSpec === "" ? (React.createElement(SvgPlaceholder, null)) : (this.state.enumIcons[index].iconSpec) })));
|
|
129
129
|
}
|
|
130
130
|
render() {
|
|
131
131
|
return (React.createElement("div", { className: classnames("components-enumbuttongroup-editor", this.props.className), style: this.props.style, ref: this._divElement }, this.state.choices &&
|
|
@@ -1 +1 @@
|
|
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EAAE,CAAC,GAA6B,EAAE,EAAE,CACrC,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,iBAE/B,MAAM,CAAC,KAAK,EACzB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,GAAG,EAAE,MAAM,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;YAG7C,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAI,CACjD,CACV,CAAC;IACJ,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CACnB,mCAAmC,EACnC,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,GAAG,EAAE,IAAI,CAAC,WAAW,IAEpB,IAAI,CAAC,KAAK,CAAC,OAAO;YACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAClE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAC9B,CACC,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,kBAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF","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 \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ButtonGroupEditorParams,\n EnumerationChoice,\n IconDefinition,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport svgPlaceholder from \"@bentley/icons-generic/icons/placeholder.svg\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumButtonGroupEditor\n extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState>\n implements TypeEditor\n{\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n public override componentDidMount() {\n void this.setStateFromProps();\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n if (\n propertyRecord &&\n propertyRecord.property.enum &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: svgPlaceholder });\n\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const bgParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ButtonGroupData.valueOf()\n ) as ButtonGroupEditorParams;\n if (bgParams) {\n bgParams.buttons.forEach(\n (iconDef: IconDefinition, index: number) => {\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n }\n );\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices\n ? this.state.choices[index].value\n : 0;\n const isActive = choiceValue === this.state.selectValue ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\"\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement | null) =>\n ref && this._btnRefs.set(choiceValue, ref)\n }\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n {/* eslint-disable-next-line deprecation/deprecation */}\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\n </button>\n );\n }\n\n public override render() {\n return (\n <div\n className={classnames(\n \"components-enumbuttongroup-editor\",\n this.props.className\n )}\n style={this.props.style}\n ref={this._divElement}\n >\n {this.state.choices &&\n this.state.enumIcons.length &&\n this.state.choices.map((choice: EnumerationChoice, index: number) =>\n this.getButton(choice, index)\n )}\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @public\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAW5D;;GAEG;AACH,MAAM,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AAC,CAAC,CACF,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CACrC,GAEH,CACK,CACV,CAAC;IACJ,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CACnB,mCAAmC,EACnC,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,GAAG,EAAE,IAAI,CAAC,WAAW,IAEpB,IAAI,CAAC,KAAK,CAAC,OAAO;YACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAClE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAC9B,CACC,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,kBAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF","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 \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ButtonGroupEditorParams,\n EnumerationChoice,\n IconDefinition,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { SvgPlaceholder } from \"@itwin/itwinui-icons-react\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumButtonGroupEditor\n extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState>\n implements TypeEditor\n{\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n public override componentDidMount() {\n void this.setStateFromProps();\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n if (\n propertyRecord &&\n propertyRecord.property.enum &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: \"\" });\n\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const bgParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ButtonGroupData.valueOf()\n ) as ButtonGroupEditorParams;\n if (bgParams) {\n bgParams.buttons.forEach(\n (iconDef: IconDefinition, index: number) => {\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n }\n );\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices\n ? this.state.choices[index].value\n : 0;\n const isActive = choiceValue === this.state.selectValue ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\"\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement | null) =>\n ref && this._btnRefs.set(choiceValue, ref)\n }\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n {/* eslint-disable-next-line deprecation/deprecation */}\n <Icon\n iconSpec={\n this.state.enumIcons[index].iconSpec === \"\" ? (\n <SvgPlaceholder />\n ) : (\n this.state.enumIcons[index].iconSpec\n )\n }\n />\n </button>\n );\n }\n\n public override render() {\n return (\n <div\n className={classnames(\n \"components-enumbuttongroup-editor\",\n this.props.className\n )}\n style={this.props.style}\n ref={this._divElement}\n >\n {this.state.choices &&\n this.state.enumIcons.length &&\n this.state.choices.map((choice: EnumerationChoice, index: number) =>\n this.getButton(choice, index)\n )}\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @public\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n"]}
|
|
@@ -43,6 +43,8 @@ export interface SharedRendererProps {
|
|
|
43
43
|
actionButtonRenderers?: ActionButtonRenderer[];
|
|
44
44
|
/** Is resize handle hovered */
|
|
45
45
|
isResizeHandleHovered?: boolean;
|
|
46
|
+
/** Enables/disables property editing */
|
|
47
|
+
isPropertyEditingEnabled?: boolean;
|
|
46
48
|
/** Callback to hover event change */
|
|
47
49
|
onResizeHandleHoverChanged?: (isHovered: boolean) => void;
|
|
48
50
|
/** Is resize handle being dragged */
|
|
@@ -51,6 +53,8 @@ export interface SharedRendererProps {
|
|
|
51
53
|
onResizeHandleDragChanged?: (isDragStarted: boolean) => void;
|
|
52
54
|
/** Information for styling property grid columns */
|
|
53
55
|
columnInfo?: PropertyGridColumnInfo;
|
|
56
|
+
/** Callback to determine which editors should be always visible */
|
|
57
|
+
alwaysShowEditor?: (property: PropertyRecord) => boolean;
|
|
54
58
|
}
|
|
55
59
|
/** Properties of [[PropertyRenderer]] React component
|
|
56
60
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH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,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC/C,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,oCAAoC;IACpC,yBAAyB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,oDAAoD;IACpD,UAAU,CAAC,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,qHAAqH;IACrH,SAAS,CAAC,EAAE,MAAM,CAAC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E,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,4BAA4B;IAC5B,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnD,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,mCAAmC;IACnC,SAAS,CAAC,EAAE,0BAA0B,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;YAAW,qBAAqB;iCAwG7C,MAAM,gBACN,WAAW,UACjB,MAAM,gBACA,MAAM,wBACE,MAAM;CAP7B,CAAC"}
|
|
@@ -18,7 +18,7 @@ import { useTranslation } from "../../l10n/useTranslation.js";
|
|
|
18
18
|
export const PropertyRenderer = (props) => {
|
|
19
19
|
const { translate } = useTranslation();
|
|
20
20
|
const [displayValue, setDisplayValue] = React.useState(() => translate("general.loading"));
|
|
21
|
-
const { isEditing, orientation, propertyRecord, indentation, propertyValueRendererManager, onEditCommit, onEditCancel, ...restProps } = props;
|
|
21
|
+
const { isEditing, orientation, propertyRecord, indentation, propertyValueRendererManager, onEditCommit, onEditCancel, alwaysShowEditor, isPropertyEditingEnabled, onClick, uniqueKey, ...restProps } = props;
|
|
22
22
|
const onCommit = React.useCallback((args) => {
|
|
23
23
|
if (onEditCommit)
|
|
24
24
|
onEditCommit(args);
|
|
@@ -27,9 +27,12 @@ export const PropertyRenderer = (props) => {
|
|
|
27
27
|
if (onEditCancel)
|
|
28
28
|
onEditCancel();
|
|
29
29
|
}, [onEditCancel]);
|
|
30
|
+
const alwaysShowsEditor = props.alwaysShowEditor
|
|
31
|
+
? props.alwaysShowEditor(props.propertyRecord)
|
|
32
|
+
: false;
|
|
30
33
|
React.useEffect(() => {
|
|
31
|
-
if (isEditing) {
|
|
32
|
-
setDisplayValue(React.createElement(EditorContainer, { propertyRecord: propertyRecord, onCommit: onCommit, onCancel: onCancel, setFocus:
|
|
34
|
+
if (isEditing || (alwaysShowsEditor && isPropertyEditingEnabled)) {
|
|
35
|
+
setDisplayValue(React.createElement(EditorContainer, { propertyRecord: propertyRecord, onCommit: onCommit, onCancel: onCancel, setFocus: isEditing, onClick: () => onClick?.(propertyRecord, uniqueKey) }));
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
38
|
setDisplayValue(CommonPropertyRenderer.createNewDisplayValue(orientation, propertyRecord, indentation, propertyValueRendererManager));
|
|
@@ -41,9 +44,15 @@ export const PropertyRenderer = (props) => {
|
|
|
41
44
|
onCommit,
|
|
42
45
|
onCancel,
|
|
43
46
|
isEditing,
|
|
47
|
+
alwaysShowsEditor,
|
|
48
|
+
isPropertyEditingEnabled,
|
|
49
|
+
onClick,
|
|
50
|
+
uniqueKey,
|
|
44
51
|
]);
|
|
45
52
|
const primitiveRendererProps = {
|
|
46
53
|
...restProps,
|
|
54
|
+
onClick,
|
|
55
|
+
uniqueKey,
|
|
47
56
|
propertyRecord,
|
|
48
57
|
orientation,
|
|
49
58
|
indentation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,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QACX,cAAc;QACd,WAAW;QACX,4BAA4B;QAC5B,QAAQ;QACR,QAAQ;QACR,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAA2B;QACrD,GAAG,SAAS;QACZ,cAAc;QACd,WAAW;QACX,WAAW;QACX,YAAY,EAAE,YAAY;KAC3B,CAAC;IAEF,QAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC/C,KAAK,mBAAmB,CAAC,SAAS;YAChC,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;QACnE,KAAK,mBAAmB,CAAC,KAAK;YAC5B,uDAAuD;YACvD,IACE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,KAAK;gBACpE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;gBAE7C,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;QACrE,0CAA0C;QAC1C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAEF,gBAAgB,CAAC,cAAc,GAAG,CAChC,WAAoB,EACpB,WAAyB,EACzB,KAAc,EACd,WAAoB,EACpB,mBAA4B,EAC5B,EAAE;IACF,OAAO,sBAAsB,CAAC,cAAc,CAC1C,WAAW,EACX,WAAW,EACX,KAAK,EACL,WAAW,EACX,mBAAmB,CACpB,CAAC;AACJ,CAAC,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport { EditorContainer } from \"../../editors/EditorContainer.js\";\nimport type { PropertyValueRendererManager } from \"../ValueRendererManager.js\";\nimport type { ActionButtonRenderer } from \"./ActionButtonRenderer.js\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer.js\";\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer.js\";\nimport type { PrimitiveRendererProps } from \"./PrimitivePropertyRenderer.js\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer.js\";\nimport type { PropertyGridColumnInfo } from \"./PropertyGridColumns.js\";\nimport type { Orientation } from \"../../common/Orientation.js\";\nimport { useTranslation } from \"../../l10n/useTranslation.js\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | {\n ratio: number;\n };\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n /** Information for styling property grid columns */\n columnInfo?: PropertyGridColumnInfo;\n}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited */\n isEditing?: boolean;\n /** Called when property edit is committed. */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. */\n onEditCancel?: () => void;\n /** Props used for highlighting. */\n highlight?: HighlightingComponentProps;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport const PropertyRenderer = (props: PropertyRendererProps) => {\n const { translate } = useTranslation();\n const [displayValue, setDisplayValue] = React.useState<React.ReactNode>(() =>\n translate(\"general.loading\")\n );\n\n const {\n isEditing,\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager,\n onEditCommit,\n onEditCancel,\n ...restProps\n } = props;\n\n const onCommit = React.useCallback(\n (args: PropertyUpdatedArgs) => {\n if (onEditCommit) onEditCommit(args);\n },\n [onEditCommit]\n );\n\n const onCancel = React.useCallback(() => {\n if (onEditCancel) onEditCancel();\n }, [onEditCancel]);\n\n React.useEffect(() => {\n if (isEditing) {\n setDisplayValue(\n <EditorContainer\n propertyRecord={propertyRecord}\n onCommit={onCommit}\n onCancel={onCancel}\n setFocus={true}\n />\n );\n return;\n }\n\n setDisplayValue(\n CommonPropertyRenderer.createNewDisplayValue(\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager\n )\n );\n }, [\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager,\n onCommit,\n onCancel,\n isEditing,\n ]);\n\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...restProps,\n propertyRecord,\n orientation,\n indentation,\n valueElement: displayValue,\n };\n\n switch (props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (\n props.propertyRecord.value.valueFormat === PropertyValueFormat.Array &&\n props.propertyRecord.value.items.length === 0\n )\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n // eslint-disable-next-line no-fallthrough\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n};\n\nPropertyRenderer.getLabelOffset = (\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number\n) => {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAoE9D;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAE,EAAE;IAC/D,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,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,EAAE;QACD,WAAW;QACX,cAAc;QACd,WAAW;QACX,4BAA4B;QAC5B,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,iBAAiB;QACjB,wBAAwB;QACxB,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAA2B;QACrD,GAAG,SAAS;QACZ,OAAO;QACP,SAAS;QACT,cAAc;QACd,WAAW;QACX,WAAW;QACX,YAAY,EAAE,YAAY;KAC3B,CAAC;IAEF,QAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC/C,KAAK,mBAAmB,CAAC,SAAS;YAChC,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;QACnE,KAAK,mBAAmB,CAAC,KAAK;YAC5B,uDAAuD;YACvD,IACE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,KAAK;gBACpE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;gBAE7C,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;QACrE,0CAA0C;QAC1C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAEF,gBAAgB,CAAC,cAAc,GAAG,CAChC,WAAoB,EACpB,WAAyB,EACzB,KAAc,EACd,WAAoB,EACpB,mBAA4B,EAC5B,EAAE;IACF,OAAO,sBAAsB,CAAC,cAAc,CAC1C,WAAW,EACX,WAAW,EACX,KAAK,EACL,WAAW,EACX,mBAAmB,CACpB,CAAC;AACJ,CAAC,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport { EditorContainer } from \"../../editors/EditorContainer.js\";\nimport type { PropertyValueRendererManager } from \"../ValueRendererManager.js\";\nimport type { ActionButtonRenderer } from \"./ActionButtonRenderer.js\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer.js\";\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer.js\";\nimport type { PrimitiveRendererProps } from \"./PrimitivePropertyRenderer.js\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer.js\";\nimport type { PropertyGridColumnInfo } from \"./PropertyGridColumns.js\";\nimport type { Orientation } from \"../../common/Orientation.js\";\nimport { useTranslation } from \"../../l10n/useTranslation.js\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | {\n ratio: number;\n };\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n /** Information for styling property grid columns */\n columnInfo?: PropertyGridColumnInfo;\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited */\n isEditing?: boolean;\n /** Called when property edit is committed. */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. */\n onEditCancel?: () => void;\n /** Props used for highlighting. */\n highlight?: HighlightingComponentProps;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport const PropertyRenderer = (props: PropertyRendererProps) => {\n const { translate } = useTranslation();\n const [displayValue, setDisplayValue] = React.useState<React.ReactNode>(() =>\n translate(\"general.loading\")\n );\n\n const {\n isEditing,\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager,\n onEditCommit,\n onEditCancel,\n alwaysShowEditor,\n isPropertyEditingEnabled,\n onClick,\n uniqueKey,\n ...restProps\n } = props;\n\n const onCommit = React.useCallback(\n (args: PropertyUpdatedArgs) => {\n if (onEditCommit) onEditCommit(args);\n },\n [onEditCommit]\n );\n\n const onCancel = React.useCallback(() => {\n if (onEditCancel) onEditCancel();\n }, [onEditCancel]);\n\n const alwaysShowsEditor = props.alwaysShowEditor\n ? props.alwaysShowEditor(props.propertyRecord)\n : false;\n\n React.useEffect(() => {\n if (isEditing || (alwaysShowsEditor && isPropertyEditingEnabled)) {\n setDisplayValue(\n <EditorContainer\n propertyRecord={propertyRecord}\n onCommit={onCommit}\n onCancel={onCancel}\n setFocus={isEditing}\n onClick={() => onClick?.(propertyRecord, uniqueKey)}\n />\n );\n return;\n }\n\n setDisplayValue(\n CommonPropertyRenderer.createNewDisplayValue(\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager\n )\n );\n }, [\n orientation,\n propertyRecord,\n indentation,\n propertyValueRendererManager,\n onCommit,\n onCancel,\n isEditing,\n alwaysShowsEditor,\n isPropertyEditingEnabled,\n onClick,\n uniqueKey,\n ]);\n\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...restProps,\n onClick,\n uniqueKey,\n propertyRecord,\n orientation,\n indentation,\n valueElement: displayValue,\n };\n\n switch (props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (\n props.propertyRecord.value.valueFormat === PropertyValueFormat.Array &&\n props.propertyRecord.value.items.length === 0\n )\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n // eslint-disable-next-line no-fallthrough\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n};\n\nPropertyRenderer.getLabelOffset = (\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number\n) => {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlPropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"UrlPropertyValueRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAKvC;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IACrE,uDAAuD;IAChD,SAAS,CAAC,MAAM,EAAE,cAAc;IAWvC,iEAAiE;IAC1D,MAAM,CACX,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,4BAA4B;CAWzC"}
|
|
@@ -9,6 +9,7 @@ import * as React from "react";
|
|
|
9
9
|
import { PropertyValueFormat, StandardTypeNames } from "@itwin/appui-abstract";
|
|
10
10
|
import { PrimitivePropertyValueRendererImpl } from "./PrimitivePropertyValueRenderer.js";
|
|
11
11
|
import { convertRecordToString } from "./Common.js";
|
|
12
|
+
import { openLink } from "../../../common/Links.js";
|
|
12
13
|
/**
|
|
13
14
|
* URL property value renderer that renders the whole value as a URL without matching it
|
|
14
15
|
* against URL regex.
|
|
@@ -30,16 +31,7 @@ export class UrlPropertyValueRenderer {
|
|
|
30
31
|
return (React.createElement(PrimitivePropertyValueRendererImpl, { record: record, context: context, stringValueCalculator: convertRecordToString, linksHandler: URI_PROPERTY_LINK_HANDLER }));
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
function handleClick(text) {
|
|
34
|
-
if (text.startsWith("mailto:")) {
|
|
35
|
-
location.href = text;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
const windowOpen = window.open(text, "_blank");
|
|
39
|
-
windowOpen?.focus();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
34
|
const URI_PROPERTY_LINK_HANDLER = {
|
|
43
|
-
onClick:
|
|
35
|
+
onClick: openLink,
|
|
44
36
|
};
|
|
45
37
|
//# sourceMappingURL=UrlPropertyValueRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IACnC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D;gBACE,iBAAiB,CAAC,GAAG;gBACrB,iBAAiB,CAAC,MAAM;gBACxB,iBAAiB,CAAC,IAAI;aACvB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAA6B,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,EAC5C,YAAY,EAAE,yBAAyB,GACvC,CACH,CAAC;IACJ,CAAC;CACF;AAED,
|
|
1
|
+
{"version":3,"file":"UrlPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/value/UrlPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,wBAAwB;IACnC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D;gBACE,iBAAiB,CAAC,GAAG;gBACrB,iBAAiB,CAAC,MAAM;gBACxB,iBAAiB,CAAC,IAAI;aACvB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,QAA6B,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,EAC5C,YAAY,EAAE,yBAAyB,GACvC,CACH,CAAC;IACJ,CAAC;CACF;AAED,MAAM,yBAAyB,GAAqB;IAClD,OAAO,EAAE,QAAQ;CAClB,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { LinkElementsInfo, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager.js\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer.js\";\nimport { convertRecordToString } from \"./Common.js\";\nimport { openLink } from \"../../../common/Links.js\";\n\n/**\n * URL property value renderer that renders the whole value as a URL without matching it\n * against URL regex.\n *\n * @public\n */\nexport class UrlPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n [\n StandardTypeNames.URL,\n StandardTypeNames.String,\n StandardTypeNames.Text,\n ].includes(record.property.typename as StandardTypeNames)\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n linksHandler={URI_PROPERTY_LINK_HANDLER}\n />\n );\n }\n}\n\nconst URI_PROPERTY_LINK_HANDLER: LinkElementsInfo = {\n onClick: openLink,\n};\n"]}
|
package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnResizingPropertyListPropsSupplier.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColumnResizingPropertyListPropsSupplier.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,WAAW,E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,qBAAqB,CAM3B;IAEF,OAAO,CAAC,2BAA2B,CAEjC;IAEF,OAAO,CAAC,0BAA0B,CAEhC;IAEF,OAAO,CAAC,0BAA0B;IA6ClC,OAAO,CAAC,mBAAmB;IAIX,MAAM;CAmBvB"}
|
package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import { Geometry } from "@itwin/core-geometry";
|
|
7
6
|
import { Orientation } from "../../common/Orientation.js";
|
|
8
7
|
const BORDER_WIDTH = 10;
|
|
9
8
|
const PROPERTY_PADDING = 16;
|
|
@@ -26,7 +25,7 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component {
|
|
|
26
25
|
isResizeHandleBeingDragged: false,
|
|
27
26
|
};
|
|
28
27
|
this._onColumnRatioChanged = (ratio) => {
|
|
29
|
-
ratio =
|
|
28
|
+
ratio = clamp(ratio, this._minRatio, this._maxRatio);
|
|
30
29
|
if (this.state.columnRatio === ratio)
|
|
31
30
|
return { ratio };
|
|
32
31
|
this.setState({ columnRatio: ratio });
|
|
@@ -81,7 +80,7 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component {
|
|
|
81
80
|
return true;
|
|
82
81
|
}
|
|
83
82
|
getValidColumnRatio() {
|
|
84
|
-
return
|
|
83
|
+
return clamp(this.state.columnRatio, this._minRatio, this._maxRatio);
|
|
85
84
|
}
|
|
86
85
|
render() {
|
|
87
86
|
const listProps = {
|
|
@@ -107,4 +106,7 @@ ColumnResizingPropertyListPropsSupplier.defaultProps = {
|
|
|
107
106
|
minLabelWidth: 100,
|
|
108
107
|
minValueWidth: 100,
|
|
109
108
|
};
|
|
109
|
+
function clamp(value, min, max) {
|
|
110
|
+
return Math.max(min, Math.min(max, value));
|
|
111
|
+
}
|
|
110
112
|
//# sourceMappingURL=ColumnResizingPropertyListPropsSupplier.js.map
|
package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnResizingPropertyListPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ColumnResizingPropertyListPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AA2C3B;;;GAGG;AACH,MAAM,OAAO,uCAAwC,SAAQ,KAAK,CAAC,SAGlE;IAHD;;QAImB,kBAAa,GAAG,IAAI,CAAC;QACrB,qBAAgB,GAAG,IAAI,CAAC;QACxB,qBAAgB,GAAG,GAAG,CAAC;QAChC,cAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAClC,cAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE1B,UAAK,GAAiD;YACpE,WAAW,EAAE,IAAI,CAAC,aAAa;YAC/B,qBAAqB,EAAE,KAAK;YAC5B,0BAA0B,EAAE,KAAK;SAClC,CAAC;QAQM,0BAAqB,GAAG,CAAC,KAAa,EAAE,EAAE;YAChD,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACrD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,KA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Ac;gBACxC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAc;gBACxC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAkB;gBAChD,0BAA0B,EAAE,IAAI,CAAC,0BAA0B,EAAE;aAC9D;SACF,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;;AAzFa,oDAAY,GACxB;IACE,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,GAAG;CACnB,AAJuB,CAItB;AAwFN,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\nconst BORDER_WIDTH = 10;\nconst PROPERTY_PADDING = 16;\nconst VALUE_MIN_WIDTH = 10;\n\n/** @internal */\nexport type ColumnResizeRelatedPropertyListProps = Required<\n Pick<\n PropertyListProps,\n | \"onColumnChanged\"\n | \"columnRatio\"\n | \"isResizeHandleHovered\"\n | \"onResizeHandleHoverChanged\"\n | \"isResizeHandleBeingDragged\"\n | \"onResizeHandleDragChanged\"\n | \"columnInfo\"\n | \"orientation\"\n | \"width\"\n >\n>;\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierProps {\n /** Orientation of the properties */\n orientation: Orientation;\n /** Width of the property list */\n width: number;\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n /** Maximum depth of the properties shown */\n maxPropertyDepth?: number;\n /** A callback that receives the required column-resize-related props for the [[PropertyList]] component */\n children: (props: ColumnResizeRelatedPropertyListProps) => React.ReactNode;\n}\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierState {\n columnRatio: number;\n isResizeHandleHovered: boolean;\n isResizeHandleBeingDragged: boolean;\n}\n\n/**\n * Wrapped PropertyCategoryBlock React component with list of properties and render optimization\n * @internal\n */\nexport class ColumnResizingPropertyListPropsSupplier extends React.Component<\n ColumnResizingPropertyListPropsSupplierProps,\n ColumnResizingPropertyListPropsSupplierState\n> {\n private readonly _initialRatio = 0.25;\n private readonly _defaultMinRatio = 0.15;\n private readonly _defaultMaxRatio = 0.6;\n private _minRatio = this._defaultMinRatio;\n private _maxRatio = this._defaultMaxRatio;\n\n public override state: ColumnResizingPropertyListPropsSupplierState = {\n columnRatio: this._initialRatio,\n isResizeHandleHovered: false,\n isResizeHandleBeingDragged: false,\n };\n\n public static defaultProps: Partial<ColumnResizingPropertyListPropsSupplierProps> =\n {\n minLabelWidth: 100,\n minValueWidth: 100,\n };\n\n private _onColumnRatioChanged = (ratio: number) => {\n ratio = clamp(ratio, this._minRatio, this._maxRatio);\n if (this.state.columnRatio === ratio) return { ratio };\n\n this.setState({ columnRatio: ratio });\n return { ratio };\n };\n\n private _onResizeHandleHoverChanged = (isHovered: boolean) => {\n this.setState({ isResizeHandleHovered: isHovered });\n };\n\n private _onResizeHandleDragChanged = (isDragStarted: boolean) => {\n this.setState({ isResizeHandleBeingDragged: isDragStarted });\n };\n\n private isMinimumColumnSizeEnabled() {\n if (this.props.orientation !== Orientation.Horizontal) return false;\n\n // calculated how much width all the borders of nested properties takes up.\n const bordersWidth = this.props.maxPropertyDepth\n ? this.props.maxPropertyDepth * BORDER_WIDTH\n : 0;\n const actionButtonWidth = this.props.actionButtonWidth ?? 0;\n\n // minimum with required to render property. This consists of:\n // * minimum label width\n // * 1px resizer\n // * minimum value width\n // * actions buttons width\n // * all nested borders width\n // * padding\n const propertyWidth =\n this.props.minLabelWidth! +\n 1 +\n this.props.minValueWidth! +\n actionButtonWidth +\n bordersWidth +\n PROPERTY_PADDING;\n // default behavior for screens that are too small to have minimum column widths\n if (this.props.width < propertyWidth) {\n this._minRatio = this._defaultMinRatio;\n // if there are action buttons calculate maximum ratio for label. Otherwise use default.\n this._maxRatio = this.props.actionButtonWidth\n ? (this.props.width -\n this.props.actionButtonWidth -\n bordersWidth -\n PROPERTY_PADDING -\n VALUE_MIN_WIDTH) /\n this.props.width\n : this._defaultMaxRatio;\n return false;\n }\n\n this._minRatio = this.props.minLabelWidth! / this.props.width;\n this._maxRatio =\n (this.props.width - actionButtonWidth - this.props.minValueWidth!) /\n this.props.width;\n return true;\n }\n\n private getValidColumnRatio(): number {\n return clamp(this.state.columnRatio, this._minRatio, this._maxRatio);\n }\n\n public override render() {\n const listProps: ColumnResizeRelatedPropertyListProps = {\n orientation: this.props.orientation,\n width: this.props.width,\n onColumnChanged: this._onColumnRatioChanged,\n columnRatio: this.getValidColumnRatio(),\n isResizeHandleHovered: this.state.isResizeHandleHovered,\n onResizeHandleHoverChanged: this._onResizeHandleHoverChanged,\n isResizeHandleBeingDragged: this.state.isResizeHandleBeingDragged,\n onResizeHandleDragChanged: this._onResizeHandleDragChanged,\n columnInfo: {\n minLabelWidth: this.props.minLabelWidth!,\n minValueWidth: this.props.minValueWidth!,\n actionButtonWidth: this.props.actionButtonWidth!,\n isMinimumColumnSizeEnabled: this.isMinimumColumnSizeEnabled(),\n },\n };\n return this.props.children(listProps);\n }\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value));\n}\n"]}
|
|
@@ -68,6 +68,8 @@ export interface CommonPropertyGridProps extends CommonProps {
|
|
|
68
68
|
* to render an action button for the property or not.
|
|
69
69
|
*/
|
|
70
70
|
actionButtonRenderers?: ActionButtonRenderer[];
|
|
71
|
+
/** Callback to determine which editors should be always visible */
|
|
72
|
+
alwaysShowEditor?: (property: PropertyRecord) => boolean;
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* Properties for highlighting text in property grid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGridCommons.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAE7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,mCAAmC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,sDAAsD;IACtD,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC;CACzB;AAED;;;GAGG;AAEH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,iGAAiG;IACjG,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,gDAAgD;IAChD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,2BAA2B,KAAK,IAAI,CAAC;IAEpE,0CAA0C;IAC1C,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,2DAA2D;IAC3D,sCAAsC,CAAC,EAAE,OAAO,CAAC;IACjD,qCAAqC;IACrC,0BAA0B,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAEhE,wCAAwC;IACxC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,CAClB,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,gBAAgB,KACvB,IAAI,CAAC;IACV,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,CAClB,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,gBAAgB,KACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtB,6CAA6C;IAC7C,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAE5D,uIAAuI;IACvI,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0GAA0G;IAC1G,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAEvC,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyGridCommons.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC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Links.js";
|
|
8
|
+
import { matchLinks, openLink } from "../../common/Links.js";
|
|
9
9
|
import { Orientation } from "../../common/Orientation.js";
|
|
10
10
|
/** @internal */
|
|
11
11
|
export class PropertyGridCommons {
|
|
@@ -28,15 +28,10 @@ export class PropertyGridCommons {
|
|
|
28
28
|
if (linksArray.length <= 0)
|
|
29
29
|
return;
|
|
30
30
|
const foundLink = linksArray[0];
|
|
31
|
-
if (foundLink
|
|
32
|
-
|
|
33
|
-
location.href = foundLink.url;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const windowOpen = window.open(foundLink.url, "_blank");
|
|
37
|
-
windowOpen?.focus();
|
|
38
|
-
}
|
|
31
|
+
if (!foundLink || !foundLink.url) {
|
|
32
|
+
return;
|
|
39
33
|
}
|
|
34
|
+
openLink(foundLink.url);
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8F1D,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,qBAAqB,CACjC,KAAa,EACb,oBAAkC,EAClC,kBAA4B,EAC5B,6BAAsC;QAEtC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,CAAC,UAAU,CAAC;QACnE,IAAI,kBAAkB;YAAE,OAAO,WAAW,CAAC;QAE3C,6BAA6B,GAAG,6BAA6B,IAAI,GAAG,CAAC;QACrE,wCAAwC;QACxC,IAAI,KAAK,GAAG,6BAA6B;YAAE,OAAO,WAAW,CAAC,QAAQ,CAAC;QAEvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACxC,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO;QACnC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;;AAED;;;GAGG;AACW,4BAAQ,GAAG,CACvB,KAAa,EAC0B,EAAE;IACzC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAC1B,CAAC,QAA8C,EAAE,EAAE;QACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC,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 PropertyGrid\n */\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport { matchLinks, openLink } from \"../../common/Links.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { ActionButtonRenderer } from \"../../properties/renderers/ActionButtonRenderer.js\";\nimport type { PropertyValueRendererManager } from \"../../properties/ValueRendererManager.js\";\nimport type { FilteredType } from \"../dataproviders/filterers/PropertyDataFiltererBase.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** Arguments for the Property Editing event callback\n * @public\n */\nexport interface PropertyEditingArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** Unique key of currently edited property */\n propertyKey?: string;\n}\n\n/** Arguments for `PropertyGridProps.onPropertyContextMenu` callback\n * @public\n */\nexport interface PropertyGridContextMenuArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** An event which caused the context menu callback */\n event: React.MouseEvent;\n}\n\n/**\n * Common Property Grid Props to be used by Property Grid Variants\n * @public\n */\n// eslint-disable-next-line deprecation/deprecation\nexport interface CommonPropertyGridProps extends CommonProps {\n /** Grid orientation. When not defined, it is chosen automatically based on width of the grid. */\n orientation?: Orientation;\n\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n\n /** Called to show a context menu when properties are right-clicked */\n onPropertyContextMenu?: (args: PropertyGridContextMenuArgs) => void;\n\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property selection with right click */\n isPropertySelectionOnRightClickEnabled?: boolean;\n /** Callback to property selection */\n onPropertySelectionChanged?: (property: PropertyRecord) => void;\n\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback for when properties are being edited */\n onPropertyEditing?: (\n args: PropertyEditingArgs,\n category: PropertyCategory\n ) => void;\n /** Callback for when properties are updated */\n onPropertyUpdated?: (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => Promise<boolean>;\n\n /** Custom property value renderer manager */\n propertyValueRendererManager?: PropertyValueRendererManager;\n\n /** Indicates whether the orientation is fixed and does not auto-switch to Vertical when the width is too narrow. Defaults to false. */\n isOrientationFixed?: boolean;\n /** The minimum width before the auto-switch to Vertical when the width is too narrow. Defaults to 300. */\n horizontalOrientationMinWidth?: number;\n\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n\n /**\n * Array of action button renderers. Each renderer is called for each property and can decide\n * to render an action button for the property or not.\n */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/**\n * Properties for highlighting text in property grid.\n * @public\n */\nexport interface PropertyGridContentHighlightProps\n extends HighlightingComponentProps {\n /**\n * Specifies what the highlighting should be applied on - category labels, property labels and / or property values.\n * Defaults to \"nowhere\".\n */\n filteredTypes?: FilteredType[];\n}\n\n/** @internal */\nexport class PropertyGridCommons {\n public static getCurrentOrientation(\n width: number,\n preferredOrientation?: Orientation,\n isOrientationFixed?: boolean,\n horizontalOrientationMinWidth?: number\n ): Orientation {\n const orientation = preferredOrientation ?? Orientation.Horizontal;\n if (isOrientationFixed) return orientation;\n\n horizontalOrientationMinWidth = horizontalOrientationMinWidth ?? 300;\n // Switch to Vertical if width too small\n if (width < horizontalOrientationMinWidth) return Orientation.Vertical;\n\n return orientation;\n }\n\n /**\n * Helper method to handle link clicks\n * @internal\n */\n public static handleLinkClick(text: string) {\n const linksArray = matchLinks(text);\n if (linksArray.length <= 0) return;\n const foundLink = linksArray[0];\n if (!foundLink || !foundLink.url) {\n return;\n }\n\n openLink(foundLink.url);\n }\n\n /**\n * A helper method to get links from string.\n * @internal\n */\n public static getLinks = (\n value: string\n ): Array<{ start: number; end: number }> => {\n return matchLinks(value).map(\n (linkInfo: { index: number; lastIndex: number }) => {\n return { start: linkInfo.index, end: linkInfo.lastIndex };\n }\n );\n };\n}\n"]}
|
package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type PropertyGridEventsRelatedProps = Pick<PropertyListProps, "onProperty
|
|
|
10
10
|
/** Properties for [[PropertyGridEventsRelatedPropsSupplier]] React component
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export type PropertyGridEventsRelatedPropsSupplierProps = Pick<CommonPropertyGridProps, "onPropertyContextMenu" | "isPropertySelectionOnRightClickEnabled" | "
|
|
13
|
+
export type PropertyGridEventsRelatedPropsSupplierProps = Pick<CommonPropertyGridProps, "onPropertyContextMenu" | "isPropertySelectionOnRightClickEnabled" | "onPropertySelectionChanged" | "isPropertyEditingEnabled" | "onPropertyUpdated"> & Required<Pick<CommonPropertyGridProps, "isPropertyHoverEnabled" | "isPropertySelectionEnabled">> & {
|
|
14
14
|
children: (context: PropertyGridEventsRelatedProps) => React.ReactNode;
|
|
15
15
|
};
|
|
16
16
|
/** State of [[PropertyGridEventsRelatedPropsSupplier]] React component
|
package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,gBAAgB;AAChB,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,iBAAiB,EACf,mBAAmB,GACnB,wBAAwB,GACxB,uBAAuB,GACvB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,oBAAoB,CACvB,GACC,IAAI,CACF,uBAAuB,EACvB,wCAAwC,GAAG,0BAA0B,CACtE,GACD,QAAQ,CACN,IAAI,CACF,uBAAuB,EACvB,wBAAwB,GAAG,4BAA4B,CACxD,CACF,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG,IAAI,CAC5D,uBAAuB,EACrB,uBAAuB,GACvB,wCAAwC,GACxC,
|
|
1
|
+
{"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,gBAAgB;AAChB,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAC/C,iBAAiB,EACf,mBAAmB,GACnB,wBAAwB,GACxB,uBAAuB,GACvB,cAAc,GACd,cAAc,GACd,qBAAqB,GACrB,oBAAoB,CACvB,GACC,IAAI,CACF,uBAAuB,EACvB,wCAAwC,GAAG,0BAA0B,CACtE,GACD,QAAQ,CACN,IAAI,CACF,uBAAuB,EACvB,wBAAwB,GAAG,4BAA4B,CACxD,CACF,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,2CAA2C,GAAG,IAAI,CAC5D,uBAAuB,EACrB,uBAAuB,GACvB,wCAAwC,GACxC,4BAA4B,GAC5B,0BAA0B,GAC1B,mBAAmB,CACtB,GACC,QAAQ,CACN,IAAI,CACF,uBAAuB,EACvB,wBAAwB,GAAG,4BAA4B,CACxD,CACF,GAAG;IACF,QAAQ,EAAE,CAAC,OAAO,EAAE,8BAA8B,KAAK,KAAK,CAAC,SAAS,CAAC;CACxE,CAAC;AAEJ;;GAEG;AACH,UAAU,2CAA2C;IACnD,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,sCAAuC,SAAQ,KAAK,CAAC,SAAS,CACzE,2CAA2C,EAC3C,2CAA2C,CAC5C;gBACa,KAAK,EAAE,2CAA2C;IAK9D,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,uBAAuB,CAM7B;IAEF,OAAO,CAAC,kBAAkB,CAGxB;IAEF,OAAO,CAAC,sBAAsB,CAO5B;IAEF,OAAO,CAAC,aAAa,CAQnB;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,OAAO,CAAC,6BAA6B;IAgBrC,OAAO,CAAC,4BAA4B;IA8BpB,MAAM;CA0BvB"}
|
package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4D/B;;GAEG;AACH,MAAM,OAAO,sCAAuC,SAAQ,KAAK,CAAC,SAGjE;IACC,YAAY,KAAkD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;QAeP,4BAAuB,GAAG,CAChC,QAAwB,EACxB,GAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;gBAC/B,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC;QAEM,uBAAkB,GAAG,CAAC,QAAwB,EAAE,GAAY,EAAE,EAAE;YACtE,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,IAAI,CAAC,4BAA4B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC,CAAC;QAEM,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KAAK,CAAC,0BAA0B;YACjE,sCAAsC,EACpC,IAAI,CAAC,KAAK,CAAC,sCAAsC;YACnD,wBAAwB,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB;YAC7D,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB;YACnD,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB;YACjD,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE;gBACzC,CAAC,CAAC,IAAI,CAAC,kBAAkB;gBACzB,CAAC,CAAC,SAAS;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE;gBACnD,CAAC,CAAC,IAAI,CAAC,uBAAuB;gBAC9B,CAAC,CAAC,SAAS;YACb,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB;gBACrD,CAAC,CAAC,IAAI,CAAC,sBAAsB;gBAC7B,CAAC,CAAC,SAAS;SACd,CAAC;QAEF,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,QAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAkB,CACtE,CAAC;IACJ,CAAC;CACF","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\n/** @packageDocumentation\n * @module PropertyGrid\n */\nimport \"./PropertyGrid.scss\";\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport type { CommonPropertyGridProps } from \"./PropertyGridCommons.js\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\n\n/** @internal */\nexport type PropertyGridEventsRelatedProps = Pick<\n PropertyListProps,\n | \"onPropertyClicked\"\n | \"onPropertyRightClicked\"\n | \"onPropertyContextMenu\"\n | \"onEditCommit\"\n | \"onEditCancel\"\n | \"selectedPropertyKey\"\n | \"editingPropertyKey\"\n> &\n Pick<\n CommonPropertyGridProps,\n \"isPropertySelectionOnRightClickEnabled\" | \"isPropertyEditingEnabled\"\n > &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n >;\n\n/** Properties for [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\nexport type PropertyGridEventsRelatedPropsSupplierProps = Pick<\n CommonPropertyGridProps,\n | \"onPropertyContextMenu\"\n | \"isPropertySelectionOnRightClickEnabled\"\n | \"isPropertySelectionOnRightClickEnabled\"\n | \"onPropertySelectionChanged\"\n | \"isPropertyEditingEnabled\"\n | \"onPropertyUpdated\"\n> &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n > & {\n children: (context: PropertyGridEventsRelatedProps) => React.ReactNode;\n };\n\n/** State of [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\ninterface PropertyGridEventsRelatedPropsSupplierState {\n /** Unique key of currently selected property */\n selectedPropertyKey?: string;\n /** Unique key of currently edited property */\n editingPropertyKey?: string;\n}\n\n/** PropertyGridEventsRelatedPropsSupplier React component.\n * @internal\n */\nexport class PropertyGridEventsRelatedPropsSupplier extends React.Component<\n PropertyGridEventsRelatedPropsSupplierProps,\n PropertyGridEventsRelatedPropsSupplierState\n> {\n constructor(props: PropertyGridEventsRelatedPropsSupplierProps) {\n super(props);\n this.state = {};\n }\n\n private _isClickSupported() {\n return (\n this.props.isPropertySelectionEnabled ||\n this.props.isPropertyEditingEnabled\n );\n }\n\n private _isRightClickSupported() {\n return this.props.isPropertySelectionOnRightClickEnabled;\n }\n\n private _onPropertyRightClicked = (\n property: PropertyRecord,\n key?: string\n ) => {\n if (this._isRightClickSupported())\n this.onEnabledPropertyRightClicked(property, key);\n };\n\n private _onPropertyClicked = (property: PropertyRecord, key?: string) => {\n if (this._isClickSupported())\n this.onEnabledPropertyLeftClicked(property, key);\n };\n\n private _onPropertyContextMenu = (\n property: PropertyRecord,\n e: React.MouseEvent\n ) => {\n if (this.props.onPropertyContextMenu) {\n this.props.onPropertyContextMenu({ propertyRecord: property, event: e });\n }\n };\n\n private _onEditCommit = async (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => {\n if (this.props.onPropertyUpdated) {\n await this.props.onPropertyUpdated(args, category);\n this.setState({ editingPropertyKey: undefined });\n }\n };\n\n private _onEditCancel = () => {\n this.setState({ editingPropertyKey: undefined });\n };\n\n private onEnabledPropertyRightClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n editingPropertyKey = undefined;\n if (selectedPropertyKey !== key) selectedPropertyKey = key;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n private onEnabledPropertyLeftClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n const isEditingEnabled = this.props.isPropertyEditingEnabled;\n const isSelectionEnabled = this.props.isPropertySelectionEnabled;\n\n if (isEditingEnabled) {\n // Deselect editing key only if another selection was made\n editingPropertyKey =\n isSelectionEnabled && selectedPropertyKey !== key ? undefined : key;\n }\n\n if (editingPropertyKey === key) {\n this.setState({ editingPropertyKey });\n return;\n }\n\n // Select/Deselect\n selectedPropertyKey = selectedPropertyKey !== key ? key : undefined;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n public override render() {\n const renderContext: PropertyGridEventsRelatedProps = {\n isPropertyHoverEnabled: this.props.isPropertyHoverEnabled,\n isPropertySelectionEnabled: this.props.isPropertySelectionEnabled,\n isPropertySelectionOnRightClickEnabled:\n this.props.isPropertySelectionOnRightClickEnabled,\n isPropertyEditingEnabled: this.props.isPropertyEditingEnabled,\n selectedPropertyKey: this.state.selectedPropertyKey,\n editingPropertyKey: this.state.editingPropertyKey,\n onEditCommit: this._onEditCommit,\n onEditCancel: this._onEditCancel,\n onPropertyClicked: this._isClickSupported()\n ? this._onPropertyClicked\n : undefined,\n onPropertyRightClicked: this._isRightClickSupported()\n ? this._onPropertyRightClicked\n : undefined,\n onPropertyContextMenu: this.props.onPropertyContextMenu\n ? this._onPropertyContextMenu\n : undefined,\n };\n\n return (\n <React.Fragment>{this.props.children(renderContext)}</React.Fragment>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2D/B;;GAEG;AACH,MAAM,OAAO,sCAAuC,SAAQ,KAAK,CAAC,SAGjE;IACC,YAAY,KAAkD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;QAeP,4BAAuB,GAAG,CAChC,QAAwB,EACxB,GAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;gBAC/B,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC;QAEM,uBAAkB,GAAG,CAAC,QAAwB,EAAE,GAAY,EAAE,EAAE;YACtE,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,IAAI,CAAC,4BAA4B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC,CAAC;QAEM,2BAAsB,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AC,0BAA0B;YACjE,sCAAsC,EACpC,IAAI,CAAC,KAAK,CAAC,sCAAsC;YACnD,wBAAwB,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB;YAC7D,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB;YACnD,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB;YACjD,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE;gBACzC,CAAC,CAAC,IAAI,CAAC,kBAAkB;gBACzB,CAAC,CAAC,SAAS;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE;gBACnD,CAAC,CAAC,IAAI,CAAC,uBAAuB;gBAC9B,CAAC,CAAC,SAAS;YACb,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB;gBACrD,CAAC,CAAC,IAAI,CAAC,sBAAsB;gBAC7B,CAAC,CAAC,SAAS;SACd,CAAC;QAEF,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,QAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAkB,CACtE,CAAC;IACJ,CAAC;CACF","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\n/** @packageDocumentation\n * @module PropertyGrid\n */\nimport \"./PropertyGrid.scss\";\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport type { CommonPropertyGridProps } from \"./PropertyGridCommons.js\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\n\n/** @internal */\nexport type PropertyGridEventsRelatedProps = Pick<\n PropertyListProps,\n | \"onPropertyClicked\"\n | \"onPropertyRightClicked\"\n | \"onPropertyContextMenu\"\n | \"onEditCommit\"\n | \"onEditCancel\"\n | \"selectedPropertyKey\"\n | \"editingPropertyKey\"\n> &\n Pick<\n CommonPropertyGridProps,\n \"isPropertySelectionOnRightClickEnabled\" | \"isPropertyEditingEnabled\"\n > &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n >;\n\n/** Properties for [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\nexport type PropertyGridEventsRelatedPropsSupplierProps = Pick<\n CommonPropertyGridProps,\n | \"onPropertyContextMenu\"\n | \"isPropertySelectionOnRightClickEnabled\"\n | \"onPropertySelectionChanged\"\n | \"isPropertyEditingEnabled\"\n | \"onPropertyUpdated\"\n> &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n > & {\n children: (context: PropertyGridEventsRelatedProps) => React.ReactNode;\n };\n\n/** State of [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\ninterface PropertyGridEventsRelatedPropsSupplierState {\n /** Unique key of currently selected property */\n selectedPropertyKey?: string;\n /** Unique key of currently edited property */\n editingPropertyKey?: string;\n}\n\n/** PropertyGridEventsRelatedPropsSupplier React component.\n * @internal\n */\nexport class PropertyGridEventsRelatedPropsSupplier extends React.Component<\n PropertyGridEventsRelatedPropsSupplierProps,\n PropertyGridEventsRelatedPropsSupplierState\n> {\n constructor(props: PropertyGridEventsRelatedPropsSupplierProps) {\n super(props);\n this.state = {};\n }\n\n private _isClickSupported() {\n return (\n this.props.isPropertySelectionEnabled ||\n this.props.isPropertyEditingEnabled\n );\n }\n\n private _isRightClickSupported() {\n return this.props.isPropertySelectionOnRightClickEnabled;\n }\n\n private _onPropertyRightClicked = (\n property: PropertyRecord,\n key?: string\n ) => {\n if (this._isRightClickSupported())\n this.onEnabledPropertyRightClicked(property, key);\n };\n\n private _onPropertyClicked = (property: PropertyRecord, key?: string) => {\n if (this._isClickSupported())\n this.onEnabledPropertyLeftClicked(property, key);\n };\n\n private _onPropertyContextMenu = (\n property: PropertyRecord,\n e: React.MouseEvent\n ) => {\n if (this.props.onPropertyContextMenu) {\n this.props.onPropertyContextMenu({ propertyRecord: property, event: e });\n }\n };\n\n private _onEditCommit = async (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => {\n if (this.props.onPropertyUpdated) {\n await this.props.onPropertyUpdated(args, category);\n this.setState({ editingPropertyKey: undefined });\n }\n };\n\n private _onEditCancel = () => {\n this.setState({ editingPropertyKey: undefined });\n };\n\n private onEnabledPropertyRightClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n editingPropertyKey = undefined;\n if (selectedPropertyKey !== key) selectedPropertyKey = key;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n private onEnabledPropertyLeftClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n const isEditingEnabled = this.props.isPropertyEditingEnabled;\n const isSelectionEnabled = this.props.isPropertySelectionEnabled;\n\n if (isEditingEnabled) {\n // Deselect editing key only if another selection was made\n editingPropertyKey =\n isSelectionEnabled && selectedPropertyKey !== key ? undefined : key;\n }\n\n if (editingPropertyKey === key) {\n this.setState({ editingPropertyKey });\n return;\n }\n\n // Select/Deselect\n selectedPropertyKey = selectedPropertyKey !== key ? key : undefined;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n public override render() {\n const renderContext: PropertyGridEventsRelatedProps = {\n isPropertyHoverEnabled: this.props.isPropertyHoverEnabled,\n isPropertySelectionEnabled: this.props.isPropertySelectionEnabled,\n isPropertySelectionOnRightClickEnabled:\n this.props.isPropertySelectionOnRightClickEnabled,\n isPropertyEditingEnabled: this.props.isPropertyEditingEnabled,\n selectedPropertyKey: this.state.selectedPropertyKey,\n editingPropertyKey: this.state.editingPropertyKey,\n onEditCommit: this._onEditCommit,\n onEditCancel: this._onEditCancel,\n onPropertyClicked: this._isClickSupported()\n ? this._onPropertyClicked\n : undefined,\n onPropertyRightClicked: this._isRightClickSupported()\n ? this._onPropertyRightClicked\n : undefined,\n onPropertyContextMenu: this.props.onPropertyContextMenu\n ? this._onPropertyContextMenu\n : undefined,\n };\n\n return (\n <React.Fragment>{this.props.children(renderContext)}</React.Fragment>\n );\n }\n}\n"]}
|
|
@@ -68,6 +68,8 @@ export interface VirtualizedPropertyGridContext {
|
|
|
68
68
|
isPropertyHoverEnabled: boolean;
|
|
69
69
|
isPropertySelectionEnabled: boolean;
|
|
70
70
|
selectedPropertyKey?: string;
|
|
71
|
+
isPropertyEditingEnabled?: boolean;
|
|
72
|
+
alwaysShowEditor?: (property: PropertyRecord) => boolean;
|
|
71
73
|
onPropertyClicked?: (property: PropertyRecord, key?: string) => void;
|
|
72
74
|
onPropertyRightClicked?: (property: PropertyRecord, key?: string) => void;
|
|
73
75
|
onPropertyContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedPropertyGrid.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/VirtualizedPropertyGrid.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,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AAE,YAAY,EAAE,CAAC;IAC1B,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,SAAS,EAAE,kBAAkB,CAAC;IAE9B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,8BAA8B,CAAC;IAC5C,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3E;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAElB,sBAAsB,EAAE,OAAO,CAAC;IAChC,0BAA0B,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"VirtualizedPropertyGrid.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/VirtualizedPropertyGrid.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAChG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAE7F,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,wCAAwC,CAAC;AAMhD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,OAAO,EAAE,+BA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yBAAyB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACvD,0BAA0B,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAExD,SAAS,CAAC,EAAE,iCAAiC,CAAC;CAC/C;AAeD;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,KAAK,CAAC,SAAS,CAC1D,4BAA4B,EAC5B,4BAA4B,CAC7B;IACC,OAAO,CAAC,QAAQ,CAAuC;gBAE3C,KAAK,EAAE,4BAA4B;IAgB/B,kBAAkB,CAAC,SAAS,EAAE,4BAA4B;IAyC1E,gBAAgB;WACF,wBAAwB,CACpC,KAAK,EAAE,4BAA4B,EACnC,KAAK,EAAE,4BAA4B,GAClC,4BAA4B,GAAG,IAAI;IAOtC,OAAO,CAAC,iBAAiB;IAgBzB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,uBAAuB,CAqB7B;IAEF,OAAO,CAAC,2BAA2B,CAGjC;IAEF,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,WAAW,CAGjB;IAEF,OAAO,CAAC,gBAAgB,CAQtB;IAEc,MAAM;CA6GvB;AAsCD;;;;GAIG;AACH,wBAAgB,uCAAuC,CAAC,CAAC,SAAS,OAAO;;;;EAExE"}
|
|
@@ -165,6 +165,8 @@ export class VirtualizedPropertyGrid extends React.Component {
|
|
|
165
165
|
isPropertyHoverEnabled: selectionContext.isPropertyHoverEnabled,
|
|
166
166
|
isPropertySelectionEnabled: selectionContext.isPropertySelectionEnabled,
|
|
167
167
|
selectedPropertyKey: selectionContext.selectedPropertyKey,
|
|
168
|
+
isPropertyEditingEnabled: this.props.isPropertyEditingEnabled,
|
|
169
|
+
alwaysShowEditor: this.props.alwaysShowEditor,
|
|
168
170
|
onPropertyClicked: selectionContext.onPropertyClicked,
|
|
169
171
|
onPropertyRightClicked: selectionContext.onPropertyRightClicked,
|
|
170
172
|
onPropertyContextMenu: selectionContext.onPropertyContextMenu,
|
|
@@ -260,7 +262,7 @@ const FlatGridItemNode = React.memo(({ index, style: virtualizedListStyle }) =>
|
|
|
260
262
|
const selectionKey = node.selectionKey;
|
|
261
263
|
const parentCategoryItem = gridModel.getItem(node.parentCategorySelectionKey);
|
|
262
264
|
return (React.createElement(FlatItemNestedBorderWrapper, { borderCount: parentCategoryItem.depth + 1, bottomBorderCount: lastInNumberOfCategories, className: "virtualized-grid-node-content" },
|
|
263
|
-
React.createElement(FlatPropertyRenderer, { key: node.key, uniqueKey: selectionKey, propertyRecord: node.derivedRecord, orientation: gridContext.orientation, indentation: node.depth, width: gridContext.gridWidth, isHoverable: gridContext.isPropertyHoverEnabled, isSelectable: gridContext.isPropertySelectionEnabled, isSelected: selectionKey === gridContext.selectedPropertyKey, onClick: gridContext.onPropertyClicked, onRightClick: gridContext.onPropertyRightClicked, onContextMenu: gridContext.onPropertyContextMenu, category: parentCategoryItem.derivedCategory, isEditing: selectionKey === gridContext.editingPropertyKey, onEditCommit: gridContext.onEditCommit, onEditCancel: gridContext.onEditCancel, isExpanded: node.isExpanded, onExpansionToggled: onExpansionToggled, onHeightChanged: onHeightChanged, actionButtonRenderers: gridContext.actionButtonRenderers, propertyValueRendererManager: gridContext.propertyValueRendererManager, columnRatio: gridContext.columnRatio, columnInfo: gridContext.columnInfo, isResizeHandleBeingDragged: gridContext.isResizeHandleBeingDragged, isResizeHandleHovered: gridContext.isResizeHandleHovered, onColumnRatioChanged: gridContext.onColumnRatioChanged, onResizeHandleDragChanged: gridContext.onResizeHandleDragChanged, onResizeHandleHoverChanged: gridContext.onResizeHandleHoverChanged, highlight: gridContext.highlight
|
|
265
|
+
React.createElement(FlatPropertyRenderer, { key: node.key, uniqueKey: selectionKey, propertyRecord: node.derivedRecord, orientation: gridContext.orientation, indentation: node.depth, width: gridContext.gridWidth, isHoverable: gridContext.isPropertyHoverEnabled, isSelectable: gridContext.isPropertySelectionEnabled, isSelected: selectionKey === gridContext.selectedPropertyKey, onClick: gridContext.onPropertyClicked, onRightClick: gridContext.onPropertyRightClicked, onContextMenu: gridContext.onPropertyContextMenu, category: parentCategoryItem.derivedCategory, isEditing: selectionKey === gridContext.editingPropertyKey, isPropertyEditingEnabled: gridContext.isPropertyEditingEnabled, alwaysShowEditor: gridContext.alwaysShowEditor, onEditCommit: gridContext.onEditCommit, onEditCancel: gridContext.onEditCancel, isExpanded: node.isExpanded, onExpansionToggled: onExpansionToggled, onHeightChanged: onHeightChanged, actionButtonRenderers: gridContext.actionButtonRenderers, propertyValueRendererManager: gridContext.propertyValueRendererManager, columnRatio: gridContext.columnRatio, columnInfo: gridContext.columnInfo, isResizeHandleBeingDragged: gridContext.isResizeHandleBeingDragged, isResizeHandleHovered: gridContext.isResizeHandleHovered, onColumnRatioChanged: gridContext.onColumnRatioChanged, onResizeHandleDragChanged: gridContext.onResizeHandleDragChanged, onResizeHandleHoverChanged: gridContext.onResizeHandleHoverChanged, highlight: gridContext.highlight
|
|
264
266
|
? {
|
|
265
267
|
applyOnLabel: gridContext.highlight.filteredTypes?.includes(FilteredType.Label) ?? false,
|
|
266
268
|
applyOnValue: gridContext.highlight.filteredTypes?.includes(FilteredType.Value) ?? false,
|