@itwin/components-react 3.2.0-dev.19 → 3.2.0-dev.22
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/lib/cjs/components-react/common/showhide/ShowHideDialog.d.ts +4 -4
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.d.ts.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.js +3 -2
- package/lib/cjs/components-react/common/showhide/ShowHideDialog.js.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideItem.d.ts +3 -3
- package/lib/cjs/components-react/common/showhide/ShowHideItem.d.ts.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideItem.js.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.d.ts.map +1 -1
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.js +2 -1
- package/lib/cjs/components-react/common/showhide/ShowHideMenu.js.map +1 -1
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -1
- package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/cjs/components-react/toolbar/ItemWrapper.d.ts +1 -1
- package/lib/cjs/components-react/toolbar/ItemWrapper.d.ts.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideDialog.d.ts +4 -4
- package/lib/esm/components-react/common/showhide/ShowHideDialog.d.ts.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideDialog.js +3 -2
- package/lib/esm/components-react/common/showhide/ShowHideDialog.js.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideItem.d.ts +3 -3
- package/lib/esm/components-react/common/showhide/ShowHideItem.d.ts.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideItem.js.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
- package/lib/esm/components-react/common/showhide/ShowHideMenu.d.ts.map +1 -1
- package/lib/esm/components-react/common/showhide/ShowHideMenu.js +2 -1
- package/lib/esm/components-react/common/showhide/ShowHideMenu.js.map +1 -1
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +1 -1
- package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/esm/components-react/toolbar/ItemWrapper.d.ts +1 -1
- package/lib/esm/components-react/toolbar/ItemWrapper.d.ts.map +1 -1
- package/package.json +12 -13
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { GlobalDialogProps } from "@itwin/core-react";
|
|
6
6
|
import { ShowHideID, ShowHideItem } from "./ShowHideItem";
|
|
7
|
-
/** Properties for the [[ShowHideDialog]] component
|
|
8
|
-
* @public
|
|
7
|
+
/** Properties for the [[ShowHideDialog]] component used in the [[Table]] to show/hide columns.
|
|
8
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
9
9
|
*/
|
|
10
10
|
export interface ShowHideDialogProps<T extends ShowHideID> extends GlobalDialogProps {
|
|
11
11
|
/** key-label pair list for id's to be shown/hidden, and an accompanying label. */
|
|
@@ -20,8 +20,8 @@ interface ShowHideDialogState<T extends ShowHideID> {
|
|
|
20
20
|
hiddenColumns: T[];
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* [Dialog]($core-react) Component used to toggle show/hide
|
|
24
|
-
* @public
|
|
23
|
+
* [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.
|
|
24
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
25
25
|
*/
|
|
26
26
|
export declare class ShowHideDialog<T extends ShowHideID> extends React.PureComponent<ShowHideDialogProps<T>, ShowHideDialogState<T>> {
|
|
27
27
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideDialog.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideDialog.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAgB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI1D;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,iBAAiB;IAClF,kFAAkF;IAClF,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,gCAAgC;IAChC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;IACpB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,SAAS,CAAC;CACvD;AAED,gBAAgB;AAChB,UAAU,mBAAmB,CAAC,CAAC,SAAS,UAAU;IAChD,aAAa,EAAE,CAAC,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC3H,gBAAgB;IAChB,SAAyB,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;gBAC3C,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAOzC,gBAAgB;IACA,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAMnE,OAAO,CAAC,WAAW,CAKjB;IAEF,OAAO,CAAC,KAAK,CAOX;IAEF,OAAO,CAAC,KAAK,CASX;IAEF,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CAiC1C"}
|
|
@@ -27,14 +27,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ShowHideDialog = void 0;
|
|
30
|
+
/* eslint-disable deprecation/deprecation */
|
|
30
31
|
const React = __importStar(require("react"));
|
|
31
32
|
const core_react_1 = require("@itwin/core-react");
|
|
32
33
|
const UiComponents_1 = require("../../UiComponents");
|
|
33
34
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
34
35
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
35
36
|
/**
|
|
36
|
-
* [Dialog]($core-react) Component used to toggle show/hide
|
|
37
|
-
* @public
|
|
37
|
+
* [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.
|
|
38
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
38
39
|
*/
|
|
39
40
|
class ShowHideDialog extends React.PureComponent {
|
|
40
41
|
constructor(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideDialog.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAAoE;AACpE,qDAAkD;AAElD,0DAAyD;AACzD,wDAAgD;AAmBhD;;;GAGG;AACH,MAAa,cAAqC,SAAQ,KAAK,CAAC,aAA6D;IAG3H,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAaP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;gBAEjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;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,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,GAAI;gBAChG,+BAAO,OAAO,EAAE,EAAE,IAAG,KAAK,CAAS,CAC/B,CACP,CAAC;QACJ,CAAC,CAAC,CACW,CAChB,CAAC;IACJ,CAAC;CACF;AA9ED,wCA8EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { GlobalDialog, GlobalDialogProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideDialog]] component
|
|
1
|
+
{"version":3,"file":"ShowHideDialog.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAA4C;AAE5C,6CAA+B;AAC/B,kDAAoE;AACpE,qDAAkD;AAElD,0DAAyD;AACzD,wDAAgD;AAmBhD;;;GAGG;AACH,MAAa,cAAqC,SAAQ,KAAK,CAAC,aAA6D;IAG3H,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAaP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;gBAEjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,CAA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AE,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,GAAI;gBAChG,+BAAO,OAAO,EAAE,EAAE,IAAG,KAAK,CAAS,CAC/B,CACP,CAAC;QACJ,CAAC,CAAC,CACW,CAChB,CAAC;IACJ,CAAC;CACF;AA9ED,wCA8EC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nimport * as React from \"react\";\r\nimport { GlobalDialog, GlobalDialogProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideDialog]] component used in the [[Table]] to show/hide columns.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideDialogProps<T extends ShowHideID> extends GlobalDialogProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideDialogState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n}\r\n\r\n/**\r\n * [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport class ShowHideDialog<T extends ShowHideID> extends React.PureComponent<ShowHideDialogProps<T>, ShowHideDialogState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideDialogState<T>;\r\n constructor(props: ShowHideDialogProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideDialogProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { opened, items, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalDialog\r\n opened={opened}\r\n resizable={true}\r\n movable={true}\r\n modal={false}\r\n minWidth={300}\r\n minHeight={250}\r\n width={300}\r\n onClose={onClose}\r\n onEscape={onClose}\r\n onOutsideClick={onClose}\r\n buttonCluster={onClose && [{ onClick: onClose, type: DialogButtonType.Close }]}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => {\r\n this._toggleItem(item);\r\n };\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-dialog-input-${index}`;\r\n return (\r\n <div key={index}>\r\n <Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} onClick={sel} />\r\n <label htmlFor={id}>{label}</label>\r\n </div>\r\n );\r\n })}\r\n </GlobalDialog>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Common
|
|
3
3
|
*/
|
|
4
|
-
/** Interface for ShowHide items
|
|
5
|
-
* @public
|
|
4
|
+
/** Interface for ShowHide items used to show/hide [[Table]] columns.
|
|
5
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
6
6
|
*/
|
|
7
7
|
export interface ShowHideItem<T extends ShowHideID> {
|
|
8
8
|
id: T;
|
|
9
9
|
label: string;
|
|
10
10
|
}
|
|
11
11
|
/** Union type for all possible ShowHide IDs
|
|
12
|
-
* @public
|
|
12
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
13
13
|
*/
|
|
14
14
|
export declare type ShowHideID = string | number | symbol;
|
|
15
15
|
//# sourceMappingURL=ShowHideItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideItem.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideItem.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,UAAU;IAChD,EAAE,EAAE,CAAC,CAAC;IACN,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideItem.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/** Interface for ShowHide items
|
|
1
|
+
{"version":3,"file":"ShowHideItem.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Interface for ShowHide items used to show/hide [[Table]] columns.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideItem<T extends ShowHideID> {\r\n id: T;\r\n label: string;\r\n}\r\n\r\n/** Union type for all possible ShowHide IDs\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport type ShowHideID = string | number | symbol;\r\n"]}
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import { GlobalContextMenuProps } from "@itwin/core-react";
|
|
6
6
|
import { ShowHideID, ShowHideItem } from "./ShowHideItem";
|
|
7
7
|
/** Properties for the [[ShowHideMenu]] component
|
|
8
|
-
* @public
|
|
8
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
9
9
|
*/
|
|
10
10
|
export interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {
|
|
11
11
|
/** key-label pair list for id's to be shown/hidden, and an accompanying label. */
|
|
@@ -31,7 +31,7 @@ interface ShowHideMenuState<T extends ShowHideID> {
|
|
|
31
31
|
/**
|
|
32
32
|
* [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.
|
|
33
33
|
* Component includes a "list" button that displays a dialog with the same checkboxes.
|
|
34
|
-
* @public
|
|
34
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
35
35
|
*/
|
|
36
36
|
export declare class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {
|
|
37
37
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA0D,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGnH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG1D;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,sBAAsB;IACrF,kFAAkF;IAClF,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;IACpB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,SAAS,CAAC;CACvD;AAED,gBAAgB;AAChB,UAAU,iBAAiB,CAAC,CAAC,SAAS,UAAU;IAC9C,aAAa,EAAE,CAAC,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACrH,gBAAgB;IAChB,SAAyB,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAErD,gBAAgB;gBACJ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAQvC,gBAAgB;IACA,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAMjE,OAAO,CAAC,WAAW,CAOjB;IAEF,OAAO,CAAC,KAAK,CAOX;IAEF,OAAO,CAAC,KAAK,CASX;IAEF,OAAO,CAAC,QAAQ,CAQd;IACF,OAAO,CAAC,WAAW,CAMjB;IAEF,OAAO,CAAC,YAAY,CAIlB;IAEF,OAAO,CAAC,mBAAmB,CAEzB;IAEF,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CAuC1C"}
|
|
@@ -27,6 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ShowHideMenu = void 0;
|
|
30
|
+
/* eslint-disable deprecation/deprecation */
|
|
30
31
|
const React = __importStar(require("react"));
|
|
31
32
|
const core_react_1 = require("@itwin/core-react");
|
|
32
33
|
const UiComponents_1 = require("../../UiComponents");
|
|
@@ -35,7 +36,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
35
36
|
/**
|
|
36
37
|
* [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.
|
|
37
38
|
* Component includes a "list" button that displays a dialog with the same checkboxes.
|
|
38
|
-
* @public
|
|
39
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
39
40
|
*/
|
|
40
41
|
class ShowHideMenu extends React.PureComponent {
|
|
41
42
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideMenu.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAAmH;AACnH,qDAAkD;AAClD,qDAAkD;AAElD,wDAAgD;AA4BhD;;;;GAIG;AACH,MAAa,YAAmC,SAAQ,KAAK,CAAC,aAAyD;IAIrH,gBAAgB;IAChB,YAAY,KAA2B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAcP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;gBAEjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO;gBACpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC;QAEM,UAAK,GAAG,CAAC,IAAqB,EAAE,EAAE;YACxC,IAAI,CAAC,QAAQ,CACX,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,GAAG,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EACzE,GAAG,EAAE;gBACH,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB;oBAC7B,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,K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GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,2BAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;gBACvE,MAAM,EAAE,GAAG,wBAAwB,KAAK,EAAE,CAAC;gBAC3C,OAAO,CACL,oBAAC,4BAAe,IAAC,GAAG,EAAE,KAAK,EACzB,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,oBAAC,wBAAQ,mBAAc,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,GAAI,IACvF,KAAK,CACU,CACnB,CAAC;YACJ,CAAC,CAAC;YACF,oBAAC,+BAAkB,OAAG;YACtB,oBAAC,4BAAe,IAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBAAE,6CAAkB,mBAAmB,IAAE,2BAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAQ,CAAkB;YACrJ,oBAAC,4BAAe,IAAC,QAAQ,EAAE,IAAI,CAAC,WAAW;gBAAE,6CAAkB,gBAAgB,IAAE,2BAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAQ,CAAkB;YAClJ,oBAAC,+BAAc,IACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,2BAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAC/C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EACvC,gBAAgB,EAAE,gBAAgB,GAAI,CACtB,CACrB,CAAC;IACJ,CAAC;CACF;AApHD,oCAoHC;AAED,wBAAwB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { ContextMenuDivider, ContextMenuItem, GlobalContextMenu, GlobalContextMenuProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideDialog } from \"./ShowHideDialog\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideMenu]] component\r\n * @public\r\n */\r\nexport interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** X position to place menu */\r\n x: number;\r\n /** Y position to place menu */\r\n y: number;\r\n /** Whether dialog is opened or closed */\r\n opened: boolean;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when close button is clicked */\r\n onClose?: () => void;\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideMenuState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n dialogOpened: boolean;\r\n}\r\n\r\n/**\r\n * [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.\r\n * Component includes a \"list\" button that displays a dialog with the same checkboxes.\r\n * @public\r\n */\r\nexport class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideMenuState<T>;\r\n\r\n /** @internal */\r\n constructor(props: ShowHideMenuProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n dialogOpened: false,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideMenuProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _showAll = () => {\r\n this.setState({ hiddenColumns: [] }, () => {\r\n // istanbul ignore next\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n private _showDialog = () => {\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n this.setState({\r\n dialogOpened: true,\r\n });\r\n };\r\n\r\n private _closeDialog = () => {\r\n this.setState({\r\n dialogOpened: false,\r\n });\r\n };\r\n\r\n private _defaultContextMenu = (event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { items, x, y, opened, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalContextMenu\r\n x={x}\r\n y={y}\r\n opened={opened}\r\n onEsc={onClose}\r\n onOutsideClick={onClose}\r\n edgeLimit={false}\r\n autoflip={true}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => this._toggleItem(item);\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-menu-input-${index}`;\r\n return (\r\n <ContextMenuItem key={index}\r\n onSelect={sel}\r\n icon={<Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} />} >\r\n {label}\r\n </ContextMenuItem>\r\n );\r\n })}\r\n <ContextMenuDivider />\r\n <ContextMenuItem onSelect={this._showAll}><span data-testid=\"show-hide-showall\">{UiComponents.translate(\"showhide.showAll\")}</span></ContextMenuItem>\r\n <ContextMenuItem onSelect={this._showDialog}><span data-testid=\"show-hide-list\">{UiComponents.translate(\"showhide.list\")}</span></ContextMenuItem>\r\n <ShowHideDialog\r\n items={items}\r\n title={UiComponents.translate(\"showhide.title\")}\r\n opened={this.state.dialogOpened}\r\n onClose={this._closeDialog}\r\n initialHidden={this.state.hiddenColumns}\r\n onContextMenu={this._defaultContextMenu}\r\n onShowHideChange={onShowHideChange} />\r\n </GlobalContextMenu>\r\n );\r\n }\r\n}\r\n\r\n// cspell:ignore showall\r\n"]}
|
|
1
|
+
{"version":3,"file":"ShowHideMenu.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAA4C;AAE5C,6CAA+B;AAC/B,kDAAmH;AACnH,qDAAkD;AAClD,qDAAkD;AAElD,wDAAgD;AA4BhD;;;;GAIG;AACH,MAAa,YAAmC,SAAQ,KAAK,CAAC,aAAyD;IAIrH,gBAAgB;IAChB,YAAY,KAA2B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAcP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAA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,oBAAC,4BAAe,IAAC,QAAQ,EAAE,IAAI,CAAC,WAAW;gBAAE,6CAAkB,gBAAgB,IAAE,2BAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAQ,CAAkB;YAClJ,oBAAC,+BAAc,IACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,2BAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAC/C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EACvC,gBAAgB,EAAE,gBAAgB,GAAI,CACtB,CACrB,CAAC;IACJ,CAAC;CACF;AApHD,oCAoHC;AAED,wBAAwB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nimport * as React from \"react\";\r\nimport { ContextMenuDivider, ContextMenuItem, GlobalContextMenu, GlobalContextMenuProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideDialog } from \"./ShowHideDialog\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideMenu]] component\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** X position to place menu */\r\n x: number;\r\n /** Y position to place menu */\r\n y: number;\r\n /** Whether dialog is opened or closed */\r\n opened: boolean;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when close button is clicked */\r\n onClose?: () => void;\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideMenuState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n dialogOpened: boolean;\r\n}\r\n\r\n/**\r\n * [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.\r\n * Component includes a \"list\" button that displays a dialog with the same checkboxes.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideMenuState<T>;\r\n\r\n /** @internal */\r\n constructor(props: ShowHideMenuProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n dialogOpened: false,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideMenuProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _showAll = () => {\r\n this.setState({ hiddenColumns: [] }, () => {\r\n // istanbul ignore next\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n private _showDialog = () => {\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n this.setState({\r\n dialogOpened: true,\r\n });\r\n };\r\n\r\n private _closeDialog = () => {\r\n this.setState({\r\n dialogOpened: false,\r\n });\r\n };\r\n\r\n private _defaultContextMenu = (event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { items, x, y, opened, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalContextMenu\r\n x={x}\r\n y={y}\r\n opened={opened}\r\n onEsc={onClose}\r\n onOutsideClick={onClose}\r\n edgeLimit={false}\r\n autoflip={true}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => this._toggleItem(item);\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-menu-input-${index}`;\r\n return (\r\n <ContextMenuItem key={index}\r\n onSelect={sel}\r\n icon={<Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} />} >\r\n {label}\r\n </ContextMenuItem>\r\n );\r\n })}\r\n <ContextMenuDivider />\r\n <ContextMenuItem onSelect={this._showAll}><span data-testid=\"show-hide-showall\">{UiComponents.translate(\"showhide.showAll\")}</span></ContextMenuItem>\r\n <ContextMenuItem onSelect={this._showDialog}><span data-testid=\"show-hide-list\">{UiComponents.translate(\"showhide.list\")}</span></ContextMenuItem>\r\n <ShowHideDialog\r\n items={items}\r\n title={UiComponents.translate(\"showhide.title\")}\r\n opened={this.state.dialogOpened}\r\n onClose={this._closeDialog}\r\n initialHidden={this.state.hiddenColumns}\r\n onContextMenu={this._defaultContextMenu}\r\n onShowHideChange={onShowHideChange} />\r\n </GlobalContextMenu>\r\n );\r\n }\r\n}\r\n\r\n// cspell:ignore showall\r\n"]}
|
|
@@ -157,7 +157,7 @@ class EnumButtonGroupEditor extends React.Component {
|
|
|
157
157
|
isDisabled = !isEnabledFunction();
|
|
158
158
|
}
|
|
159
159
|
const className = (0, classnames_1.default)("components-enumbuttongroup-button", isDisabled && "nz-is-disabled", isActive && "nz-is-active");
|
|
160
|
-
return (React.createElement("button", { ref: (ref) => this._btnRefs.set(choiceValue, ref), "data-testid": choice.label, className: className, title: choice.label, key: choice.label, onClick: () => this._handleButtonClick(index) },
|
|
160
|
+
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) },
|
|
161
161
|
React.createElement(core_react_1.Icon, { iconSpec: this.state.enumIcons[index].iconSpec })));
|
|
162
162
|
}
|
|
163
163
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAyC;AAEzC,mEAAoF;AAWpF;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK,CAAC,SAA0D;IAA3G;;QACU,aAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;QACzD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAyC;YACrE,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,E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WAAW,IAClI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACrJ,CAAC,CAAC;IACZ,CAAC;CACF;AA/JD,sDA+JC;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,0CAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AAJD,sEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,oCAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EnumButtonGroupEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\r\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n// cspell:ignore buttongroup enumbuttongroup\r\n\r\n/** @internal */\r\ninterface EnumButtonGroupEditorState {\r\n selectValue: string | number;\r\n enumIcons: IconDefinition[];\r\n choices: EnumerationChoice[];\r\n}\r\n\r\n/** EnumButtonGroupEditor React component that is a property editor with select input\r\n * @public\r\n */\r\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\r\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\r\n selectValue: \"\",\r\n enumIcons: [],\r\n choices: [],\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.selectValue,\r\n displayValue: \"\",\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this._divElement.current)\r\n containsFocus = this._divElement.current.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const { propertyRecord } = this.props;\r\n\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = propertyRecord.value.value;\r\n let selectValue: string | number;\r\n\r\n if (typeof primitiveValue === \"string\") {\r\n selectValue = primitiveValue;\r\n } else {\r\n selectValue = primitiveValue as number;\r\n }\r\n\r\n let choices: EnumerationChoice[] = [];\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum) {\r\n if (propertyRecord.property.enum.choices instanceof Promise) {\r\n choices = await propertyRecord.property.enum.choices;\r\n } else {\r\n choices = propertyRecord.property.enum.choices;\r\n }\r\n }\r\n\r\n const numChoices = choices.length;\r\n const enumIcons = new Array<IconDefinition>(numChoices);\r\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\r\n\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\r\n // istanbul ignore else\r\n if (bgParams) {\r\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\r\n // istanbul ignore else\r\n if (index < numChoices) {\r\n enumIcons[index] = iconDef;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n this.setState({ selectValue, enumIcons, choices });\r\n }\r\n }\r\n\r\n private _handleButtonClick = (index: number) => {\r\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\r\n\r\n // istanbul ignore else\r\n if (this.state.choices && this.state.choices.length > index) {\r\n const selectValue = this.state.choices[index].value;\r\n\r\n this.setState({\r\n selectValue,\r\n }, async () => {\r\n // istanbul ignore else\r\n if (propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n });\r\n }\r\n };\r\n\r\n private getButton(choice: EnumerationChoice, index: number) {\r\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\r\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\r\n let isDisabled = false;\r\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\r\n // istanbul ignore else\r\n if (isEnabledFunction) {\r\n isDisabled = !isEnabledFunction();\r\n }\r\n\r\n const className = classnames(\r\n \"components-enumbuttongroup-button\",\r\n isDisabled && \"nz-is-disabled\",\r\n isActive && \"nz-is-active\",\r\n );\r\n\r\n return (\r\n <button\r\n ref={(ref: HTMLButtonElement) => this._btnRefs.set(choiceValue, ref)}\r\n data-testid={choice.label}\r\n className={className}\r\n title={choice.label}\r\n key={choice.label}\r\n onClick={() => this._handleButtonClick(index)}\r\n >\r\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\r\n </button >\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\r\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\r\n </div>);\r\n }\r\n}\r\n\r\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\r\n * It uses the [[EnumButtonGroupEditor]] React component.\r\n * @public\r\n */\r\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\r\n public get reactNode(): React.ReactNode {\r\n return <EnumButtonGroupEditor />;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\r\n"]}
|
|
1
|
+
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAyC;AAEzC,mEAAoF;AAWpF;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK,CAAC,SAA0D;IAA3G;;QACU,aAAQ,GAAG,IAA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AO,CACL,6BAAK,SAAS,EAAE,IAAA,oBAAU,EAAC,mCAAmC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,IAClI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACrJ,CAAC,CAAC;IACZ,CAAC;CACF;AA/JD,sDA+JC;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,0CAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AAJD,sEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,oCAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EnumButtonGroupEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\r\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n// cspell:ignore buttongroup enumbuttongroup\r\n\r\n/** @internal */\r\ninterface EnumButtonGroupEditorState {\r\n selectValue: string | number;\r\n enumIcons: IconDefinition[];\r\n choices: EnumerationChoice[];\r\n}\r\n\r\n/** EnumButtonGroupEditor React component that is a property editor with select input\r\n * @public\r\n */\r\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\r\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\r\n selectValue: \"\",\r\n enumIcons: [],\r\n choices: [],\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.selectValue,\r\n displayValue: \"\",\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this._divElement.current)\r\n containsFocus = this._divElement.current.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const { propertyRecord } = this.props;\r\n\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = propertyRecord.value.value;\r\n let selectValue: string | number;\r\n\r\n if (typeof primitiveValue === \"string\") {\r\n selectValue = primitiveValue;\r\n } else {\r\n selectValue = primitiveValue as number;\r\n }\r\n\r\n let choices: EnumerationChoice[] = [];\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum) {\r\n if (propertyRecord.property.enum.choices instanceof Promise) {\r\n choices = await propertyRecord.property.enum.choices;\r\n } else {\r\n choices = propertyRecord.property.enum.choices;\r\n }\r\n }\r\n\r\n const numChoices = choices.length;\r\n const enumIcons = new Array<IconDefinition>(numChoices);\r\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\r\n\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\r\n // istanbul ignore else\r\n if (bgParams) {\r\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\r\n // istanbul ignore else\r\n if (index < numChoices) {\r\n enumIcons[index] = iconDef;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n this.setState({ selectValue, enumIcons, choices });\r\n }\r\n }\r\n\r\n private _handleButtonClick = (index: number) => {\r\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\r\n\r\n // istanbul ignore else\r\n if (this.state.choices && this.state.choices.length > index) {\r\n const selectValue = this.state.choices[index].value;\r\n\r\n this.setState({\r\n selectValue,\r\n }, async () => {\r\n // istanbul ignore else\r\n if (propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n });\r\n }\r\n };\r\n\r\n private getButton(choice: EnumerationChoice, index: number) {\r\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\r\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\r\n let isDisabled = false;\r\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\r\n // istanbul ignore else\r\n if (isEnabledFunction) {\r\n isDisabled = !isEnabledFunction();\r\n }\r\n\r\n const className = classnames(\r\n \"components-enumbuttongroup-button\",\r\n isDisabled && \"nz-is-disabled\",\r\n isActive && \"nz-is-active\",\r\n );\r\n\r\n return (\r\n <button\r\n ref={(ref: HTMLButtonElement|null) => ref && this._btnRefs.set(choiceValue, ref)}\r\n data-testid={choice.label}\r\n className={className}\r\n title={choice.label}\r\n key={choice.label}\r\n onClick={() => this._handleButtonClick(index)}\r\n >\r\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\r\n </button >\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\r\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\r\n </div>);\r\n }\r\n}\r\n\r\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\r\n * It uses the [[EnumButtonGroupEditor]] React component.\r\n * @public\r\n */\r\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\r\n public get reactNode(): React.ReactNode {\r\n return <EnumButtonGroupEditor />;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\r\n"]}
|
|
@@ -16,5 +16,5 @@ export interface ItemWrapperProps extends CommonProps {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function ItemWrapper(props: ItemWrapperProps): JSX.Element;
|
|
18
18
|
/** @internal */
|
|
19
|
-
export declare function useResizeObserverSingleDimension<T extends Element>(onResize: (size: number) => void, useHeight: boolean): (instance:
|
|
19
|
+
export declare function useResizeObserverSingleDimension<T extends Element>(onResize: (size: number) => void, useHeight: boolean): (instance: T | null) => void;
|
|
20
20
|
//# sourceMappingURL=ItemWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ItemWrapper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAInE;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAoBlD;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"ItemWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ItemWrapper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAInE;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAoBlD;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,gCAOvH"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { GlobalDialogProps } from "@itwin/core-react";
|
|
6
6
|
import { ShowHideID, ShowHideItem } from "./ShowHideItem";
|
|
7
|
-
/** Properties for the [[ShowHideDialog]] component
|
|
8
|
-
* @public
|
|
7
|
+
/** Properties for the [[ShowHideDialog]] component used in the [[Table]] to show/hide columns.
|
|
8
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
9
9
|
*/
|
|
10
10
|
export interface ShowHideDialogProps<T extends ShowHideID> extends GlobalDialogProps {
|
|
11
11
|
/** key-label pair list for id's to be shown/hidden, and an accompanying label. */
|
|
@@ -20,8 +20,8 @@ interface ShowHideDialogState<T extends ShowHideID> {
|
|
|
20
20
|
hiddenColumns: T[];
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* [Dialog]($core-react) Component used to toggle show/hide
|
|
24
|
-
* @public
|
|
23
|
+
* [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.
|
|
24
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
25
25
|
*/
|
|
26
26
|
export declare class ShowHideDialog<T extends ShowHideID> extends React.PureComponent<ShowHideDialogProps<T>, ShowHideDialogState<T>> {
|
|
27
27
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideDialog.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideDialog.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAgB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI1D;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,iBAAiB;IAClF,kFAAkF;IAClF,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,gCAAgC;IAChC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;IACpB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,SAAS,CAAC;CACvD;AAED,gBAAgB;AAChB,UAAU,mBAAmB,CAAC,CAAC,SAAS,UAAU;IAChD,aAAa,EAAE,CAAC,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC3H,gBAAgB;IAChB,SAAyB,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;gBAC3C,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAOzC,gBAAgB;IACA,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAMnE,OAAO,CAAC,WAAW,CAKjB;IAEF,OAAO,CAAC,KAAK,CAOX;IAEF,OAAO,CAAC,KAAK,CASX;IAEF,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CAiC1C"}
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Common
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable deprecation/deprecation */
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { GlobalDialog } from "@itwin/core-react";
|
|
10
11
|
import { UiComponents } from "../../UiComponents";
|
|
11
12
|
import { DialogButtonType } from "@itwin/appui-abstract";
|
|
12
13
|
import { Checkbox } from "@itwin/itwinui-react";
|
|
13
14
|
/**
|
|
14
|
-
* [Dialog]($core-react) Component used to toggle show/hide
|
|
15
|
-
* @public
|
|
15
|
+
* [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.
|
|
16
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
16
17
|
*/
|
|
17
18
|
export class ShowHideDialog extends React.PureComponent {
|
|
18
19
|
constructor(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideDialog.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAmBhD;;;GAGG;AACH,MAAM,OAAO,cAAqC,SAAQ,KAAK,CAAC,aAA6D;IAG3H,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAaP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;gBAEjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;QAEM,UAAK,GAAG,CAAC,IAAqB,EAAE,EAAE;YACxC,IA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O,EAAE,EAAE,IAAG,KAAK,CAAS,CAC/B,CACP,CAAC;QACJ,CAAC,CAAC,CACW,CAChB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { GlobalDialog, GlobalDialogProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideDialog]] component
|
|
1
|
+
{"version":3,"file":"ShowHideDialog.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideDialog.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4CAA4C;AAE5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAmBhD;;;GAGG;AACH,MAAM,OAAO,cAAqC,SAAQ,KAAK,CAAC,aAA6D;IAG3H,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAaP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC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,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,GAAI;gBAChG,+BAAO,OAAO,EAAE,EAAE,IAAG,KAAK,CAAS,CAC/B,CACP,CAAC;QACJ,CAAC,CAAC,CACW,CAChB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nimport * as React from \"react\";\r\nimport { GlobalDialog, GlobalDialogProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideDialog]] component used in the [[Table]] to show/hide columns.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideDialogProps<T extends ShowHideID> extends GlobalDialogProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideDialogState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n}\r\n\r\n/**\r\n * [Dialog]($core-react) Component used to toggle show/hide table columns, given through items prop, through a list of checkboxes.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport class ShowHideDialog<T extends ShowHideID> extends React.PureComponent<ShowHideDialogProps<T>, ShowHideDialogState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideDialogState<T>;\r\n constructor(props: ShowHideDialogProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideDialogProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { opened, items, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalDialog\r\n opened={opened}\r\n resizable={true}\r\n movable={true}\r\n modal={false}\r\n minWidth={300}\r\n minHeight={250}\r\n width={300}\r\n onClose={onClose}\r\n onEscape={onClose}\r\n onOutsideClick={onClose}\r\n buttonCluster={onClose && [{ onClick: onClose, type: DialogButtonType.Close }]}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => {\r\n this._toggleItem(item);\r\n };\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-dialog-input-${index}`;\r\n return (\r\n <div key={index}>\r\n <Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} onClick={sel} />\r\n <label htmlFor={id}>{label}</label>\r\n </div>\r\n );\r\n })}\r\n </GlobalDialog>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Common
|
|
3
3
|
*/
|
|
4
|
-
/** Interface for ShowHide items
|
|
5
|
-
* @public
|
|
4
|
+
/** Interface for ShowHide items used to show/hide [[Table]] columns.
|
|
5
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
6
6
|
*/
|
|
7
7
|
export interface ShowHideItem<T extends ShowHideID> {
|
|
8
8
|
id: T;
|
|
9
9
|
label: string;
|
|
10
10
|
}
|
|
11
11
|
/** Union type for all possible ShowHide IDs
|
|
12
|
-
* @public
|
|
12
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
13
13
|
*/
|
|
14
14
|
export declare type ShowHideID = string | number | symbol;
|
|
15
15
|
//# sourceMappingURL=ShowHideItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideItem.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideItem.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,UAAU;IAChD,EAAE,EAAE,CAAC,CAAC;IACN,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideItem.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/** Interface for ShowHide items
|
|
1
|
+
{"version":3,"file":"ShowHideItem.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideItem.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** Interface for ShowHide items used to show/hide [[Table]] columns.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideItem<T extends ShowHideID> {\r\n id: T;\r\n label: string;\r\n}\r\n\r\n/** Union type for all possible ShowHide IDs\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport type ShowHideID = string | number | symbol;\r\n"]}
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import { GlobalContextMenuProps } from "@itwin/core-react";
|
|
6
6
|
import { ShowHideID, ShowHideItem } from "./ShowHideItem";
|
|
7
7
|
/** Properties for the [[ShowHideMenu]] component
|
|
8
|
-
* @public
|
|
8
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
9
9
|
*/
|
|
10
10
|
export interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {
|
|
11
11
|
/** key-label pair list for id's to be shown/hidden, and an accompanying label. */
|
|
@@ -31,7 +31,7 @@ interface ShowHideMenuState<T extends ShowHideID> {
|
|
|
31
31
|
/**
|
|
32
32
|
* [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.
|
|
33
33
|
* Component includes a "list" button that displays a dialog with the same checkboxes.
|
|
34
|
-
* @public
|
|
34
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
35
35
|
*/
|
|
36
36
|
export declare class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {
|
|
37
37
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ShowHideMenu.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA0D,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAGnH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG1D;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,sBAAsB;IACrF,kFAAkF;IAClF,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,+BAA+B;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,yCAAyC;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;IACpB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,SAAS,CAAC;CACvD;AAED,gBAAgB;AAChB,UAAU,iBAAiB,CAAC,CAAC,SAAS,UAAU;IAC9C,aAAa,EAAE,CAAC,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACrH,gBAAgB;IAChB,SAAyB,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAErD,gBAAgB;gBACJ,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAQvC,gBAAgB;IACA,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAMjE,OAAO,CAAC,WAAW,CAOjB;IAEF,OAAO,CAAC,KAAK,CAOX;IAEF,OAAO,CAAC,KAAK,CASX;IAEF,OAAO,CAAC,QAAQ,CAQd;IACF,OAAO,CAAC,WAAW,CAMjB;IAEF,OAAO,CAAC,YAAY,CAIlB;IAEF,OAAO,CAAC,mBAAmB,CAEzB;IAEF,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CAuC1C"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Common
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable deprecation/deprecation */
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { ContextMenuDivider, ContextMenuItem, GlobalContextMenu } from "@itwin/core-react";
|
|
10
11
|
import { UiComponents } from "../../UiComponents";
|
|
@@ -13,7 +14,7 @@ import { Checkbox } from "@itwin/itwinui-react";
|
|
|
13
14
|
/**
|
|
14
15
|
* [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.
|
|
15
16
|
* Component includes a "list" button that displays a dialog with the same checkboxes.
|
|
16
|
-
* @public
|
|
17
|
+
* @public @deprecated will be removed when deprecated [[Table]] component is removed.
|
|
17
18
|
*/
|
|
18
19
|
export class ShowHideMenu extends React.PureComponent {
|
|
19
20
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowHideMenu.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAA0B,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA4BhD;;;;GAIG;AACH,MAAM,OAAO,YAAmC,SAAQ,KAAK,CAAC,aAAyD;IAIrH,gBAAgB;IAChB,YAAY,KAA2B;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QAcP,gBAAW,GAAG,CAAC,IAAqB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;gBAEjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO;gBACpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC;QAEM,UAAK,GAAG,CAAC,IAAqB,EAAE,EAAE;YACxC,IAAI,CAAC,QAAQ,CACX,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,C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AI,CAAC,mBAAmB,EACvC,gBAAgB,EAAE,gBAAgB,GAAI,CACtB,CACrB,CAAC;IACJ,CAAC;CACF;AAED,wBAAwB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { ContextMenuDivider, ContextMenuItem, GlobalContextMenu, GlobalContextMenuProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideDialog } from \"./ShowHideDialog\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideMenu]] component\r\n * @public\r\n */\r\nexport interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** X position to place menu */\r\n x: number;\r\n /** Y position to place menu */\r\n y: number;\r\n /** Whether dialog is opened or closed */\r\n opened: boolean;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when close button is clicked */\r\n onClose?: () => void;\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideMenuState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n dialogOpened: boolean;\r\n}\r\n\r\n/**\r\n * [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.\r\n * Component includes a \"list\" button that displays a dialog with the same checkboxes.\r\n * @public\r\n */\r\nexport class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideMenuState<T>;\r\n\r\n /** @internal */\r\n constructor(props: ShowHideMenuProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n dialogOpened: false,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideMenuProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _showAll = () => {\r\n this.setState({ hiddenColumns: [] }, () => {\r\n // istanbul ignore next\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n private _showDialog = () => {\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n this.setState({\r\n dialogOpened: true,\r\n });\r\n };\r\n\r\n private _closeDialog = () => {\r\n this.setState({\r\n dialogOpened: false,\r\n });\r\n };\r\n\r\n private _defaultContextMenu = (event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { items, x, y, opened, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalContextMenu\r\n x={x}\r\n y={y}\r\n opened={opened}\r\n onEsc={onClose}\r\n onOutsideClick={onClose}\r\n edgeLimit={false}\r\n autoflip={true}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => this._toggleItem(item);\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-menu-input-${index}`;\r\n return (\r\n <ContextMenuItem key={index}\r\n onSelect={sel}\r\n icon={<Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} />} >\r\n {label}\r\n </ContextMenuItem>\r\n );\r\n })}\r\n <ContextMenuDivider />\r\n <ContextMenuItem onSelect={this._showAll}><span data-testid=\"show-hide-showall\">{UiComponents.translate(\"showhide.showAll\")}</span></ContextMenuItem>\r\n <ContextMenuItem onSelect={this._showDialog}><span data-testid=\"show-hide-list\">{UiComponents.translate(\"showhide.list\")}</span></ContextMenuItem>\r\n <ShowHideDialog\r\n items={items}\r\n title={UiComponents.translate(\"showhide.title\")}\r\n opened={this.state.dialogOpened}\r\n onClose={this._closeDialog}\r\n initialHidden={this.state.hiddenColumns}\r\n onContextMenu={this._defaultContextMenu}\r\n onShowHideChange={onShowHideChange} />\r\n </GlobalContextMenu>\r\n );\r\n }\r\n}\r\n\r\n// cspell:ignore showall\r\n"]}
|
|
1
|
+
{"version":3,"file":"ShowHideMenu.js","sourceRoot":"","sources":["../../../../../src/components-react/common/showhide/ShowHideMenu.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4CAA4C;AAE5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAA0B,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB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E,oBAAC,QAAQ,mBAAc,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,GAAI,IACvF,KAAK,CACU,CACnB,CAAC;YACJ,CAAC,CAAC;YACF,oBAAC,kBAAkB,OAAG;YACtB,oBAAC,eAAe,IAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBAAE,6CAAkB,mBAAmB,IAAE,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAQ,CAAkB;YACrJ,oBAAC,eAAe,IAAC,QAAQ,EAAE,IAAI,CAAC,WAAW;gBAAE,6CAAkB,gBAAgB,IAAE,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAQ,CAAkB;YAClJ,oBAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAC/C,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC/B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EACvC,gBAAgB,EAAE,gBAAgB,GAAI,CACtB,CACrB,CAAC;IACJ,CAAC;CACF;AAED,wBAAwB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\nimport * as React from \"react\";\r\nimport { ContextMenuDivider, ContextMenuItem, GlobalContextMenu, GlobalContextMenuProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../../UiComponents\";\r\nimport { ShowHideDialog } from \"./ShowHideDialog\";\r\nimport { ShowHideID, ShowHideItem } from \"./ShowHideItem\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties for the [[ShowHideMenu]] component\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport interface ShowHideMenuProps<T extends ShowHideID> extends GlobalContextMenuProps {\r\n /** key-label pair list for id's to be shown/hidden, and an accompanying label. */\r\n items: Array<ShowHideItem<T>>;\r\n /** X position to place menu */\r\n x: number;\r\n /** Y position to place menu */\r\n y: number;\r\n /** Whether dialog is opened or closed */\r\n opened: boolean;\r\n /** Hidden list to start with */\r\n initialHidden?: T[];\r\n /** Called when close button is clicked */\r\n onClose?: () => void;\r\n /** Called when item is shown/hidden */\r\n onShowHideChange?: (cols: T[]) => boolean | undefined;\r\n}\r\n\r\n/** @internal */\r\ninterface ShowHideMenuState<T extends ShowHideID> {\r\n hiddenColumns: T[];\r\n dialogOpened: boolean;\r\n}\r\n\r\n/**\r\n * [ContextMenu]($core-react) Component used to toggle show/hide items, given through items prop, through a list of checkboxes.\r\n * Component includes a \"list\" button that displays a dialog with the same checkboxes.\r\n * @public @deprecated will be removed when deprecated [[Table]] component is removed.\r\n */\r\nexport class ShowHideMenu<T extends ShowHideID> extends React.PureComponent<ShowHideMenuProps<T>, ShowHideMenuState<T>> {\r\n /** @internal */\r\n public override readonly state: ShowHideMenuState<T>;\r\n\r\n /** @internal */\r\n constructor(props: ShowHideMenuProps<T>) {\r\n super(props);\r\n this.state = {\r\n hiddenColumns: props.initialHidden || [],\r\n dialogOpened: false,\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(oldProps: ShowHideMenuProps<T>) {\r\n if (this.props.initialHidden && oldProps.initialHidden !== this.props.initialHidden) {\r\n this.setState((_, props) => ({ hiddenColumns: props.initialHidden || /* istanbul ignore next */[] }));\r\n }\r\n }\r\n\r\n private _toggleItem = (item: ShowHideItem<T>) => {\r\n if (this.state.hiddenColumns.indexOf(item.id) !== -1)\r\n this._show(item);\r\n else\r\n this._hide(item);\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n\r\n private _hide = (item: ShowHideItem<T>) => {\r\n this.setState(\r\n (prevState) => ({ hiddenColumns: [...prevState.hiddenColumns, item.id] }),\r\n () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _show = (item: ShowHideItem<T>) => {\r\n const hiddenColumns = this.state.hiddenColumns.filter((value) => {\r\n return value !== item.id;\r\n });\r\n\r\n this.setState({ hiddenColumns }, () => {\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n };\r\n\r\n private _showAll = () => {\r\n this.setState({ hiddenColumns: [] }, () => {\r\n // istanbul ignore next\r\n if (this.props.onShowHideChange)\r\n this.props.onShowHideChange(this.state.hiddenColumns);\r\n });\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n };\r\n private _showDialog = () => {\r\n if (this.props.onClose)\r\n this.props.onClose();\r\n this.setState({\r\n dialogOpened: true,\r\n });\r\n };\r\n\r\n private _closeDialog = () => {\r\n this.setState({\r\n dialogOpened: false,\r\n });\r\n };\r\n\r\n private _defaultContextMenu = (event: React.MouseEvent) => {\r\n event.stopPropagation();\r\n };\r\n\r\n /** @internal */\r\n public override render(): React.ReactNode {\r\n const { items, x, y, opened, initialHidden, onClose, onShowHideChange, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <GlobalContextMenu\r\n x={x}\r\n y={y}\r\n opened={opened}\r\n onEsc={onClose}\r\n onOutsideClick={onClose}\r\n edgeLimit={false}\r\n autoflip={true}\r\n {...props}>\r\n {this.props.items.map((item, index) => {\r\n const visible = this.state.hiddenColumns.indexOf(item.id) === -1;\r\n const sel = () => this._toggleItem(item);\r\n const label = item.label || UiComponents.translate(\"showhide.noLabel\");\r\n const id = `show-hide-menu-input-${index}`;\r\n return (\r\n <ContextMenuItem key={index}\r\n onSelect={sel}\r\n icon={<Checkbox data-testid={id} id={id} checked={visible} onChange={() => undefined} />} >\r\n {label}\r\n </ContextMenuItem>\r\n );\r\n })}\r\n <ContextMenuDivider />\r\n <ContextMenuItem onSelect={this._showAll}><span data-testid=\"show-hide-showall\">{UiComponents.translate(\"showhide.showAll\")}</span></ContextMenuItem>\r\n <ContextMenuItem onSelect={this._showDialog}><span data-testid=\"show-hide-list\">{UiComponents.translate(\"showhide.list\")}</span></ContextMenuItem>\r\n <ShowHideDialog\r\n items={items}\r\n title={UiComponents.translate(\"showhide.title\")}\r\n opened={this.state.dialogOpened}\r\n onClose={this._closeDialog}\r\n initialHidden={this.state.hiddenColumns}\r\n onContextMenu={this._defaultContextMenu}\r\n onShowHideChange={onShowHideChange} />\r\n </GlobalContextMenu>\r\n );\r\n }\r\n}\r\n\r\n// cspell:ignore showall\r\n"]}
|
|
@@ -132,7 +132,7 @@ export class EnumButtonGroupEditor extends React.Component {
|
|
|
132
132
|
isDisabled = !isEnabledFunction();
|
|
133
133
|
}
|
|
134
134
|
const className = classnames("components-enumbuttongroup-button", isDisabled && "nz-is-disabled", isActive && "nz-is-active");
|
|
135
|
-
return (React.createElement("button", { ref: (ref) => this._btnRefs.set(choiceValue, ref), "data-testid": choice.label, className: className, title: choice.label, key: choice.label, onClick: () => this._handleButtonClick(index) },
|
|
135
|
+
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) },
|
|
136
136
|
React.createElement(Icon, { iconSpec: this.state.enumIcons[index].iconSpec })));
|
|
137
137
|
}
|
|
138
138
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,UAAU,MAAM,YAAY,CAAC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,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;YAE7C,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAI,CAChD,CACX,CAAC;IACJ,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,OAAO,CACL,6BAAK,SAAS,EAAE,UAAU,CAAC,mCAAmC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,IAClI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACrJ,CAAC,CAAC;IACZ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,kBAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EnumButtonGroupEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\r\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n// cspell:ignore buttongroup enumbuttongroup\r\n\r\n/** @internal */\r\ninterface EnumButtonGroupEditorState {\r\n selectValue: string | number;\r\n enumIcons: IconDefinition[];\r\n choices: EnumerationChoice[];\r\n}\r\n\r\n/** EnumButtonGroupEditor React component that is a property editor with select input\r\n * @public\r\n */\r\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\r\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\r\n selectValue: \"\",\r\n enumIcons: [],\r\n choices: [],\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.selectValue,\r\n displayValue: \"\",\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this._divElement.current)\r\n containsFocus = this._divElement.current.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const { propertyRecord } = this.props;\r\n\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = propertyRecord.value.value;\r\n let selectValue: string | number;\r\n\r\n if (typeof primitiveValue === \"string\") {\r\n selectValue = primitiveValue;\r\n } else {\r\n selectValue = primitiveValue as number;\r\n }\r\n\r\n let choices: EnumerationChoice[] = [];\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum) {\r\n if (propertyRecord.property.enum.choices instanceof Promise) {\r\n choices = await propertyRecord.property.enum.choices;\r\n } else {\r\n choices = propertyRecord.property.enum.choices;\r\n }\r\n }\r\n\r\n const numChoices = choices.length;\r\n const enumIcons = new Array<IconDefinition>(numChoices);\r\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\r\n\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\r\n // istanbul ignore else\r\n if (bgParams) {\r\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\r\n // istanbul ignore else\r\n if (index < numChoices) {\r\n enumIcons[index] = iconDef;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n this.setState({ selectValue, enumIcons, choices });\r\n }\r\n }\r\n\r\n private _handleButtonClick = (index: number) => {\r\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\r\n\r\n // istanbul ignore else\r\n if (this.state.choices && this.state.choices.length > index) {\r\n const selectValue = this.state.choices[index].value;\r\n\r\n this.setState({\r\n selectValue,\r\n }, async () => {\r\n // istanbul ignore else\r\n if (propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n });\r\n }\r\n };\r\n\r\n private getButton(choice: EnumerationChoice, index: number) {\r\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\r\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\r\n let isDisabled = false;\r\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\r\n // istanbul ignore else\r\n if (isEnabledFunction) {\r\n isDisabled = !isEnabledFunction();\r\n }\r\n\r\n const className = classnames(\r\n \"components-enumbuttongroup-button\",\r\n isDisabled && \"nz-is-disabled\",\r\n isActive && \"nz-is-active\",\r\n );\r\n\r\n return (\r\n <button\r\n ref={(ref: HTMLButtonElement) => this._btnRefs.set(choiceValue, ref)}\r\n data-testid={choice.label}\r\n className={className}\r\n title={choice.label}\r\n key={choice.label}\r\n onClick={() => this._handleButtonClick(index)}\r\n >\r\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\r\n </button >\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\r\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\r\n </div>);\r\n }\r\n}\r\n\r\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\r\n * It uses the [[EnumButtonGroupEditor]] React component.\r\n * @public\r\n */\r\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\r\n public get reactNode(): React.ReactNode {\r\n return <EnumButtonGroupEditor />;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\r\n"]}
|
|
1
|
+
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAC6E,wBAAwB,EAC3F,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,GAC3E,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAWpF;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAA0D;IAA3G;;QACU,aAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;QACzD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAyC;YACrE,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;QA2FM,uBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YAEnE,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE;gBAC3D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;gBAEpD,IAAI,CAAC,Q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AqB,OAAG,CAAC;IACnC,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module PropertyEditors\r\n */\r\n\r\nimport \"./EnumButtonGroupEditor.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\r\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\r\n} from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\r\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\r\n\r\n// cspell:ignore buttongroup enumbuttongroup\r\n\r\n/** @internal */\r\ninterface EnumButtonGroupEditorState {\r\n selectValue: string | number;\r\n enumIcons: IconDefinition[];\r\n choices: EnumerationChoice[];\r\n}\r\n\r\n/** EnumButtonGroupEditor React component that is a property editor with select input\r\n * @public\r\n */\r\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\r\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\r\n private _divElement = React.createRef<HTMLDivElement>();\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\r\n selectValue: \"\",\r\n enumIcons: [],\r\n choices: [],\r\n };\r\n\r\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\r\n const record = this.props.propertyRecord;\r\n let propertyValue: PropertyValue | undefined;\r\n\r\n // istanbul ignore else\r\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\r\n propertyValue = {\r\n valueFormat: PropertyValueFormat.Primitive,\r\n value: this.state.selectValue,\r\n displayValue: \"\",\r\n };\r\n }\r\n\r\n return propertyValue;\r\n }\r\n\r\n public get htmlElement(): HTMLElement | null {\r\n return this._divElement.current;\r\n }\r\n\r\n public get hasFocus(): boolean {\r\n let containsFocus = false;\r\n // istanbul ignore else\r\n if (this._divElement.current)\r\n containsFocus = this._divElement.current.contains(document.activeElement);\r\n return containsFocus;\r\n }\r\n\r\n /** @internal */\r\n public override componentDidMount() {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n /** @internal */\r\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\r\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\r\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n\r\n private async setStateFromProps() {\r\n const { propertyRecord } = this.props;\r\n\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\r\n const primitiveValue = propertyRecord.value.value;\r\n let selectValue: string | number;\r\n\r\n if (typeof primitiveValue === \"string\") {\r\n selectValue = primitiveValue;\r\n } else {\r\n selectValue = primitiveValue as number;\r\n }\r\n\r\n let choices: EnumerationChoice[] = [];\r\n // istanbul ignore else\r\n if (propertyRecord && propertyRecord.property.enum) {\r\n if (propertyRecord.property.enum.choices instanceof Promise) {\r\n choices = await propertyRecord.property.enum.choices;\r\n } else {\r\n choices = propertyRecord.property.enum.choices;\r\n }\r\n }\r\n\r\n const numChoices = choices.length;\r\n const enumIcons = new Array<IconDefinition>(numChoices);\r\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\r\n\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n // istanbul ignore else\r\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\r\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\r\n // istanbul ignore else\r\n if (bgParams) {\r\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\r\n // istanbul ignore else\r\n if (index < numChoices) {\r\n enumIcons[index] = iconDef;\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n this.setState({ selectValue, enumIcons, choices });\r\n }\r\n }\r\n\r\n private _handleButtonClick = (index: number) => {\r\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\r\n\r\n // istanbul ignore else\r\n if (this.state.choices && this.state.choices.length > index) {\r\n const selectValue = this.state.choices[index].value;\r\n\r\n this.setState({\r\n selectValue,\r\n }, async () => {\r\n // istanbul ignore else\r\n if (propertyRecord && this.props.onCommit) {\r\n const propertyValue = await this.getPropertyValue();\r\n // istanbul ignore else\r\n if (propertyValue !== undefined) {\r\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\r\n }\r\n }\r\n });\r\n }\r\n };\r\n\r\n private getButton(choice: EnumerationChoice, index: number) {\r\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\r\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\r\n let isDisabled = false;\r\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\r\n // istanbul ignore else\r\n if (isEnabledFunction) {\r\n isDisabled = !isEnabledFunction();\r\n }\r\n\r\n const className = classnames(\r\n \"components-enumbuttongroup-button\",\r\n isDisabled && \"nz-is-disabled\",\r\n isActive && \"nz-is-active\",\r\n );\r\n\r\n return (\r\n <button\r\n ref={(ref: HTMLButtonElement|null) => ref && this._btnRefs.set(choiceValue, ref)}\r\n data-testid={choice.label}\r\n className={className}\r\n title={choice.label}\r\n key={choice.label}\r\n onClick={() => this._handleButtonClick(index)}\r\n >\r\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\r\n </button >\r\n );\r\n }\r\n\r\n /** @internal */\r\n public override render() {\r\n return (\r\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\r\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\r\n </div>);\r\n }\r\n}\r\n\r\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\r\n * It uses the [[EnumButtonGroupEditor]] React component.\r\n * @public\r\n */\r\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\r\n public get reactNode(): React.ReactNode {\r\n return <EnumButtonGroupEditor />;\r\n }\r\n}\r\n\r\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\r\n"]}
|
|
@@ -16,5 +16,5 @@ export interface ItemWrapperProps extends CommonProps {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function ItemWrapper(props: ItemWrapperProps): JSX.Element;
|
|
18
18
|
/** @internal */
|
|
19
|
-
export declare function useResizeObserverSingleDimension<T extends Element>(onResize: (size: number) => void, useHeight: boolean): (instance:
|
|
19
|
+
export declare function useResizeObserverSingleDimension<T extends Element>(onResize: (size: number) => void, useHeight: boolean): (instance: T | null) => void;
|
|
20
20
|
//# sourceMappingURL=ItemWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ItemWrapper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAInE;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAoBlD;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"ItemWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ItemWrapper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAInE;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAoBlD;AAED,gBAAgB;AAChB,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,gCAOvH"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "3.2.0-dev.
|
|
3
|
+
"version": "3.2.0-dev.22",
|
|
4
4
|
"description": "iTwin.js UI complex components",
|
|
5
5
|
"main": "lib/cjs/components-react.js",
|
|
6
6
|
"module": "lib/esm/components-react.js",
|
|
7
7
|
"typings": "lib/cjs/components-react",
|
|
8
|
-
"imodeljsSharedLibrary": true,
|
|
9
8
|
"license": "MIT",
|
|
10
9
|
"repository": {
|
|
11
10
|
"type": "git",
|
|
@@ -21,9 +20,9 @@
|
|
|
21
20
|
"url": "http://www.bentley.com"
|
|
22
21
|
},
|
|
23
22
|
"peerDependencies": {
|
|
24
|
-
"@itwin/appui-abstract": "^3.2.0-dev.
|
|
25
|
-
"@itwin/core-bentley": "^3.2.0-dev.
|
|
26
|
-
"@itwin/core-react": "^3.2.0-dev.
|
|
23
|
+
"@itwin/appui-abstract": "^3.2.0-dev.22",
|
|
24
|
+
"@itwin/core-bentley": "^3.2.0-dev.22",
|
|
25
|
+
"@itwin/core-react": "^3.2.0-dev.22",
|
|
27
26
|
"react": "^17.0.0",
|
|
28
27
|
"react-dom": "^17.0.0"
|
|
29
28
|
},
|
|
@@ -32,13 +31,13 @@
|
|
|
32
31
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
33
32
|
],
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@itwin/appui-abstract": "3.2.0-dev.
|
|
36
|
-
"@itwin/build-tools": "3.2.0-dev.
|
|
37
|
-
"@itwin/core-bentley": "3.2.0-dev.
|
|
38
|
-
"@itwin/core-common": "3.2.0-dev.
|
|
39
|
-
"@itwin/core-i18n": "3.2.0-dev.
|
|
40
|
-
"@itwin/core-react": "3.2.0-dev.
|
|
41
|
-
"@itwin/eslint-plugin": "3.2.0-dev.
|
|
34
|
+
"@itwin/appui-abstract": "3.2.0-dev.22",
|
|
35
|
+
"@itwin/build-tools": "3.2.0-dev.22",
|
|
36
|
+
"@itwin/core-bentley": "3.2.0-dev.22",
|
|
37
|
+
"@itwin/core-common": "3.2.0-dev.22",
|
|
38
|
+
"@itwin/core-i18n": "3.2.0-dev.22",
|
|
39
|
+
"@itwin/core-react": "3.2.0-dev.22",
|
|
40
|
+
"@itwin/eslint-plugin": "3.2.0-dev.22",
|
|
42
41
|
"@testing-library/react": "^12.0.0",
|
|
43
42
|
"@testing-library/react-hooks": "^7.0.2",
|
|
44
43
|
"@testing-library/user-event": "^13.2.1",
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
],
|
|
96
95
|
"dependencies": {
|
|
97
96
|
"@bentley/icons-generic-webfont": "^1.0.15",
|
|
98
|
-
"@itwin/itwinui-css": "0.
|
|
97
|
+
"@itwin/itwinui-css": "0.x",
|
|
99
98
|
"@itwin/itwinui-react": "^1.32.0",
|
|
100
99
|
"@types/shortid": "~0.0.29",
|
|
101
100
|
"callable-instance2": "1.0.0",
|