frappe-ui 0.0.23 → 0.0.26
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 +1 -1
- package/src/components/Badge.vue +8 -0
- package/src/components/Input.vue +9 -4
- package/src/components/Popover.vue +1 -0
- package/src/index.js +1 -0
- package/src/utils/resources.js +16 -2
package/package.json
CHANGED
package/src/components/Badge.vue
CHANGED
|
@@ -13,6 +13,14 @@ export default {
|
|
|
13
13
|
computed: {
|
|
14
14
|
classes() {
|
|
15
15
|
let color = this.color
|
|
16
|
+
if (typeof color === 'object') {
|
|
17
|
+
for (let key in color) {
|
|
18
|
+
if (color[key]) {
|
|
19
|
+
color = key
|
|
20
|
+
break
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
16
24
|
if (!color && this.status) {
|
|
17
25
|
color = {
|
|
18
26
|
Pending: 'yellow',
|
package/src/components/Input.vue
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
)
|
|
14
14
|
"
|
|
15
15
|
v-bind="inputAttributes"
|
|
16
|
-
class="placeholder-gray-500"
|
|
16
|
+
class="placeholder-gray-500 border-gray-400"
|
|
17
17
|
ref="input"
|
|
18
18
|
:class="[
|
|
19
19
|
{
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
<textarea
|
|
31
31
|
v-if="type === 'textarea'"
|
|
32
32
|
v-bind="inputAttributes"
|
|
33
|
+
:placeholder="placeholder"
|
|
34
|
+
class="placeholder-gray-500"
|
|
33
35
|
:class="['block w-full resize-none form-textarea', inputClass]"
|
|
34
36
|
ref="input"
|
|
35
37
|
:value="passedInputValue"
|
|
36
38
|
:disabled="disabled"
|
|
37
39
|
:rows="rows || 3"
|
|
38
|
-
@blur="$emit('blur', $event)"
|
|
39
40
|
></textarea>
|
|
40
41
|
<select
|
|
41
42
|
v-bind="inputAttributes"
|
|
@@ -114,7 +115,7 @@ export default {
|
|
|
114
115
|
type: String,
|
|
115
116
|
},
|
|
116
117
|
},
|
|
117
|
-
emits: ['
|
|
118
|
+
emits: ['input', 'change', 'update:modelValue'],
|
|
118
119
|
methods: {
|
|
119
120
|
focus() {
|
|
120
121
|
this.$refs.input.focus()
|
|
@@ -139,13 +140,17 @@ export default {
|
|
|
139
140
|
return this.modelValue || null
|
|
140
141
|
},
|
|
141
142
|
inputAttributes() {
|
|
143
|
+
let attrs = {}
|
|
142
144
|
let onInput = (e) => {
|
|
143
145
|
this.$emit('input', this.getInputValue(e))
|
|
144
146
|
}
|
|
145
147
|
if (this.debounce) {
|
|
146
148
|
onInput = debounce(onInput, this.debounce)
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
if (this.type == 'checkbox') {
|
|
151
|
+
attrs.checked = this.passedInputValue
|
|
152
|
+
}
|
|
153
|
+
return Object.assign(attrs, this.$attrs, {
|
|
149
154
|
onInput,
|
|
150
155
|
onChange: (e) => {
|
|
151
156
|
this.$emit('change', this.getInputValue(e))
|
package/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { default as onOutsideClickDirective } from './directives/onOutsideClick.
|
|
|
28
28
|
// utilities
|
|
29
29
|
export { default as call, createCall } from './utils/call.js'
|
|
30
30
|
export { default as debounce } from './utils/debounce.js'
|
|
31
|
+
export { createResource } from './utils/resources.js'
|
|
31
32
|
|
|
32
33
|
// plugin
|
|
33
34
|
export { default as FrappeUI } from './utils/plugin.js'
|
package/src/utils/resources.js
CHANGED
|
@@ -81,7 +81,7 @@ export function createResource(options, vm, getResource) {
|
|
|
81
81
|
|
|
82
82
|
try {
|
|
83
83
|
let data = await resourceFetcher(options.method, params || options.params)
|
|
84
|
-
out.data = data
|
|
84
|
+
out.data = transform(data)
|
|
85
85
|
out.fetched = true
|
|
86
86
|
for (let fn of successFunctions) {
|
|
87
87
|
if (fn) {
|
|
@@ -136,7 +136,17 @@ export function createResource(options, vm, getResource) {
|
|
|
136
136
|
if (typeof data === 'function') {
|
|
137
137
|
data = data.call(vm, out.data)
|
|
138
138
|
}
|
|
139
|
-
out.data = data
|
|
139
|
+
out.data = transform(data)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function transform(data) {
|
|
143
|
+
if (options.transform) {
|
|
144
|
+
let returnValue = options.transform.call(vm, data)
|
|
145
|
+
if (typeof returnValue != null) {
|
|
146
|
+
return returnValue
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return data
|
|
140
150
|
}
|
|
141
151
|
|
|
142
152
|
if (cacheKey && !cached[cacheKey]) {
|
|
@@ -165,7 +175,9 @@ export function createDocumentResource(options, vm) {
|
|
|
165
175
|
},
|
|
166
176
|
onSuccess(data) {
|
|
167
177
|
out.doc = transform(data)
|
|
178
|
+
options.setValue?.onSuccess?.call(vm, data)
|
|
168
179
|
},
|
|
180
|
+
onError: options.setValue?.onError,
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
let out = reactive({
|
|
@@ -206,7 +218,9 @@ export function createDocumentResource(options, vm) {
|
|
|
206
218
|
},
|
|
207
219
|
onSuccess() {
|
|
208
220
|
out.doc = null
|
|
221
|
+
options.delete?.onSuccess?.call(vm, data)
|
|
209
222
|
},
|
|
223
|
+
onError: options.delete?.onError,
|
|
210
224
|
},
|
|
211
225
|
vm
|
|
212
226
|
),
|