@cloudscape-design/components 3.0.530 → 3.0.532
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/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +2 -1
- package/autosuggest/internal.js.map +1 -1
- package/calendar/grid/calendar-grid-header.d.ts +6 -0
- package/calendar/grid/calendar-grid-header.d.ts.map +1 -0
- package/calendar/grid/calendar-grid-header.js +16 -0
- package/calendar/grid/calendar-grid-header.js.map +1 -0
- package/calendar/grid/index.d.ts +10 -8
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js +12 -65
- package/calendar/grid/index.js.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts +11 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts.map +1 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js +47 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js.map +1 -0
- package/calendar/grid/use-calendar-grid-rows.d.ts +6 -0
- package/calendar/grid/use-calendar-grid-rows.d.ts.map +1 -0
- package/calendar/grid/use-calendar-grid-rows.js +11 -0
- package/calendar/grid/use-calendar-grid-rows.js.map +1 -0
- package/calendar/header/header-button.d.ts +3 -4
- package/calendar/header/header-button.d.ts.map +1 -1
- package/calendar/header/header-button.js +4 -5
- package/calendar/header/header-button.js.map +1 -1
- package/calendar/header/index.d.ts +5 -6
- package/calendar/header/index.d.ts.map +1 -1
- package/calendar/header/index.js +5 -6
- package/calendar/header/index.js.map +1 -1
- package/calendar/internal.d.ts +1 -2
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +34 -19
- package/calendar/internal.js.map +1 -1
- package/calendar/styles.css.js +18 -18
- package/calendar/styles.scoped.css +39 -39
- package/calendar/styles.selectors.js +18 -18
- package/calendar/use-calendar-labels.d.ts +16 -0
- package/calendar/use-calendar-labels.d.ts.map +1 -0
- package/calendar/use-calendar-labels.js +28 -0
- package/calendar/use-calendar-labels.js.map +1 -0
- package/calendar/utils/navigation.d.ts +1 -1
- package/calendar/utils/navigation.d.ts.map +1 -1
- package/calendar/utils/navigation.js +10 -11
- package/calendar/utils/navigation.js.map +1 -1
- package/date-range-picker/calendar/grids/index.js +2 -2
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +2 -2
- package/date-range-picker/calendar/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAejE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAWlF,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;CAAG;AAEjG,QAAA,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["autosuggest/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAIhE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAejE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAWlF,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB,EAAE,0BAA0B;CAAG;AAEjG,QAAA,MAAM,mBAAmB,uGA8NvB,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
package/autosuggest/internal.js
CHANGED
|
@@ -34,7 +34,8 @@ const InternalAutosuggest = React.forwardRef((props, ref) => {
|
|
|
34
34
|
if (restProps.recoveryText && !onLoadItems) {
|
|
35
35
|
warnOnce('Autosuggest', '`onLoadItems` must be provided for `recoveryText` to be displayed.');
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
const enteredTextLabelI18nTestValue = i18n('enteredTextLabel', undefined, format => format({ value: '' }));
|
|
38
|
+
if (!enteredTextLabel && enteredTextLabelI18nTestValue === undefined) {
|
|
38
39
|
warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');
|
|
39
40
|
}
|
|
40
41
|
const [autosuggestItemsState, autosuggestItemsHandlers] = useAutosuggestItems({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["autosuggest/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAEL,mBAAmB,EACnB,sBAAsB,GAEvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,sBAAsB,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,gBAAyC,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAIzE,MAAM,mBAAmB,GAAG,KAA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CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,cAAc,IAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,EAAE,EAAE,eAAe,GAAI,CAAC,CAAC,CAAC,IAAI,EAE5G,eAAe,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,GACrE,CACH,EAEH,cAAc,EACZ,cAAc,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAClD,oBAAC,cAAc,IACb,EAAE,EAAE,eAAe,EACnB,OAAO,EAAE,cAAc,CAAC,OAAO,EAC/B,QAAQ,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GACjD,CACH,CAAC,CAAC,CAAC,IAAI,EAEV,SAAS,EAAE,UAAU,KAAK,OAAO,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,WAAW,EACpE,eAAe,EAAE,mBAAmB,EACpC,cAAc,EAAE,kBAAkB,EAClC,gBAAgB,EAAE,oBAAoB,EACtC,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gBAAgB,IAC9B,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useAutosuggestItems } from './options-controller';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\n\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport {\n BaseKeyDetail,\n fireCancelableEvent,\n fireNonCancelableEvent,\n NonCancelableCustomEvent,\n} from '../internal/events';\nimport { BaseChangeDetail } from '../input/interfaces';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport AutosuggestOptionsList from './options-list';\nimport { useAutosuggestLoadMore } from './load-more-controller';\nimport { OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';\nimport AutosuggestInput, { AutosuggestInputRef } from '../internal/components/autosuggest-input';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { useInternalI18n } from '../i18n/context';\n\nimport styles from './styles.css.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {}\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<AutosuggestProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n clearAriaLabel,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n filteringResultsText,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n renderHighlightedAriaLive,\n __internalRootRef,\n ...restProps\n } = props;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const autosuggestInputRef = useRef<AutosuggestInputRef>(null);\n useImperativeHandle(\n ref,\n () => ({\n focus: () => autosuggestInputRef.current?.focus(),\n select: () => autosuggestInputRef.current?.select(),\n }),\n []\n );\n\n const i18n = useInternalI18n('autosuggest');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Autosuggest', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n if (!enteredTextLabel) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const [autosuggestItemsState, autosuggestItemsHandlers] = useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText: value,\n filteringType,\n hideEnteredTextLabel: false,\n onSelectItem: (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n fireNonCancelableEvent(onSelect, {\n value,\n selectedOption: option.type !== 'use-entered' ? option.option : undefined,\n });\n autosuggestInputRef.current?.close();\n },\n });\n\n const autosuggestLoadMoreHandlers = useAutosuggestLoadMore({\n options,\n statusType,\n onLoadItems: (detail: OptionsLoadItemsDetail) => fireNonCancelableEvent(onLoadItems, detail),\n });\n\n const handleChange = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestItemsHandlers.setShowAll(false);\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n fireNonCancelableEvent(onChange, event.detail);\n };\n\n const handleDelayedInput = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value);\n };\n\n const handleBlur = () => {\n fireNonCancelableEvent(onBlur, null);\n };\n\n const handleFocus = () => {\n autosuggestItemsHandlers.setShowAll(true);\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();\n fireNonCancelableEvent(onFocus, null);\n };\n\n const handleKeyUp = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyUp, event.detail, event);\n };\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyDown, event.detail, event);\n };\n\n const handlePressArrowDown = () => {\n autosuggestItemsHandlers.moveHighlightWithKeyboard(1);\n };\n\n const handlePressArrowUp = () => {\n autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);\n };\n\n const handlePressEnter = () => {\n return autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard();\n };\n\n const handleCloseDropdown = () => {\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n };\n\n const handleRecoveryClick = () => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnRecoveryClick();\n autosuggestInputRef.current?.focus();\n };\n\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('input');\n const footerControlId = useUniqueId('footer');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const listId = useUniqueId('list');\n const highlightedOptionIdSource = useUniqueId();\n const highlightedOptionId = autosuggestItemsState.highlightedOption ? highlightedOptionIdSource : undefined;\n\n const isEmpty = !value && !autosuggestItemsState.items.length;\n const isFiltered = !!value && value.length !== 0;\n const filteredText = isFiltered\n ? filteringResultsText?.(autosuggestItemsState.items.length, options?.length ?? 0)\n : undefined;\n const dropdownStatus = useDropdownStatus({\n ...props,\n isEmpty,\n isFiltered,\n recoveryText,\n errorIconAriaLabel,\n onRecoveryClick: handleRecoveryClick,\n filteringResultsText: filteredText,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const shouldRenderDropdownContent = !isEmpty || dropdownStatus.content;\n\n return (\n <AutosuggestInput\n {...restProps}\n className={clsx(styles.root, restProps.className)}\n ref={autosuggestInputRef}\n __internalRootRef={__internalRootRef}\n value={value}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n name={name}\n controlId={controlId}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n expandToViewport={expandToViewport}\n ariaControls={listId}\n ariaActivedescendant={highlightedOptionId}\n dropdownExpanded={autosuggestItemsState.items.length > 1 || dropdownStatus.content !== null}\n dropdownContent={\n shouldRenderDropdownContent && (\n <AutosuggestOptionsList\n statusType={statusType}\n autosuggestItemsState={autosuggestItemsState}\n autosuggestItemsHandlers={autosuggestItemsHandlers}\n highlightedOptionId={highlightedOptionId}\n highlightText={value}\n listId={listId}\n controlId={controlId}\n enteredTextLabel={enteredTextLabel}\n handleLoadMore={autosuggestLoadMoreHandlers.fireLoadMoreOnScroll}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={\n !dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} id={footerControlId} /> : null\n }\n ariaDescribedby={dropdownStatus.content ? footerControlId : undefined}\n />\n )\n }\n dropdownFooter={\n dropdownStatus.isSticky && dropdownStatus.content ? (\n <DropdownFooter\n id={footerControlId}\n content={dropdownStatus.content}\n hasItems={autosuggestItemsState.items.length >= 1}\n />\n ) : null\n }\n loopFocus={statusType === 'error' && !!recoveryText && !!onLoadItems}\n onCloseDropdown={handleCloseDropdown}\n onDelayedInput={handleDelayedInput}\n onPressArrowDown={handlePressArrowDown}\n onPressArrowUp={handlePressArrowUp}\n onPressEnter={handlePressEnter}\n />\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["autosuggest/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,cAAc,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAEL,mBAAmB,EACnB,sBAAsB,GAEvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,eAA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tC,cAAc,EAAE,kBAAkB,EAClC,YAAY,EAAE,gBAAgB,IAC9B,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useAutosuggestItems } from './options-controller';\nimport { AutosuggestItem, AutosuggestProps } from './interfaces';\n\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport DropdownFooter from '../internal/components/dropdown-footer';\n\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport {\n BaseKeyDetail,\n fireCancelableEvent,\n fireNonCancelableEvent,\n NonCancelableCustomEvent,\n} from '../internal/events';\nimport { BaseChangeDetail } from '../input/interfaces';\nimport { checkOptionValueField } from '../select/utils/check-option-value-field';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport AutosuggestOptionsList from './options-list';\nimport { useAutosuggestLoadMore } from './load-more-controller';\nimport { OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';\nimport AutosuggestInput, { AutosuggestInputRef } from '../internal/components/autosuggest-input';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport { useInternalI18n } from '../i18n/context';\n\nimport styles from './styles.css.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nexport interface InternalAutosuggestProps extends AutosuggestProps, InternalBaseComponentProps {}\n\nconst InternalAutosuggest = React.forwardRef((props: InternalAutosuggestProps, ref: Ref<AutosuggestProps.Ref>) => {\n const {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onLoadItems,\n options,\n filteringType = 'auto',\n statusType = 'finished',\n placeholder,\n clearAriaLabel,\n name,\n disabled,\n disableBrowserAutocorrect = false,\n autoFocus,\n readOnly,\n ariaLabel,\n ariaRequired,\n enteredTextLabel,\n filteringResultsText,\n onKeyDown,\n virtualScroll,\n expandToViewport,\n onSelect,\n renderHighlightedAriaLive,\n __internalRootRef,\n ...restProps\n } = props;\n\n checkControlled('Autosuggest', 'value', value, 'onChange', onChange);\n checkOptionValueField('Autosuggest', 'options', options);\n\n const autosuggestInputRef = useRef<AutosuggestInputRef>(null);\n useImperativeHandle(\n ref,\n () => ({\n focus: () => autosuggestInputRef.current?.focus(),\n select: () => autosuggestInputRef.current?.select(),\n }),\n []\n );\n\n const i18n = useInternalI18n('autosuggest');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Autosuggest', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const enteredTextLabelI18nTestValue = i18n('enteredTextLabel', undefined, format => format({ value: '' }));\n if (!enteredTextLabel && enteredTextLabelI18nTestValue === undefined) {\n warnOnce('Autosuggest', 'A value for enteredTextLabel must be provided.');\n }\n\n const [autosuggestItemsState, autosuggestItemsHandlers] = useAutosuggestItems({\n options: options || [],\n filterValue: value,\n filterText: value,\n filteringType,\n hideEnteredTextLabel: false,\n onSelectItem: (option: AutosuggestItem) => {\n const value = option.value || '';\n fireNonCancelableEvent(onChange, { value });\n fireNonCancelableEvent(onSelect, {\n value,\n selectedOption: option.type !== 'use-entered' ? option.option : undefined,\n });\n autosuggestInputRef.current?.close();\n },\n });\n\n const autosuggestLoadMoreHandlers = useAutosuggestLoadMore({\n options,\n statusType,\n onLoadItems: (detail: OptionsLoadItemsDetail) => fireNonCancelableEvent(onLoadItems, detail),\n });\n\n const handleChange = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestItemsHandlers.setShowAll(false);\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n fireNonCancelableEvent(onChange, event.detail);\n };\n\n const handleDelayedInput = (event: NonCancelableCustomEvent<BaseChangeDetail>) => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputChange(event.detail.value);\n };\n\n const handleBlur = () => {\n fireNonCancelableEvent(onBlur, null);\n };\n\n const handleFocus = () => {\n autosuggestItemsHandlers.setShowAll(true);\n autosuggestLoadMoreHandlers.fireLoadMoreOnInputFocus();\n fireNonCancelableEvent(onFocus, null);\n };\n\n const handleKeyUp = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyUp, event.detail, event);\n };\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n fireCancelableEvent(onKeyDown, event.detail, event);\n };\n\n const handlePressArrowDown = () => {\n autosuggestItemsHandlers.moveHighlightWithKeyboard(1);\n };\n\n const handlePressArrowUp = () => {\n autosuggestItemsHandlers.moveHighlightWithKeyboard(-1);\n };\n\n const handlePressEnter = () => {\n return autosuggestItemsHandlers.selectHighlightedOptionWithKeyboard();\n };\n\n const handleCloseDropdown = () => {\n autosuggestItemsHandlers.resetHighlightWithKeyboard();\n };\n\n const handleRecoveryClick = () => {\n autosuggestLoadMoreHandlers.fireLoadMoreOnRecoveryClick();\n autosuggestInputRef.current?.focus();\n };\n\n const formFieldContext = useFormFieldContext(restProps);\n const selfControlId = useUniqueId('input');\n const footerControlId = useUniqueId('footer');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const listId = useUniqueId('list');\n const highlightedOptionIdSource = useUniqueId();\n const highlightedOptionId = autosuggestItemsState.highlightedOption ? highlightedOptionIdSource : undefined;\n\n const isEmpty = !value && !autosuggestItemsState.items.length;\n const isFiltered = !!value && value.length !== 0;\n const filteredText = isFiltered\n ? filteringResultsText?.(autosuggestItemsState.items.length, options?.length ?? 0)\n : undefined;\n const dropdownStatus = useDropdownStatus({\n ...props,\n isEmpty,\n isFiltered,\n recoveryText,\n errorIconAriaLabel,\n onRecoveryClick: handleRecoveryClick,\n filteringResultsText: filteredText,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const shouldRenderDropdownContent = !isEmpty || dropdownStatus.content;\n\n return (\n <AutosuggestInput\n {...restProps}\n className={clsx(styles.root, restProps.className)}\n ref={autosuggestInputRef}\n __internalRootRef={__internalRootRef}\n value={value}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyUp={handleKeyUp}\n onKeyDown={handleKeyDown}\n name={name}\n controlId={controlId}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n autoFocus={autoFocus}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n expandToViewport={expandToViewport}\n ariaControls={listId}\n ariaActivedescendant={highlightedOptionId}\n dropdownExpanded={autosuggestItemsState.items.length > 1 || dropdownStatus.content !== null}\n dropdownContent={\n shouldRenderDropdownContent && (\n <AutosuggestOptionsList\n statusType={statusType}\n autosuggestItemsState={autosuggestItemsState}\n autosuggestItemsHandlers={autosuggestItemsHandlers}\n highlightedOptionId={highlightedOptionId}\n highlightText={value}\n listId={listId}\n controlId={controlId}\n enteredTextLabel={enteredTextLabel}\n handleLoadMore={autosuggestLoadMoreHandlers.fireLoadMoreOnScroll}\n hasDropdownStatus={dropdownStatus.content !== null}\n virtualScroll={virtualScroll}\n selectedAriaLabel={selectedAriaLabel}\n renderHighlightedAriaLive={renderHighlightedAriaLive}\n listBottom={\n !dropdownStatus.isSticky ? <DropdownFooter content={dropdownStatus.content} id={footerControlId} /> : null\n }\n ariaDescribedby={dropdownStatus.content ? footerControlId : undefined}\n />\n )\n }\n dropdownFooter={\n dropdownStatus.isSticky && dropdownStatus.content ? (\n <DropdownFooter\n id={footerControlId}\n content={dropdownStatus.content}\n hasItems={autosuggestItemsState.items.length >= 1}\n />\n ) : null\n }\n loopFocus={statusType === 'error' && !!recoveryText && !!onLoadItems}\n onCloseDropdown={handleCloseDropdown}\n onDelayedInput={handleDelayedInput}\n onPressArrowDown={handlePressArrowDown}\n onPressArrowUp={handlePressArrowUp}\n onPressEnter={handlePressEnter}\n />\n );\n});\n\nexport default InternalAutosuggest;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-grid-header.d.ts","sourceRoot":"lib/default/","sources":["calendar/grid/calendar-grid-header.tsx"],"names":[],"mappings":";AASA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAA;CAAE,eAmB9F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import ScreenreaderOnly from '../../internal/components/screenreader-only';
|
|
6
|
+
import { renderDayName } from '../utils/intl';
|
|
7
|
+
import styles from '../styles.css.js';
|
|
8
|
+
export default function CalendarGridHeader({ locale, rows }) {
|
|
9
|
+
return (React.createElement("thead", null,
|
|
10
|
+
React.createElement("tr", null, rows[0]
|
|
11
|
+
.map(date => date.getDay())
|
|
12
|
+
.map(dayIndex => (React.createElement("th", { key: dayIndex, scope: "col", className: clsx(styles['calendar-grid-cell'], styles['calendar-date-header']) },
|
|
13
|
+
React.createElement("span", { "aria-hidden": "true" }, renderDayName(locale, dayIndex, 'short')),
|
|
14
|
+
React.createElement(ScreenreaderOnly, null, renderDayName(locale, dayIndex, 'long'))))))));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=calendar-grid-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-grid-header.js","sourceRoot":"lib/default/","sources":["calendar/grid/calendar-grid-header.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,gBAAgB,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAsC;IAC7F,OAAO,CACL;QACE,gCACG,IAAI,CAAC,CAAC,CAAC;aACL,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1B,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CACf,4BACE,GAAG,EAAE,QAAQ,EACb,KAAK,EAAC,KAAK,EACX,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,sBAAsB,CAAC,CAAC;YAE7E,6CAAkB,MAAM,IAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAQ;YAC1E,oBAAC,gBAAgB,QAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAoB,CAC3E,CACN,CAAC,CACD,CACC,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport clsx from 'clsx';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only';\nimport { renderDayName } from '../utils/intl';\nimport styles from '../styles.css.js';\n\nexport default function CalendarGridHeader({ locale, rows }: { locale: string; rows: Date[][] }) {\n return (\n <thead>\n <tr>\n {rows[0]\n .map(date => date.getDay())\n .map(dayIndex => (\n <th\n key={dayIndex}\n scope=\"col\"\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date-header'])}\n >\n <span aria-hidden=\"true\">{renderDayName(locale, dayIndex, 'short')}</span>\n <ScreenreaderOnly>{renderDayName(locale, dayIndex, 'long')}</ScreenreaderOnly>\n </th>\n ))}\n </tr>\n </thead>\n );\n}\n"]}
|
package/calendar/grid/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { DayIndex } from '../internal';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { DatePickerProps } from '../../date-picker/interfaces';
|
|
4
3
|
/**
|
|
5
4
|
* Calendar grid supports two mechanisms of keyboard navigation:
|
|
@@ -16,18 +15,21 @@ import { DatePickerProps } from '../../date-picker/interfaces';
|
|
|
16
15
|
* - (keyboard navigation) Safari/Chrome+VO - date announcements are not interruptive and can be missed if navigating fast.
|
|
17
16
|
*/
|
|
18
17
|
export interface GridProps {
|
|
19
|
-
locale: string;
|
|
20
|
-
baseDate: Date;
|
|
21
18
|
isDateEnabled: DatePickerProps.IsDateEnabledFunction;
|
|
22
19
|
focusedDate: Date | null;
|
|
23
20
|
focusableDate: Date | null;
|
|
24
21
|
onSelectDate: (date: Date) => void;
|
|
25
22
|
onFocusDate: (date: null | Date) => void;
|
|
26
|
-
|
|
27
|
-
startOfWeek: DayIndex;
|
|
28
|
-
todayAriaLabel?: string;
|
|
23
|
+
onChangePage: (date: Date) => void;
|
|
29
24
|
selectedDate: Date | null;
|
|
30
25
|
ariaLabelledby: string;
|
|
26
|
+
header?: React.ReactNode;
|
|
27
|
+
rows: ReadonlyArray<ReadonlyArray<Date>>;
|
|
28
|
+
isCurrentPage: (date: Date) => boolean;
|
|
29
|
+
renderDate: (date: Date) => string;
|
|
30
|
+
renderDateAnnouncement: (date: Date, isOnCurrentDate: boolean) => string;
|
|
31
|
+
isSameDate: (date: Date, baseDate: Date) => boolean;
|
|
32
|
+
onGridKeyDownHandler: (event: React.KeyboardEvent) => void;
|
|
31
33
|
}
|
|
32
|
-
export default function Grid({
|
|
34
|
+
export default function Grid({ isDateEnabled, focusedDate, focusableDate, onSelectDate, selectedDate, ariaLabelledby, header, rows, isCurrentPage, renderDate, renderDateAnnouncement, isSameDate, onGridKeyDownHandler, }: GridProps): JSX.Element;
|
|
33
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["calendar/grid/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["calendar/grid/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,IAAI,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACvC,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;IACnC,sBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,KAAK,MAAM,CAAC;IACzE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,OAAO,CAAC;IACpD,oBAAoB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;CAC5D;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,MAAM,EACN,IAAI,EACJ,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,UAAU,EACV,oBAAoB,GACrB,EAAE,SAAS,eA+DX"}
|
package/calendar/grid/index.js
CHANGED
|
@@ -1,55 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
4
|
import styles from '../styles.css.js';
|
|
5
|
-
import { KeyCode } from '../../internal/keycode';
|
|
6
|
-
import { isSameDay, isSameMonth } from 'date-fns';
|
|
7
|
-
import { getCalendarMonth } from 'mnth';
|
|
8
|
-
import { getDateLabel, renderDayName } from '../utils/intl';
|
|
9
5
|
import clsx from 'clsx';
|
|
10
6
|
import { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';
|
|
11
7
|
import ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';
|
|
12
|
-
|
|
13
|
-
export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, focusableDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate, ariaLabelledby, }) {
|
|
8
|
+
export default function Grid({ isDateEnabled, focusedDate, focusableDate, onSelectDate, selectedDate, ariaLabelledby, header, rows, isCurrentPage, renderDate, renderDateAnnouncement, isSameDate, onGridKeyDownHandler, }) {
|
|
14
9
|
const focusedDateRef = useRef(null);
|
|
15
|
-
const onGridKeyDownHandler = (event) => {
|
|
16
|
-
let updatedFocusDate;
|
|
17
|
-
if (focusableDate === null) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
switch (event.keyCode) {
|
|
21
|
-
case KeyCode.space:
|
|
22
|
-
case KeyCode.enter:
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
if (focusableDate) {
|
|
25
|
-
onFocusDate(null);
|
|
26
|
-
onSelectDate(focusableDate);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
case KeyCode.right:
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);
|
|
32
|
-
break;
|
|
33
|
-
case KeyCode.left:
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);
|
|
36
|
-
break;
|
|
37
|
-
case KeyCode.up:
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);
|
|
40
|
-
break;
|
|
41
|
-
case KeyCode.down:
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (!isSameMonth(updatedFocusDate, baseDate)) {
|
|
49
|
-
onChangeMonth(updatedFocusDate);
|
|
50
|
-
}
|
|
51
|
-
onFocusDate(updatedFocusDate);
|
|
52
|
-
};
|
|
53
10
|
// The focused date changes as a feedback to keyboard navigation in the grid.
|
|
54
11
|
// Once changed, the corresponding date button needs to receive the actual focus.
|
|
55
12
|
useEffectOnUpdate(() => {
|
|
@@ -57,18 +14,13 @@ export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, foc
|
|
|
57
14
|
focusedDateRef.current.focus();
|
|
58
15
|
}
|
|
59
16
|
}, [focusedDate]);
|
|
60
|
-
const weeks = useMemo(() => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }), [baseDate, startOfWeek]);
|
|
61
|
-
const weekdays = weeks[0].map(date => date.getDay());
|
|
62
17
|
return (React.createElement("table", { role: "grid", className: styles['calendar-grid'], "aria-labelledby": ariaLabelledby },
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
React.createElement("tbody", { onKeyDown: onGridKeyDownHandler }, weeks.map((week, weekIndex) => (React.createElement("tr", { key: weekIndex, className: styles['calendar-row'] }, week.map((date, dateIndex) => {
|
|
68
|
-
const isFocusable = !!focusableDate && isSameDay(date, focusableDate);
|
|
69
|
-
const isSelected = !!selectedDate && isSameDay(date, selectedDate);
|
|
18
|
+
header,
|
|
19
|
+
React.createElement("tbody", { onKeyDown: onGridKeyDownHandler }, rows.map((row, rowIndex) => (React.createElement("tr", { key: rowIndex, className: styles['calendar-row'] }, row.map((date, dateIndex) => {
|
|
20
|
+
const isFocusable = !!focusableDate && isSameDate(date, focusableDate);
|
|
21
|
+
const isSelected = !!selectedDate && isSameDate(date, selectedDate);
|
|
70
22
|
const isEnabled = !isDateEnabled || isDateEnabled(date);
|
|
71
|
-
const
|
|
23
|
+
const isCurrentDate = isSameDate(date, new Date());
|
|
72
24
|
// Can't be focused.
|
|
73
25
|
let tabIndex = undefined;
|
|
74
26
|
if (isFocusable && isEnabled) {
|
|
@@ -79,21 +31,16 @@ export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, foc
|
|
|
79
31
|
// Can be focused programmatically.
|
|
80
32
|
tabIndex = -1;
|
|
81
33
|
}
|
|
82
|
-
|
|
83
|
-
let dayAnnouncement = getDateLabel(locale, date, 'short');
|
|
84
|
-
if (isDateOnSameDay && todayAriaLabel) {
|
|
85
|
-
dayAnnouncement += '. ' + todayAriaLabel;
|
|
86
|
-
}
|
|
87
|
-
return (React.createElement("td", { key: `${weekIndex}:${dateIndex}`, ref: tabIndex === 0 ? focusedDateRef : undefined, tabIndex: tabIndex, "aria-current": isDateOnSameDay ? 'date' : undefined, "aria-selected": isEnabled ? isSelected : undefined, "aria-disabled": !isEnabled,
|
|
34
|
+
return (React.createElement("td", { key: `${rowIndex}:${dateIndex}`, ref: tabIndex === 0 ? focusedDateRef : undefined, tabIndex: tabIndex, "aria-current": isCurrentDate ? 'date' : undefined, "aria-selected": isEnabled ? isSelected : undefined, "aria-disabled": !isEnabled,
|
|
88
35
|
// Do not attach click event when the date is disabled, otherwise VO+safari announces clickable
|
|
89
36
|
onClick: isEnabled ? () => onSelectDate(date) : undefined, className: clsx(styles['calendar-grid-cell'], styles['calendar-date'], {
|
|
90
|
-
[styles['calendar-date-current-page']]:
|
|
37
|
+
[styles['calendar-date-current-page']]: isCurrentPage(date),
|
|
91
38
|
[styles['calendar-date-enabled']]: isEnabled,
|
|
92
39
|
[styles['calendar-date-selected']]: isSelected,
|
|
93
|
-
[styles['calendar-date-current']]:
|
|
40
|
+
[styles['calendar-date-current']]: isCurrentDate,
|
|
94
41
|
}) },
|
|
95
|
-
React.createElement("span", { className: styles['date-inner'], "aria-hidden": "true" }, date
|
|
96
|
-
React.createElement(ScreenreaderOnly, null,
|
|
42
|
+
React.createElement("span", { className: styles['date-inner'], "aria-hidden": "true" }, renderDate(date)),
|
|
43
|
+
React.createElement(ScreenreaderOnly, null, renderDateAnnouncement(date, isCurrentDate))));
|
|
97
44
|
})))))));
|
|
98
45
|
}
|
|
99
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAA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AAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAChD,QAAQ,EAAE,QAAQ,kBACJ,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,mBACnC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,mBAClC,CAAC,SAAS;gBACzB,+FAA+F;gBAC/F,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EACzD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE;oBACrE,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC;oBACnE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,SAAS;oBAC5C,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,EAAE,UAAU;oBAC9C,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,eAAe;iBACnD,CAAC;gBAEF,8BAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAc,MAAM,IACtD,IAAI,CAAC,OAAO,EAAE,CACV;gBACP,oBAAC,gBAAgB,QAAE,eAAe,CAAoB,CACnD,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { KeyCode } from '../../internal/keycode';\nimport { isSameDay, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../internal';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport { getDateLabel, renderDayName } from '../utils/intl';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';\nimport { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek } from '../utils/navigation';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every date is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - dates are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - date announcements are not interruptive and can be missed if navigating fast.\n */\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel?: string;\n selectedDate: Date | null;\n ariaLabelledby: string;\n}\n\nexport default function Grid({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n ariaLabelledby,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusableDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.space:\n case KeyCode.enter:\n event.preventDefault();\n if (focusableDate) {\n onFocusDate(null);\n onSelectDate(focusableDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding date button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n const weekdays = weeks[0].map(date => date.getDay());\n\n return (\n <table role=\"grid\" className={styles['calendar-grid']} aria-labelledby={ariaLabelledby}>\n <thead>\n <tr>\n {weekdays.map(dayIndex => (\n <th\n key={dayIndex}\n scope=\"col\"\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date-header'])}\n >\n <span aria-hidden=\"true\">{renderDayName(locale, dayIndex, 'short')}</span>\n <ScreenreaderOnly>{renderDayName(locale, dayIndex, 'long')}</ScreenreaderOnly>\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => (\n <tr key={weekIndex} className={styles['calendar-row']}>\n {week.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDay(date, focusableDate);\n const isSelected = !!selectedDate && isSameDay(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isDateOnSameDay = isSameDay(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n // Screen-reader announcement for the focused date.\n let dayAnnouncement = getDateLabel(locale, date, 'short');\n if (isDateOnSameDay && todayAriaLabel) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n tabIndex={tabIndex}\n aria-current={isDateOnSameDay ? 'date' : undefined}\n aria-selected={isEnabled ? isSelected : undefined}\n aria-disabled={!isEnabled}\n // Do not attach click event when the date is disabled, otherwise VO+safari announces clickable\n onClick={isEnabled ? () => onSelectDate(date) : undefined}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date'], {\n [styles['calendar-date-current-page']]: isSameMonth(date, baseDate),\n [styles['calendar-date-enabled']]: isEnabled,\n [styles['calendar-date-selected']]: isSelected,\n [styles['calendar-date-current']]: isDateOnSameDay,\n })}\n >\n <span className={styles['date-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n <ScreenreaderOnly>{dayAnnouncement}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,gBAAgB,MAAM,sDAAsD,CAAC;AAmCpF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,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ier: Apache-2.0\nimport React, { useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every date is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - dates are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - date announcements are not interruptive and can be missed if navigating fast.\n */\n\nexport interface GridProps {\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangePage: (date: Date) => void;\n selectedDate: Date | null;\n ariaLabelledby: string;\n header?: React.ReactNode;\n rows: ReadonlyArray<ReadonlyArray<Date>>;\n isCurrentPage: (date: Date) => boolean;\n renderDate: (date: Date) => string;\n renderDateAnnouncement: (date: Date, isOnCurrentDate: boolean) => string;\n isSameDate: (date: Date, baseDate: Date) => boolean;\n onGridKeyDownHandler: (event: React.KeyboardEvent) => void;\n}\n\nexport default function Grid({\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n selectedDate,\n ariaLabelledby,\n header,\n rows,\n isCurrentPage,\n renderDate,\n renderDateAnnouncement,\n isSameDate,\n onGridKeyDownHandler,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding date button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n return (\n <table role=\"grid\" className={styles['calendar-grid']} aria-labelledby={ariaLabelledby}>\n {header}\n <tbody onKeyDown={onGridKeyDownHandler}>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex} className={styles['calendar-row']}>\n {row.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDate(date, focusableDate);\n const isSelected = !!selectedDate && isSameDate(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isCurrentDate = isSameDate(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n return (\n <td\n key={`${rowIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n tabIndex={tabIndex}\n aria-current={isCurrentDate ? 'date' : undefined}\n aria-selected={isEnabled ? isSelected : undefined}\n aria-disabled={!isEnabled}\n // Do not attach click event when the date is disabled, otherwise VO+safari announces clickable\n onClick={isEnabled ? () => onSelectDate(date) : undefined}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date'], {\n [styles['calendar-date-current-page']]: isCurrentPage(date),\n [styles['calendar-date-enabled']]: isEnabled,\n [styles['calendar-date-selected']]: isSelected,\n [styles['calendar-date-current']]: isCurrentDate,\n })}\n >\n <span className={styles['date-inner']} aria-hidden=\"true\">\n {renderDate(date)}\n </span>\n {/* Screen-reader announcement for the focused date. */}\n <ScreenreaderOnly>{renderDateAnnouncement(date, isCurrentDate)}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CalendarProps } from '../interfaces';
|
|
3
|
+
export default function useCalendarGridKeyboardNavigation({ baseDate, focusableDate, isDateEnabled, onChangePage, onFocusDate, onSelectDate, }: {
|
|
4
|
+
baseDate: Date;
|
|
5
|
+
focusableDate: Date | null;
|
|
6
|
+
isDateEnabled: CalendarProps.IsDateEnabledFunction;
|
|
7
|
+
onChangePage: (date: Date) => void;
|
|
8
|
+
onFocusDate: (date: null | Date) => void;
|
|
9
|
+
onSelectDate: (date: Date) => void;
|
|
10
|
+
}): (event: React.KeyboardEvent) => void;
|
|
11
|
+
//# sourceMappingURL=use-calendar-grid-keyboard-navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-keyboard-navigation.d.ts","sourceRoot":"lib/default/","sources":["calendar/grid/use-calendar-grid-keyboard-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAC,EACxD,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC,qBAAqB,CAAC;IACnD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC,WACsC,mBAAmB,UA2CzD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { isSameMonth } from 'date-fns';
|
|
4
|
+
import { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek } from '../utils/navigation';
|
|
5
|
+
import { KeyCode } from '../../internal/keycode';
|
|
6
|
+
export default function useCalendarGridKeyboardNavigation({ baseDate, focusableDate, isDateEnabled, onChangePage, onFocusDate, onSelectDate, }) {
|
|
7
|
+
const onGridKeyDownHandler = (event) => {
|
|
8
|
+
let updatedFocusDate;
|
|
9
|
+
if (focusableDate === null) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
switch (event.keyCode) {
|
|
13
|
+
case KeyCode.space:
|
|
14
|
+
case KeyCode.enter:
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
if (focusableDate) {
|
|
17
|
+
onFocusDate(null);
|
|
18
|
+
onSelectDate(focusableDate);
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
case KeyCode.right:
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);
|
|
24
|
+
break;
|
|
25
|
+
case KeyCode.left:
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);
|
|
28
|
+
break;
|
|
29
|
+
case KeyCode.up:
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);
|
|
32
|
+
break;
|
|
33
|
+
case KeyCode.down:
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!isSameMonth(updatedFocusDate, baseDate)) {
|
|
41
|
+
onChangePage(updatedFocusDate);
|
|
42
|
+
}
|
|
43
|
+
onFocusDate(updatedFocusDate);
|
|
44
|
+
};
|
|
45
|
+
return onGridKeyDownHandler;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=use-calendar-grid-keyboard-navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-keyboard-navigation.js","sourceRoot":"lib/default/","sources":["calendar/grid/use-calendar-grid-keyboard-navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAC,EACxD,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,GAQb;IACC,MAAM,oBAAoB,GAAG,CAAC,KAA0B,EAAE,EAAE;QAC1D,IAAI,gBAAgB,CAAC;QAErB,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,OAAO;SACR;QAED,QAAQ,KAAK,CAAC,OAAO,EAAE;YACrB,KAAK,OAAO,CAAC,KAAK,CAAC;YACnB,KAAK,OAAO,CAAC,KAAK;gBAChB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,IAAI,aAAa,EAAE;oBACjB,WAAW,CAAC,IAAI,CAAC,CAAC;oBAClB,YAAY,CAAC,aAAa,CAAC,CAAC;iBAC7B;gBACD,OAAO;YACT,KAAK,OAAO,CAAC,KAAK;gBAChB,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,gBAAgB,GAAG,WAAW,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAC7D,MAAM;YACR,KAAK,OAAO,CAAC,IAAI;gBACf,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,gBAAgB,GAAG,WAAW,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAC7D,MAAM;YACR,KAAK,OAAO,CAAC,EAAE;gBACb,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,gBAAgB,GAAG,YAAY,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAC9D,MAAM;YACR,KAAK,OAAO,CAAC,IAAI;gBACf,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,gBAAgB,GAAG,YAAY,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAC9D,MAAM;YACR;gBACE,OAAO;SACV;QAED,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE;YAC5C,YAAY,CAAC,gBAAgB,CAAC,CAAC;SAChC;QACD,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { isSameMonth } from 'date-fns';\nimport { CalendarProps } from '../interfaces';\nimport { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek } from '../utils/navigation';\nimport { KeyCode } from '../../internal/keycode';\n\nexport default function useCalendarGridKeyboardNavigation({\n baseDate,\n focusableDate,\n isDateEnabled,\n onChangePage,\n onFocusDate,\n onSelectDate,\n}: {\n baseDate: Date;\n focusableDate: Date | null;\n isDateEnabled: CalendarProps.IsDateEnabledFunction;\n onChangePage: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onSelectDate: (date: Date) => void;\n}) {\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusableDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.space:\n case KeyCode.enter:\n event.preventDefault();\n if (focusableDate) {\n onFocusDate(null);\n onSelectDate(focusableDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangePage(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n return onGridKeyDownHandler;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-rows.d.ts","sourceRoot":"lib/default/","sources":["calendar/grid/use-calendar-grid-rows.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,MAAM,EACN,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,YASA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { normalizeStartOfWeek } from '../../internal/utils/locale/index.js';
|
|
5
|
+
import { getCalendarMonth } from 'mnth';
|
|
6
|
+
export default function useCalendarGridRows({ baseDate, locale, startOfWeek, }) {
|
|
7
|
+
const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, locale);
|
|
8
|
+
const rows = useMemo(() => getCalendarMonth(baseDate, { firstDayOfWeek: normalizedStartOfWeek }), [baseDate, normalizedStartOfWeek]);
|
|
9
|
+
return rows;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=use-calendar-grid-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-rows.js","sourceRoot":"lib/default/","sources":["calendar/grid/use-calendar-grid-rows.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,QAAQ,EACR,MAAM,EACN,WAAW,GAKZ;IACC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAExE,MAAM,IAAI,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC,EAC3E,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAClC,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useMemo } from 'react';\nimport { normalizeStartOfWeek } from '../../internal/utils/locale/index.js';\nimport { getCalendarMonth } from 'mnth';\n\nexport default function useCalendarGridRows({\n baseDate,\n locale,\n startOfWeek,\n}: {\n baseDate: Date;\n locale: string;\n startOfWeek?: number;\n}) {\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, locale);\n\n const rows = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: normalizedStartOfWeek }),\n [baseDate, normalizedStartOfWeek]\n );\n\n return rows;\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface HeaderButtonProps {
|
|
3
3
|
ariaLabel?: string;
|
|
4
|
-
|
|
5
|
-
onChangeMonth: (date: Date) => void;
|
|
4
|
+
onChange: (n: number) => void;
|
|
6
5
|
}
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
6
|
+
export declare function HeaderPrevButton({ ariaLabel, onChange }: HeaderButtonProps): JSX.Element;
|
|
7
|
+
export declare function HeaderNextButton({ ariaLabel, onChange }: HeaderButtonProps): JSX.Element;
|
|
9
8
|
export {};
|
|
10
9
|
//# sourceMappingURL=header-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-button.d.ts","sourceRoot":"lib/default/","sources":["calendar/header/header-button.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"header-button.d.ts","sourceRoot":"lib/default/","sources":["calendar/header/header-button.tsx"],"names":[],"mappings":";AAOA,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B;AAED,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,iBAAiB,eAW1E;AAED,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,iBAAiB,eAW1E"}
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { InternalButton } from '../../button/internal';
|
|
5
5
|
import styles from '../styles.css.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return (React.createElement(InternalButton, { iconName: "angle-left", ariaLabel: ariaLabel, variant: "icon", onClick: () => onChangeMonth(addMonths(baseDate, -1)), formAction: "none", className: styles['calendar-prev-btn'] }));
|
|
6
|
+
export function HeaderPrevButton({ ariaLabel, onChange }) {
|
|
7
|
+
return (React.createElement(InternalButton, { iconName: "angle-left", ariaLabel: ariaLabel, variant: "icon", onClick: () => onChange(-1), formAction: "none", className: styles['calendar-prev-btn'] }));
|
|
9
8
|
}
|
|
10
|
-
export function
|
|
11
|
-
return (React.createElement(InternalButton, { iconName: "angle-right", ariaLabel: ariaLabel, variant: "icon", onClick: () =>
|
|
9
|
+
export function HeaderNextButton({ ariaLabel, onChange }) {
|
|
10
|
+
return (React.createElement(InternalButton, { iconName: "angle-right", ariaLabel: ariaLabel, variant: "icon", onClick: () => onChange(1), formAction: "none", className: styles['calendar-next-btn'] }));
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=header-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-button.js","sourceRoot":"lib/default/","sources":["calendar/header/header-button.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,MAAM,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"header-button.js","sourceRoot":"lib/default/","sources":["calendar/header/header-button.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAOtC,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAqB;IACzE,OAAO,CACL,oBAAC,cAAc,IACb,QAAQ,EAAC,YAAY,EACrB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAC3B,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,GACtC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAqB;IACzE,OAAO,CACL,oBAAC,cAAc,IACb,QAAQ,EAAC,aAAa,EACtB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAC,MAAM,EACjB,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,GACtC,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { InternalButton } from '../../button/internal';\nimport styles from '../styles.css.js';\n\ninterface HeaderButtonProps {\n ariaLabel?: string;\n onChange: (n: number) => void;\n}\n\nexport function HeaderPrevButton({ ariaLabel, onChange }: HeaderButtonProps) {\n return (\n <InternalButton\n iconName=\"angle-left\"\n ariaLabel={ariaLabel}\n variant=\"icon\"\n onClick={() => onChange(-1)}\n formAction=\"none\"\n className={styles['calendar-prev-btn']}\n />\n );\n}\n\nexport function HeaderNextButton({ ariaLabel, onChange }: HeaderButtonProps) {\n return (\n <InternalButton\n iconName=\"angle-right\"\n ariaLabel={ariaLabel}\n variant=\"icon\"\n onClick={() => onChange(1)}\n formAction=\"none\"\n className={styles['calendar-next-btn']}\n />\n );\n}\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface CalendarHeaderProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
nextMonthLabel?: string;
|
|
3
|
+
formattedDate: string;
|
|
4
|
+
onChange: (n: number) => void;
|
|
5
|
+
previousLabel?: string;
|
|
6
|
+
nextLabel?: string;
|
|
8
7
|
headingId: string;
|
|
9
8
|
}
|
|
10
|
-
declare const CalendarHeader: ({
|
|
9
|
+
declare const CalendarHeader: ({ formattedDate, onChange, previousLabel, nextLabel, headingId }: CalendarHeaderProps) => JSX.Element;
|
|
11
10
|
export default CalendarHeader;
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["calendar/header/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["calendar/header/index.tsx"],"names":[],"mappings":";AAMA,UAAU,mBAAmB;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,cAAc,qEAAsE,mBAAmB,gBAU5G,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/calendar/header/index.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import styles from '../styles.css.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const CalendarHeader = ({ baseDate, locale, onChangeMonth, previousMonthLabel, nextMonthLabel, headingId, }) => {
|
|
5
|
+
import { HeaderPrevButton, HeaderNextButton } from './header-button';
|
|
6
|
+
const CalendarHeader = ({ formattedDate, onChange, previousLabel, nextLabel, headingId }) => {
|
|
8
7
|
return (React.createElement("div", { className: styles['calendar-header'] },
|
|
9
|
-
React.createElement(
|
|
10
|
-
React.createElement("h2", { className: styles['calendar-header-
|
|
11
|
-
React.createElement(
|
|
8
|
+
React.createElement(HeaderPrevButton, { ariaLabel: previousLabel, onChange: onChange }),
|
|
9
|
+
React.createElement("h2", { className: styles['calendar-header-title'], id: headingId }, formattedDate),
|
|
10
|
+
React.createElement(HeaderNextButton, { ariaLabel: nextLabel, onChange: onChange })));
|
|
12
11
|
};
|
|
13
12
|
export default CalendarHeader;
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAUrE,MAAM,cAAc,GAAG,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAuB,EAAE,EAAE;IAC/G,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACvC,oBAAC,gBAAgB,IAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAI;QAClE,4BAAI,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,SAAS,IAC1D,aAAa,CACX;QACL,oBAAC,gBAAgB,IAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC1D,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport styles from '../styles.css.js';\nimport { HeaderPrevButton, HeaderNextButton } from './header-button';\n\ninterface CalendarHeaderProps {\n formattedDate: string;\n onChange: (n: number) => void;\n previousLabel?: string;\n nextLabel?: string;\n headingId: string;\n}\n\nconst CalendarHeader = ({ formattedDate, onChange, previousLabel, nextLabel, headingId }: CalendarHeaderProps) => {\n return (\n <div className={styles['calendar-header']}>\n <HeaderPrevButton ariaLabel={previousLabel} onChange={onChange} />\n <h2 className={styles['calendar-header-title']} id={headingId}>\n {formattedDate}\n </h2>\n <HeaderNextButton ariaLabel={nextLabel} onChange={onChange} />\n </div>\n );\n};\n\nexport default CalendarHeader;\n"]}
|
package/calendar/internal.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CalendarProps } from './interfaces.js';
|
|
3
3
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';
|
|
4
|
-
export
|
|
5
|
-
export default function Calendar({ value, locale, startOfWeek, isDateEnabled, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings, ...rest }: CalendarProps & InternalBaseComponentProps): JSX.Element;
|
|
4
|
+
export default function Calendar({ value, locale, startOfWeek, isDateEnabled, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings, previousMonthAriaLabel, nextMonthAriaLabel, todayAriaLabel, ...rest }: CalendarProps & InternalBaseComponentProps): JSX.Element;
|
|
6
5
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAS3F,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,eAuI5C"}
|