@dreamtree-org/twreact-ui 1.1.1 → 1.1.3

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/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { forwardRef, createElement, useId, useRef, useState, useEffect, useImperativeHandle, useMemo, memo, useLayoutEffect, useCallback, createContext, useContext, cloneElement, PureComponent } from 'react';
2
+ import React__default, { forwardRef, createElement, useId, useRef, useState, useEffect, useImperativeHandle, useMemo, useLayoutEffect, useCallback, createContext, useContext, cloneElement, PureComponent } from 'react';
3
3
  import ReactDOM, { createPortal } from 'react-dom';
4
4
 
5
5
  function _extends() {
@@ -3346,8 +3346,8 @@ function _defineProperty$4(e, r, t) {
3346
3346
  }
3347
3347
 
3348
3348
  var _excluded$l = ["options", "value", "onChange", "placeholder", "label", "error", "disabled", "required", "multiSelect", "searchable", "grouped", "onMenuItemRender", "className", "allowClear", "creatable", "onCreateOption", "onSearch", "loading", "selectAllOption", "closeOnSelect", "maxTagCount", "renderGroupLabel", "name"];
3349
- function ownKeys$b(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3350
- function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3349
+ function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3350
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3351
3351
 
3352
3352
  /**
3353
3353
  * Enhanced Select component (debounce removed)
@@ -3370,7 +3370,7 @@ var flattenGroups = function flattenGroups() {
3370
3370
  return groups.reduce(function (acc, g) {
3371
3371
  var groupLabel = g.label;
3372
3372
  g.options.forEach(function (opt) {
3373
- return acc.push(_objectSpread$b(_objectSpread$b({}, opt), {}, {
3373
+ return acc.push(_objectSpread$a(_objectSpread$a({}, opt), {}, {
3374
3374
  _group: groupLabel
3375
3375
  }));
3376
3376
  });
@@ -3460,7 +3460,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
3460
3460
  var flatOptions = useMemo(function () {
3461
3461
  if (grouped) return flattenGroups(options);
3462
3462
  return options.map(function (opt) {
3463
- return _objectSpread$b({}, opt);
3463
+ return _objectSpread$a({}, opt);
3464
3464
  });
3465
3465
  }, [options, grouped]);
3466
3466
  var selectedValues = multiSelect ? Array.isArray(value) ? value : [] : value;
@@ -3487,7 +3487,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
3487
3487
  }
3488
3488
  if (grouped) {
3489
3489
  return options.map(function (g) {
3490
- return _objectSpread$b(_objectSpread$b({}, g), {}, {
3490
+ return _objectSpread$a(_objectSpread$a({}, g), {}, {
3491
3491
  options: g.options.filter(function (o) {
3492
3492
  return o.label.toLowerCase().includes(searchTerm.toLowerCase());
3493
3493
  })
@@ -3714,7 +3714,7 @@ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardedRef
3714
3714
  className: "text-xs border border-slate-200 p-0.5 rounded-md cursor-pointer hover:bg-gray-100",
3715
3715
  onClick: function onClick() {
3716
3716
  return setCollapsedGroups(function (prev) {
3717
- return _objectSpread$b(_objectSpread$b({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
3717
+ return _objectSpread$a(_objectSpread$a({}, prev), {}, _defineProperty$4({}, group.label, !prev[group.label]));
3718
3718
  });
3719
3719
  }
3720
3720
  }, /*#__PURE__*/React__default.createElement(ChevronDown, {
@@ -4185,78 +4185,137 @@ function MobileFilters(_ref) {
4185
4185
  })));
4186
4186
  }
4187
4187
 
