@transferwise/components 46.33.0 → 46.35.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.js +195 -200
- package/build/index.js.map +1 -1
- package/build/index.mjs +189 -194
- package/build/index.mjs.map +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/alert/Alert.d.ts +3 -2
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/hooks/useMedia.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -11
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/drawer/Drawer.d.ts +4 -4
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/processIndicator/ProcessIndicator.d.ts +36 -19
- package/build/types/processIndicator/ProcessIndicator.d.ts.map +1 -1
- package/build/types/processIndicator/index.d.ts +2 -2
- package/build/types/processIndicator/index.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/build/types/snackbar/Snackbar.d.ts +0 -1
- package/build/types/snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/test-utils/wait.d.ts +2 -0
- package/build/types/test-utils/wait.d.ts.map +1 -0
- package/build/types/tooltip/Tooltip.d.ts +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/package.json +10 -14
- package/src/accordion/AccordionItem/AccordionItem.tsx +2 -4
- package/src/alert/Alert.spec.tsx +12 -0
- package/src/alert/Alert.story.tsx +11 -1
- package/src/alert/Alert.tsx +33 -14
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -3
- package/src/button/Button.tsx +1 -1
- package/src/common/hooks/useConditionalListener/useConditionalListener.spec.js +1 -1
- package/src/common/hooks/useHasIntersected/useHasIntersected.spec.js +3 -3
- package/src/common/hooks/useMedia.spec.ts +1 -1
- package/src/common/hooks/useMedia.ts +1 -2
- package/src/common/panel/Panel.tsx +90 -92
- package/src/common/responsivePanel/ResponsivePanel.tsx +34 -38
- package/src/dateLookup/DateLookup.rtl.spec.tsx +181 -5
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +171 -124
- package/src/drawer/Drawer.js +3 -3
- package/src/field/Field.tsx +3 -3
- package/src/index.ts +3 -2
- package/src/inputs/SelectInput.story.tsx +3 -2
- package/src/inputs/SelectInput.tsx +10 -2
- package/src/modal/Modal.tsx +1 -2
- package/src/processIndicator/ProcessIndicator.rtl.spec.tsx +45 -0
- package/src/processIndicator/ProcessIndicator.tsx +110 -0
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -1
- package/src/snackbar/Snackbar.spec.js +8 -2
- package/src/snackbar/Snackbar.story.tsx +3 -1
- package/src/snackbar/Snackbar.tsx +1 -1
- package/src/tabs/Tabs.spec.js +46 -27
- package/src/test-utils/index.js +5 -7
- package/src/test-utils/jest.setup.js +9 -3
- package/src/test-utils/wait.ts +7 -0
- package/src/tooltip/Tooltip.tsx +44 -46
- package/src/tooltip/__snapshots__/Tooltip.spec.tsx.snap +2 -2
- package/src/upload/Upload.spec.js +34 -13
- package/src/uploadInput/UploadInput.spec.tsx +21 -23
- package/src/uploadInput/uploadItem/UploadItem.tsx +1 -3
- package/src/withDisplayFormat/WithDisplayFormat.spec.js +63 -32
- package/src/withDisplayFormat/WithDisplayFormat.tsx +4 -6
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -180
- package/src/processIndicator/ProcessIndicator.js +0 -117
- package/src/processIndicator/ProcessIndicator.spec.js +0 -101
- /package/src/processIndicator/{index.js → index.ts} +0 -0
package/build/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { forwardRef, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
|
|
3
|
-
import { useId } from '@radix-ui/react-id';
|
|
2
|
+
import React__default, { forwardRef, useId, cloneElement, useState, useEffect, useRef, useMemo, Component, createContext, useContext, useSyncExternalStore, useCallback, useImperativeHandle, createElement, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill,
|
|
5
|
+
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, ArrowRight, Download, ChevronLeft, ChevronRight, AlertCircleFill, AlertCircle, ArrowLeft, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
|
|
7
6
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
8
7
|
import PropTypes from 'prop-types';
|
|
9
8
|
import commonmark from 'commonmark';
|
|
@@ -11,7 +10,6 @@ import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
|
11
10
|
import { CSSTransition } from 'react-transition-group';
|
|
12
11
|
import { FocusScope } from '@react-aria/focus';
|
|
13
12
|
import { createPortal } from 'react-dom';
|
|
14
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
15
13
|
import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
16
14
|
import { formatDate, formatMoney, formatAmount } from '@transferwise/formatting';
|
|
17
15
|
import { Transition, Listbox } from '@headlessui/react';
|
|
@@ -20,6 +18,7 @@ import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, Floa
|
|
|
20
18
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
21
19
|
import { usePopper } from 'react-popper';
|
|
22
20
|
import { Flag, Illustration } from '@wise/art';
|
|
21
|
+
import { useId as useId$1 } from '@radix-ui/react-id';
|
|
23
22
|
import clamp$2 from 'lodash.clamp';
|
|
24
23
|
import debounce from 'lodash.debounce';
|
|
25
24
|
import requiredIf from 'react-required-if';
|
|
@@ -950,7 +949,7 @@ function Alert({
|
|
|
950
949
|
"data-testid": "alert",
|
|
951
950
|
onTouchStart: () => setShouldFire(true),
|
|
952
951
|
onTouchEnd: event => {
|
|
953
|
-
if (shouldFire && action &&
|
|
952
|
+
if (shouldFire && action?.href &&
|
|
954
953
|
// Check if current event is triggered from closeButton
|
|
955
954
|
event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
|
|
956
955
|
if (action.target === '_blank') {
|
|
@@ -987,13 +986,8 @@ function Alert({
|
|
|
987
986
|
children: message
|
|
988
987
|
})
|
|
989
988
|
})]
|
|
990
|
-
}), action && /*#__PURE__*/jsx(
|
|
991
|
-
|
|
992
|
-
className: "m-t-1",
|
|
993
|
-
"aria-label": action['aria-label'],
|
|
994
|
-
target: action.target,
|
|
995
|
-
type: Typography.LINK_LARGE,
|
|
996
|
-
children: action.text
|
|
989
|
+
}), action && /*#__PURE__*/jsx(Action, {
|
|
990
|
+
action: action
|
|
997
991
|
})]
|
|
998
992
|
})]
|
|
999
993
|
}), onDismiss && /*#__PURE__*/jsx(CloseButton, {
|
|
@@ -1020,6 +1014,28 @@ function alertArrowClassNames(arrow) {
|
|
|
1020
1014
|
return 'arrow';
|
|
1021
1015
|
}
|
|
1022
1016
|
}
|
|
1017
|
+
function Action({
|
|
1018
|
+
action
|
|
1019
|
+
}) {
|
|
1020
|
+
if ('href' in action) {
|
|
1021
|
+
return /*#__PURE__*/jsx(Link, {
|
|
1022
|
+
href: action.href,
|
|
1023
|
+
className: "m-t-1",
|
|
1024
|
+
"aria-label": action['aria-label'],
|
|
1025
|
+
target: action.target,
|
|
1026
|
+
type: Typography.LINK_LARGE,
|
|
1027
|
+
onClick: action.onClick,
|
|
1028
|
+
children: action.text
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return /*#__PURE__*/jsx("button", {
|
|
1032
|
+
type: "button",
|
|
1033
|
+
"aria-label": action['aria-label'],
|
|
1034
|
+
className: "btn-unstyled np-text-link-large m-t-1",
|
|
1035
|
+
onClick: action.onClick,
|
|
1036
|
+
children: action.text
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1023
1039
|
|
|
1024
1040
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
1025
1041
|
var AvatarType;
|
|
@@ -1234,68 +1250,67 @@ const radius = {
|
|
|
1234
1250
|
};
|
|
1235
1251
|
const ANIMATION_DURATION_IN_MS = 1500;
|
|
1236
1252
|
class ProcessIndicator extends Component {
|
|
1253
|
+
static defaultProps = {
|
|
1254
|
+
status: 'processing',
|
|
1255
|
+
size: 'sm'
|
|
1256
|
+
};
|
|
1257
|
+
interval = 0;
|
|
1258
|
+
timeout = 0;
|
|
1237
1259
|
constructor(props) {
|
|
1238
1260
|
super(props);
|
|
1239
1261
|
this.state = {
|
|
1240
1262
|
status: props.status,
|
|
1241
1263
|
size: props.size
|
|
1242
1264
|
};
|
|
1243
|
-
this.interval = null;
|
|
1244
|
-
this.timeout = null;
|
|
1245
1265
|
}
|
|
1246
|
-
|
|
1247
1266
|
/**
|
|
1248
1267
|
* Create interval for animation duration (1500ms)
|
|
1249
1268
|
* Update state only at the end of every interval
|
|
1250
1269
|
* (end of animation loop) if props changed before end of animation
|
|
1251
1270
|
*/
|
|
1252
1271
|
componentDidMount() {
|
|
1253
|
-
this.interval = setInterval(() => {
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1272
|
+
this.interval = window.setInterval(() => {
|
|
1273
|
+
const {
|
|
1274
|
+
status: targetStatus,
|
|
1275
|
+
size: targetSize,
|
|
1276
|
+
onAnimationCompleted
|
|
1277
|
+
} = this.props;
|
|
1278
|
+
const {
|
|
1279
|
+
status: currentStatus,
|
|
1280
|
+
size: currentSize
|
|
1281
|
+
} = this.state;
|
|
1282
|
+
if (currentStatus !== targetStatus) {
|
|
1259
1283
|
this.setState({
|
|
1260
|
-
status:
|
|
1261
|
-
},
|
|
1284
|
+
status: targetStatus
|
|
1285
|
+
}, () => {
|
|
1286
|
+
if (onAnimationCompleted) {
|
|
1287
|
+
this.timeout = window.setTimeout(() => {
|
|
1288
|
+
onAnimationCompleted(targetStatus);
|
|
1289
|
+
}, ANIMATION_DURATION_IN_MS);
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1262
1292
|
}
|
|
1263
|
-
if (
|
|
1293
|
+
if (currentSize !== targetSize) {
|
|
1264
1294
|
this.setState({
|
|
1265
|
-
size:
|
|
1295
|
+
size: targetSize
|
|
1266
1296
|
});
|
|
1267
1297
|
}
|
|
1268
1298
|
}, ANIMATION_DURATION_IN_MS);
|
|
1269
1299
|
}
|
|
1270
|
-
|
|
1271
1300
|
/**
|
|
1272
1301
|
* Only trigger render if comopnent's state got
|
|
1273
1302
|
* updated from interval callback
|
|
1274
|
-
*
|
|
1275
|
-
* @param nextProps
|
|
1276
|
-
* @param nextState
|
|
1277
1303
|
*/
|
|
1278
1304
|
shouldComponentUpdate(nextProps, nextState) {
|
|
1279
1305
|
const isSameStatus = nextProps.status === nextState.status;
|
|
1280
1306
|
const isSameSize = nextProps.size === nextState.size;
|
|
1281
1307
|
return isSameStatus && isSameSize;
|
|
1282
1308
|
}
|
|
1283
|
-
|
|
1284
1309
|
// Clear interval before destroying component
|
|
1285
1310
|
componentWillUnmount() {
|
|
1286
|
-
clearInterval(this.interval);
|
|
1287
|
-
clearTimeout(this.timeout);
|
|
1311
|
+
window.clearInterval(this.interval);
|
|
1312
|
+
window.clearTimeout(this.timeout);
|
|
1288
1313
|
}
|
|
1289
|
-
runCallBack = statusFromProps => {
|
|
1290
|
-
const {
|
|
1291
|
-
onAnimationCompleted
|
|
1292
|
-
} = this.props;
|
|
1293
|
-
if (onAnimationCompleted) {
|
|
1294
|
-
this.timeouts = setTimeout(() => {
|
|
1295
|
-
onAnimationCompleted(statusFromProps);
|
|
1296
|
-
}, ANIMATION_DURATION_IN_MS);
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
1314
|
render() {
|
|
1300
1315
|
const {
|
|
1301
1316
|
className,
|
|
@@ -1326,28 +1341,13 @@ class ProcessIndicator extends Component {
|
|
|
1326
1341
|
className: "process-circle",
|
|
1327
1342
|
cx: "50%",
|
|
1328
1343
|
cy: "50%",
|
|
1329
|
-
r: radius[
|
|
1344
|
+
r: radius[size],
|
|
1330
1345
|
fillOpacity: "0.0"
|
|
1331
1346
|
})
|
|
1332
1347
|
})]
|
|
1333
1348
|
});
|
|
1334
1349
|
}
|
|
1335
1350
|
}
|
|
1336
|
-
ProcessIndicator.propTypes = {
|
|
1337
|
-
status: PropTypes.oneOf(['processing', 'failed', 'succeeded', 'hidden']),
|
|
1338
|
-
size: PropTypes.oneOf(['xxs', 'xs', 'sm', 'xl']),
|
|
1339
|
-
onAnimationCompleted: PropTypes.func,
|
|
1340
|
-
className: PropTypes.string,
|
|
1341
|
-
'data-testid': PropTypes.string
|
|
1342
|
-
};
|
|
1343
|
-
ProcessIndicator.defaultProps = {
|
|
1344
|
-
status: Status.PROCESSING,
|
|
1345
|
-
size: Size.SMALL,
|
|
1346
|
-
onAnimationCompleted: null,
|
|
1347
|
-
className: undefined,
|
|
1348
|
-
'data-testid': null
|
|
1349
|
-
};
|
|
1350
|
-
var ProcessIndicator$1 = ProcessIndicator;
|
|
1351
1351
|
|
|
1352
1352
|
var messages$b = defineMessages({
|
|
1353
1353
|
loadingAriaLabel: {
|
|
@@ -1469,7 +1469,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
1469
1469
|
...props,
|
|
1470
1470
|
"aria-live": loading ? 'polite' : 'off',
|
|
1471
1471
|
"aria-label": loading ? intl.formatMessage(messages$b.loadingAriaLabel) : rest['aria-label'],
|
|
1472
|
-
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator
|
|
1472
|
+
children: [children, loading && /*#__PURE__*/jsx(ProcessIndicator, {
|
|
1473
1473
|
size: processIndicatorSize(),
|
|
1474
1474
|
className: "btn-loader"
|
|
1475
1475
|
})]
|
|
@@ -1620,7 +1620,6 @@ const useHasIntersected = ({
|
|
|
1620
1620
|
return [hasIntersected];
|
|
1621
1621
|
};
|
|
1622
1622
|
|
|
1623
|
-
// eslint-disable-next-line import/extensions
|
|
1624
1623
|
function useMedia(query) {
|
|
1625
1624
|
return useSyncExternalStore(onStoreChange => {
|
|
1626
1625
|
const mediaQueryList = window.matchMedia(query);
|
|
@@ -2832,12 +2831,12 @@ Drawer.propTypes = {
|
|
|
2832
2831
|
footerContent: PropTypes.node,
|
|
2833
2832
|
/** The content to appear in the drawer header. */
|
|
2834
2833
|
headerTitle: PropTypes.node,
|
|
2835
|
-
/** The action to perform on close click. */
|
|
2836
|
-
onClose: PropTypes.func,
|
|
2837
2834
|
/** The status of Drawer either open or not. */
|
|
2838
2835
|
open: PropTypes.bool,
|
|
2839
2836
|
/** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
|
|
2840
|
-
position: PropTypes.oneOf(['left', 'right', 'bottom'])
|
|
2837
|
+
position: PropTypes.oneOf(['left', 'right', 'bottom']),
|
|
2838
|
+
/** The action to perform on close click. */
|
|
2839
|
+
onClose: PropTypes.func
|
|
2841
2840
|
};
|
|
2842
2841
|
Drawer.defaultProps = {
|
|
2843
2842
|
children: null,
|
|
@@ -3512,7 +3511,7 @@ const fallbackPlacements = {
|
|
|
3512
3511
|
[Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],
|
|
3513
3512
|
[Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM]
|
|
3514
3513
|
};
|
|
3515
|
-
const Panel = /*#__PURE__*/forwardRef(({
|
|
3514
|
+
const Panel = /*#__PURE__*/forwardRef(function Panel({
|
|
3516
3515
|
arrow = false,
|
|
3517
3516
|
flip = true,
|
|
3518
3517
|
altAxis = false,
|
|
@@ -3523,7 +3522,7 @@ const Panel = /*#__PURE__*/forwardRef(({
|
|
|
3523
3522
|
anchorRef,
|
|
3524
3523
|
anchorWidth = false,
|
|
3525
3524
|
...rest
|
|
3526
|
-
}, reference)
|
|
3525
|
+
}, reference) {
|
|
3527
3526
|
const [arrowElement, setArrowElement] = useState(null);
|
|
3528
3527
|
const [popperElement, setPopperElement] = useState(null);
|
|
3529
3528
|
const modifiers = [];
|
|
@@ -3601,7 +3600,7 @@ const Panel = /*#__PURE__*/forwardRef(({
|
|
|
3601
3600
|
...attributes.popper,
|
|
3602
3601
|
className: classNames('np-panel', {
|
|
3603
3602
|
'np-panel--open': open
|
|
3604
|
-
}, rest
|
|
3603
|
+
}, rest.className),
|
|
3605
3604
|
children: /*#__PURE__*/jsxs("div", {
|
|
3606
3605
|
ref: reference
|
|
3607
3606
|
/* eslint-disable-next-line react/forbid-dom-props */,
|
|
@@ -3620,7 +3619,7 @@ const Panel = /*#__PURE__*/forwardRef(({
|
|
|
3620
3619
|
});
|
|
3621
3620
|
var Panel$1 = Panel;
|
|
3622
3621
|
|
|
3623
|
-
const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
3622
|
+
const ResponsivePanel = /*#__PURE__*/forwardRef(function ResponsivePanel({
|
|
3624
3623
|
anchorRef,
|
|
3625
3624
|
arrow = false,
|
|
3626
3625
|
flip = true,
|
|
@@ -3629,7 +3628,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3629
3628
|
onClose,
|
|
3630
3629
|
open = false,
|
|
3631
3630
|
position = Position.BOTTOM
|
|
3632
|
-
}, reference)
|
|
3631
|
+
}, reference) {
|
|
3633
3632
|
const {
|
|
3634
3633
|
isMobile
|
|
3635
3634
|
} = useLayout();
|
|
@@ -4968,6 +4967,84 @@ const Emphasis = ({
|
|
|
4968
4967
|
}) : null;
|
|
4969
4968
|
};
|
|
4970
4969
|
|
|
4970
|
+
function InlineAlert({
|
|
4971
|
+
id,
|
|
4972
|
+
type = 'neutral',
|
|
4973
|
+
className,
|
|
4974
|
+
children
|
|
4975
|
+
}) {
|
|
4976
|
+
const danger = type === 'negative' || type === 'error';
|
|
4977
|
+
return /*#__PURE__*/jsxs("div", {
|
|
4978
|
+
role: "alert",
|
|
4979
|
+
id: id,
|
|
4980
|
+
className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
4981
|
+
children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
|
|
4982
|
+
children: children
|
|
4983
|
+
})]
|
|
4984
|
+
});
|
|
4985
|
+
}
|
|
4986
|
+
|
|
4987
|
+
const Label = ({
|
|
4988
|
+
id,
|
|
4989
|
+
htmlFor,
|
|
4990
|
+
className,
|
|
4991
|
+
children
|
|
4992
|
+
}) => {
|
|
4993
|
+
return /*#__PURE__*/jsx("label", {
|
|
4994
|
+
id: id,
|
|
4995
|
+
htmlFor: htmlFor,
|
|
4996
|
+
className: classNames('control-label d-flex flex-column gap-y-1 m-b-0', className),
|
|
4997
|
+
children: children
|
|
4998
|
+
});
|
|
4999
|
+
};
|
|
5000
|
+
|
|
5001
|
+
const Field = ({
|
|
5002
|
+
id,
|
|
5003
|
+
label,
|
|
5004
|
+
hint,
|
|
5005
|
+
error,
|
|
5006
|
+
className,
|
|
5007
|
+
children
|
|
5008
|
+
}) => {
|
|
5009
|
+
const hasError = Boolean(error);
|
|
5010
|
+
const hasHint = Boolean(hint) && !hasError;
|
|
5011
|
+
const labelId = useId();
|
|
5012
|
+
const fallbackInputId = useId();
|
|
5013
|
+
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
5014
|
+
const descriptionId = useId();
|
|
5015
|
+
return /*#__PURE__*/jsx(FieldLabelIdContextProvider, {
|
|
5016
|
+
value: labelId,
|
|
5017
|
+
children: /*#__PURE__*/jsx(InputIdContextProvider, {
|
|
5018
|
+
value: inputId,
|
|
5019
|
+
children: /*#__PURE__*/jsx(InputDescribedByProvider, {
|
|
5020
|
+
value: hasError || hasHint ? descriptionId : undefined,
|
|
5021
|
+
children: /*#__PURE__*/jsx(InputInvalidProvider, {
|
|
5022
|
+
value: hasError,
|
|
5023
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
5024
|
+
className: classNames('form-group d-block', {
|
|
5025
|
+
'has-error': hasError,
|
|
5026
|
+
'has-info': hasHint
|
|
5027
|
+
}, className),
|
|
5028
|
+
children: [/*#__PURE__*/jsxs(Label, {
|
|
5029
|
+
id: labelId,
|
|
5030
|
+
htmlFor: inputId,
|
|
5031
|
+
children: [label, children]
|
|
5032
|
+
}), hasHint && /*#__PURE__*/jsx(InlineAlert, {
|
|
5033
|
+
type: Sentiment.NEUTRAL,
|
|
5034
|
+
id: descriptionId,
|
|
5035
|
+
children: hint
|
|
5036
|
+
}), hasError && /*#__PURE__*/jsx(InlineAlert, {
|
|
5037
|
+
type: Sentiment.NEGATIVE,
|
|
5038
|
+
id: descriptionId,
|
|
5039
|
+
children: error
|
|
5040
|
+
})]
|
|
5041
|
+
})
|
|
5042
|
+
})
|
|
5043
|
+
})
|
|
5044
|
+
})
|
|
5045
|
+
});
|
|
5046
|
+
};
|
|
5047
|
+
|
|
4971
5048
|
const FlowHeader = /*#__PURE__*/React.forwardRef(({
|
|
4972
5049
|
bottomContent,
|
|
4973
5050
|
className,
|
|
@@ -5214,42 +5291,40 @@ const Tooltip = ({
|
|
|
5214
5291
|
forceUpdate();
|
|
5215
5292
|
}
|
|
5216
5293
|
}, [open]);
|
|
5217
|
-
return /*#__PURE__*/
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
})]
|
|
5252
|
-
})
|
|
5294
|
+
return /*#__PURE__*/jsxs("span", {
|
|
5295
|
+
ref: anchorReference,
|
|
5296
|
+
className: "tw-tooltip-container",
|
|
5297
|
+
onMouseOver: () => setOpen(true),
|
|
5298
|
+
onFocus: () => setOpen(true),
|
|
5299
|
+
onMouseOut: () => setOpen(false),
|
|
5300
|
+
onBlur: () => setOpen(false),
|
|
5301
|
+
children: [children ? /*#__PURE__*/cloneElement(children, {
|
|
5302
|
+
'aria-describedby': `${tooltipId}-tooltip`
|
|
5303
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
5304
|
+
// @ts-expect-error
|
|
5305
|
+
ref: setPopperElement,
|
|
5306
|
+
className: classNames('np-tooltip', 'np-panel', open ? `np-panel--open np-tooltip--open` : null, className)
|
|
5307
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5308
|
+
,
|
|
5309
|
+
style: {
|
|
5310
|
+
...styles.popper
|
|
5311
|
+
},
|
|
5312
|
+
...attributes.popper,
|
|
5313
|
+
"aria-hidden": !open,
|
|
5314
|
+
role: "tooltip",
|
|
5315
|
+
id: `${tooltipId}-tooltip`,
|
|
5316
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
5317
|
+
className: "np-panel__content tooltip-inner",
|
|
5318
|
+
children: [label, /*#__PURE__*/jsx("div", {
|
|
5319
|
+
// @ts-expect-error
|
|
5320
|
+
ref: setArrowElement,
|
|
5321
|
+
className: classNames('np-panel__arrow')
|
|
5322
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5323
|
+
,
|
|
5324
|
+
style: styles.arrow
|
|
5325
|
+
})]
|
|
5326
|
+
})
|
|
5327
|
+
})]
|
|
5253
5328
|
});
|
|
5254
5329
|
};
|
|
5255
5330
|
|
|
@@ -5447,84 +5522,6 @@ const FlowNavigation = ({
|
|
|
5447
5522
|
});
|
|
5448
5523
|
};
|
|
5449
5524
|
|
|
5450
|
-
function InlineAlert({
|
|
5451
|
-
id,
|
|
5452
|
-
type = 'neutral',
|
|
5453
|
-
className,
|
|
5454
|
-
children
|
|
5455
|
-
}) {
|
|
5456
|
-
const danger = type === 'negative' || type === 'error';
|
|
5457
|
-
return /*#__PURE__*/jsxs("div", {
|
|
5458
|
-
role: "alert",
|
|
5459
|
-
id: id,
|
|
5460
|
-
className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
5461
|
-
children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
|
|
5462
|
-
children: children
|
|
5463
|
-
})]
|
|
5464
|
-
});
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
const Label = ({
|
|
5468
|
-
id,
|
|
5469
|
-
htmlFor,
|
|
5470
|
-
className,
|
|
5471
|
-
children
|
|
5472
|
-
}) => {
|
|
5473
|
-
return /*#__PURE__*/jsx("label", {
|
|
5474
|
-
id: id,
|
|
5475
|
-
htmlFor: htmlFor,
|
|
5476
|
-
className: classNames('control-label d-flex flex-column gap-y-1 m-b-0', className),
|
|
5477
|
-
children: children
|
|
5478
|
-
});
|
|
5479
|
-
};
|
|
5480
|
-
|
|
5481
|
-
const Field = ({
|
|
5482
|
-
id,
|
|
5483
|
-
label,
|
|
5484
|
-
hint,
|
|
5485
|
-
error,
|
|
5486
|
-
className,
|
|
5487
|
-
children
|
|
5488
|
-
}) => {
|
|
5489
|
-
const hasError = Boolean(error);
|
|
5490
|
-
const hasHint = Boolean(hint) && !hasError;
|
|
5491
|
-
const labelId = useId();
|
|
5492
|
-
const fallbackInputId = useId(); // TODO: Use `React.useId()` when react>=18
|
|
5493
|
-
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
5494
|
-
const descriptionId = useId(); // TODO: Use `React.useId()` when react>=18
|
|
5495
|
-
return /*#__PURE__*/jsx(FieldLabelIdContextProvider, {
|
|
5496
|
-
value: labelId,
|
|
5497
|
-
children: /*#__PURE__*/jsx(InputIdContextProvider, {
|
|
5498
|
-
value: inputId,
|
|
5499
|
-
children: /*#__PURE__*/jsx(InputDescribedByProvider, {
|
|
5500
|
-
value: hasError || hasHint ? descriptionId : undefined,
|
|
5501
|
-
children: /*#__PURE__*/jsx(InputInvalidProvider, {
|
|
5502
|
-
value: hasError,
|
|
5503
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
5504
|
-
className: classNames('form-group d-block', {
|
|
5505
|
-
'has-error': hasError,
|
|
5506
|
-
'has-info': hasHint
|
|
5507
|
-
}, className),
|
|
5508
|
-
children: [/*#__PURE__*/jsxs(Label, {
|
|
5509
|
-
id: labelId,
|
|
5510
|
-
htmlFor: inputId,
|
|
5511
|
-
children: [label, children]
|
|
5512
|
-
}), hasHint && /*#__PURE__*/jsx(InlineAlert, {
|
|
5513
|
-
type: Sentiment.NEUTRAL,
|
|
5514
|
-
id: descriptionId,
|
|
5515
|
-
children: hint
|
|
5516
|
-
}), hasError && /*#__PURE__*/jsx(InlineAlert, {
|
|
5517
|
-
type: Sentiment.NEGATIVE,
|
|
5518
|
-
id: descriptionId,
|
|
5519
|
-
children: error
|
|
5520
|
-
})]
|
|
5521
|
-
})
|
|
5522
|
-
})
|
|
5523
|
-
})
|
|
5524
|
-
})
|
|
5525
|
-
});
|
|
5526
|
-
};
|
|
5527
|
-
|
|
5528
5525
|
const HeaderAction = ({
|
|
5529
5526
|
action
|
|
5530
5527
|
}) => {
|
|
@@ -6134,10 +6131,9 @@ class WithDisplayFormat extends Component {
|
|
|
6134
6131
|
return 'Backspace';
|
|
6135
6132
|
}
|
|
6136
6133
|
return triggerEvent.key;
|
|
6137
|
-
} else {
|
|
6138
|
-
// triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
|
|
6139
|
-
return 'Paste';
|
|
6140
6134
|
}
|
|
6135
|
+
// triggerEvent can be null only in case of "autofilling" (via password manager extension or browser build-in one) events
|
|
6136
|
+
return 'Paste';
|
|
6141
6137
|
};
|
|
6142
6138
|
resetEvent = () => {
|
|
6143
6139
|
this.setState({
|
|
@@ -6290,11 +6286,10 @@ class WithDisplayFormat extends Component {
|
|
|
6290
6286
|
selectionEnd,
|
|
6291
6287
|
pastedLength
|
|
6292
6288
|
} = this.state;
|
|
6289
|
+
const target = triggerEvent?.currentTarget;
|
|
6293
6290
|
const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
|
|
6294
6291
|
setTimeout(() => {
|
|
6295
|
-
|
|
6296
|
-
triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
|
|
6297
|
-
}
|
|
6292
|
+
target?.setSelectionRange(cursorPosition, cursorPosition);
|
|
6298
6293
|
this.setState({
|
|
6299
6294
|
selectionStart: cursorPosition,
|
|
6300
6295
|
selectionEnd: cursorPosition
|
|
@@ -10125,7 +10120,7 @@ function Select({
|
|
|
10125
10120
|
}, [defaultOptions, search, searchValue]);
|
|
10126
10121
|
const selectableOptions = useMemo(() => options.filter(isActionableOption), [options]);
|
|
10127
10122
|
const focusedOption = selectableOptions[keyboardFocusedOptionIndex];
|
|
10128
|
-
const fallbackButtonId = useId();
|
|
10123
|
+
const fallbackButtonId = useId$1();
|
|
10129
10124
|
const computedId = id || inputAttributes.id || fallbackButtonId;
|
|
10130
10125
|
const listboxId = `${computedId}-listbox`;
|
|
10131
10126
|
const searchBoxId = `${computedId}-searchbox`;
|
|
@@ -12587,7 +12582,7 @@ const ProcessingStep = props => {
|
|
|
12587
12582
|
"aria-hidden": isComplete,
|
|
12588
12583
|
children: /*#__PURE__*/jsxs("div", {
|
|
12589
12584
|
className: "droppable-card-content",
|
|
12590
|
-
children: [/*#__PURE__*/jsx(ProcessIndicator
|
|
12585
|
+
children: [/*#__PURE__*/jsx(ProcessIndicator, {
|
|
12591
12586
|
size: Size.Small,
|
|
12592
12587
|
status: processStatus,
|
|
12593
12588
|
onAnimationCompleted: status => onAnimationCompleted(status)
|
|
@@ -13410,7 +13405,7 @@ const UploadItem = ({
|
|
|
13410
13405
|
switch (status) {
|
|
13411
13406
|
case Status.PROCESSING:
|
|
13412
13407
|
case Status.PENDING:
|
|
13413
|
-
processIndicator = /*#__PURE__*/jsx(ProcessIndicator
|
|
13408
|
+
processIndicator = /*#__PURE__*/jsx(ProcessIndicator, {
|
|
13414
13409
|
size: Size.EXTRA_SMALL,
|
|
13415
13410
|
status: Status.PROCESSING
|
|
13416
13411
|
});
|
|
@@ -13421,7 +13416,7 @@ const UploadItem = ({
|
|
|
13421
13416
|
processIndicator = isModern ? /*#__PURE__*/jsx(StatusIcon, {
|
|
13422
13417
|
size: Size.SMALL,
|
|
13423
13418
|
sentiment: Sentiment.POSITIVE
|
|
13424
|
-
}) : /*#__PURE__*/jsx(ProcessIndicator
|
|
13419
|
+
}) : /*#__PURE__*/jsx(ProcessIndicator, {
|
|
13425
13420
|
size: Size.EXTRA_SMALL,
|
|
13426
13421
|
status: Status.SUCCEEDED
|
|
13427
13422
|
});
|
|
@@ -13436,7 +13431,7 @@ const UploadItem = ({
|
|
|
13436
13431
|
children: processIndicator
|
|
13437
13432
|
}); // Scale down ProcessIndicator to be 20px*20px to match `icons`
|
|
13438
13433
|
};
|
|
13439
|
-
const getErrorMessage = () => typeof error === 'object'
|
|
13434
|
+
const getErrorMessage = () => typeof error === 'object' ? error.message : error || formatMessage(MESSAGES.uploadingFailed);
|
|
13440
13435
|
const getDescription = () => {
|
|
13441
13436
|
if (error || status === Status.FAILED) {
|
|
13442
13437
|
return /*#__PURE__*/jsx(Body, {
|
|
@@ -14773,5 +14768,5 @@ const translations = {
|
|
|
14773
14768
|
'zh-HK': zhHK
|
|
14774
14769
|
};
|
|
14775
14770
|
|
|
14776
|
-
export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card$2 as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$1 as Card, Carousel, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, Field, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, Label, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator
|
|
14771
|
+
export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card$2 as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$1 as Card, Carousel, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, Field, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, Label, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCardGroup$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead$1 as Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
14777
14772
|
//# sourceMappingURL=index.mjs.map
|