pxd 0.0.25 → 0.0.26

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.
Files changed (150) hide show
  1. package/dist/components/active-graph/index.vue.d.ts +0 -1
  2. package/dist/components/avatar/index.vue +4 -3
  3. package/dist/components/avatar-group/index.vue +8 -3
  4. package/dist/components/avatar-group/index.vue.d.ts +3 -12
  5. package/dist/components/badge/index.vue +9 -9
  6. package/dist/components/badge/index.vue.d.ts +1 -1
  7. package/dist/components/book/index.vue +4 -7
  8. package/dist/components/book/index.vue.d.ts +1 -1
  9. package/dist/components/browser/index.vue +54 -0
  10. package/dist/components/browser/index.vue.d.ts +15 -0
  11. package/dist/components/button/index.vue +30 -23
  12. package/dist/components/button/index.vue.d.ts +3 -3
  13. package/dist/components/carousel/index.vue +13 -20
  14. package/dist/components/carousel-group/index.vue +128 -19
  15. package/dist/components/carousel-group/index.vue.d.ts +4 -1
  16. package/dist/components/checkbox/index.vue +11 -14
  17. package/dist/components/checkbox/index.vue.d.ts +7 -15
  18. package/dist/components/checkbox-group/index.vue +7 -3
  19. package/dist/components/checkbox-group/index.vue.d.ts +9 -15
  20. package/dist/components/chip/index.vue +5 -5
  21. package/dist/components/chip/index.vue.d.ts +1 -1
  22. package/dist/components/choicebox/index.vue +6 -5
  23. package/dist/components/choicebox/index.vue.d.ts +2 -9
  24. package/dist/components/choicebox-group/index.vue +7 -6
  25. package/dist/components/choicebox-group/index.vue.d.ts +6 -19
  26. package/dist/components/collapse/index.vue +3 -2
  27. package/dist/components/collapse-group/index.vue +7 -5
  28. package/dist/components/collapse-group/index.vue.d.ts +1 -1
  29. package/dist/components/config-provider/index.vue.d.ts +2 -2
  30. package/dist/components/description/index.vue +3 -3
  31. package/dist/components/drawer/index.vue +14 -29
  32. package/dist/components/drawer/index.vue.d.ts +6 -8
  33. package/dist/components/error/index.vue +15 -9
  34. package/dist/components/error/index.vue.d.ts +5 -2
  35. package/dist/components/gauge/index.vue +5 -5
  36. package/dist/components/gauge/index.vue.d.ts +1 -1
  37. package/dist/components/hold-button/index.vue.d.ts +1 -1
  38. package/dist/components/index.d.ts +1 -0
  39. package/dist/components/index.js +1 -0
  40. package/dist/components/input/index.vue +9 -9
  41. package/dist/components/input/index.vue.d.ts +1 -1
  42. package/dist/components/link-button/index.vue +3 -3
  43. package/dist/components/menu/index.vue +2 -4
  44. package/dist/components/menu/index.vue.d.ts +2 -1
  45. package/dist/components/menu-item/index.vue +6 -7
  46. package/dist/components/menu-item/index.vue.d.ts +1 -1
  47. package/dist/components/menu-list/index.vue +9 -3
  48. package/dist/components/menu-list/index.vue.d.ts +3 -1
  49. package/dist/components/modal/index.vue +3 -2
  50. package/dist/components/modal/index.vue.d.ts +1 -1
  51. package/dist/components/more-button/index.vue +11 -5
  52. package/dist/components/more-button/index.vue.d.ts +3 -4
  53. package/dist/components/note/index.vue +16 -16
  54. package/dist/components/note/index.vue.d.ts +8 -8
  55. package/dist/components/overlay/index.vue +5 -1
  56. package/dist/components/overlay/index.vue.d.ts +2 -1
  57. package/dist/components/pagination/index.vue +4 -4
  58. package/dist/components/pin-input/index.vue +8 -7
  59. package/dist/components/pin-input/index.vue.d.ts +1 -1
  60. package/dist/components/popover/index.vue +4 -3
  61. package/dist/components/popover/index.vue.d.ts +4 -3
  62. package/dist/components/progress/index.vue +8 -2
  63. package/dist/components/progress/index.vue.d.ts +1 -1
  64. package/dist/components/radio/index.vue +10 -13
  65. package/dist/components/radio/index.vue.d.ts +5 -12
  66. package/dist/components/radio-group/index.vue +3 -3
  67. package/dist/components/radio-group/index.vue.d.ts +8 -14
  68. package/dist/components/resizable/index.vue +18 -27
  69. package/dist/components/resizable/index.vue.d.ts +2 -2
  70. package/dist/components/resizable-handle/index.vue +6 -8
  71. package/dist/components/resizable-panel/index.vue +21 -23
  72. package/dist/components/scrollable/index.vue +2 -2
  73. package/dist/components/scrollable/index.vue.d.ts +2 -1
  74. package/dist/components/skeleton/index.vue +8 -11
  75. package/dist/components/slider/index.vue +4 -3
  76. package/dist/components/slider/index.vue.d.ts +1 -1
  77. package/dist/components/snippet/index.vue +14 -33
  78. package/dist/components/snippet/index.vue.d.ts +1 -1
  79. package/dist/components/stack/index.vue +24 -22
  80. package/dist/components/stack/index.vue.d.ts +2 -2
  81. package/dist/components/switch/index.vue +12 -15
  82. package/dist/components/switch/index.vue.d.ts +1 -1
  83. package/dist/components/switch-group/index.vue +9 -6
  84. package/dist/components/switch-group/index.vue.d.ts +4 -12
  85. package/dist/components/text/index.vue +8 -8
  86. package/dist/components/text/index.vue.d.ts +1 -1
  87. package/dist/components/textarea/index.vue +9 -9
  88. package/dist/components/textarea/index.vue.d.ts +1 -1
  89. package/dist/components/toggle/index.vue +4 -2
  90. package/dist/components/toggle/index.vue.d.ts +1 -1
  91. package/dist/components/tooltip/index.vue +4 -5
  92. package/dist/components/tooltip/index.vue.d.ts +4 -4
  93. package/dist/composables/index.d.ts +1 -0
  94. package/dist/composables/index.js +1 -0
  95. package/dist/composables/useConfigProviderContext.d.ts +3 -8
  96. package/dist/composables/useConfigProviderContext.js +10 -15
  97. package/dist/composables/useCopyClick.d.ts +5 -0
  98. package/dist/composables/useCopyClick.js +35 -0
  99. package/dist/composables/useUniqueIdContext.d.ts +2 -2
  100. package/dist/composables/useUniqueIdContext.js +4 -4
  101. package/dist/contexts/avatar.d.ts +2 -0
  102. package/dist/contexts/avatar.js +5 -0
  103. package/dist/contexts/carousel.d.ts +13 -0
  104. package/dist/contexts/carousel.js +5 -0
  105. package/dist/contexts/checkbox.d.ts +2 -0
  106. package/dist/contexts/checkbox.js +5 -0
  107. package/dist/contexts/choicebox.d.ts +4 -0
  108. package/dist/contexts/choicebox.js +11 -0
  109. package/dist/contexts/collapse.d.ts +8 -0
  110. package/dist/contexts/collapse.js +5 -0
  111. package/dist/contexts/menu.d.ts +8 -0
  112. package/dist/contexts/menu.js +5 -0
  113. package/dist/contexts/radio.d.ts +2 -0
  114. package/dist/contexts/radio.js +5 -0
  115. package/dist/contexts/resizable.d.ts +33 -0
  116. package/dist/contexts/resizable.js +5 -0
  117. package/dist/contexts/switch.d.ts +4 -0
  118. package/dist/contexts/switch.js +9 -0
  119. package/dist/index.d.ts +1 -1
  120. package/dist/index.js +1 -1
  121. package/dist/locales/en-US.js +1 -1
  122. package/dist/styles/styles.css +1 -1
  123. package/dist/styles/tw.css +29 -17
  124. package/dist/types/components/avatar.d.ts +11 -0
  125. package/dist/types/components/button.d.ts +1 -1
  126. package/dist/types/components/carousel.d.ts +16 -0
  127. package/dist/types/components/checkbox.d.ts +17 -0
  128. package/dist/types/components/choicebox.d.ts +22 -0
  129. package/dist/types/components/menu.d.ts +1 -1
  130. package/dist/types/components/radio.d.ts +16 -0
  131. package/dist/types/components/switch.d.ts +10 -0
  132. package/dist/types/shared/index.d.ts +1 -0
  133. package/dist/types/shared/props.d.ts +30 -0
  134. package/dist/utils/context.d.ts +17 -0
  135. package/dist/utils/context.js +19 -0
  136. package/dist/utils/fn.js +4 -7
  137. package/dist/utils/format.d.ts +2 -1
  138. package/dist/utils/format.js +7 -4
  139. package/package.json +6 -5
  140. package/dist/components/carousel-group/constants.d.ts +0 -25
  141. package/dist/components/carousel-group/constants.js +0 -3
  142. package/dist/styles/dst.css +0 -351
  143. package/dist/types/components/index.d.ts +0 -6
  144. package/dist/types/components/resizable.d.ts +0 -19
  145. package/dist/types/components/shared.d.ts +0 -18
  146. package/dist/types/components/shared.js +0 -0
  147. package/dist/types/index.d.ts +0 -2
  148. package/dist/types/index.js +0 -2
  149. package/dist/utils/raf.d.ts +0 -2
  150. package/dist/utils/raf.js +0 -3
