litos-ui 0.0.2 → 0.2.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/lib/animation-QfX4RtqD.js +4 -0
- package/lib/base.d.ts +36 -0
- package/lib/base.js +54 -19
- package/lib/browser.d.ts +8 -0
- package/lib/button/index.d.ts +15 -0
- package/lib/button/index.js +84 -16
- package/lib/form/form_events.d.ts +32 -0
- package/lib/form/form_events.js +24 -0
- package/lib/form/form_inner.d.ts +34 -0
- package/lib/form/form_inner.js +121 -0
- package/lib/form/form_item.d.ts +39 -0
- package/lib/form/form_item.js +128 -0
- package/lib/form/index.d.ts +37 -0
- package/lib/form/index.js +126 -0
- package/lib/form/types.js +1 -0
- package/lib/icon/arrow_down.d.ts +6 -0
- package/lib/icon/arrow_down.js +8 -6
- package/lib/icon/base.d.ts +11 -0
- package/lib/icon/base.js +24 -19
- package/lib/icon/caret_bottom.d.ts +5 -0
- package/lib/icon/caret_bottom.js +8 -6
- package/lib/icon/caret_top.d.ts +5 -0
- package/lib/icon/caret_top.js +8 -6
- package/lib/icon/font_icon.d.ts +12 -0
- package/lib/icon/font_icon.js +18 -13
- package/lib/icon/info.d.ts +6 -0
- package/lib/icon/info.js +8 -6
- package/lib/icon/loading.d.ts +5 -0
- package/lib/icon/loading.js +13 -0
- package/lib/icon/mask_close.d.ts +6 -0
- package/lib/icon/mask_close.js +8 -6
- package/lib/icon/search.d.ts +5 -0
- package/lib/icon/search.js +13 -0
- package/lib/icon/success.d.ts +6 -0
- package/lib/icon/success.js +8 -6
- package/lib/icon/warn.d.ts +6 -0
- package/lib/icon/warn.js +7 -5
- package/lib/index-B_9rPBWp.js +4 -0
- package/lib/index-Boq1Q7q9.js +4 -0
- package/lib/index-CCcVpk6U.js +4 -0
- package/lib/index-ColsUDnt.js +4 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +34 -19
- package/lib/input/index.d.ts +52 -0
- package/lib/input/index.js +118 -0
- package/lib/litos-ui.css +1 -0
- package/lib/litos-ui.min.js +1 -0
- package/lib/message/index.d.ts +25 -0
- package/lib/message/index.js +19 -19
- package/lib/radio/index.d.ts +27 -0
- package/lib/radio/index.js +113 -0
- package/lib/transition.d.ts +15 -0
- package/lib/transition.js +27 -22
- package/lib/util.d.ts +40 -0
- package/lib/util.js +46 -17
- package/package.json +22 -14
- package/styles/message.css +4 -4
- package/styles/reset.css +5 -0
- package/lib/index-DMj9CroY.js +0 -4
package/lib/transition.js
CHANGED
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var c = (r, e, t) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var o = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import d from "./base.js";
|
|
5
|
+
import { startTransition as u, endTransition as g } from "ph-utils/dom";
|
|
6
|
+
class p extends d {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
10
|
+
o(this, "sheetRec");
|
|
11
|
+
this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
12
|
+
}
|
|
4
13
|
static get observedAttributes() {
|
|
5
14
|
return ["sheets"];
|
|
6
15
|
}
|
|
7
|
-
constructor() {
|
|
8
|
-
super(), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
9
|
-
}
|
|
10
16
|
connectedCallback() {
|
|
11
17
|
super.connectedCallback(), this.show();
|
|
12
18
|
}
|
|
13
19
|
render() {
|
|
14
20
|
this.shadow.innerHTML = "<slot></slot>";
|
|
15
21
|
}
|
|
16
|
-
attributeChangedCallback(t,
|
|
17
|
-
t === "sheets" && (this.sheetRec = this._parseSheets(
|
|
22
|
+
attributeChangedCallback(t, s, i) {
|
|
23
|
+
t === "sheets" && (this.sheetRec = this._parseSheets(i));
|
|
18
24
|
}
|
|
19
25
|
show() {
|
|
20
26
|
const t = this._getSlotFirstChild();
|
|
21
27
|
if (!t) return;
|
|
22
|
-
const
|
|
23
|
-
|
|
28
|
+
const s = this.getAttr("duration", "0.3s");
|
|
29
|
+
u(t, this.sheetRec, s);
|
|
24
30
|
}
|
|
25
31
|
hide(t) {
|
|
26
|
-
const
|
|
27
|
-
|
|
32
|
+
const s = this._getSlotFirstChild();
|
|
33
|
+
s && g(s, this.sheetRec, t);
|
|
28
34
|
}
|
|
29
35
|
_parseSheets(t) {
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
if (
|
|
33
|
-
const [h,
|
|
34
|
-
|
|
36
|
+
const s = t.split(";"), i = [];
|
|
37
|
+
return s.forEach((n) => {
|
|
38
|
+
if (n) {
|
|
39
|
+
const [h, a] = n.split(":");
|
|
40
|
+
i.push([h.trim(), a.trim()]);
|
|
35
41
|
}
|
|
36
|
-
}),
|
|
42
|
+
}), i;
|
|
37
43
|
}
|
|
38
44
|
_getSlotFirstChild() {
|
|
39
45
|
const t = this.shadow.querySelector("slot");
|
|
40
46
|
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
41
47
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let o = r;
|
|
48
|
+
}
|
|
49
|
+
o(p, "tagName", "transition");
|
|
45
50
|
export {
|
|
46
|
-
|
|
51
|
+
p as Transition
|
|
47
52
|
};
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type UIConfig = {
|
|
2
|
+
/** 注册应用的前缀, 默认: lt */
|
|
3
|
+
prefix: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function config(cfg: Partial<UIConfig>): void;
|
|
6
|
+
/**
|
|
7
|
+
* 注册 Web Components 组件
|
|
8
|
+
* @param component Web Components 组件
|
|
9
|
+
* @param name 组件名称, 如果不填, 则根据组件的 baseName 生成
|
|
10
|
+
*/
|
|
11
|
+
export declare function regist(component: typeof HTMLElement, name?: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* 隐藏 Transition 组件
|
|
14
|
+
* @param el Transition 组件或者选择器, 不传则为: l-transition
|
|
15
|
+
* @param remove 是否在隐藏后移除元素, 对应 vue-vIf
|
|
16
|
+
*/
|
|
17
|
+
export declare function hideTransition(el?: string | HTMLElement, remove?: boolean): void;
|
|
18
|
+
/**
|
|
19
|
+
* 生成一个唯一标识符,格式为:`uiConfig.prefix-递增的seed值`。
|
|
20
|
+
* 此函数用于在组件或应用中生成唯一的ID。
|
|
21
|
+
* @returns {string} 唯一标识符字符串
|
|
22
|
+
*/
|
|
23
|
+
export declare function useId(): string;
|
|
24
|
+
export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
|
|
25
|
+
export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
|
|
26
|
+
export declare function parseAttrValue(value: string, defaultValue: string, key?: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* 初始化元素的属性值。
|
|
29
|
+
* 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
|
|
30
|
+
* @param el - 要初始化属性的 HTML 元素。
|
|
31
|
+
*/
|
|
32
|
+
export declare function initAttr(el: HTMLElement): void;
|
|
33
|
+
/**
|
|
34
|
+
* 生成 HTML 标签属性字符串。
|
|
35
|
+
* @param attr - 属性名。
|
|
36
|
+
* @param value - 属性值,可以是字符串、undefined 或布尔值。
|
|
37
|
+
* @returns 返回拼接好的属性字符串。
|
|
38
|
+
*/
|
|
39
|
+
export declare function tagAttr(attr: string, value: string | undefined | boolean): string;
|
|
40
|
+
export {};
|
package/lib/util.js
CHANGED
|
@@ -1,27 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { isBlank as u } from "ph-utils";
|
|
2
|
+
let m = -1, i = {
|
|
2
3
|
/** 注册应用的前缀 */
|
|
3
4
|
prefix: "l"
|
|
4
5
|
};
|
|
5
|
-
function
|
|
6
|
-
|
|
6
|
+
function g(t) {
|
|
7
|
+
i = { ...i, ...t };
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
customElements.get(
|
|
9
|
+
function h(t, n) {
|
|
10
|
+
const e = n || `${i.prefix}-${t.baseName}`;
|
|
11
|
+
customElements.get(e) || customElements.define(e, t);
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
typeof
|
|
16
|
-
n &&
|
|
13
|
+
function l(t, n = !1) {
|
|
14
|
+
t = t || "l-transition";
|
|
15
|
+
let e = t;
|
|
16
|
+
typeof t == "string" && (e = document.querySelector(t)), e && e.hide(() => {
|
|
17
|
+
n && e.remove();
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
return `${
|
|
20
|
+
function y() {
|
|
21
|
+
return `${i.prefix}-${++m}`;
|
|
22
|
+
}
|
|
23
|
+
function p(t, n, e) {
|
|
24
|
+
if (t == null) return n;
|
|
25
|
+
switch (typeof n) {
|
|
26
|
+
case "boolean":
|
|
27
|
+
return t === "" || t === "true" || t === "1" || t === e;
|
|
28
|
+
case "number":
|
|
29
|
+
return Number(t);
|
|
30
|
+
default:
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function b(t) {
|
|
35
|
+
const n = t.attributes;
|
|
36
|
+
for (const e of n) {
|
|
37
|
+
const { name: r, value: c } = e;
|
|
38
|
+
if (r.startsWith("data-") || r.startsWith("aria-") || r.startsWith("_") || r.startsWith("$"))
|
|
39
|
+
continue;
|
|
40
|
+
const o = r.split("-").map((s, a) => a === 0 ? s : s[0].toUpperCase() + s.slice(1)).join(""), f = p(c, t[o], r);
|
|
41
|
+
t[o] = f, r === "value" && (t._resetValue = f);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function x(t, n) {
|
|
45
|
+
let e = " ";
|
|
46
|
+
return n === !0 ? e = ` ${t}` : typeof n == "string" && !u(n) && (e = ` ${t}="${n}"`), e;
|
|
21
47
|
}
|
|
22
48
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
g as config,
|
|
50
|
+
l as hideTransition,
|
|
51
|
+
b as initAttr,
|
|
52
|
+
p as parseAttrValue,
|
|
53
|
+
h as regist,
|
|
54
|
+
x as tagAttr,
|
|
55
|
+
y as useId
|
|
27
56
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litos-ui",
|
|
3
3
|
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@eslint/js": "^9.
|
|
8
|
-
"@types/node": "^22.
|
|
9
|
-
"eslint": "^9.
|
|
10
|
-
"globals": "^15.
|
|
11
|
-
"
|
|
7
|
+
"@eslint/js": "^9.16.0",
|
|
8
|
+
"@types/node": "^22.10.1",
|
|
9
|
+
"eslint": "^9.16.0",
|
|
10
|
+
"globals": "^15.13.0",
|
|
11
|
+
"less": "^4.2.1",
|
|
12
|
+
"lightningcss": "^1.28.2",
|
|
13
|
+
"prettier": "^3.4.2",
|
|
12
14
|
"typescript": "^5.7.2",
|
|
13
|
-
"typescript-eslint": "^8.
|
|
14
|
-
"vite": "^
|
|
15
|
+
"typescript-eslint": "^8.17.0",
|
|
16
|
+
"vite": "^6.0.3",
|
|
15
17
|
"vitepress": "^1.5.0"
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
@@ -21,13 +23,15 @@
|
|
|
21
23
|
"main": "./lib/index.js",
|
|
22
24
|
"module": "./lib/index.js",
|
|
23
25
|
"types": "./lib/index.d.ts",
|
|
26
|
+
"jsdelivr": "./lib/litos-ui.min.js",
|
|
27
|
+
"unpkg": "./lib/litos-ui.min.js",
|
|
24
28
|
"exports": {
|
|
25
29
|
"./styles/*": "./styles/*",
|
|
26
30
|
"./lib/*": "./lib/*",
|
|
27
31
|
".": {
|
|
28
32
|
"import": "./lib/index.js",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
34
|
+
"require": "./lib/index.js"
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"repository": {
|
|
@@ -46,15 +50,19 @@
|
|
|
46
50
|
},
|
|
47
51
|
"license": "MIT",
|
|
48
52
|
"dependencies": {
|
|
49
|
-
"ph-utils": "^0.
|
|
50
|
-
"shiki": "^1.
|
|
53
|
+
"ph-utils": "^0.11.3",
|
|
54
|
+
"shiki": "^1.24.0"
|
|
51
55
|
},
|
|
52
56
|
"scripts": {
|
|
53
|
-
"lib:build": "vite build",
|
|
54
57
|
"docs:dev": "vitepress dev docs",
|
|
55
58
|
"docs:build": "vitepress build docs",
|
|
56
59
|
"docs:preview": "vitepress preview docs",
|
|
57
60
|
"inspect:eslint": "eslint --inspect-config",
|
|
58
|
-
"new_version": "node scripts/version.js"
|
|
61
|
+
"new_version": "node scripts/version.js",
|
|
62
|
+
"create": "node scripts/index.js create",
|
|
63
|
+
"source:build": "vite build",
|
|
64
|
+
"iife:build": "vite build -c vite_iife.config.ts --mode browser",
|
|
65
|
+
"dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
|
|
66
|
+
"lib:build": "pnpm source:build && pnpm dts:build && pnpm iife:build"
|
|
59
67
|
}
|
|
60
68
|
}
|
package/styles/message.css
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
border-radius: 5px;
|
|
14
14
|
font-size: 14px;
|
|
15
15
|
background: #f0faff;
|
|
16
|
-
color: var(--l-primary-color);
|
|
16
|
+
color: var(--l-primary-color, #722ed1);
|
|
17
17
|
border: 1px solid #d4eeff;
|
|
18
18
|
z-index: 1000;
|
|
19
19
|
}
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
}
|
|
23
23
|
.l-message.l-message-success {
|
|
24
24
|
background: #edfff3;
|
|
25
|
-
color: var(--l-success-color);
|
|
25
|
+
color: var(--l-success-color, #52c41a);
|
|
26
26
|
border-color: #bbf2cf;
|
|
27
27
|
}
|
|
28
28
|
.l-message.l-message-error {
|
|
29
29
|
background: #ffefe6;
|
|
30
|
-
color: var(--l-error-color);
|
|
30
|
+
color: var(--l-error-color, #f5222d);
|
|
31
31
|
border-color: #ffcfb8;
|
|
32
32
|
}
|
|
33
33
|
.l-message.l-message-warn {
|
|
34
34
|
background: #fff9e6;
|
|
35
|
-
color: var(--l-warn-color);
|
|
35
|
+
color: var(--l-warn-color, #f90);
|
|
36
36
|
border-color: #ffe7a3;
|
|
37
37
|
}
|
|
38
38
|
.l-message-container {
|
package/styles/reset.css
CHANGED
package/lib/index-DMj9CroY.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const r = ".l-btn{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #52c41a);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #31890a);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #31890a);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:var(--l-form-edit-height, 32px);border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var( --l-btn-active-border-color, var(--l-btn-active-background) );color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #31890a);--l-btn-active-text-color: var(--l-primary-color-dark1, #31890a);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color);--l-btn-hover-background: var(--l-primary-color-light1, #31890a);--l-btn-active-background: var(--l-primary-color-dark1, #31890a)}.l-btn:not(.l-btn-loading):disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;height:auto;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #52c41a);--l-btn-hover-text-color: var(--l-primary-color-light1, #31890a);--l-btn-active-text-color: var(--l-primary-color-dark1, #31890a)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height);padding:0}.l-btn-block{width:100%}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
|
|
2
|
-
export {
|
|
3
|
-
r as default
|
|
4
|
-
};
|