@keenmate/web-daterangepicker 1.13.0 → 1.14.0-rc02

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.
Files changed (42) hide show
  1. package/README.md +149 -928
  2. package/component-variables.manifest.json +380 -271
  3. package/dist/date-picker-interaction.d.ts +22 -0
  4. package/dist/date-picker-locales.d.ts +24 -0
  5. package/dist/date-picker-navigation.d.ts +70 -0
  6. package/dist/date-picker-rendering.d.ts +95 -0
  7. package/dist/date-picker-selection.d.ts +76 -0
  8. package/dist/date-picker-ui.d.ts +39 -0
  9. package/dist/date-picker-validation.d.ts +65 -0
  10. package/dist/date-picker.d.ts +371 -0
  11. package/dist/index.d.ts +31 -0
  12. package/dist/logger.d.ts +39 -0
  13. package/dist/modules/click-events/index.d.ts +39 -0
  14. package/dist/modules/index.d.ts +2 -0
  15. package/dist/modules/scroll-events/index.d.ts +27 -0
  16. package/dist/style.css +1 -1
  17. package/dist/tooltip.d.ts +42 -0
  18. package/dist/types.d.ts +537 -0
  19. package/dist/web-component.d.ts +206 -0
  20. package/dist/web-daterangepicker.js +3225 -2377
  21. package/dist/web-daterangepicker.umd.js +89 -33
  22. package/package.json +6 -6
  23. package/src/css/animations.css +15 -0
  24. package/src/css/{_badges.css → badges.css} +7 -7
  25. package/src/css/base.css +185 -0
  26. package/src/css/{_calendar-grid.css → calendar-grid.css} +77 -54
  27. package/src/css/clock-picker.css +222 -0
  28. package/src/css/compact-picker.css +141 -0
  29. package/src/css/controls.css +122 -0
  30. package/src/css/dark-mode.css +60 -0
  31. package/src/css/{_tooltips.css → floating.css} +35 -37
  32. package/src/css/{_header-navigation.css → header-navigation.css} +55 -55
  33. package/src/css/{_loading.css → loading.css} +4 -13
  34. package/src/css/main.css +41 -27
  35. package/src/css/{_message.css → message.css} +15 -15
  36. package/src/css/{_modal.css → modal.css} +28 -28
  37. package/src/css/{_modifiers.css → states.css} +19 -15
  38. package/src/css/{_summary-actions.css → summary-actions.css} +19 -18
  39. package/src/css/time-picker.css +180 -0
  40. package/src/css/{_variables.css → variables.css} +228 -31
  41. package/src/css/wheel-picker.css +195 -0
  42. package/src/css/_base.css +0 -285
package/README.md CHANGED
@@ -1,43 +1,100 @@
1
1
  # Date Range Picker Web Component
2
2
 
