@edux-design/tree-select 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -7,9 +7,9 @@ TreeSelect renders hierarchical data with expand/collapse controls, optional inl
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- pnpm add @edux-design/tree-select @edux-design/forms @edux-design/buttons @edux-design/icons @edux-design/tooltips @dnd-kit/core @dnd-kit/sortable
10
+ pnpm add @edux-design/tree-select @edux-design/forms @edux-design/buttons @edux-design/icons @edux-design/menus @edux-design/tooltips @dnd-kit/core @dnd-kit/sortable
11
11
  # or
12
- npm install @edux-design/tree-select @edux-design/forms @edux-design/buttons @edux-design/icons @edux-design/tooltips @dnd-kit/core @dnd-kit/sortable
12
+ npm install @edux-design/tree-select @edux-design/forms @edux-design/buttons @edux-design/icons @edux-design/menus @edux-design/tooltips @dnd-kit/core @dnd-kit/sortable
13
13
  ```
14
14
 
15
15
  Peer deps include `react@^19.1.0` and `react-dom@^19.1.0`.
@@ -125,6 +125,9 @@ Tree data to render. This component is controlled; updates are emitted through `
125
125
  ### `onDataChange` (function)
126
126
  Called with the updated tree when edits, add actions, or drag-and-drop reordering occur.
127
127
 
128
+ ### `onLabelChange` (function)
129
+ Called with `(id, nextLabel)` when a label edit is committed. When provided, label edits do not emit `onDataChange`.
130
+
128
131
  ### `allowDragAndDrop` (boolean, default `false`)
129
132
  Enables drag-and-drop. When `false`, drag handles are hidden and items cannot be reordered.
130
133
 
@@ -137,6 +140,33 @@ Enables inline label editing and add-item controls.
137
140
  ### `allowDelete` (boolean, default `false`)
138
141
  Shows a delete action for each item and removes the node (plus descendants).
139
142
 
143
+ ### `actionButtonsPosition` (`"start"` | `"end"`, default `"start"`)
144
+ Positions the action buttons within a row. `"end"` pushes the actions to the end of the row.
145
+
146
+ ### `renderAdditionalActionsMenu` (function)
147
+ Renders a kebab (more actions) menu per row. Return `null`/`undefined` to hide the menu for a given item.
148
+
149
+ ```jsx
150
+ import { MenuList, MenuItem } from "@edux-design/menus";
151
+
152
+ <TreeSelect
153
+ data={data}
154
+ renderAdditionalActionsMenu={({ id, node }) => (
155
+ <MenuList>
156
+ <MenuItem onClick={() => console.log("View", id)}>
157
+ View {node.label ?? id}
158
+ </MenuItem>
159
+ <MenuItem onClick={() => console.log("Duplicate", id)}>
160
+ Duplicate
161
+ </MenuItem>
162
+ </MenuList>
163
+ )}
164
+ />;
165
+ ```
166
+
167
+ ### `maxLabelLength` (number)
168
+ Limits label width by character count and truncates with an ellipsis when exceeded.
169
+
140
170
  ### `useChevron` (boolean, default `false`)
141
171
  Uses a chevron control for expand/collapse instead of the checkbox toggle.
142
172
 
@@ -155,20 +185,35 @@ Limits how deep new items can be added. For example, `maxDepth={3}` allows at mo
155
185
  ### `addChildTooltip` (string)
156
186
  Tooltip copy for the add-child button.
157
187
 
158
- ### `addChildTooltipByLevel` (string[])
159
- Tooltip copy for add-child, keyed by depth. Overrides `addChildTooltip` when provided.
160
-
161
188
  ### `addSiblingTooltip` (string)
162
189
  Tooltip copy for the add-sibling button.
163
190
 
164
- ### `addSiblingTooltipByLevel` (string[])
165
- Tooltip copy for add-sibling, keyed by depth. Overrides `addSiblingTooltip` when provided.
166
-
167
191
  ### `deleteTooltip` (string)
168
192
  Tooltip copy for the delete button.
169
193
 
170
- ### `deleteTooltipByLevel` (string[])
171
- Tooltip copy for delete, keyed by depth. Overrides `deleteTooltip` when provided.
194
+ ### `levelConfig` (object)
195
+ Per-level configuration for editing, actions, and tooltips. Use `default` for global settings and `levels` to override by depth.
196
+ Values in `levelConfig` override `isEditable`, `allowDelete`, and tooltip props for the matching depth.
197
+
198
+ ```js
199
+ levelConfig={{
200
+ default: {
201
+ editable: true,
202
+ actions: { addChild: true, addSibling: true, delete: false },
203
+ tooltips: {
204
+ addChild: "Add child",
205
+ addSibling: "Add sibling",
206
+ delete: "Delete item",
207
+ },
208
+ },
209
+ levels: {
210
+ 0: {
211
+ editable: false,
212
+ tooltips: { addChild: "Add chapter" },
213
+ },
214
+ },
215
+ }}
216
+ ```
172
217
 
