@swisper.ai/web-chat-ui 0.0.2 → 0.0.5
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/README.md +9 -12
- package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.d.ts +1 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
- package/dist/components/chat-card/contexts.d.ts +2 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -1
- package/dist/components/chat-card/hooks.d.ts +1 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -1
- package/dist/components/chat-card/types.d.ts +3 -0
- package/dist/components/chat-card/types.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.d.ts +30 -2
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-item.d.ts +6 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-items.d.ts +12 -1
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.d.ts +36 -2
- package/dist/components/chat-list/chat-list.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.d.ts +12 -1
- package/dist/components/chat-message/chat-message.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
- package/dist/components/chat-message/index.d.ts +1 -1
- package/dist/components/chat-message/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.d.ts +34 -2
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.d.ts +11 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/index.d.ts +1 -1
- package/dist/components/chat-reply/index.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
- package/dist/components/chat-suggestion/index.d.ts +2 -1
- package/dist/components/chat-suggestion/index.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.d.ts +17 -2
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/styled.d.ts +6 -2
- package/dist/components/rich-text-area/styled.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/index.d.ts +5 -5
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
- package/dist/components/topmenu/index.d.ts +2 -0
- package/dist/components/topmenu/index.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.d.ts +22 -0
- package/dist/components/topmenu/topmenu.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
- package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chat-panel.d.ts +7 -5
- package/dist/docs/chat-panel.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/docs/chatbot.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1801 -1806
- package/dist/index.es.js.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
- package/package.json +16 -10
- package/src/__storybook__/parent-block.tsx +21 -0
- package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
- package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
- package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
- package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
- package/src/components/canvas-shell/__stories__/types.ts +47 -0
- package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
- package/src/components/canvas-shell/canvas-shell.json +24 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
- package/src/components/canvas-shell/canvas-shell.tsx +44 -17
- package/src/components/chat-card/__stories__/fixtures.ts +119 -0
- package/src/components/chat-card/__stories__/types.ts +44 -0
- package/src/components/chat-card/chat-card.json +67 -3
- package/src/components/chat-card/chat-card.stories.tsx +872 -148
- package/src/components/chat-card/chat-card.tsx +2 -0
- package/src/components/chat-card/components/chat-card-body.tsx +12 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
- package/src/components/chat-card/components/chat-card-form.tsx +21 -2
- package/src/components/chat-card/components/chat-card-header.tsx +39 -2
- package/src/components/chat-card/contexts.tsx +2 -0
- package/src/components/chat-card/hooks.ts +1 -0
- package/src/components/chat-card/types.ts +3 -0
- package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
- package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
- package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
- package/src/components/chat-card-container/__stories__/types.ts +16 -0
- package/src/components/chat-card-container/chat-card-container.json +7 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
- package/src/components/chat-card-container/chat-card-container.tsx +5 -0
- package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
- package/src/components/chat-container/__stories__/fixtures.ts +27 -0
- package/src/components/chat-container/__stories__/measure.ts +22 -0
- package/src/components/chat-container/__stories__/types.ts +7 -0
- package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
- package/src/components/chat-container/chat-container.json +9 -1
- package/src/components/chat-container/chat-container.stories.tsx +538 -106
- package/src/components/chat-container/chat-container.tsx +3 -0
- package/src/components/chat-input/__stories__/fixtures.ts +31 -0
- package/src/components/chat-input/__tests__/chat-input.spec.tsx +100 -0
- package/src/components/chat-input/chat-input.json +11 -2
- package/src/components/chat-input/chat-input.stories.tsx +660 -197
- package/src/components/chat-input/chat-input.tsx +39 -5
- package/src/components/chat-input/plugins/controlled-value-plugin.tsx +16 -3
- package/src/components/chat-input/plugins/value-plugin.tsx +19 -4
- package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
- package/src/components/chat-list/__stories__/fixtures.ts +94 -0
- package/src/components/chat-list/__stories__/types.ts +13 -0
- package/src/components/chat-list/chat-list-item.tsx +6 -0
- package/src/components/chat-list/chat-list-items.tsx +16 -0
- package/src/components/chat-list/chat-list.json +24 -2
- package/src/components/chat-list/chat-list.stories.tsx +631 -215
- package/src/components/chat-list/chat-list.tsx +51 -4
- package/src/components/chat-message/__stories__/fixtures.ts +53 -0
- package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
- package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
- package/src/components/chat-message/chat-message.json +10 -1
- package/src/components/chat-message/chat-message.stories.tsx +282 -20
- package/src/components/chat-message/chat-message.tsx +16 -1
- package/src/components/chat-message/index.ts +8 -1
- package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
- package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
- package/src/components/chat-message-attachment-card/index.ts +6 -0
- package/src/components/chat-message-attachment-card/utils.ts +1 -0
- package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
- package/src/components/chat-message-response/chat-message-response.json +5 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
- package/src/components/chat-message-toolbar/index.ts +4 -0
- package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
- package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
- package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
- package/src/components/chat-messages/__stories__/types.ts +5 -0
- package/src/components/chat-messages/chat-messages.json +30 -12
- package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
- package/src/components/chat-messages/chat-messages.tsx +46 -3
- package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
- package/src/components/chat-notification-card/__stories__/types.ts +13 -0
- package/src/components/chat-notification-card/chat-notification-card.json +52 -2
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
- package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
- package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
- package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
- package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
- package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
- package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
- package/src/components/chat-reply/chat-reply.json +10 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
- package/src/components/chat-reply/chat-reply.tsx +15 -0
- package/src/components/chat-reply/index.ts +10 -1
- package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
- package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
- package/src/components/chat-suggestion/chat-suggestion.json +62 -20
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
- package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
- package/src/components/chat-suggestion/index.ts +9 -0
- package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
- package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
- package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
- package/src/components/chat-thread/__stories__/snippets.ts +129 -0
- package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
- package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
- package/src/components/chat-thread/__stories__/types.ts +12 -0
- package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
- package/src/components/chat-thread/chat-thread.json +23 -3
- package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
- package/src/components/chat-thread/chat-thread.tsx +64 -16
- package/src/components/index.ts +1 -3
- package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
- package/src/components/markdown-viewer/markdown-viewer.json +7 -1
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
- package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
- package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
- package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +114 -0
- package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +20 -3
- package/src/components/rich-text-area/plugins/value-plugin.tsx +16 -3
- package/src/components/rich-text-area/rich-text-area.json +7 -4
- package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
- package/src/components/rich-text-area/rich-text-area.tsx +27 -4
- package/src/components/rich-text-area/styled.tsx +11 -5
- package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
- package/src/components/rich-text-field/components/index.ts +8 -5
- package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
- package/src/components/rich-text-field/rich-text-field.json +3 -1
- package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
- package/src/components/rich-text-field/rich-text-field.tsx +23 -0
- package/src/components/topmenu/index.ts +1 -0
- package/src/components/topmenu/topmenu.json +107 -0
- package/src/components/topmenu/topmenu.stories.tsx +334 -0
- package/src/components/topmenu/topmenu.tsx +71 -0
- package/src/docs/agent.stories.tsx +16 -16
- package/src/docs/chat-panel.tsx +37 -32
- package/src/docs/chatbot-panel.tsx +11 -2
- package/src/docs/chatbot.mdx +17 -12
- package/src/docs/chatbot.stories.tsx +7 -8
- package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
- package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
- package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
- package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
- package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
- package/dist/components/card-item-picker/index.d.ts +0 -9
- package/dist/components/card-item-picker/index.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
- package/dist/components/chat-message-history/index.d.ts +0 -2
- package/dist/components/chat-message-history/index.d.ts.map +0 -1
- package/dist/components/spinner/index.d.ts +0 -2
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/spinner.d.ts +0 -9
- package/dist/components/spinner/spinner.d.ts.map +0 -1
- package/dist/components/spinner/spinner.stories.d.ts +0 -8
- package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
- package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
- package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
- package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
- package/src/components/card-item-picker/card-item-picker.json +0 -147
- package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
- package/src/components/card-item-picker/index.ts +0 -24
- package/src/components/chat-message-history/chat-message-history.json +0 -99
- package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
- package/src/components/chat-message-history/chat-message-history.tsx +0 -277
- package/src/components/chat-message-history/index.ts +0 -13
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.json +0 -73
- package/src/components/spinner/spinner.stories.tsx +0 -41
- package/src/components/spinner/spinner.tsx +0 -32
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { CardItemPickerList } from './card-item-picker-list';
|
|
2
|
-
export { CardItemPickerRow } from './card-item-picker-row';
|
|
3
|
-
export { CardItemPickerRowCheckbox, CardItemPickerRowContent, CardItemPickerRowDescription, CardItemPickerRowMedia, CardItemPickerRowTitle, } from './card-item-picker-row-parts';
|
|
4
|
-
export { useCardItemPickerListContext, useCardItemPickerRowContext, } from './card-item-picker-context';
|
|
5
|
-
export type { CardItemPickerListProps } from './card-item-picker-list';
|
|
6
|
-
export type { CardItemPickerRowProps } from './card-item-picker-row';
|
|
7
|
-
export type { CardItemPickerRowMediaProps, CardItemPickerRowContentProps, CardItemPickerRowTitleProps, CardItemPickerRowDescriptionProps, CardItemPickerRowCheckboxProps, } from './card-item-picker-row-parts';
|
|
8
|
-
export type { CardItemPickerValue, CardItemPickerOrientation } from './card-item-picker-context';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/card-item-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,YAAY,EACV,2BAA2B,EAC3B,6BAA6B,EAC7B,2BAA2B,EAC3B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { ScrollToBottom } from 'use-stick-to-bottom';
|
|
3
|
-
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
4
|
-
interface ChatMessageHistoryContextValue {
|
|
5
|
-
isCurrentScrollBottom: boolean;
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
isEmpty: boolean;
|
|
8
|
-
hasError: boolean;
|
|
9
|
-
scrollToLastMessage: ScrollToBottom;
|
|
10
|
-
}
|
|
11
|
-
export declare function useChatMessageHistoryContext(): ChatMessageHistoryContextValue;
|
|
12
|
-
export interface ChatMessageHistoryProps {
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
className?: string;
|
|
15
|
-
totalMessages: number;
|
|
16
|
-
isLoading?: boolean;
|
|
17
|
-
hasError?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare function ChatMessageHistory({ children, className, totalMessages, isLoading, hasError, }: ChatMessageHistoryProps): import('react').JSX.Element;
|
|
20
|
-
export interface ChatMessageHistoryListProps {
|
|
21
|
-
children: ReactNode;
|
|
22
|
-
className?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare const ChatMessageHistoryList: import('react').MemoExoticComponent<({ children, className, }: ChatMessageHistoryListProps) => import('react').JSX.Element>;
|
|
25
|
-
export interface ChatMessageHistoryEmptyStateProps {
|
|
26
|
-
children?: ReactNode;
|
|
27
|
-
className?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function ChatMessageHistoryEmptyState({ children, className, }: ChatMessageHistoryEmptyStateProps): import('react').JSX.Element | null;
|
|
30
|
-
export interface ChatMessageHistoryErrorStateProps {
|
|
31
|
-
children?: ReactNode;
|
|
32
|
-
error?: Error | string;
|
|
33
|
-
className?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare function ChatMessageHistoryErrorState({ children, error, className, }: ChatMessageHistoryErrorStateProps): import('react').JSX.Element | null;
|
|
36
|
-
export interface ChatMessageHistoryScrollButtonProps {
|
|
37
|
-
className?: string;
|
|
38
|
-
tooltip?: string;
|
|
39
|
-
}
|
|
40
|
-
export declare const ChatMessageHistoryScrollButton: import('react').MemoExoticComponent<({ className, tooltip, }: ChatMessageHistoryScrollButtonProps) => import('react').JSX.Element>;
|
|
41
|
-
interface ChatMessageHistoryScrollBarProps extends React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> {
|
|
42
|
-
className?: string;
|
|
43
|
-
orientation?: 'vertical' | 'horizontal';
|
|
44
|
-
children?: ReactNode;
|
|
45
|
-
}
|
|
46
|
-
export declare function ChatMessageHistoryScrollBar({ className, orientation, ...rest }: ChatMessageHistoryScrollBarProps): import('react').JSX.Element;
|
|
47
|
-
export {};
|
|
48
|
-
//# sourceMappingURL=chat-message-history.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message-history.d.ts","sourceRoot":"","sources":["../../../src/components/chat-message-history/chat-message-history.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EAAmC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM3F,UAAU,8BAA8B;IACtC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,mBAAmB,EAAE,cAAc,CAAC;CACrC;AAID,wBAAgB,4BAA4B,mCAU3C;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,SAAS,EACT,aAAa,EACb,SAAiB,EACjB,QAAgB,GACjB,EAAE,uBAAuB,+BA0DzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,iEAGhC,2BAA2B,iCAY5B,CAAC;AAEH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,QAAQ,EACR,SAAS,GACV,EAAE,iCAAiC,sCAkBnC;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,4BAA4B,CAAC,EAC3C,QAAQ,EACR,KAAK,EACL,SAAS,GACV,EAAE,iCAAiC,sCAsBnC;AAED,MAAM,WAAW,mCAAmC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,8BAA8B,gEAGxC,mCAAmC,iCAoCpC,CAAC;AAEH,UAAU,gCAAiC,SAAQ,KAAK,CAAC,cAAc,CACrE,OAAO,mBAAmB,CAAC,mBAAmB,CAC/C;IACC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,WAAwB,EACxB,GAAG,IAAI,EACR,EAAE,gCAAgC,+BA8BlC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { ChatMessageHistory } from './chat-message-history';
|
|
3
|
-
declare const meta: Meta<typeof ChatMessageHistory>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof ChatMessageHistory>;
|
|
6
|
-
export declare const Default: Story;
|
|
7
|
-
//# sourceMappingURL=chat-message-history.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message-history.stories.d.ts","sourceRoot":"","sources":["../../../src/components/chat-message-history/chat-message-history.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,EACL,kBAAkB,EAGnB,MAAM,wBAAwB,CAAC;AA4ChC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,kBAAkB,CAgDzC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjD,eAAO,MAAM,OAAO,EAAE,KA2BrB,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { useChatMessageHistoryContext, ChatMessageHistory, ChatMessageHistoryEmptyState, ChatMessageHistoryErrorState, ChatMessageHistoryList, ChatMessageHistoryScrollButton, type ChatMessageHistoryProps, type ChatMessageHistoryEmptyStateProps, type ChatMessageHistoryErrorStateProps, type ChatMessageHistoryListProps, type ChatMessageHistoryScrollButtonProps, } from './chat-message-history';
|
|
2
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/chat-message-history/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,sBAAsB,EACtB,8BAA8B,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACtC,KAAK,2BAA2B,EAChC,KAAK,mCAAmC,GACzC,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/spinner/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type Size = 'sm' | 'md' | 'lg' | 'xl';
|
|
2
|
-
export declare const SOURCE_ANIMATION = "https://lottie.host/444a46a4-65b4-4483-b3a8-675160a79dad/LgQ8IVLAzA.lottie";
|
|
3
|
-
export interface SpinnerProps {
|
|
4
|
-
size?: Size;
|
|
5
|
-
autoplay?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function Spinner({ size, autoplay }: SpinnerProps): import('react').JSX.Element;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAIA,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtC,eAAO,MAAM,gBAAgB,+EACiD,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAW,EAAE,QAAe,EAAE,EAAE,YAAY,+BAiBrE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { Spinner } from './spinner';
|
|
3
|
-
declare const meta: Meta<typeof Spinner>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof Spinner>;
|
|
6
|
-
export declare const Default: Story;
|
|
7
|
-
export declare const Playground: Story;
|
|
8
|
-
//# sourceMappingURL=spinner.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.stories.d.ts","sourceRoot":"","sources":["../../../src/components/spinner/spinner.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,OAAO,CA6B9B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,UAAU,EAAE,KAAU,CAAC"}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
CardItemPickerList,
|
|
6
|
-
CardItemPickerRow,
|
|
7
|
-
CardItemPickerRowCheckbox,
|
|
8
|
-
CardItemPickerRowContent,
|
|
9
|
-
CardItemPickerRowDescription,
|
|
10
|
-
CardItemPickerRowTitle,
|
|
11
|
-
type CardItemPickerOrientation,
|
|
12
|
-
} from '..';
|
|
13
|
-
|
|
14
|
-
const CITIES = ['Zurich', 'Geneva', 'Basel'];
|
|
15
|
-
|
|
16
|
-
function renderList({
|
|
17
|
-
value = null,
|
|
18
|
-
hoveredValue = null,
|
|
19
|
-
orientation,
|
|
20
|
-
onValueChange = vi.fn(),
|
|
21
|
-
onHoverChange = vi.fn(),
|
|
22
|
-
}: {
|
|
23
|
-
value?: string | null;
|
|
24
|
-
hoveredValue?: string | null;
|
|
25
|
-
orientation?: CardItemPickerOrientation;
|
|
26
|
-
onValueChange?: (value: string) => void;
|
|
27
|
-
onHoverChange?: (value: string | null) => void;
|
|
28
|
-
} = {}) {
|
|
29
|
-
return render(
|
|
30
|
-
<CardItemPickerList
|
|
31
|
-
aria-label="Cities"
|
|
32
|
-
value={value}
|
|
33
|
-
hoveredValue={hoveredValue}
|
|
34
|
-
orientation={orientation}
|
|
35
|
-
onValueChange={onValueChange}
|
|
36
|
-
onHoverChange={onHoverChange}
|
|
37
|
-
>
|
|
38
|
-
{CITIES.map((city) => (
|
|
39
|
-
<CardItemPickerRow key={city} value={city}>
|
|
40
|
-
<CardItemPickerRowContent>
|
|
41
|
-
<CardItemPickerRowTitle>{city}</CardItemPickerRowTitle>
|
|
42
|
-
<CardItemPickerRowDescription>{`${city} is in Switzerland`}</CardItemPickerRowDescription>
|
|
43
|
-
</CardItemPickerRowContent>
|
|
44
|
-
</CardItemPickerRow>
|
|
45
|
-
))}
|
|
46
|
-
</CardItemPickerList>,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function options() {
|
|
51
|
-
return screen.getAllByRole('option');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function tabStops() {
|
|
55
|
-
return options().filter((option) => option.tabIndex === 0);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
cleanup();
|
|
60
|
-
vi.restoreAllMocks();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('semantics', () => {
|
|
64
|
-
test('is a named listbox of options named by their titles', () => {
|
|
65
|
-
renderList();
|
|
66
|
-
|
|
67
|
-
expect(screen.getByRole('listbox', { name: 'Cities' })).not.toBeNull();
|
|
68
|
-
expect(options().map((option) => option.getAttribute('aria-labelledby'))).not.toContain(null);
|
|
69
|
-
expect(screen.getByRole('option', { name: 'Geneva' })).not.toBeNull();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('describes each option by its description', () => {
|
|
73
|
-
renderList();
|
|
74
|
-
|
|
75
|
-
const geneva = screen.getByRole('option', { name: 'Geneva' });
|
|
76
|
-
const description = document.getElementById(geneva.getAttribute('aria-describedby')!);
|
|
77
|
-
expect(description?.textContent).toBe('Geneva is in Switzerland');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('marks only the selected option as selected', () => {
|
|
81
|
-
renderList({ value: 'Basel' });
|
|
82
|
-
|
|
83
|
-
expect(options().map((option) => option.getAttribute('aria-selected'))).toEqual([
|
|
84
|
-
'false',
|
|
85
|
-
'false',
|
|
86
|
-
'true',
|
|
87
|
-
]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('parts throw outside their parents', () => {
|
|
91
|
-
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
92
|
-
|
|
93
|
-
expect(() => render(<CardItemPickerRow value="x" />)).toThrow(/within a CardItemPickerList/);
|
|
94
|
-
expect(() => render(<CardItemPickerRowTitle>x</CardItemPickerRowTitle>)).toThrow(
|
|
95
|
-
/within a CardItemPickerRow/,
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('checkbox', () => {
|
|
101
|
-
function renderWithCheckbox(value: string | null, onValueChange = vi.fn()) {
|
|
102
|
-
render(
|
|
103
|
-
<CardItemPickerList aria-label="Cities" value={value} onValueChange={onValueChange}>
|
|
104
|
-
{CITIES.map((city) => (
|
|
105
|
-
<CardItemPickerRow key={city} value={city}>
|
|
106
|
-
<CardItemPickerRowTitle>{city}</CardItemPickerRowTitle>
|
|
107
|
-
<CardItemPickerRowCheckbox />
|
|
108
|
-
</CardItemPickerRow>
|
|
109
|
-
))}
|
|
110
|
-
</CardItemPickerList>,
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
test('mirrors the selection, hidden from assistive tech and out of the tab order', () => {
|
|
115
|
-
renderWithCheckbox('Geneva');
|
|
116
|
-
|
|
117
|
-
const boxes = screen.getAllByTestId('checkbox');
|
|
118
|
-
expect(boxes.map((box) => box.getAttribute('data-state'))).toEqual([
|
|
119
|
-
'unchecked',
|
|
120
|
-
'checked',
|
|
121
|
-
'unchecked',
|
|
122
|
-
]);
|
|
123
|
-
expect(boxes.every((box) => box.tabIndex === -1)).toBe(true);
|
|
124
|
-
expect(screen.queryAllByRole('checkbox')).toEqual([]);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('sits in the top-right corner', () => {
|
|
128
|
-
renderWithCheckbox(null);
|
|
129
|
-
|
|
130
|
-
expect(screen.getAllByTestId('card-item-picker-row-checkbox')[0].className).toContain(
|
|
131
|
-
'absolute top-[8px] right-[8px]',
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('selection', () => {
|
|
137
|
-
test('a click picks the card', () => {
|
|
138
|
-
const onValueChange = vi.fn();
|
|
139
|
-
renderList({ onValueChange });
|
|
140
|
-
|
|
141
|
-
fireEvent.click(screen.getByRole('option', { name: 'Geneva' }));
|
|
142
|
-
|
|
143
|
-
expect(onValueChange).toHaveBeenCalledWith('Geneva');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test.each(['Enter', ' '])('%j picks the focused card', (key) => {
|
|
147
|
-
const onValueChange = vi.fn();
|
|
148
|
-
renderList({ onValueChange });
|
|
149
|
-
|
|
150
|
-
fireEvent.keyDown(screen.getByRole('option', { name: 'Basel' }), { key });
|
|
151
|
-
|
|
152
|
-
expect(onValueChange).toHaveBeenCalledWith('Basel');
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
describe('hover', () => {
|
|
157
|
-
test('reports the card under the pointer, then none', () => {
|
|
158
|
-
const onHoverChange = vi.fn();
|
|
159
|
-
renderList({ onHoverChange });
|
|
160
|
-
|
|
161
|
-
const zurich = screen.getByRole('option', { name: 'Zurich' });
|
|
162
|
-
fireEvent.mouseEnter(zurich);
|
|
163
|
-
fireEvent.mouseLeave(zurich);
|
|
164
|
-
|
|
165
|
-
expect(onHoverChange.mock.calls).toEqual([['Zurich'], [null]]);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test('mirrors the hovered value onto its card', () => {
|
|
169
|
-
renderList({ hoveredValue: 'Geneva' });
|
|
170
|
-
|
|
171
|
-
expect(options().map((option) => option.dataset.hovered)).toEqual(['false', 'true', 'false']);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('keyboard focus', () => {
|
|
176
|
-
beforeEach(() => {
|
|
177
|
-
vi.useFakeTimers();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
afterEach(() => {
|
|
181
|
-
vi.useRealTimers();
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
// Radix moves focus on a timeout after the keydown
|
|
185
|
-
function press(element: HTMLElement, key: string) {
|
|
186
|
-
fireEvent.keyDown(element, { key });
|
|
187
|
-
act(() => vi.runAllTimers());
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function tabIntoList() {
|
|
191
|
-
act(() => screen.getByRole('listbox').focus());
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
test('tabbing in lands on the first card when nothing is selected', () => {
|
|
195
|
-
renderList();
|
|
196
|
-
|
|
197
|
-
tabIntoList();
|
|
198
|
-
|
|
199
|
-
expect(document.activeElement).toBe(screen.getByRole('option', { name: 'Zurich' }));
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test('tabbing in lands on the selected card', () => {
|
|
203
|
-
renderList({ value: 'Basel' });
|
|
204
|
-
|
|
205
|
-
expect(tabStops()).toEqual([screen.getByRole('option', { name: 'Basel' })]);
|
|
206
|
-
|
|
207
|
-
tabIntoList();
|
|
208
|
-
|
|
209
|
-
expect(document.activeElement).toBe(screen.getByRole('option', { name: 'Basel' }));
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
test('tabbing back in returns to the last focused card, over the selected one', () => {
|
|
213
|
-
renderList({ value: 'Basel' });
|
|
214
|
-
const [zurich] = options();
|
|
215
|
-
|
|
216
|
-
act(() => zurich.focus());
|
|
217
|
-
act(() => zurich.blur());
|
|
218
|
-
tabIntoList();
|
|
219
|
-
|
|
220
|
-
expect(document.activeElement).toBe(zurich);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
test('arrow keys, Home and End move focus between cards', () => {
|
|
224
|
-
renderList();
|
|
225
|
-
const [zurich, geneva, basel] = options();
|
|
226
|
-
act(() => zurich.focus());
|
|
227
|
-
|
|
228
|
-
press(zurich, 'ArrowDown');
|
|
229
|
-
expect(document.activeElement).toBe(geneva);
|
|
230
|
-
|
|
231
|
-
press(geneva, 'End');
|
|
232
|
-
expect(document.activeElement).toBe(basel);
|
|
233
|
-
|
|
234
|
-
press(basel, 'ArrowDown');
|
|
235
|
-
expect(document.activeElement).toBe(basel);
|
|
236
|
-
|
|
237
|
-
press(basel, 'ArrowUp');
|
|
238
|
-
expect(document.activeElement).toBe(geneva);
|
|
239
|
-
|
|
240
|
-
press(geneva, 'Home');
|
|
241
|
-
expect(document.activeElement).toBe(zurich);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
test('PageDown and PageUp jump to the last and first card', () => {
|
|
245
|
-
renderList();
|
|
246
|
-
const [zurich, , basel] = options();
|
|
247
|
-
act(() => zurich.focus());
|
|
248
|
-
|
|
249
|
-
press(zurich, 'PageDown');
|
|
250
|
-
expect(document.activeElement).toBe(basel);
|
|
251
|
-
|
|
252
|
-
press(basel, 'PageUp');
|
|
253
|
-
expect(document.activeElement).toBe(zurich);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
test('the tab stop follows focus', () => {
|
|
257
|
-
renderList();
|
|
258
|
-
const [zurich, geneva] = options();
|
|
259
|
-
act(() => zurich.focus());
|
|
260
|
-
|
|
261
|
-
press(zurich, 'ArrowDown');
|
|
262
|
-
|
|
263
|
-
expect(tabStops()).toEqual([geneva]);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test('a horizontal list moves with left and right', () => {
|
|
267
|
-
renderList({ orientation: 'horizontal' });
|
|
268
|
-
const [zurich, geneva] = options();
|
|
269
|
-
act(() => zurich.focus());
|
|
270
|
-
|
|
271
|
-
press(zurich, 'ArrowDown');
|
|
272
|
-
expect(document.activeElement).toBe(zurich);
|
|
273
|
-
|
|
274
|
-
press(zurich, 'ArrowRight');
|
|
275
|
-
expect(document.activeElement).toBe(geneva);
|
|
276
|
-
|
|
277
|
-
expect(screen.getByRole('listbox').getAttribute('aria-orientation')).toBe('horizontal');
|
|
278
|
-
});
|
|
279
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export type CardItemPickerValue = string | number;
|
|
4
|
-
export type CardItemPickerOrientation = 'vertical' | 'horizontal';
|
|
5
|
-
|
|
6
|
-
export interface CardItemPickerListContextValue {
|
|
7
|
-
value: CardItemPickerValue | null;
|
|
8
|
-
hoveredValue: CardItemPickerValue | null;
|
|
9
|
-
orientation: CardItemPickerOrientation;
|
|
10
|
-
select: (value: CardItemPickerValue) => void;
|
|
11
|
-
hover: (value: CardItemPickerValue | null) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const CardItemPickerListContext = createContext<CardItemPickerListContextValue | null>(null);
|
|
15
|
-
|
|
16
|
-
export function useCardItemPickerListContext() {
|
|
17
|
-
const context = useContext(CardItemPickerListContext);
|
|
18
|
-
|
|
19
|
-
if (!context) {
|
|
20
|
-
throw new Error('useCardItemPickerListContext must be used within a CardItemPickerList');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return context;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface CardItemPickerRowContextValue {
|
|
27
|
-
isSelected: boolean;
|
|
28
|
-
titleId: string;
|
|
29
|
-
descriptionId: string;
|
|
30
|
-
registerTitle: () => () => void;
|
|
31
|
-
registerDescription: () => () => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const CardItemPickerRowContext = createContext<CardItemPickerRowContextValue | null>(null);
|
|
35
|
-
|
|
36
|
-
export function useCardItemPickerRowContext() {
|
|
37
|
-
const context = useContext(CardItemPickerRowContext);
|
|
38
|
-
|
|
39
|
-
if (!context) {
|
|
40
|
-
throw new Error('useCardItemPickerRowContext must be used within a CardItemPickerRow');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return context;
|
|
44
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as RovingFocusGroup from '@radix-ui/react-roving-focus';
|
|
2
|
-
import type { ComponentPropsWithoutRef } from 'react';
|
|
3
|
-
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cn } from '@swisper.ai/ui';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
CardItemPickerListContext,
|
|
9
|
-
type CardItemPickerListContextValue,
|
|
10
|
-
type CardItemPickerOrientation,
|
|
11
|
-
type CardItemPickerValue,
|
|
12
|
-
} from './card-item-picker-context';
|
|
13
|
-
|
|
14
|
-
export interface CardItemPickerListProps<
|
|
15
|
-
V extends CardItemPickerValue = CardItemPickerValue,
|
|
16
|
-
> extends Omit<ComponentPropsWithoutRef<'ul'>, 'role' | 'onKeyDown' | 'aria-orientation'> {
|
|
17
|
-
/** The selected card, or `null` when nothing is selected. */
|
|
18
|
-
value: V | null;
|
|
19
|
-
/** The card under the pointer, mirrored as `data-hovered` (e.g. when a map pin is hovered). */
|
|
20
|
-
hoveredValue?: V | null;
|
|
21
|
-
/** A card was picked by click, Enter or Space. Toggling is up to the caller. */
|
|
22
|
-
onValueChange: (value: V) => void;
|
|
23
|
-
/** The pointer entered a card (`value`) or left it (`null`). */
|
|
24
|
-
onHoverChange?: (value: V | null) => void;
|
|
25
|
-
orientation?: CardItemPickerOrientation;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A single-select list of cards, built on the ARIA listbox pattern: the list is
|
|
30
|
-
* one tab stop that moves focus into the last focused card, else the selected
|
|
31
|
-
* one, else the first. Arrow keys (plus Home/End, PageUp/PageDown) move between
|
|
32
|
-
* cards and Enter/Space picks one. Name it with `aria-label` or `aria-labelledby`.
|
|
33
|
-
*
|
|
34
|
-
* Cards are listbox options, so they must not contain their own links or
|
|
35
|
-
* buttons — put those in a details view instead.
|
|
36
|
-
*/
|
|
37
|
-
export function CardItemPickerList<V extends CardItemPickerValue>({
|
|
38
|
-
value,
|
|
39
|
-
hoveredValue = null,
|
|
40
|
-
onValueChange,
|
|
41
|
-
onHoverChange,
|
|
42
|
-
orientation = 'vertical',
|
|
43
|
-
className,
|
|
44
|
-
children,
|
|
45
|
-
...props
|
|
46
|
-
}: CardItemPickerListProps<V>) {
|
|
47
|
-
// Radix moves focus; we only pick which card is the tab stop. Controlled so the
|
|
48
|
-
// last focused card wins over the selected one (Radix's `active` would not).
|
|
49
|
-
const [lastFocusedId, setLastFocusedId] = useState<string | null>(null);
|
|
50
|
-
const tabStopId = lastFocusedId ?? (value != null ? String(value) : null);
|
|
51
|
-
|
|
52
|
-
const onHoverChangeRef = useRef(onHoverChange);
|
|
53
|
-
onHoverChangeRef.current = onHoverChange;
|
|
54
|
-
const onValueChangeRef = useRef(onValueChange);
|
|
55
|
-
onValueChangeRef.current = onValueChange;
|
|
56
|
-
|
|
57
|
-
// items only ever report the values they were given, so these are the caller's `V`
|
|
58
|
-
const select = useCallback(
|
|
59
|
-
(itemValue: CardItemPickerValue) => onValueChangeRef.current(itemValue as V),
|
|
60
|
-
[],
|
|
61
|
-
);
|
|
62
|
-
const hover = useCallback(
|
|
63
|
-
(itemValue: CardItemPickerValue | null) => onHoverChangeRef.current?.(itemValue as V | null),
|
|
64
|
-
[],
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const context = useMemo<CardItemPickerListContextValue>(
|
|
68
|
-
() => ({ value, hoveredValue, orientation, select, hover }),
|
|
69
|
-
[value, hoveredValue, orientation, select, hover],
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<CardItemPickerListContext.Provider value={context}>
|
|
74
|
-
<RovingFocusGroup.Root
|
|
75
|
-
asChild
|
|
76
|
-
orientation={orientation}
|
|
77
|
-
currentTabStopId={tabStopId}
|
|
78
|
-
onCurrentTabStopIdChange={setLastFocusedId}
|
|
79
|
-
>
|
|
80
|
-
<ul
|
|
81
|
-
{...props}
|
|
82
|
-
role="listbox"
|
|
83
|
-
aria-orientation={orientation}
|
|
84
|
-
className={cn(
|
|
85
|
-
'flex gap-[4px]',
|
|
86
|
-
orientation === 'vertical' ? 'flex-col' : 'flex-row',
|
|
87
|
-
className,
|
|
88
|
-
)}
|
|
89
|
-
>
|
|
90
|
-
{children}
|
|
91
|
-
</ul>
|
|
92
|
-
</RovingFocusGroup.Root>
|
|
93
|
-
</CardItemPickerListContext.Provider>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import { useLayoutEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
import { Checkbox, Typography, cn } from '@swisper.ai/ui';
|
|
5
|
-
|
|
6
|
-
import { useCardItemPickerRowContext } from './card-item-picker-context';
|
|
7
|
-
|
|
8
|
-
export type CardItemPickerRowMediaProps = ComponentPropsWithoutRef<'div'>;
|
|
9
|
-
|
|
10
|
-
/** Leading visual of a card (a thumbnail); hidden from assistive tech. */
|
|
11
|
-
export function CardItemPickerRowMedia({ className, ...props }: CardItemPickerRowMediaProps) {
|
|
12
|
-
useCardItemPickerRowContext();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
aria-hidden
|
|
17
|
-
className={cn(
|
|
18
|
-
'shrink-0 aspect-square h-[64px] rounded-[4px] overflow-hidden bg-secondary-states-hover',
|
|
19
|
-
className,
|
|
20
|
-
)}
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type CardItemPickerRowContentProps = ComponentPropsWithoutRef<'div'>;
|
|
27
|
-
|
|
28
|
-
/** The text column of a card, beside its media. */
|
|
29
|
-
export function CardItemPickerRowContent({ className, ...props }: CardItemPickerRowContentProps) {
|
|
30
|
-
useCardItemPickerRowContext();
|
|
31
|
-
|
|
32
|
-
return <div className={cn('flex-1 min-w-0 flex flex-col', className)} {...props} />;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface CardItemPickerRowTitleProps {
|
|
36
|
-
children: string;
|
|
37
|
-
className?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** The card's name — becomes the option's accessible name. */
|
|
41
|
-
export function CardItemPickerRowTitle({ children, className }: CardItemPickerRowTitleProps) {
|
|
42
|
-
const { titleId, registerTitle } = useCardItemPickerRowContext();
|
|
43
|
-
|
|
44
|
-
useLayoutEffect(registerTitle, [registerTitle]);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Typography
|
|
48
|
-
id={titleId}
|
|
49
|
-
variant="body"
|
|
50
|
-
fontWeight="semibold"
|
|
51
|
-
className={cn('line-clamp-1', className)}
|
|
52
|
-
title={children}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</Typography>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export type CardItemPickerRowDescriptionProps = ComponentPropsWithoutRef<'div'>;
|
|
60
|
-
|
|
61
|
-
/** Secondary details of a card — announced as the option's description. */
|
|
62
|
-
export function CardItemPickerRowDescription({
|
|
63
|
-
className,
|
|
64
|
-
...props
|
|
65
|
-
}: CardItemPickerRowDescriptionProps) {
|
|
66
|
-
const { descriptionId, registerDescription } = useCardItemPickerRowContext();
|
|
67
|
-
|
|
68
|
-
useLayoutEffect(registerDescription, [registerDescription]);
|
|
69
|
-
|
|
70
|
-
return <div {...props} id={descriptionId} className={className} />;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface CardItemPickerRowCheckboxProps {
|
|
74
|
-
className?: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* A checkbox in the card's top-right corner that mirrors its selection. It only
|
|
79
|
-
* shows the selection: the option already announces it through `aria-selected`,
|
|
80
|
-
* and a listbox option can't hold a control of its own, so the checkbox is out of
|
|
81
|
-
* the tab order, hidden from assistive tech, and clicks pass through to the card.
|
|
82
|
-
* Leave room for it on the right of the card's content.
|
|
83
|
-
*/
|
|
84
|
-
export function CardItemPickerRowCheckbox({ className }: CardItemPickerRowCheckboxProps) {
|
|
85
|
-
const { isSelected } = useCardItemPickerRowContext();
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div
|
|
89
|
-
aria-hidden
|
|
90
|
-
data-testid="card-item-picker-row-checkbox"
|
|
91
|
-
className={cn('pointer-events-none absolute top-[8px] right-[8px]', className)}
|
|
92
|
-
>
|
|
93
|
-
<Checkbox checked={isSelected} tabIndex={-1} />
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
}
|