Skip to content
bahtuiv0.6.0

<baht-datepicker>

Calendar picker (flatpickr, reskinned on the tokens: tinted header band, round day cells, Today / Clear footer; never the OS date wheel). Value is ISO yyyy-mm-dd — one string, a [start, end] range or a string[] by date_mode. min/max, disabled_dates and disabled_weekdays grey days out (and grey out Today) and the engine enforces them on validate.

Basic

<baht-datepicker></baht-datepicker>

<script>
  const el = document.querySelector('baht-datepicker');
  el.field = {
    "order": 1,
    "type": "date",
    "key": "dob",
    "label": "Date of birth",
    "max": "2026-12-31"
  };
  el.value = "1995-01-15";
</script>

Range

<baht-datepicker></baht-datepicker>

<script>
  const el = document.querySelector('baht-datepicker');
  el.field = {
    "order": 1,
    "type": "date",
    "key": "trip",
    "label": "Trip dates",
    "date_mode": "range",
    "date_format": "d M Y",
    "help": "Value is [start, end]"
  };
  el.value = [
    "2026-10-05",
    "2026-10-09"
  ];
</script>

Weekends + holidays off

<baht-datepicker></baht-datepicker>

<script>
  const el = document.querySelector('baht-datepicker');
  el.field = {
    "order": 1,
    "type": "date",
    "key": "appointment",
    "label": "Appointment",
    "min": "2026-04-01",
    "max": "2026-04-30",
    "disabled_weekdays": [
      0,
      6
    ],
    "disabled_dates": [
      "2026-04-06",
      "2026-04-13/2026-04-15"
    ],
    "help": "Mon–Fri, minus Chakri Day and Songkran"
  };
  el.value = null;
</script>

Multiple days

<baht-datepicker></baht-datepicker>

<script>
  const el = document.querySelector('baht-datepicker');
  el.field = {
    "order": 1,
    "type": "date",
    "key": "shifts",
    "label": "Shift days",
    "date_mode": "multiple"
  };
  el.value = [
    "2026-09-14",
    "2026-09-16",
    "2026-09-18"
  ];
</script>
NameTypeDefaultDescription
fieldJSFieldDescriptorField spec: { order, type, key, label?, placeholder?, options?, … }
valueJSunknownnullControlled value. Re-feed on every baht-input
disabledbooleanfalseDisable the control
readonlybooleanfalseRead-only
requiredbooleanfalseShow required mark
show-optionalbooleanfalseAppend the localized "(optional)" marker to the label when not required (set by <baht-form show-optional>).
errorJSstring | nullnullValidation message to display
debouncenumber | undefinedDebounce for typed edits (ms); unset = BahtFieldBase.defaultDebounce.
field.date_mode'single' | 'range' | 'multiple'Value shape: string | [start, end] | string[] (default single).
field.date_formatstringDisplay format in flatpickr tokens ('d/m/Y', 'j M Y'). Value stays ISO.
field.min / field.maxstringISO bounds of the calendar (also validated).
field.disabled_datesstring[]ISO days or inclusive intervals 'yyyy-mm-dd/yyyy-mm-dd' that cannot be picked.
field.disabled_weekdaysnumber[]0 = Sunday … 6 = Saturday.
EventdetailDescription
nameCustomEvent
baht-input{ key, value }Fired on every user edit