atom.io 0.33.9 → 0.33.11

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.
@@ -23,6 +23,137 @@ const OpenClose = ({ isOpen, setIsOpen, disabled, testid }) => {
23
23
  };
24
24
  const button = { OpenClose };
25
25
 
26
+ //#endregion
27
+ //#region src/react-devtools/error-boundary/DefaultFallback.tsx
28
+ const DefaultFallback = ({ error, errorInfo }) => {
29
+ const component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2];
30
+ const message = error?.toString() ?? errorInfo?.componentStack ?? `Unknown error`;
31
+ return /* @__PURE__ */ jsx("div", {
32
+ "data-testid": "error-boundary",
33
+ style: {
34
+ flex: `1`,
35
+ background: `black`,
36
+ backgroundImage: `url(./src/assets/kablooey.gif)`,
37
+ backgroundPosition: `center`,
38
+ backgroundSize: `overlay`
39
+ },
40
+ children: /* @__PURE__ */ jsx("div", {
41
+ style: {
42
+ margin: `50px`,
43
+ marginTop: `0`,
44
+ padding: `50px`,
45
+ border: `1px solid dashed`
46
+ },
47
+ children: /* @__PURE__ */ jsxs("span", {
48
+ style: {
49
+ background: `black`,
50
+ color: `white`,
51
+ padding: 10,
52
+ paddingTop: 5
53
+ },
54
+ children: [
55
+ `⚠️ `,
56
+ /* @__PURE__ */ jsx("span", {
57
+ style: {
58
+ color: `#fc0`,
59
+ fontWeight: 700
60
+ },
61
+ children: component
62
+ }),
63
+ ` ⚠️ `,
64
+ message
65
+ ]
66
+ })
67
+ })
68
+ });
69
+ };
70
+
71
+ //#endregion
72
+ //#region src/react-devtools/error-boundary/ReactErrorBoundary.tsx
73
+ var ErrorBoundary = class extends Component {
74
+ constructor(props) {
75
+ super(props);
76
+ this.state = {};
77
+ }
78
+ componentDidCatch(error, errorInfo) {
79
+ this.props.onError?.(error, errorInfo);
80
+ this.setState({
81
+ error,
82
+ errorInfo
83
+ });
84
+ }
85
+ render() {
86
+ const { error, errorInfo } = this.state;
87
+ const { children, Fallback = DefaultFallback } = this.props;
88
+ return errorInfo ? /* @__PURE__ */ jsx(Fallback, {
89
+ error,
90
+ errorInfo
91
+ }) : children;
92
+ }
93
+ };
94
+
95
+ //#endregion
96
+ //#region src/react-devtools/json-editor/default-components.tsx
97
+ const DEFAULT_JSON_EDITOR_COMPONENTS = {
98
+ ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
99
+ Button: ({ onClick, children, disabled, testid }) => /* @__PURE__ */ jsx("button", {
100
+ type: "button",
101
+ className: "json_editor_button",
102
+ onClick,
103
+ disabled,
104
+ "data-testid": testid,
105
+ children
106
+ }),
107
+ EditorWrapper: ({ children, className, testid }) => /* @__PURE__ */ jsx("div", {
108
+ className: `json_editor` + (className ? ` ${className}` : ``),
109
+ "data-testid": testid,
110
+ children
111
+ }),
112
+ ArrayWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
113
+ className: "json_editor_array",
114
+ "data-testid": testid,
115
+ children
116
+ }),
117
+ ObjectWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
118
+ className: "json_editor_object",
119
+ "data-testid": testid,
120
+ children
121
+ }),
122
+ StringWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
123
+ className: "json_editor_string",
124
+ "data-testid": testid,
125
+ children
126
+ }),
127
+ NumberWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
128
+ className: "json_editor_number",
129
+ "data-testid": testid,
130
+ children
131
+ }),
132
+ BooleanWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
133
+ className: "json_editor_boolean",
134
+ "data-testid": testid,
135
+ children
136
+ }),
137
+ Null: ({ testid }) => /* @__PURE__ */ jsx("span", {
138
+ className: "json_editor_null",
139
+ "data-testid": testid
140
+ }),
141
+ DeleteIcon: () => /* @__PURE__ */ jsx("span", {
142
+ className: "json_editor_icon json_editor_delete",
143
+ children: "x"
144
+ }),
145
+ MissingPropertyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
146
+ className: "json_editor_missing_property",
147
+ "data-testid": testid,
148
+ children
149
+ }),
150
+ KeyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
151
+ className: "json_editor_key",
152
+ "data-testid": testid,
153
+ children
154
+ })
155
+ };
156
+
26
157
  //#endregion