3
- A lightweight, accessible date picker web component with excellent keyboard navigation and range selection support.
3
+ A lightweight, framework-agnostic date picker that ships as a single
4
+ custom element. Keyboard-first navigation, single / range / multiple
5
+ selection modes, optional time + datetime modes, and OS-aware dark
6
+ mode out of the box.
7
+
8
+ > **⚠️ Security Notice:** This component intentionally allows raw HTML
9
+ > in rendering callbacks and message content to give developers full
10
+ > control over content display. If you display user-generated content,
11
+ > you must sanitize it yourself. See [HTML Injection (XSS) Notice](#html-injection-xss-notice)
12
+ > for the complete list of affected callbacks and methods.
13
+
14
+ ## What is it
15
+
16
+ `@keenmate/web-daterangepicker` is a date picker that runs as a Web
17
+ Component — drop the `<web-daterangepicker>` element into any HTML
18
+ page (or any framework that speaks DOM: React, Vue, Svelte, Angular,
19
+ plain HTML) and it works. No JavaScript framework integration to
20
+ build. No virtualized rendering. No copy-pasted theme tokens to keep
21
+ in sync.
22
+
23
+ It covers the full date-picker matrix in one component: **single date**
24
+ or **date range** selection; **single / range / multiple** modes;
25
+ **date**, **time**, or **datetime** picker modes with four time-display
26
+ UIs (rolls, Material clock face, iOS wheel, iOS compact pills);
27
+ **multi-month** grids; **input masking** with progressive auto-format
28
+ as the user types; **drag-to-adjust** for range endpoints; **disabled
29
+ dates** with five different range-traversal strategies; **special
30
+ dates** with badges, tooltips, and `dayClass` / `badgeClass`
31
+ discriminator hooks; **localized** week start, month names, and labels;
32
+ and **async validation** via `beforeDateSelectCallback` with optional
33
+ bulk metadata loading per month.
34
+
35
+ What makes it different from the rest of the date-picker ecosystem:
36
+
37
+ - **No JavaScript dark-mode detection.** The picker reacts to five
38
+ separate CSS-only signals (OS `prefers-color-scheme`, page-level
39
+ `color-scheme`, framework class on an ancestor, per-instance
40
+ `data-theme` attribute, explicit `light` override) via `light-dark()`
41
+ and `:host-context(...)` selectors. Set whichever your page already
42
+ uses; it flips automatically.
43
+ - **Theme Designer integration.** Optional. If you use the KeenMate
44
+ Theme Designer at [theme-designer.keenmate.dev](https://theme-designer.keenmate.dev),
45
+ the picker reads the cross-component `--base-*` taxonomy so one
46
+ theme drives every KeenMate component on the page.
47
+ - **One component, every selection shape.** Date / range / multiple /
48
+ time / datetime in one custom element with one consistent API —
49
+ switch by changing one attribute, not by installing a different
50
+ package.
51
+ - **First-class keyboard.** Arrow keys, Home / End, Ctrl+Home / End,
52
+ Tab between month columns, `T` to jump to today. Modal mode blurs
53
+ the input so the mobile soft-keyboard collapses.
54
+
55
+ For a more honest accessibility audit including current ARIA gaps,
56
+ see [`docs/accessibility.md`](./docs/accessibility.md).
57
+
58
+ ## What's new
59
+
60
+ **v1.14.0-rc02** (latest) — BlissFramework guidelines alignment +
61
+ sibling-picker overlap fix. See [`CHANGELOG.md`](./CHANGELOG.md) for
62
+ the full migration table and history.
63
+
64
+ ## Demos & docs
65
+
66
+ - 🚀 [Live demo](https://web-daterangepicker.keenmate.dev)
67
+ - 📘 [Usage / API reference](./docs/usage.md)
68
+ - 🎨 [Theming contract](./docs/theming.md)
69
+ - 📚 [Examples / cookbook](./docs/examples.md)
70
+ - ♿ [Accessibility](./docs/accessibility.md)
71
+
72
+ ## Install
4
73
 
5
- > **⚠️ Security Notice:** This component intentionally allows raw HTML in rendering callbacks and message content to give developers full control over content display. If you display user-generated content, you must sanitize it yourself. See [HTML Injection (XSS) Notice](#html-injection-xss-notice) for the complete list of affected callbacks and methods.
6
-
7
- ## Features
8
-
9
- - 🎯 **Input Masking** - Auto-format dates as you type with separator insertion
10
- - ⌨️ **Keyboard Navigation** - Full keyboard support (arrows, Enter, Esc, PageUp/Down, Home/End)
11
- - 📅 **Rolling Selector** - Innovative scrollable year/month picker
12
- - 📊 **Multi-Month Display** - Show 1-3+ months side by side with independent navigation
13
- - 🎨 **Themeable** - All styles use CSS custom properties (`--drp-*`)
14
- - 🖱️ **Drag-to-Adjust** - Drag range endpoints to adjust selection (range mode)
15
- - 👀 **Live Hover Preview** - See the would-be range painted live as you move toward an end date (range mode, mode-aware per `disabled-dates-handling`)
16
- - 🌐 **Multiple Formats** - YYYY-MM-DD, DD.MM.YYYY, MM/DD/YYYY, etc.
17
- - 🌍 **Locale-Aware** - Auto-detect week start day from user's locale
18
- - 🚫 **Date Restrictions** - Min/max dates, disabled days/dates, custom disable logic
19
- - 🎉 **Special Dates** - Highlight holidays, events with custom labels and styling
20
- - ✨ **Modern** - Web Component with Shadow DOM, TypeScript, bundled with Vite
74
+ ```bash
75
+ npm install @keenmate/web-daterangepicker
76
+ ```
21
77
 
22
- ## Installation
78
+ `rc` releases are tagged separately — install with `@rc` or pin the
79
+ exact version:
23
80
 
24
81
  ```bash
25
- npm install @keenmate/web-daterangepicker
82
+ npm install @keenmate/web-daterangepicker@rc
26
83
  ```
27
84
 
28
- ## Usage
85
+ ## Quick start
29
86
 
30
87
  ### Basic HTML
31
88
 
32
89
  ```html
33
- <!-- Single date picker -->
90
+ <!-- Single date -->
34
91
  <web-daterangepicker
35
92
  selection-mode="single"
36
93
  date-format-mask="YYYY-MM-DD"
37
94
  placeholder="Select date"
38
95
  ></web-daterangepicker>
39
96
 
40
- <!-- Date range picker -->
97
+ <!-- Date range -->
41
98
  <web-daterangepicker
42
99
  selection-mode="range"
43
100
  date-format-mask="YYYY-MM-DD"
@@ -46,15 +103,12 @@ npm install @keenmate/web-daterangepicker
46
103
  ></web-daterangepicker>
47
104
  ```
48
105
 
49
- ### With JavaScript/TypeScript
106
+ ### With JavaScript / TypeScript
50
107
 
51
- ```typescript
52
- // Import the component (includes styles)
108
+ ```ts
109
+ // Import the component (registers <web-daterangepicker> + injects styles)
53
110
  import '@keenmate/web-daterangepicker';
54
111
 
55
- // Or import styles separately if needed
56
- import '@keenmate/web-daterangepicker/style.css';
57
-
58
112
  const picker = document.querySelector('web-daterangepicker');
59
113
 
60
114
  // Listen for date selection
@@ -65,916 +119,45 @@ picker.addEventListener('date-select', (e) => {
65
119
  });
66
120
 
67
121
  // Programmatic API
68
- picker.show(); // Show calendar
69
- picker.hide(); // Hide calendar
70
- picker.toggle(); // Toggle calendar
71
- picker.clearSelection(); // Clear selection
72
- picker.getInputValue(); // Get current value
73
- picker.setInputValue('2025-11-15'); // Set value
74
- ```
75
-
76
- ### JavaScript Instantiation (Direct Class Usage)
77
-
78
- If you prefer to use the `DateRangePicker` class directly instead of the web component, you have full programmatic control:
79
-
80
- ```typescript
81
- import { DateRangePicker } from '@keenmate/web-daterangepicker';
82
- // IMPORTANT: Import CSS separately (web component auto-injects, but the class doesn't)
83
- import '@keenmate/web-daterangepicker/dist/style.css';
84
-
85
- const inputElement = document.getElementById('my-input');
86
-
87
- const picker = new DateRangePicker(inputElement, {
88
- selectionMode: 'range',
89
- visibleMonthsCount: 2,
90
- dateFormatMask: 'YYYY-MM-DD',
91
- onSelect: (detail) => {
92
- // Range mode: detail is { start: Date, end: Date }
93
- console.log('Range:', detail.start, 'to', detail.end);
94
- }
95
- });
96
- ```
97
-
98
- **⚠️ Critical: CSS Requirements**
99
-
100
- Unlike the web component, the `DateRangePicker` class does **NOT** automatically inject styles. You **MUST** import CSS separately or you'll see an unstyled calendar. Choose one method:
101
-
102
- **Option 1: Import CSS in JavaScript (Recommended)**
103
- ```typescript
104
- import { DateRangePicker } from '@keenmate/web-daterangepicker';
105
- import '@keenmate/web-daterangepicker/dist/style.css';
106
- ```
107
-
108
- **Option 2: Link CSS in HTML**
109
- ```html
110
- <link rel="stylesheet" href="./node_modules/@keenmate/web-daterangepicker/dist/style.css">
111
- ```
112
-
113
- **Option 3: Programmatic Injection**
114
- ```typescript
115
- import { DateRangePicker } from '@keenmate/web-daterangepicker';
116
-
117
- // Inject styles once before creating pickers
118
- DateRangePicker.injectGlobalStyles();
119
-
120
- const picker = new DateRangePicker(inputElement, options);
121
- ```
122
-
123
- **Why?** The web component uses Shadow DOM and injects styles into its isolated scope automatically. The `DateRangePicker` class creates calendar elements in the regular DOM, so it expects global CSS to be loaded separately.
124
-
125
- See the [JavaScript Instantiation Examples](examples-javascript-instantiation.html) for complete code samples and configuration options.
126
-
127
- ## Attributes
128
-
129
- > **Note:** HTML attributes use kebab-case (e.g., `selection-mode`), while JavaScript options use camelCase (e.g., `selectionMode`).
130
-
131
- | Attribute | Type | Default | Description |
132
- |-----------|------|---------|-------------|
133
- | `selection-mode` | `'single' \| 'range'` | `'single'` | Single date or date range selection |
134
- | `date-format-mask` | `string` | `'YYYY-MM-DD'` | Date format (YYYY-MM-DD, DD.MM.YYYY, MM/DD/YYYY, etc.) |
135
- | `visible-months-count` | `number` | `1` (single), `2` (range) | Number of months to display |
136
- | `calendar-open-trigger` | `'focus' \| 'typing' \| 'manual'` | `'focus'` | How to open calendar (focus = on input focus, typing = when user types, manual = programmatic only) |
137
- | `value` | `string` | - | Current value |
138
- | `placeholder` | `string` | - | Input placeholder text |
139
- | `disabled` | `boolean` | `false` | Disable the picker |
140
- | `week-start-day` | `'auto' \| 0-6` | `'auto'` | First day of week (0=Sunday, 1=Monday, etc. 'auto'=detect from locale) |
141
- | `min-date` | `string` | - | Minimum selectable date (YYYY-MM-DD) |
142
- | `max-date` | `string` | - | Maximum selectable date (YYYY-MM-DD) |
143
- | `disabled-weekdays` | `string` | - | Comma-separated day numbers to disable (e.g., "0,6" for weekends) |
144
- | `disabled-dates` | `string` | - | Comma-separated ISO dates to disable (e.g., `"2026-06-13, 2026-06-14, 2026-12-25"`). The `disabledDates` property still wins if both paths are set. |
145
- | `disabled-dates-handling` | `'allow' \| 'prevent' \| 'block' \| 'split' \| 'individual'` | `'allow'` | How to handle range selections over disabled dates (see [Range Selection Modes](#range-selection-modes)) |
146
- | `display-format-mask` | `string` | Same as `date-format-mask` | Localized format hint shown to users (e.g., `'dd/mm/aaaa'` Spanish, `'tt.mm.jjjj'` German). Used as the input placeholder when no explicit `placeholder` is set. Validation still uses `date-format-mask`. |
147
- | `highlight-disabled-in-range` | `boolean` | `true` | Whether to visually highlight disabled dates within a selected range. Set to `false` to only highlight enabled dates. |
148
- | `auto-close` | `'never' \| 'selection' \| 'apply'` | `'selection'` | When to close calendar (selection = after picking, apply = after Apply button, never = manual) |
149
- | `positioning-mode` | `'inline' \| 'floating' \| 'modal'` | `'floating'` | Calendar positioning (inline = embedded, floating = popup anchored to input, modal = centered overlay with backdrop) |
150
- | `mobile-modal-breakpoint` | CSS length (e.g., `"640px"`, `"40em"`) | — | When configured mode is `floating`, auto-switch to `modal` below this viewport width. |
151
- | `mobile-modal-min-height` | CSS length | — | Same idea but for viewport height — modal engages when viewport height is below the threshold. ORs with `mobile-modal-breakpoint`. |
152
- | `show-summary` | `boolean` | `true` | Show range-mode days/nights summary block. Set to `false` to omit entirely (no empty-div jump). |
153
- | `input-size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Input field size (floating/modal modes only) |
154
- | `enable-transitions` | `boolean` | `false` | Enable CSS transitions/animations |
155
- | `date-member` | `string` | `'date'` | Field name on `specialDates` objects holding the date. Lets you reuse existing data shapes without renaming keys. |
156
- | `badge-text-member` | `string` | `'badgeText'` | Field name on `specialDates` objects holding the badge label. |
157
- | `badge-class-member` | `string` | `'badgeClass'` | Field name on `specialDates` objects holding the badge's extra CSS class. |
158
- | `day-class-member` | `string` | `'dayClass'` | Field name on `specialDates` objects holding the day cell's extra CSS class. |
159
- | `badge-tooltip-member` | `string` | `'badgeTooltip'` | Field name on `specialDates` objects holding the badge tooltip text. |
160
- | `day-tooltip-member` | `string` | `'dayTooltip'` | Field name on `specialDates` objects holding the day tooltip text. |
161
- | `is-disabled-member` | `string` | `'isDisabled'` | Field name on `specialDates` objects holding the disabled flag. |
162
-
163
- ## Properties
164
-
165
- ```typescript
166
- // Get/set properties (use camelCase in JavaScript)
167
- picker.selectionMode = 'range';
168
- picker.dateFormatMask = 'DD.MM.YYYY';
169
- picker.value = '2025-11-15';
170
- picker.disabled = true;
171
-
172
- // Complex data (arrays / objects / callbacks) — set via property, not attribute
173
- picker.disabledDates = ['2026-06-13', '2026-06-14'];
174
- picker.specialDates = [{ date: '2026-12-25', badgeText: '🎄', badgeTooltip: 'Christmas' }];
175
-
176
- // Localization overrides
177
- picker.customStrings = { today: 'Jump', clear: 'Wipe' };
178
- picker.monthNames = ['01','02','03','04','05','06','07','08','09','10','11','12'];
179
- ```
180
-
181
- > Property setters work even before the element is upgraded — assignments made before `customElements.define()` runs are routed through the accessors during `connectedCallback`, so you don't need `customElements.whenDefined('web-daterangepicker')` guards.
182
-
183
- ## Methods
184
-
185
- | Method | Description |
186
- |--------|-------------|
187
- | `show()` | Show the calendar (floating mode only) |
188
- | `hide()` | Hide the calendar |
189
- | `toggle()` | Toggle calendar visibility |
190
- | `clearSelection()` | Clear the current selection |
191
- | `getInputValue()` | Get the current value as a string |
192
- | `setInputValue(value: string)` | Set the value |
193
- | `showMessage(html: string)` | Display a message in the calendar with custom HTML content |
194
- | `hideMessage()` | Hide the currently displayed message |
195
-
196
- ## Events
197
-
198
- | Event | Detail | Description |
199
- |-------|--------|-------------|
200
- | `date-select` | `{ date?, dateRange?, formattedValue }` | Fired when a date is selected |
201
- | `change` | `{ date?, dateRange?, formattedValue }` | Fired when selection changes |
202
- | `custom-action` | `{ [key: string]: string }` | Fired when a button with `data-action="custom"` is clicked. Detail contains all `data-*` attributes as camelCase keys. |
203
-
204
- > There are no separate `apply` or `cancel` events. The Apply button commits the pending selection and dispatches `change`. Pressing Escape with an uncommitted selection silently restores the input value and fires nothing.
205
-
206
- ## Keyboard Shortcuts
207
-
208
- - **↑ ↓** - Navigate up/down by week
209
- - **← →** - Navigate left/right by day
210
- - **Ctrl+← / Ctrl+→** - Previous / next month (maintains day position)
211
- - **PageUp / PageDown** - Previous / next month (maintains day position)
212
- - **Home** - First day of current month (repeat to cycle backwards through months)
213
- - **End** - Last day of current month (repeat to cycle forwards through months)
214
- - **Ctrl+Home** - January 1st of current year (repeat for previous year)
215
- - **Ctrl+End** - December 31st of current year (repeat for next year)
216
- - **Enter** - Select focused day
217
- - **Escape** - Close calendar
218
- - **Tab / Shift+Tab** - Switch between month columns (multi-month mode)
219
- - **T** - Jump to today
220
-
221
- ## ⚠️ Working with Dates Across Timezones
222
-
223
- This is a **calendar-date picker** — it represents days, not moments in time. Skipping this section will eventually cost you a one-day-shift bug, so please read it.
224
-
225
- ### How the picker represents dates
226
-
227
- When the user clicks April 30, the picker stores `new Date(year, month - 1, day)` — that's **local midnight** on the picked day. The same is true for `selectedDate`, `selectedStartDate`, `selectedEndDate`, and the Date passed to every callback. There's no UTC anywhere in the picker's internal lookup paths.
228
-
229
- ### The trap: `Date.prototype.toISOString()`
230
-
231
- `toISOString()` returns the date in **UTC**. For any user not in UTC, that string represents a different *calendar* day than the one they see:
232
-
233
- ```js
234
- // User in Moscow (UTC+3) picks April 30.
235
- // selectedDate is `new Date(2026, 3, 30)` = April 30 00:00 MSK = April 29 21:00 UTC.
236
-
237
- selectedDate.toISOString().split('T')[0] // → "2026-04-29" ❌ wrong day
238
- selectedDate.getDate() // → 30 ✅ what the user clicked
239
- ```
240
-
241
- This is what broke the example demos in earlier versions: lookup keys built from `dayOffset()` (local) didn't match keys derived from `toISOString()` (UTC). Badges rendered one day late, tooltips on the right day. Same bug strikes any user who tries `date.toISOString()` to key into a `Map<string, DateInfo>`.
242
-
243
- ### The rule
244
-
245
- **Format dates from local components, never from `toISOString()`:**
246
-
247
- ```js
248
- const toLocalISO = (d) =>
249
- `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
250
-
251
- picker.getDateMetadataCallback = (date) => {
252
- const dateStr = toLocalISO(date); // ✅ matches what the user sees
253
- // …lookup, return DateInfo…
254
- };
255
- ```
256
-
257
- ### Sending dates to a server / between users
258
-
259
- `Date` objects can't survive transport — they get serialized. The serialization format determines whether the date stays on the right calendar day across timezones:
260
-
261
- | What you send | Russian user picks Apr 30 → LA user receives | Verdict |
262
- |---|---|---|
263
- | `event.detail.formattedValue` (`"2026-04-30"`) | `"2026-04-30"` → set on LA picker → April 30 | ✅ |
264
- | `JSON.stringify(detail)` (Date → ISO string) | `"2026-04-29T21:00:00.000Z"` → April 29 in LA | ❌ |
265
- | `selectedDate.toISOString()` | `"2026-04-29T21:00:00.000Z"` → April 29 in LA | ❌ |
266
- | `toLocalISO(selectedDate)` (`"2026-04-30"`) | `"2026-04-30"` | ✅ |
267
-
268
- **Recommendation:** transmit calendar dates as `YYYY-MM-DD` **strings**, never as ISO timestamps or raw `Date`/JSON-serialized payloads.
269
-
270
- ### Receiving a date string
271
-
272
- `new Date("2026-04-30")` parses as **UTC midnight** — surprising for non-UTC users (in LA it'd be April 29). Build local Dates from the string parts:
273
-
274
- ```js
275
- // ❌ Don't do this
276
- const d = new Date("2026-04-30"); // UTC midnight, surprising in non-UTC
277
-
278
- // ✅ Do this
279
- const [y, m, day] = "2026-04-30".split("-").map(Number);
280
- const localDate = new Date(y, m - 1, day); // April 30 local — what the user picked
281
-
282
- // Or, if you just need to set the picker:
283
- picker.setInputValue("2026-04-30"); // picker handles parsing internally
284
- picker.value = "2026-04-30"; // attribute setter
285
- ```
286
-
287
- ### Quick checklist
288
-
289
- - [ ] Picker callbacks: format Dates with `toLocalISO()`, not `toISOString()`
290
- - [ ] Outgoing dates (server, URL, localStorage): send `YYYY-MM-DD` strings
291
- - [ ] Incoming dates: prefer `picker.setInputValue("YYYY-MM-DD")` over manual `new Date(...)` parsing
292
- - [ ] Map/dictionary keys for date lookups: build keys with `toLocalISO()` and lookup the same way
293
-
294
- ## Advanced Features
295
-
296
- ### Week Start Day
297
-
298
- Control which day the week starts on (auto-detected by default from user's locale):
299
-
300
- ```html
301
- <!-- Auto-detect from locale (default) -->
302
- <web-daterangepicker week-start-day="auto"></web-daterangepicker>
303
-
304
- <!-- Force Sunday start -->
305
- <web-daterangepicker week-start-day="0"></web-daterangepicker>
306
-
307
- <!-- Force Monday start (common in Europe) -->
308
- <web-daterangepicker week-start-day="1"></web-daterangepicker>
309
- ```
310
-
311
- ### Disabled Dates & Date Restrictions
312
-
313
- #### Simple Restrictions (Attributes)
314
-
315
- ```html
316
- <!-- Disable weekends -->
317
- <web-daterangepicker disabled-weekdays="0,6"></web-daterangepicker>
318
-
319
- <!-- Date range restriction -->
320
- <web-daterangepicker
321
- min-date="2025-01-01"
322
- max-date="2025-12-31">
323
- </web-daterangepicker>
324
- ```
325
-
326
- #### Complex Restrictions (JavaScript)
327
-
328
- ```javascript
329
- const picker = document.querySelector('web-daterangepicker');
330
-
331
- // Disable specific dates (e.g., public holidays)
332
- picker.disabledDates = [
333
- '2025-12-25', // Christmas
334
- '2025-01-01', // New Year
335
- new Date(2025, 6, 4) // July 4th
336
- ];
337
-
338
- // Custom disable logic (e.g., cottage booking)
339
- picker.getDateMetadataCallback = (date) => {
340
- // Disable all dates that overlap with existing bookings
341
- const isBooked = bookedRanges.some(range =>
342
- date >= range.start && date <= range.end
343
- );
344
- return isBooked ? { isDisabled: true } : null;
345
- };
346
- ```
347
-
348
- ### Special Dates (Holidays, Events)
349
-
350
- Add visual indicators and labels to specific dates:
351
-
352
- ```javascript
353
- const picker = document.querySelector('web-daterangepicker');
354
-
355
- picker.specialDates = [
356
- {
357
- date: '2025-12-25',
358
- dayClass: 'holiday', // CSS class for the day cell
359
- badgeText: '🎄', // Badge overlay (emoji or short text)
360
- dayTooltip: 'Christmas Day'
361
- },
362
- {
363
- date: '2025-07-04',
364
- dayClass: 'holiday',
365
- badgeText: '🎆',
366
- dayTooltip: 'Independence Day'
367
- },
368
- {
369
- date: '2025-02-14',
370
- dayClass: 'event',
371
- badgeText: '❤️',
372
- dayTooltip: 'Valentine\'s Day'
373
- }
374
- ];
375
- ```
376
-
377
- ### Advanced Styling & Info
378
-
379
- For complete control, use the `getDateMetadataCallback`:
380
-
381
- ```javascript
382
- // Local-date formatter — see "Working with Dates Across Timezones" above.
383
- // Don't use date.toISOString() here; it shifts by one day in non-UTC timezones.
384
- const toLocalISO = (d) =>
385
- `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
386
-
387
- picker.getDateMetadataCallback = (date) => {
388
- const dateStr = toLocalISO(date);
389
-
390
- // Check if it's a peak season date
391
- if (isPeakSeason(date)) {
392
- return {
393
- dayClass: 'peak-season',
394
- badgeText: '$$$',
395
- dayTooltip: 'Peak season pricing'
396
- };
397
- }
398
-
399
- // Check if it's a special offer date
400
- if (specialOffers[dateStr]) {
401
- return {
402
- dayClass: 'special-offer',
403
- badgeText: '%',
404
- dayTooltip: `${specialOffers[dateStr]}% off!`
405
- };
406
- }
407
-
408
- return null;
409
- };
410
- ```
411
-
412
- ### CSS Styling for Special Dates
413
-
414
- Since the component uses Shadow DOM, inject custom styles via the `customStylesCallback`:
415
-
416
- ```javascript
417
- picker.customStylesCallback = () => `
418
- /* Holiday styling */
419
- .drp-date-picker__day.holiday {
420
- background-color: rgba(239, 68, 68, 0.1);
421
- }
422
-
423
- /* Event styling */
424
- .drp-date-picker__day.event {
425
- background-color: rgba(16, 185, 129, 0.1);
426
- }
427
-
428
- /* Custom class example */
429
- .drp-date-picker__day.peak-season {
430
- background-color: rgba(251, 191, 36, 0.15);
431
- font-weight: 600;
432
- }
433
- `;
434
- ```
435
-
436
- ### Date Selection Validation (beforeDateSelectCallback)
437
-
438
- Validate or modify date selections before they're applied. Supports async validation (e.g., API calls):
439
-
440
- ```javascript
441
- const picker = document.querySelector('web-daterangepicker');
442
-
443
- picker.beforeDateSelectCallback = async (selection) => {
444
- // selection is Date (single mode) or { start: Date, end: Date } (range mode)
445
-
446
- // Example: Check availability via API.
447
- // Send YYYY-MM-DD strings, not toISOString() — the picker is a calendar-date
448
- // picker, and ISO timestamps shift by ±1 day across timezones.
449
- const response = await fetch('/api/check-availability', {
450
- method: 'POST',
451
- body: JSON.stringify({
452
- start: toLocalISO(selection.start),
453
- end: toLocalISO(selection.end)
454
- })
455
- });
456
- const { available, message } = await response.json();
457
-
458
- if (!available) {
459
- return {
460
- action: 'restore',
461
- message: message,
462
- showInvalidRange: true // Keep selection visible with error styling
463
- };
464
- }
465
-
466
- return { action: 'accept' };
467
- };
468
- ```
469
-
470
- **Return object options:**
471
-
472
- | Property | Type | Description |
473
- |----------|------|-------------|
474
- | `action` | `'accept' \| 'adjust' \| 'restore' \| 'clear'` | **Required.** What to do with the selection |
475
- | `message` | `string` | Optional message to display in the calendar |
476
- | `showInvalidRange` | `boolean` | When `true` with `action: 'restore'`, keeps the invalid selection visible with red error styling |
477
- | `adjustedDate` | `Date` | For `action: 'adjust'` in single mode - the corrected date |
478
- | `adjustedStartDate` | `Date` | For `action: 'adjust'` in range mode - the corrected start date |
479
- | `adjustedEndDate` | `Date` | For `action: 'adjust'` in range mode - the corrected end date |
480
-
481
- **Action behaviors:**
482
-
483
- - **`accept`**: Apply the selection as-is. Hides any existing message.
484
- - **`adjust`**: Apply corrected dates instead (use with `adjustedDate` or `adjustedStartDate`/`adjustedEndDate`)
485
- - **`restore`**: Revert to previous selection. Use `showInvalidRange: true` to show what was attempted.
486
- - **`clear`**: Clear the selection entirely.
487
-
488
- **Example: Minimum nights validation with error display:**
489
-
490
- ```javascript
491
- picker.beforeDateSelectCallback = (range) => {
492
- const nights = Math.floor((range.end - range.start) / (1000 * 60 * 60 * 24));
493
-
494
- if (nights < 2) {
495
- return {
496
- action: 'restore',
497
- message: 'Minimum 2 nights required',
498
- showInvalidRange: true // Shows attempted range with red styling
499
- };
500
- }
501
-
502
- if (nights > 14) {
503
- return {
504
- action: 'restore',
505
- message: 'Maximum 14 nights allowed',
506
- showInvalidRange: true
507
- };
508
- }
509
-
510
- return { action: 'accept' };
511
- };
512
- ```
513
-
514
- ### Bulk Metadata Loading (beforeMonthChangedCallback)
515
-
516
- Load metadata for all visible dates in a single API call when the user navigates months. Much more efficient than `getDateMetadataCallback` which is called per-date:
517
-
518
- ```javascript
519
- const picker = document.querySelector('web-daterangepicker');
520
-
521
- picker.beforeMonthChangedCallback = async (context) => {
522
- // context: { year, month, monthIndex, firstVisibleDate, lastVisibleDate }
523
-
524
- // Fetch availability for all visible dates in one call.
525
- // Use toLocalISO (see "Working with Dates Across Timezones") so the
526
- // server receives the calendar dates the user actually sees.
527
- const response = await fetch('/api/availability', {
528
- method: 'POST',
529
- body: JSON.stringify({
530
- start: toLocalISO(context.firstVisibleDate),
531
- end: toLocalISO(context.lastVisibleDate)
532
- })
533
- });
534
- const data = await response.json();
535
-
536
- // Build metadata map (key: YYYY-MM-DD, value: DateInfo)
537
- const metadata = new Map();
538
- data.forEach(day => {
539
- metadata.set(day.date, {
540
- badgeText: `$${day.price}`,
541
- isDisabled: !day.available,
542
- dayTooltip: `${day.roomsLeft} rooms available`
543
- });
544
- });
545
-
546
- return { action: 'accept', metadata };
547
- };
548
- ```
549
-
550
- **Return object options:**
551
-
552
- | Property | Type | Description |
553
- |----------|------|-------------|
554
- | `action` | `'accept' \| 'block'` | **Required.** Allow or prevent month navigation |
555
- | `metadata` | `Map<string, DateInfo>` | Bulk metadata keyed by `YYYY-MM-DD`. Cached and used instead of `getDateMetadataCallback` |
556
- | `monthHeaders` | `Map<string, string>` | Custom month headers keyed by `YYYY-MM` (e.g., `"2026-01"` → `"Jan 2026 (5 rooms)"`) |
557
- | `message` | `string` | Optional message to display (useful with `action: 'block'`) |
558
-
559
- **Performance:** 1 API call per month navigation vs 35-42 calls with `getDateMetadataCallback`.
560
-
561
- ### Messages & Custom Actions
562
-
563
- Display contextual messages in the calendar with interactive buttons:
564
-
565
- ```javascript
566
- const picker = document.querySelector('web-daterangepicker');
567
-
568
- // Show a simple message
569
- picker.showMessage('<p>Please select a check-in date</p>');
570
-
571
- // Show a message with a close button
572
- picker.showMessage(`
573
- <p>Weekend dates have higher rates</p>
574
- <button data-action="close-message">Got it</button>
575
- `);
576
-
577
- // Show a message with custom action buttons
578
- picker.showMessage(`
579
- <p>These dates are unavailable. Try:</p>
580
- <button data-action="custom" data-start-date="2026-01-14" data-end-date="2026-01-17">
581
- Jan 14 - Jan 17
582
- </button>
583
- `);
584
-
585
- // Handle custom action button clicks
586
- picker.addEventListener('custom-action', (e) => {
587
- const { startDate, endDate } = e.detail;
588
- if (startDate && endDate) {
589
- picker.selectedRanges = [{
590
- start: new Date(startDate),
591
- end: new Date(endDate)
592
- }];
593
- picker.hideMessage();
594
- }
595
- });
596
-
597
- // Hide message programmatically
598
- picker.hideMessage();
599
- ```
600
-
601
- **Built-in button actions:**
602
- - `data-action="close-message"` - Closes the message (no event fired)
603
- - `data-action="custom"` - Fires `custom-action` event with all `data-*` attributes
604
-
605
- ## Range Selection Modes
606
-
607
- When selecting date ranges that include disabled dates (e.g., selecting a working week where weekends are disabled), you can control how the selection is handled using the `disabled-dates-handling` attribute:
608
-
609
- ### Mode: 'allow' (default)
610
-
611
- Allows range selections over disabled dates. Returns both enabled and disabled date arrays:
612
-
613
- ```html
614
- <web-daterangepicker
615
- selection-mode="range"
616
- disabled-weekdays="0,6"
617
- disabled-dates-handling="allow">
618
- </web-daterangepicker>
619
-
620
- <script>
621
- picker.addEventListener('date-select', (e) => {
622
- console.log('Enabled dates:', e.detail.enabledDates);
623
- console.log('Disabled dates:', e.detail.disabledDates);
624
- console.log('Total days:', e.detail.getTotalDays());
625
- console.log('Enabled count:', e.detail.getEnabledDateCount());
626
- });
627
- </script>
628
- ```
629
-
630
- **Use case:** Selecting working weeks where you need to know both working days and weekends (e.g., "Select 3 weeks of work" where weekends are included in the range but you get a separate array of working days).
631
-
632
- ### Mode: 'prevent'
633
-
634
- Prevents selecting disabled dates entirely. Clicking a disabled date does nothing:
635
-
636
- ```html
637
- <web-daterangepicker
638
- selection-mode="range"
639
- disabled-dates-handling="prevent">
640
- </web-daterangepicker>
641
- ```
642
-
643
- **Use case:** Strict date selection where disabled dates should never be part of any selection.
644
-
645
- ### Mode: 'block'
646
-
647
- Prevents range selections from crossing disabled dates. Automatically snaps to the last enabled date before the gap:
648
-
649
- ```html
650
- <web-daterangepicker
651
- selection-mode="range"
652
- disabled-dates-handling="block">
653
- </web-daterangepicker>
654
- ```
655
-
656
- When dragging from day 1 to day 7 with days 4-5 disabled, the selection will automatically snap to days 1-3.
657
-
658
- **Use case:** Cottage booking where you can't book across existing reservations, or any scenario where gaps in the range are not allowed.
659
-
660
- ### Mode: 'split'
661
-
662
- Returns multiple date ranges separated by disabled dates:
663
-
664
- ```html
665
- <web-daterangepicker
666
- selection-mode="range"
667
- disabled-weekdays="0,6"
668
- disabled-dates-handling="split">
669
- </web-daterangepicker>
670
-
671
- <script>
672
- picker.addEventListener('date-select', (e) => {
673
- console.log('Ranges:', e.detail.dateRanges);
674
- // e.g., [{start: Mon, end: Fri}, {start: Mon, end: Fri}, {start: Mon, end: Fri}]
675
- console.log('Formatted:', e.detail.formattedValue);
676
- // "2025-11-03 - 2025-11-07, 2025-11-10 - 2025-11-14, 2025-11-17 - 2025-11-21"
677
- });
678
- </script>
679
- ```
680
-
681
- **Use case:** Reporting or analytics where you need distinct time periods (e.g., "Generate report for these 3 work weeks").
682
-
683
- ### Mode: 'individual'
684
-
685
- Returns a flat array of individual enabled dates:
686
-
687
- ```html
688
- <web-daterangepicker
689
- selection-mode="range"
690
- disabled-weekdays="0,6"
691
- disabled-dates-handling="individual">
692
- </web-daterangepicker>
693
-
694
- <script>
695
- picker.addEventListener('date-select', (e) => {
696
- console.log('Individual dates:', e.detail.dates);
697
- // [Date(Mon), Date(Tue), Date(Wed), Date(Thu), Date(Fri), Date(Mon), ...]
698
- console.log('Formatted:', e.detail.formattedValue);
699
- // "2025-11-03, 2025-11-04, 2025-11-05, 2025-11-06, 2025-11-07, ..."
700
- });
701
- </script>
702
- ```
703
-
704
- **Use case:** Scheduling or event planning where you need a list of specific dates (e.g., "Schedule training sessions on these dates").
705
-
706
- ### Event Detail Structure by Mode
707
-
708
- | Mode | Properties | Description |
709
- |------|-----------|-------------|
710
- | `allow` | `dateRange`, `enabledDates`, `disabledDates`, `getTotalDays()`, `getEnabledDateCount()` | Full range with helper methods |
711
- | `prevent` | `dateRange`, `dates` | Only enabled dates can be selected |
712
- | `block` | `dateRange`, `dates` | Single continuous range (no disabled dates) |
713
- | `split` | `dateRanges`, `dates` | Multiple ranges split by disabled dates |
714
- | `individual` | `dates` | Flat array of enabled dates |
715
-
716
- ### Visual Highlighting Control
717
-
718
- By default, when you select a range that includes disabled dates, all dates (both enabled and disabled) within the range are visually highlighted. You can change this behavior with the `highlight-disabled-in-range` attribute:
719
-
720
- ```html
721
- <!-- Default: highlights all dates in range, including disabled weekends -->
722
- <web-daterangepicker
723
- selection-mode="range"
724
- disabled-weekdays="0,6"
725
- disabled-dates-handling="split">
726
- </web-daterangepicker>
727
-
728
- <!-- Only highlight enabled dates (Mon-Fri), skip weekends -->
729
- <web-daterangepicker
730
- selection-mode="range"
731
- disabled-weekdays="0,6"
732
- disabled-dates-handling="split"
733
- highlight-disabled-in-range="false">
734
- </web-daterangepicker>
735
- ```
736
-
737
- **When to use `highlight-disabled-in-range="false"`:**
738
- - Selecting working weeks where you only want to see Monday-Friday highlighted
739
- - Visual clarity when disabled dates are not relevant to the selection
740
- - Any scenario where showing gaps in the range is clearer than showing continuous highlighting
741
-
742
- ## Theming
743
-
744
- ### Theme Designer
745
-
746
- The easiest way to customize the appearance of this component is using the **KeenMate Theme Designer** at:
747
-
748
- **[theme-designer.keenmate.dev](https://theme-designer.keenmate.dev)**
749
-
750
- #### How It Works
751
-
752
- 1. **Choose 3 base colors** - background, text, and accent
753
- 2. **Preview changes live** - see your theme applied instantly
754
- 3. **Fine-tune individual variables** - lock specific values while adjusting others
755
- 4. **Export your theme** - copy CSS, JSON, or SCSS to your project
756
-
757
- #### CSS Variable Layers
758
-
759
- KeenMate components support a **two-layer theming architecture**:
760
-
761
- **Standalone Mode (Simple)** - Just override the component-specific variables you need:
762
-
763
- ```css
764
- :root {
765
- --drp-accent-color: #your-brand-color;
766
- --drp-primary-bg: #your-background;
767
- --drp-text-primary: #your-text-color;
768
- }
769
- ```
770
-
771
- **Cascading Mode (Multi-Component)** - When using multiple KeenMate components, you can define a shared base layer:
772
-
773
- ```css
774
- :root {
775
- /* Base layer - single source of truth */
776
- --base-accent-color: #3b82f6;
777
- --base-primary-bg: #ffffff;
778
- --base-text-primary: #111827;
779
-
780
- /* Components reference base layer */
781
- --ms-accent-color: var(--base-accent-color);
782
- --drp-accent-color: var(--base-accent-color);
783
- }
784
- ```
785
-
786
- Change `--base-accent-color` once → all components update automatically.
787
-
788
- #### Unified Variable Naming
789
-
790
- All KeenMate components follow a consistent naming convention for **Tier 1 variables** (core theming):
791
-
792
- | Purpose | web-multiselect | web-daterangepicker |
793
- |---------|-----------------|---------------------|
794
- | Brand color | `--ms-accent-color` | `--drp-accent-color` |
795
- | Background | `--ms-primary-bg` | `--drp-primary-bg` |
796
- | Text color | `--ms-text-primary` | `--drp-text-primary` |
797
- | Text on accent | `--ms-text-on-accent` | `--drp-text-on-accent` |
798
- | Border color | `--ms-border-color` | `--drp-border-color` |
799
-
800
- Learn the pattern once, apply it across all components.
801
-
802
- #### Component Variables Manifest
803
-
804
- This package exports a `component-variables.manifest.json` file that documents all supported CSS variables for tooling integration (e.g., Theme Designer, IDE autocomplete):
805
-
806
- ```javascript
807
- import manifest from '@keenmate/web-daterangepicker/component-variables.manifest.json';
808
- // manifest.baseVariables - list of --base-* variables the component responds to
809
- // manifest.componentVariables - list of --drp-* component-specific variables
810
- ```
811
-
812
- ### CSS Custom Properties
813
-
814
- Customize the appearance using CSS custom properties:
815
-
816
- ```css
817
- :root {
818
- /* Base Unit - scale entire component by changing this */
819
- --drp-rem: 10px; /* Default base unit (change to scale everything) */
820
-
821
- /* Colors */
822
- --drp-dropdown-background: #ffffff;
823
- --drp-border-color: #e5e7eb;
824
- --drp-primary-bg: #f3f4f6;
825
- --drp-primary-bg-hover: #e5e7eb;
826
- --drp-accent-color: #3b82f6;
827
- --drp-accent-color-hover: #2563eb;
828
- --drp-text-primary: #111827;
829
- --drp-text-secondary: #6b7280;
830
- --drp-text-on-accent: #ffffff;
831
-
832
- /* Input Field */
833
- --drp-input-background: var(--drp-dropdown-background);
834
- --drp-input-color: var(--drp-text-primary);
835
- --drp-input-border: var(--base-input-border, var(--drp-border));
836
- --drp-input-border-hover: var(--base-input-border-hover, var(--drp-border-width-base) solid var(--drp-accent-color));
837
- --drp-input-border-focus: var(--base-input-border-focus, var(--drp-border-width-base) solid var(--drp-accent-color));
838
- --drp-input-placeholder-color: var(--drp-text-secondary);
839
-
840
- /* Typography (all scale with --drp-rem) */
841
- --drp-font-size-xs: calc(1.2 * var(--drp-rem)); /* 12px */
842
- --drp-font-size-sm: calc(1.4 * var(--drp-rem)); /* 14px */
843
- --drp-font-size-base: calc(1.6 * var(--drp-rem)); /* 16px */
844
- --drp-font-weight-medium: 500;
845
- --drp-font-weight-semibold: 600;
846
-
847
- /* Spacing (all scale with --drp-rem) */
848
- --drp-spacing-xs: calc(0.4 * var(--drp-rem)); /* 4px */
849
- --drp-spacing-sm: calc(0.8 * var(--drp-rem)); /* 8px */
850
- --drp-spacing-md: calc(1.6 * var(--drp-rem)); /* 16px */
851
-
852
- /* Borders */
853
- --drp-border-width-base: 1px;
854
- --drp-border-radius-sm: calc(var(--base-border-radius-sm, 0.4) * var(--drp-rem)); /* 4px - day cells, tooltips */
855
- --drp-border-radius-md: calc(var(--base-border-radius-md, 0.6) * var(--drp-rem)); /* 6px - inputs, buttons */
856
- --drp-border-radius-lg: calc(var(--base-border-radius-lg, 0.8) * var(--drp-rem)); /* 8px - calendar, dropdowns */
857
- --drp-border-radius: var(--drp-border-radius-md); /* default alias */
858
-
859
- /* Shadows */
860
- --drp-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
861
-
862
- /* Transitions */
863
- --drp-transition-fast: 150ms;
864
- --drp-easing-snappy: cubic-bezier(0.4, 0.0, 0.2, 1);
865
- }
122
+ picker.show();
123
+ picker.hide();
124
+ picker.toggle();
125
+ picker.clearSelection();
126
+ picker.setInputValue('2025-11-15');
866
127
  ```
867
128
 
868
- ### Input Size Scale
869
-
870
- The component uses a 10px-based sizing system (`--drp-rem: 10px`) for clean, predictable dimensions:
871
-
872
- | Size | Attribute | Height | Base Variable |
873
- |------|-----------|--------|---------------|
874
- | XS | `input-size="xs"` | 31px | `--base-input-size-xs-height` |
875
- | SM | `input-size="sm"` | 33px | `--base-input-size-sm-height` |
876
- | MD | `input-size="md"` | 35px (default) | `--base-input-size-md-height` |
877
- | LG | `input-size="lg"` | 38px | `--base-input-size-lg-height` |
878
- | XL | `input-size="xl"` | 41px | `--base-input-size-xl-height` |
879
-
880
- **Theme Designer Integration**: Input heights reference `--base-input-size-*-height` variables from the [Theme Designer](https://theme-designer.keenmate.dev). This ensures consistent input heights across all KeenMate components (web-multiselect, web-daterangepicker).
881
-
882
- For complete size variable reference (font sizes, padding, spacing), see [SIZES.md](SIZES.md).
883
-
884
- #### Customizing Input Heights
885
-
886
- Four ways to customize input dimensions:
887
-
888
- ```css
889
- /* Option 1: Via Theme Designer base variables (recommended for multi-component consistency) */
890
- :root {
891
- --base-input-size-md-height: 4.2; /* All components: 42px at 10px rem */
892
- }
129
+ Using the `DateRangePicker` class directly (without the custom
130
+ element) is fully supported — see [`docs/usage.md`](./docs/usage.md#javascript-instantiation-datepickerangepicker-class)
131
+ for the CSS-loading caveats.
893
132
 
894
- /* Option 2: Direct px override */
895
- web-daterangepicker {
896
- --drp-input-size-md-height: 42px;
897
- }
133
+ ## Browser support
898
134
 
899
- /* Option 3: Scale all sizes via --drp-rem */
900
- web-daterangepicker {
901
- --drp-rem: 12px; /* MD = 3.5 × 12 = 42px */
902
- }
135
+ Modern browsers with Web Components and CSS `color-mix()` support:
903
136
 
904
- /* Option 4: Override specific size with calc */
905
- web-daterangepicker {
906
- --drp-input-size-md-height: calc(4.2 * var(--drp-rem));
907
- }
908
- ```
909
-
910
- ### Calendar Scaling
911
-
912
- Scale the entire calendar by setting `--drp-rem` directly on the `<web-daterangepicker>` element:
913
-
914
- ```css
915
- /* Compact size (80%) */
916
- web-daterangepicker.compact {
917
- --drp-rem: 8px;
918
- }
919
-
920
- /* Large size (150%) */
921
- web-daterangepicker.large {
922
- --drp-rem: 15px;
923
- }
924
-
925
- /* Or use inline style */
926
- <web-daterangepicker style="--drp-rem: 12px;"></web-daterangepicker>
927
- ```
928
-
929
- **Important:** Due to Shadow DOM, CSS variables must be set on the `<web-daterangepicker>` element itself (via class or inline style), not on a wrapper div.
930
-
931
- For fine-grained control, override individual variables:
932
-
933
- ```css
934
- web-daterangepicker.custom {
935
- --drp-rem: 12px;
936
- --drp-spacing-xs: 2px; /* Tighter gaps */
937
- --drp-font-size-base: 18px; /* Larger text */
938
- }
939
- ```
940
-
941
- See [examples-sizes.html](examples-sizes.html) for interactive demos.
942
-
943
- ## Development
944
-
945
- ```bash
946
- # Install dependencies
947
- npm install
948
-
949
- # Start dev server
950
- npm run dev
951
-
952
- # Build for production
953
- npm run build
954
-
955
- # Preview production build
956
- npm run preview
957
- ```
958
-
959
- ## Browser Support
960
-
961
- - Modern browsers with Web Components and CSS `color-mix()` support
962
- - Chrome/Edge 111+
137
+ - Chrome / Edge 111+
963
138
  - Firefox 113+
964
139
  - Safari 16.2+
965
140
 
966
- For older browser support, use the compiled `dist/style.css` which is processed by Vite.
141
+ ## Built with BlissFramework
142
+
143
+ Follows the [BlissFramework component guidelines](https://blissframework.dev/)
144
+ for structure, theming, color-scheme, and accessibility. See
145
+ [`VALIDATION-NOTES.md`](./VALIDATION-NOTES.md) for the accepted-deviation
146
+ register and [`docs/theming.md`](./docs/theming.md) for the four-contract
147
+ theming model.
967
148
 
968
149
  ## HTML Injection (XSS) Notice
969
150
 
970
- The following callbacks and methods allow **raw HTML injection** and are intentionally **NOT XSS-safe**. This gives developers full control over rendering but requires sanitizing untrusted data:
151
+ The following callbacks and methods allow **raw HTML injection** and
152
+ are intentionally **not XSS-safe**. This gives developers full control
153
+ over rendering but requires sanitizing untrusted data:
971
154
 
972
- | Callback/Method | Output Used In | Risk Level |
973
- |-----------------|---------------|------------|
155
+ | Callback / Method | Output used in | Risk |
156
+ |---|---|---|
974
157
  | `showMessage(html)` | Message area (innerHTML) | HTML injection |
975
158
  | `renderDayCallback` | Day cells (innerHTML) | HTML injection |
976
159
  | `renderDayContentCallback` | Day cells (innerHTML) | HTML injection |
977
- | `getDateMetadataCallback` (badgeText, dayTooltip) | Badges/tooltips (innerHTML) | HTML injection |
160
+ | `getDateMetadataCallback` (`badgeText`, `dayTooltip`) | Badges / tooltips (innerHTML) | HTML injection |
978
161
  | `formatSummaryCallback` | Summary display (innerHTML) | HTML injection |
979
162
  | `getMonthHeaderCallback` | Month headers (innerHTML) | HTML injection |
980
163
  | `getUnifiedHeaderCallback` | Unified header (innerHTML) | HTML injection |
@@ -982,20 +165,58 @@ The following callbacks and methods allow **raw HTML injection** and are intenti
982
165
  | `actionButtons[].label` | Button labels (innerHTML) | HTML injection |
983
166
 
984
167
  **Safe callbacks** (output is escaped or used as data):
168
+
985
169
  - `beforeDateSelectCallback`, `beforeMonthChangedCallback` (return action objects)
986
170
  - `onSelect`, `onChange` (event handlers)
987
- - `getDateMetadataCallback` (isDisabled, dayClass, badgeClass - CSS class names only)
171
+ - `getDateMetadataCallback` (`isDisabled`, `dayClass`, `badgeClass` CSS class names only)
172
+
173
+ **If displaying user-generated content**, sanitize it before passing
174
+ it to these callbacks or methods.
175
+
176
+ ## Known Limitations
177
+
178
+ ### Consumer-data class convention — `.holiday` / `.event` / `.badge-{count,number,text}`
179
+
180
+ The shipped CSS includes default styles for a small set of class names
181
+ the picker doesn't emit itself — they're applied by your code via the
182
+ `dayClassMember` / `badgeClassMember` callbacks (or the equivalent
183
+ `getDateMetadataCallback` return shape). The component ships compound
184
+ selectors (`.drp__day.holiday`, `.drp__day.event`,
185
+ `.drp__badge-cell.badge-count`, `.drp__badge-cell.badge-number`,
186
+ `.drp__badge-cell.badge-text`) as ready-to-use hooks for these common
187
+ conventions so the most frequent decoration cases work without writing
188
+ any CSS.
189
+
190
+ This means a few CSS classes inside the shadow root don't follow
191
+ strict BEM (`.<prefix>__element--modifier`) — they're consumer-data
192
+ values used as discriminators next to a BEM block, not
193
+ component-emitted modifiers. The BEM block (`.drp__day`,
194
+ `.drp__badge-cell`) carries the component scope; the discriminator
195
+ carries the data convention.
196
+
197
+ If your data uses different class names, just supply them via the
198
+ callback and provide your own CSS — the defaults won't fight you. To
199
+ retheme the existing defaults without rewriting the CSS, override the
200
+ backing variables:
201
+
202
+ - **Holiday cell:** `--drp-holiday-color`, `--drp-holiday-bg-opacity`, `--drp-holiday-hover-bg-opacity`
203
+ - **Event cell:** `--drp-event-color`, `--drp-event-bg-opacity`, `--drp-event-hover-bg-opacity`
204
+ - **Badge types:** `--drp-badge-number-{bg,color}`, `--drp-badge-count-{bg,color}`, `--drp-badge-text-{bg,color}`
988
205
 
989
- **If displaying user-generated content**, sanitize it before passing to these callbacks or methods.
206
+ These variables are part of the public theming surface (added in
207
+ v1.6.0; see [`CHANGELOG.md`](./CHANGELOG.md)).
990
208
 
991
209
  ## Changelog
992
210
 
993
- See [CHANGELOG.md](https://github.com/keenmate/web-daterangepicker/blob/main/CHANGELOG.md) for version history and migration guides.
211
+ See [`CHANGELOG.md`](./CHANGELOG.md) for version history and migration
212
+ guides.
994
213
 
995
214
  ## License
996
215
 
997
- MIT
216
+ MIT — see [LICENSE](./LICENSE) if present, otherwise the MIT terms
217
+ apply by default per `package.json`.
998
218
 
999
219
  ## Credits
1000
220
 
1001
- Extracted from the [Pure Admin](https://github.com/keenmate/pure-admin) design system.
221
+ Extracted from the [Pure Admin](https://github.com/keenmate/pure-admin)
222
+ design system.