@itwin/appui-react 5.7.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/lib/appui-react/editors/CustomNumberEditor.d.ts.map +1 -1
  3. package/lib/appui-react/editors/CustomNumberEditor.js +3 -1
  4. package/lib/appui-react/editors/CustomNumberEditor.js.map +1 -1
  5. package/lib/appui-react/editors/NumericEditor.d.ts.map +1 -1
  6. package/lib/appui-react/editors/NumericEditor.js +3 -1
  7. package/lib/appui-react/editors/NumericEditor.js.map +1 -1
  8. package/lib/appui-react/editors/TextEditor.d.ts.map +1 -1
  9. package/lib/appui-react/editors/TextEditor.js +3 -1
  10. package/lib/appui-react/editors/TextEditor.js.map +1 -1
  11. package/lib/appui-react/hooks/useSafeContext.d.ts +7 -0
  12. package/lib/appui-react/hooks/useSafeContext.d.ts.map +1 -0
  13. package/lib/appui-react/hooks/useSafeContext.js +17 -0
  14. package/lib/appui-react/hooks/useSafeContext.js.map +1 -0
  15. package/lib/appui-react/preview/PreviewFeatures.d.ts +4 -0
  16. package/lib/appui-react/preview/PreviewFeatures.d.ts.map +1 -1
  17. package/lib/appui-react/preview/PreviewFeatures.js +1 -0
  18. package/lib/appui-react/preview/PreviewFeatures.js.map +1 -1
  19. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts +6 -0
  20. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts.map +1 -0
  21. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js +15 -0
  22. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js.map +1 -0
  23. package/lib/appui-react/toolbar/new-toolbars/ActionItem.d.ts +2 -2
  24. package/lib/appui-react/toolbar/new-toolbars/ActionItem.d.ts.map +1 -1
  25. package/lib/appui-react/toolbar/new-toolbars/ActionItem.js +2 -1
  26. package/lib/appui-react/toolbar/new-toolbars/ActionItem.js.map +1 -1
  27. package/lib/appui-react/toolbar/new-toolbars/CustomItem.d.ts +2 -2
  28. package/lib/appui-react/toolbar/new-toolbars/CustomItem.d.ts.map +1 -1
  29. package/lib/appui-react/toolbar/new-toolbars/CustomItem.js +3 -2
  30. package/lib/appui-react/toolbar/new-toolbars/CustomItem.js.map +1 -1
  31. package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts +2 -3
  32. package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts.map +1 -1
  33. package/lib/appui-react/toolbar/new-toolbars/GroupItem.js +6 -7
  34. package/lib/appui-react/toolbar/new-toolbars/GroupItem.js.map +1 -1
  35. package/lib/appui-react/toolbar/new-toolbars/Item.d.ts +3 -5
  36. package/lib/appui-react/toolbar/new-toolbars/Item.d.ts.map +1 -1
  37. package/lib/appui-react/toolbar/new-toolbars/Item.js +15 -19
  38. package/lib/appui-react/toolbar/new-toolbars/Item.js.map +1 -1
  39. package/lib/appui-react/toolbar/new-toolbars/OverflowButton.d.ts +0 -1
  40. package/lib/appui-react/toolbar/new-toolbars/OverflowButton.d.ts.map +1 -1
  41. package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js +3 -2
  42. package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js.map +1 -1
  43. package/lib/appui-react/toolbar/new-toolbars/Separator.d.ts +8 -0
  44. package/lib/appui-react/toolbar/new-toolbars/Separator.d.ts.map +1 -0
  45. package/lib/appui-react/toolbar/new-toolbars/Separator.js +19 -0
  46. package/lib/appui-react/toolbar/new-toolbars/Separator.js.map +1 -0
  47. package/lib/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
  48. package/lib/appui-react/toolbar/new-toolbars/Surface.d.ts +5 -3
  49. package/lib/appui-react/toolbar/new-toolbars/Surface.d.ts.map +1 -1
  50. package/lib/appui-react/toolbar/new-toolbars/Surface.js.map +1 -1
  51. package/lib/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
  52. package/lib/appui-react/toolbar/new-toolbars/ToolGroup.d.ts +0 -5
  53. package/lib/appui-react/toolbar/new-toolbars/ToolGroup.d.ts.map +1 -1
  54. package/lib/appui-react/toolbar/new-toolbars/ToolGroup.js +50 -19
  55. package/lib/appui-react/toolbar/new-toolbars/ToolGroup.js.map +1 -1
  56. package/lib/appui-react/toolbar/new-toolbars/Toolbar.d.ts +5 -0
  57. package/lib/appui-react/toolbar/new-toolbars/Toolbar.d.ts.map +1 -1
  58. package/lib/appui-react/toolbar/new-toolbars/Toolbar.js +45 -12
  59. package/lib/appui-react/toolbar/new-toolbars/Toolbar.js.map +1 -1
  60. package/lib/appui-react/toolbar/new-toolbars/useOverflow.js +2 -2
  61. package/lib/appui-react/toolbar/new-toolbars/useOverflow.js.map +1 -1
  62. package/lib/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  63. package/lib/appui-react/widget-panels/ToolSettings.js +10 -7
  64. package/lib/appui-react/widget-panels/ToolSettings.js.map +1 -1
  65. package/lib/appui-react/widget-panels/useWidgetDirection.d.ts +1 -1
  66. package/lib/appui-react/widget-panels/useWidgetDirection.js +1 -1
  67. package/lib/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
  68. package/lib/appui-react/widgets/useWidget.d.ts +5 -1
  69. package/lib/appui-react/widgets/useWidget.d.ts.map +1 -1
  70. package/lib/appui-react/widgets/useWidget.js +5 -1
  71. package/lib/appui-react/widgets/useWidget.js.map +1 -1
  72. package/lib/cjs/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
  73. package/lib/cjs/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
  74. package/lib/esm/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
  75. package/lib/esm/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
  76. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"useOverflow.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/useOverflow.tsx"],"names":[],"mappings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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { useResizeObserver } from \"@itwin/core-react/internal\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\n\ntype Orientation = \"horizontal\" | \"vertical\";\n\n/** @internal */\nexport const useOverflow = <\n TContainer extends HTMLElement,\n TComponent extends HTMLElement\n>(\n allItems: ReadonlyArray<string>,\n orientation: Orientation,\n getItemSize: (item: string) => SizeProps,\n getOverflowSize: () => SizeProps\n) => {\n const [visible, setVisible] = React.useState(allItems.length);\n const [calculate, setCalculate] = React.useState(false);\n const containerSizeRef = React.useRef<SizeProps>();\n const componentSizeRef = React.useRef<SizeProps>();\n\n const [prevOrientation, setPrevOrientation] = React.useState(orientation);\n if (prevOrientation !== orientation) {\n setPrevOrientation(orientation);\n setCalculate(true);\n }\n\n React.useLayoutEffect(() => {\n setCalculate(false);\n if (!calculate) return;\n\n const containerSize = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n if (containerSize === undefined) return;\n\n const componentSize = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n if (componentSize === undefined) return;\n\n const itemSizes = allItems.map((item) => {\n const size = getItemSize(item);\n return getLength(size, orientation);\n });\n const overflowSize = getLength(getOverflowSize(), orientation);\n\n const otherSize = itemSizes.reduce((acc, size) => acc + size, 0);\n if (otherSize < containerSize) {\n // No overflow.\n setVisible(itemSizes.length);\n return;\n }\n\n let totalSize = overflowSize;\n if (totalSize >= containerSize) {\n // Render only overflow.\n setVisible(0);\n return;\n }\n\n let newVisible = 0;\n for (const size of itemSizes) {\n totalSize += size;\n if (totalSize >= containerSize) {\n break;\n }\n newVisible++;\n }\n setVisible(newVisible);\n }, [calculate, allItems, getItemSize, getOverflowSize, orientation]);\n const containerRoRef = useResizeObserver<TContainer>(\n React.useCallback(\n (width: number, height: number) => {\n const length = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n containerSizeRef.current = { width, height };\n const newLength = getLength(containerSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n const componentRoRef = useResizeObserver<TComponent>(\n React.useCallback(\n (width: number, height: number) => {\n const length = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n componentSizeRef.current = { width, height };\n const newLength = getLength(componentSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n\n const overflow = calculate || visible < allItems.length;\n const visibleItems = calculate ? allItems.length : visible;\n return [containerRoRef, componentRoRef, visibleItems, overflow] as const;\n};\n\nfunction getLength(\n size: { width: number; height: number },\n orientation: Orientation\n) {\n return orientation === \"horizontal\" ? size.width : size.height;\n}\n"]}
