@bigbinary/neeto-team-members-frontend 2.4.13 → 2.4.14

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,7 +1,8 @@
1
1
  import React, { createContext, useContext, createElement, isValidElement, cloneElement, useState, useRef, useEffect, useMemo, useCallback, useLayoutEffect } from 'react';
2
2
  import { complement, isEmpty, modifyPath, prepend, assocPath, findIndex, propEq, dissocPath, groupBy, is, prop, keys, map, identical, modify, includes, pluck, fromPairs, toPairs, filter, isNil, curry, __, trim, toLower, identity, without, append, clamp, mergeLeft, head, reverse, assoc } from 'ramda';
3
- import { ExternalLink, MenuHorizontal, Up, Down, Search, Info } from '@bigbinary/neeto-icons';
4
- import ReactDOM from 'react-dom';
3
+ import { ExternalLink, MenuHorizontal, Up, Down, Search, Right as Right$1, Info } from '@bigbinary/neeto-icons';
4
+ import { QueryClient, QueryCache, QueryClientProvider, useQuery, useMutation } from 'react-query';
5
+ import { ReactQueryDevtools } from 'react-query/devtools';
5
6
  import axios from 'axios';
6
7
  import { Toastr, Tooltip, Button, Typography, Checkbox, Pane, Dropdown, Alert, Input as Input$1, PageLoader, Label, Avatar, Tag, Table as Table$1 } from '@bigbinary/neetoui';
7
8
  import { Header as Header$2, Container, MenuBar, SubHeader as SubHeader$1 } from '@bigbinary/neetoui/layouts';
@@ -2358,7 +2359,7 @@ function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeRefl
2358
2359
 
2359
2360
  function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2360
2361
 
2361
- function noop$2() {}
2362
+ function noop$1() {}
2362
2363
 
