pxd 0.0.25 → 0.0.27
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/active-graph/index.vue.d.ts +0 -1
- package/dist/components/avatar/index.vue +4 -3
- package/dist/components/avatar-group/index.vue +9 -4
- package/dist/components/avatar-group/index.vue.d.ts +3 -12
- package/dist/components/badge/index.vue +9 -9
- package/dist/components/badge/index.vue.d.ts +1 -1
- package/dist/components/book/index.vue +4 -7
- package/dist/components/book/index.vue.d.ts +1 -1
- package/dist/components/browser/index.vue +54 -0
- package/dist/components/browser/index.vue.d.ts +15 -0
- package/dist/components/button/index.vue +30 -23
- package/dist/components/button/index.vue.d.ts +3 -3
- package/dist/components/carousel/index.vue +13 -20
- package/dist/components/carousel-group/index.vue +141 -26
- package/dist/components/carousel-group/index.vue.d.ts +4 -1
- package/dist/components/checkbox/index.vue +12 -14
- package/dist/components/checkbox/index.vue.d.ts +7 -15
- package/dist/components/checkbox-group/index.vue +8 -4
- package/dist/components/checkbox-group/index.vue.d.ts +9 -15
- package/dist/components/chip/index.vue +5 -5
- package/dist/components/chip/index.vue.d.ts +1 -1
- package/dist/components/choicebox/index.vue +6 -5
- package/dist/components/choicebox/index.vue.d.ts +2 -9
- package/dist/components/choicebox-group/index.vue +7 -6
- package/dist/components/choicebox-group/index.vue.d.ts +6 -19
- package/dist/components/collapse/index.vue +3 -2
- package/dist/components/collapse-group/index.vue +7 -5
- package/dist/components/collapse-group/index.vue.d.ts +1 -1
- package/dist/components/config-provider/index.vue.d.ts +2 -2
- package/dist/components/description/index.vue +3 -3
- package/dist/components/drawer/index.vue +14 -29
- package/dist/components/drawer/index.vue.d.ts +6 -8
- package/dist/components/error/index.vue +15 -9
- package/dist/components/error/index.vue.d.ts +5 -2
- package/dist/components/gauge/index.vue +5 -5
- package/dist/components/gauge/index.vue.d.ts +1 -1
- package/dist/components/hold-button/index.vue.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input/index.vue +9 -9
- package/dist/components/input/index.vue.d.ts +1 -1
- package/dist/components/link-button/index.vue +3 -3
- package/dist/components/menu/index.vue +2 -4
- package/dist/components/menu/index.vue.d.ts +2 -1
- package/dist/components/menu-item/index.vue +6 -7
- package/dist/components/menu-item/index.vue.d.ts +1 -1
- package/dist/components/menu-list/index.vue +9 -3
- package/dist/components/menu-list/index.vue.d.ts +3 -1
- package/dist/components/modal/index.vue +3 -2
- package/dist/components/modal/index.vue.d.ts +1 -1
- package/dist/components/more-button/index.vue +11 -5
- package/dist/components/more-button/index.vue.d.ts +3 -4
- package/dist/components/note/index.vue +16 -16
- package/dist/components/note/index.vue.d.ts +8 -8
- package/dist/components/overlay/index.vue +12 -8
- package/dist/components/overlay/index.vue.d.ts +2 -1
- package/dist/components/pagination/index.vue +4 -4
- package/dist/components/pin-input/index.vue +8 -7
- package/dist/components/pin-input/index.vue.d.ts +1 -1
- package/dist/components/popover/index.vue +6 -9
- package/dist/components/popover/index.vue.d.ts +4 -3
- package/dist/components/progress/index.vue +8 -2
- package/dist/components/progress/index.vue.d.ts +1 -1
- package/dist/components/radio/index.vue +11 -13
- package/dist/components/radio/index.vue.d.ts +5 -12
- package/dist/components/radio-group/index.vue +4 -4
- package/dist/components/radio-group/index.vue.d.ts +8 -14
- package/dist/components/resizable/index.vue +18 -27
- package/dist/components/resizable/index.vue.d.ts +2 -2
- package/dist/components/resizable-handle/index.vue +6 -8
- package/dist/components/resizable-panel/index.vue +21 -23
- package/dist/components/scrollable/index.vue +2 -2
- package/dist/components/scrollable/index.vue.d.ts +2 -1
- package/dist/components/skeleton/index.vue +8 -11
- package/dist/components/slider/index.vue +4 -3
- package/dist/components/slider/index.vue.d.ts +1 -1
- package/dist/components/snippet/index.vue +14 -33
- package/dist/components/snippet/index.vue.d.ts +1 -1
- package/dist/components/stack/index.vue +27 -24
- package/dist/components/stack/index.vue.d.ts +2 -2
- package/dist/components/switch/index.vue +12 -15
- package/dist/components/switch/index.vue.d.ts +1 -1
- package/dist/components/switch-group/index.vue +9 -6
- package/dist/components/switch-group/index.vue.d.ts +4 -12
- package/dist/components/text/index.vue +8 -8
- package/dist/components/text/index.vue.d.ts +1 -1
- package/dist/components/textarea/index.vue +9 -9
- package/dist/components/textarea/index.vue.d.ts +1 -1
- package/dist/components/toggle/index.vue +4 -2
- package/dist/components/toggle/index.vue.d.ts +1 -1
- package/dist/components/tooltip/index.vue +4 -5
- package/dist/components/tooltip/index.vue.d.ts +4 -4
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/useConfigProviderContext.d.ts +3 -8
- package/dist/composables/useConfigProviderContext.js +10 -15
- package/dist/composables/useCopyClick.d.ts +5 -0
- package/dist/composables/useCopyClick.js +35 -0
- package/dist/composables/useFocusTrap.js +21 -2
- package/dist/composables/useUniqueIdContext.d.ts +2 -2
- package/dist/composables/useUniqueIdContext.js +4 -4
- package/dist/contexts/avatar.d.ts +2 -0
- package/dist/contexts/avatar.js +5 -0
- package/dist/contexts/carousel.d.ts +13 -0
- package/dist/contexts/carousel.js +5 -0
- package/dist/contexts/checkbox.d.ts +2 -0
- package/dist/contexts/checkbox.js +5 -0
- package/dist/contexts/choicebox.d.ts +4 -0
- package/dist/contexts/choicebox.js +11 -0
- package/dist/contexts/collapse.d.ts +8 -0
- package/dist/contexts/collapse.js +5 -0
- package/dist/contexts/menu.d.ts +8 -0
- package/dist/contexts/menu.js +5 -0
- package/dist/contexts/radio.d.ts +2 -0
- package/dist/contexts/radio.js +5 -0
- package/dist/contexts/resizable.d.ts +33 -0
- package/dist/contexts/resizable.js +5 -0
- package/dist/contexts/switch.d.ts +4 -0
- package/dist/contexts/switch.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/styles/styles.css +1 -1
- package/dist/styles/tw.css +29 -17
- package/dist/types/components/avatar.d.ts +11 -0
- package/dist/types/components/button.d.ts +1 -1
- package/dist/types/components/carousel.d.ts +16 -0
- package/dist/types/components/checkbox.d.ts +17 -0
- package/dist/types/components/choicebox.d.ts +22 -0
- package/dist/types/components/menu.d.ts +1 -1
- package/dist/types/components/radio.d.ts +16 -0
- package/dist/types/components/switch.d.ts +10 -0
- package/dist/types/shared/index.d.ts +1 -0
- package/dist/types/shared/props.d.ts +30 -0
- package/dist/utils/context.d.ts +17 -0
- package/dist/utils/context.js +19 -0
- package/dist/utils/events.d.ts +6 -3
- package/dist/utils/events.js +34 -0
- package/dist/utils/fn.js +4 -7
- package/dist/utils/format.d.ts +2 -1
- package/dist/utils/format.js +7 -4
- package/package.json +6 -6
- package/dist/components/carousel-group/constants.d.ts +0 -25
- package/dist/components/carousel-group/constants.js +0 -3
- package/dist/styles/dst.css +0 -351
- package/dist/types/components/index.d.ts +0 -6
- package/dist/types/components/resizable.d.ts +0 -19
- package/dist/types/components/shared.d.ts +0 -18
- package/dist/types/components/shared.js +0 -0
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.js +0 -2
- package/dist/utils/raf.d.ts +0 -2
- package/dist/utils/raf.js +0 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed,
|
|
2
|
+
import { computed, shallowRef } from "vue";
|
|
3
|
+
import { useAvatarGroupContext } from "../../contexts/avatar";
|
|
3
4
|
import { getCssUnitValue } from "../../utils/format";
|
|
4
5
|
defineOptions({
|
|
5
6
|
name: "PAvatar"
|
|
@@ -13,8 +14,8 @@ const props = defineProps({
|
|
|
13
14
|
});
|
|
14
15
|
const emits = defineEmits(["load", "error", "loadstart"]);
|
|
15
16
|
const loadingStatus = shallowRef("idle");
|
|
16
|
-
const
|
|
17
|
-
const computedSize = computed(() => getCssUnitValue(props.size ||
|
|
17
|
+
const avatarGroupContext = useAvatarGroupContext();
|
|
18
|
+
const computedSize = computed(() => getCssUnitValue(props.size || avatarGroupContext?.size, "32px"));
|
|
18
19
|
const hideAvatar = computed(() => !props.src || props.placeholder || loadingStatus.value === "error");
|
|
19
20
|
function onLoadError(event) {
|
|
20
21
|
loadingStatus.value = "error";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { provideAvatarGroupContext } from "../../contexts/avatar";
|
|
3
4
|
import PAvatar from "../avatar/index.vue";
|
|
4
5
|
defineOptions({
|
|
5
6
|
name: "PAvatarGroup"
|
|
@@ -9,8 +10,12 @@ const props = defineProps({
|
|
|
9
10
|
size: { type: [Number, String], required: false, default: 32 },
|
|
10
11
|
options: { type: Array, required: false, default: () => [] }
|
|
11
12
|
});
|
|
12
|
-
const slicedOptions = computed(() =>
|
|
13
|
-
|
|
13
|
+
const slicedOptions = computed(() => {
|
|
14
|
+
const { max, options = [] } = props;
|
|
15
|
+
const maxCount = Math.max(Math.min(max, options.length), 1);
|
|
16
|
+
return options.slice(0, maxCount);
|
|
17
|
+
});
|
|
18
|
+
provideAvatarGroupContext(props);
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
21
|
<template>
|
|
@@ -22,7 +27,7 @@ provide("pxdAvatarGroupSize", props.size);
|
|
|
22
27
|
:src="option.src"
|
|
23
28
|
:alt="option.alt"
|
|
24
29
|
:loading="option.loading"
|
|
25
|
-
class="[&:nth-child(n+2)]:-ml-3"
|
|
30
|
+
class="[&:nth-child(n+2)]:-ml-3 hover:z-10"
|
|
26
31
|
/>
|
|
27
32
|
|
|
28
33
|
<PAvatar v-if="slicedOptions.length < options.length" class="text-xs bg-gray-1000 text-gray-100 -ml-3">
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
alt?: string;
|
|
4
|
-
loading?: boolean;
|
|
5
|
-
}
|
|
6
|
-
interface Props {
|
|
7
|
-
max?: number;
|
|
8
|
-
size?: number | string;
|
|
9
|
-
options?: AvatarGroupOptions[];
|
|
10
|
-
}
|
|
11
|
-
declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
1
|
+
import type { AvatarGroupProps } from '../../types/components/avatar';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<AvatarGroupProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AvatarGroupProps> & Readonly<{}>, {
|
|
12
3
|
max: number;
|
|
13
|
-
options:
|
|
4
|
+
options: import("../../types/components/avatar").Options[];
|
|
14
5
|
size: number | string;
|
|
15
6
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
16
7
|
export default _default;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
2
|
import { computed } from "vue";
|
|
4
|
-
import {
|
|
3
|
+
import { useConfigProvider } from "../../composables/useConfigProviderContext";
|
|
5
4
|
import { getFallbackValue } from "../../utils/value";
|
|
6
5
|
defineOptions({
|
|
7
6
|
name: "PBadge"
|
|
@@ -40,15 +39,16 @@ const VARIANTS = {
|
|
|
40
39
|
"trial": "text-gray-100 dark:text-gray-1000",
|
|
41
40
|
"turborepo": "text-gray-100 dark:text-gray-1000"
|
|
42
41
|
};
|
|
43
|
-
const
|
|
44
|
-
const computedClass = computed(
|
|
45
|
-
|
|
46
|
-
"pxd-badge inline-flex items-center justify-center px-2.5 font-medium h-6
|
|
42
|
+
const config = useConfigProvider();
|
|
43
|
+
const computedClass = computed(() => {
|
|
44
|
+
const classes = [
|
|
45
|
+
"pxd-badge inline-flex items-center justify-center px-2.5 font-medium h-6 rounded-full font-sans gap-1 !no-underline motion-safe:transition-all",
|
|
47
46
|
getFallbackValue(props.variant, VARIANTS, "gray"),
|
|
48
|
-
|
|
47
|
+
getFallbackValue(props.size, SIZES, config.size),
|
|
49
48
|
props.variant
|
|
50
|
-
|
|
51
|
-
);
|
|
49
|
+
];
|
|
50
|
+
return classes.join(" ");
|
|
51
|
+
});
|
|
52
52
|
const badgeAttrs = computed(() => {
|
|
53
53
|
if (props.as === "router-link" || props.as === "RouterLink") {
|
|
54
54
|
return {
|
|
@@ -38,20 +38,17 @@ const computedStyle = computed(() => {
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
const computedClass = computed(() => {
|
|
41
|
-
const
|
|
42
|
-
|
|
41
|
+
const classes = ["pxd-book--container w-fit relative transform-3d duration-300 motion-safe:transition-transform"];
|
|
42
|
+
classes.push(
|
|
43
43
|
...Object.keys(formattedWidth.value).map((bp) => presetWidthClasses[bp])
|
|
44
44
|
);
|
|
45
|
-
return
|
|
45
|
+
return classes.join(" ");
|
|
46
46
|
});
|
|
47
47
|
</script>
|
|
48
48
|
|
|
49
49
|
<template>
|
|
50
50
|
<div class="pxd-book inline-flex w-fit">
|
|
51
|
-
<div
|
|
52
|
-
:class="computedClass"
|
|
53
|
-
:style="computedStyle"
|
|
54
|
-
>
|
|
51
|
+
<div :class="computedClass" :style="computedStyle">
|
|
55
52
|
<div class="pxd-book--content absolute w-full min-w-full flex flex-col h-full overflow-hidden translate-z-0 bg-background-secondary">
|
|
56
53
|
<div
|
|
57
54
|
v-if="variant === 'stripe'"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import ArrowLeftIcon from "@gdsicon/vue/arrow-left";
|
|
3
|
+
import LockClosedIcon from "@gdsicon/vue/lock-closed";
|
|
4
|
+
import RefreshClockwiseIcon from "@gdsicon/vue/refresh-clockwise";
|
|
5
|
+
import { useCopyClick } from "../../composables/useCopyClick";
|
|
6
|
+
import PButton from "../button/index.vue";
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: "PBrowser"
|
|
9
|
+
});
|
|
10
|
+
defineProps({
|
|
11
|
+
address: { type: String, required: false }
|
|
12
|
+
});
|
|
13
|
+
const { renderAs, onCopyClick } = useCopyClick();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<div class="pxd-browser shadow-border-small rounded-md overflow-hidden bg-background-secondary">
|
|
18
|
+
<div class="bg-background py-2.5 px-5 flex justify-between gap-4 md:gap-6">
|
|
19
|
+
<div class="flex items-center flex-1 justify-center gap-4 min-w-0 first:justify-start md:first:max-w-[140px] max-md:first:flex-none last:justify-end md:last:max-w-[140px]">
|
|
20
|
+
<div class="flex items-center gap-2">
|
|
21
|
+
<div class="w-3 h-3 rounded-full bg-[#FE5F57]" />
|
|
22
|
+
<div class="w-3 h-3 rounded-full bg-[#FEBB2E]" />
|
|
23
|
+
<div class="w-3 h-3 rounded-full bg-[#26C941]" />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="flex items-center gap-4 max-md:hidden text-sm text-gray-900">
|
|
27
|
+
<ArrowLeftIcon />
|
|
28
|
+
<ArrowLeftIcon class="rotate-180" />
|
|
29
|
+
<RefreshClockwiseIcon />
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="flex items-center flex-1 justify-center gap-4 min-w-0 first:justify-start md:first:max-w-[140px] max-md:first:flex-none last:justify-end md:last:max-w-[140px]">
|
|
34
|
+
<div class="lg:max-w-xs bg-background-secondary border border-gray-400 w-full rounded-full pl-2.5 pr-1 py-1 flex items-center justify-between">
|
|
35
|
+
<LockClosedIcon class="text-gray-900 text-sm" />
|
|
36
|
+
|
|
37
|
+
<div class="pl-1.5 text-[13px] text-gray-1000 truncate flex-1 min-w-0 text-center truncate">
|
|
38
|
+
{{ address }}
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<PButton variant="ghost" size="xs" shape="rounded" class="size-6" icon @click="onCopyClick(address)">
|
|
42
|
+
<Transition name="pxd-transition--fade-scale" mode="out-in">
|
|
43
|
+
<component :is="renderAs" class="text-sm" />
|
|
44
|
+
</Transition>
|
|
45
|
+
</PButton>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div class="flex items-center flex-1 justify-center gap-4 min-w-0 first:justify-start md:first:max-w-[140px] max-md:first:flex-none last:justify-end md:last:max-w-[140px] max-lg:hidden" />
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<slot />
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
address?: string;
|
|
3
|
+
}
|
|
4
|
+
declare var __VLS_38: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_38) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
9
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
2
|
import { computed } from "vue";
|
|
4
|
-
import {
|
|
3
|
+
import { useConfigProvider } from "../../composables/useConfigProviderContext";
|
|
5
4
|
import { isTruthyProp } from "../../utils/format";
|
|
6
5
|
import { getFallbackValue } from "../../utils/value";
|
|
7
6
|
import PSpinner from "../spinner/index.vue";
|
|
@@ -21,10 +20,19 @@ const props = defineProps({
|
|
|
21
20
|
});
|
|
22
21
|
const emits = defineEmits(["click", "dblclick"]);
|
|
23
22
|
const SIZES = {
|
|
24
|
-
xs: "h-6 px-1
|
|
25
|
-
sm: "h-7.5 px-1.5
|
|
26
|
-
md: "h-9 px-2.5
|
|
27
|
-
lg: "h-10 px-3.5
|
|
23
|
+
xs: "h-6 px-1",
|
|
24
|
+
sm: "h-7.5 px-1.5",
|
|
25
|
+
md: "h-9 px-2.5",
|
|
26
|
+
lg: "h-10 px-3.5"
|
|
27
|
+
};
|
|
28
|
+
const ROUNDED = {
|
|
29
|
+
xs: "rounded-md",
|
|
30
|
+
sm: "rounded-md",
|
|
31
|
+
md: "rounded-md",
|
|
32
|
+
lg: "rounded-lg",
|
|
33
|
+
xl: "rounded-xl",
|
|
34
|
+
square: "rounded-none",
|
|
35
|
+
rounded: "rounded-full"
|
|
28
36
|
};
|
|
29
37
|
const FONT_SIZES = {
|
|
30
38
|
xs: "text-sm",
|
|
@@ -47,31 +55,30 @@ const ALIGNMENTS = {
|
|
|
47
55
|
right: "justify-end"
|
|
48
56
|
};
|
|
49
57
|
const DISABLED_CLASS_NAMES = "is-disabled bg-gray-100 hover:bg-gray-100 active:bg-gray-100 cursor-not-allowed text-gray-700 border-gray-300";
|
|
50
|
-
const
|
|
51
|
-
const computedFontSize = useConfigProviderSize(props.size, FONT_SIZES);
|
|
58
|
+
const config = useConfigProvider();
|
|
52
59
|
const computedDisabled = computed(() => props.disabled || props.loading);
|
|
53
60
|
const computedClass = computed(() => {
|
|
54
|
-
const
|
|
61
|
+
const classes = ["pxd-button cursor-pointer select-none shrink-0 items-center motion-safe:transition-all", ALIGNMENTS[props.align]];
|
|
55
62
|
const { variant, block, shape, icon } = props;
|
|
56
|
-
|
|
63
|
+
classes.push(
|
|
64
|
+
isTruthyProp(block) ? "flex w-full" : "inline-flex",
|
|
65
|
+
getFallbackValue(props.size, FONT_SIZES, config.size),
|
|
66
|
+
shape ? ROUNDED[shape] : getFallbackValue(props.size, ROUNDED, config.size)
|
|
67
|
+
);
|
|
57
68
|
if (icon) {
|
|
58
|
-
|
|
69
|
+
classes.push("aspect-square !p-0");
|
|
59
70
|
}
|
|
60
71
|
if (variant !== "simple") {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
classes.push(
|
|
73
|
+
"border outline-none self-focus-ring",
|
|
74
|
+
getFallbackValue(variant, VARIANTS),
|
|
75
|
+
getFallbackValue(props.size, SIZES, config.size)
|
|
76
|
+
);
|
|
64
77
|
}
|
|
65
|
-
classNames.push(isTruthyProp(block) ? "flex w-full" : "inline-flex");
|
|
66
78
|
if (computedDisabled.value) {
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
if (shape) {
|
|
70
|
-
classNames.push(
|
|
71
|
-
shape === "square" ? "rounded-none" : "rounded-full"
|
|
72
|
-
);
|
|
79
|
+
classes.push(DISABLED_CLASS_NAMES);
|
|
73
80
|
}
|
|
74
|
-
return
|
|
81
|
+
return classes.join(" ");
|
|
75
82
|
});
|
|
76
83
|
function onButtonClick(event) {
|
|
77
84
|
emits("click", event);
|
|
@@ -94,7 +101,7 @@ function onButtonDblClick(event) {
|
|
|
94
101
|
|
|
95
102
|
<slot name="prefix" />
|
|
96
103
|
|
|
97
|
-
<span class="px-1.5
|
|
104
|
+
<span class="inline-flex items-center truncate" :class="{ 'px-1.5': !icon }">
|
|
98
105
|
<slot />
|
|
99
106
|
</span>
|
|
100
107
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ButtonProps } from '../../types/components';
|
|
1
|
+
import type { ButtonProps } from '../../types/components/button';
|
|
2
2
|
declare var __VLS_15: {}, __VLS_17: {}, __VLS_19: {};
|
|
3
3
|
type __VLS_Slots = {} & {
|
|
4
4
|
prefix?: (props: typeof __VLS_15) => any;
|
|
@@ -14,9 +14,9 @@ declare const __VLS_component: import("vue").DefineComponent<ButtonProps, {}, {}
|
|
|
14
14
|
onClick?: (args_0: MouseEvent) => any;
|
|
15
15
|
onDblclick?: (args_0: MouseEvent) => any;
|
|
16
16
|
}>, {
|
|
17
|
-
variant: import("../../types").ComponentVariantWithDefault | "ghost" | "simple" | "icon";
|
|
17
|
+
variant: import("../../types/shared").ComponentVariantWithDefault | "ghost" | "simple" | "icon";
|
|
18
18
|
icon: boolean;
|
|
19
|
-
as: import("../../types").ComponentAs;
|
|
19
|
+
as: import("../../types/shared").ComponentAs;
|
|
20
20
|
align: "left" | "center" | "right";
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
22
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { onBeforeUnmount, onMounted, shallowRef } from "vue";
|
|
3
|
+
import { useCarouselGroupContext } from "../../contexts/carousel";
|
|
4
|
+
import { getUniqueId } from "../../utils/uid";
|
|
5
5
|
defineOptions({
|
|
6
6
|
name: "PCarousel"
|
|
7
7
|
});
|
|
8
|
-
const carouselGroupContext =
|
|
9
|
-
|
|
10
|
-
throw new Error("CarouselGroupContext is not provided");
|
|
11
|
-
}
|
|
12
|
-
const {
|
|
13
|
-
props,
|
|
14
|
-
carousels,
|
|
15
|
-
registerCarousel,
|
|
16
|
-
unregisterCarousel
|
|
17
|
-
} = carouselGroupContext;
|
|
18
|
-
const uniqueId = useUniqueId();
|
|
8
|
+
const carouselGroupContext = useCarouselGroupContext();
|
|
9
|
+
const uniqueId = getUniqueId();
|
|
19
10
|
const transformStyle = shallowRef("");
|
|
20
11
|
function resetPosition() {
|
|
21
12
|
transformStyle.value = "";
|
|
22
13
|
}
|
|
23
14
|
function getTranslateStyle(translate) {
|
|
24
|
-
return props.direction === "horizontal" ? `translateX(${translate}%)` : `translateY(${translate}%)`;
|
|
15
|
+
return carouselGroupContext.props.direction === "horizontal" ? `translateX(${translate}%)` : `translateY(${translate}%)`;
|
|
25
16
|
}
|
|
26
17
|
function translateItem(index, activeIndex) {
|
|
27
|
-
const maxLength = carousels.value.length;
|
|
18
|
+
const maxLength = carouselGroupContext.carousels.value.length;
|
|
28
19
|
const lastIndex = maxLength - 1;
|
|
29
20
|
if (index === 0 && activeIndex === maxLength) {
|
|
30
21
|
transformStyle.value = getTranslateStyle(maxLength * 100);
|
|
@@ -34,12 +25,14 @@ function translateItem(index, activeIndex) {
|
|
|
34
25
|
resetPosition();
|
|
35
26
|
}
|
|
36
27
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
carouselGroupContext?.registerCarousel({
|
|
30
|
+
uid: uniqueId,
|
|
31
|
+
translateItem
|
|
32
|
+
});
|
|
40
33
|
});
|
|
41
34
|
onBeforeUnmount(() => {
|
|
42
|
-
unregisterCarousel(uniqueId);
|
|
35
|
+
carouselGroupContext?.unregisterCarousel(uniqueId);
|
|
43
36
|
});
|
|
44
37
|
</script>
|
|
45
38
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import ChevronRightIcon from "@gdsicon/vue/chevron-right";
|
|
3
|
-
import { computed, onBeforeUnmount, onMounted,
|
|
3
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef } from "vue";
|
|
4
|
+
import { provideCarouselGroupContext } from "../../contexts/carousel";
|
|
4
5
|
import { throttle } from "../../utils/fn";
|
|
5
6
|
import { getCssUnitValue } from "../../utils/format";
|
|
6
|
-
import { carouselGroupContextKey, THROTTLE_DELAY, TRANSITION_CLASSES } from "./constants";
|
|
7
7
|
defineOptions({
|
|
8
8
|
name: "PCarouselGroup"
|
|
9
9
|
});
|
|
@@ -11,16 +11,21 @@ const props = defineProps({
|
|
|
11
11
|
index: { type: Number, required: false, default: 0 },
|
|
12
12
|
loop: { type: Boolean, required: false, default: true },
|
|
13
13
|
arrow: { type: Boolean, required: false, default: true },
|
|
14
|
-
height: { type: [Number, String], required: false, default:
|
|
14
|
+
height: { type: [Number, String], required: false, default: 180 },
|
|
15
15
|
autoplay: { type: Boolean, required: false, default: true },
|
|
16
16
|
interval: { type: Number, required: false, default: 3e3 },
|
|
17
|
+
indicator: { type: Boolean, required: false, default: true },
|
|
18
|
+
direction: { type: String, required: false, default: "horizontal" },
|
|
19
|
+
indicatorType: { type: String, required: false, default: "line" },
|
|
20
|
+
indicatorPosition: { type: String, required: false, default: "bottom" },
|
|
17
21
|
pauseOnHover: { type: Boolean, required: false, default: true },
|
|
18
|
-
toggleOnWheel: { type: Boolean, required: false, default: true }
|
|
19
|
-
direction: { type: String, required: false, default: "horizontal" }
|
|
22
|
+
toggleOnWheel: { type: Boolean, required: false, default: true }
|
|
20
23
|
});
|
|
21
24
|
const emits = defineEmits(["change"]);
|
|
25
|
+
const THROTTLE_INTERVALS = 550;
|
|
26
|
+
const TRANSITION_CLASSES = ["transition-transform", "duration-500"];
|
|
22
27
|
let autoPlayTimer;
|
|
23
|
-
const
|
|
28
|
+
const sliderRef = shallowRef();
|
|
24
29
|
const carousels = ref([]);
|
|
25
30
|
const virtualIndex = shallowRef(props.index);
|
|
26
31
|
const correctIndex = computed(() => {
|
|
@@ -50,14 +55,16 @@ const onToggleClick = throttle((delta) => {
|
|
|
50
55
|
if (length === 0) {
|
|
51
56
|
return;
|
|
52
57
|
}
|
|
58
|
+
onPointerEnter();
|
|
53
59
|
if (props.loop) {
|
|
54
60
|
virtualIndex.value += delta;
|
|
55
61
|
translateItems();
|
|
56
62
|
} else {
|
|
57
63
|
virtualIndex.value = Math.max(0, Math.min(virtualIndex.value + delta, length - 1));
|
|
58
64
|
}
|
|
65
|
+
nextTick(onPointerLeave);
|
|
59
66
|
emits("change", correctIndex.value);
|
|
60
|
-
},
|
|
67
|
+
}, THROTTLE_INTERVALS, { leading: true, trailing: false });
|
|
61
68
|
function onWheelToggle(ev) {
|
|
62
69
|
if (!props.toggleOnWheel) {
|
|
63
70
|
return;
|
|
@@ -70,7 +77,7 @@ function onWheelToggle(ev) {
|
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
function resetContainerPosition(resetIndex) {
|
|
73
|
-
const containerClassList =
|
|
80
|
+
const containerClassList = sliderRef.value.classList;
|
|
74
81
|
containerClassList.remove(...TRANSITION_CLASSES);
|
|
75
82
|
virtualIndex.value = resetIndex;
|
|
76
83
|
translateItems();
|
|
@@ -111,58 +118,166 @@ function onPointerLeave() {
|
|
|
111
118
|
}
|
|
112
119
|
setAutoPlayTimer();
|
|
113
120
|
}
|
|
121
|
+
function onIndicatorClick(ev) {
|
|
122
|
+
onPointerEnter();
|
|
123
|
+
const target = ev.target;
|
|
124
|
+
const targetIndex = Number(target.dataset.index);
|
|
125
|
+
virtualIndex.value = targetIndex;
|
|
126
|
+
nextTick(onPointerLeave);
|
|
127
|
+
}
|
|
114
128
|
function registerCarousel(state) {
|
|
115
129
|
carousels.value.push(state);
|
|
116
130
|
}
|
|
117
131
|
function unregisterCarousel(id) {
|
|
118
132
|
carousels.value = carousels.value.filter(({ uid }) => uid !== id);
|
|
119
133
|
}
|
|
134
|
+
provideCarouselGroupContext({
|
|
135
|
+
props,
|
|
136
|
+
carousels,
|
|
137
|
+
registerCarousel,
|
|
138
|
+
unregisterCarousel
|
|
139
|
+
});
|
|
120
140
|
onMounted(() => {
|
|
121
141
|
onPointerLeave();
|
|
122
142
|
});
|
|
123
143
|
onBeforeUnmount(() => {
|
|
124
144
|
carousels.value = [];
|
|
125
145
|
});
|
|
126
|
-
provide(carouselGroupContextKey, {
|
|
127
|
-
props,
|
|
128
|
-
carousels,
|
|
129
|
-
registerCarousel,
|
|
130
|
-
unregisterCarousel
|
|
131
|
-
});
|
|
132
146
|
</script>
|
|
133
147
|
|
|
134
148
|
<template>
|
|
135
149
|
<div
|
|
136
|
-
|
|
150
|
+
tabindex="-1"
|
|
151
|
+
:data-direction="direction"
|
|
152
|
+
:data-indicator-type="indicatorType"
|
|
153
|
+
:data-indicator-position="indicatorPosition"
|
|
154
|
+
class="pxd-carousel-group group w-full relative overflow-hidden touch-manipulation"
|
|
137
155
|
:style="{ height: getCssUnitValue(height) }"
|
|
138
156
|
@pointerenter="onPointerEnter"
|
|
139
157
|
@pointerleave="onPointerLeave"
|
|
140
158
|
@wheel="onWheelToggle"
|
|
141
159
|
>
|
|
160
|
+
<div class="pxd-carousel-group--container w-full h-full">
|
|
161
|
+
<div
|
|
162
|
+
ref="sliderRef"
|
|
163
|
+
class="pxd-carousel-group--slider w-full h-full translate-z-0 group-data-[direction=horizontal]:flex group-hover:will-change-transform"
|
|
164
|
+
:style="computedStyle"
|
|
165
|
+
:class="TRANSITION_CLASSES"
|
|
166
|
+
@transitionend="onTransitionsEnd"
|
|
167
|
+
>
|
|
168
|
+
<slot />
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
142
172
|
<div
|
|
143
|
-
|
|
144
|
-
:data-
|
|
145
|
-
|
|
146
|
-
:style="computedStyle"
|
|
147
|
-
:class="TRANSITION_CLASSES"
|
|
148
|
-
@transitionend="onTransitionsEnd"
|
|
173
|
+
v-if="indicator"
|
|
174
|
+
class="pxd-carousel-group--indicator absolute w-max flex items-center gap-2 group-data-[indicator-position=left]:flex-col group-data-[indicator-position=right]:flex-col"
|
|
175
|
+
@click="onIndicatorClick"
|
|
149
176
|
>
|
|
150
|
-
<
|
|
177
|
+
<button
|
|
178
|
+
v-for="(_, i) in carousels.length"
|
|
179
|
+
:key="i"
|
|
180
|
+
:data-index="i"
|
|
181
|
+
class="pxd-carousel-group--indicator-item w-(--w) h-(--h) self-focus-ring relative rounded-full appearance-none cursor-pointer outline-none bg-gray-alpha-200 motion-safe:transition-colors hover:bg-gray-alpha-400"
|
|
182
|
+
:class="{ '!bg-primary': i === correctIndex }"
|
|
183
|
+
/>
|
|
151
184
|
</div>
|
|
152
185
|
|
|
153
|
-
<
|
|
186
|
+
<div v-if="arrow" class="pxd-carousel-group--toggle-buttons flex gap-2 absolute group-data-[indicator-position=left]:flex-col group-data-[indicator-position=right]:flex-col">
|
|
154
187
|
<button
|
|
155
|
-
|
|
188
|
+
type="button"
|
|
189
|
+
aria-label="Carousel arrow left"
|
|
190
|
+
class="pxd-carousel-group--prev-button outline-none self-focus-ring group-data-[direction=vertical]:rotate-90 appearance-none p-1.5 rounded-md cursor-pointer bg-gray-alpha-100 hover:bg-gray-alpha-200 active:bg-gray-alpha-300 disabled:pointer-events-none motion-safe:transition-colors"
|
|
156
191
|
@click="onToggleClick(-1)"
|
|
157
192
|
>
|
|
158
193
|
<ChevronRightIcon class="rotate-180" />
|
|
159
194
|
</button>
|
|
195
|
+
|
|
160
196
|
<button
|
|
161
|
-
|
|
197
|
+
type="button"
|
|
198
|
+
aria-label="Carousel arrow right"
|
|
199
|
+
class="pxd-carousel-group--next-button outline-none self-focus-ring group-data-[direction=vertical]:rotate-90 appearance-none p-1.5 rounded-md cursor-pointer bg-gray-alpha-100 hover:bg-gray-alpha-200 active:bg-gray-alpha-300 disabled:pointer-events-none motion-safe:transition-colors"
|
|
162
200
|
@click="onToggleClick(1)"
|
|
163
201
|
>
|
|
164
202
|
<ChevronRightIcon />
|
|
165
203
|
</button>
|
|
166
|
-
</
|
|
204
|
+
</div>
|
|
167
205
|
</div>
|
|
168
206
|
</template>
|
|
207
|
+
|
|
208
|
+
<style lang="postcss">
|
|
209
|
+
.pxd-carousel-group {
|
|
210
|
+
&[data-indicator-type="dot"] {
|
|
211
|
+
--w: 8px;
|
|
212
|
+
--h: 8px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&[data-indicator-type="line"] {
|
|
216
|
+
&[data-indicator-position="top"],
|
|
217
|
+
&[data-indicator-position="bottom"] {
|
|
218
|
+
--w: 16px;
|
|
219
|
+
--h: 4px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&[data-indicator-position="left"],
|
|
223
|
+
&[data-indicator-position="right"] {
|
|
224
|
+
--w: 4px;
|
|
225
|
+
--h: 16px;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&[data-indicator-position="top"] {
|
|
230
|
+
.pxd-carousel-group--indicator {
|
|
231
|
+
left: 12px;
|
|
232
|
+
top: 8px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.pxd-carousel-group--toggle-buttons {
|
|
236
|
+
right: 8px;
|
|
237
|
+
top: 8px;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
&[data-indicator-position="bottom"] {
|
|
242
|
+
.pxd-carousel-group--indicator {
|
|
243
|
+
left: 12px;
|
|
244
|
+
bottom: 8px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.pxd-carousel-group--toggle-buttons {
|
|
248
|
+
right: 8px;
|
|
249
|
+
bottom: 8px;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&[data-indicator-position="left"] {
|
|
254
|
+
.pxd-carousel-group--indicator {
|
|
255
|
+
left: 8px;
|
|
256
|
+
top: 12px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.pxd-carousel-group--toggle-buttons {
|
|
260
|
+
left: 8px;
|
|
261
|
+
bottom: 8px;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&[data-indicator-position="right"] {
|
|
266
|
+
.pxd-carousel-group--indicator {
|
|
267
|
+
right: 8px;
|
|
268
|
+
top: 12px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.pxd-carousel-group--toggle-buttons {
|
|
272
|
+
right: 8px;
|
|
273
|
+
bottom: 8px;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.pxd-carousel-group--indicator-item::before {
|
|
279
|
+
content: '';
|
|
280
|
+
position: absolute;
|
|
281
|
+
inset: -4px;
|
|
282
|
+
}
|
|
283
|
+
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CarouselGroupProps } from '
|
|
1
|
+
import type { CarouselGroupProps } from '../../types/components/carousel';
|
|
2
2
|
declare var __VLS_1: {};
|
|
3
3
|
type __VLS_Slots = {} & {
|
|
4
4
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -15,6 +15,9 @@ declare const __VLS_component: import("vue").DefineComponent<CarouselGroupProps,
|
|
|
15
15
|
autoplay: boolean;
|
|
16
16
|
loop: boolean;
|
|
17
17
|
arrow: boolean;
|
|
18
|
+
indicator: boolean;
|
|
19
|
+
indicatorType: "dot" | "line";
|
|
20
|
+
indicatorPosition: import("../../types/shared").BasePosition;
|
|
18
21
|
pauseOnHover: boolean;
|
|
19
22
|
toggleOnWheel: boolean;
|
|
20
23
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|