Skip to content

Commit

Permalink
fix(QField/QFile/QInput/QSelect): declare "maxlength" prop only for c…
Browse files Browse the repository at this point in the history
…omponents using it; popupShow & popupHide should be declared only for QSelect; correctly override virtualScrollItemSize for QSelect; correctly override modelValue for QInput
  • Loading branch information
rstoenescu committed May 3, 2024
1 parent 30bb503 commit e3e45df
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 69 deletions.
39 changes: 0 additions & 39 deletions ui/src/components/field/QField.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
"category": "model"
},

"max-values": {
"type": [ "Number", "String" ],
"desc": "Used internally by QSelect",
"internal": true
},

"tag": {
"extends": "tag",
"default": "'label'",
Expand Down Expand Up @@ -79,40 +73,7 @@

"events": {
"update:model-value": {
"extends": "update:model-value",
"desc": "Emitted when the model changes, only when used with 'clearable' or the 'control' scoped slot."
},

"focus": {
"desc": "Emitted when component gets focused",
"params": {
"evt": {
"extends": "evt"
}
}
},

"blur": {
"desc": "Emitted when component loses focus",
"params": {
"evt": {
"extends": "evt"
}
}
}
},

"methods": {
"focus": {
"desc": "Focus field",
"params": null,
"returns": null
},

"blur": {
"desc": "Blur field (lose focus)",
"params": null,
"returns": null
}
}
}
4 changes: 2 additions & 2 deletions ui/src/components/file/QFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { h, ref, computed, getCurrentInstance } from 'vue'

import QChip from '../chip/QChip.js'

import useField, { useFieldState, useFieldProps, useFieldEmits, fieldValueIsFilled } from '../../composables/private.use-field/use-field.js'
import useField, { useFieldState, useNonInputFieldProps, useFieldEmits, fieldValueIsFilled } from '../../composables/private.use-field/use-field.js'
import { useFormProps, useFormInputNameAttr } from '../../composables/use-form/private.use-form.js'
import useFile, { useFileProps, useFileEmits } from '../../composables/private.use-file/use-file.js'
import useFileFormDomProps from '../../composables/private.use-file/use-file-dom-props.js'
Expand All @@ -18,7 +18,7 @@ export default createComponent({
inheritAttrs: false,

props: {
...useFieldProps,
...useNonInputFieldProps,
...useFormProps,
...useFileProps,

Expand Down
9 changes: 2 additions & 7 deletions ui/src/components/file/QFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
},

"tabindex": {
"extends": "tabindex"
"extends": "tabindex",
"default": "0"
},

"input-class": {
Expand Down Expand Up @@ -137,12 +138,6 @@
}
},

"events": {
"update:model-value": {
"extends": "update:model-value"
}
},

"methods": {
"removeAtIndex": {
"desc": "Remove file located at specific index in the model",
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/input/QInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default createComponent({
...useMaskProps,
...useFormProps,

modelValue: { required: false },
// override of useFieldProps > modelValue
modelValue: [ String, Number ],

shadowText: String,

Expand Down
14 changes: 7 additions & 7 deletions ui/src/components/select/QSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default createComponent({
...useFormProps,
...useFieldProps,

// override of useFieldProps > modelValue
modelValue: {
required: true
},
Expand Down Expand Up @@ -107,20 +108,18 @@ export default createComponent({

autocomplete: String,

transitionShow: String,
transitionHide: String,
transitionDuration: [ String, Number ],
transitionShow: {},
transitionHide: {},
transitionDuration: {},

behavior: {
type: String,
validator: v => [ 'default', 'menu', 'dialog' ].includes(v),
default: 'default'
},

virtualScrollItemSize: {
type: [ Number, String ],
default: void 0
},
// override of useVirtualScrollProps > virtualScrollItemSize (no default)
virtualScrollItemSize: useVirtualScrollProps.virtualScrollItemSize.type,

onNewValue: Function,
onFilter: Function
Expand All @@ -130,6 +129,7 @@ export default createComponent({
...useFieldEmits,
'add', 'remove', 'inputValue',
'keyup', 'keypress', 'keydown',
'popupShow', 'popupHide',
'filterAbort'
],

Expand Down
13 changes: 3 additions & 10 deletions ui/src/components/select/QSelect.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,23 @@
"extends": "transition",
"desc": "Transition when showing the menu/dialog; One of Quasar's embedded transitions",
"default": "'fade'",
"passthrough": "child",
"category": "behavior"
},

"transition-hide": {
"extends": "transition",
"desc": "Transition when hiding the menu/dialog; One of Quasar's embedded transitions",
"default": "'fade'",
"passthrough": "child",
"category": "behavior"
},

"transition-duration": {
"type": [ "String", "Number" ],
"desc": "Transition duration when hiding the menu/dialog (in milliseconds, without unit)",
"default": "300",
"passthrough": "child",
"category": "behavior"
},

Expand Down Expand Up @@ -482,10 +485,6 @@
},

"events": {
"update:model-value": {
"extends": "update:model-value"
},

"input-value": {
"desc": "Emitted when the value in the text input changes",
"params": {
Expand Down Expand Up @@ -653,12 +652,6 @@
},

"methods": {
"focus": {
"desc": "Focus component",
"params": null,
"returns": null
},

"showPopup": {
"desc": "Focus and open popup",
"params": null,
Expand Down
9 changes: 6 additions & 3 deletions ui/src/composables/private.use-field/use-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function fieldValueIsFilled (val) {
&& ('' + val).length !== 0
}

export const useFieldProps = {
export const useNonInputFieldProps = {
...useDarkProps,
...useValidateProps,

Expand Down Expand Up @@ -61,12 +61,15 @@ export const useFieldProps = {

autofocus: Boolean,

for: String,
for: String
}

export const useFieldProps = {
...useNonInputFieldProps,
maxlength: [ Number, String ]
}

export const useFieldEmits = [ 'update:modelValue', 'clear', 'focus', 'blur', 'popupShow', 'popupHide' ]
export const useFieldEmits = [ 'update:modelValue', 'clear', 'focus', 'blur' ]

export function useFieldState ({ requiredForAttr = true, tagProp } = {}) {
const { props, proxy } = getCurrentInstance()
Expand Down
22 changes: 22 additions & 0 deletions ui/src/composables/private.use-field/use-field.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@
},

"events": {
"update:model-value": {
"extends": "update:model-value"
},

"focus": {
"desc": "Emitted when component gets focused",
"params": {
"evt": {
"extends": "evt"
}
}
},

"blur": {
"desc": "Emitted when component loses focus",
"params": {
"evt": {
"extends": "evt"
}
}
},

"clear": {
"desc": "When using the 'clearable' property, this event is emitted when the clear icon is clicked",
"params": {
Expand Down

0 comments on commit e3e45df

Please sign in to comment.