Commit b982753a48e899f09d92b6a7ea367e0e9ba68857

Authored by ly525
Committed by 小小鲁班
1 parent 25ac0f18

chore: upgrade common props to use select type

front-end/h5/package.json
... ... @@ -17,7 +17,7 @@
17 17 "@luban-h5/lbc-button": "^0.0.3",
18 18 "@luban-h5/lbp-slide": "^0.0.7",
19 19 "@luban-h5/lbs-text-align": "^0.0.3",
20   - "@luban-h5/plugin-common-props": "^0.1.6",
  20 + "@luban-h5/plugin-common-props": "^0.2.6",
21 21 "animate.css": "^3.7.2",
22 22 "ant-design-vue": "^1.3.14",
23 23 "core-js": "^2.6.5",
... ...
front-end/h5/src/components/plugins/lbp-form-button.js
... ... @@ -73,53 +73,4 @@ export default {
73 73 req.send(formData)
74 74 }
75 75 },
76   - componentsForPropsEditor: {
77   - 'lbs-select-input-type': {
78   - props: ['value'],
79   - computed: {
80   - value_: {
81   - get () {
82   - return this.value
83   - },
84   - set (val) {
85   - this.$emit('input', val)
86   - }
87   - }
88   - },
89   - template: `
90   - <a-select v-model="value_" placeholder="类型">
91   - <a-option
92   - v-for="item in options"
93   - :key="item.value"
94   - :label="item.label"
95   - :value="item.value">
96   - </a-option>
97   - </a-select>
98   - `,
99   - data: () => ({
100   - options: [
101   - {
102   - label: '文字',
103   - value: 'text'
104   - },
105   - {
106   - label: '密码',
107   - value: 'password'
108   - },
109   - {
110   - label: '日期',
111   - value: 'date'
112   - },
113   - {
114   - label: '邮箱',
115   - value: 'email'
116   - },
117   - {
118   - label: '手机号',
119   - value: 'tel'
120   - }
121   - ]
122   - })
123   - }
124   - }
125 76 }
... ...
front-end/h5/src/components/plugins/lbp-form-input.js
1 1 // https://github.com/luban-h5-components/plugin-common-props
2 2 import PropTypes from '@luban-h5/plugin-common-props'
3 3  
  4 +const typeOptions = [
  5 + {
  6 + label: '文字',
  7 + value: 'text'
  8 + },
  9 + {
  10 + label: '密码',
  11 + value: 'password'
  12 + },
  13 + {
  14 + label: '日期',
  15 + value: 'date'
  16 + },
  17 + {
  18 + label: '邮箱',
  19 + value: 'email'
  20 + },
  21 + {
  22 + label: '手机号',
  23 + value: 'tel'
  24 + }
  25 +]
  26 +
4 27 export default {
5 28 name: 'lbp-form-input',
6 29 render (h) {
... ... @@ -26,14 +49,7 @@ export default {
26 49 />
27 50 },
28 51 props: {
29   - type: {
30   - type: String,
31   - default: 'text',
32   - editor: {
33   - type: 'lbs-select-input-type',
34   - label: '类型'
35   - }
36   - },
  52 + type: PropTypes.select({ defaultValue: 'text', label: '类型', options: typeOptions }),
37 53 name: PropTypes.string({ defaultValue: 'name', label: 'name' }),
38 54 disabled: PropTypes.boolean({ label: 'disabled' }),
39 55 fontSize: PropTypes.number({ label: '字号(px)' }),
... ... @@ -47,66 +63,6 @@ export default {
47 63 vertical: PropTypes.boolean(),
48 64 lineHeight: PropTypes.number({ label: '行高(px)', defaultValue: 1 })
49 65 },
50   - componentsForPropsEditor: {
51   - 'lbs-select-input-type': {
52   - props: ['value'],
53   - computed: {
54   - value_: {
55   - get () {
56   - return this.value
57   - },
58   - set (val) {
59   - this.$emit('input', val)
60   - }
61   - }
62   - },
63   - render (h) {
64   - return (
65   - <a-select
66   - placeholder="类型"
67   - value={this.value}
68   - onChange={(value) => {
69   - this.$emit('input', value)
70   - this.$emit('change', value)
71   - }}
72   - >
73   - {
74   - this.options.map(option => (
75   - <a-select-option
76   - key={option.value}
77   - value={option.value}
78   - >{option.label}</a-select-option>
79   - ))
80   - }
81   - </a-select>
82   - )
83   - },
84   - data: () => ({
85   - options: [
86   - {
87   - label: '文字',
88   - value: 'text'
89   - },
90   - {
91   - label: '密码',
92   - value: 'password'
93   - },
94   - {
95   - label: '日期',
96   - value: 'date'
97   - },
98   - {
99   - label: '邮箱',
100   - value: 'email'
101   - },
102   - {
103   - label: '手机号',
104   - value: 'tel'
105   - }
106   - ]
107   - })
108   - }
109   - }
110 66 }
111 67  
112 68 // .lb-plugin__input {
... ...
front-end/h5/yarn.lock
... ... @@ -792,10 +792,10 @@
792 792 resolved "https://registry.yarnpkg.com/@luban-h5/plugin-common-props/-/plugin-common-props-0.0.1.tgz#10fe5d5b2dda1db64912b3b99779aec60b5ea956"
793 793 integrity sha512-D8UEBht2BCJt8YDHqcYj0hQmn3WM3QdX3Rw8eaZP02o0NeNe2oDPKE4mCM3eN9U1ygcrDf9bR48RB9YgHJRHGA==
794 794  
795   -"@luban-h5/plugin-common-props@^0.1.6":
796   - version "0.1.6"
797   - resolved "https://registry.npmjs.org/@luban-h5/plugin-common-props/-/plugin-common-props-0.1.6.tgz#b4d44dd139ac99c58274c909fb61ca6df9051aa4"
798   - integrity sha512-0+0yuLioozw+wx+3Ui9JYTIT7mKWVtKKrSZAe49ldfmhkA0zsv2phIkAVwqDDtsxuwO0t8a0fA05GwY6WRMjIA==
  795 +"@luban-h5/plugin-common-props@^0.2.6":
  796 + version "0.2.6"
  797 + resolved "https://registry.npmjs.org/@luban-h5/plugin-common-props/-/plugin-common-props-0.2.6.tgz#a834f6564ef845238f14f449d0047f6b13a57adf"
  798 + integrity sha512-MQ94psT35blUdOb9vX1AfJCNVfVfCz+7v1d0sgY+4rSesaEU12HnlDg8Aaqfq5ePs6IQUSOtRWRgWSS4u6cKhQ==
799 799  
800 800 "@mrmlnc/readdir-enhanced@^2.2.1":
801 801 version "2.2.1"
... ...