@itwin/components-react 3.2.0-dev.37 → 3.2.0-dev.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components-react/toolbar/Item.js +1 -1
- package/lib/cjs/components-react/toolbar/Item.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.js +1 -1
- package/lib/cjs/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.js +1 -1
- package/lib/cjs/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.js +1 -1
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.js.map +1 -1
- package/lib/esm/components-react/toolbar/Item.js +1 -1
- package/lib/esm/components-react/toolbar/Item.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.js +1 -1
- package/lib/esm/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.js +1 -1
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.js.map +1 -1
- package/package.json +11 -11
|
@@ -39,7 +39,7 @@ const React = __importStar(require("react"));
|
|
|
39
39
|
// eslint-disable-next-line react/display-name
|
|
40
40
|
exports.ToolbarButtonItem = React.memo((props) => {
|
|
41
41
|
const className = (0, classnames_1.default)("components-toolbar-button-item", props.isActive && "components-active", props.isDisabled && "components-disabled", props.className);
|
|
42
|
-
return (React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
42
|
+
return (React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, disabled: props.isDisabled, onClick: props.onClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: props.title },
|
|
43
43
|
React.createElement("div", { className: "components-icon" }, props.icon),
|
|
44
44
|
props.badge &&
|
|
45
45
|
React.createElement("div", { className: "components-badge" }, props.badge)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Item.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uBAAqB;AACrB,4DAAoC;AACpC,6CAA+B;AA+B/B;;GAEG;AACH,8CAA8C;AACjC,QAAA,iBAAiB,GAAG,KAAK,CAAC,IAAI,CACzC,CAAC,KAA6B,EAAE,EAAE;IAChC,MAAM,SAAS,GAAG,IAAA,oBAAU,EAC1B,gCAAgC,EAChC,KAAK,CAAC,QAAQ,IAAI,mBAAmB,EACrC,KAAK,CAAC,UAAU,IAAI,qBAAqB,EACzC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnB,OAAO,CACL,gDACgB,KAAK,CAAC,MAAM,oBACX,oBAAoB,8BACT,KAAK,CAAC,aAAa,wBACzB,KAAK,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Item.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uBAAqB;AACrB,4DAAoC;AACpC,6CAA+B;AA+B/B;;GAEG;AACH,8CAA8C;AACjC,QAAA,iBAAiB,GAAG,KAAK,CAAC,IAAI,CACzC,CAAC,KAA6B,EAAE,EAAE;IAChC,MAAM,SAAS,GAAG,IAAA,oBAAU,EAC1B,gCAAgC,EAChC,KAAK,CAAC,QAAQ,IAAI,mBAAmB,EACrC,KAAK,CAAC,UAAU,IAAI,qBAAqB,EACzC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnB,OAAO,CACL,gDACgB,KAAK,CAAC,MAAM,oBACX,oBAAoB,8BACT,KAAK,CAAC,aAAa,wBACzB,KAAK,CAAC,YAAY,2BACf,KAAK,CAAC,UAAU,EACvC,QAAQ,EAAE,KAAK,CAAC,UAAU,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAElB,6BAAK,SAAS,EAAC,iBAAiB,IAC7B,KAAK,CAAC,IAAI,CACP;QACL,KAAK,CAAC,KAAK;YACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR,CAED,CACV,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Toolbar\r\n */\r\n\r\nimport \"./Item.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\n\r\n/** Properties of [[ToolbarButtonItem]] component.\r\n * @public\r\n */\r\nexport interface ToolbarButtonItemProps extends CommonProps {\r\n /** button icon. */\r\n icon?: React.ReactNode;\r\n /** Describes if item is active. */\r\n isActive?: boolean;\r\n /** Describes if the item is disabled. */\r\n isDisabled?: boolean;\r\n /** Function called when the item is clicked. */\r\n onClick?: () => void;\r\n /** Function called when a key is pressed. */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n /** Title for the item. */\r\n title: string;\r\n /** A badge to draw. */\r\n badge?: React.ReactNode;\r\n /** If true add a gap before button. Default to false. */\r\n addGroupSeparator?: boolean;\r\n /** value added to DOM element as a data attribute to hold name of items provider. If specified in `FrontstageProvider` then this will be undefined */\r\n providerId?: string;\r\n /** value added to DOM element as a data attribute, shows 0 is undefined */\r\n itemPriority?: number;\r\n /** value added to DOM element as a data attribute */\r\n groupPriority?: number;\r\n}\r\n\r\n/** Toolbar item component. Used in [[Toolbar]] component.\r\n * @public\r\n */\r\n// eslint-disable-next-line react/display-name\r\nexport const ToolbarButtonItem = React.memo<React.FC<ToolbarButtonItemProps>>(\r\n (props: ToolbarButtonItemProps) => {\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n props.isActive && \"components-active\",\r\n props.isDisabled && \"components-disabled\",\r\n props.className);\r\n\r\n return (\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n disabled={props.isDisabled} // this is needed to prevent focusing/keyboard access to disabled buttons\r\n onClick={props.onClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={props.title}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n </button>\r\n );\r\n });\r\n"]}
|
|
@@ -88,7 +88,7 @@ function PopupItem(props) {
|
|
|
88
88
|
return (React.createElement(exports.ToolbarPopupContext.Provider, { value: {
|
|
89
89
|
closePanel: () => processPanelOpenClose(false),
|
|
90
90
|
} },
|
|
91
|
-
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "tool-button-popup", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
91
|
+
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "tool-button-popup", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, ref: targetRef, disabled: props.isDisabled, onClick: onButtonClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: props.title },
|
|
92
92
|
React.createElement("div", { className: "components-icon" }, props.icon),
|
|
93
93
|
props.badge &&
|
|
94
94
|
React.createElement("div", { className: "components-badge" }, props.badge),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupItem.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItem.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4BAA0B;AAC1B,4DAAoC;AACpC,6CAA+B;AAE/B,kDAAuD;AAEvD,+DAAwI;AACxI,2DAAqE;AAQrE;;;GAGG;AACH,gEAAgE;AACnD,QAAA,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAA2B;IAC/E,yCAAyC;IACzC,UAAU,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC;IAChD,yGAAyG;IACzG,eAAe,EAAE,0BAA0B,CAAE,CAAC,WAAyB,EAAE,EAAE,GAAG,CAAC;CAChF,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAgB,sBAAsB;IACpC,OAAO,KAAK,CAAC,UAAU,CAAC,2BAAmB,CAAC,CAAC;AAC/C,CAAC;AAFD,wDAEC;AAeD;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAqB;IAC7C,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG,IAAA,4DAAsC,GAAE,CAAC;IACzH,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,SAAkB,EAAE,EAAE;QACrE,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,uBAAuB;YACvB,IAAI,IAAI,KAAK,SAAS;gBACpB,qBAAqB,CAAC,SAAS,CAAC,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,q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AAI,CACP;YACL,KAAK,CAAC,KAAK;gBACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR;YAEP,aAAa,CAAC,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAAC,6BAAK,SAAS,EAAC,qBAAqB,GAAG,CACxF;QACT,oBAAC,cAAc,IACb,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,IAAA,kDAA8B,EAAC,kBAAkB,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,IAE7C,KAAK,CACS,CACY,CAChC,CAAC;AACJ,CAAC;AAzED,8BAyEC;AAYD,gBAAgB;AAChB,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,QAAQ,GAAG,IAAA,oDAA8B,GAAE,CAAC;IAClD,MAAM,SAAS,GAAG,IAAA,oBAAU,EAC1B,6CAA6C,EAC7C,QAAQ,IAAI,WAAW,CAAC,CAAC;IAE3B,OAAO,oBAAC,kBAAK,IACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,KAAK,KACb,KAAK,GACT,CAAC;AACL,CAAC;AAZD,wCAYC","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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { Popup, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { useToolbarPopupAutoHideContext, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { toToolbarPopupRelativePosition } from \"./PopupItemWithDrag\";\r\n\r\n/** @public */\r\nexport interface ToolbarPopupContextProps {\r\n readonly closePanel: () => void;\r\n readonly setSelectedItem?: (buttonItem: ActionButton) => void;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar items in popups to close the popup panel.\r\n * @public\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarPopupContext = React.createContext<ToolbarPopupContextProps>({\r\n /** function used to close popup panel */\r\n closePanel: /* istanbul ignore next */ () => { },\r\n /** if popup panel is a GroupButton then this is call to set the selected action item within the panel */\r\n setSelectedItem: /* istanbul ignore next */ (_buttonItem: ActionButton) => { },\r\n});\r\n\r\n/**\r\n * React hook used to retrieve the ToolbarPopupContext.\r\n * @public\r\n */\r\nexport function useToolbarPopupContext() {\r\n return React.useContext(ToolbarPopupContext);\r\n}\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemProps extends ToolbarButtonItemProps {\r\n /** Describes if expandable item triangle indicator should be hidden. */\r\n hideIndicator?: boolean;\r\n /** Panel of the toolbar. */\r\n panel?: 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 keepContentsMounted?: boolean;\r\n}\r\n\r\n/** Popup toolbar item that displays a panel\r\n * @public\r\n */\r\nexport function PopupItem(props: PopupItemProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing overflow panel\r\n const onButtonClick = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n // istanbul ignore next\r\n if (props.onClick)\r\n props.onClick();\r\n }, [props, isPanelShown, processPanelOpenClose]);\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n props.isDisabled && \"components-disabled\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n // istanbul ignore next\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? overflowExpandsTo : expandsTo;\r\n\r\n const { hideIndicator, panel } = props;\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: () => processPanelOpenClose(false),\r\n }}>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"tool-button-popup\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n ref={targetRef}\r\n disabled={props.isDisabled} // this is needed to prevent focusing/keyboard access to disabled buttons\r\n onClick={onButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={props.title}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n {hideIndicator ? /* istanbul ignore next */ undefined : <div className=\"components-triangle\" />}\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n keepContentsMounted={props.keepContentsMounted}\r\n >\r\n {panel}\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\ninterface PopupItemPopupProps {\r\n children?: React.ReactNode;\r\n isOpen?: boolean;\r\n onClose(): void;\r\n position: RelativePosition;\r\n target?: HTMLElement;\r\n keepContentsMounted?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport function PopupItemPopup(props: PopupItemPopupProps) {\r\n const isHidden = useToolbarPopupAutoHideContext();\r\n const className = classnames(\r\n \"components-toolbar-popupItem_popupItemPopup\",\r\n isHidden && \"nz-hidden\");\r\n\r\n return <Popup\r\n className={className}\r\n offset={0}\r\n showShadow={false}\r\n {...props}\r\n />;\r\n}\r\n"]}
|
|
@@ -142,7 +142,7 @@ function PopupItemWithDrag(props) {
|
|
|
142
142
|
closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),
|
|
143
143
|
setSelectedItem: /* istanbul ignore next */ (buttonItem) => setActiveAction(buttonItem),
|
|
144
144
|
} },
|
|
145
|
-
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
145
|
+
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, ref: targetRef, onPointerDown: handlePointerDown, onClick: handleButtonClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: title },
|
|
146
146
|
React.createElement("div", { className: "components-icon" }, icon),
|
|
147
147
|
props.badge &&
|
|
148
148
|
React.createElement("div", { className: "components-badge" }, badge),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupItemWithDrag.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItemWithDrag.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4BAA0B;AAC1B,4DAAoC;AACpC,6CAA+B;AAC/B,0DAA2J;AAC3J,kDAA4E;AAE5E,2CAAkE;AAClE,uDAAoD;AACpD,+DAA+H;AAC/H,6DAA0D;AAC1D,qDAAkD;AAUlD,SAAS,mBAAmB,CAAC,IAAiB;IAC5C,KAAK,MAAM,SAAS,IAAI,IAAI,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EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE,MAAM;YAEd,oBAAC,iCAAe,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,mBAAmB,EAAE,IAAI,GAAI,CAC3D,CACY,CAChC,CAAC;AACJ,CAAC;AAtGD,8CAsGC;AAED,gBAAgB;AAChB,SAAgB,8BAA8B,CAAC,SAAoB,EAAE,SAAgC;IACnG,uBAAuB;IACvB,QAAQ,SAAS,EAAE;QACjB,KAAK,qBAAS,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,SAAS,KAAK,2CAAqB,CAAC,GAAG;gBACzC,OAAO,iCAAgB,CAAC,WAAW,CAAC;YACtC,OAAO,iCAAgB,CAAC,UAAU,CAAC;SACpC;QACD,KAAK,qBAAS,CAAC,IAAI;YACjB,OAAO,iCAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,qBAAS,CAAC,KAAK;YAClB,OAAO,iCAAgB,CAAC,QAAQ,CAAC;QACnC,KAAK,qBAAS,CAAC,GAAG;YAChB,OAAO,iCAAgB,CAAC,GAAG,CAAC;KAC/B;AACH,CAAC;AAfD,wEAeC","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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, ConditionalBooleanValue, ConditionalStringValue, GroupButton, RelativePosition, ToolbarItemUtilities } from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, IconHelper, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { PopupItemPopup, ToolbarPopupContext } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { ToolbarPanelAlignment, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { useDragInteraction } from \"./useDragInteraction\";\r\nimport { Direction } from \"./utilities/Direction\";\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemWithDragProps extends ToolbarButtonItemProps {\r\n /** Panel of the toolbar. */\r\n groupItem: GroupButton;\r\n}\r\n\r\nfunction tryFindActiveAction(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n if (childItem.isActive)\r\n return childItem;\r\n } else if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = tryFindActiveAction(childItem);\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getFirstAvailableChildActionItem(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = getFirstAvailableChildActionItem(childItem);\r\n // istanbul ignore else\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getActiveAction(item: GroupButton): ActionButton | undefined {\r\n const activeItem = tryFindActiveAction(item);\r\n if (activeItem)\r\n return activeItem;\r\n\r\n // initially look only in root items\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n }\r\n }\r\n\r\n // if not found look inside groups\r\n return getFirstAvailableChildActionItem(item);\r\n}\r\n\r\n/** Expandable Group button Item\r\n * @public\r\n */\r\nexport function PopupItemWithDrag(props: PopupItemWithDragProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const [activeAction, setActiveAction] = React.useState(getActiveAction(props.groupItem));\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n\r\n React.useEffect(() => {\r\n const newActiveAction = getActiveAction(props.groupItem);\r\n // istanbul ignore else\r\n if (newActiveAction) {\r\n // istanbul ignore next\r\n if (newActiveAction.isActive) {\r\n setActiveAction(newActiveAction);\r\n } else {\r\n if (activeAction && activeAction.isActive) {\r\n setActiveAction({ ...activeAction, isActive: false });\r\n }\r\n }\r\n }\r\n }, [props.groupItem, activeAction]);\r\n\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onOpenPanel = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n }, [isPanelShown, processPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onGroupButtonClick = React.useCallback(() => {\r\n // only execute action if not disabled\r\n activeAction && !ConditionalBooleanValue.getValue(activeAction.isDisabled) && activeAction.execute();\r\n }, [activeAction]);\r\n\r\n const badge = activeAction ? BadgeUtilities.getComponentForBadgeType(activeAction.badgeType) : props.badge;\r\n const icon = activeAction ? IconHelper.getIconReactNode(activeAction.icon, activeAction.internalData) : props.icon;\r\n const title = activeAction ? ConditionalStringValue.getValue(activeAction.label) : props.title;\r\n const isActive = activeAction ? activeAction.isActive : props.isActive;\r\n const isDisabled = ConditionalBooleanValue.getValue(activeAction ? activeAction.isDisabled : props.isDisabled);\r\n\r\n const { handlePointerDown, handleButtonClick } = useDragInteraction(onGroupButtonClick, onOpenPanel);\r\n\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n isActive && \"components-active\",\r\n isDisabled && \"components-disabled-drag\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? /* istanbul ignore next */ overflowExpandsTo : expandsTo;\r\n\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),\r\n setSelectedItem: /* istanbul ignore next */ (buttonItem: ActionButton) => setActiveAction(buttonItem),\r\n }\r\n }>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-providerid={props.providerId}\r\n ref={targetRef}\r\n onPointerDown={handlePointerDown}\r\n onClick={handleButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={title}\r\n >\r\n <div className=\"components-icon\">\r\n {icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {badge}\r\n </div>\r\n }\r\n <div className=\"components-triangle\" />\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n >\r\n <PopupItemsPanel groupItem={props.groupItem} activateOnPointerUp={true} />\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport function toToolbarPopupRelativePosition(expandsTo: Direction, alignment: ToolbarPanelAlignment): RelativePosition {\r\n // istanbul ignore next\r\n switch (expandsTo) {\r\n case Direction.Bottom: {\r\n if (alignment === ToolbarPanelAlignment.End)\r\n return RelativePosition.BottomRight;\r\n return RelativePosition.BottomLeft;\r\n }\r\n case Direction.Left:\r\n return RelativePosition.LeftTop;\r\n case Direction.Right:\r\n return RelativePosition.RightTop;\r\n case Direction.Top:\r\n return RelativePosition.Top;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PopupItemWithDrag.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItemWithDrag.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4BAA0B;AAC1B,4DAAoC;AACpC,6CAA+B;AAC/B,0DAA2J;AAC3J,kDAA4E;AAE5E,2CAAkE;AAClE,uDAAoD;AACpD,+DAA+H;AAC/H,6DAA0D;AAC1D,qDAAkD;AAUlD,SAAS,mBAAmB,CAAC,IAAiB;IAC5C,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE;QAClC,uBAAuB;QACvB,IAAI,qCAAoB,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;YAClD,IAAI,SAAS,CAAC,QAAQ;gBACpB,OAAO,SAAS,CAAC;SACpB;aAAM,IAAI,qCAAoB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;YACxD,MAAM,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,WAAW;gBACb,OAAO,WAAW,CAAC;SACtB;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,gCAAgC,CAAC,IAAiB;IACzD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE;QAClC,IAAI,qCAAoB,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;YAClD,OAAO,SAAS,CAAC;SAClB;aAAM;YACL,uBAAuB;YACvB,IAAI,qCAAoB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;gBACjD,MAAM,WAAW,GAAG,gCAAgC,CAAC,SAAS,CAAC,CAAC;gBAChE,uBAAuB;gBACvB,IAAI,WAAW;oBACb,OAAO,WAAW,CAAC;aACtB;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,eAAe,CAAC,IAAiB;IACxC,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IA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,SAAS,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK;YAEZ,6BAAK,SAAS,EAAC,iBAAiB,IAC7B,IAAI,CACD;YACL,KAAK,CAAC,KAAK;gBACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CACF;YAER,6BAAK,SAAS,EAAC,qBAAqB,GAAG,CAChC;QACT,oBAAC,0BAAc,IACb,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,8BAA8B,CAAC,kBAAkB,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE,MAAM;YAEd,oBAAC,iCAAe,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,mBAAmB,EAAE,IAAI,GAAI,CAC3D,CACY,CAChC,CAAC;AACJ,CAAC;AAtGD,8CAsGC;AAED,gBAAgB;AAChB,SAAgB,8BAA8B,CAAC,SAAoB,EAAE,SAAgC;IACnG,uBAAuB;IACvB,QAAQ,SAAS,EAAE;QACjB,KAAK,qBAAS,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,SAAS,KAAK,2CAAqB,CAAC,GAAG;gBACzC,OAAO,iCAAgB,CAAC,WAAW,CAAC;YACtC,OAAO,iCAAgB,CAAC,UAAU,CAAC;SACpC;QACD,KAAK,qBAAS,CAAC,IAAI;YACjB,OAAO,iCAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,qBAAS,CAAC,KAAK;YAClB,OAAO,iCAAgB,CAAC,QAAQ,CAAC;QACnC,KAAK,qBAAS,CAAC,GAAG;YAChB,OAAO,iCAAgB,CAAC,GAAG,CAAC;KAC/B;AACH,CAAC;AAfD,wEAeC","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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, ConditionalBooleanValue, ConditionalStringValue, GroupButton, RelativePosition, ToolbarItemUtilities } from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, IconHelper, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { PopupItemPopup, ToolbarPopupContext } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { ToolbarPanelAlignment, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { useDragInteraction } from \"./useDragInteraction\";\r\nimport { Direction } from \"./utilities/Direction\";\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemWithDragProps extends ToolbarButtonItemProps {\r\n /** Panel of the toolbar. */\r\n groupItem: GroupButton;\r\n}\r\n\r\nfunction tryFindActiveAction(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n if (childItem.isActive)\r\n return childItem;\r\n } else if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = tryFindActiveAction(childItem);\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getFirstAvailableChildActionItem(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = getFirstAvailableChildActionItem(childItem);\r\n // istanbul ignore else\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getActiveAction(item: GroupButton): ActionButton | undefined {\r\n const activeItem = tryFindActiveAction(item);\r\n if (activeItem)\r\n return activeItem;\r\n\r\n // initially look only in root items\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n }\r\n }\r\n\r\n // if not found look inside groups\r\n return getFirstAvailableChildActionItem(item);\r\n}\r\n\r\n/** Expandable Group button Item\r\n * @public\r\n */\r\nexport function PopupItemWithDrag(props: PopupItemWithDragProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const [activeAction, setActiveAction] = React.useState(getActiveAction(props.groupItem));\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n\r\n React.useEffect(() => {\r\n const newActiveAction = getActiveAction(props.groupItem);\r\n // istanbul ignore else\r\n if (newActiveAction) {\r\n // istanbul ignore next\r\n if (newActiveAction.isActive) {\r\n setActiveAction(newActiveAction);\r\n } else {\r\n if (activeAction && activeAction.isActive) {\r\n setActiveAction({ ...activeAction, isActive: false });\r\n }\r\n }\r\n }\r\n }, [props.groupItem, activeAction]);\r\n\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onOpenPanel = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n }, [isPanelShown, processPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onGroupButtonClick = React.useCallback(() => {\r\n // only execute action if not disabled\r\n activeAction && !ConditionalBooleanValue.getValue(activeAction.isDisabled) && activeAction.execute();\r\n }, [activeAction]);\r\n\r\n const badge = activeAction ? BadgeUtilities.getComponentForBadgeType(activeAction.badgeType) : props.badge;\r\n const icon = activeAction ? IconHelper.getIconReactNode(activeAction.icon, activeAction.internalData) : props.icon;\r\n const title = activeAction ? ConditionalStringValue.getValue(activeAction.label) : props.title;\r\n const isActive = activeAction ? activeAction.isActive : props.isActive;\r\n const isDisabled = ConditionalBooleanValue.getValue(activeAction ? activeAction.isDisabled : props.isDisabled);\r\n\r\n const { handlePointerDown, handleButtonClick } = useDragInteraction(onGroupButtonClick, onOpenPanel);\r\n\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n isActive && \"components-active\",\r\n isDisabled && \"components-disabled-drag\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? /* istanbul ignore next */ overflowExpandsTo : expandsTo;\r\n\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),\r\n setSelectedItem: /* istanbul ignore next */ (buttonItem: ActionButton) => setActiveAction(buttonItem),\r\n }\r\n }>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n ref={targetRef}\r\n onPointerDown={handlePointerDown}\r\n onClick={handleButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={title}\r\n >\r\n <div className=\"components-icon\">\r\n {icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {badge}\r\n </div>\r\n }\r\n <div className=\"components-triangle\" />\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n >\r\n <PopupItemsPanel groupItem={props.groupItem} activateOnPointerUp={true} />\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport function toToolbarPopupRelativePosition(expandsTo: Direction, alignment: ToolbarPanelAlignment): RelativePosition {\r\n // istanbul ignore next\r\n switch (expandsTo) {\r\n case Direction.Bottom: {\r\n if (alignment === ToolbarPanelAlignment.End)\r\n return RelativePosition.BottomRight;\r\n return RelativePosition.BottomLeft;\r\n }\r\n case Direction.Left:\r\n return RelativePosition.LeftTop;\r\n case Direction.Right:\r\n return RelativePosition.RightTop;\r\n case Direction.Top:\r\n return RelativePosition.Top;\r\n }\r\n}\r\n"]}
|
|
@@ -51,7 +51,7 @@ function GroupTool(props) {
|
|
|
51
51
|
if (!props.isDisabled && props.onPointerUp)
|
|
52
52
|
props.onPointerUp(props.item);
|
|
53
53
|
}, [props]);
|
|
54
|
-
return (React.createElement("div", { className: itemClassName, onClick: handleClick, onKeyDown: props.onKeyDown, onPointerUp: handlePointerUp, "data-item-id": props.item.id, "data-item-type": "popup-tool-panel-item", "data-item-priority": props.item.itemPriority, "data-item-
|
|
54
|
+
return (React.createElement("div", { className: itemClassName, onClick: handleClick, onKeyDown: props.onKeyDown, onPointerUp: handlePointerUp, "data-item-id": props.item.id, "data-item-type": "popup-tool-panel-item", "data-item-priority": props.item.itemPriority, "data-item-provider-id": props.item.providerId, ref: ref, style: props.style, role: "button", tabIndex: 0 },
|
|
55
55
|
React.createElement("div", { className: "components-icon" },
|
|
56
56
|
props.icon,
|
|
57
57
|
props.badge &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../../../../../../src/components-react/toolbar/groupPanel/tool/Tool.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uBAAqB;AACrB,4DAAoC;AACpC,6CAA+B;AAE/B,kDAA6D;AA8B7D;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAqB;IAC7C,MAAM,GAAG,GAAG,KAAK,CA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ACpB,KAAK,CAAC,IAAI,CAAC,UAAU,EAC5C,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC;QAEX,6BAAK,SAAS,EAAC,iBAAiB;YAC7B,KAAK,CAAC,IAAI;YACV,KAAK,CAAC,KAAK;gBACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR,CAEJ;QACN,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR;QACL,KAAK,CAAC,QAAQ,CACX,CACP,CAAC;AACJ,CAAC;AArDD,8BAqDC","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 \"./Tool.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, GroupButton } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, useTargeted } from \"@itwin/core-react\";\r\n\r\n/** Properties of [[GroupTool]] component.\r\n * @internal\r\n */\r\nexport interface GroupToolProps extends CommonProps {\r\n /** Additional content, besides icon and label. */\r\n children?: React.ReactNode;\r\n /** Tool icon. */\r\n icon?: React.ReactNode;\r\n /** Describes if the item is active. */\r\n isActive?: boolean;\r\n /** Describes if the item is disabled. */\r\n isDisabled?: boolean;\r\n /** Describes if the item is focused. */\r\n isFocused?: boolean;\r\n /** Tool label. */\r\n label?: string;\r\n /** Function called when the item is clicked. */\r\n onClick?: (item: GroupButton | ActionButton) => void;\r\n /** Function called when pointer up event is received. */\r\n onPointerUp?: (item: GroupButton | ActionButton) => void;\r\n /** A badge to draw. */\r\n badge?: React.ReactNode;\r\n /** GroupButton item */\r\n item: GroupButton | ActionButton;\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/** Tool entry of tool group panel. Used in [[GroupColumn]].\r\n * @internal\r\n */\r\nexport function GroupTool(props: GroupToolProps) {\r\n const ref = React.useRef<HTMLDivElement>(null);\r\n const targeted = useTargeted(ref);\r\n const itemClassName = classnames(\r\n \"components-toolbar-item-expandable-group-tool-item\",\r\n props.isActive && \"components-active\",\r\n props.isFocused && \"components-focused\",\r\n props.isDisabled && \"components-disabled\",\r\n props.onPointerUp && \"components-pointer-up\",\r\n targeted && \"components-targeted\",\r\n props.className);\r\n\r\n const handleClick = React.useCallback(() => {\r\n // istanbul ignore else\r\n if (!props.isDisabled && props.onClick)\r\n props.onClick(props.item);\r\n }, [props]);\r\n\r\n const handlePointerUp = React.useCallback(() => {\r\n // istanbul ignore else\r\n if (!props.isDisabled && props.onPointerUp)\r\n props.onPointerUp(props.item);\r\n }, [props]);\r\n\r\n return (\r\n <div\r\n className={itemClassName}\r\n onClick={handleClick}\r\n onKeyDown={props.onKeyDown}\r\n onPointerUp={handlePointerUp}\r\n data-item-id={props.item.id}\r\n data-item-type=\"popup-tool-panel-item\"\r\n data-item-priority={props.item.itemPriority}\r\n data-item-provider-id={props.item.providerId}\r\n ref={ref}\r\n style={props.style}\r\n role=\"button\"\r\n tabIndex={0}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n </div>\r\n <div className=\"components-label\">\r\n {props.label}\r\n </div>\r\n {props.children}\r\n </div>\r\n );\r\n}\r\n"]}
|
|
@@ -14,7 +14,7 @@ import * as React from "react";
|
|
|
14
14
|
// eslint-disable-next-line react/display-name
|
|
15
15
|
export const ToolbarButtonItem = React.memo((props) => {
|
|
16
16
|
const className = classnames("components-toolbar-button-item", props.isActive && "components-active", props.isDisabled && "components-disabled", props.className);
|
|
17
|
-
return (React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
17
|
+
return (React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, disabled: props.isDisabled, onClick: props.onClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: props.title },
|
|
18
18
|
React.createElement("div", { className: "components-icon" }, props.icon),
|
|
19
19
|
props.badge &&
|
|
20
20
|
React.createElement("div", { className: "components-badge" }, props.badge)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Item.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+B/B;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CACzC,CAAC,KAA6B,EAAE,EAAE;IAChC,MAAM,SAAS,GAAG,UAAU,CAC1B,gCAAgC,EAChC,KAAK,CAAC,QAAQ,IAAI,mBAAmB,EACrC,KAAK,CAAC,UAAU,IAAI,qBAAqB,EACzC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnB,OAAO,CACL,gDACgB,KAAK,CAAC,MAAM,oBACX,oBAAoB,8BACT,KAAK,CAAC,aAAa,wBACzB,KAAK,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/Item.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+B/B;;GAEG;AACH,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CACzC,CAAC,KAA6B,EAAE,EAAE;IAChC,MAAM,SAAS,GAAG,UAAU,CAC1B,gCAAgC,EAChC,KAAK,CAAC,QAAQ,IAAI,mBAAmB,EACrC,KAAK,CAAC,UAAU,IAAI,qBAAqB,EACzC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnB,OAAO,CACL,gDACgB,KAAK,CAAC,MAAM,oBACX,oBAAoB,8BACT,KAAK,CAAC,aAAa,wBACzB,KAAK,CAAC,YAAY,2BACf,KAAK,CAAC,UAAU,EACvC,QAAQ,EAAE,KAAK,CAAC,UAAU,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK;QAElB,6BAAK,SAAS,EAAC,iBAAiB,IAC7B,KAAK,CAAC,IAAI,CACP;QACL,KAAK,CAAC,KAAK;YACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR,CAED,CACV,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Toolbar\r\n */\r\n\r\nimport \"./Item.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\n\r\n/** Properties of [[ToolbarButtonItem]] component.\r\n * @public\r\n */\r\nexport interface ToolbarButtonItemProps extends CommonProps {\r\n /** button icon. */\r\n icon?: React.ReactNode;\r\n /** Describes if item is active. */\r\n isActive?: boolean;\r\n /** Describes if the item is disabled. */\r\n isDisabled?: boolean;\r\n /** Function called when the item is clicked. */\r\n onClick?: () => void;\r\n /** Function called when a key is pressed. */\r\n onKeyDown?: (e: React.KeyboardEvent) => void;\r\n /** Title for the item. */\r\n title: string;\r\n /** A badge to draw. */\r\n badge?: React.ReactNode;\r\n /** If true add a gap before button. Default to false. */\r\n addGroupSeparator?: boolean;\r\n /** value added to DOM element as a data attribute to hold name of items provider. If specified in `FrontstageProvider` then this will be undefined */\r\n providerId?: string;\r\n /** value added to DOM element as a data attribute, shows 0 is undefined */\r\n itemPriority?: number;\r\n /** value added to DOM element as a data attribute */\r\n groupPriority?: number;\r\n}\r\n\r\n/** Toolbar item component. Used in [[Toolbar]] component.\r\n * @public\r\n */\r\n// eslint-disable-next-line react/display-name\r\nexport const ToolbarButtonItem = React.memo<React.FC<ToolbarButtonItemProps>>(\r\n (props: ToolbarButtonItemProps) => {\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n props.isActive && \"components-active\",\r\n props.isDisabled && \"components-disabled\",\r\n props.className);\r\n\r\n return (\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n disabled={props.isDisabled} // this is needed to prevent focusing/keyboard access to disabled buttons\r\n onClick={props.onClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={props.title}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n </button>\r\n );\r\n });\r\n"]}
|
|
@@ -62,7 +62,7 @@ export function PopupItem(props) {
|
|
|
62
62
|
return (React.createElement(ToolbarPopupContext.Provider, { value: {
|
|
63
63
|
closePanel: () => processPanelOpenClose(false),
|
|
64
64
|
} },
|
|
65
|
-
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "tool-button-popup", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
65
|
+
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "tool-button-popup", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, ref: targetRef, disabled: props.isDisabled, onClick: onButtonClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: props.title },
|
|
66
66
|
React.createElement("div", { className: "components-icon" }, props.icon),
|
|
67
67
|
props.badge &&
|
|
68
68
|
React.createElement("div", { className: "components-badge" }, props.badge),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupItem.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItem.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,8BAA8B,EAAE,sCAAsC,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACxI,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAQrE;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAA2B;IAC/E,yCAAyC;IACzC,UAAU,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC;IAChD,yGAAyG;IACzG,eAAe,EAAE,0BAA0B,CAAE,CAAC,WAAyB,EAAE,EAAE,GAAG,CAAC;CAChF,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;AAC/C,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,CAAC,YAAY,EA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O,oBAAC,KAAK,IACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,CAAC,EACT,UAAU,EAAE,KAAK,KACb,KAAK,GACT,CAAC;AACL,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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, RelativePosition } from \"@itwin/appui-abstract\";\r\nimport { Popup, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { useToolbarPopupAutoHideContext, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { toToolbarPopupRelativePosition } from \"./PopupItemWithDrag\";\r\n\r\n/** @public */\r\nexport interface ToolbarPopupContextProps {\r\n readonly closePanel: () => void;\r\n readonly setSelectedItem?: (buttonItem: ActionButton) => void;\r\n}\r\n\r\n/**\r\n * Context used by Toolbar items in popups to close the popup panel.\r\n * @public\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const ToolbarPopupContext = React.createContext<ToolbarPopupContextProps>({\r\n /** function used to close popup panel */\r\n closePanel: /* istanbul ignore next */ () => { },\r\n /** if popup panel is a GroupButton then this is call to set the selected action item within the panel */\r\n setSelectedItem: /* istanbul ignore next */ (_buttonItem: ActionButton) => { },\r\n});\r\n\r\n/**\r\n * React hook used to retrieve the ToolbarPopupContext.\r\n * @public\r\n */\r\nexport function useToolbarPopupContext() {\r\n return React.useContext(ToolbarPopupContext);\r\n}\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemProps extends ToolbarButtonItemProps {\r\n /** Describes if expandable item triangle indicator should be hidden. */\r\n hideIndicator?: boolean;\r\n /** Panel of the toolbar. */\r\n panel?: 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 keepContentsMounted?: boolean;\r\n}\r\n\r\n/** Popup toolbar item that displays a panel\r\n * @public\r\n */\r\nexport function PopupItem(props: PopupItemProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing overflow panel\r\n const onButtonClick = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n // istanbul ignore next\r\n if (props.onClick)\r\n props.onClick();\r\n }, [props, isPanelShown, processPanelOpenClose]);\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n props.isDisabled && \"components-disabled\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n // istanbul ignore next\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? overflowExpandsTo : expandsTo;\r\n\r\n const { hideIndicator, panel } = props;\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: () => processPanelOpenClose(false),\r\n }}>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"tool-button-popup\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n ref={targetRef}\r\n disabled={props.isDisabled} // this is needed to prevent focusing/keyboard access to disabled buttons\r\n onClick={onButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={props.title}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n {hideIndicator ? /* istanbul ignore next */ undefined : <div className=\"components-triangle\" />}\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n keepContentsMounted={props.keepContentsMounted}\r\n >\r\n {panel}\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\ninterface PopupItemPopupProps {\r\n children?: React.ReactNode;\r\n isOpen?: boolean;\r\n onClose(): void;\r\n position: RelativePosition;\r\n target?: HTMLElement;\r\n keepContentsMounted?: boolean;\r\n}\r\n\r\n/** @internal */\r\nexport function PopupItemPopup(props: PopupItemPopupProps) {\r\n const isHidden = useToolbarPopupAutoHideContext();\r\n const className = classnames(\r\n \"components-toolbar-popupItem_popupItemPopup\",\r\n isHidden && \"nz-hidden\");\r\n\r\n return <Popup\r\n className={className}\r\n offset={0}\r\n showShadow={false}\r\n {...props}\r\n />;\r\n}\r\n"]}
|
|
@@ -117,7 +117,7 @@ export function PopupItemWithDrag(props) {
|
|
|
117
117
|
closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),
|
|
118
118
|
setSelectedItem: /* istanbul ignore next */ (buttonItem) => setActiveAction(buttonItem),
|
|
119
119
|
} },
|
|
120
|
-
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-
|
|
120
|
+
React.createElement("button", { "data-item-id": props.itemId, "data-item-type": "action-tool-button", "data-item-group-priority": props.groupPriority, "data-item-priority": props.itemPriority, "data-item-provider-id": props.providerId, ref: targetRef, onPointerDown: handlePointerDown, onClick: handleButtonClick, onKeyDown: props.onKeyDown, className: className, style: props.style, title: title },
|
|
121
121
|
React.createElement("div", { className: "components-icon" }, icon),
|
|
122
122
|
props.badge &&
|
|
123
123
|
React.createElement("div", { className: "components-badge" }, badge),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupItemWithDrag.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItemWithDrag.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAgB,uBAAuB,EAAE,sBAAsB,EAAe,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3J,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,sCAAsC,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAUlD,SAAS,mBAAmB,CAAC,IAAiB;IAC5C,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE;QAClC,uBAAuB;QACvB,IAAI,oBAAoB,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;YAClD,IAAI,SAAS,CAAC,QAAQ;gBACpB,OAAO,SAAS,CAAC;SACpB;aAAM,IAAI,oBAAoB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE;YACxD,MAAM,WAAW,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;YACnD,IAA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AC,CAAC;YACrB,IAAI,SAAS,KAAK,qBAAqB,CAAC,GAAG;gBACzC,OAAO,gBAAgB,CAAC,WAAW,CAAC;YACtC,OAAO,gBAAgB,CAAC,UAAU,CAAC;SACpC;QACD,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,SAAS,CAAC,KAAK;YAClB,OAAO,gBAAgB,CAAC,QAAQ,CAAC;QACnC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,gBAAgB,CAAC,GAAG,CAAC;KAC/B;AACH,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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, ConditionalBooleanValue, ConditionalStringValue, GroupButton, RelativePosition, ToolbarItemUtilities } from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, IconHelper, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { PopupItemPopup, ToolbarPopupContext } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { ToolbarPanelAlignment, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { useDragInteraction } from \"./useDragInteraction\";\r\nimport { Direction } from \"./utilities/Direction\";\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemWithDragProps extends ToolbarButtonItemProps {\r\n /** Panel of the toolbar. */\r\n groupItem: GroupButton;\r\n}\r\n\r\nfunction tryFindActiveAction(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n if (childItem.isActive)\r\n return childItem;\r\n } else if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = tryFindActiveAction(childItem);\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getFirstAvailableChildActionItem(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = getFirstAvailableChildActionItem(childItem);\r\n // istanbul ignore else\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getActiveAction(item: GroupButton): ActionButton | undefined {\r\n const activeItem = tryFindActiveAction(item);\r\n if (activeItem)\r\n return activeItem;\r\n\r\n // initially look only in root items\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n }\r\n }\r\n\r\n // if not found look inside groups\r\n return getFirstAvailableChildActionItem(item);\r\n}\r\n\r\n/** Expandable Group button Item\r\n * @public\r\n */\r\nexport function PopupItemWithDrag(props: PopupItemWithDragProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const [activeAction, setActiveAction] = React.useState(getActiveAction(props.groupItem));\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n\r\n React.useEffect(() => {\r\n const newActiveAction = getActiveAction(props.groupItem);\r\n // istanbul ignore else\r\n if (newActiveAction) {\r\n // istanbul ignore next\r\n if (newActiveAction.isActive) {\r\n setActiveAction(newActiveAction);\r\n } else {\r\n if (activeAction && activeAction.isActive) {\r\n setActiveAction({ ...activeAction, isActive: false });\r\n }\r\n }\r\n }\r\n }, [props.groupItem, activeAction]);\r\n\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onOpenPanel = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n }, [isPanelShown, processPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onGroupButtonClick = React.useCallback(() => {\r\n // only execute action if not disabled\r\n activeAction && !ConditionalBooleanValue.getValue(activeAction.isDisabled) && activeAction.execute();\r\n }, [activeAction]);\r\n\r\n const badge = activeAction ? BadgeUtilities.getComponentForBadgeType(activeAction.badgeType) : props.badge;\r\n const icon = activeAction ? IconHelper.getIconReactNode(activeAction.icon, activeAction.internalData) : props.icon;\r\n const title = activeAction ? ConditionalStringValue.getValue(activeAction.label) : props.title;\r\n const isActive = activeAction ? activeAction.isActive : props.isActive;\r\n const isDisabled = ConditionalBooleanValue.getValue(activeAction ? activeAction.isDisabled : props.isDisabled);\r\n\r\n const { handlePointerDown, handleButtonClick } = useDragInteraction(onGroupButtonClick, onOpenPanel);\r\n\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n isActive && \"components-active\",\r\n isDisabled && \"components-disabled-drag\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? /* istanbul ignore next */ overflowExpandsTo : expandsTo;\r\n\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),\r\n setSelectedItem: /* istanbul ignore next */ (buttonItem: ActionButton) => setActiveAction(buttonItem),\r\n }\r\n }>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-providerid={props.providerId}\r\n ref={targetRef}\r\n onPointerDown={handlePointerDown}\r\n onClick={handleButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={title}\r\n >\r\n <div className=\"components-icon\">\r\n {icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {badge}\r\n </div>\r\n }\r\n <div className=\"components-triangle\" />\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n >\r\n <PopupItemsPanel groupItem={props.groupItem} activateOnPointerUp={true} />\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport function toToolbarPopupRelativePosition(expandsTo: Direction, alignment: ToolbarPanelAlignment): RelativePosition {\r\n // istanbul ignore next\r\n switch (expandsTo) {\r\n case Direction.Bottom: {\r\n if (alignment === ToolbarPanelAlignment.End)\r\n return RelativePosition.BottomRight;\r\n return RelativePosition.BottomLeft;\r\n }\r\n case Direction.Left:\r\n return RelativePosition.LeftTop;\r\n case Direction.Right:\r\n return RelativePosition.RightTop;\r\n case Direction.Top:\r\n return RelativePosition.Top;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PopupItemWithDrag.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/PopupItemWithDrag.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAgB,uBAAuB,EAAE,sBAAsB,EAAe,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC3J,OA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AAiB,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,KAAK,EAAE,KAAK;YAEZ,6BAAK,SAAS,EAAC,iBAAiB,IAC7B,IAAI,CACD;YACL,KAAK,CAAC,KAAK;gBACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CACF;YAER,6BAAK,SAAS,EAAC,qBAAqB,GAAG,CAChC;QACT,oBAAC,cAAc,IACb,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,8BAA8B,CAAC,kBAAkB,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE,MAAM;YAEd,oBAAC,eAAe,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,mBAAmB,EAAE,IAAI,GAAI,CAC3D,CACY,CAChC,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,8BAA8B,CAAC,SAAoB,EAAE,SAAgC;IACnG,uBAAuB;IACvB,QAAQ,SAAS,EAAE;QACjB,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,SAAS,KAAK,qBAAqB,CAAC,GAAG;gBACzC,OAAO,gBAAgB,CAAC,WAAW,CAAC;YACtC,OAAO,gBAAgB,CAAC,UAAU,CAAC;SACpC;QACD,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,gBAAgB,CAAC,OAAO,CAAC;QAClC,KAAK,SAAS,CAAC,KAAK;YAClB,OAAO,gBAAgB,CAAC,QAAQ,CAAC;QACnC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,gBAAgB,CAAC,GAAG,CAAC;KAC/B;AACH,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 \"./PopupItem.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, ConditionalBooleanValue, ConditionalStringValue, GroupButton, RelativePosition, ToolbarItemUtilities } from \"@itwin/appui-abstract\";\r\nimport { BadgeUtilities, IconHelper, useRefState } from \"@itwin/core-react\";\r\nimport { ToolbarButtonItemProps } from \"./Item\";\r\nimport { PopupItemPopup, ToolbarPopupContext } from \"./PopupItem\";\r\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\r\nimport { ToolbarPanelAlignment, useToolbarWithOverflowDirectionContext, useToolItemEntryContext } from \"./ToolbarWithOverflow\";\r\nimport { useDragInteraction } from \"./useDragInteraction\";\r\nimport { Direction } from \"./utilities/Direction\";\r\n\r\n/** Properties of [[PopupItem]] component.\r\n * @public\r\n */\r\nexport interface PopupItemWithDragProps extends ToolbarButtonItemProps {\r\n /** Panel of the toolbar. */\r\n groupItem: GroupButton;\r\n}\r\n\r\nfunction tryFindActiveAction(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n if (childItem.isActive)\r\n return childItem;\r\n } else if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = tryFindActiveAction(childItem);\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getFirstAvailableChildActionItem(item: GroupButton): ActionButton | undefined {\r\n for (const childItem of item.items) {\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n } else {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isGroupButton(childItem)) {\r\n const nestedChild = getFirstAvailableChildActionItem(childItem);\r\n // istanbul ignore else\r\n if (nestedChild)\r\n return nestedChild;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getActiveAction(item: GroupButton): ActionButton | undefined {\r\n const activeItem = tryFindActiveAction(item);\r\n if (activeItem)\r\n return activeItem;\r\n\r\n // initially look only in root items\r\n for (const childItem of item.items) {\r\n // istanbul ignore else\r\n if (ToolbarItemUtilities.isActionButton(childItem)) {\r\n return childItem;\r\n }\r\n }\r\n\r\n // if not found look inside groups\r\n return getFirstAvailableChildActionItem(item);\r\n}\r\n\r\n/** Expandable Group button Item\r\n * @public\r\n */\r\nexport function PopupItemWithDrag(props: PopupItemWithDragProps) {\r\n const [isPanelShown, setPanelShown] = React.useState(false);\r\n const [activeAction, setActiveAction] = React.useState(getActiveAction(props.groupItem));\r\n const { expandsTo, overflowExpandsTo, panelAlignment, onPopupPanelOpenClose } = useToolbarWithOverflowDirectionContext();\r\n\r\n React.useEffect(() => {\r\n const newActiveAction = getActiveAction(props.groupItem);\r\n // istanbul ignore else\r\n if (newActiveAction) {\r\n // istanbul ignore next\r\n if (newActiveAction.isActive) {\r\n setActiveAction(newActiveAction);\r\n } else {\r\n if (activeAction && activeAction.isActive) {\r\n setActiveAction({ ...activeAction, isActive: false });\r\n }\r\n }\r\n }\r\n }, [props.groupItem, activeAction]);\r\n\r\n const processPanelOpenClose = React.useCallback((isOpening: boolean) => {\r\n setPanelShown((prev) => {\r\n // istanbul ignore else\r\n if (prev !== isOpening)\r\n onPopupPanelOpenClose(isOpening);\r\n return isOpening;\r\n });\r\n }, [setPanelShown, onPopupPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onOpenPanel = React.useCallback(() => {\r\n processPanelOpenClose(!isPanelShown);\r\n }, [isPanelShown, processPanelOpenClose]);\r\n\r\n // handle open and closing popup panel\r\n const onGroupButtonClick = React.useCallback(() => {\r\n // only execute action if not disabled\r\n activeAction && !ConditionalBooleanValue.getValue(activeAction.isDisabled) && activeAction.execute();\r\n }, [activeAction]);\r\n\r\n const badge = activeAction ? BadgeUtilities.getComponentForBadgeType(activeAction.badgeType) : props.badge;\r\n const icon = activeAction ? IconHelper.getIconReactNode(activeAction.icon, activeAction.internalData) : props.icon;\r\n const title = activeAction ? ConditionalStringValue.getValue(activeAction.label) : props.title;\r\n const isActive = activeAction ? activeAction.isActive : props.isActive;\r\n const isDisabled = ConditionalBooleanValue.getValue(activeAction ? activeAction.isDisabled : props.isDisabled);\r\n\r\n const { handlePointerDown, handleButtonClick } = useDragInteraction(onGroupButtonClick, onOpenPanel);\r\n\r\n const className = classnames(\r\n \"components-toolbar-button-item\",\r\n \"components-toolbar-expandable-button\",\r\n isActive && \"components-active\",\r\n isDisabled && \"components-disabled-drag\",\r\n props.className);\r\n\r\n const [targetRef, target] = useRefState<HTMLButtonElement>();\r\n const handleClose = React.useCallback(() => {\r\n processPanelOpenClose(false);\r\n }, [processPanelOpenClose]);\r\n const { hasOverflow } = useToolItemEntryContext();\r\n const expandsToDirection = hasOverflow ? /* istanbul ignore next */ overflowExpandsTo : expandsTo;\r\n\r\n return (\r\n <ToolbarPopupContext.Provider value={{\r\n closePanel: /* istanbul ignore next */ () => processPanelOpenClose(false),\r\n setSelectedItem: /* istanbul ignore next */ (buttonItem: ActionButton) => setActiveAction(buttonItem),\r\n }\r\n }>\r\n <button\r\n data-item-id={props.itemId}\r\n data-item-type=\"action-tool-button\"\r\n data-item-group-priority={props.groupPriority}\r\n data-item-priority={props.itemPriority}\r\n data-item-provider-id={props.providerId}\r\n ref={targetRef}\r\n onPointerDown={handlePointerDown}\r\n onClick={handleButtonClick}\r\n onKeyDown={props.onKeyDown}\r\n className={className}\r\n style={props.style}\r\n title={title}\r\n >\r\n <div className=\"components-icon\">\r\n {icon}\r\n </div>\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {badge}\r\n </div>\r\n }\r\n <div className=\"components-triangle\" />\r\n </button>\r\n <PopupItemPopup\r\n isOpen={isPanelShown}\r\n onClose={handleClose}\r\n position={toToolbarPopupRelativePosition(expandsToDirection, panelAlignment)}\r\n target={target}\r\n >\r\n <PopupItemsPanel groupItem={props.groupItem} activateOnPointerUp={true} />\r\n </PopupItemPopup>\r\n </ToolbarPopupContext.Provider>\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport function toToolbarPopupRelativePosition(expandsTo: Direction, alignment: ToolbarPanelAlignment): RelativePosition {\r\n // istanbul ignore next\r\n switch (expandsTo) {\r\n case Direction.Bottom: {\r\n if (alignment === ToolbarPanelAlignment.End)\r\n return RelativePosition.BottomRight;\r\n return RelativePosition.BottomLeft;\r\n }\r\n case Direction.Left:\r\n return RelativePosition.LeftTop;\r\n case Direction.Right:\r\n return RelativePosition.RightTop;\r\n case Direction.Top:\r\n return RelativePosition.Top;\r\n }\r\n}\r\n"]}
|
|
@@ -26,7 +26,7 @@ export function GroupTool(props) {
|
|
|
26
26
|
if (!props.isDisabled && props.onPointerUp)
|
|
27
27
|
props.onPointerUp(props.item);
|
|
28
28
|
}, [props]);
|
|
29
|
-
return (React.createElement("div", { className: itemClassName, onClick: handleClick, onKeyDown: props.onKeyDown, onPointerUp: handlePointerUp, "data-item-id": props.item.id, "data-item-type": "popup-tool-panel-item", "data-item-priority": props.item.itemPriority, "data-item-
|
|
29
|
+
return (React.createElement("div", { className: itemClassName, onClick: handleClick, onKeyDown: props.onKeyDown, onPointerUp: handlePointerUp, "data-item-id": props.item.id, "data-item-type": "popup-tool-panel-item", "data-item-priority": props.item.itemPriority, "data-item-provider-id": props.item.providerId, ref: ref, style: props.style, role: "button", tabIndex: 0 },
|
|
30
30
|
React.createElement("div", { className: "components-icon" },
|
|
31
31
|
props.icon,
|
|
32
32
|
props.badge &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tool.js","sourceRoot":"","sources":["../../../../../../src/components-react/toolbar/groupPanel/tool/Tool.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8B7D;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S,EAC1B,WAAW,EAAE,eAAe,kBACd,KAAK,CAAC,IAAI,CAAC,EAAE,oBACZ,uBAAuB,wBAClB,KAAK,CAAC,IAAI,CAAC,YAAY,2BACpB,KAAK,CAAC,IAAI,CAAC,UAAU,EAC5C,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC;QAEX,6BAAK,SAAS,EAAC,iBAAiB;YAC7B,KAAK,CAAC,IAAI;YACV,KAAK,CAAC,KAAK;gBACV,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR,CAEJ;QACN,6BAAK,SAAS,EAAC,kBAAkB,IAC9B,KAAK,CAAC,KAAK,CACR;QACL,KAAK,CAAC,QAAQ,CACX,CACP,CAAC;AACJ,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 \"./Tool.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { ActionButton, GroupButton } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, useTargeted } from \"@itwin/core-react\";\r\n\r\n/** Properties of [[GroupTool]] component.\r\n * @internal\r\n */\r\nexport interface GroupToolProps extends CommonProps {\r\n /** Additional content, besides icon and label. */\r\n children?: React.ReactNode;\r\n /** Tool icon. */\r\n icon?: React.ReactNode;\r\n /** Describes if the item is active. */\r\n isActive?: boolean;\r\n /** Describes if the item is disabled. */\r\n isDisabled?: boolean;\r\n /** Describes if the item is focused. */\r\n isFocused?: boolean;\r\n /** Tool label. */\r\n label?: string;\r\n /** Function called when the item is clicked. */\r\n onClick?: (item: GroupButton | ActionButton) => void;\r\n /** Function called when pointer up event is received. */\r\n onPointerUp?: (item: GroupButton | ActionButton) => void;\r\n /** A badge to draw. */\r\n badge?: React.ReactNode;\r\n /** GroupButton item */\r\n item: GroupButton | ActionButton;\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/** Tool entry of tool group panel. Used in [[GroupColumn]].\r\n * @internal\r\n */\r\nexport function GroupTool(props: GroupToolProps) {\r\n const ref = React.useRef<HTMLDivElement>(null);\r\n const targeted = useTargeted(ref);\r\n const itemClassName = classnames(\r\n \"components-toolbar-item-expandable-group-tool-item\",\r\n props.isActive && \"components-active\",\r\n props.isFocused && \"components-focused\",\r\n props.isDisabled && \"components-disabled\",\r\n props.onPointerUp && \"components-pointer-up\",\r\n targeted && \"components-targeted\",\r\n props.className);\r\n\r\n const handleClick = React.useCallback(() => {\r\n // istanbul ignore else\r\n if (!props.isDisabled && props.onClick)\r\n props.onClick(props.item);\r\n }, [props]);\r\n\r\n const handlePointerUp = React.useCallback(() => {\r\n // istanbul ignore else\r\n if (!props.isDisabled && props.onPointerUp)\r\n props.onPointerUp(props.item);\r\n }, [props]);\r\n\r\n return (\r\n <div\r\n className={itemClassName}\r\n onClick={handleClick}\r\n onKeyDown={props.onKeyDown}\r\n onPointerUp={handlePointerUp}\r\n data-item-id={props.item.id}\r\n data-item-type=\"popup-tool-panel-item\"\r\n data-item-priority={props.item.itemPriority}\r\n data-item-provider-id={props.item.providerId}\r\n ref={ref}\r\n style={props.style}\r\n role=\"button\"\r\n tabIndex={0}\r\n >\r\n <div className=\"components-icon\">\r\n {props.icon}\r\n {props.badge &&\r\n <div className=\"components-badge\">\r\n {props.badge}\r\n </div>\r\n }\r\n </div>\r\n <div className=\"components-label\">\r\n {props.label}\r\n </div>\r\n {props.children}\r\n </div>\r\n );\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "3.2.0-dev.
|
|
3
|
+
"version": "3.2.0-dev.38",
|
|
4
4
|
"description": "iTwin.js UI complex components",
|
|
5
5
|
"main": "lib/cjs/components-react.js",
|
|
6
6
|
"module": "lib/esm/components-react.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"url": "http://www.bentley.com"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@itwin/appui-abstract": "^3.2.0-dev.
|
|
24
|
-
"@itwin/core-bentley": "^3.2.0-dev.
|
|
25
|
-
"@itwin/core-react": "^3.2.0-dev.
|
|
23
|
+
"@itwin/appui-abstract": "^3.2.0-dev.38",
|
|
24
|
+
"@itwin/core-bentley": "^3.2.0-dev.38",
|
|
25
|
+
"@itwin/core-react": "^3.2.0-dev.38",
|
|
26
26
|
"react": "^17.0.0",
|
|
27
27
|
"react-dom": "^17.0.0"
|
|
28
28
|
},
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@itwin/appui-abstract": "3.2.0-dev.
|
|
35
|
-
"@itwin/build-tools": "3.2.0-dev.
|
|
36
|
-
"@itwin/core-bentley": "3.2.0-dev.
|
|
37
|
-
"@itwin/core-common": "3.2.0-dev.
|
|
38
|
-
"@itwin/core-i18n": "3.2.0-dev.
|
|
39
|
-
"@itwin/core-react": "3.2.0-dev.
|
|
40
|
-
"@itwin/eslint-plugin": "3.2.0-dev.
|
|
34
|
+
"@itwin/appui-abstract": "3.2.0-dev.38",
|
|
35
|
+
"@itwin/build-tools": "3.2.0-dev.38",
|
|
36
|
+
"@itwin/core-bentley": "3.2.0-dev.38",
|
|
37
|
+
"@itwin/core-common": "3.2.0-dev.38",
|
|
38
|
+
"@itwin/core-i18n": "3.2.0-dev.38",
|
|
39
|
+
"@itwin/core-react": "3.2.0-dev.38",
|
|
40
|
+
"@itwin/eslint-plugin": "3.2.0-dev.38",
|
|
41
41
|
"@testing-library/react": "^12.0.0",
|
|
42
42
|
"@testing-library/react-hooks": "^7.0.2",
|
|
43
43
|
"@testing-library/user-event": "^13.2.1",
|