ranui 0.2.0-alpha.0 → 0.2.0-alpha.1
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/dist/button-BstLjXNe.js +117 -0
- package/dist/button.js +1 -1
- package/dist/colorpicker-CGh8pRqo.js +315 -0
- package/dist/colorpicker.js +1 -1
- package/dist/components/colorpicker/index.d.ts +11 -0
- package/dist/components/dropdown/index.d.ts +0 -2
- package/dist/components/image/index.d.ts +6 -0
- package/dist/components/input/index.d.ts +13 -20
- package/dist/components/player/core/view.d.ts +0 -1
- package/dist/components/player/index.d.ts +0 -1
- package/dist/components/popover/index.d.ts +0 -2
- package/dist/components/select/index.d.ts +15 -0
- package/dist/{dropdown-C5362qTy.js → dropdown-RqHMRhFE.js} +0 -6
- package/dist/dropdown.js +1 -1
- package/dist/{icon-DmoEnao5.js → icon-Blm7AbyY.js} +2 -0
- package/dist/icon.js +1 -1
- package/dist/{image-6GayFDqX.js → image-DKm6z7YQ.js} +17 -15
- package/dist/image.js +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.iife.js +35 -35
- package/dist/index.js +16 -16
- package/dist/input-Dskw1bAl.js +186 -0
- package/dist/input.js +1 -1
- package/dist/{katex-es-Cnq5Pk8K.cjs → katex-es-BTpuCxxV.cjs} +7 -7
- package/dist/{katex-es-Bpesphgp.js → katex-es-CKRwcaiU.js} +606 -606
- package/dist/{loading-Mko22ncl.js → loading-C4QUpm70.js} +1 -1
- package/dist/loading.js +1 -1
- package/dist/{math-B5PpSnFR.js → math-Dv4nXSoI.js} +1 -1
- package/dist/math.js +1 -1
- package/dist/{message-CQENvkoi.js → message-De5e1txT.js} +1 -1
- package/dist/message.js +1 -1
- package/dist/{player-CvfmwWUa.js → player-CqTAmg_E.js} +636 -638
- package/dist/player.js +1 -1
- package/dist/{popover-BCvHwLZb.js → popover-BY32HNMl.js} +19 -26
- package/dist/popover.js +1 -1
- package/dist/{progress-BWkNf2J5.js → progress-gZo0knzu.js} +11 -11
- package/dist/progress.js +1 -1
- package/dist/{radar-CWsawt2g.js → radar-19P5Mtld.js} +17 -17
- package/dist/radar.js +1 -1
- package/dist/ranui.css +1 -1
- package/dist/{select-BmhCUTLb.js → select-BVdUtQX5.js} +72 -51
- package/dist/select.js +1 -1
- package/dist/{skeleton-DPv9nFhL.js → skeleton-BAdJ6vyA.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/{tab-C9swK-hm.js → tab-DH2owP2V.js} +0 -1
- package/dist/tab.js +1 -1
- package/docs/COMPONENTS.md +10 -12
- package/docs/DESIGN.md +16 -0
- package/package.json +2 -2
- package/dist/button-DukaD6uL.js +0 -117
- package/dist/colorpicker-Ch67dWa_.js +0 -302
- package/dist/input-DoraIb3x.js +0 -198
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { C as i, c as b, d, f as l, p as a, s as h } from "./utils-D4pPF77E.js";
|
|
2
|
+
import { t as u } from "./events-C59wGdni.js";
|
|
3
|
+
import { _ as v, i as s, p as f } from "./factory-BdsO0dEW.js";
|
|
4
|
+
import { a as p, n as g } from "./ssr-DSGwPtEd.js";
|
|
5
|
+
var m = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{box-sizing:var(--ran-btn-box-sizing, border-box);position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-flex);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, var(--ran-skin-raised-shadow, 0 2px #00000004));cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{box-sizing:var(--ran-btn-contain-box-sizing, border-box);position:var(--ran-btn-contain-position, relative);display:var(--ran-btn-contain-display, block);background-image:var(--ran-btn-contain-background-image, none);cursor:var(--ran-btn-contain-cursor, pointer);transition:var(--ran-btn-contain-transition, color var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1), border-color var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1), box-shadow var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1), opacity var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1));-webkit-user-select:var(--ran-btn-contain-user-select, none);user-select:var(--ran-btn-contain-user-select, none);touch-action:var(--ran-btn-contain-touch-action, manipulation);border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));background:var(--ran-btn-contain-background, var(--ran-color-bg-elevated, #fff))}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:var(--ran-btn-contain-outline, 0)}:host(:focus-visible){outline:var(--ran-btn-focus-outline, 2px solid var(--ran-color-primary));outline-offset:var(--ran-btn-focus-outline-offset, 2px)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, var(--ran-color-primary, #1890ff));background-image:var(--ran-btn-content-background-image, none);border-color:var(--ran-btn-content-border-color, var(--ran-color-primary, #1890ff));color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="primary"]:not([disabled]):active) .ran-btn-content{background-color:var(--ran-btn-content-active-background-color, var(--ran-color-primary-active, #005ff2));border-color:var(--ran-btn-content-active-border-color, var(--ran-color-primary-active, #005ff2))}@media(min-width:1024px){:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-primary, #1890ff));color:var(--ran-btn-content-hover-color, var(--ran-color-primary, #1890ff))}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, var(--ran-color-primary-hover, #0059ec));border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-primary-hover, #0059ec));color:var(--ran-btn-content-hover-color, #fff)}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));color:var(--ran-btn-content-warning-color, #fff)}}:host([type="warning"]) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));background-image:var(--ran-btn-content-background-image, none);color:var(--ran-btn-content-warning-color, #fff)}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="text"]) .ran-btn-content{border:var(--ran-btn-content-text-border, none)}:host([disabled]){cursor:var(--ran-btn-disabled-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-pointer-events, all);opacity:var(--ran-btn-disabled-opacity, .6)}:host([disabled]) .ran-btn{cursor:var(--ran-btn-disabled-container-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-container-pointer-events, all);opacity:var(--ran-btn-disabled-container-opacity, .6)}:host(:not([disabled]):active) .ran-btn:after{transform:var(--ran-btn-after-transform, translate(-50%, -50%) scale(0));opacity:var(--ran-btn-after-opacity, .3);transition:var(--ran-btn-after-transition, 0s)}@media(min-width:1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,var(--ran-color-primary, #1890ff) 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:var(--ran-btn-slot-display, block)}.ran-btn-content{display:var(--ran-btn-content-display, flex);justify-content:var(--ran-btn-content-display, space-between);align-items:var(--ran-btn-content-align-items, center);padding:var(--ran-btn-content-padding, 4px 15px);border:var(--ran-btn-content-border, 1px solid transparent);border-image-source:var(--ran-btn-content-border-image-source, none);border-image-slice:var(--ran-btn-content-border-image-slice, 8);border-image-width:var(--ran-btn-content-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));border-color:var(--ran-btn-content-border-color, var(--ran-color-border, #d9d9d9));color:var(--ran-btn-content-color, var(--ran-color-text, #000000d9));line-height:var(--ran-btn-content-line-height, 22px);font-size:var(--ran-btn-content-font-size, 14px);font-weight:var(--ran-btn-content-font-weight, 400);font-family:var(--ran-btn-content-font-family, var(--ran-skin-font-family, inherit));white-space:var(--ran-btn-content-white-space, nowrap);text-align:var(--ran-btn-content-text-align, center);box-sizing:var(--ran-btn-content-box-sizing, border-box)}.ran-btn-content .icon{margin-right:var(--ran-btn-icon-margin-right, 2px)}', y = class extends g {
|
|
6
|
+
_btn;
|
|
7
|
+
_btnContent;
|
|
8
|
+
_iconElement;
|
|
9
|
+
_slot;
|
|
10
|
+
_shadowDom;
|
|
11
|
+
_events = new u();
|
|
12
|
+
debounceTimeId;
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return [
|
|
15
|
+
"disabled",
|
|
16
|
+
"icon",
|
|
17
|
+
"effect",
|
|
18
|
+
"iconSize",
|
|
19
|
+
"type",
|
|
20
|
+
"sheet"
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
constructor() {
|
|
24
|
+
super(), this._shadowDom = b(this, m);
|
|
25
|
+
const t = h(this._shadowDom, ".ran-btn", () => s().class("ran-btn").attr("part", "button").role("button").tabIndex(0).children(s().class("ran-btn-content").attr("part", "content").children(f().class("slot"))).build());
|
|
26
|
+
this._btn = t, this._btnContent = t.querySelector(".ran-btn-content"), this._slot = t.querySelector("slot");
|
|
27
|
+
}
|
|
28
|
+
get sheet() {
|
|
29
|
+
return this.getAttribute("sheet") || "";
|
|
30
|
+
}
|
|
31
|
+
set sheet(t) {
|
|
32
|
+
this.setAttribute("sheet", t || ""), this.handlerExternalCss();
|
|
33
|
+
}
|
|
34
|
+
get disabled() {
|
|
35
|
+
return a(this);
|
|
36
|
+
}
|
|
37
|
+
set disabled(t) {
|
|
38
|
+
!t || t === "false" ? (this.removeAttribute("disabled"), this.removeAttribute("aria-disabled")) : (this.setAttribute("disabled", ""), this.setAttribute("aria-disabled", "true"));
|
|
39
|
+
}
|
|
40
|
+
get iconSize() {
|
|
41
|
+
return this.getAttribute("iconSize") || "";
|
|
42
|
+
}
|
|
43
|
+
set iconSize(t) {
|
|
44
|
+
!t || t === "false" ? this.removeAttribute("iconSize") : (this.setAttribute("iconSize", t), this.setIcon());
|
|
45
|
+
}
|
|
46
|
+
get icon() {
|
|
47
|
+
return this.getAttribute("icon") || "";
|
|
48
|
+
}
|
|
49
|
+
set icon(t) {
|
|
50
|
+
!t || t === "false" ? this.removeAttribute("icon") : (this.setAttribute("icon", t), this.setIcon());
|
|
51
|
+
}
|
|
52
|
+
get effect() {
|
|
53
|
+
return this.getAttribute("effect") || "";
|
|
54
|
+
}
|
|
55
|
+
set effect(t) {
|
|
56
|
+
l.includes(t) || !t ? this.removeAttribute("effect") : this.setAttribute("effect", t);
|
|
57
|
+
}
|
|
58
|
+
get type() {
|
|
59
|
+
return this.getAttribute("type") || "";
|
|
60
|
+
}
|
|
61
|
+
set type(t) {
|
|
62
|
+
t ? this.setAttribute("type", t) : this.removeAttribute("type");
|
|
63
|
+
}
|
|
64
|
+
setIcon = () => {
|
|
65
|
+
if (typeof document > "u" || !this._slot) return;
|
|
66
|
+
const t = this.icon;
|
|
67
|
+
if (!t) {
|
|
68
|
+
this._iconElement && (this._iconElement.remove(), this._iconElement = void 0);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (this._iconElement) this._iconElement.setAttribute("name", t);
|
|
72
|
+
else {
|
|
73
|
+
let e = this._shadowDom.querySelector("r-icon");
|
|
74
|
+
e || (e = v("r-icon").attr("color", "currentColor").class("icon").build(), this._slot.insertAdjacentElement("beforebegin", e)), this._iconElement = e, this._iconElement.setAttribute("name", t);
|
|
75
|
+
}
|
|
76
|
+
const { width: n, height: r } = this._slot.getBoundingClientRect(), o = Math.min(n, r) || 16, c = this.iconSize || `${o > 5 ? o - 5 : o}`;
|
|
77
|
+
this._iconElement.setAttribute("size", String(c));
|
|
78
|
+
};
|
|
79
|
+
mousedown = (t) => {
|
|
80
|
+
if (i() === "pc" && !this.disabled) {
|
|
81
|
+
this.debounceMouseEvent();
|
|
82
|
+
const { left: n, top: r } = this.getBoundingClientRect();
|
|
83
|
+
this._btn.style.setProperty("--ran-x", `${t.clientX - n}px`), this._btn.style.setProperty("--ran-y", `${t.clientY - r}px`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
mouseup = () => {
|
|
87
|
+
i() === "pc" && (this.debounceTimeId || (this.debounceTimeId = setTimeout(() => {
|
|
88
|
+
this._btn.style.removeProperty("--ran-x"), this._btn.style.removeProperty("--ran-y"), this.debounceMouseEvent();
|
|
89
|
+
}, 600)));
|
|
90
|
+
};
|
|
91
|
+
keydown = (t) => {
|
|
92
|
+
a(this) || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.click());
|
|
93
|
+
};
|
|
94
|
+
debounceMouseEvent = () => {
|
|
95
|
+
this.debounceTimeId && (clearTimeout(this.debounceTimeId), this.debounceTimeId = void 0);
|
|
96
|
+
};
|
|
97
|
+
handlerExternalCss = () => {
|
|
98
|
+
d(this, this._shadowDom, "sheet", null, this.sheet);
|
|
99
|
+
};
|
|
100
|
+
syncA11yState = () => {
|
|
101
|
+
const t = a(this);
|
|
102
|
+
this._btn.setAttribute("aria-disabled", t ? "true" : "false"), this._btn.tabIndex = t ? -1 : 0, t ? (this.setAttribute("aria-disabled", "true"), this._btnContent.setAttribute("disabled", "true")) : (this.removeAttribute("aria-disabled"), this._btnContent.removeAttribute("disabled"));
|
|
103
|
+
};
|
|
104
|
+
connectedCallback() {
|
|
105
|
+
this.handlerExternalCss(), this.setIcon(), this.syncA11yState(), this._events.on(this._btn, "mousedown", this.mousedown).on(this._btn, "mouseup", this.mouseup).on(this._btn, "keydown", this.keydown);
|
|
106
|
+
}
|
|
107
|
+
disconnectedCallback() {
|
|
108
|
+
this.debounceMouseEvent(), this._events.abort();
|
|
109
|
+
}
|
|
110
|
+
attributeChangedCallback(t, n, r) {
|
|
111
|
+
n !== r && (t === "disabled" && this._btnContent && this.syncA11yState(), (t === "icon" || t === "iconSize") && this.setIcon(), t === "sheet" && this.handlerExternalCss());
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
p("r-button", y);
|
|
115
|
+
export {
|
|
116
|
+
y as t
|
|
117
|
+
};
|
package/dist/button.js
CHANGED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { c as v, d as x, l as m, p as h, s as P, u as y, x as l } from "./utils-D4pPF77E.js";
|
|
2
|
+
import { t as w } from "./events-C59wGdni.js";
|
|
3
|
+
import { i as S, r as p } from "./signal-XHfNsQNW.js";
|
|
4
|
+
import { _ as u, h as A, i as n } from "./factory-BdsO0dEW.js";
|
|
5
|
+
import { a as $, n as _ } from "./ssr-DSGwPtEd.js";
|
|
6
|
+
import "./input-Dskw1bAl.js";
|
|
7
|
+
import "./select-BVdUtQX5.js";
|
|
8
|
+
import "./popover-BY32HNMl.js";
|
|
9
|
+
var D = (e) => {
|
|
10
|
+
const { r: t, g: i, b: r } = I(e);
|
|
11
|
+
return f(t, i, r);
|
|
12
|
+
}, I = (e) => (e[0] === "#" && (e = e.substr(1)), e.length === 3 ? {
|
|
13
|
+
r: parseInt(e[0] + e[0], 16),
|
|
14
|
+
g: parseInt(e[1] + e[1], 16),
|
|
15
|
+
b: parseInt(e[2] + e[2], 16)
|
|
16
|
+
} : {
|
|
17
|
+
r: parseInt(e.substr(0, 2), 16),
|
|
18
|
+
g: parseInt(e.substr(2, 2), 16),
|
|
19
|
+
b: parseInt(e.substr(4, 2), 16)
|
|
20
|
+
}), f = (e, t, i) => {
|
|
21
|
+
let r;
|
|
22
|
+
const o = Math.max(e, t, i), a = o - Math.min(e, t, i);
|
|
23
|
+
a === 0 ? r = 0 : e === o ? r = (t - i) / a % 6 : t === o ? r = (i - e) / a + 2 : r = (e - t) / a + 4, r = Math.round(r * 60), r < 0 && (r += 360);
|
|
24
|
+
const s = Math.round((o === 0 ? 0 : a / o) * 100), c = Math.round(o / 255 * 100);
|
|
25
|
+
return {
|
|
26
|
+
h: r,
|
|
27
|
+
s,
|
|
28
|
+
v: c
|
|
29
|
+
};
|
|
30
|
+
}, b = (e, t, i) => {
|
|
31
|
+
t = t / 100, i = i / 100;
|
|
32
|
+
let r = [];
|
|
33
|
+
const o = i * t, a = e / 60, s = o * (1 - Math.abs(a % 2 - 1)), c = i - o;
|
|
34
|
+
return a >= 0 && a < 1 ? r = [
|
|
35
|
+
o,
|
|
36
|
+
s,
|
|
37
|
+
0
|
|
38
|
+
] : a >= 1 && a < 2 ? r = [
|
|
39
|
+
s,
|
|
40
|
+
o,
|
|
41
|
+
0
|
|
42
|
+
] : a >= 2 && a < 3 ? r = [
|
|
43
|
+
0,
|
|
44
|
+
o,
|
|
45
|
+
s
|
|
46
|
+
] : e >= 3 && a < 4 ? r = [
|
|
47
|
+
0,
|
|
48
|
+
s,
|
|
49
|
+
o
|
|
50
|
+
] : e >= 4 && a < 5 ? r = [
|
|
51
|
+
s,
|
|
52
|
+
0,
|
|
53
|
+
o
|
|
54
|
+
] : e >= 5 && a <= 6 ? r = [
|
|
55
|
+
o,
|
|
56
|
+
0,
|
|
57
|
+
s
|
|
58
|
+
] : r = [
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
0
|
|
62
|
+
], {
|
|
63
|
+
r: Math.round(255 * (r[0] + c)),
|
|
64
|
+
g: Math.round(255 * (r[1] + c)),
|
|
65
|
+
b: Math.round(255 * (r[2] + c))
|
|
66
|
+
};
|
|
67
|
+
}, k = (e) => {
|
|
68
|
+
const t = e.toString(16);
|
|
69
|
+
return t.length === 1 ? "0" + t : t;
|
|
70
|
+
}, g = (e, t, i) => "#" + [
|
|
71
|
+
k(e),
|
|
72
|
+
k(t),
|
|
73
|
+
k(i)
|
|
74
|
+
].join(""), C = /^#([\da-f]{6}|[\da-f]{3})$/i, E = /^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/, R = /^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3}(\.\d+)?)\)$/, V = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-colorpicker{box-sizing:border-box;min-width:32px;height:32px;border-radius:var(--ran-colorpicker-border-radius, var(--ran-radius-md, 8px));border:var(--ran-colorpicker-border, 1px solid var(--ran-color-border, #d9d9d9));cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:var(--ran-colorpicker-transition, border-color .2s, box-shadow .2s);background:var(--ran-colorpicker-background, var(--ran-color-bg-elevated, #ffffff));padding:3px}.ran-colorpicker:hover{border-color:var(--ran-colorpicker-border-hover, var(--ran-color-border-hover, var(--ran-gray-500)))}.ran-colorpicker-block{position:relative;border-radius:var(--ran-colorpicker-block-border-radius, var(--ran-radius-sm, 4px));width:24px;height:24px;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:50% 50%}.ran-colorpicker-inner{width:100%;height:100%;border-radius:inherit}.ran-colorpicker-block[disabled]{cursor:var(--ran-colorpicker-disabled-cursor, not-allowed);opacity:var(--ran-colorpicker-disabled-opacity, .5)}", H = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-color-picker-inner{box-sizing:border-box}.ran-color-picker-inner-content{box-sizing:border-box;display:flex;flex-direction:column;gap:12px;width:224px;padding:12px;font-family:var(--ran-font-family, inherit)}.ran-color-picker-inner-content *,.ran-color-picker-inner-content *:before,.ran-color-picker-inner-content *:after{box-sizing:border-box}.ran-color-picker-palette{position:relative;width:100%;height:160px;border-radius:var(--ran-radius-sm, 6px);overflow:hidden;cursor:crosshair;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));touch-action:none}.ran-color-picker-saturation{position:absolute;inset:0;border-radius:inherit;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.ran-color-picker-palette-dot{position:absolute;top:0;left:0;z-index:2;width:14px;height:14px;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #0003,0 1px 3px #00000059;pointer-events:none}.ran-color-picker-controls{display:flex;align-items:center;gap:12px}.ran-color-picker-preview{position:relative;flex:none;width:28px;height:28px;border-radius:50%;overflow:hidden;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:12px 12px}.ran-color-picker-preview-inner{position:absolute;inset:0;border-radius:inherit}.ran-color-picker-sliders{flex:1;min-width:0;display:flex;flex-direction:column;gap:12px}.ran-color-picker-slider{position:relative;height:10px;border-radius:999px;cursor:pointer;box-shadow:inset 0 0 0 1px var(--ran-gray-alpha-200, rgba(0, 0, 0, .09));touch-action:none}.ran-color-picker-slider-hue{background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red)}.ran-color-picker-slider-alpha{background-image:conic-gradient(var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 25%,transparent 0 50%,var(--ran-gray-alpha-100, rgba(0, 0, 0, .06)) 0 75%,transparent 0);background-size:8px 8px}.ran-color-picker-slider-alpha-track{position:absolute;inset:0;border-radius:inherit}.ran-color-picker-slider-thumb{position:absolute;top:50%;left:0;z-index:1;width:14px;height:14px;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px #0003,0 1px 3px #00000059;pointer-events:none}.ran-color-picker-input-container{display:flex;align-items:center;gap:8px}.ran-color-picker-format{flex:none;width:68px}.ran-color-picker-value{flex:1;min-width:0}", d = 360, F = class extends _ {
|
|
75
|
+
colorpicker;
|
|
76
|
+
colorpickerInner;
|
|
77
|
+
context;
|
|
78
|
+
_shadowDom;
|
|
79
|
+
_events = new w();
|
|
80
|
+
_effectDisposers = [];
|
|
81
|
+
popoverBlock;
|
|
82
|
+
popoverContent;
|
|
83
|
+
colorPickerInner;
|
|
84
|
+
colorPickerPalette;
|
|
85
|
+
colorPickerSaturation;
|
|
86
|
+
colorPickerPaletteDot;
|
|
87
|
+
colorPickerHueSlider;
|
|
88
|
+
colorPickerHueThumb;
|
|
89
|
+
colorPickerAlphaSlider;
|
|
90
|
+
colorPickerAlphaTrack;
|
|
91
|
+
colorPickerAlphaThumb;
|
|
92
|
+
colorPickerPreviewInner;
|
|
93
|
+
colorPickerValueInput;
|
|
94
|
+
colorPickerFormatSelect;
|
|
95
|
+
colorPickerPaletteSelect;
|
|
96
|
+
_activeSlider = null;
|
|
97
|
+
_format = "HEX";
|
|
98
|
+
_editingInput = !1;
|
|
99
|
+
static get observedAttributes() {
|
|
100
|
+
return [
|
|
101
|
+
"disabled",
|
|
102
|
+
"value",
|
|
103
|
+
"sheet"
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
constructor() {
|
|
107
|
+
super(), this._shadowDom = v(this, V);
|
|
108
|
+
const e = P(this._shadowDom, "r-popover", () => {
|
|
109
|
+
const t = n().class("ran-colorpicker-inner").part("swatch").build(), i = n().class("ran-colorpicker-block").part("block").children(t).build(), r = u("r-content").class("ran-content").build();
|
|
110
|
+
return u("r-popover").class("ran-popover").attr("trigger", "click").children(i, r).build();
|
|
111
|
+
});
|
|
112
|
+
this.popoverBlock = e, this.popoverContent = e.querySelector("r-content"), this.colorpicker = e.querySelector(".ran-colorpicker-block"), this.colorpickerInner = e.querySelector(".ran-colorpicker-inner"), this.colorpicker.setAttribute("role", "button"), this.colorpicker.setAttribute("tabindex", "0"), this.colorpicker.setAttribute("aria-haspopup", "dialog"), this.colorpicker.setAttribute("aria-label", "Choose color"), this.colorPickerPaletteSelect = !1, this.createContext();
|
|
113
|
+
}
|
|
114
|
+
get value() {
|
|
115
|
+
return this.context?.value.getter() || "";
|
|
116
|
+
}
|
|
117
|
+
set value(e) {
|
|
118
|
+
this.setAttribute("value", e);
|
|
119
|
+
}
|
|
120
|
+
get sheet() {
|
|
121
|
+
return m(this, "sheet");
|
|
122
|
+
}
|
|
123
|
+
set sheet(e) {
|
|
124
|
+
y(this, "sheet", e);
|
|
125
|
+
}
|
|
126
|
+
get disabled() {
|
|
127
|
+
return h(this);
|
|
128
|
+
}
|
|
129
|
+
set disabled(e) {
|
|
130
|
+
e === !1 || e === void 0 || e === null ? this.removeAttribute("disabled") : this.setAttribute("disabled", "");
|
|
131
|
+
}
|
|
132
|
+
handlerExternalCss = () => {
|
|
133
|
+
x(this, this._shadowDom, "sheet", null, this.sheet);
|
|
134
|
+
};
|
|
135
|
+
syncDisabledState = () => {
|
|
136
|
+
const e = h(this);
|
|
137
|
+
this.context?.disabled.setter(e), e ? (this.setAttribute("aria-disabled", "true"), this.colorpicker?.setAttribute("disabled", "")) : (this.removeAttribute("aria-disabled"), this.colorpicker?.removeAttribute("disabled")), this.colorpicker?.setAttribute("aria-disabled", e ? "true" : "false"), this.colorpicker?.setAttribute("tabindex", e ? "-1" : "0");
|
|
138
|
+
};
|
|
139
|
+
blockWhenDisabled = (e) => {
|
|
140
|
+
h(this) && (e.stopImmediatePropagation(), e.preventDefault());
|
|
141
|
+
};
|
|
142
|
+
createContext = () => {
|
|
143
|
+
const e = (t) => {
|
|
144
|
+
const [i, r] = S(t);
|
|
145
|
+
return {
|
|
146
|
+
getter: i,
|
|
147
|
+
setter: r
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
this.context = {
|
|
151
|
+
value: e(""),
|
|
152
|
+
disabled: e(!1),
|
|
153
|
+
hue: e(0),
|
|
154
|
+
saturation: e(0),
|
|
155
|
+
lightness: e(100),
|
|
156
|
+
transparency: e(100)
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
currentRgba = () => {
|
|
160
|
+
const { hue: e, saturation: t, lightness: i, transparency: r } = this.context, { r: o, g: a, b: s } = b(e.getter(), t.getter(), i.getter());
|
|
161
|
+
return {
|
|
162
|
+
r: o,
|
|
163
|
+
g: a,
|
|
164
|
+
b: s,
|
|
165
|
+
a: r.getter() / 100
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
currentValue = () => {
|
|
169
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba();
|
|
170
|
+
return r < 1 ? `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(2))})` : g(e, t, i);
|
|
171
|
+
};
|
|
172
|
+
currentDisplay = () => {
|
|
173
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba();
|
|
174
|
+
return this._format === "RGB" ? r < 1 ? `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(2))})` : `rgb(${e}, ${t}, ${i})` : g(e, t, i);
|
|
175
|
+
};
|
|
176
|
+
updateColorValue = (e) => {
|
|
177
|
+
if (e === this.context?.value.getter()) return;
|
|
178
|
+
const t = e.replace(/\s+/g, ""), i = C.exec(e), r = R.exec(t), o = E.exec(t);
|
|
179
|
+
if (i) {
|
|
180
|
+
const { h: a, s, v: c } = D(i[0]);
|
|
181
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(100);
|
|
182
|
+
} else if (r) {
|
|
183
|
+
const { h: a, s, v: c } = f(Number(r[1]), Number(r[2]), Number(r[3]));
|
|
184
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(Number(r[4]) * 100);
|
|
185
|
+
} else if (o) {
|
|
186
|
+
const { h: a, s, v: c } = f(Number(o[1]), Number(o[2]), Number(o[3]));
|
|
187
|
+
this.context.hue.setter(a), this.context.saturation.setter(s), this.context.lightness.setter(c), this.context.transparency.setter(100);
|
|
188
|
+
} else return;
|
|
189
|
+
this.setAttribute("value", e), this.context?.value.setter(e);
|
|
190
|
+
};
|
|
191
|
+
emitChange = () => {
|
|
192
|
+
const e = this.currentValue(), { r: t, g: i, b: r, a: o } = this.currentRgba();
|
|
193
|
+
this.context?.value.setter(e), this.setAttribute("value", e), this.dispatchEvent(new CustomEvent("change", {
|
|
194
|
+
detail: {
|
|
195
|
+
value: e,
|
|
196
|
+
hex: g(t, i, r),
|
|
197
|
+
rgb: `rgb(${t}, ${i}, ${r})`,
|
|
198
|
+
rgba: `rgba(${t}, ${i}, ${r}, ${Number(o.toFixed(2))})`,
|
|
199
|
+
alpha: Number(o.toFixed(2))
|
|
200
|
+
},
|
|
201
|
+
bubbles: !0,
|
|
202
|
+
composed: !0
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
205
|
+
palettePointerDown = (e) => {
|
|
206
|
+
e.preventDefault(), this.colorPickerPaletteSelect = !0, this.updatePaletteFromEvent(e);
|
|
207
|
+
};
|
|
208
|
+
updatePaletteFromEvent = (e) => {
|
|
209
|
+
if (!this.colorPickerPalette) return;
|
|
210
|
+
const { left: t, top: i, width: r, height: o } = this.colorPickerPalette.getBoundingClientRect();
|
|
211
|
+
if (!r || !o) return;
|
|
212
|
+
const a = l(e.clientX - t, 0, r), s = l(e.clientY - i, 0, o);
|
|
213
|
+
this.context.saturation.setter(a / r * 100), this.context.lightness.setter((1 - s / o) * 100), this.emitChange();
|
|
214
|
+
};
|
|
215
|
+
sliderPointerDown = (e) => (t) => {
|
|
216
|
+
t.preventDefault(), this._activeSlider = e, this.updateSliderFromEvent(e, t);
|
|
217
|
+
};
|
|
218
|
+
updateSliderFromEvent = (e, t) => {
|
|
219
|
+
const i = e === "hue" ? this.colorPickerHueSlider : this.colorPickerAlphaSlider;
|
|
220
|
+
if (!i) return;
|
|
221
|
+
const { left: r, width: o } = i.getBoundingClientRect();
|
|
222
|
+
if (!o) return;
|
|
223
|
+
const a = l(t.clientX - r, 0, o) / o;
|
|
224
|
+
e === "hue" ? this.context.hue.setter(a * d) : this.context.transparency.setter(a * 100), this.emitChange();
|
|
225
|
+
};
|
|
226
|
+
onPointerMove = (e) => {
|
|
227
|
+
const t = e;
|
|
228
|
+
this.colorPickerPaletteSelect ? this.updatePaletteFromEvent(t) : this._activeSlider && this.updateSliderFromEvent(this._activeSlider, t);
|
|
229
|
+
};
|
|
230
|
+
initSliderA11y = (e, t, i) => {
|
|
231
|
+
e.setAttribute("role", "slider"), e.setAttribute("tabindex", "0"), e.setAttribute("aria-label", t), e.setAttribute("aria-orientation", "horizontal"), e.setAttribute("aria-valuemin", "0"), e.setAttribute("aria-valuemax", String(i));
|
|
232
|
+
};
|
|
233
|
+
sliderKeydown = (e) => (t) => {
|
|
234
|
+
const i = e === "hue" ? d : 100, r = e === "hue" ? this.context.hue : this.context.transparency, o = t.shiftKey ? 10 : 1, a = r.getter();
|
|
235
|
+
let s = a;
|
|
236
|
+
switch (t.key) {
|
|
237
|
+
case "ArrowRight":
|
|
238
|
+
case "ArrowUp":
|
|
239
|
+
s = a + o;
|
|
240
|
+
break;
|
|
241
|
+
case "ArrowLeft":
|
|
242
|
+
case "ArrowDown":
|
|
243
|
+
s = a - o;
|
|
244
|
+
break;
|
|
245
|
+
case "Home":
|
|
246
|
+
s = 0;
|
|
247
|
+
break;
|
|
248
|
+
case "End":
|
|
249
|
+
s = i;
|
|
250
|
+
break;
|
|
251
|
+
default:
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
t.preventDefault(), r.setter(l(s, 0, i)), this.emitChange();
|
|
255
|
+
};
|
|
256
|
+
onPointerUp = () => {
|
|
257
|
+
this.colorPickerPaletteSelect = !1, this._activeSlider = null;
|
|
258
|
+
};
|
|
259
|
+
onSwatchKeydown = (e) => {
|
|
260
|
+
h(this) || (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), this.colorpicker?.click());
|
|
261
|
+
};
|
|
262
|
+
onValueInput = (e) => {
|
|
263
|
+
const t = e.target, i = e.detail?.value ?? t?.value;
|
|
264
|
+
typeof i == "string" && (this._editingInput = !0, this.updateColorValue(i.trim()), this._editingInput = !1, this.emitChange());
|
|
265
|
+
};
|
|
266
|
+
onFormatChange = (e) => {
|
|
267
|
+
const t = e.detail?.value;
|
|
268
|
+
this._format = t === "RGB" ? "RGB" : "HEX", this.syncValueInput();
|
|
269
|
+
};
|
|
270
|
+
syncValueInput = () => {
|
|
271
|
+
this._editingInput || !this.colorPickerValueInput || (this.colorPickerValueInput.value = this.currentDisplay());
|
|
272
|
+
};
|
|
273
|
+
setupEffects = () => {
|
|
274
|
+
this._effectDisposers.push(p(() => {
|
|
275
|
+
const { r: e, g: t, b: i } = b(this.context.hue.getter(), 100, 100);
|
|
276
|
+
this.colorPickerSaturation?.style.setProperty("background-color", `rgb(${e}, ${t}, ${i})`);
|
|
277
|
+
}), p(() => {
|
|
278
|
+
const e = l(this.context.saturation.getter(), 0, 100), t = l(this.context.lightness.getter(), 0, 100);
|
|
279
|
+
this.colorPickerPaletteDot?.style.setProperty("left", `${e}%`), this.colorPickerPaletteDot?.style.setProperty("top", `${100 - t}%`);
|
|
280
|
+
}), p(() => {
|
|
281
|
+
const e = this.context.hue.getter(), { r: t, g: i, b: r } = b(e, 100, 100);
|
|
282
|
+
this.colorPickerHueThumb?.style.setProperty("left", `${e / d * 100}%`), this.colorPickerHueThumb?.style.setProperty("background", `rgb(${t}, ${i}, ${r})`), this.colorPickerHueSlider?.setAttribute("aria-valuenow", String(Math.round(e)));
|
|
283
|
+
}), p(() => {
|
|
284
|
+
const { r: e, g: t, b: i, a: r } = this.currentRgba(), o = `rgb(${e}, ${t}, ${i})`, a = `rgba(${e}, ${t}, ${i}, ${Number(r.toFixed(3))})`;
|
|
285
|
+
this.colorPickerAlphaTrack?.style.setProperty("background", `linear-gradient(to right, rgba(${e}, ${t}, ${i}, 0), ${o})`), this.colorPickerAlphaThumb?.style.setProperty("left", `${r * 100}%`), this.colorPickerAlphaThumb?.style.setProperty("background", a), this.colorPickerPreviewInner?.style.setProperty("background", a), this.colorpickerInner?.style.setProperty("background", a), this.colorPickerAlphaSlider?.setAttribute("aria-valuenow", String(Math.round(r * 100))), this.colorPickerAlphaSlider?.setAttribute("aria-valuetext", `${Math.round(r * 100)}%`), this.syncValueInput();
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
disposeEffects = () => {
|
|
289
|
+
for (const e of this._effectDisposers) e();
|
|
290
|
+
this._effectDisposers = [];
|
|
291
|
+
};
|
|
292
|
+
openColorPicker = () => {
|
|
293
|
+
if (h(this) || this.colorPickerInner) return;
|
|
294
|
+
this.colorPickerSaturation = n().class("ran-color-picker-saturation").build(), this.colorPickerPaletteDot = n().class("ran-color-picker-palette-dot").build(), this.colorPickerPalette = n().class("ran-color-picker-palette").on("mousedown", this.palettePointerDown).children(this.colorPickerSaturation, this.colorPickerPaletteDot).build(), this.colorPickerPreviewInner = n().class("ran-color-picker-preview-inner").build();
|
|
295
|
+
const e = n().class("ran-color-picker-preview").children(this.colorPickerPreviewInner).build();
|
|
296
|
+
this.colorPickerHueThumb = n().class("ran-color-picker-slider-thumb").build(), this.colorPickerHueSlider = n().class("ran-color-picker-slider ran-color-picker-slider-hue").on("mousedown", this.sliderPointerDown("hue")).on("keydown", this.sliderKeydown("hue")).children(this.colorPickerHueThumb).build(), this.initSliderA11y(this.colorPickerHueSlider, "Hue", d), this.colorPickerAlphaTrack = n().class("ran-color-picker-slider-alpha-track").build(), this.colorPickerAlphaThumb = n().class("ran-color-picker-slider-thumb").build(), this.colorPickerAlphaSlider = n().class("ran-color-picker-slider ran-color-picker-slider-alpha").on("mousedown", this.sliderPointerDown("alpha")).on("keydown", this.sliderKeydown("alpha")).children(this.colorPickerAlphaTrack, this.colorPickerAlphaThumb).build(), this.initSliderA11y(this.colorPickerAlphaSlider, "Alpha opacity", 100);
|
|
297
|
+
const t = n().class("ran-color-picker-sliders").children(this.colorPickerHueSlider, this.colorPickerAlphaSlider).build(), i = n().class("ran-color-picker-controls").children(e, t).build();
|
|
298
|
+
this.colorPickerFormatSelect = u("r-select").class("ran-color-picker-format").attr("value", this._format).attr("defaultValue", this._format).attr("trigger", "click").children(...["HEX", "RGB"].map((a) => u("r-option").attr("value", a).text(a).build())).on("change", this.onFormatChange).build(), this.colorPickerValueInput = u("r-input").class("ran-color-picker-value").on("change", this.onValueInput).build();
|
|
299
|
+
const r = n().class("ran-color-picker-input-container").children(this.colorPickerFormatSelect, this.colorPickerValueInput).build(), o = n().class("ran-color-picker-inner-content").children(this.colorPickerPalette, i, r).build();
|
|
300
|
+
this.colorPickerInner = n().class("ran-color-picker-inner").children(A().text(H).build(), o).build(), this.popoverContent.appendChild(this.colorPickerInner), this.setupEffects(), this.syncValueInput();
|
|
301
|
+
};
|
|
302
|
+
connectedCallback() {
|
|
303
|
+
this.handlerExternalCss(), this.setAttribute("class", "ran-colorpicker"), this._events.on(this, "click", this.blockWhenDisabled, { capture: !0 }), this._events.on(this, "keydown", this.blockWhenDisabled, { capture: !0 }), this._events.on(this.popoverBlock, "click", this.openColorPicker), this._events.on(this.colorpicker, "keydown", this.onSwatchKeydown), this._events.on(document, "mousemove", this.onPointerMove), this._events.on(document, "mouseup", this.onPointerUp), this.syncDisabledState(), this.value && this.updateColorValue(this.value);
|
|
304
|
+
}
|
|
305
|
+
disconnectedCallback() {
|
|
306
|
+
this._events.abort(), this.disposeEffects();
|
|
307
|
+
}
|
|
308
|
+
attributeChangedCallback(e, t, i) {
|
|
309
|
+
t !== i && (e === "value" && this.updateColorValue(i), e === "disabled" && this.syncDisabledState(), e === "sheet" && this.handlerExternalCss());
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
$("r-colorpicker", F);
|
|
313
|
+
export {
|
|
314
|
+
F as t
|
|
315
|
+
};
|
package/dist/colorpicker.js
CHANGED
|
@@ -53,7 +53,18 @@ export declare class ColorPicker extends RanElement {
|
|
|
53
53
|
set value(value: string);
|
|
54
54
|
get sheet(): string;
|
|
55
55
|
set sheet(value: string);
|
|
56
|
+
get disabled(): boolean;
|
|
57
|
+
set disabled(value: boolean | string | undefined | null);
|
|
56
58
|
handlerExternalCss: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Reflect the `disabled` attribute into the internal state, ARIA, and the
|
|
61
|
+
* swatch's visual/interaction state. When disabled the swatch is removed from
|
|
62
|
+
* the tab order and marked `aria-disabled`; opening is blocked by
|
|
63
|
+
* `blockWhenDisabled` (a capture-phase guard wired in connectedCallback).
|
|
64
|
+
*/
|
|
65
|
+
syncDisabledState: () => void;
|
|
66
|
+
/** Capture-phase guard: swallow clicks/keydowns on the swatch while disabled. */
|
|
67
|
+
blockWhenDisabled: (e: Event) => void;
|
|
57
68
|
createContext: () => void;
|
|
58
69
|
currentRgba: () => RGBA;
|
|
59
70
|
/** Canonical string used for the `value` attribute and `change` events. */
|
|
@@ -17,8 +17,6 @@ export declare class Dropdown extends RanElement {
|
|
|
17
17
|
set transit(value: string);
|
|
18
18
|
get arrow(): string;
|
|
19
19
|
set arrow(value: string);
|
|
20
|
-
get show(): string;
|
|
21
|
-
set show(value: string);
|
|
22
20
|
get sheet(): string;
|
|
23
21
|
set sheet(value: string);
|
|
24
22
|
handlerExternalCss: () => void;
|
|
@@ -19,6 +19,12 @@ export declare class ImageElement extends RanElement {
|
|
|
19
19
|
set alt(value: string);
|
|
20
20
|
handlerExternalCss: () => void;
|
|
21
21
|
listenFallback(name: string, value: string | null): void;
|
|
22
|
+
/**
|
|
23
|
+
* Point the inner `<img>` at the current `src` attribute. The `error`/`load`
|
|
24
|
+
* listeners wired in `connectedCallback` stay attached, so this reuses the
|
|
25
|
+
* same fallback-on-error and append-on-load behavior for every src change.
|
|
26
|
+
*/
|
|
27
|
+
updateSrc: () => void;
|
|
22
28
|
connectedCallback(): void;
|
|
23
29
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
24
30
|
}
|
|
@@ -127,26 +127,6 @@ export declare class Input extends RanElement {
|
|
|
127
127
|
* @param {string|null} value
|
|
128
128
|
*/
|
|
129
129
|
set icon(value: string);
|
|
130
|
-
/**
|
|
131
|
-
* @description: 获取前面的 icon
|
|
132
|
-
* @return {String}
|
|
133
|
-
*/
|
|
134
|
-
get prefix(): string;
|
|
135
|
-
/**
|
|
136
|
-
* @description: 设置前面的 icon 来表示标识
|
|
137
|
-
* @param {string|null} value
|
|
138
|
-
*/
|
|
139
|
-
set prefix(value: string);
|
|
140
|
-
/**
|
|
141
|
-
* @description: 获取后面的 icon
|
|
142
|
-
* @return {String}
|
|
143
|
-
*/
|
|
144
|
-
get suffix(): string;
|
|
145
|
-
/**
|
|
146
|
-
* @description: 设置后面的 icon 来表示标识
|
|
147
|
-
* @param {string|null} value
|
|
148
|
-
*/
|
|
149
|
-
set suffix(value: string);
|
|
150
130
|
/**
|
|
151
131
|
* @description: 获取 input 的类型
|
|
152
132
|
* @return {string|null}
|
|
@@ -199,6 +179,19 @@ export declare class Input extends RanElement {
|
|
|
199
179
|
* @param {string} value
|
|
200
180
|
*/
|
|
201
181
|
listenMessage: (name: string, value: string) => void;
|
|
182
|
+
/**
|
|
183
|
+
* @description: 监听 min/max/step 属性,仅在 type="number" 时转发到内部 <input>
|
|
184
|
+
* 以启用原生数值约束;否则从内部 <input> 移除。
|
|
185
|
+
* @param {string} name
|
|
186
|
+
* @param {string} value
|
|
187
|
+
*/
|
|
188
|
+
listenNumericConstraint: (name: string, value: string) => void;
|
|
189
|
+
/**
|
|
190
|
+
* @description: 监听 required 属性,转发到内部 <input> 以启用原生约束校验
|
|
191
|
+
* @param {string} name
|
|
192
|
+
* @param {string} value
|
|
193
|
+
*/
|
|
194
|
+
listenRequired: (name: string, value: string) => void;
|
|
202
195
|
/**
|
|
203
196
|
* @description: 监听 disabled 属性
|
|
204
197
|
* @param {string} name
|
|
@@ -25,8 +25,6 @@ export declare class Popover extends RanElement {
|
|
|
25
25
|
constructor();
|
|
26
26
|
get placement(): string;
|
|
27
27
|
set placement(value: string);
|
|
28
|
-
get arrow(): string;
|
|
29
|
-
set arrow(value: string);
|
|
30
28
|
get trigger(): string;
|
|
31
29
|
set trigger(value: string);
|
|
32
30
|
get getPopupContainerId(): string;
|
|
@@ -8,11 +8,13 @@ import { EventManager } from '@/utils/builder';
|
|
|
8
8
|
interface Option {
|
|
9
9
|
label: string | number;
|
|
10
10
|
value: string | number;
|
|
11
|
+
disabled?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare class Select extends RanElement {
|
|
13
14
|
static formAssociated: boolean;
|
|
14
15
|
_internals?: ElementInternals;
|
|
15
16
|
_events: EventManager;
|
|
17
|
+
_searchEvents: EventManager;
|
|
16
18
|
removeTimeId?: NodeJS.Timeout;
|
|
17
19
|
_listboxId: string;
|
|
18
20
|
_activeIndex: number;
|
|
@@ -63,6 +65,12 @@ export declare class Select extends RanElement {
|
|
|
63
65
|
setActiveOptionByIndex: (targetIndex: number) => void;
|
|
64
66
|
selectOptionElement: (optionElement: HTMLElement | null, shouldDispatch?: boolean) => void;
|
|
65
67
|
isDropdownOpen: () => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Walk from `from` in the direction of `step` (clamped to the list bounds)
|
|
70
|
+
* and return the first non-disabled option index, or -1 if none exists.
|
|
71
|
+
* Keeps keyboard navigation from ever landing on a disabled option.
|
|
72
|
+
*/
|
|
73
|
+
_nextEnabledIndex: (from: number, step: number) => number;
|
|
66
74
|
keydownSelect: (e: KeyboardEvent) => void;
|
|
67
75
|
handlerExternalCss(): void;
|
|
68
76
|
/**
|
|
@@ -123,6 +131,13 @@ export declare class Select extends RanElement {
|
|
|
123
131
|
changeSearch: (e: Event) => void;
|
|
124
132
|
clickRemoveSelect: (e: Event) => void;
|
|
125
133
|
connectedCallback(): void;
|
|
134
|
+
/**
|
|
135
|
+
* (Re)wire the search-box listeners to match the current `showSearch` value.
|
|
136
|
+
* Reactive: abort any previously-registered search listeners first, then
|
|
137
|
+
* re-register only while `showSearch` is truthy. Safe to call on connect and
|
|
138
|
+
* on every `showSearch` attribute change.
|
|
139
|
+
*/
|
|
140
|
+
_applyShowSearch: () => void;
|
|
126
141
|
disconnectedCallback(): void;
|
|
127
142
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
128
143
|
/**
|
|
@@ -33,12 +33,6 @@ var m = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
|
|
|
33
33
|
set arrow(r) {
|
|
34
34
|
a(this, "arrow", r, { removeEmpty: !0 });
|
|
35
35
|
}
|
|
36
|
-
get show() {
|
|
37
|
-
return o(this, "show");
|
|
38
|
-
}
|
|
39
|
-
set show(r) {
|
|
40
|
-
a(this, "show", r, { removeEmpty: !0 });
|
|
41
|
-
}
|
|
42
36
|
get sheet() {
|
|
43
37
|
return o(this, "sheet");
|
|
44
38
|
}
|
package/dist/dropdown.js
CHANGED
|
@@ -136,6 +136,8 @@ var b = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
|
|
|
136
136
|
if (this._icon) {
|
|
137
137
|
const t = this.size || "1em";
|
|
138
138
|
this._icon.setAttribute("width", t), this._icon.setAttribute("height", t);
|
|
139
|
+
const e = /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t;
|
|
140
|
+
this._icon.style.setProperty("width", e), this._icon.style.setProperty("height", e);
|
|
139
141
|
}
|
|
140
142
|
};
|
|
141
143
|
setColor = () => {
|
package/dist/icon.js
CHANGED