@itwin/appui-react 5.6.0 → 5.8.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 (96) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/lib/appui-react/UiFramework.json +3 -1
  3. package/lib/appui-react/editors/CustomNumberEditor.d.ts +10 -0
  4. package/lib/appui-react/editors/CustomNumberEditor.d.ts.map +1 -0
  5. package/lib/appui-react/editors/CustomNumberEditor.js +26 -0
  6. package/lib/appui-react/editors/CustomNumberEditor.js.map +1 -0
  7. package/lib/appui-react/{uiprovider → editors}/LockEditor.d.ts +1 -1
  8. package/lib/appui-react/editors/LockEditor.d.ts.map +1 -0
  9. package/lib/appui-react/editors/LockEditor.js.map +1 -0
  10. package/lib/appui-react/editors/LockProvider.d.ts +48 -0
  11. package/lib/appui-react/editors/LockProvider.d.ts.map +1 -0
  12. package/lib/appui-react/editors/LockProvider.js +121 -0
  13. package/lib/appui-react/editors/LockProvider.js.map +1 -0
  14. package/lib/appui-react/editors/NumericEditor.d.ts +10 -0
  15. package/lib/appui-react/editors/NumericEditor.d.ts.map +1 -0
  16. package/lib/appui-react/editors/NumericEditor.js +26 -0
  17. package/lib/appui-react/editors/NumericEditor.js.map +1 -0
  18. package/lib/appui-react/editors/TextEditor.d.ts +10 -0
  19. package/lib/appui-react/editors/TextEditor.d.ts.map +1 -0
  20. package/lib/appui-react/editors/TextEditor.js +26 -0
  21. package/lib/appui-react/editors/TextEditor.js.map +1 -0
  22. package/lib/appui-react/editors/registerEditors.d.ts +6 -0
  23. package/lib/appui-react/editors/registerEditors.d.ts.map +1 -0
  24. package/lib/appui-react/editors/registerEditors.js +28 -0
  25. package/lib/appui-react/editors/registerEditors.js.map +1 -0
  26. package/lib/appui-react/hooks/useControlledState.d.ts +4 -0
  27. package/lib/appui-react/hooks/useControlledState.d.ts.map +1 -0
  28. package/lib/appui-react/hooks/useControlledState.js +16 -0
  29. package/lib/appui-react/hooks/useControlledState.js.map +1 -0
  30. package/lib/appui-react/icons/snaps/SvgSnapsPerpendicular.d.ts +7 -0
  31. package/lib/appui-react/icons/snaps/SvgSnapsPerpendicular.d.ts.map +1 -0
  32. package/lib/appui-react/icons/snaps/SvgSnapsPerpendicular.js +14 -0
  33. package/lib/appui-react/icons/snaps/SvgSnapsPerpendicular.js.map +1 -0
  34. package/lib/appui-react/icons/snaps/SvgSnapsTangent.d.ts +7 -0
  35. package/lib/appui-react/icons/snaps/SvgSnapsTangent.d.ts.map +1 -0
  36. package/lib/appui-react/icons/snaps/SvgSnapsTangent.js +14 -0
  37. package/lib/appui-react/icons/snaps/SvgSnapsTangent.js.map +1 -0
  38. package/lib/appui-react/new-editors/CustomNumberEditor.d.ts +7 -0
  39. package/lib/appui-react/new-editors/CustomNumberEditor.d.ts.map +1 -0
  40. package/lib/appui-react/new-editors/CustomNumberEditor.js +18 -0
  41. package/lib/appui-react/new-editors/CustomNumberEditor.js.map +1 -0
  42. package/lib/appui-react/new-editors/LockEditor.d.ts +3 -0
  43. package/lib/appui-react/new-editors/LockEditor.d.ts.map +1 -0
  44. package/lib/appui-react/new-editors/LockEditor.js +40 -0
  45. package/lib/appui-react/new-editors/LockEditor.js.map +1 -0
  46. package/lib/appui-react/new-editors/NumericEditor.d.ts +3 -0
  47. package/lib/appui-react/new-editors/NumericEditor.d.ts.map +1 -0
  48. package/lib/appui-react/new-editors/NumericEditor.js +34 -0
  49. package/lib/appui-react/new-editors/NumericEditor.js.map +1 -0
  50. package/lib/appui-react/new-editors/TextEditor.d.ts +3 -0
  51. package/lib/appui-react/new-editors/TextEditor.d.ts.map +1 -0
  52. package/lib/appui-react/new-editors/TextEditor.js +23 -0
  53. package/lib/appui-react/new-editors/TextEditor.js.map +1 -0
  54. package/lib/appui-react/preview/PreviewFeatures.d.ts +5 -0
  55. package/lib/appui-react/preview/PreviewFeatures.d.ts.map +1 -1
  56. package/lib/appui-react/preview/PreviewFeatures.js +1 -0
  57. package/lib/appui-react/preview/PreviewFeatures.js.map +1 -1
  58. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts +6 -0
  59. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.d.ts.map +1 -0
  60. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js +15 -0
  61. package/lib/appui-react/preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js.map +1 -0
  62. package/lib/appui-react/preview/tool-settings-lock-button/useToolSettingsLockButton.d.ts +3 -0
  63. package/lib/appui-react/preview/tool-settings-lock-button/useToolSettingsLockButton.d.ts.map +1 -1
  64. package/lib/appui-react/preview/tool-settings-lock-button/useToolSettingsLockButton.js +18 -1
  65. package/lib/appui-react/preview/tool-settings-lock-button/useToolSettingsLockButton.js.map +1 -1
  66. package/lib/appui-react/statusfields/SnapMode.d.ts.map +1 -1
  67. package/lib/appui-react/statusfields/SnapMode.js +24 -0
  68. package/lib/appui-react/statusfields/SnapMode.js.map +1 -1
  69. package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.d.ts +12 -1
  70. package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.d.ts.map +1 -1
  71. package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.js +13 -17
  72. package/lib/appui-react/statusfields/toolassistance/ToolAssistanceField.js.map +1 -1
  73. package/lib/appui-react/toolbar/new-toolbars/GroupItem.d.ts.map +1 -1
  74. package/lib/appui-react/toolbar/new-toolbars/GroupItem.js +1 -1
  75. package/lib/appui-react/toolbar/new-toolbars/GroupItem.js.map +1 -1
  76. package/lib/appui-react/toolbar/new-toolbars/Item.d.ts.map +1 -1
  77. package/lib/appui-react/toolbar/new-toolbars/Item.js +1 -1
  78. package/lib/appui-react/toolbar/new-toolbars/Item.js.map +1 -1
  79. package/lib/appui-react/uiprovider/ComponentGenerator.d.ts.map +1 -1
  80. package/lib/appui-react/uiprovider/ComponentGenerator.js +23 -12
  81. package/lib/appui-react/uiprovider/ComponentGenerator.js.map +1 -1
  82. package/lib/appui-react/uiprovider/DefaultDialogGridContainer.d.ts.map +1 -1
  83. package/lib/appui-react/uiprovider/DefaultDialogGridContainer.js +2 -1
  84. package/lib/appui-react/uiprovider/DefaultDialogGridContainer.js.map +1 -1
  85. package/lib/appui-react/widget-panels/ToolSettings.d.ts.map +1 -1
  86. package/lib/appui-react/widget-panels/ToolSettings.js +15 -7
  87. package/lib/appui-react/widget-panels/ToolSettings.js.map +1 -1
  88. package/lib/appui-react.d.ts +1 -0
  89. package/lib/appui-react.d.ts.map +1 -1
  90. package/lib/appui-react.js +3 -5
  91. package/lib/appui-react.js.map +1 -1
  92. package/lib/public/locales/en/UiFramework.json +3 -1
  93. package/package.json +7 -7
  94. package/lib/appui-react/uiprovider/LockEditor.d.ts.map +0 -1
  95. package/lib/appui-react/uiprovider/LockEditor.js.map +0 -1
  96. /package/lib/appui-react/{uiprovider → editors}/LockEditor.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