4188
- function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4189
- function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty$4(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4190
-
4191
- /**
4192
- * Action menu dropdown component for table row actions
4193
- * Uses fixed positioning with smart placement above/below anchor
4194
- */
4195
- var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
4188
+ function ActionMenu(_ref) {
4196
4189
  var _ref$actions = _ref.actions,
4197
4190
  actions = _ref$actions === void 0 ? [] : _ref$actions,
4198
4191
  row = _ref.row,
4199
4192
  onAction = _ref.onAction,
4193
+ onClose = _ref.onClose,
4200
4194
  menuRef = _ref.menuRef,
4201
- anchorEl = _ref.anchorEl,
4202
- onClose = _ref.onClose;
4195
+ anchorEl = _ref.anchorEl;
4203
4196
  var _useState = useState({
4204
- top: 0,
4205
4197
  left: 0,
4206
- visibility: "hidden"
4198
+ top: 0,
4199
+ transformOrigin: "top right",
4200
+ maxHeight: 300,
4201
+ width: 180,
4202
+ opacity: 0
4207
4203
  }),
4208
4204
  _useState2 = _slicedToArray(_useState, 2),
4209
- pos = _useState2[0],
4210
- setPos = _useState2[1];
4205
+ style = _useState2[0],
4206
+ setStyle = _useState2[1];
4207
+ var menuWidth = 180;
4208
+ var maxMenuHeight = 320;
4209
+ var minMenuHeight = 80;
4210
+ var margin = 8;
4211
4211
  useLayoutEffect(function () {
4212
- if (!anchorEl || !(menuRef !== null && menuRef !== void 0 && menuRef.current) || typeof window === "undefined") {
4213
- setPos(function (p) {
4214
- return _objectSpread$a(_objectSpread$a({}, p), {}, {
4215
- visibility: "hidden"
4216
- });
4212
+ computePosition();
4213
+ var handleResize = function handleResize() {
4214
+ window.requestAnimationFrame(function () {
4215
+ return computePosition();
4217
4216
  });
4218
- return;
4219
- }
4220
- var menu = menuRef.current;
4217
+ };
4218
+ var handleScroll = function handleScroll() {
4219
+ onClose === null || onClose === void 0 || onClose();
4220
+ };
4221
+ window.addEventListener("resize", handleResize);
4222
+ window.addEventListener("scroll", handleScroll, true);
4223
+ return function () {
4224
+ window.removeEventListener("resize", handleResize);
4225
+ window.removeEventListener("scroll", handleScroll, true);
4226
+ };
4227
+ }, [anchorEl, actions, menuRef, onClose]);
4228
+ var computePosition = function computePosition() {
4229
+ if (!anchorEl || typeof window === "undefined") return;
4221
4230
  var rect = anchorEl.getBoundingClientRect();
4222
- var menuWidth = menu.offsetWidth || 176;
4223
- var menuHeight = menu.offsetHeight || menu.scrollHeight || 200;
4224
- var viewportWidth = window.innerWidth;
4225
- var viewportHeight = window.innerHeight;
4226
- var scrollX = window.scrollX || window.pageXOffset || 0;
4227
4231
  var scrollY = window.scrollY || window.pageYOffset || 0;
4228
- var preferBelowTop = rect.bottom + scrollY + 6;
4229
- var preferAboveTop = rect.top + scrollY - menuHeight - 6;
4232
+ var scrollX = window.scrollX || window.pageXOffset || 0;
4233
+ var spaceBelow = window.innerHeight - rect.bottom;
4234
+ var spaceAbove = rect.top;
4230
4235
 
4231
- // Calculate horizontal position
4232
- var left = rect.right + scrollX - menuWidth;
4233
- if (left < 8) left = 8;
4234
- if (left + menuWidth > viewportWidth - 8) {
4235
- left = Math.max(8, viewportWidth - menuWidth - 8);
4236
+ // allowed max height based on available space
4237
+ var allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, Math.max(spaceBelow - margin, spaceAbove - margin)));
4238
+
4239
+ // decide placement
4240
+ var placement = "bottom";
4241
+ if (spaceBelow < 160 && spaceAbove > spaceBelow) {
4242
+ placement = "top";
4243
+ allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceAbove - margin));
4244
+ } else {
4245
+ allowedMaxHeight = Math.min(maxMenuHeight, Math.max(minMenuHeight, spaceBelow - margin));
4246
+ }
4247
+
4248
+ // measure content height if available
4249
+ var measuredMenuHeight = allowedMaxHeight;
4250
+ var menuEl = menuRef === null || menuRef === void 0 ? void 0 : menuRef.current;
4251
+ if (menuEl) {
4252
+ var contentHeight = menuEl.scrollHeight || menuEl.offsetHeight || allowedMaxHeight;
4253
+ measuredMenuHeight = Math.min(contentHeight, allowedMaxHeight);
4236
4254
  }
4237
4255
 
4238
- // Calculate vertical position
4256
+ // compute top based on placement
4239
4257
  var top;
4240
- if (preferBelowTop + menuHeight <= scrollY + viewportHeight - 8) {
4241
- top = preferBelowTop;
4242
- } else if (preferAboveTop >= scrollY + 8) {
4243
- top = preferAboveTop;
4258
+ if (placement === "top") {
4259
+ top = rect.top + scrollY - measuredMenuHeight - margin;
4244
4260
  } else {
4245
- top = Math.max(scrollY + 8, Math.min(preferBelowTop, scrollY + viewportHeight - menuHeight - 8));
4261
+ top = rect.bottom + scrollY + margin;
4246
4262
  }
4247
- setPos({
4248
- top: top,
4263
+
4264
+ // clamp top to viewport
4265
+ var minTop = margin + scrollY;
4266
+ var maxTop = window.innerHeight + scrollY - measuredMenuHeight - margin;
4267
+ if (top < minTop) top = minTop;
4268
+ if (top > maxTop) top = maxTop;
4269
+
4270
+ // compute left and clamp horizontally (align right edge of menu to anchor right)
4271
+ var left = rect.right + scrollX - menuWidth;
4272
+ if (left < margin) left = margin;
4273
+ if (left + menuWidth > window.innerWidth - margin) {
4274
+ left = Math.max(margin, window.innerWidth - menuWidth - margin);
4275
+ }
4276
+ var transformOrigin = placement === "bottom" ? "top right" : "bottom right";
4277
+
4278
+ // Apply style (fade-in by setting opacity to 1)
4279
+ setStyle({
4249
4280
  left: left,
4250
- visibility: "visible"
4281
+ top: top,
4282
+ transformOrigin: transformOrigin,
4283
+ maxHeight: allowedMaxHeight,
4284
+ width: menuWidth,
4285
+ opacity: 1
4251
4286
  });
4252
- }, [anchorEl, menuRef, actions, row]);
4253
- return /*#__PURE__*/React__default.createElement("div", {
4287
+ };
4288
+
4289
+ // measure & position before paint
4290
+ useLayoutEffect(function () {
4291
+ computePosition();
4292
+ var onScrollOrResize = function onScrollOrResize() {
4293
+ window.requestAnimationFrame(function () {
4294
+ return computePosition();
4295
+ });
4296
+ };
4297
+ window.addEventListener("resize", onScrollOrResize);
4298
+ window.addEventListener("scroll", onScrollOrResize, true);
4299
+ return function () {
4300
+ window.removeEventListener("resize", onScrollOrResize);
4301
+ window.removeEventListener("scroll", onScrollOrResize, true);
4302
+ };
4303
+ // recompute when anchor or actions change (content height may change)
4304
+ }, [anchorEl, actions, menuRef]);
4305
+
4306
+ // Render into body
4307
+ return /*#__PURE__*/createPortal(/*#__PURE__*/React__default.createElement("div", {
4254
4308
  ref: menuRef,
4255
- className: "absolute right-0 z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5",
4256
4309
  style: {
4257
- visibility: pos.visibility,
4258
- minWidth: 176
4310
+ position: "absolute",
4311
+ top: style.top,
4312
+ left: style.left,
4313
+ width: style.width,
4314
+ maxHeight: style.maxHeight,
4315
+ transformOrigin: style.transformOrigin,
4316
+ opacity: style.opacity
4259
4317
  },
4318
+ className: "absolute z-50 bg-white rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-y-auto transition-opacity duration-150 ease-out",
4260
4319
  onClick: function onClick(e) {
4261
4320
  return e.stopPropagation();
4262
4321
  }
@@ -4268,18 +4327,25 @@ var ActionMenu = /*#__PURE__*/memo(function ActionMenu(_ref) {
4268
4327
  return /*#__PURE__*/React__default.createElement("div", {
4269
4328
  key: action.name,
4270
4329
  className: "px-1"
4271
- }, /*#__PURE__*/React__default.createElement("button", {
4330
+ }, action.render ? /*#__PURE__*/React__default.createElement("button", {
4272
4331
  className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
4273
4332
  onClick: function onClick(e) {
4274
4333
  e.stopPropagation();
4275
4334
  onAction === null || onAction === void 0 || onAction(action, row);
4276
4335
  onClose === null || onClose === void 0 || onClose();
4277
4336
  }
4278
- }, action.render ? action.render(row) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, action.icon && /*#__PURE__*/React__default.createElement("span", {
4337
+ }, action.render(row)) : /*#__PURE__*/React__default.createElement("button", {
4338
+ className: "w-full text-left px-3 py-2 text-sm hover:bg-gray-100 flex items-center gap-2 rounded-md",
4339
+ onClick: function onClick(e) {
4340
+ e.stopPropagation();
4341
+ onAction === null || onAction === void 0 || onAction(action, row);
4342
+ onClose === null || onClose === void 0 || onClose();
4343
+ }
4344
+ }, action.icon && /*#__PURE__*/React__default.createElement("span", {
4279
4345
  className: "inline-flex"
4280
- }, action.icon), /*#__PURE__*/React__default.createElement("span", null, action.label))));
4281
- })));
4282
- });
4346
+ }, action.icon), /*#__PURE__*/React__default.createElement("span", null, action.label)));
4347
+ }))), document.body);
4348
+ }
4283
4349
 
