@dimailn/vuetify 2.7.2-alpha22 → 2.7.2-alpha24

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.
Files changed (58) hide show
  1. package/dist/vuetify.js +92 -59
  2. package/dist/vuetify.js.map +1 -1
  3. package/dist/vuetify.min.css +1 -1
  4. package/dist/vuetify.min.js +2 -2
  5. package/es5/components/VBadge/VBadge.js +17 -14
  6. package/es5/components/VBadge/VBadge.js.map +1 -1
  7. package/es5/components/VForm/VForm.js +44 -30
  8. package/es5/components/VForm/VForm.js.map +1 -1
  9. package/es5/components/VInput/VInput.js +4 -0
  10. package/es5/components/VInput/VInput.js.map +1 -1
  11. package/es5/components/VSelect/VSelectList.js +1 -1
  12. package/es5/components/VSelect/VSelectList.js.map +1 -1
  13. package/es5/framework.js +1 -1
  14. package/es5/mixins/activatable/index.js +2 -1
  15. package/es5/mixins/activatable/index.js.map +1 -1
  16. package/es5/mixins/bootable/index.js +1 -2
  17. package/es5/mixins/bootable/index.js.map +1 -1
  18. package/es5/mixins/mouse/index.js +10 -5
  19. package/es5/mixins/mouse/index.js.map +1 -1
  20. package/es5/mixins/selectable/index.js +3 -0
  21. package/es5/mixins/selectable/index.js.map +1 -1
  22. package/es5/mixins/validatable/index.js +8 -5
  23. package/es5/mixins/validatable/index.js.map +1 -1
  24. package/lib/components/VBadge/VBadge.js +14 -13
  25. package/lib/components/VBadge/VBadge.js.map +1 -1
  26. package/lib/components/VForm/VForm.js +40 -26
  27. package/lib/components/VForm/VForm.js.map +1 -1
  28. package/lib/components/VInput/VInput.js +4 -0
  29. package/lib/components/VInput/VInput.js.map +1 -1
  30. package/lib/components/VSelect/VSelectList.js +2 -1
  31. package/lib/components/VSelect/VSelectList.js.map +1 -1
  32. package/lib/framework.js +1 -1
  33. package/lib/mixins/activatable/index.js +2 -1
  34. package/lib/mixins/activatable/index.js.map +1 -1
  35. package/lib/mixins/bootable/index.js +2 -4
  36. package/lib/mixins/bootable/index.js.map +1 -1
  37. package/lib/mixins/mouse/index.js +9 -5
  38. package/lib/mixins/mouse/index.js.map +1 -1
  39. package/lib/mixins/selectable/index.js +4 -0
  40. package/lib/mixins/selectable/index.js.map +1 -1
  41. package/lib/mixins/validatable/index.js +8 -4
  42. package/lib/mixins/validatable/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/components/VBadge/VBadge.ts +24 -25
  45. package/src/components/VBadge/__tests__/VBadge.spec.ts +47 -30
  46. package/src/components/VBadge/__tests__/__snapshots__/VBadge.spec.ts.snap +5 -5
  47. package/src/components/VForm/VForm.ts +61 -35
  48. package/src/components/VForm/__tests__/VForm.spec.ts +100 -80
  49. package/src/components/VInput/VInput.ts +4 -0
  50. package/src/components/VSelect/VSelectList.ts +1 -0
  51. package/src/mixins/activatable/index.ts +2 -1
  52. package/src/mixins/bootable/__tests__/bootable.spec.ts +17 -11
  53. package/src/mixins/bootable/index.ts +4 -3
  54. package/src/mixins/mouse/__tests__/mouse.spec.ts +54 -40
  55. package/src/mixins/mouse/index.ts +10 -6
  56. package/src/mixins/selectable/index.ts +4 -0
  57. package/src/mixins/validatable/__tests__/validatable.spec.ts +194 -158
  58. package/src/mixins/validatable/index.ts +16 -18
@@ -1,4 +1,4 @@
1
- import {Transition, h} from 'vue'
1
+ import { Transition, h, defineComponent, VNode, withDirectives, vShow } from 'vue'
2
2
  // Styles
3
3
  import './VBadge.sass'
4
4
 