1
1
  # Change Log - @itwin/appui-react
2
2
 
3
+ ## 5.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4f2fc30: Add the `toolSettingsKeyPressCommit` preview feature, which enables input-like editors in the tool settings to commit entered values immediately upon key press.
8
+
9
+ ### Patch Changes
10
+
11
+ - @itwin/components-react@5.8.0
12
+ - @itwin/core-react@5.8.0
13
+ - @itwin/imodel-components-react@5.8.0
14
+
15
+ ## 5.7.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 6a13347: Add `data-item-id` attributes to toolbar items of `Toolbar` component.
20
+ - ba32702: Added new `SnapMode.PerpendicularPoint` and `SnapMode.TangentPoint` options to the `SnapModeField` component. These new snap modes are only available when using the `@itwin/core-frontend@>=5.0.0`.
21
+ - e3f7b56: Updated tool settings to display the lock button as an input decoration when the `toolSettingsLockButton` preview feature is enabled. This is supported when using the new editor system via the `toolSettingsNewEditors` preview feature.
22
+
23
+ Editors that support the lock button input decoration:
24
+
25
+ - Text editor
26
+ - Numeric editor
27
+ - Custom number editor
28
+
29
+ A separate control will still be displayed as a sibling if the lock cannot be displayed by the editor. Common cases include:
30
+
31
+ - Non-input editors (i.e. locking a toggle property)
32
+ - Custom editors (i.e. custom editor implementations that do not display the lock decoration)
33
+
34
+ Note that a separate lock control can only be displayed for the first dialog item in a row. Consider this scenario:
35
+
36
+ ```tsx
37
+ const useX = new DialogProperty();
38
+ const x = new DialogProperty();
39
+
40
+ const useY = new DialogProperty();
41
+ const y = new DialogProperty();
42
+
43
+ // Tool is supplying these tool setting properties.
44
+ const dialogItems = [
45
+ x.toDialogItem(
46
+ {
47
+ columnIndex: 0,
48
+ rowPriority: 1,
49
+ },
50
+ useX.toDialogItem({ columnIndex: 0, rowPriority: 1 })
51
+ ),
52
+ y.toDialogItem(
53
+ {
54
+ columnIndex: 0,
55
+ rowPriority: 1,
56
+ },
57
+ useY.toDialogItem({ columnIndex: 0, rowPriority: 1 })
58
+ ),
59
+ ];
60
+
61
+ // The old behavior would display the lock as a separate control for the first dialog item of the row, which is `x`.
62
+ // The new behavior will display the lock as an input decoration for both `x` and `y`. A separate lock control might be displayed for `x` only.
63
+ ```
64
+
65
+ Added `LockButtonInputDecoration` component to allow consumers to display the lock button as an input decoration in custom editors. For now this component is only compatible with the [iTwinUI Input](https://itwinui.bentley.com/docs/inputwithdecorations), but additional APIs can be exposed in the future. Usage example:
66
+
67
+ ```tsx
68
+ function MyCustomEditor(props) {
69
+ // ...
70
+ return (
71
+ <InputWithDecorations>
72
+ {/* ... */}
73
+ <LockButtonInputDecoration />
74
+ </InputWithDecorations>
75
+ );
76
+ }
77
+ ```
78
+
79
+ - fe40d0a: Add `visible`, `onVisibleChange`, `pinned` and `onPinnedChange` props to `ToolAssistanceField` component. These props can be used to manually control the visibility and pinned state of the field.
80
+
81
+ ```tsx
82
+ function CustomField(props) {
83
+ // Field is open by default
84
+ const [visible, setVisible] = React.useState(true);
85
+ return (
86
+ <ToolAssistanceField
87
+ {...props}
88
+ visible={visible}
89
+ // Update the state so the field can be opened/closed
90
+ onVisibleChange={setVisible}
91
+ // Field is always pinned
92
+ pinned={true}
93
+ />
94
+ );
95
+ }
96
+ ```
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [fd58c9f]
101
+ - @itwin/components-react@5.7.0
102
+ - @itwin/imodel-components-react@5.7.0
103
+ - @itwin/core-react@5.7.0
104
+
3
105
  ## 5.6.0
4
106
 
5
107
  ### Minor Changes
@@ -62,7 +62,9 @@
62
62
  "origin": "Origin",
63
63
  "midpoint": "Midpoint",
64
64
  "bisector": "Bisector",
65
- "multi": "Multiple"
65
+ "multi": "Multiple",
66
+ "perpendicularPoint": "Perpendicular point",
67
+ "tangentPoint": "Tangent point"
66
68
  },
