@transferwise/components 46.27.0 → 46.29.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/i18n/th.json +2 -2
- package/build/index.js +344 -1147
- package/build/index.js.map +1 -1
- package/build/index.mjs +346 -1147
- package/build/index.mjs.map +1 -1
- package/build/main.css +16 -5
- package/build/styles/logo/Logo.css +16 -0
- package/build/styles/main.css +16 -5
- package/build/types/alert/Alert.d.ts +47 -58
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/alert/index.d.ts +2 -1
- package/build/types/alert/index.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +7 -9
- package/build/types/button/Button.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/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +0 -1
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +75 -28
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +42 -63
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +9 -22
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +13 -31
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +19 -2
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +12 -2
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
- package/build/types/dateLookup/index.d.ts +2 -1
- package/build/types/dateLookup/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +17 -2
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +15 -2
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +10 -26
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inlineAlert/InlineAlert.d.ts +2 -4
- package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts +2 -2
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/stepper/deviceDetection.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/alert/{Alert.spec.js → Alert.spec.tsx} +43 -40
- package/src/alert/Alert.story.tsx +1 -2
- package/src/alert/Alert.tsx +219 -0
- package/src/alert/index.ts +2 -0
- package/src/avatar/colors/colors.ts +1 -1
- package/src/body/Body.spec.tsx +1 -1
- package/src/body/Body.story.tsx +8 -8
- package/src/button/Button.tsx +6 -10
- package/src/checkbox/Checkbox.js +1 -1
- package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
- package/src/common/Option/Option.tsx +1 -1
- package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +21 -0
- package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
- package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +8 -4
- package/src/common/deviceDetection/deviceDetection.js +1 -1
- package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
- package/src/common/propsValues/sentiment.ts +0 -10
- package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
- package/src/dateLookup/DateLookup.state.spec.js +7 -0
- package/src/dateLookup/{DateLookup.story.js → DateLookup.story.tsx} +13 -14
- package/src/dateLookup/DateLookup.tests.story.tsx +70 -0
- package/src/dateLookup/{DateLookup.js → DateLookup.tsx} +115 -81
- package/src/dateLookup/dateHeader/{DateHeader.js → DateHeader.tsx} +15 -15
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +0 -22
- package/src/dateLookup/dateTrigger/{DateTrigger.js → DateTrigger.tsx} +15 -32
- package/src/dateLookup/dayCalendar/{DayCalendar.js → DayCalendar.tsx} +14 -21
- package/src/dateLookup/dayCalendar/table/{DayCalendarTable.js → DayCalendarTable.tsx} +26 -37
- package/src/dateLookup/getStartOfDay/{getStartOfDay.js → getStartOfDay.tsx} +1 -1
- package/src/dateLookup/index.ts +2 -0
- package/src/dateLookup/monthCalendar/{MonthCalendar.js → MonthCalendar.tsx} +19 -22
- package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.js → MonthCalendarTable.tsx} +31 -30
- package/src/dateLookup/yearCalendar/{YearCalendar.js → YearCalendar.tsx} +18 -21
- package/src/dateLookup/yearCalendar/table/{YearCalendarTable.js → YearCalendarTable.tsx} +26 -28
- package/src/decision/Decision.spec.js +0 -1
- package/src/dimmer/Dimmer.tsx +6 -2
- package/src/i18n/th.json +2 -2
- package/src/index.ts +2 -2
- package/src/inlineAlert/InlineAlert.spec.tsx +0 -7
- package/src/inlineAlert/InlineAlert.story.tsx +8 -7
- package/src/inlineAlert/InlineAlert.tsx +19 -47
- package/src/inputs/InputGroup.tsx +3 -3
- package/src/inputs/SelectInput.tsx +2 -0
- package/src/inputs/_BottomSheet.tsx +21 -26
- package/src/inputs/_Popover.tsx +4 -4
- package/src/link/Link.story.tsx +16 -16
- package/src/loader/Loader.tsx +0 -1
- package/src/logo/Logo.css +16 -0
- package/src/logo/Logo.js +4 -9
- package/src/logo/Logo.less +16 -0
- package/src/logo/__snapshots__/Logo.spec.js.snap +104 -8
- package/src/main.css +16 -5
- package/src/main.less +0 -1
- package/src/moneyInput/MoneyInput.story.tsx +3 -3
- package/src/nudge/Nudge.spec.tsx +5 -5
- package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/promoCard/PromoCard.tsx +1 -1
- package/src/radioGroup/RadioGroup.spec.js +1 -1
- package/src/section/Section.story.tsx +2 -1
- package/src/segmentedControl/SegmentedControl.spec.tsx +88 -2
- package/src/segmentedControl/SegmentedControl.story.tsx +54 -16
- package/src/segmentedControl/SegmentedControl.tsx +21 -33
- package/src/select/Select.js +2 -3
- package/src/statusIcon/StatusIcon.tsx +14 -14
- package/src/stepper/deviceDetection.js +1 -2
- package/src/stepper/deviceDetection.spec.js +8 -3
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/story-config.ts +1 -1
- package/src/title/Title.spec.tsx +1 -1
- package/src/typeahead/Typeahead.spec.js +4 -2
- package/src/upload/Upload.spec.js +8 -4
- package/src/uploadInput/uploadButton/UploadButton.tsx +1 -0
- package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
- package/build/types/alert/withArrow/alertArrowPositions.d.ts +0 -9
- package/build/types/alert/withArrow/alertArrowPositions.d.ts.map +0 -1
- package/build/types/alert/withArrow/index.d.ts +0 -3
- package/build/types/alert/withArrow/index.d.ts.map +0 -1
- package/build/types/alert/withArrow/withArrow.d.ts +0 -11
- package/build/types/alert/withArrow/withArrow.d.ts.map +0 -1
- package/build/types/common/requirements.d.ts +0 -3
- package/build/types/common/requirements.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts +0 -21
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +0 -12
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/index.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/index.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts.map +0 -1
- package/src/alert/Alert.js +0 -196
- package/src/alert/index.js +0 -1
- package/src/alert/withArrow/alertArrowPositions.ts +0 -9
- package/src/alert/withArrow/index.js +0 -2
- package/src/alert/withArrow/withArrow.js +0 -50
- package/src/alert/withArrow/withArrow.spec.js +0 -51
- package/src/dateLookup/index.js +0 -1
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +0 -41
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.spec.js +0 -21
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.story.js +0 -134
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +0 -73
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.less +0 -4
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.spec.js +0 -200
- package/src/dynamicFieldDefinitionList/FormattedValue/index.js +0 -1
- package/src/dynamicFieldDefinitionList/index.js +0 -1
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.js +0 -33
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.spec.js +0 -83
- package/src/dynamicFieldDefinitionList/utils/text-format.js +0 -46
- package/src/dynamicFieldDefinitionList/utils/text-format.spec.js +0 -43
- /package/src/dateLookup/{DateLookup.messages.js → DateLookup.messages.ts} +0 -0
- /package/src/dateLookup/dateHeader/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dateTrigger/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/dayCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/getStartOfDay/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/monthCalendar/table/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/{index.js → index.ts} +0 -0
- /package/src/dateLookup/yearCalendar/table/{index.js → index.ts} +0 -0
package/build/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var reactId = require('@radix-ui/react-id');
|
|
|
7
7
|
var icons = require('@transferwise/icons');
|
|
8
8
|
var reactIntl = require('react-intl');
|
|
9
9
|
var PropTypes = require('prop-types');
|
|
10
|
+
var commonmark = require('commonmark');
|
|
10
11
|
var componentsTheming = require('@wise/components-theming');
|
|
11
12
|
var formatting = require('@transferwise/formatting');
|
|
12
13
|
var react$1 = require('@headlessui/react');
|
|
@@ -16,16 +17,14 @@ var react = require('@floating-ui/react');
|
|
|
16
17
|
var focus = require('@react-aria/focus');
|
|
17
18
|
var overlays = require('@react-aria/overlays');
|
|
18
19
|
var reactTransitionGroup = require('react-transition-group');
|
|
20
|
+
var neptuneValidation = require('@transferwise/neptune-validation');
|
|
21
|
+
var reactDom = require('react-dom');
|
|
19
22
|
var reactPopper = require('react-popper');
|
|
20
23
|
var throttle = require('lodash.throttle');
|
|
21
|
-
var reactDom = require('react-dom');
|
|
22
|
-
var neptuneValidation = require('@transferwise/neptune-validation');
|
|
23
|
-
var commonmark = require('commonmark');
|
|
24
24
|
var art = require('@wise/art');
|
|
25
25
|
var clamp$2 = require('lodash.clamp');
|
|
26
26
|
var debounce = require('lodash.debounce');
|
|
27
27
|
var requiredIf = require('react-required-if');
|
|
28
|
-
var toPairs = require('lodash.topairs');
|
|
29
28
|
var web = require('@react-spring/web');
|
|
30
29
|
|
|
31
30
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -51,13 +50,12 @@ function _interopNamespace(e) {
|
|
|
51
50
|
var classNames__default = /*#__PURE__*/_interopDefault(classNames);
|
|
52
51
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
53
52
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
53
|
+
var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
|
|
54
54
|
var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
|
|
55
55
|
var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
56
|
-
var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
|
|
57
56
|
var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
|
|
58
57
|
var debounce__default = /*#__PURE__*/_interopDefault(debounce);
|
|
59
58
|
var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
|
|
60
|
-
var toPairs__default = /*#__PURE__*/_interopDefault(toPairs);
|
|
61
59
|
|
|
62
60
|
class HistoryNavigator {
|
|
63
61
|
constructor(history = [], historyLimit = null) {
|
|
@@ -95,7 +93,7 @@ var HistoryNavigator$1 = HistoryNavigator;
|
|
|
95
93
|
function isIosDevice() {
|
|
96
94
|
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
97
95
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
98
|
-
const regex = new RegExp(matchString, '
|
|
96
|
+
const regex = new RegExp(matchString, 'gi');
|
|
99
97
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
100
98
|
}
|
|
101
99
|
|
|
@@ -807,22 +805,22 @@ const Link = ({
|
|
|
807
805
|
});
|
|
808
806
|
};
|
|
809
807
|
|
|
808
|
+
const iconTypeMap = {
|
|
809
|
+
positive: icons.Check,
|
|
810
|
+
neutral: icons.Info,
|
|
811
|
+
warning: icons.Alert,
|
|
812
|
+
negative: icons.Cross,
|
|
813
|
+
pending: icons.ClockBorderless,
|
|
814
|
+
info: icons.Info,
|
|
815
|
+
error: icons.Cross,
|
|
816
|
+
success: icons.Check
|
|
817
|
+
};
|
|
810
818
|
const StatusIcon = ({
|
|
811
|
-
sentiment =
|
|
812
|
-
size =
|
|
819
|
+
sentiment = 'neutral',
|
|
820
|
+
size = 'md'
|
|
813
821
|
}) => {
|
|
814
|
-
const iconTypeMap = {
|
|
815
|
-
[exports.Sentiment.POSITIVE]: icons.Check,
|
|
816
|
-
[exports.Sentiment.NEUTRAL]: icons.Info,
|
|
817
|
-
[exports.Sentiment.WARNING]: icons.Alert,
|
|
818
|
-
[exports.Sentiment.NEGATIVE]: icons.Cross,
|
|
819
|
-
[exports.Sentiment.PENDING]: icons.ClockBorderless,
|
|
820
|
-
[exports.Sentiment.INFO]: icons.Info,
|
|
821
|
-
[exports.Sentiment.ERROR]: icons.Cross,
|
|
822
|
-
[exports.Sentiment.SUCCESS]: icons.Check
|
|
823
|
-
};
|
|
824
|
-
const iconColor = [exports.Sentiment.WARNING, exports.Sentiment.PENDING].includes(sentiment) ? 'dark' : 'light';
|
|
825
822
|
const Icon = iconTypeMap[sentiment];
|
|
823
|
+
const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
|
|
826
824
|
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
827
825
|
"data-testid": "status-icon",
|
|
828
826
|
className: classNames__default.default('status-circle', 'status-circle-' + size, sentiment),
|
|
@@ -832,7 +830,7 @@ const StatusIcon = ({
|
|
|
832
830
|
});
|
|
833
831
|
};
|
|
834
832
|
|
|
835
|
-
function logActionRequired
|
|
833
|
+
function logActionRequired(message) {
|
|
836
834
|
if (['development', 'test'].includes(process?.env?.NODE_ENV)) {
|
|
837
835
|
// eslint-disable-next-line no-console
|
|
838
836
|
console.warn(message);
|
|
@@ -840,48 +838,10 @@ function logActionRequired$1(message) {
|
|
|
840
838
|
}
|
|
841
839
|
function logActionRequiredIf(message, conditional) {
|
|
842
840
|
if (conditional) {
|
|
843
|
-
logActionRequired
|
|
841
|
+
logActionRequired(message);
|
|
844
842
|
}
|
|
845
843
|
}
|
|
846
844
|
|
|
847
|
-
const deprecatedMessage = ({
|
|
848
|
-
component,
|
|
849
|
-
propName,
|
|
850
|
-
message,
|
|
851
|
-
expiryDate
|
|
852
|
-
}) => {
|
|
853
|
-
const messages = [`${component} has deprecated the use of ${propName}.`];
|
|
854
|
-
if (message) {
|
|
855
|
-
messages.push(message);
|
|
856
|
-
}
|
|
857
|
-
if (expiryDate) {
|
|
858
|
-
messages.push(`${propName} will be removed on or after ${expiryDate.toLocaleString('en-GB', {
|
|
859
|
-
year: 'numeric',
|
|
860
|
-
month: 'numeric',
|
|
861
|
-
day: 'numeric'
|
|
862
|
-
})}`);
|
|
863
|
-
}
|
|
864
|
-
return messages.join(' ');
|
|
865
|
-
};
|
|
866
|
-
const deprecated = (validator, {
|
|
867
|
-
component,
|
|
868
|
-
message = '',
|
|
869
|
-
newProp: newProperty = null,
|
|
870
|
-
expiryDate = null
|
|
871
|
-
}) => (props, propertyName, ...rest) => {
|
|
872
|
-
const newPropertyMessage = newProperty ? `Please use ${newProperty} instead.` : message;
|
|
873
|
-
if (props[propertyName] != null && typeof props[propertyName] !== 'undefined') {
|
|
874
|
-
logActionRequired$1(deprecatedMessage({
|
|
875
|
-
component,
|
|
876
|
-
propName: propertyName,
|
|
877
|
-
message: newPropertyMessage,
|
|
878
|
-
expiryDate
|
|
879
|
-
}));
|
|
880
|
-
}
|
|
881
|
-
return validator(props, propertyName, ...rest);
|
|
882
|
-
};
|
|
883
|
-
var deprecated$1 = deprecated;
|
|
884
|
-
|
|
885
845
|
const reader = new commonmark__default.default.Parser();
|
|
886
846
|
const writer = new commonmark__default.default.HtmlRenderer({
|
|
887
847
|
safe: true
|
|
@@ -901,7 +861,7 @@ function Markdown({
|
|
|
901
861
|
const linkTarget = config?.link?.target ?? '_self';
|
|
902
862
|
const paragraphClass = config?.paragraph?.className ?? '';
|
|
903
863
|
if (allowList != null && blockList != null) {
|
|
904
|
-
logActionRequired
|
|
864
|
+
logActionRequired('Markdown supports only one of `allowList` or `blockList` to be used at a time. `blockList` will be ignored.');
|
|
905
865
|
}
|
|
906
866
|
const parser = nodes => {
|
|
907
867
|
const parsed = reader.parse(nodes);
|
|
@@ -962,146 +922,99 @@ InlineMarkdown.defaultProps = {
|
|
|
962
922
|
};
|
|
963
923
|
var InlineMarkdown$1 = InlineMarkdown;
|
|
964
924
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
};
|
|
985
|
-
AlertWithArrow.defaultProps = {
|
|
986
|
-
className: undefined
|
|
987
|
-
};
|
|
988
|
-
return AlertWithArrow;
|
|
989
|
-
}
|
|
990
|
-
function arrowClasses(arrow) {
|
|
991
|
-
if (arrow) {
|
|
992
|
-
const classes = ['arrow'];
|
|
993
|
-
const {
|
|
994
|
-
BOTTOM,
|
|
995
|
-
BOTTOM_LEFT,
|
|
996
|
-
BOTTOM_RIGHT,
|
|
997
|
-
TOP,
|
|
998
|
-
TOP_RIGHT,
|
|
999
|
-
TOP_LEFT
|
|
1000
|
-
} = exports.AlertArrowPosition;
|
|
1001
|
-
switch (arrow) {
|
|
1002
|
-
case BOTTOM:
|
|
1003
|
-
return classes.concat('arrow-bottom', 'arrow-center');
|
|
1004
|
-
case BOTTOM_LEFT:
|
|
1005
|
-
return classes.concat('arrow-bottom', 'arrow-left');
|
|
1006
|
-
case BOTTOM_RIGHT:
|
|
1007
|
-
return classes.concat('arrow-bottom', 'arrow-right');
|
|
1008
|
-
case TOP:
|
|
1009
|
-
return classes.concat('arrow-center');
|
|
1010
|
-
case TOP_RIGHT:
|
|
1011
|
-
return classes.concat('arrow-right');
|
|
1012
|
-
case TOP_LEFT:
|
|
1013
|
-
default:
|
|
1014
|
-
return classes;
|
|
1015
|
-
}
|
|
925
|
+
var AlertArrowPosition;
|
|
926
|
+
(function (AlertArrowPosition) {
|
|
927
|
+
AlertArrowPosition["TOP_LEFT"] = "up-left";
|
|
928
|
+
AlertArrowPosition["TOP"] = "up-center";
|
|
929
|
+
AlertArrowPosition["TOP_RIGHT"] = "up-right";
|
|
930
|
+
AlertArrowPosition["BOTTOM_LEFT"] = "down-left";
|
|
931
|
+
AlertArrowPosition["BOTTOM"] = "down-center";
|
|
932
|
+
AlertArrowPosition["BOTTOM_RIGHT"] = "down-right";
|
|
933
|
+
})(AlertArrowPosition || (AlertArrowPosition = {}));
|
|
934
|
+
function resolveType(type) {
|
|
935
|
+
switch (type) {
|
|
936
|
+
case 'success':
|
|
937
|
+
return 'positive';
|
|
938
|
+
case 'info':
|
|
939
|
+
return 'neutral';
|
|
940
|
+
case 'error':
|
|
941
|
+
return 'negative';
|
|
942
|
+
default:
|
|
943
|
+
return type;
|
|
1016
944
|
}
|
|
1017
|
-
return '';
|
|
1018
945
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
const [shouldFire, setShouldFire] = React.useState(false);
|
|
1037
|
-
const {
|
|
1038
|
-
arrow,
|
|
1039
|
-
action,
|
|
1040
|
-
children,
|
|
1041
|
-
className,
|
|
1042
|
-
icon,
|
|
1043
|
-
onDismiss,
|
|
1044
|
-
message,
|
|
1045
|
-
title,
|
|
1046
|
-
type,
|
|
1047
|
-
variant
|
|
1048
|
-
} = props;
|
|
1049
|
-
const closeButtonReference = React.useRef(null);
|
|
1050
|
-
if (arrow) {
|
|
1051
|
-
const AlertWithArrow = withArrow(Alert, arrow);
|
|
1052
|
-
return /*#__PURE__*/jsxRuntime.jsx(AlertWithArrow, {
|
|
1053
|
-
...props
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
logActionRequired(props);
|
|
1057
|
-
const mappedType = deprecatedTypeMap$1[type] || type;
|
|
1058
|
-
const Icon = iconTypeMap[mappedType];
|
|
1059
|
-
function generateIcon() {
|
|
1060
|
-
if (icon) {
|
|
1061
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1062
|
-
className: "alert__icon",
|
|
1063
|
-
children: icon
|
|
1064
|
-
});
|
|
946
|
+
function Alert({
|
|
947
|
+
arrow,
|
|
948
|
+
action,
|
|
949
|
+
children,
|
|
950
|
+
className,
|
|
951
|
+
dismissible,
|
|
952
|
+
icon,
|
|
953
|
+
onDismiss,
|
|
954
|
+
message,
|
|
955
|
+
size,
|
|
956
|
+
title,
|
|
957
|
+
type = 'neutral',
|
|
958
|
+
variant = 'desktop'
|
|
959
|
+
}) {
|
|
960
|
+
React.useEffect(() => {
|
|
961
|
+
if (arrow !== undefined) {
|
|
962
|
+
logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.");
|
|
1065
963
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
});
|
|
1071
|
-
} else {
|
|
1072
|
-
return /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
1073
|
-
size: 24
|
|
1074
|
-
});
|
|
964
|
+
}, [arrow]);
|
|
965
|
+
React.useEffect(() => {
|
|
966
|
+
if (children !== undefined) {
|
|
967
|
+
logActionRequired("Alert component doesn't support 'children' anymore, use 'message' instead.");
|
|
1075
968
|
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
969
|
+
}, [children]);
|
|
970
|
+
React.useEffect(() => {
|
|
971
|
+
if (dismissible !== undefined) {
|
|
972
|
+
logActionRequired("Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.");
|
|
973
|
+
}
|
|
974
|
+
}, [dismissible]);
|
|
975
|
+
React.useEffect(() => {
|
|
976
|
+
if (size !== undefined) {
|
|
977
|
+
logActionRequired("Alert component doesn't support 'size' anymore, please remove that prop.");
|
|
978
|
+
}
|
|
979
|
+
}, [size]);
|
|
980
|
+
const resolvedType = resolveType(type);
|
|
981
|
+
React.useEffect(() => {
|
|
982
|
+
if (resolvedType !== type) {
|
|
983
|
+
logActionRequired(`Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`);
|
|
984
|
+
}
|
|
985
|
+
}, [resolvedType, type]);
|
|
986
|
+
const [shouldFire, setShouldFire] = React.useState(false);
|
|
987
|
+
const closeButtonReference = React.useRef(null);
|
|
988
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
989
|
+
className: classNames__default.default('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
|
|
990
|
+
"data-testid": "alert",
|
|
991
|
+
onTouchStart: () => setShouldFire(true),
|
|
992
|
+
onTouchEnd: event => {
|
|
993
|
+
if (shouldFire && action &&
|
|
1081
994
|
// Check if current event is triggered from closeButton
|
|
1082
|
-
|
|
1083
|
-
if (action
|
|
1084
|
-
window.top
|
|
995
|
+
event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
|
|
996
|
+
if (action.target === '_blank') {
|
|
997
|
+
window.top?.open(action.href);
|
|
1085
998
|
} else {
|
|
1086
|
-
window.top
|
|
999
|
+
window.top?.location.assign(action.href);
|
|
1087
1000
|
}
|
|
1088
1001
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1093
|
-
className: classNames__default.default('alert d-flex', `alert-${mappedType}`, className),
|
|
1094
|
-
"data-testid": "alert",
|
|
1095
|
-
onTouchStart: handleTouchStart,
|
|
1096
|
-
onTouchEnd: handleTouchEnd,
|
|
1097
|
-
onTouchMove: handleTouchMove,
|
|
1002
|
+
setShouldFire(false);
|
|
1003
|
+
},
|
|
1004
|
+
onTouchMove: () => setShouldFire(false),
|
|
1098
1005
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1099
1006
|
className: classNames__default.default('alert__content', 'd-flex', 'flex-grow-1', variant),
|
|
1100
1007
|
"data-testid": variant,
|
|
1101
|
-
children: [
|
|
1008
|
+
children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1009
|
+
className: "alert__icon",
|
|
1010
|
+
children: icon
|
|
1011
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
1012
|
+
size: exports.Size.LARGE,
|
|
1013
|
+
sentiment: resolvedType
|
|
1014
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1102
1015
|
className: "alert__message",
|
|
1103
1016
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1104
|
-
role: exports.Sentiment.NEGATIVE ===
|
|
1017
|
+
role: exports.Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status',
|
|
1105
1018
|
children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
1106
1019
|
className: "m-b-1",
|
|
1107
1020
|
type: exports.Typography.TITLE_BODY,
|
|
@@ -1129,72 +1042,24 @@ const Alert = props => {
|
|
|
1129
1042
|
onClick: onDismiss
|
|
1130
1043
|
})]
|
|
1131
1044
|
});
|
|
1132
|
-
};
|
|
1133
|
-
const deprecatedTypeMapMessage$1 = {
|
|
1134
|
-
[exports.Sentiment.SUCCESS]: 'Sentiment.POSITIVE',
|
|
1135
|
-
[exports.Sentiment.INFO]: 'Sentiment.NEUTRAL',
|
|
1136
|
-
[exports.Sentiment.ERROR]: 'Sentiment.NEGATIVE'
|
|
1137
|
-
};
|
|
1138
|
-
const deprecatedTypes$1 = Object.keys(deprecatedTypeMap$1);
|
|
1139
|
-
function logActionRequired({
|
|
1140
|
-
size,
|
|
1141
|
-
type
|
|
1142
|
-
}) {
|
|
1143
|
-
logActionRequiredIf('Alert no longer supports any possible variations in size. Please remove the `size` prop.', !!size);
|
|
1144
|
-
logActionRequiredIf(`Alert has deprecated the ${type} value for the \`type\` prop. Please update to ${deprecatedTypeMapMessage$1[type]}.`, deprecatedTypes$1.includes(type));
|
|
1145
1045
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
/** The presence of the onDismiss handler will trigger the visibility of the close button */
|
|
1164
|
-
onDismiss: PropTypes__default.default.func,
|
|
1165
|
-
/** The type dictates which icon and colour will be used */
|
|
1166
|
-
type: PropTypes__default.default.oneOf(['negative', 'neutral', 'positive', 'warning', 'info', 'error', 'success']),
|
|
1167
|
-
variant: PropTypes__default.default.oneOf(['desktop', 'mobile']),
|
|
1168
|
-
/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */
|
|
1169
|
-
arrow: deprecated$1(PropTypes__default.default.oneOf(['up-left', 'up-center', 'up-right', 'down-left', 'down-center', 'down-right']), {
|
|
1170
|
-
component: 'Alert',
|
|
1171
|
-
expiryDate: new Date('03-01-2021')
|
|
1172
|
-
}),
|
|
1173
|
-
/** @deprecated use `message` property instead */
|
|
1174
|
-
children: deprecated$1(requiredIf__default.default(PropTypes__default.default.node, ({
|
|
1175
|
-
message
|
|
1176
|
-
}) => !message), {
|
|
1177
|
-
component: 'Alert',
|
|
1178
|
-
message: 'You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.',
|
|
1179
|
-
expiryDate: new Date('03-01-2021')
|
|
1180
|
-
}),
|
|
1181
|
-
/** @deprecated use `onDismiss` instead */
|
|
1182
|
-
dismissible: deprecated$1(PropTypes__default.default.bool, {
|
|
1183
|
-
component: 'Alert',
|
|
1184
|
-
message: 'The Alert will now be considered dismissible if an `onDismiss` hander is present.',
|
|
1185
|
-
expiryDate: new Date('03-01-2021')
|
|
1186
|
-
})
|
|
1187
|
-
};
|
|
1188
|
-
Alert.defaultProps = {
|
|
1189
|
-
action: undefined,
|
|
1190
|
-
arrow: undefined,
|
|
1191
|
-
className: undefined,
|
|
1192
|
-
dismissible: undefined,
|
|
1193
|
-
icon: undefined,
|
|
1194
|
-
type: exports.Sentiment.NEUTRAL,
|
|
1195
|
-
variant: exports.Variant.DESKTOP
|
|
1196
|
-
};
|
|
1197
|
-
var Alert$1 = Alert;
|
|
1046
|
+
function alertArrowClassNames(arrow) {
|
|
1047
|
+
switch (arrow) {
|
|
1048
|
+
case 'down-center':
|
|
1049
|
+
return 'arrow arrow-bottom arrow-center';
|
|
1050
|
+
case 'down-left':
|
|
1051
|
+
return 'arrow arrow-bottom arrow-left';
|
|
1052
|
+
case 'down-right':
|
|
1053
|
+
return 'arrow arrow-bottom arrow-right';
|
|
1054
|
+
case 'up-center':
|
|
1055
|
+
return 'arrow arrow-center';
|
|
1056
|
+
case 'up-right':
|
|
1057
|
+
return 'arrow arrow-right';
|
|
1058
|
+
case 'up-left':
|
|
1059
|
+
default:
|
|
1060
|
+
return 'arrow';
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1198
1063
|
|
|
1199
1064
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
1200
1065
|
exports.AvatarType = void 0;
|
|
@@ -1222,7 +1087,7 @@ const hashSeed = seed => {
|
|
|
1222
1087
|
const modulo = avatarColors.length;
|
|
1223
1088
|
let hashValue = 0;
|
|
1224
1089
|
let basePow = 1;
|
|
1225
|
-
for (let i = 0; i < seed.length; i
|
|
1090
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
1226
1091
|
hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
|
|
1227
1092
|
basePow = basePow * base % modulo;
|
|
1228
1093
|
}
|
|
@@ -1420,6 +1285,7 @@ const FocusBoundary = ({
|
|
|
1420
1285
|
})
|
|
1421
1286
|
});
|
|
1422
1287
|
};
|
|
1288
|
+
var FocusBoundary$1 = FocusBoundary;
|
|
1423
1289
|
|
|
1424
1290
|
function withNextPortalWrapper(Component) {
|
|
1425
1291
|
return function (props) {
|
|
@@ -1513,11 +1379,15 @@ const Dimmer = ({
|
|
|
1513
1379
|
}, [onClose]);
|
|
1514
1380
|
const onEnter = () => {
|
|
1515
1381
|
setHasNotExited(true);
|
|
1516
|
-
|
|
1382
|
+
if (dimmerReference.current) {
|
|
1383
|
+
dimmerManager.add(dimmerReference.current);
|
|
1384
|
+
}
|
|
1517
1385
|
};
|
|
1518
1386
|
const onExited = () => {
|
|
1519
1387
|
setHasNotExited(false);
|
|
1520
|
-
|
|
1388
|
+
if (dimmerReference.current) {
|
|
1389
|
+
dimmerManager.remove(dimmerReference.current);
|
|
1390
|
+
}
|
|
1521
1391
|
};
|
|
1522
1392
|
React.useEffect(() => {
|
|
1523
1393
|
const localReferenceCopy = dimmerReference.current;
|
|
@@ -1561,7 +1431,7 @@ const Dimmer = ({
|
|
|
1561
1431
|
onExited: onExited,
|
|
1562
1432
|
children: /*#__PURE__*/jsxRuntime.jsx(DimmerContentWrapper, {
|
|
1563
1433
|
scrollBody: !transparent,
|
|
1564
|
-
children: /*#__PURE__*/jsxRuntime.jsx(FocusBoundary, {
|
|
1434
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FocusBoundary$1, {
|
|
1565
1435
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1566
1436
|
ref: dimmerReference,
|
|
1567
1437
|
className: classNames__default.default('dimmer', {
|
|
@@ -2193,7 +2063,7 @@ var messages$b = reactIntl.defineMessages({
|
|
|
2193
2063
|
}
|
|
2194
2064
|
});
|
|
2195
2065
|
|
|
2196
|
-
const typeClassMap
|
|
2066
|
+
const typeClassMap = {
|
|
2197
2067
|
[exports.ControlType.ACCENT]: 'btn-accent',
|
|
2198
2068
|
[exports.ControlType.POSITIVE]: 'btn-positive',
|
|
2199
2069
|
[exports.ControlType.NEGATIVE]: 'btn-negative'
|
|
@@ -2277,7 +2147,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
2277
2147
|
},
|
|
2278
2148
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
2279
2149
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2280
|
-
typeClassMap
|
|
2150
|
+
typeClassMap[newType],
|
|
2281
2151
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
2282
2152
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2283
2153
|
priorityClassMap[newPriority], className);
|
|
@@ -2662,7 +2532,7 @@ const CircularButton = ({
|
|
|
2662
2532
|
type = exports.ControlType.ACCENT,
|
|
2663
2533
|
...rest
|
|
2664
2534
|
}) => {
|
|
2665
|
-
const classes = classNames__default.default('btn np-btn', typeClassMap
|
|
2535
|
+
const classes = classNames__default.default('btn np-btn', typeClassMap[type], priorityClassMap[priority]);
|
|
2666
2536
|
const iconElement = Number(icon.props.size) !== 24 ? /*#__PURE__*/React.cloneElement(icon, {
|
|
2667
2537
|
size: 24
|
|
2668
2538
|
}) : icon;
|
|
@@ -2697,11 +2567,17 @@ function getDayNames(locale, format = 'short') {
|
|
|
2697
2567
|
|
|
2698
2568
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2699
2569
|
function moveToWithinRange(date, min, max) {
|
|
2700
|
-
|
|
2570
|
+
if (min && date < min) {
|
|
2571
|
+
return new Date(min);
|
|
2572
|
+
}
|
|
2573
|
+
if (max && date > max) {
|
|
2574
|
+
return new Date(max);
|
|
2575
|
+
}
|
|
2576
|
+
return date;
|
|
2701
2577
|
}
|
|
2702
2578
|
|
|
2703
2579
|
function isWithinRange(date, min, max) {
|
|
2704
|
-
return
|
|
2580
|
+
return (!min || date >= min) && (!max || date <= max);
|
|
2705
2581
|
}
|
|
2706
2582
|
|
|
2707
2583
|
const getMonthNames = (locale, format = 'long') => {
|
|
@@ -3225,7 +3101,7 @@ var dateTriggerMessages = reactIntl.defineMessages({
|
|
|
3225
3101
|
|
|
3226
3102
|
const DateTrigger = ({
|
|
3227
3103
|
selectedDate,
|
|
3228
|
-
size,
|
|
3104
|
+
size = exports.Size.MEDIUM,
|
|
3229
3105
|
placeholder,
|
|
3230
3106
|
label,
|
|
3231
3107
|
monthFormat,
|
|
@@ -3237,19 +3113,6 @@ const DateTrigger = ({
|
|
|
3237
3113
|
locale,
|
|
3238
3114
|
formatMessage
|
|
3239
3115
|
} = reactIntl.useIntl();
|
|
3240
|
-
const handleKeyDown = event => {
|
|
3241
|
-
if (neptuneValidation.isKey({
|
|
3242
|
-
keyType: 'Space',
|
|
3243
|
-
event: event
|
|
3244
|
-
}) || neptuneValidation.isKey({
|
|
3245
|
-
keyType: 'Enter',
|
|
3246
|
-
event: event
|
|
3247
|
-
})) {
|
|
3248
|
-
event.stopPropagation();
|
|
3249
|
-
event.preventDefault();
|
|
3250
|
-
onClear();
|
|
3251
|
-
}
|
|
3252
|
-
};
|
|
3253
3116
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3254
3117
|
children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
3255
3118
|
className: `btn btn-${size} btn-input np-date-trigger`,
|
|
@@ -3286,29 +3149,12 @@ const DateTrigger = ({
|
|
|
3286
3149
|
event.stopPropagation();
|
|
3287
3150
|
event.preventDefault();
|
|
3288
3151
|
onClear();
|
|
3289
|
-
}
|
|
3290
|
-
onKeyPress: handleKeyDown
|
|
3152
|
+
}
|
|
3291
3153
|
})
|
|
3292
3154
|
})]
|
|
3293
3155
|
}) : null]
|
|
3294
3156
|
});
|
|
3295
3157
|
};
|
|
3296
|
-
DateTrigger.propTypes = {
|
|
3297
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3298
|
-
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
3299
|
-
placeholder: PropTypes__default.default.string.isRequired,
|
|
3300
|
-
label: PropTypes__default.default.string.isRequired,
|
|
3301
|
-
monthFormat: PropTypes__default.default.oneOf(['short', 'long']).isRequired,
|
|
3302
|
-
disabled: PropTypes__default.default.bool.isRequired,
|
|
3303
|
-
onClick: PropTypes__default.default.func,
|
|
3304
|
-
onClear: PropTypes__default.default.func
|
|
3305
|
-
};
|
|
3306
|
-
DateTrigger.defaultProps = {
|
|
3307
|
-
selectedDate: null,
|
|
3308
|
-
size: exports.Size.MEDIUM,
|
|
3309
|
-
onClear: undefined
|
|
3310
|
-
};
|
|
3311
|
-
var DateTrigger$1 = DateTrigger;
|
|
3312
3158
|
|
|
3313
3159
|
var messages$8 = reactIntl.defineMessages({
|
|
3314
3160
|
next: {
|
|
@@ -3390,18 +3236,6 @@ const DateHeader = ({
|
|
|
3390
3236
|
})]
|
|
3391
3237
|
});
|
|
3392
3238
|
};
|
|
3393
|
-
DateHeader.propTypes = {
|
|
3394
|
-
label: PropTypes__default.default.string,
|
|
3395
|
-
onLabelClick: PropTypes__default.default.func,
|
|
3396
|
-
onPreviousClick: PropTypes__default.default.func.isRequired,
|
|
3397
|
-
onNextClick: PropTypes__default.default.func.isRequired,
|
|
3398
|
-
dateMode: PropTypes__default.default.string
|
|
3399
|
-
};
|
|
3400
|
-
DateHeader.defaultProps = {
|
|
3401
|
-
label: null,
|
|
3402
|
-
onLabelClick: () => {}
|
|
3403
|
-
};
|
|
3404
|
-
var DateHeader$1 = DateHeader;
|
|
3405
3239
|
|
|
3406
3240
|
function getFocusableTime(props) {
|
|
3407
3241
|
return props.timeSpan.find(time => props.isActive(time)) || props.timeSpan.find(time => props.isNow(time) && !props.isDisabled(time)) || props.timeSpan.find(time => !props.isDisabled(time));
|
|
@@ -3487,10 +3321,9 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3487
3321
|
let week = [];
|
|
3488
3322
|
const weeks = [];
|
|
3489
3323
|
let i;
|
|
3490
|
-
|
|
3491
3324
|
// Pad first week
|
|
3492
3325
|
for (i = 1; i < firstDayOfMonth; i += 1) {
|
|
3493
|
-
week.push(
|
|
3326
|
+
week.push(-1);
|
|
3494
3327
|
}
|
|
3495
3328
|
// Fill in days
|
|
3496
3329
|
for (i = 1; i <= daysInMonth; i += 1) {
|
|
@@ -3503,7 +3336,7 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3503
3336
|
if (week.length > 0) {
|
|
3504
3337
|
// Pad last week
|
|
3505
3338
|
for (i = week.length; i < 7; i += 1) {
|
|
3506
|
-
week.push(
|
|
3339
|
+
week.push(-1);
|
|
3507
3340
|
}
|
|
3508
3341
|
weeks.push(week);
|
|
3509
3342
|
}
|
|
@@ -3558,12 +3391,10 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3558
3391
|
const {
|
|
3559
3392
|
viewMonth,
|
|
3560
3393
|
viewYear,
|
|
3561
|
-
intl
|
|
3562
|
-
locale
|
|
3563
|
-
}
|
|
3394
|
+
intl
|
|
3564
3395
|
} = this.props;
|
|
3565
3396
|
const weeks = this.getTableStructure();
|
|
3566
|
-
|
|
3397
|
+
const autoFocusDay = this.getAutofocusDay(weeks);
|
|
3567
3398
|
return /*#__PURE__*/jsxRuntime.jsxs("table", {
|
|
3568
3399
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3569
3400
|
children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
|
|
@@ -3589,12 +3420,12 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3589
3420
|
children: weeks.map((week, weekIndex) => /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
3590
3421
|
children: week.map((day, dayIndex) => /*#__PURE__*/jsxRuntime.jsx("td", {
|
|
3591
3422
|
className: dayIndex > 4 ? 'weekend' : '',
|
|
3592
|
-
children: day && /*#__PURE__*/jsxRuntime.jsx(TableLink, {
|
|
3423
|
+
children: day !== -1 && /*#__PURE__*/jsxRuntime.jsx(TableLink, {
|
|
3593
3424
|
item: day,
|
|
3594
3425
|
type: "day",
|
|
3595
|
-
title: formatting.formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3426
|
+
title: formatting.formatDate(new Date(viewYear, viewMonth, day), intl.locale, SHORT_DAY_FORMAT),
|
|
3596
3427
|
autofocus: day === autoFocusDay,
|
|
3597
|
-
longTitle: formatting.formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3428
|
+
longTitle: formatting.formatDate(new Date(viewYear, viewMonth, day), intl.locale),
|
|
3598
3429
|
active: this.isActive(day),
|
|
3599
3430
|
disabled: this.isDisabled(day),
|
|
3600
3431
|
today: this.isToday(day),
|
|
@@ -3606,19 +3437,6 @@ class DayCalendarTable extends React.PureComponent {
|
|
|
3606
3437
|
});
|
|
3607
3438
|
}
|
|
3608
3439
|
}
|
|
3609
|
-
DayCalendarTable.propTypes = {
|
|
3610
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3611
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3612
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3613
|
-
viewMonth: PropTypes__default.default.number.isRequired,
|
|
3614
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3615
|
-
onSelect: PropTypes__default.default.func.isRequired
|
|
3616
|
-
};
|
|
3617
|
-
DayCalendarTable.defaultProps = {
|
|
3618
|
-
selectedDate: null,
|
|
3619
|
-
min: null,
|
|
3620
|
-
max: null
|
|
3621
|
-
};
|
|
3622
3440
|
var DayCalendarTable$1 = reactIntl.injectIntl(DayCalendarTable);
|
|
3623
3441
|
|
|
3624
3442
|
class DayCalendar extends React.PureComponent {
|
|
@@ -3658,7 +3476,7 @@ class DayCalendar extends React.PureComponent {
|
|
|
3658
3476
|
onSelect
|
|
3659
3477
|
} = this.props;
|
|
3660
3478
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3661
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader
|
|
3479
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader, {
|
|
3662
3480
|
label: formatting.formatDate(new Date(viewYear, viewMonth), locale, {
|
|
3663
3481
|
month: monthFormat,
|
|
3664
3482
|
year: 'numeric'
|
|
@@ -3678,22 +3496,6 @@ class DayCalendar extends React.PureComponent {
|
|
|
3678
3496
|
});
|
|
3679
3497
|
}
|
|
3680
3498
|
}
|
|
3681
|
-
DayCalendar.propTypes = {
|
|
3682
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3683
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3684
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3685
|
-
viewMonth: PropTypes__default.default.number.isRequired,
|
|
3686
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3687
|
-
monthFormat: PropTypes__default.default.oneOf([exports.MonthFormat.LONG, exports.MonthFormat.SHORT]).isRequired,
|
|
3688
|
-
onSelect: PropTypes__default.default.func.isRequired,
|
|
3689
|
-
onLabelClick: PropTypes__default.default.func.isRequired,
|
|
3690
|
-
onViewDateUpdate: PropTypes__default.default.func.isRequired
|
|
3691
|
-
};
|
|
3692
|
-
DayCalendar.defaultProps = {
|
|
3693
|
-
selectedDate: null,
|
|
3694
|
-
min: null,
|
|
3695
|
-
max: null
|
|
3696
|
-
};
|
|
3697
3499
|
var DayCalendar$1 = reactIntl.injectIntl(DayCalendar);
|
|
3698
3500
|
|
|
3699
3501
|
const ROWS$1 = 3;
|
|
@@ -3725,7 +3527,7 @@ const MonthCalendarTable = ({
|
|
|
3725
3527
|
});
|
|
3726
3528
|
};
|
|
3727
3529
|
const isActive = month => {
|
|
3728
|
-
return selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear();
|
|
3530
|
+
return !!(selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear());
|
|
3729
3531
|
};
|
|
3730
3532
|
const isThisMonth = month => {
|
|
3731
3533
|
return viewYear === new Date().getFullYear() && month === new Date().getMonth();
|
|
@@ -3735,7 +3537,9 @@ const MonthCalendarTable = ({
|
|
|
3735
3537
|
return !!(min && date < new Date(min.getFullYear(), min.getMonth()) || max && date > new Date(max.getFullYear(), max.getMonth()));
|
|
3736
3538
|
};
|
|
3737
3539
|
const autofocusMonth = (() => {
|
|
3738
|
-
const months =
|
|
3540
|
+
const months = Array.from({
|
|
3541
|
+
length: ROWS$1 * COLS$1
|
|
3542
|
+
}, (_, index) => index);
|
|
3739
3543
|
return getFocusableTime({
|
|
3740
3544
|
isActive,
|
|
3741
3545
|
isNow: isThisMonth,
|
|
@@ -3749,33 +3553,23 @@ const MonthCalendarTable = ({
|
|
|
3749
3553
|
className: "sr-only",
|
|
3750
3554
|
children: /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
3751
3555
|
children: /*#__PURE__*/jsxRuntime.jsx("th", {
|
|
3752
|
-
colSpan:
|
|
3556
|
+
colSpan: COLS$1,
|
|
3753
3557
|
children: placeholder
|
|
3754
3558
|
})
|
|
3755
3559
|
})
|
|
3756
3560
|
}), /*#__PURE__*/jsxRuntime.jsx("tbody", {
|
|
3757
|
-
children:
|
|
3758
|
-
|
|
3561
|
+
children: Array.from({
|
|
3562
|
+
length: ROWS$1
|
|
3563
|
+
}, (_, rowIndex) => /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
3564
|
+
children: Array.from({
|
|
3565
|
+
length: COLS$1
|
|
3566
|
+
}, (_, colIndex) => /*#__PURE__*/jsxRuntime.jsx("td", {
|
|
3759
3567
|
children: getLink(rowIndex * COLS$1 + colIndex)
|
|
3760
3568
|
}, colIndex))
|
|
3761
3569
|
}, rowIndex))
|
|
3762
3570
|
})]
|
|
3763
3571
|
});
|
|
3764
3572
|
};
|
|
3765
|
-
MonthCalendarTable.propTypes = {
|
|
3766
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3767
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3768
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3769
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3770
|
-
placeholder: PropTypes__default.default.string.isRequired,
|
|
3771
|
-
onSelect: PropTypes__default.default.func.isRequired
|
|
3772
|
-
};
|
|
3773
|
-
MonthCalendarTable.defaultProps = {
|
|
3774
|
-
selectedDate: null,
|
|
3775
|
-
min: null,
|
|
3776
|
-
max: null
|
|
3777
|
-
};
|
|
3778
|
-
var MonthCalendarTable$1 = MonthCalendarTable;
|
|
3779
3573
|
|
|
3780
3574
|
class MonthCalendar extends React.PureComponent {
|
|
3781
3575
|
onMonthSelect = month => {
|
|
@@ -3808,7 +3602,7 @@ class MonthCalendar extends React.PureComponent {
|
|
|
3808
3602
|
onLabelClick
|
|
3809
3603
|
} = this.props;
|
|
3810
3604
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3811
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader
|
|
3605
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader, {
|
|
3812
3606
|
dateMode: formatMessage(messages$8.year),
|
|
3813
3607
|
label: formatting.formatDate(new Date(viewYear, 0), locale, {
|
|
3814
3608
|
year: 'numeric'
|
|
@@ -3816,32 +3610,17 @@ class MonthCalendar extends React.PureComponent {
|
|
|
3816
3610
|
onLabelClick: onLabelClick,
|
|
3817
3611
|
onPreviousClick: this.selectPreviousYear,
|
|
3818
3612
|
onNextClick: this.selectNextYear
|
|
3819
|
-
}), /*#__PURE__*/jsxRuntime.jsx(MonthCalendarTable
|
|
3820
|
-
selectedDate,
|
|
3821
|
-
min,
|
|
3822
|
-
max,
|
|
3823
|
-
viewYear,
|
|
3824
|
-
placeholder,
|
|
3613
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MonthCalendarTable, {
|
|
3614
|
+
selectedDate: selectedDate,
|
|
3615
|
+
min: min,
|
|
3616
|
+
max: max,
|
|
3617
|
+
viewYear: viewYear,
|
|
3618
|
+
placeholder: placeholder,
|
|
3825
3619
|
onSelect: this.onMonthSelect
|
|
3826
3620
|
})]
|
|
3827
3621
|
});
|
|
3828
3622
|
}
|
|
3829
3623
|
}
|
|
3830
|
-
MonthCalendar.propTypes = {
|
|
3831
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3832
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3833
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3834
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3835
|
-
placeholder: PropTypes__default.default.string.isRequired,
|
|
3836
|
-
onSelect: PropTypes__default.default.func.isRequired,
|
|
3837
|
-
onLabelClick: PropTypes__default.default.func.isRequired,
|
|
3838
|
-
onViewDateUpdate: PropTypes__default.default.func.isRequired
|
|
3839
|
-
};
|
|
3840
|
-
MonthCalendar.defaultProps = {
|
|
3841
|
-
selectedDate: null,
|
|
3842
|
-
min: null,
|
|
3843
|
-
max: null
|
|
3844
|
-
};
|
|
3845
3624
|
var MonthCalendar$1 = reactIntl.injectIntl(MonthCalendar);
|
|
3846
3625
|
|
|
3847
3626
|
const ROWS = 5;
|
|
@@ -3883,7 +3662,9 @@ const YearCalendarTable = ({
|
|
|
3883
3662
|
return !!(min && year < min.getFullYear() || max && year > max.getFullYear());
|
|
3884
3663
|
};
|
|
3885
3664
|
const autofocusYear = (() => {
|
|
3886
|
-
const years =
|
|
3665
|
+
const years = Array.from({
|
|
3666
|
+
length: ROWS * COLS
|
|
3667
|
+
}, (_, index) => startYear + index);
|
|
3887
3668
|
return getFocusableTime({
|
|
3888
3669
|
isActive,
|
|
3889
3670
|
isNow: isThisYear,
|
|
@@ -3897,33 +3678,23 @@ const YearCalendarTable = ({
|
|
|
3897
3678
|
className: "sr-only",
|
|
3898
3679
|
children: /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
3899
3680
|
children: /*#__PURE__*/jsxRuntime.jsx("th", {
|
|
3900
|
-
colSpan:
|
|
3681
|
+
colSpan: COLS,
|
|
3901
3682
|
children: placeholder
|
|
3902
3683
|
})
|
|
3903
3684
|
})
|
|
3904
3685
|
}), /*#__PURE__*/jsxRuntime.jsx("tbody", {
|
|
3905
|
-
children:
|
|
3906
|
-
|
|
3686
|
+
children: Array.from({
|
|
3687
|
+
length: ROWS
|
|
3688
|
+
}, (_, rowIndex) => /*#__PURE__*/jsxRuntime.jsx("tr", {
|
|
3689
|
+
children: Array.from({
|
|
3690
|
+
length: COLS
|
|
3691
|
+
}, (_, colIndex) => /*#__PURE__*/jsxRuntime.jsx("td", {
|
|
3907
3692
|
children: getLink(startYear + rowIndex * COLS + colIndex)
|
|
3908
3693
|
}, colIndex))
|
|
3909
3694
|
}, rowIndex))
|
|
3910
3695
|
})]
|
|
3911
3696
|
});
|
|
3912
3697
|
};
|
|
3913
|
-
YearCalendarTable.propTypes = {
|
|
3914
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3915
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3916
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3917
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3918
|
-
placeholder: PropTypes__default.default.string.isRequired,
|
|
3919
|
-
onSelect: PropTypes__default.default.func.isRequired
|
|
3920
|
-
};
|
|
3921
|
-
YearCalendarTable.defaultProps = {
|
|
3922
|
-
selectedDate: null,
|
|
3923
|
-
min: null,
|
|
3924
|
-
max: null
|
|
3925
|
-
};
|
|
3926
|
-
var YearCalendarTable$1 = YearCalendarTable;
|
|
3927
3698
|
|
|
3928
3699
|
class YearCalendar extends React.PureComponent {
|
|
3929
3700
|
onYearSelect = year => {
|
|
@@ -3954,43 +3725,35 @@ class YearCalendar extends React.PureComponent {
|
|
|
3954
3725
|
}
|
|
3955
3726
|
} = this.props;
|
|
3956
3727
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3957
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader
|
|
3728
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateHeader, {
|
|
3958
3729
|
dateMode: formatMessage(messages$8.twentyYears),
|
|
3959
3730
|
onPreviousClick: this.selectPreviousYears,
|
|
3960
3731
|
onNextClick: this.selectNextYears
|
|
3961
|
-
}), /*#__PURE__*/jsxRuntime.jsx(YearCalendarTable
|
|
3962
|
-
selectedDate,
|
|
3963
|
-
min,
|
|
3964
|
-
max,
|
|
3965
|
-
viewYear,
|
|
3966
|
-
placeholder,
|
|
3732
|
+
}), /*#__PURE__*/jsxRuntime.jsx(YearCalendarTable, {
|
|
3733
|
+
selectedDate: selectedDate,
|
|
3734
|
+
min: min,
|
|
3735
|
+
max: max,
|
|
3736
|
+
viewYear: viewYear,
|
|
3737
|
+
placeholder: placeholder,
|
|
3967
3738
|
onSelect: this.onYearSelect
|
|
3968
3739
|
})]
|
|
3969
3740
|
});
|
|
3970
3741
|
}
|
|
3971
3742
|
}
|
|
3972
|
-
YearCalendar.propTypes = {
|
|
3973
|
-
selectedDate: PropTypes__default.default.instanceOf(Date),
|
|
3974
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
3975
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
3976
|
-
viewYear: PropTypes__default.default.number.isRequired,
|
|
3977
|
-
placeholder: PropTypes__default.default.string.isRequired,
|
|
3978
|
-
onSelect: PropTypes__default.default.func.isRequired,
|
|
3979
|
-
onViewDateUpdate: PropTypes__default.default.func.isRequired
|
|
3980
|
-
};
|
|
3981
|
-
YearCalendar.defaultProps = {
|
|
3982
|
-
selectedDate: null,
|
|
3983
|
-
min: null,
|
|
3984
|
-
max: null
|
|
3985
|
-
};
|
|
3986
3743
|
var YearCalendar$1 = reactIntl.injectIntl(YearCalendar);
|
|
3987
3744
|
|
|
3988
|
-
const MODE = {
|
|
3989
|
-
DAY: 'day',
|
|
3990
|
-
MONTH: 'month',
|
|
3991
|
-
YEAR: 'year'
|
|
3992
|
-
};
|
|
3993
3745
|
class DateLookup extends React.PureComponent {
|
|
3746
|
+
static defaultProps = {
|
|
3747
|
+
value: null,
|
|
3748
|
+
min: null,
|
|
3749
|
+
max: null,
|
|
3750
|
+
size: exports.Size.MEDIUM,
|
|
3751
|
+
placeholder: '',
|
|
3752
|
+
label: '',
|
|
3753
|
+
monthFormat: exports.MonthFormat.LONG,
|
|
3754
|
+
disabled: false,
|
|
3755
|
+
clearable: false
|
|
3756
|
+
};
|
|
3994
3757
|
element = /*#__PURE__*/React.createRef();
|
|
3995
3758
|
dropdown = /*#__PURE__*/React.createRef();
|
|
3996
3759
|
constructor(props) {
|
|
@@ -4003,7 +3766,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4003
3766
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
4004
3767
|
viewYear: (props.value || new Date()).getFullYear(),
|
|
4005
3768
|
open: false,
|
|
4006
|
-
mode:
|
|
3769
|
+
mode: 'day',
|
|
4007
3770
|
isMobile: false
|
|
4008
3771
|
};
|
|
4009
3772
|
}
|
|
@@ -4011,20 +3774,20 @@ class DateLookup extends React.PureComponent {
|
|
|
4011
3774
|
const propsSelected = getStartOfDay(props.value);
|
|
4012
3775
|
const propsMin = getStartOfDay(props.min);
|
|
4013
3776
|
const propsMax = getStartOfDay(props.max);
|
|
4014
|
-
const hasSelectedChanged =
|
|
4015
|
-
const hasMinChanged =
|
|
4016
|
-
const hasMaxChanged =
|
|
3777
|
+
const hasSelectedChanged = state.selectedDate?.getTime() !== propsSelected?.getTime();
|
|
3778
|
+
const hasMinChanged = state.min?.getTime() !== propsMin?.getTime();
|
|
3779
|
+
const hasMaxChanged = state.max?.getTime() !== propsMax?.getTime();
|
|
4017
3780
|
if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {
|
|
4018
3781
|
const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;
|
|
4019
3782
|
const min = hasMinChanged ? propsMin : state.min;
|
|
4020
3783
|
const max = hasMaxChanged ? propsMax : state.max;
|
|
4021
|
-
|
|
4022
|
-
if (!isWithinRange(selectedDate, min, max)) {
|
|
3784
|
+
if (selectedDate && !isWithinRange(selectedDate, min, max)) {
|
|
4023
3785
|
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
4024
3786
|
return null;
|
|
4025
3787
|
}
|
|
4026
|
-
const
|
|
4027
|
-
const
|
|
3788
|
+
const viewDateThatIsWithinRange = selectedDate || (min || max) && moveToWithinRange(new Date(), min, max) || new Date();
|
|
3789
|
+
const viewMonth = viewDateThatIsWithinRange.getMonth();
|
|
3790
|
+
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
4028
3791
|
return {
|
|
4029
3792
|
selectedDate,
|
|
4030
3793
|
min,
|
|
@@ -4036,12 +3799,12 @@ class DateLookup extends React.PureComponent {
|
|
|
4036
3799
|
return null;
|
|
4037
3800
|
}
|
|
4038
3801
|
componentDidUpdate(previousProps) {
|
|
4039
|
-
if (
|
|
3802
|
+
if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {
|
|
4040
3803
|
this.focusOn('.active');
|
|
4041
3804
|
}
|
|
4042
|
-
|
|
3805
|
+
const mediaQuery = window.matchMedia(`(max-width: ${exports.Breakpoint.SMALL}px)`);
|
|
4043
3806
|
this.setState({
|
|
4044
|
-
isMobile:
|
|
3807
|
+
isMobile: mediaQuery.matches
|
|
4045
3808
|
});
|
|
4046
3809
|
}
|
|
4047
3810
|
componentWillUnmount() {
|
|
@@ -4054,7 +3817,7 @@ class DateLookup extends React.PureComponent {
|
|
|
4054
3817
|
} = this.props;
|
|
4055
3818
|
this.setState({
|
|
4056
3819
|
open: true,
|
|
4057
|
-
mode:
|
|
3820
|
+
mode: 'day'
|
|
4058
3821
|
});
|
|
4059
3822
|
if (onFocus) {
|
|
4060
3823
|
onFocus();
|
|
@@ -4143,17 +3906,19 @@ class DateLookup extends React.PureComponent {
|
|
|
4143
3906
|
}
|
|
4144
3907
|
let date;
|
|
4145
3908
|
if (selectedDate) {
|
|
4146
|
-
date = new Date(mode ===
|
|
3909
|
+
date = new Date(mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(), mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(), mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate());
|
|
4147
3910
|
} else {
|
|
4148
3911
|
date = getStartOfDay(new Date());
|
|
4149
3912
|
}
|
|
4150
|
-
|
|
4151
|
-
|
|
3913
|
+
if (date) {
|
|
3914
|
+
date = moveToWithinRange(date, min, max);
|
|
3915
|
+
}
|
|
3916
|
+
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
4152
3917
|
this.props.onChange(date);
|
|
4153
3918
|
}
|
|
4154
3919
|
};
|
|
4155
3920
|
focusOn = (preferredElement, fallbackElement) => {
|
|
4156
|
-
const element = this.element.current
|
|
3921
|
+
const element = this.element.current?.querySelector(preferredElement);
|
|
4157
3922
|
if (element) {
|
|
4158
3923
|
element.focus();
|
|
4159
3924
|
} else if (fallbackElement) {
|
|
@@ -4167,9 +3932,9 @@ class DateLookup extends React.PureComponent {
|
|
|
4167
3932
|
this.focusOn('.active', '.today');
|
|
4168
3933
|
});
|
|
4169
3934
|
};
|
|
4170
|
-
switchToDays = () => this.switchMode(
|
|
4171
|
-
switchToMonths = () => this.switchMode(
|
|
4172
|
-
switchToYears = () => this.switchMode(
|
|
3935
|
+
switchToDays = () => this.switchMode('day');
|
|
3936
|
+
switchToMonths = () => this.switchMode('month');
|
|
3937
|
+
switchToYears = () => this.switchMode('year');
|
|
4173
3938
|
handleSelectedDateUpdate = selectedDate => {
|
|
4174
3939
|
this.setState({
|
|
4175
3940
|
selectedDate
|
|
@@ -4206,31 +3971,31 @@ class DateLookup extends React.PureComponent {
|
|
|
4206
3971
|
className: classNames__default.default({
|
|
4207
3972
|
'p-a-1': !isMobile
|
|
4208
3973
|
}),
|
|
4209
|
-
children: [mode ===
|
|
4210
|
-
selectedDate,
|
|
4211
|
-
min,
|
|
4212
|
-
max,
|
|
4213
|
-
viewMonth,
|
|
4214
|
-
viewYear,
|
|
4215
|
-
monthFormat,
|
|
3974
|
+
children: [mode === 'day' && /*#__PURE__*/jsxRuntime.jsx(DayCalendar$1, {
|
|
3975
|
+
selectedDate: selectedDate,
|
|
3976
|
+
min: min,
|
|
3977
|
+
max: max,
|
|
3978
|
+
viewMonth: viewMonth,
|
|
3979
|
+
viewYear: viewYear,
|
|
3980
|
+
monthFormat: monthFormat,
|
|
4216
3981
|
onSelect: this.handleSelectedDateUpdate,
|
|
4217
3982
|
onLabelClick: this.switchToYears,
|
|
4218
3983
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4219
|
-
}), mode ===
|
|
4220
|
-
selectedDate,
|
|
4221
|
-
min,
|
|
4222
|
-
max,
|
|
4223
|
-
viewYear,
|
|
4224
|
-
placeholder,
|
|
3984
|
+
}), mode === 'month' && /*#__PURE__*/jsxRuntime.jsx(MonthCalendar$1, {
|
|
3985
|
+
selectedDate: selectedDate,
|
|
3986
|
+
min: min,
|
|
3987
|
+
max: max,
|
|
3988
|
+
viewYear: viewYear,
|
|
3989
|
+
placeholder: placeholder,
|
|
4225
3990
|
onSelect: this.switchToDays,
|
|
4226
3991
|
onLabelClick: this.switchToYears,
|
|
4227
3992
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4228
|
-
}), mode ===
|
|
4229
|
-
selectedDate,
|
|
4230
|
-
min,
|
|
4231
|
-
max,
|
|
4232
|
-
viewYear,
|
|
4233
|
-
placeholder,
|
|
3993
|
+
}), mode === 'year' && /*#__PURE__*/jsxRuntime.jsx(YearCalendar$1, {
|
|
3994
|
+
selectedDate: selectedDate,
|
|
3995
|
+
min: min,
|
|
3996
|
+
max: max,
|
|
3997
|
+
viewYear: viewYear,
|
|
3998
|
+
placeholder: placeholder,
|
|
4234
3999
|
onSelect: this.switchToMonths,
|
|
4235
4000
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4236
4001
|
})]
|
|
@@ -4256,21 +4021,20 @@ class DateLookup extends React.PureComponent {
|
|
|
4256
4021
|
value
|
|
4257
4022
|
} = this.props;
|
|
4258
4023
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4259
|
-
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4260
4024
|
ref: this.element,
|
|
4261
4025
|
id: this.props.id,
|
|
4262
4026
|
"aria-labelledby": ariaLabelledBy,
|
|
4263
4027
|
className: "input-group",
|
|
4264
4028
|
onKeyDown: this.handleKeyDown,
|
|
4265
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger
|
|
4266
|
-
selectedDate,
|
|
4267
|
-
size,
|
|
4268
|
-
placeholder,
|
|
4269
|
-
label,
|
|
4270
|
-
monthFormat,
|
|
4271
|
-
disabled,
|
|
4029
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger, {
|
|
4030
|
+
selectedDate: selectedDate,
|
|
4031
|
+
size: size,
|
|
4032
|
+
placeholder: placeholder,
|
|
4033
|
+
label: label,
|
|
4034
|
+
monthFormat: monthFormat,
|
|
4035
|
+
disabled: disabled || false,
|
|
4272
4036
|
onClick: this.open,
|
|
4273
|
-
onClear: !disabled && clearable && value ? this.handleClear :
|
|
4037
|
+
onClear: !disabled && clearable && value ? this.handleClear : undefined
|
|
4274
4038
|
}), /*#__PURE__*/jsxRuntime.jsx(ResponsivePanel$1, {
|
|
4275
4039
|
anchorRef: this.element,
|
|
4276
4040
|
open: open,
|
|
@@ -4282,36 +4046,6 @@ class DateLookup extends React.PureComponent {
|
|
|
4282
4046
|
});
|
|
4283
4047
|
}
|
|
4284
4048
|
}
|
|
4285
|
-
DateLookup.propTypes = {
|
|
4286
|
-
id: PropTypes__default.default.string,
|
|
4287
|
-
value: PropTypes__default.default.instanceOf(Date),
|
|
4288
|
-
min: PropTypes__default.default.instanceOf(Date),
|
|
4289
|
-
max: PropTypes__default.default.instanceOf(Date),
|
|
4290
|
-
size: PropTypes__default.default.oneOf(['sm', 'md', 'lg']),
|
|
4291
|
-
placeholder: PropTypes__default.default.string,
|
|
4292
|
-
label: PropTypes__default.default.string,
|
|
4293
|
-
'aria-labelledby': PropTypes__default.default.string,
|
|
4294
|
-
monthFormat: PropTypes__default.default.oneOf(['long', 'short']),
|
|
4295
|
-
disabled: PropTypes__default.default.bool,
|
|
4296
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
4297
|
-
onFocus: PropTypes__default.default.func,
|
|
4298
|
-
onBlur: PropTypes__default.default.func,
|
|
4299
|
-
clearable: PropTypes__default.default.bool
|
|
4300
|
-
};
|
|
4301
|
-
DateLookup.defaultProps = {
|
|
4302
|
-
value: null,
|
|
4303
|
-
min: null,
|
|
4304
|
-
max: null,
|
|
4305
|
-
size: exports.Size.MEDIUM,
|
|
4306
|
-
placeholder: '',
|
|
4307
|
-
label: '',
|
|
4308
|
-
monthFormat: exports.MonthFormat.LONG,
|
|
4309
|
-
disabled: false,
|
|
4310
|
-
onFocus: null,
|
|
4311
|
-
onBlur: null,
|
|
4312
|
-
clearable: false
|
|
4313
|
-
};
|
|
4314
|
-
var DateLookup$1 = DateLookup;
|
|
4315
4049
|
|
|
4316
4050
|
const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
4317
4051
|
as: component = 'button',
|
|
@@ -4628,508 +4362,6 @@ const DropFade = ({
|
|
|
4628
4362
|
});
|
|
4629
4363
|
};
|
|
4630
4364
|
|
|
4631
|
-
/* eslint-disable no-unused-vars */
|
|
4632
|
-
/* eslint-disable no-param-reassign */
|
|
4633
|
-
|
|
4634
|
-
const prepFields = (fields, model, validationMessages) => {
|
|
4635
|
-
if (!fields) {
|
|
4636
|
-
return {};
|
|
4637
|
-
}
|
|
4638
|
-
let preparedFields = copyOf(fields);
|
|
4639
|
-
preparedFields = flattenFieldsWithGroups(preparedFields);
|
|
4640
|
-
preparedFields = transformFieldArrayToMap(preparedFields);
|
|
4641
|
-
preparedFields = transformNestedKeysToNestedSpecs(preparedFields);
|
|
4642
|
-
Object.keys(preparedFields).forEach(key => {
|
|
4643
|
-
preparedFields[key] = prepField(preparedFields[key], model, validationMessages);
|
|
4644
|
-
});
|
|
4645
|
-
return preparedFields;
|
|
4646
|
-
};
|
|
4647
|
-
const prepField = (field, model, validationMessages) => {
|
|
4648
|
-
const preparedField = copyOf(field);
|
|
4649
|
-
prepLegacyProps(preparedField);
|
|
4650
|
-
prepType(preparedField);
|
|
4651
|
-
prepPattern(preparedField);
|
|
4652
|
-
prepValidationMessages(preparedField, validationMessages);
|
|
4653
|
-
return preparedField;
|
|
4654
|
-
};
|
|
4655
|
-
|
|
4656
|
-
/**
|
|
4657
|
-
* In an older format we had an extra fieldGroup level, here we flatten that out
|
|
4658
|
-
* So the inner arrays of fields within the different field groups are flattened
|
|
4659
|
-
* to a single array, which is returned.
|
|
4660
|
-
*
|
|
4661
|
-
* @param fields
|
|
4662
|
-
*/
|
|
4663
|
-
const flattenFieldsWithGroups = fields => {
|
|
4664
|
-
if (Array.isArray(fields)) {
|
|
4665
|
-
let flattenedFields = [];
|
|
4666
|
-
fields.forEach(field => {
|
|
4667
|
-
// If we've been given a group with nested fields, break them out.
|
|
4668
|
-
if (field.fields) {
|
|
4669
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.fields));
|
|
4670
|
-
} else if (field.group) {
|
|
4671
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.group));
|
|
4672
|
-
} else {
|
|
4673
|
-
// Otherwise it's a regular field, just add it.
|
|
4674
|
-
flattenedFields.push(field);
|
|
4675
|
-
}
|
|
4676
|
-
});
|
|
4677
|
-
return flattenedFields;
|
|
4678
|
-
}
|
|
4679
|
-
return fields;
|
|
4680
|
-
};
|
|
4681
|
-
const flattenFieldWithGroup = (field, subFields) => {
|
|
4682
|
-
// If first field doesn't have a label, use the one from the group
|
|
4683
|
-
if (field.name && subFields.length > 0 && !subFields[0].name) {
|
|
4684
|
-
subFields[0].name = field.name;
|
|
4685
|
-
}
|
|
4686
|
-
if (field.width && subFields.length > 0 && !subFields[0].width) {
|
|
4687
|
-
subFields[0].width = field.width;
|
|
4688
|
-
}
|
|
4689
|
-
|
|
4690
|
-
// If there was a tooltip at fieldGroup level move it to first field.
|
|
4691
|
-
if (field.tooltip && subFields.length > 0 && !subFields[0].help) {
|
|
4692
|
-
subFields[0].help = {
|
|
4693
|
-
message: field.tooltip
|
|
4694
|
-
};
|
|
4695
|
-
}
|
|
4696
|
-
if (field.info && subFields.length > 0 && !subFields[0].help) {
|
|
4697
|
-
subFields[0].help = {
|
|
4698
|
-
message: field.info
|
|
4699
|
-
};
|
|
4700
|
-
}
|
|
4701
|
-
|
|
4702
|
-
// If there are two parts of this group, render them side by side
|
|
4703
|
-
if (subFields.length === 2) {
|
|
4704
|
-
subFields.forEach(nestedField => {
|
|
4705
|
-
nestedField.width = 'md';
|
|
4706
|
-
});
|
|
4707
|
-
}
|
|
4708
|
-
|
|
4709
|
-
// If there are three parts, render the first two side by side
|
|
4710
|
-
if (subFields.length === 3) {
|
|
4711
|
-
subFields[0].width = 'md';
|
|
4712
|
-
subFields[1].width = 'md';
|
|
4713
|
-
}
|
|
4714
|
-
return subFields;
|
|
4715
|
-
};
|
|
4716
|
-
|
|
4717
|
-
/*
|
|
4718
|
-
* Some older requirements return an array of fields, where it should be a map
|
|
4719
|
-
* from the property name to the spec. This converts arrays to maps.
|
|
4720
|
-
*/
|
|
4721
|
-
const transformFieldArrayToMap = fields => {
|
|
4722
|
-
if (Array.isArray(fields)) {
|
|
4723
|
-
const fieldMap = {};
|
|
4724
|
-
fields.forEach(field => {
|
|
4725
|
-
const key = field.key || field.name;
|
|
4726
|
-
delete field.key;
|
|
4727
|
-
fieldMap[key] = copyOf(field);
|
|
4728
|
-
});
|
|
4729
|
-
return fieldMap;
|
|
4730
|
-
}
|
|
4731
|
-
return fields;
|
|
4732
|
-
};
|
|
4733
|
-
|
|
4734
|
-
/*
|
|
4735
|
-
* Some older format return keys like 'address.city', expecting the value of
|
|
4736
|
-
* city to be nested inside an address object. This function creates a spec of
|
|
4737
|
-
* type 'object', and nests such fields inside of it. When we render we pass
|
|
4738
|
-
* this object spec to a nested fieldset.
|
|
4739
|
-
*/
|
|
4740
|
-
const transformNestedKeysToNestedSpecs = fieldMap => {
|
|
4741
|
-
if (Array.isArray(fieldMap)) {
|
|
4742
|
-
throw new TypeError('Expecting a map of fields, not an array');
|
|
4743
|
-
}
|
|
4744
|
-
const nestedFields = {};
|
|
4745
|
-
Object.keys(fieldMap).forEach(key => {
|
|
4746
|
-
if (key.indexOf('.') > 0) {
|
|
4747
|
-
// If the key contains a period we need to nest the fields in another object
|
|
4748
|
-
const pathSections = key.split('.');
|
|
4749
|
-
const nestedKey = pathSections[0];
|
|
4750
|
-
|
|
4751
|
-
// If this sub object doesn't exist yet, create it
|
|
4752
|
-
if (!nestedFields[nestedKey]) {
|
|
4753
|
-
nestedFields[nestedKey] = {
|
|
4754
|
-
type: 'object',
|
|
4755
|
-
properties: {}
|
|
4756
|
-
};
|
|
4757
|
-
}
|
|
4758
|
-
nestedFields[nestedKey].properties[pathSections[1]] = fieldMap[key];
|
|
4759
|
-
} else {
|
|
4760
|
-
nestedFields[key] = fieldMap[key];
|
|
4761
|
-
}
|
|
4762
|
-
});
|
|
4763
|
-
return nestedFields;
|
|
4764
|
-
};
|
|
4765
|
-
const prepType = field => {
|
|
4766
|
-
const type = field.type && field.type.toLowerCase && field.type.toLowerCase();
|
|
4767
|
-
switch (type) {
|
|
4768
|
-
case 'text':
|
|
4769
|
-
field.type = 'string';
|
|
4770
|
-
break;
|
|
4771
|
-
case 'date':
|
|
4772
|
-
field.type = 'string';
|
|
4773
|
-
field.format = 'date';
|
|
4774
|
-
break;
|
|
4775
|
-
case 'password':
|
|
4776
|
-
field.type = 'string';
|
|
4777
|
-
field.control = 'password';
|
|
4778
|
-
break;
|
|
4779
|
-
case 'checkbox':
|
|
4780
|
-
field.type = 'boolean';
|
|
4781
|
-
break;
|
|
4782
|
-
case 'select':
|
|
4783
|
-
if (!field.control) {
|
|
4784
|
-
field.control = 'select';
|
|
4785
|
-
}
|
|
4786
|
-
delete field.type;
|
|
4787
|
-
break;
|
|
4788
|
-
case 'radio':
|
|
4789
|
-
field.control = 'radio';
|
|
4790
|
-
delete field.type;
|
|
4791
|
-
break;
|
|
4792
|
-
case 'upload':
|
|
4793
|
-
field.type = 'string';
|
|
4794
|
-
field.format = 'base64url';
|
|
4795
|
-
break;
|
|
4796
|
-
case 'tel':
|
|
4797
|
-
field.type = 'string';
|
|
4798
|
-
field.format = 'phone';
|
|
4799
|
-
break;
|
|
4800
|
-
case 'textarea':
|
|
4801
|
-
field.type = 'string';
|
|
4802
|
-
field.control = 'textarea';
|
|
4803
|
-
break;
|
|
4804
|
-
}
|
|
4805
|
-
if (!field.control && field.type !== 'object') {
|
|
4806
|
-
field.control = getControlType(field);
|
|
4807
|
-
}
|
|
4808
|
-
};
|
|
4809
|
-
const prepLegacyProps = field => {
|
|
4810
|
-
if (field.name && !field.title) {
|
|
4811
|
-
field.title = field.name;
|
|
4812
|
-
delete field.name;
|
|
4813
|
-
}
|
|
4814
|
-
if (field.validationRegexp) {
|
|
4815
|
-
field.pattern = field.validationRegexp;
|
|
4816
|
-
delete field.validationRegexp;
|
|
4817
|
-
}
|
|
4818
|
-
if (field.min) {
|
|
4819
|
-
field.minimum = field.min;
|
|
4820
|
-
delete field.min;
|
|
4821
|
-
}
|
|
4822
|
-
if (field.max) {
|
|
4823
|
-
field.maximum = field.max;
|
|
4824
|
-
delete field.max;
|
|
4825
|
-
}
|
|
4826
|
-
if (field.example && !field.placeholder) {
|
|
4827
|
-
field.placeholder = field.example;
|
|
4828
|
-
delete field.example;
|
|
4829
|
-
}
|
|
4830
|
-
if (field.tooltip && !field.help) {
|
|
4831
|
-
field.help = {
|
|
4832
|
-
message: field.tooltip
|
|
4833
|
-
};
|
|
4834
|
-
delete field.tooltip;
|
|
4835
|
-
}
|
|
4836
|
-
if (field.valuesAllowed && !field.values) {
|
|
4837
|
-
field.values = field.valuesAllowed;
|
|
4838
|
-
delete field.valuesAllowed;
|
|
4839
|
-
}
|
|
4840
|
-
if (field.values && field.values.map) {
|
|
4841
|
-
field.values = prepLegacyValues(field.values);
|
|
4842
|
-
}
|
|
4843
|
-
if (field.value && !field.default) {
|
|
4844
|
-
field.default = field.value;
|
|
4845
|
-
delete field.value;
|
|
4846
|
-
}
|
|
4847
|
-
if (field.values) {
|
|
4848
|
-
// In some legacy arrays the first value is a placeholder, extract it.
|
|
4849
|
-
if (field.values && field.values.length > 0 && field.values[0] && !field.values[0].value && field.values[0].label && !field.placeholder) {
|
|
4850
|
-
field.placeholder = field.values[0].label;
|
|
4851
|
-
field.values = field.values.slice(1);
|
|
4852
|
-
}
|
|
4853
|
-
}
|
|
4854
|
-
};
|
|
4855
|
-
const prepLegacyValues = values => values.map(prepLegacyValue);
|
|
4856
|
-
const prepLegacyValue = value => {
|
|
4857
|
-
if (!value.label && value.title) {
|
|
4858
|
-
value.label = value.title;
|
|
4859
|
-
delete value.title;
|
|
4860
|
-
}
|
|
4861
|
-
if (!value.label && value.name) {
|
|
4862
|
-
value.label = value.name;
|
|
4863
|
-
delete value.name;
|
|
4864
|
-
}
|
|
4865
|
-
if (!value.value && value.code) {
|
|
4866
|
-
value.value = value.code;
|
|
4867
|
-
delete value.code;
|
|
4868
|
-
}
|
|
4869
|
-
if (!value.value && value.key) {
|
|
4870
|
-
value.value = value.key;
|
|
4871
|
-
delete value.key;
|
|
4872
|
-
}
|
|
4873
|
-
return value;
|
|
4874
|
-
};
|
|
4875
|
-
const prepPattern = field => {
|
|
4876
|
-
if (field.pattern) {
|
|
4877
|
-
try {
|
|
4878
|
-
new RegExp(field.pattern);
|
|
4879
|
-
} catch {
|
|
4880
|
-
// eslint-disable-next-line no-console
|
|
4881
|
-
console.warn('API regexp is invalid');
|
|
4882
|
-
delete field.pattern;
|
|
4883
|
-
}
|
|
4884
|
-
} else {
|
|
4885
|
-
delete field.pattern;
|
|
4886
|
-
}
|
|
4887
|
-
};
|
|
4888
|
-
const prepValidationMessages = (field, validationMessages) => {
|
|
4889
|
-
field.validationMessages = field.validationMessages ? field.validationMessages : validationMessages;
|
|
4890
|
-
if (!field.validationMessages) {
|
|
4891
|
-
delete field.validationMessages;
|
|
4892
|
-
return;
|
|
4893
|
-
}
|
|
4894
|
-
if (field.validationMessages.minimum) {
|
|
4895
|
-
field.validationMessages.min = field.validationMessages.minimum;
|
|
4896
|
-
delete field.validationMessages.minimum;
|
|
4897
|
-
}
|
|
4898
|
-
if (field.validationMessages.maximum) {
|
|
4899
|
-
field.validationMessages.max = field.validationMessages.maximum;
|
|
4900
|
-
delete field.validationMessages.maximum;
|
|
4901
|
-
}
|
|
4902
|
-
};
|
|
4903
|
-
const getControlType = field => {
|
|
4904
|
-
if (field.control) {
|
|
4905
|
-
return field.control.toLowerCase();
|
|
4906
|
-
}
|
|
4907
|
-
if (field.hidden) {
|
|
4908
|
-
return 'hidden';
|
|
4909
|
-
}
|
|
4910
|
-
if (field.values && field.values.length > 0) {
|
|
4911
|
-
return getSelectionType(field);
|
|
4912
|
-
}
|
|
4913
|
-
switch (field.type) {
|
|
4914
|
-
case 'string':
|
|
4915
|
-
return getControlForStringFormat(field.format);
|
|
4916
|
-
case 'number':
|
|
4917
|
-
case 'integer':
|
|
4918
|
-
return 'number';
|
|
4919
|
-
case 'boolean':
|
|
4920
|
-
return 'checkbox';
|
|
4921
|
-
default:
|
|
4922
|
-
return 'text';
|
|
4923
|
-
}
|
|
4924
|
-
};
|
|
4925
|
-
const getControlForStringFormat = format => {
|
|
4926
|
-
switch (format) {
|
|
4927
|
-
case 'date':
|
|
4928
|
-
return 'date';
|
|
4929
|
-
case 'base64url':
|
|
4930
|
-
return 'file';
|
|
4931
|
-
case 'password':
|
|
4932
|
-
return 'password';
|
|
4933
|
-
case 'uri':
|
|
4934
|
-
return 'text';
|
|
4935
|
-
// 'url'; - not implemented
|
|
4936
|
-
case 'email':
|
|
4937
|
-
return 'text';
|
|
4938
|
-
// 'email'; - not implemented
|
|
4939
|
-
case 'phone':
|
|
4940
|
-
return 'tel';
|
|
4941
|
-
default:
|
|
4942
|
-
return 'text';
|
|
4943
|
-
}
|
|
4944
|
-
};
|
|
4945
|
-
const getSelectionType = field => {
|
|
4946
|
-
if (field.control) {
|
|
4947
|
-
return field.control;
|
|
4948
|
-
}
|
|
4949
|
-
if (field.type === 'select') {
|
|
4950
|
-
return 'select';
|
|
4951
|
-
}
|
|
4952
|
-
if (field.type === 'radio') {
|
|
4953
|
-
return 'radio';
|
|
4954
|
-
}
|
|
4955
|
-
if (field.values) {
|
|
4956
|
-
return field.values.length > 3 ? 'select' : 'radio';
|
|
4957
|
-
}
|
|
4958
|
-
return 'select';
|
|
4959
|
-
};
|
|
4960
|
-
const copyOf = object => JSON.parse(JSON.stringify(object));
|
|
4961
|
-
|
|
4962
|
-
const formatUsingPattern = (value = '', pattern) => {
|
|
4963
|
-
if (typeof pattern !== 'string') {
|
|
4964
|
-
return value;
|
|
4965
|
-
}
|
|
4966
|
-
let newPattern = pattern;
|
|
4967
|
-
if (newPattern.indexOf('||') > 0) {
|
|
4968
|
-
newPattern = newPattern.slice(0, Math.max(0, pattern.indexOf('||')));
|
|
4969
|
-
}
|
|
4970
|
-
let newValue = '';
|
|
4971
|
-
let separators = 0;
|
|
4972
|
-
let charactersToAllocate = value.length;
|
|
4973
|
-
let position = 0;
|
|
4974
|
-
while (charactersToAllocate) {
|
|
4975
|
-
if (positionIsSeparator(newPattern, position)) {
|
|
4976
|
-
newValue += newPattern[position];
|
|
4977
|
-
separators += 1;
|
|
4978
|
-
} else {
|
|
4979
|
-
newValue += value[position - separators];
|
|
4980
|
-
charactersToAllocate -= 1;
|
|
4981
|
-
}
|
|
4982
|
-
position += 1;
|
|
4983
|
-
}
|
|
4984
|
-
const separatorsAfterCursor = countSeparatorsAfterCursor(newPattern, position);
|
|
4985
|
-
if (separatorsAfterCursor) {
|
|
4986
|
-
newValue += newPattern.slice(position, separatorsAfterCursor);
|
|
4987
|
-
}
|
|
4988
|
-
return newValue;
|
|
4989
|
-
};
|
|
4990
|
-
const countSeparatorsAfterCursor = (newPattern, position) => {
|
|
4991
|
-
let separators = 0;
|
|
4992
|
-
while (positionIsSeparator(newPattern, position + separators)) {
|
|
4993
|
-
separators += 1;
|
|
4994
|
-
}
|
|
4995
|
-
return separators;
|
|
4996
|
-
};
|
|
4997
|
-
const positionIsSeparator = (newPattern, position) => newPattern[position] && newPattern[position] !== '*';
|
|
4998
|
-
|
|
4999
|
-
const getValueLabel = (options, value) => {
|
|
5000
|
-
const option = options.find(currentOption => currentOption.value === value);
|
|
5001
|
-
return option && option.label ? option.label : value;
|
|
5002
|
-
};
|
|
5003
|
-
|
|
5004
|
-
/**
|
|
5005
|
-
*
|
|
5006
|
-
* @param {string} value
|
|
5007
|
-
*/
|
|
5008
|
-
const mask = value => new Array(value.length + 1).join('*');
|
|
5009
|
-
const FormattedValue = ({
|
|
5010
|
-
field,
|
|
5011
|
-
value
|
|
5012
|
-
}) => {
|
|
5013
|
-
const {
|
|
5014
|
-
locale
|
|
5015
|
-
} = reactIntl.useIntl();
|
|
5016
|
-
const style = [];
|
|
5017
|
-
if (field.tagClassName && field.tagClassName.h3) {
|
|
5018
|
-
style.push('np-text-body-large-bold');
|
|
5019
|
-
style.push('formatted-value__h3-custom-alignment');
|
|
5020
|
-
}
|
|
5021
|
-
switch (field.control) {
|
|
5022
|
-
case 'select':
|
|
5023
|
-
case 'radio':
|
|
5024
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5025
|
-
children: getValueLabel(field.values, value)
|
|
5026
|
-
});
|
|
5027
|
-
case 'date':
|
|
5028
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5029
|
-
children: formatting.formatDate(value instanceof Date ? value : new Date(value), locale)
|
|
5030
|
-
});
|
|
5031
|
-
case 'number':
|
|
5032
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5033
|
-
children: formatting.formatNumber(value, locale)
|
|
5034
|
-
});
|
|
5035
|
-
case 'password':
|
|
5036
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5037
|
-
children: mask(value)
|
|
5038
|
-
});
|
|
5039
|
-
case 'file':
|
|
5040
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5041
|
-
className: "thumbnail",
|
|
5042
|
-
children: /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
5043
|
-
alt: field.title,
|
|
5044
|
-
src: value
|
|
5045
|
-
})
|
|
5046
|
-
});
|
|
5047
|
-
case 'checkbox':
|
|
5048
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5049
|
-
children: JSON.stringify(value)
|
|
5050
|
-
});
|
|
5051
|
-
default:
|
|
5052
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5053
|
-
className: classNames__default.default(style),
|
|
5054
|
-
children: formatUsingPattern(value, field.displayFormat)
|
|
5055
|
-
});
|
|
5056
|
-
}
|
|
5057
|
-
};
|
|
5058
|
-
FormattedValue.propTypes = {
|
|
5059
|
-
field: PropTypes__default.default.shape({
|
|
5060
|
-
control: PropTypes__default.default.string.isRequired,
|
|
5061
|
-
displayFormat: PropTypes__default.default.string,
|
|
5062
|
-
refreshRequirementsOnChange: PropTypes__default.default.bool,
|
|
5063
|
-
title: PropTypes__default.default.string.isRequired,
|
|
5064
|
-
type: PropTypes__default.default.string.isRequired,
|
|
5065
|
-
width: PropTypes__default.default.string,
|
|
5066
|
-
tagClassName: PropTypes__default.default.shape({
|
|
5067
|
-
h3: PropTypes__default.default.bool
|
|
5068
|
-
}),
|
|
5069
|
-
values: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
5070
|
-
value: PropTypes__default.default.any
|
|
5071
|
-
}))
|
|
5072
|
-
}).isRequired,
|
|
5073
|
-
value: PropTypes__default.default.any.isRequired
|
|
5074
|
-
};
|
|
5075
|
-
var FormattedValue$1 = FormattedValue;
|
|
5076
|
-
|
|
5077
|
-
function createDefinitions(fields, model) {
|
|
5078
|
-
return toPairs__default.default(fields).map(([name, field]) => createDefinition(name, field, model)).filter(definition => !!definition);
|
|
5079
|
-
}
|
|
5080
|
-
function createDefinition(name, field, model) {
|
|
5081
|
-
const {
|
|
5082
|
-
title,
|
|
5083
|
-
group,
|
|
5084
|
-
hidden
|
|
5085
|
-
} = field;
|
|
5086
|
-
if (!model[name] || hidden) {
|
|
5087
|
-
return null;
|
|
5088
|
-
}
|
|
5089
|
-
return {
|
|
5090
|
-
title,
|
|
5091
|
-
value: group ? group.map((groupField, groupFieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
5092
|
-
// eslint-disable-line react/no-array-index-key
|
|
5093
|
-
field: groupField,
|
|
5094
|
-
value: model[name]
|
|
5095
|
-
}, groupFieldIndex)) : /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
5096
|
-
field: field,
|
|
5097
|
-
value: model[name]
|
|
5098
|
-
}),
|
|
5099
|
-
key: name
|
|
5100
|
-
};
|
|
5101
|
-
}
|
|
5102
|
-
|
|
5103
|
-
const DynamicFieldDefinitionList = ({
|
|
5104
|
-
model,
|
|
5105
|
-
title,
|
|
5106
|
-
layout,
|
|
5107
|
-
fields
|
|
5108
|
-
}) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
5109
|
-
children: [title && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5110
|
-
className: "m-t-1 m-b-3",
|
|
5111
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
5112
|
-
type: exports.Typography.TITLE_BODY,
|
|
5113
|
-
className: "p-t-3",
|
|
5114
|
-
children: title
|
|
5115
|
-
})
|
|
5116
|
-
}), /*#__PURE__*/jsxRuntime.jsx(DefinitionList$1, {
|
|
5117
|
-
layout: layout,
|
|
5118
|
-
definitions: createDefinitions(prepFields(fields), model)
|
|
5119
|
-
})]
|
|
5120
|
-
});
|
|
5121
|
-
DynamicFieldDefinitionList.propTypes = {
|
|
5122
|
-
model: PropTypes__default.default.shape({}).isRequired,
|
|
5123
|
-
fields: PropTypes__default.default.shape({}).isRequired,
|
|
5124
|
-
title: PropTypes__default.default.string,
|
|
5125
|
-
layout: PropTypes__default.default.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED'])
|
|
5126
|
-
};
|
|
5127
|
-
DynamicFieldDefinitionList.defaultProps = {
|
|
5128
|
-
title: null,
|
|
5129
|
-
layout: exports.Layout.VERTICAL_TWO_COLUMN
|
|
5130
|
-
};
|
|
5131
|
-
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
5132
|
-
|
|
5133
4365
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
5134
4366
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
5135
4367
|
class EmphasisHtmlTransformer {
|
|
@@ -5350,15 +4582,14 @@ const Logo = ({
|
|
|
5350
4582
|
}) => {
|
|
5351
4583
|
const LogoSm = svgPaths[`WISE_FLAG${type === exports.LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
|
|
5352
4584
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5353
|
-
const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
|
|
5354
4585
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
5355
4586
|
"aria-label": type === exports.LogoType.WISE ? 'Wise' : 'Wise Business' | type === exports.LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
|
|
5356
4587
|
role: "img",
|
|
5357
4588
|
className: classNames__default.default(className, 'np-logo'),
|
|
5358
|
-
children: [
|
|
5359
|
-
className: "np-logo-svg"
|
|
5360
|
-
}),
|
|
5361
|
-
className: "np-logo-svg"
|
|
4589
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LogoSm, {
|
|
4590
|
+
className: "np-logo-svg np-logo-svg--size-sm"
|
|
4591
|
+
}), /*#__PURE__*/jsxRuntime.jsx(LogoMd, {
|
|
4592
|
+
className: "np-logo-svg np-logo-svg--size-md"
|
|
5362
4593
|
})]
|
|
5363
4594
|
});
|
|
5364
4595
|
};
|
|
@@ -5470,7 +4701,6 @@ const Tooltip = ({
|
|
|
5470
4701
|
|
|
5471
4702
|
function supportsTouchEvents() {
|
|
5472
4703
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
5473
|
-
// eslint-disable-next-line compat/compat
|
|
5474
4704
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
5475
4705
|
const documentTouchIsDefined = typeof window !== 'undefined' && window.DocumentTouch && document instanceof window.DocumentTouch;
|
|
5476
4706
|
return !!(onTouchStartIsDefined || maxTouchPointsIsDefined || documentTouchIsDefined);
|
|
@@ -5478,7 +4708,7 @@ function supportsTouchEvents() {
|
|
|
5478
4708
|
function userAgentSuggestsTouchDevice() {
|
|
5479
4709
|
const sampleTouchDevices = ['android', 'iemobile', 'iphone', 'ipad', 'ipod', 'blackberry', 'bada'];
|
|
5480
4710
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
5481
|
-
const regex = new RegExp(matchString, '
|
|
4711
|
+
const regex = new RegExp(matchString, 'gi');
|
|
5482
4712
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
5483
4713
|
}
|
|
5484
4714
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -5884,8 +5114,9 @@ function resolvePlacement(preferredPlacement) {
|
|
|
5884
5114
|
case 'bottom-left':
|
|
5885
5115
|
case 'bottom-right':
|
|
5886
5116
|
return 'bottom';
|
|
5117
|
+
default:
|
|
5118
|
+
return preferredPlacement;
|
|
5887
5119
|
}
|
|
5888
|
-
return preferredPlacement;
|
|
5889
5120
|
}
|
|
5890
5121
|
function Popover$1({
|
|
5891
5122
|
children,
|
|
@@ -5898,7 +5129,7 @@ function Popover$1({
|
|
|
5898
5129
|
const resolvedPlacement = resolvePlacement(preferredPlacement);
|
|
5899
5130
|
React.useEffect(() => {
|
|
5900
5131
|
if (resolvedPlacement !== preferredPlacement) {
|
|
5901
|
-
logActionRequired
|
|
5132
|
+
logActionRequired(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`);
|
|
5902
5133
|
}
|
|
5903
5134
|
}, [preferredPlacement, resolvedPlacement]);
|
|
5904
5135
|
const anchorReference = React.useRef(null);
|
|
@@ -6003,49 +5234,22 @@ const Info = ({
|
|
|
6003
5234
|
});
|
|
6004
5235
|
};
|
|
6005
5236
|
|
|
6006
|
-
|
|
6007
|
-
[exports.Sentiment.ERROR]: 'danger',
|
|
6008
|
-
[exports.Sentiment.NEGATIVE]: 'danger'
|
|
6009
|
-
};
|
|
6010
|
-
const InlineAlert = ({
|
|
5237
|
+
function InlineAlert({
|
|
6011
5238
|
id,
|
|
6012
|
-
type =
|
|
5239
|
+
type = 'neutral',
|
|
6013
5240
|
className,
|
|
6014
5241
|
children
|
|
6015
|
-
})
|
|
6016
|
-
const
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
role: "alert",
|
|
6023
|
-
id: id,
|
|
6024
|
-
className: classNames__default.default('alert alert-detach', typeClass, className),
|
|
6025
|
-
children: [(type === 'error' || type === 'negative') && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6026
|
-
children: children
|
|
6027
|
-
})]
|
|
6028
|
-
});
|
|
6029
|
-
}
|
|
6030
|
-
const getAlertContents = ({
|
|
6031
|
-
children,
|
|
6032
|
-
className
|
|
6033
|
-
}) => {
|
|
6034
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6035
|
-
role: "alert",
|
|
6036
|
-
id: id,
|
|
6037
|
-
className: classNames__default.default('alert alert-detach p-x-2 p-y-1', typeClass, className),
|
|
5242
|
+
}) {
|
|
5243
|
+
const danger = type === 'negative' || type === 'error';
|
|
5244
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5245
|
+
role: "alert",
|
|
5246
|
+
id: id,
|
|
5247
|
+
className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
5248
|
+
children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6038
5249
|
children: children
|
|
6039
|
-
})
|
|
6040
|
-
};
|
|
6041
|
-
const AlertWithArrow = withArrow(getAlertContents, exports.AlertArrowPosition.TOP_LEFT);
|
|
6042
|
-
return /*#__PURE__*/jsxRuntime.jsx(AlertWithArrow, {
|
|
6043
|
-
id,
|
|
6044
|
-
type,
|
|
6045
|
-
className,
|
|
6046
|
-
children
|
|
5250
|
+
})]
|
|
6047
5251
|
});
|
|
6048
|
-
}
|
|
5252
|
+
}
|
|
6049
5253
|
|
|
6050
5254
|
/*
|
|
6051
5255
|
* Inspired by:
|
|
@@ -6144,9 +5348,9 @@ function InputAddon({
|
|
|
6144
5348
|
const ref = React.useRef(null);
|
|
6145
5349
|
useResizeObserver(ref, entry => {
|
|
6146
5350
|
// TODO: Remove fallback once most browsers support `borderBoxSize`
|
|
6147
|
-
|
|
6148
|
-
if (
|
|
6149
|
-
setInputPadding(
|
|
5351
|
+
const inlineSize = entry.borderBoxSize?.[0]?.inlineSize;
|
|
5352
|
+
if (inlineSize != null) {
|
|
5353
|
+
setInputPadding(inlineSize);
|
|
6150
5354
|
} else {
|
|
6151
5355
|
const targetStyle = getComputedStyle(entry.target);
|
|
6152
5356
|
setInputPadding(entry.contentRect.width + Number.parseFloat(targetStyle.paddingInlineStart) + Number.parseFloat(targetStyle.paddingInlineEnd));
|
|
@@ -6293,35 +5497,33 @@ function BottomSheet({
|
|
|
6293
5497
|
theme: "personal",
|
|
6294
5498
|
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
6295
5499
|
isNotRootProvider: true,
|
|
6296
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
5500
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(react$1.Transition, {
|
|
6297
5501
|
show: open,
|
|
6298
5502
|
className: "np-bottom-sheet-v2-container",
|
|
6299
5503
|
beforeEnter: () => {
|
|
6300
5504
|
setFloatingKey(prev => prev + 1);
|
|
6301
5505
|
},
|
|
6302
5506
|
afterLeave: onCloseEnd,
|
|
6303
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
5507
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
|
|
5508
|
+
enter: "np-bottom-sheet-v2-backdrop-container--enter",
|
|
5509
|
+
enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
|
|
5510
|
+
leave: "np-bottom-sheet-v2-backdrop-container--leave",
|
|
5511
|
+
leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
|
|
5512
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5513
|
+
className: "np-bottom-sheet-v2-backdrop"
|
|
5514
|
+
})
|
|
5515
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5516
|
+
className: "np-bottom-sheet-v2",
|
|
5517
|
+
children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
|
|
5518
|
+
className: "np-bottom-sheet-v2-content",
|
|
5519
|
+
enter: "np-bottom-sheet-v2-content--enter",
|
|
5520
|
+
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
5521
|
+
leave: "np-bottom-sheet-v2-content--leave",
|
|
5522
|
+
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
5523
|
+
children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
|
|
6320
5524
|
children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
|
|
6321
5525
|
context: context,
|
|
6322
5526
|
initialFocus: initialFocusRef,
|
|
6323
|
-
guards: false,
|
|
6324
|
-
modal: false,
|
|
6325
5527
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
6326
5528
|
// Force inner state invalidation on open
|
|
6327
5529
|
ref: refs.setFloating,
|
|
@@ -6350,8 +5552,8 @@ function BottomSheet({
|
|
|
6350
5552
|
}, floatingKey)
|
|
6351
5553
|
})
|
|
6352
5554
|
})
|
|
6353
|
-
})
|
|
6354
|
-
})
|
|
5555
|
+
})
|
|
5556
|
+
})]
|
|
6355
5557
|
})
|
|
6356
5558
|
})
|
|
6357
5559
|
})]
|
|
@@ -6449,11 +5651,9 @@ function Popover({
|
|
|
6449
5651
|
setFloatingKey(prev => prev + 1);
|
|
6450
5652
|
},
|
|
6451
5653
|
afterLeave: onCloseEnd,
|
|
6452
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
5654
|
+
children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
|
|
6453
5655
|
children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
|
|
6454
5656
|
context: context,
|
|
6455
|
-
guards: false,
|
|
6456
|
-
modal: false,
|
|
6457
5657
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6458
5658
|
// Force inner state invalidation on open
|
|
6459
5659
|
ref: refs.setFloating,
|
|
@@ -6574,6 +5774,7 @@ const defaultRenderTrigger = ({
|
|
|
6574
5774
|
})
|
|
6575
5775
|
})]
|
|
6576
5776
|
}),
|
|
5777
|
+
initialContentWidth: 24 + 4,
|
|
6577
5778
|
padding: 'sm'
|
|
6578
5779
|
},
|
|
6579
5780
|
disabled: disabled,
|
|
@@ -6857,6 +6058,7 @@ function SelectInputOptions({
|
|
|
6857
6058
|
})
|
|
6858
6059
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs("section", {
|
|
6859
6060
|
ref: listboxContainerRef,
|
|
6061
|
+
tabIndex: -1,
|
|
6860
6062
|
className: classNames__default.default('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
6861
6063
|
children: [resultsEmpty ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
6862
6064
|
id: statusId,
|
|
@@ -7482,7 +6684,6 @@ const Loader = ({
|
|
|
7482
6684
|
}, 1000);
|
|
7483
6685
|
}
|
|
7484
6686
|
return () => {
|
|
7485
|
-
// eslint-disable-next-line fp/no-mutation
|
|
7486
6687
|
cancelled = true;
|
|
7487
6688
|
clearTimeout(timeout);
|
|
7488
6689
|
};
|
|
@@ -9419,7 +8620,7 @@ const explodeNumberModel = number => {
|
|
|
9419
8620
|
};
|
|
9420
8621
|
};
|
|
9421
8622
|
|
|
9422
|
-
const DIGITS_MATCH = /^$|^(\+)|(
|
|
8623
|
+
const DIGITS_MATCH = /^$|^(\+)|(\d+)/g;
|
|
9423
8624
|
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
9424
8625
|
|
|
9425
8626
|
function sortArrayByProperty(arrayToSort, property) {
|
|
@@ -9505,7 +8706,8 @@ const PhoneNumberInput = ({
|
|
|
9505
8706
|
};
|
|
9506
8707
|
React.useEffect(() => {
|
|
9507
8708
|
if (broadcastedValue === null) {
|
|
9508
|
-
|
|
8709
|
+
setBroadcastedValue(internalValue);
|
|
8710
|
+
return;
|
|
9509
8711
|
}
|
|
9510
8712
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
9511
8713
|
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
@@ -9778,7 +8980,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
|
9778
8980
|
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
9779
8981
|
...commonProps,
|
|
9780
8982
|
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
9781
|
-
'aria-describedby': `${componentId}-title
|
|
8983
|
+
'aria-describedby': `${componentId}-title`,
|
|
9782
8984
|
'aria-disabled': isDisabled,
|
|
9783
8985
|
'data-value': value ?? undefined,
|
|
9784
8986
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -10431,8 +9633,8 @@ function Select({
|
|
|
10431
9633
|
}
|
|
10432
9634
|
};
|
|
10433
9635
|
function selectKeyboardFocusedOption() {
|
|
10434
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
10435
|
-
|
|
9636
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
9637
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
10436
9638
|
}
|
|
10437
9639
|
}
|
|
10438
9640
|
function moveFocusWithDifference(difference) {
|
|
@@ -10659,7 +9861,6 @@ function Select({
|
|
|
10659
9861
|
disabled: disabled,
|
|
10660
9862
|
"aria-controls": listboxId,
|
|
10661
9863
|
"aria-expanded": open,
|
|
10662
|
-
"aria-autocomplete": "none",
|
|
10663
9864
|
onClick: handleOnClick,
|
|
10664
9865
|
...buttonProps,
|
|
10665
9866
|
children: [selected ? /*#__PURE__*/jsxRuntime.jsx(Option$1, {
|
|
@@ -10775,12 +9976,11 @@ Select.defaultProps = {
|
|
|
10775
9976
|
|
|
10776
9977
|
const SegmentedControl = ({
|
|
10777
9978
|
name,
|
|
10778
|
-
|
|
9979
|
+
value,
|
|
10779
9980
|
mode = 'input',
|
|
10780
9981
|
segments,
|
|
10781
9982
|
onChange
|
|
10782
9983
|
}) => {
|
|
10783
|
-
const [selectedValue, setSelectedValue] = React.useState(defaultValue || segments[0].value);
|
|
10784
9984
|
const [animate, setAnimate] = React.useState(false);
|
|
10785
9985
|
const segmentsRef = React.useRef(null);
|
|
10786
9986
|
if (segments.length > 3) {
|
|
@@ -10791,7 +9991,7 @@ const SegmentedControl = ({
|
|
|
10791
9991
|
ref: /*#__PURE__*/React.createRef()
|
|
10792
9992
|
}));
|
|
10793
9993
|
const updateSegmentPosition = () => {
|
|
10794
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value ===
|
|
9994
|
+
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
|
|
10795
9995
|
// We grab the active segments style object from the ref
|
|
10796
9996
|
// and set the css variables to the selected segments width and x position.
|
|
10797
9997
|
// This is so we can animate the highlight to the selected segment
|
|
@@ -10804,6 +10004,7 @@ const SegmentedControl = ({
|
|
|
10804
10004
|
}
|
|
10805
10005
|
};
|
|
10806
10006
|
React.useEffect(() => {
|
|
10007
|
+
setAnimate(true);
|
|
10807
10008
|
updateSegmentPosition();
|
|
10808
10009
|
const handleWindowSizeChange = () => {
|
|
10809
10010
|
setAnimate(false);
|
|
@@ -10814,10 +10015,7 @@ const SegmentedControl = ({
|
|
|
10814
10015
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
10815
10016
|
};
|
|
10816
10017
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10817
|
-
}, [segmentsWithRefs,
|
|
10818
|
-
React.useEffect(() => {
|
|
10819
|
-
onChange(selectedValue);
|
|
10820
|
-
}, [onChange, selectedValue]);
|
|
10018
|
+
}, [segmentsWithRefs, value]);
|
|
10821
10019
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
10822
10020
|
ref: segmentsRef,
|
|
10823
10021
|
"data-testid": "segmented-control",
|
|
@@ -10829,50 +10027,50 @@ const SegmentedControl = ({
|
|
|
10829
10027
|
'segmented-control__segments--no-animate': !animate
|
|
10830
10028
|
}),
|
|
10831
10029
|
role: mode !== 'input' ? 'tablist' : undefined,
|
|
10832
|
-
children: segmentsWithRefs.map(segment =>
|
|
10833
|
-
|
|
10834
|
-
htmlFor: segment.id,
|
|
10835
|
-
className: classNames__default.default('segmented-control__segment', {
|
|
10836
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10837
|
-
}),
|
|
10838
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
10839
|
-
type: "radio",
|
|
10840
|
-
className: "segmented-control__radio-input",
|
|
10841
|
-
id: segment.id,
|
|
10842
|
-
name: name,
|
|
10843
|
-
value: segment.value,
|
|
10844
|
-
checked: selectedValue === segment.value,
|
|
10845
|
-
onChange: () => {
|
|
10846
|
-
setAnimate(true);
|
|
10847
|
-
setSelectedValue(segment.value);
|
|
10848
|
-
}
|
|
10849
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10850
|
-
className: "segmented-control__text",
|
|
10851
|
-
as: "span",
|
|
10852
|
-
type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10853
|
-
children: segment.label
|
|
10854
|
-
})]
|
|
10855
|
-
}, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
10856
|
-
ref: segment.ref,
|
|
10857
|
-
type: "button",
|
|
10858
|
-
role: "tab",
|
|
10859
|
-
id: segment.id,
|
|
10860
|
-
"aria-controls": segment.controls,
|
|
10861
|
-
"aria-selected": selectedValue === segment.value,
|
|
10862
|
-
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
10863
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10864
|
-
}),
|
|
10865
|
-
onClick: () => {
|
|
10030
|
+
children: segmentsWithRefs.map(segment => {
|
|
10031
|
+
const onSelect = () => {
|
|
10866
10032
|
setAnimate(true);
|
|
10867
|
-
|
|
10868
|
-
}
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10033
|
+
onChange(segment.value);
|
|
10034
|
+
};
|
|
10035
|
+
return mode === 'input' ? /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
10036
|
+
ref: segment.ref,
|
|
10037
|
+
htmlFor: segment.id,
|
|
10038
|
+
className: classNames__default.default('segmented-control__segment', {
|
|
10039
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10040
|
+
}),
|
|
10041
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
10042
|
+
type: "radio",
|
|
10043
|
+
className: "segmented-control__radio-input",
|
|
10044
|
+
id: segment.id,
|
|
10045
|
+
name: name,
|
|
10046
|
+
value: segment.value,
|
|
10047
|
+
checked: value === segment.value,
|
|
10048
|
+
onChange: onSelect
|
|
10049
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10050
|
+
className: "segmented-control__text",
|
|
10051
|
+
as: "span",
|
|
10052
|
+
type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10053
|
+
children: segment.label
|
|
10054
|
+
})]
|
|
10055
|
+
}, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
10056
|
+
ref: segment.ref,
|
|
10057
|
+
type: "button",
|
|
10058
|
+
role: "tab",
|
|
10059
|
+
id: segment.id,
|
|
10060
|
+
"aria-controls": segment.controls,
|
|
10061
|
+
"aria-selected": value === segment.value,
|
|
10062
|
+
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
10063
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10064
|
+
}),
|
|
10065
|
+
onClick: onSelect,
|
|
10066
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10067
|
+
as: "span",
|
|
10068
|
+
className: "segmented-control__text",
|
|
10069
|
+
type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10070
|
+
children: segment.label
|
|
10071
|
+
})
|
|
10072
|
+
}, segment.id);
|
|
10073
|
+
})
|
|
10876
10074
|
})
|
|
10877
10075
|
});
|
|
10878
10076
|
};
|
|
@@ -14866,10 +14064,10 @@ var th = {
|
|
|
14866
14064
|
"neptune.ClearButton.ariaLabel": "ล้าง",
|
|
14867
14065
|
"neptune.CloseButton.ariaLabel": "ปิด",
|
|
14868
14066
|
"neptune.DateInput.day.label": "วัน",
|
|
14869
|
-
"neptune.DateInput.day.placeholder": "
|
|
14067
|
+
"neptune.DateInput.day.placeholder": "วัน",
|
|
14870
14068
|
"neptune.DateInput.month.label": "เดือน",
|
|
14871
14069
|
"neptune.DateInput.year.label": "ปี",
|
|
14872
|
-
"neptune.DateInput.year.placeholder": "
|
|
14070
|
+
"neptune.DateInput.year.placeholder": "ปี",
|
|
14873
14071
|
"neptune.DateLookup.day": "วัน",
|
|
14874
14072
|
"neptune.DateLookup.goTo20YearView": "ไปที่มุมมอง 20 ปี",
|
|
14875
14073
|
"neptune.DateLookup.month": "เดือน",
|
|
@@ -15174,7 +14372,7 @@ const translations = {
|
|
|
15174
14372
|
exports.Accordion = Accordion;
|
|
15175
14373
|
exports.ActionButton = ActionButton;
|
|
15176
14374
|
exports.ActionOption = ActionOption;
|
|
15177
|
-
exports.Alert = Alert
|
|
14375
|
+
exports.Alert = Alert;
|
|
15178
14376
|
exports.Avatar = Avatar;
|
|
15179
14377
|
exports.AvatarWrapper = AvatarWrapper;
|
|
15180
14378
|
exports.Badge = Badge;
|
|
@@ -15194,7 +14392,7 @@ exports.CriticalCommsBanner = CriticalCommsBanner;
|
|
|
15194
14392
|
exports.DEFAULT_LANG = DEFAULT_LANG;
|
|
15195
14393
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
15196
14394
|
exports.DateInput = DateInput;
|
|
15197
|
-
exports.DateLookup = DateLookup
|
|
14395
|
+
exports.DateLookup = DateLookup;
|
|
15198
14396
|
exports.Decision = Decision;
|
|
15199
14397
|
exports.DefinitionList = DefinitionList$1;
|
|
15200
14398
|
exports.Dimmer = Dimmer$1;
|
|
@@ -15202,7 +14400,6 @@ exports.DirectionProvider = DirectionProvider;
|
|
|
15202
14400
|
exports.Display = Display;
|
|
15203
14401
|
exports.Drawer = Drawer$1;
|
|
15204
14402
|
exports.DropFade = DropFade;
|
|
15205
|
-
exports.DynamicFieldDefinitionList = DynamicFieldDefinitionList$1;
|
|
15206
14403
|
exports.Emphasis = Emphasis;
|
|
15207
14404
|
exports.FlowNavigation = FlowNavigation;
|
|
15208
14405
|
exports.Header = Header;
|