@itwin/components-react 3.2.0-dev.3 → 3.2.0-dev.34

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/components-react/common/ImageRenderer.d.ts.map +1 -1
  3. package/lib/cjs/components-react/common/ImageRenderer.js +2 -1
  4. package/lib/cjs/components-react/common/ImageRenderer.js.map +1 -1
  5. package/lib/cjs/components-react/common/showhide/ShowHideDialog.d.ts +4 -4
  6. package/lib/cjs/components-react/common/showhide/ShowHideDialog.d.ts.map +1 -1
  7. package/lib/cjs/components-react/common/showhide/ShowHideDialog.js +3 -2
  8. package/lib/cjs/components-react/common/showhide/ShowHideDialog.js.map +1 -1
  9. package/lib/cjs/components-react/common/showhide/ShowHideItem.d.ts +3 -3
  10. package/lib/cjs/components-react/common/showhide/ShowHideItem.d.ts.map +1 -1
  11. package/lib/cjs/components-react/common/showhide/ShowHideItem.js.map +1 -1
  12. package/lib/cjs/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
  13. package/lib/cjs/components-react/common/showhide/ShowHideMenu.d.ts.map +1 -1
  14. package/lib/cjs/components-react/common/showhide/ShowHideMenu.js +2 -1
  15. package/lib/cjs/components-react/common/showhide/ShowHideMenu.js.map +1 -1
  16. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -1
  17. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  18. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
  19. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -1
  20. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  21. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  22. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +1 -3
  23. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  24. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
  25. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -1
  26. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  27. package/lib/cjs/components-react/properties/renderers/value/UrlPropertyValueRenderer.js +1 -1
  28. package/lib/cjs/components-react/properties/renderers/value/UrlPropertyValueRenderer.js.map +1 -1
  29. package/lib/cjs/components-react/table/component/Table.js +1 -1
  30. package/lib/cjs/components-react/table/component/Table.js.map +1 -1
  31. package/lib/cjs/components-react/toolbar/Toolbar.js +2 -2
  32. package/lib/cjs/components-react/toolbar/Toolbar.js.map +1 -1
  33. package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js +2 -2
  34. package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  35. package/lib/esm/components-react/common/ImageRenderer.d.ts.map +1 -1
  36. package/lib/esm/components-react/common/ImageRenderer.js +4 -3
  37. package/lib/esm/components-react/common/ImageRenderer.js.map +1 -1
  38. package/lib/esm/components-react/common/showhide/ShowHideDialog.d.ts +4 -4
  39. package/lib/esm/components-react/common/showhide/ShowHideDialog.d.ts.map +1 -1
  40. package/lib/esm/components-react/common/showhide/ShowHideDialog.js +3 -2
  41. package/lib/esm/components-react/common/showhide/ShowHideDialog.js.map +1 -1
  42. package/lib/esm/components-react/common/showhide/ShowHideItem.d.ts +3 -3
  43. package/lib/esm/components-react/common/showhide/ShowHideItem.d.ts.map +1 -1
  44. package/lib/esm/components-react/common/showhide/ShowHideItem.js.map +1 -1
  45. package/lib/esm/components-react/common/showhide/ShowHideMenu.d.ts +2 -2
  46. package/lib/esm/components-react/common/showhide/ShowHideMenu.d.ts.map +1 -1
  47. package/lib/esm/components-react/common/showhide/ShowHideMenu.js +2 -1
  48. package/lib/esm/components-react/common/showhide/ShowHideMenu.js.map +1 -1
  49. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +1 -1
  50. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  51. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
  52. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +2 -2
  53. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  54. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  55. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +1 -3
  56. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  57. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
  58. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +2 -2
  59. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  60. package/lib/esm/components-react/properties/renderers/value/UrlPropertyValueRenderer.js +1 -1
  61. package/lib/esm/components-react/properties/renderers/value/UrlPropertyValueRenderer.js.map +1 -1
  62. package/lib/esm/components-react/table/component/Table.js +1 -1
  63. package/lib/esm/components-react/table/component/Table.js.map +1 -1
  64. package/lib/esm/components-react/toolbar/Toolbar.js +2 -2
  65. package/lib/esm/components-react/toolbar/Toolbar.js.map +1 -1
  66. package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js +2 -2
  67. package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  68. package/package.json +13 -13
