Skip to content

Commit f2c8085

Browse files
update kandy samples version with iframe fixes
1 parent 86a047c commit f2c8085

16 files changed

+340
-295
lines changed

docs/StardustDocs/resources/api/generate_docs/notebook_test_generate_docs_1.html

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
</style>
178178
</head>
179179
<body>
180-
<table class="dataframe" id="df_117440512"></table>
180+
<table class="dataframe" id="df_-1426063360"></table>
181181

182182
<p class="dataframe_description"></p>
183183
</body>
@@ -458,44 +458,46 @@
458458

459459
/*<!--*/
460460
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"user: String\">user</span>", children: [], rightAlign: false, values: ["Alice","Bob"] },
461-
{ name: "<span title=\"orders: DataFrame<*>\">orders</span>", children: [], rightAlign: false, values: [{ frameId: 117440513, value: "<b>DataFrame 2 x 2</b>" },{ frameId: 117440514, value: "<b>DataFrame 3 x 2</b>" }] },
462-
], id: 117440512, rootId: 117440512, totalRows: 2 } ) });
461+
{ name: "<span title=\"orders: DataFrame<*>\">orders</span>", children: [], rightAlign: false, values: [{ frameId: -1426063359, value: "<b>DataFrame 2 x 2</b>" },{ frameId: -1426063358, value: "<b>DataFrame 3 x 2</b>" }] },
462+
], id: -1426063360, rootId: -1426063360, totalRows: 2 } ) });
463463
/*-->*/
464464

465465
/*<!--*/
466466
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"orderId: Int\">orderId</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">101</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">102</span></span>"] },
467467
{ name: "<span title=\"amount: Double\">amount</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">50.0</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">75.5</span></span>"] },
468-
], id: 117440513, rootId: 117440512, totalRows: 2 } ) });
468+
], id: -1426063359, rootId: -1426063360, totalRows: 2 } ) });
469469
/*-->*/
470470

471471
/*<!--*/
472472
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"orderId: Int\">orderId</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">103</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">104</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">105</span></span>"] },
473473
{ name: "<span title=\"amount: Double\">amount</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">20.0</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">30.0</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">25.0</span></span>"] },
474-
], id: 117440514, rootId: 117440512, totalRows: 3 } ) });
474+
], id: -1426063358, rootId: -1426063360, totalRows: 3 } ) });
475475
/*-->*/
476476

477-
call_DataFrame(function() { DataFrame.renderTable(117440512) });
477+
call_DataFrame(function() { DataFrame.renderTable(-1426063360) });
478478

479-
function sendHeight() {
479+
function sendHeight() {
480480
const table = document.querySelector('table.dataframe');
481481
if (!table) return;
482482

483+
let height = 0;
484+
483485
const thead = table.querySelector('thead');
484-
const tbody = table.querySelector('tbody');
485-
if (!thead || !tbody || tbody.children.length === 0) return;
486+
if (thead) height += thead.offsetHeight;
487+
488+
const rows = table.querySelectorAll(':scope > tbody > tr');
489+
rows.forEach(row => {
490+
height += row.offsetHeight;
491+
});
492+
493+
height += getVerticalMargins(table) + 10;
486494

487-
let height = thead.offsetHeight;
488-
const rows = tbody.querySelectorAll('tr');
489-
for (let i = 0; i < Math.min(rows.length, 5); i++) {
490-
height += rows[i].offsetHeight;
491-
}
492-
493-
const margin = parseFloat(getComputedStyle(table).marginTop) +
494-
parseFloat(getComputedStyle(table).marginBottom);
495-
496-
const totalHeight = Math.ceil(height + margin + 10);
495+
window.parent.postMessage({ type: 'iframeHeight', height: Math.ceil(height) }, '*');
496+
}
497497

498-
window.parent.postMessage({ type: 'iframeHeight', height: totalHeight }, '*');
498+
function getVerticalMargins(element) {
499+
const style = getComputedStyle(element);
500+
return parseFloat(style.marginTop) + parseFloat(style.marginBottom);
499501
}
500502

501503
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
@@ -509,12 +511,13 @@
509511

510512
window.addEventListener('load', repeatHeightCalculation);
511513

512-
const observer = new MutationObserver(sendHeight);
514+
const observer = new MutationObserver(() => repeatHeightCalculation(5, 50));
513515
observer.observe(document.querySelector('.dataframe'), {
514516
childList: true,
515517
subtree: true,
516-
characterData: true
518+
characterData: true,
517519
});
518520

521+
519522
</script>
520523
</html>

docs/StardustDocs/resources/api/rename/notebook_test_rename_3.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
</style>
178178
</head>
179179
<body>
180-
<table class="dataframe" id="df_-922746880"></table>
180+
<table class="dataframe" id="df_-1426063357"></table>
181181

182182
<p class="dataframe_description"></p>
183183
</body>
@@ -460,31 +460,33 @@
460460
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"ColumnA: Int\">ColumnA</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">1</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">2</span></span>"] },
461461
{ name: "<span title=\"column_b: String\">column_b</span>", children: [], rightAlign: false, values: ["a","b"] },
462462
{ name: "<span title=\"COLUMN-C: Boolean\">COLUMN-C</span>", children: [], rightAlign: false, values: ["true","false"] },
463-
], id: -922746880, rootId: -922746880, totalRows: 2 } ) });
463+
], id: -1426063357, rootId: -1426063357, totalRows: 2 } ) });
464464
/*-->*/
465465

