@djangocfg/ui-tools 2.1.415 → 2.1.416
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/dist/file-icon/index.d.cts +1 -1
- package/dist/file-icon/index.d.ts +1 -1
- package/dist/slots-ClRpIzoh.d.cts +88 -0
- package/dist/slots-ClRpIzoh.d.ts +88 -0
- package/dist/tree/index.cjs +1994 -276
- package/dist/tree/index.cjs.map +1 -1
- package/dist/tree/index.d.cts +717 -72
- package/dist/tree/index.d.ts +717 -72
- package/dist/tree/index.mjs +1984 -279
- package/dist/tree/index.mjs.map +1 -1
- package/package.json +10 -6
- package/src/tools/chat/README.md +111 -1
- package/src/tools/chat/composer/Composer.tsx +138 -17
- package/src/tools/chat/composer/ComposerRichTextarea.tsx +25 -0
- package/src/tools/chat/composer/index.ts +22 -0
- package/src/tools/chat/composer/slash/README.md +187 -0
- package/src/tools/chat/composer/slash/SlashHighlightTextarea.tsx +144 -0
- package/src/tools/chat/composer/slash/SlashMenu.tsx +142 -0
- package/src/tools/chat/composer/slash/SlashToken.tsx +57 -0
- package/src/tools/chat/composer/slash/index.ts +44 -0
- package/src/tools/chat/composer/slash/labels.ts +19 -0
- package/src/tools/chat/composer/slash/state.ts +168 -0
- package/src/tools/chat/composer/slash/types.ts +64 -0
- package/src/tools/chat/composer/slash/useSlashCommands.ts +204 -0
- package/src/tools/chat/composer/types.ts +8 -0
- package/src/tools/chat/shell/SuggestedPrompts.tsx +194 -0
- package/src/tools/chat/shell/index.ts +6 -0
- package/src/tools/data/Listbox/lazy.tsx +1 -1
- package/src/tools/data/Masonry/lazy.tsx +1 -1
- package/src/tools/data/Timeline/lazy.tsx +1 -1
- package/src/tools/data/Tree/FinderTree.tsx +42 -0
- package/src/tools/data/Tree/README.md +337 -208
- package/src/tools/data/Tree/TreeDndProvider.tsx +137 -0
- package/src/tools/data/Tree/TreeRoot.tsx +170 -55
- package/src/tools/data/Tree/__tests__/dnd.test.ts +160 -0
- package/src/tools/data/Tree/__tests__/keyboard.test.ts +137 -0
- package/src/tools/data/Tree/__tests__/renameUtils.test.ts +52 -0
- package/src/tools/data/Tree/__tests__/selection.test.ts +227 -0
- package/src/tools/data/Tree/components/TreeDropIndicator.tsx +65 -0
- package/src/tools/data/Tree/components/TreeEmptyArea.tsx +160 -0
- package/src/tools/data/Tree/components/TreeRenameInput.tsx +114 -0
- package/src/tools/data/Tree/components/TreeRow.tsx +92 -8
- package/src/tools/data/Tree/components/index.ts +6 -0
- package/src/tools/data/Tree/context/TreeContext.tsx +204 -363
- package/src/tools/data/Tree/context/TreeContextValue.ts +139 -0
- package/src/tools/data/Tree/context/async-children/collect-ids.ts +27 -0
- package/src/tools/data/Tree/context/async-children/index.ts +8 -0
- package/src/tools/data/Tree/context/async-children/use-async-children.ts +157 -0
- package/src/tools/data/Tree/context/clipboard/index.ts +4 -0
- package/src/tools/data/Tree/context/clipboard/use-clipboard.ts +115 -0
- package/src/tools/data/Tree/context/dnd/index.ts +8 -0
- package/src/tools/data/Tree/context/dnd/use-dnd.ts +194 -0
- package/src/tools/data/Tree/context/expansion/index.ts +4 -0
- package/src/tools/data/Tree/context/expansion/use-expansion.ts +55 -0
- package/src/tools/data/Tree/context/hooks.ts +68 -1
- package/src/tools/data/Tree/context/index.ts +3 -0
- package/src/tools/data/Tree/context/menu/builtin-actions.ts +357 -0
- package/src/tools/data/Tree/context/menu/index.ts +10 -0
- package/src/tools/data/Tree/context/menu/use-resolved-menu.ts +127 -0
- package/src/tools/data/Tree/context/persist/index.ts +4 -0
- package/src/tools/data/Tree/context/persist/use-persist-sync.ts +74 -0
- package/src/tools/data/Tree/context/rename/index.ts +4 -0
- package/src/tools/data/Tree/context/rename/use-rename.ts +113 -0
- package/src/tools/data/Tree/context/selection/index.ts +4 -0
- package/src/tools/data/Tree/context/selection/use-selection.ts +146 -0
- package/src/tools/data/Tree/context/state/index.ts +6 -0
- package/src/tools/data/Tree/context/state/initial.ts +41 -0
- package/src/tools/data/Tree/context/state/reducer.ts +76 -0
- package/src/tools/data/Tree/context/state/types.ts +46 -0
- package/src/tools/data/Tree/data/clipboard.ts +33 -0
- package/src/tools/data/Tree/data/dnd.ts +123 -0
- package/src/tools/data/Tree/data/finderShortcuts.ts +67 -0
- package/src/tools/data/Tree/data/index.ts +19 -0
- package/src/tools/data/Tree/data/renameUtils.ts +51 -0
- package/src/tools/data/Tree/data/selection.ts +157 -0
- package/src/tools/data/Tree/hooks/finder-hotkeys/build-ctx.ts +48 -0
- package/src/tools/data/Tree/hooks/finder-hotkeys/index.ts +8 -0
- package/src/tools/data/Tree/hooks/finder-hotkeys/use-tree-finder-hotkeys.ts +166 -0
- package/src/tools/data/Tree/hooks/index.ts +23 -4
- package/src/tools/data/Tree/hooks/keyboard/activation.ts +27 -0
- package/src/tools/data/Tree/hooks/keyboard/arrow-nav.ts +26 -0
- package/src/tools/data/Tree/hooks/keyboard/expand-collapse.ts +54 -0
- package/src/tools/data/Tree/hooks/keyboard/index.ts +10 -0
- package/src/tools/data/Tree/hooks/keyboard/types.ts +39 -0
- package/src/tools/data/Tree/hooks/keyboard/use-tree-keyboard.ts +196 -0
- package/src/tools/data/Tree/hooks/type-ahead/index.ts +5 -0
- package/src/tools/data/Tree/hooks/type-ahead/match-prefix.ts +42 -0
- package/src/tools/data/Tree/hooks/{useTreeTypeAhead.ts → type-ahead/use-tree-type-ahead.ts} +8 -19
- package/src/tools/data/Tree/index.tsx +25 -2
- package/src/tools/data/Tree/types/activation.ts +30 -0
- package/src/tools/data/Tree/types/adapter.ts +70 -0
- package/src/tools/data/Tree/types/index.ts +27 -0
- package/src/tools/data/Tree/types/labels.ts +97 -0
- package/src/tools/data/Tree/types/loader.ts +9 -0
- package/src/tools/data/Tree/types/node.ts +38 -0
- package/src/tools/data/Tree/types/root-props.ts +142 -0
- package/src/tools/data/Tree/types/selection.ts +3 -0
- package/src/tools/data/Tree/types/slots.ts +64 -0
- package/src/tools/forms/MarkdownEditor/MarkdownEditor.tsx +85 -0
- package/src/tools/forms/MarkdownEditor/index.ts +1 -0
- package/src/tools/forms/MarkdownEditor/lazy.tsx +6 -0
- package/src/tools/forms/MarkdownEditor/slash/SlashCommandNode.ts +162 -0
- package/src/tools/forms/MarkdownEditor/slash/index.ts +4 -0
- package/src/tools/forms/MarkdownEditor/slash/syncSlashNode.ts +97 -0
- package/src/tools/forms/MarkdownEditor/slash/types.ts +13 -0
- package/src/tools/forms/MarkdownEditor/styles.css +18 -0
- package/dist/types-j2vhn4Kv.d.cts +0 -241
- package/dist/types-j2vhn4Kv.d.ts +0 -241
- package/src/tools/data/Tree/hooks/useTreeKeyboard.ts +0 -171
- package/src/tools/data/Tree/types.ts +0 -217
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import {
|
|
3
|
+
import { T as TreeNode, b as TreeRowSlot } from '../slots-ClRpIzoh.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface ResolveFolderIconOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import {
|
|
3
|
+
import { T as TreeNode, b as TreeRowSlot } from '../slots-ClRpIzoh.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface ResolveFolderIconOptions {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReactNode, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type TreeItemId = string;
|
|
4
|
+
/** A single node in the consumer's tree data. Generic over your payload. */
|
|
5
|
+
interface TreeNode<T = unknown> {
|
|
6
|
+
id: TreeItemId;
|
|
7
|
+
data: T;
|
|
8
|
+
/** Inline children. Omit (and provide a `loadChildren`) for async loading. */
|
|
9
|
+
children?: TreeNode<T>[];
|
|
10
|
+
/**
|
|
11
|
+
* Set to `true` to mark a node as a folder even when its `children` array
|
|
12
|
+
* is empty (e.g. an unloaded async folder). Default: derived from
|
|
13
|
+
* `Array.isArray(children)`.
|
|
14
|
+
*/
|
|
15
|
+
isFolder?: boolean;
|
|
16
|
+
/** Disable interaction. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Internal flat-row representation used by the renderer + keyboard nav.
|
|
21
|
+
* Produced by `flattenTree`; consumed by `TreeRow`, the keyboard hook,
|
|
22
|
+
* and the type-ahead hook.
|
|
23
|
+
*/
|
|
24
|
+
interface FlatRow<T> {
|
|
25
|
+
node: TreeNode<T>;
|
|
26
|
+
level: number;
|
|
27
|
+
parentId: TreeItemId | null;
|
|
28
|
+
isFolder: boolean;
|
|
29
|
+
isExpanded: boolean;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
hasError: boolean;
|
|
32
|
+
/** 1-based position among visible siblings (for `aria-posinset`). */
|
|
33
|
+
posInSet: number;
|
|
34
|
+
/** Count of visible siblings sharing this row's parent (for `aria-setsize`). */
|
|
35
|
+
setSize: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface TreeRowRenderProps<T> {
|
|
39
|
+
node: TreeNode<T>;
|
|
40
|
+
level: number;
|
|
41
|
+
isSelected: boolean;
|
|
42
|
+
isExpanded: boolean;
|
|
43
|
+
isFocused: boolean;
|
|
44
|
+
isFolder: boolean;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
isMatchingSearch: boolean;
|
|
47
|
+
}
|
|
48
|
+
type TreeRowSlot<T> = (props: TreeRowRenderProps<T>) => ReactNode;
|
|
49
|
+
type TreeContextMenuSlot<T> = (props: TreeRowRenderProps<T>, trigger: ReactNode) => ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Declarative context-menu item. Pass `'separator'` (string) in place of an
|
|
52
|
+
* object to insert a `<ContextMenuSeparator />` between groups.
|
|
53
|
+
*
|
|
54
|
+
* For more advanced needs (submenus, checkbox items, custom JSX), drop down
|
|
55
|
+
* to `renderContextMenu` instead.
|
|
56
|
+
*/
|
|
57
|
+
interface TreeContextMenuAction<T> {
|
|
58
|
+
/** Stable React key. */
|
|
59
|
+
id: string;
|
|
60
|
+
label: ReactNode;
|
|
61
|
+
/** Lucide-style icon component. Rendered as `<icon className="size-4" />`. */
|
|
62
|
+
icon?: ComponentType<{
|
|
63
|
+
className?: string;
|
|
64
|
+
}>;
|
|
65
|
+
/** Right-aligned keyboard hint (e.g. `'⌘C'`, `'↵'`). Cosmetic. */
|
|
66
|
+
shortcut?: ReactNode;
|
|
67
|
+
/** Disable the item — still rendered, not selectable. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** Style as destructive (red). */
|
|
70
|
+
destructive?: boolean;
|
|
71
|
+
/** Click / Enter handler. Receives the row meta. */
|
|
72
|
+
onSelect: (props: TreeRowRenderProps<T>) => void;
|
|
73
|
+
}
|
|
74
|
+
type TreeContextMenuItem<T> = TreeContextMenuAction<T> | 'separator';
|
|
75
|
+
/**
|
|
76
|
+
* Context passed to a `contextMenuActions` resolver. `row` is the row the
|
|
77
|
+
* user right-clicked. `selectedNodes` is the multi-selection at the
|
|
78
|
+
* moment the menu opens — when the right-clicked row was not in the
|
|
79
|
+
* selection, Tree first switches selection to that single row, so
|
|
80
|
+
* `selectedNodes` always contains the right-clicked node.
|
|
81
|
+
*/
|
|
82
|
+
interface TreeContextMenuActionsContext<T> extends TreeRowRenderProps<T> {
|
|
83
|
+
/** Multi-selection at the moment the menu opens. Always non-empty. */
|
|
84
|
+
selectedNodes: TreeNode<T>[];
|
|
85
|
+
}
|
|
86
|
+
type TreeContextMenuActionsResolver<T> = (ctx: TreeContextMenuActionsContext<T>) => TreeContextMenuItem<T>[] | null | undefined;
|
|
87
|
+
|
|
88
|
+
export type { FlatRow as F, TreeNode as T, TreeItemId as a, TreeRowSlot as b, TreeContextMenuSlot as c, TreeContextMenuActionsResolver as d, TreeRowRenderProps as e, TreeContextMenuItem as f, TreeContextMenuAction as g, TreeContextMenuActionsContext as h };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReactNode, ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type TreeItemId = string;
|
|
4
|
+
/** A single node in the consumer's tree data. Generic over your payload. */
|
|
5
|
+
interface TreeNode<T = unknown> {
|
|
6
|
+
id: TreeItemId;
|
|
7
|
+
data: T;
|
|
8
|
+
/** Inline children. Omit (and provide a `loadChildren`) for async loading. */
|
|
9
|
+
children?: TreeNode<T>[];
|
|
10
|
+
/**
|
|
11
|
+
* Set to `true` to mark a node as a folder even when its `children` array
|
|
12
|
+
* is empty (e.g. an unloaded async folder). Default: derived from
|
|
13
|
+
* `Array.isArray(children)`.
|
|
14
|
+
*/
|
|
15
|
+
isFolder?: boolean;
|
|
16
|
+
/** Disable interaction. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Internal flat-row representation used by the renderer + keyboard nav.
|
|
21
|
+
* Produced by `flattenTree`; consumed by `TreeRow`, the keyboard hook,
|
|
22
|
+
* and the type-ahead hook.
|
|
23
|
+
*/
|
|
24
|
+
interface FlatRow<T> {
|
|
25
|
+
node: TreeNode<T>;
|
|
26
|
+
level: number;
|
|
27
|
+
parentId: TreeItemId | null;
|
|
28
|
+
isFolder: boolean;
|
|
29
|
+
isExpanded: boolean;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
hasError: boolean;
|
|
32
|
+
/** 1-based position among visible siblings (for `aria-posinset`). */
|
|
33
|
+
posInSet: number;
|
|
34
|
+
/** Count of visible siblings sharing this row's parent (for `aria-setsize`). */
|
|
35
|
+
setSize: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface TreeRowRenderProps<T> {
|
|
39
|
+
node: TreeNode<T>;
|
|
40
|
+
level: number;
|
|
41
|
+
isSelected: boolean;
|
|
42
|
+
isExpanded: boolean;
|
|
43
|
+
isFocused: boolean;
|
|
44
|
+
isFolder: boolean;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
isMatchingSearch: boolean;
|
|
47
|
+
}
|
|
48
|
+
type TreeRowSlot<T> = (props: TreeRowRenderProps<T>) => ReactNode;
|
|
49
|
+
type TreeContextMenuSlot<T> = (props: TreeRowRenderProps<T>, trigger: ReactNode) => ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Declarative context-menu item. Pass `'separator'` (string) in place of an
|
|
52
|
+
* object to insert a `<ContextMenuSeparator />` between groups.
|
|
53
|
+
*
|
|
54
|
+
* For more advanced needs (submenus, checkbox items, custom JSX), drop down
|
|
55
|
+
* to `renderContextMenu` instead.
|
|
56
|
+
*/
|
|
57
|
+
interface TreeContextMenuAction<T> {
|
|
58
|
+
/** Stable React key. */
|
|
59
|
+
id: string;
|
|
60
|
+
label: ReactNode;
|
|
61
|
+
/** Lucide-style icon component. Rendered as `<icon className="size-4" />`. */
|
|
62
|
+
icon?: ComponentType<{
|
|
63
|
+
className?: string;
|
|
64
|
+
}>;
|
|
65
|
+
/** Right-aligned keyboard hint (e.g. `'⌘C'`, `'↵'`). Cosmetic. */
|
|
66
|
+
shortcut?: ReactNode;
|
|
67
|
+
/** Disable the item — still rendered, not selectable. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** Style as destructive (red). */
|
|
70
|
+
destructive?: boolean;
|
|
71
|
+
/** Click / Enter handler. Receives the row meta. */
|
|
72
|
+
onSelect: (props: TreeRowRenderProps<T>) => void;
|
|
73
|
+
}
|
|
74
|
+
type TreeContextMenuItem<T> = TreeContextMenuAction<T> | 'separator';
|
|
75
|
+
/**
|
|
76
|
+
* Context passed to a `contextMenuActions` resolver. `row` is the row the
|
|
77
|
+
* user right-clicked. `selectedNodes` is the multi-selection at the
|
|
78
|
+
* moment the menu opens — when the right-clicked row was not in the
|
|
79
|
+
* selection, Tree first switches selection to that single row, so
|
|
80
|
+
* `selectedNodes` always contains the right-clicked node.
|
|
81
|
+
*/
|
|
82
|
+
interface TreeContextMenuActionsContext<T> extends TreeRowRenderProps<T> {
|
|
83
|
+
/** Multi-selection at the moment the menu opens. Always non-empty. */
|
|
84
|
+
selectedNodes: TreeNode<T>[];
|
|
85
|
+
}
|
|
86
|
+
type TreeContextMenuActionsResolver<T> = (ctx: TreeContextMenuActionsContext<T>) => TreeContextMenuItem<T>[] | null | undefined;
|
|
87
|
+
|
|
88
|
+
export type { FlatRow as F, TreeNode as T, TreeItemId as a, TreeRowSlot as b, TreeContextMenuSlot as c, TreeContextMenuActionsResolver as d, TreeRowRenderProps as e, TreeContextMenuItem as f, TreeContextMenuAction as g, TreeContextMenuActionsContext as h };
|