27
158
  //#region src/react-devtools/elastic-input/ElasticInput.tsx
28
159
  const ElasticInput = forwardRef(function ElasticInputFC(props, ref) {
@@ -243,15 +374,12 @@ const JsonEditor_INTERNAL = ({ data, set, name, rename, remove, recast, path = [
243
374
  style,
244
375
  testid,
245
376
  children: [
246
- remove ? disabled ? /* @__PURE__ */ jsx(Components.Button, {
247
- disabled: true,
248
- testid: `${testid}-delete`,
249
- children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
250
- }) : /* @__PURE__ */ jsx(Components.Button, {
251
- testid: `${testid}-delete`,
377
+ remove ? /* @__PURE__ */ jsx(Components.Button, {
378
+ disabled,
252
379
  onClick: () => {
253
380
  remove();
254
381
  },
382
+ testid: `${testid}-delete`,
255
383
  children: /* @__PURE__ */ jsx(Components.DeleteIcon, {})
256
384
  }) : null,
257
385
  HeaderDisplay && /* @__PURE__ */ jsx(HeaderDisplay, { data }),
@@ -300,25 +428,6 @@ const makeElementSetters = (data, set) => data.map((value, index) => (newValue)
300
428
  });
301
429
  });
302
430
 
303
- //#endregion
304
- //#region src/react-devtools/json-editor/editors-by-type/array-editor.tsx
305
- const ArrayEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
306
- const setElement = makeElementSetters(data, set);
307
- return /* @__PURE__ */ jsx(Fragment$1, { children: data.map((element, index) => {
308
- const newPath = [...path, index];
309
- return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
310
- path: newPath,
311
- isReadonly,
312
- isHidden,
313
- data: element,
314
- set: setElement[index],
315
- Components,
316
- className: "json_editor_element",
317
- testid: `${testid}-element-${index}`
318
- }, newPath.join(``));
319
- }) });
320
- };
321
-
322
431
  //#endregion
323
432
  //#region src/react-devtools/json-editor/editors-by-type/utilities/cast-json.ts
324
433
  const stringToBoolean = (str) => str === `true`;
@@ -523,15 +632,31 @@ const makePropertyRenamers = (data, set, stableKeyMapRef) => fromEntries(toEntri
523
632
  }]));
524
633
  const makePropertyRemovers = (data, set) => fromEntries(toEntries(data).map(([key]) => [key, () => {
525
634
  set(() => {
526
- const { [key]: _,...rest } = data;
527
- return rest;
635
+ let next;
636
+ if (Array.isArray(data)) {
637
+ const copy = [...data];
638
+ copy.splice(key, 1);
639
+ next = copy;
640
+ } else {
641
+ const { [key]: _,...rest } = data;
642
+ next = rest;
643
+ }
644
+ return next;
528
645
  });
529
646
  }]));
530
647
  const makePropertyRecasters = (data, set) => fromEntries(toEntries(data).map(([key, value]) => [key, (newType) => {
531
- set(() => ({
532
- ...data,
533
- [key]: castToJson(value)[newType]
534
- }));
648
+ set(() => {
649
+ let next;
650
+ if (Array.isArray(data)) {
651
+ const copy = [...data];
652
+ copy[key] = castToJson(value)[newType];
653
+ next = copy;
654
+ } else next = {
655
+ ...data,
656
+ [key]: castToJson(value)[newType]
657
+ };
658
+ return next;
659
+ });
535
660
  }]));
