@ohmykreee/dsh-remote-control 0.0.0-stage → 1.0.2
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/AGENTS.md +556 -0
- package/INSTALLATION.md +310 -0
- package/LICENSE +21 -0
- package/README.md +195 -2
- package/client.js +3 -0
- package/components.json +20 -0
- package/cordis.patch.yml +3 -0
- package/docs/README.en.md +196 -0
- package/docs/screenshots/en/overview.png +0 -0
- package/docs/screenshots/en/question.png +0 -0
- package/docs/screenshots/zh/overview.png +0 -0
- package/docs/screenshots/zh/question.png +0 -0
- package/icon.svg +24 -0
- package/index.js +2 -0
- package/lib/account.js +1 -0
- package/lib/app-mapping.js +1 -0
- package/lib/i18n.js +1 -0
- package/lib/media-enrich.js +1 -0
- package/lib/notifications.js +1 -0
- package/lib/performance.js +1 -0
- package/lib/platform/index.js +1 -0
- package/lib/probe-adapter.js +1 -0
- package/lib/probe-daemon.js +1 -0
- package/lib/probe.js +1 -0
- package/lib/qr.js +1 -0
- package/lib/runtime.js +1 -0
- package/lib/service.js +1 -0
- package/lib/sessions.js +1 -0
- package/lib/settings.js +1 -0
- package/lib/types.js +1 -0
- package/lib/util.js +1 -0
- package/lib/weather.js +1 -0
- package/lib/ws.js +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +118 -4
- package/scripts/browser-shot.mjs +217 -0
- package/scripts/build-dsh.mjs +228 -0
- package/scripts/build-rust.mjs +319 -0
- package/scripts/build-web.mjs +17 -0
- package/scripts/check-npm-package.mjs +322 -0
- package/scripts/mock-preview.py +574 -0
- package/scripts/screenshot-compose.py +89 -0
- package/scripts/screenshot-device.sh +75 -0
- package/src/dsh/client/api.ts +68 -0
- package/src/dsh/client/i18n.ts +573 -0
- package/src/dsh/client/icons.ts +56 -0
- package/src/dsh/client/index.ts +95 -0
- package/src/dsh/client/logic.ts +310 -0
- package/src/dsh/client/panel.ts +483 -0
- package/src/dsh/client/sections/apps.ts +40 -0
- package/src/dsh/client/sections/balance.ts +38 -0
- package/src/dsh/client/sections/connection.ts +97 -0
- package/src/dsh/client/sections/notifications.ts +43 -0
- package/src/dsh/client/sections/pomodoro.ts +184 -0
- package/src/dsh/client/sections/preferences.ts +138 -0
- package/src/dsh/client/sections/system.ts +120 -0
- package/src/dsh/client/sections/weather.ts +276 -0
- package/src/dsh/client/styles.ts +1119 -0
- package/src/dsh/client/types.ts +366 -0
- package/src/dsh/client/ui.ts +142 -0
- package/src/dsh/index.ts +108 -0
- package/src/dsh/lib/account.ts +520 -0
- package/src/dsh/lib/app-mapping.ts +366 -0
- package/src/dsh/lib/i18n.ts +82 -0
- package/src/dsh/lib/media-enrich.ts +202 -0
- package/src/dsh/lib/notifications.ts +322 -0
- package/src/dsh/lib/performance.ts +279 -0
- package/src/dsh/lib/platform/index.ts +43 -0
- package/src/dsh/lib/probe-adapter.ts +275 -0
- package/src/dsh/lib/probe-daemon.ts +359 -0
- package/src/dsh/lib/probe.ts +395 -0
- package/src/dsh/lib/qr.ts +42 -0
- package/src/dsh/lib/runtime.ts +126 -0
- package/src/dsh/lib/service.ts +1645 -0
- package/src/dsh/lib/sessions.ts +907 -0
- package/src/dsh/lib/settings.ts +468 -0
- package/src/dsh/lib/types.ts +231 -0
- package/src/dsh/lib/util.ts +115 -0
- package/src/dsh/lib/weather.ts +532 -0
- package/src/dsh/lib/ws.ts +328 -0
- package/src/dsh/types/qrcode-generator.d.ts +16 -0
- package/src/rust/Cargo.lock +1431 -0
- package/src/rust/Cargo.toml +68 -0
- package/src/rust/src/cli.rs +233 -0
- package/src/rust/src/daemon.rs +140 -0
- package/src/rust/src/location/linux.rs +118 -0
- package/src/rust/src/location/macos.rs +26 -0
- package/src/rust/src/location/mod.rs +170 -0
- package/src/rust/src/location/windows.rs +205 -0
- package/src/rust/src/main.rs +42 -0
- package/src/rust/src/media/catalog.rs +454 -0
- package/src/rust/src/media/linux.rs +350 -0
- package/src/rust/src/media/macos/accessibility.rs +59 -0
- package/src/rust/src/media/macos.rs +366 -0
- package/src/rust/src/media/mod.rs +298 -0
- package/src/rust/src/media/vendor/apple_music.rs +90 -0
- package/src/rust/src/media/vendor/common.rs +186 -0
- package/src/rust/src/media/vendor/kugou.rs +52 -0
- package/src/rust/src/media/vendor/kuwo.rs +49 -0
- package/src/rust/src/media/vendor/mod.rs +75 -0
- package/src/rust/src/media/vendor/netease.rs +1715 -0
- package/src/rust/src/media/vendor/qishui.rs +36 -0
- package/src/rust/src/media/vendor/qqmusic.rs +33 -0
- package/src/rust/src/media/vendor/spotify.rs +46 -0
- package/src/rust/src/media/vendor/wesing.rs +39 -0
- package/src/rust/src/media/vendor/youtube_music.rs +49 -0
- package/src/rust/src/media/windows/accessibility.rs +85 -0
- package/src/rust/src/media/windows/audio.rs +116 -0
- package/src/rust/src/media/windows/private.rs +291 -0
- package/src/rust/src/media/windows.rs +775 -0
- package/src/rust/src/notifications/linux.rs +276 -0
- package/src/rust/src/notifications/macos.rs +382 -0
- package/src/rust/src/notifications/mod.rs +244 -0
- package/src/rust/src/notifications/windows.rs +565 -0
- package/src/rust/src/perf/common.rs +109 -0
- package/src/rust/src/perf/linux.rs +282 -0
- package/src/rust/src/perf/macos.rs +28 -0
- package/src/rust/src/perf/mod.rs +157 -0
- package/src/rust/src/perf/windows.rs +981 -0
- package/src/rust/src/util.rs +360 -0
- package/src/rust/src/volume/linux.rs +195 -0
- package/src/rust/src/volume/macos.rs +54 -0
- package/src/rust/src/volume/mod.rs +116 -0
- package/src/rust/src/volume/windows.rs +75 -0
- package/src/rust/tests/cli.rs +79 -0
- package/src/rust/tests/daemon.rs +107 -0
- package/src/svelte/App.svelte +385 -0
- package/src/svelte/index.html +18 -0
- package/src/svelte/lib/billing.svelte.ts +228 -0
- package/src/svelte/lib/components/BalanceCard.svelte +173 -0
- package/src/svelte/lib/components/ClockCard.svelte +183 -0
- package/src/svelte/lib/components/CountdownCard.svelte +261 -0
- package/src/svelte/lib/components/CpuMemoryCard.svelte +238 -0
- package/src/svelte/lib/components/EmptyState.svelte +34 -0
- package/src/svelte/lib/components/GpuCard.svelte +245 -0
- package/src/svelte/lib/components/HomePage.svelte +34 -0
- package/src/svelte/lib/components/MusicControls.svelte +256 -0
- package/src/svelte/lib/components/MusicCover.svelte +88 -0
- package/src/svelte/lib/components/MusicPage.svelte +116 -0
- package/src/svelte/lib/components/NotificationsCard.svelte +109 -0
- package/src/svelte/lib/components/Panel.svelte +22 -0
- package/src/svelte/lib/components/PerformancePage.svelte +55 -0
- package/src/svelte/lib/components/PomodoroCard.svelte +250 -0
- package/src/svelte/lib/components/QuestionSheet.svelte +354 -0
- package/src/svelte/lib/components/RadialGauge.svelte +99 -0
- package/src/svelte/lib/components/Rail.svelte +217 -0
- package/src/svelte/lib/components/SectionHeader.svelte +40 -0
- package/src/svelte/lib/components/SeekBar.svelte +421 -0
- package/src/svelte/lib/components/SessionList.svelte +364 -0
- package/src/svelte/lib/components/SessionStats.svelte +98 -0
- package/src/svelte/lib/components/SessionsPage.svelte +61 -0
- package/src/svelte/lib/components/SpendCard.svelte +105 -0
- package/src/svelte/lib/components/ThermalCard.svelte +249 -0
- package/src/svelte/lib/components/Toast.svelte +32 -0
- package/src/svelte/lib/components/WeatherIcon.svelte +40 -0
- package/src/svelte/lib/components/WeatherPanel.svelte +420 -0
- package/src/svelte/lib/components/ui/alert/alert-action.svelte +20 -0
- package/src/svelte/lib/components/ui/alert/alert-description.svelte +23 -0
- package/src/svelte/lib/components/ui/alert/alert-title.svelte +23 -0
- package/src/svelte/lib/components/ui/alert/alert.svelte +43 -0
- package/src/svelte/lib/components/ui/alert/index.ts +17 -0
- package/src/svelte/lib/components/ui/avatar/avatar-badge.svelte +26 -0
- package/src/svelte/lib/components/ui/avatar/avatar-fallback.svelte +20 -0
- package/src/svelte/lib/components/ui/avatar/avatar-group-count.svelte +23 -0
- package/src/svelte/lib/components/ui/avatar/avatar-group.svelte +23 -0
- package/src/svelte/lib/components/ui/avatar/avatar-image.svelte +17 -0
- package/src/svelte/lib/components/ui/avatar/avatar.svelte +26 -0
- package/src/svelte/lib/components/ui/avatar/index.ts +22 -0
- package/src/svelte/lib/components/ui/badge/badge.svelte +49 -0
- package/src/svelte/lib/components/ui/badge/index.ts +2 -0
- package/src/svelte/lib/components/ui/button/button.svelte +82 -0
- package/src/svelte/lib/components/ui/button/index.ts +17 -0
- package/src/svelte/lib/components/ui/card/card-action.svelte +23 -0
- package/src/svelte/lib/components/ui/card/card-content.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-description.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-footer.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card-header.svelte +23 -0
- package/src/svelte/lib/components/ui/card/card-title.svelte +20 -0
- package/src/svelte/lib/components/ui/card/card.svelte +22 -0
- package/src/svelte/lib/components/ui/card/index.ts +25 -0
- package/src/svelte/lib/components/ui/dialog/dialog-close.svelte +11 -0
- package/src/svelte/lib/components/ui/dialog/dialog-content.svelte +48 -0
- package/src/svelte/lib/components/ui/dialog/dialog-description.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-footer.svelte +32 -0
- package/src/svelte/lib/components/ui/dialog/dialog-header.svelte +20 -0
- package/src/svelte/lib/components/ui/dialog/dialog-overlay.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/dialog/dialog-title.svelte +17 -0
- package/src/svelte/lib/components/ui/dialog/dialog-trigger.svelte +11 -0
- package/src/svelte/lib/components/ui/dialog/dialog.svelte +7 -0
- package/src/svelte/lib/components/ui/dialog/index.ts +34 -0
- package/src/svelte/lib/components/ui/empty/empty-content.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/empty-description.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/empty-header.svelte +20 -0
- package/src/svelte/lib/components/ui/empty/empty-media.svelte +41 -0
- package/src/svelte/lib/components/ui/empty/empty-title.svelte +20 -0
- package/src/svelte/lib/components/ui/empty/empty.svelte +23 -0
- package/src/svelte/lib/components/ui/empty/index.ts +22 -0
- package/src/svelte/lib/components/ui/input/index.ts +7 -0
- package/src/svelte/lib/components/ui/input/input.svelte +48 -0
- package/src/svelte/lib/components/ui/progress/index.ts +7 -0
- package/src/svelte/lib/components/ui/progress/progress.svelte +27 -0
- package/src/svelte/lib/components/ui/scroll-area/index.ts +10 -0
- package/src/svelte/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte +30 -0
- package/src/svelte/lib/components/ui/scroll-area/scroll-area.svelte +43 -0
- package/src/svelte/lib/components/ui/separator/index.ts +7 -0
- package/src/svelte/lib/components/ui/separator/separator.svelte +21 -0
- package/src/svelte/lib/components/ui/sheet/index.ts +34 -0
- package/src/svelte/lib/components/ui/sheet/sheet-close.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet-content.svelte +55 -0
- package/src/svelte/lib/components/ui/sheet/sheet-description.svelte +17 -0
- package/src/svelte/lib/components/ui/sheet/sheet-footer.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-header.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-overlay.svelte +20 -0
- package/src/svelte/lib/components/ui/sheet/sheet-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet-title.svelte +17 -0
- package/src/svelte/lib/components/ui/sheet/sheet-trigger.svelte +7 -0
- package/src/svelte/lib/components/ui/sheet/sheet.svelte +7 -0
- package/src/svelte/lib/components/ui/skeleton/index.ts +7 -0
- package/src/svelte/lib/components/ui/skeleton/skeleton.svelte +17 -0
- package/src/svelte/lib/components/ui/slider/index.ts +7 -0
- package/src/svelte/lib/components/ui/slider/slider.svelte +52 -0
- package/src/svelte/lib/components/ui/tooltip/index.ts +19 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-content.svelte +51 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/src/svelte/lib/components/ui/tooltip/tooltip.svelte +7 -0
- package/src/svelte/lib/countdown.svelte.ts +252 -0
- package/src/svelte/lib/format.ts +199 -0
- package/src/svelte/lib/i18n.svelte.ts +583 -0
- package/src/svelte/lib/media.ts +32 -0
- package/src/svelte/lib/pages.ts +18 -0
- package/src/svelte/lib/pomodoro.svelte.ts +223 -0
- package/src/svelte/lib/session-tree.ts +80 -0
- package/src/svelte/lib/state.svelte.ts +359 -0
- package/src/svelte/lib/timer-alarm.svelte.ts +319 -0
- package/src/svelte/lib/types.ts +306 -0
- package/src/svelte/lib/utils.ts +8 -0
- package/src/svelte/lib/weather.ts +84 -0
- package/src/svelte/lib/ws.ts +104 -0
- package/src/svelte/main.ts +13 -0
- package/src/svelte/styles/global.css +315 -0
- package/src/svelte/vite-env.d.ts +12 -0
- package/static/fonts/LICENSE.txt +287 -0
- package/static/icon.svg +24 -0
- package/static/manifest.webmanifest +18 -0
- package/svelte.config.js +5 -0
- package/tsconfig.dsh-client.json +18 -0
- package/tsconfig.dsh.json +21 -0
- package/tsconfig.json +20 -0
- package/vite.config.js +31 -0
- package/web/assets/index-DLdSfnJ3.css +1 -0
- package/web/assets/index-YNE8X0Uy.js +6 -0
- package/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/web/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/web/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/web/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/web/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/web/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/web/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/web/assets/noto-sans-sc-100-wght-normal-DluiXYzi.woff2 +0 -0
- package/web/assets/noto-sans-sc-101-wght-normal-CPkZHnw0.woff2 +0 -0
- package/web/assets/noto-sans-sc-102-wght-normal-gzIulUH6.woff2 +0 -0
- package/web/assets/noto-sans-sc-103-wght-normal-CJfSBxFo.woff2 +0 -0
- package/web/assets/noto-sans-sc-104-wght-normal-B3QMglgE.woff2 +0 -0
- package/web/assets/noto-sans-sc-105-wght-normal-xXh_OMfk.woff2 +0 -0
- package/web/assets/noto-sans-sc-106-wght-normal-B9n3jMjP.woff2 +0 -0
- package/web/assets/noto-sans-sc-107-wght-normal-D7fvVprN.woff2 +0 -0
- package/web/assets/noto-sans-sc-108-wght-normal-J0_LhxVo.woff2 +0 -0
- package/web/assets/noto-sans-sc-109-wght-normal-Dsp-De_0.woff2 +0 -0
- package/web/assets/noto-sans-sc-110-wght-normal-DE_6NUrb.woff2 +0 -0
- package/web/assets/noto-sans-sc-111-wght-normal-C4S-TlTn.woff2 +0 -0
- package/web/assets/noto-sans-sc-112-wght-normal-BcFuP3w6.woff2 +0 -0
- package/web/assets/noto-sans-sc-113-wght-normal-Dk932kmj.woff2 +0 -0
- package/web/assets/noto-sans-sc-114-wght-normal-CO_5Xo-i.woff2 +0 -0
- package/web/assets/noto-sans-sc-115-wght-normal-BWy07H14.woff2 +0 -0
- package/web/assets/noto-sans-sc-116-wght-normal-B4HVAfHo.woff2 +0 -0
- package/web/assets/noto-sans-sc-117-wght-normal-siZzFqgK.woff2 +0 -0
- package/web/assets/noto-sans-sc-118-wght-normal-xhBB7f6V.woff2 +0 -0
- package/web/assets/noto-sans-sc-119-wght-normal-Ck_g2FGz.woff2 +0 -0
- package/web/assets/noto-sans-sc-21-wght-normal-D0x9-yBt.woff2 +0 -0
- package/web/assets/noto-sans-sc-22-wght-normal-BBUVTShg.woff2 +0 -0
- package/web/assets/noto-sans-sc-23-wght-normal-Du1oYWkE.woff2 +0 -0
- package/web/assets/noto-sans-sc-24-wght-normal-CmWjJ0gt.woff2 +0 -0
- package/web/assets/noto-sans-sc-25-wght-normal-BFHiqilg.woff2 +0 -0
- package/web/assets/noto-sans-sc-26-wght-normal-C0sF2Z2f.woff2 +0 -0
- package/web/assets/noto-sans-sc-27-wght-normal-COFdrquJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-28-wght-normal-DMgdNu1o.woff2 +0 -0
- package/web/assets/noto-sans-sc-29-wght-normal-Cmq8em30.woff2 +0 -0
- package/web/assets/noto-sans-sc-30-wght-normal-CZWqZ3yU.woff2 +0 -0
- package/web/assets/noto-sans-sc-31-wght-normal-Wfi_lutW.woff2 +0 -0
- package/web/assets/noto-sans-sc-32-wght-normal-BRJQ4PY5.woff2 +0 -0
- package/web/assets/noto-sans-sc-33-wght-normal-CUVQXNAJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-34-wght-normal-Bspba0wC.woff2 +0 -0
- package/web/assets/noto-sans-sc-35-wght-normal-K8fX_YPG.woff2 +0 -0
- package/web/assets/noto-sans-sc-36-wght-normal-CkITyjoT.woff2 +0 -0
- package/web/assets/noto-sans-sc-37-wght-normal-WCZ2zfEe.woff2 +0 -0
- package/web/assets/noto-sans-sc-38-wght-normal-DeM7CUce.woff2 +0 -0
- package/web/assets/noto-sans-sc-39-wght-normal-BMZNLWQU.woff2 +0 -0
- package/web/assets/noto-sans-sc-4-wght-normal-AR5bdDjz.woff2 +0 -0
- package/web/assets/noto-sans-sc-40-wght-normal-BQ5xpS5j.woff2 +0 -0
- package/web/assets/noto-sans-sc-41-wght-normal-Hthm7FFi.woff2 +0 -0
- package/web/assets/noto-sans-sc-42-wght-normal-eaS2gKds.woff2 +0 -0
- package/web/assets/noto-sans-sc-43-wght-normal-o-T53XXV.woff2 +0 -0
- package/web/assets/noto-sans-sc-44-wght-normal-BJH5J4Ez.woff2 +0 -0
- package/web/assets/noto-sans-sc-45-wght-normal-BKuxSCOJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-46-wght-normal-BR_5Mu6e.woff2 +0 -0
- package/web/assets/noto-sans-sc-47-wght-normal-CyY7gKNX.woff2 +0 -0
- package/web/assets/noto-sans-sc-48-wght-normal-BNMfTR6k.woff2 +0 -0
- package/web/assets/noto-sans-sc-49-wght-normal-DX-0y7wg.woff2 +0 -0
- package/web/assets/noto-sans-sc-5-wght-normal-CfWugllB.woff2 +0 -0
- package/web/assets/noto-sans-sc-50-wght-normal-DAOGW-Dr.woff2 +0 -0
- package/web/assets/noto-sans-sc-51-wght-normal-BlFLOjcP.woff2 +0 -0
- package/web/assets/noto-sans-sc-52-wght-normal-OZjrybnw.woff2 +0 -0
- package/web/assets/noto-sans-sc-53-wght-normal-CwyWNT6x.woff2 +0 -0
- package/web/assets/noto-sans-sc-54-wght-normal-DM0nRe18.woff2 +0 -0
- package/web/assets/noto-sans-sc-55-wght-normal-DBK2wUOR.woff2 +0 -0
- package/web/assets/noto-sans-sc-56-wght-normal-C-VKK1LS.woff2 +0 -0
- package/web/assets/noto-sans-sc-57-wght-normal-Cdbfh5kq.woff2 +0 -0
- package/web/assets/noto-sans-sc-58-wght-normal-CflMKARZ.woff2 +0 -0
- package/web/assets/noto-sans-sc-59-wght-normal-BS4Kwzxx.woff2 +0 -0
- package/web/assets/noto-sans-sc-6-wght-normal-ChnZIQfQ.woff2 +0 -0
- package/web/assets/noto-sans-sc-60-wght-normal-B7QOYsXJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-61-wght-normal-C8JjQS7w.woff2 +0 -0
- package/web/assets/noto-sans-sc-62-wght-normal-bS4wq1Gg.woff2 +0 -0
- package/web/assets/noto-sans-sc-63-wght-normal-BJr8P-OB.woff2 +0 -0
- package/web/assets/noto-sans-sc-64-wght-normal-DVB11t7j.woff2 +0 -0
- package/web/assets/noto-sans-sc-65-wght-normal-DMPCXBvK.woff2 +0 -0
- package/web/assets/noto-sans-sc-66-wght-normal-BobaG10V.woff2 +0 -0
- package/web/assets/noto-sans-sc-67-wght-normal-Dzk7WhCR.woff2 +0 -0
- package/web/assets/noto-sans-sc-68-wght-normal-DGbCD9xu.woff2 +0 -0
- package/web/assets/noto-sans-sc-69-wght-normal-Ctrv1EqA.woff2 +0 -0
- package/web/assets/noto-sans-sc-70-wght-normal-RgTO941D.woff2 +0 -0
- package/web/assets/noto-sans-sc-71-wght-normal-D9sG-CWv.woff2 +0 -0
- package/web/assets/noto-sans-sc-72-wght-normal-C4oWy3ul.woff2 +0 -0
- package/web/assets/noto-sans-sc-73-wght-normal-B1ZoOTgM.woff2 +0 -0
- package/web/assets/noto-sans-sc-74-wght-normal-F7dH_rZJ.woff2 +0 -0
- package/web/assets/noto-sans-sc-75-wght-normal-Cp2wp4si.woff2 +0 -0
- package/web/assets/noto-sans-sc-76-wght-normal-B494D7xS.woff2 +0 -0
- package/web/assets/noto-sans-sc-77-wght-normal-B3MVY9Ax.woff2 +0 -0
- package/web/assets/noto-sans-sc-78-wght-normal-5jX7iNMC.woff2 +0 -0
- package/web/assets/noto-sans-sc-79-wght-normal-BIoZy8fr.woff2 +0 -0
- package/web/assets/noto-sans-sc-80-wght-normal-Bje1Fxy1.woff2 +0 -0
- package/web/assets/noto-sans-sc-81-wght-normal-B2NN7Qi3.woff2 +0 -0
- package/web/assets/noto-sans-sc-82-wght-normal-CUggNZi4.woff2 +0 -0
- package/web/assets/noto-sans-sc-83-wght-normal-99rD8YO-.woff2 +0 -0
- package/web/assets/noto-sans-sc-84-wght-normal-zMBmUocm.woff2 +0 -0
- package/web/assets/noto-sans-sc-85-wght-normal-CjI3qdxG.woff2 +0 -0
- package/web/assets/noto-sans-sc-86-wght-normal-BHY8TVEH.woff2 +0 -0
- package/web/assets/noto-sans-sc-87-wght-normal-DioZSHnU.woff2 +0 -0
- package/web/assets/noto-sans-sc-88-wght-normal-BXYxwf2t.woff2 +0 -0
- package/web/assets/noto-sans-sc-89-wght-normal-ClMFrFaL.woff2 +0 -0
- package/web/assets/noto-sans-sc-90-wght-normal-BnOlPreP.woff2 +0 -0
- package/web/assets/noto-sans-sc-91-wght-normal-DTr9RQcS.woff2 +0 -0
- package/web/assets/noto-sans-sc-97-wght-normal-9u6Aiav-.woff2 +0 -0
- package/web/assets/noto-sans-sc-98-wght-normal-BR-H2C0V.woff2 +0 -0
- package/web/assets/noto-sans-sc-99-wght-normal-BI6XPoxp.woff2 +0 -0
- package/web/assets/noto-sans-sc-cyrillic-wght-normal-BGmsQlw-.woff2 +0 -0
- package/web/assets/noto-sans-sc-latin-ext-wght-normal-DuJTpTg_.woff2 +0 -0
- package/web/assets/noto-sans-sc-latin-wght-normal-DDW8mKAR.woff2 +0 -0
- package/web/assets/noto-sans-sc-vietnamese-wght-normal-Bi3ATJ76.woff2 +0 -0
- package/web/fonts/LICENSE.txt +287 -0
- package/web/icon.svg +24 -0
- package/web/index.html +19 -0
- package/web/manifest.webmanifest +18 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
acquirePomodoro,
|
|
5
|
+
dismissAlarm,
|
|
6
|
+
formatRemaining,
|
|
7
|
+
pomodoro,
|
|
8
|
+
pomodoroProgress,
|
|
9
|
+
resetPomodoro,
|
|
10
|
+
switchPomodoroPhase,
|
|
11
|
+
togglePomodoro,
|
|
12
|
+
} from '../pomodoro.svelte';
|
|
13
|
+
import { Button } from '$lib/components/ui/button/index.js';
|
|
14
|
+
import { Progress } from '$lib/components/ui/progress/index.js';
|
|
15
|
+
import { Badge } from '$lib/components/ui/badge/index.js';
|
|
16
|
+
import { t } from '../i18n.svelte';
|
|
17
|
+
import { cn } from '$lib/utils.js';
|
|
18
|
+
import Play from '@lucide/svelte/icons/play';
|
|
19
|
+
import Pause from '@lucide/svelte/icons/pause';
|
|
20
|
+
import RotateCcw from '@lucide/svelte/icons/rotate-ccw';
|
|
21
|
+
import BellRing from '@lucide/svelte/icons/bell-ring';
|
|
22
|
+
import Timer from '@lucide/svelte/icons/timer';
|
|
23
|
+
|
|
24
|
+
// Every page is rendered twice (infinite-loop clones), so the engine is
|
|
25
|
+
// reference-counted and shared instead of running once per card instance.
|
|
26
|
+
onMount(() => acquirePomodoro());
|
|
27
|
+
|
|
28
|
+
const phaseLabel = $derived(
|
|
29
|
+
pomodoro.finished
|
|
30
|
+
? pomodoro.phase === 'focus'
|
|
31
|
+
? t('focusDone')
|
|
32
|
+
: t('breakDone')
|
|
33
|
+
: pomodoro.phase === 'focus'
|
|
34
|
+
? t('focus')
|
|
35
|
+
: t('rest'),
|
|
36
|
+
);
|
|
37
|
+
const primaryLabel = $derived(
|
|
38
|
+
pomodoro.alarmActive
|
|
39
|
+
? t('stopAlarm')
|
|
40
|
+
: pomodoro.finished
|
|
41
|
+
? pomodoro.phase === 'focus'
|
|
42
|
+
? t('startBreak')
|
|
43
|
+
: t('startFocus')
|
|
44
|
+
: pomodoro.running
|
|
45
|
+
? t('pause')
|
|
46
|
+
: t('start'),
|
|
47
|
+
);
|
|
48
|
+
const time = $derived(formatRemaining(pomodoro.remainingMs));
|
|
49
|
+
const percent = $derived(pomodoroProgress());
|
|
50
|
+
|
|
51
|
+
function handlePrimary(): void {
|
|
52
|
+
if (pomodoro.alarmActive) {
|
|
53
|
+
dismissAlarm();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
togglePomodoro();
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<div
|
|
61
|
+
class="pomodoro"
|
|
62
|
+
class:is-break={pomodoro.phase === 'break'}
|
|
63
|
+
class:is-finished={pomodoro.finished}
|
|
64
|
+
class:is-alarm={pomodoro.alarmActive}
|
|
65
|
+
data-phase={pomodoro.phase}
|
|
66
|
+
data-running={pomodoro.running ? 'true' : 'false'}
|
|
67
|
+
>
|
|
68
|
+
<div class="flex min-w-0 flex-1 flex-col justify-center">
|
|
69
|
+
<div class="flex items-center gap-2.5">
|
|
70
|
+
<Timer class="size-[18px] text-brand" strokeWidth={1.8} />
|
|
71
|
+
<span class="text-[16px] font-medium text-muted-foreground">{t('pomodoro')}</span>
|
|
72
|
+
<button
|
|
73
|
+
class="phase-button"
|
|
74
|
+
type="button"
|
|
75
|
+
disabled={pomodoro.running}
|
|
76
|
+
title={t('switchPhase')}
|
|
77
|
+
onclick={switchPomodoroPhase}
|
|
78
|
+
>
|
|
79
|
+
{phaseLabel}
|
|
80
|
+
</button>
|
|
81
|
+
{#if pomodoro.rounds > 0}
|
|
82
|
+
<Badge
|
|
83
|
+
variant="outline"
|
|
84
|
+
class="h-6 border-border bg-secondary px-2 text-[12px] font-medium text-muted-foreground"
|
|
85
|
+
>
|
|
86
|
+
{t('roundCount', { count: pomodoro.rounds })}
|
|
87
|
+
</Badge>
|
|
88
|
+
{/if}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div class="pomodoro-main-row">
|
|
92
|
+
<span class="pomodoro-time numeric" aria-live="off">{time}</span>
|
|
93
|
+
|
|
94
|
+
<div class="flex shrink-0 items-center gap-2.5">
|
|
95
|
+
<Button
|
|
96
|
+
class={cn(
|
|
97
|
+
'h-12 gap-2 rounded-[14px] px-5 text-[16px] font-semibold shadow-none',
|
|
98
|
+
pomodoro.finished && !pomodoro.alarmActive && 'bg-success text-[#041b14] hover:bg-success/90',
|
|
99
|
+
pomodoro.alarmActive && 'bg-danger text-white hover:bg-danger/90',
|
|
100
|
+
)}
|
|
101
|
+
type="button"
|
|
102
|
+
title={primaryLabel}
|
|
103
|
+
onclick={handlePrimary}
|
|
104
|
+
>
|
|
105
|
+
{#if pomodoro.alarmActive}
|
|
106
|
+
<BellRing class="size-[19px]" strokeWidth={1.9} />
|
|
107
|
+
{:else if pomodoro.running}
|
|
108
|
+
<Pause class="size-[19px]" strokeWidth={1.9} />
|
|
109
|
+
{:else}
|
|
110
|
+
<Play class="size-[19px] fill-current" strokeWidth={1.9} />
|
|
111
|
+
{/if}
|
|
112
|
+
<span>{primaryLabel}</span>
|
|
113
|
+
</Button>
|
|
114
|
+
<Button
|
|
115
|
+
variant="outline"
|
|
116
|
+
size="icon"
|
|
117
|
+
class="size-12 rounded-[14px] border-border bg-transparent text-muted-foreground hover:bg-secondary hover:text-foreground"
|
|
118
|
+
type="button"
|
|
119
|
+
onclick={resetPomodoro}
|
|
120
|
+
aria-label={t('resetPomodoro')}
|
|
121
|
+
title={t('reset')}
|
|
122
|
+
>
|
|
123
|
+
<RotateCcw class="size-[20px]" strokeWidth={1.8} />
|
|
124
|
+
</Button>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<Progress
|
|
130
|
+
value={percent}
|
|
131
|
+
class={cn(
|
|
132
|
+
'mt-3 h-1.5 bg-secondary',
|
|
133
|
+
pomodoro.finished ? '[&>[data-slot=progress-indicator]]:bg-success' : '[&>[data-slot=progress-indicator]]:bg-brand',
|
|
134
|
+
)}
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<style>
|
|
139
|
+
.pomodoro {
|
|
140
|
+
display: flex;
|
|
141
|
+
min-height: 142px;
|
|
142
|
+
max-height: 230px;
|
|
143
|
+
flex: 1 1 auto;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
margin: clamp(20px, 3.5vh, 32px) 0;
|
|
147
|
+
padding: 16px 18px 14px;
|
|
148
|
+
border: 1px solid var(--border);
|
|
149
|
+
border-radius: 19px;
|
|
150
|
+
background: color-mix(in srgb, var(--secondary) 46%, transparent);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.phase-button {
|
|
154
|
+
min-width: 0;
|
|
155
|
+
padding: 3px 8px;
|
|
156
|
+
border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
|
|
157
|
+
border-radius: 999px;
|
|
158
|
+
background: var(--brand-soft);
|
|
159
|
+
color: var(--brand);
|
|
160
|
+
font-size: 14px;
|
|
161
|
+
font-weight: 600;
|
|
162
|
+
line-height: 1.2;
|
|
163
|
+
text-align: left;
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.phase-button:disabled {
|
|
168
|
+
cursor: default;
|
|
169
|
+
color: var(--foreground);
|
|
170
|
+
background: var(--secondary);
|
|
171
|
+
border-color: var(--border);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.pomodoro-main-row {
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: space-between;
|
|
178
|
+
gap: 16px;
|
|
179
|
+
margin-top: 7px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.pomodoro-time {
|
|
183
|
+
color: var(--foreground);
|
|
184
|
+
font-family: var(--font-mono);
|
|
185
|
+
font-size: clamp(48px, 7vh, 62px);
|
|
186
|
+
font-weight: 580;
|
|
187
|
+
line-height: 1;
|
|
188
|
+
letter-spacing: -0.05em;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.pomodoro.is-finished .pomodoro-time {
|
|
192
|
+
color: var(--success);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.pomodoro.is-alarm {
|
|
196
|
+
border-color: color-mix(in srgb, var(--danger) 28%, transparent);
|
|
197
|
+
background: var(--danger-soft);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@media (max-height: 760px) {
|
|
201
|
+
.pomodoro {
|
|
202
|
+
min-height: 118px;
|
|
203
|
+
max-height: 180px;
|
|
204
|
+
margin: 14px 0;
|
|
205
|
+
padding: 11px 13px 10px;
|
|
206
|
+
border-radius: 17px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.pomodoro-main-row {
|
|
210
|
+
margin-top: 5px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.pomodoro-time {
|
|
214
|
+
font-size: clamp(44px, 8vh, 58px);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@media (max-height: 620px) {
|
|
219
|
+
.pomodoro {
|
|
220
|
+
min-height: 104px;
|
|
221
|
+
max-height: 160px;
|
|
222
|
+
margin: 10px 0;
|
|
223
|
+
padding: 9px 12px 8px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.pomodoro-time {
|
|
227
|
+
font-size: 42px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.phase-button {
|
|
231
|
+
padding: 2px 7px;
|
|
232
|
+
font-size: 12px;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@container (max-width: 360px) {
|
|
237
|
+
.pomodoro-main-row {
|
|
238
|
+
align-items: flex-start;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.pomodoro-main-row > .flex {
|
|
243
|
+
width: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.pomodoro-main-row :global(button[data-slot='button']:first-child) {
|
|
247
|
+
flex: 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
</style>
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { app, closeQuestion, submitQuestionAnswer, toast } from '../state.svelte';
|
|
3
|
+
import type { SessionQuestion } from '../types';
|
|
4
|
+
import { t } from '../i18n.svelte';
|
|
5
|
+
import { Badge } from '$lib/components/ui/badge/index.js';
|
|
6
|
+
import { Button } from '$lib/components/ui/button/index.js';
|
|
7
|
+
import { Card } from '$lib/components/ui/card/index.js';
|
|
8
|
+
import { Input } from '$lib/components/ui/input/index.js';
|
|
9
|
+
import { ScrollArea } from '$lib/components/ui/scroll-area/index.js';
|
|
10
|
+
import * as Dialog from '$lib/components/ui/dialog/index.js';
|
|
11
|
+
import { cn } from '$lib/utils.js';
|
|
12
|
+
import X from '@lucide/svelte/icons/x';
|
|
13
|
+
import MessageCircle from '@lucide/svelte/icons/message-circle';
|
|
14
|
+
import Check from '@lucide/svelte/icons/check';
|
|
15
|
+
import PencilLine from '@lucide/svelte/icons/pencil-line';
|
|
16
|
+
import ArrowUp from '@lucide/svelte/icons/arrow-up';
|
|
17
|
+
import SkipForward from '@lucide/svelte/icons/skip-forward';
|
|
18
|
+
|
|
19
|
+
interface Draft {
|
|
20
|
+
selected: string[];
|
|
21
|
+
custom: string;
|
|
22
|
+
skipped: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface DisplayLabel {
|
|
26
|
+
text: string;
|
|
27
|
+
recommended: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const session = $derived(app.sessions.find((item) => item.id === app.answerSessionId) ?? null);
|
|
31
|
+
const pending = $derived(session?.pending ?? null);
|
|
32
|
+
const questions = $derived<SessionQuestion[]>(pending?.questions ?? []);
|
|
33
|
+
const opened = $derived(Boolean(session && pending && questions.length > 0));
|
|
34
|
+
const needsSubmit = $derived(questions.length > 1 || questions.some((question) => question.multiSelect === true));
|
|
35
|
+
const complete = $derived(questions.every((_, index) => isComplete(index)));
|
|
36
|
+
|
|
37
|
+
let drafts = $state<Draft[]>([]);
|
|
38
|
+
let busy = $state(false);
|
|
39
|
+
let error = $state('');
|
|
40
|
+
let activeKey = '';
|
|
41
|
+
|
|
42
|
+
function isComplete(index: number): boolean {
|
|
43
|
+
const draft = drafts[index];
|
|
44
|
+
if (!draft) return false;
|
|
45
|
+
return draft.skipped || draft.selected.length > 0 || draft.custom.trim() !== '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
$effect(() => {
|
|
49
|
+
const key = `${session?.id ?? ''}\u0000${pending?.requestId ?? ''}\u0000${questions.length}`;
|
|
50
|
+
if (key === activeKey) return;
|
|
51
|
+
activeKey = key;
|
|
52
|
+
drafts = questions.map(() => ({ selected: [], custom: '', skipped: false }));
|
|
53
|
+
busy = false;
|
|
54
|
+
error = '';
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (!app.answerSessionId) return;
|
|
59
|
+
if (!app.pushQuestions || !session || pending?.answerable === false || questions.length === 0) closeQuestion();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function close(): void {
|
|
63
|
+
if (busy) return;
|
|
64
|
+
closeQuestion();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function choose(question: SessionQuestion, index: number, label: string): void {
|
|
68
|
+
if (busy) return;
|
|
69
|
+
const draft = drafts[index];
|
|
70
|
+
if (!draft) return;
|
|
71
|
+
if (question.multiSelect === true) {
|
|
72
|
+
const selected = draft.selected.includes(label)
|
|
73
|
+
? draft.selected.filter((item) => item !== label)
|
|
74
|
+
: [...draft.selected, label];
|
|
75
|
+
drafts[index] = { ...draft, selected, skipped: false };
|
|
76
|
+
error = '';
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
drafts[index] = { selected: [label], custom: '', skipped: false };
|
|
80
|
+
error = '';
|
|
81
|
+
if (questions.length === 1) void submit();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function updateCustom(index: number, value: string): void {
|
|
85
|
+
if (busy) return;
|
|
86
|
+
const draft = drafts[index];
|
|
87
|
+
if (!draft) return;
|
|
88
|
+
drafts[index] = {
|
|
89
|
+
...draft,
|
|
90
|
+
custom: value,
|
|
91
|
+
selected: questions[index]?.multiSelect === true ? draft.selected : [],
|
|
92
|
+
skipped: false,
|
|
93
|
+
};
|
|
94
|
+
error = '';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function skip(index: number): void {
|
|
98
|
+
if (busy) return;
|
|
99
|
+
drafts[index] = { selected: [], custom: '', skipped: true };
|
|
100
|
+
error = '';
|
|
101
|
+
if (questions.length === 1) void submit();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function answerFor(question: SessionQuestion, index: number): { id: string; selected: string[]; custom?: string } {
|
|
105
|
+
const draft = drafts[index];
|
|
106
|
+
if (!draft || draft.skipped) return { id: question.id, selected: [] };
|
|
107
|
+
const custom = draft.custom.trim();
|
|
108
|
+
if (custom) {
|
|
109
|
+
return {
|
|
110
|
+
id: question.id,
|
|
111
|
+
selected: question.multiSelect === true ? [...draft.selected] : [],
|
|
112
|
+
custom,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return { id: question.id, selected: [...draft.selected] };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function submit(): Promise<void> {
|
|
119
|
+
if (busy) return;
|
|
120
|
+
if (!session?.id || !pending?.requestId) {
|
|
121
|
+
error = t('questionEnded');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (!complete) {
|
|
125
|
+
error = t('answerEveryQuestion');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
busy = true;
|
|
129
|
+
error = '';
|
|
130
|
+
try {
|
|
131
|
+
await submitQuestionAnswer(
|
|
132
|
+
session.id,
|
|
133
|
+
pending.requestId,
|
|
134
|
+
questions.map((question, index) => answerFor(question, index)),
|
|
135
|
+
);
|
|
136
|
+
toast(t('answered'));
|
|
137
|
+
closeQuestion();
|
|
138
|
+
} catch (cause) {
|
|
139
|
+
error = cause instanceof Error ? cause.message : String(cause);
|
|
140
|
+
toast(error);
|
|
141
|
+
} finally {
|
|
142
|
+
busy = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function customKey(event: KeyboardEvent): void {
|
|
147
|
+
if (event.key !== 'Enter' || event.shiftKey || event.isComposing || event.keyCode === 229) return;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
void submit();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function displayLabel(label: string): DisplayLabel {
|
|
153
|
+
const suffix = /\s*(?:\((?:recommended|推荐)\)|((?:recommended|推荐)))\s*$/i;
|
|
154
|
+
return suffix.test(label)
|
|
155
|
+
? { text: label.replace(suffix, ''), recommended: true }
|
|
156
|
+
: { text: label, recommended: false };
|
|
157
|
+
}
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<Dialog.Root open={opened} onOpenChange={(value) => { if (!value) close(); }}>
|
|
161
|
+
<Dialog.Content
|
|
162
|
+
showCloseButton={false}
|
|
163
|
+
interactOutsideBehavior="ignore"
|
|
164
|
+
escapeKeydownBehavior="ignore"
|
|
165
|
+
class="flex h-[calc(100dvh-20px)] max-h-[620px] w-[min(780px,calc(100vw-20px))] max-w-[780px] flex-col gap-0 overflow-hidden rounded-[24px] border border-border bg-card p-0 shadow-2xl sm:max-w-[780px]"
|
|
166
|
+
>
|
|
167
|
+
<div class="flex shrink-0 items-start justify-between gap-4 border-b border-border p-3.5">
|
|
168
|
+
<div class="flex min-w-0 items-start gap-3">
|
|
169
|
+
<span class="grid size-11 shrink-0 place-items-center rounded-[13px] border border-warn/20 bg-warn-soft text-warn">
|
|
170
|
+
<MessageCircle class="size-[24px]" strokeWidth={1.7} />
|
|
171
|
+
</span>
|
|
172
|
+
<div class="min-w-0">
|
|
173
|
+
<p class="eyebrow text-warn">WAITING FOR ANSWER</p>
|
|
174
|
+
<Dialog.Title class="mt-1 truncate text-[24px] font-semibold tracking-[-0.03em]">
|
|
175
|
+
{session?.title || t('sessionQuestion')}
|
|
176
|
+
</Dialog.Title>
|
|
177
|
+
<Dialog.Description class="mt-1 text-[14px] leading-relaxed">
|
|
178
|
+
{questions.length > 1 ? t('questionCount', { count: questions.length }) : t('chooseOption')}
|
|
179
|
+
</Dialog.Description>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<Button
|
|
184
|
+
variant="ghost"
|
|
185
|
+
size="icon"
|
|
186
|
+
class="size-11 shrink-0 rounded-[13px] text-muted-foreground hover:bg-secondary hover:text-foreground"
|
|
187
|
+
type="button"
|
|
188
|
+
aria-label={t('close')}
|
|
189
|
+
disabled={busy}
|
|
190
|
+
onclick={close}
|
|
191
|
+
>
|
|
192
|
+
<X class="size-[22px]" strokeWidth={1.8} />
|
|
193
|
+
</Button>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<ScrollArea class="min-h-0 flex-1">
|
|
197
|
+
<div class="flex flex-col gap-2.5 p-3.5">
|
|
198
|
+
{#each questions as question, index (question.id)}
|
|
199
|
+
<Card class="gap-0 rounded-[16px] border border-border bg-surface-2/55 p-3.5 shadow-none ring-0 [--card-spacing:0px]">
|
|
200
|
+
{#if question.header}
|
|
201
|
+
<Badge
|
|
202
|
+
variant="outline"
|
|
203
|
+
class="mb-2 h-7 self-start border-warn/20 bg-warn-soft px-3 text-[13px] font-medium text-warn"
|
|
204
|
+
>
|
|
205
|
+
{question.header}
|
|
206
|
+
</Badge>
|
|
207
|
+
{/if}
|
|
208
|
+
|
|
209
|
+
<div class="flex items-start gap-2.5">
|
|
210
|
+
{#if questions.length > 1}
|
|
211
|
+
<span class="grid size-7 shrink-0 place-items-center rounded-[9px] bg-brand-soft text-[14px] font-semibold text-brand">
|
|
212
|
+
{index + 1}
|
|
213
|
+
</span>
|
|
214
|
+
{/if}
|
|
215
|
+
<h3 class="text-[19px] leading-snug font-semibold text-foreground">{question.question}</h3>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
{#if question.detail}
|
|
219
|
+
<p class="mt-2.5 max-h-36 overflow-y-auto rounded-[11px] border border-border bg-card px-3 py-2.5 text-[15px] leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
|
220
|
+
{question.detail}
|
|
221
|
+
</p>
|
|
222
|
+
{/if}
|
|
223
|
+
|
|
224
|
+
{#if (question.options?.length ?? 0) > 0}
|
|
225
|
+
<div
|
|
226
|
+
class="mt-3 flex flex-col gap-2"
|
|
227
|
+
role={question.multiSelect === true ? 'group' : 'radiogroup'}
|
|
228
|
+
>
|
|
229
|
+
{#each question.options ?? [] as option, optionIndex (`${option.label}-${optionIndex}`)}
|
|
230
|
+
{@const label = displayLabel(option.label)}
|
|
231
|
+
{@const selected = drafts[index]?.selected.includes(option.label) === true}
|
|
232
|
+
<Button
|
|
233
|
+
variant="outline"
|
|
234
|
+
class={cn(
|
|
235
|
+
'h-auto min-h-[54px] w-full justify-start gap-3 rounded-[12px] border-border bg-card px-3 py-2.5 text-left whitespace-normal shadow-none hover:bg-secondary',
|
|
236
|
+
selected && 'border-brand/50 bg-brand-soft hover:bg-brand-soft',
|
|
237
|
+
)}
|
|
238
|
+
type="button"
|
|
239
|
+
role={question.multiSelect === true ? 'checkbox' : 'radio'}
|
|
240
|
+
aria-checked={selected}
|
|
241
|
+
disabled={busy}
|
|
242
|
+
onclick={() => choose(question, index, option.label)}
|
|
243
|
+
>
|
|
244
|
+
<span
|
|
245
|
+
class={cn(
|
|
246
|
+
'grid size-7 shrink-0 place-items-center rounded-[8px] border border-border text-[13px] font-semibold text-muted-foreground',
|
|
247
|
+
selected && 'border-brand bg-primary text-primary-foreground',
|
|
248
|
+
)}
|
|
249
|
+
>
|
|
250
|
+
{#if selected}
|
|
251
|
+
<Check class="size-4" strokeWidth={2.2} />
|
|
252
|
+
{:else}
|
|
253
|
+
{question.multiSelect === true ? '' : optionIndex + 1}
|
|
254
|
+
{/if}
|
|
255
|
+
</span>
|
|
256
|
+
<span class="min-w-0 flex-1">
|
|
257
|
+
<span class="flex flex-wrap items-center gap-2 text-[16px] leading-snug font-medium text-foreground">
|
|
258
|
+
{label.text}
|
|
259
|
+
{#if label.recommended}
|
|
260
|
+
<span class="rounded-full bg-success-soft px-2 py-0.5 text-[12px] font-semibold text-success">{t('recommended')}</span>
|
|
261
|
+
{/if}
|
|
262
|
+
</span>
|
|
263
|
+
{#if option.description}
|
|
264
|
+
<span class="mt-0.5 block text-[13px] leading-snug text-muted-foreground">{option.description}</span>
|
|
265
|
+
{/if}
|
|
266
|
+
</span>
|
|
267
|
+
</Button>
|
|
268
|
+
{/each}
|
|
269
|
+
</div>
|
|
270
|
+
{/if}
|
|
271
|
+
|
|
272
|
+
<div class="relative mt-3">
|
|
273
|
+
<PencilLine class="pointer-events-none absolute top-1/2 left-3.5 size-[18px] -translate-y-1/2 text-muted-foreground" strokeWidth={1.7} />
|
|
274
|
+
<Input
|
|
275
|
+
type="text"
|
|
276
|
+
value={drafts[index]?.custom ?? ''}
|
|
277
|
+
placeholder={question.options?.length ? t('otherAnswer') : t('typeAnswer')}
|
|
278
|
+
aria-label={t('customReply')}
|
|
279
|
+
class="h-12 rounded-[11px] border-border bg-card pl-11 text-[16px] shadow-none placeholder:text-muted-foreground"
|
|
280
|
+
disabled={busy}
|
|
281
|
+
oninput={(event) => updateCustom(index, event.currentTarget.value)}
|
|
282
|
+
onkeydown={customKey}
|
|
283
|
+
/>
|
|
284
|
+
{#if questions.length === 1}
|
|
285
|
+
<Button
|
|
286
|
+
size="icon"
|
|
287
|
+
class="absolute top-1/2 right-1.5 size-10 -translate-y-1/2 rounded-[10px] bg-primary text-primary-foreground shadow-none hover:bg-primary/90"
|
|
288
|
+
type="button"
|
|
289
|
+
disabled={busy || !isComplete(index)}
|
|
290
|
+
onclick={() => void submit()}
|
|
291
|
+
aria-label={t('sendAnswer')}
|
|
292
|
+
>
|
|
293
|
+
<ArrowUp class="size-[20px]" strokeWidth={2} />
|
|
294
|
+
</Button>
|
|
295
|
+
{/if}
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
<div class="mt-1.5 flex min-h-9 items-center gap-2">
|
|
299
|
+
<Button
|
|
300
|
+
variant="ghost"
|
|
301
|
+
class="h-9 gap-2 px-0 text-[14px] text-muted-foreground hover:bg-transparent hover:text-foreground"
|
|
302
|
+
type="button"
|
|
303
|
+
disabled={busy}
|
|
304
|
+
onclick={() => skip(index)}
|
|
305
|
+
>
|
|
306
|
+
<SkipForward class="size-[18px]" strokeWidth={1.7} />
|
|
307
|
+
{t('skipQuestion')}
|
|
308
|
+
</Button>
|
|
309
|
+
{#if drafts[index]?.skipped}
|
|
310
|
+
<span class="text-[13px] text-warn">{t('skippedNote')}</span>
|
|
311
|
+
{/if}
|
|
312
|
+
</div>
|
|
313
|
+
</Card>
|
|
314
|
+
{/each}
|
|
315
|
+
|
|
316
|
+
{#if error}
|
|
317
|
+
<p
|
|
318
|
+
class="rounded-[11px] border border-danger/25 bg-danger-soft px-3 py-2.5 text-[15px] leading-relaxed text-danger"
|
|
319
|
+
role="alert"
|
|
320
|
+
>
|
|
321
|
+
{error}
|
|
322
|
+
</p>
|
|
323
|
+
{/if}
|
|
324
|
+
</div>
|
|
325
|
+
</ScrollArea>
|
|
326
|
+
|
|
327
|
+
{#if needsSubmit}
|
|
328
|
+
<div class="mt-0 flex shrink-0 flex-col gap-2.5 border-t border-border bg-card p-4">
|
|
329
|
+
<p class="text-[13px] text-muted-foreground">
|
|
330
|
+
{busy ? t('sendingEllipsis') : t('canMultiAnswer')}
|
|
331
|
+
</p>
|
|
332
|
+
<div class="flex w-full gap-2.5">
|
|
333
|
+
<Button
|
|
334
|
+
variant="outline"
|
|
335
|
+
class="h-12 flex-1 rounded-[13px] border-border bg-transparent text-[16px] shadow-none hover:bg-secondary"
|
|
336
|
+
type="button"
|
|
337
|
+
disabled={busy}
|
|
338
|
+
onclick={close}
|
|
339
|
+
>
|
|
340
|
+
{t('cancel')}
|
|
341
|
+
</Button>
|
|
342
|
+
<Button
|
|
343
|
+
class="h-12 flex-1 rounded-[13px] bg-primary text-[16px] text-primary-foreground shadow-none hover:bg-primary/90"
|
|
344
|
+
type="button"
|
|
345
|
+
disabled={busy || !complete}
|
|
346
|
+
onclick={() => void submit()}
|
|
347
|
+
>
|
|
348
|
+
{busy ? t('sending') : t('sendAnswer')}
|
|
349
|
+
</Button>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
{/if}
|
|
353
|
+
</Dialog.Content>
|
|
354
|
+
</Dialog.Root>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '$lib/utils.js';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
value = 0,
|
|
6
|
+
color = 'var(--brand)',
|
|
7
|
+
size = 'clamp(92px, 14vh, 112px)',
|
|
8
|
+
class: className = '',
|
|
9
|
+
}: {
|
|
10
|
+
value?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
size?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
} = $props();
|
|
15
|
+
|
|
16
|
+
const clamped = $derived(Math.max(0, Math.min(100, Number(value) || 0)));
|
|
17
|
+
const display = $derived(Math.round(clamped));
|
|
18
|
+
const radius = 43;
|
|
19
|
+
const circumference = 2 * Math.PI * radius;
|
|
20
|
+
const offset = $derived(circumference * (1 - clamped / 100));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div
|
|
24
|
+
class={cn('radial-gauge', className)}
|
|
25
|
+
style={`--meter-color:${color}; width:${size}; height:${size};`}
|
|
26
|
+
role="meter"
|
|
27
|
+
aria-valuemin={0}
|
|
28
|
+
aria-valuemax={100}
|
|
29
|
+
aria-valuenow={display}
|
|
30
|
+
>
|
|
31
|
+
<svg viewBox="0 0 100 100" aria-hidden="true">
|
|
32
|
+
<circle class="radial-track" cx="50" cy="50" r={radius} />
|
|
33
|
+
<circle
|
|
34
|
+
class="radial-value"
|
|
35
|
+
cx="50"
|
|
36
|
+
cy="50"
|
|
37
|
+
r={radius}
|
|
38
|
+
stroke-dasharray={circumference}
|
|
39
|
+
stroke-dashoffset={offset}
|
|
40
|
+
transform="rotate(-90 50 50)"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
<div class="radial-copy">
|
|
44
|
+
<span class="radial-number numeric">{display}</span>
|
|
45
|
+
<span class="radial-unit">%</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.radial-gauge {
|
|
51
|
+
position: relative;
|
|
52
|
+
display: grid;
|
|
53
|
+
flex: 0 0 auto;
|
|
54
|
+
place-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.radial-gauge svg {
|
|
58
|
+
position: absolute;
|
|
59
|
+
inset: 0;
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.radial-track {
|
|
65
|
+
fill: none;
|
|
66
|
+
stroke: color-mix(in srgb, var(--foreground) 8%, transparent);
|
|
67
|
+
stroke-width: 7;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.radial-value {
|
|
71
|
+
fill: none;
|
|
72
|
+
stroke: var(--meter-color);
|
|
73
|
+
stroke-width: 7;
|
|
74
|
+
stroke-linecap: round;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.radial-copy {
|
|
78
|
+
position: relative;
|
|
79
|
+
z-index: 1;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: flex-start;
|
|
82
|
+
gap: 1px;
|
|
83
|
+
color: var(--foreground);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.radial-number {
|
|
87
|
+
font-size: clamp(30px, 4vw, 42px);
|
|
88
|
+
font-weight: 560;
|
|
89
|
+
line-height: 1;
|
|
90
|
+
letter-spacing: -0.05em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.radial-unit {
|
|
94
|
+
margin-top: 3px;
|
|
95
|
+
color: var(--muted-foreground);
|
|
96
|
+
font-size: clamp(13px, 1.5vw, 16px);
|
|
97
|
+
font-weight: 550;
|
|
98
|
+
}
|
|
99
|
+
</style>
|