4284
4350
  /**
4285
4351
  * Desktop table row component
@@ -5264,29 +5330,23 @@ var isWeb = typeof window !== 'undefined' &&
5264
5330
  typeof document !== 'undefined';
5265
5331
 
5266
5332
  function cloneObject(data) {
5267
- let copy;
5268
- const isArray = Array.isArray(data);
5269
- const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
5270
5333
  if (data instanceof Date) {
5271
- copy = new Date(data);
5334
+ return new Date(data);
5272
5335
  }
5273
- else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
5274
- (isArray || isObject$1(data))) {
5275
- copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
5276
- if (!isArray && !isPlainObject$3(data)) {
5277
- copy = data;
5278
- }
5279
- else {
5280
- for (const key in data) {
5281
- if (data.hasOwnProperty(key)) {
5282
- copy[key] = cloneObject(data[key]);
5283
- }
5284
- }
5285
- }
5336
+ const isFileListInstance = typeof FileList !== 'undefined' && data instanceof FileList;
5337
+ if (isWeb && (data instanceof Blob || isFileListInstance)) {
5338
+ return data;
5286
5339
  }
5287
- else {
5340
+ const isArray = Array.isArray(data);
5341
+ if (!isArray && !(isObject$1(data) && isPlainObject$3(data))) {
5288
5342
  return data;
5289
5343
  }
5344
+ const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
5345
+ for (const key in data) {
5346
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
5347
+ copy[key] = cloneObject(data[key]);
5348
+ }
5349
+ }
5290
5350
  return copy;
5291
5351
  }
5292
5352
 
@@ -5312,6 +5372,8 @@ var get$1 = (object, path, defaultValue) => {
5312
5372
 
5313
5373
  var isBoolean$3 = (value) => typeof value === 'boolean';
5314
5374
 
5375
+ var isFunction$3 = (value) => typeof value === 'function';
5376
+
5315
5377
  var set$1 = (object, path, value) => {
5316
5378
  let index = -1;
5317
5379
  const tempPath = isKey(path) ? [path] : stringToPath(path);
@@ -5359,73 +5421,16 @@ const INPUT_VALIDATION_RULES = {
5359
5421
  validate: 'validate',
5360
5422
  };
5361
5423
 
5362
- const HookFormContext = React__default.createContext(null);
5363
- HookFormContext.displayName = 'HookFormContext';
5364
5424
  /**
5365
- * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
5366
- *
5367
- * @remarks
5368
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
5369
- *
5370
- * @returns return all useForm methods
5371
- *
5372
- * @example
5373
- * ```tsx
5374
- * function App() {
5375
- * const methods = useForm();
5376
- * const onSubmit = data => console.log(data);
5377
- *
5378
- * return (
5379
- * <FormProvider {...methods} >
5380
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
5381
- * <NestedInput />
5382
- * <input type="submit" />
5383
- * </form>
5384
- * </FormProvider>
5385
- * );
5386
- * }
5387
- *
5388
- * function NestedInput() {
5389
- * const { register } = useFormContext(); // retrieve all hook methods
5390
- * return <input {...register("test")} />;
5391
- * }
5392
- * ```
5425
+ * Separate context for `control` to prevent unnecessary rerenders.
5426
+ * Internal hooks that only need control use this instead of full form context.
5393
5427
  */
