@bigbinary/neeto-approvals-frontend 0.4.0-beta1 → 0.4.0-beta2

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.cjs.js CHANGED
@@ -15,13 +15,15 @@ var Table$1 = require('@bigbinary/neetoui/Table');
15
15
  var NoData = require('@bigbinary/neetoui/NoData');
16
16
  var ramda = require('ramda');
17
17
  var reactI18next = require('react-i18next');
18
- var jsxRuntime = require('react/jsx-runtime');
18
+ var reactQuery = require('@tanstack/react-query');
19
19
  var axios = require('axios');
20
20
  var Tag = require('@bigbinary/neetoui/Tag');
21
21
  var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
22
- var neetoEditor = require('@bigbinary/neeto-editor');
22
+ var utils = require('@bigbinary/neeto-editor/utils');
23
23
  var yup = require('yup');
24
- var utils = require('@bigbinary/neeto-commons-frontend/utils');
24
+ var jsxRuntime = require('react/jsx-runtime');
25
+ var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
26
+ var EditorContent = require('@bigbinary/neeto-editor/EditorContent');
25
27
  var Label = require('@bigbinary/neetoui/Label');
26
28
  var Pane = require('@bigbinary/neetoui/Pane');
27
29
  var Textarea = require('@bigbinary/neetoui/Textarea');
@@ -38,6 +40,7 @@ var formik = require('formik');
38
40
  var ToggleFeatureCard = require('@bigbinary/neeto-molecules/ToggleFeatureCard');
39
41
  var Input = require('@bigbinary/neetoui/formik/Input');
40
42
  var Textarea$1 = require('@bigbinary/neetoui/formik/Textarea');
43
+ var FormikEditor = require('@bigbinary/neeto-editor/FormikEditor');
41
44
  var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
42
45
  var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
43
46
  var NeetoUITab = require('@bigbinary/neetoui/Tab');
@@ -64,7 +67,6 @@ function _interopNamespace(e) {
64
67
  return Object.freeze(n);
65
68
  }
66
69
 
67
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
68
70
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
69
71
  var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
70
72
  var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
@@ -76,6 +78,7 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
76
78
  var Tag__default = /*#__PURE__*/_interopDefaultLegacy(Tag);
77
79
  var DateFormat__default = /*#__PURE__*/_interopDefaultLegacy(DateFormat);
78
80
  var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
81
+ var EditorContent__default = /*#__PURE__*/_interopDefaultLegacy(EditorContent);
79
82
  var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
80
83
  var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
81
84
  var Textarea__default = /*#__PURE__*/_interopDefaultLegacy(Textarea);
@@ -90,6 +93,7 @@ var FormikForm__default = /*#__PURE__*/_interopDefaultLegacy(FormikForm);
90
93
  var ToggleFeatureCard__default = /*#__PURE__*/_interopDefaultLegacy(ToggleFeatureCard);
91
94
  var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
92
95
  var Textarea__default$1 = /*#__PURE__*/_interopDefaultLegacy(Textarea$1);
96
+ var FormikEditor__default = /*#__PURE__*/_interopDefaultLegacy(FormikEditor);
93
97
  var MoreDropdown__default = /*#__PURE__*/_interopDefaultLegacy(MoreDropdown);
94
98
  var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
95
99
  var NeetoUITab__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUITab);
@@ -211,868 +215,6 @@ var handleEmptyPage = function handleEmptyPage(data, pageProperties, handlePageC
211
215
  }
212
216
  };
213
217
 
214
- // src/subscribable.ts
215
- var Subscribable = class {
216
- constructor() {
217
- this.listeners = /* @__PURE__ */ new Set();
218
- this.subscribe = this.subscribe.bind(this);
219
- }
220
- subscribe(listener) {
221
- this.listeners.add(listener);
222
- this.onSubscribe();
223
- return () => {
224
- this.listeners.delete(listener);
225
- this.onUnsubscribe();
226
- };
227
- }
228
- hasListeners() {
229
- return this.listeners.size > 0;
230
- }
231
- onSubscribe() {
232
- }
233
- onUnsubscribe() {
234
- }
235
- };
236
-
237
- // src/utils.ts
238
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
239
- function noop() {
240
- return void 0;
241
- }
242
- function isValidTimeout(value) {
243
- return typeof value === "number" && value >= 0 && value !== Infinity;
244
- }
245
- function timeUntilStale(updatedAt, staleTime) {
246
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
247
- }
248
- function replaceEqualDeep(a, b) {
249
- if (a === b) {
250
- return a;
251
- }
252
- const array = isPlainArray(a) && isPlainArray(b);
253
- if (array || isPlainObject(a) && isPlainObject(b)) {
254
- const aItems = array ? a : Object.keys(a);
255
- const aSize = aItems.length;
256
- const bItems = array ? b : Object.keys(b);
257
- const bSize = bItems.length;
258
- const copy = array ? [] : {};
259
- let equalItems = 0;
260
- for (let i = 0; i < bSize; i++) {
261
- const key = array ? i : bItems[i];
262
- if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) {
263
- copy[key] = void 0;
264
- equalItems++;
265
- } else {
266
- copy[key] = replaceEqualDeep(a[key], b[key]);
267
- if (copy[key] === a[key] && a[key] !== void 0) {
268
- equalItems++;
269
- }
270
- }
271
- }
272
- return aSize === bSize && equalItems === aSize ? a : copy;
273
- }
274
- return b;
275
- }
276
- function shallowEqualObjects(a, b) {
277
- if (!b || Object.keys(a).length !== Object.keys(b).length) {
278
- return false;
279
- }
280
- for (const key in a) {
281
- if (a[key] !== b[key]) {
282
- return false;
283
- }
284
- }
285
- return true;
286
- }
287
- function isPlainArray(value) {
288
- return Array.isArray(value) && value.length === Object.keys(value).length;
289
- }
290
- function isPlainObject(o) {
291
- if (!hasObjectPrototype(o)) {
292
- return false;
293
- }
294
- const ctor = o.constructor;
295
- if (ctor === void 0) {
296
- return true;
297
- }
298
- const prot = ctor.prototype;
299
- if (!hasObjectPrototype(prot)) {
300
- return false;
301
- }
302
- if (!prot.hasOwnProperty("isPrototypeOf")) {
303
- return false;
304
- }
305
- if (Object.getPrototypeOf(o) !== Object.prototype) {
306
- return false;
307
- }
308
- return true;
309
- }
310
- function hasObjectPrototype(o) {
311
- return Object.prototype.toString.call(o) === "[object Object]";
312
- }
313
- function replaceData(prevData, data, options) {
314
- if (typeof options.structuralSharing === "function") {
315
- return options.structuralSharing(prevData, data);
316
- } else if (options.structuralSharing !== false) {
317
- return replaceEqualDeep(prevData, data);
318
- }
319
- return data;
320
- }
321
- function keepPreviousData(previousData) {
322
- return previousData;
323
- }
324
-
325
- // src/focusManager.ts
326
- var FocusManager = class extends Subscribable {
327
- #focused;
328
- #cleanup;
329
- #setup;
330
- constructor() {
331
- super();
332
- this.#setup = (onFocus) => {
333
- if (!isServer && window.addEventListener) {
334
- const listener = () => onFocus();
335
- window.addEventListener("visibilitychange", listener, false);
336
- return () => {
337
- window.removeEventListener("visibilitychange", listener);
338
- };
339
- }
340
- return;
341
- };
342
- }
343
- onSubscribe() {
344
- if (!this.#cleanup) {
345
- this.setEventListener(this.#setup);
346
- }
347
- }
348
- onUnsubscribe() {
349
- if (!this.hasListeners()) {
350
- this.#cleanup?.();
351
- this.#cleanup = void 0;
352
- }
353
- }
354
- setEventListener(setup) {
355
- this.#setup = setup;
356
- this.#cleanup?.();
357
- this.#cleanup = setup((focused) => {
358
- if (typeof focused === "boolean") {
359
- this.setFocused(focused);
360
- } else {
361
- this.onFocus();
362
- }
363
- });
364
- }
365
- setFocused(focused) {
366
- const changed = this.#focused !== focused;
367
- if (changed) {
368
- this.#focused = focused;
369
- this.onFocus();
370
- }
371
- }
372
- onFocus() {
373
- const isFocused = this.isFocused();
374
- this.listeners.forEach((listener) => {
375
- listener(isFocused);
376
- });
377
- }
378
- isFocused() {
379
- if (typeof this.#focused === "boolean") {
380
- return this.#focused;
381
- }
382
- return globalThis.document?.visibilityState !== "hidden";
383
- }
384
- };
385
- var focusManager = new FocusManager();
386
-
387
- // src/onlineManager.ts
388
- var OnlineManager = class extends Subscribable {
389
- #online = true;
390
- #cleanup;
391
- #setup;
392
- constructor() {
393
- super();
394
- this.#setup = (onOnline) => {
395
- if (!isServer && window.addEventListener) {
396
- const onlineListener = () => onOnline(true);
397
- const offlineListener = () => onOnline(false);
398
- window.addEventListener("online", onlineListener, false);
399
- window.addEventListener("offline", offlineListener, false);
400
- return () => {
401
- window.removeEventListener("online", onlineListener);
402
- window.removeEventListener("offline", offlineListener);
403
- };
404
- }
405
- return;
406
- };
407
- }
408
- onSubscribe() {
409
- if (!this.#cleanup) {
410
- this.setEventListener(this.#setup);
411
- }
412
- }
413
- onUnsubscribe() {
414
- if (!this.hasListeners()) {
415
- this.#cleanup?.();
416
- this.#cleanup = void 0;
417
- }
418
- }
419
- setEventListener(setup) {
420
- this.#setup = setup;
421
- this.#cleanup?.();
422
- this.#cleanup = setup(this.setOnline.bind(this));
423
- }
424
- setOnline(online) {
425
- const changed = this.#online !== online;
426
- if (changed) {
427
- this.#online = online;
428
- this.listeners.forEach((listener) => {
429
- listener(online);
430
- });
431
- }
432
- }
433
- isOnline() {
434
- return this.#online;
435
- }
436
- };
437
- var onlineManager = new OnlineManager();
438
-
439
- // src/retryer.ts
440
- function canFetch(networkMode) {
441
- return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
442
- }
443
-
444
- // src/notifyManager.ts
445
- function createNotifyManager() {
446
- let queue = [];
447
- let transactions = 0;
448
- let notifyFn = (callback) => {
449
- callback();
450
- };
451
- let batchNotifyFn = (callback) => {
452
- callback();
453
- };
454
- let scheduleFn = (cb) => setTimeout(cb, 0);
455
- const setScheduler = (fn) => {
456
- scheduleFn = fn;
457
- };
458
- const batch = (callback) => {
459
- let result;
460
- transactions++;
461
- try {
462
- result = callback();
463
- } finally {
464
- transactions--;
465
- if (!transactions) {
466
- flush();
467
- }
468
- }
469
- return result;
470
- };
471
- const schedule = (callback) => {
472
- if (transactions) {
473
- queue.push(callback);
474
- } else {
475
- scheduleFn(() => {
476
- notifyFn(callback);
477
- });
478
- }
479
- };
480
- const batchCalls = (callback) => {
481
- return (...args) => {
482
- schedule(() => {
483
- callback(...args);
484
- });
485
- };
486
- };
487
- const flush = () => {
488
- const originalQueue = queue;
489
- queue = [];
490
- if (originalQueue.length) {
491
- scheduleFn(() => {
492
- batchNotifyFn(() => {
493
- originalQueue.forEach((callback) => {
494
- notifyFn(callback);
495
- });
496
- });
497
- });
498
- }
499
- };
500
- const setNotifyFunction = (fn) => {
501
- notifyFn = fn;
502
- };
503
- const setBatchNotifyFunction = (fn) => {
504
- batchNotifyFn = fn;
505
- };
506
- return {
507
- batch,
508
- batchCalls,
509
- schedule,
510
- setNotifyFunction,
511
- setBatchNotifyFunction,
512
- setScheduler
513
- };
514
- }
515
- var notifyManager = createNotifyManager();
516
-
517
- // src/query.ts
518
- function fetchState(data, options) {
519
- return {
520
- fetchFailureCount: 0,
521
- fetchFailureReason: null,
522
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
523
- ...data === void 0 && {
524
- error: null,
525
- status: "pending"
526
- }
527
- };
528
- }
529
-
530
- // src/queryObserver.ts
531
- var QueryObserver = class extends Subscribable {
532
- constructor(client, options) {
533
- super();
534
- this.options = options;
535
- this.#client = client;
536
- this.#selectError = null;
537
- this.bindMethods();
538
- this.setOptions(options);
539
- }
540
- #client;
541
- #currentQuery = void 0;
542
- #currentQueryInitialState = void 0;
543
- #currentResult = void 0;
544
- #currentResultState;
545
- #currentResultOptions;
546
- #selectError;
547
- #selectFn;
548
- #selectResult;
549
- // This property keeps track of the last query with defined data.
550
- // It will be used to pass the previous data and query to the placeholder function between renders.
551
- #lastQueryWithDefinedData;
552
- #staleTimeoutId;
553
- #refetchIntervalId;
554
- #currentRefetchInterval;
555
- #trackedProps = /* @__PURE__ */ new Set();
556
- bindMethods() {
557
- this.refetch = this.refetch.bind(this);
558
- }
559
- onSubscribe() {
560
- if (this.listeners.size === 1) {
561
- this.#currentQuery.addObserver(this);
562
- if (shouldFetchOnMount(this.#currentQuery, this.options)) {
563
- this.#executeFetch();
564
- } else {
565
- this.updateResult();
566
- }
567
- this.#updateTimers();
568
- }
569
- }
570
- onUnsubscribe() {
571
- if (!this.hasListeners()) {
572
- this.destroy();
573
- }
574
- }
575
- shouldFetchOnReconnect() {
576
- return shouldFetchOn(
577
- this.#currentQuery,
578
- this.options,
579
- this.options.refetchOnReconnect
580
- );
581
- }
582
- shouldFetchOnWindowFocus() {
583
- return shouldFetchOn(
584
- this.#currentQuery,
585
- this.options,
586
- this.options.refetchOnWindowFocus
587
- );
588
- }
589
- destroy() {
590
- this.listeners = /* @__PURE__ */ new Set();
591
- this.#clearStaleTimeout();
592
- this.#clearRefetchInterval();
593
- this.#currentQuery.removeObserver(this);
594
- }
595
- setOptions(options, notifyOptions) {
596
- const prevOptions = this.options;
597
- const prevQuery = this.#currentQuery;
598
- this.options = this.#client.defaultQueryOptions(options);
599
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean") {
600
- throw new Error("Expected enabled to be a boolean");
601
- }
602
- this.#updateQuery();
603
- this.#currentQuery.setOptions(this.options);
604
- if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
605
- this.#client.getQueryCache().notify({
606
- type: "observerOptionsUpdated",
607
- query: this.#currentQuery,
608
- observer: this
609
- });
610
- }
611
- const mounted = this.hasListeners();
612
- if (mounted && shouldFetchOptionally(
613
- this.#currentQuery,
614
- prevQuery,
615
- this.options,
616
- prevOptions
617
- )) {
618
- this.#executeFetch();
619
- }
620
- this.updateResult(notifyOptions);
621
- if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
622
- this.#updateStaleTimeout();
623
- }
624
- const nextRefetchInterval = this.#computeRefetchInterval();
625
- if (mounted && (this.#currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.#currentRefetchInterval)) {
626
- this.#updateRefetchInterval(nextRefetchInterval);
627
- }
628
- }
629
- getOptimisticResult(options) {
630
- const query = this.#client.getQueryCache().build(this.#client, options);
631
- const result = this.createResult(query, options);
632
- if (shouldAssignObserverCurrentProperties(this, result)) {
633
- this.#currentResult = result;
634
- this.#currentResultOptions = this.options;
635
- this.#currentResultState = this.#currentQuery.state;
636
- }
637
- return result;
638
- }
639
- getCurrentResult() {
640
- return this.#currentResult;
641
- }
642
- trackResult(result, onPropTracked) {
643
- const trackedResult = {};
644
- Object.keys(result).forEach((key) => {
645
- Object.defineProperty(trackedResult, key, {
646
- configurable: false,
647
- enumerable: true,
648
- get: () => {
649
- this.trackProp(key);
650
- onPropTracked?.(key);
651
- return result[key];
652
- }
653
- });
654
- });
655
- return trackedResult;
656
- }
657
- trackProp(key) {
658
- this.#trackedProps.add(key);
659
- }
660
- getCurrentQuery() {
661
- return this.#currentQuery;
662
- }
663
- refetch({ ...options } = {}) {
664
- return this.fetch({
665
- ...options
666
- });
667
- }
668
- fetchOptimistic(options) {
669
- const defaultedOptions = this.#client.defaultQueryOptions(options);
670
- const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
671
- query.isFetchingOptimistic = true;
672
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
673
- }
674
- fetch(fetchOptions) {
675
- return this.#executeFetch({
676
- ...fetchOptions,
677
- cancelRefetch: fetchOptions.cancelRefetch ?? true
678
- }).then(() => {
679
- this.updateResult();
680
- return this.#currentResult;
681
- });
682
- }
683
- #executeFetch(fetchOptions) {
684
- this.#updateQuery();
685
- let promise = this.#currentQuery.fetch(
686
- this.options,
687
- fetchOptions
688
- );
689
- if (!fetchOptions?.throwOnError) {
690
- promise = promise.catch(noop);
691
- }
692
- return promise;
693
- }
694
- #updateStaleTimeout() {
695
- this.#clearStaleTimeout();
696
- if (isServer || this.#currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
697
- return;
698
- }
699
- const time = timeUntilStale(
700
- this.#currentResult.dataUpdatedAt,
701
- this.options.staleTime
702
- );
703
- const timeout = time + 1;
704
- this.#staleTimeoutId = setTimeout(() => {
705
- if (!this.#currentResult.isStale) {
706
- this.updateResult();
707
- }
708
- }, timeout);
709
- }
710
- #computeRefetchInterval() {
711
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
712
- }
713
- #updateRefetchInterval(nextInterval) {
714
- this.#clearRefetchInterval();
715
- this.#currentRefetchInterval = nextInterval;
716
- if (isServer || this.options.enabled === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
717
- return;
718
- }
719
- this.#refetchIntervalId = setInterval(() => {
720
- if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
721
- this.#executeFetch();
722
- }
723
- }, this.#currentRefetchInterval);
724
- }
725
- #updateTimers() {
726
- this.#updateStaleTimeout();
727
- this.#updateRefetchInterval(this.#computeRefetchInterval());
728
- }
729
- #clearStaleTimeout() {
730
- if (this.#staleTimeoutId) {
731
- clearTimeout(this.#staleTimeoutId);
732
- this.#staleTimeoutId = void 0;
733
- }
734
- }
735
- #clearRefetchInterval() {
736
- if (this.#refetchIntervalId) {
737
- clearInterval(this.#refetchIntervalId);
738
- this.#refetchIntervalId = void 0;
739
- }
740
- }
741
- createResult(query, options) {
742
- const prevQuery = this.#currentQuery;
743
- const prevOptions = this.options;
744
- const prevResult = this.#currentResult;
745
- const prevResultState = this.#currentResultState;
746
- const prevResultOptions = this.#currentResultOptions;
747
- const queryChange = query !== prevQuery;
748
- const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
749
- const { state } = query;
750
- let newState = { ...state };
751
- let isPlaceholderData = false;
752
- let data;
753
- if (options._optimisticResults) {
754
- const mounted = this.hasListeners();
755
- const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
756
- const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
757
- if (fetchOnMount || fetchOptionally) {
758
- newState = {
759
- ...newState,
760
- ...fetchState(state.data, query.options)
761
- };
762
- }
763
- if (options._optimisticResults === "isRestoring") {
764
- newState.fetchStatus = "idle";
765
- }
766
- }
767
- let { error, errorUpdatedAt, status } = newState;
768
- if (options.select && newState.data !== void 0) {
769
- if (prevResult && newState.data === prevResultState?.data && options.select === this.#selectFn) {
770
- data = this.#selectResult;
771
- } else {
772
- try {
773
- this.#selectFn = options.select;
774
- data = options.select(newState.data);
775
- data = replaceData(prevResult?.data, data, options);
776
- this.#selectResult = data;
777
- this.#selectError = null;
778
- } catch (selectError) {
779
- this.#selectError = selectError;
780
- }
781
- }
782
- } else {
783
- data = newState.data;
784
- }
785
- if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
786
- let placeholderData;
787
- if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
788
- placeholderData = prevResult.data;
789
- } else {
790
- placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
791
- this.#lastQueryWithDefinedData?.state.data,
792
- this.#lastQueryWithDefinedData
793
- ) : options.placeholderData;
794
- if (options.select && placeholderData !== void 0) {
795
- try {
796
- placeholderData = options.select(placeholderData);
797
- this.#selectError = null;
798
- } catch (selectError) {
799
- this.#selectError = selectError;
800
- }
801
- }
802
- }
803
- if (placeholderData !== void 0) {
804
- status = "success";
805
- data = replaceData(
806
- prevResult?.data,
807
- placeholderData,
808
- options
809
- );
810
- isPlaceholderData = true;
811
- }
812
- }
813
- if (this.#selectError) {
814
- error = this.#selectError;
815
- data = this.#selectResult;
816
- errorUpdatedAt = Date.now();
817
- status = "error";
818
- }
819
- const isFetching = newState.fetchStatus === "fetching";
820
- const isPending = status === "pending";
821
- const isError = status === "error";
822
- const isLoading = isPending && isFetching;
823
- const hasData = data !== void 0;
824
- const result = {
825
- status,
826
- fetchStatus: newState.fetchStatus,
827
- isPending,
828
- isSuccess: status === "success",
829
- isError,
830
- isInitialLoading: isLoading,
831
- isLoading,
832
- data,
833
- dataUpdatedAt: newState.dataUpdatedAt,
834
- error,
835
- errorUpdatedAt,
836
- failureCount: newState.fetchFailureCount,
837
- failureReason: newState.fetchFailureReason,
838
- errorUpdateCount: newState.errorUpdateCount,
839
- isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
840
- isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
841
- isFetching,
842
- isRefetching: isFetching && !isPending,
843
- isLoadingError: isError && !hasData,
844
- isPaused: newState.fetchStatus === "paused",
845
- isPlaceholderData,
846
- isRefetchError: isError && hasData,
847
- isStale: isStale(query, options),
848
- refetch: this.refetch
849
- };
850
- return result;
851
- }
852
- updateResult(notifyOptions) {
853
- const prevResult = this.#currentResult;
854
- const nextResult = this.createResult(this.#currentQuery, this.options);
855
- this.#currentResultState = this.#currentQuery.state;
856
- this.#currentResultOptions = this.options;
857
- if (this.#currentResultState.data !== void 0) {
858
- this.#lastQueryWithDefinedData = this.#currentQuery;
859
- }
860
- if (shallowEqualObjects(nextResult, prevResult)) {
861
- return;
862
- }
863
- this.#currentResult = nextResult;
864
- const defaultNotifyOptions = {};
865
- const shouldNotifyListeners = () => {
866
- if (!prevResult) {
867
- return true;
868
- }
869
- const { notifyOnChangeProps } = this.options;
870
- const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
871
- if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
872
- return true;
873
- }
874
- const includedProps = new Set(
875
- notifyOnChangePropsValue ?? this.#trackedProps
876
- );
877
- if (this.options.throwOnError) {
878
- includedProps.add("error");
879
- }
880
- return Object.keys(this.#currentResult).some((key) => {
881
- const typedKey = key;
882
- const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
883
- return changed && includedProps.has(typedKey);
884
- });
885
- };
886
- if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
887
- defaultNotifyOptions.listeners = true;
888
- }
889
- this.#notify({ ...defaultNotifyOptions, ...notifyOptions });
890
- }
891
- #updateQuery() {
892
- const query = this.#client.getQueryCache().build(this.#client, this.options);
893
- if (query === this.#currentQuery) {
894
- return;
895
- }
896
- const prevQuery = this.#currentQuery;
897
- this.#currentQuery = query;
898
- this.#currentQueryInitialState = query.state;
899
- if (this.hasListeners()) {
900
- prevQuery?.removeObserver(this);
901
- query.addObserver(this);
902
- }
903
- }
904
- onQueryUpdate() {
905
- this.updateResult();
906
- if (this.hasListeners()) {
907
- this.#updateTimers();
908
- }
909
- }
910
- #notify(notifyOptions) {
911
- notifyManager.batch(() => {
912
- if (notifyOptions.listeners) {
913
- this.listeners.forEach((listener) => {
914
- listener(this.#currentResult);
915
- });
916
- }
917
- this.#client.getQueryCache().notify({
918
- query: this.#currentQuery,
919
- type: "observerResultsUpdated"
920
- });
921
- });
922
- }
923
- };
924
- function shouldLoadOnMount(query, options) {
925
- return options.enabled !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
926
- }
927
- function shouldFetchOnMount(query, options) {
928
- return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
929
- }
930
- function shouldFetchOn(query, options, field) {
931
- if (options.enabled !== false) {
932
- const value = typeof field === "function" ? field(query) : field;
933
- return value === "always" || value !== false && isStale(query, options);
934
- }
935
- return false;
936
- }
937
- function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
938
- return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
939
- }
940
- function isStale(query, options) {
941
- return options.enabled !== false && query.isStaleByTime(options.staleTime);
942
- }
943
- function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
944
- if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
945
- return true;
946
- }
947
- return false;
948
- }
949
-
950
- var QueryClientContext = React__namespace.createContext(
951
- void 0
952
- );
953
- var useQueryClient = (queryClient) => {
954
- const client = React__namespace.useContext(QueryClientContext);
955
- if (queryClient) {
956
- return queryClient;
957
- }
958
- if (!client) {
959
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
960
- }
961
- return client;
962
- };
963
-
964
- var IsRestoringContext = React__namespace.createContext(false);
965
- var useIsRestoring = () => React__namespace.useContext(IsRestoringContext);
966
- IsRestoringContext.Provider;
967
-
968
- function createValue() {
969
- let isReset = false;
970
- return {
971
- clearReset: () => {
972
- isReset = false;
973
- },
974
- reset: () => {
975
- isReset = true;
976
- },
977
- isReset: () => {
978
- return isReset;
979
- }
980
- };
981
- }
982
- var QueryErrorResetBoundaryContext = React__namespace.createContext(createValue());
983
- var useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext);
984
-
985
- // src/utils.ts
986
- function shouldThrowError(throwError, params) {
987
- if (typeof throwError === "function") {
988
- return throwError(...params);
989
- }
990
- return !!throwError;
991
- }
992
-
993
- var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
994
- if (options.suspense || options.throwOnError) {
995
- if (!errorResetBoundary.isReset()) {
996
- options.retryOnMount = false;
997
- }
998
- }
999
- };
1000
- var useClearResetErrorBoundary = (errorResetBoundary) => {
1001
- React__namespace.useEffect(() => {
1002
- errorResetBoundary.clearReset();
1003
- }, [errorResetBoundary]);
1004
- };
1005
- var getHasError = ({
1006
- result,
1007
- errorResetBoundary,
1008
- throwOnError,
1009
- query
1010
- }) => {
1011
- return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]);
1012
- };
1013
-
1014
- // src/suspense.ts
1015
- var ensureStaleTime = (defaultedOptions) => {
1016
- if (defaultedOptions.suspense) {
1017
- if (typeof defaultedOptions.staleTime !== "number") {
1018
- defaultedOptions.staleTime = 1e3;
1019
- }
1020
- }
1021
- };
1022
- var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
1023
- var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
1024
- errorResetBoundary.clearReset();
1025
- });
1026
-
1027
- function useBaseQuery(options, Observer, queryClient) {
1028
- const client = useQueryClient(queryClient);
1029
- const isRestoring = useIsRestoring();
1030
- const errorResetBoundary = useQueryErrorResetBoundary();
1031
- const defaultedOptions = client.defaultQueryOptions(options);
1032
- defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
1033
- ensureStaleTime(defaultedOptions);
1034
- ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
1035
- useClearResetErrorBoundary(errorResetBoundary);
1036
- const [observer] = React__namespace.useState(
1037
- () => new Observer(
1038
- client,
1039
- defaultedOptions
1040
- )
1041
- );
1042
- const result = observer.getOptimisticResult(defaultedOptions);
1043
- React__namespace.useSyncExternalStore(
1044
- React__namespace.useCallback(
1045
- (onStoreChange) => {
1046
- const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
1047
- observer.updateResult();
1048
- return unsubscribe;
1049
- },
1050
- [observer, isRestoring]
1051
- ),
1052
- () => observer.getCurrentResult(),
1053
- () => observer.getCurrentResult()
1054
- );
1055
- React__namespace.useEffect(() => {
1056
- observer.setOptions(defaultedOptions, { listeners: false });
1057
- }, [defaultedOptions, observer]);
1058
- if (shouldSuspend(defaultedOptions, result)) {
1059
- throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
1060
- }
1061
- if (getHasError({
1062
- result,
1063
- errorResetBoundary,
1064
- throwOnError: defaultedOptions.throwOnError,
1065
- query: client.getQueryCache().get(defaultedOptions.queryHash)
1066
- })) {
1067
- throw result.error;
1068
- }
1069
- return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
1070
- }
1071
-
1072
- function useQuery(options, queryClient) {
1073
- return useBaseQuery(options, QueryObserver, queryClient);
1074
- }
1075
-
1076
218
  var BASE_URL = "neeto_approvals";
1077
219
  var TEMPLATE_URL = "".concat(BASE_URL, "/templates");
1078
220
 
@@ -1110,7 +252,7 @@ var useFetchRequests = function useFetchRequests(_ref) {
1110
252
  params = _ref$params === void 0 ? {} : _ref$params,
1111
253
  _ref$options = _ref.options,
1112
254
  options = _ref$options === void 0 ? {} : _ref$options;
1113
- return useQuery(_objectSpread$b({
255
+ return reactQuery.useQuery(_objectSpread$b({
1114
256
  queryKey: [QUERY_KEYS.REQUESTS, params],
1115
257
  queryFn: function queryFn() {
1116
258
  return requestsApi.fetch(params, requestUrl);
@@ -1118,7 +260,7 @@ var useFetchRequests = function useFetchRequests(_ref) {
1118
260
  select: function select(response) {
1119
261
  return response.data || response;
1120
262
  },
1121
- placeholderData: keepPreviousData
263
+ placeholderData: reactQuery.keepPreviousData
1122
264
  }, options));
1123
265
  };
1124
266
  var useUpdateRequest = function useUpdateRequest(options) {
@@ -1190,10 +332,13 @@ var REQUEST_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
1190
332
  message: yup__namespace.string().test("message", i18next.t("neetoApprovals.validations.required", {
1191
333
  what: i18next.t("neetoApprovals.inputs.labels.message")
1192
334
  }), function (content) {
1193
- return !neetoEditor.isEditorEmpty(content);
335
+ return !utils.isEditorEmpty(content);
1194
336
  }),
1195
337
  approver: yup__namespace.object().required(i18next.t("neetoApprovals.validations.approver"))
1196
338
  });
339
+ var EVENTS = {
340
+ APPROVAL_TEMPLATE_CREATED: "approval_template_created"
341
+ };
1197
342
 
1198
343
  var HISTORY_TABLE_COLUMNS = [{
1199
344
  dataIndex: "approvalLabel",
@@ -1320,7 +465,7 @@ var getApprovalFilter = function getApprovalFilter() {
1320
465
  };
1321
466
  };
1322
467
 
1323
- var MemoizedEditorContent$1 = /*#__PURE__*/React__default["default"].memo(neetoEditor.EditorContent);
468
+ var MemoizedEditorContent$1 = /*#__PURE__*/React__default["default"].memo(EditorContent__default["default"]);
1324
469
  var RequestDetailsPane = function RequestDetailsPane(_ref) {
1325
470
  var _window$globalProps, _window$globalProps2;
1326
471
  var isOpen = _ref.isOpen,
@@ -1410,7 +555,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
1410
555
  }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
1411
556
  style: "body2",
1412
557
  weight: "medium",
1413
- children: utils.dateFormat.defaultWithTime(timeInZone(createdAt))
558
+ children: utils$1.dateFormat.defaultWithTime(timeInZone(createdAt))
1414
559
  })]
1415
560
  })]
