@transferwise/components 45.14.1 → 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/i18n/en.json +1 -0
- package/build/index.esm.js +695 -53
- package/build/index.esm.js.map +1 -1
- package/build/index.js +698 -53
- 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/link/Link.d.ts.map +1 -1
- package/build/types/link/Link.messages.d.ts +8 -0
- package/build/types/link/Link.messages.d.ts.map +1 -0
- 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 +28 -22
- package/src/avatar/Avatar.story.tsx +16 -14
- 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/link/Link.messages.ts +8 -0
- package/src/link/Link.tsx +6 -2
- 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/navigationOption/NavigationOption.story.js +3 -5
- package/src/promoCard/PromoCard.css +1 -1
- package/src/radio/Radio.story.js +3 -2
- package/src/radioGroup/RadioGroup.story.js +2 -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';
|
|
@@ -759,7 +764,7 @@ const ActionOption = ({
|
|
|
759
764
|
});
|
|
760
765
|
};
|
|
761
766
|
|
|
762
|
-
var messages$
|
|
767
|
+
var messages$8 = defineMessages({
|
|
763
768
|
ariaLabel: {
|
|
764
769
|
id: "neptune.CloseButton.ariaLabel"
|
|
765
770
|
}
|
|
@@ -775,7 +780,7 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
|
|
|
775
780
|
testId
|
|
776
781
|
}, reference) {
|
|
777
782
|
const intl = useIntl();
|
|
778
|
-
ariaLabel ??= intl.formatMessage(messages$
|
|
783
|
+
ariaLabel ??= intl.formatMessage(messages$8.ariaLabel);
|
|
779
784
|
const Icon = filled ? CrossCircleFill : Cross;
|
|
780
785
|
return /*#__PURE__*/jsx("button", {
|
|
781
786
|
ref: reference,
|
|
@@ -795,6 +800,12 @@ const CloseButton = /*#__PURE__*/forwardRef(function CloseButton({
|
|
|
795
800
|
});
|
|
796
801
|
});
|
|
797
802
|
|
|
803
|
+
var messages$7 = defineMessages({
|
|
804
|
+
opensInNewTab: {
|
|
805
|
+
id: "neptune.Link.opensInNewTab"
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
|
|
798
809
|
const Link = ({
|
|
799
810
|
className,
|
|
800
811
|
children,
|
|
@@ -806,6 +817,9 @@ const Link = ({
|
|
|
806
817
|
...props
|
|
807
818
|
}) => {
|
|
808
819
|
const isBlank = target === '_blank';
|
|
820
|
+
const {
|
|
821
|
+
formatMessage
|
|
822
|
+
} = useIntl();
|
|
809
823
|
return /*#__PURE__*/jsxs("a", {
|
|
810
824
|
href: href,
|
|
811
825
|
target: target,
|
|
@@ -814,7 +828,9 @@ const Link = ({
|
|
|
814
828
|
rel: isBlank ? 'noreferrer' : undefined,
|
|
815
829
|
onClick: onClick,
|
|
816
830
|
...props,
|
|
817
|
-
children: [children, isBlank && /*#__PURE__*/jsx(NavigateAway, {
|
|
831
|
+
children: [children, " ", isBlank && /*#__PURE__*/jsx(NavigateAway, {
|
|
832
|
+
title: formatMessage(messages$7.opensInNewTab)
|
|
833
|
+
})]
|
|
818
834
|
});
|
|
819
835
|
};
|
|
820
836
|
|
|
@@ -1969,7 +1985,7 @@ const MOVE_OFFSET_THRESHOLD = 50;
|
|
|
1969
1985
|
* Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
|
|
1970
1986
|
*
|
|
1971
1987
|
*/
|
|
1972
|
-
const BottomSheet = props => {
|
|
1988
|
+
const BottomSheet$1 = props => {
|
|
1973
1989
|
const bottomSheetReference = useRef(null);
|
|
1974
1990
|
const topBarReference = useRef(null);
|
|
1975
1991
|
const contentReference = useRef(null);
|
|
@@ -2123,7 +2139,7 @@ const BottomSheet = props => {
|
|
|
2123
2139
|
})
|
|
2124
2140
|
});
|
|
2125
2141
|
};
|
|
2126
|
-
var BottomSheet$
|
|
2142
|
+
var BottomSheet$2 = BottomSheet$1;
|
|
2127
2143
|
|
|
2128
2144
|
const typeClassMap$1 = {
|
|
2129
2145
|
[ControlType.ACCENT]: 'btn-accent',
|
|
@@ -3150,7 +3166,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3150
3166
|
isMobile
|
|
3151
3167
|
} = useLayout();
|
|
3152
3168
|
if (isMobile) {
|
|
3153
|
-
return /*#__PURE__*/jsx(BottomSheet$
|
|
3169
|
+
return /*#__PURE__*/jsx(BottomSheet$2, {
|
|
3154
3170
|
open: open,
|
|
3155
3171
|
className: className,
|
|
3156
3172
|
onClose: onClose,
|
|
@@ -4231,21 +4247,14 @@ const Tile = ({
|
|
|
4231
4247
|
title
|
|
4232
4248
|
}) => {
|
|
4233
4249
|
const isSmall = size === Size.SMALL;
|
|
4234
|
-
const {
|
|
4235
|
-
isModern
|
|
4236
|
-
} = useTheme();
|
|
4237
4250
|
const Element = href ? 'a' : 'button';
|
|
4238
4251
|
return /*#__PURE__*/jsxs(Element, {
|
|
4239
4252
|
className: classNames('decision', 'flex-column', 'np-tile', 'text-no-decoration', 'text-xs-center', className, {
|
|
4240
|
-
'p-a-3': !isSmall
|
|
4241
|
-
'p-
|
|
4242
|
-
|
|
4243
|
-
'np-tile--small': isSmall,
|
|
4244
|
-
disabled
|
|
4245
|
-
}),
|
|
4253
|
+
'p-a-3': !isSmall,
|
|
4254
|
+
'p-a-2 np-tile--small': isSmall
|
|
4255
|
+
}, disabled && 'disabled'),
|
|
4246
4256
|
href: href,
|
|
4247
4257
|
target: target,
|
|
4248
|
-
"aria-label": title,
|
|
4249
4258
|
onClick: disabled ? null : onClick,
|
|
4250
4259
|
onKeyDown: disabled ? null : ({
|
|
4251
4260
|
key
|
|
@@ -4261,15 +4270,12 @@ const Tile = ({
|
|
|
4261
4270
|
type: Typography.TITLE_SUBSECTION,
|
|
4262
4271
|
className: classNames(isSmall ? 'm-t-1' : 'm-t-2'),
|
|
4263
4272
|
children: title
|
|
4264
|
-
}),
|
|
4273
|
+
}), description ? /*#__PURE__*/jsx(Body, {
|
|
4265
4274
|
as: "span",
|
|
4266
4275
|
type: Typography.BODY_DEFAULT,
|
|
4267
4276
|
className: "m-t-1",
|
|
4268
4277
|
children: description
|
|
4269
|
-
})
|
|
4270
|
-
className: "np-tile__description",
|
|
4271
|
-
children: description
|
|
4272
|
-
})]
|
|
4278
|
+
}) : null]
|
|
4273
4279
|
});
|
|
4274
4280
|
};
|
|
4275
4281
|
Tile.propTypes = {
|
|
@@ -5282,14 +5288,6 @@ LogoWise.defaultProps = {
|
|
|
5282
5288
|
height: "24",
|
|
5283
5289
|
fill: "none"
|
|
5284
5290
|
};
|
|
5285
|
-
const baseUrl = 'https://wise.com/public-resources/assets/logos/wise/';
|
|
5286
|
-
const logoPaths = {
|
|
5287
|
-
WISE: 'brand_logo.svg',
|
|
5288
|
-
WISE_BUSINESS: 'brand_logo_business.svg',
|
|
5289
|
-
WISE_INVERSE: 'brand_logo_inverse.svg',
|
|
5290
|
-
WISE_BUSINESS_INVERSE: 'brand_logo_business_inverse.svg',
|
|
5291
|
-
WISE_FLAG: 'brand_flag.svg'
|
|
5292
|
-
};
|
|
5293
5291
|
const svgPaths = {
|
|
5294
5292
|
WISE: LogoWise,
|
|
5295
5293
|
WISE_BUSINESS: LogoWise,
|
|
@@ -5303,21 +5301,14 @@ const Logo = ({
|
|
|
5303
5301
|
inverse,
|
|
5304
5302
|
type
|
|
5305
5303
|
}) => {
|
|
5306
|
-
const {
|
|
5307
|
-
isModern
|
|
5308
|
-
} = useTheme();
|
|
5309
5304
|
const [clientWidth] = useClientWidth({
|
|
5310
5305
|
ref: isServerSide() ? undefined : window
|
|
5311
5306
|
});
|
|
5312
5307
|
const isSmall = clientWidth < Breakpoint.SMALL;
|
|
5313
|
-
const path = isSmall ? logoPaths['WISE_FLAG'] : logoPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5314
5308
|
const LogoSvg = isSmall ? svgPaths[`WISE_FLAG${inverse ? '_INVERSE' : ''}`] : svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5315
|
-
return
|
|
5316
|
-
className:
|
|
5317
|
-
|
|
5318
|
-
className: classNames('np-logo', className),
|
|
5319
|
-
alt: type === LogoType.WISE ? 'Wise' : 'Wise business',
|
|
5320
|
-
src: `${baseUrl}${path}`
|
|
5309
|
+
return /*#__PURE__*/jsx(LogoSvg, {
|
|
5310
|
+
className: classNames('np-logo-svg', className),
|
|
5311
|
+
alt: type === LogoType.WISE ? 'Wise' : 'Wise business'
|
|
5321
5312
|
});
|
|
5322
5313
|
};
|
|
5323
5314
|
Logo.propTypes = {
|
|
@@ -5489,13 +5480,12 @@ const Stepper = ({
|
|
|
5489
5480
|
children: /*#__PURE__*/jsx("small", {
|
|
5490
5481
|
children: step.label
|
|
5491
5482
|
})
|
|
5492
|
-
}) : /*#__PURE__*/jsx(
|
|
5493
|
-
|
|
5494
|
-
className: "tw-stepper__step-label small",
|
|
5483
|
+
}) : /*#__PURE__*/jsx("span", {
|
|
5484
|
+
className: "tw-stepper__step-label",
|
|
5495
5485
|
children: step.label
|
|
5496
5486
|
});
|
|
5497
5487
|
return /*#__PURE__*/jsx("li", {
|
|
5498
|
-
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'),
|
|
5499
5489
|
style: isRTL ? {
|
|
5500
5490
|
right: `${index * stepPercentage * 100}%`
|
|
5501
5491
|
} : {
|
|
@@ -5828,7 +5818,7 @@ const Modal = ({
|
|
|
5828
5818
|
});
|
|
5829
5819
|
};
|
|
5830
5820
|
|
|
5831
|
-
const Popover = ({
|
|
5821
|
+
const Popover$1 = ({
|
|
5832
5822
|
children,
|
|
5833
5823
|
className,
|
|
5834
5824
|
content,
|
|
@@ -5882,12 +5872,12 @@ const logActionRequired = ({
|
|
|
5882
5872
|
}) => {
|
|
5883
5873
|
logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
|
|
5884
5874
|
};
|
|
5885
|
-
Popover.defaultProps = {
|
|
5875
|
+
Popover$1.defaultProps = {
|
|
5886
5876
|
className: undefined,
|
|
5887
5877
|
preferredPlacement: Position.RIGHT,
|
|
5888
5878
|
title: undefined
|
|
5889
5879
|
};
|
|
5890
|
-
Popover.propTypes = {
|
|
5880
|
+
Popover$1.propTypes = {
|
|
5891
5881
|
children: PropTypes.node.isRequired,
|
|
5892
5882
|
className: PropTypes.string,
|
|
5893
5883
|
content: PropTypes.node.isRequired,
|
|
@@ -5904,7 +5894,7 @@ const deprecatedPlacements = {
|
|
|
5904
5894
|
[Position.LEFT_TOP]: Position.TOP,
|
|
5905
5895
|
[Position.RIGHT_TOP]: Position.TOP
|
|
5906
5896
|
};
|
|
5907
|
-
var Popover$
|
|
5897
|
+
var Popover$2 = Popover$1;
|
|
5908
5898
|
|
|
5909
5899
|
const Info = ({
|
|
5910
5900
|
className = undefined,
|
|
@@ -5946,7 +5936,7 @@ const Info = ({
|
|
|
5946
5936
|
title: title,
|
|
5947
5937
|
onClose: () => setOpen(false)
|
|
5948
5938
|
})]
|
|
5949
|
-
}) : /*#__PURE__*/jsx(Popover$
|
|
5939
|
+
}) : /*#__PURE__*/jsx(Popover$2, {
|
|
5950
5940
|
content: content,
|
|
5951
5941
|
preferredPlacement: Position.BOTTOM,
|
|
5952
5942
|
title: title,
|
|
@@ -6135,11 +6125,12 @@ function formControlClassNameBase({
|
|
|
6135
6125
|
'np-form-control--size-sm np-text-body-default': size === 'sm',
|
|
6136
6126
|
'np-form-control--size-md np-text-body-large': size === 'md',
|
|
6137
6127
|
'np-form-control--size-lg np-text-title-subsection': size === 'lg'
|
|
6138
|
-
}
|
|
6128
|
+
});
|
|
6139
6129
|
}
|
|
6140
6130
|
|
|
6141
6131
|
const Input = /*#__PURE__*/forwardRef(function Input({
|
|
6142
6132
|
size = 'auto',
|
|
6133
|
+
shape = 'rectangle',
|
|
6143
6134
|
className,
|
|
6144
6135
|
...restProps
|
|
6145
6136
|
}, reference) {
|
|
@@ -6148,7 +6139,10 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6148
6139
|
ref: reference,
|
|
6149
6140
|
className: classNames(className, formControlClassNameBase({
|
|
6150
6141
|
size
|
|
6151
|
-
})
|
|
6142
|
+
}), 'np-input', {
|
|
6143
|
+
'np-input--shape-rectangle': shape === 'rectangle',
|
|
6144
|
+
'np-input--shape-pill': shape === 'pill'
|
|
6145
|
+
})
|
|
6152
6146
|
// eslint-disable-next-line react/forbid-dom-props
|
|
6153
6147
|
,
|
|
6154
6148
|
style: inputPaddings,
|
|
@@ -6156,6 +6150,653 @@ const Input = /*#__PURE__*/forwardRef(function Input({
|
|
|
6156
6150
|
});
|
|
6157
6151
|
});
|
|
6158
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
|
+
|
|
6159
6800
|
const TextArea = /*#__PURE__*/forwardRef(function TextArea({
|
|
6160
6801
|
className,
|
|
6161
6802
|
...restProps
|
|
@@ -7271,7 +7912,7 @@ function Select({
|
|
|
7271
7912
|
headerTitle: searchPlaceholder || formatMessage(messages$3.searchPlaceholder),
|
|
7272
7913
|
onClose: handleCloseOptions,
|
|
7273
7914
|
children: renderOptionsList()
|
|
7274
|
-
}) : /*#__PURE__*/jsx(BottomSheet$
|
|
7915
|
+
}) : /*#__PURE__*/jsx(BottomSheet$2, {
|
|
7275
7916
|
open: open,
|
|
7276
7917
|
onClose: handleCloseOptions,
|
|
7277
7918
|
children: renderOptionsList({
|
|
@@ -9927,6 +10568,7 @@ var en = {
|
|
|
9927
10568
|
"neptune.DateInput.day.label": "Day",
|
|
9928
10569
|
"neptune.DateInput.month.label": "Month",
|
|
9929
10570
|
"neptune.DateInput.year.label": "Year",
|
|
10571
|
+
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
9930
10572
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
9931
10573
|
"neptune.Select.searchPlaceholder": "Search...",
|
|
9932
10574
|
"neptune.Summary.statusDone": "Item done",
|
|
@@ -14385,5 +15027,5 @@ const translations = {
|
|
|
14385
15027
|
zh
|
|
14386
15028
|
};
|
|
14387
15029
|
|
|
14388
|
-
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 };
|
|
14389
15031
|
//# sourceMappingURL=index.esm.js.map
|