diff --git a/docs/api/options.md b/docs/api/options.md index 3da9893..c388ed8 100644 --- a/docs/api/options.md +++ b/docs/api/options.md @@ -79,6 +79,12 @@ Vue.use(Snotify, { - default: `"Enter answer here..."` > Placeholder for Prompt toast +### initialValue + +- type: `string` +- default: `""` + > Inital value for Prompt toast + ### titleMaxLength - type: `number` diff --git a/example/src/App/app.ts b/example/src/App/app.ts index ccab3ea..ac597ae 100644 --- a/example/src/App/app.ts +++ b/example/src/App/app.ts @@ -146,10 +146,11 @@ export class App extends Vue { {text: 'Yes', action: (toast) => console.log('Said Yes: ' + toast.value) }, {text: 'No', action: (toast) => { console.log('Said No: ' + toast.value); this.$snotify.remove(toast.id); }}, ], - placeholder: 'Enter "ng-snotify" to validate this input' // Max-length = 40 + placeholder: 'Enter "vue-snotify" to validate this input', // Max-length = 40 + initialValue: 'ng-snotify' }).on('input', (toast) => { console.log(toast.value); - toast.valid = !!toast.value.match('ng-snotify'); + toast.valid = !!toast.value.match('vue-snotify'); }); diff --git a/example/test/unit/specs/Prompt.spec.ts b/example/test/unit/specs/Prompt.spec.ts index 7d52dd8..3568558 100644 --- a/example/test/unit/specs/Prompt.spec.ts +++ b/example/test/unit/specs/Prompt.spec.ts @@ -80,6 +80,17 @@ describe('Prompt Toast', () => { }); }); }); + + it('should set initial value', (done) => { + const toast = vm.$snotify.prompt('test', 'test2', { + initialValue: 'Hello' + }); + vm.$nextTick(() => { + const node: HTMLInputElement = vm.$el.querySelector('.snotify.snotify-rightBottom .snotifyToast.snotify-prompt input'); + expect(node.value).toEqual('Hello'); + done(); + }); + }); }); diff --git a/src/components/SnotifyPrompt.vue b/src/components/SnotifyPrompt.vue index 0e58a3b..4fff023 100644 --- a/src/components/SnotifyPrompt.vue +++ b/src/components/SnotifyPrompt.vue @@ -1,6 +1,7 @@