@razorpay/blade 11.6.2 → 11.7.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/Accordion/Accordion.js +2 -2
- package/build/lib/native/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionButton.native.js +2 -2
- package/build/lib/native/components/Accordion/AccordionButton.native.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionContext.js +2 -2
- package/build/lib/native/components/Accordion/AccordionContext.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionItem.js +11 -14
- package/build/lib/native/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionItemBody.js +24 -0
- package/build/lib/native/components/Accordion/AccordionItemBody.js.map +1 -0
- package/build/lib/native/components/Accordion/AccordionItemHeader.js +24 -0
- package/build/lib/native/components/Accordion/AccordionItemHeader.js.map +1 -0
- package/build/lib/native/components/Accordion/commonStyles.js +1 -1
- package/build/lib/native/components/Accordion/commonStyles.js.map +1 -1
- package/build/lib/native/components/Accordion/componentIds.js +4 -0
- package/build/lib/native/components/Accordion/componentIds.js.map +1 -0
- package/build/lib/native/components/ActionList/ActionListBox.native.js +1 -4
- package/build/lib/native/components/ActionList/ActionListBox.native.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/Collapsible/CollapsibleBodyContent.native.js.map +1 -1
- package/build/lib/native/components/Dropdown/dropdownUtils.js +1 -1
- package/build/lib/native/components/Dropdown/dropdownUtils.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/index.js +2 -0
- package/build/lib/native/components/index.js.map +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/development/components/Accordion/Accordion.js +57 -6
- package/build/lib/web/development/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionButton.web.js +21 -25
- package/build/lib/web/development/components/Accordion/AccordionButton.web.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionContext.js +16 -1
- package/build/lib/web/development/components/Accordion/AccordionContext.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItem.js +66 -66
- package/build/lib/web/development/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItemBody.js +84 -0
- package/build/lib/web/development/components/Accordion/AccordionItemBody.js.map +1 -0
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js +71 -0
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js.map +1 -0
- package/build/lib/web/development/components/Accordion/StyledAccordionButton.web.js +3 -2
- package/build/lib/web/development/components/Accordion/StyledAccordionButton.web.js.map +1 -1
- package/build/lib/web/development/components/Accordion/commonStyles.js +8 -6
- package/build/lib/web/development/components/Accordion/commonStyles.js.map +1 -1
- package/build/lib/web/development/components/Accordion/componentIds.js +8 -0
- package/build/lib/web/development/components/Accordion/componentIds.js.map +1 -0
- package/build/lib/web/development/components/Accordion/index.js +2 -0
- package/build/lib/web/development/components/Accordion/index.js.map +1 -1
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js +131 -68
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleBodyContent.web.js +3 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleBodyContent.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/DropdownOverlay.web.js +4 -2
- package/build/lib/web/development/components/Dropdown/DropdownOverlay.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/dropdownUtils.js +16 -8
- package/build/lib/web/development/components/Dropdown/dropdownUtils.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/useDropdown.js +1 -1
- package/build/lib/web/development/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/development/components/FileUpload/FileUpload.web.js +0 -1
- package/build/lib/web/development/components/FileUpload/FileUpload.web.js.map +1 -1
- package/build/lib/web/development/components/index.js +2 -0
- package/build/lib/web/development/components/index.js.map +1 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js +2 -0
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/production/components/Accordion/Accordion.js +57 -6
- package/build/lib/web/production/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionButton.web.js +21 -25
- package/build/lib/web/production/components/Accordion/AccordionButton.web.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionContext.js +16 -1
- package/build/lib/web/production/components/Accordion/AccordionContext.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItem.js +66 -66
- package/build/lib/web/production/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItemBody.js +84 -0
- package/build/lib/web/production/components/Accordion/AccordionItemBody.js.map +1 -0
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js +71 -0
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js.map +1 -0
- package/build/lib/web/production/components/Accordion/StyledAccordionButton.web.js +3 -2
- package/build/lib/web/production/components/Accordion/StyledAccordionButton.web.js.map +1 -1
- package/build/lib/web/production/components/Accordion/commonStyles.js +8 -6
- package/build/lib/web/production/components/Accordion/commonStyles.js.map +1 -1
- package/build/lib/web/production/components/Accordion/componentIds.js +8 -0
- package/build/lib/web/production/components/Accordion/componentIds.js.map +1 -0
- package/build/lib/web/production/components/Accordion/index.js +2 -0
- package/build/lib/web/production/components/Accordion/index.js.map +1 -1
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js +131 -68
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleBodyContent.web.js +3 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleBodyContent.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/DropdownOverlay.web.js +4 -2
- package/build/lib/web/production/components/Dropdown/DropdownOverlay.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/dropdownUtils.js +16 -8
- package/build/lib/web/production/components/Dropdown/dropdownUtils.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/useDropdown.js +1 -1
- package/build/lib/web/production/components/Dropdown/useDropdown.js.map +1 -1
- package/build/lib/web/production/components/FileUpload/FileUpload.web.js +0 -1
- package/build/lib/web/production/components/FileUpload/FileUpload.web.js.map +1 -1
- package/build/lib/web/production/components/index.js +2 -0
- package/build/lib/web/production/components/index.js.map +1 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js +2 -0
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/types/components/index.d.ts +1054 -960
- package/build/types/components/index.native.d.ts +1057 -963
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import '../Divider/index.js';
|
|
5
5
|
import '../Box/BaseBox/index.js';
|
|
@@ -31,39 +31,78 @@ import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/a
|
|
|
31
31
|
|
|
32
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
33
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
34
|
-
var
|
|
34
|
+
var commonCenterBoxProps = {
|
|
35
35
|
display: 'flex',
|
|
36
36
|
alignItems: 'center',
|
|
37
|
-
justifyContent: 'center'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
justifyContent: 'center'
|
|
38
|
+
};
|
|
39
|
+
var centerBoxProps = {
|
|
40
|
+
large: _objectSpread(_objectSpread({}, commonCenterBoxProps), {}, {
|
|
41
|
+
// We want to align title, icon, titleSuffix, trailing, closeButton to baseline
|
|
42
|
+
// But we also want to keep them center aligned to each other
|
|
43
|
+
// So we add a virtual Box around these slots with 28px and center align them to that box
|
|
44
|
+
// We have done similar thing in figma as well (which is where this 28px comes from)
|
|
45
|
+
height: '28px'
|
|
46
|
+
}),
|
|
47
|
+
medium: _objectSpread(_objectSpread({}, commonCenterBoxProps), {}, {
|
|
48
|
+
height: '20px'
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
var sizeTokensMapping = {
|
|
52
|
+
large: {
|
|
53
|
+
title: 'large'
|
|
54
|
+
},
|
|
55
|
+
medium: {
|
|
56
|
+
title: 'medium'
|
|
57
|
+
}
|
|
43
58
|
};
|
|
44
59
|
|
|
45
60
|
// prop restriction map for corresponding sub components
|
|
46
61
|
var propRestrictionMap = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
large: {
|
|
63
|
+
Button: {
|
|
64
|
+
size: 'xsmall',
|
|
65
|
+
variant: 'tertiary'
|
|
66
|
+
},
|
|
67
|
+
Badge: {
|
|
68
|
+
size: 'medium'
|
|
69
|
+
},
|
|
70
|
+
Link: {
|
|
71
|
+
size: 'medium'
|
|
72
|
+
},
|
|
73
|
+
Text: {
|
|
74
|
+
size: 'medium',
|
|
75
|
+
variant: 'body'
|
|
76
|
+
},
|
|
77
|
+
Amount: {
|
|
78
|
+
type: 'body',
|
|
79
|
+
size: 'medium'
|
|
80
|
+
}
|
|
60
81
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
medium: {
|
|
83
|
+
Button: {
|
|
84
|
+
size: 'xsmall',
|
|
85
|
+
variant: 'tertiary'
|
|
86
|
+
},
|
|
87
|
+
Badge: {
|
|
88
|
+
size: 'small'
|
|
89
|
+
},
|
|
90
|
+
Link: {
|
|
91
|
+
size: 'small'
|
|
92
|
+
},
|
|
93
|
+
Text: {
|
|
94
|
+
size: 'small',
|
|
95
|
+
variant: 'body'
|
|
96
|
+
},
|
|
97
|
+
Amount: {
|
|
98
|
+
type: 'body',
|
|
99
|
+
size: 'small'
|
|
100
|
+
}
|
|
64
101
|
}
|
|
65
102
|
};
|
|
66
|
-
var useTrailingRestriction = function useTrailingRestriction(
|
|
103
|
+
var useTrailingRestriction = function useTrailingRestriction(_ref) {
|
|
104
|
+
var trailing = _ref.trailing,
|
|
105
|
+
size = _ref.size;
|
|
67
106
|
var _React$useState = React__default.useState(null),
|
|
68
107
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
69
108
|
validatedTrailingComponent = _React$useState2[0],
|
|
@@ -73,8 +112,8 @@ var useTrailingRestriction = function useTrailingRestriction(trailing) {
|
|
|
73
112
|
React__default.useEffect(function () {
|
|
74
113
|
if ( /*#__PURE__*/React__default.isValidElement(trailing)) {
|
|
75
114
|
var trailingComponentType = getComponentId(trailing);
|
|
76
|
-
var restrictedProps = propRestrictionMap[trailingComponentType];
|
|
77
|
-
var allowedComponents = Object.keys(propRestrictionMap);
|
|
115
|
+
var restrictedProps = propRestrictionMap[size][trailingComponentType];
|
|
116
|
+
var allowedComponents = Object.keys(propRestrictionMap[size]);
|
|
78
117
|
if (false) {
|
|
79
118
|
if (!restrictedProps) {
|
|
80
119
|
throwBladeError({
|
|
@@ -83,7 +122,7 @@ var useTrailingRestriction = function useTrailingRestriction(trailing) {
|
|
|
83
122
|
});
|
|
84
123
|
}
|
|
85
124
|
}
|
|
86
|
-
var restrictedPropKeys = Object.keys(propRestrictionMap[trailingComponentType]);
|
|
125
|
+
var restrictedPropKeys = Object.keys(propRestrictionMap[size][trailingComponentType]);
|
|
87
126
|
for (var _i = 0, _restrictedPropKeys = restrictedPropKeys; _i < _restrictedPropKeys.length; _i++) {
|
|
88
127
|
var _trailing$props;
|
|
89
128
|
var prop = _restrictedPropKeys[_i];
|
|
@@ -97,37 +136,46 @@ var useTrailingRestriction = function useTrailingRestriction(trailing) {
|
|
|
97
136
|
}
|
|
98
137
|
setValidatedTrailingComponent( /*#__PURE__*/React__default.cloneElement(trailing, restrictedProps));
|
|
99
138
|
}
|
|
100
|
-
}, [trailing]);
|
|
139
|
+
}, [trailing, size]);
|
|
101
140
|
return validatedTrailingComponent;
|
|
102
141
|
};
|
|
103
|
-
var _BaseHeader = function _BaseHeader(
|
|
104
|
-
var title =
|
|
105
|
-
subtitle =
|
|
106
|
-
leading =
|
|
107
|
-
titleSuffix =
|
|
108
|
-
trailing =
|
|
109
|
-
|
|
110
|
-
showDivider =
|
|
111
|
-
|
|
112
|
-
showBackButton =
|
|
113
|
-
|
|
114
|
-
showCloseButton =
|
|
115
|
-
onBackButtonClick =
|
|
116
|
-
onCloseButtonClick =
|
|
117
|
-
closeButtonRef =
|
|
118
|
-
backButtonRef =
|
|
119
|
-
testID =
|
|
120
|
-
onClickCapture =
|
|
121
|
-
onKeyDown =
|
|
122
|
-
onKeyUp =
|
|
123
|
-
onLostPointerCapture =
|
|
124
|
-
onPointerCancel =
|
|
125
|
-
onPointerDown =
|
|
126
|
-
onPointerMove =
|
|
127
|
-
onPointerUp =
|
|
128
|
-
metaComponentName =
|
|
129
|
-
|
|
130
|
-
|
|
142
|
+
var _BaseHeader = function _BaseHeader(_ref2) {
|
|
143
|
+
var title = _ref2.title,
|
|
144
|
+
subtitle = _ref2.subtitle,
|
|
145
|
+
leading = _ref2.leading,
|
|
146
|
+
titleSuffix = _ref2.titleSuffix,
|
|
147
|
+
trailing = _ref2.trailing,
|
|
148
|
+
_ref2$showDivider = _ref2.showDivider,
|
|
149
|
+
showDivider = _ref2$showDivider === void 0 ? true : _ref2$showDivider,
|
|
150
|
+
_ref2$showBackButton = _ref2.showBackButton,
|
|
151
|
+
showBackButton = _ref2$showBackButton === void 0 ? false : _ref2$showBackButton,
|
|
152
|
+
_ref2$showCloseButton = _ref2.showCloseButton,
|
|
153
|
+
showCloseButton = _ref2$showCloseButton === void 0 ? true : _ref2$showCloseButton,
|
|
154
|
+
onBackButtonClick = _ref2.onBackButtonClick,
|
|
155
|
+
onCloseButtonClick = _ref2.onCloseButtonClick,
|
|
156
|
+
closeButtonRef = _ref2.closeButtonRef,
|
|
157
|
+
backButtonRef = _ref2.backButtonRef,
|
|
158
|
+
testID = _ref2.testID,
|
|
159
|
+
onClickCapture = _ref2.onClickCapture,
|
|
160
|
+
onKeyDown = _ref2.onKeyDown,
|
|
161
|
+
onKeyUp = _ref2.onKeyUp,
|
|
162
|
+
onLostPointerCapture = _ref2.onLostPointerCapture,
|
|
163
|
+
onPointerCancel = _ref2.onPointerCancel,
|
|
164
|
+
onPointerDown = _ref2.onPointerDown,
|
|
165
|
+
onPointerMove = _ref2.onPointerMove,
|
|
166
|
+
onPointerUp = _ref2.onPointerUp,
|
|
167
|
+
metaComponentName = _ref2.metaComponentName,
|
|
168
|
+
paddingX = _ref2.paddingX,
|
|
169
|
+
marginY = _ref2.marginY,
|
|
170
|
+
_ref2$size = _ref2.size,
|
|
171
|
+
size$1 = _ref2$size === void 0 ? 'large' : _ref2$size,
|
|
172
|
+
isDisabled = _ref2.isDisabled,
|
|
173
|
+
children = _ref2.children,
|
|
174
|
+
trailingInteractionElement = _ref2.trailingInteractionElement;
|
|
175
|
+
var validatedTrailingComponent = useTrailingRestriction({
|
|
176
|
+
trailing: trailing,
|
|
177
|
+
size: size$1
|
|
178
|
+
});
|
|
131
179
|
var shouldWrapTitle = titleSuffix && trailing && showBackButton && showCloseButton;
|
|
132
180
|
var webOnlyEventHandlers = isReactNative() ? {} : {
|
|
133
181
|
onClickCapture: onClickCapture,
|
|
@@ -144,11 +192,11 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
144
192
|
testID: testID
|
|
145
193
|
})), {}, {
|
|
146
194
|
children: [/*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread({
|
|
147
|
-
marginY: {
|
|
195
|
+
marginY: marginY !== null && marginY !== void 0 ? marginY : {
|
|
148
196
|
base: 'spacing.5',
|
|
149
197
|
m: 'spacing.6'
|
|
150
198
|
},
|
|
151
|
-
paddingX: {
|
|
199
|
+
paddingX: paddingX !== null && paddingX !== void 0 ? paddingX : {
|
|
152
200
|
base: 'spacing.5',
|
|
153
201
|
m: 'spacing.6'
|
|
154
202
|
},
|
|
@@ -161,7 +209,7 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
161
209
|
children: [showBackButton ? /*#__PURE__*/jsx(BaseBox, {
|
|
162
210
|
overflow: "visible",
|
|
163
211
|
marginRight: "spacing.5",
|
|
164
|
-
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps), {}, {
|
|
212
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
165
213
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
166
214
|
ref: backButtonRef,
|
|
167
215
|
size: "large",
|
|
@@ -181,7 +229,7 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
181
229
|
alignItems: "flex-start",
|
|
182
230
|
children: [leading ? /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread({
|
|
183
231
|
marginRight: "spacing.3"
|
|
184
|
-
}, centerBoxProps), {}, {
|
|
232
|
+
}, centerBoxProps[size$1]), {}, {
|
|
185
233
|
children: leading
|
|
186
234
|
})) : null, /*#__PURE__*/jsxs(BaseBox, {
|
|
187
235
|
flex: "auto",
|
|
@@ -195,14 +243,14 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
195
243
|
display: "flex",
|
|
196
244
|
flexDirection: "row",
|
|
197
245
|
children: [title ? /*#__PURE__*/jsx(Text, {
|
|
198
|
-
size:
|
|
246
|
+
size: sizeTokensMapping[size$1].title,
|
|
199
247
|
marginTop: makeSize(size['1']),
|
|
200
248
|
weight: "semibold",
|
|
201
|
-
color:
|
|
249
|
+
color: isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal',
|
|
202
250
|
children: title
|
|
203
251
|
}) : null, titleSuffix && /*#__PURE__*/jsx(BaseBox, {
|
|
204
252
|
marginLeft: "spacing.3",
|
|
205
|
-
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps), {}, {
|
|
253
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
206
254
|
children: titleSuffix
|
|
207
255
|
}))
|
|
208
256
|
})]
|
|
@@ -210,16 +258,16 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
210
258
|
variant: "body",
|
|
211
259
|
size: "small",
|
|
212
260
|
weight: "regular",
|
|
213
|
-
color:
|
|
261
|
+
color: isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted',
|
|
214
262
|
children: subtitle
|
|
215
263
|
}) : null]
|
|
216
264
|
})]
|
|
217
265
|
}), validatedTrailingComponent ? /*#__PURE__*/jsx(BaseBox, {
|
|
218
266
|
marginRight: "spacing.5",
|
|
219
|
-
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps), {}, {
|
|
267
|
+
children: /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
220
268
|
children: validatedTrailingComponent
|
|
221
269
|
}))
|
|
222
|
-
}) : null, showCloseButton ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps), {}, {
|
|
270
|
+
}) : null, showCloseButton ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
223
271
|
children: /*#__PURE__*/jsx(IconButton, {
|
|
224
272
|
ref: closeButtonRef,
|
|
225
273
|
size: "large",
|
|
@@ -229,8 +277,23 @@ var _BaseHeader = function _BaseHeader(_ref) {
|
|
|
229
277
|
return onCloseButtonClick === null || onCloseButtonClick === void 0 ? void 0 : onCloseButtonClick();
|
|
230
278
|
}
|
|
231
279
|
})
|
|
280
|
+
})) : null, trailingInteractionElement && !children ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({}, centerBoxProps[size$1]), {}, {
|
|
281
|
+
children: trailingInteractionElement
|
|
282
|
+
})) : null]
|
|
283
|
+
}), /*#__PURE__*/jsxs(BaseBox, {
|
|
284
|
+
display: "flex",
|
|
285
|
+
width: "100%",
|
|
286
|
+
flexDirection: "row",
|
|
287
|
+
alignItems: "center",
|
|
288
|
+
justifyContent: "space-between",
|
|
289
|
+
children: [/*#__PURE__*/jsx(Box, {
|
|
290
|
+
children: children
|
|
291
|
+
}), trailingInteractionElement && children ? /*#__PURE__*/jsx(Box, _objectSpread(_objectSpread({
|
|
292
|
+
alignSelf: "flex-start"
|
|
293
|
+
}, centerBoxProps[size$1]), {}, {
|
|
294
|
+
children: trailingInteractionElement
|
|
232
295
|
})) : null]
|
|
233
|
-
})
|
|
296
|
+
})]
|
|
234
297
|
})), showDivider ? /*#__PURE__*/jsx(Divider, {}) : null]
|
|
235
298
|
}));
|
|
236
299
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseHeader.js","sources":["../../../../../../src/components/BaseHeaderFooter/BaseHeader.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\nimport type { ReactDOMAttributes } from '@use-gesture/react/dist/declarations/src/types';\nimport { Divider } from '~components/Divider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { IconButton } from '~components/Button/IconButton';\nimport { ChevronLeftIcon, CloseIcon } from '~components/Icons';\nimport type { TestID } from '~utils/types';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { isReactNative, makeSize } from '~utils';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport { logger, throwBladeError } from '~utils/logger';\nimport { size } from '~tokens/global';\n\ntype BaseHeaderProps = {\n title?: string;\n subtitle?: string;\n /**\n * Leading part of the header placed at the left most side of the header\n */\n leading?: React.ReactNode;\n /**\n * Trailing part of the header placed at the right most side of the header\n */\n trailing?: React.ReactNode;\n /**\n * Placed adjacent to the title text\n */\n titleSuffix?: React.ReactNode;\n /**\n * @default true\n */\n showDivider?: boolean;\n /**\n * @default false\n */\n showBackButton?: boolean;\n /**\n * @default true\n */\n showCloseButton?: boolean;\n onCloseButtonClick?: () => void;\n onBackButtonClick?: () => void;\n closeButtonRef?: React.MutableRefObject<any>;\n backButtonRef?: React.MutableRefObject<any>;\n metaComponentName?: string;\n /**\n * inner child of BottomSheetHeader. Meant to be used for AutoComplete only\n */\n children?: React.ReactElement;\n} & Pick<\n ReactDOMAttributes,\n | 'onClickCapture'\n | 'onKeyDown'\n | 'onKeyUp'\n | 'onLostPointerCapture'\n | 'onPointerCancel'\n | 'onPointerDown'\n | 'onPointerMove'\n | 'onPointerUp'\n> &\n TestID;\n\ntype TrailingComponents = 'Button' | 'Badge' | 'Link' | 'Text' | 'Amount';\n\nconst centerBoxProps: BoxProps = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n // We want to align title, icon, titleSuffix, trailing, closeButton to baseline\n // But we also want to keep them center aligned to each other\n // So we add a virtual Box around these slots with 28px and center align them to that box\n // We have done similar thing in figma as well (which is where this 28px comes from)\n height: '28px',\n};\n\n// prop restriction map for corresponding sub components\nconst propRestrictionMap = {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n} as const;\n\nconst useTrailingRestriction = (trailing: React.ReactNode): React.ReactNode => {\n const [\n validatedTrailingComponent,\n setValidatedTrailingComponent,\n ] = React.useState<React.ReactElement | null>(null);\n\n // validate and restrict sub component props in trailing prop\n React.useEffect(() => {\n if (React.isValidElement(trailing)) {\n const trailingComponentType = getComponentId(trailing) as TrailingComponents;\n const restrictedProps = propRestrictionMap[trailingComponentType];\n const allowedComponents = Object.keys(propRestrictionMap);\n if (__DEV__) {\n if (!restrictedProps) {\n throwBladeError({\n message: `Only one of \\`${allowedComponents.join(\n ', ',\n )}\\` component is accepted as trailing`,\n moduleName: 'Header',\n });\n }\n }\n\n const restrictedPropKeys = Object.keys(propRestrictionMap[trailingComponentType]);\n for (const prop of restrictedPropKeys) {\n if (trailing?.props?.hasOwnProperty(prop)) {\n logger({\n message: `Do not pass \"${prop}\" to \"${trailingComponentType}\" while inside Header trailing, because we override it.`,\n moduleName: 'Header',\n type: 'warn',\n });\n }\n }\n setValidatedTrailingComponent(\n React.cloneElement(trailing as React.ReactElement, restrictedProps),\n );\n }\n }, [trailing]);\n\n return validatedTrailingComponent;\n};\n\nconst _BaseHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n showDivider = true,\n showBackButton = false,\n showCloseButton = true,\n onBackButtonClick,\n onCloseButtonClick,\n closeButtonRef,\n backButtonRef,\n testID,\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n metaComponentName,\n children,\n}: BaseHeaderProps): React.ReactElement => {\n const validatedTrailingComponent = useTrailingRestriction(trailing);\n const shouldWrapTitle = titleSuffix && trailing && showBackButton && showCloseButton;\n\n const webOnlyEventHandlers: Record<string, any> = isReactNative()\n ? {}\n : {\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n };\n\n return (\n <BaseBox {...metaAttribute({ name: metaComponentName, testID })}>\n <BaseBox\n marginY={{ base: 'spacing.5', m: 'spacing.6' }}\n paddingX={{ base: 'spacing.5', m: 'spacing.6' }}\n touchAction=\"none\"\n {...webOnlyEventHandlers}\n >\n <BaseBox display=\"flex\" flexDirection=\"row\" userSelect=\"none\">\n {showBackButton ? (\n <BaseBox overflow=\"visible\" marginRight=\"spacing.5\">\n <Box {...centerBoxProps}>\n <IconButton\n ref={backButtonRef}\n size=\"large\"\n icon={ChevronLeftIcon}\n onClick={() => onBackButtonClick?.()}\n accessibilityLabel=\"Back\"\n />\n </Box>\n </BaseBox>\n ) : null}\n <BaseBox\n paddingRight=\"spacing.5\"\n marginRight=\"auto\"\n flex=\"auto\"\n display=\"flex\"\n flexDirection=\"row\"\n alignItems=\"flex-start\"\n >\n {leading ? (\n <BaseBox marginRight=\"spacing.3\" {...centerBoxProps}>\n {leading}\n </BaseBox>\n ) : null}\n <BaseBox flex=\"auto\">\n <BaseBox\n // Explicitly setting maxWidth in React Native because text is not being wrapped properly when multiple fix width components are rendered in header\n // In web, flex containers seem to work a expected\n // @todo: resolve this if we figure out some better solution later\n maxWidth={isReactNative() && shouldWrapTitle ? '100px' : undefined}\n flexShrink={0}\n display=\"flex\"\n flexDirection=\"row\"\n >\n {title ? (\n <Text\n size=\"large\"\n marginTop={makeSize(size['1'])}\n weight=\"semibold\"\n color=\"surface.text.gray.normal\"\n >\n {title}\n </Text>\n ) : null}\n {titleSuffix && (\n <BaseBox marginLeft=\"spacing.3\">\n <Box {...centerBoxProps}>{titleSuffix}</Box>\n </BaseBox>\n )}\n </BaseBox>\n {subtitle ? (\n <Text variant=\"body\" size=\"small\" weight=\"regular\" color=\"surface.text.gray.muted\">\n {subtitle}\n </Text>\n ) : null}\n </BaseBox>\n </BaseBox>\n {validatedTrailingComponent ? (\n <BaseBox marginRight=\"spacing.5\">\n <Box {...centerBoxProps}>{validatedTrailingComponent}</Box>\n </BaseBox>\n ) : null}\n {showCloseButton ? (\n <Box {...centerBoxProps}>\n <IconButton\n ref={closeButtonRef}\n size=\"large\"\n icon={CloseIcon}\n accessibilityLabel=\"Close\"\n onClick={() => onCloseButtonClick?.()}\n />\n </Box>\n ) : null}\n </BaseBox>\n {children}\n </BaseBox>\n {showDivider ? <Divider /> : null}\n </BaseBox>\n );\n};\n\nconst BaseHeader = assignWithoutSideEffects(_BaseHeader, {\n componentId: 'BaseHeader',\n});\n\nexport type { BaseHeaderProps };\nexport { BaseHeader };\n"],"names":["centerBoxProps","display","alignItems","justifyContent","height","propRestrictionMap","Button","size","variant","Badge","Link","Text","Amount","type","useTrailingRestriction","trailing","_React$useState","React","useState","_React$useState2","_slicedToArray","validatedTrailingComponent","setValidatedTrailingComponent","useEffect","isValidElement","trailingComponentType","getComponentId","restrictedProps","allowedComponents","Object","keys","throwBladeError","message","concat","join","moduleName","restrictedPropKeys","_i","_restrictedPropKeys","length","_trailing$props","prop","props","hasOwnProperty","logger","cloneElement","_BaseHeader","_ref","title","subtitle","leading","titleSuffix","_ref$showDivider","showDivider","_ref$showBackButton","showBackButton","_ref$showCloseButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","children","shouldWrapTitle","webOnlyEventHandlers","isReactNative","_jsxs","BaseBox","_objectSpread","metaAttribute","name","marginY","base","m","paddingX","touchAction","flexDirection","userSelect","_jsx","overflow","marginRight","Box","IconButton","ref","icon","ChevronLeftIcon","onClick","accessibilityLabel","paddingRight","flex","maxWidth","undefined","flexShrink","marginTop","makeSize","weight","color","marginLeft","CloseIcon","Divider","BaseHeader","assignWithoutSideEffects","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,IAAMA,cAAwB,GAAG;AAC/BC,EAAAA,OAAO,EAAE,MAAM;AACfC,EAAAA,UAAU,EAAE,QAAQ;AACpBC,EAAAA,cAAc,EAAE,QAAQ;AACxB;AACA;AACA;AACA;AACAC,EAAAA,MAAM,EAAE,MAAA;AACV,CAAC,CAAA;;AAED;AACA,IAAMC,kBAAkB,GAAG;AACzBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,IAAI,EAAE,QAAQ;AACdC,IAAAA,OAAO,EAAE,UAAA;GACV;AACDC,EAAAA,KAAK,EAAE;AACLF,IAAAA,IAAI,EAAE,QAAA;GACP;AACDG,EAAAA,IAAI,EAAE;AACJH,IAAAA,IAAI,EAAE,QAAA;GACP;AACDI,EAAAA,IAAI,EAAE;AACJJ,IAAAA,IAAI,EAAE,QAAQ;AACdC,IAAAA,OAAO,EAAE,MAAA;GACV;AACDI,EAAAA,MAAM,EAAE;AACNC,IAAAA,IAAI,EAAE,MAAM;AACZN,IAAAA,IAAI,EAAE,QAAA;AACR,GAAA;AACF,CAAU,CAAA;AAEV,IAAMO,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAIC,QAAyB,EAAsB;AAC7E,EAAA,IAAAC,eAAA,GAGIC,cAAK,CAACC,QAAQ,CAA4B,IAAI,CAAC;IAAAC,gBAAA,GAAAC,cAAA,CAAAJ,eAAA,EAAA,CAAA,CAAA;AAFjDK,IAAAA,0BAA0B,GAAAF,gBAAA,CAAA,CAAA,CAAA;AAC1BG,IAAAA,6BAA6B,GAAAH,gBAAA,CAAA,CAAA,CAAA,CAAA;;AAG/B;EACAF,cAAK,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,EAAE;AACvDkE,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseHeader.js","sources":["../../../../../../src/components/BaseHeaderFooter/BaseHeader.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\nimport type { ReactDOMAttributes } from '@use-gesture/react/dist/declarations/src/types';\nimport { Divider } from '~components/Divider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { IconButton } from '~components/Button/IconButton';\nimport { ChevronLeftIcon, CloseIcon } from '~components/Icons';\nimport type { TestID } from '~utils/types';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId } from '~utils/isValidAllowedChildren';\nimport { isReactNative, makeSize } from '~utils';\nimport { metaAttribute } from '~utils/metaAttribute';\nimport { logger, throwBladeError } from '~utils/logger';\nimport { size as sizeToken } from '~tokens/global';\n\ntype BaseHeaderProps = {\n title?: string;\n subtitle?: string;\n /**\n * Leading part of the header placed at the left most side of the header\n */\n leading?: React.ReactNode;\n /**\n * Trailing part of the header placed at the right most side of the header\n */\n trailing?: React.ReactNode;\n /**\n * Placed adjacent to the title text\n */\n titleSuffix?: React.ReactNode;\n /**\n * @default true\n */\n showDivider?: boolean;\n /**\n * @default false\n */\n showBackButton?: boolean;\n\n /**\n * Slot for rendering any trailing interaction element into BaseHeader.\n *\n * E.g. Used in accordion to render CollapsibleChevronIcon\n */\n trailingInteractionElement?: React.ReactNode;\n\n /**\n * Decides size of the Header\n */\n size?: 'large' | 'medium';\n /**\n * @default true\n */\n showCloseButton?: boolean;\n\n /**\n * Disabled state of BaseHeader\n *\n * @default false\n */\n isDisabled?: boolean;\n\n paddingX?: BoxProps['paddingX'];\n marginY?: BoxProps['marginY'];\n onCloseButtonClick?: () => void;\n onBackButtonClick?: () => void;\n closeButtonRef?: React.MutableRefObject<any>;\n backButtonRef?: React.MutableRefObject<any>;\n metaComponentName?: string;\n /**\n * inner child of BottomSheetHeader. Meant to be used for AutoComplete only\n */\n children?: React.ReactElement | React.ReactElement[];\n} & Pick<\n ReactDOMAttributes,\n | 'onClickCapture'\n | 'onKeyDown'\n | 'onKeyUp'\n | 'onLostPointerCapture'\n | 'onPointerCancel'\n | 'onPointerDown'\n | 'onPointerMove'\n | 'onPointerUp'\n> &\n TestID;\n\ntype TrailingComponents = 'Button' | 'Badge' | 'Link' | 'Text' | 'Amount';\n\nconst commonCenterBoxProps: BoxProps = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n};\n\nconst centerBoxProps: { large: BoxProps; medium: BoxProps } = {\n large: {\n ...commonCenterBoxProps,\n // We want to align title, icon, titleSuffix, trailing, closeButton to baseline\n // But we also want to keep them center aligned to each other\n // So we add a virtual Box around these slots with 28px and center align them to that box\n // We have done similar thing in figma as well (which is where this 28px comes from)\n height: '28px',\n },\n medium: {\n ...commonCenterBoxProps,\n height: '20px',\n },\n};\n\nconst sizeTokensMapping = {\n large: {\n title: 'large',\n },\n medium: {\n title: 'medium',\n },\n} as const;\n\n// prop restriction map for corresponding sub components\nconst propRestrictionMap = {\n large: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n Badge: {\n size: 'medium',\n },\n Link: {\n size: 'medium',\n },\n Text: {\n size: 'medium',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'medium',\n },\n },\n medium: {\n Button: {\n size: 'xsmall',\n variant: 'tertiary',\n },\n Badge: {\n size: 'small',\n },\n Link: {\n size: 'small',\n },\n Text: {\n size: 'small',\n variant: 'body',\n },\n Amount: {\n type: 'body',\n size: 'small',\n },\n },\n} as const;\n\nconst useTrailingRestriction = ({\n trailing,\n size,\n}: {\n size: NonNullable<BaseHeaderProps['size']>;\n trailing: BaseHeaderProps['trailing'];\n}): React.ReactNode => {\n const [\n validatedTrailingComponent,\n setValidatedTrailingComponent,\n ] = React.useState<React.ReactElement | null>(null);\n\n // validate and restrict sub component props in trailing prop\n React.useEffect(() => {\n if (React.isValidElement(trailing)) {\n const trailingComponentType = getComponentId(trailing) as TrailingComponents;\n const restrictedProps = propRestrictionMap[size][trailingComponentType];\n const allowedComponents = Object.keys(propRestrictionMap[size]);\n if (__DEV__) {\n if (!restrictedProps) {\n throwBladeError({\n message: `Only one of \\`${allowedComponents.join(\n ', ',\n )}\\` component is accepted as trailing`,\n moduleName: 'Header',\n });\n }\n }\n\n const restrictedPropKeys = Object.keys(propRestrictionMap[size][trailingComponentType]);\n for (const prop of restrictedPropKeys) {\n if (trailing?.props?.hasOwnProperty(prop)) {\n logger({\n message: `Do not pass \"${prop}\" to \"${trailingComponentType}\" while inside Header trailing, because we override it.`,\n moduleName: 'Header',\n type: 'warn',\n });\n }\n }\n setValidatedTrailingComponent(\n React.cloneElement(trailing as React.ReactElement, restrictedProps),\n );\n }\n }, [trailing, size]);\n\n return validatedTrailingComponent;\n};\n\nconst _BaseHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n showDivider = true,\n showBackButton = false,\n showCloseButton = true,\n onBackButtonClick,\n onCloseButtonClick,\n closeButtonRef,\n backButtonRef,\n testID,\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n metaComponentName,\n paddingX,\n marginY,\n size = 'large',\n isDisabled,\n children,\n trailingInteractionElement,\n}: BaseHeaderProps): React.ReactElement => {\n const validatedTrailingComponent = useTrailingRestriction({ trailing, size });\n const shouldWrapTitle = titleSuffix && trailing && showBackButton && showCloseButton;\n\n const webOnlyEventHandlers: Record<string, any> = isReactNative()\n ? {}\n : {\n onClickCapture,\n onKeyDown,\n onKeyUp,\n onLostPointerCapture,\n onPointerCancel,\n onPointerDown,\n onPointerMove,\n onPointerUp,\n };\n\n return (\n <BaseBox {...metaAttribute({ name: metaComponentName, testID })}>\n <BaseBox\n marginY={marginY ?? { base: 'spacing.5', m: 'spacing.6' }}\n paddingX={paddingX ?? { base: 'spacing.5', m: 'spacing.6' }}\n touchAction=\"none\"\n {...webOnlyEventHandlers}\n >\n <BaseBox display=\"flex\" flexDirection=\"row\" userSelect=\"none\">\n {showBackButton ? (\n <BaseBox overflow=\"visible\" marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>\n <IconButton\n ref={backButtonRef}\n size=\"large\"\n icon={ChevronLeftIcon}\n onClick={() => onBackButtonClick?.()}\n accessibilityLabel=\"Back\"\n />\n </Box>\n </BaseBox>\n ) : null}\n <BaseBox\n paddingRight=\"spacing.5\"\n marginRight=\"auto\"\n flex=\"auto\"\n display=\"flex\"\n flexDirection=\"row\"\n alignItems=\"flex-start\"\n >\n {leading ? (\n <BaseBox marginRight=\"spacing.3\" {...centerBoxProps[size]}>\n {leading}\n </BaseBox>\n ) : null}\n <BaseBox flex=\"auto\">\n <BaseBox\n // Explicitly setting maxWidth in React Native because text is not being wrapped properly when multiple fix width components are rendered in header\n // In web, flex containers seem to work a expected\n // @todo: resolve this if we figure out some better solution later\n maxWidth={isReactNative() && shouldWrapTitle ? '100px' : undefined}\n flexShrink={0}\n display=\"flex\"\n flexDirection=\"row\"\n >\n {title ? (\n <Text\n size={sizeTokensMapping[size].title}\n marginTop={makeSize(sizeToken['1'])}\n weight=\"semibold\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.normal'}\n >\n {title}\n </Text>\n ) : null}\n {titleSuffix && (\n <BaseBox marginLeft=\"spacing.3\">\n <Box {...centerBoxProps[size]}>{titleSuffix}</Box>\n </BaseBox>\n )}\n </BaseBox>\n {subtitle ? (\n <Text\n variant=\"body\"\n size=\"small\"\n weight=\"regular\"\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.muted'}\n >\n {subtitle}\n </Text>\n ) : null}\n </BaseBox>\n </BaseBox>\n {validatedTrailingComponent ? (\n <BaseBox marginRight=\"spacing.5\">\n <Box {...centerBoxProps[size]}>{validatedTrailingComponent}</Box>\n </BaseBox>\n ) : null}\n {showCloseButton ? (\n <Box {...centerBoxProps[size]}>\n <IconButton\n ref={closeButtonRef}\n size=\"large\"\n icon={CloseIcon}\n accessibilityLabel=\"Close\"\n onClick={() => onCloseButtonClick?.()}\n />\n </Box>\n ) : null}\n {trailingInteractionElement && !children ? (\n <Box {...centerBoxProps[size]}>{trailingInteractionElement}</Box>\n ) : null}\n </BaseBox>\n <BaseBox\n display=\"flex\"\n width=\"100%\"\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n >\n <Box>{children}</Box>\n {trailingInteractionElement && children ? (\n <Box alignSelf=\"flex-start\" {...centerBoxProps[size]}>\n {trailingInteractionElement}\n </Box>\n ) : null}\n </BaseBox>\n </BaseBox>\n {showDivider ? <Divider /> : null}\n </BaseBox>\n );\n};\n\nconst BaseHeader = assignWithoutSideEffects(_BaseHeader, {\n componentId: 'BaseHeader',\n});\n\nexport type { BaseHeaderProps };\nexport { BaseHeader };\n"],"names":["commonCenterBoxProps","display","alignItems","justifyContent","centerBoxProps","large","_objectSpread","height","medium","sizeTokensMapping","title","propRestrictionMap","Button","size","variant","Badge","Link","Text","Amount","type","useTrailingRestriction","_ref","trailing","_React$useState","React","useState","_React$useState2","_slicedToArray","validatedTrailingComponent","setValidatedTrailingComponent","useEffect","isValidElement","trailingComponentType","getComponentId","restrictedProps","allowedComponents","Object","keys","throwBladeError","message","concat","join","moduleName","restrictedPropKeys","_i","_restrictedPropKeys","length","_trailing$props","prop","props","hasOwnProperty","logger","cloneElement","_BaseHeader","_ref2","subtitle","leading","titleSuffix","_ref2$showDivider","showDivider","_ref2$showBackButton","showBackButton","_ref2$showCloseButton","showCloseButton","onBackButtonClick","onCloseButtonClick","closeButtonRef","backButtonRef","testID","onClickCapture","onKeyDown","onKeyUp","onLostPointerCapture","onPointerCancel","onPointerDown","onPointerMove","onPointerUp","metaComponentName","paddingX","marginY","_ref2$size","isDisabled","children","trailingInteractionElement","shouldWrapTitle","webOnlyEventHandlers","isReactNative","_jsxs","BaseBox","metaAttribute","name","base","m","touchAction","flexDirection","userSelect","_jsx","overflow","marginRight","Box","IconButton","ref","icon","ChevronLeftIcon","onClick","accessibilityLabel","paddingRight","flex","maxWidth","undefined","flexShrink","marginTop","makeSize","sizeToken","weight","color","marginLeft","CloseIcon","width","alignSelf","Divider","BaseHeader","assignWithoutSideEffects","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAMA,oBAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE,MAAM;AACfC,EAAAA,UAAU,EAAE,QAAQ;AACpBC,EAAAA,cAAc,EAAE,QAAA;AAClB,CAAC,CAAA;AAED,IAAMC,cAAqD,GAAG;AAC5DC,EAAAA,KAAK,EAAAC,aAAA,CAAAA,aAAA,KACAN,oBAAoB,CAAA,EAAA,EAAA,EAAA;AACvB;AACA;AACA;AACA;AACAO,IAAAA,MAAM,EAAE,MAAA;GACT,CAAA;AACDC,EAAAA,MAAM,EAAAF,aAAA,CAAAA,aAAA,KACDN,oBAAoB,CAAA,EAAA,EAAA,EAAA;AACvBO,IAAAA,MAAM,EAAE,MAAA;AAAM,GAAA,CAAA;AAElB,CAAC,CAAA;AAED,IAAME,iBAAiB,GAAG;AACxBJ,EAAAA,KAAK,EAAE;AACLK,IAAAA,KAAK,EAAE,OAAA;GACR;AACDF,EAAAA,MAAM,EAAE;AACNE,IAAAA,KAAK,EAAE,QAAA;AACT,GAAA;AACF,CAAU,CAAA;;AAEV;AACA,IAAMC,kBAAkB,GAAG;AACzBN,EAAAA,KAAK,EAAE;AACLO,IAAAA,MAAM,EAAE;AACNC,MAAAA,IAAI,EAAE,QAAQ;AACdC,MAAAA,OAAO,EAAE,UAAA;KACV;AACDC,IAAAA,KAAK,EAAE;AACLF,MAAAA,IAAI,EAAE,QAAA;KACP;AACDG,IAAAA,IAAI,EAAE;AACJH,MAAAA,IAAI,EAAE,QAAA;KACP;AACDI,IAAAA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;KACH,CAAA,CAAC,EACTxB,WAAW,gBAAGqC,GAAA,CAACwB,OAAO,EAAA,EAAE,CAAC,GAAG,IAAI,CAAA;AAAA,GAAA,CAC1B,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAMC,UAAU,gBAAGC,wBAAwB,CAACrE,WAAW,EAAE;AACvDsE,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC;;;;"}
|
|
@@ -6,7 +6,9 @@ import { getTransitionDuration, getTransitionEasing, getOpacity, getCollapsibleB
|
|
|
6
6
|
import '../../utils/index.js';
|
|
7
7
|
import '../Box/index.js';
|
|
8
8
|
import { useDidUpdate } from '../../utils/useDidUpdate.js';
|
|
9
|
+
import '../Box/BaseBox/index.js';
|
|
9
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
|
+
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
10
12
|
import { castWebType } from '../../utils/platform/castUtils.js';
|
|
11
13
|
import { makeSize } from '../../utils/makeSize/makeSize.js';
|
|
12
14
|
import { Box } from '../Box/Box.js';
|
|
@@ -19,7 +21,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
19
21
|
*/
|
|
20
22
|
var HEIGHT_EXPANDED = 'auto';
|
|
21
23
|
var HEIGHT_COLLAPSED = '0px';
|
|
22
|
-
var StyledCollapsibleBodyContent = /*#__PURE__*/styled.
|
|
24
|
+
var StyledCollapsibleBodyContent = /*#__PURE__*/styled(BaseBox).withConfig({
|
|
23
25
|
displayName: "CollapsibleBodyContentweb__StyledCollapsibleBodyContent",
|
|
24
26
|
componentId: "sc-1oi3ngc-0"
|
|
25
27
|
})(function (props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleBodyContent.web.js","sources":["../../../../../../src/components/Collapsible/CollapsibleBodyContent.web.tsx"],"sourcesContent":["import type { ReactElement, TransitionEventHandler } from 'react';\nimport { useRef } from 'react';\nimport styled from 'styled-components';\nimport { useCollapsible } from './CollapsibleContext';\nimport type { CollapsibleBodyContentProps } from './types';\nimport {\n getCollapsibleBodyContentBoxProps,\n getOpacity,\n getTransitionDuration,\n getTransitionEasing,\n} from './commonStyles';\nimport { castWebType, makeSize } from '~utils';\nimport { Box } from '~components/Box';\nimport { useDidUpdate } from '~utils/useDidUpdate';\n\ntype StyledCollapsibleBodyContentProps = {\n defaultIsExpanded: boolean;\n isExpanded: boolean;\n};\n\n/**\n * We can't animate to and from `auto` height, these are used for imperative css transitions.\n * Overall on expanding height will change as: 0px -> Actual height -> auto\n */\nconst HEIGHT_EXPANDED = 'auto';\nconst HEIGHT_COLLAPSED = '0px';\n\nconst StyledCollapsibleBodyContent = styled
|
|
1
|
+
{"version":3,"file":"CollapsibleBodyContent.web.js","sources":["../../../../../../src/components/Collapsible/CollapsibleBodyContent.web.tsx"],"sourcesContent":["import type { ReactElement, TransitionEventHandler } from 'react';\nimport { useRef } from 'react';\nimport styled from 'styled-components';\nimport { useCollapsible } from './CollapsibleContext';\nimport type { CollapsibleBodyContentProps } from './types';\nimport {\n getCollapsibleBodyContentBoxProps,\n getOpacity,\n getTransitionDuration,\n getTransitionEasing,\n} from './commonStyles';\nimport { castWebType, makeSize } from '~utils';\nimport { Box } from '~components/Box';\nimport { useDidUpdate } from '~utils/useDidUpdate';\nimport BaseBox from '~components/Box/BaseBox';\n\ntype StyledCollapsibleBodyContentProps = {\n defaultIsExpanded: boolean;\n isExpanded: boolean;\n};\n\n/**\n * We can't animate to and from `auto` height, these are used for imperative css transitions.\n * Overall on expanding height will change as: 0px -> Actual height -> auto\n */\nconst HEIGHT_EXPANDED = 'auto';\nconst HEIGHT_COLLAPSED = '0px';\n\nconst StyledCollapsibleBodyContent = styled(BaseBox)<StyledCollapsibleBodyContentProps>((props) => {\n const { theme, defaultIsExpanded, isExpanded } = props;\n const transitionDuration = castWebType(getTransitionDuration(theme));\n const transitionTimingFunction = castWebType(getTransitionEasing(theme));\n\n return {\n transitionDuration,\n transitionTimingFunction,\n transitionProperty: 'height, opacity',\n opacity: getOpacity({ isExpanded }),\n /**\n * We need height explicitly here for initial styles because the component might be rendered on server,\n * in which case for expanded items this should be `auto` because we don't know the actual pixel value.\n *\n * This is based on `defaultIsExpanded` rather than `isExpanded` because post initial render inline styles take over.\n * Otherwise, changing `height` both here and in inline styles sometimes causes animation flickers due to styles mismatch.\n */\n height: defaultIsExpanded ? HEIGHT_EXPANDED : HEIGHT_COLLAPSED,\n display: defaultIsExpanded ? 'block' : 'none',\n overflowY: 'hidden',\n };\n});\n\nconst CollapsibleBodyContent = ({ children }: CollapsibleBodyContentProps): ReactElement => {\n const { isExpanded, defaultIsExpanded, direction } = useCollapsible();\n const collapsibleBodyContentRef = useRef<HTMLDivElement>(null);\n\n /**\n * This effect imperatively updates height to make css transitions work:\n * - for expanded items: auto height -> actual height -> 0px\n * - for collapsed items: 0px -> actual height -> auto height\n * - uses `requestAnimationFrame` to set the styles just before the next repaint\n */\n useDidUpdate(() => {\n const collapsibleBodyContentElement = collapsibleBodyContentRef.current;\n\n if (!collapsibleBodyContentElement) {\n return;\n }\n\n // In collapsed state display is set to none, change it back to block\n collapsibleBodyContentElement.style.display = 'block';\n const actualHeight = collapsibleBodyContentElement.scrollHeight;\n\n if (!isExpanded) {\n // collapse\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.height = makeSize(actualHeight);\n\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.height = makeSize(0);\n });\n });\n } else {\n // expand\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.height = makeSize(0);\n\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.height = makeSize(actualHeight);\n\n /**\n * After this we want to wait for the animation to finish\n * before setting the height back to auto\n *\n * `onTransitionEnd` takes over\n */\n });\n });\n }\n }, [isExpanded]);\n\n /**\n * When expanding, waits for the animation to finish first.\n * Then sets the height of expanded item to auto from actual height.\n */\n const onTransitionEnd: TransitionEventHandler = ({ propertyName }) => {\n const collapsibleBodyContentElement = collapsibleBodyContentRef.current;\n if (propertyName === 'height' && collapsibleBodyContentElement) {\n if (isExpanded) {\n // Body content has expanded and finished animating at this point\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.height = HEIGHT_EXPANDED;\n });\n } else {\n // Body content has collapsed\n requestAnimationFrame(() => {\n collapsibleBodyContentElement.style.display = 'none';\n });\n }\n }\n };\n\n return (\n <StyledCollapsibleBodyContent\n ref={collapsibleBodyContentRef}\n isExpanded={isExpanded}\n defaultIsExpanded={defaultIsExpanded}\n onTransitionEnd={onTransitionEnd}\n >\n <Box {...getCollapsibleBodyContentBoxProps({ direction })}>{children}</Box>\n </StyledCollapsibleBodyContent>\n );\n};\n\nexport { CollapsibleBodyContent };\n"],"names":["HEIGHT_EXPANDED","HEIGHT_COLLAPSED","StyledCollapsibleBodyContent","styled","BaseBox","withConfig","displayName","componentId","props","theme","defaultIsExpanded","isExpanded","transitionDuration","castWebType","getTransitionDuration","transitionTimingFunction","getTransitionEasing","transitionProperty","opacity","getOpacity","height","display","overflowY","CollapsibleBodyContent","_ref","children","_useCollapsible","useCollapsible","direction","collapsibleBodyContentRef","useRef","useDidUpdate","collapsibleBodyContentElement","current","style","actualHeight","scrollHeight","requestAnimationFrame","makeSize","onTransitionEnd","_ref2","propertyName","_jsx","ref","Box","_objectSpread","getCollapsibleBodyContentBoxProps"],"mappings":";;;;;;;;;;;;;;;;;AAqBA;AACA;AACA;AACA;AACA,IAAMA,eAAe,GAAG,MAAM,CAAA;AAC9B,IAAMC,gBAAgB,GAAG,KAAK,CAAA;AAE9B,IAAMC,4BAA4B,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,yDAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAoC,CAAA,CAAA,UAACC,KAAK,EAAK;AACjG,EAAA,IAAQC,KAAK,GAAoCD,KAAK,CAA9CC,KAAK;IAAEC,iBAAiB,GAAiBF,KAAK,CAAvCE,iBAAiB;IAAEC,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C9D,SAAC,CAAC,CAAA;AACJ,OAAC,MAAM;AACL;AACAqC,QAAAA,qBAAqB,CAAC,YAAM;AAC1BL,UAAAA,6BAA6B,CAACE,KAAK,CAACb,OAAO,GAAG,MAAM,CAAA;AACtD,SAAC,CAAC,CAAA;AACJ,OAAA;AACF,KAAA;GACD,CAAA;EAED,oBACEqB,GAAA,CAACxC,4BAA4B,EAAA;AAC3ByC,IAAAA,GAAG,EAAEd,yBAA0B;AAC/BlB,IAAAA,UAAU,EAAEA,UAAW;AACvBD,IAAAA,iBAAiB,EAAEA,iBAAkB;AACrC6B,IAAAA,eAAe,EAAEA,eAAgB;IAAAd,QAAA,eAEjCiB,GAAA,CAACE,GAAG,EAAAC,aAAA,CAAAA,aAAA,CAAKC,EAAAA,EAAAA,iCAAiC,CAAC;AAAElB,MAAAA,SAAS,EAATA,SAAAA;AAAU,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AAAAH,MAAAA,QAAA,EAAGA,QAAAA;KAAc,CAAA,CAAA;AAAC,GAC/C,CAAC,CAAA;AAEnC;;;;"}
|
|
@@ -37,7 +37,9 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
37
37
|
testID = _ref.testID,
|
|
38
38
|
_ref$zIndex = _ref.zIndex,
|
|
39
39
|
zIndex = _ref$zIndex === void 0 ? componentZIndices.dropdownOverlay : _ref$zIndex,
|
|
40
|
-
width = _ref.width
|
|
40
|
+
width = _ref.width,
|
|
41
|
+
_ref$defaultPlacement = _ref.defaultPlacement,
|
|
42
|
+
defaultPlacement = _ref$defaultPlacement === void 0 ? 'bottom-start' : _ref$defaultPlacement;
|
|
41
43
|
var _useDropdown = useDropdown(),
|
|
42
44
|
isOpen = _useDropdown.isOpen,
|
|
43
45
|
triggererRef = _useDropdown.triggererRef,
|
|
@@ -52,7 +54,7 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
52
54
|
open: isOpen,
|
|
53
55
|
onOpenChange: setIsOpen,
|
|
54
56
|
strategy: 'fixed',
|
|
55
|
-
placement:
|
|
57
|
+
placement: defaultPlacement,
|
|
56
58
|
elements: {
|
|
57
59
|
// Input triggers have their ref on internal input element but we want width height of overall visible input hence wrapperRef is needed
|
|
58
60
|
// We fallback to use `triggererRef` for triggers like button and link where wrapper is not needed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownOverlay.web.js","sources":["../../../../../../src/components/Dropdown/DropdownOverlay.web.tsx"],"sourcesContent":["import React from 'react';\nimport {\n autoUpdate,\n offset,\n size as sizeMiddleware,\n useFloating,\n useTransitionStyles,\n flip,\n} from '@floating-ui/react';\nimport { useDropdown } from './useDropdown';\nimport { StyledDropdownOverlay } from './StyledDropdownOverlay';\nimport type { DropdownOverlayProps } from './types';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useTheme } from '~components/BladeProvider';\n// Reading directly because its not possible to get theme object on top level to be used in keyframes\nimport { size } from '~tokens/global';\nimport { makeSize } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useBottomSheetAndDropdownGlue } from '~components/BottomSheet/BottomSheetContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { componentZIndices } from '~utils/componentZIndices';\n\nconst OVERLAY_OFFSET: number = size['8'];\nconst OVERLAY_PADDING: number = size['12']; // doesn't have to be exact. Just rough padding for floating ui to decide to show overlay on top or bottom\n\n/**\n * Overlay of dropdown\n *\n * Wrap your ActionList within this component\n */\nconst _DropdownOverlay = ({\n children,\n testID,\n zIndex = componentZIndices.dropdownOverlay,\n width,\n}: DropdownOverlayProps): React.ReactElement | null => {\n const { isOpen, triggererRef, triggererWrapperRef, dropdownTriggerer, setIsOpen } = useDropdown();\n const { theme } = useTheme();\n const bottomSheetAndDropdownGlue = useBottomSheetAndDropdownGlue();\n\n const isMenu =\n dropdownTriggerer !== dropdownComponentIds.triggers.SelectInput &&\n dropdownTriggerer !== dropdownComponentIds.triggers.AutoComplete;\n\n const { refs, floatingStyles, context } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n strategy: 'fixed',\n placement:
|
|
1
|
+
{"version":3,"file":"DropdownOverlay.web.js","sources":["../../../../../../src/components/Dropdown/DropdownOverlay.web.tsx"],"sourcesContent":["import React from 'react';\nimport {\n autoUpdate,\n offset,\n size as sizeMiddleware,\n useFloating,\n useTransitionStyles,\n flip,\n} from '@floating-ui/react';\nimport { useDropdown } from './useDropdown';\nimport { StyledDropdownOverlay } from './StyledDropdownOverlay';\nimport type { DropdownOverlayProps } from './types';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useTheme } from '~components/BladeProvider';\n// Reading directly because its not possible to get theme object on top level to be used in keyframes\nimport { size } from '~tokens/global';\nimport { makeSize } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { useBottomSheetAndDropdownGlue } from '~components/BottomSheet/BottomSheetContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport { componentZIndices } from '~utils/componentZIndices';\n\nconst OVERLAY_OFFSET: number = size['8'];\nconst OVERLAY_PADDING: number = size['12']; // doesn't have to be exact. Just rough padding for floating ui to decide to show overlay on top or bottom\n\n/**\n * Overlay of dropdown\n *\n * Wrap your ActionList within this component\n */\nconst _DropdownOverlay = ({\n children,\n testID,\n zIndex = componentZIndices.dropdownOverlay,\n width,\n defaultPlacement = 'bottom-start',\n}: DropdownOverlayProps): React.ReactElement | null => {\n const { isOpen, triggererRef, triggererWrapperRef, dropdownTriggerer, setIsOpen } = useDropdown();\n const { theme } = useTheme();\n const bottomSheetAndDropdownGlue = useBottomSheetAndDropdownGlue();\n\n const isMenu =\n dropdownTriggerer !== dropdownComponentIds.triggers.SelectInput &&\n dropdownTriggerer !== dropdownComponentIds.triggers.AutoComplete;\n\n const { refs, floatingStyles, context } = useFloating({\n open: isOpen,\n onOpenChange: setIsOpen,\n strategy: 'fixed',\n placement: defaultPlacement,\n elements: {\n // Input triggers have their ref on internal input element but we want width height of overall visible input hence wrapperRef is needed\n // We fallback to use `triggererRef` for triggers like button and link where wrapper is not needed\n // Checkout: https://github.com/razorpay/blade/pull/1559#discussion_r1305438920\n reference: triggererWrapperRef.current ?? triggererRef.current,\n },\n middleware: [\n offset({\n mainAxis: OVERLAY_OFFSET,\n }),\n flip({\n padding: OVERLAY_OFFSET + OVERLAY_PADDING,\n }),\n sizeMiddleware({\n apply({ rects, elements }) {\n Object.assign(elements.floating.style, {\n // in menu, we have flexible width between min and max\n // in input triggers, we just take width of trigger\n width: isMenu ? undefined : makeSize(rects.reference.width),\n minWidth: isMenu ? makeSize(size['240']) : undefined,\n maxWidth: isMenu ? makeSize(size['400']) : undefined,\n });\n },\n }),\n ],\n whileElementsMounted: autoUpdate,\n });\n\n const { isMounted, styles } = useTransitionStyles(context, {\n duration: theme.motion.duration.quick,\n initial: () => ({\n transform: `translateY(-${makeSize(size['8'])})`,\n opacity: 0,\n }),\n });\n\n React.useEffect(() => {\n if (isOpen) {\n // On Safari clicking on a non input element doesn't focuses it https://bugs.webkit.org/show_bug.cgi?id=22261\n triggererRef.current?.focus();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isOpen]);\n\n return (\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={refs.setFloating as any}\n style={floatingStyles}\n zIndex={zIndex}\n display={isMounted ? 'flex' : 'none'}\n >\n <StyledDropdownOverlay\n isInBottomSheet={bottomSheetAndDropdownGlue?.dropdownHasBottomSheet}\n elevation={bottomSheetAndDropdownGlue?.dropdownHasBottomSheet ? undefined : 'midRaised'}\n style={{ ...styles }}\n width={width ? width : '100%'}\n {...metaAttribute({ name: MetaConstants.DropdownOverlay, testID })}\n >\n {children}\n </StyledDropdownOverlay>\n </BaseBox>\n );\n};\n\nconst DropdownOverlay = assignWithoutSideEffects(_DropdownOverlay, {\n componentId: dropdownComponentIds.DropdownOverlay,\n});\n\nexport { DropdownOverlay };\n"],"names":["OVERLAY_OFFSET","size","OVERLAY_PADDING","_DropdownOverlay","_ref","_triggererWrapperRef$","children","testID","_ref$zIndex","zIndex","componentZIndices","dropdownOverlay","width","_ref$defaultPlacement","defaultPlacement","_useDropdown","useDropdown","isOpen","triggererRef","triggererWrapperRef","dropdownTriggerer","setIsOpen","_useTheme","useTheme","theme","bottomSheetAndDropdownGlue","useBottomSheetAndDropdownGlue","isMenu","dropdownComponentIds","triggers","SelectInput","AutoComplete","_useFloating","useFloating","open","onOpenChange","strategy","placement","elements","reference","current","middleware","offset","mainAxis","flip","padding","sizeMiddleware","apply","_ref2","rects","Object","assign","floating","style","undefined","makeSize","minWidth","maxWidth","whileElementsMounted","autoUpdate","refs","floatingStyles","context","_useTransitionStyles","useTransitionStyles","duration","motion","quick","initial","transform","concat","opacity","isMounted","styles","React","useEffect","_triggererRef$current","focus","_jsx","BaseBox","ref","setFloating","display","StyledDropdownOverlay","_objectSpread","isInBottomSheet","dropdownHasBottomSheet","elevation","metaAttribute","name","MetaConstants","DropdownOverlay","assignWithoutSideEffects","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAMA,cAAsB,GAAGC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxC,IAAMC,eAAuB,GAAGD,IAAI,CAAC,IAAI,CAAC,CAAC;;AAE3C;AACA;AACA;AACA;AACA;AACA,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAAC,IAAA,EAMiC;AAAA,EAAA,IAAAC,qBAAA,CAAA;AAAA,EAAA,IALrDC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,MAAM,GAAAH,IAAA,CAANG,MAAM;IAAAC,WAAA,GAAAJ,IAAA,CACNK,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,KAAA,CAAA,GAAGE,iBAAiB,CAACC,eAAe,GAAAH,WAAA;IAC1CI,KAAK,GAAAR,IAAA,CA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AAA,EAAA,EAAA;AAAAD,MAAAA,QAAA,EAEjEA,QAAAA;KACoB,CAAA,CAAA;AAAC,GACjB,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAMqF,eAAe,gBAAGC,wBAAwB,CAACzF,gBAAgB,EAAE;EACjE0F,WAAW,EAAEjE,oBAAoB,CAAC+D,eAAAA;AACpC,CAAC;;;;"}
|
|
@@ -156,6 +156,16 @@ function isElementVisibleOnScreen(element) {
|
|
|
156
156
|
return bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.documentElement.clientWidth);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Checks if element is visible inside the given container
|
|
161
|
+
*/
|
|
162
|
+
function isElementVisible(container, element) {
|
|
163
|
+
var containerRect = container.getBoundingClientRect();
|
|
164
|
+
var elementRect = element.getBoundingClientRect();
|
|
165
|
+
var isVerticalVisible = elementRect.top >= containerRect.top && elementRect.bottom <= containerRect.bottom;
|
|
166
|
+
return isVerticalVisible;
|
|
167
|
+
}
|
|
168
|
+
|
|
159
169
|
/**
|
|
160
170
|
* Checks if the dropdown is scrollable
|
|
161
171
|
*/
|
|
@@ -212,17 +222,15 @@ var ensureScrollVisiblity = function ensureScrollVisiblity(newActiveIndex, conta
|
|
|
212
222
|
// ensure the new option is in view
|
|
213
223
|
if (containerElement) {
|
|
214
224
|
if (isScrollable(containerElement)) {
|
|
215
|
-
var optionEl = containerElement.querySelectorAll('[role="option"]');
|
|
225
|
+
var optionEl = containerElement.querySelectorAll('[role="option"], [role="menuitem"]');
|
|
216
226
|
// Making sure its the same element as the one from options state
|
|
217
227
|
if (newActiveIndex >= 0 && optionEl[newActiveIndex].dataset.value === options[newActiveIndex]) {
|
|
218
228
|
var activeElement = optionEl[newActiveIndex];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
top: offsetPosition
|
|
225
|
-
});
|
|
229
|
+
if (!isElementVisible(containerElement, activeElement)) {
|
|
230
|
+
activeElement.scrollIntoView({
|
|
231
|
+
inline: 'nearest'
|
|
232
|
+
});
|
|
233
|
+
}
|
|
226
234
|
if (!isElementVisibleOnScreen(optionEl[newActiveIndex])) {
|
|
227
235
|
activeElement.scrollIntoView({
|
|
228
236
|
behavior: 'smooth'
|