@teammodlr/ui-kit 3.0.0-beta.9 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/cardcontextmenu/CardContextMenu.vue.d.ts +4 -2
- package/lib/components/checkbox/Checkbox.vue.d.ts +4 -4
- package/lib/components/clearbutton/ClearButton.vue.d.ts +9 -0
- package/lib/components/clearbutton/style/ClearButton.css.d.ts +2 -0
- package/lib/components/clearbutton/style/index.d.ts +1 -0
- package/lib/components/colorpicker/ColorPicker.vue.d.ts +6 -4
- package/lib/components/colorpicker/style/ColorPicker.css.d.ts +1 -0
- package/lib/components/dialog/Dialog.vue.d.ts +14 -6
- package/lib/components/dialog/style/Dialog.css.d.ts +2 -0
- package/lib/components/drawer/Drawer.vue.d.ts +146 -0
- package/lib/components/drawer/style/Drawer.css.d.ts +33 -0
- package/lib/components/drawer/style/index.d.ts +1 -0
- package/lib/components/dropdown/Dropdown.vue.d.ts +4 -2
- package/lib/components/form/Form.vue.d.ts +4 -2
- package/lib/components/hovercard/HoverCard.vue.d.ts +124 -0
- package/lib/components/hovercard/style/HoverCard.css.d.ts +3 -0
- package/lib/components/hovercard/style/index.d.ts +1 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/input/Input.vue.d.ts +20 -5
- package/lib/components/input/style/Input.css.d.ts +4 -0
- package/lib/components/modal/Modal.vue.d.ts +11 -4
- package/lib/components/pagination/Pagination.vue.d.ts +6 -3
- package/lib/components/paneldialog/PanelDialog.vue.d.ts +175 -0
- package/lib/components/paneldialog/style/PanelDialog.css.d.ts +8 -0
- package/lib/components/paneldialog/style/index.d.ts +1 -0
- package/lib/components/popover/Popover.vue.d.ts +28 -2
- package/lib/components/radio/Radio.vue.d.ts +5 -5
- package/lib/components/radiobutton/RadioButton.vue.d.ts +4 -4
- package/lib/components/radiobuttongroup/RadioButtonGroup.vue.d.ts +4 -2
- package/lib/components/select/Select.vue.d.ts +94 -91
- package/lib/components/select/style/Select.css.d.ts +9 -1
- package/lib/components/slider/Slider.vue.d.ts +6 -3
- package/lib/components/switch/Switch.vue.d.ts +4 -4
- package/lib/components/tab/Tab.vue.d.ts +10 -2
- package/lib/components/tab/TabGroup.vue.d.ts +6 -3
- package/lib/components/table/Table.vue.d.ts +4 -2
- package/lib/components/textarea/Textarea.vue.d.ts +16 -5
- package/lib/components/textarea/style/Textarea.css.d.ts +2 -0
- package/lib/components/tree/Tree.vue.d.ts +6 -3
- package/lib/composables/useInput.d.ts +9 -2
- package/lib/index.cjs.js +3 -3
- package/lib/index.es.js +8526 -6393
- package/lib/style.css +1 -1
- package/lib/tsconfig.app.tsbuildinfo +1 -0
- package/lib/tsconfig.vitest.tsbuildinfo +1 -0
- package/package.json +7 -4
- package/src/components/cardcontextmenu/CardContextMenu.vue +3 -1
- package/src/components/cardcontextmenu/style/Dropdown.css.ts +7 -0
- package/src/components/clearbutton/ClearButton.vue +41 -0
- package/src/components/clearbutton/style/ClearButton.css.ts +37 -0
- package/src/components/clearbutton/style/index.ts +1 -0
- package/src/components/colorpicker/ColorPicker.vue +12 -12
- package/src/components/colorpicker/examples/basic.vue +8 -17
- package/src/components/colorpicker/style/ColorPicker.css.ts +6 -1
- package/src/components/dialog/Dialog.vue +12 -6
- package/src/components/dialog/style/Dialog.css.ts +30 -0
- package/src/components/drawer/Drawer.vue +280 -0
- package/src/components/drawer/examples/basic.vue +15 -0
- package/src/components/drawer/examples/custom-title.vue +21 -0
- package/src/components/drawer/examples/index.stories.ts +24 -0
- package/src/components/drawer/examples/index.ts +7 -0
- package/src/components/drawer/examples/no-mask.vue +15 -0
- package/src/components/drawer/examples/no-outside-close.vue +15 -0
- package/src/components/drawer/examples/placements.vue +28 -0
- package/src/components/drawer/examples/with-footer.vue +21 -0
- package/src/components/drawer/examples/with-trigger.vue +13 -0
- package/src/components/drawer/style/Drawer.css.ts +208 -0
- package/src/components/drawer/style/index.ts +1 -0
- package/src/components/dropdown/Dropdown.vue +4 -2
- package/src/components/form/Form.vue +3 -3
- package/src/components/hovercard/HoverCard.vue +165 -0
- package/src/components/hovercard/style/HoverCard.css.ts +175 -0
- package/src/components/hovercard/style/index.ts +1 -0
- package/src/components/index.ts +3 -0
- package/src/components/input/Input.vue +52 -4
- package/src/components/input/examples/clearable.vue +18 -0
- package/src/components/input/examples/index.stories.ts +3 -1
- package/src/components/input/examples/index.ts +1 -0
- package/src/components/input/style/Input.css.ts +19 -0
- package/src/components/messageprovider/MessageProvider.vue +33 -7
- package/src/components/modal/Modal.vue +28 -11
- package/src/components/pagination/Pagination.vue +4 -1
- package/src/components/paneldialog/PanelDialog.vue +509 -0
- package/src/components/paneldialog/examples/basic.vue +36 -0
- package/src/components/paneldialog/examples/index.stories.ts +22 -0
- package/src/components/paneldialog/examples/index.ts +2 -0
- package/src/components/paneldialog/examples/modal.vue +31 -0
- package/src/components/paneldialog/style/PanelDialog.css.ts +90 -0
- package/src/components/paneldialog/style/index.ts +1 -0
- package/src/components/popover/Popover.vue +9 -2
- package/src/components/radiobuttongroup/RadioButtonGroup.vue +3 -1
- package/src/components/select/Select.vue +211 -111
- package/src/components/select/examples/clearable.vue +18 -0
- package/src/components/select/examples/fill.vue +52 -0
- package/src/components/select/examples/index.stories.ts +4 -1
- package/src/components/select/examples/index.ts +3 -0
- package/src/components/select/examples/remote.vue +54 -0
- package/src/components/select/style/Select.css.ts +140 -24
- package/src/components/slider/Slider.vue +4 -1
- package/src/components/tab/Tab.vue +4 -2
- package/src/components/tab/TabGroup.vue +4 -4
- package/src/components/tab/style/Tab.css.ts +6 -0
- package/src/components/table/Table.vue +3 -3
- package/src/components/textarea/Textarea.vue +40 -4
- package/src/components/textarea/examples/clearable.vue +16 -0
- package/src/components/textarea/examples/index.stories.ts +2 -1
- package/src/components/textarea/examples/index.ts +1 -0
- package/src/components/textarea/style/Textarea.css.ts +10 -0
- package/src/components/tree/Tree.vue +4 -1
- package/src/composables/useInput.ts +10 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MSelect from '../Select.vue';
|
|
2
|
-
import { MSelectBasic, MSelectSearchable, MSelectMultiple } from './index';
|
|
2
|
+
import { MSelectBasic, MSelectSearchable, MSelectMultiple, MSelectFill, MSelectClearable, MSelectRemote } from './index';
|
|
3
3
|
|
|
4
4
|
import { createStory, sizeArgType } from '../../../__storybook__';
|
|
5
5
|
|
|
@@ -14,3 +14,6 @@ export default {
|
|
|
14
14
|
export const Basic = createStory(MSelectBasic);
|
|
15
15
|
export const Searchable = createStory(MSelectSearchable);
|
|
16
16
|
export const Multiple = createStory(MSelectMultiple);
|
|
17
|
+
export const Fill = createStory(MSelectFill);
|
|
18
|
+
export const Clearable = createStory(MSelectClearable);
|
|
19
|
+
export const Remote = createStory(MSelectRemote);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as MSelectBasic } from './basic.vue';
|
|
2
2
|
export { default as MSelectSearchable } from './searchable.vue';
|
|
3
3
|
export { default as MSelectMultiple } from './multiple.vue';
|
|
4
|
+
export { default as MSelectFill } from './fill.vue';
|
|
5
|
+
export { default as MSelectClearable } from './clearable.vue';
|
|
6
|
+
export { default as MSelectRemote } from './remote.vue';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MSelect
|
|
3
|
+
v-model="value"
|
|
4
|
+
:options="options"
|
|
5
|
+
:option-value="'id'"
|
|
6
|
+
:option-label="'name'"
|
|
7
|
+
:loading="loading"
|
|
8
|
+
searchable
|
|
9
|
+
remote
|
|
10
|
+
@search="onSearch"
|
|
11
|
+
@on-open="onSearch('')"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { ref } from "vue";
|
|
17
|
+
|
|
18
|
+
const everything = Array.from({ length: 500 }, (_, i) => ({
|
|
19
|
+
id: i,
|
|
20
|
+
name: `Option ${i + 1}`
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
// Stand-in for a server call
|
|
24
|
+
function fetchOptions(query: string): Promise<typeof everything> {
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
resolve(
|
|
28
|
+
everything
|
|
29
|
+
.filter(o => o.name.toLowerCase().includes(query.toLowerCase()))
|
|
30
|
+
.slice(0, 20)
|
|
31
|
+
);
|
|
32
|
+
}, 500);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const value = ref();
|
|
37
|
+
const options = ref<typeof everything>([]);
|
|
38
|
+
const loading = ref(false);
|
|
39
|
+
let latest = 0;
|
|
40
|
+
|
|
41
|
+
async function onSearch(query: string) {
|
|
42
|
+
const request = ++latest;
|
|
43
|
+
loading.value = true;
|
|
44
|
+
const result = await fetchOptions(query);
|
|
45
|
+
|
|
46
|
+
// Ignore stale responses
|
|
47
|
+
if (request !== latest) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
options.value = result;
|
|
52
|
+
loading.value = false;
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from '@vanilla-extract/css';
|
|
7
7
|
import { themeVars } from '../../../styles/theme.css';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const heights = {
|
|
10
10
|
xs: '26px',
|
|
11
11
|
sm: '30px',
|
|
12
12
|
md: '38px',
|
|
@@ -42,7 +42,7 @@ export const wrapper = style({
|
|
|
42
42
|
|
|
43
43
|
export const base = style({
|
|
44
44
|
vars: {
|
|
45
|
-
[vars.height]:
|
|
45
|
+
[vars.height]: heights.md,
|
|
46
46
|
[vars.radius]: borderRadiuses.md,
|
|
47
47
|
[vars.paddingX]: themeVars.space[2],
|
|
48
48
|
[vars.paddingY]: themeVars.space[0],
|
|
@@ -189,8 +189,7 @@ export const menu = style({
|
|
|
189
189
|
borderRadius: '4px',
|
|
190
190
|
border: `1px solid ${themeVars.color.gray[200]}`,
|
|
191
191
|
boxShadow: themeVars.shadow.md,
|
|
192
|
-
|
|
193
|
-
overflowY: 'auto'
|
|
192
|
+
overflow: 'hidden'
|
|
194
193
|
});
|
|
195
194
|
|
|
196
195
|
export const placeholder = style({
|
|
@@ -199,11 +198,7 @@ export const placeholder = style({
|
|
|
199
198
|
});
|
|
200
199
|
|
|
201
200
|
export const search = style({
|
|
202
|
-
// padding: `${themeVars.space[1]} ${themeVars.space[1]} 0`,
|
|
203
201
|
backgroundColor: '#FFFFFF',
|
|
204
|
-
position: 'sticky',
|
|
205
|
-
top: 0,
|
|
206
|
-
zIndex: 1,
|
|
207
202
|
borderBottom: `1px solid ${themeVars.color.gray[200]}`,
|
|
208
203
|
display: 'flex'
|
|
209
204
|
});
|
|
@@ -219,10 +214,7 @@ export const searchInput = style({
|
|
|
219
214
|
});
|
|
220
215
|
|
|
221
216
|
export const options = style({
|
|
222
|
-
|
|
223
|
-
display: 'flex',
|
|
224
|
-
flexDirection: 'column',
|
|
225
|
-
gap: themeVars.space[0.5]
|
|
217
|
+
overflow: 'hidden'
|
|
226
218
|
});
|
|
227
219
|
|
|
228
220
|
export const option = style({
|
|
@@ -234,10 +226,7 @@ export const option = style({
|
|
|
234
226
|
display: 'flex',
|
|
235
227
|
alignItems: 'center',
|
|
236
228
|
cursor: 'pointer',
|
|
237
|
-
|
|
238
|
-
fontSize: themeVars.fontSize.base,
|
|
239
|
-
paddingBlock: themeVars.space['1.5'],
|
|
240
|
-
paddingInline: themeVars.space['3'],
|
|
229
|
+
marginBottom: '2px',
|
|
241
230
|
gap: themeVars.space[2],
|
|
242
231
|
color: vars.optionColor,
|
|
243
232
|
transition: 'background-color 0.05s ease-in-out',
|
|
@@ -280,6 +269,39 @@ export const optionSelected = style({
|
|
|
280
269
|
|
|
281
270
|
export const optionLabel = style({});
|
|
282
271
|
|
|
272
|
+
export const optionSizes = styleVariants({
|
|
273
|
+
xs: {
|
|
274
|
+
minHeight: '28px',
|
|
275
|
+
fontSize: themeVars.fontSize.small,
|
|
276
|
+
paddingBlock: themeVars.space['1'],
|
|
277
|
+
paddingInline: themeVars.space['2']
|
|
278
|
+
},
|
|
279
|
+
sm: {
|
|
280
|
+
minHeight: '30px',
|
|
281
|
+
fontSize: themeVars.fontSize.base,
|
|
282
|
+
paddingBlock: themeVars.space['1'],
|
|
283
|
+
paddingInline: themeVars.space['2.5']
|
|
284
|
+
},
|
|
285
|
+
md: {
|
|
286
|
+
minHeight: '36px',
|
|
287
|
+
fontSize: themeVars.fontSize.base,
|
|
288
|
+
paddingBlock: themeVars.space['1.5'],
|
|
289
|
+
paddingInline: themeVars.space['3']
|
|
290
|
+
},
|
|
291
|
+
lg: {
|
|
292
|
+
minHeight: '40px',
|
|
293
|
+
fontSize: themeVars.fontSize.large,
|
|
294
|
+
paddingBlock: themeVars.space['2'],
|
|
295
|
+
paddingInline: themeVars.space['3']
|
|
296
|
+
},
|
|
297
|
+
xl: {
|
|
298
|
+
minHeight: '44px',
|
|
299
|
+
fontSize: themeVars.fontSize.large,
|
|
300
|
+
paddingBlock: themeVars.space['2.5'],
|
|
301
|
+
paddingInline: themeVars.space['3']
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
283
305
|
export const checkAll = style({
|
|
284
306
|
display: 'flex',
|
|
285
307
|
alignItems: 'center',
|
|
@@ -357,13 +379,15 @@ export const noResults = style({
|
|
|
357
379
|
fontSize: themeVars.fontSize.small
|
|
358
380
|
});
|
|
359
381
|
|
|
360
|
-
export const
|
|
361
|
-
width: themeVars.space[4],
|
|
362
|
-
height: themeVars.space[4],
|
|
382
|
+
export const clear = style({
|
|
363
383
|
position: 'absolute',
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
384
|
+
top: '50%',
|
|
385
|
+
right: '2.25rem',
|
|
386
|
+
transform: 'translateY(-50%)'
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
export const hasClear = style({
|
|
390
|
+
paddingRight: '3.75rem'
|
|
367
391
|
});
|
|
368
392
|
|
|
369
393
|
export const arrow = style({
|
|
@@ -371,12 +395,104 @@ export const arrow = style({
|
|
|
371
395
|
height: themeVars.space[4],
|
|
372
396
|
position: 'absolute',
|
|
373
397
|
right: themeVars.space[3],
|
|
374
|
-
top:
|
|
398
|
+
top: '50%',
|
|
399
|
+
transform: 'translateY(-50%)',
|
|
375
400
|
display: 'flex',
|
|
376
401
|
color: themeVars.color.gray[500],
|
|
377
402
|
transition: 'transform 0.3s ease',
|
|
378
403
|
});
|
|
379
404
|
|
|
380
405
|
export const arrowOpen = style({
|
|
381
|
-
transform: 'rotate(180deg)',
|
|
406
|
+
transform: 'translateY(-50%) rotate(180deg)',
|
|
382
407
|
})
|
|
408
|
+
|
|
409
|
+
export const fillRoot = style({
|
|
410
|
+
display: 'flex',
|
|
411
|
+
flexDirection: 'column',
|
|
412
|
+
height: '100%',
|
|
413
|
+
width: '100%'
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
export const fill = style({
|
|
417
|
+
flexGrow: 1,
|
|
418
|
+
width: '100%',
|
|
419
|
+
minHeight: 0
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
export const sizes = styleVariants({
|
|
423
|
+
xs: {
|
|
424
|
+
vars: {
|
|
425
|
+
[vars.height]: heights.xs,
|
|
426
|
+
[vars.radius]: borderRadiuses.xs,
|
|
427
|
+
[vars.paddingX]: themeVars.space[1]
|
|
428
|
+
},
|
|
429
|
+
fontSize: themeVars.fontSize.small
|
|
430
|
+
},
|
|
431
|
+
sm: {
|
|
432
|
+
vars: {
|
|
433
|
+
[vars.height]: heights.sm,
|
|
434
|
+
[vars.radius]: borderRadiuses.sm,
|
|
435
|
+
[vars.paddingX]: themeVars.space[1.5]
|
|
436
|
+
},
|
|
437
|
+
fontSize: themeVars.fontSize.small
|
|
438
|
+
},
|
|
439
|
+
md: {
|
|
440
|
+
vars: {
|
|
441
|
+
[vars.height]: heights.md,
|
|
442
|
+
[vars.radius]: borderRadiuses.md
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
lg: {
|
|
446
|
+
vars: {
|
|
447
|
+
[vars.height]: heights.lg,
|
|
448
|
+
[vars.radius]: borderRadiuses.lg,
|
|
449
|
+
[vars.paddingX]: themeVars.space[2.5]
|
|
450
|
+
},
|
|
451
|
+
fontSize: themeVars.fontSize.large
|
|
452
|
+
},
|
|
453
|
+
xl: {
|
|
454
|
+
vars: {
|
|
455
|
+
[vars.height]: heights.xl,
|
|
456
|
+
[vars.radius]: borderRadiuses.xl,
|
|
457
|
+
[vars.paddingX]: themeVars.space[3]
|
|
458
|
+
},
|
|
459
|
+
fontSize: themeVars.fontSize.large
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
export const fillBase = style({
|
|
464
|
+
minHeight: 'unset',
|
|
465
|
+
height: '100%',
|
|
466
|
+
lineHeight: 'normal',
|
|
467
|
+
display: 'flex',
|
|
468
|
+
alignItems: 'center',
|
|
469
|
+
overflow: 'hidden',
|
|
470
|
+
paddingRight: '2rem'
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
export const fillLabel = style({
|
|
474
|
+
overflow: 'hidden',
|
|
475
|
+
whiteSpace: 'nowrap',
|
|
476
|
+
textOverflow: 'ellipsis',
|
|
477
|
+
flex: 1,
|
|
478
|
+
minWidth: 0
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
export const noBorder = style({
|
|
482
|
+
vars: {
|
|
483
|
+
[vars.borderColor]: 'transparent'
|
|
484
|
+
},
|
|
485
|
+
borderRadius: 0,
|
|
486
|
+
boxShadow: 'none',
|
|
487
|
+
':hover': {
|
|
488
|
+
vars: {
|
|
489
|
+
[vars.borderColor]: 'transparent'
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
':focus': {
|
|
493
|
+
vars: {
|
|
494
|
+
[vars.borderColor]: 'transparent'
|
|
495
|
+
},
|
|
496
|
+
boxShadow: 'none'
|
|
497
|
+
}
|
|
498
|
+
});
|
|
@@ -29,7 +29,10 @@ export default defineComponent({
|
|
|
29
29
|
default: '',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
-
emits:
|
|
32
|
+
emits: {
|
|
33
|
+
'update:modelValue': (_value: number) => true,
|
|
34
|
+
change: (_value: number) => true
|
|
35
|
+
},
|
|
33
36
|
setup(props, { emit }) {
|
|
34
37
|
const slider = ref<HTMLElement | null>(null);
|
|
35
38
|
const dragging = ref(false);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
<teleport v-if="teleportTo && hasContent" :to="teleportTo">
|
|
16
16
|
<TabsContent :value="computedValue" as-child>
|
|
17
|
-
<div>
|
|
17
|
+
<div style="outline: none">
|
|
18
18
|
<slot />
|
|
19
19
|
</div>
|
|
20
20
|
</TabsContent>
|
|
@@ -48,7 +48,9 @@ export default defineComponent({
|
|
|
48
48
|
default: false
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
emits:
|
|
51
|
+
emits: {
|
|
52
|
+
onClose: (_tab: { value: any; label: any }) => true
|
|
53
|
+
},
|
|
52
54
|
setup(props, { attrs, slots }) {
|
|
53
55
|
const computedValue = computed(() => props.value);
|
|
54
56
|
const computedLabel = computed(() => props.label || props.value);
|
|
@@ -53,10 +53,10 @@ export default defineComponent({
|
|
|
53
53
|
validator: (value: string) => ['base', 'card'].includes(value)
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
emits:
|
|
57
|
-
'update:modelValue',
|
|
58
|
-
'update:selected'
|
|
59
|
-
|
|
56
|
+
emits: {
|
|
57
|
+
'update:modelValue': (_tab: any) => true,
|
|
58
|
+
'update:selected': (_tab: any) => true
|
|
59
|
+
},
|
|
60
60
|
setup(props, { emit }) {
|
|
61
61
|
const wrapperRef = ref<HTMLElement>();
|
|
62
62
|
const tabsRef = ref<HTMLElement>();
|
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
:value="textareaValue"
|
|
18
18
|
:readonly="readonly"
|
|
19
19
|
v-on="inputListeners"
|
|
20
|
+
@input="onNativeInput"
|
|
20
21
|
:class="inputComputedClasses"
|
|
21
22
|
v-bind="$attrs"
|
|
22
23
|
:disabled="disabled || loading"
|
|
23
24
|
:aria-disabled="disabled ? 'true' : 'false'"
|
|
24
25
|
:aria-labelledby="`${id}-label`"
|
|
25
26
|
/>
|
|
27
|
+
<MClearButton v-if="showClear" :class="style.clear" @clear="onClear" />
|
|
26
28
|
</div>
|
|
27
29
|
<div v-if="inputError" :class="style.errorMessage">
|
|
28
30
|
{{ inputError }}
|
|
@@ -37,14 +39,17 @@ import {
|
|
|
37
39
|
defineComponent,
|
|
38
40
|
ref,
|
|
39
41
|
computed,
|
|
40
|
-
toRef
|
|
42
|
+
toRef,
|
|
43
|
+
watch
|
|
41
44
|
} from "vue";
|
|
42
45
|
import { useInput } from "../../composables/useInput";
|
|
43
46
|
import { useInteractive } from "../../composables/useInteractive";
|
|
47
|
+
import MClearButton from '../clearbutton/ClearButton.vue';
|
|
44
48
|
import * as style from './style';
|
|
45
49
|
|
|
46
50
|
export default defineComponent({
|
|
47
51
|
name: 'MTextArea',
|
|
52
|
+
components: { MClearButton },
|
|
48
53
|
props: {
|
|
49
54
|
...useInput.props(),
|
|
50
55
|
...useInteractive.props(),
|
|
@@ -80,15 +85,19 @@ export default defineComponent({
|
|
|
80
85
|
default: false
|
|
81
86
|
},
|
|
82
87
|
error: {
|
|
83
|
-
type: String
|
|
88
|
+
type: String as PropType<string | null>,
|
|
84
89
|
default: ''
|
|
85
90
|
},
|
|
86
91
|
height: {
|
|
87
92
|
type: Number,
|
|
88
93
|
default: 64
|
|
89
94
|
},
|
|
95
|
+
clearable: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false
|
|
98
|
+
},
|
|
90
99
|
},
|
|
91
|
-
emits: useInput.emits(),
|
|
100
|
+
emits: [...useInput.emits(), 'clear'],
|
|
92
101
|
setup(props, { emit, expose }) {
|
|
93
102
|
const element = ref<HTMLTextAreaElement | null>(null);
|
|
94
103
|
const { focus, blur } = useInteractive(element);
|
|
@@ -136,6 +145,7 @@ export default defineComponent({
|
|
|
136
145
|
[style.block]: props.block,
|
|
137
146
|
[style.disabled]: disabled.value || loading.value,
|
|
138
147
|
[style.error]: inputError.value,
|
|
148
|
+
[style.hasClear]: props.clearable,
|
|
139
149
|
}
|
|
140
150
|
];
|
|
141
151
|
});
|
|
@@ -144,12 +154,36 @@ export default defineComponent({
|
|
|
144
154
|
return formError.value || props.error;
|
|
145
155
|
});
|
|
146
156
|
|
|
157
|
+
// Tracks typed text so clearable works without v-model
|
|
158
|
+
const internalValue = ref('');
|
|
159
|
+
watch(() => props.modelValue, value => {
|
|
160
|
+
internalValue.value = value == null ? '' : String(value);
|
|
161
|
+
}, { immediate: true });
|
|
162
|
+
|
|
147
163
|
const textareaValue = computed(() => {
|
|
148
|
-
|
|
164
|
+
if (props.modelValue !== undefined) {
|
|
165
|
+
return props.modelValue == null ? '' : String(props.modelValue);
|
|
166
|
+
}
|
|
167
|
+
return internalValue.value;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const onNativeInput = (event: Event) => {
|
|
171
|
+
internalValue.value = (event.target as HTMLTextAreaElement).value;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const showClear = computed(() => {
|
|
175
|
+
return props.clearable
|
|
176
|
+
&& !disabled.value
|
|
177
|
+
&& !loading.value
|
|
178
|
+
&& !readonly.value
|
|
179
|
+
&& textareaValue.value !== '';
|
|
149
180
|
});
|
|
150
181
|
|
|
151
182
|
const onClear = () => {
|
|
183
|
+
internalValue.value = '';
|
|
152
184
|
emit('update:modelValue', '');
|
|
185
|
+
emit('clear');
|
|
186
|
+
focus();
|
|
153
187
|
};
|
|
154
188
|
|
|
155
189
|
expose({
|
|
@@ -171,6 +205,8 @@ export default defineComponent({
|
|
|
171
205
|
textareaValue,
|
|
172
206
|
inputError,
|
|
173
207
|
style,
|
|
208
|
+
showClear,
|
|
209
|
+
onNativeInput,
|
|
174
210
|
|
|
175
211
|
onClear,
|
|
176
212
|
validate,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MTextArea
|
|
3
|
+
v-model="value"
|
|
4
|
+
label="Some Text"
|
|
5
|
+
name="text"
|
|
6
|
+
placeholder="Some text placeholder"
|
|
7
|
+
:height="128"
|
|
8
|
+
clearable
|
|
9
|
+
/>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { ref } from 'vue';
|
|
14
|
+
|
|
15
|
+
const value = ref('Clear me');
|
|
16
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MTextarea from '../Textarea.vue';
|
|
2
|
-
import { MTextareaBasic } from './index';
|
|
2
|
+
import { MTextareaBasic, MTextareaClearable } from './index';
|
|
3
3
|
|
|
4
4
|
import { createStory, sizeArgType } from '../../../__storybook__';
|
|
5
5
|
|
|
@@ -12,3 +12,4 @@ export default {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const Basic = createStory(MTextareaBasic);
|
|
15
|
+
export const Clearable = createStory(MTextareaClearable);
|
|
@@ -144,6 +144,16 @@ export const disabled = style({
|
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
+
export const hasClear = style({
|
|
148
|
+
paddingRight: '1.75rem'
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export const clear = style({
|
|
152
|
+
position: 'absolute',
|
|
153
|
+
top: themeVars.space[1],
|
|
154
|
+
right: themeVars.space[1]
|
|
155
|
+
});
|
|
156
|
+
|
|
147
157
|
export const label = style({
|
|
148
158
|
fontWeight: '500',
|
|
149
159
|
display: 'inline-block',
|
|
@@ -22,7 +22,10 @@ export default defineComponent({
|
|
|
22
22
|
components: { TreeNode },
|
|
23
23
|
name: 'Tree',
|
|
24
24
|
props: treeProps,
|
|
25
|
-
emits:
|
|
25
|
+
emits: {
|
|
26
|
+
'update:expandedKeys': (_keys: any) => true,
|
|
27
|
+
dblclick: (_node: any) => true
|
|
28
|
+
},
|
|
26
29
|
setup(props, { emit }) {
|
|
27
30
|
const selfElRef = ref<HTMLDivElement | null>(null);
|
|
28
31
|
const controlledExpandedKeysRef = toRef(props, 'expandedKeys');
|
|
@@ -10,6 +10,14 @@ export interface FormInput {
|
|
|
10
10
|
setError: (value: string) => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface InputEmitsMap {
|
|
14
|
+
'update:modelValue': (...args: any[]) => any;
|
|
15
|
+
blur: (...args: any[]) => any;
|
|
16
|
+
focus: (...args: any[]) => any;
|
|
17
|
+
input: (...args: any[]) => any;
|
|
18
|
+
change: (...args: any[]) => any;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
export const useInput = (
|
|
14
22
|
props: any,
|
|
15
23
|
{
|
|
@@ -138,12 +146,12 @@ useInput.emits = (withListeners = true): string[] => {
|
|
|
138
146
|
useInput.props = () =>
|
|
139
147
|
({
|
|
140
148
|
modelValue: [String, Number, Boolean, Object, Array] as PropType<
|
|
141
|
-
string | number | boolean | object | any[] |
|
|
149
|
+
string | number | boolean | object | any[] | null | undefined
|
|
142
150
|
>,
|
|
143
151
|
name: String,
|
|
144
152
|
readonly: Boolean,
|
|
145
153
|
required: Boolean,
|
|
146
|
-
error: String
|
|
154
|
+
error: String as PropType<string | null | undefined>,
|
|
147
155
|
rules: {
|
|
148
156
|
type: Array,
|
|
149
157
|
default: () => []
|