@gisce/ooui 2.13.0 → 2.13.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.
@@ -1,9 +1,10 @@
1
1
  export declare const isTrue: (value?: string | boolean | number) => boolean;
2
2
  declare const replaceEntities: (string: string) => string;
3
- export declare const parseJsonAttributes: ({ attrs, values, fields, }: {
3
+ export declare const parseJsonAttributes: ({ attrs, values, fields, widgetType, }: {
4
4
  attrs: string;
5
5
  values: any;
6
6
  fields: any;
7
+ widgetType?: string | undefined;
7
8
  }) => Record<string, boolean>;
8
9
  declare const evaluateAttributes: ({ tagAttributes, values, fields, widgetType, fallbackMode, }: {
9
10
  tagAttributes: any;
@@ -1 +1 @@
1
- {"version":3,"file":"attributeParser.d.ts","sourceRoot":"","sources":["../../src/helpers/attributeParser.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM,WAAW,MAAM,GAAG,OAAO,GAAG,MAAM,YAGtD,CAAC;AAuDF,QAAA,MAAM,eAAe,WAAY,MAAM,KAAG,MAEzC,CAAC;AAoHF,eAAO,MAAM,mBAAmB;WAKvB,MAAM;YACL,GAAG;YACH,GAAG;6BAsCZ,CAAC;AAEF,QAAA,MAAM,kBAAkB;mBAOP,GAAG;YACV,GAAG;YACH,GAAG;;;SAuCZ,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"attributeParser.d.ts","sourceRoot":"","sources":["../../src/helpers/attributeParser.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,MAAM,WAAW,MAAM,GAAG,OAAO,GAAG,MAAM,YAGtD,CAAC;AAuDF,QAAA,MAAM,eAAe,WAAY,MAAM,KAAG,MAEzC,CAAC;AAoHF,eAAO,MAAM,mBAAmB;WAMvB,MAAM;YACL,GAAG;YACH,GAAG;;6BAkDZ,CAAC;AAEF,QAAA,MAAM,kBAAkB;mBAOP,GAAG;YACV,GAAG;YACH,GAAG;;;SAwCZ,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
package/dist/ooui.es.js CHANGED
@@ -177,41 +177,44 @@ const ge = (i = !1) => (i = JSON.parse(i.toString().toLowerCase()), +i > 0), me
177
177
  fields: e,
178
178
  widgetType: s
179
179
  }) => {
180
- const u = i.replace(/\(/g, "[").replace(/\)/g, "]").replace(/'/g, '"').replace(/True/g, "true").replace(/False/g, "false"), _ = b(u), h = JSON.parse(_), d = {};
181
- for (const f of Object.keys(h)) {
182
- const x = h[f].map((y) => me({ entry: y, values: t, fields: e })).every((y) => y);
180
+ const h = i.replace(/\(/g, "[").replace(/\)/g, "]").replace(/'/g, '"').replace(/True/g, "true").replace(/False/g, "false"), _ = b(h), u = JSON.parse(_), d = {};
181
+ for (const f of Object.keys(u)) {
182
+ const x = u[f].map((y) => me({ entry: y, values: t, fields: e })).every((y) => y);
183
183
  x ? d[f] = !0 : f === "readonly" && !x && s === "button" && (d[f] = !1);
184
184
  }
185
185
  return d;
186
186
  }, ye = ({
187
187
  attrs: i,
188
188
  values: t,
189
- fields: e
189
+ fields: e,
190
+ widgetType: s
190
191
  }) => {
191
192
  try {
192
- const s = b(i), r = JSON.parse(
193
- s.replace(/'/g, '"')
194
- ), a = {};
195
- for (const l of Object.keys(r))
196
- a[l] = fe({
193
+ const r = b(i), a = JSON.parse(
194
+ r.replace(/'/g, '"')
195
+ ), l = {};
196
+ for (const o of Object.keys(a)) {
197
+ const h = fe({
197
198
  object: t,
198
- condition: r[l],
199
+ condition: a[o],
199
200
  evaluateFieldComparison: ({
200
- fieldName: o,
201
+ fieldName: _,
201
202
  valueInObject: u,
202
- expectedValue: _
203
+ expectedValue: d
203
204
  }) => q({
204
- fieldName: o,
205
+ fieldName: _,
205
206
  valueInObject: u,
206
- expectedValue: _,
207
+ expectedValue: d,
207
208
  fields: e
208
209
  })
209
210
  });
210
- return a;
211
- } catch (s) {
212
- throw console.error(s), s instanceof SyntaxError ? new Error(
211
+ h ? l[o] = !0 : o === "readonly" && !h && s === "button" && (l[o] = !1);
212
+ }
213
+ return l;
214
+ } catch (r) {
215
+ throw console.error(r), r instanceof SyntaxError ? new Error(
213
216
  "Error parsing new json_attrs. Original string: " + i
214
- ) : s;
217
+ ) : r;
215
218
  }
216
219
  }, xe = ({
217
220
  tagAttributes: i,
@@ -231,7 +234,8 @@ const ge = (i = !1) => (i = JSON.parse(i.toString().toLowerCase()), +i > 0), me
231
234
  a = ye({
232
235
  attrs: i.json_attrs,
233
236
  values: t,
234
- fields: e
237
+ fields: e,
238
+ widgetType: s
235
239
  });
236
240
  } catch (o) {
237
241
  if (r && i.attrs)
@@ -1523,15 +1527,15 @@ const He = ({
1523
1527
  const r = {}, a = {};
1524
1528
  for (const o of Object.keys(s))
1525
1529
  if (t.state === o) {
1526
- const u = s[o];
1527
- for (const _ of u) {
1528
- const [h, d] = _;
1529
- a[h] || (a[h] = []), a[h].push(d);
1530
+ const h = s[o];
1531
+ for (const _ of h) {
1532
+ const [u, d] = _;
1533
+ a[u] || (a[u] = []), a[u].push(d);
1530
1534
  }
1531
1535
  }
1532
1536
  for (const o of Object.keys(a)) {
1533
- const u = a[o];
1534
- r[o] = u.some((_) => _);
1537
+ const h = a[o];
1538
+ r[o] = h.some((_) => _);
1535
1539
  }
1536
1540
  return r;
1537
1541
  }, Qe = ({
@@ -1728,14 +1732,14 @@ class Ft {
1728
1732
  }
1729
1733
  parse(t, e) {
1730
1734
  var o;
1731
- const { values: s = {}, readOnly: r = !1 } = e || {}, a = Y.parse(t).filter((u) => u.tagName === "form")[0];
1735
+ const { values: s = {}, readOnly: r = !1 } = e || {}, a = Y.parse(t).filter((h) => h.tagName === "form")[0];
1732
1736
  this._string = ((o = a.attributes) == null ? void 0 : o.string) || null, this._string && (this._string = b(this._string)), this._readOnly = r, this._context = s.id ? { active_id: s.id, active_ids: [s.id] } : {}, this._invisibleFields = [], this.parseNode({
1733
1737
  fields: a.children,
1734
1738
  container: this._container,
1735
1739
  values: s
1736
- }), Ke(this._container._rows).forEach((u) => {
1737
- const _ = u;
1738
- _._id && _._context && (this._contextForFields[_._id] = u._context);
1740
+ }), Ke(this._container._rows).forEach((h) => {
1741
+ const _ = h;
1742
+ _._id && _._context && (this._contextForFields[_._id] = h._context);
1739
1743
  });
1740
1744
  }
1741
1745
  parseNode({
@@ -1746,8 +1750,8 @@ class Ft {
1746
1750
  const r = new G();
1747
1751
  t.filter((a) => typeof a == "object").forEach((a) => {
1748
1752
  var w, F;
1749
- const { tagName: l, attributes: o, children: u } = a;
1750
- let _ = l, h = o;
1753
+ const { tagName: l, attributes: o, children: h } = a;
1754
+ let _ = l, u = o;
1751
1755
  if (l === "field") {
1752
1756
  const { name: v, widget: I } = o;
1753
1757
  if (I)
@@ -1759,37 +1763,37 @@ class Ft {
1759
1763
  );
1760
1764
  _ = this._fields[v].type;
1761
1765
  }
1762
- h = {
1766
+ u = {
1763
1767
  ...this._fields[v],
1764
1768
  ...o,
1765
1769
  fieldsWidgetType: this._fields[v].type
1766
1770
  };
1767
1771
  }
1768
1772
  const d = xe({
1769
- tagAttributes: h,
1773
+ tagAttributes: u,
1770
1774
  values: s,
1771
1775
  fields: this._fields,
1772
1776
  widgetType: l
1773
1777
  });
1774
1778
  let f;
1775
- l === "button" && h.states ? f = Qe({
1776
- states: h.states,
1779
+ l === "button" && u.states ? f = Qe({
1780
+ states: u.states,
1777
1781
  values: s
1778
1782
  }) : f = He({
1779
- fieldName: h.name,
1783
+ fieldName: u.name,
1780
1784
  values: s,
1781
1785
  fields: this._fields
1782
1786
  });
1783
1787
  const c = Z({
1784
- context: h.context || ((w = this._fields[h.name]) == null ? void 0 : w.context),
1788
+ context: u.context || ((w = this._fields[u.name]) == null ? void 0 : w.context),
1785
1789
  values: s,
1786
1790
  fields: this._fields
1787
1791
  });
1788
- h.on_change && (this._onChangeFields[h.name] = Ue(
1789
- h.on_change
1792
+ u.on_change && (this._onChangeFields[u.name] = Ue(
1793
+ u.on_change
1790
1794
  ));
1791
1795
  let m;
1792
- R(h.domain) && (m = h.domain), R((F = this._fields[h.name]) == null ? void 0 : F.domain) && (m = this._fields[h.name].domain), this._keyIdx = this._keyIdx + 1;
1796
+ R(u.domain) ? m = u.domain : R((F = this._fields[u.name]) == null ? void 0 : F.domain) && (m = this._fields[u.name].domain), this._keyIdx = this._keyIdx + 1;
1793
1797
  const x = {
1794
1798
  ...d,
1795
1799
  ...f,
@@ -1800,7 +1804,7 @@ class Ft {
1800
1804
  e.readOnly && (x.readonly = !0);
1801
1805
  const y = r.createWidget(_, x);
1802
1806
  y.invisible && y instanceof g && this._invisibleFields.push(x.name), y instanceof p && this.parseNode({
1803
- fields: u,
1807
+ fields: h,
1804
1808
  container: y.container,
1805
1809
  values: s
1806
1810
  }), y instanceof Q && y.readOnly !== void 0 || (y.readOnly = y.readOnly || this.readOnly), e.addWidget(y);
@@ -1889,27 +1893,27 @@ class Ct {
1889
1893
  const { tagName: a, attributes: l } = r;
1890
1894
  let o = null;
1891
1895
  if (a === "field") {
1892
- const { name: u, widget: _ } = l;
1893
- let h = l;
1894
- if (u) {
1895
- if (!this._fields[u])
1896
- throw new Error(`Field ${u} doesn't exist in fields defintion`);
1897
- const d = this._fields[u];
1896
+ const { name: h, widget: _ } = l;
1897
+ let u = l;
1898
+ if (h) {
1899
+ if (!this._fields[h])
1900
+ throw new Error(`Field ${h} doesn't exist in fields defintion`);
1901
+ const d = this._fields[h];
1898
1902
  o = d.type, (Array.isArray(d == null ? void 0 : d.domain) && (d == null ? void 0 : d.domain.length) === 0 || (d == null ? void 0 : d.domain) === !1) && l.domain && l.domain.length > 0 && delete d.domain;
1899
1903
  const f = Z({
1900
1904
  context: l.context || d.context,
1901
1905
  values: {},
1902
1906
  fields: this._fields
1903
1907
  });
1904
- h = {
1908
+ u = {
1905
1909
  ...d,
1906
1910
  ...l,
1907
1911
  fieldsWidgetType: d == null ? void 0 : d.type,
1908
1912
  context: f
1909
- }, this._contextForFields[u] = f;
1913
+ }, this._contextForFields[h] = f;
1910
1914
  }
1911
- if (_ && (o = _), !h.invisible) {
1912
- const d = s.createWidget(o, h);
1915
+ if (_ && (o = _), !u.invisible) {
1916
+ const d = s.createWidget(o, u);
1913
1917
  this._columns.push(d);
1914
1918
  }
1915
1919
  }
@@ -2004,11 +2008,11 @@ const Ot = ({
2004
2008
  if (!Array.isArray(s))
2005
2009
  return;
2006
2010
  const [r, a, l] = s;
2007
- let o, u;
2008
- r.indexOf(".") !== -1 ? (o = r.substr(0, r.indexOf(".")), u = r.substr(
2011
+ let o, h;
2012
+ r.indexOf(".") !== -1 ? (o = r.substr(0, r.indexOf(".")), h = r.substr(
2009
2013
  r.indexOf(".") + 1,
2010
2014
  r.length - 1
2011
- )) : (o = r, u = "id"), o === t && e.push([u, a, l]);
2015
+ )) : (o = r, h = "id"), o === t && e.push([h, a, l]);
2012
2016
  }), e;
2013
2017
  }, Tt = (i) => typeof i != "string" ? [] : i.replace(/[()[\]]/g, "").split(",").map((t) => t.trim()).filter((t) => !t.includes("'"));
2014
2018
  class et {
@@ -2122,7 +2126,7 @@ const st = (i) => {
2122
2126
  let e;
2123
2127
  if (i.forEach((s) => {
2124
2128
  if (s.tagName === "field") {
2125
- const r = s.attributes.axis, a = s.attributes.operator, l = s.attributes.name, o = s.attributes.label || void 0, u = s.attributes.stacked || void 0;
2129
+ const r = s.attributes.axis, a = s.attributes.operator, l = s.attributes.name, o = s.attributes.label || void 0, h = s.attributes.stacked || void 0;
2126
2130
  if (!r)
2127
2131
  throw new Error(`Field ${l} doesn't have an axis`);
2128
2132
  if (!l)
@@ -2134,7 +2138,7 @@ const st = (i) => {
2134
2138
  name: l,
2135
2139
  operator: a,
2136
2140
  label: o,
2137
- stacked: u
2141
+ stacked: h
2138
2142
  })
2139
2143
  );
2140
2144
  }
@@ -2272,12 +2276,12 @@ function ct({
2272
2276
  groupBy: "type-stacked"
2273
2277
  }), a = `${t}s`;
2274
2278
  return Object.keys(r).forEach((o) => {
2275
- const u = r[o];
2276
- for (let _ = 0; _ < u.length; _++) {
2277
- const h = u[_];
2278
- if (s.push(h), _ === u.length - 1)
2279
+ const h = r[o];
2280
+ for (let _ = 0; _ < h.length; _++) {
2281
+ const u = h[_];
2282
+ if (s.push(u), _ === h.length - 1)
2279
2283
  return;
2280
- const d = h.x, f = u[_ + 1].x;
2284
+ const d = u.x, f = h[_ + 1].x;
2281
2285
  if (!re([d, f], a)) {
2282
2286
  const c = dt({
2283
2287
  dates: [d, f],
@@ -2288,13 +2292,13 @@ function ct({
2288
2292
  c.map((m) => ({
2289
2293
  x: m,
2290
2294
  value: 0,
2291
- type: h.type,
2292
- stacked: h.stacked
2295
+ type: u.type,
2296
+ stacked: u.stacked
2293
2297
  }))
2294
2298
  );
2295
2299
  }
2296
2300
  }
2297
- }), s.sort((o, u) => o.x < u.x ? -1 : o.x > u.x ? 1 : 0);
2301
+ }), s.sort((o, h) => o.x < h.x ? -1 : o.x > h.x ? 1 : 0);
2298
2302
  }
2299
2303
  function dt({
2300
2304
  dates: i,
@@ -2306,13 +2310,13 @@ function dt({
2306
2310
  return i;
2307
2311
  const a = i.sort((l, o) => l < o ? -1 : l > o ? 1 : 0);
2308
2312
  for (let l = 0; l < a.length - 1; l++) {
2309
- const o = a[l], u = a[l + 1];
2310
- if (!re([o, u], r)) {
2313
+ const o = a[l], h = a[l + 1];
2314
+ if (!re([o, h], r)) {
2311
2315
  const _ = P(o, S(r)).add(
2312
2316
  e,
2313
2317
  r
2314
- ), h = P(u, S(r));
2315
- for (; _.isBefore(h); )
2318
+ ), u = P(h, S(r));
2319
+ for (; _.isBefore(u); )
2316
2320
  s.push(_.format(S(r))), _.add(e, r);
2317
2321
  }
2318
2322
  }
@@ -2330,13 +2334,13 @@ function ut({
2330
2334
  groupBy: "all"
2331
2335
  });
2332
2336
  return Object.keys(r).forEach((a) => {
2333
- const l = r[a], o = l[0].operator === "count" ? "+" : l[0].operator, u = V({
2337
+ const l = r[a], o = l[0].operator === "count" ? "+" : l[0].operator, h = V({
2334
2338
  values: l.map((_) => _.value),
2335
2339
  operator: o
2336
2340
  });
2337
2341
  s.push({
2338
2342
  ...l[0],
2339
- value: u
2343
+ value: h
2340
2344
  });
2341
2345
  }), s;
2342
2346
  }
@@ -2493,16 +2497,16 @@ const gt = {
2493
2497
  const l = i.y.some((c) => c.label !== void 0), o = i.y.some((c) => c.stacked !== void 0);
2494
2498
  let _ = [...a.sort((c, m) => c.x < m.x ? -1 : c.x > m.x ? 1 : 0)];
2495
2499
  o && i.y.filter((c) => c.stacked !== void 0).length > 1 && (_ = _.map((c) => ({ ...c, type: `${c.type} - ${c.stacked}` })));
2496
- let h = [..._];
2497
- i.type === "pie" && h.some((c) => c.x === !1) ? h = h.map((c) => c.x === !1 ? { ...c, x: (s == null ? void 0 : s.uninformedString) || "Not informed" } : c) : _.some((c) => c.x === !1) && (h = h.filter(
2500
+ let u = [..._];
2501
+ i.type === "pie" && u.some((c) => c.x === !1) ? u = u.map((c) => c.x === !1 ? { ...c, x: (s == null ? void 0 : s.uninformedString) || "Not informed" } : c) : _.some((c) => c.x === !1) && (u = u.filter(
2498
2502
  (c) => c.x !== !1
2499
2503
  ));
2500
- let d = h;
2504
+ let d = u;
2501
2505
  i.timerange ? d = ot({
2502
2506
  values: d,
2503
2507
  timerange: i.timerange,
2504
2508
  interval: i.interval
2505
- }) : i.type == "pie" && (d = h.sort((c, m) => m.value - c.value));
2509
+ }) : i.type == "pie" && (d = u.sort((c, m) => m.value - c.value));
2506
2510
  const f = {
2507
2511
  data: d,
2508
2512
  isGroup: o || l,