@transferwise/components 45.17.1 → 45.18.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 +339 -293
- package/build/index.esm.js.map +1 -1
- package/build/index.js +339 -292
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/inputs/SelectInput.css +1 -1
- package/build/styles/instructionsList/InstructionsList.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/stepper/Stepper.css +1 -1
- package/build/styles/tooltip/Tooltip.css +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/common/polymorphicWithOverrides/PolymorphicWithOverrides.d.ts +13 -0
- package/build/types/common/polymorphicWithOverrides/PolymorphicWithOverrides.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +16 -6
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/instructionsList/InstructionsList.d.ts +10 -3
- package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +1 -1
- package/build/types/tooltip/Tooltip.d.ts +2 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/button/Button.story.tsx +6 -0
- package/src/button/Button.tsx +6 -1
- package/src/common/polymorphicWithOverrides/PolymorphicWithOverrides.tsx +19 -0
- package/src/index.ts +3 -0
- package/src/inputs/SelectInput.css +1 -1
- package/src/inputs/SelectInput.less +8 -2
- package/src/inputs/SelectInput.story.tsx +52 -5
- package/src/inputs/SelectInput.tsx +165 -104
- package/src/inputs/_Popover.less +1 -1
- package/src/instructionsList/InstructionList.story.tsx +39 -0
- package/src/instructionsList/InstructionsList.css +1 -1
- package/src/instructionsList/InstructionsList.less +3 -15
- package/src/instructionsList/InstructionsList.spec.tsx +35 -0
- package/src/instructionsList/InstructionsList.tsx +40 -25
- package/src/main.css +1 -1
- package/src/processIndicator/ProcessIndicator.js +2 -2
- package/src/stepper/Stepper.css +1 -1
- package/src/stepper/Stepper.less +1 -1
- package/src/tooltip/Tooltip.css +1 -1
- package/src/tooltip/Tooltip.less +13 -0
- package/src/tooltip/Tooltip.spec.tsx +97 -29
- package/src/tooltip/Tooltip.tsx +24 -31
- package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +31 -0
- package/src/instructionsList/InstructionList.story.js +0 -27
- package/src/instructionsList/InstructionsList.spec.js +0 -29
package/build/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, PureComponent, createRef,
|
|
4
|
+
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, Component, PureComponent, createRef, Children, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { useId } from '@radix-ui/react-id';
|
|
6
6
|
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';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
@@ -16,6 +16,7 @@ import mergeRefs from 'react-merge-refs';
|
|
|
16
16
|
import { isUndefined, isKey, isNumber, isEmpty, isNull, isArray } from '@transferwise/neptune-validation';
|
|
17
17
|
import { usePopper } from 'react-popper';
|
|
18
18
|
import { Transition, Listbox } from '@headlessui/react';
|
|
19
|
+
import mergeProps from 'merge-props';
|
|
19
20
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
20
21
|
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
|
|
21
22
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
@@ -2093,6 +2094,129 @@ const BottomSheet$1 = props => {
|
|
|
2093
2094
|
};
|
|
2094
2095
|
var BottomSheet$2 = BottomSheet$1;
|
|
2095
2096
|
|
|
2097
|
+
const radius = {
|
|
2098
|
+
xxs: 6,
|
|
2099
|
+
xs: 11,
|
|
2100
|
+
sm: 22,
|
|
2101
|
+
xl: 61
|
|
2102
|
+
};
|
|
2103
|
+
const ANIMATION_DURATION_IN_MS = 1500;
|
|
2104
|
+
class ProcessIndicator extends Component {
|
|
2105
|
+
constructor(props) {
|
|
2106
|
+
super(props);
|
|
2107
|
+
this.state = {
|
|
2108
|
+
status: props.status,
|
|
2109
|
+
size: props.size
|
|
2110
|
+
};
|
|
2111
|
+
this.interval = null;
|
|
2112
|
+
this.timeout = null;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* Create interval for animation duration (1500ms)
|
|
2117
|
+
* Update state only at the end of every interval
|
|
2118
|
+
* (end of animation loop) if props changed before end of animation
|
|
2119
|
+
*/
|
|
2120
|
+
componentDidMount() {
|
|
2121
|
+
this.interval = setInterval(() => {
|
|
2122
|
+
const statusFromState = this.state.status;
|
|
2123
|
+
const sizeFromState = this.state.size;
|
|
2124
|
+
const statusFromProps = this.props.status;
|
|
2125
|
+
const sizeFromProps = this.props.size;
|
|
2126
|
+
if (statusFromState !== statusFromProps) {
|
|
2127
|
+
this.setState({
|
|
2128
|
+
status: statusFromProps
|
|
2129
|
+
}, this.runCallBack(statusFromProps));
|
|
2130
|
+
}
|
|
2131
|
+
if (sizeFromState !== sizeFromProps) {
|
|
2132
|
+
this.setState({
|
|
2133
|
+
size: sizeFromProps
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
}, ANIMATION_DURATION_IN_MS);
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
/**
|
|
2140
|
+
* Only trigger render if comopnent's state got
|
|
2141
|
+
* updated from interval callback
|
|
2142
|
+
*
|
|
2143
|
+
* @param nextProps
|
|
2144
|
+
* @param nextState
|
|
2145
|
+
*/
|
|
2146
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
2147
|
+
const isSameStatus = nextProps.status === nextState.status;
|
|
2148
|
+
const isSameSize = nextProps.size === nextState.size;
|
|
2149
|
+
return isSameStatus && isSameSize;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
// Clear interval before destroying component
|
|
2153
|
+
componentWillUnmount() {
|
|
2154
|
+
clearInterval(this.interval);
|
|
2155
|
+
clearTimeout(this.timeout);
|
|
2156
|
+
}
|
|
2157
|
+
runCallBack = statusFromProps => {
|
|
2158
|
+
const {
|
|
2159
|
+
onAnimationCompleted
|
|
2160
|
+
} = this.props;
|
|
2161
|
+
if (onAnimationCompleted) {
|
|
2162
|
+
this.timeouts = setTimeout(() => {
|
|
2163
|
+
onAnimationCompleted(statusFromProps);
|
|
2164
|
+
}, ANIMATION_DURATION_IN_MS);
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
render() {
|
|
2168
|
+
const {
|
|
2169
|
+
className,
|
|
2170
|
+
'data-testid': dataTestId
|
|
2171
|
+
} = this.props;
|
|
2172
|
+
const {
|
|
2173
|
+
size,
|
|
2174
|
+
status
|
|
2175
|
+
} = this.state;
|
|
2176
|
+
const classes = classNames(`process process-${size}`, className, {
|
|
2177
|
+
[`process-danger`]: status === Status.FAILED,
|
|
2178
|
+
[`process-stopped`]: status === Status.HIDDEN,
|
|
2179
|
+
[`process-success`]: status === Status.SUCCEEDED
|
|
2180
|
+
});
|
|
2181
|
+
return /*#__PURE__*/jsxs("span", {
|
|
2182
|
+
className: classes,
|
|
2183
|
+
"data-testid": dataTestId,
|
|
2184
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
2185
|
+
className: "process-icon-container",
|
|
2186
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
2187
|
+
className: "process-icon-horizontal"
|
|
2188
|
+
}), /*#__PURE__*/jsx("span", {
|
|
2189
|
+
className: "process-icon-vertical"
|
|
2190
|
+
})]
|
|
2191
|
+
}), /*#__PURE__*/jsx("svg", {
|
|
2192
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2193
|
+
children: /*#__PURE__*/jsx("circle", {
|
|
2194
|
+
className: "process-circle",
|
|
2195
|
+
cx: "50%",
|
|
2196
|
+
cy: "50%",
|
|
2197
|
+
r: radius[this.state.size],
|
|
2198
|
+
fillOpacity: "0.0"
|
|
2199
|
+
})
|
|
2200
|
+
})]
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
ProcessIndicator.propTypes = {
|
|
2205
|
+
status: PropTypes.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
|
|
2206
|
+
size: PropTypes.oneOf(['xxs', 'xs', 'sm', 'xl']),
|
|
2207
|
+
onAnimationCompleted: PropTypes.func,
|
|
2208
|
+
className: PropTypes.string,
|
|
2209
|
+
'data-testid': PropTypes.string
|
|
2210
|
+
};
|
|
2211
|
+
ProcessIndicator.defaultProps = {
|
|
2212
|
+
status: Status.PROCESSING,
|
|
2213
|
+
size: Size.SMALL,
|
|
2214
|
+
onAnimationCompleted: null,
|
|
2215
|
+
className: undefined,
|
|
2216
|
+
'data-testid': null
|
|
2217
|
+
};
|
|
2218
|
+
var ProcessIndicator$1 = ProcessIndicator;
|
|
2219
|
+
|
|
2096
2220
|
var messages$8 = defineMessages({
|
|
2097
2221
|
loadingAriaLabel: {
|
|
2098
2222
|
id: "neptune.Button.loadingAriaLabel"
|
|
@@ -2187,6 +2311,9 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2187
2311
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
2188
2312
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2189
2313
|
priorityClassMap[newPriority], className);
|
|
2314
|
+
function processIndicatorSize() {
|
|
2315
|
+
return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
|
|
2316
|
+
}
|
|
2190
2317
|
const Element = component ?? 'button';
|
|
2191
2318
|
let props;
|
|
2192
2319
|
if (Element === 'button') {
|
|
@@ -2210,10 +2337,9 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2210
2337
|
...props,
|
|
2211
2338
|
"aria-live": loading ? 'polite' : 'off',
|
|
2212
2339
|
"aria-label": loading ? intl.formatMessage(messages$8.loadingAriaLabel) : undefined,
|
|
2213
|
-
children: [children, loading && /*#__PURE__*/jsx(
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
})
|
|
2340
|
+
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator$1, {
|
|
2341
|
+
size: processIndicatorSize(),
|
|
2342
|
+
className: "btn-loader"
|
|
2217
2343
|
})]
|
|
2218
2344
|
});
|
|
2219
2345
|
});
|
|
@@ -5361,12 +5487,15 @@ const Tooltip = ({
|
|
|
5361
5487
|
position = Position.TOP,
|
|
5362
5488
|
children = undefined,
|
|
5363
5489
|
label,
|
|
5490
|
+
id,
|
|
5364
5491
|
className
|
|
5365
5492
|
}) => {
|
|
5366
5493
|
const [open, setOpen] = useState(false);
|
|
5367
5494
|
const anchorReference = useRef(null);
|
|
5368
5495
|
const [arrowElement, setArrowElement] = useState(null);
|
|
5369
5496
|
const [popperElement, setPopperElement] = useState(null);
|
|
5497
|
+
const fallbackId = useId();
|
|
5498
|
+
const tooltipId = id ?? fallbackId;
|
|
5370
5499
|
const modifiers = [];
|
|
5371
5500
|
modifiers.push({
|
|
5372
5501
|
name: 'arrow',
|
|
@@ -5405,60 +5534,42 @@ const Tooltip = ({
|
|
|
5405
5534
|
forceUpdate();
|
|
5406
5535
|
}
|
|
5407
5536
|
}, [open]);
|
|
5408
|
-
return /*#__PURE__*/
|
|
5409
|
-
children:
|
|
5537
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
5538
|
+
children: /*#__PURE__*/jsxs("span", {
|
|
5410
5539
|
ref: anchorReference,
|
|
5411
|
-
className: "
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
onMouseOut: () => {
|
|
5427
|
-
if (children?.props?.onMouseOver) {
|
|
5428
|
-
children.props.onMouseOver();
|
|
5429
|
-
}
|
|
5430
|
-
setOpen(false);
|
|
5540
|
+
className: "tw-tooltip-container",
|
|
5541
|
+
onMouseOver: () => setOpen(true),
|
|
5542
|
+
onFocus: () => setOpen(true),
|
|
5543
|
+
onMouseOut: () => setOpen(false),
|
|
5544
|
+
onBlur: () => setOpen(false),
|
|
5545
|
+
children: [children ? /*#__PURE__*/cloneElement(children, {
|
|
5546
|
+
'aria-describedby': `${tooltipId}-tooltip`
|
|
5547
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
5548
|
+
// @ts-expect-error
|
|
5549
|
+
ref: setPopperElement,
|
|
5550
|
+
className: classNames('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
|
|
5551
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5552
|
+
,
|
|
5553
|
+
style: {
|
|
5554
|
+
...styles.popper
|
|
5431
5555
|
},
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
...attributes.popper,
|
|
5450
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
5451
|
-
className: "np-panel__content tooltip-inner",
|
|
5452
|
-
children: [label, /*#__PURE__*/jsx("div", {
|
|
5453
|
-
// @ts-expect-error
|
|
5454
|
-
ref: setArrowElement,
|
|
5455
|
-
className: classNames('np-panel__arrow')
|
|
5456
|
-
// eslint-disable-next-line react/forbid-dom-props
|
|
5457
|
-
,
|
|
5458
|
-
style: styles.arrow
|
|
5459
|
-
})]
|
|
5460
|
-
})
|
|
5461
|
-
}) : null]
|
|
5556
|
+
...attributes.popper,
|
|
5557
|
+
"aria-hidden": !open,
|
|
5558
|
+
role: "tooltip",
|
|
5559
|
+
id: `${tooltipId}-tooltip`,
|
|
5560
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
5561
|
+
className: "np-panel__content tooltip-inner",
|
|
5562
|
+
children: [label, /*#__PURE__*/jsx("div", {
|
|
5563
|
+
// @ts-expect-error
|
|
5564
|
+
ref: setArrowElement,
|
|
5565
|
+
className: classNames('np-panel__arrow')
|
|
5566
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5567
|
+
,
|
|
5568
|
+
style: styles.arrow
|
|
5569
|
+
})]
|
|
5570
|
+
})
|
|
5571
|
+
})]
|
|
5572
|
+
})
|
|
5462
5573
|
});
|
|
5463
5574
|
};
|
|
5464
5575
|
var Tooltip$1 = Tooltip;
|
|
@@ -6219,6 +6330,20 @@ function useScreenSize(size) {
|
|
|
6219
6330
|
return useMedia(`(min-width: ${size}px)`);
|
|
6220
6331
|
}
|
|
6221
6332
|
|
|
6333
|
+
const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWithOverrides({
|
|
6334
|
+
__overrides: {
|
|
6335
|
+
as: Element,
|
|
6336
|
+
...restOverrides
|
|
6337
|
+
},
|
|
6338
|
+
...restProps
|
|
6339
|
+
}, ref) {
|
|
6340
|
+
return /*#__PURE__*/jsx(Element, {
|
|
6341
|
+
ref: ref,
|
|
6342
|
+
...restProps,
|
|
6343
|
+
...restOverrides
|
|
6344
|
+
});
|
|
6345
|
+
});
|
|
6346
|
+
|
|
6222
6347
|
function wrapInFragment(value) {
|
|
6223
6348
|
return /*#__PURE__*/jsx(Fragment, {
|
|
6224
6349
|
children: value
|
|
@@ -6465,7 +6590,8 @@ function inferSearchableStrings(value) {
|
|
|
6465
6590
|
return [];
|
|
6466
6591
|
}
|
|
6467
6592
|
const SelectInputHasValueContext = /*#__PURE__*/createContext(false);
|
|
6468
|
-
const
|
|
6593
|
+
const SelectInputTriggerButtonPropsContext = /*#__PURE__*/createContext({});
|
|
6594
|
+
const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/createContext(false);
|
|
6469
6595
|
function dedupeSelectInputOptionItem(item, existingValues) {
|
|
6470
6596
|
if (existingValues.has(item.value)) {
|
|
6471
6597
|
return {
|
|
@@ -6495,14 +6621,68 @@ function dedupeSelectInputItems(items) {
|
|
|
6495
6621
|
return item;
|
|
6496
6622
|
});
|
|
6497
6623
|
}
|
|
6624
|
+
const defaultRenderTrigger = ({
|
|
6625
|
+
content,
|
|
6626
|
+
placeholderShown,
|
|
6627
|
+
clear,
|
|
6628
|
+
disabled,
|
|
6629
|
+
className
|
|
6630
|
+
}) => /*#__PURE__*/jsx(InputGroup, {
|
|
6631
|
+
addonEnd: {
|
|
6632
|
+
content: /*#__PURE__*/jsxs("span", {
|
|
6633
|
+
className: classNames('np-select-input-addon-container', disabled && 'disabled'),
|
|
6634
|
+
children: [clear != null && !placeholderShown ? /*#__PURE__*/jsxs(Fragment, {
|
|
6635
|
+
children: [/*#__PURE__*/jsx(SelectInputClearButton, {
|
|
6636
|
+
onClick: event => {
|
|
6637
|
+
event.preventDefault();
|
|
6638
|
+
clear();
|
|
6639
|
+
}
|
|
6640
|
+
}), /*#__PURE__*/jsx("span", {
|
|
6641
|
+
className: "np-select-input-addon-separator"
|
|
6642
|
+
})]
|
|
6643
|
+
}) : null, /*#__PURE__*/jsx("span", {
|
|
6644
|
+
className: "np-select-input-addon",
|
|
6645
|
+
children: /*#__PURE__*/jsx(ChevronDown, {
|
|
6646
|
+
size: 16
|
|
6647
|
+
})
|
|
6648
|
+
})]
|
|
6649
|
+
}),
|
|
6650
|
+
padding: 'sm'
|
|
6651
|
+
},
|
|
6652
|
+
disabled: disabled,
|
|
6653
|
+
className: className,
|
|
6654
|
+
children: /*#__PURE__*/jsx(SelectInputTriggerButton, {
|
|
6655
|
+
as: ButtonInput,
|
|
6656
|
+
children: placeholderShown ? /*#__PURE__*/jsxs("span", {
|
|
6657
|
+
className: "np-select-input-placeholder",
|
|
6658
|
+
children: [" ", content]
|
|
6659
|
+
}) : content
|
|
6660
|
+
})
|
|
6661
|
+
});
|
|
6662
|
+
function SelectInputClearButton({
|
|
6663
|
+
className,
|
|
6664
|
+
onClick
|
|
6665
|
+
}) {
|
|
6666
|
+
const intl = useIntl();
|
|
6667
|
+
return /*#__PURE__*/jsx("button", {
|
|
6668
|
+
type: "button",
|
|
6669
|
+
"aria-label": intl.formatMessage(messages$5.ariaLabel),
|
|
6670
|
+
className: classNames(className, 'np-select-input-addon np-select-input-addon--interactive'),
|
|
6671
|
+
onClick: onClick,
|
|
6672
|
+
children: /*#__PURE__*/jsx(Cross, {
|
|
6673
|
+
size: 16
|
|
6674
|
+
})
|
|
6675
|
+
});
|
|
6676
|
+
}
|
|
6498
6677
|
function SelectInput({
|
|
6499
6678
|
name,
|
|
6500
6679
|
placeholder,
|
|
6501
6680
|
items,
|
|
6502
6681
|
defaultValue,
|
|
6503
6682
|
value: controlledValue,
|
|
6504
|
-
renderValue = wrapInFragment,
|
|
6505
6683
|
compareValues,
|
|
6684
|
+
renderValue = wrapInFragment,
|
|
6685
|
+
renderTrigger = defaultRenderTrigger,
|
|
6506
6686
|
filterable,
|
|
6507
6687
|
filterPlaceholder,
|
|
6508
6688
|
disabled,
|
|
@@ -6510,7 +6690,6 @@ function SelectInput({
|
|
|
6510
6690
|
onChange,
|
|
6511
6691
|
onClear
|
|
6512
6692
|
}) {
|
|
6513
|
-
const intl = useIntl();
|
|
6514
6693
|
const [open, setOpen] = useState(false);
|
|
6515
6694
|
const triggerRef = useRef(null);
|
|
6516
6695
|
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
@@ -6536,87 +6715,75 @@ function SelectInput({
|
|
|
6536
6715
|
value
|
|
6537
6716
|
}) => /*#__PURE__*/jsx(SelectInputHasValueContext.Provider, {
|
|
6538
6717
|
value: value != null,
|
|
6539
|
-
children: /*#__PURE__*/jsx(
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
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__*/jsx(Cross, {
|
|
6557
|
-
size: 16
|
|
6558
|
-
})
|
|
6559
|
-
}), /*#__PURE__*/jsx("span", {
|
|
6560
|
-
className: "np-select-input-addon-separator"
|
|
6561
|
-
})]
|
|
6562
|
-
}) : null, /*#__PURE__*/jsx("span", {
|
|
6563
|
-
className: "np-select-input-addon",
|
|
6564
|
-
children: /*#__PURE__*/jsx(ChevronDown, {
|
|
6565
|
-
size: 16
|
|
6566
|
-
})
|
|
6567
|
-
})]
|
|
6568
|
-
}),
|
|
6569
|
-
padding: 'sm'
|
|
6570
|
-
},
|
|
6571
|
-
className: className,
|
|
6572
|
-
children: /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6573
|
-
open: open,
|
|
6574
|
-
renderTrigger: ({
|
|
6575
|
-
ref,
|
|
6576
|
-
getInteractionProps
|
|
6577
|
-
}) => /*#__PURE__*/jsx(Listbox.Button, {
|
|
6718
|
+
children: /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6719
|
+
open: open,
|
|
6720
|
+
renderTrigger: ({
|
|
6721
|
+
ref,
|
|
6722
|
+
getInteractionProps
|
|
6723
|
+
}) => /*#__PURE__*/jsx(SelectInputTriggerButtonPropsContext.Provider, {
|
|
6724
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6725
|
+
value: {
|
|
6578
6726
|
ref: mergeRefs([ref, triggerRef]),
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
},
|
|
6584
|
-
|
|
6727
|
+
...mergeProps({
|
|
6728
|
+
onClick: () => {
|
|
6729
|
+
setOpen(prev => !prev);
|
|
6730
|
+
}
|
|
6731
|
+
}, getInteractionProps())
|
|
6732
|
+
},
|
|
6733
|
+
children: renderTrigger({
|
|
6734
|
+
content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6585
6735
|
value: true,
|
|
6586
6736
|
children: renderValue(value, true)
|
|
6587
|
-
}) :
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6598
|
-
items: items,
|
|
6599
|
-
renderValue: renderValue,
|
|
6600
|
-
filterable: filterable,
|
|
6601
|
-
filterPlaceholder: filterPlaceholder,
|
|
6602
|
-
searchInputRef: searchInputRef,
|
|
6603
|
-
listboxRef: listboxRef
|
|
6737
|
+
}) : placeholder,
|
|
6738
|
+
placeholderShown: value == null,
|
|
6739
|
+
clear: onClear != null ? () => {
|
|
6740
|
+
onClear();
|
|
6741
|
+
triggerRef.current?.focus({
|
|
6742
|
+
preventScroll: true
|
|
6743
|
+
});
|
|
6744
|
+
} : undefined,
|
|
6745
|
+
disabled: uiDisabled,
|
|
6746
|
+
className: classNames(className, 'np-text-body-large')
|
|
6604
6747
|
})
|
|
6748
|
+
}),
|
|
6749
|
+
initialFocusRef: controllerRef,
|
|
6750
|
+
padding: "none",
|
|
6751
|
+
onClose: () => {
|
|
6752
|
+
setOpen(false);
|
|
6753
|
+
},
|
|
6754
|
+
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6755
|
+
items: items,
|
|
6756
|
+
renderValue: renderValue,
|
|
6757
|
+
filterable: filterable,
|
|
6758
|
+
filterPlaceholder: filterPlaceholder,
|
|
6759
|
+
searchInputRef: searchInputRef,
|
|
6760
|
+
listboxRef: listboxRef
|
|
6605
6761
|
})
|
|
6606
6762
|
})
|
|
6607
6763
|
})
|
|
6608
6764
|
});
|
|
6609
6765
|
}
|
|
6610
|
-
|
|
6611
|
-
|
|
6766
|
+
function SelectInputTriggerButton({
|
|
6767
|
+
as = 'button',
|
|
6612
6768
|
...restProps
|
|
6613
|
-
}
|
|
6614
|
-
|
|
6769
|
+
}) {
|
|
6770
|
+
const {
|
|
6771
|
+
ref,
|
|
6772
|
+
onClick,
|
|
6773
|
+
...interactionProps
|
|
6774
|
+
} = useContext(SelectInputTriggerButtonPropsContext);
|
|
6775
|
+
return /*#__PURE__*/jsx(Listbox.Button, {
|
|
6615
6776
|
ref: ref,
|
|
6616
|
-
|
|
6617
|
-
|
|
6777
|
+
as: PolymorphicWithOverrides,
|
|
6778
|
+
__overrides: {
|
|
6779
|
+
as,
|
|
6780
|
+
...interactionProps
|
|
6781
|
+
},
|
|
6782
|
+
...mergeProps({
|
|
6783
|
+
onClick
|
|
6784
|
+
}, restProps)
|
|
6618
6785
|
});
|
|
6619
|
-
}
|
|
6786
|
+
}
|
|
6620
6787
|
const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInputOptionsContainer({
|
|
6621
6788
|
'aria-orientation': ariaOrientation,
|
|
6622
6789
|
'aria-activedescendant': ariaActiveDescendant,
|
|
@@ -6745,8 +6912,7 @@ function SelectInputItemView({
|
|
|
6745
6912
|
{
|
|
6746
6913
|
if (needle == null) {
|
|
6747
6914
|
return /*#__PURE__*/jsx("hr", {
|
|
6748
|
-
className: "np-select-input-separator-item"
|
|
6749
|
-
"aria-hidden": true
|
|
6915
|
+
className: "np-select-input-separator-item"
|
|
6750
6916
|
});
|
|
6751
6917
|
}
|
|
6752
6918
|
break;
|
|
@@ -6799,18 +6965,19 @@ function SelectInputOption({
|
|
|
6799
6965
|
disabled: disabled,
|
|
6800
6966
|
className: ({
|
|
6801
6967
|
active,
|
|
6968
|
+
selected,
|
|
6802
6969
|
disabled: uiDisabled
|
|
6803
|
-
}) => classNames('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', uiDisabled && 'np-select-input-option-container--disabled'),
|
|
6970
|
+
}) => classNames('np-select-input-option-container np-text-body-large', active && 'np-select-input-option-container--active', selected && 'np-select-input-option-container--selected', uiDisabled && 'np-select-input-option-container--disabled'),
|
|
6804
6971
|
children: ({
|
|
6805
6972
|
selected
|
|
6806
6973
|
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
6807
|
-
children: [
|
|
6808
|
-
size: 16,
|
|
6809
|
-
className: classNames(!selected && 'np-select-input-option-check--not-selected')
|
|
6810
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
6974
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
6811
6975
|
className: "np-select-input-option",
|
|
6812
6976
|
children: children
|
|
6813
|
-
})
|
|
6977
|
+
}), cachedParentHasValue ? /*#__PURE__*/jsx(Check, {
|
|
6978
|
+
size: 24,
|
|
6979
|
+
className: classNames('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
|
|
6980
|
+
}) : null]
|
|
6814
6981
|
})
|
|
6815
6982
|
});
|
|
6816
6983
|
}
|
|
@@ -6820,16 +6987,16 @@ function SelectInputOptionContent({
|
|
|
6820
6987
|
description,
|
|
6821
6988
|
icon
|
|
6822
6989
|
}) {
|
|
6823
|
-
const
|
|
6990
|
+
const withinTrigger = useContext(SelectInputOptionContentWithinTriggerContext);
|
|
6824
6991
|
return /*#__PURE__*/jsxs("div", {
|
|
6825
6992
|
className: "np-select-input-option-content-container np-text-body-large",
|
|
6826
6993
|
children: [icon ? /*#__PURE__*/jsx("div", {
|
|
6827
|
-
className: classNames('np-select-input-option-content-icon', !
|
|
6994
|
+
className: classNames('np-select-input-option-content-icon', !withinTrigger && 'np-select-input-option-content-icon--not-within-trigger'),
|
|
6828
6995
|
children: icon
|
|
6829
6996
|
}) : null, /*#__PURE__*/jsxs("div", {
|
|
6830
6997
|
className: "np-select-input-option-content-text",
|
|
6831
6998
|
children: [/*#__PURE__*/jsxs("div", {
|
|
6832
|
-
className: classNames('np-select-input-option-content-text-line-1',
|
|
6999
|
+
className: classNames('np-select-input-option-content-text-line-1', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
|
|
6833
7000
|
children: [/*#__PURE__*/jsx("h4", {
|
|
6834
7001
|
className: "d-inline np-text-body-large",
|
|
6835
7002
|
children: title
|
|
@@ -6838,7 +7005,7 @@ function SelectInputOptionContent({
|
|
|
6838
7005
|
children: note
|
|
6839
7006
|
}) : null]
|
|
6840
7007
|
}), description ? /*#__PURE__*/jsx("div", {
|
|
6841
|
-
className: classNames('np-select-input-option-content-text-secondary np-text-body-default',
|
|
7008
|
+
className: classNames('np-select-input-option-content-text-secondary np-text-body-default', withinTrigger && 'np-select-input-option-content-text-within-trigger'),
|
|
6842
7009
|
children: description
|
|
6843
7010
|
}) : null]
|
|
6844
7011
|
})]
|
|
@@ -7288,47 +7455,48 @@ InputWithDisplayFormat.propTypes = {
|
|
|
7288
7455
|
};
|
|
7289
7456
|
var InputWithDisplayFormat$1 = InputWithDisplayFormat;
|
|
7290
7457
|
|
|
7291
|
-
const InstructionsList =
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
const {
|
|
7296
|
-
dos,
|
|
7297
|
-
donts
|
|
7298
|
-
} = props;
|
|
7299
|
-
const DontIcon = isModern ? CrossCircleFill : CrossCircle;
|
|
7300
|
-
const DoIcon = isModern ? CheckCircleFill : CheckCircle;
|
|
7458
|
+
const InstructionsList = ({
|
|
7459
|
+
dos,
|
|
7460
|
+
donts
|
|
7461
|
+
}) => {
|
|
7301
7462
|
return /*#__PURE__*/jsxs("div", {
|
|
7302
7463
|
className: "tw-instructions",
|
|
7303
7464
|
children: [dos && dos.map((doThis, index) =>
|
|
7304
7465
|
/*#__PURE__*/
|
|
7305
7466
|
// eslint-disable-next-line react/no-array-index-key
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
size: 24,
|
|
7310
|
-
className: "do"
|
|
7311
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
7312
|
-
className: "text-primary",
|
|
7313
|
-
type: Typography.BODY_LARGE,
|
|
7314
|
-
children: doThis
|
|
7315
|
-
})]
|
|
7467
|
+
jsx(Instruction, {
|
|
7468
|
+
item: doThis,
|
|
7469
|
+
type: "do"
|
|
7316
7470
|
}, index)), donts && donts.map((dont, index) =>
|
|
7317
7471
|
/*#__PURE__*/
|
|
7318
7472
|
// eslint-disable-next-line react/no-array-index-key
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
size: 24,
|
|
7323
|
-
className: "dont"
|
|
7324
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
7325
|
-
className: "text-primary",
|
|
7326
|
-
type: Typography.BODY_LARGE,
|
|
7327
|
-
children: dont
|
|
7328
|
-
})]
|
|
7473
|
+
jsx(Instruction, {
|
|
7474
|
+
item: dont,
|
|
7475
|
+
type: "dont"
|
|
7329
7476
|
}, index))]
|
|
7330
7477
|
});
|
|
7331
7478
|
};
|
|
7479
|
+
function Instruction({
|
|
7480
|
+
item,
|
|
7481
|
+
type
|
|
7482
|
+
}) {
|
|
7483
|
+
const isInstructionNode = typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;
|
|
7484
|
+
return /*#__PURE__*/jsxs("div", {
|
|
7485
|
+
className: "instruction",
|
|
7486
|
+
"aria-label": isInstructionNode ? item['aria-label'] : undefined,
|
|
7487
|
+
children: [type === 'do' ? /*#__PURE__*/jsx(CheckCircleFill, {
|
|
7488
|
+
size: 24,
|
|
7489
|
+
className: type
|
|
7490
|
+
}) : /*#__PURE__*/jsx(CrossCircleFill, {
|
|
7491
|
+
size: 24,
|
|
7492
|
+
className: type
|
|
7493
|
+
}), /*#__PURE__*/jsx(Body, {
|
|
7494
|
+
className: "text-primary",
|
|
7495
|
+
type: Typography.BODY_LARGE,
|
|
7496
|
+
children: isInstructionNode ? item.content : item
|
|
7497
|
+
})]
|
|
7498
|
+
});
|
|
7499
|
+
}
|
|
7332
7500
|
var InstructionsList$1 = InstructionsList;
|
|
7333
7501
|
|
|
7334
7502
|
const Loader = ({
|
|
@@ -10195,128 +10363,6 @@ PhoneNumberInput.defaultProps = {
|
|
|
10195
10363
|
};
|
|
10196
10364
|
var PhoneNumberInput$1 = PhoneNumberInput;
|
|
10197
10365
|
|
|
10198
|
-
const radius = {
|
|
10199
|
-
xs: 11,
|
|
10200
|
-
sm: 22,
|
|
10201
|
-
xl: 61
|
|
10202
|
-
};
|
|
10203
|
-
const ANIMATION_DURATION_IN_MS = 1500;
|
|
10204
|
-
class ProcessIndicator extends Component {
|
|
10205
|
-
constructor(props) {
|
|
10206
|
-
super(props);
|
|
10207
|
-
this.state = {
|
|
10208
|
-
status: props.status,
|
|
10209
|
-
size: props.size
|
|
10210
|
-
};
|
|
10211
|
-
this.interval = null;
|
|
10212
|
-
this.timeout = null;
|
|
10213
|
-
}
|
|
10214
|
-
|
|
10215
|
-
/**
|
|
10216
|
-
* Create interval for animation duration (1500ms)
|
|
10217
|
-
* Update state only at the end of every interval
|
|
10218
|
-
* (end of animation loop) if props changed before end of animation
|
|
10219
|
-
*/
|
|
10220
|
-
componentDidMount() {
|
|
10221
|
-
this.interval = setInterval(() => {
|
|
10222
|
-
const statusFromState = this.state.status;
|
|
10223
|
-
const sizeFromState = this.state.size;
|
|
10224
|
-
const statusFromProps = this.props.status;
|
|
10225
|
-
const sizeFromProps = this.props.size;
|
|
10226
|
-
if (statusFromState !== statusFromProps) {
|
|
10227
|
-
this.setState({
|
|
10228
|
-
status: statusFromProps
|
|
10229
|
-
}, this.runCallBack(statusFromProps));
|
|
10230
|
-
}
|
|
10231
|
-
if (sizeFromState !== sizeFromProps) {
|
|
10232
|
-
this.setState({
|
|
10233
|
-
size: sizeFromProps
|
|
10234
|
-
});
|
|
10235
|
-
}
|
|
10236
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
10237
|
-
}
|
|
10238
|
-
|
|
10239
|
-
/**
|
|
10240
|
-
* Only trigger render if comopnent's state got
|
|
10241
|
-
* updated from interval callback
|
|
10242
|
-
*
|
|
10243
|
-
* @param nextProps
|
|
10244
|
-
* @param nextState
|
|
10245
|
-
*/
|
|
10246
|
-
shouldComponentUpdate(nextProps, nextState) {
|
|
10247
|
-
const isSameStatus = nextProps.status === nextState.status;
|
|
10248
|
-
const isSameSize = nextProps.size === nextState.size;
|
|
10249
|
-
return isSameStatus && isSameSize;
|
|
10250
|
-
}
|
|
10251
|
-
|
|
10252
|
-
// Clear interval before destroying component
|
|
10253
|
-
componentWillUnmount() {
|
|
10254
|
-
clearInterval(this.interval);
|
|
10255
|
-
clearTimeout(this.timeout);
|
|
10256
|
-
}
|
|
10257
|
-
runCallBack = statusFromProps => {
|
|
10258
|
-
const {
|
|
10259
|
-
onAnimationCompleted
|
|
10260
|
-
} = this.props;
|
|
10261
|
-
if (onAnimationCompleted) {
|
|
10262
|
-
this.timeouts = setTimeout(() => {
|
|
10263
|
-
onAnimationCompleted(statusFromProps);
|
|
10264
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
10265
|
-
}
|
|
10266
|
-
};
|
|
10267
|
-
render() {
|
|
10268
|
-
const {
|
|
10269
|
-
className,
|
|
10270
|
-
'data-testid': dataTestId
|
|
10271
|
-
} = this.props;
|
|
10272
|
-
const {
|
|
10273
|
-
size,
|
|
10274
|
-
status
|
|
10275
|
-
} = this.state;
|
|
10276
|
-
const classes = classNames(`process process-${size}`, className, {
|
|
10277
|
-
[`process-danger`]: status === Status.FAILED,
|
|
10278
|
-
[`process-stopped`]: status === Status.HIDDEN,
|
|
10279
|
-
[`process-success`]: status === Status.SUCCEEDED
|
|
10280
|
-
});
|
|
10281
|
-
return /*#__PURE__*/jsxs("span", {
|
|
10282
|
-
className: classes,
|
|
10283
|
-
"data-testid": dataTestId,
|
|
10284
|
-
children: [/*#__PURE__*/jsxs("span", {
|
|
10285
|
-
className: "process-icon-container",
|
|
10286
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
10287
|
-
className: "process-icon-horizontal"
|
|
10288
|
-
}), /*#__PURE__*/jsx("span", {
|
|
10289
|
-
className: "process-icon-vertical"
|
|
10290
|
-
})]
|
|
10291
|
-
}), /*#__PURE__*/jsx("svg", {
|
|
10292
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
10293
|
-
children: /*#__PURE__*/jsx("circle", {
|
|
10294
|
-
className: "process-circle",
|
|
10295
|
-
cx: "50%",
|
|
10296
|
-
cy: "50%",
|
|
10297
|
-
r: radius[this.state.size],
|
|
10298
|
-
fillOpacity: "0.0"
|
|
10299
|
-
})
|
|
10300
|
-
})]
|
|
10301
|
-
});
|
|
10302
|
-
}
|
|
10303
|
-
}
|
|
10304
|
-
ProcessIndicator.propTypes = {
|
|
10305
|
-
status: PropTypes.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
|
|
10306
|
-
size: PropTypes.oneOf(['xs', 'sm', 'xl']),
|
|
10307
|
-
onAnimationCompleted: PropTypes.func,
|
|
10308
|
-
className: PropTypes.string,
|
|
10309
|
-
'data-testid': PropTypes.string
|
|
10310
|
-
};
|
|
10311
|
-
ProcessIndicator.defaultProps = {
|
|
10312
|
-
status: Status.PROCESSING,
|
|
10313
|
-
size: Size.SMALL,
|
|
10314
|
-
onAnimationCompleted: null,
|
|
10315
|
-
className: undefined,
|
|
10316
|
-
'data-testid': null
|
|
10317
|
-
};
|
|
10318
|
-
var ProcessIndicator$1 = ProcessIndicator;
|
|
10319
|
-
|
|
10320
10366
|
const Progress = ({
|
|
10321
10367
|
className,
|
|
10322
10368
|
id,
|