5394
- const useFormContext = () => React__default.useContext(HookFormContext);
5428
+ const HookFormControlContext = React__default.createContext(null);
5429
+ HookFormControlContext.displayName = 'HookFormControlContext';
5395
5430
  /**
5396
- * A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.
5397
- *
5398
- * @remarks
5399
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
5400
- *
5401
- * @param props - all useForm methods
5402
- *
5403
- * @example
5404
- * ```tsx
5405
- * function App() {
5406
- * const methods = useForm();
5407
- * const onSubmit = data => console.log(data);
5408
- *
5409
- * return (
5410
- * <FormProvider {...methods} >
5411
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
5412
- * <NestedInput />
5413
- * <input type="submit" />
5414
- * </form>
5415
- * </FormProvider>
5416
- * );
5417
- * }
5418
- *
5419
- * function NestedInput() {
5420
- * const { register } = useFormContext(); // retrieve all hook methods
5421
- * return <input {...register("test")} />;
5422
- * }
5423
- * ```
5431
+ * @internal Internal hook to access only control from context.
5424
5432
  */
5425
- const FormProvider = (props) => {
5426
- const { children, ...data } = props;
5427
- return (React__default.createElement(HookFormContext.Provider, { value: data }, children));
5428
- };
5433
+ const useFormControlContext = () => React__default.useContext(HookFormControlContext);
5429
5434
 
5430
5435
  var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
