@algolia/satellite 2.2.3 → 2.3.0-rc.2

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 (158) hide show
  1. package/dist/cjs/Actions/Accordion/Accordion.d.ts +8 -0
  2. package/dist/cjs/Actions/Accordion/Accordion.js +5 -3
  3. package/dist/cjs/Fields/TextArea/TextArea.d.ts +5 -1
  4. package/dist/cjs/Fields/TextArea/TextArea.js +3 -2
  5. package/dist/cjs/Fields/TextArea/TextArea.tailwind.js +1 -1
  6. package/dist/cjs/Fields/TextAreaAutoSize/TextAreaAutoSize.d.ts +18 -0
  7. package/dist/cjs/Fields/TextAreaAutoSize/TextAreaAutoSize.js +82 -0
  8. package/dist/cjs/Fields/TextAreaAutoSize/TextAreaAutoSize.styles.d.ts +25 -0
  9. package/dist/cjs/Fields/TextAreaAutoSize/TextAreaAutoSize.styles.js +16 -0
  10. package/dist/cjs/Fields/TextAreaAutoSize/index.d.ts +2 -0
  11. package/dist/cjs/Fields/TextAreaAutoSize/index.js +12 -0
  12. package/dist/cjs/Fields/index.d.ts +2 -1
  13. package/dist/cjs/Fields/index.js +15 -4
  14. package/dist/cjs/Helpers/ShimmerText/ShimmerText.d.ts +3 -0
  15. package/dist/cjs/Helpers/ShimmerText/ShimmerText.js +28 -0
  16. package/dist/cjs/Helpers/ShimmerText/ShimmerText.tailwind.d.ts +5 -0
  17. package/dist/cjs/Helpers/ShimmerText/ShimmerText.tailwind.js +37 -0
  18. package/dist/cjs/Helpers/ShimmerText/index.d.ts +2 -0
  19. package/dist/cjs/Helpers/ShimmerText/index.js +12 -0
  20. package/dist/cjs/Helpers/index.d.ts +1 -0
  21. package/dist/cjs/Helpers/index.js +11 -0
  22. package/dist/cjs/Helpers/utilities/utilities.tailwind.js +6 -1
  23. package/dist/cjs/Indicators/Skeleton/Skeleton.d.ts +2 -2
  24. package/dist/cjs/Layout/Chat/ChatContextAccordion/ChatContextAccordion.d.ts +8 -0
  25. package/dist/cjs/Layout/Chat/ChatContextAccordion/ChatContextAccordion.js +44 -0
  26. package/dist/cjs/Layout/Chat/ChatContextAccordion/ChatContextAccordion.styles.d.ts +67 -0
  27. package/dist/cjs/Layout/Chat/ChatContextAccordion/ChatContextAccordion.styles.js +23 -0
  28. package/dist/cjs/Layout/Chat/ChatContextAccordion/index.d.ts +1 -0
  29. package/dist/cjs/Layout/Chat/ChatContextAccordion/index.js +16 -0
  30. package/dist/cjs/Layout/Chat/ChatMessage/ChatMessage.d.ts +40 -0
  31. package/dist/cjs/Layout/Chat/ChatMessage/ChatMessage.js +83 -0
  32. package/dist/cjs/Layout/Chat/ChatMessage/ChatMessage.styles.d.ts +100 -0
  33. package/dist/cjs/Layout/Chat/ChatMessage/ChatMessage.styles.js +77 -0
  34. package/dist/cjs/Layout/Chat/ChatMessage/index.d.ts +1 -0
  35. package/dist/cjs/Layout/Chat/ChatMessage/index.js +16 -0
  36. package/dist/cjs/Layout/Chat/ChatMessageError/ChatMessageError.d.ts +57 -0
  37. package/dist/cjs/Layout/Chat/ChatMessageError/ChatMessageError.js +68 -0
  38. package/dist/cjs/Layout/Chat/ChatMessageError/ChatMessageError.styles.d.ts +173 -0
  39. package/dist/cjs/Layout/Chat/ChatMessageError/ChatMessageError.styles.js +18 -0
  40. package/dist/cjs/Layout/Chat/ChatMessageError/index.d.ts +1 -0
  41. package/dist/cjs/Layout/Chat/ChatMessageError/index.js +16 -0
  42. package/dist/cjs/Layout/Chat/ChatMessageLoader/ChatMessageLoader.d.ts +18 -0
  43. package/dist/cjs/Layout/Chat/ChatMessageLoader/ChatMessageLoader.js +63 -0
  44. package/dist/cjs/Layout/Chat/ChatMessageLoader/ChatMessageLoader.styles.d.ts +200 -0
  45. package/dist/cjs/Layout/Chat/ChatMessageLoader/ChatMessageLoader.styles.js +21 -0
  46. package/dist/cjs/Layout/Chat/ChatMessageLoader/index.d.ts +1 -0
  47. package/dist/cjs/Layout/Chat/ChatMessageLoader/index.js +16 -0
  48. package/dist/cjs/Layout/Chat/ChatMessages/ChatMessages.d.ts +44 -0
  49. package/dist/cjs/Layout/Chat/ChatMessages/ChatMessages.js +152 -0
  50. package/dist/cjs/Layout/Chat/ChatMessages/ChatMessages.styles.d.ts +43 -0
  51. package/dist/cjs/Layout/Chat/ChatMessages/ChatMessages.styles.js +29 -0
  52. package/dist/cjs/Layout/Chat/ChatMessages/index.d.ts +1 -0
  53. package/dist/cjs/Layout/Chat/ChatMessages/index.js +16 -0
  54. package/dist/cjs/Layout/Chat/ChatMessages/useLastMessageHeight.d.ts +8 -0
  55. package/dist/cjs/Layout/Chat/ChatMessages/useLastMessageHeight.js +48 -0
  56. package/dist/cjs/Layout/Chat/ChatPrompt/ChatPrompt.d.ts +91 -0
  57. package/dist/cjs/Layout/Chat/ChatPrompt/ChatPrompt.js +142 -0
  58. package/dist/cjs/Layout/Chat/ChatPrompt/ChatPrompt.styles.d.ts +61 -0
  59. package/dist/cjs/Layout/Chat/ChatPrompt/ChatPrompt.styles.js +22 -0
  60. package/dist/cjs/Layout/Chat/ChatPrompt/index.d.ts +1 -0
  61. package/dist/cjs/Layout/Chat/ChatPrompt/index.js +16 -0
  62. package/dist/cjs/Layout/Chat/ChatPrompt/useFocusTyping.d.ts +12 -0
  63. package/dist/cjs/Layout/Chat/ChatPrompt/useFocusTyping.js +60 -0
  64. package/dist/cjs/Layout/Chat/ChatPrompt/useTypewriter.d.ts +18 -0
  65. package/dist/cjs/Layout/Chat/ChatPrompt/useTypewriter.js +78 -0
  66. package/dist/cjs/Layout/Chat/index.d.ts +15 -0
  67. package/dist/cjs/Layout/Chat/index.js +47 -0
  68. package/dist/cjs/Layout/Chat/types.d.ts +7 -0
  69. package/dist/cjs/Layout/Chat/types.js +5 -0
  70. package/dist/cjs/Layout/index.d.ts +1 -0
  71. package/dist/cjs/Layout/index.js +11 -0
  72. package/dist/cjs/Satellite/locale.d.ts +7 -1
  73. package/dist/cjs/styles/helpers/tv.d.ts +1 -0
  74. package/dist/cjs/styles/helpers/tv.js +13 -0
  75. package/dist/cjs/styles/tailwind.config.js +1 -1
  76. package/dist/cjs/utils/getTextFromReactNode.d.ts +2 -1
  77. package/dist/cjs/utils/getTextFromReactNode.js +12 -7
  78. package/dist/cjs/utils/isCssPropertySupported.d.ts +1 -1
  79. package/dist/esm/Actions/Accordion/Accordion.d.ts +8 -0
  80. package/dist/esm/Actions/Accordion/Accordion.js +5 -3
  81. package/dist/esm/Fields/TextArea/TextArea.d.ts +5 -1
  82. package/dist/esm/Fields/TextArea/TextArea.js +3 -2
  83. package/dist/esm/Fields/TextArea/TextArea.tailwind.js +1 -1
  84. package/dist/esm/Fields/TextAreaAutoSize/TextAreaAutoSize.d.ts +18 -0
  85. package/dist/esm/Fields/TextAreaAutoSize/TextAreaAutoSize.js +75 -0
  86. package/dist/esm/Fields/TextAreaAutoSize/TextAreaAutoSize.styles.d.ts +25 -0
  87. package/dist/esm/Fields/TextAreaAutoSize/TextAreaAutoSize.styles.js +9 -0
  88. package/dist/esm/Fields/TextAreaAutoSize/index.d.ts +2 -0
  89. package/dist/esm/Fields/TextAreaAutoSize/index.js +1 -0
  90. package/dist/esm/Fields/index.d.ts +2 -1
  91. package/dist/esm/Fields/index.js +2 -1
  92. package/dist/esm/Helpers/ShimmerText/ShimmerText.d.ts +3 -0
  93. package/dist/esm/Helpers/ShimmerText/ShimmerText.js +21 -0
  94. package/dist/esm/Helpers/ShimmerText/ShimmerText.tailwind.d.ts +5 -0
  95. package/dist/esm/Helpers/ShimmerText/ShimmerText.tailwind.js +36 -0
  96. package/dist/esm/Helpers/ShimmerText/index.d.ts +2 -0
  97. package/dist/esm/Helpers/ShimmerText/index.js +1 -0
  98. package/dist/esm/Helpers/index.d.ts +1 -0
  99. package/dist/esm/Helpers/index.js +2 -1
  100. package/dist/esm/Helpers/utilities/utilities.tailwind.js +6 -1
  101. package/dist/esm/Indicators/Skeleton/Skeleton.d.ts +2 -2
  102. package/dist/esm/Layout/Chat/ChatContextAccordion/ChatContextAccordion.d.ts +8 -0
  103. package/dist/esm/Layout/Chat/ChatContextAccordion/ChatContextAccordion.js +37 -0
  104. package/dist/esm/Layout/Chat/ChatContextAccordion/ChatContextAccordion.styles.d.ts +67 -0
  105. package/dist/esm/Layout/Chat/ChatContextAccordion/ChatContextAccordion.styles.js +16 -0
  106. package/dist/esm/Layout/Chat/ChatContextAccordion/index.d.ts +1 -0
  107. package/dist/esm/Layout/Chat/ChatContextAccordion/index.js +1 -0
  108. package/dist/esm/Layout/Chat/ChatMessage/ChatMessage.d.ts +40 -0
  109. package/dist/esm/Layout/Chat/ChatMessage/ChatMessage.js +77 -0
  110. package/dist/esm/Layout/Chat/ChatMessage/ChatMessage.styles.d.ts +100 -0
  111. package/dist/esm/Layout/Chat/ChatMessage/ChatMessage.styles.js +70 -0
  112. package/dist/esm/Layout/Chat/ChatMessage/index.d.ts +1 -0
  113. package/dist/esm/Layout/Chat/ChatMessage/index.js +1 -0
  114. package/dist/esm/Layout/Chat/ChatMessageError/ChatMessageError.d.ts +57 -0
  115. package/dist/esm/Layout/Chat/ChatMessageError/ChatMessageError.js +61 -0
  116. package/dist/esm/Layout/Chat/ChatMessageError/ChatMessageError.styles.d.ts +173 -0
  117. package/dist/esm/Layout/Chat/ChatMessageError/ChatMessageError.styles.js +11 -0
  118. package/dist/esm/Layout/Chat/ChatMessageError/index.d.ts +1 -0
  119. package/dist/esm/Layout/Chat/ChatMessageError/index.js +1 -0
  120. package/dist/esm/Layout/Chat/ChatMessageLoader/ChatMessageLoader.d.ts +18 -0
  121. package/dist/esm/Layout/Chat/ChatMessageLoader/ChatMessageLoader.js +56 -0
  122. package/dist/esm/Layout/Chat/ChatMessageLoader/ChatMessageLoader.styles.d.ts +200 -0
  123. package/dist/esm/Layout/Chat/ChatMessageLoader/ChatMessageLoader.styles.js +14 -0
  124. package/dist/esm/Layout/Chat/ChatMessageLoader/index.d.ts +1 -0
  125. package/dist/esm/Layout/Chat/ChatMessageLoader/index.js +1 -0
  126. package/dist/esm/Layout/Chat/ChatMessages/ChatMessages.d.ts +44 -0
  127. package/dist/esm/Layout/Chat/ChatMessages/ChatMessages.js +145 -0
  128. package/dist/esm/Layout/Chat/ChatMessages/ChatMessages.styles.d.ts +43 -0
  129. package/dist/esm/Layout/Chat/ChatMessages/ChatMessages.styles.js +22 -0
  130. package/dist/esm/Layout/Chat/ChatMessages/index.d.ts +1 -0
  131. package/dist/esm/Layout/Chat/ChatMessages/index.js +1 -0
  132. package/dist/esm/Layout/Chat/ChatMessages/useLastMessageHeight.d.ts +8 -0
  133. package/dist/esm/Layout/Chat/ChatMessages/useLastMessageHeight.js +42 -0
  134. package/dist/esm/Layout/Chat/ChatPrompt/ChatPrompt.d.ts +91 -0
  135. package/dist/esm/Layout/Chat/ChatPrompt/ChatPrompt.js +137 -0
  136. package/dist/esm/Layout/Chat/ChatPrompt/ChatPrompt.styles.d.ts +61 -0
  137. package/dist/esm/Layout/Chat/ChatPrompt/ChatPrompt.styles.js +15 -0
  138. package/dist/esm/Layout/Chat/ChatPrompt/index.d.ts +1 -0
  139. package/dist/esm/Layout/Chat/ChatPrompt/index.js +1 -0
  140. package/dist/esm/Layout/Chat/ChatPrompt/useFocusTyping.d.ts +12 -0
  141. package/dist/esm/Layout/Chat/ChatPrompt/useFocusTyping.js +54 -0
  142. package/dist/esm/Layout/Chat/ChatPrompt/useTypewriter.d.ts +18 -0
  143. package/dist/esm/Layout/Chat/ChatPrompt/useTypewriter.js +71 -0
  144. package/dist/esm/Layout/Chat/index.d.ts +15 -0
  145. package/dist/esm/Layout/Chat/index.js +6 -0
  146. package/dist/esm/Layout/Chat/types.d.ts +7 -0
  147. package/dist/esm/Layout/Chat/types.js +1 -0
  148. package/dist/esm/Layout/index.d.ts +1 -0
  149. package/dist/esm/Layout/index.js +1 -0
  150. package/dist/esm/Satellite/locale.d.ts +7 -1
  151. package/dist/esm/styles/helpers/tv.d.ts +1 -0
  152. package/dist/esm/styles/helpers/tv.js +7 -0
  153. package/dist/esm/styles/tailwind.config.js +1 -1
  154. package/dist/esm/utils/getTextFromReactNode.d.ts +2 -1
  155. package/dist/esm/utils/getTextFromReactNode.js +13 -8
  156. package/dist/esm/utils/isCssPropertySupported.d.ts +1 -1
  157. package/dist/satellite.min.css +1 -1
  158. package/package.json +12 -3
