diff --git a/packages/varlet-ui/src/picker/Picker.vue b/packages/varlet-ui/src/picker/Picker.vue new file mode 100644 index 00000000000..977d36e79ec --- /dev/null +++ b/packages/varlet-ui/src/picker/Picker.vue @@ -0,0 +1,101 @@ + + + + + diff --git a/packages/varlet-ui/src/picker/__tests__/index.spec.js b/packages/varlet-ui/src/picker/__tests__/index.spec.js new file mode 100644 index 00000000000..59b1cd42495 --- /dev/null +++ b/packages/varlet-ui/src/picker/__tests__/index.spec.js @@ -0,0 +1,7 @@ +const Picker = require('../../../cjs/picker').default +const { render } = require('@testing-library/vue') + +test('test picker', async () => { + const wrapper = render(Picker) + console.log(wrapper) +}) diff --git a/packages/varlet-ui/src/picker/docs/en_US.md b/packages/varlet-ui/src/picker/docs/en_US.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/varlet-ui/src/picker/docs/zh_CN.md b/packages/varlet-ui/src/picker/docs/zh_CN.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/varlet-ui/src/picker/example/index.vue b/packages/varlet-ui/src/picker/example/index.vue new file mode 100644 index 00000000000..fbfbcd4c1c3 --- /dev/null +++ b/packages/varlet-ui/src/picker/example/index.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/packages/varlet-ui/src/picker/index.ts b/packages/varlet-ui/src/picker/index.ts new file mode 100644 index 00000000000..b3f96901f52 --- /dev/null +++ b/packages/varlet-ui/src/picker/index.ts @@ -0,0 +1,8 @@ +import { App } from 'vue' +import Picker from './Picker.vue' + +Picker.install = function (app: App) { + app.component(Picker.name, Picker) +} + +export default Picker diff --git a/packages/varlet-ui/src/picker/picker.less b/packages/varlet-ui/src/picker/picker.less new file mode 100644 index 00000000000..e269e1269cd --- /dev/null +++ b/packages/varlet-ui/src/picker/picker.less @@ -0,0 +1,38 @@ +@picker-background: #fff; +@picker-picked-border: 1px solid #ddd; + +.var-picker { + width: 100%; + background: @picker-background; + + &__columns { + position: relative; + display: flex; + width: 100%; + } + + &__column { + flex-grow: 1; + overflow: hidden; + } + + &__scroller { + width: 100%; + } + + &__option { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + } + + &__picked { + position: absolute; + pointer-events: none; + width: 100%; + left: 0; + border-top: @picker-picked-border; + border-bottom: @picker-picked-border; + } +} diff --git a/packages/varlet-ui/src/picker/props.ts b/packages/varlet-ui/src/picker/props.ts new file mode 100644 index 00000000000..54c5c2587ee --- /dev/null +++ b/packages/varlet-ui/src/picker/props.ts @@ -0,0 +1,45 @@ +import { PropType } from 'vue' + +export interface NormalColumn { + texts: any[] + initialIndex?: number +} + +export interface CascadeColumn { + [textKey: string]: any + children: CascadeColumn[] +} + +export const props = { + columns: { + type: Array as PropType, + default: [], + }, + title: { + type: String, + }, + textKey: { + type: String, + default: 'text', + }, + toolbar: { + type: Boolean, + default: true, + }, + optionHeight: { + type: Number, + default: 44, + }, + optionCount: { + type: Number, + default: 6, + }, + confirmButtonText: { + type: String, + default: '确认', + }, + cancelButtonText: { + type: String, + default: '取消', + }, +}