@dnd-kit/abstract 0.1.21 → 0.2.0-beta-20251025202520

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.cjs CHANGED
@@ -1123,6 +1123,58 @@ var Sensor = class extends Plugin {
1123
1123
  }
1124
1124
  };
1125
1125
 
1126
+ // src/core/sensors/activation.ts
1127
+ var ActivationController = class extends AbortController {
1128
+ constructor(constraints, onActivate) {
1129
+ super();
1130
+ this.constraints = constraints;
1131
+ this.onActivate = onActivate;
1132
+ this.activated = false;
1133
+ for (const constraint of constraints != null ? constraints : []) {
1134
+ constraint.controller = this;
1135
+ }
1136
+ }
1137
+ onEvent(event) {
1138
+ var _a;
1139
+ if (this.activated) return;
1140
+ if ((_a = this.constraints) == null ? void 0 : _a.length) {
1141
+ for (const constraint of this.constraints) {
1142
+ constraint.onEvent(event);
1143
+ }
1144
+ } else {
1145
+ this.activate(event);
1146
+ }
1147
+ }
1148
+ activate(event) {
1149
+ if (this.activated) return;
1150
+ this.activated = true;
1151
+ this.onActivate(event);
1152
+ }
1153
+ abort(event) {
1154
+ this.activated = false;
1155
+ super.abort(event);
1156
+ }
1157
+ };
1158
+ var _controller;
1159
+ var ActivationConstraint = class {
1160
+ constructor(options) {
1161
+ this.options = options;
1162
+ __privateAdd(this, _controller);
1163
+ }
1164
+ set controller(controller) {
1165
+ __privateSet(this, _controller, controller);
1166
+ controller.signal.addEventListener("abort", () => this.abort());
1167
+ }
1168
+ /**
1169
+ * Called when the activation is triggered.
1170
+ */
1171
+ activate(event) {
1172
+ var _a;
1173
+ (_a = __privateGet(this, _controller)) == null ? void 0 : _a.activate(event);
1174
+ }
1175
+ };
1176
+ _controller = new WeakMap();
1177
+
1126
1178
  // src/core/modifiers/modifier.ts
1127
1179
  var Modifier = class extends Plugin {
1128
1180
  /**
@@ -1469,6 +1521,8 @@ var DragDropManager = class {
1469
1521
  }
1470
1522
  };
1471
1523
 
1524
+ exports.ActivationConstraint = ActivationConstraint;
1525
+ exports.ActivationController = ActivationController;
1472
1526
  exports.CollisionPriority = CollisionPriority;
1473
1527
  exports.CollisionType = CollisionType;
1474
1528
  exports.CorePlugin = CorePlugin;