466-
call_DataFrame(function() { DataFrame.renderTable(-922746880) });
466+
call_DataFrame(function() { DataFrame.renderTable(-1426063357) });
467467

468-
function sendHeight() {
468+
function sendHeight() {
469469
const table = document.querySelector('table.dataframe');
470470
if (!table) return;
471471

472+
let height = 0;
473+
472474
const thead = table.querySelector('thead');
473-
const tbody = table.querySelector('tbody');
474-
if (!thead || !tbody || tbody.children.length === 0) return;
475+
if (thead) height += thead.offsetHeight;
476+
477+
const rows = table.querySelectorAll(':scope > tbody > tr');
478+
rows.forEach(row => {
479+
height += row.offsetHeight;
480+
});
481+
482+
height += getVerticalMargins(table) + 10;
475483

476-
let height = thead.offsetHeight;
477-
const rows = tbody.querySelectorAll('tr');
478-
for (let i = 0; i < Math.min(rows.length, 5); i++) {
479-
height += rows[i].offsetHeight;
480-
}
481-
482-
const margin = parseFloat(getComputedStyle(table).marginTop) +
483-
parseFloat(getComputedStyle(table).marginBottom);
484-
485-
const totalHeight = Math.ceil(height + margin + 10);
484+
window.parent.postMessage({ type: 'iframeHeight', height: Math.ceil(height) }, '*');
485+
}
486486

487-
window.parent.postMessage({ type: 'iframeHeight', height: totalHeight }, '*');
487+
function getVerticalMargins(element) {
488+
const style = getComputedStyle(element);
489+
return parseFloat(style.marginTop) + parseFloat(style.marginBottom);
488490
}
489491

490492
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
@@ -498,12 +500,13 @@
498500

499501
window.addEventListener('load', repeatHeightCalculation);
500502

501-
const observer = new MutationObserver(sendHeight);
503+
const observer = new MutationObserver(() => repeatHeightCalculation(5, 50));
502504
observer.observe(document.querySelector('.dataframe'), {
503505
childList: true,
504506
subtree: true,
505-
characterData: true
507+
characterData: true,
506508
});
507509

510+
508511
</script>
509512
</html>

docs/StardustDocs/resources/api/rename/notebook_test_rename_4.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
</style>
178178
</head>
179179
<body>
180-
<table class="dataframe" id="df_-922746879"></table>
180+
<table class="dataframe" id="df_-1426063356"></table>
181181

182182
<p class="dataframe_description"></p>
183183
</body>
@@ -460,31 +460,33 @@
460460
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"columnA: Int\">columnA</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">1</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">2</span></span>"] },
461461
{ name: "<span title=\"column_b: String\">column_b</span>", children: [], rightAlign: false, values: ["a","b"] },
462462
{ name: "<span title=\"columnC: Boolean\">columnC</span>", children: [], rightAlign: false, values: ["true","false"] },
463-
], id: -922746879, rootId: -922746879, totalRows: 2 } ) });
463+
], id: -1426063356, rootId: -1426063356, totalRows: 2 } ) });
464464
/*-->*/
465465

466-
call_DataFrame(function() { DataFrame.renderTable(-922746879) });
466+
call_DataFrame(function() { DataFrame.renderTable(-1426063356) });
467467