1
+ {"version":3,"file":"useOverflow.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/useOverflow.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAK/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,QAA+B,EAC/B,WAAwB,EACxB,WAAwC,EACxC,eAAgC,EAChC,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,KAA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AAG,gBAAgB,CAAC,OAAO;YACrC,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC;YAClD,CAAC,CAAC,SAAS,CAAC;QACd,gBAAgB,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAC7C,MAAM,SAAS,GAAG,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAEnE,IAAI,SAAS,KAAK,MAAM;YAAE,OAAO;QACjC,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,SAAS,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IACxD,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3D,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,CAAU,CAAC;AAC3E,CAAC,CAAC;AAEF,SAAS,SAAS,CAChB,IAAuC,EACvC,WAAwB;IAExB,OAAO,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Toolbar\n */\n\nimport * as React from \"react\";\nimport { useResizeObserver } from \"@itwin/core-react/internal\";\nimport type { SizeProps } from \"../../utils/SizeProps.js\";\n\ntype Orientation = \"horizontal\" | \"vertical\";\n\n/** @internal */\nexport const useOverflow = <\n TContainer extends HTMLElement,\n TComponent extends HTMLElement\n>(\n allItems: ReadonlyArray<string>,\n orientation: Orientation,\n getItemSize: (item: string) => SizeProps,\n getOverflowSize: () => SizeProps\n) => {\n const [visible, setVisible] = React.useState(allItems.length);\n const [calculate, setCalculate] = React.useState(false);\n const containerSizeRef = React.useRef<SizeProps>();\n const componentSizeRef = React.useRef<SizeProps>();\n\n const [prevOrientation, setPrevOrientation] = React.useState(orientation);\n if (prevOrientation !== orientation) {\n setPrevOrientation(orientation);\n setCalculate(true);\n }\n\n React.useLayoutEffect(() => {\n setCalculate(false);\n if (!calculate) return;\n\n const containerSize = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n if (containerSize === undefined) return;\n\n const componentSize = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n if (componentSize === undefined) return;\n\n const itemSizes = allItems.map((item) => {\n const size = getItemSize(item);\n return getLength(size, orientation);\n });\n const overflowSize = getLength(getOverflowSize(), orientation);\n\n const otherSize = itemSizes.reduce((acc, size) => acc + size, 0);\n if (otherSize < containerSize) {\n // No overflow.\n setVisible(itemSizes.length);\n return;\n }\n\n if (overflowSize >= containerSize) {\n // Render only overflow.\n setVisible(0);\n return;\n }\n\n let totalSize = overflowSize;\n let newVisible = 0;\n for (const size of itemSizes) {\n totalSize += size;\n if (totalSize >= containerSize) {\n break;\n }\n newVisible++;\n }\n setVisible(newVisible);\n }, [calculate, allItems, getItemSize, getOverflowSize, orientation]);\n const containerRoRef = useResizeObserver<TContainer>(\n React.useCallback(\n (width: number, height: number) => {\n const length = containerSizeRef.current\n ? getLength(containerSizeRef.current, orientation)\n : undefined;\n containerSizeRef.current = { width, height };\n const newLength = getLength(containerSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n const componentRoRef = useResizeObserver<TComponent>(\n React.useCallback(\n (width: number, height: number) => {\n const length = componentSizeRef.current\n ? getLength(componentSizeRef.current, orientation)\n : undefined;\n componentSizeRef.current = { width, height };\n const newLength = getLength(componentSizeRef.current, orientation);\n\n if (newLength === length) return;\n setCalculate(true);\n },\n [orientation]\n )\n );\n\n const overflow = calculate || visible < allItems.length;\n const visibleItems = calculate ? allItems.length : visible;\n return [containerRoRef, componentRoRef, visibleItems, overflow] as const;\n};\n\nfunction getLength(\n size: { width: number; height: number },\n orientation: Orientation\n) {\n return orientation === \"horizontal\" ? size.width : size.height;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ToolSettings.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,qBAAqB,CAAC;AAQ7B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAeD;;eAEe;AACf,wBAAgB,iCAAiC,YAMhD;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,6BAGvC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,sBA6CxC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B,oCA4B9C;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,sKAwBlC;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,6BAKlC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,sBAyBxC"}
1
+ {"version":3,"file":"ToolSettings.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,qBAAqB,CAAC;AAS7B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAeD;;eAEe;AACf,wBAAgB,iCAAiC,YAMhD;AAED,gBAAgB;AAChB,wBAAgB,wBAAwB,6BAGvC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,sBA+CxC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B,oCA4B9C;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,sKAwBlC;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,6BAKlC;AAED,gBAAgB;AAChB,wBAAgB,yBAAyB,sBA2BxC"}
@@ -21,6 +21,7 @@ import { DockedBar } from "./DockedBar.js";
21
21
  import { useActiveFrontstageDef } from "../frontstage/FrontstageDef.js";
