@transferwise/components 0.0.0-experimental-8b6ee2a → 0.0.0-experimental-6cef414

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.
Files changed (75) hide show
  1. package/build/index.esm.js +669 -13
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +672 -13
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +1 -1
  6. package/build/styles/common/closeButton/CloseButton.css +1 -1
  7. package/build/styles/inputs/Input.css +1 -1
  8. package/build/styles/inputs/InputGroup.css +1 -1
  9. package/build/styles/inputs/SelectInput.css +1 -0
  10. package/build/styles/inputs/TextArea.css +1 -1
  11. package/build/styles/main.css +1 -1
  12. package/build/styles/promoCard/PromoCard.css +1 -1
  13. package/build/types/common/hooks/useMedia.d.ts +2 -0
  14. package/build/types/common/hooks/useMedia.d.ts.map +1 -0
  15. package/build/types/common/hooks/useScreenSize.d.ts +3 -0
  16. package/build/types/common/hooks/useScreenSize.d.ts.map +1 -0
  17. package/build/types/common/preventScroll/PreventScroll.d.ts +2 -0
  18. package/build/types/common/preventScroll/PreventScroll.d.ts.map +1 -0
  19. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts +7 -7
  20. package/build/types/dateLookup/dateTrigger/DateTrigger.messages.d.ts.map +1 -1
  21. package/build/types/index.d.ts +4 -0
  22. package/build/types/index.d.ts.map +1 -1
  23. package/build/types/inputs/Input.d.ts +1 -0
  24. package/build/types/inputs/Input.d.ts.map +1 -1
  25. package/build/types/inputs/SearchInput.d.ts +10 -0
  26. package/build/types/inputs/SearchInput.d.ts.map +1 -0
  27. package/build/types/inputs/SelectInput.d.ts +41 -0
  28. package/build/types/inputs/SelectInput.d.ts.map +1 -0
  29. package/build/types/inputs/_BottomSheet.d.ts +17 -0
  30. package/build/types/inputs/_BottomSheet.d.ts.map +1 -0
  31. package/build/types/inputs/_ButtonInput.d.ts +6 -0
  32. package/build/types/inputs/_ButtonInput.d.ts.map +1 -0
  33. package/build/types/inputs/_Popover.d.ts +18 -0
  34. package/build/types/inputs/_Popover.d.ts.map +1 -0
  35. package/build/types/inputs/_common.d.ts.map +1 -1
  36. package/build/types/utilities/wrapInFragment.d.ts +3 -0
  37. package/build/types/utilities/wrapInFragment.d.ts.map +1 -0
  38. package/package.json +28 -22
  39. package/src/avatar/Avatar.story.tsx +14 -16
  40. package/src/common/closeButton/CloseButton.css +1 -1
  41. package/src/common/hooks/useMedia.ts +15 -0
  42. package/src/common/hooks/useScreenSize.ts +7 -0
  43. package/src/common/preventScroll/PreventScroll.tsx +6 -0
  44. package/src/index.ts +8 -0
  45. package/src/inputs/Input.css +1 -1
  46. package/src/inputs/Input.less +14 -0
  47. package/src/inputs/Input.tsx +6 -2
  48. package/src/inputs/InputGroup.css +1 -1
  49. package/src/inputs/InputGroup.less +5 -0
  50. package/src/inputs/SearchInput.story.tsx +40 -0
  51. package/src/inputs/SearchInput.tsx +35 -0
  52. package/src/inputs/SelectInput.css +1 -0
  53. package/src/inputs/SelectInput.less +183 -0
  54. package/src/inputs/SelectInput.story.tsx +259 -0
  55. package/src/inputs/SelectInput.tsx +565 -0
  56. package/src/inputs/TextArea.css +1 -1
  57. package/src/inputs/TextArea.less +5 -0
  58. package/src/inputs/_BottomSheet.less +107 -0
  59. package/src/inputs/_BottomSheet.tsx +128 -0
  60. package/src/inputs/_ButtonInput.less +7 -0
  61. package/src/inputs/_ButtonInput.tsx +27 -0
  62. package/src/inputs/_Popover.less +38 -0
  63. package/src/inputs/_Popover.tsx +118 -0
  64. package/src/inputs/_common.less +0 -4
  65. package/src/inputs/_common.ts +0 -1
  66. package/src/main.css +1 -1
  67. package/src/main.less +4 -0
  68. package/src/navigationOption/NavigationOption.story.js +5 -3
  69. package/src/promoCard/PromoCard.css +1 -1
  70. package/src/radio/Radio.story.js +2 -3
  71. package/src/radioGroup/RadioGroup.story.js +1 -2
  72. package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +1 -1
  73. package/src/ssr.spec.js +7 -0
  74. package/src/utilities/wrapInFragment.tsx +3 -0
  75. /package/src/dateLookup/dateTrigger/{DateTrigger.messages.js → DateTrigger.messages.ts} +0 -0
