Adds help text slot
This commit is contained in:
parent
2ad38933ee
commit
b58ed70a5f
2
dist/formulate.esm.js
vendored
2
dist/formulate.esm.js
vendored
File diff suppressed because one or more lines are too long
2
dist/formulate.min.js
vendored
2
dist/formulate.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/formulate.umd.js
vendored
2
dist/formulate.umd.js
vendored
File diff suppressed because one or more lines are too long
@ -41,11 +41,16 @@
|
|||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<slot
|
||||||
v-if="help"
|
name="help"
|
||||||
class="formulate-input-help"
|
v-bind="context"
|
||||||
v-text="help"
|
>
|
||||||
/>
|
<div
|
||||||
|
v-if="context.help"
|
||||||
|
class="formulate-input-help"
|
||||||
|
v-text="context.help"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
<FormulateErrors
|
<FormulateErrors
|
||||||
v-if="!disableErrors"
|
v-if="!disableErrors"
|
||||||
:type="`input`"
|
:type="`input`"
|
||||||
|
@ -9,29 +9,30 @@ import { map, arrayify, shallowEqualObjects } from './utils'
|
|||||||
export default {
|
export default {
|
||||||
context () {
|
context () {
|
||||||
return defineModel.call(this, {
|
return defineModel.call(this, {
|
||||||
type: this.type,
|
attributes: this.elementAttributes,
|
||||||
value: this.value,
|
blurHandler: blurHandler.bind(this),
|
||||||
name: this.nameOrFallback,
|
|
||||||
classification: this.classification,
|
classification: this.classification,
|
||||||
component: this.component,
|
component: this.component,
|
||||||
id: this.id || this.defaultId,
|
errors: this.explicitErrors,
|
||||||
|
getValidationErrors: this.getValidationErrors.bind(this),
|
||||||
hasLabel: (this.label && this.classification !== 'button'),
|
hasLabel: (this.label && this.classification !== 'button'),
|
||||||
|
hasValidationErrors: this.hasValidationErrors.bind(this),
|
||||||
|
help: this.help,
|
||||||
|
id: this.id || this.defaultId,
|
||||||
|
imageBehavior: this.imageBehavior,
|
||||||
label: this.label,
|
label: this.label,
|
||||||
labelPosition: this.logicalLabelPosition,
|
labelPosition: this.logicalLabelPosition,
|
||||||
attributes: this.elementAttributes,
|
name: this.nameOrFallback,
|
||||||
performValidation: this.performValidation.bind(this),
|
performValidation: this.performValidation.bind(this),
|
||||||
blurHandler: blurHandler.bind(this),
|
|
||||||
imageBehavior: this.imageBehavior,
|
|
||||||
uploadUrl: this.mergedUploadUrl,
|
|
||||||
uploader: this.uploader || this.$formulate.getUploader(),
|
|
||||||
uploadBehavior: this.uploadBehavior,
|
|
||||||
preventWindowDrops: this.preventWindowDrops,
|
preventWindowDrops: this.preventWindowDrops,
|
||||||
hasValidationErrors: this.hasValidationErrors.bind(this),
|
|
||||||
getValidationErrors: this.getValidationErrors.bind(this),
|
|
||||||
validationErrors: this.validationErrors,
|
|
||||||
errors: this.explicitErrors,
|
|
||||||
setErrors: this.setErrors.bind(this),
|
setErrors: this.setErrors.bind(this),
|
||||||
showValidationErrors: this.showValidationErrors,
|
showValidationErrors: this.showValidationErrors,
|
||||||
|
type: this.type,
|
||||||
|
uploadBehavior: this.uploadBehavior,
|
||||||
|
uploadUrl: this.mergedUploadUrl,
|
||||||
|
uploader: this.uploader || this.$formulate.getUploader(),
|
||||||
|
validationErrors: this.validationErrors,
|
||||||
|
value: this.value,
|
||||||
visibleValidationErrors: this.visibleValidationErrors,
|
visibleValidationErrors: this.visibleValidationErrors,
|
||||||
...this.typeContext
|
...this.typeContext
|
||||||
})
|
})
|
||||||
|
@ -262,4 +262,14 @@ describe('FormulateInputText', () => {
|
|||||||
})
|
})
|
||||||
expect(wrapper.find('label').text()).toBe('flavor town')
|
expect(wrapper.find('label').text()).toBe('flavor town')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Allow help text override with scoped slot', async () => {
|
||||||
|
const wrapper = mount(FormulateInput, {
|
||||||
|
propsData: { type: 'text', name: 'soda', help: 'Do you want some'},
|
||||||
|
scopedSlots: {
|
||||||
|
help: '<small>{{ props.help }} {{ props.name }}?</small>'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(wrapper.find('small').text()).toBe('Do you want some soda?')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user