22
22
  import { LockProvider } from "../editors/LockProvider.js";
23
23
  import { ToolSettingsEditorsProvider } from "../preview/tool-settings-lock-button/useToolSettingsLockButton.js";
24
+ import { ToolSettingsContext } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
24
25
  function EmptyToolSettingsLabel({ toolId }) {
25
26
  const { translate } = useTranslation();
26
27
  const tool = IModelApp.tools.find(toolId);
@@ -64,12 +65,13 @@ export function ToolSettingsDockedContent() {
64
65
  : toolSettingEntries;
65
66
  // for the overflow to work properly each setting in the DockedToolSettings should be wrapped by a DockedToolSetting component
66
67
  return (React.createElement(DockedBar, { placement: "top" },
67
- React.createElement(ToolSettingsEditorsProvider, null,
68
- React.createElement(DockedToolSettings, { itemId: InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??
69
- "none", key: forceRefreshKey }, entries.map((entry, index) => (React.createElement(DockedToolSetting, { key: index },
70
- React.createElement(LockProvider, null,
71
- entry.labelNode,
72
- entry.editorNode))))))));
68
+ React.createElement(ToolSettingsContext.Provider, { value: true },
69
+ React.createElement(ToolSettingsEditorsProvider, null,
70
+ React.createElement(DockedToolSettings, { itemId: InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??
71
+ "none", key: forceRefreshKey }, entries.map((entry, index) => (React.createElement(DockedToolSetting, { key: index },
72
+ React.createElement(LockProvider, null,
73
+ entry.labelNode,
74
+ entry.editorNode)))))))));
73
75
  }
74
76
  /** @internal */
75
77
  export function useHorizontalToolSettingEntries() {
@@ -134,7 +136,8 @@ export function ToolSettingsWidgetContent() {
134
136
  const providerId = InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ?? "none";
135
137
  return (React.createElement("div", { "data-toolsettings-provider": providerId, className: "uifw-floating-toolSettings-container", ref: floatingToolSettingsContainerRef, key: forceRefreshKey },
136
138
  React.createElement(ScrollableWidgetContent, null,
137
- React.createElement(ToolSettingsEditorsProvider, null, node ?? frontstageDef?.activeToolEmptyNode ?? (React.createElement(EmptyToolSettingsLabel, { toolId: activeToolId }))))));
139
+ React.createElement(ToolSettingsContext.Provider, { value: true },
140
+ React.createElement(ToolSettingsEditorsProvider, null, node ?? frontstageDef?.activeToolEmptyNode ?? (React.createElement(EmptyToolSettingsLabel, { toolId: activeToolId })))))));
138
141
  }
