@transferwise/components 46.13.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 +175 -346
- package/build/index.esm.js.map +1 -1
- package/build/index.js +148 -319
- 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/index.d.ts +2 -0
- package/build/types/index.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/index.ts +2 -0
- package/src/main.css +6 -82
- 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) {
|
|
@@ -2239,23 +2239,23 @@ const priorityClassMap = {
|
|
|
2239
2239
|
};
|
|
2240
2240
|
|
|
2241
2241
|
const deprecatedTypeMap = {
|
|
2242
|
-
[Type
|
|
2243
|
-
[Type
|
|
2244
|
-
[Type
|
|
2245
|
-
[Type
|
|
2246
|
-
[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
|
|
2247
2247
|
};
|
|
2248
2248
|
const oldTypePriorityMap = {
|
|
2249
|
-
[Type
|
|
2250
|
-
[Type
|
|
2251
|
-
[Type
|
|
2249
|
+
[Type.DANGER]: Priority.SECONDARY,
|
|
2250
|
+
[Type.LINK]: Priority.TERTIARY,
|
|
2251
|
+
[Type.SECONDARY]: Priority.SECONDARY
|
|
2252
2252
|
};
|
|
2253
2253
|
const deprecatedTypeMapMessage = {
|
|
2254
|
-
[Type
|
|
2255
|
-
[Type
|
|
2256
|
-
[Type
|
|
2257
|
-
[Type
|
|
2258
|
-
[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'
|
|
2259
2259
|
};
|
|
2260
2260
|
const deprecatedTypes = Object.keys(deprecatedTypeMap);
|
|
2261
2261
|
const establishNewType = originalType => deprecatedTypeMap[originalType] || originalType;
|
|
@@ -2745,15 +2745,15 @@ function getDayNames(locale, format = 'short') {
|
|
|
2745
2745
|
return days;
|
|
2746
2746
|
}
|
|
2747
2747
|
|
|
2748
|
-
function isWithinRange(date, min, max) {
|
|
2749
|
-
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2750
|
-
}
|
|
2751
|
-
|
|
2752
2748
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2753
2749
|
function moveToWithinRange(date, min, max) {
|
|
2754
2750
|
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
2755
2751
|
}
|
|
2756
2752
|
|
|
2753
|
+
function isWithinRange(date, min, max) {
|
|
2754
|
+
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
2757
|
const getMonthNames = (locale, format = 'long') => {
|
|
2758
2758
|
const months = [];
|
|
2759
2759
|
const date = new Date(2018, 0, 1);
|
|
@@ -2767,9 +2767,17 @@ const getMonthNames = (locale, format = 'long') => {
|
|
|
2767
2767
|
return months;
|
|
2768
2768
|
};
|
|
2769
2769
|
|
|
2770
|
-
const isDateValid = date =>
|
|
2771
|
-
|
|
2772
|
-
|
|
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());
|
|
2773
2781
|
|
|
2774
2782
|
const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
|
|
2775
2783
|
|
|
@@ -2791,48 +2799,31 @@ var messages$9 = defineMessages({
|
|
|
2791
2799
|
}
|
|
2792
2800
|
});
|
|
2793
2801
|
|
|
2794
|
-
const explodeDate = date => {
|
|
2795
|
-
const year = date.getFullYear();
|
|
2796
|
-
const month = date.getMonth();
|
|
2797
|
-
const day = date.getDate();
|
|
2798
|
-
return {
|
|
2799
|
-
year,
|
|
2800
|
-
month,
|
|
2801
|
-
day
|
|
2802
|
-
};
|
|
2803
|
-
};
|
|
2804
|
-
|
|
2805
2802
|
const convertToLocalMidnight = date => {
|
|
2806
2803
|
const utcDate = new Date(date.split('T')[0]); // using YYYY-MM-DD creates UTC date
|
|
2807
|
-
|
|
2808
2804
|
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
|
|
2809
2805
|
};
|
|
2810
2806
|
|
|
2811
2807
|
const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
|
|
2812
|
-
const INITIAL_DEFAULT_STATE = {
|
|
2813
|
-
year: null,
|
|
2814
|
-
month: null,
|
|
2815
|
-
day: null
|
|
2816
|
-
};
|
|
2817
2808
|
const DateInput = ({
|
|
2818
2809
|
'aria-labelledby': ariaLabelledBy,
|
|
2819
2810
|
'aria-label': ariaLabel,
|
|
2820
|
-
disabled,
|
|
2821
|
-
size,
|
|
2811
|
+
disabled = false,
|
|
2812
|
+
size = Size.MEDIUM,
|
|
2822
2813
|
value,
|
|
2823
2814
|
dayLabel,
|
|
2824
2815
|
dayAutoComplete,
|
|
2825
2816
|
monthLabel,
|
|
2826
2817
|
yearLabel,
|
|
2827
2818
|
yearAutoComplete,
|
|
2828
|
-
monthFormat,
|
|
2829
|
-
mode,
|
|
2819
|
+
monthFormat = MonthFormat.LONG,
|
|
2820
|
+
mode = DateMode.DAY_MONTH_YEAR,
|
|
2830
2821
|
onChange,
|
|
2831
2822
|
onFocus,
|
|
2832
2823
|
onBlur,
|
|
2833
2824
|
placeholders,
|
|
2834
2825
|
id,
|
|
2835
|
-
selectProps
|
|
2826
|
+
selectProps = {}
|
|
2836
2827
|
}) => {
|
|
2837
2828
|
const {
|
|
2838
2829
|
locale,
|
|
@@ -2842,23 +2833,34 @@ const DateInput = ({
|
|
|
2842
2833
|
if (value && isDateValid(value)) {
|
|
2843
2834
|
return typeof value === 'string' ? convertToLocalMidnight(value) : value;
|
|
2844
2835
|
}
|
|
2845
|
-
return
|
|
2836
|
+
return undefined;
|
|
2846
2837
|
};
|
|
2847
|
-
const
|
|
2848
|
-
let explodedDate = INITIAL_DEFAULT_STATE;
|
|
2838
|
+
const getInitialDate = unit => {
|
|
2849
2839
|
if (value && isDateValid(value)) {
|
|
2850
2840
|
const dateObject = getDateObject();
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
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
|
+
}
|
|
2854
2855
|
}
|
|
2855
2856
|
}
|
|
2856
|
-
return
|
|
2857
|
+
return null;
|
|
2857
2858
|
};
|
|
2858
|
-
const [day, setDay] = useState(() =>
|
|
2859
|
-
const [month, setMonth] = useState(() =>
|
|
2860
|
-
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'));
|
|
2861
2862
|
const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
|
|
2863
|
+
const monthNames = getMonthNames(locale, monthFormat);
|
|
2862
2864
|
dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
|
|
2863
2865
|
monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
|
|
2864
2866
|
yearLabel = yearLabel || formatMessage(messages$9.yearLabel);
|
|
@@ -2880,7 +2882,6 @@ const DateInput = ({
|
|
|
2880
2882
|
}
|
|
2881
2883
|
};
|
|
2882
2884
|
const getSelectElement = () => {
|
|
2883
|
-
const monthOptions = getMonthsOptions();
|
|
2884
2885
|
return /*#__PURE__*/jsxs("label", {
|
|
2885
2886
|
className: "d-flex flex-column",
|
|
2886
2887
|
children: [/*#__PURE__*/jsx("span", {
|
|
@@ -2889,70 +2890,60 @@ const DateInput = ({
|
|
|
2889
2890
|
}), /*#__PURE__*/jsx(SelectInput, {
|
|
2890
2891
|
name: "month",
|
|
2891
2892
|
disabled: disabled,
|
|
2892
|
-
placeholder: placeholders
|
|
2893
|
-
items:
|
|
2893
|
+
placeholder: placeholders?.month,
|
|
2894
|
+
items: Array.from({
|
|
2895
|
+
length: 12
|
|
2896
|
+
}, (_, index) => ({
|
|
2897
|
+
type: 'option',
|
|
2898
|
+
value: index
|
|
2899
|
+
})),
|
|
2894
2900
|
size: size,
|
|
2895
|
-
value:
|
|
2896
|
-
renderValue: ({
|
|
2897
|
-
|
|
2898
|
-
}) => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
2899
|
-
title: label
|
|
2901
|
+
value: month,
|
|
2902
|
+
renderValue: selectedValue => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
2903
|
+
title: monthNames[selectedValue]
|
|
2900
2904
|
}),
|
|
2901
2905
|
onChange: selectedValue => handleMonthChange(selectedValue),
|
|
2902
2906
|
...selectProps
|
|
2903
2907
|
})]
|
|
2904
2908
|
});
|
|
2905
2909
|
};
|
|
2906
|
-
const getMonthsOptions = () => {
|
|
2907
|
-
const options = [];
|
|
2908
|
-
const months = getMonthNames(locale, monthFormat);
|
|
2909
|
-
months.forEach((label, index) => {
|
|
2910
|
-
options.push({
|
|
2911
|
-
type: 'option',
|
|
2912
|
-
value: {
|
|
2913
|
-
label,
|
|
2914
|
-
value: index
|
|
2915
|
-
}
|
|
2916
|
-
});
|
|
2917
|
-
});
|
|
2918
|
-
return options;
|
|
2919
|
-
};
|
|
2920
2910
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
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;
|
|
2925
2919
|
}
|
|
2926
2920
|
if (mode === DateMode.MONTH_YEAR) {
|
|
2927
|
-
if (newMonth
|
|
2928
|
-
broadcastNewValue(
|
|
2921
|
+
if (newMonth !== month || newYear !== year) {
|
|
2922
|
+
broadcastNewValue(dateValue);
|
|
2929
2923
|
}
|
|
2930
|
-
} else if (newDay
|
|
2931
|
-
broadcastNewValue(
|
|
2924
|
+
} else if (newDay !== day || newMonth !== month || newYear !== year) {
|
|
2925
|
+
broadcastNewValue(dateValue);
|
|
2932
2926
|
}
|
|
2933
2927
|
};
|
|
2934
2928
|
const handleDayChange = event => {
|
|
2935
2929
|
const {
|
|
2936
2930
|
checkedDay
|
|
2937
|
-
} = checkDate(event.target.value, month, year);
|
|
2931
|
+
} = checkDate(Number.parseInt(event.target.value, 10), month, year);
|
|
2938
2932
|
setDay(checkedDay);
|
|
2939
2933
|
handleInternalValue(checkedDay, month, year);
|
|
2940
2934
|
};
|
|
2941
|
-
const handleMonthChange =
|
|
2942
|
-
if (
|
|
2935
|
+
const handleMonthChange = selectedMonth => {
|
|
2936
|
+
if (selectedMonth === null) {
|
|
2943
2937
|
setMonth(null);
|
|
2944
2938
|
handleInternalValue(day, null, year);
|
|
2945
2939
|
return;
|
|
2946
2940
|
}
|
|
2947
|
-
const selectedMonth = selectedValue ? selectedValue.value : 0;
|
|
2948
2941
|
const {
|
|
2949
2942
|
checkedDay
|
|
2950
2943
|
} = checkDate(day, selectedMonth, year);
|
|
2951
2944
|
setMonth(selectedMonth);
|
|
2952
|
-
if (day) {
|
|
2953
|
-
|
|
2954
|
-
setDay(checkedDay);
|
|
2955
|
-
}
|
|
2945
|
+
if (day && checkedDay !== day) {
|
|
2946
|
+
setDay(checkedDay);
|
|
2956
2947
|
}
|
|
2957
2948
|
handleInternalValue(checkedDay, selectedMonth, year);
|
|
2958
2949
|
};
|
|
@@ -2963,35 +2954,33 @@ const DateInput = ({
|
|
|
2963
2954
|
// Correct day based on year and month.
|
|
2964
2955
|
const {
|
|
2965
2956
|
checkedDay
|
|
2966
|
-
} = checkDate(day, month, newValue);
|
|
2967
|
-
if (day) {
|
|
2968
|
-
|
|
2969
|
-
setDay(checkedDay);
|
|
2970
|
-
}
|
|
2957
|
+
} = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
2958
|
+
if (day && checkedDay !== day) {
|
|
2959
|
+
setDay(checkedDay);
|
|
2971
2960
|
}
|
|
2972
|
-
setYear(slicedYear);
|
|
2973
|
-
handleInternalValue(checkedDay, month, slicedYear);
|
|
2961
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2962
|
+
handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
|
|
2974
2963
|
} else {
|
|
2975
|
-
setYear(slicedYear);
|
|
2964
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2976
2965
|
handleInternalValue(day, month, null);
|
|
2977
2966
|
}
|
|
2978
2967
|
};
|
|
2979
2968
|
const broadcastNewValue = newValue => {
|
|
2980
2969
|
if (newValue !== lastBroadcastedValue) {
|
|
2981
2970
|
setLastBroadcastedValue(newValue);
|
|
2982
|
-
onChange(getDateAsString(newValue)
|
|
2971
|
+
onChange(newValue != null ? getDateAsString(newValue) : null);
|
|
2983
2972
|
}
|
|
2984
2973
|
};
|
|
2985
2974
|
const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
|
|
2986
2975
|
let checkedDay = newDay;
|
|
2987
|
-
const maxDay = new Date(newYear || 2000, newMonth + 1, 0).getDate();
|
|
2976
|
+
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
2988
2977
|
if (!newDay) {
|
|
2989
2978
|
checkedDay = null;
|
|
2990
2979
|
}
|
|
2991
|
-
if (newDay && newDay < 0
|
|
2980
|
+
if (newDay && newDay < 0) {
|
|
2992
2981
|
checkedDay = 1;
|
|
2993
2982
|
}
|
|
2994
|
-
if (newDay && newMonth || newDay > 31) {
|
|
2983
|
+
if (newDay && newMonth || newDay && newDay > 31) {
|
|
2995
2984
|
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
2996
2985
|
}
|
|
2997
2986
|
return {
|
|
@@ -3011,8 +3000,10 @@ const DateInput = ({
|
|
|
3011
3000
|
id: id,
|
|
3012
3001
|
"aria-labelledby": ariaLabelledBy,
|
|
3013
3002
|
"aria-label": ariaLabel,
|
|
3014
|
-
|
|
3015
|
-
|
|
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(),
|
|
3016
3007
|
children: /*#__PURE__*/jsxs("div", {
|
|
3017
3008
|
className: "row",
|
|
3018
3009
|
children: [monthBeforeDay && /*#__PURE__*/jsx("div", {
|
|
@@ -3065,7 +3056,6 @@ const DateInput = ({
|
|
|
3065
3056
|
})
|
|
3066
3057
|
});
|
|
3067
3058
|
};
|
|
3068
|
-
|
|
3069
3059
|
// Should only propagate if the relatedTarget is not part of this DateInput component.
|
|
3070
3060
|
function shouldPropagateOnFocus({
|
|
3071
3061
|
target,
|
|
@@ -3075,7 +3065,6 @@ function shouldPropagateOnFocus({
|
|
|
3075
3065
|
const relatedParent = relatedTarget && relatedTarget.closest('.tw-date');
|
|
3076
3066
|
return targetParent !== relatedParent;
|
|
3077
3067
|
}
|
|
3078
|
-
|
|
3079
3068
|
// Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
|
|
3080
3069
|
function shouldPropagateOnBlur({
|
|
3081
3070
|
target,
|
|
@@ -3092,42 +3081,6 @@ function shouldPropagateOnBlur({
|
|
|
3092
3081
|
const focusElementParent = focusElement && focusElement.closest('.tw-date');
|
|
3093
3082
|
return blurElementParent !== focusElementParent;
|
|
3094
3083
|
}
|
|
3095
|
-
DateInput.propTypes = {
|
|
3096
|
-
'aria-label': PropTypes.string,
|
|
3097
|
-
'aria-labelledby': PropTypes.string,
|
|
3098
|
-
disabled: PropTypes.bool,
|
|
3099
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
3100
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
3101
|
-
onChange: PropTypes.func.isRequired,
|
|
3102
|
-
onFocus: PropTypes.func,
|
|
3103
|
-
onBlur: PropTypes.func,
|
|
3104
|
-
dayLabel: PropTypes.string,
|
|
3105
|
-
dayAutoComplete: PropTypes.string,
|
|
3106
|
-
monthLabel: PropTypes.string,
|
|
3107
|
-
yearLabel: PropTypes.string,
|
|
3108
|
-
yearAutoComplete: PropTypes.string,
|
|
3109
|
-
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
3110
|
-
mode: PropTypes.oneOf(['day-month-year', 'month-year']),
|
|
3111
|
-
placeholders: PropTypes.shape({
|
|
3112
|
-
day: PropTypes.node,
|
|
3113
|
-
month: PropTypes.node,
|
|
3114
|
-
year: PropTypes.node
|
|
3115
|
-
}),
|
|
3116
|
-
id: PropTypes.string,
|
|
3117
|
-
selectProps: PropTypes.object
|
|
3118
|
-
};
|
|
3119
|
-
DateInput.defaultProps = {
|
|
3120
|
-
disabled: false,
|
|
3121
|
-
size: Size.MEDIUM,
|
|
3122
|
-
value: null,
|
|
3123
|
-
onFocus: null,
|
|
3124
|
-
onBlur: null,
|
|
3125
|
-
monthFormat: MonthFormat.LONG,
|
|
3126
|
-
mode: DateMode.DAY_MONTH_YEAR,
|
|
3127
|
-
id: '',
|
|
3128
|
-
selectProps: {}
|
|
3129
|
-
};
|
|
3130
|
-
var DateInput$1 = DateInput;
|
|
3131
3084
|
|
|
3132
3085
|
const POPOVER_OFFSET = [0, 16];
|
|
3133
3086
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
@@ -4313,6 +4266,7 @@ class DateLookup extends PureComponent {
|
|
|
4313
4266
|
size,
|
|
4314
4267
|
placeholder,
|
|
4315
4268
|
label,
|
|
4269
|
+
'aria-labelledby': ariaLabelledBy,
|
|
4316
4270
|
monthFormat,
|
|
4317
4271
|
disabled,
|
|
4318
4272
|
clearable,
|
|
@@ -4321,6 +4275,7 @@ class DateLookup extends PureComponent {
|
|
|
4321
4275
|
return /*#__PURE__*/jsxs("div", {
|
|
4322
4276
|
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4323
4277
|
ref: this.element,
|
|
4278
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4324
4279
|
className: "input-group",
|
|
4325
4280
|
onKeyDown: this.handleKeyDown,
|
|
4326
4281
|
children: [/*#__PURE__*/jsx(DateTrigger$1, {
|
|
@@ -4350,6 +4305,7 @@ DateLookup.propTypes = {
|
|
|
4350
4305
|
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
4351
4306
|
placeholder: PropTypes.string,
|
|
4352
4307
|
label: PropTypes.string,
|
|
4308
|
+
'aria-labelledby': PropTypes.string,
|
|
4353
4309
|
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
4354
4310
|
disabled: PropTypes.bool,
|
|
4355
4311
|
onChange: PropTypes.func.isRequired,
|
|
@@ -4372,19 +4328,6 @@ DateLookup.defaultProps = {
|
|
|
4372
4328
|
};
|
|
4373
4329
|
var DateLookup$1 = DateLookup;
|
|
4374
4330
|
|
|
4375
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4376
|
-
var Presentation;
|
|
4377
|
-
(function (Presentation) {
|
|
4378
|
-
Presentation["LIST"] = "LIST";
|
|
4379
|
-
Presentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4380
|
-
Presentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4381
|
-
})(Presentation || (Presentation = {}));
|
|
4382
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4383
|
-
var Type;
|
|
4384
|
-
(function (Type) {
|
|
4385
|
-
Type["NAVIGATION"] = "NAVIGATION";
|
|
4386
|
-
})(Type || (Type = {}));
|
|
4387
|
-
|
|
4388
4331
|
const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
4389
4332
|
as: component = 'button',
|
|
4390
4333
|
disabled = false,
|
|
@@ -4418,70 +4361,6 @@ const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
|
4418
4361
|
});
|
|
4419
4362
|
});
|
|
4420
4363
|
|
|
4421
|
-
const Layout = {
|
|
4422
|
-
COLUMN: 'COLUMN'
|
|
4423
|
-
};
|
|
4424
|
-
const SizeSwapper = /*#__PURE__*/forwardRef(({
|
|
4425
|
-
items,
|
|
4426
|
-
inline
|
|
4427
|
-
}, reference) => {
|
|
4428
|
-
const parentReference = useRef(null);
|
|
4429
|
-
const [clientWidth] = useClientWidth({
|
|
4430
|
-
ref: reference || parentReference
|
|
4431
|
-
});
|
|
4432
|
-
if (!items || items.length === 0) {
|
|
4433
|
-
return null;
|
|
4434
|
-
}
|
|
4435
|
-
// If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
|
|
4436
|
-
// Do not use deconstruct here to get items and layout.
|
|
4437
|
-
let itemsToRender = [];
|
|
4438
|
-
if (clientWidth) {
|
|
4439
|
-
itemsToRender = items.filter(({
|
|
4440
|
-
breakpoint = 0
|
|
4441
|
-
}) => clientWidth >= breakpoint).pop();
|
|
4442
|
-
} else {
|
|
4443
|
-
// On SSR environments useClientWidth returns null because ref is undefined so we render
|
|
4444
|
-
// all elements by default.
|
|
4445
|
-
// If there's no SSR and on first Hydration only the right elements are going to be rendered.
|
|
4446
|
-
// If clientWidth is null or zero all elements render like a responsive technique would do.
|
|
4447
|
-
itemsToRender.items = items.map(({
|
|
4448
|
-
items
|
|
4449
|
-
}) => Object.values(items));
|
|
4450
|
-
}
|
|
4451
|
-
|
|
4452
|
-
// Always return parent container even if there are no items to display to
|
|
4453
|
-
// keep the ref on DOM and let clientWidth be calculated properly.
|
|
4454
|
-
return /*#__PURE__*/jsx("div", {
|
|
4455
|
-
ref: parentReference,
|
|
4456
|
-
className: classNames('np-size-swapper', {
|
|
4457
|
-
'd-flex': !inline,
|
|
4458
|
-
'd-inline-flex': inline,
|
|
4459
|
-
'flex-column': itemsToRender && itemsToRender.layout === Layout.COLUMN,
|
|
4460
|
-
'flex-wrap': itemsToRender && itemsToRender.wrap
|
|
4461
|
-
}),
|
|
4462
|
-
style: {
|
|
4463
|
-
visibility: clientWidth ? 'visible' : 'hidden'
|
|
4464
|
-
},
|
|
4465
|
-
children: itemsToRender && itemsToRender.items
|
|
4466
|
-
});
|
|
4467
|
-
});
|
|
4468
|
-
SizeSwapper.Breakpoint = Breakpoint;
|
|
4469
|
-
SizeSwapper.Layout = Layout;
|
|
4470
|
-
SizeSwapper.propTypes = {
|
|
4471
|
-
inline: PropTypes.bool,
|
|
4472
|
-
/** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */
|
|
4473
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
4474
|
-
items: PropTypes.arrayOf(PropTypes.element),
|
|
4475
|
-
breakpoint: PropTypes.number,
|
|
4476
|
-
layout: PropTypes.oneOf([SizeSwapper.Layout.COLUMN]),
|
|
4477
|
-
wrap: PropTypes.bool
|
|
4478
|
-
})).isRequired
|
|
4479
|
-
};
|
|
4480
|
-
SizeSwapper.defaultProps = {
|
|
4481
|
-
inline: false
|
|
4482
|
-
};
|
|
4483
|
-
var SizeSwapper$1 = SizeSwapper;
|
|
4484
|
-
|
|
4485
4364
|
const Tile = ({
|
|
4486
4365
|
className,
|
|
4487
4366
|
description,
|
|
@@ -4530,7 +4409,7 @@ Tile.propTypes = {
|
|
|
4530
4409
|
className: PropTypes.string,
|
|
4531
4410
|
description: PropTypes.node,
|
|
4532
4411
|
disabled: PropTypes.bool,
|
|
4533
|
-
href: PropTypes.string
|
|
4412
|
+
href: PropTypes.string,
|
|
4534
4413
|
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4535
4414
|
/** Accepts only Avatar and images */
|
|
4536
4415
|
media: PropTypes.node.isRequired,
|
|
@@ -4549,85 +4428,28 @@ Tile.defaultProps = {
|
|
|
4549
4428
|
};
|
|
4550
4429
|
var Tile$1 = Tile;
|
|
4551
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 = {}));
|
|
4552
4441
|
const Decision = ({
|
|
4553
4442
|
options,
|
|
4554
|
-
presentation,
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4443
|
+
presentation = DecisionPresentation.LIST,
|
|
4444
|
+
size = Size.MEDIUM,
|
|
4445
|
+
type = DecisionType.NAVIGATION,
|
|
4446
|
+
showMediaCircleInList = true,
|
|
4447
|
+
isContainerAligned = false
|
|
4559
4448
|
}) => {
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
} = Presentation;
|
|
4565
|
-
if (presentation === LIST_BLOCK || presentation === LIST_BLOCK_GRID) {
|
|
4566
|
-
const isSmall = size === Size.SMALL;
|
|
4567
|
-
const isGrid = presentation === LIST_BLOCK_GRID;
|
|
4568
|
-
const items = [{
|
|
4569
|
-
items: [],
|
|
4570
|
-
layout: SizeSwapper$1.Layout.COLUMN
|
|
4571
|
-
}, {
|
|
4572
|
-
items: [],
|
|
4573
|
-
breakpoint: isSmall ? Breakpoint.EXTRA_SMALL : Breakpoint.SMALL,
|
|
4574
|
-
wrap: isGrid
|
|
4575
|
-
}];
|
|
4576
|
-
options.forEach(({
|
|
4577
|
-
description,
|
|
4578
|
-
disabled,
|
|
4579
|
-
href,
|
|
4580
|
-
target,
|
|
4581
|
-
media: {
|
|
4582
|
-
block,
|
|
4583
|
-
list
|
|
4584
|
-
},
|
|
4585
|
-
onClick,
|
|
4586
|
-
title
|
|
4587
|
-
}, key) => {
|
|
4588
|
-
items[0].items.push( /*#__PURE__*/jsx(NavigationOption
|
|
4589
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4590
|
-
, {
|
|
4591
|
-
complex: false,
|
|
4592
|
-
content: description,
|
|
4593
|
-
disabled: disabled,
|
|
4594
|
-
href: href,
|
|
4595
|
-
target: target,
|
|
4596
|
-
media: list,
|
|
4597
|
-
showMediaAtAllSizes: true,
|
|
4598
|
-
showMediaCircle: showMediaCircleInList,
|
|
4599
|
-
isContainerAligned: isContainerAligned,
|
|
4600
|
-
title: title,
|
|
4601
|
-
onClick: onClick
|
|
4602
|
-
}, `nav-${key}`));
|
|
4603
|
-
items[1].items.push( /*#__PURE__*/jsx(Tile$1
|
|
4604
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4605
|
-
, {
|
|
4606
|
-
className: classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4607
|
-
'np-decision__tile--fixed-width': isGrid
|
|
4608
|
-
}),
|
|
4609
|
-
description: description,
|
|
4610
|
-
disabled: disabled,
|
|
4611
|
-
href: href,
|
|
4612
|
-
target: target,
|
|
4613
|
-
media: block,
|
|
4614
|
-
size: isSmall ? Size.SMALL : Size.MEDIUM,
|
|
4615
|
-
title: title,
|
|
4616
|
-
onClick: onClick
|
|
4617
|
-
}, `tile-${key}`));
|
|
4618
|
-
});
|
|
4619
|
-
return /*#__PURE__*/jsx("div", {
|
|
4620
|
-
className: classNames('np-decision', {
|
|
4621
|
-
'np-decision--small': isSmall,
|
|
4622
|
-
'np-decision--grid': isGrid
|
|
4623
|
-
}),
|
|
4624
|
-
children: /*#__PURE__*/jsx(SizeSwapper$1, {
|
|
4625
|
-
items: items
|
|
4626
|
-
})
|
|
4627
|
-
});
|
|
4628
|
-
}
|
|
4629
|
-
// LIST
|
|
4630
|
-
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(({
|
|
4631
4453
|
title,
|
|
4632
4454
|
description,
|
|
4633
4455
|
disabled,
|
|
@@ -4652,44 +4474,51 @@ const Decision = ({
|
|
|
4652
4474
|
title: title,
|
|
4653
4475
|
onClick: onClick
|
|
4654
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
|
+
});
|
|
4655
4517
|
}
|
|
4656
|
-
return
|
|
4657
|
-
};
|
|
4658
|
-
Decision.propTypes = {
|
|
4659
|
-
/** A list of elements to be rendered */
|
|
4660
|
-
options: PropTypes.arrayOf(PropTypes.shape({
|
|
4661
|
-
description: PropTypes.node,
|
|
4662
|
-
disabled: PropTypes.bool,
|
|
4663
|
-
href: PropTypes.string,
|
|
4664
|
-
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4665
|
-
media: PropTypes.shape({
|
|
4666
|
-
block: PropTypes.node.isRequired,
|
|
4667
|
-
list: PropTypes.node.isRequired
|
|
4668
|
-
}),
|
|
4669
|
-
onClick: PropTypes.func,
|
|
4670
|
-
title: PropTypes.node.isRequired
|
|
4671
|
-
})).isRequired,
|
|
4672
|
-
/** Handles the display mode of the component */
|
|
4673
|
-
presentation: PropTypes.oneOf(['LIST', 'LIST_BLOCK', 'LIST_BLOCK_GRID']),
|
|
4674
|
-
/** Size currently affects only Tile dimension */
|
|
4675
|
-
size: PropTypes.oneOf(['sm', 'md']),
|
|
4676
|
-
/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
|
|
4677
|
-
type: PropTypes.oneOf(['NAVIGATION']),
|
|
4678
|
-
/** Display media in a circle in list presentation */
|
|
4679
|
-
showMediaCircleInList: PropTypes.bool,
|
|
4680
|
-
/** Sets navigation options to be aligned with the parent container */
|
|
4681
|
-
isContainerAligned: PropTypes.bool
|
|
4682
|
-
};
|
|
4683
|
-
Decision.defaultProps = {
|
|
4684
|
-
presentation: Presentation.LIST,
|
|
4685
|
-
size: Size.MEDIUM,
|
|
4686
|
-
type: Type.NAVIGATION,
|
|
4687
|
-
showMediaCircleInList: true,
|
|
4688
|
-
isContainerAligned: false
|
|
4518
|
+
return null;
|
|
4689
4519
|
};
|
|
4690
|
-
var Decision$1 = Decision;
|
|
4691
4520
|
|
|
4692
|
-
const isLayoutHorizontal = layout => [Layout
|
|
4521
|
+
const isLayoutHorizontal = layout => [Layout.HORIZONTAL_LEFT_ALIGNED, Layout.HORIZONTAL_RIGHT_ALIGNED, Layout.HORIZONTAL_JUSTIFIED].includes(layout);
|
|
4693
4522
|
const getAlignmentClasses = (layout, action) => {
|
|
4694
4523
|
let classes = ['d-flex'];
|
|
4695
4524
|
if (action) {
|
|
@@ -4699,12 +4528,12 @@ const getAlignmentClasses = (layout, action) => {
|
|
|
4699
4528
|
classes.push('align-items-start');
|
|
4700
4529
|
}
|
|
4701
4530
|
}
|
|
4702
|
-
if (layout === Layout
|
|
4531
|
+
if (layout === Layout.HORIZONTAL_RIGHT_ALIGNED) {
|
|
4703
4532
|
classes.push('text-sm-right tw-definition-list--right-aligned-desktop');
|
|
4704
4533
|
} else {
|
|
4705
4534
|
classes.push('justify-content-between');
|
|
4706
4535
|
}
|
|
4707
|
-
if (layout === Layout
|
|
4536
|
+
if (layout === Layout.HORIZONTAL_JUSTIFIED) {
|
|
4708
4537
|
classes.push('text-sm-justify');
|
|
4709
4538
|
}
|
|
4710
4539
|
return classes;
|
|
@@ -4716,8 +4545,8 @@ const DefinitionList = ({
|
|
|
4716
4545
|
}) => /*#__PURE__*/jsx("dl", {
|
|
4717
4546
|
className: classNames('tw-definition-list d-flex ', {
|
|
4718
4547
|
'text-muted': muted,
|
|
4719
|
-
'flex-column': layout === Layout
|
|
4720
|
-
'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,
|
|
4721
4550
|
'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
|
|
4722
4551
|
}),
|
|
4723
4552
|
children: definitions.filter(definition => definition).map(({
|
|
@@ -4759,7 +4588,7 @@ DefinitionList.propTypes = {
|
|
|
4759
4588
|
};
|
|
4760
4589
|
DefinitionList.defaultProps = {
|
|
4761
4590
|
definitions: [],
|
|
4762
|
-
layout: Layout
|
|
4591
|
+
layout: Layout.VERTICAL_TWO_COLUMN,
|
|
4763
4592
|
muted: false
|
|
4764
4593
|
};
|
|
4765
4594
|
var DefinitionList$1 = DefinitionList;
|
|
@@ -5312,7 +5141,7 @@ DynamicFieldDefinitionList.propTypes = {
|
|
|
5312
5141
|
};
|
|
5313
5142
|
DynamicFieldDefinitionList.defaultProps = {
|
|
5314
5143
|
title: null,
|
|
5315
|
-
layout: Layout
|
|
5144
|
+
layout: Layout.VERTICAL_TWO_COLUMN
|
|
5316
5145
|
};
|
|
5317
5146
|
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
5318
5147
|
|
|
@@ -5371,11 +5200,11 @@ const Emphasis = ({
|
|
|
5371
5200
|
const FlowHeader = /*#__PURE__*/React.forwardRef(({
|
|
5372
5201
|
bottomContent,
|
|
5373
5202
|
className,
|
|
5374
|
-
layout = Layout
|
|
5203
|
+
layout = Layout.HORIZONTAL,
|
|
5375
5204
|
leftContent,
|
|
5376
5205
|
rightContent
|
|
5377
5206
|
}, reference) => {
|
|
5378
|
-
const isVertical = layout === Layout
|
|
5207
|
+
const isVertical = layout === Layout.VERTICAL;
|
|
5379
5208
|
return /*#__PURE__*/jsxs("div", {
|
|
5380
5209
|
ref: reference,
|
|
5381
5210
|
className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
|
|
@@ -5786,7 +5615,7 @@ const FlowNavigation = ({
|
|
|
5786
5615
|
steps: steps,
|
|
5787
5616
|
className: classNames('np-flow-navigation__stepper')
|
|
5788
5617
|
}),
|
|
5789
|
-
layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout
|
|
5618
|
+
layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout.VERTICAL : Layout.HORIZONTAL
|
|
5790
5619
|
})
|
|
5791
5620
|
});
|
|
5792
5621
|
};
|
|
@@ -15427,5 +15256,5 @@ const translations = {
|
|
|
15427
15256
|
'zh-HK': zhHK
|
|
15428
15257
|
};
|
|
15429
15258
|
|
|
15430
|
-
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 };
|
|
15431
15260
|
//# sourceMappingURL=index.esm.js.map
|