1
0
mirror of synced 2024-11-25 23:06:02 +03:00

Initial support for public scoped slot api

This commit is contained in:
Justin Schroeder 2020-03-29 00:32:07 -04:00
parent 72552cd84d
commit 2ad38933ee
5 changed files with 30 additions and 2 deletions

6
package-lock.json generated
View File

@ -20304,6 +20304,12 @@
"is-typedarray": "^1.0.0" "is-typedarray": "^1.0.0"
} }
}, },
"typescript": {
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
"dev": true
},
"uglify-js": { "uglify-js": {
"version": "3.4.10", "version": "3.4.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",

View File

@ -82,6 +82,7 @@
"rollup-plugin-terser": "^5.2.0", "rollup-plugin-terser": "^5.2.0",
"rollup-plugin-vue": "^5.1.6", "rollup-plugin-vue": "^5.1.6",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"typescript": "^3.8.3",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-jest": "^3.0.5", "vue-jest": "^3.0.5",
"vue-runtime-helpers": "^1.1.2", "vue-runtime-helpers": "^1.1.2",

View File

@ -32,7 +32,7 @@
<slot <slot
v-if="context.hasLabel && context.labelPosition === 'after'" v-if="context.hasLabel && context.labelPosition === 'after'"
name="label" name="label"
v-bind="context.label" v-bind="context"
> >
<label <label
class="formulate-input-label formulate-input-label--after" class="formulate-input-label formulate-input-label--after"

View File

@ -26,7 +26,7 @@ export default {
uploader: this.uploader || this.$formulate.getUploader(), uploader: this.uploader || this.$formulate.getUploader(),
uploadBehavior: this.uploadBehavior, uploadBehavior: this.uploadBehavior,
preventWindowDrops: this.preventWindowDrops, preventWindowDrops: this.preventWindowDrops,
hasValidationErrors: this.hasValidationErrors, hasValidationErrors: this.hasValidationErrors.bind(this),
getValidationErrors: this.getValidationErrors.bind(this), getValidationErrors: this.getValidationErrors.bind(this),
validationErrors: this.validationErrors, validationErrors: this.validationErrors,
errors: this.explicitErrors, errors: this.explicitErrors,

View File

@ -241,4 +241,25 @@ describe('FormulateInputText', () => {
await flushPromises() await flushPromises()
expect(wrapper.find('[data-has-errors]').exists()).toBe(true) expect(wrapper.find('[data-has-errors]').exists()).toBe(true)
}) })
it('allows label-before override with scoped slot', async () => {
const wrapper = mount(FormulateInput, {
propsData: { type: 'text', label: 'flavor' },
scopedSlots: {
label: '<label>{{ props.label }} town</label>'
}
})
expect(wrapper.find('label').text()).toBe('flavor town')
})
it('allows label-after override with scoped slot', async () => {
const wrapper = mount(FormulateInput, {
propsData: { type: 'text', label: 'flavor', labelPosition: 'after' },
scopedSlots: {
label: '<label>{{ props.label }} town</label>'
}
})
expect(wrapper.find('label').text()).toBe('flavor town')
})
}) })