@revojs/ui 0.1.58
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/breadcrumb.d.ts +4 -0
- package/dist/components/breadcrumb.js +1 -0
- package/dist/components/button.d.ts +18 -0
- package/dist/components/button.js +1 -0
- package/dist/components/card.d.ts +5 -0
- package/dist/components/card.js +1 -0
- package/dist/components/checkbox.d.ts +8 -0
- package/dist/components/checkbox.js +1 -0
- package/dist/components/collection.d.ts +6 -0
- package/dist/components/collection.js +1 -0
- package/dist/components/container.d.ts +4 -0
- package/dist/components/container.js +1 -0
- package/dist/components/control.d.ts +1 -0
- package/dist/components/control.js +1 -0
- package/dist/components/counter.d.ts +8 -0
- package/dist/components/counter.js +1 -0
- package/dist/components/dialog.d.ts +6 -0
- package/dist/components/dialog.js +1 -0
- package/dist/components/field.d.ts +7 -0
- package/dist/components/field.js +1 -0
- package/dist/components/heading.d.ts +7 -0
- package/dist/components/heading.js +1 -0
- package/dist/components/icon.d.ts +3 -0
- package/dist/components/icon.js +1 -0
- package/dist/components/input.d.ts +12 -0
- package/dist/components/input.js +1 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +1 -0
- package/dist/components/navigate.d.ts +7 -0
- package/dist/components/navigate.js +1 -0
- package/dist/components/popover.d.ts +10 -0
- package/dist/components/popover.js +1 -0
- package/dist/components/progress.d.ts +5 -0
- package/dist/components/progress.js +1 -0
- package/dist/components/radio.d.ts +10 -0
- package/dist/components/radio.js +1 -0
- package/dist/components/range.d.ts +8 -0
- package/dist/components/range.js +1 -0
- package/dist/components/rating.d.ts +8 -0
- package/dist/components/rating.js +1 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.js +1 -0
- package/dist/components/separator.d.ts +11 -0
- package/dist/components/separator.js +1 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +1 -0
- package/dist/components/upload.d.ts +10 -0
- package/dist/components/upload.js +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +1 -0
- package/dist/module/index.d.ts +35 -0
- package/dist/module/index.js +123 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/vue/components/breadcrumb.vue +20 -0
- package/dist/vue/components/button.vue +124 -0
- package/dist/vue/components/card.vue +53 -0
- package/dist/vue/components/checkbox.vue +54 -0
- package/dist/vue/components/collection.vue +51 -0
- package/dist/vue/components/container.vue +19 -0
- package/dist/vue/components/counter.vue +61 -0
- package/dist/vue/components/dialog.vue +76 -0
- package/dist/vue/components/field.vue +38 -0
- package/dist/vue/components/heading.vue +34 -0
- package/dist/vue/components/icon.vue +49 -0
- package/dist/vue/components/input.vue +82 -0
- package/dist/vue/components/link.vue +33 -0
- package/dist/vue/components/navigate.vue +30 -0
- package/dist/vue/components/popover.vue +123 -0
- package/dist/vue/components/progress.vue +44 -0
- package/dist/vue/components/radio.vue +59 -0
- package/dist/vue/components/range.vue +56 -0
- package/dist/vue/components/rating.vue +56 -0
- package/dist/vue/components/select.vue +99 -0
- package/dist/vue/components/separator.vue +31 -0
- package/dist/vue/components/sheet.vue +71 -0
- package/dist/vue/components/switch.vue +72 -0
- package/dist/vue/components/upload.vue +133 -0
- package/dist/vue/index.d.ts +25 -0
- package/dist/vue/index.js +25 -0
- package/package.json +46 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex w-full flex-col gap-2">
|
|
3
|
+
<span v-if="label" class="text-sm font-medium">
|
|
4
|
+
{{ label }}<span v-if="required" aria-hidden="true"> *</span>
|
|
5
|
+
</span>
|
|
6
|
+
|
|
7
|
+
<div
|
|
8
|
+
class="relative flex min-h-32 flex-col items-center justify-center gap-3 border border-dashed p-5 text-center transition-colors"
|
|
9
|
+
:class="[
|
|
10
|
+
config.radius,
|
|
11
|
+
`border-${config.light.input}`,
|
|
12
|
+
variants[state],
|
|
13
|
+
`dark:border-${config.dark.input}`,
|
|
14
|
+
interactionVariants[interaction],
|
|
15
|
+
]"
|
|
16
|
+
@dragenter.prevent="isOver = true"
|
|
17
|
+
@dragover.prevent="isOver = true"
|
|
18
|
+
@dragleave="leave"
|
|
19
|
+
@drop.prevent="drop"
|
|
20
|
+
>
|
|
21
|
+
<template v-if="modelValue">
|
|
22
|
+
<span class="max-w-full truncate text-sm">
|
|
23
|
+
{{ "name" in modelValue ? modelValue.name : "File selected" }}
|
|
24
|
+
</span>
|
|
25
|
+
|
|
26
|
+
<Button label="Remove" variant="ghost" :disabled="disabled" @click="remove" />
|
|
27
|
+
</template>
|
|
28
|
+
<template v-else>
|
|
29
|
+
<span class="text-sm opacity-60"> Drag and drop a file here </span>
|
|
30
|
+
|
|
31
|
+
<Button label="Browse files" variant="outline" :disabled="disabled" @click="input?.click()" />
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<input
|
|
35
|
+
ref="input"
|
|
36
|
+
class="sr-only"
|
|
37
|
+
type="file"
|
|
38
|
+
:accept="accept"
|
|
39
|
+
:name="name"
|
|
40
|
+
:required="required"
|
|
41
|
+
:disabled="disabled"
|
|
42
|
+
@change="change"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<span v-if="description" class="text-sm opacity-60">{{ description }}</span>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
import config from "#config/ui";
|
|
52
|
+
import { computed, ref, useTemplateRef } from "vue";
|
|
53
|
+
import type { ControlInteraction } from "../../components/control.ts";
|
|
54
|
+
import type { UploadState } from "../../components/upload.ts";
|
|
55
|
+
import Button from "./button.vue";
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
modelValue = undefined,
|
|
59
|
+
label = undefined,
|
|
60
|
+
description = undefined,
|
|
61
|
+
accept = undefined,
|
|
62
|
+
name = undefined,
|
|
63
|
+
required = false,
|
|
64
|
+
disabled = false,
|
|
65
|
+
} = defineProps<{
|
|
66
|
+
modelValue?: Blob | File;
|
|
67
|
+
label?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
accept?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
required?: boolean;
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
}>();
|
|
74
|
+
|
|
75
|
+
const emit = defineEmits<{
|
|
76
|
+
"update:modelValue": [value?: Blob | File];
|
|
77
|
+
}>();
|
|
78
|
+
|
|
79
|
+
const input = useTemplateRef("input");
|
|
80
|
+
|
|
81
|
+
const isOver = ref(false);
|
|
82
|
+
|
|
83
|
+
const interaction = computed<ControlInteraction>(() => (disabled ? "disabled" : "enabled"));
|
|
84
|
+
|
|
85
|
+
const state = computed<UploadState>(() => (isOver.value ? "over" : "idle"));
|
|
86
|
+
|
|
87
|
+
const interactionVariants: Record<ControlInteraction, string> = {
|
|
88
|
+
disabled: "opacity-50",
|
|
89
|
+
enabled: "",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const variants: Record<UploadState, Array<string>> = {
|
|
93
|
+
idle: [`bg-${config.light.muted}`, `dark:bg-${config.dark.muted}`],
|
|
94
|
+
over: [`bg-${config.light.accent}`, `dark:bg-${config.dark.accent}`],
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function change() {
|
|
98
|
+
const file = input.value?.files?.item(0);
|
|
99
|
+
|
|
100
|
+
if (file) {
|
|
101
|
+
emit("update:modelValue", file);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function drop(event: DragEvent) {
|
|
106
|
+
isOver.value = false;
|
|
107
|
+
|
|
108
|
+
if (!disabled) {
|
|
109
|
+
const file = event.dataTransfer?.files.item(0);
|
|
110
|
+
|
|
111
|
+
if (file) {
|
|
112
|
+
emit("update:modelValue", file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function leave(event: DragEvent) {
|
|
118
|
+
const element = event.currentTarget as HTMLElement;
|
|
119
|
+
const target = event.relatedTarget as Node | null;
|
|
120
|
+
|
|
121
|
+
if (!target || !element.contains(target)) {
|
|
122
|
+
isOver.value = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function remove() {
|
|
127
|
+
if (input.value) {
|
|
128
|
+
input.value.value = "";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
emit("update:modelValue", undefined);
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { default as Breadcrumb } from "./components/breadcrumb.vue";
|
|
2
|
+
export { default as Button } from "./components/button.vue";
|
|
3
|
+
export { default as Card } from "./components/card.vue";
|
|
4
|
+
export { default as Checkbox } from "./components/checkbox.vue";
|
|
5
|
+
export { default as Collection } from "./components/collection.vue";
|
|
6
|
+
export { default as Container } from "./components/container.vue";
|
|
7
|
+
export { default as Counter } from "./components/counter.vue";
|
|
8
|
+
export { default as Dialog } from "./components/dialog.vue";
|
|
9
|
+
export { default as Divider } from "./components/separator.vue";
|
|
10
|
+
export { default as Field } from "./components/field.vue";
|
|
11
|
+
export { default as Heading } from "./components/heading.vue";
|
|
12
|
+
export { default as Icon } from "./components/icon.vue";
|
|
13
|
+
export { default as Input } from "./components/input.vue";
|
|
14
|
+
export { default as Link } from "./components/link.vue";
|
|
15
|
+
export { default as Navigate } from "./components/navigate.vue";
|
|
16
|
+
export { default as Popover } from "./components/popover.vue";
|
|
17
|
+
export { default as Progress } from "./components/progress.vue";
|
|
18
|
+
export { default as Radio } from "./components/radio.vue";
|
|
19
|
+
export { default as Range } from "./components/range.vue";
|
|
20
|
+
export { default as Rating } from "./components/rating.vue";
|
|
21
|
+
export { default as Select } from "./components/select.vue";
|
|
22
|
+
export { default as Separator } from "./components/separator.vue";
|
|
23
|
+
export { default as Sheet } from "./components/sheet.vue";
|
|
24
|
+
export { default as Switch } from "./components/switch.vue";
|
|
25
|
+
export { default as Upload } from "./components/upload.vue";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Breadcrumb from "./components/breadcrumb.vue";
|
|
2
|
+
import Button from "./components/button.vue";
|
|
3
|
+
import Card from "./components/card.vue";
|
|
4
|
+
import Checkbox from "./components/checkbox.vue";
|
|
5
|
+
import Collection from "./components/collection.vue";
|
|
6
|
+
import Container from "./components/container.vue";
|
|
7
|
+
import Counter from "./components/counter.vue";
|
|
8
|
+
import Dialog from "./components/dialog.vue";
|
|
9
|
+
import Divider, { default as Separator } from "./components/separator.vue";
|
|
10
|
+
import Field from "./components/field.vue";
|
|
11
|
+
import Heading from "./components/heading.vue";
|
|
12
|
+
import Icon from "./components/icon.vue";
|
|
13
|
+
import Input from "./components/input.vue";
|
|
14
|
+
import Link from "./components/link.vue";
|
|
15
|
+
import Navigate from "./components/navigate.vue";
|
|
16
|
+
import Popover from "./components/popover.vue";
|
|
17
|
+
import Progress from "./components/progress.vue";
|
|
18
|
+
import Radio from "./components/radio.vue";
|
|
19
|
+
import Range from "./components/range.vue";
|
|
20
|
+
import Rating from "./components/rating.vue";
|
|
21
|
+
import Select from "./components/select.vue";
|
|
22
|
+
import Sheet from "./components/sheet.vue";
|
|
23
|
+
import Switch from "./components/switch.vue";
|
|
24
|
+
import Upload from "./components/upload.vue";
|
|
25
|
+
export { Breadcrumb, Button, Card, Checkbox, Collection, Container, Counter, Dialog, Divider, Field, Heading, Icon, Input, Link, Navigate, Popover, Progress, Radio, Range, Rating, Select, Separator, Sheet, Switch, Upload };
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@revojs/ui",
|
|
3
|
+
"version": "0.1.58",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/tellua/revojs.git"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./module": {
|
|
22
|
+
"types": "./dist/module/index.d.ts",
|
|
23
|
+
"import": "./dist/module/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./vue": {
|
|
26
|
+
"types": "./dist/vue/index.d.ts",
|
|
27
|
+
"import": "./dist/vue/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "vite build",
|
|
32
|
+
"watch": "vite build --watch"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@iconify/types": "^2.0.0",
|
|
36
|
+
"@iconify/utils": "^3.1.7",
|
|
37
|
+
"revojs": "*"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@revojs/tsconfig": "*",
|
|
41
|
+
"@vitejs/plugin-vue": "^6.0.9"
|
|
42
|
+
},
|
|
43
|
+
"optionalDependencies": {
|
|
44
|
+
"vue": "^3.5.42"
|
|
45
|
+
}
|
|
46
|
+
}
|