feat: to select table directly in the sidebar (#106)

This commit is contained in:
CorrectRoadH
2023-05-31 15:47:32 +08:00
committed by GitHub
parent 00022e6bb7
commit 933fb6f280
11 changed files with 366 additions and 262 deletions

View File

@ -19,7 +19,9 @@
"@mui/styled-engine-sc": "^5.11.11",
"@next-auth/prisma-adapter": "^1.0.6",
"@prisma/client": "4.13.0",
"@radix-ui/react-checkbox": "^1.0.3",
"@radix-ui/react-dropdown-menu": "^2.0.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-popover": "^1.0.5",
"@radix-ui/react-scroll-area": "^1.0.3",
"@radix-ui/react-select": "^1.2.1",

436
pnpm-lock.yaml generated
View File

@ -25,9 +25,15 @@ dependencies:
'@prisma/client':
specifier: 4.13.0
version: 4.13.0(prisma@4.13.0)
'@radix-ui/react-checkbox':
specifier: ^1.0.3
version: registry.npmmirror.com/@radix-ui/react-checkbox@1.0.3(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-dropdown-menu':
specifier: ^2.0.4
version: 2.0.4(@types/react@18.0.28)(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-icons':
specifier: ^1.3.0
version: registry.npmmirror.com/@radix-ui/react-icons@1.3.0(react@18.2.0)
'@radix-ui/react-popover':
specifier: ^1.0.5
version: 1.0.5(@types/react@18.0.28)(react-dom@18.2.0)(react@18.2.0)
@ -974,123 +980,6 @@ packages:
glob: 7.1.7
dev: true
/@next/swc-android-arm-eabi@13.2.4:
resolution: {integrity: sha512-DWlalTSkLjDU11MY11jg17O1gGQzpRccM9Oes2yTqj2DpHndajrXHGxj9HGtJ+idq2k7ImUdJVWS2h2l/EDJOw==}
engines: {node: '>= 10'}
cpu: [arm]
os: [android]
requiresBuild: true
dev: false
optional: true
/@next/swc-android-arm64@13.2.4:
resolution: {integrity: sha512-sRavmUImUCf332Gy+PjIfLkMhiRX1Ez4SI+3vFDRs1N5eXp+uNzjFUK/oLMMOzk6KFSkbiK/3Wt8+dHQR/flNg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [android]
requiresBuild: true
dev: false
optional: true
/@next/swc-darwin-arm64@13.2.4:
resolution: {integrity: sha512-S6vBl+OrInP47TM3LlYx65betocKUUlTZDDKzTiRDbsRESeyIkBtZ6Qi5uT2zQs4imqllJznVjFd1bXLx3Aa6A==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@next/swc-darwin-x64@13.2.4:
resolution: {integrity: sha512-a6LBuoYGcFOPGd4o8TPo7wmv5FnMr+Prz+vYHopEDuhDoMSHOnC+v+Ab4D7F0NMZkvQjEJQdJS3rqgFhlZmKlw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@next/swc-freebsd-x64@13.2.4:
resolution: {integrity: sha512-kkbzKVZGPaXRBPisoAQkh3xh22r+TD+5HwoC5bOkALraJ0dsOQgSMAvzMXKsN3tMzJUPS0tjtRf1cTzrQ0I5vQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: false
optional: true
/@next/swc-linux-arm-gnueabihf@13.2.4:
resolution: {integrity: sha512-7qA1++UY0fjprqtjBZaOA6cas/7GekpjVsZn/0uHvquuITFCdKGFCsKNBx3S0Rpxmx6WYo0GcmhNRM9ru08BGg==}
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@next/swc-linux-arm64-gnu@13.2.4:
resolution: {integrity: sha512-xzYZdAeq883MwXgcwc72hqo/F/dwUxCukpDOkx/j1HTq/J0wJthMGjinN9wH5bPR98Mfeh1MZJ91WWPnZOedOg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@next/swc-linux-arm64-musl@13.2.4:
resolution: {integrity: sha512-8rXr3WfmqSiYkb71qzuDP6I6R2T2tpkmf83elDN8z783N9nvTJf2E7eLx86wu2OJCi4T05nuxCsh4IOU3LQ5xw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@next/swc-linux-x64-gnu@13.2.4:
resolution: {integrity: sha512-Ngxh51zGSlYJ4EfpKG4LI6WfquulNdtmHg1yuOYlaAr33KyPJp4HeN/tivBnAHcZkoNy0hh/SbwDyCnz5PFJQQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@next/swc-linux-x64-musl@13.2.4:
resolution: {integrity: sha512-gOvwIYoSxd+j14LOcvJr+ekd9fwYT1RyMAHOp7znA10+l40wkFiMONPLWiZuHxfRk+Dy7YdNdDh3ImumvL6VwA==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@next/swc-win32-arm64-msvc@13.2.4:
resolution: {integrity: sha512-q3NJzcfClgBm4HvdcnoEncmztxrA5GXqKeiZ/hADvC56pwNALt3ngDC6t6qr1YW9V/EPDxCYeaX4zYxHciW4Dw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@next/swc-win32-ia32-msvc@13.2.4:
resolution: {integrity: sha512-/eZ5ncmHUYtD2fc6EUmAIZlAJnVT2YmxDsKs1Ourx0ttTtvtma/WKlMV5NoUsyOez0f9ExLyOpeCoz5aj+MPXw==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@next/swc-win32-x64-msvc@13.2.4:
resolution: {integrity: sha512-0MffFmyv7tBLlji01qc0IaPP/LVExzvj7/R5x1Jph1bTAIj4Vu81yFQWHHQAP6r4ff9Ukj1mBK6MDNVXm7Tcvw==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@nodelib/fs.scandir@2.1.5:
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@ -2215,7 +2104,7 @@ packages:
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
fsevents: registry.npmmirror.com/fsevents@2.3.2
dev: true
/client-only@0.0.1:
@ -3092,14 +2981,6 @@ packages:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
dev: true
/fsevents@2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
/function-bind@1.1.1:
resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
@ -4382,19 +4263,19 @@ packages:
react-dom: 18.2.0(react@18.2.0)
styled-jsx: 5.1.1(react@18.2.0)
optionalDependencies:
'@next/swc-android-arm-eabi': 13.2.4
'@next/swc-android-arm64': 13.2.4
'@next/swc-darwin-arm64': 13.2.4
'@next/swc-darwin-x64': 13.2.4
'@next/swc-freebsd-x64': 13.2.4
'@next/swc-linux-arm-gnueabihf': 13.2.4
'@next/swc-linux-arm64-gnu': 13.2.4
'@next/swc-linux-arm64-musl': 13.2.4
'@next/swc-linux-x64-gnu': 13.2.4
'@next/swc-linux-x64-musl': 13.2.4
'@next/swc-win32-arm64-msvc': 13.2.4
'@next/swc-win32-ia32-msvc': 13.2.4
'@next/swc-win32-x64-msvc': 13.2.4
'@next/swc-android-arm-eabi': registry.npmmirror.com/@next/swc-android-arm-eabi@13.2.4
'@next/swc-android-arm64': registry.npmmirror.com/@next/swc-android-arm64@13.2.4
'@next/swc-darwin-arm64': registry.npmmirror.com/@next/swc-darwin-arm64@13.2.4
'@next/swc-darwin-x64': registry.npmmirror.com/@next/swc-darwin-x64@13.2.4
'@next/swc-freebsd-x64': registry.npmmirror.com/@next/swc-freebsd-x64@13.2.4
'@next/swc-linux-arm-gnueabihf': registry.npmmirror.com/@next/swc-linux-arm-gnueabihf@13.2.4
'@next/swc-linux-arm64-gnu': registry.npmmirror.com/@next/swc-linux-arm64-gnu@13.2.4
'@next/swc-linux-arm64-musl': registry.npmmirror.com/@next/swc-linux-arm64-musl@13.2.4
'@next/swc-linux-x64-gnu': registry.npmmirror.com/@next/swc-linux-x64-gnu@13.2.4
'@next/swc-linux-x64-musl': registry.npmmirror.com/@next/swc-linux-x64-musl@13.2.4
'@next/swc-win32-arm64-msvc': registry.npmmirror.com/@next/swc-win32-arm64-msvc@13.2.4
'@next/swc-win32-ia32-msvc': registry.npmmirror.com/@next/swc-win32-ia32-msvc@13.2.4
'@next/swc-win32-x64-msvc': registry.npmmirror.com/@next/swc-win32-x64-msvc@13.2.4
transitivePeerDependencies:
- '@babel/core'
- babel-plugin-macros
@ -6064,7 +5945,7 @@ packages:
dev: false
registry.npmmirror.com/@babel/runtime@7.21.0:
resolution: {integrity: sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@babel/runtime/-/runtime-7.21.0.tgz}
resolution: {integrity: sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@babel/runtime/-/runtime-7.21.0.tgz}
name: '@babel/runtime'
version: 7.21.0
engines: {node: '>=6.9.0'}
@ -6072,8 +5953,164 @@ packages:
regenerator-runtime: registry.npmmirror.com/regenerator-runtime@0.13.11
dev: false
registry.npmmirror.com/@babel/runtime@7.21.5:
resolution: {integrity: sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@babel/runtime/-/runtime-7.21.5.tgz}
name: '@babel/runtime'
version: 7.21.5
engines: {node: '>=6.9.0'}
dependencies:
regenerator-runtime: registry.npmmirror.com/regenerator-runtime@0.13.11
dev: false
registry.npmmirror.com/@next/swc-android-arm-eabi@13.2.4:
resolution: {integrity: sha512-DWlalTSkLjDU11MY11jg17O1gGQzpRccM9Oes2yTqj2DpHndajrXHGxj9HGtJ+idq2k7ImUdJVWS2h2l/EDJOw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-13.2.4.tgz}
name: '@next/swc-android-arm-eabi'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm]
os: [android]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-android-arm64@13.2.4:
resolution: {integrity: sha512-sRavmUImUCf332Gy+PjIfLkMhiRX1Ez4SI+3vFDRs1N5eXp+uNzjFUK/oLMMOzk6KFSkbiK/3Wt8+dHQR/flNg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-android-arm64/-/swc-android-arm64-13.2.4.tgz}
name: '@next/swc-android-arm64'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm64]
os: [android]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-darwin-arm64@13.2.4:
resolution: {integrity: sha512-S6vBl+OrInP47TM3LlYx65betocKUUlTZDDKzTiRDbsRESeyIkBtZ6Qi5uT2zQs4imqllJznVjFd1bXLx3Aa6A==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.4.tgz}
name: '@next/swc-darwin-arm64'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-darwin-x64@13.2.4:
resolution: {integrity: sha512-a6LBuoYGcFOPGd4o8TPo7wmv5FnMr+Prz+vYHopEDuhDoMSHOnC+v+Ab4D7F0NMZkvQjEJQdJS3rqgFhlZmKlw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.2.4.tgz}
name: '@next/swc-darwin-x64'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-freebsd-x64@13.2.4:
resolution: {integrity: sha512-kkbzKVZGPaXRBPisoAQkh3xh22r+TD+5HwoC5bOkALraJ0dsOQgSMAvzMXKsN3tMzJUPS0tjtRf1cTzrQ0I5vQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-freebsd-x64/-/swc-freebsd-x64-13.2.4.tgz}
name: '@next/swc-freebsd-x64'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-linux-arm-gnueabihf@13.2.4:
resolution: {integrity: sha512-7qA1++UY0fjprqtjBZaOA6cas/7GekpjVsZn/0uHvquuITFCdKGFCsKNBx3S0Rpxmx6WYo0GcmhNRM9ru08BGg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-13.2.4.tgz}
name: '@next/swc-linux-arm-gnueabihf'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm]
os: [linux]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-linux-arm64-gnu@13.2.4:
resolution: {integrity: sha512-xzYZdAeq883MwXgcwc72hqo/F/dwUxCukpDOkx/j1HTq/J0wJthMGjinN9wH5bPR98Mfeh1MZJ91WWPnZOedOg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.2.4.tgz}
name: '@next/swc-linux-arm64-gnu'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-linux-arm64-musl@13.2.4:
resolution: {integrity: sha512-8rXr3WfmqSiYkb71qzuDP6I6R2T2tpkmf83elDN8z783N9nvTJf2E7eLx86wu2OJCi4T05nuxCsh4IOU3LQ5xw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.2.4.tgz}
name: '@next/swc-linux-arm64-musl'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-linux-x64-gnu@13.2.4:
resolution: {integrity: sha512-Ngxh51zGSlYJ4EfpKG4LI6WfquulNdtmHg1yuOYlaAr33KyPJp4HeN/tivBnAHcZkoNy0hh/SbwDyCnz5PFJQQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.2.4.tgz}
name: '@next/swc-linux-x64-gnu'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-linux-x64-musl@13.2.4:
resolution: {integrity: sha512-gOvwIYoSxd+j14LOcvJr+ekd9fwYT1RyMAHOp7znA10+l40wkFiMONPLWiZuHxfRk+Dy7YdNdDh3ImumvL6VwA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.2.4.tgz}
name: '@next/swc-linux-x64-musl'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-win32-arm64-msvc@13.2.4:
resolution: {integrity: sha512-q3NJzcfClgBm4HvdcnoEncmztxrA5GXqKeiZ/hADvC56pwNALt3ngDC6t6qr1YW9V/EPDxCYeaX4zYxHciW4Dw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.2.4.tgz}
name: '@next/swc-win32-arm64-msvc'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-win32-ia32-msvc@13.2.4:
resolution: {integrity: sha512-/eZ5ncmHUYtD2fc6EUmAIZlAJnVT2YmxDsKs1Ourx0ttTtvtma/WKlMV5NoUsyOez0f9ExLyOpeCoz5aj+MPXw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.2.4.tgz}
name: '@next/swc-win32-ia32-msvc'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@next/swc-win32-x64-msvc@13.2.4:
resolution: {integrity: sha512-0MffFmyv7tBLlji01qc0IaPP/LVExzvj7/R5x1Jph1bTAIj4Vu81yFQWHHQAP6r4ff9Ukj1mBK6MDNVXm7Tcvw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.4.tgz}
name: '@next/swc-win32-x64-msvc'
version: 13.2.4
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
optional: true
registry.npmmirror.com/@radix-ui/number@1.0.0:
resolution: {integrity: sha512-Ofwh/1HX69ZfJRiRBMTy7rgjAzHmwe4kW9C9Y99HTRUcYLUuVT0KESFj15rPjRgKJs20GPq8Bm5aEDJ8DuA3vA==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/number/-/number-1.0.0.tgz}
resolution: {integrity: sha512-Ofwh/1HX69ZfJRiRBMTy7rgjAzHmwe4kW9C9Y99HTRUcYLUuVT0KESFj15rPjRgKJs20GPq8Bm5aEDJ8DuA3vA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/number/-/number-1.0.0.tgz}
name: '@radix-ui/number'
version: 1.0.0
dependencies:
@ -6081,39 +6118,61 @@ packages:
dev: false
registry.npmmirror.com/@radix-ui/primitive@1.0.0:
resolution: {integrity: sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.0.0.tgz}
resolution: {integrity: sha512-3e7rn8FDMin4CgeL7Z/49smCA3rFYY3Ha2rUQ7HRWFadS5iCRw08ZgVT1LaNTCNqgvrUiyczLflrVrF0SRQtNA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.0.0.tgz}
name: '@radix-ui/primitive'
version: 1.0.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
dev: false
registry.npmmirror.com/@radix-ui/react-checkbox@1.0.3(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-55B8/vKzTuzxllH5sGJO4zaBf9gYpJuJRRzaOKm+0oAefRnMvbf+Kgww7IOANVN0w3z7agFJgtnXaZl8Uj95AA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-checkbox/-/react-checkbox-1.0.3.tgz}
id: registry.npmmirror.com/@radix-ui/react-checkbox/1.0.3
name: '@radix-ui/react-checkbox'
version: 1.0.3
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/primitive': registry.npmmirror.com/@radix-ui/primitive@1.0.0
'@radix-ui/react-compose-refs': registry.npmmirror.com/@radix-ui/react-compose-refs@1.0.0(react@18.2.0)
'@radix-ui/react-context': registry.npmmirror.com/@radix-ui/react-context@1.0.0(react@18.2.0)
'@radix-ui/react-presence': registry.npmmirror.com/@radix-ui/react-presence@1.0.0(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-primitive': registry.npmmirror.com/@radix-ui/react-primitive@1.0.2(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-use-controllable-state': registry.npmmirror.com/@radix-ui/react-use-controllable-state@1.0.0(react@18.2.0)
'@radix-ui/react-use-previous': registry.npmmirror.com/@radix-ui/react-use-previous@1.0.0(react@18.2.0)
'@radix-ui/react-use-size': registry.npmmirror.com/@radix-ui/react-use-size@1.0.0(react@18.2.0)
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false
registry.npmmirror.com/@radix-ui/react-compose-refs@1.0.0(react@18.2.0):
resolution: {integrity: sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz}
resolution: {integrity: sha512-0KaSv6sx787/hK3eF53iOkiSLwAGlFMx5lotrqD2pTjB18KbybKoEIgkNZTKC60YECDQTKGTRcDBILwZVqVKvA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-compose-refs/1.0.0
name: '@radix-ui/react-compose-refs'
version: 1.0.0
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-context@1.0.0(react@18.2.0):
resolution: {integrity: sha512-1pVM9RfOQ+n/N5PJK33kRSKsr1glNxomxONs5c49MliinBY6Yw2Q995qfBUUo0/Mbg05B/sGA0gkgPI7kmSHBg==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-context/-/react-context-1.0.0.tgz}
resolution: {integrity: sha512-1pVM9RfOQ+n/N5PJK33kRSKsr1glNxomxONs5c49MliinBY6Yw2Q995qfBUUo0/Mbg05B/sGA0gkgPI7kmSHBg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-context/-/react-context-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-context/1.0.0
name: '@radix-ui/react-context'
version: 1.0.0
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-direction@1.0.0(react@18.2.0):
resolution: {integrity: sha512-2HV05lGUgYcA6xgLQ4BKPDmtL+QbIZYH5fCOTAOOcJ5O0QbWS3i9lKaurLzliYUDhORI2Qr3pyjhJh44lKA3rQ==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-direction/-/react-direction-1.0.0.tgz}
resolution: {integrity: sha512-2HV05lGUgYcA6xgLQ4BKPDmtL+QbIZYH5fCOTAOOcJ5O0QbWS3i9lKaurLzliYUDhORI2Qr3pyjhJh44lKA3rQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-direction/-/react-direction-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-direction/1.0.0
name: '@radix-ui/react-direction'
version: 1.0.0
@ -6124,8 +6183,19 @@ packages:
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-icons@1.3.0(react@18.2.0):
resolution: {integrity: sha512-jQxj/0LKgp+j9BiTXz3O3sgs26RNet2iLWmsPyRz2SIcR4q/4SbazXfnYwbAr+vLYKSfc7qxzyGQA1HLlYiuNw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-icons/-/react-icons-1.3.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-icons/1.3.0
name: '@radix-ui/react-icons'
version: 1.3.0
peerDependencies:
react: ^16.x || ^17.x || ^18.x
dependencies:
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-presence@1.0.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-A+6XEvN01NfVWiKu38ybawfHsBjWum42MRPnEuqPsBZ4eV7e/7K321B5VgYMPv3Xx5An6o1/l9ZuDBgmcmWK3w==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-presence/-/react-presence-1.0.0.tgz}
resolution: {integrity: sha512-A+6XEvN01NfVWiKu38ybawfHsBjWum42MRPnEuqPsBZ4eV7e/7K321B5VgYMPv3Xx5An6o1/l9ZuDBgmcmWK3w==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-presence/-/react-presence-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-presence/1.0.0
name: '@radix-ui/react-presence'
version: 1.0.0
@ -6133,7 +6203,7 @@ packages:
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/react-compose-refs': registry.npmmirror.com/@radix-ui/react-compose-refs@1.0.0(react@18.2.0)
'@radix-ui/react-use-layout-effect': registry.npmmirror.com/@radix-ui/react-use-layout-effect@1.0.0(react@18.2.0)
react: 18.2.0
@ -6141,7 +6211,7 @@ packages:
dev: false
registry.npmmirror.com/@radix-ui/react-primitive@1.0.2(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-zY6G5Qq4R8diFPNwtyoLRZBxzu1Z+SXMlfYpChN7Dv8gvmx9X3qhDqiLWvKseKVJMuedFeU/Sa0Sy/Ia+t06Dw==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-primitive/-/react-primitive-1.0.2.tgz}
resolution: {integrity: sha512-zY6G5Qq4R8diFPNwtyoLRZBxzu1Z+SXMlfYpChN7Dv8gvmx9X3qhDqiLWvKseKVJMuedFeU/Sa0Sy/Ia+t06Dw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-primitive/-/react-primitive-1.0.2.tgz}
id: registry.npmmirror.com/@radix-ui/react-primitive/1.0.2
name: '@radix-ui/react-primitive'
version: 1.0.2
@ -6149,14 +6219,14 @@ packages:
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/react-slot': registry.npmmirror.com/@radix-ui/react-slot@1.0.1(react@18.2.0)
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false
registry.npmmirror.com/@radix-ui/react-scroll-area@1.0.3(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-sBX9j8Q+0/jReNObEAveKIGXJtk3xUoSIx4cMKygGtO128QJyVDn01XNOFsyvihKDCTcu7SINzQ2jPAZEhIQtw==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.3.tgz}
resolution: {integrity: sha512-sBX9j8Q+0/jReNObEAveKIGXJtk3xUoSIx4cMKygGtO128QJyVDn01XNOFsyvihKDCTcu7SINzQ2jPAZEhIQtw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.3.tgz}
id: registry.npmmirror.com/@radix-ui/react-scroll-area/1.0.3
name: '@radix-ui/react-scroll-area'
version: 1.0.3
@ -6179,20 +6249,20 @@ packages:
dev: false
registry.npmmirror.com/@radix-ui/react-slot@1.0.1(react@18.2.0):
resolution: {integrity: sha512-avutXAFL1ehGvAXtPquu0YK5oz6ctS474iM3vNGQIkswrVhdrS52e3uoMQBzZhNRAIE0jBnUyXWNmSjGHhCFcw==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.0.1.tgz}
resolution: {integrity: sha512-avutXAFL1ehGvAXtPquu0YK5oz6ctS474iM3vNGQIkswrVhdrS52e3uoMQBzZhNRAIE0jBnUyXWNmSjGHhCFcw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.0.1.tgz}
id: registry.npmmirror.com/@radix-ui/react-slot/1.0.1
name: '@radix-ui/react-slot'
version: 1.0.1
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.0
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/react-compose-refs': registry.npmmirror.com/@radix-ui/react-compose-refs@1.0.0(react@18.2.0)
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-use-callback-ref@1.0.0(react@18.2.0):
resolution: {integrity: sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.0.tgz}
resolution: {integrity: sha512-GZtyzoHz95Rhs6S63D2t/eqvdFCm7I+yHMLVQheKM7nBD8mbZIt+ct1jz4536MDnaOGKIxynJ8eHTkVGVVkoTg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-use-callback-ref/1.0.0
name: '@radix-ui/react-use-callback-ref'
version: 1.0.0
@ -6203,8 +6273,21 @@ packages:
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-use-controllable-state@1.0.0(react@18.2.0):
resolution: {integrity: sha512-FohDoZvk3mEXh9AWAVyRTYR4Sq7/gavuofglmiXB2g1aKyboUD4YtgWxKj8O5n+Uak52gXQ4wKz5IFST4vtJHg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-use-controllable-state/1.0.0
name: '@radix-ui/react-use-controllable-state'
version: 1.0.0
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/react-use-callback-ref': registry.npmmirror.com/@radix-ui/react-use-callback-ref@1.0.0(react@18.2.0)
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-use-layout-effect@1.0.0(react@18.2.0):
resolution: {integrity: sha512-6Tpkq+R6LOlmQb1R5NNETLG0B4YP0wc+klfXafpUCj6JGyaUc8il7/kUZ7m59rGbXGczE9Bs+iz2qloqsZBduQ==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.0.0.tgz}
resolution: {integrity: sha512-6Tpkq+R6LOlmQb1R5NNETLG0B4YP0wc+klfXafpUCj6JGyaUc8il7/kUZ7m59rGbXGczE9Bs+iz2qloqsZBduQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-use-layout-effect/1.0.0
name: '@radix-ui/react-use-layout-effect'
version: 1.0.0
@ -6215,14 +6298,49 @@ packages:
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-use-previous@1.0.0(react@18.2.0):
resolution: {integrity: sha512-RG2K8z/K7InnOKpq6YLDmT49HGjNmrK+fr82UCVKT2sW0GYfVnYp4wZWBooT/EYfQ5faA9uIjvsuMMhH61rheg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-previous/-/react-use-previous-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-use-previous/1.0.0
name: '@radix-ui/react-use-previous'
version: 1.0.0
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
react: 18.2.0
dev: false
registry.npmmirror.com/@radix-ui/react-use-size@1.0.0(react@18.2.0):
resolution: {integrity: sha512-imZ3aYcoYCKhhgNpkNDh/aTiU05qw9hX+HHI1QDBTyIlcFjgeFlKKySNGMwTp7nYFLQg/j0VA2FmCY4WPDDHMg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@radix-ui/react-use-size/-/react-use-size-1.0.0.tgz}
id: registry.npmmirror.com/@radix-ui/react-use-size/1.0.0
name: '@radix-ui/react-use-size'
version: 1.0.0
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
dependencies:
'@babel/runtime': registry.npmmirror.com/@babel/runtime@7.21.5
'@radix-ui/react-use-layout-effect': registry.npmmirror.com/@radix-ui/react-use-layout-effect@1.0.0(react@18.2.0)
react: 18.2.0
dev: false
registry.npmmirror.com/fsevents@2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz}
name: fsevents
version: 2.3.2
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
dev: true
optional: true
registry.npmmirror.com/regenerator-runtime@0.13.11:
resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz}
resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz}
name: regenerator-runtime
version: 0.13.11
dev: false
registry.npmmirror.com/tailwind-scrollbar-hide@1.1.7:
resolution: {integrity: sha512-X324n9OtpTmOMqEgDUEA/RgLrNfBF/jwJdctaPZDzB3mppxJk7TLIDmOreEDm1Bq4R9LSPu4Epf8VSdovNU+iA==, registry: https://registry.npmjs.org/, tarball: https://registry.npmmirror.com/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz}
resolution: {integrity: sha512-X324n9OtpTmOMqEgDUEA/RgLrNfBF/jwJdctaPZDzB3mppxJk7TLIDmOreEDm1Bq4R9LSPu4Epf8VSdovNU+iA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz}
name: tailwind-scrollbar-hide
version: 1.1.7
dev: false

View File

@ -7,12 +7,11 @@ import useLoading from "@/hooks/useLoading";
import Select from "./kit/Select";
import Icon from "./Icon";
import DarkModeSwitch from "./DarkModeSwitch";
import ConversationList from "./Sidebar/ConversationList";
import ConnectionList from "./Sidebar/ConnectionList";
import QuotaView from "./QuotaView";
import { hasFeature } from "../utils";
import MultipleSelect from "./kit/MultipleSelect";
import { countTextTokens, hasFeature } from "../utils";
import SettingAvatarIcon from "./SettingAvatarIcon";
import Checkbox from "./kit/Checkbox";
interface State {}
@ -34,6 +33,12 @@ const ConnectionSidebar = () => {
conversationStore.getConversationById(conversationStore.currentConversationId)?.selectedSchemaName || "";
const tableSchemaLoadingState = useLoading();
const currentConversation = conversationStore.getConversationById(conversationStore.currentConversationId);
const [totalToken, setTotalToken] = useState<number>(0);
useEffect(() => {
updateHasSchemaProperty(
currentConnectionCtx?.connection.engineType === Engine.PostgreSQL || currentConnectionCtx?.connection.engineType === Engine.MSSQL
);
}, [currentConnectionCtx?.connection]);
useEffect(() => {
updateHasSchemaProperty(
@ -60,6 +65,16 @@ const ConnectionSidebar = () => {
};
}, []);
useEffect(() => {
// update total token
const totalToken = selectedTablesName.reduce((totalToken, tableName) => {
const table = tableList.find((table) => table.name === tableName);
// because old cache didn't have token, So the value may is undefined.
return totalToken + (table?.token || countTextTokens(table?.structure || ""));
}, 0);
setTotalToken(totalToken);
}, [selectedTablesName, tableList]);
useEffect(() => {
if (currentConnectionCtx?.connection) {
setIsRequestingDatabase(true);
@ -134,16 +149,12 @@ const ConnectionSidebar = () => {
}
};
const handleTableNameSelect = async (selectedTablesName: string[]) => {
conversationStore.updateSelectedTablesName(selectedTablesName);
};
const handleAllSelect = async () => {
conversationStore.updateSelectedTablesName(tableList.map((table) => table.name));
};
const handleEmptySelect = async () => {
conversationStore.updateSelectedTablesName([]);
const handleTableCheckboxChange = async (tableName: string, value: boolean) => {
if (value) {
conversationStore.updateSelectedTablesName([...selectedTablesName, tableName]);
} else {
conversationStore.updateSelectedTablesName(selectedTablesName.filter((name) => name !== tableName));
}
};
const handleSchemaNameSelect = async (schemaName: string) => {
@ -211,42 +222,31 @@ const ConnectionSidebar = () => {
)}
{currentConnectionCtx &&
(tableSchemaLoadingState.isLoading ? (
<div className="w-full h-12 flex flex-row justify-start items-center px-4 sticky top-0 border z-1 mb-4 mt-2 rounded-lg text-sm text-gray-600 dark:text-gray-400">
<div className="w-full h-12 flex flex-row justify-start items-center px-4 sticky top-0 z-1 mb-4 mt-2 rounded-lg text-sm text-gray-600 dark:text-gray-400">
<Icon.BiLoaderAlt className="w-4 h-auto animate-spin mr-1" /> {t("common.loading")}
</div>
) : (
tableList.length > 0 && (
<div className="w-full sticky top-0 z-1 my-4">
<MultipleSelect
className="w-full px-4 py-3 !text-base"
value={selectedTablesName}
itemList={tableList.map((table) => {
return {
label: table.name === "" ? t("connection.all-tables") : table.name,
value: table.name,
};
})}
onValueChange={(tableName) => handleTableNameSelect(tableName)}
placeholder={(selectedTablesName.length ? selectedTablesName.join(",") : t("connection.all-tables")) || ""}
>
<button
className="whitespace-nowrap rounded w-full bg-indigo-600 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
onClick={(e) => {
selectedTablesName.length ? handleEmptySelect() : handleAllSelect();
// The Button area is a option that have select event. So must to stop Propagation
e.stopPropagation();
}}
tableList.length > 0 &&
tableList.map((table) => {
return (
<div key={table.name}>
<Checkbox
value={selectedTablesName.includes(table.name)}
label={table.name}
onValueChange={handleTableCheckboxChange}
>
{selectedTablesName.length ? t("connection.empty-select") : t("connection.select-all")}
</button>
</MultipleSelect>
</div>
)
<div className="text-black dark:text-gray-300">{table.token || countTextTokens(table.structure)}</div>
</Checkbox>
</div>
);
})
))}
{/* TODO(steven): remove this after we finish left sidebar */}
<ConversationList />
</div>
<div className="sticky bottom-0 w-full flex flex-col justify-center bg-gray-100 dark:bg-zinc-700 backdrop-blur bg-opacity-60 pb-4 py-2">
<div className="text-black dark:text-gray-300">
{t("connection.total-token")} {totalToken}
</div>
{!settingStore.setting.openAIApiConfig?.key && hasFeature("quota") && (
<div className="mb-4">
<QuotaView />

View File

@ -0,0 +1,34 @@
import * as CheckboxUI from "@radix-ui/react-checkbox";
import { CheckIcon, DividerHorizontalIcon } from "@radix-ui/react-icons";
import { ReactNode } from "react";
interface CheckboxProps {
value: boolean;
label: string;
onValueChange: (tableName: string, value: boolean) => void;
}
const Checkbox = (props: CheckboxProps & { children?: ReactNode }) => {
const { value, label, onValueChange, children } = props;
return (
<form>
<div className="flex justify-between items-center px-3 py-2">
<CheckboxUI.Root
checked={value}
onCheckedChange={(value: boolean) => onValueChange(label, value)}
className="bg-white w-5 h-5 shrink-0 cursor-pointer rounded-sm flex border border-gray-300 hover:border-black m-auto"
id={label}
>
<CheckboxUI.Indicator className="m-auto text-black">
<CheckIcon />
</CheckboxUI.Indicator>
</CheckboxUI.Root>
<label className="Label grow m-auto px-3 py-2 cursor-pointer truncate text-black dark:text-gray-300" htmlFor={label}>
{label}
</label>
{children}
</div>
</form>
);
};
export default Checkbox;

View File

@ -1,59 +0,0 @@
import { Listbox, Transition } from "@headlessui/react";
import { Fragment, ReactNode, useState } from "react";
import * as SelectUI from "@radix-ui/react-select";
import Icon from "../Icon";
interface Props<T = any> {
value: T[];
itemList: {
value: T;
label: string;
}[];
className?: string;
placeholder?: string;
selectedPlaceholder?: string;
onValueChange: (value: T) => void;
}
const MultipleSelect = (props: Props & { children?: ReactNode }) => {
const { itemList, value, placeholder, className, onValueChange, children } = props;
return (
<Listbox value={value} onChange={onValueChange} multiple>
<Listbox.Button
className={`${
className || ""
} flex flex-row justify-between items-center text-sm whitespace-nowrap dark:text-gray-300 bg-white dark:bg-zinc-700 border dark:border-zinc-800 px-3 py-2 rounded-lg`}
>
<div className="truncate">{placeholder}</div>
<SelectUI.Icon className="ml-1 w-5 h-auto shrink-0">
<Icon.BiChevronDown className="w-full h-auto opacity-60" />
</SelectUI.Icon>
</Listbox.Button>
<Transition as={Fragment} leave="transition ease-in duration-100" leaveFrom="opacity-100" leaveTo="opacity-0">
<Listbox.Options className="absolute border rounded-lg drop-shadow-lg dark:border-zinc-800 p-1 mt-1 max-h-80 overflow-y-auto scrollbar-hide w-full overflow-auto bg-white dark:bg-zinc-700 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{children && (
<Listbox.Option className="px-2 py-2" key="button" value="button">
{children}
</Listbox.Option>
)}
{itemList.map((item) => (
<Listbox.Option
className="w-full px-3 py-2 whitespace-nowrap truncate text-ellipsis overflow-x-hidden text-sm rounded-lg flex flex-row justify-between items-center cursor-pointer dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-zinc-800"
key={item.value}
value={item.value}
>
<div className="truncate">{item.label}</div>
{(value.find((v: string) => v === item.value) ? true : false) ? (
<span className="w-5 h-auto">
<Icon.BiCheck className="w-full h-auto" aria-hidden="true" />
</span>
) : null}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</Listbox>
);
};
export default MultipleSelect;

View File

@ -136,7 +136,6 @@ const getTableSchema = async (connection: Connection, databaseName: string): Pro
await client.end();
return schemaList;
return [];
};
const newConnector = (connection: Connection): Connector => {

View File

@ -32,6 +32,7 @@
"select-table": "Select your table",
"select-schema": "Select your Schema",
"all-tables": "All Tables",
"total-token": "Total Tokens",
"database-type": "Database type",
"title": "Title",
"host": "Host",

View File

@ -38,6 +38,7 @@
"password": "Contraseña",
"empty-select": "selección clara",
"select-all": "seleccionar todo",
"total-token": "Total Tokens",
"tidb-serverless-ssl-hint": "Se requiere SSL y ya está configurado"
},
"assistant": {

View File

@ -33,6 +33,7 @@
"select-schema": "选择 Schema",
"all-tables": "全部表",
"select-all": "选择全部",
"total-token": "总计 Token",
"empty-select": "清空选择",
"database-type": "数据库类型",
"title": "标题",

View File

@ -3,7 +3,8 @@ import { uniqBy } from "lodash-es";
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { Connection, Database, Engine, ResponseObject, Schema } from "@/types";
import { generateUUID } from "@/utils";
import { countTextTokens, generateUUID } from "@/utils";
import { count } from "console";
interface ConnectionContext {
connection: Connection;
@ -111,6 +112,11 @@ export const useConnectionStore = create<ConnectionState>()(
}
const fetchedTableList: Schema[] = result.data;
fetchedTableList.forEach((schema) => {
schema.tables.forEach((table) => {
table.token = countTextTokens(table.structure);
});
});
set((state) => ({
...state,
databaseList: state.databaseList.map((item) =>

View File

@ -10,6 +10,7 @@ export interface Table {
// structure is a string of the table structure.
// It's mainly used for providing a chat context for the assistant.
structure: string;
token?: number;
}
export interface Schema {
name: string;