Giter Club home page Giter Club logo

vue3-promise-dialog's People

Contributors

hognevevle avatar pittan avatar reinerba avatar rlemaigre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue3-promise-dialog's Issues

Close dialog from setup function

Currently it seems the only way to dismiss a dialog, is to use the $close function from the template. (Possibly, you could also do this.$close from the Options API?)

Is there any way to dismiss dialogs from within setup()? My first hunch was to try import { closeDialog } from 'vue3-promise-dialog'; , but it seems the closeDialog isn't exported.

CleanShot 2022-04-08 at 13 52 31

I tried also the following workaround in my dialog component, but it throws an error when used:

const instance = getCurrentInstance();

onMounted(() => {
      setBackAction(instance?.appContext.config.globalProperties.$close);
    })

Error:

Uncaught TypeError: comp.returnValue is not a function
    at Proxy.app.config.globalProperties.$close (vue3-promise-dialog.es.js?db71:23:1)
    at eval (MessengerHeader.vue?a0c7:54:1)
    at eval (runtime-dom.esm-bundler.js?2725:1466:1)
    at callWithErrorHandling (runtime-core.esm-bundler.js?d2dd:155:1)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?d2dd:164:1)
    at HTMLAnchorElement.invoker (runtime-dom.esm-bundler.js?2725:366:1)

Cannot find name '$close' vs-code

Everything works great, but vs-code tells me that it can't find function $close. From where should I find it's declaration? Or maybe there is some workaround to just hide the error?

Example of a basic dialog with <script setup>?

Hi there โ€“

I'm trying to implement a basic dialog using the Composition API, in plain JS.

My component is shown below (styles omitted):

<template>
  <div class="dialog">
    <div class="center">
      <p>{{text}}</p>
      <button @click="$close(this, 'user clicked no')" class="btn">NO</button>
      <button @click="$close(this)" class="btn">YES</button>
    </div>
  </div>
</template>

<script setup>

    const props = defineProps({
        text: {
            type: String,
        },
    })

    function returnValue() {
        return 'user clicked yes';
    }

</script>

This almost works. Clicking on "No" resolves the promise with the string "user clicked no", as expected.

However, clicking on "Yes" gives the following error in the console:

runtime-core.esm-bundler.js:218 Uncaught TypeError: dialogRef.value.comp.returnValue is not a function
    at closeDialog (vue3-promise-dialog.es.js:5:33)
    at Proxy.app.config.globalProperties.$close (vue3-promise-dialog.es.js:23:7)
    at _createElementVNode.onClick._cache.<computed>._cache.<computed> (TempDialog.vue:6:23)
    at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
    at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:366:13)

Do you know what I'm doing wrong? I'm sure it's something basic...

It would be nice to provide an example of this usage in the docs.

Thanks for this great package โ€“ if I can figure out this little detail, then it's exactly what I needed!

Typescript Build Error

Hi
Using Typescript, with Vite 3.x, Vue 3.x
I get a build error:

src/main.ts:48:10 - error TS2345: Argument of type '{ install: (app: any, options: any) => void; }' is not assignable to parameter of type 'Plugin_2<[]>'.
  Type '{ install: (app: any, options: any) => void; }' is not assignable to type '{ install: (app: App<any>) => any; }'.
    Types of property 'install' are incompatible.
      Type '(app: any, options: any) => void' is not assignable to type '(app: App<any>) => any'.

48     .use(PromiseDialog)

using vue3-promise-dialog with <script setup>

If using <script setup> it is necessary to expose the returnValue function in the following way. (It took me a while to figure this out; perhaps the README can be updated)

defineExpose({
returnValue: () => { return true },
});

Maintained alternative?

Sorry for asking such a potentially rude question...
But is there any alternative library which serves the same purpose but is actively maintained?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.