@bagelink/vue 0.0.170 → 0.0.182
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/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/DropDown.vue.d.ts.map +1 -1
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts +15 -8
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/formkit/FileUploader.vue.d.ts +5 -0
- package/dist/components/formkit/FileUploader.vue.d.ts.map +1 -1
- package/dist/index.cjs +133 -64
- package/dist/index.mjs +133 -64
- package/dist/style.css +64 -37
- package/package.json +1 -1
- package/src/components/DataPreview.vue +33 -15
- package/src/components/DropDown.vue +35 -33
- package/src/components/TableSchema.vue +82 -84
- package/src/components/form/inputs/Checkbox.vue +21 -18
- package/src/components/form/inputs/TextInput.vue +70 -8
- package/src/components/formkit/FileUploader.vue +7 -4
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<label class="primary-checkbox">
|
|
3
|
+
<input type="checkbox" v-model="val" >
|
|
4
|
+
<span>
|
|
5
|
+
<MaterialIcon icon="check" />
|
|
6
|
+
</span>
|
|
7
|
+
</label>
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
|
-
import { watch } from
|
|
12
|
-
import { MaterialIcon } from
|
|
11
|
+
import { watch } from 'vue';
|
|
12
|
+
import { MaterialIcon } from '@bagelink/vue';
|
|
13
13
|
|
|
14
14
|
const props = defineProps({
|
|
15
|
-
|
|
15
|
+
modelValue: Boolean,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const emits = defineEmits([
|
|
18
|
+
const emits = defineEmits(['update:modelValue']);
|
|
19
19
|
|
|
20
20
|
let val = $ref<boolean>();
|
|
21
21
|
|
|
22
22
|
watch(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
() => props.modelValue,
|
|
24
|
+
(v: boolean) => {
|
|
25
|
+
if (v === undefined || v === val) return;
|
|
26
|
+
console.log('v', v);
|
|
27
|
+
val = v;
|
|
28
|
+
},
|
|
29
|
+
{ immediate: true },
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
watch(
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
() => val,
|
|
34
|
+
(v) => {
|
|
35
|
+
if (v !== props.modelValue) emits('update:modelValue', v);
|
|
36
|
+
},
|
|
34
37
|
);
|
|
35
38
|
</script>
|
|
36
39
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="bagel-input"
|
|
4
|
-
:class="{ small }"
|
|
4
|
+
:class="{ small, shrink, toggleEdit, editMode }"
|
|
5
5
|
:title="title"
|
|
6
6
|
>
|
|
7
7
|
<label :for="id">
|
|
@@ -9,20 +9,28 @@
|
|
|
9
9
|
<input
|
|
10
10
|
:id="id"
|
|
11
11
|
v-model="inputVal"
|
|
12
|
-
type="
|
|
12
|
+
:type="type"
|
|
13
|
+
ref="input"
|
|
13
14
|
:placeholder="placeholder || label"
|
|
14
|
-
:
|
|
15
|
+
:disabled="!editMode"
|
|
15
16
|
:required="required"
|
|
16
17
|
:pattern="pattern"
|
|
17
18
|
v-bind="nativeInputAttrs"
|
|
19
|
+
@dblclick="toggleEditAction"
|
|
20
|
+
@keydown.enter="toggleEditAction"
|
|
18
21
|
>
|
|
19
22
|
</label>
|
|
23
|
+
<Btn
|
|
24
|
+
class="toggleEditBtn"
|
|
25
|
+
v-if="toggleEdit" thin @click="toggleEditAction" :icon="editMode?'check':'edit'"
|
|
26
|
+
flat
|
|
27
|
+
/>
|
|
20
28
|
</div>
|
|
21
29
|
</template>
|
|
22
30
|
|
|
23
31
|
<script setup lang="ts">
|
|
24
32
|
import { watch } from 'vue';
|
|
25
|
-
import { debounce } from '@bagelink/vue';
|
|
33
|
+
import { debounce, Btn } from '@bagelink/vue';
|
|
26
34
|
|
|
27
35
|
const emit = defineEmits(['update:modelValue', 'debounce']);
|
|
28
36
|
const props = withDefaults(
|
|
@@ -30,24 +38,43 @@ const props = withDefaults(
|
|
|
30
38
|
id?: string;
|
|
31
39
|
title?: string;
|
|
32
40
|
placeholder?: string;
|
|
33
|
-
modelValue?: string;
|
|
41
|
+
modelValue?: string | number;
|
|
34
42
|
label?: string;
|
|
35
|
-
editMode?: boolean;
|
|
36
43
|
small?: boolean;
|
|
37
44
|
required?: boolean;
|
|
38
45
|
pattern?: string;
|
|
46
|
+
shrink?: boolean;
|
|
47
|
+
toggleEdit?: boolean;
|
|
48
|
+
type?: string;
|
|
39
49
|
nativeInputAttrs?: Record<string, any>;
|
|
40
50
|
}>(),
|
|
41
51
|
{
|
|
42
|
-
|
|
52
|
+
type: 'text',
|
|
53
|
+
toggleEdit: false,
|
|
43
54
|
modelValue: '',
|
|
44
55
|
},
|
|
45
56
|
);
|
|
46
|
-
let inputVal = $ref<string>();
|
|
57
|
+
let inputVal = $ref<string|number>();
|
|
58
|
+
let editMode = $ref<boolean>(!props.toggleEdit);
|
|
59
|
+
|
|
60
|
+
const input = $ref<HTMLInputElement>();
|
|
61
|
+
|
|
62
|
+
const toggleEditAction = () => {
|
|
63
|
+
if (editMode) {
|
|
64
|
+
editMode = false;
|
|
65
|
+
emit('debounce', inputVal);
|
|
66
|
+
emit('update:modelValue', inputVal as string);
|
|
67
|
+
} else {
|
|
68
|
+
editMode = true;
|
|
69
|
+
setTimeout(() => input?.focus(), 10);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
47
72
|
|
|
48
73
|
watch(
|
|
49
74
|
() => inputVal,
|
|
50
75
|
(newVal) => {
|
|
76
|
+
if (props.toggleEdit) return;
|
|
77
|
+
if (newVal === props.modelValue) return;
|
|
51
78
|
emit('update:modelValue', newVal as string);
|
|
52
79
|
debounce(() => emit('debounce', newVal));
|
|
53
80
|
},
|
|
@@ -61,3 +88,38 @@ watch(
|
|
|
61
88
|
{ immediate: true },
|
|
62
89
|
);
|
|
63
90
|
</script>
|
|
91
|
+
|
|
92
|
+
<style>
|
|
93
|
+
.bagel-input.shrink, .bagel-input.shrink input{
|
|
94
|
+
min-width: unset !important;
|
|
95
|
+
/* width: auto; */
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
.bagel-input input[disabled]{
|
|
101
|
+
background: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.bagel-input.toggleEdit:hover {
|
|
105
|
+
background-color: var(--input-bg);
|
|
106
|
+
}
|
|
107
|
+
.bagel-input.small{
|
|
108
|
+
margin-bottom:0;
|
|
109
|
+
height: 30px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.toggleEditBtn{
|
|
113
|
+
position: absolute;
|
|
114
|
+
right: -24px;
|
|
115
|
+
top: 4;
|
|
116
|
+
opacity: 0;
|
|
117
|
+
}
|
|
118
|
+
.bagel-input:hover .toggleEditBtn, .bagel-input.editMode .toggleEditBtn{
|
|
119
|
+
opacity: 1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.bagel-input.small input{
|
|
123
|
+
height: 30px;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
type="file"
|
|
76
76
|
@change="handleFileInput"
|
|
77
77
|
ref="fileInputEl"
|
|
78
|
-
:multiple="
|
|
78
|
+
:multiple="computedMultiple"
|
|
79
79
|
>
|
|
80
80
|
</div>
|
|
81
81
|
</template>
|
|
@@ -109,18 +109,21 @@ const props = withDefaults(
|
|
|
109
109
|
context: Record<string, any>;
|
|
110
110
|
dragDropLabel?: string;
|
|
111
111
|
browseLabel?: string;
|
|
112
|
+
multiple?: boolean;
|
|
112
113
|
}>(),
|
|
113
114
|
{
|
|
114
115
|
dragDropLabel: 'Drag and drop your files here',
|
|
115
116
|
browseLabel: 'or browse',
|
|
117
|
+
multiple: false,
|
|
116
118
|
},
|
|
117
119
|
);
|
|
118
120
|
|
|
119
121
|
const computedDragDropLabel = $computed(() => props?.context?.attrs?.dragDropLabel || props?.dragDropLabel);
|
|
120
122
|
const computedDrowseLabel = $computed(() => props?.context?.attrs?.browseLabel || props?.browseLabel);
|
|
123
|
+
const computedMultiple = $computed(() => !!(props?.context?.attrs?.multiple || props?.multiple));
|
|
121
124
|
|
|
122
125
|
const allowUpload = $computed(() => {
|
|
123
|
-
const tooManyFiles = !
|
|
126
|
+
const tooManyFiles = !computedMultiple && files.length > 0;
|
|
124
127
|
return !tooManyFiles;
|
|
125
128
|
});
|
|
126
129
|
|
|
@@ -140,7 +143,7 @@ function animateCircle(e: DragEvent) {
|
|
|
140
143
|
function emitValue() {
|
|
141
144
|
// const fileValues = files.map((f) => f.serverFile?.id);
|
|
142
145
|
// console.log({ files });
|
|
143
|
-
if (!
|
|
146
|
+
if (!computedMultiple) return props.context?.node.input(files[0].serverFile);
|
|
144
147
|
// eslint-disable-next-line no-alert
|
|
145
148
|
return alert('not implemented');
|
|
146
149
|
}
|
|
@@ -199,7 +202,7 @@ async function addFiles(addedFiles: FileList) {
|
|
|
199
202
|
|
|
200
203
|
onMounted(() => {
|
|
201
204
|
dropZoneEl?.addEventListener('dragover', animateCircle);
|
|
202
|
-
if (!
|
|
205
|
+
if (!computedMultiple && props.context?.value) {
|
|
203
206
|
files.push({
|
|
204
207
|
serverFile: props.context?.value,
|
|
205
208
|
uploaded: true,
|