plain-design 1.0.0-beta.33 → 1.0.0-beta.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. package/dist/plain-design.commonjs.min.js +18 -18
  2. package/dist/plain-design.min.css +1 -1
  3. package/dist/plain-design.min.js +18 -18
  4. package/dist/report.html +38 -38
  5. package/package.json +3 -2
  6. package/src/packages/components/Dropdown/dropdown.public.scss +10 -0
  7. package/src/packages/components/Dropdown/dropdown.utils.tsx +3 -1
  8. package/src/packages/components/Dropdown/index.tsx +2 -2
  9. package/src/packages/components/DropdownSeparator/index.tsx +8 -0
  10. package/src/packages/entry.tsx +1 -0
  11. package/src/pages/data/address.json +0 -39317
  12. package/src/pages/data/data-1.json +0 -754
  13. package/src/pages/data/data-2.json +0 -3006
  14. package/src/pages/data/data-200.json +0 -5206
  15. package/src/pages/data/data-2000.json +0 -51954
  16. package/src/pages/data/data-50.json +0 -2075
  17. package/src/pages/data/data.json +0 -30002
  18. package/src/pages/data/demo.json +0 -1702
  19. package/src/pages/data/mock.database.js +0 -43
  20. package/src/pages/data/mock.js +0 -141
  21. package/src/pages/data/tree.data.json +0 -87
  22. package/src/pages/env/config/local.js +0 -3
  23. package/src/pages/env/config/prod.js +0 -3
  24. package/src/pages/env/config/undefined.js +0 -1
  25. package/src/pages/env/env.d.ts +0 -4
  26. package/src/pages/env/index.ts +0 -1
  27. package/src/pages/history/createHistory.ts +0 -94
  28. package/src/pages/history/history.utils.ts +0 -64
  29. package/src/pages/index/App.tsx +0 -17
  30. package/src/pages/index/Demo/DemoLine.tsx +0 -23
  31. package/src/pages/index/Demo/DemoRow.scss +0 -131
  32. package/src/pages/index/Demo/DemoRow.tsx +0 -71
  33. package/src/pages/index/Demo/DemoRow.utils.ts +0 -23
  34. package/src/pages/index/Demo/DemoRowController.tsx +0 -45
  35. package/src/pages/index/Demo/index.ts +0 -8
  36. package/src/pages/index/app.scss +0 -197
  37. package/src/pages/index/components/AutoTable/AutoHeightAutoRow.tsx +0 -56
  38. package/src/pages/index/components/AutoTable/AutoHeightFixedRow.tsx +0 -50
  39. package/src/pages/index/components/AutoTable/AutoTableBasicUsage.tsx +0 -75
  40. package/src/pages/index/components/AutoTable/AutoTableCascade.tsx +0 -99
  41. package/src/pages/index/components/AutoTable/AutoTableDefaultSearch.tsx +0 -73
  42. package/src/pages/index/components/AutoTable/AutoTableFiles.tsx +0 -26
  43. package/src/pages/index/components/AutoTable/AutoTableFill.tsx +0 -51
  44. package/src/pages/index/components/AutoTable/AutoTableGroupUsage.tsx +0 -71
  45. package/src/pages/index/components/AutoTable/AutoTableObjectPicker.tsx +0 -181
  46. package/src/pages/index/components/AutoTable/AutoTableOvList.tsx +0 -80
  47. package/src/pages/index/components/AutoTable/AutoTableProductList.tsx +0 -98
  48. package/src/pages/index/components/AutoTable/AutoTableRowFormatter.tsx +0 -58
  49. package/src/pages/index/components/AutoTable/FixedHeightAutoRow.tsx +0 -50
  50. package/src/pages/index/components/AutoTable/FixedHeightFixedRow.tsx +0 -49
  51. package/src/pages/index/components/bus/DemoAddress.tsx +0 -181
  52. package/src/pages/index/components/bus/DemoAddressCascade.tsx +0 -132
  53. package/src/pages/index/components/bus/DemoFilter.tsx +0 -184
  54. package/src/pages/index/components/columns/DemoPlcAddress.tsx +0 -161
  55. package/src/pages/index/components/columns/DemoPlcDate.tsx +0 -363
  56. package/src/pages/index/components/columns/DemoPlcSelect.tsx +0 -505
  57. package/src/pages/index/components/columns/DemoPlcTime.tsx +0 -293
  58. package/src/pages/index/components/columns/DemoTableColumns.tsx +0 -88
  59. package/src/pages/index/components/form/DemoFormBasic.tsx +0 -516
  60. package/src/pages/index/components/form/DemoFormBlur.tsx +0 -204
  61. package/src/pages/index/components/form/DemoFormDynamicFields.tsx +0 -54
  62. package/src/pages/index/components/form/DemoFormEditControl.tsx +0 -164
  63. package/src/pages/index/components/form/DemoFormElement.tsx +0 -207
  64. package/src/pages/index/components/form/DemoFormLayout.scss +0 -7
  65. package/src/pages/index/components/form/DemoFormLayout.tsx +0 -311
  66. package/src/pages/index/components/form/DemoFormSimplify.tsx +0 -587
  67. package/src/pages/index/components/form/DemoFormSize.tsx +0 -274
  68. package/src/pages/index/components/form/DemoFormVertical.tsx +0 -280
  69. package/src/pages/index/components/normal/DemoAlert.tsx +0 -66
  70. package/src/pages/index/components/normal/DemoBadge.tsx +0 -53
  71. package/src/pages/index/components/normal/DemoButton.tsx +0 -300
  72. package/src/pages/index/components/normal/DemoCard.tsx +0 -176
  73. package/src/pages/index/components/normal/DemoCarousel.tsx +0 -230
  74. package/src/pages/index/components/normal/DemoCascade.tsx +0 -880
  75. package/src/pages/index/components/normal/DemoCheckbox.scss +0 -24
  76. package/src/pages/index/components/normal/DemoCheckbox.tsx +0 -294
  77. package/src/pages/index/components/normal/DemoCollapse.tsx +0 -104
  78. package/src/pages/index/components/normal/DemoColor.scss +0 -20
  79. package/src/pages/index/components/normal/DemoColor.tsx +0 -82
  80. package/src/pages/index/components/normal/DemoColorPicker.tsx +0 -163
  81. package/src/pages/index/components/normal/DemoDate.tsx +0 -443
  82. package/src/pages/index/components/normal/DemoDialog.tsx +0 -507
  83. package/src/pages/index/components/normal/DemoDropdown.tsx +0 -463
  84. package/src/pages/index/components/normal/DemoGrid.scss +0 -26
  85. package/src/pages/index/components/normal/DemoGrid.tsx +0 -181
  86. package/src/pages/index/components/normal/DemoIcon.tsx +0 -39
  87. package/src/pages/index/components/normal/DemoImage.tsx +0 -122
  88. package/src/pages/index/components/normal/DemoInput.scss +0 -0
  89. package/src/pages/index/components/normal/DemoInput.tsx +0 -790
  90. package/src/pages/index/components/normal/DemoKeepAlive.tsx +0 -505
  91. package/src/pages/index/components/normal/DemoLayout.tsx +0 -144
  92. package/src/pages/index/components/normal/DemoList.scss +0 -15
  93. package/src/pages/index/components/normal/DemoList.tsx +0 -82
  94. package/src/pages/index/components/normal/DemoLoading.tsx +0 -86
  95. package/src/pages/index/components/normal/DemoNumber.tsx +0 -269
  96. package/src/pages/index/components/normal/DemoPagination.tsx +0 -164
  97. package/src/pages/index/components/normal/DemoPopup.tsx +0 -695
  98. package/src/pages/index/components/normal/DemoProgress.tsx +0 -133
  99. package/src/pages/index/components/normal/DemoRadio.scss +0 -16
  100. package/src/pages/index/components/normal/DemoRadio.tsx +0 -188
  101. package/src/pages/index/components/normal/DemoRate.tsx +0 -77
  102. package/src/pages/index/components/normal/DemoScroll.scss +0 -22
  103. package/src/pages/index/components/normal/DemoScroll.tsx +0 -300
  104. package/src/pages/index/components/normal/DemoSegment.tsx +0 -71
  105. package/src/pages/index/components/normal/DemoSelect.tsx +0 -819
  106. package/src/pages/index/components/normal/DemoSlider.tsx +0 -128
  107. package/src/pages/index/components/normal/DemoSortList.tsx +0 -70
  108. package/src/pages/index/components/normal/DemoStackCard.tsx +0 -356
  109. package/src/pages/index/components/normal/DemoStep.scss +0 -18
  110. package/src/pages/index/components/normal/DemoStep.tsx +0 -291
  111. package/src/pages/index/components/normal/DemoTab.tsx +0 -338
  112. package/src/pages/index/components/normal/DemoTag.tsx +0 -100
  113. package/src/pages/index/components/normal/DemoTime.tsx +0 -403
  114. package/src/pages/index/components/normal/DemoToggle.tsx +0 -56
  115. package/src/pages/index/components/normal/DemoTooltip.tsx +0 -120
  116. package/src/pages/index/components/normal/DemoTree.tsx +0 -1183
  117. package/src/pages/index/components/normal/DemoUpload.tsx +0 -484
  118. package/src/pages/index/components/normal/DemoVirtualList.tsx +0 -464
  119. package/src/pages/index/components/service/DemoDialogService.tsx +0 -249
  120. package/src/pages/index/components/service/DemoFileService.tsx +0 -110
  121. package/src/pages/index/components/service/DemoImagePreviewer.tsx +0 -185
  122. package/src/pages/index/components/service/DemoMessageService.tsx +0 -100
  123. package/src/pages/index/components/service/DemoNoticeService.tsx +0 -99
  124. package/src/pages/index/components/service/DemoPopupService.tsx +0 -325
  125. package/src/pages/index/components/table/DemoPlcOperation.tsx +0 -307
  126. package/src/pages/index/components/table/DemoTableBasic.tsx +0 -220
  127. package/src/pages/index/components/table/DemoTableCheck.tsx +0 -78
  128. package/src/pages/index/components/table/DemoTableClassAndStyle.scss +0 -18
  129. package/src/pages/index/components/table/DemoTableClassAndStyle.tsx +0 -112
  130. package/src/pages/index/components/table/DemoTableColDraggable.tsx +0 -80
  131. package/src/pages/index/components/table/DemoTableEdit.tsx +0 -136
  132. package/src/pages/index/components/table/DemoTableExpand.tsx +0 -203
  133. package/src/pages/index/components/table/DemoTableFixed.tsx +0 -131
  134. package/src/pages/index/components/table/DemoTableFormatter.tsx +0 -66
  135. package/src/pages/index/components/table/DemoTableOverflowTooltip.tsx +0 -67
  136. package/src/pages/index/components/table/DemoTableRowDraggable.tsx +0 -106
  137. package/src/pages/index/components/table/DemoTableSlots.tsx +0 -153
  138. package/src/pages/index/components/table/DemoTableSpan.tsx +0 -167
  139. package/src/pages/index/components/table/DemoTableTree.tsx +0 -976
  140. package/src/pages/index/components/table/DemoVirtualTable.tsx +0 -274
  141. package/src/pages/index/components/test/DemoI18n.tsx +0 -27
  142. package/src/pages/index/components/test/DemoI18n2.jsx +0 -11
  143. package/src/pages/index/home/AppContent.tsx +0 -69
  144. package/src/pages/index/home/AppHead.tsx +0 -18
  145. package/src/pages/index/home/AppHome.tsx +0 -31
  146. package/src/pages/index/home/AppMenu.tsx +0 -38
  147. package/src/pages/index/home/menus.tsx +0 -220
  148. package/src/pages/index/home/plain-design.png +0 -0
  149. package/src/pages/index/main.tsx +0 -23
  150. package/src/pages/index/nav/$nav.ts +0 -41
  151. package/src/pages/index/pages.d.ts +0 -6
  152. package/src/pages/libs/iconfont-fontcls/demo.css +0 -539
  153. package/src/pages/libs/iconfont-fontcls/demo_index.html +0 -303
  154. package/src/pages/libs/iconfont-fontcls/iconfont.css +0 -35
  155. package/src/pages/libs/iconfont-fontcls/iconfont.js +0 -1
  156. package/src/pages/libs/iconfont-fontcls/iconfont.json +0 -44
  157. package/src/pages/libs/iconfont-fontcls/iconfont.ttf +0 -0
  158. package/src/pages/libs/iconfont-fontcls/iconfont.woff +0 -0
  159. package/src/pages/libs/iconfont-fontcls/iconfont.woff2 +0 -0
  160. package/src/pages/libs/iconfont-symbol/demo.css +0 -539
  161. package/src/pages/libs/iconfont-symbol/demo_index.html +0 -303
  162. package/src/pages/libs/iconfont-symbol/iconfont.css +0 -35
  163. package/src/pages/libs/iconfont-symbol/iconfont.js +0 -1
  164. package/src/pages/libs/iconfont-symbol/iconfont.json +0 -44
  165. package/src/pages/libs/iconfont-symbol/iconfont.ttf +0 -0
  166. package/src/pages/libs/iconfont-symbol/iconfont.woff +0 -0
  167. package/src/pages/libs/iconfont-symbol/iconfont.woff2 +0 -0
  168. package/src/pages/libs/install.iconfont-fontcls.tsx +0 -11
  169. package/src/pages/libs/install.iconfont-symbol.scss +0 -7
  170. package/src/pages/libs/install.iconfont-symbol.tsx +0 -14
  171. package/src/pages/module/address.ts +0 -27
  172. package/src/pages/module/http.ts +0 -24
  173. package/src/pages/module/index.ts +0 -19
  174. package/src/pages/module/object.ts +0 -5
  175. package/src/pages/module/ov.tsx +0 -13
  176. package/src/pages/module/upload.ts +0 -9
  177. package/src/pages/module/useTableOption.ts +0 -28
