@elabs-ai/components-ui 4.0.0
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 +21 -0
- package/README.md +78 -0
- package/dist/index.d.ts +4497 -0
- package/dist/index.js +15192 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cn.d.ts +10 -0
- package/dist/lib/cn.js +20 -0
- package/dist/lib/cn.js.map +1 -0
- package/package.json +106 -0
- package/src/blocks/sidebar-02/app-sidebar.tsx +160 -0
- package/src/blocks/sidebar-02/logo.tsx +18 -0
- package/src/blocks/sidebar-02/nav-main.tsx +13 -0
- package/src/blocks/sidebar-02/nav-notifications.tsx +7 -0
- package/src/blocks/sidebar-02/sidebar-02.stories.tsx +23 -0
- package/src/blocks/sidebar-02/team-switcher.tsx +7 -0
- package/src/blocks/sidebar-04/app-sidebar.tsx +236 -0
- package/src/blocks/sidebar-04/mail-context.tsx +29 -0
- package/src/blocks/sidebar-04/nav-user.tsx +6 -0
- package/src/blocks/sidebar-04/sidebar-04.stories.tsx +150 -0
- package/src/blocks/sidebar-05/app-sidebar.tsx +375 -0
- package/src/blocks/sidebar-05/sidebar-05.stories.tsx +18 -0
- package/src/blocks/sidebar-05/team-switcher.tsx +6 -0
- package/src/blocks-comparison-table.stories.tsx +165 -0
- package/src/components/accordion/accordion.stories.tsx +71 -0
- package/src/components/accordion/accordion.test.tsx +18 -0
- package/src/components/accordion/accordion.tsx +49 -0
- package/src/components/accordion/index.ts +1 -0
- package/src/components/advanced-group/advanced-group.stories.tsx +143 -0
- package/src/components/advanced-group/advanced-group.test.tsx +81 -0
- package/src/components/advanced-group/advanced-group.tsx +111 -0
- package/src/components/advanced-group/index.ts +2 -0
- package/src/components/alert/alert.stories.tsx +156 -0
- package/src/components/alert/alert.test.tsx +57 -0
- package/src/components/alert/alert.tsx +91 -0
- package/src/components/alert/index.ts +8 -0
- package/src/components/alert-dialog/alert-dialog.stories.tsx +73 -0
- package/src/components/alert-dialog/alert-dialog.tsx +104 -0
- package/src/components/alert-dialog/index.ts +12 -0
- package/src/components/app-shell/app-shell.stories.tsx +61 -0
- package/src/components/app-shell/app-shell.tsx +31 -0
- package/src/components/app-shell/index.ts +1 -0
- package/src/components/app-sidebar/app-sidebar.stories.tsx +121 -0
- package/src/components/app-sidebar/app-sidebar.test.tsx +55 -0
- package/src/components/app-sidebar/app-sidebar.tsx +53 -0
- package/src/components/app-sidebar/index.ts +1 -0
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +46 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +3 -0
- package/src/components/aspect-ratio/index.ts +1 -0
- package/src/components/attribution-panel/attribution-panel.stories.tsx +83 -0
- package/src/components/attribution-panel/attribution-panel.test.tsx +123 -0
- package/src/components/attribution-panel/attribution-panel.tsx +191 -0
- package/src/components/attribution-panel/attribution-types.ts +44 -0
- package/src/components/attribution-panel/attributions.generated.ts +1422 -0
- package/src/components/attribution-panel/index.ts +3 -0
- package/src/components/avatar/avatar.stories.tsx +45 -0
- package/src/components/avatar/avatar.test.tsx +13 -0
- package/src/components/avatar/avatar.tsx +46 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/badge/badge.stories.tsx +44 -0
- package/src/components/badge/badge.test.tsx +10 -0
- package/src/components/badge/badge.tsx +28 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/bento-grid/bento-grid.stories.tsx +165 -0
- package/src/components/bento-grid/bento-grid.test.tsx +119 -0
- package/src/components/bento-grid/bento-grid.tsx +339 -0
- package/src/components/bento-grid/index.ts +9 -0
- package/src/components/bounded-number/bounded-number.stories.tsx +118 -0
- package/src/components/bounded-number/bounded-number.test.tsx +73 -0
- package/src/components/bounded-number/bounded-number.tsx +110 -0
- package/src/components/bounded-number/index.ts +1 -0
- package/src/components/breadcrumb/breadcrumb.stories.tsx +47 -0
- package/src/components/breadcrumb/breadcrumb.test.tsx +17 -0
- package/src/components/breadcrumb/breadcrumb.tsx +86 -0
- package/src/components/breadcrumb/index.ts +9 -0
- package/src/components/button/button.stories.tsx +70 -0
- package/src/components/button/button.test.tsx +50 -0
- package/src/components/button/button.tsx +63 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button-group/button-group.stories.tsx +45 -0
- package/src/components/button-group/button-group.tsx +70 -0
- package/src/components/button-group/index.ts +6 -0
- package/src/components/calendar/calendar.stories.tsx +95 -0
- package/src/components/calendar/calendar.test.tsx +140 -0
- package/src/components/calendar/calendar.tsx +70 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/card/card.stories.tsx +438 -0
- package/src/components/card/card.test.tsx +153 -0
- package/src/components/card/card.tsx +332 -0
- package/src/components/card/index.ts +13 -0
- package/src/components/carousel/carousel.stories.tsx +102 -0
- package/src/components/carousel/carousel.tsx +225 -0
- package/src/components/carousel/index.ts +8 -0
- package/src/components/change-review/change-review.stories.tsx +288 -0
- package/src/components/change-review/change-review.test.tsx +261 -0
- package/src/components/change-review/change-review.tsx +637 -0
- package/src/components/change-review/index.ts +23 -0
- package/src/components/checkbox/checkbox.stories.tsx +119 -0
- package/src/components/checkbox/checkbox.test.tsx +40 -0
- package/src/components/checkbox/checkbox.tsx +34 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/collapsible/collapsible.stories.tsx +62 -0
- package/src/components/collapsible/collapsible.tsx +22 -0
- package/src/components/collapsible/index.ts +1 -0
- package/src/components/collapsible-panel/index.ts +8 -0
- package/src/components/collapsible-panel/use-collapsible-panel.test.tsx +93 -0
- package/src/components/collapsible-panel/use-collapsible-panel.ts +159 -0
- package/src/components/color-picker/color-picker.stories.tsx +93 -0
- package/src/components/color-picker/color-picker.test.tsx +79 -0
- package/src/components/color-picker/color-picker.tsx +341 -0
- package/src/components/color-picker/index.ts +1 -0
- package/src/components/combobox/combobox.stories.tsx +154 -0
- package/src/components/combobox/combobox.test.tsx +246 -0
- package/src/components/combobox/combobox.tsx +210 -0
- package/src/components/combobox/index.ts +1 -0
- package/src/components/command/command.stories.tsx +371 -0
- package/src/components/command/command.test.tsx +280 -0
- package/src/components/command/command.tsx +301 -0
- package/src/components/command/index.ts +13 -0
- package/src/components/confirm-dialog/confirm-dialog.stories.tsx +183 -0
- package/src/components/confirm-dialog/confirm-dialog.test.tsx +147 -0
- package/src/components/confirm-dialog/confirm-dialog.tsx +146 -0
- package/src/components/confirm-dialog/index.ts +2 -0
- package/src/components/context-menu/context-menu.stories.tsx +70 -0
- package/src/components/context-menu/context-menu.tsx +172 -0
- package/src/components/context-menu/index.ts +16 -0
- package/src/components/copyable-value/copyable-value.stories.tsx +80 -0
- package/src/components/copyable-value/copyable-value.test.tsx +128 -0
- package/src/components/copyable-value/copyable-value.tsx +101 -0
- package/src/components/copyable-value/index.ts +1 -0
- package/src/components/date-picker/date-picker.stories.tsx +42 -0
- package/src/components/date-picker/date-picker.tsx +49 -0
- package/src/components/date-picker/index.ts +1 -0
- package/src/components/date-range-picker/date-range-picker.stories.tsx +151 -0
- package/src/components/date-range-picker/date-range-picker.test.tsx +62 -0
- package/src/components/date-range-picker/date-range-picker.tsx +126 -0
- package/src/components/date-range-picker/index.ts +6 -0
- package/src/components/descriptions/descriptions.stories.tsx +43 -0
- package/src/components/descriptions/descriptions.test.tsx +41 -0
- package/src/components/descriptions/descriptions.tsx +95 -0
- package/src/components/descriptions/index.ts +6 -0
- package/src/components/dialog/dialog.stories.tsx +728 -0
- package/src/components/dialog/dialog.test.tsx +285 -0
- package/src/components/dialog/dialog.tsx +340 -0
- package/src/components/dialog/index.ts +18 -0
- package/src/components/dialog/use-dialog-dismiss-guard.test.tsx +80 -0
- package/src/components/dialog/use-dialog-dismiss-guard.ts +109 -0
- package/src/components/drawer/drawer.stories.tsx +76 -0
- package/src/components/drawer/drawer.tsx +85 -0
- package/src/components/drawer/index.ts +11 -0
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +176 -0
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +109 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +179 -0
- package/src/components/dropdown-menu/index.ts +17 -0
- package/src/components/empty-state/empty-state.stories.tsx +54 -0
- package/src/components/empty-state/empty-state.test.tsx +11 -0
- package/src/components/empty-state/empty-state.tsx +30 -0
- package/src/components/empty-state/index.ts +1 -0
- package/src/components/error-state/error-state.stories.tsx +51 -0
- package/src/components/error-state/error-state.tsx +27 -0
- package/src/components/error-state/index.ts +1 -0
- package/src/components/expand-dialog/expand-dialog.stories.tsx +246 -0
- package/src/components/expand-dialog/expand-dialog.test.tsx +185 -0
- package/src/components/expand-dialog/expand-dialog.tsx +387 -0
- package/src/components/expand-dialog/index.ts +11 -0
- package/src/components/field-row/field-row.stories.tsx +114 -0
- package/src/components/field-row/field-row.test.tsx +188 -0
- package/src/components/field-row/field-row.tsx +115 -0
- package/src/components/field-row/index.ts +1 -0
- package/src/components/file-upload/file-upload.stories.tsx +183 -0
- package/src/components/file-upload/file-upload.test.tsx +169 -0
- package/src/components/file-upload/file-upload.tsx +459 -0
- package/src/components/file-upload/index.ts +13 -0
- package/src/components/form/form.stories.tsx +71 -0
- package/src/components/form/form.tsx +141 -0
- package/src/components/form/index.ts +10 -0
- package/src/components/hover-card/hover-card.stories.tsx +57 -0
- package/src/components/hover-card/hover-card.tsx +25 -0
- package/src/components/hover-card/index.ts +1 -0
- package/src/components/icon-button/icon-button.stories.tsx +108 -0
- package/src/components/icon-button/icon-button.test.tsx +93 -0
- package/src/components/icon-button/icon-button.tsx +139 -0
- package/src/components/icon-button/index.ts +1 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.stories.tsx +44 -0
- package/src/components/input/input.test.tsx +19 -0
- package/src/components/input/input.tsx +26 -0
- package/src/components/input-group/index.ts +11 -0
- package/src/components/input-group/input-group.stories.tsx +87 -0
- package/src/components/input-group/input-group.test.tsx +48 -0
- package/src/components/input-group/input-group.tsx +170 -0
- package/src/components/input-otp/index.ts +1 -0
- package/src/components/input-otp/input-otp.stories.tsx +66 -0
- package/src/components/input-otp/input-otp.tsx +68 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/kbd/kbd.stories.tsx +45 -0
- package/src/components/kbd/kbd.tsx +20 -0
- package/src/components/key-value-editor/index.ts +1 -0
- package/src/components/key-value-editor/key-value-editor.stories.tsx +130 -0
- package/src/components/key-value-editor/key-value-editor.test.tsx +231 -0
- package/src/components/key-value-editor/key-value-editor.tsx +263 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/label/label.stories.tsx +35 -0
- package/src/components/label/label.tsx +19 -0
- package/src/components/link-preview/index.ts +2 -0
- package/src/components/link-preview/link-preview.stories.tsx +178 -0
- package/src/components/link-preview/link-preview.test.tsx +123 -0
- package/src/components/link-preview/link-preview.tsx +194 -0
- package/src/components/list-editor/index.ts +1 -0
- package/src/components/list-editor/list-editor.stories.tsx +119 -0
- package/src/components/list-editor/list-editor.test.tsx +96 -0
- package/src/components/list-editor/list-editor.tsx +192 -0
- package/src/components/loading-state/index.ts +1 -0
- package/src/components/loading-state/loading-state.stories.tsx +38 -0
- package/src/components/loading-state/loading-state.tsx +26 -0
- package/src/components/locale-provider/index.ts +8 -0
- package/src/components/locale-provider/locale-provider.stories.tsx +83 -0
- package/src/components/locale-provider/locale-provider.test.tsx +238 -0
- package/src/components/locale-provider/locale-provider.tsx +187 -0
- package/src/components/locale-provider/messages.ts +300 -0
- package/src/components/match-highlight/index.ts +7 -0
- package/src/components/match-highlight/match-highlight.stories.tsx +146 -0
- package/src/components/match-highlight/match-highlight.test.tsx +202 -0
- package/src/components/match-highlight/match-highlight.tsx +145 -0
- package/src/components/mention-input/index.ts +28 -0
- package/src/components/mention-input/mention-input-mirror.stories.tsx +171 -0
- package/src/components/mention-input/mention-input.stories.tsx +463 -0
- package/src/components/mention-input/mention-input.test.tsx +617 -0
- package/src/components/mention-input/mention-input.tsx +1102 -0
- package/src/components/mention-input/mention-value.test.ts +253 -0
- package/src/components/mention-input/mention-value.ts +193 -0
- package/src/components/menubar/index.ts +17 -0
- package/src/components/menubar/menubar.stories.tsx +67 -0
- package/src/components/menubar/menubar.tsx +198 -0
- package/src/components/metric-card/index.ts +1 -0
- package/src/components/metric-card/metric-card.stories.tsx +224 -0
- package/src/components/metric-card/metric-card.test.tsx +198 -0
- package/src/components/metric-card/metric-card.tsx +229 -0
- package/src/components/model-picker/index.ts +11 -0
- package/src/components/model-picker/model-picker-state.ts +85 -0
- package/src/components/model-picker/model-picker.stories.tsx +128 -0
- package/src/components/model-picker/model-picker.test.tsx +241 -0
- package/src/components/model-picker/model-picker.tsx +270 -0
- package/src/components/nav-main/index.ts +1 -0
- package/src/components/nav-main/nav-main.tsx +147 -0
- package/src/components/nav-notifications/index.ts +5 -0
- package/src/components/nav-notifications/nav-notifications.test.tsx +15 -0
- package/src/components/nav-notifications/nav-notifications.tsx +70 -0
- package/src/components/nav-user/index.ts +1 -0
- package/src/components/nav-user/nav-user.test.tsx +29 -0
- package/src/components/nav-user/nav-user.tsx +114 -0
- package/src/components/navigation-menu/index.ts +10 -0
- package/src/components/navigation-menu/navigation-menu.stories.tsx +92 -0
- package/src/components/navigation-menu/navigation-menu.tsx +99 -0
- package/src/components/number-input/index.ts +1 -0
- package/src/components/number-input/number-input.stories.tsx +120 -0
- package/src/components/number-input/number-input.test.tsx +96 -0
- package/src/components/number-input/number-input.tsx +219 -0
- package/src/components/page-shell/index.ts +1 -0
- package/src/components/page-shell/page-shell.stories.tsx +105 -0
- package/src/components/page-shell/page-shell.test.tsx +57 -0
- package/src/components/page-shell/page-shell.tsx +62 -0
- package/src/components/pagination/index.ts +9 -0
- package/src/components/pagination/pagination.stories.tsx +57 -0
- package/src/components/pagination/pagination.tsx +77 -0
- package/src/components/popover/index.ts +1 -0
- package/src/components/popover/popover.stories.tsx +28 -0
- package/src/components/popover/popover.test.tsx +16 -0
- package/src/components/popover/popover.tsx +29 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.stories.tsx +80 -0
- package/src/components/progress/progress.test.tsx +35 -0
- package/src/components/progress/progress.tsx +50 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/radio-group/radio-group.stories.tsx +75 -0
- package/src/components/radio-group/radio-group.test.tsx +16 -0
- package/src/components/radio-group/radio-group.tsx +33 -0
- package/src/components/rating/index.ts +1 -0
- package/src/components/rating/rating.stories.tsx +111 -0
- package/src/components/rating/rating.test.tsx +41 -0
- package/src/components/rating/rating.tsx +226 -0
- package/src/components/resizable/index.ts +1 -0
- package/src/components/resizable/resizable.stories.tsx +25 -0
- package/src/components/resizable/resizable.tsx +40 -0
- package/src/components/reveal/index.ts +7 -0
- package/src/components/reveal/reveal.stories.tsx +90 -0
- package/src/components/reveal/reveal.test.tsx +43 -0
- package/src/components/reveal/reveal.tsx +95 -0
- package/src/components/revision-timeline/index.ts +10 -0
- package/src/components/revision-timeline/revision-timeline.stories.tsx +785 -0
- package/src/components/revision-timeline/revision-timeline.test.tsx +509 -0
- package/src/components/revision-timeline/revision-timeline.tsx +1107 -0
- package/src/components/scroll-area/index.ts +1 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +45 -0
- package/src/components/scroll-area/scroll-area.tsx +43 -0
- package/src/components/section-header/index.ts +1 -0
- package/src/components/section-header/section-header.stories.tsx +20 -0
- package/src/components/section-header/section-header.tsx +36 -0
- package/src/components/segmented-field/index.ts +5 -0
- package/src/components/segmented-field/segmented-field.stories.tsx +121 -0
- package/src/components/segmented-field/segmented-field.test.tsx +163 -0
- package/src/components/segmented-field/segmented-field.tsx +235 -0
- package/src/components/select/index.ts +10 -0
- package/src/components/select/select.stories.tsx +106 -0
- package/src/components/select/select.test.tsx +98 -0
- package/src/components/select/select.tsx +230 -0
- package/src/components/separator/index.ts +2 -0
- package/src/components/separator/separator.stories.tsx +87 -0
- package/src/components/separator/separator.tsx +51 -0
- package/src/components/sheet/index.ts +12 -0
- package/src/components/sheet/sheet.stories.tsx +65 -0
- package/src/components/sheet/sheet.tsx +109 -0
- package/src/components/sidebar/index.ts +27 -0
- package/src/components/sidebar/sidebar.stories.tsx +69 -0
- package/src/components/sidebar/sidebar.test.tsx +43 -0
- package/src/components/sidebar/sidebar.tsx +688 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.stories.tsx +28 -0
- package/src/components/skeleton/skeleton.tsx +15 -0
- package/src/components/slider/index.ts +1 -0
- package/src/components/slider/slider.stories.tsx +211 -0
- package/src/components/slider/slider.test.tsx +168 -0
- package/src/components/slider/slider.tsx +136 -0
- package/src/components/slider-number/index.ts +1 -0
- package/src/components/slider-number/slider-number.stories.tsx +123 -0
- package/src/components/slider-number/slider-number.test.tsx +165 -0
- package/src/components/slider-number/slider-number.tsx +191 -0
- package/src/components/sonner/index.ts +1 -0
- package/src/components/sonner/sonner.stories.tsx +124 -0
- package/src/components/sonner/sonner.test.tsx +76 -0
- package/src/components/sonner/sonner.tsx +101 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner/spinner.stories.tsx +27 -0
- package/src/components/spinner/spinner.tsx +19 -0
- package/src/components/split-panel/index.ts +1 -0
- package/src/components/split-panel/split-panel.stories.tsx +60 -0
- package/src/components/split-panel/split-panel.test.tsx +38 -0
- package/src/components/split-panel/split-panel.tsx +95 -0
- package/src/components/state-panel/index.ts +1 -0
- package/src/components/state-panel/state-panel.stories.tsx +80 -0
- package/src/components/state-panel/state-panel.test.tsx +64 -0
- package/src/components/state-panel/state-panel.tsx +167 -0
- package/src/components/status-badge/index.ts +18 -0
- package/src/components/status-badge/status-badge.stories.tsx +132 -0
- package/src/components/status-badge/status-badge.test.tsx +189 -0
- package/src/components/status-badge/status-badge.tsx +330 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.stories.tsx +58 -0
- package/src/components/switch/switch.test.tsx +12 -0
- package/src/components/switch/switch.tsx +29 -0
- package/src/components/table/index.ts +10 -0
- package/src/components/table/table.stories.tsx +53 -0
- package/src/components/table/table.test.tsx +17 -0
- package/src/components/table/table.tsx +106 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/tabs.stories.tsx +267 -0
- package/src/components/tabs/tabs.test.tsx +94 -0
- package/src/components/tabs/tabs.tsx +170 -0
- package/src/components/tag-input/index.ts +1 -0
- package/src/components/tag-input/tag-input.stories.tsx +120 -0
- package/src/components/tag-input/tag-input.test.tsx +97 -0
- package/src/components/tag-input/tag-input.tsx +253 -0
- package/src/components/team-switcher/index.ts +1 -0
- package/src/components/team-switcher/team-switcher.test.tsx +39 -0
- package/src/components/team-switcher/team-switcher.tsx +100 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/textarea.stories.tsx +42 -0
- package/src/components/textarea/textarea.tsx +24 -0
- package/src/components/theme-switcher/index.ts +2 -0
- package/src/components/theme-switcher/theme-switcher.stories.tsx +146 -0
- package/src/components/theme-switcher/theme-switcher.test.tsx +253 -0
- package/src/components/theme-switcher/theme-switcher.tsx +280 -0
- package/src/components/theme-switcher/use-theme-transition.ts +62 -0
- package/src/components/timeline/index.ts +13 -0
- package/src/components/timeline/timeline.stories.tsx +99 -0
- package/src/components/timeline/timeline.test.tsx +196 -0
- package/src/components/timeline/timeline.tsx +188 -0
- package/src/components/toggle/index.ts +1 -0
- package/src/components/toggle/toggle.stories.tsx +116 -0
- package/src/components/toggle/toggle.test.tsx +119 -0
- package/src/components/toggle/toggle.tsx +64 -0
- package/src/components/toggle-group/index.ts +1 -0
- package/src/components/toggle-group/toggle-group.stories.tsx +110 -0
- package/src/components/toggle-group/toggle-group.tsx +59 -0
- package/src/components/toolbar/index.ts +14 -0
- package/src/components/toolbar/toolbar.stories.tsx +126 -0
- package/src/components/toolbar/toolbar.test.tsx +73 -0
- package/src/components/toolbar/toolbar.tsx +177 -0
- package/src/components/tooltip/index.ts +1 -0
- package/src/components/tooltip/tooltip.stories.tsx +67 -0
- package/src/components/tooltip/tooltip.tsx +27 -0
- package/src/components/top-nav/index.ts +1 -0
- package/src/components/top-nav/top-nav.stories.tsx +18 -0
- package/src/components/top-nav/top-nav.tsx +34 -0
- package/src/components/transfer/index.ts +2 -0
- package/src/components/transfer/transfer.stories.tsx +162 -0
- package/src/components/transfer/transfer.test.tsx +177 -0
- package/src/components/transfer/transfer.tsx +481 -0
- package/src/components/tree/index.ts +6 -0
- package/src/components/tree/tree.stories.tsx +618 -0
- package/src/components/tree/tree.test.tsx +699 -0
- package/src/components/tree/tree.tsx +1149 -0
- package/src/components/tree/use-tree-keyboard.ts +314 -0
- package/src/components/tree-select/index.ts +1 -0
- package/src/components/tree-select/tree-select.stories.tsx +127 -0
- package/src/components/tree-select/tree-select.test.tsx +40 -0
- package/src/components/tree-select/tree-select.tsx +137 -0
- package/src/components/typography/index.ts +31 -0
- package/src/components/typography/prose.test.tsx +48 -0
- package/src/components/typography/prose.tsx +194 -0
- package/src/components/typography/typography.stories.tsx +244 -0
- package/src/components/typography/typography.test.tsx +140 -0
- package/src/components/typography/typography.tsx +126 -0
- package/src/components/view-toolbar/index.ts +10 -0
- package/src/components/view-toolbar/view-toolbar.stories.tsx +342 -0
- package/src/components/view-toolbar/view-toolbar.test.tsx +262 -0
- package/src/components/view-toolbar/view-toolbar.tsx +320 -0
- package/src/components/virtual-select/index.ts +2 -0
- package/src/components/virtual-select/use-virtual-listbox.ts +132 -0
- package/src/components/virtual-select/virtual-select.stories.tsx +203 -0
- package/src/components/virtual-select/virtual-select.test.tsx +106 -0
- package/src/components/virtual-select/virtual-select.tsx +361 -0
- package/src/components/wizard/index.ts +12 -0
- package/src/components/wizard/wizard.stories.tsx +148 -0
- package/src/components/wizard/wizard.test.tsx +67 -0
- package/src/components/wizard/wizard.tsx +354 -0
- package/src/decoration.stories.tsx +236 -0
- package/src/index.ts +174 -0
- package/src/lib/cn.test.ts +39 -0
- package/src/lib/cn.ts +31 -0
- package/src/lib/compact-number.ts +61 -0
- package/src/lib/document-address.test.ts +75 -0
- package/src/lib/document-address.ts +265 -0
- package/src/lib/download.ts +93 -0
- package/src/lib/file-icon.test.ts +45 -0
- package/src/lib/file-icon.ts +58 -0
- package/src/lib/file-kind.test.ts +98 -0
- package/src/lib/file-kind.ts +303 -0
- package/src/lib/file-source.test.ts +217 -0
- package/src/lib/file-source.ts +269 -0
- package/src/lib/merge-refs.test.ts +37 -0
- package/src/lib/merge-refs.ts +17 -0
- package/src/lib/streamdown-translations.ts +99 -0
- package/src/lib/use-copy-to-clipboard.ts +75 -0
- package/src/lib/use-mobile.ts +16 -0
- package/src/motion.stories.tsx +266 -0
- package/src/taste-profile.test.tsx +252 -0
- package/src/templates-object-detail-hub.stories.tsx +466 -0
- package/src/templates-screen-states.stories.tsx +306 -0
- package/src/templates-settings.stories.tsx +245 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
type ComponentProps,
|
|
9
|
+
type HTMLAttributes,
|
|
10
|
+
type KeyboardEvent,
|
|
11
|
+
} from "react";
|
|
12
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
|
|
13
|
+
import { ArrowLeft, ArrowRight } from "lucide-react";
|
|
14
|
+
import { cn } from "../../lib/cn";
|
|
15
|
+
import { Button } from "../button";
|
|
16
|
+
|
|
17
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
18
|
+
type CarouselOptions = NonNullable<Parameters<typeof useEmblaCarousel>[0]>;
|
|
19
|
+
type CarouselPlugin = NonNullable<Parameters<typeof useEmblaCarousel>[1]>;
|
|
20
|
+
|
|
21
|
+
interface CarouselProps {
|
|
22
|
+
opts?: CarouselOptions;
|
|
23
|
+
plugins?: CarouselPlugin;
|
|
24
|
+
orientation?: "horizontal" | "vertical";
|
|
25
|
+
setApi?: (api: CarouselApi) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface CarouselContextValue extends CarouselProps {
|
|
29
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0];
|
|
30
|
+
api: CarouselApi;
|
|
31
|
+
scrollPrev: () => void;
|
|
32
|
+
scrollNext: () => void;
|
|
33
|
+
canScrollPrev: boolean;
|
|
34
|
+
canScrollNext: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const CarouselContext = createContext<CarouselContextValue | null>(null);
|
|
38
|
+
|
|
39
|
+
function useCarousel() {
|
|
40
|
+
const ctx = useContext(CarouselContext);
|
|
41
|
+
if (!ctx) throw new Error("useCarousel must be used within <Carousel />");
|
|
42
|
+
return ctx;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Root carousel region. Carries `role="region" aria-roledescription="carousel"`
|
|
47
|
+
* plus an `aria-label` — it defaults to `"Carousel"` so the region always has an
|
|
48
|
+
* accessible name (issue #279), but **consumers should pass a specific
|
|
49
|
+
* `aria-label`** (e.g. `"Product photos"`) describing what the carousel actually
|
|
50
|
+
* shows, since AT users otherwise can't distinguish multiple carousels on a page.
|
|
51
|
+
*/
|
|
52
|
+
export const Carousel = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & CarouselProps>(
|
|
53
|
+
function Carousel(
|
|
54
|
+
{
|
|
55
|
+
orientation = "horizontal",
|
|
56
|
+
opts,
|
|
57
|
+
setApi,
|
|
58
|
+
plugins,
|
|
59
|
+
className,
|
|
60
|
+
children,
|
|
61
|
+
// A carousel region MUST have an accessible name (WAI-ARIA APG) —
|
|
62
|
+
// aria-roledescription changes the announcement, it does not name the
|
|
63
|
+
// landmark. Default is overridable; pass a specific label ("Product
|
|
64
|
+
// photos") when the carousel's purpose isn't generic. Issue #279.
|
|
65
|
+
"aria-label": ariaLabel = "Carousel",
|
|
66
|
+
...props
|
|
67
|
+
},
|
|
68
|
+
ref,
|
|
69
|
+
) {
|
|
70
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
71
|
+
{ ...opts, axis: orientation === "horizontal" ? "x" : "y" },
|
|
72
|
+
plugins,
|
|
73
|
+
);
|
|
74
|
+
const [canScrollPrev, setCanScrollPrev] = useState(false);
|
|
75
|
+
const [canScrollNext, setCanScrollNext] = useState(false);
|
|
76
|
+
|
|
77
|
+
const onSelect = useCallback((a: CarouselApi) => {
|
|
78
|
+
if (!a) return;
|
|
79
|
+
setCanScrollPrev(a.canScrollPrev());
|
|
80
|
+
setCanScrollNext(a.canScrollNext());
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const scrollPrev = useCallback(() => api?.scrollPrev(), [api]);
|
|
84
|
+
const scrollNext = useCallback(() => api?.scrollNext(), [api]);
|
|
85
|
+
|
|
86
|
+
const onKeyDown = useCallback(
|
|
87
|
+
(e: KeyboardEvent<HTMLDivElement>) => {
|
|
88
|
+
if (e.key === "ArrowLeft") {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
scrollPrev();
|
|
91
|
+
} else if (e.key === "ArrowRight") {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
scrollNext();
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
[scrollPrev, scrollNext],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (api && setApi) setApi(api);
|
|
101
|
+
}, [api, setApi]);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!api) return;
|
|
104
|
+
onSelect(api);
|
|
105
|
+
api.on("reInit", onSelect);
|
|
106
|
+
api.on("select", onSelect);
|
|
107
|
+
return () => {
|
|
108
|
+
api.off("select", onSelect);
|
|
109
|
+
};
|
|
110
|
+
}, [api, onSelect]);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<CarouselContext.Provider
|
|
114
|
+
value={{
|
|
115
|
+
carouselRef,
|
|
116
|
+
api,
|
|
117
|
+
opts,
|
|
118
|
+
orientation,
|
|
119
|
+
scrollPrev,
|
|
120
|
+
scrollNext,
|
|
121
|
+
canScrollPrev,
|
|
122
|
+
canScrollNext,
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<div
|
|
126
|
+
ref={ref}
|
|
127
|
+
onKeyDownCapture={onKeyDown}
|
|
128
|
+
className={cn("relative", className)}
|
|
129
|
+
role="region"
|
|
130
|
+
aria-roledescription="carousel"
|
|
131
|
+
aria-label={ariaLabel}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
{children}
|
|
135
|
+
</div>
|
|
136
|
+
</CarouselContext.Provider>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const CarouselContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
|
142
|
+
function CarouselContent({ className, ...props }, ref) {
|
|
143
|
+
const { carouselRef, orientation } = useCarousel();
|
|
144
|
+
return (
|
|
145
|
+
<div ref={carouselRef} className="overflow-hidden">
|
|
146
|
+
<div
|
|
147
|
+
ref={ref}
|
|
148
|
+
className={cn(
|
|
149
|
+
"flex",
|
|
150
|
+
orientation === "horizontal" ? "-ms-4" : "-mt-4 flex-col",
|
|
151
|
+
className,
|
|
152
|
+
)}
|
|
153
|
+
{...props}
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
export const CarouselItem = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
|
|
161
|
+
function CarouselItem({ className, ...props }, ref) {
|
|
162
|
+
const { orientation } = useCarousel();
|
|
163
|
+
return (
|
|
164
|
+
<div
|
|
165
|
+
ref={ref}
|
|
166
|
+
role="group"
|
|
167
|
+
aria-roledescription="slide"
|
|
168
|
+
className={cn(
|
|
169
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
170
|
+
orientation === "horizontal" ? "ps-4" : "pt-4",
|
|
171
|
+
className,
|
|
172
|
+
)}
|
|
173
|
+
{...props}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
export function CarouselPrevious({ className, ...props }: ComponentProps<typeof Button>) {
|
|
180
|
+
const { scrollPrev, canScrollPrev, orientation } = useCarousel();
|
|
181
|
+
return (
|
|
182
|
+
<Button
|
|
183
|
+
variant="outline"
|
|
184
|
+
size="icon"
|
|
185
|
+
disabled={!canScrollPrev}
|
|
186
|
+
onClick={scrollPrev}
|
|
187
|
+
aria-label="Previous slide"
|
|
188
|
+
className={cn(
|
|
189
|
+
"absolute size-8 rounded-full",
|
|
190
|
+
orientation === "horizontal"
|
|
191
|
+
? "-start-12 top-1/2 -translate-y-1/2"
|
|
192
|
+
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
193
|
+
className,
|
|
194
|
+
)}
|
|
195
|
+
{...props}
|
|
196
|
+
>
|
|
197
|
+
<ArrowLeft className="size-4" data-rtl-flip />
|
|
198
|
+
</Button>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function CarouselNext({ className, ...props }: ComponentProps<typeof Button>) {
|
|
203
|
+
const { scrollNext, canScrollNext, orientation } = useCarousel();
|
|
204
|
+
return (
|
|
205
|
+
<Button
|
|
206
|
+
variant="outline"
|
|
207
|
+
size="icon"
|
|
208
|
+
disabled={!canScrollNext}
|
|
209
|
+
onClick={scrollNext}
|
|
210
|
+
aria-label="Next slide"
|
|
211
|
+
className={cn(
|
|
212
|
+
"absolute size-8 rounded-full",
|
|
213
|
+
orientation === "horizontal"
|
|
214
|
+
? "-end-12 top-1/2 -translate-y-1/2"
|
|
215
|
+
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
216
|
+
className,
|
|
217
|
+
)}
|
|
218
|
+
{...props}
|
|
219
|
+
>
|
|
220
|
+
<ArrowRight className="size-4" data-rtl-flip />
|
|
221
|
+
</Button>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export type { CarouselApi };
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { expect, userEvent, waitFor, within } from "storybook/test";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ChangeReview,
|
|
6
|
+
ChangeReviewHeader,
|
|
7
|
+
ChangeReviewHunk,
|
|
8
|
+
ChangeReviewList,
|
|
9
|
+
ChangeReviewProvider,
|
|
10
|
+
ChangeReviewProvenance,
|
|
11
|
+
type ChangeHunk,
|
|
12
|
+
} from "./change-review";
|
|
13
|
+
|
|
14
|
+
// ─── Sample hunks ─────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
const HUNKS: ChangeHunk[] = [
|
|
17
|
+
{
|
|
18
|
+
id: "hunk-1",
|
|
19
|
+
title: "config/settings.json",
|
|
20
|
+
status: "modified",
|
|
21
|
+
before: `"timeout": 30`,
|
|
22
|
+
after: `"timeout": 60`,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "hunk-2",
|
|
26
|
+
title: "src/utils/logger.ts",
|
|
27
|
+
status: "added",
|
|
28
|
+
after: `export const log = (msg: string) => console.log("[APP]", msg);`,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "hunk-3",
|
|
32
|
+
title: "src/legacy/old-handler.ts",
|
|
33
|
+
status: "removed",
|
|
34
|
+
before: `export function oldHandler() { /* deprecated */ }`,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const PROVENANCE = {
|
|
39
|
+
author: "Claude Sonnet",
|
|
40
|
+
model: "claude-sonnet-4-6",
|
|
41
|
+
timestamp: "2026-06-15 14:02",
|
|
42
|
+
note: "run-abc123",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// ─── Meta ─────────────────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
const meta = {
|
|
48
|
+
title: "AI/ChangeReview",
|
|
49
|
+
component: ChangeReview,
|
|
50
|
+
tags: ["autodocs"],
|
|
51
|
+
parameters: {
|
|
52
|
+
layout: "padded",
|
|
53
|
+
docs: {
|
|
54
|
+
description: {
|
|
55
|
+
component:
|
|
56
|
+
"AI-edit trust gate. When an agent proposes edits, the human reviews them " +
|
|
57
|
+
"hunk-by-hunk and accepts or rejects each before they apply. Compound " +
|
|
58
|
+
"component with lifted state — compose parts for custom layouts, or use the " +
|
|
59
|
+
"convenience `<ChangeReview>` root.",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
} satisfies Meta<typeof ChangeReview>;
|
|
64
|
+
|
|
65
|
+
export default meta;
|
|
66
|
+
type Story = StoryObj<typeof meta>;
|
|
67
|
+
|
|
68
|
+
// ─── Default (uncontrolled, with provenance) ──────────────────────────────────
|
|
69
|
+
|
|
70
|
+
export const Default: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
hunks: HUNKS,
|
|
73
|
+
provenance: PROVENANCE,
|
|
74
|
+
},
|
|
75
|
+
play: async ({ canvasElement }) => {
|
|
76
|
+
const canvas = within(canvasElement);
|
|
77
|
+
// Header renders with count
|
|
78
|
+
await waitFor(() => expect(canvas.getByText("Review changes")).toBeVisible());
|
|
79
|
+
await waitFor(() => expect(canvas.getByText("0 of 3 approved")).toBeVisible());
|
|
80
|
+
// Three hunk rows visible
|
|
81
|
+
expect(canvas.getAllByRole("listitem")).toHaveLength(3);
|
|
82
|
+
// Provenance attribution visible
|
|
83
|
+
await waitFor(() => expect(canvas.getByText("Claude Sonnet")).toBeVisible());
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// ─── Empty (no hunks → StatePanel) ───────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
export const Empty: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
hunks: [],
|
|
92
|
+
},
|
|
93
|
+
play: async ({ canvasElement }) => {
|
|
94
|
+
const canvas = within(canvasElement);
|
|
95
|
+
// The empty StatePanel fades in (animate-in), so wait out the entrance before
|
|
96
|
+
// asserting visibility (jest-dom toBeVisible treats opacity:0 as not visible).
|
|
97
|
+
await waitFor(() => expect(canvas.getByText("No changes to review")).toBeVisible());
|
|
98
|
+
// No list items
|
|
99
|
+
expect(canvas.queryAllByRole("listitem")).toHaveLength(0);
|
|
100
|
+
// Approve all / Reject all buttons absent when no hunks
|
|
101
|
+
expect(canvas.queryByRole("button", { name: /approve all/i })).not.toBeInTheDocument();
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// ─── Single hunk ──────────────────────────────────────────────────────────────
|
|
106
|
+
|
|
107
|
+
export const SingleHunk: Story = {
|
|
108
|
+
args: {
|
|
109
|
+
hunks: [HUNKS[0]],
|
|
110
|
+
},
|
|
111
|
+
play: async ({ canvasElement }) => {
|
|
112
|
+
const canvas = within(canvasElement);
|
|
113
|
+
await waitFor(() => expect(canvas.getByText("config/settings.json")).toBeVisible());
|
|
114
|
+
expect(canvas.getAllByRole("listitem")).toHaveLength(1);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// ─── All approved ─────────────────────────────────────────────────────────────
|
|
119
|
+
|
|
120
|
+
export const AllApproved: Story = {
|
|
121
|
+
args: {
|
|
122
|
+
hunks: HUNKS,
|
|
123
|
+
approved: new Set(HUNKS.map((h) => h.id)),
|
|
124
|
+
},
|
|
125
|
+
play: async ({ canvasElement }) => {
|
|
126
|
+
const canvas = within(canvasElement);
|
|
127
|
+
await waitFor(() => expect(canvas.getByText("3 of 3 approved")).toBeVisible());
|
|
128
|
+
// Each hunk shows "Approved" badge
|
|
129
|
+
const approvedBadges = canvas.getAllByText("Approved");
|
|
130
|
+
expect(approvedBadges).toHaveLength(3);
|
|
131
|
+
// Approve all button disabled
|
|
132
|
+
const approveAll = canvas.getByRole("button", { name: /approve all/i });
|
|
133
|
+
expect(approveAll).toBeDisabled();
|
|
134
|
+
// Reject all button enabled
|
|
135
|
+
const rejectAll = canvas.getByRole("button", { name: /reject all/i });
|
|
136
|
+
expect(rejectAll).not.toBeDisabled();
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// ─── All rejected ─────────────────────────────────────────────────────────────
|
|
141
|
+
|
|
142
|
+
export const AllRejected: Story = {
|
|
143
|
+
args: {
|
|
144
|
+
hunks: HUNKS,
|
|
145
|
+
approved: new Set(),
|
|
146
|
+
},
|
|
147
|
+
play: async ({ canvasElement }) => {
|
|
148
|
+
const canvas = within(canvasElement);
|
|
149
|
+
await waitFor(() => expect(canvas.getByText("0 of 3 approved")).toBeVisible());
|
|
150
|
+
// Reject all button disabled (nothing to reject)
|
|
151
|
+
const rejectAll = canvas.getByRole("button", { name: /reject all/i });
|
|
152
|
+
expect(rejectAll).toBeDisabled();
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// ─── Mixed approval ───────────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
export const Mixed: Story = {
|
|
159
|
+
args: {
|
|
160
|
+
hunks: HUNKS,
|
|
161
|
+
approved: new Set(["hunk-1", "hunk-3"]),
|
|
162
|
+
},
|
|
163
|
+
play: async ({ canvasElement }) => {
|
|
164
|
+
const canvas = within(canvasElement);
|
|
165
|
+
await waitFor(() => expect(canvas.getByText("2 of 3 approved")).toBeVisible());
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// ─── Interactive (uncontrolled, toggle hunks) ─────────────────────────────────
|
|
170
|
+
|
|
171
|
+
export const Interactive: Story = {
|
|
172
|
+
args: { hunks: HUNKS },
|
|
173
|
+
play: async ({ canvasElement }) => {
|
|
174
|
+
const canvas = within(canvasElement);
|
|
175
|
+
|
|
176
|
+
// Initially 0 approved
|
|
177
|
+
await waitFor(() => expect(canvas.getByText("0 of 3 approved")).toBeVisible());
|
|
178
|
+
|
|
179
|
+
// Approve first hunk
|
|
180
|
+
const approveBtn = canvas.getByRole("button", {
|
|
181
|
+
name: /approve hunk: config\/settings\.json/i,
|
|
182
|
+
});
|
|
183
|
+
await userEvent.click(approveBtn);
|
|
184
|
+
await waitFor(() => expect(canvas.getByText("1 of 3 approved")).toBeVisible());
|
|
185
|
+
|
|
186
|
+
// Approve all
|
|
187
|
+
const approveAll = canvas.getByRole("button", { name: /approve all/i });
|
|
188
|
+
await userEvent.click(approveAll);
|
|
189
|
+
await waitFor(() => expect(canvas.getByText("3 of 3 approved")).toBeVisible());
|
|
190
|
+
|
|
191
|
+
// Reject all
|
|
192
|
+
const rejectAll = canvas.getByRole("button", { name: /reject all/i });
|
|
193
|
+
await userEvent.click(rejectAll);
|
|
194
|
+
await waitFor(() => expect(canvas.getByText("0 of 3 approved")).toBeVisible());
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// ─── Controlled ───────────────────────────────────────────────────────────────
|
|
199
|
+
|
|
200
|
+
function ControlledDemo() {
|
|
201
|
+
const [approved, setApproved] = useState<Set<string>>(new Set());
|
|
202
|
+
return (
|
|
203
|
+
<div className="space-y-3">
|
|
204
|
+
<ChangeReview
|
|
205
|
+
hunks={HUNKS}
|
|
206
|
+
approved={approved}
|
|
207
|
+
onToggle={(id, next) =>
|
|
208
|
+
setApproved((prev) => {
|
|
209
|
+
const s = new Set(prev);
|
|
210
|
+
if (next) s.add(id);
|
|
211
|
+
else s.delete(id);
|
|
212
|
+
return s;
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
onApproveAll={() => setApproved(new Set(HUNKS.map((h) => h.id)))}
|
|
216
|
+
onRejectAll={() => setApproved(new Set())}
|
|
217
|
+
/>
|
|
218
|
+
<p className="text-caption text-muted-foreground">
|
|
219
|
+
Approved IDs: {[...approved].join(", ") || "(none)"}
|
|
220
|
+
</p>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export const Controlled: Story = {
|
|
226
|
+
render: () => <ControlledDemo />,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// ─── Custom renderHunk ────────────────────────────────────────────────────────
|
|
230
|
+
|
|
231
|
+
export const CustomRenderer: Story = {
|
|
232
|
+
args: {
|
|
233
|
+
hunks: HUNKS,
|
|
234
|
+
renderHunk: (hunk, { approved }) => (
|
|
235
|
+
<div className="text-caption text-muted-foreground italic">
|
|
236
|
+
{approved ? "Accepted" : "Pending"}: {hunk.title}
|
|
237
|
+
</div>
|
|
238
|
+
),
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// ─── Compound (manual layout) ─────────────────────────────────────────────────
|
|
243
|
+
|
|
244
|
+
export const Compound: Story = {
|
|
245
|
+
render: () => (
|
|
246
|
+
<ChangeReviewProvider hunks={HUNKS}>
|
|
247
|
+
<div className="space-y-3 p-4 border rounded-lg bg-card">
|
|
248
|
+
<ChangeReviewHeader />
|
|
249
|
+
<ChangeReviewProvenance
|
|
250
|
+
provenance={{ author: "Atlas Agent", model: "claude-sonnet-4-6", timestamp: "14:02" }}
|
|
251
|
+
/>
|
|
252
|
+
<ChangeReviewList>
|
|
253
|
+
{HUNKS.map((hunk) => (
|
|
254
|
+
<ChangeReviewHunk key={hunk.id} hunk={hunk} />
|
|
255
|
+
))}
|
|
256
|
+
</ChangeReviewList>
|
|
257
|
+
</div>
|
|
258
|
+
</ChangeReviewProvider>
|
|
259
|
+
),
|
|
260
|
+
play: async ({ canvasElement }) => {
|
|
261
|
+
const canvas = within(canvasElement);
|
|
262
|
+
await waitFor(() => expect(canvas.getByText("Review changes")).toBeVisible());
|
|
263
|
+
expect(canvas.getAllByRole("listitem")).toHaveLength(3);
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// ─── Long content ─────────────────────────────────────────────────────────────
|
|
268
|
+
|
|
269
|
+
export const LongContent: Story = {
|
|
270
|
+
args: {
|
|
271
|
+
hunks: [
|
|
272
|
+
{
|
|
273
|
+
id: "long-1",
|
|
274
|
+
title: "src/components/very/deeply/nested/component/with/a/long/path.tsx",
|
|
275
|
+
status: "modified",
|
|
276
|
+
before: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod
|
|
277
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
278
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo.
|
|
279
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
|
|
280
|
+
eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.`,
|
|
281
|
+
after: `Revised content. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
282
|
+
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Completely
|
|
283
|
+
rewritten with improved clarity and fewer side effects. The new version handles
|
|
284
|
+
edge cases properly and includes proper error boundaries.`,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
};
|