@miman/json-schema-viewer-react 1.0.0 → 1.0.2

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 CHANGED
@@ -62,7 +62,7 @@
62
62
  box-sizing: border-box;
63
63
  }
64
64
 
65
- .schema-header {
65
+ .schema-container .schema-header {
66
66
  background: var(--header-bg);
67
67
  padding: 16px;
68
68
  border-radius: 8px;
@@ -70,20 +70,20 @@
70
70
  border: 1px solid var(--border-color);
71
71
  }
72
72
 
73
- .schema-header-top {
73
+ .schema-container .schema-header-top {
74
74
  display: flex;
75
75
  justify-content: space-between;
76
76
  align-items: center;
77
77
  margin-bottom: 8px;
78
78
  }
79
79
 
80
- .schema-title {
80
+ .schema-container .schema-title {
81
81
  font-size: 24px;
82
82
  font-weight: 600;
83
83
  color: var(--type-object);
84
84
  }
85
85
 
86
- .view-selector {
86
+ .schema-container .view-selector {
87
87
  display: flex;
88
88
  flex-direction: column;
89
89
  align-items: flex-end;
@@ -92,19 +92,19 @@
92
92
  color: var(--expand-icon);
93
93
  }
94
94
 
95
- .view-switch {
95
+ .schema-container .view-switch {
96
96
  display: inline-flex;
97
97
  align-items: center;
98
98
  gap: 8px;
99
99
  }
100
100
 
101
- .view-switch-label {
101
+ .schema-container .view-switch-label {
102
102
  font-size: 12px;
103
103
  color: var(--expand-icon);
104
104
  user-select: none;
105
105
  }
106
106
 
107
- .view-switch-checkbox {
107
+ .schema-container .view-switch-checkbox {
108
108
  appearance: none;
109
109
  width: 33px;
110
110
  height: 18px;
@@ -118,7 +118,7 @@
118
118
  transition: background 0.15s ease;
119
119
  }
120
120
 
121
- .view-switch-checkbox::after {
121
+ .schema-container .view-switch-checkbox::after {
122
122
  content: '';
123
123
  position: absolute;
124
124
  top: 3px;
@@ -131,19 +131,19 @@
131
131
  transition: transform 0.15s ease;
132
132
  }
133
133
 
134
- .view-switch-checkbox:checked::after {
134
+ .schema-container .view-switch-checkbox:checked::after {
135
135
  transform: translateX(15px);
136
136
  }
137
137
 
138
- .view-switch-left {
138
+ .schema-container .view-switch-left {
139
139
  margin-right: 6px;
140
140
  }
141
141
 
142
- .view-switch-right {
142
+ .schema-container .view-switch-right {
143
143
  margin-left: 6px;
144
144
  }
145
145
 
146
- .active-link-label {
146
+ .schema-container .active-link-label {
147
147
  display: inline-flex;
148
148
  align-items: center;
149
149
  gap: 6px;
@@ -155,7 +155,7 @@
155
155
  white-space: nowrap;
156
156
  }
157
157
 
158
- .active-link-checkbox {
158
+ .schema-container .active-link-checkbox {
159
159
  appearance: none;
160
160
  width: 16px;
161
161
  height: 16px;
@@ -166,12 +166,12 @@
166
166
  background: var(--bg-color);
167
167
  }
168
168
 
169
- .active-link-checkbox:checked {
169
+ .schema-container .active-link-checkbox:checked {
170
170
  background: var(--type-boolean);
171
171
  border-color: var(--type-boolean);
172
172
  }
173
173
 
174
- .active-link-checkbox:checked::after {
174
+ .schema-container .active-link-checkbox:checked::after {
175
175
  content: '✓';
176
176
  position: absolute;
177
177
  top: 50%;
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ function J() {
65
65
  box-sizing: border-box;
66
66
  }
67
67
 
68
- .schema-header {
68
+ .schema-container .schema-header {
69
69
  background: var(--header-bg);
70
70
  padding: 16px;
71
71
  border-radius: 8px;
@@ -73,20 +73,20 @@ function J() {
73
73
  border: 1px solid var(--border-color);
74
74
  }
75
75
 
76
- .schema-header-top {
76
+ .schema-container .schema-header-top {
77
77
  display: flex;
78
78
  justify-content: space-between;
79
79
  align-items: center;
80
80
  margin-bottom: 8px;
81
81
  }
82
82
 
83
- .schema-title {
83
+ .schema-container .schema-title {
84
84
  font-size: 24px;
85
85
  font-weight: 600;
86
86
  color: var(--type-object);
87
87
  }
88
88
 
89
- .view-selector {
89
+ .schema-container .view-selector {
90
90
  display: flex;
91
91
  flex-direction: column;
92
92
  align-items: flex-end;
@@ -95,19 +95,19 @@ function J() {
95
95
  color: var(--expand-icon);
96
96
  }
97
97
 
98
- .view-switch {
98
+ .schema-container .view-switch {
99
99
  display: inline-flex;
100
100
  align-items: center;
101
101
  gap: 8px;
102
102
  }
103
103
 
104
- .view-switch-label {
104
+ .schema-container .view-switch-label {
105
105
  font-size: 12px;
106
106
  color: var(--expand-icon);
107
107
  user-select: none;
108
108
  }
109
109
 
110
- .view-switch-checkbox {
110
+ .schema-container .view-switch-checkbox {
111
111
  appearance: none;
112
112
  width: 33px;
113
113
  height: 18px;
@@ -121,7 +121,7 @@ function J() {
121
121
  transition: background 0.15s ease;
122
122
  }
123
123
 
124
- .view-switch-checkbox::after {
124
+ .schema-container .view-switch-checkbox::after {
125
125
  content: '';
126
126
  position: absolute;
127
127
  top: 3px;
@@ -134,19 +134,19 @@ function J() {
134
134
  transition: transform 0.15s ease;
135
135
  }
136
136
 
137
- .view-switch-checkbox:checked::after {
137
+ .schema-container .view-switch-checkbox:checked::after {
138
138
  transform: translateX(15px);
139
139
  }
140
140
 
141
- .view-switch-left {
141
+ .schema-container .view-switch-left {
142
142
  margin-right: 6px;
143
143
  }
144
144
 
145
- .view-switch-right {
145
+ .schema-container .view-switch-right {
146
146
  margin-left: 6px;
147
147
  }
148
148
 
149
- .active-link-label {
149
+ .schema-container .active-link-label {
150
150
  display: inline-flex;
151
151
  align-items: center;
152
152
  gap: 6px;
@@ -158,7 +158,7 @@ function J() {
158
158
  white-space: nowrap;
159
159
  }
160
160
 
161
- .active-link-checkbox {
161
+ .schema-container .active-link-checkbox {
162
162
  appearance: none;
163
163
  width: 16px;
164
164
  height: 16px;
@@ -169,12 +169,12 @@ function J() {
169
169
  background: var(--bg-color);
170
170
  }
171
171
 
172
- .active-link-checkbox:checked {
172
+ .schema-container .active-link-checkbox:checked {
173
173
  background: var(--type-boolean);
174
174
  border-color: var(--type-boolean);
175
175
  }
176
176
 
177
- .active-link-checkbox:checked::after {
177
+ .schema-container .active-link-checkbox:checked::after {
178
178
  content: '✓';
179
179
  position: absolute;
180
180
  top: 50%;
@@ -838,8 +838,8 @@ function W(e, t) {
838
838
  c.forEach((f) => {
839
839
  const v = document.createElement("li");
840
840
  if (v.textContent = f, l.includes(f)) {
841
- const h = document.createElement("span");
842
- h.className = "missing-badge", h.textContent = "file not found", v.appendChild(document.createTextNode(" ")), v.appendChild(h);
841
+ const b = document.createElement("span");
842
+ b.className = "missing-badge", b.textContent = "file not found", v.appendChild(document.createTextNode(" ")), v.appendChild(b);
843
843
  }
844
844
  m.appendChild(v);
845
845
  }), o.appendChild(m), e.appendChild(o);
@@ -854,20 +854,20 @@ function N(e, t, n, r, c, l, d, s, p) {
854
854
  function A(e, t, n, r, c, l, d, s, p) {
855
855
  const i = document.createElement("div");
856
856
  i.className = "schema-object";
857
- const a = C(t, r, c), o = L(a), m = M(a), f = a.description || "", v = a.__isImported || O(t), h = a.__isMissing, w = l[p], x = (b) => {
858
- if (!b) return null;
859
- const u = b.match(/[#/](\$defs|definitions)\/([^/]+)$/);
857
+ const a = C(t, r, c), o = L(a), m = M(a), f = a.description || "", v = a.__isImported || O(t), b = a.__isMissing, w = l[p], x = (h) => {
858
+ if (!h) return null;
859
+ const u = h.match(/[#/](\$defs|definitions)\/([^/]+)$/);
860
860
  if (u) return u[2];
861
- const k = b.match(/\/([^/]+)$/);
861
+ const k = h.match(/\/([^/]+)$/);
862
862
  return k ? k[1] : null;
863
863
  };
864
864
  let $ = o;
865
865
  if (t.$ref) {
866
- const b = x(t.$ref);
867
- b && ($ = `object<${b}>`);
866
+ const h = x(t.$ref);
867
+ h && ($ = `object<${h}>`);
868
868
  } else if (o === "array" && t.items?.$ref) {
869
- const b = x(t.items.$ref);
870
- b && ($ = `array<${b}>`);
869
+ const h = x(t.items.$ref);
870
+ h && ($ = `array<${h}>`);
871
871
  }
872
872
  const y = document.createElement("div");
873
873
  if (y.className = "schema-object-header", w !== void 0 && (y.dataset.sourceLine = String(w)), y.innerHTML = `
@@ -876,17 +876,17 @@ function A(e, t, n, r, c, l, d, s, p) {
876
876
  <span class="property-type type-${g(o)}">${o === "missing" ? "file not found" : g($)}</span>
877
877
  ${n ? '<span class="required-badge">required</span>' : ""}
878
878
  ${v ? '<span class="imported-badge">imported</span>' : ""}
879
- ${h ? '<span class="missing-badge">file not found</span>' : ""}
879
+ ${b ? '<span class="missing-badge">file not found</span>' : ""}
880
880
  ${f ? `<span class="property-description">${g(f)}</span>` : ""}
881
- `, y.addEventListener("click", (b) => {
881
+ `, y.addEventListener("click", (h) => {
882
882
  if (m) {
883
883
  const u = i.querySelector(".schema-object-content"), k = y.querySelector(".expand-icon");
884
884
  u?.classList.toggle("expanded"), k?.classList.toggle("expanded");
885
885
  }
886
- d && w !== void 0 && s && (s(w), b.stopPropagation());
887
- }), i.appendChild(y), m && !h) {
888
- const b = document.createElement("div");
889
- b.className = "schema-object-content", H(b, a, r, c, l, d, s, p), i.appendChild(b);
886
+ d && w !== void 0 && s && (s(w), h.stopPropagation());
887
+ }), i.appendChild(y), m && !b) {
888
+ const h = document.createElement("div");
889
+ h.className = "schema-object-content", H(h, a, r, c, l, d, s, p), i.appendChild(h);
890
890
  }
891
891
  return i;
892
892
  }
@@ -909,8 +909,8 @@ function H(e, t, n, r, c, l, d, s) {
909
909
  }), i === "example") {
910
910
  const f = document.createElement("div");
911
911
  f.className = "object-example-view";
912
- const v = E(t, n, r, /* @__PURE__ */ new Set()), h = K(JSON.stringify(v, null, 2));
913
- f.innerHTML = `<pre>${h}</pre>`, o.appendChild(f);
912
+ const v = E(t, n, r, /* @__PURE__ */ new Set()), b = K(JSON.stringify(v, null, 2));
913
+ f.innerHTML = `<pre>${b}</pre>`, o.appendChild(f);
914
914
  } else
915
915
  q(o, t, n, r, c, l, d, s);
916
916
  };
@@ -947,7 +947,7 @@ function q(e, t, n, r, c, l, d, s) {
947
947
  if (t[a]) {
948
948
  const o = document.createElement("div");
949
949
  o.className = "array-items-label", o.textContent = a + ":", e.appendChild(o), t[a].forEach((m, f) => {
950
- const v = C(m, n, r), h = `${s}.${a}.${f}`, w = A(`Option ${f + 1}`, v, !1, n, r, c, l, d, h);
950
+ const v = C(m, n, r), b = `${s}.${a}.${f}`, w = A(`Option ${f + 1}`, v, !1, n, r, c, l, d, b);
951
951
  e.appendChild(w);
952
952
  });
953
953
  }
@@ -956,7 +956,7 @@ function q(e, t, n, r, c, l, d, s) {
956
956
  function X(e, t, n, r, c, l, d, s) {
957
957
  const p = document.createElement("div");
958
958
  p.className = "schema-object", p.id = `def-${e}`;
959
- const i = C(t, n, r), a = L(i), o = M(i), m = i.description || "", f = i.__isImported || O(t), v = i.__isMissing, h = `${s}.${e}`, w = c[h], x = document.createElement("div");
959
+ const i = C(t, n, r), a = L(i), o = M(i), m = i.description || "", f = i.__isImported || O(t), v = i.__isMissing, b = `${s}.${e}`, w = c[b], x = document.createElement("div");
960
960
  if (x.className = "schema-object-header", w !== void 0 && (x.dataset.sourceLine = String(w)), x.innerHTML = `
961
961
  ${o ? '<svg class="expand-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>' : '<div style="width: 24px;"></div>'}
962
962
  <span class="property-name">${g(e)}</span>
@@ -966,13 +966,13 @@ function X(e, t, n, r, c, l, d, s) {
966
966
  ${m ? `<span class="property-description">${g(m)}</span>` : ""}
967
967
  `, x.addEventListener("click", ($) => {
968
968
  if (o) {
969
- const y = p.querySelector(".schema-object-content"), b = x.querySelector(".expand-icon");
970
- y?.classList.toggle("expanded"), b?.classList.toggle("expanded");
969
+ const y = p.querySelector(".schema-object-content"), h = x.querySelector(".expand-icon");
970
+ y?.classList.toggle("expanded"), h?.classList.toggle("expanded");
971
971
  }
972
972
  l && w !== void 0 && d && (d(w), $.stopPropagation());
973
973
  }), p.appendChild(x), o && !v) {
974
974
  const $ = document.createElement("div");
975
- $.className = "schema-object-content", H($, i, n, r, c, l, d, h), p.appendChild($);
975
+ $.className = "schema-object-content", H($, i, n, r, c, l, d, b), p.appendChild($);
976
976
  }
977
977
  return p;
978
978
  }
@@ -1020,29 +1020,29 @@ function _(e, t, n, r, c, l, d, s, p, i) {
1020
1020
  }
1021
1021
  const v = f ? s[f] : void 0;
1022
1022
  v !== void 0 && (o.dataset.sourceLine = String(v));
1023
- const h = L(m), w = M(m), x = r.expandedNodes.has(t.id), $ = (u) => {
1023
+ const b = L(m), w = M(m), x = r.expandedNodes.has(t.id), $ = (u) => {
1024
1024
  if (!u) return null;
1025
1025
  const k = u.match(/[#/](\$defs|definitions)\/([^/]+)$/);
1026
1026
  if (k) return k[2];
1027
1027
  const z = u.match(/\/([^/]+)$/);
1028
1028
  return z ? z[1] : null;
1029
1029
  };
1030
- let y = m.enum ? "enum" : h;
1030
+ let y = m.enum ? "enum" : b;
1031
1031
  if (t.prop.$ref) {
1032
1032
  const u = $(t.prop.$ref);
1033
1033
  u && (y = u);
1034
- } else if (h === "array" && t.prop.items?.$ref) {
1034
+ } else if (b === "array" && t.prop.items?.$ref) {
1035
1035
  const u = $(t.prop.items.$ref);
1036
1036
  u && (y = `array<${u}>`);
1037
- } else if (h === "object" && m.properties) {
1037
+ } else if (b === "object" && m.properties) {
1038
1038
  const u = Object.keys(m.properties).length;
1039
1039
  y = `object (${u} ${u === 1 ? "property" : "properties"})`;
1040
- } else if (h === "array" && m.items) {
1040
+ } else if (b === "array" && m.items) {
1041
1041
  const u = C(m.items, c, l);
1042
1042
  y = `array<${L(u)}>`;
1043
1043
  }
1044
- let b = "";
1045
- x && (m.pattern && (b += `<div class="tree-node-meta-item">Pattern: <code>${g(m.pattern)}</code></div>`), m.minLength !== void 0 && (b += `<div class="tree-node-meta-item">Min Length: ${m.minLength}</div>`)), m.enum && (b += `<div class="tree-node-meta-item">Enum: <span class="tree-enum-values">${m.enum.map((u) => JSON.stringify(u)).join(", ")}</span></div>`), o.innerHTML = `
1044
+ let h = "";
1045
+ x && (m.pattern && (h += `<div class="tree-node-meta-item">Pattern: <code>${g(m.pattern)}</code></div>`), m.minLength !== void 0 && (h += `<div class="tree-node-meta-item">Min Length: ${m.minLength}</div>`)), m.enum && (h += `<div class="tree-node-meta-item">Enum: <span class="tree-enum-values">${m.enum.map((u) => JSON.stringify(u)).join(", ")}</span></div>`), o.innerHTML = `
1046
1046
  <div class="tree-node-header">
1047
1047
  <div class="tree-node-title-row">
1048
1048
  <span class="property-name">${g(t.name)}</span>
@@ -1050,7 +1050,7 @@ function _(e, t, n, r, c, l, d, s, p, i) {
1050
1050
  </div>
1051
1051
  <span class="property-type type-${g(y)}">${g(y)}</span>
1052
1052
  </div>
1053
- ${b ? `<div class="tree-node-meta">${b}</div>` : ""}
1053
+ ${h ? `<div class="tree-node-meta">${h}</div>` : ""}
1054
1054
  ${x && m.description ? `<div class="tree-node-description">${g(m.description)}</div>` : ""}
1055
1055
  ${w ? `
1056
1056
  <div class="tree-node-toggle">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miman/json-schema-viewer-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "React component for visualizing JSON Schema files",
5
5
  "type": "module",
6
6
  "scripts": {