468-
function sendHeight() {
468+
function sendHeight() {
469469
const table = document.querySelector('table.dataframe');
470470
if (!table) return;
471471

472+
let height = 0;
473+
472474
const thead = table.querySelector('thead');
473-
const tbody = table.querySelector('tbody');
474-
if (!thead || !tbody || tbody.children.length === 0) return;
475+
if (thead) height += thead.offsetHeight;
476+
477+
const rows = table.querySelectorAll(':scope > tbody > tr');
478+
rows.forEach(row => {
479+
height += row.offsetHeight;
480+
});
481+
482+
height += getVerticalMargins(table) + 10;
475483

476-
let height = thead.offsetHeight;
477-
const rows = tbody.querySelectorAll('tr');
478-
for (let i = 0; i < Math.min(rows.length, 5); i++) {
479-
height += rows[i].offsetHeight;
480-
}
481-
482-
const margin = parseFloat(getComputedStyle(table).marginTop) +
483-
parseFloat(getComputedStyle(table).marginBottom);
484-
485-
const totalHeight = Math.ceil(height + margin + 10);
484+
window.parent.postMessage({ type: 'iframeHeight', height: Math.ceil(height) }, '*');
485+
}
486486

487-
window.parent.postMessage({ type: 'iframeHeight', height: totalHeight }, '*');
487+
function getVerticalMargins(element) {
488+
const style = getComputedStyle(element);
489+
return parseFloat(style.marginTop) + parseFloat(style.marginBottom);
488490
}
489491

490492
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
@@ -498,12 +500,13 @@
498500

499501
window.addEventListener('load', repeatHeightCalculation);
500502

501-
const observer = new MutationObserver(sendHeight);
503+
const observer = new MutationObserver(() => repeatHeightCalculation(5, 50));
502504
observer.observe(document.querySelector('.dataframe'), {
503505
childList: true,
504506
subtree: true,
505-
characterData: true
507+
characterData: true,
506508
});
507509

510+
508511
</script>
509512
</html>

docs/StardustDocs/resources/api/rename/notebook_test_rename_5.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
</style>
178178
</head>
179179
<body>
180-
<table class="dataframe" id="df_-922746878"></table>
180+
<table class="dataframe" id="df_-1426063355"></table>
181181

182182
<p class="dataframe_description"></p>
183183
</body>
@@ -460,31 +460,33 @@
460460
call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: "<span title=\"columnA: Int\">columnA</span>", children: [], rightAlign: true, values: ["<span class=\"formatted\" title=\"\"><span class=\"numbers\">1</span></span>","<span class=\"formatted\" title=\"\"><span class=\"numbers\">2</span></span>"] },
461461
{ name: "<span title=\"columnB: String\">columnB</span>", children: [], rightAlign: false, values: ["a","b"] },
462462
{ name: "<span title=\"columnC: Boolean\">columnC</span>", children: [], rightAlign: false, values: ["true","false"] },
463-
], id: -922746878, rootId: -922746878, totalRows: 2 } ) });
463+
], id: -1426063355, rootId: -1426063355, totalRows: 2 } ) });
464464
/*-->*/
465465

466-
call_DataFrame(function() { DataFrame.renderTable(-922746878) });
466+
call_DataFrame(function() { DataFrame.renderTable(-1426063355) });
467467

468-
function sendHeight() {
468+
function sendHeight() {
469469
const table = document.querySelector('table.dataframe');
470470
if (!table) return;
471471

472+
let height = 0;
473+
472474
const thead = table.querySelector('thead');
473-
const tbody = table.querySelector('tbody');
474-
if (!thead || !tbody || tbody.children.length === 0) return;
475+
if (thead) height += thead.offsetHeight;
476+
477+
const rows = table.querySelectorAll(':scope > tbody > tr');
478+
rows.forEach(row => {
479+
height += row.offsetHeight;
480+
});
481+
482+
height += getVerticalMargins(table) + 10;
475483

476-
let height = thead.offsetHeight;
477-
const rows = tbody.querySelectorAll('tr');
478-
for (let i = 0; i < Math.min(rows.length, 5); i++) {
479-
height += rows[i].offsetHeight;
480-
}
481-
482-
const margin = parseFloat(getComputedStyle(table).marginTop) +
483-
parseFloat(getComputedStyle(table).marginBottom);
484-
485-
const totalHeight = Math.ceil(height + margin + 10);
484+
window.parent.postMessage({ type: 'iframeHeight', height: Math.ceil(height) }, '*');
485+
}
486486

487-
window.parent.postMessage({ type: 'iframeHeight', height: totalHeight }, '*');
487+
function getVerticalMargins(element) {
488+
const style = getComputedStyle(element);
489+
return parseFloat(style.marginTop) + parseFloat(style.marginBottom);
488490
}
489491

490492
function repeatHeightCalculation(maxRetries = 10, interval = 100) {
@@ -498,12 +500,13 @@
498500

499501
window.addEventListener('load', repeatHeightCalculation);
500502

501-
const observer = new MutationObserver(sendHeight);
503+
const observer = new MutationObserver(() => repeatHeightCalculation(5, 50));
502504
observer.observe(document.querySelector('.dataframe'), {
503505
childList: true,
504506
subtree: true,
505-
characterData: true
507+
characterData: true,
506508
});
507509

510+
508511
</script>
509512
</html>

0 commit comments

Comments
 (0)