536
661
  const makePropertyCreationInterface = (data, set) => (key, type) => (value) => {
537
662
  set({
@@ -546,6 +671,44 @@ const makePropertySorter = (data, set, sortFn) => () => {
546
671
  set(sortedObj);
547
672
  };
548
673
 
674
+ //#endregion
675
+ //#region src/react-devtools/json-editor/editors-by-type/array-editor.tsx
676
+ const ArrayEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
677
+ const disabled = isReadonly(path);
678
+ const setElement = makeElementSetters(data, set);
679
+ const removeElement = makePropertyRemovers(data, set);
680
+ const recastElement = makePropertyRecasters(data, set);
681
+ return /* @__PURE__ */ jsxs(Components.ArrayWrapper, { children: [/* @__PURE__ */ jsx("div", {
682
+ className: `json_editor_elements${disabled ? ` readonly` : ``}`,
683
+ children: data.map((element, index) => {
684
+ const newPath = [...path, index];
685
+ return /* @__PURE__ */ jsx(JsonEditor_INTERNAL, {
686
+ path: newPath,
687
+ name: `${index}`,
688
+ isReadonly,
689
+ isHidden,
690
+ data: element,
691
+ set: setElement[index],
692
+ remove: removeElement[index],
693
+ recast: recastElement[index],
694
+ className: "json_editor_element",
695
+ Components,
696
+ testid: `${testid}-element-${index}`
697
+ }, newPath.join(``));
698
+ })
699
+ }), disabled ? null : /* @__PURE__ */ jsx(Components.Button, {
700
+ testid: `${testid}-add-element`,
701
+ disabled,
702
+ onClick: () => {
703
+ set((current) => {
704
+ const newData = [...current, JSON_DEFAULTS.string];
705
+ return newData;
706
+ });
707
+ },
708
+ children: "+"
709
+ })] });
710
+ };
711
+
549
712
  //#endregion
550
713
  //#region src/react-devtools/json-editor/editors-by-type/object-editor.tsx
551
714
  const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => false, data, set, Components, testid }) => {
@@ -560,15 +723,8 @@ const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => fa
560
723
  const recastProperty = makePropertyRecasters(data, set);
561
724
  const sortProperties = makePropertySorter(data, set);
562
725
  const makePropertyAdder = makePropertyCreationInterface(data, set);
563
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Components.Button, {
564
- testid: `${testid}-sort-properties`,
565
- onClick: () => {
566
- sortProperties();
567
- },
568
- disabled,
569
- children: "Sort"
570
- }), /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [/* @__PURE__ */ jsx("div", {
571
- className: "json_editor_properties",
726
+ return /* @__PURE__ */ jsxs(Components.ObjectWrapper, { children: [/* @__PURE__ */ jsx("div", {
727
+ className: `json_editor_properties${disabled ? ` readonly` : ``}`,
572
728
  children: Object.keys(data).map((key) => {
573
729
  const originalKey = stableKeyMap.current[key];
574
730
  const newPath = [...path, key];
@@ -588,22 +744,27 @@ const ObjectEditor = ({ path = [], isReadonly = () => false, isHidden = () => fa
588
744
  testid: `${testid}-property-${key}`
589
745
  }, originalPath.join(`.`));
590
746
  })
591
- }), disabled ? /* @__PURE__ */ jsx(Components.Button, {
592
- disabled: true,
593
- testid: `${testid}-add-property`,
594
- children: "+"
595
- }) : /* @__PURE__ */ jsx(Components.Button, {
747
+ }), disabled ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Components.Button, {
748
+ disabled,
596
749
  testid: `${testid}-add-property`,
597
750
  onClick: () => {
598
751
  makePropertyAdder(`new_property`, `string`)();
599
752
  },
600
753
  children: "+"
754
+ }), /* @__PURE__ */ jsx(Components.Button, {
755
+ testid: `${testid}-sort-properties`,
756
+ onClick: () => {
757
+ sortProperties();
758
+ },
759
+ disabled,
760
+ children: "Sort"
601
761
  })] })] });
