@ds-mo/ui 1.0.1 → 1.1.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.
- package/dist/components/ds-bar-nav-action.js +1 -1
- package/dist/components/ds-bar-nav.js +1 -1
- package/dist/components/ds-bar-nav.js.map +1 -1
- package/dist/components/ds-breadcrumb.js +1 -1
- package/dist/components/ds-button-group.js +1 -1
- package/dist/components/ds-button.js +1 -1
- package/dist/components/ds-card.js +1 -1
- package/dist/components/ds-card.js.map +1 -1
- package/dist/components/ds-checkbox.js +1 -1
- package/dist/components/ds-divider.js +1 -1
- package/dist/components/ds-empty-state.js +1 -1
- package/dist/components/ds-empty-state.js.map +1 -1
- package/dist/components/ds-fade.js +1 -1
- package/dist/components/ds-field.js +1 -1
- package/dist/components/ds-header.js +1 -1
- package/dist/components/ds-header.js.map +1 -1
- package/dist/components/ds-icon.js +1 -1
- package/dist/components/ds-input.js +1 -1
- package/dist/components/ds-label-wrap.js +1 -1
- package/dist/components/ds-menu.js +1 -1
- package/dist/components/ds-modal.js +1 -1
- package/dist/components/ds-panel-nav.js +1 -1
- package/dist/components/ds-radio-group.js +1 -1
- package/dist/components/ds-radio-group.js.map +1 -1
- package/dist/components/ds-scrollbar.js +1 -1
- package/dist/components/ds-select.js +1 -1
- package/dist/components/ds-slider.js +1 -1
- package/dist/components/ds-slider.js.map +1 -1
- package/dist/components/ds-surface.js +1 -1
- package/dist/components/ds-tab-group-nav.d.ts +11 -0
- package/dist/components/ds-tab-group-nav.js +2 -0
- package/dist/components/ds-tab-group-nav.js.map +1 -0
- package/dist/components/ds-tab-group.js +1 -1
- package/dist/components/ds-tab-group.js.map +1 -1
- package/dist/components/ds-table.js +1 -1
- package/dist/components/ds-table.js.map +1 -1
- package/dist/components/ds-tag.js +1 -1
- package/dist/components/ds-text.js +1 -1
- package/dist/components/ds-toast-provider.js +1 -1
- package/dist/components/ds-toggle-button-group.js +1 -1
- package/dist/components/ds-toggle-button.js +1 -1
- package/dist/components/ds-toggle.js +1 -1
- package/dist/components/ds-tooltip.js +1 -1
- package/dist/components/p-BQq26pt9.js +2 -0
- package/dist/components/p-BQq26pt9.js.map +1 -0
- package/dist/components/p-CMyQsk0K.js +2 -0
- package/dist/components/p-CMyQsk0K.js.map +1 -0
- package/dist/components/{p-D3CwGoIu.js → p-COsKOwZR.js} +2 -2
- package/dist/components/p-CpbnmEu1.js +2 -0
- package/dist/components/p-CpbnmEu1.js.map +1 -0
- package/dist/components/{p-DHF5BQbO.js → p-Dd0GrKaF.js} +2 -2
- package/dist/components/p-H89PzqGU.js +2 -0
- package/dist/components/p-H89PzqGU.js.map +1 -0
- package/dist/components/{p-Dfx0StHj.js → p-Vwlmhl4E.js} +2 -2
- package/dist/components/{p-C4p1fG67.js → p-woooYulR.js} +2 -2
- package/dist/types/.stencil/BarNav/BarNav.d.ts +7 -2
- package/dist/types/.stencil/BarNav/bar-nav-dom-utils.d.ts +1 -2
- package/dist/types/.stencil/TabGroupNav/TabGroupNav.d.ts +27 -0
- package/dist/types/components.d.ts +68 -0
- package/package.json +39 -9
- package/src/angular/index.ts +1 -0
- package/src/angular/proxies.ts +28 -0
- package/src/react/components.ts +46 -0
- package/src/react/ds-accordion.ts +27 -0
- package/src/react/ds-badge.ts +26 -0
- package/src/react/ds-banner.ts +27 -0
- package/src/react/ds-bar-nav-action.ts +27 -0
- package/src/react/ds-bar-nav.ts +33 -0
- package/src/react/ds-breadcrumb.ts +27 -0
- package/src/react/ds-button-group.ts +27 -0
- package/src/react/ds-button.ts +35 -0
- package/src/react/ds-card.ts +26 -0
- package/src/react/ds-checkbox.ts +27 -0
- package/src/react/ds-divider.ts +26 -0
- package/src/react/ds-empty-state.ts +26 -0
- package/src/react/ds-fade.ts +26 -0
- package/src/react/ds-field.ts +26 -0
- package/src/react/ds-header.ts +26 -0
- package/src/react/ds-icon.ts +26 -0
- package/src/react/ds-input.ts +33 -0
- package/src/react/ds-label-wrap.ts +26 -0
- package/src/react/ds-loader.ts +26 -0
- package/src/react/ds-menu.ts +33 -0
- package/src/react/ds-modal.ts +27 -0
- package/src/react/ds-pagination.ts +27 -0
- package/src/react/ds-panel-nav.ts +37 -0
- package/src/react/ds-radio-group.ts +27 -0
- package/src/react/ds-scrollbar.ts +26 -0
- package/src/react/ds-select.ts +27 -0
- package/src/react/ds-sidebar.ts +33 -0
- package/src/react/ds-skeleton.ts +26 -0
- package/src/react/ds-slider.ts +27 -0
- package/src/react/ds-surface.ts +26 -0
- package/src/react/ds-tab-group-nav.ts +27 -0
- package/src/react/ds-tab-group.ts +27 -0
- package/src/react/ds-table.ts +35 -0
- package/src/react/ds-tag.ts +35 -0
- package/src/react/ds-text.ts +26 -0
- package/src/react/ds-toast-provider.ts +26 -0
- package/src/react/ds-toggle-button-group.ts +27 -0
- package/src/react/ds-toggle-button.ts +27 -0
- package/src/react/ds-toggle.ts +27 -0
- package/src/react/ds-tooltip.ts +26 -0
- package/src/wc/components/Accordion/Accordion.tsx +144 -0
- package/src/wc/components/Badge/Badge.tsx +34 -0
- package/src/wc/components/Badge/index.ts +1 -0
- package/src/wc/components/Banner/Banner.tsx +148 -0
- package/src/wc/components/BarNav/BarNav.tsx +605 -0
- package/src/wc/components/BarNav/bar-nav-dom-utils.ts +23 -0
- package/src/wc/components/BarNav/bar-nav-tabs-menu-utils.ts +59 -0
- package/src/wc/components/BarNav/bar-nav-utils.ts +76 -0
- package/src/wc/components/BarNav/index.ts +1 -0
- package/src/wc/components/BarNavAction/BarNavAction.tsx +67 -0
- package/src/wc/components/BarNavAction/index.ts +1 -0
- package/src/wc/components/Breadcrumb/Breadcrumb.tsx +61 -0
- package/src/wc/components/Button/Button.tsx +158 -0
- package/src/wc/components/Button/index.ts +1 -0
- package/src/wc/components/ButtonGroup/ButtonGroup.tsx +110 -0
- package/src/wc/components/Card/Card.tsx +26 -0
- package/src/wc/components/Checkbox/Checkbox.tsx +60 -0
- package/src/wc/components/Checkbox/index.ts +1 -0
- package/src/wc/components/Divider/Divider.tsx +23 -0
- package/src/wc/components/Divider/index.ts +2 -0
- package/src/wc/components/EmptyState/EmptyState.tsx +32 -0
- package/src/wc/components/Fade/Fade.tsx +32 -0
- package/src/wc/components/Fade/index.ts +1 -0
- package/src/wc/components/Field/Field.tsx +28 -0
- package/src/wc/components/Header/Header.tsx +33 -0
- package/src/wc/components/Icon/Icon.tsx +112 -0
- package/src/wc/components/Icon/flag-icon-catalog.ts +68 -0
- package/src/wc/components/Icon/index.ts +1 -0
- package/src/wc/components/Icon/system-icon-catalog.ts +798 -0
- package/src/wc/components/Input/Input.tsx +100 -0
- package/src/wc/components/Input/index.ts +1 -0
- package/src/wc/components/LabelWrap/LabelWrap.tsx +38 -0
- package/src/wc/components/Loader/Loader.tsx +47 -0
- package/src/wc/components/Loader/index.ts +1 -0
- package/src/wc/components/Menu/Menu.tsx +340 -0
- package/src/wc/components/Modal/Modal.tsx +197 -0
- package/src/wc/components/Pagination/Pagination.tsx +97 -0
- package/src/wc/components/PanelNav/PanelNav.tsx +666 -0
- package/src/wc/components/PanelNav/index.ts +7 -0
- package/src/wc/components/PanelNav/panel-nav-utils.ts +124 -0
- package/src/wc/components/RadioGroup/RadioGroup.tsx +128 -0
- package/src/wc/components/RadioGroup/index.ts +1 -0
- package/src/wc/components/Scrollbar/Scrollbar.tsx +189 -0
- package/src/wc/components/Select/Select.tsx +195 -0
- package/src/wc/components/Sidebar/Sidebar.tsx +245 -0
- package/src/wc/components/Skeleton/Skeleton.tsx +64 -0
- package/src/wc/components/Skeleton/index.ts +1 -0
- package/src/wc/components/Slider/Slider.tsx +68 -0
- package/src/wc/components/Slider/index.ts +1 -0
- package/src/wc/components/Surface/Surface.tsx +81 -0
- package/src/wc/components/TabGroup/TabGroup.tsx +188 -0
- package/src/wc/components/TabGroup/tab-item-utils.ts +24 -0
- package/src/wc/components/TabGroupNav/TabGroupNav.tsx +188 -0
- package/src/wc/components/Table/Table.tsx +268 -0
- package/src/wc/components/Tag/Tag.tsx +135 -0
- package/src/wc/components/Tag/index.ts +1 -0
- package/src/wc/components/Text/Text.tsx +100 -0
- package/src/wc/components/Text/index.ts +1 -0
- package/src/wc/components/Toast/Toast.tsx +174 -0
- package/src/wc/components/Toast/toast-service.ts +60 -0
- package/src/wc/components/Toggle/Toggle.tsx +43 -0
- package/src/wc/components/Toggle/index.ts +1 -0
- package/src/wc/components/ToggleButton/ToggleButton.tsx +120 -0
- package/src/wc/components/ToggleButtonGroup/ToggleButtonGroup.tsx +118 -0
- package/src/wc/components/Tooltip/Tooltip.tsx +196 -0
- package/src/wc/components.d.ts +3028 -0
- package/dist/components/p-DV8pmt1m.js +0 -2
- package/dist/components/p-DV8pmt1m.js.map +0 -1
- package/dist/components/p-Dqga4VCz.js +0 -2
- package/dist/components/p-Dqga4VCz.js.map +0 -1
- package/dist/components/p-STnE_bmQ.js +0 -2
- package/dist/components/p-STnE_bmQ.js.map +0 -1
- /package/dist/components/{p-D3CwGoIu.js.map → p-COsKOwZR.js.map} +0 -0
- /package/dist/components/{p-DHF5BQbO.js.map → p-Dd0GrKaF.js.map} +0 -0
- /package/dist/components/{p-Dfx0StHj.js.map → p-Vwlmhl4E.js.map} +0 -0
- /package/dist/components/{p-C4p1fG67.js.map → p-woooYulR.js.map} +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Component, Prop, State, Element, Watch, h, Host } from '@stencil/core';
|
|
2
|
+
|
|
3
|
+
export type TooltipSide = 'top' | 'right' | 'bottom' | 'left';
|
|
4
|
+
export type TooltipAlign = 'start' | 'center' | 'end';
|
|
5
|
+
|
|
6
|
+
const HOVER_DELAY_MS = 600;
|
|
7
|
+
const INSTANT_REOPEN_MS = 300;
|
|
8
|
+
const FADE_OUT_MS = 200;
|
|
9
|
+
const VP_PAD = 4;
|
|
10
|
+
|
|
11
|
+
let lastDismissedAt = 0;
|
|
12
|
+
let tooltipIdCounter = 0;
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
tag: 'ds-tooltip',
|
|
16
|
+
styleUrl: 'Tooltip.css',
|
|
17
|
+
scoped: true,
|
|
18
|
+
})
|
|
19
|
+
export class Tooltip {
|
|
20
|
+
@Element() el!: HTMLElement;
|
|
21
|
+
|
|
22
|
+
@Prop() label!: string;
|
|
23
|
+
@Prop() side: TooltipSide = 'top';
|
|
24
|
+
@Prop() align: TooltipAlign = 'center';
|
|
25
|
+
@Prop() sideOffset: number = 4;
|
|
26
|
+
@Prop() alignOffset: number = 0;
|
|
27
|
+
@Prop() delay: number = HOVER_DELAY_MS;
|
|
28
|
+
@Prop() shortcutKey: string | undefined;
|
|
29
|
+
@Prop() shortcutKeyPosition: 'start' | 'end' = 'end';
|
|
30
|
+
|
|
31
|
+
@State() private visible: boolean = false;
|
|
32
|
+
@State() private closing: boolean = false;
|
|
33
|
+
@State() private pos: { x: number; y: number } = { x: 0, y: 0 };
|
|
34
|
+
|
|
35
|
+
private tooltipId = `ds-tooltip-${++tooltipIdCounter}`;
|
|
36
|
+
private delayTimer: ReturnType<typeof setTimeout> | null = null;
|
|
37
|
+
private closeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
38
|
+
private anchor: HTMLElement | null = null;
|
|
39
|
+
private tooltipEl: HTMLElement | null = null;
|
|
40
|
+
private mouseEnterHandler: () => void = () => this.show();
|
|
41
|
+
private mouseLeaveHandler: () => void = () => this.hide();
|
|
42
|
+
private focusHandler: () => void = () => this.show();
|
|
43
|
+
private blurHandler: () => void = () => this.hide();
|
|
44
|
+
|
|
45
|
+
componentDidLoad() {
|
|
46
|
+
this.bindAnchor();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
this.unbindAnchor();
|
|
51
|
+
this.clearTimers();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Watch('label')
|
|
55
|
+
@Watch('side')
|
|
56
|
+
@Watch('align')
|
|
57
|
+
onPositionPropsChange() {
|
|
58
|
+
if (this.visible) this.calculatePosition();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private bindAnchor() {
|
|
62
|
+
const slot = this.el.querySelector('slot') as HTMLSlotElement | null;
|
|
63
|
+
const slotted = slot?.assignedElements?.() ?? [];
|
|
64
|
+
const child = (slotted[0] ?? this.el.firstElementChild) as HTMLElement | null;
|
|
65
|
+
if (!child) return;
|
|
66
|
+
this.anchor = child;
|
|
67
|
+
child.setAttribute('aria-describedby', this.tooltipId);
|
|
68
|
+
child.addEventListener('mouseenter', this.mouseEnterHandler);
|
|
69
|
+
child.addEventListener('mouseleave', this.mouseLeaveHandler);
|
|
70
|
+
child.addEventListener('focus', this.focusHandler);
|
|
71
|
+
child.addEventListener('blur', this.blurHandler);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private unbindAnchor() {
|
|
75
|
+
if (!this.anchor) return;
|
|
76
|
+
this.anchor.removeAttribute('aria-describedby');
|
|
77
|
+
this.anchor.removeEventListener('mouseenter', this.mouseEnterHandler);
|
|
78
|
+
this.anchor.removeEventListener('mouseleave', this.mouseLeaveHandler);
|
|
79
|
+
this.anchor.removeEventListener('focus', this.focusHandler);
|
|
80
|
+
this.anchor.removeEventListener('blur', this.blurHandler);
|
|
81
|
+
this.anchor = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private clearTimers() {
|
|
85
|
+
if (this.delayTimer) { clearTimeout(this.delayTimer); this.delayTimer = null; }
|
|
86
|
+
if (this.closeTimer) { clearTimeout(this.closeTimer); this.closeTimer = null; }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private show() {
|
|
90
|
+
this.clearTimers();
|
|
91
|
+
const instant = Date.now() - lastDismissedAt < INSTANT_REOPEN_MS;
|
|
92
|
+
if (instant) {
|
|
93
|
+
this.closing = false;
|
|
94
|
+
this.visible = true;
|
|
95
|
+
requestAnimationFrame(() => this.calculatePosition());
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.delayTimer = setTimeout(() => {
|
|
99
|
+
this.delayTimer = null;
|
|
100
|
+
this.closing = false;
|
|
101
|
+
this.visible = true;
|
|
102
|
+
requestAnimationFrame(() => this.calculatePosition());
|
|
103
|
+
}, this.delay);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private hide() {
|
|
107
|
+
this.clearTimers();
|
|
108
|
+
if (!this.visible) return;
|
|
109
|
+
lastDismissedAt = Date.now();
|
|
110
|
+
this.closing = true;
|
|
111
|
+
this.closeTimer = setTimeout(() => {
|
|
112
|
+
this.closeTimer = null;
|
|
113
|
+
this.visible = false;
|
|
114
|
+
this.closing = false;
|
|
115
|
+
}, FADE_OUT_MS);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private calculatePosition() {
|
|
119
|
+
if (!this.anchor) return;
|
|
120
|
+
const tip = this.el.querySelector('.tooltip-popup') as HTMLElement | null;
|
|
121
|
+
if (!tip) return;
|
|
122
|
+
const a = this.anchor.getBoundingClientRect();
|
|
123
|
+
const tw = tip.offsetWidth || 80;
|
|
124
|
+
const th = tip.offsetHeight || 24;
|
|
125
|
+
let x = 0, y = 0;
|
|
126
|
+
|
|
127
|
+
switch (this.side) {
|
|
128
|
+
case 'top':
|
|
129
|
+
y = a.top - th - this.sideOffset;
|
|
130
|
+
x = this.align === 'start' ? a.left + this.alignOffset
|
|
131
|
+
: this.align === 'end' ? a.right - tw + this.alignOffset
|
|
132
|
+
: a.left + a.width / 2 - tw / 2 + this.alignOffset;
|
|
133
|
+
break;
|
|
134
|
+
case 'bottom':
|
|
135
|
+
y = a.bottom + this.sideOffset;
|
|
136
|
+
x = this.align === 'start' ? a.left + this.alignOffset
|
|
137
|
+
: this.align === 'end' ? a.right - tw + this.alignOffset
|
|
138
|
+
: a.left + a.width / 2 - tw / 2 + this.alignOffset;
|
|
139
|
+
break;
|
|
140
|
+
case 'left':
|
|
141
|
+
x = a.left - tw - this.sideOffset;
|
|
142
|
+
y = this.align === 'start' ? a.top + this.alignOffset
|
|
143
|
+
: this.align === 'end' ? a.bottom - th + this.alignOffset
|
|
144
|
+
: a.top + a.height / 2 - th / 2 + this.alignOffset;
|
|
145
|
+
break;
|
|
146
|
+
case 'right':
|
|
147
|
+
x = a.right + this.sideOffset;
|
|
148
|
+
y = this.align === 'start' ? a.top + this.alignOffset
|
|
149
|
+
: this.align === 'end' ? a.bottom - th + this.alignOffset
|
|
150
|
+
: a.top + a.height / 2 - th / 2 + this.alignOffset;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.pos = {
|
|
155
|
+
x: Math.min(Math.max(x, VP_PAD), window.innerWidth - tw - VP_PAD),
|
|
156
|
+
y: Math.min(Math.max(y, VP_PAD), window.innerHeight - th - VP_PAD),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
render() {
|
|
161
|
+
return (
|
|
162
|
+
<Host style={{ display: 'contents' }}>
|
|
163
|
+
<slot />
|
|
164
|
+
{(this.visible || this.closing) && (
|
|
165
|
+
<div
|
|
166
|
+
id={this.tooltipId}
|
|
167
|
+
class={{ 'tooltip-popup': true, 'tooltip-popup--closing': this.closing }}
|
|
168
|
+
role="tooltip"
|
|
169
|
+
style={{
|
|
170
|
+
position: 'fixed',
|
|
171
|
+
left: '0',
|
|
172
|
+
top: '0',
|
|
173
|
+
transform: `translate(${Math.round(this.pos.x)}px, ${Math.round(this.pos.y)}px)`,
|
|
174
|
+
zIndex: '10000',
|
|
175
|
+
pointerEvents: 'none',
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<div class="tooltip-inner">
|
|
179
|
+
{this.shortcutKey && this.shortcutKeyPosition === 'start' && (
|
|
180
|
+
<div class="key-hint" aria-hidden="true">
|
|
181
|
+
<span class="text-caption-emphasis">{this.shortcutKey}</span>
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
<span class="text-body-small">{this.label}</span>
|
|
185
|
+
{this.shortcutKey && this.shortcutKeyPosition === 'end' && (
|
|
186
|
+
<div class="key-hint" aria-hidden="true">
|
|
187
|
+
<span class="text-caption-emphasis">{this.shortcutKey}</span>
|
|
188
|
+
</div>
|
|
189
|
+
)}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
</Host>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|