1
0
mirror of synced 2025-02-16 20:53:13 +03:00

Adds help text slot

This commit is contained in:
Justin Schroeder 2020-03-29 00:46:39 -04:00
parent 2ad38933ee
commit b58ed70a5f
6 changed files with 38 additions and 22 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -41,11 +41,16 @@
/>
</slot>
</div>
<div
v-if="help"
class="formulate-input-help"
v-text="help"
/>
<slot
name="help"
v-bind="context"
>
<div
v-if="context.help"
class="formulate-input-help"
v-text="context.help"
/>
</slot>
<FormulateErrors
v-if="!disableErrors"
:type="`input`"

View File

@ -9,29 +9,30 @@ import { map, arrayify, shallowEqualObjects } from './utils'
export default {
context () {
return defineModel.call(this, {
type: this.type,
value: this.value,
name: this.nameOrFallback,
attributes: this.elementAttributes,
blurHandler: blurHandler.bind(this),
classification: this.classification,
component: this.component,
id: this.id || this.defaultId,
errors: this.explicitErrors,
getValidationErrors: this.getValidationErrors.bind(this),
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,
labelPosition: this.logicalLabelPosition,
attributes: this.elementAttributes,
name: this.nameOrFallback,
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,
hasValidationErrors: this.hasValidationErrors.bind(this),
getValidationErrors: this.getValidationErrors.bind(this),
validationErrors: this.validationErrors,
errors: this.explicitErrors,
setErrors: this.setErrors.bind(this),
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,
...this.typeContext
})

View File

@ -262,4 +262,14 @@ describe('FormulateInputText', () => {
})
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?')
})
})