pxd 0.0.10 → 0.0.12

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 (70) hide show
  1. package/dist/components/avatar/index.vue +90 -0
  2. package/dist/components/avatar/index.vue.d.ts +23 -0
  3. package/dist/components/avatar-group/index.vue +31 -0
  4. package/dist/components/avatar-group/index.vue.d.ts +124 -0
  5. package/dist/components/badge/index.vue +68 -0
  6. package/dist/components/badge/index.vue.d.ts +50 -0
  7. package/dist/components/button/index.vue +12 -13
  8. package/dist/components/button/index.vue.d.ts +24 -0
  9. package/dist/components/checkbox/index.vue +97 -0
  10. package/dist/components/checkbox/index.vue.d.ts +28 -0
  11. package/dist/components/checkbox-group/index.vue +33 -0
  12. package/dist/components/checkbox-group/index.vue.d.ts +30 -0
  13. package/dist/components/color-scheme/index.vue +10 -2
  14. package/dist/components/color-scheme/index.vue.d.ts +9 -0
  15. package/dist/components/config-provider/index.vue.d.ts +20 -0
  16. package/dist/components/error/index.vue +36 -0
  17. package/dist/components/error/index.vue.d.ts +18 -0
  18. package/dist/components/hold-button/index.vue +39 -22
  19. package/dist/components/hold-button/index.vue.d.ts +35 -0
  20. package/dist/components/index.d.ts +17 -0
  21. package/dist/components/index.js +17 -0
  22. package/dist/components/input/index.vue +128 -0
  23. package/dist/components/input/index.vue.d.ts +41 -0
  24. package/dist/components/kbd/index.vue +35 -0
  25. package/dist/components/kbd/index.vue.d.ts +20 -0
  26. package/dist/components/link-button/index.vue +18 -10
  27. package/dist/components/link-button/index.vue.d.ts +29 -0
  28. package/dist/components/loading-dots/index.vue +34 -0
  29. package/dist/components/loading-dots/index.vue.d.ts +14 -0
  30. package/dist/components/more-button/index.vue +3 -10
  31. package/dist/components/more-button/index.vue.d.ts +18 -0
  32. package/dist/components/progress/index.vue +57 -0
  33. package/dist/components/progress/index.vue.d.ts +15 -0
  34. package/dist/components/radio/index.vue +79 -0
  35. package/dist/components/radio/index.vue.d.ts +23 -0
  36. package/dist/components/radio-group/index.vue +39 -0
  37. package/dist/components/radio-group/index.vue.d.ts +29 -0
  38. package/dist/components/scrollable/index.vue +350 -0
  39. package/dist/components/scrollable/index.vue.d.ts +35 -0
  40. package/dist/components/spinner/index.vue +11 -4
  41. package/dist/components/spinner/index.vue.d.ts +2 -0
  42. package/dist/components/stack/index.vue +95 -0
  43. package/dist/components/stack/index.vue.d.ts +20 -0
  44. package/dist/components/status-dot/index.vue +34 -0
  45. package/dist/components/status-dot/index.vue.d.ts +9 -0
  46. package/dist/components/textarea/index.vue +108 -0
  47. package/dist/components/textarea/index.vue.d.ts +25 -0
  48. package/dist/components/toggle/index.vue +81 -0
  49. package/dist/components/toggle/index.vue.d.ts +35 -0
  50. package/dist/composables/index.d.ts +2 -0
  51. package/dist/composables/index.js +2 -0
  52. package/dist/composables/useConfigProviderContext.d.ts +1 -1
  53. package/dist/composables/useMediaQuery.js +11 -10
  54. package/dist/composables/useModelValue.d.ts +10 -0
  55. package/dist/composables/useModelValue.js +8 -0
  56. package/dist/composables/useRandomValueContext.d.ts +2 -0
  57. package/dist/composables/useRandomValueContext.js +11 -0
  58. package/dist/index.d.ts +1 -0
  59. package/dist/index.js +1 -0
  60. package/dist/plugins/resolver.js +2 -1
  61. package/dist/styles/index.css +2 -0
  62. package/dist/styles/tokens.css +18 -22
  63. package/dist/styles/tw.css +50 -24
  64. package/dist/types/components.d.ts +31 -0
  65. package/dist/types/components.js +0 -0
  66. package/dist/utils/format.d.ts +2 -0
  67. package/dist/utils/format.js +10 -0
  68. package/dist/utils/random.d.ts +2 -0
  69. package/dist/utils/random.js +6 -0
  70. package/package.json +20 -7