602
762
  };
603
763
 
604
764
  //#endregion
605
765
  //#region src/react-devtools/json-editor/editors-by-type/primitive-editors.tsx
606
- const BooleanEditor = ({ data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx("input", {
766
+ const BooleanEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.BooleanWrapper, { children: /* @__PURE__ */ jsx("input", {
767
+ disabled: isReadonly(path),
607
768
  "data-testid": `${testid}-boolean-input`,
608
769
  type: "checkbox",
609
770
  checked: data,
@@ -613,6 +774,7 @@ const BooleanEditor = ({ data, set, Components, testid }) => /* @__PURE__ */ jsx
613
774
  }) });
614
775
  const NullEditor = ({ Components, testid }) => /* @__PURE__ */ jsx(Components.Null, { testid: `${testid}-null` });
615
776
  const NumberEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => /* @__PURE__ */ jsx(Components.NumberWrapper, { children: /* @__PURE__ */ jsx(NumberInput, {
777
+ disabled: isReadonly(path),
616
778
  testid: `${testid}-number-input`,
617
779
  value: data,
618
780
  set: isReadonly(path) ? void 0 : (newValue) => {
@@ -622,6 +784,7 @@ const NumberEditor = ({ path = [], isReadonly = () => false, data, set, Componen
622
784
  }) });
623
785
  const StringEditor = ({ path = [], isReadonly = () => false, data, set, Components, testid }) => {
624
786
  return /* @__PURE__ */ jsx(Components.StringWrapper, { children: /* @__PURE__ */ jsx(TextInput, {
787
+ readOnly: isReadonly(path),
625
788
  testid: `${testid}-string-input`,
626
789
  value: data,
627
790
  set: isReadonly(path) ? void 0 : set,
@@ -629,139 +792,16 @@ const StringEditor = ({ path = [], isReadonly = () => false, data, set, Componen
629
792
  }) });
630
793
  };
631
794
 
632
- //#endregion
633
- //#region src/react-devtools/error-boundary/DefaultFallback.tsx
634
- const DefaultFallback = ({ error, errorInfo }) => {
635
- const component = errorInfo?.componentStack?.split(` `).filter(Boolean)[2];
636
- const message = error?.toString() ?? errorInfo?.componentStack ?? `Unknown error`;
637
- return /* @__PURE__ */ jsx("div", {
638
- "data-testid": "error-boundary",
639
- style: {
640
- flex: `1`,
641
- background: `black`,
642
- backgroundImage: `url(./src/assets/kablooey.gif)`,
643
- backgroundPosition: `center`,
644
- backgroundSize: `overlay`
645
- },
646
- children: /* @__PURE__ */ jsx("div", {
647
- style: {
648
- margin: `50px`,
649
- marginTop: `0`,
650
- padding: `50px`,
651
- border: `1px solid dashed`
652
- },
653
- children: /* @__PURE__ */ jsxs("span", {
654
- style: {
655
- background: `black`,
656
- color: `white`,
657
- padding: 10,
658
- paddingTop: 5
659
- },
660
- children: [
661
- `⚠️ `,
662
- /* @__PURE__ */ jsx("span", {
663
- style: {
664
- color: `#fc0`,
665
- fontWeight: 700
666
- },
667
- children: component
668
- }),
669
- ` ⚠️ `,
670
- message
671
- ]
672
- })
673
- })
674
- });
675
- };
676
-
677
- //#endregion
678
- //#region src/react-devtools/error-boundary/ReactErrorBoundary.tsx
679
- var ErrorBoundary = class extends Component {
680
- constructor(props) {
681
- super(props);
682
- this.state = {};
683
- }
684
- componentDidCatch(error, errorInfo) {
685
- this.props.onError?.(error, errorInfo);
686
- this.setState({
687
- error,
688
- errorInfo
689
- });
690
- }
691
- render() {
692
- const { error, errorInfo } = this.state;
693
- const { children, Fallback = DefaultFallback } = this.props;
694
- return errorInfo ? /* @__PURE__ */ jsx(Fallback, {
695
- error,
696
- errorInfo
697
- }) : children;
698
- }
699
- };
700
-
701
- //#endregion
702
- //#region src/react-devtools/json-editor/default-components.tsx
703
- const DEFAULT_JSON_EDITOR_COMPONENTS = {
704
- ErrorBoundary: ({ children }) => /* @__PURE__ */ jsx(ErrorBoundary, { children }),
705
- Button: ({ onClick, children, disabled, testid }) => /* @__PURE__ */ jsx("button", {
706
- type: "button",
707
- className: "json_editor_button",
708
- onClick,
709
- disabled,
710
- "data-testid": testid,
711
- children
712
- }),
713
- EditorWrapper: ({ children, className, testid }) => /* @__PURE__ */ jsx("div", {
714
- className: `json_editor` + (className ? ` ${className}` : ``),
715
- "data-testid": testid,
716
- children
717
- }),
718
- ArrayWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
719
- className: "json_editor_array",
720
- "data-testid": testid,
721
- children
722
- }),
723
- ObjectWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("div", {
724
- className: "json_editor_object",
725
- "data-testid": testid,
726
- children
727
- }),
728
- StringWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
729
- className: "json_editor_string",
730
- "data-testid": testid,
731
- children
732
- }),
733
- NumberWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
734
- className: "json_editor_number",
735
- "data-testid": testid,
736
- children
737
- }),
738
- BooleanWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
739
- className: "json_editor_boolean",
740
- "data-testid": testid,
741
- children
742
- }),
743
- Null: ({ testid }) => /* @__PURE__ */ jsx("span", {
744
- className: "json_editor_null",
745
- "data-testid": testid
746
- }),
747
- DeleteIcon: () => /* @__PURE__ */ jsx("span", {
748
- className: "json_editor_icon json_editor_delete",
749
- children: "x"
750
- }),
751
- MissingPropertyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
752
- className: "json_editor_missing_property",
753
- "data-testid": testid,
754
- children
755
- }),
756
- KeyWrapper: ({ children, testid }) => /* @__PURE__ */ jsx("span", {
757
- className: "json_editor_key",
758
- "data-testid": testid,
759
- children
760
- })
761
- };
762
-
763
795
  //#endregion
