@razorpay/blade 12.20.0 → 12.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/native/components/ActionList/ActionListItem.js +1 -1
- package/build/lib/native/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/native/components/BottomSheet/BottomSheet.native.js +1 -1
- package/build/lib/native/components/BottomSheet/BottomSheet.native.js.map +1 -1
- package/build/lib/native/components/BottomSheet/BottomSheetContext.js.map +1 -1
- package/build/lib/native/components/Collapsible/Collapsible.js +3 -1
- package/build/lib/native/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleBody.js +2 -1
- package/build/lib/native/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleButton.js +2 -3
- package/build/lib/native/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleLink.js +2 -3
- package/build/lib/native/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/native/components/Collapsible/componentIds.js +4 -0
- package/build/lib/native/components/Collapsible/componentIds.js.map +1 -0
- package/build/lib/native/components/Dropdown/Dropdown.js +1 -1
- package/build/lib/native/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/native/components/Dropdown/DropdownHeaderFooter.js +1 -1
- package/build/lib/native/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/native/components/Dropdown/useDropdown.js +1 -1
- package/build/lib/native/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/native/components/Input/BaseInput/BaseInput.js +1 -1
- package/build/lib/native/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/AutoComplete.js +1 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/AutoComplete.js.map +1 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +2 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/web/development/components/ActionList/ActionListBox.web.js +3 -3
- package/build/lib/web/development/components/ActionList/ActionListBox.web.js.map +1 -1
- package/build/lib/web/development/components/ActionList/ActionListItem.js +4 -4
- package/build/lib/web/development/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js +9 -2
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js +3 -3
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetContext.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetHeader.web.js +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetHeader.web.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/Collapsible.js +7 -2
- package/build/lib/web/development/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleBody.js +2 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleButton.js +2 -3
- package/build/lib/web/development/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleLink.js +2 -3
- package/build/lib/web/development/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/componentIds.js +9 -0
- package/build/lib/web/development/components/Collapsible/componentIds.js.map +1 -0
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js +6 -3
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/useDatesState.js +12 -1
- package/build/lib/web/development/components/DatePicker/useDatesState.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/usePopup.js +5 -1
- package/build/lib/web/development/components/DatePicker/usePopup.js.map +1 -1
- package/build/lib/web/development/components/Drawer/DrawerSubcomponents.web.js +6 -3
- package/build/lib/web/development/components/Drawer/DrawerSubcomponents.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/Dropdown.js +8 -6
- package/build/lib/web/development/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/DropdownHeaderFooter.js +18 -8
- package/build/lib/web/development/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/useDropdown.js +16 -6
- package/build/lib/web/development/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/development/components/Input/BaseInput/BaseInput.js +7 -3
- package/build/lib/web/development/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/web/development/components/Input/BaseInput/StyledBaseInput.web.js +5 -2
- package/build/lib/web/development/components/Input/BaseInput/StyledBaseInput.web.js.map +1 -1
- package/build/lib/web/development/components/Input/DropdownInputTriggers/AutoComplete.js +11 -8
- package/build/lib/web/development/components/Input/DropdownInputTriggers/AutoComplete.js.map +1 -1
- package/build/lib/web/development/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +24 -12
- package/build/lib/web/development/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNav.web.js +13 -2
- package/build/lib/web/development/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js +1 -0
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavLevel.web.js +4 -0
- package/build/lib/web/development/components/SideNav/SideNavLevel.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js +26 -4
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepItem.web.js +2 -1
- package/build/lib/web/development/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/lib/web/production/components/ActionList/ActionListBox.web.js +3 -3
- package/build/lib/web/production/components/ActionList/ActionListBox.web.js.map +1 -1
- package/build/lib/web/production/components/ActionList/ActionListItem.js +4 -4
- package/build/lib/web/production/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js +9 -2
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js +3 -3
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetContext.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetHeader.web.js +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetHeader.web.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/Collapsible.js +7 -2
- package/build/lib/web/production/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleBody.js +2 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleButton.js +2 -3
- package/build/lib/web/production/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleLink.js +2 -3
- package/build/lib/web/production/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/componentIds.js +9 -0
- package/build/lib/web/production/components/Collapsible/componentIds.js.map +1 -0
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js +6 -3
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/useDatesState.js +12 -1
- package/build/lib/web/production/components/DatePicker/useDatesState.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/usePopup.js +5 -1
- package/build/lib/web/production/components/DatePicker/usePopup.js.map +1 -1
- package/build/lib/web/production/components/Drawer/DrawerSubcomponents.web.js +6 -3
- package/build/lib/web/production/components/Drawer/DrawerSubcomponents.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/Dropdown.js +8 -6
- package/build/lib/web/production/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/DropdownHeaderFooter.js +18 -8
- package/build/lib/web/production/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/useDropdown.js +16 -6
- package/build/lib/web/production/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/production/components/Input/BaseInput/BaseInput.js +7 -3
- package/build/lib/web/production/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/web/production/components/Input/BaseInput/StyledBaseInput.web.js +5 -2
- package/build/lib/web/production/components/Input/BaseInput/StyledBaseInput.web.js.map +1 -1
- package/build/lib/web/production/components/Input/DropdownInputTriggers/AutoComplete.js +11 -8
- package/build/lib/web/production/components/Input/DropdownInputTriggers/AutoComplete.js.map +1 -1
- package/build/lib/web/production/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +24 -12
- package/build/lib/web/production/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNav.web.js +13 -2
- package/build/lib/web/production/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js +1 -0
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavLevel.web.js +4 -0
- package/build/lib/web/production/components/SideNav/SideNavLevel.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js +26 -4
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepItem.web.js +2 -1
- package/build/lib/web/production/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/types/components/index.d.ts +20 -9
- package/build/types/components/index.native.d.ts +19 -8
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeA
|
|
|
17
17
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
18
18
|
import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.web.js';
|
|
19
19
|
|
|
20
|
-
var _excluded = ["title", "subtitle", "leading", "titleSuffix", "trailing", "testID"];
|
|
20
|
+
var _excluded = ["title", "subtitle", "leading", "titleSuffix", "trailing", "testID", "children"];
|
|
21
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
23
|
var _DropdownHeader = function _DropdownHeader(_ref) {
|
|
@@ -27,17 +27,25 @@ var _DropdownHeader = function _DropdownHeader(_ref) {
|
|
|
27
27
|
titleSuffix = _ref.titleSuffix,
|
|
28
28
|
trailing = _ref.trailing,
|
|
29
29
|
testID = _ref.testID,
|
|
30
|
+
children = _ref.children,
|
|
30
31
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
var _useDropdown = useDropdown(),
|
|
33
|
+
hasAutoCompleteInHeader = _useDropdown.hasAutoCompleteInHeader,
|
|
34
|
+
setShouldIgnoreBlurAnimation = _useDropdown.setShouldIgnoreBlurAnimation;
|
|
31
35
|
return /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread({
|
|
32
36
|
flexShrink: 0
|
|
33
37
|
}, isReactNative() ? {} : {
|
|
34
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
39
|
onMouseDown: function onMouseDown(e) {
|
|
36
|
-
// we don't want focus to ever move on header because its static element
|
|
37
|
-
|
|
40
|
+
// we don't want focus to ever move on header because its static element except when autocomplete is present
|
|
41
|
+
if (!hasAutoCompleteInHeader) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
} else {
|
|
44
|
+
setShouldIgnoreBlurAnimation(false);
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
}), {}, {
|
|
40
|
-
children: /*#__PURE__*/jsx(BaseHeader, _objectSpread({
|
|
48
|
+
children: /*#__PURE__*/jsx(BaseHeader, _objectSpread(_objectSpread({
|
|
41
49
|
title: title,
|
|
42
50
|
subtitle: subtitle,
|
|
43
51
|
leading: leading,
|
|
@@ -51,7 +59,9 @@ var _DropdownHeader = function _DropdownHeader(_ref) {
|
|
|
51
59
|
// close button
|
|
52
60
|
,
|
|
53
61
|
showCloseButton: false
|
|
54
|
-
}, makeAnalyticsAttribute(rest))
|
|
62
|
+
}, makeAnalyticsAttribute(rest)), {}, {
|
|
63
|
+
children: children
|
|
64
|
+
}))
|
|
55
65
|
}));
|
|
56
66
|
};
|
|
57
67
|
var DropdownHeader = /*#__PURE__*/assignWithoutSideEffects(_DropdownHeader, {
|
|
@@ -60,9 +70,9 @@ var DropdownHeader = /*#__PURE__*/assignWithoutSideEffects(_DropdownHeader, {
|
|
|
60
70
|
var _DropdownFooter = function _DropdownFooter(_ref2) {
|
|
61
71
|
var children = _ref2.children,
|
|
62
72
|
testID = _ref2.testID;
|
|
63
|
-
var
|
|
64
|
-
setHasFooterAction =
|
|
65
|
-
isOpen =
|
|
73
|
+
var _useDropdown2 = useDropdown(),
|
|
74
|
+
setHasFooterAction = _useDropdown2.setHasFooterAction,
|
|
75
|
+
isOpen = _useDropdown2.isOpen;
|
|
66
76
|
var footerRef = React__default.useRef(null);
|
|
67
77
|
React__default.useEffect(function () {
|
|
68
78
|
setHasFooterAction(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownHeaderFooter.js","sources":["../../../../../../src/components/Dropdown/DropdownHeaderFooter.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { useDropdown } from './useDropdown';\nimport { BaseFooter } from '~components/BaseHeaderFooter/BaseFooter';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport type { BaseFooterProps } from '~components/BaseHeaderFooter/BaseFooter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { isReactNative } from '~utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { MetaConstants } from '~utils/metaAttribute/metaConstants';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype DropdownHeaderProps = Pick<\n BaseHeaderProps,\n | 'title'\n | 'subtitle'\n | 'leading'\n | 'trailing'\n | 'titleSuffix'\n | 'testID'\n | keyof DataAnalyticsAttribute\n>;\n\nconst _DropdownHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n testID,\n ...rest\n}: DropdownHeaderProps): React.ReactElement => {\n return (\n <BaseBox\n flexShrink={0}\n {...(isReactNative()\n ? {}\n : {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onMouseDown: (e: any) => {\n // we don't want focus to ever move on header because its static element\n e.preventDefault();\n },\n })}\n >\n <BaseHeader\n title={title}\n subtitle={subtitle}\n leading={leading}\n trailing={trailing}\n titleSuffix={titleSuffix}\n metaComponentName={MetaConstants.DropdownHeader}\n testID={testID}\n // back button\n showBackButton={false}\n // close button\n showCloseButton={false}\n {...makeAnalyticsAttribute(rest)}\n
|
|
1
|
+
{"version":3,"file":"DropdownHeaderFooter.js","sources":["../../../../../../src/components/Dropdown/DropdownHeaderFooter.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { useDropdown } from './useDropdown';\nimport { BaseFooter } from '~components/BaseHeaderFooter/BaseFooter';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport type { BaseHeaderProps } from '~components/BaseHeaderFooter/BaseHeader';\nimport type { BaseFooterProps } from '~components/BaseHeaderFooter/BaseFooter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { isReactNative } from '~utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { MetaConstants } from '~utils/metaAttribute/metaConstants';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype DropdownHeaderProps = Pick<\n BaseHeaderProps,\n | 'title'\n | 'subtitle'\n | 'leading'\n | 'trailing'\n | 'titleSuffix'\n | 'testID'\n | 'children'\n | keyof DataAnalyticsAttribute\n>;\n\nconst _DropdownHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n testID,\n children,\n ...rest\n}: DropdownHeaderProps): React.ReactElement => {\n const { hasAutoCompleteInHeader, setShouldIgnoreBlurAnimation } = useDropdown();\n\n return (\n <BaseBox\n flexShrink={0}\n {...(isReactNative()\n ? {}\n : {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onMouseDown: (e: any) => {\n // we don't want focus to ever move on header because its static element except when autocomplete is present\n if (!hasAutoCompleteInHeader) {\n e.preventDefault();\n } else {\n setShouldIgnoreBlurAnimation(false);\n }\n },\n })}\n >\n <BaseHeader\n title={title}\n subtitle={subtitle}\n leading={leading}\n trailing={trailing}\n titleSuffix={titleSuffix}\n metaComponentName={MetaConstants.DropdownHeader}\n testID={testID}\n // back button\n showBackButton={false}\n // close button\n showCloseButton={false}\n {...makeAnalyticsAttribute(rest)}\n >\n {children}\n </BaseHeader>\n </BaseBox>\n );\n};\n\nconst DropdownHeader = assignWithoutSideEffects(_DropdownHeader, {\n componentId: 'DropdownHeader',\n});\n\ntype DropdownFooter = Pick<BaseFooterProps, 'children' | 'testID'>;\n\nconst _DropdownFooter = ({ children, testID }: DropdownFooter): React.ReactElement => {\n const { setHasFooterAction, isOpen } = useDropdown();\n const footerRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n setHasFooterAction(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={footerRef as any}\n {...makeAccessible({\n role: isReactNative() ? undefined : 'group',\n })}\n >\n <BaseFooter metaComponentName={MetaConstants.DropdownFooter} testID={testID}>\n {/* We don't want any of the interactive children to get focussed on TAB when dropdown is closed so we remove them from DOM itself */}\n {isOpen ? children : null}\n </BaseFooter>\n </BaseBox>\n );\n};\n\nconst DropdownFooter = assignWithoutSideEffects(_DropdownFooter, {\n componentId: 'DropdownFooter',\n});\n\nexport { DropdownHeader, DropdownFooter };\n"],"names":["_DropdownHeader","_ref","title","subtitle","leading","titleSuffix","trailing","testID","children","rest","_objectWithoutProperties","_excluded","_useDropdown","useDropdown","hasAutoCompleteInHeader","setShouldIgnoreBlurAnimation","_jsx","BaseBox","_objectSpread","flexShrink","isReactNative","onMouseDown","e","preventDefault","BaseHeader","metaComponentName","MetaConstants","DropdownHeader","showBackButton","showCloseButton","makeAnalyticsAttribute","assignWithoutSideEffects","componentId","_DropdownFooter","_ref2","_useDropdown2","setHasFooterAction","isOpen","footerRef","React","useRef","useEffect","ref","makeAccessible","role","undefined","BaseFooter","DropdownFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,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AAEA,MAAO;AAAAC,MAAAA,QAAA,EAEzE6B,MAAM,GAAG7B,QAAQ,GAAG,IAAA;KACX,CAAA;AAAC,GAAA,CACN,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAMuC,cAAc,gBAAGhB,wBAAwB,CAACE,eAAe,EAAE;AAC/DD,EAAAA,WAAW,EAAE,gBAAA;AACf,CAAC;;;;"}
|
|
@@ -36,8 +36,8 @@ var DropdownContext = /*#__PURE__*/React__default.createContext({
|
|
|
36
36
|
setShouldIgnoreBlurAnimation: noop,
|
|
37
37
|
hasFooterAction: false,
|
|
38
38
|
setHasFooterAction: noop,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
hasAutoCompleteInHeader: false,
|
|
40
|
+
setHasAutoCompleteInHeader: noop,
|
|
41
41
|
isKeydownPressed: false,
|
|
42
42
|
setIsKeydownPressed: noop,
|
|
43
43
|
changeCallbackTriggerer: 0,
|
|
@@ -53,6 +53,9 @@ var DropdownContext = /*#__PURE__*/React__default.createContext({
|
|
|
53
53
|
triggererRef: {
|
|
54
54
|
current: null
|
|
55
55
|
},
|
|
56
|
+
headerAutoCompleteRef: {
|
|
57
|
+
current: null
|
|
58
|
+
},
|
|
56
59
|
isTagDismissedRef: {
|
|
57
60
|
current: null
|
|
58
61
|
},
|
|
@@ -166,7 +169,7 @@ var useDropdown = function useDropdown() {
|
|
|
166
169
|
setActiveTagIndex(-1);
|
|
167
170
|
var newIndex = index !== null && index !== void 0 ? index : activeIndex;
|
|
168
171
|
var updatedIndex;
|
|
169
|
-
var hasAutoComplete = rest.
|
|
172
|
+
var hasAutoComplete = rest.hasAutoCompleteInHeader || dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete;
|
|
170
173
|
if (hasAutoComplete && filteredValues.length > 0) {
|
|
171
174
|
// When its autocomplete, we don't loop over all options. We only loop on filtered options
|
|
172
175
|
|
|
@@ -208,14 +211,21 @@ var useDropdown = function useDropdown() {
|
|
|
208
211
|
* - moves focus to combobox
|
|
209
212
|
*/
|
|
210
213
|
var onOptionClick = function onOptionClick(e, index) {
|
|
214
|
+
setIsKeydownPressed(false);
|
|
211
215
|
var actionType = getActionFromKey(e, isOpen, dropdownTriggerer);
|
|
212
216
|
if (typeof actionType === 'number') {
|
|
213
217
|
onOptionChange(actionType, index);
|
|
214
218
|
}
|
|
215
219
|
selectOption(index);
|
|
216
220
|
if (!isReactNative()) {
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
if (rest.hasAutoCompleteInHeader) {
|
|
222
|
+
var _rest$headerAutoCompl;
|
|
223
|
+
// move focus to autocomplete
|
|
224
|
+
(_rest$headerAutoCompl = rest.headerAutoCompleteRef.current) === null || _rest$headerAutoCompl === void 0 ? void 0 : _rest$headerAutoCompl.focus();
|
|
225
|
+
} else {
|
|
226
|
+
var _rest$triggererRef$cu;
|
|
227
|
+
(_rest$triggererRef$cu = rest.triggererRef.current) === null || _rest$triggererRef$cu === void 0 ? void 0 : _rest$triggererRef$cu.focus();
|
|
228
|
+
}
|
|
219
229
|
}
|
|
220
230
|
};
|
|
221
231
|
|
|
@@ -229,7 +239,7 @@ var useDropdown = function useDropdown() {
|
|
|
229
239
|
var onComboType = function onComboType(letter, actionType) {
|
|
230
240
|
// open the listbox if it is closed
|
|
231
241
|
setIsOpen(true);
|
|
232
|
-
if (rest.
|
|
242
|
+
if (rest.hasAutoCompleteInHeader || dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete) {
|
|
233
243
|
return;
|
|
234
244
|
}
|
|
235
245
|
if (typeof searchTimeout === 'number') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropdown.js","sources":["../../../../../../src/components/Dropdown/useDropdown.ts"],"sourcesContent":["import React from 'react';\n\nimport {\n ensureScrollVisiblity,\n getActionFromKey,\n getIndexByLetter,\n getUpdatedIndex,\n makeInputDisplayValue,\n makeInputValue,\n performAction,\n} from './dropdownUtils';\nimport type { SelectActionsType } from './dropdownUtils';\nimport type { DropdownProps } from './types';\n\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { FormInputHandleOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { isReactNative, isBrowser } from '~utils';\nimport type { ContainerElementType } from '~utils/types';\nimport { fireNativeEvent } from '~utils/fireNativeEvent';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\ntype OptionsType = {\n title: string;\n value: string;\n onClickTrigger?: (isSelected: boolean) => void;\n}[];\n\ntype DropdownContextType = {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n close: () => void;\n /**\n * contains the indexes of selected items\n */\n selectedIndices: number[];\n setSelectedIndices: (value: number[]) => void;\n /**\n * contains the indexes of selected items during controlled selection\n */\n controlledValueIndices: number[];\n setControlledValueIndices: (value: number[]) => void;\n /**\n * contains information about all the options inside actionlist\n */\n options: OptionsType;\n setOptions: (value: OptionsType) => void;\n\n /**\n * Filtered values for AutoComplete Inputs\n */\n filteredValues: string[];\n setFilteredValues: (values: string[]) => void;\n\n /** Currently active (focussed) index */\n activeIndex: number;\n setActiveIndex: (value: number) => void;\n\n /** Currently active (focussed) tag */\n activeTagIndex: number;\n setActiveTagIndex: (value: number) => void;\n\n /**\n * Sometimes we want to ignore the blur event to keep dropdown open but not ignore the blur animation from selectinput\n * E.g. When someone clicks on Footer, we just want to ignore the blur event and not the blur animation\n */\n shouldIgnoreBlurAnimation: boolean;\n setShouldIgnoreBlurAnimation: (value: boolean) => void;\n /** Tells you if keyboard was used. Its false by default and turns into true when keydown is called */\n isKeydownPressed: boolean;\n setIsKeydownPressed: (value: boolean) => void;\n /** common baseId which is prepended to multiple other ids inside this dropdown */\n dropdownBaseId: string;\n /** Which element has triggered the dropdown */\n dropdownTriggerer?:\n | 'SelectInput'\n | 'DropdownButton'\n | 'DropdownIconButton'\n | 'AutoComplete'\n | 'DropdownLink'\n | 'SearchInput'\n | 'FilterChipSelectInput';\n\n /** ref of triggerer. Used to call focus in certain places */\n triggererRef: React.MutableRefObject<HTMLButtonElement | null>;\n triggererWrapperRef: React.MutableRefObject<ContainerElementType | null>;\n actionListItemRef: React.RefObject<HTMLDivElement | null>;\n isTagDismissedRef: React.RefObject<{ value: boolean } | null>;\n visibleTagsCountRef: React.RefObject<{ value: number } | null>;\n\n selectionType?: DropdownProps['selectionType'];\n /** whether footer has an action item.\n * certain a11y behaviour changes happen here\n * E.g. tabbing moves focus to that action instead of outside\n */\n hasFooterAction: boolean;\n setHasFooterAction: (value: boolean) => void;\n\n /**\n * Whether the FilterChipSelectInput is uncontrolled\n */\n hasUnControlledFilterChipSelectInput: boolean;\n setHasUnControlledFilterChipSelectInput: (value: boolean) => void;\n /**\n * Apart from dropdownTriggerer prop, we also set this boolean because in BottomSheet, the initial trigger can be Select but also have autocomplete inside of it\n */\n hasAutoCompleteInBottomSheetHeader: boolean;\n setHasAutoCompleteInBottomSheetHeader: (value: boolean) => void;\n\n /**\n * A value that can be used in dependency array to know when Dropdown value is changed.\n *\n * E.g.\n * ```ts\n * useEffect(() => {\n * console.log('Uncontrolled value change');\n * }, [changeCallbackTriggerer])\n * ```\n */\n changeCallbackTriggerer: number;\n setChangeCallbackTriggerer: (changeCallbackTriggerer: number) => void;\n\n /**\n * true when SelectInput has `value` prop (when it is controlled)\n */\n isControlled: boolean;\n setIsControlled: (isControlled: boolean) => void;\n};\n\nconst DropdownContext = React.createContext<DropdownContextType>({\n isOpen: false,\n setIsOpen: noop,\n close: noop,\n selectedIndices: [],\n setSelectedIndices: noop,\n controlledValueIndices: [],\n setControlledValueIndices: noop,\n options: [],\n setOptions: noop,\n filteredValues: [],\n setFilteredValues: noop,\n activeIndex: -1,\n setActiveIndex: noop,\n activeTagIndex: -1,\n setActiveTagIndex: noop,\n shouldIgnoreBlurAnimation: false,\n setShouldIgnoreBlurAnimation: noop,\n hasFooterAction: false,\n setHasFooterAction: noop,\n hasAutoCompleteInBottomSheetHeader: false,\n setHasAutoCompleteInBottomSheetHeader: noop,\n isKeydownPressed: false,\n setIsKeydownPressed: noop,\n changeCallbackTriggerer: 0,\n setChangeCallbackTriggerer: noop,\n isControlled: false,\n setIsControlled: noop,\n hasUnControlledFilterChipSelectInput: false,\n setHasUnControlledFilterChipSelectInput: noop,\n dropdownBaseId: '',\n actionListItemRef: {\n current: null,\n },\n triggererRef: {\n current: null,\n },\n isTagDismissedRef: {\n current: null,\n },\n visibleTagsCountRef: {\n current: null,\n },\n triggererWrapperRef: {\n current: null,\n },\n});\n\nlet searchTimeout: number;\nlet searchString = '';\n\ntype UseDropdownReturnValue = DropdownContextType & {\n /**\n * Click event on combobox. Toggles the dropdown\n */\n onTriggerClick: () => void;\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n onTriggerKeydown: FormInputHandleOnKeyDownEvent | undefined;\n\n /**\n * Handles the click even on option.\n *\n * Contains the logic that selects the option, moves the focus, etc\n */\n onOptionClick: (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ) => void;\n\n /**\n * Removes the option with given optionsIndex\n */\n removeOption: (index: number) => void;\n\n /**\n * value that is used during form submissions\n */\n value: string;\n /**\n * This is the value that is displayed inside select after selection\n */\n displayValue: string;\n};\n\n/**\n * Handles almost all the functionality of dropdown.\n *\n * Returns the values from DropdownContext along with some helper functions and event handlers\n *\n */\nconst useDropdown = (): UseDropdownReturnValue => {\n const {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n options,\n selectionType,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setControlledValueIndices,\n filteredValues,\n dropdownTriggerer,\n ...rest\n } = React.useContext(DropdownContext);\n\n type SelectOptionType = (\n index: number,\n properties?: {\n closeOnSelection?: boolean;\n },\n ) => boolean;\n\n const setIndices = (indices: number[]): void => {\n if (isControlled) {\n setControlledValueIndices(indices);\n } else {\n setSelectedIndices(indices);\n }\n };\n\n const removeOption = (index: number): void => {\n // remove existing item\n const existingItemIndex = selectedIndices.indexOf(index);\n if (existingItemIndex < 0) {\n return;\n }\n\n setIndices([\n ...selectedIndices.slice(0, existingItemIndex),\n ...selectedIndices.slice(existingItemIndex + 1),\n ]);\n };\n\n /**\n * Marks the given index as selected.\n *\n * In single select, it also closes the menu.\n * In multiselect, it keeps the menu open for more selections\n */\n const selectOption: SelectOptionType = (\n index,\n properties = {\n closeOnSelection: true,\n },\n ) => {\n let isSelected = false;\n\n if (index < 0 || index > options.length - 1) {\n return isSelected;\n }\n\n if (selectionType === 'multiple') {\n if (selectedIndices.includes(index)) {\n removeOption(index);\n isSelected = false;\n } else {\n setIndices([...selectedIndices, index]);\n isSelected = true;\n }\n } else {\n setIndices([index]);\n isSelected = true;\n }\n\n // Triggers `onChange` on SelectInput\n setChangeCallbackTriggerer(changeCallbackTriggerer + 1);\n\n if (activeIndex !== index) {\n setActiveIndex(index);\n }\n\n if (properties?.closeOnSelection && selectionType !== 'multiple') {\n close();\n }\n\n return isSelected;\n };\n\n /**\n * Click listener for combobox (or any triggerer of the dropdown)\n */\n const onTriggerClick = (): void => {\n if (isOpen) {\n close();\n } else {\n setIsOpen(true);\n }\n };\n\n /**\n * Function that we call when we want to move focus from one option to other\n */\n const onOptionChange = (actionType: SelectActionsType, index?: number): void => {\n setActiveTagIndex(-1);\n const newIndex = index ?? activeIndex;\n let updatedIndex: number;\n const hasAutoComplete =\n rest.hasAutoCompleteInBottomSheetHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete;\n if (hasAutoComplete && filteredValues.length > 0) {\n // When its autocomplete, we don't loop over all options. We only loop on filtered options\n\n const filteredIndexes = filteredValues\n .map((filteredValue) => options.findIndex((option) => option.value === filteredValue))\n .sort((a, b) => a - b);\n\n updatedIndex =\n filteredIndexes[\n getUpdatedIndex({\n currentIndex: filteredIndexes.indexOf(newIndex),\n maxIndex: filteredIndexes.length - 1,\n actionType,\n })\n ];\n } else {\n updatedIndex = getUpdatedIndex({\n currentIndex: newIndex,\n maxIndex: options.length - 1,\n actionType,\n });\n }\n setActiveIndex(updatedIndex);\n\n const optionValues = options.map((option) => option.value);\n ensureScrollVisiblity(updatedIndex, rest.actionListItemRef.current, optionValues);\n if (isBrowser()) {\n fireNativeEvent(rest.actionListItemRef as React.RefObject<HTMLElement>, ['change', 'input']);\n }\n };\n\n /**\n * Click handler when user clicks on any particular option.\n *\n * It\n * - changes the option focus\n * - selects that option\n * - moves focus to combobox\n */\n const onOptionClick = (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ): void => {\n const actionType = getActionFromKey(e, isOpen, dropdownTriggerer);\n if (typeof actionType === 'number') {\n onOptionChange(actionType, index);\n }\n selectOption(index);\n if (!isReactNative()) {\n rest.triggererRef.current?.focus();\n }\n };\n\n /**\n * Function we call to handle the typeahead.\n *\n * It takes a letter, stores that letter in searchString (and clears it after timeout) to maintain a word\n *\n * Then searches for that word in options and moves focus there.\n */\n const onComboType = (letter: string, actionType: SelectActionsType): void => {\n // open the listbox if it is closed\n setIsOpen(true);\n\n if (\n rest.hasAutoCompleteInBottomSheetHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete\n ) {\n return;\n }\n\n if (typeof searchTimeout === 'number') {\n window.clearTimeout(searchTimeout);\n }\n\n searchTimeout = window.setTimeout(() => {\n searchString = '';\n }, 500);\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n searchString = searchString + letter;\n const optionTitles = options.map((option) => option.title);\n const searchIndex = getIndexByLetter(optionTitles, searchString, activeIndex + 1);\n\n // if a match was found, go to it\n if (searchIndex >= 0) {\n onOptionChange(actionType, searchIndex);\n }\n // if no matches, clear the timeout and search string\n else {\n window.clearTimeout(searchTimeout);\n searchString = '';\n }\n };\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n const onTriggerKeydown = (e: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n }): void => {\n if (!isKeydownPressed && ![' ', 'Enter', 'Escape', 'Meta'].includes(e.event.key)) {\n // When keydown is not already pressed and its not Enter, Space, Command, or Escape key (those are generic keys and we only want to handle arrow keys or home buttons etc)\n setIsKeydownPressed(true);\n }\n\n const actionType = getActionFromKey(e.event, isOpen, dropdownTriggerer);\n\n if (actionType) {\n performAction(actionType, e, {\n setIsOpen,\n close,\n onOptionChange,\n onComboType,\n selectCurrentOption: () => {\n if (activeIndex < 0) {\n return;\n }\n\n const isSelected = selectOption(activeIndex);\n if (rest.hasFooterAction && !isReactNative()) {\n rest.triggererRef.current?.focus();\n }\n\n options[activeIndex].onClickTrigger?.(isSelected);\n },\n });\n }\n };\n\n return {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n filteredValues,\n removeOption,\n setControlledValueIndices,\n onTriggerClick,\n onTriggerKeydown,\n onOptionClick,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n options,\n value: makeInputValue(selectedIndices, options),\n displayValue: makeInputDisplayValue(selectedIndices, options),\n selectionType,\n dropdownTriggerer,\n ...rest,\n };\n};\n\nexport type { DropdownContextType, OptionsType };\nexport { useDropdown, DropdownContext };\n"],"names":["noop","DropdownContext","React","createContext","isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","controlledValueIndices","setControlledValueIndices","options","setOptions","filteredValues","setFilteredValues","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","hasFooterAction","setHasFooterAction","hasAutoCompleteInBottomSheetHeader","setHasAutoCompleteInBottomSheetHeader","isKeydownPressed","setIsKeydownPressed","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setIsControlled","hasUnControlledFilterChipSelectInput","setHasUnControlledFilterChipSelectInput","dropdownBaseId","actionListItemRef","current","triggererRef","isTagDismissedRef","visibleTagsCountRef","triggererWrapperRef","searchTimeout","searchString","useDropdown","_React$useContext","useContext","selectionType","dropdownTriggerer","rest","_objectWithoutProperties","_excluded","setIndices","indices","removeOption","index","existingItemIndex","indexOf","concat","_toConsumableArray","slice","selectOption","properties","arguments","length","undefined","closeOnSelection","isSelected","includes","onTriggerClick","onOptionChange","actionType","newIndex","updatedIndex","hasAutoComplete","dropdownComponentIds","triggers","AutoComplete","filteredIndexes","map","filteredValue","findIndex","option","value","sort","a","b","getUpdatedIndex","currentIndex","maxIndex","optionValues","ensureScrollVisiblity","isBrowser","fireNativeEvent","onOptionClick","e","getActionFromKey","isReactNative","_rest$triggererRef$cu","focus","onComboType","letter","window","clearTimeout","setTimeout","optionTitles","title","searchIndex","getIndexByLetter","onTriggerKeydown","event","key","performAction","selectCurrentOption","_options$activeIndex$","_options$activeIndex","_rest$triggererRef$cu2","onClickTrigger","call","_objectSpread","makeInputValue","displayValue","makeInputDisplayValue"],"mappings":";;;;;;;;;;;;;;;;AAoBA;AACA,IAAMA,IAAI,GAAG,SAAPA,IAAIA,GAAe,EAAE,CAAA;AA6G3B,IAAMC,eAAe,gBAAGC,cAAK,CAACC,aAAa,CAAsB;AAC/DC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,SAAS,EAAEL,IAAI;AACfM,EAAAA,KAAK,EAAEN,IAAI;AACXO,EAAAA,eAAe,EAAE,EAAE;AACnBC,EAAAA,kBAAkB,EAAER,IAAI;AACxBS,EAAAA,sBAAsB,EAAE,EAAE;AAC1BC,EAAAA,yBAAyB,EAAEV,IAAI;AAC/BW,EAAAA,OAAO,EAAE,EAAE;AACXC,EAAAA,UAAU,EAAEZ,IAAI;AAChBa,EAAAA,cAAc,EAAE,EAAE;AAClBC,EAAAA,iBAAiB,EAAEd,IAAI;EACvBe,WAAW,EAAE,CAAC,CAAC;AACfC,EAAAA,cAAc,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AmB;AACnBC,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBC,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAC1BC,IAAAA,YAAY,EAAZA,YAAY;AACZlB,IAAAA,OAAO,EAAPA,OAAO;AACPsE,IAAAA,KAAK,EAAEqC,cAAc,CAAC/G,eAAe,EAAEI,OAAO,CAAC;AAC/C4G,IAAAA,YAAY,EAAEC,qBAAqB,CAACjH,eAAe,EAAEI,OAAO,CAAC;AAC7DkC,IAAAA,aAAa,EAAbA,aAAa;AACbC,IAAAA,iBAAiB,EAAjBA,iBAAAA;AAAiB,GAAA,EACdC,IAAI,CAAA,CAAA;AAEX;;;;"}
|
|
1
|
+
{"version":3,"file":"useDropdown.js","sources":["../../../../../../src/components/Dropdown/useDropdown.ts"],"sourcesContent":["import React from 'react';\n\nimport {\n ensureScrollVisiblity,\n getActionFromKey,\n getIndexByLetter,\n getUpdatedIndex,\n makeInputDisplayValue,\n makeInputValue,\n performAction,\n} from './dropdownUtils';\nimport type { SelectActionsType } from './dropdownUtils';\nimport type { DropdownProps } from './types';\n\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport type { FormInputHandleOnKeyDownEvent } from '~components/Form/FormTypes';\nimport { isReactNative, isBrowser } from '~utils';\nimport type { ContainerElementType } from '~utils/types';\nimport { fireNativeEvent } from '~utils/fireNativeEvent';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = (): void => {};\n\ntype OptionsType = {\n title: string;\n value: string;\n onClickTrigger?: (isSelected: boolean) => void;\n}[];\n\ntype DropdownContextType = {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n close: () => void;\n /**\n * contains the indexes of selected items\n */\n selectedIndices: number[];\n setSelectedIndices: (value: number[]) => void;\n /**\n * contains the indexes of selected items during controlled selection\n */\n controlledValueIndices: number[];\n setControlledValueIndices: (value: number[]) => void;\n /**\n * contains information about all the options inside actionlist\n */\n options: OptionsType;\n setOptions: (value: OptionsType) => void;\n\n /**\n * Filtered values for AutoComplete Inputs\n */\n filteredValues: string[];\n setFilteredValues: (values: string[]) => void;\n\n /** Currently active (focussed) index */\n activeIndex: number;\n setActiveIndex: (value: number) => void;\n\n /** Currently active (focussed) tag */\n activeTagIndex: number;\n setActiveTagIndex: (value: number) => void;\n\n /**\n * Sometimes we want to ignore the blur event to keep dropdown open but not ignore the blur animation from selectinput\n * E.g. When someone clicks on Footer, we just want to ignore the blur event and not the blur animation\n */\n shouldIgnoreBlurAnimation: boolean;\n setShouldIgnoreBlurAnimation: (value: boolean) => void;\n /** Tells you if keyboard was used. Its false by default and turns into true when keydown is called */\n isKeydownPressed: boolean;\n setIsKeydownPressed: (value: boolean) => void;\n /** common baseId which is prepended to multiple other ids inside this dropdown */\n dropdownBaseId: string;\n /** Which element has triggered the dropdown */\n dropdownTriggerer?:\n | 'SelectInput'\n | 'DropdownButton'\n | 'DropdownIconButton'\n | 'AutoComplete'\n | 'DropdownLink'\n | 'SearchInput'\n | 'FilterChipSelectInput';\n\n /** ref of triggerer. Used to call focus in certain places */\n triggererRef: React.MutableRefObject<HTMLButtonElement | null>;\n headerAutoCompleteRef: React.MutableRefObject<HTMLButtonElement | null>;\n triggererWrapperRef: React.MutableRefObject<ContainerElementType | null>;\n actionListItemRef: React.RefObject<HTMLDivElement | null>;\n isTagDismissedRef: React.RefObject<{ value: boolean } | null>;\n visibleTagsCountRef: React.RefObject<{ value: number } | null>;\n\n selectionType?: DropdownProps['selectionType'];\n /** whether footer has an action item.\n * certain a11y behaviour changes happen here\n * E.g. tabbing moves focus to that action instead of outside\n */\n hasFooterAction: boolean;\n setHasFooterAction: (value: boolean) => void;\n\n /**\n * Whether the FilterChipSelectInput is uncontrolled\n */\n hasUnControlledFilterChipSelectInput: boolean;\n setHasUnControlledFilterChipSelectInput: (value: boolean) => void;\n /**\n * Apart from dropdownTriggerer prop, we also set this boolean because in BottomSheetHeader and DropdownHeader, the trigger can be Select but they can also have autocomplete inside of header\n */\n hasAutoCompleteInHeader: boolean;\n setHasAutoCompleteInHeader: (value: boolean) => void;\n\n /**\n * A value that can be used in dependency array to know when Dropdown value is changed.\n *\n * E.g.\n * ```ts\n * useEffect(() => {\n * console.log('Uncontrolled value change');\n * }, [changeCallbackTriggerer])\n * ```\n */\n changeCallbackTriggerer: number;\n setChangeCallbackTriggerer: (changeCallbackTriggerer: number) => void;\n\n /**\n * true when SelectInput has `value` prop (when it is controlled)\n */\n isControlled: boolean;\n setIsControlled: (isControlled: boolean) => void;\n};\n\nconst DropdownContext = React.createContext<DropdownContextType>({\n isOpen: false,\n setIsOpen: noop,\n close: noop,\n selectedIndices: [],\n setSelectedIndices: noop,\n controlledValueIndices: [],\n setControlledValueIndices: noop,\n options: [],\n setOptions: noop,\n filteredValues: [],\n setFilteredValues: noop,\n activeIndex: -1,\n setActiveIndex: noop,\n activeTagIndex: -1,\n setActiveTagIndex: noop,\n shouldIgnoreBlurAnimation: false,\n setShouldIgnoreBlurAnimation: noop,\n hasFooterAction: false,\n setHasFooterAction: noop,\n hasAutoCompleteInHeader: false,\n setHasAutoCompleteInHeader: noop,\n isKeydownPressed: false,\n setIsKeydownPressed: noop,\n changeCallbackTriggerer: 0,\n setChangeCallbackTriggerer: noop,\n isControlled: false,\n setIsControlled: noop,\n hasUnControlledFilterChipSelectInput: false,\n setHasUnControlledFilterChipSelectInput: noop,\n dropdownBaseId: '',\n actionListItemRef: {\n current: null,\n },\n triggererRef: {\n current: null,\n },\n headerAutoCompleteRef: {\n current: null,\n },\n isTagDismissedRef: {\n current: null,\n },\n visibleTagsCountRef: {\n current: null,\n },\n triggererWrapperRef: {\n current: null,\n },\n});\n\nlet searchTimeout: number;\nlet searchString = '';\n\ntype UseDropdownReturnValue = DropdownContextType & {\n /**\n * Click event on combobox. Toggles the dropdown\n */\n onTriggerClick: () => void;\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n onTriggerKeydown: FormInputHandleOnKeyDownEvent | undefined;\n\n /**\n * Handles the click even on option.\n *\n * Contains the logic that selects the option, moves the focus, etc\n */\n onOptionClick: (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ) => void;\n\n /**\n * Removes the option with given optionsIndex\n */\n removeOption: (index: number) => void;\n\n /**\n * value that is used during form submissions\n */\n value: string;\n /**\n * This is the value that is displayed inside select after selection\n */\n displayValue: string;\n};\n\n/**\n * Handles almost all the functionality of dropdown.\n *\n * Returns the values from DropdownContext along with some helper functions and event handlers\n *\n */\nconst useDropdown = (): UseDropdownReturnValue => {\n const {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n options,\n selectionType,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setControlledValueIndices,\n filteredValues,\n dropdownTriggerer,\n ...rest\n } = React.useContext(DropdownContext);\n\n type SelectOptionType = (\n index: number,\n properties?: {\n closeOnSelection?: boolean;\n },\n ) => boolean;\n\n const setIndices = (indices: number[]): void => {\n if (isControlled) {\n setControlledValueIndices(indices);\n } else {\n setSelectedIndices(indices);\n }\n };\n\n const removeOption = (index: number): void => {\n // remove existing item\n const existingItemIndex = selectedIndices.indexOf(index);\n if (existingItemIndex < 0) {\n return;\n }\n\n setIndices([\n ...selectedIndices.slice(0, existingItemIndex),\n ...selectedIndices.slice(existingItemIndex + 1),\n ]);\n };\n\n /**\n * Marks the given index as selected.\n *\n * In single select, it also closes the menu.\n * In multiselect, it keeps the menu open for more selections\n */\n const selectOption: SelectOptionType = (\n index,\n properties = {\n closeOnSelection: true,\n },\n ) => {\n let isSelected = false;\n\n if (index < 0 || index > options.length - 1) {\n return isSelected;\n }\n\n if (selectionType === 'multiple') {\n if (selectedIndices.includes(index)) {\n removeOption(index);\n isSelected = false;\n } else {\n setIndices([...selectedIndices, index]);\n isSelected = true;\n }\n } else {\n setIndices([index]);\n isSelected = true;\n }\n\n // Triggers `onChange` on SelectInput\n setChangeCallbackTriggerer(changeCallbackTriggerer + 1);\n\n if (activeIndex !== index) {\n setActiveIndex(index);\n }\n\n if (properties?.closeOnSelection && selectionType !== 'multiple') {\n close();\n }\n\n return isSelected;\n };\n\n /**\n * Click listener for combobox (or any triggerer of the dropdown)\n */\n const onTriggerClick = (): void => {\n if (isOpen) {\n close();\n } else {\n setIsOpen(true);\n }\n };\n\n /**\n * Function that we call when we want to move focus from one option to other\n */\n const onOptionChange = (actionType: SelectActionsType, index?: number): void => {\n setActiveTagIndex(-1);\n const newIndex = index ?? activeIndex;\n let updatedIndex: number;\n const hasAutoComplete =\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete;\n if (hasAutoComplete && filteredValues.length > 0) {\n // When its autocomplete, we don't loop over all options. We only loop on filtered options\n\n const filteredIndexes = filteredValues\n .map((filteredValue) => options.findIndex((option) => option.value === filteredValue))\n .sort((a, b) => a - b);\n\n updatedIndex =\n filteredIndexes[\n getUpdatedIndex({\n currentIndex: filteredIndexes.indexOf(newIndex),\n maxIndex: filteredIndexes.length - 1,\n actionType,\n })\n ];\n } else {\n updatedIndex = getUpdatedIndex({\n currentIndex: newIndex,\n maxIndex: options.length - 1,\n actionType,\n });\n }\n setActiveIndex(updatedIndex);\n\n const optionValues = options.map((option) => option.value);\n ensureScrollVisiblity(updatedIndex, rest.actionListItemRef.current, optionValues);\n if (isBrowser()) {\n fireNativeEvent(rest.actionListItemRef as React.RefObject<HTMLElement>, ['change', 'input']);\n }\n };\n\n /**\n * Click handler when user clicks on any particular option.\n *\n * It\n * - changes the option focus\n * - selects that option\n * - moves focus to combobox\n */\n const onOptionClick = (\n e: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLInputElement>,\n index: number,\n ): void => {\n setIsKeydownPressed(false);\n const actionType = getActionFromKey(e, isOpen, dropdownTriggerer);\n if (typeof actionType === 'number') {\n onOptionChange(actionType, index);\n }\n selectOption(index);\n\n if (!isReactNative()) {\n if (rest.hasAutoCompleteInHeader) {\n // move focus to autocomplete\n rest.headerAutoCompleteRef.current?.focus();\n } else {\n rest.triggererRef.current?.focus();\n }\n }\n };\n\n /**\n * Function we call to handle the typeahead.\n *\n * It takes a letter, stores that letter in searchString (and clears it after timeout) to maintain a word\n *\n * Then searches for that word in options and moves focus there.\n */\n const onComboType = (letter: string, actionType: SelectActionsType): void => {\n // open the listbox if it is closed\n setIsOpen(true);\n\n if (\n rest.hasAutoCompleteInHeader ||\n dropdownTriggerer === dropdownComponentIds.triggers.AutoComplete\n ) {\n return;\n }\n\n if (typeof searchTimeout === 'number') {\n window.clearTimeout(searchTimeout);\n }\n\n searchTimeout = window.setTimeout(() => {\n searchString = '';\n }, 500);\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n searchString = searchString + letter;\n const optionTitles = options.map((option) => option.title);\n const searchIndex = getIndexByLetter(optionTitles, searchString, activeIndex + 1);\n\n // if a match was found, go to it\n if (searchIndex >= 0) {\n onOptionChange(actionType, searchIndex);\n }\n // if no matches, clear the timeout and search string\n else {\n window.clearTimeout(searchTimeout);\n searchString = '';\n }\n };\n\n /**\n * Keydown event of combobox. Handles most of the keyboard accessibility of dropdown\n */\n const onTriggerKeydown = (e: {\n event: React.KeyboardEvent<HTMLInputElement | HTMLButtonElement>;\n }): void => {\n if (!isKeydownPressed && ![' ', 'Enter', 'Escape', 'Meta'].includes(e.event.key)) {\n // When keydown is not already pressed and its not Enter, Space, Command, or Escape key (those are generic keys and we only want to handle arrow keys or home buttons etc)\n setIsKeydownPressed(true);\n }\n\n const actionType = getActionFromKey(e.event, isOpen, dropdownTriggerer);\n\n if (actionType) {\n performAction(actionType, e, {\n setIsOpen,\n close,\n onOptionChange,\n onComboType,\n selectCurrentOption: () => {\n if (activeIndex < 0) {\n return;\n }\n\n const isSelected = selectOption(activeIndex);\n if (rest.hasFooterAction && !isReactNative()) {\n rest.triggererRef.current?.focus();\n }\n\n options[activeIndex].onClickTrigger?.(isSelected);\n },\n });\n }\n };\n\n return {\n isOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n filteredValues,\n removeOption,\n setControlledValueIndices,\n onTriggerClick,\n onTriggerKeydown,\n onOptionClick,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n isKeydownPressed,\n setIsKeydownPressed,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n options,\n value: makeInputValue(selectedIndices, options),\n displayValue: makeInputDisplayValue(selectedIndices, options),\n selectionType,\n dropdownTriggerer,\n ...rest,\n };\n};\n\nexport type { DropdownContextType, OptionsType };\nexport { useDropdown, DropdownContext };\n"],"names":["noop","DropdownContext","React","createContext","isOpen","setIsOpen","close","selectedIndices","setSelectedIndices","controlledValueIndices","setControlledValueIndices","options","setOptions","filteredValues","setFilteredValues","activeIndex","setActiveIndex","activeTagIndex","setActiveTagIndex","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","hasFooterAction","setHasFooterAction","hasAutoCompleteInHeader","setHasAutoCompleteInHeader","isKeydownPressed","setIsKeydownPressed","changeCallbackTriggerer","setChangeCallbackTriggerer","isControlled","setIsControlled","hasUnControlledFilterChipSelectInput","setHasUnControlledFilterChipSelectInput","dropdownBaseId","actionListItemRef","current","triggererRef","headerAutoCompleteRef","isTagDismissedRef","visibleTagsCountRef","triggererWrapperRef","searchTimeout","searchString","useDropdown","_React$useContext","useContext","selectionType","dropdownTriggerer","rest","_objectWithoutProperties","_excluded","setIndices","indices","removeOption","index","existingItemIndex","indexOf","concat","_toConsumableArray","slice","selectOption","properties","arguments","length","undefined","closeOnSelection","isSelected","includes","onTriggerClick","onOptionChange","actionType","newIndex","updatedIndex","hasAutoComplete","dropdownComponentIds","triggers","AutoComplete","filteredIndexes","map","filteredValue","findIndex","option","value","sort","a","b","getUpdatedIndex","currentIndex","maxIndex","optionValues","ensureScrollVisiblity","isBrowser","fireNativeEvent","onOptionClick","e","getActionFromKey","isReactNative","_rest$headerAutoCompl","focus","_rest$triggererRef$cu","onComboType","letter","window","clearTimeout","setTimeout","optionTitles","title","searchIndex","getIndexByLetter","onTriggerKeydown","event","key","performAction","selectCurrentOption","_options$activeIndex$","_options$activeIndex","_rest$triggererRef$cu2","onClickTrigger","call","_objectSpread","makeInputValue","displayValue","makeInputDisplayValue"],"mappings":";;;;;;;;;;;;;;;;AAoBA;AACA,IAAMA,IAAI,GAAG,SAAPA,IAAIA,GAAe,EAAE,CAAA;AA8G3B,IAAMC,eAAe,gBAAGC,cAAK,CAACC,aAAa,CAAsB;AAC/DC,EAAAA,MAAM,EAAE,KAAK;AACbC,EAAAA,SAAS,EAAEL,IAAI;AACfM,EAAAA,KAAK,EAAEN,IAAI;AACXO,EAAAA,eAAe,EAAE,EAAE;AACnBC,EAAAA,kBAAkB,EAAER,IAAI;AACxBS,EAAAA,sBAAsB,EAAE,EAAE;AAC1BC,EAAAA,yBAAyB,EAAEV,IAAI;AAC/BW,EAAAA,OAAO,EAAE,EAAE;AACXC,EAAAA,UAAU,EAAEZ,IAAI;AAChBa,EAAAA,cAAc,EAAE,EAAE;AAClBC,EAAAA,iBAAiB,EAAEd,IAAI;EACvBe,WAAW,EAAE,CAAC,CAAC;AACfC,EAAAA,cAAc,EAAEhB,IAAI;EACpBiB,cAAc,EAAE,CAAC,CAAC;AAClBC,EAAAA,iBAAiB,EAAElB,IAAI;AACvBmB,EAAAA,yBAAyB,EAAE,KAAK;AAChCC,EAAAA,4BAA4B,EAAEpB,IAAI;AAClCqB,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,kBAAkB,EAAEtB,IAAI;AACxBuB,EAAAA,uBAAuB,EAAE,KAAK;AAC9BC,EAAAA,0BAA0B,EAAExB,IAAI;AAChCyB,EAAAA,gBAAgB,EAAE,KAAK;AACvBC,EAAAA,mBAAmB,EAAE1B,IAAI;AACzB2B,EAAAA,uBAAuB,EAA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,mBAAmB,EAAnBA,mBAAmB;AACnBC,IAAAA,uBAAuB,EAAvBA,uBAAuB;AACvBC,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAC1BC,IAAAA,YAAY,EAAZA,YAAY;AACZlB,IAAAA,OAAO,EAAPA,OAAO;AACPuE,IAAAA,KAAK,EAAEsC,cAAc,CAACjH,eAAe,EAAEI,OAAO,CAAC;AAC/C8G,IAAAA,YAAY,EAAEC,qBAAqB,CAACnH,eAAe,EAAEI,OAAO,CAAC;AAC7DmC,IAAAA,aAAa,EAAbA,aAAa;AACbC,IAAAA,iBAAiB,EAAjBA,iBAAAA;AAAiB,GAAA,EACdC,IAAI,CAAA,CAAA;AAEX;;;;"}
|
|
@@ -47,7 +47,7 @@ import { makeSize } from '../../../utils/makeSize/makeSize.js';
|
|
|
47
47
|
import { FormHint } from '../../Form/FormHint.js';
|
|
48
48
|
import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
49
49
|
|
|
50
|
-
var _excluded = ["as", "label", "labelPosition", "placeholder", "type", "defaultValue", "tags", "showAllTags", "activeTagIndex", "setActiveTagIndex", "name", "value", "onFocus", "onChange", "onInput", "onBlur", "onSubmit", "onClick", "onKeyDown", "isDisabled", "necessityIndicator", "validationState", "errorText", "helpText", "successText", "isRequired", "leadingIcon", "prefix", "trailingInteractionElement", "onTrailingInteractionElementClick", "leadingInteractionElement", "suffix", "trailingIcon", "maxCharacters", "textAlign", "autoFocus", "keyboardReturnKeyType", "keyboardType", "autoCompleteSuggestionType", "trailingHeaderSlot", "trailingFooterSlot", "numberOfLines", "id", "componentName", "accessibilityLabel", "labelId", "activeDescendant", "hideLabelText", "hideFormHint", "hasPopup", "popupId", "isPopupExpanded", "maxTagRows", "shouldIgnoreBlurAnimation", "setShouldIgnoreBlurAnimation", "autoCapitalize", "setInputWrapperRef", "testID", "isDropdownTrigger", "isLabelInsideInput", "size", "trailingButton", "valueComponentType", "isTableInputCell", "showHintsAsTooltip", "_motionMeta"];
|
|
50
|
+
var _excluded = ["as", "label", "labelPosition", "placeholder", "type", "defaultValue", "tags", "showAllTags", "activeTagIndex", "setActiveTagIndex", "name", "value", "onFocus", "onChange", "onInput", "onBlur", "onSubmit", "onClick", "onKeyDown", "isDisabled", "necessityIndicator", "validationState", "errorText", "helpText", "successText", "isRequired", "leadingIcon", "prefix", "trailingInteractionElement", "onTrailingInteractionElementClick", "leadingInteractionElement", "suffix", "trailingIcon", "maxCharacters", "textAlign", "autoFocus", "keyboardReturnKeyType", "keyboardType", "autoCompleteSuggestionType", "trailingHeaderSlot", "trailingFooterSlot", "numberOfLines", "id", "componentName", "accessibilityLabel", "labelId", "activeDescendant", "hideLabelText", "hideFormHint", "hasPopup", "popupId", "isPopupExpanded", "maxTagRows", "shouldIgnoreBlurAnimation", "setShouldIgnoreBlurAnimation", "autoCapitalize", "setInputWrapperRef", "testID", "isDropdownTrigger", "isLabelInsideInput", "size", "trailingButton", "valueComponentType", "isTableInputCell", "showHintsAsTooltip", "_motionMeta", "role", "tabIndex"];
|
|
51
51
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
52
52
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
53
53
|
var autoCompleteSuggestionTypeValues = ['none', 'on', 'name', 'email', 'username', 'password', 'newPassword', 'oneTimeCode', 'telephone', 'postalCode', 'countryName', 'creditCardNumber', 'creditCardCSC', 'creditCardExpiry', 'creditCardExpiryMonth', 'creditCardExpiryYear'];
|
|
@@ -378,6 +378,8 @@ var _BaseInput = function _BaseInput(_ref12, ref) {
|
|
|
378
378
|
_ref12$showHintsAsToo = _ref12.showHintsAsTooltip,
|
|
379
379
|
showHintsAsTooltip = _ref12$showHintsAsToo === void 0 ? false : _ref12$showHintsAsToo,
|
|
380
380
|
_motionMeta = _ref12._motionMeta,
|
|
381
|
+
role = _ref12.role,
|
|
382
|
+
tabIndex = _ref12.tabIndex,
|
|
381
383
|
rest = _objectWithoutProperties(_ref12, _excluded);
|
|
382
384
|
var _useTheme = useTheme(),
|
|
383
385
|
theme = _useTheme.theme;
|
|
@@ -392,6 +394,7 @@ var _BaseInput = function _BaseInput(_ref12, ref) {
|
|
|
392
394
|
showAllTagsWithAnimation = _React$useState4[0],
|
|
393
395
|
setShowAllTagsWithAnimation = _React$useState4[1];
|
|
394
396
|
var isReactNative = getPlatformType() === 'react-native';
|
|
397
|
+
var defaultRole = hasPopup ? 'combobox' : undefined;
|
|
395
398
|
React__default.useEffect(function () {
|
|
396
399
|
if (showAllTags) {
|
|
397
400
|
setShowAllTagsWithAnimation(true);
|
|
@@ -450,7 +453,7 @@ var _BaseInput = function _BaseInput(_ref12, ref) {
|
|
|
450
453
|
hasPopup: hasPopup,
|
|
451
454
|
expanded: hasPopup ? isPopupExpanded : undefined,
|
|
452
455
|
controls: hasPopup ? popupId : undefined,
|
|
453
|
-
role:
|
|
456
|
+
role: role !== null && role !== void 0 ? role : defaultRole,
|
|
454
457
|
activeDescendant: activeDescendant
|
|
455
458
|
});
|
|
456
459
|
var willRenderHintText = Boolean(helpText) || validationState === 'success' && Boolean(successText) || validationState === 'error' && Boolean(errorText);
|
|
@@ -606,7 +609,8 @@ var _BaseInput = function _BaseInput(_ref12, ref) {
|
|
|
606
609
|
isDropdownTrigger: isDropdownTrigger,
|
|
607
610
|
$size: size,
|
|
608
611
|
valueComponentType: valueComponentType,
|
|
609
|
-
isTableInputCell: isTableInputCell
|
|
612
|
+
isTableInputCell: isTableInputCell,
|
|
613
|
+
tabIndex: tabIndex
|
|
610
614
|
}, metaAttribute({
|
|
611
615
|
name: MetaConstants.StyledBaseInput
|
|
612
616
|
})), makeAnalyticsAttribute(rest)))
|