litos-ui 0.17.4 → 0.18.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 (161) hide show
  1. package/README.md +49 -49
  2. package/lib/animation-CTt9qgA7.js +4 -0
  3. package/lib/base-Dm0WS1pK.js +62 -0
  4. package/lib/base.js +111 -147
  5. package/lib/button/index.d.ts +8 -3
  6. package/lib/button/index.js +2 -137
  7. package/lib/button-CC5PmAb1.js +146 -0
  8. package/lib/calendar/index.d.ts +15 -4
  9. package/lib/calendar/index.js +2 -95
  10. package/lib/calendar-DeP6yZB0.js +149 -0
  11. package/lib/carousel/index.js +2 -280
  12. package/lib/carousel/item.js +2 -15
  13. package/lib/carousel-D4Fe3LEx.js +272 -0
  14. package/lib/check/checkbox.js +2 -18
  15. package/lib/check/checkbox_group.js +6 -6
  16. package/lib/check/radio.js +2 -15
  17. package/lib/check/radio_group.js +9 -9
  18. package/lib/check-B0XraJvb.js +73 -0
  19. package/lib/check-CvGaONEx.js +117 -0
  20. package/lib/checkbox-DbWsmAaL.js +16 -0
  21. package/lib/collapse/index.d.ts +18 -11
  22. package/lib/collapse/index.js +2 -88
  23. package/lib/collapse/item.d.ts +28 -9
  24. package/lib/collapse/item.js +2 -115
  25. package/lib/collapse/types.d.ts +7 -0
  26. package/lib/collapse-CeKRZ-43.js +104 -0
  27. package/lib/color_picker/index.js +2 -42
  28. package/lib/color_picker-D0brKFm-.js +41 -0
  29. package/lib/date_picker/index.d.ts +23 -0
  30. package/lib/date_picker/index.js +3 -0
  31. package/lib/date_picker-DQGoiN8v.js +103 -0
  32. package/lib/date_picker_ori/index.js +2 -129
  33. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  34. package/lib/description_panel/index.js +2 -66
  35. package/lib/description_panel-Df_8rVbX.js +57 -0
  36. package/lib/dialog/dialog_container.js +2 -131
  37. package/lib/dialog/index.js +67 -85
  38. package/lib/dialog_container-DcN87wj0.js +126 -0
  39. package/lib/esm-sVEoAVPu.js +244 -0
  40. package/lib/form/form_item.d.ts +1 -0
  41. package/lib/form/form_item.js +2 -136
  42. package/lib/form/index.js +2 -147
  43. package/lib/form-DdU0yK0k.js +154 -0
  44. package/lib/form_inner-DR9tyB_r.js +117 -0
  45. package/lib/form_item-Bv-YafZK.js +137 -0
  46. package/lib/icon/arrow_down.js +12 -12
  47. package/lib/icon/arrow_left.js +9 -9
  48. package/lib/icon/arrow_right.js +9 -9
  49. package/lib/icon/arrow_up.js +12 -12
  50. package/lib/icon/base.d.ts +16 -2
  51. package/lib/icon/base.js +2 -38
  52. package/lib/icon/calendar.d.ts +5 -0
  53. package/lib/icon/calendar.js +10 -0
  54. package/lib/icon/caret_bottom.js +9 -9
  55. package/lib/icon/caret_top.js +9 -9
  56. package/lib/icon/close.js +9 -9
  57. package/lib/icon/close_filled.js +12 -12
  58. package/lib/icon/d_arrow_left.js +12 -12
  59. package/lib/icon/d_arrow_right.js +12 -12
  60. package/lib/icon/font_icon.d.ts +2 -3
  61. package/lib/icon/font_icon.js +35 -39
  62. package/lib/icon/info.js +12 -12
  63. package/lib/icon/loading.js +9 -9
  64. package/lib/icon/moon.js +12 -12
  65. package/lib/icon/more.js +12 -12
  66. package/lib/icon/reduction.js +12 -12
  67. package/lib/icon/refresh.d.ts +5 -0
  68. package/lib/icon/refresh.js +10 -0
  69. package/lib/icon/refresh_left.js +12 -12
  70. package/lib/icon/refresh_right.js +9 -9
  71. package/lib/icon/search.js +9 -9
  72. package/lib/icon/select.js +12 -12
  73. package/lib/icon/sort.js +9 -9
  74. package/lib/icon/success.js +12 -12
  75. package/lib/icon/sun.js +12 -12
  76. package/lib/icon/theme_default.js +12 -12
  77. package/lib/icon/warn.js +12 -12
  78. package/lib/icon/zoom_in.js +12 -12
  79. package/lib/icon/zoom_out.js +12 -12
  80. package/lib/image/image_preview.js +2 -104
  81. package/lib/image/index.js +2 -176
  82. package/lib/image-CeQVfS-v.js +162 -0
  83. package/lib/image_preview-PzZzwo6m.js +92 -0
  84. package/lib/index.d.ts +10 -4
  85. package/lib/index.js +80 -169
  86. package/lib/input/index.d.ts +6 -2
  87. package/lib/input/index.js +188 -203
  88. package/lib/input-DjKxcxry.js +4 -0
  89. package/lib/input_inner-BKJg9n9A.js +4 -0
  90. package/lib/item-Cuw_ZPyn.js +14 -0
  91. package/lib/item-DV842Aux.js +57 -0
  92. package/lib/item-ZXLWFzSm.js +119 -0
  93. package/lib/list/index.js +2 -58
  94. package/lib/list-CU7vHS6s.js +51 -0
  95. package/lib/loading/index.d.ts +4 -2
  96. package/lib/loading/index.js +109 -123
  97. package/lib/mask/index.js +2 -105
  98. package/lib/mask-BlV5QfTj.js +112 -0
  99. package/lib/md_input/index.js +2 -60
  100. package/lib/md_input-DSQx5TMW.js +58 -0
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/menu_item.js +2 -21
  103. package/lib/menu/sub_menu.js +2 -83
  104. package/lib/menu-DAtplYAH.js +91 -0
  105. package/lib/menu_item-BW1Tu11Q.js +20 -0
  106. package/lib/message/index.js +67 -60
  107. package/lib/modal/index.js +2 -196
  108. package/lib/modal/modal_box.js +87 -86
  109. package/lib/modal-DWyWrN-D.js +192 -0
  110. package/lib/page_header/index.js +2 -109
  111. package/lib/page_header-DdeRDN4U.js +101 -0
  112. package/lib/pagination/index.js +2 -248
  113. package/lib/pagination-BoPzSPjT.js +210 -0
  114. package/lib/polygon/index.js +2 -27
  115. package/lib/polygon-C4Ow2lxi.js +20 -0
  116. package/lib/qrcode/index.d.ts +13 -4
  117. package/lib/qrcode/index.js +2 -57
  118. package/lib/qrcode-BFxsD_OP.js +64 -0
  119. package/lib/radio-2mNSYujz.js +13 -0
  120. package/lib/select/index.js +3 -401
  121. package/lib/select-CAgggYh7.js +326 -0
  122. package/lib/select_ori/index.js +47 -50
  123. package/lib/space/index.js +2 -35
  124. package/lib/space-CpTmBfHP.js +38 -0
  125. package/lib/sub_menu-D1s8ABNu.js +75 -0
  126. package/lib/switch/index.js +2 -50
  127. package/lib/switch-BaVBi5Ip.js +48 -0
  128. package/lib/tabbar/index.js +2 -109
  129. package/lib/tabbar/item.js +2 -58
  130. package/lib/tabbar-4_d2Fj1n.js +91 -0
  131. package/lib/table/index.js +2 -269
  132. package/lib/table-Hifj8jAX.js +234 -0
  133. package/lib/tabs/index.js +38 -42
  134. package/lib/tag/index.js +2 -72
  135. package/lib/tag-DPENZf_V.js +76 -0
  136. package/lib/theme/index.js +2 -89
  137. package/lib/theme/theme_color.js +22 -26
  138. package/lib/theme-BRTI2-Yk.js +83 -0
  139. package/lib/utils/clickoutside.js +18 -18
  140. package/lib/utils/context_provide.js +21 -21
  141. package/lib/utils/event.js +13 -18
  142. package/lib/utils/index.js +55 -58
  143. package/lib/utils/popover.d.ts +4 -1
  144. package/lib/utils/popover.js +276 -352
  145. package/lib/utils/transition.js +33 -31
  146. package/package.json +10 -11
  147. package/styles/container.css +4 -0
  148. package/styles/datepicker.css +55 -0
  149. package/styles/popover.css +14 -1
  150. package/lib/animation-DttknHkX.js +0 -4
  151. package/lib/calendar/langs.js +0 -8
  152. package/lib/carousel/timer.js +0 -19
  153. package/lib/check/check.js +0 -118
  154. package/lib/check/index.js +0 -68
  155. package/lib/check-CksURvTv.js +0 -4
  156. package/lib/form/form_inner.js +0 -125
  157. package/lib/form/types.js +0 -1
  158. package/lib/index-CrMiSe0x.js +0 -249
  159. package/lib/index-DY6m9Wbe.js +0 -4
  160. package/lib/litos-ui.css +0 -1
  161. package/lib/table/types.js +0 -1
