@mitodl/smoot-design 0.0.0-7bc0c0f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +28 -0
- package/README.md +31 -0
- package/dist/bundles/remoteTutorDrawer.es.js +38347 -0
- package/dist/bundles/remoteTutorDrawer.umd.js +207 -0
- package/dist/cjs/ai.d.ts +3 -0
- package/dist/cjs/ai.js +5 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/FlashcardsScreen.js +87 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +276 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +283 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
- package/dist/cjs/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +241 -0
- package/dist/cjs/bundles/remoteTutorDrawer.d.ts +7 -0
- package/dist/cjs/bundles/remoteTutorDrawer.js +40 -0
- package/dist/cjs/components/AiChat/AiChat.d.ts +5 -0
- package/dist/cjs/components/AiChat/AiChat.js +247 -0
- package/dist/cjs/components/AiChat/AiChat.stories.d.ts +21 -0
- package/dist/cjs/components/AiChat/AiChat.stories.js +243 -0
- package/dist/cjs/components/AiChat/AiChat.test.d.ts +1 -0
- package/dist/cjs/components/AiChat/AiChat.test.js +211 -0
- package/dist/cjs/components/AiChat/ChatTitle.d.ts +8 -0
- package/dist/cjs/components/AiChat/ChatTitle.js +43 -0
- package/dist/cjs/components/AiChat/EntryScreen.d.ts +11 -0
- package/dist/cjs/components/AiChat/EntryScreen.js +123 -0
- package/dist/cjs/components/AiChat/TimLogo.d.ts +5 -0
- package/dist/cjs/components/AiChat/TimLogo.js +15 -0
- package/dist/cjs/components/AiChat/test-utils/api.d.ts +2 -0
- package/dist/cjs/components/AiChat/test-utils/api.js +125 -0
- package/dist/cjs/components/AiChat/types.d.ts +82 -0
- package/dist/cjs/components/AiChat/types.js +3 -0
- package/dist/cjs/components/AiChat/utils.d.ts +9 -0
- package/dist/cjs/components/AiChat/utils.js +41 -0
- package/dist/cjs/components/Alert/Alert.d.ts +15 -0
- package/dist/cjs/components/Alert/Alert.js +62 -0
- package/dist/cjs/components/Alert/Alert.stories.d.ts +8 -0
- package/dist/cjs/components/Alert/Alert.stories.js +53 -0
- package/dist/cjs/components/Button/ActionButton.d.ts +30 -0
- package/dist/cjs/components/Button/ActionButton.js +73 -0
- package/dist/cjs/components/Button/ActionButton.stories.d.ts +15 -0
- package/dist/cjs/components/Button/ActionButton.stories.js +113 -0
- package/dist/cjs/components/Button/Button.d.ts +54 -0
- package/dist/cjs/components/Button/Button.js +240 -0
- package/dist/cjs/components/Button/Button.stories.d.ts +17 -0
- package/dist/cjs/components/Button/Button.stories.js +135 -0
- package/dist/cjs/components/Button/Button.test.d.ts +1 -0
- package/dist/cjs/components/Button/Button.test.js +46 -0
- package/dist/cjs/components/ImageAdapter/ImageAdapter.d.ts +23 -0
- package/dist/cjs/components/ImageAdapter/ImageAdapter.js +30 -0
- package/dist/cjs/components/Input/Input.d.ts +116 -0
- package/dist/cjs/components/Input/Input.js +237 -0
- package/dist/cjs/components/Input/Input.stories.d.ts +19 -0
- package/dist/cjs/components/Input/Input.stories.js +135 -0
- package/dist/cjs/components/Input/Input.test.d.ts +1 -0
- package/dist/cjs/components/Input/Input.test.js +32 -0
- package/dist/cjs/components/LinkAdapter/LinkAdapter.d.ts +23 -0
- package/dist/cjs/components/LinkAdapter/LinkAdapter.js +34 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.d.ts +19 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.js +59 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
- package/dist/cjs/components/ScrollSnap/ScrollSnap.stories.js +43 -0
- package/dist/cjs/components/ScrollSnap/useScrollSnap.d.ts +6 -0
- package/dist/cjs/components/ScrollSnap/useScrollSnap.js +36 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.js +43 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.stories.js +44 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
- package/dist/cjs/components/SrAnnouncer/SrAnnouncer.test.js +62 -0
- package/dist/cjs/components/TabButtons/TabButtonList.d.ts +25 -0
- package/dist/cjs/components/TabButtons/TabButtonList.js +97 -0
- package/dist/cjs/components/TabButtons/TabButtonList.stories.d.ts +24 -0
- package/dist/cjs/components/TabButtons/TabButtonList.stories.js +139 -0
- package/dist/cjs/components/TextField/TextField.d.ts +29 -0
- package/dist/cjs/components/TextField/TextField.js +33 -0
- package/dist/cjs/components/TextField/TextField.stories.d.ts +10 -0
- package/dist/cjs/components/TextField/TextField.stories.js +136 -0
- package/dist/cjs/components/TextField/TextField.test.d.ts +1 -0
- package/dist/cjs/components/TextField/TextField.test.js +77 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.d.ts +21 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.js +86 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
- package/dist/cjs/components/ThemeProvider/ThemeProvider.stories.js +102 -0
- package/dist/cjs/components/ThemeProvider/Typography.stories.d.ts +39 -0
- package/dist/cjs/components/ThemeProvider/Typography.stories.js +65 -0
- package/dist/cjs/components/ThemeProvider/breakpoints.d.ts +4 -0
- package/dist/cjs/components/ThemeProvider/breakpoints.js +19 -0
- package/dist/cjs/components/ThemeProvider/buttons.d.ts +7 -0
- package/dist/cjs/components/ThemeProvider/buttons.js +20 -0
- package/dist/cjs/components/ThemeProvider/chips.d.ts +3 -0
- package/dist/cjs/components/ThemeProvider/chips.js +154 -0
- package/dist/cjs/components/ThemeProvider/colors.d.ts +32 -0
- package/dist/cjs/components/ThemeProvider/colors.js +35 -0
- package/dist/cjs/components/ThemeProvider/typography.d.ts +18 -0
- package/dist/cjs/components/ThemeProvider/typography.js +173 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.js +33 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
- package/dist/cjs/components/VisuallyHidden/VisuallyHidden.stories.js +13 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.js +78 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
- package/dist/cjs/components/internal/FormHelpers/FormHelpers.test.js +93 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/jest-setup.d.ts +1 -0
- package/dist/cjs/jest-setup.js +18 -0
- package/dist/cjs/jsdom-extended.d.ts +6 -0
- package/dist/cjs/jsdom-extended.js +14 -0
- package/dist/cjs/story-utils/index.d.ts +6 -0
- package/dist/cjs/story-utils/index.js +17 -0
- package/dist/cjs/utils/composeRefs.d.ts +7 -0
- package/dist/cjs/utils/composeRefs.js +20 -0
- package/dist/cjs/utils/composeRefs.test.d.ts +1 -0
- package/dist/cjs/utils/composeRefs.test.js +19 -0
- package/dist/cjs/utils/useDevCheckStable.d.ts +8 -0
- package/dist/cjs/utils/useDevCheckStable.js +29 -0
- package/dist/cjs/utils/useInterval.d.ts +7 -0
- package/dist/cjs/utils/useInterval.js +25 -0
- package/dist/esm/ai.d.ts +3 -0
- package/dist/esm/ai.js +1 -0
- package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/esm/bundles/RemoteTutorDrawer/FlashcardsScreen.js +83 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.d.ts +57 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.js +273 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts +16 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.stories.js +280 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts +1 -0
- package/dist/esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.js +239 -0
- package/dist/esm/bundles/remoteTutorDrawer.d.ts +7 -0
- package/dist/esm/bundles/remoteTutorDrawer.js +37 -0
- package/dist/esm/components/AiChat/AiChat.d.ts +5 -0
- package/dist/esm/components/AiChat/AiChat.js +244 -0
- package/dist/esm/components/AiChat/AiChat.stories.d.ts +21 -0
- package/dist/esm/components/AiChat/AiChat.stories.js +240 -0
- package/dist/esm/components/AiChat/AiChat.test.d.ts +1 -0
- package/dist/esm/components/AiChat/AiChat.test.js +209 -0
- package/dist/esm/components/AiChat/ChatTitle.d.ts +8 -0
- package/dist/esm/components/AiChat/ChatTitle.js +40 -0
- package/dist/esm/components/AiChat/EntryScreen.d.ts +11 -0
- package/dist/esm/components/AiChat/EntryScreen.js +120 -0
- package/dist/esm/components/AiChat/TimLogo.d.ts +5 -0
- package/dist/esm/components/AiChat/TimLogo.js +13 -0
- package/dist/esm/components/AiChat/test-utils/api.d.ts +2 -0
- package/dist/esm/components/AiChat/test-utils/api.js +122 -0
- package/dist/esm/components/AiChat/types.d.ts +82 -0
- package/dist/esm/components/AiChat/types.js +2 -0
- package/dist/esm/components/AiChat/utils.d.ts +9 -0
- package/dist/esm/components/AiChat/utils.js +38 -0
- package/dist/esm/components/Alert/Alert.d.ts +15 -0
- package/dist/esm/components/Alert/Alert.js +59 -0
- package/dist/esm/components/Alert/Alert.stories.d.ts +8 -0
- package/dist/esm/components/Alert/Alert.stories.js +50 -0
- package/dist/esm/components/Button/ActionButton.d.ts +30 -0
- package/dist/esm/components/Button/ActionButton.js +68 -0
- package/dist/esm/components/Button/ActionButton.stories.d.ts +15 -0
- package/dist/esm/components/Button/ActionButton.stories.js +110 -0
- package/dist/esm/components/Button/Button.d.ts +54 -0
- package/dist/esm/components/Button/Button.js +232 -0
- package/dist/esm/components/Button/Button.stories.d.ts +17 -0
- package/dist/esm/components/Button/Button.stories.js +132 -0
- package/dist/esm/components/Button/Button.test.d.ts +1 -0
- package/dist/esm/components/Button/Button.test.js +44 -0
- package/dist/esm/components/ImageAdapter/ImageAdapter.d.ts +23 -0
- package/dist/esm/components/ImageAdapter/ImageAdapter.js +27 -0
- package/dist/esm/components/Input/Input.d.ts +116 -0
- package/dist/esm/components/Input/Input.js +232 -0
- package/dist/esm/components/Input/Input.stories.d.ts +19 -0
- package/dist/esm/components/Input/Input.stories.js +132 -0
- package/dist/esm/components/Input/Input.test.d.ts +1 -0
- package/dist/esm/components/Input/Input.test.js +30 -0
- package/dist/esm/components/LinkAdapter/LinkAdapter.d.ts +23 -0
- package/dist/esm/components/LinkAdapter/LinkAdapter.js +31 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.d.ts +19 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.js +56 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.stories.d.ts +6 -0
- package/dist/esm/components/ScrollSnap/ScrollSnap.stories.js +40 -0
- package/dist/esm/components/ScrollSnap/useScrollSnap.d.ts +6 -0
- package/dist/esm/components/ScrollSnap/useScrollSnap.js +33 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.d.ts +25 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.js +40 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.d.ts +6 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.stories.js +41 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.d.ts +1 -0
- package/dist/esm/components/SrAnnouncer/SrAnnouncer.test.js +60 -0
- package/dist/esm/components/TabButtons/TabButtonList.d.ts +25 -0
- package/dist/esm/components/TabButtons/TabButtonList.js +92 -0
- package/dist/esm/components/TabButtons/TabButtonList.stories.d.ts +24 -0
- package/dist/esm/components/TabButtons/TabButtonList.stories.js +136 -0
- package/dist/esm/components/TextField/TextField.d.ts +29 -0
- package/dist/esm/components/TextField/TextField.js +30 -0
- package/dist/esm/components/TextField/TextField.stories.d.ts +10 -0
- package/dist/esm/components/TextField/TextField.stories.js +133 -0
- package/dist/esm/components/TextField/TextField.test.d.ts +1 -0
- package/dist/esm/components/TextField/TextField.test.js +75 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.d.ts +21 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.js +82 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.stories.d.ts +63 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.stories.js +99 -0
- package/dist/esm/components/ThemeProvider/Typography.stories.d.ts +39 -0
- package/dist/esm/components/ThemeProvider/Typography.stories.js +62 -0
- package/dist/esm/components/ThemeProvider/breakpoints.d.ts +4 -0
- package/dist/esm/components/ThemeProvider/breakpoints.js +15 -0
- package/dist/esm/components/ThemeProvider/buttons.d.ts +7 -0
- package/dist/esm/components/ThemeProvider/buttons.js +17 -0
- package/dist/esm/components/ThemeProvider/chips.d.ts +3 -0
- package/dist/esm/components/ThemeProvider/chips.js +151 -0
- package/dist/esm/components/ThemeProvider/colors.d.ts +32 -0
- package/dist/esm/components/ThemeProvider/colors.js +32 -0
- package/dist/esm/components/ThemeProvider/typography.d.ts +18 -0
- package/dist/esm/components/ThemeProvider/typography.js +167 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.d.ts +24 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.js +30 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
- package/dist/esm/components/VisuallyHidden/VisuallyHidden.stories.js +10 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.d.ts +39 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.js +73 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.test.d.ts +1 -0
- package/dist/esm/components/internal/FormHelpers/FormHelpers.test.js +91 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/jest-setup.d.ts +1 -0
- package/dist/esm/jest-setup.js +16 -0
- package/dist/esm/jsdom-extended.d.ts +6 -0
- package/dist/esm/jsdom-extended.js +12 -0
- package/dist/esm/story-utils/index.d.ts +6 -0
- package/dist/esm/story-utils/index.js +13 -0
- package/dist/esm/utils/composeRefs.d.ts +7 -0
- package/dist/esm/utils/composeRefs.js +17 -0
- package/dist/esm/utils/composeRefs.test.d.ts +1 -0
- package/dist/esm/utils/composeRefs.test.js +17 -0
- package/dist/esm/utils/useDevCheckStable.d.ts +8 -0
- package/dist/esm/utils/useDevCheckStable.js +26 -0
- package/dist/esm/utils/useInterval.d.ts +7 -0
- package/dist/esm/utils/useInterval.js +22 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/type-augmentation/TypescriptDocs.mdx +17 -0
- package/dist/type-augmentation/imports.d.ts +3 -0
- package/dist/type-augmentation/index.d.ts +3 -0
- package/dist/type-augmentation/theme.d.ts +105 -0
- package/dist/type-augmentation/typography.d.ts +54 -0
- package/package.json +155 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const React = require("react");
|
|
15
|
+
const react_1 = require("@testing-library/react");
|
|
16
|
+
const FormHelpers_1 = require("./FormHelpers");
|
|
17
|
+
const ThemeProvider_1 = require("../../../components/ThemeProvider/ThemeProvider");
|
|
18
|
+
const en_1 = require("@faker-js/faker/locale/en");
|
|
19
|
+
const assertDescription = ({ text, total, exists, }) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const input = react_1.screen.getByRole("textbox");
|
|
22
|
+
const describedBy = input.getAttribute("aria-describedby");
|
|
23
|
+
const descriptionIds = (_a = describedBy === null || describedBy === void 0 ? void 0 : describedBy.split(" ")) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
if (total === 0) {
|
|
25
|
+
expect(describedBy).toBe(null);
|
|
26
|
+
}
|
|
27
|
+
expect(descriptionIds.length).toBe(total);
|
|
28
|
+
const description = react_1.screen.queryByText(text);
|
|
29
|
+
expect(!!description).toBe(exists);
|
|
30
|
+
if (exists) {
|
|
31
|
+
expect(description).toBeInTheDocument();
|
|
32
|
+
expect(descriptionIds).toContain(description === null || description === void 0 ? void 0 : description.id);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
describe("FormFieldWrapper", () => {
|
|
36
|
+
const setup = (props) => {
|
|
37
|
+
const defaults = {
|
|
38
|
+
name: "test-name",
|
|
39
|
+
value: "test-value",
|
|
40
|
+
label: "test-label",
|
|
41
|
+
};
|
|
42
|
+
const { rerender: _rerender } = (0, react_1.render)(React.createElement(FormHelpers_1.FormFieldWrapper, Object.assign({}, defaults, props), (_a) => {
|
|
43
|
+
var { error, labelId, fullWidth } = _a, childProps = __rest(_a, ["error", "labelId", "fullWidth"]);
|
|
44
|
+
return (React.createElement("input", Object.assign({}, childProps)));
|
|
45
|
+
}), {
|
|
46
|
+
wrapper: ThemeProvider_1.ThemeProvider,
|
|
47
|
+
});
|
|
48
|
+
const rerender = (newProps) => {
|
|
49
|
+
_rerender(React.createElement(FormHelpers_1.FormFieldWrapper, Object.assign({}, defaults, newProps), (_a) => {
|
|
50
|
+
var { error, labelId, fullWidth } = _a, childProps = __rest(_a, ["error", "labelId", "fullWidth"]);
|
|
51
|
+
return (React.createElement("input", Object.assign({}, childProps)));
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
return { rerender };
|
|
55
|
+
};
|
|
56
|
+
it("Labels the input", () => {
|
|
57
|
+
const label = en_1.faker.lorem.words();
|
|
58
|
+
setup({ label });
|
|
59
|
+
const input = react_1.screen.getByRole("textbox", { name: label });
|
|
60
|
+
expect(input).toBeInstanceOf(HTMLInputElement);
|
|
61
|
+
});
|
|
62
|
+
it("Has a description only if description provided", () => {
|
|
63
|
+
const label = en_1.faker.lorem.words();
|
|
64
|
+
const helpText = en_1.faker.lorem.words();
|
|
65
|
+
const { rerender } = setup({ label, helpText });
|
|
66
|
+
assertDescription({ text: helpText, total: 1, exists: true });
|
|
67
|
+
rerender({ label });
|
|
68
|
+
assertDescription({ text: helpText, total: 0, exists: false });
|
|
69
|
+
});
|
|
70
|
+
it("Has an error message only if errorText provided AND error=true", () => {
|
|
71
|
+
const label = en_1.faker.lorem.words();
|
|
72
|
+
const errorText = en_1.faker.lorem.words();
|
|
73
|
+
const { rerender } = setup({ label, errorText, error: true });
|
|
74
|
+
assertDescription({ text: errorText, total: 1, exists: true });
|
|
75
|
+
rerender({ label, errorText });
|
|
76
|
+
assertDescription({ text: errorText, total: 0, exists: false });
|
|
77
|
+
rerender({ label, error: true });
|
|
78
|
+
assertDescription({ text: errorText, total: 0, exists: false });
|
|
79
|
+
rerender({ label, errorText, error: true });
|
|
80
|
+
assertDescription({ text: errorText, total: 1, exists: true });
|
|
81
|
+
});
|
|
82
|
+
it("Shows both description and errormessage if both provided and error", () => {
|
|
83
|
+
const label = en_1.faker.lorem.words();
|
|
84
|
+
const errorText = en_1.faker.lorem.words();
|
|
85
|
+
const helpText = en_1.faker.lorem.words();
|
|
86
|
+
const { rerender } = setup({ label, errorText, helpText });
|
|
87
|
+
assertDescription({ text: helpText, total: 1, exists: true });
|
|
88
|
+
assertDescription({ text: errorText, total: 1, exists: false });
|
|
89
|
+
rerender({ label, errorText, helpText, error: true });
|
|
90
|
+
assertDescription({ text: helpText, total: 2, exists: true });
|
|
91
|
+
assertDescription({ text: errorText, total: 2, exists: true });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default as styled } from "@emotion/styled";
|
|
2
|
+
export { css, Global } from "@emotion/react";
|
|
3
|
+
export { ThemeProvider, createTheme, } from "./components/ThemeProvider/ThemeProvider";
|
|
4
|
+
export { Button, ButtonLink } from "./components/Button/Button";
|
|
5
|
+
export type { ButtonProps, ButtonLinkProps } from "./components/Button/Button";
|
|
6
|
+
export { ActionButton, ActionButtonLink, } from "./components/Button/ActionButton";
|
|
7
|
+
export type { ActionButtonProps, ActionButtonLinkProps, } from "./components/Button/ActionButton";
|
|
8
|
+
export type { LinkAdapterPropsOverrides } from "./components/LinkAdapter/LinkAdapter";
|
|
9
|
+
export { Input } from "./components/Input/Input";
|
|
10
|
+
export type { InputProps } from "./components/Input/Input";
|
|
11
|
+
export { TextField } from "./components/TextField/TextField";
|
|
12
|
+
export type { TextFieldProps } from "./components/TextField/TextField";
|
|
13
|
+
export { SrAnnouncer } from "./components/SrAnnouncer/SrAnnouncer";
|
|
14
|
+
export type { SrAnnouncerProps } from "./components/SrAnnouncer/SrAnnouncer";
|
|
15
|
+
export { TabButton, TabButtonLink, TabButtonList, } from "./components/TabButtons/TabButtonList";
|
|
16
|
+
export { VisuallyHidden } from "./components/VisuallyHidden/VisuallyHidden";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.VisuallyHidden = exports.TabButtonList = exports.TabButtonLink = exports.TabButton = exports.SrAnnouncer = exports.TextField = exports.Input = exports.ActionButtonLink = exports.ActionButton = exports.ButtonLink = exports.Button = exports.createTheme = exports.ThemeProvider = exports.Global = exports.css = exports.styled = void 0;
|
|
5
|
+
var styled_1 = require("@emotion/styled");
|
|
6
|
+
Object.defineProperty(exports, "styled", { enumerable: true, get: function () { return styled_1.default; } });
|
|
7
|
+
var react_1 = require("@emotion/react");
|
|
8
|
+
Object.defineProperty(exports, "css", { enumerable: true, get: function () { return react_1.css; } });
|
|
9
|
+
Object.defineProperty(exports, "Global", { enumerable: true, get: function () { return react_1.Global; } });
|
|
10
|
+
var ThemeProvider_1 = require("./components/ThemeProvider/ThemeProvider");
|
|
11
|
+
Object.defineProperty(exports, "ThemeProvider", { enumerable: true, get: function () { return ThemeProvider_1.ThemeProvider; } });
|
|
12
|
+
Object.defineProperty(exports, "createTheme", { enumerable: true, get: function () { return ThemeProvider_1.createTheme; } });
|
|
13
|
+
var Button_1 = require("./components/Button/Button");
|
|
14
|
+
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return Button_1.Button; } });
|
|
15
|
+
Object.defineProperty(exports, "ButtonLink", { enumerable: true, get: function () { return Button_1.ButtonLink; } });
|
|
16
|
+
var ActionButton_1 = require("./components/Button/ActionButton");
|
|
17
|
+
Object.defineProperty(exports, "ActionButton", { enumerable: true, get: function () { return ActionButton_1.ActionButton; } });
|
|
18
|
+
Object.defineProperty(exports, "ActionButtonLink", { enumerable: true, get: function () { return ActionButton_1.ActionButtonLink; } });
|
|
19
|
+
var Input_1 = require("./components/Input/Input");
|
|
20
|
+
Object.defineProperty(exports, "Input", { enumerable: true, get: function () { return Input_1.Input; } });
|
|
21
|
+
var TextField_1 = require("./components/TextField/TextField");
|
|
22
|
+
Object.defineProperty(exports, "TextField", { enumerable: true, get: function () { return TextField_1.TextField; } });
|
|
23
|
+
var SrAnnouncer_1 = require("./components/SrAnnouncer/SrAnnouncer");
|
|
24
|
+
Object.defineProperty(exports, "SrAnnouncer", { enumerable: true, get: function () { return SrAnnouncer_1.SrAnnouncer; } });
|
|
25
|
+
var TabButtonList_1 = require("./components/TabButtons/TabButtonList");
|
|
26
|
+
Object.defineProperty(exports, "TabButton", { enumerable: true, get: function () { return TabButtonList_1.TabButton; } });
|
|
27
|
+
Object.defineProperty(exports, "TabButtonLink", { enumerable: true, get: function () { return TabButtonList_1.TabButtonLink; } });
|
|
28
|
+
Object.defineProperty(exports, "TabButtonList", { enumerable: true, get: function () { return TabButtonList_1.TabButtonList; } });
|
|
29
|
+
var VisuallyHidden_1 = require("./components/VisuallyHidden/VisuallyHidden");
|
|
30
|
+
Object.defineProperty(exports, "VisuallyHidden", { enumerable: true, get: function () { return VisuallyHidden_1.VisuallyHidden; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
5
|
+
const failOnConsole = require("jest-fail-on-console");
|
|
6
|
+
failOnConsole();
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
const scrollBy = jest.fn();
|
|
9
|
+
HTMLElement.prototype.scrollBy = scrollBy;
|
|
10
|
+
});
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
/**
|
|
13
|
+
* Clear all mock call counts between tests.
|
|
14
|
+
* This does NOT clear mock implementations.
|
|
15
|
+
* Mock implementations are always cleared between test files.
|
|
16
|
+
*/
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TestEnvironment } from "jest-environment-jsdom";
|
|
2
|
+
import { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
|
|
3
|
+
declare class JSDOMEnvironmentExtended extends TestEnvironment {
|
|
4
|
+
constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
|
|
5
|
+
}
|
|
6
|
+
export default JSDOMEnvironmentExtended;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Jest environment extended with Web APIs para tranbajar con MSW
|
|
4
|
+
const jest_environment_jsdom_1 = require("jest-environment-jsdom");
|
|
5
|
+
class JSDOMEnvironmentExtended extends jest_environment_jsdom_1.TestEnvironment {
|
|
6
|
+
constructor(config, context) {
|
|
7
|
+
super(config, context);
|
|
8
|
+
this.global.TransformStream = TransformStream;
|
|
9
|
+
this.global.ReadableStream = ReadableStream;
|
|
10
|
+
this.global.Response = Response;
|
|
11
|
+
this.global.TextDecoderStream = TextDecoderStream;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = JSDOMEnvironmentExtended;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type helper just to make sure an array contains union values.
|
|
3
|
+
*/
|
|
4
|
+
declare const enumValues: <T extends string | undefined>(obj: Record<NonNullable<T>, unknown>) => NonNullable<T>[];
|
|
5
|
+
declare const gitLink: (filepath: string) => string;
|
|
6
|
+
export { enumValues, gitLink };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gitLink = exports.enumValues = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A type helper just to make sure an array contains union values.
|
|
6
|
+
*/
|
|
7
|
+
const enumValues = (obj) => {
|
|
8
|
+
return Object.keys(obj);
|
|
9
|
+
};
|
|
10
|
+
exports.enumValues = enumValues;
|
|
11
|
+
const gitLink = (filepath) => {
|
|
12
|
+
if (!filepath.startsWith("src/")) {
|
|
13
|
+
throw new Error(`Invalid filepath: ${filepath}\nShould start with "src/"`);
|
|
14
|
+
}
|
|
15
|
+
return `https://github.com/mitodl/smoot-design/blob/${process.env.STORYBOOK_GIT_SHA}/${filepath}`;
|
|
16
|
+
};
|
|
17
|
+
exports.gitLink = gitLink;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MutableRefObject, ForwardedRef, RefCallback } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Compose 2+ refs. Useful when a reusable component needs a ref itself, but
|
|
4
|
+
* consumers may also need the ref.
|
|
5
|
+
*/
|
|
6
|
+
declare const composeRefs: <T>(...refs: (ForwardedRef<T> | MutableRefObject<T | undefined> | RefCallback<T>)[]) => RefCallback<T>;
|
|
7
|
+
export { composeRefs };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeRefs = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compose 2+ refs. Useful when a reusable component needs a ref itself, but
|
|
6
|
+
* consumers may also need the ref.
|
|
7
|
+
*/
|
|
8
|
+
const composeRefs = (...refs) => {
|
|
9
|
+
return (value) => {
|
|
10
|
+
refs.forEach((ref) => {
|
|
11
|
+
if (typeof ref === "function") {
|
|
12
|
+
ref(value);
|
|
13
|
+
}
|
|
14
|
+
else if (ref) {
|
|
15
|
+
ref.current = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.composeRefs = composeRefs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const composeRefs_1 = require("./composeRefs");
|
|
5
|
+
const react_1 = require("@testing-library/react");
|
|
6
|
+
describe("composeRefs", () => {
|
|
7
|
+
test("Composing object + fn ref", () => {
|
|
8
|
+
const objRef1 = React.createRef();
|
|
9
|
+
const objRef2 = React.createRef();
|
|
10
|
+
const fnRef1 = jest.fn();
|
|
11
|
+
const fnRef2 = jest.fn();
|
|
12
|
+
(0, react_1.render)(React.createElement("div", { "data-testid": "my-div", ref: (0, composeRefs_1.composeRefs)(objRef1, objRef2, fnRef1, fnRef2) }));
|
|
13
|
+
const el = react_1.screen.getByTestId("my-div");
|
|
14
|
+
expect(objRef1.current).toBe(el);
|
|
15
|
+
expect(objRef2.current).toBe(el);
|
|
16
|
+
expect(fnRef1).toHaveBeenCalledWith(el);
|
|
17
|
+
expect(fnRef2).toHaveBeenCalledWith(el);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits `console.error` if two subsequent values of `jsonSerializable` serialize
|
|
3
|
+
* to the same thing but are different references.
|
|
4
|
+
*
|
|
5
|
+
* This hook does NOT run in production.
|
|
6
|
+
*/
|
|
7
|
+
declare const useDevCheckStable: (jsonSerializable: unknown, msg?: string) => void;
|
|
8
|
+
export { useDevCheckStable };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDevCheckStable = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Emits `console.error` if two subsequent values of `jsonSerializable` serialize
|
|
7
|
+
* to the same thing but are different references.
|
|
8
|
+
*
|
|
9
|
+
* This hook does NOT run in production.
|
|
10
|
+
*/
|
|
11
|
+
const useDevCheckStable = (jsonSerializable, msg = "The value has changed. This may cause unnecessary re-renders") => {
|
|
12
|
+
if (process.env.NODE_ENV !== "production") {
|
|
13
|
+
/**
|
|
14
|
+
* Calling hooks conditionally based on env vars is not really a problem.
|
|
15
|
+
* In a given environment, the hook will always run or always not run.
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
18
|
+
const valRef = (0, react_1.useRef)(jsonSerializable);
|
|
19
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
const sameJson = JSON.stringify(valRef.current) === JSON.stringify(jsonSerializable);
|
|
22
|
+
const differentRefs = valRef.current !== jsonSerializable;
|
|
23
|
+
if (!sameJson || differentRefs) {
|
|
24
|
+
console.error(`useDevCheckStable: ${msg}`, valRef.current, jsonSerializable);
|
|
25
|
+
}
|
|
26
|
+
}, [jsonSerializable, msg]);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.useDevCheckStable = useDevCheckStable;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInterval = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Calls a function at a specified interval.
|
|
7
|
+
*
|
|
8
|
+
* Based on https://overreacted.io/making-setinterval-declarative-with-react-hooks/
|
|
9
|
+
*/
|
|
10
|
+
const useInterval = (callback, delay) => {
|
|
11
|
+
const savedCallback = (0, react_1.useRef)(null);
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
savedCallback.current = callback;
|
|
14
|
+
}, [callback]);
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
if (delay !== null) {
|
|
17
|
+
const id = setInterval(() => { var _a; return (_a = savedCallback.current) === null || _a === void 0 ? void 0 : _a.call(savedCallback); }, delay);
|
|
18
|
+
return () => clearInterval(id);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return () => { };
|
|
22
|
+
}
|
|
23
|
+
}, [delay]);
|
|
24
|
+
};
|
|
25
|
+
exports.useInterval = useInterval;
|
package/dist/esm/ai.d.ts
ADDED
package/dist/esm/ai.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AiChat } from "./components/AiChat/AiChat";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type Flashcard = {
|
|
3
|
+
question: string;
|
|
4
|
+
answer: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const FlashcardsScreen: ({ flashcards, wasKeyboardFocus, }: {
|
|
7
|
+
flashcards?: Flashcard[];
|
|
8
|
+
wasKeyboardFocus: boolean;
|
|
9
|
+
}) => React.JSX.Element | null;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ActionButton } from "../../components/Button/ActionButton";
|
|
2
|
+
import Typography from "@mui/material/Typography";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useState, useCallback, useEffect, useRef } from "react";
|
|
5
|
+
import styled from "@emotion/styled";
|
|
6
|
+
import { RiArrowRightLine, RiArrowLeftLine } from "@remixicon/react";
|
|
7
|
+
const Container = styled.div ``;
|
|
8
|
+
const FlashcardContainer = styled.div(({ theme }) => ({
|
|
9
|
+
display: "flex",
|
|
10
|
+
height: 300,
|
|
11
|
+
padding: 40,
|
|
12
|
+
flexDirection: "column",
|
|
13
|
+
justifyContent: "center",
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
alignSelf: "stretch",
|
|
16
|
+
borderRadius: 8,
|
|
17
|
+
border: `1px solid ${theme.custom.colors.lightGray2}`,
|
|
18
|
+
marginTop: "8px",
|
|
19
|
+
cursor: "pointer",
|
|
20
|
+
textAlign: "center",
|
|
21
|
+
}));
|
|
22
|
+
const Navigation = styled.div({
|
|
23
|
+
display: "flex",
|
|
24
|
+
justifyContent: "space-between",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
width: "100%",
|
|
27
|
+
marginTop: "24px",
|
|
28
|
+
});
|
|
29
|
+
const Page = styled.div(({ theme }) => (Object.assign({ color: theme.custom.colors.silverGrayDark }, theme.typography.body2)));
|
|
30
|
+
const Flashcard = React.forwardRef(({ content, "aria-label": ariaLabel }, ref) => {
|
|
31
|
+
const [screen, setScreen] = useState(0);
|
|
32
|
+
useEffect(() => setScreen(0), [content]);
|
|
33
|
+
const handleKeyDown = (e) => {
|
|
34
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
35
|
+
setScreen(screen === 0 ? 1 : 0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return (React.createElement(FlashcardContainer, { ref: ref, onClick: () => setScreen(screen === 0 ? 1 : 0), onKeyDown: handleKeyDown, tabIndex: 0, "aria-label": ariaLabel },
|
|
39
|
+
React.createElement(Typography, { variant: "h5" }, screen === 0 ? `Q: ${content.question}` : `Answer: ${content.answer}`)));
|
|
40
|
+
});
|
|
41
|
+
Flashcard.displayName = "Flashcard";
|
|
42
|
+
export const FlashcardsScreen = ({ flashcards, wasKeyboardFocus, }) => {
|
|
43
|
+
const [cardIndex, setCardIndex] = useState(0);
|
|
44
|
+
const containerRef = useRef(null);
|
|
45
|
+
const flashcardRef = useRef(null);
|
|
46
|
+
const handleKeyDown = useCallback((e) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!flashcards)
|
|
49
|
+
return;
|
|
50
|
+
if (!((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) &&
|
|
51
|
+
wasKeyboardFocus) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (e.key === "ArrowRight") {
|
|
55
|
+
setCardIndex((prevIndex) => (prevIndex + 1) % flashcards.length);
|
|
56
|
+
}
|
|
57
|
+
else if (e.key === "ArrowLeft") {
|
|
58
|
+
setCardIndex((prevIndex) => (prevIndex - 1 + flashcards.length) % flashcards.length);
|
|
59
|
+
}
|
|
60
|
+
}, [flashcards, wasKeyboardFocus]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
var _a;
|
|
63
|
+
(_a = flashcardRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
64
|
+
}, [cardIndex]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
67
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
68
|
+
}, [handleKeyDown]);
|
|
69
|
+
if (!(flashcards === null || flashcards === void 0 ? void 0 : flashcards.length)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return (React.createElement(Container, { ref: containerRef },
|
|
73
|
+
React.createElement(Flashcard, { ref: flashcardRef, content: flashcards[cardIndex], "aria-label": `Flashcard ${cardIndex + 1} of ${flashcards.length}` }),
|
|
74
|
+
React.createElement(Navigation, null,
|
|
75
|
+
React.createElement(ActionButton, { onClick: () => setCardIndex(cardIndex - 1), disabled: cardIndex === 0, variant: "secondary", color: "secondary", size: "small", "aria-label": "Previous card" },
|
|
76
|
+
React.createElement(RiArrowLeftLine, { "aria-hidden": true })),
|
|
77
|
+
React.createElement(Page, null,
|
|
78
|
+
cardIndex + 1,
|
|
79
|
+
" / ",
|
|
80
|
+
flashcards.length),
|
|
81
|
+
React.createElement(ActionButton, { onClick: () => setCardIndex(cardIndex + 1), disabled: cardIndex === flashcards.length - 1, variant: "secondary", color: "secondary", size: "small", "aria-label": "Next card" },
|
|
82
|
+
React.createElement(RiArrowRightLine, { "aria-hidden": true })))));
|
|
83
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { AiChatMessage } from "../../components/AiChat/types";
|
|
3
|
+
import type { AiChatProps } from "../../components/AiChat/AiChat";
|
|
4
|
+
type RemoteTutorDrawerInitMessage = {
|
|
5
|
+
type: "smoot-design::tutor-drawer-open";
|
|
6
|
+
payload: {
|
|
7
|
+
blockType?: "problem" | "video";
|
|
8
|
+
target?: string;
|
|
9
|
+
/**
|
|
10
|
+
* If the title begins "AskTIM", it is styled as the AskTIM logo.
|
|
11
|
+
*/
|
|
12
|
+
title?: string;
|
|
13
|
+
chat: {
|
|
14
|
+
chatId?: AiChatProps["chatId"];
|
|
15
|
+
conversationStarters?: AiChatProps["conversationStarters"];
|
|
16
|
+
initialMessages?: AiChatProps["initialMessages"];
|
|
17
|
+
apiUrl: AiChatProps["requestOpts"]["apiUrl"];
|
|
18
|
+
requestBody?: Record<string, unknown>;
|
|
19
|
+
entryScreenEnabled?: AiChatProps["entryScreenEnabled"];
|
|
20
|
+
entryScreenTitle?: AiChatProps["entryScreenTitle"];
|
|
21
|
+
};
|
|
22
|
+
summary?: {
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
type RemoteTutorDrawerProps = {
|
|
28
|
+
className?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The origin of the messages that will be received to open the chat.
|
|
31
|
+
* The drawer will ignore all message events not from this origin.
|
|
32
|
+
*/
|
|
33
|
+
messageOrigin: string;
|
|
34
|
+
/**
|
|
35
|
+
* Transform the body of the request before sending it to the server.
|
|
36
|
+
* Its result will be merged with the per-message requestBody opt, with
|
|
37
|
+
* transformBody taking precedence.
|
|
38
|
+
*
|
|
39
|
+
* *This cannot be supplied via message events since the function is not serializable.*
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
transformBody?: (messages: AiChatMessage[]) => Iterable<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch options to be passed to the fetch call.
|
|
45
|
+
*
|
|
46
|
+
* NOTE: By default, the credentials are set to "include" to enable thread-
|
|
47
|
+
* identifying cookies.
|
|
48
|
+
*/
|
|
49
|
+
fetchOpts?: AiChatProps["requestOpts"]["fetchOpts"];
|
|
50
|
+
/**
|
|
51
|
+
* Pass to target a specific drawer instance where multiple are on the page.
|
|
52
|
+
*/
|
|
53
|
+
target?: string;
|
|
54
|
+
};
|
|
55
|
+
declare const RemoteTutorDrawer: FC<RemoteTutorDrawerProps>;
|
|
56
|
+
export { RemoteTutorDrawer };
|
|
57
|
+
export type { RemoteTutorDrawerProps, RemoteTutorDrawerInitMessage };
|