@transferwise/components 46.12.0 → 46.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.esm.js +193 -352
- package/build/index.esm.js.map +1 -1
- package/build/index.js +166 -325
- package/build/index.js.map +1 -1
- package/build/main.css +6 -82
- package/build/styles/decision/Decision.css +6 -82
- package/build/styles/main.css +6 -82
- package/build/types/body/Body.d.ts +1 -1
- package/build/types/common/commonProps.d.ts +1 -1
- package/build/types/common/commonProps.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/getDayNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getDayNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/getMonthNames.d.ts.map +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts +1 -1
- package/build/types/common/dateUtils/getMonthNames/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/index.d.ts +6 -6
- package/build/types/common/dateUtils/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts +1 -1
- package/build/types/common/dateUtils/isDateValid/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts +2 -2
- package/build/types/common/dateUtils/isDateValid/isDateValid.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts +1 -1
- package/build/types/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/index.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts +1 -1
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -1
- package/build/types/dateInput/DateInput.d.ts +30 -41
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateInput/DateInput.messages.d.ts +24 -33
- package/build/types/dateInput/DateInput.messages.d.ts.map +1 -1
- package/build/types/dateInput/index.d.ts +2 -2
- package/build/types/dateInput/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/convertToLocalMidnight.d.ts.map +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts +1 -1
- package/build/types/dateInput/utils/convertToLocalMidnight/index.d.ts.map +1 -1
- package/build/types/dateInput/utils/index.d.ts +1 -2
- package/build/types/dateInput/utils/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +1 -0
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/decision/Decision.d.ts +39 -52
- package/build/types/decision/Decision.d.ts.map +1 -1
- package/build/types/decision/index.d.ts +1 -2
- package/build/types/decision/index.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts +1 -1
- package/build/types/drawer/Drawer.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/modal/Modal.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +1 -0
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/promoCard/PromoCard.d.ts +1 -2
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts +1 -1
- package/package.json +1 -1
- package/src/common/commonProps.ts +1 -1
- package/src/common/dateUtils/getDayNames/getDayNames.spec.js +2 -2
- package/src/common/dateUtils/getDayNames/{getDayNames.js → getDayNames.ts} +5 -2
- package/src/common/dateUtils/getMonthNames/getMonthNames.spec.js +9 -8
- package/src/common/dateUtils/getMonthNames/{getMonthNames.js → getMonthNames.ts} +5 -3
- package/src/common/dateUtils/isDateValid/{isDateValid.spec.js → isDateValid.spec.ts} +1 -1
- package/src/common/dateUtils/isDateValid/isDateValid.ts +13 -0
- package/src/common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.spec.js +3 -7
- package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.js → isMonthAndYearFormat.ts} +1 -1
- package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.js → isWithinRange.spec.ts} +0 -10
- package/src/common/dateUtils/isWithinRange/{isWithinRange.js → isWithinRange.ts} +1 -1
- package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.js → moveToWithinRange.ts} +2 -2
- package/src/dateInput/DateInput.spec.js +7 -56
- package/src/dateInput/DateInput.story.tsx +11 -8
- package/src/dateInput/{DateInput.js → DateInput.tsx} +116 -123
- package/src/dateInput/index.ts +2 -0
- package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.js → convertToLocalMidnight.ts} +1 -1
- package/src/dateInput/utils/{index.js → index.ts} +0 -1
- package/src/dateLookup/DateLookup.js +12 -1
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +12 -1
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +1 -0
- package/src/decision/Decision.css +6 -82
- package/src/decision/Decision.less +3 -41
- package/src/decision/Decision.spec.js +56 -61
- package/src/decision/{Decision.story.js → Decision.story.tsx} +5 -5
- package/src/decision/Decision.tsx +133 -0
- package/src/decision/index.ts +1 -0
- package/src/drawer/Drawer.js +13 -2
- package/src/drawer/__snapshots__/Drawer.rtl.spec.js.snap +1 -0
- package/src/index.ts +2 -0
- package/src/main.css +6 -82
- package/src/modal/Modal.tsx +6 -3
- package/src/popover/Popover.js +7 -3
- package/src/popover/Popover.spec.js +16 -8
- package/src/popover/__snapshots__/Popover.spec.js.snap +0 -56
- package/src/promoCard/PromoCard.tsx +1 -2
- package/src/tile/Tile.js +1 -1
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts +0 -6
- package/build/types/dateInput/utils/explodeDate/explodeDate.d.ts.map +0 -1
- package/build/types/dateInput/utils/explodeDate/index.d.ts +0 -2
- package/build/types/dateInput/utils/explodeDate/index.d.ts.map +0 -1
- package/build/types/decision/decisionEnums.d.ts +0 -9
- package/build/types/decision/decisionEnums.d.ts.map +0 -1
- package/build/types/sizeSwapper/SizeSwapper.d.ts +0 -3
- package/build/types/sizeSwapper/SizeSwapper.d.ts.map +0 -1
- package/build/types/sizeSwapper/index.d.ts +0 -2
- package/build/types/sizeSwapper/index.d.ts.map +0 -1
- package/src/common/dateUtils/isDateValid/isDateValid.js +0 -6
- package/src/dateInput/index.js +0 -3
- package/src/dateInput/utils/explodeDate/explodeDate.js +0 -7
- package/src/dateInput/utils/explodeDate/explodeDate.spec.js +0 -11
- package/src/dateInput/utils/explodeDate/index.js +0 -1
- package/src/decision/Decision.js +0 -148
- package/src/decision/decisionEnums.ts +0 -11
- package/src/decision/index.js +0 -2
- package/src/sizeSwapper/SizeSwapper.js +0 -69
- package/src/sizeSwapper/SizeSwapper.spec.js +0 -100
- package/src/sizeSwapper/SizeSwapper.story.js +0 -34
- package/src/sizeSwapper/index.js +0 -1
- /package/src/common/dateUtils/getDayNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/getMonthNames/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isDateValid/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isMonthAndYearFormat/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/isWithinRange/{index.js → index.ts} +0 -0
- /package/src/common/dateUtils/moveToWithinRange/{index.js → index.ts} +0 -0
- /package/src/dateInput/{DateInput.messages.js → DateInput.messages.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.js → convertToLocalMidnight.spec.ts} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{index.js → index.ts} +0 -0
package/build/index.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');
|
|
@@ -1901,6 +1901,7 @@ const Drawer = ({
|
|
|
1901
1901
|
const {
|
|
1902
1902
|
isMobile
|
|
1903
1903
|
} = useLayout();
|
|
1904
|
+
const titleId = reactId.useId();
|
|
1904
1905
|
return /*#__PURE__*/jsxRuntime.jsx(Dimmer$1, {
|
|
1905
1906
|
open: open,
|
|
1906
1907
|
onClose: onClose,
|
|
@@ -1908,13 +1909,16 @@ const Drawer = ({
|
|
|
1908
1909
|
open: open,
|
|
1909
1910
|
position: isMobile ? exports.Position.BOTTOM : position,
|
|
1910
1911
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1911
|
-
className: classNames__default.default('np-drawer', className),
|
|
1912
1912
|
role: "dialog",
|
|
1913
|
+
"aria-modal": true,
|
|
1914
|
+
"aria-labelledby": headerTitle ? titleId : undefined,
|
|
1915
|
+
className: classNames__default.default('np-drawer', className),
|
|
1913
1916
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1914
1917
|
className: classNames__default.default('np-drawer-header', {
|
|
1915
1918
|
'np-drawer-header--withborder': headerTitle
|
|
1916
1919
|
}),
|
|
1917
1920
|
children: [headerTitle && /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
1921
|
+
id: titleId,
|
|
1918
1922
|
type: exports.Typography.TITLE_BODY,
|
|
1919
1923
|
children: headerTitle
|
|
1920
1924
|
}), /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
@@ -2775,15 +2779,15 @@ function getDayNames(locale, format = 'short') {
|
|
|
2775
2779
|
return days;
|
|
2776
2780
|
}
|
|
2777
2781
|
|
|
2778
|
-
function isWithinRange(date, min, max) {
|
|
2779
|
-
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
2782
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2783
2783
|
function moveToWithinRange(date, min, max) {
|
|
2784
2784
|
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
2785
2785
|
}
|
|
2786
2786
|
|
|
2787
|
+
function isWithinRange(date, min, max) {
|
|
2788
|
+
return !date || (!min || date >= min) && (!max || date <= max);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2787
2791
|
const getMonthNames = (locale, format = 'long') => {
|
|
2788
2792
|
const months = [];
|
|
2789
2793
|
const date = new Date(2018, 0, 1);
|
|
@@ -2797,9 +2801,17 @@ const getMonthNames = (locale, format = 'long') => {
|
|
|
2797
2801
|
return months;
|
|
2798
2802
|
};
|
|
2799
2803
|
|
|
2800
|
-
const isDateValid = date =>
|
|
2801
|
-
|
|
2802
|
-
|
|
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());
|
|
2803
2815
|
|
|
2804
2816
|
const isMonthAndYearFormat = dateString => validDateString(dateString) && dateString.split('-').length < 3;
|
|
2805
2817
|
|
|
@@ -2821,48 +2833,31 @@ var messages$9 = reactIntl.defineMessages({
|
|
|
2821
2833
|
}
|
|
2822
2834
|
});
|
|
2823
2835
|
|
|
2824
|
-
const explodeDate = date => {
|
|
2825
|
-
const year = date.getFullYear();
|
|
2826
|
-
const month = date.getMonth();
|
|
2827
|
-
const day = date.getDate();
|
|
2828
|
-
return {
|
|
2829
|
-
year,
|
|
2830
|
-
month,
|
|
2831
|
-
day
|
|
2832
|
-
};
|
|
2833
|
-
};
|
|
2834
|
-
|
|
2835
2836
|
const convertToLocalMidnight = date => {
|
|
2836
2837
|
const utcDate = new Date(date.split('T')[0]); // using YYYY-MM-DD creates UTC date
|
|
2837
|
-
|
|
2838
2838
|
return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
|
|
2839
2839
|
};
|
|
2840
2840
|
|
|
2841
2841
|
const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
|
|
2842
|
-
const INITIAL_DEFAULT_STATE = {
|
|
2843
|
-
year: null,
|
|
2844
|
-
month: null,
|
|
2845
|
-
day: null
|
|
2846
|
-
};
|
|
2847
2842
|
const DateInput = ({
|
|
2848
2843
|
'aria-labelledby': ariaLabelledBy,
|
|
2849
2844
|
'aria-label': ariaLabel,
|
|
2850
|
-
disabled,
|
|
2851
|
-
size,
|
|
2845
|
+
disabled = false,
|
|
2846
|
+
size = exports.Size.MEDIUM,
|
|
2852
2847
|
value,
|
|
2853
2848
|
dayLabel,
|
|
2854
2849
|
dayAutoComplete,
|
|
2855
2850
|
monthLabel,
|
|
2856
2851
|
yearLabel,
|
|
2857
2852
|
yearAutoComplete,
|
|
2858
|
-
monthFormat,
|
|
2859
|
-
mode,
|
|
2853
|
+
monthFormat = exports.MonthFormat.LONG,
|
|
2854
|
+
mode = exports.DateMode.DAY_MONTH_YEAR,
|
|
2860
2855
|
onChange,
|
|
2861
2856
|
onFocus,
|
|
2862
2857
|
onBlur,
|
|
2863
2858
|
placeholders,
|
|
2864
2859
|
id,
|
|
2865
|
-
selectProps
|
|
2860
|
+
selectProps = {}
|
|
2866
2861
|
}) => {
|
|
2867
2862
|
const {
|
|
2868
2863
|
locale,
|
|
@@ -2872,23 +2867,34 @@ const DateInput = ({
|
|
|
2872
2867
|
if (value && isDateValid(value)) {
|
|
2873
2868
|
return typeof value === 'string' ? convertToLocalMidnight(value) : value;
|
|
2874
2869
|
}
|
|
2875
|
-
return
|
|
2870
|
+
return undefined;
|
|
2876
2871
|
};
|
|
2877
|
-
const
|
|
2878
|
-
let explodedDate = INITIAL_DEFAULT_STATE;
|
|
2872
|
+
const getInitialDate = unit => {
|
|
2879
2873
|
if (value && isDateValid(value)) {
|
|
2880
2874
|
const dateObject = getDateObject();
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
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
|
+
}
|
|
2884
2889
|
}
|
|
2885
2890
|
}
|
|
2886
|
-
return
|
|
2891
|
+
return null;
|
|
2887
2892
|
};
|
|
2888
|
-
const [day, setDay] = React.useState(() =>
|
|
2889
|
-
const [month, setMonth] = React.useState(() =>
|
|
2890
|
-
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'));
|
|
2891
2896
|
const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
|
|
2897
|
+
const monthNames = getMonthNames(locale, monthFormat);
|
|
2892
2898
|
dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
|
|
2893
2899
|
monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
|
|
2894
2900
|
yearLabel = yearLabel || formatMessage(messages$9.yearLabel);
|
|
@@ -2910,7 +2916,6 @@ const DateInput = ({
|
|
|
2910
2916
|
}
|
|
2911
2917
|
};
|
|
2912
2918
|
const getSelectElement = () => {
|
|
2913
|
-
const monthOptions = getMonthsOptions();
|
|
2914
2919
|
return /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
2915
2920
|
className: "d-flex flex-column",
|
|
2916
2921
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -2919,70 +2924,60 @@ const DateInput = ({
|
|
|
2919
2924
|
}), /*#__PURE__*/jsxRuntime.jsx(SelectInput, {
|
|
2920
2925
|
name: "month",
|
|
2921
2926
|
disabled: disabled,
|
|
2922
|
-
placeholder: placeholders
|
|
2923
|
-
items:
|
|
2927
|
+
placeholder: placeholders?.month,
|
|
2928
|
+
items: Array.from({
|
|
2929
|
+
length: 12
|
|
2930
|
+
}, (_, index) => ({
|
|
2931
|
+
type: 'option',
|
|
2932
|
+
value: index
|
|
2933
|
+
})),
|
|
2924
2934
|
size: size,
|
|
2925
|
-
value:
|
|
2926
|
-
renderValue: ({
|
|
2927
|
-
|
|
2928
|
-
}) => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent, {
|
|
2929
|
-
title: label
|
|
2935
|
+
value: month,
|
|
2936
|
+
renderValue: selectedValue => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent, {
|
|
2937
|
+
title: monthNames[selectedValue]
|
|
2930
2938
|
}),
|
|
2931
2939
|
onChange: selectedValue => handleMonthChange(selectedValue),
|
|
2932
2940
|
...selectProps
|
|
2933
2941
|
})]
|
|
2934
2942
|
});
|
|
2935
2943
|
};
|
|
2936
|
-
const getMonthsOptions = () => {
|
|
2937
|
-
const options = [];
|
|
2938
|
-
const months = getMonthNames(locale, monthFormat);
|
|
2939
|
-
months.forEach((label, index) => {
|
|
2940
|
-
options.push({
|
|
2941
|
-
type: 'option',
|
|
2942
|
-
value: {
|
|
2943
|
-
label,
|
|
2944
|
-
value: index
|
|
2945
|
-
}
|
|
2946
|
-
});
|
|
2947
|
-
});
|
|
2948
|
-
return options;
|
|
2949
|
-
};
|
|
2950
2944
|
const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
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;
|
|
2955
2953
|
}
|
|
2956
2954
|
if (mode === exports.DateMode.MONTH_YEAR) {
|
|
2957
|
-
if (newMonth
|
|
2958
|
-
broadcastNewValue(
|
|
2955
|
+
if (newMonth !== month || newYear !== year) {
|
|
2956
|
+
broadcastNewValue(dateValue);
|
|
2959
2957
|
}
|
|
2960
|
-
} else if (newDay
|
|
2961
|
-
broadcastNewValue(
|
|
2958
|
+
} else if (newDay !== day || newMonth !== month || newYear !== year) {
|
|
2959
|
+
broadcastNewValue(dateValue);
|
|
2962
2960
|
}
|
|
2963
2961
|
};
|
|
2964
2962
|
const handleDayChange = event => {
|
|
2965
2963
|
const {
|
|
2966
2964
|
checkedDay
|
|
2967
|
-
} = checkDate(event.target.value, month, year);
|
|
2965
|
+
} = checkDate(Number.parseInt(event.target.value, 10), month, year);
|
|
2968
2966
|
setDay(checkedDay);
|
|
2969
2967
|
handleInternalValue(checkedDay, month, year);
|
|
2970
2968
|
};
|
|
2971
|
-
const handleMonthChange =
|
|
2972
|
-
if (
|
|
2969
|
+
const handleMonthChange = selectedMonth => {
|
|
2970
|
+
if (selectedMonth === null) {
|
|
2973
2971
|
setMonth(null);
|
|
2974
2972
|
handleInternalValue(day, null, year);
|
|
2975
2973
|
return;
|
|
2976
2974
|
}
|
|
2977
|
-
const selectedMonth = selectedValue ? selectedValue.value : 0;
|
|
2978
2975
|
const {
|
|
2979
2976
|
checkedDay
|
|
2980
2977
|
} = checkDate(day, selectedMonth, year);
|
|
2981
2978
|
setMonth(selectedMonth);
|
|
2982
|
-
if (day) {
|
|
2983
|
-
|
|
2984
|
-
setDay(checkedDay);
|
|
2985
|
-
}
|
|
2979
|
+
if (day && checkedDay !== day) {
|
|
2980
|
+
setDay(checkedDay);
|
|
2986
2981
|
}
|
|
2987
2982
|
handleInternalValue(checkedDay, selectedMonth, year);
|
|
2988
2983
|
};
|
|
@@ -2993,35 +2988,33 @@ const DateInput = ({
|
|
|
2993
2988
|
// Correct day based on year and month.
|
|
2994
2989
|
const {
|
|
2995
2990
|
checkedDay
|
|
2996
|
-
} = checkDate(day, month, newValue);
|
|
2997
|
-
if (day) {
|
|
2998
|
-
|
|
2999
|
-
setDay(checkedDay);
|
|
3000
|
-
}
|
|
2991
|
+
} = checkDate(day, month, Number.parseInt(newValue, 10));
|
|
2992
|
+
if (day && checkedDay !== day) {
|
|
2993
|
+
setDay(checkedDay);
|
|
3001
2994
|
}
|
|
3002
|
-
setYear(slicedYear);
|
|
3003
|
-
handleInternalValue(checkedDay, month, slicedYear);
|
|
2995
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
2996
|
+
handleInternalValue(checkedDay, month, Number.parseInt(slicedYear, 10));
|
|
3004
2997
|
} else {
|
|
3005
|
-
setYear(slicedYear);
|
|
2998
|
+
setYear(Number.parseInt(slicedYear, 10));
|
|
3006
2999
|
handleInternalValue(day, month, null);
|
|
3007
3000
|
}
|
|
3008
3001
|
};
|
|
3009
3002
|
const broadcastNewValue = newValue => {
|
|
3010
3003
|
if (newValue !== lastBroadcastedValue) {
|
|
3011
3004
|
setLastBroadcastedValue(newValue);
|
|
3012
|
-
onChange(getDateAsString(newValue)
|
|
3005
|
+
onChange(newValue != null ? getDateAsString(newValue) : null);
|
|
3013
3006
|
}
|
|
3014
3007
|
};
|
|
3015
3008
|
const checkDate = (newDay = null, newMonth = 0, newYear = null) => {
|
|
3016
3009
|
let checkedDay = newDay;
|
|
3017
|
-
const maxDay = new Date(newYear || 2000, newMonth + 1, 0).getDate();
|
|
3010
|
+
const maxDay = new Date(newYear || 2000, newMonth != null ? newMonth + 1 : 1, 0).getDate();
|
|
3018
3011
|
if (!newDay) {
|
|
3019
3012
|
checkedDay = null;
|
|
3020
3013
|
}
|
|
3021
|
-
if (newDay && newDay < 0
|
|
3014
|
+
if (newDay && newDay < 0) {
|
|
3022
3015
|
checkedDay = 1;
|
|
3023
3016
|
}
|
|
3024
|
-
if (newDay && newMonth || newDay > 31) {
|
|
3017
|
+
if (newDay && newMonth || newDay && newDay > 31) {
|
|
3025
3018
|
checkedDay = newDay > maxDay ? maxDay : newDay;
|
|
3026
3019
|
}
|
|
3027
3020
|
return {
|
|
@@ -3041,8 +3034,10 @@ const DateInput = ({
|
|
|
3041
3034
|
id: id,
|
|
3042
3035
|
"aria-labelledby": ariaLabelledBy,
|
|
3043
3036
|
"aria-label": ariaLabel,
|
|
3044
|
-
|
|
3045
|
-
|
|
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(),
|
|
3046
3041
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3047
3042
|
className: "row",
|
|
3048
3043
|
children: [monthBeforeDay && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -3095,7 +3090,6 @@ const DateInput = ({
|
|
|
3095
3090
|
})
|
|
3096
3091
|
});
|
|
3097
3092
|
};
|
|
3098
|
-
|
|
3099
3093
|
// Should only propagate if the relatedTarget is not part of this DateInput component.
|
|
3100
3094
|
function shouldPropagateOnFocus({
|
|
3101
3095
|
target,
|
|
@@ -3105,7 +3099,6 @@ function shouldPropagateOnFocus({
|
|
|
3105
3099
|
const relatedParent = relatedTarget && relatedTarget.closest('.tw-date');
|
|
3106
3100
|
return targetParent !== relatedParent;
|
|
3107
3101
|
}
|
|
3108
|
-
|
|
3109
3102
|
// Should only propagate if the relatedTarget or the activeElement is not part of this DateInput component.
|
|
3110
3103
|
function shouldPropagateOnBlur({
|
|
3111
3104
|
target,
|
|
@@ -3122,42 +3115,6 @@ function shouldPropagateOnBlur({
|
|
|
3122
3115
|
const focusElementParent = focusElement && focusElement.closest('.tw-date');
|
|
3123
3116
|
return blurElementParent !== focusElementParent;
|
|
3124
3117
|
}
|
|
3125
|
-
DateInput.propTypes = {
|
|
3126
|
-
'aria-label': PropTypes__default.default.string,
|
|
3127
|
-
'aria-labelledby': PropTypes__default.default.string,
|
|
3128
|
-
disabled: PropTypes__default.default.bool,
|
|
3129
|
-
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
3130
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.instanceOf(Date)]),
|
|
3131
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
3132
|
-
onFocus: PropTypes__default.default.func,
|
|
3133
|
-
onBlur: PropTypes__default.default.func,
|
|
3134
|
-
dayLabel: PropTypes__default.default.string,
|
|
3135
|
-
dayAutoComplete: PropTypes__default.default.string,
|
|
3136
|
-
monthLabel: PropTypes__default.default.string,
|
|
3137
|
-
yearLabel: PropTypes__default.default.string,
|
|
3138
|
-
yearAutoComplete: PropTypes__default.default.string,
|
|
3139
|
-
monthFormat: PropTypes__default.default.oneOf(['long', 'short']),
|
|
3140
|
-
mode: PropTypes__default.default.oneOf(['day-month-year', 'month-year']),
|
|
3141
|
-
placeholders: PropTypes__default.default.shape({
|
|
3142
|
-
day: PropTypes__default.default.node,
|
|
3143
|
-
month: PropTypes__default.default.node,
|
|
3144
|
-
year: PropTypes__default.default.node
|
|
3145
|
-
}),
|
|
3146
|
-
id: PropTypes__default.default.string,
|
|
3147
|
-
selectProps: PropTypes__default.default.object
|
|
3148
|
-
};
|
|
3149
|
-
DateInput.defaultProps = {
|
|
3150
|
-
disabled: false,
|
|
3151
|
-
size: exports.Size.MEDIUM,
|
|
3152
|
-
value: null,
|
|
3153
|
-
onFocus: null,
|
|
3154
|
-
onBlur: null,
|
|
3155
|
-
monthFormat: exports.MonthFormat.LONG,
|
|
3156
|
-
mode: exports.DateMode.DAY_MONTH_YEAR,
|
|
3157
|
-
id: '',
|
|
3158
|
-
selectProps: {}
|
|
3159
|
-
};
|
|
3160
|
-
var DateInput$1 = DateInput;
|
|
3161
3118
|
|
|
3162
3119
|
const POPOVER_OFFSET = [0, 16];
|
|
3163
3120
|
// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space
|
|
@@ -4343,6 +4300,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4343
4300
|
size,
|
|
4344
4301
|
placeholder,
|
|
4345
4302
|
label,
|
|
4303
|
+
'aria-labelledby': ariaLabelledBy,
|
|
4346
4304
|
monthFormat,
|
|
4347
4305
|
disabled,
|
|
4348
4306
|
clearable,
|
|
@@ -4351,6 +4309,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4351
4309
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4352
4310
|
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4353
4311
|
ref: this.element,
|
|
4312
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4354
4313
|
className: "input-group",
|
|
4355
4314
|
onKeyDown: this.handleKeyDown,
|
|
4356
4315
|
children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger$1, {
|
|
@@ -4380,6 +4339,7 @@ DateLookup.propTypes = {
|
|
|
4380
4339
|
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
4381
4340
|
placeholder: PropTypes__default.default.string,
|
|
4382
4341
|
label: PropTypes__default.default.string,
|
|
4342
|
+
'aria-labelledby': PropTypes__default.default.string,
|
|
4383
4343
|
monthFormat: PropTypes__default.default.oneOf(['long', 'short']),
|
|
4384
4344
|
disabled: PropTypes__default.default.bool,
|
|
4385
4345
|
onChange: PropTypes__default.default.func.isRequired,
|
|
@@ -4402,19 +4362,6 @@ DateLookup.defaultProps = {
|
|
|
4402
4362
|
};
|
|
4403
4363
|
var DateLookup$1 = DateLookup;
|
|
4404
4364
|
|
|
4405
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4406
|
-
exports.DecisionPresentation = void 0;
|
|
4407
|
-
(function (Presentation) {
|
|
4408
|
-
Presentation["LIST"] = "LIST";
|
|
4409
|
-
Presentation["LIST_BLOCK"] = "LIST_BLOCK";
|
|
4410
|
-
Presentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
|
|
4411
|
-
})(exports.DecisionPresentation || (exports.DecisionPresentation = {}));
|
|
4412
|
-
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
4413
|
-
exports.DecisionType = void 0;
|
|
4414
|
-
(function (Type) {
|
|
4415
|
-
Type["NAVIGATION"] = "NAVIGATION";
|
|
4416
|
-
})(exports.DecisionType || (exports.DecisionType = {}));
|
|
4417
|
-
|
|
4418
4365
|
const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
4419
4366
|
as: component = 'button',
|
|
4420
4367
|
disabled = false,
|
|
@@ -4448,70 +4395,6 @@ const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
|
4448
4395
|
});
|
|
4449
4396
|
});
|
|
4450
4397
|
|
|
4451
|
-
const Layout = {
|
|
4452
|
-
COLUMN: 'COLUMN'
|
|
4453
|
-
};
|
|
4454
|
-
const SizeSwapper = /*#__PURE__*/React.forwardRef(({
|
|
4455
|
-
items,
|
|
4456
|
-
inline
|
|
4457
|
-
}, reference) => {
|
|
4458
|
-
const parentReference = React.useRef(null);
|
|
4459
|
-
const [clientWidth] = useClientWidth({
|
|
4460
|
-
ref: reference || parentReference
|
|
4461
|
-
});
|
|
4462
|
-
if (!items || items.length === 0) {
|
|
4463
|
-
return null;
|
|
4464
|
-
}
|
|
4465
|
-
// If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
|
|
4466
|
-
// Do not use deconstruct here to get items and layout.
|
|
4467
|
-
let itemsToRender = [];
|
|
4468
|
-
if (clientWidth) {
|
|
4469
|
-
itemsToRender = items.filter(({
|
|
4470
|
-
breakpoint = 0
|
|
4471
|
-
}) => clientWidth >= breakpoint).pop();
|
|
4472
|
-
} else {
|
|
4473
|
-
// On SSR environments useClientWidth returns null because ref is undefined so we render
|
|
4474
|
-
// all elements by default.
|
|
4475
|
-
// If there's no SSR and on first Hydration only the right elements are going to be rendered.
|
|
4476
|
-
// If clientWidth is null or zero all elements render like a responsive technique would do.
|
|
4477
|
-
itemsToRender.items = items.map(({
|
|
4478
|
-
items
|
|
4479
|
-
}) => Object.values(items));
|
|
4480
|
-
}
|
|
4481
|
-
|
|
4482
|
-
// Always return parent container even if there are no items to display to
|
|
4483
|
-
// keep the ref on DOM and let clientWidth be calculated properly.
|
|
4484
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4485
|
-
ref: parentReference,
|
|
4486
|
-
className: classNames__default.default('np-size-swapper', {
|
|
4487
|
-
'd-flex': !inline,
|
|
4488
|
-
'd-inline-flex': inline,
|
|
4489
|
-
'flex-column': itemsToRender && itemsToRender.layout === Layout.COLUMN,
|
|
4490
|
-
'flex-wrap': itemsToRender && itemsToRender.wrap
|
|
4491
|
-
}),
|
|
4492
|
-
style: {
|
|
4493
|
-
visibility: clientWidth ? 'visible' : 'hidden'
|
|
4494
|
-
},
|
|
4495
|
-
children: itemsToRender && itemsToRender.items
|
|
4496
|
-
});
|
|
4497
|
-
});
|
|
4498
|
-
SizeSwapper.Breakpoint = exports.Breakpoint;
|
|
4499
|
-
SizeSwapper.Layout = Layout;
|
|
4500
|
-
SizeSwapper.propTypes = {
|
|
4501
|
-
inline: PropTypes__default.default.bool,
|
|
4502
|
-
/** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */
|
|
4503
|
-
items: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4504
|
-
items: PropTypes__default.default.arrayOf(PropTypes__default.default.element),
|
|
4505
|
-
breakpoint: PropTypes__default.default.number,
|
|
4506
|
-
layout: PropTypes__default.default.oneOf([SizeSwapper.Layout.COLUMN]),
|
|
4507
|
-
wrap: PropTypes__default.default.bool
|
|
4508
|
-
})).isRequired
|
|
4509
|
-
};
|
|
4510
|
-
SizeSwapper.defaultProps = {
|
|
4511
|
-
inline: false
|
|
4512
|
-
};
|
|
4513
|
-
var SizeSwapper$1 = SizeSwapper;
|
|
4514
|
-
|
|
4515
4398
|
const Tile = ({
|
|
4516
4399
|
className,
|
|
4517
4400
|
description,
|
|
@@ -4560,7 +4443,7 @@ Tile.propTypes = {
|
|
|
4560
4443
|
className: PropTypes__default.default.string,
|
|
4561
4444
|
description: PropTypes__default.default.node,
|
|
4562
4445
|
disabled: PropTypes__default.default.bool,
|
|
4563
|
-
href: PropTypes__default.default.string
|
|
4446
|
+
href: PropTypes__default.default.string,
|
|
4564
4447
|
target: PropTypes__default.default.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4565
4448
|
/** Accepts only Avatar and images */
|
|
4566
4449
|
media: PropTypes__default.default.node.isRequired,
|
|
@@ -4579,85 +4462,28 @@ Tile.defaultProps = {
|
|
|
4579
4462
|
};
|
|
4580
4463
|
var Tile$1 = Tile;
|
|
4581
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 = {}));
|
|
4582
4475
|
const Decision = ({
|
|
4583
4476
|
options,
|
|
4584
|
-
presentation,
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4477
|
+
presentation = exports.DecisionPresentation.LIST,
|
|
4478
|
+
size = exports.Size.MEDIUM,
|
|
4479
|
+
type = exports.DecisionType.NAVIGATION,
|
|
4480
|
+
showMediaCircleInList = true,
|
|
4481
|
+
isContainerAligned = false
|
|
4589
4482
|
}) => {
|
|
4483
|
+
const screenXs = useScreenSize(exports.Breakpoint.EXTRA_SMALL);
|
|
4484
|
+
const screenSm = useScreenSize(exports.Breakpoint.SMALL);
|
|
4590
4485
|
if (type === exports.DecisionType.NAVIGATION) {
|
|
4591
|
-
const {
|
|
4592
|
-
LIST_BLOCK,
|
|
4593
|
-
LIST_BLOCK_GRID
|
|
4594
|
-
} = exports.DecisionPresentation;
|
|
4595
|
-
if (presentation === LIST_BLOCK || presentation === LIST_BLOCK_GRID) {
|
|
4596
|
-
const isSmall = size === exports.Size.SMALL;
|
|
4597
|
-
const isGrid = presentation === LIST_BLOCK_GRID;
|
|
4598
|
-
const items = [{
|
|
4599
|
-
items: [],
|
|
4600
|
-
layout: SizeSwapper$1.Layout.COLUMN
|
|
4601
|
-
}, {
|
|
4602
|
-
items: [],
|
|
4603
|
-
breakpoint: isSmall ? exports.Breakpoint.EXTRA_SMALL : exports.Breakpoint.SMALL,
|
|
4604
|
-
wrap: isGrid
|
|
4605
|
-
}];
|
|
4606
|
-
options.forEach(({
|
|
4607
|
-
description,
|
|
4608
|
-
disabled,
|
|
4609
|
-
href,
|
|
4610
|
-
target,
|
|
4611
|
-
media: {
|
|
4612
|
-
block,
|
|
4613
|
-
list
|
|
4614
|
-
},
|
|
4615
|
-
onClick,
|
|
4616
|
-
title
|
|
4617
|
-
}, key) => {
|
|
4618
|
-
items[0].items.push( /*#__PURE__*/jsxRuntime.jsx(NavigationOption
|
|
4619
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4620
|
-
, {
|
|
4621
|
-
complex: false,
|
|
4622
|
-
content: description,
|
|
4623
|
-
disabled: disabled,
|
|
4624
|
-
href: href,
|
|
4625
|
-
target: target,
|
|
4626
|
-
media: list,
|
|
4627
|
-
showMediaAtAllSizes: true,
|
|
4628
|
-
showMediaCircle: showMediaCircleInList,
|
|
4629
|
-
isContainerAligned: isContainerAligned,
|
|
4630
|
-
title: title,
|
|
4631
|
-
onClick: onClick
|
|
4632
|
-
}, `nav-${key}`));
|
|
4633
|
-
items[1].items.push( /*#__PURE__*/jsxRuntime.jsx(Tile$1
|
|
4634
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
4635
|
-
, {
|
|
4636
|
-
className: classNames__default.default(`np-decision__tile${isSmall ? '--small' : ''}`, {
|
|
4637
|
-
'np-decision__tile--fixed-width': isGrid
|
|
4638
|
-
}),
|
|
4639
|
-
description: description,
|
|
4640
|
-
disabled: disabled,
|
|
4641
|
-
href: href,
|
|
4642
|
-
target: target,
|
|
4643
|
-
media: block,
|
|
4644
|
-
size: isSmall ? exports.Size.SMALL : exports.Size.MEDIUM,
|
|
4645
|
-
title: title,
|
|
4646
|
-
onClick: onClick
|
|
4647
|
-
}, `tile-${key}`));
|
|
4648
|
-
});
|
|
4649
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4650
|
-
className: classNames__default.default('np-decision', {
|
|
4651
|
-
'np-decision--small': isSmall,
|
|
4652
|
-
'np-decision--grid': isGrid
|
|
4653
|
-
}),
|
|
4654
|
-
children: /*#__PURE__*/jsxRuntime.jsx(SizeSwapper$1, {
|
|
4655
|
-
items: items
|
|
4656
|
-
})
|
|
4657
|
-
});
|
|
4658
|
-
}
|
|
4659
|
-
// LIST
|
|
4660
|
-
return options.map(({
|
|
4486
|
+
const renderedOptions = options.map(({
|
|
4661
4487
|
title,
|
|
4662
4488
|
description,
|
|
4663
4489
|
disabled,
|
|
@@ -4682,42 +4508,49 @@ const Decision = ({
|
|
|
4682
4508
|
title: title,
|
|
4683
4509
|
onClick: onClick
|
|
4684
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
|
+
});
|
|
4685
4551
|
}
|
|
4686
|
-
return
|
|
4687
|
-
};
|
|
4688
|
-
Decision.propTypes = {
|
|
4689
|
-
/** A list of elements to be rendered */
|
|
4690
|
-
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4691
|
-
description: PropTypes__default.default.node,
|
|
4692
|
-
disabled: PropTypes__default.default.bool,
|
|
4693
|
-
href: PropTypes__default.default.string,
|
|
4694
|
-
target: PropTypes__default.default.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
4695
|
-
media: PropTypes__default.default.shape({
|
|
4696
|
-
block: PropTypes__default.default.node.isRequired,
|
|
4697
|
-
list: PropTypes__default.default.node.isRequired
|
|
4698
|
-
}),
|
|
4699
|
-
onClick: PropTypes__default.default.func,
|
|
4700
|
-
title: PropTypes__default.default.node.isRequired
|
|
4701
|
-
})).isRequired,
|
|
4702
|
-
/** Handles the display mode of the component */
|
|
4703
|
-
presentation: PropTypes__default.default.oneOf(['LIST', 'LIST_BLOCK', 'LIST_BLOCK_GRID']),
|
|
4704
|
-
/** Size currently affects only Tile dimension */
|
|
4705
|
-
size: PropTypes__default.default.oneOf(['sm', 'md']),
|
|
4706
|
-
/** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
|
|
4707
|
-
type: PropTypes__default.default.oneOf(['NAVIGATION']),
|
|
4708
|
-
/** Display media in a circle in list presentation */
|
|
4709
|
-
showMediaCircleInList: PropTypes__default.default.bool,
|
|
4710
|
-
/** Sets navigation options to be aligned with the parent container */
|
|
4711
|
-
isContainerAligned: PropTypes__default.default.bool
|
|
4712
|
-
};
|
|
4713
|
-
Decision.defaultProps = {
|
|
4714
|
-
presentation: exports.DecisionPresentation.LIST,
|
|
4715
|
-
size: exports.Size.MEDIUM,
|
|
4716
|
-
type: exports.DecisionType.NAVIGATION,
|
|
4717
|
-
showMediaCircleInList: true,
|
|
4718
|
-
isContainerAligned: false
|
|
4552
|
+
return null;
|
|
4719
4553
|
};
|
|
4720
|
-
var Decision$1 = Decision;
|
|
4721
4554
|
|
|
4722
4555
|
const isLayoutHorizontal = layout => [exports.Layout.HORIZONTAL_LEFT_ALIGNED, exports.Layout.HORIZONTAL_RIGHT_ALIGNED, exports.Layout.HORIZONTAL_JUSTIFIED].includes(layout);
|
|
4723
4556
|
const getAlignmentClasses = (layout, action) => {
|
|
@@ -5956,6 +5789,7 @@ const Modal = ({
|
|
|
5956
5789
|
const isCompact = checkSpecialClasses('compact');
|
|
5957
5790
|
const noDivider = checkSpecialClasses('no-divider');
|
|
5958
5791
|
const contentReference = React.useRef(null);
|
|
5792
|
+
const titleId = reactId.useId();
|
|
5959
5793
|
return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
|
|
5960
5794
|
open: open,
|
|
5961
5795
|
headerTitle: title,
|
|
@@ -5983,11 +5817,12 @@ const Modal = ({
|
|
|
5983
5817
|
className: classNames__default.default('tw-modal', 'd-flex', 'fade', 'outline-none', scroll === exports.Scroll.CONTENT && 'tw-modal--scrollable', className),
|
|
5984
5818
|
...otherProps,
|
|
5985
5819
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5820
|
+
role: "dialog",
|
|
5821
|
+
"aria-modal": true,
|
|
5822
|
+
"aria-labelledby": titleId,
|
|
5986
5823
|
className: classNames__default.default('tw-modal-dialog', 'd-flex', {
|
|
5987
5824
|
[`tw-modal-${size}`]: size
|
|
5988
5825
|
}),
|
|
5989
|
-
"aria-modal": true,
|
|
5990
|
-
role: "dialog",
|
|
5991
5826
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5992
5827
|
className: classNames__default.default('tw-modal-content', 'd-flex', 'flex-column', 'justify-content-between', {
|
|
5993
5828
|
'tw-modal-compact': isCompact,
|
|
@@ -5998,6 +5833,7 @@ const Modal = ({
|
|
|
5998
5833
|
'modal--withoutborder': !title || noDivider
|
|
5999
5834
|
}),
|
|
6000
5835
|
children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
5836
|
+
id: titleId,
|
|
6001
5837
|
type: exports.Typography.TITLE_BODY,
|
|
6002
5838
|
className: "tw-modal-title",
|
|
6003
5839
|
children: title
|
|
@@ -6027,7 +5863,8 @@ const Popover$1 = ({
|
|
|
6027
5863
|
className,
|
|
6028
5864
|
content,
|
|
6029
5865
|
preferredPlacement,
|
|
6030
|
-
title
|
|
5866
|
+
title,
|
|
5867
|
+
onClose
|
|
6031
5868
|
}) => {
|
|
6032
5869
|
logActionRequired({
|
|
6033
5870
|
preferredPlacement
|
|
@@ -6037,7 +5874,10 @@ const Popover$1 = ({
|
|
|
6037
5874
|
const {
|
|
6038
5875
|
isModern
|
|
6039
5876
|
} = componentsTheming.useTheme();
|
|
6040
|
-
const
|
|
5877
|
+
const handleOnClose = () => {
|
|
5878
|
+
setOpen(false);
|
|
5879
|
+
onClose?.();
|
|
5880
|
+
};
|
|
6041
5881
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
6042
5882
|
className: classNames__default.default('np-popover', className),
|
|
6043
5883
|
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -6057,7 +5897,7 @@ const Popover$1 = ({
|
|
|
6057
5897
|
position: deprecatedPlacements[preferredPlacement] || preferredPlacement,
|
|
6058
5898
|
arrow: true,
|
|
6059
5899
|
className: "np-popover__container",
|
|
6060
|
-
onClose:
|
|
5900
|
+
onClose: handleOnClose,
|
|
6061
5901
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
6062
5902
|
className: isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content',
|
|
6063
5903
|
"aria-hidden": !open,
|
|
@@ -6090,6 +5930,7 @@ Popover$1.propTypes = {
|
|
|
6090
5930
|
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
6091
5931
|
*/
|
|
6092
5932
|
preferredPlacement: PropTypes__default.default.oneOf(['top', 'right', 'bottom', 'left', 'left-top', 'right-top', 'bottom-right', 'bottom-left']),
|
|
5933
|
+
onClose: PropTypes__default.default.func,
|
|
6093
5934
|
title: PropTypes__default.default.node
|
|
6094
5935
|
};
|
|
6095
5936
|
const deprecatedPlacements = {
|
|
@@ -15471,9 +15312,9 @@ exports.CircularButton = CircularButton$1;
|
|
|
15471
15312
|
exports.CriticalCommsBanner = CriticalCommsBanner;
|
|
15472
15313
|
exports.DEFAULT_LANG = DEFAULT_LANG;
|
|
15473
15314
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
15474
|
-
exports.DateInput = DateInput
|
|
15315
|
+
exports.DateInput = DateInput;
|
|
15475
15316
|
exports.DateLookup = DateLookup$1;
|
|
15476
|
-
exports.Decision = Decision
|
|
15317
|
+
exports.Decision = Decision;
|
|
15477
15318
|
exports.DefinitionList = DefinitionList$1;
|
|
15478
15319
|
exports.Dimmer = Dimmer$1;
|
|
15479
15320
|
exports.DirectionProvider = DirectionProvider;
|