@@ -8,30 +8,29 @@ import VIcon from '../VIcon/VIcon'
8
8
  // Mixins
9
9
  import Colorable from '../../mixins/colorable'
10
10
  import Themeable from '../../mixins/themeable'
11
- import Toggleable from '../../mixins/toggleable'
11
+ import { factory as ToggleableFactory } from '../../mixins/toggleable'
12
12
  import Transitionable from '../../mixins/transitionable'
13
13
  import { factory as PositionableFactory } from '../../mixins/positionable'
14
14
  import mergeData from '../../util/mergeData'
15
15
  // Utilities
16
- import mixins from '../../util/mixins'
17
16
  import {
18
17
  convertToUnit,
19
18
  getSlot,
20
19
  } from '../../util/helpers'
21
20
 
22
- // Types
23
- import { VNode } from 'vue'
24
-
25
- export default mixins(
26
- Colorable,
27
- PositionableFactory(['left', 'bottom']),
28
- Themeable,
29
- Toggleable,
30
- Transitionable,
31
- /* @vue/component */
32
- ).extend({
21
+ const Toggleable = ToggleableFactory('modelValue', 'update:modelValue')
22
+
23
+ export default defineComponent({
33
24
  name: 'v-badge',
34
25
 
26
+ mixins: [
27
+ Colorable,
28
+ PositionableFactory(['left', 'bottom']),
29
+ Themeable,
30
+ Toggleable,
31
+ Transitionable,
32
+ ],
33
+
35
34
  props: {
36
35
  avatar: Boolean,
37
36
  bordered: Boolean,
@@ -55,7 +54,7 @@ export default mixins(
55
54
  type: String,
56
55
  default: 'scale-rotate-transition',
57
56
  },
58
- value: { default: true },
57
+ modelValue: { default: true },
59
58
  },
60
59
 
61
60
  computed: {
@@ -136,13 +135,12 @@ export default mixins(
136
135
  'aria-live': this.$attrs['aria-live'] || 'polite',
137
136
  title: this.$attrs.title,
138
137
  role: this.$attrs.role || 'status',
139
- directives: [{
140
- name: 'show',
141
- value: this.isActive,
142
- }],
143
138
  })
144
139
 
145
- const badge = h('span', data, [this.genBadgeContent()])
140
+ const badge = withDirectives(
141
+ h('span', data, [this.genBadgeContent()]),
142
+ [[vShow, this.isActive]]
143
+ )
146
144
 
147
145
  if (!this.transition) return badge
148
146
 
@@ -150,7 +148,9 @@ export default mixins(
150
148
  name: this.transition,
151
149
  origin: this.origin,
152
150
  mode: this.mode,
153
- }, [badge])
151
+ }, {
152
+ default: () => [badge],
153
+ })
154
154
  },
155
155
  genBadgeContent () {
156
156
  // Dot prop shows no content
@@ -160,7 +160,7 @@ export default mixins(
160
160
 
161
161
  if (slot) return slot
162
162
  if (this.content) return String(this.content)
163
- if (this.icon) return h(VIcon, this.icon)
163
+ if (this.icon) return h(VIcon, { icon: this.icon })
164
164
 
165
165
  return undefined
166
166
  },
@@ -187,8 +187,7 @@ export default mixins(
187
187
  else children.push(badge)
188
188
 
189
189
  return h('span', mergeData({
190
- class: ['v-badge', this.classes]
191
- }, attrs)
192
- , children)
190
+ class: ['v-badge', this.classes],
191
+ }, attrs), children)
193
192
  },
194
193
  })
@@ -2,25 +2,26 @@
2
2
  import VBadge from '../VBadge'
3
3
 
4
4
  // Utilities
5
- import {
6
- mount,
7
- Wrapper,
8
- } from '@vue/test-utils'
9
- import { compileToFunctions } from 'vue-template-compiler'
5
+ import { mount, enableAutoUnmount, VueWrapper } from '@vue/test-utils'
10
6
 
11
7
  // Types
12
- import { ExtractVue } from '../../../util/mixins'
8
+ import { ComponentPublicInstance } from 'vue'
13
9
 
