@liveblocks/react-ui 2.25.0-aiprivatebeta4 → 2.25.0-aiprivatebeta6

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.
Files changed (199) hide show
  1. package/dist/_private/index.cjs +4 -0
  2. package/dist/_private/index.cjs.map +1 -1
  3. package/dist/_private/index.d.cts +31 -94
  4. package/dist/_private/index.d.ts +31 -94
  5. package/dist/_private/index.js +2 -0
  6. package/dist/_private/index.js.map +1 -1
  7. package/dist/components/AiChat.cjs +217 -0
  8. package/dist/components/AiChat.cjs.map +1 -0
  9. package/dist/components/AiChat.js +215 -0
  10. package/dist/components/AiChat.js.map +1 -0
  11. package/dist/components/Comment.cjs +2 -2
  12. package/dist/components/Comment.cjs.map +1 -1
  13. package/dist/components/Comment.js +1 -1
  14. package/dist/components/Comment.js.map +1 -1
  15. package/dist/components/Composer.cjs +1 -2
  16. package/dist/components/Composer.cjs.map +1 -1
  17. package/dist/components/Composer.js +1 -2
  18. package/dist/components/Composer.js.map +1 -1
  19. package/dist/components/internal/AiChatAssistantMessage.cjs +83 -124
  20. package/dist/components/internal/AiChatAssistantMessage.cjs.map +1 -1
  21. package/dist/components/internal/AiChatAssistantMessage.js +81 -122
  22. package/dist/components/internal/AiChatAssistantMessage.js.map +1 -1
  23. package/dist/components/internal/AiChatComposer.cjs +30 -266
  24. package/dist/components/internal/AiChatComposer.cjs.map +1 -1
  25. package/dist/components/internal/AiChatComposer.js +35 -267
  26. package/dist/components/internal/AiChatComposer.js.map +1 -1
  27. package/dist/components/internal/AiChatUserMessage.cjs +18 -168
  28. package/dist/components/internal/AiChatUserMessage.cjs.map +1 -1
  29. package/dist/components/internal/AiChatUserMessage.js +20 -170
  30. package/dist/components/internal/AiChatUserMessage.js.map +1 -1
  31. package/dist/constants.cjs +2 -0
  32. package/dist/constants.cjs.map +1 -1
  33. package/dist/constants.js +2 -1
  34. package/dist/constants.js.map +1 -1
  35. package/dist/icon.cjs +4 -0
  36. package/dist/icon.cjs.map +1 -1
  37. package/dist/icon.js +2 -0
  38. package/dist/icon.js.map +1 -1
  39. package/dist/icons/Copy.cjs +8 -9
  40. package/dist/icons/Copy.cjs.map +1 -1
  41. package/dist/icons/Copy.js +8 -9
  42. package/dist/icons/Copy.js.map +1 -1
  43. package/dist/icons/Retry.cjs +21 -0
  44. package/dist/icons/Retry.cjs.map +1 -0
  45. package/dist/icons/Retry.js +19 -0
  46. package/dist/icons/Retry.js.map +1 -0
  47. package/dist/icons/index.cjs +4 -0
  48. package/dist/icons/index.cjs.map +1 -1
  49. package/dist/icons/index.js +2 -0
  50. package/dist/icons/index.js.map +1 -1
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +32 -43
  54. package/dist/index.d.ts +32 -43
  55. package/dist/index.js +1 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/overrides.cjs +10 -10
  58. package/dist/overrides.cjs.map +1 -1
  59. package/dist/overrides.js +10 -10
  60. package/dist/overrides.js.map +1 -1
  61. package/dist/primitives/AiChatComposer/index.cjs +203 -0
  62. package/dist/primitives/AiChatComposer/index.cjs.map +1 -0
  63. package/dist/primitives/AiChatComposer/index.js +196 -0
  64. package/dist/primitives/AiChatComposer/index.js.map +1 -0
  65. package/dist/primitives/Comment/index.cjs +2 -2
  66. package/dist/primitives/Comment/index.cjs.map +1 -1
  67. package/dist/primitives/Comment/index.js +1 -1
  68. package/dist/primitives/Comment/index.js.map +1 -1
  69. package/dist/primitives/Composer/index.cjs +19 -14
  70. package/dist/primitives/Composer/index.cjs.map +1 -1
  71. package/dist/primitives/Composer/index.js +18 -13
  72. package/dist/primitives/Composer/index.js.map +1 -1
  73. package/dist/{slate → primitives/Composer/slate}/plugins/auto-formatting.cjs +3 -3
  74. package/dist/primitives/Composer/slate/plugins/auto-formatting.cjs.map +1 -0
  75. package/dist/{slate → primitives/Composer/slate}/plugins/auto-formatting.js +3 -3
  76. package/dist/primitives/Composer/slate/plugins/auto-formatting.js.map +1 -0
  77. package/dist/{slate → primitives/Composer/slate}/plugins/auto-links.cjs +7 -2
  78. package/dist/primitives/Composer/slate/plugins/auto-links.cjs.map +1 -0
  79. package/dist/{slate → primitives/Composer/slate}/plugins/auto-links.js +8 -3
  80. package/dist/primitives/Composer/slate/plugins/auto-links.js.map +1 -0
  81. package/dist/{slate → primitives/Composer/slate}/plugins/custom-links.cjs +8 -3
  82. package/dist/primitives/Composer/slate/plugins/custom-links.cjs.map +1 -0
  83. package/dist/{slate → primitives/Composer/slate}/plugins/custom-links.js +9 -4
  84. package/dist/primitives/Composer/slate/plugins/custom-links.js.map +1 -0
  85. package/dist/{slate → primitives/Composer/slate}/plugins/mentions.cjs +9 -10
  86. package/dist/primitives/Composer/slate/plugins/mentions.cjs.map +1 -0
  87. package/dist/{slate → primitives/Composer/slate}/plugins/mentions.js +6 -6
  88. package/dist/primitives/Composer/slate/plugins/mentions.js.map +1 -0
  89. package/dist/{slate → primitives/Composer/slate}/plugins/paste.cjs +1 -1
  90. package/dist/primitives/Composer/slate/plugins/paste.cjs.map +1 -0
  91. package/dist/{slate → primitives/Composer/slate}/plugins/paste.js +1 -1
  92. package/dist/primitives/Composer/slate/plugins/paste.js.map +1 -0
  93. package/dist/primitives/Composer/utils.cjs +4 -4
  94. package/dist/primitives/Composer/utils.cjs.map +1 -1
  95. package/dist/primitives/Composer/utils.js +4 -4
  96. package/dist/primitives/Composer/utils.js.map +1 -1
  97. package/dist/primitives/index.cjs +2 -5
  98. package/dist/primitives/index.cjs.map +1 -1
  99. package/dist/primitives/index.d.cts +33 -62
  100. package/dist/primitives/index.d.ts +33 -62
  101. package/dist/primitives/index.js +6 -5
  102. package/dist/primitives/index.js.map +1 -1
  103. package/dist/primitives/internal/{Collapsible.cjs → Collapsible/index.cjs} +23 -17
  104. package/dist/primitives/internal/Collapsible/index.cjs.map +1 -0
  105. package/dist/primitives/internal/{Collapsible.js → Collapsible/index.js} +23 -17
  106. package/dist/primitives/internal/Collapsible/index.js.map +1 -0
  107. package/dist/primitives/slate/plugins/empty-clear-formatting.cjs.map +1 -0
  108. package/dist/primitives/slate/plugins/empty-clear-formatting.js.map +1 -0
  109. package/dist/{slate → primitives/slate}/plugins/normalize.cjs +0 -5
  110. package/dist/primitives/slate/plugins/normalize.cjs.map +1 -0
  111. package/dist/{slate → primitives/slate}/plugins/normalize.js +0 -5
  112. package/dist/primitives/slate/plugins/normalize.js.map +1 -0
  113. package/dist/primitives/slate/utils/get-character.cjs.map +1 -0
  114. package/dist/primitives/slate/utils/get-character.js.map +1 -0
  115. package/dist/primitives/slate/utils/get-dom-range.cjs.map +1 -0
  116. package/dist/primitives/slate/utils/get-dom-range.js.map +1 -0
  117. package/dist/primitives/slate/utils/get-match-range.cjs.map +1 -0
  118. package/dist/primitives/slate/utils/get-match-range.js.map +1 -0
  119. package/dist/primitives/slate/utils/is-empty-string.cjs.map +1 -0
  120. package/dist/primitives/slate/utils/is-empty-string.js.map +1 -0
  121. package/dist/primitives/slate/utils/is-empty.cjs.map +1 -0
  122. package/dist/primitives/slate/utils/is-empty.js.map +1 -0
  123. package/dist/primitives/slate/utils/is-text.cjs.map +1 -0
  124. package/dist/primitives/slate/utils/is-text.js.map +1 -0
  125. package/dist/primitives/slate/utils/is-whitespace-character.cjs.map +1 -0
  126. package/dist/primitives/slate/utils/is-whitespace-character.js.map +1 -0
  127. package/dist/{slate → primitives/slate}/utils/marks.cjs +9 -9
  128. package/dist/primitives/slate/utils/marks.cjs.map +1 -0
  129. package/dist/{slate → primitives/slate}/utils/marks.js +9 -9
  130. package/dist/primitives/slate/utils/marks.js.map +1 -0
  131. package/dist/primitives/slate/utils/selection-contains-inlines.cjs.map +1 -0
  132. package/dist/primitives/slate/utils/selection-contains-inlines.js.map +1 -0
  133. package/dist/version.cjs +1 -1
  134. package/dist/version.js +1 -1
  135. package/package.json +4 -4
  136. package/src/styles/index.css +120 -133
  137. package/src/styles/utils.css +7 -2
  138. package/styles.css +1 -1
  139. package/styles.css.map +1 -1
  140. package/dist/components/AiChat/AiChat.cjs +0 -211
  141. package/dist/components/AiChat/AiChat.cjs.map +0 -1
  142. package/dist/components/AiChat/AiChat.js +0 -209
  143. package/dist/components/AiChat/AiChat.js.map +0 -1
  144. package/dist/primitives/Chat/Composer/index.cjs +0 -323
  145. package/dist/primitives/Chat/Composer/index.cjs.map +0 -1
  146. package/dist/primitives/Chat/Composer/index.js +0 -315
  147. package/dist/primitives/Chat/Composer/index.js.map +0 -1
  148. package/dist/primitives/internal/Collapsible.cjs.map +0 -1
  149. package/dist/primitives/internal/Collapsible.js.map +0 -1
  150. package/dist/slate/plugins/auto-formatting.cjs.map +0 -1
  151. package/dist/slate/plugins/auto-formatting.js.map +0 -1
  152. package/dist/slate/plugins/auto-links.cjs.map +0 -1
  153. package/dist/slate/plugins/auto-links.js.map +0 -1
  154. package/dist/slate/plugins/custom-links.cjs.map +0 -1
  155. package/dist/slate/plugins/custom-links.js.map +0 -1
  156. package/dist/slate/plugins/empty-clear-formatting.cjs.map +0 -1
  157. package/dist/slate/plugins/empty-clear-formatting.js.map +0 -1
  158. package/dist/slate/plugins/mentions.cjs.map +0 -1
  159. package/dist/slate/plugins/mentions.js.map +0 -1
  160. package/dist/slate/plugins/normalize.cjs.map +0 -1
  161. package/dist/slate/plugins/normalize.js.map +0 -1
  162. package/dist/slate/plugins/paste.cjs.map +0 -1
  163. package/dist/slate/plugins/paste.js.map +0 -1
  164. package/dist/slate/utils/get-character.cjs.map +0 -1
  165. package/dist/slate/utils/get-character.js.map +0 -1
  166. package/dist/slate/utils/get-dom-range.cjs.map +0 -1
  167. package/dist/slate/utils/get-dom-range.js.map +0 -1
  168. package/dist/slate/utils/get-match-range.cjs.map +0 -1
  169. package/dist/slate/utils/get-match-range.js.map +0 -1
  170. package/dist/slate/utils/is-empty-string.cjs.map +0 -1
  171. package/dist/slate/utils/is-empty-string.js.map +0 -1
  172. package/dist/slate/utils/is-empty.cjs.map +0 -1
  173. package/dist/slate/utils/is-empty.js.map +0 -1
  174. package/dist/slate/utils/is-text.cjs.map +0 -1
  175. package/dist/slate/utils/is-text.js.map +0 -1
  176. package/dist/slate/utils/is-whitespace-character.cjs.map +0 -1
  177. package/dist/slate/utils/is-whitespace-character.js.map +0 -1
  178. package/dist/slate/utils/marks.cjs.map +0 -1
  179. package/dist/slate/utils/marks.js.map +0 -1
  180. package/dist/slate/utils/selection-contains-inlines.cjs.map +0 -1
  181. package/dist/slate/utils/selection-contains-inlines.js.map +0 -1
  182. /package/dist/{slate → primitives/slate}/plugins/empty-clear-formatting.cjs +0 -0
  183. /package/dist/{slate → primitives/slate}/plugins/empty-clear-formatting.js +0 -0
  184. /package/dist/{slate → primitives/slate}/utils/get-character.cjs +0 -0
  185. /package/dist/{slate → primitives/slate}/utils/get-character.js +0 -0
  186. /package/dist/{slate → primitives/slate}/utils/get-dom-range.cjs +0 -0
  187. /package/dist/{slate → primitives/slate}/utils/get-dom-range.js +0 -0
  188. /package/dist/{slate → primitives/slate}/utils/get-match-range.cjs +0 -0
  189. /package/dist/{slate → primitives/slate}/utils/get-match-range.js +0 -0
  190. /package/dist/{slate → primitives/slate}/utils/is-empty-string.cjs +0 -0
  191. /package/dist/{slate → primitives/slate}/utils/is-empty-string.js +0 -0
  192. /package/dist/{slate → primitives/slate}/utils/is-empty.cjs +0 -0
  193. /package/dist/{slate → primitives/slate}/utils/is-empty.js +0 -0
  194. /package/dist/{slate → primitives/slate}/utils/is-text.cjs +0 -0
  195. /package/dist/{slate → primitives/slate}/utils/is-text.js +0 -0
  196. /package/dist/{slate → primitives/slate}/utils/is-whitespace-character.cjs +0 -0
  197. /package/dist/{slate → primitives/slate}/utils/is-whitespace-character.js +0 -0
  198. /package/dist/{slate → primitives/slate}/utils/selection-contains-inlines.cjs +0 -0
  199. /package/dist/{slate → primitives/slate}/utils/selection-contains-inlines.js +0 -0
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ComponentPropsWithoutRef, FormHTMLAttributes, FormEvent, HTMLAttributes, ButtonHTMLAttributes, ReactNode, ComponentType } from 'react';
2
+ import { ElementType, ComponentPropsWithoutRef, FormEvent, ReactNode, ComponentType } from 'react';
3
3
  import { CommentBody as CommentBody$1, CommentAttachment, CommentMixedAttachment } from '@liveblocks/core';
