@haiilo/catalyst 5.2.3 → 5.4.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/catalyst/catalyst.css +56 -39
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.cdn.js +1 -0
- package/dist/catalyst/index.esm.js +2 -2
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-34e0cbba.entry.js +10 -0
- package/dist/catalyst/p-34e0cbba.entry.js.map +1 -0
- package/dist/catalyst/{p-d1fb9d96.js → p-ce6a1db2.js} +1 -1
- package/dist/catalyst/p-ce6a1db2.js.map +1 -0
- package/dist/catalyst/p-cf32399c.js +2 -0
- package/dist/catalyst/p-cf32399c.js.map +1 -0
- package/dist/catalyst/scss/_snippets/_checkbox-hint.scss +20 -0
- package/dist/catalyst/scss/_snippets/_form-label.scss +2 -1
- package/dist/catalyst/scss/utils/_border.scss +14 -0
- package/dist/catalyst/scss/utils/_media.mixins.scss +0 -1
- package/dist/catalyst/scss/utils/_typography.mixins.scss +1 -0
- package/dist/cjs/{cat-alert_24.cjs.entry.js → cat-alert_27.cjs.entry.js} +3777 -192
- package/dist/cjs/cat-alert_27.cjs.entry.js.map +1 -0
- package/dist/cjs/{cat-icon-registry-671af264.js → cat-icon-registry-228164a1.js} +43 -2
- package/dist/cjs/cat-icon-registry-228164a1.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +3 -3
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-01312a2e.js → index-4258b31e.js} +8 -1
- package/dist/{catalyst/p-d1fb9d96.js.map → cjs/index-4258b31e.js.map} +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/cat-alert/cat-alert.js +5 -5
- package/dist/collection/components/cat-alert/cat-alert.js.map +1 -1
- package/dist/collection/components/cat-button/cat-button.css +27 -9
- package/dist/collection/components/cat-button/cat-button.js +27 -25
- package/dist/collection/components/cat-button/cat-button.js.map +1 -1
- package/dist/collection/components/cat-button-group/cat-button-group.css +15 -0
- package/dist/collection/components/cat-button-group/cat-button-group.js +51 -0
- package/dist/collection/components/cat-button-group/cat-button-group.js.map +1 -0
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +24 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.js +8 -4
- package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.css +381 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +873 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -0
- package/dist/collection/components/cat-datepicker/datepicker-type.js +8 -0
- package/dist/collection/components/cat-datepicker/datepicker-type.js.map +1 -0
- package/dist/collection/components/cat-datepicker/dayjs.config.js +8 -0
- package/dist/collection/components/cat-datepicker/dayjs.config.js.map +1 -0
- package/dist/collection/components/cat-datepicker/vanillajs-datepicker.config.js +46 -0
- package/dist/collection/components/cat-datepicker/vanillajs-datepicker.config.js.map +1 -0
- package/dist/collection/components/cat-dropdown/cat-dropdown.css +1 -0
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +26 -7
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js +29 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +29 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +392 -15
- package/dist/collection/components/cat-input/cat-input.js +8 -4
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-label/cat-label.js +19 -0
- package/dist/collection/components/cat-label/cat-label.js.map +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js +1 -1
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +28 -6
- package/dist/collection/components/cat-pagination/cat-pagination.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +24 -1
- package/dist/collection/components/cat-radio/cat-radio.js +8 -4
- package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +7 -3
- package/dist/collection/components/cat-radio-group/cat-radio-group.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.css +1 -4
- package/dist/collection/components/cat-select/cat-select.css +98 -11
- package/dist/collection/components/cat-select/cat-select.js +73 -23
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.css +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +17 -16
- package/dist/collection/components/cat-textarea/cat-textarea.js +8 -4
- package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
- package/dist/collection/components/cat-timepicker/cat-timepicker.css +5 -0
- package/dist/collection/components/cat-timepicker/cat-timepicker.js +668 -0
- package/dist/collection/components/cat-timepicker/cat-timepicker.js.map +1 -0
- package/dist/collection/components/cat-toggle/cat-toggle.css +24 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +8 -4
- package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.css +1 -8
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +22 -18
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/index.cdn.js +1 -0
- package/dist/collection/scss/_snippets/_checkbox-hint.scss +20 -0
- package/dist/collection/scss/_snippets/_form-label.scss +2 -1
- package/dist/collection/scss/utils/_border.scss +14 -0
- package/dist/collection/scss/utils/_media.mixins.scss +0 -1
- package/dist/collection/scss/utils/_typography.mixins.scss +1 -0
- package/dist/components/cat-alert.js +5 -5
- package/dist/components/cat-alert.js.map +1 -1
- package/dist/components/cat-button-group.d.ts +11 -0
- package/dist/components/cat-button-group.js +46 -0
- package/dist/components/cat-button-group.js.map +1 -0
- package/dist/components/cat-button2.js +12 -10
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +2 -2
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-datepicker.d.ts +11 -0
- package/dist/components/cat-datepicker.js +3210 -0
- package/dist/components/cat-datepicker.js.map +1 -0
- package/dist/components/cat-dropdown2.js +640 -43
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-form-group.js +11 -2
- package/dist/components/cat-form-group.js.map +1 -1
- package/dist/components/cat-icon-registry.js +42 -1
- package/dist/components/cat-icon-registry.js.map +1 -1
- package/dist/components/cat-input.js +1 -226
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-input2.js +230 -0
- package/dist/components/cat-input2.js.map +1 -0
- package/dist/components/cat-label.js +2 -0
- package/dist/components/cat-label.js.map +1 -1
- package/dist/components/cat-pagination.js +10 -5
- package/dist/components/cat-pagination.js.map +1 -1
- package/dist/components/cat-radio-group.js.map +1 -1
- package/dist/components/cat-radio.js +2 -2
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +7 -5
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +2 -2
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +46 -17
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -1
- package/dist/components/cat-skeleton2.js.map +1 -1
- package/dist/components/cat-textarea.js +3 -3
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-timepicker.d.ts +11 -0
- package/dist/components/cat-timepicker.js +258 -0
- package/dist/components/cat-timepicker.js.map +1 -0
- package/dist/components/cat-toggle.js +2 -2
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +24 -20
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +142 -56
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/esm/{cat-alert_24.entry.js → cat-alert_27.entry.js} +3775 -193
- package/dist/esm/cat-alert_27.entry.js.map +1 -0
- package/dist/esm/{cat-icon-registry-d6b80490.js → cat-icon-registry-4bd597f4.js} +43 -2
- package/dist/esm/cat-icon-registry-4bd597f4.js.map +1 -0
- package/dist/esm/catalyst.js +4 -4
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-fc2f91a4.js → index-636ce8d6.js} +8 -1
- package/dist/esm/index-636ce8d6.js.map +1 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +4 -4
- package/dist/esm/loader.js.map +1 -1
- package/dist/types/components/cat-button/cat-button.d.ts +4 -5
- package/dist/types/components/cat-button-group/cat-button-group.d.ts +11 -0
- package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +1 -1
- package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +187 -0
- package/dist/types/components/cat-datepicker/datepicker-type.d.ts +7 -0
- package/dist/types/components/cat-datepicker/datepicker.d.ts +1 -0
- package/dist/types/components/cat-datepicker/dayjs.config.d.ts +3 -0
- package/dist/types/components/cat-datepicker/vanillajs-datepicker.config.d.ts +4 -0
- package/dist/types/components/cat-form-group/cat-form-group.d.ts +5 -0
- package/dist/types/components/cat-input/cat-input.d.ts +1 -1
- package/dist/types/components/cat-label/cat-label.d.ts +4 -0
- package/dist/types/components/cat-pagination/cat-pagination.d.ts +6 -0
- package/dist/types/components/cat-radio/cat-radio.d.ts +1 -1
- package/dist/types/components/cat-radio-group/cat-radio-group.d.ts +1 -1
- package/dist/types/components/cat-select/cat-select.d.ts +10 -1
- package/dist/types/components/cat-textarea/cat-textarea.d.ts +1 -1
- package/dist/types/components/cat-timepicker/cat-timepicker.d.ts +158 -0
- package/dist/types/components/cat-toggle/cat-toggle.d.ts +1 -1
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +2 -2
- package/dist/types/components.d.ts +585 -17
- package/package.json +22 -18
- package/dist/catalyst/p-ccfebe33.js +0 -2
- package/dist/catalyst/p-ccfebe33.js.map +0 -1
- package/dist/catalyst/p-d135d677.entry.js +0 -10
- package/dist/catalyst/p-d135d677.entry.js.map +0 -1
- package/dist/cjs/cat-alert_24.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-icon-registry-671af264.js.map +0 -1
- package/dist/cjs/index-01312a2e.js.map +0 -1
- package/dist/components/first-tabbable.js +0 -464
- package/dist/components/first-tabbable.js.map +0 -1
- package/dist/esm/cat-alert_24.entry.js.map +0 -1
- package/dist/esm/cat-icon-registry-d6b80490.js.map +0 -1
- package/dist/esm/index-fc2f91a4.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
3
|
-
import { b as firstTabbable } from './first-tabbable.js';
|
|
2
|
+
import { c as computePosition, a as autoUpdate, o as offset, f as flip, b as shift } from './floating-ui.dom.esm.js';
|
|
4
3
|
|
|
5
4
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
6
5
|
|
|
7
|
-
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{--cat-font-color-head:cat-token(\"color.ui.font.tooltip\", $wrap: false);--cat-font-color-body:cat-token(\"color.ui.font.tooltip\", $wrap: false);position:fixed;width:max-content;top:0;left:0;box-sizing:border-box;font-size:0.875rem;line-height:
|
|
6
|
+
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{--cat-font-color-head:cat-token(\"color.ui.font.tooltip\", $wrap: false);--cat-font-color-body:cat-token(\"color.ui.font.tooltip\", $wrap: false);position:fixed;width:max-content;top:0;left:0;box-sizing:border-box;font-size:0.875rem;line-height:1.125rem;font-weight:500;background-color:rgb(var(--cat-bg-tooltip, 0, 0, 0));border-radius:var(--cat-border-radius-m, 0.25rem);color:rgb(var(--cat-font-color-tooltip, 255, 255, 255));transition:opacity 0.25s linear, visibility 0.25s linear;visibility:hidden;opacity:0;box-shadow:rgba(0, 0, 0, 0.08) 0 1px 8px 0;z-index:200;max-width:min(100vw - 0.5rem, 20rem)}.tooltip-hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.tooltip-show{opacity:1;visibility:visible}.tooltip-round{border-radius:10rem}.tooltip-s{padding:0.375rem 0.5rem}.tooltip-s.tooltip-round{padding:0.375rem 0.75rem}.tooltip-m{padding:0.75rem}.tooltip-m.tooltip-round{padding:0.75rem 1rem}.tooltip-l{padding:1rem}.tooltip-l.tooltip-round{padding:1rem 1.5rem}";
|
|
8
7
|
|
|
9
8
|
let nextUniqueId = 0;
|
|
10
9
|
const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
@@ -28,24 +27,22 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
28
27
|
key === 'Escape' && this.hideListener();
|
|
29
28
|
}
|
|
30
29
|
componentDidLoad() {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (this.trigger && this.tooltip) {
|
|
37
|
-
autoUpdate(this.trigger, this.tooltip, () => this.update());
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31
|
+
const slot = (_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
|
|
32
|
+
this.trigger = (_c = (_b = slot === null || slot === void 0 ? void 0 : slot.assignedElements) === null || _b === void 0 ? void 0 : _b.call(slot)) === null || _c === void 0 ? void 0 : _c[0];
|
|
33
|
+
if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {
|
|
34
|
+
this.trigger.setAttribute('aria-describedby', this.id);
|
|
38
35
|
}
|
|
39
36
|
if (isTouchDevice) {
|
|
40
37
|
window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
|
|
41
|
-
(
|
|
42
|
-
(
|
|
38
|
+
(_d = this.trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('touchstart', this.touchStartListener.bind(this));
|
|
39
|
+
(_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('touchend', this.touchEndListener.bind(this));
|
|
43
40
|
}
|
|
44
41
|
else {
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
48
|
-
(
|
|
42
|
+
(_f = this.trigger) === null || _f === void 0 ? void 0 : _f.addEventListener('focusin', this.showListener.bind(this));
|
|
43
|
+
(_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('focusout', this.hideListener.bind(this));
|
|
44
|
+
(_h = this.trigger) === null || _h === void 0 ? void 0 : _h.addEventListener('mouseenter', this.showListener.bind(this));
|
|
45
|
+
(_j = this.trigger) === null || _j === void 0 ? void 0 : _j.addEventListener('mouseleave', this.hideListener.bind(this));
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
componentWillRender() {
|
|
@@ -67,16 +64,13 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
render() {
|
|
70
|
-
return (h(Host, null, h("
|
|
67
|
+
return (h(Host, null, h("slot", null), h("div", { ref: el => (this.tooltip = el), id: this.id, "aria-hidden": this.hidden, class: {
|
|
71
68
|
tooltip: true,
|
|
72
69
|
'tooltip-hidden': this.hidden,
|
|
73
70
|
'tooltip-round': this.round,
|
|
74
71
|
[`tooltip-${this.size}`]: Boolean(this.size)
|
|
75
72
|
} }, this.hasSlottedContent ? h("slot", { name: "content" }) : this.content)));
|
|
76
73
|
}
|
|
77
|
-
get isTabbable() {
|
|
78
|
-
return firstTabbable(this.trigger);
|
|
79
|
-
}
|
|
80
74
|
async update() {
|
|
81
75
|
if (this.trigger && this.tooltip) {
|
|
82
76
|
await computePosition(this.trigger, this.tooltip, {
|
|
@@ -104,6 +98,7 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
104
98
|
this.hideTimeout = window.setTimeout(() => {
|
|
105
99
|
var _a;
|
|
106
100
|
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
|
|
101
|
+
this.hideTooltip();
|
|
107
102
|
}, this.hideDelay);
|
|
108
103
|
}
|
|
109
104
|
touchStartListener(event) {
|
|
@@ -115,6 +110,7 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
115
110
|
touchEndListener() {
|
|
116
111
|
if (this.touchTimeout) {
|
|
117
112
|
window.clearTimeout(this.touchTimeout);
|
|
113
|
+
this.hideTooltip();
|
|
118
114
|
}
|
|
119
115
|
}
|
|
120
116
|
windowTouchStartListener() {
|
|
@@ -123,8 +119,16 @@ const CatTooltip$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
123
119
|
}
|
|
124
120
|
showTooltip() {
|
|
125
121
|
var _a;
|
|
122
|
+
if (this.trigger && this.tooltip) {
|
|
123
|
+
this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());
|
|
124
|
+
}
|
|
126
125
|
!this.hidden && ((_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show'));
|
|
127
126
|
}
|
|
127
|
+
hideTooltip() {
|
|
128
|
+
if (this.cleanupFloatingUi) {
|
|
129
|
+
this.cleanupFloatingUi();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
128
132
|
get hostElement() { return this; }
|
|
129
133
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AAC,CAAC;GACpB;EAEO,kBAAkB,CAAC,KAAY;IACrC,KAAK,CAAC,eAAe,EAAE,CAAC;IACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC;MACpC,IAAI,CAAC,WAAW,EAAE,CAAC;KACpB,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;GAC5B;EAEO,gBAAgB;IACtB,IAAI,IAAI,CAAC,YAAY,EAAE;MACrB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACxC;GACF;EAEO,wBAAwB;;IAC9B,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;GAChD;EAEO,WAAW;;IACjB,CAAC,IAAI,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA,CAAC;GAC7D;;;;;;;;;;;;;;AAlLuBA,mBAAM,GAAG,CAAC,CAAC;AACXA,0BAAa,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;","names":["CatTooltip","isTouchScreen"],"sources":["./src/utils/is-touch-screen.ts","./src/components/cat-tooltip/cat-tooltip.scss?tag=cat-tooltip&encapsulation=shadow","./src/components/cat-tooltip/cat-tooltip.tsx"],"sourcesContent":["const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n\nexport default isTouchDevice;\n","@use 'variables' as *;\n@use 'mixins' as *;\n\n$-max-width: 20rem;\n$-box-shadow: rgb(0 0 0 / 8%) 0 1px 8px 0;\n$-shift-padding: 0.25rem; // padding given to the shift() middleware\n\n:host {\n display: contents;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.tooltip {\n --cat-font-color-head: cat-token('color.ui.font.tooltip', $wrap: false);\n --cat-font-color-body: cat-token('color.ui.font.tooltip', $wrap: false);\n position: fixed;\n width: max-content;\n top: 0;\n left: 0;\n box-sizing: border-box;\n @include cat-body('s', 500);\n background-color: cat-token('color.ui.background.tooltip');\n border-radius: cat-border-radius('m');\n color: cat-token('color.ui.font.tooltip');\n transition: opacity cat-token('time.transition.m') linear, visibility cat-token('time.transition.m') linear;\n visibility: hidden;\n opacity: 0;\n box-shadow: $-box-shadow;\n z-index: $cat-tooltip-z-index;\n max-width: min(calc(100vw - 2 * $-shift-padding), $-max-width);\n\n &-hidden {\n @include cat-visually-hidden;\n }\n\n &-show {\n opacity: 1;\n visibility: visible;\n }\n}\n\n// ----- round\n\n.tooltip-round {\n border-radius: 10rem;\n}\n\n// ----- size\n\n.tooltip-s {\n padding: 0.375rem 0.5rem;\n\n &.tooltip-round {\n padding: 0.375rem 0.75rem;\n }\n}\n\n.tooltip-m {\n padding: 0.75rem;\n\n &.tooltip-round {\n padding: 0.75rem 1rem;\n }\n}\n\n.tooltip-l {\n padding: 1rem;\n\n &.tooltip-round {\n padding: 1rem 1.5rem;\n }\n}\n\n// ----- trigger\n\n.tooltip-trigger {\n display: inline-block;\n\n &:focus {\n outline: none;\n }\n}\n","import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport { FocusableElement } from 'tabbable';\nimport firstTabbable from '../../utils/first-tabbable';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private triggerElement?: HTMLElement;\n private trigger?: FocusableElement;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;\n if (!this.isTabbable) {\n this.trigger?.setAttribute('tabindex', '0');\n }\n\n if (this.trigger && this.tooltip) {\n autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <div ref={el => (this.triggerElement = el)} aria-describedby={this.id} class=\"tooltip-trigger\">\n <slot />\n </div>\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private get isTabbable() {\n return firstTabbable(this.trigger);\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.tooltip?.classList.remove('tooltip-show');\n }, this.hideDelay);\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n this.touchTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n if (this.touchTimeout) {\n window.clearTimeout(this.touchTimeout);\n }\n }\n\n private windowTouchStartListener() {\n this.tooltip?.classList.remove('tooltip-show');\n }\n\n private showTooltip() {\n !this.hidden && this.tooltip?.classList.add('tooltip-show');\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"cat-tooltip.js","mappings":";;;AAAA,MAAM,aAAa,G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AAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;MACvC,IAAI,CAAC,WAAW,EAAE,CAAC;KACpB;GACF;EAEO,wBAAwB;;IAC9B,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;GAChD;EAEO,WAAW;;IACjB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE;MAChC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;KACtF;IACD,CAAC,IAAI,CAAC,MAAM,KAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA,CAAC;GAC7D;EAEO,WAAW;IACjB,IAAI,IAAI,CAAC,iBAAiB,EAAE;MAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;GACF;;;;;;;;;;;;;;AApLuBA,mBAAM,GAAG,CAAC,CAAC;AACXA,0BAAa,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;","names":["CatTooltip","isTouchScreen"],"sources":["./src/utils/is-touch-screen.ts","./src/components/cat-tooltip/cat-tooltip.scss?tag=cat-tooltip&encapsulation=shadow","./src/components/cat-tooltip/cat-tooltip.tsx"],"sourcesContent":["const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n\nexport default isTouchDevice;\n","@use 'variables' as *;\n@use 'mixins' as *;\n\n$-max-width: 20rem;\n$-box-shadow: rgb(0 0 0 / 8%) 0 1px 8px 0;\n$-shift-padding: 0.25rem; // padding given to the shift() middleware\n\n:host {\n display: contents;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.tooltip {\n --cat-font-color-head: cat-token('color.ui.font.tooltip', $wrap: false);\n --cat-font-color-body: cat-token('color.ui.font.tooltip', $wrap: false);\n position: fixed;\n width: max-content;\n top: 0;\n left: 0;\n box-sizing: border-box;\n @include cat-body('s', 500);\n background-color: cat-token('color.ui.background.tooltip');\n border-radius: cat-border-radius('m');\n color: cat-token('color.ui.font.tooltip');\n transition: opacity cat-token('time.transition.m') linear, visibility cat-token('time.transition.m') linear;\n visibility: hidden;\n opacity: 0;\n box-shadow: $-box-shadow;\n z-index: $cat-tooltip-z-index;\n max-width: min(calc(100vw - 2 * $-shift-padding), $-max-width);\n\n &-hidden {\n @include cat-visually-hidden;\n }\n\n &-show {\n opacity: 1;\n visibility: visible;\n }\n}\n\n// ----- round\n\n.tooltip-round {\n border-radius: 10rem;\n}\n\n// ----- size\n\n.tooltip-s {\n padding: 0.375rem 0.5rem;\n\n &.tooltip-round {\n padding: 0.375rem 0.75rem;\n }\n}\n\n.tooltip-m {\n padding: 0.75rem;\n\n &.tooltip-round {\n padding: 0.75rem 1rem;\n }\n}\n\n.tooltip-l {\n padding: 1rem;\n\n &.tooltip-round {\n padding: 1rem 1.5rem;\n }\n}\n","import { autoUpdate, computePosition, flip, offset, Placement, shift } from '@floating-ui/dom';\nimport { Component, Element, h, Host, Listen, Prop, State } from '@stencil/core';\nimport isTouchScreen from '../../utils/is-touch-screen';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private static readonly SHIFT_PADDING = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private trigger?: Element;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n private hidden = false;\n private cleanupFloatingUi?: () => void;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedContent = false;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * Use round tooltip edges.\n */\n @Prop() round = false;\n\n /**\n * The size of the tooltip.\n */\n @Prop() size: 's' | 'm' | 'l' = 'm';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 250;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n const slot = this.hostElement.shadowRoot?.querySelector('slot');\n this.trigger = slot?.assignedElements?.()?.[0];\n if (this.trigger && !this.trigger.hasAttribute('aria-describedby')) {\n this.trigger.setAttribute('aria-describedby', this.id);\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedContent = !!this.hostElement.querySelector('[slot=\"content\"]');\n this.hidden = this.disabled || (!this.content && !this.hasSlottedContent);\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <slot />\n <div\n ref={el => (this.tooltip = el)}\n id={this.id}\n aria-hidden={this.hidden}\n class={{\n tooltip: true,\n 'tooltip-hidden': this.hidden,\n 'tooltip-round': this.round,\n [`tooltip-${this.size}`]: Boolean(this.size)\n }}\n >\n {this.hasSlottedContent ? <slot name=\"content\" /> : this.content}\n </div>\n </Host>\n );\n }\n\n private async update() {\n if (this.trigger && this.tooltip) {\n await computePosition(this.trigger, this.tooltip, {\n strategy: 'fixed',\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip(), shift({ padding: CatTooltip.SHIFT_PADDING })]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.tooltip?.classList.remove('tooltip-show');\n this.hideTooltip();\n }, this.hideDelay);\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n this.touchTimeout = window.setTimeout(() => {\n this.showTooltip();\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n if (this.touchTimeout) {\n window.clearTimeout(this.touchTimeout);\n this.hideTooltip();\n }\n }\n\n private windowTouchStartListener() {\n this.tooltip?.classList.remove('tooltip-show');\n }\n\n private showTooltip() {\n if (this.trigger && this.tooltip) {\n this.cleanupFloatingUi = autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n !this.hidden && this.tooltip?.classList.add('tooltip-show');\n }\n\n private hideTooltip() {\n if (this.cleanupFloatingUi) {\n this.cleanupFloatingUi();\n }\n }\n}\n"],"version":3}
|
|
@@ -587,6 +587,89 @@ const shift = function (options) {
|
|
|
587
587
|
};
|
|
588
588
|
};
|
|
589
589
|
|
|
590
|
+
/**
|
|
591
|
+
* Provides data that allows you to change the size of the floating element —
|
|
592
|
+
* for instance, prevent it from overflowing the clipping boundary or match the
|
|
593
|
+
* width of the reference element.
|
|
594
|
+
* @see https://floating-ui.com/docs/size
|
|
595
|
+
*/
|
|
596
|
+
const size = function (options) {
|
|
597
|
+
if (options === void 0) {
|
|
598
|
+
options = {};
|
|
599
|
+
}
|
|
600
|
+
return {
|
|
601
|
+
name: 'size',
|
|
602
|
+
options,
|
|
603
|
+
async fn(state) {
|
|
604
|
+
const {
|
|
605
|
+
placement,
|
|
606
|
+
rects,
|
|
607
|
+
platform,
|
|
608
|
+
elements
|
|
609
|
+
} = state;
|
|
610
|
+
const {
|
|
611
|
+
apply = () => {},
|
|
612
|
+
...detectOverflowOptions
|
|
613
|
+
} = options;
|
|
614
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
615
|
+
const side = getSide(placement);
|
|
616
|
+
const alignment = getAlignment(placement);
|
|
617
|
+
const axis = getMainAxisFromPlacement(placement);
|
|
618
|
+
const isXAxis = axis === 'x';
|
|
619
|
+
const {
|
|
620
|
+
width,
|
|
621
|
+
height
|
|
622
|
+
} = rects.floating;
|
|
623
|
+
let heightSide;
|
|
624
|
+
let widthSide;
|
|
625
|
+
if (side === 'top' || side === 'bottom') {
|
|
626
|
+
heightSide = side;
|
|
627
|
+
widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
|
|
628
|
+
} else {
|
|
629
|
+
widthSide = side;
|
|
630
|
+
heightSide = alignment === 'end' ? 'top' : 'bottom';
|
|
631
|
+
}
|
|
632
|
+
const overflowAvailableHeight = height - overflow[heightSide];
|
|
633
|
+
const overflowAvailableWidth = width - overflow[widthSide];
|
|
634
|
+
const noShift = !state.middlewareData.shift;
|
|
635
|
+
let availableHeight = overflowAvailableHeight;
|
|
636
|
+
let availableWidth = overflowAvailableWidth;
|
|
637
|
+
if (isXAxis) {
|
|
638
|
+
const maximumClippingWidth = width - overflow.left - overflow.right;
|
|
639
|
+
availableWidth = alignment || noShift ? min$1(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
|
|
640
|
+
} else {
|
|
641
|
+
const maximumClippingHeight = height - overflow.top - overflow.bottom;
|
|
642
|
+
availableHeight = alignment || noShift ? min$1(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
|
|
643
|
+
}
|
|
644
|
+
if (noShift && !alignment) {
|
|
645
|
+
const xMin = max$1(overflow.left, 0);
|
|
646
|
+
const xMax = max$1(overflow.right, 0);
|
|
647
|
+
const yMin = max$1(overflow.top, 0);
|
|
648
|
+
const yMax = max$1(overflow.bottom, 0);
|
|
649
|
+
if (isXAxis) {
|
|
650
|
+
availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right));
|
|
651
|
+
} else {
|
|
652
|
+
availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
await apply({
|
|
656
|
+
...state,
|
|
657
|
+
availableWidth,
|
|
658
|
+
availableHeight
|
|
659
|
+
});
|
|
660
|
+
const nextDimensions = await platform.getDimensions(elements.floating);
|
|
661
|
+
if (width !== nextDimensions.width || height !== nextDimensions.height) {
|
|
662
|
+
return {
|
|
663
|
+
reset: {
|
|
664
|
+
rects: true
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
return {};
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
|
|
590
673
|
function getWindow(node) {
|
|
591
674
|
var _node$ownerDocument;
|
|
592
675
|
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
@@ -596,28 +679,9 @@ function getComputedStyle$1(element) {
|
|
|
596
679
|
return getWindow(element).getComputedStyle(element);
|
|
597
680
|
}
|
|
598
681
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
const round = Math.round;
|
|
602
|
-
|
|
603
|
-
function getCssDimensions(element) {
|
|
604
|
-
const css = getComputedStyle$1(element);
|
|
605
|
-
let width = parseFloat(css.width);
|
|
606
|
-
let height = parseFloat(css.height);
|
|
607
|
-
const offsetWidth = element.offsetWidth;
|
|
608
|
-
const offsetHeight = element.offsetHeight;
|
|
609
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
610
|
-
if (shouldFallback) {
|
|
611
|
-
width = offsetWidth;
|
|
612
|
-
height = offsetHeight;
|
|
613
|
-
}
|
|
614
|
-
return {
|
|
615
|
-
width,
|
|
616
|
-
height,
|
|
617
|
-
fallback: shouldFallback
|
|
618
|
-
};
|
|
682
|
+
function isNode(value) {
|
|
683
|
+
return value instanceof getWindow(value).Node;
|
|
619
684
|
}
|
|
620
|
-
|
|
621
685
|
function getNodeName(node) {
|
|
622
686
|
return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
|
|
623
687
|
}
|
|
@@ -641,9 +705,6 @@ function isHTMLElement(value) {
|
|
|
641
705
|
function isElement(value) {
|
|
642
706
|
return value instanceof getWindow(value).Element;
|
|
643
707
|
}
|
|
644
|
-
function isNode(value) {
|
|
645
|
-
return value instanceof getWindow(value).Node;
|
|
646
|
-
}
|
|
647
708
|
function isShadowRoot(node) {
|
|
648
709
|
// Browsers without `ShadowRoot` support.
|
|
649
710
|
if (typeof ShadowRoot === 'undefined') {
|
|
@@ -700,6 +761,31 @@ function isLastTraversableNode(node) {
|
|
|
700
761
|
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
701
762
|
}
|
|
702
763
|
|
|
764
|
+
const min = Math.min;
|
|
765
|
+
const max = Math.max;
|
|
766
|
+
const round = Math.round;
|
|
767
|
+
|
|
768
|
+
function getCssDimensions(element) {
|
|
769
|
+
const css = getComputedStyle$1(element);
|
|
770
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
771
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
772
|
+
let width = parseFloat(css.width) || 0;
|
|
773
|
+
let height = parseFloat(css.height) || 0;
|
|
774
|
+
const hasOffset = isHTMLElement(element);
|
|
775
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
776
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
777
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
778
|
+
if (shouldFallback) {
|
|
779
|
+
width = offsetWidth;
|
|
780
|
+
height = offsetHeight;
|
|
781
|
+
}
|
|
782
|
+
return {
|
|
783
|
+
width,
|
|
784
|
+
height,
|
|
785
|
+
fallback: shouldFallback
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
703
789
|
function unwrapElement(element) {
|
|
704
790
|
return !isElement(element) ? element.contextElement : element;
|
|
705
791
|
}
|
|
@@ -781,16 +867,12 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
781
867
|
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
782
868
|
}
|
|
783
869
|
}
|
|
784
|
-
return {
|
|
870
|
+
return rectToClientRect({
|
|
785
871
|
width,
|
|
786
872
|
height,
|
|
787
|
-
top: y,
|
|
788
|
-
right: x + width,
|
|
789
|
-
bottom: y + height,
|
|
790
|
-
left: x,
|
|
791
873
|
x,
|
|
792
874
|
y
|
|
793
|
-
};
|
|
875
|
+
});
|
|
794
876
|
}
|
|
795
877
|
|
|
796
878
|
function getDocumentElement(node) {
|
|
@@ -989,6 +1071,13 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
|
|
|
989
1071
|
}
|
|
990
1072
|
return rectToClientRect(rect);
|
|
991
1073
|
}
|
|
1074
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1075
|
+
const parentNode = getParentNode(element);
|
|
1076
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1080
|
+
}
|
|
992
1081
|
|
|
993
1082
|
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
994
1083
|
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
@@ -1006,19 +1095,17 @@ function getClippingElementAncestors(element, cache) {
|
|
|
1006
1095
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1007
1096
|
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1008
1097
|
const computedStyle = getComputedStyle$1(currentNode);
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
if (shouldIgnoreCurrentNode) {
|
|
1098
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1099
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1012
1100
|
currentContainingBlockComputedStyle = null;
|
|
1101
|
+
}
|
|
1102
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1103
|
+
if (shouldDropCurrentNode) {
|
|
1104
|
+
// Drop non-containing blocks.
|
|
1105
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1013
1106
|
} else {
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
// Drop non-containing blocks.
|
|
1017
|
-
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1018
|
-
} else {
|
|
1019
|
-
// Record last containing block for next iteration.
|
|
1020
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
1021
|
-
}
|
|
1107
|
+
// Record last containing block for next iteration.
|
|
1108
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1022
1109
|
}
|
|
1023
1110
|
currentNode = getParentNode(currentNode);
|
|
1024
1111
|
}
|
|
@@ -1055,10 +1142,7 @@ function getClippingRect(_ref) {
|
|
|
1055
1142
|
}
|
|
1056
1143
|
|
|
1057
1144
|
function getDimensions(element) {
|
|
1058
|
-
|
|
1059
|
-
return getCssDimensions(element);
|
|
1060
|
-
}
|
|
1061
|
-
return element.getBoundingClientRect();
|
|
1145
|
+
return getCssDimensions(element);
|
|
1062
1146
|
}
|
|
1063
1147
|
|
|
1064
1148
|
function getTrueOffsetParent(element, polyfill) {
|
|
@@ -1086,6 +1170,9 @@ function getContainingBlock(element) {
|
|
|
1086
1170
|
// such as table ancestors and cross browser bugs.
|
|
1087
1171
|
function getOffsetParent(element, polyfill) {
|
|
1088
1172
|
const window = getWindow(element);
|
|
1173
|
+
if (!isHTMLElement(element)) {
|
|
1174
|
+
return window;
|
|
1175
|
+
}
|
|
1089
1176
|
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1090
1177
|
while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
|
|
1091
1178
|
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
@@ -1170,27 +1257,26 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1170
1257
|
options = {};
|
|
1171
1258
|
}
|
|
1172
1259
|
const {
|
|
1173
|
-
ancestorScroll
|
|
1260
|
+
ancestorScroll = true,
|
|
1174
1261
|
ancestorResize = true,
|
|
1175
1262
|
elementResize = true,
|
|
1176
1263
|
animationFrame = false
|
|
1177
1264
|
} = options;
|
|
1178
|
-
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1179
1265
|
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : reference.contextElement ? getOverflowAncestors(reference.contextElement) : []), ...getOverflowAncestors(floating)] : [];
|
|
1180
1266
|
ancestors.forEach(ancestor => {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1267
|
+
// ignores Window, checks for [object VisualViewport]
|
|
1268
|
+
const isVisualViewport = !isElement(ancestor) && ancestor.toString().includes('V');
|
|
1269
|
+
if (ancestorScroll && (animationFrame ? isVisualViewport : true)) {
|
|
1270
|
+
ancestor.addEventListener('scroll', update, {
|
|
1271
|
+
passive: true
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1184
1274
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1185
1275
|
});
|
|
1186
1276
|
let observer = null;
|
|
1187
1277
|
if (elementResize) {
|
|
1188
|
-
let initialUpdate = true;
|
|
1189
1278
|
observer = new ResizeObserver(() => {
|
|
1190
|
-
|
|
1191
|
-
update();
|
|
1192
|
-
}
|
|
1193
|
-
initialUpdate = false;
|
|
1279
|
+
update();
|
|
1194
1280
|
});
|
|
1195
1281
|
isElement(reference) && !animationFrame && observer.observe(reference);
|
|
1196
1282
|
if (!isElement(reference) && reference.contextElement && !animationFrame) {
|
|
@@ -1250,6 +1336,6 @@ const computePosition = (reference, floating, options) => {
|
|
|
1250
1336
|
});
|
|
1251
1337
|
};
|
|
1252
1338
|
|
|
1253
|
-
export { autoUpdate as a, computePosition as c, flip as f, offset as o,
|
|
1339
|
+
export { autoUpdate as a, shift as b, computePosition as c, flip as f, offset as o, size as s };
|
|
1254
1340
|
|
|
1255
1341
|
//# sourceMappingURL=floating-ui.dom.esm.js.map
|