@transferwise/components 45.14.2 → 45.15.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/index.esm.js +680 -50
- package/build/index.esm.js.map +1 -1
- package/build/index.js +683 -50
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/common/closeButton/CloseButton.css +1 -1
- package/build/styles/inputs/Input.css +1 -1
- package/build/styles/inputs/InputGroup.css +1 -1
- package/build/styles/inputs/SelectInput.css +1 -0
- 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/styles/stepper/Stepper.css +1 -1
- package/build/types/common/hooks/useMedia.d.ts +2 -0
- package/build/types/common/hooks/useMedia.d.ts.map +1 -0
- package/build/types/common/hooks/useScreenSize.d.ts +3 -0
- package/build/types/common/hooks/useScreenSize.d.ts.map +1 -0
- package/build/types/common/preventScroll/PreventScroll.d.ts +2 -0
- package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -0
- 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 +4 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts +1 -0
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SearchInput.d.ts +10 -0
- package/build/types/inputs/SearchInput.d.ts.map +1 -0
- package/build/types/inputs/SelectInput.d.ts +41 -0
- package/build/types/inputs/SelectInput.d.ts.map +1 -0
- package/build/types/inputs/_BottomSheet.d.ts +17 -0
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -0
- package/build/types/inputs/_ButtonInput.d.ts +6 -0
- package/build/types/inputs/_ButtonInput.d.ts.map +1 -0
- package/build/types/inputs/_Popover.d.ts +18 -0
- package/build/types/inputs/_Popover.d.ts.map +1 -0
- package/build/types/inputs/_common.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/stepper/Stepper.d.ts.map +1 -1
- package/build/types/tile/Tile.d.ts.map +1 -1
- package/build/types/utilities/wrapInFragment.d.ts +3 -0
- package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
- package/package.json +26 -20
- package/src/common/closeButton/CloseButton.css +1 -1
- package/src/common/hooks/useMedia.spec.ts +39 -0
- package/src/common/hooks/useMedia.ts +15 -0
- package/src/common/hooks/useScreenSize.ts +7 -0
- package/src/common/preventScroll/PreventScroll.tsx +6 -0
- package/src/decision/Decision.story.js +11 -11
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +12 -12
- package/src/i18n/en.json +1 -0
- package/src/index.ts +8 -0
- package/src/inputs/Input.css +1 -1
- package/src/inputs/Input.less +14 -0
- package/src/inputs/Input.tsx +6 -2
- package/src/inputs/InputGroup.css +1 -1
- package/src/inputs/InputGroup.less +5 -0
- package/src/inputs/SearchInput.story.tsx +40 -0
- package/src/inputs/SearchInput.tsx +35 -0
- package/src/inputs/SelectInput.css +1 -0
- package/src/inputs/SelectInput.less +183 -0
- package/src/inputs/SelectInput.spec.tsx +120 -0
- package/src/inputs/SelectInput.story.tsx +259 -0
- package/src/inputs/SelectInput.tsx +565 -0
- package/src/inputs/TextArea.css +1 -1
- package/src/inputs/TextArea.less +5 -0
- package/src/inputs/_BottomSheet.less +107 -0
- package/src/inputs/_BottomSheet.tsx +128 -0
- package/src/inputs/_ButtonInput.less +7 -0
- package/src/inputs/_ButtonInput.tsx +27 -0
- package/src/inputs/_Popover.less +38 -0
- package/src/inputs/_Popover.tsx +118 -0
- package/src/inputs/_common.less +0 -4
- package/src/inputs/_common.ts +0 -1
- package/src/logo/Logo.js +3 -21
- package/src/logo/__snapshots__/Logo.spec.js.snap +78 -30
- package/src/main.css +1 -1
- package/src/main.less +4 -0
- package/src/promoCard/PromoCard.css +1 -1
- package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
- package/src/ssr.spec.js +7 -0
- package/src/stepper/Stepper.css +1 -1
- package/src/stepper/Stepper.less +1 -9
- package/src/stepper/Stepper.spec.js +4 -4
- package/src/stepper/Stepper.tsx +2 -5
- package/src/tile/Tile.js +5 -11
- package/src/tile/__snapshots__/Tile.spec.js.snap +7 -9
- package/src/utilities/wrapInFragment.tsx +3 -0
- /package/src/dateLookup/dateTrigger/{DateTrigger.messages.js → DateTrigger.messages.ts} +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, Search, ChevronDown, CheckCircleFill, 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,6 +13,11 @@ 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';
|
|
16
21
|
import { Illustration } from '@wise/art';
|
|
17
22
|
import clamp$2 from 'lodash.clamp';
|
|
18
23
|
import debounce from 'lodash.debounce';
|
|
@@ -1980,7 +1985,7 @@ const MOVE_OFFSET_THRESHOLD = 50;
|
|
|
1980
1985
|
* Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
|
|
1981
1986
|
*
|
|
1982
1987
|
*/
|
|
1983
|
-
const BottomSheet = props => {
|
|
1988
|
+
const BottomSheet$1 = props => {
|
|
1984
1989
|
const bottomSheetReference = useRef(null);
|
|
1985
1990
|
const topBarReference = useRef(null);
|
|
1986
1991
|
const contentReference = useRef(null);
|
|
@@ -2134,7 +2139,7 @@ const BottomSheet = props => {
|
|
|
2134
2139
|
})
|
|
2135
2140
|
});
|
|
2136
2141
|
};
|
|
2137
|
-
var BottomSheet$
|
|
2142
|
+
var BottomSheet$2 = BottomSheet$1;
|
|
2138
2143
|
|
|
2139
2144
|
const typeClassMap$1 = {
|
|
2140
2145
|
[ControlType.ACCENT]: 'btn-accent',
|
|
@@ -3161,7 +3166,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3161
3166
|
isMobile
|
|
3162
3167
|
} = useLayout();
|
|
3163
3168
|
if (isMobile) {
|
|
3164
|
-
return /*#__PURE__*/jsx(BottomSheet$
|
|
3169
|
+
return /*#__PURE__*/jsx(BottomSheet$2, {
|
|
3165
3170
|
open: open,
|
|
3166
3171
|
className: className,
|
|
3167
3172
|
onClose: onClose,
|
|
@@ -4242,21 +4247,14 @@ const Tile = ({
|
|
|
4242
4247
|
title
|
|
4243
4248
|
}) => {
|
|
4244
4249
|
const isSmall = size === Size.SMALL;
|
|
4245
|
-
const {
|
|
4246
|
-
isModern
|
|
4247
|
-
} = useTheme();
|
|
4248
4250
|
const Element = href ? 'a' : 'button';
|
|
4249
4251
|
return /*#__PURE__*/jsxs(Element, {
|
|
4250
4252
|
className: classNames('decision', 'flex-column', 'np-tile', 'text-no-decoration', 'text-xs-center', className, {
|
|
4251
|
-
'p-a-3': !isSmall
|
|
4252
|
-
'p-
|
|
4253
|
-
|
|
4254
|
-
'np-tile--small': isSmall,
|
|
4255
|
-
disabled
|
|
4256
|
-
}),
|
|
4253
|
+
'p-a-3': !isSmall,
|
|
4254
|
+
'p-a-2 np-tile--small': isSmall
|
|
4255
|
+
}, disabled && 'disabled'),
|
|
4257
4256
|
href: href,
|
|
4258
4257
|
target: target,
|
|
4259
|
-
"aria-label": title,
|
|
4260
4258
|
onClick: disabled ? null : onClick,
|
|
4261
4259
|
onKeyDown: disabled ? null : ({
|
|
4262
4260
|
key
|
|
@@ -4272,15 +4270,12 @@ const Tile = ({
|
|
|
4272
4270
|
type: Typography.TITLE_SUBSECTION,
|
|
4273
4271
|
className: classNames(isSmall ? 'm-t-1' : 'm-t-2'),
|
|
4274
4272
|
children: title
|
|
4275
|
-
}),
|
|
4273
|
+
}), description ? /*#__PURE__*/jsx(Body, {
|
|
4276
4274
|
as: "span",
|
|
4277
4275
|
type: Typography.BODY_DEFAULT,
|
|
4278
4276
|
className: "m-t-1",
|
|
4279
4277
|
children: description
|
|
4280
|
-
})
|
|
4281
|
-
className: "np-tile__description",
|
|
4282
|
-
children: description
|
|
4283
|
-
})]
|
|
4278
|
+
}) : null]
|
|
4284
4279
|
});
|
|
4285
4280
|
};
|
|
4286
4281
|
Tile.propTypes = {
|
|
@@ -5293,14 +5288,6 @@ LogoWise.defaultProps = {
|
|
|
5293
5288
|
height: "24",
|
|
5294
5289
|
fill: "none"
|
|
5295
5290
|
};
|
|
5296
|
-
const baseUrl = 'https://wise.com/public-resources/assets/logos/wise/';
|
|
5297
|
-
const logoPaths = {
|
|
5298
|
-
WISE: 'brand_logo.svg',
|
|
5299
|
-
WISE_BUSINESS: 'brand_logo_business.svg',
|
|
5300
|
-
WISE_INVERSE: 'brand_logo_inverse.svg',
|
|
5301
|
-
WISE_BUSINESS_INVERSE: 'brand_logo_business_inverse.svg',
|
|
5302
|
-
WISE_FLAG: 'brand_flag.svg'
|
|
5303
|
-
};
|
|
5304
5291
|
const svgPaths = {
|
|
5305
5292
|
WISE: LogoWise,
|
|
5306
5293
|
WISE_BUSINESS: LogoWise,
|
|
@@ -5314,21 +5301,14 @@ const Logo = ({
|
|
|
5314
5301
|
inverse,
|
|
5315
5302
|
type
|
|
5316
5303
|
}) => {
|
|
5317
|
-
const {
|
|
5318
|
-
isModern
|
|
5319
|
-
} = useTheme();
|
|
5320
5304
|
const [clientWidth] = useClientWidth({
|
|
5321
5305
|
ref: isServerSide() ? undefined : window
|
|
5322
5306
|
});
|
|
5323
5307
|
const isSmall = clientWidth < Breakpoint.SMALL;
|
|
5324
|
-
const path = isSmall ? logoPaths['WISE_FLAG'] : logoPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5325
5308
|
const LogoSvg = isSmall ? svgPaths[`WISE_FLAG${inverse ? '_INVERSE' : ''}`] : svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5326
|
-
return
|
|
5327
|
-
className:
|
|
5328
|
-
|
|
5329
|
-
className: classNames('np-logo', className),
|
|
5330
|
-
alt: type === LogoType.WISE ? 'Wise' : 'Wise business',
|
|
5331
|
-
src: `${baseUrl}${path}`
|
|
5309
|
+
return /*#__PURE__*/jsx(LogoSvg, {
|
|
5310
|
+
className: classNames('np-logo-svg', className),
|
|
5311
|
+
alt: type === LogoType.WISE ? 'Wise' : 'Wise business'
|
|
5332
5312
|
});
|
|
5333
5313
|
};
|
|
5334
5314
|
Logo.propTypes = {
|
|
@@ -5500,13 +5480,12 @@ const Stepper = ({
|
|
|
5500
5480
|
children: /*#__PURE__*/jsx("small", {
|
|
5501
5481
|
children: step.label
|
|
5502
5482
|
})
|
|
5503
|
-
}) : /*#__PURE__*/jsx(
|
|
5504
|
-
|
|
5505
|
-
className: "tw-stepper__step-label small",
|
|
5483
|
+
}) : /*#__PURE__*/jsx("span", {
|
|
5484
|
+
className: "tw-stepper__step-label",
|
|
5506
5485
|
children: step.label
|
|
5507
5486
|
});
|
|
5508
5487
|
return /*#__PURE__*/jsx("li", {
|
|
5509
|
-
className: classNames('hidden-xs', 'tw-stepper__step', active
|
|
5488
|
+
className: classNames('hidden-xs', 'tw-stepper__step', active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default', clickable && 'tw-stepper__step--clickable', step.hoverLabel && 'tw-stepper__step--has-tooltip'),
|
|
5510
5489
|
style: isRTL ? {
|
|
5511
5490
|
right: `${index * stepPercentage * 100}%`
|
|
5512
5491
|
} : {
|
|
@@ -5839,7 +5818,7 @@ const Modal = ({
|
|
|
5839
5818
|
});
|
|
5840
5819
|
};
|
|
5841
5820
|
|
|
5842
|
-
const Popover = ({
|
|
5821
|
+
const Popover$1 = ({
|
|
5843
5822
|
children,
|
|
5844
5823
|
className,
|
|
5845
5824
|
content,
|
|
@@ -5893,12 +5872,12 @@ const logActionRequired = ({
|
|
|
5893
5872
|
}) => {
|
|
5894
5873
|
logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
|
|
5895
5874
|
};
|
|
5896
|
-
Popover.defaultProps = {
|
|
5875
|
+
Popover$1.defaultProps = {
|
|
5897
5876
|
className: undefined,
|
|
5898
5877
|
preferredPlacement: Position.RIGHT,
|
|
5899
5878
|
title: undefined
|
|
5900
5879
|
};
|
|
5901
|
-
Popover.propTypes = {
|
|
5880
|
+
Popover$1.propTypes = {
|
|
5902
5881
|
children: PropTypes.node.isRequired,
|
|
5903
5882
|
className: PropTypes.string,
|
|
5904
5883
|
content: PropTypes.node.isRequired,
|
|
@@ -5915,7 +5894,7 @@ const deprecatedPlacements = {
|
|
|
5915
5894
|
[Position.LEFT_TOP]: Position.TOP,
|
|
5916
5895
|
[Position.RIGHT_TOP]: Position.TOP
|
|
5917
5896
|
};
|
|
5918
|
-
var Popover$
|
|
5897
|
+
var Popover$2 = Popover$1;
|
|
5919
5898
|
|
|
5920
5899
|
const Info = ({
|
|
5921
5900
|
className = undefined,
|
|
@@ -5957,7 +5936,7 @@ const Info = ({
|
|
|
5957
5936
|
title: title,
|
|
5958
5937
|
onClose: () => setOpen(false)
|
|
5959
5938
|
})]
|
|
5960
|
-
}) : /*#__PURE__*/jsx(Popover$
|
|
5939
|
+
}) : /*#__PURE__*/jsx(Popover$2, {
|
|
5961
5940
|
content: content,
|
|
5962
5941
|
preferredPlacement: Position.BOTTOM,
|
|
5963
5942
|
title: title,
|
|
@@ -6146,11 +6125,12 @@ function formControlClassNameBase({
|
|
|
6146
6125
|
'np-form-control--size-sm np-text-body-default': size === 'sm',
|
|
6147
6126
|
'np-form-control--size-md np-text-body-large': size === 'md',
|
|
6148
6127
|
'np-form-control--size-lg np-text-title-subsection': size === 'lg'
|
|
6149
|
-
}
|
|
6128
|
+
});
|
|
6150
6129
|
}
|
|
6151
6130
|
|
|
6152
6131
|
const Input = /*#__PURE__*/forwardRef(function Input({
|
|
6153
6132
|
size = 'auto',
|
|
6133
|
+
shape = 'rectangle',
|
|
6154
6134
|
className,
|
|
6155
6135
|
...restProps
|
|
6156
6136
|
}, reference) {
|
|
@@ -6159,7 +6139,10 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6159
6139
|
ref: reference,
|
|
6160
6140
|
className: classNames(className, formControlClassNameBase({
|
|
6161
6141
|
size
|
|
6162
|
-
})
|
|
6142
|
+
}), 'np-input', {
|
|
6143
|
+
'np-input--shape-rectangle': shape === 'rectangle',
|
|
6144
|
+
'np-input--shape-pill': shape === 'pill'
|
|
6145
|
+
})
|
|
6163
6146
|
// eslint-disable-next-line react/forbid-dom-props
|
|
6164
6147
|
,
|
|
6165
6148
|
style: inputPaddings,
|
|
@@ -6167,6 +6150,653 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6167
6150
|
});
|
|
6168
6151
|
});
|
|
6169
6152
|
|
|
6153
|
+
const SearchInput = /*#__PURE__*/forwardRef(function SearchInput({
|
|
6154
|
+
shape = 'pill',
|
|
6155
|
+
disabled,
|
|
6156
|
+
className,
|
|
6157
|
+
...restProps
|
|
6158
|
+
}, ref) {
|
|
6159
|
+
return /*#__PURE__*/jsx(InputGroup, {
|
|
6160
|
+
addonStart: {
|
|
6161
|
+
content: /*#__PURE__*/jsx(Search, {
|
|
6162
|
+
size: 24
|
|
6163
|
+
}),
|
|
6164
|
+
initialContentWidth: 24
|
|
6165
|
+
},
|
|
6166
|
+
disabled: disabled,
|
|
6167
|
+
className: className,
|
|
6168
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
6169
|
+
ref: ref,
|
|
6170
|
+
role: "searchbox",
|
|
6171
|
+
inputMode: "search",
|
|
6172
|
+
shape: shape,
|
|
6173
|
+
...restProps
|
|
6174
|
+
})
|
|
6175
|
+
});
|
|
6176
|
+
});
|
|
6177
|
+
|
|
6178
|
+
function useMedia(query) {
|
|
6179
|
+
return useSyncExternalStore(onStoreChange => {
|
|
6180
|
+
const mediaQueryList = window.matchMedia(query);
|
|
6181
|
+
mediaQueryList.addEventListener('change', onStoreChange);
|
|
6182
|
+
return () => {
|
|
6183
|
+
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
6184
|
+
};
|
|
6185
|
+
}, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
|
|
6186
|
+
}
|
|
6187
|
+
|
|
6188
|
+
function useScreenSize(size) {
|
|
6189
|
+
return useMedia(`(min-width: ${size}px)`);
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6192
|
+
function wrapInFragment(value) {
|
|
6193
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
6194
|
+
children: value
|
|
6195
|
+
});
|
|
6196
|
+
}
|
|
6197
|
+
|
|
6198
|
+
function PreventScroll() {
|
|
6199
|
+
usePreventScroll();
|
|
6200
|
+
return null;
|
|
6201
|
+
}
|
|
6202
|
+
|
|
6203
|
+
function BottomSheet({
|
|
6204
|
+
open,
|
|
6205
|
+
renderTrigger,
|
|
6206
|
+
title,
|
|
6207
|
+
initialFocusRef,
|
|
6208
|
+
padding = 'md',
|
|
6209
|
+
children,
|
|
6210
|
+
onClose
|
|
6211
|
+
}) {
|
|
6212
|
+
const {
|
|
6213
|
+
refs,
|
|
6214
|
+
context
|
|
6215
|
+
} = useFloating({
|
|
6216
|
+
open,
|
|
6217
|
+
onOpenChange: value => {
|
|
6218
|
+
if (!value) {
|
|
6219
|
+
onClose?.();
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
6222
|
+
});
|
|
6223
|
+
const dismiss = useDismiss(context, {
|
|
6224
|
+
outsidePressEvent: 'mousedown'
|
|
6225
|
+
});
|
|
6226
|
+
const role = useRole(context);
|
|
6227
|
+
const {
|
|
6228
|
+
getReferenceProps,
|
|
6229
|
+
getFloatingProps
|
|
6230
|
+
} = useInteractions([dismiss, role]);
|
|
6231
|
+
const [floatingKey, setFloatingKey] = useState(0);
|
|
6232
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
6233
|
+
children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger?.({
|
|
6234
|
+
ref: refs.setReference,
|
|
6235
|
+
getInteractionProps: getReferenceProps
|
|
6236
|
+
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6237
|
+
children: /*#__PURE__*/jsxs(Transition, {
|
|
6238
|
+
show: open,
|
|
6239
|
+
className: "np-bottom-sheet-v2-container",
|
|
6240
|
+
beforeEnter: () => {
|
|
6241
|
+
setFloatingKey(prev => prev + 1);
|
|
6242
|
+
},
|
|
6243
|
+
children: [/*#__PURE__*/jsx(Transition.Child, {
|
|
6244
|
+
enter: "np-bottom-sheet-v2-backdrop-container--enter",
|
|
6245
|
+
enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
|
|
6246
|
+
leave: "np-bottom-sheet-v2-backdrop-container--leave",
|
|
6247
|
+
leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
|
|
6248
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6249
|
+
className: "np-bottom-sheet-v2-backdrop"
|
|
6250
|
+
})
|
|
6251
|
+
}), /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6252
|
+
context: context,
|
|
6253
|
+
initialFocus: initialFocusRef,
|
|
6254
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6255
|
+
className: "np-bottom-sheet-v2",
|
|
6256
|
+
children: /*#__PURE__*/jsx(Transition.Child, {
|
|
6257
|
+
className: "np-bottom-sheet-v2-content",
|
|
6258
|
+
enter: "np-bottom-sheet-v2-content--enter",
|
|
6259
|
+
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
6260
|
+
leave: "np-bottom-sheet-v2-content--leave",
|
|
6261
|
+
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
6262
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
6263
|
+
// Force inner state invalidation on open
|
|
6264
|
+
ref: refs.setFloating,
|
|
6265
|
+
className: "np-bottom-sheet-v2-content-inner-container",
|
|
6266
|
+
...getFloatingProps(),
|
|
6267
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
6268
|
+
className: "np-bottom-sheet-v2-header",
|
|
6269
|
+
children: /*#__PURE__*/jsx(CloseButton, {
|
|
6270
|
+
size: Size.SMALL,
|
|
6271
|
+
onClick: () => {
|
|
6272
|
+
onClose?.();
|
|
6273
|
+
}
|
|
6274
|
+
})
|
|
6275
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
6276
|
+
className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
|
|
6277
|
+
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
|
|
6278
|
+
}),
|
|
6279
|
+
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
6280
|
+
className: "np-bottom-sheet-v2-title np-text-title-body",
|
|
6281
|
+
children: title
|
|
6282
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
6283
|
+
className: "np-bottom-sheet-v2-body np-text-body-default",
|
|
6284
|
+
children: children
|
|
6285
|
+
})]
|
|
6286
|
+
})]
|
|
6287
|
+
}, floatingKey)
|
|
6288
|
+
})
|
|
6289
|
+
})
|
|
6290
|
+
})]
|
|
6291
|
+
})
|
|
6292
|
+
})]
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
6295
|
+
|
|
6296
|
+
const ButtonInput = /*#__PURE__*/forwardRef(function ButtonInput({
|
|
6297
|
+
size = 'md',
|
|
6298
|
+
className,
|
|
6299
|
+
style,
|
|
6300
|
+
...restProps
|
|
6301
|
+
}, ref) {
|
|
6302
|
+
const inputPaddings = useInputPaddings();
|
|
6303
|
+
return /*#__PURE__*/jsx("button", {
|
|
6304
|
+
ref: ref,
|
|
6305
|
+
type: "button",
|
|
6306
|
+
className: classNames(className, formControlClassNameBase({
|
|
6307
|
+
size
|
|
6308
|
+
}), 'np-button-input')
|
|
6309
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
6310
|
+
,
|
|
6311
|
+
style: {
|
|
6312
|
+
...inputPaddings,
|
|
6313
|
+
...style
|
|
6314
|
+
},
|
|
6315
|
+
...restProps
|
|
6316
|
+
});
|
|
6317
|
+
});
|
|
6318
|
+
|
|
6319
|
+
const floatingPadding = 16;
|
|
6320
|
+
function Popover({
|
|
6321
|
+
placement,
|
|
6322
|
+
open,
|
|
6323
|
+
renderTrigger,
|
|
6324
|
+
title,
|
|
6325
|
+
padding = 'md',
|
|
6326
|
+
children,
|
|
6327
|
+
onClose
|
|
6328
|
+
}) {
|
|
6329
|
+
const {
|
|
6330
|
+
refs,
|
|
6331
|
+
floatingStyles,
|
|
6332
|
+
context
|
|
6333
|
+
} = useFloating({
|
|
6334
|
+
placement,
|
|
6335
|
+
middleware: [offset(8), flip({
|
|
6336
|
+
padding: floatingPadding,
|
|
6337
|
+
crossAxis: false
|
|
6338
|
+
}), shift(), size({
|
|
6339
|
+
padding: floatingPadding,
|
|
6340
|
+
apply: ({
|
|
6341
|
+
elements,
|
|
6342
|
+
rects,
|
|
6343
|
+
availableHeight
|
|
6344
|
+
}) => {
|
|
6345
|
+
elements.floating.style.setProperty('--max-height', `${availableHeight}px`);
|
|
6346
|
+
elements.floating.style.setProperty('--width', `${rects.reference.width}px`);
|
|
6347
|
+
}
|
|
6348
|
+
})],
|
|
6349
|
+
whileElementsMounted: autoUpdate,
|
|
6350
|
+
open,
|
|
6351
|
+
onOpenChange: value => {
|
|
6352
|
+
if (!value) {
|
|
6353
|
+
onClose?.();
|
|
6354
|
+
}
|
|
6355
|
+
}
|
|
6356
|
+
});
|
|
6357
|
+
const dismiss = useDismiss(context, {
|
|
6358
|
+
outsidePressEvent: 'mousedown'
|
|
6359
|
+
});
|
|
6360
|
+
const role = useRole(context);
|
|
6361
|
+
const {
|
|
6362
|
+
getReferenceProps,
|
|
6363
|
+
getFloatingProps
|
|
6364
|
+
} = useInteractions([role, dismiss]);
|
|
6365
|
+
const [floatingKey, setFloatingKey] = useState(0);
|
|
6366
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
6367
|
+
children: [open ? /*#__PURE__*/jsx(PreventScroll, {}) : null, renderTrigger({
|
|
6368
|
+
ref: refs.setReference,
|
|
6369
|
+
getInteractionProps: getReferenceProps
|
|
6370
|
+
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6371
|
+
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6372
|
+
context: context,
|
|
6373
|
+
children: /*#__PURE__*/jsx(Transition, {
|
|
6374
|
+
show: open,
|
|
6375
|
+
leave: "transition-opacity",
|
|
6376
|
+
leaveTo: "opacity-0",
|
|
6377
|
+
beforeEnter: () => {
|
|
6378
|
+
setFloatingKey(prev => prev + 1);
|
|
6379
|
+
},
|
|
6380
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6381
|
+
// Force inner state invalidation on open
|
|
6382
|
+
ref: refs.setFloating,
|
|
6383
|
+
className: "np-popover-v2-container"
|
|
6384
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
6385
|
+
,
|
|
6386
|
+
style: floatingStyles,
|
|
6387
|
+
...getFloatingProps(),
|
|
6388
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
6389
|
+
className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
|
|
6390
|
+
'np-popover-v2--padding-md': padding === 'md'
|
|
6391
|
+
}),
|
|
6392
|
+
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
6393
|
+
className: "np-popover-v2-title np-text-title-body",
|
|
6394
|
+
children: title
|
|
6395
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
6396
|
+
className: "np-popover-v2-content np-text-body-default",
|
|
6397
|
+
children: children
|
|
6398
|
+
})]
|
|
6399
|
+
})
|
|
6400
|
+
}, floatingKey)
|
|
6401
|
+
})
|
|
6402
|
+
})
|
|
6403
|
+
})]
|
|
6404
|
+
});
|
|
6405
|
+
}
|
|
6406
|
+
|
|
6407
|
+
function searchableString(value) {
|
|
6408
|
+
return value.trim().replace(/\s+/gu, ' ').toLowerCase();
|
|
6409
|
+
}
|
|
6410
|
+
function inferSearchableStrings(value) {
|
|
6411
|
+
if (typeof value === 'string') {
|
|
6412
|
+
return [searchableString(value)];
|
|
6413
|
+
}
|
|
6414
|
+
if (typeof value === 'object' && value != null) {
|
|
6415
|
+
return Object.values(value).filter(innerValue => typeof innerValue === 'string').map(innerValue => searchableString(innerValue));
|
|
6416
|
+
}
|
|
6417
|
+
return [];
|
|
6418
|
+
}
|
|
6419
|
+
const SelectInputHasValueContext = /*#__PURE__*/createContext(false);
|
|
6420
|
+
const SelectInputOptionContentCompactContext = /*#__PURE__*/createContext(false);
|
|
6421
|
+
function dedupeSelectInputOptionItem(item, existingValues) {
|
|
6422
|
+
if (existingValues.has(item.value)) {
|
|
6423
|
+
return {
|
|
6424
|
+
...item,
|
|
6425
|
+
value: undefined
|
|
6426
|
+
};
|
|
6427
|
+
}
|
|
6428
|
+
existingValues.add(item.value);
|
|
6429
|
+
return item;
|
|
6430
|
+
}
|
|
6431
|
+
function dedupeSelectInputItems(items) {
|
|
6432
|
+
const existingValues = new Set();
|
|
6433
|
+
return items.map(item => {
|
|
6434
|
+
switch (item.type) {
|
|
6435
|
+
case 'option':
|
|
6436
|
+
{
|
|
6437
|
+
return dedupeSelectInputOptionItem(item, existingValues);
|
|
6438
|
+
}
|
|
6439
|
+
case 'group':
|
|
6440
|
+
{
|
|
6441
|
+
return {
|
|
6442
|
+
...item,
|
|
6443
|
+
options: item.options.map(option => dedupeSelectInputOptionItem(option, existingValues))
|
|
6444
|
+
};
|
|
6445
|
+
}
|
|
6446
|
+
}
|
|
6447
|
+
return item;
|
|
6448
|
+
});
|
|
6449
|
+
}
|
|
6450
|
+
function SelectInput({
|
|
6451
|
+
name,
|
|
6452
|
+
placeholder,
|
|
6453
|
+
items,
|
|
6454
|
+
defaultValue,
|
|
6455
|
+
value: controlledValue,
|
|
6456
|
+
renderValue = wrapInFragment,
|
|
6457
|
+
compareValues,
|
|
6458
|
+
filterable,
|
|
6459
|
+
filterPlaceholder,
|
|
6460
|
+
disabled,
|
|
6461
|
+
className,
|
|
6462
|
+
onChange,
|
|
6463
|
+
onClear
|
|
6464
|
+
}) {
|
|
6465
|
+
const intl = useIntl();
|
|
6466
|
+
const [open, setOpen] = useState(false);
|
|
6467
|
+
const triggerRef = useRef(null);
|
|
6468
|
+
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
6469
|
+
const OptionsOverlay = screenSm ? Popover : BottomSheet;
|
|
6470
|
+
const searchInputRef = useRef(null);
|
|
6471
|
+
const listboxRef = useRef(null);
|
|
6472
|
+
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
6473
|
+
return /*#__PURE__*/jsx(Listbox, {
|
|
6474
|
+
name: name,
|
|
6475
|
+
defaultValue: defaultValue,
|
|
6476
|
+
value: controlledValue
|
|
6477
|
+
// TODO: Remove assertion when upgrading TypeScript to v5
|
|
6478
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
6479
|
+
,
|
|
6480
|
+
by: compareValues,
|
|
6481
|
+
disabled: disabled,
|
|
6482
|
+
onChange: value => {
|
|
6483
|
+
setOpen(false);
|
|
6484
|
+
onChange?.(value);
|
|
6485
|
+
},
|
|
6486
|
+
children: ({
|
|
6487
|
+
disabled: uiDisabled,
|
|
6488
|
+
value
|
|
6489
|
+
}) => /*#__PURE__*/jsx(SelectInputHasValueContext.Provider, {
|
|
6490
|
+
value: value != null,
|
|
6491
|
+
children: /*#__PURE__*/jsx(InputGroup, {
|
|
6492
|
+
addonEnd: {
|
|
6493
|
+
content: /*#__PURE__*/jsxs("span", {
|
|
6494
|
+
className: classNames('np-select-input-addon-container', uiDisabled && 'disabled'),
|
|
6495
|
+
children: [onClear != null && value != null ? /*#__PURE__*/jsxs(Fragment, {
|
|
6496
|
+
children: [/*#__PURE__*/jsx("button", {
|
|
6497
|
+
type: "button",
|
|
6498
|
+
"aria-label": intl.formatMessage(messages$4.ariaLabel),
|
|
6499
|
+
disabled: uiDisabled,
|
|
6500
|
+
className: "np-select-input-addon np-select-input-addon--interactive",
|
|
6501
|
+
onClick: event => {
|
|
6502
|
+
event.preventDefault();
|
|
6503
|
+
onClear();
|
|
6504
|
+
triggerRef.current?.focus({
|
|
6505
|
+
preventScroll: true
|
|
6506
|
+
});
|
|
6507
|
+
},
|
|
6508
|
+
children: /*#__PURE__*/jsx(Cross, {
|
|
6509
|
+
size: 16
|
|
6510
|
+
})
|
|
6511
|
+
}), /*#__PURE__*/jsx("span", {
|
|
6512
|
+
className: "np-select-input-addon-separator"
|
|
6513
|
+
})]
|
|
6514
|
+
}) : null, /*#__PURE__*/jsx("span", {
|
|
6515
|
+
className: "np-select-input-addon",
|
|
6516
|
+
children: /*#__PURE__*/jsx(ChevronDown, {
|
|
6517
|
+
size: 16
|
|
6518
|
+
})
|
|
6519
|
+
})]
|
|
6520
|
+
}),
|
|
6521
|
+
padding: 'sm'
|
|
6522
|
+
},
|
|
6523
|
+
className: className,
|
|
6524
|
+
children: /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6525
|
+
open: open,
|
|
6526
|
+
renderTrigger: ({
|
|
6527
|
+
ref,
|
|
6528
|
+
getInteractionProps
|
|
6529
|
+
}) => /*#__PURE__*/jsx(Listbox.Button, {
|
|
6530
|
+
ref: mergeRefs([ref, triggerRef]),
|
|
6531
|
+
as: SelectInputButton,
|
|
6532
|
+
overrides: getInteractionProps(),
|
|
6533
|
+
onClick: () => {
|
|
6534
|
+
setOpen(prev => !prev);
|
|
6535
|
+
},
|
|
6536
|
+
children: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentCompactContext.Provider, {
|
|
6537
|
+
value: true,
|
|
6538
|
+
children: renderValue(value, true)
|
|
6539
|
+
}) : /*#__PURE__*/jsx("span", {
|
|
6540
|
+
className: "np-select-input-placeholder",
|
|
6541
|
+
children: placeholder
|
|
6542
|
+
})
|
|
6543
|
+
}),
|
|
6544
|
+
initialFocusRef: controllerRef,
|
|
6545
|
+
padding: "none",
|
|
6546
|
+
onClose: () => {
|
|
6547
|
+
setOpen(false);
|
|
6548
|
+
},
|
|
6549
|
+
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6550
|
+
items: items,
|
|
6551
|
+
renderValue: renderValue,
|
|
6552
|
+
filterable: filterable,
|
|
6553
|
+
filterPlaceholder: filterPlaceholder,
|
|
6554
|
+
searchInputRef: searchInputRef,
|
|
6555
|
+
listboxRef: listboxRef
|
|
6556
|
+
})
|
|
6557
|
+
})
|
|
6558
|
+
})
|
|
6559
|
+
})
|
|
6560
|
+
});
|
|
6561
|
+
}
|
|
6562
|
+
const SelectInputButton = /*#__PURE__*/forwardRef(function SelectInputButton({
|
|
6563
|
+
overrides,
|
|
6564
|
+
...restProps
|
|
6565
|
+
}, ref) {
|
|
6566
|
+
return /*#__PURE__*/jsx(ButtonInput, {
|
|
6567
|
+
ref: ref,
|
|
6568
|
+
...restProps,
|
|
6569
|
+
...overrides
|
|
6570
|
+
});
|
|
6571
|
+
});
|
|
6572
|
+
const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInputOptionsContainer({
|
|
6573
|
+
'aria-orientation': ariaOrientation,
|
|
6574
|
+
'aria-activedescendant': ariaActiveDescendant,
|
|
6575
|
+
role,
|
|
6576
|
+
tabIndex,
|
|
6577
|
+
onAriaActiveDescendantChange,
|
|
6578
|
+
onKeyDown,
|
|
6579
|
+
...restProps
|
|
6580
|
+
}, ref) {
|
|
6581
|
+
const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);
|
|
6582
|
+
useEffect(() => {
|
|
6583
|
+
handleAriaActiveDescendantChange(ariaActiveDescendant);
|
|
6584
|
+
}, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
|
|
6585
|
+
return (
|
|
6586
|
+
/*#__PURE__*/
|
|
6587
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
6588
|
+
jsx("div", {
|
|
6589
|
+
ref: ref,
|
|
6590
|
+
onKeyDown: event => {
|
|
6591
|
+
// Prevent absorbing dismissal requests too early
|
|
6592
|
+
if (event.key !== 'Escape') {
|
|
6593
|
+
onKeyDown?.(event);
|
|
6594
|
+
}
|
|
6595
|
+
},
|
|
6596
|
+
...restProps
|
|
6597
|
+
})
|
|
6598
|
+
);
|
|
6599
|
+
});
|
|
6600
|
+
function SelectInputOptions({
|
|
6601
|
+
items,
|
|
6602
|
+
renderValue = wrapInFragment,
|
|
6603
|
+
filterable,
|
|
6604
|
+
filterPlaceholder,
|
|
6605
|
+
searchInputRef,
|
|
6606
|
+
listboxRef
|
|
6607
|
+
}) {
|
|
6608
|
+
const [query, setQuery] = useState('');
|
|
6609
|
+
const needle = useMemo(() => query ? searchableString(query) : null, [query]);
|
|
6610
|
+
const listboxContainerRef = useRef(null);
|
|
6611
|
+
useEffect(() => {
|
|
6612
|
+
if (listboxContainerRef.current != null) {
|
|
6613
|
+
listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
|
|
6614
|
+
}
|
|
6615
|
+
}, []);
|
|
6616
|
+
const listboxId = useId();
|
|
6617
|
+
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
6618
|
+
return /*#__PURE__*/jsxs(Listbox.Options, {
|
|
6619
|
+
as: SelectInputOptionsContainer,
|
|
6620
|
+
static: true,
|
|
6621
|
+
className: "np-select-input-options-container",
|
|
6622
|
+
onAriaActiveDescendantChange: value => {
|
|
6623
|
+
if (controllerRef.current != null) {
|
|
6624
|
+
if (value != null) {
|
|
6625
|
+
controllerRef.current.setAttribute('aria-activedescendant', value);
|
|
6626
|
+
} else {
|
|
6627
|
+
controllerRef.current.removeAttribute('aria-activedescendant');
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
},
|
|
6631
|
+
children: [filterable ? /*#__PURE__*/jsx("div", {
|
|
6632
|
+
className: "np-select-input-query-container",
|
|
6633
|
+
children: /*#__PURE__*/jsx(SearchInput, {
|
|
6634
|
+
ref: searchInputRef,
|
|
6635
|
+
shape: "rectangle",
|
|
6636
|
+
placeholder: filterPlaceholder,
|
|
6637
|
+
value: query,
|
|
6638
|
+
"aria-controls": listboxId,
|
|
6639
|
+
onKeyDown: event => {
|
|
6640
|
+
// Prevent interfering with the matcher of Headless UI
|
|
6641
|
+
// https://mathiasbynens.be/notes/javascript-unicode#regex
|
|
6642
|
+
if (/^.$/u.test(event.key)) {
|
|
6643
|
+
event.stopPropagation();
|
|
6644
|
+
}
|
|
6645
|
+
},
|
|
6646
|
+
onChange: event => {
|
|
6647
|
+
setQuery(event.currentTarget.value);
|
|
6648
|
+
}
|
|
6649
|
+
})
|
|
6650
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
6651
|
+
ref: listboxContainerRef,
|
|
6652
|
+
className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
6653
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6654
|
+
ref: listboxRef,
|
|
6655
|
+
id: listboxId,
|
|
6656
|
+
role: "listbox",
|
|
6657
|
+
"aria-orientation": "vertical",
|
|
6658
|
+
tabIndex: 0,
|
|
6659
|
+
className: "np-select-input-listbox",
|
|
6660
|
+
children: (needle == null ? items : dedupeSelectInputItems(items)).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
6661
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
6662
|
+
, {
|
|
6663
|
+
item: item,
|
|
6664
|
+
renderValue: renderValue,
|
|
6665
|
+
needle: needle
|
|
6666
|
+
}, index))
|
|
6667
|
+
})
|
|
6668
|
+
})]
|
|
6669
|
+
});
|
|
6670
|
+
}
|
|
6671
|
+
function SelectInputItemView({
|
|
6672
|
+
item,
|
|
6673
|
+
renderValue,
|
|
6674
|
+
needle
|
|
6675
|
+
}) {
|
|
6676
|
+
switch (item.type) {
|
|
6677
|
+
case 'option':
|
|
6678
|
+
{
|
|
6679
|
+
if (item.value != null && (!needle || inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle)))) {
|
|
6680
|
+
return /*#__PURE__*/jsx(SelectInputOption, {
|
|
6681
|
+
value: item.value,
|
|
6682
|
+
disabled: item.disabled,
|
|
6683
|
+
children: renderValue(item.value, false)
|
|
6684
|
+
});
|
|
6685
|
+
}
|
|
6686
|
+
break;
|
|
6687
|
+
}
|
|
6688
|
+
case 'group':
|
|
6689
|
+
{
|
|
6690
|
+
return /*#__PURE__*/jsx(SelectInputGroupItemView, {
|
|
6691
|
+
item: item,
|
|
6692
|
+
renderValue: renderValue,
|
|
6693
|
+
needle: needle
|
|
6694
|
+
});
|
|
6695
|
+
}
|
|
6696
|
+
case 'separator':
|
|
6697
|
+
{
|
|
6698
|
+
if (needle == null) {
|
|
6699
|
+
return /*#__PURE__*/jsx("hr", {
|
|
6700
|
+
className: "np-select-input-separator-item",
|
|
6701
|
+
"aria-hidden": true
|
|
6702
|
+
});
|
|
6703
|
+
}
|
|
6704
|
+
break;
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
return null;
|
|
6708
|
+
}
|
|
6709
|
+
function SelectInputGroupItemView({
|
|
6710
|
+
item,
|
|
6711
|
+
renderValue,
|
|
6712
|
+
needle
|
|
6713
|
+
}) {
|
|
6714
|
+
const headerId = useId();
|
|
6715
|
+
return (
|
|
6716
|
+
/*#__PURE__*/
|
|
6717
|
+
// An empty container may be rendered when no options match `needle`
|
|
6718
|
+
// However, pre-filtering would result in worse performance overall
|
|
6719
|
+
jsxs("section", {
|
|
6720
|
+
role: "group",
|
|
6721
|
+
"aria-labelledby": headerId,
|
|
6722
|
+
className: classNames(needle == null && 'np-select-input-group-item--without-needle'),
|
|
6723
|
+
children: [needle == null ? /*#__PURE__*/jsx("header", {
|
|
6724
|
+
id: headerId,
|
|
6725
|
+
role: "presentation",
|
|
6726
|
+
className: "np-select-input-group-item-header np-text-title-group",
|
|
6727
|
+
children: item.label
|
|
6728
|
+
}) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
6729
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
6730
|
+
, {
|
|
6731
|
+
item: option,
|
|
6732
|
+
renderValue: renderValue,
|
|
6733
|
+
needle: needle
|
|
6734
|
+
}, index))]
|
|
6735
|
+
})
|
|
6736
|
+
);
|
|
6737
|
+
}
|
|
6738
|
+
function SelectInputOption({
|
|
6739
|
+
value,
|
|
6740
|
+
disabled,
|
|
6741
|
+
children
|
|
6742
|
+
}) {
|
|
6743
|
+
const parentHasValue = useContext(SelectInputHasValueContext);
|
|
6744
|
+
// Avoid flash during exit transition
|
|
6745
|
+
const {
|
|
6746
|
+
current: cachedParentHasValue
|
|
6747
|
+
} = useRef(parentHasValue);
|
|
6748
|
+
return /*#__PURE__*/jsx(Listbox.Option, {
|
|
6749
|
+
as: "div",
|
|
6750
|
+
value: value,
|
|
6751
|
+
disabled: disabled,
|
|
6752
|
+
className: ({
|
|
6753
|
+
active,
|
|
6754
|
+
disabled: uiDisabled
|
|
6755
|
+
}) => classNames('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
|
|
6756
|
+
children: ({
|
|
6757
|
+
selected
|
|
6758
|
+
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
6759
|
+
children: [cachedParentHasValue ? /*#__PURE__*/jsx(Check, {
|
|
6760
|
+
size: 16,
|
|
6761
|
+
className: classNames(!selected && 'np-select-input-option-check--not-selected')
|
|
6762
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
6763
|
+
className: "np-select-input-option",
|
|
6764
|
+
children: children
|
|
6765
|
+
})]
|
|
6766
|
+
})
|
|
6767
|
+
});
|
|
6768
|
+
}
|
|
6769
|
+
function SelectInputOptionContent({
|
|
6770
|
+
title,
|
|
6771
|
+
note,
|
|
6772
|
+
description,
|
|
6773
|
+
icon
|
|
6774
|
+
}) {
|
|
6775
|
+
const compact = useContext(SelectInputOptionContentCompactContext);
|
|
6776
|
+
return /*#__PURE__*/jsxs("div", {
|
|
6777
|
+
className: "np-select-input-option-content-container np-text-body-large",
|
|
6778
|
+
children: [icon ? /*#__PURE__*/jsx("div", {
|
|
6779
|
+
className: classNames('np-select-input-option-content-icon', !compact && 'np-select-input-option-content-icon--not-compact'),
|
|
6780
|
+
children: icon
|
|
6781
|
+
}) : null, /*#__PURE__*/jsxs("div", {
|
|
6782
|
+
className: "np-select-input-option-content-text",
|
|
6783
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
6784
|
+
className: classNames('np-select-input-option-content-text-line-1', compact && 'np-select-input-option-content-text-compact'),
|
|
6785
|
+
children: [/*#__PURE__*/jsx("h4", {
|
|
6786
|
+
className: "d-inline np-text-body-large",
|
|
6787
|
+
children: title
|
|
6788
|
+
}), note ? /*#__PURE__*/jsx("span", {
|
|
6789
|
+
className: "np-select-input-option-content-text-secondary np-text-body-default",
|
|
6790
|
+
children: note
|
|
6791
|
+
}) : null]
|
|
6792
|
+
}), description ? /*#__PURE__*/jsx("div", {
|
|
6793
|
+
className: classNames('np-select-input-option-content-text-secondary np-text-body-default', compact && 'np-select-input-option-content-text-compact'),
|
|
6794
|
+
children: description
|
|
6795
|
+
}) : null]
|
|
6796
|
+
})]
|
|
6797
|
+
});
|
|
6798
|
+
}
|
|
6799
|
+
|
|
6170
6800
|
const TextArea = /*#__PURE__*/forwardRef(function TextArea({
|
|
6171
6801
|
className,
|
|
6172
6802
|
...restProps
|
|
@@ -7282,7 +7912,7 @@ function Select({
|
|
|
7282
7912
|
headerTitle: searchPlaceholder || formatMessage(messages$3.searchPlaceholder),
|
|
7283
7913
|
onClose: handleCloseOptions,
|
|
7284
7914
|
children: renderOptionsList()
|
|
7285
|
-
}) : /*#__PURE__*/jsx(BottomSheet$
|
|
7915
|
+
}) : /*#__PURE__*/jsx(BottomSheet$2, {
|
|
7286
7916
|
open: open,
|
|
7287
7917
|
onClose: handleCloseOptions,
|
|
7288
7918
|
children: renderOptionsList({
|
|
@@ -14397,5 +15027,5 @@ const translations = {
|
|
|
14397
15027
|
zh
|
|
14398
15028
|
};
|
|
14399
15029
|
|
|
14400
|
-
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$
|
|
15030
|
+
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 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$2 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, SearchInput, Section, Select, SelectInput, SelectInputOptionContent, 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 };
|
|
14401
15031
|
//# sourceMappingURL=index.esm.js.map
|