@@ -1,790 +0,0 @@
1
- import {computed, designComponent, designPage, PropType, reactive, useModel, useRefs, watch} from "plain-design-composition";
2
- import {DemoRow} from "../../Demo/DemoRow";
3
- import {$message, $notice, Button, Checkbox, Dropdown, DropdownOption, Icon, Input, InputGroup, Loading, Segment, SegmentGroup, Tag} from "../../../../packages";
4
- import {DemoLine} from "../../Demo/DemoLine";
5
- import './DemoInput.scss';
6
- import {delay} from "plain-utils/utils/delay";
7
- import {FixInput} from "../../../../packages/utils/FixInput";
8
-
9
- export const demo1 = designPage(() => {
10
-
11
- const state = reactive({
12
- val: 'hello world'
13
- });
14
-
15
- return () => (
16
- <DemoRow title="基本用法">
17
- <Input v-model={state.val} width="200"/> {state.val}
18
- </DemoRow>
19
- );
20
- });
21
-
22
-
23
- export const demoSize = designPage(() => {
24
-
25
- const state = reactive({
26
- val: 'hello world'
27
- });
28
-
29
- return () => (
30
- <DemoRow title="大小尺寸">
31
- <DemoLine>
32
- <div>
33
- <Input v-model={state.val} size="mini" width="200px"/>
34
- <Button label="提交" size="mini"/>
35
- </div>
36
- </DemoLine>
37
- <DemoLine>
38
- <div>
39
- <Input v-model={state.val} size="small" width="200px"/>
40
- <Button label="提交" size="small"/>
41
- </div>
42
- </DemoLine>
43
- <DemoLine>
44
- <div>
45
- <Input v-model={state.val} size="normal" width="200px"/>
46
- <Button label="提交" size="normal"/>
47
- </div>
48
- </DemoLine>
49
- <DemoLine>
50
- <div>
51
- <Input v-model={state.val} size="large" width="200px"/>
52
- <Button label="提交" size="large"/>
53
- </div>
54
- </DemoLine>
55
- </DemoRow>
56
- );
57
- });
58
-
59
- export const demoNoClear = designPage(() => {
60
-
61
- const state = reactive({
62
- val: 'hello world'
63
- });
64
-
65
- return () => (
66
- <DemoRow title="去掉清空按钮">
67
- <DemoLine>
68
- <Input v-model={state.val} width="200" noClear/> noClear
69
- </DemoLine>
70
- <DemoLine>
71
- <Input modelValue="桃花仙人种桃树,又摘桃花换酒钱" width="200" noClear/> noClear
72
- </DemoLine>
73
- <DemoLine>
74
- <Input v-model={state.val} width="200"/>
75
- </DemoLine>
76
- <DemoLine>
77
- <Input modelValue="桃花仙人种桃树,又摘桃花换酒钱" width="200"/>
78
- </DemoLine>
79
-
80
- </DemoRow>
81
- );
82
- });
83
-
84
-
85
- export const demoIcon = designPage(() => {
86
-
87
- const state = reactive({
88
- val: 'hello world'
89
- });
90
-
91
- const handler = {
92
- onClickPrefixIcon: () => $message.primary('prefix'),
93
- onClickSuffixIcon: () => $message.warn('suffix'),
94
- onClear: () => $message.error('clear')
95
- };
96
-
97
- return () => (
98
- <DemoRow title="前置后置图标">
99
- <DemoLine>
100
- <Input v-model={state.val} width="200" prefixIcon="pi-search" {...handler}/> prefixIcon
101
- </DemoLine>
102
- <DemoLine>
103
- <Input modelValue="桃花仙人种桃树,又摘桃花换酒钱" width="200" suffixIcon="pi-search" {...handler}/> suffixIcon
104
- </DemoLine>
105
- <DemoLine>
106
- <Input v-model={state.val} width="200" prefixIcon="pi-search" noClear {...handler}/> prefixIcon no clear
107
- </DemoLine>
108
- <DemoLine>
109
- <Input modelValue="桃花仙人种桃树,又摘桃花换酒钱" width="200" suffixIcon="pi-search" noClear {...handler}/> suffixIcon no
110
- clear
111
- </DemoLine>
112
- <DemoLine>
113
- <Input modelValue="桃花仙人种桃树,又摘桃花换酒钱" width="200" suffixIcon="pi-search"
114
- prefixIcon="pi-search" {...handler}/> prefixIcon and suffixIcon
115
- </DemoLine>
116
-
117
- </DemoRow>
118
- );
119
- });
120
-
121
- export const demoSuffix = designPage(() => {
122
-
123
- const Selector = designComponent({
124
- props: {
125
- modelValue: { type: String },
126
- options: { type: Array as PropType<{ label: string, icon: string }[]> },
127
- placement: {},
128
- size: {},
129
- },
130
- emits: {
131
- onUpdateModelValue: (val?: string) => true,
132
- },
133
- setup({ props, event: { emit } }) {
134
-
135
- const model = useModel(() => props.modelValue, emit.onUpdateModelValue);
136
-
137
- return () => (
138
- <Dropdown placement={props.placement as any || 'bottom-start'} size={props.size as any}>
139
- {{
140
- reference: ({ open }: { open?: boolean }) => <span
141
- style={{ paddingLeft: '12px' }}>{props.options?.find(i => i.label === model.value)?.label} <Icon
142
- icon={open ? 'pi-up' : 'pi-down'} style={{ marginLeft: '4px' }}/></span>,
143
- popper: () => <>
144
- {props.options?.map(option => (
145
- <DropdownOption key={option.label} label={option.label} icon={option.icon}
146
- onClick={() => model.value = option.label}/>
147
- ))}
148
- </>
149
- }}
150
- </Dropdown>
151
- );
152
- }
153
- });
154
-
155
- const payOptions = [
156
- { label: '微信支付', icon: 'pi-alipay-circle' },
157
- { label: '支付宝', icon: 'pi-wechatpay' },
158
- { label: '财付通', icon: 'pi-qq' },
159
- ];
160
-
161
- const state = reactive({
162
- val: 'hello world',
163
- size: 'normal' as any,
164
- });
165
-
166
- return () => (
167
- <DemoRow title="前置后置内容" key={state.size}>
168
- <DemoLine>
169
- <SegmentGroup v-model={state.size}>
170
- <Segment label="Mini" val="mini"/>
171
- <Segment label="Small" val="small"/>
172
- <Segment label="Normal" val="normal"/>
173
- <Segment label="Large" val="large"/>
174
- </SegmentGroup>
175
- </DemoLine>
176
- <DemoLine>
177
- <Input v-model={state.val} width="300px" size={state.size}>
178
- {{ prefix: () => (<span>汇款账户</span>) }}
179
- </Input>
180
- <span>prefix test</span>
181
- </DemoLine>
182
- <DemoLine>
183
- <Input v-model={state.val} width="300px" size={state.size}>
184
- {{ prefix: () => (<Selector options={payOptions} modelValue="支付宝" size={state.size}/>) }}
185
- </Input>
186
- <span>prefix dropdown</span>
187
- </DemoLine>
188
-
189
- <DemoLine>
190
- <Input v-model={state.val} width="300px" size={state.size}>
191
- {{ suffix: () => (<span>汇款账户</span>) }}
192
- </Input>
193
- <span>suffix test</span>
194
- </DemoLine>
195
- <DemoLine>
196
- <Input v-model={state.val} width="300px" size={state.size}>
197
- {{
198
- suffix: () => (<Selector options={payOptions} modelValue="支付宝" placement="bottom-end" size={state.size}/>)
199
- }}
200
- </Input>
201
- <span>suffix dropdown</span>
202
- </DemoLine>
203
- </DemoRow>
204
- );
205
- });
206
-
207
- export const demoStatus = designPage(() => {
208
-
209
- const state = reactive({
210
- val: 'hello world'
211
- });
212
-
213
- return () => (
214
- <DemoRow title="状态">
215
- <Input v-model={state.val} width="200"/>
216
- <Input v-model={state.val} status="primary" width="200"/>
217
- <Input v-model={state.val} status="success" width="200"/>
218
- <Input v-model={state.val} status="warn" width="200"/>
219
- <Input v-model={state.val} status="error" width="200"/>
220
- </DemoRow>
221
- );
222
- });
223
-
224
- export const demoBlock = designPage(() => {
225
-
226
- return () => (
227
- <DemoRow title="宽度">
228
- <div>
229
- <Input placeholder="80px" width="80px" noClear/>
230
- <br/>
231
- <br/>
232
- <Input placeholder="150" width="150px" noClear/>
233
- <br/>
234
- <br/>
235
- <Input placeholder="300px" width="300px" noClear/>
236
- <br/>
237
- <br/>
238
- <Input placeholder="Default" noClear/>
239
- </div>
240
- </DemoRow>
241
- );
242
- });
243
-
244
-
245
- export const demoThrottleEnter = designPage(() => {
246
-
247
- return () => (
248
- <DemoRow title="enter事件节流">
249
- <div>
250
- <Input placeholder="500ms" width="300" throttleEnter={500} onEnter={() => $message('enter')}/>
251
- <br/>
252
- <br/>
253
- <Input placeholder="1s" width="300" throttleEnter onEnter={() => $message('enter')}/>
254
- </div>
255
- </DemoRow>
256
- );
257
- });
258
-
259
- export const demoAsyncEnter = designPage(() => {
260
-
261
- const asyncEnterHandler = async () => {
262
- await delay(2000);
263
- console.log('done');
264
- };
265
-
266
- return () => (
267
- <DemoRow title="异步enter处理">
268
- <p>使用asyncHandler来处理异步的enter事件,会自动开启loading事件</p>
269
- <div>
270
- <Input width="300" asyncHandler={asyncEnterHandler}/>
271
- </div>
272
- </DemoRow>
273
- );
274
- });
275
-
276
- export const demoLoading = designPage(() => {
277
-
278
- const state = reactive({
279
- loading: false,
280
- });
281
-
282
- return () => (
283
- <DemoRow title="加载状态">
284
- <Checkbox label="open loading" v-model={state.loading}/>
285
- <Input width="300" loading={state.loading}/>
286
- </DemoRow>
287
- );
288
- });
289
-
290
- export const demoPassword = designPage(() => {
291
-
292
- const state = reactive({
293
- visible: false,
294
- text: '123456789',
295
- });
296
-
297
- return () => (
298
- <DemoRow title="密码输入框">
299
- <Input width="300" type={state.visible ? 'text' : 'password'} v-model={state.text} noClear>
300
- {{
301
- suffixIconContent: () => (
302
- <Icon icon={state.visible ? 'pi-eye-invisible' : 'pi-eye'} onClick={() => state.visible = !state.visible}
303
- className="input-suffix-icon"/>
304
- )
305
- }}
306
- </Input>
307
- </DemoRow>
308
- );
309
- });
310
-
311
-
312
- export const demoRange = designPage(() => {
313
-
314
- const useFocusHandler = (elGetter: () => HTMLElement | null | undefined) => {
315
- const state = reactive({
316
- isFocus: false,
317
- getEl: () => null as null | HTMLElement,
318
- });
319
- const handler = {
320
- onFocus: () => {
321
- state.isFocus = true;
322
- },
323
- onBlue: () => {
324
- state.isFocus = false;
325
- },
326
- };
327
- watch(() => elGetter(), (newEl) => {
328
- const oldEl = state.getEl();
329
- if (!!oldEl) {
330
- oldEl.removeEventListener('focus', handler.onFocus);
331
- oldEl.removeEventListener('blur', handler.onBlue);
332
- }
333
- if (!newEl) {
334
- return;
335
- }
336
- state.getEl = () => newEl || null;
337
- newEl.addEventListener('focus', handler.onFocus);
338
- newEl.addEventListener('blur', handler.onBlue);
339
- }, { immediate: true });
340
- const methods = {
341
- focus: () => state.getEl()?.focus(),
342
- blur: () => state.getEl()?.blur(),
343
- };
344
- return {
345
- state,
346
- ...methods,
347
- };
348
- };
349
-
350
- const { refs, onRef } = useRefs({ start: HTMLInputElement, end: HTMLInputElement });
351
-
352
- const startInput = useFocusHandler(() => refs.start);
353
- const endInput = useFocusHandler(() => refs.end);
354
-
355
- return () => (
356
- <DemoRow title="范围输入框">
357
- <div>
358
- <Input placeholder="300px" width="300px" isFocus={startInput.state.isFocus || endInput.state.isFocus}>
359
- <div className="input-box input-fill">
360
- <FixInput type="text" className="input-box input-fill" value="2022-05-01" style={{ textAlign: 'center' }}
361
- ref={onRef.start}/>
362
- <span>/</span>
363
- <FixInput type="text" className="input-box input-fill" value="2022-05-20" style={{ textAlign: 'center' }}
364
- ref={onRef.end}/>
365
- </div>
366
- </Input>
367
- </div>
368
- </DemoRow>
369
- );
370
- });
371
-
372
-
373
- export const demoMultiple = designPage(() => {
374
-
375
- const state = reactive({
376
- size: 'normal' as any,
377
- arrayStringValue: null,
378
- });
379
-
380
- return () => (
381
- <DemoRow title="多值输入框">
382
- <p>默认支持以空格,换行符中英文逗号分隔字符串。如果需要禁用这个行为,请设置 multipleSeparator 为 null</p>
383
- <DemoLine>
384
- <SegmentGroup v-model={state.size}>
385
- <Segment label="Mini" val="mini"/>
386
- <Segment label="Small" val="small"/>
387
- <Segment label="Normal" val="normal"/>
388
- <Segment label="Large" val="large"/>
389
- </SegmentGroup>
390
- </DemoLine>
391
- <div>
392
- <Input size={state.size} placeholder="normal input" width="300px"/><Button
393
- size={state.size}><span>normal input</span></Button>
394
- <br/>
395
- <br/>
396
- <Input size={state.size} modelValue={['标签001', '标签002', '标签003']} multiple width="300px"/><Button
397
- size={state.size}><span>multiple input</span></Button>
398
- <br/>
399
- <br/>
400
- <div><Input size={state.size} multiple width="300px"/><Button
401
- size={state.size}><span>empty multiple input</span></Button></div>
402
- <br/>
403
- <br/>
404
- <Input size={state.size} modelValue={['标签001', '标签002', '标签003', '标签004', '标签005', '标签006', '标签007']} multiple
405
- width="300px" tagsWrap/>
406
- <br/>
407
- <br/>
408
- <Input size={state.size} modelValue={['标签001', '标签002', '标签003', '标签004', '标签005', '标签006', '标签007']} multiple
409
- width="300px"/>
410
- <br/>
411
- <br/>
412
- <Input v-model={state.arrayStringValue} placeholder="绑定值类型为arraystring" valueType="arraystring" size={state.size} multiple width="300px"/>
413
- {JSON.stringify(state.arrayStringValue)}
414
- </div>
415
- </DemoRow>
416
- );
417
- });
418
-
419
- export const demoBindMultipleText = designPage(() => {
420
-
421
- const state = reactive({
422
- val: ['hello world'],
423
- inputText: '货拉拉拉不拉拉布拉多取决于拉布拉多在货拉拉上拉的多不多',
424
- });
425
-
426
- return () => (
427
- <DemoRow title="多值的时候绑定实时输入的文本">
428
- <Input v-model={state.val} width="200" multiple v-model:multipleText={state.inputText}
429
- placeholder="请输入标签"/>
430
- {state.val?.map((item, index) => <Tag key={index}>{item}</Tag>)}
431
- <div>
432
- <br/>
433
- <Input textarea v-model={state.inputText}/>
434
- </div>
435
- </DemoRow>
436
- );
437
- });
438
-
439
- export const demoTextarea = designPage(() => {
440
-
441
- const state = reactive({
442
- val: 'hello world'
443
- });
444
-
445
- return () => (
446
- <DemoRow title="文本域输入框">
447
- <div><Input v-model={state.val} width="300"/><Button label="normal input"/></div>
448
- <br/>
449
- <br/>
450
- <div>
451
- <Input v-model={state.val} width="300" textarea/>
452
- <Button label="textarea"/>
453
- </div>
454
- <br/>
455
- <br/>
456
- <div>
457
- <Input v-model={state.val} width="300" textarea maxHeight="200"/>
458
- <Button label="max height 200px"/>
459
- </div>
460
- <br/>
461
- <br/>
462
- <div>
463
- <Input v-model={state.val} width="300" textarea height="200"/>
464
- <Button label="height 200px"/>
465
- </div>
466
- <br/>
467
- <br/>
468
- <div>
469
- <Input v-model={state.val} width="300" textarea minHeight="100"/>
470
- <Button label="min height 100px"/>
471
- </div>
472
- </DemoRow>
473
- );
474
- });
475
-
476
- export const DemoPlaceholder = designPage(() => () => (
477
- <>
478
- <DemoRow title="placeholder">
479
- <div><Input placeholder="Placeholder"/></div>
480
- <br/>
481
- <br/>
482
- <div><Input placeholder="Placeholder" multiple/></div>
483
- <br/>
484
- <br/>
485
- <div><Input placeholder="Placeholder" textarea/></div>
486
- <br/>
487
- <br/>
488
- </DemoRow>
489
- </>
490
- ));
491
-
492
-
493
- export const DemoMaxLength = designPage(() => () => (
494
- <>
495
- <DemoRow title="最大文本长度">
496
- <div><Input placeholder="Placeholder" width="300" maxLength={100}/></div>
497
- <br/>
498
- <br/>
499
- <div><Input placeholder="Placeholder" width="300" multiple maxLength={3}/></div>
500
- <br/>
501
- <br/>
502
- <div><Input placeholder="Placeholder" width="300" textarea maxLength={100}/></div>
503
- <br/>
504
- <br/>
505
- </DemoRow>
506
- </>
507
- ));
508
-
509
-
510
- export const DemoVerifyCode = designPage(() => {
511
-
512
- const state = reactive({
513
- code: null
514
- });
515
-
516
- const sendVerifyCodeRequest = async () => {
517
- await delay(1000);
518
- $notice.primary('已经发送验证码,请注意查收!');
519
- };
520
-
521
- const getVerifyCode = (() => {
522
- const state = reactive({ count: null as number | null, loading: false });
523
- return Object.assign(async () => {
524
- if (!!state.loading || !!state.count) {
525
- return;
526
- }
527
- state.loading = true;
528
- await sendVerifyCodeRequest();
529
- state.loading = false;
530
- state.count = 60;
531
- const timer = setInterval(() => {
532
- if (!!state.count) {
533
- state.count--;
534
- }
535
- if (state.count === 0) {
536
- state.count = null;
537
- clearInterval(timer);
538
- }
539
- }, 1000);
540
- }, { state });
541
- })();
542
-
543
- return () => (
544
- <>
545
- <DemoRow title="验证码示例">
546
- <Input v-model={state.code} placeholder="请输入验证码" width="300" maxLength={6}>
547
- {{
548
- suffix: () => (
549
- <span onClick={getVerifyCode}>
550
- {getVerifyCode.state.loading ? <Loading/> : (
551
- <span>{!!getVerifyCode.state.count ? getVerifyCode.state.count + 's' :
552
- <span style={{ cursor: 'pointer' }}>获取验证码</span>}</span>
553
- )}
554
- </span>
555
- )
556
- }}
557
- </Input>
558
- </DemoRow>
559
- </>
560
- );
561
- });
562
-
563
- export const DemoGroup = designPage(() => () => (
564
- <DemoRow title="输入框组">
565
- <InputGroup>
566
- <Input placeholder="Placeholder" suffixIcon="pi-search" modelValue="hello world"/>
567
- <Button label="Submit" mode="fill"/>
568
- </InputGroup>
569
- <br/>
570
- <br/>
571
- <InputGroup>
572
- <Input placeholder="Placeholder" multiple suffixIcon="pi-search" modelValue={['hello', 'world']}/>
573
- <Button label="Submit" mode="fill"/>
574
- </InputGroup>
575
- <br/>
576
- <br/>
577
- <InputGroup>
578
- <Input placeholder="Placeholder" suffixIcon="pi-search" modelValue="hello world" fixedWidth width={120}/>
579
- <Input placeholder="Placeholder" suffixIcon="pi-search" modelValue="hello world"/>
580
- <Button label="Submit" mode="fill"/>
581
- </InputGroup>
582
- </DemoRow>
583
- ));
584
-
585
-
586
- export const DemoNotEditable = designPage(() => {
587
-
588
- return () => (
589
- <DemoRow title="禁用">
590
- <p>input</p>
591
- <Input placeholder="Placeholder" disabled/>
592
- <br/>
593
- <br/>
594
- <Input placeholder="Placeholder" disabled modelValue="hello world"/>
595
- <br/>
596
- <br/>
597
-
598
- <p>multiple input</p>
599
- <Input placeholder="Placeholder" multiple disabled/>
600
- <br/>
601
- <br/>
602
- <Input placeholder="Placeholder" multiple disabled modelValue={['hello', 'world']}/>
603
- <br/>
604
- <br/>
605
-
606
- <p>textarea</p>
607
- <Input placeholder="Placeholder" disabled textarea/>
608
- <br/>
609
- <br/>
610
- <Input placeholder="Placeholder" disabled modelValue="hello world" textarea/>
611
- <br/>
612
- <br/>
613
-
614
- <p>input group</p>
615
- <InputGroup disabled>
616
- <Input placeholder="Placeholder" suffixIcon="pi-search" modelValue="hello world"/>
617
- <Button label="Submit" mode="fill"/>
618
- </InputGroup>
619
- </DemoRow>
620
- );
621
- });
622
-
623
-
624
- export const DemoReadonly = designPage(() => {
625
-
626
- return () => (
627
- <DemoRow title="只读">
628
- <p>input</p>
629
- <Input placeholder="Placeholder" readonly/>
630
- <br/>
631
- <br/>
632
- <Input placeholder="Placeholder" readonly modelValue="hello world"/>
633
- <br/>
634
- <br/>
635
-
636
- <p>multiple input</p>
637
- <Input placeholder="Placeholder" multiple readonly/>
638
- <br/>
639
- <br/>
640
- <Input placeholder="Placeholder" multiple readonly modelValue={['hello', 'world']}/>
641
- <br/>
642
- <br/>
643
-
644
- <p>textarea</p>
645
- <Input placeholder="Placeholder" readonly textarea/>
646
- <br/>
647
- <br/>
648
- <Input placeholder="Placeholder" readonly modelValue="hello world" textarea/>
649
- <br/>
650
- <br/>
651
-
652
- <p>input group</p>
653
- <InputGroup readonly>
654
- <Input placeholder="Placeholder" suffixIcon="pi-search" modelValue="hello world"/>
655
- <Button label="Submit" mode="fill"/>
656
- </InputGroup>
657
- </DemoRow>
658
- );
659
- });
660
-
661
- export const demoSwitchInputType = designPage(() => {
662
-
663
- const state = reactive({
664
- val: 'hello world' as any,
665
- type: 'input',
666
- });
667
-
668
- return () => (
669
- <DemoRow title="基本用法">
670
- <SegmentGroup v-model={state.type} onUpdateModelValue={((val: any) => {
671
- if (val === 'multiple') {
672
- state.val = ['hello'];
673
- } else {
674
- state.val = 'hello world';
675
- }
676
- }) as any}>
677
- <Segment label="input" val="input"/>
678
- <Segment label="textarea" val="textarea"/>
679
- <Segment label="multiple" val="multiple"/>
680
- </SegmentGroup>
681
- <Input v-model={state.val} width="200" textarea={state.type === 'textarea'} multiple={state.type === 'multiple'}/>
682
- {JSON.stringify(state.val)}
683
- </DemoRow>
684
- );
685
- });
686
-
687
- export const demoSuggestion = designPage(() => {
688
-
689
- const state = reactive({
690
- val: null as any,
691
- multipleValue: null as any,
692
- multipleSearchText: null as any,
693
- textarea: '',
694
- });
695
-
696
- const suggestion1 = computed(() => {
697
- const val = state.val?.trim();
698
- return !!val && !!val.length ? [
699
- `${val}`,
700
- `${val}${val}`,
701
- `${val}${val}${val}`,
702
- ] : [
703
- '重庆小面',
704
- '云南过桥米线',
705
- '陕西肉夹馍',
706
- '广东肠粉',
707
- '柳州螺蛳粉',
708
- ];
709
- });
710
-
711
- const suggestion2 = computed(() => {
712
- const val = state.multipleSearchText?.trim();
713
- return !!val && !!val.length ? [
714
- `${val}`,
715
- `${val}${val}`,
716
- `${val}${val}${val}`,
717
- ] : [
718
- '重庆小面',
719
- '云南过桥米线',
720
- '陕西肉夹馍',
721
- '广东肠粉',
722
- '柳州螺蛳粉',
723
- ];
724
- });
725
-
726
- const suggestion3 = computed(() => {
727
- const val = state.textarea?.trim();
728
- return !!val && !!val.length ? [
729
- `${val}`,
730
- `${val}${val}`,
731
- `${val}${val}${val}`,
732
- ] : [
733
- '重庆小面',
734
- '云南过桥米线',
735
- '陕西肉夹馍',
736
- '广东肠粉',
737
- '柳州螺蛳粉',
738
- ];
739
- });
740
-
741
- return () => (
742
- <DemoRow title="推荐输入(自动补全)">
743
- <DemoLine title="普通输入框">
744
- <Input v-model={state.val} width="200" suggestion={suggestion1.value}/> {state.val}
745
- </DemoLine>
746
- <DemoLine title="多值输入框">
747
- <Input v-model={state.multipleValue} width="200" suggestion={suggestion2.value} multiple v-model:multipleText={state.multipleSearchText}/> {state.multipleValue}
748
- </DemoLine>
749
- <DemoLine title="多行输入框">
750
- <Input v-model={state.textarea} width="200" suggestion={suggestion3.value} textarea/> {state.textarea}
751
- </DemoLine>
752
- </DemoRow>
753
- );
754
- });
755
-
756
- export const demoSuggestion2 = designPage(() => {
757
- const state = reactive({
758
- val: null as any,
759
- multipleValue: null as any,
760
- multipleSearchText: null as any,
761
- textarea: '',
762
- });
763
-
764
- const suggestion1 = computed(() => {
765
- let val = state.val?.trim();
766
- if (!val) {
767
- return [];
768
- }
769
- val = val.split('@')[0];
770
- if (!val) {
771
- return [];
772
- }
773
- return [
774
- `${val}@gmail.com`,
775
- `${val}@aliyun.com`,
776
- `${val}@qq.com`,
777
- `${val}@foxmail.com`,
778
- `${val}@163.com`,
779
- ];
780
- });
781
-
782
-
783
- return () => (
784
- <DemoRow title="邮箱自动补全">
785
- <DemoLine title="普通输入框">
786
- <Input v-model={state.val} width="200" suggestion={suggestion1.value}/> {state.val}
787
- </DemoLine>
788
- </DemoRow>
789
- );
790
- });