sf-i-events 1.0.937 → 1.0.939

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/src/util.ts CHANGED
@@ -574,8 +574,82 @@ function isJSONParsable(str: unknown): boolean {
574
574
  }
575
575
  }
576
576
 
577
+ function isVisible(el: HTMLElement): boolean {
578
+ const style = window.getComputedStyle(el);
579
+ const rect = el.getBoundingClientRect();
580
+ console.log('previous style', style.display, rect, el.id);
581
+
582
+ return (
583
+ rect.height > 0 &&
584
+ rect.width >= 0
585
+ ) && (
586
+ style.display !== "none" &&
587
+ style.visibility !== "hidden" &&
588
+ style.opacity !== "0"
589
+ );
590
+ }
591
+
592
+ function compareObjects (obj1: any, obj2: any): any {
593
+ if (obj1 === obj2) return {};
594
+
595
+ // If both are arrays
596
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
597
+ const maxLength = Math.max(obj1.length, obj2.length);
598
+ const result: any[] = [];
599
+
600
+ for (let i = 0; i < maxLength; i++) {
601
+ if (i >= obj1.length) {
602
+ result[i] = obj2[i]; // new item
603
+ } else if (i >= obj2.length) {
604
+ result[i] = undefined; // removed item
605
+ } else {
606
+ const diff = compareObjects(obj1[i], obj2[i]);
607
+ if (Object.keys(diff).length > 0) {
608
+ result[i] = diff;
609
+ }
610
+ }
611
+ }
612
+
613
+ return result.filter(v => v !== undefined).length > 0 ? result : {};
614
+ }
615
+ // If both are objects
616
+ if (
617
+ typeof obj1 === "object" &&
618
+ obj1 !== null &&
619
+ typeof obj2 === "object" &&
620
+ obj2 !== null
621
+ ) {
622
+ const keys = new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
623
+ const diff: Record<string, any> = {};
624
+
625
+ for (const key of keys) {
626
+ if (!(key in obj1)) {
627
+ diff[key] = [null,(obj2 as any)[key]];
628
+ } else if (!(key in obj2)) {
629
+ diff[key] = [(obj1 as any)[key], null];
630
+ } else {
631
+ const valueDiff = compareObjects((obj1 as any)[key], (obj2 as any)[key]);
632
+ if (
633
+ typeof valueDiff === "object" &&
634
+ valueDiff !== null &&
635
+ Object.keys(valueDiff).length === 0
636
+ ) {
637
+ continue;
638
+ }
639
+ if (valueDiff !== undefined) {
640
+ diff[key] = valueDiff;
641
+ }
642
+ }
643
+ }
644
+
645
+ return Object.keys(diff).length > 0 ? diff : {};
646
+ }
647
+
648
+ // Primitive comparison
649
+ return obj1 !== obj2 ? [obj1,obj2] : [];
650
+ }
577
651
  const exportFunctions = {
578
- callApiPresignedDelete, callApiPresignedGet, callApiPresigned, jsonObjectToHtml, clearListeners, isInteger, callApi, validateName, readCookie, timeSince, createDiagonalPattern1, createDiagonalPattern2, createDiagonalPattern3, getRandomColor, convertToCSV, parseCsv, titleCase, alphabeticalSort, percentageString, getCurrentFiscal, getDateTimeStrings, getUsermap, setFeatures, getFeatures, getProjectUsermap, downloadExcelFromCSV, isJSONParsable
652
+ callApiPresignedDelete, callApiPresignedGet, callApiPresigned, jsonObjectToHtml, clearListeners, isInteger, callApi, validateName, readCookie, timeSince, createDiagonalPattern1, createDiagonalPattern2, createDiagonalPattern3, getRandomColor, convertToCSV, parseCsv, titleCase, alphabeticalSort, percentageString, getCurrentFiscal, getDateTimeStrings, getUsermap, setFeatures, getFeatures, getProjectUsermap, downloadExcelFromCSV, isJSONParsable, isVisible, compareObjects
579
653
  };
580
654
 
581
655
  export default exportFunctions;
package/util.d.ts CHANGED
@@ -23,6 +23,8 @@ declare function setFeatures(features: any): void;
23
23
  declare function getFeatures(): any;
24
24
  export declare const downloadExcelFromCSV: (csvString: string, fileName: string | undefined, title: string, projectname: string) => void;
25
25
  declare function isJSONParsable(str: unknown): boolean;
