litos-ui 0.15.7 → 0.16.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.
Files changed (44) hide show
  1. package/lib/button/index.d.ts +4 -0
  2. package/lib/button/index.js +24 -16
  3. package/lib/check/check.js +6 -7
  4. package/lib/check/checkbox.js +1 -1
  5. package/lib/check/index.d.ts +2 -1
  6. package/lib/check/index.js +25 -12
  7. package/lib/check/radio.js +10 -6
  8. package/lib/check-C7YSuH60.js +4 -0
  9. package/lib/color_picker/index.js +1 -1
  10. package/lib/description_panel/index.js +4 -9
  11. package/lib/dialog/dialog_container.js +4 -6
  12. package/lib/form/form_inner.d.ts +3 -0
  13. package/lib/form/form_inner.js +28 -23
  14. package/lib/image/image_preview.js +3 -3
  15. package/lib/index-DvcllHRh.js +4 -0
  16. package/lib/index.d.ts +2 -0
  17. package/lib/index.js +163 -164
  18. package/lib/input/index.d.ts +2 -1
  19. package/lib/input/index.js +37 -26
  20. package/lib/mask/index.js +1 -6
  21. package/lib/message/index.d.ts +11 -12
  22. package/lib/message/index.js +39 -40
  23. package/lib/modal/index.js +1 -1
  24. package/lib/select/index.js +1 -6
  25. package/lib/select_ori/index.js +1 -1
  26. package/lib/space/index.d.ts +8 -0
  27. package/lib/space/index.js +35 -0
  28. package/lib/tabbar/index.d.ts +3 -1
  29. package/lib/tabbar/index.js +13 -7
  30. package/lib/table/index.d.ts +27 -10
  31. package/lib/table/index.js +165 -96
  32. package/lib/table/types.d.ts +9 -1
  33. package/lib/tag/index.js +4 -1
  34. package/lib/utils/index.d.ts +0 -25
  35. package/lib/utils/index.js +40 -87
  36. package/lib/utils/popover.js +24 -17
  37. package/package.json +41 -40
  38. package/styles/container.css +1 -0
  39. package/styles/dark.css +13 -0
  40. package/styles/reset.css +3 -5
  41. package/styles/vars.css +10 -12
  42. package/lib/check-A86JxUfd.js +0 -4
  43. package/lib/index-D4II9KsF.js +0 -4
  44. package/lib/menu/base.js +0 -1
