@nectary/components 5.6.5 → 5.6.7
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/bundle.js +66 -6
- package/date-picker/utils.js +54 -4
- package/package.json +3 -3
- package/tooltip/index.js +12 -2
- package/tooltip/types.d.ts +5 -0
package/bundle.js
CHANGED
|
@@ -3427,7 +3427,7 @@ const getPopOrientation$1 = (orientation) => {
|
|
|
3427
3427
|
}
|
|
3428
3428
|
return orientation;
|
|
3429
3429
|
};
|
|
3430
|
-
const templateHTML$Q = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"
|
|
3430
|
+
const templateHTML$Q = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
3431
3431
|
const TIP_SIZE$1 = 8;
|
|
3432
3432
|
const SHOW_DELAY_SLOW = 1e3;
|
|
3433
3433
|
const SHOW_DELAY_FAST = 250;
|
|
@@ -3497,7 +3497,8 @@ class Tooltip extends NectaryElement {
|
|
|
3497
3497
|
"type",
|
|
3498
3498
|
"aria-label",
|
|
3499
3499
|
"aria-description",
|
|
3500
|
-
"show-outside-viewport"
|
|
3500
|
+
"show-outside-viewport",
|
|
3501
|
+
"allow-scroll"
|
|
3501
3502
|
];
|
|
3502
3503
|
}
|
|
3503
3504
|
attributeChangedCallback(name, _, newVal) {
|
|
@@ -3544,6 +3545,11 @@ class Tooltip extends NectaryElement {
|
|
|
3544
3545
|
updateBooleanAttribute(this.#$pop, "disable-backdrop-close", false);
|
|
3545
3546
|
this.#tooltipState.hide();
|
|
3546
3547
|
}
|
|
3548
|
+
break;
|
|
3549
|
+
}
|
|
3550
|
+
case "allow-scroll": {
|
|
3551
|
+
updateAttribute(this.#$pop, "allow-scroll", newVal);
|
|
3552
|
+
break;
|
|
3547
3553
|
}
|
|
3548
3554
|
}
|
|
3549
3555
|
}
|
|
@@ -3650,6 +3656,10 @@ class Tooltip extends NectaryElement {
|
|
|
3650
3656
|
}
|
|
3651
3657
|
#updateTipOrientation = () => {
|
|
3652
3658
|
const orient = this.orientation;
|
|
3659
|
+
if (!("footprintRect" in this.#$pop)) {
|
|
3660
|
+
requestAnimationFrame(this.#updateTipOrientation);
|
|
3661
|
+
return;
|
|
3662
|
+
}
|
|
3653
3663
|
const targetRect = this.#$pop.footprintRect;
|
|
3654
3664
|
const contentRect = this.#$content.getBoundingClientRect();
|
|
3655
3665
|
const diffX = targetRect.x - contentRect.x;
|
|
@@ -4154,19 +4164,69 @@ const clampMaxDate = (date, max) => {
|
|
|
4154
4164
|
}
|
|
4155
4165
|
};
|
|
4156
4166
|
const incMonth = (date, max) => {
|
|
4157
|
-
date.
|
|
4167
|
+
const currentDay = date.getUTCDate();
|
|
4168
|
+
const currentMonth = date.getUTCMonth();
|
|
4169
|
+
const currentYear = date.getUTCFullYear();
|
|
4170
|
+
let nextMonth = currentMonth + 1;
|
|
4171
|
+
let nextYear = currentYear;
|
|
4172
|
+
if (nextMonth > 11) {
|
|
4173
|
+
nextMonth = 0;
|
|
4174
|
+
nextYear++;
|
|
4175
|
+
}
|
|
4176
|
+
const nextMonthLastDay = new Date(Date.UTC(nextYear, nextMonth + 1, 0));
|
|
4177
|
+
const maxDayInNextMonth = nextMonthLastDay.getUTCDate();
|
|
4178
|
+
const targetDay = Math.min(currentDay, maxDayInNextMonth);
|
|
4179
|
+
date.setUTCFullYear(nextYear, nextMonth, targetDay);
|
|
4158
4180
|
clampMaxDate(date, max);
|
|
4159
4181
|
};
|
|
4160
4182
|
const decMonth = (date, min) => {
|
|
4161
|
-
date.
|
|
4183
|
+
const currentDay = date.getUTCDate();
|
|
4184
|
+
const currentMonth = date.getUTCMonth();
|
|
4185
|
+
const currentYear = date.getUTCFullYear();
|
|
4186
|
+
let prevMonth = currentMonth - 1;
|
|
4187
|
+
let prevYear = currentYear;
|
|
4188
|
+
if (prevMonth < 0) {
|
|
4189
|
+
prevMonth = 11;
|
|
4190
|
+
prevYear--;
|
|
4191
|
+
}
|
|
4192
|
+
const prevMonthLastDay = new Date(Date.UTC(prevYear, prevMonth + 1, 0));
|
|
4193
|
+
const maxDayInPrevMonth = prevMonthLastDay.getUTCDate();
|
|
4194
|
+
const targetDay = Math.min(currentDay, maxDayInPrevMonth);
|
|
4195
|
+
date.setUTCFullYear(prevYear, prevMonth, targetDay);
|
|
4162
4196
|
clampMinDate(date, min);
|
|
4163
4197
|
};
|
|
4164
4198
|
const incYear = (date, max) => {
|
|
4165
|
-
date.
|
|
4199
|
+
const currentDay = date.getUTCDate();
|
|
4200
|
+
const currentMonth = date.getUTCMonth();
|
|
4201
|
+
const currentYear = date.getUTCFullYear();
|
|
4202
|
+
const nextYear = currentYear + 1;
|
|
4203
|
+
if (currentMonth === 1 && currentDay === 29) {
|
|
4204
|
+
const isNextYearLeap = new Date(Date.UTC(nextYear, 1, 29)).getUTCDate() === 29;
|
|
4205
|
+
if (!isNextYearLeap) {
|
|
4206
|
+
date.setUTCFullYear(nextYear, currentMonth, 28);
|
|
4207
|
+
} else {
|
|
4208
|
+
date.setUTCFullYear(nextYear, currentMonth, currentDay);
|
|
4209
|
+
}
|
|
4210
|
+
} else {
|
|
4211
|
+
date.setUTCFullYear(nextYear, currentMonth, currentDay);
|
|
4212
|
+
}
|
|
4166
4213
|
clampMaxDate(date, max);
|
|
4167
4214
|
};
|
|
4168
4215
|
const decYear = (date, min) => {
|
|
4169
|
-
date.
|
|
4216
|
+
const currentDay = date.getUTCDate();
|
|
4217
|
+
const currentMonth = date.getUTCMonth();
|
|
4218
|
+
const currentYear = date.getUTCFullYear();
|
|
4219
|
+
const prevYear = currentYear - 1;
|
|
4220
|
+
if (currentMonth === 1 && currentDay === 29) {
|
|
4221
|
+
const isPrevYearLeap = new Date(Date.UTC(prevYear, 1, 29)).getUTCDate() === 29;
|
|
4222
|
+
if (!isPrevYearLeap) {
|
|
4223
|
+
date.setUTCFullYear(prevYear, currentMonth, 28);
|
|
4224
|
+
} else {
|
|
4225
|
+
date.setUTCFullYear(prevYear, currentMonth, currentDay);
|
|
4226
|
+
}
|
|
4227
|
+
} else {
|
|
4228
|
+
date.setUTCFullYear(prevYear, currentMonth, currentDay);
|
|
4229
|
+
}
|
|
4170
4230
|
clampMinDate(date, min);
|
|
4171
4231
|
};
|
|
4172
4232
|
const canGoPrevMonth = (date, min) => {
|
package/date-picker/utils.js
CHANGED
|
@@ -72,19 +72,69 @@ const clampMaxDate = (date, max) => {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
const incMonth = (date, max) => {
|
|
75
|
-
date.
|
|
75
|
+
const currentDay = date.getUTCDate();
|
|
76
|
+
const currentMonth = date.getUTCMonth();
|
|
77
|
+
const currentYear = date.getUTCFullYear();
|
|
78
|
+
let nextMonth = currentMonth + 1;
|
|
79
|
+
let nextYear = currentYear;
|
|
80
|
+
if (nextMonth > 11) {
|
|
81
|
+
nextMonth = 0;
|
|
82
|
+
nextYear++;
|
|
83
|
+
}
|
|
84
|
+
const nextMonthLastDay = new Date(Date.UTC(nextYear, nextMonth + 1, 0));
|
|
85
|
+
const maxDayInNextMonth = nextMonthLastDay.getUTCDate();
|
|
86
|
+
const targetDay = Math.min(currentDay, maxDayInNextMonth);
|
|
87
|
+
date.setUTCFullYear(nextYear, nextMonth, targetDay);
|
|
76
88
|
clampMaxDate(date, max);
|
|
77
89
|
};
|
|
78
90
|
const decMonth = (date, min) => {
|
|
79
|
-
date.
|
|
91
|
+
const currentDay = date.getUTCDate();
|
|
92
|
+
const currentMonth = date.getUTCMonth();
|
|
93
|
+
const currentYear = date.getUTCFullYear();
|
|
94
|
+
let prevMonth = currentMonth - 1;
|
|
95
|
+
let prevYear = currentYear;
|
|
96
|
+
if (prevMonth < 0) {
|
|
97
|
+
prevMonth = 11;
|
|
98
|
+
prevYear--;
|
|
99
|
+
}
|
|
100
|
+
const prevMonthLastDay = new Date(Date.UTC(prevYear, prevMonth + 1, 0));
|
|
101
|
+
const maxDayInPrevMonth = prevMonthLastDay.getUTCDate();
|
|
102
|
+
const targetDay = Math.min(currentDay, maxDayInPrevMonth);
|
|
103
|
+
date.setUTCFullYear(prevYear, prevMonth, targetDay);
|
|
80
104
|
clampMinDate(date, min);
|
|
81
105
|
};
|
|
82
106
|
const incYear = (date, max) => {
|
|
83
|
-
date.
|
|
107
|
+
const currentDay = date.getUTCDate();
|
|
108
|
+
const currentMonth = date.getUTCMonth();
|
|
109
|
+
const currentYear = date.getUTCFullYear();
|
|
110
|
+
const nextYear = currentYear + 1;
|
|
111
|
+
if (currentMonth === 1 && currentDay === 29) {
|
|
112
|
+
const isNextYearLeap = new Date(Date.UTC(nextYear, 1, 29)).getUTCDate() === 29;
|
|
113
|
+
if (!isNextYearLeap) {
|
|
114
|
+
date.setUTCFullYear(nextYear, currentMonth, 28);
|
|
115
|
+
} else {
|
|
116
|
+
date.setUTCFullYear(nextYear, currentMonth, currentDay);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
date.setUTCFullYear(nextYear, currentMonth, currentDay);
|
|
120
|
+
}
|
|
84
121
|
clampMaxDate(date, max);
|
|
85
122
|
};
|
|
86
123
|
const decYear = (date, min) => {
|
|
87
|
-
date.
|
|
124
|
+
const currentDay = date.getUTCDate();
|
|
125
|
+
const currentMonth = date.getUTCMonth();
|
|
126
|
+
const currentYear = date.getUTCFullYear();
|
|
127
|
+
const prevYear = currentYear - 1;
|
|
128
|
+
if (currentMonth === 1 && currentDay === 29) {
|
|
129
|
+
const isPrevYearLeap = new Date(Date.UTC(prevYear, 1, 29)).getUTCDate() === 29;
|
|
130
|
+
if (!isPrevYearLeap) {
|
|
131
|
+
date.setUTCFullYear(prevYear, currentMonth, 28);
|
|
132
|
+
} else {
|
|
133
|
+
date.setUTCFullYear(prevYear, currentMonth, currentDay);
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
date.setUTCFullYear(prevYear, currentMonth, currentDay);
|
|
137
|
+
}
|
|
88
138
|
clampMinDate(date, min);
|
|
89
139
|
};
|
|
90
140
|
const canGoPrevMonth = (date, min) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.7",
|
|
4
4
|
"files": [
|
|
5
5
|
"**/*/*.css",
|
|
6
6
|
"**/*/*.json",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.22.15",
|
|
27
|
-
"@nectary/assets": "3.3.
|
|
27
|
+
"@nectary/assets": "3.3.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/cli": "^7.22.15",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"vite": "^7.0.6"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@nectary/theme-base": "1.7.
|
|
43
|
+
"@nectary/theme-base": "1.7.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/tooltip/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { rectOverlap } from "../utils/rect.js";
|
|
|
6
6
|
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
7
7
|
import { TooltipState } from "./tooltip-state.js";
|
|
8
8
|
import { getPopOrientation, orientationValues, textAlignValues, typeValues } from "./utils.js";
|
|
9
|
-
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"
|
|
9
|
+
const templateHTML = '<style>:host{display:contents}#content-wrapper{padding-bottom:8px;filter:drop-shadow(var(--sinch-comp-tooltip-shadow))}:host([orientation=left]) #content-wrapper{padding-bottom:0;padding-right:8px}:host([orientation=right]) #content-wrapper{padding-bottom:0;padding-left:8px}:host([orientation^=bottom]) #content-wrapper{padding-bottom:0;padding-top:8px}#content{position:relative;display:block;max-width:300px;padding:2px 6px;box-sizing:border-box;background-color:var(--sinch-local-color-background);border-radius:var(--sinch-comp-tooltip-shape-radius);pointer-events:none;opacity:0;--sinch-local-color-background:var(--sinch-comp-tooltip-color-background);--sinch-global-color-text:var(--sinch-comp-tooltip-color-text)}#text{word-break:break-word;pointer-events:none;--sinch-comp-text-font:var(--sinch-comp-tooltip-font-body)}#tip{position:absolute;left:50%;top:100%;transform:translateX(-50%) rotate(0);transform-origin:top center;fill:var(--sinch-local-color-background);pointer-events:none}#tip.hidden{display:none}:host([orientation=left]) #tip{transform:translateX(-50%) rotate(270deg);top:50%;left:100%}:host([orientation=right]) #tip{transform:translateX(-50%) rotate(90deg);top:50%;left:0}:host([orientation^=bottom]) #tip{transform:translateX(-50%) rotate(180deg);top:0}:host([text-align=right]) #text{--sinch-comp-text-align:right}:host([text-align=center]) #text{--sinch-comp-text-align:center}:host([text-align=left]) #text{--sinch-comp-text-align:left}</style><sinch-pop id="pop"><slot id="target" slot="target"></slot><div id="content-wrapper" slot="content"><div id="content"><sinch-text id="text" type="s"></sinch-text><svg id="tip" width="8" height="4" aria-hidden="true"><path d="m4 4 4-4h-8l4 4Z"/></svg></div></div></sinch-pop>';
|
|
10
10
|
const TIP_SIZE = 8;
|
|
11
11
|
const SHOW_DELAY_SLOW = 1e3;
|
|
12
12
|
const SHOW_DELAY_FAST = 250;
|
|
@@ -76,7 +76,8 @@ class Tooltip extends NectaryElement {
|
|
|
76
76
|
"type",
|
|
77
77
|
"aria-label",
|
|
78
78
|
"aria-description",
|
|
79
|
-
"show-outside-viewport"
|
|
79
|
+
"show-outside-viewport",
|
|
80
|
+
"allow-scroll"
|
|
80
81
|
];
|
|
81
82
|
}
|
|
82
83
|
attributeChangedCallback(name, _, newVal) {
|
|
@@ -123,6 +124,11 @@ class Tooltip extends NectaryElement {
|
|
|
123
124
|
updateBooleanAttribute(this.#$pop, "disable-backdrop-close", false);
|
|
124
125
|
this.#tooltipState.hide();
|
|
125
126
|
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case "allow-scroll": {
|
|
130
|
+
updateAttribute(this.#$pop, "allow-scroll", newVal);
|
|
131
|
+
break;
|
|
126
132
|
}
|
|
127
133
|
}
|
|
128
134
|
}
|
|
@@ -229,6 +235,10 @@ class Tooltip extends NectaryElement {
|
|
|
229
235
|
}
|
|
230
236
|
#updateTipOrientation = () => {
|
|
231
237
|
const orient = this.orientation;
|
|
238
|
+
if (!("footprintRect" in this.#$pop)) {
|
|
239
|
+
requestAnimationFrame(this.#updateTipOrientation);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
232
242
|
const targetRect = this.#$pop.footprintRect;
|
|
233
243
|
const contentRect = this.#$content.getBoundingClientRect();
|
|
234
244
|
const diffX = targetRect.x - contentRect.x;
|
package/tooltip/types.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export type TSinchTooltipProps = {
|
|
|
15
15
|
'show-outside-viewport'?: boolean;
|
|
16
16
|
readonly footprintRect?: TRect;
|
|
17
17
|
readonly tooltipRect?: TRect;
|
|
18
|
+
/**
|
|
19
|
+
* Whether or not the tooltip allows scrolling, blocks by default, setting it
|
|
20
|
+
* to true can have unexpected behavior in dialogs
|
|
21
|
+
*/
|
|
22
|
+
'allow-scroll'?: boolean;
|
|
18
23
|
};
|
|
19
24
|
export type TSinchTooltipEvents = {
|
|
20
25
|
/** Show event handler */
|