frappe-ui 0.0.33 → 0.0.35

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.33",
3
+ "version": "0.0.35",
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,100 @@
1
+ <template>
2
+ <Combobox v-model="selectedValue" v-slot="{ open: isComboBoxOpen }" nullable>
3
+ <Popover class="w-full">
4
+ <template #target="{ open: openPopover }">
5
+ <ComboboxInput
6
+ :displayValue="(option) => option?.label"
7
+ :class="['w-full form-input', { 'rounded-b-none': isComboBoxOpen }]"
8
+ type="text"
9
+ @change="
10
+ (e) => {
11
+ query = e.target.value
12
+ openPopover()
13
+ }
14
+ "
15
+ @focus="openPopover"
16
+ autocomplete="off"
17
+ />
18
+ </template>
19
+ <template #body>
20
+ <ComboboxOptions
21
+ :class="[
22
+ 'p-1.5 bg-white rounded-md shadow-md',
23
+ { 'rounded-t-none': isComboBoxOpen },
24
+ ]"
25
+ >
26
+ <ComboboxOption
27
+ as="template"
28
+ v-for="option in filteredOptions"
29
+ :key="option.value"
30
+ :value="option"
31
+ v-slot="{ active, selected }"
32
+ >
33
+ <li
34
+ :class="[
35
+ 'px-2.5 py-1.5 rounded-md text-base',
36
+ { 'bg-gray-100': active },
37
+ ]"
38
+ >
39
+ {{ option.label }}
40
+ </li>
41
+ </ComboboxOption>
42
+ <li
43
+ v-if="filteredOptions.length == 0"
44
+ class="px-2.5 py-1.5 rounded-md text-base text-gray-600"
45
+ >
46
+ No results found
47
+ </li>
48
+ </ComboboxOptions>
49
+ </template>
50
+ </Popover>
51
+ </Combobox>
52
+ </template>
53
+ <script>
54
+ import {
55
+ Combobox,
56
+ ComboboxInput,
57
+ ComboboxOptions,
58
+ ComboboxOption,
59
+ } from '@headlessui/vue'
60
+ import Popover from './Popover.vue'
61
+
62
+ export default {
63
+ name: 'Autocomplete',
64
+ props: ['modelValue', 'options'],
65
+ emits: ['update:modelValue'],
66
+ components: {
67
+ Popover,
68
+ Combobox,
69
+ ComboboxInput,
70
+ ComboboxOptions,
71
+ ComboboxOption,
72
+ },
73
+ data() {
74
+ return {
75
+ query: '',
76
+ }
77
+ },
78
+ computed: {
79
+ selectedValue: {
80
+ get() {
81
+ return this.modelValue
82
+ },
83
+ set(val) {
84
+ this.$emit('update:modelValue', val)
85
+ },
86
+ },
87
+ filteredOptions() {
88
+ if (!this.query) {
89
+ return this.options
90
+ }
91
+ return this.options.filter((option) => {
92
+ let searchTexts = [option.label, option.value]
93
+ return searchTexts.some((text) =>
94
+ (text || '').toLowerCase().includes(this.query.toLowerCase())
95
+ )
96
+ })
97
+ },
98
+ },
99
+ }
100
+ </script>
@@ -12,10 +12,11 @@ export default {
12
12
  validator(value) {
13
13
  const valid = validIcons.includes(value)
14
14
  if (!valid) {
15
- console.warn(
16
- `name property for feather-icon must be one of `,
17
- validIcons
15
+ console.groupCollapsed(
16
+ '[frappe-ui] name property for feather-icon must be one of '
18
17
  )
18
+ console.dir(validIcons)
19
+ console.groupEnd()
19
20
  }
20
21
  return valid
21
22
  },
@@ -31,6 +32,9 @@ export default {
31
32
  },
32
33
  render() {
33
34
  let icon = feather.icons[this.name]
35
+ if (!icon) {
36
+ icon = feather.icons['circle']
37
+ }
34
38
  return h(
35
39
  'svg',
36
40
  mergeProps(
@@ -2,7 +2,7 @@
2
2
  <div ref="reference">
3
3
  <div
4
4
  ref="target"
5
- class="inline-block"
5
+ :class="['inline-block', $attrs.class]"
6
6
  @click="updatePosition"
7
7
  @focusin="updatePosition"
8
8
  @keydown="updatePosition"
@@ -53,6 +53,7 @@ import { createPopper } from '@popperjs/core'
53
53
 
54
54
  export default {
55
55
  name: 'Popover',
56
+ inheritAttrs: false,
56
57
  props: {
57
58
  show: {
58
59
  default: undefined,
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // components
2
2
  export { default as Alert } from './components/Alert.vue'
3
+ export { default as Autocomplete } from './components/Autocomplete.vue'
3
4
  export { default as Avatar } from './components/Avatar.vue'
4
5
  export { default as Badge } from './components/Badge.vue'
5
6
  export { default as Button } from './components/Button.vue'
@@ -67,14 +67,14 @@ export function createResource(options, vm, getResource) {
67
67
  try {
68
68
  invalidMessage = await validateFunction.call(vm, out.params)
69
69
  if (invalidMessage && typeof invalidMessage == 'string') {
70
+ out.loading = false
70
71
  let error = new Error(invalidMessage)
71
72
  handleError(error, errorFunctions)
72
- out.loading = false
73
73
  return
74
74
  }
75
75
  } catch (error) {
76
- handleError(error, errorFunctions)
77
76
  out.loading = false
77
+ handleError(error, errorFunctions)
78
78
  return
79
79
  }
80
80
  }
@@ -92,6 +92,7 @@ export function createResource(options, vm, getResource) {
92
92
  handleError(error, errorFunctions)
93
93
  }
94
94
  out.loading = false
95
+ return out.data
95
96
  }
96
97
 
97
98
  function update({ method, params, auto }) {
@@ -117,7 +118,6 @@ export function createResource(options, vm, getResource) {
117
118
  }
118
119
 
119
120
  function handleError(error, errorFunctions) {
120
- console.error(error)
121
121
  if (out.previousData) {
122
122
  out.data = out.previousData
123
123
  }
@@ -127,6 +127,7 @@ export function createResource(options, vm, getResource) {
127
127
  fn.call(vm, error)
128
128
  }
129
129
  }
130
+ throw error
130
131
  }
131
132
 
132
133
  // usage: