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

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,9 +1,10 @@
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
- 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
+ import { Toastr, Tooltip, Button, Typography, Checkbox, Pane, Dropdown, Alert, Input as Input$1, PageLoader, Label, Avatar, Tag, Modal, Table as Table$1 } from '@bigbinary/neetoui';
7
8
  import { Header as Header$2, Container, MenuBar, SubHeader as SubHeader$1 } from '@bigbinary/neetoui/layouts';
8
9
  import { useFormikContext } from 'formik';
9
10
  import { Form, Input, Textarea, MultiEmailInput, Radio } from '@bigbinary/neetoui/formik';
@@ -27,13 +28,29 @@ function _classCallCheck(instance, Constructor) {
27
28
  }
28
29
  }
29
30
 
31
+ function _toPrimitive(input, hint) {
32
+ if (_typeof(input) !== "object" || input === null) return input;
33
+ var prim = input[Symbol.toPrimitive];
34
+ if (prim !== undefined) {
35
+ var res = prim.call(input, hint || "default");
36
+ if (_typeof(res) !== "object") return res;
37
+ throw new TypeError("@@toPrimitive must return a primitive value.");
38
+ }
39
+ return (hint === "string" ? String : Number)(input);
40
+ }
41
+
42
+ function _toPropertyKey(arg) {
43
+ var key = _toPrimitive(arg, "string");
44
+ return _typeof(key) === "symbol" ? key : String(key);
45
+ }
46
+
30
47
  function _defineProperties(target, props) {
31
48
  for (var i = 0; i < props.length; i++) {
32
49
  var descriptor = props[i];
33
50
  descriptor.enumerable = descriptor.enumerable || false;
34
51
  descriptor.configurable = true;
35
52
  if ("value" in descriptor) descriptor.writable = true;
36
- Object.defineProperty(target, descriptor.key, descriptor);
53
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
37
54
  }
38
55
  }
39
56
  function _createClass(Constructor, protoProps, staticProps) {
@@ -94,6 +111,7 @@ function _getPrototypeOf(o) {
94
111
  }
95
112
 
96
113
  function _defineProperty(obj, key, value) {
114
+ key = _toPropertyKey(key);
97
115
  if (key in obj) {
98
116
  Object.defineProperty(obj, key, {
99
117
  value: value,
@@ -2358,7 +2376,7 @@ function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeRefl
2358
2376
 
2359
2377
  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
2378
 
2361
- function noop$2() {}
2379
+ function noop$1() {}
2362
2380
 
2363
2381
  function bindMemberFunctions(inst) {
2364
2382
  var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
@@ -2523,7 +2541,7 @@ var I18n = function (_EventEmitter) {
2523
2541
  }
2524
2542
 
2525
2543
  this.format = this.options.interpolation.format;
2526
- if (!callback) callback = noop$2;
2544
+ if (!callback) callback = noop$1;
2527
2545
 
2528
2546
  if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
2529
2547
  var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
@@ -2584,7 +2602,7 @@ var I18n = function (_EventEmitter) {
2584
2602
  value: function loadResources(language) {
2585
2603
  var _this3 = this;
2586
2604
 
2587
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2605
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2588
2606
  var usedCallback = callback;
2589
2607
  var usedLng = typeof language === 'string' ? language : this.language;
2590
2608
  if (typeof language === 'function') usedCallback = language;
@@ -2632,7 +2650,7 @@ var I18n = function (_EventEmitter) {
2632
2650
  var deferred = defer();
2633
2651
  if (!lngs) lngs = this.languages;
2634
2652
  if (!ns) ns = this.options.ns;
2635
- if (!callback) callback = noop$2;
2653
+ if (!callback) callback = noop$1;
2636
2654
  this.services.backendConnector.reload(lngs, ns, function (err) {
2637
2655
  deferred.resolve();
2638
2656
  callback(err);
@@ -2911,7 +2929,7 @@ var I18n = function (_EventEmitter) {
2911
2929
  var _this8 = this;
2912
2930
 
2913
2931
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2914
- var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2932
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
2915
2933
 
2916
2934
  var mergedOptions = _objectSpread$6$1(_objectSpread$6$1(_objectSpread$6$1({}, this.options), options), {
2917
2935
  isClone: true
@@ -3562,8 +3580,8 @@ function hasLoadedNamespace(ns, i18n) {
3562
3580
  });
3563
3581
  }
3564
3582
 
3565
- var _excluded$2 = ["format"],
3566
- _excluded2$2 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
3583
+ var _excluded$3 = ["format"],
3584
+ _excluded2$3 = ["children", "count", "parent", "i18nKey", "context", "tOptions", "values", "defaults", "components", "ns", "i18n", "t", "shouldUnescape"];
3567
3585
 
3568
3586
  function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3569
3587
 
@@ -3628,7 +3646,7 @@ function nodesToString(children, i18nOptions) {
3628
3646
  warn("Trans: the passed in value is invalid - seems you passed in a null child.");
3629
3647
  } else if (_typeof(child) === 'object') {
3630
3648
  var format = child.format,
3631
- clone = _objectWithoutProperties(child, _excluded$2);
3649
+ clone = _objectWithoutProperties(child, _excluded$3);
3632
3650
 
3633
3651
  var keys = Object.keys(clone);
3634
3652
 
@@ -3784,7 +3802,7 @@ function Trans(_ref) {
3784
3802
  i18nFromProps = _ref.i18n,
3785
3803
  tFromProps = _ref.t,
3786
3804
  shouldUnescape = _ref.shouldUnescape,
3787
- additionalProps = _objectWithoutProperties(_ref, _excluded2$2);
3805
+ additionalProps = _objectWithoutProperties(_ref, _excluded2$3);
3788
3806
 
3789
3807
  var _ref2 = useContext(I18nContext) || {},
3790
3808
  i18nFromContext = _ref2.i18n,
@@ -3831,28 +3849,33 @@ function Trans(_ref) {
3831
3849
  }
3832
3850
 
3833
3851
  function _iterableToArrayLimit(arr, i) {
3834
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3835
- if (_i == null) return;
3836
- var _arr = [];
3837
- var _n = true;
3838
- var _d = false;
3839
- var _s, _e;
3840
- try {
3841
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
3842
- _arr.push(_s.value);
3843
- if (i && _arr.length === i) break;
3844
- }
3845
- } catch (err) {
3846
- _d = true;
3847
- _e = err;
3848
- } finally {
3852
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
3853
+ if (null != _i) {
3854
+ var _s,
3855
+ _e,
3856
+ _x,
3857
+ _r,
3858
+ _arr = [],
3859
+ _n = !0,
3860
+ _d = !1;
3849
3861
  try {
3850
- if (!_n && _i["return"] != null) _i["return"]();
3862
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
3863
+ if (Object(_i) !== _i) return;
3864
+ _n = !1;
3865
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) {
3866
+ ;
3867
+ }
3868
+ } catch (err) {
3869
+ _d = !0, _e = err;
3851
3870
  } finally {
3852
- if (_d) throw _e;
3871
+ try {
3872
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
3873
+ } finally {
3874
+ if (_d) throw _e;
3875
+ }
3853
3876
  }
3877
+ return _arr;
3854
3878
  }
3855
- return _arr;
3856
3879
  }
3857
3880
 
3858
3881
  function _slicedToArray(arr, i) {
@@ -4017,7 +4040,8 @@ var common$1 = {
4017
4040
  role_one: "Role",
4018
4041
  role_other: "Roles",
4019
4042
  search_: "Search {{what}}",
4020
- update_: "Update {{what}}"
4043
+ update_: "Update {{what}}",
4044
+ takeAction: "Take action"
4021
4045
  };
4022
4046
  var helpers$1 = {
4023
4047
  configPermissions: "Configure permissions for the modules.",
@@ -4025,7 +4049,7 @@ var helpers$1 = {
4025
4049
  moreInfoAboutPermissions: "More information about permissions",
4026
4050
  noRolesFound: "No roles found.",
4027
4051
  searchRoles: "Search roles",
4028
- selectedMembersCount: "{{count}} {{metaName}} selected from {{totalCount}}",
4052
+ selectedMembersCount: "{{count}} {{metaName}} selected of",
4029
4053
  visitToKnowMoreAboutPermissions: "Visit to know more about permissions"
4030
4054
  };
4031
4055
  var metaNames$1 = {
@@ -4114,7 +4138,8 @@ var common = {
4114
4138
  role_one: "Rôle",
4115
4139
  role_other: "Rôles",
4116
4140
  search_: "Rechercher des {{what}}",
4117
- update_: "Mettre à jour le {{what}}"
4141
+ update_: "Mettre à jour le {{what}}",
4142
+ takeAction: "Passer à l'action"
4118
4143
  };
4119
4144
  var helpers = {
4120
4145
  configPermissions: "Configurez les autorisations pour les modules.",
@@ -4122,8 +4147,8 @@ var helpers = {
4122
4147
  moreInfoAboutPermissions: "Plus d'informations sur les autorisations",
4123
4148
  noRolesFound: "Aucun rôle trouvé.",
4124
4149
  searchRoles: "Rechercher des rôles",
4125
- selectedMembersCount_one: "{{count}} {{metaName}} sélectionné parmi {{totalCount}}",
4126
- selectedMembersCount_other: "{{count}} {{metaName}} sélectionnés parmi {{totalCount}}",
4150
+ selectedMembersCount_one: "{{count}} {{metaName}} sélectionné sur",
4151
+ selectedMembersCount_other: "{{count}} {{metaName}} sélectionnés sur",
4127
4152
  visitToKnowMoreAboutPermissions: "Visitez pour en savoir plus sur les autorisations"
4128
4153
  };
4129
4154
  var metaNames = {
@@ -4214,7 +4239,7 @@ const getScrollBarWidth = () => {
4214
4239
  document.body.removeChild(outerElement);
4215
4240
  return w1 - w2;
4216
4241
  };
4217
- const noop$1 = () => {};
4242
+ const noop = () => {};
4218
4243
  const slugify = string => string.toString().toLowerCase().replace(/\s+/g, "-") // Replace spaces with -
4219
4244
  .replace(/&/g, "-and-") // Replace & with 'and'
4220
4245
  .replace(/[^\w-]+/g, "") // Remove all non-word characters
@@ -4235,3403 +4260,215 @@ const PLURAL = {
4235
4260
  const MANAGE_MEMBER_PERMISSIONS = ["members.manage_members", "agents.manage_agents"];
4236
4261
  const DEFAULT_PERMISSION = true; // Until we add permission prop to all neeto apps, this is the default permission.
4237
4262
 
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;
4263
+ const queryClient = new QueryClient({
4264
+ queryCache: new QueryCache()
4265
+ });
4253
4266
 
4254
- var callback = listener || function () {
4255
- return undefined;
4256
- };
4267
+ const withReactQuery = Component => {
4268
+ const QueryWrapper = props => /*#__PURE__*/React.createElement(QueryClientProvider, {
4269
+ client: queryClient
4270
+ }, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(ReactQueryDevtools, {
4271
+ initialIsOpen: false,
4272
+ position: "bottom-right"
4273
+ }));
4274
+ return QueryWrapper;
4275
+ };
4257
4276
 
4258
- this.listeners.push(callback);
4259
- this.onSubscribe();
4260
- return function () {
4261
- _this.listeners = _this.listeners.filter(function (x) {
4262
- return x !== callback;
4263
- });
4277
+ /* eslint-disable @bigbinary/neeto/no-dangling-constants */
4278
+ const BASE_URL = "team_members";
4264
4279
 
4265
- _this.onUnsubscribe();
4266
- };
4267
- };
4280
+ const fetch$2 = () => axios.get(`${BASE_URL}/permissions`);
4281
+ const permissionsApi = {
4282
+ fetch: fetch$2
4283
+ };
4268
4284
 
4269
- _proto.hasListeners = function hasListeners() {
4270
- return this.listeners.length > 0;
4271
- };
4285
+ const DEFAULT_STALE_TIME = 300000; // 5 minutes
4272
4286
 
4273
- _proto.onSubscribe = function onSubscribe() {// Do nothing
4274
- };
4287
+ const QUERY_KEYS = {
4288
+ TEAMS: "neeto-team-members-teams",
4289
+ ROLES: "neeto-team-members-roles",
4290
+ PERMISSIONS: "neeto-team-members-permissions"
4291
+ };
4275
4292
 
4276
- _proto.onUnsubscribe = function onUnsubscribe() {// Do nothing
4277
- };
4293
+ function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4294
+ function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4295
+ const useFetchPermissions = function () {
4296
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4297
+ return useQuery(QUERY_KEYS.PERMISSIONS, permissionsApi.fetch, _objectSpread$8({
4298
+ staleTime: DEFAULT_STALE_TIME,
4299
+ select: response => response.permissions || response.data.permissions
4300
+ }, options));
4301
+ };
4278
4302
 
4279
- return Subscribable;
4280
- }();
4303
+ const fetch$1 = () => axios.get(`${BASE_URL}/organization_roles`);
4304
+ const create$1 = payload => axios.post(`${BASE_URL}/organization_roles`, payload);
4305
+ const update$1 = (id, payload) => axios.patch(`${BASE_URL}/organization_roles/${id}`, payload);
4306
+ const destroy = (id, payload) => axios.delete(`${BASE_URL}/organization_roles/${id}`, {
4307
+ data: payload
4308
+ });
4309
+ const organizationRolesApi = {
4310
+ fetch: fetch$1,
4311
+ create: create$1,
4312
+ update: update$1,
4313
+ destroy
4314
+ };
4281
4315
 
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];
4316
+ const _excluded$2 = ["onSuccess"],
4317
+ _excluded2$2 = ["onSuccess"],
4318
+ _excluded3$1 = ["onSuccess"];
4319
+ function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4320
+ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4321
+ const useFetchRoles = function () {
4322
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4323
+ return useQuery(QUERY_KEYS.ROLES, organizationRolesApi.fetch, _objectSpread$7({
4324
+ staleTime: DEFAULT_STALE_TIME,
4325
+ select: response => response.organizationRoles || response.data.organizationRoles
4326
+ }, options));
4327
+ };
4328
+ const useCreateRole = _ref => {
4329
+ let onSuccess = _ref.onSuccess,
4330
+ options = _objectWithoutProperties(_ref, _excluded$2);
4331
+ return useMutation(organizationRolesApi.create, _objectSpread$7({
4332
+ onSuccess: response => {
4333
+ queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
4334
+ if (!!cachedData.data && !!cachedData.data.organizationRoles) {
4335
+ return modifyPath(["data", "organizationRoles"], prepend(response.data.organizationRole), cachedData);
4289
4336
  }
4290
- }
4337
+ return modifyPath(["organizationRoles"], prepend(response.organizationRole), cachedData);
4338
+ });
4339
+ Toastr.success(response.ntmNotice || response.data.ntmNotice);
4340
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
4291
4341
  }
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
4342
+ }, options));
4343
+ };
4344
+ const useUpdateRole = _ref2 => {
4345
+ let onSuccess = _ref2.onSuccess,
4346
+ options = _objectWithoutProperties(_ref2, _excluded2$2);
4347
+ return useMutation(_ref3 => {
4348
+ let id = _ref3.id,
4349
+ payload = _ref3.payload;
4350
+ return organizationRolesApi.update(id, payload);
4351
+ }, _objectSpread$7({
4352
+ onSuccess: response => {
4353
+ queryClient.invalidateQueries(QUERY_KEYS.TEAMS);
4354
+ queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
4355
+ if (!!cachedData.data && !!cachedData.data.organizationRoles) {
4356
+ return assocPath(["data", "organizationRoles", findIndex(propEq("id", response.data.organizationRole.id), cachedData.data.organizationRoles)], response.data.organizationRole, cachedData);
4357
+ }
4358
+ return assocPath(["organizationRoles", findIndex(propEq("id", response.organizationRole.id), cachedData.organizationRoles)], response.organizationRole, cachedData);
4337
4359
  });
4360
+ Toastr.success(response.ntmNotice || response.data.ntmNotice);
4361
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
4338
4362
  }
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;
4363
+ }, options));
4364
+ };
4365
+ const useDestroyRole = _ref4 => {
4366
+ let _ref4$onSuccess = _ref4.onSuccess,
4367
+ onSuccess = _ref4$onSuccess === void 0 ? noop : _ref4$onSuccess,
4368
+ options = _objectWithoutProperties(_ref4, _excluded3$1);
4369
+ return useMutation(_ref5 => {
4370
+ let id = _ref5.id,
4371
+ payload = _ref5.payload;
4372
+ return organizationRolesApi.destroy(id, payload);
4373
+ }, _objectSpread$7({
4374
+ onSuccess: response => {
4375
+ queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
4376
+ if (!!cachedData.data && !!cachedData.data.organizationRoles) {
4377
+ return dissocPath(["data", "organizationRoles", findIndex(propEq("id", response.data.id), cachedData.data.organizationRoles)], cachedData);
4378
+ }
4379
+ return dissocPath(["organizationRoles", findIndex(propEq("id", response.id), cachedData.organizationRoles)], cachedData);
4380
+ });
4381
+ Toastr.success(response.ntmNotice || response.data.ntmNotice);
4382
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
4386
4383
  }
4387
- }
4384
+ }, options));
4385
+ };
4388
4386
 
4389
- var queryStatusFilter = mapQueryStatusFilter(active, inactive);
4387
+ var dist = {exports: {}};
4390
4388
 
4391
- if (queryStatusFilter === 'none') {
4392
- return false;
4393
- } else if (queryStatusFilter !== 'all') {
4394
- var isActive = query.isActive();
4389
+ (function (module, exports) {
4390
+ (function webpackUniversalModuleDefinition(root, factory) {
4391
+ module.exports = factory(React);
4392
+ })(commonjsGlobal, function(__WEBPACK_EXTERNAL_MODULE_4__) {
4393
+ return /******/ (function(modules) { // webpackBootstrap
4394
+ /******/ // The module cache
4395
+ /******/ var installedModules = {};
4396
+ /******/
4397
+ /******/ // The require function
4398
+ /******/ function __webpack_require__(moduleId) {
4399
+ /******/
4400
+ /******/ // Check if module is in cache
4401
+ /******/ if(installedModules[moduleId]) {
4402
+ /******/ return installedModules[moduleId].exports;
4403
+ /******/ }
4404
+ /******/ // Create a new module (and put it into the cache)
4405
+ /******/ var module = installedModules[moduleId] = {
4406
+ /******/ i: moduleId,
4407
+ /******/ l: false,
4408
+ /******/ exports: {}
4409
+ /******/ };
4410
+ /******/
4411
+ /******/ // Execute the module function
4412
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
4413
+ /******/
4414
+ /******/ // Flag the module as loaded
4415
+ /******/ module.l = true;
4416
+ /******/
4417
+ /******/ // Return the exports of the module
4418
+ /******/ return module.exports;
4419
+ /******/ }
4420
+ /******/
4421
+ /******/
4422
+ /******/ // expose the modules object (__webpack_modules__)
4423
+ /******/ __webpack_require__.m = modules;
4424
+ /******/
4425
+ /******/ // expose the module cache
4426
+ /******/ __webpack_require__.c = installedModules;
4427
+ /******/
4428
+ /******/ // identity function for calling harmony imports with the correct context
4429
+ /******/ __webpack_require__.i = function(value) { return value; };
4430
+ /******/
4431
+ /******/ // define getter function for harmony exports
4432
+ /******/ __webpack_require__.d = function(exports, name, getter) {
4433
+ /******/ if(!__webpack_require__.o(exports, name)) {
4434
+ /******/ Object.defineProperty(exports, name, {
4435
+ /******/ configurable: false,
4436
+ /******/ enumerable: true,
4437
+ /******/ get: getter
4438
+ /******/ });
4439
+ /******/ }
4440
+ /******/ };
4441
+ /******/
4442
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
4443
+ /******/ __webpack_require__.n = function(module) {
4444
+ /******/ var getter = module && module.__esModule ?
4445
+ /******/ function getDefault() { return module['default']; } :
4446
+ /******/ function getModuleExports() { return module; };
4447
+ /******/ __webpack_require__.d(getter, 'a', getter);
4448
+ /******/ return getter;
4449
+ /******/ };
4450
+ /******/
4451
+ /******/ // Object.prototype.hasOwnProperty.call
4452
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
4453
+ /******/
4454
+ /******/ // __webpack_public_path__
4455
+ /******/ __webpack_require__.p = "";
4456
+ /******/
4457
+ /******/ // Load entry module and return exports
4458
+ /******/ return __webpack_require__(__webpack_require__.s = 10);
4459
+ /******/ })
4460
+ /************************************************************************/
4461
+ /******/ ([
4462
+ /* 0 */
4463
+ /***/ (function(module, exports) {
4395
4464
 
4396
- if (queryStatusFilter === 'active' && !isActive) {
4397
- return false;
4398
- }
4465
+ // shim for using process in browser
4466
+ var process = module.exports = {};
4399
4467
 
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
- const queryClient = new QueryClient({
7414
- queryCache: new QueryCache()
7415
- });
7416
-
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
- const withReactQuery = Component => {
7431
- const QueryWrapper = props => /*#__PURE__*/React.createElement(QueryClientProvider, {
7432
- client: queryClient
7433
- }, /*#__PURE__*/React.createElement(Component, props), /*#__PURE__*/React.createElement(devtools.exports.ReactQueryDevtools, {
7434
- initialIsOpen: false,
7435
- position: "bottom-right"
7436
- }));
7437
- return QueryWrapper;
7438
- };
7439
-
7440
- /* eslint-disable @bigbinary/neeto/no-dangling-constants */
7441
- const BASE_URL = "team_members";
7442
-
7443
- const fetch$2 = () => axios.get(`${BASE_URL}/permissions`);
7444
- const permissionsApi = {
7445
- fetch: fetch$2
7446
- };
7447
-
7448
- const DEFAULT_STALE_TIME = 300000; // 5 minutes
7449
-
7450
- const QUERY_KEYS = {
7451
- TEAMS: "neeto-team-members-teams",
7452
- ROLES: "neeto-team-members-roles",
7453
- PERMISSIONS: "neeto-team-members-permissions"
7454
- };
7455
-
7456
- function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7457
- function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7458
- const useFetchPermissions = function () {
7459
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7460
- return useQuery(QUERY_KEYS.PERMISSIONS, permissionsApi.fetch, _objectSpread$8({
7461
- staleTime: DEFAULT_STALE_TIME,
7462
- select: response => response.permissions || response.data.permissions
7463
- }, options));
7464
- };
7465
-
7466
- const fetch$1 = () => axios.get(`${BASE_URL}/organization_roles`);
7467
- const create$1 = payload => axios.post(`${BASE_URL}/organization_roles`, payload);
7468
- const update$1 = (id, payload) => axios.patch(`${BASE_URL}/organization_roles/${id}`, payload);
7469
- const destroy = (id, payload) => axios.delete(`${BASE_URL}/organization_roles/${id}`, {
7470
- data: payload
7471
- });
7472
- const organizationRolesApi = {
7473
- fetch: fetch$1,
7474
- create: create$1,
7475
- update: update$1,
7476
- destroy
7477
- };
7478
-
7479
- const _excluded$1 = ["onSuccess"],
7480
- _excluded2$1 = ["onSuccess"],
7481
- _excluded3$1 = ["onSuccess"];
7482
- function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7483
- function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7484
- const useFetchRoles = function () {
7485
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7486
- return useQuery(QUERY_KEYS.ROLES, organizationRolesApi.fetch, _objectSpread$7({
7487
- staleTime: DEFAULT_STALE_TIME,
7488
- select: response => response.organizationRoles || response.data.organizationRoles
7489
- }, options));
7490
- };
7491
- const useCreateRole = _ref => {
7492
- let onSuccess = _ref.onSuccess,
7493
- options = _objectWithoutProperties(_ref, _excluded$1);
7494
- return useMutation(organizationRolesApi.create, _objectSpread$7({
7495
- onSuccess: response => {
7496
- queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
7497
- if (!!cachedData.data && !!cachedData.data.organizationRoles) {
7498
- return modifyPath(["data", "organizationRoles"], prepend(response.data.organizationRole), cachedData);
7499
- }
7500
- return modifyPath(["organizationRoles"], prepend(response.organizationRole), cachedData);
7501
- });
7502
- Toastr.success(response.ntmNotice || response.data.ntmNotice);
7503
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
7504
- }
7505
- }, options));
7506
- };
7507
- const useUpdateRole = _ref2 => {
7508
- let onSuccess = _ref2.onSuccess,
7509
- options = _objectWithoutProperties(_ref2, _excluded2$1);
7510
- return useMutation(_ref3 => {
7511
- let id = _ref3.id,
7512
- payload = _ref3.payload;
7513
- return organizationRolesApi.update(id, payload);
7514
- }, _objectSpread$7({
7515
- onSuccess: response => {
7516
- queryClient.invalidateQueries(QUERY_KEYS.TEAMS);
7517
- queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
7518
- if (!!cachedData.data && !!cachedData.data.organizationRoles) {
7519
- return assocPath(["data", "organizationRoles", findIndex(propEq("id", response.data.organizationRole.id), cachedData.data.organizationRoles)], response.data.organizationRole, cachedData);
7520
- }
7521
- return assocPath(["organizationRoles", findIndex(propEq("id", response.organizationRole.id), cachedData.organizationRoles)], response.organizationRole, cachedData);
7522
- });
7523
- Toastr.success(response.ntmNotice || response.data.ntmNotice);
7524
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
7525
- }
7526
- }, options));
7527
- };
7528
- const useDestroyRole = _ref4 => {
7529
- let _ref4$onSuccess = _ref4.onSuccess,
7530
- onSuccess = _ref4$onSuccess === void 0 ? noop$1 : _ref4$onSuccess,
7531
- options = _objectWithoutProperties(_ref4, _excluded3$1);
7532
- return useMutation(_ref5 => {
7533
- let id = _ref5.id,
7534
- payload = _ref5.payload;
7535
- return organizationRolesApi.destroy(id, payload);
7536
- }, _objectSpread$7({
7537
- onSuccess: response => {
7538
- queryClient.setQueriesData(QUERY_KEYS.ROLES, cachedData => {
7539
- if (!!cachedData.data && !!cachedData.data.organizationRoles) {
7540
- return dissocPath(["data", "organizationRoles", findIndex(propEq("id", response.data.id), cachedData.data.organizationRoles)], cachedData);
7541
- }
7542
- return dissocPath(["organizationRoles", findIndex(propEq("id", response.id), cachedData.organizationRoles)], cachedData);
7543
- });
7544
- Toastr.success(response.ntmNotice || response.data.ntmNotice);
7545
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
7546
- }
7547
- }, options));
7548
- };
7549
-
7550
- var dist = {exports: {}};
7551
-
7552
- (function (module, exports) {
7553
- (function webpackUniversalModuleDefinition(root, factory) {
7554
- module.exports = factory(React);
7555
- })(commonjsGlobal, function(__WEBPACK_EXTERNAL_MODULE_4__) {
7556
- return /******/ (function(modules) { // webpackBootstrap
7557
- /******/ // The module cache
7558
- /******/ var installedModules = {};
7559
- /******/
7560
- /******/ // The require function
7561
- /******/ function __webpack_require__(moduleId) {
7562
- /******/
7563
- /******/ // Check if module is in cache
7564
- /******/ if(installedModules[moduleId]) {
7565
- /******/ return installedModules[moduleId].exports;
7566
- /******/ }
7567
- /******/ // Create a new module (and put it into the cache)
7568
- /******/ var module = installedModules[moduleId] = {
7569
- /******/ i: moduleId,
7570
- /******/ l: false,
7571
- /******/ exports: {}
7572
- /******/ };
7573
- /******/
7574
- /******/ // Execute the module function
7575
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
7576
- /******/
7577
- /******/ // Flag the module as loaded
7578
- /******/ module.l = true;
7579
- /******/
7580
- /******/ // Return the exports of the module
7581
- /******/ return module.exports;
7582
- /******/ }
7583
- /******/
7584
- /******/
7585
- /******/ // expose the modules object (__webpack_modules__)
7586
- /******/ __webpack_require__.m = modules;
7587
- /******/
7588
- /******/ // expose the module cache
7589
- /******/ __webpack_require__.c = installedModules;
7590
- /******/
7591
- /******/ // identity function for calling harmony imports with the correct context
7592
- /******/ __webpack_require__.i = function(value) { return value; };
7593
- /******/
7594
- /******/ // define getter function for harmony exports
7595
- /******/ __webpack_require__.d = function(exports, name, getter) {
7596
- /******/ if(!__webpack_require__.o(exports, name)) {
7597
- /******/ Object.defineProperty(exports, name, {
7598
- /******/ configurable: false,
7599
- /******/ enumerable: true,
7600
- /******/ get: getter
7601
- /******/ });
7602
- /******/ }
7603
- /******/ };
7604
- /******/
7605
- /******/ // getDefaultExport function for compatibility with non-harmony modules
7606
- /******/ __webpack_require__.n = function(module) {
7607
- /******/ var getter = module && module.__esModule ?
7608
- /******/ function getDefault() { return module['default']; } :
7609
- /******/ function getModuleExports() { return module; };
7610
- /******/ __webpack_require__.d(getter, 'a', getter);
7611
- /******/ return getter;
7612
- /******/ };
7613
- /******/
7614
- /******/ // Object.prototype.hasOwnProperty.call
7615
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
7616
- /******/
7617
- /******/ // __webpack_public_path__
7618
- /******/ __webpack_require__.p = "";
7619
- /******/
7620
- /******/ // Load entry module and return exports
7621
- /******/ return __webpack_require__(__webpack_require__.s = 10);
7622
- /******/ })
7623
- /************************************************************************/
7624
- /******/ ([
7625
- /* 0 */
7626
- /***/ (function(module, exports) {
7627
-
7628
- // shim for using process in browser
7629
- var process = module.exports = {};
7630
-
7631
- // cached from whatever global is present so that test runners that stub it
7632
- // don't break things. But we need to wrap it in a try catch in case it is
7633
- // wrapped in strict mode code which doesn't define any globals. It's inside a
7634
- // function because try/catches deoptimize in certain engines.
4468
+ // cached from whatever global is present so that test runners that stub it
4469
+ // don't break things. But we need to wrap it in a try catch in case it is
4470
+ // wrapped in strict mode code which doesn't define any globals. It's inside a
4471
+ // function because try/catches deoptimize in certain engines.
7635
4472
 
7636
4473
  var cachedSetTimeout;
7637
4474
  var cachedClearTimeout;
@@ -9862,8 +6699,8 @@ const teamsApi = {
9862
6699
  update
9863
6700
  };
9864
6701
 
9865
- const _excluded = ["onSuccess"],
9866
- _excluded2 = ["onSuccess"],
6702
+ const _excluded$1 = ["onSuccess"],
6703
+ _excluded2$1 = ["onSuccess"],
9867
6704
  _excluded3 = ["onSuccess"];
9868
6705
  function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9869
6706
  function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -9878,7 +6715,7 @@ const useFetchMembers = function () {
9878
6715
  };
9879
6716
  const useCreateMember = _ref => {
9880
6717
  let onSuccess = _ref.onSuccess,
9881
- options = _objectWithoutProperties(_ref, _excluded);
6718
+ options = _objectWithoutProperties(_ref, _excluded$1);
9882
6719
  return useMutation(teamsApi.create, _objectSpread$4({
9883
6720
  onSuccess: response => {
9884
6721
  queryClient.invalidateQueries(QUERY_KEYS.TEAMS);
@@ -9889,7 +6726,7 @@ const useCreateMember = _ref => {
9889
6726
  };
9890
6727
  const useUpdateMember = _ref2 => {
9891
6728
  let onSuccess = _ref2.onSuccess,
9892
- options = _objectWithoutProperties(_ref2, _excluded2);
6729
+ options = _objectWithoutProperties(_ref2, _excluded2$1);
9893
6730
  return useMutation(_ref3 => {
9894
6731
  let id = _ref3.id,
9895
6732
  payload = _ref3.payload;
@@ -9930,24 +6767,57 @@ const useDebounce = function (value) {
9930
6767
  return debouncedValue;
9931
6768
  };
9932
6769
 
6770
+ function _extends() {
6771
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
6772
+ for (var i = 1; i < arguments.length; i++) {
6773
+ var source = arguments[i];
6774
+ for (var key in source) {
6775
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
6776
+ target[key] = source[key];
6777
+ }
6778
+ }
6779
+ }
6780
+ return target;
6781
+ };
6782
+ return _extends.apply(this, arguments);
6783
+ }
6784
+
6785
+ const FIXED_COLUMNS = ["actions"];
6786
+ const COLUMNS_DROPDOWN_PROPS = {
6787
+ label: instance.t("common.column", PLURAL)
6788
+ };
6789
+ const COLUMNS_SEARCH_PROPS = {
6790
+ placeholder: instance.t("columns.search")
6791
+ };
6792
+ const MANAGE_ROLES_BUTTON_LABEL = instance.t("common.manage_", {
6793
+ what: instance.t("common.role", PLURAL).toLocaleLowerCase()
6794
+ });
6795
+
9933
6796
  const Header = _ref => {
9934
- var _permissions$create, _permissions$create2;
6797
+ var _permissions$create;
9935
6798
  let metaName = _ref.metaName,
9936
6799
  _ref$onClick = _ref.onClick,
9937
- onClick = _ref$onClick === void 0 ? noop$1 : _ref$onClick,
9938
- permissions = _ref.permissions;
9939
- return /*#__PURE__*/React.createElement(Tooltip, {
6800
+ onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
6801
+ permissions = _ref.permissions,
6802
+ rolesButtonProps = _ref.rolesButtonProps;
6803
+ const isRolesButtonVisible = !!rolesButtonProps;
6804
+ const hasCreatePermission = (_permissions$create = permissions === null || permissions === void 0 ? void 0 : permissions.create) !== null && _permissions$create !== void 0 ? _permissions$create : hasPermission(MANAGE_MEMBER_PERMISSIONS);
6805
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isRolesButtonVisible ? /*#__PURE__*/React.createElement(Button, _extends({
6806
+ "data-cy": "ntm-manage-roles-button",
6807
+ label: MANAGE_ROLES_BUTTON_LABEL,
6808
+ style: "secondary"
6809
+ }, rolesButtonProps)) : null, /*#__PURE__*/React.createElement(Tooltip, {
9940
6810
  content: instance.t("tooltips.noPermissionToAddMember"),
9941
- disabled: (_permissions$create = permissions === null || permissions === void 0 ? void 0 : permissions.create) !== null && _permissions$create !== void 0 ? _permissions$create : hasPermission(MANAGE_MEMBER_PERMISSIONS),
6811
+ disabled: hasCreatePermission,
9942
6812
  position: "bottom"
9943
6813
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Button, {
9944
6814
  "data-cy": "ntm-add-member-button",
9945
- disabled: !((_permissions$create2 = permissions === null || permissions === void 0 ? void 0 : permissions.create) !== null && _permissions$create2 !== void 0 ? _permissions$create2 : hasPermission(MANAGE_MEMBER_PERMISSIONS)),
6815
+ disabled: !hasCreatePermission,
9946
6816
  label: instance.t("common.add_", {
9947
6817
  what: metaName(SINGULAR).toLocaleLowerCase()
9948
6818
  }),
9949
6819
  onClick: onClick
9950
- })));
6820
+ }))));
9951
6821
  };
9952
6822
 
9953
6823
  const getStorageValue = (key, defaultValue) => {
@@ -10081,20 +6951,6 @@ const Columns = _ref => {
10081
6951
  }, noColumnMessage), !!actionBlock && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, null), actionBlock))));
10082
6952
  };
10083
6953
 
10084
- const FIXED_COLUMNS = ["actions"];
10085
- const COLUMNS_DROPDOWN_PROPS = {
10086
- buttonProps: {
10087
- size: "small"
10088
- },
10089
- label: instance.t("common.column", PLURAL)
10090
- };
10091
- const COLUMNS_SEARCH_PROPS = {
10092
- placeholder: instance.t("columns.search")
10093
- };
10094
- const MANAGE_ROLES_BUTTON_LABEL = instance.t("common.manage_", {
10095
- what: instance.t("common.role", PLURAL).toLocaleLowerCase()
10096
- });
10097
-
10098
6954
  const filterBySearchTerm = (searchTerm, roles) => filter(_ref => {
10099
6955
  let name = _ref.name;
10100
6956
  return includes(trim(toLower(searchTerm)), trim(toLower(name)));
@@ -10132,39 +6988,49 @@ const RolesDropdown = _ref => {
10132
6988
  setSearchTerm("");
10133
6989
  setIsDropdownOpen(false);
10134
6990
  };
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",
6991
+ const handleClick = event => {
6992
+ event.stopPropagation();
6993
+ setIsDropdownOpen(!isDropdownOpen);
6994
+ };
6995
+ return /*#__PURE__*/React.createElement(Dropdown, {
10141
6996
  buttonStyle: "secondary",
10142
6997
  closeOnSelect: false,
10143
- "data-cy": "ntm-members-roles-update-dropdown",
6998
+ customTarget: /*#__PURE__*/React.createElement(MenuItem.Button, {
6999
+ suffix: /*#__PURE__*/React.createElement(Right$1, {
7000
+ size: 16
7001
+ })
7002
+ }, instance.t("buttons.changeRole")),
7003
+ "data-cy": "ntm-members-roles-update-dropdown-button",
10144
7004
  disabled: !hasUpdatePermission,
10145
- label: instance.t("buttons.changeRole"),
10146
7005
  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, {
7006
+ onClick: handleClick,
7007
+ onClose: handleOnClose,
7008
+ position: "auto-end"
7009
+ }, /*#__PURE__*/React.createElement(Menu$1, null, isSearchable && /*#__PURE__*/React.createElement("div", {
10151
7010
  className: "neeto-ui-px-3 neeto-ui-py-2",
7011
+ onClick: e => {
7012
+ e.stopPropagation();
7013
+ }
7014
+ }, /*#__PURE__*/React.createElement(Input$1, {
10152
7015
  "data-cy": "ntm-members-roles-search-input",
10153
7016
  onChange: handleSearch,
10154
7017
  placeholder: instance.t("helpers.searchRoles"),
10155
7018
  prefix: /*#__PURE__*/React.createElement(Search, null),
10156
7019
  type: "search",
10157
7020
  value: searchTerm
10158
- }), isNotEmpty$1(filteredRoles) ? filteredRoles.map(_ref3 => {
7021
+ })), isNotEmpty$1(filteredRoles) ? filteredRoles.map(_ref3 => {
10159
7022
  let id = _ref3.id,
10160
7023
  name = _ref3.name;
10161
7024
  return /*#__PURE__*/React.createElement(MenuItem.Button, {
10162
7025
  key: id,
10163
7026
  onClick: () => handleSelectRole(name)
10164
7027
  }, 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")))))));
7028
+ }) : /*#__PURE__*/React.createElement("div", {
7029
+ className: "neeto-ui-flex neeto-ui-justify-center neeto-ui-p-1"
7030
+ }, /*#__PURE__*/React.createElement(Typography, {
7031
+ className: "neeto-ui-text-gray-700",
7032
+ style: "body2"
7033
+ }, instance.t("helpers.noRolesFound")))));
10168
7034
  };
10169
7035
 
10170
7036
  var _URLSearchParams$get;
@@ -10214,10 +7080,13 @@ const DEFAULT_SELECTED_ROWS = {
10214
7080
  };
10215
7081
 
10216
7082
  const Left = _ref => {
10217
- var _selectedRows$keys, _selectedRows$keys2;
10218
- let filteredCount = _ref.filteredCount,
7083
+ var _selectedRows$keys, _selectedRows$keys2, _config$permissions$u, _config$permissions, _config$otherBulkActi;
7084
+ let config = _ref.config,
7085
+ filteredCount = _ref.filteredCount,
10219
7086
  metaName = _ref.metaName,
7087
+ roles = _ref.roles,
10220
7088
  selectedRows = _ref.selectedRows,
7089
+ setSelectedRows = _ref.setSelectedRows,
10221
7090
  totalCount = _ref.totalCount;
10222
7091
  const hasSelectedRows = isNotEmpty$1(selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.keys);
10223
7092
  const pluralizedByFilterCount = metaName({
@@ -10227,28 +7096,8 @@ const Left = _ref => {
10227
7096
  count: selectedRows === null || selectedRows === void 0 ? void 0 : (_selectedRows$keys = selectedRows.keys) === null || _selectedRows$keys === void 0 ? void 0 : _selectedRows$keys.length,
10228
7097
  metaName: metaName({
10229
7098
  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
7099
+ }).toLocaleLowerCase()
10232
7100
  };
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
7101
  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
7102
  const _useBulkUpdateMembers = useBulkUpdateMembers({
10254
7103
  onSuccess: () => setSelectedRows(DEFAULT_SELECTED_ROWS)
@@ -10275,33 +7124,46 @@ const Right = _ref2 => {
10275
7124
  }
10276
7125
  });
10277
7126
  };
10278
- return /*#__PURE__*/React.createElement(React.Fragment, null, getDeactivatedButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(Tooltip, {
7127
+ const Menu = Dropdown.Menu,
7128
+ MenuItem = Dropdown.MenuItem;
7129
+ return /*#__PURE__*/React.createElement("div", {
7130
+ className: "flex items-center gap-4"
7131
+ }, /*#__PURE__*/React.createElement(Typography, {
7132
+ component: "h4",
7133
+ "data-cy": "ntm-filtered-members-count",
7134
+ style: "h4"
7135
+ }, hasSelectedRows ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Trans, {
7136
+ i18nKey: "helpers.selectedMembersCount",
7137
+ values: selectedMembersCountValues
7138
+ }), /*#__PURE__*/React.createElement("span", {
7139
+ className: "neeto-ui-text-gray-600"
7140
+ }, " ", totalCount)) : `${filteredCount} ${pluralizedByFilterCount}`), hasSelectedRows && /*#__PURE__*/React.createElement(Tooltip, {
10279
7141
  content: instance.t("tooltips.noPermissionToEditMembers"),
10280
7142
  disabled: hasUpdatePermission,
10281
7143
  position: "top"
10282
- }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Button, {
7144
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Dropdown, {
7145
+ "data-cy": "ntm-members-take-action-dropdown-button",
7146
+ buttonStyle: "secondary",
7147
+ disabled: !hasUpdatePermission,
7148
+ label: instance.t("common.takeAction")
7149
+ }, /*#__PURE__*/React.createElement(Menu, null, getDeactivatedButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(MenuItem.Button, {
10283
7150
  "data-cy": "ntm-deactivate-members-button",
10284
7151
  disabled: !hasUpdatePermission,
10285
- label: instance.t("common.deactivate"),
10286
- size: "small",
10287
- style: "secondary",
10288
7152
  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, {
7153
+ }, instance.t("common.deactivate")), getActivateButtonVisible(selectedRows) && /*#__PURE__*/React.createElement(MenuItem.Button, {
10294
7154
  "data-cy": "ntm-activate-members-button",
10295
7155
  disabled: !hasUpdatePermission,
10296
- label: instance.t("common.activate"),
10297
- size: "small",
10298
- style: "secondary",
10299
7156
  onClick: () => handleActivateMembers()
10300
- }))), isNotEmpty$1(selectedRows.keys) && /*#__PURE__*/React.createElement(RolesDropdown, {
7157
+ }, instance.t("common.activate")), /*#__PURE__*/React.createElement(RolesDropdown, {
10301
7158
  handleRoleChange: handleRoleChange,
10302
7159
  hasUpdatePermission: hasUpdatePermission,
10303
7160
  roles: roles
10304
- }), /*#__PURE__*/React.createElement(Columns, {
7161
+ }), config === null || config === void 0 ? void 0 : (_config$otherBulkActi = config.otherBulkActions) === null || _config$otherBulkActi === void 0 ? void 0 : _config$otherBulkActi.call(config))))));
7162
+ };
7163
+ const Right = _ref2 => {
7164
+ let columns = _ref2.columns,
7165
+ setColumnData = _ref2.setColumnData;
7166
+ return /*#__PURE__*/React.createElement(Columns, {
10305
7167
  columnData: columns,
10306
7168
  dropdownProps: COLUMNS_DROPDOWN_PROPS,
10307
7169
  fixedColumns: FIXED_COLUMNS,
@@ -10309,12 +7171,7 @@ const Right = _ref2 => {
10309
7171
  noColumnMessage: instance.t("columns.noColumnsFound"),
10310
7172
  onChange: setColumnData,
10311
7173
  searchProps: COLUMNS_SEARCH_PROPS
10312
- }), isRolesButtonVisible ? /*#__PURE__*/React.createElement(Button, _extends({
10313
- "data-cy": "ntm-manage-roles-button",
10314
- label: MANAGE_ROLES_BUTTON_LABEL,
10315
- size: "small",
10316
- style: "secondary"
10317
- }, rolesButtonProps)) : null);
7174
+ });
10318
7175
  };
10319
7176
  const SubHeader = {
10320
7177
  Left,
@@ -11013,6 +7870,28 @@ const getMetaName = curry((metaName, count) => {
11013
7870
  });
11014
7871
  const clearSelectedMembers = (previousCategory, currentCategory) => isNotEqual(previousCategory, currentCategory) && isNotEqual(currentCategory, "ALL");
11015
7872
 
7873
+ const _excluded = ["className", "children"],
7874
+ _excluded2 = ["className", "children"];
7875
+ const PageWrapper = _ref => {
7876
+ let className = _ref.className,
7877
+ children = _ref.children,
7878
+ otherProps = _objectWithoutProperties(_ref, _excluded);
7879
+ return /*#__PURE__*/React.createElement("div", _extends({
7880
+ className: className
7881
+ }, otherProps), children);
7882
+ };
7883
+ const Page = _ref2 => {
7884
+ let className = _ref2.className,
7885
+ children = _ref2.children,
7886
+ otherProps = _objectWithoutProperties(_ref2, _excluded2);
7887
+ return /*#__PURE__*/React.createElement("div", _extends({
7888
+ className: className
7889
+ }, otherProps), children);
7890
+ };
7891
+ Page.Header = PageWrapper;
7892
+ Page.Body = PageWrapper;
7893
+ Page.Footer = PageWrapper;
7894
+
11016
7895
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11017
7896
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11018
7897
  const MULTIPLE_EMAIL_INPUT_VALIDATION_SCHEMA = {
@@ -11033,6 +7912,19 @@ const MANAGE_MEMBERS_FORMIK_PROPS = {
11033
7912
  enableReinitialize: true,
11034
7913
  validationSchema: VALIDATION_SCHEMA$1
11035
7914
  };
7915
+ const DEFAULT_COMPONENT_CONFIG = {
7916
+ type: "pane",
7917
+ isOpen: false,
7918
+ className: "",
7919
+ headerProps: {},
7920
+ bodyProps: {},
7921
+ footerProps: {}
7922
+ };
7923
+ const MEMBERS_FORM_COMPONENT_MAPPER = {
7924
+ pane: Pane,
7925
+ modal: Modal,
7926
+ page: Page
7927
+ };
11036
7928
 
11037
7929
  const renderInitialValues = (selectedMember, roles) => {
11038
7930
  var _roles$;
@@ -11064,7 +7956,9 @@ const MultipleEmailInput = _ref => {
11064
7956
  var _head;
11065
7957
  let emails = _ref.emails,
11066
7958
  selectedMember = _ref.selectedMember;
11067
- return selectedMember ? /*#__PURE__*/React.createElement(Input, {
7959
+ return /*#__PURE__*/React.createElement("div", {
7960
+ className: "neeto-ui-w-full"
7961
+ }, selectedMember ? /*#__PURE__*/React.createElement(Input, {
11068
7962
  disabled: true,
11069
7963
  "data-cy": "ntm-manage-member-email-input",
11070
7964
  label: instance.t("common.email", SINGULAR),
@@ -11079,7 +7973,7 @@ const MultipleEmailInput = _ref => {
11079
7973
  label: `${instance.t("common.email", PLURAL)}*`,
11080
7974
  name: "emails",
11081
7975
  placeholder: instance.t("placeholders.email")
11082
- });
7976
+ }));
11083
7977
  };
11084
7978
  MultipleEmailInput.defaultProps = {
11085
7979
  emails: [],
@@ -11106,11 +8000,11 @@ const RolesRadioGroup = _ref => {
11106
8000
  let id = _ref2.id,
11107
8001
  name = _ref2.name;
11108
8002
  return /*#__PURE__*/React.createElement("label", {
11109
- className: "ntm-members-pane-radio-item__wrapper",
8003
+ className: "ntm-members-form-radio-item__wrapper",
11110
8004
  htmlFor: slugify(name),
11111
8005
  key: id
11112
8006
  }, /*#__PURE__*/React.createElement(Radio.Item, {
11113
- className: "ntm-members-pane-radio-item__label",
8007
+ className: "ntm-members-form-radio-item__label",
11114
8008
  "data-cy": "ntm-manage-member-roles-button",
11115
8009
  defaultChecked: identical(name, role),
11116
8010
  id: slugify(name),
@@ -11128,41 +8022,55 @@ RolesRadioGroup.defaultProps = {
11128
8022
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11129
8023
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11130
8024
  const ManageMember = _ref => {
11131
- var _config$manageMember;
8025
+ var _config$permissions$v, _config$permissions, _config$manageMember;
11132
8026
  let config = _ref.config,
11133
- isOpen = _ref.isOpen,
11134
- metaName = _ref.metaName,
11135
- onClose = _ref.onClose,
8027
+ onComplete = _ref.onComplete,
11136
8028
  _ref$roles = _ref.roles,
11137
8029
  roles = _ref$roles === void 0 ? [] : _ref$roles,
11138
- selectedMember = _ref.selectedMember;
8030
+ _ref$selectedMember = _ref.selectedMember,
8031
+ selectedMember = _ref$selectedMember === void 0 ? null : _ref$selectedMember,
8032
+ _ref$componentConfig = _ref.componentConfig,
8033
+ componentConfig = _ref$componentConfig === void 0 ? {} : _ref$componentConfig;
11139
8034
  const _useState = useState(false),
11140
8035
  _useState2 = _slicedToArray(_useState, 2),
11141
8036
  hasSubmitted = _useState2[0],
11142
8037
  setHasSubmitted = _useState2[1];
11143
8038
  const formReference = useRef(null);
11144
- const onPaneClose = () => {
11145
- onClose();
8039
+ const manageMemberComponentConfig = _objectSpread$1(_objectSpread$1({}, DEFAULT_COMPONENT_CONFIG), componentConfig);
8040
+ const Component = MEMBERS_FORM_COMPONENT_MAPPER[manageMemberComponentConfig.type || "pane"];
8041
+ const handleClose = () => {
8042
+ onComplete();
11146
8043
  setHasSubmitted(false);
11147
8044
  };
8045
+ const haveToFetchRoles = isEmpty(roles) ? (_config$permissions$v = config === null || config === void 0 ? void 0 : (_config$permissions = config.permissions) === null || _config$permissions === void 0 ? void 0 : _config$permissions.view) !== null && _config$permissions$v !== void 0 ? _config$permissions$v : DEFAULT_PERMISSION : false;
8046
+ const _useFetchRoles = useFetchRoles({
8047
+ select: response => {
8048
+ var _ref2;
8049
+ return reverse((_ref2 = response.organizationRoles || response.data.organizationRoles) !== null && _ref2 !== void 0 ? _ref2 : []);
8050
+ },
8051
+ enabled: haveToFetchRoles
8052
+ }),
8053
+ _useFetchRoles$data = _useFetchRoles.data,
8054
+ rolesList = _useFetchRoles$data === void 0 ? roles : _useFetchRoles$data,
8055
+ isRolesLoading = _useFetchRoles.isLoading;
11148
8056
  const manageMemberProps = {
11149
8057
  hasSubmitted,
11150
- onPaneClose,
11151
- roles,
8058
+ handleClose,
8059
+ roles: rolesList,
11152
8060
  selectedMember,
11153
8061
  queryClient
11154
8062
  };
11155
8063
  const _useCreateMember = useCreateMember({
11156
8064
  onSuccess: () => {
11157
8065
  var _config$createMember, _config$createMember$;
11158
- onPaneClose();
8066
+ handleClose();
11159
8067
  config === null || config === void 0 ? void 0 : (_config$createMember = config.createMember) === null || _config$createMember === void 0 ? void 0 : (_config$createMember$ = _config$createMember.onSuccess) === null || _config$createMember$ === void 0 ? void 0 : _config$createMember$.callback();
11160
8068
  }
11161
8069
  }),
11162
8070
  createMember = _useCreateMember.mutate,
11163
8071
  isCreatingMember = _useCreateMember.isLoading;
11164
8072
  const _useUpdateMember = useUpdateMember({
11165
- onSuccess: onPaneClose
8073
+ onSuccess: handleClose
11166
8074
  }),
11167
8075
  updateMember = _useUpdateMember.mutate,
11168
8076
  isUpdatingMember = _useUpdateMember.isLoading;
@@ -11172,46 +8080,56 @@ const ManageMember = _ref => {
11172
8080
  payload: renderPayload(values, selectedMember)
11173
8081
  }) : createMember(renderPayload(values));
11174
8082
  };
11175
- const isSubmitting = isCreatingMember || isUpdatingMember;
11176
- return /*#__PURE__*/React.createElement(Pane, {
8083
+ const isSubmitting = isCreatingMember || isUpdatingMember || isRolesLoading;
8084
+ const getTitle = () => {
8085
+ const metaName = (config === null || config === void 0 ? void 0 : config.metaName) || "member";
8086
+
8087
+ /* eslint-disable @bigbinary/neeto/no-missing-localization */
8088
+ return selectedMember ? instance.t("common.edit_", {
8089
+ what: getMetaName(metaName)(SINGULAR).toLocaleLowerCase()
8090
+ }) : instance.t("common.add_", {
8091
+ what: getMetaName(metaName)(SINGULAR).toLocaleLowerCase()
8092
+ });
8093
+ /* eslint-disable @bigbinary/neeto/no-missing-localization */
8094
+ };
8095
+
8096
+ return /*#__PURE__*/React.createElement(Component, {
11177
8097
  "data-cy": "ntm-manage-members-pane-wrapper",
11178
- isOpen: isOpen,
11179
- onClose: onPaneClose
11180
- }, /*#__PURE__*/React.createElement(Pane.Header, null, /*#__PURE__*/React.createElement(Typography, {
11181
- className: "ntm-members-pane__header",
8098
+ isOpen: manageMemberComponentConfig.isOpen,
8099
+ onClose: handleClose,
8100
+ className: manageMemberComponentConfig.className
8101
+ }, /*#__PURE__*/React.createElement(Component.Header, manageMemberComponentConfig.headerProps, /*#__PURE__*/React.createElement(Typography, {
8102
+ className: "ntm-members-form__header",
11182
8103
  "data-cy": "ntm-manage-members-pane-header",
11183
8104
  style: "h2",
11184
8105
  weight: "semibold"
11185
- }, selectedMember ? instance.t("common.edit_", {
11186
- what: metaName(SINGULAR).toLocaleLowerCase()
11187
- }) : instance.t("common.add_", {
11188
- what: metaName(SINGULAR).toLocaleLowerCase()
11189
- }))), config !== null && config !== void 0 && (_config$manageMember = config.manageMember) !== null && _config$manageMember !== void 0 && _config$manageMember.component ? config.manageMember.component(manageMemberProps) : /*#__PURE__*/React.createElement(Form, {
8106
+ }, getTitle())), config !== null && config !== void 0 && (_config$manageMember = config.manageMember) !== null && _config$manageMember !== void 0 && _config$manageMember.component ? config.manageMember.component(manageMemberProps) : /*#__PURE__*/React.createElement(Form, {
11190
8107
  ref: formReference,
11191
8108
  formikProps: _objectSpread$1(_objectSpread$1({}, MANAGE_MEMBERS_FORMIK_PROPS), {}, {
11192
- initialValues: renderInitialValues(selectedMember, roles),
8109
+ initialValues: renderInitialValues(selectedMember, rolesList),
11193
8110
  onSubmit: handleAddMember,
11194
8111
  validateOnBlur: hasSubmitted,
11195
8112
  validateOnChange: hasSubmitted
11196
8113
  })
11197
- }, _ref2 => {
11198
- let values = _ref2.values,
11199
- dirty = _ref2.dirty;
8114
+ }, _ref3 => {
8115
+ var _manageMemberComponen, _manageMemberComponen2;
8116
+ let values = _ref3.values,
8117
+ dirty = _ref3.dirty;
11200
8118
  const emails = values.emails,
11201
8119
  role = values.role;
11202
8120
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ScrollToErrorField, {
11203
8121
  formRef: formReference
11204
- }), /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
11205
- className: "ntm-members-pane__body"
11206
- }, /*#__PURE__*/React.createElement(MultipleEmailInput, {
8122
+ }), /*#__PURE__*/React.createElement(Component.Body, _extends({}, manageMemberComponentConfig.bodyProps, {
8123
+ className: classnames(["ntm-members-form__body", (_manageMemberComponen = manageMemberComponentConfig.bodyProps) === null || _manageMemberComponen === void 0 ? void 0 : _manageMemberComponen.className])
8124
+ }), /*#__PURE__*/React.createElement(MultipleEmailInput, {
11207
8125
  emails: emails,
11208
8126
  selectedMember: selectedMember
11209
8127
  }), /*#__PURE__*/React.createElement(RolesRadioGroup, {
11210
8128
  role: role,
11211
- roles: roles
11212
- }))), /*#__PURE__*/React.createElement(Pane.Footer, {
11213
- className: "ntm-members-pane__footer"
11214
- }, /*#__PURE__*/React.createElement(Button, {
8129
+ roles: rolesList
8130
+ })), /*#__PURE__*/React.createElement(Component.Footer, _extends({}, manageMemberComponentConfig.footerProps, {
8131
+ className: classnames(["ntm-members-form__footer", (_manageMemberComponen2 = manageMemberComponentConfig.footerProps) === null || _manageMemberComponen2 === void 0 ? void 0 : _manageMemberComponen2.className])
8132
+ }), /*#__PURE__*/React.createElement(Button, {
11215
8133
  "data-cy": "ntm-manage-member-submit-button",
11216
8134
  disabled: !dirty || isSubmitting,
11217
8135
  label: instance.t("buttons.saveChanges"),
@@ -11222,7 +8140,7 @@ const ManageMember = _ref => {
11222
8140
  }), /*#__PURE__*/React.createElement(Button, {
11223
8141
  "data-cy": "ntm-manage-member-cancel-button",
11224
8142
  label: instance.t("buttons.cancel"),
11225
- onClick: onPaneClose,
8143
+ onClick: handleClose,
11226
8144
  style: "text"
11227
8145
  })));
11228
8146
  }));
@@ -11355,6 +8273,7 @@ const TeamMembers = _ref => {
11355
8273
  setIsOpen(assoc("manageMember", false));
11356
8274
  setSelectedMember(null);
11357
8275
  };
8276
+ const resetSelectedRows = () => setSelectedRows(DEFAULT_SELECTED_ROWS);
11358
8277
  const handleMemberFilterChange = filter => {
11359
8278
  setFilters(assoc("category", filter));
11360
8279
  clearSelectedMembers(filters.category, filter) && setSelectedRows(DEFAULT_SELECTED_ROWS);
@@ -11367,10 +8286,17 @@ const TeamMembers = _ref => {
11367
8286
  }));
11368
8287
  };
11369
8288
  const handleRowSelect = (keys, rowData) => {
11370
- setSelectedRows({
8289
+ var _config$table, _config$table$onRowSe;
8290
+ const rows = {
11371
8291
  active: pluck("active", rowData),
11372
8292
  emails: pluck("email", rowData),
11373
8293
  keys
8294
+ };
8295
+ setSelectedRows(_objectSpread({}, rows));
8296
+ config === null || config === void 0 ? void 0 : (_config$table = config.table) === null || _config$table === void 0 ? void 0 : (_config$table$onRowSe = _config$table.onRowSelect) === null || _config$table$onRowSe === void 0 ? void 0 : _config$table$onRowSe.call(_config$table, {
8297
+ rows,
8298
+ resetSelectedRows,
8299
+ rowData
11374
8300
  });
11375
8301
  };
11376
8302
  if (isRolesLoading || isMembersLoading) {
@@ -11398,23 +8324,22 @@ const TeamMembers = _ref => {
11398
8324
  actionBlock: /*#__PURE__*/React.createElement(Header, {
11399
8325
  metaName: metaName,
11400
8326
  onClick: () => setIsOpen(assoc("manageMember", true)),
11401
- permissions: config === null || config === void 0 ? void 0 : config.permissions
8327
+ permissions: config === null || config === void 0 ? void 0 : config.permissions,
8328
+ rolesButtonProps: config.rolesButtonProps
11402
8329
  })
11403
8330
  }), /*#__PURE__*/React.createElement(SubHeader$1, {
11404
8331
  leftActionBlock: /*#__PURE__*/React.createElement(SubHeader.Left, {
8332
+ config: config,
11405
8333
  filteredCount: team === null || team === void 0 ? void 0 : team.membersCount,
11406
8334
  metaName: metaName,
8335
+ roles: roles,
11407
8336
  selectedRows: selectedRows,
8337
+ setSelectedRows: setSelectedRows,
11408
8338
  totalCount: currentCategoryCount
11409
8339
  }),
11410
8340
  rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.Right, {
11411
8341
  columns: columns,
11412
- config: config,
11413
- roles: roles,
11414
- rolesButtonProps: config.rolesButtonProps,
11415
- selectedRows: selectedRows,
11416
- setColumnData: setColumnData,
11417
- setSelectedRows: setSelectedRows
8342
+ setColumnData: setColumnData
11418
8343
  })
11419
8344
  }), (team === null || team === void 0 ? void 0 : team.membersCount) !== 0 ? /*#__PURE__*/React.createElement("div", {
11420
8345
  className: "ntm-members__table-wrapper"
@@ -11445,11 +8370,12 @@ const TeamMembers = _ref => {
11445
8370
  })
11446
8371
  })), /*#__PURE__*/React.createElement(ManageMember, {
11447
8372
  config: config,
11448
- isOpen: isOpen.manageMember,
11449
- metaName: metaName,
11450
- onClose: handleModalClose,
8373
+ onComplete: handleModalClose,
11451
8374
  roles: roles,
11452
- selectedMember: selectedMember
8375
+ selectedMember: selectedMember,
8376
+ componentConfig: {
8377
+ isOpen: isOpen.manageMember
8378
+ }
11453
8379
  }), /*#__PURE__*/React.createElement(Alert, {
11454
8380
  isOpen: isOpen.alert,
11455
8381
  title: renderUpdateAlert("title", updateMemberAlertProps),
@@ -11480,8 +8406,8 @@ const VALIDATION_SCHEMA = {
11480
8406
 
11481
8407
  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
8408
 
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}";
8409
+ 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-form__header {\n margin-bottom: 0.5rem;\n}\n.ntm-members-form__body {\n width: 100%;\n padding-bottom: 1rem;\n}\n.ntm-members-form__body > * + * {\n margin-top: 1rem;\n}\n.ntm-members-form__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-form-radio-item__wrapper {\n width: 100%;\n cursor: pointer;\n padding: 8px 0px !important;\n}\n.ntm-members-form-radio-item__wrapper:first-child {\n padding-top: 0px !important;\n}\n.ntm-members-form-radio-item__label {\n margin-bottom: 0 !important;\n}\n.ntm-members-form-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
8410
  n(css,{});
11485
8411
 
11486
- export { MultipleEmailInput, index$1 as Roles, RolesRadioGroup, index as TeamMembers, VALIDATION_SCHEMA, hasPermission, refetchMembers };
8412
+ export { ManageMember, MultipleEmailInput, index$1 as Roles, RolesRadioGroup, index as TeamMembers, VALIDATION_SCHEMA, hasPermission, refetchMembers };
11487
8413
  //# sourceMappingURL=index.esm.js.map