Skip to content

Commit 55aaed9

Browse files
committed
feat: add fieldColProps option
1 parent 6b3e2b1 commit 55aaed9

File tree

5 files changed

+219
-168
lines changed

5 files changed

+219
-168
lines changed

doc/examples/classes.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
const id = 'classes'
22

3-
const title = 'Classes and styles'
3+
const title = 'Layout, classes and styles'
44

5-
const description = `You can define classes on the wrapping element of each property using a \`x-class\` annotation. If you use layout management classes you can then position properties next to each other for examples.
5+
const description = `You can define classes on the wrapping element of each property using the \`x-class\` annotation.
66
77
To write CSS rules directly on the wrapping element of a property use the \`x-style\` annotation.
88
9-
There are also classes that can be defined as options: \`objectContainerClass\`, \`sectionsClass\`, \`sectionsTitlesClasses\`, \`childrenClass\`.`
9+
To customize the responsive layout of your form you can use the \`x-cols\` annotation or the \`fieldColProps\` option.
10+
11+
There are also many options that can be used to apply classes to different parts of your form: \`objectContainerClass\`, \`sectionsClass\`, \`sectionsTitlesClasses\`, \`childrenClass\`, etc.`
1012

1113
const schema = {
1214
type: 'object',
1315
properties: {
14-
stringPropHalf: { type: 'string', title: `I'm a half width string`, 'x-class': 'xs6' },
15-
stringPropHalf2: { type: 'string', title: `I'm another half width string`, 'x-class': 'xs6' },
16+
stringPropHalf: { type: 'string', title: `I'm a half width string using x-cols`, 'x-cols': 6 },
17+
stringPropHalf2: { type: 'string', title: `I'm another half width string using fieldColProps option`, 'x-options': { fieldColProps: { cols: 6 } } },
18+
stringPropClass: { type: 'string', title: `I'm a string with class pl-10`, 'x-class': 'pl-10' },
1619
stringPropStyle: { type: 'string', title: `I'm a string with style`, 'x-style': 'background-color: pink; padding-left: 20px;' }
1720
}
1821
}

doc/pages/configuration.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
</tr>
172172
<tr>
173173
<td>x-cols</td>
174-
<td>The width of the v-col component wrapping the property (default is 12).</td>
174+
<td>The width of the v-col component wrapping the property (default is 12). You can use the fieldColProps option for further layout customization.</td>
175175
</tr>
176176
<tr>
177177
<td>x-slots</td>
@@ -198,6 +198,7 @@ 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+
fieldColProps: 'props passed to the v-col component that wraps any field. Use "cols", "xs", "md", etc. to customize your form layout.',
201202
textFieldProps: 'props passed to the underlying v-text-field components',
202203
textareaProps: 'props passed to the underlying v-textarea components',
203204
numberProps: 'props passed to the underlying v-text-field components with type="number"',

lib/VJsfNoDeps.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ export default {
162162
children.push(h('div', { domProps: { innerHTML: this.fullOptions.markdown(this.xSlots.after) } }))
163163
}
164164

165-
return h('v-col', { props: { cols: this.fullSchema['x-cols'] || 12 }, class: this.propertyClass, style: this.fullSchema['x-style'] || '' }, children)
165+
const colProps = { ...this.fullOptions.fieldColProps }
166+
if (this.fullSchema['x-cols']) colProps.cols = this.fullSchema['x-cols']
167+
return h('v-col', { props: colProps, class: this.propertyClass, style: this.fullSchema['x-style'] || '' }, children)
166168
},
167169
methods: {
168170
renderPropSlots(h) {

lib/utils/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const defaultOptions = {
88
sectionsTitlesClasses: ['title', 'subtitle-1', 'subtitle-2'],
99
childrenClass: 'pr-2',
1010
fieldProps: {},
11+
fieldColProps: { cols: 12 },
1112
textFieldProps: {},
1213
textareaProps: { filled: true },
1314
numberProps: {},

0 commit comments

Comments
 (0)