@modelform/react-native 0.1.1 → 0.3.0

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.
@@ -483,6 +483,32 @@ var GRID_COLUMNS = 24;
483
483
  var CELL_HEIGHT = 30;
484
484
  var CELL_MARGIN = 8;
485
485
  var gridUnitsToPx = (h) => h * CELL_HEIGHT + (h - 1) * CELL_MARGIN;
486
+ var gridOffsetPx = (y) => y * (CELL_HEIGHT + CELL_MARGIN);
487
+ var overlaps = (a, b) => a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;
488
+ function compactGrid(boxes, fixed2 = /* @__PURE__ */ new Set()) {
489
+ const snapped = boxes.map((b) => {
490
+ const w = Math.min(GRID_COLUMNS, Math.max(1, Math.round(b.x + b.w) - Math.round(b.x)));
491
+ const x = Math.min(GRID_COLUMNS - w, Math.max(0, Math.round(b.x)));
492
+ return { x, y: Math.max(0, b.y), w, h: Math.max(1, Math.round(b.h)) };
493
+ });
494
+ const out = new Array(boxes.length);
495
+ const placed = [];
496
+ for (const i of fixed2) {
497
+ if (!snapped[i]) continue;
498
+ out[i] = { ...snapped[i], y: Math.round(snapped[i].y) };
499
+ placed.push(out[i]);
500
+ }
501
+ const order = snapped.map((_, i) => i).filter((i) => !fixed2.has(i)).sort((a, b) => snapped[a].y - snapped[b].y || snapped[a].x - snapped[b].x || a - b);
502
+ for (const i of order) {
503
+ const box = { ...snapped[i], y: Math.floor(snapped[i].y) };
504
+ box.y = Math.min(box.y, Math.max(0, ...placed.map((p) => p.y + p.h)));
505
+ while (box.y > 0 && !placed.some((p) => overlaps({ ...box, y: box.y - 1 }, p))) box.y--;
506
+ for (let hit = placed.find((p) => overlaps(box, p)); hit; hit = placed.find((p) => overlaps(box, p))) box.y = hit.y + hit.h;
507
+ out[i] = box;
508
+ placed.push(box);
509
+ }
510
+ return out;
511
+ }
486
512
  var isRow = (p) => p.type === "row";
487
513
  var byPosition = (a, b) => a.gridPos.y - b.gridPos.y || a.gridPos.x - b.gridPos.x;
488
514
  function layoutDashboard(dashboard, mode = "phone", repeat2) {
@@ -506,12 +532,15 @@ function layoutDashboard(dashboard, mode = "phone", repeat2) {
506
532
  children: s.children.map((c) => ({ ...c, scopedVars: { ...c.scopedVars, ...scoped } }))
507
533
  };
508
534
  });
509
- }).map((s) => ({
510
- key: s.key,
511
- row: s.row,
512
- collapsed: !!s.row?.collapsed,
513
- rows: packRows(expandPanelRepeats(s.children, repeat2).sort(byPosition), mode)
514
- }));
535
+ }).map((s) => {
536
+ const panels = expandPanelRepeats(s.children, repeat2).sort(byPosition);
537
+ return { key: s.key, row: s.row, collapsed: !!s.row?.collapsed, rows: packRows(panels, mode), grid: placeOnGrid(panels) };
538
+ });
539
+ }
540
+ function placeOnGrid(panels) {
541
+ const boxes = compactGrid(panels.map((p) => p.gridPos));
542
+ const cells = panels.map((panel, i) => ({ key: panelKey(panel), panel, span: boxes[i].w, ...boxes[i] }));
543
+ return { cells, h: Math.max(0, ...boxes.map((b) => b.y + b.h)) };
515
544
  }
516
545
  function repeatOptions(name, ctx) {
517
546
  const value = ctx.values[name];
@@ -8068,11 +8097,28 @@ function resolveUrl(base, rel) {
8068
8097
  }
8069
8098
  return origin + out.join("/");
8070
8099
  }