@@ -53,8 +53,8 @@ function Toolbar(props) {
53
53
  const panelAlignment = props.panelAlignment ? props.panelAlignment : ToolbarWithOverflow_1.ToolbarPanelAlignment.Start;
54
54
  const [popupPanelCount, setPopupPanelCount] = React.useState(0);
55
55
  const handlePopupPanelOpenClose = React.useCallback((isOpening) => {
56
- // use setImmediate to avoid warning about setting state in Toolbar from render method of PopupItem/PopupItemWithDrag
57
- setImmediate(() => {
56
+ // use setTimeout to avoid warning about setting state in Toolbar from render method of PopupItem/PopupItemWithDrag
57
+ setTimeout(() => {
58
58
  setPopupPanelCount((prev) => {
59
59
  const nextCount = isOpening ? (prev + 1) : (prev - 1);
60
60
  // eslint-disable-next-line no-console
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Toolbar.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB,4DAAoC;AACpC,6CAA+B;AAK/B,mCAAuC;AACvC,qDAAmG;AACnG,+DAAyL;AAsBzL,SAAS,mBAAmB,CAAC,KAAsB;IACjD,uBAAuB;IACvB,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAC/B,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,iBAAiB;YAC9C,OAAO,0CAA0C,CAAC;KACrD;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,KAAmB;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAS,CAAC,MAAM,CAAC;IACvE,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;IACtD,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,2CAAqB,CAAC,KAAK,CAAC;IACjG,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,yBAAyB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,SAAkB,EAAE,EAAE;QACzE,qHAAqH;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AC,6BAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,gBAAgB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,IAAG,KAAK,CAAO,CAAC,CACxH,CACX,CAEoB,CACgB,CACjD,CAAC;AACJ,CAAC;AAjFD,0BAiFC","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 Toolbar\r\n */\r\n\r\nimport \"./Toolbar.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n CommonToolbarItem, OnItemExecutedFunc,\r\n} from \"@itwin/appui-abstract\";\r\nimport { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\r\nimport { ToolbarItems } from \"./Items\";\r\nimport { Direction, OrthogonalDirection, OrthogonalDirectionHelpers } from \"./utilities/Direction\";\r\nimport { getToolbarDirection, ToolbarItemComponent, ToolbarItemContext, ToolbarOpacitySetting, ToolbarPanelAlignment, ToolbarWithOverflowDirectionContext } from \"./ToolbarWithOverflow\";\r\n\r\n/** Properties of [[Toolbar]] component.\r\n * @public\r\n */\r\nexport interface ToolbarProps extends CommonProps, NoChildrenProps {\r\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\r\n expandsTo?: Direction;\r\n /** definitions for items of the toolbar. i.e. [[CommonToolbarItem]]. Items are expected to be already sorted by group and item. */\r\n items: CommonToolbarItem[];\r\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\r\n panelAlignment?: ToolbarPanelAlignment;\r\n /** Use Drag Interaction to open popups with nest action buttons */\r\n useDragInteraction?: boolean;\r\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\r\n toolbarOpacitySetting?: ToolbarOpacitySetting;\r\n /** Optional function to call on any item execution */\r\n onItemExecuted?: OnItemExecutedFunc;\r\n /** Optional function to call on any KeyDown events processed by toolbar */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\nfunction getItemWrapperClass(child: React.ReactNode) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child)) {\r\n if (child.props && child.props.addGroupSeparator)\r\n return \"components-toolbar-button-add-gap-before\";\r\n }\r\n return \"\";\r\n}\r\n\r\n/** Component that displays tool settings as a bar across the top of the content view.\r\n * @public\r\n */\r\nexport function Toolbar(props: ToolbarProps) {\r\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\r\n const useDragInteraction = !!props.useDragInteraction;\r\n const panelAlignment = props.panelAlignment ? props.panelAlignment : ToolbarPanelAlignment.Start;\r\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\r\n\r\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n // use setImmediate to avoid warning about setting state in Toolbar from render method of PopupItem/PopupItemWithDrag\r\n setImmediate(() => {\r\n setPopupPanelCount((prev) => {\r\n const nextCount = isOpening ? (prev + 1) : (prev - 1);\r\n // eslint-disable-next-line no-console\r\n // console.log(`new popup count = ${nextCount}`);\r\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\r\n });\r\n });\r\n }, []);\r\n\r\n const availableNodes = React.useMemo<React.ReactNode[]>(() => {\r\n return props.items.map((item, index) => {\r\n let addGroupSeparator = false;\r\n if (index > 0)\r\n addGroupSeparator = item.groupPriority !== props.items[index - 1].groupPriority;\r\n return (\r\n <ToolbarItemComponent\r\n key={item.id}\r\n item={item}\r\n addGroupSeparator={!!addGroupSeparator}\r\n />\r\n );\r\n });\r\n }, [props.items]);\r\n\r\n const direction = getToolbarDirection(expandsTo);\r\n const className = classnames(\r\n \"components-toolbar-overflow-sizer\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n props.className);\r\n\r\n // needed to construct DOM structure identical to ToolbarWithOverflow so same css can be applied.\r\n const wrapperClassName = classnames(\r\n \"components-toolbar-item-container\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n );\r\n\r\n return (\r\n <ToolbarWithOverflowDirectionContext.Provider value={\r\n {\r\n expandsTo, direction, overflowExpandsTo: Direction.Right, panelAlignment, useDragInteraction,\r\n toolbarOpacitySetting: props.toolbarOpacitySetting ? props.toolbarOpacitySetting : ToolbarOpacitySetting.Proximity,\r\n overflowDirection: OrthogonalDirection.Horizontal,\r\n openPopupCount: popupPanelCount, onPopupPanelOpenClose: handlePopupPanelOpenClose, overflowDisplayActive: false,\r\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : /* istanbul ignore next */ () => { },\r\n onKeyDown: props.onKeyDown ? props.onKeyDown : /* istanbul ignore next */ (_e: React.KeyboardEvent) => { },\r\n }\r\n }>\r\n <ToolbarItemContext.Provider\r\n value={{\r\n hasOverflow: false,\r\n useHeight: false,\r\n onResize: /* istanbul ignore next */ () => { },\r\n }}\r\n >\r\n {(availableNodes.length > 0) &&\r\n <div\r\n className={className}\r\n style={props.style}\r\n onKeyDown={props.onKeyDown}\r\n role=\"presentation\"\r\n >\r\n <ToolbarItems\r\n className=\"components-items\"\r\n direction={direction}\r\n >\r\n {availableNodes.map((child, index) => <div key={index} className={`${wrapperClassName} ${getItemWrapperClass(child)}`}>{child}</div>)}\r\n </ToolbarItems>\r\n </div>\r\n }\r\n </ToolbarItemContext.Provider>\r\n </ToolbarWithOverflowDirectionContext.Provider >\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"Toolbar.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Toolbar.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB,4DAAoC;AACpC,6CAA+B;AAK/B,mCAAuC;AACvC,qDAAmG;AACnG,+DAAyL;AAsBzL,SAAS,mBAAmB,CAAC,KAAsB;IACjD,uBAAuB;IACvB,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK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CAAC,CAAC,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC;YAClG,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,EAAuB,EAAE,EAAE,GAAG,CAAC;SAC3G;QAED,oBAAC,wCAAkB,CAAC,QAAQ,IAC1B,KAAK,EAAE;gBACL,WAAW,EAAE,KAAK;gBAClB,SAAS,EAAE,KAAK;gBAChB,QAAQ,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC;aAC/C,IAEA,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC1B,6BACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,IAAI,EAAC,cAAc;gBAEnB,oBAAC,oBAAY,IACX,SAAS,EAAC,kBAAkB,EAC5B,SAAS,EAAE,SAAS,IAEnB,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,6BAAK,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,gBAAgB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,IAAG,KAAK,CAAO,CAAC,CACxH,CACX,CAEoB,CACgB,CACjD,CAAC;AACJ,CAAC;AAjFD,0BAiFC","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 Toolbar\r\n */\r\n\r\nimport \"./Toolbar.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n CommonToolbarItem, OnItemExecutedFunc,\r\n} from \"@itwin/appui-abstract\";\r\nimport { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\r\nimport { ToolbarItems } from \"./Items\";\r\nimport { Direction, OrthogonalDirection, OrthogonalDirectionHelpers } from \"./utilities/Direction\";\r\nimport { getToolbarDirection, ToolbarItemComponent, ToolbarItemContext, ToolbarOpacitySetting, ToolbarPanelAlignment, ToolbarWithOverflowDirectionContext } from \"./ToolbarWithOverflow\";\r\n\r\n/** Properties of [[Toolbar]] component.\r\n * @public\r\n */\r\nexport interface ToolbarProps extends CommonProps, NoChildrenProps {\r\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\r\n expandsTo?: Direction;\r\n /** definitions for items of the toolbar. i.e. [[CommonToolbarItem]]. Items are expected to be already sorted by group and item. */\r\n items: CommonToolbarItem[];\r\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\r\n panelAlignment?: ToolbarPanelAlignment;\r\n /** Use Drag Interaction to open popups with nest action buttons */\r\n useDragInteraction?: boolean;\r\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\r\n toolbarOpacitySetting?: ToolbarOpacitySetting;\r\n /** Optional function to call on any item execution */\r\n onItemExecuted?: OnItemExecutedFunc;\r\n /** Optional function to call on any KeyDown events processed by toolbar */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\nfunction getItemWrapperClass(child: React.ReactNode) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child)) {\r\n if (child.props && child.props.addGroupSeparator)\r\n return \"components-toolbar-button-add-gap-before\";\r\n }\r\n return \"\";\r\n}\r\n\r\n/** Component that displays tool settings as a bar across the top of the content view.\r\n * @public\r\n */\r\nexport function Toolbar(props: ToolbarProps) {\r\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\r\n const useDragInteraction = !!props.useDragInteraction;\r\n const panelAlignment = props.panelAlignment ? props.panelAlignment : ToolbarPanelAlignment.Start;\r\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\r\n\r\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n // use setTimeout to avoid warning about setting state in Toolbar from render method of PopupItem/PopupItemWithDrag\r\n setTimeout(() => {\r\n setPopupPanelCount((prev) => {\r\n const nextCount = isOpening ? (prev + 1) : (prev - 1);\r\n // eslint-disable-next-line no-console\r\n // console.log(`new popup count = ${nextCount}`);\r\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\r\n });\r\n });\r\n }, []);\r\n\r\n const availableNodes = React.useMemo<React.ReactNode[]>(() => {\r\n return props.items.map((item, index) => {\r\n let addGroupSeparator = false;\r\n if (index > 0)\r\n addGroupSeparator = item.groupPriority !== props.items[index - 1].groupPriority;\r\n return (\r\n <ToolbarItemComponent\r\n key={item.id}\r\n item={item}\r\n addGroupSeparator={!!addGroupSeparator}\r\n />\r\n );\r\n });\r\n }, [props.items]);\r\n\r\n const direction = getToolbarDirection(expandsTo);\r\n const className = classnames(\r\n \"components-toolbar-overflow-sizer\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n props.className);\r\n\r\n // needed to construct DOM structure identical to ToolbarWithOverflow so same css can be applied.\r\n const wrapperClassName = classnames(\r\n \"components-toolbar-item-container\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n );\r\n\r\n return (\r\n <ToolbarWithOverflowDirectionContext.Provider value={\r\n {\r\n expandsTo, direction, overflowExpandsTo: Direction.Right, panelAlignment, useDragInteraction,\r\n toolbarOpacitySetting: props.toolbarOpacitySetting ? props.toolbarOpacitySetting : ToolbarOpacitySetting.Proximity,\r\n overflowDirection: OrthogonalDirection.Horizontal,\r\n openPopupCount: popupPanelCount, onPopupPanelOpenClose: handlePopupPanelOpenClose, overflowDisplayActive: false,\r\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : /* istanbul ignore next */ () => { },\r\n onKeyDown: props.onKeyDown ? props.onKeyDown : /* istanbul ignore next */ (_e: React.KeyboardEvent) => { },\r\n }\r\n }>\r\n <ToolbarItemContext.Provider\r\n value={{\r\n hasOverflow: false,\r\n useHeight: false,\r\n onResize: /* istanbul ignore next */ () => { },\r\n }}\r\n >\r\n {(availableNodes.length > 0) &&\r\n <div\r\n className={className}\r\n style={props.style}\r\n onKeyDown={props.onKeyDown}\r\n role=\"presentation\"\r\n >\r\n <ToolbarItems\r\n className=\"components-items\"\r\n direction={direction}\r\n >\r\n {availableNodes.map((child, index) => <div key={index} className={`${wrapperClassName} ${getItemWrapperClass(child)}`}>{child}</div>)}\r\n </ToolbarItems>\r\n </div>\r\n }\r\n </ToolbarItemContext.Provider>\r\n </ToolbarWithOverflowDirectionContext.Provider >\r\n );\r\n}\r\n"]}
@@ -226,8 +226,8 @@ function ToolbarWithOverflow(props) {
226
226
  };
227
227
  });
228
228
  const handlePopupPanelOpenClose = React.useCallback((isOpening) => {
229
- // use setImmediate to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag
230
- setImmediate(() => {
229
+ // use setTimeout to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag
230
+ setTimeout(() => {
231
231
  // istanbul ignore next
232
232
  if (!isMounted.current)
233
233
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"ToolbarWithOverflow.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ToolbarWithOverflow.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAsG;AACtG,iCAA2C;AAC3C,mCAAuC;AACvC,+CAA8E;AAC9E,yCAAmD;AACnD,mDAAuD;AACvD,2CAAwC;AACxC,uDAAoD;AACpD,2DAAwD;AACxD,qDAAqH;AACrH,kDAA+C;AAe/C;;;GAGG;AACH,gEAAgE;AACnD,QAAA,2BAA2B,GAAG,KAAK,CAAC,aAAa,CAAU,KAAK,CAAC,CAAC;AAE/E;;;GAGG;AACH,SAAgB,8BAA8B;IAC5C,OAAO,KAAK,CAAC,UAAU,CA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,0BAAkB,CAAC,CAAC;AAC9C,CAAC;AAFD,0DAEC;AAED,SAAS,kBAAkB,CAAI,GAA+B;IAC5D,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE;QACzB,4CAA4C;QAC5C,IAAI,GAAG,KAAK,SAAS;YACnB,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,GAAqB,CAAC;AAC/B,CAAC;AAED,SAAS,GAAG,CAAC,IAAmC,EAAE,KAAwB;IACxE,IAAI,CAAC,IAAI;QACP,OAAO,KAAK,CAAC;IACf,uBAAuB;IACvB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC9B,OAAO,KAAK,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC;YACT,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,IAAI,CAAC;AACd,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 Toolbar\r\n */\r\n\r\nimport \"./Toolbar.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ActionButton, CommonToolbarItem, ConditionalBooleanValue, ConditionalStringValue, CustomButtonDefinition,\r\n GroupButton, OnItemExecutedFunc, ToolbarItemUtilities,\r\n} from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, CommonProps, IconHelper, NoChildrenProps, useRefs } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItem } from \"./Item\";\r\nimport { ToolbarItems } from \"./Items\";\r\nimport { ItemWrapper, useResizeObserverSingleDimension } from \"./ItemWrapper\";\r\nimport { ToolbarOverflowButton } from \"./Overflow\";\r\nimport { ToolbarOverflowPanel } from \"./OverflowPanel\";\r\nimport { PopupItem } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { PopupItemWithDrag } from \"./PopupItemWithDrag\";\r\nimport { Direction, DirectionHelpers, OrthogonalDirection, OrthogonalDirectionHelpers } from \"./utilities/Direction\";\r\nimport { UiComponents } from \"../UiComponents\";\r\n\r\n/** Describes the data needed to insert a custom `React` button into an ToolbarWithOverflow.\r\n * @public\r\n */\r\nexport interface CustomToolbarItem extends CustomButtonDefinition {\r\n /** React node that must result in providing a PopupItem @deprecated use panelContentNode */\r\n buttonNode?: React.ReactNode;\r\n /** defines the content to display in popup panel */\r\n panelContentNode?: React.ReactNode;\r\n /** If true the popup panel is mounted once and unmounted when button is unmounted. If false the\r\n * content node is unmounted each time the popup is closed. */\r\n keepContentsLoaded?: boolean;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar items to know if popup panel should be hidden - via AutoHide.\r\n * @public\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarPopupAutoHideContext = React.createContext<boolean>(false);\r\n\r\n/**\r\n * React hook used to retrieve the ToolbarPopupAutoHideContext.\r\n * @public\r\n */\r\nexport function useToolbarPopupAutoHideContext() {\r\n return React.useContext(ToolbarPopupAutoHideContext);\r\n}\r\n\r\n/** Describes toolbar item.\r\n * @public\r\n */\r\nexport type ToolbarItem = ActionButton | GroupButton | CustomToolbarItem;\r\n\r\n/** CustomToolbarItem type guard.\r\n * @internal\r\n */\r\nexport function isCustomToolbarItem(item: ToolbarItem): item is CustomToolbarItem {\r\n return !!(item as CustomToolbarItem).isCustom && ((\"buttonNode\" in item) || (\"panelContentNode\" in item));\r\n}\r\n\r\n/** @internal */\r\nexport const getToolbarDirection = (expandsTo: Direction): OrthogonalDirection => {\r\n const orthogonalDirection = DirectionHelpers.getOrthogonalDirection(expandsTo);\r\n return OrthogonalDirectionHelpers.inverse(orthogonalDirection);\r\n};\r\n\r\n/** Available alignment modes of [[ToolbarWithOverflow]] panels.\r\n * @public\r\n */\r\nexport enum ToolbarPanelAlignment {\r\n Start,\r\n End,\r\n}\r\n\r\n/** Enumeration of Toolbar Opacity setting.\r\n * @public\r\n */\r\nexport enum ToolbarOpacitySetting {\r\n /** Use the default background, box-shadow opacity and backdrop-filter blur */\r\n Defaults,\r\n /** Alter the opacity from transparent to the defaults based on mouse proximity */\r\n Proximity,\r\n /** Use a transparent background, box-shadow opacity and backdrop-filter blur */\r\n Transparent,\r\n}\r\n\r\n/** Helpers for [[ToolbarPanelAlignment]].\r\n * @internal\r\n */\r\nexport class ToolbarPanelAlignmentHelpers {\r\n /** Class name of [[ToolbarPanelAlignment.Start]] */\r\n public static readonly START_CLASS_NAME = \"components-panel-alignment-start\";\r\n /** Class name of [[ToolbarPanelAlignment.End]] */\r\n public static readonly END_CLASS_NAME = \"components-panel-alignment-end\";\r\n\r\n /** @returns Class name of specified [[ToolbarPanelAlignment]] */\r\n public static getCssClassName(panelAlignment: ToolbarPanelAlignment): string {\r\n switch (panelAlignment) {\r\n case ToolbarPanelAlignment.Start:\r\n return ToolbarPanelAlignmentHelpers.START_CLASS_NAME;\r\n case ToolbarPanelAlignment.End:\r\n return ToolbarPanelAlignmentHelpers.END_CLASS_NAME;\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface ToolbarOverflowContextProps {\r\n readonly expandsTo: Direction;\r\n readonly direction: OrthogonalDirection;\r\n readonly overflowExpandsTo: Direction;\r\n readonly overflowDirection: OrthogonalDirection;\r\n readonly panelAlignment: ToolbarPanelAlignment;\r\n readonly useDragInteraction: boolean;\r\n readonly toolbarOpacitySetting: ToolbarOpacitySetting;\r\n readonly openPopupCount: number;\r\n readonly onPopupPanelOpenClose: (isOpening: boolean) => void;\r\n readonly overflowDisplayActive: boolean;\r\n readonly onItemExecuted: OnItemExecutedFunc;\r\n readonly onKeyDown: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar component to provide Direction to child components.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarWithOverflowDirectionContext = React.createContext<ToolbarOverflowContextProps>({\r\n expandsTo: Direction.Bottom,\r\n direction: OrthogonalDirection.Horizontal,\r\n overflowExpandsTo: Direction.Right,\r\n overflowDirection: OrthogonalDirection.Vertical,\r\n panelAlignment: ToolbarPanelAlignment.Start,\r\n useDragInteraction: false,\r\n toolbarOpacitySetting: ToolbarOpacitySetting.Proximity,\r\n openPopupCount: 0,\r\n onPopupPanelOpenClose: /* istanbul ignore next */ (_isOpening: boolean) => { },\r\n overflowDisplayActive: false,\r\n onItemExecuted: /* istanbul ignore next */ (_item: any) => void {},\r\n onKeyDown: /* istanbul ignore next */ (_e: React.KeyboardEvent) => void {},\r\n});\r\n\r\n/** @internal */\r\nexport function CustomItem({ item, addGroupSeparator }: { item: CustomToolbarItem, addGroupSeparator: boolean }) {\r\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\r\n const icon = React.useMemo(() => (item.icon &&\r\n IconHelper.getIconReactNode(item.icon, item.internalData)) || /* istanbul ignore next */\r\n <i className=\"icon icon-placeholder\" />, [item.icon, item.internalData]);\r\n const isDisabled = React.useMemo(() => ConditionalBooleanValue.getValue(item.isDisabled), [item.isDisabled]);\r\n const title = React.useMemo(() => /* istanbul ignore next */ ConditionalStringValue.getValue(item.label) ?? item.id, [item.id, item.label]);\r\n const badge = React.useMemo(() => BadgeUtilities.getComponentForBadgeType(item.badgeType), [item.badgeType]);\r\n\r\n if (item.panelContentNode) {\r\n return <PopupItem\r\n key={item.id}\r\n itemId={item.id}\r\n icon={icon}\r\n isDisabled={isDisabled}\r\n title={title}\r\n panel={item.panelContentNode}\r\n hideIndicator={useDragInteraction}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n keepContentsMounted={item.keepContentsLoaded}\r\n />;\r\n }\r\n\r\n // istanbul ignore else\r\n if (item.buttonNode)\r\n return <>{item.buttonNode}</>;\r\n\r\n // istanbul ignore next\r\n return null;\r\n}\r\n\r\n/** @internal */\r\nexport function GroupPopupItem({ item, addGroupSeparator }: { item: GroupButton, addGroupSeparator: boolean }) {\r\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\r\n const title = ConditionalStringValue.getValue(item.label)!;\r\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\r\n const panel = React.useMemo(() => <PopupItemsPanel groupItem={item} activateOnPointerUp={false} />, [item]);\r\n if (useDragInteraction) {\r\n return <PopupItemWithDrag\r\n key={item.id}\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n groupItem={item}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n }\r\n return <PopupItem\r\n key={item.id}\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n panel={panel}\r\n badge={badge}\r\n hideIndicator={useDragInteraction}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n}\r\n\r\n/** @internal */\r\nexport function ActionItem({ item, addGroupSeparator }: { item: ActionButton, addGroupSeparator: boolean }) {\r\n const title = ConditionalStringValue.getValue(item.label)!;\r\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\r\n const { onItemExecuted } = useToolbarWithOverflowDirectionContext();\r\n const onExecute = React.useCallback(() => {\r\n item.execute();\r\n onItemExecuted(item);\r\n }, [item, onItemExecuted]);\r\n\r\n return <ToolbarButtonItem\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n key={item.id}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isActive={item.isActive}\r\n onClick={onExecute}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n}\r\n\r\n/** @internal */\r\nexport function ToolbarItemComponent({ item, addGroupSeparator }: { item: ToolbarItem, addGroupSeparator: boolean }) {\r\n if (ToolbarItemUtilities.isGroupButton(item)) {\r\n return <GroupPopupItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n } else if (isCustomToolbarItem(item)) {\r\n return <CustomItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(item)) {\r\n return <ActionItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n }\r\n }\r\n // istanbul ignore next\r\n return null;\r\n}\r\n\r\n/** @internal */\r\nexport function useToolbarWithOverflowDirectionContext() {\r\n return React.useContext(ToolbarWithOverflowDirectionContext);\r\n}\r\n\r\nfunction OverflowItemsContainer(p: { children: React.ReactNode }) {\r\n return <>{p.children}</>;\r\n}\r\n\r\nfunction getItemWrapperClass(child: React.ReactNode) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child)) {\r\n if (child.props && child.props.addGroupSeparator)\r\n return \"components-toolbar-button-add-gap-before\";\r\n }\r\n return undefined;\r\n}\r\n\r\n/** Properties of [[ToolbarWithOverflow]] component.\r\n * @public\r\n */\r\nexport interface ToolbarWithOverflowProps extends CommonProps, NoChildrenProps {\r\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\r\n expandsTo?: Direction;\r\n /** Describes to which direction the overflow popup panels are expanded. Defaults to: [[Direction.Right]] */\r\n overflowExpandsTo?: Direction;\r\n /** definitions for items of the toolbar. i.e. [[CommonToolbarItem]]. Items are expected to be already sorted by group and item. */\r\n items: CommonToolbarItem[];\r\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\r\n panelAlignment?: ToolbarPanelAlignment;\r\n /** Use Drag Interaction to open popups with nest action buttons */\r\n useDragInteraction?: boolean;\r\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\r\n toolbarOpacitySetting?: ToolbarOpacitySetting;\r\n /** Optional function to call on any item execution */\r\n onItemExecuted?: OnItemExecutedFunc;\r\n /** Optional function to call on any KeyDown events processed by toolbar */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\n/** Component that displays tool settings as a bar across the top of the content view.\r\n * @public\r\n */\r\nexport function ToolbarWithOverflow(props: ToolbarWithOverflowProps) {\r\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\r\n const useDragInteraction = !!props.useDragInteraction;\r\n const panelAlignment = props.panelAlignment ? props.panelAlignment : ToolbarPanelAlignment.Start;\r\n const useHeight = (expandsTo === Direction.Right || expandsTo === Direction.Left);\r\n const [isOverflowPanelOpen, setIsOverflowPanelOpen] = React.useState(false);\r\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\r\n const overflowTitle = React.useRef(UiComponents.translate(\"toolbar.overflow\"));\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n });\r\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n // use setImmediate to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag\r\n setImmediate(() => {\r\n // istanbul ignore next\r\n if (!isMounted.current)\r\n return;\r\n setPopupPanelCount((prev) => {\r\n const nextCount = isOpening ? (prev + 1) : (prev - 1);\r\n // eslint-disable-next-line no-console\r\n // console.log(`new popup count = ${nextCount}`);\r\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\r\n });\r\n });\r\n }, []);\r\n\r\n const ref = React.useRef<HTMLDivElement>(null);\r\n const width = React.useRef<number | undefined>(undefined);\r\n const availableNodes = React.useMemo<React.ReactNode>(() => {\r\n return props.items.map((item, index) => {\r\n let addGroupSeparator = false;\r\n if (index > 0)\r\n addGroupSeparator = item.groupPriority !== props.items[index - 1].groupPriority;\r\n return (\r\n <ToolbarItemComponent\r\n key={item.id}\r\n item={item}\r\n addGroupSeparator={!!addGroupSeparator}\r\n />\r\n );\r\n });\r\n }, [props.items]);\r\n /* overflowItemKeys - keys of items to show in overflow panel\r\n * handleContainerResize - handler called when container <div> is resized.\r\n * handleOverflowResize - handler called when determining size of overflow indicator/button.\r\n * handleEntryResize - handler called when determining size of each item/button. */\r\n const [overflowItemKeys, handleContainerResize, handleOverflowResize, handleEntryResize] = useOverflow(availableNodes, panelAlignment === ToolbarPanelAlignment.End);\r\n // handler called by ResizeObserver\r\n const handleResize = React.useCallback((w: number) => {\r\n width.current = w;\r\n width.current !== undefined && handleContainerResize(width.current);\r\n }, [handleContainerResize]);\r\n const resizeObserverRef = useResizeObserverSingleDimension(handleResize, useHeight);\r\n const handleClick = React.useCallback(() => {\r\n setIsOverflowPanelOpen((prev) => !prev);\r\n }, []);\r\n // istanbul ignore next - NEEDSWORK add complete tests\r\n const handleClose = React.useCallback(() => {\r\n setIsOverflowPanelOpen(false);\r\n }, []);\r\n\r\n const refs = useRefs(ref, resizeObserverRef);\r\n const availableItems = React.Children.toArray(availableNodes);\r\n const displayedItems = availableItems.reduce<Array<[string, React.ReactNode]>>((acc, child, index) => {\r\n const key = getChildKey(child, index);\r\n if (!overflowItemKeys || overflowItemKeys.indexOf(key) < 0) {\r\n acc.push([key, child]);\r\n }\r\n return acc;\r\n }, []);\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const overflowPanelItems = overflowItemKeys ? availableItems.reduce<Array<[string, React.ReactNode]>>((acc, child, index) => {\r\n const key = getChildKey(child, index);\r\n if (overflowItemKeys.indexOf(key) >= 0) {\r\n acc.push([key, child]);\r\n }\r\n return acc;\r\n }, []) : [];\r\n\r\n const direction = getToolbarDirection(expandsTo);\r\n const overflowExpandsTo = undefined !== props.overflowExpandsTo ? props.overflowExpandsTo : Direction.Right;\r\n const addOverflowButton = React.useCallback((atStart: boolean) => {\r\n const overflowItems = !!atStart ? overflowPanelItems.reverse() : overflowPanelItems;\r\n return (<ToolbarItemContext.Provider\r\n value={{\r\n hasOverflow: false,\r\n useHeight,\r\n onResize: handleOverflowResize,\r\n }}\r\n >\r\n <ToolbarOverflowButton\r\n expandsTo={expandsTo}\r\n onClick={handleClick}\r\n onClose={handleClose}\r\n open={overflowItems.length > 0 && isOverflowPanelOpen}\r\n panelNode={\r\n <ToolbarOverflowPanel>\r\n <OverflowItemsContainer>\r\n {overflowItems.map(([key, child]) => {\r\n return (\r\n <ToolbarItemContext.Provider\r\n key={key}\r\n value={{\r\n hasOverflow: true,\r\n useHeight,\r\n onResize: () => { },\r\n }}\r\n >\r\n {<ItemWrapper className={getItemWrapperClass(child)}>{child}</ItemWrapper>}\r\n </ToolbarItemContext.Provider>\r\n );\r\n })}\r\n </OverflowItemsContainer>\r\n </ToolbarOverflowPanel>\r\n }\r\n title={overflowTitle.current}\r\n />\r\n </ToolbarItemContext.Provider>);\r\n }, [handleClick, handleClose, handleOverflowResize, isOverflowPanelOpen, expandsTo, overflowPanelItems, useHeight]);\r\n\r\n const className = classnames(\r\n \"components-toolbar-overflow-sizer\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n props.className);\r\n\r\n const showOverflowAtStart = (direction === OrthogonalDirection.Horizontal) && (panelAlignment === ToolbarPanelAlignment.End);\r\n /* The ItemWrapper is used to wrap the <Item> <ExpandableItem> with a <div> that specifies a ref that the sizing logic uses to determine the\r\n size of the item. */\r\n return (\r\n <ToolbarWithOverflowDirectionContext.Provider value={\r\n {\r\n expandsTo, direction, overflowExpandsTo, panelAlignment, useDragInteraction,\r\n toolbarOpacitySetting: undefined !== props.toolbarOpacitySetting ? props.toolbarOpacitySetting : ToolbarOpacitySetting.Proximity,\r\n overflowDirection: direction === OrthogonalDirection.Horizontal ? OrthogonalDirection.Vertical : OrthogonalDirection.Horizontal,\r\n openPopupCount: popupPanelCount,\r\n onPopupPanelOpenClose: handlePopupPanelOpenClose,\r\n overflowDisplayActive: overflowPanelItems.length > 0 && isOverflowPanelOpen,\r\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : () => { },\r\n onKeyDown: props.onKeyDown ? props.onKeyDown : /* istanbul ignore next */ (_e: React.KeyboardEvent) => { },\r\n }\r\n }>\r\n {(availableItems.length > 0) &&\r\n <div\r\n className={className}\r\n ref={refs}\r\n style={props.style}\r\n onKeyDown={props.onKeyDown}\r\n role=\"presentation\"\r\n >\r\n <ToolbarItems\r\n className=\"components-items\"\r\n direction={direction}\r\n >\r\n {(!overflowItemKeys || overflowItemKeys.length > 0) && showOverflowAtStart && addOverflowButton(true)}\r\n {displayedItems.map(([key, child]) => {\r\n const onEntryResize = handleEntryResize(key);\r\n return (\r\n <ToolbarItemContext.Provider\r\n key={key}\r\n value={{\r\n hasOverflow: false,\r\n useHeight,\r\n onResize: onEntryResize,\r\n }}\r\n >\r\n {<ItemWrapper className={getItemWrapperClass(child)}>{child}</ItemWrapper>}\r\n </ToolbarItemContext.Provider>\r\n );\r\n })}\r\n {(!overflowItemKeys || overflowItemKeys.length > 0) && !showOverflowAtStart && addOverflowButton(false)}\r\n\r\n </ToolbarItems>\r\n </div>\r\n }\r\n </ToolbarWithOverflowDirectionContext.Provider >\r\n );\r\n}\r\n\r\n/** Returns key of a child. Must be used along with React.Children.toArray to preserve the semantics of availableItems.\r\n * @internal\r\n */\r\nfunction getChildKey(child: React.ReactNode, index: number) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child) && child.key !== null) {\r\n return child.key.toString();\r\n }\r\n // istanbul ignore next\r\n return index.toString();\r\n}\r\n\r\n/** Returns a subset of toolbar item entry keys that exceed given width and should be overflowItemKeys.\r\n * @internal\r\n */\r\nfunction determineOverflowItems(size: number, entries: ReadonlyArray<readonly [string, number]>, overflowButtonSize: number, overflowButtonAtStart: boolean): string[] {\r\n let toolbarSize = 0;\r\n const buttonPadding = 2;\r\n if (overflowButtonAtStart && entries.length > 0) {\r\n let i = entries.length - 1;\r\n for (; i >= 0; i--) {\r\n const w = entries[i][1] + buttonPadding;\r\n const newSettingsWidth = toolbarSize + w;\r\n if (newSettingsWidth > size) {\r\n toolbarSize += (overflowButtonSize + buttonPadding);\r\n break;\r\n }\r\n toolbarSize = newSettingsWidth;\r\n }\r\n if (i >= 0) {\r\n let j = i + 1;\r\n for (; j < entries.length; j++) {\r\n if (toolbarSize <= size)\r\n break;\r\n const w = entries[j][1] + buttonPadding;\r\n toolbarSize -= w;\r\n }\r\n\r\n return entries.slice(0, j).map((e) => e[0]);\r\n } else {\r\n return [];\r\n }\r\n } else {\r\n let i = 0;\r\n for (; i < entries.length; i++) {\r\n const w = entries[i][1] + buttonPadding;\r\n const newSettingsWidth = toolbarSize + w;\r\n if (newSettingsWidth > size) {\r\n toolbarSize += (overflowButtonSize + buttonPadding);\r\n break;\r\n }\r\n toolbarSize = newSettingsWidth;\r\n }\r\n let j = i;\r\n for (; j > 0; j--) {\r\n if (toolbarSize <= size)\r\n break;\r\n const w = entries[j][1] + buttonPadding;\r\n toolbarSize -= w;\r\n }\r\n\r\n return entries.slice(j).map((e) => e[0]);\r\n }\r\n}\r\n\r\n/** Hook that returns a list of overflowItemKeys availableItems.\r\n * @internal\r\n */\r\nfunction useOverflow(availableItems: React.ReactNode, overflowButtonAtStart: boolean): [\r\n ReadonlyArray<string> | undefined,\r\n (size: number) => void,\r\n (size: number) => void,\r\n (key: string) => (size: number) => void,\r\n] {\r\n const [overflowItemKeys, setOverflown] = React.useState<ReadonlyArray<string>>();\r\n const itemSizes = React.useRef(new Map<string, number | undefined>());\r\n const size = React.useRef<number | undefined>(undefined);\r\n const overflowButtonSize = React.useRef<number | undefined>(undefined);\r\n\r\n const calculateOverflow = React.useCallback(() => {\r\n const sizes = verifiedMapEntries(itemSizes.current);\r\n if (size.current === undefined ||\r\n sizes === undefined ||\r\n overflowButtonSize.current === undefined) {\r\n setOverflown(undefined);\r\n return;\r\n }\r\n\r\n // Calculate overflow.\r\n const newOverflown = determineOverflowItems(size.current, [...sizes.entries()], overflowButtonSize.current, overflowButtonAtStart);\r\n setOverflown((prevOverflown) => {\r\n return eql(prevOverflown, newOverflown) ? prevOverflown : newOverflown;\r\n });\r\n }, [overflowButtonAtStart]);\r\n\r\n React.useLayoutEffect(() => {\r\n const newEntryWidths = new Map<string, number | undefined>();\r\n const array = React.Children.toArray(availableItems);\r\n for (let i = 0; i < array.length; i++) {\r\n const child = array[i];\r\n const key = getChildKey(child, i);\r\n const lastW = itemSizes.current.get(key);\r\n newEntryWidths.set(key, lastW);\r\n }\r\n itemSizes.current = newEntryWidths;\r\n calculateOverflow();\r\n }, [availableItems, calculateOverflow]);\r\n\r\n const handleContainerResize = React.useCallback((w: number) => {\r\n const calculate = size.current !== w;\r\n size.current = w;\r\n calculate && calculateOverflow();\r\n }, [calculateOverflow]);\r\n\r\n const handleOverflowResize = React.useCallback((w: number) => {\r\n const calculate = overflowButtonSize.current !== w;\r\n overflowButtonSize.current = w;\r\n calculate && calculateOverflow();\r\n }, [calculateOverflow]);\r\n\r\n const handleEntryResize = React.useCallback((key: string) => (w: number) => {\r\n const oldW = itemSizes.current.get(key);\r\n if (oldW !== w) {\r\n itemSizes.current.set(key, w);\r\n calculateOverflow();\r\n }\r\n }, [calculateOverflow]);\r\n\r\n return [overflowItemKeys, handleContainerResize, handleOverflowResize, handleEntryResize];\r\n}\r\n\r\n/** Interface toolbars use to define context for its items.\r\n * @internal\r\n */\r\nexport interface ToolbarItemContextArgs {\r\n readonly hasOverflow: boolean;\r\n readonly useHeight: boolean;\r\n readonly onResize: (w: number) => void;\r\n}\r\n\r\n/** Interface toolbars use to define context for its items.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarItemContext = React.createContext<ToolbarItemContextArgs>(null!);\r\n\r\n/** @internal */\r\nexport function useToolItemEntryContext() {\r\n return React.useContext(ToolbarItemContext);\r\n}\r\n\r\nfunction verifiedMapEntries<T>(map: Map<string, T | undefined>) {\r\n for (const [, val] of map) {\r\n // istanbul ignore next during unit testing\r\n if (val === undefined)\r\n return undefined;\r\n }\r\n return map as Map<string, T>;\r\n}\r\n\r\nfunction eql(prev: readonly string[] | undefined, value: readonly string[]) {\r\n if (!prev)\r\n return false;\r\n // istanbul ignore next\r\n if (prev.length !== value.length)\r\n return false;\r\n for (let i = 0; i < prev.length; i++) {\r\n const p = prev[i];\r\n const v = value[i];\r\n // istanbul ignore next\r\n if (p !== v)\r\n return false;\r\n }\r\n return true;\r\n}\r\n"]}
1
+ {"version":3,"file":"ToolbarWithOverflow.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/ToolbarWithOverflow.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAsG;AACtG,iCAA2C;AAC3C,mCAAuC;AACvC,+CAA8E;AAC9E,yCAAmD;AACnD,mDAAuD;AACvD,2CAAwC;AACxC,uDAAoD;AACpD,2DAAwD;AACxD,qDAAqH;AACrH,kDAA+C;AAe/C;;;GAGG;AACH,gEAAgE;AACnD,QAAA,2BAA2B,GAAG,KAAK,CAAC,aAAa,CAAU,KAAK,CAAC,CAAC;AAE/E;;;GAGG;AACH,SAAgB,8BAA8B;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,mCAA2B,CAAC,CAAC;AACvD,CAAC;AAFD,wEAEC;AAOD;;GAEG;AACH,SAAgB,mBAAmB,CAAC,IAAiB;IACnD,OAAO,CAAC,CAAE,IAA0B,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,IAA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,GAAG,KAAK,SAAS;YACnB,OAAO,SAAS,CAAC;KACpB;IACD,OAAO,GAAqB,CAAC;AAC/B,CAAC;AAED,SAAS,GAAG,CAAC,IAAmC,EAAE,KAAwB;IACxE,IAAI,CAAC,IAAI;QACP,OAAO,KAAK,CAAC;IACf,uBAAuB;IACvB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC9B,OAAO,KAAK,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC;YACT,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,IAAI,CAAC;AACd,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 Toolbar\r\n */\r\n\r\nimport \"./Toolbar.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport {\r\n ActionButton, CommonToolbarItem, ConditionalBooleanValue, ConditionalStringValue, CustomButtonDefinition,\r\n GroupButton, OnItemExecutedFunc, ToolbarItemUtilities,\r\n} from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, CommonProps, IconHelper, NoChildrenProps, useRefs } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItem } from \"./Item\";\r\nimport { ToolbarItems } from \"./Items\";\r\nimport { ItemWrapper, useResizeObserverSingleDimension } from \"./ItemWrapper\";\r\nimport { ToolbarOverflowButton } from \"./Overflow\";\r\nimport { ToolbarOverflowPanel } from \"./OverflowPanel\";\r\nimport { PopupItem } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { PopupItemWithDrag } from \"./PopupItemWithDrag\";\r\nimport { Direction, DirectionHelpers, OrthogonalDirection, OrthogonalDirectionHelpers } from \"./utilities/Direction\";\r\nimport { UiComponents } from \"../UiComponents\";\r\n\r\n/** Describes the data needed to insert a custom `React` button into an ToolbarWithOverflow.\r\n * @public\r\n */\r\nexport interface CustomToolbarItem extends CustomButtonDefinition {\r\n /** React node that must result in providing a PopupItem @deprecated use panelContentNode */\r\n buttonNode?: React.ReactNode;\r\n /** defines the content to display in popup panel */\r\n panelContentNode?: React.ReactNode;\r\n /** If true the popup panel is mounted once and unmounted when button is unmounted. If false the\r\n * content node is unmounted each time the popup is closed. */\r\n keepContentsLoaded?: boolean;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar items to know if popup panel should be hidden - via AutoHide.\r\n * @public\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarPopupAutoHideContext = React.createContext<boolean>(false);\r\n\r\n/**\r\n * React hook used to retrieve the ToolbarPopupAutoHideContext.\r\n * @public\r\n */\r\nexport function useToolbarPopupAutoHideContext() {\r\n return React.useContext(ToolbarPopupAutoHideContext);\r\n}\r\n\r\n/** Describes toolbar item.\r\n * @public\r\n */\r\nexport type ToolbarItem = ActionButton | GroupButton | CustomToolbarItem;\r\n\r\n/** CustomToolbarItem type guard.\r\n * @internal\r\n */\r\nexport function isCustomToolbarItem(item: ToolbarItem): item is CustomToolbarItem {\r\n return !!(item as CustomToolbarItem).isCustom && ((\"buttonNode\" in item) || (\"panelContentNode\" in item));\r\n}\r\n\r\n/** @internal */\r\nexport const getToolbarDirection = (expandsTo: Direction): OrthogonalDirection => {\r\n const orthogonalDirection = DirectionHelpers.getOrthogonalDirection(expandsTo);\r\n return OrthogonalDirectionHelpers.inverse(orthogonalDirection);\r\n};\r\n\r\n/** Available alignment modes of [[ToolbarWithOverflow]] panels.\r\n * @public\r\n */\r\nexport enum ToolbarPanelAlignment {\r\n Start,\r\n End,\r\n}\r\n\r\n/** Enumeration of Toolbar Opacity setting.\r\n * @public\r\n */\r\nexport enum ToolbarOpacitySetting {\r\n /** Use the default background, box-shadow opacity and backdrop-filter blur */\r\n Defaults,\r\n /** Alter the opacity from transparent to the defaults based on mouse proximity */\r\n Proximity,\r\n /** Use a transparent background, box-shadow opacity and backdrop-filter blur */\r\n Transparent,\r\n}\r\n\r\n/** Helpers for [[ToolbarPanelAlignment]].\r\n * @internal\r\n */\r\nexport class ToolbarPanelAlignmentHelpers {\r\n /** Class name of [[ToolbarPanelAlignment.Start]] */\r\n public static readonly START_CLASS_NAME = \"components-panel-alignment-start\";\r\n /** Class name of [[ToolbarPanelAlignment.End]] */\r\n public static readonly END_CLASS_NAME = \"components-panel-alignment-end\";\r\n\r\n /** @returns Class name of specified [[ToolbarPanelAlignment]] */\r\n public static getCssClassName(panelAlignment: ToolbarPanelAlignment): string {\r\n switch (panelAlignment) {\r\n case ToolbarPanelAlignment.Start:\r\n return ToolbarPanelAlignmentHelpers.START_CLASS_NAME;\r\n case ToolbarPanelAlignment.End:\r\n return ToolbarPanelAlignmentHelpers.END_CLASS_NAME;\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface ToolbarOverflowContextProps {\r\n readonly expandsTo: Direction;\r\n readonly direction: OrthogonalDirection;\r\n readonly overflowExpandsTo: Direction;\r\n readonly overflowDirection: OrthogonalDirection;\r\n readonly panelAlignment: ToolbarPanelAlignment;\r\n readonly useDragInteraction: boolean;\r\n readonly toolbarOpacitySetting: ToolbarOpacitySetting;\r\n readonly openPopupCount: number;\r\n readonly onPopupPanelOpenClose: (isOpening: boolean) => void;\r\n readonly overflowDisplayActive: boolean;\r\n readonly onItemExecuted: OnItemExecutedFunc;\r\n readonly onKeyDown: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar component to provide Direction to child components.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarWithOverflowDirectionContext = React.createContext<ToolbarOverflowContextProps>({\r\n expandsTo: Direction.Bottom,\r\n direction: OrthogonalDirection.Horizontal,\r\n overflowExpandsTo: Direction.Right,\r\n overflowDirection: OrthogonalDirection.Vertical,\r\n panelAlignment: ToolbarPanelAlignment.Start,\r\n useDragInteraction: false,\r\n toolbarOpacitySetting: ToolbarOpacitySetting.Proximity,\r\n openPopupCount: 0,\r\n onPopupPanelOpenClose: /* istanbul ignore next */ (_isOpening: boolean) => { },\r\n overflowDisplayActive: false,\r\n onItemExecuted: /* istanbul ignore next */ (_item: any) => void {},\r\n onKeyDown: /* istanbul ignore next */ (_e: React.KeyboardEvent) => void {},\r\n});\r\n\r\n/** @internal */\r\nexport function CustomItem({ item, addGroupSeparator }: { item: CustomToolbarItem, addGroupSeparator: boolean }) {\r\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\r\n const icon = React.useMemo(() => (item.icon &&\r\n IconHelper.getIconReactNode(item.icon, item.internalData)) || /* istanbul ignore next */\r\n <i className=\"icon icon-placeholder\" />, [item.icon, item.internalData]);\r\n const isDisabled = React.useMemo(() => ConditionalBooleanValue.getValue(item.isDisabled), [item.isDisabled]);\r\n const title = React.useMemo(() => /* istanbul ignore next */ ConditionalStringValue.getValue(item.label) ?? item.id, [item.id, item.label]);\r\n const badge = React.useMemo(() => BadgeUtilities.getComponentForBadgeType(item.badgeType), [item.badgeType]);\r\n\r\n if (item.panelContentNode) {\r\n return <PopupItem\r\n key={item.id}\r\n itemId={item.id}\r\n icon={icon}\r\n isDisabled={isDisabled}\r\n title={title}\r\n panel={item.panelContentNode}\r\n hideIndicator={useDragInteraction}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n keepContentsMounted={item.keepContentsLoaded}\r\n />;\r\n }\r\n\r\n // istanbul ignore else\r\n if (item.buttonNode)\r\n return <>{item.buttonNode}</>;\r\n\r\n // istanbul ignore next\r\n return null;\r\n}\r\n\r\n/** @internal */\r\nexport function GroupPopupItem({ item, addGroupSeparator }: { item: GroupButton, addGroupSeparator: boolean }) {\r\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\r\n const title = ConditionalStringValue.getValue(item.label)!;\r\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\r\n const panel = React.useMemo(() => <PopupItemsPanel groupItem={item} activateOnPointerUp={false} />, [item]);\r\n if (useDragInteraction) {\r\n return <PopupItemWithDrag\r\n key={item.id}\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n groupItem={item}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n }\r\n return <PopupItem\r\n key={item.id}\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n panel={panel}\r\n badge={badge}\r\n hideIndicator={useDragInteraction}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n}\r\n\r\n/** @internal */\r\nexport function ActionItem({ item, addGroupSeparator }: { item: ActionButton, addGroupSeparator: boolean }) {\r\n const title = ConditionalStringValue.getValue(item.label)!;\r\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\r\n const { onItemExecuted } = useToolbarWithOverflowDirectionContext();\r\n const onExecute = React.useCallback(() => {\r\n item.execute();\r\n onItemExecuted(item);\r\n }, [item, onItemExecuted]);\r\n\r\n return <ToolbarButtonItem\r\n itemId={item.id}\r\n providerId={item.providerId}\r\n itemPriority={item.itemPriority}\r\n groupPriority={item.groupPriority}\r\n key={item.id}\r\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\r\n title={title}\r\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\r\n isActive={item.isActive}\r\n onClick={onExecute}\r\n badge={badge}\r\n addGroupSeparator={addGroupSeparator}\r\n />;\r\n}\r\n\r\n/** @internal */\r\nexport function ToolbarItemComponent({ item, addGroupSeparator }: { item: ToolbarItem, addGroupSeparator: boolean }) {\r\n if (ToolbarItemUtilities.isGroupButton(item)) {\r\n return <GroupPopupItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n } else if (isCustomToolbarItem(item)) {\r\n return <CustomItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(item)) {\r\n return <ActionItem item={item} addGroupSeparator={addGroupSeparator} />;\r\n }\r\n }\r\n // istanbul ignore next\r\n return null;\r\n}\r\n\r\n/** @internal */\r\nexport function useToolbarWithOverflowDirectionContext() {\r\n return React.useContext(ToolbarWithOverflowDirectionContext);\r\n}\r\n\r\nfunction OverflowItemsContainer(p: { children: React.ReactNode }) {\r\n return <>{p.children}</>;\r\n}\r\n\r\nfunction getItemWrapperClass(child: React.ReactNode) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child)) {\r\n if (child.props && child.props.addGroupSeparator)\r\n return \"components-toolbar-button-add-gap-before\";\r\n }\r\n return undefined;\r\n}\r\n\r\n/** Properties of [[ToolbarWithOverflow]] component.\r\n * @public\r\n */\r\nexport interface ToolbarWithOverflowProps extends CommonProps, NoChildrenProps {\r\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\r\n expandsTo?: Direction;\r\n /** Describes to which direction the overflow popup panels are expanded. Defaults to: [[Direction.Right]] */\r\n overflowExpandsTo?: Direction;\r\n /** definitions for items of the toolbar. i.e. [[CommonToolbarItem]]. Items are expected to be already sorted by group and item. */\r\n items: CommonToolbarItem[];\r\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\r\n panelAlignment?: ToolbarPanelAlignment;\r\n /** Use Drag Interaction to open popups with nest action buttons */\r\n useDragInteraction?: boolean;\r\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\r\n toolbarOpacitySetting?: ToolbarOpacitySetting;\r\n /** Optional function to call on any item execution */\r\n onItemExecuted?: OnItemExecutedFunc;\r\n /** Optional function to call on any KeyDown events processed by toolbar */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n}\r\n\r\n/** Component that displays tool settings as a bar across the top of the content view.\r\n * @public\r\n */\r\nexport function ToolbarWithOverflow(props: ToolbarWithOverflowProps) {\r\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\r\n const useDragInteraction = !!props.useDragInteraction;\r\n const panelAlignment = props.panelAlignment ? props.panelAlignment : ToolbarPanelAlignment.Start;\r\n const useHeight = (expandsTo === Direction.Right || expandsTo === Direction.Left);\r\n const [isOverflowPanelOpen, setIsOverflowPanelOpen] = React.useState(false);\r\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\r\n const overflowTitle = React.useRef(UiComponents.translate(\"toolbar.overflow\"));\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n });\r\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n // use setTimeout to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag\r\n setTimeout(() => {\r\n // istanbul ignore next\r\n if (!isMounted.current)\r\n return;\r\n setPopupPanelCount((prev) => {\r\n const nextCount = isOpening ? (prev + 1) : (prev - 1);\r\n // eslint-disable-next-line no-console\r\n // console.log(`new popup count = ${nextCount}`);\r\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\r\n });\r\n });\r\n }, []);\r\n\r\n const ref = React.useRef<HTMLDivElement>(null);\r\n const width = React.useRef<number | undefined>(undefined);\r\n const availableNodes = React.useMemo<React.ReactNode>(() => {\r\n return props.items.map((item, index) => {\r\n let addGroupSeparator = false;\r\n if (index > 0)\r\n addGroupSeparator = item.groupPriority !== props.items[index - 1].groupPriority;\r\n return (\r\n <ToolbarItemComponent\r\n key={item.id}\r\n item={item}\r\n addGroupSeparator={!!addGroupSeparator}\r\n />\r\n );\r\n });\r\n }, [props.items]);\r\n /* overflowItemKeys - keys of items to show in overflow panel\r\n * handleContainerResize - handler called when container <div> is resized.\r\n * handleOverflowResize - handler called when determining size of overflow indicator/button.\r\n * handleEntryResize - handler called when determining size of each item/button. */\r\n const [overflowItemKeys, handleContainerResize, handleOverflowResize, handleEntryResize] = useOverflow(availableNodes, panelAlignment === ToolbarPanelAlignment.End);\r\n // handler called by ResizeObserver\r\n const handleResize = React.useCallback((w: number) => {\r\n width.current = w;\r\n width.current !== undefined && handleContainerResize(width.current);\r\n }, [handleContainerResize]);\r\n const resizeObserverRef = useResizeObserverSingleDimension(handleResize, useHeight);\r\n const handleClick = React.useCallback(() => {\r\n setIsOverflowPanelOpen((prev) => !prev);\r\n }, []);\r\n // istanbul ignore next - NEEDSWORK add complete tests\r\n const handleClose = React.useCallback(() => {\r\n setIsOverflowPanelOpen(false);\r\n }, []);\r\n\r\n const refs = useRefs(ref, resizeObserverRef);\r\n const availableItems = React.Children.toArray(availableNodes);\r\n const displayedItems = availableItems.reduce<Array<[string, React.ReactNode]>>((acc, child, index) => {\r\n const key = getChildKey(child, index);\r\n if (!overflowItemKeys || overflowItemKeys.indexOf(key) < 0) {\r\n acc.push([key, child]);\r\n }\r\n return acc;\r\n }, []);\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n const overflowPanelItems = overflowItemKeys ? availableItems.reduce<Array<[string, React.ReactNode]>>((acc, child, index) => {\r\n const key = getChildKey(child, index);\r\n if (overflowItemKeys.indexOf(key) >= 0) {\r\n acc.push([key, child]);\r\n }\r\n return acc;\r\n }, []) : [];\r\n\r\n const direction = getToolbarDirection(expandsTo);\r\n const overflowExpandsTo = undefined !== props.overflowExpandsTo ? props.overflowExpandsTo : Direction.Right;\r\n const addOverflowButton = React.useCallback((atStart: boolean) => {\r\n const overflowItems = !!atStart ? overflowPanelItems.reverse() : overflowPanelItems;\r\n return (<ToolbarItemContext.Provider\r\n value={{\r\n hasOverflow: false,\r\n useHeight,\r\n onResize: handleOverflowResize,\r\n }}\r\n >\r\n <ToolbarOverflowButton\r\n expandsTo={expandsTo}\r\n onClick={handleClick}\r\n onClose={handleClose}\r\n open={overflowItems.length > 0 && isOverflowPanelOpen}\r\n panelNode={\r\n <ToolbarOverflowPanel>\r\n <OverflowItemsContainer>\r\n {overflowItems.map(([key, child]) => {\r\n return (\r\n <ToolbarItemContext.Provider\r\n key={key}\r\n value={{\r\n hasOverflow: true,\r\n useHeight,\r\n onResize: () => { },\r\n }}\r\n >\r\n {<ItemWrapper className={getItemWrapperClass(child)}>{child}</ItemWrapper>}\r\n </ToolbarItemContext.Provider>\r\n );\r\n })}\r\n </OverflowItemsContainer>\r\n </ToolbarOverflowPanel>\r\n }\r\n title={overflowTitle.current}\r\n />\r\n </ToolbarItemContext.Provider>);\r\n }, [handleClick, handleClose, handleOverflowResize, isOverflowPanelOpen, expandsTo, overflowPanelItems, useHeight]);\r\n\r\n const className = classnames(\r\n \"components-toolbar-overflow-sizer\",\r\n OrthogonalDirectionHelpers.getCssClassName(direction),\r\n props.className);\r\n\r\n const showOverflowAtStart = (direction === OrthogonalDirection.Horizontal) && (panelAlignment === ToolbarPanelAlignment.End);\r\n /* The ItemWrapper is used to wrap the <Item> <ExpandableItem> with a <div> that specifies a ref that the sizing logic uses to determine the\r\n size of the item. */\r\n return (\r\n <ToolbarWithOverflowDirectionContext.Provider value={\r\n {\r\n expandsTo, direction, overflowExpandsTo, panelAlignment, useDragInteraction,\r\n toolbarOpacitySetting: undefined !== props.toolbarOpacitySetting ? props.toolbarOpacitySetting : ToolbarOpacitySetting.Proximity,\r\n overflowDirection: direction === OrthogonalDirection.Horizontal ? OrthogonalDirection.Vertical : OrthogonalDirection.Horizontal,\r\n openPopupCount: popupPanelCount,\r\n onPopupPanelOpenClose: handlePopupPanelOpenClose,\r\n overflowDisplayActive: overflowPanelItems.length > 0 && isOverflowPanelOpen,\r\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : () => { },\r\n onKeyDown: props.onKeyDown ? props.onKeyDown : /* istanbul ignore next */ (_e: React.KeyboardEvent) => { },\r\n }\r\n }>\r\n {(availableItems.length > 0) &&\r\n <div\r\n className={className}\r\n ref={refs}\r\n style={props.style}\r\n onKeyDown={props.onKeyDown}\r\n role=\"presentation\"\r\n >\r\n <ToolbarItems\r\n className=\"components-items\"\r\n direction={direction}\r\n >\r\n {(!overflowItemKeys || overflowItemKeys.length > 0) && showOverflowAtStart && addOverflowButton(true)}\r\n {displayedItems.map(([key, child]) => {\r\n const onEntryResize = handleEntryResize(key);\r\n return (\r\n <ToolbarItemContext.Provider\r\n key={key}\r\n value={{\r\n hasOverflow: false,\r\n useHeight,\r\n onResize: onEntryResize,\r\n }}\r\n >\r\n {<ItemWrapper className={getItemWrapperClass(child)}>{child}</ItemWrapper>}\r\n </ToolbarItemContext.Provider>\r\n );\r\n })}\r\n {(!overflowItemKeys || overflowItemKeys.length > 0) && !showOverflowAtStart && addOverflowButton(false)}\r\n\r\n </ToolbarItems>\r\n </div>\r\n }\r\n </ToolbarWithOverflowDirectionContext.Provider >\r\n );\r\n}\r\n\r\n/** Returns key of a child. Must be used along with React.Children.toArray to preserve the semantics of availableItems.\r\n * @internal\r\n */\r\nfunction getChildKey(child: React.ReactNode, index: number) {\r\n // istanbul ignore else\r\n if (React.isValidElement(child) && child.key !== null) {\r\n return child.key.toString();\r\n }\r\n // istanbul ignore next\r\n return index.toString();\r\n}\r\n\r\n/** Returns a subset of toolbar item entry keys that exceed given width and should be overflowItemKeys.\r\n * @internal\r\n */\r\nfunction determineOverflowItems(size: number, entries: ReadonlyArray<readonly [string, number]>, overflowButtonSize: number, overflowButtonAtStart: boolean): string[] {\r\n let toolbarSize = 0;\r\n const buttonPadding = 2;\r\n if (overflowButtonAtStart && entries.length > 0) {\r\n let i = entries.length - 1;\r\n for (; i >= 0; i--) {\r\n const w = entries[i][1] + buttonPadding;\r\n const newSettingsWidth = toolbarSize + w;\r\n if (newSettingsWidth > size) {\r\n toolbarSize += (overflowButtonSize + buttonPadding);\r\n break;\r\n }\r\n toolbarSize = newSettingsWidth;\r\n }\r\n if (i >= 0) {\r\n let j = i + 1;\r\n for (; j < entries.length; j++) {\r\n if (toolbarSize <= size)\r\n break;\r\n const w = entries[j][1] + buttonPadding;\r\n toolbarSize -= w;\r\n }\r\n\r\n return entries.slice(0, j).map((e) => e[0]);\r\n } else {\r\n return [];\r\n }\r\n } else {\r\n let i = 0;\r\n for (; i < entries.length; i++) {\r\n const w = entries[i][1] + buttonPadding;\r\n const newSettingsWidth = toolbarSize + w;\r\n if (newSettingsWidth > size) {\r\n toolbarSize += (overflowButtonSize + buttonPadding);\r\n break;\r\n }\r\n toolbarSize = newSettingsWidth;\r\n }\r\n let j = i;\r\n for (; j > 0; j--) {\r\n if (toolbarSize <= size)\r\n break;\r\n const w = entries[j][1] + buttonPadding;\r\n toolbarSize -= w;\r\n }\r\n\r\n return entries.slice(j).map((e) => e[0]);\r\n }\r\n}\r\n\r\n/** Hook that returns a list of overflowItemKeys availableItems.\r\n * @internal\r\n */\r\nfunction useOverflow(availableItems: React.ReactNode, overflowButtonAtStart: boolean): [\r\n ReadonlyArray<string> | undefined,\r\n (size: number) => void,\r\n (size: number) => void,\r\n (key: string) => (size: number) => void,\r\n] {\r\n const [overflowItemKeys, setOverflown] = React.useState<ReadonlyArray<string>>();\r\n const itemSizes = React.useRef(new Map<string, number | undefined>());\r\n const size = React.useRef<number | undefined>(undefined);\r\n const overflowButtonSize = React.useRef<number | undefined>(undefined);\r\n\r\n const calculateOverflow = React.useCallback(() => {\r\n const sizes = verifiedMapEntries(itemSizes.current);\r\n if (size.current === undefined ||\r\n sizes === undefined ||\r\n overflowButtonSize.current === undefined) {\r\n setOverflown(undefined);\r\n return;\r\n }\r\n\r\n // Calculate overflow.\r\n const newOverflown = determineOverflowItems(size.current, [...sizes.entries()], overflowButtonSize.current, overflowButtonAtStart);\r\n setOverflown((prevOverflown) => {\r\n return eql(prevOverflown, newOverflown) ? prevOverflown : newOverflown;\r\n });\r\n }, [overflowButtonAtStart]);\r\n\r\n React.useLayoutEffect(() => {\r\n const newEntryWidths = new Map<string, number | undefined>();\r\n const array = React.Children.toArray(availableItems);\r\n for (let i = 0; i < array.length; i++) {\r\n const child = array[i];\r\n const key = getChildKey(child, i);\r\n const lastW = itemSizes.current.get(key);\r\n newEntryWidths.set(key, lastW);\r\n }\r\n itemSizes.current = newEntryWidths;\r\n calculateOverflow();\r\n }, [availableItems, calculateOverflow]);\r\n\r\n const handleContainerResize = React.useCallback((w: number) => {\r\n const calculate = size.current !== w;\r\n size.current = w;\r\n calculate && calculateOverflow();\r\n }, [calculateOverflow]);\r\n\r\n const handleOverflowResize = React.useCallback((w: number) => {\r\n const calculate = overflowButtonSize.current !== w;\r\n overflowButtonSize.current = w;\r\n calculate && calculateOverflow();\r\n }, [calculateOverflow]);\r\n\r\n const handleEntryResize = React.useCallback((key: string) => (w: number) => {\r\n const oldW = itemSizes.current.get(key);\r\n if (oldW !== w) {\r\n itemSizes.current.set(key, w);\r\n calculateOverflow();\r\n }\r\n }, [calculateOverflow]);\r\n\r\n return [overflowItemKeys, handleContainerResize, handleOverflowResize, handleEntryResize];\r\n}\r\n\r\n/** Interface toolbars use to define context for its items.\r\n * @internal\r\n */\r\nexport interface ToolbarItemContextArgs {\r\n readonly hasOverflow: boolean;\r\n readonly useHeight: boolean;\r\n readonly onResize: (w: number) => void;\r\n}\r\n\r\n/** Interface toolbars use to define context for its items.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarItemContext = React.createContext<ToolbarItemContextArgs>(null!);\r\n\r\n/** @internal */\r\nexport function useToolItemEntryContext() {\r\n return React.useContext(ToolbarItemContext);\r\n}\r\n\r\nfunction verifiedMapEntries<T>(map: Map<string, T | undefined>) {\r\n for (const [, val] of map) {\r\n // istanbul ignore next during unit testing\r\n if (val === undefined)\r\n return undefined;\r\n }\r\n return map as Map<string, T>;\r\n}\r\n\r\nfunction eql(prev: readonly string[] | undefined, value: readonly string[]) {\r\n if (!prev)\r\n return false;\r\n // istanbul ignore next\r\n if (prev.length !== value.length)\r\n return false;\r\n for (let i = 0; i < prev.length; i++) {\r\n const p = prev[i];\r\n const v = value[i];\r\n // istanbul ignore next\r\n if (p !== v)\r\n return false;\r\n }\r\n return true;\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAmD,MAAM,gBAAgB,CAAC;AAExF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW;IAWnB,8BAA8B;IAC9B,OAAO,CAAC,YAAY;IAMpB,iCAAiC;IACjC,OAAO,CAAC,SAAS;IAMjB,+BAA+B;IAC/B,OAAO,CAAC,SAAS;IAIjB,sCAAsC;IACtC,OAAO,CAAC,cAAc;IAItB,sDAAsD;IACtD,OAAO,CAAC,0BAA0B;IAIlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAc/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAKzB,yDAAyD;IAClD,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS;CAuBnD"}
1
+ {"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAmD,MAAM,gBAAgB,CAAC;AAExF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW;IAWnB,8BAA8B;IAC9B,OAAO,CAAC,YAAY;IAMpB,iCAAiC;IACjC,OAAO,CAAC,SAAS;IAOjB,+BAA+B;IAC/B,OAAO,CAAC,SAAS;IAIjB,sCAAsC;IACtC,OAAO,CAAC,cAAc;IAItB,sDAAsD;IACtD,OAAO,CAAC,0BAA0B;IAIlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAc/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAKzB,yDAAyD;IAClD,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS;CAuBnD"}
@@ -6,8 +6,8 @@
6
6
  * @module Common
7
7
  */
8
8
  import * as React from "react";
9
- import { UiError } from "@itwin/appui-abstract";
10
- import { SvgSprite, WebFontIcon } from "@itwin/core-react";
9
+ import { IconSpecUtilities, UiError } from "@itwin/appui-abstract";
10
+ import { Icon, WebFontIcon } from "@itwin/core-react";
11
11
  import { UiComponents } from "../UiComponents";
12
12
  /** A class that renders images from data provided by an image loader
13
13
  * @internal
@@ -30,8 +30,9 @@ export class ImageRenderer {
30
30
  }
31
31
  /** Render svg string into JSX */
32
32
  renderSvg(svg) {
33
+ const iconSpec = IconSpecUtilities.createWebComponentIconSpec(svg);
33
34
  return (React.createElement("div", null,
34
- React.createElement(SvgSprite, { src: svg })));
35
+ React.createElement(Icon, { iconSpec: iconSpec })));
35
36
  }
36
37
  /** Render image from an url */
37
38
  renderUrl(url) {
@@ -1 +1 @@
1
- {"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,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gDAAgD;gBAC3G,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,6BAA6B,mBAAmB,GAAG,CAAC,CAAC;SAC7G;IACH,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 { UiError } from \"@itwin/appui-abstract\";\r\nimport { SvgSprite, WebFontIcon, WebFontIconProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { Image, ImageFileFormat, LoadedBinaryImage, LoadedImage } from \"./IImageLoader\";\r\n\r\n/** A class that renders images from data provided by an image loader\r\n * @internal\r\n */\r\nexport class ImageRenderer {\r\n private hexToBase64(hexstring: string) {\r\n const match = hexstring.match(/\\w{2}/g);\r\n // istanbul ignore next\r\n if (!match)\r\n return \"\";\r\n\r\n return btoa(match.map((a) => { // eslint-disable-line deprecation/deprecation\r\n return String.fromCharCode(parseInt(a, 16));\r\n }).join(\"\"));\r\n }\r\n\r\n /** Render raw binary image */\r\n private renderBinary(data: string, format: ImageFileFormat) {\r\n // Convert binary to base64\r\n const dataAsBase64 = this.hexToBase64(data);\r\n return (<img src={`data:image/${format};base64,${dataAsBase64}`} alt=\"\" />);\r\n }\r\n\r\n /** Render svg string into JSX */\r\n private renderSvg(svg: string) {\r\n return (\r\n <div><SvgSprite src={svg} /></div>\r\n );\r\n }\r\n\r\n /** Render image from an url */\r\n private renderUrl(url: string) {\r\n return (<img src={url} alt=\"\" />);\r\n }\r\n\r\n /** Render image as core-react icon */\r\n private renderCoreIcon(iconName: string) {\r\n return (<WebFontIcon iconName={iconName} />);\r\n }\r\n\r\n /** Replaces the escaped instances of \"\\:\" with \":\" */\r\n private normalizeEscapedIconString(escapedIconString: string) {\r\n return escapedIconString.replace(/\\\\:/g, \":\");\r\n }\r\n\r\n /**\r\n * Extract class and name from icon name, if the name follows format \"{className}:{fontName}\".\r\n * className and fontName can be escaped using \\ if : is needed.\r\n */\r\n private extractIconClassAndName(iconName: string): Pick<WebFontIconProps, \"iconClassName\" | \"iconName\"> {\r\n const matches = iconName.match(/(\\\\.|[^:])+/g);\r\n if (!matches || matches.length !== 2)\r\n return {\r\n iconClassName: undefined,\r\n iconName,\r\n };\r\n\r\n return {\r\n iconClassName: this.normalizeEscapedIconString(matches[0]),\r\n iconName: this.normalizeEscapedIconString(matches[1]),\r\n };\r\n }\r\n\r\n /**\r\n * Render image as provided webfont icon.\r\n * Defaults to core-react icon if iconName does not contain className.\r\n */\r\n private renderWebfontIcon(iconName: string) {\r\n const iconInfo = this.extractIconClassAndName(iconName);\r\n return (<WebFontIcon {...iconInfo} />);\r\n }\r\n\r\n /** Render image from data provided by an image loader */\r\n public render(loadedImage: Image): React.ReactNode {\r\n switch (loadedImage.sourceType) {\r\n case \"binary\":\r\n const image = loadedImage as LoadedBinaryImage;\r\n return this.renderBinary(image.value, image.fileFormat);\r\n\r\n case \"url\":\r\n return this.renderUrl((loadedImage as LoadedImage).value);\r\n\r\n case \"svg\":\r\n return this.renderSvg((loadedImage as LoadedImage).value);\r\n\r\n case \"core-icon\":\r\n return this.renderCoreIcon((loadedImage as LoadedImage).value);\r\n\r\n case \"webfont-icon\":\r\n return this.renderWebfontIcon((loadedImage as LoadedImage).value);\r\n\r\n default:\r\n const unhandledSourceType: never = loadedImage.sourceType; // Compile time check that all cases are handled\r\n throw new UiError(UiComponents.loggerCategory(this), `Can't handle sourceType: \"${unhandledSourceType}\"`);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;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YAE5D,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEjE,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,iBAAiB,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEpE;gBACE,MAAM,mBAAmB,GAAU,WAAW,CAAC,UAAU,CAAC,CAAC,gDAAgD;gBAC3G,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,6BAA6B,mBAAmB,GAAG,CAAC,CAAC;SAC7G;IACH,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 { IconSpecUtilities, UiError } from \"@itwin/appui-abstract\";\r\nimport { Icon, WebFontIcon, WebFontIconProps } from \"@itwin/core-react\";\r\nimport { UiComponents } from \"../UiComponents\";\r\nimport { Image, ImageFileFormat, LoadedBinaryImage, LoadedImage } from \"./IImageLoader\";\r\n\r\n/** A class that renders images from data provided by an image loader\r\n * @internal\r\n */\r\nexport class ImageRenderer {\r\n private hexToBase64(hexstring: string) {\r\n const match = hexstring.match(/\\w{2}/g);\r\n // istanbul ignore next\r\n if (!match)\r\n return \"\";\r\n\r\n return btoa(match.map((a) => { // eslint-disable-line deprecation/deprecation\r\n return String.fromCharCode(parseInt(a, 16));\r\n }).join(\"\"));\r\n }\r\n\r\n /** Render raw binary image */\r\n private renderBinary(data: string, format: ImageFileFormat) {\r\n // Convert binary to base64\r\n const dataAsBase64 = this.hexToBase64(data);\r\n return (<img src={`data:image/${format};base64,${dataAsBase64}`} alt=\"\" />);\r\n }\r\n\r\n /** Render svg string into JSX */\r\n private renderSvg(svg: string) {\r\n const iconSpec = IconSpecUtilities.createWebComponentIconSpec(svg);\r\n return (\r\n <div><Icon iconSpec={iconSpec} /></div>\r\n );\r\n }\r\n\r\n /** Render image from an url */\r\n private renderUrl(url: string) {\r\n return (<img src={url} alt=\"\" />);\r\n }\r\n\r\n /** Render image as core-react icon */\r\n private renderCoreIcon(iconName: string) {\r\n return (<WebFontIcon iconName={iconName} />);\r\n }\r\n\r\n /** Replaces the escaped instances of \"\\:\" with \":\" */\r\n private normalizeEscapedIconString(escapedIconString: string) {\r\n return escapedIconString.replace(/\\\\:/g, \":\");\r\n }\r\n\r\n /**\r\n * Extract class and name from icon name, if the name follows format \"{className}:{fontName}\".\r\n * className and fontName can be escaped using \\ if : is needed.\r\n */\r\n private extractIconClassAndName(iconName: string): Pick<WebFontIconProps, \"iconClassName\" | \"iconName\"> {\r\n const matches = iconName.match(/(\\\\.|[^:])+/g);\r\n if (!matches || matches.length !== 2)\r\n return {\r\n iconClassName: undefined,\r\n iconName,\r\n };\r\n\r\n return {\r\n iconClassName: this.normalizeEscapedIconString(matches[0]),\r\n iconName: this.normalizeEscapedIconString(matches[1]),\r\n };\r\n }\r\n\r\n /**\r\n * Render image as provided webfont icon.\r\n * Defaults to core-react icon if iconName does not contain className.\r\n */\r\n private renderWebfontIcon(iconName: string) {\r\n const iconInfo = this.extractIconClassAndName(iconName);\r\n return (<WebFontIcon {...iconInfo} />);\r\n }\r\n\r\n /** Render image from data provided by an image loader */\r\n public render(loadedImage: Image): React.ReactNode {\r\n switch (loadedImage.sourceType) {\r\n case \"binary\":\r\n const image = loadedImage as LoadedBinaryImage;\r\n return this.renderBinary(image.value, image.fileFormat);\r\n\r\n case \"url\":\r\n return this.renderUrl((loadedImage as LoadedImage).value);\r\n\r\n case \"svg\":\r\n return this.renderSvg((loadedImage as LoadedImage).value);\r\n\r\n case \"core-icon\":\r\n return this.renderCoreIcon((loadedImage as LoadedImage).value);\r\n\r\n case \"webfont-icon\":\r\n return this.renderWebfontIcon((loadedImage as LoadedImage).value);\r\n\r\n default:\r\n const unhandledSourceType: never = loadedImage.sourceType; // Compile time check that all cases are handled\r\n throw new UiError(UiComponents.loggerCategory(this), `Can't handle sourceType: \"${unhandledSourceType}\"`);\r\n }\r\n }\r\n}\r\n"]}
@@ -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 items, given through items prop, through a list of checkboxes.
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;AAEH,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,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,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 items, given through items prop, through a list of checkboxes.
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,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,KAAK,CAAC,aAAa,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QAEM,UAAK,GAAG,CAAC,IAAqB,EA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,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,OAAO,EACvB,aAAa,EAAE,OAAO,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,KAC1E,KAAK,IACR,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACpC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;YACjE,MAAM,GAAG,GAAG,GAAG,EAAE;gBACf,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;YACvE,MAAM,EAAE,GAAG,0BAA0B,KAAK,EAAE,CAAC;YAC7C,OAAO,CACL,6BAAK,GAAG,EAAE,KAAK;gBACb,oBAAC,QAAQ,mBAAc,EAAE,EAAE,EAAE,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\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\r\n * @public\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 items, given through items prop, through a list of checkboxes.\r\n * @public\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
+ {"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,OAA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AAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;YACvE,MAAM,EAAE,GAAG,0BAA0B,KAAK,EAAE,CAAC;YAC7C,OAAO,CACL,6BAAK,GAAG,EAAE,KAAK;gBACb,oBAAC,QAAQ,mBAAc,EAAE,EAAE,EAAE,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;AAEH;;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
+ {"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\r\n * @public\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\r\n */\r\nexport type ShowHideID = string | number | symbol;\r\n"]}
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;AAEH,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,CA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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,C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,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\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,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,CAAC,GAAG,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EACzE,GAAG,EAAE;gBAC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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"]}