2363
2364
  function bindMemberFunctions(inst) {
2364
2365
  var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
@@ -2523,7 +2524,7 @@ var I18n = function (_EventEmitter) {
2523
2524
  }
2524
2525
 
2525
2526
  this.format = this.options.interpolation.format;
2526
- if (!callback) callback = noop$2;
2527
+ if (!callback) callback = noop$1;
2527
2528
 
2528
2529
  if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
2529
2530
  var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
@@ -2584,7 +2585,7 @@ var I18n = function (_EventEmitter) {
2584
2585
  value: function loadResources(language) {
2585
2586
  var _this3 = this;
2586
2587
 
2587
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2588
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2588
2589
  var usedCallback = callback;
2589
2590
  var usedLng = typeof language === 'string' ? language : this.language;
2590
2591
  if (typeof language === 'function') usedCallback = language;
@@ -2632,7 +2633,7 @@ var I18n = function (_EventEmitter) {
2632
2633
  var deferred = defer();
2633
2634
  if (!lngs) lngs = this.languages;
2634
2635
  if (!ns) ns = this.options.ns;
2635
- if (!callback) callback = noop$2;
2636
+ if (!callback) callback = noop$1;
2636
2637
  this.services.backendConnector.reload(lngs, ns, function (err) {
2637
2638
  deferred.resolve();
2638
2639
  callback(err);
@@ -2911,7 +2912,7 @@ var I18n = function (_EventEmitter) {
2911
2912
  var _this8 = this;
2912
2913
 
2913
2914
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2914
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2915
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2915
2916
 
2916
2917
  var mergedOptions = _objectSpread$6$1(_objectSpread$6$1(_objectSpread$6$1({}, this.options), options), {
2917
2918
  isClone: true
@@ -4017,7 +4018,8 @@ var common$1 = {
4017
4018
  role_one: "Role",
4018
4019
  role_other: "Roles",
4019
4020
  search_: "Search {{what}}",
4020
- update_: "Update {{what}}"
4021
+ update_: "Update {{what}}",
4022
+ takeAction: "Take action"
4021
4023
  };
4022
4024
  var helpers$1 = {
4023
4025
  configPermissions: "Configure permissions for the modules.",
@@ -4025,7 +4027,7 @@ var helpers$1 = {
4025
4027
  moreInfoAboutPermissions: "More information about permissions",
4026
4028
  noRolesFound: "No roles found.",
4027
4029
  searchRoles: "Search roles",
4028
- selectedMembersCount: "{{count}} {{metaName}} selected from {{totalCount}}",
4030
+ selectedMembersCount: "{{count}} {{metaName}} selected of",
4029
4031
  visitToKnowMoreAboutPermissions: "Visit to know more about permissions"
4030
4032
  };
4031
4033
  var metaNames$1 = {
@@ -4114,7 +4116,8 @@ var common = {
4114
4116
  role_one: "Rôle",
4115
4117
  role_other: "Rôles",
4116
4118
  search_: "Rechercher des {{what}}",
4117
- update_: "Mettre à jour le {{what}}"
4119
+ update_: "Mettre à jour le {{what}}",
4120
+ takeAction: "Passer à l'action"
4118
4121
  };
4119
4122
  var helpers = {
4120
4123
  configPermissions: "Configurez les autorisations pour les modules.",
@@ -4122,8 +4125,8 @@ var helpers = {
4122
4125
  moreInfoAboutPermissions: "Plus d'informations sur les autorisations",
4123
4126
  noRolesFound: "Aucun rôle trouvé.",
4124
4127
  searchRoles: "Rechercher des rôles",
4125
- selectedMembersCount_one: "{{count}} {{metaName}} sélectionné parmi {{totalCount}}",
4126
- selectedMembersCount_other: "{{count}} {{metaName}} sélectionnés parmi {{totalCount}}",
4128
+ selectedMembersCount_one: "{{count}} {{metaName}} sélectionné sur",
4129
+ selectedMembersCount_other: "{{count}} {{metaName}} sélectionnés sur",
4127
4130
  visitToKnowMoreAboutPermissions: "Visitez pour en savoir plus sur les autorisations"
4128
4131
  };
4129
4132
  var metaNames = {
@@ -4214,7 +4217,7 @@ const getScrollBarWidth = () => {
4214
4217
  document.body.removeChild(outerElement);
4215
4218
  return w1 - w2;
4216
4219
  };
4217
- const noop$1 = () => {};
4220
+ const noop = () => {};
4218
4221
  const slugify = string => string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
4219
4222
  .replace(/&/g, "-and-") // Replace & with 'and'
4220
4223
  .replace(/[^\w-]+/g, "") // Remove all non-word characters
@@ -4235,3202 +4238,14 @@ const PLURAL = {
4235
4238
  const MANAGE_MEMBER_PERMISSIONS = ["members.manage_members", "agents.manage_agents"];
4236
4239
  const DEFAULT_PERMISSION = true; // Until we add permission prop to all neeto apps, this is the default permission.
4237
4240
 
4238
- function _inheritsLoose(subClass, superClass) {
4239
- subClass.prototype = Object.create(superClass.prototype);
4240
- subClass.prototype.constructor = subClass;
4241
- _setPrototypeOf(subClass, superClass);
4242
- }
4243
-
4244
- var Subscribable = /*#__PURE__*/function () {
4245
- function Subscribable() {
4246
- this.listeners = [];
4247
- }
4248
-
4249
- var _proto = Subscribable.prototype;
4250
-
4251
- _proto.subscribe = function subscribe(listener) {
4252
- var _this = this;
4253
-
4254
- var callback = listener || function () {
4255
- return undefined;
4256
- };
4257
-
4258
- this.listeners.push(callback);
4259
- this.onSubscribe();
4260
- return function () {
4261
- _this.listeners = _this.listeners.filter(function (x) {
4262
- return x !== callback;
4263
- });
4264
-
4265
- _this.onUnsubscribe();
4266
- };
4267
- };
4268
-
4269
- _proto.hasListeners = function hasListeners() {
4270
- return this.listeners.length > 0;
4271
- };
4272
-
4273
- _proto.onSubscribe = function onSubscribe() {// Do nothing
4274
- };
4275
-
4276
- _proto.onUnsubscribe = function onUnsubscribe() {// Do nothing
4277
- };
4278
-
4279
- return Subscribable;
4280
- }();
4281
-
4282
- function _extends() {
4283
- _extends = Object.assign ? Object.assign.bind() : function (target) {
4284
- for (var i = 1; i < arguments.length; i++) {
4285
- var source = arguments[i];
4286
- for (var key in source) {
4287
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4288
- target[key] = source[key];
4289
- }
4290
- }
4291
- }
4292
- return target;
4293
- };
4294
- return _extends.apply(this, arguments);
4295
- }
4296
-
4297
- // TYPES
4298
- // UTILS
4299
- var isServer = typeof window === 'undefined';
4300
- function noop() {
4301
- return undefined;
4302
- }
4303
- function functionalUpdate(updater, input) {
4304
- return typeof updater === 'function' ? updater(input) : updater;
4305
- }
4306
- function isValidTimeout(value) {
4307
- return typeof value === 'number' && value >= 0 && value !== Infinity;
4308
- }
4309
- function ensureQueryKeyArray(value) {
4310
- return Array.isArray(value) ? value : [value];
4311
- }
4312
- function timeUntilStale(updatedAt, staleTime) {
4313
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
4314
- }
4315
- function parseQueryArgs(arg1, arg2, arg3) {
4316
- if (!isQueryKey(arg1)) {
4317
- return arg1;
4318
- }
4319
-
4320
- if (typeof arg2 === 'function') {
4321
- return _extends({}, arg3, {
4322
- queryKey: arg1,
4323
- queryFn: arg2
4324
- });
4325
- }
4326
-
4327
- return _extends({}, arg2, {
4328
- queryKey: arg1
4329
- });
4330
- }
4331
- function parseMutationArgs(arg1, arg2, arg3) {
4332
- if (isQueryKey(arg1)) {
4333
- if (typeof arg2 === 'function') {
4334
- return _extends({}, arg3, {
4335
- mutationKey: arg1,
4336
- mutationFn: arg2
4337
- });
4338
- }
4339
-
4340
- return _extends({}, arg2, {
4341
- mutationKey: arg1
4342
- });
4343
- }
4344
-
4345
- if (typeof arg1 === 'function') {
4346
- return _extends({}, arg2, {
4347
- mutationFn: arg1
4348
- });
4349
- }
4350
-
4351
- return _extends({}, arg1);
4352
- }
4353
- function parseFilterArgs(arg1, arg2, arg3) {
4354
- return isQueryKey(arg1) ? [_extends({}, arg2, {
4355
- queryKey: arg1
4356
- }), arg3] : [arg1 || {}, arg2];
4357
- }
4358
- function mapQueryStatusFilter(active, inactive) {
4359
- if (active === true && inactive === true || active == null && inactive == null) {
4360
- return 'all';
4361
- } else if (active === false && inactive === false) {
4362
- return 'none';
4363
- } else {
4364
- // At this point, active|inactive can only be true|false or false|true
4365
- // so, when only one value is provided, the missing one has to be the negated value
4366
- var isActive = active != null ? active : !inactive;
4367
- return isActive ? 'active' : 'inactive';
4368
- }
4369
- }
4370
- function matchQuery(filters, query) {
4371
- var active = filters.active,
4372
- exact = filters.exact,
4373
- fetching = filters.fetching,
4374
- inactive = filters.inactive,
4375
- predicate = filters.predicate,
4376
- queryKey = filters.queryKey,
4377
- stale = filters.stale;
4378
-
4379
- if (isQueryKey(queryKey)) {
4380
- if (exact) {
4381
- if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
4382
- return false;
4383
- }
4384
- } else if (!partialMatchKey(query.queryKey, queryKey)) {
4385
- return false;
4386
- }
4387
- }
4388
-
4389
- var queryStatusFilter = mapQueryStatusFilter(active, inactive);
4390
-
4391
- if (queryStatusFilter === 'none') {
4392
- return false;
4393
- } else if (queryStatusFilter !== 'all') {
4394
- var isActive = query.isActive();
4395
-
4396
- if (queryStatusFilter === 'active' && !isActive) {
4397
- return false;
4398
- }
4399
-
4400
- if (queryStatusFilter === 'inactive' && isActive) {
4401
- return false;
4402
- }
4403
- }
4404
-
4405
- if (typeof stale === 'boolean' && query.isStale() !== stale) {
4406
- return false;
4407
- }
4408
-
4409
- if (typeof fetching === 'boolean' && query.isFetching() !== fetching) {
4410
- return false;
4411
- }
4412
-
4413
- if (predicate && !predicate(query)) {
4414
- return false;
4415
- }
4416
-
4417
- return true;
4418
- }
4419
- function matchMutation(filters, mutation) {
4420
- var exact = filters.exact,
4421
- fetching = filters.fetching,
4422
- predicate = filters.predicate,
4423
- mutationKey = filters.mutationKey;
4424
-
4425
- if (isQueryKey(mutationKey)) {
4426
- if (!mutation.options.mutationKey) {
4427
- return false;
4428
- }
4429
-
4430
- if (exact) {
4431
- if (hashQueryKey(mutation.options.mutationKey) !== hashQueryKey(mutationKey)) {
4432
- return false;
4433
- }
4434
- } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
4435
- return false;
4436
- }
4437
- }
4438
-
4439
- if (typeof fetching === 'boolean' && mutation.state.status === 'loading' !== fetching) {
4440
- return false;
4441
- }
4442
-
4443
- if (predicate && !predicate(mutation)) {
4444
- return false;
4445
- }
4446
-
4447
- return true;
4448
- }
4449
- function hashQueryKeyByOptions(queryKey, options) {
4450
- var hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashQueryKey;
4451
- return hashFn(queryKey);
4452
- }
4453
- /**
4454
- * Default query keys hash function.
4455
- */
4456
-
4457
- function hashQueryKey(queryKey) {
4458
- var asArray = ensureQueryKeyArray(queryKey);
4459
- return stableValueHash(asArray);
4460
- }
4461
- /**
4462
- * Hashes the value into a stable hash.
4463
- */
4464
-
4465
- function stableValueHash(value) {
4466
- return JSON.stringify(value, function (_, val) {
4467
- return isPlainObject(val) ? Object.keys(val).sort().reduce(function (result, key) {
4468
- result[key] = val[key];
4469
- return result;
4470
- }, {}) : val;
4471
- });
4472
- }
4473
- /**
4474
- * Checks if key `b` partially matches with key `a`.
4475
- */
4476
-
4477
- function partialMatchKey(a, b) {
4478
- return partialDeepEqual(ensureQueryKeyArray(a), ensureQueryKeyArray(b));
4479
- }
4480
- /**
4481
- * Checks if `b` partially matches with `a`.
4482
- */
4483
-
4484
- function partialDeepEqual(a, b) {
4485
- if (a === b) {
4486
- return true;
4487
- }
4488
-
4489
- if (typeof a !== typeof b) {
4490
- return false;
4491
- }
4492
-
4493
- if (a && b && typeof a === 'object' && typeof b === 'object') {
4494
- return !Object.keys(b).some(function (key) {
4495
- return !partialDeepEqual(a[key], b[key]);
4496
- });
4497
- }
4498
-
4499
- return false;
4500
- }
4501
- /**
4502
- * This function returns `a` if `b` is deeply equal.
4503
- * If not, it will replace any deeply equal children of `b` with those of `a`.
4504
- * This can be used for structural sharing between JSON values for example.
4505
- */
4506
-
4507
- function replaceEqualDeep(a, b) {
4508
- if (a === b) {
4509
- return a;
4510
- }
4511
-
4512
- var array = Array.isArray(a) && Array.isArray(b);
4513
-
4514
- if (array || isPlainObject(a) && isPlainObject(b)) {
4515
- var aSize = array ? a.length : Object.keys(a).length;
4516
- var bItems = array ? b : Object.keys(b);
4517
- var bSize = bItems.length;
4518
- var copy = array ? [] : {};
4519
- var equalItems = 0;
4520
-
4521
- for (var i = 0; i < bSize; i++) {
4522
- var key = array ? i : bItems[i];
4523
- copy[key] = replaceEqualDeep(a[key], b[key]);
4524
-
4525
- if (copy[key] === a[key]) {
4526
- equalItems++;
4527
- }
4528
- }
4529
-
4530
- return aSize === bSize && equalItems === aSize ? a : copy;
4531
- }
4532
-
4533
- return b;
4534
- }
4535
- /**
4536
- * Shallow compare objects. Only works with objects that always have the same properties.
4537
- */
4538
-
4539
- function shallowEqualObjects(a, b) {
4540
- if (a && !b || b && !a) {
4541
- return false;
4542
- }
4543
-
4544
- for (var key in a) {
4545
- if (a[key] !== b[key]) {
4546
- return false;
4547
- }
4548
- }
4549
-
4550
- return true;
4551
- } // Copied from: https://github.com/jonschlinkert/is-plain-object
4552
-
4553
- function isPlainObject(o) {
4554
- if (!hasObjectPrototype(o)) {
4555
- return false;
4556
- } // If has modified constructor
4557
-
4558
-
4559
- var ctor = o.constructor;
4560
-
4561
- if (typeof ctor === 'undefined') {
4562
- return true;
4563
- } // If has modified prototype
4564
-
4565
-
4566
- var prot = ctor.prototype;
4567
-
4568
- if (!hasObjectPrototype(prot)) {
4569
- return false;
4570
- } // If constructor does not have an Object-specific method
4571
-
4572
-
4573
- if (!prot.hasOwnProperty('isPrototypeOf')) {
4574
- return false;
4575
- } // Most likely a plain Object
4576
-
4577
-
4578
- return true;
4579
- }
4580
-
4581
- function hasObjectPrototype(o) {
4582
- return Object.prototype.toString.call(o) === '[object Object]';
4583
- }
4584
-
4585
- function isQueryKey(value) {
4586
- return typeof value === 'string' || Array.isArray(value);
4587
- }
4588
- function sleep(timeout) {
4589
- return new Promise(function (resolve) {
4590
- setTimeout(resolve, timeout);
4591
- });
4592
- }
4593
- /**
4594
- * Schedules a microtask.
4595
- * This can be useful to schedule state updates after rendering.
4596
- */
4597
-
4598
- function scheduleMicrotask(callback) {
4599
- Promise.resolve().then(callback).catch(function (error) {
4600
- return setTimeout(function () {
4601
- throw error;
4602
- });
4603
- });
4604
- }
4605
- function getAbortController() {
4606
- if (typeof AbortController === 'function') {
4607
- return new AbortController();
4608
- }
4609
- }
4610
-
4611
- var FocusManager = /*#__PURE__*/function (_Subscribable) {
4612
- _inheritsLoose(FocusManager, _Subscribable);
4613
-
4614
- function FocusManager() {
4615
- var _this;
4616
-
4617
- _this = _Subscribable.call(this) || this;
4618
-
4619
- _this.setup = function (onFocus) {
4620
- var _window;
4621
-
4622
- if (!isServer && ((_window = window) == null ? void 0 : _window.addEventListener)) {
4623
- var listener = function listener() {
4624
- return onFocus();
4625
- }; // Listen to visibillitychange and focus
4626
-
4627
-
4628
- window.addEventListener('visibilitychange', listener, false);
4629
- window.addEventListener('focus', listener, false);
4630
- return function () {
4631
- // Be sure to unsubscribe if a new handler is set
4632
- window.removeEventListener('visibilitychange', listener);
4633
- window.removeEventListener('focus', listener);
4634
- };
4635
- }
4636
- };
4637
-
4638
- return _this;
4639
- }
4640
-
4641
- var _proto = FocusManager.prototype;
4642
-
4643
- _proto.onSubscribe = function onSubscribe() {
4644
- if (!this.cleanup) {
4645
- this.setEventListener(this.setup);
4646
- }
4647
- };
4648
-
4649
- _proto.onUnsubscribe = function onUnsubscribe() {
4650
- if (!this.hasListeners()) {
4651
- var _this$cleanup;
4652
-
4653
- (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
4654
- this.cleanup = undefined;
4655
- }
4656
- };
4657
-
4658
- _proto.setEventListener = function setEventListener(setup) {
4659
- var _this$cleanup2,
4660
- _this2 = this;
4661
-
4662
- this.setup = setup;
4663
- (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
4664
- this.cleanup = setup(function (focused) {
4665
- if (typeof focused === 'boolean') {
4666
- _this2.setFocused(focused);
4667
- } else {
4668
- _this2.onFocus();
4669
- }
4670
- });
4671
- };
4672
-
4673
- _proto.setFocused = function setFocused(focused) {
4674
- this.focused = focused;
4675
-
4676
- if (focused) {
4677
- this.onFocus();
4678
- }
4679
- };
4680
-
4681
- _proto.onFocus = function onFocus() {
4682
- this.listeners.forEach(function (listener) {
4683
- listener();
4684
- });
4685
- };
4686
-
4687
- _proto.isFocused = function isFocused() {
4688
- if (typeof this.focused === 'boolean') {
4689
- return this.focused;
4690
- } // document global can be unavailable in react native
4691
-
4692
-
4693
- if (typeof document === 'undefined') {
4694
- return true;
4695
- }
4696
-
4697
- return [undefined, 'visible', 'prerender'].includes(document.visibilityState);
4698
- };
4699
-
4700
- return FocusManager;
4701
- }(Subscribable);
4702
- var focusManager = new FocusManager();
4703
-
4704
- var OnlineManager = /*#__PURE__*/function (_Subscribable) {
4705
- _inheritsLoose(OnlineManager, _Subscribable);
4706
-
4707
- function OnlineManager() {
4708
- var _this;
4709
-
4710
- _this = _Subscribable.call(this) || this;
4711
-
4712
- _this.setup = function (onOnline) {
4713
- var _window;
4714
-
4715
- if (!isServer && ((_window = window) == null ? void 0 : _window.addEventListener)) {
4716
- var listener = function listener() {
4717
- return onOnline();
4718
- }; // Listen to online
4719
-
4720
-
4721
- window.addEventListener('online', listener, false);
4722
- window.addEventListener('offline', listener, false);
4723
- return function () {
4724
- // Be sure to unsubscribe if a new handler is set
4725
- window.removeEventListener('online', listener);
4726
- window.removeEventListener('offline', listener);
4727
- };
4728
- }
4729
- };
4730
-
4731
- return _this;
4732
- }
4733
-
4734
- var _proto = OnlineManager.prototype;
4735
-
4736
- _proto.onSubscribe = function onSubscribe() {
4737
- if (!this.cleanup) {
4738
- this.setEventListener(this.setup);
4739
- }
4740
- };
4741
-
4742
- _proto.onUnsubscribe = function onUnsubscribe() {
4743
- if (!this.hasListeners()) {
4744
- var _this$cleanup;
4745
-
4746
- (_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
4747
- this.cleanup = undefined;
4748
- }
4749
- };
4750
-
4751
- _proto.setEventListener = function setEventListener(setup) {
4752
- var _this$cleanup2,
4753
- _this2 = this;
4754
-
4755
- this.setup = setup;
4756
- (_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
4757
- this.cleanup = setup(function (online) {
4758
- if (typeof online === 'boolean') {
4759
- _this2.setOnline(online);
4760
- } else {
4761
- _this2.onOnline();
4762
- }
4763
- });
4764
- };
4765
-
4766
- _proto.setOnline = function setOnline(online) {
4767
- this.online = online;
4768
-
4769
- if (online) {
4770
- this.onOnline();
4771
- }
4772
- };
4773
-
4774
- _proto.onOnline = function onOnline() {
4775
- this.listeners.forEach(function (listener) {
4776
- listener();
4777
- });
4778
- };
4779
-
4780
- _proto.isOnline = function isOnline() {
4781
- if (typeof this.online === 'boolean') {
4782
- return this.online;
4783
- }
4784
-
4785
- if (typeof navigator === 'undefined' || typeof navigator.onLine === 'undefined') {
4786
- return true;
4787
- }
4788
-
4789
- return navigator.onLine;
4790
- };
4791
-
4792
- return OnlineManager;
4793
- }(Subscribable);
4794
- var onlineManager = new OnlineManager();
4795
-
4796
- function defaultRetryDelay(failureCount) {
4797
- return Math.min(1000 * Math.pow(2, failureCount), 30000);
4798
- }
4799
-
4800
- function isCancelable(value) {
4801
- return typeof (value == null ? void 0 : value.cancel) === 'function';
4802
- }
4803
- var CancelledError = function CancelledError(options) {
4804
- this.revert = options == null ? void 0 : options.revert;
4805
- this.silent = options == null ? void 0 : options.silent;
4806
- };
4807
- function isCancelledError(value) {
4808
- return value instanceof CancelledError;
4809
- } // CLASS
4810
-
4811
- var Retryer = function Retryer(config) {
4812
- var _this = this;
4813
-
4814
- var cancelRetry = false;
4815
- var cancelFn;
4816
- var continueFn;
4817
- var promiseResolve;
4818
- var promiseReject;
4819
- this.abort = config.abort;
4820
-
4821
- this.cancel = function (cancelOptions) {
4822
- return cancelFn == null ? void 0 : cancelFn(cancelOptions);
4823
- };
4824
-
4825
- this.cancelRetry = function () {
4826
- cancelRetry = true;
4827
- };
4828
-
4829
- this.continueRetry = function () {
4830
- cancelRetry = false;
4831
- };
4832
-
4833
- this.continue = function () {
4834
- return continueFn == null ? void 0 : continueFn();
4835
- };
4836
-
4837
- this.failureCount = 0;
4838
- this.isPaused = false;
4839
- this.isResolved = false;
4840
- this.isTransportCancelable = false;
4841
- this.promise = new Promise(function (outerResolve, outerReject) {
4842
- promiseResolve = outerResolve;
4843
- promiseReject = outerReject;
4844
- });
4845
-
4846
- var resolve = function resolve(value) {
4847
- if (!_this.isResolved) {
4848
- _this.isResolved = true;
4849
- config.onSuccess == null ? void 0 : config.onSuccess(value);
4850
- continueFn == null ? void 0 : continueFn();
4851
- promiseResolve(value);
4852
- }
4853
- };
4854
-
4855
- var reject = function reject(value) {
4856
- if (!_this.isResolved) {
4857
- _this.isResolved = true;
4858
- config.onError == null ? void 0 : config.onError(value);
4859
- continueFn == null ? void 0 : continueFn();
4860
- promiseReject(value);
4861
- }
4862
- };
4863
-
4864
- var pause = function pause() {
4865
- return new Promise(function (continueResolve) {
4866
- continueFn = continueResolve;
4867
- _this.isPaused = true;
4868
- config.onPause == null ? void 0 : config.onPause();
4869
- }).then(function () {
4870
- continueFn = undefined;
4871
- _this.isPaused = false;
4872
- config.onContinue == null ? void 0 : config.onContinue();
4873
- });
4874
- }; // Create loop function
4875
-
4876
-
4877
- var run = function run() {
4878
- // Do nothing if already resolved
4879
- if (_this.isResolved) {
4880
- return;
4881
- }
4882
-
4883
- var promiseOrValue; // Execute query
4884
-
4885
- try {
4886
- promiseOrValue = config.fn();
4887
- } catch (error) {
4888
- promiseOrValue = Promise.reject(error);
4889
- } // Create callback to cancel this fetch
4890
-
4891
-
4892
- cancelFn = function cancelFn(cancelOptions) {
4893
- if (!_this.isResolved) {
4894
- reject(new CancelledError(cancelOptions));
4895
- _this.abort == null ? void 0 : _this.abort(); // Cancel transport if supported
4896
-
4897
- if (isCancelable(promiseOrValue)) {
4898
- try {
4899
- promiseOrValue.cancel();
4900
- } catch (_unused) {}
4901
- }
4902
- }
4903
- }; // Check if the transport layer support cancellation
4904
-
4905
-
4906
- _this.isTransportCancelable = isCancelable(promiseOrValue);
4907
- Promise.resolve(promiseOrValue).then(resolve).catch(function (error) {
4908
- var _config$retry, _config$retryDelay;
4909
-
4910
- // Stop if the fetch is already resolved
4911
- if (_this.isResolved) {
4912
- return;
4913
- } // Do we need to retry the request?
4914
-
4915
-
4916
- var retry = (_config$retry = config.retry) != null ? _config$retry : 3;
4917
- var retryDelay = (_config$retryDelay = config.retryDelay) != null ? _config$retryDelay : defaultRetryDelay;
4918
- var delay = typeof retryDelay === 'function' ? retryDelay(_this.failureCount, error) : retryDelay;
4919
- var shouldRetry = retry === true || typeof retry === 'number' && _this.failureCount < retry || typeof retry === 'function' && retry(_this.failureCount, error);
4920
-
4921
- if (cancelRetry || !shouldRetry) {
4922
- // We are done if the query does not need to be retried
4923
- reject(error);
4924
- return;
4925
- }
4926
-
4927
- _this.failureCount++; // Notify on fail
4928
-
4929
- config.onFail == null ? void 0 : config.onFail(_this.failureCount, error); // Delay
4930
-
4931
- sleep(delay) // Pause if the document is not visible or when the device is offline
4932
- .then(function () {
4933
- if (!focusManager.isFocused() || !onlineManager.isOnline()) {
4934
- return pause();
4935
- }
4936
- }).then(function () {
4937
- if (cancelRetry) {
4938
- reject(error);
4939
- } else {
4940
- run();
4941
- }
4942
- });
4943
- });
4944
- }; // Start loop
4945
-
4946
-
4947
- run();
4948
- };
4949
-
4950
- // CLASS
4951
- var NotifyManager = /*#__PURE__*/function () {
4952
- function NotifyManager() {
4953
- this.queue = [];
4954
- this.transactions = 0;
4955
-
4956
- this.notifyFn = function (callback) {
4957
- callback();
4958
- };
4959
-
4960
- this.batchNotifyFn = function (callback) {
4961
- callback();
4962
- };
4963
- }
4964
-
4965
- var _proto = NotifyManager.prototype;
4966
-
4967
- _proto.batch = function batch(callback) {
4968
- var result;
4969
- this.transactions++;
4970
-
4971
- try {
4972
- result = callback();
4973
- } finally {
4974
- this.transactions--;
4975
-
4976
- if (!this.transactions) {
4977
- this.flush();
4978
- }
4979
- }
4980
-
4981
- return result;
4982
- };
4983
-
4984
- _proto.schedule = function schedule(callback) {
4985
- var _this = this;
4986
-
4987
- if (this.transactions) {
4988
- this.queue.push(callback);
4989
- } else {
4990
- scheduleMicrotask(function () {
4991
- _this.notifyFn(callback);
4992
- });
4993
- }
4994
- }
4995
- /**
4996
- * All calls to the wrapped function will be batched.
4997
- */
4998
- ;
4999
-
5000
- _proto.batchCalls = function batchCalls(callback) {
5001
- var _this2 = this;
5002
-
5003
- return function () {
5004
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5005
- args[_key] = arguments[_key];
5006
- }
5007
-
5008
- _this2.schedule(function () {
5009
- callback.apply(void 0, args);
5010
- });
5011
- };
5012
- };
5013
-
5014
- _proto.flush = function flush() {
5015
- var _this3 = this;
5016
-
5017
- var queue = this.queue;
5018
- this.queue = [];
5019
-
5020
- if (queue.length) {
5021
- scheduleMicrotask(function () {
5022
- _this3.batchNotifyFn(function () {
5023
- queue.forEach(function (callback) {
5024
- _this3.notifyFn(callback);
5025
- });
5026
- });
5027
- });
5028
- }
5029
- }
5030
- /**
5031
- * Use this method to set a custom notify function.
5032
- * This can be used to for example wrap notifications with `React.act` while running tests.
5033
- */
5034
- ;
5035
-
5036
- _proto.setNotifyFunction = function setNotifyFunction(fn) {
5037
- this.notifyFn = fn;
5038
- }
5039
- /**
5040
- * Use this method to set a custom function to batch notifications together into a single tick.
5041
- * By default React Query will use the batch function provided by ReactDOM or React Native.
5042
- */
5043
- ;
5044
-
5045
- _proto.setBatchNotifyFunction = function setBatchNotifyFunction(fn) {
5046
- this.batchNotifyFn = fn;
5047
- };
5048
-
5049
- return NotifyManager;
5050
- }(); // SINGLETON
5051
-
5052
- var notifyManager = new NotifyManager();
5053
-
5054
- // TYPES
5055
- // FUNCTIONS
5056
- var logger$1 = console;
5057
- function getLogger() {
5058
- return logger$1;
5059
- }
5060
- function setLogger(newLogger) {
5061
- logger$1 = newLogger;
5062
- }
5063
-
5064
- // CLASS
5065
- var Query = /*#__PURE__*/function () {
5066
- function Query(config) {
5067
- this.abortSignalConsumed = false;
5068
- this.hadObservers = false;
5069
- this.defaultOptions = config.defaultOptions;
5070
- this.setOptions(config.options);
5071
- this.observers = [];
5072
- this.cache = config.cache;
5073
- this.queryKey = config.queryKey;
5074
- this.queryHash = config.queryHash;
5075
- this.initialState = config.state || this.getDefaultState(this.options);
5076
- this.state = this.initialState;
5077
- this.meta = config.meta;
5078
- this.scheduleGc();
5079
- }
5080
-
5081
- var _proto = Query.prototype;
5082
-
5083
- _proto.setOptions = function setOptions(options) {
5084
- var _this$options$cacheTi;
5085
-
5086
- this.options = _extends({}, this.defaultOptions, options);
5087
- this.meta = options == null ? void 0 : options.meta; // Default to 5 minutes if not cache time is set
5088
-
5089
- this.cacheTime = Math.max(this.cacheTime || 0, (_this$options$cacheTi = this.options.cacheTime) != null ? _this$options$cacheTi : 5 * 60 * 1000);
5090
- };
5091
-
5092
- _proto.setDefaultOptions = function setDefaultOptions(options) {
5093
- this.defaultOptions = options;
5094
- };
5095
-
5096
- _proto.scheduleGc = function scheduleGc() {
5097
- var _this = this;
5098
-
5099
- this.clearGcTimeout();
5100
-
5101
- if (isValidTimeout(this.cacheTime)) {
5102
- this.gcTimeout = setTimeout(function () {
5103
- _this.optionalRemove();
5104
- }, this.cacheTime);
5105
- }
5106
- };
5107
-
5108
- _proto.clearGcTimeout = function clearGcTimeout() {
5109
- if (this.gcTimeout) {
5110
- clearTimeout(this.gcTimeout);
5111
- this.gcTimeout = undefined;
5112
- }
5113
- };
5114
-
5115
- _proto.optionalRemove = function optionalRemove() {
5116
- if (!this.observers.length) {
5117
- if (this.state.isFetching) {
5118
- if (this.hadObservers) {
5119
- this.scheduleGc();
5120
- }
5121
- } else {
5122
- this.cache.remove(this);
5123
- }
5124
- }
5125
- };
5126
-
5127
- _proto.setData = function setData(updater, options) {
5128
- var _this$options$isDataE, _this$options;
5129
-
5130
- var prevData = this.state.data; // Get the new data
5131
-
5132
- var data = functionalUpdate(updater, prevData); // Use prev data if an isDataEqual function is defined and returns `true`
5133
-
5134
- if ((_this$options$isDataE = (_this$options = this.options).isDataEqual) == null ? void 0 : _this$options$isDataE.call(_this$options, prevData, data)) {
5135
- data = prevData;
5136
- } else if (this.options.structuralSharing !== false) {
5137
- // Structurally share data between prev and new data if needed
5138
- data = replaceEqualDeep(prevData, data);
5139
- } // Set data and mark it as cached
5140
-
5141
-
5142
- this.dispatch({
5143
- data: data,
5144
- type: 'success',
5145
- dataUpdatedAt: options == null ? void 0 : options.updatedAt
5146
- });
5147
- return data;
5148
- };
5149
-
5150
- _proto.setState = function setState(state, setStateOptions) {
5151
- this.dispatch({
5152
- type: 'setState',
5153
- state: state,
5154
- setStateOptions: setStateOptions
5155
- });
5156
- };
5157
-
5158
- _proto.cancel = function cancel(options) {
5159
- var _this$retryer;
5160
-
5161
- var promise = this.promise;
5162
- (_this$retryer = this.retryer) == null ? void 0 : _this$retryer.cancel(options);
5163
- return promise ? promise.then(noop).catch(noop) : Promise.resolve();
5164
- };
5165
-
5166
- _proto.destroy = function destroy() {
5167
- this.clearGcTimeout();
5168
- this.cancel({
5169
- silent: true
5170
- });
5171
- };
5172
-
5173
- _proto.reset = function reset() {
5174
- this.destroy();
5175
- this.setState(this.initialState);
5176
- };
5177
-
5178
- _proto.isActive = function isActive() {
5179
- return this.observers.some(function (observer) {
5180
- return observer.options.enabled !== false;
5181
- });
5182
- };
5183
-
5184
- _proto.isFetching = function isFetching() {
5185
- return this.state.isFetching;
5186
- };
5187
-
5188
- _proto.isStale = function isStale() {
5189
- return this.state.isInvalidated || !this.state.dataUpdatedAt || this.observers.some(function (observer) {
5190
- return observer.getCurrentResult().isStale;
5191
- });
5192
- };
5193
-
5194
- _proto.isStaleByTime = function isStaleByTime(staleTime) {
5195
- if (staleTime === void 0) {
5196
- staleTime = 0;
5197
- }
5198
-
5199
- return this.state.isInvalidated || !this.state.dataUpdatedAt || !timeUntilStale(this.state.dataUpdatedAt, staleTime);
5200
- };
5201
-
5202
- _proto.onFocus = function onFocus() {
5203
- var _this$retryer2;
5204
-
5205
- var observer = this.observers.find(function (x) {
5206
- return x.shouldFetchOnWindowFocus();
5207
- });
5208
-
5209
- if (observer) {
5210
- observer.refetch();
5211
- } // Continue fetch if currently paused
5212
-
5213
-
5214
- (_this$retryer2 = this.retryer) == null ? void 0 : _this$retryer2.continue();
5215
- };
5216
-
5217
- _proto.onOnline = function onOnline() {
5218
- var _this$retryer3;
5219
-
5220
- var observer = this.observers.find(function (x) {
5221
- return x.shouldFetchOnReconnect();
5222
- });
5223
-
5224
- if (observer) {
5225
- observer.refetch();
5226
- } // Continue fetch if currently paused
5227
-
5228
-
5229
- (_this$retryer3 = this.retryer) == null ? void 0 : _this$retryer3.continue();
5230
- };
5231
-
5232
- _proto.addObserver = function addObserver(observer) {
5233
- if (this.observers.indexOf(observer) === -1) {
5234
- this.observers.push(observer);
5235
- this.hadObservers = true; // Stop the query from being garbage collected
5236
-
5237
- this.clearGcTimeout();
5238
- this.cache.notify({
5239
- type: 'observerAdded',
5240
- query: this,
5241
- observer: observer
5242
- });
5243
- }
5244
- };
5245
-
5246
- _proto.removeObserver = function removeObserver(observer) {
5247
- if (this.observers.indexOf(observer) !== -1) {
5248
- this.observers = this.observers.filter(function (x) {
5249
- return x !== observer;
5250
- });
5251
-
5252
- if (!this.observers.length) {
5253
- // If the transport layer does not support cancellation
5254
- // we'll let the query continue so the result can be cached
5255
- if (this.retryer) {
5256
- if (this.retryer.isTransportCancelable || this.abortSignalConsumed) {
5257
- this.retryer.cancel({
5258
- revert: true
5259
- });
5260
- } else {
5261
- this.retryer.cancelRetry();
5262
- }
5263
- }
5264
-
5265
- if (this.cacheTime) {
5266
- this.scheduleGc();
5267
- } else {
5268
- this.cache.remove(this);
5269
- }
5270
- }
5271
-
5272
- this.cache.notify({
5273
- type: 'observerRemoved',
5274
- query: this,
5275
- observer: observer
5276
- });
5277
- }
5278
- };
5279
-
5280
- _proto.getObserversCount = function getObserversCount() {
5281
- return this.observers.length;
5282
- };
5283
-
5284
- _proto.invalidate = function invalidate() {
5285
- if (!this.state.isInvalidated) {
5286
- this.dispatch({
5287
- type: 'invalidate'
5288
- });
5289
- }
5290
- };
5291
-
5292
- _proto.fetch = function fetch(options, fetchOptions) {
5293
- var _this2 = this,
5294
- _this$options$behavio,
5295
- _context$fetchOptions,
5296
- _abortController$abor;
5297
-
5298
- if (this.state.isFetching) {
5299
- if (this.state.dataUpdatedAt && (fetchOptions == null ? void 0 : fetchOptions.cancelRefetch)) {
5300
- // Silently cancel current fetch if the user wants to cancel refetches
5301
- this.cancel({
5302
- silent: true
5303
- });
5304
- } else if (this.promise) {
5305
- var _this$retryer4;
5306
-
5307
- // make sure that retries that were potentially cancelled due to unmounts can continue
5308
- (_this$retryer4 = this.retryer) == null ? void 0 : _this$retryer4.continueRetry(); // Return current promise if we are already fetching
5309
-
5310
- return this.promise;
5311
- }
5312
- } // Update config if passed, otherwise the config from the last execution is used
5313
-
5314
-
5315
- if (options) {
5316
- this.setOptions(options);
5317
- } // Use the options from the first observer with a query function if no function is found.
5318
- // This can happen when the query is hydrated or created with setQueryData.
5319
-
5320
-
5321
- if (!this.options.queryFn) {
5322
- var observer = this.observers.find(function (x) {
5323
- return x.options.queryFn;
5324
- });
5325
-
5326
- if (observer) {
5327
- this.setOptions(observer.options);
5328
- }
5329
- }
5330
-
5331
- var queryKey = ensureQueryKeyArray(this.queryKey);
5332
- var abortController = getAbortController(); // Create query function context
5333
-
5334
- var queryFnContext = {
5335
- queryKey: queryKey,
5336
- pageParam: undefined,
5337
- meta: this.meta
5338
- };
5339
- Object.defineProperty(queryFnContext, 'signal', {
5340
- enumerable: true,
5341
- get: function get() {
5342
- if (abortController) {
5343
- _this2.abortSignalConsumed = true;
5344
- return abortController.signal;
5345
- }
5346
-
5347
- return undefined;
5348
- }
5349
- }); // Create fetch function
5350
-
5351
- var fetchFn = function fetchFn() {
5352
- if (!_this2.options.queryFn) {
5353
- return Promise.reject('Missing queryFn');
5354
- }
5355
-
5356
- _this2.abortSignalConsumed = false;
5357
- return _this2.options.queryFn(queryFnContext);
5358
- }; // Trigger behavior hook
5359
-
5360
-
5361
- var context = {
5362
- fetchOptions: fetchOptions,
5363
- options: this.options,
5364
- queryKey: queryKey,
5365
- state: this.state,
5366
- fetchFn: fetchFn,
5367
- meta: this.meta
5368
- };
5369
-
5370
- if ((_this$options$behavio = this.options.behavior) == null ? void 0 : _this$options$behavio.onFetch) {
5371
- var _this$options$behavio2;
5372
-
5373
- (_this$options$behavio2 = this.options.behavior) == null ? void 0 : _this$options$behavio2.onFetch(context);
5374
- } // Store state in case the current fetch needs to be reverted
5375
-
5376
-
5377
- this.revertState = this.state; // Set to fetching state if not already in it
5378
-
5379
- if (!this.state.isFetching || this.state.fetchMeta !== ((_context$fetchOptions = context.fetchOptions) == null ? void 0 : _context$fetchOptions.meta)) {
5380
- var _context$fetchOptions2;
5381
-
5382
- this.dispatch({
5383
- type: 'fetch',
5384
- meta: (_context$fetchOptions2 = context.fetchOptions) == null ? void 0 : _context$fetchOptions2.meta
5385
- });
5386
- } // Try to fetch the data
5387
-
5388
-
5389
- this.retryer = new Retryer({
5390
- fn: context.fetchFn,
5391
- abort: abortController == null ? void 0 : (_abortController$abor = abortController.abort) == null ? void 0 : _abortController$abor.bind(abortController),
5392
- onSuccess: function onSuccess(data) {
5393
- _this2.setData(data); // Notify cache callback
5394
-
5395
-
5396
- _this2.cache.config.onSuccess == null ? void 0 : _this2.cache.config.onSuccess(data, _this2); // Remove query after fetching if cache time is 0
5397
-
5398
- if (_this2.cacheTime === 0) {
5399
- _this2.optionalRemove();
5400
- }
5401
- },
5402
- onError: function onError(error) {
5403
- // Optimistically update state if needed
5404
- if (!(isCancelledError(error) && error.silent)) {
5405
- _this2.dispatch({
5406
- type: 'error',
5407
- error: error
5408
- });
5409
- }
5410
-
5411
- if (!isCancelledError(error)) {
5412
- // Notify cache callback
5413
- _this2.cache.config.onError == null ? void 0 : _this2.cache.config.onError(error, _this2); // Log error
5414
-
5415
- getLogger().error(error);
5416
- } // Remove query after fetching if cache time is 0
5417
-
5418
-
5419
- if (_this2.cacheTime === 0) {
5420
- _this2.optionalRemove();
5421
- }
5422
- },
5423
- onFail: function onFail() {
5424
- _this2.dispatch({
5425
- type: 'failed'
5426
- });
5427
- },
5428
- onPause: function onPause() {
5429
- _this2.dispatch({
5430
- type: 'pause'
5431
- });
5432
- },
5433
- onContinue: function onContinue() {
5434
- _this2.dispatch({
5435
- type: 'continue'
5436
- });
5437
- },
5438
- retry: context.options.retry,
5439
- retryDelay: context.options.retryDelay
5440
- });
5441
- this.promise = this.retryer.promise;
5442
- return this.promise;
5443
- };
5444
-
5445
- _proto.dispatch = function dispatch(action) {
5446
- var _this3 = this;
5447
-
5448
- this.state = this.reducer(this.state, action);
5449
- notifyManager.batch(function () {
5450
- _this3.observers.forEach(function (observer) {
5451
- observer.onQueryUpdate(action);
5452
- });
5453
-
5454
- _this3.cache.notify({
5455
- query: _this3,
5456
- type: 'queryUpdated',
5457
- action: action
5458
- });
5459
- });
5460
- };
5461
-
5462
- _proto.getDefaultState = function getDefaultState(options) {
5463
- var data = typeof options.initialData === 'function' ? options.initialData() : options.initialData;
5464
- var hasInitialData = typeof options.initialData !== 'undefined';
5465
- var initialDataUpdatedAt = hasInitialData ? typeof options.initialDataUpdatedAt === 'function' ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
5466
- var hasData = typeof data !== 'undefined';
5467
- return {
5468
- data: data,
5469
- dataUpdateCount: 0,
5470
- dataUpdatedAt: hasData ? initialDataUpdatedAt != null ? initialDataUpdatedAt : Date.now() : 0,
5471
- error: null,
5472
- errorUpdateCount: 0,
5473
- errorUpdatedAt: 0,
5474
- fetchFailureCount: 0,
5475
- fetchMeta: null,
5476
- isFetching: false,
5477
- isInvalidated: false,
5478
- isPaused: false,
5479
- status: hasData ? 'success' : 'idle'
5480
- };
5481
- };
5482
-
5483
- _proto.reducer = function reducer(state, action) {
5484
- var _action$meta, _action$dataUpdatedAt;
5485
-
5486
- switch (action.type) {
5487
- case 'failed':
5488
- return _extends({}, state, {
5489
- fetchFailureCount: state.fetchFailureCount + 1
5490
- });
5491
-
5492
- case 'pause':
5493
- return _extends({}, state, {
5494
- isPaused: true
5495
- });
5496
-
5497
- case 'continue':
5498
- return _extends({}, state, {
5499
- isPaused: false
5500
- });
5501
-
5502
- case 'fetch':
5503
- return _extends({}, state, {
5504
- fetchFailureCount: 0,
5505
- fetchMeta: (_action$meta = action.meta) != null ? _action$meta : null,
5506
- isFetching: true,
5507
- isPaused: false
5508
- }, !state.dataUpdatedAt && {
5509
- error: null,
5510
- status: 'loading'
5511
- });
5512
-
5513
- case 'success':
5514
- return _extends({}, state, {
5515
- data: action.data,
5516
- dataUpdateCount: state.dataUpdateCount + 1,
5517
- dataUpdatedAt: (_action$dataUpdatedAt = action.dataUpdatedAt) != null ? _action$dataUpdatedAt : Date.now(),
5518
- error: null,
5519
- fetchFailureCount: 0,
5520
- isFetching: false,
5521
- isInvalidated: false,
5522
- isPaused: false,
5523
- status: 'success'
5524
- });
5525
-
5526
- case 'error':
5527
- var error = action.error;
5528
-
5529
- if (isCancelledError(error) && error.revert && this.revertState) {
5530
- return _extends({}, this.revertState);
5531
- }
5532
-
5533
- return _extends({}, state, {
5534
- error: error,
5535
- errorUpdateCount: state.errorUpdateCount + 1,
5536
- errorUpdatedAt: Date.now(),
5537
- fetchFailureCount: state.fetchFailureCount + 1,
5538
- isFetching: false,
5539
- isPaused: false,
5540
- status: 'error'
5541
- });
5542
-
5543
- case 'invalidate':
5544
- return _extends({}, state, {
5545
- isInvalidated: true
5546
- });
5547
-
5548
- case 'setState':
5549
- return _extends({}, state, action.state);
5550
-
5551
- default:
5552
- return state;
5553
- }
5554
- };
5555
-
5556
- return Query;
5557
- }();
5558
-
5559
- // CLASS
5560
- var QueryCache = /*#__PURE__*/function (_Subscribable) {
5561
- _inheritsLoose(QueryCache, _Subscribable);
5562
-
5563
- function QueryCache(config) {
5564
- var _this;
5565
-
5566
- _this = _Subscribable.call(this) || this;
5567
- _this.config = config || {};
5568
- _this.queries = [];
5569
- _this.queriesMap = {};
5570
- return _this;
5571
- }
5572
-
5573
- var _proto = QueryCache.prototype;
5574
-
5575
- _proto.build = function build(client, options, state) {
5576
- var _options$queryHash;
5577
-
5578
- var queryKey = options.queryKey;
5579
- var queryHash = (_options$queryHash = options.queryHash) != null ? _options$queryHash : hashQueryKeyByOptions(queryKey, options);
5580
- var query = this.get(queryHash);
5581
-
5582
- if (!query) {
5583
- query = new Query({
5584
- cache: this,
5585
- queryKey: queryKey,
5586
- queryHash: queryHash,
5587
- options: client.defaultQueryOptions(options),
5588
- state: state,
5589
- defaultOptions: client.getQueryDefaults(queryKey),
5590
- meta: options.meta
5591
- });
5592
- this.add(query);
5593
- }
5594
-
5595
- return query;
5596
- };
5597
-
5598
- _proto.add = function add(query) {
5599
- if (!this.queriesMap[query.queryHash]) {
5600
- this.queriesMap[query.queryHash] = query;
5601
- this.queries.push(query);
5602
- this.notify({
5603
- type: 'queryAdded',
5604
- query: query
5605
- });
5606
- }
5607
- };
5608
-
5609
- _proto.remove = function remove(query) {
5610
- var queryInMap = this.queriesMap[query.queryHash];
5611
-
5612
- if (queryInMap) {
5613
- query.destroy();
5614
- this.queries = this.queries.filter(function (x) {
5615
- return x !== query;
5616
- });
5617
-
5618
- if (queryInMap === query) {
5619
- delete this.queriesMap[query.queryHash];
5620
- }
5621
-
5622
- this.notify({
5623
- type: 'queryRemoved',
5624
- query: query
5625
- });
5626
- }
5627
- };
5628
-
5629
- _proto.clear = function clear() {
5630
- var _this2 = this;
5631
-
5632
- notifyManager.batch(function () {
5633
- _this2.queries.forEach(function (query) {
5634
- _this2.remove(query);
5635
- });
5636
- });
5637
- };
5638
-
5639
- _proto.get = function get(queryHash) {
5640
- return this.queriesMap[queryHash];
5641
- };
5642
-
5643
- _proto.getAll = function getAll() {
5644
- return this.queries;
5645
- };
5646
-
5647
- _proto.find = function find(arg1, arg2) {
5648
- var _parseFilterArgs = parseFilterArgs(arg1, arg2),
5649
- filters = _parseFilterArgs[0];
5650
-
5651
- if (typeof filters.exact === 'undefined') {
5652
- filters.exact = true;
5653
- }
5654
-
5655
- return this.queries.find(function (query) {
5656
- return matchQuery(filters, query);
5657
- });
5658
- };
5659
-
5660
- _proto.findAll = function findAll(arg1, arg2) {
5661
- var _parseFilterArgs2 = parseFilterArgs(arg1, arg2),
5662
- filters = _parseFilterArgs2[0];
5663
-
5664
- return Object.keys(filters).length > 0 ? this.queries.filter(function (query) {
5665
- return matchQuery(filters, query);
5666
- }) : this.queries;
5667
- };
5668
-
5669
- _proto.notify = function notify(event) {
5670
- var _this3 = this;
5671
-
5672
- notifyManager.batch(function () {
5673
- _this3.listeners.forEach(function (listener) {
5674
- listener(event);
5675
- });
5676
- });
5677
- };
5678
-
5679
- _proto.onFocus = function onFocus() {
5680
- var _this4 = this;
5681
-
5682
- notifyManager.batch(function () {
5683
- _this4.queries.forEach(function (query) {
5684
- query.onFocus();
5685
- });
5686
- });
5687
- };
5688
-
5689
- _proto.onOnline = function onOnline() {
5690
- var _this5 = this;
5691
-
5692
- notifyManager.batch(function () {
5693
- _this5.queries.forEach(function (query) {
5694
- query.onOnline();
5695
- });
5696
- });
5697
- };
5698
-
5699
- return QueryCache;
5700
- }(Subscribable);
5701
-
5702
- // CLASS
5703
- var Mutation = /*#__PURE__*/function () {
5704
- function Mutation(config) {
5705
- this.options = _extends({}, config.defaultOptions, config.options);
5706
- this.mutationId = config.mutationId;
5707
- this.mutationCache = config.mutationCache;
5708
- this.observers = [];
5709
- this.state = config.state || getDefaultState();
5710
- this.meta = config.meta;
5711
- }
5712
-
5713
- var _proto = Mutation.prototype;
5714
-
5715
- _proto.setState = function setState(state) {
5716
- this.dispatch({
5717
- type: 'setState',
5718
- state: state
5719
- });
5720
- };
5721
-
5722
- _proto.addObserver = function addObserver(observer) {
5723
- if (this.observers.indexOf(observer) === -1) {
5724
- this.observers.push(observer);
5725
- }
5726
- };
5727
-
5728
- _proto.removeObserver = function removeObserver(observer) {
5729
- this.observers = this.observers.filter(function (x) {
5730
- return x !== observer;
5731
- });
5732
- };
5733
-
5734
- _proto.cancel = function cancel() {
5735
- if (this.retryer) {
5736
- this.retryer.cancel();
5737
- return this.retryer.promise.then(noop).catch(noop);
5738
- }
5739
-
5740
- return Promise.resolve();
5741
- };
5742
-
5743
- _proto.continue = function _continue() {
5744
- if (this.retryer) {
5745
- this.retryer.continue();
5746
- return this.retryer.promise;
5747
- }
5748
-
5749
- return this.execute();
5750
- };
5751
-
5752
- _proto.execute = function execute() {
5753
- var _this = this;
5754
-
5755
- var data;
5756
- var restored = this.state.status === 'loading';
5757
- var promise = Promise.resolve();
5758
-
5759
- if (!restored) {
5760
- this.dispatch({
5761
- type: 'loading',
5762
- variables: this.options.variables
5763
- });
5764
- promise = promise.then(function () {
5765
- // Notify cache callback
5766
- _this.mutationCache.config.onMutate == null ? void 0 : _this.mutationCache.config.onMutate(_this.state.variables, _this);
5767
- }).then(function () {
5768
- return _this.options.onMutate == null ? void 0 : _this.options.onMutate(_this.state.variables);
5769
- }).then(function (context) {
5770
- if (context !== _this.state.context) {
5771
- _this.dispatch({
5772
- type: 'loading',
5773
- context: context,
5774
- variables: _this.state.variables
5775
- });
5776
- }
5777
- });
5778
- }
5779
-
5780
- return promise.then(function () {
5781
- return _this.executeMutation();
5782
- }).then(function (result) {
5783
- data = result; // Notify cache callback
5784
-
5785
- _this.mutationCache.config.onSuccess == null ? void 0 : _this.mutationCache.config.onSuccess(data, _this.state.variables, _this.state.context, _this);
5786
- }).then(function () {
5787
- return _this.options.onSuccess == null ? void 0 : _this.options.onSuccess(data, _this.state.variables, _this.state.context);
5788
- }).then(function () {
5789
- return _this.options.onSettled == null ? void 0 : _this.options.onSettled(data, null, _this.state.variables, _this.state.context);
5790
- }).then(function () {
5791
- _this.dispatch({
5792
- type: 'success',
5793
- data: data
5794
- });
5795
-
5796
- return data;
5797
- }).catch(function (error) {
5798
- // Notify cache callback
5799
- _this.mutationCache.config.onError == null ? void 0 : _this.mutationCache.config.onError(error, _this.state.variables, _this.state.context, _this); // Log error
5800
-
5801
- getLogger().error(error);
5802
- return Promise.resolve().then(function () {
5803
- return _this.options.onError == null ? void 0 : _this.options.onError(error, _this.state.variables, _this.state.context);
5804
- }).then(function () {
5805
- return _this.options.onSettled == null ? void 0 : _this.options.onSettled(undefined, error, _this.state.variables, _this.state.context);
5806
- }).then(function () {
5807
- _this.dispatch({
5808
- type: 'error',
5809
- error: error
5810
- });
5811
-
5812
- throw error;
5813
- });
5814
- });
5815
- };
5816
-
5817
- _proto.executeMutation = function executeMutation() {
5818
- var _this2 = this,
5819
- _this$options$retry;
5820
-
5821
- this.retryer = new Retryer({
5822
- fn: function fn() {
5823
- if (!_this2.options.mutationFn) {
5824
- return Promise.reject('No mutationFn found');
5825
- }
5826
-
5827
- return _this2.options.mutationFn(_this2.state.variables);
5828
- },
5829
- onFail: function onFail() {
5830
- _this2.dispatch({
5831
- type: 'failed'
5832
- });
5833
- },
5834
- onPause: function onPause() {
5835
- _this2.dispatch({
5836
- type: 'pause'
5837
- });
5838
- },
5839
- onContinue: function onContinue() {
5840
- _this2.dispatch({
5841
- type: 'continue'
5842
- });
5843
- },
5844
- retry: (_this$options$retry = this.options.retry) != null ? _this$options$retry : 0,
5845
- retryDelay: this.options.retryDelay
5846
- });
5847
- return this.retryer.promise;
5848
- };
5849
-
5850
- _proto.dispatch = function dispatch(action) {
5851
- var _this3 = this;
5852
-
5853
- this.state = reducer(this.state, action);
5854
- notifyManager.batch(function () {
5855
- _this3.observers.forEach(function (observer) {
5856
- observer.onMutationUpdate(action);
5857
- });
5858
-
5859
- _this3.mutationCache.notify(_this3);
5860
- });
5861
- };
5862
-
5863
- return Mutation;
5864
- }();
5865
- function getDefaultState() {
5866
- return {
5867
- context: undefined,
5868
- data: undefined,
5869
- error: null,
5870
- failureCount: 0,
5871
- isPaused: false,
5872
- status: 'idle',
5873
- variables: undefined
5874
- };
5875
- }
5876
-
5877
- function reducer(state, action) {
5878
- switch (action.type) {
5879
- case 'failed':
5880
- return _extends({}, state, {
5881
- failureCount: state.failureCount + 1
5882
- });
5883
-
5884
- case 'pause':
5885
- return _extends({}, state, {
5886
- isPaused: true
5887
- });
5888
-
5889
- case 'continue':
5890
- return _extends({}, state, {
5891
- isPaused: false
5892
- });
5893
-
5894
- case 'loading':
5895
- return _extends({}, state, {
5896
- context: action.context,
5897
- data: undefined,
5898
- error: null,
5899
- isPaused: false,
5900
- status: 'loading',
5901
- variables: action.variables
5902
- });
5903
-
5904
- case 'success':
5905
- return _extends({}, state, {
5906
- data: action.data,
5907
- error: null,
5908
- status: 'success',
5909
- isPaused: false
5910
- });
5911
-
5912
- case 'error':
5913
- return _extends({}, state, {
5914
- data: undefined,
5915
- error: action.error,
5916
- failureCount: state.failureCount + 1,
5917
- isPaused: false,
5918
- status: 'error'
5919
- });
5920
-
5921
- case 'setState':
5922
- return _extends({}, state, action.state);
5923
-
5924
- default:
5925
- return state;
5926
- }
5927
- }
5928
-
5929
- // CLASS
5930
- var MutationCache = /*#__PURE__*/function (_Subscribable) {
5931
- _inheritsLoose(MutationCache, _Subscribable);
5932
-
5933
- function MutationCache(config) {
5934
- var _this;
5935
-
5936
- _this = _Subscribable.call(this) || this;
5937
- _this.config = config || {};
5938
- _this.mutations = [];
5939
- _this.mutationId = 0;
5940
- return _this;
5941
- }
5942
-
5943
- var _proto = MutationCache.prototype;
5944
-
5945
- _proto.build = function build(client, options, state) {
5946
- var mutation = new Mutation({
5947
- mutationCache: this,
5948
- mutationId: ++this.mutationId,
5949
- options: client.defaultMutationOptions(options),
5950
- state: state,
5951
- defaultOptions: options.mutationKey ? client.getMutationDefaults(options.mutationKey) : undefined,
5952
- meta: options.meta
5953
- });
5954
- this.add(mutation);
5955
- return mutation;
5956
- };
5957
-
5958
- _proto.add = function add(mutation) {
5959
- this.mutations.push(mutation);
5960
- this.notify(mutation);
5961
- };
5962
-
5963
- _proto.remove = function remove(mutation) {
5964
- this.mutations = this.mutations.filter(function (x) {
5965
- return x !== mutation;
5966
- });
5967
- mutation.cancel();
5968
- this.notify(mutation);
5969
- };
5970
-
5971
- _proto.clear = function clear() {
5972
- var _this2 = this;
5973
-
5974
- notifyManager.batch(function () {
5975
- _this2.mutations.forEach(function (mutation) {
5976
- _this2.remove(mutation);
5977
- });
5978
- });
5979
- };
5980
-
5981
- _proto.getAll = function getAll() {
5982
- return this.mutations;
5983
- };
5984
-
5985
- _proto.find = function find(filters) {
5986
- if (typeof filters.exact === 'undefined') {
5987
- filters.exact = true;
5988
- }
5989
-
5990
- return this.mutations.find(function (mutation) {
5991
- return matchMutation(filters, mutation);
5992
- });
5993
- };
5994
-
5995
- _proto.findAll = function findAll(filters) {
5996
- return this.mutations.filter(function (mutation) {
5997
- return matchMutation(filters, mutation);
5998
- });
5999
- };
6000
-
6001
- _proto.notify = function notify(mutation) {
6002
- var _this3 = this;
6003
-
6004
- notifyManager.batch(function () {
6005
- _this3.listeners.forEach(function (listener) {
6006
- listener(mutation);
6007
- });
6008
- });
6009
- };
6010
-
6011
- _proto.onFocus = function onFocus() {
6012
- this.resumePausedMutations();
6013
- };
6014
-
6015
- _proto.onOnline = function onOnline() {
6016
- this.resumePausedMutations();
6017
- };
6018
-
6019
- _proto.resumePausedMutations = function resumePausedMutations() {
6020
- var pausedMutations = this.mutations.filter(function (x) {
6021
- return x.state.isPaused;
6022
- });
6023
- return notifyManager.batch(function () {
6024
- return pausedMutations.reduce(function (promise, mutation) {
6025
- return promise.then(function () {
6026
- return mutation.continue().catch(noop);
6027
- });
6028
- }, Promise.resolve());
6029
- });
6030
- };
6031
-
6032
- return MutationCache;
6033
- }(Subscribable);
6034
-
6035
- function infiniteQueryBehavior() {
6036
- return {
6037
- onFetch: function onFetch(context) {
6038
- context.fetchFn = function () {
6039
- var _context$fetchOptions, _context$fetchOptions2, _context$fetchOptions3, _context$fetchOptions4, _context$state$data, _context$state$data2;
6040
-
6041
- var refetchPage = (_context$fetchOptions = context.fetchOptions) == null ? void 0 : (_context$fetchOptions2 = _context$fetchOptions.meta) == null ? void 0 : _context$fetchOptions2.refetchPage;
6042
- var fetchMore = (_context$fetchOptions3 = context.fetchOptions) == null ? void 0 : (_context$fetchOptions4 = _context$fetchOptions3.meta) == null ? void 0 : _context$fetchOptions4.fetchMore;
6043
- var pageParam = fetchMore == null ? void 0 : fetchMore.pageParam;
6044
- var isFetchingNextPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'forward';
6045
- var isFetchingPreviousPage = (fetchMore == null ? void 0 : fetchMore.direction) === 'backward';
6046
- var oldPages = ((_context$state$data = context.state.data) == null ? void 0 : _context$state$data.pages) || [];
6047
- var oldPageParams = ((_context$state$data2 = context.state.data) == null ? void 0 : _context$state$data2.pageParams) || [];
6048
- var abortController = getAbortController();
6049
- var abortSignal = abortController == null ? void 0 : abortController.signal;
6050
- var newPageParams = oldPageParams;
6051
- var cancelled = false; // Get query function
6052
-
6053
- var queryFn = context.options.queryFn || function () {
6054
- return Promise.reject('Missing queryFn');
6055
- };
6056
-
6057
- var buildNewPages = function buildNewPages(pages, param, page, previous) {
6058
- newPageParams = previous ? [param].concat(newPageParams) : [].concat(newPageParams, [param]);
6059
- return previous ? [page].concat(pages) : [].concat(pages, [page]);
6060
- }; // Create function to fetch a page
6061
-
6062
-
6063
- var fetchPage = function fetchPage(pages, manual, param, previous) {
6064
- if (cancelled) {
6065
- return Promise.reject('Cancelled');
6066
- }
6067
-
6068
- if (typeof param === 'undefined' && !manual && pages.length) {
6069
- return Promise.resolve(pages);
6070
- }
6071
-
6072
- var queryFnContext = {
6073
- queryKey: context.queryKey,
6074
- signal: abortSignal,
6075
- pageParam: param,
6076
- meta: context.meta
6077
- };
6078
- var queryFnResult = queryFn(queryFnContext);
6079
- var promise = Promise.resolve(queryFnResult).then(function (page) {
6080
- return buildNewPages(pages, param, page, previous);
6081
- });
6082
-
6083
- if (isCancelable(queryFnResult)) {
6084
- var promiseAsAny = promise;
6085
- promiseAsAny.cancel = queryFnResult.cancel;
6086
- }
6087
-
6088
- return promise;
6089
- };
6090
-
6091
- var promise; // Fetch first page?
6092
-
6093
- if (!oldPages.length) {
6094
- promise = fetchPage([]);
6095
- } // Fetch next page?
6096
- else if (isFetchingNextPage) {
6097
- var manual = typeof pageParam !== 'undefined';
6098
- var param = manual ? pageParam : getNextPageParam(context.options, oldPages);
6099
- promise = fetchPage(oldPages, manual, param);
6100
- } // Fetch previous page?
6101
- else if (isFetchingPreviousPage) {
6102
- var _manual = typeof pageParam !== 'undefined';
6103
-
6104
- var _param = _manual ? pageParam : getPreviousPageParam(context.options, oldPages);
6105
-
6106
- promise = fetchPage(oldPages, _manual, _param, true);
6107
- } // Refetch pages
6108
- else {
6109
- (function () {
6110
- newPageParams = [];
6111
- var manual = typeof context.options.getNextPageParam === 'undefined';
6112
- var shouldFetchFirstPage = refetchPage && oldPages[0] ? refetchPage(oldPages[0], 0, oldPages) : true; // Fetch first page
6113
-
6114
- promise = shouldFetchFirstPage ? fetchPage([], manual, oldPageParams[0]) : Promise.resolve(buildNewPages([], oldPageParams[0], oldPages[0])); // Fetch remaining pages
6115
-
6116
- var _loop = function _loop(i) {
6117
- promise = promise.then(function (pages) {
6118
- var shouldFetchNextPage = refetchPage && oldPages[i] ? refetchPage(oldPages[i], i, oldPages) : true;
6119
-
6120
- if (shouldFetchNextPage) {
6121
- var _param2 = manual ? oldPageParams[i] : getNextPageParam(context.options, pages);
6122
-
6123
- return fetchPage(pages, manual, _param2);
6124
- }
6125
-
6126
- return Promise.resolve(buildNewPages(pages, oldPageParams[i], oldPages[i]));
6127
- });
6128
- };
6129
-
6130
- for (var i = 1; i < oldPages.length; i++) {
6131
- _loop(i);
6132
- }
6133
- })();
6134
- }
6135
-
6136
- var finalPromise = promise.then(function (pages) {
6137
- return {
6138
- pages: pages,
6139
- pageParams: newPageParams
6140
- };
6141
- });
6142
- var finalPromiseAsAny = finalPromise;
6143
-
6144
- finalPromiseAsAny.cancel = function () {
6145
- cancelled = true;
6146
- abortController == null ? void 0 : abortController.abort();
6147
-
6148
- if (isCancelable(promise)) {
6149
- promise.cancel();
6150
- }
6151
- };
6152
-
6153
- return finalPromise;
6154
- };
6155
- }
6156
- };
6157
- }
6158
- function getNextPageParam(options, pages) {
6159
- return options.getNextPageParam == null ? void 0 : options.getNextPageParam(pages[pages.length - 1], pages);
6160
- }
6161
- function getPreviousPageParam(options, pages) {
6162
- return options.getPreviousPageParam == null ? void 0 : options.getPreviousPageParam(pages[0], pages);
6163
- }
6164
-
6165
- // CLASS
6166
- var QueryClient = /*#__PURE__*/function () {
6167
- function QueryClient(config) {
6168
- if (config === void 0) {
6169
- config = {};
6170
- }
6171
-
6172
- this.queryCache = config.queryCache || new QueryCache();
6173
- this.mutationCache = config.mutationCache || new MutationCache();
6174
- this.defaultOptions = config.defaultOptions || {};
6175
- this.queryDefaults = [];
6176
- this.mutationDefaults = [];
6177
- }
6178
-
6179
- var _proto = QueryClient.prototype;
6180
-
6181
- _proto.mount = function mount() {
6182
- var _this = this;
6183
-
6184
- this.unsubscribeFocus = focusManager.subscribe(function () {
6185
- if (focusManager.isFocused() && onlineManager.isOnline()) {
6186
- _this.mutationCache.onFocus();
6187
-
6188
- _this.queryCache.onFocus();
6189
- }
6190
- });
6191
- this.unsubscribeOnline = onlineManager.subscribe(function () {
6192
- if (focusManager.isFocused() && onlineManager.isOnline()) {
6193
- _this.mutationCache.onOnline();
6194
-
6195
- _this.queryCache.onOnline();
6196
- }
6197
- });
6198
- };
6199
-
6200
- _proto.unmount = function unmount() {
6201
- var _this$unsubscribeFocu, _this$unsubscribeOnli;
6202
-
6203
- (_this$unsubscribeFocu = this.unsubscribeFocus) == null ? void 0 : _this$unsubscribeFocu.call(this);
6204
- (_this$unsubscribeOnli = this.unsubscribeOnline) == null ? void 0 : _this$unsubscribeOnli.call(this);
6205
- };
6206
-
6207
- _proto.isFetching = function isFetching(arg1, arg2) {
6208
- var _parseFilterArgs = parseFilterArgs(arg1, arg2),
6209
- filters = _parseFilterArgs[0];
6210
-
6211
- filters.fetching = true;
6212
- return this.queryCache.findAll(filters).length;
6213
- };
6214
-
6215
- _proto.isMutating = function isMutating(filters) {
6216
- return this.mutationCache.findAll(_extends({}, filters, {
6217
- fetching: true
6218
- })).length;
6219
- };
6220
-
6221
- _proto.getQueryData = function getQueryData(queryKey, filters) {
6222
- var _this$queryCache$find;
6223
-
6224
- return (_this$queryCache$find = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find.state.data;
6225
- };
6226
-
6227
- _proto.getQueriesData = function getQueriesData(queryKeyOrFilters) {
6228
- return this.getQueryCache().findAll(queryKeyOrFilters).map(function (_ref) {
6229
- var queryKey = _ref.queryKey,
6230
- state = _ref.state;
6231
- var data = state.data;
6232
- return [queryKey, data];
6233
- });
6234
- };
6235
-
6236
- _proto.setQueryData = function setQueryData(queryKey, updater, options) {
6237
- var parsedOptions = parseQueryArgs(queryKey);
6238
- var defaultedOptions = this.defaultQueryOptions(parsedOptions);
6239
- return this.queryCache.build(this, defaultedOptions).setData(updater, options);
6240
- };
6241
-
6242
- _proto.setQueriesData = function setQueriesData(queryKeyOrFilters, updater, options) {
6243
- var _this2 = this;
6244
-
6245
- return notifyManager.batch(function () {
6246
- return _this2.getQueryCache().findAll(queryKeyOrFilters).map(function (_ref2) {
6247
- var queryKey = _ref2.queryKey;
6248
- return [queryKey, _this2.setQueryData(queryKey, updater, options)];
6249
- });
6250
- });
6251
- };
6252
-
6253
- _proto.getQueryState = function getQueryState(queryKey, filters) {
6254
- var _this$queryCache$find2;
6255
-
6256
- return (_this$queryCache$find2 = this.queryCache.find(queryKey, filters)) == null ? void 0 : _this$queryCache$find2.state;
6257
- };
6258
-
6259
- _proto.removeQueries = function removeQueries(arg1, arg2) {
6260
- var _parseFilterArgs2 = parseFilterArgs(arg1, arg2),
6261
- filters = _parseFilterArgs2[0];
6262
-
6263
- var queryCache = this.queryCache;
6264
- notifyManager.batch(function () {
6265
- queryCache.findAll(filters).forEach(function (query) {
6266
- queryCache.remove(query);
6267
- });
6268
- });
6269
- };
6270
-
6271
- _proto.resetQueries = function resetQueries(arg1, arg2, arg3) {
6272
- var _this3 = this;
6273
-
6274
- var _parseFilterArgs3 = parseFilterArgs(arg1, arg2, arg3),
6275
- filters = _parseFilterArgs3[0],
6276
- options = _parseFilterArgs3[1];
6277
-
6278
- var queryCache = this.queryCache;
6279
-
6280
- var refetchFilters = _extends({}, filters, {
6281
- active: true
6282
- });
6283
-
6284
- return notifyManager.batch(function () {
6285
- queryCache.findAll(filters).forEach(function (query) {
6286
- query.reset();
6287
- });
6288
- return _this3.refetchQueries(refetchFilters, options);
6289
- });
6290
- };
6291
-
6292
- _proto.cancelQueries = function cancelQueries(arg1, arg2, arg3) {
6293
- var _this4 = this;
6294
-
6295
- var _parseFilterArgs4 = parseFilterArgs(arg1, arg2, arg3),
6296
- filters = _parseFilterArgs4[0],
6297
- _parseFilterArgs4$ = _parseFilterArgs4[1],
6298
- cancelOptions = _parseFilterArgs4$ === void 0 ? {} : _parseFilterArgs4$;
6299
-
6300
- if (typeof cancelOptions.revert === 'undefined') {
6301
- cancelOptions.revert = true;
6302
- }
6303
-
6304
- var promises = notifyManager.batch(function () {
6305
- return _this4.queryCache.findAll(filters).map(function (query) {
6306
- return query.cancel(cancelOptions);
6307
- });
6308
- });
6309
- return Promise.all(promises).then(noop).catch(noop);
6310
- };
6311
-
6312
- _proto.invalidateQueries = function invalidateQueries(arg1, arg2, arg3) {
6313
- var _ref3,
6314
- _filters$refetchActiv,
6315
- _filters$refetchInact,
6316
- _this5 = this;
6317
-
6318
- var _parseFilterArgs5 = parseFilterArgs(arg1, arg2, arg3),
6319
- filters = _parseFilterArgs5[0],
6320
- options = _parseFilterArgs5[1];
6321
-
6322
- var refetchFilters = _extends({}, filters, {
6323
- // if filters.refetchActive is not provided and filters.active is explicitly false,
6324
- // e.g. invalidateQueries({ active: false }), we don't want to refetch active queries
6325
- active: (_ref3 = (_filters$refetchActiv = filters.refetchActive) != null ? _filters$refetchActiv : filters.active) != null ? _ref3 : true,
6326
- inactive: (_filters$refetchInact = filters.refetchInactive) != null ? _filters$refetchInact : false
6327
- });
6328
-
6329
- return notifyManager.batch(function () {
6330
- _this5.queryCache.findAll(filters).forEach(function (query) {
6331
- query.invalidate();
6332
- });
6333
-
6334
- return _this5.refetchQueries(refetchFilters, options);
6335
- });
6336
- };
6337
-
6338
- _proto.refetchQueries = function refetchQueries(arg1, arg2, arg3) {
6339
- var _this6 = this;
6340
-
6341
- var _parseFilterArgs6 = parseFilterArgs(arg1, arg2, arg3),
6342
- filters = _parseFilterArgs6[0],
6343
- options = _parseFilterArgs6[1];
6344
-
6345
- var promises = notifyManager.batch(function () {
6346
- return _this6.queryCache.findAll(filters).map(function (query) {
6347
- return query.fetch(undefined, _extends({}, options, {
6348
- meta: {
6349
- refetchPage: filters == null ? void 0 : filters.refetchPage
6350
- }
6351
- }));
6352
- });
6353
- });
6354
- var promise = Promise.all(promises).then(noop);
6355
-
6356
- if (!(options == null ? void 0 : options.throwOnError)) {
6357
- promise = promise.catch(noop);
6358
- }
6359
-
6360
- return promise;
6361
- };
6362
-
6363
- _proto.fetchQuery = function fetchQuery(arg1, arg2, arg3) {
6364
- var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
6365
- var defaultedOptions = this.defaultQueryOptions(parsedOptions); // https://github.com/tannerlinsley/react-query/issues/652
6366
-
6367
- if (typeof defaultedOptions.retry === 'undefined') {
6368
- defaultedOptions.retry = false;
6369
- }
6370
-
6371
- var query = this.queryCache.build(this, defaultedOptions);
6372
- return query.isStaleByTime(defaultedOptions.staleTime) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
6373
- };
6374
-
6375
- _proto.prefetchQuery = function prefetchQuery(arg1, arg2, arg3) {
6376
- return this.fetchQuery(arg1, arg2, arg3).then(noop).catch(noop);
6377
- };
6378
-
6379
- _proto.fetchInfiniteQuery = function fetchInfiniteQuery(arg1, arg2, arg3) {
6380
- var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
6381
- parsedOptions.behavior = infiniteQueryBehavior();
6382
- return this.fetchQuery(parsedOptions);
6383
- };
6384
-
6385
- _proto.prefetchInfiniteQuery = function prefetchInfiniteQuery(arg1, arg2, arg3) {
6386
- return this.fetchInfiniteQuery(arg1, arg2, arg3).then(noop).catch(noop);
6387
- };
6388
-
6389
- _proto.cancelMutations = function cancelMutations() {
6390
- var _this7 = this;
6391
-
6392
- var promises = notifyManager.batch(function () {
6393
- return _this7.mutationCache.getAll().map(function (mutation) {
6394
- return mutation.cancel();
6395
- });
6396
- });
6397
- return Promise.all(promises).then(noop).catch(noop);
6398
- };
6399
-
6400
- _proto.resumePausedMutations = function resumePausedMutations() {
6401
- return this.getMutationCache().resumePausedMutations();
6402
- };
6403
-
6404
- _proto.executeMutation = function executeMutation(options) {
6405
- return this.mutationCache.build(this, options).execute();
6406
- };
6407
-
6408
- _proto.getQueryCache = function getQueryCache() {
6409
- return this.queryCache;
6410
- };
6411
-
6412
- _proto.getMutationCache = function getMutationCache() {
6413
- return this.mutationCache;
6414
- };
6415
-
6416
- _proto.getDefaultOptions = function getDefaultOptions() {
6417
- return this.defaultOptions;
6418
- };
6419
-
6420
- _proto.setDefaultOptions = function setDefaultOptions(options) {
6421
- this.defaultOptions = options;
6422
- };
6423
-
6424
- _proto.setQueryDefaults = function setQueryDefaults(queryKey, options) {
6425
- var result = this.queryDefaults.find(function (x) {
6426
- return hashQueryKey(queryKey) === hashQueryKey(x.queryKey);
6427
- });
6428
-
6429
- if (result) {
6430
- result.defaultOptions = options;
6431
- } else {
6432
- this.queryDefaults.push({
6433
- queryKey: queryKey,
6434
- defaultOptions: options
6435
- });
6436
- }
6437
- };
6438
-
6439
- _proto.getQueryDefaults = function getQueryDefaults(queryKey) {
6440
- var _this$queryDefaults$f;
6441
-
6442
- return queryKey ? (_this$queryDefaults$f = this.queryDefaults.find(function (x) {
6443
- return partialMatchKey(queryKey, x.queryKey);
6444
- })) == null ? void 0 : _this$queryDefaults$f.defaultOptions : undefined;
6445
- };
6446
-
6447
- _proto.setMutationDefaults = function setMutationDefaults(mutationKey, options) {
6448
- var result = this.mutationDefaults.find(function (x) {
6449
- return hashQueryKey(mutationKey) === hashQueryKey(x.mutationKey);
6450
- });
6451
-
6452
- if (result) {
6453
- result.defaultOptions = options;
6454
- } else {
6455
- this.mutationDefaults.push({
6456
- mutationKey: mutationKey,
6457
- defaultOptions: options
6458
- });
6459
- }
6460
- };
6461
-
6462
- _proto.getMutationDefaults = function getMutationDefaults(mutationKey) {
6463
- var _this$mutationDefault;
6464
-
6465
- return mutationKey ? (_this$mutationDefault = this.mutationDefaults.find(function (x) {
6466
- return partialMatchKey(mutationKey, x.mutationKey);
6467
- })) == null ? void 0 : _this$mutationDefault.defaultOptions : undefined;
6468
- };
6469
-
6470
- _proto.defaultQueryOptions = function defaultQueryOptions(options) {
6471
- if (options == null ? void 0 : options._defaulted) {
6472
- return options;
6473
- }
6474
-
6475
- var defaultedOptions = _extends({}, this.defaultOptions.queries, this.getQueryDefaults(options == null ? void 0 : options.queryKey), options, {
6476
- _defaulted: true
6477
- });
6478
-
6479
- if (!defaultedOptions.queryHash && defaultedOptions.queryKey) {
6480
- defaultedOptions.queryHash = hashQueryKeyByOptions(defaultedOptions.queryKey, defaultedOptions);
6481
- }
6482
-
6483
- return defaultedOptions;
6484
- };
6485
-
6486
- _proto.defaultQueryObserverOptions = function defaultQueryObserverOptions(options) {
6487
- return this.defaultQueryOptions(options);
6488
- };
6489
-
6490
- _proto.defaultMutationOptions = function defaultMutationOptions(options) {
6491
- if (options == null ? void 0 : options._defaulted) {
6492
- return options;
6493
- }
6494
-
6495
- return _extends({}, this.defaultOptions.mutations, this.getMutationDefaults(options == null ? void 0 : options.mutationKey), options, {
6496
- _defaulted: true
6497
- });
6498
- };
6499
-
6500
- _proto.clear = function clear() {
6501
- this.queryCache.clear();
6502
- this.mutationCache.clear();
6503
- };
6504
-
6505
- return QueryClient;
6506
- }();
6507
-
6508
- var QueryObserver = /*#__PURE__*/function (_Subscribable) {
6509
- _inheritsLoose(QueryObserver, _Subscribable);
6510
-
6511
- function QueryObserver(client, options) {
6512
- var _this;
6513
-
6514
- _this = _Subscribable.call(this) || this;
6515
- _this.client = client;
6516
- _this.options = options;
6517
- _this.trackedProps = [];
6518
- _this.selectError = null;
6519
-
6520
- _this.bindMethods();
6521
-
6522
- _this.setOptions(options);
6523
-
6524
- return _this;
6525
- }
6526
-
6527
- var _proto = QueryObserver.prototype;
6528
-
6529
- _proto.bindMethods = function bindMethods() {
6530
- this.remove = this.remove.bind(this);
6531
- this.refetch = this.refetch.bind(this);
6532
- };
6533
-
6534
- _proto.onSubscribe = function onSubscribe() {
6535
- if (this.listeners.length === 1) {
6536
- this.currentQuery.addObserver(this);
6537
-
6538
- if (shouldFetchOnMount(this.currentQuery, this.options)) {
6539
- this.executeFetch();
6540
- }
6541
-
6542
- this.updateTimers();
6543
- }
6544
- };
6545
-
6546
- _proto.onUnsubscribe = function onUnsubscribe() {
6547
- if (!this.listeners.length) {
6548
- this.destroy();
6549
- }
6550
- };
6551
-
6552
- _proto.shouldFetchOnReconnect = function shouldFetchOnReconnect() {
6553
- return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnReconnect);
6554
- };
6555
-
6556
- _proto.shouldFetchOnWindowFocus = function shouldFetchOnWindowFocus() {
6557
- return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnWindowFocus);
6558
- };
6559
-
6560
- _proto.destroy = function destroy() {
6561
- this.listeners = [];
6562
- this.clearTimers();
6563
- this.currentQuery.removeObserver(this);
6564
- };
6565
-
6566
- _proto.setOptions = function setOptions(options, notifyOptions) {
6567
- var prevOptions = this.options;
6568
- var prevQuery = this.currentQuery;
6569
- this.options = this.client.defaultQueryObserverOptions(options);
6570
-
6571
- if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
6572
- throw new Error('Expected enabled to be a boolean');
6573
- } // Keep previous query key if the user does not supply one
6574
-
6575
-
6576
- if (!this.options.queryKey) {
6577
- this.options.queryKey = prevOptions.queryKey;
6578
- }
6579
-
6580
- this.updateQuery();
6581
- var mounted = this.hasListeners(); // Fetch if there are subscribers
6582
-
6583
- if (mounted && shouldFetchOptionally(this.currentQuery, prevQuery, this.options, prevOptions)) {
6584
- this.executeFetch();
6585
- } // Update result
6586
-
6587
-
6588
- this.updateResult(notifyOptions); // Update stale interval if needed
6589
-
6590
- if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
6591
- this.updateStaleTimeout();
6592
- }
6593
-
6594
- var nextRefetchInterval = this.computeRefetchInterval(); // Update refetch interval if needed
6595
-
6596
- if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.currentRefetchInterval)) {
6597
- this.updateRefetchInterval(nextRefetchInterval);
6598
- }
6599
- };
6600
-
6601
- _proto.getOptimisticResult = function getOptimisticResult(options) {
6602
- var defaultedOptions = this.client.defaultQueryObserverOptions(options);
6603
- var query = this.client.getQueryCache().build(this.client, defaultedOptions);
6604
- return this.createResult(query, defaultedOptions);
6605
- };
6606
-
6607
- _proto.getCurrentResult = function getCurrentResult() {
6608
- return this.currentResult;
6609
- };
6610
-
6611
- _proto.trackResult = function trackResult(result, defaultedOptions) {
6612
- var _this2 = this;
6613
-
6614
- var trackedResult = {};
6615
-
6616
- var trackProp = function trackProp(key) {
6617
- if (!_this2.trackedProps.includes(key)) {
6618
- _this2.trackedProps.push(key);
6619
- }
6620
- };
6621
-
6622
- Object.keys(result).forEach(function (key) {
6623
- Object.defineProperty(trackedResult, key, {
6624
- configurable: false,
6625
- enumerable: true,
6626
- get: function get() {
6627
- trackProp(key);
6628
- return result[key];
6629
- }
6630
- });
6631
- });
6632
-
6633
- if (defaultedOptions.useErrorBoundary || defaultedOptions.suspense) {
6634
- trackProp('error');
6635
- }
6636
-
6637
- return trackedResult;
6638
- };
6639
-
6640
- _proto.getNextResult = function getNextResult(options) {
6641
- var _this3 = this;
6642
-
6643
- return new Promise(function (resolve, reject) {
6644
- var unsubscribe = _this3.subscribe(function (result) {
6645
- if (!result.isFetching) {
6646
- unsubscribe();
6647
-
6648
- if (result.isError && (options == null ? void 0 : options.throwOnError)) {
6649
- reject(result.error);
6650
- } else {
6651
- resolve(result);
6652
- }
6653
- }
6654
- });
6655
- });
6656
- };
6657
-
6658
- _proto.getCurrentQuery = function getCurrentQuery() {
6659
- return this.currentQuery;
6660
- };
6661
-
6662
- _proto.remove = function remove() {
6663
- this.client.getQueryCache().remove(this.currentQuery);
6664
- };
6665
-
6666
- _proto.refetch = function refetch(options) {
6667
- return this.fetch(_extends({}, options, {
6668
- meta: {
6669
- refetchPage: options == null ? void 0 : options.refetchPage
6670
- }
6671
- }));
6672
- };
6673
-
6674
- _proto.fetchOptimistic = function fetchOptimistic(options) {
6675
- var _this4 = this;
6676
-
6677
- var defaultedOptions = this.client.defaultQueryObserverOptions(options);
6678
- var query = this.client.getQueryCache().build(this.client, defaultedOptions);
6679
- return query.fetch().then(function () {
6680
- return _this4.createResult(query, defaultedOptions);
6681
- });
6682
- };
6683
-
6684
- _proto.fetch = function fetch(fetchOptions) {
6685
- var _this5 = this;
6686
-
6687
- return this.executeFetch(fetchOptions).then(function () {
6688
- _this5.updateResult();
6689
-
6690
- return _this5.currentResult;
6691
- });
6692
- };
6693
-
6694
- _proto.executeFetch = function executeFetch(fetchOptions) {
6695
- // Make sure we reference the latest query as the current one might have been removed
6696
- this.updateQuery(); // Fetch
6697
-
6698
- var promise = this.currentQuery.fetch(this.options, fetchOptions);
6699
-
6700
- if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
6701
- promise = promise.catch(noop);
6702
- }
6703
-
6704
- return promise;
6705
- };
6706
-
6707
- _proto.updateStaleTimeout = function updateStaleTimeout() {
6708
- var _this6 = this;
6709
-
6710
- this.clearStaleTimeout();
6711
-
6712
- if (isServer || this.currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
6713
- return;
6714
- }
6715
-
6716
- var time = timeUntilStale(this.currentResult.dataUpdatedAt, this.options.staleTime); // The timeout is sometimes triggered 1 ms before the stale time expiration.
6717
- // To mitigate this issue we always add 1 ms to the timeout.
6718
-
6719
- var timeout = time + 1;
6720
- this.staleTimeoutId = setTimeout(function () {
6721
- if (!_this6.currentResult.isStale) {
6722
- _this6.updateResult();
6723
- }
6724
- }, timeout);
6725
- };
6726
-
6727
- _proto.computeRefetchInterval = function computeRefetchInterval() {
6728
- var _this$options$refetch;
6729
-
6730
- return typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(this.currentResult.data, this.currentQuery) : (_this$options$refetch = this.options.refetchInterval) != null ? _this$options$refetch : false;
6731
- };
6732
-
6733
- _proto.updateRefetchInterval = function updateRefetchInterval(nextInterval) {
6734
- var _this7 = this;
6735
-
6736
- this.clearRefetchInterval();
6737
- this.currentRefetchInterval = nextInterval;
6738
-
6739
- if (isServer || this.options.enabled === false || !isValidTimeout(this.currentRefetchInterval) || this.currentRefetchInterval === 0) {
6740
- return;
6741
- }
6742
-
6743
- this.refetchIntervalId = setInterval(function () {
6744
- if (_this7.options.refetchIntervalInBackground || focusManager.isFocused()) {
6745
- _this7.executeFetch();
6746
- }
6747
- }, this.currentRefetchInterval);
6748
- };
6749
-
6750
- _proto.updateTimers = function updateTimers() {
6751
- this.updateStaleTimeout();
6752
- this.updateRefetchInterval(this.computeRefetchInterval());
6753
- };
6754
-
6755
- _proto.clearTimers = function clearTimers() {
6756
- this.clearStaleTimeout();
6757
- this.clearRefetchInterval();
6758
- };
6759
-
6760
- _proto.clearStaleTimeout = function clearStaleTimeout() {
6761
- if (this.staleTimeoutId) {
6762
- clearTimeout(this.staleTimeoutId);
6763
- this.staleTimeoutId = undefined;
6764
- }
6765
- };
6766
-
6767
- _proto.clearRefetchInterval = function clearRefetchInterval() {
6768
- if (this.refetchIntervalId) {
6769
- clearInterval(this.refetchIntervalId);
6770
- this.refetchIntervalId = undefined;
6771
- }
6772
- };
6773
-
6774
- _proto.createResult = function createResult(query, options) {
6775
- var prevQuery = this.currentQuery;
6776
- var prevOptions = this.options;
6777
- var prevResult = this.currentResult;
6778
- var prevResultState = this.currentResultState;
6779
- var prevResultOptions = this.currentResultOptions;
6780
- var queryChange = query !== prevQuery;
6781
- var queryInitialState = queryChange ? query.state : this.currentQueryInitialState;
6782
- var prevQueryResult = queryChange ? this.currentResult : this.previousQueryResult;
6783
- var state = query.state;
6784
- var dataUpdatedAt = state.dataUpdatedAt,
6785
- error = state.error,
6786
- errorUpdatedAt = state.errorUpdatedAt,
6787
- isFetching = state.isFetching,
6788
- status = state.status;
6789
- var isPreviousData = false;
6790
- var isPlaceholderData = false;
6791
- var data; // Optimistically set result in fetching state if needed
6792
-
6793
- if (options.optimisticResults) {
6794
- var mounted = this.hasListeners();
6795
- var fetchOnMount = !mounted && shouldFetchOnMount(query, options);
6796
- var fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
6797
-
6798
- if (fetchOnMount || fetchOptionally) {
6799
- isFetching = true;
6800
-
6801
- if (!dataUpdatedAt) {
6802
- status = 'loading';
6803
- }
6804
- }
6805
- } // Keep previous data if needed
6806
-
6807
-
6808
- if (options.keepPreviousData && !state.dataUpdateCount && (prevQueryResult == null ? void 0 : prevQueryResult.isSuccess) && status !== 'error') {
6809
- data = prevQueryResult.data;
6810
- dataUpdatedAt = prevQueryResult.dataUpdatedAt;
6811
- status = prevQueryResult.status;
6812
- isPreviousData = true;
6813
- } // Select data if needed
6814
- else if (options.select && typeof state.data !== 'undefined') {
6815
- // Memoize select result
6816
- if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === this.selectFn) {
6817
- data = this.selectResult;
6818
- } else {
6819
- try {
6820
- this.selectFn = options.select;
6821
- data = options.select(state.data);
6822
-
6823
- if (options.structuralSharing !== false) {
6824
- data = replaceEqualDeep(prevResult == null ? void 0 : prevResult.data, data);
6825
- }
6826
-
6827
- this.selectResult = data;
6828
- this.selectError = null;
6829
- } catch (selectError) {
6830
- getLogger().error(selectError);
6831
- this.selectError = selectError;
6832
- }
6833
- }
6834
- } // Use query data
6835
- else {
6836
- data = state.data;
6837
- } // Show placeholder data if needed
6838
-
6839
-
6840
- if (typeof options.placeholderData !== 'undefined' && typeof data === 'undefined' && (status === 'loading' || status === 'idle')) {
6841
- var placeholderData; // Memoize placeholder data
6842
-
6843
- if ((prevResult == null ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
6844
- placeholderData = prevResult.data;
6845
- } else {
6846
- placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData() : options.placeholderData;
6847
-
6848
- if (options.select && typeof placeholderData !== 'undefined') {
6849
- try {
6850
- placeholderData = options.select(placeholderData);
6851
-
6852
- if (options.structuralSharing !== false) {
6853
- placeholderData = replaceEqualDeep(prevResult == null ? void 0 : prevResult.data, placeholderData);
6854
- }
6855
-
6856
- this.selectError = null;
6857
- } catch (selectError) {
6858
- getLogger().error(selectError);
6859
- this.selectError = selectError;
6860
- }
6861
- }
6862
- }
6863
-
6864
- if (typeof placeholderData !== 'undefined') {
6865
- status = 'success';
6866
- data = placeholderData;
6867
- isPlaceholderData = true;
6868
- }
6869
- }
6870
-
6871
- if (this.selectError) {
6872
- error = this.selectError;
6873
- data = this.selectResult;
6874
- errorUpdatedAt = Date.now();
6875
- status = 'error';
6876
- }
6877
-
6878
- var result = {
6879
- status: status,
6880
- isLoading: status === 'loading',
6881
- isSuccess: status === 'success',
6882
- isError: status === 'error',
6883
- isIdle: status === 'idle',
6884
- data: data,
6885
- dataUpdatedAt: dataUpdatedAt,
6886
- error: error,
6887
- errorUpdatedAt: errorUpdatedAt,
6888
- failureCount: state.fetchFailureCount,
6889
- errorUpdateCount: state.errorUpdateCount,
6890
- isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0,
6891
- isFetchedAfterMount: state.dataUpdateCount > queryInitialState.dataUpdateCount || state.errorUpdateCount > queryInitialState.errorUpdateCount,
6892
- isFetching: isFetching,
6893
- isRefetching: isFetching && status !== 'loading',
6894
- isLoadingError: status === 'error' && state.dataUpdatedAt === 0,
6895
- isPlaceholderData: isPlaceholderData,
6896
- isPreviousData: isPreviousData,
6897
- isRefetchError: status === 'error' && state.dataUpdatedAt !== 0,
6898
- isStale: isStale(query, options),
6899
- refetch: this.refetch,
6900
- remove: this.remove
6901
- };
6902
- return result;
6903
- };
6904
-
6905
- _proto.shouldNotifyListeners = function shouldNotifyListeners(result, prevResult) {
6906
- if (!prevResult) {
6907
- return true;
6908
- }
6909
-
6910
- var _this$options = this.options,
6911
- notifyOnChangeProps = _this$options.notifyOnChangeProps,
6912
- notifyOnChangePropsExclusions = _this$options.notifyOnChangePropsExclusions;
6913
-
6914
- if (!notifyOnChangeProps && !notifyOnChangePropsExclusions) {
6915
- return true;
6916
- }
6917
-
6918
- if (notifyOnChangeProps === 'tracked' && !this.trackedProps.length) {
6919
- return true;
6920
- }
6921
-
6922
- var includedProps = notifyOnChangeProps === 'tracked' ? this.trackedProps : notifyOnChangeProps;
6923
- return Object.keys(result).some(function (key) {
6924
- var typedKey = key;
6925
- var changed = result[typedKey] !== prevResult[typedKey];
6926
- var isIncluded = includedProps == null ? void 0 : includedProps.some(function (x) {
6927
- return x === key;
6928
- });
6929
- var isExcluded = notifyOnChangePropsExclusions == null ? void 0 : notifyOnChangePropsExclusions.some(function (x) {
6930
- return x === key;
6931
- });
6932
- return changed && !isExcluded && (!includedProps || isIncluded);
6933
- });
6934
- };
6935
-
6936
- _proto.updateResult = function updateResult(notifyOptions) {
6937
- var prevResult = this.currentResult;
6938
- this.currentResult = this.createResult(this.currentQuery, this.options);
6939
- this.currentResultState = this.currentQuery.state;
6940
- this.currentResultOptions = this.options; // Only notify if something has changed
6941
-
6942
- if (shallowEqualObjects(this.currentResult, prevResult)) {
6943
- return;
6944
- } // Determine which callbacks to trigger
6945
-
6946
-
6947
- var defaultNotifyOptions = {
6948
- cache: true
6949
- };
6950
-
6951
- if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && this.shouldNotifyListeners(this.currentResult, prevResult)) {
6952
- defaultNotifyOptions.listeners = true;
6953
- }
6954
-
6955
- this.notify(_extends({}, defaultNotifyOptions, notifyOptions));
6956
- };
6957
-
6958
- _proto.updateQuery = function updateQuery() {
6959
- var query = this.client.getQueryCache().build(this.client, this.options);
6960
-
6961
- if (query === this.currentQuery) {
6962
- return;
6963
- }
6964
-
6965
- var prevQuery = this.currentQuery;
6966
- this.currentQuery = query;
6967
- this.currentQueryInitialState = query.state;
6968
- this.previousQueryResult = this.currentResult;
6969
-
6970
- if (this.hasListeners()) {
6971
- prevQuery == null ? void 0 : prevQuery.removeObserver(this);
6972
- query.addObserver(this);
6973
- }
6974
- };
6975
-
6976
- _proto.onQueryUpdate = function onQueryUpdate(action) {
6977
- var notifyOptions = {};
6978
-
6979
- if (action.type === 'success') {
6980
- notifyOptions.onSuccess = true;
6981
- } else if (action.type === 'error' && !isCancelledError(action.error)) {
6982
- notifyOptions.onError = true;
6983
- }
6984
-
6985
- this.updateResult(notifyOptions);
6986
-
6987
- if (this.hasListeners()) {
6988
- this.updateTimers();
6989
- }
6990
- };
6991
-
6992
- _proto.notify = function notify(notifyOptions) {
6993
- var _this8 = this;
6994
-
6995
- notifyManager.batch(function () {
6996
- // First trigger the configuration callbacks
6997
- if (notifyOptions.onSuccess) {
6998
- _this8.options.onSuccess == null ? void 0 : _this8.options.onSuccess(_this8.currentResult.data);
6999
- _this8.options.onSettled == null ? void 0 : _this8.options.onSettled(_this8.currentResult.data, null);
7000
- } else if (notifyOptions.onError) {
7001
- _this8.options.onError == null ? void 0 : _this8.options.onError(_this8.currentResult.error);
7002
- _this8.options.onSettled == null ? void 0 : _this8.options.onSettled(undefined, _this8.currentResult.error);
7003
- } // Then trigger the listeners
7004
-
7005
-
7006
- if (notifyOptions.listeners) {
7007
- _this8.listeners.forEach(function (listener) {
7008
- listener(_this8.currentResult);
7009
- });
7010
- } // Then the cache listeners
7011
-
7012
-
7013
- if (notifyOptions.cache) {
7014
- _this8.client.getQueryCache().notify({
7015
- query: _this8.currentQuery,
7016
- type: 'observerResultsUpdated'
7017
- });
7018
- }
7019
- });
7020
- };
7021
-
7022
- return QueryObserver;
7023
- }(Subscribable);
7024
-
7025
- function shouldLoadOnMount(query, options) {
7026
- return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === 'error' && options.retryOnMount === false);
7027
- }
7028
-
7029
- function shouldFetchOnMount(query, options) {
7030
- return shouldLoadOnMount(query, options) || query.state.dataUpdatedAt > 0 && shouldFetchOn(query, options, options.refetchOnMount);
7031
- }
7032
-
7033
- function shouldFetchOn(query, options, field) {
7034
- if (options.enabled !== false) {
7035
- var value = typeof field === 'function' ? field(query) : field;
7036
- return value === 'always' || value !== false && isStale(query, options);
7037
- }
7038
-
7039
- return false;
7040
- }
7041
-
7042
- function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
7043
- return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== 'error') && isStale(query, options);
7044
- }
7045
-
7046
- function isStale(query, options) {
7047
- return query.isStaleByTime(options.staleTime);
7048
- }
7049
-
7050
- // CLASS
7051
- var MutationObserver = /*#__PURE__*/function (_Subscribable) {
7052
- _inheritsLoose(MutationObserver, _Subscribable);
7053
-
7054
- function MutationObserver(client, options) {
7055
- var _this;
7056
-
7057
- _this = _Subscribable.call(this) || this;
7058
- _this.client = client;
7059
-
7060
- _this.setOptions(options);
7061
-
7062
- _this.bindMethods();
7063
-
7064
- _this.updateResult();
7065
-
7066
- return _this;
7067
- }
7068
-
7069
- var _proto = MutationObserver.prototype;
7070
-
7071
- _proto.bindMethods = function bindMethods() {
7072
- this.mutate = this.mutate.bind(this);
7073
- this.reset = this.reset.bind(this);
7074
- };
7075
-
7076
- _proto.setOptions = function setOptions(options) {
7077
- this.options = this.client.defaultMutationOptions(options);
7078
- };
7079
-
7080
- _proto.onUnsubscribe = function onUnsubscribe() {
7081
- if (!this.listeners.length) {
7082
- var _this$currentMutation;
7083
-
7084
- (_this$currentMutation = this.currentMutation) == null ? void 0 : _this$currentMutation.removeObserver(this);
7085
- }
7086
- };
7087
-
7088
- _proto.onMutationUpdate = function onMutationUpdate(action) {
7089
- this.updateResult(); // Determine which callbacks to trigger
7090
-
7091
- var notifyOptions = {
7092
- listeners: true
7093
- };
7094
-
7095
- if (action.type === 'success') {
7096
- notifyOptions.onSuccess = true;
7097
- } else if (action.type === 'error') {
7098
- notifyOptions.onError = true;
7099
- }
7100
-
7101
- this.notify(notifyOptions);
7102
- };
7103
-
7104
- _proto.getCurrentResult = function getCurrentResult() {
7105
- return this.currentResult;
7106
- };
7107
-
7108
- _proto.reset = function reset() {
7109
- this.currentMutation = undefined;
7110
- this.updateResult();
7111
- this.notify({
7112
- listeners: true
7113
- });
7114
- };
7115
-
7116
- _proto.mutate = function mutate(variables, options) {
7117
- this.mutateOptions = options;
7118
-
7119
- if (this.currentMutation) {
7120
- this.currentMutation.removeObserver(this);
7121
- }
7122
-
7123
- this.currentMutation = this.client.getMutationCache().build(this.client, _extends({}, this.options, {
7124
- variables: typeof variables !== 'undefined' ? variables : this.options.variables
7125
- }));
7126
- this.currentMutation.addObserver(this);
7127
- return this.currentMutation.execute();
7128
- };
7129
-
7130
- _proto.updateResult = function updateResult() {
7131
- var state = this.currentMutation ? this.currentMutation.state : getDefaultState();
7132
-
7133
- var result = _extends({}, state, {
7134
- isLoading: state.status === 'loading',
7135
- isSuccess: state.status === 'success',
7136
- isError: state.status === 'error',
7137
- isIdle: state.status === 'idle',
7138
- mutate: this.mutate,
7139
- reset: this.reset
7140
- });
7141
-
7142
- this.currentResult = result;
7143
- };
7144
-
7145
- _proto.notify = function notify(options) {
7146
- var _this2 = this;
7147
-
7148
- notifyManager.batch(function () {
7149
- // First trigger the mutate callbacks
7150
- if (_this2.mutateOptions) {
7151
- if (options.onSuccess) {
7152
- _this2.mutateOptions.onSuccess == null ? void 0 : _this2.mutateOptions.onSuccess(_this2.currentResult.data, _this2.currentResult.variables, _this2.currentResult.context);
7153
- _this2.mutateOptions.onSettled == null ? void 0 : _this2.mutateOptions.onSettled(_this2.currentResult.data, null, _this2.currentResult.variables, _this2.currentResult.context);
7154
- } else if (options.onError) {
7155
- _this2.mutateOptions.onError == null ? void 0 : _this2.mutateOptions.onError(_this2.currentResult.error, _this2.currentResult.variables, _this2.currentResult.context);
7156
- _this2.mutateOptions.onSettled == null ? void 0 : _this2.mutateOptions.onSettled(undefined, _this2.currentResult.error, _this2.currentResult.variables, _this2.currentResult.context);
7157
- }
7158
- } // Then trigger the listeners
7159
-
7160
-
7161
- if (options.listeners) {
7162
- _this2.listeners.forEach(function (listener) {
7163
- listener(_this2.currentResult);
7164
- });
7165
- }
7166
- });
7167
- };
7168
-
7169
- return MutationObserver;
7170
- }(Subscribable);
7171
-
7172
- var unstable_batchedUpdates = ReactDOM.unstable_batchedUpdates;
7173
-
7174
- notifyManager.setBatchNotifyFunction(unstable_batchedUpdates);
7175
-
7176
- var logger = console;
7177
-
7178
- setLogger(logger);
7179
-
7180
- var defaultContext = /*#__PURE__*/React.createContext(undefined);
7181
- var QueryClientSharingContext = /*#__PURE__*/React.createContext(false); // if contextSharing is on, we share the first and at least one
7182
- // instance of the context across the window
7183
- // to ensure that if React Query is used across
7184
- // different bundles or microfrontends they will
7185
- // all use the same **instance** of context, regardless
7186
- // of module scoping.
7187
-
7188
- function getQueryClientContext(contextSharing) {
7189
- if (contextSharing && typeof window !== 'undefined') {
7190
- if (!window.ReactQueryClientContext) {
7191
- window.ReactQueryClientContext = defaultContext;
7192
- }
7193
-
7194
- return window.ReactQueryClientContext;
7195
- }
7196
-
7197
- return defaultContext;
7198
- }
7199
-
7200
- var useQueryClient = function useQueryClient() {
7201
- var queryClient = React.useContext(getQueryClientContext(React.useContext(QueryClientSharingContext)));
7202
-
7203
- if (!queryClient) {
7204
- throw new Error('No QueryClient set, use QueryClientProvider to set one');
7205
- }
7206
-
7207
- return queryClient;
7208
- };
7209
- var QueryClientProvider = function QueryClientProvider(_ref) {
7210
- var client = _ref.client,
7211
- _ref$contextSharing = _ref.contextSharing,
7212
- contextSharing = _ref$contextSharing === void 0 ? false : _ref$contextSharing,
7213
- children = _ref.children;
7214
- React.useEffect(function () {
7215
- client.mount();
7216
- return function () {
7217
- client.unmount();
7218
- };
7219
- }, [client]);
7220
- var Context = getQueryClientContext(contextSharing);
7221
- return /*#__PURE__*/React.createElement(QueryClientSharingContext.Provider, {
7222
- value: contextSharing
7223
- }, /*#__PURE__*/React.createElement(Context.Provider, {
7224
- value: client
7225
- }, children));
7226
- };
7227
-
7228
- function createValue() {
7229
- var _isReset = false;
7230
- return {
7231
- clearReset: function clearReset() {
7232
- _isReset = false;
7233
- },
7234
- reset: function reset() {
7235
- _isReset = true;
7236
- },
7237
- isReset: function isReset() {
7238
- return _isReset;
7239
- }
7240
- };
7241
- }
7242
-
7243
- var QueryErrorResetBoundaryContext = /*#__PURE__*/React.createContext(createValue()); // HOOK
7244
-
7245
- var useQueryErrorResetBoundary = function useQueryErrorResetBoundary() {
7246
- return React.useContext(QueryErrorResetBoundaryContext);
7247
- }; // COMPONENT
7248
-
7249
- function shouldThrowError(suspense, _useErrorBoundary, params) {
7250
- // Allow useErrorBoundary function to override throwing behavior on a per-error basis
7251
- if (typeof _useErrorBoundary === 'function') {
7252
- return _useErrorBoundary.apply(void 0, params);
7253
- } // Allow useErrorBoundary to override suspense's throwing behavior
7254
-
7255
-
7256
- if (typeof _useErrorBoundary === 'boolean') return _useErrorBoundary; // If suspense is enabled default to throwing errors
7257
-
7258
- return !!suspense;
7259
- }
7260
-
7261
- function useMutation(arg1, arg2, arg3) {
7262
- var mountedRef = React.useRef(false);
7263
-
7264
- var _React$useState = React.useState(0),
7265
- forceUpdate = _React$useState[1];
7266
-
7267
- var options = parseMutationArgs(arg1, arg2, arg3);
7268
- var queryClient = useQueryClient();
7269
- var obsRef = React.useRef();
7270
-
7271
- if (!obsRef.current) {
7272
- obsRef.current = new MutationObserver(queryClient, options);
7273
- } else {
7274
- obsRef.current.setOptions(options);
7275
- }
7276
-
7277
- var currentResult = obsRef.current.getCurrentResult();
7278
- React.useEffect(function () {
7279
- mountedRef.current = true;
7280
- var unsubscribe = obsRef.current.subscribe(notifyManager.batchCalls(function () {
7281
- if (mountedRef.current) {
7282
- forceUpdate(function (x) {
7283
- return x + 1;
7284
- });
7285
- }
7286
- }));
7287
- return function () {
7288
- mountedRef.current = false;
7289
- unsubscribe();
7290
- };
7291
- }, []);
7292
- var mutate = React.useCallback(function (variables, mutateOptions) {
7293
- obsRef.current.mutate(variables, mutateOptions).catch(noop);
7294
- }, []);
7295
-
7296
- if (currentResult.error && shouldThrowError(undefined, obsRef.current.options.useErrorBoundary, [currentResult.error])) {
7297
- throw currentResult.error;
7298
- }
7299
-
7300
- return _extends({}, currentResult, {
7301
- mutate: mutate,
7302
- mutateAsync: currentResult.mutate
7303
- });
7304
- }
7305
-
7306
- function useBaseQuery(options, Observer) {
7307
- var mountedRef = React.useRef(false);
7308
-
7309
- var _React$useState = React.useState(0),
7310
- forceUpdate = _React$useState[1];
7311
-
7312
- var queryClient = useQueryClient();
7313
- var errorResetBoundary = useQueryErrorResetBoundary();
7314
- var defaultedOptions = queryClient.defaultQueryObserverOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
7315
-
7316
- defaultedOptions.optimisticResults = true; // Include callbacks in batch renders
7317
-
7318
- if (defaultedOptions.onError) {
7319
- defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
7320
- }
7321
-
7322
- if (defaultedOptions.onSuccess) {
7323
- defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
7324
- }
7325
-
7326
- if (defaultedOptions.onSettled) {
7327
- defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
7328
- }
7329
-
7330
- if (defaultedOptions.suspense) {
7331
- // Always set stale time when using suspense to prevent
7332
- // fetching again when directly mounting after suspending
7333
- if (typeof defaultedOptions.staleTime !== 'number') {
7334
- defaultedOptions.staleTime = 1000;
7335
- } // Set cache time to 1 if the option has been set to 0
7336
- // when using suspense to prevent infinite loop of fetches
7337
-
7338
-
7339
- if (defaultedOptions.cacheTime === 0) {
7340
- defaultedOptions.cacheTime = 1;
7341
- }
7342
- }
7343
-
7344
- if (defaultedOptions.suspense || defaultedOptions.useErrorBoundary) {
7345
- // Prevent retrying failed query if the error boundary has not been reset yet
7346
- if (!errorResetBoundary.isReset()) {
7347
- defaultedOptions.retryOnMount = false;
7348
- }
7349
- }
7350
-
7351
- var _React$useState2 = React.useState(function () {
7352
- return new Observer(queryClient, defaultedOptions);
7353
- }),
7354
- observer = _React$useState2[0];
7355
-
7356
- var result = observer.getOptimisticResult(defaultedOptions);
7357
- React.useEffect(function () {
7358
- mountedRef.current = true;
7359
- errorResetBoundary.clearReset();
7360
- var unsubscribe = observer.subscribe(notifyManager.batchCalls(function () {
7361
- if (mountedRef.current) {
7362
- forceUpdate(function (x) {
7363
- return x + 1;
7364
- });
7365
- }
7366
- })); // Update result to make sure we did not miss any query updates
7367
- // between creating the observer and subscribing to it.
7368
-
7369
- observer.updateResult();
7370
- return function () {
7371
- mountedRef.current = false;
7372
- unsubscribe();
7373
- };
7374
- }, [errorResetBoundary, observer]);
7375
- React.useEffect(function () {
7376
- // Do not notify on updates because of changes in the options because
7377
- // these changes should already be reflected in the optimistic result.
7378
- observer.setOptions(defaultedOptions, {
7379
- listeners: false
7380
- });
7381
- }, [defaultedOptions, observer]); // Handle suspense
7382
-
7383
- if (defaultedOptions.suspense && result.isLoading) {
7384
- throw observer.fetchOptimistic(defaultedOptions).then(function (_ref) {
7385
- var data = _ref.data;
7386
- defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
7387
- defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
7388
- }).catch(function (error) {
7389
- errorResetBoundary.clearReset();
7390
- defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
7391
- defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
7392
- });
7393
- } // Handle error boundary
7394
-
7395
-
7396
- if (result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(defaultedOptions.suspense, defaultedOptions.useErrorBoundary, [result.error, observer.getCurrentQuery()])) {
7397
- throw result.error;
7398
- } // Handle result property usage tracking
7399
-
7400
-
7401
- if (defaultedOptions.notifyOnChangeProps === 'tracked') {
7402
- result = observer.trackResult(result, defaultedOptions);
7403
- }
7404
-
7405
- return result;
7406
- }
7407
-
7408
- function useQuery(arg1, arg2, arg3) {
7409
- var parsedOptions = parseQueryArgs(arg1, arg2, arg3);
7410
- return useBaseQuery(parsedOptions, QueryObserver);
7411
- }
7412
-
7413
4241
  const queryClient = new QueryClient({
7414
4242
  queryCache: new QueryCache()
7415
4243
  });
7416
4244
 
7417
- var devtools = {exports: {}};
7418
-
7419
- {
7420
- devtools.exports = {
7421
- ReactQueryDevtools: function () {
7422
- return null
7423
- },
7424
- ReactQueryDevtoolsPanel: function () {
7425
- return null
7426
- },
7427
- };
7428
- }
7429
-
7430
4245
  const withReactQuery = Component => {
7431
4246
  const QueryWrapper = props => /*#__PURE__*/React.createElement(QueryClientProvider, {
7432
4247
  client: queryClient
7433
- }, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(devtools.exports.ReactQueryDevtools, {
4248
+ }, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(ReactQueryDevtools, {
7434
4249
  initialIsOpen: false,
7435
4250
  position: "bottom-right"
7436
4251
  }));
@@ -7527,7 +4342,7 @@ const useUpdateRole = _ref2 => {
7527
4342
  };
7528
4343
  const useDestroyRole = _ref4 => {
7529
4344
  let _ref4$onSuccess = _ref4.onSuccess,
7530
- onSuccess = _ref4$onSuccess === void 0 ? noop$1 : _ref4$onSuccess,
4345
+ onSuccess = _ref4$onSuccess === void 0 ? noop : _ref4$onSuccess,
7531
4346
  options = _objectWithoutProperties(_ref4, _excluded3$1);
7532
4347
  return useMutation(_ref5 => {
7533
4348
  let id = _ref5.id,
@@ -9934,7 +6749,7 @@ const Header = _ref => {
9934
6749
  var _permissions$create, _permissions$create2;
9935
6750
  let metaName = _ref.metaName,
9936
6751
  _ref$onClick = _ref.onClick,
9937
- onClick = _ref$onClick === void 0 ? noop$1 : _ref$onClick,
6752
+ onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
9938
6753
  permissions = _ref.permissions;
9939
6754
  return /*#__PURE__*/React.createElement(Tooltip, {
9940
6755
  content: instance.t("tooltips.noPermissionToAddMember"),
@@ -9950,6 +6765,21 @@ const Header = _ref => {
9950
6765
  })));
9951
6766
  };
9952
6767
 
6768
+ function _extends() {
6769
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
6770
+ for (var i = 1; i < arguments.length; i++) {
6771
+ var source = arguments[i];
6772
+ for (var key in source) {
6773
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6774
+ target[key] = source[key];
6775
+ }
6776
+ }
6777
+ }
6778
+ return target;
6779
+ };
6780
+ return _extends.apply(this, arguments);
6781
+ }
6782
+
9953
6783
  const getStorageValue = (key, defaultValue) => {
9954
6784
  const saved = localStorage.getItem(key);
9955
6785
  return JSON.parse(saved) || defaultValue;
@@ -10083,9 +6913,6 @@ const Columns = _ref => {
10083
6913
 
10084
6914
  const FIXED_COLUMNS = ["actions"];
10085
6915
  const COLUMNS_DROPDOWN_PROPS = {
10086
- buttonProps: {
10087
- size: "small"
10088
- },
10089
6916
  label: instance.t("common.column", PLURAL)
10090
6917
  };
10091
6918
  const COLUMNS_SEARCH_PROPS = {
@@ -10132,39 +6959,49 @@ const RolesDropdown = _ref => {
10132
6959
  setSearchTerm("");
10133
6960
  setIsDropdownOpen(false);
10134
6961
  };
10135
- return /*#__PURE__*/React.createElement(Tooltip, {
10136
- content: instance.t("tooltips.noPermissionToEditMembers"),
10137
- disabled: hasUpdatePermission,
10138
- position: "top"
10139
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Dropdown, {
10140
- buttonSize: "small",
6962
+ const handleClick = event => {
6963
+ event.stopPropagation();
6964
+ setIsDropdownOpen(!isDropdownOpen);
6965
+ };
6966
+ return /*#__PURE__*/React.createElement(Dropdown, {
10141
6967
  buttonStyle: "secondary",
10142
6968
  closeOnSelect: false,
10143
- "data-cy": "ntm-members-roles-update-dropdown",
6969
+ customTarget: /*#__PURE__*/React.createElement(MenuItem.Button, {
6970
+ suffix: /*#__PURE__*/React.createElement(Right$1, {
6971
+ size: 16
6972
+ })
6973
+ }, instance.t("buttons.changeRole")),
6974
+ "data-cy": "ntm-members-roles-update-dropdown-button",
10144
6975
  disabled: !hasUpdatePermission,
10145
- label: instance.t("buttons.changeRole"),
10146
6976
  isOpen: isDropdownOpen,
10147
- onClick: () => setIsDropdownOpen(true),
10148
- onClose: () => handleOnClose(),
10149
- position: "bottom-end"
10150
- }, /*#__PURE__*/React.createElement(Menu$1, null, /*#__PURE__*/React.createElement("div", null, isSearchable && /*#__PURE__*/React.createElement(Input$1, {
6977
+ onClick: handleClick,
6978
+ onClose: handleOnClose,
6979
+ position: "auto-end"
6980
+ }, /*#__PURE__*/React.createElement(Menu$1, null, isSearchable && /*#__PURE__*/React.createElement("div", {
10151
6981
  className: "neeto-ui-px-3 neeto-ui-py-2",
6982
+ onClick: e => {
6983
+ e.stopPropagation();
6984
+ }
6985
+ }, /*#__PURE__*/React.createElement(Input$1, {
10152
6986
  "data-cy": "ntm-members-roles-search-input",
10153
6987
  onChange: handleSearch,
10154
6988
  placeholder: instance.t("helpers.searchRoles"),
10155
6989
  prefix: /*#__PURE__*/React.createElement(Search, null),
10156
6990
  type: "search",
10157
6991
  value: searchTerm
10158
- }), isNotEmpty$1(filteredRoles) ? filteredRoles.map(_ref3 => {
6992
+ })), isNotEmpty$1(filteredRoles) ? filteredRoles.map(_ref3 => {
10159
6993
  let id = _ref3.id,
10160
6994
  name = _ref3.name;
10161
6995
  return /*#__PURE__*/React.createElement(MenuItem.Button, {
10162
6996
  key: id,
10163
6997
  onClick: () => handleSelectRole(name)
10164
6998
  }, name);
10165
- }) : /*#__PURE__*/React.createElement("span", {
10166
- className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-items-center neeto-ui-p-2"
10167
- }, instance.t("helpers.noRolesFound")))))));
6999
+ }) : /*#__PURE__*/React.createElement("div", {
7000
+ className: "neeto-ui-flex neeto-ui-justify-center neeto-ui-p-1"
7001
+ }, /*#__PURE__*/React.createElement(Typography, {
7002
+ className: "neeto-ui-text-gray-700",
7003
+ style: "body2"
7004
+ }, instance.t("helpers.noRolesFound")))));
10168
7005
  };
10169
7006
 
10170
7007
  var _URLSearchParams$get;
@@ -10214,10 +7051,13 @@ const DEFAULT_SELECTED_ROWS = {
10214
7051
  };
10215
7052
 
10216
7053
  const Left = _ref => {
10217
- var _selectedRows$keys, _selectedRows$keys2;
10218
- let filteredCount = _ref.filteredCount,
7054
+ var _selectedRows$keys, _selectedRows$keys2, _config$permissions$u, _config$permissions;
7055
+ let config = _ref.config,
7056
+ filteredCount = _ref.filteredCount,
10219
7057
  metaName = _ref.metaName,
7058
+ roles = _ref.roles,
10220
7059
  selectedRows = _ref.selectedRows,
7060
+ setSelectedRows = _ref.setSelectedRows,
10221
7061
  totalCount = _ref.totalCount;
10222
7062
  const hasSelectedRows = isNotEmpty$1(selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.keys);
10223
7063
  const pluralizedByFilterCount = metaName({
@@ -10227,28 +7067,8 @@ const Left = _ref => {
10227
7067
  count: selectedRows === null || selectedRows === void 0 ? void 0 : (_selectedRows$keys = selectedRows.keys) === null || _selectedRows$keys === void 0 ? void 0 : _selectedRows$keys.length,
10228
7068
  metaName: metaName({
10229
7069
  count: selectedRows === null || selectedRows === void 0 ? void 0 : (_selectedRows$keys2 = selectedRows.keys) === null || _selectedRows$keys2 === void 0 ? void 0 : _selectedRows$keys2.length
10230
- }).toLocaleLowerCase(),
10231
- totalCount
7070
+ }).toLocaleLowerCase()
10232
7071
  };
10233
- return /*#__PURE__*/React.createElement(Typography, {
10234
- "data-cy": "ntm-filtered-members-count",
10235
- component: "h4",
10236
- style: "h4"
10237
- }, hasSelectedRows ? /*#__PURE__*/React.createElement(Trans, {
10238
- i18nKey: "helpers.selectedMembersCount",
10239
- values: selectedMembersCountValues
10240
- }) : `${filteredCount} ${pluralizedByFilterCount}`);
10241
- };
10242
- const Right = _ref2 => {
10243
- var _config$permissions$u, _config$permissions;
10244
- let columns = _ref2.columns,
10245
- config = _ref2.config,
10246
- roles = _ref2.roles,
10247
- rolesButtonProps = _ref2.rolesButtonProps,
10248
- selectedRows = _ref2.selectedRows,
10249
- setColumnData = _ref2.setColumnData,
10250
- setSelectedRows = _ref2.setSelectedRows;
10251
- const isRolesButtonVisible = !!rolesButtonProps;
10252
7072
  const hasUpdatePermission = (_config$permissions$u = config === null || config === void 0 ? void 0 : (_config$permissions = config.permissions) === null || _config$permissions === void 0 ? void 0 : _config$permissions.update) !== null && _config$permissions$u !== void 0 ? _config$permissions$u : DEFAULT_PERMISSION;
10253
7073
  const _useBulkUpdateMembers = useBulkUpdateMembers({
10254
7074
  onSuccess: () => setSelectedRows(DEFAULT_SELECTED_ROWS)
@@ -10275,33 +7095,48 @@ const Right = _ref2 => {
10275
7095
  }
10276
7096
  });
10277
7097
  };
10278
- return /*#__PURE__*/React.createElement(React.Fragment, null, getDeactivatedButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(Tooltip, {
7098
+ const Menu = Dropdown.Menu,
7099
+ MenuItem = Dropdown.MenuItem;
7100
+ return /*#__PURE__*/React.createElement("div", {
7101
+ className: "flex items-center gap-4"
7102
+ }, /*#__PURE__*/React.createElement(Typography, {
7103
+ component: "h4",
7104
+ "data-cy": "ntm-filtered-members-count",
7105
+ style: "h4"
7106
+ }, hasSelectedRows ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Trans, {
7107
+ i18nKey: "helpers.selectedMembersCount",
7108
+ values: selectedMembersCountValues
7109
+ }), /*#__PURE__*/React.createElement("span", {
7110
+ className: "neeto-ui-text-gray-600"
7111
+ }, " ", totalCount)) : `${filteredCount} ${pluralizedByFilterCount}`), hasSelectedRows && /*#__PURE__*/React.createElement(Tooltip, {
10279
7112
  content: instance.t("tooltips.noPermissionToEditMembers"),
10280
7113
  disabled: hasUpdatePermission,
10281
7114
  position: "top"
10282
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Button, {
7115
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Dropdown, {
7116
+ "data-cy": "ntm-members-take-action-dropdown-button",
7117
+ buttonStyle: "secondary",
7118
+ disabled: !hasUpdatePermission,
7119
+ label: instance.t("common.takeAction")
7120
+ }, /*#__PURE__*/React.createElement(Menu, null, getDeactivatedButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(MenuItem.Button, {
10283
7121
  "data-cy": "ntm-deactivate-members-button",
10284
7122
  disabled: !hasUpdatePermission,
10285
- label: instance.t("common.deactivate"),
10286
- size: "small",
10287
- style: "secondary",
10288
7123
  onClick: () => handleDeactivateMembers()
10289
- }))), getActivateButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(Tooltip, {
10290
- content: instance.t("tooltips.noPermissionToEditMembers"),
10291
- disabled: hasUpdatePermission,
10292
- position: "top"
10293
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Button, {
7124
+ }, instance.t("common.deactivate")), getActivateButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(MenuItem.Button, {
10294
7125
  "data-cy": "ntm-activate-members-button",
10295
7126
  disabled: !hasUpdatePermission,
10296
- label: instance.t("common.activate"),
10297
- size: "small",
10298
- style: "secondary",
10299
7127
  onClick: () => handleActivateMembers()
10300
- }))), isNotEmpty$1(selectedRows.keys) && /*#__PURE__*/React.createElement(RolesDropdown, {
7128
+ }, instance.t("common.activate")), /*#__PURE__*/React.createElement(RolesDropdown, {
10301
7129
  handleRoleChange: handleRoleChange,
10302
7130
  hasUpdatePermission: hasUpdatePermission,
10303
7131
  roles: roles
10304
- }), /*#__PURE__*/React.createElement(Columns, {
7132
+ }))))));
7133
+ };
7134
+ const Right = _ref2 => {
7135
+ let columns = _ref2.columns,
7136
+ rolesButtonProps = _ref2.rolesButtonProps,
7137
+ setColumnData = _ref2.setColumnData;
7138
+ const isRolesButtonVisible = !!rolesButtonProps;
7139
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Columns, {
10305
7140
  columnData: columns,
10306
7141
  dropdownProps: COLUMNS_DROPDOWN_PROPS,
10307
7142
  fixedColumns: FIXED_COLUMNS,
@@ -10312,7 +7147,6 @@ const Right = _ref2 => {
10312
7147
  }), isRolesButtonVisible ? /*#__PURE__*/React.createElement(Button, _extends({
10313
7148
  "data-cy": "ntm-manage-roles-button",
10314
7149
  label: MANAGE_ROLES_BUTTON_LABEL,
10315
- size: "small",
10316
7150
  style: "secondary"
10317
7151
  }, rolesButtonProps)) : null);
10318
7152
  };
@@ -11402,19 +8236,18 @@ const TeamMembers = _ref => {
11402
8236
  })
11403
8237
  }), /*#__PURE__*/React.createElement(SubHeader$1, {
11404
8238
  leftActionBlock: /*#__PURE__*/React.createElement(SubHeader.Left, {
8239
+ config: config,
11405
8240
  filteredCount: team === null || team === void 0 ? void 0 : team.membersCount,
11406
8241
  metaName: metaName,
8242
+ roles: roles,
11407
8243
  selectedRows: selectedRows,
8244
+ setSelectedRows: setSelectedRows,
11408
8245
  totalCount: currentCategoryCount
11409
8246
  }),
11410
8247
  rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.Right, {
11411
8248
  columns: columns,
11412
- config: config,
11413
- roles: roles,
11414
8249
  rolesButtonProps: config.rolesButtonProps,
11415
- selectedRows: selectedRows,
11416
- setColumnData: setColumnData,
11417
- setSelectedRows: setSelectedRows
8250
+ setColumnData: setColumnData
11418
8251
  })
11419
8252
  }), (team === null || team === void 0 ? void 0 : team.membersCount) !== 0 ? /*#__PURE__*/React.createElement("div", {
11420
8253
  className: "ntm-members__table-wrapper"
@@ -11480,7 +8313,7 @@ const VALIDATION_SCHEMA = {
11480
8313
 
11481
8314
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
11482
8315
 
11483
- var css = ":root {\n --ntm-roles-table-default-scroll: 15px;\n --ntm-roles-table-cell-height: 68px;\n}\n\n.ntm-dropdown__button {\n border-radius: 0 !important;\n font-weight: var(--neeto-ui-font-normal);\n min-height: 34px;\n min-width: 150px;\n text-align: left;\n width: 100%;\n}\n\n.ntm-scrollbar__inner {\n width: 100%;\n height: 200px;\n}\n.ntm-scrollbar__outer {\n position: \"absolute\";\n top: 0px;\n left: 0px;\n width: 200px;\n height: 150px;\n overflow: \"hidden\";\n visibility: \"hidden\";\n}\n\n.ntm-empty-state {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: center;\n width: 100%;\n}\n.ntm-empty-state__image {\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 2rem;\n}\n.ntm-empty-state__title--with-action-block {\n margin-bottom: 1rem;\n}\n.ntm-empty-state__action-block {\n display: flex;\n justify-content: center;\n}\n\n.ntm-members {\n overflow: auto;\n width: 100%;\n}\n.ntm-members-wrapper {\n display: flex;\n}\n.ntm-members-page-loader {\n width: 100%;\n height: 100vh;\n}\n.ntm-members__table-wrapper {\n height: calc(100vh - 205px);\n width: 100%;\n}\n.ntm-members-table__column {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n.ntm-members-pane__header {\n margin-bottom: 0.5rem;\n}\n.ntm-members-pane__body {\n width: 100%;\n padding-bottom: 1rem;\n}\n.ntm-members-pane__body > * + * {\n margin-top: 1rem;\n}\n.ntm-members-pane__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-members-radio-group {\n width: 100%;\n}\n.ntm-members-radio-group .neeto-ui-radio__container--stacked {\n width: 100%;\n}\n.ntm-members-radio-group__label {\n padding-right: 4px;\n}\n.ntm-members-radio-group__icon {\n cursor: pointer;\n}\n\n.ntm-members-pane-radio-item__wrapper {\n width: 100%;\n cursor: pointer;\n padding: 8px 0px !important;\n}\n.ntm-members-pane-radio-item__wrapper:first-child {\n padding-top: 0px !important;\n}\n.ntm-members-pane-radio-item__label {\n margin-bottom: 0 !important;\n}\n.ntm-members-pane-radio-item__description {\n color: rgb(var(--neeto-ui-gray-700));\n}\n\n.ntm-roles-header {\n border-bottom: 1px solid rgb(var(--neeto-ui-gray-300));\n}\n\n.ntm-roles-table__wrapper {\n width: 100%;\n height: calc(100vh - var(--neeto-ui-main-header-with-breadcrumbs-height));\n display: flex;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar {\n width: 396px;\n min-width: 396px;\n border-right: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__search {\n padding: 24px 24px 16px;\n height: 72px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list {\n height: calc(\n 100vh - var(--neeto-ui-main-header-with-breadcrumbs-height) - 72px -\n var(--ntm-roles-table-default-scroll)\n );\n overflow-y: auto;\n padding-left: 24px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 8px;\n min-height: var(--ntm-roles-table-cell-height);\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item.ntm-roles-table-sidebar__list-item--highlighted {\n background-color: rgb(var(--neeto-ui-primary-100));\n padding: 12px 8px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item:not(.ntm-roles-table-sidebar__list-item--highlighted) {\n border-bottom: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns {\n width: calc(\n 100vw - var(--neeto-ui-sidebar-width) - 396px - 24px\n );\n overflow: hidden;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__cell {\n width: 100%;\n min-width: 200px;\n height: var(--ntm-roles-table-cell-height);\n padding: 12px 8px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-right: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table-cell__checkbox-wrapper {\n position: absolute;\n height: 1rem;\n width: 1rem;\n margin: auto;\n z-index: 10;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table-cell__checkbox {\n z-index: 10;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header {\n display: flex;\n align-items: center;\n overflow-x: auto;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table__cell {\n height: 72px;\n padding-left: 24px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header-cell__container {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n gap: 1rem;\n overflow: hidden;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header__dropdown {\n margin: 3px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header__role-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows {\n width: 100%;\n height: calc(\n 100vh - var(--neeto-ui-main-header-with-breadcrumbs-height) - 72px -\n var(--ntm-roles-table-default-scroll)\n );\n overflow-y: auto;\n scrollbar-width: none;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-thumb {\n background: rgb(var(--neeto-ui-gray-300));\n border-radius: 50px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-thumb:hover {\n border-radius: 50px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-track {\n background: rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row {\n display: flex;\n align-items: center;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row .ntm-roles-table__cell {\n overflow: hidden;\n position: relative;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row .ntm-roles-table__cell p {\n opacity: 0;\n width: 340px;\n min-width: 340px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row.ntm-roles-table__row--highlighted .ntm-roles-table__cell {\n background-color: rgb(var(--neeto-ui-primary-100));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row:not(.ntm-roles-table__row--highlighted) .ntm-roles-table__cell {\n border-bottom: thin solid rgb(var(--neeto-ui-gray-300));\n}\n\n.ntm-roles-table-sidebar__drop-down-button {\n color: rgb(var(--neeto-ui-gray-600));\n cursor: pointer;\n}\n\n.ntm-roles-modal__body > * + * {\n margin-top: 1rem;\n}\n.ntm-roles-modal__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-roles-pane__body {\n width: 100%;\n margin-bottom: 1.5rem;\n}\n.ntm-roles-pane__body-wrapper > * + * {\n margin-top: 1rem;\n}\n.ntm-roles-pane__body > * + * {\n margin-top: 1.5rem;\n}\n.ntm-roles-pane__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-roles-permission > * + * {\n margin: 0.5rem;\n}\n.ntm-roles-permission__heading {\n color: rgb(var(--neeto-ui-gray-500));\n text-transform: uppercase;\n}\n.ntm-roles-permission__card {\n background-color: rgb(var(--neeto-ui-white));\n align-items: center;\n border-radius: var(--neeto-ui-rounded);\n border-width: 1px;\n border-color: rgb(var(--neeto-ui-gray-300));\n cursor: pointer;\n display: flex;\n gap: 0.75rem;\n padding: 1rem 0.75rem;\n}\n.ntm-roles-permission__card--description {\n flex-grow: 1;\n}\n.ntm-roles-permission__card--checkbox {\n padding: 0 0.5rem;\n}\n\n.ntm-roles-help-url-wrapper {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n padding: 1rem 0;\n}\n\ntd.ant-table-column-sort {\n background: transparent;\n}";
8316
+ var css = ":root {\n --ntm-roles-table-default-scroll: 15px;\n --ntm-roles-table-cell-height: 68px;\n}\n\n.ntm-dropdown__button {\n border-radius: 0 !important;\n font-weight: var(--neeto-ui-font-normal);\n min-height: 34px;\n min-width: 150px;\n text-align: left;\n width: 100%;\n}\n\n.ntm-scrollbar__inner {\n width: 100%;\n height: 200px;\n}\n.ntm-scrollbar__outer {\n position: \"absolute\";\n top: 0px;\n left: 0px;\n width: 200px;\n height: 150px;\n overflow: \"hidden\";\n visibility: \"hidden\";\n}\n\n.ntm-empty-state {\n align-items: center;\n display: flex;\n height: 100%;\n justify-content: center;\n width: 100%;\n}\n.ntm-empty-state__image {\n display: flex;\n justify-content: center;\n align-items: center;\n margin-bottom: 2rem;\n}\n.ntm-empty-state__title--with-action-block {\n margin-bottom: 1rem;\n}\n.ntm-empty-state__action-block {\n display: flex;\n justify-content: center;\n}\n\n.ntm-members {\n overflow: auto;\n width: 100%;\n}\n.ntm-members-wrapper {\n display: flex;\n}\n.ntm-members-page-loader {\n width: 100%;\n height: 100vh;\n}\n.ntm-members__table-wrapper {\n height: calc(100vh - 205px);\n width: 100%;\n}\n.ntm-members-table__column {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n.ntm-members-pane__header {\n margin-bottom: 0.5rem;\n}\n.ntm-members-pane__body {\n width: 100%;\n padding-bottom: 1rem;\n}\n.ntm-members-pane__body > * + * {\n margin-top: 1rem;\n}\n.ntm-members-pane__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-members-radio-group {\n width: 100%;\n}\n.ntm-members-radio-group .neeto-ui-radio__container--stacked {\n width: 100%;\n}\n.ntm-members-radio-group__label {\n padding-right: 4px;\n}\n.ntm-members-radio-group__icon {\n cursor: pointer;\n}\n\n.ntm-members-pane-radio-item__wrapper {\n width: 100%;\n cursor: pointer;\n padding: 8px 0px !important;\n}\n.ntm-members-pane-radio-item__wrapper:first-child {\n padding-top: 0px !important;\n}\n.ntm-members-pane-radio-item__label {\n margin-bottom: 0 !important;\n}\n.ntm-members-pane-radio-item__description {\n color: rgb(var(--neeto-ui-gray-700));\n}\n\n.ntm-roles-header {\n border-bottom: 1px solid rgb(var(--neeto-ui-gray-300));\n}\n\n.ntm-roles-table__wrapper {\n width: 100%;\n height: calc(100vh - var(--neeto-ui-main-header-with-breadcrumbs-height));\n display: flex;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar {\n width: 396px;\n min-width: 396px;\n border-right: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__search {\n padding: 24px 24px 16px;\n height: 72px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list {\n height: calc(\n 100vh - var(--neeto-ui-main-header-with-breadcrumbs-height) - 72px -\n var(--ntm-roles-table-default-scroll)\n );\n overflow-y: auto;\n padding-left: 24px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 12px 8px;\n min-height: var(--ntm-roles-table-cell-height);\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item.ntm-roles-table-sidebar__list-item--highlighted {\n background-color: rgb(var(--neeto-ui-primary-100));\n padding: 12px 8px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__sidebar .ntm-roles-table-sidebar__list .ntm-roles-table-sidebar__list-item:not(.ntm-roles-table-sidebar__list-item--highlighted) {\n border-bottom: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns {\n width: calc(\n 100vw - var(--neeto-ui-sidebar-width) - 396px - 24px\n );\n overflow: hidden;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__cell {\n width: 100%;\n min-width: 200px;\n height: var(--ntm-roles-table-cell-height);\n padding: 12px 8px;\n display: flex;\n justify-content: center;\n align-items: center;\n border-right: thin solid rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table-cell__checkbox-wrapper {\n position: absolute;\n height: 1rem;\n width: 1rem;\n margin: auto;\n z-index: 10;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table-cell__checkbox {\n z-index: 10;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header {\n display: flex;\n align-items: center;\n overflow-x: auto;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table__cell {\n height: 72px;\n padding-left: 24px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header-cell__container {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n gap: 1rem;\n overflow: hidden;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header__dropdown {\n margin: 3px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__header .ntm-roles-table-header__role-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows {\n width: 100%;\n height: calc(\n 100vh - var(--neeto-ui-main-header-with-breadcrumbs-height) - 72px -\n var(--ntm-roles-table-default-scroll)\n );\n overflow-y: auto;\n scrollbar-width: none;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-thumb {\n background: rgb(var(--neeto-ui-gray-300));\n border-radius: 50px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-thumb:hover {\n border-radius: 50px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows::-webkit-scrollbar-track {\n background: rgb(var(--neeto-ui-gray-300));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row {\n display: flex;\n align-items: center;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row .ntm-roles-table__cell {\n overflow: hidden;\n position: relative;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row .ntm-roles-table__cell p {\n opacity: 0;\n width: 340px;\n min-width: 340px;\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row.ntm-roles-table__row--highlighted .ntm-roles-table__cell {\n background-color: rgb(var(--neeto-ui-primary-100));\n}\n.ntm-roles-table__wrapper .ntm-roles-table__columns .ntm-roles-table__rows .ntm-roles-table__row:not(.ntm-roles-table__row--highlighted) .ntm-roles-table__cell {\n border-bottom: thin solid rgb(var(--neeto-ui-gray-300));\n}\n\n.ntm-roles-table-sidebar__drop-down-button {\n color: rgb(var(--neeto-ui-gray-600));\n cursor: pointer;\n}\n\n.ntm-roles-modal__body > * + * {\n margin-top: 1rem;\n}\n.ntm-roles-modal__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-roles-pane__body {\n width: 100%;\n margin-bottom: 1.5rem;\n}\n.ntm-roles-pane__body-wrapper > * + * {\n margin-top: 1rem;\n}\n.ntm-roles-pane__body > * + * {\n margin-top: 1.5rem;\n}\n.ntm-roles-pane__footer {\n display: flex;\n gap: 0.5rem;\n}\n\n.ntm-roles-permission > * + * {\n margin: 0.5rem;\n}\n.ntm-roles-permission__heading {\n color: rgb(var(--neeto-ui-gray-500));\n text-transform: uppercase;\n}\n.ntm-roles-permission__card {\n background-color: rgb(var(--neeto-ui-white));\n align-items: center;\n border-radius: var(--neeto-ui-rounded);\n border-width: 1px;\n border-color: rgb(var(--neeto-ui-gray-300));\n cursor: pointer;\n display: flex;\n gap: 0.75rem;\n padding: 1rem 0.75rem;\n}\n.ntm-roles-permission__card--description {\n flex-grow: 1;\n}\n.ntm-roles-permission__card--checkbox {\n padding: 0 0.5rem;\n}\n\n.ntm-roles-help-url-wrapper {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n padding: 1rem 0;\n}\n\n.neeto-ui-subheader .neeto-ui-subheader__left-wrapper .neeto-ui-subheader__left {\n max-width: none;\n}\n\ntd.ant-table-column-sort {\n background: transparent;\n}";
11484
8317
  n(css,{});
11485
8318
 
11486
8319
  export { MultipleEmailInput, index$1 as Roles, RolesRadioGroup, index as TeamMembers, VALIDATION_SCHEMA, hasPermission, refetchMembers };