26
+ declare function isVisible(el: HTMLElement): boolean;
27
+ declare function compareObjects(obj1: any, obj2: any): any;
26
28
  declare const exportFunctions: {
27
29
  callApiPresignedDelete: typeof callApiPresignedDelete;
28
30
  callApiPresignedGet: typeof callApiPresignedGet;
@@ -51,6 +53,8 @@ declare const exportFunctions: {
51
53
  getProjectUsermap: typeof getProjectUsermap;
52
54
  downloadExcelFromCSV: (csvString: string, fileName: string | undefined, title: string, projectname: string) => void;
53
55
  isJSONParsable: typeof isJSONParsable;
56
+ isVisible: typeof isVisible;
57
+ compareObjects: typeof compareObjects;
54
58
  };
55
59
  export default exportFunctions;
56
60
  //# sourceMappingURL=util.d.ts.map
package/util.js CHANGED
@@ -486,8 +486,71 @@ function isJSONParsable(str) {
486
486
  return false;
487
487
  }
488
488
  }
489
+ function isVisible(el) {
490
+ const style = window.getComputedStyle(el);
491
+ const rect = el.getBoundingClientRect();
492
+ console.log('previous style', style.display, rect, el.id);
493
+ return (rect.height > 0 &&
494
+ rect.width >= 0) && (style.display !== "none" &&
495
+ style.visibility !== "hidden" &&
496
+ style.opacity !== "0");
497
+ }
498
+ function compareObjects(obj1, obj2) {
499
+ if (obj1 === obj2)
500
+ return {};
501
+ // If both are arrays
502
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
503
+ const maxLength = Math.max(obj1.length, obj2.length);
504
+ const result = [];
505
+ for (let i = 0; i < maxLength; i++) {
506
+ if (i >= obj1.length) {
507
+ result[i] = obj2[i]; // new item
508
+ }
509
+ else if (i >= obj2.length) {
510
+ result[i] = undefined; // removed item
511
+ }
512
+ else {
513
+ const diff = compareObjects(obj1[i], obj2[i]);
514
+ if (Object.keys(diff).length > 0) {
515
+ result[i] = diff;
516
+ }
517
+ }
518
+ }
519
+ return result.filter(v => v !== undefined).length > 0 ? result : {};
520
+ }
521
+ // If both are objects
522
+ if (typeof obj1 === "object" &&
523
+ obj1 !== null &&
524
+ typeof obj2 === "object" &&
525
+ obj2 !== null) {
526
+ const keys = new Set([...Object.keys(obj1), ...Object.keys(obj2)]);
527
+ const diff = {};
528
+ for (const key of keys) {
529
+ if (!(key in obj1)) {
530
+ diff[key] = [null, obj2[key]];
531
+ }
532
+ else if (!(key in obj2)) {
533
+ diff[key] = [obj1[key], null];
534
+ }
535
+ else {
536
+ const valueDiff = compareObjects(obj1[key], obj2[key]);
537
+ if (typeof valueDiff === "object" &&
538
+ valueDiff !== null &&
539
+ Object.keys(valueDiff).length === 0) {
540
+ continue;
541
+ }
542
+ if (valueDiff !== undefined) {
543
+ diff[key] = valueDiff;
544
+ }
545
+ }
546
+ }
547
+ return Object.keys(diff).length > 0 ? diff : {};
548
+ }
549
+ // Primitive comparison
550
+ return obj1 !== obj2 ? [obj1, obj2] : [];
551
+ }
489
552
  const exportFunctions = {
490
- callApiPresignedDelete, callApiPresignedGet, callApiPresigned, jsonObjectToHtml, clearListeners, isInteger, callApi, validateName, readCookie, timeSince, createDiagonalPattern1, createDiagonalPattern2, createDiagonalPattern3, getRandomColor, convertToCSV, parseCsv, titleCase, alphabeticalSort, percentageString, getCurrentFiscal, getDateTimeStrings, getUsermap, setFeatures, getFeatures, getProjectUsermap, downloadExcelFromCSV, isJSONParsable
553
+ callApiPresignedDelete, callApiPresignedGet, callApiPresigned, jsonObjectToHtml, clearListeners, isInteger, callApi, validateName, readCookie, timeSince, createDiagonalPattern1, createDiagonalPattern2, createDiagonalPattern3, getRandomColor, convertToCSV, parseCsv, titleCase, alphabeticalSort, percentageString, getCurrentFiscal, getDateTimeStrings, getUsermap, setFeatures, getFeatures, getProjectUsermap, downloadExcelFromCSV, isJSONParsable, isVisible, compareObjects
491
554
  };
492
555
  export default exportFunctions;
493
556
  //# sourceMappingURL=util.js.map