@infonomic/uikit 6.8.2 → 6.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/README.md +183 -19
- package/dist/components/accordion/accordion.js +5 -5
- package/dist/components/accordion/accordion.module.css +11 -1
- package/dist/components/accordion/accordion_module.css +3 -1
- package/dist/components/avatar/avatar.module.css +9 -4
- package/dist/components/avatar/avatar_module.css +3 -1
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.module.css +9 -4
- package/dist/components/badge/badge_module.css +3 -1
- package/dist/components/button/button-group.d.ts +1 -1
- package/dist/components/button/button-group.module.css +11 -1
- package/dist/components/button/button-group_module.css +4 -2
- package/dist/components/button/button.module.css +9 -4
- package/dist/components/button/button_module.css +3 -1
- package/dist/components/button/combo-button.d.ts +1 -1
- package/dist/components/button/combo-button.module.css +11 -1
- package/dist/components/button/combo-button_module.css +3 -1
- package/dist/components/button/control-buttons.module.css +11 -1
- package/dist/components/button/control-buttons_module.css +3 -1
- package/dist/components/button/copy-button.module.css +9 -4
- package/dist/components/button/copy-button_module.css +3 -1
- package/dist/components/button/index.d.ts +5 -5
- package/dist/components/card/card.module.css +9 -4
- package/dist/components/card/card_module.css +3 -1
- package/dist/components/chips/chip.module.css +9 -4
- package/dist/components/chips/chip_module.css +3 -1
- package/dist/components/container/container.module.css +9 -4
- package/dist/components/container/container_module.css +6 -4
- package/dist/components/dropdown/dropdown.js +11 -11
- package/dist/components/dropdown/dropdown.module.css +9 -4
- package/dist/components/dropdown/dropdown_module.css +3 -1
- package/dist/components/hamburger/hamburger.module.css +9 -4
- package/dist/components/hamburger/hamburger_module.css +3 -1
- package/dist/components/inputs/autocomplete.module.css +9 -4
- package/dist/components/inputs/autocomplete_module.css +3 -1
- package/dist/components/inputs/calendar.module.css +9 -4
- package/dist/components/inputs/calendar_module.css +4 -2
- package/dist/components/inputs/checkbox-group.module.css +9 -4
- package/dist/components/inputs/checkbox-group_module.css +3 -1
- package/dist/components/inputs/checkbox.module.css +9 -4
- package/dist/components/inputs/checkbox_module.css +3 -1
- package/dist/components/inputs/error-text.module.css +9 -4
- package/dist/components/inputs/error-text_module.css +3 -1
- package/dist/components/inputs/help-text.module.css +9 -4
- package/dist/components/inputs/help-text_module.css +3 -1
- package/dist/components/inputs/input-adornment.module.css +9 -4
- package/dist/components/inputs/input-adornment_module.css +3 -1
- package/dist/components/inputs/input-password.d.ts +18 -2
- package/dist/components/inputs/input-password.d.ts.map +1 -1
- package/dist/components/inputs/input-password.js +19 -11
- package/dist/components/inputs/input-password.module.css +55 -0
- package/dist/components/inputs/input-password.module.js +5 -0
- package/dist/components/inputs/input-password_module.css +25 -0
- package/dist/components/inputs/input.d.ts +1 -1
- package/dist/components/inputs/input.module.css +9 -4
- package/dist/components/inputs/input_module.css +3 -1
- package/dist/components/inputs/label.module.css +9 -4
- package/dist/components/inputs/label_module.css +3 -1
- package/dist/components/inputs/radio-group.d.ts +1 -1
- package/dist/components/inputs/radio-group.module.css +9 -4
- package/dist/components/inputs/radio-group_module.css +3 -1
- package/dist/components/inputs/select.module.css +9 -4
- package/dist/components/inputs/select_module.css +3 -1
- package/dist/components/inputs/text-area.module.css +9 -4
- package/dist/components/inputs/text-area_module.css +3 -1
- package/dist/components/notifications/alert.module.css +9 -4
- package/dist/components/notifications/alert_module.css +4 -2
- package/dist/components/notifications/toast.module.css +9 -4
- package/dist/components/notifications/toast_module.css +5 -3
- package/dist/components/pager/first-button.d.ts +1 -1
- package/dist/components/pager/hooks/usePagination.d.ts +1 -1
- package/dist/components/pager/last-button.d.ts +1 -1
- package/dist/components/pager/next-button.d.ts +1 -1
- package/dist/components/pager/number-button.d.ts +1 -1
- package/dist/components/pager/pagination.d.ts +7 -7
- package/dist/components/pager/pagination.module.css +9 -4
- package/dist/components/pager/pagination_module.css +4 -2
- package/dist/components/pager/previous-button.d.ts +1 -1
- package/dist/components/scroll-area/scroll-area.module.css +9 -4
- package/dist/components/scroll-area/scroll-area_module.css +3 -1
- package/dist/components/scroll-to-top/scroll-to-top.module.css +9 -3
- package/dist/components/scroll-to-top/scroll-to-top_module.css +4 -2
- package/dist/components/section/section.module.css +9 -4
- package/dist/components/section/section_module.css +3 -1
- package/dist/components/shimmer/shimmer.module.css +9 -4
- package/dist/components/shimmer/shimmer_module.css +3 -1
- package/dist/components/table/table.module.css +9 -4
- package/dist/components/table/table_module.css +3 -1
- package/dist/components/tabs/tabs.module.css +9 -4
- package/dist/components/tabs/tabs_module.css +3 -1
- package/dist/components/tooltip/tooltip.module.css +9 -4
- package/dist/components/tooltip/tooltip_module.css +3 -1
- package/dist/css-layers.d.ts +23 -0
- package/dist/css-layers.d.ts.map +1 -0
- package/dist/css-layers.js +14 -0
- package/dist/icons/icons.module.css +11 -1
- package/dist/icons/icons_module.css +3 -1
- package/dist/icons/stopwatch-icon.d.ts +1 -1
- package/dist/loaders/ellipses.module.css +9 -4
- package/dist/loaders/ellipses_module.css +3 -1
- package/dist/loaders/ring.module.css +9 -4
- package/dist/loaders/ring_module.css +3 -1
- package/dist/loaders/spinner.module.css +9 -4
- package/dist/loaders/spinner_module.css +3 -1
- package/dist/react.d.ts +14 -14
- package/dist/styles/components-vanilla.css +1 -1
- package/dist/styles/reset.css +1 -1
- package/dist/styles/styles.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/widgets/datepicker/datepicker.d.ts +42 -1
- package/dist/widgets/datepicker/datepicker.d.ts.map +1 -1
- package/dist/widgets/datepicker/datepicker.js +34 -4
- package/dist/widgets/datepicker/datepicker.module.css +21 -2
- package/dist/widgets/datepicker/datepicker.module.js +1 -0
- package/dist/widgets/datepicker/datepicker_module.css +7 -2
- package/dist/widgets/drawer/drawer.d.ts +4 -4
- package/dist/widgets/drawer/drawer.module.css +11 -1
- package/dist/widgets/drawer/drawer_module.css +4 -2
- package/dist/widgets/modal/modal-context.d.ts +20 -0
- package/dist/widgets/modal/modal-context.d.ts.map +1 -0
- package/dist/widgets/modal/modal-context.js +4 -0
- package/dist/widgets/modal/modal-header.d.ts +1 -1
- package/dist/widgets/modal/modal-header.d.ts.map +1 -1
- package/dist/widgets/modal/modal-header.js +23 -1
- package/dist/widgets/modal/modal.d.ts +13 -8
- package/dist/widgets/modal/modal.d.ts.map +1 -1
- package/dist/widgets/modal/modal.js +8 -4
- package/dist/widgets/modal/modal.module.css +11 -1
- package/dist/widgets/modal/modal_module.css +5 -3
- package/dist/widgets/timeline/timeline.module.css +9 -4
- package/dist/widgets/timeline/timeline_module.css +3 -1
- package/package.json +45 -32
- package/src/components/accordion/accordion.module.css +11 -1
- package/src/components/avatar/avatar.module.css +9 -4
- package/src/components/badge/badge.module.css +9 -4
- package/src/components/button/button-group.module.css +11 -1
- package/src/components/button/button.module.css +9 -4
- package/src/components/button/combo-button.module.css +11 -1
- package/src/components/button/control-buttons.module.css +11 -1
- package/src/components/button/copy-button.module.css +9 -4
- package/src/components/card/card.module.css +9 -4
- package/src/components/chips/chip.module.css +9 -4
- package/src/components/container/container.module.css +9 -4
- package/src/components/dropdown/dropdown.module.css +9 -4
- package/src/components/hamburger/hamburger.module.css +9 -4
- package/src/components/inputs/autocomplete.module.css +9 -4
- package/src/components/inputs/calendar.module.css +9 -4
- package/src/components/inputs/checkbox-group.module.css +9 -4
- package/src/components/inputs/checkbox.module.css +9 -4
- package/src/components/inputs/error-text.module.css +9 -4
- package/src/components/inputs/help-text.module.css +9 -4
- package/src/components/inputs/input-adornment.module.css +9 -4
- package/src/components/inputs/input-password.module.css +55 -0
- package/src/components/inputs/input-password.tsx +49 -7
- package/src/components/inputs/input.module.css +9 -4
- package/src/components/inputs/label.module.css +9 -4
- package/src/components/inputs/radio-group.module.css +9 -4
- package/src/components/inputs/select.module.css +9 -4
- package/src/components/inputs/text-area.module.css +9 -4
- package/src/components/notifications/alert.module.css +9 -4
- package/src/components/notifications/toast.module.css +9 -4
- package/src/components/pager/pagination.module.css +9 -4
- package/src/components/scroll-area/scroll-area.module.css +9 -4
- package/src/components/scroll-to-top/scroll-to-top.module.css +9 -3
- package/src/components/section/section.module.css +9 -4
- package/src/components/shimmer/shimmer.module.css +9 -4
- package/src/components/table/table.module.css +9 -4
- package/src/components/tabs/tabs.module.css +9 -4
- package/src/components/tooltip/tooltip.module.css +9 -4
- package/src/css-layers.ts +34 -0
- package/src/icons/icons.module.css +11 -1
- package/src/loaders/ellipses.module.css +9 -4
- package/src/loaders/ring.module.css +9 -4
- package/src/loaders/spinner.module.css +9 -4
- package/src/styles/base/animations.css +12 -0
- package/src/styles/base/base.css +12 -0
- package/src/styles/base/borders.css +12 -0
- package/src/styles/base/breakpoints.css +12 -0
- package/src/styles/base/colors.css +12 -0
- package/src/styles/base/opacity.css +12 -0
- package/src/styles/base/shadows.css +12 -0
- package/src/styles/base/size.css +12 -0
- package/src/styles/base/spacing.css +12 -0
- package/src/styles/base/transitions.css +12 -0
- package/src/styles/base/typography.css +12 -0
- package/src/styles/base/z-index.css +12 -0
- package/src/styles/components/components.css +12 -0
- package/src/styles/components/fade-in-lift.css +27 -13
- package/src/styles/components/hamburger.css +11 -6
- package/src/styles/components/loaders.css +168 -154
- package/src/styles/functional/README.md +18 -18
- package/src/styles/functional/borders.css +12 -0
- package/src/styles/functional/colors.css +12 -0
- package/src/styles/functional/functional.css +12 -0
- package/src/styles/functional/grid-flex.css +12 -0
- package/src/styles/functional/shadcn-compat.css +12 -0
- package/src/styles/functional/surfaces.css +12 -0
- package/src/styles/functional/typography.css +12 -0
- package/src/styles/local-fonts.css +12 -0
- package/src/styles/reset.css +18 -0
- package/src/styles/styles.css +9 -4
- package/src/styles/theme/autofill.css +12 -0
- package/src/styles/theme/defaults.css +12 -0
- package/src/styles/theme/scrollers.css +12 -0
- package/src/styles/theme/theme.css +12 -0
- package/src/styles/typography/fonts.css +12 -0
- package/src/styles/typography/prose.css +12 -0
- package/src/styles/typography.css +12 -0
- package/src/styles/utils/scroll-layout-shift.css +12 -0
- package/src/styles/utils/utility-classes.css +12 -0
- package/src/styles/utils/utils.css +12 -0
- package/src/widgets/datepicker/datepicker.module.css +21 -2
- package/src/widgets/datepicker/datepicker.tsx +97 -4
- package/src/widgets/drawer/drawer.module.css +11 -1
- package/src/widgets/modal/modal-context.ts +23 -0
- package/src/widgets/modal/modal-header.tsx +29 -2
- package/src/widgets/modal/modal.module.css +11 -1
- package/src/widgets/modal/modal.tsx +15 -6
- package/src/widgets/timeline/timeline.module.css +9 -4
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
12
|
+
|
|
1
13
|
/*
|
|
2
14
|
* Adapted from Tailwind typography plugin
|
|
3
15
|
* Portions copyright (c) Tailwind Labs, Inc.
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
12
|
+
|
|
1
13
|
@import "./typography/fonts.css";
|
|
2
14
|
@import "./typography/prose.css";
|
|
3
15
|
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
12
|
+
|
|
1
13
|
@layer infonomic-utilities {
|
|
2
14
|
.fix-scroll-layout-shift-right {
|
|
3
15
|
padding-right: var(--removed-body-scroll-bar-size);
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
12
|
+
|
|
1
13
|
@import "./utility-classes.css";
|
|
2
14
|
@import "./scroll-layout-shift.css";
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
@layer
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
2
12
|
|
|
3
13
|
@layer infonomic-components {
|
|
4
14
|
.container,
|
|
@@ -13,10 +23,19 @@
|
|
|
13
23
|
width: 100%;
|
|
14
24
|
}
|
|
15
25
|
|
|
26
|
+
/* Base UI's Positioner is the absolutely-positioned element, so it is the
|
|
27
|
+
one that can take part in z-index stacking. The Popup inside it is
|
|
28
|
+
`position: static`, where a z-index is inert — which is why the calendar
|
|
29
|
+
lost to any positioned ancestor above it in the tree, most visibly by
|
|
30
|
+
rendering behind a Modal. */
|
|
31
|
+
.positioner,
|
|
32
|
+
:global(.infonomic-datepicker-positioner) {
|
|
33
|
+
z-index: 50;
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
.content,
|
|
17
37
|
:global(.infonomic-datepicker-content) {
|
|
18
38
|
width: 100%;
|
|
19
|
-
z-index: 50;
|
|
20
39
|
border-radius: 4px;
|
|
21
40
|
padding-top: var(--spacing-16);
|
|
22
41
|
padding-bottom: var(--spacing-8);
|
|
@@ -25,6 +25,24 @@ import { CloseIcon } from '../../icons/close-icon.js'
|
|
|
25
25
|
import styles from './datepicker.module.css'
|
|
26
26
|
import type { Intent, Size, Variant } from '../../components/inputs/@types/input.js'
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The selection as the editor made it: a calendar day and a clock reading,
|
|
30
|
+
* with no instant attached.
|
|
31
|
+
*
|
|
32
|
+
* `onDateChange` reports a `Date`, which is an instant, and building one from a
|
|
33
|
+
* wall time goes through `setHours` — so on the two days a year the clocks
|
|
34
|
+
* change, the instant is not the time that was picked. A spring-forward 02:30
|
|
35
|
+
* comes back as 03:30, and an ambiguous autumn 01:30 silently resolves to the
|
|
36
|
+
* earlier of its two instants. Callers that must reject or disambiguate those
|
|
37
|
+
* cases need the wall time itself, which is what this carries.
|
|
38
|
+
*/
|
|
39
|
+
export interface DatePickerWallTime {
|
|
40
|
+
/** Calendar day as `YYYY-MM-DD`. */
|
|
41
|
+
date: string
|
|
42
|
+
/** Clock reading as `HH:mm`, 24-hour. */
|
|
43
|
+
time: string
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
export interface DatePickerProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
29
47
|
id: string
|
|
30
48
|
name: string
|
|
@@ -32,6 +50,23 @@ export interface DatePickerProps extends React.InputHTMLAttributes<HTMLInputElem
|
|
|
32
50
|
required?: boolean
|
|
33
51
|
initialValue?: Date | null
|
|
34
52
|
mode?: 'date' | 'datetime'
|
|
53
|
+
/**
|
|
54
|
+
* Earliest selectable day. Days before it are disabled in the calendar and
|
|
55
|
+
* the month navigation will not go back past its month.
|
|
56
|
+
*
|
|
57
|
+
* Day granularity only — the day containing `minDate` stays selectable in
|
|
58
|
+
* full, and in `datetime` mode every slot in the time list remains offered.
|
|
59
|
+
* A caller that needs a cutoff finer than a day has to enforce it itself.
|
|
60
|
+
*/
|
|
61
|
+
minDate?: Date
|
|
62
|
+
/**
|
|
63
|
+
* Latest selectable day, the mirror of `minDate`: days after it are disabled
|
|
64
|
+
* and the month navigation will not go forward past its month. Takes
|
|
65
|
+
* precedence over `yearsInFuture`, which otherwise sets the upper bound.
|
|
66
|
+
*
|
|
67
|
+
* Day granularity only, on the same terms as `minDate`.
|
|
68
|
+
*/
|
|
69
|
+
maxDate?: Date
|
|
35
70
|
yearsInFuture?: number
|
|
36
71
|
yearsInPast?: number
|
|
37
72
|
variant?: Variant
|
|
@@ -47,6 +82,13 @@ export interface DatePickerProps extends React.InputHTMLAttributes<HTMLInputElem
|
|
|
47
82
|
ariaLabelForClear?: string
|
|
48
83
|
onClear?: () => void
|
|
49
84
|
onDateChange?: (value: Date | null) => void
|
|
85
|
+
/**
|
|
86
|
+
* Fired alongside `onDateChange` with the day and clock reading the editor
|
|
87
|
+
* actually selected, before any instant is derived from them. Optional and
|
|
88
|
+
* additive — callers that are happy with the `Date` can ignore it entirely.
|
|
89
|
+
* Reports `null` when the selection is cleared.
|
|
90
|
+
*/
|
|
91
|
+
onWallTimeChange?: (wall: DatePickerWallTime | null) => void
|
|
50
92
|
validatorFn?: (value: Date) => {
|
|
51
93
|
valid: boolean
|
|
52
94
|
value: Date
|
|
@@ -61,6 +103,8 @@ export function DatePicker({
|
|
|
61
103
|
required,
|
|
62
104
|
initialValue,
|
|
63
105
|
mode = 'datetime',
|
|
106
|
+
minDate,
|
|
107
|
+
maxDate,
|
|
64
108
|
yearsInFuture = 1,
|
|
65
109
|
yearsInPast = 10,
|
|
66
110
|
variant,
|
|
@@ -72,6 +116,7 @@ export function DatePicker({
|
|
|
72
116
|
contentClassName,
|
|
73
117
|
onClear = () => {},
|
|
74
118
|
onDateChange = () => {},
|
|
119
|
+
onWallTimeChange,
|
|
75
120
|
validatorFn,
|
|
76
121
|
helpText,
|
|
77
122
|
errorText,
|
|
@@ -81,7 +126,6 @@ export function DatePicker({
|
|
|
81
126
|
...rest
|
|
82
127
|
}: DatePickerProps): React.JSX.Element {
|
|
83
128
|
const [isOpen, setIsOpen] = useState(false)
|
|
84
|
-
const [time, setTime] = useState<string>('08:00')
|
|
85
129
|
const [date, setDate] = useState<Date | null>(() => {
|
|
86
130
|
if (initialValue) {
|
|
87
131
|
return initialValue
|
|
@@ -91,6 +135,11 @@ export function DatePicker({
|
|
|
91
135
|
}
|
|
92
136
|
return null
|
|
93
137
|
})
|
|
138
|
+
// Seeded from the incoming date so the clock the widget holds agrees with the
|
|
139
|
+
// date it is showing. Declared after `date` for that reason. Previously this
|
|
140
|
+
// always started at 08:00, so picking a different day on a picker opened at
|
|
141
|
+
// 17:56 silently moved the value to 08:00.
|
|
142
|
+
const [time, setTime] = useState<string>(() => (date != null ? format(date, 'HH:mm') : '08:00'))
|
|
94
143
|
const [month, setMonth] = useState<Date | null>(date)
|
|
95
144
|
const calendarRef = useRef<HTMLDivElement | null>(null)
|
|
96
145
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
@@ -102,6 +151,7 @@ export function DatePicker({
|
|
|
102
151
|
}
|
|
103
152
|
setDate(null)
|
|
104
153
|
onDateChange(null)
|
|
154
|
+
emitWallTime(null, time)
|
|
105
155
|
onClear()
|
|
106
156
|
}
|
|
107
157
|
|
|
@@ -111,6 +161,26 @@ export function DatePicker({
|
|
|
111
161
|
}
|
|
112
162
|
}
|
|
113
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Report the selection as a wall time. `clock` is passed explicitly wherever
|
|
166
|
+
* the editor's chosen clock reading is known independently of `day`, because
|
|
167
|
+
* `day` has already been through `setHours` by then and cannot be trusted to
|
|
168
|
+
* still say what was picked.
|
|
169
|
+
*/
|
|
170
|
+
const emitWallTime = (day: Date | null, clock: string): void => {
|
|
171
|
+
if (onWallTimeChange == null) return
|
|
172
|
+
onWallTimeChange(day == null ? null : { date: format(day, 'yyyy-MM-dd'), time: clock })
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Two separate matchers, never one `{ before, after }` object: that shape is
|
|
176
|
+
// react-day-picker's DateInterval and matches the days *between* the two
|
|
177
|
+
// bounds — the exact inverse of an allowed window. An array of matchers is
|
|
178
|
+
// OR'd, so each bound disables its own side.
|
|
179
|
+
const disabledDays = [
|
|
180
|
+
...(minDate == null ? [] : [{ before: minDate }]),
|
|
181
|
+
...(maxDate == null ? [] : [{ after: maxDate }]),
|
|
182
|
+
]
|
|
183
|
+
|
|
114
184
|
const handleOnKeyDown = (e: React.KeyboardEvent<HTMLInputElement>): void => {
|
|
115
185
|
if (e.key === 'ArrowDown') {
|
|
116
186
|
e.preventDefault()
|
|
@@ -132,6 +202,7 @@ export function DatePicker({
|
|
|
132
202
|
) {
|
|
133
203
|
hasInitialized.current = true
|
|
134
204
|
onDateChange(date)
|
|
205
|
+
emitWallTime(date, time)
|
|
135
206
|
}
|
|
136
207
|
})
|
|
137
208
|
|
|
@@ -205,7 +276,10 @@ export function DatePicker({
|
|
|
205
276
|
<span className="sr-only">Select date</span>
|
|
206
277
|
</Popover.Trigger>
|
|
207
278
|
<Popover.Portal>
|
|
208
|
-
<Popover.Positioner
|
|
279
|
+
<Popover.Positioner
|
|
280
|
+
sideOffset={5}
|
|
281
|
+
className={cx('infonomic-datepicker-positioner', styles.positioner)}
|
|
282
|
+
>
|
|
209
283
|
<Popover.Popup
|
|
210
284
|
className={cx('infonomic-datepicker-content', styles.content, contentClassName)}
|
|
211
285
|
>
|
|
@@ -225,6 +299,10 @@ export function DatePicker({
|
|
|
225
299
|
onMonthChange={setMonth}
|
|
226
300
|
onSelect={(selectedDate: Date) => {
|
|
227
301
|
if (selectedDate) {
|
|
302
|
+
// Read the day before `setHours` mutates it: the
|
|
303
|
+
// editor picked this day at the clock reading already
|
|
304
|
+
// held in `time`, and normalization can move both.
|
|
305
|
+
const day = new Date(selectedDate.getTime())
|
|
228
306
|
const [hours, minutes] = time.split(':')
|
|
229
307
|
selectedDate.setHours(
|
|
230
308
|
Number.parseInt(hours, 10),
|
|
@@ -233,10 +311,15 @@ export function DatePicker({
|
|
|
233
311
|
setDate(selectedDate)
|
|
234
312
|
setMonth(selectedDate)
|
|
235
313
|
handleOnDateChange(selectedDate)
|
|
314
|
+
emitWallTime(day, time)
|
|
236
315
|
}
|
|
237
316
|
}}
|
|
238
|
-
|
|
239
|
-
|
|
317
|
+
disabled={disabledDays.length > 0 ? disabledDays : undefined}
|
|
318
|
+
// Clamp the navigable range to the bounds as well as
|
|
319
|
+
// disabling the days, so the caller is not offered months
|
|
320
|
+
// in which nothing can be picked.
|
|
321
|
+
startMonth={minDate ?? new Date(new Date().getFullYear() - yearsInPast, 0)}
|
|
322
|
+
endMonth={maxDate ?? new Date(new Date().getFullYear() + yearsInFuture, 0)}
|
|
240
323
|
// TODO: add props
|
|
241
324
|
// disabled={(date) =>
|
|
242
325
|
// Number(date) < Date.now() - 1000 * 60 * 60 * 24 ||
|
|
@@ -271,6 +354,10 @@ export function DatePicker({
|
|
|
271
354
|
)
|
|
272
355
|
setDate(newDate)
|
|
273
356
|
handleOnDateChange(newDate)
|
|
357
|
+
// `date`, not `newDate` — the grid label is
|
|
358
|
+
// what was clicked, and `newDate` may have
|
|
359
|
+
// been normalized away from it.
|
|
360
|
+
emitWallTime(date, timeValue)
|
|
274
361
|
}
|
|
275
362
|
}}
|
|
276
363
|
>
|
|
@@ -307,9 +394,14 @@ export function DatePicker({
|
|
|
307
394
|
)}
|
|
308
395
|
onClick={() => {
|
|
309
396
|
const today = new Date()
|
|
397
|
+
const clock = format(today, 'HH:mm')
|
|
310
398
|
setDate(today)
|
|
311
399
|
setMonth(today)
|
|
400
|
+
// Keep the held clock in step with the value, so a
|
|
401
|
+
// subsequent day pick preserves this time.
|
|
402
|
+
setTime(clock)
|
|
312
403
|
handleOnDateChange(today)
|
|
404
|
+
emitWallTime(today, clock)
|
|
313
405
|
}}
|
|
314
406
|
>
|
|
315
407
|
Today
|
|
@@ -339,6 +431,7 @@ export function DatePicker({
|
|
|
339
431
|
onClick={() => {
|
|
340
432
|
setIsOpen(false)
|
|
341
433
|
handleOnDateChange(date)
|
|
434
|
+
emitWallTime(date, time)
|
|
342
435
|
}}
|
|
343
436
|
>
|
|
344
437
|
Select
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
@layer
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
2
12
|
|
|
3
13
|
@layer infonomic-components {
|
|
4
14
|
/* Backdrop overlay (replaces previous Overlay component) */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared between `Modal` and its slots. Lives in its own module because
|
|
7
|
+
* `Modal` renders `Modal.Header` while `Modal.Header` needs the context —
|
|
8
|
+
* importing it from `modal.tsx` would make the two modules circular.
|
|
9
|
+
*/
|
|
10
|
+
export const ModalContext = createContext<{
|
|
11
|
+
onDismiss?: () => void
|
|
12
|
+
/**
|
|
13
|
+
* Id the dialog points `aria-labelledby` at. `Modal.Header` puts it on the
|
|
14
|
+
* heading it finds among its children, which is what gives the dialog its
|
|
15
|
+
* accessible name — without it a screen reader announces the modal as an
|
|
16
|
+
* unnamed "dialog".
|
|
17
|
+
*
|
|
18
|
+
* A dangling reference degrades safely: name computation ignores an
|
|
19
|
+
* `aria-labelledby` that resolves to nothing and falls through, so a modal
|
|
20
|
+
* with no header is no worse off than before.
|
|
21
|
+
*/
|
|
22
|
+
headingId?: string
|
|
23
|
+
}>({})
|
|
@@ -1,16 +1,42 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useContext } from 'react'
|
|
4
5
|
|
|
5
6
|
import cx from 'clsx'
|
|
6
7
|
|
|
7
8
|
import styles from './modal.module.css'
|
|
9
|
+
import { ModalContext } from './modal-context.js'
|
|
8
10
|
|
|
9
11
|
type ModalHeaderIntrinsicProps = React.JSX.IntrinsicElements['div']
|
|
10
12
|
export interface ModalHeaderProps extends ModalHeaderIntrinsicProps {
|
|
11
13
|
className?: string
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
const HEADING_TAGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Give the dialog's heading the id that `Modal` points `aria-labelledby` at.
|
|
20
|
+
*
|
|
21
|
+
* The heading is found rather than declared, so no caller has to change: a
|
|
22
|
+
* header is conventionally written as a heading element optionally followed by
|
|
23
|
+
* a close button. Only the first heading is labelled, and only direct children
|
|
24
|
+
* are searched — a header deep enough to hide its heading is better served by
|
|
25
|
+
* `Modal`'s explicit `ariaLabel`.
|
|
26
|
+
*
|
|
27
|
+
* `Modal.Header` owns the heading's `id` for this reason; an id set by a caller
|
|
28
|
+
* is replaced, because the dialog's name depends on this one resolving.
|
|
29
|
+
*/
|
|
30
|
+
function labelHeading(children: React.ReactNode, headingId: string): React.ReactNode {
|
|
31
|
+
let labelled = false
|
|
32
|
+
return React.Children.map(children, (child) => {
|
|
33
|
+
if (labelled || !React.isValidElement(child)) return child
|
|
34
|
+
if (typeof child.type !== 'string' || !HEADING_TAGS.has(child.type)) return child
|
|
35
|
+
labelled = true
|
|
36
|
+
return React.cloneElement(child as React.ReactElement<{ id?: string }>, { id: headingId })
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
14
40
|
export const ModalHeader = function ModalHeader({
|
|
15
41
|
ref,
|
|
16
42
|
children,
|
|
@@ -19,10 +45,11 @@ export const ModalHeader = function ModalHeader({
|
|
|
19
45
|
}: ModalHeaderProps & {
|
|
20
46
|
ref?: React.RefObject<HTMLDivElement>
|
|
21
47
|
}) {
|
|
48
|
+
const { headingId } = useContext(ModalContext)
|
|
22
49
|
const classes = cx('infonomic-modal-header', styles['modal-header'], 'prose', className)
|
|
23
50
|
return (
|
|
24
51
|
<div style={{ overflowWrap: 'anywhere' }} ref={ref} {...rest} className={classes}>
|
|
25
|
-
{children}
|
|
52
|
+
{headingId == null ? children : labelHeading(children, headingId)}
|
|
26
53
|
</div>
|
|
27
54
|
)
|
|
28
55
|
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
@layer
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
|
+
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
6
|
+
infonomic-typography,
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
2
12
|
|
|
3
13
|
@layer infonomic-components {
|
|
4
14
|
/* Backdrop overlay */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import type React from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback, useId, useRef, useState } from 'react'
|
|
5
5
|
|
|
6
6
|
import { Dialog } from '@base-ui/react/dialog'
|
|
7
7
|
import cx from 'clsx'
|
|
@@ -10,19 +10,24 @@ import styles from './modal.module.css'
|
|
|
10
10
|
import { ModalActions } from './modal-actions'
|
|
11
11
|
import { ModalContainer } from './modal-container'
|
|
12
12
|
import { ModalContent } from './modal-content'
|
|
13
|
+
import { ModalContext } from './modal-context.js'
|
|
13
14
|
import { ModalHeader } from './modal-header'
|
|
14
15
|
|
|
16
|
+
export { ModalContext }
|
|
17
|
+
|
|
15
18
|
export interface ModalProps {
|
|
16
19
|
isOpen?: boolean
|
|
17
20
|
onDismiss?: () => void
|
|
18
21
|
closeOnOverlayClick?: boolean
|
|
22
|
+
/**
|
|
23
|
+
* Accessible name for the dialog, for modals that carry no `Modal.Header`
|
|
24
|
+
* heading to borrow one from. Modals that do have a heading need nothing
|
|
25
|
+
* here — see `ModalContext.headingId`.
|
|
26
|
+
*/
|
|
27
|
+
ariaLabel?: string
|
|
19
28
|
children?: React.ReactNode
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
export const ModalContext = createContext<{
|
|
23
|
-
onDismiss?: () => void
|
|
24
|
-
}>({})
|
|
25
|
-
|
|
26
31
|
export type UseModalProps = ReturnType<typeof useModal>
|
|
27
32
|
|
|
28
33
|
export function useModal(): {
|
|
@@ -53,8 +58,10 @@ function Modal({
|
|
|
53
58
|
isOpen,
|
|
54
59
|
onDismiss,
|
|
55
60
|
closeOnOverlayClick,
|
|
61
|
+
ariaLabel,
|
|
56
62
|
children,
|
|
57
63
|
}: ModalProps): React.JSX.Element {
|
|
64
|
+
const headingId = useId()
|
|
58
65
|
// Overlay dismissal is handled here rather than by Base UI's outside-press
|
|
59
66
|
// detection. `Dialog.Popup` below is the full-viewport flex box that centres
|
|
60
67
|
// the dialog, not the dialog box itself, so a click on the empty space around
|
|
@@ -83,7 +90,7 @@ function Modal({
|
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
return (
|
|
86
|
-
<ModalContext.Provider value={{ onDismiss }}>
|
|
93
|
+
<ModalContext.Provider value={{ onDismiss, headingId }}>
|
|
87
94
|
<Dialog.Root
|
|
88
95
|
open={isOpen}
|
|
89
96
|
onOpenChange={(open) => {
|
|
@@ -98,6 +105,8 @@ function Modal({
|
|
|
98
105
|
<Dialog.Backdrop className={cx('infonomic-modal-backdrop', styles.backdrop)} />
|
|
99
106
|
<Dialog.Popup
|
|
100
107
|
className={cx('infonomic-modal-wrapper', styles['modal-wrapper'])}
|
|
108
|
+
aria-label={ariaLabel}
|
|
109
|
+
aria-labelledby={ariaLabel == null ? headingId : undefined}
|
|
101
110
|
onPointerDown={handleOverlayPointerDown}
|
|
102
111
|
onClick={handleOverlayClick}
|
|
103
112
|
>
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
@layer
|
|
2
|
-
infonomic-
|
|
3
|
-
|
|
1
|
+
@layer base,
|
|
2
|
+
infonomic-base,
|
|
3
|
+
theme,
|
|
4
4
|
infonomic-theme,
|
|
5
|
+
infonomic-functional,
|
|
5
6
|
infonomic-typography,
|
|
6
|
-
|
|
7
|
+
components,
|
|
8
|
+
infonomic-components,
|
|
9
|
+
overrides,
|
|
10
|
+
infonomic-utilities,
|
|
11
|
+
utilities;
|
|
7
12
|
|
|
8
13
|
@layer infonomic-components {
|
|
9
14
|
.timeline,
|