14
10
  describe('VBadge.ts', () => {
15
- type Instance = ExtractVue<typeof VBadge>
16
- let mountFunction: (options?: object) => Wrapper<Instance>
11
+ type Instance = ComponentPublicInstance
12
+ let mountFunction: (options?: object) => VueWrapper<Instance>
13
+
14
+ enableAutoUnmount(afterEach)
17
15
 
18
16
  beforeEach(() => {
19
17
  mountFunction = (options = {}) => {
20
18
  return mount(VBadge, {
21
- mocks: {
22
- $vuetify: {
23
- lang: { t: (text = '') => text },
19
+ global: {
20
+ mocks: {
21
+ $vuetify: {
22
+ lang: { t: (text = '') => text },
23
+ rtl: false,
24
+ },
24
25
  },
25
26
  },
26
27
  ...options,
@@ -31,22 +32,22 @@ describe('VBadge.ts', () => {
31
32
  it('should render component and match snapshot', async () => {
32
33
  const wrapper = mountFunction({
33
34
  slots: {
34
- badge: [compileToFunctions('<span>content</span>')],
35
- default: [compileToFunctions('<span>element</span>')],
35
+ badge: '<span>content</span>',
36
+ default: '<span>element</span>',
36
37
  },
37
38
  })
38
39
 
39
40
  expect(wrapper.html()).toMatchSnapshot()
40
41
  })
41
42
 
42
- it('should render component with with value=false and match snapshot', async () => {
43
+ it('should render component with with modelValue=false and match snapshot', async () => {
43
44
  const wrapper = mountFunction({
44
- propsData: {
45
- value: false,
45
+ props: {
46
+ modelValue: false,
46
47
  },
47
48
  slots: {
48
- badge: [compileToFunctions('<span>content</span>')],
49
- default: [compileToFunctions('<span>element</span>')],
49
+ badge: '<span>content</span>',
50
+ default: '<span>element</span>',
50
51
  },
51
52
  })
52
53
 
@@ -55,7 +56,7 @@ describe('VBadge.ts', () => {
55
56
 
56
57
  it('should render component with bottom prop', () => {
57
58
  const wrapper = mountFunction({
58
- propsData: {
59
+ props: {
59
60
  bottom: true,
60
61
  },
61
62
  })
@@ -65,7 +66,7 @@ describe('VBadge.ts', () => {
65
66
 
66
67
  it('should render component with left prop', () => {
67
68
  const wrapper = mountFunction({
68
- propsData: {
69
+ props: {
69
70
  left: true,
70
71
  },
71
72
  })
@@ -75,7 +76,7 @@ describe('VBadge.ts', () => {
75
76
 
76
77
  it('should render component with overlap prop', () => {
77
78
  const wrapper = mountFunction({
78
- propsData: {
79
+ props: {
79
80
  overlap: true,
80
81
  },
81
82
  })
@@ -85,11 +86,11 @@ describe('VBadge.ts', () => {
85
86
 
86
87
  it('should render component with color prop', () => {
87
88
  const wrapper = mountFunction({
88
- propsData: {
89
+ props: {
89
90
  color: 'green lighten-1',
90
91
  },
91
92
  slots: {
92
- badge: [compileToFunctions('<span>content</span>')],
93
+ badge: '<span>content</span>',
93
94
  },
94
95
  })
95
96
 
@@ -104,9 +105,17 @@ describe('VBadge.ts', () => {
104
105
  render: jest.fn(),
105
106
  }
106
107
 
107
- mountFunction({
108
- stubs: {
109
- transition: transitionStub,
108
+ const wrapper = mount(VBadge, {
109
+ global: {
110
+ mocks: {
111
+ $vuetify: {
112
+ lang: { t: (text = '') => text },
113
+ rtl: false,
114
+ },
115
+ },
116
+ stubs: {
117
+ transition: transitionStub,
118
+ },
110
119
  },
111
120
  })
112
121
 
@@ -119,12 +128,20 @@ describe('VBadge.ts', () => {
119
128
  render: jest.fn(),
120
129
  }
121
130
 
122
- mountFunction({
123
- propsData: {
131
+ const wrapper = mount(VBadge, {
132
+ props: {
124
133
  transition: '',
125
134
  },
126
- stubs: {
127
- transition: transitionStub,
135
+ global: {
136
+ mocks: {
137
+ $vuetify: {
138
+ lang: { t: (text = '') => text },
139
+ rtl: false,
140
+ },
141
+ },
142
+ stubs: {
143
+ transition: transitionStub,
144
+ },
128
145
  },
129
146
  })
130
147
 
@@ -6,11 +6,11 @@ exports[`VBadge.ts should render component and match snapshot 1`] = `
6
6
  element
7
7
  </span>
8
8
  <span class="v-badge__wrapper">
9
- <span aria-atomic="true"
9
+ <span class="v-badge__badge primary"
10
+ aria-atomic="true"
10
11
  aria-label="$vuetify.badge"
11
12
  aria-live="polite"
12
13
  role="status"
13
- class="v-badge__badge primary"
14
14
  >
15
15
  <span>
16
16
  content
@@ -20,17 +20,17 @@ exports[`VBadge.ts should render component and match snapshot 1`] = `
20
20
  </span>
21
21
  `;
22
22
 
23
- exports[`VBadge.ts should render component with with value=false and match snapshot 1`] = `
23
+ exports[`VBadge.ts should render component with with modelValue=false and match snapshot 1`] = `
24
24
  <span class="v-badge theme--light">
25
25
  <span>
26
26
  element
27
27
  </span>
28
28
  <span class="v-badge__wrapper">
29
- <span aria-atomic="true"
29
+ <span class="v-badge__badge primary"
30
+ aria-atomic="true"
30
31
  aria-label="$vuetify.badge"
31
32
  aria-live="polite"
32
33
  role="status"
33
- class="v-badge__badge primary"
34
34
  style="display: none;"
35
35
  >
36
36
  <span>
@@ -1,4 +1,4 @@
1
- import {h} from 'vue'
1
+ import { h, VNode } from 'vue'
2
2
  // Components
3
3
  import VInput from '../VInput/VInput'
4
4
 
@@ -8,7 +8,6 @@ import BindsAttrs from '../../mixins/binds-attrs'
8
8
  import { provide as RegistrableProvide } from '../../mixins/registrable'
9
9
 
10
10
  // Helpers
11
- import { VNode } from 'vue'
12
11
  import { getSlot } from '../../util/helpers'
13
12
 
14
13
  type ErrorBag = Record<number, boolean>
@@ -19,6 +18,17 @@ type Watchers = {
19
18
  shouldValidate: () => void
20
19
  }
21
20
 
21
+ interface VFormContext {
22
+ inputs: VInputInstance[]
23
+ watchers: Watchers[]
24
+ errorBag: ErrorBag
25
+ lazyValidation: boolean
26
+ $emit: (event: string, ...args: any[]) => void
27
+ getInputUid: (input: VInputInstance) => number
28
+ watchInput: (input: VInputInstance) => Watchers
29
+ resetErrorBag: () => void
30
+ }
31
+
22
32
  /* @vue/component */
23
33
  export default mixins(
24
34
  BindsAttrs,
@@ -48,10 +58,11 @@ export default mixins(
48
58
 
49
59
  watch: {
50
60
  errorBag: {
51
- handler (val) {
61
+ handler (this: VFormContext, val: ErrorBag) {
52
62
  const errors = Object.values(val).includes(true)
53
63
 
54
64
  this.$emit('input', !errors)
65
+ this.$emit('update:modelValue', !errors)
55
66
  },
56
67
  deep: true,
57
68
  immediate: true,
@@ -59,45 +70,56 @@ export default mixins(
59
70
  },
60
71
 
61
72
  methods: {
62
- watchInput (input: any): Watchers {
63
- const watcher = (input: any): (() => void) => {
64
- return input.$watch('hasError', (val: boolean) => {
65
- this.errorBag[input.$.uid] = val
66
- }, { immediate: true })
73
+ getInputUid (input: VInputInstance): number {
74
+ return input.$.uid
75
+ },
76
+
77
+ watchInput (this: VFormContext, input: VInputInstance): Watchers {
78
+ const inputId = this.getInputUid(input)
79
+
80
+ const createErrorWatcher = (inputComponent: VInputInstance): (() => void) => {
81
+ if (typeof inputComponent.$watch === 'function') {
82
+ return inputComponent.$watch('hasError', (hasError: boolean) => {
83
+ this.errorBag[inputId] = hasError
84
+ }, { immediate: true })
85
+ } else {
86
+ // Fallback для Vue 3
87
+ return () => {}
88
+ }
67
89
  }
68
90
 
69
91
  const watchers: Watchers = {
70
- _uid: input.$.uid,
92
+ _uid: inputId,
71
93
  valid: () => {},
72
94
  shouldValidate: () => {},
73
95
  }
74
96
 
75
97
  if (this.lazyValidation) {
76
- // Only start watching inputs if we need to
77
- watchers.shouldValidate = input.$watch('shouldValidate', (val: boolean) => {
78
- if (!val) return
98
+ if (typeof input.$watch === 'function') {
99
+ watchers.shouldValidate = input.$watch('shouldValidate', (shouldValidate: boolean) => {
100
+ if (!shouldValidate) return
79
101
 
80
- // Only watch if we're not already doing it
81
- if (this.errorBag.hasOwnProperty(input.$.uid)) return
102
+ if (this.errorBag.hasOwnProperty(inputId)) return
82
103
 
83
- watchers.valid = watcher(input)
84
- })
104
+ watchers.valid = createErrorWatcher(input)
105
+ })
106
+ }
85
107
  } else {
86
- watchers.valid = watcher(input)
108
+ watchers.valid = createErrorWatcher(input)
87
109
  }
88
110
 
89
111
  return watchers
90
112
  },
91
113
  /** @public */
92
- validate (): boolean {
93
- return this.inputs.filter(input => !input.validate(true)).length === 0
114
+ validate (this: VFormContext): boolean {
115
+ return this.inputs.filter((input: VInputInstance) => !input.validate(true)).length === 0
94
116
  },
95
117
  /** @public */
96
- reset (): void {
97
- this.inputs.forEach(input => input.reset())
118
+ reset (this: VFormContext): void {
119
+ this.inputs.forEach((input: VInputInstance) => input.reset())
98
120
  this.resetErrorBag()
99
121
  },
100
- resetErrorBag () {
122
+ resetErrorBag (this: VFormContext) {
101
123
  if (this.lazyValidation) {
102
124
  // Account for timeout in validatable
103
125
  setTimeout(() => {
@@ -106,28 +128,32 @@ export default mixins(
106
128
  }
107
129
  },
108
130
  /** @public */
109
- resetValidation () {
110
- this.inputs.forEach(input => input.resetValidation())
131
+ resetValidation (this: VFormContext) {
132
+ this.inputs.forEach((input: VInputInstance) => input.resetValidation())
111
133
  this.resetErrorBag()
112
134
  },
113
- register (input: VInputInstance) {
135
+
136
+ register (this: VFormContext, input: VInputInstance) {
114
137
  this.inputs.push(input)
115
138
  this.watchers.push(this.watchInput(input))
116
139
  },
117
- unregister (input: VInputInstance) {
118
- const found = this.inputs.find(i => i.$.uid === input.$.uid)
119
140
 
120
- if (!found) return
141
+ unregister (this: VFormContext, input: VInputInstance) {
142
+ const inputId = this.getInputUid(input)
143
+ const foundInput = this.inputs.find((inputComponent: VInputInstance) => this.getInputUid(inputComponent) === inputId)
144
+
145
+ if (!foundInput) return
121
146
 
122
- const unwatch = this.watchers.find(i => i._uid === found.$.uid)
123
- if (unwatch) {
124
- unwatch.valid()
125
- unwatch.shouldValidate()
147
+ const inputWatcher = this.watchers.find((watcher: Watchers) => watcher._uid === inputId)
148
+ if (inputWatcher) {
149
+ inputWatcher.valid()
150
+ inputWatcher.shouldValidate()
126
151
  }
127
152
 
128
- this.watchers = this.watchers.filter(i => i._uid !== found.$.uid)
129
- this.inputs = this.inputs.filter(i => i.$.uid !== found.$.uid)
130
- delete this.errorBag[found.$.uid]
153
+ this.watchers = this.watchers.filter((watcher: Watchers) => watcher._uid !== inputId)
154
+ this.inputs = this.inputs.filter((inputComponent: VInputInstance) => this.getInputUid(inputComponent) !== inputId)
155
+
156
+ delete this.errorBag[inputId]
131
157
  },
132
158
  },
133
159