1416
561
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -1429,7 +574,7 @@ var RequestDetailsPane = function RequestDetailsPane(_ref) {
1429
574
  placeholder: t("neetoApprovals.inputs.placeholders.add_", {
1430
575
  what: t("neetoApprovals.common.note")
1431
576
  }),
1432
- onChange: utils.withEventTargetValue(setNote)
577
+ onChange: utils$1.withEventTargetValue(setNote)
1433
578
  }), !isPending && note && /*#__PURE__*/jsxRuntime.jsxs("div", {
1434
579
  className: "w-full space-y-2",
1435
580
  children: [/*#__PURE__*/jsxRuntime.jsx(Label__default["default"], {
@@ -1688,7 +833,7 @@ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t
1688
833
  var useFetchTemplates = function useFetchTemplates() {
1689
834
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1690
835
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1691
- return useQuery(_objectSpread$8({
836
+ return reactQuery.useQuery(_objectSpread$8({
1692
837
  queryKey: [QUERY_KEYS.TEMPLATES, params],
1693
838
  queryFn: function queryFn() {
1694
839
  return templatesApi.fetch(params);
@@ -1696,13 +841,13 @@ var useFetchTemplates = function useFetchTemplates() {
1696
841
  select: function select(response) {
1697
842
  return response.data || response;
1698
843
  },
1699
- placeholderData: keepPreviousData
844
+ placeholderData: reactQuery.keepPreviousData
1700
845
  }, options));
1701
846
  };
1702
847
  var useFetchTemplate = function useFetchTemplate(_ref) {
1703
848
  var id = _ref.id,
1704
849
  params = _ref.params;
1705
- return useQuery({
850
+ return reactQuery.useQuery({
1706
851
  queryKey: [QUERY_KEYS.SHOW_TEMPLATE, id, params],
1707
852
  queryFn: function queryFn() {
1708
853
  return templatesApi.show({
@@ -1713,10 +858,13 @@ var useFetchTemplate = function useFetchTemplate(_ref) {
1713
858
  enabled: !!id
1714
859
  });
1715
860
  };
1716
- var useCreateTemplate = function useCreateTemplate(options) {
1717
- return reactUtils.useMutationWithInvalidation(templatesApi.create, _objectSpread$8({
1718
- keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]]
1719
- }, options));
861
+ var useCreateTemplate = function useCreateTemplate() {
862
+ return reactUtils.useMutationWithInvalidation(templatesApi.create, {
863
+ keysToInvalidate: [[QUERY_KEYS.TEMPLATES], [QUERY_KEYS.VIEWS]],
864
+ onSuccess: function onSuccess() {
865
+ return utils$1.captureAnalyticsEvent(EVENTS.APPROVAL_TEMPLATE_CREATED);
866
+ }
867
+ });
1720
868
  };
1721
869
  var useUpdateTemplate = function useUpdateTemplate(options) {
1722
870
  return reactUtils.useMutationWithInvalidation(templatesApi.update, _objectSpread$8({
@@ -1744,7 +892,7 @@ var TEMPLATE_FORM_VALIDATION_SCHEMA = yup__namespace.object().shape({
1744
892
  message: yup__namespace.string().test("message", i18next.t("neetoApprovals.validations.required", {
1745
893
  what: i18next.t("neetoApprovals.inputs.labels.message")
1746
894
  }), function (content) {
1747
- return !neetoEditor.isEditorEmpty(content);
895
+ return !utils.isEditorEmpty(content);
1748
896
  })
1749
897
  });
1750
898
 
@@ -1754,7 +902,7 @@ var MessageEditor = reactUtils.withT(function (_ref) {
1754
902
  placeholders = _ref$placeholders === void 0 ? [] : _ref$placeholders,
1755
903
  _ref$initialValue = _ref.initialValue,
1756
904
  initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue;
1757
- return /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, {
905
+ return /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], {
1758
906
  initialValue: initialValue,
1759
907
  required: true,
1760
908
  label: t("neetoApprovals.inputs.labels.message"),
@@ -1952,7 +1100,7 @@ var Field = function Field(_ref) {
1952
1100
  };
1953
1101
  var Field$1 = /*#__PURE__*/React__default["default"].memo(Field);
1954
1102
 
1955
- var MemoizedEditorContent = /*#__PURE__*/React__default["default"].memo(neetoEditor.EditorContent);
1103
+ var MemoizedEditorContent = /*#__PURE__*/React__default["default"].memo(EditorContent__default["default"]);
1956
1104
  var TemplateDetails = function TemplateDetails(_ref) {
1957
1105
  var isOpen = _ref.isOpen,
1958
1106
  onClose = _ref.onClose,
@@ -2354,7 +1502,7 @@ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymb
2354
1502
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2355
1503
  var useFetchViews = function useFetchViews() {
2356
1504
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2357
- return useQuery(_objectSpread$3({
1505
+ return reactQuery.useQuery(_objectSpread$3({
2358
1506
  queryKey: [QUERY_KEYS.VIEWS],
2359
1507
  queryFn: viewsApi.fetch,
2360
1508
  select: function select(response) {
@@ -2458,7 +1606,7 @@ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t
2458
1606
  var useFetchApprovers = function useFetchApprovers() {
2459
1607
  var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2460
1608
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2461
- return useQuery(_objectSpread$1({
1609
+ return reactQuery.useQuery(_objectSpread$1({
2462
1610
  queryKey: [QUERY_KEYS.APPROVERS, params],
2463
1611
  queryFn: function queryFn() {
2464
1612
  return approversApi.fetch(params);
@@ -2566,7 +1714,7 @@ var Form$1 = function Form(_ref) {
2566
1714
  })
2567
1715
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
2568
1716
  className: "space-y-2",
2569
- children: /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, {
1717
+ children: /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], {
2570
1718
  required: true,
2571
1719
  label: t("neetoApprovals.inputs.labels.message"),
2572
1720
  name: "message",
@@ -2665,7 +1813,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
2665
1813
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2666
1814
  var useFetchPublicRequest = function useFetchPublicRequest(_ref, options) {
2667
1815
  var requestId = _ref.requestId;
2668
- return useQuery(_objectSpread({
1816
+ return reactQuery.useQuery(_objectSpread({
2669
1817
  queryKey: [QUERY_KEYS.SHOW_PUBLIC_REQUEST, requestId],
2670
1818
  queryFn: function queryFn() {
2671
1819
  return publicRequestsApi.show(requestId);
@@ -2733,7 +1881,7 @@ var Public = function Public() {
2733
1881
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
2734
1882
  style: "h2",
2735
1883
  children: approvalRequest.title
2736
- }), /*#__PURE__*/jsxRuntime.jsx(neetoEditor.EditorContent, {
1884
+ }), /*#__PURE__*/jsxRuntime.jsx(EditorContent__default["default"], {
2737
1885
  content: approvalRequest.message
2738
1886
  }), !hideTextArea && /*#__PURE__*/jsxRuntime.jsx(Textarea__default["default"], {
2739
1887
  label: t("neetoApprovals.common.note"),
@@ -2742,7 +1890,7 @@ var Public = function Public() {
2742
1890
  }),
2743
1891
  value: note,
2744
1892
  disabled: approvalRequest.status !== STATUSES.pending,
2745
- onChange: utils.withEventTargetValue(setNote)
1893
+ onChange: utils$1.withEventTargetValue(setNote)
2746
1894
  }), approvalRequest.status === STATUSES.pending ? /*#__PURE__*/jsxRuntime.jsxs("div", {
2747
1895
  className: "mx-auto mt-8 flex space-x-6",
2748
1896
  children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {