frappe-ui 0.0.91 → 0.0.93

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.0.91",
3
+ "version": "0.0.93",
4
4
  "description": "A set of components and utilities for rapid UI development",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -10,7 +10,7 @@
10
10
  @close="open = false"
11
11
  >
12
12
  <div
13
- class="flex min-h-screen flex-col items-center px-4 pt-4 pb-20 text-center"
13
+ class="flex min-h-screen flex-col items-center px-4 py-4 text-center"
14
14
  :class="dialogPositionClasses"
15
15
  >
16
16
  <TransitionChild
@@ -1,49 +1,49 @@
1
1
  <template>
2
2
  <Menu as="div" class="relative inline-block text-left" v-slot="{ open }">
3
- <MenuButton as="div">
4
- <slot v-if="$slots.default" v-bind="{ open }"></slot>
5
- <Button v-else v-bind="button" :active="open">
6
- {{ button ? button?.label || null : 'Options' }}
7
- </Button>
8
- </MenuButton>
3
+ <Popover :transition="dropdownTransition" :show="open">
4
+ <template #target>
5
+ <MenuButton as="div">
6
+ <slot v-if="$slots.default" v-bind="{ open }" />
7
+ <Button v-else :active="open" v-bind="button">
8
+ {{ button ? button?.label || null : 'Options' }}
9
+ </Button>
10
+ </MenuButton>
11
+ </template>
9
12
 
10
- <transition
11
- enter-active-class="transition duration-100 ease-out"
12
- enter-from-class="transform scale-95 opacity-0"
13
- enter-to-class="transform scale-100 opacity-100"
14
- leave-active-class="transition duration-75 ease-in"
15
- leave-from-class="transform scale-100 opacity-100"
16
- leave-to-class="transform scale-95 opacity-0"
17
- >
18
- <MenuItems
19
- class="min-w-40 absolute z-10 mt-2 divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
20
- :class="{
21
- 'left-0 origin-top-left': placement == 'left',
22
- 'right-0 origin-top-right': placement == 'right',
23
- 'inset-x-0 origin-top': placement == 'center',
24
- }"
25
- >
26
- <div v-for="group in groups" :key="group.key" class="px-1 py-1">
27
- <div
28
- v-if="group.group && !group.hideLabel"
29
- class="px-2 py-1 text-xs font-semibold uppercase tracking-wider text-gray-500"
30
- >
31
- {{ group.group }}
32
- </div>
33
- <MenuItem
34
- v-for="item in group.items"
35
- :key="item.label"
36
- v-slot="{ active }"
37
- >
38
- <button
39
- :class="[
40
- active ? 'bg-gray-100' : 'text-gray-900',
41
- 'group flex w-full items-center rounded-md px-2 py-2 text-sm',
42
- ]"
43
- @click="item.onClick"
13
+ <template #body>
14
+ <MenuItems
15
+ class="min-w-40 mt-2 divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
16
+ :class="{
17
+ 'left-0 origin-top-left': placement == 'left',
18
+ 'right-0 origin-top-right': placement == 'right',
19
+ 'inset-x-0 origin-top': placement == 'center',
20
+ }"
21
+ >
22
+ <div v-for="group in groups" :key="group.key" class="px-1 py-1">
23
+ <div
24
+ v-if="group.group && !group.hideLabel"
25
+ class="px-2 py-1 text-xs font-semibold uppercase tracking-wider text-gray-500"
26
+ >
27
+ {{ group.group }}
28
+ </div>
29
+ <MenuItem
30
+ v-for="item in group.items"
31
+ :key="item.label"
32
+ v-slot="{ active }"
44
33
  >
45
- <component :is="item.component" v-if="item.component" />
46
- <template v-else>
34
+ <component
35
+ v-if="item.component"
36
+ :is="item.component"
37
+ :active="active"
38
+ />
39
+ <button
40
+ v-else
41
+ :class="[
42
+ active ? 'bg-gray-100' : 'text-gray-900',
43
+ 'group flex w-full items-center rounded-md px-2 py-2 text-sm',
44
+ ]"
45
+ @click="item.onClick"
46
+ >
47
47
  <FeatherIcon