@@ -12,7 +12,6 @@ interface Props {
12
12
  transpose?: boolean;
13
13
  tooltipText?: string;
14
14
  }
15
- /** 提示框信息 */
16
15
  interface TooltipInfo {
17
16
  date: string;
18
17
  count: number;
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
- import { computed, inject, shallowRef } from "vue";
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 groupSize = inject("pxdAvatarGroupSize", 32);
17
- const computedSize = computed(() => getCssUnitValue(props.size || groupSize));
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, provide } from "vue";
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(() => props.options?.slice(0, props.max));
13
- provide("pxdAvatarGroupSize", props.size);
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>
@@ -1,16 +1,7 @@
1
- interface AvatarGroupOptions {
2
- src?: string;
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: AvatarGroupOptions[];
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 { useConfigProviderSize } from "../../composables/useConfigProviderContext";
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 computedSize = useConfigProviderSize(props.size, SIZES);
44
- const computedClass = computed(
45
- () => twMerge(
46
- "pxd-badge inline-flex items-center justify-center px-2.5 font-medium h-6 text-xs rounded-full font-sans gap-1 !no-underline motion-safe:transition-all",
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
- computedSize.value,
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 {
@@ -1,4 +1,4 @@
1
- import type { ComponentAs } from '../../types/components';
1
+ import type { ComponentAs } from '../../types/shared';
2
2
  interface Props {
3
3
  as?: ComponentAs;
4
4
  variant?: keyof typeof VARIANTS;
@@ -38,20 +38,17 @@ const computedStyle = computed(() => {
38
38
  };
39
39
  });
40
40
  const computedClass = computed(() => {
41
- const basic = ["pxd-book--container w-fit relative transform-3d duration-300 motion-safe:transition-transform"];
42
- basic.push(
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 basic;
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'"
@@ -1,4 +1,4 @@
1
- import type { ComponentLabel, ResponsiveValue } from '../../types/components';
1
+ import type { ComponentLabel, ResponsiveValue } from '../../types/shared';
2
2
  interface Props {
3
3
  color?: string;
4
4
  title?: ComponentLabel;
@@ -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 { useConfigProviderSize } from "../../composables/useConfigProviderContext";
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 rounded-md",
25
- sm: "h-7.5 px-1.5 rounded-md",
26
- md: "h-9 px-2.5 rounded-md",
27
- lg: "h-10 px-3.5 rounded-lg"
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 computedSize = useConfigProviderSize(props.size, SIZES);
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 classNames = ["pxd-button cursor-pointer select-none items-center motion-safe:transition-all", ALIGNMENTS[props.align]];
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
- classNames.push(computedFontSize.value);
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
- classNames.push("aspect-square !p-0");
69
+ classes.push("aspect-square !p-0");
59
70
  }
60
71
  if (variant !== "simple") {
61
- classNames.push("border outline-none self-focus-ring");
62
- classNames.push(getFallbackValue(variant, VARIANTS));
63
- classNames.push(computedSize.value);
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
- classNames.push(DISABLED_CLASS_NAMES);
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 twMerge(classNames);
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 inline-flex truncate">
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 { inject, onBeforeUnmount, shallowRef } from "vue";
3
- import { useUniqueId } from "../../composables/useUniqueIdContext";
4
- import { carouselGroupContextKey } from "../carousel-group/constants";
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 = inject(carouselGroupContextKey);
9
- if (!carouselGroupContext) {
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
- registerCarousel({
38
- uid: uniqueId,
39
- translateItem
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, provide, ref, shallowRef } from "vue";
3
+ import { computed, 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,14 +11,19 @@ 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: 150 },
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
28
  const containerRef = shallowRef();
24
29
  const carousels = ref([]);
@@ -57,7 +62,7 @@ const onToggleClick = throttle((delta) => {
57
62
  virtualIndex.value = Math.max(0, Math.min(virtualIndex.value + delta, length - 1));
58
63
  }
59
64
  emits("change", correctIndex.value);
60
- }, THROTTLE_DELAY, { leading: true, trailing: false });
65
+ }, THROTTLE_INTERVALS, { leading: true, trailing: false });
61
66
  function onWheelToggle(ev) {
62
67
  if (!props.toggleOnWheel) {
63
68
  return;
@@ -111,29 +116,38 @@ function onPointerLeave() {
111
116
  }
112
117
  setAutoPlayTimer();
113
118
  }
119
+ function onIndicatorClick(ev) {
120
+ const target = ev.target;
121
+ const targetIndex = Number(target.dataset.index);
122
+ virtualIndex.value = targetIndex;
123
+ }
114
124
  function registerCarousel(state) {
115
125
  carousels.value.push(state);
116
126
  }
117
127
  function unregisterCarousel(id) {
118
128
  carousels.value = carousels.value.filter(({ uid }) => uid !== id);
119
129
  }
130
+ provideCarouselGroupContext({
131
+ props,
132
+ carousels,
133
+ registerCarousel,
134
+ unregisterCarousel
135
+ });
120
136
  onMounted(() => {
121
137
  onPointerLeave();
122
138
  });
123
139
  onBeforeUnmount(() => {
124
140
  carousels.value = [];
125
141
  });
126
- provide(carouselGroupContextKey, {
127
- props,
128
- carousels,
129
- registerCarousel,
130
- unregisterCarousel
131
- });
132
142
  </script>
133
143
 
134
144
  <template>
135
145
  <div
136
- class="pxd-carousel-group group/carousel w-full relative overflow-hidden"
146
+ tabindex="-1"
147
+ :data-direction="direction"
148
+ :data-indicator-type="indicatorType"
149
+ :data-indicator-position="indicatorPosition"
150
+ class="pxd-carousel-group group w-full relative overflow-hidden touch-manipulation"
137
151
  :style="{ height: getCssUnitValue(height) }"
138
152
  @pointerenter="onPointerEnter"
139
153
  @pointerleave="onPointerLeave"
@@ -141,8 +155,7 @@ provide(carouselGroupContextKey, {
141
155
  >
142
156
  <div
143
157
  ref="containerRef"
144
- :data-direction="direction"
145
- class="pxd-carousel-group--container w-full h-full translate-z-0 data-[direction=horizontal]:flex group-hover/carousel:will-change-transform"
158
+ class="pxd-carousel-group--container w-full h-full translate-z-0 group-data-[direction=horizontal]:flex group-hover:will-change-transform"
146
159
  :style="computedStyle"
147
160
  :class="TRANSITION_CLASSES"
148
161
  @transitionend="onTransitionsEnd"
@@ -150,19 +163,115 @@ provide(carouselGroupContextKey, {
150
163
  <slot />
151
164
  </div>
152
165
 
153
- <template v-if="arrow">
166
+ <div
167
+ v-if="indicator"
168
+ 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"
169
+ @click="onIndicatorClick"
170
+ >
171
+ <button
172
+ v-for="(_, i) in carousels.length"
173
+ :key="i"
174
+ :data-index="i"
175
+ 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"
176
+ :class="{ '!bg-primary': i === correctIndex }"
177
+ />
178
+ </div>
179
+
180
+ <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
181
  <button
155
- class="pxd-carousel-group--prev-button z-10 appearance-none absolute top-1/2 p-2 rounded-full bg-gray-alpha-200 -translate-y-1/2 opacity-0 cursor-pointer left-0 -translate-x-full disabled:pointer-events-none group-hover/carousel:translate-x-1/2 group-hover/carousel:opacity-30 hover:opacity-90 active:opacity-100 motion-safe:transition-all"
182
+ type="button"
183
+ aria-label="Carousel arrow left"
184
+ class="pxd-carousel-group--prev-button outline-none self-focus-ring group-data-[direction=vertical]:rotate-90 appearance-none p-1.5 rounded-md bg-gray-alpha-200 cursor-pointer disabled:pointer-events-none hover:bg-gray-alpha-100 hover:bg-gray-alpha-200 active:bg-gray-alpha-400 motion-safe:transition-colors"
156
185
  @click="onToggleClick(-1)"
157
186
  >
158
187
  <ChevronRightIcon class="rotate-180" />
159
188
  </button>
189
+
160
190
  <button
161
- class="pxd-carousel-group--next-button z-10 appearance-none absolute top-1/2 p-2 rounded-full bg-gray-alpha-200 -translate-y-1/2 opacity-0 cursor-pointer right-0 translate-x-full disabled:pointer-events-none group-hover/carousel:-translate-x-1/2 group-hover/carousel:opacity-30 hover:opacity-90 active:opacity-100 motion-safe:transition-all"
191
+ type="button"
192
+ aria-label="Carousel arrow right"
193
+ class="pxd-carousel-group--next-button outline-none self-focus-ring group-data-[direction=vertical]:rotate-90 appearance-none p-1.5 rounded-md bg-gray-alpha-200 cursor-pointer disabled:pointer-events-none hover:bg-gray-alpha-100 hover:bg-gray-alpha-200 active:bg-gray-alpha-400 motion-safe:transition-colors outline-none"
162
194
  @click="onToggleClick(1)"
163
195
  >
164
196
  <ChevronRightIcon />
165
197
  </button>
166
- </template>
198
+ </div>
167
199
  </div>
168
200
  </template>
201
+
202
+ <style lang="postcss">
203
+ .pxd-carousel-group {
204
+ &[data-indicator-type="dot"] {
205
+ --w: 8px;
206
+ --h: 8px;
207
+ }
208
+
209
+ &[data-indicator-type="line"] {
210
+ &[data-indicator-position="top"],
211
+ &[data-indicator-position="bottom"] {
212
+ --w: 16px;
213
+ --h: 4px;
214
+ }
215
+
216
+ &[data-indicator-position="left"],
217
+ &[data-indicator-position="right"] {
218
+ --w: 4px;
219
+ --h: 16px;
220
+ }
221
+ }
222
+
223
+ &[data-indicator-position="top"] {
224
+ .pxd-carousel-group--indicator {
225
+ left: 12px;
226
+ top: 8px;
227
+ }
228
+
229
+ .pxd-carousel-group--toggle-buttons {
230
+ right: 8px;
231
+ top: 8px;
232
+ }
233
+ }
234
+
235
+ &[data-indicator-position="bottom"] {
236
+ .pxd-carousel-group--indicator {
237
+ left: 12px;
238
+ bottom: 8px;
239
+ }
240
+
241
+ .pxd-carousel-group--toggle-buttons {
242
+ right: 8px;
243
+ bottom: 8px;
244
+ }
245
+ }
246
+
247
+ &[data-indicator-position="left"] {
248
+ .pxd-carousel-group--indicator {
249
+ left: 8px;
250
+ top: 12px;
251
+ }
252
+
253
+ .pxd-carousel-group--toggle-buttons {
254
+ left: 8px;
255
+ bottom: 8px;
256
+ }
257
+ }
258
+
259
+ &[data-indicator-position="right"] {
260
+ .pxd-carousel-group--indicator {
261
+ right: 8px;
262
+ top: 12px;
263
+ }
264
+
265
+ .pxd-carousel-group--toggle-buttons {
266
+ right: 8px;
267
+ bottom: 8px;
268
+ }
269
+ }
270
+ }
271
+
272
+ .pxd-carousel-group--indicator-item::before {
273
+ content: '';
274
+ position: absolute;
275
+ inset: -4px;
276
+ }
277
+ </style>
@@ -1,4 +1,4 @@
1
- import type { CarouselGroupProps } from './constants';
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>;