5431
5436
  const result = {
@@ -5479,8 +5484,8 @@ const useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React__defau
5479
5484
  * ```
5480
5485
  */
5481
5486
  function useFormState(props) {
5482
- const methods = useFormContext();
5483
- const { control = methods.control, disabled, name, exact } = props || {};
5487
+ const formControl = useFormControlContext();
5488
+ const { control = formControl, disabled, name, exact } = props || {};
5484
5489
  const [formState, updateFormState] = React__default.useState(control._formState);
5485
5490
  const _localProxyFormState = React__default.useRef({
5486
5491
  isDirty: false,
@@ -5532,7 +5537,7 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
5532
5537
  return Object.is(object1, object2);
5533
5538
  }
5534
5539
  if (isDateObject(object1) && isDateObject(object2)) {
5535
- return object1.getTime() === object2.getTime();
5540
+ return Object.is(object1.getTime(), object2.getTime());
5536
5541
  }
5537
5542
  const keys1 = Object.keys(object1);
5538
5543
  const keys2 = Object.keys(object2);
@@ -5580,8 +5585,8 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
5580
5585
  * ```
5581
5586
  */
5582
5587
  function useWatch(props) {
5583
- const methods = useFormContext();
5584
- const { control = methods.control, name, defaultValue, disabled, exact, compute, } = props || {};
5588
+ const formControl = useFormControlContext();
5589
+ const { control = formControl, name, defaultValue, disabled, exact, compute, } = props || {};
5585
5590
  const _defaultValue = React__default.useRef(defaultValue);
5586
5591
  const _compute = React__default.useRef(compute);
5587
5592
  const _computeFormValues = React__default.useRef(undefined);
@@ -5674,8 +5679,8 @@ function useWatch(props) {
5674
5679
  * ```
5675
5680
  */
5676
5681
  function useController(props) {
5677
- const methods = useFormContext();
5678
- const { name, disabled, control = methods.control, shouldUnregister, defaultValue, exact = true, } = props;
5682
+ const formControl = useFormControlContext();
5683
+ const { name, disabled, control = formControl, shouldUnregister, defaultValue, exact = true, } = props;
5679
5684
  const isArrayField = isNameInFieldArray(control._names.array, name);
5680
5685
  const defaultValueMemo = React__default.useMemo(() => get$1(control._formValues, name, get$1(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
5681
5686
  const value = useWatch({
@@ -5735,12 +5740,12 @@ function useController(props) {
5735
5740
  }), [name, control._formValues]);
5736
5741
  const ref = React__default.useCallback((elm) => {
5737
5742
  const field = get$1(control._fields, name);
5738
- if (field && elm) {
5743
+ if (field && field._f && elm) {
5739
5744
  field._f.ref = {
5740
- focus: () => elm.focus && elm.focus(),
5741
- select: () => elm.select && elm.select(),
5742
- setCustomValidity: (message) => elm.setCustomValidity(message),
5743
- reportValidity: () => elm.reportValidity(),
5745
+ focus: () => isFunction$3(elm.focus) && elm.focus(),
5746
+ select: () => isFunction$3(elm.select) && elm.select(),
5747
+ setCustomValidity: (message) => isFunction$3(elm.setCustomValidity) && elm.setCustomValidity(message),
5748
+ reportValidity: () => isFunction$3(elm.reportValidity) && elm.reportValidity(),
5744
5749
  };
5745
5750
  }
5746
5751
  }, [control._fields, name]);
@@ -5847,6 +5852,78 @@ function useController(props) {
5847
5852
  */
5848
5853
  const Controller = (props) => props.render(useController(props));
5849
5854
 
5855
+ const HookFormContext = React__default.createContext(null);
5856
+ HookFormContext.displayName = 'HookFormContext';
5857
+ /**
5858
+ * A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.
5859
+ *
5860
+ * @remarks
5861
+ * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
5862
+ *
5863
+ * @param props - all useForm methods
5864
+ *
5865
+ * @example
5866
+ * ```tsx
5867
+ * function App() {
5868
+ * const methods = useForm();
5869
+ * const onSubmit = data => console.log(data);
5870
+ *
5871
+ * return (
5872
+ * <FormProvider {...methods} >
5873
+ * <form onSubmit={methods.handleSubmit(onSubmit)}>
5874
+ * <NestedInput />
5875
+ * <input type="submit" />
5876
+ * </form>
5877
+ * </FormProvider>
5878
+ * );
5879
+ * }
5880
+ *
5881
+ * function NestedInput() {
5882
+ * const { register } = useFormContext(); // retrieve all hook methods
5883
+ * return <input {...register("test")} />;
5884
+ * }
5885
+ * ```
5886
+ */
5887
+ const FormProvider = (props) => {
5888
+ const { children, watch, getValues, getFieldState, setError, clearErrors, setValue, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, } = props;
5889
+ return (React__default.createElement(HookFormContext.Provider, { value: React__default.useMemo(() => ({
5890
+ watch,
5891
+ getValues,
5892
+ getFieldState,
5893
+ setError,
5894
+ clearErrors,
5895
+ setValue,
5896
+ trigger,
5897
+ formState,
5898
+ resetField,
5899
+ reset,
5900
+ handleSubmit,
5901
+ unregister,
5902
+ control,
5903
+ register,
5904
+ setFocus,
5905
+ subscribe,
5906
+ }), [
5907
+ clearErrors,
5908
+ control,
5909
+ formState,
5910
+ getFieldState,
5911
+ getValues,
5912
+ handleSubmit,
5913
+ register,
5914
+ reset,
5915
+ resetField,
5916
+ setError,
5917
+ setFocus,
5918
+ setValue,
5919
+ subscribe,
5920
+ trigger,
5921
+ unregister,
5922
+ watch,
5923
+ ]) },
5924
+ React__default.createElement(HookFormControlContext.Provider, { value: control }, children)));
5925
+ };
5926
+
5850
5927
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
5851
5928
  ? {
5852
5929
  ...errors[name],
@@ -5911,8 +5988,6 @@ var isEmptyObject$1 = (value) => isObject$1(value) && !Object.keys(value).length
5911
5988
 
5912
5989
  var isFileInput = (element) => element.type === 'file';
5913
5990
 
5914
- var isFunction$3 = (value) => typeof value === 'function';
5915
-
5916
5991
  var isHTMLElement = (value) => {
5917
5992
  if (!isWeb) {
5918
5993
  return false;
@@ -6480,6 +6555,7 @@ function createFormControl(props = {}) {
6480
6555
  action: false,
6481
6556
  mount: false,
6482
6557
  watch: false,
6558
+ keepIsValid: false,
6483
6559
  };
6484
6560
  let _names = {
6485
6561
  mount: new Set(),
@@ -6490,7 +6566,7 @@ function createFormControl(props = {}) {
6490
6566
  };
6491
6567
  let delayErrorCallback;
6492
6568
  let timer = 0;
6493
- const _proxyFormState = {
6569
+ const defaultProxyFormState = {
6494
6570
  isDirty: false,
6495
6571
  dirtyFields: false,
6496
6572
  validatingFields: false,
@@ -6499,6 +6575,9 @@ function createFormControl(props = {}) {
6499
6575
  isValid: false,
6500
6576
  errors: false,
6501
6577
  };
6578
+ const _proxyFormState = {
6579
+ ...defaultProxyFormState,
6580
+ };
6502
6581
  let _proxySubscribeFormState = {
6503
6582
  ..._proxyFormState,
6504
6583
  };
@@ -6512,13 +6591,21 @@ function createFormControl(props = {}) {
6512
6591
  timer = setTimeout(callback, wait);
6513
6592
  };
6514
6593
  const _setValid = async (shouldUpdateValid) => {
6594
+ if (_state.keepIsValid) {
6595
+ return;
6596
+ }
6515
6597
  if (!_options.disabled &&
6516
6598
  (_proxyFormState.isValid ||
6517
6599
  _proxySubscribeFormState.isValid ||
6518
6600
  shouldUpdateValid)) {
6519
- const isValid = _options.resolver
6520
- ? isEmptyObject$1((await _runSchema()).errors)
6521
- : await executeBuiltInValidation(_fields, true);
6601
+ let isValid;
6602
+ if (_options.resolver) {
6603
+ isValid = isEmptyObject$1((await _runSchema()).errors);
6604
+ _updateIsValidating();
6605
+ }
6606
+ else {
6607
+ isValid = await executeBuiltInValidation(_fields, true);
6608
+ }
6522
6609
  if (isValid !== _formState.isValid) {
6523
6610
  _subjects.state.next({
6524
6611
  isValid,
@@ -6681,11 +6768,11 @@ function createFormControl(props = {}) {
6681
6768
  const _runSchema = async (name) => {
6682
6769
  _updateIsValidating(name, true);
6683
6770
  const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
6684
- _updateIsValidating(name);
6685
6771
  return result;
6686
6772
  };
6687
6773
  const executeSchemaAndUpdateState = async (names) => {
6688
6774
  const { errors } = await _runSchema(names);
6775
+ _updateIsValidating(names);
6689
6776
  if (names) {
6690
6777
  for (const name of names) {
6691
6778
  const error = get$1(errors, name);
@@ -6718,7 +6805,7 @@ function createFormControl(props = {}) {
6718
6805
  }
6719
6806
  if (fieldError[_f.name]) {
6720
6807
  context.valid = false;
6721
- if (shouldOnlyCheckValid) {
6808
+ if (shouldOnlyCheckValid || props.shouldUseNativeValidation) {
6722
6809
  break;
6723
6810
  }
6724
6811
  }
@@ -6853,11 +6940,19 @@ function createFormControl(props = {}) {
6853
6940
  ? setValues(name, cloneValue, options)
6854
6941
  : setFieldValue(name, cloneValue, options);
6855
6942
  }
6856
- isWatched(name, _names) && _subjects.state.next({ ..._formState, name });
6857
- _subjects.state.next({
6858
- name: _state.mount ? name : undefined,
6859
- values: cloneObject(_formValues),
6860
- });
6943
+ if (isWatched(name, _names)) {
6944
+ _subjects.state.next({
6945
+ ..._formState,
6946
+ name,
6947
+ values: cloneObject(_formValues),
6948
+ });
6949
+ }
6950
+ else {
6951
+ _subjects.state.next({
6952
+ name: _state.mount ? name : undefined,
6953
+ values: cloneObject(_formValues),
6954
+ });
6955
+ }
6861
6956
  };
6862
6957
  const onChange = async (event) => {
6863
6958
  _state.mount = true;
@@ -6921,6 +7016,7 @@ function createFormControl(props = {}) {
6921
7016
  !isBlurEvent && watched && _subjects.state.next({ ..._formState });
6922
7017
  if (_options.resolver) {
6923
7018
  const { errors } = await _runSchema([name]);
7019
+ _updateIsValidating([name]);
6924
7020
  _updateIsFieldValueUpdated(fieldValue);
6925
7021
  if (isFieldValueUpdated) {
6926
7022
  const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
@@ -7066,7 +7162,10 @@ function createFormControl(props = {}) {
7066
7162
  };
7067
7163
  return _subscribe({
7068
7164
  ...props,
7069
- formState: _proxySubscribeFormState,
7165
+ formState: {
7166
+ ...defaultProxyFormState,
7167
+ ...props.formState,
7168
+ },
7070
7169
  });
7071
7170
  };
7072
7171
  const unregister = (name, options = {}) => {
@@ -7099,7 +7198,11 @@ function createFormControl(props = {}) {
7099
7198
  if ((isBoolean$3(disabled) && _state.mount) ||
7100
7199
  !!disabled ||
7101
7200
  _names.disabled.has(name)) {
7201
+ const wasDisabled = _names.disabled.has(name);
7202
+ const isDisabled = !!disabled;
7203
+ const disabledStateChanged = wasDisabled !== isDisabled;
7102
7204
  disabled ? _names.disabled.add(name) : _names.disabled.delete(name);
7205
+ disabledStateChanged && _state.mount && !_state.action && _setValid();
7103
7206
  }
7104
7207
  };
7105
7208
  const register = (name, options = {}) => {
@@ -7219,6 +7322,7 @@ function createFormControl(props = {}) {
7219
7322
  });
7220
7323
  if (_options.resolver) {
7221
7324
  const { errors, values } = await _runSchema();
7325
+ _updateIsValidating();
7222
7326
  _formState.errors = errors;
7223
7327
  fieldValues = cloneObject(values);
7224
7328
  }
@@ -7300,9 +7404,15 @@ function createFormControl(props = {}) {
7300
7404
  ...Object.keys(getDirtyFields(_defaultValues, _formValues)),
7301
7405
  ]);
7302
7406
  for (const fieldName of Array.from(fieldsToCheck)) {
7303
- get$1(_formState.dirtyFields, fieldName)
7304
- ? set$1(values, fieldName, get$1(_formValues, fieldName))
7305
- : setValue(fieldName, get$1(values, fieldName));
7407
+ const isDirty = get$1(_formState.dirtyFields, fieldName);
7408
+ const existingValue = get$1(_formValues, fieldName);
7409
+ const newValue = get$1(values, fieldName);
7410
+ if (isDirty && !isUndefined$1(existingValue)) {
7411
+ set$1(values, fieldName, existingValue);
7412
+ }
7413
+ else if (!isDirty && !isUndefined$1(newValue)) {
7414
+ setValue(fieldName, newValue);
7415
+ }
7306
7416
  }
7307
7417
  }
7308
7418
  else {
@@ -7359,6 +7469,14 @@ function createFormControl(props = {}) {
7359
7469
  !!keepStateOptions.keepDirtyValues ||
7360
7470
  (!_options.shouldUnregister && !isEmptyObject$1(values));
7361
7471
  _state.watch = !!_options.shouldUnregister;
7472
+ _state.keepIsValid = !!keepStateOptions.keepIsValid;
7473
+ _state.action = false;
7474
+ // Clear errors synchronously to prevent validation errors on subsequent submissions
7475
+ // This fixes the issue where form.reset() causes validation errors on subsequent
7476
+ // submissions in Next.js 16 with Server Actions
7477
+ if (!keepStateOptions.keepErrors) {
7478
+ _formState.errors = {};
7479
+ }
7362
7480
  _subjects.state.next({
7363
7481
  submitCount: keepStateOptions.keepSubmitCount
7364
7482
  ? _formState.submitCount
@@ -7396,7 +7514,7 @@ function createFormControl(props = {}) {
7396
7514
  };
7397
7515
  const reset = (formValues, keepStateOptions) => _reset(isFunction$3(formValues)
7398
7516
  ? formValues(_formValues)
7399
- : formValues, keepStateOptions);
7517
+ : formValues, { ..._options.resetOptions, ...keepStateOptions });
7400
7518
  const setFocus = (name, options = {}) => {
7401
7519
  const field = get$1(_fields, name);
7402
7520
  const fieldReference = field && field._f;
@@ -7405,10 +7523,14 @@ function createFormControl(props = {}) {
7405
7523
  ? fieldReference.refs[0]
7406
7524
  : fieldReference.ref;
7407
7525
  if (fieldRef.focus) {
7408
- fieldRef.focus();
7409
- options.shouldSelect &&
7410
- isFunction$3(fieldRef.select) &&
7411
- fieldRef.select();
7526
+ // Use setTimeout to ensure focus happens after any pending state updates
7527
+ // This fixes the issue where setFocus doesn't work immediately after setError
7528
+ setTimeout(() => {
7529
+ fieldRef.focus();
7530
+ options.shouldSelect &&
7531
+ isFunction$3(fieldRef.select) &&
7532
+ fieldRef.select();
7533
+ });
7412
7534
  }
7413
7535
  }
7414
7536
  };
@@ -7434,6 +7556,7 @@ function createFormControl(props = {}) {
7434
7556
  setError,
7435
7557
  _subscribe,
7436
7558
  _runSchema,
7559
+ _updateIsValidating,
7437
7560
  _focusError,
7438
7561
  _getWatch,
7439
7562
  _getDirty,
@@ -7646,7 +7769,7 @@ function useForm(props = {}) {
7646
7769
  }
7647
7770
  control._removeUnmounted();
7648
7771
  });
7649
- _formControl.current.formState = getProxyFormState(formState, control);
7772
+ _formControl.current.formState = React__default.useMemo(() => getProxyFormState(formState, control), [control, formState]);
7650
7773
  return _formControl.current;
7651
7774
  }
7652
7775
 
@@ -18701,6 +18824,10 @@ var isSet = (target) => target instanceof Set;
18701
18824
  var isObjectish = (target) => typeof target === "object";
18702
18825
  var isFunction$2 = (target) => typeof target === "function";
18703
18826
  var isBoolean$2 = (target) => typeof target === "boolean";
18827
+ function isArrayIndex(value) {
18828
+ const n = +value;
18829
+ return Number.isInteger(n) && String(n) === value;
18830
+ }
18704
18831
  var latest = (state) => state.copy_ || state.base_;
18705
18832
  var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
18706
18833
  function shallowCopy(base, strict) {
@@ -18780,6 +18907,7 @@ function isFrozen(obj) {
18780
18907
  // src/utils/plugins.ts
18781
18908
  var PluginMapSet = "MapSet";
18782
18909
  var PluginPatches = "Patches";
18910
+ var PluginArrayMethods = "ArrayMethods";
18783
18911
  var plugins = {};
18784
18912
  function getPlugin(pluginKey) {
18785
18913
  const plugin = plugins[pluginKey];
@@ -18803,7 +18931,8 @@ var createScope = (parent_, immer_) => ({
18803
18931
  unfinalizedDrafts_: 0,
18804
18932
  handledSet_: /* @__PURE__ */ new Set(),
18805
18933
  processedForPatches_: /* @__PURE__ */ new Set(),
18806
- mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0
18934
+ mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
18935
+ arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
18807
18936
  });
18808
18937
  function usePatchesInScope(scope, patchListener) {
18809
18938
  if (patchListener) {
@@ -18938,7 +19067,7 @@ function registerChildFinalizationCallback(parent, child, key) {
18938
19067
  });
18939
19068
  }
18940
19069
  function generatePatchesAndFinalize(state, rootScope) {
18941
- const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 /* Set */ || (state.assigned_?.size ?? 0) > 0);
19070
+ const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 /* Set */ || state.type_ === 1 /* Array */ && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
18942
19071
  if (shouldFinalize) {
18943
19072
  const { patchPlugin_ } = rootScope;
18944
19073
  if (patchPlugin_) {
@@ -18964,13 +19093,19 @@ function handleCrossReference(target, key, value) {
18964
19093
  } else if (isDraftable(value)) {
18965
19094
  target.callbacks_.push(function nestedDraftCleanup() {
18966
19095
  const targetCopy = latest(target);
18967
- if (get(targetCopy, key, target.type_) === value) {
18968
- if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
18969
- handleValue(
18970
- get(target.copy_, key, target.type_),
18971
- scope_.handledSet_,
18972
- scope_
18973
- );
19096
+ if (target.type_ === 3 /* Set */) {
19097
+ if (targetCopy.has(value)) {
19098
+ handleValue(value, scope_.handledSet_, scope_);
19099
+ }
19100
+ } else {
19101
+ if (get(targetCopy, key, target.type_) === value) {
19102
+ if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
19103
+ handleValue(
19104
+ get(target.copy_, key, target.type_),
19105
+ scope_.handledSet_,
19106
+ scope_
19107
+ );
19108
+ }
18974
19109
  }
18975
19110
  }
18976
19111
  });
@@ -19043,6 +19178,13 @@ var objectTraps = {
19043
19178
  get(state, prop) {
19044
19179
  if (prop === DRAFT_STATE)
19045
19180
  return state;
19181
+ let arrayPlugin = state.scope_.arrayMethodsPlugin_;
19182
+ const isArrayWithStringProp = state.type_ === 1 /* Array */ && typeof prop === "string";
19183
+ if (isArrayWithStringProp) {
19184
+ if (arrayPlugin?.isArrayOperationMethod(prop)) {
19185
+ return arrayPlugin.createMethodInterceptor(state, prop);
19186
+ }
19187
+ }
19046
19188
  const source = latest(state);
19047
19189
  if (!has(source, prop, state.type_)) {
19048
19190
  return readPropFromProto(state, source, prop);
@@ -19051,6 +19193,11 @@ var objectTraps = {
19051
19193
  if (state.finalized_ || !isDraftable(value)) {
19052
19194
  return value;
19053
19195
  }
19196
+ if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
19197
+ state.operationMethod
19198
+ ) && isArrayIndex(prop)) {
19199
+ return value;
19200
+ }
19054
19201
  if (value === peek(state.base_, prop)) {
19055
19202
  prepareCopy(state);
19056
19203
  const childKey = state.type_ === 1 /* Array */ ? +prop : prop;
@@ -19131,13 +19278,14 @@ var objectTraps = {
19131
19278
  }
19132
19279
  };
19133
19280
  var arrayTraps = {};
19134
- each(objectTraps, (key, fn) => {
19281
+ for (let key in objectTraps) {
19282
+ let fn = objectTraps[key];
19135
19283
  arrayTraps[key] = function() {
19136
19284
  const args = arguments;
19137
19285
  args[0] = args[0][0];
19138
19286
  return fn.apply(this, args);
19139
19287
  };
19140
- });
19288
+ }
19141
19289
  arrayTraps.deleteProperty = function(state, prop) {
19142
19290
  if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
19143
19291
  die(13);
@@ -20441,29 +20589,11 @@ var addAbortSignalListener = (abortSignal, callback) => {
20441
20589
  });
20442
20590
  return () => abortSignal.removeEventListener("abort", callback);
20443
20591
  };
20444
- var abortControllerWithReason = (abortController, reason) => {
20445
- const signal = abortController.signal;
20446
- if (signal.aborted) {
20447
- return;
20448
- }
20449
- if (!("reason" in signal)) {
20450
- Object.defineProperty(signal, "reason", {
20451
- enumerable: true,
20452
- value: reason,
20453
- configurable: true,
20454
- writable: true
20455
- });
20456
- }
20457
- abortController.abort(reason);
20458
- };
20459
20592
 
20460
20593
  // src/listenerMiddleware/task.ts
20461
20594
  var validateActive = (signal) => {
20462
20595
  if (signal.aborted) {
20463
- const {
20464
- reason
20465
- } = signal;
20466
- throw new TaskAbortError(reason);
20596
+ throw new TaskAbortError(signal.reason);
20467
20597
  }
20468
20598
  };
20469
20599
  function raceWithSignal(signal, promise) {
@@ -20519,7 +20649,7 @@ var {
20519
20649
  var INTERNAL_NIL_TOKEN = {};
20520
20650
  var alm = "listenerMiddleware";
20521
20651
  var createFork = (parentAbortSignal, parentBlockingPromises) => {
20522
- const linkControllers = (controller) => addAbortSignalListener(parentAbortSignal, () => abortControllerWithReason(controller, parentAbortSignal.reason));
20652
+ const linkControllers = (controller) => addAbortSignalListener(parentAbortSignal, () => controller.abort(parentAbortSignal.reason));
20523
20653
  return (taskExecutor, opts) => {
20524
20654
  assertFunction(taskExecutor, "taskExecutor");
20525
20655
  const childAbortController = new AbortController();
@@ -20534,14 +20664,14 @@ var createFork = (parentAbortSignal, parentBlockingPromises) => {
20534
20664
  });
20535
20665
  validateActive(childAbortController.signal);
20536
20666
  return result2;
20537
- }, () => abortControllerWithReason(childAbortController, taskCompleted));
20667
+ }, () => childAbortController.abort(taskCompleted));
20538
20668
  if (opts?.autoJoin) {
20539
20669
  parentBlockingPromises.push(result.catch(noop2));
20540
20670
  }
20541
20671
  return {
20542
20672
  result: createPause(parentAbortSignal)(result),
20543
20673
  cancel() {
20544
- abortControllerWithReason(childAbortController, taskCancelled);
20674
+ childAbortController.abort(taskCancelled);
20545
20675
  }
20546
20676
  };
20547
20677
  };
@@ -20636,7 +20766,7 @@ var findListenerEntry = (listenerMap, options) => {
20636
20766
  };
20637
20767
  var cancelActiveListeners = (entry) => {
20638
20768
  entry.pending.forEach((controller) => {
20639
- abortControllerWithReason(controller, listenerCancelled);
20769
+ controller.abort(listenerCancelled);
20640
20770
  });
20641
20771
  };
20642
20772
  var createClearListenerMiddleware = (listenerMap, executingListeners) => {
@@ -20742,13 +20872,13 @@ var createListenerMiddleware = (middlewareOptions = {}) => {
20742
20872
  cancelActiveListeners: () => {
20743
20873
  entry.pending.forEach((controller, _, set) => {
20744
20874
  if (controller !== internalTaskController) {
20745
- abortControllerWithReason(controller, listenerCancelled);
20875
+ controller.abort(listenerCancelled);
20746
20876
  set.delete(controller);
20747
20877
  }
20748
20878
  });
20749
20879
  },
20750
20880
  cancel: () => {
20751
- abortControllerWithReason(internalTaskController, listenerCancelled);
20881
+ internalTaskController.abort(listenerCancelled);
20752
20882
  entry.pending.delete(internalTaskController);
20753
20883
  },
20754
20884
  throwIfCancelled: () => {
@@ -20764,7 +20894,7 @@ var createListenerMiddleware = (middlewareOptions = {}) => {
20764
20894
  }
20765
20895
  } finally {
20766
20896
  await Promise.all(autoJoinPromises);
20767
- abortControllerWithReason(internalTaskController, listenerCompleted);
20897
+ internalTaskController.abort(listenerCompleted);
20768
20898
  untrackExecutingListener(entry);
20769
20899
  entry.pending.delete(internalTaskController);
20770
20900
  }