package/build/index.js CHANGED
@@ -14,6 +14,11 @@ var reactDom = require('react-dom');
14
14
  var neptuneValidation = require('@transferwise/neptune-validation');
15
15
  var mergeRefs = require('react-merge-refs');
16
16
  var reactPopper = require('react-popper');
17
+ var react$1 = require('@headlessui/react');
18
+ var reactId = require('@radix-ui/react-id');
19
+ var shim = require('use-sync-external-store/shim');
20
+ var react = require('@floating-ui/react');
21
+ var overlays = require('@react-aria/overlays');
17
22
  var art = require('@wise/art');
18
23
  var clamp$2 = require('lodash.clamp');
19
24
  var debounce = require('lodash.debounce');
@@ -2002,7 +2007,7 @@ const MOVE_OFFSET_THRESHOLD = 50;
2002
2007
  * Neptune Web: https://transferwise.github.io/neptune-web/components/overlays/BottomSheet
2003
2008
  *
2004
2009
  */
2005
- const BottomSheet = props => {
2010
+ const BottomSheet$1 = props => {
2006
2011
  const bottomSheetReference = React.useRef(null);
2007
2012
  const topBarReference = React.useRef(null);
2008
2013
  const contentReference = React.useRef(null);
@@ -2156,7 +2161,7 @@ const BottomSheet = props => {
2156
2161
  })
2157
2162
  });
2158
2163
  };
2159
- var BottomSheet$1 = BottomSheet;
2164
+ var BottomSheet$2 = BottomSheet$1;
2160
2165
 
