mirror of
https://github.com/tabler/tabler.git
synced 2026-08-29 13:21:29 +04:00
Render Modal as real markup; drain scripts via CaptureScript (#2742)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
+19
-19
@@ -1,6 +1,6 @@
|
||||
---
|
||||
// Port of ui/range.html. With an id → a noUiSlider div + init script, rendered
|
||||
// directly here; without an id → a native <input type=range>.
|
||||
// With an id → a noUiSlider div + init script; without an id → a native <input type=range>.
|
||||
import CaptureScript from '../components/CaptureScript.astro';
|
||||
interface Props {
|
||||
min?: number;
|
||||
max?: number;
|
||||
@@ -18,7 +18,7 @@ const size = values.length;
|
||||
const numericValues = values.map(Number);
|
||||
const startValue = size > 1 ? numericValues : numericValues[0];
|
||||
|
||||
// connect array: {% for i in (2..size) %}cycle false,true{% endfor %} then true, false
|
||||
// Connect array: alternate false/true for mid segments, then true, false.
|
||||
let connectValue;
|
||||
if (size > 1 || connect) {
|
||||
const parts: boolean[] = [];
|
||||
@@ -38,22 +38,22 @@ const rangeId = `range-${id}`;
|
||||
}
|
||||
{
|
||||
id && (
|
||||
<Fragment>
|
||||
<Fragment set:html={'<!-- BEGIN RANGE -->'} />
|
||||
<script define:vars={{ rangeId, startValue, connectValue, step, min, max }}>
|
||||
function initRange() {
|
||||
window.noUiSlider &&
|
||||
noUiSlider.create(document.getElementById(rangeId), {
|
||||
start: startValue,
|
||||
...(connectValue ? { connect: connectValue } : {}),
|
||||
step,
|
||||
range: { min, max },
|
||||
});
|
||||
}
|
||||
<CaptureScript>
|
||||
<!-- BEGIN RANGE -->
|
||||
<script define:vars={{ rangeId, startValue, connectValue, step, min, max }}>
|
||||
function initRange() {
|
||||
window.noUiSlider &&
|
||||
noUiSlider.create(document.getElementById(rangeId), {
|
||||
start: startValue,
|
||||
...(connectValue ? { connect: connectValue } : {}),
|
||||
step,
|
||||
range: { min, max },
|
||||
});
|
||||
}
|
||||
|
||||
document.readyState !== 'loading' ? initRange() : document.addEventListener('DOMContentLoaded', initRange, { once: true });
|
||||
</script>
|
||||
<Fragment set:html={'<!-- END RANGE -->'} />
|
||||
</Fragment>
|
||||
document.readyState !== 'loading' ? initRange() : document.addEventListener('DOMContentLoaded', initRange, { once: true });
|
||||
</script>
|
||||
<!-- END RANGE -->
|
||||
</CaptureScript>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user