hazo_ui 2.3.1 → 2.4.0
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/index.cjs +1698 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -1
- package/dist/index.d.ts +347 -1
- package/dist/index.js +1657 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { Node, Extension } from '@tiptap/core';
|
|
3
4
|
|
|
4
5
|
interface FilterField {
|
|
5
6
|
value: string;
|
|
@@ -162,4 +163,349 @@ interface HazoUiRteProps {
|
|
|
162
163
|
*/
|
|
163
164
|
declare const HazoUiRte: React.FC<HazoUiRteProps>;
|
|
164
165
|
|
|
165
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Types for HazoUiCommand - Command/Mention System
|
|
168
|
+
*
|
|
169
|
+
* Shared type definitions for command pills in text inputs with
|
|
170
|
+
* prefix-triggered command menus (e.g., @mentions, /commands, #tags).
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Individual command item that can be selected from the command menu
|
|
175
|
+
*/
|
|
176
|
+
interface CommandItem {
|
|
177
|
+
/** Unique identifier for this command (e.g., "user_123", "due_date") */
|
|
178
|
+
action: string;
|
|
179
|
+
/** Display label shown in the pill and dropdown (e.g., "John Doe", "Due Date") */
|
|
180
|
+
action_label: string;
|
|
181
|
+
/** Optional description shown in the dropdown */
|
|
182
|
+
action_description?: string;
|
|
183
|
+
/** Optional icon to display alongside the command */
|
|
184
|
+
icon?: React.ReactNode;
|
|
185
|
+
/** Optional group name for categorizing commands in the dropdown */
|
|
186
|
+
group?: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Configuration for a prefix trigger character
|
|
190
|
+
*/
|
|
191
|
+
interface PrefixConfig {
|
|
192
|
+
/** Trigger character (e.g., "/", "@", "#") */
|
|
193
|
+
char: string;
|
|
194
|
+
/** Available commands for this prefix */
|
|
195
|
+
commands: CommandItem[];
|
|
196
|
+
/** Allow free text entries that don't match existing commands */
|
|
197
|
+
allow_free_text?: boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Represents a command that has been inserted into the text
|
|
201
|
+
*/
|
|
202
|
+
interface InsertedCommand {
|
|
203
|
+
/** Unique identifier for this insertion (for tracking position) */
|
|
204
|
+
id: string;
|
|
205
|
+
/** The prefix character used (e.g., "@", "/") */
|
|
206
|
+
prefix: string;
|
|
207
|
+
/** The action identifier */
|
|
208
|
+
action: string;
|
|
209
|
+
/** The display label */
|
|
210
|
+
action_label: string;
|
|
211
|
+
/** Position in the plain text output */
|
|
212
|
+
position: number;
|
|
213
|
+
/** Length of the command string in plain text */
|
|
214
|
+
length: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Output format for text with commands
|
|
218
|
+
*/
|
|
219
|
+
interface CommandTextOutput {
|
|
220
|
+
/** Plain text with prefix + action format (e.g., "Hello @user_123 /due_date tomorrow") */
|
|
221
|
+
plain_text: string;
|
|
222
|
+
/** Display text with prefix + label format (e.g., "Hello @John Doe /Due Date tomorrow") */
|
|
223
|
+
display_text: string;
|
|
224
|
+
/** Array of all inserted commands with position info */
|
|
225
|
+
commands: InsertedCommand[];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Props for the command popover component
|
|
229
|
+
*/
|
|
230
|
+
interface CommandPopoverProps {
|
|
231
|
+
/** Whether the popover is open */
|
|
232
|
+
is_open: boolean;
|
|
233
|
+
/** Commands to display, filtered by current query */
|
|
234
|
+
commands: CommandItem[];
|
|
235
|
+
/** The current prefix being used */
|
|
236
|
+
prefix: string;
|
|
237
|
+
/** Current search/filter query */
|
|
238
|
+
query: string;
|
|
239
|
+
/** Currently selected index for keyboard navigation */
|
|
240
|
+
selected_index: number;
|
|
241
|
+
/** Position for the popover */
|
|
242
|
+
position: {
|
|
243
|
+
top: number;
|
|
244
|
+
left: number;
|
|
245
|
+
};
|
|
246
|
+
/** Called when query changes */
|
|
247
|
+
on_query_change: (query: string) => void;
|
|
248
|
+
/** Called when a command is selected */
|
|
249
|
+
on_select: (command: CommandItem) => void;
|
|
250
|
+
/** Called when the popover should close */
|
|
251
|
+
on_close: () => void;
|
|
252
|
+
/** Called when selection changes via keyboard */
|
|
253
|
+
on_selection_change: (index: number) => void;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Props for the command pill component
|
|
257
|
+
*/
|
|
258
|
+
interface CommandPillProps {
|
|
259
|
+
/** The prefix character */
|
|
260
|
+
prefix: string;
|
|
261
|
+
/** The action identifier */
|
|
262
|
+
action: string;
|
|
263
|
+
/** The display label */
|
|
264
|
+
action_label: string;
|
|
265
|
+
/** Unique ID for this pill instance */
|
|
266
|
+
id: string;
|
|
267
|
+
/** Whether the pill is currently selected in the editor */
|
|
268
|
+
selected?: boolean;
|
|
269
|
+
/** Pill style variant */
|
|
270
|
+
variant?: "default" | "outline" | "subtle";
|
|
271
|
+
/** Called when the pill is clicked (to open edit popover) */
|
|
272
|
+
on_click?: () => void;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Suggestion state passed from TipTap suggestion extension
|
|
276
|
+
*/
|
|
277
|
+
interface SuggestionState {
|
|
278
|
+
/** Whether suggestion mode is active */
|
|
279
|
+
is_active: boolean;
|
|
280
|
+
/** Current query string (text after prefix) */
|
|
281
|
+
query: string;
|
|
282
|
+
/** The prefix character that triggered this suggestion */
|
|
283
|
+
prefix: string;
|
|
284
|
+
/** Client rect for positioning the popover */
|
|
285
|
+
client_rect: (() => DOMRect | null) | null;
|
|
286
|
+
/** Commands available for this prefix */
|
|
287
|
+
commands: CommandItem[];
|
|
288
|
+
/** TipTap range for the suggestion */
|
|
289
|
+
range: {
|
|
290
|
+
from: number;
|
|
291
|
+
to: number;
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Props shared between HazoUiTextbox and HazoUiTextarea
|
|
296
|
+
*/
|
|
297
|
+
interface BaseCommandInputProps {
|
|
298
|
+
/** Controlled value - plain text with prefix + action format */
|
|
299
|
+
value?: string;
|
|
300
|
+
/** Default value for uncontrolled mode */
|
|
301
|
+
default_value?: string;
|
|
302
|
+
/** Prefix configurations for command triggers */
|
|
303
|
+
prefixes: PrefixConfig[];
|
|
304
|
+
/** Placeholder text */
|
|
305
|
+
placeholder?: string;
|
|
306
|
+
/** Whether the input is disabled */
|
|
307
|
+
disabled?: boolean;
|
|
308
|
+
/** Additional CSS classes */
|
|
309
|
+
className?: string;
|
|
310
|
+
/** Pill style variant */
|
|
311
|
+
pill_variant?: "default" | "outline" | "subtle";
|
|
312
|
+
/** Called when the content changes */
|
|
313
|
+
on_change?: (output: CommandTextOutput) => void;
|
|
314
|
+
/** Called when a command is inserted */
|
|
315
|
+
on_command_insert?: (command: CommandItem, prefix: string) => void;
|
|
316
|
+
/** Called when an existing command is changed */
|
|
317
|
+
on_command_change?: (old_command: InsertedCommand, new_command: CommandItem) => void;
|
|
318
|
+
/** Called when a command is removed */
|
|
319
|
+
on_command_remove?: (command: InsertedCommand) => void;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Props for HazoUiTextbox (single-line input)
|
|
323
|
+
*/
|
|
324
|
+
interface HazoUiTextboxProps extends BaseCommandInputProps {
|
|
325
|
+
/** Called when Enter is pressed */
|
|
326
|
+
on_submit?: (output: CommandTextOutput) => void;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Props for HazoUiTextarea (multi-line input)
|
|
330
|
+
*/
|
|
331
|
+
interface HazoUiTextareaProps extends BaseCommandInputProps {
|
|
332
|
+
/** Minimum height for the textarea */
|
|
333
|
+
min_height?: string;
|
|
334
|
+
/** Maximum height for the textarea */
|
|
335
|
+
max_height?: string;
|
|
336
|
+
/** Number of visible rows */
|
|
337
|
+
rows?: number;
|
|
338
|
+
/** Called when Cmd/Ctrl+Enter is pressed */
|
|
339
|
+
on_submit?: (output: CommandTextOutput) => void;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Context type for command editing
|
|
343
|
+
*/
|
|
344
|
+
interface CommandEditContext {
|
|
345
|
+
/** The command being edited */
|
|
346
|
+
command: InsertedCommand;
|
|
347
|
+
/** Position of the node in the document */
|
|
348
|
+
node_pos: number;
|
|
349
|
+
/** Client rect for positioning the edit popover */
|
|
350
|
+
rect: DOMRect;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Command Node Extension for TipTap
|
|
355
|
+
*
|
|
356
|
+
* Custom atomic node extension for command pills (mentions, slash commands, etc.).
|
|
357
|
+
* Commands are rendered as non-editable pills and serialize to prefix + action format.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
declare module "@tiptap/core" {
|
|
361
|
+
interface Commands<ReturnType> {
|
|
362
|
+
commandNode: {
|
|
363
|
+
/**
|
|
364
|
+
* Insert a command node
|
|
365
|
+
*/
|
|
366
|
+
insertCommand: (attrs: {
|
|
367
|
+
prefix: string;
|
|
368
|
+
action: string;
|
|
369
|
+
action_label: string;
|
|
370
|
+
variant?: "default" | "outline" | "subtle";
|
|
371
|
+
}) => ReturnType;
|
|
372
|
+
/**
|
|
373
|
+
* Update an existing command node by ID
|
|
374
|
+
*/
|
|
375
|
+
updateCommand: (id: string, attrs: {
|
|
376
|
+
action: string;
|
|
377
|
+
action_label: string;
|
|
378
|
+
}) => ReturnType;
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
declare const CommandNodeExtension: Node<any, any>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Command Suggestion Extension for TipTap
|
|
386
|
+
*
|
|
387
|
+
* Detects prefix characters and triggers the command popover for selection.
|
|
388
|
+
* Works with multiple configurable prefixes (e.g., @, /, #).
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Props for creating the suggestion extension
|
|
393
|
+
*/
|
|
394
|
+
interface CommandSuggestionConfig {
|
|
395
|
+
/** Prefix configurations */
|
|
396
|
+
prefixes: PrefixConfig[];
|
|
397
|
+
/** Callback when suggestion state changes */
|
|
398
|
+
on_suggestion_change: (state: SuggestionState | null) => void;
|
|
399
|
+
/** Callback to insert a command */
|
|
400
|
+
on_insert_command: (command: CommandItem, prefix: string, range: {
|
|
401
|
+
from: number;
|
|
402
|
+
to: number;
|
|
403
|
+
}) => void;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Create a combined suggestion extension for all configured prefixes
|
|
407
|
+
*/
|
|
408
|
+
declare const create_command_suggestion_extension: (config: CommandSuggestionConfig) => Extension[];
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Command Pill Component
|
|
412
|
+
*
|
|
413
|
+
* Standalone pill component for displaying commands outside the editor.
|
|
414
|
+
* Used in edit popovers and previews.
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* CommandPill - Displays a command as a styled badge/pill
|
|
419
|
+
*/
|
|
420
|
+
declare const CommandPill: React.FC<CommandPillProps>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Command Popover Component
|
|
424
|
+
*
|
|
425
|
+
* Dropdown menu for searching and selecting commands.
|
|
426
|
+
* Supports keyboard navigation and command grouping.
|
|
427
|
+
*
|
|
428
|
+
* Note: The query filtering is handled by TipTap's suggestion extension,
|
|
429
|
+
* so typing continues in the editor and filters the list automatically.
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* CommandPopover - Dropdown for command selection
|
|
434
|
+
*/
|
|
435
|
+
declare const CommandPopover: React.FC<CommandPopoverProps>;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* HazoUiCommand - Headless Command/Mention System
|
|
439
|
+
*
|
|
440
|
+
* Provides TipTap extensions and UI components for implementing
|
|
441
|
+
* command pills with prefix triggers (e.g., @mentions, /commands, #tags).
|
|
442
|
+
*
|
|
443
|
+
* This module exports:
|
|
444
|
+
* - CommandNodeExtension: TipTap node for rendering command pills
|
|
445
|
+
* - CommandPill: Standalone pill component
|
|
446
|
+
* - CommandPopover: Dropdown menu for command selection
|
|
447
|
+
* - create_command_suggestion_extension: Factory for prefix detection
|
|
448
|
+
* - Types for building custom command UIs
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Utility to parse plain text with commands into structured format
|
|
453
|
+
*
|
|
454
|
+
* @param text - Plain text with prefix + action format (e.g., "Hello @user_123")
|
|
455
|
+
* @param prefixes - Prefix configurations to detect
|
|
456
|
+
* @returns Parsed commands with positions
|
|
457
|
+
*/
|
|
458
|
+
declare const parse_commands_from_text: (text: string, prefixes: {
|
|
459
|
+
char: string;
|
|
460
|
+
commands: {
|
|
461
|
+
action: string;
|
|
462
|
+
action_label: string;
|
|
463
|
+
}[];
|
|
464
|
+
}[]) => {
|
|
465
|
+
action: string;
|
|
466
|
+
action_label: string;
|
|
467
|
+
prefix: string;
|
|
468
|
+
position: number;
|
|
469
|
+
length: number;
|
|
470
|
+
}[];
|
|
471
|
+
/**
|
|
472
|
+
* Convert parsed commands to TipTap content structure
|
|
473
|
+
*
|
|
474
|
+
* @param text - Plain text with prefix + action format
|
|
475
|
+
* @param prefixes - Prefix configurations
|
|
476
|
+
* @param variant - Pill variant style
|
|
477
|
+
* @returns TipTap JSON content structure
|
|
478
|
+
*/
|
|
479
|
+
declare const text_to_tiptap_content: (text: string, prefixes: {
|
|
480
|
+
char: string;
|
|
481
|
+
commands: {
|
|
482
|
+
action: string;
|
|
483
|
+
action_label: string;
|
|
484
|
+
}[];
|
|
485
|
+
}[], variant?: "default" | "outline" | "subtle") => Record<string, unknown>;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* HazoUiTextbox - Single-line Input with Command Support
|
|
489
|
+
*
|
|
490
|
+
* A TipTap-based single-line text input that supports prefix-triggered
|
|
491
|
+
* command pills (e.g., @mentions, /commands, #tags).
|
|
492
|
+
*/
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* HazoUiTextbox Component
|
|
496
|
+
*/
|
|
497
|
+
declare const HazoUiTextbox: React.FC<HazoUiTextboxProps>;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* HazoUiTextarea - Multi-line Input with Command Support
|
|
501
|
+
*
|
|
502
|
+
* A TipTap-based multi-line text input that supports prefix-triggered
|
|
503
|
+
* command pills (e.g., @mentions, /commands, #tags).
|
|
504
|
+
*/
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* HazoUiTextarea Component
|
|
508
|
+
*/
|
|
509
|
+
declare const HazoUiTextarea: React.FC<HazoUiTextareaProps>;
|
|
510
|
+
|
|
511
|
+
export { type BaseCommandInputProps, type CommandEditContext, type CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type FilterConfig, type FilterField, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte, type HazoUiRteProps, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, type InsertedCommand, type PrefixConfig, type RteAttachment, type RteOutput, type RteVariable, type SortConfig, type SortField, type SuggestionState, create_command_suggestion_extension, parse_commands_from_text, text_to_tiptap_content };
|