2161
2166
  const typeClassMap$1 = {
2162
2167
  [exports.ControlType.ACCENT]: 'btn-accent',
@@ -3183,7 +3188,7 @@ const ResponsivePanel = /*#__PURE__*/React.forwardRef(({
3183
3188
  isMobile
3184
3189
  } = useLayout();
3185
3190
  if (isMobile) {
3186
- return /*#__PURE__*/jsxRuntime.jsx(BottomSheet$1, {
3191
+ return /*#__PURE__*/jsxRuntime.jsx(BottomSheet$2, {
3187
3192
  open: open,
3188
3193
  className: className,
3189
3194
  onClose: onClose,
@@ -5861,7 +5866,7 @@ const Modal = ({
5861
5866
  });
5862
5867
  };
5863
5868
 
5864
- const Popover = ({
5869
+ const Popover$1 = ({
5865
5870
  children,
5866
5871
  className,
5867
5872
  content,
@@ -5915,12 +5920,12 @@ const logActionRequired = ({
5915
5920
  }) => {
5916
5921
  logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
5917
5922
  };
5918
- Popover.defaultProps = {
5923
+ Popover$1.defaultProps = {
5919
5924
  className: undefined,
5920
5925
  preferredPlacement: exports.Position.RIGHT,
5921
5926
  title: undefined
5922
5927
  };
5923
- Popover.propTypes = {
5928
+ Popover$1.propTypes = {
5924
5929
  children: PropTypes__default.default.node.isRequired,
5925
5930
  className: PropTypes__default.default.string,
5926
5931
  content: PropTypes__default.default.node.isRequired,
@@ -5937,7 +5942,7 @@ const deprecatedPlacements = {
5937
5942
  [exports.Position.LEFT_TOP]: exports.Position.TOP,
5938
5943
  [exports.Position.RIGHT_TOP]: exports.Position.TOP
5939
5944
  };
5940
- var Popover$1 = Popover;
5945
+ var Popover$2 = Popover$1;
5941
5946
 
5942
5947
  const Info = ({
5943
5948
  className = undefined,
@@ -5979,7 +5984,7 @@ const Info = ({
5979
5984
  title: title,
5980
5985
  onClose: () => setOpen(false)
5981
5986
  })]
5982
- }) : /*#__PURE__*/jsxRuntime.jsx(Popover$1, {
5987
+ }) : /*#__PURE__*/jsxRuntime.jsx(Popover$2, {
5983
5988
  content: content,
5984
5989
  preferredPlacement: exports.Position.BOTTOM,
5985
5990
  title: title,
@@ -6168,11 +6173,12 @@ function formControlClassNameBase({
6168
6173
  'np-form-control--size-sm np-text-body-default': size === 'sm',
6169
6174
  'np-form-control--size-md np-text-body-large': size === 'md',
6170
6175
  'np-form-control--size-lg np-text-title-subsection': size === 'lg'
6171
- }, 'np-form-control--shape-rectangle');
6176
+ });
6172
6177
  }
6173
6178
 
6174
6179
  const Input = /*#__PURE__*/React.forwardRef(function Input({
6175
6180
  size = 'auto',
6181
+ shape = 'rectangle',
6176
6182
  className,
6177
6183
  ...restProps
6178
6184
  }, reference) {
@@ -6181,7 +6187,10 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
6181
6187
  ref: reference,
6182
6188
  className: classNames__default.default(className, formControlClassNameBase({
6183
6189
  size
6184
- }))
6190
+ }), 'np-input', {
6191
+ 'np-input--shape-rectangle': shape === 'rectangle',
6192
+ 'np-input--shape-pill': shape === 'pill'
6193
+ })
6185
6194
  // eslint-disable-next-line react/forbid-dom-props
6186
6195
  ,
6187
6196
  style: inputPaddings,
@@ -6189,6 +6198,653 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
6189
6198
  });
6190
6199
  });
6191
6200
 
6201
+ const SearchInput = /*#__PURE__*/React.forwardRef(function SearchInput({
6202
+ shape = 'pill',
6203
+ disabled,
6204
+ className,
6205
+ ...restProps
6206
+ }, ref) {
6207
+ return /*#__PURE__*/jsxRuntime.jsx(InputGroup, {
6208
+ addonStart: {
6209
+ content: /*#__PURE__*/jsxRuntime.jsx(icons.Search, {
6210
+ size: 24
6211
+ }),
6212
+ initialContentWidth: 24
6213
+ },
6214
+ disabled: disabled,
6215
+ className: className,
6216
+ children: /*#__PURE__*/jsxRuntime.jsx(Input, {
6217
+ ref: ref,
6218
+ role: "searchbox",
6219
+ inputMode: "search",
6220
+ shape: shape,
6221
+ ...restProps
6222
+ })
6223
+ });
6224
+ });
6225
+
6226
+ function useMedia(query) {
6227
+ return shim.useSyncExternalStore(onStoreChange => {
6228
+ const mediaQueryList = window.matchMedia(query);
6229
+ mediaQueryList.addEventListener('change', onStoreChange);
6230
+ return () => {
6231
+ mediaQueryList.removeEventListener('change', onStoreChange);
6232
+ };
6233
+ }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
6234
+ }
6235
+
6236
+ function useScreenSize(size) {
6237
+ return useMedia(`(min-width: ${size}px)`);
6238
+ }
6239
+
6240
+ function wrapInFragment(value) {
6241
+ return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
6242
+ children: value
6243
+ });
6244
+ }
6245
+
6246
+ function PreventScroll() {
6247
+ overlays.usePreventScroll();
6248
+ return null;
6249
+ }
6250
+
6251
+ function BottomSheet({
6252
+ open,
6253
+ renderTrigger,
6254
+ title,
6255
+ initialFocusRef,
6256
+ padding = 'md',
6257
+ children,
6258
+ onClose
6259
+ }) {
6260
+ const {
6261
+ refs,
6262
+ context
6263
+ } = react.useFloating({
6264
+ open,
6265
+ onOpenChange: value => {
6266
+ if (!value) {
6267
+ onClose?.();
6268
+ }
6269
+ }
6270
+ });
6271
+ const dismiss = react.useDismiss(context, {
6272
+ outsidePressEvent: 'mousedown'
6273
+ });
6274
+ const role = react.useRole(context);
6275
+ const {
6276
+ getReferenceProps,
6277
+ getFloatingProps
6278
+ } = react.useInteractions([dismiss, role]);
6279
+ const [floatingKey, setFloatingKey] = React.useState(0);
6280
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6281
+ children: [open ? /*#__PURE__*/jsxRuntime.jsx(PreventScroll, {}) : null, renderTrigger?.({
6282
+ ref: refs.setReference,
6283
+ getInteractionProps: getReferenceProps
6284
+ }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingPortal, {
6285
+ children: /*#__PURE__*/jsxRuntime.jsxs(react$1.Transition, {
6286
+ show: open,
6287
+ className: "np-bottom-sheet-v2-container",
6288
+ beforeEnter: () => {
6289
+ setFloatingKey(prev => prev + 1);
6290
+ },
6291
+ children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6292
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6293
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6294
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6295
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6296
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6297
+ className: "np-bottom-sheet-v2-backdrop"
6298
+ })
6299
+ }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6300
+ context: context,
6301
+ initialFocus: initialFocusRef,
6302
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6303
+ className: "np-bottom-sheet-v2",
6304
+ children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6305
+ className: "np-bottom-sheet-v2-content",
6306
+ enter: "np-bottom-sheet-v2-content--enter",
6307
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6308
+ leave: "np-bottom-sheet-v2-content--leave",
6309
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6310
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6311
+ // Force inner state invalidation on open
6312
+ ref: refs.setFloating,
6313
+ className: "np-bottom-sheet-v2-content-inner-container",
6314
+ ...getFloatingProps(),
6315
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6316
+ className: "np-bottom-sheet-v2-header",
6317
+ children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
6318
+ size: exports.Size.SMALL,
6319
+ onClick: () => {
6320
+ onClose?.();
6321
+ }
6322
+ })
6323
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
6324
+ className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6325
+ 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6326
+ }),
6327
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6328
+ className: "np-bottom-sheet-v2-title np-text-title-body",
6329
+ children: title
6330
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6331
+ className: "np-bottom-sheet-v2-body np-text-body-default",
6332
+ children: children
6333
+ })]
6334
+ })]
6335
+ }, floatingKey)
6336
+ })
6337
+ })
6338
+ })]
6339
+ })
6340
+ })]
6341
+ });
6342
+ }
6343
+
6344
+ const ButtonInput = /*#__PURE__*/React.forwardRef(function ButtonInput({
6345
+ size = 'md',
6346
+ className,
6347
+ style,
6348
+ ...restProps
6349
+ }, ref) {
6350
+ const inputPaddings = useInputPaddings();
6351
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
6352
+ ref: ref,
6353
+ type: "button",
6354
+ className: classNames__default.default(className, formControlClassNameBase({
6355
+ size
6356
+ }), 'np-button-input')
6357
+ // eslint-disable-next-line react/forbid-dom-props
6358
+ ,
6359
+ style: {
6360
+ ...inputPaddings,
6361
+ ...style
6362
+ },
6363
+ ...restProps
6364
+ });
6365
+ });
6366
+
6367
+ const floatingPadding = 16;
6368
+ function Popover({
6369
+ placement,
6370
+ open,
6371
+ renderTrigger,
6372
+ title,
6373
+ padding = 'md',
6374
+ children,
6375
+ onClose
6376
+ }) {
6377
+ const {
6378
+ refs,
6379
+ floatingStyles,
6380
+ context
6381
+ } = react.useFloating({
6382
+ placement,
6383
+ middleware: [react.offset(8), react.flip({
6384
+ padding: floatingPadding,
6385
+ crossAxis: false
6386
+ }), react.shift(), react.size({
6387
+ padding: floatingPadding,
6388
+ apply: ({
6389
+ elements,
6390
+ rects,
6391
+ availableHeight
6392
+ }) => {
6393
+ elements.floating.style.setProperty('--max-height', `${availableHeight}px`);
6394
+ elements.floating.style.setProperty('--width', `${rects.reference.width}px`);
6395
+ }
6396
+ })],
6397
+ whileElementsMounted: react.autoUpdate,
6398
+ open,
6399
+ onOpenChange: value => {
6400
+ if (!value) {
6401
+ onClose?.();
6402
+ }
6403
+ }
6404
+ });
6405
+ const dismiss = react.useDismiss(context, {
6406
+ outsidePressEvent: 'mousedown'
6407
+ });
6408
+ const role = react.useRole(context);
6409
+ const {
6410
+ getReferenceProps,
6411
+ getFloatingProps
6412
+ } = react.useInteractions([role, dismiss]);
6413
+ const [floatingKey, setFloatingKey] = React.useState(0);
6414
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6415
+ children: [open ? /*#__PURE__*/jsxRuntime.jsx(PreventScroll, {}) : null, renderTrigger({
6416
+ ref: refs.setReference,
6417
+ getInteractionProps: getReferenceProps
6418
+ }), /*#__PURE__*/jsxRuntime.jsx(react.FloatingPortal, {
6419
+ children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6420
+ context: context,
6421
+ children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition, {
6422
+ show: open,
6423
+ leave: "transition-opacity",
6424
+ leaveTo: "opacity-0",
6425
+ beforeEnter: () => {
6426
+ setFloatingKey(prev => prev + 1);
6427
+ },
6428
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6429
+ // Force inner state invalidation on open
6430
+ ref: refs.setFloating,
6431
+ className: "np-popover-v2-container"
6432
+ // eslint-disable-next-line react/forbid-dom-props
6433
+ ,
6434
+ style: floatingStyles,
6435
+ ...getFloatingProps(),
6436
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6437
+ className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
6438
+ 'np-popover-v2--padding-md': padding === 'md'
6439
+ }),
6440
+ children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6441
+ className: "np-popover-v2-title np-text-title-body",
6442
+ children: title
6443
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6444
+ className: "np-popover-v2-content np-text-body-default",
6445
+ children: children
6446
+ })]
6447
+ })
6448
+ }, floatingKey)
6449
+ })
6450
+ })
6451
+ })]
6452
+ });
6453
+ }
6454
+
6455
+ function searchableString(value) {
6456
+ return value.trim().replace(/\s+/gu, ' ').toLowerCase();
6457
+ }
6458
+ function inferSearchableStrings(value) {
6459
+ if (typeof value === 'string') {
6460
+ return [searchableString(value)];
6461
+ }
6462
+ if (typeof value === 'object' && value != null) {
6463
+ return Object.values(value).filter(innerValue => typeof innerValue === 'string').map(innerValue => searchableString(innerValue));
6464
+ }
6465
+ return [];
6466
+ }
6467
+ const SelectInputHasValueContext = /*#__PURE__*/React.createContext(false);
6468
+ const SelectInputOptionContentCompactContext = /*#__PURE__*/React.createContext(false);
6469
+ function dedupeSelectInputOptionItem(item, existingValues) {
6470
+ if (existingValues.has(item.value)) {
6471
+ return {
6472
+ ...item,
6473
+ value: undefined
6474
+ };
6475
+ }
6476
+ existingValues.add(item.value);
6477
+ return item;
6478
+ }
6479
+ function dedupeSelectInputItems(items) {
6480
+ const existingValues = new Set();
6481
+ return items.map(item => {
6482
+ switch (item.type) {
6483
+ case 'option':
6484
+ {
6485
+ return dedupeSelectInputOptionItem(item, existingValues);
6486
+ }
6487
+ case 'group':
6488
+ {
6489
+ return {
6490
+ ...item,
6491
+ options: item.options.map(option => dedupeSelectInputOptionItem(option, existingValues))
6492
+ };
6493
+ }
6494
+ }
6495
+ return item;
6496
+ });
6497
+ }
6498
+ function SelectInput({
6499
+ name,
6500
+ placeholder,
6501
+ items,
6502
+ defaultValue,
6503
+ value: controlledValue,
6504
+ renderValue = wrapInFragment,
6505
+ compareValues,
6506
+ filterable,
6507
+ filterPlaceholder,
6508
+ disabled,
6509
+ className,
6510
+ onChange,
6511
+ onClear
6512
+ }) {
6513
+ const intl = reactIntl.useIntl();
6514
+ const [open, setOpen] = React.useState(false);
6515
+ const triggerRef = React.useRef(null);
6516
+ const screenSm = useScreenSize(exports.Breakpoint.SMALL);
6517
+ const OptionsOverlay = screenSm ? Popover : BottomSheet;
6518
+ const searchInputRef = React.useRef(null);
6519
+ const listboxRef = React.useRef(null);
6520
+ const controllerRef = filterable ? searchInputRef : listboxRef;
6521
+ return /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox, {
6522
+ name: name,
6523
+ defaultValue: defaultValue,
6524
+ value: controlledValue
6525
+ // TODO: Remove assertion when upgrading TypeScript to v5
6526
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
6527
+ ,
6528
+ by: compareValues,
6529
+ disabled: disabled,
6530
+ onChange: value => {
6531
+ setOpen(false);
6532
+ onChange?.(value);
6533
+ },
6534
+ children: ({
6535
+ disabled: uiDisabled,
6536
+ value
6537
+ }) => /*#__PURE__*/jsxRuntime.jsx(SelectInputHasValueContext.Provider, {
6538
+ value: value != null,
6539
+ children: /*#__PURE__*/jsxRuntime.jsx(InputGroup, {
6540
+ addonEnd: {
6541
+ content: /*#__PURE__*/jsxRuntime.jsxs("span", {
6542
+ className: classNames__default.default('np-select-input-addon-container', uiDisabled && 'disabled'),
6543
+ children: [onClear != null && value != null ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6544
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
6545
+ type: "button",
6546
+ "aria-label": intl.formatMessage(messages$4.ariaLabel),
6547
+ disabled: uiDisabled,
6548
+ className: "np-select-input-addon np-select-input-addon--interactive",
6549
+ onClick: event => {
6550
+ event.preventDefault();
6551
+ onClear();
6552
+ triggerRef.current?.focus({
6553
+ preventScroll: true
6554
+ });
6555
+ },
6556
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {
6557
+ size: 16
6558
+ })
6559
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
6560
+ className: "np-select-input-addon-separator"
6561
+ })]
6562
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
6563
+ className: "np-select-input-addon",
6564
+ children: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronDown, {
6565
+ size: 16
6566
+ })
6567
+ })]
6568
+ }),
6569
+ padding: 'sm'
6570
+ },
6571
+ className: className,
6572
+ children: /*#__PURE__*/jsxRuntime.jsx(OptionsOverlay, {
6573
+ open: open,
6574
+ renderTrigger: ({
6575
+ ref,
6576
+ getInteractionProps
6577
+ }) => /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox.Button, {
6578
+ ref: mergeRefs__default.default([ref, triggerRef]),
6579
+ as: SelectInputButton,
6580
+ overrides: getInteractionProps(),
6581
+ onClick: () => {
6582
+ setOpen(prev => !prev);
6583
+ },
6584
+ children: value != null ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentCompactContext.Provider, {
6585
+ value: true,
6586
+ children: renderValue(value, true)
6587
+ }) : /*#__PURE__*/jsxRuntime.jsx("span", {
6588
+ className: "np-select-input-placeholder",
6589
+ children: placeholder
6590
+ })
6591
+ }),
6592
+ initialFocusRef: controllerRef,
6593
+ padding: "none",
6594
+ onClose: () => {
6595
+ setOpen(false);
6596
+ },
6597
+ children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
6598
+ items: items,
6599
+ renderValue: renderValue,
6600
+ filterable: filterable,
6601
+ filterPlaceholder: filterPlaceholder,
6602
+ searchInputRef: searchInputRef,
6603
+ listboxRef: listboxRef
6604
+ })
6605
+ })
6606
+ })
6607
+ })
6608
+ });
6609
+ }
6610
+ const SelectInputButton = /*#__PURE__*/React.forwardRef(function SelectInputButton({
6611
+ overrides,
6612
+ ...restProps
6613
+ }, ref) {
6614
+ return /*#__PURE__*/jsxRuntime.jsx(ButtonInput, {
6615
+ ref: ref,
6616
+ ...restProps,
6617
+ ...overrides
6618
+ });
6619
+ });
6620
+ const SelectInputOptionsContainer = /*#__PURE__*/React.forwardRef(function SelectInputOptionsContainer({
6621
+ 'aria-orientation': ariaOrientation,
6622
+ 'aria-activedescendant': ariaActiveDescendant,
6623
+ role,
6624
+ tabIndex,
6625
+ onAriaActiveDescendantChange,
6626
+ onKeyDown,
6627
+ ...restProps
6628
+ }, ref) {
6629
+ const handleAriaActiveDescendantChange = useEffectEvent(onAriaActiveDescendantChange);
6630
+ React.useEffect(() => {
6631
+ handleAriaActiveDescendantChange(ariaActiveDescendant);
6632
+ }, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
6633
+ return (
6634
+ /*#__PURE__*/
6635
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
6636
+ jsxRuntime.jsx("div", {
6637
+ ref: ref,
6638
+ onKeyDown: event => {
6639
+ // Prevent absorbing dismissal requests too early
6640
+ if (event.key !== 'Escape') {
6641
+ onKeyDown?.(event);
6642
+ }
6643
+ },
6644
+ ...restProps
6645
+ })
6646
+ );
6647
+ });
6648
+ function SelectInputOptions({
6649
+ items,
6650
+ renderValue = wrapInFragment,
6651
+ filterable,
6652
+ filterPlaceholder,
6653
+ searchInputRef,
6654
+ listboxRef
6655
+ }) {
6656
+ const [query, setQuery] = React.useState('');
6657
+ const needle = React.useMemo(() => query ? searchableString(query) : null, [query]);
6658
+ const listboxContainerRef = React.useRef(null);
6659
+ React.useEffect(() => {
6660
+ if (listboxContainerRef.current != null) {
6661
+ listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
6662
+ }
6663
+ }, []);
6664
+ const listboxId = reactId.useId();
6665
+ const controllerRef = filterable ? searchInputRef : listboxRef;
6666
+ return /*#__PURE__*/jsxRuntime.jsxs(react$1.Listbox.Options, {
6667
+ as: SelectInputOptionsContainer,
6668
+ static: true,
6669
+ className: "np-select-input-options-container",
6670
+ onAriaActiveDescendantChange: value => {
6671
+ if (controllerRef.current != null) {
6672
+ if (value != null) {
6673
+ controllerRef.current.setAttribute('aria-activedescendant', value);
6674
+ } else {
6675
+ controllerRef.current.removeAttribute('aria-activedescendant');
6676
+ }
6677
+ }
6678
+ },
6679
+ children: [filterable ? /*#__PURE__*/jsxRuntime.jsx("div", {
6680
+ className: "np-select-input-query-container",
6681
+ children: /*#__PURE__*/jsxRuntime.jsx(SearchInput, {
6682
+ ref: searchInputRef,
6683
+ shape: "rectangle",
6684
+ placeholder: filterPlaceholder,
6685
+ value: query,
6686
+ "aria-controls": listboxId,
6687
+ onKeyDown: event => {
6688
+ // Prevent interfering with the matcher of Headless UI
6689
+ // https://mathiasbynens.be/notes/javascript-unicode#regex
6690
+ if (/^.$/u.test(event.key)) {
6691
+ event.stopPropagation();
6692
+ }
6693
+ },
6694
+ onChange: event => {
6695
+ setQuery(event.currentTarget.value);
6696
+ }
6697
+ })
6698
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6699
+ ref: listboxContainerRef,
6700
+ className: classNames__default.default('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6701
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
6702
+ ref: listboxRef,
6703
+ id: listboxId,
6704
+ role: "listbox",
6705
+ "aria-orientation": "vertical",
6706
+ tabIndex: 0,
6707
+ className: "np-select-input-listbox",
6708
+ children: (needle == null ? items : dedupeSelectInputItems(items)).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
6709
+ // eslint-disable-next-line react/no-array-index-key
6710
+ , {
6711
+ item: item,
6712
+ renderValue: renderValue,
6713
+ needle: needle
6714
+ }, index))
6715
+ })
6716
+ })]
6717
+ });
6718
+ }
6719
+ function SelectInputItemView({
6720
+ item,
6721
+ renderValue,
6722
+ needle
6723
+ }) {
6724
+ switch (item.type) {
6725
+ case 'option':
6726
+ {
6727
+ if (item.value != null && (!needle || inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle)))) {
6728
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputOption, {
6729
+ value: item.value,
6730
+ disabled: item.disabled,
6731
+ children: renderValue(item.value, false)
6732
+ });
6733
+ }
6734
+ break;
6735
+ }
6736
+ case 'group':
6737
+ {
6738
+ return /*#__PURE__*/jsxRuntime.jsx(SelectInputGroupItemView, {
6739
+ item: item,
6740
+ renderValue: renderValue,
6741
+ needle: needle
6742
+ });
6743
+ }
6744
+ case 'separator':
6745
+ {
6746
+ if (needle == null) {
6747
+ return /*#__PURE__*/jsxRuntime.jsx("hr", {
6748
+ className: "np-select-input-separator-item",
6749
+ "aria-hidden": true
6750
+ });
6751
+ }
6752
+ break;
6753
+ }
6754
+ }
6755
+ return null;
6756
+ }
6757
+ function SelectInputGroupItemView({
6758
+ item,
6759
+ renderValue,
6760
+ needle
6761
+ }) {
6762
+ const headerId = reactId.useId();
6763
+ return (
6764
+ /*#__PURE__*/
6765
+ // An empty container may be rendered when no options match `needle`
6766
+ // However, pre-filtering would result in worse performance overall
6767
+ jsxRuntime.jsxs("section", {
6768
+ role: "group",
6769
+ "aria-labelledby": headerId,
6770
+ className: classNames__default.default(needle == null && 'np-select-input-group-item--without-needle'),
6771
+ children: [needle == null ? /*#__PURE__*/jsxRuntime.jsx("header", {
6772
+ id: headerId,
6773
+ role: "presentation",
6774
+ className: "np-select-input-group-item-header np-text-title-group",
6775
+ children: item.label
6776
+ }) : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
6777
+ // eslint-disable-next-line react/no-array-index-key
6778
+ , {
6779
+ item: option,
6780
+ renderValue: renderValue,
6781
+ needle: needle
6782
+ }, index))]
6783
+ })
6784
+ );
6785
+ }
6786
+ function SelectInputOption({
6787
+ value,
6788
+ disabled,
6789
+ children
6790
+ }) {
6791
+ const parentHasValue = React.useContext(SelectInputHasValueContext);
6792
+ // Avoid flash during exit transition
6793
+ const {
6794
+ current: cachedParentHasValue
6795
+ } = React.useRef(parentHasValue);
6796
+ return /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox.Option, {
6797
+ as: "div",
6798
+ value: value,
6799
+ disabled: disabled,
6800
+ className: ({
6801
+ active,
6802
+ disabled: uiDisabled
6803
+ }) => classNames__default.default('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
6804
+ children: ({
6805
+ selected
6806
+ }) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6807
+ children: [cachedParentHasValue ? /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
6808
+ size: 16,
6809
+ className: classNames__default.default(!selected && 'np-select-input-option-check--not-selected')
6810
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
6811
+ className: "np-select-input-option",
6812
+ children: children
6813
+ })]
6814
+ })
6815
+ });
6816
+ }
6817
+ function SelectInputOptionContent({
6818
+ title,
6819
+ note,
6820
+ description,
6821
+ icon
6822
+ }) {
6823
+ const compact = React.useContext(SelectInputOptionContentCompactContext);
6824
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
6825
+ className: "np-select-input-option-content-container np-text-body-large",
6826
+ children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
6827
+ className: classNames__default.default('np-select-input-option-content-icon', !compact && 'np-select-input-option-content-icon--not-compact'),
6828
+ children: icon
6829
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
6830
+ className: "np-select-input-option-content-text",
6831
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
6832
+ className: classNames__default.default('np-select-input-option-content-text-line-1', compact && 'np-select-input-option-content-text-compact'),
6833
+ children: [/*#__PURE__*/jsxRuntime.jsx("h4", {
6834
+ className: "d-inline np-text-body-large",
6835
+ children: title
6836
+ }), note ? /*#__PURE__*/jsxRuntime.jsx("span", {
6837
+ className: "np-select-input-option-content-text-secondary np-text-body-default",
6838
+ children: note
6839
+ }) : null]
6840
+ }), description ? /*#__PURE__*/jsxRuntime.jsx("div", {
6841
+ className: classNames__default.default('np-select-input-option-content-text-secondary np-text-body-default', compact && 'np-select-input-option-content-text-compact'),
6842
+ children: description
6843
+ }) : null]
6844
+ })]
6845
+ });
6846
+ }
6847
+
6192
6848
  const TextArea = /*#__PURE__*/React.forwardRef(function TextArea({
6193
6849
  className,
6194
6850
  ...restProps
@@ -7304,7 +7960,7 @@ function Select({
7304
7960
  headerTitle: searchPlaceholder || formatMessage(messages$3.searchPlaceholder),
7305
7961
  onClose: handleCloseOptions,
7306
7962
  children: renderOptionsList()
7307
- }) : /*#__PURE__*/jsxRuntime.jsx(BottomSheet$1, {
7963
+ }) : /*#__PURE__*/jsxRuntime.jsx(BottomSheet$2, {
7308
7964
  open: open,
7309
7965
  onClose: handleCloseOptions,
7310
7966
  children: renderOptionsList({
@@ -14427,7 +15083,7 @@ exports.AvatarWrapper = AvatarWrapper;
14427
15083
  exports.Badge = Badge;
14428
15084
  exports.BaseCard = Card;
14429
15085
  exports.Body = Body;
14430
- exports.BottomSheet = BottomSheet$1;
15086
+ exports.BottomSheet = BottomSheet$2;
14431
15087
  exports.Button = Button;
14432
15088
  exports.Card = Card$2;
14433
15089
  exports.Checkbox = Checkbox$1;
@@ -14475,7 +15131,7 @@ exports.Nudge = Nudge;
14475
15131
  exports.Option = Option$2;
14476
15132
  exports.OverlayHeader = OverlayHeader$1;
14477
15133
  exports.PhoneNumberInput = PhoneNumberInput$1;
14478
- exports.Popover = Popover$1;
15134
+ exports.Popover = Popover$2;
14479
15135
  exports.ProcessIndicator = ProcessIndicator$1;
14480
15136
  exports.Progress = Progress;
14481
15137
  exports.ProgressBar = ProgressBar;
@@ -14487,8 +15143,11 @@ exports.Radio = Radio$1;
14487
15143
  exports.RadioGroup = RadioGroup$1;
14488
15144
  exports.RadioOption = RadioOption$1;
14489
15145
  exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
15146
+ exports.SearchInput = SearchInput;
14490
15147
  exports.Section = Section;
14491
15148
  exports.Select = Select;
15149
+ exports.SelectInput = SelectInput;
15150
+ exports.SelectInputOptionContent = SelectInputOptionContent;
14492
15151
  exports.SlidingPanel = SlidingPanel$1;
14493
15152
  exports.SnackbarConsumer = SnackbarConsumer;
14494
15153
  exports.SnackbarContext = SnackbarContext;