@haiyue/ui 0.1.2 → 0.2.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/CHANGELOG.md +28 -1
- package/README.md +444 -1
- package/dist/adapters/web/controls.d.ts +19 -0
- package/dist/adapters/web/controls.js +284 -0
- package/dist/adapters/web/dom.d.ts +10 -0
- package/dist/adapters/web/dom.js +98 -0
- package/dist/adapters/web/index.d.ts +3 -0
- package/dist/adapters/web/index.js +3 -0
- package/dist/adapters/web/renderer.d.ts +18 -0
- package/dist/adapters/web/renderer.js +545 -0
- package/dist/adapters/web/styles.d.ts +3 -0
- package/dist/adapters/web/styles.js +62 -0
- package/dist/adapters/web/types.d.ts +46 -0
- package/dist/adapters/web/types.js +2 -0
- package/dist/affix.d.ts +35 -0
- package/dist/affix.js +137 -0
- package/dist/badge.d.ts +45 -0
- package/dist/badge.js +168 -0
- package/dist/breadcrumb.d.ts +37 -0
- package/dist/breadcrumb.js +210 -0
- package/dist/button-group.d.ts +12 -0
- package/dist/button-group.js +72 -0
- package/dist/button.d.ts +15 -1
- package/dist/button.js +101 -12
- package/dist/cascader.d.ts +65 -0
- package/dist/cascader.js +479 -0
- package/dist/collapse.d.ts +55 -0
- package/dist/collapse.js +261 -0
- package/dist/core/actions.d.ts +32 -0
- package/dist/core/actions.js +145 -0
- package/dist/core/data.d.ts +4 -0
- package/dist/core/data.js +27 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +6 -0
- package/dist/core/platform-view.d.ts +17 -0
- package/dist/core/platform-view.js +84 -0
- package/dist/core/selection.d.ts +14 -0
- package/dist/core/selection.js +93 -0
- package/dist/core/text.d.ts +31 -0
- package/dist/core/text.js +154 -0
- package/dist/core/types.d.ts +250 -0
- package/dist/core/types.js +2 -0
- package/dist/core/validation.d.ts +24 -0
- package/dist/core/validation.js +238 -0
- package/dist/date-picker.d.ts +60 -0
- package/dist/date-picker.js +355 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.js +23 -5
- package/dist/divider.d.ts +33 -0
- package/dist/divider.js +113 -0
- package/dist/draggable.d.ts +78 -0
- package/dist/draggable.js +255 -0
- package/dist/index.d.ts +45 -1
- package/dist/index.js +66 -0
- package/dist/input.d.ts +30 -1
- package/dist/input.js +166 -54
- package/dist/portable/index.d.ts +4 -0
- package/dist/portable/index.js +3 -0
- package/dist/portable/page.d.ts +38 -0
- package/dist/portable/page.js +361 -0
- package/dist/portable/theme.d.ts +19 -0
- package/dist/portable/theme.js +40 -0
- package/dist/portable/tree.d.ts +10 -0
- package/dist/portable/tree.js +96 -0
- package/dist/range.d.ts +3 -0
- package/dist/range.js +16 -5
- package/dist/rate.d.ts +46 -0
- package/dist/rate.js +193 -0
- package/dist/resizable.d.ts +97 -0
- package/dist/resizable.js +426 -0
- package/dist/skeleton.d.ts +41 -0
- package/dist/skeleton.js +141 -0
- package/dist/steps.d.ts +45 -0
- package/dist/steps.js +203 -0
- package/dist/table.d.ts +106 -0
- package/dist/table.js +689 -0
- package/dist/tabs.d.ts +3 -0
- package/dist/tabs.js +11 -1
- package/dist/tag.d.ts +55 -0
- package/dist/tag.js +225 -0
- package/dist/time-picker.d.ts +62 -0
- package/dist/time-picker.js +298 -0
- package/dist/timeline.d.ts +48 -0
- package/dist/timeline.js +201 -0
- package/dist/toast.d.ts +55 -0
- package/dist/toast.js +224 -0
- package/dist/tour.d.ts +89 -0
- package/dist/tour.js +306 -0
- package/dist/virtual-keyboard.d.ts +95 -0
- package/dist/virtual-keyboard.js +432 -0
- package/dist/virtual-mouse.d.ts +82 -0
- package/dist/virtual-mouse.js +358 -0
- package/dist/watermark.d.ts +44 -0
- package/dist/watermark.js +148 -0
- package/package.json +115 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class HYButtonGroup extends HTMLElement {
|
|
2
|
+
_group = document.createElement('div');
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ['orientation', 'aria-label'];
|
|
5
|
+
}
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const root = this.attachShadow({ mode: 'open' });
|
|
9
|
+
const style = document.createElement('style');
|
|
10
|
+
style.textContent = `
|
|
11
|
+
:host { display: inline-flex; max-width: 100%; }
|
|
12
|
+
.group { display: inline-flex; align-items: stretch; max-width: 100%; }
|
|
13
|
+
:host([orientation="vertical"]) .group { flex-direction: column; }
|
|
14
|
+
::slotted(hy-button) {
|
|
15
|
+
position: relative;
|
|
16
|
+
display: block;
|
|
17
|
+
--hy-button-radius: 0;
|
|
18
|
+
}
|
|
19
|
+
:host(:not([orientation="vertical"])) ::slotted(hy-button:not(:first-child)) { margin-left: -1px; }
|
|
20
|
+
:host(:not([orientation="vertical"])) ::slotted(hy-button:first-child) {
|
|
21
|
+
--hy-button-radius-top-left: var(--hy-button-group-radius, 4px);
|
|
22
|
+
--hy-button-radius-bottom-left: var(--hy-button-group-radius, 4px);
|
|
23
|
+
}
|
|
24
|
+
:host(:not([orientation="vertical"])) ::slotted(hy-button:last-child) {
|
|
25
|
+
--hy-button-radius-top-right: var(--hy-button-group-radius, 4px);
|
|
26
|
+
--hy-button-radius-bottom-right: var(--hy-button-group-radius, 4px);
|
|
27
|
+
}
|
|
28
|
+
:host([orientation="vertical"]) ::slotted(hy-button:not(:first-child)) { margin-top: -1px; }
|
|
29
|
+
:host([orientation="vertical"]) ::slotted(hy-button:first-child) {
|
|
30
|
+
--hy-button-radius-top-left: var(--hy-button-group-radius, 4px);
|
|
31
|
+
--hy-button-radius-top-right: var(--hy-button-group-radius, 4px);
|
|
32
|
+
}
|
|
33
|
+
:host([orientation="vertical"]) ::slotted(hy-button:last-child) {
|
|
34
|
+
--hy-button-radius-bottom-left: var(--hy-button-group-radius, 4px);
|
|
35
|
+
--hy-button-radius-bottom-right: var(--hy-button-group-radius, 4px);
|
|
36
|
+
}
|
|
37
|
+
::slotted(hy-button:hover), ::slotted(hy-button:focus-within) { z-index: 1; }
|
|
38
|
+
`;
|
|
39
|
+
this._group.className = 'group';
|
|
40
|
+
this._group.part.add('group');
|
|
41
|
+
this._group.setAttribute('role', 'group');
|
|
42
|
+
this._group.append(document.createElement('slot'));
|
|
43
|
+
root.append(style, this._group);
|
|
44
|
+
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
if (!this.hasAttribute('orientation'))
|
|
47
|
+
this.setAttribute('orientation', 'horizontal');
|
|
48
|
+
this._sync();
|
|
49
|
+
}
|
|
50
|
+
attributeChangedCallback() {
|
|
51
|
+
this._sync();
|
|
52
|
+
}
|
|
53
|
+
get orientation() {
|
|
54
|
+
return this.getAttribute('orientation') === 'vertical' ? 'vertical' : 'horizontal';
|
|
55
|
+
}
|
|
56
|
+
set orientation(value) {
|
|
57
|
+
this.setAttribute('orientation', value === 'vertical' ? 'vertical' : 'horizontal');
|
|
58
|
+
}
|
|
59
|
+
_sync() {
|
|
60
|
+
const label = this.getAttribute('aria-label');
|
|
61
|
+
if (label)
|
|
62
|
+
this._group.setAttribute('aria-label', label);
|
|
63
|
+
else
|
|
64
|
+
this._group.removeAttribute('aria-label');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function defineButtonGroupComponents() {
|
|
68
|
+
if (!customElements.get('hy-button-group')) {
|
|
69
|
+
customElements.define('hy-button-group', HYButtonGroup);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=button-group.js.map
|
package/dist/button.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
export type HYButtonIconPosition = 'start' | 'end';
|
|
1
2
|
export declare class HYButton extends HTMLElement {
|
|
2
3
|
private readonly _button;
|
|
3
|
-
private readonly
|
|
4
|
+
private readonly _content;
|
|
5
|
+
private readonly _contentSlot;
|
|
6
|
+
private readonly _icon;
|
|
7
|
+
private readonly _iconSlot;
|
|
8
|
+
private readonly _iconFallback;
|
|
9
|
+
private readonly _spinner;
|
|
4
10
|
static get observedAttributes(): string[];
|
|
5
11
|
constructor();
|
|
6
12
|
connectedCallback(): void;
|
|
7
13
|
attributeChangedCallback(): void;
|
|
14
|
+
get loading(): boolean;
|
|
15
|
+
set loading(value: boolean);
|
|
16
|
+
get icon(): string;
|
|
17
|
+
set icon(value: string);
|
|
18
|
+
get iconPosition(): HYButtonIconPosition;
|
|
19
|
+
set iconPosition(value: HYButtonIconPosition);
|
|
20
|
+
click(): void;
|
|
8
21
|
private _sync;
|
|
22
|
+
private _syncIcon;
|
|
9
23
|
}
|
|
10
24
|
export declare function defineButtonComponents(): void;
|
package/dist/button.js
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
export class HYButton extends HTMLElement {
|
|
2
2
|
_button = document.createElement('button');
|
|
3
|
-
|
|
3
|
+
_content = document.createElement('span');
|
|
4
|
+
_contentSlot = document.createElement('slot');
|
|
5
|
+
_icon = document.createElement('span');
|
|
6
|
+
_iconSlot = document.createElement('slot');
|
|
7
|
+
_iconFallback = document.createElement('span');
|
|
8
|
+
_spinner = document.createElement('span');
|
|
4
9
|
static get observedAttributes() {
|
|
5
|
-
return ['label', 'disabled', 'aria-label', 'title', 'icon-only'];
|
|
10
|
+
return ['label', 'disabled', 'aria-label', 'aria-pressed', 'title', 'icon-only', 'icon', 'icon-position', 'loading'];
|
|
6
11
|
}
|
|
7
12
|
constructor() {
|
|
8
13
|
super();
|
|
9
14
|
const root = this.attachShadow({ mode: 'open' });
|
|
10
15
|
const style = document.createElement('style');
|
|
11
16
|
style.textContent = `
|
|
12
|
-
:host { display: inline-block; }
|
|
17
|
+
:host { display: inline-block; min-width: 0; }
|
|
13
18
|
button {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
gap: var(--hy-button-icon-gap, 7px);
|
|
23
|
+
width: 100%;
|
|
14
24
|
min-height: 28px;
|
|
15
25
|
padding: 0 10px;
|
|
16
26
|
border: 1px solid var(--hy-border-color, #3d4654);
|
|
17
|
-
border-radius:
|
|
27
|
+
border-radius:
|
|
28
|
+
var(--hy-button-radius-top-left, var(--hy-button-radius, 4px))
|
|
29
|
+
var(--hy-button-radius-top-right, var(--hy-button-radius, 4px))
|
|
30
|
+
var(--hy-button-radius-bottom-right, var(--hy-button-radius, 4px))
|
|
31
|
+
var(--hy-button-radius-bottom-left, var(--hy-button-radius, 4px));
|
|
18
32
|
background: var(--hy-surface-elevated-color, #202733);
|
|
19
33
|
color: var(--hy-text-color, #eef3ff);
|
|
20
34
|
font: 12px system-ui, sans-serif;
|
|
@@ -31,9 +45,21 @@ export class HYButton extends HTMLElement {
|
|
|
31
45
|
button.icon-only {
|
|
32
46
|
width: 28px;
|
|
33
47
|
padding: 0;
|
|
34
|
-
|
|
35
|
-
place-items: center;
|
|
48
|
+
gap: 0;
|
|
36
49
|
}
|
|
50
|
+
.icon { display: inline-grid; flex: 0 0 auto; place-items: center; line-height: 1; }
|
|
51
|
+
button.icon-end .icon { order: 2; }
|
|
52
|
+
.icon[hidden], .spinner[hidden] { display: none; }
|
|
53
|
+
.spinner {
|
|
54
|
+
width: var(--hy-button-loading-size, 14px);
|
|
55
|
+
height: var(--hy-button-loading-size, 14px);
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
border: var(--hy-button-loading-stroke, 2px) solid color-mix(in srgb, currentColor 28%, transparent);
|
|
58
|
+
border-top-color: currentColor;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
animation: hy-button-spin var(--hy-button-loading-duration, 0.72s) linear infinite;
|
|
61
|
+
}
|
|
62
|
+
@keyframes hy-button-spin { to { transform: rotate(360deg); } }
|
|
37
63
|
::slotted(svg) {
|
|
38
64
|
width: 16px;
|
|
39
65
|
height: 16px;
|
|
@@ -48,7 +74,26 @@ export class HYButton extends HTMLElement {
|
|
|
48
74
|
opacity: 0.5;
|
|
49
75
|
cursor: default;
|
|
50
76
|
}
|
|
77
|
+
@media (prefers-reduced-motion: reduce) {
|
|
78
|
+
.spinner { animation-duration: 1.5s; }
|
|
79
|
+
}
|
|
51
80
|
`;
|
|
81
|
+
this._button.type = 'button';
|
|
82
|
+
this._button.part.add('button');
|
|
83
|
+
this._content.className = 'content';
|
|
84
|
+
this._content.part.add('content');
|
|
85
|
+
this._icon.className = 'icon';
|
|
86
|
+
this._icon.part.add('icon');
|
|
87
|
+
this._iconSlot.name = 'icon';
|
|
88
|
+
this._iconFallback.className = 'icon-fallback';
|
|
89
|
+
this._spinner.className = 'spinner';
|
|
90
|
+
this._spinner.part.add('spinner');
|
|
91
|
+
this._spinner.setAttribute('aria-hidden', 'true');
|
|
92
|
+
this._iconSlot.append(this._iconFallback);
|
|
93
|
+
this._icon.append(this._iconSlot, this._spinner);
|
|
94
|
+
this._content.append(this._contentSlot);
|
|
95
|
+
this._button.append(this._icon, this._content);
|
|
96
|
+
this._iconSlot.addEventListener('slotchange', () => this._syncIcon());
|
|
52
97
|
root.append(style, this._button);
|
|
53
98
|
}
|
|
54
99
|
connectedCallback() {
|
|
@@ -57,24 +102,68 @@ export class HYButton extends HTMLElement {
|
|
|
57
102
|
attributeChangedCallback() {
|
|
58
103
|
this._sync();
|
|
59
104
|
}
|
|
105
|
+
get loading() {
|
|
106
|
+
return this.hasAttribute('loading');
|
|
107
|
+
}
|
|
108
|
+
set loading(value) {
|
|
109
|
+
this.toggleAttribute('loading', Boolean(value));
|
|
110
|
+
}
|
|
111
|
+
get icon() {
|
|
112
|
+
return this.getAttribute('icon') ?? '';
|
|
113
|
+
}
|
|
114
|
+
set icon(value) {
|
|
115
|
+
if (value)
|
|
116
|
+
this.setAttribute('icon', value);
|
|
117
|
+
else
|
|
118
|
+
this.removeAttribute('icon');
|
|
119
|
+
}
|
|
120
|
+
get iconPosition() {
|
|
121
|
+
return this.getAttribute('icon-position') === 'end' ? 'end' : 'start';
|
|
122
|
+
}
|
|
123
|
+
set iconPosition(value) {
|
|
124
|
+
this.setAttribute('icon-position', value === 'end' ? 'end' : 'start');
|
|
125
|
+
}
|
|
126
|
+
click() {
|
|
127
|
+
this._button.click();
|
|
128
|
+
}
|
|
60
129
|
_sync() {
|
|
61
130
|
const label = this.getAttribute('label');
|
|
62
131
|
if (label !== null) {
|
|
63
|
-
this.
|
|
64
|
-
|
|
132
|
+
if (this._content.textContent !== label || this._content.firstChild === this._contentSlot)
|
|
133
|
+
this._content.textContent = label;
|
|
65
134
|
this._button.removeAttribute('aria-label');
|
|
66
135
|
}
|
|
67
136
|
else {
|
|
68
|
-
if (this.
|
|
69
|
-
this.
|
|
70
|
-
this._button.classList.toggle('icon-only', this.hasAttribute('icon-only'));
|
|
137
|
+
if (this._content.firstChild !== this._contentSlot)
|
|
138
|
+
this._content.replaceChildren(this._contentSlot);
|
|
71
139
|
const accessibleLabel = this.getAttribute('aria-label') ?? this.getAttribute('title') ?? '';
|
|
72
140
|
if (accessibleLabel)
|
|
73
141
|
this._button.setAttribute('aria-label', accessibleLabel);
|
|
74
142
|
else
|
|
75
143
|
this._button.removeAttribute('aria-label');
|
|
76
144
|
}
|
|
77
|
-
|
|
145
|
+
const loading = this.loading;
|
|
146
|
+
this._button.classList.toggle('icon-only', label === null && this.hasAttribute('icon-only'));
|
|
147
|
+
this._button.classList.toggle('icon-end', this.iconPosition === 'end');
|
|
148
|
+
this._button.disabled = this.hasAttribute('disabled') || loading;
|
|
149
|
+
if (loading)
|
|
150
|
+
this._button.setAttribute('aria-busy', 'true');
|
|
151
|
+
else
|
|
152
|
+
this._button.removeAttribute('aria-busy');
|
|
153
|
+
const pressed = this.getAttribute('aria-pressed');
|
|
154
|
+
if (pressed === 'true' || pressed === 'false' || pressed === 'mixed')
|
|
155
|
+
this._button.setAttribute('aria-pressed', pressed);
|
|
156
|
+
else
|
|
157
|
+
this._button.removeAttribute('aria-pressed');
|
|
158
|
+
this._syncIcon();
|
|
159
|
+
}
|
|
160
|
+
_syncIcon() {
|
|
161
|
+
const loading = this.loading;
|
|
162
|
+
const assignedIcon = this._iconSlot.assignedNodes({ flatten: true }).some(node => node.nodeType !== Node.TEXT_NODE || Boolean(node.textContent?.trim()));
|
|
163
|
+
this._iconFallback.textContent = this.icon;
|
|
164
|
+
this._iconSlot.hidden = loading;
|
|
165
|
+
this._spinner.hidden = !loading;
|
|
166
|
+
this._icon.hidden = !loading && !this.icon && !assignedIcon;
|
|
78
167
|
}
|
|
79
168
|
}
|
|
80
169
|
export function defineButtonComponents() {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type HYCascaderValue = string | number;
|
|
2
|
+
export interface HYCascaderOption {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly value: HYCascaderValue;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
readonly children?: readonly HYCascaderOption[];
|
|
7
|
+
}
|
|
8
|
+
export interface HYCascaderChangeDetail {
|
|
9
|
+
readonly value: readonly HYCascaderValue[];
|
|
10
|
+
readonly options: readonly HYCascaderOption[];
|
|
11
|
+
}
|
|
12
|
+
export interface HYCascaderOpenChangeDetail {
|
|
13
|
+
readonly open: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Tree-backed cascading dropdown that commits a complete value path. */
|
|
16
|
+
export declare class HYCascader extends HTMLElement {
|
|
17
|
+
private readonly _control;
|
|
18
|
+
private readonly _trigger;
|
|
19
|
+
private readonly _label;
|
|
20
|
+
private readonly _arrow;
|
|
21
|
+
private readonly _clear;
|
|
22
|
+
private readonly _panel;
|
|
23
|
+
private readonly _panelId;
|
|
24
|
+
private _options;
|
|
25
|
+
private _value;
|
|
26
|
+
private _activePath;
|
|
27
|
+
private _reflecting;
|
|
28
|
+
private _outsideAbort;
|
|
29
|
+
static get observedAttributes(): string[];
|
|
30
|
+
constructor();
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
34
|
+
get options(): readonly HYCascaderOption[];
|
|
35
|
+
set options(value: readonly HYCascaderOption[]);
|
|
36
|
+
get value(): readonly HYCascaderValue[];
|
|
37
|
+
set value(value: readonly HYCascaderValue[]);
|
|
38
|
+
get open(): boolean;
|
|
39
|
+
set open(value: boolean);
|
|
40
|
+
get disabled(): boolean;
|
|
41
|
+
set disabled(value: boolean);
|
|
42
|
+
get clearable(): boolean;
|
|
43
|
+
set clearable(value: boolean);
|
|
44
|
+
get changeOnSelect(): boolean;
|
|
45
|
+
set changeOnSelect(value: boolean);
|
|
46
|
+
get placeholder(): string;
|
|
47
|
+
set placeholder(value: string);
|
|
48
|
+
get displaySeparator(): string;
|
|
49
|
+
set displaySeparator(value: string);
|
|
50
|
+
private _syncAttributes;
|
|
51
|
+
private _readOptionsAttribute;
|
|
52
|
+
private _readValueAttribute;
|
|
53
|
+
private _reflectValue;
|
|
54
|
+
private _normalizePath;
|
|
55
|
+
private _resolveOptions;
|
|
56
|
+
private _render;
|
|
57
|
+
private _renderPanel;
|
|
58
|
+
private _createOption;
|
|
59
|
+
private _activateOption;
|
|
60
|
+
private _commit;
|
|
61
|
+
private _handleOptionKeydown;
|
|
62
|
+
private _syncOutsideListener;
|
|
63
|
+
private _dispatchOpenChange;
|
|
64
|
+
}
|
|
65
|
+
export declare function defineCascaderComponents(): void;
|