frappe-ui 0.1.56 → 0.1.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frappe-ui",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <Dialog v-model="showDialog" :options="{ title }">
3
+ <template #body-content>
4
+ <div class="space-y-4">
5
+ <p class="text-p-base text-gray-800" v-if="message" v-html="message" />
6
+ </div>
7
+ </template>
8
+ <template #actions>
9
+ <Button class="w-full" v-bind="primaryActionProps" />
10
+ </template>
11
+ </Dialog>
12
+ </template>
13
+ <script>
14
+ import Dialog from './Dialog.vue'
15
+ export default {
16
+ name: 'ConfirmDialog',
17
+ props: ['title', 'message', 'fields', 'onConfirm'],
18
+ expose: ['show', 'hide'],
19
+ components: {
20
+ Dialog,
21
+ },
22
+ data() {
23
+ return {
24
+ showDialog: true,
25
+ isLoading: false,
26
+ }
27
+ },
28
+ methods: {
29
+ handleConfirmation() {
30
+ try {
31
+ this.onConfirm?.({
32
+ hideDialog: this.hide,
33
+ })
34
+ } finally {
35
+ this.isLoading = false
36
+ }
37
+ },
38
+ show() {
39
+ this.showDialog = true
40
+ },
41
+ hide() {
42
+ this.showDialog = false
43
+ },
44
+ },
45
+ computed: {
46
+ primaryActionProps() {
47
+ return {
48
+ label: 'Confirm',
49
+ variant: 'solid',
50
+ loading: this.isLoading,
51
+ onClick: this.handleConfirmation,
52
+ }
53
+ },
54
+ },
55
+ }
56
+ </script>
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <div>
3
+ <component v-for="dialog in dialogs" :is="dialog"></component>
4
+ </div>
5
+ </template>
6
+ <script setup>
7
+ import { dialogs } from '../utils/confirmDialog.js'
8
+ </script>
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ export { default as Card } from './components/Card.vue'
9
9
  export { default as Checkbox } from './components/Checkbox.vue'
10
10
  export { default as DatePicker } from './components/DatePicker.vue'
11
11
  export { default as Dialog } from './components/Dialog.vue'
12
+ export { default as Dialogs } from './components/Dialogs.vue'
12
13
  export { default as Divider } from './components/Divider.vue'
13
14
  export { default as Dropdown } from './components/Dropdown.vue'
14
15
  export { default as ErrorMessage } from './components/ErrorMessage.vue'
@@ -86,3 +87,4 @@ export { setConfig, getConfig } from './utils/config.js'
86
87
  // plugin
87
88
  export { default as pageMetaPlugin } from './utils/pageMeta.js'
88
89
  export { default as FrappeUI } from './utils/plugin.js'
90
+ export { confirmDialog } from './utils/confirmDialog.js'
@@ -0,0 +1,25 @@
1
+ import ConfirmDialog from '../components/ConfirmDialog.vue'
2
+ import { h, ref } from 'vue'
3
+
4
+ export function confirmDialog({
5
+ title = 'Untitled',
6
+ message = '',
7
+ fields = [],
8
+ onConfirm,
9
+ }) {
10
+ renderDialog(
11
+ h(ConfirmDialog, {
12
+ title,
13
+ message,
14
+ fields,
15
+ onConfirm,
16
+ })
17
+ )
18
+ }
19
+
20
+ export const dialogs = ref([])
21
+
22
+ export function renderDialog(component) {
23
+ component.id = dialogs.length
24
+ dialogs.value.push(component)
25
+ }