@@ -0,0 +1,91 @@
1
+ import type { FormEvent, KeyboardEvent, ReactNode } from "react";
2
+ import type { TextAreaAutoSizeProps } from "../../../Fields/TextAreaAutoSize/TextAreaAutoSize";
3
+ import type { ChatStatus } from "../../../Layout/Chat/types";
4
+ export declare type ChatPromptLocale = {
5
+ textareaLabel?: string;
6
+ emptyMessageTooltip?: string;
7
+ stopResponseTooltip?: string;
8
+ sendMessageTooltip?: string;
9
+ };
10
+ export declare type ChatPromptProps = Omit<TextAreaAutoSizeProps, "onSubmit"> & {
11
+ /**
12
+ * Content to render above the textarea (e.g., a title or instructions).
13
+ */
14
+ renderHeader?: ReactNode;
15
+ /**
16
+ * Content to render below the textarea (e.g., additional controls or hints).
17
+ */
18
+ renderFooter?: ReactNode;
19
+ /**
20
+ * An optional array of placeholder strings to cycle through with a typewriter effect.
21
+ * If provided and non-empty, the component will use the dynamic, animated placeholder
22
+ * text instead of any static `placeholder` prop passed in.
23
+ */
24
+ placeholders?: string[];
25
+ /**
26
+ * The current status of the chat prompt submit button:
27
+ * - "submitted": The message has been sent to the API and we're awaiting the start of the response stream.
28
+ * - "streaming": The response is actively streaming in from the API, receiving chunks of data.
29
+ * - "ready": The full response has been received and processed; a new user message can be submitted.
30
+ * - "error": An error occurred during the API request, preventing successful completion.
31
+ */
32
+ status?: ChatStatus;
33
+ /**
34
+ * Whether to automatically focus the textarea when the user starts typing.
35
+ */
36
+ autoFocusOnTyping?: boolean;
37
+ /**
38
+ * Optional locale.
39
+ */
40
+ locale?: ChatPromptLocale;
41
+ /**
42
+ * Callback invoked when the user submits the form, either by clicking
43
+ * the submit button or pressing Enter (without Shift) inside the textarea.
44
+ */
45
+ onSubmit?: (e: KeyboardEvent<HTMLTextAreaElement> | FormEvent<HTMLFormElement>) => void;
46
+ /**
47
+ * Callback invoked when the user requests to stop the current chat response stream.
48
+ */
49
+ onStop?: () => void;
50
+ };
51
+ export declare const ChatPrompt: import("react").ForwardRefExoticComponent<Omit<TextAreaAutoSizeProps, "onSubmit"> & {
52
+ /**
53
+ * Content to render above the textarea (e.g., a title or instructions).
54
+ */
55
+ renderHeader?: ReactNode;
56
+ /**
57
+ * Content to render below the textarea (e.g., additional controls or hints).
58
+ */
59
+ renderFooter?: ReactNode;
60
+ /**
61
+ * An optional array of placeholder strings to cycle through with a typewriter effect.
62
+ * If provided and non-empty, the component will use the dynamic, animated placeholder
63
+ * text instead of any static `placeholder` prop passed in.
64
+ */
65
+ placeholders?: string[] | undefined;
66
+ /**
67
+ * The current status of the chat prompt submit button:
68
+ * - "submitted": The message has been sent to the API and we're awaiting the start of the response stream.
69
+ * - "streaming": The response is actively streaming in from the API, receiving chunks of data.
70
+ * - "ready": The full response has been received and processed; a new user message can be submitted.
71
+ * - "error": An error occurred during the API request, preventing successful completion.
72
+ */
73
+ status?: ChatStatus | undefined;
74
+ /**
75
+ * Whether to automatically focus the textarea when the user starts typing.
76
+ */
77
+ autoFocusOnTyping?: boolean | undefined;
78
+ /**
79
+ * Optional locale.
80
+ */
81
+ locale?: ChatPromptLocale | undefined;
82
+ /**
83
+ * Callback invoked when the user submits the form, either by clicking
84
+ * the submit button or pressing Enter (without Shift) inside the textarea.
85
+ */
86
+ onSubmit?: ((e: KeyboardEvent<HTMLTextAreaElement> | FormEvent<HTMLFormElement>) => void) | undefined;
87
+ /**
88
+ * Callback invoked when the user requests to stop the current chat response stream.
89
+ */
90
+ onStop?: (() => void) | undefined;
91
+ } & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ChatPrompt = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _lucideReact = require("lucide-react");
12
+ var _react = require("react");
13
+ var _ChatPrompt = require("./ChatPrompt.styles");
14
+ var _useFocusTyping = require("./useFocusTyping");
15
+ var _useTypewriter = require("./useTypewriter");
16
+ var _Actions = require("./../../../Actions");
17
+ var _TextAreaAutoSize = require("./../../../Fields/TextAreaAutoSize/TextAreaAutoSize");
18
+ var _Satellite = require("./../../../Satellite");
19
+ var _mergeRefs = require("./../../../utils/mergeRefs");
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ var _excluded = ["className", "renderHeader", "children", "renderFooter", "onSubmit", "onStop", "placeholder", "placeholders", "status", "autoFocusOnTyping", "defaultValue", "value", "locale"];
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ var DEFAULT_CHAT_PROMPT_LOCALE = {
25
+ textareaLabel: "Type your message...",
26
+ emptyMessageTooltip: "Message is empty",
27
+ stopResponseTooltip: "Stop response",
28
+ sendMessageTooltip: "Send message"
29
+ };
30
+ var ChatPrompt = exports.ChatPrompt = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, forwardedRef) {
31
+ var _ref2;
32
+ var className = _ref.className,
33
+ renderHeader = _ref.renderHeader,
34
+ children = _ref.children,
35
+ renderFooter = _ref.renderFooter,
36
+ onSubmit = _ref.onSubmit,
37
+ onStop = _ref.onStop,
38
+ staticPlaceholder = _ref.placeholder,
39
+ _ref$placeholders = _ref.placeholders,
40
+ placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
41
+ _ref$status = _ref.status,
42
+ status = _ref$status === void 0 ? "ready" : _ref$status,
43
+ autoFocusOnTyping = _ref.autoFocusOnTyping,
44
+ defaultValue = _ref.defaultValue,
45
+ valueProp = _ref.value,
46
+ propsLocale = _ref.locale,
47
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
48
+ var contextLocale = (0, _Satellite.useLocale)("chatPrompt");
49
+ var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CHAT_PROMPT_LOCALE), contextLocale), propsLocale);
50
+ var internalRef = (0, _react.useRef)(null);
51
+ var styles = (0, _ChatPrompt.chatPromptStyles)();
52
+ var _useState = (0, _react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""),
53
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
54
+ internalValue = _useState2[0],
55
+ setInternalValue = _useState2[1];
56
+ var isControlled = typeof valueProp !== "undefined";
57
+ var value = isControlled ? valueProp : internalValue;
58
+ var hasValue = typeof value === "string" ? value.trim() !== "" : !!value;
59
+ var canStop = status === "submitted" || status === "streaming";
60
+ var buttonDisabled = !hasValue && !canStop;
61
+ var dynamicPlaceholder = (0, _useTypewriter.useTypewriter)(placeholders, !hasValue);
62
+ var computedPlaceholder = placeholders.length > 0 ? dynamicPlaceholder : staticPlaceholder;
63
+ (0, _useFocusTyping.useFocusOnTyping)(internalRef, {
64
+ enabled: autoFocusOnTyping,
65
+ strictChars: true
66
+ });
67
+ var submit = function submit(e) {
68
+ e.preventDefault();
69
+ if (!hasValue || canStop) {
70
+ return;
71
+ }
72
+ onSubmit === null || onSubmit === void 0 || onSubmit(e);
73
+ };
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("form", {
75
+ className: styles.base(),
76
+ onSubmit: submit,
77
+ children: [!!renderHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
78
+ className: styles.header(),
79
+ children: renderHeader
80
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
81
+ className: styles.body(),
82
+ onClick: function onClick(e) {
83
+ var _internalRef$current;
84
+ if (e.target === internalRef.current) return;
85
+ (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 || _internalRef$current.focus();
86
+ },
87
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextAreaAutoSize.TextAreaAutoSize, _objectSpread(_objectSpread({
88
+ ref: (0, _mergeRefs.mergeRefs)([forwardedRef, internalRef]),
89
+ rows: 2,
90
+ maxRows: 8,
91
+ placeholder: computedPlaceholder,
92
+ value: value,
93
+ "aria-label": (_ref2 = placeholders[0] ? placeholders[0] : staticPlaceholder) !== null && _ref2 !== void 0 ? _ref2 : locale.textareaLabel,
94
+ translate: "no",
95
+ onInput: function onInput(e) {
96
+ var _props$onInput;
97
+ if (!isControlled) {
98
+ setInternalValue(e.currentTarget.value);
99
+ }
100
+ (_props$onInput = props.onInput) === null || _props$onInput === void 0 || _props$onInput.call(props, e);
101
+ }
102
+ }, props), {}, {
103
+ className: styles.textarea({
104
+ className: className
105
+ }),
106
+ onKeyDown: function onKeyDown(e) {
107
+ var _props$onKeyDown;
108
+ (_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 || _props$onKeyDown.call(props, e);
109
+ if (e.key === "Enter" && !e.shiftKey) {
110
+ submit(e);
111
+ }
112
+ if (e.key === "Escape") {
113
+ e.currentTarget.blur();
114
+ }
115
+ },
116
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
117
+ className: styles.actions(),
118
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Actions.IconButton, {
119
+ type: status === "ready" ? "submit" : undefined,
120
+ onClick: function onClick(e) {
121
+ if (canStop) {
122
+ e.preventDefault();
123
+ onStop === null || onStop === void 0 || onStop();
124
+ }
125
+ },
126
+ icon: canStop ? _lucideReact.CircleStopIcon : _lucideReact.ArrowUpIcon,
127
+ variant: canStop ? "neutral" : "primary",
128
+ size: "small",
129
+ title: buttonDisabled ? locale.emptyMessageTooltip : canStop ? locale.stopResponseTooltip : locale.sendMessageTooltip,
130
+ tooltipSide: "top",
131
+ disabled: buttonDisabled,
132
+ className: styles.submit()
133
+ })
134
+ })
135
+ }))
136
+ }), !!renderFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
137
+ className: styles.footer(),
138
+ children: renderFooter
139
+ })]
140
+ });
141
+ });
142
+ ChatPrompt.displayName = "ChatPrompt";
@@ -0,0 +1,61 @@
1
+ export declare const chatPromptStyles: import("tailwind-variants").TVReturnType<{
2
+ [key: string]: {
3
+ [key: string]: import("tailwind-merge").ClassNameValue | {
4
+ base?: import("tailwind-merge").ClassNameValue;
5
+ body?: import("tailwind-merge").ClassNameValue;
6
+ footer?: import("tailwind-merge").ClassNameValue;
7
+ header?: import("tailwind-merge").ClassNameValue;
8
+ textarea?: import("tailwind-merge").ClassNameValue;
9
+ submit?: import("tailwind-merge").ClassNameValue;
10
+ actions?: import("tailwind-merge").ClassNameValue;
11
+ };
12
+ };
13
+ } | {
14
+ [x: string]: {
15
+ [x: string]: import("tailwind-merge").ClassNameValue | {
16
+ base?: import("tailwind-merge").ClassNameValue;
17
+ body?: import("tailwind-merge").ClassNameValue;
18
+ footer?: import("tailwind-merge").ClassNameValue;
19
+ header?: import("tailwind-merge").ClassNameValue;
20
+ textarea?: import("tailwind-merge").ClassNameValue;
21
+ submit?: import("tailwind-merge").ClassNameValue;
22
+ actions?: import("tailwind-merge").ClassNameValue;
23
+ };
24
+ };
25
+ } | {}, {
26
+ base: string;
27
+ header: string;
28
+ body: string;
29
+ textarea: string;
30
+ actions: string;
31
+ submit: string;
32
+ footer: string;
33
+ }, undefined, {
34
+ [key: string]: {
35
+ [key: string]: import("tailwind-merge").ClassNameValue | {
36
+ base?: import("tailwind-merge").ClassNameValue;
37
+ body?: import("tailwind-merge").ClassNameValue;
38
+ footer?: import("tailwind-merge").ClassNameValue;
39
+ header?: import("tailwind-merge").ClassNameValue;
40
+ textarea?: import("tailwind-merge").ClassNameValue;
41
+ submit?: import("tailwind-merge").ClassNameValue;
42
+ actions?: import("tailwind-merge").ClassNameValue;
43
+ };
44
+ };
45
+ } | {}, {
46
+ base: string;
47
+ header: string;
48
+ body: string;
49
+ textarea: string;
50
+ actions: string;
51
+ submit: string;
52
+ footer: string;
53
+ }, import("tailwind-variants").TVReturnType<unknown, {
54
+ base: string;
55
+ header: string;
56
+ body: string;
57
+ textarea: string;
58
+ actions: string;
59
+ submit: string;
60
+ footer: string;
61
+ }, undefined, unknown, unknown, undefined>>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.chatPromptStyles = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _satellitePrefixer = _interopRequireDefault(require("./../../../styles/helpers/satellitePrefixer"));
10
+ var _tv = require("./../../../styles/helpers/tv");
11
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
12
+ var chatPromptStyles = exports.chatPromptStyles = (0, _tv.tv)({
13
+ slots: {
14
+ base: (0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["relative flex flex-col items-stretch gap-2 w-full"]))),
15
+ header: (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["flex items-center gap-1.5"]))),
16
+ body: (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""]))),
17
+ textarea: (0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["[&>textarea]:p-3 [&>textarea]:pb-0 [&>textarea]:thin-scrollbar"]))),
18
+ actions: (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["flex flex-row p-3 pt-2 justify-end cursor-text"]))),
19
+ submit: (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])([""]))),
20
+ footer: (0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["flex items-center justify-between gap-1.5"])))
21
+ }
22
+ });
@@ -0,0 +1 @@
1
+ export * from "./ChatPrompt";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ChatPrompt = require("./ChatPrompt");
7
+ Object.keys(_ChatPrompt).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ChatPrompt[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _ChatPrompt[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ declare type Editable = HTMLTextAreaElement | HTMLInputElement | HTMLElement;
3
+ interface Options {
4
+ enabled?: boolean;
5
+ strictChars?: boolean;
6
+ }
7
+ /**
8
+ * Focus `editableRef` the moment the user types anywhere on the page,
9
+ * *unless* their cursor is already inside an editable control.
10
+ */
11
+ export declare function useFocusOnTyping<E extends Editable = Editable>(editableRef: React.RefObject<E>, { enabled, strictChars }?: Options): void;
12
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useFocusOnTyping = useFocusOnTyping;
7
+ var _react = require("react");
8
+ var isTextualElement = function isTextualElement(el) {
9
+ if (el.isContentEditable) return true;
10
+ var tag = el.tagName.toUpperCase();
11
+ if (tag === "TEXTAREA") return true;
12
+ if (tag === "INPUT") {
13
+ // Empty `type` defaults to "text"
14
+ var t = (el.type || "text").toLowerCase();
15
+ return ["text", "search", "url", "email", "tel", "password", "number", "date", "datetime-local", "month", "week", "time"].includes(t);
16
+ }
17
+ return false;
18
+ };
19
+ var shouldFocusEditable = function shouldFocusEditable(target) {
20
+ var el = target;
21
+ if (!el) return true;
22
+ return !isTextualElement(el);
23
+ };
24
+
25
+ // e.g. <div contentEditable>
26
+
27
+ /**
28
+ * Focus `editableRef` the moment the user types anywhere on the page,
29
+ * *unless* their cursor is already inside an editable control.
30
+ */
31
+ function useFocusOnTyping(editableRef) {
32
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
33
+ _ref$enabled = _ref.enabled,
34
+ enabled = _ref$enabled === void 0 ? true : _ref$enabled,
35
+ _ref$strictChars = _ref.strictChars,
36
+ strictChars = _ref$strictChars === void 0 ? false : _ref$strictChars;
37
+ var handleKeyDown = (0, _react.useCallback)(function (e) {
38
+ if (!enabled || e.ctrlKey || e.altKey || e.metaKey || e.isComposing || e.repeat || (
39
+ // Printable-character test
40
+ strictChars ? !/^[A-Za-z0-9]$/.test(e.key) : e.key.length !== 1)) {
41
+ return;
42
+ }
43
+ var node = editableRef.current;
44
+ if (!node) return;
45
+ if (node.contains(document.activeElement)) return;
46
+ if (shouldFocusEditable(e.target)) {
47
+ node.focus();
48
+ }
49
+ }, [enabled, strictChars, editableRef]);
50
+ (0, _react.useEffect)(function () {
51
+ if (typeof window === "undefined") return; // SSR/test guard
52
+
53
+ window.addEventListener("keydown", handleKeyDown, {
54
+ passive: true
55
+ });
56
+ return function () {
57
+ return window.removeEventListener("keydown", handleKeyDown);
58
+ };
59
+ }, [handleKeyDown]);
60
+ }
@@ -0,0 +1,18 @@
1
+ export interface UseTypewriterOptions {
2
+ /**
3
+ * Milliseconds per character when typing.
4
+ * @default 150
5
+ */
6
+ typingSpeed?: number;
7
+ /**
8
+ * Milliseconds per character when deleting.
9
+ * @default 20
10
+ */
11
+ deletingSpeed?: number;
12
+ /**
13
+ * Milliseconds to pause after typing a full word before deleting.
14
+ * @default 1000
15
+ */
16
+ pauseDuration?: number;
17
+ }
18
+ export declare function useTypewriter(texts: string[], enabled?: boolean, options?: UseTypewriterOptions): string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useTypewriter = useTypewriter;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = require("react");
10
+ function useTypewriter(texts) {
11
+ var enabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
13
+ var _options$typingSpeed = options.typingSpeed,
14
+ typingSpeed = _options$typingSpeed === void 0 ? 150 : _options$typingSpeed,
15
+ _options$deletingSpee = options.deletingSpeed,
16
+ deletingSpeed = _options$deletingSpee === void 0 ? 20 : _options$deletingSpee,
17
+ _options$pauseDuratio = options.pauseDuration,
18
+ pauseDuration = _options$pauseDuratio === void 0 ? 1000 : _options$pauseDuratio;
19
+ var _useState = (0, _react.useState)(""),
20
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
21
+ currentText = _useState2[0],
22
+ setCurrentText = _useState2[1];
23
+ var _useState3 = (0, _react.useState)(false),
24
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
25
+ isDeleting = _useState4[0],
26
+ setIsDeleting = _useState4[1];
27
+ var _useState5 = (0, _react.useState)(0),
28
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
29
+ loopIndex = _useState6[0],
30
+ setLoopIndex = _useState6[1];
31
+ (0, _react.useEffect)(function () {
32
+ if (texts.length === 0 || !enabled) {
33
+ return;
34
+ }
35
+ var currentIndex = loopIndex % texts.length;
36
+ var fullText = texts[currentIndex];
37
+ var isFullWord = !isDeleting && currentText === fullText;
38
+ var isEmptyWord = isDeleting && currentText === "";
39
+ var nextText;
40
+ var delay;
41
+ if (isFullWord) {
42
+ // Just finished typing the full word: pause, then start deleting
43
+ nextText = fullText.substring(0, fullText.length - 1);
44
+ delay = pauseDuration;
45
+ } else if (isEmptyWord) {
46
+ // Just finished deleting the word: move to next word
47
+ nextText = "";
48
+ delay = typingSpeed;
49
+ } else {
50
+ // Normal typing or deleting behavior
51
+ if (isDeleting) {
52
+ nextText = fullText.substring(0, currentText.length - 1);
53
+ delay = deletingSpeed;
54
+ } else {
55
+ nextText = fullText.substring(0, currentText.length + 1);
56
+ delay = typingSpeed;
57
+ }
58
+ }
59
+ var timer = setTimeout(function () {
60
+ setCurrentText(nextText);
61
+ if (isFullWord) {
62
+ // Switch to deleting
63
+ setIsDeleting(true);
64
+ } else if (isEmptyWord) {
65
+ // Reset to typing next word
66
+ setIsDeleting(false);
67
+ setLoopIndex(function (prev) {
68
+ return prev + 1;
69
+ });
70
+ }
71
+ // Otherwise, keep the current isDeleting value
72
+ }, delay);
73
+ return function () {
74
+ return clearTimeout(timer);
75
+ };
76
+ }, [enabled, currentText, isDeleting, loopIndex, texts, typingSpeed, deletingSpeed, pauseDuration]);
77
+ return currentText;
78
+ }
@@ -0,0 +1,15 @@
1
+ export type { ChatMessageProps as ExperimentalChatMessageProps } from "./ChatMessage";
2
+ export { ChatMessage as ExperimentalChatMessage } from "./ChatMessage";
3
+ export type { ChatMessagesProps as ExperimentalChatMessagesProps, ChatMessageLocale as ExperimentalChatMessageLocale, } from "./ChatMessages";
4
+ export { ChatMessages as ExperimentalChatMessages } from "./ChatMessages";
5
+ export type { ChatPromptProps as ExperimentalChatPromptProps } from "./ChatPrompt";
6
+ export type { ChatPromptLocale as ExperimentalChatPromptLocale } from "./ChatPrompt";
7
+ export { ChatPrompt as ExperimentalChatPrompt } from "./ChatPrompt";
8
+ export type { ChatContextAccordionProps as ExperimentalChatContextAccordionProps } from "./ChatContextAccordion";
9
+ export { ChatContextAccordion as ExperimentalChatContextAccordion } from "./ChatContextAccordion";
10
+ export type { ChatMessageErrorLocale as ExperimentalChatMessageErrorLocale } from "./ChatMessageError";
11
+ export type { ChatMessageErrorProps as ExperimentalChatMessageErrorProps } from "./ChatMessageError";
12
+ export { ChatMessageError as ExperimentalChatMessageError } from "./ChatMessageError";
13
+ export type { ChatMessageLoaderProps as ExperimentalChatMessageLoaderProps } from "./ChatMessageLoader";
14
+ export { ChatMessageLoader as ExperimentalChatMessageLoader } from "./ChatMessageLoader";
15
+ export type { ChatMessageBase as ExperimentalChatMessageBase, ChatMessageRole as ExperimentalChatMessageRole, ChatStatus as ExperimentalChatStatus, } from "./types";
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ExperimentalChatContextAccordion", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _ChatContextAccordion.ChatContextAccordion;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ExperimentalChatMessage", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _ChatMessage.ChatMessage;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ExperimentalChatMessageError", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _ChatMessageError.ChatMessageError;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "ExperimentalChatMessageLoader", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _ChatMessageLoader.ChatMessageLoader;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "ExperimentalChatMessages", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _ChatMessages.ChatMessages;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "ExperimentalChatPrompt", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _ChatPrompt.ChatPrompt;
40
+ }
41
+ });
42
+ var _ChatMessage = require("./ChatMessage");
43
+ var _ChatMessages = require("./ChatMessages");
44
+ var _ChatPrompt = require("./ChatPrompt");
45
+ var _ChatContextAccordion = require("./ChatContextAccordion");
46
+ var _ChatMessageError = require("./ChatMessageError");
47
+ var _ChatMessageLoader = require("./ChatMessageLoader");
@@ -0,0 +1,7 @@
1
+ export declare type ChatMessageRole = "system" | "user" | "assistant" | "data";
2
+ export declare type ChatStatus = "submitted" | "streaming" | "ready" | "error";
3
+ export declare type ChatMessageBase = {
4
+ id: string;
5
+ role: ChatMessageRole;
6
+ content: string;
7
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,4 +1,5 @@
1
1
  export * from "./Card";
2
+ export * from "./Chat";
2
3
  export * from "./CollapsibleCard";
3
4
  export * from "./FlexGrid";
4
5
  export * from "./Insert";
@@ -14,6 +14,17 @@ Object.keys(_Card).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _Chat = require("./Chat");
18
+ Object.keys(_Chat).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _Chat[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _Chat[key];
25
+ }
26
+ });
27
+ });
17
28
  var _CollapsibleCard = require("./CollapsibleCard");
