@jcsoftdev/ui 0.5.0 → 0.7.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/CHANGELOG.md +361 -0
- package/README.md +31 -5
- package/bin/ui-theme.mjs +40 -6
- package/dist/ai/code-block/code-block.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +6 -1
- package/dist/atoms/avatar/avatar.js +3 -2
- package/dist/atoms/big-date/big-date.js +2 -2
- package/dist/atoms/button/button.d.ts +6 -1
- package/dist/atoms/button/button.js +2 -2
- package/dist/atoms/chip/chip.d.ts +5 -0
- package/dist/atoms/chip/chip.js +3 -3
- package/dist/atoms/icon-button/icon-button.js +1 -1
- package/dist/atoms/internal/hit-area.d.ts +5 -4
- package/dist/atoms/internal/hit-area.js +1 -1
- package/dist/atoms/progress/index.d.ts +1 -1
- package/dist/atoms/progress/index.js +4 -1
- package/dist/atoms/progress/progress.d.ts +6 -1
- package/dist/atoms/progress/progress.js +19 -1
- package/dist/atoms/radio-group/radio-group.js +1 -1
- package/dist/atoms/status-pill/status-pill.d.ts +16 -5
- package/dist/atoms/status-pill/status-pill.js +43 -18
- package/dist/brand/logo-forge.js +1 -1
- package/dist/charts/candlestick-chart/candlestick-chart.js +2 -2
- package/dist/charts/chart-grid/chart-grid.js +2 -2
- package/dist/charts/chord-chart/chord-chart.js +1 -1
- package/dist/charts/core/axes.js +2 -2
- package/dist/charts/core/cartesian/annotations.js +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/distribution/marks.js +1 -1
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/export-menu.js +1 -1
- package/dist/charts/funnel-chart/funnel-chart.js +1 -1
- package/dist/charts/gantt-chart/gantt-chart.js +4 -4
- package/dist/charts/gantt-chart/gantt-marks.js +3 -3
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/charts/maps/geo/map-data-table.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +1 -1
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/stock-chart/stock-chart.js +1 -1
- package/dist/charts/stock-chart/stock-drawing-layer.js +3 -3
- package/dist/charts/stock-chart/stock-plot.js +2 -2
- package/dist/containers/chat-thread/chat-thread.d.ts +98 -0
- package/dist/containers/chat-thread/chat-thread.js +219 -0
- package/dist/containers/chat-thread/format.d.ts +20 -0
- package/dist/containers/chat-thread/format.js +50 -0
- package/dist/containers/chat-thread/index.d.ts +1 -0
- package/dist/containers/chat-thread/index.js +8 -0
- package/dist/containers/cols/cols.d.ts +1 -1
- package/dist/containers/cols/cols.js +7 -0
- package/dist/containers/comment/comment.js +1 -1
- package/dist/containers/context-rail/context-rail.d.ts +62 -0
- package/dist/containers/context-rail/context-rail.js +175 -0
- package/dist/containers/context-rail/index.d.ts +1 -0
- package/dist/containers/context-rail/index.js +6 -0
- package/dist/containers/dashboard/dashboard.d.ts +40 -0
- package/dist/containers/dashboard/dashboard.js +84 -0
- package/dist/containers/dashboard/index.d.ts +1 -0
- package/dist/containers/dashboard/index.js +14 -0
- package/dist/containers/data-grid/data-grid.demos.js +4 -4
- package/dist/containers/data-grid/data-grid.js +6 -6
- package/dist/containers/data-grid/filter-builder-editor.js +2 -2
- package/dist/containers/data-grid/grid-toolbar.js +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.d.ts +1 -1
- package/dist/containers/data-grid/spreadsheet.demos.js +1 -1
- package/dist/containers/detail-header/detail-header.d.ts +24 -0
- package/dist/containers/detail-header/detail-header.js +32 -0
- package/dist/containers/detail-header/index.d.ts +1 -0
- package/dist/containers/detail-header/index.js +6 -0
- package/dist/containers/facts/facts.js +1 -1
- package/dist/containers/filter-bar/filter-bar.d.ts +58 -0
- package/dist/containers/filter-bar/filter-bar.js +123 -0
- package/dist/containers/filter-bar/index.d.ts +1 -0
- package/dist/containers/filter-bar/index.js +6 -0
- package/dist/containers/hbars/hbars.js +2 -2
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kanban/kanban.d.ts +23 -2
- package/dist/containers/kanban/kanban.js +103 -21
- package/dist/containers/kanban/model.d.ts +12 -0
- package/dist/containers/kanban/model.js +8 -0
- package/dist/containers/kpi/kpi.js +1 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +6 -1
- package/dist/containers/kpi-group/kpi-group.js +6 -2
- package/dist/containers/list-detail/index.d.ts +1 -1
- package/dist/containers/list-detail/index.js +4 -0
- package/dist/containers/list-detail/list-detail.d.ts +51 -3
- package/dist/containers/list-detail/list-detail.js +111 -15
- package/dist/containers/page/page.d.ts +17 -4
- package/dist/containers/page/page.js +33 -4
- package/dist/containers/page-header/back.d.ts +10 -0
- package/dist/containers/page-header/back.js +28 -0
- package/dist/containers/page-header/index.d.ts +1 -0
- package/dist/containers/page-header/index.js +1 -0
- package/dist/containers/page-header/page-header.d.ts +19 -2
- package/dist/containers/page-header/page-header.js +26 -2
- package/dist/containers/pagination/cursor-pagination.d.ts +28 -0
- package/dist/containers/pagination/cursor-pagination.js +48 -0
- package/dist/containers/pagination/index.d.ts +3 -0
- package/dist/containers/pagination/index.js +10 -0
- package/dist/containers/pagination/pagination.d.ts +52 -0
- package/dist/containers/pagination/pagination.js +216 -0
- package/dist/containers/pagination/range.d.ts +29 -0
- package/dist/containers/pagination/range.js +42 -0
- package/dist/containers/pagination/use-pagination.d.ts +18 -0
- package/dist/containers/pagination/use-pagination.js +22 -0
- package/dist/containers/responsive-list/responsive-list.d.ts +29 -3
- package/dist/containers/responsive-list/responsive-list.js +202 -82
- package/dist/containers/row-actions/index.d.ts +1 -0
- package/dist/containers/row-actions/index.js +4 -0
- package/dist/containers/row-actions/row-actions.d.ts +26 -0
- package/dist/containers/row-actions/row-actions.js +78 -0
- package/dist/containers/selectable-card/index.d.ts +1 -0
- package/dist/containers/selectable-card/index.js +6 -0
- package/dist/containers/selectable-card/selectable-card.d.ts +26 -0
- package/dist/containers/selectable-card/selectable-card.js +57 -0
- package/dist/containers/settings-layout/settings-layout.d.ts +24 -7
- package/dist/containers/settings-layout/settings-layout.js +63 -8
- package/dist/containers/shortcuts/shortcuts.js +1 -1
- package/dist/containers/table/cell-padding.d.ts +2 -0
- package/dist/containers/table/cell-padding.js +4 -0
- package/dist/containers/table/index.d.ts +1 -0
- package/dist/containers/table/index.js +8 -0
- package/dist/containers/table/sort.d.ts +14 -0
- package/dist/containers/table/sort.js +11 -0
- package/dist/containers/table/table-parts.d.ts +24 -0
- package/dist/containers/table/table-parts.js +52 -0
- package/dist/containers/table/table.d.ts +37 -3
- package/dist/containers/table/table.js +120 -19
- package/dist/containers/table-columns-menu/index.d.ts +1 -0
- package/dist/containers/table-columns-menu/index.js +6 -0
- package/dist/containers/table-columns-menu/table-columns-menu.d.ts +14 -0
- package/dist/containers/table-columns-menu/table-columns-menu.js +46 -0
- package/dist/dashboards/layout.d.ts +1 -27
- package/dist/dashboards/layout.js +8 -40
- package/dist/forms/chip-group/chip-group.d.ts +5 -0
- package/dist/forms/chip-group/chip-group.js +3 -1
- package/dist/forms/combobox/combobox.js +1 -1
- package/dist/forms/copy-field/copy-field.js +1 -1
- package/dist/forms/date-picker/date-picker.d.ts +3 -1
- package/dist/forms/date-picker/date-picker.js +4 -2
- package/dist/forms/date-picker/date-time-picker.d.ts +8 -2
- package/dist/forms/date-picker/date-time-picker.js +13 -2
- package/dist/forms/field/field.d.ts +9 -2
- package/dist/forms/field/field.js +18 -4
- package/dist/forms/fieldset/fieldset.d.ts +11 -0
- package/dist/forms/fieldset/fieldset.js +12 -0
- package/dist/forms/fieldset/index.d.ts +1 -0
- package/dist/forms/fieldset/index.js +4 -0
- package/dist/forms/form-footer/form-footer.d.ts +26 -0
- package/dist/forms/form-footer/form-footer.js +44 -0
- package/dist/forms/form-footer/index.d.ts +1 -0
- package/dist/forms/form-footer/index.js +4 -0
- package/dist/forms/form-grid/form-grid.d.ts +21 -4
- package/dist/forms/form-grid/form-grid.js +20 -3
- package/dist/forms/form-grid/index.d.ts +1 -1
- package/dist/forms/form-grid/index.js +6 -2
- package/dist/forms/form-section/form-section.d.ts +12 -0
- package/dist/forms/form-section/form-section.js +30 -0
- package/dist/forms/form-section/index.d.ts +1 -0
- package/dist/forms/form-section/index.js +4 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.js +3 -0
- package/dist/forms/input/input.d.ts +6 -2
- package/dist/forms/input/input.js +4 -1
- package/dist/forms/internal/listbox-items.d.ts +1 -1
- package/dist/forms/internal/listbox-items.js +3 -2
- package/dist/forms/native-select/native-select.js +1 -1
- package/dist/forms/number-stepper/index.d.ts +1 -1
- package/dist/forms/number-stepper/number-stepper.d.ts +7 -0
- package/dist/forms/number-stepper/number-stepper.js +37 -6
- package/dist/forms/select/index.d.ts +1 -1
- package/dist/forms/select/select.d.ts +5 -2
- package/dist/forms/select/select.js +7 -2
- package/dist/forms/select-menu/select-menu.js +1 -1
- package/dist/forms/time-input/time-input.d.ts +4 -2
- package/dist/forms/time-input/time-input.js +3 -1
- package/dist/i18n/strings.d.ts +94 -0
- package/dist/i18n/strings.js +50 -0
- package/dist/motion/count-up.d.ts +20 -0
- package/dist/motion/count-up.js +59 -0
- package/dist/motion/cross-fade.d.ts +21 -0
- package/dist/motion/cross-fade.js +86 -0
- package/dist/motion/index.d.ts +5 -0
- package/dist/motion/index.js +14 -0
- package/dist/motion/model.d.ts +15 -0
- package/dist/motion/model.js +68 -0
- package/dist/motion/motion-styles.d.ts +1 -0
- package/dist/motion/motion-styles.js +35 -0
- package/dist/motion/reveal.d.ts +37 -0
- package/dist/motion/reveal.js +69 -0
- package/dist/motion/use-enter-phase.d.ts +11 -0
- package/dist/motion/use-enter-phase.js +40 -0
- package/dist/motion/use-highlight-row.d.ts +22 -0
- package/dist/motion/use-highlight-row.js +38 -0
- package/dist/navigation/tabs/tabs.js +1 -1
- package/dist/navigation/wizard/wizard.d.ts +4 -1
- package/dist/navigation/wizard/wizard.js +3 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +8 -1
- package/dist/overlays/context-menu/context-menu.js +3 -1
- package/dist/overlays/dialog/dialog.d.ts +1 -0
- package/dist/overlays/dialog/dialog.js +11 -3
- package/dist/overlays/drawer/drawer.d.ts +18 -4
- package/dist/overlays/drawer/drawer.js +53 -4
- package/dist/overlays/drawer/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +5 -4
- package/dist/overlays/hover-card/hover-card.js +2 -0
- package/dist/overlays/popover/popover.js +2 -0
- package/dist/overlays/toaster/index.d.ts +1 -1
- package/dist/overlays/toaster/toast-store.d.ts +2 -0
- package/dist/overlays/toaster/toast-store.js +6 -1
- package/dist/overlays/toaster/toaster.d.ts +28 -2
- package/dist/overlays/toaster/toaster.js +86 -29
- package/dist/overlays/tooltip/tooltip.js +2 -0
- package/dist/primitives/use-presence.js +9 -0
- package/dist/shell/app-shell/app-shell.d.ts +8 -1
- package/dist/shell/app-shell/app-shell.js +50 -3
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +1 -0
- package/dist/shell/sidebar/sidebar.d.ts +17 -1
- package/dist/shell/sidebar/sidebar.js +126 -76
- package/dist/shell/topbar/topbar.d.ts +4 -2
- package/dist/shell/topbar/topbar.js +2 -0
- package/dist/showcase/operations-bento.js +2 -2
- package/dist/states/empty-state/empty-state.d.ts +10 -3
- package/dist/states/empty-state/empty-state.js +46 -5
- package/dist/states/error-state/error-state.js +1 -1
- package/dist/states/skeleton/skeleton.d.ts +16 -1
- package/dist/states/skeleton/skeleton.js +13 -5
- package/dist/utils/class-tokens.generated.js +4 -6
- package/dist/utils/focus-chain.d.ts +11 -0
- package/dist/utils/focus-chain.js +39 -0
- package/dist/utils/focus-rescue.d.ts +13 -0
- package/dist/utils/focus-rescue.js +48 -0
- package/dist/utils/list-navigation.d.ts +14 -0
- package/dist/utils/list-navigation.js +44 -0
- package/dist/utils/overlay-motion.d.ts +12 -0
- package/dist/utils/overlay-motion.js +14 -0
- package/dist/utils/use-container-width.d.ts +6 -0
- package/dist/utils/use-container-width.js +19 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +46 -5
- package/src/ai/code-block/code-block.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +8 -2
- package/src/atoms/big-date/big-date.tsx +2 -2
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/chip/chip.tsx +8 -3
- package/src/atoms/icon-button/icon-button.tsx +1 -1
- package/src/atoms/internal/hit-area.ts +5 -4
- package/src/atoms/progress/index.ts +8 -1
- package/src/atoms/progress/progress.tsx +30 -1
- package/src/atoms/radio-group/radio-group.tsx +1 -1
- package/src/atoms/status-pill/status-pill.tsx +59 -18
- package/src/brand/logo-forge.tsx +1 -1
- package/src/charts/candlestick-chart/candlestick-chart.tsx +2 -2
- package/src/charts/chart-grid/chart-grid.tsx +2 -2
- package/src/charts/chord-chart/chord-chart.tsx +1 -1
- package/src/charts/core/axes.tsx +2 -2
- package/src/charts/core/cartesian/annotations.tsx +2 -2
- package/src/charts/core/cartesian/marks.tsx +1 -1
- package/src/charts/core/distribution/marks.tsx +1 -1
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/export-menu.tsx +1 -1
- package/src/charts/funnel-chart/funnel-chart.tsx +1 -1
- package/src/charts/gantt-chart/gantt-chart.tsx +4 -4
- package/src/charts/gantt-chart/gantt-marks.tsx +3 -3
- package/src/charts/index.ts +2 -0
- package/src/charts/maps/geo/map-data-table.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +1 -1
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-chart.tsx +1 -1
- package/src/charts/stock-chart/stock-drawing-layer.tsx +3 -3
- package/src/charts/stock-chart/stock-plot.tsx +2 -2
- package/src/containers/chat-thread/chat-thread.tsx +331 -0
- package/src/containers/chat-thread/format.ts +67 -0
- package/src/containers/chat-thread/index.ts +12 -0
- package/src/containers/cols/cols.tsx +13 -1
- package/src/containers/comment/comment.tsx +1 -1
- package/src/containers/context-rail/context-rail.tsx +229 -0
- package/src/containers/context-rail/index.ts +7 -0
- package/src/containers/dashboard/dashboard.tsx +142 -0
- package/src/containers/dashboard/index.ts +12 -0
- package/src/containers/data-grid/data-grid.demos.tsx +4 -4
- package/src/containers/data-grid/data-grid.tsx +6 -6
- package/src/containers/data-grid/filter-builder-editor.tsx +2 -2
- package/src/containers/data-grid/grid-toolbar.tsx +1 -1
- package/src/containers/data-grid/spreadsheet.demos.tsx +1 -1
- package/src/containers/detail-header/detail-header.tsx +64 -0
- package/src/containers/detail-header/index.ts +5 -0
- package/src/containers/facts/facts.tsx +1 -1
- package/src/containers/filter-bar/filter-bar.tsx +201 -0
- package/src/containers/filter-bar/index.ts +7 -0
- package/src/containers/hbars/hbars.tsx +2 -2
- package/src/containers/index.ts +9 -0
- package/src/containers/kanban/kanban.tsx +148 -39
- package/src/containers/kanban/model.ts +20 -0
- package/src/containers/kpi/kpi.tsx +1 -1
- package/src/containers/kpi-group/kpi-group.tsx +17 -2
- package/src/containers/list-detail/index.ts +5 -0
- package/src/containers/list-detail/list-detail.tsx +159 -9
- package/src/containers/page/page.tsx +61 -7
- package/src/containers/page-header/back.tsx +42 -0
- package/src/containers/page-header/index.ts +1 -0
- package/src/containers/page-header/page-header.tsx +49 -3
- package/src/containers/pagination/cursor-pagination.tsx +79 -0
- package/src/containers/pagination/index.ts +7 -0
- package/src/containers/pagination/pagination.tsx +266 -0
- package/src/containers/pagination/range.ts +68 -0
- package/src/containers/pagination/use-pagination.ts +44 -0
- package/src/containers/responsive-list/responsive-list.tsx +190 -47
- package/src/containers/row-actions/index.ts +1 -0
- package/src/containers/row-actions/row-actions.tsx +114 -0
- package/src/containers/selectable-card/index.ts +5 -0
- package/src/containers/selectable-card/selectable-card.tsx +84 -0
- package/src/containers/settings-layout/settings-layout.tsx +104 -13
- package/src/containers/shortcuts/shortcuts.tsx +1 -1
- package/src/containers/table/cell-padding.ts +2 -0
- package/src/containers/table/index.ts +6 -0
- package/src/containers/table/sort.ts +23 -0
- package/src/containers/table/table-parts.tsx +81 -0
- package/src/containers/table/table.tsx +212 -45
- package/src/containers/table-columns-menu/index.ts +5 -0
- package/src/containers/table-columns-menu/table-columns-menu.tsx +68 -0
- package/src/dashboards/layout.tsx +8 -75
- package/src/forms/chip-group/chip-group.tsx +8 -1
- package/src/forms/combobox/combobox.tsx +1 -1
- package/src/forms/copy-field/copy-field.tsx +1 -1
- package/src/forms/date-picker/date-picker.tsx +7 -2
- package/src/forms/date-picker/date-time-picker.tsx +28 -2
- package/src/forms/field/field.tsx +30 -3
- package/src/forms/fieldset/fieldset.tsx +22 -0
- package/src/forms/fieldset/index.ts +1 -0
- package/src/forms/form-footer/form-footer.tsx +74 -0
- package/src/forms/form-footer/index.ts +1 -0
- package/src/forms/form-grid/form-grid.tsx +42 -5
- package/src/forms/form-grid/index.ts +8 -1
- package/src/forms/form-section/form-section.tsx +41 -0
- package/src/forms/form-section/index.ts +1 -0
- package/src/forms/index.ts +3 -0
- package/src/forms/input/input.tsx +10 -3
- package/src/forms/internal/listbox-items.tsx +3 -4
- package/src/forms/native-select/native-select.tsx +1 -1
- package/src/forms/number-stepper/index.ts +1 -0
- package/src/forms/number-stepper/number-stepper.tsx +51 -6
- package/src/forms/select/index.ts +1 -1
- package/src/forms/select/select.tsx +14 -3
- package/src/forms/select-menu/select-menu.tsx +1 -1
- package/src/forms/time-input/time-input.tsx +6 -2
- package/src/i18n/strings.ts +94 -0
- package/src/motion/count-up.tsx +83 -0
- package/src/motion/cross-fade.tsx +139 -0
- package/src/motion/index.ts +5 -0
- package/src/motion/model.ts +86 -0
- package/src/motion/motion-styles.tsx +47 -0
- package/src/motion/reveal.tsx +115 -0
- package/src/motion/use-enter-phase.ts +50 -0
- package/src/motion/use-highlight-row.ts +63 -0
- package/src/navigation/tabs/tabs.tsx +1 -1
- package/src/navigation/wizard/wizard.tsx +6 -1
- package/src/overlays/alert-dialog/alert-dialog.tsx +5 -1
- package/src/overlays/context-menu/context-menu.tsx +3 -2
- package/src/overlays/dialog/dialog.tsx +9 -3
- package/src/overlays/drawer/drawer.tsx +68 -6
- package/src/overlays/drawer/index.ts +1 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +5 -4
- package/src/overlays/hover-card/hover-card.tsx +2 -0
- package/src/overlays/popover/popover.tsx +2 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +8 -0
- package/src/overlays/toaster/toaster.tsx +127 -17
- package/src/overlays/tooltip/tooltip.tsx +2 -0
- package/src/primitives/use-presence.ts +13 -0
- package/src/shell/app-shell/app-shell.tsx +54 -2
- package/src/shell/index.ts +1 -0
- package/src/shell/sidebar/sidebar.tsx +154 -75
- package/src/shell/topbar/topbar.tsx +8 -0
- package/src/showcase/operations-bento.tsx +2 -2
- package/src/states/empty-state/empty-state.tsx +52 -9
- package/src/states/error-state/error-state.tsx +1 -1
- package/src/states/skeleton/skeleton.tsx +33 -5
- package/src/utils/class-tokens.generated.ts +4 -6
- package/src/utils/focus-chain.ts +53 -0
- package/src/utils/focus-rescue.ts +68 -0
- package/src/utils/list-navigation.ts +63 -0
- package/src/utils/overlay-motion.ts +33 -0
- package/src/utils/use-container-width.ts +24 -0
- package/styles/Theme.kt +15 -18
- package/styles/tailwind.css +29 -28
- package/styles/theme.css +29 -28
- package/styles/tokens.css +46 -0
- package/tokens/default.json +51 -29
|
@@ -36,7 +36,7 @@ function Pill({
|
|
|
36
36
|
y={y}
|
|
37
37
|
dy="0.35em"
|
|
38
38
|
textAnchor="middle"
|
|
39
|
-
className="font-bold text-fs-
|
|
39
|
+
className="font-bold text-fs-110"
|
|
40
40
|
style={{ fill: ink }}
|
|
41
41
|
>
|
|
42
42
|
{text}
|
|
@@ -111,7 +111,7 @@ export const AnnotationLayer = memo(function AnnotationLayer({
|
|
|
111
111
|
<text
|
|
112
112
|
x={(horizontal ? 0 : note.from) + 6}
|
|
113
113
|
y={(horizontal ? note.from : 0) + 13}
|
|
114
|
-
className="font-bold text-fs-
|
|
114
|
+
className="font-bold text-fs-110"
|
|
115
115
|
style={{ fill: ink }}
|
|
116
116
|
>
|
|
117
117
|
{note.label}
|
|
@@ -146,7 +146,7 @@ export const DataLabels = memo(function DataLabels({ geometry, dimmed }: DataLab
|
|
|
146
146
|
strokeWidth={label.inside ? 0 : 3}
|
|
147
147
|
strokeLinejoin="round"
|
|
148
148
|
className={cn(
|
|
149
|
-
"font-bold text-fs-
|
|
149
|
+
"font-bold text-fs-110 tabular-nums",
|
|
150
150
|
label.inside ? "fill-surface" : "fill-ink-2 stroke-surface",
|
|
151
151
|
)}
|
|
152
152
|
>
|
|
@@ -7,7 +7,7 @@ import type { DistributionLabels } from "./labels.js";
|
|
|
7
7
|
import type { CategoryLayout, XYLayout } from "./layout.js";
|
|
8
8
|
import type { BoxStats } from "./stats.js";
|
|
9
9
|
|
|
10
|
-
const TITLE = "fill-ink-3 font-bold text-fs-
|
|
10
|
+
const TITLE = "fill-ink-3 font-bold text-fs-110";
|
|
11
11
|
|
|
12
12
|
/** Gridlines along the value axis plus both axes of a `categoryLayout`. */
|
|
13
13
|
export const CategoryAxes = memo(function CategoryAxes({
|
|
@@ -980,7 +980,7 @@ function XYPointPlot({
|
|
|
980
980
|
x={Math.min(trend.x2, innerWidth) - 4}
|
|
981
981
|
y={trend.y2 - 8}
|
|
982
982
|
textAnchor="end"
|
|
983
|
-
className="font-bold text-fs-
|
|
983
|
+
className="font-bold text-fs-110 tabular-nums"
|
|
984
984
|
style={{ fill: trend.series.color }}
|
|
985
985
|
>
|
|
986
986
|
{`R² ${formatNumber(trend.fit.r2, { maximumFractionDigits: 2 })}`}
|
|
@@ -58,7 +58,7 @@ export function ExportMenu({
|
|
|
58
58
|
type="button"
|
|
59
59
|
aria-label={`${texts.export} ${texts[kind]}`}
|
|
60
60
|
onClick={() => run(kind)}
|
|
61
|
-
className="cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-
|
|
61
|
+
className="cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-120 text-ink-3 outline-none hover:bg-surface hover:text-ink focus-visible:outline-2 focus-visible:outline-accent-ink"
|
|
62
62
|
>
|
|
63
63
|
{texts[kind]}
|
|
64
64
|
</button>
|
|
@@ -443,7 +443,7 @@ function FunnelPlot({
|
|
|
443
443
|
x={x}
|
|
444
444
|
y={y + 4}
|
|
445
445
|
textAnchor="middle"
|
|
446
|
-
className={cn("fill-ink-2 font-bold text-fs-
|
|
446
|
+
className={cn("fill-ink-2 font-bold text-fs-110 tabular-nums")}
|
|
447
447
|
>
|
|
448
448
|
{formatPercent(conversion, { decimals: 0 })}
|
|
449
449
|
</text>
|
|
@@ -983,7 +983,7 @@ function GanttBody({
|
|
|
983
983
|
aria-label={texts.zoomLevels[level]}
|
|
984
984
|
onClick={() => onZoom(level)}
|
|
985
985
|
className={cn(
|
|
986
|
-
"cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-
|
|
986
|
+
"cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-120 outline-none focus-visible:outline-2 focus-visible:outline-accent-ink @md/chart:px-3",
|
|
987
987
|
zoom === level ? "bg-surface text-ink shadow-xs" : "text-ink-3 hover:text-ink",
|
|
988
988
|
)}
|
|
989
989
|
>
|
|
@@ -997,7 +997,7 @@ function GanttBody({
|
|
|
997
997
|
))}
|
|
998
998
|
</fieldset>
|
|
999
999
|
{critical || baselines ? (
|
|
1000
|
-
<ul className="m-0 hidden min-w-0 list-none items-center gap-3 p-0 text-fs-
|
|
1000
|
+
<ul className="m-0 hidden min-w-0 list-none items-center gap-3 p-0 text-fs-120 text-ink-3 @xl/chart:flex">
|
|
1001
1001
|
{critical ? (
|
|
1002
1002
|
<li className="flex items-center gap-1.5 whitespace-nowrap">
|
|
1003
1003
|
<span
|
|
@@ -1077,7 +1077,7 @@ function GanttBody({
|
|
|
1077
1077
|
<button
|
|
1078
1078
|
type="button"
|
|
1079
1079
|
onClick={() => scrollToTime(todayTime, true)}
|
|
1080
|
-
className="shrink-0 cursor-pointer rounded-button border-divider bg-surface-control px-3 py-1 font-semibold text-fs-
|
|
1080
|
+
className="shrink-0 cursor-pointer rounded-button border-divider bg-surface-control px-3 py-1 font-semibold text-fs-120 text-ink-2 outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent-ink"
|
|
1081
1081
|
>
|
|
1082
1082
|
{texts.today}
|
|
1083
1083
|
</button>
|
|
@@ -1235,7 +1235,7 @@ function GanttBody({
|
|
|
1235
1235
|
<span
|
|
1236
1236
|
key={column}
|
|
1237
1237
|
aria-hidden="true"
|
|
1238
|
-
className="shrink-0 truncate pr-3 text-right text-fs-
|
|
1238
|
+
className="shrink-0 truncate pr-3 text-right text-fs-120 text-ink-3 tabular-nums"
|
|
1239
1239
|
style={{ width: COLUMN_WIDTH[column] }}
|
|
1240
1240
|
>
|
|
1241
1241
|
{column === "start"
|
|
@@ -118,7 +118,7 @@ export const TimelineHeader = memo(function TimelineHeader({
|
|
|
118
118
|
x={x}
|
|
119
119
|
y={HEADER_ROW / 2}
|
|
120
120
|
dy="0.34em"
|
|
121
|
-
className="fill-ink-2 font-semibold text-fs-
|
|
121
|
+
className="fill-ink-2 font-semibold text-fs-120"
|
|
122
122
|
>
|
|
123
123
|
{cell.label}
|
|
124
124
|
</text>
|
|
@@ -150,7 +150,7 @@ export const TimelineHeader = memo(function TimelineHeader({
|
|
|
150
150
|
y={HEADER_ROW + HEADER_ROW / 2}
|
|
151
151
|
dy="0.34em"
|
|
152
152
|
textAnchor="middle"
|
|
153
|
-
className="fill-ink-3 font-medium text-fs-
|
|
153
|
+
className="fill-ink-3 font-medium text-fs-110 tabular-nums"
|
|
154
154
|
>
|
|
155
155
|
{cell.label}
|
|
156
156
|
</text>
|
|
@@ -698,7 +698,7 @@ export const AnnotationLayer = memo(function AnnotationLayer({
|
|
|
698
698
|
x={item.x0 + 10}
|
|
699
699
|
y={y + 7.5}
|
|
700
700
|
dy="0.34em"
|
|
701
|
-
className="fill-ink font-semibold text-fs-
|
|
701
|
+
className="fill-ink font-semibold text-fs-110"
|
|
702
702
|
>
|
|
703
703
|
{item.label}
|
|
704
704
|
</text>
|
package/src/charts/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./beeswarm-chart/index.js";
|
|
|
4
4
|
export * from "./box-plot/index.js";
|
|
5
5
|
export * from "./bubble-chart/index.js";
|
|
6
6
|
export * from "./bubble-map/index.js";
|
|
7
|
+
export * from "./bullet-chart/index.js";
|
|
7
8
|
export * from "./candlestick-chart/index.js";
|
|
8
9
|
export * from "./chart-grid/index.js";
|
|
9
10
|
export * from "./chord-chart/index.js";
|
|
@@ -25,6 +26,7 @@ export * from "./histogram/index.js";
|
|
|
25
26
|
export * from "./icicle-chart/index.js";
|
|
26
27
|
export * from "./isotype-rows/index.js";
|
|
27
28
|
export * from "./line-chart/index.js";
|
|
29
|
+
export * from "./lollipop-chart/index.js";
|
|
28
30
|
export * from "./maps/index.js";
|
|
29
31
|
export * from "./parliament-chart/index.js";
|
|
30
32
|
export * from "./pictogram-chart/index.js";
|
|
@@ -82,7 +82,7 @@ export function MapDataTable({
|
|
|
82
82
|
);
|
|
83
83
|
return (
|
|
84
84
|
<div className="@container/table overflow-auto rounded-event border-divider" style={{ height }}>
|
|
85
|
-
<table className="w-full border-collapse text-fs-
|
|
85
|
+
<table className="w-full border-collapse text-fs-120">
|
|
86
86
|
<caption className="sr-only">{caption}</caption>
|
|
87
87
|
<thead>
|
|
88
88
|
<tr className="border-b-divider">
|
|
@@ -434,7 +434,7 @@ function RosePlot({
|
|
|
434
434
|
x={cx + 4}
|
|
435
435
|
y={cy - ring.r - 3}
|
|
436
436
|
{...DECORATIVE}
|
|
437
|
-
className="pointer-events-none fill-ink-3 text-fs-
|
|
437
|
+
className="pointer-events-none fill-ink-3 text-fs-100 tabular-nums"
|
|
438
438
|
style={{ paintOrder: "stroke", stroke: "var(--surface)", strokeWidth: 3 }}
|
|
439
439
|
>
|
|
440
440
|
{axisFormat(ring.value)}
|
|
@@ -444,7 +444,7 @@ export function StockChart({
|
|
|
444
444
|
setRange(rangeWindow(dates, preset));
|
|
445
445
|
}}
|
|
446
446
|
className={cn(
|
|
447
|
-
"cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-
|
|
447
|
+
"cursor-pointer rounded-button px-2 py-1 font-semibold text-fs-120 tabular-nums outline-none focus-visible:outline-2 focus-visible:outline-accent-ink @md/chart:px-2.5",
|
|
448
448
|
activePreset?.id === preset.id
|
|
449
449
|
? "bg-surface text-ink shadow-xs"
|
|
450
450
|
: "text-ink-3 hover:text-ink",
|
|
@@ -134,7 +134,7 @@ export function DrawingShape({
|
|
|
134
134
|
<text
|
|
135
135
|
x={6}
|
|
136
136
|
y={py - 5}
|
|
137
|
-
className="font-semibold text-fs-
|
|
137
|
+
className="font-semibold text-fs-110 tabular-nums"
|
|
138
138
|
style={{ fill: COLORS.horizontal }}
|
|
139
139
|
>
|
|
140
140
|
{fmt(drawing.price)}
|
|
@@ -189,7 +189,7 @@ export function DrawingShape({
|
|
|
189
189
|
<text
|
|
190
190
|
x={left + 6}
|
|
191
191
|
y={top + 14}
|
|
192
|
-
className="font-bold text-fs-
|
|
192
|
+
className="font-bold text-fs-110 tabular-nums"
|
|
193
193
|
style={{ fill: COLORS.range }}
|
|
194
194
|
>
|
|
195
195
|
{change > 0 ? "+" : ""}
|
|
@@ -289,7 +289,7 @@ export function MeasureShape({
|
|
|
289
289
|
y={boxY + 11}
|
|
290
290
|
dy="0.34em"
|
|
291
291
|
textAnchor="middle"
|
|
292
|
-
className="font-bold text-fs-
|
|
292
|
+
className="font-bold text-fs-110 tabular-nums"
|
|
293
293
|
style={{ fill: "var(--surface)" }}
|
|
294
294
|
>
|
|
295
295
|
{label}
|
|
@@ -813,7 +813,7 @@ export function StockPlot({
|
|
|
813
813
|
})}
|
|
814
814
|
{lower && oscillator ? (
|
|
815
815
|
<g transform={`translate(0,${lowerTop})`}>
|
|
816
|
-
<text {...DECORATIVE} x={0} y={-7} className="fill-ink-3 font-semibold text-fs-
|
|
816
|
+
<text {...DECORATIVE} x={0} y={-7} className="fill-ink-3 font-semibold text-fs-110">
|
|
817
817
|
{oscillator.name}
|
|
818
818
|
{(() => {
|
|
819
819
|
const index = active ?? view.length - 1;
|
|
@@ -1123,7 +1123,7 @@ function AxisTag({
|
|
|
1123
1123
|
y={0}
|
|
1124
1124
|
dy="0.34em"
|
|
1125
1125
|
textAnchor="middle"
|
|
1126
|
-
className="font-bold text-fs-
|
|
1126
|
+
className="font-bold text-fs-110 tabular-nums"
|
|
1127
1127
|
style={{ fill: "var(--surface)" }}
|
|
1128
1128
|
>
|
|
1129
1129
|
{text}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useEffect, useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { Button } from "../../atoms/button/button.js";
|
|
5
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
6
|
+
import { Check, CheckCheck } from "../../icons/index.js";
|
|
7
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
8
|
+
import { cn } from "../../utils/cn.js";
|
|
9
|
+
import { type ChatTimestamp, dayKey, formatDay, formatTime, withDayBreaks } from "./format.js";
|
|
10
|
+
|
|
11
|
+
export type ChatAuthorKind = "customer" | "bot" | "staff";
|
|
12
|
+
export type ChatDeliveryStatus = "sending" | "sent" | "delivered" | "read" | "failed";
|
|
13
|
+
|
|
14
|
+
export interface ChatThreadMessage {
|
|
15
|
+
id: string;
|
|
16
|
+
kind?: "message";
|
|
17
|
+
/** Who wrote it: the customer (incoming), the bot or a staff member (outgoing). */
|
|
18
|
+
author: ChatAuthorKind;
|
|
19
|
+
/** Name shown above the bubble. Defaults to the localized author kind. */
|
|
20
|
+
name?: string;
|
|
21
|
+
at: ChatTimestamp;
|
|
22
|
+
content: ReactNode;
|
|
23
|
+
/** Delivery state, shown under outgoing messages only. Omit it to show none. */
|
|
24
|
+
status?: ChatDeliveryStatus;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A line in the middle of the thread that is not a message, e.g. "The customer asked for a person". */
|
|
28
|
+
export interface ChatThreadNote {
|
|
29
|
+
id: string;
|
|
30
|
+
kind: "note";
|
|
31
|
+
at: ChatTimestamp;
|
|
32
|
+
content: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ChatThreadItem = ChatThreadMessage | ChatThreadNote;
|
|
36
|
+
|
|
37
|
+
export interface ChatThreadLabels {
|
|
38
|
+
conversation: string;
|
|
39
|
+
today: string;
|
|
40
|
+
yesterday: string;
|
|
41
|
+
customer: string;
|
|
42
|
+
bot: string;
|
|
43
|
+
staff: string;
|
|
44
|
+
sending: string;
|
|
45
|
+
sent: string;
|
|
46
|
+
delivered: string;
|
|
47
|
+
read: string;
|
|
48
|
+
notSent: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Ready-made labels; the thread defaults to `en`. Pass `chatThreadLabels.es` for Spanish. */
|
|
52
|
+
export const chatThreadLabels = {
|
|
53
|
+
en: {
|
|
54
|
+
conversation: "Conversation",
|
|
55
|
+
today: "Today",
|
|
56
|
+
yesterday: "Yesterday",
|
|
57
|
+
customer: "Customer",
|
|
58
|
+
bot: "Bot",
|
|
59
|
+
staff: "Staff",
|
|
60
|
+
sending: "Sending",
|
|
61
|
+
sent: "Sent",
|
|
62
|
+
delivered: "Delivered",
|
|
63
|
+
read: "Read",
|
|
64
|
+
notSent: "Not sent",
|
|
65
|
+
},
|
|
66
|
+
es: {
|
|
67
|
+
conversation: "Conversación",
|
|
68
|
+
today: "Hoy",
|
|
69
|
+
yesterday: "Ayer",
|
|
70
|
+
customer: "Cliente",
|
|
71
|
+
bot: "Bot",
|
|
72
|
+
staff: "Equipo",
|
|
73
|
+
sending: "Enviando",
|
|
74
|
+
sent: "Enviado",
|
|
75
|
+
delivered: "Entregado",
|
|
76
|
+
read: "Leído",
|
|
77
|
+
notSent: "No se envió",
|
|
78
|
+
},
|
|
79
|
+
} as const satisfies Record<"en" | "es", ChatThreadLabels>;
|
|
80
|
+
|
|
81
|
+
export type ChatThreadPart =
|
|
82
|
+
| "root"
|
|
83
|
+
| "log"
|
|
84
|
+
| "day"
|
|
85
|
+
| "message"
|
|
86
|
+
| "bubble"
|
|
87
|
+
| "author"
|
|
88
|
+
| "meta"
|
|
89
|
+
| "note"
|
|
90
|
+
| "composer";
|
|
91
|
+
|
|
92
|
+
export interface ChatThreadProps {
|
|
93
|
+
items: readonly ChatThreadItem[];
|
|
94
|
+
/** Slot under the thread, usually a `Textarea` or `PromptInput` with a send button. */
|
|
95
|
+
composer?: ReactNode;
|
|
96
|
+
/** Texts of the thread (name, day labels, authors, delivery states). English by default; see `chatThreadLabels`. */
|
|
97
|
+
labels?: Partial<ChatThreadLabels>;
|
|
98
|
+
/** Accessible name of the thread. Defaults to `labels.conversation`. */
|
|
99
|
+
label?: string;
|
|
100
|
+
/** Called by the retry button of a `failed` message. Without it the button is not shown. */
|
|
101
|
+
onRetry?: (id: string) => void;
|
|
102
|
+
/** Shown instead of the log while there are no items. */
|
|
103
|
+
empty?: ReactNode;
|
|
104
|
+
/** `Intl` locale for times and day labels. */
|
|
105
|
+
locale?: string;
|
|
106
|
+
/** Time zone for times and day breaks; the local one when omitted. */
|
|
107
|
+
timeZone?: string;
|
|
108
|
+
/** The instant "Today" refers to. Pass a fixed value for stable output. Defaults to the current time. */
|
|
109
|
+
now?: ChatTimestamp;
|
|
110
|
+
className?: string;
|
|
111
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
112
|
+
classNames?: ClassNames<ChatThreadPart>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
116
|
+
|
|
117
|
+
const bubbleTone: Record<ChatAuthorKind, string> = {
|
|
118
|
+
customer: "bg-surface-2 text-ink",
|
|
119
|
+
bot: "border border-accent-line bg-accent-soft text-accent-ink",
|
|
120
|
+
staff: "bg-accent text-on-accent",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
function Status({ status, labels }: { status: ChatDeliveryStatus; labels: ChatThreadLabels }) {
|
|
124
|
+
const label = {
|
|
125
|
+
sending: labels.sending,
|
|
126
|
+
sent: labels.sent,
|
|
127
|
+
delivered: labels.delivered,
|
|
128
|
+
read: labels.read,
|
|
129
|
+
failed: labels.notSent,
|
|
130
|
+
}[status];
|
|
131
|
+
return (
|
|
132
|
+
<span
|
|
133
|
+
data-status={status}
|
|
134
|
+
className={cn(
|
|
135
|
+
"inline-flex items-center gap-1",
|
|
136
|
+
status === "read" && "text-accent-ink",
|
|
137
|
+
status === "failed" && "text-danger",
|
|
138
|
+
)}
|
|
139
|
+
>
|
|
140
|
+
{status === "sent" ? <Check aria-hidden="true" className="size-3" /> : null}
|
|
141
|
+
{status === "delivered" || status === "read" ? (
|
|
142
|
+
<CheckCheck aria-hidden="true" className="size-3" />
|
|
143
|
+
) : null}
|
|
144
|
+
{label}
|
|
145
|
+
</span>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Business conversation between a customer, a bot and staff: incoming messages on the start side,
|
|
151
|
+
* outgoing ones (bot, staff) on the end side with distinct tones, day separators, optional delivery
|
|
152
|
+
* status, system notes and a composer slot. It is a live `log` that stays at the bottom while new
|
|
153
|
+
* items arrive and you are already there. Colors come from the kit tokens in both schemes. The
|
|
154
|
+
* `ai/` chat parts model user and assistant only; this one models the three authors of a shop chat.
|
|
155
|
+
*/
|
|
156
|
+
export function ChatThread({
|
|
157
|
+
items,
|
|
158
|
+
composer,
|
|
159
|
+
labels: labelsProp,
|
|
160
|
+
label,
|
|
161
|
+
onRetry,
|
|
162
|
+
empty,
|
|
163
|
+
locale,
|
|
164
|
+
timeZone,
|
|
165
|
+
now,
|
|
166
|
+
className,
|
|
167
|
+
classNames,
|
|
168
|
+
}: ChatThreadProps) {
|
|
169
|
+
const labels: ChatThreadLabels = { ...chatThreadLabels.en, ...labelsProp };
|
|
170
|
+
const logRef = useRef<HTMLDivElement>(null);
|
|
171
|
+
const stickToEnd = useRef(true);
|
|
172
|
+
const reference = now ?? new Date();
|
|
173
|
+
const format = { locale, timeZone };
|
|
174
|
+
const authorName = { customer: labels.customer, bot: labels.bot, staff: labels.staff };
|
|
175
|
+
|
|
176
|
+
useIsomorphicLayoutEffect(() => {
|
|
177
|
+
const log = logRef.current;
|
|
178
|
+
if (log && stickToEnd.current) log.scrollTop = log.scrollHeight;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<section
|
|
183
|
+
aria-label={label ?? labels.conversation}
|
|
184
|
+
className={cn("flex min-h-0 min-w-0 flex-col", classNames?.root, className)}
|
|
185
|
+
>
|
|
186
|
+
{items.length === 0 && empty != null ? (
|
|
187
|
+
<div className="flex flex-1 items-center justify-center p-card">{empty}</div>
|
|
188
|
+
) : (
|
|
189
|
+
<div
|
|
190
|
+
ref={logRef}
|
|
191
|
+
role="log"
|
|
192
|
+
aria-live="polite"
|
|
193
|
+
aria-relevant="additions"
|
|
194
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable log must be reachable with the keyboard
|
|
195
|
+
tabIndex={0}
|
|
196
|
+
onScroll={(event) => {
|
|
197
|
+
const log = event.currentTarget;
|
|
198
|
+
stickToEnd.current = log.scrollHeight - log.scrollTop - log.clientHeight < 80;
|
|
199
|
+
}}
|
|
200
|
+
className={cn(
|
|
201
|
+
"min-h-0 flex-1 overflow-y-auto overscroll-contain p-density focus-visible:focus-ring",
|
|
202
|
+
classNames?.log,
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
205
|
+
<ol className="m-0 flex list-none flex-col gap-2 p-0">
|
|
206
|
+
{withDayBreaks(items, timeZone).map(({ item, dayStart }) => (
|
|
207
|
+
<ChatThreadRow
|
|
208
|
+
key={item.id}
|
|
209
|
+
item={item}
|
|
210
|
+
dayLabel={
|
|
211
|
+
dayStart
|
|
212
|
+
? formatDay(
|
|
213
|
+
item.at,
|
|
214
|
+
reference,
|
|
215
|
+
{ today: labels.today, yesterday: labels.yesterday },
|
|
216
|
+
format,
|
|
217
|
+
)
|
|
218
|
+
: undefined
|
|
219
|
+
}
|
|
220
|
+
dayValue={dayStart ? dayKey(item.at, timeZone) : undefined}
|
|
221
|
+
time={formatTime(item.at, format)}
|
|
222
|
+
authorName={authorName}
|
|
223
|
+
labels={labels}
|
|
224
|
+
onRetry={onRetry}
|
|
225
|
+
classNames={classNames}
|
|
226
|
+
/>
|
|
227
|
+
))}
|
|
228
|
+
</ol>
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
{composer != null ? (
|
|
232
|
+
<div
|
|
233
|
+
className={cn("shrink-0 border-t-divider p-density", classNames?.composer)}
|
|
234
|
+
data-slot="composer"
|
|
235
|
+
>
|
|
236
|
+
{composer}
|
|
237
|
+
</div>
|
|
238
|
+
) : null}
|
|
239
|
+
</section>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface RowProps {
|
|
244
|
+
item: ChatThreadItem;
|
|
245
|
+
dayLabel: string | undefined;
|
|
246
|
+
dayValue: string | undefined;
|
|
247
|
+
time: string;
|
|
248
|
+
authorName: Record<ChatAuthorKind, string>;
|
|
249
|
+
labels: ChatThreadLabels;
|
|
250
|
+
onRetry: ((id: string) => void) | undefined;
|
|
251
|
+
classNames: ClassNames<ChatThreadPart> | undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function ChatThreadRow({
|
|
255
|
+
item,
|
|
256
|
+
dayLabel,
|
|
257
|
+
dayValue,
|
|
258
|
+
time,
|
|
259
|
+
authorName,
|
|
260
|
+
labels,
|
|
261
|
+
onRetry,
|
|
262
|
+
classNames,
|
|
263
|
+
}: RowProps) {
|
|
264
|
+
const strings = useUiStrings();
|
|
265
|
+
return (
|
|
266
|
+
<>
|
|
267
|
+
{dayLabel ? (
|
|
268
|
+
<li className={cn("flex justify-center py-1", classNames?.day)} data-slot="day">
|
|
269
|
+
<time
|
|
270
|
+
dateTime={dayValue}
|
|
271
|
+
className="rounded-badge bg-sunken px-2.5 py-0.5 text-ink-2 text-meta"
|
|
272
|
+
>
|
|
273
|
+
{dayLabel}
|
|
274
|
+
</time>
|
|
275
|
+
</li>
|
|
276
|
+
) : null}
|
|
277
|
+
{item.kind === "note" ? (
|
|
278
|
+
<li className="flex justify-center" data-kind="note">
|
|
279
|
+
<p
|
|
280
|
+
className={cn(
|
|
281
|
+
"m-0 max-w-[85%] rounded-badge bg-sunken px-3 py-1 text-center text-ink-2 text-meta",
|
|
282
|
+
classNames?.note,
|
|
283
|
+
)}
|
|
284
|
+
>
|
|
285
|
+
{item.content}
|
|
286
|
+
</p>
|
|
287
|
+
</li>
|
|
288
|
+
) : (
|
|
289
|
+
<li
|
|
290
|
+
data-author={item.author}
|
|
291
|
+
className={cn(
|
|
292
|
+
"flex",
|
|
293
|
+
item.author === "customer" ? "justify-start" : "justify-end",
|
|
294
|
+
classNames?.message,
|
|
295
|
+
)}
|
|
296
|
+
>
|
|
297
|
+
<div
|
|
298
|
+
className={cn(
|
|
299
|
+
"flex min-w-0 max-w-[min(34rem,85%)] flex-col gap-0.5",
|
|
300
|
+
item.author === "customer" ? "items-start" : "items-end",
|
|
301
|
+
)}
|
|
302
|
+
>
|
|
303
|
+
<span className={cn("text-ink-3 text-meta", classNames?.author)}>
|
|
304
|
+
{item.name ?? authorName[item.author]}
|
|
305
|
+
</span>
|
|
306
|
+
<div
|
|
307
|
+
className={cn(
|
|
308
|
+
"min-w-0 whitespace-pre-wrap rounded-card px-3 py-2 text-body [overflow-wrap:anywhere]",
|
|
309
|
+
bubbleTone[item.author],
|
|
310
|
+
classNames?.bubble,
|
|
311
|
+
)}
|
|
312
|
+
>
|
|
313
|
+
{item.content}
|
|
314
|
+
</div>
|
|
315
|
+
<div className={cn("flex items-center gap-2 text-ink-3 text-meta", classNames?.meta)}>
|
|
316
|
+
<time dateTime={new Date(item.at).toISOString()}>{time}</time>
|
|
317
|
+
{item.author !== "customer" && item.status ? (
|
|
318
|
+
<Status status={item.status} labels={labels} />
|
|
319
|
+
) : null}
|
|
320
|
+
{item.status === "failed" && onRetry ? (
|
|
321
|
+
<Button variant="ghost" size="sm" onClick={() => onRetry(item.id)}>
|
|
322
|
+
{strings.retry}
|
|
323
|
+
</Button>
|
|
324
|
+
) : null}
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
</li>
|
|
328
|
+
)}
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type ChatTimestamp = Date | string | number;
|
|
2
|
+
|
|
3
|
+
export interface ChatThreadFormat {
|
|
4
|
+
locale?: string | undefined;
|
|
5
|
+
timeZone?: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const toDate = (at: ChatTimestamp) => (at instanceof Date ? at : new Date(at));
|
|
9
|
+
|
|
10
|
+
/** `YYYY-MM-DD` of the instant in `timeZone` (the local zone when omitted). */
|
|
11
|
+
export function dayKey(at: ChatTimestamp, timeZone?: string): string {
|
|
12
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
13
|
+
timeZone,
|
|
14
|
+
year: "numeric",
|
|
15
|
+
month: "2-digit",
|
|
16
|
+
day: "2-digit",
|
|
17
|
+
}).format(toDate(at));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function shiftDay(key: string, days: number): string {
|
|
21
|
+
const [year = 0, month = 1, day = 1] = key.split("-").map(Number);
|
|
22
|
+
const shifted = new Date(Date.UTC(year, month - 1, day + days));
|
|
23
|
+
return shifted.toISOString().slice(0, 10);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function formatTime(at: ChatTimestamp, { locale, timeZone }: ChatThreadFormat = {}): string {
|
|
27
|
+
return new Intl.DateTimeFormat(locale, {
|
|
28
|
+
timeZone,
|
|
29
|
+
hour: "2-digit",
|
|
30
|
+
minute: "2-digit",
|
|
31
|
+
}).format(toDate(at));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** "Today" and "Yesterday" relative to `now`, otherwise a long date (with the year when it differs). */
|
|
35
|
+
export function formatDay(
|
|
36
|
+
at: ChatTimestamp,
|
|
37
|
+
now: ChatTimestamp,
|
|
38
|
+
labels: { today: string; yesterday: string },
|
|
39
|
+
{ locale, timeZone }: ChatThreadFormat = {},
|
|
40
|
+
): string {
|
|
41
|
+
const key = dayKey(at, timeZone);
|
|
42
|
+
const today = dayKey(now, timeZone);
|
|
43
|
+
if (key === today) return labels.today;
|
|
44
|
+
if (key === shiftDay(today, -1)) return labels.yesterday;
|
|
45
|
+
const sameYear = key.slice(0, 4) === today.slice(0, 4);
|
|
46
|
+
return new Intl.DateTimeFormat(locale, {
|
|
47
|
+
timeZone,
|
|
48
|
+
weekday: "long",
|
|
49
|
+
day: "numeric",
|
|
50
|
+
month: "long",
|
|
51
|
+
...(sameYear ? {} : { year: "numeric" }),
|
|
52
|
+
}).format(toDate(at));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Items in order, each flagged with whether a new day starts at it. */
|
|
56
|
+
export function withDayBreaks<T extends { at: ChatTimestamp }>(
|
|
57
|
+
items: readonly T[],
|
|
58
|
+
timeZone?: string,
|
|
59
|
+
): Array<{ item: T; dayStart: boolean }> {
|
|
60
|
+
let previous: string | null = null;
|
|
61
|
+
return items.map((item) => {
|
|
62
|
+
const key = dayKey(item.at, timeZone);
|
|
63
|
+
const dayStart = key !== previous;
|
|
64
|
+
previous = key;
|
|
65
|
+
return { item, dayStart };
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type ChatAuthorKind,
|
|
3
|
+
type ChatDeliveryStatus,
|
|
4
|
+
ChatThread,
|
|
5
|
+
type ChatThreadItem,
|
|
6
|
+
type ChatThreadLabels,
|
|
7
|
+
type ChatThreadMessage,
|
|
8
|
+
type ChatThreadNote,
|
|
9
|
+
type ChatThreadPart,
|
|
10
|
+
type ChatThreadProps,
|
|
11
|
+
chatThreadLabels,
|
|
12
|
+
} from "./chat-thread.js";
|