@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.
- package/CHANGELOG.md +26 -0
- package/lib/appui-react/editors/CustomNumberEditor.d.ts.map +1 -1
- package/lib/appui-react/editors/CustomNumberEditor.js +3 -1
- package/lib/appui-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/appui-react/editors/NumericEditor.d.ts.map +1 -1
- package/lib/appui-react/editors/NumericEditor.js +3 -1
- package/lib/appui-react/editors/NumericEditor.js.map +1 -1
- package/lib/appui-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/appui-react/editors/TextEditor.js +3 -1
- package/lib/appui-react/editors/TextEditor.js.map +1 -1
- package/lib/appui-react/hooks/useSafeContext.d.ts +7 -0
- package/lib/appui-react/hooks/useSafeContext.d.ts.map +1 -0
- package/lib/appui-react/hooks/useSafeContext.js +17 -0
- package/lib/appui-react/hooks/useSafeContext.js.map +1 -0
- package/lib/appui-react/preview/PreviewFeatures.d.ts +4 -0
- package/lib/appui-react/preview/PreviewFeatures.d.ts.map +1 -1
- package/lib/appui-react/preview/PreviewFeatures.js +1 -0
- package/lib/appui-react/preview/PreviewFeatures.js.map +1 -1
- package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts +6 -0
- package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts.map +1 -0
- package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js +15 -0
- package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js.map +1 -0
- package/lib/appui-react/toolbar/new-toolbars/ActionItem.d.ts +2 -2
- package/lib/appui-react/toolbar/new-toolbars/ActionItem.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/ActionItem.js +2 -1
- package/lib/appui-react/toolbar/new-toolbars/ActionItem.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/CustomItem.d.ts +2 -2
- package/lib/appui-react/toolbar/new-toolbars/CustomItem.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/CustomItem.js +3 -2
- package/lib/appui-react/toolbar/new-toolbars/CustomItem.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts +2 -3
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.js +6 -7
- package/lib/appui-react/toolbar/new-toolbars/GroupItem.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Item.d.ts +3 -5
- package/lib/appui-react/toolbar/new-toolbars/Item.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Item.js +15 -19
- package/lib/appui-react/toolbar/new-toolbars/Item.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.d.ts +0 -1
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js +3 -2
- package/lib/appui-react/toolbar/new-toolbars/OverflowButton.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Separator.d.ts +8 -0
- package/lib/appui-react/toolbar/new-toolbars/Separator.d.ts.map +1 -0
- package/lib/appui-react/toolbar/new-toolbars/Separator.js +19 -0
- package/lib/appui-react/toolbar/new-toolbars/Separator.js.map +1 -0
- package/lib/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
- package/lib/appui-react/toolbar/new-toolbars/Surface.d.ts +5 -3
- package/lib/appui-react/toolbar/new-toolbars/Surface.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Surface.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
- package/lib/appui-react/toolbar/new-toolbars/ToolGroup.d.ts +0 -5
- package/lib/appui-react/toolbar/new-toolbars/ToolGroup.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/ToolGroup.js +50 -19
- package/lib/appui-react/toolbar/new-toolbars/ToolGroup.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Toolbar.d.ts +5 -0
- package/lib/appui-react/toolbar/new-toolbars/Toolbar.d.ts.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/Toolbar.js +45 -12
- package/lib/appui-react/toolbar/new-toolbars/Toolbar.js.map +1 -1
- package/lib/appui-react/toolbar/new-toolbars/useOverflow.js +2 -2
- package/lib/appui-react/toolbar/new-toolbars/useOverflow.js.map +1 -1
- package/lib/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
- package/lib/appui-react/widget-panels/ToolSettings.js +10 -7
- package/lib/appui-react/widget-panels/ToolSettings.js.map +1 -1
- package/lib/appui-react/widget-panels/useWidgetDirection.d.ts +1 -1
- package/lib/appui-react/widget-panels/useWidgetDirection.js +1 -1
- package/lib/appui-react/widget-panels/useWidgetDirection.js.map +1 -1
- package/lib/appui-react/widgets/useWidget.d.ts +5 -1
- package/lib/appui-react/widgets/useWidget.d.ts.map +1 -1
- package/lib/appui-react/widgets/useWidget.js +5 -1
- package/lib/appui-react/widgets/useWidget.js.map +1 -1
- package/lib/cjs/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
- package/lib/cjs/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
- package/lib/esm/appui-react/toolbar/new-toolbars/Separator.scss +32 -0
- package/lib/esm/appui-react/toolbar/new-toolbars/Surface.scss +4 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Change Log - @itwin/appui-react
|
|
2
2
|
|
|
3
|
+
## 5.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1be3f19: Bump the release tag of `useWidget` and `useWidgetDirection` hooks from `@alpha` to `@public`.
|
|
8
|
+
- 6e9d137: Update `Toolbar` component to render a separator between items of different groups. This is a visual change based on the previous toolbar implementation.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [1be3f19]
|
|
13
|
+
- @itwin/imodel-components-react@5.9.0
|
|
14
|
+
- @itwin/components-react@5.9.0
|
|
15
|
+
- @itwin/core-react@5.9.0
|
|
16
|
+
|
|
17
|
+
## 5.8.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 4f2fc30: Add the `toolSettingsKeyPressCommit` preview feature, which enables input-like editors in the tool settings to commit entered values immediately upon key press.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- @itwin/components-react@5.8.0
|
|
26
|
+
- @itwin/core-react@5.8.0
|
|
27
|
+
- @itwin/imodel-components-react@5.8.0
|
|
28
|
+
|
|
3
29
|
## 5.7.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumberEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,0BAA0B,IAAI,8BAA8B,EAC7D,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomNumberEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,0BAA0B,IAAI,8BAA8B,EAC7D,MAAM,yBAAyB,CAAC;AAQjC,gBAAgB;AAChB,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS,sBAE5B;CACF"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { CustomNumberEditor as BaseCustomNumberEditor, CustomNumberPropertyEditor as BaseCustomNumberPropertyEditor, } from "@itwin/components-react";
|
|
10
10
|
import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
|
|
11
|
+
import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
|
|
11
12
|
/** @internal */
|
|
12
13
|
export class CustomNumberPropertyEditor extends BaseCustomNumberPropertyEditor {
|
|
13
14
|
get reactNode() {
|
|
@@ -15,10 +16,11 @@ export class CustomNumberPropertyEditor extends BaseCustomNumberPropertyEditor {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
const CustomNumberEditor = React.forwardRef(function CustomNumberEditor(props, forwardedRef) {
|
|
19
|
+
const shouldCommitOnChange = useToolSettingsKeyPressCommit();
|
|
18
20
|
const lockDecoration = useLockDecoration();
|
|
19
21
|
const internalProps = {
|
|
20
22
|
decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
|
|
21
23
|
};
|
|
22
|
-
return (React.createElement(BaseCustomNumberEditor, { ...props, ...internalProps, ref: forwardedRef }));
|
|
24
|
+
return (React.createElement(BaseCustomNumberEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
|
|
23
25
|
});
|
|
24
26
|
//# sourceMappingURL=CustomNumberEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,0BAA0B,IAAI,8BAA8B,GAC7D,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,0BAA0B,IAAI,8BAA8B,GAC7D,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,4EAA4E,CAAC;AAE3H,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS;QAC3B,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CACzC,SAAS,kBAAkB,CAAC,KAAK,EAAE,YAAY;IAC7C,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAC3C,MAAM,aAAa,GAAG;QACpB,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,oBAAC,yBAAyB,OAAG,CAAC,CAAC,CAAC,SAAS;KACpC,CAAC;IACrC,OAAO,CACL,oBAAC,sBAAsB,OACjB,KAAK,KACL,aAAa,EACjB,oBAAoB,EAAE,oBAAoB,EAC1C,GAAG,EAAE,YAAY,GACjB,CACH,CAAC;AACJ,CAAC,CACF,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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport {\n CustomNumberEditor as BaseCustomNumberEditor,\n CustomNumberPropertyEditor as BaseCustomNumberPropertyEditor,\n} from \"@itwin/components-react\";\nimport type { InternalInputEditorProps } from \"@itwin/components-react/internal\";\nimport {\n LockButtonInputDecoration,\n useLockDecoration,\n} from \"./LockProvider.js\";\nimport { useToolSettingsKeyPressCommit } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** @internal */\nexport class CustomNumberPropertyEditor extends BaseCustomNumberPropertyEditor {\n public override get reactNode() {\n return <CustomNumberEditor />;\n }\n}\n\nconst CustomNumberEditor = React.forwardRef<BaseCustomNumberEditor>(\n function CustomNumberEditor(props, forwardedRef) {\n const shouldCommitOnChange = useToolSettingsKeyPressCommit();\n const lockDecoration = useLockDecoration();\n const internalProps = {\n decoration: lockDecoration ? <LockButtonInputDecoration /> : undefined,\n } satisfies InternalInputEditorProps;\n return (\n <BaseCustomNumberEditor\n {...props}\n {...internalProps}\n shouldCommitOnChange={shouldCommitOnChange}\n ref={forwardedRef}\n />\n );\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/NumericEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,0BAA0B,IAAI,8BAA8B,EAC7D,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"NumericEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/NumericEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,0BAA0B,IAAI,8BAA8B,EAC7D,MAAM,yBAAyB,CAAC;AAQjC,gBAAgB;AAChB,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS,sBAE5B;CACF"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { NumericInputEditor as BaseNumericInputEditor, NumericInputPropertyEditor as BaseNumericInputPropertyEditor, } from "@itwin/components-react";
|
|
10
10
|
import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
|
|
11
|
+
import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
|
|
11
12
|
/** @internal */
|
|
12
13
|
export class NumericInputPropertyEditor extends BaseNumericInputPropertyEditor {
|
|
13
14
|
get reactNode() {
|
|
@@ -15,10 +16,11 @@ export class NumericInputPropertyEditor extends BaseNumericInputPropertyEditor {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
const NumericEditor = React.forwardRef(function NumericEditor(props, forwardedRef) {
|
|
19
|
+
const shouldCommitOnChange = useToolSettingsKeyPressCommit();
|
|
18
20
|
const lockDecoration = useLockDecoration();
|
|
19
21
|
const internalProps = {
|
|
20
22
|
decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
|
|
21
23
|
};
|
|
22
|
-
return (React.createElement(BaseNumericInputEditor, { ...props, ...internalProps, ref: forwardedRef }));
|
|
24
|
+
return (React.createElement(BaseNumericInputEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
|
|
23
25
|
});
|
|
24
26
|
//# sourceMappingURL=NumericEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/NumericEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,0BAA0B,IAAI,8BAA8B,GAC7D,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"NumericEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/NumericEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,0BAA0B,IAAI,8BAA8B,GAC7D,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,4EAA4E,CAAC;AAE3H,gBAAgB;AAChB,MAAM,OAAO,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS;QAC3B,OAAO,oBAAC,aAAa,OAAG,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CACpC,SAAS,aAAa,CAAC,KAAK,EAAE,YAAY;IACxC,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAC3C,MAAM,aAAa,GAAG;QACpB,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,oBAAC,yBAAyB,OAAG,CAAC,CAAC,CAAC,SAAS;KACpC,CAAC;IACrC,OAAO,CACL,oBAAC,sBAAsB,OACjB,KAAK,KACL,aAAa,EACjB,oBAAoB,EAAE,oBAAoB,EAC1C,GAAG,EAAE,YAAY,GACjB,CACH,CAAC;AACJ,CAAC,CACF,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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport {\n NumericInputEditor as BaseNumericInputEditor,\n NumericInputPropertyEditor as BaseNumericInputPropertyEditor,\n} from \"@itwin/components-react\";\nimport type { InternalInputEditorProps } from \"@itwin/components-react/internal\";\nimport {\n LockButtonInputDecoration,\n useLockDecoration,\n} from \"./LockProvider.js\";\nimport { useToolSettingsKeyPressCommit } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** @internal */\nexport class NumericInputPropertyEditor extends BaseNumericInputPropertyEditor {\n public override get reactNode() {\n return <NumericEditor />;\n }\n}\n\nconst NumericEditor = React.forwardRef<BaseNumericInputEditor>(\n function NumericEditor(props, forwardedRef) {\n const shouldCommitOnChange = useToolSettingsKeyPressCommit();\n const lockDecoration = useLockDecoration();\n const internalProps = {\n decoration: lockDecoration ? <LockButtonInputDecoration /> : undefined,\n } satisfies InternalInputEditorProps;\n return (\n <BaseNumericInputEditor\n {...props}\n {...internalProps}\n shouldCommitOnChange={shouldCommitOnChange}\n ref={forwardedRef}\n />\n );\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,mBAAmB,IAAI,sBAAsB,EAC9C,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAEL,mBAAmB,IAAI,sBAAsB,EAC9C,MAAM,yBAAyB,CAAC;AAQjC,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,sBAAsB;IAC5D,IAAoB,SAAS,sBAE5B;CACF"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import { TextEditor as BaseTextEditor, BasicPropertyEditor as BaseTextPropertyEditor, } from "@itwin/components-react";
|
|
10
10
|
import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
|
|
11
|
+
import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
|
|
11
12
|
/** @internal */
|
|
12
13
|
export class TextPropertyEditor extends BaseTextPropertyEditor {
|
|
13
14
|
get reactNode() {
|
|
@@ -15,10 +16,11 @@ export class TextPropertyEditor extends BaseTextPropertyEditor {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
const TextEditor = React.forwardRef(function TextEditor(props, forwardedRef) {
|
|
19
|
+
const shouldCommitOnChange = useToolSettingsKeyPressCommit();
|
|
18
20
|
const lockDecoration = useLockDecoration();
|
|
19
21
|
const internalProps = {
|
|
20
22
|
decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
|
|
21
23
|
};
|
|
22
|
-
return React.createElement(BaseTextEditor, { ...props, ...internalProps, ref: forwardedRef });
|
|
24
|
+
return (React.createElement(BaseTextEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
|
|
23
25
|
});
|
|
24
26
|
//# sourceMappingURL=TextEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,UAAU,IAAI,cAAc,EAC5B,mBAAmB,IAAI,sBAAsB,GAC9C,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,UAAU,IAAI,cAAc,EAC5B,mBAAmB,IAAI,sBAAsB,GAC9C,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,6BAA6B,EAAE,MAAM,4EAA4E,CAAC;AAE3H,gBAAgB;AAChB,MAAM,OAAO,kBAAmB,SAAQ,sBAAsB;IAC5D,IAAoB,SAAS;QAC3B,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAED,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAiB,SAAS,UAAU,CACrE,KAAK,EACL,YAAY;IAEZ,MAAM,oBAAoB,GAAG,6BAA6B,EAAE,CAAC;IAC7D,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAC3C,MAAM,aAAa,GAAG;QACpB,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,oBAAC,yBAAyB,OAAG,CAAC,CAAC,CAAC,SAAS;KACpC,CAAC;IACrC,OAAO,CACL,oBAAC,cAAc,OACT,KAAK,KACL,aAAa,EACjB,oBAAoB,EAAE,oBAAoB,EAC1C,GAAG,EAAE,YAAY,GACjB,CACH,CAAC;AACJ,CAAC,CAAC,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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport {\n TextEditor as BaseTextEditor,\n BasicPropertyEditor as BaseTextPropertyEditor,\n} from \"@itwin/components-react\";\nimport type { InternalInputEditorProps } from \"@itwin/components-react/internal\";\nimport {\n LockButtonInputDecoration,\n useLockDecoration,\n} from \"./LockProvider.js\";\nimport { useToolSettingsKeyPressCommit } from \"../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js\";\n\n/** @internal */\nexport class TextPropertyEditor extends BaseTextPropertyEditor {\n public override get reactNode() {\n return <TextEditor />;\n }\n}\n\nconst TextEditor = React.forwardRef<BaseTextEditor>(function TextEditor(\n props,\n forwardedRef\n) {\n const shouldCommitOnChange = useToolSettingsKeyPressCommit();\n const lockDecoration = useLockDecoration();\n const internalProps = {\n decoration: lockDecoration ? <LockButtonInputDecoration /> : undefined,\n } satisfies InternalInputEditorProps;\n return (\n <BaseTextEditor\n {...props}\n {...internalProps}\n shouldCommitOnChange={shouldCommitOnChange}\n ref={forwardedRef}\n />\n );\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSafeContext.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useSafeContext.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAQ1D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Hooks
|
|
7
|
+
*/
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export function useSafeContext(context) {
|
|
11
|
+
const value = React.useContext(context);
|
|
12
|
+
if (value === undefined) {
|
|
13
|
+
throw new Error(`${context.displayName || "Context"} is undefined`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useSafeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSafeContext.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useSafeContext.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAI,OAAyB;IACzD,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAExC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,IAAI,SAAS,eAAe,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,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 Hooks\n */\n\nimport * as React from \"react\";\n\n/** @internal */\nexport function useSafeContext<C>(context: React.Context<C>) {\n const value = React.useContext(context);\n\n if (value === undefined) {\n throw new Error(`${context.displayName || \"Context\"} is undefined`);\n }\n\n return value;\n}\n"]}
|
|
@@ -64,6 +64,10 @@ interface KnownPreviewFeatures {
|
|
|
64
64
|
* Additionally, the icon button will be rendered as an input decoration in editors that support it.
|
|
65
65
|
*/
|
|
66
66
|
toolSettingsLockButton: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* If `true`, the input-like editors rendered in the tool settings will commit the entered value on key press.
|
|
69
|
+
*/
|
|
70
|
+
toolSettingsKeyPressCommit: boolean;
|
|
67
71
|
}
|
|
68
72
|
/** List of preview features that can be enabled/disabled.
|
|
69
73
|
* This list is expected to change over time, the interface is made
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewFeatures.d.ts","sourceRoot":"","sources":["../../../src/appui-react/preview/PreviewFeatures.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,sCAAsC;AACtC,UAAU,oBAAoB;IAC5B;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC;;;OAGG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,oBAAoB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C;;;OAGG;IACH,wCAAwC,EAAE,OAAO,CAAC;IAClD;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD;;;;;OAKG;IACH,uBAAuB,EAAE,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IACrD;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PreviewFeatures.d.ts","sourceRoot":"","sources":["../../../src/appui-react/preview/PreviewFeatures.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,sCAAsC;AACtC,UAAU,oBAAoB;IAC5B;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC;;;OAGG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,oBAAoB,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C;;;OAGG;IACH,wCAAwC,EAAE,OAAO,CAAC;IAClD;;;;;;OAMG;IACH,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IACnD;;;;;OAKG;IACH,uBAAuB,EAAE,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;IACrD;;;OAGG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC;;OAEG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACrC;AAmBD;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO,CAAC,oBAAoB,CAAC;IACpE,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG,CAAC;CAC5B;AAuDD;;GAEG;AACH,wBAAgB,kBAAkB,oBAEjC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,QAAQ,GACT,EAAE,4BAA4B,qBAgB9B"}
|
|
@@ -23,6 +23,7 @@ const knownFeaturesObject = {
|
|
|
23
23
|
controlWidgetVisibility: undefined,
|
|
24
24
|
toolSettingsNewEditors: undefined,
|
|
25
25
|
toolSettingsLockButton: undefined,
|
|
26
|
+
toolSettingsKeyPressCommit: undefined,
|
|
26
27
|
};
|
|
27
28
|
/** Trim an object to only contain known feature keys.
|
|
28
29
|
* @param previewFeatures object potentially containing unknown features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewFeatures.js","sourceRoot":"","sources":["../../../src/appui-react/preview/PreviewFeatures.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAk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AAC,GAAG,EAAE,EAAE;IACnE,OAAO;QACL,eAAe,EAAE,EAAE;QACnB,kBAAkB,EAAE,CAAC,kBAAmC,EAAE,EAAE;YAC1D,MAAM,eAAe,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;YACpE,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,uBAAuB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAUD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,QAAQ,GACqB;IAC7B,MAAM,kBAAkB,GAAG,uBAAuB,CAChD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,kBAAkB,CACpC,CAAC;IACF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,kBAAkB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEnC,0CAA0C;IAC1C,KAAK,CAAC,SAAS,CACb,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC,EACD,CAAC,kBAAkB,CAAC,CACrB,CAAC;IACF,OAAO,0CAAG,QAAQ,CAAI,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 Utilities\n */\n\nimport * as React from \"react\";\nimport { create } from \"zustand\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport type { useTransientState } from \"../widget-panels/useTransientState.js\";\nimport type { WidgetDef } from \"../widgets/WidgetDef.js\";\nimport type { UiItemsManager } from \"../ui-items-provider/UiItemsManager.js\";\n\n/** List of known preview features. */\ninterface KnownPreviewFeatures {\n /** If `true`, the panels and tool settings will always be rendered over the content.\n * The content will never change size.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/672\n */\n contentAlwaysMaxSize: boolean;\n /** If `true`, the floating widget will have a \"maximize\" button. Use `enableMaximizedPanelWidget` to enable the feature for panel widgets.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/673\n */\n enableMaximizedFloatingWidget: boolean;\n /** If `true`, the panel widget will have a \"maximize\" button. Use `enableMaximizedFloatingWidget` to enable the feature for floating widgets.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/673\n */\n enableMaximizedPanelWidget: boolean;\n /** If `true`, the horizontal panels will have an additional \"Align\" button.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/706\n */\n horizontalPanelAlignment: boolean;\n /** If enabled, a dropdown menu will be rendered for widgets that exceed the specified threshold of title bar buttons.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/723\n */\n widgetActionDropdown: { threshold: number };\n /** If `true`, the accudraw input field will accept some letters for bearing angle. Defaults to `false`.\n *\n * This allows to type letters for Bearing angles in the accudraw input field. (N, S, E, W)\n */\n allowBearingLettersInAccuDrawInputFields: boolean;\n /** If `true`, popout widgets will not be rendered in a separate element tree, instead widget content will be re-parented to a popout content container.\n * Alternatively, an array of widget ids can be specified to only re-parent specific widgets.\n * @note Use {@link useTransientState} to save and restore DOM transient state when re-parenting widgets.\n * @note There is a known limitation where iTwinUI v2 popover elements will be rendered in the main window. Prefer using iTwinUI v3 when using this feature.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/925\n */\n reparentPopoutWidgets: boolean | WidgetDef[\"id\"][];\n /** If `true`, additional UI elements are rendered to allow the end user of the layout to control widget visibility.\n * Alternatively, an array of widget ids can be specified to only control specific widgets.\n * @note Use {@link UiItemsManager} APIs to manage what widgets are available to the end-user.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/859\n */\n controlWidgetVisibility: boolean | WidgetDef[\"id\"][];\n /**\n * If `true`, the tool settings will be using the new editor API. The new system delivers same default editors as the old one.\n * However, in order to use custom editors they need to be provided using `EditorsRegistryProvider` component.\n */\n toolSettingsNewEditors: boolean;\n /**\n * If `true`, the default tool settings lock editor will be rendered as an icon button rather than a checkbox.\n * Consumers can still use a custom component to render the lock by customizing the `PropertyDescription`.\n * Additionally, the icon button will be rendered as an input decoration in editors that support it.\n */\n toolSettingsLockButton: boolean;\n}\n\n/** Object used trim to only known features at runtime.\n * @internal\n */\nconst knownFeaturesObject: Record<keyof KnownPreviewFeatures, undefined> = {\n contentAlwaysMaxSize: undefined,\n enableMaximizedFloatingWidget: undefined,\n enableMaximizedPanelWidget: undefined,\n horizontalPanelAlignment: undefined,\n widgetActionDropdown: undefined,\n allowBearingLettersInAccuDrawInputFields: undefined,\n reparentPopoutWidgets: undefined,\n controlWidgetVisibility: undefined,\n toolSettingsNewEditors: undefined,\n toolSettingsLockButton: undefined,\n};\n\n/** List of preview features that can be enabled/disabled.\n * This list is expected to change over time, the interface is made\n * so that new features can be added or removed without breaking existing code.\n * A console warning will simply appear if unknown features are passed.\n * @beta\n */\nexport interface PreviewFeatures extends Partial<KnownPreviewFeatures> {\n [featureName: string]: any;\n}\n\n/** Trim an object to only contain known feature keys.\n * @param previewFeatures object potentially containing unknown features\n * @returns object containing only known features\n * @internal\n */\nfunction trimToKnownFeaturesOnly(previewFeatures: PreviewFeatures) {\n const knownFeatureKeys = Object.keys(knownFeaturesObject);\n const [knownFeatures, unknownFeatures] = Object.entries(\n previewFeatures\n ).reduce(\n ([known, unknown], [key, value]) => {\n if (knownFeatureKeys.includes(key)) {\n known[key] = value;\n } else {\n unknown.push(key);\n }\n return [known, unknown];\n },\n [{}, []] as [PreviewFeatures, string[]]\n );\n if (Object.keys(unknownFeatures).length > 0) {\n Logger.logWarning(\n UiFramework.loggerCategory(\"trimToKnownFeaturesOnly\"),\n `Features used in \"setPreviewFeatures\" are unknown or no longer in preview`,\n {\n unknownFeatures,\n }\n );\n }\n return knownFeatures;\n}\n\ninterface PreviewFeaturesState {\n previewFeatures: PreviewFeatures;\n setPreviewFeatures: (previewFeatures: PreviewFeatures) => void;\n}\n\n/** Preview features store used by `UiFramework.previewFeatures` and `UiFramework.setPreviewFeatures()` APIs to manage the preview features.\n * Use `usePreviewFeatures` hook to access the preview features set from a react component.\n * Use `usePreviewFeaturesStore.getState().previewFeatures` to access the preview features set from a non-react component.\n * Use `usePreviewFeaturesStore.subscribe()` to subscribe to changes to the preview features set from a non-react component.\n * @internal\n */\nconst usePreviewFeaturesStore = create<PreviewFeaturesState>((set) => {\n return {\n previewFeatures: {},\n setPreviewFeatures: (newPreviewFeatures: PreviewFeatures) => {\n const previewFeatures = trimToKnownFeaturesOnly(newPreviewFeatures);\n set({ previewFeatures });\n },\n };\n});\n\n/** Hook to access the preview features set.\n * @internal\n */\nexport function usePreviewFeatures() {\n return usePreviewFeaturesStore((state) => state.previewFeatures);\n}\n\n/** Props for PreviewFeaturesProvider.\n * @beta\n */\nexport interface PreviewFeaturesProviderProps {\n children?: React.ReactNode;\n features?: PreviewFeatures;\n}\n\n/** Set which preview features are enabled. These features are not yet ready for production use nor have\n * a proper API defined yet.\n * The available set of features are defined in the [[PreviewFeatures]] interface.\n *\n * This component should wrap the Provider component.\n *\n * ```tsx\n * <PreviewFeaturesProvider features={{ enableMaximizedFloatingWidget: true }}>\n * <Provider store={UiFramework.store}>\n * [...]\n * <ConfigurableUIContent />\n * [/...]\n * </Provider>\n * </PreviewFeaturesProvider>\n * ```\n * @beta\n */\nexport function PreviewFeaturesProvider({\n children,\n features,\n}: PreviewFeaturesProviderProps) {\n const setPreviewFeatures = usePreviewFeaturesStore(\n (state) => state.setPreviewFeatures\n );\n React.useEffect(() => {\n setPreviewFeatures(features ?? {});\n }, [features, setPreviewFeatures]);\n\n // Clear preview features when unmounting.\n React.useEffect(\n () => () => {\n setPreviewFeatures({});\n },\n [setPreviewFeatures]\n );\n return <>{children}</>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PreviewFeatures.js","sourceRoot":"","sources":["../../../src/appui-react/preview/PreviewFeatures.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsEhD;;GAEG;AACH,MAAM,mBAAmB,GAAkD;IACzE,oBAAoB,EAAE,SAAS;IAC/B,6BAA6B,EAAE,SAAS;IACxC,0BAA0B,EAAE,SAAS;IACrC,wBAAwB,EAAE,SAAS;IACnC,oBAAoB,EAAE,SAAS;IAC/B,wCAAwC,EAAE,SAAS;IACnD,qBAAqB,EAAE,SAAS;IAChC,uBAAuB,EAAE,SAAS;IAClC,sBAAsB,EAAE,SAAS;IACjC,sBAAsB,EAAE,SAAS;IACjC,0BAA0B,EAAE,SAAS;CACtC,CAAC;AAYF;;;;GAIG;AACH,SAAS,uBAAuB,CAAC,eAAgC;IAC/D,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,CAAC,aAAa,EAAE,eAAe,CAAC,GAAG,MAAM,CAAC,OAAO,CACrD,eAAe,CAChB,CAAC,MAAM,CACN,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACjC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC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CAAC,CAAC,CAAC;IAEnC,0CAA0C;IAC1C,KAAK,CAAC,SAAS,CACb,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC,EACD,CAAC,kBAAkB,CAAC,CACrB,CAAC;IACF,OAAO,0CAAG,QAAQ,CAAI,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 Utilities\n */\n\nimport * as React from \"react\";\nimport { create } from \"zustand\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"../UiFramework.js\";\nimport type { useTransientState } from \"../widget-panels/useTransientState.js\";\nimport type { WidgetDef } from \"../widgets/WidgetDef.js\";\nimport type { UiItemsManager } from \"../ui-items-provider/UiItemsManager.js\";\n\n/** List of known preview features. */\ninterface KnownPreviewFeatures {\n /** If `true`, the panels and tool settings will always be rendered over the content.\n * The content will never change size.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/672\n */\n contentAlwaysMaxSize: boolean;\n /** If `true`, the floating widget will have a \"maximize\" button. Use `enableMaximizedPanelWidget` to enable the feature for panel widgets.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/673\n */\n enableMaximizedFloatingWidget: boolean;\n /** If `true`, the panel widget will have a \"maximize\" button. Use `enableMaximizedFloatingWidget` to enable the feature for floating widgets.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/673\n */\n enableMaximizedPanelWidget: boolean;\n /** If `true`, the horizontal panels will have an additional \"Align\" button.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/706\n */\n horizontalPanelAlignment: boolean;\n /** If enabled, a dropdown menu will be rendered for widgets that exceed the specified threshold of title bar buttons.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/723\n */\n widgetActionDropdown: { threshold: number };\n /** If `true`, the accudraw input field will accept some letters for bearing angle. Defaults to `false`.\n *\n * This allows to type letters for Bearing angles in the accudraw input field. (N, S, E, W)\n */\n allowBearingLettersInAccuDrawInputFields: boolean;\n /** If `true`, popout widgets will not be rendered in a separate element tree, instead widget content will be re-parented to a popout content container.\n * Alternatively, an array of widget ids can be specified to only re-parent specific widgets.\n * @note Use {@link useTransientState} to save and restore DOM transient state when re-parenting widgets.\n * @note There is a known limitation where iTwinUI v2 popover elements will be rendered in the main window. Prefer using iTwinUI v3 when using this feature.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/925\n */\n reparentPopoutWidgets: boolean | WidgetDef[\"id\"][];\n /** If `true`, additional UI elements are rendered to allow the end user of the layout to control widget visibility.\n * Alternatively, an array of widget ids can be specified to only control specific widgets.\n * @note Use {@link UiItemsManager} APIs to manage what widgets are available to the end-user.\n *\n * Discuss or upvote this feature: https://github.com/iTwin/appui/discussions/859\n */\n controlWidgetVisibility: boolean | WidgetDef[\"id\"][];\n /**\n * If `true`, the tool settings will be using the new editor API. The new system delivers same default editors as the old one.\n * However, in order to use custom editors they need to be provided using `EditorsRegistryProvider` component.\n */\n toolSettingsNewEditors: boolean;\n /**\n * If `true`, the default tool settings lock editor will be rendered as an icon button rather than a checkbox.\n * Consumers can still use a custom component to render the lock by customizing the `PropertyDescription`.\n * Additionally, the icon button will be rendered as an input decoration in editors that support it.\n */\n toolSettingsLockButton: boolean;\n /**\n * If `true`, the input-like editors rendered in the tool settings will commit the entered value on key press.\n */\n toolSettingsKeyPressCommit: boolean;\n}\n\n/** Object used trim to only known features at runtime.\n * @internal\n */\nconst knownFeaturesObject: Record<keyof KnownPreviewFeatures, undefined> = {\n contentAlwaysMaxSize: undefined,\n enableMaximizedFloatingWidget: undefined,\n enableMaximizedPanelWidget: undefined,\n horizontalPanelAlignment: undefined,\n widgetActionDropdown: undefined,\n allowBearingLettersInAccuDrawInputFields: undefined,\n reparentPopoutWidgets: undefined,\n controlWidgetVisibility: undefined,\n toolSettingsNewEditors: undefined,\n toolSettingsLockButton: undefined,\n toolSettingsKeyPressCommit: undefined,\n};\n\n/** List of preview features that can be enabled/disabled.\n * This list is expected to change over time, the interface is made\n * so that new features can be added or removed without breaking existing code.\n * A console warning will simply appear if unknown features are passed.\n * @beta\n */\nexport interface PreviewFeatures extends Partial<KnownPreviewFeatures> {\n [featureName: string]: any;\n}\n\n/** Trim an object to only contain known feature keys.\n * @param previewFeatures object potentially containing unknown features\n * @returns object containing only known features\n * @internal\n */\nfunction trimToKnownFeaturesOnly(previewFeatures: PreviewFeatures) {\n const knownFeatureKeys = Object.keys(knownFeaturesObject);\n const [knownFeatures, unknownFeatures] = Object.entries(\n previewFeatures\n ).reduce(\n ([known, unknown], [key, value]) => {\n if (knownFeatureKeys.includes(key)) {\n known[key] = value;\n } else {\n unknown.push(key);\n }\n return [known, unknown];\n },\n [{}, []] as [PreviewFeatures, string[]]\n );\n if (Object.keys(unknownFeatures).length > 0) {\n Logger.logWarning(\n UiFramework.loggerCategory(\"trimToKnownFeaturesOnly\"),\n `Features used in \"setPreviewFeatures\" are unknown or no longer in preview`,\n {\n unknownFeatures,\n }\n );\n }\n return knownFeatures;\n}\n\ninterface PreviewFeaturesState {\n previewFeatures: PreviewFeatures;\n setPreviewFeatures: (previewFeatures: PreviewFeatures) => void;\n}\n\n/** Preview features store used by `UiFramework.previewFeatures` and `UiFramework.setPreviewFeatures()` APIs to manage the preview features.\n * Use `usePreviewFeatures` hook to access the preview features set from a react component.\n * Use `usePreviewFeaturesStore.getState().previewFeatures` to access the preview features set from a non-react component.\n * Use `usePreviewFeaturesStore.subscribe()` to subscribe to changes to the preview features set from a non-react component.\n * @internal\n */\nconst usePreviewFeaturesStore = create<PreviewFeaturesState>((set) => {\n return {\n previewFeatures: {},\n setPreviewFeatures: (newPreviewFeatures: PreviewFeatures) => {\n const previewFeatures = trimToKnownFeaturesOnly(newPreviewFeatures);\n set({ previewFeatures });\n },\n };\n});\n\n/** Hook to access the preview features set.\n * @internal\n */\nexport function usePreviewFeatures() {\n return usePreviewFeaturesStore((state) => state.previewFeatures);\n}\n\n/** Props for PreviewFeaturesProvider.\n * @beta\n */\nexport interface PreviewFeaturesProviderProps {\n children?: React.ReactNode;\n features?: PreviewFeatures;\n}\n\n/** Set which preview features are enabled. These features are not yet ready for production use nor have\n * a proper API defined yet.\n * The available set of features are defined in the [[PreviewFeatures]] interface.\n *\n * This component should wrap the Provider component.\n *\n * ```tsx\n * <PreviewFeaturesProvider features={{ enableMaximizedFloatingWidget: true }}>\n * <Provider store={UiFramework.store}>\n * [...]\n * <ConfigurableUIContent />\n * [/...]\n * </Provider>\n * </PreviewFeaturesProvider>\n * ```\n * @beta\n */\nexport function PreviewFeaturesProvider({\n children,\n features,\n}: PreviewFeaturesProviderProps) {\n const setPreviewFeatures = usePreviewFeaturesStore(\n (state) => state.setPreviewFeatures\n );\n React.useEffect(() => {\n setPreviewFeatures(features ?? {});\n }, [features, setPreviewFeatures]);\n\n // Clear preview features when unmounting.\n React.useEffect(\n () => () => {\n setPreviewFeatures({});\n },\n [setPreviewFeatures]\n );\n return <>{children}</>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToolSettingsKeyPressCommit.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,gBAAgB;AAChB,wBAAgB,6BAA6B,YAI5C;AAED,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,wBAA6B,CAAC"}
|
package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import * as React from "react";
|
|
6
|
+
import { usePreviewFeatures } from "../PreviewFeatures.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export function useToolSettingsKeyPressCommit() {
|
|
9
|
+
const { toolSettingsKeyPressCommit } = usePreviewFeatures();
|
|
10
|
+
const isToolSettings = React.useContext(ToolSettingsContext);
|
|
11
|
+
return !!toolSettingsKeyPressCommit && isToolSettings;
|
|
12
|
+
}
|
|
13
|
+
/** @internal */
|
|
14
|
+
export const ToolSettingsContext = React.createContext(false);
|
|
15
|
+
//# sourceMappingURL=useToolSettingsKeyPressCommit.js.map
|
package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToolSettingsKeyPressCommit.js","sourceRoot":"","sources":["../../../../src/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,gBAAgB;AAChB,MAAM,UAAU,6BAA6B;IAC3C,MAAM,EAAE,0BAA0B,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC5D,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC7D,OAAO,CAAC,CAAC,0BAA0B,IAAI,cAAc,CAAC;AACxD,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport { usePreviewFeatures } from \"../PreviewFeatures.js\";\n\n/** @internal */\nexport function useToolSettingsKeyPressCommit() {\n const { toolSettingsKeyPressCommit } = usePreviewFeatures();\n const isToolSettings = React.useContext(ToolSettingsContext);\n return !!toolSettingsKeyPressCommit && isToolSettings;\n}\n\n/** @internal */\nexport const ToolSettingsContext = React.createContext(false);\n"]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import type { ToolbarActionItem } from "../../toolbar/ToolbarItem.js";
|
|
6
|
-
|
|
7
|
-
export interface ActionItemProps {
|
|
6
|
+
interface ActionItemProps {
|
|
8
7
|
item: ToolbarActionItem;
|
|
9
8
|
}
|
|
10
9
|
/** @internal */
|
|
11
10
|
export declare const ActionItem: React.ForwardRefExoticComponent<ActionItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export {};
|
|
12
12
|
//# sourceMappingURL=ActionItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/ActionItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/ActionItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOtE,UAAU,eAAe;IACvB,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,gBAAgB;AAChB,eAAO,MAAM,UAAU,2FAkBtB,CAAC"}
|
|
@@ -10,9 +10,10 @@ import { ToolGroupOverflowContext } from "./OverflowButton.js";
|
|
|
10
10
|
import { Item } from "./Item.js";
|
|
11
11
|
import { GroupMenuItem } from "./GroupItem.js";
|
|
12
12
|
import { ToolbarContext } from "./Toolbar.js";
|
|
13
|
+
import { useSafeContext } from "../../hooks/useSafeContext.js";
|
|
13
14
|
/** @internal */
|
|
14
15
|
export const ActionItem = React.forwardRef(function ActionItem({ item }, ref) {
|
|
15
|
-
const { onItemExecuted } =
|
|
16
|
+
const { onItemExecuted } = useSafeContext(ToolbarContext);
|
|
16
17
|
const overflowContext = React.useContext(ToolGroupOverflowContext);
|
|
17
18
|
if (overflowContext) {
|
|
18
19
|
return React.createElement(GroupMenuItem, { item: item, onClose: overflowContext.onClose });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/ActionItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/ActionItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAM/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACxC,SAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG;IAC/B,MAAM,EAAE,cAAc,EAAE,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;IACnE,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,GAAI,CAAC;IACzE,CAAC;IACD,OAAO,CACL,oBAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CACF,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 type { ToolbarActionItem } from \"../../toolbar/ToolbarItem.js\";\nimport { ToolGroupOverflowContext } from \"./OverflowButton.js\";\nimport { Item } from \"./Item.js\";\nimport { GroupMenuItem } from \"./GroupItem.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface ActionItemProps {\n item: ToolbarActionItem;\n}\n\n/** @internal */\nexport const ActionItem = React.forwardRef<HTMLButtonElement, ActionItemProps>(\n function ActionItem({ item }, ref) {\n const { onItemExecuted } = useSafeContext(ToolbarContext);\n const overflowContext = React.useContext(ToolGroupOverflowContext);\n if (overflowContext) {\n return <GroupMenuItem item={item} onClose={overflowContext.onClose} />;\n }\n return (\n <Item\n ref={ref}\n item={item}\n onClick={() => {\n item.execute();\n onItemExecuted?.(item);\n }}\n />\n );\n }\n);\n"]}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import type { ToolbarCustomItem } from "../../toolbar/ToolbarItem.js";
|
|
6
|
-
|
|
7
|
-
export interface CustomItemProps {
|
|
6
|
+
interface CustomItemProps {
|
|
8
7
|
item: ToolbarCustomItem;
|
|
9
8
|
}
|
|
10
9
|
/** @internal */
|
|
11
10
|
export declare const CustomItem: React.ForwardRefExoticComponent<CustomItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export {};
|
|
12
12
|
//# sourceMappingURL=CustomItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/CustomItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/CustomItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAQtE,UAAU,eAAe;IACvB,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,gBAAgB;AAChB,eAAO,MAAM,UAAU,2FA2BtB,CAAC"}
|
|
@@ -12,10 +12,11 @@ import { Item } from "./Item.js";
|
|
|
12
12
|
import { GroupMenuItem, usePopoverPlacement } from "./GroupItem.js";
|
|
13
13
|
import { ToolGroupOverflowContext } from "./OverflowButton.js";
|
|
14
14
|
import { ToolbarContext } from "./Toolbar.js";
|
|
15
|
+
import { useSafeContext } from "../../hooks/useSafeContext.js";
|
|
15
16
|
/** @internal */
|
|
16
17
|
export const CustomItem = React.forwardRef(function CustomItem({ item }, ref) {
|
|
17
18
|
const placement = usePopoverPlacement();
|
|
18
|
-
const
|
|
19
|
+
const { setPopoverOpen } = useSafeContext(ToolbarContext);
|
|
19
20
|
const overflowContext = React.useContext(ToolGroupOverflowContext);
|
|
20
21
|
if (overflowContext) {
|
|
21
22
|
return React.createElement(GroupMenuItem, { item: item, onClose: overflowContext.onClose });
|
|
@@ -25,7 +26,7 @@ export const CustomItem = React.forwardRef(function CustomItem({ item }, ref) {
|
|
|
25
26
|
React.createElement(MenuExtraContent, { key: 0 }, item.panelContent),
|
|
26
27
|
];
|
|
27
28
|
}, placement: placement, onVisibleChange: (newVisible) => {
|
|
28
|
-
|
|
29
|
+
setPopoverOpen(newVisible);
|
|
29
30
|
} },
|
|
30
31
|
React.createElement(Item, { ref: ref, item: item },
|
|
31
32
|
React.createElement(ExpandIndicator, null))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/CustomItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|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;YAC9B,cAAc,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;QAED,oBAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;YACxB,oBAAC,eAAe,OAAG,CACd,CACM,CAChB,CAAC;AACJ,CAAC,CACF,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 { DropdownMenu, MenuExtraContent } from \"@itwin/itwinui-react\";\nimport type { ToolbarCustomItem } from \"../../toolbar/ToolbarItem.js\";\nimport { ExpandIndicator } from \"./ExpandIndicator.js\";\nimport { Item } from \"./Item.js\";\nimport { GroupMenuItem, usePopoverPlacement } from \"./GroupItem.js\";\nimport { ToolGroupOverflowContext } from \"./OverflowButton.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface CustomItemProps {\n item: ToolbarCustomItem;\n}\n\n/** @internal */\nexport const CustomItem = React.forwardRef<HTMLButtonElement, CustomItemProps>(\n function CustomItem({ item }, ref) {\n const placement = usePopoverPlacement();\n const { setPopoverOpen } = useSafeContext(ToolbarContext);\n const overflowContext = React.useContext(ToolGroupOverflowContext);\n\n if (overflowContext) {\n return <GroupMenuItem item={item} onClose={overflowContext.onClose} />;\n }\n return (\n <DropdownMenu\n menuItems={() => {\n return [\n <MenuExtraContent key={0}>{item.panelContent}</MenuExtraContent>,\n ];\n }}\n placement={placement}\n onVisibleChange={(newVisible) => {\n setPopoverOpen(newVisible);\n }}\n >\n <Item ref={ref} item={item}>\n <ExpandIndicator />\n </Item>\n </DropdownMenu>\n );\n }\n);\n"]}
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import type { ToolbarItem } from "../../toolbar/ToolbarItem.js";
|
|
6
6
|
import { type ToolbarGroupItem } from "../../toolbar/ToolbarItem.js";
|
|
7
|
-
|
|
8
|
-
export interface GroupItemProps {
|
|
7
|
+
interface GroupItemProps {
|
|
9
8
|
item: ToolbarGroupItem;
|
|
10
9
|
}
|
|
11
10
|
/** @internal */
|
|
12
11
|
export declare const GroupItem: React.ForwardRefExoticComponent<GroupItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
13
12
|
/** @internal */
|
|
14
|
-
export declare function usePopoverPlacement(): "top-end" | "top-start" | "
|
|
13
|
+
export declare function usePopoverPlacement(): "top-end" | "top-start" | "bottom-end" | "bottom-start" | "left-end" | "left-start" | "right-end" | "right-start";
|
|
15
14
|
interface GroupMenuItemProps {
|
|
16
15
|
item: ToolbarItem;
|
|
17
16
|
onClose?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupItem.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAStC,UAAU,cAAc;IACtB,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,gBAAgB;AAChB,eAAO,MAAM,SAAS,0FAyBrB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,mBAAmB,sHAGlC;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,4BAwClE"}
|
|
@@ -15,10 +15,11 @@ import { Item } from "./Item.js";
|
|
|
15
15
|
import { Badge } from "./Badge.js";
|
|
16
16
|
import { ToolGroupOverflowContext } from "./OverflowButton.js";
|
|
17
17
|
import { ToolbarContext } from "./Toolbar.js";
|
|
18
|
+
import { useSafeContext } from "../../hooks/useSafeContext.js";
|
|
18
19
|
/** @internal */
|
|
19
20
|
export const GroupItem = React.forwardRef(function GroupItem({ item }, ref) {
|
|
20
21
|
const placement = usePopoverPlacement();
|
|
21
|
-
const
|
|
22
|
+
const { setPopoverOpen } = useSafeContext(ToolbarContext);
|
|
22
23
|
const overflowContext = React.useContext(ToolGroupOverflowContext);
|
|
23
24
|
if (overflowContext) {
|
|
24
25
|
return React.createElement(GroupMenuItem, { item: item, onClose: overflowContext.onClose });
|
|
@@ -26,21 +27,19 @@ export const GroupItem = React.forwardRef(function GroupItem({ item }, ref) {
|
|
|
26
27
|
return (React.createElement(DropdownMenu, { menuItems: (close) => {
|
|
27
28
|
return toMenuItems(item, close);
|
|
28
29
|
}, placement: placement, onVisibleChange: (newVisible) => {
|
|
29
|
-
|
|
30
|
+
setPopoverOpen(newVisible);
|
|
30
31
|
} },
|
|
31
32
|
React.createElement(Item, { item: item, ref: ref },
|
|
32
33
|
React.createElement(ExpandIndicator, null))));
|
|
33
34
|
});
|
|
34
35
|
/** @internal */
|
|
35
36
|
export function usePopoverPlacement() {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
return undefined;
|
|
39
|
-
return `${context.expandsTo}-${context.panelAlignment}`;
|
|
37
|
+
const { expandsTo, panelAlignment } = useSafeContext(ToolbarContext);
|
|
38
|
+
return `${expandsTo}-${panelAlignment}`;
|
|
40
39
|
}
|
|
41
40
|
/** @internal */
|
|
42
41
|
export function GroupMenuItem({ item, onClose }) {
|
|
43
|
-
const { onItemExecuted } =
|
|
42
|
+
const { onItemExecuted } = useSafeContext(ToolbarContext);
|
|
44
43
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
45
44
|
const iconSpec = useConditionalProp(item.icon);
|
|
46
45
|
const label = useConditionalProp(item.label);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupItem.js","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/GroupItem.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,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AAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;gBACvB,OAAO,EAAE,EAAE,CAAC;YACd,CAAC;QACH,CAAC,EACD,UAAU,EAAE,QAAQ,kBACN,IAAI,CAAC,EAAE;QAGrB,oBAAC,KAAK,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,GAAI;QACtD,KAAK,CACG,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAiB,EAAE,OAAoB;IAC1D,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAClC,OAAO,CACL,oBAAC,aAAa,IAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAI,CACxE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,oBAAC,gBAAgB,IAAC,GAAG,EAAE,IAAI,CAAC,EAAE,IAAG,IAAI,CAAC,YAAY,CAAoB;SACvE,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { Icon } from \"@itwin/core-react\";\nimport { DropdownMenu, MenuExtraContent, MenuItem } from \"@itwin/itwinui-react\";\nimport type { ToolbarItem } from \"../../toolbar/ToolbarItem.js\";\nimport {\n isToolbarActionItem,\n isToolbarCustomItem,\n isToolbarGroupItem,\n type ToolbarGroupItem,\n} from \"../../toolbar/ToolbarItem.js\";\nimport { useConditionalProp } from \"../../hooks/useConditionalProp.js\";\nimport { ExpandIndicator } from \"./ExpandIndicator.js\";\nimport { Item } from \"./Item.js\";\nimport { Badge } from \"./Badge.js\";\nimport { ToolGroupOverflowContext } from \"./OverflowButton.js\";\nimport { ToolbarContext } from \"./Toolbar.js\";\nimport { useSafeContext } from \"../../hooks/useSafeContext.js\";\n\ninterface GroupItemProps {\n item: ToolbarGroupItem;\n}\n\n/** @internal */\nexport const GroupItem = React.forwardRef<HTMLButtonElement, GroupItemProps>(\n function GroupItem({ item }, ref) {\n const placement = usePopoverPlacement();\n const { setPopoverOpen } = useSafeContext(ToolbarContext);\n const overflowContext = React.useContext(ToolGroupOverflowContext);\n\n if (overflowContext) {\n return <GroupMenuItem item={item} onClose={overflowContext.onClose} />;\n }\n return (\n <DropdownMenu\n menuItems={(close) => {\n return toMenuItems(item, close);\n }}\n placement={placement}\n onVisibleChange={(newVisible) => {\n setPopoverOpen(newVisible);\n }}\n >\n <Item item={item} ref={ref}>\n <ExpandIndicator />\n </Item>\n </DropdownMenu>\n );\n }\n);\n\n/** @internal */\nexport function usePopoverPlacement() {\n const { expandsTo, panelAlignment } = useSafeContext(ToolbarContext);\n return `${expandsTo}-${panelAlignment}` as const;\n}\n\ninterface GroupMenuItemProps {\n item: ToolbarItem;\n onClose?: () => void;\n}\n\n/** @internal */\nexport function GroupMenuItem({ item, onClose }: GroupMenuItemProps) {\n const { onItemExecuted } = useSafeContext(ToolbarContext);\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const iconSpec = useConditionalProp(item.icon);\n const label = useConditionalProp(item.label);\n const isDisabled = useConditionalProp(item.isDisabled);\n const isHidden = useConditionalProp(item.isHidden);\n const isActive = useConditionalProp(item.isActive);\n\n if (isHidden) {\n return null;\n }\n\n const subMenuItems = isDisabled ? undefined : toMenuItems(item, onClose);\n const startIcon = item.iconNode ? (\n <>{item.iconNode}</>\n ) : (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={iconSpec} />\n );\n return (\n <MenuItem\n startIcon={startIcon}\n disabled={isDisabled}\n subMenuItems={subMenuItems}\n onClick={() => {\n if (isToolbarActionItem(item)) {\n item.execute();\n onItemExecuted?.(item);\n onClose?.();\n }\n }}\n isSelected={isActive}\n data-item-id={item.id}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Badge badge={item.badge} badgeKind={item.badgeKind} />\n {label}\n </MenuItem>\n );\n}\n\nfunction toMenuItems(item: ToolbarItem, onClose?: () => void) {\n if (isToolbarGroupItem(item)) {\n return item.items.map((groupItem) => {\n return (\n <GroupMenuItem key={groupItem.id} item={groupItem} onClose={onClose} />\n );\n });\n }\n if (isToolbarCustomItem(item)) {\n return [\n <MenuExtraContent key={item.id}>{item.panelContent}</MenuExtraContent>,\n ];\n }\n return [];\n}\n"]}
|
|
@@ -4,18 +4,16 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { IconButton } from "@itwin/itwinui-react";
|
|
6
6
|
import type { ToolbarItem } from "../../toolbar/ToolbarItem.js";
|
|
7
|
-
|
|
8
|
-
export interface ItemProps extends Partial<React.ComponentProps<typeof IconButton>> {
|
|
7
|
+
interface ItemProps extends Partial<React.ComponentProps<typeof IconButton>> {
|
|
9
8
|
item: ToolbarItem;
|
|
10
9
|
}
|
|
11
10
|
/** @internal */
|
|
12
11
|
export declare const Item: React.ForwardRefExoticComponent<Omit<ItemProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
13
12
|
/** @internal */
|
|
14
|
-
export declare function useExpandsTo(): "top" | "left" | "right" | "bottom";
|
|
15
|
-
/** @internal */
|
|
16
13
|
export declare function useLabelProps(): {
|
|
17
|
-
readonly placement: "top" | "
|
|
14
|
+
readonly placement: "top" | "bottom" | "left" | "right";
|
|
18
15
|
readonly visible: boolean;
|
|
19
16
|
readonly onVisibleChange: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
17
|
};
|
|
18
|
+
export {};
|
|
21
19
|
//# sourceMappingURL=Item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/toolbar/new-toolbars/Item.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAOhE,UAAU,SAAU,SAAQ,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;IAC1E,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,gBAAgB;AAChB,eAAO,MAAM,IAAI,kGAsChB,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa;;;;EAS5B"}
|