@itwin/components-react 5.19.0 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/lib/components-react/UiComponents.js +2 -1
- package/lib/components-react/UiComponents.js.map +1 -1
- package/lib/components-react/common/ImageRenderer.js +1 -1
- package/lib/components-react/common/ImageRenderer.js.map +1 -1
- package/lib/components-react/common/SubscriptionScheduler.js +1 -1
- package/lib/components-react/common/SubscriptionScheduler.js.map +1 -1
- package/lib/components-react/common/selection/SelectionHandler.js +20 -2
- package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
- package/lib/components-react/converters/BooleanTypeConverter.js +4 -4
- package/lib/components-react/converters/BooleanTypeConverter.js.map +1 -1
- package/lib/components-react/converters/PointTypeConverter.js +1 -0
- package/lib/components-react/converters/PointTypeConverter.js.map +1 -1
- package/lib/components-react/converters/TypeConverterManager.js +2 -1
- package/lib/components-react/converters/TypeConverterManager.js.map +1 -1
- package/lib/components-react/datepicker/IntlFormatter.js +1 -0
- package/lib/components-react/datepicker/IntlFormatter.js.map +1 -1
- package/lib/components-react/editors/BooleanEditor.js +23 -26
- package/lib/components-react/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/editors/CustomNumberEditor.js +92 -97
- package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.js +60 -63
- package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js +23 -26
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/editors/EnumEditor.js +30 -33
- package/lib/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/editors/IconEditor.js +16 -16
- package/lib/components-react/editors/IconEditor.js.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js +22 -25
- package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.js +26 -29
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/PopupButton.js +26 -29
- package/lib/components-react/editors/PopupButton.js.map +1 -1
- package/lib/components-react/editors/PropertyEditorManager.js +2 -4
- package/lib/components-react/editors/PropertyEditorManager.js.map +1 -1
- package/lib/components-react/editors/SliderEditor.js +65 -68
- package/lib/components-react/editors/SliderEditor.js.map +1 -1
- package/lib/components-react/editors/TextEditor.js +22 -25
- package/lib/components-react/editors/TextEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.js +29 -32
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/editors/ToggleEditor.js +26 -29
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/filter-builder/FilterBuilderState.js +1 -0
- package/lib/components-react/filter-builder/FilterBuilderState.js.map +1 -1
- package/lib/components-react/filtering/FilteringInput.js +36 -36
- package/lib/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/components-react/filtering/ResultSelector.js +50 -50
- package/lib/components-react/filtering/ResultSelector.js.map +1 -1
- package/lib/components-react/iconpicker/IconPickerButton.js +18 -18
- package/lib/components-react/iconpicker/IconPickerButton.js.map +1 -1
- package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts +3 -2
- package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/FormattedNumericInput.js +2 -2
- package/lib/components-react/new-editors/editors/FormattedNumericInput.js.map +1 -1
- package/lib/components-react/properties/ValueRendererManager.js +6 -7
- package/lib/components-react/properties/ValueRendererManager.js.map +1 -1
- package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +17 -17
- package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/PropertyGridColumns.js +4 -3
- package/lib/components-react/properties/renderers/PropertyGridColumns.js.map +1 -1
- package/lib/components-react/properties/renderers/PropertyView.js +23 -23
- package/lib/components-react/properties/renderers/PropertyView.js.map +1 -1
- package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js +6 -9
- package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js +9 -12
- package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js.map +1 -1
- package/lib/components-react/propertygrid/MergingPropertyDataProvider.js +2 -1
- package/lib/components-react/propertygrid/MergingPropertyDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -4
- package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/components-react/propertygrid/SimplePropertyDataProvider.js +6 -4
- package/lib/components-react/propertygrid/SimplePropertyDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +26 -29
- package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js +3 -3
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js +9 -9
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +22 -22
- package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyList.js +5 -5
- package/lib/components-react/propertygrid/component/PropertyList.js.map +1 -1
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +29 -29
- package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +12 -14
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +3 -0
- package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js +1 -3
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js.map +1 -1
- package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js +11 -10
- package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js.map +1 -1
- package/lib/components-react/propertygrid/internal/PropertyGridModel.js +3 -3
- package/lib/components-react/propertygrid/internal/PropertyGridModel.js.map +1 -1
- package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js +4 -2
- package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js +2 -0
- package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js +2 -0
- package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +6 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +10 -7
- package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -0
- package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +8 -8
- package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/components-react/toolbar/InternalToolbarComponent.js +4 -4
- package/lib/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
- package/lib/components-react/toolbar/utilities/Direction.js +12 -12
- package/lib/components-react/toolbar/utilities/Direction.js.map +1 -1
- package/lib/components-react/tree/HighlightingEngine.js +3 -1
- package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
- package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
- package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventDispatcher.js +5 -1
- package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventHandler.js +10 -14
- package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModel.js +7 -9
- package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeModelSource.js +3 -2
- package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeNodeLoader.js +11 -3
- package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.js +1 -4
- package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/SparseTree.js +7 -5
- package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +3 -0
- package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
- package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js +56 -51
- package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/package.json +5 -5
|
@@ -18,65 +18,65 @@ import { SvgChevronLeft, SvgChevronRight } from "@itwin/itwinui-icons-react";
|
|
|
18
18
|
export class ResultSelector extends React.PureComponent {
|
|
19
19
|
constructor(props) {
|
|
20
20
|
super(props);
|
|
21
|
-
this._onClickPrevious = () => {
|
|
22
|
-
if (this.state.selectedResultInEditMode) {
|
|
23
|
-
this._onSelectedResultConfirmed();
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (this.state.selectedResultId > 1) {
|
|
27
|
-
this.props.onSelectedChanged(this.state.selectedResultId - 1);
|
|
28
|
-
this.setState((state) => ({
|
|
29
|
-
selectedResultId: state.selectedResultId - 1,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
this._onClickNext = () => {
|
|
34
|
-
if (this.state.selectedResultInEditMode) {
|
|
35
|
-
this._onSelectedResultConfirmed();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (this.state.selectedResultId < this.props.resultCount) {
|
|
39
|
-
this.props.onSelectedChanged(this.state.selectedResultId + 1);
|
|
40
|
-
this.setState((state) => ({
|
|
41
|
-
selectedResultId: state.selectedResultId + 1,
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
this._onSelectedResultChanged = (event) => {
|
|
46
|
-
if (event.target.value.length <= this._maxSelectedResultInputLength)
|
|
47
|
-
this.setState({ selectedResultEdit: event.target.value });
|
|
48
|
-
};
|
|
49
|
-
this._onSelectedResultConfirmed = () => {
|
|
50
|
-
let selectedId = +this.state.selectedResultEdit;
|
|
51
|
-
if (selectedId > this.props.resultCount)
|
|
52
|
-
selectedId = this.props.resultCount;
|
|
53
|
-
else if (selectedId < 1)
|
|
54
|
-
selectedId = 1;
|
|
55
|
-
this.setState({
|
|
56
|
-
selectedResultInEditMode: false,
|
|
57
|
-
selectedResultId: selectedId,
|
|
58
|
-
});
|
|
59
|
-
this.props.onSelectedChanged(selectedId);
|
|
60
|
-
};
|
|
61
|
-
this._onSelectedResultClick = () => {
|
|
62
|
-
this.setState((state) => ({
|
|
63
|
-
selectedResultInEditMode: true,
|
|
64
|
-
selectedResultEdit: state.selectedResultId.toString(),
|
|
65
|
-
}));
|
|
66
|
-
};
|
|
67
|
-
this._onSelectedResultKeyDown = (event) => {
|
|
68
|
-
if (event.key === Key.Enter.valueOf())
|
|
69
|
-
this._onSelectedResultConfirmed();
|
|
70
|
-
};
|
|
71
21
|
this.state = {
|
|
72
22
|
selectedResultId: props.resultCount ? 1 : 0,
|
|
73
23
|
selectedResultEdit: "",
|
|
74
24
|
selectedResultInEditMode: false,
|
|
75
25
|
};
|
|
76
26
|
}
|
|
27
|
+
_onClickPrevious = () => {
|
|
28
|
+
if (this.state.selectedResultInEditMode) {
|
|
29
|
+
this._onSelectedResultConfirmed();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (this.state.selectedResultId > 1) {
|
|
33
|
+
this.props.onSelectedChanged(this.state.selectedResultId - 1);
|
|
34
|
+
this.setState((state) => ({
|
|
35
|
+
selectedResultId: state.selectedResultId - 1,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
_onClickNext = () => {
|
|
40
|
+
if (this.state.selectedResultInEditMode) {
|
|
41
|
+
this._onSelectedResultConfirmed();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this.state.selectedResultId < this.props.resultCount) {
|
|
45
|
+
this.props.onSelectedChanged(this.state.selectedResultId + 1);
|
|
46
|
+
this.setState((state) => ({
|
|
47
|
+
selectedResultId: state.selectedResultId + 1,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
77
51
|
get _maxSelectedResultInputLength() {
|
|
78
52
|
return this.props.resultCount.toString().length;
|
|
79
53
|
}
|
|
54
|
+
_onSelectedResultChanged = (event) => {
|
|
55
|
+
if (event.target.value.length <= this._maxSelectedResultInputLength)
|
|
56
|
+
this.setState({ selectedResultEdit: event.target.value });
|
|
57
|
+
};
|
|
58
|
+
_onSelectedResultConfirmed = () => {
|
|
59
|
+
let selectedId = +this.state.selectedResultEdit;
|
|
60
|
+
if (selectedId > this.props.resultCount)
|
|
61
|
+
selectedId = this.props.resultCount;
|
|
62
|
+
else if (selectedId < 1)
|
|
63
|
+
selectedId = 1;
|
|
64
|
+
this.setState({
|
|
65
|
+
selectedResultInEditMode: false,
|
|
66
|
+
selectedResultId: selectedId,
|
|
67
|
+
});
|
|
68
|
+
this.props.onSelectedChanged(selectedId);
|
|
69
|
+
};
|
|
70
|
+
_onSelectedResultClick = () => {
|
|
71
|
+
this.setState((state) => ({
|
|
72
|
+
selectedResultInEditMode: true,
|
|
73
|
+
selectedResultEdit: state.selectedResultId.toString(),
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
_onSelectedResultKeyDown = (event) => {
|
|
77
|
+
if (event.key === Key.Enter.valueOf())
|
|
78
|
+
this._onSelectedResultConfirmed();
|
|
79
|
+
};
|
|
80
80
|
componentDidMount() {
|
|
81
81
|
this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);
|
|
82
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultSelector.js","sourceRoot":"","sources":["../../../src/components-react/filtering/ResultSelector.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,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B,CAAC,CAAC,CAAC,CACrC,+BACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE;wBACL,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI;qBAC7D,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACpC,QAAQ,EAAE,IAAI,CAAC,wBAAwB,EACvC,MAAM,EAAE,IAAI,CAAC,0BAA0B,EACvC,SAAS,EAAE,IAAI,CAAC,wBAAwB,GACxC,CACH,CAAC,CAAC,CAAC,CACF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAC5B;gBACD,8BAAM,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IACnD,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,CAChC;gBACP,kCAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAQ,CAChC;YAEP,gCACE,SAAS,EAAC,wCAAwC,iBACtC,aAAa,EACzB,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;gBAGrC,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,eAAe,OAAG,GAAI,CAChC,CACJ,CACR,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/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./ResultSelector.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\n/** [[ResultSelector]] React Component state\n * @internal\n */\ninterface ResultSelectorState {\n /** Currently selected result/entry index */\n selectedResultId: number;\n /** Input string */\n selectedResultEdit: string;\n /** Informs if selectedResult is currently being edited */\n selectedResultInEditMode: boolean;\n}\n\n/** [[ResultSelector]] React Component properties\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ResultSelectorProps extends CommonProps {\n /** Total number of results/entries */\n resultCount: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n}\n\n/** Component for stepping through results/entries\n * @public\n */\nexport class ResultSelector extends React.PureComponent<\n ResultSelectorProps,\n ResultSelectorState\n> {\n constructor(props: ResultSelectorProps) {\n super(props);\n this.state = {\n selectedResultId: props.resultCount ? 1 : 0,\n selectedResultEdit: \"\",\n selectedResultInEditMode: false,\n };\n }\n\n private _onClickPrevious = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId > 1) {\n this.props.onSelectedChanged(this.state.selectedResultId - 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId - 1,\n }));\n }\n };\n\n private _onClickNext = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId < this.props.resultCount) {\n this.props.onSelectedChanged(this.state.selectedResultId + 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId + 1,\n }));\n }\n };\n\n private get _maxSelectedResultInputLength() {\n return this.props.resultCount.toString().length;\n }\n\n private _onSelectedResultChanged = (\n event: React.ChangeEvent<HTMLInputElement>\n ) => {\n if (event.target.value.length <= this._maxSelectedResultInputLength)\n this.setState({ selectedResultEdit: event.target.value });\n };\n\n private _onSelectedResultConfirmed = () => {\n let selectedId = +this.state.selectedResultEdit;\n if (selectedId > this.props.resultCount)\n selectedId = this.props.resultCount;\n else if (selectedId < 1) selectedId = 1;\n\n this.setState({\n selectedResultInEditMode: false,\n selectedResultId: selectedId,\n });\n this.props.onSelectedChanged(selectedId);\n };\n\n private _onSelectedResultClick = () => {\n this.setState((state) => ({\n selectedResultInEditMode: true,\n selectedResultEdit: state.selectedResultId.toString(),\n }));\n };\n\n private _onSelectedResultKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === Key.Enter.valueOf()) this._onSelectedResultConfirmed();\n };\n\n public override componentDidMount() {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: ResultSelectorProps) {\n if (this.props.resultCount !== prevProps.resultCount) {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n }\n\n public override render() {\n return (\n <span\n className={classnames(\n \"components-result-selector\",\n this.props.className\n )}\n style={this.props.style}\n >\n <button\n className={classnames(\"components-result-selector-button\", \"icon\")}\n data-testid=\"previous-button\"\n onClick={this._onClickPrevious}\n disabled={this.props.resultCount <= 0}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n\n <span\n style={{ pointerEvents: this.props.resultCount ? \"auto\" : \"none\" }}\n className=\"components-result-selector-current-result\"\n onClick={this._onSelectedResultClick}\n role=\"presentation\"\n >\n {this.state.selectedResultInEditMode ? (\n <input\n type=\"number\"\n style={{\n width: `${this.state.selectedResultEdit.length * 0.6 + 1}em`,\n }}\n value={this.state.selectedResultEdit}\n onChange={this._onSelectedResultChanged}\n onBlur={this._onSelectedResultConfirmed}\n onKeyDown={this._onSelectedResultKeyDown}\n />\n ) : (\n this.state.selectedResultId\n )}\n <span style={{ marginLeft: \"5px\", marginRight: \"5px\" }}>\n {UiComponents.translate(\"general.of\")}\n </span>\n <span>{this.props.resultCount}</span>\n </span>\n\n <button\n className=\"components-result-selector-button icon\"\n data-testid=\"next-button\"\n onClick={this._onClickNext}\n disabled={this.props.resultCount <= 0}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </span>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ResultSelector.js","sourceRoot":"","sources":["../../../src/components-react/filtering/ResultSelector.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAyB7E;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,aAGzC;IACC,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,kBAAkB,EAAE,EAAE;YACtB,wBAAwB,EAAE,KAAK;SAChC,CAAC;IACJ,CAAC;IAEO,gBAAgB,GAAG,GAAG,EAAE;QAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;YACxC,IAAI,CAAC,0BAA0B,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,GAAG,CAAC;aAC7C,CAAC,CAA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,CACR,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/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./ResultSelector.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\n/** [[ResultSelector]] React Component state\n * @internal\n */\ninterface ResultSelectorState {\n /** Currently selected result/entry index */\n selectedResultId: number;\n /** Input string */\n selectedResultEdit: string;\n /** Informs if selectedResult is currently being edited */\n selectedResultInEditMode: boolean;\n}\n\n/** [[ResultSelector]] React Component properties\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface ResultSelectorProps extends CommonProps {\n /** Total number of results/entries */\n resultCount: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n}\n\n/** Component for stepping through results/entries\n * @public\n */\nexport class ResultSelector extends React.PureComponent<\n ResultSelectorProps,\n ResultSelectorState\n> {\n constructor(props: ResultSelectorProps) {\n super(props);\n this.state = {\n selectedResultId: props.resultCount ? 1 : 0,\n selectedResultEdit: \"\",\n selectedResultInEditMode: false,\n };\n }\n\n private _onClickPrevious = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId > 1) {\n this.props.onSelectedChanged(this.state.selectedResultId - 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId - 1,\n }));\n }\n };\n\n private _onClickNext = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId < this.props.resultCount) {\n this.props.onSelectedChanged(this.state.selectedResultId + 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId + 1,\n }));\n }\n };\n\n private get _maxSelectedResultInputLength() {\n return this.props.resultCount.toString().length;\n }\n\n private _onSelectedResultChanged = (\n event: React.ChangeEvent<HTMLInputElement>\n ) => {\n if (event.target.value.length <= this._maxSelectedResultInputLength)\n this.setState({ selectedResultEdit: event.target.value });\n };\n\n private _onSelectedResultConfirmed = () => {\n let selectedId = +this.state.selectedResultEdit;\n if (selectedId > this.props.resultCount)\n selectedId = this.props.resultCount;\n else if (selectedId < 1) selectedId = 1;\n\n this.setState({\n selectedResultInEditMode: false,\n selectedResultId: selectedId,\n });\n this.props.onSelectedChanged(selectedId);\n };\n\n private _onSelectedResultClick = () => {\n this.setState((state) => ({\n selectedResultInEditMode: true,\n selectedResultEdit: state.selectedResultId.toString(),\n }));\n };\n\n private _onSelectedResultKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === Key.Enter.valueOf()) this._onSelectedResultConfirmed();\n };\n\n public override componentDidMount() {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: ResultSelectorProps) {\n if (this.props.resultCount !== prevProps.resultCount) {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n }\n\n public override render() {\n return (\n <span\n className={classnames(\n \"components-result-selector\",\n this.props.className\n )}\n style={this.props.style}\n >\n <button\n className={classnames(\"components-result-selector-button\", \"icon\")}\n data-testid=\"previous-button\"\n onClick={this._onClickPrevious}\n disabled={this.props.resultCount <= 0}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n\n <span\n style={{ pointerEvents: this.props.resultCount ? \"auto\" : \"none\" }}\n className=\"components-result-selector-current-result\"\n onClick={this._onSelectedResultClick}\n role=\"presentation\"\n >\n {this.state.selectedResultInEditMode ? (\n <input\n type=\"number\"\n style={{\n width: `${this.state.selectedResultEdit.length * 0.6 + 1}em`,\n }}\n value={this.state.selectedResultEdit}\n onChange={this._onSelectedResultChanged}\n onBlur={this._onSelectedResultConfirmed}\n onKeyDown={this._onSelectedResultKeyDown}\n />\n ) : (\n this.state.selectedResultId\n )}\n <span style={{ marginLeft: \"5px\", marginRight: \"5px\" }}>\n {UiComponents.translate(\"general.of\")}\n </span>\n <span>{this.props.resultCount}</span>\n </span>\n\n <button\n className=\"components-result-selector-button icon\"\n data-testid=\"next-button\"\n onClick={this._onClickNext}\n disabled={this.props.resultCount <= 0}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </span>\n );\n }\n}\n"]}
|
|
@@ -34,25 +34,28 @@ class IconItem extends React.PureComponent {
|
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
36
|
export class IconPickerButton extends React.PureComponent {
|
|
37
|
+
_target = React.createRef();
|
|
38
|
+
static defaultProps = {
|
|
39
|
+
numColumns: 4,
|
|
40
|
+
};
|
|
37
41
|
constructor(props) {
|
|
38
42
|
super(props);
|
|
39
|
-
this._target = React.createRef();
|
|
40
|
-
this._togglePopup = () => {
|
|
41
|
-
if (this.props.readonly)
|
|
42
|
-
return;
|
|
43
|
-
this.setState((prevState) => ({ showPopup: !prevState.showPopup }));
|
|
44
|
-
};
|
|
45
|
-
this._closePopup = () => {
|
|
46
|
-
this.setState({ showPopup: false });
|
|
47
|
-
};
|
|
48
|
-
this._handleIconPicked = (icon) => {
|
|
49
|
-
this.setState({ showPopup: false, icon }, () => {
|
|
50
|
-
if (this.props.onIconChange)
|
|
51
|
-
this.props.onIconChange(icon);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
43
|
this.state = { showPopup: false, icon: this.props.icon };
|
|
55
44
|
}
|
|
45
|
+
_togglePopup = () => {
|
|
46
|
+
if (this.props.readonly)
|
|
47
|
+
return;
|
|
48
|
+
this.setState((prevState) => ({ showPopup: !prevState.showPopup }));
|
|
49
|
+
};
|
|
50
|
+
_closePopup = () => {
|
|
51
|
+
this.setState({ showPopup: false });
|
|
52
|
+
};
|
|
53
|
+
_handleIconPicked = (icon) => {
|
|
54
|
+
this.setState({ showPopup: false, icon }, () => {
|
|
55
|
+
if (this.props.onIconChange)
|
|
56
|
+
this.props.onIconChange(icon);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
56
59
|
renderPopup(title) {
|
|
57
60
|
const containerStyle = {
|
|
58
61
|
gridTemplateColumns: `repeat(${this.props.numColumns}, 1fr)`,
|
|
@@ -72,7 +75,4 @@ export class IconPickerButton extends React.PureComponent {
|
|
|
72
75
|
React.createElement(Popup, { className: "components-iconpicker-popup", isOpen: this.state.showPopup, position: RelativePosition.BottomLeft, onClose: this._closePopup, target: this._target.current }, this.renderPopup(this.props.dropDownTitle))));
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
IconPickerButton.defaultProps = {
|
|
76
|
-
numColumns: 4,
|
|
77
|
-
};
|
|
78
78
|
//# sourceMappingURL=IconPickerButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconPickerButton.js","sourceRoot":"","sources":["../../../src/components-react/iconpicker/IconPickerButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAe5D;;GAEG;AACH,MAAM,QAAS,SAAQ,KAAK,CAAC,aAA4B;IACvD,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,MAAM;QACpB,MAAM,EACJ,OAAO,EACP,IAAI,EAAE,qCAAqC;QAC3C,GAAG,UAAU,EACd,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,MAAM,WAAW,GAAG,CAAC,EAAoB,EAAE,EAAE;YAC3C,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,UAAU,CAAC,wBAAwB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE3E,OAAO,CACL,mCACM,UAAU,EACd,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,WAAW;YAGpB,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,GAAI,CACjB,CACV,CAAC;IACJ,CAAC;CACF;AA+BD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK,CAAC,aAG3C;
|
|
1
|
+
{"version":3,"file":"IconPickerButton.js","sourceRoot":"","sources":["../../../src/components-react/iconpicker/IconPickerButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAe5D;;GAEG;AACH,MAAM,QAAS,SAAQ,KAAK,CAAC,aAA4B;IACvD,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,MAAM;QACpB,MAAM,EACJ,OAAO,EACP,IAAI,EAAE,qCAAqC;QAC3C,GAAG,UAAU,EACd,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,MAAM,WAAW,GAAG,CAAC,EAAoB,E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pC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GACzB;gBACF,8BAAM,SAAS,EAAC,MAAM;oBAEpB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,cAAc,OAAG,GAAI,CACjC,CACA;YAET,oBAAC,KAAK,IACJ,SAAS,EAAC,6BAA6B,EACvC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC5B,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAE3B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CACrC,CACP,CACJ,CAAC;IACJ,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 IconPicker\n */\n\nimport \"./IconPickerButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup } from \"@itwin/core-react\";\nimport { SvgChevronDown } from \"@itwin/itwinui-icons-react\";\n\n/** Properties for the [[IconItem]] React component\n * @internal\n */\ninterface IconItemProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CommonProps {\n /** icon specification */\n icon: string;\n /** function to run when user selects icon */\n onClick?: () => void;\n}\n\n/** IconItem Functional component\n * @internal\n */\nclass IconItem extends React.PureComponent<IconItemProps> {\n constructor(props: IconItemProps) {\n super(props);\n }\n\n public override render() {\n const {\n onClick,\n icon, // do not pass on item specific props\n ...otherProps\n } = this.props;\n\n const handleClick = (_e: React.MouseEvent) => {\n if (onClick) onClick();\n };\n\n const classes = classnames(\"components-icon-swatch\", this.props.className);\n\n return (\n <button\n {...otherProps}\n className={classes}\n style={this.props.style}\n onClick={handleClick}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={icon} />\n </button>\n );\n }\n}\n\n/** Properties for the [[IconPicker]] React component\n * @internal\n */\nexport interface IconPickerProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CommonProps {\n /** active string */\n icon: string;\n /** available icons */\n icons: string[];\n /** function to run when user selects icon */\n onIconChange?: ((icon: string) => void) | undefined;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** Title to show at top of DropDown */\n dropDownTitle?: string;\n /** Number of columns */\n numColumns: number;\n}\n\n/** @internal */\ninterface IconPickerState {\n showPopup: boolean;\n icon: string;\n}\n\n/** IconPickerButton component\n * @internal\n */\nexport class IconPickerButton extends React.PureComponent<\n IconPickerProps,\n IconPickerState\n> {\n private _target = React.createRef<HTMLButtonElement>();\n\n public static defaultProps: Partial<IconPickerProps> = {\n numColumns: 4,\n };\n\n constructor(props: IconPickerProps) {\n super(props);\n\n this.state = { showPopup: false, icon: this.props.icon };\n }\n\n private _togglePopup = () => {\n if (this.props.readonly) return;\n\n this.setState((prevState) => ({ showPopup: !prevState.showPopup }));\n };\n\n private _closePopup = () => {\n this.setState({ showPopup: false });\n };\n\n private _handleIconPicked = (icon: string) => {\n this.setState({ showPopup: false, icon }, () => {\n if (this.props.onIconChange) this.props.onIconChange(icon);\n });\n };\n\n private renderPopup(title: string | undefined) {\n const containerStyle: React.CSSProperties = {\n gridTemplateColumns: `repeat(${this.props.numColumns}, 1fr)`,\n };\n return (\n <div className=\"components-iconpicker-popup-container\">\n {title && <h4>{title}</h4>}\n <div\n data-testid=\"components-iconpicker-popup-icons\"\n className=\"components-iconpicker-popup-icons\"\n style={containerStyle}\n >\n {this.props.icons.map((icon: string, index: number) => (\n <IconItem\n key={index}\n icon={icon}\n onClick={this._handleIconPicked.bind(this, icon)}\n />\n ))}\n </div>\n </div>\n );\n }\n\n public override render() {\n const buttonStyle = { ...this.props.style } as React.CSSProperties;\n const buttonClassNames = classnames(\n \"components-iconpicker-button\",\n this.props.readonly && \"readonly\",\n this.props.className\n );\n\n return (\n <>\n <button\n data-testid=\"components-iconpicker-button\"\n onClick={this._togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={this.props.disabled}\n ref={this._target}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon\n className=\"iconpicker-button-sprite\"\n iconSpec={this.state.icon}\n />\n <span className=\"icon\">\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronDown />} />\n </span>\n </button>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Popup\n className=\"components-iconpicker-popup\"\n isOpen={this.state.showPopup}\n position={RelativePosition.BottomLeft}\n onClose={this._closePopup}\n target={this._target.current}\n >\n {this.renderPopup(this.props.dropDownTitle)}\n </Popup>\n </>\n );\n }\n}\n"]}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* @module PropertyEditors
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
|
+
import { Input } from "@itwin/itwinui-react";
|
|
5
6
|
import type { NumericValue } from "../values/Values.js";
|
|
6
7
|
/**
|
|
7
8
|
* Props for FormattedNumericInput component.
|
|
8
9
|
* @beta
|
|
9
10
|
*/
|
|
10
|
-
interface FormattedNumericInputProps {
|
|
11
|
+
interface FormattedNumericInputProps extends Pick<React.ComponentPropsWithoutRef<typeof Input>, "onBlur" | "onFocus"> {
|
|
11
12
|
value: NumericValue;
|
|
12
13
|
onChange: (value: NumericValue) => void;
|
|
13
14
|
parseValue: (value: string) => number | undefined;
|
|
@@ -19,6 +20,6 @@ interface FormattedNumericInputProps {
|
|
|
19
20
|
* A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
|
|
20
21
|
* @beta
|
|
21
22
|
*/
|
|
22
|
-
export declare function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }: FormattedNumericInputProps): React.JSX.Element;
|
|
23
|
+
export declare function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, ...props }: FormattedNumericInputProps): React.JSX.Element;
|
|
23
24
|
export {};
|
|
24
25
|
//# sourceMappingURL=FormattedNumericInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedNumericInput.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattedNumericInput.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,UAAU,0BACR,SAAQ,IAAI,CACV,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,EAC5C,QAAQ,GAAG,SAAS,CACrB;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAClD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,0BAA0B,qBAgB5B"}
|
|
@@ -11,7 +11,7 @@ import { Input } from "@itwin/itwinui-react";
|
|
|
11
11
|
* A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
|
|
12
12
|
* @beta
|
|
13
13
|
*/
|
|
14
|
-
export function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }) {
|
|
14
|
+
export function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, ...props }) {
|
|
15
15
|
const { currentValue, inputProps } = useParsedNumberInput({
|
|
16
16
|
initialValue: value.rawValue,
|
|
17
17
|
parseValue,
|
|
@@ -24,7 +24,7 @@ export function FormattedNumericInput({ onChange, value, parseValue, formatValue
|
|
|
24
24
|
React.useEffect(() => {
|
|
25
25
|
onChangeRef.current(currentValue);
|
|
26
26
|
}, [currentValue]);
|
|
27
|
-
return React.createElement(Input, { disabled: disabled, size: size
|
|
27
|
+
return React.createElement(Input, { ...props, ...inputProps, disabled: disabled, size: size });
|
|
28
28
|
}
|
|
29
29
|
function useParsedNumberInput({ initialValue, formatValue, parseValue, }) {
|
|
30
30
|
const [state, setState] = React.useState(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedNumericInput.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattedNumericInput.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,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C,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,YAAY,EACV,SAAS,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS;wBACpC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;wBACvC,CAAC,CAAC,EAAE;iBACT;gBACD,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;aACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAEtC,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,QAAQ;oBACR,YAAY,EAAE,QAAQ;iBACvB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,KAAK;QACzB,UAAU,EAAE;YACV,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY;YAC/B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,QAAQ,EAAE,YAAY;SACvB;KACF,CAAC;AACJ,CAAC;AAED,oBAAoB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { NumericValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Props for FormattedNumericInput component.\n * @beta\n */\ninterface FormattedNumericInputProps\n extends Pick<\n React.ComponentPropsWithoutRef<typeof Input>,\n \"onBlur\" | \"onFocus\"\n > {\n value: NumericValue;\n onChange: (value: NumericValue) => void;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n disabled?: boolean;\n size?: \"small\" | \"large\";\n}\n\n/**\n * A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.\n * @beta\n */\nexport function FormattedNumericInput({\n onChange,\n value,\n parseValue,\n formatValue,\n disabled,\n size,\n ...props\n}: FormattedNumericInputProps) {\n const { currentValue, inputProps } = useParsedNumberInput({\n initialValue: value.rawValue,\n parseValue,\n formatValue,\n });\n const onChangeRef = React.useRef(onChange);\n React.useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n React.useEffect(() => {\n onChangeRef.current(currentValue);\n }, [currentValue]);\n\n return <Input {...props} {...inputProps} disabled={disabled} size={size} />;\n}\n\nfunction useParsedNumberInput({\n initialValue,\n formatValue,\n parseValue,\n}: {\n initialValue: number | undefined;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n}) {\n interface State {\n value: NumericValue;\n placeholder: string;\n }\n\n const [state, setState] = React.useState<State>(() => {\n return {\n value: {\n rawValue: initialValue,\n displayValue:\n initialValue !== undefined ? formatValue(initialValue) : \"\",\n },\n placeholder: formatValue(initialValue ?? 123.45),\n };\n });\n\n React.useEffect(() => {\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n displayValue:\n prevState.value.rawValue !== undefined\n ? formatValue(prevState.value.rawValue)\n : \"\",\n },\n placeholder: formatValue(123.45),\n };\n });\n }, [formatValue]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n const rawValue = parseValue(newValue);\n\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n rawValue,\n displayValue: newValue,\n },\n };\n });\n };\n\n return {\n currentValue: state.value,\n inputProps: {\n value: state.value.displayValue,\n placeholder: state.placeholder,\n onChange: handleChange,\n },\n };\n}\n\n/* v8 ignore stop */\n"]}
|
|
@@ -23,13 +23,12 @@ export var PropertyContainerType;
|
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
25
|
export class PropertyValueRendererManager {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
26
|
+
static _defaultRendererManager;
|
|
27
|
+
_propertyRenderers = new Map();
|
|
28
|
+
_defaultPrimitiveValueRenderer = new PrimitivePropertyValueRenderer();
|
|
29
|
+
_defaultArrayValueRenderer = new ArrayPropertyValueRenderer();
|
|
30
|
+
_defaultStructValueRenderer = new StructPropertyValueRenderer();
|
|
31
|
+
_defaultMergedValueRenderer = new MergedPropertyValueRenderer();
|
|
33
32
|
getCustomRenderer(record) {
|
|
34
33
|
if (record.property.renderer &&
|
|
35
34
|
this._propertyRenderers.has(record.property.renderer.name))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValueRendererManager.js","sourceRoot":"","sources":["../../../src/components-react/properties/ValueRendererManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F;;GAEG;AACH,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sCAAa,CAAA;AACf,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC;AA8DD;;GAEG;AACH,MAAM,OAAO,4BAA4B;
|
|
1
|
+
{"version":3,"file":"ValueRendererManager.js","sourceRoot":"","sources":["../../../src/components-react/properties/ValueRendererManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F;;GAEG;AACH,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sCAAa,CAAA;AACf,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC;AA8DD;;GAEG;AACH,MAAM,OAAO,4BAA4B;IAC/B,MAAM,CAAC,uBAAuB,CAA+B;IAE3D,kBAAkB,GAAwC,IAAI,GAAG,EAGxE,CAAC;IACM,8BAA8B,GACtC,IAAI,8BAA8B,EAAE,CAAC;IAC7B,0BAA0B,GAClC,IAAI,0BAA0B,EAAE,CAAC;IACzB,2BAA2B,GACnC,IAAI,2BAA2B,EAAE,CAAC;IAC1B,2BAA2B,GACnC,IAAI,2BAA2B,EAAE,CAAC;IAE5B,iBAAiB,CAAC,MAAsB;QAC9C,IACE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YACxB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;YAE1D,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEpE,IAAI,IAAI,CA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B,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,MAAM,KAAK,CACT,8DAA8D,YAAY,4BAA4B,gBAAgB,CAAC,WAAW,CAAC,IAAI,GAAG,CAC3I,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAED,oDAAoD;IAC7C,kBAAkB,CAAC,YAAoB;QAC5C,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,wDAAwD;IACjD,qBAAqB,CAAC,YAAoB;QAC/C,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IAED,0FAA0F;IACnF,iBAAiB,CAAC,MAAsB;QAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACtD,OAAO,CAAC,CAAC,CAAC,cAAc,IAAI,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,4DAA4D;IACrD,MAAM,KAAK,cAAc;QAC9B,IAAI,CAAC,IAAI,CAAC,uBAAuB;YAC/B,IAAI,CAAC,uBAAuB,GAAG,IAAI,4BAA4B,EAAE,CAAC;QAEpE,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,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 Properties\n */\n\nimport type * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ArrayPropertyValueRenderer } from \"./renderers/value/ArrayPropertyValueRenderer.js\";\nimport { MergedPropertyValueRenderer } from \"./renderers/value/MergedPropertyValueRenderer.js\";\nimport { PrimitivePropertyValueRenderer } from \"./renderers/value/PrimitivePropertyValueRenderer.js\";\nimport { StructPropertyValueRenderer } from \"./renderers/value/StructPropertyValueRenderer.js\";\nimport type { Orientation } from \"../common/Orientation.js\";\n\n/** Types of property containers\n * @public\n */\nexport enum PropertyContainerType {\n PropertyPane = \"pane\",\n Table = \"table\",\n Tree = \"tree\",\n}\n\n/** State of the Dialog component in a container which renders properties\n * @public\n */\nexport interface PropertyDialogState {\n title: string;\n content: React.ReactNode;\n}\n\n/** State of the Popup component in a container which renders properties\n * @public\n */\nexport interface PropertyPopupState {\n fixedPosition: { top: number; left: number };\n content: React.ReactNode;\n}\n\n/** Additional parameters to the renderer\n * @public\n */\nexport interface PropertyValueRendererContext {\n /** Type of container that holds the property */\n containerType?: string;\n /** Style that should be applied to the rendered element */\n style?: React.CSSProperties;\n /** Orientation of property/container */\n orientation?: Orientation;\n /** Callback to request for a Popup to be shown. */\n onPopupShow?: (popupState: PropertyPopupState) => void;\n /** Callback to request for a Popup to be hidden. */\n onPopupHide?: () => void;\n /** Callback to request for Dialog to be opened. */\n onDialogOpen?: (dialogState: PropertyDialogState) => void;\n /** Callback to highlight text */\n textHighlighter?: (text: string) => React.ReactNode;\n /** Default value to show if value rendering is asynchronous */\n defaultValue?: React.ReactNode;\n /** Whether property value is expanded. */\n isExpanded?: boolean;\n /** Called when property value expansion or collapse is requested. */\n onExpansionToggled?: () => void;\n /** Called when property value element height changes. */\n onHeightChanged?: (newHeight: number) => void;\n}\n\n/** Custom property value renderer interface\n * @public\n */\nexport interface IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n canRender: (\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) => boolean;\n /** Method that returns a JSX representation of PropertyRecord */\n render: (\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) => React.ReactNode;\n}\n\n/** Default implementation of property value renderer manager\n * @public\n */\nexport class PropertyValueRendererManager {\n private static _defaultRendererManager: PropertyValueRendererManager;\n\n protected _propertyRenderers: Map<string, IPropertyValueRenderer> = new Map<\n string,\n IPropertyValueRenderer\n >();\n protected _defaultPrimitiveValueRenderer: IPropertyValueRenderer =\n new PrimitivePropertyValueRenderer();\n protected _defaultArrayValueRenderer: IPropertyValueRenderer =\n new ArrayPropertyValueRenderer();\n protected _defaultStructValueRenderer: IPropertyValueRenderer =\n new StructPropertyValueRenderer();\n protected _defaultMergedValueRenderer: IPropertyValueRenderer =\n new MergedPropertyValueRenderer();\n\n private getCustomRenderer(record: PropertyRecord) {\n if (\n record.property.renderer &&\n this._propertyRenderers.has(record.property.renderer.name)\n )\n return this._propertyRenderers.get(record.property.renderer.name);\n\n if (this._defaultMergedValueRenderer.canRender(record))\n return this._defaultMergedValueRenderer;\n\n if (this._propertyRenderers.has(record.property.typename))\n return this._propertyRenderers.get(record.property.typename)!;\n\n return undefined;\n }\n\n private selectRenderer(record: PropertyRecord) {\n const customRenderer = this.getCustomRenderer(record);\n if (customRenderer) return customRenderer;\n\n // Use one of default renderers\n switch (record.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return this._defaultPrimitiveValueRenderer;\n case PropertyValueFormat.Array:\n return this._defaultArrayValueRenderer;\n case PropertyValueFormat.Struct:\n return this._defaultStructValueRenderer;\n default:\n return undefined;\n }\n }\n\n /** Render property into JSX element */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ): React.ReactNode {\n const selectedRenderer = this.selectRenderer(record);\n\n if (!selectedRenderer || !selectedRenderer.canRender(record, context))\n return undefined;\n\n return selectedRenderer.render(record, context);\n }\n\n /** Register a specified property type renderer */\n public registerRenderer(\n rendererType: string,\n propertyRenderer: IPropertyValueRenderer,\n overwrite = false\n ) {\n if (!overwrite && this._propertyRenderers.has(rendererType)) {\n throw Error(\n `PropertyValueRendererManager.registerRenderer error: type '${rendererType}' already registered to '${propertyRenderer.constructor.name}'`\n );\n }\n\n this._propertyRenderers.set(rendererType, propertyRenderer);\n }\n\n /** Unregister a specified property type renderer */\n public unregisterRenderer(rendererType: string) {\n this._propertyRenderers.delete(rendererType);\n }\n\n /** Get the specified property type renderer instance */\n public getRegisteredRenderer(rendererType: string) {\n return this._propertyRenderers.get(rendererType);\n }\n\n /** Check whether a property record has a custom renderer registered that can render it */\n public hasCustomRenderer(record: PropertyRecord): boolean {\n const customRenderer = this.getCustomRenderer(record);\n return !!(customRenderer && customRenderer.canRender(record));\n }\n\n /** Returns default PropertyValueRendererManager instance */\n public static get defaultManager() {\n if (!this._defaultRendererManager)\n this._defaultRendererManager = new PropertyValueRendererManager();\n\n return this._defaultRendererManager;\n }\n}\n"]}
|
|
@@ -16,26 +16,19 @@ import { PropertyView } from "./PropertyView.js";
|
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
18
|
export class NonPrimitivePropertyRenderer extends React.Component {
|
|
19
|
+
state = {
|
|
20
|
+
/** If it's not collapsible, that means it's expanded by default and can't be collapsed */
|
|
21
|
+
isExpanded: !this.props.isCollapsible || this.props.propertyRecord.autoExpand,
|
|
22
|
+
};
|
|
19
23
|
constructor(props) {
|
|
20
24
|
super(props);
|
|
21
|
-
this.state = {
|
|
22
|
-
/** If it's not collapsible, that means it's expanded by default and can't be collapsed */
|
|
23
|
-
isExpanded: !this.props.isCollapsible || this.props.propertyRecord.autoExpand,
|
|
24
|
-
};
|
|
25
|
-
this._onExpanded = () => {
|
|
26
|
-
this.setState({ isExpanded: true });
|
|
27
|
-
};
|
|
28
|
-
this._onCollapsed = () => {
|
|
29
|
-
this.setState({ isExpanded: false });
|
|
30
|
-
};
|
|
31
|
-
this._renderPropertyForItem = (item) => {
|
|
32
|
-
const prefix = this.props.uniqueKey
|
|
33
|
-
? this.props.uniqueKey
|
|
34
|
-
: this.props.propertyRecord.property.name;
|
|
35
|
-
const uniqueKey = `${prefix}_${item.property.name}`;
|
|
36
|
-
return (React.createElement(PropertyRenderer, { key: uniqueKey, uniqueKey: uniqueKey, propertyRecord: item, indentation: this.props.indentation ? this.props.indentation + 1 : 1, orientation: this.props.orientation, columnRatio: this.props.columnRatio, actionButtonRenderers: this.props.actionButtonRenderers, onColumnRatioChanged: this.props.onColumnRatioChanged, width: this.props.width, isResizeHandleHovered: this.props.isResizeHandleHovered, onResizeHandleHoverChanged: this.props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: this.props.isResizeHandleBeingDragged, onResizeHandleDragChanged: this.props.onResizeHandleDragChanged, columnInfo: this.props.columnInfo }));
|
|
37
|
-
};
|
|
38
25
|
}
|
|
26
|
+
_onExpanded = () => {
|
|
27
|
+
this.setState({ isExpanded: true });
|
|
28
|
+
};
|
|
29
|
+
_onCollapsed = () => {
|
|
30
|
+
this.setState({ isExpanded: false });
|
|
31
|
+
};
|
|
39
32
|
getLabel(props, state) {
|
|
40
33
|
const { orientation, indentation, width, columnRatio, columnInfo } = props;
|
|
41
34
|
const minLabelWidth = columnInfo?.minLabelWidth;
|
|
@@ -54,6 +47,13 @@ export class NonPrimitivePropertyRenderer extends React.Component {
|
|
|
54
47
|
});
|
|
55
48
|
return modifiedProperties;
|
|
56
49
|
}
|
|
50
|
+
_renderPropertyForItem = (item) => {
|
|
51
|
+
const prefix = this.props.uniqueKey
|
|
52
|
+
? this.props.uniqueKey
|
|
53
|
+
: this.props.propertyRecord.property.name;
|
|
54
|
+
const uniqueKey = `${prefix}_${item.property.name}`;
|
|
55
|
+
return (React.createElement(PropertyRenderer, { key: uniqueKey, uniqueKey: uniqueKey, propertyRecord: item, indentation: this.props.indentation ? this.props.indentation + 1 : 1, orientation: this.props.orientation, columnRatio: this.props.columnRatio, actionButtonRenderers: this.props.actionButtonRenderers, onColumnRatioChanged: this.props.onColumnRatioChanged, width: this.props.width, isResizeHandleHovered: this.props.isResizeHandleHovered, onResizeHandleHoverChanged: this.props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: this.props.isResizeHandleBeingDragged, onResizeHandleDragChanged: this.props.onResizeHandleDragChanged, columnInfo: this.props.columnInfo }));
|
|
56
|
+
};
|
|
57
57
|
render() {
|
|
58
58
|
let items = this.props.propertyRecord.getChildrenRecords();
|
|
59
59
|
if (this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonPrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/NonPrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qCAAqC,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiBjD;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK,CAAC,SAGvD;
|
|
1
|
+
{"version":3,"file":"NonPrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/NonPrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qCAAqC,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiBjD;;GAEG;AACH,MAAM,OAAO,4BA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CAAC,qBAAqB,EACvD,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB,EACrD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB,EACvD,0BAA0B,EAAE,IAAI,CAAC,KAAK,CAAC,0BAA0B,EACjE,0BAA0B,EAAE,IAAI,CAAC,KAAK,CAAC,0BAA0B,EACjE,yBAAyB,EAAE,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAC/D,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GACjC,CACH,CAAC;IACJ,CAAC,CAAC;IAEc,MAAM;QACpB,IAAI,KAAK,GACP,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC;QACjD,IACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,KAAK;YAEzE,KAAK,GAAG,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAEjD,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,OAAO,CACL;YACG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAC1B,oBAAC,YAAY,IACX,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAC/C,KAAK,GACT,CACH,CAAC,CAAC,CAAC,SAAS;YAEZ,IAAI,CAAC,KAAK,CAAC,UAAU;gBACpB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC;gBACxC,CAAC,CAAC,SAAS,CACZ,CACJ,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/** @packageDocumentation\n * @module Properties\n */\n\nimport \"./NonPrimitivePropertyRenderer.scss\";\nimport * as React from \"react\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer.js\";\nimport { NonPrimitivePropertyLabelRenderer } from \"./label/NonPrimitivePropertyLabelRenderer.js\";\nimport type { PrimitiveRendererProps } from \"./PrimitivePropertyRenderer.js\";\nimport { PropertyRenderer } from \"./PropertyRenderer.js\";\nimport { PropertyView } from \"./PropertyView.js\";\n\n/** Properties of [[NonPrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface NonPrimitivePropertyRendererProps\n extends PrimitiveRendererProps {\n /** Can struct/array property be collapsed */\n isCollapsible?: boolean;\n}\n\n/** State of [[NonPrimitivePropertyRenderer]] React component. */\ninterface NonPrimitivePropertyRendererState {\n /** Is struct/array property expanded */\n isExpanded?: boolean;\n}\n\n/** React Component that renders struct and array properties\n * @public\n */\nexport class NonPrimitivePropertyRenderer extends React.Component<\n NonPrimitivePropertyRendererProps,\n NonPrimitivePropertyRendererState\n> {\n public override readonly state: NonPrimitivePropertyRendererState = {\n /** If it's not collapsible, that means it's expanded by default and can't be collapsed */\n isExpanded:\n !this.props.isCollapsible || this.props.propertyRecord.autoExpand,\n };\n\n constructor(props: NonPrimitivePropertyRendererProps) {\n super(props);\n }\n\n private _onExpanded = () => {\n this.setState({ isExpanded: true });\n };\n\n private _onCollapsed = () => {\n this.setState({ isExpanded: false });\n };\n\n private getLabel(\n props: NonPrimitivePropertyRendererProps,\n state: NonPrimitivePropertyRendererState\n ): React.ReactNode {\n const { orientation, indentation, width, columnRatio, columnInfo } = props;\n const minLabelWidth = columnInfo?.minLabelWidth;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minLabelWidth\n );\n\n let displayLabel = props.propertyRecord.property.displayLabel;\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n displayLabel = `${displayLabel} (${this.props.propertyRecord.value.items.length})`;\n\n return (\n <NonPrimitivePropertyLabelRenderer\n isExpanded={!!state.isExpanded}\n onExpand={this._onExpanded}\n onCollapse={this._onCollapsed}\n offset={offset}\n renderColon={false}\n >\n {displayLabel}\n </NonPrimitivePropertyLabelRenderer>\n );\n }\n\n private overrideArrayChildrenNames(items: PropertyRecord[]) {\n const modifiedProperties: PropertyRecord[] = items.map(\n (item, index): PropertyRecord => {\n const newProperty = { ...item.property };\n newProperty.displayLabel = `[${index + 1}]`;\n newProperty.name = `${newProperty.name}_${index}`;\n return new PropertyRecord(item.value, newProperty);\n }\n );\n\n return modifiedProperties;\n }\n\n private _renderPropertyForItem = (item: PropertyRecord) => {\n const prefix = this.props.uniqueKey\n ? this.props.uniqueKey\n : this.props.propertyRecord.property.name;\n const uniqueKey = `${prefix}_${item.property.name}`;\n return (\n <PropertyRenderer\n key={uniqueKey}\n uniqueKey={uniqueKey}\n propertyRecord={item}\n indentation={this.props.indentation ? this.props.indentation + 1 : 1}\n orientation={this.props.orientation}\n columnRatio={this.props.columnRatio}\n actionButtonRenderers={this.props.actionButtonRenderers}\n onColumnRatioChanged={this.props.onColumnRatioChanged}\n width={this.props.width}\n isResizeHandleHovered={this.props.isResizeHandleHovered}\n onResizeHandleHoverChanged={this.props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={this.props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={this.props.onResizeHandleDragChanged}\n columnInfo={this.props.columnInfo}\n />\n );\n };\n\n public override render() {\n let items: PropertyRecord[] =\n this.props.propertyRecord.getChildrenRecords();\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n items = this.overrideArrayChildrenNames(items);\n\n const { indentation, ...props } = this.props;\n return (\n <>\n {this.props.isCollapsible ? (\n <PropertyView\n labelElement={this.getLabel(this.props, this.state)}\n {...props}\n />\n ) : undefined}\n\n {this.state.isExpanded\n ? items.map(this._renderPropertyForItem)\n : undefined}\n </>\n );\n }\n}\n"]}
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
import { Orientation } from "../../common/Orientation.js";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export class PropertyGridColumnStyleProvider {
|
|
11
|
+
_minLabelWidth = 0;
|
|
12
|
+
_minValueWidth = 0;
|
|
13
|
+
_actionButtonWidth = 0;
|
|
14
|
+
_isMinimumColumnSizeEnabled;
|
|
11
15
|
constructor(columnInfo) {
|
|
12
|
-
this._minLabelWidth = 0;
|
|
13
|
-
this._minValueWidth = 0;
|
|
14
|
-
this._actionButtonWidth = 0;
|
|
15
16
|
if (!columnInfo) {
|
|
16
17
|
this._isMinimumColumnSizeEnabled = false;
|
|
17
18
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGridColumns.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyGridColumns.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAU1D,gBAAgB;AAChB,MAAM,OAAO,+BAA+B;
|
|
1
|
+
{"version":3,"file":"PropertyGridColumns.js","sourceRoot":"","sources":["../../../../src/components-react/properties/renderers/PropertyGridColumns.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAU1D,gBAAgB;AAChB,MAAM,OAAO,+BAA+B;IAClC,cAAc,GAAW,CAAC,CAAC;IAC3B,cAAc,GAAW,CAAC,CAAC;IAC3B,kBAAkB,GAAW,CAAC,CAAC;IAC/B,2BAA2B,CAAU;IAE7C,YAAmB,UAA8C;QAC/D,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC;YACzC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,U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AAa,EACb,oBAA6B;QAE7B,MAAM,eAAe,GAAG,oBAAoB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAClE,MAAM,kBAAkB,GAAG,iBAAiB;YAC1C,CAAC,CAAC,IAAI,CAAC,iBAAiB;gBACtB,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,IAAI;gBAC/B,CAAC,CAAC,MAAM;YACV,CAAC,CAAC,SAAS,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,0BAA0B;YAClC,OAAO,IAAI,CAAC,kBAAkB,CAAC;gBAC7B,GAAG,KAAK,GAAG,GAAG,GAAG;gBACjB,eAAe;gBACf,MAAM;gBACN,kBAAkB;aACnB,CAAC,CAAC;QAEL,MAAM,WAAW,GAAG,UAAU,IAAI,CAAC,aAAa,OAAO,KAAK,GAAG,GAAG,IAAI,CAAC;QACvE,MAAM,WAAW,GAAG,UAAU,IAAI,CAAC,aAAa,UAAU,CAAC;QAE3D,OAAO,IAAI,CAAC,kBAAkB,CAAC;YAC7B,WAAW;YACX,eAAe;YACf,WAAW;YACX,kBAAkB;SACnB,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,iBAA0B;QACjD,OAAO,IAAI,CAAC,kBAAkB,CAAC;YAC7B,MAAM;YACN,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACvC,CAAC,CAAC;IACL,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 Properties\n */\n\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** @internal */\nexport interface PropertyGridColumnInfo {\n minLabelWidth: number;\n minValueWidth: number;\n actionButtonWidth: number;\n isMinimumColumnSizeEnabled: boolean;\n}\n\n/** @internal */\nexport class PropertyGridColumnStyleProvider {\n private _minLabelWidth: number = 0;\n private _minValueWidth: number = 0;\n private _actionButtonWidth: number = 0;\n private _isMinimumColumnSizeEnabled: boolean;\n\n public constructor(columnInfo: PropertyGridColumnInfo | undefined) {\n if (!columnInfo) {\n this._isMinimumColumnSizeEnabled = false;\n return;\n }\n\n this._minLabelWidth = columnInfo.minLabelWidth;\n this._minValueWidth = columnInfo.minValueWidth;\n this._actionButtonWidth = columnInfo.actionButtonWidth;\n this._isMinimumColumnSizeEnabled = columnInfo.isMinimumColumnSizeEnabled;\n }\n\n public get minLabelWidth() {\n return this._minLabelWidth;\n }\n\n public get minValueWidth() {\n return this._minValueWidth;\n }\n\n public get actionButtonWidth() {\n return this._actionButtonWidth;\n }\n\n public get isMinimumColumnSizeEnabled() {\n return this._isMinimumColumnSizeEnabled;\n }\n\n public getStyle(\n orientation: Orientation,\n needActionButtons: boolean,\n ratio: number,\n needElementSeparator: boolean\n ): React.CSSProperties {\n switch (orientation) {\n case Orientation.Horizontal:\n return this.getHorizontalStyle(\n needActionButtons,\n ratio,\n needElementSeparator\n );\n case Orientation.Vertical:\n return this.getVerticalStyle(needActionButtons);\n\n default:\n const unhandledOrientationType: never = orientation; // Compile time check that all cases handled\n throw new Error(\n `Unhandled orientation type: ${String(\n unhandledOrientationType\n )}. Was new orientation added ? `\n );\n }\n }\n\n /** Join columns together in sequence, filtering out undefined column definitions */\n private columnStyleBuilder(\n columns: Array<string | undefined>\n ): React.CSSProperties {\n columns = columns.filter((el) => el !== undefined);\n return { gridTemplateColumns: columns.join(\" \") };\n }\n\n private getHorizontalStyle(\n needActionButtons: boolean,\n ratio: number,\n needElementSeparator: boolean\n ): React.CSSProperties {\n const separatorColumn = needElementSeparator ? \"auto\" : undefined;\n const actionButtonColumn = needActionButtons\n ? this.actionButtonWidth\n ? `${this.actionButtonWidth}px`\n : \"auto\"\n : undefined;\n if (!this.isMinimumColumnSizeEnabled)\n return this.columnStyleBuilder([\n `${ratio * 100}%`,\n separatorColumn,\n \"auto\",\n actionButtonColumn,\n ]);\n\n const labelColumn = `minmax(${this.minLabelWidth}px, ${ratio * 100}%)`;\n const valueColumn = `minmax(${this.minValueWidth}px, 1fr)`;\n\n return this.columnStyleBuilder([\n labelColumn,\n separatorColumn,\n valueColumn,\n actionButtonColumn,\n ]);\n }\n\n private getVerticalStyle(needActionButtons: boolean): React.CSSProperties {\n return this.columnStyleBuilder([\n \"auto\",\n needActionButtons ? \"auto\" : undefined,\n ]);\n }\n}\n"]}
|