package/lib/index.js CHANGED
@@ -1,166 +1,165 @@
1
- import { getPopoverOffsetX as t, getPopoverOffsetY as r, impactDetect as a, initAttr as f, kebabToCamel as s, parseAttrValue as l, regist as m, setAttrs as p, tagAttr as u, tagAttrs as d, useId as x } from "./utils/index.js";
2
- import { set as c, remove as I } from "./utils/clickoutside.js";
3
- import { default as g } from "./base.js";
4
- import { default as P } from "./message/index.js";
5
- import { default as h } from "./dialog/index.js";
6
- import { default as w } from "./dialog/dialog_container.js";
7
- import { default as v } from "./loading/index.js";
8
- import { default as M } from "./tabs/index.js";
9
- import { default as k } from "./modal/index.js";
10
- import { default as R } from "./icon/base.js";
11
- import { default as B } from "./icon/arrow_down.js";
12
- import { default as G } from "./icon/arrow_left.js";
13
- import { default as Z } from "./icon/arrow_right.js";
14
- import { default as H } from "./icon/arrow_up.js";
15
- import { default as V } from "./icon/caret_top.js";
16
- import { default as X } from "./icon/caret_bottom.js";
17
- import { default as j } from "./icon/font_icon.js";
18
- import { default as z } from "./icon/loading.js";
19
- import { default as J } from "./icon/search.js";
20
- import { default as N } from "./icon/sun.js";
21
- import { default as $ } from "./icon/moon.js";
22
- import { default as eo } from "./icon/reduction.js";
23
- import { default as ro } from "./icon/refresh_left.js";
24
- import { default as fo } from "./icon/refresh_right.js";
25
- import { default as lo } from "./icon/sort.js";
26
- import { default as po } from "./icon/theme_default.js";
27
- import { default as xo } from "./icon/close.js";
28
- import { default as co } from "./icon/info.js";
29
- import { default as io } from "./icon/success.js";
30
- import { default as Co } from "./icon/warn.js";
31
- import { default as bo } from "./icon/close_filled.js";
32
- import { default as Ao } from "./icon/more.js";
33
- import { default as To } from "./icon/d_arrow_left.js";
34
- import { default as Do } from "./icon/d_arrow_right.js";
35
- import { default as So } from "./icon/zoom_in.js";
36
- import { default as Oo } from "./icon/zoom_out.js";
37
- import { default as Lo } from "./icon/select.js";
38
- import { default as Fo } from "./form/index.js";
39
- import { default as Uo } from "./form/form_item.js";
40
- import { default as yo } from "./check/radio_group.js";
41
- import { default as Qo } from "./check/radio.js";
42
- import { default as Wo } from "./check/checkbox.js";
43
- import { default as Yo } from "./check/checkbox_group.js";
44
- import { default as qo } from "./button/index.js";
45
- import { default as Eo } from "./input/index.js";
46
- import { default as Ko } from "./select_ori/index.js";
47
- import { default as _o } from "./switch/index.js";
48
- import { default as oe } from "./md_input/index.js";
49
- import { default as te } from "./select/index.js";
50
- import { default as ae } from "./list/index.js";
51
- import { default as se } from "./polygon/index.js";
52
- import { default as me } from "./color_picker/index.js";
53
- import { default as ue } from "./tabbar/index.js";
54
- import { default as xe } from "./tabbar/item.js";
55
- import { default as ce } from "./theme/index.js";
56
- import { default as ie } from "./theme/theme_color.js";
57
- import { default as Ce } from "./date_picker/index.js";
58
- import { default as be } from "./menu/index.js";
59
- import { default as Ae } from "./menu/menu_item.js";
60
- import { default as Te } from "./menu/sub_menu.js";
61
- import { default as De } from "./carousel/index.js";
62
- import { default as Se } from "./carousel/item.js";
63
- import { default as Oe } from "./qrcode/index.js";
64
- import { default as Le } from "./description_panel/index.js";
65
- import { default as Fe } from "./pagination/index.js";
66
- import { default as Ue } from "./mask/index.js";
67
- import { default as ye } from "./page_header/index.js";
68
- import { default as Qe } from "./tag/index.js";
69
- import { default as We } from "./collapse/index.js";
70
- import { default as Ye } from "./collapse/item.js";
71
- import { default as qe } from "./image/index.js";
72
- import { default as Ee } from "./image/image_preview.js";
73
- import { Popover as Ke, autoUpdate as Ne, createPopoverObserver as _e, getOverflowAncestors as $e, popconfirmProps as ot, updatePosition as et } from "./utils/popover.js";
74
- import { default as rt } from "./table/index.js";
1
+ import { initAttr as r, kebabToCamel as t, parseAttrValue as a, regist as f, setAttrs as s, tagAttr as l, tagAttrs as m, useId as p } from "./utils/index.js";
2
+ import { set as d, remove as x } from "./utils/clickoutside.js";
3
+ import { default as c } from "./base.js";
4
+ import { default as i } from "./message/index.js";
5
+ import { default as C } from "./dialog/index.js";
6
+ import { default as h } from "./dialog/dialog_container.js";
7
+ import { default as P } from "./loading/index.js";
8
+ import { default as S } from "./tabs/index.js";
9
+ import { default as M } from "./modal/index.js";
10
+ import { default as D } from "./icon/base.js";
11
+ import { default as v } from "./icon/arrow_down.js";
12
+ import { default as O } from "./icon/arrow_left.js";
13
+ import { default as F } from "./icon/arrow_right.js";
14
+ import { default as U } from "./icon/arrow_up.js";
15
+ import { default as y } from "./icon/caret_top.js";
16
+ import { default as Q } from "./icon/caret_bottom.js";
17
+ import { default as W } from "./icon/font_icon.js";
18
+ import { default as q } from "./icon/loading.js";
19
+ import { default as E } from "./icon/search.js";
20
+ import { default as K } from "./icon/sun.js";
21
+ import { default as X } from "./icon/moon.js";
22
+ import { default as _ } from "./icon/reduction.js";
23
+ import { default as oo } from "./icon/refresh_left.js";
24
+ import { default as ro } from "./icon/refresh_right.js";
25
+ import { default as ao } from "./icon/sort.js";
26
+ import { default as so } from "./icon/theme_default.js";
27
+ import { default as mo } from "./icon/close.js";
28
+ import { default as uo } from "./icon/info.js";
29
+ import { default as no } from "./icon/success.js";
30
+ import { default as Io } from "./icon/warn.js";
31
+ import { default as go } from "./icon/close_filled.js";
32
+ import { default as bo } from "./icon/more.js";
33
+ import { default as Ao } from "./icon/d_arrow_left.js";
34
+ import { default as wo } from "./icon/d_arrow_right.js";
35
+ import { default as To } from "./icon/zoom_in.js";
36
+ import { default as ko } from "./icon/zoom_out.js";
37
+ import { default as Ro } from "./icon/select.js";
38
+ import { default as Lo } from "./form/index.js";
39
+ import { default as Bo } from "./form/form_item.js";
40
+ import { default as Go } from "./check/radio_group.js";
41
+ import { default as Zo } from "./check/radio.js";
42
+ import { default as Ho } from "./check/checkbox.js";
43
+ import { default as Vo } from "./check/checkbox_group.js";
44
+ import { default as jo } from "./button/index.js";
45
+ import { default as zo } from "./input/index.js";
46
+ import { default as Jo } from "./select_ori/index.js";
47
+ import { default as No } from "./switch/index.js";
48
+ import { default as Yo } from "./md_input/index.js";
49
+ import { default as $o } from "./select/index.js";
50
+ import { default as ee } from "./list/index.js";
51
+ import { default as te } from "./polygon/index.js";
52
+ import { default as fe } from "./color_picker/index.js";
53
+ import { default as le } from "./tabbar/index.js";
54
+ import { default as pe } from "./tabbar/item.js";
55
+ import { default as de } from "./theme/index.js";
56
+ import { default as ne } from "./theme/theme_color.js";
57
+ import { default as Ie } from "./date_picker/index.js";
58
+ import { default as ge } from "./menu/index.js";
59
+ import { default as be } from "./menu/menu_item.js";
60
+ import { default as Ae } from "./menu/sub_menu.js";
61
+ import { default as we } from "./carousel/index.js";
62
+ import { default as Te } from "./carousel/item.js";
63
+ import { default as ke } from "./qrcode/index.js";
64
+ import { default as Re } from "./description_panel/index.js";
65
+ import { default as Le } from "./pagination/index.js";
66
+ import { default as Be } from "./mask/index.js";
67
+ import { default as Ge } from "./page_header/index.js";
68
+ import { default as Ze } from "./tag/index.js";
69
+ import { default as He } from "./collapse/index.js";
70
+ import { default as Ve } from "./collapse/item.js";
71
+ import { default as je } from "./image/index.js";
72
+ import { default as ze } from "./image/image_preview.js";
73
+ import { Popover as Je, autoUpdate as Ke, createPopoverObserver as Ne, getOverflowAncestors as Xe, popconfirmProps as Ye, updatePosition as _e } from "./utils/popover.js";
74
+ import { default as or } from "./table/index.js";
75
+ import { default as rr } from "./space/index.js";
75
76
  export {
76
- B as ArrowDownIcon,
77
- G as ArrowLeftIcon,
78
- Z as ArrowRightIcon,
79
- H as ArrowUpIcon,
80
- g as BaseComponent,
81
- R as BaseIcon,
82
- qo as Button,
83
- X as CaretBottomIcon,
84
- V as CaretTopIcon,
85
- De as Carousel,
86
- Se as CarouselItem,
87
- Wo as Checkbox,
88
- Yo as CheckboxGroup,
89
- bo as CloseFilledIcon,
90
- xo as CloseIcon,
91
- We as Collapse,
92
- Ye as CollapseItem,
93
- me as ColorPicker,
94
- To as DArrowLeftIcon,
95
- Do as DArrowRightIcon,
96
- Ce as DatePicker,
97
- Le as DescriptionPanel,
98
- h as Dialog,
99
- w as DialogContainer,
100
- j as FontIcon,
101
- Fo as Form,
102
- Uo as FormItem,
103
- qe as Image,
104
- Ee as ImagePreview,
105
- co as InfoIcon,
106
- Eo as Input,
107
- ae as List,
108
- v as Loading,
109
- z as LoadingIcon,
110
- Ue as Mask,
111
- oe as MdInput,
112
- be as Menu,
113
- Ae as MenuItem,
114
- P as Message,
115
- k as Modal,
116
- $ as MoonIcon,
117
- Ao as MoreIcon,
118
- ye as PageHeader,
119
- Fe as Pagination,
120
- se as Polygon,
121
- Ke as Popover,
122
- Oe as Qrcode,
123
- Qo as Radio,
124
- yo as RadioGroup,
125
- eo as ReductionIcon,
126
- ro as RefreshLeftIcon,
127
- fo as RefreshRightIcon,
128
- J as SearchIcon,
129
- te as Select,
130
- Lo as SelectIcon,
131
- Ko as SelectOri,
132
- lo as SortIcon,
133
- Te as SubMenu,
134
- io as SuccessIcon,
135
- N as SunIcon,
136
- _o as Switch,
137
- ue as Tabbar,
138
- xe as TabbarItem,
139
- rt as Table,
140
- M as Tabs,
141
- Qe as Tag,
142
- ce as Theme,
143
- ie as ThemeColor,
144
- po as ThemeDefaultIcon,
145
- Co as WarnIcon,
146
- So as ZoomInIcon,
147
- Oo as ZoomOutIcon,
148
- c as addClickOutside,
149
- Ne as autoUpdate,
150
- _e as createPopoverObserver,
151
- $e as getOverflowAncestors,
152
- t as getPopoverOffsetX,
153
- r as getPopoverOffsetY,
154
- a as impactDetect,
155
- f as initAttr,
156
- s as kebabToCamel,
157
- l as parseAttrValue,
158
- ot as popconfirmProps,
159
- m as regist,
160
- I as removeClickOutside,
161
- p as setAttrs,
162
- u as tagAttr,
163
- d as tagAttrs,
164
- et as updatePosition,
165
- x as useId
77
+ v as ArrowDownIcon,
78
+ O as ArrowLeftIcon,
79
+ F as ArrowRightIcon,
80
+ U as ArrowUpIcon,
81
+ c as BaseComponent,
82
+ D as BaseIcon,
83
+ jo as Button,
84
+ Q as CaretBottomIcon,
85
+ y as CaretTopIcon,
86
+ we as Carousel,
87
+ Te as CarouselItem,
88
+ Ho as Checkbox,
89
+ Vo as CheckboxGroup,
90
+ go as CloseFilledIcon,
91
+ mo as CloseIcon,
92
+ He as Collapse,
93
+ Ve as CollapseItem,
94
+ fe as ColorPicker,
95
+ Ao as DArrowLeftIcon,
96
+ wo as DArrowRightIcon,
97
+ Ie as DatePicker,
98
+ Re as DescriptionPanel,
99
+ C as Dialog,
100
+ h as DialogContainer,
101
+ W as FontIcon,
102
+ Lo as Form,
103
+ Bo as FormItem,
104
+ je as Image,
105
+ ze as ImagePreview,
106
+ uo as InfoIcon,
107
+ zo as Input,
108
+ ee as List,
109
+ P as Loading,
110
+ q as LoadingIcon,
111
+ Be as Mask,
112
+ Yo as MdInput,
113
+ ge as Menu,
114
+ be as MenuItem,
115
+ i as Message,
116
+ M as Modal,
117
+ X as MoonIcon,
118
+ bo as MoreIcon,
119
+ Ge as PageHeader,
120
+ Le as Pagination,
121
+ te as Polygon,
122
+ Je as Popover,
123
+ ke as Qrcode,
124
+ Zo as Radio,
125
+ Go as RadioGroup,
126
+ _ as ReductionIcon,
127
+ oo as RefreshLeftIcon,
128
+ ro as RefreshRightIcon,
129
+ E as SearchIcon,
130
+ $o as Select,
131
+ Ro as SelectIcon,
132
+ Jo as SelectOri,
133
+ ao as SortIcon,
134
+ rr as Space,
135
+ Ae as SubMenu,
136
+ no as SuccessIcon,
137
+ K as SunIcon,
138
+ No as Switch,
139
+ le as Tabbar,
140
+ pe as TabbarItem,
141
+ or as Table,
142
+ S as Tabs,
143
+ Ze as Tag,
144
+ de as Theme,
145
+ ne as ThemeColor,
146
+ so as ThemeDefaultIcon,
147
+ Io as WarnIcon,
148
+ To as ZoomInIcon,
149
+ ko as ZoomOutIcon,
150
+ d as addClickOutside,
151
+ Ke as autoUpdate,
152
+ Ne as createPopoverObserver,
153
+ Xe as getOverflowAncestors,
154
+ r as initAttr,
155
+ t as kebabToCamel,
156
+ a as parseAttrValue,
157
+ Ye as popconfirmProps,
158
+ f as regist,
159
+ x as removeClickOutside,
160
+ s as setAttrs,
161
+ l as tagAttr,
162
+ m as tagAttrs,
163
+ _e as updatePosition,
164
+ p as useId
166
165
  };
