@finstack-com-public/design 0.8.0 → 0.9.0
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.
- package/CHANGELOG.md +26 -1
- package/dist/css/calendar.css +102 -8
- package/dist/css/calendar.md +134 -2
- package/dist/css-text/calendar.js +1 -1
- package/dist/css-text/kit.js +102 -8
- package/dist/dom/calendar.d.ts +48 -3
- package/dist/dom/calendar.js +262 -46
- package/dist/dom/index.d.ts +1 -1
- package/dist/kit.css +102 -8
- package/dist/react/inputs.d.ts +27 -9
- package/dist/react/inputs.js +85 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,32 @@
|
|
|
3
3
|
Written by hand for each release. Token names, class names, file paths and exports are the
|
|
4
4
|
public API. While the kit is 0.x, a minor version may break them, and its entry says so.
|
|
5
5
|
|
|
6
|
-
## 0.
|
|
6
|
+
## 0.9.0 — unreleased
|
|
7
|
+
|
|
8
|
+
Nothing breaks. Upgrading from 0.8.0 needs no change.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Date range (T85, D42):** `createCalendar(root, { mode: 'range', value: { start, end }, … })`, at month or day
|
|
13
|
+
granularity. The first pick sets the start, the second the end (swapped if earlier); the cells between preview on
|
|
14
|
+
hover and on keyboard focus; `fs-change` fires with `{ start, end }` only when both are set. Start and end are
|
|
15
|
+
filled like a selected cell, the cells between sit on an accent-wash band, and every cell in the range is
|
|
16
|
+
`aria-selected`. Range mode requires `labels.rangeStart` and `labels.rangeEnd`, which the kit says after the cell's
|
|
17
|
+
name, so the ends are never told by colour alone. See `css/calendar.md`.
|
|
18
|
+
- **Two pages (T85):** `months: 2` shows two months (or two years in a month calendar) side by side, paging together.
|
|
19
|
+
Works in single mode too.
|
|
20
|
+
- **React `DateRangeCalendar` (T85):** `value`/`defaultValue` as `{ start, end }`, `onChange({ start, end })`;
|
|
21
|
+
`Calendar` also takes `months`.
|
|
22
|
+
- **Date-range picker recipe (T85):** one `.fs-input--picker` button showing both ends ("2026. jan. – 2026. márc."),
|
|
23
|
+
the range calendar in a `.fs-popover--fit`. In `css/calendar.md`.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **Calendar in forced colours (I15):** the selected cell no longer sets `Highlight` behind `HighlightText`, which
|
|
28
|
+
Firefox and WebKit painted with the old ink (axe `color-contrast` failed). It is now `CanvasText` on `Canvas`,
|
|
29
|
+
marked by a 2 px `Highlight` edge inside the cell, as the segmented control does.
|
|
30
|
+
|
|
31
|
+
## 0.8.0 — 2026-11-09
|
|
7
32
|
|
|
8
33
|
Nothing breaks: everything here is new. Upgrading from 0.7.1 needs no change.
|
|
9
34
|
|
package/dist/css/calendar.css
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
/* Calendar (spec 02 B): year, month and day views
|
|
2
|
-
which renders the header and the grid into an empty
|
|
1
|
+
/* Calendar (spec 02 B): year, month and day views; one value or a range (T85), one page or two.
|
|
2
|
+
Usage: calendar.md. Behaviour: createCalendar, which renders the header and the grid into an empty
|
|
3
|
+
.fs-calendar (D42). */
|
|
3
4
|
@layer fs.components {
|
|
4
5
|
.fs-calendar {
|
|
5
6
|
/* One cell's width: seven make the calendar, so it follows the density. */
|
|
6
7
|
--fs-calendar-cell: var(--fs-control-h);
|
|
8
|
+
/* Between two pages side by side (months: 2). */
|
|
9
|
+
--fs-calendar-gap: var(--fs-space-4);
|
|
7
10
|
display: inline-flex;
|
|
8
11
|
flex-direction: column;
|
|
9
12
|
gap: var(--fs-space-1);
|
|
@@ -16,12 +19,39 @@
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
.fs-calendar__header {
|
|
22
|
+
position: relative;
|
|
19
23
|
display: flex;
|
|
20
24
|
align-items: center;
|
|
21
25
|
gap: var(--fs-space-1);
|
|
22
26
|
height: var(--fs-control-h);
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/* Two pages side by side (months: 2): twice as wide in every view, so a popover never resizes. The
|
|
30
|
+
higher views' one grid spans both columns. */
|
|
31
|
+
.fs-calendar:has(> .fs-calendar__months) {
|
|
32
|
+
width: calc(14 * var(--fs-calendar-cell) + var(--fs-calendar-gap));
|
|
33
|
+
}
|
|
34
|
+
.fs-calendar__months {
|
|
35
|
+
display: grid;
|
|
36
|
+
grid-template-columns: repeat(2, 1fr);
|
|
37
|
+
column-gap: var(--fs-calendar-gap);
|
|
38
|
+
}
|
|
39
|
+
.fs-calendar__months > .fs-calendar__grid:only-child {
|
|
40
|
+
grid-column: 1 / -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* The second page's heading, over its grid; the view button names the first. Not a control. */
|
|
44
|
+
.fs-calendar__caption {
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset-block: 0;
|
|
47
|
+
inset-inline-start: calc(7 * var(--fs-calendar-cell) + var(--fs-calendar-gap));
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
padding: 0 var(--fs-pad-x);
|
|
51
|
+
font-weight: var(--fs-weight-semibold);
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
}
|
|
54
|
+
|
|
25
55
|
/* Shows the page's heading; steps up a view. In the top view it is the heading alone. */
|
|
26
56
|
.fs-calendar__view {
|
|
27
57
|
display: inline-flex;
|
|
@@ -101,6 +131,9 @@
|
|
|
101
131
|
.fs-calendar__cell[aria-selected='true']:not([aria-disabled='true']):hover {
|
|
102
132
|
background-color: var(--fs-primary-bg-hover);
|
|
103
133
|
}
|
|
134
|
+
.fs-calendar__cell--range[aria-selected='true']:not([aria-disabled='true']):hover {
|
|
135
|
+
background-color: var(--fs-bg-hover);
|
|
136
|
+
}
|
|
104
137
|
}
|
|
105
138
|
.fs-calendar__view:not([aria-disabled='true']):active,
|
|
106
139
|
.fs-calendar__cell:active {
|
|
@@ -127,6 +160,37 @@
|
|
|
127
160
|
border-color: var(--fs-primary-ink);
|
|
128
161
|
}
|
|
129
162
|
|
|
163
|
+
/* A range (T85): start and end are filled as selected; the cells between are a band on the accent
|
|
164
|
+
wash. Each end squares off where it meets the band, and the band's cells are square, so the band
|
|
165
|
+
runs unbroken across a row. Start and end are also in the cells' names (cellLabel's range role). */
|
|
166
|
+
.fs-calendar__cell--range-start {
|
|
167
|
+
border-start-end-radius: 0;
|
|
168
|
+
border-end-end-radius: 0;
|
|
169
|
+
}
|
|
170
|
+
.fs-calendar__cell--range-end {
|
|
171
|
+
border-start-start-radius: 0;
|
|
172
|
+
border-end-start-radius: 0;
|
|
173
|
+
}
|
|
174
|
+
.fs-calendar__cell--range[aria-selected='true'] {
|
|
175
|
+
font-weight: inherit;
|
|
176
|
+
color: var(--fs-ink);
|
|
177
|
+
background-color: var(--fs-accent-wash);
|
|
178
|
+
border-radius: 0;
|
|
179
|
+
}
|
|
180
|
+
.fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {
|
|
181
|
+
border-color: var(--fs-accent);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* The preview, while only the start is picked: from the start to the hovered or focused cell, a
|
|
185
|
+
dashed edge above and below, joined across the row. Not a fill: nothing is picked yet. */
|
|
186
|
+
.fs-calendar__cell--preview::before {
|
|
187
|
+
content: '';
|
|
188
|
+
position: absolute;
|
|
189
|
+
inset: 3px 0;
|
|
190
|
+
border-block: var(--fs-line-width) dashed var(--fs-accent);
|
|
191
|
+
pointer-events: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
130
194
|
/* The ring recipe (D15). The header's own button rings outside; cells touch, so theirs is inside. */
|
|
131
195
|
.fs-calendar__view:focus-visible {
|
|
132
196
|
outline: var(--fs-ring-width) solid var(--fs-ring);
|
|
@@ -152,21 +216,51 @@
|
|
|
152
216
|
cursor: not-allowed;
|
|
153
217
|
}
|
|
154
218
|
|
|
155
|
-
/* Forced colours: washes and fills are erased, so the selected cell
|
|
156
|
-
|
|
219
|
+
/* Forced colours: washes and fills are erased, so the selected cell keeps CanvasText on Canvas (Firefox
|
|
220
|
+
and WebKit repaint the background but keep the ink, so a Highlight pair fails contrast: I15) and is
|
|
221
|
+
marked by a 2px Highlight edge inside the cell, as the segmented control does. Today keeps its edge
|
|
222
|
+
(borders survive, in the system's colour), inset further when the cell is selected too. Disabled is
|
|
223
|
+
GrayText. */
|
|
157
224
|
@media (forced-colors: active) {
|
|
158
225
|
.fs-calendar__cell[aria-selected='true'] {
|
|
159
|
-
color:
|
|
160
|
-
background-color:
|
|
226
|
+
color: CanvasText;
|
|
227
|
+
background-color: Canvas;
|
|
228
|
+
}
|
|
229
|
+
.fs-calendar__cell[aria-selected='true']:not(.fs-calendar__cell--range)::before {
|
|
230
|
+
content: '';
|
|
231
|
+
position: absolute;
|
|
232
|
+
inset: 0;
|
|
233
|
+
border: 2px solid Highlight;
|
|
234
|
+
border-radius: var(--fs-radius-sm);
|
|
235
|
+
pointer-events: none;
|
|
161
236
|
}
|
|
162
237
|
.fs-calendar__cell[aria-current='date']::after {
|
|
163
238
|
border-color: CanvasText;
|
|
164
239
|
}
|
|
165
|
-
.fs-calendar__cell[aria-selected='true'][aria-current='date']::after {
|
|
166
|
-
|
|
240
|
+
.fs-calendar__cell[aria-selected='true'][aria-current='date']:not(.fs-calendar__cell--range)::after {
|
|
241
|
+
inset: 4px;
|
|
242
|
+
border-color: CanvasText;
|
|
167
243
|
}
|
|
168
244
|
.fs-calendar__cell[aria-disabled='true'] {
|
|
169
245
|
color: GrayText;
|
|
170
246
|
}
|
|
247
|
+
/* The band keeps its shape as a Highlight edge above and below; start and end take the edge above. */
|
|
248
|
+
.fs-calendar__cell--range[aria-selected='true'] {
|
|
249
|
+
color: CanvasText;
|
|
250
|
+
background-color: Canvas;
|
|
251
|
+
}
|
|
252
|
+
.fs-calendar__cell--range[aria-selected='true']::before {
|
|
253
|
+
content: '';
|
|
254
|
+
position: absolute;
|
|
255
|
+
inset: 2px 0;
|
|
256
|
+
border-block: var(--fs-line-width) solid Highlight;
|
|
257
|
+
pointer-events: none;
|
|
258
|
+
}
|
|
259
|
+
.fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {
|
|
260
|
+
border-color: CanvasText;
|
|
261
|
+
}
|
|
262
|
+
.fs-calendar__cell--preview::before {
|
|
263
|
+
border-color: Highlight;
|
|
264
|
+
}
|
|
171
265
|
}
|
|
172
266
|
}
|
package/dist/css/calendar.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Spec 02 B. CSS: `css/calendar.css` (the header's previous and next buttons also use
|
|
4
4
|
`css/icon-button.css`, and its live region `.fs-visually-hidden` from `css/utilities.css`). Behaviour: `createCalendar(el, options)`, which renders the content (D42).
|
|
5
|
-
Gallery: `inputs.html` (and `react.html` for the React `Calendar` and
|
|
5
|
+
Gallery: `inputs.html` (and `react.html` for the React `Calendar`, `DateRangeCalendar` and pickers).
|
|
6
|
+
One value, or a range with `mode: 'range'` (below); one page, or two side by side with `months: 2`.
|
|
6
7
|
|
|
7
8
|
You write only the empty root; the helper renders the header and the grid into it, and re-renders
|
|
8
9
|
the grid on every page and view.
|
|
@@ -60,11 +61,14 @@ What it renders (the day view):
|
|
|
60
61
|
|---|---|---|
|
|
61
62
|
| hover, press | — | hover and press washes |
|
|
62
63
|
| focus | the grid's one tab stop (`tabindex="0"`) | the ring, drawn inside: cells touch |
|
|
63
|
-
| selected | `aria-selected="true"` | accent fill, weight 600; forced colours: `Highlight` |
|
|
64
|
+
| selected | `aria-selected="true"` | accent fill, weight 600; forced colours: `CanvasText` on `Canvas` with a 2 px `Highlight` edge inside the cell (I15) |
|
|
64
65
|
| today | `aria-current="date"` | an accent edge inside the cell, not a fill; on the selected cell the edge is white |
|
|
65
66
|
| outside `min`/`max` | `aria-disabled="true"` | disabled ink; reachable by the keyboard, never picked; no opacity |
|
|
66
67
|
| neighbouring months' days | `.fs-calendar__blank` | blank |
|
|
67
68
|
| top view's heading | `aria-disabled="true"` on `__view` | the heading, no chevron, no hover |
|
|
69
|
+
| range start, end (T85) | `aria-selected="true"` + `__cell--range-start` / `__cell--range-end` | filled as selected, square where it meets the band; a one-cell range or a pending start has neither class: a plain selected cell |
|
|
70
|
+
| inside a range | `aria-selected="true"` + `__cell--range` | the band: accent wash, square cells joined across the row, normal weight; forced colours: a `Highlight` edge above and below |
|
|
71
|
+
| preview (start picked, end not yet) | `__cell--preview`, from the start to the hovered cell, else the focused one | a dashed accent edge above and below, no fill; not selected |
|
|
68
72
|
|
|
69
73
|
- **The views:** it opens on the lowest view (`granularity`), on the page of the value, else
|
|
70
74
|
today, held inside `min` and `max`. The view button steps up (day → month → year); picking a
|
|
@@ -100,6 +104,66 @@ What it renders (the day view):
|
|
|
100
104
|
- Don't write the header or the grid yourself, style cells by position, or dim a state with
|
|
101
105
|
opacity.
|
|
102
106
|
|
|
107
|
+
## Date range — `mode: 'range'` (T85)
|
|
108
|
+
|
|
109
|
+
The same helper (D42), with a start and an end. The first pick sets the start, the second the end
|
|
110
|
+
(swapped if it is earlier); `fs-change` fires with `{ start, end }` only then, never on the first
|
|
111
|
+
pick. A third pick starts a new range.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
const range = createCalendar(el, {
|
|
115
|
+
...HU_NAMES, // as above
|
|
116
|
+
labels: { ...HU_NAMES.labels, rangeStart: 'kezdete', rangeEnd: 'vége' }, // required in range mode
|
|
117
|
+
mode: 'range', // fixed at creation
|
|
118
|
+
value: { start: '2026-11-04', end: '2026-11-19' }, // or null; YYYY-MM ends with granularity 'month'
|
|
119
|
+
months: 2, // two months side by side (two years in a month calendar)
|
|
120
|
+
min: '2025-01-01', max: '2027-06-30',
|
|
121
|
+
});
|
|
122
|
+
el.addEventListener('fs-change', (e) => setPeriod(e.detail.start, e.detail.end));
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- **Never colour alone:** the start's and end's names end with `labels.rangeStart` and
|
|
126
|
+
`labels.rangeEnd` (required in range mode; the kit holds no words), after ", ": a one-cell range
|
|
127
|
+
says both. One rule in every view, by where the name lives: a **day**'s `aria-label`
|
|
128
|
+
(`cellLabel`'s text, then the word: "2026. november 4., szerda, kezdete"); a **month** or
|
|
129
|
+
**year** cell, named by its visible text, gets a visually hidden span after the text
|
|
130
|
+
(`jan.<span class="fs-visually-hidden">, kezdete</span>`), so its name still holds the text as whole
|
|
131
|
+
words (WCAG 2.5.3, axe's `label-content-name-mismatch`). `cellLabel` itself never sees the range.
|
|
132
|
+
Every cell in the range is `aria-selected="true"` (the cells inside say nothing more). In the higher
|
|
133
|
+
views the months (and years) the range touches are marked the same way.
|
|
134
|
+
- **Preview:** while only the start is picked, the cells from it to the hovered cell, else to the
|
|
135
|
+
focused cell while the grid has focus, take `__cell--preview` (a class, not a selection; a
|
|
136
|
+
disabled cell previews nothing). The keyboard leads once it moves.
|
|
137
|
+
- **Value in, value out:** `value` is read leniently: ends in either order, a month as a day
|
|
138
|
+
calendar's `end` means its last day, a missing or malformed start means no range. `calendar.value`
|
|
139
|
+
is `{ start, end }` with `end: null` while the second pick is pending, or null. `setValue(range)`
|
|
140
|
+
(no event) drops a pending start, so a picker calls it on each open.
|
|
141
|
+
- `min`/`max` work as for one value: a disabled cell is never a start or an end.
|
|
142
|
+
|
|
143
|
+
**Two pages (`months: 2`, either mode):** the lowest view shows two pages side by side, in a
|
|
144
|
+
`__months` grid; the first is named by the view button's heading, the second by a `__caption`
|
|
145
|
+
heading in the header (not a control), each grid `aria-labelledby` its own. Arrows cross from one
|
|
146
|
+
page to the other without paging; a move past the second page pages both by one. PageUp/PageDown
|
|
147
|
+
and the previous and next buttons page both together, keeping the focus's column; previous and
|
|
148
|
+
next turn off when the page before the first, or after the second, has nothing pickable. The new
|
|
149
|
+
pair is announced as "2026. december – 2027. január". The higher views are one grid, as wide, so a
|
|
150
|
+
popover never resizes; stepping down puts the picked month on the left.
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<div class="fs-calendar__header">
|
|
154
|
+
<button type="button" class="fs-calendar__view"><span class="fs-calendar__heading" id="…-heading">2026. november</span>…</button>
|
|
155
|
+
<span class="fs-calendar__caption" id="…-caption">2026. december</span>
|
|
156
|
+
<button type="button" class="fs-icon-button fs-calendar__prev" aria-label="Előző hónap">…</button>
|
|
157
|
+
<button type="button" class="fs-icon-button fs-calendar__next" aria-label="Következő hónap">…</button>
|
|
158
|
+
</div>
|
|
159
|
+
<div class="fs-calendar__months">
|
|
160
|
+
<div role="grid" class="fs-calendar__grid fs-calendar__grid--day" aria-labelledby="…-heading">…</div>
|
|
161
|
+
<div role="grid" class="fs-calendar__grid fs-calendar__grid--day" aria-labelledby="…-caption">…</div>
|
|
162
|
+
</div>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`--fs-calendar-gap` (`--fs-space-4`) is the gap between the pages.
|
|
166
|
+
|
|
103
167
|
## Date picker — a picker button and a popover (T84)
|
|
104
168
|
|
|
105
169
|
The recipe for a period field (BI App's monthly and daily filters): a `.fs-input--picker` button
|
|
@@ -167,3 +231,71 @@ function PeriodPicker({ value, onChange, min, max }: Props) {
|
|
|
167
231
|
must be blocked.
|
|
168
232
|
- The popover needs a name (`aria-label`, or a title); the button says the value, its label says
|
|
169
233
|
what it is.
|
|
234
|
+
|
|
235
|
+
## Date-range picker — two values on one button (T85)
|
|
236
|
+
|
|
237
|
+
The date-picker recipe with the range calendar: the button shows both ends ("2026. jan. – 2026.
|
|
238
|
+
márc.", "2026. 11. 04. – 2026. 11. 19."); the first pick sets the start and the popover stays open;
|
|
239
|
+
the second pick fires `fs-change` and closes it, focus back on the button. Escape after a first pick
|
|
240
|
+
closes it with the range unchanged; the next open shows that range again (`setValue` drops the
|
|
241
|
+
pending start).
|
|
242
|
+
|
|
243
|
+
```html
|
|
244
|
+
<div class="fs-field">
|
|
245
|
+
<label class="fs-field__label" for="span">Időszak</label>
|
|
246
|
+
<button class="fs-input fs-input--picker" id="span" type="button" aria-haspopup="dialog">2026. 11. 04. – 2026. 11. 19.</button>
|
|
247
|
+
</div>
|
|
248
|
+
<div class="fs-popover fs-popover--fit" id="span-pop" role="dialog" aria-label="Időszak választása" hidden>
|
|
249
|
+
<div class="fs-calendar" id="span-cal"></div>
|
|
250
|
+
</div>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
```js
|
|
254
|
+
let value = { start: '2026-11-04', end: '2026-11-19' };
|
|
255
|
+
const labels = { ...HU_NAMES.labels, rangeStart: 'kezdete', rangeEnd: 'vége' };
|
|
256
|
+
const calendar = createCalendar(calEl, { ...HU_NAMES, labels, mode: 'range', months: 2, value, min, max });
|
|
257
|
+
const pop = createPopover(popEl, { anchor: button, focus: 'none' });
|
|
258
|
+
popEl.addEventListener('fs-open', (e) => {
|
|
259
|
+
if (e.target !== popEl) return;
|
|
260
|
+
calendar.setValue(value); // back to the range, dropping a start left pending by Escape
|
|
261
|
+
calendar.focus(); // on the start
|
|
262
|
+
});
|
|
263
|
+
calEl.addEventListener('fs-change', (e) => {
|
|
264
|
+
value = e.detail; // { start, end }, both set
|
|
265
|
+
button.textContent = `${formatHu(value.start)} – ${formatHu(value.end)}`;
|
|
266
|
+
pop.close();
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
import { DateRangeCalendar, Field, PickerButton, Popover } from '@finstack-com-public/design/react';
|
|
272
|
+
|
|
273
|
+
function SpanPicker({ value, onChange, min, max }: Props) {
|
|
274
|
+
const button = useRef<HTMLButtonElement>(null);
|
|
275
|
+
const [open, setOpen] = useState(false);
|
|
276
|
+
const [opened, setOpened] = useState(0);
|
|
277
|
+
return (
|
|
278
|
+
<>
|
|
279
|
+
<Field label="Időszak">
|
|
280
|
+
{(c) => <PickerButton {...c} ref={button} aria-haspopup="dialog">{formatHu(value.start)} – {formatHu(value.end)}</PickerButton>}
|
|
281
|
+
</Field>
|
|
282
|
+
<Popover anchor={button} label="Időszak választása" className="fs-popover--fit" focus="none" open={open}
|
|
283
|
+
onOpenChange={(o) => { if (o) setOpened((n) => n + 1); setOpen(o); }}>
|
|
284
|
+
<DateRangeCalendar key={opened} autoFocus={open} months={2} {...HU_NAMES} labels={labels} value={value} min={min} max={max}
|
|
285
|
+
onChange={(range) => { onChange(range); setOpen(false); }} />
|
|
286
|
+
</Popover>
|
|
287
|
+
</>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
- **`DateRangeCalendar`** is the React wrapper for `mode: 'range'` (the same helper; its `labels`
|
|
293
|
+
must carry `rangeStart` and `rangeEnd`): `value` / `defaultValue` are `{ start, end }`,
|
|
294
|
+
`onChange({ start, end })` comes only with both ends. A pending
|
|
295
|
+
start lives in the helper: a parent re-rendering an equal range keeps it; a range the parent
|
|
296
|
+
refuses is put back. `Calendar` takes `months` too.
|
|
297
|
+
- **Presets** ("last 3 months") are not part of the kit: put the product's own buttons in the
|
|
298
|
+
popover (a `.fs-popover__actions` row under the calendar) and call `setValue`, or set the React `value`.
|
|
299
|
+
- One day calendar with two months is 14 cells wide (about 410 px compact): on a narrow screen use
|
|
300
|
+
`months: 1`.
|
|
301
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default "/* Calendar (spec 02 B): year, month and day views
|
|
1
|
+
export default "/* Calendar (spec 02 B): year, month and day views; one value or a range (T85), one page or two.\n Usage: calendar.md. Behaviour: createCalendar, which renders the header and the grid into an empty\n .fs-calendar (D42). */\n@layer fs.components {\n .fs-calendar {\n /* One cell's width: seven make the calendar, so it follows the density. */\n --fs-calendar-cell: var(--fs-control-h);\n /* Between two pages side by side (months: 2). */\n --fs-calendar-gap: var(--fs-space-4);\n display: inline-flex;\n flex-direction: column;\n gap: var(--fs-space-1);\n box-sizing: content-box;\n width: calc(7 * var(--fs-calendar-cell));\n padding: var(--fs-space-2);\n font-size: var(--fs-text-body-size);\n line-height: var(--fs-text-body-line);\n color: var(--fs-ink);\n }\n\n .fs-calendar__header {\n position: relative;\n display: flex;\n align-items: center;\n gap: var(--fs-space-1);\n height: var(--fs-control-h);\n }\n\n /* Two pages side by side (months: 2): twice as wide in every view, so a popover never resizes. The\n higher views' one grid spans both columns. */\n .fs-calendar:has(> .fs-calendar__months) {\n width: calc(14 * var(--fs-calendar-cell) + var(--fs-calendar-gap));\n }\n .fs-calendar__months {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: var(--fs-calendar-gap);\n }\n .fs-calendar__months > .fs-calendar__grid:only-child {\n grid-column: 1 / -1;\n }\n\n /* The second page's heading, over its grid; the view button names the first. Not a control. */\n .fs-calendar__caption {\n position: absolute;\n inset-block: 0;\n inset-inline-start: calc(7 * var(--fs-calendar-cell) + var(--fs-calendar-gap));\n display: flex;\n align-items: center;\n padding: 0 var(--fs-pad-x);\n font-weight: var(--fs-weight-semibold);\n white-space: nowrap;\n }\n\n /* Shows the page's heading; steps up a view. In the top view it is the heading alone. */\n .fs-calendar__view {\n display: inline-flex;\n align-items: center;\n gap: var(--fs-space-1);\n box-sizing: border-box;\n min-width: 0;\n height: var(--fs-control-h);\n margin: 0 auto 0 0;\n padding: 0 var(--fs-pad-x);\n font: inherit;\n font-weight: var(--fs-weight-semibold);\n color: var(--fs-ink);\n white-space: nowrap;\n background: transparent;\n border: 0;\n border-radius: var(--fs-radius-sm);\n cursor: pointer;\n }\n .fs-calendar__view-icon {\n width: var(--fs-icon-size);\n height: var(--fs-icon-size);\n color: var(--fs-ink-2);\n }\n\n .fs-calendar__grid {\n display: grid;\n align-content: start;\n /* A six-week month and the 4 × 3 month and year pages are the same height. */\n min-height: calc(7 * var(--fs-calendar-cell));\n }\n .fs-calendar__row {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n }\n .fs-calendar__grid--day .fs-calendar__row {\n grid-template-columns: repeat(7, 1fr);\n }\n\n .fs-calendar__weekday {\n display: grid;\n place-items: center;\n height: var(--fs-calendar-cell);\n font-size: var(--fs-text-xs-size);\n line-height: var(--fs-text-xs-line);\n color: var(--fs-ink-muted);\n }\n\n .fs-calendar__cell {\n position: relative;\n display: grid;\n place-items: center;\n box-sizing: border-box;\n min-width: 0;\n height: var(--fs-calendar-cell);\n margin: 0;\n padding: 0 2px;\n font: inherit;\n font-variant-numeric: tabular-nums;\n color: var(--fs-ink);\n white-space: nowrap;\n background: transparent;\n border: 0;\n border-radius: var(--fs-radius-sm);\n cursor: pointer;\n }\n .fs-calendar__grid--month .fs-calendar__cell,\n .fs-calendar__grid--year .fs-calendar__cell {\n height: calc(1.75 * var(--fs-calendar-cell));\n }\n\n @media (hover: hover) {\n .fs-calendar__view:not([aria-disabled='true']):hover,\n .fs-calendar__cell:hover {\n background-color: var(--fs-bg-hover);\n }\n .fs-calendar__cell[aria-selected='true']:not([aria-disabled='true']):hover {\n background-color: var(--fs-primary-bg-hover);\n }\n .fs-calendar__cell--range[aria-selected='true']:not([aria-disabled='true']):hover {\n background-color: var(--fs-bg-hover);\n }\n }\n .fs-calendar__view:not([aria-disabled='true']):active,\n .fs-calendar__cell:active {\n background-color: var(--fs-bg-active);\n }\n\n /* Today: an edge, not a fill, drawn inside so it never meets a neighbour's. */\n .fs-calendar__cell[aria-current='date']::after {\n content: '';\n position: absolute;\n inset: 2px;\n border: var(--fs-line-width) solid var(--fs-accent);\n border-radius: var(--fs-radius-sm);\n pointer-events: none;\n }\n\n /* Selected: the accent fill and weight 600, so it never rests on colour alone. */\n .fs-calendar__cell[aria-selected='true'] {\n font-weight: var(--fs-weight-semibold);\n color: var(--fs-primary-ink);\n background-color: var(--fs-primary-bg);\n }\n .fs-calendar__cell[aria-selected='true'][aria-current='date']::after {\n border-color: var(--fs-primary-ink);\n }\n\n /* A range (T85): start and end are filled as selected; the cells between are a band on the accent\n wash. Each end squares off where it meets the band, and the band's cells are square, so the band\n runs unbroken across a row. Start and end are also in the cells' names (cellLabel's range role). */\n .fs-calendar__cell--range-start {\n border-start-end-radius: 0;\n border-end-end-radius: 0;\n }\n .fs-calendar__cell--range-end {\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n }\n .fs-calendar__cell--range[aria-selected='true'] {\n font-weight: inherit;\n color: var(--fs-ink);\n background-color: var(--fs-accent-wash);\n border-radius: 0;\n }\n .fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {\n border-color: var(--fs-accent);\n }\n\n /* The preview, while only the start is picked: from the start to the hovered or focused cell, a\n dashed edge above and below, joined across the row. Not a fill: nothing is picked yet. */\n .fs-calendar__cell--preview::before {\n content: '';\n position: absolute;\n inset: 3px 0;\n border-block: var(--fs-line-width) dashed var(--fs-accent);\n pointer-events: none;\n }\n\n /* The ring recipe (D15). The header's own button rings outside; cells touch, so theirs is inside. */\n .fs-calendar__view:focus-visible {\n outline: var(--fs-ring-width) solid var(--fs-ring);\n outline-offset: var(--fs-ring-halo-width);\n box-shadow: 0 0 0 var(--fs-ring-halo-width) var(--fs-ring-halo);\n }\n .fs-calendar__cell:focus-visible {\n z-index: 1;\n outline: var(--fs-ring-width) solid var(--fs-ring);\n outline-offset: calc(-1 * var(--fs-ring-width));\n box-shadow: inset 0 0 0 calc(var(--fs-ring-width) + var(--fs-ring-halo-width)) var(--fs-ring-halo);\n }\n\n /* The top view's heading is not a control. */\n .fs-calendar__view[aria-disabled='true'] {\n cursor: default;\n }\n\n /* Outside min and max: reachable, never pickable. Last, so it beats hover, press and selected. */\n .fs-calendar__cell[aria-disabled='true'] {\n color: var(--fs-ink-disabled);\n background-color: transparent;\n cursor: not-allowed;\n }\n\n /* Forced colours: washes and fills are erased, so the selected cell keeps CanvasText on Canvas (Firefox\n and WebKit repaint the background but keep the ink, so a Highlight pair fails contrast: I15) and is\n marked by a 2px Highlight edge inside the cell, as the segmented control does. Today keeps its edge\n (borders survive, in the system's colour), inset further when the cell is selected too. Disabled is\n GrayText. */\n @media (forced-colors: active) {\n .fs-calendar__cell[aria-selected='true'] {\n color: CanvasText;\n background-color: Canvas;\n }\n .fs-calendar__cell[aria-selected='true']:not(.fs-calendar__cell--range)::before {\n content: '';\n position: absolute;\n inset: 0;\n border: 2px solid Highlight;\n border-radius: var(--fs-radius-sm);\n pointer-events: none;\n }\n .fs-calendar__cell[aria-current='date']::after {\n border-color: CanvasText;\n }\n .fs-calendar__cell[aria-selected='true'][aria-current='date']:not(.fs-calendar__cell--range)::after {\n inset: 4px;\n border-color: CanvasText;\n }\n .fs-calendar__cell[aria-disabled='true'] {\n color: GrayText;\n }\n /* The band keeps its shape as a Highlight edge above and below; start and end take the edge above. */\n .fs-calendar__cell--range[aria-selected='true'] {\n color: CanvasText;\n background-color: Canvas;\n }\n .fs-calendar__cell--range[aria-selected='true']::before {\n content: '';\n position: absolute;\n inset: 2px 0;\n border-block: var(--fs-line-width) solid Highlight;\n pointer-events: none;\n }\n .fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {\n border-color: CanvasText;\n }\n .fs-calendar__cell--preview::before {\n border-color: Highlight;\n }\n }\n}\n";
|
package/dist/css-text/kit.js
CHANGED
|
@@ -1372,12 +1372,15 @@ export default `@layer fs.tokens, fs.reset, fs.base, fs.components, fs.utilities
|
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
1374
|
|
|
1375
|
-
/* Calendar (spec 02 B): year, month and day views
|
|
1376
|
-
which renders the header and the grid into an empty
|
|
1375
|
+
/* Calendar (spec 02 B): year, month and day views; one value or a range (T85), one page or two.
|
|
1376
|
+
Usage: calendar.md. Behaviour: createCalendar, which renders the header and the grid into an empty
|
|
1377
|
+
.fs-calendar (D42). */
|
|
1377
1378
|
@layer fs.components {
|
|
1378
1379
|
.fs-calendar {
|
|
1379
1380
|
/* One cell's width: seven make the calendar, so it follows the density. */
|
|
1380
1381
|
--fs-calendar-cell: var(--fs-control-h);
|
|
1382
|
+
/* Between two pages side by side (months: 2). */
|
|
1383
|
+
--fs-calendar-gap: var(--fs-space-4);
|
|
1381
1384
|
display: inline-flex;
|
|
1382
1385
|
flex-direction: column;
|
|
1383
1386
|
gap: var(--fs-space-1);
|
|
@@ -1390,12 +1393,39 @@ export default `@layer fs.tokens, fs.reset, fs.base, fs.components, fs.utilities
|
|
|
1390
1393
|
}
|
|
1391
1394
|
|
|
1392
1395
|
.fs-calendar__header {
|
|
1396
|
+
position: relative;
|
|
1393
1397
|
display: flex;
|
|
1394
1398
|
align-items: center;
|
|
1395
1399
|
gap: var(--fs-space-1);
|
|
1396
1400
|
height: var(--fs-control-h);
|
|
1397
1401
|
}
|
|
1398
1402
|
|
|
1403
|
+
/* Two pages side by side (months: 2): twice as wide in every view, so a popover never resizes. The
|
|
1404
|
+
higher views' one grid spans both columns. */
|
|
1405
|
+
.fs-calendar:has(> .fs-calendar__months) {
|
|
1406
|
+
width: calc(14 * var(--fs-calendar-cell) + var(--fs-calendar-gap));
|
|
1407
|
+
}
|
|
1408
|
+
.fs-calendar__months {
|
|
1409
|
+
display: grid;
|
|
1410
|
+
grid-template-columns: repeat(2, 1fr);
|
|
1411
|
+
column-gap: var(--fs-calendar-gap);
|
|
1412
|
+
}
|
|
1413
|
+
.fs-calendar__months > .fs-calendar__grid:only-child {
|
|
1414
|
+
grid-column: 1 / -1;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/* The second page's heading, over its grid; the view button names the first. Not a control. */
|
|
1418
|
+
.fs-calendar__caption {
|
|
1419
|
+
position: absolute;
|
|
1420
|
+
inset-block: 0;
|
|
1421
|
+
inset-inline-start: calc(7 * var(--fs-calendar-cell) + var(--fs-calendar-gap));
|
|
1422
|
+
display: flex;
|
|
1423
|
+
align-items: center;
|
|
1424
|
+
padding: 0 var(--fs-pad-x);
|
|
1425
|
+
font-weight: var(--fs-weight-semibold);
|
|
1426
|
+
white-space: nowrap;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1399
1429
|
/* Shows the page's heading; steps up a view. In the top view it is the heading alone. */
|
|
1400
1430
|
.fs-calendar__view {
|
|
1401
1431
|
display: inline-flex;
|
|
@@ -1475,6 +1505,9 @@ export default `@layer fs.tokens, fs.reset, fs.base, fs.components, fs.utilities
|
|
|
1475
1505
|
.fs-calendar__cell[aria-selected='true']:not([aria-disabled='true']):hover {
|
|
1476
1506
|
background-color: var(--fs-primary-bg-hover);
|
|
1477
1507
|
}
|
|
1508
|
+
.fs-calendar__cell--range[aria-selected='true']:not([aria-disabled='true']):hover {
|
|
1509
|
+
background-color: var(--fs-bg-hover);
|
|
1510
|
+
}
|
|
1478
1511
|
}
|
|
1479
1512
|
.fs-calendar__view:not([aria-disabled='true']):active,
|
|
1480
1513
|
.fs-calendar__cell:active {
|
|
@@ -1501,6 +1534,37 @@ export default `@layer fs.tokens, fs.reset, fs.base, fs.components, fs.utilities
|
|
|
1501
1534
|
border-color: var(--fs-primary-ink);
|
|
1502
1535
|
}
|
|
1503
1536
|
|
|
1537
|
+
/* A range (T85): start and end are filled as selected; the cells between are a band on the accent
|
|
1538
|
+
wash. Each end squares off where it meets the band, and the band's cells are square, so the band
|
|
1539
|
+
runs unbroken across a row. Start and end are also in the cells' names (cellLabel's range role). */
|
|
1540
|
+
.fs-calendar__cell--range-start {
|
|
1541
|
+
border-start-end-radius: 0;
|
|
1542
|
+
border-end-end-radius: 0;
|
|
1543
|
+
}
|
|
1544
|
+
.fs-calendar__cell--range-end {
|
|
1545
|
+
border-start-start-radius: 0;
|
|
1546
|
+
border-end-start-radius: 0;
|
|
1547
|
+
}
|
|
1548
|
+
.fs-calendar__cell--range[aria-selected='true'] {
|
|
1549
|
+
font-weight: inherit;
|
|
1550
|
+
color: var(--fs-ink);
|
|
1551
|
+
background-color: var(--fs-accent-wash);
|
|
1552
|
+
border-radius: 0;
|
|
1553
|
+
}
|
|
1554
|
+
.fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {
|
|
1555
|
+
border-color: var(--fs-accent);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
/* The preview, while only the start is picked: from the start to the hovered or focused cell, a
|
|
1559
|
+
dashed edge above and below, joined across the row. Not a fill: nothing is picked yet. */
|
|
1560
|
+
.fs-calendar__cell--preview::before {
|
|
1561
|
+
content: '';
|
|
1562
|
+
position: absolute;
|
|
1563
|
+
inset: 3px 0;
|
|
1564
|
+
border-block: var(--fs-line-width) dashed var(--fs-accent);
|
|
1565
|
+
pointer-events: none;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1504
1568
|
/* The ring recipe (D15). The header's own button rings outside; cells touch, so theirs is inside. */
|
|
1505
1569
|
.fs-calendar__view:focus-visible {
|
|
1506
1570
|
outline: var(--fs-ring-width) solid var(--fs-ring);
|
|
@@ -1526,22 +1590,52 @@ export default `@layer fs.tokens, fs.reset, fs.base, fs.components, fs.utilities
|
|
|
1526
1590
|
cursor: not-allowed;
|
|
1527
1591
|
}
|
|
1528
1592
|
|
|
1529
|
-
/* Forced colours: washes and fills are erased, so the selected cell
|
|
1530
|
-
|
|
1593
|
+
/* Forced colours: washes and fills are erased, so the selected cell keeps CanvasText on Canvas (Firefox
|
|
1594
|
+
and WebKit repaint the background but keep the ink, so a Highlight pair fails contrast: I15) and is
|
|
1595
|
+
marked by a 2px Highlight edge inside the cell, as the segmented control does. Today keeps its edge
|
|
1596
|
+
(borders survive, in the system's colour), inset further when the cell is selected too. Disabled is
|
|
1597
|
+
GrayText. */
|
|
1531
1598
|
@media (forced-colors: active) {
|
|
1532
1599
|
.fs-calendar__cell[aria-selected='true'] {
|
|
1533
|
-
color:
|
|
1534
|
-
background-color:
|
|
1600
|
+
color: CanvasText;
|
|
1601
|
+
background-color: Canvas;
|
|
1602
|
+
}
|
|
1603
|
+
.fs-calendar__cell[aria-selected='true']:not(.fs-calendar__cell--range)::before {
|
|
1604
|
+
content: '';
|
|
1605
|
+
position: absolute;
|
|
1606
|
+
inset: 0;
|
|
1607
|
+
border: 2px solid Highlight;
|
|
1608
|
+
border-radius: var(--fs-radius-sm);
|
|
1609
|
+
pointer-events: none;
|
|
1535
1610
|
}
|
|
1536
1611
|
.fs-calendar__cell[aria-current='date']::after {
|
|
1537
1612
|
border-color: CanvasText;
|
|
1538
1613
|
}
|
|
1539
|
-
.fs-calendar__cell[aria-selected='true'][aria-current='date']::after {
|
|
1540
|
-
|
|
1614
|
+
.fs-calendar__cell[aria-selected='true'][aria-current='date']:not(.fs-calendar__cell--range)::after {
|
|
1615
|
+
inset: 4px;
|
|
1616
|
+
border-color: CanvasText;
|
|
1541
1617
|
}
|
|
1542
1618
|
.fs-calendar__cell[aria-disabled='true'] {
|
|
1543
1619
|
color: GrayText;
|
|
1544
1620
|
}
|
|
1621
|
+
/* The band keeps its shape as a Highlight edge above and below; start and end take the edge above. */
|
|
1622
|
+
.fs-calendar__cell--range[aria-selected='true'] {
|
|
1623
|
+
color: CanvasText;
|
|
1624
|
+
background-color: Canvas;
|
|
1625
|
+
}
|
|
1626
|
+
.fs-calendar__cell--range[aria-selected='true']::before {
|
|
1627
|
+
content: '';
|
|
1628
|
+
position: absolute;
|
|
1629
|
+
inset: 2px 0;
|
|
1630
|
+
border-block: var(--fs-line-width) solid Highlight;
|
|
1631
|
+
pointer-events: none;
|
|
1632
|
+
}
|
|
1633
|
+
.fs-calendar__cell--range[aria-selected='true'][aria-current='date']::after {
|
|
1634
|
+
border-color: CanvasText;
|
|
1635
|
+
}
|
|
1636
|
+
.fs-calendar__cell--preview::before {
|
|
1637
|
+
border-color: Highlight;
|
|
1638
|
+
}
|
|
1545
1639
|
}
|
|
1546
1640
|
}
|
|
1547
1641
|
|
package/dist/dom/calendar.d.ts
CHANGED
|
@@ -33,10 +33,18 @@ export interface CalendarLabels {
|
|
|
33
33
|
next: Record<CalendarView, string>;
|
|
34
34
|
/** Optional: said after the heading in the view button's name ("2026. november, hónap választása"). */
|
|
35
35
|
up?: Partial<Record<'day' | 'month', string>>;
|
|
36
|
+
/** Range mode (required there): said after a range's first cell's name ("kezdete"). */
|
|
37
|
+
rangeStart?: string;
|
|
38
|
+
/** Range mode (required there): said after a range's last cell's name ("vége"). */
|
|
39
|
+
rangeEnd?: string;
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
/** A range calendar's labels: the start and end words are required. */
|
|
42
|
+
export interface CalendarRangeLabels extends CalendarLabels {
|
|
43
|
+
rangeStart: string;
|
|
44
|
+
rangeEnd: string;
|
|
45
|
+
}
|
|
46
|
+
/** The options both modes take. */
|
|
47
|
+
interface CalendarBaseOptions {
|
|
40
48
|
/** The first and last pickable day or month; either form is read at the granularity. */
|
|
41
49
|
min?: string;
|
|
42
50
|
max?: string;
|
|
@@ -46,6 +54,11 @@ export interface CalendarOptions {
|
|
|
46
54
|
granularity?: Granularity;
|
|
47
55
|
/** The first column, 0 = Sunday. Default 1 (Monday). */
|
|
48
56
|
weekStart?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Pages of the lowest view side by side, paging together: 2 shows two months in a day calendar,
|
|
59
|
+
* two years in a month calendar. The higher views stay one page, as wide. Default 1.
|
|
60
|
+
*/
|
|
61
|
+
months?: 1 | 2;
|
|
49
62
|
/** Twelve names the month cells show, January first. Short forms fit ("jan.", "febr."). */
|
|
50
63
|
monthNames: readonly string[];
|
|
51
64
|
/** Seven column headers, Sunday first whatever the week start ("V", "H", "K", "Sze", …). */
|
|
@@ -58,9 +71,32 @@ export interface CalendarOptions {
|
|
|
58
71
|
/** The host's live region (CE §7). Without one the calendar keeps its own, visually hidden. */
|
|
59
72
|
announcer?: HTMLElement;
|
|
60
73
|
}
|
|
74
|
+
export interface CalendarOptions extends CalendarBaseOptions {
|
|
75
|
+
/** One value (the default). */
|
|
76
|
+
mode?: 'single';
|
|
77
|
+
/** The picked day (`YYYY-MM-DD`) or month (`YYYY-MM`), or null. */
|
|
78
|
+
value?: string | null;
|
|
79
|
+
}
|
|
80
|
+
/** A range at the granularity. While the second pick is pending, `end` is null. */
|
|
81
|
+
export interface CalendarRange {
|
|
82
|
+
start: string | null;
|
|
83
|
+
end: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface RangeCalendarOptions extends CalendarBaseOptions {
|
|
86
|
+
/** A start and an end (T85): the first pick sets the start, the second the end. Fixed at creation. */
|
|
87
|
+
mode: 'range';
|
|
88
|
+
labels: CalendarRangeLabels;
|
|
89
|
+
/** The range, or null. Read leniently: ends in either order; a month as a day calendar's end is its last day. */
|
|
90
|
+
value?: CalendarRange | null;
|
|
91
|
+
}
|
|
61
92
|
export interface CalendarChangeDetail {
|
|
62
93
|
value: string;
|
|
63
94
|
}
|
|
95
|
+
/** A range calendar's `fs-change`: only when both ends are set, `start` ≤ `end`. */
|
|
96
|
+
export interface CalendarRangeChangeDetail {
|
|
97
|
+
start: string;
|
|
98
|
+
end: string;
|
|
99
|
+
}
|
|
64
100
|
export interface Calendar {
|
|
65
101
|
readonly value: string | null;
|
|
66
102
|
readonly view: CalendarView;
|
|
@@ -75,5 +111,14 @@ export interface Calendar {
|
|
|
75
111
|
/** Removes every listener and empties the root. */
|
|
76
112
|
destroy(): void;
|
|
77
113
|
}
|
|
114
|
+
export interface RangeCalendar extends Omit<Calendar, 'value' | 'setValue' | 'update'> {
|
|
115
|
+
/** The range shown, `end` null while the second pick is pending; null when there is none. */
|
|
116
|
+
readonly value: CalendarRange | null;
|
|
117
|
+
/** Sets the range (dropping a pending start) and shows its start's page, without an event. */
|
|
118
|
+
setValue(value: CalendarRange | null): void;
|
|
119
|
+
/** Takes new options; a `value` among them moves to its page as `setValue` does. */
|
|
120
|
+
update(options: Partial<Omit<RangeCalendarOptions, 'mode'>>): void;
|
|
121
|
+
}
|
|
78
122
|
/** `root` is an empty `.fs-calendar` element; the helper renders the header and the grid into it. */
|
|
123
|
+
export declare function createCalendar(root: HTMLElement, options: RangeCalendarOptions): RangeCalendar;
|
|
79
124
|
export declare function createCalendar(root: HTMLElement, options: CalendarOptions): Calendar;
|