18
29
  Object.keys(_CollapsibleCard).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
@@ -3,11 +3,17 @@ import type { AutoCompleteLocale, DateInputLocale, DatePickerLocale, DropzoneLoc
3
3
  import type { AnnouncementBadgeLocale, TagLocale, ToastLocale, ToastsLocale } from "../Indicators";
4
4
  import type { UserAvatarLocale } from "../Indicators/Avatars";
5
5
  import type { DataTableLocale, SidebarLocale } from "../Layout";
6
+ import type { ChatMessageErrorLocale } from "../Layout/Chat/ChatMessageError";
7
+ import type { ChatMessageLocale } from "../Layout/Chat/ChatMessages";
8
+ import type { ChatPromptLocale } from "../Layout/Chat/ChatPrompt";
6
9
  import type { CompactPaginationLocale, DotPaginationLocale, PaginationLocale, StepperLocale } from "../Navigation";
7
10
  import type { ModalLocale, PopoverLocale } from "../Overlay";
8
11
  export declare type ComponentsLocales = {
9
12
  announcementBadge?: AnnouncementBadgeLocale;
10
13
  autoComplete?: AutoCompleteLocale;
14
+ chatMessage?: ChatMessageLocale;
15
+ chatMessageError?: ChatMessageErrorLocale;
16
+ chatPrompt?: ChatPromptLocale;
11
17
  compactPagination?: CompactPaginationLocale;
12
18
  dataTable?: DataTableLocale;
13
19
  dateInput?: DateInputLocale;
@@ -17,8 +23,8 @@ export declare type ComponentsLocales = {
17
23
  dropzone?: DropzoneLocale;
18
24
  filePicker?: FilePickerLocale;
19
25
  form?: ExperimentalFormLocale;
20
- input?: InputPropsLocale;
21
26
  iconButtonWithFeedback?: IconButtonWithFeedbackLocale;
27
+ input?: InputPropsLocale;
22
28
  modal?: ModalLocale;
23
29
  pagination?: PaginationLocale;
24
30
  popover?: PopoverLocale;
@@ -0,0 +1 @@
1
+ export declare const tv: import("tailwind-variants").CreateTV;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.tv = void 0;
7
+ var _tailwindVariants = require("tailwind-variants");
8
+ var tv = exports.tv = (0, _tailwindVariants.createTV)({
9
+ twMergeConfig: {
10
+ // eslint-disable-next-line @algolia/stl/prefer-stl-helper
11
+ prefix: "stl-"
12
+ }
13
+ });