67
69
  "selectionScopeField": {
68
70
  "label": "Scope",
@@ -0,0 +1,10 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import { CustomNumberPropertyEditor as BaseCustomNumberPropertyEditor } from "@itwin/components-react";
6
+ /** @internal */
7
+ export declare class CustomNumberPropertyEditor extends BaseCustomNumberPropertyEditor {
8
+ get reactNode(): React.JSX.Element;
9
+ }
10
+ //# sourceMappingURL=CustomNumberEditor.d.ts.map
@@ -0,0 +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;AAQjC,gBAAgB;AAChB,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS,sBAE5B;CACF"}
@@ -0,0 +1,26 @@
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 PropertyEditors
7
+ */
8
+ import * as React from "react";
9
+ import { CustomNumberEditor as BaseCustomNumberEditor, CustomNumberPropertyEditor as BaseCustomNumberPropertyEditor, } from "@itwin/components-react";
10
+ import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
11
+ import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
12
+ /** @internal */
13
+ export class CustomNumberPropertyEditor extends BaseCustomNumberPropertyEditor {
14
+ get reactNode() {
15
+ return React.createElement(CustomNumberEditor, null);
16
+ }
17
+ }
18
+ const CustomNumberEditor = React.forwardRef(function CustomNumberEditor(props, forwardedRef) {
19
+ const shouldCommitOnChange = useToolSettingsKeyPressCommit();
20
+ const lockDecoration = useLockDecoration();
21
+ const internalProps = {
22
+ decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
23
+ };
24
+ return (React.createElement(BaseCustomNumberEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
25
+ });
26
+ //# sourceMappingURL=CustomNumberEditor.js.map
@@ -0,0 +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;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"]}
@@ -5,7 +5,7 @@ import * as React from "react";
5
5
  import { PropertyEditorBase } from "@itwin/components-react";
6
6
  /** @internal */
7
7
  export declare class LockPropertyEditor extends PropertyEditorBase {
8
- get reactNode(): React.ReactNode;
8
+ get reactNode(): React.JSX.Element;
9
9
  }
10
10
  /** @internal */
11
11
  export declare const LockPropertyEditorName = "appui-internal:tool-settings-lock";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockEditor.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/LockEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAyE7D,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,IAAW,SAAS,sBAEnB;CACF;AAED,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,sCAAsC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockEditor.js","sourceRoot":"","sources":["../../../src/appui-react/editors/LockEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CACjC,SAAS,UAAU,CAAC,KAAK,EAAE,YAAY;IACrC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAoB,IAAI,CAAC,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S,EAAC,YAAY,EACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,QAAQ;gBAAE,OAAO;YACrD,KAAK,CAAC,QAAQ,CAAC;gBACb,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,QAAQ,EAAE;oBACR,WAAW,EAAE,mBAAmB,CAAC,SAAS;oBAC1C,KAAK,EAAE,CAAC,YAAY;oBACpB,YAAY,EAAE,EAAE;iBACjB;aACF,CAAC,CAAC;QACL,CAAC,IAEA,YAAY,CAAC,CAAC,CAAC,oBAAC,OAAO,OAAG,CAAC,CAAC,CAAC,oBAAC,eAAe,OAAG,CACtC,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB;AAChB,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,mCAAmC,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 UiProvider\n */\n\nimport * as React from \"react\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { SvgLock, SvgLockUnlocked } from \"@itwin/itwinui-icons-react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\n\nconst LockEditor = React.forwardRef<TypeEditor, PropertyEditorProps>(\n function LockEditor(props, forwardedRef) {\n const ref = React.useRef<HTMLButtonElement>(null);\n const getCurrentValue = () => {\n if (\n props.propertyRecord &&\n props.propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n return props.propertyRecord.value.value as boolean;\n }\n return false;\n };\n const currentValue = getCurrentValue();\n\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n getPropertyValue: async () => {\n let propertyValue: PropertyValue | undefined;\n if (\n props.propertyRecord &&\n props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive\n ) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: currentValue,\n displayValue: \"\",\n };\n }\n return propertyValue;\n },\n htmlElement: ref.current,\n hasFocus: document.activeElement === ref.current,\n }),\n [currentValue, props.propertyRecord]\n );\n\n const displayLabel = props.propertyRecord?.property.displayLabel;\n const label = displayLabel ? displayLabel : \"Toggle lock\";\n const disabled = props.propertyRecord?.isDisabled;\n return (\n <IconButton\n ref={ref}\n label={label}\n size=\"small\"\n styleType=\"borderless\"\n isActive={currentValue}\n disabled={disabled}\n onClick={() => {\n if (!props.propertyRecord || !props.onCommit) return;\n props.onCommit({\n propertyRecord: props.propertyRecord,\n newValue: {\n valueFormat: PropertyValueFormat.Primitive,\n value: !currentValue,\n displayValue: \"\",\n },\n });\n }}\n >\n {currentValue ? <SvgLock /> : <SvgLockUnlocked />}\n </IconButton>\n );\n }\n);\n\n/** @internal */\nexport class LockPropertyEditor extends PropertyEditorBase {\n public get reactNode() {\n return <LockEditor />;\n }\n}\n\n/** @internal */\nexport const LockPropertyEditorName = \"appui-internal:tool-settings-lock\";\n"]}
@@ -0,0 +1,48 @@
1
+ /** @packageDocumentation
2
+ * @module ToolSettings
3
+ */
4
+ import * as React from "react";
5
+ import type { UiLayoutDataProvider } from "@itwin/appui-abstract";
6
+ /** This is used to notify the parent component that the lock decoration is displayed in the editor
7
+ * and a separate lock component should not be displayed as a sibling.
8
+ * @internal
9
+ */
10
+ export declare const LockContext: React.Context<{
11
+ /** Describes if the lock is displayed as an editor decoration. */
12
+ lockDecorations: Record<string, true>;
13
+ /** Called by editors that display lock decoration. */
14
+ setLockDecoration: (propertyName: string, lockDecoration: boolean) => void;
15
+ } | undefined>;
16
+ /** @internal */
17
+ export declare function LockProvider({ children }: React.PropsWithChildren): React.JSX.Element;
18
+ /** Additional context for property editors that support lock decoration.
19
+ * @internal
20
+ */
21
+ export declare const PropertyEditorContext: React.Context<{
22
+ uiDataProvider: UiLayoutDataProvider;
23
+ itemPropertyName: string;
24
+ /** Specified when rendering a lock editor. */
25
+ lockPropertyName: string | undefined;
26
+ } | undefined>;
27
+ type PropertyEditorContextType = React.ContextType<typeof PropertyEditorContext>;
28
+ interface PropertyEditorProviderProps extends NonNullable<PropertyEditorContextType> {
29
+ children?: React.ReactNode;
30
+ }
31
+ /** @internal */
32
+ export declare function PropertyEditorProvider(props: PropertyEditorProviderProps): React.JSX.Element;
33
+ /** Returns `true` if the lock decoration should be displayed.
34
+ * @internal
35
+ */
36
+ export declare function useLockDecoration(): boolean;
37
+ interface UseLockPropertyArgs {
38
+ provider: UiLayoutDataProvider;
39
+ itemPropertyName: string;
40
+ }
41
+ /** @internal */
42
+ export declare function useLockProperty(args: UseLockPropertyArgs | undefined): import("@itwin/appui-abstract").BaseDialogItem | undefined;
43
+ /** This component displays a lock button in the property editor when the `toolSettingsLockButton` preview feature is enabled.
44
+ * @alpha
45
+ */
46
+ export declare function LockButtonInputDecoration(): React.JSX.Element | null;
47
+ export {};
48
+ //# sourceMappingURL=LockProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LockProvider.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/LockProvider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAMlE;;;GAGG;AACH,eAAO,MAAM,WAAW;IAElB,kEAAkE;qBACjD,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IACrC,sDAAsD;uBACnC,CACjB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,OAAO,KACpB,IAAI;cAGH,CAAC;AAEb,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,qBAgCjE;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;oBAEZ,oBAAoB;sBAClB,MAAM;IACxB,8CAA8C;sBAC5B,MAAM,GAAG,SAAS;cAG9B,CAAC;AAEb,KAAK,yBAAyB,GAAG,KAAK,CAAC,WAAW,CAChD,OAAO,qBAAqB,CAC7B,CAAC;AAEF,UAAU,2BACR,SAAQ,WAAW,CAAC,yBAAyB,CAAC;IAC9C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,qBAiBxE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,YAchC;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,8DAqBpE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,6BAuDxC"}
@@ -0,0 +1,121 @@
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 ToolSettings
7
+ */
8
+ import * as React from "react";
9
+ import { InputWithDecorations } from "@itwin/itwinui-react";
10
+ import { SvgLock, SvgLockUnlocked } from "@itwin/itwinui-icons-react";
11
+ import { produce } from "immer";
12
+ import { usePreviewFeatures } from "../preview/PreviewFeatures.js";
13
+ /** This is used to notify the parent component that the lock decoration is displayed in the editor
14
+ * and a separate lock component should not be displayed as a sibling.
15
+ * @internal
16
+ */
17
+ export const LockContext = React.createContext(undefined);
18
+ /** @internal */
19
+ export function LockProvider({ children }) {
20
+ const [lockDecorations, setLockDecorations] = React.useState({});
21
+ const setLockDecoration = React.useCallback((propertyName, lockDecoration) => {
22
+ setLockDecorations(produce((draft) => {
23
+ if (lockDecoration) {
24
+ draft[propertyName] = true;
25
+ return;
26
+ }
27
+ delete draft[propertyName];
28
+ }));
29
+ }, []);
30
+ return (React.createElement(LockContext.Provider, { value: React.useMemo(() => ({
31
+ lockDecorations,
32
+ setLockDecoration,
33
+ }), [lockDecorations, setLockDecoration]) }, children));
34
+ }
35
+ /** Additional context for property editors that support lock decoration.
36
+ * @internal
37
+ */
38
+ export const PropertyEditorContext = React.createContext(undefined);
39
+ /** @internal */
40
+ export function PropertyEditorProvider(props) {
41
+ const { children, uiDataProvider, itemPropertyName, lockPropertyName } = props;
42
+ return (React.createElement(PropertyEditorContext.Provider, { value: React.useMemo(() => ({
43
+ uiDataProvider,
44
+ itemPropertyName,
45
+ lockPropertyName,
46
+ }), [uiDataProvider, itemPropertyName, lockPropertyName]) }, children));
47
+ }
48
+ /** Returns `true` if the lock decoration should be displayed.
49
+ * @internal
50
+ */
51
+ export function useLockDecoration() {
52
+ const { lockPropertyName, itemPropertyName, uiDataProvider } = React.useContext(PropertyEditorContext) ?? {};
53
+ const { toolSettingsLockButton } = usePreviewFeatures();
54
+ const dialogItem = React.useMemo(() => uiDataProvider?.items.find((item) => item.property.name === itemPropertyName), [uiDataProvider, itemPropertyName]);
55
+ return (!!toolSettingsLockButton && !lockPropertyName && !!dialogItem?.lockProperty);
56
+ }
57
+ /** @internal */
58
+ export function useLockProperty(args) {
59
+ const { provider, itemPropertyName } = args ?? {};
60
+ const subscribe = React.useCallback((onStoreChange) => {
61
+ const listeners = provider
62
+ ? [
63
+ provider.onItemsReloadedEvent.addListener(onStoreChange),
64
+ provider.onSyncPropertiesChangeEvent.addListener(onStoreChange),
65
+ ]
66
+ : [];
67
+ return () => listeners.forEach((l) => l());
68
+ }, [provider]);
69
+ const getSnapshot = React.useCallback(() => {
70
+ const dialogItem = provider?.items.find((item) => item.property.name === itemPropertyName);
71
+ return dialogItem?.lockProperty;
72
+ }, [provider, itemPropertyName]);
73
+ return React.useSyncExternalStore(subscribe, getSnapshot);
74
+ }
75
+ /** This component displays a lock button in the property editor when the `toolSettingsLockButton` preview feature is enabled.
76
+ * @alpha
77
+ */
78
+ export function LockButtonInputDecoration() {
79
+ const { itemPropertyName, uiDataProvider: provider } = React.useContext(PropertyEditorContext) ?? {};
80
+ const { setLockDecoration } = React.useContext(LockContext) ?? {};
81
+ const lockDecoration = useLockDecoration();
82
+ const lockProperty = useLockProperty(provider && itemPropertyName
83
+ ? {
84
+ provider,
85
+ itemPropertyName,
86
+ }
87
+ : undefined);
88
+ React.useLayoutEffect(() => {
89
+ if (!lockDecoration)
90
+ return;
91
+ if (!setLockDecoration)
92
+ return;
93
+ if (!itemPropertyName)
94
+ return;
95
+ setLockDecoration(itemPropertyName, true);
96
+ return () => {
97
+ setLockDecoration(itemPropertyName, false);
98
+ };
99
+ }, [setLockDecoration, itemPropertyName, lockDecoration]);
100
+ if (!lockDecoration)
101
+ return null;
102
+ const isLocked = !!lockProperty?.value.value;
103
+ const displayLabel = lockProperty?.property.displayLabel;
104
+ const label = displayLabel ? displayLabel : "Toggle lock";
105
+ const disabled = lockProperty?.isDisabled;
106
+ return (React.createElement(InputWithDecorations.Button, { isActive: isLocked, label: label, disabled: disabled, size: "small", styleType: "borderless", onClick: () => {
107
+ if (!provider)
108
+ return;
109
+ if (!lockProperty)
110
+ return;
111
+ provider.applyUiPropertyChange({
112
+ value: {
113
+ ...lockProperty.value,
114
+ value: !isLocked,
115
+ },
116
+ propertyName: lockProperty.property.name,
117
+ });
118
+ provider.reloadDialogItems();
119
+ } }, isLocked ? React.createElement(SvgLock, null) : React.createElement(SvgLockUnlocked, null)));
120
+ }
121
+ //# sourceMappingURL=LockProvider.js.map
@@ -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,CAAC,CAAC,oBAAC,OAAO,OAAG,CAAC,CAAC,CAAC,oBAAC,eAAe,OAAG,CACjB,CAC/B,CAAC;AACJ,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 type { UiLayoutDataProvider } from \"@itwin/appui-abstract\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\nimport { SvgLock, SvgLockUnlocked } from \"@itwin/itwinui-icons-react\";\nimport { produce } from \"immer\";\nimport { usePreviewFeatures } from \"../preview/PreviewFeatures.js\";\n\n/** This is used to notify the parent component that the lock decoration is displayed in the editor\n * and a separate lock component should not be displayed as a sibling.\n * @internal\n */\nexport const LockContext = React.createContext<\n | {\n /** Describes if the lock is displayed as an editor decoration. */\n lockDecorations: Record<string, true>;\n /** Called by editors that display lock decoration. */\n setLockDecoration: (\n propertyName: string,\n lockDecoration: boolean\n ) => void;\n }\n | undefined\n>(undefined);\n\n/** @internal */\nexport function LockProvider({ children }: React.PropsWithChildren) {\n const [lockDecorations, setLockDecorations] = React.useState<\n Record<string, true>\n >({});\n const setLockDecoration = React.useCallback(\n (propertyName: string, lockDecoration: boolean) => {\n setLockDecorations(\n produce((draft) => {\n if (lockDecoration) {\n draft[propertyName] = true;\n return;\n }\n\n delete draft[propertyName];\n })\n );\n },\n []\n );\n return (\n <LockContext.Provider\n value={React.useMemo(\n () => ({\n lockDecorations,\n setLockDecoration,\n }),\n [lockDecorations, setLockDecoration]\n )}\n >\n {children}\n </LockContext.Provider>\n );\n}\n\n/** Additional context for property editors that support lock decoration.\n * @internal\n */\nexport const PropertyEditorContext = React.createContext<\n | {\n uiDataProvider: UiLayoutDataProvider;\n itemPropertyName: string;\n /** Specified when rendering a lock editor. */\n lockPropertyName: string | undefined;\n }\n | undefined\n>(undefined);\n\ntype PropertyEditorContextType = React.ContextType<\n typeof PropertyEditorContext\n>;\n\ninterface PropertyEditorProviderProps\n extends NonNullable<PropertyEditorContextType> {\n children?: React.ReactNode;\n}\n\n/** @internal */\nexport function PropertyEditorProvider(props: PropertyEditorProviderProps) {\n const { children, uiDataProvider, itemPropertyName, lockPropertyName } =\n props;\n return (\n <PropertyEditorContext.Provider\n value={React.useMemo(\n () => ({\n uiDataProvider,\n itemPropertyName,\n lockPropertyName,\n }),\n [uiDataProvider, itemPropertyName, lockPropertyName]\n )}\n >\n {children}\n </PropertyEditorContext.Provider>\n );\n}\n\n/** Returns `true` if the lock decoration should be displayed.\n * @internal\n */\nexport function useLockDecoration() {\n const { lockPropertyName, itemPropertyName, uiDataProvider } =\n React.useContext(PropertyEditorContext) ?? {};\n const { toolSettingsLockButton } = usePreviewFeatures();\n const dialogItem = React.useMemo(\n () =>\n uiDataProvider?.items.find(\n (item) => item.property.name === itemPropertyName\n ),\n [uiDataProvider, itemPropertyName]\n );\n return (\n !!toolSettingsLockButton && !lockPropertyName && !!dialogItem?.lockProperty\n );\n}\n\ninterface UseLockPropertyArgs {\n provider: UiLayoutDataProvider;\n itemPropertyName: string;\n}\n\n/** @internal */\nexport function useLockProperty(args: UseLockPropertyArgs | undefined) {\n const { provider, itemPropertyName } = args ?? {};\n const subscribe = React.useCallback(\n (onStoreChange: () => void) => {\n const listeners = provider\n ? [\n provider.onItemsReloadedEvent.addListener(onStoreChange),\n provider.onSyncPropertiesChangeEvent.addListener(onStoreChange),\n ]\n : [];\n return () => listeners.forEach((l) => l());\n },\n [provider]\n );\n const getSnapshot = React.useCallback(() => {\n const dialogItem = provider?.items.find(\n (item) => item.property.name === itemPropertyName\n );\n return dialogItem?.lockProperty;\n }, [provider, itemPropertyName]);\n return React.useSyncExternalStore(subscribe, getSnapshot);\n}\n\n/** This component displays a lock button in the property editor when the `toolSettingsLockButton` preview feature is enabled.\n * @alpha\n */\nexport function LockButtonInputDecoration() {\n const { itemPropertyName, uiDataProvider: provider } =\n React.useContext(PropertyEditorContext) ?? {};\n const { setLockDecoration } = React.useContext(LockContext) ?? {};\n const lockDecoration = useLockDecoration();\n\n const lockProperty = useLockProperty(\n provider && itemPropertyName\n ? {\n provider,\n itemPropertyName,\n }\n : undefined\n );\n\n React.useLayoutEffect(() => {\n if (!lockDecoration) return;\n if (!setLockDecoration) return;\n if (!itemPropertyName) return;\n setLockDecoration(itemPropertyName, true);\n return () => {\n setLockDecoration(itemPropertyName, false);\n };\n }, [setLockDecoration, itemPropertyName, lockDecoration]);\n\n if (!lockDecoration) return null;\n\n const isLocked = !!lockProperty?.value.value;\n const displayLabel = lockProperty?.property.displayLabel;\n const label = displayLabel ? displayLabel : \"Toggle lock\";\n const disabled = lockProperty?.isDisabled;\n return (\n <InputWithDecorations.Button\n isActive={isLocked}\n label={label}\n disabled={disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n if (!provider) return;\n if (!lockProperty) return;\n\n provider.applyUiPropertyChange({\n value: {\n ...lockProperty.value,\n value: !isLocked,\n },\n propertyName: lockProperty.property.name,\n });\n provider.reloadDialogItems();\n }}\n >\n {isLocked ? <SvgLock /> : <SvgLockUnlocked />}\n </InputWithDecorations.Button>\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import { NumericInputPropertyEditor as BaseNumericInputPropertyEditor } from "@itwin/components-react";
6
+ /** @internal */
7
+ export declare class NumericInputPropertyEditor extends BaseNumericInputPropertyEditor {
8
+ get reactNode(): React.JSX.Element;
9
+ }
10
+ //# sourceMappingURL=NumericEditor.d.ts.map
@@ -0,0 +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;AAQjC,gBAAgB;AAChB,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC5E,IAAoB,SAAS,sBAE5B;CACF"}
@@ -0,0 +1,26 @@
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 PropertyEditors
7
+ */
8
+ import * as React from "react";
9
+ import { NumericInputEditor as BaseNumericInputEditor, NumericInputPropertyEditor as BaseNumericInputPropertyEditor, } from "@itwin/components-react";
10
+ import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
11
+ import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
12
+ /** @internal */
13
+ export class NumericInputPropertyEditor extends BaseNumericInputPropertyEditor {
14
+ get reactNode() {
15
+ return React.createElement(NumericEditor, null);
16
+ }
17
+ }
18
+ const NumericEditor = React.forwardRef(function NumericEditor(props, forwardedRef) {
19
+ const shouldCommitOnChange = useToolSettingsKeyPressCommit();
20
+ const lockDecoration = useLockDecoration();
21
+ const internalProps = {
22
+ decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
23
+ };
24
+ return (React.createElement(BaseNumericInputEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
25
+ });
26
+ //# sourceMappingURL=NumericEditor.js.map
@@ -0,0 +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;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"]}
@@ -0,0 +1,10 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import { BasicPropertyEditor as BaseTextPropertyEditor } from "@itwin/components-react";
6
+ /** @internal */
7
+ export declare class TextPropertyEditor extends BaseTextPropertyEditor {
8
+ get reactNode(): React.JSX.Element;
9
+ }
10
+ //# sourceMappingURL=TextEditor.d.ts.map
@@ -0,0 +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;AAQjC,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,sBAAsB;IAC5D,IAAoB,SAAS,sBAE5B;CACF"}
@@ -0,0 +1,26 @@
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 PropertyEditors
7
+ */
8
+ import * as React from "react";
9
+ import { TextEditor as BaseTextEditor, BasicPropertyEditor as BaseTextPropertyEditor, } from "@itwin/components-react";
10
+ import { LockButtonInputDecoration, useLockDecoration, } from "./LockProvider.js";
11
+ import { useToolSettingsKeyPressCommit } from "../preview/tool-settings-key-press-commit/useToolSettingsKeyPressCommit.js";
12
+ /** @internal */
13
+ export class TextPropertyEditor extends BaseTextPropertyEditor {
14
+ get reactNode() {
15
+ return React.createElement(TextEditor, null);
16
+ }
17
+ }
18
+ const TextEditor = React.forwardRef(function TextEditor(props, forwardedRef) {
19
+ const shouldCommitOnChange = useToolSettingsKeyPressCommit();
20
+ const lockDecoration = useLockDecoration();
21
+ const internalProps = {
22
+ decoration: lockDecoration ? React.createElement(LockButtonInputDecoration, null) : undefined,
23
+ };
24
+ return (React.createElement(BaseTextEditor, { ...props, ...internalProps, shouldCommitOnChange: shouldCommitOnChange, ref: forwardedRef }));
25
+ });
26
+ //# sourceMappingURL=TextEditor.js.map
@@ -0,0 +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;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,6 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ /** @internal */
5
+ export declare function registerEditors(): void;
6
+ //# sourceMappingURL=registerEditors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerEditors.d.ts","sourceRoot":"","sources":["../../../src/appui-react/editors/registerEditors.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH,gBAAgB;AAChB,wBAAgB,eAAe,SAwD9B"}
@@ -0,0 +1,28 @@
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 PropertyEditors
7
+ */
8
+ import { StandardEditorNames, StandardTypeNames } from "@itwin/appui-abstract";
9
+ import { registerDefaultPropertyEditor } from "@itwin/components-react/internal";
10
+ import { LockPropertyEditor, LockPropertyEditorName } from "./LockEditor.js";
11
+ import { CustomNumberPropertyEditor } from "./CustomNumberEditor.js";
12
+ import { TextPropertyEditor } from "./TextEditor.js";
13
+ import { NumericInputPropertyEditor } from "./NumericEditor.js";
14
+ /** @internal */
15
+ export function registerEditors() {
16
+ // Editors that support lock decorations.
17
+ registerDefaultPropertyEditor(StandardTypeNames.Text, TextPropertyEditor, undefined, true);
18
+ registerDefaultPropertyEditor(StandardTypeNames.String, TextPropertyEditor, undefined, true);
19
+ registerDefaultPropertyEditor(StandardTypeNames.Number, NumericInputPropertyEditor, StandardEditorNames.NumericInput, true);
20
+ registerDefaultPropertyEditor(StandardTypeNames.Int, NumericInputPropertyEditor, StandardEditorNames.NumericInput, true);
21
+ registerDefaultPropertyEditor(StandardTypeNames.Float, NumericInputPropertyEditor, StandardEditorNames.NumericInput, true);
22
+ registerDefaultPropertyEditor(StandardTypeNames.Double, NumericInputPropertyEditor, StandardEditorNames.NumericInput, true);
23
+ registerDefaultPropertyEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom, true);
24
+ // `appui-react` specific editors.
25
+ registerDefaultPropertyEditor(StandardTypeNames.Bool, LockPropertyEditor, LockPropertyEditorName);
26
+ registerDefaultPropertyEditor(StandardTypeNames.Boolean, LockPropertyEditor, LockPropertyEditorName);
27
+ }
28
+ //# sourceMappingURL=registerEditors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerEditors.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AC3B,iBAAiB,CAAC,IAAI,EACtB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;IACF,6BAA6B,CAC3B,iBAAiB,CAAC,OAAO,EACzB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;AACJ,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 { StandardEditorNames, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { registerDefaultPropertyEditor } from \"@itwin/components-react/internal\";\nimport { LockPropertyEditor, LockPropertyEditorName } from \"./LockEditor.js\";\nimport { CustomNumberPropertyEditor } from \"./CustomNumberEditor.js\";\nimport { TextPropertyEditor } from \"./TextEditor.js\";\nimport { NumericInputPropertyEditor } from \"./NumericEditor.js\";\n\n/** @internal */\nexport function registerEditors() {\n // Editors that support lock decorations.\n registerDefaultPropertyEditor(\n StandardTypeNames.Text,\n TextPropertyEditor,\n undefined,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.String,\n TextPropertyEditor,\n undefined,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Number,\n NumericInputPropertyEditor,\n StandardEditorNames.NumericInput,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Int,\n NumericInputPropertyEditor,\n StandardEditorNames.NumericInput,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Float,\n NumericInputPropertyEditor,\n StandardEditorNames.NumericInput,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Double,\n NumericInputPropertyEditor,\n StandardEditorNames.NumericInput,\n true\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Number,\n CustomNumberPropertyEditor,\n StandardEditorNames.NumberCustom,\n true\n );\n\n // `appui-react` specific editors.\n registerDefaultPropertyEditor(\n StandardTypeNames.Bool,\n LockPropertyEditor,\n LockPropertyEditorName\n );\n registerDefaultPropertyEditor(\n StandardTypeNames.Boolean,\n LockPropertyEditor,\n LockPropertyEditorName\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ /** @internal */
3
+ export declare function useControlledState<T>(initialValue: T, controlledState: T | undefined, setControlledState?: React.Dispatch<React.SetStateAction<T>>): readonly [T, React.Dispatch<React.SetStateAction<T>>];
4
+ //# sourceMappingURL=useControlledState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useControlledState.d.ts","sourceRoot":"","sources":["../../../src/appui-react/hooks/useControlledState.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,YAAY,EAAE,CAAC,EACf,eAAe,EAAE,CAAC,GAAG,SAAS,EAC9B,kBAAkB,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,yDAmB7D"}
@@ -0,0 +1,16 @@
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
+ /** @internal */
7
+ export function useControlledState(initialValue, controlledState, setControlledState) {
8
+ const [uncontrolledState, setUncontrolledState] = React.useState(initialValue);
9
+ const state = React.useMemo(() => (controlledState !== undefined ? controlledState : uncontrolledState), [controlledState, uncontrolledState]);
10
+ const setState = React.useCallback((value) => {
11
+ setUncontrolledState(value);
12
+ setControlledState?.(value);
13
+ }, [setControlledState, setUncontrolledState]);
14
+ return [state, setState];
15
+ }
16
+ //# sourceMappingURL=useControlledState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useControlledState.js","sourceRoot":"","sources":["../../../src/appui-react/hooks/useControlledState.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAChC,YAAe,EACf,eAA8B,EAC9B,kBAA4D;IAE5D,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAC7C,KAAK,CAAC,QAAQ,CAAI,YAAY,CAAC,CAAC;IAElC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CACzB,GAAG,EAAE,CAAC,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,EAC3E,CAAC,eAAe,EAAE,iBAAiB,CAAC,CACrC,CAAC;IAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAChC,CAAC,KAAK,EAAE,EAAE;QACR,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC5B,kBAAkB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,EACD,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CACA,CAAC;IAE7C,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAU,CAAC;AACpC,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\";\n\n/** @internal */\nexport function useControlledState<T>(\n initialValue: T,\n controlledState: T | undefined,\n setControlledState?: React.Dispatch<React.SetStateAction<T>>\n) {\n const [uncontrolledState, setUncontrolledState] =\n React.useState<T>(initialValue);\n\n const state = React.useMemo(\n () => (controlledState !== undefined ? controlledState : uncontrolledState),\n [controlledState, uncontrolledState]\n );\n\n const setState = React.useCallback(\n (value) => {\n setUncontrolledState(value);\n setControlledState?.(value);\n },\n [setControlledState, setUncontrolledState]\n ) as React.Dispatch<React.SetStateAction<T>>;\n\n return [state, setState] as const;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /** @packageDocumentation
2
+ * @module Utilities
3
+ */
4
+ import * as React from "react";
5
+ /** @internal */
6
+ export declare function SvgSnapsPerpendicular(): React.JSX.Element;
7
+ //# sourceMappingURL=SvgSnapsPerpendicular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SvgSnapsPerpendicular.d.ts","sourceRoot":"","sources":["../../../../src/appui-react/icons/snaps/SvgSnapsPerpendicular.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,wBAAgB,qBAAqB,sBAYpC"}
@@ -0,0 +1,14 @@
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 Utilities
7
+ */
8
+ import * as React from "react";
9
+ /** @internal */
10
+ export function SvgSnapsPerpendicular() {
11
+ return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16" },
12
+ React.createElement("path", { d: "M8 2a.5.5 0 0 1 .5.5v7.565A2 2 0 0 1 9.935 11.5H13.5a.5.5 0 0 1 0 1H9.935a1.999 1.999 0 0 1-3.87 0H2.5a.5.5 0 0 1 0-1h3.565A2 2 0 0 1 7.5 10.065V2.5A.5.5 0 0 1 8 2Zm0 9a1 1 0 1 0 1 1l-.005-.102A1 1 0 0 0 8 11Z" })));
13
+ }
14
+ //# sourceMappingURL=SvgSnapsPerpendicular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SvgSnapsPerpendicular.js","sourceRoot":"","sources":["../../../../src/appui-react/icons/snaps/SvgSnapsPerpendicular.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,gBAAgB;AAChB,MAAM,UAAU,qBAAqB;IACnC,OAAO,CACL,6BACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,WAAW;QAEnB,8BAAM,CAAC,EAAC,mNAAmN,GAAG,CAC1N,CACP,CAAC;AACJ,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\";\n\n/** @internal */\nexport function SvgSnapsPerpendicular() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path d=\"M8 2a.5.5 0 0 1 .5.5v7.565A2 2 0 0 1 9.935 11.5H13.5a.5.5 0 0 1 0 1H9.935a1.999 1.999 0 0 1-3.87 0H2.5a.5.5 0 0 1 0-1h3.565A2 2 0 0 1 7.5 10.065V2.5A.5.5 0 0 1 8 2Zm0 9a1 1 0 1 0 1 1l-.005-.102A1 1 0 0 0 8 11Z\" />\n </svg>\n );\n}\n"]}