@veritree/ui 0.26.0 → 0.26.1-0
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/index.js +63 -75
- package/mixins/floating-ui-content.js +1 -1
- package/mixins/floating-ui-item.js +8 -6
- package/mixins/floating-ui.js +8 -1
- package/mixins/form-control-icon.js +3 -3
- package/mixins/form-control.js +9 -14
- package/nuxt.js +30 -26
- package/package.json +14 -6
- package/src/components/Alert/VTAlert.vue +55 -14
- package/src/components/Avatar/VTAvatarImage.vue +6 -26
- package/src/components/Button/VTButton.vue +25 -11
- package/src/components/Checkbox/VTCheckbox.vue +134 -0
- package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
- package/src/components/Checkbox/VTCheckboxText.vue +20 -0
- package/src/components/Dialog/VTDialog.vue +22 -23
- package/src/components/Dialog/VTDialogClose.vue +1 -1
- package/src/components/Dialog/VTDialogContent.vue +13 -5
- package/src/components/Dialog/VTDialogFooter.vue +8 -2
- package/src/components/Dialog/VTDialogHeader.vue +2 -1
- package/src/components/Dialog/VTDialogMain.vue +1 -1
- package/src/components/Dialog/VTDialogOverlay.vue +5 -1
- package/src/components/Disclosure/VTDisclosureContent.vue +1 -1
- package/src/components/Disclosure/VTDisclosureDetails.vue +1 -1
- package/src/components/Disclosure/VTDisclosureHeader.vue +2 -2
- package/src/components/Disclosure/VTDisclosureIcon.vue +1 -1
- package/src/components/Drawer/VTDrawer.vue +6 -15
- package/src/components/Drawer/VTDrawerClose.vue +5 -5
- package/src/components/Drawer/VTDrawerContent.vue +10 -10
- package/src/components/Drawer/VTDrawerFooter.vue +4 -4
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +0 -6
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +10 -1
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +7 -16
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +5 -1
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +1 -10
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +2 -4
- package/src/components/Form/VTFormFeedback.vue +7 -1
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +2 -5
- package/src/components/Form/VTInputIcon.vue +1 -2
- package/src/components/Form/VTInputPassword.vue +14 -5
- package/src/components/Form/VTTextarea.vue +3 -6
- package/src/components/Image/VTImage.vue +61 -18
- package/src/components/Listbox/VTListbox.vue +72 -5
- package/src/components/Listbox/VTListboxContent.vue +0 -1
- package/src/components/Listbox/VTListboxItem.vue +11 -1
- package/src/components/Listbox/VTListboxLabel.vue +3 -4
- package/src/components/Listbox/VTListboxList.vue +3 -1
- package/src/components/Listbox/VTListboxSearch.vue +7 -6
- package/src/components/Listbox/VTListboxTrigger.vue +2 -0
- package/src/components/Popover/VTPopoverContent.vue +3 -3
- package/src/components/Popover/VTPopoverDivider.vue +1 -1
- package/src/components/Popover/VTPopoverItem.vue +6 -2
- package/src/components/ProgressBar/VTProgressBar.vue +21 -3
- package/src/components/Tabs/VTTab.vue +6 -5
- package/src/components/Tabs/VTTabGroup.vue +67 -9
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Tooltip/VTTooltipTrigger.vue +3 -5
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +31 -13
- package/src/utils/components.js +18 -0
- package/src/utils/images.js +18 -25
- package/src/components/Input/VTInput.vue +0 -82
- package/src/components/Input/VTInputDate.vue +0 -36
- package/src/components/Input/VTInputFile.vue +0 -60
- package/src/components/Input/VTInputUpload.vue +0 -54
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
package/src/utils/images.js
CHANGED
|
@@ -3,42 +3,35 @@ export const handleImageResizing = (url, width) => {
|
|
|
3
3
|
if (!url) {
|
|
4
4
|
return '';
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
let cdn;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// new code
|
|
11
|
+
if (typeof url === 'string' && url.includes('cloudfront.net/')) {
|
|
12
|
+
cdn = url;
|
|
13
|
+
} else {
|
|
14
|
+
// old code
|
|
15
|
+
if (typeof url === 'object') {
|
|
16
|
+
cdn = url.cdn_url;
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
if (typeof url === 'string') {
|
|
20
|
+
cdn = JSON.parse(url).cdn_url;
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
const base64String = cdn.split('net/');
|
|
19
25
|
const firstPart = base64String[0];
|
|
26
|
+
const decodedString = JSON.parse(atob(base64String[1]));
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
// don't worry, it seems to be about NodeJS and not about
|
|
23
|
-
// browsers.
|
|
24
|
-
//
|
|
25
|
-
// Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
|
|
26
|
-
const decodedString = JSON.parse(atob(base64String[1]));
|
|
27
|
-
|
|
28
|
-
width
|
|
29
|
-
? (decodedString.edits.resize.width = width)
|
|
30
|
-
: (decodedString.edits.resize.width = 450);
|
|
28
|
+
decodedString.edits.resize.width = width ?? 450;
|
|
31
29
|
|
|
32
|
-
// if btoa is crossed and your editor says is not supported,
|
|
33
|
-
// don't worry, it seems to be about NodeJS and not about
|
|
34
|
-
// browsers.
|
|
35
|
-
//
|
|
36
|
-
// Details: https://developer.mozilla.org/en-US/docs/Web/API/atob
|
|
37
30
|
const encodedString = btoa(JSON.stringify(decodedString));
|
|
38
31
|
const encodedUrl = `${firstPart}net/${encodedString}`;
|
|
39
32
|
|
|
40
|
-
return encodedUrl
|
|
41
|
-
} catch(error) {
|
|
33
|
+
return encodedUrl;
|
|
34
|
+
} catch (error) {
|
|
42
35
|
console.error(`${error} in ${cdn}`);
|
|
43
36
|
}
|
|
44
|
-
};
|
|
37
|
+
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<input
|
|
3
|
-
:class="classes"
|
|
4
|
-
class="form-control"
|
|
5
|
-
:data-theme="theme"
|
|
6
|
-
:type="type"
|
|
7
|
-
:value="value"
|
|
8
|
-
v-on="listeners"
|
|
9
|
-
/>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
export default {
|
|
14
|
-
name: 'VTInput',
|
|
15
|
-
|
|
16
|
-
props: {
|
|
17
|
-
lazy: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
default: false,
|
|
20
|
-
},
|
|
21
|
-
type: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: 'text',
|
|
24
|
-
},
|
|
25
|
-
theme: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: null,
|
|
28
|
-
validator(value) {
|
|
29
|
-
return ['dark'].includes(value);
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
variant: {
|
|
33
|
-
type: [String, Object],
|
|
34
|
-
default: '',
|
|
35
|
-
validator(value) {
|
|
36
|
-
if (value === '' || typeof value === 'object') {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return ['success', 'warning', 'error'].includes(value);
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
value: {
|
|
44
|
-
type: [String, Number, Object, Array],
|
|
45
|
-
default: null,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
computed: {
|
|
50
|
-
classes() {
|
|
51
|
-
const classes = {};
|
|
52
|
-
|
|
53
|
-
if (this.variant) {
|
|
54
|
-
classes[`form-control--${this.variant}`] = true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return classes;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
listeners() {
|
|
61
|
-
// `Object.assign` merges objects together to form a new object
|
|
62
|
-
return Object.assign(
|
|
63
|
-
{},
|
|
64
|
-
// We add all the listeners from the parent
|
|
65
|
-
this.$listeners,
|
|
66
|
-
// Then we can add custom listeners or override the
|
|
67
|
-
// behavior of some listeners.
|
|
68
|
-
{
|
|
69
|
-
// This ensures that the component works with v-model
|
|
70
|
-
input: (event) => {
|
|
71
|
-
if (this.lazy) return;
|
|
72
|
-
this.$emit('input', event.target.value);
|
|
73
|
-
},
|
|
74
|
-
blur: (event) => {
|
|
75
|
-
this.$emit('blur', event);
|
|
76
|
-
},
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
</script>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<VTInput v-model="date" type="date" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
import VTInput from './VTInput.vue';
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
name: 'VTInputDate',
|
|
10
|
-
|
|
11
|
-
components: { VTInput },
|
|
12
|
-
|
|
13
|
-
model: {
|
|
14
|
-
prop: 'value',
|
|
15
|
-
event: 'input',
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
props: {
|
|
19
|
-
value: {
|
|
20
|
-
type: String,
|
|
21
|
-
default: '',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
computed: {
|
|
26
|
-
date: {
|
|
27
|
-
get() {
|
|
28
|
-
return this.$date.format(this.value, 'YYYY-MM-DD');
|
|
29
|
-
},
|
|
30
|
-
set(newDate) {
|
|
31
|
-
this.$emit('input', newDate);
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
</script>
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="flex items-stretch gap-2">
|
|
3
|
-
<VTInput
|
|
4
|
-
ref="input"
|
|
5
|
-
type="file"
|
|
6
|
-
:value="value"
|
|
7
|
-
:theme="theme"
|
|
8
|
-
v-bind="$attrs"
|
|
9
|
-
@change="onChange"
|
|
10
|
-
/>
|
|
11
|
-
<VTButton :theme="theme" @click.stop="onButtonClick">Browse</VTButton>
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import VTButton from '../Button/VTButton.vue';
|
|
17
|
-
import VTInput from './VTInput.vue';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'VTInputFile',
|
|
21
|
-
|
|
22
|
-
components: {
|
|
23
|
-
VTInput,
|
|
24
|
-
VTButton,
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
inheritAttrs: false,
|
|
28
|
-
|
|
29
|
-
props: {
|
|
30
|
-
theme: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: null,
|
|
33
|
-
validator(value) {
|
|
34
|
-
return ['dark'].includes(value);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
multiple: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
data() {
|
|
44
|
-
return {
|
|
45
|
-
value: null,
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
methods: {
|
|
50
|
-
onChange(event) {
|
|
51
|
-
this.value = this.$refs.input.$el.value;
|
|
52
|
-
this.$emit('change', event);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
onButtonClick() {
|
|
56
|
-
this.$refs.input.$el.click();
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
</script>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<label
|
|
3
|
-
class="flex h-full w-full flex-col items-center justify-center rounded border-2 border-dotted border-white p-4 text-center hover:border-fl-500 hover:bg-fd-500"
|
|
4
|
-
:class="{ 'border-fl-500 bg-fd-500': isDraggingOver }"
|
|
5
|
-
@drop.prevent="onDrop"
|
|
6
|
-
@dragover.prevent="onDragOver"
|
|
7
|
-
@dragleave.prevent="onDragLeave"
|
|
8
|
-
>
|
|
9
|
-
<IconImagePlaceholder class="mb-3" />
|
|
10
|
-
<span>Drop your images here, or click to browse</span>
|
|
11
|
-
<VTInput type="file" class="sr-only" v-bind="$attrs" @change="onChange" />
|
|
12
|
-
</label>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script>
|
|
16
|
-
import { IconImagePlaceholder } from '@veritree/icons';
|
|
17
|
-
import VTInput from './VTInput.vue';
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
name: 'VTInputFile',
|
|
21
|
-
|
|
22
|
-
components: {
|
|
23
|
-
VTInput,
|
|
24
|
-
IconImagePlaceholder,
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
inheritAttrs: false,
|
|
28
|
-
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
isDraggingOver: false,
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
methods: {
|
|
36
|
-
onDrop(event) {
|
|
37
|
-
this.isDraggingOver = false;
|
|
38
|
-
this.$emit('drop', event);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
onDragOver() {
|
|
42
|
-
this.isDraggingOver = true;
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
onDragLeave() {
|
|
46
|
-
this.isDraggingOver = false;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
onChange(event) {
|
|
50
|
-
this.$emit('change', event);
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
</script>
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition
|
|
3
|
-
enter-active-class="duration-300 ease-out"
|
|
4
|
-
enter-class="transform opacity-0"
|
|
5
|
-
enter-to-class="opacity-100"
|
|
6
|
-
leave-active-class="duration-300 ease-in"
|
|
7
|
-
leave-class="opacity-100"
|
|
8
|
-
leave-to-class="transform opacity-0"
|
|
9
|
-
@after-enter="afterEnter"
|
|
10
|
-
@after-leave="afterLeave"
|
|
11
|
-
>
|
|
12
|
-
<div
|
|
13
|
-
v-if="visible"
|
|
14
|
-
class="bg-fd-700/75 fixed inset-0 z-50 flex flex-col justify-center"
|
|
15
|
-
tabindex="-1"
|
|
16
|
-
@keyup.esc="close"
|
|
17
|
-
@click="close"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
class="relative mx-auto flex max-w-lg flex-col justify-center rounded bg-white"
|
|
21
|
-
@click.stop
|
|
22
|
-
>
|
|
23
|
-
<div class="absolute right-4 top-4">
|
|
24
|
-
<VTButton variant="icon" @click.prevent="close"
|
|
25
|
-
><IconClose class="h-4 w-4"
|
|
26
|
-
/></VTButton>
|
|
27
|
-
</div>
|
|
28
|
-
<slot></slot>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</transition>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script>
|
|
35
|
-
import { IconClose } from '@veritree/icons';
|
|
36
|
-
import VTButton from '../Button/VTButton.vue';
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
name: 'VTModal',
|
|
40
|
-
|
|
41
|
-
components: { IconClose, VTButton },
|
|
42
|
-
|
|
43
|
-
model: {
|
|
44
|
-
prop: 'visible',
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
props: {
|
|
48
|
-
visible: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
methods: {
|
|
55
|
-
close() {
|
|
56
|
-
this.$emit('input', false);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
afterEnter() {
|
|
60
|
-
this.$emit('shown');
|
|
61
|
-
this.$nextTick(() => this.$el.focus());
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
afterLeave() {
|
|
65
|
-
this.$emit('hidden');
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
</script>
|
package/src/utils/genId.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Generate id
|
|
2
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
|
|
3
|
-
let gen = null;
|
|
4
|
-
|
|
5
|
-
function* idMaker() {
|
|
6
|
-
let index = 0;
|
|
7
|
-
while (true) yield index++;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const genId = () => {
|
|
11
|
-
if (!gen) gen = idMaker();
|
|
12
|
-
return gen.next().value;
|
|
13
|
-
};
|