pxd 0.0.6 → 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 +12 -2
- package/dist/components/button/index.vue +40 -60
- package/dist/components/config-provider/index.vue +10 -19
- 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/index.d.ts +1 -3
- package/dist/index.js +4 -9
- package/package.json +27 -23
- /package/dist/composables/{useConfigProvider.d.ts → useConfigProviderContext.d.ts} +0 -0
- /package/dist/composables/{useConfigProvider.js → useConfigProviderContext.js} +0 -0
- /package/dist/{tokens.css → styles/tw.css} +0 -0
package/README.md
CHANGED
|
@@ -4,15 +4,25 @@ A universal UI component library for Vue2&3
|
|
|
4
4
|
## Contribution
|
|
5
5
|
|
|
6
6
|
### Dev
|
|
7
|
+
|
|
7
8
|
```shell
|
|
8
9
|
pnpm install
|
|
9
10
|
|
|
10
|
-
pnpm dev:lib
|
|
11
|
-
|
|
12
11
|
pnpm dev
|
|
12
|
+
|
|
13
|
+
pnpm dev:docs
|
|
13
14
|
```
|
|
14
15
|
|
|
15
16
|
### Build
|
|
17
|
+
|
|
18
|
+
#### Core
|
|
19
|
+
|
|
16
20
|
```shell
|
|
17
21
|
pnpm build
|
|
18
22
|
```
|
|
23
|
+
|
|
24
|
+
#### Docs
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
pnpm build:docs
|
|
28
|
+
```
|
|
@@ -1,75 +1,55 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
variant?: keyof typeof VARIANTS
|
|
7
|
-
size?: keyof typeof SIZES
|
|
8
|
-
disabled?: boolean
|
|
9
|
-
block?: boolean
|
|
10
|
-
href?: string
|
|
11
|
-
shape?: 'square' | 'rounded'
|
|
12
|
-
}
|
|
13
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useConfigProvider } from "../../composables/useConfigProviderContext";
|
|
14
4
|
defineOptions({
|
|
15
|
-
name:
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const config = useConfigProvider()
|
|
26
|
-
|
|
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();
|
|
27
16
|
const SIZES = {
|
|
28
|
-
xs:
|
|
29
|
-
sm:
|
|
30
|
-
md:
|
|
31
|
-
lg:
|
|
32
|
-
}
|
|
33
|
-
|
|
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
|
+
};
|
|
34
22
|
const VARIANTS = {
|
|
35
|
-
outline:
|
|
36
|
-
ghost:
|
|
37
|
-
primary:
|
|
38
|
-
error:
|
|
39
|
-
warning:
|
|
40
|
-
success:
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
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 '
|
|
44
|
-
|
|
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 ";
|
|
45
31
|
const computedClassNames = computed(() => {
|
|
46
|
-
let classNames =
|
|
47
|
-
|
|
48
|
-
classNames +=
|
|
49
|
-
|
|
50
|
-
classNames += SIZES[props.size || config.size]
|
|
51
|
-
|
|
52
|
-
classNames += props.block ? 'flex ' : 'inline-flex '
|
|
53
|
-
|
|
32
|
+
let classNames = "";
|
|
33
|
+
classNames += VARIANTS[props.variant] || VARIANTS.outline;
|
|
34
|
+
classNames += SIZES[props.size || config.size];
|
|
35
|
+
classNames += props.block ? "flex " : "inline-flex ";
|
|
54
36
|
if (props.disabled) {
|
|
55
|
-
classNames += DISABLED_CLASS_NAMES
|
|
37
|
+
classNames += DISABLED_CLASS_NAMES;
|
|
56
38
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
else if (props.shape === 'rounded') {
|
|
62
|
-
classNames += '!rounded-full '
|
|
39
|
+
if (props.shape === "square") {
|
|
40
|
+
classNames += "!rounded-none ";
|
|
41
|
+
} else if (props.shape === "rounded") {
|
|
42
|
+
classNames += "!rounded-full ";
|
|
63
43
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})
|
|
44
|
+
return classNames;
|
|
45
|
+
});
|
|
67
46
|
</script>
|
|
68
47
|
|
|
69
48
|
<template>
|
|
70
49
|
<Component
|
|
71
50
|
:is="props.href ? 'router-link' : 'button'"
|
|
72
|
-
class="pxd-button
|
|
51
|
+
class="pxd-button cursor-pointer transition-colors items-center justify-center border"
|
|
52
|
+
:class="computedClassNames"
|
|
73
53
|
:disabled="disabled"
|
|
74
54
|
:to="href"
|
|
75
55
|
>
|
|
@@ -1,26 +1,17 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import { provideConfigProvider, type ComponentSize } from '../../composables/useConfigProvider'
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
as?: keyof HTMLElementTagNameMap | VNode
|
|
7
|
-
size?: ComponentSize
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const props = withDefaults(
|
|
11
|
-
defineProps<Props>(),
|
|
12
|
-
{ as: 'div', size: 'md' },
|
|
13
|
-
)
|
|
14
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { defaultConfig, provideConfigProvider } from "../../composables/useConfigProviderContext";
|
|
15
3
|
defineOptions({
|
|
16
|
-
name:
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
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);
|
|
20
11
|
</script>
|
|
21
12
|
|
|
22
13
|
<template>
|
|
23
|
-
<component :is="as">
|
|
14
|
+
<component :is="as" class="pxd-config-provider">
|
|
24
15
|
<slot />
|
|
25
16
|
</component>
|
|
26
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>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { App } from 'vue';
|
|
2
|
-
|
|
3
|
-
import ConfigProvider from './components/config-provider/index.vue';
|
|
2
|
+
export * from './components/index';
|
|
4
3
|
export default function install(app: App): void;
|
|
5
|
-
export { Button, ConfigProvider, };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const components = [Button, ConfigProvider];
|
|
1
|
+
import * as components from "./components/index.js";
|
|
2
|
+
export * from "./components/index.js";
|
|
4
3
|
export default function install(app) {
|
|
5
|
-
components.forEach((component) => {
|
|
6
|
-
app.component(
|
|
4
|
+
Object.entries(components).forEach(([key, component]) => {
|
|
5
|
+
app.component(key, component);
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
|
-
export {
|
|
10
|
-
Button,
|
|
11
|
-
ConfigProvider
|
|
12
|
-
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pxd",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.0.7",
|
|
5
|
+
"description": "A universal UI component library for Vue2&3.",
|
|
6
6
|
"author": "libondev <bon.li@outlook.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/libondev/pxd#readme",
|
|
@@ -20,26 +20,29 @@
|
|
|
20
20
|
"component library"
|
|
21
21
|
],
|
|
22
22
|
"sideEffects": false,
|
|
23
|
-
"imports": {
|
|
24
|
-
"#/*": "./src/*",
|
|
25
|
-
"#types": "./src/types",
|
|
26
|
-
"#types/*": "./src/types/*",
|
|
27
|
-
"#utils/*": "./src/components/_utils/*"
|
|
28
|
-
},
|
|
29
23
|
"exports": {
|
|
30
24
|
".": {
|
|
31
25
|
"types": "./dist/index.d.ts",
|
|
32
26
|
"default": "./dist/index.js"
|
|
33
27
|
},
|
|
34
|
-
"./nuxt":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
"./nuxt": {
|
|
29
|
+
"types": "./dist/plugins/nuxt.d.ts",
|
|
30
|
+
"default": "./dist/plugins/nuxt.js"
|
|
31
|
+
},
|
|
32
|
+
"./resolver": {
|
|
33
|
+
"types": "./dist/plugins/resolver.d.ts",
|
|
34
|
+
"default": "./dist/plugins/resolver.js"
|
|
35
|
+
},
|
|
36
|
+
"./components": {
|
|
37
|
+
"types": "./dist/components/index.d.ts",
|
|
38
|
+
"default": "./dist/components/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./tw.css": "./dist/styles/tw.css",
|
|
41
|
+
"./components/*": "./dist/components/*/index.vue"
|
|
38
42
|
},
|
|
39
43
|
"main": "./dist/index.js",
|
|
40
44
|
"module": "./dist/index.js",
|
|
41
45
|
"types": "./dist/index.d.ts",
|
|
42
|
-
"style": "./dist/tokens.css",
|
|
43
46
|
"typesVersions": {
|
|
44
47
|
"*": {
|
|
45
48
|
"*": [
|
|
@@ -54,19 +57,18 @@
|
|
|
54
57
|
"dist"
|
|
55
58
|
],
|
|
56
59
|
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
60
|
+
"access": "public",
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
58
62
|
},
|
|
59
63
|
"scripts": {
|
|
60
|
-
"
|
|
61
|
-
"dev": "pnpm dev:docs",
|
|
64
|
+
"dev": "unbuild --stub",
|
|
62
65
|
"dev:docs": "pnpm --filter docs dev",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"build": "pnpm build
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"preview:vue2": "pnpm --filter vue2 preview",
|
|
66
|
+
"build": "run-s typecheck update-exports build:lib",
|
|
67
|
+
"build:lib": "unbuild",
|
|
68
|
+
"build:docs": "pnpm build && pnpm --filter docs build",
|
|
69
|
+
"preview:docs": "pnpm --filter docs preview",
|
|
70
|
+
"update-exports": "node scripts/update-exports.js",
|
|
71
|
+
"prepublishOnly": "pnpm build",
|
|
70
72
|
"lint": "eslint .",
|
|
71
73
|
"lint:fix": "eslint . --fix",
|
|
72
74
|
"test": "vitest run",
|
|
@@ -86,6 +88,7 @@
|
|
|
86
88
|
"eslint": "catalog:",
|
|
87
89
|
"jsdom": "catalog:",
|
|
88
90
|
"mkdist": "catalog:",
|
|
91
|
+
"npm-run-all2": "catalog:",
|
|
89
92
|
"tailwindcss": "catalog:",
|
|
90
93
|
"tinyglobby": "catalog:",
|
|
91
94
|
"typescript": "catalog:",
|
|
@@ -94,6 +97,7 @@
|
|
|
94
97
|
"unplugin-vue-components": "catalog:",
|
|
95
98
|
"vitest": "catalog:",
|
|
96
99
|
"vue": "catalog:",
|
|
100
|
+
"vue-sfc-transformer": "catalog:",
|
|
97
101
|
"vue-tsc": "catalog:"
|
|
98
102
|
}
|
|
99
103
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|