139
142
  /**
140
143
  * Hook that returns a key that can be used to force refresh the tool settings.
@@ -1 +1 @@
1
- {"version":3,"file":"ToolSettings.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,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C,uBAAuB;YACtB,oBAAC,2BAA2B,QACzB,IAAI,IAAI,aAAa,EAAE,mBAAmB,IAAI,CAC7C,oBAAC,sBAAsB,IAAC,MAAM,EAAE,YAAY,GAAI,CACjD,CAC2B,CACN,CACtB,CACP,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,gBAAqB;IAC1C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,+EAA+E;QAC/E,0BAA0B;QAC1B,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvB,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ToolSettings\n */\n\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { DockedToolSettings } from \"../layout/tool-settings/Docked.js\";\nimport { DockedToolSetting } from \"../layout/tool-settings/Setting.js\";\nimport { ScrollableWidgetContent } from \"../layout/widget/Content.js\";\nimport \"./ToolSettings.scss\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\nimport { useTranslation } from \"../hooks/useTranslation.js\";\nimport { DockedBar } from \"./DockedBar.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { LockProvider } from \"../editors/LockProvider.js\";\nimport { ToolSettingsEditorsProvider } from \"../preview/tool-settings-lock-button/useToolSettingsLockButton.js\";\n\n/** Defines a ToolSettings property entry.\n * @public\n */\nexport interface ToolSettingsEntry {\n // label node which potentially can contain a lock node as well.\n labelNode: React.ReactNode;\n // editor entry used to display and edit the property value\n editorNode: React.ReactNode;\n}\n\nfunction EmptyToolSettingsLabel({ toolId }: { toolId: string }) {\n const { translate } = useTranslation();\n const tool = IModelApp.tools.find(toolId);\n const toolName = tool?.flyover;\n return (\n <Text as=\"i\" isMuted={true} className=\"uifw-toolSettings-label-empty\">\n {translate(\"tools.noToolSettingsStart\")}\n {toolName || translate(\"tools.noToolSettingsPlaceholderName\")}\n {translate(\"tools.noToolSettingsEnd\")}\n </Text>\n );\n}\n\n/**\n * Hook that returns true if the tool settings should be rendered docked.\n * @internal */\nexport function useShouldRenderDockedToolSettings() {\n return useLayout((state) => {\n const toolSettings = state.toolSettings;\n if (!toolSettings || toolSettings.type === \"widget\") return false;\n return !toolSettings.hidden;\n });\n}\n\n/** @internal */\nexport function WidgetPanelsToolSettings() {\n if (!useShouldRenderDockedToolSettings()) return null;\n return <ToolSettingsDockedContent />;\n}\n\n/** @internal */\nexport function ToolSettingsDockedContent() {\n const activeToolId = useActiveToolId();\n const toolSettingEntries = useHorizontalToolSettingEntries();\n const forceRefreshKey = useRefreshKey(toolSettingEntries);\n const frontstageDef = useActiveFrontstageDef();\n\n const emptySettings = React.useMemo<ToolSettingsEntry[]>(\n () => [\n {\n editorNode: null,\n labelNode: frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n ),\n },\n ],\n [activeToolId, frontstageDef]\n );\n const entries =\n !toolSettingEntries || toolSettingEntries.length === 0\n ? emptySettings\n : toolSettingEntries;\n\n // for the overflow to work properly each setting in the DockedToolSettings should be wrapped by a DockedToolSetting component\n return (\n <DockedBar placement=\"top\">\n <ToolSettingsEditorsProvider>\n <DockedToolSettings\n itemId={\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??\n \"none\"\n }\n key={forceRefreshKey}\n >\n {entries.map((entry, index) => (\n <DockedToolSetting key={index}>\n <LockProvider>\n {entry.labelNode}\n {entry.editorNode}\n </LockProvider>\n </DockedToolSetting>\n ))}\n </DockedToolSettings>\n </ToolSettingsEditorsProvider>\n </DockedBar>\n );\n}\n\n/** @internal */\nexport function useHorizontalToolSettingEntries() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n return settings;\n}\n\n/** @internal */\nexport function useToolSettingsNode() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n return settings;\n}\n\n/** @internal */\nexport function ToolSettingsContent() {\n const toolSettingsType = useLayout((state) => state.toolSettings?.type);\n // This is needed to remount underlying components tree when going into widget state.\n if (!toolSettingsType || toolSettingsType === \"docked\") return null;\n return <ToolSettingsWidgetContent />;\n}\n\n/** @internal */\nexport function ToolSettingsWidgetContent() {\n const floatingToolSettingsContainerRef = React.useRef<HTMLDivElement>(null);\n const node = useToolSettingsNode();\n const activeToolId = useActiveToolId();\n const forceRefreshKey = useRefreshKey(node);\n const frontstageDef = useActiveFrontstageDef();\n\n const providerId =\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ?? \"none\";\n return (\n <div\n data-toolsettings-provider={providerId}\n className=\"uifw-floating-toolSettings-container\"\n ref={floatingToolSettingsContainerRef}\n key={forceRefreshKey}\n >\n <ScrollableWidgetContent>\n <ToolSettingsEditorsProvider>\n {node ?? frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n )}\n </ToolSettingsEditorsProvider>\n </ScrollableWidgetContent>\n </div>\n );\n}\n\n/**\n * Hook that returns a key that can be used to force refresh the tool settings.\n * @param toolSettingNodes Nodes that are used to determine if the tool settings should be refreshed.\n * @returns a new key if the dependency changes.\n */\nfunction useRefreshKey(toolSettingNodes: any) {\n const [forceRefreshKey, setForceRefreshKey] = React.useState(Date.now());\n React.useEffect(() => {\n // We cant work with the content of the settings, but we can force refresh when\n // the array is different.\n setForceRefreshKey(Date.now());\n }, [toolSettingNodes]);\n return forceRefreshKey;\n}\n"]}
1
+ {"version":3,"file":"ToolSettings.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/ToolSettings.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACh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gB;AAChB,MAAM,UAAU,yBAAyB;IACvC,MAAM,gCAAgC,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC5E,MAAM,IAAI,GAAG,mBAAmB,EAAE,CAAC;IACnC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,sBAAsB,EAAE,CAAC;IAE/C,MAAM,UAAU,GACd,yBAAyB,CAAC,0BAA0B,EAAE,QAAQ,IAAI,MAAM,CAAC;IAC3E,OAAO,CACL,2DAC8B,UAAU,EACtC,SAAS,EAAC,sCAAsC,EAChD,GAAG,EAAE,gCAAgC,EACrC,GAAG,EAAE,eAAe;QAEpB,oBAAC,uBAAuB;YACtB,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI;gBACvC,oBAAC,2BAA2B,QACzB,IAAI,IAAI,aAAa,EAAE,mBAAmB,IAAI,CAC7C,oBAAC,sBAAsB,IAAC,MAAM,EAAE,YAAY,GAAI,CACjD,CAC2B,CACD,CACP,CACtB,CACP,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,gBAAqB;IAC1C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,+EAA+E;QAC/E,0BAA0B;QAC1B,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvB,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ToolSettings\n */\n\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { DockedToolSettings } from \"../layout/tool-settings/Docked.js\";\nimport { DockedToolSetting } from \"../layout/tool-settings/Setting.js\";\nimport { ScrollableWidgetContent } from \"../layout/widget/Content.js\";\nimport \"./ToolSettings.scss\";\nimport { useActiveToolId } from \"../hooks/useActiveToolId.js\";\nimport { useTranslation } from \"../hooks/useTranslation.js\";\nimport { DockedBar } from \"./DockedBar.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { LockProvider } from \"../editors/LockProvider.js\";\nimport { ToolSettingsEditorsProvider } from \"../preview/tool-settings-lock-button/useToolSettingsLockButton.js\";\nimport { ToolSettingsContext } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** Defines a ToolSettings property entry.\n * @public\n */\nexport interface ToolSettingsEntry {\n // label node which potentially can contain a lock node as well.\n labelNode: React.ReactNode;\n // editor entry used to display and edit the property value\n editorNode: React.ReactNode;\n}\n\nfunction EmptyToolSettingsLabel({ toolId }: { toolId: string }) {\n const { translate } = useTranslation();\n const tool = IModelApp.tools.find(toolId);\n const toolName = tool?.flyover;\n return (\n <Text as=\"i\" isMuted={true} className=\"uifw-toolSettings-label-empty\">\n {translate(\"tools.noToolSettingsStart\")}\n {toolName || translate(\"tools.noToolSettingsPlaceholderName\")}\n {translate(\"tools.noToolSettingsEnd\")}\n </Text>\n );\n}\n\n/**\n * Hook that returns true if the tool settings should be rendered docked.\n * @internal */\nexport function useShouldRenderDockedToolSettings() {\n return useLayout((state) => {\n const toolSettings = state.toolSettings;\n if (!toolSettings || toolSettings.type === \"widget\") return false;\n return !toolSettings.hidden;\n });\n}\n\n/** @internal */\nexport function WidgetPanelsToolSettings() {\n if (!useShouldRenderDockedToolSettings()) return null;\n return <ToolSettingsDockedContent />;\n}\n\n/** @internal */\nexport function ToolSettingsDockedContent() {\n const activeToolId = useActiveToolId();\n const toolSettingEntries = useHorizontalToolSettingEntries();\n const forceRefreshKey = useRefreshKey(toolSettingEntries);\n const frontstageDef = useActiveFrontstageDef();\n\n const emptySettings = React.useMemo<ToolSettingsEntry[]>(\n () => [\n {\n editorNode: null,\n labelNode: frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n ),\n },\n ],\n [activeToolId, frontstageDef]\n );\n const entries =\n !toolSettingEntries || toolSettingEntries.length === 0\n ? emptySettings\n : toolSettingEntries;\n\n // for the overflow to work properly each setting in the DockedToolSettings should be wrapped by a DockedToolSetting component\n return (\n <DockedBar placement=\"top\">\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n <DockedToolSettings\n itemId={\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ??\n \"none\"\n }\n key={forceRefreshKey}\n >\n {entries.map((entry, index) => (\n <DockedToolSetting key={index}>\n <LockProvider>\n {entry.labelNode}\n {entry.editorNode}\n </LockProvider>\n </DockedToolSetting>\n ))}\n </DockedToolSettings>\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </DockedBar>\n );\n}\n\n/** @internal */\nexport function useHorizontalToolSettingEntries() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider\n ?.horizontalToolSettingNodes;\n setSettings(nodes);\n });\n }, []);\n\n return settings;\n}\n\n/** @internal */\nexport function useToolSettingsNode() {\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n UiFramework.frontstages.activeToolInformation?.toolUiProvider?.reloadPropertiesFromTool();\n }, []);\n const [settings, setSettings] = React.useState(\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode\n );\n React.useEffect(() => {\n return UiFramework.frontstages.onToolActivatedEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n\n React.useEffect(() => {\n return UiFramework.frontstages.onToolSettingsReloadEvent.addListener(() => {\n const nodes =\n InternalFrontstageManager.activeToolSettingsProvider?.toolSettingsNode;\n setSettings(nodes);\n });\n }, [setSettings]);\n return settings;\n}\n\n/** @internal */\nexport function ToolSettingsContent() {\n const toolSettingsType = useLayout((state) => state.toolSettings?.type);\n // This is needed to remount underlying components tree when going into widget state.\n if (!toolSettingsType || toolSettingsType === \"docked\") return null;\n return <ToolSettingsWidgetContent />;\n}\n\n/** @internal */\nexport function ToolSettingsWidgetContent() {\n const floatingToolSettingsContainerRef = React.useRef<HTMLDivElement>(null);\n const node = useToolSettingsNode();\n const activeToolId = useActiveToolId();\n const forceRefreshKey = useRefreshKey(node);\n const frontstageDef = useActiveFrontstageDef();\n\n const providerId =\n InternalFrontstageManager.activeToolSettingsProvider?.uniqueId ?? \"none\";\n return (\n <div\n data-toolsettings-provider={providerId}\n className=\"uifw-floating-toolSettings-container\"\n ref={floatingToolSettingsContainerRef}\n key={forceRefreshKey}\n >\n <ScrollableWidgetContent>\n <ToolSettingsContext.Provider value={true}>\n <ToolSettingsEditorsProvider>\n {node ?? frontstageDef?.activeToolEmptyNode ?? (\n <EmptyToolSettingsLabel toolId={activeToolId} />\n )}\n </ToolSettingsEditorsProvider>\n </ToolSettingsContext.Provider>\n </ScrollableWidgetContent>\n </div>\n );\n}\n\n/**\n * Hook that returns a key that can be used to force refresh the tool settings.\n * @param toolSettingNodes Nodes that are used to determine if the tool settings should be refreshed.\n * @returns a new key if the dependency changes.\n */\nfunction useRefreshKey(toolSettingNodes: any) {\n const [forceRefreshKey, setForceRefreshKey] = React.useState(Date.now());\n React.useEffect(() => {\n // We cant work with the content of the settings, but we can force refresh when\n // the array is different.\n setForceRefreshKey(Date.now());\n }, [toolSettingNodes]);\n return forceRefreshKey;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  /** Returns widget direction.
5
5
  * I.e. "horizontal" when widget is in bottom/top stage panel.
6
- * @alpha
6
+ * @public
7
7
  */
8
8
  export declare function useWidgetDirection(): "horizontal" | "vertical";
9
9
  //# sourceMappingURL=useWidgetDirection.d.ts.map
@@ -13,7 +13,7 @@ import { isHorizontalPanelSide } from "../layout/widget-panels/Panel.js";
13
13
  import { TabIdContext } from "../layout/widget/ContentRenderer.js";
14
14
  /** Returns widget direction.
15
15
  * I.e. "horizontal" when widget is in bottom/top stage panel.
16
- * @alpha
16
+ * @public
17
17
  */
18
18
  export function useWidgetDirection() {
19
19
  const tabId = React.useContext(TabIdContext);
@@ -1 +1 @@
1
- {"version":3,"file":"useWidgetDirection.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/useWidgetDirection.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,IACE,WAAW;YACX,MAAM,IAAI,WAAW;YACrB,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,EACvC,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport * as React from \"react\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { getTabLocation } from \"../layout/state/TabLocation.js\";\nimport { isHorizontalPanelSide } from \"../layout/widget-panels/Panel.js\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer.js\";\n\n/** Returns widget direction.\n * I.e. \"horizontal\" when widget is in bottom/top stage panel.\n * @alpha\n */\nexport function useWidgetDirection(): \"horizontal\" | \"vertical\" {\n const tabId = React.useContext(TabIdContext);\n assert(!!tabId);\n return useLayout((state) => {\n const tabLocation = getTabLocation(state, tabId);\n if (\n tabLocation &&\n \"side\" in tabLocation &&\n isHorizontalPanelSide(tabLocation.side)\n ) {\n return \"horizontal\";\n }\n return \"vertical\";\n });\n}\n"]}
1
+ {"version":3,"file":"useWidgetDirection.js","sourceRoot":"","sources":["../../../src/appui-react/widget-panels/useWidgetDirection.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACzB,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,IACE,WAAW;YACX,MAAM,IAAI,WAAW;YACrB,qBAAqB,CAAC,WAAW,CAAC,IAAI,CAAC,EACvC,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport * as React from \"react\";\nimport { useLayout } from \"../layout/base/LayoutStore.js\";\nimport { getTabLocation } from \"../layout/state/TabLocation.js\";\nimport { isHorizontalPanelSide } from \"../layout/widget-panels/Panel.js\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer.js\";\n\n/** Returns widget direction.\n * I.e. \"horizontal\" when widget is in bottom/top stage panel.\n * @public\n */\nexport function useWidgetDirection(): \"horizontal\" | \"vertical\" {\n const tabId = React.useContext(TabIdContext);\n assert(!!tabId);\n return useLayout((state) => {\n const tabLocation = getTabLocation(state, tabId);\n if (\n tabLocation &&\n \"side\" in tabLocation &&\n isHorizontalPanelSide(tabLocation.side)\n ) {\n return \"horizontal\";\n }\n return \"vertical\";\n });\n}\n"]}
@@ -1,8 +1,12 @@
1
+ /** @packageDocumentation
2
+ * @module Widget
3
+ */
1
4
  import type { WidgetState } from "./WidgetState.js";
2
5
  /** Hook that returns information about the Widget in the current context.
6
+ * @note This hook must be used within a widget.
3
7
  * @returns object that contains the WidgetLocation, WidgetState, and
4
8
  * the ability to set the state of the widget.
5
- * @alpha
9
+ * @public
6
10
  */
7
11
  export declare function useWidget(): {
8
12
  /** State of the Widget */
@@ -1 +1 @@
1
- {"version":3,"file":"useWidget.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widgets/useWidget.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,SAAS;IA0CrB,0BAA0B;;IAE1B,sEAAsE;;IAEtE;;OAEG;4BAbW,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC;EAgBxD"}
1
+ {"version":3,"file":"useWidget.d.ts","sourceRoot":"","sources":["../../../src/appui-react/widgets/useWidget.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAeH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,SAAS;IA0CrB,0BAA0B;;IAE1B,sEAAsE;;IAEtE;;OAEG;4BAbW,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC;EAgBxD"}
@@ -2,6 +2,9 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Widget
7
+ */
5
8
  import { assert } from "@itwin/core-bentley";
6
9
  import * as React from "react";
7
10
  import { useActiveFrontstageDef } from "../frontstage/FrontstageDef.js";
@@ -10,9 +13,10 @@ import { getTabLocation, isFloatingTabLocation, isPanelTabLocation, isPopoutTabL
10
13
  import { TabIdContext } from "../layout/widget/ContentRenderer.js";
11
14
  import { useWidgetDef } from "../widget-panels/Content.js";
12
15
  /** Hook that returns information about the Widget in the current context.
16
+ * @note This hook must be used within a widget.
13
17
  * @returns object that contains the WidgetLocation, WidgetState, and
14
18
  * the ability to set the state of the widget.
15
- * @alpha
19
+ * @public
16
20
  */
17
21
  export function useWidget() {
18
22
  const tabId = React.useContext(TabIdContext);
@@ -1 +1 @@
1
- {"version":3,"file":"useWidget.js","sourceRoot":"","sources":["../../../src/appui-react/widgets/useWidget.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEhB,MAAM,UAAU,GAAG,sBAAsB,EAAE,CAAC;IAE5C,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAErB,MAAM,SAAS,GAAG,YAAY,EAA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,cAAc,CAAC,UAAU,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAE5E,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC;YACvC,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { assert } from \"@itwin/core-bentley\";\nimport * as React from \"react\";\nimport type { FrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport {\n getTabLocation,\n isFloatingTabLocation,\n isPanelTabLocation,\n isPopoutTabLocation,\n} from \"../layout/state/TabLocation.js\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer.js\";\nimport { useWidgetDef } from \"../widget-panels/Content.js\";\nimport type { WidgetState } from \"./WidgetState.js\";\n\n/** Hook that returns information about the Widget in the current context.\n * @returns object that contains the WidgetLocation, WidgetState, and\n * the ability to set the state of the widget.\n * @alpha\n */\nexport function useWidget() {\n const tabId = React.useContext(TabIdContext);\n assert(!!tabId);\n\n const frontstage = useActiveFrontstageDef();\n\n assert(!!frontstage);\n\n const widgetDef = useWidgetDef();\n\n assert(!!widgetDef);\n\n const [widgetLocation, setWidgetLocation] = React.useState<\n \"docked\" | \"floating\" | \"popout\"\n >(findLocation(tabId, frontstage));\n\n const [state, setState] = React.useState(widgetDef.state);\n\n React.useEffect(() => {\n return InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.addListener(\n () => {\n if (widgetDef) return setState(widgetDef.state);\n }\n );\n }, [frontstage, widgetDef]);\n\n React.useEffect(() => {\n return InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.addListener(\n () => {\n setWidgetLocation(findLocation(tabId, frontstage));\n }\n );\n }, [frontstage, tabId]);\n\n const setWidgetState = React.useCallback(\n (widgetState: Omit<WidgetState, WidgetState.Floating>) => {\n widgetDef?.setWidgetState(widgetState as WidgetState);\n },\n [widgetDef]\n );\n\n return {\n /** State of the Widget */\n state,\n /** Where the widget is located (\"docked\" | \"popout\" | \"floating\"). */\n widgetLocation,\n /** Set widget to different state\n * @param WidgetState that you want to set the widget to.\n */\n setState: setWidgetState,\n };\n}\n\nfunction findLocation(locationTabId: string, frontstage: FrontstageDef) {\n assert(!!frontstage.nineZoneState);\n const tabLocation = getTabLocation(frontstage.nineZoneState, locationTabId);\n\n if (tabLocation) {\n if (isFloatingTabLocation(tabLocation)) {\n return \"floating\";\n }\n\n if (isPopoutTabLocation(tabLocation)) {\n return \"popout\";\n }\n\n if (isPanelTabLocation(tabLocation)) {\n return \"docked\";\n }\n }\n\n return \"floating\";\n}\n"]}
1
+ {"version":3,"file":"useWidget.js","sourceRoot":"","sources":["../../../src/appui-react/widgets/useWidget.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OA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AAc,CAAC,WAA0B,CAAC,CAAC;IACxD,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,OAAO;QACL,0BAA0B;QAC1B,KAAK;QACL,sEAAsE;QACtE,cAAc;QACd;;WAEG;QACH,QAAQ,EAAE,cAAc;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,aAAqB,EAAE,UAAyB;IACpE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACnC,MAAM,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAE5E,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC;YACvC,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Widget\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport * as React from \"react\";\nimport type { FrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { useActiveFrontstageDef } from \"../frontstage/FrontstageDef.js\";\nimport { InternalFrontstageManager } from \"../frontstage/InternalFrontstageManager.js\";\nimport {\n getTabLocation,\n isFloatingTabLocation,\n isPanelTabLocation,\n isPopoutTabLocation,\n} from \"../layout/state/TabLocation.js\";\nimport { TabIdContext } from \"../layout/widget/ContentRenderer.js\";\nimport { useWidgetDef } from \"../widget-panels/Content.js\";\nimport type { WidgetState } from \"./WidgetState.js\";\n\n/** Hook that returns information about the Widget in the current context.\n * @note This hook must be used within a widget.\n * @returns object that contains the WidgetLocation, WidgetState, and\n * the ability to set the state of the widget.\n * @public\n */\nexport function useWidget() {\n const tabId = React.useContext(TabIdContext);\n assert(!!tabId);\n\n const frontstage = useActiveFrontstageDef();\n\n assert(!!frontstage);\n\n const widgetDef = useWidgetDef();\n\n assert(!!widgetDef);\n\n const [widgetLocation, setWidgetLocation] = React.useState<\n \"docked\" | \"floating\" | \"popout\"\n >(findLocation(tabId, frontstage));\n\n const [state, setState] = React.useState(widgetDef.state);\n\n React.useEffect(() => {\n return InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.addListener(\n () => {\n if (widgetDef) return setState(widgetDef.state);\n }\n );\n }, [frontstage, widgetDef]);\n\n React.useEffect(() => {\n return InternalFrontstageManager.onFrontstageNineZoneStateChangedEvent.addListener(\n () => {\n setWidgetLocation(findLocation(tabId, frontstage));\n }\n );\n }, [frontstage, tabId]);\n\n const setWidgetState = React.useCallback(\n (widgetState: Omit<WidgetState, WidgetState.Floating>) => {\n widgetDef?.setWidgetState(widgetState as WidgetState);\n },\n [widgetDef]\n );\n\n return {\n /** State of the Widget */\n state,\n /** Where the widget is located (\"docked\" | \"popout\" | \"floating\"). */\n widgetLocation,\n /** Set widget to different state\n * @param WidgetState that you want to set the widget to.\n */\n setState: setWidgetState,\n };\n}\n\nfunction findLocation(locationTabId: string, frontstage: FrontstageDef) {\n assert(!!frontstage.nineZoneState);\n const tabLocation = getTabLocation(frontstage.nineZoneState, locationTabId);\n\n if (tabLocation) {\n if (isFloatingTabLocation(tabLocation)) {\n return \"floating\";\n }\n\n if (isPopoutTabLocation(tabLocation)) {\n return \"popout\";\n }\n\n if (isPanelTabLocation(tabLocation)) {\n return \"docked\";\n }\n }\n\n return \"floating\";\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ .uifw-toolbar-newToolbars-separator {
6
+ display: none;
7
+
8
+ &.uifw-horizontal {
9
+ border-right: var(--iui-surface-border);
10
+ border-color: var(--_uifw-toolbar-border-color);
11
+ }
12
+
13
+ &.uifw-vertical {
14
+ border-bottom: var(--iui-surface-border);
15
+ border-color: var(--_uifw-toolbar-border-color);
16
+ }
17
+
18
+ &:has(~ button) {
19
+ button + & {
20
+ display: block;
21
+ }
22
+ }
23
+
24
+ @supports not selector(:has(~ *)) {
25
+ button + & {
26
+ // This will display the last separator if there are multiple separators at the end of the toolbar.
27
+ &:not(:last-child) {
28
+ display: block;
29
+ }
30
+ }
31
+ }
32
+ }
@@ -3,10 +3,12 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  .uifw-toolbar-group-surface {
6
+ --_uifw-toolbar-border-color: var(--iui-color-border-foreground);
7
+
6
8
  display: flex;
7
9
  width: fit-content;
8
10
  height: fit-content;
9
- border-color: var(--iui-color-border-foreground);
11
+ border-color: var(--_uifw-toolbar-border-color);
10
12
  transition: border-color var(--iui-duration-1) ease;
11
13
  // TODO: needed due to opacity on toolbar container (since pointer events are disabled for center content).
12
14
  pointer-events: all;
@@ -26,7 +28,7 @@
26
28
 
27
29
  &:hover,
28
30
  &:focus-within {
29
- border-color: var(--iui-color-border-foreground-hover);
31
+ --_uifw-toolbar-border-color: var(--iui-color-border-foreground-hover);
30
32
  }
31
33
 
32
34
  &:empty {
@@ -0,0 +1,32 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ .uifw-toolbar-newToolbars-separator {
6
+ display: none;
7
+
8
+ &.uifw-horizontal {
9
+ border-right: var(--iui-surface-border);
10
+ border-color: var(--_uifw-toolbar-border-color);
11
+ }
12
+
13
+ &.uifw-vertical {
14
+ border-bottom: var(--iui-surface-border);
15
+ border-color: var(--_uifw-toolbar-border-color);
16
+ }
17
+
18
+ &:has(~ button) {
19
+ button + & {
20
+ display: block;
21
+ }
22
+ }
23
+
24
+ @supports not selector(:has(~ *)) {
25
+ button + & {
26
+ // This will display the last separator if there are multiple separators at the end of the toolbar.
27
+ &:not(:last-child) {
28
+ display: block;
29
+ }
30
+ }
31
+ }
32
+ }
@@ -3,10 +3,12 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  .uifw-toolbar-group-surface {
6
+ --_uifw-toolbar-border-color: var(--iui-color-border-foreground);
7
+
6
8
  display: flex;
7
9
  width: fit-content;
8
10
  height: fit-content;
9
- border-color: var(--iui-color-border-foreground);
11
+ border-color: var(--_uifw-toolbar-border-color);
10
12
  transition: border-color var(--iui-duration-1) ease;
11
13
  // TODO: needed due to opacity on toolbar container (since pointer events are disabled for center content).
12
14
  pointer-events: all;
@@ -26,7 +28,7 @@
26
28
 
27
29
  &:hover,
28
30
  &:focus-within {
29
- border-color: var(--iui-color-border-foreground-hover);
31
+ --_uifw-toolbar-border-color: var(--iui-color-border-foreground-hover);
30
32
  }
31
33
 
32
34
  &:empty {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/appui-react",
3
- "version": "5.7.0",
3
+ "version": "5.9.0",
4
4
  "description": "A react component library for AppUI framework",
5
5
  "type": "module",
6
6
  "types": "./lib/appui-react.d.ts",
@@ -45,9 +45,9 @@
45
45
  "react-dom": "^18.0.0",
46
46
  "react-redux": "^7.2.2 || ^8.0.0 || ^9.0.0",
47
47
  "redux": "^4.1.0 || ^5.0.0",
48
- "@itwin/components-react": "5.7.0",
49
- "@itwin/core-react": "5.7.0",
50
- "@itwin/imodel-components-react": "5.7.0"
48
+ "@itwin/components-react": "5.9.0",
49
+ "@itwin/core-react": "5.9.0",
50
+ "@itwin/imodel-components-react": "5.9.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@itwin/appui-abstract": "rc",
@@ -60,7 +60,7 @@
60
60
  "@itwin/core-quantity": "rc",
61
61
  "@itwin/ecschema-metadata": "rc",
62
62
  "@itwin/eslint-plugin": "5.1.0",
63
- "@itwin/itwinui-react": "^3.17.0",
63
+ "@itwin/itwinui-react": "^3.18.3",
64
64
  "@itwin/webgl-compatibility": "rc",
65
65
  "@testing-library/dom": "^10.1.0",
66
66
  "@testing-library/react": "^15.0.7",
@@ -91,9 +91,9 @@
91
91
  "typescript": "~5.6.2",
92
92
  "upath": "^2.0.1",
93
93
  "vitest": "^3.0.6",
94
- "@itwin/components-react": "5.7.0",
95
- "@itwin/core-react": "5.7.0",
96
- "@itwin/imodel-components-react": "5.7.0"
94
+ "@itwin/core-react": "5.9.0",
95
+ "@itwin/components-react": "5.9.0",
96
+ "@itwin/imodel-components-react": "5.9.0"
97
97
  },
98
98
  "dependencies": {
99
99
  "@itwin/itwinui-icons-react": "^2.8.0",