pxd 0.0.5 → 0.0.7
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/README.md +14 -70
- package/dist/components/button/index.vue +64 -0
- package/dist/components/config-provider/index.vue +17 -0
- package/dist/components/hold-button/index.vue +72 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/composables/useConfigProviderContext.d.ts +8 -0
- package/dist/composables/useConfigProviderContext.js +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/plugins/nuxt.d.ts +5 -0
- package/dist/plugins/nuxt.js +24 -0
- package/dist/plugins/resolver.d.ts +3 -3
- package/dist/plugins/resolver.js +19 -1
- package/dist/styles/tw.css +378 -0
- package/package.json +67 -50
- package/dist/Check.js +0 -1
- package/dist/ChevronDown.js +0 -1
- package/dist/code-block.css +0 -1
- package/dist/components/_utils/css.d.ts +0 -9
- package/dist/components/_utils/css.js +0 -1
- package/dist/components/avatar/_.js +0 -1
- package/dist/components/avatar/index.d.ts +0 -6
- package/dist/components/avatar/index.js +0 -1
- package/dist/components/avatar/src/avatar.d.ts +0 -22
- package/dist/components/avatar-group/index.d.ts +0 -7
- package/dist/components/avatar-group/index.js +0 -1
- package/dist/components/avatar-group/src/avatar-group.d.ts +0 -3
- package/dist/components/badge/index.d.ts +0 -1
- package/dist/components/badge/index.js +0 -1
- package/dist/components/badge/src/badge.d.ts +0 -42
- package/dist/components/book/index.d.ts +0 -1
- package/dist/components/book/index.js +0 -1
- package/dist/components/book/src/book.d.ts +0 -8
- package/dist/components/button/index.d.ts +0 -23
- package/dist/components/button/index.js +0 -1
- package/dist/components/button/src/button.d.ts +0 -29
- package/dist/components/checkbox/index.d.ts +0 -1
- package/dist/components/checkbox/index.js +0 -1
- package/dist/components/checkbox/src/checkbox.d.ts +0 -27
- package/dist/components/checkbox-group/index.d.ts +0 -4
- package/dist/components/checkbox-group/index.js +0 -1
- package/dist/components/checkbox-group/src/checkbox-group.d.ts +0 -17
- package/dist/components/choicebox/index.d.ts +0 -1
- package/dist/components/choicebox/index.js +0 -1
- package/dist/components/choicebox/src/choicebox.d.ts +0 -21
- package/dist/components/choicebox-group/index.d.ts +0 -13
- package/dist/components/choicebox-group/index.js +0 -1
- package/dist/components/choicebox-group/src/choicebox-group.d.ts +0 -25
- package/dist/components/code-block/index.d.ts +0 -1
- package/dist/components/code-block/index.js +0 -1
- package/dist/components/code-block/src/code-block.d.ts +0 -8
- package/dist/components/collapse/index.d.ts +0 -1
- package/dist/components/collapse/index.js +0 -1
- package/dist/components/collapse/src/collapse.d.ts +0 -9
- package/dist/components/combobox/index.d.ts +0 -1
- package/dist/components/combobox/index.js +0 -1
- package/dist/components/combobox/src/combobox.d.ts +0 -19
- package/dist/components/dialog/index.d.ts +0 -1
- package/dist/components/dialog/index.js +0 -1
- package/dist/components/dialog/src/dialog.d.ts +0 -32
- package/dist/components/error/index.d.ts +0 -1
- package/dist/components/error/index.js +0 -1
- package/dist/components/error/src/error.d.ts +0 -22
- package/dist/components/input/index.d.ts +0 -4
- package/dist/components/input/index.js +0 -1
- package/dist/components/input/src/input.d.ts +0 -25
- package/dist/components/keyboard-input/index.d.ts +0 -1
- package/dist/components/keyboard-input/index.js +0 -1
- package/dist/components/keyboard-input/src/keyboard-input.d.ts +0 -24
- package/dist/components/link/index.d.ts +0 -1
- package/dist/components/link/index.js +0 -1
- package/dist/components/link/src/link.d.ts +0 -23
- package/dist/components/loading-dots/index.d.ts +0 -1
- package/dist/components/loading-dots/index.js +0 -1
- package/dist/components/loading-dots/src/loading-dots.d.ts +0 -19
- package/dist/components/overlay/index.d.ts +0 -1
- package/dist/components/overlay/index.js +0 -1
- package/dist/components/overlay/src/overlay.d.ts +0 -5
- package/dist/components/progress/index.d.ts +0 -1
- package/dist/components/progress/index.js +0 -1
- package/dist/components/progress/src/progress.d.ts +0 -15
- package/dist/components/radio/index.d.ts +0 -6
- package/dist/components/radio/index.js +0 -1
- package/dist/components/radio/src/radio.d.ts +0 -17
- package/dist/components/scroller/index.d.ts +0 -1
- package/dist/components/scroller/index.js +0 -1
- package/dist/components/scroller/src/scroller.d.ts +0 -16
- package/dist/components/select/index.d.ts +0 -1
- package/dist/components/select/index.js +0 -1
- package/dist/components/select/src/select.d.ts +0 -15
- package/dist/components/show-more/index.d.ts +0 -1
- package/dist/components/show-more/index.js +0 -1
- package/dist/components/show-more/src/show-more.d.ts +0 -16
- package/dist/components/spinner/_.js +0 -1
- package/dist/components/spinner/index.d.ts +0 -1
- package/dist/components/spinner/index.js +0 -1
- package/dist/components/spinner/src/spinner.d.ts +0 -5
- package/dist/components/status-dot/index.d.ts +0 -1
- package/dist/components/status-dot/index.js +0 -1
- package/dist/components/status-dot/src/status-dot.d.ts +0 -6
- package/dist/components/switch/index.d.ts +0 -1
- package/dist/components/switch/index.js +0 -1
- package/dist/components/switch/src/switch.d.ts +0 -38
- package/dist/components/tabs/index.d.ts +0 -8
- package/dist/components/tabs/index.js +0 -1
- package/dist/components/tabs/src/tabs.d.ts +0 -48
- package/dist/components/tabs-item/index.d.ts +0 -1
- package/dist/components/tabs-item/index.js +0 -1
- package/dist/components/tabs-item/src/tabs-item.d.ts +0 -34
- package/dist/components/textarea/index.d.ts +0 -1
- package/dist/components/textarea/index.js +0 -1
- package/dist/components/textarea/src/textarea.d.ts +0 -16
- package/dist/components/toggle/index.d.ts +0 -1
- package/dist/components/toggle/index.js +0 -1
- package/dist/components/toggle/src/toggle.d.ts +0 -35
- package/dist/error.vue_vue_type_script_setup_true_lang.js +0 -1
- package/dist/link.vue_vue_type_script_setup_true_lang.js +0 -1
- package/dist/plugins/tailwind-preset.d.ts +0 -196
- package/dist/plugins/tailwind-preset.js +0 -1
- package/dist/vars.css +0 -1
package/README.md
CHANGED
|
@@ -1,84 +1,28 @@
|
|
|
1
1
|
# PXD
|
|
2
|
-
|
|
2
|
+
A universal UI component library for Vue2&3
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
> The library is still under development and may undergo major changes at any time.
|
|
4
|
+
## Contribution
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
> This is a COMMUNITY PROJECT, not associated with Vercel, originating from [Vercel design system](https://vercel.com/geist/introduction). Did not strictly follow its implementation, and added some personal ideas.
|
|
6
|
+
### Dev
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
```shell
|
|
9
|
+
pnpm install
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
pnpm i pxd
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
### Styles
|
|
19
|
-
```js
|
|
20
|
-
// tailwind.config.js
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
content: [
|
|
24
|
-
'./src/**/*.{ts,tsx,vue}',
|
|
25
|
-
'./node_modules/pxd/dist/components/**/*.js',
|
|
26
|
-
]
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### vars.css
|
|
11
|
+
pnpm dev
|
|
31
12
|
|
|
32
|
-
|
|
33
|
-
// main.ts
|
|
34
|
-
import 'pxd/vars.css'
|
|
13
|
+
pnpm dev:docs
|
|
35
14
|
```
|
|
36
15
|
|
|
37
|
-
###
|
|
16
|
+
### Build
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
// vite.config.js
|
|
41
|
-
import PxResolver from 'pxd/resolver'
|
|
42
|
-
import VueComponents from 'unplugin-vue-components/vite'
|
|
43
|
-
import { defineConfig } from 'vite'
|
|
18
|
+
#### Core
|
|
44
19
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
VueComponents({
|
|
48
|
-
resolvers: [
|
|
49
|
-
PxResolver()
|
|
50
|
-
]
|
|
51
|
-
})
|
|
52
|
-
]
|
|
53
|
-
})
|
|
20
|
+
```shell
|
|
21
|
+
pnpm build
|
|
54
22
|
```
|
|
55
23
|
|
|
56
|
-
|
|
57
|
-
We strongly recommend using automatic import because it can significantly reduce the package size.
|
|
24
|
+
#### Docs
|
|
58
25
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// main.ts
|
|
62
|
-
|
|
63
|
-
// All components only need to import this style file.
|
|
64
|
-
import 'pxd/vars.css'
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
```vue
|
|
68
|
-
<script setup>
|
|
69
|
-
import Button from 'pxd/components/button/index.js'
|
|
70
|
-
</script>
|
|
71
|
-
|
|
72
|
-
<template>
|
|
73
|
-
<Button>
|
|
74
|
-
Button
|
|
75
|
-
</Button>
|
|
76
|
-
</template>
|
|
26
|
+
```shell
|
|
27
|
+
pnpm build:docs
|
|
77
28
|
```
|
|
78
|
-
|
|
79
|
-
## Acknowledgement
|
|
80
|
-
rankings are in no particular order, they are all very important to this project.
|
|
81
|
-
|
|
82
|
-
- Vite: https://vitejs.dev/
|
|
83
|
-
- Iconify: https://iconify.design/
|
|
84
|
-
- Geist Design System: https://vercel.com/geist/introduction
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useConfigProvider } from "../../composables/useConfigProviderContext";
|
|
4
|
+
defineOptions({
|
|
5
|
+
name: "PButton"
|
|
6
|
+
});
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
variant: { type: null, required: false, default: "outline" },
|
|
9
|
+
size: { type: null, required: false },
|
|
10
|
+
disabled: { type: Boolean, required: false },
|
|
11
|
+
block: { type: Boolean, required: false },
|
|
12
|
+
href: { type: String, required: false },
|
|
13
|
+
shape: { type: String, required: false }
|
|
14
|
+
});
|
|
15
|
+
const config = useConfigProvider();
|
|
16
|
+
const SIZES = {
|
|
17
|
+
xs: "px-1 rounded-md h-6 text-sm ",
|
|
18
|
+
sm: "px-1.5 rounded-md h-7 text-sm ",
|
|
19
|
+
md: "px-2.5 rounded-md h-8 text-sm ",
|
|
20
|
+
lg: "px-3.5 rounded-lg h-9 text-base "
|
|
21
|
+
};
|
|
22
|
+
const VARIANTS = {
|
|
23
|
+
outline: "bg-background text-foreground hover:bg-background-hover active:bg-background-active border-input ",
|
|
24
|
+
ghost: "bg-transparent text-foreground hover:bg-gray-alpha-200 active:bg-gray-alpha-300 border-transparent ",
|
|
25
|
+
primary: "bg-foreground text-background hover:bg-foreground/80 active:bg-foreground border-transparent ",
|
|
26
|
+
error: "bg-red-800 text-white hover:bg-red-700 active:bg-red-800 border-transparent ",
|
|
27
|
+
warning: "bg-amber-800 text-black hover:bg-amber-700 active:bg-amber-800 border-transparent ",
|
|
28
|
+
success: "bg-green-800 text-white hover:bg-green-700 active:bg-green-800 border-transparent "
|
|
29
|
+
};
|
|
30
|
+
const DISABLED_CLASS_NAMES = "disabled:bg-gray-100 !text-gray-700 border-none shadow-[0_0_0_1px_hsl(var(--gray-200-value))] !cursor-not-allowed ";
|
|
31
|
+
const computedClassNames = computed(() => {
|
|
32
|
+
let classNames = "";
|
|
33
|
+
classNames += VARIANTS[props.variant] || VARIANTS.outline;
|
|
34
|
+
classNames += SIZES[props.size || config.size];
|
|
35
|
+
classNames += props.block ? "flex " : "inline-flex ";
|
|
36
|
+
if (props.disabled) {
|
|
37
|
+
classNames += DISABLED_CLASS_NAMES;
|
|
38
|
+
}
|
|
39
|
+
if (props.shape === "square") {
|
|
40
|
+
classNames += "!rounded-none ";
|
|
41
|
+
} else if (props.shape === "rounded") {
|
|
42
|
+
classNames += "!rounded-full ";
|
|
43
|
+
}
|
|
44
|
+
return classNames;
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<Component
|
|
50
|
+
:is="props.href ? 'router-link' : 'button'"
|
|
51
|
+
class="pxd-button cursor-pointer transition-colors items-center justify-center border"
|
|
52
|
+
:class="computedClassNames"
|
|
53
|
+
:disabled="disabled"
|
|
54
|
+
:to="href"
|
|
55
|
+
>
|
|
56
|
+
<slot name="prefix" />
|
|
57
|
+
|
|
58
|
+
<span class="px-1 inline-flex truncate">
|
|
59
|
+
<slot />
|
|
60
|
+
</span>
|
|
61
|
+
|
|
62
|
+
<slot name="suffix" />
|
|
63
|
+
</Component>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { defaultConfig, provideConfigProvider } from "../../composables/useConfigProviderContext";
|
|
3
|
+
defineOptions({
|
|
4
|
+
name: "PConfigProvider"
|
|
5
|
+
});
|
|
6
|
+
const props = defineProps(/* @__PURE__ */ _mergeDefaults({
|
|
7
|
+
as: { type: null, required: false },
|
|
8
|
+
size: { type: String, required: false }
|
|
9
|
+
}, { as: "div", ...defaultConfig }));
|
|
10
|
+
provideConfigProvider(props);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<component :is="as" class="pxd-config-provider">
|
|
15
|
+
<slot />
|
|
16
|
+
</component>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { shallowRef } from "vue";
|
|
3
|
+
import Button from "../button/index.vue";
|
|
4
|
+
defineProps({
|
|
5
|
+
scale: { type: Boolean, required: false, default: true },
|
|
6
|
+
durations: { type: [Number, String], required: false, default: 2 },
|
|
7
|
+
maskColor: { type: String, required: false, default: "hsl(var(--red-600-value))" }
|
|
8
|
+
});
|
|
9
|
+
const emits = defineEmits(["trigger", "confirm"]);
|
|
10
|
+
let isPointerDown = true;
|
|
11
|
+
const isConfirm = shallowRef(false);
|
|
12
|
+
function onPointerDown() {
|
|
13
|
+
isPointerDown = true;
|
|
14
|
+
isConfirm.value = false;
|
|
15
|
+
}
|
|
16
|
+
function onTransitionEnd(ev) {
|
|
17
|
+
const targetElement = ev.target;
|
|
18
|
+
const styleValue = getComputedStyle(targetElement).getPropertyValue(ev.propertyName);
|
|
19
|
+
if (isPointerDown && styleValue === "inset(0px)") {
|
|
20
|
+
emits("trigger");
|
|
21
|
+
isPointerDown = false;
|
|
22
|
+
isConfirm.value = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function onPointerUp() {
|
|
26
|
+
emits("confirm", isConfirm.value);
|
|
27
|
+
isPointerDown = false;
|
|
28
|
+
isConfirm.value = false;
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<Button class="pxd-hold-button relative !transition-all" :class="{ scale }" @pointerdown="onPointerDown" @pointerup="onPointerUp">
|
|
34
|
+
<template #prefix>
|
|
35
|
+
<slot name="prefix" />
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<slot />
|
|
39
|
+
|
|
40
|
+
<template #suffix>
|
|
41
|
+
<slot name="suffix" />
|
|
42
|
+
<div
|
|
43
|
+
class="pxd-hold-button--overlay absolute -inset-px bg-(--mc) rounded-[inherit] pointer-events-none"
|
|
44
|
+
:class="{ confirm: isConfirm }"
|
|
45
|
+
:style="`--ds:${durations}s;--mc:${maskColor}`"
|
|
46
|
+
@transitionend="onTransitionEnd"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
49
|
+
</Button>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<style lang="postcss">
|
|
53
|
+
.pxd-hold-button--overlay {
|
|
54
|
+
--opacity: .48;
|
|
55
|
+
opacity: var(--opacity);
|
|
56
|
+
clip-path: inset(0 100% 0 0);
|
|
57
|
+
transition: clip-path .1s ease-out, opacity 0s linear;
|
|
58
|
+
|
|
59
|
+
&.confirm {
|
|
60
|
+
--opacity: .72;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.pxd-hold-button.scale:active {
|
|
65
|
+
transform: scale(.97);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.pxd-hold-button:active .pxd-hold-button--overlay {
|
|
69
|
+
clip-path: inset(0);
|
|
70
|
+
transition: clip-path var(--ds) ease-out, opacity .2s ease-out;
|
|
71
|
+
}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const injectionKey = "configProvider";
|
|
2
|
+
export type ComponentSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface ConfigProviderProps {
|
|
4
|
+
size?: ComponentSize;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultConfig: Required<ConfigProviderProps>;
|
|
7
|
+
export declare function provideConfigProvider(configProvider: ConfigProviderProps): void;
|
|
8
|
+
export declare function useConfigProvider(): Required<ConfigProviderProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
export const injectionKey = "configProvider";
|
|
3
|
+
export const defaultConfig = {
|
|
4
|
+
size: "md"
|
|
5
|
+
};
|
|
6
|
+
export function provideConfigProvider(configProvider) {
|
|
7
|
+
provide(injectionKey, configProvider);
|
|
8
|
+
}
|
|
9
|
+
export function useConfigProvider() {
|
|
10
|
+
return inject(injectionKey, defaultConfig);
|
|
11
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { addComponent, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
+
import * as components from "../index.js";
|
|
3
|
+
import { name } from "../../package.json";
|
|
4
|
+
export default defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "pxd",
|
|
7
|
+
configKey: "pxd",
|
|
8
|
+
compatibility: {
|
|
9
|
+
nuxt: ">=3.0.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
prefix: ""
|
|
14
|
+
},
|
|
15
|
+
async setup(options) {
|
|
16
|
+
for (const component in components) {
|
|
17
|
+
addComponent({
|
|
18
|
+
name: `${options.prefix}${component}`,
|
|
19
|
+
export: component,
|
|
20
|
+
filePath: name
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
|
-
declare function
|
|
3
|
-
export default
|
|
1
|
+
import type { ComponentResolver } from 'unplugin-vue-components';
|
|
2
|
+
declare function resolver(): ComponentResolver;
|
|
3
|
+
export default resolver;
|
package/dist/plugins/resolver.js
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
const
|
|
1
|
+
const LIBRARY_NAME = "pxd";
|
|
2
|
+
const NAMESPACE = LIBRARY_NAME[0].toUpperCase();
|
|
3
|
+
function resolver() {
|
|
4
|
+
const prefixRegex = /^P[A-Z]/;
|
|
5
|
+
return {
|
|
6
|
+
type: "component",
|
|
7
|
+
resolve(name) {
|
|
8
|
+
if (!prefixRegex.test(name)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const partialName = name.replace(new RegExp(NAMESPACE, "i"), "").replace(/([A-Z])/g, "-$1").toLowerCase().slice(1);
|
|
12
|
+
return {
|
|
13
|
+
importName: name,
|
|
14
|
+
from: `pxd/components/${partialName}`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export default resolver;
|