@@ -0,0 +1,73 @@
1
+ import { unitNumberStr as e } from "./utils/index.js";
2
+ import { n as t } from "./esm-sVEoAVPu.js";
3
+ import { t as n } from "./form_inner-DR9tyB_r.js";
4
+ import { $$ as r, off as i, on as a } from "ph-utils/dom";
5
+ //#region src/components/check/index.less?inline
6
+ var o = ":host{align-items:center;gap:var(--l-check-gap,0px);display:flex}", s = class extends n {
7
+ values;
8
+ multiple;
9
+ _state;
10
+ setValue(e) {
11
+ super.setValue(e), this.rendered && this.updateChecked();
12
+ }
13
+ constructor() {
14
+ super(!1), this.multiple = !0, this.values = t([]), this._state = {};
15
+ }
16
+ static get observedAttributes() {
17
+ return [
18
+ "disabled",
19
+ "value",
20
+ "name",
21
+ "inner-block",
22
+ "gap"
23
+ ];
24
+ }
25
+ attributeChange(t, n, r) {
26
+ switch (t) {
27
+ case "gap":
28
+ this._state.gap = e(r);
29
+ break;
30
+ }
31
+ }
32
+ updateDOM(e) {
33
+ e.has("gap") && this._updateGap();
34
+ }
35
+ connectedCallback() {
36
+ this.loadStyleText([o]), this.updateChecked(), super.connectedCallback(), this._updateGap();
37
+ }
38
+ afterInit() {
39
+ a(this.root, "change", this.#e), a(this, "check-context-request", this._privide);
40
+ }
41
+ beforeDestroy() {
42
+ i(this.root, "change", this.#e), i(this, "check-context-request", this._privide), this.values([]);
43
+ }
44
+ render() {
45
+ return r("slot");
46
+ }
47
+ _privide = (e) => {
48
+ let { context: t, callback: n } = e.detail;
49
+ t === "check-context-request" && n(this.values);
50
+ };
51
+ _updateGap = () => {
52
+ this._state.gap ? this.style.setProperty("--l-check-gap", this._state.gap) : this.style.removeProperty("--l-check-gap");
53
+ };
54
+ #e = (e) => {
55
+ e.stopPropagation();
56
+ let t = e.detail.value, n = this.values(), r = n.indexOf(t);
57
+ this.multiple ? (r === -1 ? n.push(t) : n.splice(r, 1), this.setAttribute("value", n.join("&"))) : r === -1 && this.setAttribute("value", t), this.emit("change", {
58
+ detail: { value: this.multiple ? n : t },
59
+ composed: !0
60
+ });
61
+ };
62
+ updateChecked() {
63
+ let e = [];
64
+ if (this.value) if (this.multiple) {
65
+ let t = this.value.split("&");
66
+ e.push(...t.map((e) => decodeURIComponent(e)));
67
+ } else e = [this.value];
68
+ else e = [];
69
+ this.values(e);
70
+ }
71
+ };
72
+ //#endregion
73
+ export { s as t };
@@ -0,0 +1,117 @@
1
+ import { parseAttrValue as e, stopSignal as t } from "./utils/index.js";
2
+ import { t as n } from "./esm-sVEoAVPu.js";
3
+ import { t as r } from "./form_inner-DR9tyB_r.js";
4
+ import { $$ as i, addClass as a, off as o, on as s, removeClass as c, toggleClass as l } from "ph-utils/dom";
5
+ //#region src/components/check/check.ts
6
+ var u = class extends r {
7
+ _checked;
8
+ _inputType;
9
+ $input;
10
+ _groupCtx;
11
+ _groupCtxStop;
12
+ setChecked(e) {
13
+ this._checked = e, this.checkedChange();
14
+ }
15
+ getChecked() {
16
+ return this._checked;
17
+ }
18
+ constructor() {
19
+ super(), this._checked = !1, this._inputType = "radio", Object.defineProperty(this, "checked", {
20
+ configurable: !0,
21
+ enumerable: !0,
22
+ get: this.getChecked,
23
+ set: this.setChecked
24
+ });
25
+ }
26
+ static get observedAttributes() {
27
+ return [
28
+ "checked",
29
+ "label",
30
+ "button",
31
+ "indeterminate",
32
+ ...r.observedAttributes
33
+ ];
34
+ }
35
+ connectedCallback() {
36
+ super.connectedCallback(), this.getChecked() && this.setChecked(!0), this.isDisabled() && a(this, "is-disabled"), this._updateIndeterminate(), this.emitInject("check-context-request", (e) => {
37
+ this._groupCtx = e;
38
+ }), this._groupCtxStop = n(() => {
39
+ if (this.value == null) return;
40
+ let e = this._groupCtx ? this._groupCtx() : [];
41
+ this.setChecked(e.includes(this.value));
42
+ });
43
+ }
44
+ afterInit() {
45
+ s(this, "click", this.#e);
46
+ }
47
+ beforeDestroy() {
48
+ o(this, "click", this.#e), this._groupCtxStop = t(this._groupCtxStop);
49
+ }
50
+ render() {
51
+ let e = document.createDocumentFragment(), t = i("input", {
52
+ type: this._inputType,
53
+ class: "l-check__input",
54
+ name: this.getName(),
55
+ value: this.value,
56
+ checked: this.getChecked(),
57
+ disabled: this.isDisabled() ? "disabled" : void 0
58
+ });
59
+ if (this.$input = t, e.appendChild(t), !this._state.button) {
60
+ let t = i("span", { class: "l-check__inner" });
61
+ e.appendChild(t);
62
+ }
63
+ let n = i("label", {
64
+ class: "l-check__label",
65
+ part: "label"
66
+ }), r = i("slot", { textContent: this._state.label });
67
+ return n.appendChild(r), e.appendChild(n), e;
68
+ }
69
+ attributeChange(t, n, r) {
70
+ switch (t) {
71
+ case "checked":
72
+ let n = e(r, !1, "checked");
73
+ this.setChecked(n);
74
+ break;
75
+ case "button":
76
+ this._state[t] = e(r, !1, t);
77
+ break;
78
+ case "indeterminate":
79
+ let i = e(r, !1, t);
80
+ this._state.indeterminate = i, this._updateIndeterminate();
81
+ break;
82
+ case "label":
83
+ this._state.label = r;
84
+ break;
85
+ }
86
+ }
87
+ checkedChange() {
88
+ this.getChecked() ? a(this, "is-checked") : c(this, "is-checked"), this.$input && (this.$input.checked = this.getChecked());
89
+ }
90
+ disabledChange() {
91
+ l(this, "is-disabled"), this.$input && (this.$input.disabled = this.isDisabled());
92
+ }
93
+ _updateIndeterminate() {
94
+ this._state.indeterminate ? a(this, "is-indeterminate") : c(this, "is-indeterminate");
95
+ }
96
+ #e = () => {
97
+ if (!this.isDisabled()) if (this.value && this._groupCtx) this.emitChange();
98
+ else {
99
+ let e = this._inputType === "radio" ? !0 : !this.getChecked();
100
+ this.setChecked(e), this.emitChange();
101
+ }
102
+ };
103
+ emitChange() {
104
+ this.emit("change", {
105
+ detail: {
106
+ value: this.value,
107
+ name: this.getName(),
108
+ checked: this.getChecked()
109
+ },
110
+ composed: !0,
111
+ bubbles: !0
112
+ });
113
+ }
114
+ _doChangeAction() {}
115
+ }, d = ":host{--l-check-size:14px;cursor:pointer;outline:none;align-items:center;width:auto;transition:color .3s,border-color .3s,background-color .3s;display:inline-flex;position:relative}.l-check__input{z-index:-1;opacity:0;width:0;height:0;margin:0;position:absolute}.l-check__inner{width:var(--l-check-size,14px);height:var(--l-check-size,14px);box-sizing:border-box;border:1px solid #dcddd9;border-radius:3px;flex-shrink:0;justify-content:center;align-items:center;margin-right:5px;transition:border-color .3s ease-in-out;display:flex;position:relative}.l-check__label{cursor:inherit;line-height:1;transition:color .3s}:host(.is-checked){color:var(--l-primary-color,#722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color,#722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color,#e6e6e6)}:host([button]){height:var(--l-form-control-height,32px);border-radius:inherit;border:1px solid #c0c4cc;border-left-width:0;justify-content:center;margin-left:0;padding:0 15px}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color,#722ed1);color:#fff;border-color:var(--l-primary-color,#722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color,#722ed1)}";
116
+ //#endregion
117
+ export { u as n, d as t };
@@ -0,0 +1,16 @@
1
+ import { n as e, t } from "./check-CvGaONEx.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 };
@@ -1,19 +1,26 @@
1
1
  import BaseComponent from "../base";
2
- export default class Collapase extends BaseComponent {
3
- #private;
4
- static baseName: string;
5
- arrowPlacement?: "left" | "right";
6
- headerJustify?: "flex-start" | "flex-end" | "space-between";
7
- /** 是否带有背景边框 */
8
- background?: boolean;
9
- gap?: string;
2
+ type CollapseState = {
10
3
  borderRadius?: string;
11
4
  grid?: boolean;
12
5
  accordion?: boolean;
13
- connectedCallback(): void;
6
+ prop?: string;
7
+ };
8
+ export default class Collapase extends BaseComponent<CollapseState> {
9
+ static baseName: string;
10
+ private context;
11
+ private expands;
12
+ constructor();
14
13
  static get observedAttributes(): string[];
15
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
16
- render(): HTMLElement;
14
+ attributeChanged(name: string, oldValue: string, newValue: string): void;
15
+ protected updateDOM(changedProps: Set<string>): void;
16
+ render_v2(): {
17
+ template: HTMLElement;
18
+ style: string;
19
+ };
20
+ _setStyleAndClass(): void;
17
21
  afterInit(): void;
22
+ private _provide;
18
23
  beforeDestroy(): void;
24
+ _onChange: (e: CustomEvent) => void;
19
25
  }
26
+ export {};
@@ -1,88 +1,2 @@
1
- import o from "../base.js";
2
- import { kebabToCamel as d, parseAttrValue as r } from "../utils/index.js";
3
- import { $$ as n, on as c, iterate as i, off as p } from "ph-utils/dom";
4
- const h = ":host{--l-collapse-border-color: var(--l-border-color, #dedede);--l-collapse-border-radius: 0px;display:grid;grid-template-columns:1fr;gap:var(--l-collapse-gap, 0px);box-sizing:border-box}:host(.l-collapse-grid){grid-template-columns:repeat(auto-fill,minmax(200px,1fr));align-items:start}";
5
- class x extends o {
6
- static baseName = "collapse";
7
- arrowPlacement = "left";
8
- headerJustify = "flex-start";
9
- /** 是否带有背景边框 */
10
- background = !1;
11
- gap;
12
- borderRadius;
13
- grid = !1;
14
- accordion = !1;
15
- #e = /* @__PURE__ */ new Set();
16
- connectedCallback() {
17
- this.loadStyleText(h), this.#s(), super.connectedCallback();
18
- }
19
- static get observedAttributes() {
20
- return [
21
- "arrow-placement",
22
- "header-justify",
23
- "background",
24
- "gap",
25
- "border-radius",
26
- "grid",
27
- "accordion",
28
- "name"
29
- ];
30
- }
31
- attributeChangedCallback(t, s, a) {
32
- t = d(t);
33
- const e = r(
34
- a,
35
- this[t],
36
- t
37
- );
38
- t === "name" ? e && (this.#e.clear(), e.split("&").forEach((l) => {
39
- this.#e.add(decodeURIComponent(l));
40
- })) : e !== this[t] && (this[t] = e);
41
- }
42
- render() {
43
- return n("slot");
44
- }
45
- #s() {
46
- this.gap && this.gap !== "0px" && this.style.setProperty("--l-collapse-gap", this.gap), this.borderRadius && this.borderRadius !== "0px" && this.style.setProperty("--l-collapse-border-radius", this.borderRadius), this.grid && this.classList.add("l-collapse-grid");
47
- }
48
- afterInit() {
49
- c(this, "expand-change", this.#t);
50
- const t = this.children;
51
- if (i(t, (s) => {
52
- const a = s.getAttribute("name");
53
- if (a)
54
- if (this.#e.size > 0)
55
- this.#e.has(a) && s.setAttribute("expand", "on");
56
- else {
57
- let e = s.getAttribute("expand");
58
- e != null && (e = r(e, !1, "expand"), e && this.#e.add(a));
59
- }
60
- }), this.#e.size > 0) {
61
- const s = this.children;
62
- i(s, (a) => {
63
- const e = a.getAttribute("name");
64
- e && this.#e.has(e) && a.setAttribute("expand", "on");
65
- });
66
- }
67
- }
68
- beforeDestroy() {
69
- p(this, "expand-change", this.#t);
70
- }
71
- #t = (t) => {
72
- const s = t.detail;
73
- if (s.expand) {
74
- if (this.accordion) {
75
- const a = this.children;
76
- i(a, (e) => {
77
- e.name !== s.name && (e.expand = !1);
78
- }), this.#e.clear();
79
- }
80
- this.#e.add(s.name);
81
- } else
82
- this.#e.delete(s.name);
83
- this.emit("change", { detail: { expandedNames: [...this.#e] } });
84
- };
85
- }
86
- export {
87
- x as default
88
- };
1
+ import { t as e } from "../collapse-CeKRZ-43.js";
2
+ export { e as default };
@@ -1,15 +1,34 @@
1
1
  import BaseComponent from "../base";
2
- export default class CollapaseItem extends BaseComponent {
3
- #private;
2
+ import type { CollapseContext } from "./types";
3
+ type CollapaseItemState = {
4
+ prop: string;
5
+ headerText: string;
6
+ expand: boolean;
7
+ };
8
+ export default class CollapaseItem extends BaseComponent<CollapaseItemState> {
4
9
  static baseName: string;
5
- name: string;
6
- headerText?: string;
7
- connectedCallback(): void;
8
- get expand(): boolean;
9
- set expand(value: boolean);
10
+ private $header?;
11
+ context?: CollapseContext;
12
+ private _ctxStop?;
13
+ private _expandStop?;
14
+ expands?: Signal<string[]>;
15
+ constructor();
16
+ protected updateDOM(changedProps: Set<string>): void;
17
+ _setStyleAndClass(): void;
10
18
  static get observedAttributes(): string[];
11
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
12
- render(): DocumentFragment;
19
+ protected attributeChanged(name: string, oldValue: string, newValue: string): void;
20
+ render_v2(): {
21
+ template: DocumentFragment;
22
+ style: string;
23
+ };
13
24
  afterInit(): void;
14
25
  beforeDestroy(): void;
26
+ _handleExpandsChange: () => void;
27
+ _handleHeaderTap: () => void;
28
+ _updateLayout: () => void;
29
+ contextInject: (ctx: CollapseContext, exds: Signal<string[]>) => void;
30
+ _handleExpand(): void;
31
+ _emitChange: () => void;
32
+ _createContentElement(hide?: boolean): HTMLElement;
15
33
  }
34
+ export {};
@@ -1,115 +1,2 @@
1
- import l from "../base.js";
2
- import { kebabToCamel as i, parseAttrValue as n } from "../utils/index.js";
3
- import { $$ as o, $one as r, on as d, off as c, queryHideNodeSize as p } from "ph-utils/dom";
4
- const h = ":host{display:block;box-sizing:border-box;border-bottom:1px solid var(--l-collapse-border-color);color:#333;font-size:14px}.l-collapse-item__header{padding:10px 0;cursor:pointer;display:flex;align-items:center;justify-content:flex-start;gap:5px}.l-collapse-item__header.arrow-right{flex-direction:row-reverse;justify-content:flex-end}.l-collapse-item__header.space-between{justify-content:space-between}.l-collapse-arrow-icon{transform:rotate3d(0,0,1,0);transition:transform .3s}.l-collapse-content{box-sizing:border-box;transition:height .3s;overflow-y:hidden}.l-collapse-content-box{padding-bottom:15px}:host(.l-collapse-expand) .l-collapse-arrow-icon{transform:rotate3d(0,0,1,90deg)}:host(.background){border-left:1px solid var(--l-collapse-border-color);border-right:1px solid var(--l-collapse-border-color);background-color:#00000005}:host(.background:first-child),:host(.background.space){border-top:1px solid var(--l-collapse-border-color)}:host(.background) .l-collapse-item__header{padding:10px 15px}:host(.background) .l-collapse-content{border-top:1px solid var(--l-collapse-border-color);background:#fff}:host(.background) .l-collapse-content-box{padding:15px}:host(:first-child){border-top-left-radius:var(--l-collapse-border-radius, 0px);border-top-right-radius:var(--l-collapse-border-radius, 0px)}:host(:last-child){border-bottom-left-radius:var(--l-collapse-border-radius, 0px);border-bottom-right-radius:var(--l-collapse-border-radius, 0px)}:host(.space){border-radius:var(--l-collapse-border-radius, 0px)}";
5
- class u extends l {
6
- static baseName = "collapse-item";
7
- name = "";
8
- headerText = "";
9
- #e = !1;
10
- connectedCallback() {
11
- this.loadStyleText(h), this.#s(), super.connectedCallback();
12
- }
13
- #s() {
14
- this.expand ? this.classList.add("l-collapse-expand") : this.classList.remove("l-collapse-expand");
15
- }
16
- get expand() {
17
- return this.#e;
18
- }
19
- set expand(e) {
20
- this.#e = e, this.#r();
21
- }
22
- static get observedAttributes() {
23
- return ["name", "header-text", "expand"];
24
- }
25
- attributeChangedCallback(e, t, a) {
26
- e = i(e);
27
- const s = n(
28
- a,
29
- this[e],
30
- e
31
- );
32
- s !== this[e] && (this[e] = s);
33
- }
34
- render() {
35
- const e = document.createDocumentFragment(), t = o("div", {
36
- class: "l-collapse-item__header",
37
- part: "header"
38
- }), a = o("l-arrow-right-icon", { class: "l-collapse-arrow-icon" });
39
- if (t.appendChild(a), this.headerText) {
40
- const s = o("span", {
41
- part: "header-text",
42
- textContent: `${this.headerText}`
43
- });
44
- t.appendChild(s);
45
- } else
46
- t.appendChild(
47
- o("slot", {
48
- name: "header-text"
49
- })
50
- );
51
- return e.appendChild(t), this.expand && e.appendChild(this.#a(!1)), e;
52
- }
53
- afterInit() {
54
- const e = this.parentElement;
55
- e && e.tagName.endsWith("COLLAPASE") && this.#o({
56
- arrowPlacement: e.arrowPlacement,
57
- headerJustify: e.headerJustify,
58
- background: e.background,
59
- gap: e.gap
60
- });
61
- const t = r(".l-collapse-item__header", this.root);
62
- t && d(t, "click", this.#t);
63
- }
64
- beforeDestroy() {
65
- const e = r(".l-collapse-item__header", this.root);
66
- e && c(e, "click", this.#t);
67
- }
68
- #t = () => {
69
- this.expand = !this.expand;
70
- };
71
- #o(e) {
72
- let t = r(".l-collapse-item__header", this.root);
73
- t && (e.arrowPlacement === "right" ? t.classList.add("arrow-right") : t.classList.remove("arrow-right"), e.headerJustify === "space-between" ? t.classList.add("space-between") : t.classList.remove("space-between")), e.background ? this.classList.add("background") : this.classList.remove("background"), e.gap && e.gap !== "0px" ? this.classList.add("space") : this.classList.remove("space");
74
- }
75
- #r() {
76
- if (!this.rendered) return;
77
- let e = r(".l-collapse-content", this.root), t = 0;
78
- if (this.#e) {
79
- this.classList.add("l-collapse-expand"), e || (e = this.#a(!0), this.root.appendChild(e));
80
- const a = p(e, null);
81
- e.style.height = `${a.height}px`, e.style.display = "block", t = a.height;
82
- } else
83
- this.classList.remove("l-collapse-expand"), e && (t = e.getBoundingClientRect().height);
84
- if (e) {
85
- const a = [{ height: "0px" }, { height: `${t}px` }];
86
- this.#e || a.reverse();
87
- let s = e.animate(a, {
88
- duration: 150
89
- });
90
- this.#e || (s.onfinish = () => {
91
- e.style.display = "none", s.onfinish = null, s = null;
92
- });
93
- }
94
- this.emit("expand-change", {
95
- detail: { name: this.name, expand: this.expand }
96
- });
97
- }
98
- #a(e = !0) {
99
- const t = o("div", {
100
- class: "l-collapse-content",
101
- style: e ? "display: none;" : ""
102
- });
103
- return o(
104
- "div",
105
- {
106
- class: "l-collapse-content-box",
107
- innerHTML: "<slot></slot>"
108
- },
109
- t
110
- ), t;
111
- }
112
- }
113
- export {
114
- u as default
115
- };
1
+ import { t as e } from "../item-ZXLWFzSm.js";
2
+ export { e as default };
@@ -0,0 +1,7 @@
1
+ export type CollapseContext = Signal<{
2
+ arrowPlacement: "left" | "right";
3
+ headerJustify: "flex-start" | "flex-end" | "space-between";
4
+ /** 是否带有背景边框 */
5
+ background: boolean;
6
+ gap?: string;
7
+ }>;
@@ -0,0 +1,104 @@
1
+ import e from "./base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "./utils/index.js";
3
+ import { n as i } from "./esm-sVEoAVPu.js";
4
+ import { $$ as a, off as o, on as s } from "ph-utils/dom";
5
+ //#region src/components/collapse/index.less?inline
6
+ var c = ":host{--l-collapse-border-color:var(--l-border-color,#dedede);--l-collapse-border-radius:0px;gap:var(--l-collapse-gap,0px);box-sizing:border-box;grid-template-columns:1fr;display:grid}:host(.l-collapse-grid){grid-template-columns:repeat(auto-fill,minmax(200px,1fr));align-items:start}", l = class extends e {
7
+ static baseName = "collapse";
8
+ context;
9
+ expands;
10
+ constructor() {
11
+ super(), this.version = 2, this.context = i({
12
+ arrowPlacement: "left",
13
+ headerJustify: "flex-start",
14
+ background: !1
15
+ }), this.expands = i([]), this._state = {
16
+ grid: !1,
17
+ accordion: !1
18
+ };
19
+ }
20
+ static get observedAttributes() {
21
+ return [
22
+ "arrow-placement",
23
+ "header-justify",
24
+ "background",
25
+ "gap",
26
+ "border-radius",
27
+ "grid",
28
+ "accordion",
29
+ "prop"
30
+ ];
31
+ }
32
+ attributeChanged(e, i, a) {
33
+ switch (e) {
34
+ case "arrow-placement":
35
+ case "header-justify":
36
+ let i = { ...this.context() };
37
+ i[t(e)] = a, this.context(i);
38
+ break;
39
+ case "gap":
40
+ this.context({
41
+ ...this.context(),
42
+ gap: r(a)
43
+ });
44
+ break;
45
+ case "border-radius":
46
+ this._state.borderRadius = r(a);
47
+ break;
48
+ case "background":
49
+ this.context({
50
+ ...this.context(),
51
+ background: n(a, !1, e)
52
+ });
53
+ break;
54
+ case "accordion":
55
+ case "grid":
56
+ this._state[e] = n(a, !1, e);
57
+ break;
58
+ case "prop":
59
+ if (a !== this._state.prop) {
60
+ this._state.prop = a;
61
+ let e = [], t = a.split("&");
62
+ for (let n = 0, r = t.length; n < r; n++) e.push(t[n]);
63
+ this.expands(e);
64
+ }
65
+ break;
66
+ }
67
+ }
68
+ updateDOM(e) {
69
+ (e.has("gap") || e.has("borderRadius") || e.has("grid")) && this._setStyleAndClass();
70
+ }
71
+ render_v2() {
72
+ return {
73
+ template: a("slot"),
74
+ style: c
75
+ };
76
+ }
77
+ _setStyleAndClass() {
78
+ this.context().gap ? this.style.setProperty("--l-collapse-gap", this.context().gap) : this.style.removeProperty("--l-collapse-gap"), this._state.borderRadius ? this.style.setProperty("--l-collapse-border-radius", this._state.borderRadius) : this.style.removeProperty("--l-collapse-border-radius"), this._state.grid ? this.classList.add("l-collapse-grid") : this.classList.remove("l-collapse-grid");
79
+ }
80
+ afterInit() {
81
+ this._setStyleAndClass(), s(this, "collapse-context-request", this._provide), s(this, "expand-change", this._onChange);
82
+ }
83
+ _provide(e) {
84
+ let { context: t, callback: n } = e.detail;
85
+ t === "collapse-context-request" && n(this.context, this.expands);
86
+ }
87
+ beforeDestroy() {
88
+ o(this, "collapse-context-request", this._provide), o(this, "expand-change", this._onChange);
89
+ }
90
+ _onChange = (e) => {
91
+ let t = e.detail, n = this.expands();
92
+ if (t.expand) this._state.accordion ? n = [t.prop] : n.includes(t.prop) || n.push(t.prop);
93
+ else {
94
+ let e = n.indexOf(t.prop);
95
+ e !== -1 && n.splice(e, 1);
96
+ }
97
+ this.expands([...n]), this._state.prop = n.join("&"), this.emit("change", { detail: {
98
+ expands: n,
99
+ value: this._state.prop
100
+ } });
101
+ };
102
+ };
103
+ //#endregion
104
+ export { l as t };
@@ -1,42 +1,2 @@
1
- import { $one as i, on as s, off as a } from "ph-utils/dom";
2
- import r from "../form/form_inner.js";
3
- import { initAttr as c, setAttrs as n } from "../utils/index.js";
4
- import { i as l } from "../index-DY6m9Wbe.js";
5
- const o = ":host{--l-input-width: 60px}";
6
- class m extends r {
7
- static baseName = "color-picker";
8
- $picker;
9
- _value = "#000000";
10
- constructor() {
11
- super(), c(this);
12
- }
13
- setValue(e) {
14
- super.setValue(e), this.$picker && (this.$picker.value = e);
15
- }
16
- connectedCallback() {
17
- this.loadStyleText([l, o]), super.connectedCallback(), this.$picker = i("input", this.root), s(this.$picker, "change", this._handleChange);
18
- }
19
- disconnectedCallback() {
20
- super.disconnectedCallback(), this.$picker && (a(this.$picker, "change", this._handleChange), this.$picker = void 0);
21
- }
22
- render() {
23
- const e = document.createElement("input");
24
- return n(e, [
25
- ["value", this.value],
26
- ["disabled", this.isDisabled()],
27
- ["name", this.getName()],
28
- ["type", "color"],
29
- ["class", "l-input l-color-picker"]
30
- ]), e;
31
- }
32
- disabledChange() {
33
- this.$picker && (this.$picker.disabled = this.isDisabled());
34
- }
35
- _handleChange = (e) => {
36
- const t = e.target.value;
37
- super.setValue(t), this.dispatchEvent(new CustomEvent("change", { detail: t }));
38
- };
39
- }
40
- export {
41
- m as default
42
- };
1
+ import { t as e } from "../color_picker-D0brKFm-.js";
2
+ export { e as default };