@aglyn/shared-util-dom 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +37 -0
- package/src/constants/enums.d.ts +18 -0
- package/src/constants/enums.js +19 -0
- package/src/constants/enums.js.map +1 -0
- package/src/dom.d.ts +100 -0
- package/src/dom.js +51 -0
- package/src/dom.js.map +1 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/controllers/page-title.d.ts +47 -0
- package/src/lib/controllers/page-title.js +114 -0
- package/src/lib/controllers/page-title.js.map +1 -0
- package/src/lib/get-element-client-rect-bounding-inner.d.ts +19 -0
- package/src/lib/get-element-client-rect-bounding-inner.js +31 -0
- package/src/lib/get-element-client-rect-bounding-inner.js.map +1 -0
- package/src/lib/get-element-client-rect-bounding.d.ts +39 -0
- package/src/lib/get-element-client-rect-bounding.js +45 -0
- package/src/lib/get-element-client-rect-bounding.js.map +1 -0
- package/src/lib/get-element-clipping-rect.d.ts +26 -0
- package/src/lib/get-element-clipping-rect.js +77 -0
- package/src/lib/get-element-clipping-rect.js.map +1 -0
- package/src/lib/get-element-computed-style.d.ts +18 -0
- package/src/lib/get-element-computed-style.js +22 -0
- package/src/lib/get-element-computed-style.js.map +1 -0
- package/src/lib/get-element-document-element-rect.d.ts +19 -0
- package/src/lib/get-element-document-element-rect.js +43 -0
- package/src/lib/get-element-document-element-rect.js.map +1 -0
- package/src/lib/get-element-document-element.d.ts +18 -0
- package/src/lib/get-element-document-element.js +23 -0
- package/src/lib/get-element-document-element.js.map +1 -0
- package/src/lib/get-element-fragment-rects.d.ts +93 -0
- package/src/lib/get-element-fragment-rects.js +113 -0
- package/src/lib/get-element-fragment-rects.js.map +1 -0
- package/src/lib/get-element-list-scroll-parents.d.ts +19 -0
- package/src/lib/get-element-list-scroll-parents.js +38 -0
- package/src/lib/get-element-list-scroll-parents.js.map +1 -0
- package/src/lib/get-element-node-name.d.ts +18 -0
- package/src/lib/get-element-node-name.js +21 -0
- package/src/lib/get-element-node-name.js.map +1 -0
- package/src/lib/get-element-offset-parent.d.ts +18 -0
- package/src/lib/get-element-offset-parent.js +81 -0
- package/src/lib/get-element-offset-parent.js.map +1 -0
- package/src/lib/get-element-parent-node.d.ts +18 -0
- package/src/lib/get-element-parent-node.js +31 -0
- package/src/lib/get-element-parent-node.js.map +1 -0
- package/src/lib/get-element-rect-as-client-rect.d.ts +19 -0
- package/src/lib/get-element-rect-as-client-rect.js +27 -0
- package/src/lib/get-element-rect-as-client-rect.js.map +1 -0
- package/src/lib/get-element-scroll-parent.d.ts +18 -0
- package/src/lib/get-element-scroll-parent.js +36 -0
- package/src/lib/get-element-scroll-parent.js.map +1 -0
- package/src/lib/get-element-viewport-rect.d.ts +23 -0
- package/src/lib/get-element-viewport-rect.js +57 -0
- package/src/lib/get-element-viewport-rect.js.map +1 -0
- package/src/lib/get-element-window-scroll-bar-x.d.ts +18 -0
- package/src/lib/get-element-window-scroll-bar-x.js +31 -0
- package/src/lib/get-element-window-scroll-bar-x.js.map +1 -0
- package/src/lib/get-event-coordinates.d.ts +22 -0
- package/src/lib/get-event-coordinates.js +49 -0
- package/src/lib/get-event-coordinates.js.map +1 -0
- package/src/lib/get-iframe-document.d.ts +18 -0
- package/src/lib/get-iframe-document.js +29 -0
- package/src/lib/get-iframe-document.js.map +1 -0
- package/src/lib/get-node-window-scroll.d.ts +21 -0
- package/src/lib/get-node-window-scroll.js +28 -0
- package/src/lib/get-node-window-scroll.js.map +1 -0
- package/src/lib/get-node-window.d.ts +18 -0
- package/src/lib/get-node-window.js +34 -0
- package/src/lib/get-node-window.js.map +1 -0
- package/src/lib/get-owner-document.d.ts +2 -0
- package/src/lib/get-owner-document.js +40 -0
- package/src/lib/get-owner-document.js.map +1 -0
- package/src/lib/guards/element-contains-child-element.d.ts +18 -0
- package/src/lib/guards/element-contains-child-element.js +37 -0
- package/src/lib/guards/element-contains-child-element.js.map +1 -0
- package/src/lib/guards/event-has-viewport-coordinates.d.ts +18 -0
- package/src/lib/guards/event-has-viewport-coordinates.js +21 -0
- package/src/lib/guards/event-has-viewport-coordinates.js.map +1 -0
- package/src/lib/guards/is-element-html-element.d.ts +18 -0
- package/src/lib/guards/is-element-html-element.js +26 -0
- package/src/lib/guards/is-element-html-element.js.map +1 -0
- package/src/lib/guards/is-element-scroll-parent-element.d.ts +2 -0
- package/src/lib/guards/is-element-scroll-parent-element.js +24 -0
- package/src/lib/guards/is-element-scroll-parent-element.js.map +1 -0
- package/src/lib/guards/is-element-window.d.ts +18 -0
- package/src/lib/guards/is-element-window.js +22 -0
- package/src/lib/guards/is-element-window.js.map +1 -0
- package/src/lib/guards/is-keyboard-event.d.ts +18 -0
- package/src/lib/guards/is-keyboard-event.js +26 -0
- package/src/lib/guards/is-keyboard-event.js.map +1 -0
- package/src/lib/guards/is-node-element.d.ts +2 -0
- package/src/lib/guards/is-node-element.js +23 -0
- package/src/lib/guards/is-node-element.js.map +1 -0
- package/src/lib/guards/is-node-object.d.ts +18 -0
- package/src/lib/guards/is-node-object.js +21 -0
- package/src/lib/guards/is-node-object.js.map +1 -0
- package/src/lib/guards/is-node-shadow-root.d.ts +2 -0
- package/src/lib/guards/is-node-shadow-root.js +27 -0
- package/src/lib/guards/is-node-shadow-root.js.map +1 -0
- package/src/lib/guards/is-node-table-element.d.ts +2 -0
- package/src/lib/guards/is-node-table-element.js +26 -0
- package/src/lib/guards/is-node-table-element.js.map +1 -0
- package/src/lib/guards/is-node-window-document.d.ts +18 -0
- package/src/lib/guards/is-node-window-document.js +23 -0
- package/src/lib/guards/is-node-window-document.js.map +1 -0
- package/src/lib/guards/is-svg-element.d.ts +2 -0
- package/src/lib/guards/is-svg-element.js +22 -0
- package/src/lib/guards/is-svg-element.js.map +1 -0
- package/src/lib/guards/is-touch-event.d.ts +18 -0
- package/src/lib/guards/is-touch-event.js +26 -0
- package/src/lib/guards/is-touch-event.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/util/dom/src/lib/controllers/page-title.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { _isStrEmpty, _isUndOrNull } from '@aglyn/shared-util-tools'\nimport { arraySafe } from '@aglyn/shared-util-tools'\nimport { makeAutoObservable } from 'mobx'\nimport { BehaviorSubject } from 'rxjs'\nimport { map } from 'rxjs/operators'\n\nexport type PageTitleObject = {\n number?: number\n screen?: string | string[]\n suffix?: string\n separator?: string\n}\n\nexport class PageTitle {\n public separator?: string = '–'\n public page?: number = 1\n public view?: string = 'Page Title'\n public area?: string = ''\n public prefix?: string = ''\n public suffix?: string = 'My App'\n\n public get value(): string {\n let title = `${this.view}`\n\n if (this.page > 1) title = `${title} (Page ${this.page})`\n\n return [this.prefix, title, this.area, this.suffix]\n .filter(Boolean)\n .join(` ${this.separator} `)\n }\n\n constructor() {\n makeAutoObservable(this)\n }\n\n public setPage(page?: number) {\n this.page = page || 1\n return this\n }\n\n public setView(view?: string) {\n this.view = view || ''\n return this\n }\n\n public setArea(area?: string) {\n this.area = area || ''\n return this\n }\n\n public setPrefix(prefix?: string) {\n this.prefix = prefix || ''\n return this\n }\n\n public setSuffix(suffix?: string) {\n this.suffix = suffix || ''\n return this\n }\n\n public toString(): string {\n return this.value\n }\n}\n\nexport const $title = new PageTitle()\n\nlet _values: PageTitleObject = { suffix: 'My App' }\nexport const $_screenObj = new BehaviorSubject<PageTitleObject>({\n suffix: 'My App',\n})\nexport const $pageTitle = $_screenObj.pipe(map(buildScreenTitle))\n\nfunction buildScreenTitle(values: PageTitleObject): string {\n const { number, screen, suffix, separator } = buildValues(values)\n\n const newTitle = arraySafe(screen, [screen])\n .concat(!number ? null : ` - Page ${number}`, suffix)\n .filter((i) => !_isUndOrNull(i) && !_isStrEmpty(i))\n .join(separator || ' – ')\n\n return newTitle\n}\n\nfunction buildValues(values?: PageTitleObject): PageTitleObject {\n return (_values = {\n number: values.number ?? _values.number,\n screen: values.screen || _values.screen,\n suffix: values.suffix || _values.suffix,\n separator: values.separator || _values.separator,\n })\n}\n\nexport function setScreenName(screen: string, number?: number): void {\n $_screenObj.next(buildValues({ screen, number }))\n}\nexport function setScreenSeparator(separator: string): void {\n $_screenObj.next(buildValues({ separator }))\n}\nexport function setScreenSuffix(suffix: string): void {\n $_screenObj.next(buildValues({ suffix }))\n}\nexport function setScreenNumber(number?: number): void {\n $_screenObj.next(buildValues({ number }))\n}\nexport function setScreenTitle(values: PageTitleObject): void {\n $_screenObj.next(buildValues(values))\n}\n"],"names":["_isStrEmpty","_isUndOrNull","arraySafe","makeAutoObservable","BehaviorSubject","map","PageTitle","value","title","view","page","prefix","area","suffix","filter","Boolean","join","separator","setPage","setView","setArea","setPrefix","setSuffix","toString","$title","_values","$_screenObj","$pageTitle","pipe","buildScreenTitle","values","number","screen","buildValues","newTitle","concat","i","setScreenName","next","setScreenSeparator","setScreenSuffix","setScreenNumber","setScreenTitle"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,EAAEC,YAAY,QAAQ,2BAA0B;AACpE,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,kBAAkB,QAAQ,OAAM;AACzC,SAASC,eAAe,QAAQ,OAAM;AACtC,SAASC,GAAG,QAAQ,iBAAgB;AASpC,OAAO,MAAMC;IAQX,IAAWC,QAAgB;QACzB,IAAIC,QAAQ,GAAG,IAAI,CAACC,IAAI,EAAE;QAE1B,IAAI,IAAI,CAACC,IAAI,GAAG,GAAGF,QAAQ,GAAGA,MAAM,OAAO,EAAE,IAAI,CAACE,IAAI,CAAC,CAAC,CAAC;QAEzD,OAAO;YAAC,IAAI,CAACC,MAAM;YAAEH;YAAO,IAAI,CAACI,IAAI;YAAE,IAAI,CAACC,MAAM;SAAC,CAChDC,MAAM,CAACC,SACPC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC;IAC/B;IAMOC,QAAQR,IAAa,EAAE;QAC5B,IAAI,CAACA,IAAI,GAAGA,QAAQ;QACpB,OAAO,IAAI;IACb;IAEOS,QAAQV,IAAa,EAAE;QAC5B,IAAI,CAACA,IAAI,GAAGA,QAAQ;QACpB,OAAO,IAAI;IACb;IAEOW,QAAQR,IAAa,EAAE;QAC5B,IAAI,CAACA,IAAI,GAAGA,QAAQ;QACpB,OAAO,IAAI;IACb;IAEOS,UAAUV,MAAe,EAAE;QAChC,IAAI,CAACA,MAAM,GAAGA,UAAU;QACxB,OAAO,IAAI;IACb;IAEOW,UAAUT,MAAe,EAAE;QAChC,IAAI,CAACA,MAAM,GAAGA,UAAU;QACxB,OAAO,IAAI;IACb;IAEOU,WAAmB;QACxB,OAAO,IAAI,CAAChB,KAAK;IACnB;IA/BA,aAAc;aAjBPU,YAAqB;aACrBP,OAAgB;aAChBD,OAAgB;aAChBG,OAAgB;aAChBD,SAAkB;aAClBE,SAAkB;QAavBV,mBAAmB,IAAI;IACzB;AA8BF;AAEA,OAAO,MAAMqB,SAAS,IAAIlB,YAAW;AAErC,IAAImB,UAA2B;IAAEZ,QAAQ;AAAS;AAClD,OAAO,MAAMa,cAAc,IAAItB,gBAAiC;IAC9DS,QAAQ;AACV,GAAE;AACF,OAAO,MAAMc,aAAaD,YAAYE,IAAI,CAACvB,IAAIwB,mBAAkB;AAEjE,SAASA,iBAAiBC,MAAuB;IAC/C,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEnB,MAAM,EAAEI,SAAS,EAAE,GAAGgB,YAAYH;IAE1D,MAAMI,WAAWhC,UAAU8B,QAAQ;QAACA;KAAO,EACxCG,MAAM,CAAC,CAACJ,SAAS,OAAO,CAAC,QAAQ,EAAEA,QAAQ,EAAElB,QAC7CC,MAAM,CAAC,CAACsB,IAAM,CAACnC,aAAamC,MAAM,CAACpC,YAAYoC,IAC/CpB,IAAI,CAACC,aAAa;IAErB,OAAOiB;AACT;AAEA,SAASD,YAAYH,MAAwB;QAEjCA;IADV,OAAQL,UAAU;QAChBM,MAAM,GAAED,iBAAAA,OAAOC,MAAM,YAAbD,iBAAiBL,QAAQM,MAAM;QACvCC,QAAQF,OAAOE,MAAM,IAAIP,QAAQO,MAAM;QACvCnB,QAAQiB,OAAOjB,MAAM,IAAIY,QAAQZ,MAAM;QACvCI,WAAWa,OAAOb,SAAS,IAAIQ,QAAQR,SAAS;IAClD;AACF;AAEA,OAAO,SAASoB,cAAcL,MAAc,EAAED,MAAe;IAC3DL,YAAYY,IAAI,CAACL,YAAY;QAAED;QAAQD;IAAO;AAChD;AACA,OAAO,SAASQ,mBAAmBtB,SAAiB;IAClDS,YAAYY,IAAI,CAACL,YAAY;QAAEhB;IAAU;AAC3C;AACA,OAAO,SAASuB,gBAAgB3B,MAAc;IAC5Ca,YAAYY,IAAI,CAACL,YAAY;QAAEpB;IAAO;AACxC;AACA,OAAO,SAAS4B,gBAAgBV,MAAe;IAC7CL,YAAYY,IAAI,CAACL,YAAY;QAAEF;IAAO;AACxC;AACA,OAAO,SAASW,eAAeZ,MAAuB;IACpDJ,YAAYY,IAAI,CAACL,YAAYH;AAC/B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { ClientRectObject } from '../dom';
|
|
18
|
+
export declare function getElementClientRectBoundingInner(element: Element): ClientRectObject;
|
|
19
|
+
export default getElementClientRectBoundingInner;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { getElementClientRectBounding } from "./get-element-client-rect-bounding.js";
|
|
17
|
+
export function getElementClientRectBoundingInner(element) {
|
|
18
|
+
const rect = getElementClientRectBounding(element);
|
|
19
|
+
rect.top = rect.top + element.clientTop;
|
|
20
|
+
rect.left = rect.left + element.clientLeft;
|
|
21
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
22
|
+
rect.right = rect.left + element.clientWidth;
|
|
23
|
+
rect.width = element.clientWidth;
|
|
24
|
+
rect.height = element.clientHeight;
|
|
25
|
+
rect.x = rect.left;
|
|
26
|
+
rect.y = rect.top;
|
|
27
|
+
return rect;
|
|
28
|
+
}
|
|
29
|
+
export default getElementClientRectBoundingInner;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=get-element-client-rect-bounding-inner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-client-rect-bounding-inner.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {ClientRectObject} from '../dom'\nimport {getElementClientRectBounding} from './get-element-client-rect-bounding'\n\n\nexport function getElementClientRectBoundingInner(\n element: Element,\n): ClientRectObject {\n const rect = getElementClientRectBounding(element)\n rect.top = rect.top + element.clientTop\n rect.left = rect.left + element.clientLeft\n rect.bottom = rect.top + element.clientHeight\n rect.right = rect.left + element.clientWidth\n rect.width = element.clientWidth\n rect.height = element.clientHeight\n rect.x = rect.left\n rect.y = rect.top\n return rect\n}\nexport default getElementClientRectBoundingInner\n"],"names":["getElementClientRectBounding","getElementClientRectBoundingInner","element","rect","top","clientTop","left","clientLeft","bottom","clientHeight","right","clientWidth","width","height","x","y"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAAQA,4BAA4B,QAAO,wCAAoC;AAG/E,OAAO,SAASC,kCACdC,OAAgB;IAEhB,MAAMC,OAAOH,6BAA6BE;IAC1CC,KAAKC,GAAG,GAAGD,KAAKC,GAAG,GAAGF,QAAQG,SAAS;IACvCF,KAAKG,IAAI,GAAGH,KAAKG,IAAI,GAAGJ,QAAQK,UAAU;IAC1CJ,KAAKK,MAAM,GAAGL,KAAKC,GAAG,GAAGF,QAAQO,YAAY;IAC7CN,KAAKO,KAAK,GAAGP,KAAKG,IAAI,GAAGJ,QAAQS,WAAW;IAC5CR,KAAKS,KAAK,GAAGV,QAAQS,WAAW;IAChCR,KAAKU,MAAM,GAAGX,QAAQO,YAAY;IAClCN,KAAKW,CAAC,GAAGX,KAAKG,IAAI;IAClBH,KAAKY,CAAC,GAAGZ,KAAKC,GAAG;IACjB,OAAOD;AACT;AACA,eAAeF,kCAAiC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { VirtualElement } from '../dom';
|
|
18
|
+
export type BoundingClientRect = {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
top: number;
|
|
22
|
+
right: number;
|
|
23
|
+
bottom: number;
|
|
24
|
+
left: number;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING: {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
top: number;
|
|
32
|
+
right: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
left: number;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function getElementClientRectBounding(element: Element | VirtualElement): BoundingClientRect;
|
|
39
|
+
export default getElementClientRectBounding;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
|
+
export const DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING = {
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
top: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
};
|
|
27
|
+
export function getElementClientRectBounding(element) {
|
|
28
|
+
var _element_getBoundingClientRect;
|
|
29
|
+
const { width, height, left, top, right, bottom } = (element == null ? void 0 : (_element_getBoundingClientRect = element.getBoundingClientRect) == null ? void 0 : _element_getBoundingClientRect.call(element)) || _extends({}, DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING);
|
|
30
|
+
const scaleX = 1;
|
|
31
|
+
const scaleY = 1;
|
|
32
|
+
return {
|
|
33
|
+
width: width / scaleX,
|
|
34
|
+
height: height / scaleY,
|
|
35
|
+
top: top / scaleY,
|
|
36
|
+
right: right / scaleX,
|
|
37
|
+
bottom: bottom / scaleY,
|
|
38
|
+
left: left / scaleX,
|
|
39
|
+
x: left / scaleX,
|
|
40
|
+
y: top / scaleY
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export default getElementClientRectBounding;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=get-element-client-rect-bounding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-client-rect-bounding.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { VirtualElement } from '../dom'\n\nexport type BoundingClientRect = {\n width: number\n height: number\n top: number\n right: number\n bottom: number\n left: number\n x: number\n y: number\n}\n\nexport const DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING = {\n width: 0,\n height: 0,\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n x: 0,\n y: 0,\n}\n\nexport function getElementClientRectBounding(\n element: Element | VirtualElement,\n): BoundingClientRect {\n const { width, height, left, top, right, bottom } =\n element?.getBoundingClientRect?.() || {\n ...DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING,\n }\n const scaleX = 1\n const scaleY = 1\n\n return {\n width: width / scaleX,\n height: height / scaleY,\n top: top / scaleY,\n right: right / scaleX,\n bottom: bottom / scaleY,\n left: left / scaleX,\n x: left / scaleX,\n y: top / scaleY,\n }\n}\nexport default getElementClientRectBounding\n"],"names":["DEFAULT_ELEMENT_CLIENT_RECT_BOUNDING","width","height","top","right","bottom","left","x","y","getElementClientRectBounding","element","getBoundingClientRect","scaleX","scaleY"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAcD,OAAO,MAAMA,uCAAuC;IAClDC,OAAO;IACPC,QAAQ;IACRC,KAAK;IACLC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,GAAG;IACHC,GAAG;AACL,EAAC;AAED,OAAO,SAASC,6BACdC,OAAiC;QAG/BA;IADF,MAAM,EAAET,KAAK,EAAEC,MAAM,EAAEI,IAAI,EAAEH,GAAG,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAC/CK,CAAAA,4BAAAA,iCAAAA,QAASC,qBAAqB,qBAA9BD,oCAAAA,aAAsC,aACjCV;IAEP,MAAMY,SAAS;IACf,MAAMC,SAAS;IAEf,OAAO;QACLZ,OAAOA,QAAQW;QACfV,QAAQA,SAASW;QACjBV,KAAKA,MAAMU;QACXT,OAAOA,QAAQQ;QACfP,QAAQA,SAASQ;QACjBP,MAAMA,OAAOM;QACbL,GAAGD,OAAOM;QACVJ,GAAGL,MAAMU;IACX;AACF;AACA,eAAeJ,6BAA4B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { Boundary, ClientRectObject, RootBoundary } from '../dom';
|
|
18
|
+
/**
|
|
19
|
+
* Gets the maximum area that the element is visible in due to any number of
|
|
20
|
+
* clipping parents
|
|
21
|
+
* @param element
|
|
22
|
+
* @param boundary
|
|
23
|
+
* @param rootBoundary
|
|
24
|
+
*/
|
|
25
|
+
export declare function getElementClippingRect(element: Element, boundary: Boundary, rootBoundary: RootBoundary): ClientRectObject;
|
|
26
|
+
export default getElementClippingRect;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { viewport } from "../constants/enums.js";
|
|
17
|
+
import { getElementClientRectBoundingInner } from "./get-element-client-rect-bounding-inner.js";
|
|
18
|
+
import { getElementDocumentElement } from "./get-element-document-element.js";
|
|
19
|
+
import { getElementDocumentElementRect } from "./get-element-document-element-rect.js";
|
|
20
|
+
import { getElementListScrollParents } from "./get-element-list-scroll-parents.js";
|
|
21
|
+
import { getElementNodeName } from "./get-element-node-name.js";
|
|
22
|
+
import { getElementOffsetParent } from "./get-element-offset-parent.js";
|
|
23
|
+
import { getElementParentNode } from "./get-element-parent-node.js";
|
|
24
|
+
import { getElementRectAsClientRect } from "./get-element-rect-as-client-rect.js";
|
|
25
|
+
import { getElementViewportRect } from "./get-element-viewport-rect.js";
|
|
26
|
+
import { elementContainsChildElement } from "./guards/element-contains-child-element.js";
|
|
27
|
+
import { isElementHTMLElement } from "./guards/is-element-html-element.js";
|
|
28
|
+
import { isNodeElement } from "./guards/is-node-element.js";
|
|
29
|
+
function getClientRectFromMixedType(element, clippingParent) {
|
|
30
|
+
return clippingParent === viewport ? getElementRectAsClientRect(getElementViewportRect(element)) : isElementHTMLElement(clippingParent) ? getElementClientRectBoundingInner(clippingParent) : getElementRectAsClientRect(getElementDocumentElementRect(getElementDocumentElement(element)));
|
|
31
|
+
}
|
|
32
|
+
// A "clipping parent" is an overflowable container with the characteristic of
|
|
33
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
34
|
+
// `initial`
|
|
35
|
+
function getElementClippingParents(element) {
|
|
36
|
+
const clippingParents = getElementListScrollParents(getElementParentNode(element));
|
|
37
|
+
const canEscapeClipping = [
|
|
38
|
+
'absolute',
|
|
39
|
+
'fixed'
|
|
40
|
+
].indexOf(getComputedStyle(element).position) >= 0;
|
|
41
|
+
const clipperElement = canEscapeClipping && isElementHTMLElement(element) ? getElementOffsetParent(element) : element;
|
|
42
|
+
if (!isNodeElement(clipperElement)) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
// $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
|
46
|
+
return clippingParents.filter((clippingParent)=>isNodeElement(clippingParent) && elementContainsChildElement(clippingParent, clipperElement) && getElementNodeName(clippingParent) !== 'body');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets the maximum area that the element is visible in due to any number of
|
|
50
|
+
* clipping parents
|
|
51
|
+
* @param element
|
|
52
|
+
* @param boundary
|
|
53
|
+
* @param rootBoundary
|
|
54
|
+
*/ export function getElementClippingRect(element, boundary, rootBoundary) {
|
|
55
|
+
const mainClippingParents = boundary === 'clippingParents' ? getElementClippingParents(element) : [].concat(boundary);
|
|
56
|
+
const clippingParents = [
|
|
57
|
+
...mainClippingParents,
|
|
58
|
+
rootBoundary
|
|
59
|
+
];
|
|
60
|
+
const firstClippingParent = clippingParents[0];
|
|
61
|
+
const clippingRect = clippingParents.reduce((accRect, clippingParent)=>{
|
|
62
|
+
const rect = getClientRectFromMixedType(element, clippingParent);
|
|
63
|
+
accRect.top = Math.max(rect.top, accRect.top);
|
|
64
|
+
accRect.right = Math.min(rect.right, accRect.right);
|
|
65
|
+
accRect.bottom = Math.min(rect.bottom, accRect.bottom);
|
|
66
|
+
accRect.left = Math.max(rect.left, accRect.left);
|
|
67
|
+
return accRect;
|
|
68
|
+
}, getClientRectFromMixedType(element, firstClippingParent));
|
|
69
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
70
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
71
|
+
clippingRect.x = clippingRect.left;
|
|
72
|
+
clippingRect.y = clippingRect.top;
|
|
73
|
+
return clippingRect;
|
|
74
|
+
}
|
|
75
|
+
export default getElementClippingRect;
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=get-element-clipping-rect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-clipping-rect.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {viewport} from '../constants/enums'\nimport type {Boundary, ClientRectObject, RootBoundary} from '../dom'\nimport {getElementClientRectBoundingInner} from './get-element-client-rect-bounding-inner'\nimport {getElementDocumentElement} from './get-element-document-element'\nimport {getElementDocumentElementRect} from './get-element-document-element-rect'\nimport {getElementListScrollParents} from './get-element-list-scroll-parents'\nimport {getElementNodeName} from './get-element-node-name'\nimport {getElementOffsetParent} from './get-element-offset-parent'\nimport {getElementParentNode} from './get-element-parent-node'\nimport {getElementRectAsClientRect} from './get-element-rect-as-client-rect'\nimport {getElementViewportRect} from './get-element-viewport-rect'\nimport {elementContainsChildElement} from './guards/element-contains-child-element'\nimport {isElementHTMLElement} from './guards/is-element-html-element'\nimport {isNodeElement} from './guards/is-node-element'\n\n\nfunction getClientRectFromMixedType(\n element: Element,\n clippingParent: Element | RootBoundary,\n): ClientRectObject {\n return clippingParent === viewport\n ? getElementRectAsClientRect(getElementViewportRect(element))\n : isElementHTMLElement(clippingParent as Element)\n ? getElementClientRectBoundingInner(clippingParent as Element)\n : getElementRectAsClientRect(getElementDocumentElementRect(getElementDocumentElement(element)))\n}\n// A \"clipping parent\" is an overflowable container with the characteristic of\n// clipping (or hiding) overflowing elements with a position different from\n// `initial`\nfunction getElementClippingParents(element: Element): Array<Element> {\n const clippingParents = getElementListScrollParents(getElementParentNode(element))\n const canEscapeClipping =\n ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0\n const clipperElement =\n canEscapeClipping && isElementHTMLElement(element)\n ? getElementOffsetParent(element)\n : element\n\n if (!isNodeElement(clipperElement)) {\n return []\n }\n\n // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414\n return clippingParents.filter(\n (clippingParent) =>\n isNodeElement(clippingParent) &&\n elementContainsChildElement(clippingParent as Element, clipperElement as Element) &&\n getElementNodeName(clippingParent as Element) !== 'body',\n ) as Element[]\n}\n\n\n/**\n * Gets the maximum area that the element is visible in due to any number of\n * clipping parents\n * @param element\n * @param boundary\n * @param rootBoundary\n */\nexport function getElementClippingRect(\n element: Element,\n boundary: Boundary,\n rootBoundary: RootBoundary,\n): ClientRectObject {\n const mainClippingParents =\n boundary === 'clippingParents'\n ? getElementClippingParents(element)\n : [].concat(boundary)\n const clippingParents = [...mainClippingParents, rootBoundary]\n const firstClippingParent = clippingParents[0]\n\n const clippingRect = clippingParents.reduce((accRect, clippingParent) => {\n const rect = getClientRectFromMixedType(element, clippingParent)\n\n accRect.top = Math.max(rect.top, accRect.top)\n accRect.right = Math.min(rect.right, accRect.right)\n accRect.bottom = Math.min(rect.bottom, accRect.bottom)\n accRect.left = Math.max(rect.left, accRect.left)\n\n return accRect\n }, getClientRectFromMixedType(element, firstClippingParent))\n\n clippingRect.width = clippingRect.right - clippingRect.left\n clippingRect.height = clippingRect.bottom - clippingRect.top\n clippingRect.x = clippingRect.left\n clippingRect.y = clippingRect.top\n\n return clippingRect\n}\nexport default getElementClippingRect\n"],"names":["viewport","getElementClientRectBoundingInner","getElementDocumentElement","getElementDocumentElementRect","getElementListScrollParents","getElementNodeName","getElementOffsetParent","getElementParentNode","getElementRectAsClientRect","getElementViewportRect","elementContainsChildElement","isElementHTMLElement","isNodeElement","getClientRectFromMixedType","element","clippingParent","getElementClippingParents","clippingParents","canEscapeClipping","indexOf","getComputedStyle","position","clipperElement","filter","getElementClippingRect","boundary","rootBoundary","mainClippingParents","concat","firstClippingParent","clippingRect","reduce","accRect","rect","top","Math","max","right","min","bottom","left","width","height","x","y"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAAQA,QAAQ,QAAO,wBAAoB;AAE3C,SAAQC,iCAAiC,QAAO,8CAA0C;AAC1F,SAAQC,yBAAyB,QAAO,oCAAgC;AACxE,SAAQC,6BAA6B,QAAO,yCAAqC;AACjF,SAAQC,2BAA2B,QAAO,uCAAmC;AAC7E,SAAQC,kBAAkB,QAAO,6BAAyB;AAC1D,SAAQC,sBAAsB,QAAO,iCAA6B;AAClE,SAAQC,oBAAoB,QAAO,+BAA2B;AAC9D,SAAQC,0BAA0B,QAAO,uCAAmC;AAC5E,SAAQC,sBAAsB,QAAO,iCAA6B;AAClE,SAAQC,2BAA2B,QAAO,6CAAyC;AACnF,SAAQC,oBAAoB,QAAO,sCAAkC;AACrE,SAAQC,aAAa,QAAO,8BAA0B;AAGtD,SAASC,2BACPC,OAAgB,EAChBC,cAAsC;IAEtC,OAAOA,mBAAmBf,WACtBQ,2BAA2BC,uBAAuBK,YAClDH,qBAAqBI,kBACnBd,kCAAkCc,kBAClCP,2BAA2BL,8BAA8BD,0BAA0BY;AAC3F;AACA,8EAA8E;AAC9E,2EAA2E;AAC3E,YAAY;AACZ,SAASE,0BAA0BF,OAAgB;IACjD,MAAMG,kBAAkBb,4BAA4BG,qBAAqBO;IACzE,MAAMI,oBACJ;QAAC;QAAY;KAAQ,CAACC,OAAO,CAACC,iBAAiBN,SAASO,QAAQ,KAAK;IACvE,MAAMC,iBACJJ,qBAAqBP,qBAAqBG,WACtCR,uBAAuBQ,WACvBA;IAEN,IAAI,CAACF,cAAcU,iBAAiB;QAClC,OAAO,EAAE;IACX;IAEA,gFAAgF;IAChF,OAAOL,gBAAgBM,MAAM,CAC3B,CAACR,iBACCH,cAAcG,mBACdL,4BAA4BK,gBAA2BO,mBACvDjB,mBAAmBU,oBAA+B;AAExD;AAGA;;;;;;CAMC,GACD,OAAO,SAASS,uBACdV,OAAgB,EAChBW,QAAkB,EAClBC,YAA0B;IAE1B,MAAMC,sBACJF,aAAa,oBACTT,0BAA0BF,WAC1B,EAAE,CAACc,MAAM,CAACH;IAChB,MAAMR,kBAAkB;WAAIU;QAAqBD;KAAa;IAC9D,MAAMG,sBAAsBZ,eAAe,CAAC,EAAE;IAE9C,MAAMa,eAAeb,gBAAgBc,MAAM,CAAC,CAACC,SAASjB;QACpD,MAAMkB,OAAOpB,2BAA2BC,SAASC;QAEjDiB,QAAQE,GAAG,GAAGC,KAAKC,GAAG,CAACH,KAAKC,GAAG,EAAEF,QAAQE,GAAG;QAC5CF,QAAQK,KAAK,GAAGF,KAAKG,GAAG,CAACL,KAAKI,KAAK,EAAEL,QAAQK,KAAK;QAClDL,QAAQO,MAAM,GAAGJ,KAAKG,GAAG,CAACL,KAAKM,MAAM,EAAEP,QAAQO,MAAM;QACrDP,QAAQQ,IAAI,GAAGL,KAAKC,GAAG,CAACH,KAAKO,IAAI,EAAER,QAAQQ,IAAI;QAE/C,OAAOR;IACT,GAAGnB,2BAA2BC,SAASe;IAEvCC,aAAaW,KAAK,GAAGX,aAAaO,KAAK,GAAGP,aAAaU,IAAI;IAC3DV,aAAaY,MAAM,GAAGZ,aAAaS,MAAM,GAAGT,aAAaI,GAAG;IAC5DJ,aAAaa,CAAC,GAAGb,aAAaU,IAAI;IAClCV,aAAac,CAAC,GAAGd,aAAaI,GAAG;IAEjC,OAAOJ;AACT;AACA,eAAeN,uBAAsB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getElementComputedStyle(element: Element): CSSStyleDeclaration;
|
|
18
|
+
export default getElementComputedStyle;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { getNodeWindow } from "./get-node-window.js";
|
|
17
|
+
export function getElementComputedStyle(element) {
|
|
18
|
+
return getNodeWindow(element).getComputedStyle(element);
|
|
19
|
+
}
|
|
20
|
+
export default getElementComputedStyle;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=get-element-computed-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-computed-style.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {getNodeWindow} from './get-node-window'\n\n\nexport function getElementComputedStyle(\n element: Element,\n): CSSStyleDeclaration {\n return getNodeWindow(element).getComputedStyle(element)\n}\n\nexport default getElementComputedStyle\n"],"names":["getNodeWindow","getElementComputedStyle","element","getComputedStyle"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAAQA,aAAa,QAAO,uBAAmB;AAG/C,OAAO,SAASC,wBACdC,OAAgB;IAEhB,OAAOF,cAAcE,SAASC,gBAAgB,CAACD;AACjD;AAEA,eAAeD,wBAAuB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { Rect } from '../dom';
|
|
18
|
+
export declare function getElementDocumentElementRect(element: HTMLElement): Rect;
|
|
19
|
+
export default getElementDocumentElementRect;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { getElementComputedStyle } from "./get-element-computed-style.js";
|
|
17
|
+
import { getElementDocumentElement } from "./get-element-document-element.js";
|
|
18
|
+
import { getElementWindowScrollBarX } from "./get-element-window-scroll-bar-x.js";
|
|
19
|
+
import { getNodeWindowScroll } from "./get-node-window-scroll.js";
|
|
20
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
21
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
22
|
+
export function getElementDocumentElementRect(element) {
|
|
23
|
+
var _element_ownerDocument;
|
|
24
|
+
const html = getElementDocumentElement(element);
|
|
25
|
+
const winScroll = getNodeWindowScroll(element);
|
|
26
|
+
const body = (_element_ownerDocument = element.ownerDocument) == null ? void 0 : _element_ownerDocument.body;
|
|
27
|
+
const width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
28
|
+
const height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
29
|
+
let x = -winScroll.scrollLeft + getElementWindowScrollBarX(element);
|
|
30
|
+
const y = -winScroll.scrollTop;
|
|
31
|
+
if (getElementComputedStyle(body || html).direction === 'rtl') {
|
|
32
|
+
x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
x,
|
|
38
|
+
y
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export default getElementDocumentElementRect;
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=get-element-document-element-rect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-document-element-rect.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n\nimport type {Rect} from '../dom'\nimport {getElementComputedStyle} from './get-element-computed-style'\nimport {getElementDocumentElement} from './get-element-document-element'\nimport {getElementWindowScrollBarX} from './get-element-window-scroll-bar-x'\nimport {getNodeWindowScroll} from './get-node-window-scroll'\n\n// Gets the entire size of the scrollable document area, even extending outside\n// of the `<html>` and `<body>` rect bounds if horizontally scrollable\nexport function getElementDocumentElementRect(element: HTMLElement): Rect {\n const html = getElementDocumentElement(element)\n const winScroll = getNodeWindowScroll(element)\n const body = element.ownerDocument?.body\n\n const width = Math.max(\n html.scrollWidth,\n html.clientWidth,\n body ? body.scrollWidth : 0,\n body ? body.clientWidth : 0,\n )\n const height = Math.max(\n html.scrollHeight,\n html.clientHeight,\n body ? body.scrollHeight : 0,\n body ? body.clientHeight : 0,\n )\n\n let x = -winScroll.scrollLeft + getElementWindowScrollBarX(element)\n const y = -winScroll.scrollTop\n\n if (getElementComputedStyle(body || html).direction === 'rtl') {\n x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width\n }\n\n return {width, height, x, y}\n}\nexport default getElementDocumentElementRect\n"],"names":["getElementComputedStyle","getElementDocumentElement","getElementWindowScrollBarX","getNodeWindowScroll","getElementDocumentElementRect","element","html","winScroll","body","ownerDocument","width","Math","max","scrollWidth","clientWidth","height","scrollHeight","clientHeight","x","scrollLeft","y","scrollTop","direction"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SAAQA,uBAAuB,QAAO,kCAA8B;AACpE,SAAQC,yBAAyB,QAAO,oCAAgC;AACxE,SAAQC,0BAA0B,QAAO,uCAAmC;AAC5E,SAAQC,mBAAmB,QAAO,8BAA0B;AAE5D,+EAA+E;AAC/E,sEAAsE;AACtE,OAAO,SAASC,8BAA8BC,OAAoB;QAGnDA;IAFb,MAAMC,OAAOL,0BAA0BI;IACvC,MAAME,YAAYJ,oBAAoBE;IACtC,MAAMG,QAAOH,yBAAAA,QAAQI,aAAa,qBAArBJ,uBAAuBG,IAAI;IAExC,MAAME,QAAQC,KAAKC,GAAG,CACpBN,KAAKO,WAAW,EAChBP,KAAKQ,WAAW,EAChBN,OAAOA,KAAKK,WAAW,GAAG,GAC1BL,OAAOA,KAAKM,WAAW,GAAG;IAE5B,MAAMC,SAASJ,KAAKC,GAAG,CACrBN,KAAKU,YAAY,EACjBV,KAAKW,YAAY,EACjBT,OAAOA,KAAKQ,YAAY,GAAG,GAC3BR,OAAOA,KAAKS,YAAY,GAAG;IAG7B,IAAIC,IAAI,CAACX,UAAUY,UAAU,GAAGjB,2BAA2BG;IAC3D,MAAMe,IAAI,CAACb,UAAUc,SAAS;IAE9B,IAAIrB,wBAAwBQ,QAAQF,MAAMgB,SAAS,KAAK,OAAO;QAC7DJ,KAAKP,KAAKC,GAAG,CAACN,KAAKQ,WAAW,EAAEN,OAAOA,KAAKM,WAAW,GAAG,KAAKJ;IACjE;IAEA,OAAO;QAACA;QAAOK;QAAQG;QAAGE;IAAC;AAC7B;AACA,eAAehB,8BAA6B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getElementDocumentElement(element: Element | Window): HTMLElement;
|
|
18
|
+
export default getElementDocumentElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { isNodeElement } from "./guards/is-node-element.js";
|
|
17
|
+
export function getElementDocumentElement(element) {
|
|
18
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
19
|
+
return ((isNodeElement(element) ? element['ownerDocument'] : element['document']) || window.document).documentElement;
|
|
20
|
+
}
|
|
21
|
+
export default getElementDocumentElement;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=get-element-document-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/get-element-document-element.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {isNodeElement} from './guards/is-node-element'\n\n\nexport function getElementDocumentElement(\n element: Element | Window,\n): HTMLElement {\n // $FlowFixMe[incompatible-return]: assume body is always available\n return (\n (\n isNodeElement(element) ? element['ownerDocument'] : element['document']\n ) || window.document\n ).documentElement\n}\n\nexport default getElementDocumentElement\n"],"names":["isNodeElement","getElementDocumentElement","element","window","document","documentElement"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAAQA,aAAa,QAAO,8BAA0B;AAGtD,OAAO,SAASC,0BACdC,OAAyB;IAEzB,mEAAmE;IACnE,OAAO,AACL,CAAA,AACEF,CAAAA,cAAcE,WAAWA,OAAO,CAAC,gBAAgB,GAAGA,OAAO,CAAC,WAAW,AAAD,KACnEC,OAAOC,QAAQ,AAAD,EACnBC,eAAe;AACnB;AAEA,eAAeJ,0BAAyB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type BoundingClientRect } from './get-element-client-rect-bounding';
|
|
18
|
+
export interface ElementFragmentRects {
|
|
19
|
+
/**
|
|
20
|
+
* One box per LINE FRAGMENT, in viewport pixels, in content order.
|
|
21
|
+
*
|
|
22
|
+
* A block has exactly one. An inline run that has wrapped has one per line
|
|
23
|
+
* it occupies, and no single rectangle describes it.
|
|
24
|
+
*/
|
|
25
|
+
fragments: BoundingClientRect[];
|
|
26
|
+
/**
|
|
27
|
+
* The union of `fragments` — by definition identical to
|
|
28
|
+
* `getBoundingClientRect()`, which the CSSOM spec defines as the union of
|
|
29
|
+
* `getClientRects()`.
|
|
30
|
+
*/
|
|
31
|
+
union: BoundingClientRect;
|
|
32
|
+
/**
|
|
33
|
+
* The fragment the run STARTS on, i.e. `fragments[0]`.
|
|
34
|
+
*
|
|
35
|
+
* This is the anchor for anything that must sit at "the element", because
|
|
36
|
+
* the union's top-left can be a point the element does not occupy: an
|
|
37
|
+
* inline run that begins mid-line and wraps has a union whose left edge
|
|
38
|
+
* comes from the SECOND line, so chrome placed there floats over a sibling
|
|
39
|
+
* rather than over the element it names.
|
|
40
|
+
*/
|
|
41
|
+
first: BoundingClientRect;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Where an element actually is, as the set of boxes it really occupies
|
|
45
|
+
* (AGL-2486).
|
|
46
|
+
*
|
|
47
|
+
* ## The defect this exists for
|
|
48
|
+
*
|
|
49
|
+
* The besigner draws selection, hover, the drag affordance and the
|
|
50
|
+
* collaborator selection boxes from element geometry. Taking that from ONE
|
|
51
|
+
* `getBoundingClientRect()` is right for a block. For an inline run that has
|
|
52
|
+
* wrapped it is not merely imprecise — it is a different shape.
|
|
53
|
+
* An inline element is a set of line fragments; its bounding rect is their
|
|
54
|
+
* union, which covers the empty space to the right of a short last line, and
|
|
55
|
+
* — when the run starts mid-line — the whole left gutter of the first line,
|
|
56
|
+
* where a *sibling's* text is. So the outline both fails to wrap what the
|
|
57
|
+
* element is and claims pixels that belong to something else.
|
|
58
|
+
*
|
|
59
|
+
* ## Why per-fragment rather than the union
|
|
60
|
+
*
|
|
61
|
+
* A union box is one element and cheap, and for HOVER it is arguably honest.
|
|
62
|
+
* But selection is a persistent statement about what the panels on the right
|
|
63
|
+
* are editing, and a union box makes that statement about pixels the element
|
|
64
|
+
* does not own. That is the same lie in a smaller form. Per-fragment is what
|
|
65
|
+
* a browser's own selection highlight does, and it is the only shape that is
|
|
66
|
+
* true at every wrap.
|
|
67
|
+
*
|
|
68
|
+
* ## Blocks are not routed through a fragment path
|
|
69
|
+
*
|
|
70
|
+
* The overwhelming majority of canvas nodes are blocks, and their geometry is
|
|
71
|
+
* correct today. When the element yields at most one client rect this returns
|
|
72
|
+
* the union OBJECT ITSELF for `fragments[0]`, `first` and `union` — the same
|
|
73
|
+
* value the old single-rect code produced, from the same call. Blocks do not
|
|
74
|
+
* take a different code path that merely happens to agree; there is nothing
|
|
75
|
+
* for them to disagree with. `get-element-fragment-rects.spec.ts` pins that.
|
|
76
|
+
*
|
|
77
|
+
* ## The shadow boundary and the device preview
|
|
78
|
+
*
|
|
79
|
+
* `getClientRects()` is a LAYOUT query on `Element`, not a tree lookup, so it
|
|
80
|
+
* reads identically for an element inside the canvas's CLOSED shadow root —
|
|
81
|
+
* verified in the running besigner on 2026-08-23, where a wrapped
|
|
82
|
+
* `<aglyn-text>` inside the closed root returned 3 fragments while its
|
|
83
|
+
* `getBoundingClientRect()` returned their union. This is unlike
|
|
84
|
+
* `elementFromPoint`, which retargets to the host because it returns a node
|
|
85
|
+
* from the light tree.
|
|
86
|
+
*
|
|
87
|
+
* Both calls return coordinates in the same viewport space with every
|
|
88
|
+
* ancestor transform already applied, so the artboard's device preview — and
|
|
89
|
+
* any future pan/zoom transform — needs no handling here, exactly as it
|
|
90
|
+
* needed none for the single rect.
|
|
91
|
+
*/
|
|
92
|
+
export declare function getElementFragmentRects(element: Element | null | undefined): ElementFragmentRects;
|
|
93
|
+
export default getElementFragmentRects;
|