@djangocfg/ui-tools 2.1.413 → 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/dev/OpenapiViewer/components/DocsLayout/EndpointDoc/Responses/ResponseBody.tsx +1 -1
- package/src/tools/dev/OpenapiViewer/components/shared/ResponsePanel/PrettyView.tsx +1 -1
- 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/src/tools/index.ts +2 -2
- 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,217 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import type { TreeAppearance } from './data/appearance';
|
|
6
|
-
|
|
7
|
-
export type TreeItemId = string;
|
|
8
|
-
|
|
9
|
-
/** A single node in the consumer's tree data. Generic over your payload. */
|
|
10
|
-
export interface TreeNode<T = unknown> {
|
|
11
|
-
id: TreeItemId;
|
|
12
|
-
data: T;
|
|
13
|
-
/** Inline children. Omit (and provide a `loadChildren`) for async loading. */
|
|
14
|
-
children?: TreeNode<T>[];
|
|
15
|
-
/**
|
|
16
|
-
* Set to `true` to mark a node as a folder even when its `children` array
|
|
17
|
-
* is empty (e.g. an unloaded async folder). Default: derived from
|
|
18
|
-
* `Array.isArray(children)`.
|
|
19
|
-
*/
|
|
20
|
-
isFolder?: boolean;
|
|
21
|
-
/** Disable interaction. */
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface TreeLabels {
|
|
26
|
-
loading: string;
|
|
27
|
-
empty: string;
|
|
28
|
-
error: string;
|
|
29
|
-
searchPlaceholder: string;
|
|
30
|
-
searchMatches: (count: number) => string;
|
|
31
|
-
ariaLabel: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const DEFAULT_TREE_LABELS: TreeLabels = {
|
|
35
|
-
loading: 'Loading…',
|
|
36
|
-
empty: 'Nothing to show',
|
|
37
|
-
error: 'Failed to load',
|
|
38
|
-
searchPlaceholder: 'Search…',
|
|
39
|
-
searchMatches: (n) => `${n} match${n === 1 ? '' : 'es'}`,
|
|
40
|
-
ariaLabel: 'Tree',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type TreeSelectionMode = 'none' | 'single' | 'multiple';
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* How a node becomes "activated" (i.e. opened) on pointer interaction.
|
|
47
|
-
*
|
|
48
|
-
* - `'single-click'` (default): single click activates a leaf immediately;
|
|
49
|
-
* double-click also activates. Folders always toggle on single click.
|
|
50
|
-
* - `'double-click'`: single click only selects + focuses; double-click is
|
|
51
|
-
* required to activate. Mirrors classic file-manager behaviour.
|
|
52
|
-
* - `'single-click-preview'`: VSCode Explorer / Cursor behaviour. Single
|
|
53
|
-
* click activates with `{ preview: true }` (consumer renders a preview
|
|
54
|
-
* tab); double-click activates with `{ preview: false }` (pinned tab).
|
|
55
|
-
*
|
|
56
|
-
* Folders ignore this setting — they always toggle on single click and
|
|
57
|
-
* never call `onActivate`.
|
|
58
|
-
*/
|
|
59
|
-
export type TreeActivationMode =
|
|
60
|
-
| 'single-click'
|
|
61
|
-
| 'double-click'
|
|
62
|
-
| 'single-click-preview';
|
|
63
|
-
|
|
64
|
-
export interface TreeActivateOptions {
|
|
65
|
-
/**
|
|
66
|
-
* `true` when the activation came from a single click in
|
|
67
|
-
* `'single-click-preview'` mode. `false` for double-click and for
|
|
68
|
-
* non-preview modes. Consumers typically map this to a
|
|
69
|
-
* preview-tab vs pinned-tab distinction.
|
|
70
|
-
*/
|
|
71
|
-
preview: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Async loader: called the first time a folder is expanded with no inline
|
|
76
|
-
* `children`. Result is cached; concurrent expansions are de-duplicated.
|
|
77
|
-
*/
|
|
78
|
-
export type TreeLoadChildren<T> = (
|
|
79
|
-
node: TreeNode<T>,
|
|
80
|
-
) => Promise<TreeNode<T>[]>;
|
|
81
|
-
|
|
82
|
-
export interface TreeRowRenderProps<T> {
|
|
83
|
-
node: TreeNode<T>;
|
|
84
|
-
level: number;
|
|
85
|
-
isSelected: boolean;
|
|
86
|
-
isExpanded: boolean;
|
|
87
|
-
isFocused: boolean;
|
|
88
|
-
isFolder: boolean;
|
|
89
|
-
isLoading: boolean;
|
|
90
|
-
isMatchingSearch: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type TreeRowSlot<T> = (props: TreeRowRenderProps<T>) => ReactNode;
|
|
94
|
-
|
|
95
|
-
export type TreeContextMenuSlot<T> = (
|
|
96
|
-
props: TreeRowRenderProps<T>,
|
|
97
|
-
trigger: ReactNode,
|
|
98
|
-
) => ReactNode;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Declarative context-menu item. Pass `'separator'` (string) in place of an
|
|
102
|
-
* object to insert a `<ContextMenuSeparator />` between groups.
|
|
103
|
-
*
|
|
104
|
-
* For more advanced needs (submenus, checkbox items, custom JSX), drop down
|
|
105
|
-
* to `renderContextMenu` instead.
|
|
106
|
-
*/
|
|
107
|
-
export interface TreeContextMenuAction<T> {
|
|
108
|
-
/** Stable React key. */
|
|
109
|
-
id: string;
|
|
110
|
-
label: ReactNode;
|
|
111
|
-
/** Lucide-style icon component. Rendered as `<icon className="size-4" />`. */
|
|
112
|
-
icon?: React.ComponentType<{ className?: string }>;
|
|
113
|
-
/** Right-aligned keyboard hint (e.g. `'⌘C'`, `'↵'`). Cosmetic. */
|
|
114
|
-
shortcut?: ReactNode;
|
|
115
|
-
/** Disable the item — still rendered, not selectable. */
|
|
116
|
-
disabled?: boolean;
|
|
117
|
-
/** Style as destructive (red). */
|
|
118
|
-
destructive?: boolean;
|
|
119
|
-
/** Click / Enter handler. Receives the row meta. */
|
|
120
|
-
onSelect: (props: TreeRowRenderProps<T>) => void;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type TreeContextMenuItem<T> = TreeContextMenuAction<T> | 'separator';
|
|
124
|
-
|
|
125
|
-
export type TreeContextMenuActionsResolver<T> = (
|
|
126
|
-
props: TreeRowRenderProps<T>,
|
|
127
|
-
) => TreeContextMenuItem<T>[] | null | undefined;
|
|
128
|
-
|
|
129
|
-
export interface TreeRootProps<T> {
|
|
130
|
-
/** Root nodes. Top-level items are rendered directly (no synthetic root). */
|
|
131
|
-
data: TreeNode<T>[];
|
|
132
|
-
/** Returns the human-readable name for a node (used by search/type-ahead). */
|
|
133
|
-
getItemName: (node: TreeNode<T>) => string;
|
|
134
|
-
|
|
135
|
-
/** Async loader for folders without inline `children`. */
|
|
136
|
-
loadChildren?: TreeLoadChildren<T>;
|
|
137
|
-
|
|
138
|
-
/** Selection behaviour. Default: `'single'`. */
|
|
139
|
-
selectionMode?: TreeSelectionMode;
|
|
140
|
-
/** Pointer activation behaviour. Default: `'single-click'`. */
|
|
141
|
-
activationMode?: TreeActivationMode;
|
|
142
|
-
/** Initially expanded ids. */
|
|
143
|
-
initialExpandedIds?: TreeItemId[];
|
|
144
|
-
/** Initially selected ids. */
|
|
145
|
-
initialSelectedIds?: TreeItemId[];
|
|
146
|
-
/** Pixels of indent per nesting level. Default: 16. (Shortcut for `appearance.indent`.) */
|
|
147
|
-
indent?: number;
|
|
148
|
-
/** Cosmetic configuration: density, sizes, accent intensity, radius. */
|
|
149
|
-
appearance?: TreeAppearance;
|
|
150
|
-
|
|
151
|
-
/** Triggered when selection changes. */
|
|
152
|
-
onSelectionChange?: (selectedIds: TreeItemId[]) => void;
|
|
153
|
-
/** Triggered when expanded set changes. */
|
|
154
|
-
onExpansionChange?: (expandedIds: TreeItemId[]) => void;
|
|
155
|
-
/**
|
|
156
|
-
* Triggered when a leaf is activated (Enter / dblclick / click depending
|
|
157
|
-
* on `activationMode`). Folders never call this — they toggle instead.
|
|
158
|
-
*/
|
|
159
|
-
onActivate?: (node: TreeNode<T>, opts: TreeActivateOptions) => void;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Optional predicate. Nodes returning `false` (and their descendants) are
|
|
163
|
-
* not rendered and not searchable. Use this to hide dot-files, system
|
|
164
|
-
* entries, or anything else the consumer wants to filter out.
|
|
165
|
-
*/
|
|
166
|
-
filterNode?: (node: TreeNode<T>) => boolean;
|
|
167
|
-
|
|
168
|
-
/** Show built-in search input. Default: false. */
|
|
169
|
-
enableSearch?: boolean;
|
|
170
|
-
/** Type printable letters to jump to a matching name. Default: true. */
|
|
171
|
-
enableTypeAhead?: boolean;
|
|
172
|
-
/** Render vertical indent guides under expanded folders. Default: false. */
|
|
173
|
-
showIndentGuides?: boolean;
|
|
174
|
-
|
|
175
|
-
/** Custom row renderer. Falls back to the default <TreeRow />. */
|
|
176
|
-
renderRow?: TreeRowSlot<T>;
|
|
177
|
-
/** Replace default folder/file icon. */
|
|
178
|
-
renderIcon?: TreeRowSlot<T>;
|
|
179
|
-
/** Replace default label rendering. */
|
|
180
|
-
renderLabel?: TreeRowSlot<T>;
|
|
181
|
-
/** Right-side actions slot (per row). */
|
|
182
|
-
renderActions?: TreeRowSlot<T>;
|
|
183
|
-
/** Wrap each row in a context menu (right-click). Receives the row meta + trigger element. */
|
|
184
|
-
renderContextMenu?: TreeContextMenuSlot<T>;
|
|
185
|
-
/**
|
|
186
|
-
* Declarative right-click menu — short-form. Pass `(row) => [items]` and the
|
|
187
|
-
* Tree builds a `<ContextMenu>` for you with sensible defaults. Ignored if
|
|
188
|
-
* `renderContextMenu` is also set. Return `null`/`undefined`/`[]` to skip
|
|
189
|
-
* the menu for that row.
|
|
190
|
-
*/
|
|
191
|
-
contextMenuActions?: TreeContextMenuActionsResolver<T>;
|
|
192
|
-
|
|
193
|
-
/** Override built-in copy in your locale. */
|
|
194
|
-
labels?: Partial<TreeLabels>;
|
|
195
|
-
/** Persist expanded + (optional) selected ids in localStorage under this key. */
|
|
196
|
-
persistKey?: string;
|
|
197
|
-
/** Persist selection alongside expansion. Default: false. */
|
|
198
|
-
persistSelection?: boolean;
|
|
199
|
-
|
|
200
|
-
className?: string;
|
|
201
|
-
style?: React.CSSProperties;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** Internal flat-row representation used by the renderer + keyboard nav. */
|
|
205
|
-
export interface FlatRow<T> {
|
|
206
|
-
node: TreeNode<T>;
|
|
207
|
-
level: number;
|
|
208
|
-
parentId: TreeItemId | null;
|
|
209
|
-
isFolder: boolean;
|
|
210
|
-
isExpanded: boolean;
|
|
211
|
-
isLoading: boolean;
|
|
212
|
-
hasError: boolean;
|
|
213
|
-
/** 1-based position among visible siblings (for `aria-posinset`). */
|
|
214
|
-
posInSet: number;
|
|
215
|
-
/** Count of visible siblings sharing this row's parent (for `aria-setsize`). */
|
|
216
|
-
setSize: number;
|
|
217
|
-
}
|