@cratis/components 4.39.5 → 4.40.1
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/compat-manifest.json +13 -13
- package/dist/esm/Chat/Kit/ChatComposer.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/ChatComposer.js +14 -7
- package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.d.ts +3 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.d.ts.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js +2 -1
- package/dist/esm/Chat/Kit/Mentions/MentionSuggestions.js.map +1 -1
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.d.ts +9 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.d.ts.map +1 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.js +4 -0
- package/dist/esm/Chat/Kit/Mentions/mentionOptionId.js.map +1 -0
- package/dist/esm/Common/DatePickerButtonBar.d.ts +15 -0
- package/dist/esm/Common/DatePickerButtonBar.d.ts.map +1 -0
- package/dist/esm/Common/DatePickerButtonBar.js +17 -0
- package/dist/esm/Common/DatePickerButtonBar.js.map +1 -0
- package/dist/esm/Common/DatePickerCalendar.d.ts +8 -0
- package/dist/esm/Common/DatePickerCalendar.d.ts.map +1 -0
- package/dist/esm/Common/DatePickerCalendar.js +29 -0
- package/dist/esm/Common/DatePickerCalendar.js.map +1 -0
- package/dist/esm/Common/DatePickerDateInput.d.ts +14 -0
- package/dist/esm/Common/DatePickerDateInput.d.ts.map +1 -0
- package/dist/esm/Common/DatePickerDateInput.js +9 -0
- package/dist/esm/Common/DatePickerDateInput.js.map +1 -0
- package/dist/esm/Common/DatePickerGroup.d.ts +21 -0
- package/dist/esm/Common/DatePickerGroup.d.ts.map +1 -0
- package/dist/esm/Common/DatePickerGroup.js +10 -0
- package/dist/esm/Common/DatePickerGroup.js.map +1 -0
- package/dist/esm/Common/DatePickerInputImplementation.d.ts +1 -1
- package/dist/esm/Common/DatePickerInputImplementation.d.ts.map +1 -1
- package/dist/esm/Common/DatePickerInputImplementation.js +35 -91
- package/dist/esm/Common/DatePickerInputImplementation.js.map +1 -1
- package/dist/esm/Common/DatePickerPopover.d.ts +12 -0
- package/dist/esm/Common/DatePickerPopover.d.ts.map +1 -0
- package/dist/esm/Common/DatePickerPopover.js +11 -0
- package/dist/esm/Common/DatePickerPopover.js.map +1 -0
- package/dist/esm/Common/datePickerStateAttributes.d.ts +38 -0
- package/dist/esm/Common/datePickerStateAttributes.d.ts.map +1 -0
- package/dist/esm/Common/datePickerStateAttributes.js +26 -0
- package/dist/esm/Common/datePickerStateAttributes.js.map +1 -0
- package/dist/esm/Common/datePickerValues.d.ts +11 -0
- package/dist/esm/Common/datePickerValues.d.ts.map +1 -0
- package/dist/esm/Common/datePickerValues.js +23 -0
- package/dist/esm/Common/datePickerValues.js.map +1 -0
- package/dist/esm/Common/toolbarFocusQueries.d.ts +13 -0
- package/dist/esm/Common/toolbarFocusQueries.d.ts.map +1 -0
- package/dist/esm/Common/toolbarFocusQueries.js +46 -0
- package/dist/esm/Common/toolbarFocusQueries.js.map +1 -0
- package/dist/esm/Common/toolbarNavigationCandidates.d.ts +7 -0
- package/dist/esm/Common/toolbarNavigationCandidates.d.ts.map +1 -0
- package/dist/esm/Common/toolbarNavigationCandidates.js +44 -0
- package/dist/esm/Common/toolbarNavigationCandidates.js.map +1 -0
- package/dist/esm/Common/toolbarTabStop.d.ts +28 -0
- package/dist/esm/Common/toolbarTabStop.d.ts.map +1 -0
- package/dist/esm/Common/toolbarTabStop.js +94 -0
- package/dist/esm/Common/toolbarTabStop.js.map +1 -0
- package/dist/esm/Common/useDatePickerState.d.ts +591 -0
- package/dist/esm/Common/useDatePickerState.d.ts.map +1 -0
- package/dist/esm/Common/useDatePickerState.js +78 -0
- package/dist/esm/Common/useDatePickerState.js.map +1 -0
- package/dist/esm/Common/useMicrotaskScheduler.d.ts +3 -0
- package/dist/esm/Common/useMicrotaskScheduler.d.ts.map +1 -0
- package/dist/esm/Common/useMicrotaskScheduler.js +17 -0
- package/dist/esm/Common/useMicrotaskScheduler.js.map +1 -0
- package/dist/esm/Common/useToolbarKeyboardNavigation.d.ts +1 -2
- package/dist/esm/Common/useToolbarKeyboardNavigation.d.ts.map +1 -1
- package/dist/esm/Common/useToolbarKeyboardNavigation.js +12 -211
- package/dist/esm/Common/useToolbarKeyboardNavigation.js.map +1 -1
- package/dist/esm/Common/useToolbarTabStop.d.ts +9 -0
- package/dist/esm/Common/useToolbarTabStop.d.ts.map +1 -0
- package/dist/esm/Common/useToolbarTabStop.js +81 -0
- package/dist/esm/Common/useToolbarTabStop.js.map +1 -0
- package/dist/esm/Dropdown/ComboBoxCommitBridge.d.ts +13 -0
- package/dist/esm/Dropdown/ComboBoxCommitBridge.d.ts.map +1 -0
- package/dist/esm/Dropdown/ComboBoxCommitBridge.js +16 -0
- package/dist/esm/Dropdown/ComboBoxCommitBridge.js.map +1 -0
- package/dist/esm/Dropdown/DropdownBranchProps.d.ts +10 -0
- package/dist/esm/Dropdown/DropdownBranchProps.d.ts.map +1 -0
- package/dist/esm/Dropdown/DropdownBranchProps.js +4 -0
- package/dist/esm/Dropdown/DropdownBranchProps.js.map +1 -0
- package/dist/esm/Dropdown/DropdownImplementation.d.ts +1 -2
- package/dist/esm/Dropdown/DropdownImplementation.d.ts.map +1 -1
- package/dist/esm/Dropdown/DropdownImplementation.js +16 -192
- package/dist/esm/Dropdown/DropdownImplementation.js.map +1 -1
- package/dist/esm/Dropdown/DropdownOptionLists.d.ts +15 -0
- package/dist/esm/Dropdown/DropdownOptionLists.d.ts.map +1 -0
- package/dist/esm/Dropdown/DropdownOptionLists.js +12 -0
- package/dist/esm/Dropdown/DropdownOptionLists.js.map +1 -0
- package/dist/esm/Dropdown/DropdownParts.d.ts +46 -0
- package/dist/esm/Dropdown/DropdownParts.d.ts.map +1 -0
- package/dist/esm/Dropdown/DropdownParts.js +14 -0
- package/dist/esm/Dropdown/DropdownParts.js.map +1 -0
- package/dist/esm/Dropdown/FilterDropdown.d.ts +7 -0
- package/dist/esm/Dropdown/FilterDropdown.d.ts.map +1 -0
- package/dist/esm/Dropdown/FilterDropdown.js +31 -0
- package/dist/esm/Dropdown/FilterDropdown.js.map +1 -0
- package/dist/esm/Dropdown/MultipleSelectDropdown.d.ts +4 -0
- package/dist/esm/Dropdown/MultipleSelectDropdown.d.ts.map +1 -0
- package/dist/esm/Dropdown/MultipleSelectDropdown.js +23 -0
- package/dist/esm/Dropdown/MultipleSelectDropdown.js.map +1 -0
- package/dist/esm/Dropdown/SingleSelectDropdown.d.ts +4 -0
- package/dist/esm/Dropdown/SingleSelectDropdown.d.ts.map +1 -0
- package/dist/esm/Dropdown/SingleSelectDropdown.js +16 -0
- package/dist/esm/Dropdown/SingleSelectDropdown.js.map +1 -0
- package/dist/esm/Dropdown/SingleSelectTrigger.d.ts +4 -0
- package/dist/esm/Dropdown/SingleSelectTrigger.d.ts.map +1 -0
- package/dist/esm/Dropdown/SingleSelectTrigger.js +16 -0
- package/dist/esm/Dropdown/SingleSelectTrigger.js.map +1 -0
- package/dist/esm/Dropdown/dropdownAttributes.d.ts +867 -0
- package/dist/esm/Dropdown/dropdownAttributes.d.ts.map +1 -0
- package/dist/esm/Dropdown/dropdownAttributes.js +9 -0
- package/dist/esm/Dropdown/dropdownAttributes.js.map +1 -0
- package/dist/esm/Dropdown/renderTriggerWithOpenState.d.ts +4 -0
- package/dist/esm/Dropdown/renderTriggerWithOpenState.d.ts.map +1 -0
- package/dist/esm/Dropdown/renderTriggerWithOpenState.js +8 -0
- package/dist/esm/Dropdown/renderTriggerWithOpenState.js.map +1 -0
- package/dist/esm/Dropdown/resolveOptions.d.ts +12 -0
- package/dist/esm/Dropdown/resolveOptions.d.ts.map +1 -0
- package/dist/esm/Dropdown/resolveOptions.js +36 -0
- package/dist/esm/Dropdown/resolveOptions.js.map +1 -0
- package/dist/esm/Dropdown/useDropdownHandlers.d.ts +12 -0
- package/dist/esm/Dropdown/useDropdownHandlers.d.ts.map +1 -0
- package/dist/esm/Dropdown/useDropdownHandlers.js +50 -0
- package/dist/esm/Dropdown/useDropdownHandlers.js.map +1 -0
- package/dist/esm/Dropdown/useDropdownState.d.ts +28 -0
- package/dist/esm/Dropdown/useDropdownState.d.ts.map +1 -0
- package/dist/esm/Dropdown/useDropdownState.js +91 -0
- package/dist/esm/Dropdown/useDropdownState.js.map +1 -0
- package/dist/esm/styles.Canvas.css +1 -0
- package/dist/esm/styles.Chat.css +1 -0
- package/dist/esm/styles.css +1 -0
- package/dist/esm/theme.css +1 -0
- package/package.json +6 -4
|
@@ -3,5 +3,5 @@ import type { DatePickerInputProps } from './DatePickerInput.js';
|
|
|
3
3
|
* An internationalized date or date-time picker with Cratis-owned markup parts.
|
|
4
4
|
* The public boundary remains `Date | null`; React Aria's calendar values stay internal.
|
|
5
5
|
*/
|
|
6
|
-
export declare const DatePickerInputImplementation: (
|
|
6
|
+
export declare const DatePickerInputImplementation: (props: DatePickerInputProps) => import("react").JSX.Element;
|
|
7
7
|
//# sourceMappingURL=DatePickerInputImplementation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerInputImplementation.d.ts","sourceRoot":"","sources":["../../../Common/DatePickerInputImplementation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePickerInputImplementation.d.ts","sourceRoot":"","sources":["../../../Common/DatePickerInputImplementation.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAmB,CAAC;AAc9D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,UAAW,oBAAoB,gCA2GxE,CAAC"}
|
|
@@ -1,106 +1,50 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { DatePicker,
|
|
4
|
-
import { Dialog } from 'react-aria-components/Dialog';
|
|
5
|
-
import { Heading } from 'react-aria-components/Heading';
|
|
3
|
+
import { DatePicker, Button } from 'react-aria-components/DatePicker';
|
|
6
4
|
import { UNSAFE_PortalProvider } from 'react-aria';
|
|
7
5
|
import { unstable_useOverlayEnvironment } from '../renderer/RendererContext.js';
|
|
8
|
-
import 'react-aria-components/I18nProvider';
|
|
9
|
-
import 'react-aria-components';
|
|
10
|
-
import 'ts-deepmerge';
|
|
11
|
-
import 'react-dom';
|
|
12
|
-
import { useCratisComponentsConfig } from '../configuration/CratisComponentsContext.js';
|
|
13
|
-
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
14
|
-
import '../Notifications/toast.js';
|
|
15
|
-
import { classNames } from '../ClassNames/classNames.js';
|
|
16
|
-
import { zIndexAboveDialog, OVERLAY_OFFSET } from '../renderer/dialogStack.js';
|
|
17
|
-
import { useNearestDialogZIndex } from '../renderer/DialogStackContext.js';
|
|
18
6
|
import { asReactAriaButtonProps } from './reactAriaProps.js';
|
|
19
|
-
import {
|
|
7
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
8
|
+
import { DatePickerDateInput } from './DatePickerDateInput.js';
|
|
9
|
+
import { DatePickerGroup, DatePickerPlaceholder } from './DatePickerGroup.js';
|
|
10
|
+
import { DatePickerPopover } from './DatePickerPopover.js';
|
|
11
|
+
import { asDate, asDateValue } from './datePickerValues.js';
|
|
12
|
+
import { triggerStateAttributes, rootStateAttributes } from './datePickerStateAttributes.js';
|
|
13
|
+
import { useDatePickerState } from './useDatePickerState.js';
|
|
20
14
|
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
return showTime ? zoned : toCalendarDate(zoned);
|
|
15
|
+
const resolveHourCycle = (hourFormat) => {
|
|
16
|
+
if (hourFormat === '12')
|
|
17
|
+
return 12;
|
|
18
|
+
return hourFormat === '24' ? 24 : undefined;
|
|
26
19
|
};
|
|
27
|
-
const
|
|
28
|
-
const
|
|
20
|
+
const DatePickerInputImplementation = (props) => {
|
|
21
|
+
const { value, onChange, onBlur, showButtonBar, isNonModal = false, showIcon = true, showTime, hourFormat, style, pt } = props;
|
|
29
22
|
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
30
23
|
const overlayEnvironment = unstable_useOverlayEnvironment();
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const resolvedTodayLabel = todayLabel ?? datePickerMessages?.today ?? 'Today';
|
|
39
|
-
const resolvedClearLabel = clearLabel ?? datePickerMessages?.clear ?? 'Clear';
|
|
40
|
-
const timeZone = getLocalTimeZone();
|
|
41
|
-
const minValue = asDateValue(minDate ?? null, showTime) ?? undefined;
|
|
42
|
-
const maxValue = asDateValue(maxDate ?? null, showTime) ?? undefined;
|
|
43
|
-
const todayDate = today(timeZone).toDate(timeZone);
|
|
44
|
-
const todayValue = asDateValue(todayDate, showTime);
|
|
45
|
-
const isTodayOutOfBounds = (minValue !== undefined && todayValue.compare(minValue) < 0) ||
|
|
46
|
-
(maxValue !== undefined && todayValue.compare(maxValue) > 0);
|
|
47
|
-
const rootClassName = classNames('cratis-date-picker', pt?.root?.className, className);
|
|
48
|
-
const inputId = id ?? pt?.input?.id;
|
|
49
|
-
const effectiveDisabled = disabled ?? pt?.input?.disabled ?? false;
|
|
50
|
-
const effectiveReadOnly = readOnly ?? pt?.input?.readOnly ?? false;
|
|
51
|
-
const effectiveInvalid = invalid ?? pt?.input?.['aria-invalid'] ?? false;
|
|
52
|
-
const actionsDisabled = effectiveDisabled || effectiveReadOnly;
|
|
53
|
-
const clearDisabled = actionsDisabled || pt?.clear?.disabled || false;
|
|
54
|
-
const effectivePlaceholder = placeholder ?? pt?.input?.placeholder;
|
|
55
|
-
const effectiveAriaLabel = ariaLabel ??
|
|
56
|
-
pt?.input?.['aria-label'] ??
|
|
57
|
-
effectivePlaceholder ??
|
|
58
|
-
datePickerMessages?.label ??
|
|
59
|
-
'Date';
|
|
60
|
-
const effectiveAriaLabelledby = ariaLabelledby ?? pt?.input?.['aria-labelledby'];
|
|
61
|
-
const effectiveAriaDescribedby = ariaDescribedby ?? pt?.input?.['aria-describedby'];
|
|
62
|
-
const inputPartAttributes = {
|
|
63
|
-
...pt?.input,
|
|
64
|
-
id: undefined,
|
|
65
|
-
className: undefined,
|
|
66
|
-
style: undefined,
|
|
67
|
-
disabled: undefined,
|
|
68
|
-
readOnly: undefined,
|
|
69
|
-
placeholder: undefined,
|
|
70
|
-
'aria-label': undefined,
|
|
71
|
-
'aria-labelledby': undefined,
|
|
72
|
-
'aria-describedby': undefined,
|
|
73
|
-
'aria-invalid': undefined,
|
|
24
|
+
const state = useDatePickerState(props);
|
|
25
|
+
const { effectiveDisabled, effectiveReadOnly } = state;
|
|
26
|
+
const fieldState = {
|
|
27
|
+
invalid: state.effectiveInvalid,
|
|
28
|
+
disabled: effectiveDisabled,
|
|
29
|
+
readOnly: effectiveReadOnly,
|
|
30
|
+
selected: value !== null,
|
|
74
31
|
};
|
|
75
|
-
|
|
32
|
+
const buttonBar = showButtonBar ? {
|
|
33
|
+
pt,
|
|
34
|
+
todayLabel: state.resolvedTodayLabel,
|
|
35
|
+
clearLabel: state.resolvedClearLabel,
|
|
36
|
+
actionsDisabled: state.actionsDisabled,
|
|
37
|
+
clearDisabled: state.clearDisabled,
|
|
38
|
+
isTodayOutOfBounds: state.isTodayOutOfBounds,
|
|
39
|
+
todayDate: state.todayDate,
|
|
40
|
+
onChange,
|
|
41
|
+
} : null;
|
|
42
|
+
return (jsx("div", { ...pt?.root, className: state.rootClassName, style: { ...pt?.root?.style, ...style }, "data-cratis-part": 'root', "data-cratis-component": 'DatePickerInput', ...rootStateAttributes(fieldState, isPickerOpen), onBlur: onBlur, children: jsx(UNSAFE_PortalProvider, { getContainer: overlayEnvironment.getContainer, children: jsx(DatePicker, { value: asDateValue(value, showTime), onChange: (next) => onChange(asDate(next), { source: 'user' }), isDisabled: effectiveDisabled, isReadOnly: effectiveReadOnly, isInvalid: state.effectiveInvalid, isOpen: isPickerOpen, onOpenChange: (nextIsOpen) => {
|
|
76
43
|
if (!nextIsOpen || !effectiveReadOnly)
|
|
77
44
|
setIsPickerOpen(nextIsOpen);
|
|
78
|
-
}, minValue: minValue, maxValue: maxValue, granularity: showTime ? 'minute' : 'day', hourCycle: hourFormat
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
datePickerMessages?.openCalendar ??
|
|
82
|
-
'Open calendar', children: jsx("span", { "aria-hidden": 'true', children: "\u25A6" }) }))] }), jsx(Popover, { ...pt?.popover, isNonModal: isNonModal, className: classNames('cratis-date-picker__popover', pt?.popover?.className), style: {
|
|
83
|
-
zIndex: resolvedPopoverZIndex,
|
|
84
|
-
...pt?.popover?.style,
|
|
85
|
-
}, "data-cratis-part": 'popover', "data-open": true, placement: 'bottom start', children: jsxs(Dialog, { ...pt?.dialog, className: classNames('cratis-date-picker__dialog', pt?.dialog?.className), "data-cratis-part": 'dialog', "data-open": true, children: [jsxs(Calendar, { ...pt?.calendar, className: classNames('cratis-date-picker__calendar', pt?.calendar?.className), "data-cratis-part": 'calendar', "data-open": true, children: [jsxs("header", { ...pt?.header, className: classNames('cratis-date-picker__header', pt?.header?.className), "data-cratis-part": 'header', children: [jsx(Button, { ...asReactAriaButtonProps(pt?.previous), slot: 'previous', className: classNames('cratis-date-picker__nav', pt?.previous?.className), "data-cratis-part": 'previous', "aria-label": pt?.previous?.['aria-label'] ??
|
|
86
|
-
datePickerMessages?.previousMonth ??
|
|
87
|
-
'Previous month', children: jsx("span", { "aria-hidden": 'true', children: icon('previous', '‹') }) }), jsx(Heading, { ...pt?.heading, className: classNames('cratis-date-picker__heading', pt?.heading?.className), "data-cratis-part": 'heading' }), jsx(Button, { ...asReactAriaButtonProps(pt?.next), slot: 'next', className: classNames('cratis-date-picker__nav', pt?.next?.className), "data-cratis-part": 'next', "aria-label": pt?.next?.['aria-label'] ??
|
|
88
|
-
datePickerMessages?.nextMonth ??
|
|
89
|
-
'Next month', children: jsx("span", { "aria-hidden": 'true', children: icon('next', '›') }) })] }), jsxs(CalendarGrid, { ...pt?.grid, className: classNames('cratis-date-picker__grid', pt?.grid?.className), "data-cratis-part": 'grid', children: [jsx(CalendarGridHeader, { children: (day) => (jsx(CalendarHeaderCell, { children: day })) }), jsx(CalendarGridBody, { children: (date) => (jsx(CalendarCell, { ...pt?.cell, date: date, className: classNames('cratis-date-picker__cell', pt?.cell?.className), "data-cratis-part": 'cell' })) })] })] }), showButtonBar && (jsxs("div", { ...pt?.buttonBar, className: classNames('cratis-date-picker__button-bar', pt?.buttonBar?.className), "data-cratis-part": 'button-bar', children: [jsx("button", { ...pt?.today, type: 'button', className: classNames('cratis-date-picker__action', pt?.today?.className), "data-cratis-part": 'today', "data-disabled": actionsDisabled || isTodayOutOfBounds || undefined, disabled: actionsDisabled || isTodayOutOfBounds, "aria-disabled": actionsDisabled || isTodayOutOfBounds || undefined, onClick: (event) => {
|
|
90
|
-
if (actionsDisabled || isTodayOutOfBounds)
|
|
91
|
-
return;
|
|
92
|
-
onChange(todayDate, {
|
|
93
|
-
source: 'user',
|
|
94
|
-
nativeEvent: event.nativeEvent,
|
|
95
|
-
});
|
|
96
|
-
}, children: resolvedTodayLabel }), jsx("button", { ...pt?.clear, type: 'button', className: classNames('cratis-date-picker__action', pt?.clear?.className), "data-cratis-part": 'clear', "data-disabled": clearDisabled || undefined, disabled: clearDisabled, "aria-disabled": clearDisabled || pt?.clear?.['aria-disabled'] || undefined, onClick: (event) => {
|
|
97
|
-
if (clearDisabled)
|
|
98
|
-
return;
|
|
99
|
-
onChange(null, {
|
|
100
|
-
source: 'user',
|
|
101
|
-
nativeEvent: event.nativeEvent,
|
|
102
|
-
});
|
|
103
|
-
}, children: resolvedClearLabel })] }))] }) })] })) }) }) }));
|
|
45
|
+
}, minValue: state.minValue, maxValue: state.maxValue, granularity: showTime ? 'minute' : 'day', hourCycle: resolveHourCycle(hourFormat), "aria-label": state.effectiveAriaLabel, "aria-labelledby": state.effectiveAriaLabelledby, "aria-describedby": state.effectiveAriaDescribedby, className: 'cratis-date-picker__picker', children: ({ isOpen }) => (jsxs(Fragment, { children: [jsxs(DatePickerGroup, { pt: pt, inputId: state.inputId, state: fieldState, isOpen: isOpen, children: [jsx(DatePickerDateInput, { pt: pt, inputPartAttributes: state.inputPartAttributes, placeholder: state.effectivePlaceholder, state: fieldState, isOpen: isOpen }), jsx(DatePickerPlaceholder, { pt: pt, placeholder: state.effectivePlaceholder, selected: fieldState.selected }), showIcon && (jsx(Button, { ...asReactAriaButtonProps(pt?.trigger), isDisabled: effectiveDisabled || effectiveReadOnly, className: classNames('cratis-date-picker__trigger', pt?.trigger?.className), "data-cratis-part": 'trigger', render: (triggerProps) => (jsx("button", { ...triggerProps, ...triggerStateAttributes(fieldState, isOpen) })), "aria-label": pt?.trigger?.['aria-label'] ??
|
|
46
|
+
state.datePickerMessages?.openCalendar ??
|
|
47
|
+
'Open calendar', children: jsx("span", { "aria-hidden": 'true', children: "\u25A6" }) }))] }), jsx(DatePickerPopover, { pt: pt, isNonModal: isNonModal, zIndex: state.resolvedPopoverZIndex, buttonBar: buttonBar })] })) }) }) }));
|
|
104
48
|
};
|
|
105
49
|
|
|
106
50
|
export { DatePickerInputImplementation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerInputImplementation.js","sources":["../../../Common/DatePickerInputImplementation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport {\n Button,\n Calendar,\n CalendarCell,\n CalendarGrid,\n CalendarGridBody,\n CalendarGridHeader,\n CalendarHeaderCell,\n DateInput,\n DatePicker as AriaDatePicker,\n DateSegment,\n Group,\n Popover,\n type DateValue,\n} from 'react-aria-components/DatePicker';\nimport { Dialog } from 'react-aria-components/Dialog';\nimport { Heading } from 'react-aria-components/Heading';\nimport { UNSAFE_PortalProvider } from 'react-aria';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { useCratisComponentsConfig } from './CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { OVERLAY_OFFSET, zIndexAboveDialog } from '../renderer/dialogStack';\nimport { useNearestDialogZIndex } from '../renderer/DialogStackContext';\nimport { asReactAriaButtonProps } from './reactAriaProps';\nimport {\n fromDate,\n getLocalTimeZone,\n today,\n toCalendarDate,\n} from '@internationalized/date';\nimport type { DatePickerInputProps } from './DatePickerInput';\nimport { classNames } from '../ClassNames/classNames';\n\nconst asDateValue = (\n value: Date | null,\n showTime: boolean | undefined,\n): DateValue | null => {\n if (!value) return null;\n const zoned = fromDate(value, getLocalTimeZone());\n return showTime ? zoned : toCalendarDate(zoned);\n};\n\nconst asDate = (value: DateValue | null): Date | null =>\n value ? value.toDate(getLocalTimeZone()) : null;\n\n/**\n * An internationalized date or date-time picker with Cratis-owned markup parts.\n * The public boundary remains `Date | null`; React Aria's calendar values stay internal.\n */\nexport const DatePickerInputImplementation = ({\n value,\n onChange,\n onBlur,\n invalid,\n disabled,\n readOnly,\n id,\n showButtonBar,\n isNonModal = false,\n placeholder,\n showIcon = true,\n showTime,\n hourFormat,\n minDate,\n maxDate,\n className,\n style,\n pt,\n todayLabel,\n clearLabel,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n}: DatePickerInputProps) => {\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const nearestDialogZIndex = useNearestDialogZIndex();\n const resolvedPopoverZIndex =\n nearestDialogZIndex === null\n ? 'var(--cratis-z-index-overlay)'\n : zIndexAboveDialog(nearestDialogZIndex, OVERLAY_OFFSET);\n const { messages } = useCratisComponentsConfig();\n const datePickerMessages = messages?.datePicker;\n const icon = useCratisIcon();\n const resolvedTodayLabel = todayLabel ?? datePickerMessages?.today ?? 'Today';\n const resolvedClearLabel = clearLabel ?? datePickerMessages?.clear ?? 'Clear';\n const timeZone = getLocalTimeZone();\n const minValue = asDateValue(minDate ?? null, showTime) ?? undefined;\n const maxValue = asDateValue(maxDate ?? null, showTime) ?? undefined;\n const todayDate = today(timeZone).toDate(timeZone);\n // Compare the same granularity that the action emits. In date-time mode the Today action\n // retains its existing local-midnight value, which can legitimately fall before a same-day\n // minDate carrying a later time.\n const todayValue = asDateValue(todayDate, showTime)!;\n const isTodayOutOfBounds =\n (minValue !== undefined && todayValue.compare(minValue) < 0) ||\n (maxValue !== undefined && todayValue.compare(maxValue) > 0);\n const rootClassName = classNames(\n 'cratis-date-picker',\n pt?.root?.className,\n className,\n );\n const inputId = id ?? pt?.input?.id;\n const effectiveDisabled = disabled ?? pt?.input?.disabled ?? false;\n const effectiveReadOnly = readOnly ?? pt?.input?.readOnly ?? false;\n const effectiveInvalid = invalid ?? pt?.input?.['aria-invalid'] ?? false;\n const actionsDisabled = effectiveDisabled || effectiveReadOnly;\n const clearDisabled = actionsDisabled || pt?.clear?.disabled || false;\n const effectivePlaceholder = placeholder ?? pt?.input?.placeholder;\n const effectiveAriaLabel =\n ariaLabel ??\n pt?.input?.['aria-label'] ??\n effectivePlaceholder ??\n datePickerMessages?.label ??\n 'Date';\n const effectiveAriaLabelledby = ariaLabelledby ?? pt?.input?.['aria-labelledby'];\n const effectiveAriaDescribedby = ariaDescribedby ?? pt?.input?.['aria-describedby'];\n const inputPartAttributes = {\n ...pt?.input,\n id: undefined,\n className: undefined,\n style: undefined,\n disabled: undefined,\n readOnly: undefined,\n placeholder: undefined,\n 'aria-label': undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': undefined,\n 'aria-invalid': undefined,\n };\n\n return (\n <div\n {...pt?.root}\n className={rootClassName}\n style={{ ...pt?.root?.style, ...style }}\n data-cratis-part='root'\n data-cratis-component='DatePickerInput'\n data-invalid={effectiveInvalid || undefined}\n data-disabled={effectiveDisabled || undefined}\n data-readonly={effectiveReadOnly || undefined}\n data-open={isPickerOpen || undefined}\n data-selected={value !== null || undefined}\n onBlur={onBlur}\n >\n <UNSAFE_PortalProvider getContainer={overlayEnvironment.getContainer}>\n <AriaDatePicker\n value={asDateValue(value, showTime)}\n onChange={(next) => onChange(asDate(next), { source: 'user' })}\n isDisabled={effectiveDisabled}\n isReadOnly={effectiveReadOnly}\n isInvalid={effectiveInvalid}\n isOpen={isPickerOpen}\n onOpenChange={(nextIsOpen) => {\n if (!nextIsOpen || !effectiveReadOnly) setIsPickerOpen(nextIsOpen);\n }}\n minValue={minValue}\n maxValue={maxValue}\n granularity={showTime ? 'minute' : 'day'}\n hourCycle={\n hourFormat === '12' ? 12 : hourFormat === '24' ? 24 : undefined\n }\n aria-label={effectiveAriaLabel}\n aria-labelledby={effectiveAriaLabelledby}\n aria-describedby={effectiveAriaDescribedby}\n className='cratis-date-picker__picker'\n >\n {({ isOpen }) => (\n <>\n <Group\n {...pt?.group}\n id={inputId}\n aria-invalid={effectiveInvalid || undefined}\n className={classNames(\n 'cratis-date-picker__group',\n pt?.group?.className,\n )}\n data-cratis-part='group'\n data-empty={value === null || undefined}\n render={(groupProps) => (\n <div\n {...groupProps}\n data-open={isOpen || undefined}\n data-invalid={effectiveInvalid || undefined}\n data-disabled={effectiveDisabled || undefined}\n data-readonly={effectiveReadOnly || undefined}\n data-selected={value !== null || undefined}\n />\n )}\n >\n <DateInput\n {...inputPartAttributes}\n className={classNames(\n 'cratis-date-picker__input',\n pt?.input?.className,\n )}\n style={pt?.input?.style}\n data-cratis-part='input'\n data-placeholder={effectivePlaceholder}\n render={(inputProps) => (\n <div\n {...inputProps}\n data-open={isOpen || undefined}\n data-invalid={effectiveInvalid || undefined}\n data-disabled={effectiveDisabled || undefined}\n data-readonly={effectiveReadOnly || undefined}\n data-selected={value !== null || undefined}\n />\n )}\n >\n {(segment) => (\n <DateSegment\n {...pt?.segment}\n segment={segment}\n className={classNames(\n 'cratis-date-picker__segment',\n pt?.segment?.className,\n )}\n data-cratis-part='segment'\n render={(segmentProps) => (\n <span\n {...segmentProps}\n data-invalid={\n effectiveInvalid || undefined\n }\n data-disabled={\n effectiveDisabled || undefined\n }\n data-readonly={\n effectiveReadOnly || undefined\n }\n />\n )}\n />\n )}\n </DateInput>\n {value === null && effectivePlaceholder && (\n <span\n {...pt?.placeholder}\n className={classNames(\n 'cratis-date-picker__placeholder',\n pt?.placeholder?.className,\n )}\n data-cratis-part='placeholder'\n aria-hidden='true'\n >\n {effectivePlaceholder}\n </span>\n )}\n {showIcon && (\n <Button\n {...asReactAriaButtonProps(pt?.trigger)}\n isDisabled={\n effectiveDisabled || effectiveReadOnly\n }\n className={classNames(\n 'cratis-date-picker__trigger',\n pt?.trigger?.className,\n )}\n data-cratis-part='trigger'\n render={(triggerProps) => (\n <button\n {...triggerProps}\n data-open={isOpen || undefined}\n data-invalid={\n effectiveInvalid || undefined\n }\n data-disabled={\n effectiveDisabled ||\n effectiveReadOnly ||\n undefined\n }\n data-readonly={\n effectiveReadOnly || undefined\n }\n data-selected={\n value !== null || undefined\n }\n />\n )}\n aria-label={\n pt?.trigger?.['aria-label'] ??\n datePickerMessages?.openCalendar ??\n 'Open calendar'\n }\n >\n <span aria-hidden='true'>▦</span>\n </Button>\n )}\n </Group>\n <Popover\n {...pt?.popover}\n isNonModal={isNonModal}\n className={classNames(\n 'cratis-date-picker__popover',\n pt?.popover?.className,\n )}\n style={{\n zIndex: resolvedPopoverZIndex,\n ...pt?.popover?.style,\n }}\n data-cratis-part='popover'\n data-open\n placement='bottom start'\n >\n <Dialog\n {...pt?.dialog}\n className={classNames(\n 'cratis-date-picker__dialog',\n pt?.dialog?.className,\n )}\n data-cratis-part='dialog'\n data-open\n >\n <Calendar\n {...pt?.calendar}\n className={classNames(\n 'cratis-date-picker__calendar',\n pt?.calendar?.className,\n )}\n data-cratis-part='calendar'\n data-open\n >\n <header\n {...pt?.header}\n className={classNames(\n 'cratis-date-picker__header',\n pt?.header?.className,\n )}\n data-cratis-part='header'\n >\n <Button\n {...asReactAriaButtonProps(pt?.previous)}\n slot='previous'\n className={classNames(\n 'cratis-date-picker__nav',\n pt?.previous?.className,\n )}\n data-cratis-part='previous'\n aria-label={\n pt?.previous?.['aria-label'] ??\n datePickerMessages?.previousMonth ??\n 'Previous month'\n }\n >\n <span aria-hidden='true'>\n {icon('previous', '‹')}\n </span>\n </Button>\n <Heading\n {...pt?.heading}\n className={classNames(\n 'cratis-date-picker__heading',\n pt?.heading?.className,\n )}\n data-cratis-part='heading'\n />\n <Button\n {...asReactAriaButtonProps(pt?.next)}\n slot='next'\n className={classNames(\n 'cratis-date-picker__nav',\n pt?.next?.className,\n )}\n data-cratis-part='next'\n aria-label={\n pt?.next?.['aria-label'] ??\n datePickerMessages?.nextMonth ??\n 'Next month'\n }\n >\n <span aria-hidden='true'>\n {icon('next', '›')}\n </span>\n </Button>\n </header>\n <CalendarGrid\n {...pt?.grid}\n className={classNames(\n 'cratis-date-picker__grid',\n pt?.grid?.className,\n )}\n data-cratis-part='grid'\n >\n <CalendarGridHeader>\n {(day) => (\n <CalendarHeaderCell>\n {day}\n </CalendarHeaderCell>\n )}\n </CalendarGridHeader>\n <CalendarGridBody>\n {(date) => (\n <CalendarCell\n {...pt?.cell}\n date={date}\n className={classNames(\n 'cratis-date-picker__cell',\n pt?.cell?.className,\n )}\n data-cratis-part='cell'\n />\n )}\n </CalendarGridBody>\n </CalendarGrid>\n </Calendar>\n {showButtonBar && (\n <div\n {...pt?.buttonBar}\n className={classNames(\n 'cratis-date-picker__button-bar',\n pt?.buttonBar?.className,\n )}\n data-cratis-part='button-bar'\n >\n <button\n {...pt?.today}\n type='button'\n className={classNames(\n 'cratis-date-picker__action',\n pt?.today?.className,\n )}\n data-cratis-part='today'\n data-disabled={\n actionsDisabled || isTodayOutOfBounds || undefined\n }\n disabled={actionsDisabled || isTodayOutOfBounds}\n aria-disabled={\n actionsDisabled || isTodayOutOfBounds || undefined\n }\n onClick={(event) => {\n if (actionsDisabled || isTodayOutOfBounds) return;\n onChange(todayDate, {\n source: 'user',\n nativeEvent: event.nativeEvent,\n });\n }}\n >\n {resolvedTodayLabel}\n </button>\n <button\n {...pt?.clear}\n type='button'\n className={classNames(\n 'cratis-date-picker__action',\n pt?.clear?.className,\n )}\n data-cratis-part='clear'\n data-disabled={clearDisabled || undefined}\n disabled={clearDisabled}\n aria-disabled={clearDisabled || pt?.clear?.['aria-disabled'] || undefined}\n onClick={(event) => {\n if (clearDisabled) return;\n onChange(null, {\n source: 'user',\n nativeEvent: event.nativeEvent,\n });\n }}\n >\n {resolvedClearLabel}\n </button>\n </div>\n )}\n </Dialog>\n </Popover>\n </>\n )}\n </AriaDatePicker>\n </UNSAFE_PortalProvider>\n </div>\n );\n};\n"],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,WAAW,GAAG,CAChB,KAAkB,EAClB,QAA6B,KACX;AAClB,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;IACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACjD,IAAA,OAAO,QAAQ,GAAG,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;AACnD,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,KAAuB,KACnC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAAG,IAAI;AAM5C,MAAM,6BAA6B,GAAG,CAAC,EAC1C,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,WAAW,EACX,QAAQ,GAAG,IAAI,EACf,QAAQ,EACR,UAAU,EACV,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,EACL,EAAE,EACF,UAAU,EACV,UAAU,EACV,YAAY,EAAE,SAA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,EAAE,KAAK,EAAE,SAAS,CACvB,EAAA,kBAAA,EACgB,OAAO,EAAA,eAAA,EACT,aAAa,IAAI,SAAS,EACzC,QAAQ,EAAE,aAAa,EAAA,eAAA,EACR,aAAa,IAAI,EAAE,EAAE,KAAK,GAAG,eAAe,CAAC,IAAI,SAAS,EACzE,OAAO,EAAE,CAAC,KAAK,KAAI;AACf,oDAAA,IAAI,aAAa;wDAAE;oDACnB,QAAQ,CAAC,IAAI,EAAE;AACX,wDAAA,MAAM,EAAE,MAAM;wDACd,WAAW,EAAE,KAAK,CAAC,WAAW;AACjC,qDAAA,CAAC;AACN,gDAAA,CAAC,EAAA,QAAA,EAEA,kBAAkB,EAAA,CACd,CAAA,EAAA,CACP,CACT,CAAA,EAAA,CACI,EAAA,CACH,CAAA,EAAA,CACX,CACN,EAAA,CACY,EAAA,CACG,EAAA,CACtB;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"DatePickerInputImplementation.js","sources":["../../../Common/DatePickerInputImplementation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport {\n Button,\n DatePicker as AriaDatePicker,\n} from 'react-aria-components/DatePicker';\nimport { UNSAFE_PortalProvider } from 'react-aria';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { asReactAriaButtonProps } from './reactAriaProps';\nimport type { DatePickerInputProps } from './DatePickerInput';\nimport { classNames } from '../ClassNames/classNames';\nimport { DatePickerDateInput } from './DatePickerDateInput';\nimport { DatePickerGroup, DatePickerPlaceholder } from './DatePickerGroup';\nimport { DatePickerPopover } from './DatePickerPopover';\nimport { asDate, asDateValue } from './datePickerValues';\nimport { rootStateAttributes, triggerStateAttributes } from './datePickerStateAttributes';\nimport { useDatePickerState } from './useDatePickerState';\n\nconst resolveHourCycle = (hourFormat: DatePickerInputProps['hourFormat']) => {\n if (hourFormat === '12') return 12;\n return hourFormat === '24' ? 24 : undefined;\n};\n\n/**\n * An internationalized date or date-time picker with Cratis-owned markup parts.\n * The public boundary remains `Date | null`; React Aria's calendar values stay internal.\n */\nexport const DatePickerInputImplementation = (props: DatePickerInputProps) => {\n const { value, onChange, onBlur, showButtonBar, isNonModal = false, showIcon = true, showTime, hourFormat, style, pt } = props;\n const [isPickerOpen, setIsPickerOpen] = useState(false);\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const state = useDatePickerState(props);\n const { effectiveDisabled, effectiveReadOnly } = state;\n const fieldState = {\n invalid: state.effectiveInvalid,\n disabled: effectiveDisabled,\n readOnly: effectiveReadOnly,\n selected: value !== null,\n };\n const buttonBar = showButtonBar ? {\n pt,\n todayLabel: state.resolvedTodayLabel,\n clearLabel: state.resolvedClearLabel,\n actionsDisabled: state.actionsDisabled,\n clearDisabled: state.clearDisabled,\n isTodayOutOfBounds: state.isTodayOutOfBounds,\n todayDate: state.todayDate,\n onChange,\n } : null;\n\n return (\n <div\n {...pt?.root}\n className={state.rootClassName}\n style={{ ...pt?.root?.style, ...style }}\n data-cratis-part='root'\n data-cratis-component='DatePickerInput'\n {...rootStateAttributes(fieldState, isPickerOpen)}\n onBlur={onBlur}\n >\n <UNSAFE_PortalProvider getContainer={overlayEnvironment.getContainer}>\n <AriaDatePicker\n value={asDateValue(value, showTime)}\n onChange={(next) => onChange(asDate(next), { source: 'user' })}\n isDisabled={effectiveDisabled}\n isReadOnly={effectiveReadOnly}\n isInvalid={state.effectiveInvalid}\n isOpen={isPickerOpen}\n onOpenChange={(nextIsOpen) => {\n if (!nextIsOpen || !effectiveReadOnly) setIsPickerOpen(nextIsOpen);\n }}\n minValue={state.minValue}\n maxValue={state.maxValue}\n granularity={showTime ? 'minute' : 'day'}\n hourCycle={resolveHourCycle(hourFormat)}\n aria-label={state.effectiveAriaLabel}\n aria-labelledby={state.effectiveAriaLabelledby}\n aria-describedby={state.effectiveAriaDescribedby}\n className='cratis-date-picker__picker'\n >\n {({ isOpen }) => (\n <>\n <DatePickerGroup pt={pt} inputId={state.inputId} state={fieldState} isOpen={isOpen}>\n <DatePickerDateInput\n pt={pt}\n inputPartAttributes={state.inputPartAttributes}\n placeholder={state.effectivePlaceholder}\n state={fieldState}\n isOpen={isOpen}\n />\n <DatePickerPlaceholder\n pt={pt}\n placeholder={state.effectivePlaceholder}\n selected={fieldState.selected}\n />\n {showIcon && (\n <Button\n {...asReactAriaButtonProps(pt?.trigger)}\n isDisabled={\n effectiveDisabled || effectiveReadOnly\n }\n className={classNames(\n 'cratis-date-picker__trigger',\n pt?.trigger?.className,\n )}\n data-cratis-part='trigger'\n render={(triggerProps) => (\n <button\n {...triggerProps}\n {...triggerStateAttributes(fieldState, isOpen)}\n />\n )}\n aria-label={\n pt?.trigger?.['aria-label'] ??\n state.datePickerMessages?.openCalendar ??\n 'Open calendar'\n }\n >\n <span aria-hidden='true'>▦</span>\n </Button>\n )}\n </DatePickerGroup>\n <DatePickerPopover\n pt={pt}\n isNonModal={isNonModal}\n zIndex={state.resolvedPopoverZIndex}\n buttonBar={buttonBar}\n />\n </>\n )}\n </AriaDatePicker>\n </UNSAFE_PortalProvider>\n </div>\n );\n};\n"],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;AAoBA,MAAM,gBAAgB,GAAG,CAAC,UAA8C,KAAI;IACxE,IAAI,UAAU,KAAK,IAAI;AAAE,QAAA,OAAO,EAAE;IAClC,OAAO,UAAU,KAAK,IAAI,GAAG,EAAE,GAAG,SAAS;AAC/C,CAAC;AAMM,MAAM,6BAA6B,GAAG,CAAC,KAA2B,KAAI;IACzE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,GAAG,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,KAAK;IAC9H,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,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AU,EACN,iBAAiB,IAAI,iBAAiB,EAE1C,SAAS,EAAE,UAAU,CACjB,6BAA6B,EAC7B,EAAE,EAAE,OAAO,EAAE,SAAS,CACzB,EAAA,kBAAA,EACgB,SAAS,EAC1B,MAAM,EAAE,CAAC,YAAY,MACjBA,GAAA,CAAA,QAAA,EAAA,EAAA,GACQ,YAAY,KACZ,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAA,CAChD,CACL,gBAEG,EAAE,EAAE,OAAO,GAAG,YAAY,CAAC;wCAC3B,KAAK,CAAC,kBAAkB,EAAE,YAAY;AACtC,wCAAA,eAAe,EAAA,QAAA,EAGnBA,GAAA,CAAA,MAAA,EAAA,EAAA,aAAA,EAAkB,MAAM,EAAA,QAAA,EAAA,QAAA,EAAA,CAAS,GAC5B,CACZ,CAAA,EAAA,CACa,EAClBA,GAAA,CAAC,iBAAiB,EAAA,EACd,EAAE,EAAE,EAAE,EACN,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,KAAK,CAAC,qBAAqB,EACnC,SAAS,EAAE,SAAS,EAAA,CACtB,IACH,CACN,EAAA,CACY,EAAA,CACG,EAAA,CACtB;AAEd;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DatePickerButtonBarProps } from './DatePickerButtonBar.js';
|
|
2
|
+
import type { DatePickerInputPassThrough } from './DatePickerInput.js';
|
|
3
|
+
interface DatePickerPopoverProps {
|
|
4
|
+
pt: DatePickerInputPassThrough | undefined;
|
|
5
|
+
isNonModal: boolean;
|
|
6
|
+
zIndex: string;
|
|
7
|
+
buttonBar: DatePickerButtonBarProps | null;
|
|
8
|
+
}
|
|
9
|
+
/** The portaled popover with the calendar dialog and, when requested, the Today and Clear actions. */
|
|
10
|
+
export declare const DatePickerPopover: ({ pt, isNonModal, zIndex, buttonBar }: DatePickerPopoverProps) => import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=DatePickerPopover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerPopover.d.ts","sourceRoot":"","sources":["../../../Common/DatePickerPopover.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,0BAAuB,CAAC;AAE3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAmB,CAAC;AAEpE,UAAU,sBAAsB;IAC5B,EAAE,EAAE,0BAA0B,GAAG,SAAS,CAAC;IAC3C,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC9C;AAED,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,0CAA2C,sBAAsB,gCAoB9F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Popover } from 'react-aria-components/DatePicker';
|
|
3
|
+
import { Dialog } from 'react-aria-components/Dialog';
|
|
4
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
5
|
+
import { DatePickerButtonBar } from './DatePickerButtonBar.js';
|
|
6
|
+
import { DatePickerCalendar } from './DatePickerCalendar.js';
|
|
7
|
+
|
|
8
|
+
const DatePickerPopover = ({ pt, isNonModal, zIndex, buttonBar }) => (jsx(Popover, { ...pt?.popover, isNonModal: isNonModal, className: classNames('cratis-date-picker__popover', pt?.popover?.className), style: { zIndex, ...pt?.popover?.style }, "data-cratis-part": 'popover', "data-open": true, placement: 'bottom start', children: jsxs(Dialog, { ...pt?.dialog, className: classNames('cratis-date-picker__dialog', pt?.dialog?.className), "data-cratis-part": 'dialog', "data-open": true, children: [jsx(DatePickerCalendar, { pt: pt }), buttonBar && jsx(DatePickerButtonBar, { ...buttonBar })] }) }));
|
|
9
|
+
|
|
10
|
+
export { DatePickerPopover };
|
|
11
|
+
//# sourceMappingURL=DatePickerPopover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePickerPopover.js","sources":["../../../Common/DatePickerPopover.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Popover } from 'react-aria-components/DatePicker';\nimport { Dialog } from 'react-aria-components/Dialog';\nimport { classNames } from '../ClassNames/classNames';\nimport { DatePickerButtonBar, type DatePickerButtonBarProps } from './DatePickerButtonBar';\nimport { DatePickerCalendar } from './DatePickerCalendar';\nimport type { DatePickerInputPassThrough } from './DatePickerInput';\n\ninterface DatePickerPopoverProps {\n pt: DatePickerInputPassThrough | undefined;\n isNonModal: boolean;\n zIndex: string;\n buttonBar: DatePickerButtonBarProps | null;\n}\n\n/** The portaled popover with the calendar dialog and, when requested, the Today and Clear actions. */\nexport const DatePickerPopover = ({ pt, isNonModal, zIndex, buttonBar }: DatePickerPopoverProps) => (\n <Popover\n {...pt?.popover}\n isNonModal={isNonModal}\n className={classNames('cratis-date-picker__popover', pt?.popover?.className)}\n style={{ zIndex, ...pt?.popover?.style }}\n data-cratis-part='popover'\n data-open\n placement='bottom start'\n >\n <Dialog\n {...pt?.dialog}\n className={classNames('cratis-date-picker__dialog', pt?.dialog?.className)}\n data-cratis-part='dialog'\n data-open\n >\n <DatePickerCalendar pt={pt} />\n {buttonBar && <DatePickerButtonBar {...buttonBar} />}\n </Dialog>\n </Popover>\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;MAkBa,iBAAiB,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAA0B,MAC3FA,GAAA,CAAC,OAAO,EAAA,EAAA,GACA,EAAE,EAAE,OAAO,EACf,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,UAAU,CAAC,6BAA6B,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,EAC5E,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAA,kBAAA,EACvB,SAAS,qBAE1B,SAAS,EAAC,cAAc,EAAA,QAAA,EAExBC,IAAA,CAAC,MAAM,OACC,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EACzD,QAAQ,gCAGzBD,GAAA,CAAC,kBAAkB,EAAA,EAAC,EAAE,EAAE,EAAE,GAAI,EAC7B,SAAS,IAAIA,GAAA,CAAC,mBAAmB,EAAA,EAAA,GAAK,SAAS,EAAA,CAAI,CAAA,EAAA,CAC/C,EAAA,CACH;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** The state the date picker parts expose as data attributes. */
|
|
2
|
+
export interface DatePickerFieldState {
|
|
3
|
+
invalid: boolean;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
selected: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** State attributes of the picker's outer wrapper. */
|
|
9
|
+
export declare const rootStateAttributes: (state: DatePickerFieldState, isPickerOpen: boolean) => {
|
|
10
|
+
'data-invalid': true | undefined;
|
|
11
|
+
'data-disabled': true | undefined;
|
|
12
|
+
'data-readonly': true | undefined;
|
|
13
|
+
'data-open': true | undefined;
|
|
14
|
+
'data-selected': true | undefined;
|
|
15
|
+
};
|
|
16
|
+
/** State attributes of the segmented group and input. */
|
|
17
|
+
export declare const fieldStateAttributes: (state: DatePickerFieldState, isOpen: boolean) => {
|
|
18
|
+
'data-open': true | undefined;
|
|
19
|
+
'data-invalid': true | undefined;
|
|
20
|
+
'data-disabled': true | undefined;
|
|
21
|
+
'data-readonly': true | undefined;
|
|
22
|
+
'data-selected': true | undefined;
|
|
23
|
+
};
|
|
24
|
+
/** State attributes of the calendar trigger, which is also disabled while read only. */
|
|
25
|
+
export declare const triggerStateAttributes: (state: DatePickerFieldState, isOpen: boolean) => {
|
|
26
|
+
'data-open': true | undefined;
|
|
27
|
+
'data-invalid': true | undefined;
|
|
28
|
+
'data-readonly': true | undefined;
|
|
29
|
+
'data-selected': true | undefined;
|
|
30
|
+
'data-disabled': true | undefined;
|
|
31
|
+
};
|
|
32
|
+
/** State attributes of one date or time segment. */
|
|
33
|
+
export declare const segmentStateAttributes: (state: DatePickerFieldState) => {
|
|
34
|
+
'data-invalid': true | undefined;
|
|
35
|
+
'data-disabled': true | undefined;
|
|
36
|
+
'data-readonly': true | undefined;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=datePickerStateAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datePickerStateAttributes.d.ts","sourceRoot":"","sources":["../../../Common/datePickerStateAttributes.ts"],"names":[],"mappings":"AAGA,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,UAAW,oBAAoB,gBAAgB,OAAO;IAClF,cAAc;IACd,eAAe;IACf,eAAe;IACf,WAAW;IACX,eAAe;CACjB,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,UAAW,oBAAoB,UAAU,OAAO;IAC7E,WAAW;IACX,cAAc;IACd,eAAe;IACf,eAAe;IACf,eAAe;CACjB,CAAC;AAEH,wFAAwF;AACxF,eAAO,MAAM,sBAAsB,UAAW,oBAAoB,UAAU,OAAO;;;;;;CAGjF,CAAC;AAEH,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,UAAW,oBAAoB;IAC9D,cAAc;IACd,eAAe;IACf,eAAe;CACjB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const rootStateAttributes = (state, isPickerOpen) => ({
|
|
2
|
+
'data-invalid': state.invalid || undefined,
|
|
3
|
+
'data-disabled': state.disabled || undefined,
|
|
4
|
+
'data-readonly': state.readOnly || undefined,
|
|
5
|
+
'data-open': isPickerOpen || undefined,
|
|
6
|
+
'data-selected': state.selected || undefined,
|
|
7
|
+
});
|
|
8
|
+
const fieldStateAttributes = (state, isOpen) => ({
|
|
9
|
+
'data-open': isOpen || undefined,
|
|
10
|
+
'data-invalid': state.invalid || undefined,
|
|
11
|
+
'data-disabled': state.disabled || undefined,
|
|
12
|
+
'data-readonly': state.readOnly || undefined,
|
|
13
|
+
'data-selected': state.selected || undefined,
|
|
14
|
+
});
|
|
15
|
+
const triggerStateAttributes = (state, isOpen) => ({
|
|
16
|
+
...fieldStateAttributes(state, isOpen),
|
|
17
|
+
'data-disabled': state.disabled || state.readOnly || undefined,
|
|
18
|
+
});
|
|
19
|
+
const segmentStateAttributes = (state) => ({
|
|
20
|
+
'data-invalid': state.invalid || undefined,
|
|
21
|
+
'data-disabled': state.disabled || undefined,
|
|
22
|
+
'data-readonly': state.readOnly || undefined,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { fieldStateAttributes, rootStateAttributes, segmentStateAttributes, triggerStateAttributes };
|
|
26
|
+
//# sourceMappingURL=datePickerStateAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datePickerStateAttributes.js","sources":["../../../Common/datePickerStateAttributes.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** The state the date picker parts expose as data attributes. */\nexport interface DatePickerFieldState {\n invalid: boolean;\n disabled: boolean;\n readOnly: boolean;\n selected: boolean;\n}\n\n/** State attributes of the picker's outer wrapper. */\nexport const rootStateAttributes = (state: DatePickerFieldState, isPickerOpen: boolean) => ({\n 'data-invalid': state.invalid || undefined,\n 'data-disabled': state.disabled || undefined,\n 'data-readonly': state.readOnly || undefined,\n 'data-open': isPickerOpen || undefined,\n 'data-selected': state.selected || undefined,\n});\n\n/** State attributes of the segmented group and input. */\nexport const fieldStateAttributes = (state: DatePickerFieldState, isOpen: boolean) => ({\n 'data-open': isOpen || undefined,\n 'data-invalid': state.invalid || undefined,\n 'data-disabled': state.disabled || undefined,\n 'data-readonly': state.readOnly || undefined,\n 'data-selected': state.selected || undefined,\n});\n\n/** State attributes of the calendar trigger, which is also disabled while read only. */\nexport const triggerStateAttributes = (state: DatePickerFieldState, isOpen: boolean) => ({\n ...fieldStateAttributes(state, isOpen),\n 'data-disabled': state.disabled || state.readOnly || undefined,\n});\n\n/** State attributes of one date or time segment. */\nexport const segmentStateAttributes = (state: DatePickerFieldState) => ({\n 'data-invalid': state.invalid || undefined,\n 'data-disabled': state.disabled || undefined,\n 'data-readonly': state.readOnly || undefined,\n});\n"],"names":[],"mappings":"AAYO,MAAM,mBAAmB,GAAG,CAAC,KAA2B,EAAE,YAAqB,MAAM;AACxF,IAAA,cAAc,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS;AAC1C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC5C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;IAC5C,WAAW,EAAE,YAAY,IAAI,SAAS;AACtC,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC/C,CAAA;AAGM,MAAM,oBAAoB,GAAG,CAAC,KAA2B,EAAE,MAAe,MAAM;IACnF,WAAW,EAAE,MAAM,IAAI,SAAS;AAChC,IAAA,cAAc,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS;AAC1C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC5C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC5C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC/C,CAAA;AAGM,MAAM,sBAAsB,GAAG,CAAC,KAA2B,EAAE,MAAe,MAAM;AACrF,IAAA,GAAG,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC;IACtC,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,SAAS;AACjE,CAAA;MAGY,sBAAsB,GAAG,CAAC,KAA2B,MAAM;AACpE,IAAA,cAAc,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS;AAC1C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC5C,IAAA,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;AAC/C,CAAA;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DateValue } from '@internationalized/date';
|
|
2
|
+
export declare const asDateValue: (value: Date | null, showTime: boolean | undefined) => DateValue | null;
|
|
3
|
+
export declare const asDate: (value: DateValue | null) => Date | null;
|
|
4
|
+
/** The calendar bounds for the configured dates, and whether the Today action falls outside them. */
|
|
5
|
+
export declare const resolveDatePickerBounds: (minDate: Date | null | undefined, maxDate: Date | null | undefined, showTime: boolean | undefined) => {
|
|
6
|
+
minValue: DateValue | undefined;
|
|
7
|
+
maxValue: DateValue | undefined;
|
|
8
|
+
todayDate: Date;
|
|
9
|
+
isTodayOutOfBounds: boolean;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=datePickerValues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datePickerValues.d.ts","sourceRoot":"","sources":["../../../Common/datePickerValues.ts"],"names":[],"mappings":"AAGA,OAAO,EAKH,KAAK,SAAS,EACjB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,WAAW,UACb,IAAI,GAAG,IAAI,YACR,OAAO,GAAG,SAAS,KAC9B,SAAS,GAAG,IAId,CAAC;AAEF,eAAO,MAAM,MAAM,UAAW,SAAS,GAAG,IAAI,KAAG,IAAI,GAAG,IACL,CAAC;AAQpD,qGAAqG;AACrG,eAAO,MAAM,uBAAuB,YACvB,IAAI,GAAG,IAAI,GAAG,SAAS,WACvB,IAAI,GAAG,IAAI,GAAG,SAAS,YACtB,OAAO,GAAG,SAAS;;;;;CAYhC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getLocalTimeZone, fromDate, toCalendarDate, today } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
const asDateValue = (value, showTime) => {
|
|
4
|
+
if (!value)
|
|
5
|
+
return null;
|
|
6
|
+
const zoned = fromDate(value, getLocalTimeZone());
|
|
7
|
+
return showTime ? zoned : toCalendarDate(zoned);
|
|
8
|
+
};
|
|
9
|
+
const asDate = (value) => value ? value.toDate(getLocalTimeZone()) : null;
|
|
10
|
+
const isBelow = (value, minimum) => minimum !== undefined && value.compare(minimum) < 0;
|
|
11
|
+
const isAbove = (value, maximum) => maximum !== undefined && value.compare(maximum) > 0;
|
|
12
|
+
const resolveDatePickerBounds = (minDate, maxDate, showTime) => {
|
|
13
|
+
const timeZone = getLocalTimeZone();
|
|
14
|
+
const minValue = asDateValue(minDate ?? null, showTime) ?? undefined;
|
|
15
|
+
const maxValue = asDateValue(maxDate ?? null, showTime) ?? undefined;
|
|
16
|
+
const todayDate = today(timeZone).toDate(timeZone);
|
|
17
|
+
const todayValue = asDateValue(todayDate, showTime);
|
|
18
|
+
const isTodayOutOfBounds = isBelow(todayValue, minValue) || isAbove(todayValue, maxValue);
|
|
19
|
+
return { minValue, maxValue, todayDate, isTodayOutOfBounds };
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { asDate, asDateValue, resolveDatePickerBounds };
|
|
23
|
+
//# sourceMappingURL=datePickerValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datePickerValues.js","sources":["../../../Common/datePickerValues.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {\n fromDate,\n getLocalTimeZone,\n today,\n toCalendarDate,\n type DateValue,\n} from '@internationalized/date';\n\nexport const asDateValue = (\n value: Date | null,\n showTime: boolean | undefined,\n): DateValue | null => {\n if (!value) return null;\n const zoned = fromDate(value, getLocalTimeZone());\n return showTime ? zoned : toCalendarDate(zoned);\n};\n\nexport const asDate = (value: DateValue | null): Date | null =>\n value ? value.toDate(getLocalTimeZone()) : null;\n\nconst isBelow = (value: DateValue, minimum: DateValue | undefined): boolean =>\n minimum !== undefined && value.compare(minimum) < 0;\n\nconst isAbove = (value: DateValue, maximum: DateValue | undefined): boolean =>\n maximum !== undefined && value.compare(maximum) > 0;\n\n/** The calendar bounds for the configured dates, and whether the Today action falls outside them. */\nexport const resolveDatePickerBounds = (\n minDate: Date | null | undefined,\n maxDate: Date | null | undefined,\n showTime: boolean | undefined,\n) => {\n const timeZone = getLocalTimeZone();\n const minValue = asDateValue(minDate ?? null, showTime) ?? undefined;\n const maxValue = asDateValue(maxDate ?? null, showTime) ?? undefined;\n const todayDate = today(timeZone).toDate(timeZone);\n // Compare the same granularity that the action emits. In date-time mode the Today action\n // retains its existing local-midnight value, which can legitimately fall before a same-day\n // minDate carrying a later time.\n const todayValue = asDateValue(todayDate, showTime)!;\n const isTodayOutOfBounds = isBelow(todayValue, minValue) || isAbove(todayValue, maxValue);\n return { minValue, maxValue, todayDate, isTodayOutOfBounds };\n};\n"],"names":[],"mappings":";;MAWa,WAAW,GAAG,CACvB,KAAkB,EAClB,QAA6B,KACX;AAClB,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,IAAI;IACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACjD,IAAA,OAAO,QAAQ,GAAG,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;AACnD;AAEO,MAAM,MAAM,GAAG,CAAC,KAAuB,KAC1C,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAAG;AAE/C,MAAM,OAAO,GAAG,CAAC,KAAgB,EAAE,OAA8B,KAC7D,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;AAEvD,MAAM,OAAO,GAAG,CAAC,KAAgB,EAAE,OAA8B,KAC7D,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;AAGhD,MAAM,uBAAuB,GAAG,CACnC,OAAgC,EAChC,OAAgC,EAChC,QAA6B,KAC7B;AACA,IAAA,MAAM,QAAQ,GAAG,gBAAgB,EAAE;AACnC,IAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,IAAI,IAAI,EAAE,QAAQ,CAAC,IAAI,SAAS;AACpE,IAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,IAAI,IAAI,EAAE,QAAQ,CAAC,IAAI,SAAS;IACpE,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlD,MAAM,UAAU,GAAG,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAE;AACpD,IAAA,MAAM,kBAAkB,GAAG,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC;IACzF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE;AAChE;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { KeyboardEvent } from 'react';
|
|
2
|
+
import { ToolbarFocusMode } from './ToolbarFocusMode.js';
|
|
3
|
+
export declare const toolSelector = "button, a[href], input, select, textarea, [tabindex]";
|
|
4
|
+
/** Whether the element belongs to this toolbar's own DOM scope, not a portal or a nested toolbar. */
|
|
5
|
+
export declare const isInToolbarScope: (root: HTMLElement | null, tool: Element) => boolean;
|
|
6
|
+
export declare const isDisabledTool: (tool: HTMLElement) => boolean;
|
|
7
|
+
/** Whether the tool or any ancestor below the toolbar root is hidden from users. */
|
|
8
|
+
export declare const isHiddenInside: (tool: HTMLElement, root: HTMLElement) => boolean;
|
|
9
|
+
/** Resolves the tool a key press happened on, or null when the toolbar must not handle it. */
|
|
10
|
+
export declare const resolveKeyTool: (root: HTMLElement | null, target: EventTarget) => HTMLElement | null;
|
|
11
|
+
export declare const resolveDirection: (root: HTMLElement) => string;
|
|
12
|
+
export declare const shouldIgnoreKey: (event: KeyboardEvent, focusMode: ToolbarFocusMode) => boolean;
|
|
13
|
+
//# sourceMappingURL=toolbarFocusQueries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarFocusQueries.d.ts","sourceRoot":"","sources":["../../../Common/toolbarFocusQueries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAoB,CAAC;AAEtD,eAAO,MAAM,YAAY,yDAAyD,CAAC;AAKnF,qGAAqG;AACrG,eAAO,MAAM,gBAAgB,SAAU,WAAW,GAAG,IAAI,QAAQ,OAAO,KAAG,OACiB,CAAC;AAE7F,eAAO,MAAM,cAAc,SAAU,WAAW,KAAG,OAAyC,CAAC;AAY7F,oFAAoF;AACpF,eAAO,MAAM,cAAc,SAAU,WAAW,QAAQ,WAAW,KAAG,OAKrE,CAAC;AAgBF,8FAA8F;AAC9F,eAAO,MAAM,cAAc,SAAU,WAAW,GAAG,IAAI,UAAU,WAAW,KAAG,WAAW,GAAG,IAI5F,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,WAAW,KAAG,MAGpD,CAAC;AAMF,eAAO,MAAM,eAAe,UAAW,aAAa,aAAa,gBAAgB,KAAG,OAC8B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ToolbarFocusMode } from './ToolbarFocusMode.js';
|
|
2
|
+
|
|
3
|
+
const toolSelector = 'button, a[href], input, select, textarea, [tabindex]';
|
|
4
|
+
const widgetSelector = 'input:not([type="button"]):not([type="submit"]):not([type="reset"]), textarea, select, [contenteditable]:not([contenteditable="false"]), [role="slider"], [role="spinbutton"], [role="textbox"], [role="combobox"], [role="listbox"], [role="menu"], [role="menubar"], [role="tree"], [role="grid"], [role="application"]';
|
|
5
|
+
const toolbarSelector = '[role="toolbar"]';
|
|
6
|
+
const disabledSelector = ':disabled, [disabled], [aria-disabled="true"]';
|
|
7
|
+
const isInToolbarScope = (root, tool) => !!root && tool !== root && root.contains(tool) && tool.closest(toolbarSelector) === root;
|
|
8
|
+
const isDisabledTool = (tool) => tool.matches(disabledSelector);
|
|
9
|
+
const hasHiddenAttribute = (element) => !!element.hidden || element.hasAttribute('inert') || element.getAttribute('aria-hidden') === 'true';
|
|
10
|
+
const hasHiddenStyle = (element) => {
|
|
11
|
+
const { display, visibility } = getComputedStyle(element);
|
|
12
|
+
return display === 'none' || visibility === 'hidden' || visibility === 'collapse';
|
|
13
|
+
};
|
|
14
|
+
const isHiddenElement = (element) => hasHiddenAttribute(element) || hasHiddenStyle(element);
|
|
15
|
+
const isHiddenInside = (tool, root) => {
|
|
16
|
+
for (let element = tool; element && element !== root; element = element.parentElement) {
|
|
17
|
+
if (isHiddenElement(element))
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
const isInsideWidget = (target, root) => {
|
|
23
|
+
for (let element = target; element && element !== root; element = element.parentElement) {
|
|
24
|
+
if (element.matches(widgetSelector))
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
const isOwnedTarget = (root, target) => target instanceof Element && root.contains(target) && target.closest(toolbarSelector) === root;
|
|
30
|
+
const isOwnTool = (root, tool) => !!tool && tool !== root && tool.closest(toolbarSelector) === root;
|
|
31
|
+
const resolveKeyTool = (root, target) => {
|
|
32
|
+
if (!root || !isOwnedTarget(root, target) || isInsideWidget(target, root))
|
|
33
|
+
return null;
|
|
34
|
+
const current = target.closest(toolSelector);
|
|
35
|
+
return isOwnTool(root, current) ? current : null;
|
|
36
|
+
};
|
|
37
|
+
const resolveDirection = (root) => {
|
|
38
|
+
const directionElement = root.closest('[dir]');
|
|
39
|
+
return getComputedStyle(root).direction || directionElement?.dir || 'ltr';
|
|
40
|
+
};
|
|
41
|
+
const hasModifier = (event) => event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
|
|
42
|
+
const isHandled = (event) => event.defaultPrevented || event.isPropagationStopped();
|
|
43
|
+
const shouldIgnoreKey = (event, focusMode) => focusMode === ToolbarFocusMode.None || isHandled(event) || hasModifier(event) || event.nativeEvent.isComposing;
|
|
44
|
+
|
|
45
|
+
export { isDisabledTool, isHiddenInside, isInToolbarScope, resolveDirection, resolveKeyTool, shouldIgnoreKey, toolSelector };
|
|
46
|
+
//# sourceMappingURL=toolbarFocusQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarFocusQueries.js","sources":["../../../Common/toolbarFocusQueries.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { KeyboardEvent } from 'react';\nimport { ToolbarFocusMode } from './ToolbarFocusMode';\n\nexport const toolSelector = 'button, a[href], input, select, textarea, [tabindex]';\nconst widgetSelector = 'input:not([type=\"button\"]):not([type=\"submit\"]):not([type=\"reset\"]), textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=\"slider\"], [role=\"spinbutton\"], [role=\"textbox\"], [role=\"combobox\"], [role=\"listbox\"], [role=\"menu\"], [role=\"menubar\"], [role=\"tree\"], [role=\"grid\"], [role=\"application\"]';\nconst toolbarSelector = '[role=\"toolbar\"]';\nconst disabledSelector = ':disabled, [disabled], [aria-disabled=\"true\"]';\n\n/** Whether the element belongs to this toolbar's own DOM scope, not a portal or a nested toolbar. */\nexport const isInToolbarScope = (root: HTMLElement | null, tool: Element): boolean =>\n !!root && tool !== root && root.contains(tool) && tool.closest(toolbarSelector) === root;\n\nexport const isDisabledTool = (tool: HTMLElement): boolean => tool.matches(disabledSelector);\n\nconst hasHiddenAttribute = (element: HTMLElement): boolean =>\n !!element.hidden || element.hasAttribute('inert') || element.getAttribute('aria-hidden') === 'true';\n\nconst hasHiddenStyle = (element: HTMLElement): boolean => {\n const { display, visibility } = getComputedStyle(element);\n return display === 'none' || visibility === 'hidden' || visibility === 'collapse';\n};\n\nconst isHiddenElement = (element: HTMLElement): boolean => hasHiddenAttribute(element) || hasHiddenStyle(element);\n\n/** Whether the tool or any ancestor below the toolbar root is hidden from users. */\nexport const isHiddenInside = (tool: HTMLElement, root: HTMLElement): boolean => {\n for (let element: HTMLElement | null = tool; element && element !== root; element = element.parentElement) {\n if (isHiddenElement(element)) return true;\n }\n return false;\n};\n\nconst isInsideWidget = (target: Element, root: HTMLElement): boolean => {\n for (let element: Element | null = target; element && element !== root; element = element.parentElement) {\n if (element.matches(widgetSelector)) return true;\n }\n return false;\n};\n\n// React events from a portal may bubble here without a DOM ancestor relationship.\nconst isOwnedTarget = (root: HTMLElement, target: EventTarget): target is Element =>\n target instanceof Element && root.contains(target) && target.closest(toolbarSelector) === root;\n\nconst isOwnTool = (root: HTMLElement, tool: HTMLElement | null): tool is HTMLElement =>\n !!tool && tool !== root && tool.closest(toolbarSelector) === root;\n\n/** Resolves the tool a key press happened on, or null when the toolbar must not handle it. */\nexport const resolveKeyTool = (root: HTMLElement | null, target: EventTarget): HTMLElement | null => {\n if (!root || !isOwnedTarget(root, target) || isInsideWidget(target, root)) return null;\n const current = target.closest<HTMLElement>(toolSelector);\n return isOwnTool(root, current) ? current : null;\n};\n\nexport const resolveDirection = (root: HTMLElement): string => {\n const directionElement = root.closest<HTMLElement>('[dir]');\n return getComputedStyle(root).direction || directionElement?.dir || 'ltr';\n};\n\nconst hasModifier = (event: KeyboardEvent): boolean => event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n\nconst isHandled = (event: KeyboardEvent): boolean => event.defaultPrevented || event.isPropagationStopped();\n\nexport const shouldIgnoreKey = (event: KeyboardEvent, focusMode: To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Ac,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ;AAEvH,MAAM,SAAS,GAAG,CAAC,KAAoB,KAAc,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,oBAAoB,EAAE;AAEpG,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,SAA2B,KAC7E,SAAS,KAAK,gBAAgB,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
2
|
+
/** The tools to try focusing for a key, in the order they are tried. */
|
|
3
|
+
export declare const candidatesFor: (key: string, orientation: Orientation, direction: string, available: HTMLElement[], current: HTMLElement) => HTMLElement[];
|
|
4
|
+
/** Focuses the first candidate that accepts focus; false when none did or the walk reached the current tool. */
|
|
5
|
+
export declare const focusFirstFocusable: (candidates: HTMLElement[], current: HTMLElement) => boolean;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=toolbarNavigationCandidates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarNavigationCandidates.d.ts","sourceRoot":"","sources":["../../../Common/toolbarNavigationCandidates.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAwB7C,wEAAwE;AACxE,eAAO,MAAM,aAAa,QAAS,MAAM,eAAe,WAAW,aAAa,MAAM,aAAa,WAAW,EAAE,WAAW,WAAW,KAAG,WAAW,EAOnJ,CAAC;AAKF,gHAAgH;AAChH,eAAO,MAAM,mBAAmB,eAAgB,WAAW,EAAE,WAAW,WAAW,KAAG,OAOrF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const stepKeys = (orientation, direction) => {
|
|
2
|
+
if (orientation === 'vertical')
|
|
3
|
+
return { next: 'ArrowDown', previous: 'ArrowUp' };
|
|
4
|
+
return direction === 'rtl' ? { next: 'ArrowLeft', previous: 'ArrowRight' } : { next: 'ArrowRight', previous: 'ArrowLeft' };
|
|
5
|
+
};
|
|
6
|
+
const isPositioned = (current, tool, position) => !!(current.compareDocumentPosition(tool) & position);
|
|
7
|
+
const toolsAfter = (available, current) => {
|
|
8
|
+
const index = available.indexOf(current);
|
|
9
|
+
return index >= 0
|
|
10
|
+
? available.slice(index + 1)
|
|
11
|
+
: available.filter(tool => isPositioned(current, tool, Node.DOCUMENT_POSITION_FOLLOWING));
|
|
12
|
+
};
|
|
13
|
+
const toolsBefore = (available, current) => {
|
|
14
|
+
const index = available.indexOf(current);
|
|
15
|
+
return index >= 0
|
|
16
|
+
? available.slice(0, index).reverse()
|
|
17
|
+
: available.slice().reverse().filter(tool => isPositioned(current, tool, Node.DOCUMENT_POSITION_PRECEDING));
|
|
18
|
+
};
|
|
19
|
+
const candidatesFor = (key, orientation, direction, available, current) => {
|
|
20
|
+
const { next, previous } = stepKeys(orientation, direction);
|
|
21
|
+
if (key === 'Home')
|
|
22
|
+
return available;
|
|
23
|
+
if (key === 'End')
|
|
24
|
+
return available.slice().reverse();
|
|
25
|
+
if (key === next)
|
|
26
|
+
return toolsAfter(available, current);
|
|
27
|
+
if (key === previous)
|
|
28
|
+
return toolsBefore(available, current);
|
|
29
|
+
return [];
|
|
30
|
+
};
|
|
31
|
+
const holdsFocus = (candidate) => candidate.getRootNode().activeElement === candidate || candidate.matches(':focus');
|
|
32
|
+
const focusFirstFocusable = (candidates, current) => {
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
if (candidate === current)
|
|
35
|
+
return false;
|
|
36
|
+
candidate.focus();
|
|
37
|
+
if (holdsFocus(candidate))
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { candidatesFor, focusFirstFocusable };
|
|
44
|
+
//# sourceMappingURL=toolbarNavigationCandidates.js.map
|