@sondor-technology/sondor-components 1.0.7 → 1.0.8
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/calendar/calendar.d.ts +36 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +439 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/cron-builder/cron-builder.d.ts +34 -0
- package/dist/components/cron-builder/cron-builder.d.ts.map +1 -0
- package/dist/components/cron-builder/cron-builder.js +456 -0
- package/dist/components/cron-builder/cron-builder.js.map +1 -0
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +35 -12
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/pin-input/pin-input.d.ts +33 -0
- package/dist/components/pin-input/pin-input.d.ts.map +1 -0
- package/dist/components/pin-input/pin-input.js +253 -0
- package/dist/components/pin-input/pin-input.js.map +1 -0
- package/dist/components/popover/popover.d.ts +26 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +196 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/select/select.d.ts +4 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +26 -4
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/time-picker/time-picker.d.ts +38 -0
- package/dist/components/time-picker/time-picker.d.ts.map +1 -0
- package/dist/components/time-picker/time-picker.js +280 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/toggle-group/toggle-button.d.ts +23 -0
- package/dist/components/toggle-group/toggle-button.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-button.js +115 -0
- package/dist/components/toggle-group/toggle-button.js.map +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +32 -0
- package/dist/components/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-group.js +150 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +33 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +293 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/styles/index.css +1 -0
- package/package.json +29 -1
- package/src/components/calendar/calendar.ts +444 -0
- package/src/components/cron-builder/cron-builder.ts +452 -0
- package/src/components/input/input.ts +38 -14
- package/src/components/pin-input/pin-input.ts +249 -0
- package/src/components/popover/popover.ts +192 -0
- package/src/components/select/select.ts +25 -63
- package/src/components/time-picker/time-picker.ts +272 -0
- package/src/components/toggle-group/toggle-button.ts +104 -0
- package/src/components/toggle-group/toggle-group.ts +148 -0
- package/src/components/tooltip/tooltip.ts +286 -0
- package/src/styles/theme.css +2 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import {LitElement, html, css, PropertyValues} from "lit";
|
|
2
|
+
import {customElement, property, state, queryAssignedElements} from "lit/decorators.js";
|
|
3
|
+
import {classMap} from "lit/directives/class-map.js";
|
|
4
|
+
import {resetStyles} from "../../styles/reset.js";
|
|
5
|
+
|
|
6
|
+
export type TooltipPosition = "top" | "bottom" | "left" | "right";
|
|
7
|
+
export type TooltipVariant = "default" | "info" | "success" | "warning" | "danger";
|
|
8
|
+
|
|
9
|
+
@customElement("st-tooltip")
|
|
10
|
+
export class StTooltip extends LitElement {
|
|
11
|
+
@property({type: String}) content = "";
|
|
12
|
+
@property({type: String}) position: TooltipPosition = "top";
|
|
13
|
+
@property({type: String}) variant: TooltipVariant = "default";
|
|
14
|
+
@property({type: Number}) delay = 200;
|
|
15
|
+
@property({type: Boolean, reflect: true}) disabled = false;
|
|
16
|
+
|
|
17
|
+
@state() private _isVisible = false;
|
|
18
|
+
|
|
19
|
+
private _showTimeout?: number;
|
|
20
|
+
private _hideTimeout?: number;
|
|
21
|
+
private _tooltipId = `st-tooltip-${Math.random().toString(36).substring(2, 9)}`;
|
|
22
|
+
|
|
23
|
+
private _a11yNode?: HTMLSpanElement;
|
|
24
|
+
|
|
25
|
+
@queryAssignedElements() private _slottedElements!: HTMLElement[];
|
|
26
|
+
|
|
27
|
+
static styles = [
|
|
28
|
+
resetStyles,
|
|
29
|
+
css`
|
|
30
|
+
:host {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
position: relative;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.tooltip-target {
|
|
36
|
+
display: inline-block;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tooltip-popup {
|
|
40
|
+
position: absolute;
|
|
41
|
+
z-index: 1000;
|
|
42
|
+
background: var(--st-color-surface);
|
|
43
|
+
color: var(--st-color-text);
|
|
44
|
+
border: 1px solid var(--st-color-border);
|
|
45
|
+
padding: var(--st-spacing-xs) var(--st-spacing-sm);
|
|
46
|
+
border-radius: var(--st-radius-sm);
|
|
47
|
+
font-size: var(--st-font-size-xs);
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
opacity: 0;
|
|
52
|
+
visibility: hidden;
|
|
53
|
+
transition:
|
|
54
|
+
opacity 0.2s ease,
|
|
55
|
+
transform 0.2s ease,
|
|
56
|
+
visibility 0.2s;
|
|
57
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.tooltip-popup::before {
|
|
61
|
+
content: "";
|
|
62
|
+
position: absolute;
|
|
63
|
+
width: 8px;
|
|
64
|
+
height: 8px;
|
|
65
|
+
background: var(--st-color-surface);
|
|
66
|
+
border: 1px solid var(--st-color-border);
|
|
67
|
+
transform: rotate(45deg);
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.is-visible {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
visibility: visible;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* ==========================================
|
|
77
|
+
VARIANTS
|
|
78
|
+
========================================== */
|
|
79
|
+
|
|
80
|
+
.variant-info {
|
|
81
|
+
background: var(--st-color-info, #3b82f6);
|
|
82
|
+
border-color: var(--st-color-info, #3b82f6);
|
|
83
|
+
color: var(--st-color-on-info, #ffffff);
|
|
84
|
+
}
|
|
85
|
+
.variant-info::before {
|
|
86
|
+
background: var(--st-color-info, #3b82f6);
|
|
87
|
+
border-color: var(--st-color-info, #3b82f6);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.variant-success {
|
|
91
|
+
background: var(--st-color-success, #16a34a);
|
|
92
|
+
border-color: var(--st-color-success, #16a34a);
|
|
93
|
+
color: var(--st-color-on-success, #ffffff);
|
|
94
|
+
}
|
|
95
|
+
.variant-success::before {
|
|
96
|
+
background: var(--st-color-success, #16a34a);
|
|
97
|
+
border-color: var(--st-color-success, #16a34a);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.variant-warning {
|
|
101
|
+
background: var(--st-color-warning, #f59e0b);
|
|
102
|
+
border-color: var(--st-color-warning, #f59e0b);
|
|
103
|
+
/* Warning usually needs dark text for contrast */
|
|
104
|
+
color: var(--st-color-on-warning, #1e293b);
|
|
105
|
+
}
|
|
106
|
+
.variant-warning::before {
|
|
107
|
+
background: var(--st-color-warning, #f59e0b);
|
|
108
|
+
border-color: var(--st-color-warning, #f59e0b);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.variant-danger {
|
|
112
|
+
background: var(--st-color-danger, #dc2626);
|
|
113
|
+
border-color: var(--st-color-danger, #dc2626);
|
|
114
|
+
color: var(--st-color-on-danger, #ffffff);
|
|
115
|
+
}
|
|
116
|
+
.variant-danger::before {
|
|
117
|
+
background: var(--st-color-danger, #dc2626);
|
|
118
|
+
border-color: var(--st-color-danger, #dc2626);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* ==========================================
|
|
122
|
+
POSITIONS
|
|
123
|
+
========================================== */
|
|
124
|
+
|
|
125
|
+
.position-top {
|
|
126
|
+
bottom: 100%;
|
|
127
|
+
left: 50%;
|
|
128
|
+
transform: translateX(-50%) translateY(-10px);
|
|
129
|
+
}
|
|
130
|
+
.position-top.is-visible {
|
|
131
|
+
transform: translateX(-50%) translateY(-6px);
|
|
132
|
+
}
|
|
133
|
+
.position-top::before {
|
|
134
|
+
bottom: -5px;
|
|
135
|
+
left: 50%;
|
|
136
|
+
margin-left: -4px;
|
|
137
|
+
border-top: none;
|
|
138
|
+
border-left: none;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.position-bottom {
|
|
142
|
+
top: 100%;
|
|
143
|
+
left: 50%;
|
|
144
|
+
transform: translateX(-50%) translateY(10px);
|
|
145
|
+
}
|
|
146
|
+
.position-bottom.is-visible {
|
|
147
|
+
transform: translateX(-50%) translateY(6px);
|
|
148
|
+
}
|
|
149
|
+
.position-bottom::before {
|
|
150
|
+
top: -5px;
|
|
151
|
+
left: 50%;
|
|
152
|
+
margin-left: -4px;
|
|
153
|
+
border-bottom: none;
|
|
154
|
+
border-right: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.position-left {
|
|
158
|
+
right: 100%;
|
|
159
|
+
top: 50%;
|
|
160
|
+
transform: translateY(-50%) translateX(-10px);
|
|
161
|
+
}
|
|
162
|
+
.position-left.is-visible {
|
|
163
|
+
transform: translateY(-50%) translateX(-6px);
|
|
164
|
+
}
|
|
165
|
+
.position-left::before {
|
|
166
|
+
right: -5px;
|
|
167
|
+
top: 50%;
|
|
168
|
+
margin-top: -4px;
|
|
169
|
+
border-bottom: none;
|
|
170
|
+
border-left: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.position-right {
|
|
174
|
+
left: 100%;
|
|
175
|
+
top: 50%;
|
|
176
|
+
transform: translateY(-50%) translateX(10px);
|
|
177
|
+
}
|
|
178
|
+
.position-right.is-visible {
|
|
179
|
+
transform: translateY(-50%) translateX(6px);
|
|
180
|
+
}
|
|
181
|
+
.position-right::before {
|
|
182
|
+
left: -5px;
|
|
183
|
+
top: 50%;
|
|
184
|
+
margin-top: -4px;
|
|
185
|
+
border-top: none;
|
|
186
|
+
border-right: none;
|
|
187
|
+
}
|
|
188
|
+
`,
|
|
189
|
+
];
|
|
190
|
+
|
|
191
|
+
override connectedCallback() {
|
|
192
|
+
super.connectedCallback();
|
|
193
|
+
this._a11yNode = document.createElement("span");
|
|
194
|
+
this._a11yNode.id = this._tooltipId;
|
|
195
|
+
this._a11yNode.role = "tooltip";
|
|
196
|
+
this._a11yNode.style.display = "none";
|
|
197
|
+
this._a11yNode.textContent = this.content;
|
|
198
|
+
this.appendChild(this._a11yNode);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
override disconnectedCallback() {
|
|
202
|
+
super.disconnectedCallback();
|
|
203
|
+
if (this._a11yNode && this.contains(this._a11yNode)) {
|
|
204
|
+
this.removeChild(this._a11yNode);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
override updated(changedProperties: PropertyValues) {
|
|
209
|
+
super.updated(changedProperties);
|
|
210
|
+
if (changedProperties.has("content") && this._a11yNode) {
|
|
211
|
+
this._a11yNode.textContent = this.content;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private _handleSlotChange() {
|
|
216
|
+
if (this._slottedElements.length > 0) {
|
|
217
|
+
this._slottedElements.forEach((el) => {
|
|
218
|
+
el.setAttribute("aria-describedby", this._tooltipId);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private _handleMouseEnter() {
|
|
224
|
+
if (this.disabled || !this.content) return;
|
|
225
|
+
clearTimeout(this._hideTimeout);
|
|
226
|
+
this._showTimeout = window.setTimeout(() => {
|
|
227
|
+
this._isVisible = true;
|
|
228
|
+
}, this.delay);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private _handleMouseLeave() {
|
|
232
|
+
clearTimeout(this._showTimeout);
|
|
233
|
+
this._hideTimeout = window.setTimeout(() => {
|
|
234
|
+
this._isVisible = false;
|
|
235
|
+
}, 100);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private _handleFocusIn() {
|
|
239
|
+
if (this.disabled || !this.content) return;
|
|
240
|
+
this._isVisible = true;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private _handleFocusOut() {
|
|
244
|
+
this._isVisible = false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private _handleKeyDown(e: KeyboardEvent) {
|
|
248
|
+
if (e.key === "Escape" && this._isVisible) {
|
|
249
|
+
e.stopPropagation();
|
|
250
|
+
this._isVisible = false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
render() {
|
|
255
|
+
return html`
|
|
256
|
+
<div
|
|
257
|
+
class="tooltip-target"
|
|
258
|
+
@mouseenter=${this._handleMouseEnter}
|
|
259
|
+
@mouseleave=${this._handleMouseLeave}
|
|
260
|
+
@focusin=${this._handleFocusIn}
|
|
261
|
+
@focusout=${this._handleFocusOut}
|
|
262
|
+
@keydown=${this._handleKeyDown}
|
|
263
|
+
>
|
|
264
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
<div
|
|
268
|
+
class=${classMap({
|
|
269
|
+
"tooltip-popup": true,
|
|
270
|
+
[`position-${this.position}`]: true,
|
|
271
|
+
[`variant-${this.variant}`]: true,
|
|
272
|
+
"is-visible": this._isVisible,
|
|
273
|
+
})}
|
|
274
|
+
aria-hidden="true"
|
|
275
|
+
>
|
|
276
|
+
${this.content}
|
|
277
|
+
</div>
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
declare global {
|
|
283
|
+
interface HTMLElementTagNameMap {
|
|
284
|
+
"st-tooltip": StTooltip;
|
|
285
|
+
}
|
|
286
|
+
}
|