@transferwise/components 46.12.0 → 46.14.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 +193 -352
- package/build/index.esm.js.map +1 -1
- package/build/index.js +166 -325
- package/build/index.js.map +1 -1
- package/build/main.css +6 -82
- package/build/styles/decision/Decision.css +6 -82
- package/build/styles/main.css +6 -82
- package/build/types/body/Body.d.ts +1 -1
- package/build/types/common/commonProps.d.ts +1 -1
- package/build/types/common/commonProps.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/index.d.ts +6 -6
- package/build/types/common/dateUtils/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts +2 -2
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -1
- package/build/types/dateInput/DateInput.d.ts +30 -41
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateInput/DateInput.messages.d.ts +24 -33
- package/build/types/dateInput/DateInput.messages.d.ts.map +1 -1
- package/build/types/dateInput/index.d.ts +2 -2
- package/build/types/dateInput/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/index.d.ts +1 -2
- package/build/types/dateInput/utils/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +1 -0
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/decision/Decision.d.ts +39 -52
- package/build/types/decision/Decision.d.ts.map +1 -1
- package/build/types/decision/index.d.ts +1 -2
- package/build/types/decision/index.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -1
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +1 -0
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +1 -2
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/package.json +1 -1
- package/src/common/commonProps.ts +1 -1
- package/src/common/dateUtils/getDayNames/getDayNames.spec.js +2 -2
- package/src/common/dateUtils/getDayNames/{getDayNames.js → getDayNames.ts} +5 -2
- package/src/common/dateUtils/getMonthNames/getMonthNames.spec.js +9 -8
- package/src/common/dateUtils/getMonthNames/{getMonthNames.js → getMonthNames.ts} +5 -3
- package/src/common/dateUtils/isDateValid/{isDateValid.spec.js → isDateValid.spec.ts} +1 -1
- package/src/common/dateUtils/isDateValid/isDateValid.ts +13 -0
- package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.spec.js +3 -7
- package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.js → isMonthAndYearFormat.ts} +1 -1
- package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.js → isWithinRange.spec.ts} +0 -10
- package/src/common/dateUtils/isWithinRange/{isWithinRange.js → isWithinRange.ts} +1 -1
- package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.js → moveToWithinRange.ts} +2 -2
- package/src/dateInput/DateInput.spec.js +7 -56
- package/src/dateInput/DateInput.story.tsx +11 -8
- package/src/dateInput/{DateInput.js → DateInput.tsx} +116 -123
- package/src/dateInput/index.ts +2 -0
- package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.js → convertToLocalMidnight.ts} +1 -1
- package/src/dateInput/utils/{index.js → index.ts} +0 -1
- package/src/dateLookup/DateLookup.js +12 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +12 -1
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -0
- package/src/decision/Decision.css +6 -82
- package/src/decision/Decision.less +3 -41
- package/src/decision/Decision.spec.js +56 -61
- package/src/decision/{Decision.story.js → Decision.story.tsx} +5 -5
- package/src/decision/Decision.tsx +133 -0
- package/src/decision/index.ts +1 -0
- package/src/drawer/Drawer.js +13 -2
- package/src/drawer/__snapshots__/Drawer.rtl.spec.js.snap +1 -0
- package/src/index.ts +2 -0
- package/src/main.css +6 -82
- package/src/modal/Modal.tsx +6 -3
- package/src/popover/Popover.js +7 -3
- package/src/popover/Popover.spec.js +16 -8
- package/src/popover/__snapshots__/Popover.spec.js.snap +0 -56
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/tile/Tile.js +1 -1
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts +0 -6
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts.map +0 -1
- package/build/types/dateInput/utils/explodeDate/index.d.ts +0 -2
- package/build/types/dateInput/utils/explodeDate/index.d.ts.map +0 -1
- package/build/types/decision/decisionEnums.d.ts +0 -9
- package/build/types/decision/decisionEnums.d.ts.map +0 -1
- package/build/types/sizeSwapper/SizeSwapper.d.ts +0 -3
- package/build/types/sizeSwapper/SizeSwapper.d.ts.map +0 -1
- package/build/types/sizeSwapper/index.d.ts +0 -2
- package/build/types/sizeSwapper/index.d.ts.map +0 -1
- package/src/common/dateUtils/isDateValid/isDateValid.js +0 -6
- package/src/dateInput/index.js +0 -3
- package/src/dateInput/utils/explodeDate/explodeDate.js +0 -7
- package/src/dateInput/utils/explodeDate/explodeDate.spec.js +0 -11
- package/src/dateInput/utils/explodeDate/index.js +0 -1
- package/src/decision/Decision.js +0 -148
- package/src/decision/decisionEnums.ts +0 -11
- package/src/decision/index.js +0 -2
- package/src/sizeSwapper/SizeSwapper.js +0 -69
- package/src/sizeSwapper/SizeSwapper.spec.js +0 -100
- package/src/sizeSwapper/SizeSwapper.story.js +0 -34
- package/src/sizeSwapper/index.js +0 -1
- /package/src/common/dateUtils/getDayNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/getMonthNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isDateValid/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isMonthAndYearFormat/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isWithinRange/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/moveToWithinRange/{index.js → index.ts} +0 -0
- /package/src/dateInput/{DateInput.messages.js → DateInput.messages.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.js → convertToLocalMidnight.spec.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{index.js → index.ts} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1,
|
|
|
7
7
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
10
|
+
import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
|
|
10
11
|
import { Transition, Listbox } from '@headlessui/react';
|
|
11
12
|
import mergeProps from 'merge-props';
|
|
12
13
|
import mergeRefs from 'react-merge-refs';
|
|
@@ -14,7 +15,6 @@ import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
|
14
15
|
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
|
|
15
16
|
import { FocusScope } from '@react-aria/focus';
|
|
16
17
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
17
|
-
import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
|
|
18
18
|
import { CSSTransition } from 'react-transition-group';
|
|
19
19
|
import { usePopper } from 'react-popper';
|
|
20
20
|
import throttle from 'lodash.throttle';
|
|
@@ -207,7 +207,7 @@ var Width;
|
|
|
207
207
|
/**
|
|
208
208
|
* @deprecated use `ControlType` and `Priority` enums instead
|
|
209
209
|
*/
|
|
210
|
-
var Type
|
|
210
|
+
var Type;
|
|
211
211
|
(function (Type) {
|
|
212
212
|
Type["PRIMARY"] = "primary";
|
|
213
213
|
/**
|
|
@@ -217,7 +217,7 @@ var Type$1;
|
|
|
217
217
|
Type["SECONDARY"] = "secondary";
|
|
218
218
|
Type["DANGER"] = "danger";
|
|
219
219
|
Type["LINK"] = "link";
|
|
220
|
-
})(Type
|
|
220
|
+
})(Type || (Type = {}));
|
|
221
221
|
|
|
222
222
|
var DateMode;
|
|
223
223
|
(function (DateMode) {
|
|
@@ -244,7 +244,7 @@ var Position;
|
|
|
244
244
|
Position["TOP"] = "top";
|
|
245
245
|
})(Position || (Position = {}));
|
|
246
246
|
|
|
247
|
-
var Layout
|
|
247
|
+
var Layout;
|
|
248
248
|
(function (Layout) {
|
|
249
249
|
Layout["VERTICAL"] = "VERTICAL";
|
|
250
250
|
Layout["VERTICAL_TWO_COLUMN"] = "VERTICAL_TWO_COLUMN";
|
|
@@ -253,7 +253,7 @@ var Layout$1;
|
|
|
253
253
|
Layout["HORIZONTAL_JUSTIFIED"] = "HORIZONTAL_JUSTIFIED";
|
|
254
254
|
Layout["HORIZONTAL_LEFT_ALIGNED"] = "HORIZONTAL_LEFT_ALIGNED";
|
|
255
255
|
Layout["HORIZONTAL_RIGHT_ALIGNED"] = "HORIZONTAL_RIGHT_ALIGNED";
|
|
256
|
-
})(Layout
|
|
256
|
+
})(Layout || (Layout = {}));
|
|
257
257
|
|
|
258
258
|
var Status;
|
|
259
259
|
(function (Status) {
|
|
@@ -1867,6 +1867,7 @@ const Drawer = ({
|
|
|
1867
1867
|
const {
|
|
1868
1868
|
isMobile
|
|
1869
1869
|
} = useLayout();
|
|
1870
|
+
const titleId = useId();
|
|
1870
1871
|
return /*#__PURE__*/jsx(Dimmer$1, {
|
|
1871
1872
|
open: open,
|
|
1872
1873
|
onClose: onClose,
|
|
@@ -1874,13 +1875,16 @@ const Drawer = ({
|
|
|
1874
1875
|
open: open,
|
|
1875
1876
|
position: isMobile ? Position.BOTTOM : position,
|
|
1876
1877
|
children: /*#__PURE__*/jsxs("div", {
|
|
1877
|
-
className: classNames('np-drawer', className),
|
|
1878
1878
|
role: "dialog",
|
|
1879
|
+
"aria-modal": true,
|
|
1880
|
+
"aria-labelledby": headerTitle ? titleId : undefined,
|
|
1881
|
+
className: classNames('np-drawer', className),
|
|
1879
1882
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1880
1883
|
className: classNames('np-drawer-header', {
|
|
1881
1884
|
'np-drawer-header--withborder': headerTitle
|
|
1882
1885
|
}),
|
|
1883
1886
|
children: [headerTitle && /*#__PURE__*/jsx(Title, {
|
|
1887
|
+
id: titleId,
|
|
1884
1888
|
type: Typography.TITLE_BODY,
|
|
1885
1889
|
children: headerTitle
|
|
1886
1890
|
}), /*#__PURE__*/jsx(CloseButton, {
|
|
@@ -2235,23 +2239,23 @@ const priorityClassMap = {
|
|
|
2235
2239
|
};
|
|
2236
2240
|
|
|
2237
2241
|
const deprecatedTypeMap = {
|
|
2238
|
-
[Type
|
|
2239
|
-
[Type
|
|
2240
|
-
[Type
|
|
2241
|
-
[Type
|
|
2242
|
-
[Type
|
|
2242
|
+
[Type.PRIMARY]: ControlType.ACCENT,
|
|
2243
|
+
[Type.SECONDARY]: ControlType.ACCENT,
|
|
2244
|
+
[Type.LINK]: ControlType.ACCENT,
|
|
2245
|
+
[Type.PAY]: ControlType.POSITIVE,
|
|
2246
|
+
[Type.DANGER]: ControlType.NEGATIVE
|
|
2243
2247
|
};
|
|
2244
2248
|
const oldTypePriorityMap = {
|
|
2245
|
-
[Type
|
|
2246
|
-
[Type
|
|
2247
|
-
[Type
|
|
2249
|
+
[Type.DANGER]: Priority.SECONDARY,
|
|
2250
|
+
[Type.LINK]: Priority.TERTIARY,
|
|
2251
|
+
[Type.SECONDARY]: Priority.SECONDARY
|
|
2248
2252
|
};
|
|
2249
2253
|
const deprecatedTypeMapMessage = {
|
|
2250
|
-
[Type
|
|
2251
|
-
[Type
|
|
2252
|
-
[Type
|
|
2253
|
-
[Type
|
|
2254
|
-
[Type
|
|
2254
|
+
[Type.DANGER]: 'Type.NEGATIVE',
|
|
2255
|
+
[Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',
|
|
2256
|
+
[Type.PAY]: 'ControlType.POSITIVE',
|
|
2257
|
+
[Type.PRIMARY]: 'ControlType.ACCENT',
|
|
2258
|
+
[Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY'
|
|
2255
2259
|
};
|
|
2256
2260
|
const deprecatedTypes = Object.keys(deprecatedTypeMap);
|
|
2257
2261
|
const establishNewType = originalType => deprecatedTypeMap[originalType] || originalType;
|
|
@@ -2741,15 +2745,15 @@ function getDayNames(locale, format = 'short') {
|
|
|
2741
2745
|
return days;
|
|
2742
2746
|
}
|
|
2743
2747
|
|
|
2744
|
-
function isWithinRange(date, min, max) {
|
|
2745
|
-
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2746
|
-
}
|
|
2747
|
-
|
|
2748
2748
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2749
2749
|
function moveToWithinRange(date, min, max) {
|
|
2750
2750
|
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
2751
2751
|
}
|
|
2752
2752
|
|
|
2753
|
+
function isWithinRange(date, min, max) {
|
|
2754
|
+
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2753
2757
|
const getMonthNames = (locale, format = 'long') => {
|
|
2754
2758
|
const months = [];
|
|
2755
2759
|
const date = new Date(2018, 0, 1);
|
|
@@ -2763,9 +2767,17 @@ const getMonthNames = (locale, format = 'long') => {
|
|
|
2763
2767
|
return months;
|
|
2764
2768
|
};
|
|
2765
2769
|
|
|
2766
|
-
const isDateValid = date =>
|
|
2767
|
-
|
|
2768
|
-
|
|
2770
|
+
const isDateValid = date => {
|
|
2771
|
+
if (date === null) {
|
|
2772
|
+
return false;
|
|
2773
|
+
} else if (date instanceof Date) {
|
|
2774
|
+
return validDateObject(date);
|
|
2775
|
+
} else {
|
|
2776
|
+
return validDateString(date);
|
|
2777
|
+
}
|
|
2778
|
+
};
|
|
2779
|
+
const validDateString = dateString => validDateObject(new Date(dateString));
|
|
2780
|
+
const validDateObject = dateObject => !isNaN(dateObject.getTime());
|
|
2769
2781
|
|
|
2770
2782
|
const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
|
|
2771
2783
|
|
|
@@ -2787,48 +2799,31 @@ var messages$9 = defineMessages({
|
|
|
2787
2799
|
}
|
|
2788
2800
|
});
|
|
2789
2801
|
|
|
2790
|
-
const explodeDate = date => {
|
|
2791
|
-
const year = date.getFullYear();
|
|
2792
|
-
const month = date.getMonth();
|
|
2793
|
-
const day = date.getDate();
|
|
2794
|
-
return {
|
|
2795
|
-
year,
|
|
2796
|
-
month,
|
|
2797
|
-
day
|
|
2798
|
-
};
|
|
2799
|
-
};
|
|
2800
|
-
|
|
2801
2802
|
const convertToLocalMidnight = date => {
|
|
2802
2803
|
const utcDate = new Date(date.split('T')[0]); // using YYYY-MM-DD creates UTC date
|
|
2803
|
-
|
|
2804
2804
|
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
|
|
2805
2805
|
};
|
|
2806
2806
|
|
|
2807
2807
|
const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
|
|
2808
|
-
const INITIAL_DEFAULT_STATE = {
|
|
2809
|
-
year: null,
|
|
2810
|
-
month: null,
|
|
2811
|
-
day: null
|
|
2812
|
-
};
|
|
2813
2808
|
const DateInput = ({
|
|
2814
2809
|
'aria-labelledby': ariaLabelledBy,
|
|
2815
2810
|
'aria-label': ariaLabel,
|
|
2816
|
-
disabled,
|
|
2817
|
-
size,
|
|
2811
|
+
disabled = false,
|
|
2812
|
+
size = Size.MEDIUM,
|
|
2818
2813
|
value,
|
|
2819
2814
|
dayLabel,
|
|
2820
2815
|
dayAutoComplete,
|
|
2821
2816
|
monthLabel,
|
|
2822
2817
|
yearLabel,
|
|
2823
2818
|
yearAutoComplete,
|
|
2824
|
-
monthFormat,
|
|
2825
|
-
mode,
|
|
2819
|
+
monthFormat = MonthFormat.LONG,
|
|
2820
|
+
mode = DateMode.DAY_MONTH_YEAR,
|
|
2826
2821
|
onChange,
|
|
2827
2822
|
onFocus,
|
|
2828
2823
|
onBlur,
|
|
2829
2824
|
placeholders,
|
|
2830
2825
|
id,
|
|
2831
|
-
selectProps
|
|
2826
|
+
selectProps = {}
|
|
2832
2827
|
}) => {
|
|
2833
2828
|
const {
|
|
2834
2829
|
locale,
|
|
@@ -2838,23 +2833,34 @@ const DateInput = ({
|
|
|
2838
2833
|
if (value && isDateValid(value)) {
|
|
2839
2834
|
return typeof value === 'string' ? convertToLocalMidnight(value) : value;
|
|
2840
2835
|
}
|
|
2841
|
-
return
|
|
2836
|
+
return undefined;
|
|
2842
2837
|
};
|
|
2843
|
-
const
|
|
2844
|
-
let explodedDate = INITIAL_DEFAULT_STATE;
|
|
2838
|
+
const getInitialDate = unit => {
|
|
2845
2839
|
if (value && isDateValid(value)) {
|
|
2846
2840
|
const dateObject = getDateObject();
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2841
|
+
if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {
|
|
2842
|
+
return null;
|
|
2843
|
+
}
|
|
2844
|
+
if (dateObject !== undefined) {
|
|
2845
|
+
switch (unit) {
|
|
2846
|
+
case 'year':
|
|
2847
|
+
return dateObject.getFullYear();
|
|
2848
|
+
case 'month':
|
|
2849
|
+
return dateObject.getMonth();
|
|
2850
|
+
case 'day':
|
|
2851
|
+
return dateObject.getDate();
|
|
2852
|
+
default:
|
|
2853
|
+
return null;
|
|
2854
|
+
}
|
|
2850
2855
|
}
|
|
2851
2856
|
}
|
|
2852
|
-
return
|
|
2857
|
+
return null;
|
|
2853
2858
|
};
|
|
2854
|
-
const [day, setDay] = useState(() =>
|
|
2855
|
-
const [month, setMonth] = useState(() =>
|
|
2856
|
-
const [year, setYear] = useState(() =>
|
|
2859
|
+
const [day, setDay] = useState(() => getInitialDate('day'));
|
|
2860
|
+
const [month, setMonth] = useState(() => getInitialDate('month'));
|
|
2861
|
+
const [year, setYear] = useState(() => getInitialDate('year'));
|
|
2857
2862
|
const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
|
|
2863
|
+
const monthNames = getMonthNames(locale, monthFormat);
|
|
2858
2864
|
dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
|
|
2859
2865
|
monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
|
|
2860
2866
|
yearLabel = yearLabel || formatMessage(messages$9.yearLabel);
|
|
@@ -2876,7 +2882,6 @@ const DateInput = ({
|
|
|
2876
2882
|
}
|
|
2877
2883
|
};
|
|
2878
2884
|
const getSelectElement = () => {
|
|
2879
|
-
const monthOptions = getMonthsOptions();
|
|
2880
2885
|
return /*#__PURE__*/jsxs("label", {
|
|
2881
2886
|
className: "d-flex flex-column",
|
|
2882
2887
|
children: [/*#__PURE__*/jsx("span", {
|
|
@@ -2885,70 +2890,60 @@ const DateInput = ({
|
|
|
2885
2890
|
}), /*#__PURE__*/jsx(SelectInput, {
|
|
2886
2891
|
name: "month",
|
|
2887
2892
|
disabled: disabled,
|
|
2888
|
-
placeholder: placeholders
|
|
2889
|
-
items:
|
|
2893
|
+
placeholder: placeholders?.month,
|
|
2894
|
+
items: Array.from({
|
|
2895
|
+
length: 12
|
|
2896
|
+
}, (_, index) => ({
|
|
2897
|
+
type: 'option',
|
|
2898
|
+
value: index
|
|
2899
|
+
})),
|
|
2890
2900
|
size: size,
|
|
2891
|
-
value:
|
|
2892
|
-
renderValue: ({
|
|
2893
|
-
|
|
2894
|
-
}) => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
2895
|
-
title: label
|
|
2901
|
+
value: month,
|
|
2902
|
+
renderValue: selectedValue => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
2903
|
+
title: monthNames[selectedValue]
|
|
2896
2904
|
}),
|
|
2897
2905
|
onChange: selectedValue => handleMonthChange(selectedValue),
|
|
2898
2906
|
...selectProps
|
|
2899
2907
|
})]
|
|
2900
2908
|
});
|
|
2901
2909
|
};
|
|
2902
|
-
const getMonthsOptions = () => {
|
|
2903
|
-
const options = [];
|
|
2904
|
-
const months = getMonthNames(locale, monthFormat);
|
|
2905
|
-
months.forEach((label, index) => {
|
|
2906
|
-
options.push({
|
|
2907
|
-
type: 'option',
|
|
2908
|
-
value: {
|
|
2909
|
-
label,
|
|
2910
|
-
value: index
|
|
2911
|
-
}
|
|
2912
|
-
});
|
|
2913
|
-
});
|
|
2914
|
-
return options;
|
|
2915
|
-
};
|
|
2916
2910
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2911
|
+
if (newDay == null || newMonth == null || newYear == null) {
|
|
2912
|
+
broadcastNewValue(null);
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
const dateValue = new Date(newYear, newMonth, newDay);
|
|
2916
|
+
if (!isDateValid(dateValue)) {
|
|
2917
|
+
broadcastNewValue(null);
|
|
2918
|
+
return;
|
|
2921
2919
|
}
|
|
2922
2920
|
if (mode === DateMode.MONTH_YEAR) {
|
|
2923
|
-
if (newMonth
|
|
2924
|
-
broadcastNewValue(
|
|
2921
|
+
if (newMonth !== month || newYear !== year) {
|
|
2922
|
+
broadcastNewValue(dateValue);
|
|
2925
2923
|
}
|
|
2926
|
-
} else if (newDay
|
|
2927
|
-
broadcastNewValue(
|
|
2924
|
+
} else if (newDay !== day || newMonth !== month || newYear !== year) {
|
|
2925
|
+
broadcastNewValue(dateValue);
|
|
2928
2926
|
}
|
|
2929
2927
|
};
|
|
2930
2928
|
const handleDayChange = event => {
|
|
2931
2929
|
const {
|
|
2932
2930
|
checkedDay
|
|
2933
|
-
} = checkDate(event.target.value, month, year);
|
|
2931
|
+
} = checkDate(Number.parseInt(event.target.value, 10), month, year);
|
|
2934
2932
|
setDay(checkedDay);
|
|
2935
2933
|
handleInternalValue(checkedDay, month, year);
|
|
2936
2934
|
};
|
|
2937
|
-
const handleMonthChange =
|
|
2938
|
-
if (
|
|
2935
|
+
const handleMonthChange = selectedMonth => {
|
|
2936
|
+
if (selectedMonth === null) {
|
|
2939
2937
|
setMonth(null);
|
|
2940
2938
|
handleInternalValue(day, null, year);
|
|
2941
2939
|
return;
|
|
2942
2940
|
}
|
|
2943
|
-
const selectedMonth = selectedValue ? selectedValue.value : 0;
|
|
2944
2941
|
const {
|
|
2945
2942
|
checkedDay
|
|
2946
2943
|
} = checkDate(day, selectedMonth, year);
|
|
2947
2944
|
setMonth(selectedMonth);
|
|
2948
|
-
if (day) {
|
|
2949
|
-
|
|
2950
|
-
setDay(checkedDay);
|
|
2951
|
-
}
|
|
2945
|
+
if (day && checkedDay !== day) {
|
|
2946
|
+
setDay(checkedDay);
|
|
2952
2947
|
}
|
|
2953
2948
|
handleInternalValue(checkedDay, selectedMonth, year);
|
|
2954
2949
|
};
|
|
@@ -2959,35 +2954,33 @@ const DateInput = ({
|
|
|
2959
2954
|
// Correct day based on year and month.
|
|
2960
2955
|
const {
|
|
2961
2956
|
checkedDay
|
|
2962
|
-
} = checkDate(day, month, newValue);
|
|
2963
|
-
if (day) {
|
|
2964
|
-
|
|
2965
|
-
setDay(checkedDay);
|
|
2966
|
-
}
|
|
2957
|
+
} = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
2958
|
+
if (day && checkedDay !== day) {
|
|
2959
|
+
setDay(checkedDay);
|
|
2967
2960
|
}
|
|
2968
|
-
setYear(slicedYear);
|
|
2969
|
-
handleInternalValue(checkedDay, month, slicedYear);
|
|
2961
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2962
|
+
handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
|
|
2970
2963
|
} else {
|
|
2971
|
-
setYear(slicedYear);
|
|
2964
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2972
2965
|
handleInternalValue(day, month, null);
|
|
2973
2966
|
}
|
|
2974
2967
|
};
|
|
2975
2968
|
const broadcastNewValue = newValue => {
|
|
2976
2969
|
if (newValue !== lastBroadcastedValue) {
|
|
2977
2970
|
setLastBroadcastedValue(newValue);
|
|
2978
|
-
onChange(getDateAsString(newValue)
|
|
2971
|
+
onChange(newValue != null ? getDateAsString(newValue) : null);
|
|
2979
2972
|
}
|
|
2980
2973
|
};
|
|
2981
2974
|
const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
|
|
2982
2975
|
let checkedDay = newDay;
|
|
2983
|
-
const maxDay = new Date(newYear || 2000, newMonth + 1, 0).getDate();
|
|
2976
|
+
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
2984
2977
|
if (!newDay) {
|
|
2985
2978
|
checkedDay = null;
|
|
2986
2979
|
}
|
|
2987
|
-
if (newDay && newDay < 0
|
|
2980
|
+
if (newDay && newDay < 0) {
|
|
2988
2981
|
checkedDay = 1;
|
|
2989
2982
|
}
|
|
2990
|
-
if (newDay && newMonth || newDay > 31) {
|
|
2983
|
+
if (newDay && newMonth || newDay && newDay > 31) {
|
|
2991
2984
|
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
2992
2985
|
}
|
|
2993
2986
|
return {
|
|
@@ -3007,8 +3000,10 @@ const DateInput = ({
|
|
|
3007
3000
|
id: id,
|
|
3008
3001
|
"aria-labelledby": ariaLabelledBy,
|
|
3009
3002
|
"aria-label": ariaLabel,
|
|
3010
|
-
|
|
3011
|
-
|
|
3003
|
+
role: "group" // Add role attribute to indicate container for interactive elements
|
|
3004
|
+
,
|
|
3005
|
+
onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus(event) : event.stopPropagation(),
|
|
3006
|
+
onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur(event) : event.stopPropagation(),
|
|
3012
3007
|
children: /*#__PURE__*/jsxs("div", {
|
|
3013
3008
|
className: "row",
|
|
3014
3009
|
children: [monthBeforeDay && /*#__PURE__*/jsx("div", {
|
|
@@ -3061,7 +3056,6 @@ const DateInput = ({
|
|
|
3061
3056
|
})
|
|
3062
3057
|
});
|
|
3063
3058
|
};
|
|
3064
|
-
|
|
3065
3059
|
// Should only propagate if the relatedTarget is not part of this DateInput component.
|
|
3066
3060
|
function shouldPropagateOnFocus({
|
|
3067
3061
|
target,
|
|
@@ -3071,7 +3065,6 @@ function shouldPropagateOnFocus({
|
|
|
3071
3065
|
const relatedParent = relatedTarget && relatedTarget.closest('.tw-date');
|
|
3072
3066
|
return targetParent !== relatedParent;
|
|
3073
3067
|
}
|
|
3074
|
-
|
|
3075
3068
|
// Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
|
|
3076
3069
|
function shouldPropagateOnBlur({
|
|
3077
3070
|
target,
|
|
@@ -3088,42 +3081,6 @@ function shouldPropagateOnBlur({
|
|
|
3088
3081
|
const focusElementParent = focusElement && focusElement.closest('.tw-date');
|
|
3089
3082
|
return blurElementParent !== focusElementParent;
|
|
3090
3083
|
}
|
|
3091
|
-
DateInput.propTypes = {
|
|
3092
|
-
'aria-label': PropTypes.string,
|
|
3093
|
-
'aria-labelledby': PropTypes.string,
|
|
3094
|
-
disabled: PropTypes.bool,
|
|
3095
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
3096
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
3097
|
-
onChange: PropTypes.func.isRequired,
|
|
3098
|
-
onFocus: PropTypes.func,
|
|
3099
|
-
onBlur: PropTypes.func,
|
|
3100
|
-
dayLabel: PropTypes.string,
|
|
3101
|
-
dayAutoComplete: PropTypes.string,
|
|
3102
|
-
monthLabel: PropTypes.string,
|
|
3103
|
-
yearLabel: PropTypes.string,
|
|
3104
|
-
yearAutoComplete: PropTypes.string,
|
|
3105
|
-
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
3106
|
-
mode: PropTypes.oneOf(['day-month-year', 'month-year']),
|
|
3107
|
-
placeholders: PropTypes.shape({
|
|
3108
|
-
day: PropTypes.node,
|
|
3109
|
-
month: PropTypes.node,
|
|
3110
|
-
year: PropTypes.node
|
|
3111
|
-
}),
|
|
3112
|
-
id: PropTypes.string,
|
|
3113
|
-
selectProps: PropTypes.object
|
|
3114
|
-
};
|
|
3115
|
-
DateInput.defaultProps = {
|
|
3116
|
-
disabled: false,
|
|
3117
|
-
size: Size.MEDIUM,
|
|
3118
|
-
value: null,
|
|
3119
|
-
onFocus: null,
|
|
3120
|
-
onBlur: null,
|
|
3121
|
-
monthFormat: MonthFormat.LONG,
|
|
3122
|
-
mode: DateMode.DAY_MONTH_YEAR,
|
|
3123
|
-
id: '',
|
|
3124
|
-
selectProps: {}
|
|
3125
|
-
};
|
|
3126
|
-
var DateInput$1 = DateInput;
|
|
3127
3084
|
|
|
3128
3085
|
const POPOVER_OFFSET = [0, 16];
|
|
3129
3086
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
@@ -4309,6 +4266,7 @@ class DateLookup extends PureComponent {
|
|
|
4309
4266
|
size,
|
|
4310
4267
|
placeholder,
|
|
4311
4268
|
label,
|
|
4269
|
+
'aria-labelledby': ariaLabelledBy,
|
|
4312
4270
|
monthFormat,
|
|
4313
4271
|
disabled,
|
|
4314
4272
|
clearable,
|
|
@@ -4317,6 +4275,7 @@ class DateLookup extends PureComponent {
|
|
|
4317
4275
|
return /*#__PURE__*/jsxs("div", {
|
|
4318
4276
|
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4319
4277
|
ref: this.element,
|
|
4278
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4320
4279
|
className: "input-group",
|
|
4321
4280
|
onKeyDown: this.handleKeyDown,
|
|
4322
4281
|
children: [/*#__PURE__*/jsx(DateTrigger$1, {
|
|
@@ -4346,6 +4305,7 @@ DateLookup.propTypes = {
|
|
|
4346
4305
|
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
4347
4306
|
placeholder: PropTypes.string,
|
|
4348
4307
|
label: PropTypes.string,
|
|
4308
|
+
'aria-labelledby': PropTypes.string,
|
|
4349
4309
|
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
4350
4310
|
disabled: PropTypes.bool,
|
|
4351
4311
|
onChange: PropTypes.func.isRequired,
|
|
@@ -4368,19 +4328,6 @@ DateLookup.defaultProps = {
|
|
|
4368
4328
|
};
|
|
4369
4329
|
var DateLookup$1 = DateLookup;
|
|
4370
4330
|
|
|
4371
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4372
|
-
var Presentation;
|
|
4373
|
-
(function (Presentation) {
|
|
4374
|
-
Presentation["LIST"] = "LIST";
|
|
4375
|
-
Presentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4376
|
-
Presentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4377
|
-
})(Presentation || (Presentation = {}));
|
|
4378
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4379
|
-
var Type;
|
|
4380
|
-
(function (Type) {
|
|
4381
|
-
Type["NAVIGATION"] = "NAVIGATION";
|
|
4382
|
-
})(Type || (Type = {}));
|
|
4383
|
-
|
|
4384
4331
|
const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
4385
4332
|
as: component = 'button',
|
|
4386
4333
|
disabled = false,
|
|
@@ -4414,70 +4361,6 @@ const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
|
4414
4361
|
});
|
|
4415
4362
|
});
|
|
4416
4363
|
|
|
4417
|
-
const Layout = {
|
|
4418
|
-
COLUMN: 'COLUMN'
|
|
4419
|
-
};
|
|
4420
|
-
const SizeSwapper = /*#__PURE__*/forwardRef(({
|
|
4421
|
-
items,
|
|
4422
|
-
inline
|
|
4423
|
-
}, reference) => {
|
|
4424
|
-
const parentReference = useRef(null);
|
|
4425
|
-
const [clientWidth] = useClientWidth({
|
|
4426
|
-
ref: reference || parentReference
|
|
4427
|
-
});
|
|
4428
|
-
if (!items || items.length === 0) {
|
|
4429
|
-
return null;
|
|
4430
|
-
}
|
|
4431
|
-
// If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
|
|
4432
|
-
// Do not use deconstruct here to get items and layout.
|
|
4433
|
-
let itemsToRender = [];
|
|
4434
|
-
if (clientWidth) {
|
|
4435
|
-
itemsToRender = items.filter(({
|
|
4436
|
-
breakpoint = 0
|
|
4437
|
-
}) => clientWidth >= breakpoint).pop();
|
|
4438
|
-
} else {
|
|
4439
|
-
// On SSR environments useClientWidth returns null because ref is undefined so we render
|
|
4440
|
-
// all elements by default.
|
|
4441
|
-
// If there's no SSR and on first Hydration only the right elements are going to be rendered.
|
|
4442
|
-
// If clientWidth is null or zero all elements render like a responsive technique would do.
|
|
4443
|
-
itemsToRender.items = items.map(({
|
|
4444
|
-
items
|
|
4445
|
-
}) => Object.values(items));
|
|
4446
|
-
}
|
|
4447
|
-
|
|
4448
|
-
// Always return parent container even if there are no items to display to
|
|
4449
|
-
// keep the ref on DOM and let clientWidth be calculated properly.
|
|
4450
|
-
return /*#__PURE__*/jsx("div", {
|
|
4451
|
-
ref: parentReference,
|
|
4452
|
-
className: classNames('np-size-swapper', {
|
|
4453
|
-
'd-flex': !inline,
|
|
4454
|
-
'd-inline-flex': inline,
|
|
4455
|
-
'flex-column': itemsToRender && itemsToRender.layout === Layout.COLUMN,
|
|
4456
|
-
'flex-wrap': itemsToRender && itemsToRender.wrap
|
|
4457
|
-
}),
|
|
4458
|
-
style: {
|
|
4459
|
-
visibility: clientWidth ? 'visible' : 'hidden'
|
|
4460
|
-
},
|
|
4461
|
-
children: itemsToRender && itemsToRender.items
|
|
4462
|
-
});
|
|
4463
|
-
});
|
|
4464
|
-
SizeSwapper.Breakpoint = Breakpoint;
|
|
4465
|
-
SizeSwapper.Layout = Layout;
|
|
4466
|
-
SizeSwapper.propTypes = {
|
|
4467
|
-
inline: PropTypes.bool,
|
|
4468
|
-
/** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */
|
|
4469
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
4470
|
-
items: PropTypes.arrayOf(PropTypes.element),
|
|
4471
|
-
breakpoint: PropTypes.number,
|
|
4472
|
-
layout: PropTypes.oneOf([SizeSwapper.Layout.COLUMN]),
|
|
4473
|
-
wrap: PropTypes.bool
|
|
4474
|
-
})).isRequired
|
|
4475
|
-
};
|
|
4476
|
-
SizeSwapper.defaultProps = {
|
|
4477
|
-
inline: false
|
|
4478
|
-
};
|
|
4479
|
-
var SizeSwapper$1 = SizeSwapper;
|
|
4480
|
-
|
|
4481
4364
|
const Tile = ({
|
|
4482
4365
|
className,
|
|
4483
4366
|
description,
|
|
@@ -4526,7 +4409,7 @@ Tile.propTypes = {
|
|
|
4526
4409
|
className: PropTypes.string,
|
|
4527
4410
|
description: PropTypes.node,
|
|
4528
4411
|
disabled: PropTypes.bool,
|
|
4529
|
-
href: PropTypes.string
|
|
4412
|
+
href: PropTypes.string,
|
|
4530
4413
|
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4531
4414
|
/** Accepts only Avatar and images */
|
|
4532
4415
|
media: PropTypes.node.isRequired,
|
|
@@ -4545,85 +4428,28 @@ Tile.defaultProps = {
|
|
|
4545
4428
|
};
|
|
4546
4429
|
var Tile$1 = Tile;
|
|
4547
4430
|
|
|
4431
|
+
var DecisionPresentation;
|
|
4432
|
+
(function (DecisionPresentation) {
|
|
4433
|
+
DecisionPresentation["LIST"] = "LIST";
|
|
4434
|
+
DecisionPresentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4435
|
+
DecisionPresentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4436
|
+
})(DecisionPresentation || (DecisionPresentation = {}));
|
|
4437
|
+
var DecisionType;
|
|
4438
|
+
(function (DecisionType) {
|
|
4439
|
+
DecisionType["NAVIGATION"] = "NAVIGATION";
|
|
4440
|
+
})(DecisionType || (DecisionType = {}));
|
|
4548
4441
|
const Decision = ({
|
|
4549
4442
|
options,
|
|
4550
|
-
presentation,
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4443
|
+
presentation = DecisionPresentation.LIST,
|
|
4444
|
+
size = Size.MEDIUM,
|
|
4445
|
+
type = DecisionType.NAVIGATION,
|
|
4446
|
+
showMediaCircleInList = true,
|
|
4447
|
+
isContainerAligned = false
|
|
4555
4448
|
}) => {
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
} = Presentation;
|
|
4561
|
-
if (presentation === LIST_BLOCK || presentation === LIST_BLOCK_GRID) {
|
|
4562
|
-
const isSmall = size === Size.SMALL;
|
|
4563
|
-
const isGrid = presentation === LIST_BLOCK_GRID;
|
|
4564
|
-
const items = [{
|
|
4565
|
-
items: [],
|
|
4566
|
-
layout: SizeSwapper$1.Layout.COLUMN
|
|
4567
|
-
}, {
|
|
4568
|
-
items: [],
|
|
4569
|
-
breakpoint: isSmall ? Breakpoint.EXTRA_SMALL : Breakpoint.SMALL,
|
|
4570
|
-
wrap: isGrid
|
|
4571
|
-
}];
|
|
4572
|
-
options.forEach(({
|
|
4573
|
-
description,
|
|
4574
|
-
disabled,
|
|
4575
|
-
href,
|
|
4576
|
-
target,
|
|
4577
|
-
media: {
|
|
4578
|
-
block,
|
|
4579
|
-
list
|
|
4580
|
-
},
|
|
4581
|
-
onClick,
|
|
4582
|
-
title
|
|
4583
|
-
}, key) => {
|
|
4584
|
-
items[0].items.push( /*#__PURE__*/jsx(NavigationOption
|
|
4585
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4586
|
-
, {
|
|
4587
|
-
complex: false,
|
|
4588
|
-
content: description,
|
|
4589
|
-
disabled: disabled,
|
|
4590
|
-
href: href,
|
|
4591
|
-
target: target,
|
|
4592
|
-
media: list,
|
|
4593
|
-
showMediaAtAllSizes: true,
|
|
4594
|
-
showMediaCircle: showMediaCircleInList,
|
|
4595
|
-
isContainerAligned: isContainerAligned,
|
|
4596
|
-
title: title,
|
|
4597
|
-
onClick: onClick
|
|
4598
|
-
}, `nav-${key}`));
|
|
4599
|
-
items[1].items.push( /*#__PURE__*/jsx(Tile$1
|
|
4600
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4601
|
-
, {
|
|
4602
|
-
className: classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4603
|
-
'np-decision__tile--fixed-width': isGrid
|
|
4604
|
-
}),
|
|
4605
|
-
description: description,
|
|
4606
|
-
disabled: disabled,
|
|
4607
|
-
href: href,
|
|
4608
|
-
target: target,
|
|
4609
|
-
media: block,
|
|
4610
|
-
size: isSmall ? Size.SMALL : Size.MEDIUM,
|
|
4611
|
-
title: title,
|
|
4612
|
-
onClick: onClick
|
|
4613
|
-
}, `tile-${key}`));
|
|
4614
|
-
});
|
|
4615
|
-
return /*#__PURE__*/jsx("div", {
|
|
4616
|
-
className: classNames('np-decision', {
|
|
4617
|
-
'np-decision--small': isSmall,
|
|
4618
|
-
'np-decision--grid': isGrid
|
|
4619
|
-
}),
|
|
4620
|
-
children: /*#__PURE__*/jsx(SizeSwapper$1, {
|
|
4621
|
-
items: items
|
|
4622
|
-
})
|
|
4623
|
-
});
|
|
4624
|
-
}
|
|
4625
|
-
// LIST
|
|
4626
|
-
return options.map(({
|
|
4449
|
+
const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
|
|
4450
|
+
const screenSm = useScreenSize(Breakpoint.SMALL);
|
|
4451
|
+
if (type === DecisionType.NAVIGATION) {
|
|
4452
|
+
const renderedOptions = options.map(({
|
|
4627
4453
|
title,
|
|
4628
4454
|
description,
|
|
4629
4455
|
disabled,
|
|
@@ -4648,44 +4474,51 @@ const Decision = ({
|
|
|
4648
4474
|
title: title,
|
|
4649
4475
|
onClick: onClick
|
|
4650
4476
|
}, `nav-${key}`));
|
|
4477
|
+
if (presentation === DecisionPresentation.LIST_BLOCK || presentation === DecisionPresentation.LIST_BLOCK_GRID) {
|
|
4478
|
+
const isSmall = size === Size.SMALL;
|
|
4479
|
+
const breakpoint = isSmall ? screenXs : screenSm;
|
|
4480
|
+
const isGrid = presentation === DecisionPresentation.LIST_BLOCK_GRID;
|
|
4481
|
+
return /*#__PURE__*/jsx("div", {
|
|
4482
|
+
className: classNames('np-decision d-flex', {
|
|
4483
|
+
'np-decision--small': isSmall,
|
|
4484
|
+
'np-decision--grid': isGrid
|
|
4485
|
+
}, breakpoint ? isGrid && 'flex-wrap' : 'flex-column'),
|
|
4486
|
+
children: breakpoint ? options.map(({
|
|
4487
|
+
description,
|
|
4488
|
+
disabled,
|
|
4489
|
+
href,
|
|
4490
|
+
target,
|
|
4491
|
+
media: {
|
|
4492
|
+
block
|
|
4493
|
+
},
|
|
4494
|
+
onClick,
|
|
4495
|
+
title
|
|
4496
|
+
}, key) => /*#__PURE__*/jsx(Tile$1
|
|
4497
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4498
|
+
, {
|
|
4499
|
+
className: classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4500
|
+
'np-decision__tile--fixed-width': isGrid
|
|
4501
|
+
}),
|
|
4502
|
+
description: description,
|
|
4503
|
+
disabled: disabled,
|
|
4504
|
+
href: href,
|
|
4505
|
+
target: target,
|
|
4506
|
+
media: block,
|
|
4507
|
+
size: isSmall ? Size.SMALL : Size.MEDIUM,
|
|
4508
|
+
title: title,
|
|
4509
|
+
onClick: onClick
|
|
4510
|
+
}, `tile-${key}`)) : renderedOptions
|
|
4511
|
+
});
|
|
4512
|
+
}
|
|
4513
|
+
// LIST
|
|
4514
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
4515
|
+
children: renderedOptions
|
|
4516
|
+
});
|
|
4651
4517
|
}
|
|
4652
|
-
return
|
|
4653
|
-
};
|
|
4654
|
-
Decision.propTypes = {
|
|
4655
|
-
/** A list of elements to be rendered */
|
|
4656
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
4657
|
-
description: PropTypes.node,
|
|
4658
|
-
disabled: PropTypes.bool,
|
|
4659
|
-
href: PropTypes.string,
|
|
4660
|
-
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4661
|
-
media: PropTypes.shape({
|
|
4662
|
-
block: PropTypes.node.isRequired,
|
|
4663
|
-
list: PropTypes.node.isRequired
|
|
4664
|
-
}),
|
|
4665
|
-
onClick: PropTypes.func,
|
|
4666
|
-
title: PropTypes.node.isRequired
|
|
4667
|
-
})).isRequired,
|
|
4668
|
-
/** Handles the display mode of the component */
|
|
4669
|
-
presentation: PropTypes.oneOf(['LIST', 'LIST_BLOCK', 'LIST_BLOCK_GRID']),
|
|
4670
|
-
/** Size currently affects only Tile dimension */
|
|
4671
|
-
size: PropTypes.oneOf(['sm', 'md']),
|
|
4672
|
-
/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
|
|
4673
|
-
type: PropTypes.oneOf(['NAVIGATION']),
|
|
4674
|
-
/** Display media in a circle in list presentation */
|
|
4675
|
-
showMediaCircleInList: PropTypes.bool,
|
|
4676
|
-
/** Sets navigation options to be aligned with the parent container */
|
|
4677
|
-
isContainerAligned: PropTypes.bool
|
|
4678
|
-
};
|
|
4679
|
-
Decision.defaultProps = {
|
|
4680
|
-
presentation: Presentation.LIST,
|
|
4681
|
-
size: Size.MEDIUM,
|
|
4682
|
-
type: Type.NAVIGATION,
|
|
4683
|
-
showMediaCircleInList: true,
|
|
4684
|
-
isContainerAligned: false
|
|
4518
|
+
return null;
|
|
4685
4519
|
};
|
|
4686
|
-
var Decision$1 = Decision;
|
|
4687
4520
|
|
|
4688
|
-
const isLayoutHorizontal = layout => [Layout
|
|
4521
|
+
const isLayoutHorizontal = layout => [Layout.HORIZONTAL_LEFT_ALIGNED, Layout.HORIZONTAL_RIGHT_ALIGNED, Layout.HORIZONTAL_JUSTIFIED].includes(layout);
|
|
4689
4522
|
const getAlignmentClasses = (layout, action) => {
|
|
4690
4523
|
let classes = ['d-flex'];
|
|
4691
4524
|
if (action) {
|
|
@@ -4695,12 +4528,12 @@ const getAlignmentClasses = (layout, action) => {
|
|
|
4695
4528
|
classes.push('align-items-start');
|
|
4696
4529
|
}
|
|
4697
4530
|
}
|
|
4698
|
-
if (layout === Layout
|
|
4531
|
+
if (layout === Layout.HORIZONTAL_RIGHT_ALIGNED) {
|
|
4699
4532
|
classes.push('text-sm-right tw-definition-list--right-aligned-desktop');
|
|
4700
4533
|
} else {
|
|
4701
4534
|
classes.push('justify-content-between');
|
|
4702
4535
|
}
|
|
4703
|
-
if (layout === Layout
|
|
4536
|
+
if (layout === Layout.HORIZONTAL_JUSTIFIED) {
|
|
4704
4537
|
classes.push('text-sm-justify');
|
|
4705
4538
|
}
|
|
4706
4539
|
return classes;
|
|
@@ -4712,8 +4545,8 @@ const DefinitionList = ({
|
|
|
4712
4545
|
}) => /*#__PURE__*/jsx("dl", {
|
|
4713
4546
|
className: classNames('tw-definition-list d-flex ', {
|
|
4714
4547
|
'text-muted': muted,
|
|
4715
|
-
'flex-column': layout === Layout
|
|
4716
|
-
'tw-definition-list--columns flex-column flex-row--sm': layout === Layout
|
|
4548
|
+
'flex-column': layout === Layout.VERTICAL_ONE_COLUMN,
|
|
4549
|
+
'tw-definition-list--columns flex-column flex-row--sm': layout === Layout.VERTICAL_TWO_COLUMN,
|
|
4717
4550
|
'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
|
|
4718
4551
|
}),
|
|
4719
4552
|
children: definitions.filter(definition => definition).map(({
|
|
@@ -4755,7 +4588,7 @@ DefinitionList.propTypes = {
|
|
|
4755
4588
|
};
|
|
4756
4589
|
DefinitionList.defaultProps = {
|
|
4757
4590
|
definitions: [],
|
|
4758
|
-
layout: Layout
|
|
4591
|
+
layout: Layout.VERTICAL_TWO_COLUMN,
|
|
4759
4592
|
muted: false
|
|
4760
4593
|
};
|
|
4761
4594
|
var DefinitionList$1 = DefinitionList;
|
|
@@ -5308,7 +5141,7 @@ DynamicFieldDefinitionList.propTypes = {
|
|
|
5308
5141
|
};
|
|
5309
5142
|
DynamicFieldDefinitionList.defaultProps = {
|
|
5310
5143
|
title: null,
|
|
5311
|
-
layout: Layout
|
|
5144
|
+
layout: Layout.VERTICAL_TWO_COLUMN
|
|
5312
5145
|
};
|
|
5313
5146
|
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
5314
5147
|
|
|
@@ -5367,11 +5200,11 @@ const Emphasis = ({
|
|
|
5367
5200
|
const FlowHeader = /*#__PURE__*/React.forwardRef(({
|
|
5368
5201
|
bottomContent,
|
|
5369
5202
|
className,
|
|
5370
|
-
layout = Layout
|
|
5203
|
+
layout = Layout.HORIZONTAL,
|
|
5371
5204
|
leftContent,
|
|
5372
5205
|
rightContent
|
|
5373
5206
|
}, reference) => {
|
|
5374
|
-
const isVertical = layout === Layout
|
|
5207
|
+
const isVertical = layout === Layout.VERTICAL;
|
|
5375
5208
|
return /*#__PURE__*/jsxs("div", {
|
|
5376
5209
|
ref: reference,
|
|
5377
5210
|
className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
|
|
@@ -5782,7 +5615,7 @@ const FlowNavigation = ({
|
|
|
5782
5615
|
steps: steps,
|
|
5783
5616
|
className: classNames('np-flow-navigation__stepper')
|
|
5784
5617
|
}),
|
|
5785
|
-
layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout
|
|
5618
|
+
layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout.VERTICAL : Layout.HORIZONTAL
|
|
5786
5619
|
})
|
|
5787
5620
|
});
|
|
5788
5621
|
};
|
|
@@ -5922,6 +5755,7 @@ const Modal = ({
|
|
|
5922
5755
|
const isCompact = checkSpecialClasses('compact');
|
|
5923
5756
|
const noDivider = checkSpecialClasses('no-divider');
|
|
5924
5757
|
const contentReference = useRef(null);
|
|
5758
|
+
const titleId = useId();
|
|
5925
5759
|
return !isMedium ? /*#__PURE__*/jsx(Drawer$1, {
|
|
5926
5760
|
open: open,
|
|
5927
5761
|
headerTitle: title,
|
|
@@ -5949,11 +5783,12 @@ const Modal = ({
|
|
|
5949
5783
|
className: classNames('tw-modal', 'd-flex', 'fade', 'outline-none', scroll === Scroll.CONTENT && 'tw-modal--scrollable', className),
|
|
5950
5784
|
...otherProps,
|
|
5951
5785
|
children: /*#__PURE__*/jsx("div", {
|
|
5786
|
+
role: "dialog",
|
|
5787
|
+
"aria-modal": true,
|
|
5788
|
+
"aria-labelledby": titleId,
|
|
5952
5789
|
className: classNames('tw-modal-dialog', 'd-flex', {
|
|
5953
5790
|
[`tw-modal-${size}`]: size
|
|
5954
5791
|
}),
|
|
5955
|
-
"aria-modal": true,
|
|
5956
|
-
role: "dialog",
|
|
5957
5792
|
children: /*#__PURE__*/jsxs("div", {
|
|
5958
5793
|
className: classNames('tw-modal-content', 'd-flex', 'flex-column', 'justify-content-between', {
|
|
5959
5794
|
'tw-modal-compact': isCompact,
|
|
@@ -5964,6 +5799,7 @@ const Modal = ({
|
|
|
5964
5799
|
'modal--withoutborder': !title || noDivider
|
|
5965
5800
|
}),
|
|
5966
5801
|
children: [/*#__PURE__*/jsx(Title, {
|
|
5802
|
+
id: titleId,
|
|
5967
5803
|
type: Typography.TITLE_BODY,
|
|
5968
5804
|
className: "tw-modal-title",
|
|
5969
5805
|
children: title
|
|
@@ -5993,7 +5829,8 @@ const Popover$1 = ({
|
|
|
5993
5829
|
className,
|
|
5994
5830
|
content,
|
|
5995
5831
|
preferredPlacement,
|
|
5996
|
-
title
|
|
5832
|
+
title,
|
|
5833
|
+
onClose
|
|
5997
5834
|
}) => {
|
|
5998
5835
|
logActionRequired({
|
|
5999
5836
|
preferredPlacement
|
|
@@ -6003,7 +5840,10 @@ const Popover$1 = ({
|
|
|
6003
5840
|
const {
|
|
6004
5841
|
isModern
|
|
6005
5842
|
} = useTheme();
|
|
6006
|
-
const
|
|
5843
|
+
const handleOnClose = () => {
|
|
5844
|
+
setOpen(false);
|
|
5845
|
+
onClose?.();
|
|
5846
|
+
};
|
|
6007
5847
|
return /*#__PURE__*/jsxs("span", {
|
|
6008
5848
|
className: classNames('np-popover', className),
|
|
6009
5849
|
children: [/*#__PURE__*/jsx("span", {
|
|
@@ -6023,7 +5863,7 @@ const Popover$1 = ({
|
|
|
6023
5863
|
position: deprecatedPlacements[preferredPlacement] || preferredPlacement,
|
|
6024
5864
|
arrow: true,
|
|
6025
5865
|
className: "np-popover__container",
|
|
6026
|
-
onClose:
|
|
5866
|
+
onClose: handleOnClose,
|
|
6027
5867
|
children: /*#__PURE__*/jsxs("div", {
|
|
6028
5868
|
className: isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content',
|
|
6029
5869
|
"aria-hidden": !open,
|
|
@@ -6056,6 +5896,7 @@ Popover$1.propTypes = {
|
|
|
6056
5896
|
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
6057
5897
|
*/
|
|
6058
5898
|
preferredPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left', 'left-top', 'right-top', 'bottom-right', 'bottom-left']),
|
|
5899
|
+
onClose: PropTypes.func,
|
|
6059
5900
|
title: PropTypes.node
|
|
6060
5901
|
};
|
|
6061
5902
|
const deprecatedPlacements = {
|
|
@@ -15415,5 +15256,5 @@ const translations = {
|
|
|
15415
15256
|
'zh-HK': zhHK
|
|
15416
15257
|
};
|
|
15417
15258
|
|
|
15418
|
-
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput
|
|
15259
|
+
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton$1 as 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, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList$1 as InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$2 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider$1 as Provider, RTL_LANGUAGES, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
15419
15260
|
//# sourceMappingURL=index.esm.js.map
|