8071
- var defaultFetchJson = async (url, options) => {
8072
- const res = await fetch(url, { headers: { Accept: options?.accept ?? "application/json" }, cache: "no-store" });
8073
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
8074
- return JSON.parse(await res.text());
8075
- };
8100
+ function httpFetchJson(options = {}) {
8101
+ const seen = /* @__PURE__ */ new Map();
8102
+ return async (url, { accept = "application/json", signal } = {}) => {
8103
+ const extra = await options.headers?.() ?? {};
8104
+ const key = JSON.stringify([url, accept, extra]);
8105
+ const last = seen.get(key);
8106
+ const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
8107
+ const res = await get(last?.etag).catch((e) => {
8108
+ if (!last || signal?.aborted) throw e;
8109
+ seen.delete(key);
8110
+ return get();
8111
+ });
8112
+ if (res.status === 304 && last) return last.json;
8113
+ if (!res.ok) throw new Error(options.httpError?.(res.status) ?? `HTTP ${res.status}`);
8114
+ const json = JSON.parse(await res.text());
8115
+ const etag = res.headers.get("ETag");
8116
+ if (etag) seen.set(key, { etag, json });
8117
+ else seen.delete(key);
8118
+ return json;
8119
+ };
8120
+ }
8121
+ var defaultFetchJson = httpFetchJson();
8076
8122
  var fileName = (url) => url.replace(/[?#].*$/, "").split("/").pop() || url;
8077
8123
  var BUNDLE_TYPE = "application/vnd.modelform.bundle+json";
8078
8124
  var BUNDLE_ACCEPT = `${BUNDLE_TYPE}, application/json;q=0.9`;
@@ -8085,7 +8131,7 @@ function bundleRoot(manifestUrl, manifestPath) {
8085
8131
  return bare.endsWith(manifestPath) ? bare.slice(0, bare.length - manifestPath.length) : bare.replace(/[^/]*$/, "");
8086
8132
  }
8087
8133
  var NOT_IN_BUNDLE = "not found in the config";
8088
- async function assembleFromResponse(url, response, fetchJson = defaultFetchJson) {
8134
+ async function assembleFromResponse(url, response, fetchJson = defaultFetchJson, signal) {
8089
8135
  const root = bundleRoot(url, response.manifest);
8090
8136
  const file = fileName(url);
8091
8137
  const parse3 = (path) => {
@@ -8103,7 +8149,7 @@ async function assembleFromResponse(url, response, fetchJson = defaultFetchJson)
8103
8149
  manifest,
8104
8150
  async (ref) => {
8105
8151
  const abs = resolveUrl(url, ref).replace(/[?#].*$/, "");
8106
- return abs.startsWith(root) ? parse3(abs.slice(root.length)) : fetchJson(resolveUrl(url, ref));
8152
+ return abs.startsWith(root) ? parse3(abs.slice(root.length)) : fetchJson(resolveUrl(url, ref), { signal });
8107
8153
  },
8108
8154
  file
8109
8155
  );
@@ -8131,16 +8177,33 @@ async function assembleBundle(manifest, load, file = "manifest") {
8131
8177
  issues.push(...validateBundle(bundle, file));
8132
8178
  return issues.some((i) => i.severity === "error") ? { issues } : { bundle, issues };
8133
8179
  }
8134
- async function fetchBundle(url, fetchJson = defaultFetchJson) {
8180
+ async function fetchBundle(url, fetchJson = defaultFetchJson, signal) {
8135
8181
  let manifest;
8136
8182
  try {
8137
- manifest = await fetchJson(url, { accept: BUNDLE_ACCEPT });
8183
+ manifest = await fetchJson(url, { accept: BUNDLE_ACCEPT, signal });
8138
8184
  } catch (e) {
8139
- return { issues: [{ severity: "error", path: fileName(url), message: e.message }] };
8185
+ return { issues: [{ severity: "error", path: fileName(url), message: e.message }], ...!(e instanceof SyntaxError) && { unreachable: true } };
8140
8186
  }
8141
- if (isBundleResponse(manifest)) return assembleFromResponse(url, manifest, fetchJson);
8142
- return assembleBundle(manifest, (path) => fetchJson(resolveUrl(url, path)), fileName(url));
8187
+ if (isBundleResponse(manifest)) return assembleFromResponse(url, manifest, fetchJson, signal);
8188
+ return assembleBundle(manifest, (path) => fetchJson(resolveUrl(url, path), { signal }), fileName(url));
8143
8189
  }
8190
+ function revalidateBundle(bundle) {
8191
+ try {
8192
+ const { manifest } = bundle;
8193
+ if (validateManifest(manifest).length) return void 0;
8194
+ const documents = {};
8195
+ for (const id of Object.keys(manifest.documents)) {
8196
+ const { dashboard } = prepareDashboard(bundle.documents[id], id);
8197
+ if (!dashboard) return void 0;
8198
+ documents[id] = dashboard;
8199
+ }
8200
+ const checked = { manifest, documents };
8201
+ return validateBundle(checked).some((i) => i.severity === "error") ? void 0 : checked;
8202
+ } catch {
8203
+ return void 0;
8204
+ }
8205
+ }
8206
+ var DEFAULT_TIMEOUT_MS = 15e3;
8144
8207
  var ConfigLoader = class {
8145
8208
  constructor(options) {
8146
8209
  this.options = options;
@@ -8153,6 +8216,8 @@ var ConfigLoader = class {
8153
8216
  snapshot;
8154
8217
  lastJson;
8155
8218
  inflight;
8219
+ controller;
8220
+ disposed = false;
8156
8221
  get state() {
8157
8222
  return this.snapshot;
8158
8223
  }
@@ -8163,27 +8228,45 @@ var ConfigLoader = class {
8163
8228
  };
8164
8229
  };
8165
8230
  getSnapshot = () => this.snapshot;
8166
- /** Loads the cached copy (if it was fetched from the same URL), then fetches. */
8231
+ /** Loads the cached copy (if it was fetched from the same URL and still checks out), then fetches. */
8167
8232
  async start() {
8168
8233
  const { url, cache: cache2 } = this.options;
8169
8234
  if (!url) return;
8170
8235
  const cached = await cache2?.read().catch(() => null);
8171
- if (cached?.url === url && !this.snapshot.fetchedAt) {
8172
- this.lastJson = JSON.stringify(cached.bundle);
8173
- this.set({ bundle: cached.bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
8236
+ const bundle = cached?.url === url ? revalidateBundle(cached.bundle) : void 0;
8237
+ if (cached && bundle && !this.snapshot.fetchedAt) {
8238
+ this.lastJson = JSON.stringify(bundle);
8239
+ this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
8174
8240
  }
8175
8241
  await this.refresh();
8176
8242
  }
8177
8243
  /** Fetches now. Concurrent calls share one fetch. Only notifies listeners when something changed. */
8178
8244
  refresh() {
8179
- const { url, cache: cache2, fetchJson } = this.options;
8180
- if (!url) return Promise.resolve();
8245
+ const { url, cache: cache2, fetchJson, timeoutMs = DEFAULT_TIMEOUT_MS } = this.options;
8246
+ if (!url || this.disposed) return Promise.resolve();
8181
8247
  this.inflight ??= (async () => {
8248
+ const controller = new AbortController();
8249
+ this.controller = controller;
8250
+ let timer;
8251
+ const abandoned = new Promise((resolve) => {
8252
+ const fail = (message) => resolve({ issues: [{ severity: "error", path: fileName(url), message }], unreachable: true });
8253
+ timer = setTimeout(() => {
8254
+ fail(`no answer in ${timeoutMs / 1e3}s`);
8255
+ controller.abort();
8256
+ }, timeoutMs);
8257
+ controller.signal.addEventListener("abort", () => fail("cancelled"));
8258
+ });
8182
8259
  try {
8183
- const { bundle, issues, revision } = await fetchBundle(url, fetchJson);
8260
+ const result = await Promise.race([fetchBundle(url, fetchJson, controller.signal), abandoned]);
8261
+ if (this.disposed) return;
8262
+ const { bundle, issues, revision, unreachable } = result;
8184
8263
  if (!bundle) {
8185
8264
  const errors = issues.filter((i) => i.severity === "error").length;
8186
- return this.set({ loading: false, error: errors === 1 ? "1 error" : `${errors} errors`, issues });
8265
+ const error = unreachable ? issues[0]?.message : errors === 1 ? "1 error" : `${errors} errors`;
8266
+ return this.set(
8267
+ { loading: false, error, unreachable: !!unreachable, issues },
8268
+ this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || !sameIssues(issues, this.snapshot.issues)
8269
+ );
8187
8270
  }
8188
8271
  const json = JSON.stringify(bundle);
8189
8272
  const changed = json !== this.lastJson;
@@ -8192,18 +8275,26 @@ var ConfigLoader = class {
8192
8275
  if (changed || revision !== this.snapshot.revision) cache2?.write({ url, fetchedAt, bundle, revision }).catch(() => {
8193
8276
  });
8194
8277
  this.set(
8195
- { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, issues },
8278
+ { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, issues },
8196
8279
  changed || revision !== this.snapshot.revision || this.snapshot.source !== "remote" || !!this.snapshot.error || this.snapshot.loading || !sameIssues(issues, this.snapshot.issues)
8197
8280
  );
8198
8281
  } finally {
8282
+ clearTimeout(timer);
8283
+ if (this.controller === controller) this.controller = void 0;
8199
8284
  this.inflight = void 0;
8200
8285
  }
8201
8286
  })();
8202
8287
  return this.inflight;
8203
8288
  }
8289
+ /** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
8290
+ dispose() {
8291
+ this.disposed = true;
8292
+ this.controller?.abort();
8293
+ this.listeners.clear();
8294
+ }
8204
8295
  /** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
8205
8296
  set(patch, notify = true) {
8206
- if (!notify) return;
8297
+ if (!notify || this.disposed) return;
8207
8298
  this.snapshot = { ...this.snapshot, ...patch };
8208
8299
  this.listeners.forEach((l) => l());
8209
8300
  }
@@ -10177,11 +10268,7 @@ var HttpConfigFiles = class {
10177
10268
  }
10178
10269
  };
10179
10270
  function fetchJsonWithToken(token) {
10180
- return async (url, options) => {
10181
- const res = await fetch(url, { headers: { Accept: options?.accept ?? "application/json", ...await authHeaders(token) }, cache: "no-store" });
10182
- if (!res.ok) throw new Error(res.status === 401 ? "not signed in" : `HTTP ${res.status}`);
10183
- return JSON.parse(await res.text());
10184
- };
10271
+ return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
10185
10272
  }
10186
10273
  async function readConfigFiles(source) {
10187
10274
  const all = await source.readAll?.();
@@ -10248,6 +10335,33 @@ function panelSize(panel, mode) {
10248
10335
  return { span: panelSpan(panel, "phone"), h: clampH(panel.mobile?.h ?? p.h) };
10249
10336
  }
10250
10337
  function layoutCanvas(panels, order, mode, width, override) {
10338
+ return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
10339
+ }
10340
+ function layoutGridCanvas(panels, width, override) {
10341
+ const colW = (width + CANVAS_GAP) / GRID_COLUMNS;
10342
+ let boxes = gridBoxes(panels);
10343
+ if (override && boxes[override.index]) {
10344
+ const b = { ...boxes[override.index] };
10345
+ if (!isRow(panels[override.index])) {
10346
+ if (override.span !== void 0) b.w = clampW(override.span);
10347
+ if (override.h !== void 0) b.h = clampH(override.h);
10348
+ }
10349
+ if (override.x !== void 0) b.x = isRow(panels[override.index]) ? 0 : Math.min(GRID_COLUMNS - b.w, Math.max(0, Math.round(override.x)));
10350
+ if (override.y !== void 0) b.y = Math.max(0, Math.round(override.y));
10351
+ b.x = Math.min(b.x, GRID_COLUMNS - b.w);
10352
+ boxes = [...boxes];
10353
+ boxes[override.index] = b;
10354
+ }
10355
+ const settled = settleBoxes(boxes, override?.index);
10356
+ const items = settled.map((b, index) => {
10357
+ const row = isRow(panels[index]);
10358
+ return { index, row, x: b.x * colW, y: gridOffsetPx(b.y), width: b.w * colW - CANVAS_GAP, height: row ? gridUnitsToPx(1) : gridUnitsToPx(b.h), span: b.w, h: b.h };
10359
+ });
10360
+ items.sort((a, b) => a.y - b.y || a.x - b.x);
10361
+ return { items, height: Math.max(0, ...items.map((c) => c.y + c.height)), hidden: [] };
10362
+ }
10363
+ function layoutPhoneCanvas(panels, order, width, override) {
10364
+ const mode = "phone";
10251
10365
  const colW = (width + CANVAS_GAP) / GRID_COLUMNS;
10252
10366
  const items = [];
10253
10367
  const hidden = [];
@@ -10286,7 +10400,8 @@ function layoutCanvas(panels, order, mode, width, override) {
10286
10400
  hidden.push(index);
10287
10401
  continue;
10288
10402
  }
10289
- const size = override?.index === index ? { span: clampW(override.span), h: clampH(override.h) } : panelSize(panel, mode);
10403
+ const natural = panelSize(panel, mode);
10404
+ const size = override?.index === index ? { span: clampW(override.span ?? natural.span), h: clampH(override.h ?? natural.h) } : natural;
10290
10405
  if (used + size.span > GRID_COLUMNS) flush();
10291
10406
  line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
10292
10407
  used += size.span;
@@ -10307,16 +10422,21 @@ function dropTarget(canvas, x, y, dragging) {
10307
10422
  return items[items.indexOf(best) + 1]?.index ?? null;
10308
10423
  }
10309
10424
  function movePanel(panels, index, before) {
10310
- const order = readingOrder(panels).filter((i) => i !== index);
10311
- const at = before === null ? order.length : order.indexOf(before);
10312
- order.splice(at === -1 ? order.length : at, 0, index);
10313
- return repack(panels, order);
10425
+ if (before === index) return panels;
10426
+ const others = panels.filter((_, i) => i !== index);
10427
+ const at = before === null || !panels[before] ? { x: 0, y: bottom(others) } : pos(panels[before]);
10428
+ return placePanel(panels, index, at.x, at.y);
10314
10429
  }
10315
10430
  function resizePanel(panels, index, mode, span, h) {
10316
10431
  const out = [...panels];
10317
10432
  const p = panels[index];
10318
- out[index] = mode === "grid" ? { ...p, gridPos: { ...pos(p), w: clampW(span), h: clampH(h) } } : { ...p, mobile: { ...p.mobile, span: clampW(span), h: clampH(h) } };
10319
- return repack(out, readingOrder(out));
10433
+ if (mode === "phone") {
10434
+ out[index] = { ...p, mobile: { ...p.mobile, span: clampW(span), h: clampH(h) } };
10435
+ return out;
10436
+ }
10437
+ const w = clampW(span);
10438
+ out[index] = { ...p, gridPos: { ...pos(p), x: Math.min(pos(p).x, GRID_COLUMNS - w), w, h: clampH(h) } };
10439
+ return settleLayout(out, index);
10320
10440
  }
10321
10441
  function setHiddenOnPhones(panels, index, hidden) {
10322
10442
  const out = [...panels];
@@ -10331,34 +10451,77 @@ function nextPanelId(panels) {
10331
10451
  }
10332
10452
  function insertPanel(panels, panel, after) {
10333
10453
  const index = panels.length;
10334
- const out = [...panels, { ...panel, id: nextPanelId(panels), gridPos: { ...DEFAULT_POS, ...panel.gridPos } }];
10335
- const order = readingOrder(panels);
10336
- order.splice(after === null ? order.length : order.indexOf(after) + 1, 0, index);
10337
- return { panels: repack(out, order), index };
10454
+ const p = { ...DEFAULT_POS, ...panel.gridPos };
10455
+ const w = isRow(panel) ? GRID_COLUMNS : clampW(p.w);
10456
+ let at;
10457
+ if (after === null || !panels[after]) at = { x: 0, y: bottom(panels) };
10458
+ else {
10459
+ const a = pos(panels[after]);
10460
+ at = !isRow(panel) && !isRow(panels[after]) && a.x + a.w + w <= GRID_COLUMNS ? { x: a.x + a.w, y: a.y } : { x: isRow(panel) ? 0 : Math.min(a.x, GRID_COLUMNS - w), y: a.y + a.h };
10461
+ }
10462
+ const out = [...panels, { ...panel, id: nextPanelId(panels), gridPos: { ...p, ...at, w } }];
10463
+ return { panels: settleLayout(out, index), index };
10338
10464
  }
10339
10465
  function duplicatePanel(panels, index) {
10340
10466
  return insertPanel(panels, structuredClone(panels[index]), index);
10341
10467
  }
10342
10468
  function removePanel(panels, index) {
10343
- const out = panels.filter((_, i) => i !== index);
10344
- return repack(out, readingOrder(out));
10469
+ return settleLayout(panels.filter((_, i) => i !== index));
10345
10470
  }
10346
10471
  function expandRow(panels, index) {
10347
10472
  const row = panels[index];
10348
10473
  const children = row.panels ?? [];
10349
- const out = [...panels, ...children];
10474
+ const top = pos(row).y + 1;
10475
+ const first = Math.min(...children.map((c) => pos(c).y));
10476
+ const height = Math.max(0, ...children.map((c) => pos(c).y - first + pos(c).h));
10477
+ const out = panels.map((p, i) => i !== index && pos(p).y > pos(row).y ? { ...p, gridPos: { ...pos(p), y: pos(p).y + height } } : p);
10350
10478
  out[index] = { ...row, collapsed: false, panels: [] };
10479
+ out.push(...children.map((c) => ({ ...c, gridPos: { ...pos(c), y: top + pos(c).y - first } })));
10480
+ return settleLayout(out);
10481
+ }
10482
+ function collapseRow(panels, index) {
10351
10483
  const order = readingOrder(panels);
10352
- order.splice(order.indexOf(index) + 1, 0, ...children.map((_, i) => panels.length + i));
10353
- return repack(out, order);
10484
+ const at = order.indexOf(index);
10485
+ const next = order.findIndex((i, n) => n > at && isRow(panels[i]));
10486
+ const removed = order.slice(at + 1, next === -1 ? order.length : next).sort((a, b) => a - b);
10487
+ const out = panels.filter((_, i) => !removed.includes(i));
10488
+ const rowAt = index - removed.filter((i) => i < index).length;
10489
+ out[rowAt] = { ...panels[index], collapsed: true, panels: removed.map((i) => panels[i]) };
10490
+ return { panels: settleLayout(out), removed };
10491
+ }
10492
+ var bottom = (panels) => Math.max(0, ...panels.map((p) => pos(p).y + pos(p).h));
10493
+ var gridBoxes = (panels) => panels.map((p) => isRow(p) ? { ...pos(p), x: 0, w: GRID_COLUMNS, h: 1 } : pos(p));
10494
+ function settleBoxes(boxes, fixed2) {
10495
+ const made = fixed2 === void 0 ? boxes : compactGrid(boxes, /* @__PURE__ */ new Set([fixed2]));
10496
+ return compactGrid(made);
10497
+ }
10498
+ function writeBoxes(panels, boxes) {
10499
+ return panels.map((p, i) => {
10500
+ const before = p.gridPos;
10501
+ const b = boxes[i];
10502
+ return before && before.x === b.x && before.y === b.y && before.w === b.w && before.h === b.h ? p : { ...p, gridPos: { ...pos(p), ...b } };
10503
+ });
10504
+ }
10505
+ function settleLayout(panels, fixed2) {
10506
+ return writeBoxes(panels, settleBoxes(gridBoxes(panels), fixed2));
10507
+ }
10508
+ function placePanel(panels, index, x, y) {
10509
+ const out = [...panels];
10510
+ const p = pos(panels[index]);
10511
+ const w = isRow(panels[index]) ? GRID_COLUMNS : clampW(p.w);
10512
+ out[index] = { ...panels[index], gridPos: { ...p, x: Math.min(GRID_COLUMNS - w, Math.max(0, Math.round(x))), y: Math.max(0, Math.round(y)) } };
10513
+ return settleLayout(out, index);
10514
+ }
10515
+ function snapToGrid(width, x, y, w) {
10516
+ const colW = (width + CANVAS_GAP) / GRID_COLUMNS;
10517
+ return { x: Math.min(GRID_COLUMNS - w, Math.max(0, Math.round(x / colW))), y: Math.max(0, Math.round(y / gridOffsetPx(1))) };
10354
10518
  }
10355
10519
  function panelEdits(before, after, removed) {
10356
10520
  const edits = [];
10357
10521
  let base = before;
10358
- if (removed !== void 0) {
10359
- edits.push({ path: ["panels", removed], remove: true });
10360
- base = before.filter((_, i) => i !== removed);
10361
- }
10522
+ const gone = [...new Set(removed === void 0 ? [] : [removed].flat())].sort((a, b) => b - a);
10523
+ for (const i of gone) edits.push({ path: ["panels", i], remove: true });
10524
+ if (gone.length) base = before.filter((_, i) => !gone.includes(i));
10362
10525
  base.forEach((p, i) => edits.push(...diffJson(p, after[i], ["panels", i])));
10363
10526
  for (let i = base.length; i < after.length; i++) edits.push({ path: ["panels", i], value: after[i], insert: true });
10364
10527
  return edits;
@@ -10478,6 +10641,8 @@ export {
10478
10641
  valueText,
10479
10642
  GRID_COLUMNS,
10480
10643
  gridUnitsToPx,
10644
+ gridOffsetPx,
10645
+ compactGrid,
10481
10646
  isRow,
10482
10647
  layoutDashboard,
10483
10648
  repeatOptions,
@@ -10564,6 +10729,7 @@ export {
10564
10729
  validateDashboard2 as validateDashboard,
10565
10730
  validateBundle,
10566
10731
  resolveUrl,
10732
+ httpFetchJson,
10567
10733
  defaultFetchJson,
10568
10734
  BUNDLE_TYPE,
10569
10735
  BUNDLE_ACCEPT,
@@ -10572,6 +10738,7 @@ export {
10572
10738
  assembleFromResponse,
10573
10739
  assembleBundle,
10574
10740
  fetchBundle,
10741
+ revalidateBundle,
10575
10742
  ConfigLoader,
10576
10743
  tabIdFor,
10577
10744
  screenOfType,
@@ -10625,6 +10792,10 @@ export {
10625
10792
  duplicatePanel,
10626
10793
  removePanel,
10627
10794
  expandRow,
10795
+ collapseRow,
10796
+ settleLayout,
10797
+ placePanel,
10798
+ snapToGrid,
10628
10799
  panelEdits,
10629
10800
  sampleEntries
10630
10801
  };
@@ -187,7 +187,6 @@
187
187
 
188
188
 
189
189
 
190
- var _chunkL4SQVIJVjs = require('../chunk-L4SQVIJV.js');
191
190
 
192
191
 
193
192
 
@@ -196,6 +195,7 @@ var _chunkL4SQVIJVjs = require('../chunk-L4SQVIJV.js');
196
195
 
197
196
 
198
197
 
198
+ var _chunkHZEXKGDSjs = require('../chunk-HZEXKGDS.js');
199
199
 
200
200
 
201
201
 
@@ -377,4 +377,20 @@ var _chunkL4SQVIJVjs = require('../chunk-L4SQVIJV.js');
377
377
 
378
378
 
379
379
 
380
- exports.ALL = _chunkL4SQVIJVjs.ALL; exports.BUNDLE_ACCEPT = _chunkL4SQVIJVjs.BUNDLE_ACCEPT; exports.BUNDLE_TYPE = _chunkL4SQVIJVjs.BUNDLE_TYPE; exports.CANVAS_GAP = _chunkL4SQVIJVjs.CANVAS_GAP; exports.CANVAS_ROW_HEADER = _chunkL4SQVIJVjs.CANVAS_ROW_HEADER; exports.ConfigLoader = _chunkL4SQVIJVjs.ConfigLoader; exports.DASHBOARD_DS = _chunkL4SQVIJVjs.DASHBOARD_DS; exports.DEFAULT_GAZETTEER = _chunkL4SQVIJVjs.DEFAULT_GAZETTEER; exports.EDITABLE_VARIABLE_TYPES = _chunkL4SQVIJVjs.EDITABLE_VARIABLE_TYPES; exports.GRID_COLUMNS = _chunkL4SQVIJVjs.GRID_COLUMNS; exports.GrafanaClient = _chunkL4SQVIJVjs.GrafanaClient; exports.GrafanaDataSource = _chunkL4SQVIJVjs.GrafanaDataSource; exports.GrafanaError = _chunkL4SQVIJVjs.GrafanaError; exports.HttpConfigFiles = _chunkL4SQVIJVjs.HttpConfigFiles; exports.INPUT_OPTION_KEYS = _chunkL4SQVIJVjs.INPUT_OPTION_KEYS; exports.INPUT_TYPES = _chunkL4SQVIJVjs.INPUT_TYPES; exports.LOCAL_DATASOURCE_TYPE = _chunkL4SQVIJVjs.LOCAL_DATASOURCE_TYPE; exports.LocalDataSource = _chunkL4SQVIJVjs.LocalDataSource; exports.MANIFEST_VERSION = _chunkL4SQVIJVjs.MANIFEST_VERSION; exports.MAPPING_TYPES = _chunkL4SQVIJVjs.MAPPING_TYPES; exports.MemoryEntryStore = _chunkL4SQVIJVjs.MemoryEntryStore; exports.NAMED_COLORS = _chunkL4SQVIJVjs.NAMED_COLORS; exports.OPTION_CATEGORIES = _chunkL4SQVIJVjs.OPTION_CATEGORIES; exports.OVERRIDE_MATCHERS = _chunkL4SQVIJVjs.OVERRIDE_MATCHERS; exports.PANEL_TYPES = _chunkL4SQVIJVjs.PANEL_TYPES; exports.REDUCER_LABELS = _chunkL4SQVIJVjs.REDUCER_LABELS; exports.REFRESH_CHOICES = _chunkL4SQVIJVjs.REFRESH_CHOICES; exports.RELATIVE_RANGES = _chunkL4SQVIJVjs.RELATIVE_RANGES; exports.SERIES_PALETTE = _chunkL4SQVIJVjs.SERIES_PALETTE; exports.SPECIAL_MATCHES = _chunkL4SQVIJVjs.SPECIAL_MATCHES; exports.SaveConflictError = _chunkL4SQVIJVjs.SaveConflictError; exports.TIME_PRESETS = _chunkL4SQVIJVjs.TIME_PRESETS; exports.UNIT_CHOICES = _chunkL4SQVIJVjs.UNIT_CHOICES; exports.addTime = _chunkL4SQVIJVjs.addTime; exports.appSchema = _chunkL4SQVIJVjs.appSchema; exports.applyDashboardLink = _chunkL4SQVIJVjs.applyDashboardLink; exports.applyJsonEdits = _chunkL4SQVIJVjs.applyJsonEdits; exports.applyTransformations = _chunkL4SQVIJVjs.applyTransformations; exports.assembleBundle = _chunkL4SQVIJVjs.assembleBundle; exports.assembleFromResponse = _chunkL4SQVIJVjs.assembleFromResponse; exports.buildFrames = _chunkL4SQVIJVjs.buildFrames; exports.bundleFromFiles = _chunkL4SQVIJVjs.bundleFromFiles; exports.bundleRoot = _chunkL4SQVIJVjs.bundleRoot; exports.calculateInterval = _chunkL4SQVIJVjs.calculateInterval; exports.checkFiles = _chunkL4SQVIJVjs.checkFiles; exports.cleanDashboard = _chunkL4SQVIJVjs.cleanDashboard; exports.cleanPanelOptions = _chunkL4SQVIJVjs.cleanPanelOptions; exports.dashboardSchema = _chunkL4SQVIJVjs.dashboardSchema; exports.dashboardSchemaIssues = _chunkL4SQVIJVjs.dashboardSchemaIssues; exports.dashboardSourceIds = _chunkL4SQVIJVjs.dashboardSourceIds; exports.defaultFetchJson = _chunkL4SQVIJVjs.defaultFetchJson; exports.describeRange = _chunkL4SQVIJVjs.describeRange; exports.diffJson = _chunkL4SQVIJVjs.diffJson; exports.documentIdFor = _chunkL4SQVIJVjs.documentIdFor; exports.documentUses = _chunkL4SQVIJVjs.documentUses; exports.dropTarget = _chunkL4SQVIJVjs.dropTarget; exports.duplicatePanel = _chunkL4SQVIJVjs.duplicatePanel; exports.entriesSavedWith = _chunkL4SQVIJVjs.entriesSavedWith; exports.entryToInputValue = _chunkL4SQVIJVjs.entryToInputValue; exports.expandRow = _chunkL4SQVIJVjs.expandRow; exports.fetchBundle = _chunkL4SQVIJVjs.fetchBundle; exports.fetchJsonWithToken = _chunkL4SQVIJVjs.fetchJsonWithToken; exports.fieldDisplayName = _chunkL4SQVIJVjs.fieldDisplayName; exports.fieldMatches = _chunkL4SQVIJVjs.fieldMatches; exports.formatClock = _chunkL4SQVIJVjs.formatClock; exports.formatDisplay = _chunkL4SQVIJVjs.formatDisplay; exports.formatDuration = _chunkL4SQVIJVjs.formatDuration; exports.formatJsonText = _chunkL4SQVIJVjs.formatJsonText; exports.formatLocalDateTime = _chunkL4SQVIJVjs.formatLocalDateTime; exports.formatValue = _chunkL4SQVIJVjs.formatValue; exports.frameLength = _chunkL4SQVIJVjs.frameLength; exports.framesToOptions = _chunkL4SQVIJVjs.framesToOptions; exports.fromWire = _chunkL4SQVIJVjs.fromWire; exports.getPath = _chunkL4SQVIJVjs.getPath; exports.gridUnitsToPx = _chunkL4SQVIJVjs.gridUnitsToPx; exports.initialVariableValues = _chunkL4SQVIJVjs.initialVariableValues; exports.inputPanels = _chunkL4SQVIJVjs.inputPanels; exports.inputProblem = _chunkL4SQVIJVjs.inputProblem; exports.insertPanel = _chunkL4SQVIJVjs.insertPanel; exports.interpolate = _chunkL4SQVIJVjs.interpolate; exports.interpolateDeep = _chunkL4SQVIJVjs.interpolateDeep; exports.isBundleResponse = _chunkL4SQVIJVjs.isBundleResponse; exports.isEditableVariableType = _chunkL4SQVIJVjs.isEditableVariableType; exports.isInputPanel = _chunkL4SQVIJVjs.isInputPanel; exports.isInputType = _chunkL4SQVIJVjs.isInputType; exports.isLocalDatasource = _chunkL4SQVIJVjs.isLocalDatasource; exports.isReducer = _chunkL4SQVIJVjs.isReducer; exports.isRow = _chunkL4SQVIJVjs.isRow; exports.isSqlDatasource = _chunkL4SQVIJVjs.isSqlDatasource; exports.layoutCanvas = _chunkL4SQVIJVjs.layoutCanvas; exports.layoutDashboard = _chunkL4SQVIJVjs.layoutDashboard; exports.lineColumn = _chunkL4SQVIJVjs.lineColumn; exports.loadGazetteer = _chunkL4SQVIJVjs.loadGazetteer; exports.locate = _chunkL4SQVIJVjs.locate; exports.manifestSchemaIssues = _chunkL4SQVIJVjs.manifestSchemaIssues; exports.mappedResult = _chunkL4SQVIJVjs.mappedResult; exports.mappingProblem = _chunkL4SQVIJVjs.mappingProblem; exports.mappingRow = _chunkL4SQVIJVjs.mappingRow; exports.mappingRows = _chunkL4SQVIJVjs.mappingRows; exports.metricChanges = _chunkL4SQVIJVjs.metricChanges; exports.movePanel = _chunkL4SQVIJVjs.movePanel; exports.newDocument = _chunkL4SQVIJVjs.newDocument; exports.newPanel = _chunkL4SQVIJVjs.newPanel; exports.newVariable = _chunkL4SQVIJVjs.newVariable; exports.nextPanelId = _chunkL4SQVIJVjs.nextPanelId; exports.normalizeRef = _chunkL4SQVIJVjs.normalizeRef; exports.numberFields = _chunkL4SQVIJVjs.numberFields; exports.optionValue = _chunkL4SQVIJVjs.optionValue; exports.overrideProperties = _chunkL4SQVIJVjs.overrideProperties; exports.panelEdits = _chunkL4SQVIJVjs.panelEdits; exports.panelHasQueries = _chunkL4SQVIJVjs.panelHasQueries; exports.panelKey = _chunkL4SQVIJVjs.panelKey; exports.panelOptions = _chunkL4SQVIJVjs.panelOptions; exports.panelOverrides = _chunkL4SQVIJVjs.panelOverrides; exports.panelSize = _chunkL4SQVIJVjs.panelSize; exports.panelSpan = _chunkL4SQVIJVjs.panelSpan; exports.parseClockDigits = _chunkL4SQVIJVjs.parseClockDigits; exports.parseDashboardLink = _chunkL4SQVIJVjs.parseDashboardLink; exports.parseDuration = _chunkL4SQVIJVjs.parseDuration; exports.parseGazetteer = _chunkL4SQVIJVjs.parseGazetteer; exports.parseJsonText = _chunkL4SQVIJVjs.parseJsonText; exports.parseLocalDateTime = _chunkL4SQVIJVjs.parseLocalDateTime; exports.parseRange = _chunkL4SQVIJVjs.parseRange; exports.parseTime = _chunkL4SQVIJVjs.parseTime; exports.pointerToPath = _chunkL4SQVIJVjs.pointerToPath; exports.prepareDashboard = _chunkL4SQVIJVjs.prepareDashboard; exports.queryPanel = _chunkL4SQVIJVjs.queryPanel; exports.queryParam = _chunkL4SQVIJVjs.queryParam; exports.readConfigFiles = _chunkL4SQVIJVjs.readConfigFiles; exports.readingOrder = _chunkL4SQVIJVjs.readingOrder; exports.reduce = _chunkL4SQVIJVjs.reduce; exports.refineOptions = _chunkL4SQVIJVjs.refineOptions; exports.refreshedVariables = _chunkL4SQVIJVjs.refreshedVariables; exports.removeDocumentFromManifest = _chunkL4SQVIJVjs.removeDocumentFromManifest; exports.removePanel = _chunkL4SQVIJVjs.removePanel; exports.renameDocumentInManifest = _chunkL4SQVIJVjs.renameDocumentInManifest; exports.renameVariableInPanels = _chunkL4SQVIJVjs.renameVariableInPanels; exports.repack = _chunkL4SQVIJVjs.repack; exports.repeatOptions = _chunkL4SQVIJVjs.repeatOptions; exports.resizePanel = _chunkL4SQVIJVjs.resizePanel; exports.resolveColor = _chunkL4SQVIJVjs.resolveColor; exports.resolveFieldConfig = _chunkL4SQVIJVjs.resolveFieldConfig; exports.resolveLinks = _chunkL4SQVIJVjs.resolveLinks; exports.resolveTimezone = _chunkL4SQVIJVjs.resolveTimezone; exports.resolveUrl = _chunkL4SQVIJVjs.resolveUrl; exports.resolveVariables = _chunkL4SQVIJVjs.resolveVariables; exports.rowsToMappings = _chunkL4SQVIJVjs.rowsToMappings; exports.sampleEntries = _chunkL4SQVIJVjs.sampleEntries; exports.screenDocuments = _chunkL4SQVIJVjs.screenDocuments; exports.screenOfType = _chunkL4SQVIJVjs.screenOfType; exports.selectValue = _chunkL4SQVIJVjs.selectValue; exports.seriesColor = _chunkL4SQVIJVjs.seriesColor; exports.setHiddenOnPhones = _chunkL4SQVIJVjs.setHiddenOnPhones; exports.setJsonValue = _chunkL4SQVIJVjs.setJsonValue; exports.setOption = _chunkL4SQVIJVjs.setOption; exports.setOptionValue = _chunkL4SQVIJVjs.setOptionValue; exports.setOverrides = _chunkL4SQVIJVjs.setOverrides; exports.splitPath = _chunkL4SQVIJVjs.splitPath; exports.startOf = _chunkL4SQVIJVjs.startOf; exports.stringifyCompact = _chunkL4SQVIJVjs.stringifyCompact; exports.tabIdFor = _chunkL4SQVIJVjs.tabIdFor; exports.textSuggestions = _chunkL4SQVIJVjs.textSuggestions; exports.thresholdStep = _chunkL4SQVIJVjs.thresholdStep; exports.timeExprError = _chunkL4SQVIJVjs.timeExprError; exports.timeField = _chunkL4SQVIJVjs.timeField; exports.toEntries = _chunkL4SQVIJVjs.toEntries; exports.toMillis = _chunkL4SQVIJVjs.toMillis; exports.toSeries = _chunkL4SQVIJVjs.toSeries; exports.toXYSeries = _chunkL4SQVIJVjs.toXYSeries; exports.uniqueNames = _chunkL4SQVIJVjs.uniqueNames; exports.validateBundle = _chunkL4SQVIJVjs.validateBundle; exports.validateDashboard = _chunkL4SQVIJVjs.validateDashboard; exports.validateManifest = _chunkL4SQVIJVjs.validateManifest; exports.valueColor = _chunkL4SQVIJVjs.valueColor; exports.valueText = _chunkL4SQVIJVjs.valueText; exports.variableDependents = _chunkL4SQVIJVjs.variableDependents; exports.variableInfo = _chunkL4SQVIJVjs.variableInfo; exports.variableNameError = _chunkL4SQVIJVjs.variableNameError; exports.variableOptions = _chunkL4SQVIJVjs.variableOptions; exports.variableOrder = _chunkL4SQVIJVjs.variableOrder; exports.variableReferences = _chunkL4SQVIJVjs.variableReferences; exports.variableUses = _chunkL4SQVIJVjs.variableUses; exports.variableWithCurrent = _chunkL4SQVIJVjs.variableWithCurrent; exports.variableWithFlags = _chunkL4SQVIJVjs.variableWithFlags; exports.variableWithQuery = _chunkL4SQVIJVjs.variableWithQuery; exports.variableWithType = _chunkL4SQVIJVjs.variableWithType; exports.visibleVariables = _chunkL4SQVIJVjs.visibleVariables; exports.zoomRange = _chunkL4SQVIJVjs.zoomRange;
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+ exports.ALL = _chunkHZEXKGDSjs.ALL; exports.BUNDLE_ACCEPT = _chunkHZEXKGDSjs.BUNDLE_ACCEPT; exports.BUNDLE_TYPE = _chunkHZEXKGDSjs.BUNDLE_TYPE; exports.CANVAS_GAP = _chunkHZEXKGDSjs.CANVAS_GAP; exports.CANVAS_ROW_HEADER = _chunkHZEXKGDSjs.CANVAS_ROW_HEADER; exports.ConfigLoader = _chunkHZEXKGDSjs.ConfigLoader; exports.DASHBOARD_DS = _chunkHZEXKGDSjs.DASHBOARD_DS; exports.DEFAULT_GAZETTEER = _chunkHZEXKGDSjs.DEFAULT_GAZETTEER; exports.EDITABLE_VARIABLE_TYPES = _chunkHZEXKGDSjs.EDITABLE_VARIABLE_TYPES; exports.GRID_COLUMNS = _chunkHZEXKGDSjs.GRID_COLUMNS; exports.GrafanaClient = _chunkHZEXKGDSjs.GrafanaClient; exports.GrafanaDataSource = _chunkHZEXKGDSjs.GrafanaDataSource; exports.GrafanaError = _chunkHZEXKGDSjs.GrafanaError; exports.HttpConfigFiles = _chunkHZEXKGDSjs.HttpConfigFiles; exports.INPUT_OPTION_KEYS = _chunkHZEXKGDSjs.INPUT_OPTION_KEYS; exports.INPUT_TYPES = _chunkHZEXKGDSjs.INPUT_TYPES; exports.LOCAL_DATASOURCE_TYPE = _chunkHZEXKGDSjs.LOCAL_DATASOURCE_TYPE; exports.LocalDataSource = _chunkHZEXKGDSjs.LocalDataSource; exports.MANIFEST_VERSION = _chunkHZEXKGDSjs.MANIFEST_VERSION; exports.MAPPING_TYPES = _chunkHZEXKGDSjs.MAPPING_TYPES; exports.MemoryEntryStore = _chunkHZEXKGDSjs.MemoryEntryStore; exports.NAMED_COLORS = _chunkHZEXKGDSjs.NAMED_COLORS; exports.OPTION_CATEGORIES = _chunkHZEXKGDSjs.OPTION_CATEGORIES; exports.OVERRIDE_MATCHERS = _chunkHZEXKGDSjs.OVERRIDE_MATCHERS; exports.PANEL_TYPES = _chunkHZEXKGDSjs.PANEL_TYPES; exports.REDUCER_LABELS = _chunkHZEXKGDSjs.REDUCER_LABELS; exports.REFRESH_CHOICES = _chunkHZEXKGDSjs.REFRESH_CHOICES; exports.RELATIVE_RANGES = _chunkHZEXKGDSjs.RELATIVE_RANGES; exports.SERIES_PALETTE = _chunkHZEXKGDSjs.SERIES_PALETTE; exports.SPECIAL_MATCHES = _chunkHZEXKGDSjs.SPECIAL_MATCHES; exports.SaveConflictError = _chunkHZEXKGDSjs.SaveConflictError; exports.TIME_PRESETS = _chunkHZEXKGDSjs.TIME_PRESETS; exports.UNIT_CHOICES = _chunkHZEXKGDSjs.UNIT_CHOICES; exports.addTime = _chunkHZEXKGDSjs.addTime; exports.appSchema = _chunkHZEXKGDSjs.appSchema; exports.applyDashboardLink = _chunkHZEXKGDSjs.applyDashboardLink; exports.applyJsonEdits = _chunkHZEXKGDSjs.applyJsonEdits; exports.applyTransformations = _chunkHZEXKGDSjs.applyTransformations; exports.assembleBundle = _chunkHZEXKGDSjs.assembleBundle; exports.assembleFromResponse = _chunkHZEXKGDSjs.assembleFromResponse; exports.buildFrames = _chunkHZEXKGDSjs.buildFrames; exports.bundleFromFiles = _chunkHZEXKGDSjs.bundleFromFiles; exports.bundleRoot = _chunkHZEXKGDSjs.bundleRoot; exports.calculateInterval = _chunkHZEXKGDSjs.calculateInterval; exports.checkFiles = _chunkHZEXKGDSjs.checkFiles; exports.cleanDashboard = _chunkHZEXKGDSjs.cleanDashboard; exports.cleanPanelOptions = _chunkHZEXKGDSjs.cleanPanelOptions; exports.collapseRow = _chunkHZEXKGDSjs.collapseRow; exports.compactGrid = _chunkHZEXKGDSjs.compactGrid; exports.dashboardSchema = _chunkHZEXKGDSjs.dashboardSchema; exports.dashboardSchemaIssues = _chunkHZEXKGDSjs.dashboardSchemaIssues; exports.dashboardSourceIds = _chunkHZEXKGDSjs.dashboardSourceIds; exports.defaultFetchJson = _chunkHZEXKGDSjs.defaultFetchJson; exports.describeRange = _chunkHZEXKGDSjs.describeRange; exports.diffJson = _chunkHZEXKGDSjs.diffJson; exports.documentIdFor = _chunkHZEXKGDSjs.documentIdFor; exports.documentUses = _chunkHZEXKGDSjs.documentUses; exports.dropTarget = _chunkHZEXKGDSjs.dropTarget; exports.duplicatePanel = _chunkHZEXKGDSjs.duplicatePanel; exports.entriesSavedWith = _chunkHZEXKGDSjs.entriesSavedWith; exports.entryToInputValue = _chunkHZEXKGDSjs.entryToInputValue; exports.expandRow = _chunkHZEXKGDSjs.expandRow; exports.fetchBundle = _chunkHZEXKGDSjs.fetchBundle; exports.fetchJsonWithToken = _chunkHZEXKGDSjs.fetchJsonWithToken; exports.fieldDisplayName = _chunkHZEXKGDSjs.fieldDisplayName; exports.fieldMatches = _chunkHZEXKGDSjs.fieldMatches; exports.formatClock = _chunkHZEXKGDSjs.formatClock; exports.formatDisplay = _chunkHZEXKGDSjs.formatDisplay; exports.formatDuration = _chunkHZEXKGDSjs.formatDuration; exports.formatJsonText = _chunkHZEXKGDSjs.formatJsonText; exports.formatLocalDateTime = _chunkHZEXKGDSjs.formatLocalDateTime; exports.formatValue = _chunkHZEXKGDSjs.formatValue; exports.frameLength = _chunkHZEXKGDSjs.frameLength; exports.framesToOptions = _chunkHZEXKGDSjs.framesToOptions; exports.fromWire = _chunkHZEXKGDSjs.fromWire; exports.getPath = _chunkHZEXKGDSjs.getPath; exports.gridOffsetPx = _chunkHZEXKGDSjs.gridOffsetPx; exports.gridUnitsToPx = _chunkHZEXKGDSjs.gridUnitsToPx; exports.httpFetchJson = _chunkHZEXKGDSjs.httpFetchJson; exports.initialVariableValues = _chunkHZEXKGDSjs.initialVariableValues; exports.inputPanels = _chunkHZEXKGDSjs.inputPanels; exports.inputProblem = _chunkHZEXKGDSjs.inputProblem; exports.insertPanel = _chunkHZEXKGDSjs.insertPanel; exports.interpolate = _chunkHZEXKGDSjs.interpolate; exports.interpolateDeep = _chunkHZEXKGDSjs.interpolateDeep; exports.isBundleResponse = _chunkHZEXKGDSjs.isBundleResponse; exports.isEditableVariableType = _chunkHZEXKGDSjs.isEditableVariableType; exports.isInputPanel = _chunkHZEXKGDSjs.isInputPanel; exports.isInputType = _chunkHZEXKGDSjs.isInputType; exports.isLocalDatasource = _chunkHZEXKGDSjs.isLocalDatasource; exports.isReducer = _chunkHZEXKGDSjs.isReducer; exports.isRow = _chunkHZEXKGDSjs.isRow; exports.isSqlDatasource = _chunkHZEXKGDSjs.isSqlDatasource; exports.layoutCanvas = _chunkHZEXKGDSjs.layoutCanvas; exports.layoutDashboard = _chunkHZEXKGDSjs.layoutDashboard; exports.lineColumn = _chunkHZEXKGDSjs.lineColumn; exports.loadGazetteer = _chunkHZEXKGDSjs.loadGazetteer; exports.locate = _chunkHZEXKGDSjs.locate; exports.manifestSchemaIssues = _chunkHZEXKGDSjs.manifestSchemaIssues; exports.mappedResult = _chunkHZEXKGDSjs.mappedResult; exports.mappingProblem = _chunkHZEXKGDSjs.mappingProblem; exports.mappingRow = _chunkHZEXKGDSjs.mappingRow; exports.mappingRows = _chunkHZEXKGDSjs.mappingRows; exports.metricChanges = _chunkHZEXKGDSjs.metricChanges; exports.movePanel = _chunkHZEXKGDSjs.movePanel; exports.newDocument = _chunkHZEXKGDSjs.newDocument; exports.newPanel = _chunkHZEXKGDSjs.newPanel; exports.newVariable = _chunkHZEXKGDSjs.newVariable; exports.nextPanelId = _chunkHZEXKGDSjs.nextPanelId; exports.normalizeRef = _chunkHZEXKGDSjs.normalizeRef; exports.numberFields = _chunkHZEXKGDSjs.numberFields; exports.optionValue = _chunkHZEXKGDSjs.optionValue; exports.overrideProperties = _chunkHZEXKGDSjs.overrideProperties; exports.panelEdits = _chunkHZEXKGDSjs.panelEdits; exports.panelHasQueries = _chunkHZEXKGDSjs.panelHasQueries; exports.panelKey = _chunkHZEXKGDSjs.panelKey; exports.panelOptions = _chunkHZEXKGDSjs.panelOptions; exports.panelOverrides = _chunkHZEXKGDSjs.panelOverrides; exports.panelSize = _chunkHZEXKGDSjs.panelSize; exports.panelSpan = _chunkHZEXKGDSjs.panelSpan; exports.parseClockDigits = _chunkHZEXKGDSjs.parseClockDigits; exports.parseDashboardLink = _chunkHZEXKGDSjs.parseDashboardLink; exports.parseDuration = _chunkHZEXKGDSjs.parseDuration; exports.parseGazetteer = _chunkHZEXKGDSjs.parseGazetteer; exports.parseJsonText = _chunkHZEXKGDSjs.parseJsonText; exports.parseLocalDateTime = _chunkHZEXKGDSjs.parseLocalDateTime; exports.parseRange = _chunkHZEXKGDSjs.parseRange; exports.parseTime = _chunkHZEXKGDSjs.parseTime; exports.placePanel = _chunkHZEXKGDSjs.placePanel; exports.pointerToPath = _chunkHZEXKGDSjs.pointerToPath; exports.prepareDashboard = _chunkHZEXKGDSjs.prepareDashboard; exports.queryPanel = _chunkHZEXKGDSjs.queryPanel; exports.queryParam = _chunkHZEXKGDSjs.queryParam; exports.readConfigFiles = _chunkHZEXKGDSjs.readConfigFiles; exports.readingOrder = _chunkHZEXKGDSjs.readingOrder; exports.reduce = _chunkHZEXKGDSjs.reduce; exports.refineOptions = _chunkHZEXKGDSjs.refineOptions; exports.refreshedVariables = _chunkHZEXKGDSjs.refreshedVariables; exports.removeDocumentFromManifest = _chunkHZEXKGDSjs.removeDocumentFromManifest; exports.removePanel = _chunkHZEXKGDSjs.removePanel; exports.renameDocumentInManifest = _chunkHZEXKGDSjs.renameDocumentInManifest; exports.renameVariableInPanels = _chunkHZEXKGDSjs.renameVariableInPanels; exports.repack = _chunkHZEXKGDSjs.repack; exports.repeatOptions = _chunkHZEXKGDSjs.repeatOptions; exports.resizePanel = _chunkHZEXKGDSjs.resizePanel; exports.resolveColor = _chunkHZEXKGDSjs.resolveColor; exports.resolveFieldConfig = _chunkHZEXKGDSjs.resolveFieldConfig; exports.resolveLinks = _chunkHZEXKGDSjs.resolveLinks; exports.resolveTimezone = _chunkHZEXKGDSjs.resolveTimezone; exports.resolveUrl = _chunkHZEXKGDSjs.resolveUrl; exports.resolveVariables = _chunkHZEXKGDSjs.resolveVariables; exports.revalidateBundle = _chunkHZEXKGDSjs.revalidateBundle; exports.rowsToMappings = _chunkHZEXKGDSjs.rowsToMappings; exports.sampleEntries = _chunkHZEXKGDSjs.sampleEntries; exports.screenDocuments = _chunkHZEXKGDSjs.screenDocuments; exports.screenOfType = _chunkHZEXKGDSjs.screenOfType; exports.selectValue = _chunkHZEXKGDSjs.selectValue; exports.seriesColor = _chunkHZEXKGDSjs.seriesColor; exports.setHiddenOnPhones = _chunkHZEXKGDSjs.setHiddenOnPhones; exports.setJsonValue = _chunkHZEXKGDSjs.setJsonValue; exports.setOption = _chunkHZEXKGDSjs.setOption; exports.setOptionValue = _chunkHZEXKGDSjs.setOptionValue; exports.setOverrides = _chunkHZEXKGDSjs.setOverrides; exports.settleLayout = _chunkHZEXKGDSjs.settleLayout; exports.snapToGrid = _chunkHZEXKGDSjs.snapToGrid; exports.splitPath = _chunkHZEXKGDSjs.splitPath; exports.startOf = _chunkHZEXKGDSjs.startOf; exports.stringifyCompact = _chunkHZEXKGDSjs.stringifyCompact; exports.tabIdFor = _chunkHZEXKGDSjs.tabIdFor; exports.textSuggestions = _chunkHZEXKGDSjs.textSuggestions; exports.thresholdStep = _chunkHZEXKGDSjs.thresholdStep; exports.timeExprError = _chunkHZEXKGDSjs.timeExprError; exports.timeField = _chunkHZEXKGDSjs.timeField; exports.toEntries = _chunkHZEXKGDSjs.toEntries; exports.toMillis = _chunkHZEXKGDSjs.toMillis; exports.toSeries = _chunkHZEXKGDSjs.toSeries; exports.toXYSeries = _chunkHZEXKGDSjs.toXYSeries; exports.uniqueNames = _chunkHZEXKGDSjs.uniqueNames; exports.validateBundle = _chunkHZEXKGDSjs.validateBundle; exports.validateDashboard = _chunkHZEXKGDSjs.validateDashboard; exports.validateManifest = _chunkHZEXKGDSjs.validateManifest; exports.valueColor = _chunkHZEXKGDSjs.valueColor; exports.valueText = _chunkHZEXKGDSjs.valueText; exports.variableDependents = _chunkHZEXKGDSjs.variableDependents; exports.variableInfo = _chunkHZEXKGDSjs.variableInfo; exports.variableNameError = _chunkHZEXKGDSjs.variableNameError; exports.variableOptions = _chunkHZEXKGDSjs.variableOptions; exports.variableOrder = _chunkHZEXKGDSjs.variableOrder; exports.variableReferences = _chunkHZEXKGDSjs.variableReferences; exports.variableUses = _chunkHZEXKGDSjs.variableUses; exports.variableWithCurrent = _chunkHZEXKGDSjs.variableWithCurrent; exports.variableWithFlags = _chunkHZEXKGDSjs.variableWithFlags; exports.variableWithQuery = _chunkHZEXKGDSjs.variableWithQuery; exports.variableWithType = _chunkHZEXKGDSjs.variableWithType; exports.visibleVariables = _chunkHZEXKGDSjs.visibleVariables; exports.zoomRange = _chunkHZEXKGDSjs.zoomRange;
@@ -46,6 +46,8 @@ import {
46
46
  checkFiles,
47
47
  cleanDashboard,
48
48
  cleanPanelOptions,
49
+ collapseRow,
50
+ compactGrid,
49
51
  dashboardSchema,
50
52
  dashboardSchemaIssues,
51
53
  dashboardSourceIds,
@@ -73,7 +75,9 @@ import {
73
75
  framesToOptions,
74
76
  fromWire,
75
77
  getPath,
78
+ gridOffsetPx,
76
79
  gridUnitsToPx,
80
+ httpFetchJson,
77
81
  initialVariableValues,
78
82
  inputPanels,
79
83
  inputProblem,
@@ -123,6 +127,7 @@ import {
123
127
  parseLocalDateTime,
124
128
  parseRange,
125
129
  parseTime,
130
+ placePanel,
126
131
  pointerToPath,
127
132
  prepareDashboard,
128
133
  queryPanel,
@@ -145,6 +150,7 @@ import {
145
150
  resolveTimezone,
146
151
  resolveUrl,
147
152
  resolveVariables,
153
+ revalidateBundle,
148
154
  rowsToMappings,
149
155
  sampleEntries,
150
156
  screenDocuments,
@@ -156,6 +162,8 @@ import {
156
162
  setOption,
157
163
  setOptionValue,
158
164
  setOverrides,
165
+ settleLayout,
166
+ snapToGrid,
159
167
  splitPath,
160
168
  startOf,
161
169
  stringifyCompact,
@@ -187,7 +195,7 @@ import {
187
195
  variableWithType,
188
196
  visibleVariables,
189
197
  zoomRange
190
- } from "../chunk-PIHXMZ4G.mjs";
198
+ } from "../chunk-PU7RRUV4.mjs";
191
199
  export {
192
200
  ALL,
193
201
  BUNDLE_ACCEPT,
@@ -236,6 +244,8 @@ export {
236
244
  checkFiles,
237
245
  cleanDashboard,
238
246
  cleanPanelOptions,
247
+ collapseRow,
248
+ compactGrid,
239
249
  dashboardSchema,
240
250
  dashboardSchemaIssues,
241
251
  dashboardSourceIds,
@@ -263,7 +273,9 @@ export {
263
273
  framesToOptions,
264
274
  fromWire,
265
275
  getPath,
276
+ gridOffsetPx,
266
277
  gridUnitsToPx,
278
+ httpFetchJson,
267
279
  initialVariableValues,
268
280
  inputPanels,
269
281
  inputProblem,
@@ -313,6 +325,7 @@ export {
313
325
  parseLocalDateTime,
314
326
  parseRange,
315
327
  parseTime,
328
+ placePanel,
316
329
  pointerToPath,
317
330
  prepareDashboard,
318
331
  queryPanel,
@@ -335,6 +348,7 @@ export {
335
348
  resolveTimezone,
336
349
  resolveUrl,
337
350
  resolveVariables,
351
+ revalidateBundle,
338
352
  rowsToMappings,
339
353
  sampleEntries,
340
354
  screenDocuments,
@@ -346,6 +360,8 @@ export {
346
360
  setOption,
347
361
  setOptionValue,
348
362
  setOverrides,
363
+ settleLayout,
364
+ snapToGrid,
349
365
  splitPath,
350
366
  startOf,
351
367
  stringifyCompact,
@@ -26,15 +26,48 @@ export interface LayoutRow {
26
26
  /** Height in grid units. */
27
27
  h: number;
28
28
  }
29
+ /** A panel placed on Grafana's grid, relative to the top of its section. */
30
+ export interface GridCell extends LayoutCell {
31
+ /** Column of the left edge, 0 to 23. */
32
+ x: number;
33
+ /** In grid units from the top of the section. */
34
+ y: number;
35
+ /** Columns wide; the same as `span`. */
36
+ w: number;
37
+ /** Height in grid units. */
38
+ h: number;
39
+ }
29
40
  export interface LayoutSection {
30
41
  key: string;
31
42
  /** The Grafana "row" panel heading this section, if any. */
32
43
  row?: Panel;
33
44
  collapsed: boolean;
45
+ /** Panels packed into lines in reading order: how phones show the section. */
34
46
  rows: LayoutRow[];
47
+ /** Panels where Grafana puts them, floated up: how wide screens show the section. */
48
+ grid: {
49
+ cells: GridCell[];
50
+ h: number;
51
+ };
35
52
  }
36
53
  /** Grafana's pixel height for h grid units. */
37
54
  export declare const gridUnitsToPx: (h: number) => number;
55
+ /** How far down y grid units starts, in pixels: each unit is a cell plus the gap under it. */
56
+ export declare const gridOffsetPx: (y: number) => number;
57
+ /** A rectangle on Grafana's grid, in columns and height units. */
58
+ export interface GridBox {
59
+ x: number;
60
+ y: number;
61
+ w: number;
62
+ h: number;
63
+ }
64
+ /**
65
+ * Grafana's vertical compaction. Boxes are taken top to bottom, then left to right; each floats
66
+ * up as far as it can, and one that overlaps a box already placed drops below it. Boxes listed
67
+ * in `fixed` are placed first, where they are, so the rest make way for them. Columns are
68
+ * snapped to whole units and kept on the grid. Returns new boxes, in the same order.
69
+ */
70
+ export declare function compactGrid(boxes: GridBox[], fixed?: ReadonlySet<number>): GridBox[];
38
71
  export declare const isRow: (p: Panel) => boolean;
39
72
  /** Current variable values and options; without them repeated rows and panels render once, unrepeated. */
40
73
  export interface RepeatContext {