@mistriwork/ui 1.0.0-rc.57 → 1.0.0-rc.59
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/README.md +46 -12
- package/dist/Avatar.js +3 -3
- package/dist/Button.d.ts +4 -14
- package/dist/Button.js +26 -13
- package/dist/Carousel.d.ts +6 -5
- package/dist/Carousel.js +58 -67
- package/dist/Choices.d.ts +2 -9
- package/dist/Choices.js +127 -64
- package/dist/DateField.d.ts +9 -4
- package/dist/DateField.js +102 -119
- package/dist/Drawer.d.ts +1 -19
- package/dist/Drawer.js +8 -9
- package/dist/DropMenu.d.ts +8 -21
- package/dist/DropMenu.js +84 -30
- package/dist/Dropdown.d.ts +9 -8
- package/dist/Dropdown.js +69 -65
- package/dist/Field.d.ts +2 -1
- package/dist/Field.js +12 -18
- package/dist/FileField.d.ts +3 -10
- package/dist/FileField.js +12 -9
- package/dist/FormParts.d.ts +17 -10
- package/dist/FormParts.js +26 -41
- package/dist/HeroBlocks.d.ts +7 -3
- package/dist/HeroBlocks.js +11 -6
- package/dist/Modal.d.ts +6 -17
- package/dist/Modal.js +90 -21
- package/dist/Pagination.d.ts +1 -12
- package/dist/Pagination.js +17 -3
- package/dist/Popover.d.ts +1 -15
- package/dist/Popover.js +10 -15
- package/dist/Resizable.d.ts +3 -21
- package/dist/Resizable.js +14 -91
- package/dist/ScrollArea.d.ts +4 -2
- package/dist/ScrollArea.js +11 -11
- package/dist/Select.d.ts +1 -6
- package/dist/Select.js +16 -7
- package/dist/SensitiveField.d.ts +1 -8
- package/dist/SensitiveField.js +6 -4
- package/dist/Slider.d.ts +1 -5
- package/dist/Slider.js +13 -5
- package/dist/Switch.d.ts +1 -11
- package/dist/Switch.js +10 -9
- package/dist/Tabs.d.ts +3 -3
- package/dist/Tabs.js +3 -3
- package/dist/TextArea.d.ts +4 -6
- package/dist/TextArea.js +14 -5
- package/dist/TextField.d.ts +5 -9
- package/dist/TextField.js +67 -9
- package/dist/Tooltip.d.ts +1 -21
- package/dist/Tooltip.js +13 -31
- package/dist/Typeahead.d.ts +15 -18
- package/dist/Typeahead.js +151 -86
- package/dist/UiKit.d.ts +63 -4
- package/dist/UiKit.js +46 -5
- package/dist/behaviors/DaysParts.js +28 -0
- package/dist/behaviors/EditableParts.js +21 -0
- package/dist/behaviors/PickParts.js +30 -0
- package/dist/behaviors/ScrubParts.js +21 -0
- package/dist/behaviors/SortableParts.js +32 -0
- package/dist/behaviors/SpansParts.js +12 -0
- package/dist/behaviors/TransferParts.js +37 -0
- package/dist/behaviors/TurnsParts.js +31 -0
- package/dist/behaviors/WidthsParts.js +27 -0
- package/dist/behaviors/days.js +216 -0
- package/dist/behaviors/dress.js +86 -0
- package/dist/behaviors/editable.js +104 -0
- package/dist/behaviors/heard.js +22 -0
- package/dist/behaviors/index.d.ts +310 -0
- package/dist/behaviors/index.js +44 -0
- package/dist/behaviors/pick.js +158 -0
- package/dist/behaviors/scrub.js +152 -0
- package/dist/behaviors/sortable.js +170 -0
- package/dist/behaviors/spans.js +240 -0
- package/dist/behaviors/testing.js +48 -0
- package/dist/behaviors/transfer.js +202 -0
- package/dist/behaviors/turns.js +106 -0
- package/dist/behaviors/widths.js +150 -0
- package/dist/behaviors.css +309 -0
- package/dist/changeDetails.d.ts +4 -8
- package/dist/changeDetails.js +0 -6
- package/dist/conformance.js +107 -1
- package/dist/controls.css +36 -0
- package/dist/fieldFrame.d.ts +2 -15
- package/dist/fieldFrame.js +1 -17
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -5
- package/dist/internal/Frame.d.ts +6 -0
- package/dist/internal/Frame.js +25 -0
- package/dist/internal/HelpTip.d.ts +5 -0
- package/dist/internal/HelpTip.js +37 -0
- package/dist/internal/layers.d.ts +21 -0
- package/dist/internal/layers.js +66 -0
- package/dist/internal/popups.d.ts +12 -10
- package/dist/internal/popups.js +18 -14
- package/dist/internal/told.d.ts +14 -0
- package/dist/internal/told.js +20 -0
- package/dist/internal/uiKitContext.js +6 -4
- package/dist/preferences.css +2 -3
- package/dist/style.css +5 -16
- package/dist/styles/extras.css +461 -0
- package/dist/styles/forms.css +346 -0
- package/dist/styles/guard.css +114 -0
- package/dist/styles/kit-fields.css +181 -0
- package/dist/styles/kit-parts.css +130 -0
- package/dist/styles/kit.css +558 -0
- package/dist/styles/layers.css +4 -0
- package/dist/styles/looks.css +374 -0
- package/dist/styles/m-tokens.css +173 -0
- package/dist/styles/overlays.css +107 -0
- package/dist/styles/parts.css +456 -0
- package/dist/styles/screens.css +76 -0
- package/dist/styles/ui-sdk.css +1635 -0
- package/dist/tokens.css +15 -4
- package/dist/uiKitSlots.d.ts +1 -1
- package/dist/uiKitSlots.js +18 -2
- package/package.json +13 -11
- package/dist/forms.css +0 -225
- package/dist/hero.css +0 -23
- package/dist/internal/anchor.d.ts +0 -19
- package/dist/internal/anchor.js +0 -52
- package/dist/primitives.css +0 -200
- package/dist/standalone.css +0 -478
package/dist/Choices.js
CHANGED
|
@@ -1,93 +1,156 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* Choices drawn as buttons, cards and checkboxes: Yes/No, icon cards (one or several), a checkbox and a consent. One
|
|
4
|
-
* answer is
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* answer is UI SDK's radio group, so the arrows move between the answers and choose, and the focus ring shows on the
|
|
5
|
+
* face when the keyboard is on the radio. Several cards are one group as the radios are (CheckCards): one Tab stop,
|
|
6
|
+
* the arrows move between them, Space turns one on or off, and each says `aria-checked`. Props only.
|
|
7
7
|
* Preview: @mistriwork/ui is Preview at 1.0.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
9
|
+
import { createChange, definePrimitive } from '@ui-sdk/core';
|
|
10
|
+
import { Checkbox as Box, CheckboxIndicator } from '@ui-sdk/react/checkbox';
|
|
11
|
+
import { FieldControl } from '@ui-sdk/react/field';
|
|
12
|
+
import { createParts } from '@ui-sdk/react/primitive';
|
|
13
|
+
import { Radio, RadioGroup } from '@ui-sdk/react/radio';
|
|
14
|
+
import { useId } from 'react';
|
|
15
|
+
import { Frame } from './internal/Frame.js';
|
|
16
|
+
import { told } from './internal/told.js';
|
|
13
17
|
import { slotted } from './internal/uiKitContext.js';
|
|
14
18
|
/** Two buttons answering a question. */
|
|
19
|
+
/* Each radio is named by its word, by id, since the word stands beside the radio and not inside it. */
|
|
15
20
|
function DefaultYesNo(props) {
|
|
16
|
-
const
|
|
17
|
-
return (_jsx(
|
|
21
|
+
const id = useId();
|
|
22
|
+
return (_jsx(Frame, { ...props, children: _jsx(RadioGroup, { "data-kind": "cards", "data-fit": "pair", value: props.value === '' ? null : props.value, onValueChange: (next, details) => {
|
|
23
|
+
if (next === 'yes' || next === 'no')
|
|
24
|
+
props.onChange(next, told('select', details));
|
|
25
|
+
}, children: ['yes', 'no'].map((answer) => (_jsxs("label", { "data-slot": "choice", "data-checked": props.value === answer ? '' : undefined, children: [_jsx(Radio, { value: answer, "aria-labelledby": `${id}-${answer}` }), _jsx("span", { "data-slot": "choice-label", id: `${id}-${answer}`, children: props[answer] })] }, answer))) }) }));
|
|
18
26
|
}
|
|
19
27
|
/** Cards with an icon, a label and a box. One choice is a radio group; `multiple` a group of checkboxes. */
|
|
20
28
|
function DefaultChoiceCards(props) {
|
|
21
|
-
const
|
|
22
|
-
const toggle = (v, on, event) => {
|
|
23
|
-
const details = changeDetails('select', event);
|
|
24
|
-
if (!props.multiple)
|
|
25
|
-
return props.onChange(on ? [v] : [], details);
|
|
26
|
-
if (v === props.exclusive)
|
|
27
|
-
return props.onChange(on ? [v] : [], details);
|
|
28
|
-
const rest = props.value.filter((x) => x !== v && x !== props.exclusive);
|
|
29
|
-
props.onChange(on ? props.options.map((o) => o.value).filter((x) => x === v || rest.includes(x)) : rest, details);
|
|
30
|
-
};
|
|
29
|
+
const id = useId();
|
|
31
30
|
if (props.multiple)
|
|
32
|
-
return (_jsx(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
return (_jsx(Frame, { ...props, children: _jsx(FieldControl, { render: _jsx(CheckCards, { cards: props.options.map((option) => ({
|
|
32
|
+
key: option.value,
|
|
33
|
+
label: option.label,
|
|
34
|
+
icon: option.icon,
|
|
35
|
+
on: props.value.includes(option.value),
|
|
36
|
+
})), onToggle: (index, on, details) => {
|
|
37
|
+
const value = props.options[index].value;
|
|
38
|
+
const say = { ...details, reason: 'select' };
|
|
39
|
+
if (value === props.exclusive)
|
|
40
|
+
return props.onChange(on ? [value] : [], say);
|
|
41
|
+
const rest = props.value.filter((other) => other !== value && other !== props.exclusive);
|
|
42
|
+
props.onChange(on ? props.options.map((option) => option.value).filter((other) => other === value || rest.includes(other)) : rest, say);
|
|
43
|
+
} }) }) }));
|
|
44
|
+
return (_jsx(Frame, { ...props, children: _jsx(RadioGroup, { "data-kind": "cards", value: props.value[0] ?? null, onValueChange: (next, details) => props.onChange(next === null ? [] : [String(next)], told('select', details)), children: props.options.map((option) => (_jsxs("label", { "data-slot": "choice", "data-checked": props.value[0] === option.value ? '' : undefined, children: [_jsx(Radio, { value: option.value, "aria-labelledby": `${id}-${option.value}` }), option.icon ? (_jsx("span", { "data-slot": "choice-icon", "aria-hidden": "true", children: option.icon })) : null, _jsx("span", { "data-slot": "choice-label", id: `${id}-${option.value}`, children: option.label })] }, option.value))) }) }));
|
|
37
45
|
}
|
|
46
|
+
const checkCards = definePrimitive({
|
|
47
|
+
name: 'check-cards',
|
|
48
|
+
options: { keys: 'list', value: 'list', onValueChange: 'callback', disabled: 'boolean' },
|
|
49
|
+
controlled: ['value'],
|
|
50
|
+
state: (options) => ({
|
|
51
|
+
value: (options.value ?? []),
|
|
52
|
+
/* The card the keyboard was last on. */
|
|
53
|
+
cursor: null,
|
|
54
|
+
}),
|
|
55
|
+
sync: (options) => (options.value === undefined ? {} : { value: options.value }),
|
|
56
|
+
api: (context) => {
|
|
57
|
+
const change = createChange(context);
|
|
58
|
+
const keys = () => context.options().keys ?? [];
|
|
59
|
+
return {
|
|
60
|
+
disabled: () => context.options().disabled === true,
|
|
61
|
+
on: (key) => context.store.get().value.includes(key),
|
|
62
|
+
stop() {
|
|
63
|
+
const { value, cursor } = context.store.get();
|
|
64
|
+
const all = keys();
|
|
65
|
+
if (cursor !== null && all.includes(cursor))
|
|
66
|
+
return cursor;
|
|
67
|
+
return all.find((key) => value.includes(key)) ?? all[0] ?? null;
|
|
68
|
+
},
|
|
69
|
+
walked(key) {
|
|
70
|
+
if (context.store.get().cursor !== key)
|
|
71
|
+
context.store.set({ cursor: key });
|
|
72
|
+
},
|
|
73
|
+
/* Where a key takes the keyboard from a card, round the ends, or nowhere. */
|
|
74
|
+
step(from, key) {
|
|
75
|
+
const all = keys();
|
|
76
|
+
const at = all.indexOf(from);
|
|
77
|
+
const to = { ArrowDown: at + 1, ArrowRight: at + 1, ArrowUp: at - 1, ArrowLeft: at - 1, Home: 0, End: all.length - 1 }[key];
|
|
78
|
+
return to === undefined || at < 0 ? undefined : all[(to + all.length) % all.length];
|
|
79
|
+
},
|
|
80
|
+
toggle(key, event) {
|
|
81
|
+
if (context.options().disabled)
|
|
82
|
+
return false;
|
|
83
|
+
const { value } = context.store.get();
|
|
84
|
+
const next = value.includes(key)
|
|
85
|
+
? value.filter((other) => other !== key)
|
|
86
|
+
: keys().filter((other) => other === key || value.includes(other));
|
|
87
|
+
return change('value', next, { reason: 'press', event });
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
slots: (slot) => ({
|
|
92
|
+
root: slot({
|
|
93
|
+
attrs: (_state, part) => ({ role: 'group', 'data-disabled': part.api.disabled() ? '' : undefined }),
|
|
94
|
+
}),
|
|
95
|
+
card: slot({
|
|
96
|
+
props: { value: 'string' },
|
|
97
|
+
state: (state, part) => ({ on: state.value.includes(part.props.value) }),
|
|
98
|
+
attrs: (state, part) => ({
|
|
99
|
+
role: 'checkbox',
|
|
100
|
+
tabindex: part.api.stop() === part.props.value ? '0' : '-1',
|
|
101
|
+
'data-key': part.props.value,
|
|
102
|
+
'aria-checked': String(state.value.includes(part.props.value)),
|
|
103
|
+
'aria-disabled': part.api.disabled() ? 'true' : undefined,
|
|
104
|
+
'data-checked': state.value.includes(part.props.value) ? '' : undefined,
|
|
105
|
+
}),
|
|
106
|
+
on: {
|
|
107
|
+
keydown: (event, { api, el, props }) => {
|
|
108
|
+
const to = api.step(props.value, event.key);
|
|
109
|
+
if (to !== undefined) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
api.walked(to);
|
|
112
|
+
el?.parentElement?.querySelector(`[data-slot="check-cards-card"][data-key="${CSS.escape(to)}"]`)?.focus();
|
|
113
|
+
}
|
|
114
|
+
else if (event.key === ' ') {
|
|
115
|
+
// Space is the box's own key; the page does not scroll under it.
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
api.toggle(props.value, event);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
focus: (_event, { api, props }) => api.walked(props.value),
|
|
121
|
+
click: (event, { api, props }) => {
|
|
122
|
+
api.walked(props.value);
|
|
123
|
+
api.toggle(props.value, event);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
const cardParts = createParts(checkCards, { root: 'div', card: 'div' });
|
|
38
130
|
/**
|
|
39
131
|
* Several cards, any of them on: full-width cards, each an icon, its words and a square at its end that fills when it
|
|
40
132
|
* is on. They are one group to the keyboard, as radios are — one Tab stop (the card last moved to, else the first one
|
|
41
133
|
* on, else the first), the arrows and Home and End move between them, and Space turns the one in hand on or off — and
|
|
42
134
|
* each is a `checkbox` saying `aria-checked`, so a screen reader hears "checked" as it moves.
|
|
43
135
|
*/
|
|
136
|
+
/* Whatever else it is handed goes on the group: a field that takes the cards as its control (ChoiceCards) gives
|
|
137
|
+
them a ref and its own attributes beside the props a caller names. */
|
|
44
138
|
function DefaultCheckCards(props) {
|
|
45
|
-
const { cards } = props;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
setHeld(next);
|
|
53
|
-
faces.current[next]?.focus();
|
|
54
|
-
};
|
|
55
|
-
const keys = (event, index) => {
|
|
56
|
-
const to = event.key === 'ArrowDown' || event.key === 'ArrowRight'
|
|
57
|
-
? index + 1
|
|
58
|
-
: event.key === 'ArrowUp' || event.key === 'ArrowLeft'
|
|
59
|
-
? index - 1
|
|
60
|
-
: event.key === 'Home'
|
|
61
|
-
? 0
|
|
62
|
-
: event.key === 'End'
|
|
63
|
-
? cards.length - 1
|
|
64
|
-
: undefined;
|
|
65
|
-
if (to !== undefined) {
|
|
66
|
-
event.preventDefault();
|
|
67
|
-
move(to);
|
|
68
|
-
}
|
|
69
|
-
else if (event.key === ' ') {
|
|
70
|
-
// Space is the box's own key; the page does not scroll under it.
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
if (!props.disabled)
|
|
73
|
-
props.onToggle(index, !cards[index].on, changeDetails('toggle', event));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return (_jsx("div", { className: "choice-cards", role: "group", "data-fit": props.fit, id: props.id, "aria-labelledby": props['aria-labelledby'], "aria-describedby": props['aria-describedby'], "aria-invalid": props['aria-invalid'], children: cards.map((card, index) => (_jsxs("div", { ref: (face) => {
|
|
77
|
-
faces.current[index] = face;
|
|
78
|
-
}, role: "checkbox", "aria-checked": card.on, "aria-disabled": props.disabled || undefined, tabIndex: index === stop ? 0 : -1, className: `choice-card${card.on ? ' is-on' : ''}`, onClick: (event) => {
|
|
79
|
-
setHeld(index);
|
|
80
|
-
if (!props.disabled)
|
|
81
|
-
props.onToggle(index, !card.on, changeDetails('toggle', event));
|
|
82
|
-
}, onFocus: () => setHeld(index), onKeyDown: (event) => keys(event, index), children: [card.icon ? (_jsx("span", { className: "choice-card-icon", "aria-hidden": "true", children: card.icon })) : null, _jsxs("span", { className: "choice-card-label", children: [card.label, card.help ? _jsx("span", { className: "choice-card-help", children: card.help }) : null] }), _jsx("span", { className: "choice-box", "aria-hidden": "true" })] }, card.key))) }));
|
|
139
|
+
const { cards, onToggle, disabled, fit, ...rest } = props;
|
|
140
|
+
return (_jsx(cardParts.Root, { ...rest, "data-fit": fit, keys: cards.map((card) => card.key), value: cards.filter((card) => card.on).map((card) => card.key), disabled: disabled, onValueChange: (next, details) => {
|
|
141
|
+
// The primitive says the whole list; the caller hears the one card that moved.
|
|
142
|
+
const index = cards.findIndex((card) => card.on !== next.includes(card.key));
|
|
143
|
+
if (index >= 0)
|
|
144
|
+
onToggle(index, !cards[index].on, told('toggle', details));
|
|
145
|
+
}, children: cards.map((card) => (_jsxs(cardParts.Card, { value: card.key, children: [card.icon ? (_jsx("span", { "data-slot": "choice-icon", "aria-hidden": "true", children: card.icon })) : null, _jsxs("span", { "data-slot": "choice-label", children: [card.label, card.help ? _jsx("span", { "data-slot": "choice-hint", children: card.help }) : null] }), _jsx("span", { "data-slot": "checkbox", "data-checked": card.on ? '' : undefined, "aria-hidden": "true", children: card.on ? _jsx("span", { "data-slot": "checkbox-indicator", "data-checked": "" }) : null })] }, card.key))) }));
|
|
83
146
|
}
|
|
84
147
|
/** A checkbox beside its text. */
|
|
85
148
|
function DefaultCheckbox(props) {
|
|
86
|
-
return (_jsx(
|
|
149
|
+
return (_jsx(Frame, { ...props, check: true, children: _jsx(Box, { id: props.id, checked: props.checked, disabled: props.disabled, "aria-required": props.required || undefined, onCheckedChange: (next, details) => props.onChange(next === true, told('toggle', details)), children: _jsx(CheckboxIndicator, {}) }) }));
|
|
87
150
|
}
|
|
88
151
|
/** A checkbox for a long notice: the paragraph is the label, in the body's weight. */
|
|
89
152
|
function DefaultConsent(props) {
|
|
90
|
-
return _jsx(Checkbox, { ...props, className: ['
|
|
153
|
+
return _jsx(Checkbox, { ...props, className: ['consent', props.className].filter(Boolean).join(' ') });
|
|
91
154
|
}
|
|
92
155
|
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
93
156
|
export const YesNo = slotted('YesNo', DefaultYesNo, { onChange: [1, 'select'] });
|
package/dist/DateField.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* for a date, or with `withTime` for a date and a wall-clock time. The text
|
|
4
4
|
* is the value — typed drafts survive, the calendar only ever writes the
|
|
5
5
|
* date part — and nothing here converts a value through an instant. The
|
|
6
|
-
* arithmetic and the bounds are datePickerModel.ts's
|
|
7
|
-
*
|
|
6
|
+
* arithmetic and the bounds are datePickerModel.ts's; the popover and the
|
|
7
|
+
* month's grid, with its keys, are UI SDK's. Its words and the calendar
|
|
8
|
+
* button's icon are props: the kit lends its catalog's and its icon.
|
|
8
9
|
*/
|
|
9
10
|
import { type AriaAttributes, type KeyboardEvent, type ReactNode, type Ref } from 'react';
|
|
10
11
|
import { type ChangeDetails } from './changeDetails.js';
|
|
@@ -30,6 +31,8 @@ export interface DateFieldWords {
|
|
|
30
31
|
nextMonth: string;
|
|
31
32
|
clear: string;
|
|
32
33
|
today: string;
|
|
34
|
+
/** The clock's name beside a date and a time, with the field's label when it has one. Absent, no clock is drawn. */
|
|
35
|
+
time?: (label?: string) => string;
|
|
33
36
|
}
|
|
34
37
|
export interface DateFieldProps {
|
|
35
38
|
id: string;
|
|
@@ -61,7 +64,7 @@ export interface DateFieldProps {
|
|
|
61
64
|
withTime?: boolean;
|
|
62
65
|
/** The calendar is drawn in a portal; an owner that watches focus (an autosaving field) is told where. */
|
|
63
66
|
popupRef?: (node: HTMLDivElement | null) => void;
|
|
64
|
-
/**
|
|
67
|
+
/** A popover's words (`trigger-press`, `outside-press`, `escape-key` …), `day-press` when a choice closed it, `open-key` for Alt+ArrowDown, and `disabled` when the
|
|
65
68
|
field was disabled or its bounds stopped agreeing while it was open. */
|
|
66
69
|
onOpenChange?: (open: boolean, details: ChangeDetails<DateFieldOpenReason>) => void;
|
|
67
70
|
'aria-label'?: string;
|
|
@@ -69,7 +72,9 @@ export interface DateFieldProps {
|
|
|
69
72
|
'aria-describedby'?: string;
|
|
70
73
|
}
|
|
71
74
|
export type DateFieldOpenReason = 'trigger-hover' | 'trigger-focus' | 'trigger-press' | 'outside-press' | 'escape-key' | 'close-press' | 'focus-out' | 'imperative-action' | 'implicit' | 'day-press' | 'open-key' | 'disabled';
|
|
72
|
-
/** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone.
|
|
75
|
+
/** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone. The box
|
|
76
|
+
and the calendar are one field to whoever listens for its blur: `onBlur` is not said while the keyboard goes
|
|
77
|
+
between them, and is said once when it leaves both. */
|
|
73
78
|
declare function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, onKeyDown, disabled, required, min, max, locale, timezone, now, firstDay, className, name, inputRef, placeholder, withTime, popupRef, onOpenChange, 'aria-label': label, 'aria-invalid': invalid, 'aria-describedby': describedBy, }: DateFieldProps): import("react").JSX.Element;
|
|
74
79
|
export declare const DateField: typeof DefaultDateField;
|
|
75
80
|
export {};
|
package/dist/DateField.js
CHANGED
|
@@ -4,15 +4,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* for a date, or with `withTime` for a date and a wall-clock time. The text
|
|
5
5
|
* is the value — typed drafts survive, the calendar only ever writes the
|
|
6
6
|
* date part — and nothing here converts a value through an instant. The
|
|
7
|
-
* arithmetic and the bounds are datePickerModel.ts's
|
|
8
|
-
*
|
|
7
|
+
* arithmetic and the bounds are datePickerModel.ts's; the popover and the
|
|
8
|
+
* month's grid, with its keys, are UI SDK's. Its words and the calendar
|
|
9
|
+
* button's icon are props: the kit lends its catalog's and its icon.
|
|
9
10
|
*/
|
|
10
11
|
import { useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import { Button } from '@ui-sdk/react/button';
|
|
13
|
+
import { Calendar, CalendarDay, CalendarGrid, CalendarHeading, CalendarNext, CalendarPrevious, CalendarWeekday, CalendarWeekdays, CalendarWeeks, createCalendarController, } from '@ui-sdk/react/calendar';
|
|
14
|
+
import { Input } from '@ui-sdk/react/input';
|
|
15
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@ui-sdk/react/popover';
|
|
16
|
+
import { changeDetails } from './changeDetails.js';
|
|
17
|
+
import { clampDate, dateBounds, dateFormat, dateParts, dateTimeWithinBounds, dateWithinBounds, FIRST_DATE, isPickerDate, isPickerDateTime, LAST_DATE, splitDateTime, todayInZone, withDate, } from './internal/datePickerModel.js';
|
|
18
|
+
import { popupContainer, useDialogContainer } from './internal/popups.js';
|
|
19
|
+
import { told } from './internal/told.js';
|
|
16
20
|
import { slotted } from './internal/uiKitContext.js';
|
|
17
21
|
/** How a locale writes a numeric date: the order of its parts and its separator ("MM/DD/YYYY" in en-US). */
|
|
18
22
|
function dateMask(locale) {
|
|
@@ -55,12 +59,21 @@ function readDate(text, mask) {
|
|
|
55
59
|
const iso = `${at.year}-${at.month.padStart(2, '0')}-${at.day.padStart(2, '0')}`;
|
|
56
60
|
return isPickerDate(iso) ? iso : undefined;
|
|
57
61
|
}
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
/* What UI SDK's popover says of an open or a close, in the words this field says them. */
|
|
63
|
+
const OPENS = new Set(['trigger-hover', 'trigger-press', 'outside-press', 'escape-key', 'close-press', 'focus-out']);
|
|
64
|
+
const openReason = (said) => said === 'imperative' ? 'imperative-action' : said && OPENS.has(said) ? said : 'implicit';
|
|
65
|
+
/* The month's two arrows. */
|
|
66
|
+
function Caret({ to }) {
|
|
67
|
+
return (_jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: _jsx("path", { d: to === 'left' ? 'M10 3.5L5.5 8l4.5 4.5' : 'M6 3.5L10.5 8 6 12.5', strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
68
|
+
}
|
|
69
|
+
/** A date field, or a date and a wall-clock time. No input is parsed as an instant or shifted by a timezone. The box
|
|
70
|
+
and the calendar are one field to whoever listens for its blur: `onBlur` is not said while the keyboard goes
|
|
71
|
+
between them, and is said once when it leaves both. */
|
|
72
|
+
function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, onKeyDown, disabled, required, min, max, locale, timezone, now, firstDay = 1, className, name, inputRef, placeholder, withTime = false, popupRef, onOpenChange, 'aria-label': label, 'aria-invalid': invalid, 'aria-describedby': describedBy, }) {
|
|
60
73
|
// The calendar only ever sees the date; a wall time's clock stays in the box.
|
|
61
74
|
const datePart = withTime ? (splitDateTime(value)?.date ?? value.slice(0, 10)) : value;
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
/* A range's two ends may for a moment be half typed or the wrong way round. The text stays editable, and the
|
|
76
|
+
calendar is shut until they agree. */
|
|
64
77
|
const configuredBounds = useMemo(() => {
|
|
65
78
|
try {
|
|
66
79
|
return dateBounds(withTime ? min?.slice(0, 10) : min, withTime ? max?.slice(0, 10) : max);
|
|
@@ -72,18 +85,21 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
72
85
|
const bounds = configuredBounds ?? dateBounds();
|
|
73
86
|
const today = todayInZone(now ?? new Date(), timezone);
|
|
74
87
|
const seed = () => clampDate(isPickerDate(datePart) ? datePart : today, bounds);
|
|
75
|
-
const [active, setActive] = useState(seed);
|
|
76
88
|
const [open, setOpenState] = useState(false);
|
|
77
89
|
const openCallback = useRef(onOpenChange);
|
|
90
|
+
const blurCallback = useRef(onBlur);
|
|
78
91
|
useLayoutEffect(() => {
|
|
79
92
|
openCallback.current = onOpenChange;
|
|
93
|
+
blurCallback.current = onBlur;
|
|
80
94
|
});
|
|
81
95
|
const setOpen = (next, details) => {
|
|
82
96
|
setOpenState(next);
|
|
83
97
|
openCallback.current?.(next, details);
|
|
84
98
|
};
|
|
85
|
-
const [container, setContainer] = useState(null);
|
|
86
99
|
const group = useRef(null);
|
|
100
|
+
/* A calendar opened inside a dialog is drawn inside it, so the dialog's focus trap and its stacking keep it as
|
|
101
|
+
their own; elsewhere it goes where every popup here does (internal/popups.ts). */
|
|
102
|
+
const container = useDialogContainer(group);
|
|
87
103
|
const trigger = useRef(null);
|
|
88
104
|
const input = useRef(null);
|
|
89
105
|
useImperativeHandle(inputRef, () => input.current, []);
|
|
@@ -92,34 +108,20 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
92
108
|
popup.current = node;
|
|
93
109
|
popupRef?.(node);
|
|
94
110
|
}, [popupRef]);
|
|
111
|
+
const month = useMemo(() => createCalendarController(), []);
|
|
95
112
|
const ownedFocus = useRef(false);
|
|
96
|
-
const moveFocus = useRef(false);
|
|
97
113
|
const blurTimer = useRef(undefined);
|
|
98
|
-
|
|
99
|
-
const blurCallback = useRef(onBlur);
|
|
100
|
-
useLayoutEffect(() => {
|
|
101
|
-
blurCallback.current = onBlur;
|
|
102
|
-
});
|
|
103
|
-
const caption = useId();
|
|
114
|
+
useEffect(() => () => clearTimeout(blurTimer.current), []);
|
|
104
115
|
const hint = useId();
|
|
105
116
|
/* A date alone is shown as the locale writes it and kept as ISO; what is being typed stays as typed until the
|
|
106
117
|
field is left, so a half-typed date is never rewritten under the caret. A date with a time stays ISO text. */
|
|
107
118
|
const mask = useMemo(() => dateMask(locale), [locale]);
|
|
108
119
|
const [draft, setDraft] = useState(null);
|
|
109
120
|
const shown = withTime ? value : (draft ?? (isPickerDate(value) ? localeText(value, mask) : value));
|
|
110
|
-
const formatHint = withTime ? words.dateTimePattern : mask.hint;
|
|
111
121
|
useEffect(() => {
|
|
112
122
|
if (draft !== null && value !== (readDate(draft, mask) ?? draft))
|
|
113
123
|
setDraft(null);
|
|
114
124
|
}, [value]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
115
|
-
const days = monthGrid(active, firstDay, bounds);
|
|
116
|
-
const weekdays = weekdayLabels(locale, firstDay);
|
|
117
|
-
useEffect(() => {
|
|
118
|
-
setContainer(trigger.current?.closest('dialog, [role="dialog"]'));
|
|
119
|
-
return () => {
|
|
120
|
-
clearTimeout(blurTimer.current);
|
|
121
|
-
};
|
|
122
|
-
}, []);
|
|
123
125
|
const bad = !configuredBounds ||
|
|
124
126
|
(value !== '' &&
|
|
125
127
|
(withTime
|
|
@@ -128,6 +130,8 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
128
130
|
useEffect(() => {
|
|
129
131
|
input.current?.setCustomValidity(!bad ? '' : withTime ? words.enterDateAndTime : words.enterDate(mask.hint));
|
|
130
132
|
}, [bad, withTime, mask]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
133
|
+
/* While the calendar is open and what bounds it moves under it, the month in view goes to where a day can still
|
|
134
|
+
be chosen, and the keyboard goes with it where it was on a day. */
|
|
131
135
|
useLayoutEffect(() => {
|
|
132
136
|
if (!open)
|
|
133
137
|
return;
|
|
@@ -135,51 +139,38 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
135
139
|
setOpen(false, changeDetails('disabled'));
|
|
136
140
|
return;
|
|
137
141
|
}
|
|
138
|
-
const next =
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}, [value, min, max, disabled]);
|
|
145
|
-
useLayoutEffect(() => {
|
|
146
|
-
if (!open || !moveFocus.current)
|
|
147
|
-
return;
|
|
148
|
-
popup.current?.querySelector(`[data-date="${active}"]`)?.focus();
|
|
149
|
-
moveFocus.current = false;
|
|
150
|
-
}, [active, open]);
|
|
142
|
+
const next = seed();
|
|
143
|
+
if (month.getMonth() !== next.slice(0, 7))
|
|
144
|
+
month.setMonth(next.slice(0, 7));
|
|
145
|
+
if (popup.current?.querySelector('[data-slot="calendar-day"]:focus'))
|
|
146
|
+
month.focus(next);
|
|
147
|
+
}, [value, min, max, disabled]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
151
148
|
const within = (node) => Boolean(node && (group.current?.contains(node) || popup.current?.contains(node)));
|
|
152
149
|
const commitBlur = () => {
|
|
153
|
-
if (ownedFocus.current)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
if (!ownedFocus.current)
|
|
151
|
+
return;
|
|
152
|
+
ownedFocus.current = false;
|
|
153
|
+
setDraft(null);
|
|
154
|
+
blurCallback.current?.();
|
|
158
155
|
};
|
|
159
156
|
const checkBlur = () => {
|
|
160
157
|
clearTimeout(blurTimer.current);
|
|
161
|
-
//
|
|
158
|
+
// The focus a closing popup hands back lands a moment later; the field is left only if it is not there then.
|
|
162
159
|
blurTimer.current = setTimeout(() => {
|
|
163
160
|
if (!within(document.activeElement))
|
|
164
161
|
commitBlur();
|
|
165
162
|
}, 0);
|
|
166
163
|
};
|
|
167
164
|
const leave = (event) => {
|
|
168
|
-
if (!event.relatedTarget)
|
|
169
|
-
checkBlur();
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
165
|
+
if (!event.relatedTarget)
|
|
166
|
+
return checkBlur();
|
|
172
167
|
clearTimeout(blurTimer.current);
|
|
173
|
-
//
|
|
174
|
-
//
|
|
168
|
+
// A pointer's focus leaves before the click it lands with: the draft is published now, so a button pressed
|
|
169
|
+
// outside (a filter's Apply) reads the new value.
|
|
175
170
|
if (!within(event.relatedTarget))
|
|
176
171
|
commitBlur();
|
|
177
172
|
};
|
|
178
173
|
const changeOpen = (next, details) => {
|
|
179
|
-
if (next) {
|
|
180
|
-
restoreFocus.current = false;
|
|
181
|
-
setActive(seed());
|
|
182
|
-
}
|
|
183
174
|
setOpen(next, details);
|
|
184
175
|
if (!next)
|
|
185
176
|
checkBlur();
|
|
@@ -190,72 +181,64 @@ function DefaultDateField({ id, words, calendarIcon, value, onChange, onBlur, on
|
|
|
190
181
|
target.focus({ preventScroll: true });
|
|
191
182
|
}
|
|
192
183
|
};
|
|
193
|
-
const choose = (date,
|
|
194
|
-
const details = changeDetails('day-press', event);
|
|
195
|
-
restoreFocus.current = true;
|
|
184
|
+
const choose = (date, details) => {
|
|
196
185
|
setDraft(null);
|
|
197
|
-
//
|
|
198
|
-
//
|
|
186
|
+
// The keyboard goes back to the button before the day it was on is taken away, and before the caller hears the
|
|
187
|
+
// value: an enclosing dialog would see the focus fall to the page, and a caller may unmount the field.
|
|
199
188
|
returnToTrigger();
|
|
200
189
|
onChange(withTime && date ? withDate(value, date) : date, details);
|
|
201
190
|
changeOpen(false, details);
|
|
202
191
|
};
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
target?.isConnected &&
|
|
254
|
-
(!container || (container.isConnected && !container.hasAttribute('data-closed'))) &&
|
|
255
|
-
(focused === target || focused === document.body || focused === container)
|
|
256
|
-
? target
|
|
257
|
-
: false;
|
|
258
|
-
}, className: "date-field-popup", "aria-label": words.calendar(label || undefined), initialFocus: () => popup.current?.querySelector(`[data-date="${active}"]`) ?? true, children: [_jsxs("div", { className: "date-field-head", children: [_jsx("button", { type: "button", "aria-label": words.previousMonth, disabled: previous.slice(0, 7) === active.slice(0, 7) || previous.slice(0, 7) < bounds.min.slice(0, 7), onClick: () => setActive(clampDate(previous, bounds)), children: "\u2190" }), _jsx("span", { id: caption, "aria-live": "polite", "aria-atomic": "true", children: monthLabel(active, locale) }), _jsx("button", { type: "button", "aria-label": words.nextMonth, disabled: next.slice(0, 7) === active.slice(0, 7) || next.slice(0, 7) > bounds.max.slice(0, 7), onClick: () => setActive(clampDate(next, bounds)), children: "\u2192" })] }), _jsxs("table", { className: "date-field-calendar", role: "grid", "aria-labelledby": caption, children: [_jsx("thead", { children: _jsx("tr", { children: weekdays.map((day) => (_jsx("th", { scope: "col", "aria-label": day.long, children: day.short }, day.long))) }) }), _jsx("tbody", { children: Array.from({ length: 6 }, (_, week) => (_jsx("tr", { children: days.slice(week * 7, week * 7 + 7).map((day, index) => (_jsx("td", { "aria-selected": day.date === datePart, children: day.date && (_jsx("button", { type: "button", "data-date": day.date, "data-outside": !day.inMonth || undefined, "data-selected": day.date === datePart || undefined, "aria-current": day.date === today ? 'date' : undefined, disabled: day.disabled, tabIndex: day.date === active ? 0 : -1, "aria-label": dayName(day.date), onKeyDown: onDayKey, onClick: (event) => choose(day.date, event), children: Number(day.date.slice(8)) })) }, day.date ?? index))) }, week))) })] }), _jsxs("div", { className: "date-field-foot", children: [_jsx("button", { type: "button", onClick: (event) => choose('', event), children: words.clear }), _jsx("button", { type: "button", disabled: !dateWithinBounds(today, bounds), onClick: (event) => choose(today, event), children: words.today })] })] }) }) })] }) }));
|
|
192
|
+
const shut = disabled || !configuredBounds;
|
|
193
|
+
return (_jsxs("span", { ref: group, "data-slot": "date-field", "data-kind": withTime ? 'with-time' : undefined,
|
|
194
|
+
// The caller's class is a box's, and the box here is the text and its button together.
|
|
195
|
+
className: className, onFocus: () => {
|
|
196
|
+
ownedFocus.current = true;
|
|
197
|
+
}, onBlur: leave, children: [_jsx(Input, { id: id, ref: input, name: name, type: "text", value: shown, placeholder: placeholder ?? (withTime ? words.dateTimePattern : mask.hint), disabled: disabled, required: required, autoComplete: "off", spellCheck: false, "aria-required": required, "aria-label": label, "aria-invalid": invalid || bad || undefined, "aria-describedby": [describedBy, hint].filter(Boolean).join(' '),
|
|
198
|
+
/* React's own change, not UI SDK's `onValueChange`: that one hears the `input` event alone, and a value
|
|
199
|
+
put in the box without one (a browser's autofill, a script that sets it and says `change`) would be
|
|
200
|
+
shown and never reported. */
|
|
201
|
+
onChange: (event) => {
|
|
202
|
+
const text = event.target.value;
|
|
203
|
+
const said = changeDetails('input-change', event);
|
|
204
|
+
if (withTime)
|
|
205
|
+
return onChange(text, said);
|
|
206
|
+
setDraft(text);
|
|
207
|
+
onChange(readDate(text, mask) ?? text, said);
|
|
208
|
+
}, onKeyDown: (event) => {
|
|
209
|
+
if (event.altKey && event.key === 'ArrowDown') {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
event.stopPropagation();
|
|
212
|
+
if (configuredBounds && !disabled)
|
|
213
|
+
changeOpen(true, changeDetails('open-key', event));
|
|
214
|
+
}
|
|
215
|
+
else
|
|
216
|
+
onKeyDown?.(event);
|
|
217
|
+
} }), withTime && words.time && (_jsx("input", { type: "time", "data-slot": "date-field-time", "aria-label": words.time(label || undefined), disabled: disabled, value: (splitDateTime(value)?.time ?? '').slice(0, 5), onChange: (event) => {
|
|
218
|
+
const clock = event.target.value;
|
|
219
|
+
if (!clock)
|
|
220
|
+
return;
|
|
221
|
+
const day = isPickerDate(datePart) ? datePart : today;
|
|
222
|
+
onChange(`${day} ${clock}`, changeDetails('input-change', event));
|
|
223
|
+
} })), _jsxs("span", { id: hint, "data-slot": "date-field-hint", "data-kind": "visually-hidden", children: [withTime ? words.dateAndTimeFormat : words.dateFormat(mask.hint), " ", words.openWithKeys] }), _jsxs(Popover, { open: open && !shut, onOpenChange: (next, details) => {
|
|
224
|
+
// Escape hands the keyboard back to the button; a press elsewhere leaves it where the press put it.
|
|
225
|
+
if (!next && details.reason === 'escape-key')
|
|
226
|
+
returnToTrigger();
|
|
227
|
+
changeOpen(next, told(openReason(details.reason), details));
|
|
228
|
+
}, children: [_jsx(PopoverTrigger, { ref: trigger, "aria-label": words.chooseDate(label || undefined), disabled: shut, "data-variant": "quiet", children: calendarIcon }), _jsxs(PopoverContent, { ref: setPopup, "aria-label": words.calendar(label || undefined), "data-kind": "calendar", align: "end", sideOffset: 6, container: container ?? popupContainer(),
|
|
229
|
+
// The keyboard starts on the day, not on the month's arrows, and where it goes on a close is said above.
|
|
230
|
+
initialFocus: () => popup.current?.querySelector('[data-slot="calendar-day"][tabindex="0"]'), finalFocus: "none",
|
|
231
|
+
// The calendar is called what the caller's words call it. UI SDK names a popover by its button, which
|
|
232
|
+
// here would say "Choose a date" for the dialog too, so the name it adds is taken off what it draws.
|
|
233
|
+
render: (drawn) => _jsx("div", { ...drawn, "aria-labelledby": undefined }), children: [_jsxs(Calendar, { controller: month, value: isPickerDate(datePart) ? datePart : null, defaultMonth: seed().slice(0, 7), min: bounds.min === FIRST_DATE ? undefined : bounds.min, max: bounds.max === LAST_DATE ? undefined : bounds.max, locale: locale, timeZone: timezone, today: today, weekStartsOn: firstDay, onValueChange: (next, details) => {
|
|
234
|
+
if (typeof next === 'string')
|
|
235
|
+
choose(next, told('day-press', details));
|
|
236
|
+
}, children: [_jsx(CalendarPrevious, { "aria-label": words.previousMonth, children: _jsx(Caret, { to: "left" }) }), _jsx(CalendarHeading, {}), _jsx(CalendarNext, { "aria-label": words.nextMonth, children: _jsx(Caret, { to: "right" }) }), _jsxs(CalendarGrid, { children: [_jsx(CalendarWeekdays, { children: (index) => _jsx(CalendarWeekday, { index: index }) }), _jsx(CalendarWeeks, { children: (cell) => cell.date === datePart ? (_jsx(CalendarDay, { value: cell.date, onClick: (event) => choose(cell.date, changeDetails('day-press', event)), onKeyDown: (event) => {
|
|
237
|
+
if (event.key !== 'Enter' && event.key !== ' ')
|
|
238
|
+
return;
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
choose(cell.date, changeDetails('day-press', event));
|
|
241
|
+
} })) : (_jsx(CalendarDay, { value: cell.date })) })] })] }), _jsxs("div", { "data-slot": "action-bar", children: [_jsx(Button, { "data-variant": "quiet", "data-size": "sm", onClick: (event) => choose('', changeDetails('day-press', event)), children: words.clear }), _jsx(Button, { "data-variant": "quiet", "data-size": "sm", disabled: !dateWithinBounds(today, bounds), onClick: (event) => choose(today, changeDetails('day-press', event)), children: words.today })] })] })] })] }));
|
|
259
242
|
}
|
|
260
243
|
/* Slotted (UiKit.tsx): an App's control kit may draw its own in place of the default, with the same props. */
|
|
261
244
|
export const DateField = slotted('DateField', DefaultDateField, { onChange: [1, 'input-change'], onOpenChange: [1, 'implicit'] });
|