@cratis/components 4.40.0 → 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/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/package.json +6 -4
|
@@ -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,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ode.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: ToolbarFocusMode): boolean =>\n focusMode === ToolbarFocusMode.None || isHandled(event) || hasModifier(event) || event.nativeEvent.isComposing;\n"],"names":[],"mappings":";;AAMO,MAAM,YAAY,GAAG;AAC5B,MAAM,cAAc,GAAG,2TAA2T;AAClV,MAAM,eAAe,GAAG,kBAAkB;AAC1C,MAAM,gBAAgB,GAAG,+CAA+C;AAGjE,MAAM,gBAAgB,GAAG,CAAC,IAAwB,EAAE,IAAa,KACpE,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK;AAEjF,MAAM,cAAc,GAAG,CAAC,IAAiB,KAAc,IAAI,CAAC,OAAO,CAAC,gBAAgB;AAE3F,MAAM,kBAAkB,GAAG,CAAC,OAAoB,KAC5C,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,MAAM;AAEvG,MAAM,cAAc,GAAG,CAAC,OAAoB,KAAa;IACrD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC;IACzD,OAAO,OAAO,KAAK,MAAM,IAAI,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,UAAU;AACrF,CAAC;AAED,MAAM,eAAe,GAA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D,IAAA,OAAO,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,OAAO,GAAG,IAAI;AACpD;AAEO,MAAM,gBAAgB,GAAG,CAAC,IAAiB,KAAY;IAC1D,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAc,OAAO,CAAC;AAC3D,IAAA,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,gBAAgB,EAAE,GAAG,IAAI,KAAK;AAC7E;AAEA,MAAM,WAAW,GAAG,CAAC,KAAoB,KAAc,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarNavigationCandidates.js","sources":["../../../Common/toolbarNavigationCandidates.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\ntype Orientation = 'horizontal' | 'vertical';\n\nconst stepKeys = (orientation: Orientation, direction: string) => {\n if (orientation === 'vertical') return { next: 'ArrowDown', previous: 'ArrowUp' };\n return direction === 'rtl' ? { next: 'ArrowLeft', previous: 'ArrowRight' } : { next: 'ArrowRight', previous: 'ArrowLeft' };\n};\n\nconst isPositioned = (current: HTMLElement, tool: HTMLElement, position: number): boolean =>\n !!(current.compareDocumentPosition(tool) & position);\n\nconst toolsAfter = (available: HTMLElement[], current: HTMLElement): HTMLElement[] => {\n const index = available.indexOf(current);\n return index >= 0\n ? available.slice(index + 1)\n : available.filter(tool => isPositioned(current, tool, Node.DOCUMENT_POSITION_FOLLOWING));\n};\n\nconst toolsBefore = (available: HTMLElement[], current: HTMLElement): HTMLElement[] => {\n const index = available.indexOf(current);\n return index >= 0\n ? available.slice(0, index).reverse()\n : available.slice().reverse().filter(tool => isPositioned(current, tool, Node.DOCUMENT_POSITION_PRECEDING));\n};\n\n/** The tools to try focusing for a key, in the order they are tried. */\nexport const candidatesFor = (key: string, orientation: Orientation, direction: string, available: HTMLElement[], current: HTMLElement): HTMLElement[] => {\n const { next, previous } = stepKeys(orientation, direction);\n if (key === 'Home') return available;\n if (key === 'End') return available.slice().reverse();\n if (key === next) return toolsAfter(available, current);\n if (key === previous) return toolsBefore(available, current);\n return [];\n};\n\nconst holdsFocus = (candidate: HTMLElement): boolean =>\n (candidate.getRootNode() as Document | ShadowRoot).activeElement === candidate || candidate.matches(':focus');\n\n/** Focuses the first candidate that accepts focus; false when none did or the walk reached the current tool. */\nexport const focusFirstFocusable = (candidates: HTMLElement[], current: HTMLElement): boolean => {\n for (const candidate of candidates) {\n if (candidate === current) return false;\n candidate.focus();\n if (holdsFocus(candidate)) return true;\n }\n return false;\n};\n"],"names":[],"mappings":"AAKA,MAAM,QAAQ,GAAG,CAAC,WAAwB,EAAE,SAAiB,KAAI;IAC7D,IAAI,WAAW,KAAK,UAAU;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE;IACjF,OAAO,SAAS,KAAK,KAAK,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE;AAC9H,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,OAAoB,EAAE,IAAiB,EAAE,QAAgB,KAC3E,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;AAExD,MAAM,UAAU,GAAG,CAAC,SAAwB,EAAE,OAAoB,KAAmB;IACjF,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,OAAO,KAAK,IAAI;UACV,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC;UACzB,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;AACjG,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,SAAwB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AAA,OAAO,IAAI;IAC1C;AACA,IAAA,OAAO,KAAK;AAChB;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** What a toolbar knows about the tools it owns in single-Tab-stop mode. */
|
|
2
|
+
export interface ToolbarTabStopState {
|
|
3
|
+
managedByKey: Map<string, HTMLElement>;
|
|
4
|
+
keyByManaged: Map<HTMLElement, string>;
|
|
5
|
+
activeKey: string | null;
|
|
6
|
+
listeners: Set<() => void>;
|
|
7
|
+
inScope: Set<string>;
|
|
8
|
+
resizeObserver: ResizeObserver | null;
|
|
9
|
+
pendingRemoval: Set<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare const createToolbarTabStopState: () => ToolbarTabStopState;
|
|
12
|
+
export declare const notifyListeners: (state: ToolbarTabStopState) => void;
|
|
13
|
+
export declare const setActiveKey: (state: ToolbarTabStopState, key: string | null) => boolean;
|
|
14
|
+
export declare const isAvailableTool: (root: HTMLElement | null, state: ToolbarTabStopState, tool: HTMLElement) => boolean;
|
|
15
|
+
export declare const availableTools: (root: HTMLElement | null, state: ToolbarTabStopState) => HTMLElement[];
|
|
16
|
+
/**
|
|
17
|
+
* Keeps the active tool available: when it is removed, disabled, hidden, moved out of scope, or
|
|
18
|
+
* opts out with its own tab index, the first available tool the toolbar owns becomes the single
|
|
19
|
+
* Tab stop. This only changes the toolbar's own state; tools render their tab index from it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const reconcileTabStop: (root: HTMLElement | null, state: ToolbarTabStopState) => void;
|
|
22
|
+
/** Forgets tools that unregistered and did not register again. */
|
|
23
|
+
export declare const dropPendingRemovals: (state: ToolbarTabStopState) => void;
|
|
24
|
+
/** Registers a tool element for a key. Returns true when the toolbar should reconcile soon. */
|
|
25
|
+
export declare const registerManagedTool: (state: ToolbarTabStopState, key: string, element: HTMLElement) => boolean;
|
|
26
|
+
/** Marks a key's tool for removal; a re-attach of the same element before the check costs nothing. */
|
|
27
|
+
export declare const markForRemoval: (state: ToolbarTabStopState, key: string)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AACtG,eAAO,MAAM,cAAc,UAAW,mBAAmB,OAAO,MAAM,KAAG,IAExE,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { toolSelector, isInToolbarScope, isDisabledTool, isHiddenInside } from './toolbarFocusQueries.js';
|
|
2
|
+
|
|
3
|
+
const createToolbarTabStopState = () => ({
|
|
4
|
+
managedByKey: new Map(),
|
|
5
|
+
keyByManaged: new Map(),
|
|
6
|
+
activeKey: null,
|
|
7
|
+
listeners: new Set(),
|
|
8
|
+
inScope: new Set(),
|
|
9
|
+
resizeObserver: null,
|
|
10
|
+
pendingRemoval: new Set(),
|
|
11
|
+
});
|
|
12
|
+
const notifyListeners = (state) => state.listeners.forEach(listener => listener());
|
|
13
|
+
const setActiveKey = (state, key) => {
|
|
14
|
+
if (state.activeKey === key)
|
|
15
|
+
return false;
|
|
16
|
+
state.activeKey = key;
|
|
17
|
+
notifyListeners(state);
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
const isAvailableTool = (root, state, tool) => {
|
|
21
|
+
if (!root || !isInToolbarScope(root, tool) || isDisabledTool(tool))
|
|
22
|
+
return false;
|
|
23
|
+
if (tool.getAttribute('tabindex') === '-1' && !state.keyByManaged.has(tool))
|
|
24
|
+
return false;
|
|
25
|
+
return !isHiddenInside(tool, root);
|
|
26
|
+
};
|
|
27
|
+
const availableTools = (root, state) => root ? Array.from(root.querySelectorAll(toolSelector)).filter(tool => isAvailableTool(root, state, tool)) : [];
|
|
28
|
+
const syncScope = (root, state) => {
|
|
29
|
+
let scopeChanged = false;
|
|
30
|
+
for (const key of state.inScope) {
|
|
31
|
+
if (!state.managedByKey.has(key))
|
|
32
|
+
state.inScope.delete(key);
|
|
33
|
+
}
|
|
34
|
+
for (const [key, element] of state.managedByKey) {
|
|
35
|
+
const inside = isInToolbarScope(root, element);
|
|
36
|
+
if (inside === state.inScope.has(key))
|
|
37
|
+
continue;
|
|
38
|
+
if (inside)
|
|
39
|
+
state.inScope.add(key);
|
|
40
|
+
else
|
|
41
|
+
state.inScope.delete(key);
|
|
42
|
+
scopeChanged = true;
|
|
43
|
+
}
|
|
44
|
+
return scopeChanged;
|
|
45
|
+
};
|
|
46
|
+
const isActiveToolUsable = (root, state) => {
|
|
47
|
+
const key = state.activeKey;
|
|
48
|
+
const element = key === null ? undefined : state.managedByKey.get(key);
|
|
49
|
+
return !!element && state.inScope.has(key) && isAvailableTool(root, state, element);
|
|
50
|
+
};
|
|
51
|
+
const reconcileTabStop = (root, state) => {
|
|
52
|
+
const scopeChanged = syncScope(root, state);
|
|
53
|
+
if (!isActiveToolUsable(root, state)) {
|
|
54
|
+
const first = availableTools(root, state).find(tool => state.inScope.has(state.keyByManaged.get(tool) ?? ''));
|
|
55
|
+
if (setActiveKey(state, first ? state.keyByManaged.get(first) : null))
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (scopeChanged)
|
|
59
|
+
notifyListeners(state);
|
|
60
|
+
};
|
|
61
|
+
const forgetManaged = (state, element) => {
|
|
62
|
+
state.keyByManaged.delete(element);
|
|
63
|
+
state.resizeObserver?.unobserve(element);
|
|
64
|
+
};
|
|
65
|
+
const dropPendingRemovals = (state) => {
|
|
66
|
+
for (const key of state.pendingRemoval) {
|
|
67
|
+
const element = state.managedByKey.get(key);
|
|
68
|
+
if (element)
|
|
69
|
+
forgetManaged(state, element);
|
|
70
|
+
state.managedByKey.delete(key);
|
|
71
|
+
}
|
|
72
|
+
state.pendingRemoval.clear();
|
|
73
|
+
};
|
|
74
|
+
const registerManagedTool = (state, key, element) => {
|
|
75
|
+
const previous = state.managedByKey.get(key);
|
|
76
|
+
if (previous === element && state.pendingRemoval.delete(key))
|
|
77
|
+
return false;
|
|
78
|
+
state.pendingRemoval.delete(key);
|
|
79
|
+
if (previous === element)
|
|
80
|
+
return false;
|
|
81
|
+
if (previous)
|
|
82
|
+
forgetManaged(state, previous);
|
|
83
|
+
state.managedByKey.set(key, element);
|
|
84
|
+
state.keyByManaged.set(element, key);
|
|
85
|
+
state.resizeObserver?.observe(element);
|
|
86
|
+
return true;
|
|
87
|
+
};
|
|
88
|
+
const markForRemoval = (state, key) => {
|
|
89
|
+
if (state.managedByKey.has(key))
|
|
90
|
+
state.pendingRemoval.add(key);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { availableTools, createToolbarTabStopState, dropPendingRemovals, isAvailableTool, markForRemoval, notifyListeners, reconcileTabStop, registerManagedTool, setActiveKey };
|
|
94
|
+
//# sourceMappingURL=toolbarTabStop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbarTabStop.js","sources":["../../../Common/toolbarTabStop.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 { isDisabledTool, isHiddenInside, isInToolbarScope, toolSelector } from './toolbarFocusQueries';\n\n/** What a toolbar knows about the tools it owns in single-Tab-stop mode. */\nexport interface ToolbarTabStopState {\n // Their -1 tab index comes from this toolbar, so it does not make them unreachable by arrow keys.\n managedByKey: Map<string, HTMLElement>;\n keyByManaged: Map<HTMLElement, string>;\n activeKey: string | null;\n listeners: Set<() => void>;\n // Keys of managed tools that lie in this toolbar's own DOM scope. A tool rendered through a\n // portal or under a nested consumer toolbar can never be reached from here, so it keeps its\n // native Tab stop instead of a -1 the toolbar could never lift.\n inScope: Set<string>;\n resizeObserver: ResizeObserver | null;\n pendingRemoval: Set<string>;\n}\n\nexport const createToolbarTabStopState = (): ToolbarTabStopState => ({\n managedByKey: new Map(),\n keyByManaged: new Map(),\n activeKey: null,\n listeners: new Set(),\n inScope: new Set(),\n resizeObserver: null,\n pendingRemoval: new Set(),\n});\n\nexport const notifyListeners = (state: ToolbarTabStopState): void => state.listeners.forEach(listener => listener());\n\nexport const setActiveKey = (state: ToolbarTabStopState, key: string | null): boolean => {\n if (state.activeKey === key) return false;\n state.activeKey = key;\n notifyListeners(state);\n return true;\n};\n\nexport const isAvailableTool = (root: HTMLElement | null, state: ToolbarTabStopState, tool: HTMLElement): boolean => {\n if (!root || !isInToolbarScope(root, tool) || isDisabledTool(tool)) return false;\n if (tool.getAttribute('tabindex') === '-1' && !state.keyByManaged.has(tool)) return false;\n return !isHiddenInside(tool, root);\n};\n\nexport const availableTools = (root: HTMLElement | null, state: ToolbarTabStopState): HTMLElement[] =>\n root ? Array.from(root.querySelectorAll<HTMLElement>(toolSelector)).filter(tool => isAvailableTool(root, state, tool)) : [];\n\n// Drops stale keys and records which managed tools moved in or out of scope; true when any did.\nconst syncScope = (root: HTMLElement | null, state: ToolbarTabStopState): boolean => {\n let scopeChanged = false;\n for (const key of state.inScope) {\n if (!state.managedByKey.has(key)) state.inScope.delete(key);\n }\n for (const [key, element] of state.managedByKey) {\n const inside = isInToolbarScope(root, element);\n if (inside === state.inScope.has(key)) continue;\n if (inside) state.inScope.add(key);\n else state.inScope.delete(key);\n scopeChanged = true;\n }\n return scopeChanged;\n};\n\nconst isActiveToolUsable = (root: HTMLElement | null, state: ToolbarTabStopState): boolean => {\n const key = state.activeKey;\n const element = key === null ? undefined : state.managedByKey.get(key);\n return !!element && state.inScope.has(key!) && isAvailableTool(root, state, element);\n};\n\n/**\n * Keeps the active tool available: when it is removed, disabled, hidden, moved out of scope, or\n * opts out with its own tab index, the first available tool the toolbar owns becomes the single\n * Tab stop. This only changes the toolbar's own state; tools render their tab index from it.\n */\nexport const reconcileTabStop = (root: HTMLElement | null, state: ToolbarTabStopState): void => {\n const scopeChanged = syncScope(root, state);\n // Checking the active tool alone is enough on most renders; the full scan runs only when it is gone.\n if (!isActiveToolUsable(root, state)) {\n const first = availableTools(root, state).find(tool => state.inScope.has(state.keyByManaged.get(tool) ?? ''));\n if (setActiveKey(state, first ? state.keyByManaged.get(first)! : null)) return;\n }\n if (scopeChanged) notifyListeners(state);\n};\n\nconst forgetManaged = (state: ToolbarTabStopState, element: HTMLElement): void => {\n state.keyByManaged.delete(element);\n state.resizeObserver?.unobserve(element);\n};\n\n/** Forgets tools that unregistered and did not register again. */\nexport const dropPendingRemovals = (state: ToolbarTabStopState): void => {\n for (const key of state.pendingRemoval) {\n const element = state.managedByKey.get(key);\n if (element) forgetManaged(state, element);\n state.managedByKey.delete(key);\n }\n state.pendingRemoval.clear();\n};\n\n/** Registers a tool element for a key. Returns true when the toolbar should reconcile soon. */\nexport const registerManagedTool = (state: ToolbarTabStopState, key: string, element: HTMLElement): boolean => {\n const previous = state.managedByKey.get(key);\n if (previous === element && state.pendingRemoval.delete(key)) return false;\n state.pendingRemoval.delete(key);\n if (previous === element) return false;\n if (previous) forgetManaged(state, previous);\n state.managedByKey.set(key, element);\n state.keyByManaged.set(element, key);\n state.resizeObserver?.observe(element);\n return true;\n};\n\n/** Marks a key's tool for removal; a re-attach of the same element before the check costs nothing. */\nexport const markForRemoval = (state: ToolbarTabStopState, key: string): void => {\n if (state.managedByKey.has(key)) state.pendingRemoval.add(key);\n};\n"],"names":[],"mappings":";;AAoBO,MAAM,yBAAyB,GAAG,OAA4B;IACjE,YAAY,EAAE,IAAI,GAAG,EAAE;IACvB,YAAY,EAAE,IAAI,GAAG,EAAE;AACvB,IAAA,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI,GAAG,EAAE;IACpB,OAAO,EAAE,IAAI,GAAG,EAAE;AAClB,IAAA,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI,GAAG,EAAE;AAC5B,CAAA;MAEY,eAAe,GAAG,CAAC,KAA0B,KAAW,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,EAAE;MAEtG,YAAY,GAAG,CAAC,KAA0B,EAAE,GAAkB,KAAa;AACpF,IAAA,IAAI,KAAK,CAAC,SAAS,KAAK,GAAG;AAAE,QAAA,OAAO,KAAK;AACzC,IAAA,KAAK,CAAC,SAAS,GAAG,GAAG;IACrB,eAAe,CAAC,KAAK,CAAC;AACtB,IAAA,OAAO,IAAI;AACf;AAEO,MAAM,eAAe,GAAG,CA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