@@ -0,0 +1,90 @@
1
+ <script setup>
2
+ import { computed, inject, ref } from "vue";
3
+ defineOptions({
4
+ name: "PAvatar"
5
+ });
6
+ const props = defineProps({
7
+ src: { type: String, required: false },
8
+ size: { type: [Number, String], required: false },
9
+ loading: { type: Boolean, required: false }
10
+ });
11
+ defineEmits(["error"]);
12
+ const isLoadFailed = ref(false);
13
+ const groupSize = inject("groupSize", 32);
14
+ const computedSize = computed(() => {
15
+ const _size = props.size || groupSize;
16
+ if (typeof _size === "number") {
17
+ return `${_size}px`;
18
+ }
19
+ return _size;
20
+ });
21
+ const computedLoading = computed(() => props.loading || isLoadFailed.value);
22
+ </script>
23
+
24
+ <template>
25
+ <div
26
+ class="pxd-avatar inline-flex items-center justify-center relative rounded-full border border-white select-none size-(--s)"
27
+ :style="{ '--s': computedSize }"
28
+ >
29
+ <slot>
30
+ <img
31
+ v-if="!computedLoading"
32
+ :src="src"
33
+ alt="avatar"
34
+ loading="lazy"
35
+ decoding="async"
36
+ aria-hidden="true"
37
+ fetchpriority="low"
38
+ crossorigin="anonymous"
39
+ class="relative block rounded-inherit overflow-hidden w-full h-full"
40
+ @error="$emit('error', $event)"
41
+ >
42
+ </slot>
43
+
44
+ <div
45
+ v-if="$slots.badge"
46
+ class="absolute -bottom-1 -left-1 z-10 w-1/2 h-1/2 flex items-center rounded-full border border-white bg-white overflow-hidden"
47
+ >
48
+ <slot name="badge" />
49
+ </div>
50
+ </div>
51
+ </template>
52
+
53
+ <style lang="postcss">
54
+ .pxd-avatar {
55
+ &::before,
56
+ &::after {
57
+ content: '';
58
+ width: 100%;
59
+ height: 100%;
60
+ position: absolute;
61
+ inset: 0;
62
+ border-radius: inherit;
63
+ }
64
+
65
+ &::before {
66
+ background-image: linear-gradient(270deg, var(--gray-alpha-100), var(--gray-alpha-300), var(--gray-alpha-300), var(--gray-alpha-100));
67
+ background-size: 400% 100%;
68
+ }
69
+
70
+ &::after {
71
+ border: 1px solid var(--gray-alpha-400)
72
+ }
73
+ }
74
+
75
+ @keyframes gradient {
76
+ 0% {
77
+ background-position: 200% 0;
78
+ }
79
+
80
+ 100% {
81
+ background-position: -200% 0;
82
+ }
83
+ }
84
+
85
+ @media (prefers-reduced-motion: no-preference) {
86
+ .pxd-avatar::before {
87
+ animation: gradient 8s ease-in-out infinite;
88
+ }
89
+ }
90
+ </style>
@@ -0,0 +1,23 @@
1
+ interface Props {
2
+ src?: string;
3
+ size?: number | string;
4
+ loading?: boolean;
5
+ }
6
+ declare var __VLS_1: {}, __VLS_3: {};
7
+ type __VLS_Slots = {} & {
8
+ default?: (props: typeof __VLS_1) => any;
9
+ } & {
10
+ badge?: (props: typeof __VLS_3) => any;
11
+ };
12
+ declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ error: (args_0: Event) => any;
14
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
15
+ onError?: (args_0: Event) => any;
16
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
+ export default _default;
19
+ type __VLS_WithSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };
@@ -0,0 +1,31 @@
1
+ <script setup>
2
+ import { computed, provide } from "vue";
3
+ import Avatar from "../avatar/index.vue";
4
+ defineOptions({
5
+ name: "PAvatarGroup"
6
+ });
7
+ const props = defineProps({
8
+ max: { type: Number, required: false, default: 5 },
9
+ size: { type: [Number, String], required: false, default: 32 },
10
+ options: { type: Array, required: false, default: () => [] }
11
+ });
12
+ const slicedOptions = computed(() => props.options?.slice(0, props.max));
13
+ provide("groupSize", props.size);
14
+ </script>
15
+
16
+ <template>
17
+ <div class="pxd-avatar-group flex flex-wrap items-center">
18
+ <Avatar
19
+ v-for="(option, index) in slicedOptions"
20
+ :key="index"
21
+ :size="size"
22
+ :src="option.src"
23
+ :loading="option.loading"
24
+ class="[&:nth-child(n+2)]:-ml-3"
25
+ />
26
+
27
+ <Avatar v-if="slicedOptions.length < options.length" class="text-xs bg-gray-1000 text-gray-100 -ml-3">
28
+ +{{ options.length - slicedOptions.length }}
29
+ </Avatar>
30
+ </div>
31
+ </template>
@@ -0,0 +1,124 @@
1
+ interface AvatarGroupOptions {
2
+ src?: string;
3
+ loading?: boolean;
4
+ }
5
+ interface Props {
6
+ max?: number;
7
+ size?: number | string;
8
+ options?: AvatarGroupOptions[];
9
+ }
10
+ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
11
+ max: number;
12
+ options: AvatarGroupOptions[];
13
+ size: number | string;
14
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ export default _default;
16
+ declare global {
17
+ const __VLS_intrinsicElements: __VLS_IntrinsicElements;
18
+ const __VLS_directiveBindingRestFields: {
19
+ instance: null;
20
+ oldValue: null;
21
+ modifiers: any;
22
+ dir: any;
23
+ };
24
+ const __VLS_unref: typeof import('vue').unref;
25
+ const __VLS_placeholder: any;
26
+ type __VLS_NativeElements = __VLS_SpreadMerge<SVGElementTagNameMap, HTMLElementTagNameMap>;
27
+ type __VLS_IntrinsicElements = import('vue/jsx-runtime').JSX.IntrinsicElements;
28
+ type __VLS_Element = import('vue/jsx-runtime').JSX.Element;
29
+ type __VLS_GlobalComponents = import('vue').GlobalComponents;
30
+ type __VLS_GlobalDirectives = import('vue').GlobalDirectives;
31
+ type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
32
+ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
33
+ type __VLS_SpreadMerge<A, B> = Omit<A, keyof B> & B;
34
+ type __VLS_WithComponent<N0 extends string, LocalComponents, Self, N1 extends string, N2 extends string, N3 extends string> = N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
35
+ [K in N0]: LocalComponents[N1];
36
+ } : N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
37
+ [K in N0]: LocalComponents[N2];
38
+ } : N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : {
39
+ [K in N0]: LocalComponents[N3];
40
+ } : Self extends object ? {
41
+ [K in N0]: Self;
42
+ } : N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
43
+ [K in N0]: __VLS_GlobalComponents[N1];
44
+ } : N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
45
+ [K in N0]: __VLS_GlobalComponents[N2];
46
+ } : N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
47
+ [K in N0]: __VLS_GlobalComponents[N3];
48
+ } : {
49
+ [K in N0]: unknown;
50
+ };
51
+ type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
52
+ __ctx?: {
53
+ props?: infer P;
54
+ };
55
+ } ? NonNullable<P> : never : T extends (props: infer P, ...args: any) => any ? P : {};
56
+ type __VLS_IsFunction<T, K> = K extends keyof T ? __VLS_IsAny<T[K]> extends false ? unknown extends T[K] ? false : true : false : false;
57
+ type __VLS_NormalizeComponentEvent<Props, Events, onEvent extends keyof Props, Event extends keyof Events, CamelizedEvent extends keyof Events> = (__VLS_IsFunction<Props, onEvent> extends true ? Props : __VLS_IsFunction<Events, Event> extends true ? {
58
+ [K in onEvent]?: Events[Event];
59
+ } : __VLS_IsFunction<Events, CamelizedEvent> extends true ? {
60
+ [K in onEvent]?: Events[CamelizedEvent];
61
+ } : Props) & Record<string, unknown>;
62
+ type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
63
+ type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R ? U extends T ? never : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R) : never;
64
+ type __VLS_OverloadUnion<T> = Exclude<__VLS_OverloadUnionInner<(() => never) & T>, T extends () => never ? never : () => never>;
65
+ type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F ? F extends (event: infer E, ...args: infer A) => any ? {
66
+ [K in E & string]: (...args: A) => void;
67
+ } : never : never;
68
+ type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<__VLS_UnionToIntersection<__VLS_ConstructorOverloads<T> & {
69
+ [K in keyof T]: T[K] extends any[] ? {
70
+ (...args: T[K]): void;
71
+ } : never;
72
+ }>>;
73
+ type __VLS_PrettifyGlobal<T> = {
74
+ [K in keyof T]: T[K];
75
+ } & {};
76
+ type __VLS_PickFunctionalComponentCtx<T, K> = NonNullable<__VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
77
+ __ctx?: infer Ctx;
78
+ } ? Ctx : never : any, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any>>;
79
+ type __VLS_UseTemplateRef<T> = Readonly<import('vue').ShallowRef<T | null>>;
80
+ function __VLS_getVForSourceType<T extends number | string | any[] | Iterable<any>>(source: T): [
81
+ item: T extends number ? number : T extends string ? string : T extends any[] ? T[number] : T extends Iterable<infer T1> ? T1 : any,
82
+ index: number
83
+ ][];
84
+ function __VLS_getVForSourceType<T>(source: T): [
85
+ item: T[keyof T],
86
+ key: keyof T,
87
+ index: number
88
+ ][];
89
+ function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
90
+ function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
91
+ function __VLS_asFunctionalDirective<T>(dir: T): T extends import('vue').ObjectDirective ? NonNullable<T['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']> : T extends (...args: any) => any ? T : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
92
+ function __VLS_makeOptional<T>(t: T): {
93
+ [K in keyof T]?: T[K];
94
+ };
95
+ function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): T extends new (...args: any) => any ? (props: (K extends {
96
+ $props: infer Props;
97
+ } ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & {
98
+ __ctx?: {
99
+ attrs?: any;
100
+ slots?: K extends {
101
+ $slots: infer Slots;
102
+ } ? Slots : any;
103
+ emit?: K extends {
104
+ $emit: infer Emit;
105
+ } ? Emit : any;
106
+ expose?(exposed: K): void;
107
+ props?: (K extends {
108
+ $props: infer Props;
109
+ } ? Props : any) & Record<string, unknown>;
110
+ };
111
+ } : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T> : T extends (...args: any) => any ? T : (_: {} & Record<string, unknown>, ctx?: any) => {
112
+ __ctx?: {
113
+ attrs?: any;
114
+ expose?: any;
115
+ slots?: any;
116
+ emit?: any;
117
+ props?: {} & Record<string, unknown>;
118
+ };
119
+ };
120
+ function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
121
+ function __VLS_asFunctionalElement<T>(tag: T, endTag?: T): (attrs: T & Record<string, unknown>) => void;
122
+ function __VLS_asFunctionalSlot<S>(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable<S>;
123
+ function __VLS_tryAsConstant<const T>(t: T): T;
124
+ }
@@ -0,0 +1,68 @@
1
+ <script setup>
2
+ import { twMerge } from "tailwind-merge";
3
+ import { computed } from "vue";
4
+ import { useConfigProvider } from "../../composables/useConfigProviderContext";
5
+ defineOptions({
6
+ name: "PBadge"
7
+ });
8
+ const props = defineProps({
9
+ as: { type: null, required: false, default: "span" },
10
+ variant: { type: null, required: false, default: "gray" },
11
+ size: { type: null, required: false },
12
+ href: { type: String, required: false }
13
+ });
14
+ const config = useConfigProvider();
15
+ const SIZES = {
16
+ sm: "px-1.5 h-5 text-xs",
17
+ md: "px-2.5 h-6 text-xs",
18
+ lg: "px-3 h-7.5 text-sm"
19
+ };
20
+ const VARIANTS = {
21
+ "pill": "bg-background shadow-[0_0_0_1px_var(--color-gray-300)]",
22
+ "gray": "bg-gray-600 text-white",
23
+ "blue": "bg-blue-700 text-gray-100 dark:text-gray-1000",
24
+ "purple": "bg-purple-700 text-gray-100 dark:text-gray-1000",
25
+ "amber": "bg-amber-700 text-gray-1000 dark:text-gray-100",
26
+ "red": "bg-red-700 text-gray-100 dark:text-gray-1000",
27
+ "pink": "bg-pink-700 text-gray-100 dark:text-gray-1000",
28
+ "green": "bg-green-700 text-gray-100 dark:text-gray-1000",
29
+ "teal": "bg-teal-700 text-gray-100 dark:text-gray-1000",
30
+ "gray-subtle": "bg-gray-200 text-gray-1000",
31
+ "blue-subtle": "bg-blue-200 text-blue-900",
32
+ "purple-subtle": "bg-purple-200 text-purple-900",
33
+ "amber-subtle": "bg-amber-200 text-amber-900",
34
+ "red-subtle": "bg-red-200 text-red-900",
35
+ "pink-subtle": "bg-pink-200 text-pink-900",
36
+ "green-subtle": "bg-green-200 text-green-900",
37
+ "teal-subtle": "bg-teal-200 text-teal-900",
38
+ "inverted": "bg-gray-1000 text-gray-100",
39
+ "vue": "text-gray-100 dark:text-gray-1000 bg-linear-[315deg,#42d392_25%,#647eff]",
40
+ "trial": "text-gray-100 dark:text-gray-1000 bg-linear-[135deg,#0070f3,#f81ce5]",
41
+ "turborepo": "text-gray-100 dark:text-gray-1000 bg-linear-[135deg,#ff1e56,#0096ff]"
42
+ };
43
+ const computedClass = computed(
44
+ () => twMerge(
45
+ "pxd-badge inline-flex items-center justify-center px-2.5 h-6 text-xs rounded-full font-sans gap-1 !no-underline",
46
+ VARIANTS[props.variant],
47
+ SIZES[props.size || config.size]
48
+ )
49
+ );
50
+ const badgeAttrs = computed(() => {
51
+ if (props.as === "router-link" || props.as === "RouterLink") {
52
+ return {
53
+ to: props.href
54
+ };
55
+ } else if (props.as === "a") {
56
+ return {
57
+ href: props.href
58
+ };
59
+ }
60
+ return {};
61
+ });
62
+ </script>
63
+
64
+ <template>
65
+ <component :is="as" :class="computedClass" v-bind="badgeAttrs">
66
+ <slot />
67
+ </component>
68
+ </template>
@@ -0,0 +1,50 @@
1
+ import type { ComponentAs } from '../../types/components';
2
+ interface Props {
3
+ as?: ComponentAs;
4
+ variant?: keyof typeof VARIANTS;
5
+ size?: keyof typeof SIZES;
6
+ href?: string;
7
+ }
8
+ declare const SIZES: {
9
+ sm: string;
10
+ md: string;
11
+ lg: string;
12
+ };
13
+ declare const VARIANTS: {
14
+ pill: string;
15
+ gray: string;
16
+ blue: string;
17
+ purple: string;
18
+ amber: string;
19
+ red: string;
20
+ pink: string;
21
+ green: string;
22
+ teal: string;
23
+ 'gray-subtle': string;
24
+ 'blue-subtle': string;
25
+ 'purple-subtle': string;
26
+ 'amber-subtle': string;
27
+ 'red-subtle': string;
28
+ 'pink-subtle': string;
29
+ 'green-subtle': string;
30
+ 'teal-subtle': string;
31
+ inverted: string;
32
+ vue: string;
33
+ trial: string;
34
+ turborepo: string;
35
+ };
36
+ declare var __VLS_6: {};
37
+ type __VLS_Slots = {} & {
38
+ default?: (props: typeof __VLS_6) => any;
39
+ };
40
+ declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
41
+ variant: keyof typeof VARIANTS;
42
+ as: ComponentAs;
43
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
44
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
45
+ export default _default;
46
+ type __VLS_WithSlots<T, S> = T & {
47
+ new (): {
48
+ $slots: S;
49
+ };
50
+ };
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { twMerge } from "tailwind-merge";
3
- import { computed, useAttrs } from "vue";
3
+ import { computed } from "vue";
4
4
  import { useConfigProvider } from "../../composables/useConfigProviderContext";
5
5
  import Spinner from "../spinner/index.vue";
6
6
  defineOptions({
@@ -8,26 +8,25 @@ defineOptions({
8
8
  });
9
9
  const props = defineProps({
10
10
  as: { type: null, required: false, default: "button" },
11
- variant: { type: null, required: false, default: "outline" },
12
- size: { type: null, required: false },
11
+ variant: { type: String, required: false, default: "outline" },
12
+ size: { type: String, required: false },
13
13
  shape: { type: String, required: false },
14
14
  block: { type: Boolean, required: false },
15
15
  loading: { type: Boolean, required: false },
16
16
  disabled: { type: Boolean, required: false }
17
17
  });
18
18
  const emits = defineEmits(["click"]);
19
- const attrs = useAttrs();
20
19
  const config = useConfigProvider();
21
20
  const SIZES = {
22
21
  xs: "px-1 rounded-md h-6 text-sm",
23
- sm: "px-1.5 rounded-md h-7 text-sm",
24
- md: "px-2.5 rounded-md h-8 text-sm",
25
- lg: "px-3.5 rounded-lg h-9 text-base"
22
+ sm: "px-1.5 rounded-md h-7.5 text-sm",
23
+ md: "px-2.5 rounded-md h-9 text-sm",
24
+ lg: "px-3.5 rounded-lg h-10.5 text-base"
26
25
  };
27
26
  const VARIANTS = {
28
27
  outline: "bg-background text-foreground hover:bg-background-hover active:bg-background-active border-input",
29
28
  ghost: "bg-transparent text-foreground hover:bg-gray-alpha-200 active:bg-gray-alpha-300 border-transparent",
30
- primary: "bg-foreground text-background hover:bg-foreground/80 active:bg-foreground border-transparent",
29
+ primary: "bg-primary text-gray-100 hover:bg-primary/80 active:bg-primary border-transparent",
31
30
  error: "bg-red-800 text-white hover:bg-red-700 active:bg-red-800 border-transparent",
32
31
  warning: "bg-amber-800 text-black hover:bg-amber-700 active:bg-amber-800 border-transparent",
33
32
  success: "bg-green-800 text-white hover:bg-green-700 active:bg-green-800 border-transparent"
@@ -36,11 +35,11 @@ const DISABLED_CLASS_NAMES = "is-disabled bg-gray-100 hover:bg-gray-100 active:b
36
35
  const computedDisabled = computed(() => {
37
36
  return props.disabled || props.loading;
38
37
  });
39
- const computedClassNames = computed(() => {
40
- const classNames = ["pxd-button cursor-pointer motion-safe:transition-colors items-center justify-center border"];
38
+ const computedClasses = computed(() => {
39
+ const classNames = ["pxd-button cursor-pointer select-none items-center justify-center border outline-none self-focus-ring motion-safe:transition-colors"];
41
40
  classNames.push(VARIANTS[props.variant] || VARIANTS.outline);
42
41
  classNames.push(SIZES[props.size || config.size]);
43
- classNames.push(props.block ? "flex " : "inline-flex");
42
+ classNames.push(props.block ? "flex w-full" : "inline-flex");
44
43
  if (computedDisabled.value) {
45
44
  classNames.push(DISABLED_CLASS_NAMES);
46
45
  }
@@ -49,7 +48,7 @@ const computedClassNames = computed(() => {
49
48
  props.shape === "square" ? "rounded-none" : "rounded-full"
50
49
  );
51
50
  }
52
- return twMerge(classNames, attrs.class);
51
+ return twMerge(classNames);
53
52
  });
54
53
  function onButtonClick(event) {
55
54
  emits("click", event);
@@ -60,7 +59,7 @@ function onButtonClick(event) {
60
59
  <Component
61
60
  :is="as"
62
61
  role="button"
63
- :class="computedClassNames"
62
+ :class="computedClasses"
64
63
  :disabled="computedDisabled"
65
64
  @click="onButtonClick"
66
65
  >
@@ -0,0 +1,24 @@
1
+ import type { ButtonProps } from '../../types/components';
2
+ declare var __VLS_13: {}, __VLS_15: {}, __VLS_17: {};
3
+ type __VLS_Slots = {} & {
4
+ prefix?: (props: typeof __VLS_13) => any;
5
+ } & {
6
+ default?: (props: typeof __VLS_15) => any;
7
+ } & {
8
+ suffix?: (props: typeof __VLS_17) => any;
9
+ };
10
+ declare const __VLS_component: import("vue").DefineComponent<ButtonProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ click: (args_0: MouseEvent) => any;
12
+ }, string, import("vue").PublicProps, Readonly<ButtonProps> & Readonly<{
13
+ onClick?: (args_0: MouseEvent) => any;
14
+ }>, {
15
+ variant: "outline" | "ghost" | "primary" | "error" | "warning" | "success";
16
+ as: import("../../types/components").ComponentAs;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
19
+ export default _default;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -0,0 +1,97 @@
1
+ <script setup>
2
+ import { CheckIcon, MinusIcon } from "gdsi/vue";
3
+ import { twMerge } from "tailwind-merge";
4
+ import { computed, inject } from "vue";
5
+ import { useModelValue } from "../../composables/useModelValue";
6
+ import { getRandomId } from "../../utils/random";
7
+ defineOptions({
8
+ name: "PCheckbox",
9
+ model: {
10
+ prop: "modelValue",
11
+ event: "update:modelValue"
12
+ }
13
+ });
14
+ const props = defineProps({
15
+ label: { type: [String, Number], required: false },
16
+ value: { type: [String, Number, Boolean], required: false, default: true },
17
+ disabled: { type: Boolean, required: false },
18
+ required: { type: Boolean, required: false },
19
+ modelValue: { type: [String, Number, Boolean, Array], required: false, default: false },
20
+ indeterminate: { type: Boolean, required: false }
21
+ });
22
+ const emits = defineEmits(["update:modelValue"]);
23
+ const randomId = getRandomId();
24
+ const modelValue = useModelValue(props, emits);
25
+ const checkboxGroupProps = inject("checkboxGroupProps", {
26
+ disabled: false,
27
+ required: false
28
+ });
29
+ const isChecked = computed(() => {
30
+ if (Array.isArray(modelValue.value)) {
31
+ return modelValue.value.includes(props.value);
32
+ }
33
+ if (typeof props.value === "boolean") {
34
+ return modelValue.value;
35
+ }
36
+ return modelValue.value === props.value;
37
+ });
38
+ const computedDisabled = computed(() => props.disabled || checkboxGroupProps.disabled);
39
+ const computedRequired = computed(() => props.required || checkboxGroupProps.required);
40
+ const computedInnerClasses = computed(() => {
41
+ const basic = [
42
+ "pxd-checkbox--inner size-4 flex-shrink-0 inline-flex items-center justify-center peer-focus-ring",
43
+ "rounded-sm border overflow-hidden transform-gpu motion-safe:transition-colors"
44
+ ];
45
+ if (isChecked.value) {
46
+ basic.push(
47
+ computedDisabled.value ? "bg-gray-600 border-gray-600" : "bg-gray-1000 border-gray-1000"
48
+ );
49
+ } else {
50
+ basic.push(
51
+ computedDisabled.value ? "bg-gray-100 border-gray-500" : "bg-background border-gray-alpha-400 group-hover:bg-gray-200"
52
+ );
53
+ }
54
+ return twMerge(basic);
55
+ });
56
+ function toggleChecked(isChecked2) {
57
+ if (Array.isArray(modelValue.value)) {
58
+ modelValue.value = isChecked2 ? [...modelValue.value, props.value] : modelValue.value.filter((v) => v !== props.value);
59
+ return;
60
+ }
61
+ modelValue.value = isChecked2;
62
+ }
63
+ function onInputChange(event) {
64
+ const isInputChecked = event.target.checked;
65
+ toggleChecked(isInputChecked);
66
+ }
67
+ </script>
68
+
69
+ <template>
70
+ <label
71
+ class="pxd-checkbox inline-flex items-center group"
72
+ :class="{ 'is-disabled cursor-not-allowed text-gray-500': computedDisabled }"
73
+ :for="randomId"
74
+ >
75
+ <input
76
+ :id="randomId"
77
+ :value="value"
78
+ type="checkbox"
79
+ class="smallest peer"
80
+ :checked="isChecked"
81
+ :required="computedRequired"
82
+ :disabled="computedDisabled"
83
+ @change="onInputChange"
84
+ >
85
+ <span aria-hidden="true" :class="computedInnerClasses">
86
+ <CheckIcon v-if="isChecked" class="size-3 text-gray-100" />
87
+ <MinusIcon v-else-if="indeterminate" class="size-3" />
88
+ <span v-else class="size-3" />
89
+ </span>
90
+
91
+ <span class="ml-2 text-sm empty:hidden">
92
+ <slot>
93
+ {{ label }}
94
+ </slot>
95
+ </span>
96
+ </label>
97
+ </template>
@@ -0,0 +1,28 @@
1
+ type ValueType = string | number | boolean;
2
+ interface Props {
3
+ label?: string | number;
4
+ value?: ValueType;
5
+ disabled?: boolean;
6
+ required?: boolean;
7
+ modelValue?: ValueType | ValueType[];
8
+ indeterminate?: boolean;
9
+ }
10
+ declare var __VLS_9: {};
11
+ type __VLS_Slots = {} & {
12
+ default?: (props: typeof __VLS_9) => any;
13
+ };
14
+ declare const __VLS_component: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ "update:modelValue": (args_0: ValueType | ValueType[]) => any;
16
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
17
+ "onUpdate:modelValue"?: (args_0: ValueType | ValueType[]) => any;
18
+ }>, {
19
+ value: ValueType;
20
+ modelValue: ValueType | ValueType[];
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
23
+ export default _default;
24
+ type __VLS_WithSlots<T, S> = T & {
25
+ new (): {
26
+ $slots: S;
27
+ };
28
+ };
@@ -0,0 +1,33 @@
1
+ <script setup>
2
+ import { provide } from "vue";
3
+ import { useModelValue } from "../../composables/useModelValue";
4
+ import Checkbox from "../checkbox/index.vue";
5
+ import Stack from "../stack/index.vue";
6
+ defineOptions({
7
+ name: "PCheckboxGroup"
8
+ });
9
+ const props = defineProps({
10
+ disabled: { type: Boolean, required: false },
11
+ required: { type: Boolean, required: false },
12
+ modelValue: { type: Array, required: false, default: () => [] },
13
+ options: { type: Array, required: false, default: () => [] }
14
+ });
15
+ const emits = defineEmits(["update:modelValue"]);
16
+ const modelValue = useModelValue(props, emits);
17
+ provide("checkboxGroupProps", props);
18
+ </script>
19
+
20
+ <template>
21
+ <Stack class="pxd-checkbox-group">
22
+ <slot>
23
+ <Checkbox
24
+ v-for="option in options"
25
+ :key="option.value"
26
+ v-model="modelValue"
27
+ :label="option.label"
28
+ :value="option.value"
29
+ :disabled="option.disabled"
30
+ />
31
+ </slot>
32
+ </Stack>
33
+ </template>