@mitodl/smoot-design 0.0.0-0a23f44
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 +35 -0
- package/dist/bundles/aiDrawerManager.es.js +38832 -0
- package/dist/bundles/aiDrawerManager.es.js.map +1 -0
- package/dist/bundles/aiDrawerManager.umd.js +245 -0
- package/dist/bundles/aiDrawerManager.umd.js.map +1 -0
- package/dist/bundles/remoteTutorDrawer.es.js +38832 -0
- package/dist/bundles/remoteTutorDrawer.es.js.map +1 -0
- package/dist/bundles/remoteTutorDrawer.umd.js +245 -0
- package/dist/bundles/remoteTutorDrawer.umd.js.map +1 -0
- package/dist/cjs/VERSION.d.ts +12 -0
- package/dist/cjs/VERSION.js +15 -0
- package/dist/cjs/ai.d.ts +3 -0
- package/dist/cjs/ai.js +9 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawer.d.ts +55 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawer.js +262 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawer.stories.d.ts +17 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawer.stories.js +264 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.d.ts +12 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.js +51 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.stories.d.ts +6 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.stories.js +267 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.test.d.ts +1 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.test.js +245 -0
- package/dist/cjs/bundles/AiDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/cjs/bundles/AiDrawer/FlashcardsScreen.js +87 -0
- package/dist/cjs/bundles/aiDrawerManager.d.ts +6 -0
- package/dist/cjs/bundles/aiDrawerManager.js +44 -0
- package/dist/cjs/components/AiChat/AiChat.d.ts +5 -0
- package/dist/cjs/components/AiChat/AiChat.js +267 -0
- package/dist/cjs/components/AiChat/AiChat.stories.d.ts +17 -0
- package/dist/cjs/components/AiChat/AiChat.stories.js +194 -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/AiChatContext.d.ts +26 -0
- package/dist/cjs/components/AiChat/AiChatContext.js +106 -0
- package/dist/cjs/components/AiChat/AiChatContext.stories.d.ts +14 -0
- package/dist/cjs/components/AiChat/AiChatContext.stories.js +75 -0
- package/dist/cjs/components/AiChat/AiChatMarkdown.stories.d.ts +15 -0
- package/dist/cjs/components/AiChat/AiChatMarkdown.stories.js +282 -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/EllipsisIcon.d.ts +6 -0
- package/dist/cjs/components/AiChat/EllipsisIcon.js +17 -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/Markdown.d.ts +7 -0
- package/dist/cjs/components/AiChat/Markdown.js +14 -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 +164 -0
- package/dist/cjs/components/AiChat/types.d.ts +96 -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 +58 -0
- package/dist/cjs/components/Button/Button.js +261 -0
- package/dist/cjs/components/Button/Button.stories.d.ts +18 -0
- package/dist/cjs/components/Button/Button.stories.js +148 -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/Checkbox/Checkbox.d.ts +20 -0
- package/dist/cjs/components/Checkbox/Checkbox.js +85 -0
- package/dist/cjs/components/Checkbox/Checkbox.stories.d.ts +8 -0
- package/dist/cjs/components/Checkbox/Checkbox.stories.js +33 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.d.ts +21 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.js +43 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.stories.d.ts +8 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.stories.js +50 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.test.d.ts +1 -0
- package/dist/cjs/components/CheckboxChoiceField/CheckboxChoiceField.test.js +52 -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/RadioChoiceField/BooleanRadioChoiceField.stories.d.ts +6 -0
- package/dist/cjs/components/RadioChoiceField/BooleanRadioChoiceField.stories.js +47 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.d.ts +45 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.js +69 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.stories.d.ts +6 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.stories.js +55 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.test.d.ts +1 -0
- package/dist/cjs/components/RadioChoiceField/RadioChoiceField.test.js +53 -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 +25 -0
- package/dist/cjs/index.js +44 -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/retryingFetch.d.ts +19 -0
- package/dist/cjs/utils/retryingFetch.js +98 -0
- package/dist/cjs/utils/retryingFetch.test.d.ts +1 -0
- package/dist/cjs/utils/retryingFetch.test.js +48 -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/VERSION.d.ts +12 -0
- package/dist/esm/VERSION.js +12 -0
- package/dist/esm/ai.d.ts +3 -0
- package/dist/esm/ai.js +2 -0
- package/dist/esm/bundles/AiDrawer/AiDrawer.d.ts +55 -0
- package/dist/esm/bundles/AiDrawer/AiDrawer.js +259 -0
- package/dist/esm/bundles/AiDrawer/AiDrawer.stories.d.ts +17 -0
- package/dist/esm/bundles/AiDrawer/AiDrawer.stories.js +261 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.d.ts +12 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.js +48 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.stories.d.ts +6 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.stories.js +264 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.test.d.ts +1 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.test.js +243 -0
- package/dist/esm/bundles/AiDrawer/FlashcardsScreen.d.ts +9 -0
- package/dist/esm/bundles/AiDrawer/FlashcardsScreen.js +83 -0
- package/dist/esm/bundles/aiDrawerManager.d.ts +6 -0
- package/dist/esm/bundles/aiDrawerManager.js +41 -0
- package/dist/esm/components/AiChat/AiChat.d.ts +5 -0
- package/dist/esm/components/AiChat/AiChat.js +263 -0
- package/dist/esm/components/AiChat/AiChat.stories.d.ts +17 -0
- package/dist/esm/components/AiChat/AiChat.stories.js +191 -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/AiChatContext.d.ts +26 -0
- package/dist/esm/components/AiChat/AiChatContext.js +102 -0
- package/dist/esm/components/AiChat/AiChatContext.stories.d.ts +14 -0
- package/dist/esm/components/AiChat/AiChatContext.stories.js +72 -0
- package/dist/esm/components/AiChat/AiChatMarkdown.stories.d.ts +15 -0
- package/dist/esm/components/AiChat/AiChatMarkdown.stories.js +279 -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/EllipsisIcon.d.ts +6 -0
- package/dist/esm/components/AiChat/EllipsisIcon.js +15 -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/Markdown.d.ts +7 -0
- package/dist/esm/components/AiChat/Markdown.js +12 -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 +161 -0
- package/dist/esm/components/AiChat/types.d.ts +96 -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 +58 -0
- package/dist/esm/components/Button/Button.js +252 -0
- package/dist/esm/components/Button/Button.stories.d.ts +18 -0
- package/dist/esm/components/Button/Button.stories.js +145 -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/Checkbox/Checkbox.d.ts +20 -0
- package/dist/esm/components/Checkbox/Checkbox.js +81 -0
- package/dist/esm/components/Checkbox/Checkbox.stories.d.ts +8 -0
- package/dist/esm/components/Checkbox/Checkbox.stories.js +30 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.d.ts +21 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.js +40 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.stories.d.ts +8 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.stories.js +47 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.test.d.ts +1 -0
- package/dist/esm/components/CheckboxChoiceField/CheckboxChoiceField.test.js +50 -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/RadioChoiceField/BooleanRadioChoiceField.stories.d.ts +6 -0
- package/dist/esm/components/RadioChoiceField/BooleanRadioChoiceField.stories.js +44 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.d.ts +45 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.js +65 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.stories.d.ts +6 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.stories.js +52 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.test.d.ts +1 -0
- package/dist/esm/components/RadioChoiceField/RadioChoiceField.test.js +51 -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 +25 -0
- package/dist/esm/index.js +16 -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/retryingFetch.d.ts +19 -0
- package/dist/esm/utils/retryingFetch.js +96 -0
- package/dist/esm/utils/retryingFetch.test.d.ts +1 -0
- package/dist/esm/utils/retryingFetch.test.js +46 -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 +159 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { AiDrawerProps } from "./AiDrawer";
|
|
3
|
+
type AiDrawerManagerProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The origin of the messages that will be received to open the chat.
|
|
6
|
+
* The drawer will ignore all message events not from this origin.
|
|
7
|
+
*/
|
|
8
|
+
messageOrigin: string;
|
|
9
|
+
} & AiDrawerProps;
|
|
10
|
+
declare const AiDrawerManager: ({ className, messageOrigin, transformBody, fetchOpts, target, }: AiDrawerManagerProps) => React.JSX.Element;
|
|
11
|
+
export { AiDrawerManager };
|
|
12
|
+
export type { AiDrawerManagerProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiDrawerManager = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const AiDrawer_1 = require("./AiDrawer");
|
|
7
|
+
const better_react_mathjax_1 = require("better-react-mathjax");
|
|
8
|
+
const hashPayload = (payload) => {
|
|
9
|
+
const str = JSON.stringify(payload);
|
|
10
|
+
let hash = 5381;
|
|
11
|
+
for (let i = 0; i < str.length; i++) {
|
|
12
|
+
hash = (hash << 5) + hash + str.charCodeAt(i);
|
|
13
|
+
hash = hash & hash;
|
|
14
|
+
}
|
|
15
|
+
return Math.abs(hash).toString(36);
|
|
16
|
+
};
|
|
17
|
+
const AiDrawerManager = ({ className, messageOrigin, transformBody, fetchOpts, target, }) => {
|
|
18
|
+
const [drawerStates, setDrawerStates] = (0, react_1.useState)({});
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
const cb = (event) => {
|
|
21
|
+
if (event.origin !== messageOrigin) {
|
|
22
|
+
if (process.env.NODE_ENV === "development") {
|
|
23
|
+
console.warn(`AiDrawerManager: received message from unexpected origin: ${event.origin}`);
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if ([
|
|
28
|
+
"smoot-design::ai-drawer-open",
|
|
29
|
+
"smoot-design::tutor-drawer-open", // legacy
|
|
30
|
+
].includes(event.data.type)) {
|
|
31
|
+
const key = hashPayload(event.data.payload);
|
|
32
|
+
event.data.payload.chat.chatId = event.data.payload.chat.chatId || key;
|
|
33
|
+
setDrawerStates((prev) => (Object.assign(Object.assign({}, prev), { [key]: { key, open: false, payload: event.data.payload } })));
|
|
34
|
+
requestAnimationFrame(() => {
|
|
35
|
+
setDrawerStates((prev) => (Object.assign(Object.assign({}, prev), { [key]: Object.assign(Object.assign({}, prev[key]), { open: true }) })));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("message", cb);
|
|
40
|
+
return () => {
|
|
41
|
+
window.removeEventListener("message", cb);
|
|
42
|
+
};
|
|
43
|
+
}, [messageOrigin, target]);
|
|
44
|
+
if (Object.values(drawerStates).length === 0) {
|
|
45
|
+
return React.createElement("div", { "data-testid": "ai-drawer-manager-waiting" });
|
|
46
|
+
}
|
|
47
|
+
return (React.createElement(better_react_mathjax_1.MathJaxContext, null, Object.values(drawerStates).map(({ key, open, payload }) => (React.createElement(AiDrawer_1.AiDrawer, { key: key, className: className, transformBody: transformBody, fetchOpts: fetchOpts, payload: payload, open: open, onClose: () => {
|
|
48
|
+
setDrawerStates((prev) => (Object.assign(Object.assign({}, prev), { [key]: Object.assign(Object.assign({}, prev[key]), { open: false }) })));
|
|
49
|
+
} })))));
|
|
50
|
+
};
|
|
51
|
+
exports.AiDrawerManager = AiDrawerManager;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { AiDrawerManager } from "./AiDrawerManager";
|
|
3
|
+
declare const meta: Meta<typeof AiDrawerManager>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AiDrawerManager>;
|
|
6
|
+
export declare const AiDrawerManagerStory: Story;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiDrawerManagerStory = void 0;
|
|
4
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const tiny_invariant_1 = require("tiny-invariant");
|
|
7
|
+
const msw_1 = require("msw");
|
|
8
|
+
const api_1 = require("../../components/AiChat/test-utils/api");
|
|
9
|
+
const AiDrawerManager_1 = require("./AiDrawerManager");
|
|
10
|
+
const better_react_mathjax_1 = require("better-react-mathjax");
|
|
11
|
+
const TEST_API_STREAMING = "http://localhost:4567/streaming";
|
|
12
|
+
const CONTENT_FILE_URL = "http://localhost:4567/api/v1/contentfiles/?edx_module_id=1";
|
|
13
|
+
const INITIAL_MESSAGES = [
|
|
14
|
+
{
|
|
15
|
+
content: "Hi! What are you interested in learning about?",
|
|
16
|
+
role: "assistant",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
const STARTERS = [
|
|
20
|
+
{ content: "I'm interested in quantum computing" },
|
|
21
|
+
{ content: "I want to understand global warming. " },
|
|
22
|
+
{ content: "I am curious about AI applications for business" },
|
|
23
|
+
];
|
|
24
|
+
const buildIFrame = (payload) => (el) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (!el)
|
|
27
|
+
return;
|
|
28
|
+
const doc = el.contentDocument;
|
|
29
|
+
const parent = (_a = el.contentWindow) === null || _a === void 0 ? void 0 : _a.parent;
|
|
30
|
+
(0, tiny_invariant_1.default)(doc && parent);
|
|
31
|
+
const button = doc.createElement("button");
|
|
32
|
+
button.style["padding"] = "6px";
|
|
33
|
+
button.textContent = "Open drawer (send message to parent)";
|
|
34
|
+
doc.body.appendChild(button);
|
|
35
|
+
doc.body.style.fontFamily = "Nunito Sans, sans-serif";
|
|
36
|
+
doc.body.style.color = "#2e3438";
|
|
37
|
+
const div = doc.createElement("div");
|
|
38
|
+
doc.body.appendChild(div);
|
|
39
|
+
const p = doc.createElement("p");
|
|
40
|
+
p.textContent = "Message Data:";
|
|
41
|
+
div.appendChild(p);
|
|
42
|
+
const textarea = doc.createElement("textarea");
|
|
43
|
+
div.append(textarea);
|
|
44
|
+
textarea.style["display"] = "block";
|
|
45
|
+
textarea.style["width"] = "100%";
|
|
46
|
+
textarea.style["height"] = "500px";
|
|
47
|
+
const message = {
|
|
48
|
+
type: "smoot-design::tutor-drawer-open",
|
|
49
|
+
payload,
|
|
50
|
+
};
|
|
51
|
+
textarea.value = JSON.stringify(message, null, 2);
|
|
52
|
+
button.addEventListener("click", () => {
|
|
53
|
+
parent.postMessage(JSON.parse(textarea.value));
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const IFrame = ({ payload }) => {
|
|
57
|
+
return (React.createElement("iframe", { width: "100%", height: "600px", ref: buildIFrame(payload), title: "button frame" }));
|
|
58
|
+
};
|
|
59
|
+
const meta = {
|
|
60
|
+
title: "smoot-design/AI/AiDrawerManager",
|
|
61
|
+
component: AiDrawerManager_1.AiDrawerManager,
|
|
62
|
+
render: () => (React.createElement("div", { style: { fontFamily: "Nunito Sans, sans-serif", color: "#2e3438" } },
|
|
63
|
+
React.createElement("h3", null, "Tutor Bot"),
|
|
64
|
+
React.createElement(IFrame, { payload: {
|
|
65
|
+
blockType: "problem",
|
|
66
|
+
title: "AskTIM for help with Problem: Derivatives 1.1",
|
|
67
|
+
chat: {
|
|
68
|
+
apiUrl: TEST_API_STREAMING,
|
|
69
|
+
initialMessages: INITIAL_MESSAGES,
|
|
70
|
+
conversationStarters: STARTERS,
|
|
71
|
+
},
|
|
72
|
+
} }),
|
|
73
|
+
React.createElement("h3", null, "Tutor Bot with default initial messages"),
|
|
74
|
+
React.createElement(IFrame, { payload: {
|
|
75
|
+
blockType: "problem",
|
|
76
|
+
title: "AskTIM for help with Problem: Derivatives 1.1",
|
|
77
|
+
chat: {
|
|
78
|
+
apiUrl: TEST_API_STREAMING,
|
|
79
|
+
conversationStarters: STARTERS,
|
|
80
|
+
},
|
|
81
|
+
} }),
|
|
82
|
+
React.createElement("h3", null, "Tutor Bot with entry screen"),
|
|
83
|
+
React.createElement(IFrame, { payload: {
|
|
84
|
+
blockType: "problem",
|
|
85
|
+
chat: {
|
|
86
|
+
apiUrl: TEST_API_STREAMING,
|
|
87
|
+
initialMessages: INITIAL_MESSAGES,
|
|
88
|
+
conversationStarters: STARTERS,
|
|
89
|
+
entryScreenEnabled: true,
|
|
90
|
+
entryScreenTitle: "AskTIM about this problem",
|
|
91
|
+
},
|
|
92
|
+
} }),
|
|
93
|
+
React.createElement("h3", null, "Video Drawer"),
|
|
94
|
+
React.createElement("p", null, "The chat entry screen is shown by default for the video blocks Tutor drawer."),
|
|
95
|
+
React.createElement(IFrame, { payload: {
|
|
96
|
+
blockType: "video",
|
|
97
|
+
chat: {
|
|
98
|
+
apiUrl: TEST_API_STREAMING,
|
|
99
|
+
conversationStarters: STARTERS,
|
|
100
|
+
},
|
|
101
|
+
summary: {
|
|
102
|
+
apiUrl: CONTENT_FILE_URL,
|
|
103
|
+
},
|
|
104
|
+
} }),
|
|
105
|
+
React.createElement("h3", null, "Video Drawer Flashcard Conversation Starters"),
|
|
106
|
+
React.createElement("p", null,
|
|
107
|
+
"Where conversation starters are not provided, they will be selected at random from the returned flashcard questions or from",
|
|
108
|
+
React.createElement("code", null, " DEFAULT_VIDEO_STARTERS"),
|
|
109
|
+
" provided."),
|
|
110
|
+
React.createElement(IFrame, { payload: {
|
|
111
|
+
blockType: "video",
|
|
112
|
+
target: "starters-frame",
|
|
113
|
+
chat: {
|
|
114
|
+
apiUrl: TEST_API_STREAMING,
|
|
115
|
+
},
|
|
116
|
+
summary: {
|
|
117
|
+
apiUrl: CONTENT_FILE_URL,
|
|
118
|
+
},
|
|
119
|
+
} }),
|
|
120
|
+
React.createElement(better_react_mathjax_1.MathJaxContext, null,
|
|
121
|
+
React.createElement(AiDrawerManager_1.AiDrawerManager, { messageOrigin: "http://localhost:6006" })))),
|
|
122
|
+
};
|
|
123
|
+
exports.default = meta;
|
|
124
|
+
exports.AiDrawerManagerStory = {
|
|
125
|
+
args: {
|
|
126
|
+
target: "video-frame",
|
|
127
|
+
},
|
|
128
|
+
parameters: {
|
|
129
|
+
msw: {
|
|
130
|
+
handlers: [
|
|
131
|
+
msw_1.http.get(CONTENT_FILE_URL, () => {
|
|
132
|
+
return msw_1.HttpResponse.json(sampleResponse);
|
|
133
|
+
}),
|
|
134
|
+
...api_1.handlers,
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
// From https://api.rc.learn.mit.edu/api/v1/contentfiles/?edx_module_id=asset-v1%3AMITxT%2B3.012Sx%2B3T2024%2Btype%40asset%2Bblock%400cc53e11-1f91-4ed8-8bab-0d873db8cb90-en.srt
|
|
140
|
+
const sampleResponse = {
|
|
141
|
+
count: 1,
|
|
142
|
+
next: null,
|
|
143
|
+
previous: null,
|
|
144
|
+
results: [
|
|
145
|
+
{
|
|
146
|
+
id: 16649919,
|
|
147
|
+
run_id: 7462,
|
|
148
|
+
run_title: "Structure of Materials",
|
|
149
|
+
run_slug: null,
|
|
150
|
+
departments: [
|
|
151
|
+
{
|
|
152
|
+
department_id: "3",
|
|
153
|
+
name: "Materials Science and Engineering",
|
|
154
|
+
channel_url: "https://rc.learn.mit.edu/c/department/materials-science-and-engineering/",
|
|
155
|
+
school: {
|
|
156
|
+
id: 2,
|
|
157
|
+
name: "School of Engineering",
|
|
158
|
+
url: "https://engineering.mit.edu/",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
semester: null,
|
|
163
|
+
year: null,
|
|
164
|
+
topics: [
|
|
165
|
+
{
|
|
166
|
+
id: 732,
|
|
167
|
+
name: "Science & Math",
|
|
168
|
+
icon: "RiTestTubeLine",
|
|
169
|
+
parent: null,
|
|
170
|
+
channel_url: "https://rc.learn.mit.edu/c/topic/science-math/",
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: 734,
|
|
174
|
+
name: "Chemistry",
|
|
175
|
+
icon: "RiTestTubeLine",
|
|
176
|
+
parent: 732,
|
|
177
|
+
channel_url: "https://rc.learn.mit.edu/c/topic/chemistry/",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 748,
|
|
181
|
+
name: "Engineering",
|
|
182
|
+
icon: "RiRobot2Line",
|
|
183
|
+
parent: null,
|
|
184
|
+
channel_url: "https://rc.learn.mit.edu/c/topic/engineering/",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 755,
|
|
188
|
+
name: "Materials Science and Engineering",
|
|
189
|
+
icon: "RiRobot2Line",
|
|
190
|
+
parent: 748,
|
|
191
|
+
channel_url: "https://rc.learn.mit.edu/c/topic/materials-science-and-engineering/",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
key: "asset-v1:MITxT+3.012Sx+3T2024+type@asset+block@0cc53e11-1f91-4ed8-8bab-0d873db8cb90-en.srt",
|
|
195
|
+
uid: null,
|
|
196
|
+
title: null,
|
|
197
|
+
description: null,
|
|
198
|
+
url: null,
|
|
199
|
+
content_feature_type: [],
|
|
200
|
+
content_type: "file",
|
|
201
|
+
content: " So with this, we will conclude a discussion about the glasses. And I mentioned that there is another class of materials that we'll talk about that form amorphous materials, and they are called polymers. And one very important concept that we will introduce in terms of the polymers is called a random walk model. And it helps us to understand what is the structure of the polymers and how they look in different solvents, how they behave at different temperatures, et cetera. So you've probably heard about polymers. Some of you do know about the internal structure of the polymers. But the polymers, in general, are materials that are composed of individual units that are connected among each other to form relatively long chains. So the name itself comes from Latin that means many parts or units. So it simply means that one individual structural unit within the polymer is composed of many identical or different units. So there are many naturally occurring polymers. So for example, cotton, leather, rubber, wool, et cetera, they're all polymers. And what they all have again in common is that they have the structural units that they're interconnected among each other. There are many biopolymers, so DNA molecules, for example. They belong into the class of polymers simply because they have individual structural units that are connected in a relatively long chain. What we will mostly talk about are synthetic polymers. So these are the polymers that are man-made. And it turns out that they're mostly organic in composition. And I just gave you a couple of examples. So again, most of them are composed of hydrocarbons. They can have other elements, but again, mostly carbon and hydrogen. So one example that they would like to give you is ethylene. So the ethylene itself are two carbon atoms that they're connected among each other, and then each is surrounded by two hydrogen atoms. So this is a monomer, ethylene. if I make a polymer out of the structural unit, I will end up in polyethylene. So you've probably heard about this particular polymer. And its composition would be it is as follows. So you would, again, have carbon atoms that they're connected among each other. And they're surrounded by hydrogen atoms. And there would be many, many of them connected among each other. And again this would be my structural unit, or this would be my monomer. So the polyethylene would be, again, how I would typically write this is would be CH2 CH2, et cetera. And there would be n of them. And this n can be arbitrary. So we will see that there can be polyethylene polymers that are relatively short in the chain length, but some of them are relatively long. Another example would be vinyl chloride, or PVC in the polymer phase. So the vinyl chloride, again, the structure of the PVC would be that, again, you have carbon atoms that are connected among each other. You have hydrogen atoms that is surrounding one, but one has a chlorine atom. And this would be a monomer. And there would be, again, a number or n of these individual monitor units that would be connected among each other. And again, how we typically present this polymers is, again, we have individual units, or monomers, that are connected among each other in a relatively long chain. So this would be a relatively low molecular weight polymer, meaning that each polymer chain is relatively short. Or this would represent the high molecular weight polymer, meaning that the number of the monomer units is relatively high. So do you happen to know about what is the number of monomers in a typical polymer? What would be your guess? Here of we are drawing maybe 10 of them or maybe 30 of them. Yes? A couple thousands. Couple of thousands, that's right. So just to illustrate that fact, the molecular weight, typical molecular weight of a polymer would be, let's say, 10 to the fourth up to 10 to 15 grams per mole. And the molecular weight of an individual ethylene units would be C2 H2 is 28 grams per mole. So you can see that in individual polymer unit can have thousands and thousands of these individual monomer units. So these are very, very long chains. So how do we understand the structure of these materials when there are a number and number of these chains that are somehow forming the solid material? So to understand that we will represent polymers in a form that is shown here. So in other words, just to understand what this image here represents, if this was an example or representation of a polymer chain right-- these are just paper clips that they clip together-- if this is my monument, this would be a polymer chain. So if you have a material, if you have a solid material, if you have a piece of a polymer in the solid form, it's very, very unlikely, almost impossible to have this in a crystalline form where all of the chains are aligned like this. And they are periodically arranged in space. How this polymer units or polymer chains actually look like in this polymer is that they're somehow they form this type of a structure. So they are somehow clumped together, or they form as something that looks like a mess. So the question that we are trying to answer and that we will try to answer in the next couple of minutes is, how do we describe that mess? How do I describe whether the extension of this chain will be like this, or perhaps this chain will collapse completely like this? And this will strongly depend on the environment. For example, if you have a polymer in a specific solvent, how it behaves in that solvent and how far this chain extends in space will strongly depend on the interaction of that polymer with the solvent. But the main idea is that we are trying to quantify how far in space that chain expands. And to do that, we will use this random walk model that I will try to explain in the next couple of minutes. So the random walk model simply describes a set of steps that each monomer is taking. So this particular image shows a very, very long chain. And each individual component of this chain is a single monomer. So we are trying to quantify how this polymer chain behaves in space. So what we're doing is that we are describing a random walk model in which we are trying to make steps of individual monomers units, and we are trying to understand how they arrange in space. So you might be familiar with the random walk model, for example, from Brownian motion. So if you think about Brownian motion or how particles move in different liquids, you would use this random walk model. So it's a similar way how we describe, for example, diffusion of the atoms, et cetera. So one way to think about this is to have so-called a lattice random walk model, in which each unit, monomer unit is taking a step. So this arrow here will represent one monomer. So I'm going from the starting position to the end position of the monomer. And the lattice this random walk model would assume that each of these monomer units is making a specific steps in lattice. So this would be an example of a specific structure where, again, the lattice and the angle, where the length of this arrow, the monomer size, and the angle are fixed. So the angle is 90 degrees always. So in the lattice random walk model, the length of each step and the angle are fixed. And this would explain very well diffusion within a material-- So when you assume that each step has a very well-defined length and a very well-defined angle. On the other hand, in polymers, this angle is not necessarily fixed. So if I have one monomer unit, there is no reason to believe that the next monomer unit will be 90 degrees relatively to that first step. So we will develop something that is called variable angle of random walk model. So this is the variable angle of a random walk. Again, we are assuming that each step is, of the same length, which we'll call l. So the next monomer unit has the same length l, but it can have any angle relative to the first one. And so in this particular case, the length is fixed, but the angle is random. And this would be a very good example of a random walk model applied to polymers. ",
|
|
202
|
+
content_title: "",
|
|
203
|
+
content_author: null,
|
|
204
|
+
content_language: null,
|
|
205
|
+
image_src: null,
|
|
206
|
+
resource_id: "5124",
|
|
207
|
+
resource_readable_id: "course-v1:MITxT+3.012Sx",
|
|
208
|
+
course_number: ["course-v1:MITxT+3.012Sx"],
|
|
209
|
+
file_type: null,
|
|
210
|
+
file_extension: ".srt",
|
|
211
|
+
offered_by: {
|
|
212
|
+
code: "mitx",
|
|
213
|
+
name: "MITx",
|
|
214
|
+
channel_url: "https://rc.learn.mit.edu/c/unit/mitx/",
|
|
215
|
+
},
|
|
216
|
+
platform: {
|
|
217
|
+
code: "mitxonline",
|
|
218
|
+
name: "MITx Online",
|
|
219
|
+
},
|
|
220
|
+
run_readable_id: "course-v1:MITxT+3.012Sx+3T2024",
|
|
221
|
+
edx_module_id: "asset-v1:MITxT+3.012Sx+3T2024+type@asset+block@0cc53e11-1f91-4ed8-8bab-0d873db8cb90-en.srt",
|
|
222
|
+
summary: 'The video discusses polymers, a class of materials composed of long chains of interconnected structural units or monomers. Key points include:\n\n1. **Definition and Structure**: Polymers consist of many repeating units, which can be identical or different. They can be naturally occurring (like cotton and DNA) or synthetic (like polyethylene and PVC).\n\n2. **Monomers and Polymers**: Monomers are the individual units that make up polymers. For example, ethylene is a monomer that forms polyethylene when linked together. The molecular weight of polymers can be very high, often ranging from 10,000 to 10^15 grams per mole.\n\n3. **Random Walk Model**: This model is introduced to understand the structure and behavior of polymers in different environments. It describes how individual monomers take steps in space, akin to Brownian motion. \n\n4. **Lattice Random Walk vs. Variable Angle Random Walk**: The lattice model assumes fixed step lengths and angles, while the variable angle model allows for random angles between steps, better representing the behavior of polymer chains.\n\n5. **Impact of Environment**: The extension and arrangement of polymer chains depend on their interactions with solvents and environmental conditions, leading to a "messy" structure rather than a crystalline form.\n\nOverall, the video emphasizes the complexity and variability in the structure and behavior of polymers, which can be modeled using random walk principles.',
|
|
223
|
+
flashcards: [
|
|
224
|
+
{
|
|
225
|
+
answer: "The main topic is about polymers and their structure, particularly the random walk model.",
|
|
226
|
+
question: "What is the main topic discussed in the transcript regarding materials?",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
answer: "Polymers are materials composed of individual units connected to form long chains, derived from the Latin term meaning 'many parts or units'.",
|
|
230
|
+
question: "What does the term 'polymers' mean?",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
answer: "Examples of naturally occurring polymers include cotton, leather, rubber, and wool.",
|
|
234
|
+
question: "Can you name some naturally occurring polymers mentioned in the transcript?",
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
answer: "Synthetic polymers are man-made polymers, mostly organic in composition, primarily composed of hydrocarbons.",
|
|
238
|
+
question: "What is a synthetic polymer?",
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
answer: "The monomer for polyethylene is ethylene, which consists of two carbon atoms connected to each other, each surrounded by two hydrogen atoms.",
|
|
242
|
+
question: "What is the monomer for polyethylene?",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
answer: "The typical molecular weight of a polymer ranges from 10^4 to 10^15 grams per mole.",
|
|
246
|
+
question: "What is the typical molecular weight range for polymers?",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
answer: "The random walk model helps to describe how polymer chains behave in space and their arrangement in different environments.",
|
|
250
|
+
question: "What does the random walk model help to describe in polymers?",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
answer: "In the lattice random walk model, each step has a fixed length and angle (90 degrees), while in the variable angle random walk model, the length is fixed but the angle can vary.",
|
|
254
|
+
question: "How does the lattice random walk model differ from the variable angle random walk model?",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
answer: "An example of a polymer derived from vinyl chloride is PVC (polyvinyl chloride).",
|
|
258
|
+
question: "What is an example of a polymer mentioned that is derived from vinyl chloride?",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
answer: "The interactions of polymers with solvents strongly influence how far the polymer chain extends in space.",
|
|
262
|
+
question: "How do the interactions of polymers with solvents affect their behavior?",
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const react_1 = require("@testing-library/react");
|
|
13
|
+
const user_event_1 = require("@testing-library/user-event");
|
|
14
|
+
const AiDrawerManager_1 = require("./AiDrawerManager");
|
|
15
|
+
const ThemeProvider_1 = require("../../components/ThemeProvider/ThemeProvider");
|
|
16
|
+
const React = require("react");
|
|
17
|
+
const msw_1 = require("msw");
|
|
18
|
+
const node_1 = require("msw/node");
|
|
19
|
+
jest.mock("../../components/AiChat/Markdown", () => {
|
|
20
|
+
return {
|
|
21
|
+
__esModule: true,
|
|
22
|
+
default: ({ children }) => React.createElement("div", null, children),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
jest.mock("better-react-mathjax", () => ({
|
|
26
|
+
MathJaxContext: ({ children }) => (React.createElement(React.Fragment, null, children)),
|
|
27
|
+
}));
|
|
28
|
+
const TEST_API_STREAMING = "http://localhost:4567/test";
|
|
29
|
+
const CONTENT_FILE_URL = "http://localhost:4567/api/v1/contentfiles/1";
|
|
30
|
+
const CONTENT_RESPONSE = {
|
|
31
|
+
count: 1,
|
|
32
|
+
next: null,
|
|
33
|
+
previous: null,
|
|
34
|
+
results: [
|
|
35
|
+
{
|
|
36
|
+
id: 1,
|
|
37
|
+
summary: "This is a test summary",
|
|
38
|
+
flashcards: [
|
|
39
|
+
{
|
|
40
|
+
question: "Test question 1?",
|
|
41
|
+
answer: "Test answer 1",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
question: "Test question 2?",
|
|
45
|
+
answer: "Test answer 2",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
question: "Test question 3?",
|
|
49
|
+
answer: "Test answer 3",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
class MockResizeObserver {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.observe = jest.fn();
|
|
58
|
+
this.unobserve = jest.fn();
|
|
59
|
+
this.disconnect = jest.fn();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
global.ResizeObserver = MockResizeObserver;
|
|
63
|
+
describe("AiDrawerManager", () => {
|
|
64
|
+
const server = (0, node_1.setupServer)(msw_1.http.post(TEST_API_STREAMING, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
return msw_1.HttpResponse.text("AI Response");
|
|
66
|
+
})), msw_1.http.get(CONTENT_FILE_URL, () => {
|
|
67
|
+
return msw_1.HttpResponse.json(CONTENT_RESPONSE);
|
|
68
|
+
}));
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
jest.resetAllMocks();
|
|
71
|
+
});
|
|
72
|
+
afterEach(() => {
|
|
73
|
+
server.resetHandlers();
|
|
74
|
+
});
|
|
75
|
+
afterAll(() => server.close());
|
|
76
|
+
const setup = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
server.listen();
|
|
78
|
+
(0, react_1.render)(React.createElement(AiDrawerManager_1.AiDrawerManager, { messageOrigin: "http://localhost:6006" }), {
|
|
79
|
+
wrapper: ThemeProvider_1.ThemeProvider,
|
|
80
|
+
});
|
|
81
|
+
yield react_1.screen.findByTestId("ai-drawer-manager-waiting");
|
|
82
|
+
const event = new MessageEvent("message", {
|
|
83
|
+
data: message,
|
|
84
|
+
origin: "http://localhost:6006",
|
|
85
|
+
});
|
|
86
|
+
yield (0, react_1.act)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
window.dispatchEvent(event);
|
|
88
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
89
|
+
}));
|
|
90
|
+
});
|
|
91
|
+
test("Problem drawer opens showing title", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
yield setup({
|
|
93
|
+
type: "smoot-design::ai-drawer-open",
|
|
94
|
+
payload: {
|
|
95
|
+
blockType: "problem",
|
|
96
|
+
title: "Drawer Title",
|
|
97
|
+
chat: {
|
|
98
|
+
apiUrl: TEST_API_STREAMING,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
react_1.screen.getByRole("heading", { name: "Drawer Title" });
|
|
103
|
+
}));
|
|
104
|
+
test("Video drawer opens showing chat entry screen and tabs", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
yield setup({
|
|
106
|
+
type: "smoot-design::ai-drawer-open",
|
|
107
|
+
payload: {
|
|
108
|
+
blockType: "video",
|
|
109
|
+
chat: {
|
|
110
|
+
entryScreenTitle: "Entry screen title",
|
|
111
|
+
apiUrl: TEST_API_STREAMING,
|
|
112
|
+
conversationStarters: [
|
|
113
|
+
{ content: "Prompt 1" },
|
|
114
|
+
{ content: "Prompt 2" },
|
|
115
|
+
{ content: "Prompt 3" },
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
summary: {
|
|
119
|
+
apiUrl: CONTENT_FILE_URL,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
react_1.screen.getByText("Entry screen title");
|
|
124
|
+
react_1.screen.getByRole("tab", { name: "Chat" });
|
|
125
|
+
react_1.screen.getByRole("tab", { name: "Flashcards" });
|
|
126
|
+
react_1.screen.getByRole("tab", { name: "Summary" });
|
|
127
|
+
react_1.screen.getByRole("button", { name: "Prompt 1" });
|
|
128
|
+
react_1.screen.getByRole("button", { name: "Prompt 2" });
|
|
129
|
+
react_1.screen.getByRole("button", { name: "Prompt 3" });
|
|
130
|
+
}));
|
|
131
|
+
test("Video drawer chat entry screen selects starters from flashcards", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
yield setup({
|
|
133
|
+
type: "smoot-design::ai-drawer-open",
|
|
134
|
+
payload: {
|
|
135
|
+
blockType: "video",
|
|
136
|
+
chat: {
|
|
137
|
+
entryScreenTitle: "Entry screen title",
|
|
138
|
+
apiUrl: TEST_API_STREAMING,
|
|
139
|
+
},
|
|
140
|
+
summary: {
|
|
141
|
+
apiUrl: CONTENT_FILE_URL,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
react_1.screen.getByRole("button", { name: "Test question 1?" });
|
|
146
|
+
react_1.screen.getByRole("button", { name: "Test question 2?" });
|
|
147
|
+
react_1.screen.getByRole("button", { name: "Test question 3?" });
|
|
148
|
+
}));
|
|
149
|
+
test("Video drawer chat entry screen shows default starters where no flashcards are available", server.boundary(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
const contentResponse = JSON.parse(JSON.stringify(CONTENT_RESPONSE));
|
|
151
|
+
contentResponse.results[0].flashcards = null;
|
|
152
|
+
server.use(msw_1.http.get(CONTENT_FILE_URL, () => {
|
|
153
|
+
return msw_1.HttpResponse.json(contentResponse);
|
|
154
|
+
}));
|
|
155
|
+
yield setup({
|
|
156
|
+
type: "smoot-design::ai-drawer-open",
|
|
157
|
+
payload: {
|
|
158
|
+
blockType: "video",
|
|
159
|
+
chat: {
|
|
160
|
+
entryScreenTitle: "Entry screen title",
|
|
161
|
+
apiUrl: TEST_API_STREAMING,
|
|
162
|
+
},
|
|
163
|
+
summary: {
|
|
164
|
+
apiUrl: CONTENT_FILE_URL,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
react_1.screen.getByRole("button", {
|
|
169
|
+
name: "What are the most important concepts introduced in the video?",
|
|
170
|
+
});
|
|
171
|
+
react_1.screen.getByRole("button", {
|
|
172
|
+
name: "What examples are used to illustrate concepts covered in the video?",
|
|
173
|
+
});
|
|
174
|
+
react_1.screen.getByRole("button", {
|
|
175
|
+
name: "What are the key terms introduced in this video?",
|
|
176
|
+
});
|
|
177
|
+
})));
|
|
178
|
+
test("Video drawer chat entry screen displays default title", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
179
|
+
yield setup({
|
|
180
|
+
type: "smoot-design::ai-drawer-open",
|
|
181
|
+
payload: {
|
|
182
|
+
blockType: "video",
|
|
183
|
+
chat: {
|
|
184
|
+
apiUrl: TEST_API_STREAMING,
|
|
185
|
+
},
|
|
186
|
+
summary: {
|
|
187
|
+
apiUrl: CONTENT_FILE_URL,
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
react_1.screen.getByText("What do you want to know about this video?");
|
|
192
|
+
}));
|
|
193
|
+
test("Flashcard shows content and can be click navigated", server.boundary(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
+
yield setup({
|
|
195
|
+
type: "smoot-design::ai-drawer-open",
|
|
196
|
+
payload: {
|
|
197
|
+
blockType: "video",
|
|
198
|
+
chat: {
|
|
199
|
+
apiUrl: TEST_API_STREAMING,
|
|
200
|
+
},
|
|
201
|
+
summary: {
|
|
202
|
+
apiUrl: CONTENT_FILE_URL,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
yield user_event_1.default.click(react_1.screen.getByRole("tab", { name: "Flashcards" }));
|
|
207
|
+
yield user_event_1.default.click(react_1.screen.getByText("Q: Test question 1?"));
|
|
208
|
+
react_1.screen.getByText("Answer: Test answer 1");
|
|
209
|
+
yield user_event_1.default.click(react_1.screen.getByRole("button", { name: "Next card" }));
|
|
210
|
+
yield user_event_1.default.click(react_1.screen.getByText("Q: Test question 2?"));
|
|
211
|
+
react_1.screen.getByText("Answer: Test answer 2");
|
|
212
|
+
yield user_event_1.default.click(react_1.screen.getByRole("button", { name: "Previous card" }));
|
|
213
|
+
react_1.screen.getByText("Q: Test question 1?");
|
|
214
|
+
})));
|
|
215
|
+
test("Flashcard shows content and can be keyboard navigated and cycles", server.boundary(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
216
|
+
yield setup({
|
|
217
|
+
type: "smoot-design::ai-drawer-open",
|
|
218
|
+
payload: {
|
|
219
|
+
blockType: "video",
|
|
220
|
+
chat: {
|
|
221
|
+
apiUrl: TEST_API_STREAMING,
|
|
222
|
+
},
|
|
223
|
+
summary: {
|
|
224
|
+
apiUrl: CONTENT_FILE_URL,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
yield user_event_1.default.click(react_1.screen.getByRole("tab", { name: "Flashcards" }));
|
|
229
|
+
react_1.screen.getByText("Q: Test question 1?");
|
|
230
|
+
yield user_event_1.default.keyboard("{enter}");
|
|
231
|
+
react_1.screen.getByText("Answer: Test answer 1");
|
|
232
|
+
yield user_event_1.default.keyboard("{arrowright}");
|
|
233
|
+
react_1.screen.getByText("Q: Test question 2?");
|
|
234
|
+
yield user_event_1.default.keyboard("{enter}");
|
|
235
|
+
react_1.screen.getByText("Answer: Test answer 2");
|
|
236
|
+
yield user_event_1.default.keyboard("{arrowleft}");
|
|
237
|
+
react_1.screen.getByText("Q: Test question 1?");
|
|
238
|
+
yield user_event_1.default.keyboard("{arrowleft}");
|
|
239
|
+
react_1.screen.getByText("Q: Test question 3?");
|
|
240
|
+
yield user_event_1.default.keyboard("{arrowright}");
|
|
241
|
+
yield user_event_1.default.keyboard("{arrowright}");
|
|
242
|
+
yield user_event_1.default.keyboard("{arrowright}");
|
|
243
|
+
react_1.screen.getByText("Q: Test question 3?");
|
|
244
|
+
})));
|
|
245
|
+
});
|
|
@@ -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;
|