From 7f3d698b2b7371632a7f63455ad598c8688a8508 Mon Sep 17 00:00:00 2001
From: 1549469775 <1549469775@qq.com>
Date: Wed, 1 Jun 2022 17:06:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 5 +-
docs/.vitepress/theme/index.js | 3 +-
packages/components/captcha/index.ts | 8 ++
packages/components/captcha/index.vue | 83 +++++++++++++++++
packages/components/components.ts | 6 +-
packages/components/send/index.ts | 8 --
packages/components/send/index.vue | 82 ----------------
packages/playground/components.d.ts | 3 +-
packages/playground/src/App.vue | 24 +++--
packages/playground/vite.config.ts | 2 +-
packages/princess-ui/PrincessResolver.js | 40 ++++++--
packages/princess-ui/components.d.ts | 6 +-
packages/princess-ui/lib/button/index.d.ts | 20 +---
packages/princess-ui/lib/button/index.js | 19 ++--
packages/princess-ui/lib/button/index.umd.js | 2 +-
packages/princess-ui/lib/button/style.css | 1 -
packages/princess-ui/lib/captcha/index.d.ts | 84 +++++++++++++++++
packages/princess-ui/lib/captcha/index.js | 75 +++++++++++++++
packages/princess-ui/lib/captcha/index.umd.js | 1 +
packages/princess-ui/lib/components.d.ts | 4 +-
packages/princess-ui/lib/index.js | 129 +++++++++++++++++++++-----
packages/princess-ui/lib/index.umd.js | 2 +-
packages/princess-ui/lib/send/index.js | 16 ----
packages/princess-ui/lib/send/index.umd.js | 1 -
packages/princess-ui/lib/send/style.css | 1 -
packages/princess-ui/lib/style.css | 2 +-
packages/theme-chalk/src/captcha.scss | 4 +
packages/theme-chalk/src/index.scss | 1 +
28 files changed, 434 insertions(+), 198 deletions(-)
create mode 100644 packages/components/captcha/index.ts
create mode 100644 packages/components/captcha/index.vue
delete mode 100644 packages/components/send/index.ts
delete mode 100644 packages/components/send/index.vue
delete mode 100644 packages/princess-ui/lib/button/style.css
create mode 100644 packages/princess-ui/lib/captcha/index.d.ts
create mode 100644 packages/princess-ui/lib/captcha/index.js
create mode 100644 packages/princess-ui/lib/captcha/index.umd.js
delete mode 100644 packages/princess-ui/lib/send/index.js
delete mode 100644 packages/princess-ui/lib/send/index.umd.js
delete mode 100644 packages/princess-ui/lib/send/style.css
create mode 100644 packages/theme-chalk/src/captcha.scss
diff --git a/.gitignore b/.gitignore
index 7c14f38..a023b40 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
node_modules
.temp
.cache
-dist
\ No newline at end of file
+dist
+princess-ui/lib
+princess-ui/theme-chalk
+princess-ui/components.d.ts
\ No newline at end of file
diff --git a/docs/.vitepress/theme/index.js b/docs/.vitepress/theme/index.js
index 6cc7749..d16446d 100644
--- a/docs/.vitepress/theme/index.js
+++ b/docs/.vitepress/theme/index.js
@@ -1,10 +1,11 @@
import DefaultTheme from 'vitepress/dist/client/theme-default'
-
+import PrincessUI from "@princess-ui/components"
export default {
...DefaultTheme,
enhanceApp({ app, router, siteData }) {
// app is the Vue 3 app instance from `createApp()`. router is VitePress'
// custom router. `siteData`` is a `ref`` of current site-level metadata.
+ app.use(PrincessUI)
}
}
diff --git a/packages/components/captcha/index.ts b/packages/components/captcha/index.ts
new file mode 100644
index 0000000..aeea16e
--- /dev/null
+++ b/packages/components/captcha/index.ts
@@ -0,0 +1,8 @@
+import PsCaptcha from "./index.vue"
+
+PsCaptcha.name = "ps-captcha"
+
+export {
+ PsCaptcha
+}
+export default PsCaptcha
\ No newline at end of file
diff --git a/packages/components/captcha/index.vue b/packages/components/captcha/index.vue
new file mode 100644
index 0000000..29d4a63
--- /dev/null
+++ b/packages/components/captcha/index.vue
@@ -0,0 +1,83 @@
+
+
+ {{ text }}
+
+
+
+
diff --git a/packages/components/components.ts b/packages/components/components.ts
index 0423ed1..e8abfd0 100644
--- a/packages/components/components.ts
+++ b/packages/components/components.ts
@@ -1,9 +1,9 @@
// 该文件为自动生成,请勿修改!!!
import PsButton from "./button"
+import PsCaptcha from "./captcha"
import PsFuck from "./fuck"
-import PsSend from "./send"
export {
PsButton,
- PsFuck,
- PsSend
+ PsCaptcha,
+ PsFuck
}
\ No newline at end of file
diff --git a/packages/components/send/index.ts b/packages/components/send/index.ts
deleted file mode 100644
index 5cd3002..0000000
--- a/packages/components/send/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import PsSend from "./index.vue"
-
-PsSend.name = "ps-send"
-
-export {
- PsSend
-}
-export default PsSend
\ No newline at end of file
diff --git a/packages/components/send/index.vue b/packages/components/send/index.vue
deleted file mode 100644
index 1011153..0000000
--- a/packages/components/send/index.vue
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
diff --git a/packages/playground/components.d.ts b/packages/playground/components.d.ts
index 8557ef6..12efac8 100644
--- a/packages/playground/components.d.ts
+++ b/packages/playground/components.d.ts
@@ -6,8 +6,7 @@ import '@vue/runtime-core'
declare module '@vue/runtime-core' {
export interface GlobalComponents {
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
- PsButton: typeof import('@princess-ui/components/button')['PsButton']
- PsSend: typeof import('@princess-ui/components/send')['PsSend']
+ PsCaptcha: typeof import('@princess-ui/components/captcha')['PsCaptcha']
}
}
diff --git a/packages/playground/src/App.vue b/packages/playground/src/App.vue
index 9697652..e8992b2 100644
--- a/packages/playground/src/App.vue
+++ b/packages/playground/src/App.vue
@@ -2,22 +2,26 @@
// This starter template is using Vue 3
-
-
- sada
- sada
+ sada
diff --git a/packages/playground/vite.config.ts b/packages/playground/vite.config.ts
index ec16c63..12d5446 100644
--- a/packages/playground/vite.config.ts
+++ b/packages/playground/vite.config.ts
@@ -22,7 +22,7 @@ export default defineConfig({
type: 'component',
resolve: (componentName: string) => {
if (componentName.startsWith('Ps')) {
- const name = _.lowerFirst(componentName.slice(2))
+ const name = _.lowerFirst(componentName.slice(2))
return {
name: componentName,
from: `@princess-ui/components/${name}`,
diff --git a/packages/princess-ui/PrincessResolver.js b/packages/princess-ui/PrincessResolver.js
index b80e66c..13a4227 100644
--- a/packages/princess-ui/PrincessResolver.js
+++ b/packages/princess-ui/PrincessResolver.js
@@ -6,24 +6,44 @@ exports.__esModule = true;
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
function existCss(compName) {
- if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, "./lib/" + compName[0].toLowerCase() + compName.slice(1) + "/style.css"))) {
+ if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, './lib/' +
+ compName[0].toLowerCase() +
+ compName.slice(1) +
+ '/style.css'))) {
return true;
}
return false;
}
-exports["default"] = (function (name, p) {
- if (name === void 0) { name = "princess-ui"; }
- if (p === void 0) { p = "/lib"; }
+function existTheme(compName) {
+ if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, './theme-chalk/ps-' +
+ compName[0].toLowerCase() +
+ compName.slice(1) +
+ '.css'))) {
+ return true;
+ }
+ return false;
+}
+exports["default"] = (function () {
return {
- type: "component",
+ type: 'component',
resolve: function (componentName) {
- if (componentName.startsWith("Ps")) {
+ if (componentName.startsWith('Ps')) {
+ var css = [];
+ var n = componentName.slice(2);
+ if (existCss(n)) {
+ css.push((function getSideEffects(compName) {
+ return "princess-ui/lib/".concat(compName[0].toLowerCase() + compName.slice(1), "/style.css");
+ })(n));
+ }
+ if (existTheme(n)) {
+ css.push((function getSideEffects(compName) {
+ return "princess-ui/theme-chalk/ps-".concat(compName[0].toLowerCase() + compName.slice(1), ".css");
+ })(n));
+ }
return {
name: componentName,
- from: name,
- sideEffects: existCss(componentName.slice(2)) ? (function getSideEffects(compName) {
- return "".concat(name).concat(p, "/").concat(compName[0].toLowerCase() + compName.slice(1), "/style.css");
- })(componentName.slice(2)) : undefined
+ from: 'princess-ui',
+ sideEffects: css
};
}
}
diff --git a/packages/princess-ui/components.d.ts b/packages/princess-ui/components.d.ts
index a51408b..7051862 100644
--- a/packages/princess-ui/components.d.ts
+++ b/packages/princess-ui/components.d.ts
@@ -1,8 +1,8 @@
declare module 'vue' {
export interface GlobalComponents {
- PsButton: typeof import('./lib')['PsButton'],
- PsFuck: typeof import('./lib')['PsFuck'],
- PsSend: typeof import('./lib')['PsSend']
+ PsButton: typeof import('./lib/button')['PsButton'],
+ PsCaptcha: typeof import('./lib/captcha')['PsCaptcha'],
+ PsFuck: typeof import('./lib/fuck')['PsFuck']
}
}
export { }
\ No newline at end of file
diff --git a/packages/princess-ui/lib/button/index.d.ts b/packages/princess-ui/lib/button/index.d.ts
index 6d3864a..3e8b152 100644
--- a/packages/princess-ui/lib/button/index.d.ts
+++ b/packages/princess-ui/lib/button/index.d.ts
@@ -1,21 +1,7 @@
-import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue';
+import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
declare const _sfc_main: DefineComponent<{
- color: {
- type: PropType<"blue" | "red">;
- required: true;
- };
- aaa: {
- type: PropType<"red" | "dd">;
- required: true;
- };
+ text: StringConstructor;
}, unknown, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly;
- required: true;
- };
- aaa: {
- type: PropType<"red" | "dd">;
- required: true;
- };
+ text: StringConstructor;
}>>, {}>;
export default _sfc_main;
diff --git a/packages/princess-ui/lib/button/index.js b/packages/princess-ui/lib/button/index.js
index 364edb5..9be03d5 100644
--- a/packages/princess-ui/lib/button/index.js
+++ b/packages/princess-ui/lib/button/index.js
@@ -1,5 +1,4 @@
-import { defineComponent, openBlock, createElementBlock, toDisplayString } from "vue";
-var index_vue_vue_type_style_index_0_lang = "";
+import { defineComponent, openBlock, createElementBlock, renderSlot, createTextVNode, toDisplayString } from "vue";
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
@@ -9,18 +8,16 @@ var _export_sfc = (sfc, props) => {
};
const _sfc_main = defineComponent({
props: {
- color: {
- type: String,
- required: true
- },
- aaa: {
- type: String,
- required: true
- }
+ text: String
}
});
+const _hoisted_1 = { class: "ps-button" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, " sada" + toDisplayString(_ctx.color), 1);
+ return openBlock(), createElementBlock("div", _hoisted_1, [
+ renderSlot(_ctx.$slots, "default", {}, () => [
+ createTextVNode(toDisplayString(_ctx.text), 1)
+ ])
+ ]);
}
var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
PsButton.name = "ps-button";
diff --git a/packages/princess-ui/lib/button/index.umd.js b/packages/princess-ui/lib/button/index.umd.js
index 566fb56..be8ea6f 100644
--- a/packages/princess-ui/lib/button/index.umd.js
+++ b/packages/princess-ui/lib/button/index.umd.js
@@ -1 +1 @@
-(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e.psButton={},e.Vue))})(this,function(e,t){"use strict";var c="",d=(n,i)=>{const r=n.__vccOpts||n;for(const[u,s]of i)r[u]=s;return r};const p=t.defineComponent({props:{color:{type:String,required:!0},aaa:{type:String,required:!0}}});function a(n,i,r,u,s,f){return t.openBlock(),t.createElementBlock("div",null," sada"+t.toDisplayString(n.color),1)}var o=d(p,[["render",a]]);o.name="ps-button",e.PsButton=o,e.default=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
+(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.psButton={},t.Vue))})(this,function(t,e){"use strict";var u=(n,r)=>{const s=n.__vccOpts||n;for(const[i,d]of r)s[i]=d;return s};const f=e.defineComponent({props:{text:String}}),p={class:"ps-button"};function c(n,r,s,i,d,a){return e.openBlock(),e.createElementBlock("div",p,[e.renderSlot(n.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(n.text),1)])])}var o=u(f,[["render",c]]);o.name="ps-button",t.PsButton=o,t.default=o,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
diff --git a/packages/princess-ui/lib/button/style.css b/packages/princess-ui/lib/button/style.css
deleted file mode 100644
index 33143a5..0000000
--- a/packages/princess-ui/lib/button/style.css
+++ /dev/null
@@ -1 +0,0 @@
-div{background-color:#639}div{color:red}
diff --git a/packages/princess-ui/lib/captcha/index.d.ts b/packages/princess-ui/lib/captcha/index.d.ts
new file mode 100644
index 0000000..7b46283
--- /dev/null
+++ b/packages/princess-ui/lib/captcha/index.d.ts
@@ -0,0 +1,84 @@
+import type { DefineComponent, Ref, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
+declare const _sfc_main: DefineComponent<{
+ duration: {
+ type: NumberConstructor;
+ required: false;
+ default: number;
+ };
+ initText: {
+ type: StringConstructor;
+ required: false;
+ default: string;
+ };
+ runText: {
+ type: StringConstructor;
+ required: false;
+ default: string;
+ };
+ loadingText: {
+ type: StringConstructor;
+ required: false;
+ default: string;
+ };
+ resetText: {
+ type: StringConstructor;
+ required: false;
+ default: string;
+ };
+}, {
+ props: {
+ duration: number;
+ initText: string;
+ runText: string;
+ loadingText: string;
+ resetText: string;
+ };
+ emits: {
+ (event: "update:modelValue", show: boolean): void;
+ (event: "send", start: () => void, done: (isDone?: boolean) => void): void;
+ };
+ text: Ref;
+ isDisabled: Ref;
+ isLoading: Ref;
+ timeID: any;
+ stop: () => void;
+ getText: (second: string | number) => string;
+ run: () => void;
+ onClick: () => void;
+}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("update:modelValue" | "send")[], "update:modelValue" | "send", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly> & {
+ "onUpdate:modelValue"?: (...args: any[]) => any;
+ onSend?: (...args: any[]) => any;
+}, {
+ duration: number;
+ initText: string;
+ runText: string;
+ loadingText: string;
+ resetText: string;
+}>;
+export default _sfc_main;
diff --git a/packages/princess-ui/lib/captcha/index.js b/packages/princess-ui/lib/captcha/index.js
new file mode 100644
index 0000000..a825222
--- /dev/null
+++ b/packages/princess-ui/lib/captcha/index.js
@@ -0,0 +1,75 @@
+import { defineComponent, ref, onBeforeUnmount, openBlock, createElementBlock, toDisplayString } from "vue";
+const _hoisted_1 = ["disabled", "loading"];
+const _sfc_main = /* @__PURE__ */ defineComponent({
+ name: "index",
+ props: {
+ duration: { default: 60 },
+ initText: { default: "\u83B7\u53D6\u9A8C\u8BC1\u7801" },
+ runText: { default: "{%s}s \u540E\u91CD\u65B0\u53D1\u9001" },
+ loadingText: { default: "\u6B63\u5728\u53D1\u9001" },
+ resetText: { default: "\u91CD\u65B0\u83B7\u53D6" }
+ },
+ emits: ["update:modelValue", "send"],
+ setup(__props, { emit: emits }) {
+ const props = __props;
+ const text = ref(props.initText);
+ const isDisabled = ref(false);
+ const isLoading = ref(false);
+ let timeID;
+ onBeforeUnmount(() => {
+ stop();
+ });
+ function stop() {
+ clearInterval(timeID);
+ text.value = props.resetText;
+ isLoading.value = false;
+ isDisabled.value = false;
+ emits("update:modelValue", false);
+ }
+ function getText(second) {
+ return props.runText.replace(/\{([^{]*?)%s(.*?)\}/g, String(second));
+ }
+ function run() {
+ isLoading.value = false;
+ let number = props.duration;
+ text.value = getText(number);
+ clearInterval(timeID);
+ timeID = setInterval(() => {
+ number--;
+ text.value = getText(number);
+ if (number <= 0) {
+ stop();
+ }
+ }, 1e3);
+ }
+ function onClick() {
+ if (isDisabled.value)
+ return;
+ if (isLoading.value)
+ return;
+ emits("send", () => {
+ isDisabled.value = true;
+ isLoading.value = true;
+ text.value = props.loadingText;
+ }, (isDone = true) => {
+ if (isDone) {
+ run();
+ } else {
+ stop();
+ }
+ });
+ }
+ return (_ctx, _cache) => {
+ return openBlock(), createElementBlock("div", {
+ class: "ps-send",
+ onClick,
+ disabled: isDisabled.value,
+ loading: isLoading.value,
+ type: "button",
+ size: "small"
+ }, toDisplayString(text.value), 9, _hoisted_1);
+ };
+ }
+});
+_sfc_main.name = "ps-captcha";
+export { _sfc_main as PsCaptcha, _sfc_main as default };
diff --git a/packages/princess-ui/lib/captcha/index.umd.js b/packages/princess-ui/lib/captcha/index.umd.js
new file mode 100644
index 0000000..4c030fa
--- /dev/null
+++ b/packages/princess-ui/lib/captcha/index.umd.js
@@ -0,0 +1 @@
+(function(u,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis!="undefined"?globalThis:u||self,e(u.psCaptcha={},u.Vue))})(this,function(u,e){"use strict";const c=["disabled","loading"],s=e.defineComponent({name:"index",props:{duration:{default:60},initText:{default:"\u83B7\u53D6\u9A8C\u8BC1\u7801"},runText:{default:"{%s}s \u540E\u91CD\u65B0\u53D1\u9001"},loadingText:{default:"\u6B63\u5728\u53D1\u9001"},resetText:{default:"\u91CD\u65B0\u83B7\u53D6"}},emits:["update:modelValue","send"],setup(p,{emit:d}){const n=p,a=e.ref(n.initText),i=e.ref(!1),l=e.ref(!1);let o;e.onBeforeUnmount(()=>{r()});function r(){clearInterval(o),a.value=n.resetText,l.value=!1,i.value=!1,d("update:modelValue",!1)}function f(t){return n.runText.replace(/\{([^{]*?)%s(.*?)\}/g,String(t))}function m(){l.value=!1;let t=n.duration;a.value=f(t),clearInterval(o),o=setInterval(()=>{t--,a.value=f(t),t<=0&&r()},1e3)}function v(){i.value||l.value||d("send",()=>{i.value=!0,l.value=!0,a.value=n.loadingText},(t=!0)=>{t?m():r()})}return(t,x)=>(e.openBlock(),e.createElementBlock("div",{class:"ps-send",onClick:v,disabled:i.value,loading:l.value,type:"button",size:"small"},e.toDisplayString(a.value),9,c))}});s.name="ps-captcha",u.PsCaptcha=s,u.default=s,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
diff --git a/packages/princess-ui/lib/components.d.ts b/packages/princess-ui/lib/components.d.ts
index 0f08e3c..b067fcc 100644
--- a/packages/princess-ui/lib/components.d.ts
+++ b/packages/princess-ui/lib/components.d.ts
@@ -1,4 +1,4 @@
import PsButton from "./button";
+import PsCaptcha from "./captcha";
import PsFuck from "./fuck";
-import PsSend from "./send";
-export { PsButton, PsFuck, PsSend };
+export { PsButton, PsCaptcha, PsFuck };
diff --git a/packages/princess-ui/lib/index.js b/packages/princess-ui/lib/index.js
index 24a0607..f001593 100644
--- a/packages/princess-ui/lib/index.js
+++ b/packages/princess-ui/lib/index.js
@@ -1,5 +1,4 @@
-import { defineComponent, openBlock, createElementBlock, toDisplayString, createTextVNode, createVNode, unref } from "vue";
-var index_vue_vue_type_style_index_0_lang$2 = "";
+import { defineComponent, openBlock, createElementBlock, renderSlot, createTextVNode, toDisplayString, ref, onBeforeUnmount, createVNode, unref } from "vue";
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
@@ -9,25 +8,106 @@ var _export_sfc = (sfc, props) => {
};
const _sfc_main$2 = defineComponent({
props: {
- color: {
- type: String,
- required: true
- },
- aaa: {
- type: String,
- required: true
- }
+ text: String
}
});
-function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
- return openBlock(), createElementBlock("div", null, " sada" + toDisplayString(_ctx.color), 1);
+const _hoisted_1$1 = { class: "ps-button" };
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
+ renderSlot(_ctx.$slots, "default", {}, () => [
+ createTextVNode(toDisplayString(_ctx.text), 1)
+ ])
+ ]);
}
-var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]);
+var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
PsButton.name = "ps-button";
-var index_vue_vue_type_style_index_0_lang$1 = "";
+var __glob_2_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
+ __proto__: null,
+ PsButton,
+ "default": PsButton
+}, Symbol.toStringTag, { value: "Module" }));
+const _hoisted_1 = ["disabled", "loading"];
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
name: "index",
props: {
+ duration: { default: 60 },
+ initText: { default: "\u83B7\u53D6\u9A8C\u8BC1\u7801" },
+ runText: { default: "{%s}s \u540E\u91CD\u65B0\u53D1\u9001" },
+ loadingText: { default: "\u6B63\u5728\u53D1\u9001" },
+ resetText: { default: "\u91CD\u65B0\u83B7\u53D6" }
+ },
+ emits: ["update:modelValue", "send"],
+ setup(__props, { emit: emits }) {
+ const props = __props;
+ const text = ref(props.initText);
+ const isDisabled = ref(false);
+ const isLoading = ref(false);
+ let timeID;
+ onBeforeUnmount(() => {
+ stop();
+ });
+ function stop() {
+ clearInterval(timeID);
+ text.value = props.resetText;
+ isLoading.value = false;
+ isDisabled.value = false;
+ emits("update:modelValue", false);
+ }
+ function getText(second) {
+ return props.runText.replace(/\{([^{]*?)%s(.*?)\}/g, String(second));
+ }
+ function run() {
+ isLoading.value = false;
+ let number = props.duration;
+ text.value = getText(number);
+ clearInterval(timeID);
+ timeID = setInterval(() => {
+ number--;
+ text.value = getText(number);
+ if (number <= 0) {
+ stop();
+ }
+ }, 1e3);
+ }
+ function onClick() {
+ if (isDisabled.value)
+ return;
+ if (isLoading.value)
+ return;
+ emits("send", () => {
+ isDisabled.value = true;
+ isLoading.value = true;
+ text.value = props.loadingText;
+ }, (isDone = true) => {
+ if (isDone) {
+ run();
+ } else {
+ stop();
+ }
+ });
+ }
+ return (_ctx, _cache) => {
+ return openBlock(), createElementBlock("div", {
+ class: "ps-send",
+ onClick,
+ disabled: isDisabled.value,
+ loading: isLoading.value,
+ type: "button",
+ size: "small"
+ }, toDisplayString(text.value), 9, _hoisted_1);
+ };
+ }
+});
+_sfc_main$1.name = "ps-captcha";
+var __glob_2_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
+ __proto__: null,
+ PsCaptcha: _sfc_main$1,
+ "default": _sfc_main$1
+}, Symbol.toStringTag, { value: "Module" }));
+var index_vue_vue_type_style_index_0_lang = "";
+const _sfc_main = /* @__PURE__ */ defineComponent({
+ name: "index",
+ props: {
color: null
},
setup(__props) {
@@ -42,20 +122,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
};
}
});
-_sfc_main$1.name = "ps-fuck";
-var index_vue_vue_type_style_index_0_lang = "";
-const _sfc_main = {};
-function _sfc_render(_ctx, _cache) {
- return openBlock(), createElementBlock("div", null, " send ");
-}
-var PsSend = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
-PsSend.name = "ps-send";
+_sfc_main.name = "ps-fuck";
+var __glob_2_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
+ __proto__: null,
+ PsFuck: _sfc_main,
+ "default": _sfc_main
+}, Symbol.toStringTag, { value: "Module" }));
var componets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
PsButton,
- PsFuck: _sfc_main$1,
- PsSend
+ PsCaptcha: _sfc_main$1,
+ PsFuck: _sfc_main
}, Symbol.toStringTag, { value: "Module" }));
+console.log({ "./button/index.ts": __glob_2_0, "./captcha/index.ts": __glob_2_1, "./fuck/index.ts": __glob_2_2 });
function install(app) {
for (const key in componets) {
const component = componets[key];
@@ -65,4 +144,4 @@ function install(app) {
var index = {
install
};
-export { PsButton, _sfc_main$1 as PsFuck, PsSend, index as default, install };
+export { PsButton, _sfc_main$1 as PsCaptcha, _sfc_main as PsFuck, index as default, install };
diff --git a/packages/princess-ui/lib/index.umd.js b/packages/princess-ui/lib/index.umd.js
index 7cfd74a..99527a1 100644
--- a/packages/princess-ui/lib/index.umd.js
+++ b/packages/princess-ui/lib/index.umd.js
@@ -1 +1 @@
-(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.ps={},n.Vue))})(this,function(n,e){"use strict";var g="",i=(t,o)=>{const r=t.__vccOpts||t;for(const[_,u]of o)r[_]=u;return r};const p=e.defineComponent({props:{color:{type:String,required:!0},aaa:{type:String,required:!0}}});function f(t,o,r,_,u,x){return e.openBlock(),e.createElementBlock("div",null," sada"+e.toDisplayString(t.color),1)}var c=i(p,[["render",f]]);c.name="ps-button";var k="";const s=e.defineComponent({name:"index",props:{color:null},setup(t){return(o,r)=>(e.openBlock(),e.createElementBlock("div",null,[e.createTextVNode(" sada"+e.toDisplayString(t.color)+" ",1),e.createVNode(e.unref(c),{color:"red",aaa:"red"})]))}});s.name="ps-fuck";var S="";const m={};function y(t,o){return e.openBlock(),e.createElementBlock("div",null," send ")}var a=i(m,[["render",y]]);a.name="ps-send";var d=Object.freeze(Object.defineProperty({__proto__:null,PsButton:c,PsFuck:s,PsSend:a},Symbol.toStringTag,{value:"Module"}));function l(t){for(const o in d){const r=d[o];t.component(r.name||"ps-"+o,r)}}var v={install:l};n.PsButton=c,n.PsFuck=s,n.PsSend=a,n.default=v,n.install=l,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
+(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.ps={},n.Vue))})(this,function(n,e){"use strict";var b=(o,a)=>{const t=o.__vccOpts||o;for(const[r,u]of a)t[r]=u;return t};const x=e.defineComponent({props:{text:String}}),v={class:"ps-button"};function y(o,a,t,r,u,i){return e.openBlock(),e.createElementBlock("div",v,[e.renderSlot(o.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(o.text),1)])])}var s=b(x,[["render",y]]);s.name="ps-button";var T=Object.freeze(Object.defineProperty({__proto__:null,PsButton:s,default:s},Symbol.toStringTag,{value:"Module"}));const B=["disabled","loading"],c=e.defineComponent({name:"index",props:{duration:{default:60},initText:{default:"\u83B7\u53D6\u9A8C\u8BC1\u7801"},runText:{default:"{%s}s \u540E\u91CD\u65B0\u53D1\u9001"},loadingText:{default:"\u6B63\u5728\u53D1\u9001"},resetText:{default:"\u91CD\u65B0\u83B7\u53D6"}},emits:["update:modelValue","send"],setup(o,{emit:a}){const t=o,r=e.ref(t.initText),u=e.ref(!1),i=e.ref(!1);let f;e.onBeforeUnmount(()=>{p()});function p(){clearInterval(f),r.value=t.resetText,i.value=!1,u.value=!1,a("update:modelValue",!1)}function g(l){return t.runText.replace(/\{([^{]*?)%s(.*?)\}/g,String(l))}function h(){i.value=!1;let l=t.duration;r.value=g(l),clearInterval(f),f=setInterval(()=>{l--,r.value=g(l),l<=0&&p()},1e3)}function C(){u.value||i.value||a("send",()=>{u.value=!0,i.value=!0,r.value=t.loadingText},(l=!0)=>{l?h():p()})}return(l,j)=>(e.openBlock(),e.createElementBlock("div",{class:"ps-send",onClick:C,disabled:u.value,loading:i.value,type:"button",size:"small"},e.toDisplayString(r.value),9,B))}});c.name="ps-captcha";var S=Object.freeze(Object.defineProperty({__proto__:null,PsCaptcha:c,default:c},Symbol.toStringTag,{value:"Module"})),D="";const d=e.defineComponent({name:"index",props:{color:null},setup(o){return(a,t)=>(e.openBlock(),e.createElementBlock("div",null,[e.createTextVNode(" sada"+e.toDisplayString(o.color)+" ",1),e.createVNode(e.unref(s),{color:"red",aaa:"red"})]))}});d.name="ps-fuck";var P=Object.freeze(Object.defineProperty({__proto__:null,PsFuck:d,default:d},Symbol.toStringTag,{value:"Module"})),_=Object.freeze(Object.defineProperty({__proto__:null,PsButton:s,PsCaptcha:c,PsFuck:d},Symbol.toStringTag,{value:"Module"}));console.log({"./button/index.ts":T,"./captcha/index.ts":S,"./fuck/index.ts":P});function m(o){for(const a in _){const t=_[a];o.component(t.name||"ps-"+a,t)}}var k={install:m};n.PsButton=s,n.PsCaptcha=c,n.PsFuck=d,n.default=k,n.install=m,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
diff --git a/packages/princess-ui/lib/send/index.js b/packages/princess-ui/lib/send/index.js
deleted file mode 100644
index 85642a1..0000000
--- a/packages/princess-ui/lib/send/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import { openBlock, createElementBlock } from "vue";
-var index_vue_vue_type_style_index_0_lang = "";
-var _export_sfc = (sfc, props) => {
- const target = sfc.__vccOpts || sfc;
- for (const [key, val] of props) {
- target[key] = val;
- }
- return target;
-};
-const _sfc_main = {};
-function _sfc_render(_ctx, _cache) {
- return openBlock(), createElementBlock("div", null, " send ");
-}
-var PsSend = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
-PsSend.name = "ps-send";
-export { PsSend, PsSend as default };
diff --git a/packages/princess-ui/lib/send/index.umd.js b/packages/princess-ui/lib/send/index.umd.js
deleted file mode 100644
index 704c3c5..0000000
--- a/packages/princess-ui/lib/send/index.umd.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e.psSend={},e.Vue))})(this,function(e,n){"use strict";var f="",u=(d,o)=>{const s=d.__vccOpts||d;for(const[_,c]of o)s[_]=c;return s};const i={};function r(d,o){return n.openBlock(),n.createElementBlock("div",null," send ")}var t=u(i,[["render",r]]);t.name="ps-send",e.PsSend=t,e.default=t,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
diff --git a/packages/princess-ui/lib/send/style.css b/packages/princess-ui/lib/send/style.css
deleted file mode 100644
index 0c58ae8..0000000
--- a/packages/princess-ui/lib/send/style.css
+++ /dev/null
@@ -1 +0,0 @@
-div{color:gold}
diff --git a/packages/princess-ui/lib/style.css b/packages/princess-ui/lib/style.css
index 2e5130e..bdc6ae2 100644
--- a/packages/princess-ui/lib/style.css
+++ b/packages/princess-ui/lib/style.css
@@ -1 +1 @@
-div{background-color:#639}div{color:red}div{color:green}div{color:gold}
+div{color:green}
diff --git a/packages/theme-chalk/src/captcha.scss b/packages/theme-chalk/src/captcha.scss
new file mode 100644
index 0000000..46ae780
--- /dev/null
+++ b/packages/theme-chalk/src/captcha.scss
@@ -0,0 +1,4 @@
+.ps-send{
+ color: blue;
+ cursor: pointer;
+}
\ No newline at end of file
diff --git a/packages/theme-chalk/src/index.scss b/packages/theme-chalk/src/index.scss
index a272ae8..7bdaf62 100644
--- a/packages/theme-chalk/src/index.scss
+++ b/packages/theme-chalk/src/index.scss
@@ -1,4 +1,5 @@
@import "./button.scss";
+@import "./send.scss";
div{
color: rosybrown;
}
\ No newline at end of file