@itwin/presentation-hierarchies-react 2.0.0-alpha.52 → 2.0.0-alpha.53

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @itwin/presentation-hierarchies-react
2
2
 
3
+ ## 2.0.0-alpha.53
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1192](https://github.com/iTwin/presentation/pull/1192): Fix situations where expander was rendered for leaf nodes.
8
+ - [#1196](https://github.com/iTwin/presentation/pull/1196): Added accessible name for tree node rename input.
9
+
3
10
  ## 2.0.0-alpha.52
4
11
 
5
12
  ### Patch Changes
@@ -109,6 +109,11 @@ export interface LocalizedStrings {
109
109
  * Default value: `Cancel`.
110
110
  */
111
111
  cancel: string;
112
+ /**
113
+ * Label for tree node rename input.
114
+ * Default value: `New label`.
115
+ */
116
+ newLabel: string;
112
117
  }
113
118
  /** @internal */
114
119
  export interface LocalizationContext {
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AA4BD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
1
+ {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE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@ -26,6 +26,7 @@ const defaultLocalizedStrings = {
26
26
  more: "More",
27
27
  confirm: "Confirm",
28
28
  cancel: "Cancel",
29
+ newLabel: "New label",
29
30
  };
30
31
  const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
31
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuH1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAqC,EAAE,mBAAmB;IAC1D,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,6CAA6C;IACjE,8BAA8B,EAAE,eAAe;IAC/C,uBAAuB,EAAE,0CAA0C;IACnE,2BAA2B,EAAE,sBAAsB;IACnD,mBAAmB,EAAE,gGAAgG;IACrH,uBAAuB,EAAE,8EAA8E;IACvG,aAAa,EAAE,4BAA4B;IAC3C,WAAW,EAAE,sCAAsC;IACnD,aAAa,EAAE,kBAAkB;IACjC,sBAAsB,EAAE,6BAA6B;IACrD,iCAAiC,EAAE,cAAc;IACjD,mCAAmC,EAAE,YAAY;IACjD,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,mBAAmB,GAAG,aAAa,CAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAW9G;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAuD;IAC7H,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE9G,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAAE,GAAG,uBAAuB,EAAE,GAAG,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAgC,CAAC;AAC/F,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,sBAAsB;IACpC,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
1
+ {"version":3,"file":"LocalizationContext.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAqB,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA4H1F,MAAM,uBAAuB,GAAqB;IAChD,OAAO,EAAE,YAAY;IACrB,oBAAoB,EAAE,cAAc;IACpC,qCAAq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AACzC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { createContext, PropsWithChildren, useContext, useEffect, useState } from \"react\";\n\n/**\n * Localized strings used in the components.\n * @public\n */\nexport interface LocalizedStrings {\n /**\n * Message displayed when nodes are loading.\n * Default value: `Loading...`.\n */\n loading: string;\n /**\n * Title for apply hierarchy filter button.\n * Default value: `Apply filter`.\n */\n filterHierarchyLevel: string;\n /**\n * Accessible description for applied hierarchy filter button.\n * Default value: `Filter is applied`.\n */\n filterHierarchyLevelActiveDescription: string;\n /**\n * Title for clear hierarchy filter button.\n * Default value: `Clear active filter`.\n */\n clearHierarchyLevelFilter: string;\n /**\n * Message displayed when no nodes matching filter are found.\n * Default value: `No matches for current filter for {{node}}.`.\n */\n noFilteredChildren: string;\n /**\n * Label for change filter action.\n * Default value: `Change filter`.\n */\n noFilteredChildrenChangeFilter: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to create hierarchy for {{node}}.`.\n */\n failedToCreateHierarchy: string;\n /**\n * Message displayed when hierarchy creation for a node failed.\n * Default value: `Failed to load tree.`.\n */\n failedToCreateRootHierarchy: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.\n */\n resultLimitExceeded: string;\n /**\n * Message displayed when result limit exceeds hierarchy size limit.\n * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.\n */\n rootResultLimitExceeded: string;\n /**\n * Name for the error region landmark.\n * Default value: `Issues for {{tree_label}}.`.\n */\n issuesForTree: string;\n /**\n * Label displayed on the error region, when errors are detected.\n * Default value: `{{number_of_issues}} issue(s) found.`.\n */\n issuesFound: string;\n /**\n * Label displayed on the error region, when no issues are found.\n * Default value: `No issues found.`.\n */\n noIssuesFound: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Increase limit to {{limit}}`.\n */\n increaseHierarchyLimit: string;\n /**\n * Message displayed when hierarchy size limit can be overridden.\n * Default value: `Remove limit`.\n */\n increaseHierarchyLimitToUnlimited: string;\n /**\n * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.\n * Default value: `Add Filter`.\n */\n increaseHierarchyLimitWithFiltering: string;\n /**\n * Label for retry action.\n * Default value: `Retry`.\n */\n retry: string;\n /**\n * Label for rename action.\n * Default value: `Rename`.\n */\n rename: string;\n /**\n * Label for more actions button.\n * Default value: `More`.\n */\n more: string;\n /**\n * Label for confirm button.\n * Default value: `Confirm`.\n */\n confirm: string;\n /**\n * Label for cancel button.\n * Default value: `Cancel`.\n */\n cancel: string;\n /**\n * Label for tree node rename input.\n * Default value: `New label`.\n */\n newLabel: string;\n}\n\n/** @internal */\nexport interface LocalizationContext {\n localizedStrings: LocalizedStrings;\n}\n\nconst defaultLocalizedStrings: LocalizedStrings = {\n loading: \"Loading...\",\n filterHierarchyLevel: \"Apply filter\",\n filterHierarchyLevelActiveDescription: \"Filter is applied\",\n clearHierarchyLevelFilter: \"Clear active filter\",\n noFilteredChildren: \"No matches for current filter for {{node}}.\",\n noFilteredChildrenChangeFilter: \"Change filter\",\n failedToCreateHierarchy: \"Failed to create hierarchy for {{node}}.\",\n failedToCreateRootHierarchy: \"Failed to load tree.\",\n resultLimitExceeded: \"The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.\",\n rootResultLimitExceeded: \"The root item hierarchy contains {{limit}}+ items. Try increasing the limit.\",\n issuesForTree: \"Issues for {{tree_label}}.\",\n issuesFound: \"{{number_of_issues}} issue(s) found.\",\n noIssuesFound: \"No issues found.\",\n increaseHierarchyLimit: \"Increase limit to {{limit}}\",\n increaseHierarchyLimitToUnlimited: \"Remove limit\",\n increaseHierarchyLimitWithFiltering: \"Add Filter\",\n retry: \"Retry\",\n rename: \"Rename\",\n more: \"More\",\n confirm: \"Confirm\",\n cancel: \"Cancel\",\n newLabel: \"New label\",\n};\n\nconst localizationContext = createContext<LocalizationContext>({ localizedStrings: defaultLocalizedStrings });\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localized strings used in the components. */\n localizedStrings?: Partial<LocalizedStrings>;\n}\n\n/**\n * Context provider for localized strings used in the components.\n * @public\n */\nexport function LocalizationContextProvider({ localizedStrings, children }: PropsWithChildren<LocalizationContextProviderProps>) {\n const [state, setState] = useState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n\n useEffect(() => {\n setState({ localizedStrings: { ...defaultLocalizedStrings, ...localizedStrings } });\n }, [localizedStrings]);\n\n return <localizationContext.Provider value={state}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useLocalizationContext() {\n return useContext(localizationContext);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAEL,wBAAwB,EACxB,EAAE,EAIF,YAAY,EACZ,SAAS,EACT,aAAa,EAOd,MAAM,OAAO,CAAC;AAKf,OAAO,EAA6C,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,gBAAgB;AAChB,UAAU,wBAAyB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,CAAC;IAC7F,6BAA6B;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B;;;OAGG;IACH,kBAAk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;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC;CAClC;AAED,aAAa;AACb,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACvC,wBAAwB,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,EAC1C,SAAS,GAAG,eAAe,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,GAAG,sBAAsB,GAAG,OAAO,CAC1G,GAAG;IACF;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,YAAY,CAAC,qBAAqB,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CA4H1G,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,EAAE,CAC9B,YAAY,CAAC,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,YAAY,GAAG,eAAe,GAAG,cAAc,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAgBnI,CAAC"}
@@ -46,11 +46,12 @@ export const StrataKitTreeNodeRenderer = memo(forwardRef(function HierarchyNode(
46
46
  if (node.error) {
47
47
  return undefined;
48
48
  }
49
- if (node.isExpanded || node.children === true || node.children.length > 0) {
50
- return node.isExpanded;
49
+ // this is a leaf node
50
+ if (node.children !== true && node.children.length === 0) {
51
+ return undefined;
51
52
  }
52
- return undefined;
53
- }, [node.children, node.error, node.isExpanded]);
53
+ return node.isExpanded;
54
+ }, [node]);
54
55
  const { renameParameters, cancelRename } = renameContext ?? {};
55
56
  const labelEditor = (_jsx(LabelEditor, { initialLabel: node.label, onChange: renameParameters?.commit, onCancel: cancelRename, labelValidationHint: renameParameters?.labelValidationHint, validate: renameParameters?.validate }));
56
57
  return (_jsxs(_Fragment, { children: [_jsx(Popover, { content: labelEditor, placement: "bottom", open: renameParameters?.nodeId === node.id, setOpen: cancelRename, unmountOnHide: true, children: _jsx(Tree.Item, { ...treeItemProps, ref: forwardedRef, label: label, expanded: expanded, onExpandedChange: useCallback((isExpanded) => {
@@ -112,7 +113,7 @@ function LabelEditor({ initialLabel, labelValidationHint, onChange, onCancel, va
112
113
  }, []);
113
114
  const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;
114
115
  const inputId = useId();
115
- return (_jsxs("div", { className: "phr-node-label-editor", children: [_jsxs("div", { className: "phr-node-label-editor-input-row", children: [_jsx(TextBox.Root, { style: { width: "100%" }, className: hasError ? "with-error" : undefined, children: _jsx(TextBox.Input, { id: inputId, ref: inputRef, value: newLabelValue, onChange: (event) => {
116
+ return (_jsxs("div", { className: "phr-node-label-editor", children: [_jsxs("div", { className: "phr-node-label-editor-input-row", children: [_jsx(TextBox.Root, { style: { width: "100%" }, className: hasError ? "with-error" : undefined, children: _jsx(TextBox.Input, { id: inputId, ref: inputRef, "aria-label": localizedStrings.newLabel, value: newLabelValue, onChange: (event) => {
116
117
  setNewLabelValue(event.target.value);
117
118
  setHasError(false);
118
119
  }, onKeyUp: (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,EAGZ,UAAU,EACV,cAAc,EACd,IAAI,EAIJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,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IAAC,OAAO,EAAC,YAAY,YAAE,mBAAmB,GAAQ,GAC3C,CACf,CAAC,CAAC,CAAC,SAAS,KA3BL,YAAY,CA4BhB,CACP,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAoB,EAAE,OAA4C;IAC7F,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAA2B,MAAM,CAAC,CAAC;SACpE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAA2B,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeRenderer.css\";\n\nimport {\n cloneElement,\n ComponentPropsWithoutRef,\n FC,\n forwardRef,\n isValidElement,\n memo,\n PropsWithRef,\n ReactNode,\n RefAttributes,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Description, IconButton, Spinner, Text, TextBox } from \"@stratakit/bricks\";\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\nimport { DropdownMenu, unstable_Popover as Popover, Tree } from \"@stratakit/structures\";\nimport { TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\nimport { useTreeNodeRenameContext } from \"./TreeNodeRenameAction.js\";\n\n/** @internal */\ninterface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, \"expandNode\" | \"reloadTree\"> {\n /** Node that is rendered. */\n node: TreeNode;\n /**\n * Menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n menuActions?: ReactNode[];\n /**\n * Inline actions for tree item.\n * Must be an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n inlineActions?: ReactNode[];\n /**\n * Context menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n contextMenuActions?: ReactNode[];\n}\n\n/** @alpha */\nexport type StrataKitTreeItemProps = Omit<\n ComponentPropsWithoutRef<typeof Tree.Item>,\n \"actions\" | \"inlineActions\" | \"expanded\" | \"onExpandedChange\" | \"icon\" | \"unstable_decorations\" | \"error\"\n> & {\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n decorations?: ReactNode;\n};\n\n/** @internal */\nexport type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;\n\n/**\n * A component that renders given `FlatTreeNode` using the `Tree.Item` component from `@itwin/itwinui-react`. The\n * `FlatTreeNode` objects for this renderer are generally created using the `useFlatTreeNodeList` hook.\n *\n * @internal\n */\nexport const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>> = memo(\n forwardRef<HTMLElement, TreeNodeRendererProps>(function HierarchyNode(props, forwardedRef) {\n const { node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps } = props;\n const { localizedStrings } = useLocalizationContext();\n const renameContext = useTreeNodeRenameContext();\n const [contextMenuProps, setContextMenuProps] = useState<{ position: { x: number; y: number }; actions: ReactNode[] } | undefined>(undefined);\n\n const label = treeItemProps.label ?? node.label;\n const inlineActionItems = useMemo(() => {\n if (node.error !== undefined && node.error.type === \"ChildrenLoad\") {\n return [\n <TreeActionBase\n key=\"retry\"\n label={localizedStrings.retry}\n onClick={() => reloadTree({ parentNodeId: node.id, state: \"reset\" })}\n visible={true}\n icon={refreshSvg}\n variant=\"inline\"\n />,\n ];\n }\n if (!inlineActions) {\n return undefined;\n }\n return injectActionVariant(inlineActions, \"inline\");\n }, [node, inlineActions, localizedStrings.retry, reloadTree]);\n\n const menuActionItems = useMemo(() => {\n if (!menuActions) {\n return undefined;\n }\n return injectActionVariant(menuActions, \"default\");\n }, [menuActions]);\n\n const expanded = useMemo(() => {\n if (node.error) {\n return undefined;\n }\n\n if (node.isExpanded || node.children === true || node.children.length > 0) {\n return node.isExpanded;\n }\n\n return undefined;\n }, [node.children, node.error, node.isExpanded]);\n\n const { renameParameters, cancelRename } = renameContext ?? {};\n const labelEditor = (\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters?.commit}\n onCancel={cancelRename}\n labelValidationHint={renameParameters?.labelValidationHint}\n validate={renameParameters?.validate}\n />\n );\n\n return (\n <>\n <Popover content={labelEditor} placement=\"bottom\" open={renameParameters?.nodeId === node.id} setOpen={cancelRename} unmountOnHide>\n <Tree.Item\n {...treeItemProps}\n ref={forwardedRef}\n label={label}\n expanded={expanded}\n onExpandedChange={useCallback(\n (isExpanded: boolean) => {\n expandNode(node.id, isExpanded);\n },\n [node, expandNode],\n )}\n inlineActions={inlineActionItems}\n actions={menuActionItems}\n unstable_decorations={decorations}\n error={node.error ? node.error.id : undefined}\n onContextMenu={(e) => {\n if (treeItemProps.onContextMenu) {\n treeItemProps.onContextMenu(e);\n }\n\n if (!contextMenuActions) {\n return;\n }\n\n e.preventDefault();\n const actions = injectActionVariant(contextMenuActions, \"context-menu\");\n if (actions.length === 0) {\n return;\n }\n\n setContextMenuProps({\n position: {\n x: e.clientX,\n y: e.clientY,\n },\n actions,\n });\n }}\n />\n </Popover>\n <DropdownMenu.Provider\n open={contextMenuProps !== undefined}\n setOpen={(open) => {\n if (!open) {\n setContextMenuProps(undefined);\n }\n }}\n key={`${node.id}-${contextMenuProps?.position.x ?? \"\"}-${contextMenuProps?.position.y ?? \"\"}`}\n >\n {contextMenuProps ? (\n <DropdownMenu.Button style={{ position: \"fixed\", top: contextMenuProps.position.y, left: contextMenuProps.position.x }} render={<div />} />\n ) : null}\n {/* `autoFocus` prop is coming from ariakit and is not native HTML `autoFocus` prop. */}\n {/* `focusable` is needed for `autoFocus` to work. StrataKit exposes only `autoFocus` and does not set `focusable` internally. */}\n {/* eslint-disable jsx-a11y/no-autofocus */}\n {/* @ts-expect-error focusable is passed through */}\n <DropdownMenu.Content focusable autoFocus={true}>\n {contextMenuProps?.actions}\n </DropdownMenu.Content>\n </DropdownMenu.Provider>\n </>\n );\n }),\n);\n\nexport const PlaceholderNode: FC<\n PropsWithRef<Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\"> & RefAttributes<HTMLElement>>\n> = memo(\n forwardRef<HTMLElement, Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>(function PlaceholderNode(\n { ...props },\n forwardedRef,\n ) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Tree.Item\n {...props}\n ref={forwardedRef}\n label={localizedStrings.loading}\n unstable_decorations={<Spinner size={\"small\"} title={localizedStrings.loading} />}\n />\n );\n }),\n);\n\nfunction LabelEditor({\n initialLabel,\n labelValidationHint,\n onChange,\n onCancel,\n validate,\n}: {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}) {\n const { localizedStrings } = useLocalizationContext();\n const inputRef = useRef<HTMLInputElement>(null);\n const [newLabelValue, setNewLabelValue] = useState(initialLabel);\n const [hasError, setHasError] = useState<boolean>(false);\n const handleLabelChange = () => {\n if (validate && !validate(newLabelValue)) {\n setHasError(true);\n return;\n }\n\n if (initialLabel !== newLabelValue) {\n onChange?.(newLabelValue);\n return;\n }\n onCancel?.();\n };\n\n const cancelLabelChange = () => {\n setNewLabelValue(initialLabel);\n onCancel?.();\n };\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;\n const inputId = useId();\n\n return (\n <div key={initialLabel} className=\"phr-node-label-editor\">\n <div className=\"phr-node-label-editor-input-row\">\n <TextBox.Root style={{ width: \"100%\" }} className={hasError ? \"with-error\" : undefined}>\n <TextBox.Input\n id={inputId}\n ref={inputRef}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyUp={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n </TextBox.Root>\n <IconButton icon={dismissSvg} label={localizedStrings.cancel} onClick={cancelLabelChange} />\n <IconButton icon={checkmarkSvg} label={localizedStrings.confirm} onClick={handleLabelChange} disabled={!canRename} />\n </div>\n {labelValidationHint !== undefined ? (\n <Description id={inputId} tone={hasError ? \"critical\" : \"neutral\"} style={{ display: \"flex\" }}>\n <Text variant=\"caption-lg\">{labelValidationHint}</Text>\n </Description>\n ) : undefined}\n </div>\n );\n}\n\nfunction injectActionVariant(actions: ReactNode[], variant: TreeActionBaseAttributes[\"variant\"]) {\n return actions\n .filter((action) => isValidElement<TreeActionBaseAttributes>(action))\n .map((action) => cloneElement<TreeActionBaseAttributes>(action, { variant }));\n}\n"]}
1
+ {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/TreeNodeRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,EAGZ,UAAU,EACV,cAAc,EACd,IAAI,EAIJ,WAAW,EACX,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAC1D,OAAO,UAAU,MAAM,8BAA8B,CAAC;AACtD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ACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAoB,EAAE,OAA4C;IAC7F,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAA2B,MAAM,CAAC,CAAC;SACpE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAA2B,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TreeNodeRenderer.css\";\n\nimport {\n cloneElement,\n ComponentPropsWithoutRef,\n FC,\n forwardRef,\n isValidElement,\n memo,\n PropsWithRef,\n ReactNode,\n RefAttributes,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { Description, IconButton, Spinner, Text, TextBox } from \"@stratakit/bricks\";\nimport checkmarkSvg from \"@stratakit/icons/checkmark.svg\";\nimport dismissSvg from \"@stratakit/icons/dismiss.svg\";\nimport refreshSvg from \"@stratakit/icons/refresh.svg\";\nimport { DropdownMenu, unstable_Popover as Popover, Tree } from \"@stratakit/structures\";\nimport { TreeRendererProps } from \"../Renderers.js\";\nimport { TreeNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\nimport { TreeActionBase, TreeActionBaseAttributes } from \"./TreeAction.js\";\nimport { useTreeNodeRenameContext } from \"./TreeNodeRenameAction.js\";\n\n/** @internal */\ninterface TreeNodeRendererOwnProps extends Pick<TreeRendererProps, \"expandNode\" | \"reloadTree\"> {\n /** Node that is rendered. */\n node: TreeNode;\n /**\n * Menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n menuActions?: ReactNode[];\n /**\n * Inline actions for tree item.\n * Must be an array of `<TreeActionBase />` elements.\n * Max 2 items.\n */\n inlineActions?: ReactNode[];\n /**\n * Context menu actions for tree item.\n * Must be an array of `<TreeActionBase />` or `<Divider />` elements.\n */\n contextMenuActions?: ReactNode[];\n}\n\n/** @alpha */\nexport type StrataKitTreeItemProps = Omit<\n ComponentPropsWithoutRef<typeof Tree.Item>,\n \"actions\" | \"inlineActions\" | \"expanded\" | \"onExpandedChange\" | \"icon\" | \"unstable_decorations\" | \"error\"\n> & {\n /**\n * Used to render elements between expander and label.\n * E.g. icons, color picker, etc.\n */\n decorations?: ReactNode;\n};\n\n/** @internal */\nexport type TreeNodeRendererProps = StrataKitTreeItemProps & TreeNodeRendererOwnProps;\n\n/**\n * A component that renders given `FlatTreeNode` using the `Tree.Item` component from `@itwin/itwinui-react`. The\n * `FlatTreeNode` objects for this renderer are generally created using the `useFlatTreeNodeList` hook.\n *\n * @internal\n */\nexport const StrataKitTreeNodeRenderer: FC<PropsWithRef<TreeNodeRendererProps & RefAttributes<HTMLElement>>> = memo(\n forwardRef<HTMLElement, TreeNodeRendererProps>(function HierarchyNode(props, forwardedRef) {\n const { node, decorations, inlineActions, menuActions, contextMenuActions, expandNode, reloadTree, ...treeItemProps } = props;\n const { localizedStrings } = useLocalizationContext();\n const renameContext = useTreeNodeRenameContext();\n const [contextMenuProps, setContextMenuProps] = useState<{ position: { x: number; y: number }; actions: ReactNode[] } | undefined>(undefined);\n\n const label = treeItemProps.label ?? node.label;\n const inlineActionItems = useMemo(() => {\n if (node.error !== undefined && node.error.type === \"ChildrenLoad\") {\n return [\n <TreeActionBase\n key=\"retry\"\n label={localizedStrings.retry}\n onClick={() => reloadTree({ parentNodeId: node.id, state: \"reset\" })}\n visible={true}\n icon={refreshSvg}\n variant=\"inline\"\n />,\n ];\n }\n if (!inlineActions) {\n return undefined;\n }\n return injectActionVariant(inlineActions, \"inline\");\n }, [node, inlineActions, localizedStrings.retry, reloadTree]);\n\n const menuActionItems = useMemo(() => {\n if (!menuActions) {\n return undefined;\n }\n return injectActionVariant(menuActions, \"default\");\n }, [menuActions]);\n\n const expanded = useMemo(() => {\n if (node.error) {\n return undefined;\n }\n\n // this is a leaf node\n if (node.children !== true && node.children.length === 0) {\n return undefined;\n }\n\n return node.isExpanded;\n }, [node]);\n\n const { renameParameters, cancelRename } = renameContext ?? {};\n const labelEditor = (\n <LabelEditor\n initialLabel={node.label}\n onChange={renameParameters?.commit}\n onCancel={cancelRename}\n labelValidationHint={renameParameters?.labelValidationHint}\n validate={renameParameters?.validate}\n />\n );\n\n return (\n <>\n <Popover content={labelEditor} placement=\"bottom\" open={renameParameters?.nodeId === node.id} setOpen={cancelRename} unmountOnHide>\n <Tree.Item\n {...treeItemProps}\n ref={forwardedRef}\n label={label}\n expanded={expanded}\n onExpandedChange={useCallback(\n (isExpanded: boolean) => {\n expandNode(node.id, isExpanded);\n },\n [node, expandNode],\n )}\n inlineActions={inlineActionItems}\n actions={menuActionItems}\n unstable_decorations={decorations}\n error={node.error ? node.error.id : undefined}\n onContextMenu={(e) => {\n if (treeItemProps.onContextMenu) {\n treeItemProps.onContextMenu(e);\n }\n\n if (!contextMenuActions) {\n return;\n }\n\n e.preventDefault();\n const actions = injectActionVariant(contextMenuActions, \"context-menu\");\n if (actions.length === 0) {\n return;\n }\n\n setContextMenuProps({\n position: {\n x: e.clientX,\n y: e.clientY,\n },\n actions,\n });\n }}\n />\n </Popover>\n <DropdownMenu.Provider\n open={contextMenuProps !== undefined}\n setOpen={(open) => {\n if (!open) {\n setContextMenuProps(undefined);\n }\n }}\n key={`${node.id}-${contextMenuProps?.position.x ?? \"\"}-${contextMenuProps?.position.y ?? \"\"}`}\n >\n {contextMenuProps ? (\n <DropdownMenu.Button style={{ position: \"fixed\", top: contextMenuProps.position.y, left: contextMenuProps.position.x }} render={<div />} />\n ) : null}\n {/* `autoFocus` prop is coming from ariakit and is not native HTML `autoFocus` prop. */}\n {/* `focusable` is needed for `autoFocus` to work. StrataKit exposes only `autoFocus` and does not set `focusable` internally. */}\n {/* eslint-disable jsx-a11y/no-autofocus */}\n {/* @ts-expect-error focusable is passed through */}\n <DropdownMenu.Content focusable autoFocus={true}>\n {contextMenuProps?.actions}\n </DropdownMenu.Content>\n </DropdownMenu.Provider>\n </>\n );\n }),\n);\n\nexport const PlaceholderNode: FC<\n PropsWithRef<Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\"> & RefAttributes<HTMLElement>>\n> = memo(\n forwardRef<HTMLElement, Pick<StrataKitTreeItemProps, \"style\" | \"aria-level\" | \"aria-posinset\" | \"aria-setsize\">>(function PlaceholderNode(\n { ...props },\n forwardedRef,\n ) {\n const { localizedStrings } = useLocalizationContext();\n return (\n <Tree.Item\n {...props}\n ref={forwardedRef}\n label={localizedStrings.loading}\n unstable_decorations={<Spinner size={\"small\"} title={localizedStrings.loading} />}\n />\n );\n }),\n);\n\nfunction LabelEditor({\n initialLabel,\n labelValidationHint,\n onChange,\n onCancel,\n validate,\n}: {\n initialLabel: string;\n labelValidationHint?: string;\n onChange?: (newLabel: string) => void;\n onCancel?: () => void;\n validate?: (newLabel: string) => boolean;\n}) {\n const { localizedStrings } = useLocalizationContext();\n const inputRef = useRef<HTMLInputElement>(null);\n const [newLabelValue, setNewLabelValue] = useState(initialLabel);\n const [hasError, setHasError] = useState<boolean>(false);\n const handleLabelChange = () => {\n if (validate && !validate(newLabelValue)) {\n setHasError(true);\n return;\n }\n\n if (initialLabel !== newLabelValue) {\n onChange?.(newLabelValue);\n return;\n }\n onCancel?.();\n };\n\n const cancelLabelChange = () => {\n setNewLabelValue(initialLabel);\n onCancel?.();\n };\n\n useEffect(() => {\n if (inputRef.current) {\n inputRef.current.focus();\n inputRef.current.select();\n }\n }, []);\n\n const canRename = newLabelValue && newLabelValue !== initialLabel && !hasError;\n const inputId = useId();\n\n return (\n <div key={initialLabel} className=\"phr-node-label-editor\">\n <div className=\"phr-node-label-editor-input-row\">\n <TextBox.Root style={{ width: \"100%\" }} className={hasError ? \"with-error\" : undefined}>\n <TextBox.Input\n id={inputId}\n ref={inputRef}\n aria-label={localizedStrings.newLabel}\n value={newLabelValue}\n onChange={(event) => {\n setNewLabelValue(event.target.value);\n setHasError(false);\n }}\n onKeyUp={(event) => {\n if (event.key === \"Enter\") {\n handleLabelChange();\n } else if (event.key === \"Escape\") {\n cancelLabelChange();\n }\n }}\n />\n </TextBox.Root>\n <IconButton icon={dismissSvg} label={localizedStrings.cancel} onClick={cancelLabelChange} />\n <IconButton icon={checkmarkSvg} label={localizedStrings.confirm} onClick={handleLabelChange} disabled={!canRename} />\n </div>\n {labelValidationHint !== undefined ? (\n <Description id={inputId} tone={hasError ? \"critical\" : \"neutral\"} style={{ display: \"flex\" }}>\n <Text variant=\"caption-lg\">{labelValidationHint}</Text>\n </Description>\n ) : undefined}\n </div>\n );\n}\n\nfunction injectActionVariant(actions: ReactNode[], variant: TreeActionBaseAttributes[\"variant\"]) {\n return actions\n .filter((action) => isValidElement<TreeActionBaseAttributes>(action))\n .map((action) => cloneElement<TreeActionBaseAttributes>(action, { variant }));\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/presentation-hierarchies-react",
3
- "version": "2.0.0-alpha.52",
3
+ "version": "2.0.0-alpha.53",
4
4
  "description": "React components based on `@itwin/presentation-hierarchies`",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -44,8 +44,8 @@
44
44
  "react-error-boundary": "^4.1.2",
45
45
  "rxjs": "^7.8.2",
46
46
  "@itwin/presentation-hierarchies": "^2.0.0-alpha.10",
47
- "@itwin/presentation-shared": "^2.0.0-alpha.6",
48
- "@itwin/unified-selection": "^1.6.6-alpha.0"
47
+ "@itwin/unified-selection": "^1.6.6-alpha.0",
48
+ "@itwin/presentation-shared": "^2.0.0-alpha.6"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@stratakit/bricks": "^0.5.4",