Skip to content

Commit d87f760

Browse files
committed
feat: more options for underlying vuetify components
1 parent 43ee242 commit d87f760

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

doc/pages/configuration.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,17 @@ export default {
198198
descriptions: {
199199
rootDisplay: 'equivalent of x-display annotation on the root object of the schema, can be "tabs" or "expansion-panels"',
200200
fieldProps: 'props passed to the underlying components for simple fields (v-text-field, v-select, etc.)',
201+
textFieldProps: 'props passed to the underlying v-text-field components',
202+
textareaProps: 'props passed to the underlying v-textarea components',
203+
numberProps: 'props passed to the underlying v-text-field components with type="number"',
204+
sliderProps: 'props passed to the underlying v-slider components',
205+
checkboxProps: 'props passed to the underlying v-checkbox components',
206+
switchProps: 'props passed to the underlying v-switch components',
207+
comboboxProps: 'props passed to the underlying v-combobox components',
201208
selectProps: 'props passed to the underlying components for select fields',
209+
fileInputProps: 'props passed to the underlying v-file-input components',
210+
radioGroupProps: 'props passed to the underlying v-radio-group components',
211+
radioItemProps: 'props passed to the underlying v-radio-item components',
202212
tabsProps: 'props passed to the underlying v-tabs component when relevant',
203213
expansionPanelsProps: 'props passed to the underlying v-expansion-panels component when relevant',
204214
dialogProps: 'props passed to the underlying v-dialog component when relevant',

lib/mixins/FileProperty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default {
4545
methods: {
4646
renderFileProp(h) {
4747
if (!this.isFileProp) return
48-
const props = { ...this.commonFieldProps }
48+
const props = { ...this.commonFieldProps, ...this.fullOptions.fileInputProps }
4949
delete props.value
5050
const attrs = {}
5151
if (this.fullSchema.contentMediaType) attrs.accept = this.fullSchema.contentMediaType

lib/mixins/SelectProperty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ export default {
211211
renderRadioItem(h, item) {
212212
const label = item[this.itemTitle] || item[this.itemKey]
213213
const value = item[this.itemKey]
214-
return h('v-radio', { props: { label, value } })
214+
return h('v-radio', { props: { ...this.fullOptions.radioItemProps, label, value } })
215215
},
216216
renderRadioGroup(h) {
217-
const props = { ...this.commonFieldProps }
217+
const props = { ...this.commonFieldProps, ...this.fullOptions.radioGroupProps }
218218
const on = {
219219
change: value => {
220220
this.input(value)

lib/mixins/SimpleProperty.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,26 @@ export default {
2626
let tooltipSlot = 'append-outer'
2727

2828
if (this.fullSchema.type === 'string') {
29-
tag = 'v-text-field'
30-
if (this.display === 'password') props.type = 'password'
3129
if (this.display === 'textarea' || (this.fullSchema.maxLength && this.fullSchema.maxLength > 1000 && this.display !== 'single-line')) {
3230
tag = 'v-textarea'
33-
props.filled = true
31+
Object.assign(props, this.fullOptions.textareaProps)
3432
domProps.class = 'v-text-field--box v-text-field--enclosed'
33+
} else {
34+
tag = 'v-text-field'
35+
Object.assign(props, this.fullOptions.textFieldProps)
36+
if (this.display === 'password') props.type = 'password'
3537
}
3638
}
3739

3840
if (['number', 'integer'].includes(this.fullSchema.type)) {
39-
tag = 'v-text-field'
40-
if (this.display === 'slider') tag = 'v-slider'
41-
41+
if (this.display === 'slider') {
42+
tag = 'v-slider'
43+
Object.assign(props, this.fullOptions.sliderProps)
44+
} else {
45+
tag = 'v-text-field'
46+
Object.assign(props, this.fullOptions.textFieldProps)
47+
Object.assign(props, this.fullOptions.numberProps)
48+
}
4249
props.type = 'number'
4350
if (this.fullSchema.minimum !== undefined) props.min = this.fullSchema.minimum
4451
if (this.fullSchema.maximum !== undefined) props.max = this.fullSchema.maximum
@@ -48,9 +55,14 @@ export default {
4855
}
4956

5057
if (this.fullSchema.type === 'boolean') {
51-
tag = 'v-checkbox'
5258
tooltipSlot = 'append'
53-
if (this.display === 'switch') tag = 'v-switch'
59+
if (this.display === 'switch') {
60+
tag = 'v-switch'
61+
Object.assign(props, this.fullOptions.switchProps)
62+
} else {
63+
tag = 'v-checkbox'
64+
Object.assign(props, this.fullOptions.checkboxProps)
65+
}
5466
on.change = value => {
5567
this.input(value || false)
5668
this.change(value || false)
@@ -59,7 +71,7 @@ export default {
5971

6072
if (this.fullSchema.type === 'array' && ['string', 'number', 'integer'].includes(this.fullSchema.items.type)) {
6173
tag = 'v-combobox'
62-
74+
Object.assign(props, this.fullOptions.comboboxProps)
6375
props.chips = true
6476
props.multiple = true
6577
props.appendIcon = ''

lib/utils/options.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ export const defaultOptions = {
88
sectionsTitlesClasses: ['title', 'subtitle-1', 'subtitle-2'],
99
childrenClass: 'pr-2',
1010
fieldProps: {},
11+
textFieldProps: {},
12+
textareaProps: { filled: true },
13+
numberProps: {},
14+
sliderProps: {},
15+
checkboxProps: {},
16+
switchProps: {},
17+
comboboxProps: {},
1118
selectProps: {},
19+
fileInputProps: {},
20+
radioGroupProps: {},
21+
radioItemProps: {},
1222
tabsProps: { grow: true },
1323
expansionPanelsProps: { mandatory: true },
1424
dialogProps: { maxWidth: 500 },

0 commit comments

Comments
 (0)