@sokngounchan/frontend-kit 0.0.0-stage → 0.1.0
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/CHANGELOG.md +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -3
- package/dist/components/BaseButton.vue.d.ts +28 -0
- package/dist/composables/index.cjs +1 -0
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +19 -0
- package/dist/composables/useDebounce.d.ts +2 -0
- package/dist/composables/useToggle.d.ts +4 -0
- package/dist/frontend-kit.css +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +34 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/utils/debounce.d.ts +1 -0
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +18 -0
- package/dist/validators/index.cjs +1 -0
- package/dist/validators/index.d.ts +6 -0
- package/dist/validators/index.js +4 -0
- package/package.json +95 -3
package/CHANGELOG.md
ADDED
|
File without changes
|
package/LICENSE
ADDED
|
File without changes
|
package/README.md
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
variant?: 'primary' | 'secondary' | 'danger';
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_template: () => {
|
|
7
|
+
__VLS_Slots: {
|
|
8
|
+
default?: (props: {}) => any;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
12
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
13
|
+
click: (event: MouseEvent) => any;
|
|
14
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
15
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
16
|
+
}>, {
|
|
17
|
+
variant: "primary" | "secondary" | "danger";
|
|
18
|
+
loading: boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
22
|
+
declare const _default: typeof __VLS_export;
|
|
23
|
+
export default _default;
|
|
24
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
25
|
+
new (): {
|
|
26
|
+
$slots: S;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("vue");function t(t=!1){let n=(0,e.ref)(t);return{state:n,toggle:e=>{n.value=typeof e==`boolean`?e:!n.value}}}function n(t,n=300){let r=(0,e.ref)(t.value),i;return(0,e.watch)(t,e=>{i&&clearTimeout(i),i=setTimeout(()=>r.value=e,n)}),r}exports.useDebounce=n,exports.useToggle=t;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ref as e, watch as t } from "vue";
|
|
2
|
+
// src/composables/useToggle.ts
|
|
3
|
+
function n(t = !1) {
|
|
4
|
+
let n = e(t);
|
|
5
|
+
return {
|
|
6
|
+
state: n,
|
|
7
|
+
toggle: (e) => {
|
|
8
|
+
n.value = typeof e == "boolean" ? e : !n.value;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
// src/composables/useDebounce.ts
|
|
13
|
+
function r(n, r = 300) {
|
|
14
|
+
let i = e(n.value), a;
|
|
15
|
+
return t(n, (e) => {
|
|
16
|
+
a && clearTimeout(a), a = setTimeout(() => i.value = e, r);
|
|
17
|
+
}), i;
|
|
18
|
+
}
|
|
19
|
+
export { r as useDebounce, n as useToggle };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.fk-btn{cursor:pointer;font:inherit;border:0;border-radius:6px;padding:.5rem 1rem}.fk-btn--primary{color:#fff;background:#2563eb}.fk-btn--secondary{color:#111827;background:#e5e7eb}.fk-btn--danger{color:#fff;background:#dc2626}.fk-btn:disabled{opacity:.6;cursor:not-allowed}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./utils/index.cjs"),t=require("./composables/index.cjs");let n=require("vue");var r=[`disabled`],i={key:0,class:`fk-btn__spinner`,"aria-hidden":`true`},a=(0,n.defineComponent)({__name:`BaseButton`,props:{variant:{default:`primary`},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:[`click`],setup(e,{emit:t}){let a=t;return(t,o)=>((0,n.openBlock)(),(0,n.createElementBlock)(`button`,{class:(0,n.normalizeClass)([`fk-btn`,`fk-btn--${e.variant}`]),disabled:e.disabled||e.loading,onClick:o[0]||=e=>a(`click`,e)},[e.loading?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,i)):(0,n.createCommentVNode)(``,!0),(0,n.renderSlot)(t.$slots,`default`)],10,r))}}),o={install(e){e.component(`BaseButton`,a)}};exports.BaseButton=a,exports.debounce=e.debounce,exports.default=o,exports.formatCurrency=e.formatCurrency,exports.truncate=e.truncate,exports.useDebounce=t.useDebounce,exports.useToggle=t.useToggle;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { debounce as e, formatCurrency as t, truncate as n } from "./utils/index.js";
|
|
2
|
+
import { useDebounce as r, useToggle as i } from "./composables/index.js";
|
|
3
|
+
import { createCommentVNode as a, createElementBlock as o, defineComponent as s, normalizeClass as c, openBlock as l, renderSlot as u } from "vue";
|
|
4
|
+
// src/components/BaseButton.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var d = ["disabled"], f = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "fk-btn__spinner",
|
|
8
|
+
"aria-hidden": "true"
|
|
9
|
+
}, p = /* @__PURE__ */ s({
|
|
10
|
+
__name: "BaseButton",
|
|
11
|
+
props: {
|
|
12
|
+
variant: { default: "primary" },
|
|
13
|
+
loading: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: !1
|
|
16
|
+
},
|
|
17
|
+
disabled: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !1
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
emits: ["click"],
|
|
23
|
+
setup(e, { emit: t }) {
|
|
24
|
+
let n = t;
|
|
25
|
+
return (t, r) => (l(), o("button", {
|
|
26
|
+
class: c(["fk-btn", `fk-btn--${e.variant}`]),
|
|
27
|
+
disabled: e.disabled || e.loading,
|
|
28
|
+
onClick: r[0] ||= (e) => n("click", e)
|
|
29
|
+
}, [e.loading ? (l(), o("span", f)) : a("", !0), u(t.$slots, "default")], 10, d));
|
|
30
|
+
}
|
|
31
|
+
}), m = { install(e) {
|
|
32
|
+
e.component("BaseButton", p);
|
|
33
|
+
} };
|
|
34
|
+
export { p as BaseButton, e as debounce, m as default, t as formatCurrency, n as truncate, r as useDebounce, i as useToggle };
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function debounce<A extends unknown[]>(fn: (...args: A) => void, delay?: number): (...args: A) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t=`USD`,n=`en-US`){return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e)}function t(e,t){return e.length>t?e.slice(0,t-3)+`...`:e}function n(e,t=300){let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}}exports.debounce=n,exports.formatCurrency=e,exports.truncate=t;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/utils/format.ts
|
|
2
|
+
function e(e, t = "USD", n = "en-US") {
|
|
3
|
+
return new Intl.NumberFormat(n, {
|
|
4
|
+
style: "currency",
|
|
5
|
+
currency: t
|
|
6
|
+
}).format(e);
|
|
7
|
+
}
|
|
8
|
+
function t(e, t) {
|
|
9
|
+
return e.length > t ? e.slice(0, t - 3) + "..." : e;
|
|
10
|
+
}
|
|
11
|
+
// src/utils/debounce.ts
|
|
12
|
+
function n(e, t = 300) {
|
|
13
|
+
let n;
|
|
14
|
+
return (...r) => {
|
|
15
|
+
n && clearTimeout(n), n = setTimeout(() => e(...r), t);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export { n as debounce, e as formatCurrency, t as truncate };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var{req:e,regex:t,withMessage:n}=require("@vuelidate/validators").helpers,r=n(`Invalid phone number`,t(/^\+?[0-9\s-]{7,15}$/)),i=t=>n(`Must contain "${t}"`,n=>!e(n)||n.includes(t)),a=n(`Spaces are not allowed`,t=>!e(t)||!/\s/.test(t));exports.mustContain=i,exports.noSpaces=a,exports.phone=r;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Optional phone number: digits, spaces, dashes, optional leading + */
|
|
2
|
+
export declare const phone: import('@vuelidate/core').ValidationRuleWithParams<object, any>;
|
|
3
|
+
/** Value must contain a word. Empty values pass (use `required` for that). */
|
|
4
|
+
export declare const mustContain: (word: string) => import('@vuelidate/core').ValidationRuleWithParams<object, any>;
|
|
5
|
+
/** Value must not contain whitespace. */
|
|
6
|
+
export declare const noSpaces: import('@vuelidate/core').ValidationRuleWithParams<object, any>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { helpers as e } from "@vuelidate/validators";
|
|
2
|
+
// src/validators/index.ts
|
|
3
|
+
var { req: t, regex: n, withMessage: r } = e, i = r("Invalid phone number", n(/^\+?[0-9\s-]{7,15}$/)), a = (e) => r(`Must contain "${e}"`, (n) => !t(n) || n.includes(e)), o = r("Spaces are not allowed", (e) => !t(e) || !/\s/.test(e));
|
|
4
|
+
export { a as mustContain, o as noSpaces, i as phone };
|
package/package.json
CHANGED
|
@@ -1,6 +1,98 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sokngounchan/frontend-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable Vue components, composables, utilities and validators",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "Sokngoun <sokngounchan@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/sokngoun/frontend-kit.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/sokngoun/frontend-kit#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sokngoun/frontend-kit/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue",
|
|
18
|
+
"vue3",
|
|
19
|
+
"components",
|
|
20
|
+
"composables",
|
|
21
|
+
"vuelidate",
|
|
22
|
+
"frontend"
|
|
23
|
+
],
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./utils": {
|
|
34
|
+
"types": "./dist/utils/index.d.ts",
|
|
35
|
+
"import": "./dist/utils/index.js",
|
|
36
|
+
"require": "./dist/utils/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./composables": {
|
|
39
|
+
"types": "./dist/composables/index.d.ts",
|
|
40
|
+
"import": "./dist/composables/index.js",
|
|
41
|
+
"require": "./dist/composables/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"./validators": {
|
|
44
|
+
"types": "./dist/validators/index.d.ts",
|
|
45
|
+
"import": "./dist/validators/index.js",
|
|
46
|
+
"require": "./dist/validators/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./style.css": "./dist/style.css",
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"CHANGELOG.md"
|
|
56
|
+
],
|
|
57
|
+
"sideEffects": [
|
|
58
|
+
"**/*.css"
|
|
59
|
+
],
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=18"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"dev": "vite build --watch",
|
|
68
|
+
"build": "vite build",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"typecheck": "vue-tsc --noEmit",
|
|
71
|
+
"prepublishOnly": "npm run typecheck && npm run test && npm run build"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@vuelidate/core": "^2.0.0",
|
|
75
|
+
"@vuelidate/validators": "^2.0.0",
|
|
76
|
+
"vue": "^3.3.0"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"@vuelidate/core": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@vuelidate/validators": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
88
|
+
"@vue/test-utils": "^2.5.1",
|
|
89
|
+
"@vuelidate/core": "^2.0.3",
|
|
90
|
+
"@vuelidate/validators": "^2.0.4",
|
|
91
|
+
"jsdom": "^31.0.0",
|
|
92
|
+
"typescript": "^6.0.3",
|
|
93
|
+
"vite-plugin-dts": "^5.1.2",
|
|
94
|
+
"vitest": "^5.1.0",
|
|
95
|
+
"vue": "^3.5.45",
|
|
96
|
+
"vue-tsc": "^3.3.14"
|
|
97
|
+
}
|
|
6
98
|
}
|