@transferwise/components 46.13.0 → 46.15.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 +246 -525
- package/build/index.esm.js.map +1 -1
- package/build/index.js +222 -501
- 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/actionButton/ActionButton.d.ts +1 -1
- package/build/types/body/Body.d.ts +1 -1
- package/build/types/common/Option/Option.d.ts.map +1 -1
- package/build/types/common/RadioButton/RadioButton.d.ts +10 -34
- package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
- package/build/types/common/RadioButton/index.d.ts +1 -1
- package/build/types/common/RadioButton/index.d.ts.map +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 +5 -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/radio/Radio.d.ts +10 -21
- package/build/types/radio/Radio.d.ts.map +1 -1
- package/build/types/radio/index.d.ts +2 -2
- package/build/types/radio/index.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts +10 -26
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/radioGroup/index.d.ts +2 -1
- package/build/types/radioGroup/index.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts +15 -23
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/build/types/radioOption/index.d.ts +2 -1
- package/build/types/radioOption/index.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/package.json +1 -1
- package/src/common/Option/Option.tsx +0 -1
- package/src/common/RadioButton/RadioButton.tsx +43 -0
- 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 +5 -0
- package/src/main.css +6 -82
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/radio/{Radio.story.js → Radio.story.tsx} +0 -3
- package/src/radio/{Radio.js → Radio.tsx} +18 -28
- package/src/radio/index.ts +2 -0
- package/src/radioGroup/RadioGroup.spec.js +24 -26
- package/src/radioGroup/{RadioGroup.story.js → RadioGroup.story.tsx} +0 -3
- package/src/radioGroup/RadioGroup.tsx +39 -0
- package/src/radioGroup/index.ts +2 -0
- package/src/radioOption/RadioOption.spec.js +4 -4
- package/src/radioOption/{RadioOption.story.js → RadioOption.story.tsx} +4 -4
- package/src/radioOption/RadioOption.tsx +60 -0
- package/src/radioOption/index.ts +2 -0
- 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/RadioButton/RadioButton.js +0 -41
- 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/radio/index.js +0 -3
- package/src/radioGroup/RadioGroup.js +0 -66
- package/src/radioGroup/index.js +0 -1
- package/src/radioOption/RadioOption.js +0 -81
- package/src/radioOption/index.js +0 -1
- 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/RadioButton/{RadioButton.spec.js → RadioButton.spec.tsx} +0 -0
- /package/src/common/RadioButton/__snapshots__/{RadioButton.spec.js.snap → RadioButton.spec.tsx.snap} +0 -0
- /package/src/common/RadioButton/{index.js → index.ts} +0 -0
- /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/src/radio/{Radio.rtl.spec.js → Radio.rtl.spec.tsx} +0 -0
- /package/src/radio/__snapshots__/{Radio.rtl.spec.js.snap → Radio.rtl.spec.tsx.snap} +0 -0
package/build/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var icons = require('@transferwise/icons');
|
|
|
8
8
|
var reactIntl = require('react-intl');
|
|
9
9
|
var PropTypes = require('prop-types');
|
|
10
10
|
var componentsTheming = require('@wise/components-theming');
|
|
11
|
+
var formatting = require('@transferwise/formatting');
|
|
11
12
|
var react$1 = require('@headlessui/react');
|
|
12
13
|
var mergeProps = require('merge-props');
|
|
13
14
|
var mergeRefs = require('react-merge-refs');
|
|
@@ -15,7 +16,6 @@ var shim = require('use-sync-external-store/shim');
|
|
|
15
16
|
var react = require('@floating-ui/react');
|
|
16
17
|
var focus = require('@react-aria/focus');
|
|
17
18
|
var overlays = require('@react-aria/overlays');
|
|
18
|
-
var formatting = require('@transferwise/formatting');
|
|
19
19
|
var reactTransitionGroup = require('react-transition-group');
|
|
20
20
|
var reactPopper = require('react-popper');
|
|
21
21
|
var throttle = require('lodash.throttle');
|
|
@@ -2779,15 +2779,15 @@ function getDayNames(locale, format = 'short') {
|
|
|
2779
2779
|
return days;
|
|
2780
2780
|
}
|
|
2781
2781
|
|
|
2782
|
-
function isWithinRange(date, min, max) {
|
|
2783
|
-
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
2782
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2787
2783
|
function moveToWithinRange(date, min, max) {
|
|
2788
2784
|
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
2789
2785
|
}
|
|
2790
2786
|
|
|
2787
|
+
function isWithinRange(date, min, max) {
|
|
2788
|
+
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
2791
|
const getMonthNames = (locale, format = 'long') => {
|
|
2792
2792
|
const months = [];
|
|
2793
2793
|
const date = new Date(2018, 0, 1);
|
|
@@ -2801,9 +2801,17 @@ const getMonthNames = (locale, format = 'long') => {
|
|
|
2801
2801
|
return months;
|
|
2802
2802
|
};
|
|
2803
2803
|
|
|
2804
|
-
const isDateValid = date =>
|
|
2805
|
-
|
|
2806
|
-
|
|
2804
|
+
const isDateValid = date => {
|
|
2805
|
+
if (date === null) {
|
|
2806
|
+
return false;
|
|
2807
|
+
} else if (date instanceof Date) {
|
|
2808
|
+
return validDateObject(date);
|
|
2809
|
+
} else {
|
|
2810
|
+
return validDateString(date);
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
const validDateString = dateString => validDateObject(new Date(dateString));
|
|
2814
|
+
const validDateObject = dateObject => !isNaN(dateObject.getTime());
|
|
2807
2815
|
|
|
2808
2816
|
const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
|
|
2809
2817
|
|
|
@@ -2825,48 +2833,31 @@ var messages$9 = reactIntl.defineMessages({
|
|
|
2825
2833
|
}
|
|
2826
2834
|
});
|
|
2827
2835
|
|
|
2828
|
-
const explodeDate = date => {
|
|
2829
|
-
const year = date.getFullYear();
|
|
2830
|
-
const month = date.getMonth();
|
|
2831
|
-
const day = date.getDate();
|
|
2832
|
-
return {
|
|
2833
|
-
year,
|
|
2834
|
-
month,
|
|
2835
|
-
day
|
|
2836
|
-
};
|
|
2837
|
-
};
|
|
2838
|
-
|
|
2839
2836
|
const convertToLocalMidnight = date => {
|
|
2840
2837
|
const utcDate = new Date(date.split('T')[0]); // using YYYY-MM-DD creates UTC date
|
|
2841
|
-
|
|
2842
2838
|
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
|
|
2843
2839
|
};
|
|
2844
2840
|
|
|
2845
2841
|
const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
|
|
2846
|
-
const INITIAL_DEFAULT_STATE = {
|
|
2847
|
-
year: null,
|
|
2848
|
-
month: null,
|
|
2849
|
-
day: null
|
|
2850
|
-
};
|
|
2851
2842
|
const DateInput = ({
|
|
2852
2843
|
'aria-labelledby': ariaLabelledBy,
|
|
2853
2844
|
'aria-label': ariaLabel,
|
|
2854
|
-
disabled,
|
|
2855
|
-
size,
|
|
2845
|
+
disabled = false,
|
|
2846
|
+
size = exports.Size.MEDIUM,
|
|
2856
2847
|
value,
|
|
2857
2848
|
dayLabel,
|
|
2858
2849
|
dayAutoComplete,
|
|
2859
2850
|
monthLabel,
|
|
2860
2851
|
yearLabel,
|
|
2861
2852
|
yearAutoComplete,
|
|
2862
|
-
monthFormat,
|
|
2863
|
-
mode,
|
|
2853
|
+
monthFormat = exports.MonthFormat.LONG,
|
|
2854
|
+
mode = exports.DateMode.DAY_MONTH_YEAR,
|
|
2864
2855
|
onChange,
|
|
2865
2856
|
onFocus,
|
|
2866
2857
|
onBlur,
|
|
2867
2858
|
placeholders,
|
|
2868
2859
|
id,
|
|
2869
|
-
selectProps
|
|
2860
|
+
selectProps = {}
|
|
2870
2861
|
}) => {
|
|
2871
2862
|
const {
|
|
2872
2863
|
locale,
|
|
@@ -2876,23 +2867,34 @@ const DateInput = ({
|
|
|
2876
2867
|
if (value && isDateValid(value)) {
|
|
2877
2868
|
return typeof value === 'string' ? convertToLocalMidnight(value) : value;
|
|
2878
2869
|
}
|
|
2879
|
-
return
|
|
2870
|
+
return undefined;
|
|
2880
2871
|
};
|
|
2881
|
-
const
|
|
2882
|
-
let explodedDate = INITIAL_DEFAULT_STATE;
|
|
2872
|
+
const getInitialDate = unit => {
|
|
2883
2873
|
if (value && isDateValid(value)) {
|
|
2884
2874
|
const dateObject = getDateObject();
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2875
|
+
if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {
|
|
2876
|
+
return null;
|
|
2877
|
+
}
|
|
2878
|
+
if (dateObject !== undefined) {
|
|
2879
|
+
switch (unit) {
|
|
2880
|
+
case 'year':
|
|
2881
|
+
return dateObject.getFullYear();
|
|
2882
|
+
case 'month':
|
|
2883
|
+
return dateObject.getMonth();
|
|
2884
|
+
case 'day':
|
|
2885
|
+
return dateObject.getDate();
|
|
2886
|
+
default:
|
|
2887
|
+
return null;
|
|
2888
|
+
}
|
|
2888
2889
|
}
|
|
2889
2890
|
}
|
|
2890
|
-
return
|
|
2891
|
+
return null;
|
|
2891
2892
|
};
|
|
2892
|
-
const [day, setDay] = React.useState(() =>
|
|
2893
|
-
const [month, setMonth] = React.useState(() =>
|
|
2894
|
-
const [year, setYear] = React.useState(() =>
|
|
2893
|
+
const [day, setDay] = React.useState(() => getInitialDate('day'));
|
|
2894
|
+
const [month, setMonth] = React.useState(() => getInitialDate('month'));
|
|
2895
|
+
const [year, setYear] = React.useState(() => getInitialDate('year'));
|
|
2895
2896
|
const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
|
|
2897
|
+
const monthNames = getMonthNames(locale, monthFormat);
|
|
2896
2898
|
dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
|
|
2897
2899
|
monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
|
|
2898
2900
|
yearLabel = yearLabel || formatMessage(messages$9.yearLabel);
|
|
@@ -2914,7 +2916,6 @@ const DateInput = ({
|
|
|
2914
2916
|
}
|
|
2915
2917
|
};
|
|
2916
2918
|
const getSelectElement = () => {
|
|
2917
|
-
const monthOptions = getMonthsOptions();
|
|
2918
2919
|
return /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
2919
2920
|
className: "d-flex flex-column",
|
|
2920
2921
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -2923,70 +2924,60 @@ const DateInput = ({
|
|
|
2923
2924
|
}), /*#__PURE__*/jsxRuntime.jsx(SelectInput, {
|
|
2924
2925
|
name: "month",
|
|
2925
2926
|
disabled: disabled,
|
|
2926
|
-
placeholder: placeholders
|
|
2927
|
-
items:
|
|
2927
|
+
placeholder: placeholders?.month,
|
|
2928
|
+
items: Array.from({
|
|
2929
|
+
length: 12
|
|
2930
|
+
}, (_, index) => ({
|
|
2931
|
+
type: 'option',
|
|
2932
|
+
value: index
|
|
2933
|
+
})),
|
|
2928
2934
|
size: size,
|
|
2929
|
-
value:
|
|
2930
|
-
renderValue: ({
|
|
2931
|
-
|
|
2932
|
-
}) => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent, {
|
|
2933
|
-
title: label
|
|
2935
|
+
value: month,
|
|
2936
|
+
renderValue: selectedValue => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent, {
|
|
2937
|
+
title: monthNames[selectedValue]
|
|
2934
2938
|
}),
|
|
2935
2939
|
onChange: selectedValue => handleMonthChange(selectedValue),
|
|
2936
2940
|
...selectProps
|
|
2937
2941
|
})]
|
|
2938
2942
|
});
|
|
2939
2943
|
};
|
|
2940
|
-
const getMonthsOptions = () => {
|
|
2941
|
-
const options = [];
|
|
2942
|
-
const months = getMonthNames(locale, monthFormat);
|
|
2943
|
-
months.forEach((label, index) => {
|
|
2944
|
-
options.push({
|
|
2945
|
-
type: 'option',
|
|
2946
|
-
value: {
|
|
2947
|
-
label,
|
|
2948
|
-
value: index
|
|
2949
|
-
}
|
|
2950
|
-
});
|
|
2951
|
-
});
|
|
2952
|
-
return options;
|
|
2953
|
-
};
|
|
2954
2944
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2945
|
+
if (newDay == null || newMonth == null || newYear == null) {
|
|
2946
|
+
broadcastNewValue(null);
|
|
2947
|
+
return;
|
|
2948
|
+
}
|
|
2949
|
+
const dateValue = new Date(newYear, newMonth, newDay);
|
|
2950
|
+
if (!isDateValid(dateValue)) {
|
|
2951
|
+
broadcastNewValue(null);
|
|
2952
|
+
return;
|
|
2959
2953
|
}
|
|
2960
2954
|
if (mode === exports.DateMode.MONTH_YEAR) {
|
|
2961
|
-
if (newMonth
|
|
2962
|
-
broadcastNewValue(
|
|
2955
|
+
if (newMonth !== month || newYear !== year) {
|
|
2956
|
+
broadcastNewValue(dateValue);
|
|
2963
2957
|
}
|
|
2964
|
-
} else if (newDay
|
|
2965
|
-
broadcastNewValue(
|
|
2958
|
+
} else if (newDay !== day || newMonth !== month || newYear !== year) {
|
|
2959
|
+
broadcastNewValue(dateValue);
|
|
2966
2960
|
}
|
|
2967
2961
|
};
|
|
2968
2962
|
const handleDayChange = event => {
|
|
2969
2963
|
const {
|
|
2970
2964
|
checkedDay
|
|
2971
|
-
} = checkDate(event.target.value, month, year);
|
|
2965
|
+
} = checkDate(Number.parseInt(event.target.value, 10), month, year);
|
|
2972
2966
|
setDay(checkedDay);
|
|
2973
2967
|
handleInternalValue(checkedDay, month, year);
|
|
2974
2968
|
};
|
|
2975
|
-
const handleMonthChange =
|
|
2976
|
-
if (
|
|
2969
|
+
const handleMonthChange = selectedMonth => {
|
|
2970
|
+
if (selectedMonth === null) {
|
|
2977
2971
|
setMonth(null);
|
|
2978
2972
|
handleInternalValue(day, null, year);
|
|
2979
2973
|
return;
|
|
2980
2974
|
}
|
|
2981
|
-
const selectedMonth = selectedValue ? selectedValue.value : 0;
|
|
2982
2975
|
const {
|
|
2983
2976
|
checkedDay
|
|
2984
2977
|
} = checkDate(day, selectedMonth, year);
|
|
2985
2978
|
setMonth(selectedMonth);
|
|
2986
|
-
if (day) {
|
|
2987
|
-
|
|
2988
|
-
setDay(checkedDay);
|
|
2989
|
-
}
|
|
2979
|
+
if (day && checkedDay !== day) {
|
|
2980
|
+
setDay(checkedDay);
|
|
2990
2981
|
}
|
|
2991
2982
|
handleInternalValue(checkedDay, selectedMonth, year);
|
|
2992
2983
|
};
|
|
@@ -2997,35 +2988,33 @@ const DateInput = ({
|
|
|
2997
2988
|
// Correct day based on year and month.
|
|
2998
2989
|
const {
|
|
2999
2990
|
checkedDay
|
|
3000
|
-
} = checkDate(day, month, newValue);
|
|
3001
|
-
if (day) {
|
|
3002
|
-
|
|
3003
|
-
setDay(checkedDay);
|
|
3004
|
-
}
|
|
2991
|
+
} = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
2992
|
+
if (day && checkedDay !== day) {
|
|
2993
|
+
setDay(checkedDay);
|
|
3005
2994
|
}
|
|
3006
|
-
setYear(slicedYear);
|
|
3007
|
-
handleInternalValue(checkedDay, month, slicedYear);
|
|
2995
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2996
|
+
handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
|
|
3008
2997
|
} else {
|
|
3009
|
-
setYear(slicedYear);
|
|
2998
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
3010
2999
|
handleInternalValue(day, month, null);
|
|
3011
3000
|
}
|
|
3012
3001
|
};
|
|
3013
3002
|
const broadcastNewValue = newValue => {
|
|
3014
3003
|
if (newValue !== lastBroadcastedValue) {
|
|
3015
3004
|
setLastBroadcastedValue(newValue);
|
|
3016
|
-
onChange(getDateAsString(newValue)
|
|
3005
|
+
onChange(newValue != null ? getDateAsString(newValue) : null);
|
|
3017
3006
|
}
|
|
3018
3007
|
};
|
|
3019
3008
|
const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
|
|
3020
3009
|
let checkedDay = newDay;
|
|
3021
|
-
const maxDay = new Date(newYear || 2000, newMonth + 1, 0).getDate();
|
|
3010
|
+
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
3022
3011
|
if (!newDay) {
|
|
3023
3012
|
checkedDay = null;
|
|
3024
3013
|
}
|
|
3025
|
-
if (newDay && newDay < 0
|
|
3014
|
+
if (newDay && newDay < 0) {
|
|
3026
3015
|
checkedDay = 1;
|
|
3027
3016
|
}
|
|
3028
|
-
if (newDay && newMonth || newDay > 31) {
|
|
3017
|
+
if (newDay && newMonth || newDay && newDay > 31) {
|
|
3029
3018
|
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
3030
3019
|
}
|
|
3031
3020
|
return {
|
|
@@ -3045,8 +3034,10 @@ const DateInput = ({
|
|
|
3045
3034
|
id: id,
|
|
3046
3035
|
"aria-labelledby": ariaLabelledBy,
|
|
3047
3036
|
"aria-label": ariaLabel,
|
|
3048
|
-
|
|
3049
|
-
|
|
3037
|
+
role: "group" // Add role attribute to indicate container for interactive elements
|
|
3038
|
+
,
|
|
3039
|
+
onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus(event) : event.stopPropagation(),
|
|
3040
|
+
onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur(event) : event.stopPropagation(),
|
|
3050
3041
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3051
3042
|
className: "row",
|
|
3052
3043
|
children: [monthBeforeDay && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -3099,7 +3090,6 @@ const DateInput = ({
|
|
|
3099
3090
|
})
|
|
3100
3091
|
});
|
|
3101
3092
|
};
|
|
3102
|
-
|
|
3103
3093
|
// Should only propagate if the relatedTarget is not part of this DateInput component.
|
|
3104
3094
|
function shouldPropagateOnFocus({
|
|
3105
3095
|
target,
|
|
@@ -3109,7 +3099,6 @@ function shouldPropagateOnFocus({
|
|
|
3109
3099
|
const relatedParent = relatedTarget && relatedTarget.closest('.tw-date');
|
|
3110
3100
|
return targetParent !== relatedParent;
|
|
3111
3101
|
}
|
|
3112
|
-
|
|
3113
3102
|
// Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
|
|
3114
3103
|
function shouldPropagateOnBlur({
|
|
3115
3104
|
target,
|
|
@@ -3126,42 +3115,6 @@ function shouldPropagateOnBlur({
|
|
|
3126
3115
|
const focusElementParent = focusElement && focusElement.closest('.tw-date');
|
|
3127
3116
|
return blurElementParent !== focusElementParent;
|
|
3128
3117
|
}
|
|
3129
|
-
DateInput.propTypes = {
|
|
3130
|
-
'aria-label': PropTypes__default.default.string,
|
|
3131
|
-
'aria-labelledby': PropTypes__default.default.string,
|
|
3132
|
-
disabled: PropTypes__default.default.bool,
|
|
3133
|
-
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
3134
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.instanceOf(Date)]),
|
|
3135
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
3136
|
-
onFocus: PropTypes__default.default.func,
|
|
3137
|
-
onBlur: PropTypes__default.default.func,
|
|
3138
|
-
dayLabel: PropTypes__default.default.string,
|
|
3139
|
-
dayAutoComplete: PropTypes__default.default.string,
|
|
3140
|
-
monthLabel: PropTypes__default.default.string,
|
|
3141
|
-
yearLabel: PropTypes__default.default.string,
|
|
3142
|
-
yearAutoComplete: PropTypes__default.default.string,
|
|
3143
|
-
monthFormat: PropTypes__default.default.oneOf(['long', 'short']),
|
|
3144
|
-
mode: PropTypes__default.default.oneOf(['day-month-year', 'month-year']),
|
|
3145
|
-
placeholders: PropTypes__default.default.shape({
|
|
3146
|
-
day: PropTypes__default.default.node,
|
|
3147
|
-
month: PropTypes__default.default.node,
|
|
3148
|
-
year: PropTypes__default.default.node
|
|
3149
|
-
}),
|
|
3150
|
-
id: PropTypes__default.default.string,
|
|
3151
|
-
selectProps: PropTypes__default.default.object
|
|
3152
|
-
};
|
|
3153
|
-
DateInput.defaultProps = {
|
|
3154
|
-
disabled: false,
|
|
3155
|
-
size: exports.Size.MEDIUM,
|
|
3156
|
-
value: null,
|
|
3157
|
-
onFocus: null,
|
|
3158
|
-
onBlur: null,
|
|
3159
|
-
monthFormat: exports.MonthFormat.LONG,
|
|
3160
|
-
mode: exports.DateMode.DAY_MONTH_YEAR,
|
|
3161
|
-
id: '',
|
|
3162
|
-
selectProps: {}
|
|
3163
|
-
};
|
|
3164
|
-
var DateInput$1 = DateInput;
|
|
3165
3118
|
|
|
3166
3119
|
const POPOVER_OFFSET = [0, 16];
|
|
3167
3120
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
@@ -4347,6 +4300,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4347
4300
|
size,
|
|
4348
4301
|
placeholder,
|
|
4349
4302
|
label,
|
|
4303
|
+
'aria-labelledby': ariaLabelledBy,
|
|
4350
4304
|
monthFormat,
|
|
4351
4305
|
disabled,
|
|
4352
4306
|
clearable,
|
|
@@ -4355,6 +4309,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4355
4309
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4356
4310
|
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4357
4311
|
ref: this.element,
|
|
4312
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4358
4313
|
className: "input-group",
|
|
4359
4314
|
onKeyDown: this.handleKeyDown,
|
|
4360
4315
|
children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger$1, {
|
|
@@ -4384,6 +4339,7 @@ DateLookup.propTypes = {
|
|
|
4384
4339
|
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
4385
4340
|
placeholder: PropTypes__default.default.string,
|
|
4386
4341
|
label: PropTypes__default.default.string,
|
|
4342
|
+
'aria-labelledby': PropTypes__default.default.string,
|
|
4387
4343
|
monthFormat: PropTypes__default.default.oneOf(['long', 'short']),
|
|
4388
4344
|
disabled: PropTypes__default.default.bool,
|
|
4389
4345
|
onChange: PropTypes__default.default.func.isRequired,
|
|
@@ -4406,19 +4362,6 @@ DateLookup.defaultProps = {
|
|
|
4406
4362
|
};
|
|
4407
4363
|
var DateLookup$1 = DateLookup;
|
|
4408
4364
|
|
|
4409
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4410
|
-
exports.DecisionPresentation = void 0;
|
|
4411
|
-
(function (Presentation) {
|
|
4412
|
-
Presentation["LIST"] = "LIST";
|
|
4413
|
-
Presentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4414
|
-
Presentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4415
|
-
})(exports.DecisionPresentation || (exports.DecisionPresentation = {}));
|
|
4416
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4417
|
-
exports.DecisionType = void 0;
|
|
4418
|
-
(function (Type) {
|
|
4419
|
-
Type["NAVIGATION"] = "NAVIGATION";
|
|
4420
|
-
})(exports.DecisionType || (exports.DecisionType = {}));
|
|
4421
|
-
|
|
4422
4365
|
const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
4423
4366
|
as: component = 'button',
|
|
4424
4367
|
disabled = false,
|
|
@@ -4452,70 +4395,6 @@ const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
|
4452
4395
|
});
|
|
4453
4396
|
});
|
|
4454
4397
|
|
|
4455
|
-
const Layout = {
|
|
4456
|
-
COLUMN: 'COLUMN'
|
|
4457
|
-
};
|
|
4458
|
-
const SizeSwapper = /*#__PURE__*/React.forwardRef(({
|
|
4459
|
-
items,
|
|
4460
|
-
inline
|
|
4461
|
-
}, reference) => {
|
|
4462
|
-
const parentReference = React.useRef(null);
|
|
4463
|
-
const [clientWidth] = useClientWidth({
|
|
4464
|
-
ref: reference || parentReference
|
|
4465
|
-
});
|
|
4466
|
-
if (!items || items.length === 0) {
|
|
4467
|
-
return null;
|
|
4468
|
-
}
|
|
4469
|
-
// If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
|
|
4470
|
-
// Do not use deconstruct here to get items and layout.
|
|
4471
|
-
let itemsToRender = [];
|
|
4472
|
-
if (clientWidth) {
|
|
4473
|
-
itemsToRender = items.filter(({
|
|
4474
|
-
breakpoint = 0
|
|
4475
|
-
}) => clientWidth >= breakpoint).pop();
|
|
4476
|
-
} else {
|
|
4477
|
-
// On SSR environments useClientWidth returns null because ref is undefined so we render
|
|
4478
|
-
// all elements by default.
|
|
4479
|
-
// If there's no SSR and on first Hydration only the right elements are going to be rendered.
|
|
4480
|
-
// If clientWidth is null or zero all elements render like a responsive technique would do.
|
|
4481
|
-
itemsToRender.items = items.map(({
|
|
4482
|
-
items
|
|
4483
|
-
}) => Object.values(items));
|
|
4484
|
-
}
|
|
4485
|
-
|
|
4486
|
-
// Always return parent container even if there are no items to display to
|
|
4487
|
-
// keep the ref on DOM and let clientWidth be calculated properly.
|
|
4488
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4489
|
-
ref: parentReference,
|
|
4490
|
-
className: classNames__default.default('np-size-swapper', {
|
|
4491
|
-
'd-flex': !inline,
|
|
4492
|
-
'd-inline-flex': inline,
|
|
4493
|
-
'flex-column': itemsToRender && itemsToRender.layout === Layout.COLUMN,
|
|
4494
|
-
'flex-wrap': itemsToRender && itemsToRender.wrap
|
|
4495
|
-
}),
|
|
4496
|
-
style: {
|
|
4497
|
-
visibility: clientWidth ? 'visible' : 'hidden'
|
|
4498
|
-
},
|
|
4499
|
-
children: itemsToRender && itemsToRender.items
|
|
4500
|
-
});
|
|
4501
|
-
});
|
|
4502
|
-
SizeSwapper.Breakpoint = exports.Breakpoint;
|
|
4503
|
-
SizeSwapper.Layout = Layout;
|
|
4504
|
-
SizeSwapper.propTypes = {
|
|
4505
|
-
inline: PropTypes__default.default.bool,
|
|
4506
|
-
/** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */
|
|
4507
|
-
items: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4508
|
-
items: PropTypes__default.default.arrayOf(PropTypes__default.default.element),
|
|
4509
|
-
breakpoint: PropTypes__default.default.number,
|
|
4510
|
-
layout: PropTypes__default.default.oneOf([SizeSwapper.Layout.COLUMN]),
|
|
4511
|
-
wrap: PropTypes__default.default.bool
|
|
4512
|
-
})).isRequired
|
|
4513
|
-
};
|
|
4514
|
-
SizeSwapper.defaultProps = {
|
|
4515
|
-
inline: false
|
|
4516
|
-
};
|
|
4517
|
-
var SizeSwapper$1 = SizeSwapper;
|
|
4518
|
-
|
|
4519
4398
|
const Tile = ({
|
|
4520
4399
|
className,
|
|
4521
4400
|
description,
|
|
@@ -4564,7 +4443,7 @@ Tile.propTypes = {
|
|
|
4564
4443
|
className: PropTypes__default.default.string,
|
|
4565
4444
|
description: PropTypes__default.default.node,
|
|
4566
4445
|
disabled: PropTypes__default.default.bool,
|
|
4567
|
-
href: PropTypes__default.default.string
|
|
4446
|
+
href: PropTypes__default.default.string,
|
|
4568
4447
|
target: PropTypes__default.default.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4569
4448
|
/** Accepts only Avatar and images */
|
|
4570
4449
|
media: PropTypes__default.default.node.isRequired,
|
|
@@ -4583,85 +4462,28 @@ Tile.defaultProps = {
|
|
|
4583
4462
|
};
|
|
4584
4463
|
var Tile$1 = Tile;
|
|
4585
4464
|
|
|
4465
|
+
exports.DecisionPresentation = void 0;
|
|
4466
|
+
(function (DecisionPresentation) {
|
|
4467
|
+
DecisionPresentation["LIST"] = "LIST";
|
|
4468
|
+
DecisionPresentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4469
|
+
DecisionPresentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4470
|
+
})(exports.DecisionPresentation || (exports.DecisionPresentation = {}));
|
|
4471
|
+
exports.DecisionType = void 0;
|
|
4472
|
+
(function (DecisionType) {
|
|
4473
|
+
DecisionType["NAVIGATION"] = "NAVIGATION";
|
|
4474
|
+
})(exports.DecisionType || (exports.DecisionType = {}));
|
|
4586
4475
|
const Decision = ({
|
|
4587
4476
|
options,
|
|
4588
|
-
presentation,
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4477
|
+
presentation = exports.DecisionPresentation.LIST,
|
|
4478
|
+
size = exports.Size.MEDIUM,
|
|
4479
|
+
type = exports.DecisionType.NAVIGATION,
|
|
4480
|
+
showMediaCircleInList = true,
|
|
4481
|
+
isContainerAligned = false
|
|
4593
4482
|
}) => {
|
|
4483
|
+
const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
|
|
4484
|
+
const screenSm = useScreenSize(exports.Breakpoint.SMALL);
|
|
4594
4485
|
if (type === exports.DecisionType.NAVIGATION) {
|
|
4595
|
-
const {
|
|
4596
|
-
LIST_BLOCK,
|
|
4597
|
-
LIST_BLOCK_GRID
|
|
4598
|
-
} = exports.DecisionPresentation;
|
|
4599
|
-
if (presentation === LIST_BLOCK || presentation === LIST_BLOCK_GRID) {
|
|
4600
|
-
const isSmall = size === exports.Size.SMALL;
|
|
4601
|
-
const isGrid = presentation === LIST_BLOCK_GRID;
|
|
4602
|
-
const items = [{
|
|
4603
|
-
items: [],
|
|
4604
|
-
layout: SizeSwapper$1.Layout.COLUMN
|
|
4605
|
-
}, {
|
|
4606
|
-
items: [],
|
|
4607
|
-
breakpoint: isSmall ? exports.Breakpoint.EXTRA_SMALL : exports.Breakpoint.SMALL,
|
|
4608
|
-
wrap: isGrid
|
|
4609
|
-
}];
|
|
4610
|
-
options.forEach(({
|
|
4611
|
-
description,
|
|
4612
|
-
disabled,
|
|
4613
|
-
href,
|
|
4614
|
-
target,
|
|
4615
|
-
media: {
|
|
4616
|
-
block,
|
|
4617
|
-
list
|
|
4618
|
-
},
|
|
4619
|
-
onClick,
|
|
4620
|
-
title
|
|
4621
|
-
}, key) => {
|
|
4622
|
-
items[0].items.push( /*#__PURE__*/jsxRuntime.jsx(NavigationOption
|
|
4623
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4624
|
-
, {
|
|
4625
|
-
complex: false,
|
|
4626
|
-
content: description,
|
|
4627
|
-
disabled: disabled,
|
|
4628
|
-
href: href,
|
|
4629
|
-
target: target,
|
|
4630
|
-
media: list,
|
|
4631
|
-
showMediaAtAllSizes: true,
|
|
4632
|
-
showMediaCircle: showMediaCircleInList,
|
|
4633
|
-
isContainerAligned: isContainerAligned,
|
|
4634
|
-
title: title,
|
|
4635
|
-
onClick: onClick
|
|
4636
|
-
}, `nav-${key}`));
|
|
4637
|
-
items[1].items.push( /*#__PURE__*/jsxRuntime.jsx(Tile$1
|
|
4638
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4639
|
-
, {
|
|
4640
|
-
className: classNames__default.default(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4641
|
-
'np-decision__tile--fixed-width': isGrid
|
|
4642
|
-
}),
|
|
4643
|
-
description: description,
|
|
4644
|
-
disabled: disabled,
|
|
4645
|
-
href: href,
|
|
4646
|
-
target: target,
|
|
4647
|
-
media: block,
|
|
4648
|
-
size: isSmall ? exports.Size.SMALL : exports.Size.MEDIUM,
|
|
4649
|
-
title: title,
|
|
4650
|
-
onClick: onClick
|
|
4651
|
-
}, `tile-${key}`));
|
|
4652
|
-
});
|
|
4653
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4654
|
-
className: classNames__default.default('np-decision', {
|
|
4655
|
-
'np-decision--small': isSmall,
|
|
4656
|
-
'np-decision--grid': isGrid
|
|
4657
|
-
}),
|
|
4658
|
-
children: /*#__PURE__*/jsxRuntime.jsx(SizeSwapper$1, {
|
|
4659
|
-
items: items
|
|
4660
|
-
})
|
|
4661
|
-
});
|
|
4662
|
-
}
|
|
4663
|
-
// LIST
|
|
4664
|
-
return options.map(({
|
|
4486
|
+
const renderedOptions = options.map(({
|
|
4665
4487
|
title,
|
|
4666
4488
|
description,
|
|
4667
4489
|
disabled,
|
|
@@ -4686,42 +4508,49 @@ const Decision = ({
|
|
|
4686
4508
|
title: title,
|
|
4687
4509
|
onClick: onClick
|
|
4688
4510
|
}, `nav-${key}`));
|
|
4511
|
+
if (presentation === exports.DecisionPresentation.LIST_BLOCK || presentation === exports.DecisionPresentation.LIST_BLOCK_GRID) {
|
|
4512
|
+
const isSmall = size === exports.Size.SMALL;
|
|
4513
|
+
const breakpoint = isSmall ? screenXs : screenSm;
|
|
4514
|
+
const isGrid = presentation === exports.DecisionPresentation.LIST_BLOCK_GRID;
|
|
4515
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4516
|
+
className: classNames__default.default('np-decision d-flex', {
|
|
4517
|
+
'np-decision--small': isSmall,
|
|
4518
|
+
'np-decision--grid': isGrid
|
|
4519
|
+
}, breakpoint ? isGrid && 'flex-wrap' : 'flex-column'),
|
|
4520
|
+
children: breakpoint ? options.map(({
|
|
4521
|
+
description,
|
|
4522
|
+
disabled,
|
|
4523
|
+
href,
|
|
4524
|
+
target,
|
|
4525
|
+
media: {
|
|
4526
|
+
block
|
|
4527
|
+
},
|
|
4528
|
+
onClick,
|
|
4529
|
+
title
|
|
4530
|
+
}, key) => /*#__PURE__*/jsxRuntime.jsx(Tile$1
|
|
4531
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4532
|
+
, {
|
|
4533
|
+
className: classNames__default.default(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4534
|
+
'np-decision__tile--fixed-width': isGrid
|
|
4535
|
+
}),
|
|
4536
|
+
description: description,
|
|
4537
|
+
disabled: disabled,
|
|
4538
|
+
href: href,
|
|
4539
|
+
target: target,
|
|
4540
|
+
media: block,
|
|
4541
|
+
size: isSmall ? exports.Size.SMALL : exports.Size.MEDIUM,
|
|
4542
|
+
title: title,
|
|
4543
|
+
onClick: onClick
|
|
4544
|
+
}, `tile-${key}`)) : renderedOptions
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4547
|
+
// LIST
|
|
4548
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
4549
|
+
children: renderedOptions
|
|
4550
|
+
});
|
|
4689
4551
|
}
|
|
4690
|
-
return
|
|
4691
|
-
};
|
|
4692
|
-
Decision.propTypes = {
|
|
4693
|
-
/** A list of elements to be rendered */
|
|
4694
|
-
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4695
|
-
description: PropTypes__default.default.node,
|
|
4696
|
-
disabled: PropTypes__default.default.bool,
|
|
4697
|
-
href: PropTypes__default.default.string,
|
|
4698
|
-
target: PropTypes__default.default.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4699
|
-
media: PropTypes__default.default.shape({
|
|
4700
|
-
block: PropTypes__default.default.node.isRequired,
|
|
4701
|
-
list: PropTypes__default.default.node.isRequired
|
|
4702
|
-
}),
|
|
4703
|
-
onClick: PropTypes__default.default.func,
|
|
4704
|
-
title: PropTypes__default.default.node.isRequired
|
|
4705
|
-
})).isRequired,
|
|
4706
|
-
/** Handles the display mode of the component */
|
|
4707
|
-
presentation: PropTypes__default.default.oneOf(['LIST', 'LIST_BLOCK', 'LIST_BLOCK_GRID']),
|
|
4708
|
-
/** Size currently affects only Tile dimension */
|
|
4709
|
-
size: PropTypes__default.default.oneOf(['sm', 'md']),
|
|
4710
|
-
/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
|
|
4711
|
-
type: PropTypes__default.default.oneOf(['NAVIGATION']),
|
|
4712
|
-
/** Display media in a circle in list presentation */
|
|
4713
|
-
showMediaCircleInList: PropTypes__default.default.bool,
|
|
4714
|
-
/** Sets navigation options to be aligned with the parent container */
|
|
4715
|
-
isContainerAligned: PropTypes__default.default.bool
|
|
4716
|
-
};
|
|
4717
|
-
Decision.defaultProps = {
|
|
4718
|
-
presentation: exports.DecisionPresentation.LIST,
|
|
4719
|
-
size: exports.Size.MEDIUM,
|
|
4720
|
-
type: exports.DecisionType.NAVIGATION,
|
|
4721
|
-
showMediaCircleInList: true,
|
|
4722
|
-
isContainerAligned: false
|
|
4552
|
+
return null;
|
|
4723
4553
|
};
|
|
4724
|
-
var Decision$1 = Decision;
|
|
4725
4554
|
|
|
4726
4555
|
const isLayoutHorizontal = layout => [exports.Layout.HORIZONTAL_LEFT_ALIGNED, exports.Layout.HORIZONTAL_RIGHT_ALIGNED, exports.Layout.HORIZONTAL_JUSTIFIED].includes(layout);
|
|
4727
4556
|
const getAlignmentClasses = (layout, action) => {
|
|
@@ -10143,54 +9972,42 @@ Provider.defaultProps = {
|
|
|
10143
9972
|
};
|
|
10144
9973
|
var Provider$1 = Provider;
|
|
10145
9974
|
|
|
10146
|
-
|
|
9975
|
+
function RadioButton({
|
|
10147
9976
|
id,
|
|
10148
|
-
value,
|
|
9977
|
+
value = '',
|
|
10149
9978
|
name,
|
|
10150
9979
|
checked,
|
|
10151
9980
|
onChange,
|
|
10152
9981
|
disabled,
|
|
10153
9982
|
readOnly
|
|
10154
|
-
})
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
className:
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
})
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
10181
|
-
readOnly: PropTypes__default.default.bool
|
|
10182
|
-
};
|
|
10183
|
-
RadioButton.defaultProps = {
|
|
10184
|
-
checked: false,
|
|
10185
|
-
onChange: () => {},
|
|
10186
|
-
disabled: false,
|
|
10187
|
-
id: null,
|
|
10188
|
-
value: '',
|
|
10189
|
-
readOnly: false
|
|
10190
|
-
};
|
|
10191
|
-
var RadioButton$1 = RadioButton;
|
|
9983
|
+
}) {
|
|
9984
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
9985
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
9986
|
+
type: "radio",
|
|
9987
|
+
className: "sr-only",
|
|
9988
|
+
id: id,
|
|
9989
|
+
value: value,
|
|
9990
|
+
name: name,
|
|
9991
|
+
checked: checked,
|
|
9992
|
+
disabled: disabled || readOnly,
|
|
9993
|
+
onChange: () => {
|
|
9994
|
+
if (!checked) {
|
|
9995
|
+
onChange?.(value);
|
|
9996
|
+
}
|
|
9997
|
+
}
|
|
9998
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
9999
|
+
className: classNames__default.default('tw-radio-button', {
|
|
10000
|
+
checked,
|
|
10001
|
+
disabled: disabled || readOnly
|
|
10002
|
+
}),
|
|
10003
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
10004
|
+
className: "tw-radio-check"
|
|
10005
|
+
})
|
|
10006
|
+
})]
|
|
10007
|
+
});
|
|
10008
|
+
}
|
|
10192
10009
|
|
|
10193
|
-
|
|
10010
|
+
function Radio({
|
|
10194
10011
|
label,
|
|
10195
10012
|
id,
|
|
10196
10013
|
disabled,
|
|
@@ -10198,7 +10015,7 @@ const Radio = ({
|
|
|
10198
10015
|
avatar,
|
|
10199
10016
|
secondary,
|
|
10200
10017
|
...otherProps
|
|
10201
|
-
})
|
|
10018
|
+
}) {
|
|
10202
10019
|
const {
|
|
10203
10020
|
isModern
|
|
10204
10021
|
} = componentsTheming.useTheme();
|
|
@@ -10214,7 +10031,7 @@ const Radio = ({
|
|
|
10214
10031
|
htmlFor: id,
|
|
10215
10032
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
10216
10033
|
className: classNames__default.default(isModern ? 'm-r-2' : 'p-r-2', 'np-radio-button'),
|
|
10217
|
-
children: /*#__PURE__*/jsxRuntime.jsx(RadioButton
|
|
10034
|
+
children: /*#__PURE__*/jsxRuntime.jsx(RadioButton, {
|
|
10218
10035
|
id: id,
|
|
10219
10036
|
disabled: disabled,
|
|
10220
10037
|
...otherProps
|
|
@@ -10236,100 +10053,36 @@ const Radio = ({
|
|
|
10236
10053
|
})]
|
|
10237
10054
|
})
|
|
10238
10055
|
});
|
|
10239
|
-
}
|
|
10240
|
-
Radio.propTypes = {
|
|
10241
|
-
avatar: PropTypes__default.default.element,
|
|
10242
|
-
checked: PropTypes__default.default.bool,
|
|
10243
|
-
disabled: PropTypes__default.default.bool,
|
|
10244
|
-
id: PropTypes__default.default.string,
|
|
10245
|
-
label: PropTypes__default.default.string.isRequired,
|
|
10246
|
-
name: PropTypes__default.default.string.isRequired,
|
|
10247
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
10248
|
-
secondary: PropTypes__default.default.string,
|
|
10249
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
10250
|
-
className: PropTypes__default.default.string
|
|
10251
|
-
};
|
|
10252
|
-
Radio.defaultProps = {
|
|
10253
|
-
avatar: undefined,
|
|
10254
|
-
checked: false,
|
|
10255
|
-
disabled: false,
|
|
10256
|
-
id: null,
|
|
10257
|
-
secondary: null,
|
|
10258
|
-
value: '',
|
|
10259
|
-
className: undefined
|
|
10260
|
-
};
|
|
10261
|
-
var Radio$1 = Radio;
|
|
10056
|
+
}
|
|
10262
10057
|
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
children: radios.map(({
|
|
10289
|
-
id,
|
|
10290
|
-
avatar,
|
|
10291
|
-
value,
|
|
10292
|
-
label,
|
|
10293
|
-
disabled,
|
|
10294
|
-
secondary,
|
|
10295
|
-
readOnly
|
|
10296
|
-
}, index) => /*#__PURE__*/jsxRuntime.jsx(Radio$1
|
|
10297
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
10298
|
-
, {
|
|
10299
|
-
id: id,
|
|
10300
|
-
value: value,
|
|
10301
|
-
label: label,
|
|
10302
|
-
name: name,
|
|
10303
|
-
disabled: disabled,
|
|
10304
|
-
checked: selectedValue === value,
|
|
10305
|
-
secondary: secondary,
|
|
10306
|
-
readOnly: readOnly,
|
|
10307
|
-
avatar: avatar,
|
|
10308
|
-
onChange: value_ => this.handleOnChange(value_)
|
|
10309
|
-
}, index))
|
|
10310
|
-
}) : null;
|
|
10311
|
-
}
|
|
10058
|
+
function RadioGroup({
|
|
10059
|
+
name,
|
|
10060
|
+
radios,
|
|
10061
|
+
selectedValue: controlledValue,
|
|
10062
|
+
onChange
|
|
10063
|
+
}) {
|
|
10064
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(controlledValue);
|
|
10065
|
+
return radios.length > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
10066
|
+
role: "radiogroup",
|
|
10067
|
+
children: radios.map(({
|
|
10068
|
+
value = '',
|
|
10069
|
+
...restProps
|
|
10070
|
+
}, index) => /*#__PURE__*/jsxRuntime.jsx(Radio
|
|
10071
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
10072
|
+
, {
|
|
10073
|
+
...restProps,
|
|
10074
|
+
name: name,
|
|
10075
|
+
value: value,
|
|
10076
|
+
checked: value === uncontrolledValue,
|
|
10077
|
+
onChange: nextValue => {
|
|
10078
|
+
setUncontrolledValue(nextValue);
|
|
10079
|
+
onChange(nextValue);
|
|
10080
|
+
}
|
|
10081
|
+
}, index))
|
|
10082
|
+
}) : null;
|
|
10312
10083
|
}
|
|
10313
|
-
RadioGroup.propTypes = {
|
|
10314
|
-
radios: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
10315
|
-
id: PropTypes__default.default.string,
|
|
10316
|
-
avatar: PropTypes__default.default.element,
|
|
10317
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
10318
|
-
secondary: PropTypes__default.default.string,
|
|
10319
|
-
label: PropTypes__default.default.string.isRequired,
|
|
10320
|
-
disabled: PropTypes__default.default.bool,
|
|
10321
|
-
readOnly: PropTypes__default.default.bool
|
|
10322
|
-
})).isRequired,
|
|
10323
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
10324
|
-
selectedValue: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
10325
|
-
name: PropTypes__default.default.string.isRequired
|
|
10326
|
-
};
|
|
10327
|
-
RadioGroup.defaultProps = {
|
|
10328
|
-
selectedValue: null
|
|
10329
|
-
};
|
|
10330
|
-
var RadioGroup$1 = RadioGroup;
|
|
10331
10084
|
|
|
10332
|
-
|
|
10085
|
+
function RadioOption({
|
|
10333
10086
|
'aria-label': ariaLabel,
|
|
10334
10087
|
media,
|
|
10335
10088
|
title,
|
|
@@ -10344,22 +10097,19 @@ const RadioOption = ({
|
|
|
10344
10097
|
showMediaCircle,
|
|
10345
10098
|
showMediaAtAllSizes,
|
|
10346
10099
|
isContainerAligned
|
|
10347
|
-
})
|
|
10348
|
-
const sharedProps = {
|
|
10349
|
-
'aria-label': ariaLabel,
|
|
10350
|
-
media,
|
|
10351
|
-
title,
|
|
10352
|
-
content,
|
|
10353
|
-
name,
|
|
10354
|
-
complex,
|
|
10355
|
-
disabled,
|
|
10356
|
-
showMediaCircle,
|
|
10357
|
-
showMediaAtAllSizes,
|
|
10358
|
-
isContainerAligned
|
|
10359
|
-
};
|
|
10100
|
+
}) {
|
|
10360
10101
|
return /*#__PURE__*/jsxRuntime.jsx(Option$2, {
|
|
10361
|
-
|
|
10362
|
-
|
|
10102
|
+
"aria-label": ariaLabel,
|
|
10103
|
+
media: media,
|
|
10104
|
+
title: title,
|
|
10105
|
+
content: content,
|
|
10106
|
+
name: name,
|
|
10107
|
+
complex: complex,
|
|
10108
|
+
disabled: disabled,
|
|
10109
|
+
showMediaCircle: showMediaCircle,
|
|
10110
|
+
showMediaAtAllSizes: showMediaAtAllSizes,
|
|
10111
|
+
isContainerAligned: isContainerAligned,
|
|
10112
|
+
button: /*#__PURE__*/jsxRuntime.jsx(RadioButton, {
|
|
10363
10113
|
id: id,
|
|
10364
10114
|
name: name,
|
|
10365
10115
|
checked: checked,
|
|
@@ -10368,36 +10118,7 @@ const RadioOption = ({
|
|
|
10368
10118
|
onChange: onChange
|
|
10369
10119
|
})
|
|
10370
10120
|
});
|
|
10371
|
-
}
|
|
10372
|
-
RadioOption.propTypes = {
|
|
10373
|
-
'aria-label': PropTypes__default.default.string,
|
|
10374
|
-
media: PropTypes__default.default.node,
|
|
10375
|
-
id: PropTypes__default.default.string.isRequired,
|
|
10376
|
-
name: PropTypes__default.default.string.isRequired,
|
|
10377
|
-
title: PropTypes__default.default.node.isRequired,
|
|
10378
|
-
content: PropTypes__default.default.node,
|
|
10379
|
-
checked: PropTypes__default.default.bool,
|
|
10380
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
10381
|
-
complex: PropTypes__default.default.bool,
|
|
10382
|
-
disabled: PropTypes__default.default.bool,
|
|
10383
|
-
value: PropTypes__default.default.string,
|
|
10384
|
-
showMediaCircle: PropTypes__default.default.bool,
|
|
10385
|
-
showMediaAtAllSizes: PropTypes__default.default.bool,
|
|
10386
|
-
isContainerAligned: PropTypes__default.default.bool
|
|
10387
|
-
};
|
|
10388
|
-
RadioOption.defaultProps = {
|
|
10389
|
-
'aria-label': undefined,
|
|
10390
|
-
media: null,
|
|
10391
|
-
content: null,
|
|
10392
|
-
checked: false,
|
|
10393
|
-
complex: false,
|
|
10394
|
-
disabled: false,
|
|
10395
|
-
showMediaCircle: true,
|
|
10396
|
-
showMediaAtAllSizes: false,
|
|
10397
|
-
isContainerAligned: false,
|
|
10398
|
-
value: ''
|
|
10399
|
-
};
|
|
10400
|
-
var RadioOption$1 = RadioOption;
|
|
10121
|
+
}
|
|
10401
10122
|
|
|
10402
10123
|
const Section = ({
|
|
10403
10124
|
children,
|
|
@@ -15483,9 +15204,9 @@ exports.CircularButton = CircularButton$1;
|
|
|
15483
15204
|
exports.CriticalCommsBanner = CriticalCommsBanner;
|
|
15484
15205
|
exports.DEFAULT_LANG = DEFAULT_LANG;
|
|
15485
15206
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
15486
|
-
exports.DateInput = DateInput
|
|
15207
|
+
exports.DateInput = DateInput;
|
|
15487
15208
|
exports.DateLookup = DateLookup$1;
|
|
15488
|
-
exports.Decision = Decision
|
|
15209
|
+
exports.Decision = Decision;
|
|
15489
15210
|
exports.DefinitionList = DefinitionList$1;
|
|
15490
15211
|
exports.Dimmer = Dimmer$1;
|
|
15491
15212
|
exports.DirectionProvider = DirectionProvider;
|
|
@@ -15526,9 +15247,9 @@ exports.PromoCard = PromoCard$1;
|
|
|
15526
15247
|
exports.PromoCardGroup = PromoCard$1;
|
|
15527
15248
|
exports.Provider = Provider$1;
|
|
15528
15249
|
exports.RTL_LANGUAGES = RTL_LANGUAGES;
|
|
15529
|
-
exports.Radio = Radio
|
|
15530
|
-
exports.RadioGroup = RadioGroup
|
|
15531
|
-
exports.RadioOption = RadioOption
|
|
15250
|
+
exports.Radio = Radio;
|
|
15251
|
+
exports.RadioGroup = RadioGroup;
|
|
15252
|
+
exports.RadioOption = RadioOption;
|
|
15532
15253
|
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
15533
15254
|
exports.SearchInput = SearchInput;
|
|
15534
15255
|
exports.Section = Section;
|