@dnd-kit/dom 0.1.20 → 0.1.21

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/index.d.cts CHANGED
@@ -224,6 +224,10 @@ interface CursorPluginOptions {
224
224
  * @default 'grabbing'
225
225
  */
226
226
  cursor?: string;
227
+ /**
228
+ * The nonce to be applied to the style element.
229
+ */
230
+ nonce?: string;
227
231
  }
228
232
  declare class Cursor extends Plugin<DragDropManager> {
229
233
  manager: DragDropManager;
@@ -232,6 +236,7 @@ declare class Cursor extends Plugin<DragDropManager> {
232
236
 
233
237
  interface FeedbackOptions {
234
238
  rootElement?: Element | ((source: Draggable) => Element);
239
+ nonce?: string;
235
240
  }
236
241
  declare class Feedback extends Plugin<DragDropManager, FeedbackOptions> {
237
242
  #private;
@@ -279,9 +284,15 @@ declare class ScrollListener extends CorePlugin<DragDropManager> {
279
284
  private handleScroll;
280
285
  }
281
286
 
287
+ interface PreventSelectionPluginOptions {
288
+ /**
289
+ * The nonce to be applied to the style element.
290
+ */
291
+ nonce?: string;
292
+ }
282
293
  declare class PreventSelection extends Plugin<DragDropManager> {
283
294
  manager: DragDropManager;
284
- constructor(manager: DragDropManager);
295
+ constructor(manager: DragDropManager, options?: PreventSelectionPluginOptions);
285
296
  }
286
297
 
287
298
  export { Accessibility, AutoScroller, Cursor, DragDropManager, type Input as DragDropManagerInput, Draggable, type Input$2 as DraggableInput, Droppable, type Input$1 as DroppableInput, Feedback, type FeedbackType, KeyboardSensor, PointerSensor, PreventSelection, ScrollListener, Scroller, type Sensors, type Transition, defaultPreset };
package/index.d.ts CHANGED
@@ -224,6 +224,10 @@ interface CursorPluginOptions {
224
224
  * @default 'grabbing'
225
225
  */
226
226
  cursor?: string;
227
+ /**
228
+ * The nonce to be applied to the style element.
229
+ */
230
+ nonce?: string;
227
231
  }
228
232
  declare class Cursor extends Plugin<DragDropManager> {
229
233
  manager: DragDropManager;
@@ -232,6 +236,7 @@ declare class Cursor extends Plugin<DragDropManager> {
232
236
 
233
237
  interface FeedbackOptions {
234
238
  rootElement?: Element | ((source: Draggable) => Element);
239
+ nonce?: string;
235
240
  }
236
241
  declare class Feedback extends Plugin<DragDropManager, FeedbackOptions> {
237
242
  #private;
@@ -279,9 +284,15 @@ declare class ScrollListener extends CorePlugin<DragDropManager> {
279
284
  private handleScroll;
280
285
  }
281
286
 
287
+ interface PreventSelectionPluginOptions {
288
+ /**
289
+ * The nonce to be applied to the style element.
290
+ */
291
+ nonce?: string;
292
+ }
282
293
  declare class PreventSelection extends Plugin<DragDropManager> {
283
294
  manager: DragDropManager;
284
- constructor(manager: DragDropManager);
295
+ constructor(manager: DragDropManager, options?: PreventSelectionPluginOptions);
285
296
  }
286
297
 
287
298
  export { Accessibility, AutoScroller, Cursor, DragDropManager, type Input as DragDropManagerInput, Draggable, type Input$2 as DraggableInput, Droppable, type Input$1 as DroppableInput, Feedback, type FeedbackType, KeyboardSensor, PointerSensor, PreventSelection, ScrollListener, Scroller, type Sensors, type Transition, defaultPreset };
package/index.js CHANGED
@@ -309,10 +309,13 @@ var Cursor = class extends Plugin {
309
309
  this.destroy = effect(() => {
310
310
  var _a4;
311
311
  const { dragOperation } = this.manager;
312
- const { cursor = "grabbing" } = (_a4 = this.options) != null ? _a4 : {};
312
+ const { cursor = "grabbing", nonce } = (_a4 = this.options) != null ? _a4 : {};
313
313
  if (dragOperation.status.initialized) {
314
314
  const document2 = doc.value;
315
315
  const style = document2.createElement("style");
316
+ if (nonce) {
317
+ style.setAttribute("nonce", nonce);
318
+ }
316
319
  style.textContent = `* { cursor: ${cursor} !important; }`;
317
320
  document2.head.appendChild(style);
318
321
  return () => style.remove();
@@ -914,17 +917,21 @@ render_fn = function() {
914
917
  };
915
918
  };
916
919
  injectStyles_fn = function() {
917
- var _a4, _b2;
920
+ var _a4, _b2, _c3;
918
921
  const { status, source, target } = this.manager.dragOperation;
922
+ const { nonce } = (_a4 = this.options) != null ? _a4 : {};
919
923
  if (status.initializing) {
920
- const sourceDocument = getDocument((_a4 = source == null ? void 0 : source.element) != null ? _a4 : null);
921
- const targetDocument = getDocument((_b2 = target == null ? void 0 : target.element) != null ? _b2 : null);
924
+ const sourceDocument = getDocument((_b2 = source == null ? void 0 : source.element) != null ? _b2 : null);
925
+ const targetDocument = getDocument((_c3 = target == null ? void 0 : target.element) != null ? _c3 : null);
922
926
  const documents = /* @__PURE__ */ new Set([sourceDocument, targetDocument]);
923
927
  for (const doc of documents) {
924
928
  let registration = styleSheetRegistry.get(doc);
925
929
  if (!registration) {
926
930
  const style = document.createElement("style");
927
931
  style.textContent = CSS_RULES;
932
+ if (nonce) {
933
+ style.setAttribute("nonce", nonce);
934
+ }
928
935
  doc.head.prepend(style);
929
936
  const mutationObserver = new MutationObserver((entries) => {
930
937
  for (const entry of entries) {
@@ -1298,13 +1305,18 @@ var ScrollListener = class extends CorePlugin {
1298
1305
  };
1299
1306
  _timeout = new WeakMap();
1300
1307
  var PreventSelection = class extends Plugin {
1301
- constructor(manager) {
1302
- super(manager);
1308
+ constructor(manager, options) {
1309
+ super(manager, options);
1303
1310
  this.manager = manager;
1304
1311
  this.destroy = effect(() => {
1312
+ var _a4;
1305
1313
  const { dragOperation } = this.manager;
1314
+ const { nonce } = (_a4 = this.options) != null ? _a4 : {};
1306
1315
  if (dragOperation.status.initialized) {
1307
1316
  const style = document.createElement("style");
1317
+ if (nonce) {
1318
+ style.setAttribute("nonce", nonce);
1319
+ }
1308
1320
  style.textContent = `* { user-select: none !important; -webkit-user-select: none !important; }`;
1309
1321
  document.head.appendChild(style);
1310
1322
  removeSelection();