Initial commit
This commit is contained in:
13
node_modules/@radix-ui/rect/README.md
generated
vendored
Normal file
13
node_modules/@radix-ui/rect/README.md
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# `rect`
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ yarn add @radix-ui/rect
|
||||
# or
|
||||
$ npm install @radix-ui/rect
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This is an internal utility, not intended for public usage.
|
||||
16
node_modules/@radix-ui/rect/dist/index.d.mts
generated
vendored
Normal file
16
node_modules/@radix-ui/rect/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
type Measurable = {
|
||||
getBoundingClientRect(): ClientRect;
|
||||
};
|
||||
/**
|
||||
* Observes an element's rectangle on screen (getBoundingClientRect)
|
||||
* This is useful to track elements on the screen and attach other elements
|
||||
* that might be in different layers, etc.
|
||||
*/
|
||||
declare function observeElementRect(
|
||||
/** The element whose rect to observe */
|
||||
elementToObserve: Measurable,
|
||||
/** The callback which will be called when the rect changes */
|
||||
callback: CallbackFn): () => void;
|
||||
type CallbackFn = (rect: ClientRect) => void;
|
||||
|
||||
export { type Measurable, observeElementRect };
|
||||
16
node_modules/@radix-ui/rect/dist/index.d.ts
generated
vendored
Normal file
16
node_modules/@radix-ui/rect/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
type Measurable = {
|
||||
getBoundingClientRect(): ClientRect;
|
||||
};
|
||||
/**
|
||||
* Observes an element's rectangle on screen (getBoundingClientRect)
|
||||
* This is useful to track elements on the screen and attach other elements
|
||||
* that might be in different layers, etc.
|
||||
*/
|
||||
declare function observeElementRect(
|
||||
/** The element whose rect to observe */
|
||||
elementToObserve: Measurable,
|
||||
/** The callback which will be called when the rect changes */
|
||||
callback: CallbackFn): () => void;
|
||||
type CallbackFn = (rect: ClientRect) => void;
|
||||
|
||||
export { type Measurable, observeElementRect };
|
||||
73
node_modules/@radix-ui/rect/dist/index.js
generated
vendored
Normal file
73
node_modules/@radix-ui/rect/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// packages/core/rect/src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
observeElementRect: () => observeElementRect
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// packages/core/rect/src/observeElementRect.ts
|
||||
function observeElementRect(elementToObserve, callback) {
|
||||
const observedData = observedElements.get(elementToObserve);
|
||||
if (observedData === void 0) {
|
||||
observedElements.set(elementToObserve, { rect: {}, callbacks: [callback] });
|
||||
if (observedElements.size === 1) {
|
||||
rafId = requestAnimationFrame(runLoop);
|
||||
}
|
||||
} else {
|
||||
observedData.callbacks.push(callback);
|
||||
callback(elementToObserve.getBoundingClientRect());
|
||||
}
|
||||
return () => {
|
||||
const observedData2 = observedElements.get(elementToObserve);
|
||||
if (observedData2 === void 0) return;
|
||||
const index = observedData2.callbacks.indexOf(callback);
|
||||
if (index > -1) {
|
||||
observedData2.callbacks.splice(index, 1);
|
||||
}
|
||||
if (observedData2.callbacks.length === 0) {
|
||||
observedElements.delete(elementToObserve);
|
||||
if (observedElements.size === 0) {
|
||||
cancelAnimationFrame(rafId);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
var rafId;
|
||||
var observedElements = /* @__PURE__ */ new Map();
|
||||
function runLoop() {
|
||||
const changedRectsData = [];
|
||||
observedElements.forEach((data, element) => {
|
||||
const newRect = element.getBoundingClientRect();
|
||||
if (!rectEquals(data.rect, newRect)) {
|
||||
data.rect = newRect;
|
||||
changedRectsData.push(data);
|
||||
}
|
||||
});
|
||||
changedRectsData.forEach((data) => {
|
||||
data.callbacks.forEach((callback) => callback(data.rect));
|
||||
});
|
||||
rafId = requestAnimationFrame(runLoop);
|
||||
}
|
||||
function rectEquals(rect1, rect2) {
|
||||
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
7
node_modules/@radix-ui/rect/dist/index.js.map
generated
vendored
Normal file
7
node_modules/@radix-ui/rect/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/index.ts", "../src/observeElementRect.ts"],
|
||||
"sourcesContent": ["export { observeElementRect } from './observeElementRect';\nexport type { Measurable } from './observeElementRect';\n", "type Measurable = { getBoundingClientRect(): ClientRect };\n\n/**\n * Observes an element's rectangle on screen (getBoundingClientRect)\n * This is useful to track elements on the screen and attach other elements\n * that might be in different layers, etc.\n */\nfunction observeElementRect(\n /** The element whose rect to observe */\n elementToObserve: Measurable,\n /** The callback which will be called when the rect changes */\n callback: CallbackFn\n) {\n const observedData = observedElements.get(elementToObserve);\n\n if (observedData === undefined) {\n // add the element to the map of observed elements with its first callback\n // because this is the first time this element is observed\n observedElements.set(elementToObserve, { rect: {} as ClientRect, callbacks: [callback] });\n\n if (observedElements.size === 1) {\n // start the internal loop once at least 1 element is observed\n rafId = requestAnimationFrame(runLoop);\n }\n } else {\n // only add a callback for this element as it's already observed\n observedData.callbacks.push(callback);\n callback(elementToObserve.getBoundingClientRect());\n }\n\n return () => {\n const observedData = observedElements.get(elementToObserve);\n if (observedData === undefined) return;\n\n // start by removing the callback\n const index = observedData.callbacks.indexOf(callback);\n if (index > -1) {\n observedData.callbacks.splice(index, 1);\n }\n\n if (observedData.callbacks.length === 0) {\n // stop observing this element because there are no\n // callbacks registered for it anymore\n observedElements.delete(elementToObserve);\n\n if (observedElements.size === 0) {\n // stop the internal loop once no elements are observed anymore\n cancelAnimationFrame(rafId);\n }\n }\n };\n}\n\n// ========================================================================\n// module internals\n\ntype CallbackFn = (rect: ClientRect) => void;\n\ntype ObservedData = {\n rect: ClientRect;\n callbacks: Array<CallbackFn>;\n};\n\nlet rafId: number;\nconst observedElements: Map<Measurable, ObservedData> = new Map();\n\nfunction runLoop() {\n const changedRectsData: Array<ObservedData> = [];\n\n // process all DOM reads first (getBoundingClientRect)\n observedElements.forEach((data, element) => {\n const newRect = element.getBoundingClientRect();\n\n // gather all the data for elements whose rects have changed\n if (!rectEquals(data.rect, newRect)) {\n data.rect = newRect;\n changedRectsData.push(data);\n }\n });\n\n // group DOM writes here after the DOM reads (getBoundingClientRect)\n // as DOM writes will most likely happen with the callbacks\n changedRectsData.forEach((data) => {\n data.callbacks.forEach((callback) => callback(data.rect));\n });\n\n rafId = requestAnimationFrame(runLoop);\n}\n// ========================================================================\n\n/**\n * Returns whether 2 rects are equal in values\n */\nfunction rectEquals(rect1: ClientRect, rect2: ClientRect) {\n return (\n rect1.width === rect2.width &&\n rect1.height === rect2.height &&\n rect1.top === rect2.top &&\n rect1.right === rect2.right &&\n rect1.bottom === rect2.bottom &&\n rect1.left === rect2.left\n );\n}\n\nexport { observeElementRect };\nexport type { Measurable };\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,SAAS,mBAEP,kBAEA,UACA;AACA,QAAM,eAAe,iBAAiB,IAAI,g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,MAAM,SACtB,MAAM,WAAW,MAAM,UACvB,MAAM,SAAS,MAAM;AAEzB;",
|
||||
"names": ["observedData"]
|
||||
}
|
||||
50
node_modules/@radix-ui/rect/dist/index.mjs
generated
vendored
Normal file
50
node_modules/@radix-ui/rect/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// packages/core/rect/src/observeElementRect.ts
|
||||
function observeElementRect(elementToObserve, callback) {
|
||||
const observedData = observedElements.get(elementToObserve);
|
||||
if (observedData === void 0) {
|
||||
observedElements.set(elementToObserve, { rect: {}, callbacks: [callback] });
|
||||
if (observedElements.size === 1) {
|
||||
rafId = requestAnimationFrame(runLoop);
|
||||
}
|
||||
} else {
|
||||
observedData.callbacks.push(callback);
|
||||
callback(elementToObserve.getBoundingClientRect());
|
||||
}
|
||||
return () => {
|
||||
const observedData2 = observedElements.get(elementToObserve);
|
||||
if (observedData2 === void 0) return;
|
||||
const index = observedData2.callbacks.indexOf(callback);
|
||||
if (index > -1) {
|
||||
observedData2.callbacks.splice(index, 1);
|
||||
}
|
||||
if (observedData2.callbacks.length === 0) {
|
||||
observedElements.delete(elementToObserve);
|
||||
if (observedElements.size === 0) {
|
||||
cancelAnimationFrame(rafId);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
var rafId;
|
||||
var observedElements = /* @__PURE__ */ new Map();
|
||||
function runLoop() {
|
||||
const changedRectsData = [];
|
||||
observedElements.forEach((data, element) => {
|
||||
const newRect = element.getBoundingClientRect();
|
||||
if (!rectEquals(data.rect, newRect)) {
|
||||
data.rect = newRect;
|
||||
changedRectsData.push(data);
|
||||
}
|
||||
});
|
||||
changedRectsData.forEach((data) => {
|
||||
data.callbacks.forEach((callback) => callback(data.rect));
|
||||
});
|
||||
rafId = requestAnimationFrame(runLoop);
|
||||
}
|
||||
function rectEquals(rect1, rect2) {
|
||||
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
|
||||
}
|
||||
export {
|
||||
observeElementRect
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
7
node_modules/@radix-ui/rect/dist/index.mjs.map
generated
vendored
Normal file
7
node_modules/@radix-ui/rect/dist/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/observeElementRect.ts"],
|
||||
"sourcesContent": ["type Measurable = { getBoundingClientRect(): ClientRect };\n\n/**\n * Observes an element's rectangle on screen (getBoundingClientRect)\n * This is useful to track elements on the screen and attach other elements\n * that might be in different layers, etc.\n */\nfunction observeElementRect(\n /** The element whose rect to observe */\n elementToObserve: Measurable,\n /** The callback which will be called when the rect changes */\n callback: CallbackFn\n) {\n const observedData = observedElements.get(elementToObserve);\n\n if (observedData === undefined) {\n // add the element to the map of observed elements with its first callback\n // because this is the first time this element is observed\n observedElements.set(elementToObserve, { rect: {} as ClientRect, callbacks: [callback] });\n\n if (observedElements.size === 1) {\n // start the internal loop once at least 1 element is observed\n rafId = requestAnimationFrame(runLoop);\n }\n } else {\n // only add a callback for this element as it's already observed\n observedData.callbacks.push(callback);\n callback(elementToObserve.getBoundingClientRect());\n }\n\n return () => {\n const observedData = observedElements.get(elementToObserve);\n if (observedData === undefined) return;\n\n // start by removing the callback\n const index = observedData.callbacks.indexOf(callback);\n if (index > -1) {\n observedData.callbacks.splice(index, 1);\n }\n\n if (observedData.callbacks.length === 0) {\n // stop observing this element because there are no\n // callbacks registered for it anymore\n observedElements.delete(elementToObserve);\n\n if (observedElements.size === 0) {\n // stop the internal loop once no elements are observed anymore\n cancelAnimationFrame(rafId);\n }\n }\n };\n}\n\n// ========================================================================\n// module internals\n\ntype CallbackFn = (rect: ClientRect) => void;\n\ntype ObservedData = {\n rect: ClientRect;\n callbacks: Array<CallbackFn>;\n};\n\nlet rafId: number;\nconst observedElements: Map<Measurable, ObservedData> = new Map();\n\nfunction runLoop() {\n const changedRectsData: Array<ObservedData> = [];\n\n // process all DOM reads first (getBoundingClientRect)\n observedElements.forEach((data, element) => {\n const newRect = element.getBoundingClientRect();\n\n // gather all the data for elements whose rects have changed\n if (!rectEquals(data.rect, newRect)) {\n data.rect = newRect;\n changedRectsData.push(data);\n }\n });\n\n // group DOM writes here after the DOM reads (getBoundingClientRect)\n // as DOM writes will most likely happen with the callbacks\n changedRectsData.forEach((data) => {\n data.callbacks.forEach((callback) => callback(data.rect));\n });\n\n rafId = requestAnimationFrame(runLoop);\n}\n// ========================================================================\n\n/**\n * Returns whether 2 rects are equal in values\n */\nfunction rectEquals(rect1: ClientRect, rect2: ClientRect) {\n return (\n rect1.width === rect2.width &&\n rect1.height === rect2.height &&\n rect1.top === rect2.top &&\n rect1.right === rect2.right &&\n rect1.bottom === rect2.bottom &&\n rect1.left === rect2.left\n );\n}\n\nexport { observeElementRect };\nexport type { Measurable };\n"],
|
||||
"mappings": ";AAOA,SAAS,mBAEP,kBAEA,UACA;AACA,QAAM,eAAe,iBAAiB,IAAI,gBAAgB;AAE1D,MAAI,iBAAiB,QAAW;AAG9B,qBAAiB,IAAI,kBAAkB,EAAE,MAAM,CAAC,GAAiB,WAAW,CAAC,QAAQ,EAAE,CAAC;AAExF,QAAI,iBAAiB,SAAS,GAAG;AAE/B,cAAQ,sBAAsB,OAAO;AAAA,IACvC;AAAA,EACF,OAAO;AAEL,iBAAa,UAAU,KAAK,QAAQ;AACpC,aAAS,iBAAiB,sBAAsB,CAAC;AAAA,EACnD;AAEA,SAAO,MAAM;AACX,UAAMA,gBAAe,iBAAiB,IAAI,gBAAgB;AAC1D,QAAIA,kBAAiB,OAAW;AAGhC,UAAM,QAAQA,cAAa,UAAU,QAAQ,QAAQ;AACrD,QAAI,QAAQ,IAAI;AACd,MAAAA,cAAa,UAAU,OAAO,OAAO,CAAC;AAAA,IACxC;AAEA,QAAIA,cAAa,UAAU,WAAW,GAAG;AAGvC,uBAAiB,OAAO,gBAAgB;AAExC,UAAI,iBAAiB,SAAS,GAAG;AAE/B,6BAAqB,KAAK;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AACF;AAYA,IAAI;AACJ,IAAM,mBAAkD,oBAAI,IAAI;AAEhE,SAAS,UAAU;AACjB,QAAM,mBAAwC,CAAC;AAG/C,mBAAiB,QAAQ,CAAC,MAAM,YAAY;AAC1C,UAAM,UAAU,QAAQ,sBAAsB;AAG9C,QAAI,CAAC,WAAW,KAAK,MAAM,OAAO,GAAG;AACnC,WAAK,OAAO;AACZ,uBAAiB,KAAK,IAAI;AAAA,IAC5B;AAAA,EACF,CAAC;AAID,mBAAiB,QAAQ,CAAC,SAAS;AACjC,SAAK,UAAU,QAAQ,CAAC,aAAa,SAAS,KAAK,IAAI,CAAC;AAAA,EAC1D,CAAC;AAED,UAAQ,sBAAsB,OAAO;AACvC;AAMA,SAAS,WAAW,OAAmB,OAAmB;AACxD,SACE,MAAM,UAAU,MAAM,SACtB,MAAM,WAAW,MAAM,UACvB,MAAM,QAAQ,MAAM,OACpB,MAAM,UAAU,MAAM,SACtB,MAAM,WAAW,MAAM,UACvB,MAAM,SAAS,MAAM;AAEzB;",
|
||||
"names": ["observedData"]
|
||||
}
|
||||
66
node_modules/@radix-ui/rect/package.json
generated
vendored
Normal file
66
node_modules/@radix-ui/rect/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "@radix-ui/rect@1.1.0",
|
||||
"_id": "@radix-ui/rect@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==",
|
||||
"_location": "/@radix-ui/rect",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@radix-ui/rect@1.1.0",
|
||||
"name": "@radix-ui/rect",
|
||||
"escapedName": "@radix-ui%2frect",
|
||||
"scope": "@radix-ui",
|
||||
"rawSpec": "1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@radix-ui/react-popper",
|
||||
"/@radix-ui/react-use-rect"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/@radix-ui/rect/-/rect-1.1.0.tgz",
|
||||
"_shasum": "f817d1d3265ac5415dadc67edab30ae196696438",
|
||||
"_spec": "@radix-ui/rect@1.1.0",
|
||||
"_where": "/Users/hongbin9/www/botgroup.chat/node_modules/@radix-ui/react-popper",
|
||||
"bugs": {
|
||||
"url": "https://github.com/radix-ui/primitives/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "## Installation",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"homepage": "https://radix-ui.com/primitives",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"name": "@radix-ui/rect",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/radix-ui/primitives.git"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf dist",
|
||||
"version": "yarn version"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"version": "1.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user