@andreyfedkovich/cozy-ui 1.0.12 → 1.0.13
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 +4 -0
- package/README.md +5 -0
- package/dist-lib/index.d.ts +6 -1
- package/dist-lib/ui-library.cjs.js +12 -12
- package/dist-lib/ui-library.cjs.js.map +1 -1
- package/dist-lib/ui-library.es.js +3535 -3531
- package/dist-lib/ui-library.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
Формат основан на [Keep a Changelog](https://keepachangelog.com/).
|
|
4
4
|
Версии соответствуют [Semantic Versioning](https://semver.org/) и git-тегам `v*`.
|
|
5
5
|
|
|
6
|
+
## Unreleased
|
|
7
|
+
|
|
8
|
+
- **feat:** `TreeDialogSelect` — проп `isNodeSelectable` для ограничения выбора узлов предикатом (компонуется с `leafConfirmOnly`).
|
|
9
|
+
|
|
6
10
|
## 1.0.8 - 2026-09-14
|
|
7
11
|
|
|
8
12
|
- **feat:** `TreeDialogSelect` — `mode="multiple"` с независимым выбором узлов через чекбоксы, тегами в триггере и `onDelete`; `resolveSelectedPath` работает для всех выбранных значений.
|
package/README.md
CHANGED
|
@@ -697,6 +697,8 @@ Hierarchical picker with lazy-loaded branches and search.
|
|
|
697
697
|
| `label` | `ReactNode` | Field label above the trigger. |
|
|
698
698
|
| `tooltipContent` | `ReactNode` | Help tooltip on the «?» icon next to the label. |
|
|
699
699
|
| `tooltipPopperClassName` | `string` | Extra class for the tooltip popper. |
|
|
700
|
+
| `leafConfirmOnly` | `boolean` | When true, only leaf nodes (`hasChildren !== true`) can be confirmed. |
|
|
701
|
+
| `isNodeSelectable` | `(node) => boolean` | When provided, nodes for which this returns `false` cannot be selected or confirmed. Composed with `leafConfirmOnly`. |
|
|
700
702
|
| `onDelete` | `(node) => void` | Multiple mode only — remove a selected node (tag click or uncheck in dialog). |
|
|
701
703
|
| `tagRender` | `(node) => ReactNode` | Multiple mode only — custom tag render in the trigger. |
|
|
702
704
|
| `resolveSelectedPath` | `(value) => Promise<TreeSearchResult>` | Resolves the path to the current value when the dialog opens; expands the tree, highlights the row, and scrolls it into view. In multiple mode, called for each selected value. |
|
|
@@ -713,12 +715,15 @@ import { TreeDialogSelect } from "@andreyfedkovich/cozy-ui";
|
|
|
713
715
|
searchNodes={async (search) => ({ matches: await searchTreeWithPath(search) })}
|
|
714
716
|
resolveSelectedPath={async (value) => ({ matches: await resolveTreePathById(value) })}
|
|
715
717
|
leafConfirmOnly
|
|
718
|
+
isNodeSelectable={(node) => node.meta?.selectable !== false}
|
|
716
719
|
onValueChange={(node) => console.log(node)}
|
|
717
720
|
/>;
|
|
718
721
|
```
|
|
719
722
|
|
|
720
723
|
With **`leafConfirmOnly`**, the confirm button in the dialog stays disabled until a row is selected and that node’s `hasChildren` is not strictly `true` (only leaves can be confirmed). Omit the prop to allow confirming any selected node, including branches.
|
|
721
724
|
|
|
725
|
+
With **`isNodeSelectable`**, you can block arbitrary nodes (e.g. by `meta`). A node is confirmable only when it passes both `leafConfirmOnly` (if set) and the predicate. Non-selectable rows are visually disabled; expanding branches still works.
|
|
726
|
+
|
|
722
727
|
With **`resolveSelectedPath`**, reopening the dialog with an existing `value` expands the tree to that node, pre-selects it in the dialog, and scrolls the row into view. Works independently of `searchNodes`. In **`mode="multiple"`**, paths for all selected values are resolved in parallel.
|
|
723
728
|
|
|
724
729
|
```tsx
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -1224,7 +1224,7 @@ export declare type TooltipTrigger = "hover" | "click";
|
|
|
1224
1224
|
/** `yyyy-MM-dd` for API / form state */
|
|
1225
1225
|
export declare const toYmdString: (d: Date) => string;
|
|
1226
1226
|
|
|
1227
|
-
export declare const TreeDialogSelect: <T, S extends string | number>({ value, placeholder, loadChildren: loadChildrenProp, loadNodes, searchNodes, resolveSelectedPath, onValueChange, onChange, onBlur, onFocus, onClear, onDelete, label, tooltipContent, tooltipPopperClassName, title, searchPlaceholder, selectButtonText, closeButtonText, confirmButtonText, debounceMs, disabled, error, suppressError, fieldMeta, showErrorPolicy, className, inputClassName, selectedOptionRender, nodeRender, tagRender, leafConfirmOnly, mode, }: TreeDialogSelectComponentProps<T, S>) => JSX.Element;
|
|
1227
|
+
export declare const TreeDialogSelect: <T, S extends string | number>({ value, placeholder, loadChildren: loadChildrenProp, loadNodes, searchNodes, resolveSelectedPath, onValueChange, onChange, onBlur, onFocus, onClear, onDelete, label, tooltipContent, tooltipPopperClassName, title, searchPlaceholder, selectButtonText, closeButtonText, confirmButtonText, debounceMs, disabled, error, suppressError, fieldMeta, showErrorPolicy, className, inputClassName, selectedOptionRender, nodeRender, tagRender, leafConfirmOnly, isNodeSelectable, mode, }: TreeDialogSelectComponentProps<T, S>) => JSX.Element;
|
|
1228
1228
|
|
|
1229
1229
|
declare type TreeDialogSelectComponentProps<T, S extends string | number> = TreeDialogSelectProps<T, S> & {
|
|
1230
1230
|
mode?: "single" | "multiple";
|
|
@@ -1279,6 +1279,11 @@ declare interface TreeDialogSelectShared<T, S extends string | number> extends V
|
|
|
1279
1279
|
* {@link TreeNode.hasChildren} is not strictly `true` (confirm leaf nodes only).
|
|
1280
1280
|
*/
|
|
1281
1281
|
leafConfirmOnly?: boolean;
|
|
1282
|
+
/**
|
|
1283
|
+
* When provided, nodes for which this returns `false` cannot be selected
|
|
1284
|
+
* (or confirmed). Composed with {@link leafConfirmOnly}.
|
|
1285
|
+
*/
|
|
1286
|
+
isNodeSelectable?: (node: TreeNode<T, S>) => boolean;
|
|
1282
1287
|
}
|
|
1283
1288
|
|
|
1284
1289
|
declare type TreeLoader<T, S extends string | number> = (params: TreeLoadParams<S>) => Promise<TreeLoadResult<T, S>>;
|