4
4
 
5
5
  type Direction = "ltr" | "rtl";
@@ -22,7 +22,7 @@ type ComposerBodyMarks = {
22
22
  [K in ComposerBodyMark]: boolean;
23
23
  };
24
24
 
25
- type FormProps = FormHTMLAttributes<HTMLFormElement> & {
25
+ interface AiChatComposerFormProps extends ComponentPropsWithSlot<"form"> {
26
26
  /**
27
27
  * The event handler called when a chat message is submitted.
28
28
  */
@@ -40,36 +40,8 @@ type FormProps = FormHTMLAttributes<HTMLFormElement> & {
40
40
  * The id of the chat the composer belongs to.
41
41
  */
42
42
  chatId: string;
43
- };
44
- /**
45
- * Surrounds the chat composer's content and handles submissions.
46
- *
47
- * @example
48
- * <Form onComposerSubmit={({ text }) => {}}>
49
- * <Editor />
50
- * <Submit />
51
- * </Form>
52
- */
53
- declare const Form: react.ForwardRefExoticComponent<FormHTMLAttributes<HTMLFormElement> & {
54
- /**
55
- * The event handler called when a chat message is submitted.
56
- */
57
- onComposerSubmit?: (message: {
58
- /**
59
- * The submitted message text.
60
- */
61
- text: string;
62
- }, event: FormEvent<HTMLFormElement>) => void;
63
- /**
64
- * Whether the composer is disabled.
65
- */
66
- disabled?: boolean;
67
- /**
68
- * The id of the chat the composer belongs to.
69
- */
70
- chatId: string;
71
- } & react.RefAttributes<HTMLFormElement>>;
72
- type EditorProps = Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
43
+ }
44
+ interface AiChatComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue"> {
73
45
  /**
74
46
  * The editor's initial value.
75
47
  */
@@ -86,47 +58,46 @@ type EditorProps = Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
86
58
  * Whether to focus the editor on mount.
87
59
  */
88
60
  autoFocus?: boolean;
89
- };
61
+ }
62
+
90
63
  /**
91
- * Displays the chat composer's editor.
64
+ * Surrounds the chat composer's content and handles submissions.
92
65
  *
93
66
  * @example
94
- * <Editor placeholder="Write a message…" />
67
+ * <AiChatComposer.Form onComposerSubmit={({ text }) => {}}>
68
+ * <AiChatComposer.Editor />
69
+ * <AiChatComposer.Submit />
70
+ * </AiChatComposer.Form>
95
71
  */
96
- declare const Editor: react.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
97
- /**
98
- * The editor's initial value.
99
- */
100
- defaultValue?: string;
101
- /**
102
- * The text to display when the editor is empty.
103
- */
104
- placeholder?: string;
105
- /**
106
- * Whether the editor is disabled.
107
- */
108
- disabled?: boolean;
109
- /**
110
- * Whether to focus the editor on mount.
111
- */
112
- autoFocus?: boolean;
113
- } & react.RefAttributes<HTMLDivElement>>;
114
- type SubmitProps = ButtonHTMLAttributes<HTMLButtonElement>;
72
+ declare const AiChatComposerForm: react.ForwardRefExoticComponent<AiChatComposerFormProps & react.RefAttributes<HTMLFormElement>>;
115
73
  /**
116
- * A button to submit a chat message.
74
+ * Displays the chat composer's editor.
117
75
  *
118
76
  * @example
119
- * <ChatComposer.Submit>Send</ChatComposer.Submit>
77
+ * <AiChatComposer.Editor placeholder="Write a message…" />
120
78
  */
121
- declare const Submit: react.ForwardRefExoticComponent<SubmitProps & react.RefAttributes<HTMLButtonElement>>;
122
- type AttachFilesProps = ButtonHTMLAttributes<HTMLButtonElement>;
79
+ declare const AiChatComposerEditor: react.ForwardRefExoticComponent<AiChatComposerEditorProps & react.RefAttributes<HTMLDivElement>>;
123
80
  /**
124
- * A button which opens a file picker to create attachments.
81
+ * A button to submit a chat message.
125
82
  *
126
83
  * @example
127
- * <Composer.AttachFiles>Attach files</Composer.AttachFiles>
84
+ * <AiChatComposer.Submit>Send</AiChatComposer.Submit>
128
85
  */
129
- declare const AttachFiles: react.ForwardRefExoticComponent<AttachFilesProps & react.RefAttributes<HTMLButtonElement>>;
86
+ declare const AiChatComposerSubmit: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
87
+
88
+ declare const index$2_AiChatComposerEditor: typeof AiChatComposerEditor;
89
+ declare const index$2_AiChatComposerForm: typeof AiChatComposerForm;
90
+ declare const index$2_AiChatComposerSubmit: typeof AiChatComposerSubmit;
91
+ declare namespace index$2 {
92
+ export {
93
+ index$2_AiChatComposerEditor as AiChatComposerEditor,
94
+ index$2_AiChatComposerForm as AiChatComposerForm,
95
+ index$2_AiChatComposerSubmit as AiChatComposerSubmit,
96
+ AiChatComposerEditor as Editor,
97
+ AiChatComposerForm as Form,
98
+ AiChatComposerSubmit as Submit,
99
+ };
100
+ }
130
101
 
