react-resizable-panels 2.0.22 → 2.1.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/CHANGELOG.md +9 -0
- package/README.md +16 -0
- package/dist/declarations/src/index.d.ts +3 -1
- package/dist/declarations/src/utils/csp.d.ts +2 -0
- package/dist/declarations/src/utils/cursor.d.ts +7 -0
- package/dist/react-resizable-panels.browser.cjs.js +27 -2
- package/dist/react-resizable-panels.browser.cjs.mjs +4 -1
- package/dist/react-resizable-panels.browser.development.cjs.js +27 -2
- package/dist/react-resizable-panels.browser.development.cjs.mjs +4 -1
- package/dist/react-resizable-panels.browser.development.esm.js +25 -3
- package/dist/react-resizable-panels.browser.esm.js +25 -3
- package/dist/react-resizable-panels.cjs.js +27 -2
- package/dist/react-resizable-panels.cjs.mjs +4 -1
- package/dist/react-resizable-panels.development.cjs.js +27 -2
- package/dist/react-resizable-panels.development.cjs.mjs +4 -1
- package/dist/react-resizable-panels.development.esm.js +25 -3
- package/dist/react-resizable-panels.development.node.cjs.js +27 -2
- package/dist/react-resizable-panels.development.node.cjs.mjs +4 -1
- package/dist/react-resizable-panels.development.node.esm.js +25 -3
- package/dist/react-resizable-panels.esm.js +25 -3
- package/dist/react-resizable-panels.node.cjs.js +27 -2
- package/dist/react-resizable-panels.node.cjs.mjs +4 -1
- package/dist/react-resizable-panels.node.esm.js +25 -3
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/utils/csp.ts +9 -0
- package/src/utils/cursor.ts +19 -0
- package/src/vendor/react.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
* Add opt-in support for setting the [`"nonce"` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) for the global cursor style (#386)
|
|
6
|
+
- Support disabling global cursor styles (#387)
|
|
7
|
+
|
|
8
|
+
## 2.0.23
|
|
9
|
+
|
|
10
|
+
- Improve obfuscation for `React.useId` references (#382)
|
|
11
|
+
|
|
3
12
|
## 2.0.22
|
|
4
13
|
|
|
5
14
|
- Force eager layout re-calculation after panel added/removed (#375)
|
package/README.md
CHANGED
|
@@ -227,3 +227,19 @@ export function ClientComponent({
|
|
|
227
227
|
> Be sure to specify a `defaultSize` prop for **every** `Panel` component to avoid layout flicker.
|
|
228
228
|
|
|
229
229
|
A demo of this is available [here](https://github.com/bvaughn/react-resizable-panels-demo-ssr).
|
|
230
|
+
|
|
231
|
+
#### How can I set the [CSP `"nonce"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce) attribute?
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
import { setNonce } from "react-resizable-panels";
|
|
235
|
+
|
|
236
|
+
setNonce("your-nonce-value-here");
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### How can I disable global cursor styles?
|
|
240
|
+
|
|
241
|
+
```js
|
|
242
|
+
import { disableGlobalCursorStyles } from "react-resizable-panels";
|
|
243
|
+
|
|
244
|
+
disableGlobalCursorStyles();
|
|
245
|
+
```
|
|
@@ -2,6 +2,8 @@ import { Panel } from "./Panel.js";
|
|
|
2
2
|
import { PanelGroup } from "./PanelGroup.js";
|
|
3
3
|
import { PanelResizeHandle } from "./PanelResizeHandle.js";
|
|
4
4
|
import { assert } from "./utils/assert.js";
|
|
5
|
+
import { setNonce } from "./utils/csp.js";
|
|
6
|
+
import { enableGlobalCursorStyles, disableGlobalCursorStyles } from "./utils/cursor.js";
|
|
5
7
|
import { getPanelElement } from "./utils/dom/getPanelElement.js";
|
|
6
8
|
import { getPanelElementsForGroup } from "./utils/dom/getPanelElementsForGroup.js";
|
|
7
9
|
import { getPanelGroupElement } from "./utils/dom/getPanelGroupElement.js";
|
|
@@ -15,4 +17,4 @@ import type { ImperativePanelHandle, PanelOnCollapse, PanelOnExpand, PanelOnResi
|
|
|
15
17
|
import type { ImperativePanelGroupHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage } from "./PanelGroup.js";
|
|
16
18
|
import type { PanelResizeHandleOnDragging, PanelResizeHandleProps } from "./PanelResizeHandle.js";
|
|
17
19
|
import type { PointerHitAreaMargins } from "./PanelResizeHandleRegistry.js";
|
|
18
|
-
export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, PointerHitAreaMargins, Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, intersects, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, };
|
|
20
|
+
export { ImperativePanelGroupHandle, ImperativePanelHandle, PanelGroupOnLayout, PanelGroupProps, PanelGroupStorage, PanelOnCollapse, PanelOnExpand, PanelOnResize, PanelProps, PanelResizeHandleOnDragging, PanelResizeHandleProps, PointerHitAreaMargins, Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, intersects, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, enableGlobalCursorStyles, disableGlobalCursorStyles, setNonce, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type CursorState = "horizontal" | "intersection" | "vertical";
|
|
2
|
+
export declare function disableGlobalCursorStyles(): void;
|
|
3
|
+
export declare function enableGlobalCursorStyles(): void;
|
|
4
|
+
export declare function getCursorStyle(state: CursorState, constraintFlags: number): string;
|
|
5
|
+
export declare function resetGlobalCursorStyle(): void;
|
|
6
|
+
export declare function setGlobalCursorStyle(state: CursorState, constraintFlags: number): void;
|
|
7
|
+
export {};
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
49
|
|
|
50
50
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -201,8 +201,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
201
201
|
PanelWithForwardedRef.displayName = "Panel";
|
|
202
202
|
Panel.displayName = "forwardRef(Panel)";
|
|
203
203
|
|
|
204
|
+
let nonce;
|
|
205
|
+
function getNonce() {
|
|
206
|
+
return nonce;
|
|
207
|
+
}
|
|
208
|
+
function setNonce(value) {
|
|
209
|
+
nonce = value;
|
|
210
|
+
}
|
|
211
|
+
|
|
204
212
|
let currentCursorStyle = null;
|
|
213
|
+
let enabled = true;
|
|
205
214
|
let styleElement = null;
|
|
215
|
+
function disableGlobalCursorStyles() {
|
|
216
|
+
enabled = false;
|
|
217
|
+
}
|
|
218
|
+
function enableGlobalCursorStyles() {
|
|
219
|
+
enabled = true;
|
|
220
|
+
}
|
|
206
221
|
function getCursorStyle(state, constraintFlags) {
|
|
207
222
|
if (constraintFlags) {
|
|
208
223
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -248,6 +263,9 @@ function resetGlobalCursorStyle() {
|
|
|
248
263
|
}
|
|
249
264
|
}
|
|
250
265
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
266
|
+
if (!enabled) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
251
269
|
const style = getCursorStyle(state, constraintFlags);
|
|
252
270
|
if (currentCursorStyle === style) {
|
|
253
271
|
return;
|
|
@@ -255,6 +273,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
255
273
|
currentCursorStyle = style;
|
|
256
274
|
if (styleElement === null) {
|
|
257
275
|
styleElement = document.createElement("style");
|
|
276
|
+
const nonce = getNonce();
|
|
277
|
+
if (nonce) {
|
|
278
|
+
styleElement.setAttribute("nonce", nonce);
|
|
279
|
+
}
|
|
258
280
|
document.head.appendChild(styleElement);
|
|
259
281
|
}
|
|
260
282
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2407,6 +2429,8 @@ exports.Panel = Panel;
|
|
|
2407
2429
|
exports.PanelGroup = PanelGroup;
|
|
2408
2430
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2409
2431
|
exports.assert = assert;
|
|
2432
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2433
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2410
2434
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2411
2435
|
exports.getPanelElement = getPanelElement;
|
|
2412
2436
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2416,3 +2440,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2416
2440
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2417
2441
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2418
2442
|
exports.intersects = intersects;
|
|
2443
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.browser.cjs.js";
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
49
49
|
|
|
50
50
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -207,8 +207,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
207
207
|
PanelWithForwardedRef.displayName = "Panel";
|
|
208
208
|
Panel.displayName = "forwardRef(Panel)";
|
|
209
209
|
|
|
210
|
+
let nonce;
|
|
211
|
+
function getNonce() {
|
|
212
|
+
return nonce;
|
|
213
|
+
}
|
|
214
|
+
function setNonce(value) {
|
|
215
|
+
nonce = value;
|
|
216
|
+
}
|
|
217
|
+
|
|
210
218
|
let currentCursorStyle = null;
|
|
219
|
+
let enabled = true;
|
|
211
220
|
let styleElement = null;
|
|
221
|
+
function disableGlobalCursorStyles() {
|
|
222
|
+
enabled = false;
|
|
223
|
+
}
|
|
224
|
+
function enableGlobalCursorStyles() {
|
|
225
|
+
enabled = true;
|
|
226
|
+
}
|
|
212
227
|
function getCursorStyle(state, constraintFlags) {
|
|
213
228
|
if (constraintFlags) {
|
|
214
229
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -254,6 +269,9 @@ function resetGlobalCursorStyle() {
|
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
271
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
272
|
+
if (!enabled) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
257
275
|
const style = getCursorStyle(state, constraintFlags);
|
|
258
276
|
if (currentCursorStyle === style) {
|
|
259
277
|
return;
|
|
@@ -261,6 +279,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
261
279
|
currentCursorStyle = style;
|
|
262
280
|
if (styleElement === null) {
|
|
263
281
|
styleElement = document.createElement("style");
|
|
282
|
+
const nonce = getNonce();
|
|
283
|
+
if (nonce) {
|
|
284
|
+
styleElement.setAttribute("nonce", nonce);
|
|
285
|
+
}
|
|
264
286
|
document.head.appendChild(styleElement);
|
|
265
287
|
}
|
|
266
288
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2513,6 +2535,8 @@ exports.Panel = Panel;
|
|
|
2513
2535
|
exports.PanelGroup = PanelGroup;
|
|
2514
2536
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2515
2537
|
exports.assert = assert;
|
|
2538
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2539
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2516
2540
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2517
2541
|
exports.getPanelElement = getPanelElement;
|
|
2518
2542
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2522,3 +2546,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2522
2546
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2523
2547
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2524
2548
|
exports.intersects = intersects;
|
|
2549
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.browser.development.cjs.js";
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
25
25
|
|
|
26
26
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -183,8 +183,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
183
183
|
PanelWithForwardedRef.displayName = "Panel";
|
|
184
184
|
Panel.displayName = "forwardRef(Panel)";
|
|
185
185
|
|
|
186
|
+
let nonce;
|
|
187
|
+
function getNonce() {
|
|
188
|
+
return nonce;
|
|
189
|
+
}
|
|
190
|
+
function setNonce(value) {
|
|
191
|
+
nonce = value;
|
|
192
|
+
}
|
|
193
|
+
|
|
186
194
|
let currentCursorStyle = null;
|
|
195
|
+
let enabled = true;
|
|
187
196
|
let styleElement = null;
|
|
197
|
+
function disableGlobalCursorStyles() {
|
|
198
|
+
enabled = false;
|
|
199
|
+
}
|
|
200
|
+
function enableGlobalCursorStyles() {
|
|
201
|
+
enabled = true;
|
|
202
|
+
}
|
|
188
203
|
function getCursorStyle(state, constraintFlags) {
|
|
189
204
|
if (constraintFlags) {
|
|
190
205
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -230,6 +245,9 @@ function resetGlobalCursorStyle() {
|
|
|
230
245
|
}
|
|
231
246
|
}
|
|
232
247
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
248
|
+
if (!enabled) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
233
251
|
const style = getCursorStyle(state, constraintFlags);
|
|
234
252
|
if (currentCursorStyle === style) {
|
|
235
253
|
return;
|
|
@@ -237,6 +255,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
237
255
|
currentCursorStyle = style;
|
|
238
256
|
if (styleElement === null) {
|
|
239
257
|
styleElement = document.createElement("style");
|
|
258
|
+
const nonce = getNonce();
|
|
259
|
+
if (nonce) {
|
|
260
|
+
styleElement.setAttribute("nonce", nonce);
|
|
261
|
+
}
|
|
240
262
|
document.head.appendChild(styleElement);
|
|
241
263
|
}
|
|
242
264
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2485,4 +2507,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2485
2507
|
};
|
|
2486
2508
|
}
|
|
2487
2509
|
|
|
2488
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2510
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
25
25
|
|
|
26
26
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -177,8 +177,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
177
177
|
PanelWithForwardedRef.displayName = "Panel";
|
|
178
178
|
Panel.displayName = "forwardRef(Panel)";
|
|
179
179
|
|
|
180
|
+
let nonce;
|
|
181
|
+
function getNonce() {
|
|
182
|
+
return nonce;
|
|
183
|
+
}
|
|
184
|
+
function setNonce(value) {
|
|
185
|
+
nonce = value;
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
let currentCursorStyle = null;
|
|
189
|
+
let enabled = true;
|
|
181
190
|
let styleElement = null;
|
|
191
|
+
function disableGlobalCursorStyles() {
|
|
192
|
+
enabled = false;
|
|
193
|
+
}
|
|
194
|
+
function enableGlobalCursorStyles() {
|
|
195
|
+
enabled = true;
|
|
196
|
+
}
|
|
182
197
|
function getCursorStyle(state, constraintFlags) {
|
|
183
198
|
if (constraintFlags) {
|
|
184
199
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -224,6 +239,9 @@ function resetGlobalCursorStyle() {
|
|
|
224
239
|
}
|
|
225
240
|
}
|
|
226
241
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
242
|
+
if (!enabled) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
227
245
|
const style = getCursorStyle(state, constraintFlags);
|
|
228
246
|
if (currentCursorStyle === style) {
|
|
229
247
|
return;
|
|
@@ -231,6 +249,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
231
249
|
currentCursorStyle = style;
|
|
232
250
|
if (styleElement === null) {
|
|
233
251
|
styleElement = document.createElement("style");
|
|
252
|
+
const nonce = getNonce();
|
|
253
|
+
if (nonce) {
|
|
254
|
+
styleElement.setAttribute("nonce", nonce);
|
|
255
|
+
}
|
|
234
256
|
document.head.appendChild(styleElement);
|
|
235
257
|
}
|
|
236
258
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2379,4 +2401,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2379
2401
|
};
|
|
2380
2402
|
}
|
|
2381
2403
|
|
|
2382
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2404
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
|
@@ -45,8 +45,8 @@ const {
|
|
|
45
45
|
useState
|
|
46
46
|
} = React__namespace;
|
|
47
47
|
|
|
48
|
-
// `
|
|
49
|
-
const useId = React__namespace[
|
|
48
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
49
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
50
50
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
51
51
|
|
|
52
52
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -203,8 +203,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
203
203
|
PanelWithForwardedRef.displayName = "Panel";
|
|
204
204
|
Panel.displayName = "forwardRef(Panel)";
|
|
205
205
|
|
|
206
|
+
let nonce;
|
|
207
|
+
function getNonce() {
|
|
208
|
+
return nonce;
|
|
209
|
+
}
|
|
210
|
+
function setNonce(value) {
|
|
211
|
+
nonce = value;
|
|
212
|
+
}
|
|
213
|
+
|
|
206
214
|
let currentCursorStyle = null;
|
|
215
|
+
let enabled = true;
|
|
207
216
|
let styleElement = null;
|
|
217
|
+
function disableGlobalCursorStyles() {
|
|
218
|
+
enabled = false;
|
|
219
|
+
}
|
|
220
|
+
function enableGlobalCursorStyles() {
|
|
221
|
+
enabled = true;
|
|
222
|
+
}
|
|
208
223
|
function getCursorStyle(state, constraintFlags) {
|
|
209
224
|
if (constraintFlags) {
|
|
210
225
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -250,6 +265,9 @@ function resetGlobalCursorStyle() {
|
|
|
250
265
|
}
|
|
251
266
|
}
|
|
252
267
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
268
|
+
if (!enabled) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
253
271
|
const style = getCursorStyle(state, constraintFlags);
|
|
254
272
|
if (currentCursorStyle === style) {
|
|
255
273
|
return;
|
|
@@ -257,6 +275,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
257
275
|
currentCursorStyle = style;
|
|
258
276
|
if (styleElement === null) {
|
|
259
277
|
styleElement = document.createElement("style");
|
|
278
|
+
const nonce = getNonce();
|
|
279
|
+
if (nonce) {
|
|
280
|
+
styleElement.setAttribute("nonce", nonce);
|
|
281
|
+
}
|
|
260
282
|
document.head.appendChild(styleElement);
|
|
261
283
|
}
|
|
262
284
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2409,6 +2431,8 @@ exports.Panel = Panel;
|
|
|
2409
2431
|
exports.PanelGroup = PanelGroup;
|
|
2410
2432
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2411
2433
|
exports.assert = assert;
|
|
2434
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2435
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2412
2436
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2413
2437
|
exports.getPanelElement = getPanelElement;
|
|
2414
2438
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2418,3 +2442,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2418
2442
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2419
2443
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2420
2444
|
exports.intersects = intersects;
|
|
2445
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.cjs.js";
|
|
@@ -45,8 +45,8 @@ const {
|
|
|
45
45
|
useState
|
|
46
46
|
} = React__namespace;
|
|
47
47
|
|
|
48
|
-
// `
|
|
49
|
-
const useId = React__namespace[
|
|
48
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
49
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
50
50
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
51
51
|
|
|
52
52
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -214,8 +214,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
214
214
|
PanelWithForwardedRef.displayName = "Panel";
|
|
215
215
|
Panel.displayName = "forwardRef(Panel)";
|
|
216
216
|
|
|
217
|
+
let nonce;
|
|
218
|
+
function getNonce() {
|
|
219
|
+
return nonce;
|
|
220
|
+
}
|
|
221
|
+
function setNonce(value) {
|
|
222
|
+
nonce = value;
|
|
223
|
+
}
|
|
224
|
+
|
|
217
225
|
let currentCursorStyle = null;
|
|
226
|
+
let enabled = true;
|
|
218
227
|
let styleElement = null;
|
|
228
|
+
function disableGlobalCursorStyles() {
|
|
229
|
+
enabled = false;
|
|
230
|
+
}
|
|
231
|
+
function enableGlobalCursorStyles() {
|
|
232
|
+
enabled = true;
|
|
233
|
+
}
|
|
219
234
|
function getCursorStyle(state, constraintFlags) {
|
|
220
235
|
if (constraintFlags) {
|
|
221
236
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -261,6 +276,9 @@ function resetGlobalCursorStyle() {
|
|
|
261
276
|
}
|
|
262
277
|
}
|
|
263
278
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
279
|
+
if (!enabled) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
264
282
|
const style = getCursorStyle(state, constraintFlags);
|
|
265
283
|
if (currentCursorStyle === style) {
|
|
266
284
|
return;
|
|
@@ -268,6 +286,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
268
286
|
currentCursorStyle = style;
|
|
269
287
|
if (styleElement === null) {
|
|
270
288
|
styleElement = document.createElement("style");
|
|
289
|
+
const nonce = getNonce();
|
|
290
|
+
if (nonce) {
|
|
291
|
+
styleElement.setAttribute("nonce", nonce);
|
|
292
|
+
}
|
|
271
293
|
document.head.appendChild(styleElement);
|
|
272
294
|
}
|
|
273
295
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2520,6 +2542,8 @@ exports.Panel = Panel;
|
|
|
2520
2542
|
exports.PanelGroup = PanelGroup;
|
|
2521
2543
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2522
2544
|
exports.assert = assert;
|
|
2545
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2546
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2523
2547
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2524
2548
|
exports.getPanelElement = getPanelElement;
|
|
2525
2549
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2529,3 +2553,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2529
2553
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2530
2554
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2531
2555
|
exports.intersects = intersects;
|
|
2556
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.development.cjs.js";
|
|
@@ -21,8 +21,8 @@ const {
|
|
|
21
21
|
useState
|
|
22
22
|
} = React;
|
|
23
23
|
|
|
24
|
-
// `
|
|
25
|
-
const useId = React[
|
|
24
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
25
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
26
26
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
27
27
|
|
|
28
28
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -190,8 +190,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
190
190
|
PanelWithForwardedRef.displayName = "Panel";
|
|
191
191
|
Panel.displayName = "forwardRef(Panel)";
|
|
192
192
|
|
|
193
|
+
let nonce;
|
|
194
|
+
function getNonce() {
|
|
195
|
+
return nonce;
|
|
196
|
+
}
|
|
197
|
+
function setNonce(value) {
|
|
198
|
+
nonce = value;
|
|
199
|
+
}
|
|
200
|
+
|
|
193
201
|
let currentCursorStyle = null;
|
|
202
|
+
let enabled = true;
|
|
194
203
|
let styleElement = null;
|
|
204
|
+
function disableGlobalCursorStyles() {
|
|
205
|
+
enabled = false;
|
|
206
|
+
}
|
|
207
|
+
function enableGlobalCursorStyles() {
|
|
208
|
+
enabled = true;
|
|
209
|
+
}
|
|
195
210
|
function getCursorStyle(state, constraintFlags) {
|
|
196
211
|
if (constraintFlags) {
|
|
197
212
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -237,6 +252,9 @@ function resetGlobalCursorStyle() {
|
|
|
237
252
|
}
|
|
238
253
|
}
|
|
239
254
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
255
|
+
if (!enabled) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
240
258
|
const style = getCursorStyle(state, constraintFlags);
|
|
241
259
|
if (currentCursorStyle === style) {
|
|
242
260
|
return;
|
|
@@ -244,6 +262,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
244
262
|
currentCursorStyle = style;
|
|
245
263
|
if (styleElement === null) {
|
|
246
264
|
styleElement = document.createElement("style");
|
|
265
|
+
const nonce = getNonce();
|
|
266
|
+
if (nonce) {
|
|
267
|
+
styleElement.setAttribute("nonce", nonce);
|
|
268
|
+
}
|
|
247
269
|
document.head.appendChild(styleElement);
|
|
248
270
|
}
|
|
249
271
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2492,4 +2514,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2492
2514
|
};
|
|
2493
2515
|
}
|
|
2494
2516
|
|
|
2495
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2517
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
|
|
49
49
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
50
50
|
|
|
@@ -176,8 +176,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
176
176
|
PanelWithForwardedRef.displayName = "Panel";
|
|
177
177
|
Panel.displayName = "forwardRef(Panel)";
|
|
178
178
|
|
|
179
|
+
let nonce;
|
|
180
|
+
function getNonce() {
|
|
181
|
+
return nonce;
|
|
182
|
+
}
|
|
183
|
+
function setNonce(value) {
|
|
184
|
+
nonce = value;
|
|
185
|
+
}
|
|
186
|
+
|
|
179
187
|
let currentCursorStyle = null;
|
|
188
|
+
let enabled = true;
|
|
180
189
|
let styleElement = null;
|
|
190
|
+
function disableGlobalCursorStyles() {
|
|
191
|
+
enabled = false;
|
|
192
|
+
}
|
|
193
|
+
function enableGlobalCursorStyles() {
|
|
194
|
+
enabled = true;
|
|
195
|
+
}
|
|
181
196
|
function getCursorStyle(state, constraintFlags) {
|
|
182
197
|
if (constraintFlags) {
|
|
183
198
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -223,6 +238,9 @@ function resetGlobalCursorStyle() {
|
|
|
223
238
|
}
|
|
224
239
|
}
|
|
225
240
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
241
|
+
if (!enabled) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
226
244
|
const style = getCursorStyle(state, constraintFlags);
|
|
227
245
|
if (currentCursorStyle === style) {
|
|
228
246
|
return;
|
|
@@ -230,6 +248,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
230
248
|
currentCursorStyle = style;
|
|
231
249
|
if (styleElement === null) {
|
|
232
250
|
styleElement = document.createElement("style");
|
|
251
|
+
const nonce = getNonce();
|
|
252
|
+
if (nonce) {
|
|
253
|
+
styleElement.setAttribute("nonce", nonce);
|
|
254
|
+
}
|
|
233
255
|
document.head.appendChild(styleElement);
|
|
234
256
|
}
|
|
235
257
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2285,6 +2307,8 @@ exports.Panel = Panel;
|
|
|
2285
2307
|
exports.PanelGroup = PanelGroup;
|
|
2286
2308
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2287
2309
|
exports.assert = assert;
|
|
2310
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2311
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2288
2312
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2289
2313
|
exports.getPanelElement = getPanelElement;
|
|
2290
2314
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2294,3 +2318,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2294
2318
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2295
2319
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2296
2320
|
exports.intersects = intersects;
|
|
2321
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.development.node.cjs.js";
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
|
|
25
25
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
26
26
|
|
|
@@ -152,8 +152,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
152
152
|
PanelWithForwardedRef.displayName = "Panel";
|
|
153
153
|
Panel.displayName = "forwardRef(Panel)";
|
|
154
154
|
|
|
155
|
+
let nonce;
|
|
156
|
+
function getNonce() {
|
|
157
|
+
return nonce;
|
|
158
|
+
}
|
|
159
|
+
function setNonce(value) {
|
|
160
|
+
nonce = value;
|
|
161
|
+
}
|
|
162
|
+
|
|
155
163
|
let currentCursorStyle = null;
|
|
164
|
+
let enabled = true;
|
|
156
165
|
let styleElement = null;
|
|
166
|
+
function disableGlobalCursorStyles() {
|
|
167
|
+
enabled = false;
|
|
168
|
+
}
|
|
169
|
+
function enableGlobalCursorStyles() {
|
|
170
|
+
enabled = true;
|
|
171
|
+
}
|
|
157
172
|
function getCursorStyle(state, constraintFlags) {
|
|
158
173
|
if (constraintFlags) {
|
|
159
174
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -199,6 +214,9 @@ function resetGlobalCursorStyle() {
|
|
|
199
214
|
}
|
|
200
215
|
}
|
|
201
216
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
217
|
+
if (!enabled) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
202
220
|
const style = getCursorStyle(state, constraintFlags);
|
|
203
221
|
if (currentCursorStyle === style) {
|
|
204
222
|
return;
|
|
@@ -206,6 +224,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
206
224
|
currentCursorStyle = style;
|
|
207
225
|
if (styleElement === null) {
|
|
208
226
|
styleElement = document.createElement("style");
|
|
227
|
+
const nonce = getNonce();
|
|
228
|
+
if (nonce) {
|
|
229
|
+
styleElement.setAttribute("nonce", nonce);
|
|
230
|
+
}
|
|
209
231
|
document.head.appendChild(styleElement);
|
|
210
232
|
}
|
|
211
233
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2257,4 +2279,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2257
2279
|
};
|
|
2258
2280
|
}
|
|
2259
2281
|
|
|
2260
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2282
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
|
@@ -21,8 +21,8 @@ const {
|
|
|
21
21
|
useState
|
|
22
22
|
} = React;
|
|
23
23
|
|
|
24
|
-
// `
|
|
25
|
-
const useId = React[
|
|
24
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
25
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
26
26
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
27
27
|
|
|
28
28
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
@@ -179,8 +179,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
179
179
|
PanelWithForwardedRef.displayName = "Panel";
|
|
180
180
|
Panel.displayName = "forwardRef(Panel)";
|
|
181
181
|
|
|
182
|
+
let nonce;
|
|
183
|
+
function getNonce() {
|
|
184
|
+
return nonce;
|
|
185
|
+
}
|
|
186
|
+
function setNonce(value) {
|
|
187
|
+
nonce = value;
|
|
188
|
+
}
|
|
189
|
+
|
|
182
190
|
let currentCursorStyle = null;
|
|
191
|
+
let enabled = true;
|
|
183
192
|
let styleElement = null;
|
|
193
|
+
function disableGlobalCursorStyles() {
|
|
194
|
+
enabled = false;
|
|
195
|
+
}
|
|
196
|
+
function enableGlobalCursorStyles() {
|
|
197
|
+
enabled = true;
|
|
198
|
+
}
|
|
184
199
|
function getCursorStyle(state, constraintFlags) {
|
|
185
200
|
if (constraintFlags) {
|
|
186
201
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -226,6 +241,9 @@ function resetGlobalCursorStyle() {
|
|
|
226
241
|
}
|
|
227
242
|
}
|
|
228
243
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
244
|
+
if (!enabled) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
229
247
|
const style = getCursorStyle(state, constraintFlags);
|
|
230
248
|
if (currentCursorStyle === style) {
|
|
231
249
|
return;
|
|
@@ -233,6 +251,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
233
251
|
currentCursorStyle = style;
|
|
234
252
|
if (styleElement === null) {
|
|
235
253
|
styleElement = document.createElement("style");
|
|
254
|
+
const nonce = getNonce();
|
|
255
|
+
if (nonce) {
|
|
256
|
+
styleElement.setAttribute("nonce", nonce);
|
|
257
|
+
}
|
|
236
258
|
document.head.appendChild(styleElement);
|
|
237
259
|
}
|
|
238
260
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2381,4 +2403,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2381
2403
|
};
|
|
2382
2404
|
}
|
|
2383
2405
|
|
|
2384
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2406
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
|
@@ -43,8 +43,8 @@ const {
|
|
|
43
43
|
useState
|
|
44
44
|
} = React__namespace;
|
|
45
45
|
|
|
46
|
-
// `
|
|
47
|
-
const useId = React__namespace[
|
|
46
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
47
|
+
const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
|
|
48
48
|
|
|
49
49
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
50
50
|
|
|
@@ -165,8 +165,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
165
165
|
PanelWithForwardedRef.displayName = "Panel";
|
|
166
166
|
Panel.displayName = "forwardRef(Panel)";
|
|
167
167
|
|
|
168
|
+
let nonce;
|
|
169
|
+
function getNonce() {
|
|
170
|
+
return nonce;
|
|
171
|
+
}
|
|
172
|
+
function setNonce(value) {
|
|
173
|
+
nonce = value;
|
|
174
|
+
}
|
|
175
|
+
|
|
168
176
|
let currentCursorStyle = null;
|
|
177
|
+
let enabled = true;
|
|
169
178
|
let styleElement = null;
|
|
179
|
+
function disableGlobalCursorStyles() {
|
|
180
|
+
enabled = false;
|
|
181
|
+
}
|
|
182
|
+
function enableGlobalCursorStyles() {
|
|
183
|
+
enabled = true;
|
|
184
|
+
}
|
|
170
185
|
function getCursorStyle(state, constraintFlags) {
|
|
171
186
|
if (constraintFlags) {
|
|
172
187
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -212,6 +227,9 @@ function resetGlobalCursorStyle() {
|
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
230
|
+
if (!enabled) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
215
233
|
const style = getCursorStyle(state, constraintFlags);
|
|
216
234
|
if (currentCursorStyle === style) {
|
|
217
235
|
return;
|
|
@@ -219,6 +237,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
219
237
|
currentCursorStyle = style;
|
|
220
238
|
if (styleElement === null) {
|
|
221
239
|
styleElement = document.createElement("style");
|
|
240
|
+
const nonce = getNonce();
|
|
241
|
+
if (nonce) {
|
|
242
|
+
styleElement.setAttribute("nonce", nonce);
|
|
243
|
+
}
|
|
222
244
|
document.head.appendChild(styleElement);
|
|
223
245
|
}
|
|
224
246
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2184,6 +2206,8 @@ exports.Panel = Panel;
|
|
|
2184
2206
|
exports.PanelGroup = PanelGroup;
|
|
2185
2207
|
exports.PanelResizeHandle = PanelResizeHandle;
|
|
2186
2208
|
exports.assert = assert;
|
|
2209
|
+
exports.disableGlobalCursorStyles = disableGlobalCursorStyles;
|
|
2210
|
+
exports.enableGlobalCursorStyles = enableGlobalCursorStyles;
|
|
2187
2211
|
exports.getIntersectingRectangle = getIntersectingRectangle;
|
|
2188
2212
|
exports.getPanelElement = getPanelElement;
|
|
2189
2213
|
exports.getPanelElementsForGroup = getPanelElementsForGroup;
|
|
@@ -2193,3 +2217,4 @@ exports.getResizeHandleElementIndex = getResizeHandleElementIndex;
|
|
|
2193
2217
|
exports.getResizeHandleElementsForGroup = getResizeHandleElementsForGroup;
|
|
2194
2218
|
exports.getResizeHandlePanelIds = getResizeHandlePanelIds;
|
|
2195
2219
|
exports.intersects = intersects;
|
|
2220
|
+
exports.setNonce = setNonce;
|
|
@@ -3,6 +3,8 @@ export {
|
|
|
3
3
|
PanelGroup,
|
|
4
4
|
PanelResizeHandle,
|
|
5
5
|
assert,
|
|
6
|
+
disableGlobalCursorStyles,
|
|
7
|
+
enableGlobalCursorStyles,
|
|
6
8
|
getIntersectingRectangle,
|
|
7
9
|
getPanelElement,
|
|
8
10
|
getPanelElementsForGroup,
|
|
@@ -11,5 +13,6 @@ export {
|
|
|
11
13
|
getResizeHandleElementIndex,
|
|
12
14
|
getResizeHandleElementsForGroup,
|
|
13
15
|
getResizeHandlePanelIds,
|
|
14
|
-
intersects
|
|
16
|
+
intersects,
|
|
17
|
+
setNonce
|
|
15
18
|
} from "./react-resizable-panels.node.cjs.js";
|
|
@@ -19,8 +19,8 @@ const {
|
|
|
19
19
|
useState
|
|
20
20
|
} = React;
|
|
21
21
|
|
|
22
|
-
// `
|
|
23
|
-
const useId = React[
|
|
22
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
23
|
+
const useId = React[`useId${Math.random()}`.slice(0, 5)];
|
|
24
24
|
|
|
25
25
|
// The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
|
|
26
26
|
|
|
@@ -141,8 +141,23 @@ const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
|
|
|
141
141
|
PanelWithForwardedRef.displayName = "Panel";
|
|
142
142
|
Panel.displayName = "forwardRef(Panel)";
|
|
143
143
|
|
|
144
|
+
let nonce;
|
|
145
|
+
function getNonce() {
|
|
146
|
+
return nonce;
|
|
147
|
+
}
|
|
148
|
+
function setNonce(value) {
|
|
149
|
+
nonce = value;
|
|
150
|
+
}
|
|
151
|
+
|
|
144
152
|
let currentCursorStyle = null;
|
|
153
|
+
let enabled = true;
|
|
145
154
|
let styleElement = null;
|
|
155
|
+
function disableGlobalCursorStyles() {
|
|
156
|
+
enabled = false;
|
|
157
|
+
}
|
|
158
|
+
function enableGlobalCursorStyles() {
|
|
159
|
+
enabled = true;
|
|
160
|
+
}
|
|
146
161
|
function getCursorStyle(state, constraintFlags) {
|
|
147
162
|
if (constraintFlags) {
|
|
148
163
|
const horizontalMin = (constraintFlags & EXCEEDED_HORIZONTAL_MIN) !== 0;
|
|
@@ -188,6 +203,9 @@ function resetGlobalCursorStyle() {
|
|
|
188
203
|
}
|
|
189
204
|
}
|
|
190
205
|
function setGlobalCursorStyle(state, constraintFlags) {
|
|
206
|
+
if (!enabled) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
191
209
|
const style = getCursorStyle(state, constraintFlags);
|
|
192
210
|
if (currentCursorStyle === style) {
|
|
193
211
|
return;
|
|
@@ -195,6 +213,10 @@ function setGlobalCursorStyle(state, constraintFlags) {
|
|
|
195
213
|
currentCursorStyle = style;
|
|
196
214
|
if (styleElement === null) {
|
|
197
215
|
styleElement = document.createElement("style");
|
|
216
|
+
const nonce = getNonce();
|
|
217
|
+
if (nonce) {
|
|
218
|
+
styleElement.setAttribute("nonce", nonce);
|
|
219
|
+
}
|
|
198
220
|
document.head.appendChild(styleElement);
|
|
199
221
|
}
|
|
200
222
|
styleElement.innerHTML = `*{cursor: ${style}!important;}`;
|
|
@@ -2156,4 +2178,4 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
|
|
|
2156
2178
|
};
|
|
2157
2179
|
}
|
|
2158
2180
|
|
|
2159
|
-
export { Panel, PanelGroup, PanelResizeHandle, assert, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects };
|
|
2181
|
+
export { Panel, PanelGroup, PanelResizeHandle, assert, disableGlobalCursorStyles, enableGlobalCursorStyles, getIntersectingRectangle, getPanelElement, getPanelElementsForGroup, getPanelGroupElement, getResizeHandleElement, getResizeHandleElementIndex, getResizeHandleElementsForGroup, getResizeHandlePanelIds, intersects, setNonce };
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { Panel } from "./Panel";
|
|
|
2
2
|
import { PanelGroup } from "./PanelGroup";
|
|
3
3
|
import { PanelResizeHandle } from "./PanelResizeHandle";
|
|
4
4
|
import { assert } from "./utils/assert";
|
|
5
|
+
import { setNonce } from "./utils/csp";
|
|
6
|
+
import {
|
|
7
|
+
enableGlobalCursorStyles,
|
|
8
|
+
disableGlobalCursorStyles,
|
|
9
|
+
} from "./utils/cursor";
|
|
5
10
|
import { getPanelElement } from "./utils/dom/getPanelElement";
|
|
6
11
|
import { getPanelElementsForGroup } from "./utils/dom/getPanelElementsForGroup";
|
|
7
12
|
import { getPanelGroupElement } from "./utils/dom/getPanelGroupElement";
|
|
@@ -64,4 +69,9 @@ export {
|
|
|
64
69
|
getResizeHandleElementIndex,
|
|
65
70
|
getResizeHandleElementsForGroup,
|
|
66
71
|
getResizeHandlePanelIds,
|
|
72
|
+
|
|
73
|
+
// Styles and CSP (see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce)
|
|
74
|
+
enableGlobalCursorStyles,
|
|
75
|
+
disableGlobalCursorStyles,
|
|
76
|
+
setNonce,
|
|
67
77
|
};
|
package/src/utils/csp.ts
ADDED
package/src/utils/cursor.ts
CHANGED
|
@@ -4,12 +4,22 @@ import {
|
|
|
4
4
|
EXCEEDED_VERTICAL_MAX,
|
|
5
5
|
EXCEEDED_VERTICAL_MIN,
|
|
6
6
|
} from "../PanelResizeHandleRegistry";
|
|
7
|
+
import { getNonce } from "./csp";
|
|
7
8
|
|
|
8
9
|
type CursorState = "horizontal" | "intersection" | "vertical";
|
|
9
10
|
|
|
10
11
|
let currentCursorStyle: string | null = null;
|
|
12
|
+
let enabled: boolean = true;
|
|
11
13
|
let styleElement: HTMLStyleElement | null = null;
|
|
12
14
|
|
|
15
|
+
export function disableGlobalCursorStyles() {
|
|
16
|
+
enabled = false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function enableGlobalCursorStyles() {
|
|
20
|
+
enabled = true;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export function getCursorStyle(
|
|
14
24
|
state: CursorState,
|
|
15
25
|
constraintFlags: number
|
|
@@ -66,6 +76,10 @@ export function setGlobalCursorStyle(
|
|
|
66
76
|
state: CursorState,
|
|
67
77
|
constraintFlags: number
|
|
68
78
|
) {
|
|
79
|
+
if (!enabled) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
69
83
|
const style = getCursorStyle(state, constraintFlags);
|
|
70
84
|
|
|
71
85
|
if (currentCursorStyle === style) {
|
|
@@ -77,6 +91,11 @@ export function setGlobalCursorStyle(
|
|
|
77
91
|
if (styleElement === null) {
|
|
78
92
|
styleElement = document.createElement("style");
|
|
79
93
|
|
|
94
|
+
const nonce = getNonce();
|
|
95
|
+
if (nonce) {
|
|
96
|
+
styleElement.setAttribute("nonce", nonce);
|
|
97
|
+
}
|
|
98
|
+
|
|
80
99
|
document.head.appendChild(styleElement);
|
|
81
100
|
}
|
|
82
101
|
|
package/src/vendor/react.ts
CHANGED
|
@@ -36,8 +36,10 @@ const {
|
|
|
36
36
|
useState,
|
|
37
37
|
} = React;
|
|
38
38
|
|
|
39
|
-
// `
|
|
40
|
-
const useId = (React as any)[
|
|
39
|
+
// `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
|
|
40
|
+
const useId = (React as any)[
|
|
41
|
+
`useId${Math.random()}`.slice(0, 5)
|
|
42
|
+
] as () => string;
|
|
41
43
|
|
|
42
44
|
const useLayoutEffect_do_not_use_directly = useLayoutEffect;
|
|
43
45
|
|