@opencxh/ui-kit 3.176.1 → 3.177.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.
@@ -46,6 +46,7 @@ export { Checkbox, type CheckboxProps } from './input/Checkbox';
46
46
  export { DatePicker, type DatePickerProps } from './input/DatePicker';
47
47
  export { type FolderDestination, FolderSelect, type FolderSelectProps } from './input/FolderSelect';
48
48
  export { ImageField, type ImageFieldProps } from './input/ImageField';
49
+ export { MentionComposer, type MentionComposerProps, type MentionComposerRef, type MentionPerson, } from './input/MentionComposer';
49
50
  export { SearchableTextField, type SearchableTextFieldProps } from './input/SearchableTextField';
50
51
  export { SearchField, type SearchFieldProps } from './input/SearchField';
51
52
  export { Select, type SelectOption, type SelectProps } from './input/Select';
@@ -0,0 +1,42 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Someone who can be mentioned. Structural on purpose — a domain `User` is assignable, and so
4
+ * is anything else with a name and an id (a team, an agent), without ui-kit knowing what it is.
5
+ */
6
+ export interface MentionPerson {
7
+ id: string;
8
+ name: string;
9
+ }
10
+ export interface MentionComposerProps {
11
+ /** Seed HTML, sanitised before it lands. Mention chips survive if they carry `data-mention-id`. */
12
+ initialContent?: string;
13
+ /** Plain text plus the ids of the chips still standing in it. */
14
+ onChange: (plainText: string, mentionIds: string[]) => void;
15
+ people: MentionPerson[];
16
+ placeholder?: string;
17
+ /** Cmd/Ctrl+Enter. Omitted means the shortcut does nothing. */
18
+ onSubmit?: () => void;
19
+ /**
20
+ * Focus on mount, desktop only. Off by default: a composer that is one tab of a detail
21
+ * page steals both the caret and the scroll position from whatever the reader was doing.
22
+ */
23
+ autoFocus?: boolean;
24
+ className?: string;
25
+ }
26
+ export interface MentionComposerRef {
27
+ insertText: (text: string) => void;
28
+ clear: () => void;
29
+ focus: () => void;
30
+ }
31
+ /**
32
+ * A one-line-or-more composer where `@` completes a person.
33
+ *
34
+ * Mentions are chips (`data-mention-id`), not text: they delete as one unit and survive being
35
+ * typed around, so the ids handed to `onChange` always match what the author still sees. That
36
+ * is why this is `contenteditable` and not a `<textarea>` — a textarea can only ever guess
37
+ * from the text whether a name is still a mention.
38
+ *
39
+ * Uncontrolled by design. The DOM holds the content; `onChange` reports it, and the ref is how
40
+ * a caller writes into it (a template, a draft) without a re-render fighting the caret.
41
+ */
42
+ export declare const MentionComposer: React.ForwardRefExoticComponent<MentionComposerProps & React.RefAttributes<MentionComposerRef>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/ui-kit",
3
- "version": "3.176.1",
3
+ "version": "3.177.0",
4
4
  "description": "Theme-aware UI component library for OpenCXH platform",
5
5
  "type": "module",
6
6
  "exports": {