131
102
  type CommentMentionProps = ComponentPropsWithSlot<"span">;
132
103
  type CommentBodyMentionProps = {
@@ -600,4 +571,4 @@ interface TimestampProps extends Omit<ComponentPropsWithSlot<"time">, "children"
600
571
  */
601
572
  declare const Timestamp: react.ForwardRefExoticComponent<TimestampProps & react.RefAttributes<HTMLTimeElement>>;
602
573
 
603
- export { AttachmentTooLargeError, AttachFiles as ChatComposerAttachFiles, AttachFilesProps as ChatComposerAttachFilesProps, Editor as ChatComposerEditor, EditorProps as ChatComposerEditorProps, Form as ChatComposerForm, FormProps as ChatComposerFormProps, Submit as ChatComposerSubmit, SubmitProps as ChatComposerSubmitProps, index$1 as Comment, CommentBodyComponents, CommentBodyLinkProps, CommentBodyMentionProps, CommentBodyProps, CommentLinkProps, CommentMentionProps, index as Composer, ComposerAttachFilesProps, ComposerAttachmentsDropAreaProps, ComposerBodyMark, ComposerBodyMarks, ComposerContext, ComposerEditorComponents, ComposerEditorFloatingToolbarProps, ComposerEditorLinkProps, ComposerEditorMentionProps, ComposerEditorMentionSuggestionsProps, ComposerEditorProps, ComposerFloatingToolbarProps, ComposerFormProps, ComposerLinkProps, ComposerMarkToggleProps, ComposerMentionProps, ComposerSubmitComment, ComposerSubmitProps, ComposerSuggestionsListItemProps, ComposerSuggestionsListProps, FileSize, FileSizeProps, Timestamp, TimestampProps, useComposer };
574
+ export { index$2 as AiChatComposer, AttachmentTooLargeError, index$1 as Comment, CommentBodyComponents, CommentBodyLinkProps, CommentBodyMentionProps, CommentBodyProps, CommentLinkProps, CommentMentionProps, index as Composer, ComposerAttachFilesProps, ComposerAttachmentsDropAreaProps, ComposerBodyMark, ComposerBodyMarks, ComposerContext, ComposerEditorComponents, ComposerEditorFloatingToolbarProps, ComposerEditorLinkProps, ComposerEditorMentionProps, ComposerEditorMentionSuggestionsProps, ComposerEditorProps, ComposerFloatingToolbarProps, ComposerFormProps, ComposerLinkProps, ComposerMarkToggleProps, ComposerMentionProps, ComposerSubmitComment, ComposerSubmitProps, ComposerSuggestionsListItemProps, ComposerSuggestionsListProps, FileSize, FileSizeProps, Timestamp, TimestampProps, useComposer };
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ComponentPropsWithoutRef, FormHTMLAttributes, FormEvent, HTMLAttributes, ButtonHTMLAttributes, ReactNode, ComponentType } from 'react';
2
+ import { ElementType, ComponentPropsWithoutRef, FormEvent, ReactNode, ComponentType } from 'react';
3
3
  import { CommentBody as CommentBody$1, CommentAttachment, CommentMixedAttachment } from '@liveblocks/core';
4
4
 
5
5
  type Direction = "ltr" | "rtl";
@@ -22,7 +22,7 @@ type ComposerBodyMarks = {
22
22
  [K in ComposerBodyMark]: boolean;
23
23
  };
24
24
 
25
- type FormProps = FormHTMLAttributes<HTMLFormElement> & {
25
+ interface AiChatComposerFormProps extends ComponentPropsWithSlot<"form"> {
26
26
  /**
27
27
  * The event handler called when a chat message is submitted.
28
28
  */
@@ -40,36 +40,8 @@ type FormProps = FormHTMLAttributes<HTMLFormElement> & {
40
40
  * The id of the chat the composer belongs to.
41
41
  */
42
42
  chatId: string;
43
- };
44
- /**
45
- * Surrounds the chat composer's content and handles submissions.
46
- *
47
- * @example
48
- * <Form onComposerSubmit={({ text }) => {}}>
49
- * <Editor />
50
- * <Submit />
51
- * </Form>
52
- */
53
- declare const Form: react.ForwardRefExoticComponent<FormHTMLAttributes<HTMLFormElement> & {
54
- /**
55
- * The event handler called when a chat message is submitted.
56
- */
57
- onComposerSubmit?: (message: {
58
- /**
59
- * The submitted message text.
60
- */
61
- text: string;
62
- }, event: FormEvent<HTMLFormElement>) => void;
63
- /**
64
- * Whether the composer is disabled.
65
- */
66
- disabled?: boolean;
67
- /**
68
- * The id of the chat the composer belongs to.
69
- */
70
- chatId: string;
71
- } & react.RefAttributes<HTMLFormElement>>;
72
- type EditorProps = Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
43
+ }
44
+ interface AiChatComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue"> {
73
45
  /**
74
46
  * The editor's initial value.
75
47
  */
@@ -86,47 +58,46 @@ type EditorProps = Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
86
58
  * Whether to focus the editor on mount.
87
59
  */
88
60
  autoFocus?: boolean;
89
- };
61
+ }
62
+
90
63
  /**
91
- * Displays the chat composer's editor.
64
+ * Surrounds the chat composer's content and handles submissions.
92
65
  *
93
66
  * @example
94
- * <Editor placeholder="Write a message…" />
67
+ * <AiChatComposer.Form onComposerSubmit={({ text }) => {}}>
68
+ * <AiChatComposer.Editor />
69
+ * <AiChatComposer.Submit />
70
+ * </AiChatComposer.Form>
95
71
  */
96
- declare const Editor: react.ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "defaultValue"> & {
97
- /**
98
- * The editor's initial value.
99
- */
100
- defaultValue?: string;
101
- /**
102
- * The text to display when the editor is empty.
103
- */
104
- placeholder?: string;
105
- /**
106
- * Whether the editor is disabled.
107
- */
108
- disabled?: boolean;
109
- /**
110
- * Whether to focus the editor on mount.
111
- */
112
- autoFocus?: boolean;
113
- } & react.RefAttributes<HTMLDivElement>>;
114
- type SubmitProps = ButtonHTMLAttributes<HTMLButtonElement>;
72
+ declare const AiChatComposerForm: react.ForwardRefExoticComponent<AiChatComposerFormProps & react.RefAttributes<HTMLFormElement>>;
115
73
  /**
116
- * A button to submit a chat message.
74
+ * Displays the chat composer's editor.
117
75
  *
118
76
  * @example
119
- * <ChatComposer.Submit>Send</ChatComposer.Submit>
77
+ * <AiChatComposer.Editor placeholder="Write a message…" />
120
78
  */
121
- declare const Submit: react.ForwardRefExoticComponent<SubmitProps & react.RefAttributes<HTMLButtonElement>>;
122
- type AttachFilesProps = ButtonHTMLAttributes<HTMLButtonElement>;
79
+ declare const AiChatComposerEditor: react.ForwardRefExoticComponent<AiChatComposerEditorProps & react.RefAttributes<HTMLDivElement>>;
123
80
  /**
124
- * A button which opens a file picker to create attachments.
81
+ * A button to submit a chat message.
125
82
  *
126
83
  * @example
127
- * <Composer.AttachFiles>Attach files</Composer.AttachFiles>
84
+ * <AiChatComposer.Submit>Send</AiChatComposer.Submit>
128
85
  */
129
- declare const AttachFiles: react.ForwardRefExoticComponent<AttachFilesProps & react.RefAttributes<HTMLButtonElement>>;
86
+ declare const AiChatComposerSubmit: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
87
+
88
+ declare const index$2_AiChatComposerEditor: typeof AiChatComposerEditor;
89
+ declare const index$2_AiChatComposerForm: typeof AiChatComposerForm;
90
+ declare const index$2_AiChatComposerSubmit: typeof AiChatComposerSubmit;
91
+ declare namespace index$2 {
92
+ export {
93
+ index$2_AiChatComposerEditor as AiChatComposerEditor,
94
+ index$2_AiChatComposerForm as AiChatComposerForm,
95
+ index$2_AiChatComposerSubmit as AiChatComposerSubmit,
96
+ AiChatComposerEditor as Editor,
97
+ AiChatComposerForm as Form,
98
+ AiChatComposerSubmit as Submit,
99
+ };
100
+ }
130
101
 
131
102
  type CommentMentionProps = ComponentPropsWithSlot<"span">;
