diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index 2c85b44b..4797e92c 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -260,7 +260,8 @@ export default { {text: '日期选取器 (Date Picker)', link: 'form/date-picker', icon: '/components/form/date-picker.svg', version: '2024.5.3'}, {text: '计划任务 (Cron)', link: 'form/cron', icon: '/components/form/cron.svg', version: '2024.5.3'}, {text: '提及 (Mention)', link: 'form/mention', icon: '/components/form/mention.svg', version: '2025.1.0'}, - {text: 'IP输入框 (IP Input)', link: 'form/ip-input', icon: '/components/form/ip-input.svg', version: '2025.1.3'} + {text: 'IP输入框 (IP Input)', link: 'form/ip-input', icon: '/components/form/ip-input.svg', version: '2025.1.3'}, + {text: '穿梭框 (Transfer)', link: 'form/transfer', icon: '/components/form/transfer.svg', version: '2026.0.0'} ] return { diff --git a/docs/components/form/transfer.md b/docs/components/form/transfer.md new file mode 100644 index 00000000..843bd688 --- /dev/null +++ b/docs/components/form/transfer.md @@ -0,0 +1,811 @@ +--- +title: 穿梭框 (Transfer) +--- + +# 介绍 + +
+ +本文档主要用于描述 `ShadcnTransfer` 组件的一些特性和用法。 + +## 用法 + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 自定义列表标题 + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 自定义高度 + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 可搜索 (filterable) + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 自定义搜索方法 + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 禁用 (disabled) + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 尺寸 (size) + + +
+ + + +
+
+ +::: details 查看代码 + +```vue + + + +``` + +::: + +## 类型 (type) + + +
+ + + + +
+
+ +::: details 查看代码 + +```vue + + + +``` + +::: + +## 液态玻璃效果 (glass) + +::: raw + + +
+ +
+
+ +::: + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 自定义渲染 + + + + + + + +::: details 查看代码 + +```vue + + + +``` + +::: + +## 在表单中使用 + + + + + + +
+ + 重置 + + + 提交 + +
+
+
+ +::: details 查看代码 + +```vue + + + +``` + +::: + +## 穿梭框 (Transfer) 属性 + + + + +## 穿梭框 (Transfer) 事件 + + + + +## 穿梭框 (Transfer) 插槽 + + + + + diff --git a/packages/index.ts b/packages/index.ts index 43e6d116..a684ff48 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -83,6 +83,7 @@ import { ShadcnNotification, ShadcnNotificationItem } from '@/ui/notification' import { ShadcnTime } from '@/ui/time' import { ShadcnIPInput } from '@/ui/ip-input' import { ShadcnMarkdown } from '@/ui/markdown' +import { ShadcnTransfer } from '@/ui/transfer' let components = [ ShadcnButton, ShadcnButtonGroup, @@ -163,7 +164,8 @@ let components = [ ShadcnNotification, ShadcnNotificationItem, ShadcnTime, ShadcnIPInput, - ShadcnMarkdown + ShadcnMarkdown, + ShadcnTransfer ] interface InstallOptions @@ -279,6 +281,7 @@ export { ShadcnNotification, ShadcnNotificationItem } from '@/ui/notification' export { ShadcnTime } from '@/ui/time' export { ShadcnIPInput } from '@/ui/ip-input' export { ShadcnMarkdown } from '@/ui/markdown' +export { ShadcnTransfer } from '@/ui/transfer' // Export functions export { fnToString, fnToFunction } from '@/utils/formatter' diff --git a/playground/src/example/transfer/custom.vue b/playground/src/example/transfer/custom.vue new file mode 100644 index 00000000..3af7e72c --- /dev/null +++ b/playground/src/example/transfer/custom.vue @@ -0,0 +1,44 @@ + + + diff --git a/playground/src/example/transfer/glass.vue b/playground/src/example/transfer/glass.vue new file mode 100644 index 00000000..2d047476 --- /dev/null +++ b/playground/src/example/transfer/glass.vue @@ -0,0 +1,59 @@ + + + diff --git a/playground/src/example/transfer/usage.vue b/playground/src/example/transfer/usage.vue new file mode 100644 index 00000000..c46f6d04 --- /dev/null +++ b/playground/src/example/transfer/usage.vue @@ -0,0 +1,115 @@ + + + diff --git a/src/App.vue b/src/App.vue index fbe67bee..7dc1ef85 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,98 +1,180 @@ diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index fb3c8be0..223f1fee 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -333,5 +333,12 @@ export default { clearAll: 'Clear All', noData: 'No data' } + }, + transfer: { + text: { + leftTitle: 'Source', + rightTitle: 'Target', + filterPlaceholder: 'Search' + } } } \ No newline at end of file diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 3dba708d..a84e6e03 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -333,5 +333,12 @@ export default { clearAll: '全部清除', noData: '暂无数据' } + }, + transfer: { + text: { + leftTitle: '源列表', + rightTitle: '目标列表', + filterPlaceholder: '请输入搜索内容' + } } } \ No newline at end of file diff --git a/src/ui/transfer/ShadcnTransfer.vue b/src/ui/transfer/ShadcnTransfer.vue new file mode 100644 index 00000000..2d5f79ce --- /dev/null +++ b/src/ui/transfer/ShadcnTransfer.vue @@ -0,0 +1,413 @@ + + + diff --git a/src/ui/transfer/index.ts b/src/ui/transfer/index.ts new file mode 100644 index 00000000..fd187233 --- /dev/null +++ b/src/ui/transfer/index.ts @@ -0,0 +1,2 @@ +export { default as ShadcnTransfer } from './ShadcnTransfer.vue' +export type { TransferProps, TransferEmits, TransferItem } from './types' diff --git a/src/ui/transfer/types.ts b/src/ui/transfer/types.ts new file mode 100644 index 00000000..352b3cfe --- /dev/null +++ b/src/ui/transfer/types.ts @@ -0,0 +1,29 @@ +import { Size } from '@/ui/enum/Size' +import { Type } from '@/ui/enum/Type' + +export interface TransferItem { + [key: string]: any + disabled?: boolean +} + +export interface TransferProps { + data: TransferItem[] + modelValue: (string | number)[] + keyProp?: string + labelProp?: string + leftTitle?: string + rightTitle?: string + dark?: boolean + glass?: boolean + type?: keyof typeof Type + size?: keyof typeof Size + height?: any + filterable?: boolean + filterPlaceholder?: string + filterMethod?: (query: string, item: TransferItem) => boolean +} + +export type TransferEmits = { + 'update:modelValue': [value: (string | number)[]] + 'on-change': [value: (string | number)[], direction: 'left' | 'right', movedKeys: (string | number)[]] +} diff --git a/types/view-shadcn.d.ts b/types/view-shadcn.d.ts index be7f3099..57e6b65e 100644 --- a/types/view-shadcn.d.ts +++ b/types/view-shadcn.d.ts @@ -9,7 +9,7 @@ declare module 'view-shadcn-ui' export const ShadcnCopy: typeof import('@/ui/copy').default export const ShadcnCode: typeof import('@/ui/code').default export const ShadcnInput: typeof import('@/ui/input').default - export const Icon: typeof import('@/ui/icon').default + export const ShadcnIcon: typeof import('@/ui/icon').default export const ShadcnModal: typeof import('@/ui/modal').default export const ShadcnTooltip: typeof import('@/ui/tooltip').default export const ShadcnRow: typeof import('@/ui/row').default @@ -49,4 +49,7 @@ declare module 'view-shadcn-ui' export const ShadcnBreadcrumb: typeof import('@/ui/breadcrumb').default export const ShadcnBreadcrumbItem: typeof import('@/ui/breadcrumb/item').default export const ShadcnSlider: typeof import('@/ui/slider').default + export const ShadcnTransfer: typeof import('@/ui/transfer').ShadcnTransfer + + export type { TransferProps, TransferEmits, TransferItem } from '@/ui/transfer' }