@revojs/ui 0.2.9 → 0.2.11
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/container.d.ts +2 -0
- package/dist/components/icon.d.ts +1 -0
- package/dist/components/separator.d.ts +1 -6
- package/dist/components/stack.d.ts +12 -0
- package/dist/components/stack.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/module/index.js +10 -10
- package/dist/style.css +7 -0
- package/dist/vue/components/breadcrumb.vue +12 -4
- package/dist/vue/components/button.vue +8 -3
- package/dist/vue/components/card.vue +18 -15
- package/dist/vue/components/checkbox.vue +6 -5
- package/dist/vue/components/collection.vue +13 -5
- package/dist/vue/components/container.vue +4 -3
- package/dist/vue/components/counter.vue +4 -3
- package/dist/vue/components/dialog.vue +7 -1
- package/dist/vue/components/field.vue +4 -3
- package/dist/vue/components/icon.vue +6 -2
- package/dist/vue/components/input.vue +11 -5
- package/dist/vue/components/popover.vue +54 -56
- package/dist/vue/components/progress.vue +7 -6
- package/dist/vue/components/radio.vue +7 -6
- package/dist/vue/components/range.vue +7 -6
- package/dist/vue/components/rating.vue +6 -5
- package/dist/vue/components/select.vue +78 -95
- package/dist/vue/components/sheet.vue +10 -4
- package/dist/vue/components/stack.vue +70 -0
- package/dist/vue/components/switch.vue +8 -7
- package/dist/vue/components/upload.vue +9 -5
- package/dist/vue/index.d.ts +3 -1
- package/dist/vue/index.js +5 -2
- package/dist/vue/utilities/use-focus-trap.d.ts +2 -0
- package/dist/vue/utilities/use-focus-trap.js +34 -0
- package/dist/vue/utilities/use-scroll-lock.d.ts +2 -0
- package/dist/vue/utilities/use-scroll-lock.js +33 -0
- package/package.json +1 -1
package/dist/vue/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export { default as Collection } from "./components/collection.vue";
|
|
|
6
6
|
export { default as Container } from "./components/container.vue";
|
|
7
7
|
export { default as Counter } from "./components/counter.vue";
|
|
8
8
|
export { default as Dialog } from "./components/dialog.vue";
|
|
9
|
-
export { default as Divider } from "./components/separator.vue";
|
|
10
9
|
export { default as Field } from "./components/field.vue";
|
|
11
10
|
export { default as Heading } from "./components/heading.vue";
|
|
12
11
|
export { default as Icon } from "./components/icon.vue";
|
|
@@ -21,5 +20,8 @@ export { default as Rating } from "./components/rating.vue";
|
|
|
21
20
|
export { default as Select } from "./components/select.vue";
|
|
22
21
|
export { default as Separator } from "./components/separator.vue";
|
|
23
22
|
export { default as Sheet } from "./components/sheet.vue";
|
|
23
|
+
export { default as Stack } from "./components/stack.vue";
|
|
24
24
|
export { default as Switch } from "./components/switch.vue";
|
|
25
25
|
export { default as Upload } from "./components/upload.vue";
|
|
26
|
+
export { useFocusTrap } from "./utilities/use-focus-trap";
|
|
27
|
+
export { useScrollLock } from "./utilities/use-scroll-lock";
|
package/dist/vue/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useFocusTrap } from "./utilities/use-focus-trap.js";
|
|
2
|
+
import { useScrollLock } from "./utilities/use-scroll-lock.js";
|
|
1
3
|
import Breadcrumb from "./components/breadcrumb.vue";
|
|
2
4
|
import Button from "./components/button.vue";
|
|
3
5
|
import Card from "./components/card.vue";
|
|
@@ -6,7 +8,6 @@ import Collection from "./components/collection.vue";
|
|
|
6
8
|
import Container from "./components/container.vue";
|
|
7
9
|
import Counter from "./components/counter.vue";
|
|
8
10
|
import Dialog from "./components/dialog.vue";
|
|
9
|
-
import Divider, { default as Separator } from "./components/separator.vue";
|
|
10
11
|
import Field from "./components/field.vue";
|
|
11
12
|
import Heading from "./components/heading.vue";
|
|
12
13
|
import Icon from "./components/icon.vue";
|
|
@@ -19,7 +20,9 @@ import Radio from "./components/radio.vue";
|
|
|
19
20
|
import Range from "./components/range.vue";
|
|
20
21
|
import Rating from "./components/rating.vue";
|
|
21
22
|
import Select from "./components/select.vue";
|
|
23
|
+
import Separator from "./components/separator.vue";
|
|
22
24
|
import Sheet from "./components/sheet.vue";
|
|
25
|
+
import Stack from "./components/stack.vue";
|
|
23
26
|
import Switch from "./components/switch.vue";
|
|
24
27
|
import Upload from "./components/upload.vue";
|
|
25
|
-
export { Breadcrumb, Button, Card, Checkbox, Collection, Container, Counter, Dialog,
|
|
28
|
+
export { Breadcrumb, Button, Card, Checkbox, Collection, Container, Counter, Dialog, Field, Heading, Icon, Input, Link, Navigate, Popover, Progress, Radio, Range, Rating, Select, Separator, Sheet, Stack, Switch, Upload, useFocusTrap, useScrollLock };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { onUnmounted, toValue, watch } from "vue";
|
|
2
|
+
//#region src/vue/utilities/use-focus-trap.ts
|
|
3
|
+
function useFocusTrap(container, active) {
|
|
4
|
+
function handleKeyDown(event) {
|
|
5
|
+
if (event.key !== "Tab" || !toValue(active)) return;
|
|
6
|
+
const root = container.value;
|
|
7
|
+
if (!root) return;
|
|
8
|
+
const elements = [...root.querySelectorAll("a[href]:not([disabled]), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])")].filter((element) => element.offsetParent !== null);
|
|
9
|
+
if (elements.length === 0) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const first = elements[0];
|
|
14
|
+
const last = elements[elements.length - 1];
|
|
15
|
+
const current = document.activeElement;
|
|
16
|
+
if (event.shiftKey && (current === first || !root.contains(current))) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
last.focus();
|
|
19
|
+
} else if (!event.shiftKey && current === last) {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
first.focus();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
watch(() => toValue(active), (value) => {
|
|
25
|
+
if (typeof document === "undefined") return;
|
|
26
|
+
if (value) document.addEventListener("keydown", handleKeyDown);
|
|
27
|
+
else document.removeEventListener("keydown", handleKeyDown);
|
|
28
|
+
}, { immediate: true });
|
|
29
|
+
onUnmounted(() => {
|
|
30
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { useFocusTrap };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { onUnmounted, toValue, watch } from "vue";
|
|
2
|
+
//#region src/vue/utilities/use-scroll-lock.ts
|
|
3
|
+
var locks = 0;
|
|
4
|
+
var previous = null;
|
|
5
|
+
function useScrollLock(active) {
|
|
6
|
+
let locked = false;
|
|
7
|
+
function lock() {
|
|
8
|
+
if (locked) return;
|
|
9
|
+
locked = true;
|
|
10
|
+
locks += 1;
|
|
11
|
+
if (locks === 1) previous = document.body.style.overflow;
|
|
12
|
+
document.body.style.overflow = "hidden";
|
|
13
|
+
}
|
|
14
|
+
function unlock() {
|
|
15
|
+
if (!locked) return;
|
|
16
|
+
locked = false;
|
|
17
|
+
locks = Math.max(0, locks - 1);
|
|
18
|
+
if (locks === 0 && previous !== null) {
|
|
19
|
+
document.body.style.overflow = previous;
|
|
20
|
+
previous = null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
watch(() => toValue(active), (value) => {
|
|
24
|
+
if (typeof document === "undefined") return;
|
|
25
|
+
if (value) lock();
|
|
26
|
+
else unlock();
|
|
27
|
+
}, { immediate: true });
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
unlock();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { useScrollLock };
|