132
103
  type CommentBodyMentionProps = {
@@ -600,4 +571,4 @@ interface TimestampProps extends Omit<ComponentPropsWithSlot<"time">, "children"
600
571
  */
601
572
  declare const Timestamp: react.ForwardRefExoticComponent<TimestampProps & react.RefAttributes<HTMLTimeElement>>;
602
573
 
603
- export { AttachmentTooLargeError, AttachFiles as ChatComposerAttachFiles, AttachFilesProps as ChatComposerAttachFilesProps, Editor as ChatComposerEditor, EditorProps as ChatComposerEditorProps, Form as ChatComposerForm, FormProps as ChatComposerFormProps, Submit as ChatComposerSubmit, SubmitProps as ChatComposerSubmitProps, index$1 as Comment, CommentBodyComponents, CommentBodyLinkProps, CommentBodyMentionProps, CommentBodyProps, CommentLinkProps, CommentMentionProps, index as Composer, ComposerAttachFilesProps, ComposerAttachmentsDropAreaProps, ComposerBodyMark, ComposerBodyMarks, ComposerContext, ComposerEditorComponents, ComposerEditorFloatingToolbarProps, ComposerEditorLinkProps, ComposerEditorMentionProps, ComposerEditorMentionSuggestionsProps, ComposerEditorProps, ComposerFloatingToolbarProps, ComposerFormProps, ComposerLinkProps, ComposerMarkToggleProps, ComposerMentionProps, ComposerSubmitComment, ComposerSubmitProps, ComposerSuggestionsListItemProps, ComposerSuggestionsListProps, FileSize, FileSizeProps, Timestamp, TimestampProps, useComposer };
574
+ export { index$2 as AiChatComposer, AttachmentTooLargeError, index$1 as Comment, CommentBodyComponents, CommentBodyLinkProps, CommentBodyMentionProps, CommentBodyProps, CommentLinkProps, CommentMentionProps, index as Composer, ComposerAttachFilesProps, ComposerAttachmentsDropAreaProps, ComposerBodyMark, ComposerBodyMarks, ComposerContext, ComposerEditorComponents, ComposerEditorFloatingToolbarProps, ComposerEditorLinkProps, ComposerEditorMentionProps, ComposerEditorMentionSuggestionsProps, ComposerEditorProps, ComposerFloatingToolbarProps, ComposerFormProps, ComposerLinkProps, ComposerMarkToggleProps, ComposerMentionProps, ComposerSubmitComment, ComposerSubmitProps, ComposerSuggestionsListItemProps, ComposerSuggestionsListProps, FileSize, FileSizeProps, Timestamp, TimestampProps, useComposer };
@@ -1,8 +1,9 @@
1
- export { AttachFiles as ChatComposerAttachFiles, Editor as ChatComposerEditor, Form as ChatComposerForm, Submit as ChatComposerSubmit } from './Chat/Composer/index.js';
2
- import * as index from './Comment/index.js';
3
- export { index as Comment };
4
- import * as index$1 from './Composer/index.js';
5
- export { index$1 as Composer };
1
+ import * as index from './AiChatComposer/index.js';
2
+ export { index as AiChatComposer };
3
+ import * as index$1 from './Comment/index.js';
4
+ export { index$1 as Comment };
5
+ import * as index$2 from './Composer/index.js';
6
+ export { index$2 as Composer };
6
7
  export { useComposer } from './Composer/contexts.js';
7
8
  export { AttachmentTooLargeError } from './Composer/utils.js';
8
9
  export { FileSize } from './FileSize.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -1,29 +1,34 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
+ var reactSlot = require('@radix-ui/react-slot');
4
5
  var react = require('react');
5
6
 
6
7
  const RootContext = react.createContext(null);
7
- const Root = react.forwardRef(function Root2({ open, onOpenChange, disabled = false, ...props }, forwardedRef) {
8
- const id = react.useId();
9
- return /* @__PURE__ */ jsxRuntime.jsx(RootContext.Provider, {
10
- value: { open, onOpenChange, disabled, contentId: id },
11
- children: /* @__PURE__ */ jsxRuntime.jsx("div", {
12
- ...props,
13
- ref: forwardedRef,
14
- "data-state": open ? "open" : "closed",
15
- "data-disabled": disabled ? "" : void 0
16
- })
17
- });
18
- });
8
+ const Root = react.forwardRef(
9
+ ({ open, onOpenChange, disabled = false, asChild, ...props }, forwardedRef) => {
10
+ const Component = asChild ? reactSlot.Slot : "div";
11
+ const id = react.useId();
12
+ return /* @__PURE__ */ jsxRuntime.jsx(RootContext.Provider, {
13
+ value: { open, onOpenChange, disabled, contentId: id },
14
+ children: /* @__PURE__ */ jsxRuntime.jsx(Component, {
15
+ ...props,
16
+ ref: forwardedRef,
17
+ "data-state": open ? "open" : "closed",
18
+ "data-disabled": disabled ? "" : void 0
19
+ })
20
+ });
21
+ }
22
+ );
19
23
  const Trigger = react.forwardRef(
20
- function Trigger2({ onClick, ...props }, forwardedRef) {
24
+ ({ onClick, asChild, ...props }, forwardedRef) => {
25
+ const Component = asChild ? reactSlot.Slot : "button";
21
26
  const context = react.useContext(RootContext);
22
27
  if (!context) {
23
28
  throw new Error("Collapsible.Trigger must be a descendant of Root");
24
29
  }
25
30
  const { open, disabled, contentId, onOpenChange } = context;
26
- return /* @__PURE__ */ jsxRuntime.jsx("button", {
31
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, {
27
32
  ...props,
28
33
  ref: forwardedRef,
29
34
  type: "button",
@@ -44,7 +49,8 @@ const Trigger = react.forwardRef(
44
49
  }
45
50
  );
46
51
  const Content = react.forwardRef(
47
- function Content2(props, forwardedRef) {
52
+ ({ asChild, ...props }, forwardedRef) => {
53
+ const Component = asChild ? reactSlot.Slot : "div";
48
54
  const rootContext = react.useContext(RootContext);
49
55
  const divRef = react.useRef(null);
50
56
  if (!rootContext)
@@ -82,7 +88,7 @@ const Content = react.forwardRef(
82
88
  react.useImperativeHandle(forwardedRef, () => {
83
89
  return divRef.current;
84
90
  }, []);
85
- return /* @__PURE__ */ jsxRuntime.jsx("div", {
91
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, {
86
92
  ...props,
87
93
  ref: divRef,
88
94
  "data-state": open ? "open" : "closed",
@@ -96,4 +102,4 @@ const Content = react.forwardRef(
96
102
  exports.Content = Content;
97
103
  exports.Root = Root;
98
104
  exports.Trigger = Trigger;
99
- //# sourceMappingURL=Collapsible.cjs.map
105
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/primitives/internal/Collapsible/index.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\n\nimport type { ContentProps, RootProps, TriggerProps } from \"./types\";\n\n/* -------------------------------------------------------------------------------------------------\n * Root\n * -----------------------------------------------------------------------------------------------*/\n\nconst RootContext = createContext<{\n open: boolean;\n onOpenChange(open: boolean): void;\n\n disabled: boolean;\n contentId: string;\n} | null>(null);\n\nexport const Root = forwardRef<HTMLDivElement, RootProps>(\n (\n { open, onOpenChange, disabled = false, asChild, ...props },\n forwardedRef\n ) => {\n const Component = asChild ? Slot : \"div\";\n const id = useId();\n\n return (\n <RootContext.Provider\n value={{ open, onOpenChange, disabled, contentId: id }}\n >\n <Component\n {...props}\n ref={forwardedRef}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n />\n </RootContext.Provider>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Trigger\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Trigger = forwardRef<HTMLButtonElement, TriggerProps>(\n ({ onClick, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"button\";\n const context = useContext(RootContext);\n\n if (!context) {\n throw new Error(\"Collapsible.Trigger must be a descendant of Root\");\n }\n\n const { open, disabled, contentId, onOpenChange } = context;\n\n return (\n <Component\n {...props}\n ref={forwardedRef}\n type=\"button\"\n aria-controls={contentId}\n aria-expanded={open || false}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n disabled={disabled}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (disabled) return;\n onOpenChange(!open);\n }}\n />\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Content\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Content = forwardRef<HTMLDivElement, ContentProps>(\n ({ asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"div\";\n const rootContext = useContext(RootContext);\n const divRef = useRef<HTMLDivElement>(null);\n\n if (!rootContext) throw new Error(\"Missing RootContext Provider\");\n\n const { open, onOpenChange, disabled, contentId } = rootContext;\n\n useEffect(() => {\n const element = divRef.current;\n if (element === null) return;\n\n const isHiddenUntilFoundSupported = \"onbeforematch\" in document.body;\n if (!isHiddenUntilFoundSupported) return;\n\n function handleBeforeMatch() {\n onOpenChange(true);\n }\n\n // https://developer.chrome.com/articles/hidden-until-found/\n element.addEventListener(\"beforematch\", handleBeforeMatch);\n return () => {\n element.removeEventListener(\"beforematch\", handleBeforeMatch);\n };\n }, [onOpenChange]);\n\n // Passing `string` to `hidden` in JSX is not currently supported: https://github.com/facebook/react/issues/24740\n useEffect(() => {\n const element = divRef.current;\n if (element === null) return;\n\n if (open) return;\n\n const isHiddenUntilFoundSupported = \"onbeforematch\" in document.body;\n if (!isHiddenUntilFoundSupported) return;\n\n element.setAttribute(\"hidden\", \"until-found\");\n return () => {\n element.removeAttribute(\"hidden\");\n };\n }, [open]);\n\n useImperativeHandle<\n HTMLDivElement | null,\n HTMLDivElement | null\n >(forwardedRef, () => {\n return divRef.current;\n }, []);\n\n return (\n <Component\n {...props}\n ref={divRef}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n id={contentId}\n hidden={!open}\n />\n );\n }\n);\n"],"names":["createContext","forwardRef","Slot","useId","jsx","useContext","useRef","useEffect","useImperativeHandle"],"mappings":";;;;;;AAiBA,MAAM,WAAA,GAAcA,oBAMV,IAAI,CAAA,CAAA;AAEP,MAAM,IAAO,GAAAC,gBAAA;AAAA,EAClB,CACE,EAAE,IAAM,EAAA,YAAA,EAAc,WAAW,KAAO,EAAA,OAAA,EAAA,GAAY,KAAM,EAAA,EAC1D,YACG,KAAA;AACH,IAAM,MAAA,SAAA,GAAY,UAAUC,cAAO,GAAA,KAAA,CAAA;AACnC,IAAA,MAAM,KAAKC,WAAM,EAAA,CAAA;AAEjB,IACE,uBAA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AAA,OAAA,CAAA;AACvB,MAAA,IAAI,OAAY,KAAA,IAAA;AAAM,QAAA,OAAA;AAEtB,MAAI,IAAA,IAAA;AAAM,QAAA,OAAA;AAEV,MAAM,MAAA,2BAAA,GAA8B,mBAAmB,QAAS,CAAA,IAAA,CAAA;AAChE,MAAA,IAAI,CAAC,2BAAA;AAA6B,QAAA,OAAA;AAElC,MAAQ,OAAA,CAAA,YAAA,CAAa,UAAU,aAAa,CAAA,CAAA;AAC5C,MAAA,OAAO,MAAM;AACX,QAAA,OAAA,CAAQ,gBAAgB,QAAQ,CAAA,CAAA;AAAA,OAClC,CAAA;AAAA,KACF,EAAG,CAAC,IAAI,CAAC,CAAA,CAAA;AAET,IAAAC,yBAAA,CAGE,cAAc,MAAM;AACpB,MAAA,OAAO,MAAO,CAAA,OAAA,CAAA;AAAA,KAChB,EAAG,EAAE,CAAA,CAAA;AAEL,IAAA,uBACGJ,cAAA,CAAA,SAAA,EAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,GAAK,EAAA,MAAA;AAAA,MACL,YAAA,EAAY,OAAO,MAAS,GAAA,QAAA;AAAA,MAC5B,eAAA,EAAe,WAAW,EAAK,GAAA,KAAA,CAAA;AAAA,MAC/B,EAAI,EAAA,SAAA;AAAA,MACJ,QAAQ,CAAC,IAAA;AAAA,KACX,CAAA,CAAA;AAAA,GAEJ;AACF;;;;;;"}
@@ -1,27 +1,32 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
+ import { Slot } from '@radix-ui/react-slot';
2
3
  import { createContext, forwardRef, useId, useContext, useRef, useEffect, useImperativeHandle } from 'react';
3
4
 
4
5
  const RootContext = createContext(null);
5
- const Root = forwardRef(function Root2({ open, onOpenChange, disabled = false, ...props }, forwardedRef) {
6
- const id = useId();
7
- return /* @__PURE__ */ jsx(RootContext.Provider, {
8
- value: { open, onOpenChange, disabled, contentId: id },
9
- children: /* @__PURE__ */ jsx("div", {
10
- ...props,
11
- ref: forwardedRef,
12
- "data-state": open ? "open" : "closed",
13
- "data-disabled": disabled ? "" : void 0
14
- })
15
- });
16
- });
6
+ const Root = forwardRef(
7
+ ({ open, onOpenChange, disabled = false, asChild, ...props }, forwardedRef) => {
8
+ const Component = asChild ? Slot : "div";
9
+ const id = useId();
10
+ return /* @__PURE__ */ jsx(RootContext.Provider, {
11
+ value: { open, onOpenChange, disabled, contentId: id },
12
+ children: /* @__PURE__ */ jsx(Component, {
13
+ ...props,
14
+ ref: forwardedRef,
15
+ "data-state": open ? "open" : "closed",
16
+ "data-disabled": disabled ? "" : void 0
17
+ })
18
+ });
19
+ }
20
+ );
17
21
  const Trigger = forwardRef(
18
- function Trigger2({ onClick, ...props }, forwardedRef) {
22
+ ({ onClick, asChild, ...props }, forwardedRef) => {
23
+ const Component = asChild ? Slot : "button";
19
24
  const context = useContext(RootContext);
20
25
  if (!context) {
21
26
  throw new Error("Collapsible.Trigger must be a descendant of Root");
22
27
  }
23
28
  const { open, disabled, contentId, onOpenChange } = context;
24
- return /* @__PURE__ */ jsx("button", {
29
+ return /* @__PURE__ */ jsx(Component, {
25
30
  ...props,
26
31
  ref: forwardedRef,
27
32
  type: "button",
@@ -42,7 +47,8 @@ const Trigger = forwardRef(
42
47
  }
43
48
  );
44
49
  const Content = forwardRef(
45
- function Content2(props, forwardedRef) {
50
+ ({ asChild, ...props }, forwardedRef) => {
51
+ const Component = asChild ? Slot : "div";
46
52
  const rootContext = useContext(RootContext);
47
53
  const divRef = useRef(null);
48
54
  if (!rootContext)
@@ -80,7 +86,7 @@ const Content = forwardRef(
80
86
  useImperativeHandle(forwardedRef, () => {
81
87
  return divRef.current;
82
88
  }, []);
83
- return /* @__PURE__ */ jsx("div", {
89
+ return /* @__PURE__ */ jsx(Component, {
84
90
  ...props,
85
91
  ref: divRef,
86
92
  "data-state": open ? "open" : "closed",
@@ -92,4 +98,4 @@ const Content = forwardRef(
92
98
  );
93
99
 
94
100
  export { Content, Root, Trigger };
95
- //# sourceMappingURL=Collapsible.js.map
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/primitives/internal/Collapsible/index.tsx"],"sourcesContent":["import { Slot } from \"@radix-ui/react-slot\";\nimport {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\n\nimport type { ContentProps, RootProps, TriggerProps } from \"./types\";\n\n/* -------------------------------------------------------------------------------------------------\n * Root\n * -----------------------------------------------------------------------------------------------*/\n\nconst RootContext = createContext<{\n open: boolean;\n onOpenChange(open: boolean): void;\n\n disabled: boolean;\n contentId: string;\n} | null>(null);\n\nexport const Root = forwardRef<HTMLDivElement, RootProps>(\n (\n { open, onOpenChange, disabled = false, asChild, ...props },\n forwardedRef\n ) => {\n const Component = asChild ? Slot : \"div\";\n const id = useId();\n\n return (\n <RootContext.Provider\n value={{ open, onOpenChange, disabled, contentId: id }}\n >\n <Component\n {...props}\n ref={forwardedRef}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n />\n </RootContext.Provider>\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Trigger\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Trigger = forwardRef<HTMLButtonElement, TriggerProps>(\n ({ onClick, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"button\";\n const context = useContext(RootContext);\n\n if (!context) {\n throw new Error(\"Collapsible.Trigger must be a descendant of Root\");\n }\n\n const { open, disabled, contentId, onOpenChange } = context;\n\n return (\n <Component\n {...props}\n ref={forwardedRef}\n type=\"button\"\n aria-controls={contentId}\n aria-expanded={open || false}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n disabled={disabled}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n if (disabled) return;\n onOpenChange(!open);\n }}\n />\n );\n }\n);\n\n/* -------------------------------------------------------------------------------------------------\n * Content\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Content = forwardRef<HTMLDivElement, ContentProps>(\n ({ asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"div\";\n const rootContext = useContext(RootContext);\n const divRef = useRef<HTMLDivElement>(null);\n\n if (!rootContext) throw new Error(\"Missing RootContext Provider\");\n\n const { open, onOpenChange, disabled, contentId } = rootContext;\n\n useEffect(() => {\n const element = divRef.current;\n if (element === null) return;\n\n const isHiddenUntilFoundSupported = \"onbeforematch\" in document.body;\n if (!isHiddenUntilFoundSupported) return;\n\n function handleBeforeMatch() {\n onOpenChange(true);\n }\n\n // https://developer.chrome.com/articles/hidden-until-found/\n element.addEventListener(\"beforematch\", handleBeforeMatch);\n return () => {\n element.removeEventListener(\"beforematch\", handleBeforeMatch);\n };\n }, [onOpenChange]);\n\n // Passing `string` to `hidden` in JSX is not currently supported: https://github.com/facebook/react/issues/24740\n useEffect(() => {\n const element = divRef.current;\n if (element === null) return;\n\n if (open) return;\n\n const isHiddenUntilFoundSupported = \"onbeforematch\" in document.body;\n if (!isHiddenUntilFoundSupported) return;\n\n element.setAttribute(\"hidden\", \"until-found\");\n return () => {\n element.removeAttribute(\"hidden\");\n };\n }, [open]);\n\n useImperativeHandle<\n HTMLDivElement | null,\n HTMLDivElement | null\n >(forwardedRef, () => {\n return divRef.current;\n }, []);\n\n return (\n <Component\n {...props}\n ref={divRef}\n data-state={open ? \"open\" : \"closed\"}\n data-disabled={disabled ? \"\" : undefined}\n id={contentId}\n hidden={!open}\n />\n );\n }\n);\n"],"names":[],"mappings":";;;;AAiBA,MAAM,WAAA,GAAc,cAMV,IAAI,CAAA,CAAA;AAEP,MAAM,IAAO,GAAA,UAAA;AAAA,EAClB,CACE,EAAE,IAAM,EAAA,YAAA,EAAc,WAAW,KAAO,EAAA,OAAA,EAAA,GAAY,KAAM,EAAA,EAC1D,YACG,KAAA;AACH,IAAM,MAAA,SAAA,GAAY,UAAU,IAAO,GAAA,KAAA,CAAA;AACnC,IAAA,MAAM,KAAK,KAAM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AAU,MAAO,CAAA,OAAA,CAAA;AACvB,MAAA,IAAI,OAAY,KAAA,IAAA;AAAM,QAAA,OAAA;AAEtB,MAAI,IAAA,IAAA;AAAM,QAAA,OAAA;AAEV,MAAM,MAAA,2BAAA,GAA8B,mBAAmB,QAAS,CAAA,IAAA,CAAA;AAChE,MAAA,IAAI,CAAC,2BAAA;AAA6B,QAAA,OAAA;AAElC,MAAQ,OAAA,CAAA,YAAA,CAAa,UAAU,aAAa,CAAA,CAAA;AAC5C,MAAA,OAAO,MAAM;AACX,QAAA,OAAA,CAAQ,gBAAgB,QAAQ,CAAA,CAAA;AAAA,OAClC,CAAA;AAAA,KACF,EAAG,CAAC,IAAI,CAAC,CAAA,CAAA;AAET,IAAA,mBAAA,CAGE,cAAc,MAAM;AACpB,MAAA,OAAO,MAAO,CAAA,OAAA,CAAA;AAAA,KAChB,EAAG,EAAE,CAAA,CAAA;AAEL,IAAA,uBACG,GAAA,CAAA,SAAA,EAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,GAAK,EAAA,MAAA;AAAA,MACL,YAAA,EAAY,OAAO,MAAS,GAAA,QAAA;AAAA,MAC5B,eAAA,EAAe,WAAW,EAAK,GAAA,KAAA,CAAA;AAAA,MAC/B,EAAI,EAAA,SAAA;AAAA,MACJ,QAAQ,CAAC,IAAA;AAAA,KACX,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-clear-formatting.cjs","sources":["../../../../src/primitives/slate/plugins/empty-clear-formatting.ts"],"sourcesContent":["import type { Editor as SlateEditor } from \"slate\";\n\nimport { isEmpty } from \"../utils/is-empty\";\nimport { removeMarks } from \"../utils/marks\";\n\n// This plugins clears formatting on empty blocks\n// https://github.com/ianstormtaylor/slate/issues/2908\nexport function withEmptyClearFormatting<T extends SlateEditor>(editor: T): T {\n const { onChange } = editor;\n\n editor.onChange = (options) => {\n if (isEmpty(editor, editor.children)) {\n removeMarks(editor);\n }\n\n onChange(options);\n };\n\n return editor;\n}\n"],"names":["isEmpty","removeMarks"],"mappings":";;;;;AAOO,SAAS,yBAAgD,MAAc,EAAA;AAC5E,EAAM,MAAA,EAAE,UAAa,GAAA,MAAA,CAAA;AAErB,EAAO,MAAA,CAAA,QAAA,GAAW,CAAC,OAAY,KAAA;AAC7B,IAAA,IAAIA,eAAQ,CAAA,MAAA,EAAQ,MAAO,CAAA,QAAQ,CAAG,EAAA;AACpC,MAAAC,iBAAA,CAAY,MAAM,CAAA,CAAA;AAAA,KACpB;AAEA,IAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AAAA,GAClB,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-clear-formatting.js","sources":["../../../../src/primitives/slate/plugins/empty-clear-formatting.ts"],"sourcesContent":["import type { Editor as SlateEditor } from \"slate\";\n\nimport { isEmpty } from \"../utils/is-empty\";\nimport { removeMarks } from \"../utils/marks\";\n\n// This plugins clears formatting on empty blocks\n// https://github.com/ianstormtaylor/slate/issues/2908\nexport function withEmptyClearFormatting<T extends SlateEditor>(editor: T): T {\n const { onChange } = editor;\n\n editor.onChange = (options) => {\n if (isEmpty(editor, editor.children)) {\n removeMarks(editor);\n }\n\n onChange(options);\n };\n\n return editor;\n}\n"],"names":[],"mappings":";;;AAOO,SAAS,yBAAgD,MAAc,EAAA;AAC5E,EAAM,MAAA,EAAE,UAAa,GAAA,MAAA,CAAA;AAErB,EAAO,MAAA,CAAA,QAAA,GAAW,CAAC,OAAY,KAAA;AAC7B,IAAA,IAAI,OAAQ,CAAA,MAAA,EAAQ,MAAO,CAAA,QAAQ,CAAG,EAAA;AACpC,MAAA,WAAA,CAAY,MAAM,CAAA,CAAA;AAAA,KACpB;AAEA,IAAA,QAAA,CAAS,OAAO,CAAA,CAAA;AAAA,GAClB,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -14,11 +14,6 @@ function withNormalize(editor) {
14
14
  }
15
15
  }
16
16
  }
17
- if (slate.Element.isElement(node) && (node.type === "auto-link" || node.type === "custom-link")) {
18
- if (node.children.length === 0 || node.children.length === 1 && node.children[0]?.text === "") {
19
- slate.Transforms.removeNodes(editor, { at: path });
20
- }
21
- }
22
17
  normalizeNode(entry);
23
18
  };
24
19
  return editor;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.cjs","sources":["../../../../src/primitives/slate/plugins/normalize.ts"],"sourcesContent":["import type { Editor as SlateEditor } from \"slate\";\nimport {\n Element as SlateElement,\n Node as SlateNode,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nexport function withNormalize(editor: SlateEditor) {\n const { normalizeNode } = editor;\n\n editor.normalizeNode = (entry) => {\n const [node, path] = entry;\n\n // Paragraphs should only contain inline elements\n if (SlateElement.isElement(node) && node.type === \"paragraph\") {\n for (const [child, childPath] of SlateNode.children(editor, path)) {\n if (SlateElement.isElement(child) && !editor.isInline(child)) {\n SlateTransforms.unwrapNodes(editor, { at: childPath });\n return;\n }\n }\n }\n\n normalizeNode(entry);\n };\n\n return editor;\n}\n"],"names":["SlateElement","SlateNode","SlateTransforms"],"mappings":";;;;AAOO,SAAS,cAAc,MAAqB,EAAA;AACjD,EAAM,MAAA,EAAE,eAAkB,GAAA,MAAA,CAAA;AAE1B,EAAO,MAAA,CAAA,aAAA,GAAgB,CAAC,KAAU,KAAA;AAChC,IAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,KAAA,CAAA;AAGrB,IAAA,IAAIA,cAAa,SAAU,CAAA,IAAI,CAAK,IAAA,IAAA,CAAK,SAAS,WAAa,EAAA;AAC7D,MAAW,KAAA,MAAA,CAAC,OAAO,SAAS,CAAA,IAAKC,WAAU,QAAS,CAAA,MAAA,EAAQ,IAAI,CAAG,EAAA;AACjE,QAAI,IAAAD,aAAA,CAAa,UAAU,KAAK,CAAA,IAAK,CAAC,MAAO,CAAA,QAAA,CAAS,KAAK,CAAG,EAAA;AAC5D,UAAAE,gBAAA,CAAgB,WAAY,CAAA,MAAA,EAAQ,EAAE,EAAA,EAAI,WAAW,CAAA,CAAA;AACrD,UAAA,OAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEA,IAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,GACrB,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -12,11 +12,6 @@ function withNormalize(editor) {
12
12
  }
13
13
  }
14
14
  }
15
- if (Element.isElement(node) && (node.type === "auto-link" || node.type === "custom-link")) {
16
- if (node.children.length === 0 || node.children.length === 1 && node.children[0]?.text === "") {
17
- Transforms.removeNodes(editor, { at: path });
18
- }
19
- }
20
15
  normalizeNode(entry);
21
16
  };
22
17
  return editor;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sources":["../../../../src/primitives/slate/plugins/normalize.ts"],"sourcesContent":["import type { Editor as SlateEditor } from \"slate\";\nimport {\n Element as SlateElement,\n Node as SlateNode,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nexport function withNormalize(editor: SlateEditor) {\n const { normalizeNode } = editor;\n\n editor.normalizeNode = (entry) => {\n const [node, path] = entry;\n\n // Paragraphs should only contain inline elements\n if (SlateElement.isElement(node) && node.type === \"paragraph\") {\n for (const [child, childPath] of SlateNode.children(editor, path)) {\n if (SlateElement.isElement(child) && !editor.isInline(child)) {\n SlateTransforms.unwrapNodes(editor, { at: childPath });\n return;\n }\n }\n }\n\n normalizeNode(entry);\n };\n\n return editor;\n}\n"],"names":["SlateElement","SlateNode","SlateTransforms"],"mappings":";;AAOO,SAAS,cAAc,MAAqB,EAAA;AACjD,EAAM,MAAA,EAAE,eAAkB,GAAA,MAAA,CAAA;AAE1B,EAAO,MAAA,CAAA,aAAA,GAAgB,CAAC,KAAU,KAAA;AAChC,IAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,KAAA,CAAA;AAGrB,IAAA,IAAIA,QAAa,SAAU,CAAA,IAAI,CAAK,IAAA,IAAA,CAAK,SAAS,WAAa,EAAA;AAC7D,MAAW,KAAA,MAAA,CAAC,OAAO,SAAS,CAAA,IAAKC,KAAU,QAAS,CAAA,MAAA,EAAQ,IAAI,CAAG,EAAA;AACjE,QAAI,IAAAD,OAAA,CAAa,UAAU,KAAK,CAAA,IAAK,CAAC,MAAO,CAAA,QAAA,CAAS,KAAK,CAAG,EAAA;AAC5D,UAAAE,UAAA,CAAgB,WAAY,CAAA,MAAA,EAAQ,EAAE,EAAA,EAAI,WAAW,CAAA,CAAA;AACrD,UAAA,OAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEA,IAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,GACrB,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-character.cjs","sources":["../../../../src/primitives/slate/utils/get-character.ts"],"sourcesContent":["import type { Location as SlateLocation } from \"slate\";\nimport { Editor as SlateEditor, Range as SlateRange } from \"slate\";\n\ninterface Options {\n filterVoids?: boolean;\n}\n\nexport function getCharacterBefore<T extends SlateEditor>(\n editor: T,\n at: SlateLocation,\n options: Options = {}\n) {\n const { filterVoids } = options;\n const before = SlateEditor.before(editor, at, {\n unit: \"character\",\n voids: filterVoids,\n });\n\n if (before) {\n const range = SlateEditor.range(\n editor,\n before,\n SlateRange.isRange(at) ? SlateRange.start(at) : at\n );\n const text = SlateEditor.string(editor, range);\n\n return {\n range,\n text,\n void: text.length === 0,\n };\n }\n\n return;\n}\n\nexport function getCharacterAfter<T extends SlateEditor>(\n editor: T,\n at: SlateLocation,\n options: Options = {}\n) {\n const { filterVoids } = options;\n const after = SlateEditor.after(editor, at, {\n unit: \"character\",\n voids: filterVoids,\n });\n\n if (after) {\n const range = SlateEditor.range(\n editor,\n after,\n SlateRange.isRange(at) ? SlateRange.end(at) : at\n );\n const text = SlateEditor.string(editor, range);\n\n return {\n range,\n text,\n void: text.length ===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AIA,WAAW,CAAA,GAAA,CAAI,EAAE,CAAI,GAAA,EAAA;AAAA,KAChD,CAAA;AACA,IAAA,MAAM,IAAO,GAAAD,YAAA,CAAY,MAAO,CAAA,MAAA,EAAQ,KAAK,CAAA,CAAA;AAE7C,IAAO,OAAA;AAAA,MACL,KAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAA,EAAM,KAAK,MAAW,KAAA,CAAA;AAAA,KACxB,CAAA;AAAA,GACF;AAEA,EAAA,OAAA;AACF;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-character.js","sources":["../../../../src/primitives/slate/utils/get-character.ts"],"sourcesContent":["import type { Location as SlateLocation } from \"slate\";\nimport { Editor as SlateEditor, Range as SlateRange } from \"slate\";\n\ninterface Options {\n filterVoids?: boolean;\n}\n\nexport function getCharacterBefore<T extends SlateEditor>(\n editor: T,\n at: SlateLocation,\n options: Options = {}\n) {\n const { filterVoids } = options;\n const before = SlateEditor.before(editor, at, {\n unit: \"character\",\n voids: filterVoids,\n });\n\n if (before) {\n const range = SlateEditor.range(\n editor,\n before,\n SlateRange.isRange(at) ? SlateRange.start(at) : at\n );\n const text = SlateEditor.string(editor, range);\n\n return {\n range,\n text,\n void: text.length === 0,\n };\n }\n\n return;\n}\n\nexport function getCharacterAfter<T extends SlateEditor>(\n editor: T,\n at: SlateLocation,\n options: Options = {}\n) {\n const { filterVoids } = options;\n const after = SlateEditor.after(editor, at, {\n unit: \"character\",\n voids: filterVoids,\n });\n\n if (after) {\n const range = SlateEditor.range(\n editor,\n after,\n SlateRange.isRange(at) ? SlateRange.end(at) : at\n );\n const text = SlateEditor.string(editor, range);\n\n return {\n range,\n text,\n void: text.length === 0,\n };\n }\n\n return;\n}\n"],"names":["SlateEditor","SlateRange"],"mappings":";;AAOO,SAAS,kBACd,CAAA,MAAA,EACA,EACA,EAAA,OAAA,GAAmB,EACnB,EAAA;AACA,EAAM,MAAA,EAAE,aAAgB,GAAA,OAAA,CAAA;AACxB,EAAA,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A;AAAA,MACA,IAAA;AAAA,MACA,IAAA,EAAM,KAAK,MAAW,KAAA,CAAA;AAAA,KACxB,CAAA;AAAA,GACF;AAEA,EAAA,OAAA;AACF;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-dom-range.cjs","sources":["../../../../src/primitives/slate/utils/get-dom-range.ts"],"sourcesContent":["import type { Editor as SlateEditor, Range as SlateRange } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\n\nexport function getDOMRange(\n editor: SlateEditor,\n range: SlateRange\n): Range | undefined {\n try {\n return ReactEditor.toDOMRange(editor, range);\n } catch (error) {\n return getDOMRange(editor, {\n anchor: range.anchor,\n focus: range.anchor,\n });\n }\n}\n"],"names":["ReactEditor"],"mappings":";;;;AAGgB,SAAA,WAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAI,IAAA;AACF,IAAO,OAAAA,sBAAA,CAAY,UAAW,CAAA,MAAA,EAAQ,KAAK,CAAA,CAAA;AAAA,WACpC,KAAP,EAAA;AACA,IAAA,OAAO,YAAY,MAAQ,EAAA;AAAA,MACzB,QAAQ,KAAM,CAAA,MAAA;AAAA,MACd,OAAO,KAAM,CAAA,MAAA;AAAA,KACd,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-dom-range.js","sources":["../../../../src/primitives/slate/utils/get-dom-range.ts"],"sourcesContent":["import type { Editor as SlateEditor, Range as SlateRange } from \"slate\";\nimport { ReactEditor } from \"slate-react\";\n\nexport function getDOMRange(\n editor: SlateEditor,\n range: SlateRange\n): Range | undefined {\n try {\n return ReactEditor.toDOMRange(editor, range);\n } catch (error) {\n return getDOMRange(editor, {\n anchor: range.anchor,\n focus: range.anchor,\n });\n }\n}\n"],"names":[],"mappings":";;AAGgB,SAAA,WAAA,CACd,QACA,KACmB,EAAA;AACnB,EAAI,IAAA;AACF,IAAO,OAAA,WAAA,CAAY,UAAW,CAAA,MAAA,EAAQ,KAAK,CAAA,CAAA;AAAA,WACpC,KAAP,EAAA;AACA,IAAA,OAAO,YAAY,MAAQ,EAAA;AAAA,MACzB,QAAQ,KAAM,CAAA,MAAA;AAAA,MACd,OAAO,KAAM,CAAA,MAAA;AAAA,KACd,CAAA,CAAA;AAAA,GACH;AACF;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-match-range.cjs","sources":["../../../../src/primitives/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {\n Editor as SlateEditor,\n Path as SlatePath,\n Range as SlateRange,\n} from \"slate\";\n\nimport { isWhitespaceCharacter } from \"./is-whitespace-character\";\n\ninterface Options {\n include?: boolean;\n direction?: \"before\" | \"after\" | \"both\";\n allowConsecutiveWhitespace?: boolean;\n ignoreTerminator?: (\n character: string,\n point: SlatePoint,\n direction: \"before\" | \"after\"\n ) => boolean;\n}\n\nconst defaultOptions: Options = {\n direction: \"before\",\n allowConsecutiveWhitespace: true,\n};\n\nexport function getMatchRange(\n editor: SlateEditor,\n at: SlateRange,\n terminators: string[] = [\" \"],\n options: Options = defaultOptions\n): SlateRange | undefined {\n const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {\n ...defaultOptions,\n ...options,\n };\n\n let [start, end] = SlateRange.edges(at);\n let point: SlatePoint = start;\n let previousCharacterWasWhitespace = false;\n\n function move(direction: \"before\" | \"after\"): boolean {\n const nextPoint =\n direction === \"after\"\n ? SlateEditor.after(editor, point, { unit: \"character\" })\n : SlateEditor.before(editor, point, { unit: \"character\" });\n\n // Stop if we reached the end of a block\n if (!nextPoint || SlatePath.compare(nextPoint.path, point.path) !== 0) {\n return false;\n }\n\n const nextCharacter =\n nextPoint &&\n SlateEditor.string(\n editor,\n direction === \"after\"\n ? { anchor: point, focus: nextPoint }\n : { anchor: nextPoint, focus: point }\n );\n const lastCharacter =\n nextCharacter &&\n nextCharacter[direction === \"after\" ? 0 : nextCharacter.length - 1];\n\n if (\n !allowConsecutiveWhitespace &&\n previousCharacterWasWhitespace &&\n isWhitespaceCharacter(lastCharacter)\n ) {\n return false;\n }\n\n if (\n nextPoint &&\n lastCharacter &&\n (!terminators.includes(lastCharacter) ||\n ignoreTerminator?.(lastCharacter, nextPoint, direction))\n ) {\n previousCharacterWasWhitespace = isWhitespaceCharacter(lastCharacter);\n point = nextPoint;\n\n if (point.offset === 0) {\n return false;\n }\n } else {\n return false;\n }\n\n return true;\n }\n\n if (direction !== \"before\") {\n point = end;\n while (move(\"after\"));\n end = point;\n }\n\n if (direction !== \"after\") {\n point = start;\n while (move(\"before\"));\n start = point;\n }\n\n if (include) {\n return {\n anchor:\n direction === \"before\" || direction === \"both\"\n ? (SlateEditor.before(editor, start, { unit: \"offset\" }) ?? start)\n : start,\n focus:\n direction === \"after\" || direction === \"both\"\n ? (SlateEditor.after(editor, end, { unit: \"offset\" }) ?? end)\n : end,\n };\n }\n\n return { anchor: start, focus: end };\n}\n"],"names":["SlateRange","direction","SlateEditor","SlatePath","isWhitespaceCharacter"],"mappings":";;;;;AAoBA,MAAM,cAA0B,GAAA;AAAA,EAC9B,SAAW,EAAA,QAAA;AAAA,EACX,0BAA4B,EAAA,IAAA;AAC9B,CAAA,CAAA;AAEgB,SAAA,aAAA,CACd,QACA,EACA,EAAA,WAAA,GAAwB,CAAC,GAAG,CAAA,EAC5B,UAAmB,cACK,EAAA;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAW,EAAA,gBAAA,EAAkB,4BAA+B,GAAA;AAAA,IAC3E,GAAG,cAAA;AAAA,IACH,GAAG,OAAA;AAAA,GACL,CAAA;AAEA,EAAA,IAAI,CAAC,KAAO,EAAA,GAAG,CAAI,GAAAA,WAAA,CAAW,MAAM,EAAE,CAAA,CAAA;AACtC,EAAA,IAAI,KAAoB,GAAA,KAAA,CAAA;AACxB,EAAA,IAAI,8BAAiC,GAAA,KAAA,CAAA;AAErC,EAAA,SAAS,KAAKC,UAAwC,EAAA;AACpD,IAAA,MAAM,YACJA,UAAc,KAAA,OAAA,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I,cAAc,QAAU,EAAA;AAC1B,IAAQ,KAAA,GAAA,GAAA,CAAA;AACR,IAAA,OAAO,KAAK,OAAO,CAAA;AAAE,MAAA,CAAA;AACrB,IAAM,GAAA,GAAA,KAAA,CAAA;AAAA,GACR;AAEA,EAAA,IAAI,cAAc,OAAS,EAAA;AACzB,IAAQ,KAAA,GAAA,KAAA,CAAA;AACR,IAAA,OAAO,KAAK,QAAQ,CAAA;AAAE,MAAA,CAAA;AACtB,IAAQ,KAAA,GAAA,KAAA,CAAA;AAAA,GACV;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAO,OAAA;AAAA,MACL,MACE,EAAA,SAAA,KAAc,QAAY,IAAA,SAAA,KAAc,SACnCF,YAAY,CAAA,MAAA,CAAO,MAAQ,EAAA,KAAA,EAAO,EAAE,IAAA,EAAM,QAAS,EAAC,KAAK,KAC1D,GAAA,KAAA;AAAA,MACN,KACE,EAAA,SAAA,KAAc,OAAW,IAAA,SAAA,KAAc,SAClCA,YAAY,CAAA,KAAA,CAAM,MAAQ,EAAA,GAAA,EAAK,EAAE,IAAA,EAAM,QAAS,EAAC,KAAK,GACvD,GAAA,GAAA;AAAA,KACR,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAO,EAAA,KAAA,EAAO,GAAI,EAAA,CAAA;AACrC;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-match-range.js","sources":["../../../../src/primitives/slate/utils/get-match-range.ts"],"sourcesContent":["import type { Point as SlatePoint } from \"slate\";\nimport {\n Editor as SlateEditor,\n Path as SlatePath,\n Range as SlateRange,\n} from \"slate\";\n\nimport { isWhitespaceCharacter } from \"./is-whitespace-character\";\n\ninterface Options {\n include?: boolean;\n direction?: \"before\" | \"after\" | \"both\";\n allowConsecutiveWhitespace?: boolean;\n ignoreTerminator?: (\n character: string,\n point: SlatePoint,\n direction: \"before\" | \"after\"\n ) => boolean;\n}\n\nconst defaultOptions: Options = {\n direction: \"before\",\n allowConsecutiveWhitespace: true,\n};\n\nexport function getMatchRange(\n editor: SlateEditor,\n at: SlateRange,\n terminators: string[] = [\" \"],\n options: Options = defaultOptions\n): SlateRange | undefined {\n const { include, direction, ignoreTerminator, allowConsecutiveWhitespace } = {\n ...defaultOptions,\n ...options,\n };\n\n let [start, end] = SlateRange.edges(at);\n let point: SlatePoint = start;\n let previousCharacterWasWhitespace = false;\n\n function move(direction: \"before\" | \"after\"): boolean {\n const nextPoint =\n direction === \"after\"\n ? SlateEditor.after(editor, point, { unit: \"character\" })\n : SlateEditor.before(editor, point, { unit: \"character\" });\n\n // Stop if we reached the end of a block\n if (!nextPoint || SlatePath.compare(nextPoint.path, point.path) !== 0) {\n return false;\n }\n\n const nextCharacter =\n nextPoint &&\n SlateEditor.string(\n editor,\n direction === \"after\"\n ? { anchor: point, focus: nextPoint }\n : { anchor: nextPoint, focus: point }\n );\n const lastCharacter =\n nextCharacter &&\n nextCharacter[direction === \"after\" ? 0 : nextCharacter.length - 1];\n\n if (\n !allowConsecutiveWhitespace &&\n previousCharacterWasWhitespace &&\n isWhitespaceCharacter(lastCharacter)\n ) {\n return false;\n }\n\n if (\n nextPoint &&\n lastCharacter &&\n (!terminators.includes(lastCharacter) ||\n ignoreTerminator?.(lastCharacter, nextPoint, direction))\n ) {\n previousCharacterWasWhitespace = isWhitespaceCharacter(lastCharacter);\n point = nextPoint;\n\n if (point.offset === 0) {\n return false;\n }\n } else {\n return false;\n }\n\n return true;\n }\n\n if (direction !== \"before\") {\n point = end;\n while (move(\"after\"));\n end = point;\n }\n\n if (direction !== \"after\") {\n point = start;\n while (move(\"before\"));\n start = point;\n }\n\n if (include) {\n return {\n anchor:\n direction === \"before\" || direction === \"both\"\n ? (SlateEditor.before(editor, start, { unit: \"offset\" }) ?? start)\n : start,\n focus:\n direction === \"after\" || direction === \"both\"\n ? (SlateEditor.after(editor, end, { unit: \"offset\" }) ?? end)\n : end,\n };\n }\n\n return { anchor: start, focus: end };\n}\n"],"names":["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IAAA,SAAA,KAAc,SAClCA,MAAY,CAAA,KAAA,CAAM,MAAQ,EAAA,GAAA,EAAK,EAAE,IAAA,EAAM,QAAS,EAAC,KAAK,GACvD,GAAA,GAAA;AAAA,KACR,CAAA;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAO,EAAA,KAAA,EAAO,GAAI,EAAA,CAAA;AACrC;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty-string.cjs","sources":["../../../../src/primitives/slate/utils/is-empty-string.ts"],"sourcesContent":["export function isEmptyString(string: string) {\n return !string.trim();\n}\n"],"names":[],"mappings":";;AAAO,SAAS,cAAc,MAAgB,EAAA;AAC5C,EAAO,OAAA,CAAC,OAAO,IAAK,EAAA,CAAA;AACtB;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty-string.js","sources":["../../../../src/primitives/slate/utils/is-empty-string.ts"],"sourcesContent":["export function isEmptyString(string: string) {\n return !string.trim();\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,MAAgB,EAAA;AAC5C,EAAO,OAAA,CAAC,OAAO,IAAK,EAAA,CAAA;AACtB;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty.cjs","sources":["../../../../src/primitives/slate/utils/is-empty.ts"],"sourcesContent":["import type { Descendant as SlateDescendant } from \"slate\";\nimport { Editor as SlateEditor } from \"slate\";\n\nimport { isEmptyString } from \"./is-empty-string\";\nimport { isText } from \"./is-text\";\n\nexport function isEmpty(editor: SlateEditor, children: SlateDescendant[]) {\n // Check if all blocks are empty, stopping at the first non-empty block\n for (const child of children) {\n if (isText(child)) {\n // Non-empty text\n if (!isEmptyString(child.text)) {\n return false;\n }\n } else if (child.type === \"paragraph\") {\n // Non-empty paragraph\n if (\n child.children.length > 1 ||\n (child.children[0] &&\n !(isText(child.children[0]) && isEmptyString(child.children[0].text)))\n ) {\n return false;\n }\n } else {\n // Non-empty other block\n if (!SlateEditor.isEmpty(editor, child)) {\n return false;\n }\n }\n }\n\n return true;\n}\n"],"names":["isText","isEmptyString","SlateEditor"],"mappings":";;;;;;AAMgB,SAAA,OAAA,CAAQ,QAAqB,QAA6B,EAAA;AAExE,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC5B,IAAI,IAAAA,aAAA,CAAO,KAAK,CAAG,EAAA;AAEjB,MAAA,IAAI,CAACC,2BAAA,CAAc,KAAM,CAAA,IAAI,CAAG,EAAA;AAC9B,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF,MAAA,IAAW,KAAM,CAAA,IAAA,KAAS,WAAa,EAAA;AAErC,MAAA,IACE,MAAM,QAAS,CAAA,MAAA,GAAS,KACvB,KAAM,CAAA,QAAA,CAAS,MACd,EAAED,aAAA,CAAO,KAAM,CAAA,QAAA,CAAS,EAAE,CAAK,IAAAC,2BAAA,CAAc,MAAM,QAAS,CAAA,CAAA,CAAA,CAAG,IAAI,CACrE,CAAA,EAAA;AACA,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AAEL,MAAA,IAAI,CAACC,YAAA,CAAY,OAAQ,CAAA,MAAA,EAAQ,KAAK,CAAG,EAAA;AACvC,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF;AAEA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty.js","sources":["../../../../src/primitives/slate/utils/is-empty.ts"],"sourcesContent":["import type { Descendant as SlateDescendant } from \"slate\";\nimport { Editor as SlateEditor } from \"slate\";\n\nimport { isEmptyString } from \"./is-empty-string\";\nimport { isText } from \"./is-text\";\n\nexport function isEmpty(editor: SlateEditor, children: SlateDescendant[]) {\n // Check if all blocks are empty, stopping at the first non-empty block\n for (const child of children) {\n if (isText(child)) {\n // Non-empty text\n if (!isEmptyString(child.text)) {\n return false;\n }\n } else if (child.type === \"paragraph\") {\n // Non-empty paragraph\n if (\n child.children.length > 1 ||\n (child.children[0] &&\n !(isText(child.children[0]) && isEmptyString(child.children[0].text)))\n ) {\n return false;\n }\n } else {\n // Non-empty other block\n if (!SlateEditor.isEmpty(editor, child)) {\n return false;\n }\n }\n }\n\n return true;\n}\n"],"names":["SlateEditor"],"mappings":";;;;AAMgB,SAAA,OAAA,CAAQ,QAAqB,QAA6B,EAAA;AAExE,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC5B,IAAI,IAAA,MAAA,CAAO,KAAK,CAAG,EAAA;AAEjB,MAAA,IAAI,CAAC,aAAA,CAAc,KAAM,CAAA,IAAI,CAAG,EAAA;AAC9B,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF,MAAA,IAAW,KAAM,CAAA,IAAA,KAAS,WAAa,EAAA;AAErC,MAAA,IACE,MAAM,QAAS,CAAA,MAAA,GAAS,KACvB,KAAM,CAAA,QAAA,CAAS,MACd,EAAE,MAAA,CAAO,KAAM,CAAA,QAAA,CAAS,EAAE,CAAK,IAAA,aAAA,CAAc,MAAM,QAAS,CAAA,CAAA,CAAA,CAAG,IAAI,CACrE,CAAA,EAAA;AACA,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AAEL,MAAA,IAAI,CAACA,MAAA,CAAY,OAAQ,CAAA,MAAA,EAAQ,KAAK,CAAG,EAAA;AACvC,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF;AAEA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-text.cjs","sources":["../../../../src/primitives/slate/utils/is-text.ts"],"sourcesContent":["import type { Node as SlateNode, Text as SlateText } from \"slate\";\n\nexport function isText(element: SlateNode): element is SlateText {\n return (\n !(\"type\" in element) &&\n \"text\" in element &&\n typeof element.text === \"string\"\n );\n}\n\nexport function isPlainText(node: SlateNode): boolean {\n return isText(node) && Object.keys(node).length === 1;\n}\n"],"names":[],"mappings":";;AAEO,SAAS,OAAO,OAA0C,EAAA;AAC/D,EAAA,OACE,EAAE,MAAU,IAAA,OAAA,CAAA,IACZ,UAAU,OACV,IAAA,OAAO,QAAQ,IAAS,KAAA,QAAA,CAAA;AAE5B,CAAA;AAEO,SAAS,YAAY,IAA0B,EAAA;AACpD,EAAA,OAAO,OAAO,IAAI,CAAA,IAAK,OAAO,IAAK,CAAA,IAAI,EAAE,MAAW,KAAA,CAAA,CAAA;AACtD;;;;;"}