173
218
  ---
174
219
 
@@ -181,6 +226,7 @@ Tooltip copy for delete, keyed by depth. Overrides `deleteTooltip` when provided
181
226
  - `defaultExpanded` only seeds the initial state; use `expanded` for controlled expansion.
182
227
  - When `expanded` is provided, `onExpandedChange` is called with the next set of expanded ids.
183
228
  - Deleting a node removes the entire subtree and clears any selected/expanded state for those ids.
229
+ - `levelConfig` can override editability, actions, and tooltips per depth.
184
230
  - Drag-and-drop supports reordering within a level and moving items between levels.
185
231
  - Drag handle alignment is set so child handles align under the parent toggle.
186
232
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDrag, isEditable, allowDelete, useChevron, maxDepth, addChildTooltip, addSiblingTooltip, deleteTooltip, addChildTooltipByLevel, addSiblingTooltipByLevel, deleteTooltipByLevel, defaultExpanded, expanded, onExpandedChange, }: {
3
+ declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDrag, isEditable, allowDelete, useChevron, actionButtonsPosition, maxLabelLength, maxDepth, addChildTooltip, addSiblingTooltip, deleteTooltip, onLabelChange, levelConfig, defaultExpanded, expanded, onExpandedChange, renderAdditionalActionsMenu, }: {
4
4
  data: any;
5
5
  onDataChange: any;
6
6
  allowDragAndDrop?: boolean;
@@ -8,16 +8,18 @@ declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDr
8
8
  isEditable?: boolean;
9
9
  allowDelete?: boolean;
10
10
  useChevron?: boolean;
11
+ actionButtonsPosition?: string;
12
+ maxLabelLength: any;
11
13
  maxDepth: any;
12
14
  addChildTooltip: any;
13
15
  addSiblingTooltip: any;
14
16
  deleteTooltip: any;
15
- addChildTooltipByLevel: any;
16
- addSiblingTooltipByLevel: any;
17
- deleteTooltipByLevel: any;
17
+ onLabelChange: any;
18
+ levelConfig: any;
18
19
  defaultExpanded: any;
19
20
  expanded: any;
20
21
  onExpandedChange: any;
22
+ renderAdditionalActionsMenu: any;
21
23
  }): react_jsx_runtime.JSX.Element;
22
24
 
23
25
  export { TreeSelect };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDrag, isEditable, allowDelete, useChevron, maxDepth, addChildTooltip, addSiblingTooltip, deleteTooltip, addChildTooltipByLevel, addSiblingTooltipByLevel, deleteTooltipByLevel, defaultExpanded, expanded, onExpandedChange, }: {
3
+ declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDrag, isEditable, allowDelete, useChevron, actionButtonsPosition, maxLabelLength, maxDepth, addChildTooltip, addSiblingTooltip, deleteTooltip, onLabelChange, levelConfig, defaultExpanded, expanded, onExpandedChange, renderAdditionalActionsMenu, }: {
4
4
  data: any;
5
5
  onDataChange: any;
6
6
  allowDragAndDrop?: boolean;
@@ -8,16 +8,18 @@ declare function TreeSelect({ data, onDataChange, allowDragAndDrop, allowMultiDr
8
8
  isEditable?: boolean;
9
9
  allowDelete?: boolean;
10
10
  useChevron?: boolean;
11
+ actionButtonsPosition?: string;
12
+ maxLabelLength: any;
11
13
  maxDepth: any;
12
14
  addChildTooltip: any;
13
15
  addSiblingTooltip: any;
14
16
  deleteTooltip: any;
15
- addChildTooltipByLevel: any;
16
- addSiblingTooltipByLevel: any;
17
- deleteTooltipByLevel: any;
17
+ onLabelChange: any;
18
+ levelConfig: any;
18
19
  defaultExpanded: any;
19
20
  expanded: any;
20
21
  onExpandedChange: any;
22
+ renderAdditionalActionsMenu: any;
21
23
  }): react_jsx_runtime.JSX.Element;
22
24
 
23
25
  export { TreeSelect };