litos-ui 0.17.2 → 0.17.4

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.
@@ -1,9 +1,15 @@
1
1
  import BaseComponent from "../base";
2
- export default class ThemeColor extends BaseComponent {
2
+ type ThemeColorState = {
3
+ color: string;
4
+ };
5
+ export default class ThemeColor extends BaseComponent<ThemeColorState> {
3
6
  #private;
4
7
  static baseName: string;
5
- color: string;
6
8
  constructor();
7
- connectedCallback(): void;
8
- render(): string | void | HTMLElement | HTMLElement[];
9
+ render_v2(): {
10
+ template?: string | HTMLElement | DocumentFragment;
11
+ style?: string | string[];
12
+ };
13
+ afterInit(): void;
9
14
  }
15
+ export {};
@@ -1,28 +1,25 @@
1
1
  import { $one as t, on as r } from "ph-utils/dom";
2
- import c from "../base.js";
3
- import { getColorTheme as n, applyColorTheme as l } from "ph-utils/theme";
4
- class m extends c {
2
+ import s from "../base.js";
3
+ import { getColorTheme as a, applyColorTheme as c } from "ph-utils/theme";
4
+ class m extends s {
5
5
  static baseName = "theme-color";
6
- color;
7
6
  constructor() {
8
- super(), this.color = n() || "#722ed1";
7
+ super(), this.version = 2, this._state = {
8
+ color: a() || "#722ed1"
9
+ };
9
10
  }
10
- connectedCallback() {
11
- super.connectedCallback(), this.#e();
11
+ render_v2() {
12
+ return {
13
+ template: `<l-color-picker value="${this._state.color}"></l-color-picker>`
14
+ };
12
15
  }
13
- render() {
14
- const e = document.createElement(
15
- "l-color-picker"
16
- );
17
- return e.value = this.color, e;
18
- }
19
- #e() {
16
+ afterInit() {
20
17
  const e = t("l-color-picker", this.root);
21
- e && r(e, "change", this.#o);
18
+ e && r(e, "change", this.#e);
22
19
  }
23
- #o = async (e) => {
20
+ #e = async (e) => {
24
21
  const o = e.detail;
25
- this.color = o, await l(o), this.dispatchEvent(new CustomEvent("change", { detail: o }));
22
+ this._state.color = o, await c(o), this.dispatchEvent(new CustomEvent("change", { detail: o }));
26
23
  };
27
24
  }
28
25
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litos-ui",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "基于 Web Component 的 UI 组件库",
5
5
  "keywords": [
6
6
  "component library",
@@ -1,99 +0,0 @@
1
- import { initAttr as l } from "../utils/index.js";
2
- import n from "../form/form_inner.js";
3
- import { iterate as o, formatStyle as d, $ as c, on as a, off as r, $$ as h } from "ph-utils/dom";
4
- import { parse as m } from "ph-utils/date";
5
- const u = ":host{display:inline-flex;align-items:center;width:var(--l-date-picker-width, auto)}.l-date-inner{height:var(--l-form-control-height, 32px);border-radius:3px;outline:none;border:1px solid var(--l-border-color, #dedede);cursor:text;padding:0 5px;flex-grow:1;transition:border-color .3s}.l-date-inner:hover{border-color:var(--l-primary-color-light1, #9254de)}.l-date-inner:focus{border-color:var(--l-primary-color, #722ed1)}.l-date-range-divider{margin:0 10px}";
6
- class y extends n {
7
- static baseName = "date-picker";
8
- /** 是否显示日期范围选择 */
9
- range = !1;
10
- /** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
11
- emitTimeout = 300;
12
- /** 原生 type 属性 */
13
- type = "date";
14
- width;
15
- /** 日期范围 */
16
- min;
17
- max;
18
- allowEmpty = !0;
19
- #t = [];
20
- #e = [];
21
- #i = -1;
22
- // 至上一次触发change后,是否有更改
23
- #s = !1;
24
- set value(t) {
25
- this.setValue(t), this.#e = t.split(","), o(this.#t, (i, e) => {
26
- i.value = this.#e[e];
27
- });
28
- }
29
- connectedCallback() {
30
- l(this), this.loadStyleText(u);
31
- const t = {};
32
- this.width && (t["--l-date-picker-width"] = this.width), this.style.cssText = d(t), super.connectedCallback();
33
- }
34
- afterInit() {
35
- this.#t = c(".l-date-inner", this.root), a(this.#t, "change", this.#h), this.range && (a(this.#t, "focus", this.#n), a(this.#t, "blur", this.#o));
36
- }
37
- beforeDestroy() {
38
- r(this.#t, "change", this.#h), this.range && (r(this.#t, "focus", this.#n), r(this.#t, "blur", this.#o)), this.#a();
39
- }
40
- attributeChange(t, i, e) {
41
- t === "value" && e !== this._value && (this.value = e);
42
- }
43
- render() {
44
- const t = document.createDocumentFragment();
45
- if (t.appendChild(this.#r(0)), this.range) {
46
- const i = h("span", {
47
- class: "l-date-range-divider",
48
- textContent: "-"
49
- });
50
- t.appendChild(i), t.appendChild(this.#r(1));
51
- }
52
- return t;
53
- }
54
- #r(t = 0) {
55
- return h("input", {
56
- type: this.type,
57
- class: `l-date-inner l-date-inner${t}`,
58
- name: this.getName(),
59
- value: this.#e[t],
60
- "l-datepicker": `${t}`,
61
- disabled: this.isDisabled(),
62
- min: this.min,
63
- max: this.max
64
- });
65
- }
66
- #h = (t) => {
67
- const i = t.target, e = Number(i.getAttribute("l-datepicker"));
68
- let s = i.value;
69
- !s && !this.allowEmpty && (s = this._resetValue || "", s = s.split(",")[e], i.value = s), this.#e[e] = s, this.#e.join(",") !== this._value && (this.setValue(this.#e.join(",")), this.#s = !0), e === 0 && this.#t.length > 1 ? this.#t[1].min = s : e === 1 && (this.#t[0].max = s), this.range ? this.#l() : this.#d();
70
- };
71
- #a() {
72
- this.#i !== -1 && (clearTimeout(this.#i), this.#i = -1);
73
- }
74
- #l() {
75
- this.#s && (this.#a(), this.#i = setTimeout(() => {
76
- this.#d(), this.#s = !1;
77
- }, this.emitTimeout));
78
- }
79
- #n = () => {
80
- this.#a();
81
- };
82
- #o = () => {
83
- this.#l();
84
- };
85
- #d() {
86
- this.dispatchEvent(
87
- new CustomEvent("change", {
88
- detail: {
89
- value: this.getValue(),
90
- dateStr: this.#e,
91
- dates: this.#e.map((t) => m(t))
92
- }
93
- })
94
- );
95
- }
96
- }
97
- export {
98
- y as default
99
- };