@malloy-publisher/sdk 0.2.2 → 0.2.3
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/{core-CqRKhtoy.cjs.js → core-BGF3_bhb.cjs.js} +1 -1
- package/dist/{core-mFfgwzPH.es.js → core-Dvp73xXv.es.js} +1 -1
- package/dist/{index-hiul47sw.es.js → index-C3jm0T-h.es.js} +3165 -3157
- package/dist/{index-DD4b_bt0.cjs.js → index-iCOPU4zJ.cjs.js} +30 -30
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
- package/src/components/RenderedResult/RenderedResult.tsx +87 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-iCOPU4zJ.cjs.js"),r=require("./ServerProvider-Cn_LhKda.cjs.js");exports.AnalyzePackageButton=e.AnalyzePackageButton;exports.BrowserWorkbookStorage=e.BrowserWorkbookStorage;exports.ConnectionExplorer=e.ConnectionExplorer;exports.DOC_LINKS=e.DOC_LINKS;exports.DRILL_CELL_CLASS=e.DRILL_CELL_CLASS;exports.DRILL_SELF=e.DRILL_SELF;exports.Dashboard=e.Dashboard;exports.DashboardTile=e.DashboardTile;exports.DataAppViewer=e.DataAppViewer;exports.DimensionFilter=e.DimensionFilter;exports.EmbeddedQueryResult=e.EmbeddedQueryResult;exports.Environment=e.Environment;exports.EnvironmentMaterializations=e.EnvironmentMaterializations;exports.GivenInput=e.GivenInput;exports.GivensPanel=e.GivensPanel;exports.Home=e.Home;exports.Loading=e.Loading;exports.Materializations=e.Materializations;exports.Model=e.Model;exports.ModelExplorer=e.ModelExplorer;exports.ModelExplorerDialog=e.ModelExplorerDialog;exports.Models=e.Models;exports.Notebook=e.Notebook;exports.Package=e.Package;exports.Packages=e.Packages;exports.QueryResult=e.QueryResult;exports.RenderedResult=e.RenderedResult;exports.ResultContainer=e.ResultContainer;exports.SourceExplorerComponent=e.SourceExplorerComponent;exports.SourcesExplorer=e.SourcesExplorer;exports.Workbook=e.Workbook;exports.WorkbookList=e.WorkbookList;exports.WorkbookManager=e.WorkbookManager;exports.WorkbookStorageProvider=e.WorkbookStorageProvider;exports.buildMalloyExplicitTheme=e.buildMalloyExplicitTheme;exports.buildTableCssVars=e.buildTableCssVars;exports.buildVegaThemeOverride=e.buildVegaThemeOverride;exports.createEmbeddedQueryResult=e.createEmbeddedQueryResult;exports.drillDestinations=e.drillDestinations;exports.drillValueToFilter=e.drillValueToFilter;exports.drillableFieldNames=e.drillableFieldNames;exports.encodeDrillValue=e.encodeDrillValue;exports.encodeResourceUri=e.encodeResourceUri;exports.extractDimensionSpecs=e.extractDimensionSpecs;exports.extractSourceFromQuery=e.extractSourceFromQuery;exports.generateFilterClause=e.generateFilterClause;exports.getDimensionKey=e.getDimensionKey;exports.getJoinedSources=e.getJoinedSources;exports.humanizeSlug=e.humanizeSlug;exports.injectWhereClause=e.injectWhereClause;exports.makeDimensionKey=e.makeDimensionKey;exports.markDrillableCells=e.markDrillableCells;exports.packageFileUrl=e.packageFileUrl;exports.parseAllSourceInfos=e.parseAllSourceInfos;exports.parseDimensionFilterAnnotation=e.parseDimensionFilterAnnotation;exports.parseNotebookFilterAnnotation=e.parseNotebookFilterAnnotation;exports.parseResourceUri=e.parseResourceUri;exports.readChartAnnotations=e.readChartAnnotations;exports.resolveDrill=e.resolveDrill;exports.useDimensionFilters=e.useDimensionFilters;exports.useDimensionFiltersFromSpec=e.useDimensionFiltersFromSpec;exports.useDimensionFiltersQuery=e.useDimensionFiltersQuery;exports.useDimensionalFilterRangeData=e.useDimensionalFilterRangeData;exports.useDrill=e.useDrill;exports.useGivensState=e.useGivensState;exports.useModelData=e.useModelData;exports.useModelGivens=e.useModelGivens;exports.useRawQueryData=e.useRawQueryData;exports.useRouterClickHandler=e.useRouterClickHandler;exports.useSuggestOptions=e.useSuggestOptions;exports.DEFAULT_THEME=r.DEFAULT_THEME;exports.ServerProvider=r.ServerProvider;exports.ThemeProvider=r.ThemeProvider;exports.resolveMode=r.resolveMode;exports.resolveTheme=r.resolveTheme;exports.usePublisherTheme=r.usePublisherTheme;exports.useServer=r.useServer;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as s, a7 as r, C as o, ao as i, j as l, l as n, D as t, g as u, i as d, x as m, a0 as D, E as c, R as k, L as p, M as S, N as b, O as g, Q as E, S as v, T as F, U as R, _ as C, Y as L, Z as M, P as h, $ as T, a2 as x, a3 as y, W as A, V as P, a4 as W, a5 as Q, a8 as V, a6 as I, ai as U, aj as _, ak as G, a1 as N, n as f, o as z, k as H, q as K, an as O, y as j, B as w, F as B, ad as J, G as q, r as X, H as Y, ae as Z, m as $, p as aa, I as ea, J as sa, K as ra, am as oa, al as ia, t as la, a9 as na, aa as ta, ab as ua, ac as da, v as ma, ag as Da, X as ca, af as ka, u as pa, e as Sa, ah as ba } from "./index-
|
|
1
|
+
import { A as s, a7 as r, C as o, ao as i, j as l, l as n, D as t, g as u, i as d, x as m, a0 as D, E as c, R as k, L as p, M as S, N as b, O as g, Q as E, S as v, T as F, U as R, _ as C, Y as L, Z as M, P as h, $ as T, a2 as x, a3 as y, W as A, V as P, a4 as W, a5 as Q, a8 as V, a6 as I, ai as U, aj as _, ak as G, a1 as N, n as f, o as z, k as H, q as K, an as O, y as j, B as w, F as B, ad as J, G as q, r as X, H as Y, ae as Z, m as $, p as aa, I as ea, J as sa, K as ra, am as oa, al as ia, t as la, a9 as na, aa as ta, ab as ua, ac as da, v as ma, ag as Da, X as ca, af as ka, u as pa, e as Sa, ah as ba } from "./index-C3jm0T-h.es.js";
|
|
2
2
|
import { aU as Ea, S as va, aW as Fa, aV as Ra, aT as Ca, aE as La, u as Ma } from "./ServerProvider-CWkd55-c.es.js";
|
|
3
3
|
export {
|
|
4
4
|
s as AnalyzePackageButton,
|
package/package.json
CHANGED
|
@@ -40,6 +40,15 @@ type MalloyRenderElement = HTMLElement & Record<string, unknown>;
|
|
|
40
40
|
* `@malloydata/render` if more methods are needed.
|
|
41
41
|
*/
|
|
42
42
|
interface MalloyVizHandle extends DrillMetadataSource {
|
|
43
|
+
// Narrowed from `DrillMetadataSource`, which only declares the part the
|
|
44
|
+
// drill affordance reads. `getRootField().renderAs()` is what decides
|
|
45
|
+
// whether one measurement is enough; see `sizesToContent`.
|
|
46
|
+
getMetadata: () =>
|
|
47
|
+
| (NonNullable<ReturnType<DrillMetadataSource["getMetadata"]>> & {
|
|
48
|
+
getRootField: () => { renderAs: () => string };
|
|
49
|
+
})
|
|
50
|
+
| null
|
|
51
|
+
| undefined;
|
|
43
52
|
setResult: (result: unknown) => void;
|
|
44
53
|
render: (element: HTMLElement) => void;
|
|
45
54
|
remove: () => void;
|
|
@@ -319,6 +328,43 @@ function injectRendererOverrides(): void {
|
|
|
319
328
|
document.head.appendChild(style);
|
|
320
329
|
}
|
|
321
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Whether the renderer's top-level output sizes itself to its CONTENT rather
|
|
333
|
+
* than to the box it was handed, which decides whether measuring it once is
|
|
334
|
+
* enough.
|
|
335
|
+
*
|
|
336
|
+
* It is not, for a table. The renderer signals `onReady` as soon as it knows it
|
|
337
|
+
* can paint, and for a table that is immediately — a chart waits for a non-zero
|
|
338
|
+
* parent size, a table does not — so the single measurement taken there lands
|
|
339
|
+
* before the table's virtualized grid has laid out, and reads a height the
|
|
340
|
+
* table never keeps.
|
|
341
|
+
*
|
|
342
|
+
* Re-measuring a table TERMINATES: `.malloy-table.root` is
|
|
343
|
+
* `height: fit-content; max-height: 100%` in the renderer's own CSS and the
|
|
344
|
+
* wrappers between it and the container add no padding, so shrinking the
|
|
345
|
+
* container to the table's content height is the exact point at which the cap
|
|
346
|
+
* stops binding and the next measurement reports the same number.
|
|
347
|
+
*
|
|
348
|
+
* A root that FILLS its container stays on the one-shot path deliberately: a
|
|
349
|
+
* chart draws itself inset from the box it is given, so feeding its height back
|
|
350
|
+
* as the new container height would ratchet the container down by that inset
|
|
351
|
+
* every pass and never converge.
|
|
352
|
+
*
|
|
353
|
+
* A table is the only root that needs this, and the reason is the virtualized
|
|
354
|
+
* grid rather than the sizing strategy it shares with a `# size=` chart: that
|
|
355
|
+
* chart takes its dimensions from a lookup synchronously, so its first
|
|
356
|
+
* measurement is already right. Measured, for every size value and spelling.
|
|
357
|
+
*/
|
|
358
|
+
function sizesToContent(viz: MalloyVizHandle): boolean {
|
|
359
|
+
try {
|
|
360
|
+
return viz.getMetadata()?.getRootField().renderAs() === "table";
|
|
361
|
+
} catch {
|
|
362
|
+
// Metadata unavailable: measure once, which is the behavior every
|
|
363
|
+
// non-table root gets anyway.
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
322
368
|
function RenderedResultInner({
|
|
323
369
|
result,
|
|
324
370
|
height: inputHeight,
|
|
@@ -411,6 +457,11 @@ function RenderedResultInner({
|
|
|
411
457
|
let drillFocusIn: ((event: FocusEvent) => void) | null = null;
|
|
412
458
|
let observer: MutationObserver | null = null;
|
|
413
459
|
let measureTimeout: NodeJS.Timeout | null = null;
|
|
460
|
+
// Keeps a table's height honest after `onReady` has lied about it; see
|
|
461
|
+
// `sizesToContent` above.
|
|
462
|
+
let sizeObserver: ResizeObserver | null = null;
|
|
463
|
+
let observedNode: HTMLElement | null = null;
|
|
464
|
+
let lastReportedHeight = 0;
|
|
414
465
|
// Safety net so a render that never signals ready (an async renderer
|
|
415
466
|
// error that only reaches onError) can't leave a previous chart showing
|
|
416
467
|
// stale data forever; see the setTimeout below.
|
|
@@ -422,12 +473,21 @@ function RenderedResultInner({
|
|
|
422
473
|
// wraps the renderer output) and report it up. Same grandchild/dashboard
|
|
423
474
|
// HACK as before, just anchored on the stage wrapper.
|
|
424
475
|
const measureRenderedSize = (root: HTMLElement) => {
|
|
425
|
-
if (
|
|
426
|
-
return;
|
|
476
|
+
if (cancelled || !root.firstElementChild) return;
|
|
427
477
|
const child = root.firstElementChild as HTMLElement;
|
|
428
478
|
const grandchild = child.firstElementChild as HTMLElement;
|
|
429
479
|
if (!grandchild) return;
|
|
480
|
+
// A table reports a height of its own, so it keeps being measured
|
|
481
|
+
// even after the first one lands. Everything else measures once.
|
|
482
|
+
const contentSized = viz !== undefined && sizesToContent(viz);
|
|
483
|
+
if (hasMeasuredRef.current && !contentSized) return;
|
|
430
484
|
const greatgrandchild = grandchild.firstElementChild as HTMLElement;
|
|
485
|
+
// `scrollHeight` is the CONTENT height, so this assumes the box adds
|
|
486
|
+
// no chrome of its own. True today: `.malloy-table.root` has no
|
|
487
|
+
// border, and a horizontal scrollbar costs no layout where scrollbars
|
|
488
|
+
// overlay. A wide table clipped by a few pixels on a platform that
|
|
489
|
+
// draws classic scrollbars would be this assumption breaking, and the
|
|
490
|
+
// fix is `+ (offsetHeight - clientHeight)`.
|
|
431
491
|
let renderedHeight =
|
|
432
492
|
grandchild.scrollHeight || grandchild.offsetHeight || 0;
|
|
433
493
|
|
|
@@ -444,10 +504,20 @@ function RenderedResultInner({
|
|
|
444
504
|
|
|
445
505
|
if (renderedHeight > 0) {
|
|
446
506
|
hasMeasuredRef.current = true;
|
|
447
|
-
if (onSizeChange) {
|
|
507
|
+
if (onSizeChange && renderedHeight !== lastReportedHeight) {
|
|
508
|
+
lastReportedHeight = renderedHeight;
|
|
448
509
|
onSizeChange(renderedHeight);
|
|
449
510
|
}
|
|
450
511
|
}
|
|
512
|
+
// Watch the table from here on. Attached after the first measurement
|
|
513
|
+
// rather than at render time because the node does not exist until
|
|
514
|
+
// the renderer builds it, and this is the callback that first sees it.
|
|
515
|
+
if (contentSized && observedNode !== grandchild) {
|
|
516
|
+
observedNode = grandchild;
|
|
517
|
+
sizeObserver?.disconnect();
|
|
518
|
+
sizeObserver = new ResizeObserver(() => measureRenderedSize(root));
|
|
519
|
+
sizeObserver.observe(grandchild);
|
|
520
|
+
}
|
|
451
521
|
};
|
|
452
522
|
|
|
453
523
|
(async () => {
|
|
@@ -508,7 +578,18 @@ function RenderedResultInner({
|
|
|
508
578
|
if (measureTimeout) clearTimeout(measureTimeout);
|
|
509
579
|
measureTimeout = setTimeout(() => {
|
|
510
580
|
measureRenderedSize(stageNode);
|
|
511
|
-
|
|
581
|
+
// Only once a measurement actually landed. Disconnecting
|
|
582
|
+
// unconditionally gave up on a stage whose renderer output was
|
|
583
|
+
// still empty at the first settle, leaving nothing to measure it
|
|
584
|
+
// later.
|
|
585
|
+
//
|
|
586
|
+
// Staying connected cannot loop the way the version this
|
|
587
|
+
// disconnect was first added to guard (#531) could: THAT
|
|
588
|
+
// observer watched the container, with `attributes: true`, so
|
|
589
|
+
// reporting a height re-triggered it through the container's own
|
|
590
|
+
// style. This one watches `stage`, a descendant, which that
|
|
591
|
+
// style write is outside of.
|
|
592
|
+
if (hasMeasuredRef.current) observer?.disconnect();
|
|
512
593
|
}, 100);
|
|
513
594
|
});
|
|
514
595
|
observer.observe(stage, {
|
|
@@ -736,6 +817,7 @@ function RenderedResultInner({
|
|
|
736
817
|
} catch (error) {
|
|
737
818
|
console.error("Error rendering visualization:", error);
|
|
738
819
|
observer?.disconnect();
|
|
820
|
+
sizeObserver?.disconnect();
|
|
739
821
|
drillObserver?.disconnect();
|
|
740
822
|
viz.remove();
|
|
741
823
|
viz = undefined;
|
|
@@ -748,6 +830,7 @@ function RenderedResultInner({
|
|
|
748
830
|
return () => {
|
|
749
831
|
cancelled = true;
|
|
750
832
|
observer?.disconnect();
|
|
833
|
+
sizeObserver?.disconnect();
|
|
751
834
|
if (measureTimeout) clearTimeout(measureTimeout);
|
|
752
835
|
if (readyFallback) clearTimeout(readyFallback);
|
|
753
836
|
// If this render built a stage but never swapped it into `liveRef`
|