Convert date_range_picker.js to TypeScript (issue #17)

- Add ts/date_range_picker.ts: typed port. CalendarState interface (with the
  dynamically-assigned refreshFromField) and an Anchor union replace the loose
  state object; date helpers and DOM queries fully typed; var → const/let
- Replace the DOMContentLoaded + per-element guard-flag + window global with
  onSwap("[data-date-range-picker]", ...), the documented init pattern — so the
  picker now also initializes inside htmx-swapped fragments. Drops the dead
  window.initDateRangePickers export
- Point the DateRangePicker component Media at dist/date_range_picker.js and load
  it as an ES module in the e2e page (was a deferred classic script)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-19 13:52:48 +02:00
parent c809341064
commit 19e9fd1419
4 changed files with 173 additions and 164 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ class RealComponentMediaTest(unittest.TestCase):
media = collect_media(
DateRangePicker(label="Played", input_name_prefix="played")
)
self.assertEqual(media.js, ("date_range_picker.js",))
self.assertEqual(media.js, ("dist/date_range_picker.js",))
def test_range_slider_declares_its_script(self):
from common.components.filters import RangeSlider