764
796
  //#region src/react-devtools/json-editor/developer-interface.tsx
797
+ const SubEditors = {
798
+ array: ArrayEditor,
799
+ boolean: BooleanEditor,
800
+ null: NullEditor,
801
+ number: NumberEditor,
802
+ object: ObjectEditor,
803
+ string: StringEditor
804
+ };
765
805
  const JsonEditor = ({ data, set, name, rename, remove, isReadonly = () => false, isHidden = () => false, className, Header, style, Components: CustomComponents = {}, testid }) => {
766
806
  const Components = {
767
807
  ...DEFAULT_JSON_EDITOR_COMPONENTS,
@@ -784,17 +824,6 @@ const JsonEditor = ({ data, set, name, rename, remove, isReadonly = () => false,
784
824
  });
785
825
  };
786
826
 
787
- //#endregion
788
- //#region src/react-devtools/json-editor/index.ts
789
- const SubEditors = {
790
- array: ArrayEditor,
791
- boolean: BooleanEditor,
792
- null: NullEditor,
793
- number: NumberEditor,
794
- object: ObjectEditor,
795
- string: StringEditor
796
- };
797
-
798
827
  //#endregion
799
828
  //#region src/react-devtools/StateEditor.tsx
800
829
  const StateEditor = ({ token }) => {