@cloudscape-design/components-themeable 3.0.1373 → 3.0.1374
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/checkbox/styles.scss +34 -9
- package/lib/internal/scss/dialog/styles.scss +101 -0
- package/lib/internal/scss/dialog/test-classes/styles.scss +13 -0
- package/lib/internal/scss/expandable-section/styles.scss +8 -3
- package/lib/internal/scss/icon/mixins.scss +18 -0
- package/lib/internal/scss/icon/styles.scss +9 -0
- package/lib/internal/scss/internal/components/checkbox-icon/styles.scss +12 -9
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/scss/internal/styles/links.scss +15 -10
- package/lib/internal/scss/internal/styles/style-api.scss +3 -2
- package/lib/internal/template/button-dropdown/interfaces.d.ts +5 -0
- package/lib/internal/template/button-dropdown/interfaces.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/interfaces.js.map +1 -1
- package/lib/internal/template/button-dropdown/internal-interfaces.d.ts +1 -1
- package/lib/internal/template/button-dropdown/internal-interfaces.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/internal-interfaces.js.map +1 -1
- package/lib/internal/template/button-dropdown/internal.js +2 -2
- package/lib/internal/template/button-dropdown/internal.js.map +1 -1
- package/lib/internal/template/button-dropdown/items-list.d.ts +1 -1
- package/lib/internal/template/button-dropdown/items-list.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/items-list.js +2 -2
- package/lib/internal/template/button-dropdown/items-list.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/move-highlight.d.ts +3 -2
- package/lib/internal/template/button-dropdown/utils/move-highlight.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/move-highlight.js +13 -21
- package/lib/internal/template/button-dropdown/utils/move-highlight.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts +1 -1
- package/lib/internal/template/button-dropdown/utils/use-button-dropdown.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js +8 -6
- package/lib/internal/template/button-dropdown/utils/use-button-dropdown.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/use-highlighted-menu.d.ts +2 -2
- package/lib/internal/template/button-dropdown/utils/use-highlighted-menu.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/use-highlighted-menu.js +14 -4
- package/lib/internal/template/button-dropdown/utils/use-highlighted-menu.js.map +1 -1
- package/lib/internal/template/button-dropdown/utils/utils.d.ts +1 -0
- package/lib/internal/template/button-dropdown/utils/utils.d.ts.map +1 -1
- package/lib/internal/template/button-dropdown/utils/utils.js +1 -0
- package/lib/internal/template/button-dropdown/utils/utils.js.map +1 -1
- package/lib/internal/template/calendar/interfaces.d.ts +2 -1
- package/lib/internal/template/calendar/interfaces.d.ts.map +1 -1
- package/lib/internal/template/calendar/interfaces.js.map +1 -1
- package/lib/internal/template/calendar/internal.d.ts.map +1 -1
- package/lib/internal/template/calendar/internal.js +3 -1
- package/lib/internal/template/calendar/internal.js.map +1 -1
- package/lib/internal/template/checkbox/internal.d.ts +6 -0
- package/lib/internal/template/checkbox/internal.d.ts.map +1 -1
- package/lib/internal/template/checkbox/internal.js +2 -2
- package/lib/internal/template/checkbox/internal.js.map +1 -1
- package/lib/internal/template/checkbox/styles.css.js +7 -3
- package/lib/internal/template/checkbox/styles.scoped.css +72 -16
- package/lib/internal/template/checkbox/styles.selectors.js +7 -3
- package/lib/internal/template/date-range-picker/index.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/index.js +3 -2
- package/lib/internal/template/date-range-picker/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/interfaces.d.ts +2 -1
- package/lib/internal/template/date-range-picker/interfaces.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/interfaces.js.map +1 -1
- package/lib/internal/template/dialog/index.d.ts +4 -0
- package/lib/internal/template/dialog/index.d.ts.map +1 -0
- package/lib/internal/template/dialog/index.js +21 -0
- package/lib/internal/template/dialog/index.js.map +1 -0
- package/lib/internal/template/dialog/interfaces.d.ts +41 -0
- package/lib/internal/template/dialog/interfaces.d.ts.map +1 -0
- package/lib/internal/template/dialog/interfaces.js +2 -0
- package/lib/internal/template/dialog/interfaces.js.map +1 -0
- package/lib/internal/template/dialog/internal.d.ts +6 -0
- package/lib/internal/template/dialog/internal.d.ts.map +1 -0
- package/lib/internal/template/dialog/internal.js +39 -0
- package/lib/internal/template/dialog/internal.js.map +1 -0
- package/lib/internal/template/dialog/styles.css.js +13 -0
- package/lib/internal/template/dialog/styles.scoped.css +126 -0
- package/lib/internal/template/dialog/styles.selectors.js +14 -0
- package/lib/internal/template/dialog/test-classes/styles.css.js +11 -0
- package/lib/internal/template/dialog/test-classes/styles.scoped.css +12 -0
- package/lib/internal/template/dialog/test-classes/styles.selectors.js +12 -0
- package/lib/internal/template/dialog/use-focus-restore.d.ts +6 -0
- package/lib/internal/template/dialog/use-focus-restore.d.ts.map +1 -0
- package/lib/internal/template/dialog/use-focus-restore.js +34 -0
- package/lib/internal/template/dialog/use-focus-restore.js.map +1 -0
- package/lib/internal/template/expandable-section/expandable-section-header.d.ts.map +1 -1
- package/lib/internal/template/expandable-section/expandable-section-header.js +9 -2
- package/lib/internal/template/expandable-section/expandable-section-header.js.map +1 -1
- package/lib/internal/template/expandable-section/styles.css.js +44 -43
- package/lib/internal/template/expandable-section/styles.scoped.css +92 -88
- package/lib/internal/template/expandable-section/styles.selectors.js +44 -43
- package/lib/internal/template/i18n/messages/all.all.js +1 -1
- package/lib/internal/template/i18n/messages/all.all.json +1 -1
- package/lib/internal/template/i18n/messages/all.de.js +1 -1
- package/lib/internal/template/i18n/messages/all.de.json +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
- package/lib/internal/template/i18n/messages/all.en.js +1 -1
- package/lib/internal/template/i18n/messages/all.en.json +1 -1
- package/lib/internal/template/i18n/messages/all.es.js +1 -1
- package/lib/internal/template/i18n/messages/all.es.json +1 -1
- package/lib/internal/template/i18n/messages/all.fr.js +1 -1
- package/lib/internal/template/i18n/messages/all.fr.json +1 -1
- package/lib/internal/template/i18n/messages/all.id.js +1 -1
- package/lib/internal/template/i18n/messages/all.id.json +1 -1
- package/lib/internal/template/i18n/messages/all.it.js +1 -1
- package/lib/internal/template/i18n/messages/all.it.json +1 -1
- package/lib/internal/template/i18n/messages/all.ja.js +1 -1
- package/lib/internal/template/i18n/messages/all.ja.json +1 -1
- package/lib/internal/template/i18n/messages/all.ko.js +1 -1
- package/lib/internal/template/i18n/messages/all.ko.json +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
- package/lib/internal/template/i18n/messages/all.tr.js +1 -1
- package/lib/internal/template/i18n/messages/all.tr.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
- package/lib/internal/template/i18n/messages-types.d.ts +3 -0
- package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
- package/lib/internal/template/i18n/messages-types.js.map +1 -1
- package/lib/internal/template/icon/internal.d.ts +3 -1
- package/lib/internal/template/icon/internal.d.ts.map +1 -1
- package/lib/internal/template/icon/internal.js +10 -2
- package/lib/internal/template/icon/internal.js.map +1 -1
- package/lib/internal/template/icon/styles.css.js +43 -42
- package/lib/internal/template/icon/styles.scoped.css +126 -98
- package/lib/internal/template/icon/styles.selectors.js +43 -42
- package/lib/internal/template/icon-provider/context.d.ts +2 -0
- package/lib/internal/template/icon-provider/context.d.ts.map +1 -1
- package/lib/internal/template/icon-provider/context.js +2 -0
- package/lib/internal/template/icon-provider/context.js.map +1 -1
- package/lib/internal/template/icon-provider/interfaces.d.ts +39 -1
- package/lib/internal/template/icon-provider/interfaces.d.ts.map +1 -1
- package/lib/internal/template/icon-provider/interfaces.js.map +1 -1
- package/lib/internal/template/icon-provider/internal.d.ts +1 -1
- package/lib/internal/template/icon-provider/internal.d.ts.map +1 -1
- package/lib/internal/template/icon-provider/internal.js +17 -3
- package/lib/internal/template/icon-provider/internal.js.map +1 -1
- package/lib/internal/template/icon-provider/use-component-icons.d.ts +4 -0
- package/lib/internal/template/icon-provider/use-component-icons.d.ts.map +1 -0
- package/lib/internal/template/icon-provider/use-component-icons.js +9 -0
- package/lib/internal/template/icon-provider/use-component-icons.js.map +1 -0
- package/lib/internal/template/index.d.ts +1 -0
- package/lib/internal/template/index.d.ts.map +1 -1
- package/lib/internal/template/index.js +1 -0
- package/lib/internal/template/index.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/base-theme/styles.scoped.css +36 -0
- package/lib/internal/template/internal/components/abstract-switch/index.d.ts +3 -1
- package/lib/internal/template/internal/components/abstract-switch/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/abstract-switch/index.js +5 -3
- package/lib/internal/template/internal/components/abstract-switch/index.js.map +1 -1
- package/lib/internal/template/internal/components/checkbox-icon/styles.css.js +9 -9
- package/lib/internal/template/internal/components/checkbox-icon/styles.scoped.css +18 -18
- package/lib/internal/template/internal/components/checkbox-icon/styles.selectors.js +9 -9
- package/lib/internal/template/internal/components/customizable-icon/index.d.ts +19 -0
- package/lib/internal/template/internal/components/customizable-icon/index.d.ts.map +1 -0
- package/lib/internal/template/internal/components/customizable-icon/index.js +12 -0
- package/lib/internal/template/internal/components/customizable-icon/index.js.map +1 -0
- package/lib/internal/template/internal/components/expand-toggle-button/index.d.ts +4 -1
- package/lib/internal/template/internal/components/expand-toggle-button/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/expand-toggle-button/index.js +6 -3
- package/lib/internal/template/internal/components/expand-toggle-button/index.js.map +1 -1
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/internal/generated/styles/tokens.d.ts +11 -0
- package/lib/internal/template/internal/generated/styles/tokens.js +11 -0
- package/lib/internal/template/internal/generated/theming/index.cjs +157 -1
- package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +582 -5
- package/lib/internal/template/internal/generated/theming/index.d.cts +4308 -0
- package/lib/internal/template/internal/generated/theming/index.d.ts +99 -0
- package/lib/internal/template/internal/generated/theming/index.js +157 -1
- package/lib/internal/template/internal/utils/locale/normalize-locale.js +8 -5
- package/lib/internal/template/internal/utils/locale/normalize-locale.js.map +1 -1
- package/lib/internal/template/package.json +3 -0
- package/lib/internal/template/split-panel/bottom.d.ts +2 -1
- package/lib/internal/template/split-panel/bottom.d.ts.map +1 -1
- package/lib/internal/template/split-panel/bottom.js.map +1 -1
- package/lib/internal/template/split-panel/content-props.d.ts +17 -0
- package/lib/internal/template/split-panel/content-props.d.ts.map +1 -0
- package/lib/internal/template/split-panel/content-props.js +2 -0
- package/lib/internal/template/split-panel/content-props.js.map +1 -0
- package/lib/internal/template/split-panel/interfaces.d.ts +0 -13
- package/lib/internal/template/split-panel/interfaces.d.ts.map +1 -1
- package/lib/internal/template/split-panel/interfaces.js.map +1 -1
- package/lib/internal/template/split-panel/side.d.ts +2 -1
- package/lib/internal/template/split-panel/side.d.ts.map +1 -1
- package/lib/internal/template/split-panel/side.js.map +1 -1
- package/lib/internal/template/table/body-cell/td-element.d.ts.map +1 -1
- package/lib/internal/template/table/body-cell/td-element.js +3 -1
- package/lib/internal/template/table/body-cell/td-element.js.map +1 -1
- package/lib/internal/template/table/header-cell/index.d.ts.map +1 -1
- package/lib/internal/template/table/header-cell/index.js +8 -2
- package/lib/internal/template/table/header-cell/index.js.map +1 -1
- package/lib/internal/template/table/internal.js +1 -1
- package/lib/internal/template/table/internal.js.map +1 -1
- package/lib/internal/template/test-utils/dom/dialog/index.d.ts +25 -0
- package/lib/internal/template/test-utils/dom/dialog/index.js +43 -0
- package/lib/internal/template/test-utils/dom/dialog/index.js.map +1 -0
- package/lib/internal/template/test-utils/dom/index.d.ts +28 -0
- package/lib/internal/template/test-utils/dom/index.js +21 -2
- package/lib/internal/template/test-utils/dom/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/dialog/index.d.ts +25 -0
- package/lib/internal/template/test-utils/selectors/dialog/index.js +43 -0
- package/lib/internal/template/test-utils/selectors/dialog/index.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/index.d.ts +18 -0
- package/lib/internal/template/test-utils/selectors/index.js +16 -2
- package/lib/internal/template/test-utils/selectors/index.js.map +1 -1
- package/lib/internal/template/tree-view/interfaces.d.ts +3 -0
- package/lib/internal/template/tree-view/interfaces.d.ts.map +1 -1
- package/lib/internal/template/tree-view/interfaces.js.map +1 -1
- package/lib/internal/template/tree-view/tree-item/index.d.ts.map +1 -1
- package/lib/internal/template/tree-view/tree-item/index.js +3 -1
- package/lib/internal/template/tree-view/tree-item/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-highlighted-menu.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/use-highlighted-menu.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,eAA8B,MAAM,qBAAqB,CAAC;AACjE,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"use-highlighted-menu.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/use-highlighted-menu.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,eAA8B,MAAM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Ac,CAAC,aAAa,CAAC,CAAC;YAC9B,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,cAAc,CAAC,EAAE,CAAC,CAAC;QACnB,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU;QACV,aAAa;QACb,mBAAmB;QACnB,UAAU;QACV,aAAa;QACb,aAAa;QACb,WAAW;QACX,aAAa;QACb,KAAK;QACL,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { ButtonDropdownProps, HighlightProps } from '../interfaces';\nimport createItemsTree, { TreeIndex } from './create-items-tree';\nimport moveHighlightOneStep from './move-highlight';\nimport { indexEquals, indexIncludes, isItemGroup } from './utils';\n\ninterface UseHighlightedMenuOptions {\n items: ButtonDropdownProps.Items;\n isExpandable: (item: ButtonDropdownProps.ItemOrGroup) => boolean;\n isInRestrictedView?: boolean;\n}\n\ninterface UseHighlightedMenuApi extends HighlightProps {\n moveHighlight: (direction: -1 | 1, loop?: boolean) => void;\n expandGroup: (group?: ButtonDropdownProps.ItemGroup) => void;\n collapseGroup: () => void;\n reset: () => void;\n setIsUsingMouse: (isUsingMouse: boolean) => void;\n}\n\nexport default function useHighlightedMenu({\n items,\n isExpandable,\n isInRestrictedView = false,\n}: UseHighlightedMenuOptions): UseHighlightedMenuApi {\n const [targetIndex, setTargetIndex] = useState<TreeIndex>([]);\n const [expandedIndex, setExpandedIndex] = useState<TreeIndex>([]);\n const [isUsingMouse, setIsUsingMouse] = useState<boolean>(true);\n\n const { getItem, getItemIndex, getSequentialIndex, getParentIndex } = useMemo(() => createItemsTree(items), [items]);\n\n const targetItem = useMemo(() => getItem(targetIndex), [targetIndex, getItem]);\n\n const isHighlighted = useCallback(\n (item: ButtonDropdownProps.ItemOrGroup) => {\n const index = getItemIndex(item);\n return indexIncludes(index, targetIndex);\n },\n [targetIndex, getItemIndex]\n );\n\n // check if keyboard focus is on the element\n const isKeyboardHighlight = useCallback(\n (item: ButtonDropdownProps.ItemOrGroup) => {\n const index = getItemIndex(item);\n return !isUsingMouse && indexEquals(index, targetIndex);\n },\n [targetIndex, getItemIndex, isUsingMouse]\n );\n\n const isExpanded = useCallback(\n (group: ButtonDropdownProps.ItemGroup) => {\n const index = getItemIndex(group);\n\n return indexIncludes(index, expandedIndex);\n },\n [expandedIndex, getItemIndex]\n );\n\n // an index's navigable plane: an expandable group's children form its plane, everything else is top plane\n const planeOf = useCallback(\n (index: TreeIndex): TreeIndex => {\n if (index.length <= 1) {\n return [];\n }\n const parentIndex = index.slice(0, -1);\n const parent = getItem(parentIndex);\n return parent && isItemGroup(parent) && isExpandable(parent) ? parentIndex : [];\n },\n [getItem, isExpandable]\n );\n\n const moveHighlight = useCallback(\n (direction: -1 | 1, loop?: boolean) => {\n const getNext = (index: TreeIndex) => {\n const nextIndex = getSequentialIndex(index, direction, loop);\n const item = getItem(nextIndex || [-1]);\n\n if (!nextIndex || !item) {\n return null;\n }\n\n const parentIndex = getParentIndex(item);\n const parentItem = parentIndex && getItem(parentIndex);\n\n return { index: nextIndex, item, parent: parentItem || undefined };\n };\n\n const nextIndex = moveHighlightOneStep({\n startIndex: targetIndex,\n expandedIndex,\n getNext,\n isExpandable,\n planeOf,\n isInRestrictedView,\n });\n\n if (nextIndex) {\n setTargetIndex(nextIndex);\n }\n },\n [targetIndex, expandedIndex, getItem, getSequentialIndex, getParentIndex, isExpandable, planeOf, isInRestrictedView]\n );\n\n const highlightItem = useCallback(\n (item: ButtonDropdownProps.ItemOrGroup) => {\n setTargetIndex(getItemIndex(item));\n },\n [getItemIndex]\n );\n\n const expandGroup = useCallback(\n (group?: ButtonDropdownProps.ItemGroup) => {\n const groupIndex = group ? getItemIndex(group) : targetIndex;\n const firstChildIndex = [...groupIndex, 0];\n\n // move to the first child item unless in restricted mode\n setTargetIndex(isInRestrictedView ? groupIndex : firstChildIndex);\n setExpandedIndex(groupIndex);\n },\n [targetIndex, getItemIndex, isInRestrictedView]\n );\n\n const collapseGroup = useCallback(() => {\n if (expandedIndex.length > 0) {\n setTargetIndex(expandedIndex);\n setExpandedIndex(expandedIndex.slice(0, -1));\n }\n }, [expandedIndex]);\n\n const reset = useCallback(() => {\n setTargetIndex([]);\n setExpandedIndex([]);\n }, []);\n\n return {\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n moveHighlight,\n highlightItem,\n expandGroup,\n collapseGroup,\n reset,\n setIsUsingMouse,\n };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ButtonDropdownProps, LinkItem } from '../interfaces';
|
|
2
2
|
export declare const isItemGroup: (item: ButtonDropdownProps.ItemOrGroup) => item is ButtonDropdownProps.ItemGroup;
|
|
3
|
+
export declare const isGroupExpandable: (item: ButtonDropdownProps.ItemOrGroup, expandableGroupsDefault: boolean) => boolean;
|
|
3
4
|
export declare const isLinkItem: (item: LinkItem | ButtonDropdownProps.ItemOrGroup) => item is LinkItem;
|
|
4
5
|
export declare const isCheckboxItem: (item: ButtonDropdownProps.ItemOrGroup) => item is ButtonDropdownProps.CheckboxItem;
|
|
5
6
|
export declare const getItemTarget: (item: ButtonDropdownProps.Item) => "_blank" | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9D,eAAO,MAAM,WAAW,GAAI,MAAM,mBAAmB,CAAC,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AAM,mBAAmB,CAAC,IAAI,yBAA2C,CAAC;AAExG,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAQ/D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,WAY1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,WAQhE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,WAQtE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { traverseItems } from './create-items-tree';
|
|
2
2
|
export const isItemGroup = (item) => item && item.items !== undefined;
|
|
3
|
+
export const isGroupExpandable = (item, expandableGroupsDefault) => { var _a; return isItemGroup(item) && ((_a = item.expandable) !== null && _a !== void 0 ? _a : expandableGroupsDefault); };
|
|
3
4
|
export const isLinkItem = (item) => item && item.href !== undefined;
|
|
4
5
|
export const isCheckboxItem = (item) => item && item.itemType === 'checkbox';
|
|
5
6
|
export const getItemTarget = (item) => (item.external ? '_blank' : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/button-dropdown/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAqC,EAAyC,EAAE,CAC1G,IAAI,IAAK,IAAsC,CAAC,KAAK,KAAK,SAAS,CAAC;AAEtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAgD,EAAoB,EAAE,CAC/F,IAAI,IAAK,IAAiB,CAAC,IAAI,KAAK,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAqC,EAA4C,EAAE,CAChH,IAAI,IAAK,IAAyC,CAAC,QAAQ,KAAK,UAAU,CAAC;AAE7E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AC;IAC/B,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;QAC1B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonDropdownProps, LinkItem } from '../interfaces';\nimport { traverseItems } from './create-items-tree';\n\nexport const isItemGroup = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.ItemGroup =>\n item && (item as ButtonDropdownProps.ItemGroup).items !== undefined;\n\nexport const isLinkItem = (item: LinkItem | ButtonDropdownProps.ItemOrGroup): item is LinkItem =>\n item && (item as LinkItem).href !== undefined;\n\nexport const isCheckboxItem = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.CheckboxItem =>\n item && (item as ButtonDropdownProps.CheckboxItem).itemType === 'checkbox';\n\nexport const getItemTarget = (item: ButtonDropdownProps.Item) => (item.external ? '_blank' : undefined);\n\nexport function indexIncludes(source: number[], target: number[]) {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function indexEquals(left: number[], right: number[]) {\n if (left.length !== right.length) {\n return false;\n }\n\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function hasCheckboxItems(items: ButtonDropdownProps.Items) {\n let hasCheckboxItems = false;\n traverseItems(items, item => {\n if (item.itemType === 'checkbox') {\n hasCheckboxItems = true;\n }\n });\n return hasCheckboxItems;\n}\n\nexport function hasDisabledReasonItems(items: ButtonDropdownProps.Items) {\n let hasDisabledReasons = false;\n traverseItems(items, item => {\n if (item.disabledReason) {\n hasDisabledReasons = true;\n }\n });\n return hasDisabledReasons;\n}\n"]}
|
|
1
|
+
{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CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAgC;IAC/D,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;QAC1B,IAAI,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAgC;IACrE,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE;QAC1B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonDropdownProps, LinkItem } from '../interfaces';\nimport { traverseItems } from './create-items-tree';\n\nexport const isItemGroup = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.ItemGroup =>\n item && (item as ButtonDropdownProps.ItemGroup).items !== undefined;\n\nexport const isGroupExpandable = (item: ButtonDropdownProps.ItemOrGroup, expandableGroupsDefault: boolean): boolean =>\n isItemGroup(item) && (item.expandable ?? expandableGroupsDefault);\n\nexport const isLinkItem = (item: LinkItem | ButtonDropdownProps.ItemOrGroup): item is LinkItem =>\n item && (item as LinkItem).href !== undefined;\n\nexport const isCheckboxItem = (item: ButtonDropdownProps.ItemOrGroup): item is ButtonDropdownProps.CheckboxItem =>\n item && (item as ButtonDropdownProps.CheckboxItem).itemType === 'checkbox';\n\nexport const getItemTarget = (item: ButtonDropdownProps.Item) => (item.external ? '_blank' : undefined);\n\nexport function indexIncludes(source: number[], target: number[]) {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function indexEquals(left: number[], right: number[]) {\n if (left.length !== right.length) {\n return false;\n }\n\n for (let index = 0; index < left.length; index++) {\n if (left[index] !== right[index]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function hasCheckboxItems(items: ButtonDropdownProps.Items) {\n let hasCheckboxItems = false;\n traverseItems(items, item => {\n if (item.itemType === 'checkbox') {\n hasCheckboxItems = true;\n }\n });\n return hasCheckboxItems;\n}\n\nexport function hasDisabledReasonItems(items: ButtonDropdownProps.Items) {\n let hasDisabledReasons = false;\n traverseItems(items, item => {\n if (item.disabledReason) {\n hasDisabledReasons = true;\n }\n });\n return hasDisabledReasons;\n}\n"]}
|
|
@@ -22,7 +22,8 @@ export interface CalendarProps extends BaseComponentProps {
|
|
|
22
22
|
dateDisabledReason?: CalendarProps.DateDisabledReasonFunction;
|
|
23
23
|
/**
|
|
24
24
|
* Specifies the locale to use to render month names and determine the starting day of the week.
|
|
25
|
-
* If you don't provide this, the locale is determined by the
|
|
25
|
+
* If you don't provide this, the locale is determined by the locale of the surrounding I18nProvider,
|
|
26
|
+
* or the page and browser locales otherwise.
|
|
26
27
|
* Supported values and formats are listed in the
|
|
27
28
|
* [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
|
28
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/calendar/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC;IAEpD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC;IAE9D
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/calendar/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC;IAEpD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC;IAE9D;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAEjE;;;;OAIG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;IAExC;;;QAGI;IACJ,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,YAAY;QAC3B;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,qBAAqB;QACpC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;KACvB;IAED,UAAiB,0BAA0B;QACzC,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;KACtB;IAED,KAAY,WAAW,GAAG,eAAe,CAAC;IAE1C,UAAiB,WAAW;QAC1B;;WAEG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB;;WAEG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAE5B;;WAEG;QACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAEhC;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAE/B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/calendar/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../types/base-component';\nimport { DateGranularity } from '../types/date-time';\nimport { NonCancelableEventHandler } from '../types/events';\n\nexport interface CalendarProps extends BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\n\n /**\n * Defines whether a particular date is enabled in the calendar or not.\n * If you disable a date in the calendar, users can still enter this date using a keyboard.\n * We recommend that you also validate these constraints on the client-side and server-side\n * as you would for other form elements.\n * @param date\n */\n isDateEnabled?: CalendarProps.IsDateEnabledFunction;\n\n /**\n * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: CalendarProps.DateDisabledReasonFunction;\n\n /**\n * Specifies the locale to use to render month names and determine the starting day of the week.\n * If you don't provide this, the locale is determined by the page and browser locales.\n * Supported values and formats are listed in the\n * [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Determines the starting day of the week. The values 0-6 map to Sunday-Saturday.\n * By default the starting day of the week is defined by the locale, but you can use this property to override it.\n */\n startOfWeek?: number;\n\n /**\n * Adds an `aria-label` to the calendar.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the calendar.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the calendar.\n */\n ariaDescribedby?: string;\n\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n * @deprecated Use `i18nString.todayAriaLabel` instead.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n * @deprecated Use `i18nStrings.nextMonthAriaLabel` instead.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n * @deprecated Use `i18nStrings.previousMonthAriaLabel` instead.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Called whenever a user changes the input value (by typing, pasting, or selecting a value).\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<CalendarProps.ChangeDetail>;\n\n /**\n * An object containing all the necessary localized strings required by\n * the component.\n * @i18n\n */\n i18nStrings?: CalendarProps.I18nStrings;\n\n /**\n * Specifies the granularity at which users will be able to select a date.\n * Defaults to `day`.\n **/\n granularity?: CalendarProps.Granularity;\n}\n\nexport namespace CalendarProps {\n export interface ChangeDetail {\n /**\n * The new value of this component.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface DateDisabledReasonFunction {\n (date: Date): string;\n }\n\n export type Granularity = DateGranularity;\n\n export interface I18nStrings {\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Used as part of the `aria-label` for the current month in the calendar.\n * @i18n\n */\n currentMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next year' button.\n * @i18n\n */\n nextYearAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous year' button.\n * @i18n\n */\n previousYearAriaLabel?: string;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/calendar/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BaseComponentProps } from '../types/base-component';\nimport { DateGranularity } from '../types/date-time';\nimport { NonCancelableEventHandler } from '../types/events';\n\nexport interface CalendarProps extends BaseComponentProps {\n /**\n * The current input value, in YYYY-MM-DD format.\n */\n value: string;\n\n /**\n * Defines whether a particular date is enabled in the calendar or not.\n * If you disable a date in the calendar, users can still enter this date using a keyboard.\n * We recommend that you also validate these constraints on the client-side and server-side\n * as you would for other form elements.\n * @param date\n */\n isDateEnabled?: CalendarProps.IsDateEnabledFunction;\n\n /**\n * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: CalendarProps.DateDisabledReasonFunction;\n\n /**\n * Specifies the locale to use to render month names and determine the starting day of the week.\n * If you don't provide this, the locale is determined by the locale of the surrounding I18nProvider,\n * or the page and browser locales otherwise.\n * Supported values and formats are listed in the\n * [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Determines the starting day of the week. The values 0-6 map to Sunday-Saturday.\n * By default the starting day of the week is defined by the locale, but you can use this property to override it.\n */\n startOfWeek?: number;\n\n /**\n * Adds an `aria-label` to the calendar.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the calendar.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the calendar.\n */\n ariaDescribedby?: string;\n\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n * @deprecated Use `i18nString.todayAriaLabel` instead.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n * @deprecated Use `i18nStrings.nextMonthAriaLabel` instead.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n * @deprecated Use `i18nStrings.previousMonthAriaLabel` instead.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Called whenever a user changes the input value (by typing, pasting, or selecting a value).\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<CalendarProps.ChangeDetail>;\n\n /**\n * An object containing all the necessary localized strings required by\n * the component.\n * @i18n\n */\n i18nStrings?: CalendarProps.I18nStrings;\n\n /**\n * Specifies the granularity at which users will be able to select a date.\n * Defaults to `day`.\n **/\n granularity?: CalendarProps.Granularity;\n}\n\nexport namespace CalendarProps {\n export interface ChangeDetail {\n /**\n * The new value of this component.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface DateDisabledReasonFunction {\n (date: Date): string;\n }\n\n export type Granularity = DateGranularity;\n\n export interface I18nStrings {\n /**\n * Used as part of the `aria-label` for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Used as part of the `aria-label` for the current month in the calendar.\n * @i18n\n */\n currentMonthAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'next year' button.\n * @i18n\n */\n nextYearAriaLabel?: string;\n\n /**\n * Specifies an `aria-label` for the 'previous year' button.\n * @i18n\n */\n previousYearAriaLabel?: string;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAS3F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,KAAK,qBAAqB,GAAG,aAAa,GAAG,0BAA0B,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,kBAA6B,EAC7B,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,WAAmB,EACnB,UAAU,EACV,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,GAAG,IAAI,EACR,EAAE,qBAAqB,eAwJvB"}
|
|
@@ -4,6 +4,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { addMonths, addYears, isSameDay, isSameMonth, isSameYear } from 'date-fns';
|
|
6
6
|
import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
7
|
+
import { useLocale } from '../i18n/context.js';
|
|
7
8
|
import { getBaseProps } from '../internal/base-component';
|
|
8
9
|
import { fireNonCancelableEvent } from '../internal/events/index.js';
|
|
9
10
|
import checkControlled from '../internal/hooks/check-controlled/index.js';
|
|
@@ -22,7 +23,8 @@ import styles from './styles.css.js';
|
|
|
22
23
|
export default function Calendar({ value, locale = '', startOfWeek, isDateEnabled = () => true, dateDisabledReason = () => '', ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings, granularity = 'day', referrerId, previousMonthAriaLabel, nextMonthAriaLabel, todayAriaLabel, ...rest }) {
|
|
23
24
|
checkControlled('Calendar', 'value', value, 'onChange', onChange);
|
|
24
25
|
const baseProps = getBaseProps(rest);
|
|
25
|
-
const
|
|
26
|
+
const contextLocale = useLocale();
|
|
27
|
+
const normalizedLocale = normalizeLocale('Calendar', locale || contextLocale);
|
|
26
28
|
const gridWrapperRef = useRef(null);
|
|
27
29
|
const [focusedDate, setFocusedDate] = useState(null);
|
|
28
30
|
const valueDateCache = useDateCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC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EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAC1C,UAAU,EAAE,UAAU,GACtB,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { addMonths, addYears, isSameDay, isSameMonth, isSameYear } from 'date-fns';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport Grid from './grid';\nimport CalendarGridHeader from './grid/calendar-grid-header';\nimport useCalendarGridKeyboardNavigation from './grid/use-calendar-grid-keyboard-navigation';\nimport useCalendarGridRows from './grid/use-calendar-grid-rows';\nimport CalendarHeader from './header';\nimport { CalendarProps } from './interfaces.js';\nimport useCalendarLabels from './use-calendar-labels';\nimport { getBaseDay } from './utils/navigation-day';\nimport { getBaseMonth } from './utils/navigation-month';\n\nimport styles from './styles.css.js';\n\ntype InternalCalendarProps = CalendarProps & InternalBaseComponentProps & { referrerId?: string };\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n dateDisabledReason = () => '',\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n i18nStrings,\n granularity = 'day',\n referrerId,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n ...rest\n}: InternalCalendarProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue && !isNaN(parsedValue.getDate()) ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const isMonthPicker = granularity === 'month';\n\n const isDateFocusable = (date: Date) => isDateEnabled(date) || (!isDateEnabled(date) && !!dateDisabledReason(date));\n\n const baseDate = isMonthPicker\n ? getBaseMonth(displayedDate, isDateEnabled)\n : getBaseDay(displayedDate, isDateEnabled);\n\n const isSameDate = isMonthPicker ? isSameMonth : isSameDay;\n const isSamePage = isMonthPicker ? isSameYear : isSameMonth;\n const isCurrentPage = (date: Date) => isMonthPicker || isSameMonth(date, baseDate);\n\n const { previousButtonLabel, nextButtonLabel, renderDate, renderDateAnnouncement, renderHeaderText } =\n useCalendarLabels({\n granularity,\n i18nStrings,\n locale: normalizedLocale,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n });\n\n const gridRows = useCalendarGridRows({ baseDate, granularity, startOfWeek, locale: normalizedLocale });\n\n // Update displayed date if value changes.\n useEffect(() => {\n if (memoizedValue) {\n setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateFocusable(selected) && isSamePage(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateFocusable(today) && isSamePage(today, baseDate)) {\n return today;\n }\n if (isDateFocusable(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangePageHandler = (amount: number) => {\n const movePage = isMonthPicker ? addYears : addMonths;\n const newDate = movePage(baseDate, amount);\n onChangePageHandler(newDate);\n };\n\n const onChangePageHandler = (newDate: Date) => {\n setDisplayedDate(newDate);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date, granularity) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n const onGridKeyDownHandler = useCalendarGridKeyboardNavigation({\n baseDate,\n focusableDate,\n granularity,\n isDateEnabled,\n isDateFocusable,\n onChangePage: onChangePageHandler,\n onFocusDate: onGridFocusDateHandler,\n onSelectDate: onGridSelectDateHandler,\n });\n\n const headerText = renderHeaderText(baseDate);\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n formattedDate={headerText}\n onChange={onHeaderChangePageHandler}\n previousLabel={previousButtonLabel}\n nextLabel={nextButtonLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangePage={onChangePageHandler}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n header={isMonthPicker ? null : <CalendarGridHeader locale={normalizedLocale} rows={gridRows} />}\n rows={gridRows}\n isCurrentPage={isCurrentPage}\n renderDate={renderDate}\n renderDateAnnouncement={renderDateAnnouncement}\n isSameDate={isSameDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n referrerId={referrerId}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAAO,iCAAiC,MAAM,8CAA8C,CAAC;AAC7F,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,cAAc,MAAM,UAAU,CAAC;AAEtC,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAA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,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;QAElE,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACtC,oBAAC,cAAc,IACb,aAAa,EAAE,UAAU,EACzB,QAAQ,EAAE,yBAAyB,EACnC,aAAa,EAAE,mBAAmB,EAClC,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,SAAS,GACpB;YACF,6BAAK,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc;gBAC1C,oBAAC,IAAI,IACH,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,uBAAuB,EACrC,WAAW,EAAE,sBAAsB,EACnC,YAAY,EAAE,mBAAmB,EACjC,YAAY,EAAE,aAAa,EAC3B,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAC,kBAAkB,IAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,GAAI,EAC/F,IAAI,EAAE,QAAQ,EACd,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,oBAAoB,EAC1C,UAAU,EAAE,UAAU,GACtB,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { addMonths, addYears, isSameDay, isSameMonth, isSameYear } from 'date-fns';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useLocale } from '../i18n/context.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport Grid from './grid';\nimport CalendarGridHeader from './grid/calendar-grid-header';\nimport useCalendarGridKeyboardNavigation from './grid/use-calendar-grid-keyboard-navigation';\nimport useCalendarGridRows from './grid/use-calendar-grid-rows';\nimport CalendarHeader from './header';\nimport { CalendarProps } from './interfaces.js';\nimport useCalendarLabels from './use-calendar-labels';\nimport { getBaseDay } from './utils/navigation-day';\nimport { getBaseMonth } from './utils/navigation-month';\n\nimport styles from './styles.css.js';\n\ntype InternalCalendarProps = CalendarProps & InternalBaseComponentProps & { referrerId?: string };\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n dateDisabledReason = () => '',\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n i18nStrings,\n granularity = 'day',\n referrerId,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n ...rest\n}: InternalCalendarProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const contextLocale = useLocale();\n const normalizedLocale = normalizeLocale('Calendar', locale || contextLocale);\n\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue && !isNaN(parsedValue.getDate()) ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const isMonthPicker = granularity === 'month';\n\n const isDateFocusable = (date: Date) => isDateEnabled(date) || (!isDateEnabled(date) && !!dateDisabledReason(date));\n\n const baseDate = isMonthPicker\n ? getBaseMonth(displayedDate, isDateEnabled)\n : getBaseDay(displayedDate, isDateEnabled);\n\n const isSameDate = isMonthPicker ? isSameMonth : isSameDay;\n const isSamePage = isMonthPicker ? isSameYear : isSameMonth;\n const isCurrentPage = (date: Date) => isMonthPicker || isSameMonth(date, baseDate);\n\n const { previousButtonLabel, nextButtonLabel, renderDate, renderDateAnnouncement, renderHeaderText } =\n useCalendarLabels({\n granularity,\n i18nStrings,\n locale: normalizedLocale,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n });\n\n const gridRows = useCalendarGridRows({ baseDate, granularity, startOfWeek, locale: normalizedLocale });\n\n // Update displayed date if value changes.\n useEffect(() => {\n if (memoizedValue) {\n setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateFocusable(selected) && isSamePage(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateFocusable(today) && isSamePage(today, baseDate)) {\n return today;\n }\n if (isDateFocusable(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangePageHandler = (amount: number) => {\n const movePage = isMonthPicker ? addYears : addMonths;\n const newDate = movePage(baseDate, amount);\n onChangePageHandler(newDate);\n };\n\n const onChangePageHandler = (newDate: Date) => {\n setDisplayedDate(newDate);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date, granularity) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n const onGridKeyDownHandler = useCalendarGridKeyboardNavigation({\n baseDate,\n focusableDate,\n granularity,\n isDateEnabled,\n isDateFocusable,\n onChangePage: onChangePageHandler,\n onFocusDate: onGridFocusDateHandler,\n onSelectDate: onGridSelectDateHandler,\n });\n\n const headerText = renderHeaderText(baseDate);\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n formattedDate={headerText}\n onChange={onHeaderChangePageHandler}\n previousLabel={previousButtonLabel}\n nextLabel={nextButtonLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangePage={onChangePageHandler}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n header={isMonthPicker ? null : <CalendarGridHeader locale={normalizedLocale} rows={gridRows} />}\n rows={gridRows}\n isCurrentPage={isCurrentPage}\n renderDate={renderDate}\n renderDateAnnouncement={renderDateAnnouncement}\n isSameDate={isSameDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n referrerId={referrerId}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -4,8 +4,14 @@ import { CheckboxProps } from './interfaces';
|
|
|
4
4
|
interface InternalProps extends CheckboxProps, InternalBaseComponentProps {
|
|
5
5
|
tabIndex?: -1;
|
|
6
6
|
showOutline?: boolean;
|
|
7
|
+
styleClassNames?: StyleClassNames;
|
|
7
8
|
__injectAnalyticsComponentMetadata?: boolean;
|
|
8
9
|
}
|
|
10
|
+
interface StyleClassNames {
|
|
11
|
+
control?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
9
15
|
declare const InternalCheckbox: React.ForwardRefExoticComponent<InternalProps & React.RefAttributes<CheckboxProps.Ref>>;
|
|
10
16
|
export default InternalCheckbox;
|
|
11
17
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/checkbox/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAejD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,UAAU,aAAc,SAAQ,aAAa,EAAE,0BAA0B;IACvE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,QAAA,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/checkbox/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAejD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,UAAU,aAAc,SAAQ,aAAa,EAAE,0BAA0B;IACvE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAGD,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,gBAAgB,yFAwHrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -13,7 +13,7 @@ import useForwardFocus from '../internal/hooks/forward-focus';
|
|
|
13
13
|
import WithNativeAttributes from '../internal/utils/with-native-attributes';
|
|
14
14
|
import { getAbstractSwitchStyles, getCheckboxIconStyles } from './style';
|
|
15
15
|
import styles from './styles.css.js';
|
|
16
|
-
const InternalCheckbox = React.forwardRef(({ controlId, name, checked, disabled, readOnly, ariaRequired, indeterminate, children, description, ariaLabel, onFocus, onBlur, onChange, tabIndex: explicitTabIndex, showOutline, ariaControls, style, nativeInputAttributes, __internalRootRef, __injectAnalyticsComponentMetadata = false, ...rest }, ref) => {
|
|
16
|
+
const InternalCheckbox = React.forwardRef(({ controlId, name, checked, disabled, readOnly, ariaRequired, indeterminate, children, description, ariaLabel, onFocus, onBlur, onChange, tabIndex: explicitTabIndex, showOutline, ariaControls, style, styleClassNames, nativeInputAttributes, __internalRootRef, __injectAnalyticsComponentMetadata = false, ...rest }, ref) => {
|
|
17
17
|
const { ariaDescribedby, ariaLabelledby } = useFormFieldContext(rest);
|
|
18
18
|
const baseProps = getBaseProps(rest);
|
|
19
19
|
const checkboxRef = useRef(null);
|
|
@@ -38,7 +38,7 @@ const InternalCheckbox = React.forwardRef(({ controlId, name, checked, disabled,
|
|
|
38
38
|
if (!disabled && !readOnly) {
|
|
39
39
|
analyticsMetadata.action = !checked ? 'select' : 'deselect';
|
|
40
40
|
}
|
|
41
|
-
return (React.createElement(AbstractSwitch, { ...baseProps, className: clsx(styles.root, baseProps.className), controlClassName: styles['checkbox-control'], outlineClassName: styles.outline, controlId: controlId, disabled: disabled, readOnly: readOnly, label: children, description: description, descriptionBottomPadding: true, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaControls: ariaControls, showOutline: showOutline, nativeControl: nativeControlProps => (React.createElement(WithNativeAttributes, { ...nativeControlProps, tag: "input", componentName: "Checkbox", nativeAttributes: nativeInputAttributes, ref: checkboxRef, type: "checkbox", checked: checked, name: name, "aria-required": ariaRequired ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, tabIndex: tabIndex, onFocus: () => fireNonCancelableEvent(onFocus), onBlur: () => fireNonCancelableEvent(onBlur),
|
|
41
|
+
return (React.createElement(AbstractSwitch, { ...baseProps, className: clsx(styles.root, baseProps.className), controlClassName: clsx(styleClassNames === null || styleClassNames === void 0 ? void 0 : styleClassNames.control, styles['checkbox-control']), outlineClassName: styles.outline, controlId: controlId, disabled: disabled, readOnly: readOnly, label: children, labelClassName: clsx(styleClassNames === null || styleClassNames === void 0 ? void 0 : styleClassNames.label, styles.label, disabled && styles['label-disabled']), description: description, descriptionClassName: clsx(styleClassNames === null || styleClassNames === void 0 ? void 0 : styleClassNames.description, styles.description, disabled && styles['description-disabled']), descriptionBottomPadding: true, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaControls: ariaControls, showOutline: showOutline, nativeControl: nativeControlProps => (React.createElement(WithNativeAttributes, { ...nativeControlProps, tag: "input", componentName: "Checkbox", nativeAttributes: nativeInputAttributes, ref: checkboxRef, type: "checkbox", checked: checked, name: name, "aria-required": ariaRequired ? 'true' : undefined, "aria-disabled": readOnly && !disabled ? 'true' : undefined, tabIndex: tabIndex, onFocus: () => fireNonCancelableEvent(onFocus), onBlur: () => fireNonCancelableEvent(onBlur),
|
|
42
42
|
// empty handler to suppress React controllability warning
|
|
43
43
|
onChange: () => { } })), onClick: () => {
|
|
44
44
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/checkbox/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAA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AEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal';\nimport {\n GeneratedAnalyticsMetadataFragment,\n getAnalyticsMetadataAttribute,\n} from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { getBaseProps } from '../internal/base-component';\nimport AbstractSwitch from '../internal/components/abstract-switch';\nimport CheckboxIcon from '../internal/components/checkbox-icon';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport WithNativeAttributes from '../internal/utils/with-native-attributes';\nimport { GeneratedAnalyticsMetadataCheckboxComponent } from './analytics-metadata/interfaces';\nimport { CheckboxProps } from './interfaces';\nimport { getAbstractSwitchStyles, getCheckboxIconStyles } from './style';\n\nimport styles from './styles.css.js';\n\ninterface InternalProps extends CheckboxProps, InternalBaseComponentProps {\n tabIndex?: -1;\n showOutline?: boolean;\n styleClassNames?: StyleClassNames;\n __injectAnalyticsComponentMetadata?: boolean;\n}\n\n// Style API v2\ninterface StyleClassNames {\n control?: string;\n label?: string;\n description?: string;\n}\n\nconst InternalCheckbox = React.forwardRef<CheckboxProps.Ref, InternalProps>(\n (\n {\n controlId,\n name,\n checked,\n disabled,\n readOnly,\n ariaRequired,\n indeterminate,\n children,\n description,\n ariaLabel,\n onFocus,\n onBlur,\n onChange,\n tabIndex: explicitTabIndex,\n showOutline,\n ariaControls,\n style,\n styleClassNames,\n nativeInputAttributes,\n __internalRootRef,\n __injectAnalyticsComponentMetadata = false,\n ...rest\n },\n ref\n ) => {\n const { ariaDescribedby, ariaLabelledby } = useFormFieldContext(rest);\n const baseProps = getBaseProps(rest);\n const checkboxRef = useRef<HTMLInputElement>(null);\n useForwardFocus(ref, checkboxRef);\n useEffect(() => {\n if (checkboxRef.current) {\n checkboxRef.current.indeterminate = Boolean(indeterminate);\n }\n });\n\n const { tabIndex } = useSingleTabStopNavigation(checkboxRef, { tabIndex: explicitTabIndex });\n\n const analyticsMetadata: GeneratedAnalyticsMetadataFragment = {};\n const analyticsComponentMetadata: GeneratedAnalyticsMetadataCheckboxComponent = {\n name: 'awsui.Checkbox',\n label: { root: 'self' },\n properties: {\n checked: `${!!checked}`,\n },\n };\n if (__injectAnalyticsComponentMetadata) {\n analyticsMetadata.component = analyticsComponentMetadata;\n }\n if (!disabled && !readOnly) {\n analyticsMetadata.action = !checked ? 'select' : 'deselect';\n }\n\n return (\n <AbstractSwitch\n {...baseProps}\n className={clsx(styles.root, baseProps.className)}\n controlClassName={clsx(styleClassNames?.control, styles['checkbox-control'])}\n outlineClassName={styles.outline}\n controlId={controlId}\n disabled={disabled}\n readOnly={readOnly}\n label={children}\n labelClassName={clsx(styleClassNames?.label, styles.label, disabled && styles['label-disabled'])}\n description={description}\n descriptionClassName={clsx(\n styleClassNames?.description,\n styles.description,\n disabled && styles['description-disabled']\n )}\n descriptionBottomPadding={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaControls={ariaControls}\n showOutline={showOutline}\n nativeControl={nativeControlProps => (\n <WithNativeAttributes<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>\n {...nativeControlProps}\n tag=\"input\"\n componentName=\"Checkbox\"\n nativeAttributes={nativeInputAttributes}\n ref={checkboxRef}\n type=\"checkbox\"\n checked={checked}\n name={name}\n aria-required={ariaRequired ? 'true' : undefined}\n aria-disabled={readOnly && !disabled ? 'true' : undefined}\n tabIndex={tabIndex}\n onFocus={() => fireNonCancelableEvent(onFocus)}\n onBlur={() => fireNonCancelableEvent(onBlur)}\n // empty handler to suppress React controllability warning\n onChange={() => {}}\n />\n )}\n onClick={() => {\n checkboxRef.current?.focus();\n fireNonCancelableEvent(\n onChange,\n // for deterministic transitions \"indeterminate\" -> \"checked\" -> \"unchecked\"\n indeterminate ? { checked: true, indeterminate: false } : { checked: !checked, indeterminate: false }\n );\n }}\n styledControl={\n <CheckboxIcon\n checked={checked}\n indeterminate={indeterminate}\n disabled={disabled}\n readOnly={readOnly}\n style={getCheckboxIconStyles(style, checked, disabled, readOnly, indeterminate)}\n />\n }\n style={getAbstractSwitchStyles(style, checked, disabled, readOnly, indeterminate)}\n __internalRootRef={__internalRootRef}\n {...getAnalyticsMetadataAttribute(analyticsMetadata)}\n />\n );\n }\n);\n\nexport default InternalCheckbox;\n"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"root": "
|
|
5
|
-
"checkbox-control": "awsui_checkbox-
|
|
6
|
-
"outline": "
|
|
4
|
+
"root": "awsui_root_k2y2q_1la84_44",
|
|
5
|
+
"checkbox-control": "awsui_checkbox-control_k2y2q_1la84_77",
|
|
6
|
+
"outline": "awsui_outline_k2y2q_1la84_93",
|
|
7
|
+
"label": "awsui_label_k2y2q_1la84_115",
|
|
8
|
+
"label-disabled": "awsui_label-disabled_k2y2q_1la84_118",
|
|
9
|
+
"description": "awsui_description_k2y2q_1la84_122",
|
|
10
|
+
"description-disabled": "awsui_description-disabled_k2y2q_1la84_125"
|
|
7
11
|
};
|
|
8
12
|
|
|
@@ -6,7 +6,42 @@
|
|
|
6
6
|
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
7
7
|
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
8
8
|
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
9
|
-
|
|
9
|
+
@property --awsui-style-color {
|
|
10
|
+
syntax: "*";
|
|
11
|
+
inherits: false;
|
|
12
|
+
}
|
|
13
|
+
@property --awsui-style-background-color {
|
|
14
|
+
syntax: "*";
|
|
15
|
+
inherits: false;
|
|
16
|
+
}
|
|
17
|
+
@property --awsui-style-border-color {
|
|
18
|
+
syntax: "*";
|
|
19
|
+
inherits: false;
|
|
20
|
+
}
|
|
21
|
+
@property --awsui-style-focus-ring-color {
|
|
22
|
+
syntax: "*";
|
|
23
|
+
inherits: false;
|
|
24
|
+
}
|
|
25
|
+
@property --awsui-style-focus-ring-width {
|
|
26
|
+
syntax: "*";
|
|
27
|
+
inherits: false;
|
|
28
|
+
}
|
|
29
|
+
@property --awsui-style-focus-ring-radius {
|
|
30
|
+
syntax: "*";
|
|
31
|
+
inherits: false;
|
|
32
|
+
}
|
|
33
|
+
@property --awsui-style-focus-ring-gutter-block {
|
|
34
|
+
syntax: "*";
|
|
35
|
+
inherits: false;
|
|
36
|
+
}
|
|
37
|
+
@property --awsui-style-focus-ring-gutter-inline {
|
|
38
|
+
syntax: "*";
|
|
39
|
+
inherits: false;
|
|
40
|
+
}
|
|
41
|
+
/* awsui:style-api-slot name=control tokens=color, background-color, border-color, focus-ring-color, focus-ring-width, focus-ring-radius, focus-ring-gutter-block, focus-ring-gutter-inline */
|
|
42
|
+
/* awsui:style-api-slot name=label tokens=color */
|
|
43
|
+
/* awsui:style-api-slot name=description tokens=color */
|
|
44
|
+
.awsui_root_k2y2q_1la84_44.awsui_root_k2y2q_1la84_44:not(#\9) {
|
|
10
45
|
border-collapse: separate;
|
|
11
46
|
border-spacing: 0;
|
|
12
47
|
box-sizing: border-box;
|
|
@@ -39,7 +74,15 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
39
74
|
display: flex;
|
|
40
75
|
}
|
|
41
76
|
|
|
42
|
-
.awsui_checkbox-
|
|
77
|
+
.awsui_checkbox-control_k2y2q_1la84_77:not(#\9) {
|
|
78
|
+
--awsui-internal-style-color: var(--awsui-style-color);
|
|
79
|
+
--awsui-internal-style-background-color: var(--awsui-style-background-color);
|
|
80
|
+
--awsui-internal-style-border-color: var(--awsui-style-border-color);
|
|
81
|
+
--awsui-internal-style-focus-ring-color: var(--awsui-style-focus-ring-color);
|
|
82
|
+
--awsui-internal-style-focus-ring-width: var(--awsui-style-focus-ring-width);
|
|
83
|
+
--awsui-internal-style-focus-ring-radius: var(--awsui-style-focus-ring-radius);
|
|
84
|
+
--awsui-internal-style-focus-ring-gutter-block: var(--awsui-style-focus-ring-gutter-block);
|
|
85
|
+
--awsui-internal-style-focus-ring-gutter-inline: var(--awsui-style-focus-ring-gutter-inline);
|
|
43
86
|
margin-block-start: calc((var(--line-height-body-m-5xw6xo, 22px) - var(--size-control-jpgj8e, 14px)) / 2);
|
|
44
87
|
min-block-size: var(--size-control-jpgj8e, 14px);
|
|
45
88
|
min-inline-size: var(--size-control-jpgj8e, 14px);
|
|
@@ -47,25 +90,38 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
47
90
|
inline-size: var(--size-control-jpgj8e, 14px);
|
|
48
91
|
}
|
|
49
92
|
|
|
50
|
-
.
|
|
51
|
-
--awsui-style-focus-ring-box-shadow-66120l: 0 0 0 var(--awsui-style-focus-ring-border-width-66120l, 2px) var(--awsui-style-focus-ring-border-color-66120l, var(--color-border-item-focused-sewkzn, #0073bb));
|
|
93
|
+
.awsui_outline_k2y2q_1la84_93:not(#\9) {
|
|
52
94
|
position: relative;
|
|
53
95
|
}
|
|
54
|
-
.
|
|
96
|
+
.awsui_outline_k2y2q_1la84_93:not(#\9) {
|
|
55
97
|
outline: 2px dotted transparent;
|
|
56
|
-
outline-offset: calc(2px - 1px);
|
|
98
|
+
outline-offset: calc(var(--awsui-internal-style-focus-ring-gutter-inline, 2px) - 1px);
|
|
57
99
|
}
|
|
58
|
-
.
|
|
100
|
+
.awsui_outline_k2y2q_1la84_93:not(#\9)::before {
|
|
59
101
|
content: " ";
|
|
60
102
|
display: block;
|
|
61
103
|
position: absolute;
|
|
62
|
-
inset-inline-start: calc(-1 * 2px);
|
|
63
|
-
inset-block-start: calc(-1 * 2px);
|
|
64
|
-
inline-size: calc(100% + 2px + 2px);
|
|
65
|
-
block-size: calc(100% + 2px + 2px);
|
|
66
|
-
border-start-start-radius: var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px));
|
|
67
|
-
border-start-end-radius: var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px));
|
|
68
|
-
border-end-start-radius: var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px));
|
|
69
|
-
border-end-end-radius: var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px));
|
|
70
|
-
box-shadow: var(--awsui-style-focus-ring-
|
|
104
|
+
inset-inline-start: calc(-1 * var(--awsui-internal-style-focus-ring-gutter-inline, 2px));
|
|
105
|
+
inset-block-start: calc(-1 * var(--awsui-internal-style-focus-ring-gutter-block, 2px));
|
|
106
|
+
inline-size: calc(100% + var(--awsui-internal-style-focus-ring-gutter-inline, 2px) + var(--awsui-internal-style-focus-ring-gutter-inline, 2px));
|
|
107
|
+
block-size: calc(100% + var(--awsui-internal-style-focus-ring-gutter-block, 2px) + var(--awsui-internal-style-focus-ring-gutter-block, 2px));
|
|
108
|
+
border-start-start-radius: var(--awsui-internal-style-focus-ring-radius, var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px)));
|
|
109
|
+
border-start-end-radius: var(--awsui-internal-style-focus-ring-radius, var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px)));
|
|
110
|
+
border-end-start-radius: var(--awsui-internal-style-focus-ring-radius, var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px)));
|
|
111
|
+
border-end-end-radius: var(--awsui-internal-style-focus-ring-radius, var(--awsui-style-focus-ring-border-radius-66120l, var(--border-radius-control-default-focus-ring-akwhsf, 2px)));
|
|
112
|
+
box-shadow: 0 0 0 var(--awsui-internal-style-focus-ring-width, var(--awsui-style-focus-ring-border-width-66120l, 2px)) var(--awsui-internal-style-focus-ring-color, var(--awsui-style-focus-ring-border-color-66120l, var(--color-border-item-focused-sewkzn, #0073bb)));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.awsui_label_k2y2q_1la84_115.awsui_label_k2y2q_1la84_115:not(#\9) {
|
|
116
|
+
color: var(--awsui-style-color, var(--color-text-form-default-8bb22s, #16191f));
|
|
117
|
+
}
|
|
118
|
+
.awsui_label_k2y2q_1la84_115.awsui_label_k2y2q_1la84_115.awsui_label-disabled_k2y2q_1la84_118:not(#\9) {
|
|
119
|
+
color: var(--awsui-style-color, var(--color-text-control-disabled-54tz75, #aab7b8));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.awsui_description_k2y2q_1la84_122.awsui_description_k2y2q_1la84_122:not(#\9) {
|
|
123
|
+
color: var(--awsui-style-color, var(--color-text-form-secondary-wt0md2, #687078));
|
|
124
|
+
}
|
|
125
|
+
.awsui_description_k2y2q_1la84_122.awsui_description_k2y2q_1la84_122.awsui_description-disabled_k2y2q_1la84_125:not(#\9) {
|
|
126
|
+
color: var(--awsui-style-color, var(--color-text-control-disabled-54tz75, #aab7b8));
|
|
71
127
|
}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"checkbox-control": "awsui_checkbox-
|
|
7
|
-
"outline": "
|
|
5
|
+
"root": "awsui_root_k2y2q_1la84_44",
|
|
6
|
+
"checkbox-control": "awsui_checkbox-control_k2y2q_1la84_77",
|
|
7
|
+
"outline": "awsui_outline_k2y2q_1la84_93",
|
|
8
|
+
"label": "awsui_label_k2y2q_1la84_115",
|
|
9
|
+
"label-disabled": "awsui_label-disabled_k2y2q_1la84_118",
|
|
10
|
+
"description": "awsui_description_k2y2q_1la84_122",
|
|
11
|
+
"description-disabled": "awsui_description-disabled_k2y2q_1la84_125"
|
|
8
12
|
};
|
|
9
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AA0BhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAmDhC,QAAA,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA2C,MAAM,OAAO,CAAC;AA0BhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAmDhC,QAAA,MAAM,eAAe,uGA6SpB,CAAC;AAGF,eAAe,eAAe,CAAC"}
|
|
@@ -5,7 +5,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
7
7
|
import Dropdown from '../dropdown/internal';
|
|
8
|
-
import { useInternalI18n } from '../i18n/context';
|
|
8
|
+
import { useInternalI18n, useLocale } from '../i18n/context';
|
|
9
9
|
import InternalIcon from '../icon/internal';
|
|
10
10
|
import { getBaseProps } from '../internal/base-component';
|
|
11
11
|
import ButtonTrigger from '../internal/components/button-trigger';
|
|
@@ -96,7 +96,8 @@ const DateRangePicker = React.forwardRef(({ locale = '', startOfWeek, isDateEnab
|
|
|
96
96
|
const triggerContentId = useUniqueId('date-range-picker-trigger');
|
|
97
97
|
useFocusTracker({ rootRef, onBlur, onFocus });
|
|
98
98
|
const [isDropDownOpen, setIsDropDownOpen] = useState(false);
|
|
99
|
-
const
|
|
99
|
+
const contextLocale = useLocale();
|
|
100
|
+
const normalizedLocale = normalizeLocale('DateRangePicker', locale || contextLocale);
|
|
100
101
|
const closeDropdown = (focusTrigger = false) => {
|
|
101
102
|
var _a;
|
|
102
103
|
setIsDropDownOpen(false);
|