@@ -29,7 +29,8 @@ export default class Input extends FormInner {
29
29
  /** 宽度铺满 */
30
30
  block: boolean;
31
31
  error: boolean;
32
- maxlength?: number;
32
+ maxlength?: string;
33
+ minlength?: string;
33
34
  inputmode: InputMode;
34
35
  $inner?: HTMLInputElement;
35
36
  set value(value: any);
@@ -1,9 +1,9 @@
1
- import { addClass as h, removeClass as u, $one as d, on as o, formatStyle as f, off as p, $ as c, $$ as a } from "ph-utils/dom";
2
- import { initAttr as g, parseAttrValue as n } from "../utils/index.js";
3
- import b from "../form/form_inner.js";
4
- import { add as m, remove as x } from "../utils/event.js";
5
- import { i as v } from "../index-D4II9KsF.js";
6
- class y extends b {
1
+ import { addClass as h, removeClass as u, $one as d, on as o, formatStyle as c, off as p, $ as f, $$ as n } from "ph-utils/dom";
2
+ import { initAttr as g, parseAttrValue as a } from "../utils/index.js";
3
+ import m from "../form/form_inner.js";
4
+ import { add as b, remove as x } from "../utils/event.js";
5
+ import { i as v } from "../index-DvcllHRh.js";
6
+ class I extends m {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
9
9
  type = "text";
@@ -19,6 +19,7 @@ class y extends b {
19
19
  block = !1;
20
20
  error = !1;
21
21
  maxlength;
22
+ minlength;
22
23
  inputmode = "text";
23
24
  $inner;
24
25
  #t = !1;
@@ -35,56 +36,63 @@ class y extends b {
35
36
  this.#t = t, t ? h(this, "l-input--clearable") : u(this, "l-input--clearable");
36
37
  }
37
38
  static get observedAttributes() {
38
- return ["disabled", "error", "clearable", "maxlength", "inputmode"];
39
+ return [
40
+ "disabled",
41
+ "value",
42
+ "name",
43
+ "error",
44
+ "clearable",
45
+ "maxlength",
46
+ "inputmode"
47
+ ];
39
48
  }
40
49
  connectedCallback() {
41
- g(this), this.loadStyleText([v]), super.connectedCallback(), this.$inner = d(".l-input__inner", this.root), o(this.$inner, "input", this._input), o(this.$inner, "change", this.#s), this.style.cssText = f(this._getStyleObj()) + this.getAttr("style", ""), this.error && h(this, "is-error"), this.getName() && this.formAttrs.id && m(this.formAttrs.id, "validateChange", this._validateChange);
50
+ g(this), this.loadStyleText([v]), super.connectedCallback(), this.$inner = d(".l-input__inner", this.root), o(this.$inner, "input", this._input), o(this.$inner, "change", this.#s), this.style.cssText = c(this._getStyleObj()) + this.getAttr("style", ""), this.error && h(this, "is-error"), this.getName() && this.formAttrs.id && b(this.formAttrs.id, "validateChange", this._validateChange);
42
51
  }
43
52
  disconnectedCallback() {
44
53
  super.disconnectedCallback(), this.formAttrs.id && x(this.formAttrs.id, "validateChange", this._validateChange), p(this.$inner, "input", this._input);
45
54
  }
46
55
  attributeChange(t, s, e) {
47
- const r = n(
56
+ const r = a(
48
57
  e,
49
58
  this[t],
50
59
  t
51
60
  );
52
61
  if (r !== this[t] && (this[t] = r), t === "error") {
53
- const i = n(e, !1, t);
62
+ const i = a(e, !1, t);
54
63
  i !== this.error && (this.error = i, this._updateError());
55
64
  } else if (t === "clearable") {
56
- const i = n(e, !1, t);
65
+ const i = a(e, !1, t);
57
66
  i !== this.clearable && (this.clearable = i);
58
67
  } else if (t === "maxlength") {
59
- const i = n(e, -1);
68
+ const i = a(e, this.maxlength);
60
69
  i !== this.maxlength && (this.maxlength = i);
61
70
  }
62
71
  }
63
72
  render() {
64
73
  const t = document.createDocumentFragment();
65
- if (c('[slot="prefix"]', this).length > 0) {
66
- const i = a("slot", {
74
+ if (f('[slot="prefix"]', this).length > 0) {
75
+ const i = n("slot", {
67
76
  name: "prefix"
68
- }), l = a("span", {
77
+ }), l = n("span", {
69
78
  class: "l-input__prefix",
70
79
  part: "prefix"
71
80
  });
72
81
  l.appendChild(i), t.appendChild(l);
73
82
  }
74
- const e = a("input", {
83
+ const e = n("input", {
75
84
  class: "l-input__inner",
76
85
  value: this.value,
77
- name: this.getName(),
78
- placeholder: this.placeholder,
79
- disabled: this.isDisabled(),
86
+ name: this.getName() || "",
87
+ placeholder: this.placeholder || "",
80
88
  part: "default",
81
89
  type: this.type,
82
90
  inputmode: this.inputmode
83
91
  });
84
- if (this.maxlength && this.maxlength >= 0 && e.setAttribute("maxlength", String(this.maxlength)), t.appendChild(e), c('[slot="suffix"]', this).length > 0) {
85
- const i = a("slot", {
92
+ if (this.isDisabled() && (e.disabled = !0), this.maxlength && e.setAttribute("maxlength", this.maxlength), this.minlength && e.setAttribute("minlength", this.minlength), t.appendChild(e), f('[slot="suffix"]', this).length > 0) {
93
+ const i = n("slot", {
86
94
  name: "suffix"
87
- }), l = a("span", {
95
+ }), l = n("span", {
88
96
  class: "l-input__suffix",
89
97
  part: "suffix"
90
98
  });
@@ -117,10 +125,10 @@ class y extends b {
117
125
  let t = d(".l-clearable", this.root);
118
126
  if (this.value.length > 0) {
119
127
  if (t == null) {
120
- t = a("span", {
128
+ t = n("span", {
121
129
  class: "l-input__suffix l-clearable"
122
130
  });
123
- const s = a("l-close-filled-icon");
131
+ const s = n("l-close-filled-icon");
124
132
  t.appendChild(s), this.root.appendChild(t), o(t, "click", this.#i);
125
133
  }
126
134
  } else
@@ -129,7 +137,10 @@ class y extends b {
129
137
  }
130
138
  #i = () => {
131
139
  this.value = "", this.dispatchEvent(
132
- new CustomEvent("input", { bubbles: !0, detail: { value: this.value } })
140
+ new CustomEvent("input", {
141
+ bubbles: !0,
142
+ detail: { value: this.value }
143
+ })
133
144
  ), this.#e();
134
145
  };
135
146
  disabledChange() {
@@ -177,5 +188,5 @@ class y extends b {
177
188
  };
178
189
  }
179
190
  export {
180
- y as default
191
+ I as default
181
192
  };
package/lib/mask/index.js CHANGED
@@ -37,12 +37,7 @@ class x extends a {
37
37
  this[t],
38
38
  t
39
39
  );
40
- if (o !== this[t])
41
- switch (this[t] = o, t) {
42
- case "zIndex":
43
- o === 100 ? this.style.removeProperty("--l-mask-zindex") : this.style.setProperty("--l-mask-zindex", o);
44
- break;
45
- }
40
+ o !== this[t] && (this[t] = o, t === "zIndex" && (o === 100 ? this.style.removeProperty("--l-mask-zindex") : this.style.setProperty("--l-mask-zindex", o)));
46
41
  }
47
42
  render() {
48
43
  const t = document.createDocumentFragment(), e = n("div", {
@@ -11,15 +11,14 @@ interface MessageOption {
11
11
  /** 自定义类名 */
12
12
  customClass?: string;
13
13
  }
14
- interface MessageInstance {
15
- (option: string | MessageOption): string;
16
- info: (msg: string | MessageOption) => string;
17
- warn: (msg: string | MessageOption) => string;
18
- success: (msg: string | MessageOption) => string;
19
- error: (msg: string | MessageOption) => string;
20
- show: (msg: string | MessageOption) => string;
21
- close: (id: string) => void;
22
- [index: string]: any;
23
- }
24
- declare const Message: MessageInstance;
25
- export default Message;
14
+ /** 关闭消息 */
15
+ declare function close(id: string): void;
16
+ declare const _default: {
17
+ info: (options: string | MessageOption) => string;
18
+ success: (options: string | MessageOption) => string;
19
+ error: (options: string | MessageOption) => string;
20
+ warn: (options: string | MessageOption) => string;
21
+ show: (options: string | MessageOption) => string;
22
+ close: typeof close;
23
+ };
24
+ export default _default;
@@ -1,67 +1,66 @@
1
- import { regist as y, useId as p } from "../utils/index.js";
2
- import { transition as d } from "ph-utils/dom";
3
- import h from "../icon/close_filled.js";
4
- import $ from "../icon/success.js";
5
- import v from "../icon/warn.js";
6
- import w from "../icon/info.js";
7
- const c = [], u = [
1
+ import { regist as g, useId as y } from "../utils/index.js";
2
+ import { transition as m } from "ph-utils/dom";
3
+ import p from "../icon/close_filled.js";
4
+ import h from "../icon/success.js";
5
+ import $ from "../icon/warn.js";
6
+ import x from "../icon/info.js";
7
+ const r = [], d = [
8
8
  ["opacity", "0", "0.3s"],
9
9
  ["transform", "translate3d(-50%, -100%, 0)", "0.3s"]
10
10
  ];
11
- let m = !0;
12
- function g(e) {
13
- const t = c.findIndex((o) => o.id === e);
11
+ let l = !0;
12
+ function u(e) {
13
+ const t = r.findIndex((o) => o.id === e);
14
14
  if (t === -1) return;
15
- const s = c.splice(t, 1)[0];
15
+ const s = r.splice(t, 1)[0];
16
16
  if (s == null) return;
17
- d(s, u, "leave", () => {
17
+ m(s, d, "leave", () => {
18
18
  s.remove();
19
19
  });
20
- const r = 15 + s.offsetHeight, n = c.length;
20
+ const i = 15 + s.offsetHeight, n = r.length;
21
21
  if (n !== 0)
22
22
  for (let o = t; o < n; o++) {
23
- const f = c[o], l = parseInt(f.style.top, 10) - r;
24
- f.style.setProperty("top", `${l}px`);
23
+ const a = r[o], f = parseInt(a.style.top, 10) - i;
24
+ a.style.setProperty("top", `${f}px`);
25
25
  }
26
26
  }
27
- function x(e) {
27
+ function v(e) {
28
28
  const t = document.createElement("div");
29
29
  t.id = e.id;
30
30
  const s = e.type || "info";
31
- let r = `l-message l-message-${s}`;
32
- e.customClass && (r += " " + e.customClass), t.className = r, t.style.setProperty("top", `${e.offset}px`), t.style.setProperty("z-index", `${e.zindex || 1e3}`), e.width && t.style.setProperty("width", e.width);
31
+ let i = `l-message l-message-${s}`;
32
+ e.customClass && (i += " " + e.customClass), t.className = i, t.style.setProperty("top", `${e.offset}px`), t.style.setProperty("z-index", `${e.zindex || 1e3}`), e.width && t.style.setProperty("width", e.width);
33
33
  let n = s;
34
- return n === "error" && (n = "mask-close"), t.innerHTML = [
34
+ return n === "error" && (n = "close-filled"), t.innerHTML = [
35
35
  '<div class="l-message-container">',
36
36
  `<l-${n}-icon class="l-message-icon"></l-${n}-icon>`,
37
37
  `<span class="l-message-content">${e.message}</span>`,
38
38
  "</div>"
39
39
  ].join(""), t;
40
40
  }
41
- const i = (e) => {
42
- m && (y([h, $, v, w]), m = !1);
43
- const t = c.reduce(
44
- (f, l) => f + l.offsetHeight + 15,
45
- 15
46
- ), s = p(), r = typeof e == "string" ? { message: e } : e;
47
- r.id = s, r.offset = t;
48
- const n = x(r);
49
- c.push(n), document.body.appendChild(n), d(n, u, "enter");
50
- let o = r.duration;
41
+ const w = ((e) => {
42
+ l && (g([p, h, $, x]), l = !1);
43
+ const t = r.reduce((a, f) => a + f.offsetHeight + 15, 15), s = y(), i = typeof e == "string" ? { message: e } : e;
44
+ i.id = s, i.offset = t;
45
+ const n = v(i);
46
+ r.push(n), document.body.appendChild(n), m(n, d, "enter");
47
+ let o = i.duration;
51
48
  return o == null && (o = 3e3), o !== 0 && setTimeout(() => {
52
- g(s);
49
+ u(s);
53
50
  }, o), s;
54
- };
55
- function a(e, t = "info") {
51
+ });
52
+ function c(e, t = "info") {
56
53
  const s = typeof e == "string" ? { message: e } : e;
57
- return s.type || (s.type = t), i(s);
54
+ return s.type || (s.type = t), w(s);
58
55
  }
59
- i.info = (e) => a(e, "info");
60
- i.success = (e) => a(e, "success");
61
- i.error = (e) => a(e, "error");
62
- i.warn = (e) => a(e, "warn");
63
- i.show = (e) => a(e);
64
- i.close = g;
56
+ const F = {
57
+ info: (e) => c(e, "info"),
58
+ success: (e) => c(e, "success"),
59
+ error: (e) => c(e, "error"),
60
+ warn: (e) => c(e, "warn"),
61
+ show: (e) => c(e),
62
+ close: u
63
+ };
65
64
  export {
66
- i as default
65
+ F as default
67
66
  };