litos-ui 0.18.4 → 0.18.5
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/check/checkbox.js +1 -1
- package/lib/check/checkbox_group.js +1 -1
- package/lib/check/radio.js +1 -1
- package/lib/check/radio_group.js +1 -1
- package/lib/{check-CuKgzwRS.js → check-BDOpD_0-.js} +1 -1
- package/lib/{check-BQWzxdO2.js → check-CrlZ7zVL.js} +2 -2
- package/lib/checkbox-D_bZGoUD.js +16 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/{color_picker-fDdSa0hC.js → color_picker-AaFcIczZ.js} +1 -1
- package/lib/date_picker/index.js +1 -1
- package/lib/{date_picker-DHCCvMnX.js → date_picker-HjkRma9j.js} +1 -1
- package/lib/date_picker_ori/index.js +1 -1
- package/lib/{date_picker_ori-JXqzXaYz.js → date_picker_ori-1IOHZsan.js} +1 -1
- package/lib/form/form_inner.d.ts +4 -1
- package/lib/form/index.d.ts +9 -1
- package/lib/form/index.js +1 -1
- package/lib/{form-uOybauzi.js → form-BvZHaqAt.js} +42 -18
- package/lib/{form_inner-B7IMSpMf.js → form_inner-52DR1IPu.js} +12 -3
- package/lib/index.js +11 -11
- package/lib/input/index.js +1 -1
- package/lib/loading/index.js +6 -5
- package/lib/md_input/index.js +1 -1
- package/lib/{md_input-DHz8GRs3.js → md_input-DN3ceqsw.js} +1 -1
- package/lib/{radio-C8FTHdm3.js → radio-C7dkhgwc.js} +1 -1
- package/lib/select/index.d.ts +24 -15
- package/lib/select/index.js +1 -1
- package/lib/select-Cis6kRjQ.js +351 -0
- package/lib/select_ori/index.d.ts +5 -0
- package/lib/select_ori/index.js +2 -48
- package/lib/select_ori-DcJbNYYr.js +57 -0
- package/lib/switch/index.js +1 -1
- package/lib/{switch-DDNxkTiM.js → switch-UyhlgW7F.js} +1 -1
- package/lib/theme/index.js +1 -1
- package/lib/{theme-DBghUmYD.js → theme-Barcq234.js} +5 -2
- package/lib/utils/popover.js +11 -14
- package/package.json +68 -65
- package/styles/vars.css +1 -2
- package/types/preact.d.ts +128 -0
- package/lib/checkbox-CNluBmyo.js +0 -16
- package/lib/select-CnwPEFQ3.js +0 -326
package/package.json
CHANGED
|
@@ -1,66 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "litos-ui",
|
|
3
|
-
"version": "0.18.
|
|
4
|
-
"description": "基于 Web Component 的 UI 组件库",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"component library",
|
|
7
|
-
"litos-ui",
|
|
8
|
-
"ui framework",
|
|
9
|
-
"web component"
|
|
10
|
-
],
|
|
11
|
-
"homepage": "https://dvshu.github.io/litos-ui/",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/DvShu/litos-ui/issues"
|
|
14
|
-
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/DvShu/litos-ui.git"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"lib",
|
|
22
|
-
"styles"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"./
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"docs:
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "litos-ui",
|
|
3
|
+
"version": "0.18.5",
|
|
4
|
+
"description": "基于 Web Component 的 UI 组件库",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"component library",
|
|
7
|
+
"litos-ui",
|
|
8
|
+
"ui framework",
|
|
9
|
+
"web component"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://dvshu.github.io/litos-ui/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/DvShu/litos-ui/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/DvShu/litos-ui.git"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib",
|
|
22
|
+
"styles",
|
|
23
|
+
"types"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./lib/index.js",
|
|
27
|
+
"module": "./lib/index.js",
|
|
28
|
+
"types": "./lib/index.d.ts",
|
|
29
|
+
"unpkg": "./lib/litos-ui.min.js",
|
|
30
|
+
"jsdelivr": "./lib/litos-ui.min.js",
|
|
31
|
+
"exports": {
|
|
32
|
+
"./styles/*": "./styles/*",
|
|
33
|
+
"./lib/*": "./lib/*",
|
|
34
|
+
"./types/*": "./types/*",
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./lib/index.d.ts",
|
|
37
|
+
"import": "./lib/index.js",
|
|
38
|
+
"require": "./lib/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"dev": "vite dev",
|
|
43
|
+
"build": "vite build",
|
|
44
|
+
"docs:dev": "vitepress dev docs --force --host 0.0.0.0",
|
|
45
|
+
"docs:build": "vitepress build docs",
|
|
46
|
+
"docs:preview": "vitepress preview docs",
|
|
47
|
+
"create": "node scripts/index.js create",
|
|
48
|
+
"dts:build": "tsc -p tsconfig.build.json",
|
|
49
|
+
"lib:build": "npm run build && npm run dts:build"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"alien-signals": "^3.2.1",
|
|
53
|
+
"iconify-icon": "^3.0.2",
|
|
54
|
+
"ph-utils": "^0.20.1",
|
|
55
|
+
"qrcode-generator-es": "^2.1.3",
|
|
56
|
+
"shiki": "^4.3.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^26.0.1",
|
|
60
|
+
"less": "^4.6.7",
|
|
61
|
+
"lightningcss": "^1.32.0",
|
|
62
|
+
"oxfmt": "^0.56.0",
|
|
63
|
+
"oxlint": "^1.71.0",
|
|
64
|
+
"preact": "^10.29.2",
|
|
65
|
+
"typescript": "^6.0.3",
|
|
66
|
+
"vite": "^8.1.0",
|
|
67
|
+
"vitepress": "^1.6.4"
|
|
68
|
+
}
|
|
66
69
|
}
|
package/styles/vars.css
CHANGED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "preact";
|
|
2
|
+
|
|
3
|
+
interface ButtonProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
type?: "primary" | "default" | "link";
|
|
5
|
+
block?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
"loading-text"?: string;
|
|
9
|
+
ghost?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ModalProps extends HTMLAttributes<HTMLElement> {
|
|
13
|
+
header?: string | boolean;
|
|
14
|
+
show?: string | boolean;
|
|
15
|
+
onok?: (e: CustomEvent) => void;
|
|
16
|
+
oncancel?: (e: CustomEvent) => void;
|
|
17
|
+
footer?: boolean | string;
|
|
18
|
+
close?: boolean | string;
|
|
19
|
+
title?: string;
|
|
20
|
+
"destroy-on-close"?: boolean;
|
|
21
|
+
"vertical-align"?: string;
|
|
22
|
+
"mask-closable"?: string | boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TagProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
closeable?: boolean;
|
|
27
|
+
type?: "primary" | "info" | "success";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface FormItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
31
|
+
label?: string;
|
|
32
|
+
labelPosition?: "top" | "left";
|
|
33
|
+
required?: boolean;
|
|
34
|
+
prop?: string;
|
|
35
|
+
/** 验证失败时的提示信息 */
|
|
36
|
+
validity?: string;
|
|
37
|
+
pattern?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface PageHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
41
|
+
/** 标题 */
|
|
42
|
+
"page-title"?: string;
|
|
43
|
+
/** 对齐方式 */
|
|
44
|
+
align?: "left" | "center";
|
|
45
|
+
onaction?: (e: CustomEvent) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface CheckBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
49
|
+
checked?: boolean;
|
|
50
|
+
value?: string;
|
|
51
|
+
label?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface CheckboxGroupProps extends HTMLAttributes<HTMLElement> {
|
|
55
|
+
gap?: string;
|
|
56
|
+
value?: string;
|
|
57
|
+
onchange?: (e: CustomEvent) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface MenuProps extends HTMLAttributes<HTMLElement> {
|
|
61
|
+
index?: string;
|
|
62
|
+
onselect?: (e: CustomEvent) => void;
|
|
63
|
+
/** 当前选中的菜单 */
|
|
64
|
+
"selected-index"?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface IconProps extends HTMLAttributes<HTMLElement> {}
|
|
68
|
+
|
|
69
|
+
interface QrcodeProps extends HTMLAttributes<HTMLElement> {
|
|
70
|
+
text: string;
|
|
71
|
+
size?: number | string;
|
|
72
|
+
level?: "H" | "M" | "Q" | "L";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type FormProps = HTMLAttributes<HTMLElement> & {
|
|
76
|
+
/** 表单内的输入元素是否铺满剩余宽度 */
|
|
77
|
+
"inner-block"?: boolean;
|
|
78
|
+
/** 标签的位置; 默认: left */
|
|
79
|
+
"label-position"?: "top" | "left" | "right";
|
|
80
|
+
/** 表单域标签的宽度, 可以传 auto */
|
|
81
|
+
"label-width"?: string;
|
|
82
|
+
novalidate?: boolean;
|
|
83
|
+
onsubmit?: (
|
|
84
|
+
e: CustomEvent<{
|
|
85
|
+
email: string;
|
|
86
|
+
password: string;
|
|
87
|
+
}>,
|
|
88
|
+
) => void | Promise<void>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type InputProps = HTMLAttributes<HTMLElement> & {
|
|
92
|
+
placeholder?: string;
|
|
93
|
+
value?: string;
|
|
94
|
+
oninput?: (e: CustomEvent) => void;
|
|
95
|
+
type?: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
maxlength?: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 正确扩展 Preact 的 JSX 命名空间以支持 VSCode 智能感知
|
|
101
|
+
declare global {
|
|
102
|
+
namespace preact {
|
|
103
|
+
namespace JSX {
|
|
104
|
+
// 扩展 IntrinsicElements 以支持自定义元素
|
|
105
|
+
interface IntrinsicElements {
|
|
106
|
+
"l-arrow-right-icon": IconProps;
|
|
107
|
+
"l-select-icon": IconProps;
|
|
108
|
+
"l-close-icon": IconProps;
|
|
109
|
+
"l-checkbox": CheckBoxProps;
|
|
110
|
+
"l-checkbox-group": CheckboxGroupProps;
|
|
111
|
+
"l-radio-group": CheckboxGroupProps;
|
|
112
|
+
"l-radio": CheckBoxProps;
|
|
113
|
+
"l-button": ButtonProps;
|
|
114
|
+
"l-tag": TagProps;
|
|
115
|
+
"l-modal": ModalProps;
|
|
116
|
+
"l-form-item": FormItemProps;
|
|
117
|
+
"l-form": FormProps;
|
|
118
|
+
"l-page-header": PageHeaderProps;
|
|
119
|
+
"l-menu": MenuProps;
|
|
120
|
+
"l-sub-menu": MenuProps;
|
|
121
|
+
"l-menu-item": MenuProps;
|
|
122
|
+
"l-arrow-down-icon": IconProps;
|
|
123
|
+
"l-qrcode": QrcodeProps;
|
|
124
|
+
"l-input": InputProps;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
package/lib/checkbox-CNluBmyo.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { n as e, t } from "./check-BQWzxdO2.js";
|
|
2
|
-
//#region src/components/check/checkbox.less?inline
|
|
3
|
-
var n = ":host(.is-indeterminate) .l-check__inner{background-color:var(--l-primary-color,#722ed1)}:host(.is-indeterminate) .l-check__inner:after{content:\"\";width:calc(var(--l-check-size) * .4);border:none;border-bottom:1px solid #fff;height:1px;margin-top:0;display:block;transform:rotate(0)}.l-check__inner:after,:host(.is-checked) .l-check__inner:after{content:\"\";width:calc(var(--l-check-size) * .6);height:calc(var(--l-check-size) * .3);border-top:none;border-bottom:1px solid #0000;border-left:1px solid #0000;border-right:none;margin-top:-3px;transition:border-color .2s ease-in-out;display:block;transform:rotate(-45deg)}:host(.is-checked) .l-check__inner{background-color:var(--l-primary-color,#722ed1)}:host(.is-checked) .l-check__inner:after{border-color:#fff}:host(.is-disabled) .l-check__inner{background-color:var(--l-disabled-color,#e6e6e6);border-color:var(--l-disabled-color,#e6e6e6)}", r = class extends e {
|
|
4
|
-
static baseName = "checkbox";
|
|
5
|
-
constructor() {
|
|
6
|
-
super(), this._inputType = "checkbox";
|
|
7
|
-
}
|
|
8
|
-
connectedCallback() {
|
|
9
|
-
this.loadStyleText([t, n]), super.connectedCallback();
|
|
10
|
-
}
|
|
11
|
-
_doChangeAction() {
|
|
12
|
-
this.getChecked() ? this.setChecked(!1) : this.setChecked(!0), this.emitChange();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { r as t };
|
package/lib/select-CnwPEFQ3.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { kebabToCamel as e, parseAttrValue as t } from "./utils/index.js";
|
|
2
|
-
import { t as n } from "./form_inner-B7IMSpMf.js";
|
|
3
|
-
import { Popover as r } from "./utils/popover.js";
|
|
4
|
-
import { $ as i, $$ as a, $one as o, iterate as s, off as c, on as l, shouldEventNext as u } from "ph-utils/dom";
|
|
5
|
-
import { debounce as d } from "ph-utils/web";
|
|
6
|
-
//#region src/components/select/index.less?inline
|
|
7
|
-
var f = ":host{--l-select-width:100%;min-height:var(--l-form-control-height,32px);width:var(--l-select-width);border:1px solid var(--l-border-color,#d9d9d9);cursor:pointer;box-sizing:border-box;border-radius:4px;justify-content:space-between;align-items:center;gap:5px;padding:4px 10px;font-size:14px;line-height:1;transition:border-color .3s;display:inline-flex;position:relative}:host(:hover){border-color:silver}:host(.l-select--disabled){background-color:var(--l-disabled-color,#f5f7fa);cursor:not-allowed}:host(.l-select--expand),:host(.l-select--active){border-color:var(--l-primary-color,#722ed1)}:host(.l-select--expand) .l-select-arrow{transform:rotate(180deg)}:host(.l-select--loading) .l-select-arrow{opacity:.2}:host(.l-select--clearable) .l-select-arrow{opacity:0}.l-select-main{box-sizing:border-box;flex-flow:wrap;flex-grow:1;gap:5px;display:flex;overflow:hidden}.l-selected-item{flex-shrink:0}.l-select-placeholder{flex-grow:1}.l-select-placeholder,.l-select-arrow{color:#a8abb2}.l-select-filter{background-color:#0000;border:none;outline:none;flex-grow:1;flex-shrink:0;width:0;min-width:15px;max-width:100%}.l-select-filter::placeholder{color:#a8abb2}.l-select-arrow{flex-shrink:0;transition:transform .3s,opacity .3s;transform:rotate(0)}.l-select-tag-close{box-sizing:border-box;cursor:pointer;border-radius:50%;justify-content:center;align-items:center;width:14px;height:14px;margin-left:3px;font-size:12px;transition:color .3s,background-color .3s;display:inline-flex}.l-select-tag-close:hover{color:#fff;background-color:#999}.l-select-clear,.l-select-loading{position:absolute;top:50%;right:10px;transform:translateY(-50%)}.l-select-loading{color:var(--l-primary-color,#722ed1);z-index:2;animation:1.5s linear infinite l-select-loading}.l-select-clear{color:#afafaf;z-index:1}@keyframes l-select-loading{0%{transform:translateY(-50%)rotate(0)}to{transform:translateY(-50%)rotate(360deg)}}", p = class extends n {
|
|
8
|
-
static baseName = "select";
|
|
9
|
-
selectedLabels = [];
|
|
10
|
-
filterable = !1;
|
|
11
|
-
placeholder = "请选择";
|
|
12
|
-
labelField = "label";
|
|
13
|
-
valueField = "value";
|
|
14
|
-
multiple = !1;
|
|
15
|
-
collapseTags = !1;
|
|
16
|
-
_loading = !1;
|
|
17
|
-
width;
|
|
18
|
-
clearable = !1;
|
|
19
|
-
_expanded = !1;
|
|
20
|
-
remote = !1;
|
|
21
|
-
filter;
|
|
22
|
-
options = [];
|
|
23
|
-
_backOptions;
|
|
24
|
-
inputHandler;
|
|
25
|
-
_popover;
|
|
26
|
-
_searchEl;
|
|
27
|
-
constructor() {
|
|
28
|
-
super(!0, !1);
|
|
29
|
-
}
|
|
30
|
-
connectedCallback() {
|
|
31
|
-
this.loadStyleText(f), super.connectedCallback();
|
|
32
|
-
}
|
|
33
|
-
setInputHandler(e) {
|
|
34
|
-
this.inputHandler = e;
|
|
35
|
-
}
|
|
36
|
-
setFilter(e) {
|
|
37
|
-
this.filter = e;
|
|
38
|
-
}
|
|
39
|
-
get loading() {
|
|
40
|
-
return this._loading;
|
|
41
|
-
}
|
|
42
|
-
set loading(e) {
|
|
43
|
-
this.setLoading(e ?? !1);
|
|
44
|
-
}
|
|
45
|
-
setLoading(e) {
|
|
46
|
-
this._loading = e;
|
|
47
|
-
let t = o(".l-select-loading", this.root);
|
|
48
|
-
e && (t || this.root.appendChild(a("l-loading-icon", { class: "l-select-loading" })), this.classList.add("l-select--loading")), t &&= (this.classList.remove("l-select--loading"), t.remove(), null);
|
|
49
|
-
}
|
|
50
|
-
get expanded() {
|
|
51
|
-
return this._expanded;
|
|
52
|
-
}
|
|
53
|
-
set expanded(e) {
|
|
54
|
-
this.setExpanded(e);
|
|
55
|
-
}
|
|
56
|
-
setExpanded(e) {
|
|
57
|
-
this._expanded = e, e ? (this.classList.add("l-select--expand"), this._searchEl && this._searchEl.focus()) : this.classList.remove("l-select--expand");
|
|
58
|
-
}
|
|
59
|
-
setValue(e) {
|
|
60
|
-
let t = e;
|
|
61
|
-
typeof e == "string" && (t = e.split(",")), this.multiple ? Array.isArray(t) || (t = [t]) : Array.isArray(t) && (t = t[0]), super.setValue(t), this._updateSelectedLabels(), this._reRenderLabels();
|
|
62
|
-
}
|
|
63
|
-
_updateSelectedLabels() {
|
|
64
|
-
if (this.options) {
|
|
65
|
-
this.selectedLabels = this.options.filter((e) => this._isOptionSelect(e[this.valueField])).map((e) => e[this.labelField]);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
this.selectedLabels = [];
|
|
69
|
-
}
|
|
70
|
-
static get observedAttributes() {
|
|
71
|
-
return [
|
|
72
|
-
"disabled",
|
|
73
|
-
"value",
|
|
74
|
-
"multiple",
|
|
75
|
-
"placeholder",
|
|
76
|
-
"collapse-tags",
|
|
77
|
-
"filterable",
|
|
78
|
-
"loading",
|
|
79
|
-
"label-field",
|
|
80
|
-
"value-field",
|
|
81
|
-
"width",
|
|
82
|
-
"clearable",
|
|
83
|
-
"expanded",
|
|
84
|
-
"remote"
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
attributeChange(n, r, i) {
|
|
88
|
-
n = e(n);
|
|
89
|
-
let a = t(i, this[n], n);
|
|
90
|
-
if (a !== this[n] && (this[n] = a), this.rendered) switch (n) {
|
|
91
|
-
case "width":
|
|
92
|
-
a ? this.style.setProperty("--l-select-width", a) : this.style.removeProperty("--l-select-width");
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
setOptions(e) {
|
|
97
|
-
this.options = e, this._backOptions = [...e], this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
98
|
-
}
|
|
99
|
-
_isOptionSelect(e) {
|
|
100
|
-
let t = !1;
|
|
101
|
-
return e != null && this.value != null && (t = this.multiple ? this.value.includes(e) : e === this.value), t;
|
|
102
|
-
}
|
|
103
|
-
_updateOptionSelect(e, t) {
|
|
104
|
-
let n = o(".l-select-icon", e);
|
|
105
|
-
t ? (e.classList.add("l-select-option--selected"), n || a("l-select-icon", { class: "l-select-icon" }, e)) : (e.classList.remove("l-select-option--selected"), n && n.remove());
|
|
106
|
-
}
|
|
107
|
-
_renderOption() {
|
|
108
|
-
let e = [];
|
|
109
|
-
if (this.options) {
|
|
110
|
-
let t = this.options.length;
|
|
111
|
-
for (let n = 0; n < t; n++) {
|
|
112
|
-
let t = this.options[n], r = this._isOptionSelect(t[this.valueField]), i = a("li", {
|
|
113
|
-
class: ["l-select-option", r ? "l-select-option--selected" : void 0],
|
|
114
|
-
"data-action": `${n}`
|
|
115
|
-
});
|
|
116
|
-
a("span", {
|
|
117
|
-
class: "l-select-option-content",
|
|
118
|
-
textContent: t[this.labelField],
|
|
119
|
-
title: t[this.labelField]
|
|
120
|
-
}, i), r && a("l-select-icon", { class: "l-select-icon" }, i), e.push(i.outerHTML);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (e.length === 0) {
|
|
124
|
-
let t = a("li", {
|
|
125
|
-
class: "l-select-option l-select-option--empty",
|
|
126
|
-
textContent: "暂无数据"
|
|
127
|
-
});
|
|
128
|
-
e.push(t.outerHTML);
|
|
129
|
-
}
|
|
130
|
-
return e.join("");
|
|
131
|
-
}
|
|
132
|
-
_calculateOffset(e, t) {
|
|
133
|
-
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
134
|
-
return n.top - r.top + t.scrollTop;
|
|
135
|
-
}
|
|
136
|
-
isEmpty() {
|
|
137
|
-
let e = !0;
|
|
138
|
-
return !this.multiple && this.value != null && this.value !== "" && (e = !1), this.multiple && this.value && this.value.length > 0 && (e = !1), e;
|
|
139
|
-
}
|
|
140
|
-
_toggleClearable(e = !1) {
|
|
141
|
-
if (this.clearable) {
|
|
142
|
-
let t = o(".l-select-clear", this.root);
|
|
143
|
-
if (e || this.isEmpty() || this.loading) {
|
|
144
|
-
t && t.remove(), this.classList.remove("l-select--clearable");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
t || a("l-close-filled-icon", {
|
|
148
|
-
class: "l-select-clear",
|
|
149
|
-
"data-action": "clear"
|
|
150
|
-
}, this.root), this.classList.add("l-select--clearable");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
_onMouseEnter = () => {
|
|
154
|
-
this._toggleClearable(!1);
|
|
155
|
-
};
|
|
156
|
-
_onMouseLeave = () => {
|
|
157
|
-
this._toggleClearable(!0);
|
|
158
|
-
};
|
|
159
|
-
_togglePopover() {
|
|
160
|
-
if (this._popover) {
|
|
161
|
-
if (this._popover.isShow()) {
|
|
162
|
-
this._popover.hide();
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
this._popover.show(this);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
_updatePopoverContent() {
|
|
169
|
-
this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
170
|
-
}
|
|
171
|
-
_onRootTap = (e) => {
|
|
172
|
-
e.stopPropagation();
|
|
173
|
-
let [t, n, r] = u(e, "data-action", e.currentTarget);
|
|
174
|
-
if (t) {
|
|
175
|
-
if (n === "clear") this.value = this.multiple ? [] : "", this.selectedLabels = [], this._toggleClearable(!0), this._reRenderLabels(), this._updatePopoverContent();
|
|
176
|
-
else {
|
|
177
|
-
let e = Number(n);
|
|
178
|
-
this.selectedLabels.splice(e, 1), this._value.splice(e, 1), this._updatePopoverContent(), this.collapseTags ? this._reRenderLabels() : r.parentElement && (r.parentElement.remove(), this._updateSearchValue()), this._searchEl && this._searchEl.focus();
|
|
179
|
-
}
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
this._togglePopover();
|
|
183
|
-
};
|
|
184
|
-
_onTap = () => {
|
|
185
|
-
this._togglePopover();
|
|
186
|
-
};
|
|
187
|
-
_onSearchBlur = () => {
|
|
188
|
-
this._updateSearchValue();
|
|
189
|
-
};
|
|
190
|
-
_onSearchInput = (e) => {
|
|
191
|
-
if (this.inputHandler && this.filterable) {
|
|
192
|
-
let t = e.target.value;
|
|
193
|
-
this.inputHandler(t);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
_handleFilte = (e) => {
|
|
197
|
-
if (this.remote) {
|
|
198
|
-
this.emit("search", { detail: { value: e } });
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
this.options = this._filteOption(e), this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
202
|
-
};
|
|
203
|
-
_filteOption(e) {
|
|
204
|
-
let t = [];
|
|
205
|
-
return this._backOptions && (t = this._backOptions.filter((t) => e ? this.filter ? this.filter(e, t) : t[this.labelField].includes(e) : !0)), t;
|
|
206
|
-
}
|
|
207
|
-
afterInit() {
|
|
208
|
-
l(this, "mouseenter", this._onMouseEnter), l(this, "mouseleave", this._onMouseLeave), l(this.root, "click", this._onRootTap), l(this, "click", this._onTap), this._searchEl = o(".l-select-filter", this.root), this._searchEl && (this.inputHandler = d(this._handleFilte, 300), l(this._searchEl, "input", this._onSearchInput), l(this._searchEl, "blur", this._onSearchBlur)), this.disabledChange(), this.width && this.style.setProperty("--l-select-width", this.width), this._popover ||= new r({
|
|
209
|
-
arrow: !1,
|
|
210
|
-
offset: 2,
|
|
211
|
-
placement: "bottom",
|
|
212
|
-
popoverWidth: "trigger",
|
|
213
|
-
trigger: "manual",
|
|
214
|
-
theme: "select",
|
|
215
|
-
disabled: this.isDisabled(),
|
|
216
|
-
contentRender() {
|
|
217
|
-
return "<ul class=\"l-select-list\"></ul>";
|
|
218
|
-
},
|
|
219
|
-
updateContent: (e) => {
|
|
220
|
-
let t = o(".l-select-list", e);
|
|
221
|
-
t && (t.innerHTML = this._renderOption());
|
|
222
|
-
},
|
|
223
|
-
onOpenChange: (e) => {
|
|
224
|
-
this.setExpanded(e);
|
|
225
|
-
},
|
|
226
|
-
onPopoverAction: (e, t) => {
|
|
227
|
-
if (e && this.options) {
|
|
228
|
-
let n = Number(e), r = this.options[n], a = r[this.valueField], o = r[this.labelField], c = this.value, l = this.selectedLabels;
|
|
229
|
-
if (this.multiple === !0) if (!c) c = [a], l = [o];
|
|
230
|
-
else if (Array.isArray(c)) {
|
|
231
|
-
let e = c.indexOf(a);
|
|
232
|
-
e === -1 ? (c.push(a), l.push(o)) : (c.splice(e, 1), l.splice(e, 1));
|
|
233
|
-
} else c != a && (c = [c, a], l = [l, o]);
|
|
234
|
-
else c = a, l = [o];
|
|
235
|
-
this._value = c, this.selectedLabels = l;
|
|
236
|
-
let u = this._isOptionSelect(a);
|
|
237
|
-
this.multiple || s(i(".l-select-option--selected", t.parentElement), (e) => {
|
|
238
|
-
this._updateOptionSelect(e, !1);
|
|
239
|
-
}), this._updateOptionSelect(t, u), this._reRenderLabels(), !this.multiple && this._popover && this._popover.hide(), this._searchEl && this.multiple && this._searchEl.focus();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
beforeDestroy() {
|
|
245
|
-
if (c(this, "mouseenter", this._onMouseEnter), c(this, "mouseleave", this._onMouseLeave), c(this.root, "click", this._onRootTap), c(this, "click", this._onTap), this.options = void 0, this._popover &&= (this._popover.destroy(), void 0), this._searchEl) {
|
|
246
|
-
if (c(this._searchEl, "blur", this._onSearchBlur), c(this._searchEl, "input", this._onSearchInput), this.inputHandler) {
|
|
247
|
-
try {
|
|
248
|
-
this.inputHandler.cancel();
|
|
249
|
-
} catch {}
|
|
250
|
-
this.inputHandler = void 0;
|
|
251
|
-
}
|
|
252
|
-
this._searchEl = void 0;
|
|
253
|
-
}
|
|
254
|
-
this.filter = void 0;
|
|
255
|
-
}
|
|
256
|
-
render() {
|
|
257
|
-
let e = document.createDocumentFragment(), t = a("div", { class: "l-select-main" }), n = this._renderSelectedLabels();
|
|
258
|
-
if (t.appendChild(n), this.filterable) {
|
|
259
|
-
let e = this.placeholder || "请选择", n = "";
|
|
260
|
-
this.selectedLabels.length > 0 && (this.multiple ? e = "" : (e = this.selectedLabels[0], n = this.selectedLabels[0])), t.appendChild(a("input", {
|
|
261
|
-
class: "l-select-filter",
|
|
262
|
-
placeholder: e,
|
|
263
|
-
value: n
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
e.appendChild(t);
|
|
267
|
-
let r = a("l-arrow-down-icon", { class: "l-select-arrow" });
|
|
268
|
-
return e.appendChild(r), e;
|
|
269
|
-
}
|
|
270
|
-
disabledChange() {
|
|
271
|
-
if (!this.rendered) return;
|
|
272
|
-
let e = this.isDisabled();
|
|
273
|
-
this._popover && this._popover.setOption("disabled", e), e ? this.classList.add("l-select--disabled") : this.classList.remove("l-select--disabled"), this._searchEl && (this._searchEl.disabled = e);
|
|
274
|
-
}
|
|
275
|
-
_renderTag(e, t = 0, n = !0) {
|
|
276
|
-
let r = a("l-tag", {
|
|
277
|
-
type: "info",
|
|
278
|
-
class: "l-selected-item",
|
|
279
|
-
textContent: e
|
|
280
|
-
});
|
|
281
|
-
if (n) {
|
|
282
|
-
let e = a("div", {
|
|
283
|
-
class: "l-select-tag-close",
|
|
284
|
-
slot: "suffix",
|
|
285
|
-
innerHTML: "<l-close-icon></l-close-icon>",
|
|
286
|
-
"data-action": `${t}`
|
|
287
|
-
});
|
|
288
|
-
r.appendChild(e);
|
|
289
|
-
}
|
|
290
|
-
return r;
|
|
291
|
-
}
|
|
292
|
-
_reRenderLabels() {
|
|
293
|
-
let e = o(".l-select-main", this.root);
|
|
294
|
-
if (e) {
|
|
295
|
-
let t = i(".l-selected-item", e);
|
|
296
|
-
t.length > 0 && s(t, (e) => {
|
|
297
|
-
e && e != this._searchEl && e.remove();
|
|
298
|
-
});
|
|
299
|
-
let n = this._renderSelectedLabels();
|
|
300
|
-
this._searchEl ? e.insertBefore(n, this._searchEl) : e.appendChild(n);
|
|
301
|
-
}
|
|
302
|
-
this._updateSearchValue();
|
|
303
|
-
}
|
|
304
|
-
_updateSearchValue() {
|
|
305
|
-
if (this._searchEl) {
|
|
306
|
-
let e = this.placeholder || "请选择", t = "";
|
|
307
|
-
this.selectedLabels.length > 0 && (this.multiple ? e = "" : (e = this.selectedLabels[0], t = this.selectedLabels[0])), this._searchEl.placeholder = e, this._searchEl.value = t;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
_renderSelectedLabels() {
|
|
311
|
-
let e = document.createDocumentFragment(), t = this.selectedLabels.length;
|
|
312
|
-
if (t > 0) if (!this.multiple) this.filterable || e.appendChild(a("span", {
|
|
313
|
-
class: "l-selected-item",
|
|
314
|
-
textContent: this.selectedLabels[0]
|
|
315
|
-
}));
|
|
316
|
-
else if (this.collapseTags) e.appendChild(this._renderTag(this.selectedLabels[0])), t > 1 && e.appendChild(this._renderTag(`+${t - 1}`, -1, !1));
|
|
317
|
-
else for (let n = 0; n < t; n++) e.appendChild(this._renderTag(this.selectedLabels[n], n));
|
|
318
|
-
else this.filterable || e.appendChild(a("span", {
|
|
319
|
-
class: "l-selected-item l-select-placeholder",
|
|
320
|
-
textContent: this.placeholder
|
|
321
|
-
}));
|
|
322
|
-
return e;
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
//#endregion
|
|
326
|
-
export { p as t };
|