@transferwise/components 0.0.0-experimental-335b83d → 0.0.0-experimental-fd2ddc2
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/index.esm.js +65 -688
- package/build/index.esm.js.map +1 -1
- package/build/index.js +65 -691
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/inputs/Input.css +1 -1
- package/build/styles/inputs/InputGroup.css +1 -1
- package/build/styles/inputs/TextArea.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/promoCard/PromoCard.css +1 -1
- package/build/types/common/card/index.d.ts +1 -0
- package/build/types/common/card/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts +7 -7
- package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts +0 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/_common.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +9 -3
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/promoCard/PromoCardIndicator.d.ts +5 -3
- package/build/types/promoCard/PromoCardIndicator.d.ts.map +1 -1
- package/package.json +22 -28
- package/src/common/card/Card.tsx +1 -1
- package/src/common/card/index.ts +1 -0
- package/src/index.ts +0 -8
- package/src/inputs/Input.css +1 -1
- package/src/inputs/Input.less +0 -14
- package/src/inputs/Input.tsx +2 -6
- package/src/inputs/InputGroup.css +1 -1
- package/src/inputs/InputGroup.less +1 -6
- package/src/inputs/TextArea.css +1 -1
- package/src/inputs/TextArea.less +0 -5
- package/src/inputs/_common.less +4 -0
- package/src/inputs/_common.ts +1 -0
- package/src/main.css +1 -1
- package/src/main.less +0 -4
- package/src/promoCard/PromoCard.css +1 -1
- package/src/promoCard/PromoCard.less +9 -9
- package/src/promoCard/PromoCard.spec.tsx +1 -0
- package/src/promoCard/PromoCard.story.tsx +86 -29
- package/src/promoCard/PromoCard.tsx +69 -22
- package/src/promoCard/PromoCardIndicator.tsx +20 -8
- package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
- package/src/ssr.spec.js +0 -7
- package/build/styles/inputs/SelectInput.css +0 -1
- package/build/types/common/hooks/useMedia.d.ts +0 -2
- package/build/types/common/hooks/useMedia.d.ts.map +0 -1
- package/build/types/common/hooks/useScreenSize.d.ts +0 -3
- package/build/types/common/hooks/useScreenSize.d.ts.map +0 -1
- package/build/types/common/preventScroll/PreventScroll.d.ts +0 -2
- package/build/types/common/preventScroll/PreventScroll.d.ts.map +0 -1
- package/build/types/inputs/SearchInput.d.ts +0 -10
- package/build/types/inputs/SearchInput.d.ts.map +0 -1
- package/build/types/inputs/SelectInput.d.ts +0 -41
- package/build/types/inputs/SelectInput.d.ts.map +0 -1
- package/build/types/inputs/_BottomSheet.d.ts +0 -17
- package/build/types/inputs/_BottomSheet.d.ts.map +0 -1
- package/build/types/inputs/_ButtonInput.d.ts +0 -6
- package/build/types/inputs/_ButtonInput.d.ts.map +0 -1
- package/build/types/inputs/_Popover.d.ts +0 -18
- package/build/types/inputs/_Popover.d.ts.map +0 -1
- package/build/types/utilities/wrapInFragment.d.ts +0 -3
- package/build/types/utilities/wrapInFragment.d.ts.map +0 -1
- package/src/common/hooks/useMedia.ts +0 -15
- package/src/common/hooks/useScreenSize.ts +0 -7
- package/src/common/preventScroll/PreventScroll.tsx +0 -6
- package/src/inputs/SearchInput.story.tsx +0 -40
- package/src/inputs/SearchInput.tsx +0 -35
- package/src/inputs/SelectInput.css +0 -1
- package/src/inputs/SelectInput.less +0 -183
- package/src/inputs/SelectInput.story.tsx +0 -259
- package/src/inputs/SelectInput.tsx +0 -565
- package/src/inputs/_BottomSheet.less +0 -107
- package/src/inputs/_BottomSheet.tsx +0 -128
- package/src/inputs/_ButtonInput.less +0 -7
- package/src/inputs/_ButtonInput.tsx +0 -27
- package/src/inputs/_Popover.less +0 -38
- package/src/inputs/_Popover.tsx +0 -118
- package/src/utilities/wrapInFragment.tsx +0 -3
- /package/src/dateLookup/dateTrigger/{DateTrigger.messages.ts → DateTrigger.messages.js} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useLayoutEffect, createContext, useContext, useCallback, PureComponent, createRef, Component, Children, Fragment as Fragment$1 } from 'react';
|
|
5
|
-
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle,
|
|
5
|
+
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, CheckCircleFill, Search, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
8
8
|
import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
@@ -13,11 +13,6 @@ import { createPortal } from 'react-dom';
|
|
|
13
13
|
import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
|
|
14
14
|
import mergeRefs from 'react-merge-refs';
|
|
15
15
|
import { usePopper } from 'react-popper';
|
|
16
|
-
import { Transition, Listbox } from '@headlessui/react';
|
|
17
|
-
import { useId } from '@radix-ui/react-id';
|
|
18
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
19
|
-
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
|
|
20
|
-
import { usePreventScroll } from '@react-aria/overlays';
|
|
21
16
|
import { Illustration } from '@wise/art';
|
|
22
17
|
import clamp$2 from 'lodash.clamp';
|
|
23
18
|
import debounce from 'lodash.debounce';
|
|
@@ -1974,7 +1969,7 @@ const MOVE_OFFSET_THRESHOLD = 50;
|
|
|
1974
1969
|
* Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
|
|
1975
1970
|
*
|
|
1976
1971
|
*/
|
|
1977
|
-
const BottomSheet
|
|
1972
|
+
const BottomSheet = props => {
|
|
1978
1973
|
const bottomSheetReference = useRef(null);
|
|
1979
1974
|
const topBarReference = useRef(null);
|
|
1980
1975
|
const contentReference = useRef(null);
|
|
@@ -2128,7 +2123,7 @@ const BottomSheet$1 = props => {
|
|
|
2128
2123
|
})
|
|
2129
2124
|
});
|
|
2130
2125
|
};
|
|
2131
|
-
var BottomSheet$
|
|
2126
|
+
var BottomSheet$1 = BottomSheet;
|
|
2132
2127
|
|
|
2133
2128
|
const typeClassMap$1 = {
|
|
2134
2129
|
[ControlType.ACCENT]: 'btn-accent',
|
|
@@ -2322,7 +2317,7 @@ var Card$2 = Card$1;
|
|
|
2322
2317
|
|
|
2323
2318
|
const Card = ({
|
|
2324
2319
|
className,
|
|
2325
|
-
children,
|
|
2320
|
+
children = null,
|
|
2326
2321
|
id,
|
|
2327
2322
|
isDisabled = false,
|
|
2328
2323
|
isSmall = false,
|
|
@@ -3155,7 +3150,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3155
3150
|
isMobile
|
|
3156
3151
|
} = useLayout();
|
|
3157
3152
|
if (isMobile) {
|
|
3158
|
-
return /*#__PURE__*/jsx(BottomSheet$
|
|
3153
|
+
return /*#__PURE__*/jsx(BottomSheet$1, {
|
|
3159
3154
|
open: open,
|
|
3160
3155
|
className: className,
|
|
3161
3156
|
onClose: onClose,
|
|
@@ -5833,7 +5828,7 @@ const Modal = ({
|
|
|
5833
5828
|
});
|
|
5834
5829
|
};
|
|
5835
5830
|
|
|
5836
|
-
const Popover
|
|
5831
|
+
const Popover = ({
|
|
5837
5832
|
children,
|
|
5838
5833
|
className,
|
|
5839
5834
|
content,
|
|
@@ -5887,12 +5882,12 @@ const logActionRequired = ({
|
|
|
5887
5882
|
}) => {
|
|
5888
5883
|
logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
|
|
5889
5884
|
};
|
|
5890
|
-
Popover
|
|
5885
|
+
Popover.defaultProps = {
|
|
5891
5886
|
className: undefined,
|
|
5892
5887
|
preferredPlacement: Position.RIGHT,
|
|
5893
5888
|
title: undefined
|
|
5894
5889
|
};
|
|
5895
|
-
Popover
|
|
5890
|
+
Popover.propTypes = {
|
|
5896
5891
|
children: PropTypes.node.isRequired,
|
|
5897
5892
|
className: PropTypes.string,
|
|
5898
5893
|
content: PropTypes.node.isRequired,
|
|
@@ -5909,7 +5904,7 @@ const deprecatedPlacements = {
|
|
|
5909
5904
|
[Position.LEFT_TOP]: Position.TOP,
|
|
5910
5905
|
[Position.RIGHT_TOP]: Position.TOP
|
|
5911
5906
|
};
|
|
5912
|
-
var Popover$
|
|
5907
|
+
var Popover$1 = Popover;
|
|
5913
5908
|
|
|
5914
5909
|
const Info = ({
|
|
5915
5910
|
className = undefined,
|
|
@@ -5951,7 +5946,7 @@ const Info = ({
|
|
|
5951
5946
|
title: title,
|
|
5952
5947
|
onClose: () => setOpen(false)
|
|
5953
5948
|
})]
|
|
5954
|
-
}) : /*#__PURE__*/jsx(Popover$
|
|
5949
|
+
}) : /*#__PURE__*/jsx(Popover$1, {
|
|
5955
5950
|
content: content,
|
|
5956
5951
|
preferredPlacement: Position.BOTTOM,
|
|
5957
5952
|
title: title,
|
|
@@ -6140,12 +6135,11 @@ function formControlClassNameBase({
|
|
|
6140
6135
|
'np-form-control--size-sm np-text-body-default': size === 'sm',
|
|
6141
6136
|
'np-form-control--size-md np-text-body-large': size === 'md',
|
|
6142
6137
|
'np-form-control--size-lg np-text-title-subsection': size === 'lg'
|
|
6143
|
-
});
|
|
6138
|
+
}, 'np-form-control--shape-rectangle');
|
|
6144
6139
|
}
|
|
6145
6140
|
|
|
6146
6141
|
const Input = /*#__PURE__*/forwardRef(function Input({
|
|
6147
6142
|
size = 'auto',
|
|
6148
|
-
shape = 'rectangle',
|
|
6149
6143
|
className,
|
|
6150
6144
|
...restProps
|
|
6151
6145
|
}, reference) {
|
|
@@ -6154,10 +6148,7 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6154
6148
|
ref: reference,
|
|
6155
6149
|
className: classNames(className, formControlClassNameBase({
|
|
6156
6150
|
size
|
|
6157
|
-
})
|
|
6158
|
-
'np-input--shape-rectangle': shape === 'rectangle',
|
|
6159
|
-
'np-input--shape-pill': shape === 'pill'
|
|
6160
|
-
})
|
|
6151
|
+
}))
|
|
6161
6152
|
// eslint-disable-next-line react/forbid-dom-props
|
|
6162
6153
|
,
|
|
6163
6154
|
style: inputPaddings,
|
|
@@ -6165,653 +6156,6 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6165
6156
|
});
|
|
6166
6157
|
});
|
|
6167
6158
|
|
|
6168
|
-
const SearchInput = /*#__PURE__*/forwardRef(function SearchInput({
|
|
6169
|
-
shape = 'pill',
|
|
6170
|
-
disabled,
|
|
6171
|
-
className,
|
|
6172
|
-
...restProps
|
|
6173
|
-
}, ref) {
|
|
6174
|
-
return /*#__PURE__*/jsx(InputGroup, {
|
|
6175
|
-
addonStart: {
|
|
6176
|
-
content: /*#__PURE__*/jsx(Search, {
|
|
6177
|
-
size: 24
|
|
6178
|
-
}),
|
|
6179
|
-
initialContentWidth: 24
|
|
6180
|
-
},
|
|
6181
|
-
disabled: disabled,
|
|
6182
|
-
className: className,
|
|
6183
|
-
children: /*#__PURE__*/jsx(Input, {
|
|
6184
|
-
ref: ref,
|
|
6185
|
-
role: "searchbox",
|
|
6186
|
-
inputMode: "search",
|
|
6187
|
-
shape: shape,
|
|
6188
|
-
...restProps
|
|
6189
|
-
})
|
|
6190
|
-
});
|
|
6191
|
-
});
|
|
6192
|
-
|
|
6193
|
-
function useMedia(query) {
|
|
6194
|
-
return useSyncExternalStore(onStoreChange => {
|
|
6195
|
-
const mediaQueryList = window.matchMedia(query);
|
|
6196
|
-
mediaQueryList.addEventListener('change', onStoreChange);
|
|
6197
|
-
return () => {
|
|
6198
|
-
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
6199
|
-
};
|
|
6200
|
-
}, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
|
|
6201
|
-
}
|
|
6202
|
-
|
|
6203
|
-
function useScreenSize(size) {
|
|
6204
|
-
return useMedia(`(min-width: ${size}px)`);
|
|
6205
|
-
}
|
|
6206
|
-
|
|
6207
|
-
function wrapInFragment(value) {
|
|
6208
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
6209
|
-
children: value
|
|
6210
|
-
});
|
|
6211
|
-
}
|
|
6212
|
-
|
|
6213
|
-
function PreventScroll() {
|
|
6214
|
-
usePreventScroll();
|
|
6215
|
-
return null;
|
|
6216
|
-
}
|
|
6217
|
-
|
|
6218
|
-
function BottomSheet({
|
|
6219
|
-
open,
|
|
6220
|
-
renderTrigger,
|
|
6221
|
-
title,
|
|
6222
|
-
initialFocusRef,
|
|
6223
|
-
padding = 'md',
|
|
6224
|
-
children,
|
|
6225
|
-
onClose
|
|
6226
|
-
}) {
|
|
6227
|
-
const {
|
|
6228
|
-
refs,
|
|
6229
|
-
context
|
|
6230
|
-
} = useFloating({
|
|
6231
|
-
open,
|
|
6232
|
-
onOpenChange: value => {
|
|
6233
|
-
if (!value) {
|
|
6234
|
-
onClose?.();
|
|
6235
|
-
}
|
|
6236
|
-
}
|
|
6237
|
-
});
|
|
6238
|
-
const dismiss = useDismiss(context, {
|
|
6239
|
-
outsidePressEvent: 'mousedown'
|
|
6240
|
-
});
|
|
6241
|
-
const role = useRole(context);
|
|
6242
|
-
const {
|
|
6243
|
-
getReferenceProps,
|
|
6244
|
-
getFloatingProps
|
|
6245
|
-
} = useInteractions([dismiss, role]);
|
|
6246
|
-
const [floatingKey, setFloatingKey] = useState(0);
|
|
6247
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
6248
|
-
children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger?.({
|
|
6249
|
-
ref: refs.setReference,
|
|
6250
|
-
getInteractionProps: getReferenceProps
|
|
6251
|
-
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6252
|
-
children: /*#__PURE__*/jsxs(Transition, {
|
|
6253
|
-
show: open,
|
|
6254
|
-
className: "np-bottom-sheet-v2-container",
|
|
6255
|
-
beforeEnter: () => {
|
|
6256
|
-
setFloatingKey(prev => prev + 1);
|
|
6257
|
-
},
|
|
6258
|
-
children: [/*#__PURE__*/jsx(Transition.Child, {
|
|
6259
|
-
enter: "np-bottom-sheet-v2-backdrop-container--enter",
|
|
6260
|
-
enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
|
|
6261
|
-
leave: "np-bottom-sheet-v2-backdrop-container--leave",
|
|
6262
|
-
leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
|
|
6263
|
-
children: /*#__PURE__*/jsx("div", {
|
|
6264
|
-
className: "np-bottom-sheet-v2-backdrop"
|
|
6265
|
-
})
|
|
6266
|
-
}), /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6267
|
-
context: context,
|
|
6268
|
-
initialFocus: initialFocusRef,
|
|
6269
|
-
children: /*#__PURE__*/jsx("div", {
|
|
6270
|
-
className: "np-bottom-sheet-v2",
|
|
6271
|
-
children: /*#__PURE__*/jsx(Transition.Child, {
|
|
6272
|
-
className: "np-bottom-sheet-v2-content",
|
|
6273
|
-
enter: "np-bottom-sheet-v2-content--enter",
|
|
6274
|
-
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
6275
|
-
leave: "np-bottom-sheet-v2-content--leave",
|
|
6276
|
-
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
6277
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
6278
|
-
// Force inner state invalidation on open
|
|
6279
|
-
ref: refs.setFloating,
|
|
6280
|
-
className: "np-bottom-sheet-v2-content-inner-container",
|
|
6281
|
-
...getFloatingProps(),
|
|
6282
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
6283
|
-
className: "np-bottom-sheet-v2-header",
|
|
6284
|
-
children: /*#__PURE__*/jsx(CloseButton, {
|
|
6285
|
-
size: Size.SMALL,
|
|
6286
|
-
onClick: () => {
|
|
6287
|
-
onClose?.();
|
|
6288
|
-
}
|
|
6289
|
-
})
|
|
6290
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
6291
|
-
className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
|
|
6292
|
-
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
|
|
6293
|
-
}),
|
|
6294
|
-
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
6295
|
-
className: "np-bottom-sheet-v2-title np-text-title-body",
|
|
6296
|
-
children: title
|
|
6297
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
6298
|
-
className: "np-bottom-sheet-v2-body np-text-body-default",
|
|
6299
|
-
children: children
|
|
6300
|
-
})]
|
|
6301
|
-
})]
|
|
6302
|
-
}, floatingKey)
|
|
6303
|
-
})
|
|
6304
|
-
})
|
|
6305
|
-
})]
|
|
6306
|
-
})
|
|
6307
|
-
})]
|
|
6308
|
-
});
|
|
6309
|
-
}
|
|
6310
|
-
|
|
6311
|
-
const ButtonInput = /*#__PURE__*/forwardRef(function ButtonInput({
|
|
6312
|
-
size = 'md',
|
|
6313
|
-
className,
|
|
6314
|
-
style,
|
|
6315
|
-
...restProps
|
|
6316
|
-
}, ref) {
|
|
6317
|
-
const inputPaddings = useInputPaddings();
|
|
6318
|
-
return /*#__PURE__*/jsx("button", {
|
|
6319
|
-
ref: ref,
|
|
6320
|
-
type: "button",
|
|
6321
|
-
className: classNames(className, formControlClassNameBase({
|
|
6322
|
-
size
|
|
6323
|
-
}), 'np-button-input')
|
|
6324
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
6325
|
-
,
|
|
6326
|
-
style: {
|
|
6327
|
-
...inputPaddings,
|
|
6328
|
-
...style
|
|
6329
|
-
},
|
|
6330
|
-
...restProps
|
|
6331
|
-
});
|
|
6332
|
-
});
|
|
6333
|
-
|
|
6334
|
-
const floatingPadding = 16;
|
|
6335
|
-
function Popover({
|
|
6336
|
-
placement,
|
|
6337
|
-
open,
|
|
6338
|
-
renderTrigger,
|
|
6339
|
-
title,
|
|
6340
|
-
padding = 'md',
|
|
6341
|
-
children,
|
|
6342
|
-
onClose
|
|
6343
|
-
}) {
|
|
6344
|
-
const {
|
|
6345
|
-
refs,
|
|
6346
|
-
floatingStyles,
|
|
6347
|
-
context
|
|
6348
|
-
} = useFloating({
|
|
6349
|
-
placement,
|
|
6350
|
-
middleware: [offset(8), flip({
|
|
6351
|
-
padding: floatingPadding,
|
|
6352
|
-
crossAxis: false
|
|
6353
|
-
}), shift(), size({
|
|
6354
|
-
padding: floatingPadding,
|
|
6355
|
-
apply: ({
|
|
6356
|
-
elements,
|
|
6357
|
-
rects,
|
|
6358
|
-
availableHeight
|
|
6359
|
-
}) => {
|
|
6360
|
-
elements.floating.style.setProperty('--max-height', `${availableHeight}px`);
|
|
6361
|
-
elements.floating.style.setProperty('--width', `${rects.reference.width}px`);
|
|
6362
|
-
}
|
|
6363
|
-
})],
|
|
6364
|
-
whileElementsMounted: autoUpdate,
|
|
6365
|
-
open,
|
|
6366
|
-
onOpenChange: value => {
|
|
6367
|
-
if (!value) {
|
|
6368
|
-
onClose?.();
|
|
6369
|
-
}
|
|
6370
|
-
}
|
|
6371
|
-
});
|
|
6372
|
-
const dismiss = useDismiss(context, {
|
|
6373
|
-
outsidePressEvent: 'mousedown'
|
|
6374
|
-
});
|
|
6375
|
-
const role = useRole(context);
|
|
6376
|
-
const {
|
|
6377
|
-
getReferenceProps,
|
|
6378
|
-
getFloatingProps
|
|
6379
|
-
} = useInteractions([role, dismiss]);
|
|
6380
|
-
const [floatingKey, setFloatingKey] = useState(0);
|
|
6381
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
6382
|
-
children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger({
|
|
6383
|
-
ref: refs.setReference,
|
|
6384
|
-
getInteractionProps: getReferenceProps
|
|
6385
|
-
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6386
|
-
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6387
|
-
context: context,
|
|
6388
|
-
children: /*#__PURE__*/jsx(Transition, {
|
|
6389
|
-
show: open,
|
|
6390
|
-
leave: "transition-opacity",
|
|
6391
|
-
leaveTo: "opacity-0",
|
|
6392
|
-
beforeEnter: () => {
|
|
6393
|
-
setFloatingKey(prev => prev + 1);
|
|
6394
|
-
},
|
|
6395
|
-
children: /*#__PURE__*/jsx("div", {
|
|
6396
|
-
// Force inner state invalidation on open
|
|
6397
|
-
ref: refs.setFloating,
|
|
6398
|
-
className: "np-popover-v2-container"
|
|
6399
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
6400
|
-
,
|
|
6401
|
-
style: floatingStyles,
|
|
6402
|
-
...getFloatingProps(),
|
|
6403
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
6404
|
-
className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
|
|
6405
|
-
'np-popover-v2--padding-md': padding === 'md'
|
|
6406
|
-
}),
|
|
6407
|
-
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
6408
|
-
className: "np-popover-v2-title np-text-title-body",
|
|
6409
|
-
children: title
|
|
6410
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
6411
|
-
className: "np-popover-v2-content np-text-body-default",
|
|
6412
|
-
children: children
|
|
6413
|
-
})]
|
|
6414
|
-
})
|
|
6415
|
-
}, floatingKey)
|
|
6416
|
-
})
|
|
6417
|
-
})
|
|
6418
|
-
})]
|
|
6419
|
-
});
|
|
6420
|
-
}
|
|
6421
|
-
|
|
6422
|
-
function searchableString(value) {
|
|
6423
|
-
return value.trim().replace(/\s+/gu, ' ').toLowerCase();
|
|
6424
|
-
}
|
|
6425
|
-
function inferSearchableStrings(value) {
|
|
6426
|
-
if (typeof value === 'string') {
|
|
6427
|
-
return [searchableString(value)];
|
|
6428
|
-
}
|
|
6429
|
-
if (typeof value === 'object' && value != null) {
|
|
6430
|
-
return Object.values(value).filter(innerValue => typeof innerValue === 'string').map(innerValue => searchableString(innerValue));
|
|
6431
|
-
}
|
|
6432
|
-
return [];
|
|
6433
|
-
}
|
|
6434
|
-
const SelectInputHasValueContext = /*#__PURE__*/createContext(false);
|
|
6435
|
-
const SelectInputOptionContentCompactContext = /*#__PURE__*/createContext(false);
|
|
6436
|
-
function dedupeSelectInputOptionItem(item, existingValues) {
|
|
6437
|
-
if (existingValues.has(item.value)) {
|
|
6438
|
-
return {
|
|
6439
|
-
...item,
|
|
6440
|
-
value: undefined
|
|
6441
|
-
};
|
|
6442
|
-
}
|
|
6443
|
-
existingValues.add(item.value);
|
|
6444
|
-
return item;
|
|
6445
|
-
}
|
|
6446
|
-
function dedupeSelectInputItems(items) {
|
|
6447
|
-
const existingValues = new Set();
|
|
6448
|
-
return items.map(item => {
|
|
6449
|
-
switch (item.type) {
|
|
6450
|
-
case 'option':
|
|
6451
|
-
{
|
|
6452
|
-
return dedupeSelectInputOptionItem(item, existingValues);
|
|
6453
|
-
}
|
|
6454
|
-
case 'group':
|
|
6455
|
-
{
|
|
6456
|
-
return {
|
|
6457
|
-
...item,
|
|
6458
|
-
options: item.options.map(option => dedupeSelectInputOptionItem(option, existingValues))
|
|
6459
|
-
};
|
|
6460
|
-
}
|
|
6461
|
-
}
|
|
6462
|
-
return item;
|
|
6463
|
-
});
|
|
6464
|
-
}
|
|
6465
|
-
function SelectInput({
|
|
6466
|
-
name,
|
|
6467
|
-
placeholder,
|
|
6468
|
-
items,
|
|
6469
|
-
defaultValue,
|
|
6470
|
-
value: controlledValue,
|
|
6471
|
-
renderValue = wrapInFragment,
|
|
6472
|
-
compareValues,
|
|
6473
|
-
filterable,
|
|
6474
|
-
filterPlaceholder,
|
|
6475
|
-
disabled,
|
|
6476
|
-
className,
|
|
6477
|
-
onChange,
|
|
6478
|
-
onClear
|
|
6479
|
-
}) {
|
|
6480
|
-
const intl = useIntl();
|
|
6481
|
-
const [open, setOpen] = useState(false);
|
|
6482
|
-
const triggerRef = useRef(null);
|
|
6483
|
-
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
6484
|
-
const OptionsOverlay = screenSm ? Popover : BottomSheet;
|
|
6485
|
-
const searchInputRef = useRef(null);
|
|
6486
|
-
const listboxRef = useRef(null);
|
|
6487
|
-
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
6488
|
-
return /*#__PURE__*/jsx(Listbox, {
|
|
6489
|
-
name: name,
|
|
6490
|
-
defaultValue: defaultValue,
|
|
6491
|
-
value: controlledValue
|
|
6492
|
-
// TODO: Remove assertion when upgrading TypeScript to v5
|
|
6493
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
6494
|
-
,
|
|
6495
|
-
by: compareValues,
|
|
6496
|
-
disabled: disabled,
|
|
6497
|
-
onChange: value => {
|
|
6498
|
-
setOpen(false);
|
|
6499
|
-
onChange?.(value);
|
|
6500
|
-
},
|
|
6501
|
-
children: ({
|
|
6502
|
-
disabled: uiDisabled,
|
|
6503
|
-
value
|
|
6504
|
-
}) => /*#__PURE__*/jsx(SelectInputHasValueContext.Provider, {
|
|
6505
|
-
value: value != null,
|
|
6506
|
-
children: /*#__PURE__*/jsx(InputGroup, {
|
|
6507
|
-
addonEnd: {
|
|
6508
|
-
content: /*#__PURE__*/jsxs("span", {
|
|
6509
|
-
className: classNames('np-select-input-addon-container', uiDisabled && 'disabled'),
|
|
6510
|
-
children: [onClear != null && value != null ? /*#__PURE__*/jsxs(Fragment, {
|
|
6511
|
-
children: [/*#__PURE__*/jsx("button", {
|
|
6512
|
-
type: "button",
|
|
6513
|
-
"aria-label": intl.formatMessage(messages$4.ariaLabel),
|
|
6514
|
-
disabled: uiDisabled,
|
|
6515
|
-
className: "np-select-input-addon np-select-input-addon--interactive",
|
|
6516
|
-
onClick: event => {
|
|
6517
|
-
event.preventDefault();
|
|
6518
|
-
onClear();
|
|
6519
|
-
triggerRef.current?.focus({
|
|
6520
|
-
preventScroll: true
|
|
6521
|
-
});
|
|
6522
|
-
},
|
|
6523
|
-
children: /*#__PURE__*/jsx(Cross, {
|
|
6524
|
-
size: 16
|
|
6525
|
-
})
|
|
6526
|
-
}), /*#__PURE__*/jsx("span", {
|
|
6527
|
-
className: "np-select-input-addon-separator"
|
|
6528
|
-
})]
|
|
6529
|
-
}) : null, /*#__PURE__*/jsx("span", {
|
|
6530
|
-
className: "np-select-input-addon",
|
|
6531
|
-
children: /*#__PURE__*/jsx(ChevronDown, {
|
|
6532
|
-
size: 16
|
|
6533
|
-
})
|
|
6534
|
-
})]
|
|
6535
|
-
}),
|
|
6536
|
-
padding: 'sm'
|
|
6537
|
-
},
|
|
6538
|
-
className: className,
|
|
6539
|
-
children: /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6540
|
-
open: open,
|
|
6541
|
-
renderTrigger: ({
|
|
6542
|
-
ref,
|
|
6543
|
-
getInteractionProps
|
|
6544
|
-
}) => /*#__PURE__*/jsx(Listbox.Button, {
|
|
6545
|
-
ref: mergeRefs([ref, triggerRef]),
|
|
6546
|
-
as: SelectInputButton,
|
|
6547
|
-
overrides: getInteractionProps(),
|
|
6548
|
-
onClick: () => {
|
|
6549
|
-
setOpen(prev => !prev);
|
|
6550
|
-
},
|
|
6551
|
-
children: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentCompactContext.Provider, {
|
|
6552
|
-
value: true,
|
|
6553
|
-
children: renderValue(value, true)
|
|
6554
|
-
}) : /*#__PURE__*/jsx("span", {
|
|
6555
|
-
className: "np-select-input-placeholder",
|
|
6556
|
-
children: placeholder
|
|
6557
|
-
})
|
|
6558
|
-
}),
|
|
6559
|
-
initialFocusRef: controllerRef,
|
|
6560
|
-
padding: "none",
|
|
6561
|
-
onClose: () => {
|
|
6562
|
-
setOpen(false);
|
|
6563
|
-
},
|
|
6564
|
-
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6565
|
-
items: items,
|
|
6566
|
-
renderValue: renderValue,
|
|
6567
|
-
filterable: filterable,
|
|
6568
|
-
filterPlaceholder: filterPlaceholder,
|
|
6569
|
-
searchInputRef: searchInputRef,
|
|
6570
|
-
listboxRef: listboxRef
|
|
6571
|
-
})
|
|
6572
|
-
})
|
|
6573
|
-
})
|
|
6574
|
-
})
|
|
6575
|
-
});
|
|
6576
|
-
}
|
|
6577
|
-
const SelectInputButton = /*#__PURE__*/forwardRef(function SelectInputButton({
|
|
6578
|
-
overrides,
|
|
6579
|
-
...restProps
|
|
6580
|
-
}, ref) {
|
|
6581
|
-
return /*#__PURE__*/jsx(ButtonInput, {
|
|
6582
|
-
ref: ref,
|
|
6583
|
-
...restProps,
|
|
6584
|
-
...overrides
|
|
6585
|
-
});
|
|
6586
|
-
});
|
|
6587
|
-
const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInputOptionsContainer({
|
|
6588
|
-
'aria-orientation': ariaOrientation,
|
|
6589
|
-
'aria-activedescendant': ariaActiveDescendant,
|
|
6590
|
-
role,
|
|
6591
|
-
tabIndex,
|
|
6592
|
-
onAriaActiveDescendantChange,
|
|
6593
|
-
onKeyDown,
|
|
6594
|
-
...restProps
|
|
6595
|
-
}, ref) {
|
|
6596
|
-
const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);
|
|
6597
|
-
useEffect(() => {
|
|
6598
|
-
handleAriaActiveDescendantChange(ariaActiveDescendant);
|
|
6599
|
-
}, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
|
|
6600
|
-
return (
|
|
6601
|
-
/*#__PURE__*/
|
|
6602
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
6603
|
-
jsx("div", {
|
|
6604
|
-
ref: ref,
|
|
6605
|
-
onKeyDown: event => {
|
|
6606
|
-
// Prevent absorbing dismissal requests too early
|
|
6607
|
-
if (event.key !== 'Escape') {
|
|
6608
|
-
onKeyDown?.(event);
|
|
6609
|
-
}
|
|
6610
|
-
},
|
|
6611
|
-
...restProps
|
|
6612
|
-
})
|
|
6613
|
-
);
|
|
6614
|
-
});
|
|
6615
|
-
function SelectInputOptions({
|
|
6616
|
-
items,
|
|
6617
|
-
renderValue = wrapInFragment,
|
|
6618
|
-
filterable,
|
|
6619
|
-
filterPlaceholder,
|
|
6620
|
-
searchInputRef,
|
|
6621
|
-
listboxRef
|
|
6622
|
-
}) {
|
|
6623
|
-
const [query, setQuery] = useState('');
|
|
6624
|
-
const needle = useMemo(() => query ? searchableString(query) : null, [query]);
|
|
6625
|
-
const listboxContainerRef = useRef(null);
|
|
6626
|
-
useEffect(() => {
|
|
6627
|
-
if (listboxContainerRef.current != null) {
|
|
6628
|
-
listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
|
|
6629
|
-
}
|
|
6630
|
-
}, []);
|
|
6631
|
-
const listboxId = useId();
|
|
6632
|
-
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
6633
|
-
return /*#__PURE__*/jsxs(Listbox.Options, {
|
|
6634
|
-
as: SelectInputOptionsContainer,
|
|
6635
|
-
static: true,
|
|
6636
|
-
className: "np-select-input-options-container",
|
|
6637
|
-
onAriaActiveDescendantChange: value => {
|
|
6638
|
-
if (controllerRef.current != null) {
|
|
6639
|
-
if (value != null) {
|
|
6640
|
-
controllerRef.current.setAttribute('aria-activedescendant', value);
|
|
6641
|
-
} else {
|
|
6642
|
-
controllerRef.current.removeAttribute('aria-activedescendant');
|
|
6643
|
-
}
|
|
6644
|
-
}
|
|
6645
|
-
},
|
|
6646
|
-
children: [filterable ? /*#__PURE__*/jsx("div", {
|
|
6647
|
-
className: "np-select-input-query-container",
|
|
6648
|
-
children: /*#__PURE__*/jsx(SearchInput, {
|
|
6649
|
-
ref: searchInputRef,
|
|
6650
|
-
shape: "rectangle",
|
|
6651
|
-
placeholder: filterPlaceholder,
|
|
6652
|
-
value: query,
|
|
6653
|
-
"aria-controls": listboxId,
|
|
6654
|
-
onKeyDown: event => {
|
|
6655
|
-
// Prevent interfering with the matcher of Headless UI
|
|
6656
|
-
// https://mathiasbynens.be/notes/javascript-unicode#regex
|
|
6657
|
-
if (/^.$/u.test(event.key)) {
|
|
6658
|
-
event.stopPropagation();
|
|
6659
|
-
}
|
|
6660
|
-
},
|
|
6661
|
-
onChange: event => {
|
|
6662
|
-
setQuery(event.currentTarget.value);
|
|
6663
|
-
}
|
|
6664
|
-
})
|
|
6665
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
6666
|
-
ref: listboxContainerRef,
|
|
6667
|
-
className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
6668
|
-
children: /*#__PURE__*/jsx("div", {
|
|
6669
|
-
ref: listboxRef,
|
|
6670
|
-
id: listboxId,
|
|
6671
|
-
role: "listbox",
|
|
6672
|
-
"aria-orientation": "vertical",
|
|
6673
|
-
tabIndex: 0,
|
|
6674
|
-
className: "np-select-input-listbox",
|
|
6675
|
-
children: (needle == null ? items : dedupeSelectInputItems(items)).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
6676
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
6677
|
-
, {
|
|
6678
|
-
item: item,
|
|
6679
|
-
renderValue: renderValue,
|
|
6680
|
-
needle: needle
|
|
6681
|
-
}, index))
|
|
6682
|
-
})
|
|
6683
|
-
})]
|
|
6684
|
-
});
|
|
6685
|
-
}
|
|
6686
|
-
function SelectInputItemView({
|
|
6687
|
-
item,
|
|
6688
|
-
renderValue,
|
|
6689
|
-
needle
|
|
6690
|
-
}) {
|
|
6691
|
-
switch (item.type) {
|
|
6692
|
-
case 'option':
|
|
6693
|
-
{
|
|
6694
|
-
if (item.value != null && (!needle || inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle)))) {
|
|
6695
|
-
return /*#__PURE__*/jsx(SelectInputOption, {
|
|
6696
|
-
value: item.value,
|
|
6697
|
-
disabled: item.disabled,
|
|
6698
|
-
children: renderValue(item.value, false)
|
|
6699
|
-
});
|
|
6700
|
-
}
|
|
6701
|
-
break;
|
|
6702
|
-
}
|
|
6703
|
-
case 'group':
|
|
6704
|
-
{
|
|
6705
|
-
return /*#__PURE__*/jsx(SelectInputGroupItemView, {
|
|
6706
|
-
item: item,
|
|
6707
|
-
renderValue: renderValue,
|
|
6708
|
-
needle: needle
|
|
6709
|
-
});
|
|
6710
|
-
}
|
|
6711
|
-
case 'separator':
|
|
6712
|
-
{
|
|
6713
|
-
if (needle == null) {
|
|
6714
|
-
return /*#__PURE__*/jsx("hr", {
|
|
6715
|
-
className: "np-select-input-separator-item",
|
|
6716
|
-
"aria-hidden": true
|
|
6717
|
-
});
|
|
6718
|
-
}
|
|
6719
|
-
break;
|
|
6720
|
-
}
|
|
6721
|
-
}
|
|
6722
|
-
return null;
|
|
6723
|
-
}
|
|
6724
|
-
function SelectInputGroupItemView({
|
|
6725
|
-
item,
|
|
6726
|
-
renderValue,
|
|
6727
|
-
needle
|
|
6728
|
-
}) {
|
|
6729
|
-
const headerId = useId();
|
|
6730
|
-
return (
|
|
6731
|
-
/*#__PURE__*/
|
|
6732
|
-
// An empty container may be rendered when no options match `needle`
|
|
6733
|
-
// However, pre-filtering would result in worse performance overall
|
|
6734
|
-
jsxs("section", {
|
|
6735
|
-
role: "group",
|
|
6736
|
-
"aria-labelledby": headerId,
|
|
6737
|
-
className: classNames(needle == null && 'np-select-input-group-item--without-needle'),
|
|
6738
|
-
children: [needle == null ? /*#__PURE__*/jsx("header", {
|
|
6739
|
-
id: headerId,
|
|
6740
|
-
role: "presentation",
|
|
6741
|
-
className: "np-select-input-group-item-header np-text-title-group",
|
|
6742
|
-
children: item.label
|
|
6743
|
-
}) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
6744
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
6745
|
-
, {
|
|
6746
|
-
item: option,
|
|
6747
|
-
renderValue: renderValue,
|
|
6748
|
-
needle: needle
|
|
6749
|
-
}, index))]
|
|
6750
|
-
})
|
|
6751
|
-
);
|
|
6752
|
-
}
|
|
6753
|
-
function SelectInputOption({
|
|
6754
|
-
value,
|
|
6755
|
-
disabled,
|
|
6756
|
-
children
|
|
6757
|
-
}) {
|
|
6758
|
-
const parentHasValue = useContext(SelectInputHasValueContext);
|
|
6759
|
-
// Avoid flash during exit transition
|
|
6760
|
-
const {
|
|
6761
|
-
current: cachedParentHasValue
|
|
6762
|
-
} = useRef(parentHasValue);
|
|
6763
|
-
return /*#__PURE__*/jsx(Listbox.Option, {
|
|
6764
|
-
as: "div",
|
|
6765
|
-
value: value,
|
|
6766
|
-
disabled: disabled,
|
|
6767
|
-
className: ({
|
|
6768
|
-
active,
|
|
6769
|
-
disabled: uiDisabled
|
|
6770
|
-
}) => classNames('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
|
|
6771
|
-
children: ({
|
|
6772
|
-
selected
|
|
6773
|
-
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
6774
|
-
children: [cachedParentHasValue ? /*#__PURE__*/jsx(Check, {
|
|
6775
|
-
size: 16,
|
|
6776
|
-
className: classNames(!selected && 'np-select-input-option-check--not-selected')
|
|
6777
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
6778
|
-
className: "np-select-input-option",
|
|
6779
|
-
children: children
|
|
6780
|
-
})]
|
|
6781
|
-
})
|
|
6782
|
-
});
|
|
6783
|
-
}
|
|
6784
|
-
function SelectInputOptionContent({
|
|
6785
|
-
title,
|
|
6786
|
-
note,
|
|
6787
|
-
description,
|
|
6788
|
-
icon
|
|
6789
|
-
}) {
|
|
6790
|
-
const compact = useContext(SelectInputOptionContentCompactContext);
|
|
6791
|
-
return /*#__PURE__*/jsxs("div", {
|
|
6792
|
-
className: "np-select-input-option-content-container np-text-body-large",
|
|
6793
|
-
children: [icon ? /*#__PURE__*/jsx("div", {
|
|
6794
|
-
className: classNames('np-select-input-option-content-icon', !compact && 'np-select-input-option-content-icon--not-compact'),
|
|
6795
|
-
children: icon
|
|
6796
|
-
}) : null, /*#__PURE__*/jsxs("div", {
|
|
6797
|
-
className: "np-select-input-option-content-text",
|
|
6798
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
6799
|
-
className: classNames('np-select-input-option-content-text-line-1', compact && 'np-select-input-option-content-text-compact'),
|
|
6800
|
-
children: [/*#__PURE__*/jsx("h4", {
|
|
6801
|
-
className: "d-inline np-text-body-large",
|
|
6802
|
-
children: title
|
|
6803
|
-
}), note ? /*#__PURE__*/jsx("span", {
|
|
6804
|
-
className: "np-select-input-option-content-text-secondary np-text-body-default",
|
|
6805
|
-
children: note
|
|
6806
|
-
}) : null]
|
|
6807
|
-
}), description ? /*#__PURE__*/jsx("div", {
|
|
6808
|
-
className: classNames('np-select-input-option-content-text-secondary np-text-body-default', compact && 'np-select-input-option-content-text-compact'),
|
|
6809
|
-
children: description
|
|
6810
|
-
}) : null]
|
|
6811
|
-
})]
|
|
6812
|
-
});
|
|
6813
|
-
}
|
|
6814
|
-
|
|
6815
6159
|
const TextArea = /*#__PURE__*/forwardRef(function TextArea({
|
|
6816
6160
|
className,
|
|
6817
6161
|
...restProps
|
|
@@ -7927,7 +7271,7 @@ function Select({
|
|
|
7927
7271
|
headerTitle: searchPlaceholder || formatMessage(messages$3.searchPlaceholder),
|
|
7928
7272
|
onClose: handleCloseOptions,
|
|
7929
7273
|
children: renderOptionsList()
|
|
7930
|
-
}) : /*#__PURE__*/jsx(BottomSheet$
|
|
7274
|
+
}) : /*#__PURE__*/jsx(BottomSheet$1, {
|
|
7931
7275
|
open: open,
|
|
7932
7276
|
onClose: handleCloseOptions,
|
|
7933
7277
|
children: renderOptionsList({
|
|
@@ -10360,10 +9704,12 @@ const PromoCardIndicator = ({
|
|
|
10360
9704
|
children,
|
|
10361
9705
|
label,
|
|
10362
9706
|
icon,
|
|
9707
|
+
isSmall = false,
|
|
10363
9708
|
testid,
|
|
10364
9709
|
...rest
|
|
10365
9710
|
}) => {
|
|
10366
|
-
const
|
|
9711
|
+
const isIconString = icon && typeof icon === 'string';
|
|
9712
|
+
const IconComponent = isIconString && {
|
|
10367
9713
|
check: Check,
|
|
10368
9714
|
arrow: ArrowRight,
|
|
10369
9715
|
download: Download
|
|
@@ -10377,12 +9723,15 @@ const PromoCardIndicator = ({
|
|
|
10377
9723
|
type: Typography.BODY_LARGE_BOLD,
|
|
10378
9724
|
className: "np-Card-indicatorText",
|
|
10379
9725
|
children: label
|
|
10380
|
-
}),
|
|
9726
|
+
}), icon && /*#__PURE__*/jsx(Avatar, {
|
|
9727
|
+
type: AvatarType.ICON,
|
|
9728
|
+
size: isSmall ? 40 : 56,
|
|
9729
|
+
backgroundColor: "var(--Card-indicator-icon-background-color)",
|
|
10381
9730
|
className: "np-Card-indicatorIcon",
|
|
10382
|
-
children: /*#__PURE__*/jsx(IconComponent, {
|
|
9731
|
+
children: IconComponent ? /*#__PURE__*/jsx(IconComponent, {
|
|
10383
9732
|
size: 24,
|
|
10384
9733
|
"aria-hidden": "true"
|
|
10385
|
-
})
|
|
9734
|
+
}) : icon
|
|
10386
9735
|
}), children]
|
|
10387
9736
|
});
|
|
10388
9737
|
};
|
|
@@ -10444,6 +9793,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10444
9793
|
imageClass,
|
|
10445
9794
|
imageSource,
|
|
10446
9795
|
indicatorLabel,
|
|
9796
|
+
indicatorIcon,
|
|
10447
9797
|
isChecked,
|
|
10448
9798
|
isDisabled,
|
|
10449
9799
|
onClick,
|
|
@@ -10454,6 +9804,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10454
9804
|
title,
|
|
10455
9805
|
type,
|
|
10456
9806
|
value,
|
|
9807
|
+
isSmall,
|
|
9808
|
+
useDisplayFont = true,
|
|
10457
9809
|
...props
|
|
10458
9810
|
}, reference) => {
|
|
10459
9811
|
// Set the `checked` state to the value of `defaultChecked` if it is truthy,
|
|
@@ -10477,7 +9829,19 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10477
9829
|
// Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
|
|
10478
9830
|
// `'download'` if `download` is truthy. If neither condition is true, set
|
|
10479
9831
|
// `icon` to `undefined`.
|
|
10480
|
-
|
|
9832
|
+
// Create a function to get icon type
|
|
9833
|
+
const getIconType = () => {
|
|
9834
|
+
if (indicatorIcon) {
|
|
9835
|
+
return indicatorIcon;
|
|
9836
|
+
}
|
|
9837
|
+
if (download) {
|
|
9838
|
+
return 'download';
|
|
9839
|
+
}
|
|
9840
|
+
if (href && !type) {
|
|
9841
|
+
return 'arrow';
|
|
9842
|
+
}
|
|
9843
|
+
return undefined;
|
|
9844
|
+
};
|
|
10481
9845
|
// Define all class names string based on the values of the `href`, `type`,
|
|
10482
9846
|
// `checked`, and `className` props.
|
|
10483
9847
|
const commonClasses = classNames({
|
|
@@ -10494,7 +9858,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10494
9858
|
isDisabled: isDisabled || contextIsDisabled,
|
|
10495
9859
|
onClick,
|
|
10496
9860
|
ref: reference,
|
|
10497
|
-
'data-testid': testId
|
|
9861
|
+
'data-testid': testId,
|
|
9862
|
+
isSmall
|
|
10498
9863
|
};
|
|
10499
9864
|
// Object with Anchor props that will be passed to the `a` element. These
|
|
10500
9865
|
// won't be refurned if set to `isDisabled`
|
|
@@ -10522,6 +9887,27 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10522
9887
|
ref: reference,
|
|
10523
9888
|
tabIndex: 0
|
|
10524
9889
|
} : {};
|
|
9890
|
+
const getTitle = () => {
|
|
9891
|
+
const titleContent = href && !type ? /*#__PURE__*/jsx("a", {
|
|
9892
|
+
className: "np-Card-titleLink",
|
|
9893
|
+
...anchorProps,
|
|
9894
|
+
children: title
|
|
9895
|
+
}) : title;
|
|
9896
|
+
const titleProps = {
|
|
9897
|
+
id: `${componentId}-title`,
|
|
9898
|
+
as: headingLevel,
|
|
9899
|
+
className: 'np-Card-title'
|
|
9900
|
+
};
|
|
9901
|
+
return useDisplayFont ? /*#__PURE__*/jsx(Display, {
|
|
9902
|
+
type: Typography.DISPLAY_SMALL,
|
|
9903
|
+
...titleProps,
|
|
9904
|
+
children: titleContent
|
|
9905
|
+
}) : /*#__PURE__*/jsx(Title, {
|
|
9906
|
+
type: Typography.TITLE_SUBSECTION,
|
|
9907
|
+
...titleProps,
|
|
9908
|
+
children: titleContent
|
|
9909
|
+
});
|
|
9910
|
+
};
|
|
10525
9911
|
useEffect(() => {
|
|
10526
9912
|
setChecked(defaultChecked ?? isChecked ?? false);
|
|
10527
9913
|
}, [defaultChecked, isChecked]);
|
|
@@ -10535,17 +9921,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10535
9921
|
size: 24,
|
|
10536
9922
|
"aria-hidden": "true"
|
|
10537
9923
|
})
|
|
10538
|
-
}), /*#__PURE__*/jsx(
|
|
10539
|
-
id: `${componentId}-title`,
|
|
10540
|
-
as: headingLevel,
|
|
10541
|
-
className: "np-Card-title",
|
|
10542
|
-
type: Typography.DISPLAY_SMALL,
|
|
10543
|
-
children: href && !type ? /*#__PURE__*/jsx("a", {
|
|
10544
|
-
className: "np-Card-titleLink",
|
|
10545
|
-
...anchorProps,
|
|
10546
|
-
children: title
|
|
10547
|
-
}) : title
|
|
10548
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
9924
|
+
}), getTitle(), /*#__PURE__*/jsx(Body, {
|
|
10549
9925
|
className: "np-Card-description",
|
|
10550
9926
|
children: description
|
|
10551
9927
|
}), imageSource && /*#__PURE__*/jsx("div", {
|
|
@@ -10559,7 +9935,8 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
10559
9935
|
})
|
|
10560
9936
|
}), /*#__PURE__*/jsx(PromoCardIndicator, {
|
|
10561
9937
|
label: indicatorLabel,
|
|
10562
|
-
icon:
|
|
9938
|
+
icon: getIconType(),
|
|
9939
|
+
isSmall: isSmall
|
|
10563
9940
|
})]
|
|
10564
9941
|
});
|
|
10565
9942
|
});
|
|
@@ -15041,5 +14418,5 @@ const translations = {
|
|
|
15041
14418
|
zh
|
|
15042
14419
|
};
|
|
15043
14420
|
|
|
15044
|
-
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$
|
|
14421
|
+
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron$1 as Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat$1 as InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput$1 as PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, Section, Select, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat$1 as TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useSnackbar };
|
|
15045
14422
|
//# sourceMappingURL=index.esm.js.map
|