48
48
  v-if="item.icon"
49
49
  :name="item.icon"
@@ -53,17 +53,18 @@
53
53
  <span class="whitespace-nowrap">
54
54
  {{ item.label }}
55
55
  </span>
56
- </template>
57
- </button>
58
- </MenuItem>
59
- </div>
60
- </MenuItems>
61
- </transition>
56
+ </button>
57
+ </MenuItem>
58
+ </div>
59
+ </MenuItems>
60
+ </template>
61
+ </Popover>
62
62
  </Menu>
63
63
  </template>
64
64
 
65
65
  <script>
66
66
  import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
67
+ import Popover from './Popover.vue'
67
68
  import Button from './Button.vue'
68
69
  import FeatherIcon from './FeatherIcon.vue'
69
70
 
@@ -90,6 +91,7 @@ export default {
90
91
  MenuItem,
91
92
  Button,
92
93
  FeatherIcon,
94
+ Popover,
93
95
  },
94
96
  methods: {
95
97
  normalizeDropdownItem(option) {
@@ -128,6 +130,16 @@ export default {
128
130
  }
129
131
  })
130
132
  },
133
+ dropdownTransition() {
134
+ return {
135
+ enterActiveClass: 'transition duration-100 ease-out',
136
+ enterFromClass: 'transform scale-95 opacity-0',
137
+ enterToClass: 'transform scale-100 opacity-100',
138
+ leaveActiveClass: 'transition duration-75 ease-in',
139
+ leaveFromClass: 'transform scale-100 opacity-100',
140
+ leaveToClass: 'transform scale-95 opacity-0',
141
+ }
142
+ },
131
143
  },
132
144
  }
133
145
  </script>
@@ -201,16 +201,10 @@ export default {
201
201
  }
202
202
  },
203
203
  open() {
204
- if (this.isOpen) {
205
- return
206
- }
207
204
  this.isOpen = true
208
205
  this.$nextTick(() => this.setupPopper())
209
206
  },
210
207
  close() {
211
- if (!this.isOpen) {
212
- return
213
- }
214
208
  this.isOpen = false
215
209
  },
216
210
  onMouseover() {
@@ -48,7 +48,7 @@ export function createDocumentResource(options, vm) {
48
48
  doctype: options.doctype,
49
49
  name: options.name,
50
50
  doc: null,
51
- auto: true,
51
+ auto: options.auto || true,
52
52
  get: createResource(
53
53
  {
54
54
  url: 'frappe.client.get',
@@ -103,7 +103,7 @@ export function createDocumentResource(options, vm) {
103
103
  let methodOptions = options.whitelistedMethods[methodKey]
104
104
  if (typeof methodOptions == 'string') {
105
105
  methodOptions = {
106
- url: methodOptions,
106
+ method: methodOptions,
107
107
  }
108
108
  }
109
109
  let { method, onSuccess, ...otherOptions } = methodOptions
@@ -183,6 +183,11 @@ export function createDocumentResource(options, vm) {
183
183
  out.doc = transform(data)
184
184
  }
185
185
  })
186
+
187
+ if (out.auto) {
188
+ out.get.fetch()
189
+ }
190
+
186
191
  return out
187
192
  }
188
193
 
@@ -58,6 +58,7 @@ export function createResource(options, vm) {
58
58
  out.params = params
59
59
  out.previousData = out.data ? JSON.parse(JSON.stringify(out.data)) : null
60
60
  out.loading = true
61
+ out.error = null
61
62
 
62
63
  if (options.onFetch) {
63
64
  options.onFetch.call(vm, out.params)
@@ -21,7 +21,7 @@ function createMixin() {
21
21
  let debugInfo = `${this.$options.name} (${
22
22
  this.$options.__file || ''
23
23
  })`
24
- if (import.meta.env.DEV) {
24
+ if (process.env.NODE_ENV === 'development') {
25
25
  console.warn('Failed to parse pageMeta in', debugInfo)
26
26
  }
27
27
  return null