@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.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo,
|
|
4
|
+
import React__default, { forwardRef, cloneElement, useState, useEffect, useRef, useMemo, useCallback, useLayoutEffect, createContext, useContext, useImperativeHandle, createElement, Component, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { useId } from '@radix-ui/react-id';
|
|
6
|
-
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$
|
|
6
|
+
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
|
|
7
7
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
+
import commonmark from 'commonmark';
|
|
9
10
|
import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
10
|
-
import { formatDate,
|
|
11
|
+
import { formatDate, formatMoney, formatAmount } from '@transferwise/formatting';
|
|
11
12
|
import { Transition, Listbox } from '@headlessui/react';
|
|
12
13
|
import mergeProps from 'merge-props';
|
|
13
14
|
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
@@ -15,16 +16,14 @@ import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, Floa
|
|
|
15
16
|
import { FocusScope } from '@react-aria/focus';
|
|
16
17
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
17
18
|
import { CSSTransition } from 'react-transition-group';
|
|
19
|
+
import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
20
|
+
import { createPortal } from 'react-dom';
|
|
18
21
|
import { usePopper } from 'react-popper';
|
|
19
22
|
import throttle from 'lodash.throttle';
|
|
20
|
-
import { createPortal } from 'react-dom';
|
|
21
|
-
import { isUndefined, isKey, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
22
|
-
import commonmark from 'commonmark';
|
|
23
23
|
import { Flag, Illustration } from '@wise/art';
|
|
24
24
|
import clamp$2 from 'lodash.clamp';
|
|
25
25
|
import debounce from 'lodash.debounce';
|
|
26
26
|
import requiredIf from 'react-required-if';
|
|
27
|
-
import toPairs from 'lodash.topairs';
|
|
28
27
|
import { Spring, animated } from '@react-spring/web';
|
|
29
28
|
|
|
30
29
|
class HistoryNavigator {
|
|
@@ -63,7 +62,7 @@ var HistoryNavigator$1 = HistoryNavigator;
|
|
|
63
62
|
function isIosDevice() {
|
|
64
63
|
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
65
64
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
66
|
-
const regex = new RegExp(matchString, '
|
|
65
|
+
const regex = new RegExp(matchString, 'gi');
|
|
67
66
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -775,22 +774,22 @@ const Link = ({
|
|
|
775
774
|
});
|
|
776
775
|
};
|
|
777
776
|
|
|
777
|
+
const iconTypeMap = {
|
|
778
|
+
positive: Check,
|
|
779
|
+
neutral: Info$1,
|
|
780
|
+
warning: Alert$1,
|
|
781
|
+
negative: Cross,
|
|
782
|
+
pending: ClockBorderless,
|
|
783
|
+
info: Info$1,
|
|
784
|
+
error: Cross,
|
|
785
|
+
success: Check
|
|
786
|
+
};
|
|
778
787
|
const StatusIcon = ({
|
|
779
|
-
sentiment =
|
|
780
|
-
size =
|
|
788
|
+
sentiment = 'neutral',
|
|
789
|
+
size = 'md'
|
|
781
790
|
}) => {
|
|
782
|
-
const iconTypeMap = {
|
|
783
|
-
[Sentiment.POSITIVE]: Check,
|
|
784
|
-
[Sentiment.NEUTRAL]: Info$1,
|
|
785
|
-
[Sentiment.WARNING]: Alert$2,
|
|
786
|
-
[Sentiment.NEGATIVE]: Cross,
|
|
787
|
-
[Sentiment.PENDING]: ClockBorderless,
|
|
788
|
-
[Sentiment.INFO]: Info$1,
|
|
789
|
-
[Sentiment.ERROR]: Cross,
|
|
790
|
-
[Sentiment.SUCCESS]: Check
|
|
791
|
-
};
|
|
792
|
-
const iconColor = [Sentiment.WARNING, Sentiment.PENDING].includes(sentiment) ? 'dark' : 'light';
|
|
793
791
|
const Icon = iconTypeMap[sentiment];
|
|
792
|
+
const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
|
|
794
793
|
return /*#__PURE__*/jsx("span", {
|
|
795
794
|
"data-testid": "status-icon",
|
|
796
795
|
className: classNames('status-circle', 'status-circle-' + size, sentiment),
|
|
@@ -800,7 +799,7 @@ const StatusIcon = ({
|
|
|
800
799
|
});
|
|
801
800
|
};
|
|
802
801
|
|
|
803
|
-
function logActionRequired
|
|
802
|
+
function logActionRequired(message) {
|
|
804
803
|
if (['development', 'test'].includes(process?.env?.NODE_ENV)) {
|
|
805
804
|
// eslint-disable-next-line no-console
|
|
806
805
|
console.warn(message);
|
|
@@ -808,48 +807,10 @@ function logActionRequired$1(message) {
|
|
|
808
807
|
}
|
|
809
808
|
function logActionRequiredIf(message, conditional) {
|
|
810
809
|
if (conditional) {
|
|
811
|
-
logActionRequired
|
|
810
|
+
logActionRequired(message);
|
|
812
811
|
}
|
|
813
812
|
}
|
|
814
813
|
|
|
815
|
-
const deprecatedMessage = ({
|
|
816
|
-
component,
|
|
817
|
-
propName,
|
|
818
|
-
message,
|
|
819
|
-
expiryDate
|
|
820
|
-
}) => {
|
|
821
|
-
const messages = [`${component} has deprecated the use of ${propName}.`];
|
|
822
|
-
if (message) {
|
|
823
|
-
messages.push(message);
|
|
824
|
-
}
|
|
825
|
-
if (expiryDate) {
|
|
826
|
-
messages.push(`${propName} will be removed on or after ${expiryDate.toLocaleString('en-GB', {
|
|
827
|
-
year: 'numeric',
|
|
828
|
-
month: 'numeric',
|
|
829
|
-
day: 'numeric'
|
|
830
|
-
})}`);
|
|
831
|
-
}
|
|
832
|
-
return messages.join(' ');
|
|
833
|
-
};
|
|
834
|
-
const deprecated = (validator, {
|
|
835
|
-
component,
|
|
836
|
-
message = '',
|
|
837
|
-
newProp: newProperty = null,
|
|
838
|
-
expiryDate = null
|
|
839
|
-
}) => (props, propertyName, ...rest) => {
|
|
840
|
-
const newPropertyMessage = newProperty ? `Please use ${newProperty} instead.` : message;
|
|
841
|
-
if (props[propertyName] != null && typeof props[propertyName] !== 'undefined') {
|
|
842
|
-
logActionRequired$1(deprecatedMessage({
|
|
843
|
-
component,
|
|
844
|
-
propName: propertyName,
|
|
845
|
-
message: newPropertyMessage,
|
|
846
|
-
expiryDate
|
|
847
|
-
}));
|
|
848
|
-
}
|
|
849
|
-
return validator(props, propertyName, ...rest);
|
|
850
|
-
};
|
|
851
|
-
var deprecated$1 = deprecated;
|
|
852
|
-
|
|
853
814
|
const reader = new commonmark.Parser();
|
|
854
815
|
const writer = new commonmark.HtmlRenderer({
|
|
855
816
|
safe: true
|
|
@@ -869,7 +830,7 @@ function Markdown({
|
|
|
869
830
|
const linkTarget = config?.link?.target ?? '_self';
|
|
870
831
|
const paragraphClass = config?.paragraph?.className ?? '';
|
|
871
832
|
if (allowList != null && blockList != null) {
|
|
872
|
-
logActionRequired
|
|
833
|
+
logActionRequired('Markdown supports only one of `allowList` or `blockList` to be used at a time. `blockList` will be ignored.');
|
|
873
834
|
}
|
|
874
835
|
const parser = nodes => {
|
|
875
836
|
const parsed = reader.parse(nodes);
|
|
@@ -930,146 +891,99 @@ InlineMarkdown.defaultProps = {
|
|
|
930
891
|
};
|
|
931
892
|
var InlineMarkdown$1 = InlineMarkdown;
|
|
932
893
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
};
|
|
953
|
-
AlertWithArrow.defaultProps = {
|
|
954
|
-
className: undefined
|
|
955
|
-
};
|
|
956
|
-
return AlertWithArrow;
|
|
957
|
-
}
|
|
958
|
-
function arrowClasses(arrow) {
|
|
959
|
-
if (arrow) {
|
|
960
|
-
const classes = ['arrow'];
|
|
961
|
-
const {
|
|
962
|
-
BOTTOM,
|
|
963
|
-
BOTTOM_LEFT,
|
|
964
|
-
BOTTOM_RIGHT,
|
|
965
|
-
TOP,
|
|
966
|
-
TOP_RIGHT,
|
|
967
|
-
TOP_LEFT
|
|
968
|
-
} = ArrowPosition;
|
|
969
|
-
switch (arrow) {
|
|
970
|
-
case BOTTOM:
|
|
971
|
-
return classes.concat('arrow-bottom', 'arrow-center');
|
|
972
|
-
case BOTTOM_LEFT:
|
|
973
|
-
return classes.concat('arrow-bottom', 'arrow-left');
|
|
974
|
-
case BOTTOM_RIGHT:
|
|
975
|
-
return classes.concat('arrow-bottom', 'arrow-right');
|
|
976
|
-
case TOP:
|
|
977
|
-
return classes.concat('arrow-center');
|
|
978
|
-
case TOP_RIGHT:
|
|
979
|
-
return classes.concat('arrow-right');
|
|
980
|
-
case TOP_LEFT:
|
|
981
|
-
default:
|
|
982
|
-
return classes;
|
|
983
|
-
}
|
|
894
|
+
var AlertArrowPosition;
|
|
895
|
+
(function (AlertArrowPosition) {
|
|
896
|
+
AlertArrowPosition["TOP_LEFT"] = "up-left";
|
|
897
|
+
AlertArrowPosition["TOP"] = "up-center";
|
|
898
|
+
AlertArrowPosition["TOP_RIGHT"] = "up-right";
|
|
899
|
+
AlertArrowPosition["BOTTOM_LEFT"] = "down-left";
|
|
900
|
+
AlertArrowPosition["BOTTOM"] = "down-center";
|
|
901
|
+
AlertArrowPosition["BOTTOM_RIGHT"] = "down-right";
|
|
902
|
+
})(AlertArrowPosition || (AlertArrowPosition = {}));
|
|
903
|
+
function resolveType(type) {
|
|
904
|
+
switch (type) {
|
|
905
|
+
case 'success':
|
|
906
|
+
return 'positive';
|
|
907
|
+
case 'info':
|
|
908
|
+
return 'neutral';
|
|
909
|
+
case 'error':
|
|
910
|
+
return 'negative';
|
|
911
|
+
default:
|
|
912
|
+
return type;
|
|
984
913
|
}
|
|
985
|
-
return '';
|
|
986
914
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const [shouldFire, setShouldFire] = useState(false);
|
|
1005
|
-
const {
|
|
1006
|
-
arrow,
|
|
1007
|
-
action,
|
|
1008
|
-
children,
|
|
1009
|
-
className,
|
|
1010
|
-
icon,
|
|
1011
|
-
onDismiss,
|
|
1012
|
-
message,
|
|
1013
|
-
title,
|
|
1014
|
-
type,
|
|
1015
|
-
variant
|
|
1016
|
-
} = props;
|
|
1017
|
-
const closeButtonReference = useRef(null);
|
|
1018
|
-
if (arrow) {
|
|
1019
|
-
const AlertWithArrow = withArrow(Alert, arrow);
|
|
1020
|
-
return /*#__PURE__*/jsx(AlertWithArrow, {
|
|
1021
|
-
...props
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
logActionRequired(props);
|
|
1025
|
-
const mappedType = deprecatedTypeMap$1[type] || type;
|
|
1026
|
-
const Icon = iconTypeMap[mappedType];
|
|
1027
|
-
function generateIcon() {
|
|
1028
|
-
if (icon) {
|
|
1029
|
-
return /*#__PURE__*/jsx("div", {
|
|
1030
|
-
className: "alert__icon",
|
|
1031
|
-
children: icon
|
|
1032
|
-
});
|
|
915
|
+
function Alert({
|
|
916
|
+
arrow,
|
|
917
|
+
action,
|
|
918
|
+
children,
|
|
919
|
+
className,
|
|
920
|
+
dismissible,
|
|
921
|
+
icon,
|
|
922
|
+
onDismiss,
|
|
923
|
+
message,
|
|
924
|
+
size,
|
|
925
|
+
title,
|
|
926
|
+
type = 'neutral',
|
|
927
|
+
variant = 'desktop'
|
|
928
|
+
}) {
|
|
929
|
+
useEffect(() => {
|
|
930
|
+
if (arrow !== undefined) {
|
|
931
|
+
logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.");
|
|
1033
932
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
});
|
|
1039
|
-
} else {
|
|
1040
|
-
return /*#__PURE__*/jsx(Icon, {
|
|
1041
|
-
size: 24
|
|
1042
|
-
});
|
|
933
|
+
}, [arrow]);
|
|
934
|
+
useEffect(() => {
|
|
935
|
+
if (children !== undefined) {
|
|
936
|
+
logActionRequired("Alert component doesn't support 'children' anymore, use 'message' instead.");
|
|
1043
937
|
}
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
938
|
+
}, [children]);
|
|
939
|
+
useEffect(() => {
|
|
940
|
+
if (dismissible !== undefined) {
|
|
941
|
+
logActionRequired("Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.");
|
|
942
|
+
}
|
|
943
|
+
}, [dismissible]);
|
|
944
|
+
useEffect(() => {
|
|
945
|
+
if (size !== undefined) {
|
|
946
|
+
logActionRequired("Alert component doesn't support 'size' anymore, please remove that prop.");
|
|
947
|
+
}
|
|
948
|
+
}, [size]);
|
|
949
|
+
const resolvedType = resolveType(type);
|
|
950
|
+
useEffect(() => {
|
|
951
|
+
if (resolvedType !== type) {
|
|
952
|
+
logActionRequired(`Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`);
|
|
953
|
+
}
|
|
954
|
+
}, [resolvedType, type]);
|
|
955
|
+
const [shouldFire, setShouldFire] = useState(false);
|
|
956
|
+
const closeButtonReference = useRef(null);
|
|
957
|
+
return /*#__PURE__*/jsxs("div", {
|
|
958
|
+
className: classNames('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
|
|
959
|
+
"data-testid": "alert",
|
|
960
|
+
onTouchStart: () => setShouldFire(true),
|
|
961
|
+
onTouchEnd: event => {
|
|
962
|
+
if (shouldFire && action &&
|
|
1049
963
|
// Check if current event is triggered from closeButton
|
|
1050
|
-
|
|
1051
|
-
if (action
|
|
1052
|
-
window.top
|
|
964
|
+
event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
|
|
965
|
+
if (action.target === '_blank') {
|
|
966
|
+
window.top?.open(action.href);
|
|
1053
967
|
} else {
|
|
1054
|
-
window.top
|
|
968
|
+
window.top?.location.assign(action.href);
|
|
1055
969
|
}
|
|
1056
970
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
return /*#__PURE__*/jsxs("div", {
|
|
1061
|
-
className: classNames('alert d-flex', `alert-${mappedType}`, className),
|
|
1062
|
-
"data-testid": "alert",
|
|
1063
|
-
onTouchStart: handleTouchStart,
|
|
1064
|
-
onTouchEnd: handleTouchEnd,
|
|
1065
|
-
onTouchMove: handleTouchMove,
|
|
971
|
+
setShouldFire(false);
|
|
972
|
+
},
|
|
973
|
+
onTouchMove: () => setShouldFire(false),
|
|
1066
974
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1067
975
|
className: classNames('alert__content', 'd-flex', 'flex-grow-1', variant),
|
|
1068
976
|
"data-testid": variant,
|
|
1069
|
-
children: [
|
|
977
|
+
children: [icon ? /*#__PURE__*/jsx("div", {
|
|
978
|
+
className: "alert__icon",
|
|
979
|
+
children: icon
|
|
980
|
+
}) : /*#__PURE__*/jsx(StatusIcon, {
|
|
981
|
+
size: Size.LARGE,
|
|
982
|
+
sentiment: resolvedType
|
|
983
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1070
984
|
className: "alert__message",
|
|
1071
985
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1072
|
-
role: Sentiment.NEGATIVE ===
|
|
986
|
+
role: Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status',
|
|
1073
987
|
children: [title && /*#__PURE__*/jsx(Title, {
|
|
1074
988
|
className: "m-b-1",
|
|
1075
989
|
type: Typography.TITLE_BODY,
|
|
@@ -1097,72 +1011,24 @@ const Alert = props => {
|
|
|
1097
1011
|
onClick: onDismiss
|
|
1098
1012
|
})]
|
|
1099
1013
|
});
|
|
1100
|
-
};
|
|
1101
|
-
const deprecatedTypeMapMessage$1 = {
|
|
1102
|
-
[Sentiment.SUCCESS]: 'Sentiment.POSITIVE',
|
|
1103
|
-
[Sentiment.INFO]: 'Sentiment.NEUTRAL',
|
|
1104
|
-
[Sentiment.ERROR]: 'Sentiment.NEGATIVE'
|
|
1105
|
-
};
|
|
1106
|
-
const deprecatedTypes$1 = Object.keys(deprecatedTypeMap$1);
|
|
1107
|
-
function logActionRequired({
|
|
1108
|
-
size,
|
|
1109
|
-
type
|
|
1110
|
-
}) {
|
|
1111
|
-
logActionRequiredIf('Alert no longer supports any possible variations in size. Please remove the `size` prop.', !!size);
|
|
1112
|
-
logActionRequiredIf(`Alert has deprecated the ${type} value for the \`type\` prop. Please update to ${deprecatedTypeMapMessage$1[type]}.`, deprecatedTypes$1.includes(type));
|
|
1113
1014
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
/** The presence of the onDismiss handler will trigger the visibility of the close button */
|
|
1132
|
-
onDismiss: PropTypes.func,
|
|
1133
|
-
/** The type dictates which icon and colour will be used */
|
|
1134
|
-
type: PropTypes.oneOf(['negative', 'neutral', 'positive', 'warning', 'info', 'error', 'success']),
|
|
1135
|
-
variant: PropTypes.oneOf(['desktop', 'mobile']),
|
|
1136
|
-
/** @deprecated no arrow for `Alert` component anymore, consider to use [`InlineAlert`](https://transferwise.github.io/neptune-web/components/alerts/InlineAlert) component */
|
|
1137
|
-
arrow: deprecated$1(PropTypes.oneOf(['up-left', 'up-center', 'up-right', 'down-left', 'down-center', 'down-right']), {
|
|
1138
|
-
component: 'Alert',
|
|
1139
|
-
expiryDate: new Date('03-01-2021')
|
|
1140
|
-
}),
|
|
1141
|
-
/** @deprecated use `message` property instead */
|
|
1142
|
-
children: deprecated$1(requiredIf(PropTypes.node, ({
|
|
1143
|
-
message
|
|
1144
|
-
}) => !message), {
|
|
1145
|
-
component: 'Alert',
|
|
1146
|
-
message: 'You should now use the `message` prop. Be aware `message` only accepts plain text or text with **bold** markdown.',
|
|
1147
|
-
expiryDate: new Date('03-01-2021')
|
|
1148
|
-
}),
|
|
1149
|
-
/** @deprecated use `onDismiss` instead */
|
|
1150
|
-
dismissible: deprecated$1(PropTypes.bool, {
|
|
1151
|
-
component: 'Alert',
|
|
1152
|
-
message: 'The Alert will now be considered dismissible if an `onDismiss` hander is present.',
|
|
1153
|
-
expiryDate: new Date('03-01-2021')
|
|
1154
|
-
})
|
|
1155
|
-
};
|
|
1156
|
-
Alert.defaultProps = {
|
|
1157
|
-
action: undefined,
|
|
1158
|
-
arrow: undefined,
|
|
1159
|
-
className: undefined,
|
|
1160
|
-
dismissible: undefined,
|
|
1161
|
-
icon: undefined,
|
|
1162
|
-
type: Sentiment.NEUTRAL,
|
|
1163
|
-
variant: Variant.DESKTOP
|
|
1164
|
-
};
|
|
1165
|
-
var Alert$1 = Alert;
|
|
1015
|
+
function alertArrowClassNames(arrow) {
|
|
1016
|
+
switch (arrow) {
|
|
1017
|
+
case 'down-center':
|
|
1018
|
+
return 'arrow arrow-bottom arrow-center';
|
|
1019
|
+
case 'down-left':
|
|
1020
|
+
return 'arrow arrow-bottom arrow-left';
|
|
1021
|
+
case 'down-right':
|
|
1022
|
+
return 'arrow arrow-bottom arrow-right';
|
|
1023
|
+
case 'up-center':
|
|
1024
|
+
return 'arrow arrow-center';
|
|
1025
|
+
case 'up-right':
|
|
1026
|
+
return 'arrow arrow-right';
|
|
1027
|
+
case 'up-left':
|
|
1028
|
+
default:
|
|
1029
|
+
return 'arrow';
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1166
1032
|
|
|
1167
1033
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
1168
1034
|
var AvatarType;
|
|
@@ -1190,7 +1056,7 @@ const hashSeed = seed => {
|
|
|
1190
1056
|
const modulo = avatarColors.length;
|
|
1191
1057
|
let hashValue = 0;
|
|
1192
1058
|
let basePow = 1;
|
|
1193
|
-
for (let i = 0; i < seed.length; i
|
|
1059
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
1194
1060
|
hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
|
|
1195
1061
|
basePow = basePow * base % modulo;
|
|
1196
1062
|
}
|
|
@@ -1388,6 +1254,7 @@ const FocusBoundary = ({
|
|
|
1388
1254
|
})
|
|
1389
1255
|
});
|
|
1390
1256
|
};
|
|
1257
|
+
var FocusBoundary$1 = FocusBoundary;
|
|
1391
1258
|
|
|
1392
1259
|
function withNextPortalWrapper(Component) {
|
|
1393
1260
|
return function (props) {
|
|
@@ -1481,11 +1348,15 @@ const Dimmer = ({
|
|
|
1481
1348
|
}, [onClose]);
|
|
1482
1349
|
const onEnter = () => {
|
|
1483
1350
|
setHasNotExited(true);
|
|
1484
|
-
|
|
1351
|
+
if (dimmerReference.current) {
|
|
1352
|
+
dimmerManager.add(dimmerReference.current);
|
|
1353
|
+
}
|
|
1485
1354
|
};
|
|
1486
1355
|
const onExited = () => {
|
|
1487
1356
|
setHasNotExited(false);
|
|
1488
|
-
|
|
1357
|
+
if (dimmerReference.current) {
|
|
1358
|
+
dimmerManager.remove(dimmerReference.current);
|
|
1359
|
+
}
|
|
1489
1360
|
};
|
|
1490
1361
|
useEffect(() => {
|
|
1491
1362
|
const localReferenceCopy = dimmerReference.current;
|
|
@@ -1529,7 +1400,7 @@ const Dimmer = ({
|
|
|
1529
1400
|
onExited: onExited,
|
|
1530
1401
|
children: /*#__PURE__*/jsx(DimmerContentWrapper, {
|
|
1531
1402
|
scrollBody: !transparent,
|
|
1532
|
-
children: /*#__PURE__*/jsx(FocusBoundary, {
|
|
1403
|
+
children: /*#__PURE__*/jsx(FocusBoundary$1, {
|
|
1533
1404
|
children: /*#__PURE__*/jsx("div", {
|
|
1534
1405
|
ref: dimmerReference,
|
|
1535
1406
|
className: classNames('dimmer', {
|
|
@@ -2161,7 +2032,7 @@ var messages$b = defineMessages({
|
|
|
2161
2032
|
}
|
|
2162
2033
|
});
|
|
2163
2034
|
|
|
2164
|
-
const typeClassMap
|
|
2035
|
+
const typeClassMap = {
|
|
2165
2036
|
[ControlType.ACCENT]: 'btn-accent',
|
|
2166
2037
|
[ControlType.POSITIVE]: 'btn-positive',
|
|
2167
2038
|
[ControlType.NEGATIVE]: 'btn-negative'
|
|
@@ -2245,7 +2116,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
2245
2116
|
},
|
|
2246
2117
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
2247
2118
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2248
|
-
typeClassMap
|
|
2119
|
+
typeClassMap[newType],
|
|
2249
2120
|
// @ts-expect-error fix when refactor `typeClassMap` to TypeScript
|
|
2250
2121
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2251
2122
|
priorityClassMap[newPriority], className);
|
|
@@ -2630,7 +2501,7 @@ const CircularButton = ({
|
|
|
2630
2501
|
type = ControlType.ACCENT,
|
|
2631
2502
|
...rest
|
|
2632
2503
|
}) => {
|
|
2633
|
-
const classes = classNames('btn np-btn', typeClassMap
|
|
2504
|
+
const classes = classNames('btn np-btn', typeClassMap[type], priorityClassMap[priority]);
|
|
2634
2505
|
const iconElement = Number(icon.props.size) !== 24 ? /*#__PURE__*/cloneElement(icon, {
|
|
2635
2506
|
size: 24
|
|
2636
2507
|
}) : icon;
|
|
@@ -2665,11 +2536,17 @@ function getDayNames(locale, format = 'short') {
|
|
|
2665
2536
|
|
|
2666
2537
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
2667
2538
|
function moveToWithinRange(date, min, max) {
|
|
2668
|
-
|
|
2539
|
+
if (min && date < min) {
|
|
2540
|
+
return new Date(min);
|
|
2541
|
+
}
|
|
2542
|
+
if (max && date > max) {
|
|
2543
|
+
return new Date(max);
|
|
2544
|
+
}
|
|
2545
|
+
return date;
|
|
2669
2546
|
}
|
|
2670
2547
|
|
|
2671
2548
|
function isWithinRange(date, min, max) {
|
|
2672
|
-
return
|
|
2549
|
+
return (!min || date >= min) && (!max || date <= max);
|
|
2673
2550
|
}
|
|
2674
2551
|
|
|
2675
2552
|
const getMonthNames = (locale, format = 'long') => {
|
|
@@ -3193,7 +3070,7 @@ var dateTriggerMessages = defineMessages({
|
|
|
3193
3070
|
|
|
3194
3071
|
const DateTrigger = ({
|
|
3195
3072
|
selectedDate,
|
|
3196
|
-
size,
|
|
3073
|
+
size = Size.MEDIUM,
|
|
3197
3074
|
placeholder,
|
|
3198
3075
|
label,
|
|
3199
3076
|
monthFormat,
|
|
@@ -3205,19 +3082,6 @@ const DateTrigger = ({
|
|
|
3205
3082
|
locale,
|
|
3206
3083
|
formatMessage
|
|
3207
3084
|
} = useIntl();
|
|
3208
|
-
const handleKeyDown = event => {
|
|
3209
|
-
if (isKey({
|
|
3210
|
-
keyType: 'Space',
|
|
3211
|
-
event: event
|
|
3212
|
-
}) || isKey({
|
|
3213
|
-
keyType: 'Enter',
|
|
3214
|
-
event: event
|
|
3215
|
-
})) {
|
|
3216
|
-
event.stopPropagation();
|
|
3217
|
-
event.preventDefault();
|
|
3218
|
-
onClear();
|
|
3219
|
-
}
|
|
3220
|
-
};
|
|
3221
3085
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3222
3086
|
children: [/*#__PURE__*/jsxs("button", {
|
|
3223
3087
|
className: `btn btn-${size} btn-input np-date-trigger`,
|
|
@@ -3254,29 +3118,12 @@ const DateTrigger = ({
|
|
|
3254
3118
|
event.stopPropagation();
|
|
3255
3119
|
event.preventDefault();
|
|
3256
3120
|
onClear();
|
|
3257
|
-
}
|
|
3258
|
-
onKeyPress: handleKeyDown
|
|
3121
|
+
}
|
|
3259
3122
|
})
|
|
3260
3123
|
})]
|
|
3261
3124
|
}) : null]
|
|
3262
3125
|
});
|
|
3263
3126
|
};
|
|
3264
|
-
DateTrigger.propTypes = {
|
|
3265
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3266
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
3267
|
-
placeholder: PropTypes.string.isRequired,
|
|
3268
|
-
label: PropTypes.string.isRequired,
|
|
3269
|
-
monthFormat: PropTypes.oneOf(['short', 'long']).isRequired,
|
|
3270
|
-
disabled: PropTypes.bool.isRequired,
|
|
3271
|
-
onClick: PropTypes.func,
|
|
3272
|
-
onClear: PropTypes.func
|
|
3273
|
-
};
|
|
3274
|
-
DateTrigger.defaultProps = {
|
|
3275
|
-
selectedDate: null,
|
|
3276
|
-
size: Size.MEDIUM,
|
|
3277
|
-
onClear: undefined
|
|
3278
|
-
};
|
|
3279
|
-
var DateTrigger$1 = DateTrigger;
|
|
3280
3127
|
|
|
3281
3128
|
var messages$8 = defineMessages({
|
|
3282
3129
|
next: {
|
|
@@ -3358,18 +3205,6 @@ const DateHeader = ({
|
|
|
3358
3205
|
})]
|
|
3359
3206
|
});
|
|
3360
3207
|
};
|
|
3361
|
-
DateHeader.propTypes = {
|
|
3362
|
-
label: PropTypes.string,
|
|
3363
|
-
onLabelClick: PropTypes.func,
|
|
3364
|
-
onPreviousClick: PropTypes.func.isRequired,
|
|
3365
|
-
onNextClick: PropTypes.func.isRequired,
|
|
3366
|
-
dateMode: PropTypes.string
|
|
3367
|
-
};
|
|
3368
|
-
DateHeader.defaultProps = {
|
|
3369
|
-
label: null,
|
|
3370
|
-
onLabelClick: () => {}
|
|
3371
|
-
};
|
|
3372
|
-
var DateHeader$1 = DateHeader;
|
|
3373
3208
|
|
|
3374
3209
|
function getFocusableTime(props) {
|
|
3375
3210
|
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));
|
|
@@ -3455,10 +3290,9 @@ class DayCalendarTable extends PureComponent {
|
|
|
3455
3290
|
let week = [];
|
|
3456
3291
|
const weeks = [];
|
|
3457
3292
|
let i;
|
|
3458
|
-
|
|
3459
3293
|
// Pad first week
|
|
3460
3294
|
for (i = 1; i < firstDayOfMonth; i += 1) {
|
|
3461
|
-
week.push(
|
|
3295
|
+
week.push(-1);
|
|
3462
3296
|
}
|
|
3463
3297
|
// Fill in days
|
|
3464
3298
|
for (i = 1; i <= daysInMonth; i += 1) {
|
|
@@ -3471,7 +3305,7 @@ class DayCalendarTable extends PureComponent {
|
|
|
3471
3305
|
if (week.length > 0) {
|
|
3472
3306
|
// Pad last week
|
|
3473
3307
|
for (i = week.length; i < 7; i += 1) {
|
|
3474
|
-
week.push(
|
|
3308
|
+
week.push(-1);
|
|
3475
3309
|
}
|
|
3476
3310
|
weeks.push(week);
|
|
3477
3311
|
}
|
|
@@ -3526,12 +3360,10 @@ class DayCalendarTable extends PureComponent {
|
|
|
3526
3360
|
const {
|
|
3527
3361
|
viewMonth,
|
|
3528
3362
|
viewYear,
|
|
3529
|
-
intl
|
|
3530
|
-
locale
|
|
3531
|
-
}
|
|
3363
|
+
intl
|
|
3532
3364
|
} = this.props;
|
|
3533
3365
|
const weeks = this.getTableStructure();
|
|
3534
|
-
|
|
3366
|
+
const autoFocusDay = this.getAutofocusDay(weeks);
|
|
3535
3367
|
return /*#__PURE__*/jsxs("table", {
|
|
3536
3368
|
className: "table table-condensed table-bordered tw-date-lookup-calendar m-b-0",
|
|
3537
3369
|
children: [/*#__PURE__*/jsx("thead", {
|
|
@@ -3557,12 +3389,12 @@ class DayCalendarTable extends PureComponent {
|
|
|
3557
3389
|
children: weeks.map((week, weekIndex) => /*#__PURE__*/jsx("tr", {
|
|
3558
3390
|
children: week.map((day, dayIndex) => /*#__PURE__*/jsx("td", {
|
|
3559
3391
|
className: dayIndex > 4 ? 'weekend' : '',
|
|
3560
|
-
children: day && /*#__PURE__*/jsx(TableLink, {
|
|
3392
|
+
children: day !== -1 && /*#__PURE__*/jsx(TableLink, {
|
|
3561
3393
|
item: day,
|
|
3562
3394
|
type: "day",
|
|
3563
|
-
title: formatDate(new Date(viewYear, viewMonth, day), locale, SHORT_DAY_FORMAT),
|
|
3395
|
+
title: formatDate(new Date(viewYear, viewMonth, day), intl.locale, SHORT_DAY_FORMAT),
|
|
3564
3396
|
autofocus: day === autoFocusDay,
|
|
3565
|
-
longTitle: formatDate(new Date(viewYear, viewMonth, day), locale),
|
|
3397
|
+
longTitle: formatDate(new Date(viewYear, viewMonth, day), intl.locale),
|
|
3566
3398
|
active: this.isActive(day),
|
|
3567
3399
|
disabled: this.isDisabled(day),
|
|
3568
3400
|
today: this.isToday(day),
|
|
@@ -3574,19 +3406,6 @@ class DayCalendarTable extends PureComponent {
|
|
|
3574
3406
|
});
|
|
3575
3407
|
}
|
|
3576
3408
|
}
|
|
3577
|
-
DayCalendarTable.propTypes = {
|
|
3578
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3579
|
-
min: PropTypes.instanceOf(Date),
|
|
3580
|
-
max: PropTypes.instanceOf(Date),
|
|
3581
|
-
viewMonth: PropTypes.number.isRequired,
|
|
3582
|
-
viewYear: PropTypes.number.isRequired,
|
|
3583
|
-
onSelect: PropTypes.func.isRequired
|
|
3584
|
-
};
|
|
3585
|
-
DayCalendarTable.defaultProps = {
|
|
3586
|
-
selectedDate: null,
|
|
3587
|
-
min: null,
|
|
3588
|
-
max: null
|
|
3589
|
-
};
|
|
3590
3409
|
var DayCalendarTable$1 = injectIntl(DayCalendarTable);
|
|
3591
3410
|
|
|
3592
3411
|
class DayCalendar extends PureComponent {
|
|
@@ -3626,7 +3445,7 @@ class DayCalendar extends PureComponent {
|
|
|
3626
3445
|
onSelect
|
|
3627
3446
|
} = this.props;
|
|
3628
3447
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3629
|
-
children: [/*#__PURE__*/jsx(DateHeader
|
|
3448
|
+
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3630
3449
|
label: formatDate(new Date(viewYear, viewMonth), locale, {
|
|
3631
3450
|
month: monthFormat,
|
|
3632
3451
|
year: 'numeric'
|
|
@@ -3646,22 +3465,6 @@ class DayCalendar extends PureComponent {
|
|
|
3646
3465
|
});
|
|
3647
3466
|
}
|
|
3648
3467
|
}
|
|
3649
|
-
DayCalendar.propTypes = {
|
|
3650
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3651
|
-
min: PropTypes.instanceOf(Date),
|
|
3652
|
-
max: PropTypes.instanceOf(Date),
|
|
3653
|
-
viewMonth: PropTypes.number.isRequired,
|
|
3654
|
-
viewYear: PropTypes.number.isRequired,
|
|
3655
|
-
monthFormat: PropTypes.oneOf([MonthFormat.LONG, MonthFormat.SHORT]).isRequired,
|
|
3656
|
-
onSelect: PropTypes.func.isRequired,
|
|
3657
|
-
onLabelClick: PropTypes.func.isRequired,
|
|
3658
|
-
onViewDateUpdate: PropTypes.func.isRequired
|
|
3659
|
-
};
|
|
3660
|
-
DayCalendar.defaultProps = {
|
|
3661
|
-
selectedDate: null,
|
|
3662
|
-
min: null,
|
|
3663
|
-
max: null
|
|
3664
|
-
};
|
|
3665
3468
|
var DayCalendar$1 = injectIntl(DayCalendar);
|
|
3666
3469
|
|
|
3667
3470
|
const ROWS$1 = 3;
|
|
@@ -3693,7 +3496,7 @@ const MonthCalendarTable = ({
|
|
|
3693
3496
|
});
|
|
3694
3497
|
};
|
|
3695
3498
|
const isActive = month => {
|
|
3696
|
-
return selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear();
|
|
3499
|
+
return !!(selectedDate && month === selectedDate.getMonth() && viewYear === selectedDate.getFullYear());
|
|
3697
3500
|
};
|
|
3698
3501
|
const isThisMonth = month => {
|
|
3699
3502
|
return viewYear === new Date().getFullYear() && month === new Date().getMonth();
|
|
@@ -3703,7 +3506,9 @@ const MonthCalendarTable = ({
|
|
|
3703
3506
|
return !!(min && date < new Date(min.getFullYear(), min.getMonth()) || max && date > new Date(max.getFullYear(), max.getMonth()));
|
|
3704
3507
|
};
|
|
3705
3508
|
const autofocusMonth = (() => {
|
|
3706
|
-
const months =
|
|
3509
|
+
const months = Array.from({
|
|
3510
|
+
length: ROWS$1 * COLS$1
|
|
3511
|
+
}, (_, index) => index);
|
|
3707
3512
|
return getFocusableTime({
|
|
3708
3513
|
isActive,
|
|
3709
3514
|
isNow: isThisMonth,
|
|
@@ -3717,33 +3522,23 @@ const MonthCalendarTable = ({
|
|
|
3717
3522
|
className: "sr-only",
|
|
3718
3523
|
children: /*#__PURE__*/jsx("tr", {
|
|
3719
3524
|
children: /*#__PURE__*/jsx("th", {
|
|
3720
|
-
colSpan:
|
|
3525
|
+
colSpan: COLS$1,
|
|
3721
3526
|
children: placeholder
|
|
3722
3527
|
})
|
|
3723
3528
|
})
|
|
3724
3529
|
}), /*#__PURE__*/jsx("tbody", {
|
|
3725
|
-
children:
|
|
3726
|
-
|
|
3530
|
+
children: Array.from({
|
|
3531
|
+
length: ROWS$1
|
|
3532
|
+
}, (_, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3533
|
+
children: Array.from({
|
|
3534
|
+
length: COLS$1
|
|
3535
|
+
}, (_, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3727
3536
|
children: getLink(rowIndex * COLS$1 + colIndex)
|
|
3728
3537
|
}, colIndex))
|
|
3729
3538
|
}, rowIndex))
|
|
3730
3539
|
})]
|
|
3731
3540
|
});
|
|
3732
3541
|
};
|
|
3733
|
-
MonthCalendarTable.propTypes = {
|
|
3734
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3735
|
-
min: PropTypes.instanceOf(Date),
|
|
3736
|
-
max: PropTypes.instanceOf(Date),
|
|
3737
|
-
viewYear: PropTypes.number.isRequired,
|
|
3738
|
-
placeholder: PropTypes.string.isRequired,
|
|
3739
|
-
onSelect: PropTypes.func.isRequired
|
|
3740
|
-
};
|
|
3741
|
-
MonthCalendarTable.defaultProps = {
|
|
3742
|
-
selectedDate: null,
|
|
3743
|
-
min: null,
|
|
3744
|
-
max: null
|
|
3745
|
-
};
|
|
3746
|
-
var MonthCalendarTable$1 = MonthCalendarTable;
|
|
3747
3542
|
|
|
3748
3543
|
class MonthCalendar extends PureComponent {
|
|
3749
3544
|
onMonthSelect = month => {
|
|
@@ -3776,7 +3571,7 @@ class MonthCalendar extends PureComponent {
|
|
|
3776
3571
|
onLabelClick
|
|
3777
3572
|
} = this.props;
|
|
3778
3573
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3779
|
-
children: [/*#__PURE__*/jsx(DateHeader
|
|
3574
|
+
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3780
3575
|
dateMode: formatMessage(messages$8.year),
|
|
3781
3576
|
label: formatDate(new Date(viewYear, 0), locale, {
|
|
3782
3577
|
year: 'numeric'
|
|
@@ -3784,32 +3579,17 @@ class MonthCalendar extends PureComponent {
|
|
|
3784
3579
|
onLabelClick: onLabelClick,
|
|
3785
3580
|
onPreviousClick: this.selectPreviousYear,
|
|
3786
3581
|
onNextClick: this.selectNextYear
|
|
3787
|
-
}), /*#__PURE__*/jsx(MonthCalendarTable
|
|
3788
|
-
selectedDate,
|
|
3789
|
-
min,
|
|
3790
|
-
max,
|
|
3791
|
-
viewYear,
|
|
3792
|
-
placeholder,
|
|
3582
|
+
}), /*#__PURE__*/jsx(MonthCalendarTable, {
|
|
3583
|
+
selectedDate: selectedDate,
|
|
3584
|
+
min: min,
|
|
3585
|
+
max: max,
|
|
3586
|
+
viewYear: viewYear,
|
|
3587
|
+
placeholder: placeholder,
|
|
3793
3588
|
onSelect: this.onMonthSelect
|
|
3794
3589
|
})]
|
|
3795
3590
|
});
|
|
3796
3591
|
}
|
|
3797
3592
|
}
|
|
3798
|
-
MonthCalendar.propTypes = {
|
|
3799
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3800
|
-
min: PropTypes.instanceOf(Date),
|
|
3801
|
-
max: PropTypes.instanceOf(Date),
|
|
3802
|
-
viewYear: PropTypes.number.isRequired,
|
|
3803
|
-
placeholder: PropTypes.string.isRequired,
|
|
3804
|
-
onSelect: PropTypes.func.isRequired,
|
|
3805
|
-
onLabelClick: PropTypes.func.isRequired,
|
|
3806
|
-
onViewDateUpdate: PropTypes.func.isRequired
|
|
3807
|
-
};
|
|
3808
|
-
MonthCalendar.defaultProps = {
|
|
3809
|
-
selectedDate: null,
|
|
3810
|
-
min: null,
|
|
3811
|
-
max: null
|
|
3812
|
-
};
|
|
3813
3593
|
var MonthCalendar$1 = injectIntl(MonthCalendar);
|
|
3814
3594
|
|
|
3815
3595
|
const ROWS = 5;
|
|
@@ -3851,7 +3631,9 @@ const YearCalendarTable = ({
|
|
|
3851
3631
|
return !!(min && year < min.getFullYear() || max && year > max.getFullYear());
|
|
3852
3632
|
};
|
|
3853
3633
|
const autofocusYear = (() => {
|
|
3854
|
-
const years =
|
|
3634
|
+
const years = Array.from({
|
|
3635
|
+
length: ROWS * COLS
|
|
3636
|
+
}, (_, index) => startYear + index);
|
|
3855
3637
|
return getFocusableTime({
|
|
3856
3638
|
isActive,
|
|
3857
3639
|
isNow: isThisYear,
|
|
@@ -3865,33 +3647,23 @@ const YearCalendarTable = ({
|
|
|
3865
3647
|
className: "sr-only",
|
|
3866
3648
|
children: /*#__PURE__*/jsx("tr", {
|
|
3867
3649
|
children: /*#__PURE__*/jsx("th", {
|
|
3868
|
-
colSpan:
|
|
3650
|
+
colSpan: COLS,
|
|
3869
3651
|
children: placeholder
|
|
3870
3652
|
})
|
|
3871
3653
|
})
|
|
3872
3654
|
}), /*#__PURE__*/jsx("tbody", {
|
|
3873
|
-
children:
|
|
3874
|
-
|
|
3655
|
+
children: Array.from({
|
|
3656
|
+
length: ROWS
|
|
3657
|
+
}, (_, rowIndex) => /*#__PURE__*/jsx("tr", {
|
|
3658
|
+
children: Array.from({
|
|
3659
|
+
length: COLS
|
|
3660
|
+
}, (_, colIndex) => /*#__PURE__*/jsx("td", {
|
|
3875
3661
|
children: getLink(startYear + rowIndex * COLS + colIndex)
|
|
3876
3662
|
}, colIndex))
|
|
3877
3663
|
}, rowIndex))
|
|
3878
3664
|
})]
|
|
3879
3665
|
});
|
|
3880
3666
|
};
|
|
3881
|
-
YearCalendarTable.propTypes = {
|
|
3882
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3883
|
-
min: PropTypes.instanceOf(Date),
|
|
3884
|
-
max: PropTypes.instanceOf(Date),
|
|
3885
|
-
viewYear: PropTypes.number.isRequired,
|
|
3886
|
-
placeholder: PropTypes.string.isRequired,
|
|
3887
|
-
onSelect: PropTypes.func.isRequired
|
|
3888
|
-
};
|
|
3889
|
-
YearCalendarTable.defaultProps = {
|
|
3890
|
-
selectedDate: null,
|
|
3891
|
-
min: null,
|
|
3892
|
-
max: null
|
|
3893
|
-
};
|
|
3894
|
-
var YearCalendarTable$1 = YearCalendarTable;
|
|
3895
3667
|
|
|
3896
3668
|
class YearCalendar extends PureComponent {
|
|
3897
3669
|
onYearSelect = year => {
|
|
@@ -3922,43 +3694,35 @@ class YearCalendar extends PureComponent {
|
|
|
3922
3694
|
}
|
|
3923
3695
|
} = this.props;
|
|
3924
3696
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3925
|
-
children: [/*#__PURE__*/jsx(DateHeader
|
|
3697
|
+
children: [/*#__PURE__*/jsx(DateHeader, {
|
|
3926
3698
|
dateMode: formatMessage(messages$8.twentyYears),
|
|
3927
3699
|
onPreviousClick: this.selectPreviousYears,
|
|
3928
3700
|
onNextClick: this.selectNextYears
|
|
3929
|
-
}), /*#__PURE__*/jsx(YearCalendarTable
|
|
3930
|
-
selectedDate,
|
|
3931
|
-
min,
|
|
3932
|
-
max,
|
|
3933
|
-
viewYear,
|
|
3934
|
-
placeholder,
|
|
3701
|
+
}), /*#__PURE__*/jsx(YearCalendarTable, {
|
|
3702
|
+
selectedDate: selectedDate,
|
|
3703
|
+
min: min,
|
|
3704
|
+
max: max,
|
|
3705
|
+
viewYear: viewYear,
|
|
3706
|
+
placeholder: placeholder,
|
|
3935
3707
|
onSelect: this.onYearSelect
|
|
3936
3708
|
})]
|
|
3937
3709
|
});
|
|
3938
3710
|
}
|
|
3939
3711
|
}
|
|
3940
|
-
YearCalendar.propTypes = {
|
|
3941
|
-
selectedDate: PropTypes.instanceOf(Date),
|
|
3942
|
-
min: PropTypes.instanceOf(Date),
|
|
3943
|
-
max: PropTypes.instanceOf(Date),
|
|
3944
|
-
viewYear: PropTypes.number.isRequired,
|
|
3945
|
-
placeholder: PropTypes.string.isRequired,
|
|
3946
|
-
onSelect: PropTypes.func.isRequired,
|
|
3947
|
-
onViewDateUpdate: PropTypes.func.isRequired
|
|
3948
|
-
};
|
|
3949
|
-
YearCalendar.defaultProps = {
|
|
3950
|
-
selectedDate: null,
|
|
3951
|
-
min: null,
|
|
3952
|
-
max: null
|
|
3953
|
-
};
|
|
3954
3712
|
var YearCalendar$1 = injectIntl(YearCalendar);
|
|
3955
3713
|
|
|
3956
|
-
const MODE = {
|
|
3957
|
-
DAY: 'day',
|
|
3958
|
-
MONTH: 'month',
|
|
3959
|
-
YEAR: 'year'
|
|
3960
|
-
};
|
|
3961
3714
|
class DateLookup extends PureComponent {
|
|
3715
|
+
static defaultProps = {
|
|
3716
|
+
value: null,
|
|
3717
|
+
min: null,
|
|
3718
|
+
max: null,
|
|
3719
|
+
size: Size.MEDIUM,
|
|
3720
|
+
placeholder: '',
|
|
3721
|
+
label: '',
|
|
3722
|
+
monthFormat: MonthFormat.LONG,
|
|
3723
|
+
disabled: false,
|
|
3724
|
+
clearable: false
|
|
3725
|
+
};
|
|
3962
3726
|
element = /*#__PURE__*/createRef();
|
|
3963
3727
|
dropdown = /*#__PURE__*/createRef();
|
|
3964
3728
|
constructor(props) {
|
|
@@ -3971,7 +3735,7 @@ class DateLookup extends PureComponent {
|
|
|
3971
3735
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
3972
3736
|
viewYear: (props.value || new Date()).getFullYear(),
|
|
3973
3737
|
open: false,
|
|
3974
|
-
mode:
|
|
3738
|
+
mode: 'day',
|
|
3975
3739
|
isMobile: false
|
|
3976
3740
|
};
|
|
3977
3741
|
}
|
|
@@ -3979,20 +3743,20 @@ class DateLookup extends PureComponent {
|
|
|
3979
3743
|
const propsSelected = getStartOfDay(props.value);
|
|
3980
3744
|
const propsMin = getStartOfDay(props.min);
|
|
3981
3745
|
const propsMax = getStartOfDay(props.max);
|
|
3982
|
-
const hasSelectedChanged =
|
|
3983
|
-
const hasMinChanged =
|
|
3984
|
-
const hasMaxChanged =
|
|
3746
|
+
const hasSelectedChanged = state.selectedDate?.getTime() !== propsSelected?.getTime();
|
|
3747
|
+
const hasMinChanged = state.min?.getTime() !== propsMin?.getTime();
|
|
3748
|
+
const hasMaxChanged = state.max?.getTime() !== propsMax?.getTime();
|
|
3985
3749
|
if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {
|
|
3986
3750
|
const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;
|
|
3987
3751
|
const min = hasMinChanged ? propsMin : state.min;
|
|
3988
3752
|
const max = hasMaxChanged ? propsMax : state.max;
|
|
3989
|
-
|
|
3990
|
-
if (!isWithinRange(selectedDate, min, max)) {
|
|
3753
|
+
if (selectedDate && !isWithinRange(selectedDate, min, max)) {
|
|
3991
3754
|
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
3992
3755
|
return null;
|
|
3993
3756
|
}
|
|
3994
|
-
const
|
|
3995
|
-
const
|
|
3757
|
+
const viewDateThatIsWithinRange = selectedDate || (min || max) && moveToWithinRange(new Date(), min, max) || new Date();
|
|
3758
|
+
const viewMonth = viewDateThatIsWithinRange.getMonth();
|
|
3759
|
+
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
3996
3760
|
return {
|
|
3997
3761
|
selectedDate,
|
|
3998
3762
|
min,
|
|
@@ -4004,12 +3768,12 @@ class DateLookup extends PureComponent {
|
|
|
4004
3768
|
return null;
|
|
4005
3769
|
}
|
|
4006
3770
|
componentDidUpdate(previousProps) {
|
|
4007
|
-
if (
|
|
3771
|
+
if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {
|
|
4008
3772
|
this.focusOn('.active');
|
|
4009
3773
|
}
|
|
4010
|
-
|
|
3774
|
+
const mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);
|
|
4011
3775
|
this.setState({
|
|
4012
|
-
isMobile:
|
|
3776
|
+
isMobile: mediaQuery.matches
|
|
4013
3777
|
});
|
|
4014
3778
|
}
|
|
4015
3779
|
componentWillUnmount() {
|
|
@@ -4022,7 +3786,7 @@ class DateLookup extends PureComponent {
|
|
|
4022
3786
|
} = this.props;
|
|
4023
3787
|
this.setState({
|
|
4024
3788
|
open: true,
|
|
4025
|
-
mode:
|
|
3789
|
+
mode: 'day'
|
|
4026
3790
|
});
|
|
4027
3791
|
if (onFocus) {
|
|
4028
3792
|
onFocus();
|
|
@@ -4111,17 +3875,19 @@ class DateLookup extends PureComponent {
|
|
|
4111
3875
|
}
|
|
4112
3876
|
let date;
|
|
4113
3877
|
if (selectedDate) {
|
|
4114
|
-
date = new Date(mode ===
|
|
3878
|
+
date = new Date(mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(), mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(), mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate());
|
|
4115
3879
|
} else {
|
|
4116
3880
|
date = getStartOfDay(new Date());
|
|
4117
3881
|
}
|
|
4118
|
-
|
|
4119
|
-
|
|
3882
|
+
if (date) {
|
|
3883
|
+
date = moveToWithinRange(date, min, max);
|
|
3884
|
+
}
|
|
3885
|
+
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
4120
3886
|
this.props.onChange(date);
|
|
4121
3887
|
}
|
|
4122
3888
|
};
|
|
4123
3889
|
focusOn = (preferredElement, fallbackElement) => {
|
|
4124
|
-
const element = this.element.current
|
|
3890
|
+
const element = this.element.current?.querySelector(preferredElement);
|
|
4125
3891
|
if (element) {
|
|
4126
3892
|
element.focus();
|
|
4127
3893
|
} else if (fallbackElement) {
|
|
@@ -4135,9 +3901,9 @@ class DateLookup extends PureComponent {
|
|
|
4135
3901
|
this.focusOn('.active', '.today');
|
|
4136
3902
|
});
|
|
4137
3903
|
};
|
|
4138
|
-
switchToDays = () => this.switchMode(
|
|
4139
|
-
switchToMonths = () => this.switchMode(
|
|
4140
|
-
switchToYears = () => this.switchMode(
|
|
3904
|
+
switchToDays = () => this.switchMode('day');
|
|
3905
|
+
switchToMonths = () => this.switchMode('month');
|
|
3906
|
+
switchToYears = () => this.switchMode('year');
|
|
4141
3907
|
handleSelectedDateUpdate = selectedDate => {
|
|
4142
3908
|
this.setState({
|
|
4143
3909
|
selectedDate
|
|
@@ -4174,31 +3940,31 @@ class DateLookup extends PureComponent {
|
|
|
4174
3940
|
className: classNames({
|
|
4175
3941
|
'p-a-1': !isMobile
|
|
4176
3942
|
}),
|
|
4177
|
-
children: [mode ===
|
|
4178
|
-
selectedDate,
|
|
4179
|
-
min,
|
|
4180
|
-
max,
|
|
4181
|
-
viewMonth,
|
|
4182
|
-
viewYear,
|
|
4183
|
-
monthFormat,
|
|
3943
|
+
children: [mode === 'day' && /*#__PURE__*/jsx(DayCalendar$1, {
|
|
3944
|
+
selectedDate: selectedDate,
|
|
3945
|
+
min: min,
|
|
3946
|
+
max: max,
|
|
3947
|
+
viewMonth: viewMonth,
|
|
3948
|
+
viewYear: viewYear,
|
|
3949
|
+
monthFormat: monthFormat,
|
|
4184
3950
|
onSelect: this.handleSelectedDateUpdate,
|
|
4185
3951
|
onLabelClick: this.switchToYears,
|
|
4186
3952
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4187
|
-
}), mode ===
|
|
4188
|
-
selectedDate,
|
|
4189
|
-
min,
|
|
4190
|
-
max,
|
|
4191
|
-
viewYear,
|
|
4192
|
-
placeholder,
|
|
3953
|
+
}), mode === 'month' && /*#__PURE__*/jsx(MonthCalendar$1, {
|
|
3954
|
+
selectedDate: selectedDate,
|
|
3955
|
+
min: min,
|
|
3956
|
+
max: max,
|
|
3957
|
+
viewYear: viewYear,
|
|
3958
|
+
placeholder: placeholder,
|
|
4193
3959
|
onSelect: this.switchToDays,
|
|
4194
3960
|
onLabelClick: this.switchToYears,
|
|
4195
3961
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4196
|
-
}), mode ===
|
|
4197
|
-
selectedDate,
|
|
4198
|
-
min,
|
|
4199
|
-
max,
|
|
4200
|
-
viewYear,
|
|
4201
|
-
placeholder,
|
|
3962
|
+
}), mode === 'year' && /*#__PURE__*/jsx(YearCalendar$1, {
|
|
3963
|
+
selectedDate: selectedDate,
|
|
3964
|
+
min: min,
|
|
3965
|
+
max: max,
|
|
3966
|
+
viewYear: viewYear,
|
|
3967
|
+
placeholder: placeholder,
|
|
4202
3968
|
onSelect: this.switchToMonths,
|
|
4203
3969
|
onViewDateUpdate: this.handleViewDateUpdate
|
|
4204
3970
|
})]
|
|
@@ -4224,21 +3990,20 @@ class DateLookup extends PureComponent {
|
|
|
4224
3990
|
value
|
|
4225
3991
|
} = this.props;
|
|
4226
3992
|
return /*#__PURE__*/jsxs("div", {
|
|
4227
|
-
// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
4228
3993
|
ref: this.element,
|
|
4229
3994
|
id: this.props.id,
|
|
4230
3995
|
"aria-labelledby": ariaLabelledBy,
|
|
4231
3996
|
className: "input-group",
|
|
4232
3997
|
onKeyDown: this.handleKeyDown,
|
|
4233
|
-
children: [/*#__PURE__*/jsx(DateTrigger
|
|
4234
|
-
selectedDate,
|
|
4235
|
-
size,
|
|
4236
|
-
placeholder,
|
|
4237
|
-
label,
|
|
4238
|
-
monthFormat,
|
|
4239
|
-
disabled,
|
|
3998
|
+
children: [/*#__PURE__*/jsx(DateTrigger, {
|
|
3999
|
+
selectedDate: selectedDate,
|
|
4000
|
+
size: size,
|
|
4001
|
+
placeholder: placeholder,
|
|
4002
|
+
label: label,
|
|
4003
|
+
monthFormat: monthFormat,
|
|
4004
|
+
disabled: disabled || false,
|
|
4240
4005
|
onClick: this.open,
|
|
4241
|
-
onClear: !disabled && clearable && value ? this.handleClear :
|
|
4006
|
+
onClear: !disabled && clearable && value ? this.handleClear : undefined
|
|
4242
4007
|
}), /*#__PURE__*/jsx(ResponsivePanel$1, {
|
|
4243
4008
|
anchorRef: this.element,
|
|
4244
4009
|
open: open,
|
|
@@ -4250,36 +4015,6 @@ class DateLookup extends PureComponent {
|
|
|
4250
4015
|
});
|
|
4251
4016
|
}
|
|
4252
4017
|
}
|
|
4253
|
-
DateLookup.propTypes = {
|
|
4254
|
-
id: PropTypes.string,
|
|
4255
|
-
value: PropTypes.instanceOf(Date),
|
|
4256
|
-
min: PropTypes.instanceOf(Date),
|
|
4257
|
-
max: PropTypes.instanceOf(Date),
|
|
4258
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
4259
|
-
placeholder: PropTypes.string,
|
|
4260
|
-
label: PropTypes.string,
|
|
4261
|
-
'aria-labelledby': PropTypes.string,
|
|
4262
|
-
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
4263
|
-
disabled: PropTypes.bool,
|
|
4264
|
-
onChange: PropTypes.func.isRequired,
|
|
4265
|
-
onFocus: PropTypes.func,
|
|
4266
|
-
onBlur: PropTypes.func,
|
|
4267
|
-
clearable: PropTypes.bool
|
|
4268
|
-
};
|
|
4269
|
-
DateLookup.defaultProps = {
|
|
4270
|
-
value: null,
|
|
4271
|
-
min: null,
|
|
4272
|
-
max: null,
|
|
4273
|
-
size: Size.MEDIUM,
|
|
4274
|
-
placeholder: '',
|
|
4275
|
-
label: '',
|
|
4276
|
-
monthFormat: MonthFormat.LONG,
|
|
4277
|
-
disabled: false,
|
|
4278
|
-
onFocus: null,
|
|
4279
|
-
onBlur: null,
|
|
4280
|
-
clearable: false
|
|
4281
|
-
};
|
|
4282
|
-
var DateLookup$1 = DateLookup;
|
|
4283
4018
|
|
|
4284
4019
|
const NavigationOption = /*#__PURE__*/forwardRef(({
|
|
4285
4020
|
as: component = 'button',
|
|
@@ -4596,508 +4331,6 @@ const DropFade = ({
|
|
|
4596
4331
|
});
|
|
4597
4332
|
};
|
|
4598
4333
|
|
|
4599
|
-
/* eslint-disable no-unused-vars */
|
|
4600
|
-
/* eslint-disable no-param-reassign */
|
|
4601
|
-
|
|
4602
|
-
const prepFields = (fields, model, validationMessages) => {
|
|
4603
|
-
if (!fields) {
|
|
4604
|
-
return {};
|
|
4605
|
-
}
|
|
4606
|
-
let preparedFields = copyOf(fields);
|
|
4607
|
-
preparedFields = flattenFieldsWithGroups(preparedFields);
|
|
4608
|
-
preparedFields = transformFieldArrayToMap(preparedFields);
|
|
4609
|
-
preparedFields = transformNestedKeysToNestedSpecs(preparedFields);
|
|
4610
|
-
Object.keys(preparedFields).forEach(key => {
|
|
4611
|
-
preparedFields[key] = prepField(preparedFields[key], model, validationMessages);
|
|
4612
|
-
});
|
|
4613
|
-
return preparedFields;
|
|
4614
|
-
};
|
|
4615
|
-
const prepField = (field, model, validationMessages) => {
|
|
4616
|
-
const preparedField = copyOf(field);
|
|
4617
|
-
prepLegacyProps(preparedField);
|
|
4618
|
-
prepType(preparedField);
|
|
4619
|
-
prepPattern(preparedField);
|
|
4620
|
-
prepValidationMessages(preparedField, validationMessages);
|
|
4621
|
-
return preparedField;
|
|
4622
|
-
};
|
|
4623
|
-
|
|
4624
|
-
/**
|
|
4625
|
-
* In an older format we had an extra fieldGroup level, here we flatten that out
|
|
4626
|
-
* So the inner arrays of fields within the different field groups are flattened
|
|
4627
|
-
* to a single array, which is returned.
|
|
4628
|
-
*
|
|
4629
|
-
* @param fields
|
|
4630
|
-
*/
|
|
4631
|
-
const flattenFieldsWithGroups = fields => {
|
|
4632
|
-
if (Array.isArray(fields)) {
|
|
4633
|
-
let flattenedFields = [];
|
|
4634
|
-
fields.forEach(field => {
|
|
4635
|
-
// If we've been given a group with nested fields, break them out.
|
|
4636
|
-
if (field.fields) {
|
|
4637
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.fields));
|
|
4638
|
-
} else if (field.group) {
|
|
4639
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.group));
|
|
4640
|
-
} else {
|
|
4641
|
-
// Otherwise it's a regular field, just add it.
|
|
4642
|
-
flattenedFields.push(field);
|
|
4643
|
-
}
|
|
4644
|
-
});
|
|
4645
|
-
return flattenedFields;
|
|
4646
|
-
}
|
|
4647
|
-
return fields;
|
|
4648
|
-
};
|
|
4649
|
-
const flattenFieldWithGroup = (field, subFields) => {
|
|
4650
|
-
// If first field doesn't have a label, use the one from the group
|
|
4651
|
-
if (field.name && subFields.length > 0 && !subFields[0].name) {
|
|
4652
|
-
subFields[0].name = field.name;
|
|
4653
|
-
}
|
|
4654
|
-
if (field.width && subFields.length > 0 && !subFields[0].width) {
|
|
4655
|
-
subFields[0].width = field.width;
|
|
4656
|
-
}
|
|
4657
|
-
|
|
4658
|
-
// If there was a tooltip at fieldGroup level move it to first field.
|
|
4659
|
-
if (field.tooltip && subFields.length > 0 && !subFields[0].help) {
|
|
4660
|
-
subFields[0].help = {
|
|
4661
|
-
message: field.tooltip
|
|
4662
|
-
};
|
|
4663
|
-
}
|
|
4664
|
-
if (field.info && subFields.length > 0 && !subFields[0].help) {
|
|
4665
|
-
subFields[0].help = {
|
|
4666
|
-
message: field.info
|
|
4667
|
-
};
|
|
4668
|
-
}
|
|
4669
|
-
|
|
4670
|
-
// If there are two parts of this group, render them side by side
|
|
4671
|
-
if (subFields.length === 2) {
|
|
4672
|
-
subFields.forEach(nestedField => {
|
|
4673
|
-
nestedField.width = 'md';
|
|
4674
|
-
});
|
|
4675
|
-
}
|
|
4676
|
-
|
|
4677
|
-
// If there are three parts, render the first two side by side
|
|
4678
|
-
if (subFields.length === 3) {
|
|
4679
|
-
subFields[0].width = 'md';
|
|
4680
|
-
subFields[1].width = 'md';
|
|
4681
|
-
}
|
|
4682
|
-
return subFields;
|
|
4683
|
-
};
|
|
4684
|
-
|
|
4685
|
-
/*
|
|
4686
|
-
* Some older requirements return an array of fields, where it should be a map
|
|
4687
|
-
* from the property name to the spec. This converts arrays to maps.
|
|
4688
|
-
*/
|
|
4689
|
-
const transformFieldArrayToMap = fields => {
|
|
4690
|
-
if (Array.isArray(fields)) {
|
|
4691
|
-
const fieldMap = {};
|
|
4692
|
-
fields.forEach(field => {
|
|
4693
|
-
const key = field.key || field.name;
|
|
4694
|
-
delete field.key;
|
|
4695
|
-
fieldMap[key] = copyOf(field);
|
|
4696
|
-
});
|
|
4697
|
-
return fieldMap;
|
|
4698
|
-
}
|
|
4699
|
-
return fields;
|
|
4700
|
-
};
|
|
4701
|
-
|
|
4702
|
-
/*
|
|
4703
|
-
* Some older format return keys like 'address.city', expecting the value of
|
|
4704
|
-
* city to be nested inside an address object. This function creates a spec of
|
|
4705
|
-
* type 'object', and nests such fields inside of it. When we render we pass
|
|
4706
|
-
* this object spec to a nested fieldset.
|
|
4707
|
-
*/
|
|
4708
|
-
const transformNestedKeysToNestedSpecs = fieldMap => {
|
|
4709
|
-
if (Array.isArray(fieldMap)) {
|
|
4710
|
-
throw new TypeError('Expecting a map of fields, not an array');
|
|
4711
|
-
}
|
|
4712
|
-
const nestedFields = {};
|
|
4713
|
-
Object.keys(fieldMap).forEach(key => {
|
|
4714
|
-
if (key.indexOf('.') > 0) {
|
|
4715
|
-
// If the key contains a period we need to nest the fields in another object
|
|
4716
|
-
const pathSections = key.split('.');
|
|
4717
|
-
const nestedKey = pathSections[0];
|
|
4718
|
-
|
|
4719
|
-
// If this sub object doesn't exist yet, create it
|
|
4720
|
-
if (!nestedFields[nestedKey]) {
|
|
4721
|
-
nestedFields[nestedKey] = {
|
|
4722
|
-
type: 'object',
|
|
4723
|
-
properties: {}
|
|
4724
|
-
};
|
|
4725
|
-
}
|
|
4726
|
-
nestedFields[nestedKey].properties[pathSections[1]] = fieldMap[key];
|
|
4727
|
-
} else {
|
|
4728
|
-
nestedFields[key] = fieldMap[key];
|
|
4729
|
-
}
|
|
4730
|
-
});
|
|
4731
|
-
return nestedFields;
|
|
4732
|
-
};
|
|
4733
|
-
const prepType = field => {
|
|
4734
|
-
const type = field.type && field.type.toLowerCase && field.type.toLowerCase();
|
|
4735
|
-
switch (type) {
|
|
4736
|
-
case 'text':
|
|
4737
|
-
field.type = 'string';
|
|
4738
|
-
break;
|
|
4739
|
-
case 'date':
|
|
4740
|
-
field.type = 'string';
|
|
4741
|
-
field.format = 'date';
|
|
4742
|
-
break;
|
|
4743
|
-
case 'password':
|
|
4744
|
-
field.type = 'string';
|
|
4745
|
-
field.control = 'password';
|
|
4746
|
-
break;
|
|
4747
|
-
case 'checkbox':
|
|
4748
|
-
field.type = 'boolean';
|
|
4749
|
-
break;
|
|
4750
|
-
case 'select':
|
|
4751
|
-
if (!field.control) {
|
|
4752
|
-
field.control = 'select';
|
|
4753
|
-
}
|
|
4754
|
-
delete field.type;
|
|
4755
|
-
break;
|
|
4756
|
-
case 'radio':
|
|
4757
|
-
field.control = 'radio';
|
|
4758
|
-
delete field.type;
|
|
4759
|
-
break;
|
|
4760
|
-
case 'upload':
|
|
4761
|
-
field.type = 'string';
|
|
4762
|
-
field.format = 'base64url';
|
|
4763
|
-
break;
|
|
4764
|
-
case 'tel':
|
|
4765
|
-
field.type = 'string';
|
|
4766
|
-
field.format = 'phone';
|
|
4767
|
-
break;
|
|
4768
|
-
case 'textarea':
|
|
4769
|
-
field.type = 'string';
|
|
4770
|
-
field.control = 'textarea';
|
|
4771
|
-
break;
|
|
4772
|
-
}
|
|
4773
|
-
if (!field.control && field.type !== 'object') {
|
|
4774
|
-
field.control = getControlType(field);
|
|
4775
|
-
}
|
|
4776
|
-
};
|
|
4777
|
-
const prepLegacyProps = field => {
|
|
4778
|
-
if (field.name && !field.title) {
|
|
4779
|
-
field.title = field.name;
|
|
4780
|
-
delete field.name;
|
|
4781
|
-
}
|
|
4782
|
-
if (field.validationRegexp) {
|
|
4783
|
-
field.pattern = field.validationRegexp;
|
|
4784
|
-
delete field.validationRegexp;
|
|
4785
|
-
}
|
|
4786
|
-
if (field.min) {
|
|
4787
|
-
field.minimum = field.min;
|
|
4788
|
-
delete field.min;
|
|
4789
|
-
}
|
|
4790
|
-
if (field.max) {
|
|
4791
|
-
field.maximum = field.max;
|
|
4792
|
-
delete field.max;
|
|
4793
|
-
}
|
|
4794
|
-
if (field.example && !field.placeholder) {
|
|
4795
|
-
field.placeholder = field.example;
|
|
4796
|
-
delete field.example;
|
|
4797
|
-
}
|
|
4798
|
-
if (field.tooltip && !field.help) {
|
|
4799
|
-
field.help = {
|
|
4800
|
-
message: field.tooltip
|
|
4801
|
-
};
|
|
4802
|
-
delete field.tooltip;
|
|
4803
|
-
}
|
|
4804
|
-
if (field.valuesAllowed && !field.values) {
|
|
4805
|
-
field.values = field.valuesAllowed;
|
|
4806
|
-
delete field.valuesAllowed;
|
|
4807
|
-
}
|
|
4808
|
-
if (field.values && field.values.map) {
|
|
4809
|
-
field.values = prepLegacyValues(field.values);
|
|
4810
|
-
}
|
|
4811
|
-
if (field.value && !field.default) {
|
|
4812
|
-
field.default = field.value;
|
|
4813
|
-
delete field.value;
|
|
4814
|
-
}
|
|
4815
|
-
if (field.values) {
|
|
4816
|
-
// In some legacy arrays the first value is a placeholder, extract it.
|
|
4817
|
-
if (field.values && field.values.length > 0 && field.values[0] && !field.values[0].value && field.values[0].label && !field.placeholder) {
|
|
4818
|
-
field.placeholder = field.values[0].label;
|
|
4819
|
-
field.values = field.values.slice(1);
|
|
4820
|
-
}
|
|
4821
|
-
}
|
|
4822
|
-
};
|
|
4823
|
-
const prepLegacyValues = values => values.map(prepLegacyValue);
|
|
4824
|
-
const prepLegacyValue = value => {
|
|
4825
|
-
if (!value.label && value.title) {
|
|
4826
|
-
value.label = value.title;
|
|
4827
|
-
delete value.title;
|
|
4828
|
-
}
|
|
4829
|
-
if (!value.label && value.name) {
|
|
4830
|
-
value.label = value.name;
|
|
4831
|
-
delete value.name;
|
|
4832
|
-
}
|
|
4833
|
-
if (!value.value && value.code) {
|
|
4834
|
-
value.value = value.code;
|
|
4835
|
-
delete value.code;
|
|
4836
|
-
}
|
|
4837
|
-
if (!value.value && value.key) {
|
|
4838
|
-
value.value = value.key;
|
|
4839
|
-
delete value.key;
|
|
4840
|
-
}
|
|
4841
|
-
return value;
|
|
4842
|
-
};
|
|
4843
|
-
const prepPattern = field => {
|
|
4844
|
-
if (field.pattern) {
|
|
4845
|
-
try {
|
|
4846
|
-
new RegExp(field.pattern);
|
|
4847
|
-
} catch {
|
|
4848
|
-
// eslint-disable-next-line no-console
|
|
4849
|
-
console.warn('API regexp is invalid');
|
|
4850
|
-
delete field.pattern;
|
|
4851
|
-
}
|
|
4852
|
-
} else {
|
|
4853
|
-
delete field.pattern;
|
|
4854
|
-
}
|
|
4855
|
-
};
|
|
4856
|
-
const prepValidationMessages = (field, validationMessages) => {
|
|
4857
|
-
field.validationMessages = field.validationMessages ? field.validationMessages : validationMessages;
|
|
4858
|
-
if (!field.validationMessages) {
|
|
4859
|
-
delete field.validationMessages;
|
|
4860
|
-
return;
|
|
4861
|
-
}
|
|
4862
|
-
if (field.validationMessages.minimum) {
|
|
4863
|
-
field.validationMessages.min = field.validationMessages.minimum;
|
|
4864
|
-
delete field.validationMessages.minimum;
|
|
4865
|
-
}
|
|
4866
|
-
if (field.validationMessages.maximum) {
|
|
4867
|
-
field.validationMessages.max = field.validationMessages.maximum;
|
|
4868
|
-
delete field.validationMessages.maximum;
|
|
4869
|
-
}
|
|
4870
|
-
};
|
|
4871
|
-
const getControlType = field => {
|
|
4872
|
-
if (field.control) {
|
|
4873
|
-
return field.control.toLowerCase();
|
|
4874
|
-
}
|
|
4875
|
-
if (field.hidden) {
|
|
4876
|
-
return 'hidden';
|
|
4877
|
-
}
|
|
4878
|
-
if (field.values && field.values.length > 0) {
|
|
4879
|
-
return getSelectionType(field);
|
|
4880
|
-
}
|
|
4881
|
-
switch (field.type) {
|
|
4882
|
-
case 'string':
|
|
4883
|
-
return getControlForStringFormat(field.format);
|
|
4884
|
-
case 'number':
|
|
4885
|
-
case 'integer':
|
|
4886
|
-
return 'number';
|
|
4887
|
-
case 'boolean':
|
|
4888
|
-
return 'checkbox';
|
|
4889
|
-
default:
|
|
4890
|
-
return 'text';
|
|
4891
|
-
}
|
|
4892
|
-
};
|
|
4893
|
-
const getControlForStringFormat = format => {
|
|
4894
|
-
switch (format) {
|
|
4895
|
-
case 'date':
|
|
4896
|
-
return 'date';
|
|
4897
|
-
case 'base64url':
|
|
4898
|
-
return 'file';
|
|
4899
|
-
case 'password':
|
|
4900
|
-
return 'password';
|
|
4901
|
-
case 'uri':
|
|
4902
|
-
return 'text';
|
|
4903
|
-
// 'url'; - not implemented
|
|
4904
|
-
case 'email':
|
|
4905
|
-
return 'text';
|
|
4906
|
-
// 'email'; - not implemented
|
|
4907
|
-
case 'phone':
|
|
4908
|
-
return 'tel';
|
|
4909
|
-
default:
|
|
4910
|
-
return 'text';
|
|
4911
|
-
}
|
|
4912
|
-
};
|
|
4913
|
-
const getSelectionType = field => {
|
|
4914
|
-
if (field.control) {
|
|
4915
|
-
return field.control;
|
|
4916
|
-
}
|
|
4917
|
-
if (field.type === 'select') {
|
|
4918
|
-
return 'select';
|
|
4919
|
-
}
|
|
4920
|
-
if (field.type === 'radio') {
|
|
4921
|
-
return 'radio';
|
|
4922
|
-
}
|
|
4923
|
-
if (field.values) {
|
|
4924
|
-
return field.values.length > 3 ? 'select' : 'radio';
|
|
4925
|
-
}
|
|
4926
|
-
return 'select';
|
|
4927
|
-
};
|
|
4928
|
-
const copyOf = object => JSON.parse(JSON.stringify(object));
|
|
4929
|
-
|
|
4930
|
-
const formatUsingPattern = (value = '', pattern) => {
|
|
4931
|
-
if (typeof pattern !== 'string') {
|
|
4932
|
-
return value;
|
|
4933
|
-
}
|
|
4934
|
-
let newPattern = pattern;
|
|
4935
|
-
if (newPattern.indexOf('||') > 0) {
|
|
4936
|
-
newPattern = newPattern.slice(0, Math.max(0, pattern.indexOf('||')));
|
|
4937
|
-
}
|
|
4938
|
-
let newValue = '';
|
|
4939
|
-
let separators = 0;
|
|
4940
|
-
let charactersToAllocate = value.length;
|
|
4941
|
-
let position = 0;
|
|
4942
|
-
while (charactersToAllocate) {
|
|
4943
|
-
if (positionIsSeparator(newPattern, position)) {
|
|
4944
|
-
newValue += newPattern[position];
|
|
4945
|
-
separators += 1;
|
|
4946
|
-
} else {
|
|
4947
|
-
newValue += value[position - separators];
|
|
4948
|
-
charactersToAllocate -= 1;
|
|
4949
|
-
}
|
|
4950
|
-
position += 1;
|
|
4951
|
-
}
|
|
4952
|
-
const separatorsAfterCursor = countSeparatorsAfterCursor(newPattern, position);
|
|
4953
|
-
if (separatorsAfterCursor) {
|
|
4954
|
-
newValue += newPattern.slice(position, separatorsAfterCursor);
|
|
4955
|
-
}
|
|
4956
|
-
return newValue;
|
|
4957
|
-
};
|
|
4958
|
-
const countSeparatorsAfterCursor = (newPattern, position) => {
|
|
4959
|
-
let separators = 0;
|
|
4960
|
-
while (positionIsSeparator(newPattern, position + separators)) {
|
|
4961
|
-
separators += 1;
|
|
4962
|
-
}
|
|
4963
|
-
return separators;
|
|
4964
|
-
};
|
|
4965
|
-
const positionIsSeparator = (newPattern, position) => newPattern[position] && newPattern[position] !== '*';
|
|
4966
|
-
|
|
4967
|
-
const getValueLabel = (options, value) => {
|
|
4968
|
-
const option = options.find(currentOption => currentOption.value === value);
|
|
4969
|
-
return option && option.label ? option.label : value;
|
|
4970
|
-
};
|
|
4971
|
-
|
|
4972
|
-
/**
|
|
4973
|
-
*
|
|
4974
|
-
* @param {string} value
|
|
4975
|
-
*/
|
|
4976
|
-
const mask = value => new Array(value.length + 1).join('*');
|
|
4977
|
-
const FormattedValue = ({
|
|
4978
|
-
field,
|
|
4979
|
-
value
|
|
4980
|
-
}) => {
|
|
4981
|
-
const {
|
|
4982
|
-
locale
|
|
4983
|
-
} = useIntl();
|
|
4984
|
-
const style = [];
|
|
4985
|
-
if (field.tagClassName && field.tagClassName.h3) {
|
|
4986
|
-
style.push('np-text-body-large-bold');
|
|
4987
|
-
style.push('formatted-value__h3-custom-alignment');
|
|
4988
|
-
}
|
|
4989
|
-
switch (field.control) {
|
|
4990
|
-
case 'select':
|
|
4991
|
-
case 'radio':
|
|
4992
|
-
return /*#__PURE__*/jsx("span", {
|
|
4993
|
-
children: getValueLabel(field.values, value)
|
|
4994
|
-
});
|
|
4995
|
-
case 'date':
|
|
4996
|
-
return /*#__PURE__*/jsx("span", {
|
|
4997
|
-
children: formatDate(value instanceof Date ? value : new Date(value), locale)
|
|
4998
|
-
});
|
|
4999
|
-
case 'number':
|
|
5000
|
-
return /*#__PURE__*/jsx("span", {
|
|
5001
|
-
children: formatNumber(value, locale)
|
|
5002
|
-
});
|
|
5003
|
-
case 'password':
|
|
5004
|
-
return /*#__PURE__*/jsx("span", {
|
|
5005
|
-
children: mask(value)
|
|
5006
|
-
});
|
|
5007
|
-
case 'file':
|
|
5008
|
-
return /*#__PURE__*/jsx("div", {
|
|
5009
|
-
className: "thumbnail",
|
|
5010
|
-
children: /*#__PURE__*/jsx("img", {
|
|
5011
|
-
alt: field.title,
|
|
5012
|
-
src: value
|
|
5013
|
-
})
|
|
5014
|
-
});
|
|
5015
|
-
case 'checkbox':
|
|
5016
|
-
return /*#__PURE__*/jsx("span", {
|
|
5017
|
-
children: JSON.stringify(value)
|
|
5018
|
-
});
|
|
5019
|
-
default:
|
|
5020
|
-
return /*#__PURE__*/jsx("span", {
|
|
5021
|
-
className: classNames(style),
|
|
5022
|
-
children: formatUsingPattern(value, field.displayFormat)
|
|
5023
|
-
});
|
|
5024
|
-
}
|
|
5025
|
-
};
|
|
5026
|
-
FormattedValue.propTypes = {
|
|
5027
|
-
field: PropTypes.shape({
|
|
5028
|
-
control: PropTypes.string.isRequired,
|
|
5029
|
-
displayFormat: PropTypes.string,
|
|
5030
|
-
refreshRequirementsOnChange: PropTypes.bool,
|
|
5031
|
-
title: PropTypes.string.isRequired,
|
|
5032
|
-
type: PropTypes.string.isRequired,
|
|
5033
|
-
width: PropTypes.string,
|
|
5034
|
-
tagClassName: PropTypes.shape({
|
|
5035
|
-
h3: PropTypes.bool
|
|
5036
|
-
}),
|
|
5037
|
-
values: PropTypes.arrayOf(PropTypes.shape({
|
|
5038
|
-
value: PropTypes.any
|
|
5039
|
-
}))
|
|
5040
|
-
}).isRequired,
|
|
5041
|
-
value: PropTypes.any.isRequired
|
|
5042
|
-
};
|
|
5043
|
-
var FormattedValue$1 = FormattedValue;
|
|
5044
|
-
|
|
5045
|
-
function createDefinitions(fields, model) {
|
|
5046
|
-
return toPairs(fields).map(([name, field]) => createDefinition(name, field, model)).filter(definition => !!definition);
|
|
5047
|
-
}
|
|
5048
|
-
function createDefinition(name, field, model) {
|
|
5049
|
-
const {
|
|
5050
|
-
title,
|
|
5051
|
-
group,
|
|
5052
|
-
hidden
|
|
5053
|
-
} = field;
|
|
5054
|
-
if (!model[name] || hidden) {
|
|
5055
|
-
return null;
|
|
5056
|
-
}
|
|
5057
|
-
return {
|
|
5058
|
-
title,
|
|
5059
|
-
value: group ? group.map((groupField, groupFieldIndex) => /*#__PURE__*/jsx(FormattedValue$1, {
|
|
5060
|
-
// eslint-disable-line react/no-array-index-key
|
|
5061
|
-
field: groupField,
|
|
5062
|
-
value: model[name]
|
|
5063
|
-
}, groupFieldIndex)) : /*#__PURE__*/jsx(FormattedValue$1, {
|
|
5064
|
-
field: field,
|
|
5065
|
-
value: model[name]
|
|
5066
|
-
}),
|
|
5067
|
-
key: name
|
|
5068
|
-
};
|
|
5069
|
-
}
|
|
5070
|
-
|
|
5071
|
-
const DynamicFieldDefinitionList = ({
|
|
5072
|
-
model,
|
|
5073
|
-
title,
|
|
5074
|
-
layout,
|
|
5075
|
-
fields
|
|
5076
|
-
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
5077
|
-
children: [title && /*#__PURE__*/jsx("div", {
|
|
5078
|
-
className: "m-t-1 m-b-3",
|
|
5079
|
-
children: /*#__PURE__*/jsx(Title, {
|
|
5080
|
-
type: Typography.TITLE_BODY,
|
|
5081
|
-
className: "p-t-3",
|
|
5082
|
-
children: title
|
|
5083
|
-
})
|
|
5084
|
-
}), /*#__PURE__*/jsx(DefinitionList$1, {
|
|
5085
|
-
layout: layout,
|
|
5086
|
-
definitions: createDefinitions(prepFields(fields), model)
|
|
5087
|
-
})]
|
|
5088
|
-
});
|
|
5089
|
-
DynamicFieldDefinitionList.propTypes = {
|
|
5090
|
-
model: PropTypes.shape({}).isRequired,
|
|
5091
|
-
fields: PropTypes.shape({}).isRequired,
|
|
5092
|
-
title: PropTypes.string,
|
|
5093
|
-
layout: PropTypes.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED'])
|
|
5094
|
-
};
|
|
5095
|
-
DynamicFieldDefinitionList.defaultProps = {
|
|
5096
|
-
title: null,
|
|
5097
|
-
layout: Layout.VERTICAL_TWO_COLUMN
|
|
5098
|
-
};
|
|
5099
|
-
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
5100
|
-
|
|
5101
4334
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
5102
4335
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
5103
4336
|
class EmphasisHtmlTransformer {
|
|
@@ -5318,15 +4551,14 @@ const Logo = ({
|
|
|
5318
4551
|
}) => {
|
|
5319
4552
|
const LogoSm = svgPaths[`WISE_FLAG${type === LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
|
|
5320
4553
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5321
|
-
const screenMd = useScreenSize(Breakpoint.MEDIUM);
|
|
5322
4554
|
return /*#__PURE__*/jsxs("span", {
|
|
5323
4555
|
"aria-label": type === LogoType.WISE ? 'Wise' : 'Wise Business' | type === LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
|
|
5324
4556
|
role: "img",
|
|
5325
4557
|
className: classNames(className, 'np-logo'),
|
|
5326
|
-
children: [
|
|
5327
|
-
className: "np-logo-svg"
|
|
5328
|
-
}),
|
|
5329
|
-
className: "np-logo-svg"
|
|
4558
|
+
children: [/*#__PURE__*/jsx(LogoSm, {
|
|
4559
|
+
className: "np-logo-svg np-logo-svg--size-sm"
|
|
4560
|
+
}), /*#__PURE__*/jsx(LogoMd, {
|
|
4561
|
+
className: "np-logo-svg np-logo-svg--size-md"
|
|
5330
4562
|
})]
|
|
5331
4563
|
});
|
|
5332
4564
|
};
|
|
@@ -5438,7 +4670,6 @@ const Tooltip = ({
|
|
|
5438
4670
|
|
|
5439
4671
|
function supportsTouchEvents() {
|
|
5440
4672
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
5441
|
-
// eslint-disable-next-line compat/compat
|
|
5442
4673
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
5443
4674
|
const documentTouchIsDefined = typeof window !== 'undefined' && window.DocumentTouch && document instanceof window.DocumentTouch;
|
|
5444
4675
|
return !!(onTouchStartIsDefined || maxTouchPointsIsDefined || documentTouchIsDefined);
|
|
@@ -5446,7 +4677,7 @@ function supportsTouchEvents() {
|
|
|
5446
4677
|
function userAgentSuggestsTouchDevice() {
|
|
5447
4678
|
const sampleTouchDevices = ['android', 'iemobile', 'iphone', 'ipad', 'ipod', 'blackberry', 'bada'];
|
|
5448
4679
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
5449
|
-
const regex = new RegExp(matchString, '
|
|
4680
|
+
const regex = new RegExp(matchString, 'gi');
|
|
5450
4681
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
5451
4682
|
}
|
|
5452
4683
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -5852,8 +5083,9 @@ function resolvePlacement(preferredPlacement) {
|
|
|
5852
5083
|
case 'bottom-left':
|
|
5853
5084
|
case 'bottom-right':
|
|
5854
5085
|
return 'bottom';
|
|
5086
|
+
default:
|
|
5087
|
+
return preferredPlacement;
|
|
5855
5088
|
}
|
|
5856
|
-
return preferredPlacement;
|
|
5857
5089
|
}
|
|
5858
5090
|
function Popover$1({
|
|
5859
5091
|
children,
|
|
@@ -5866,7 +5098,7 @@ function Popover$1({
|
|
|
5866
5098
|
const resolvedPlacement = resolvePlacement(preferredPlacement);
|
|
5867
5099
|
useEffect(() => {
|
|
5868
5100
|
if (resolvedPlacement !== preferredPlacement) {
|
|
5869
|
-
logActionRequired
|
|
5101
|
+
logActionRequired(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`);
|
|
5870
5102
|
}
|
|
5871
5103
|
}, [preferredPlacement, resolvedPlacement]);
|
|
5872
5104
|
const anchorReference = useRef(null);
|
|
@@ -5971,49 +5203,22 @@ const Info = ({
|
|
|
5971
5203
|
});
|
|
5972
5204
|
};
|
|
5973
5205
|
|
|
5974
|
-
|
|
5975
|
-
[Sentiment.ERROR]: 'danger',
|
|
5976
|
-
[Sentiment.NEGATIVE]: 'danger'
|
|
5977
|
-
};
|
|
5978
|
-
const InlineAlert = ({
|
|
5206
|
+
function InlineAlert({
|
|
5979
5207
|
id,
|
|
5980
|
-
type =
|
|
5208
|
+
type = 'neutral',
|
|
5981
5209
|
className,
|
|
5982
5210
|
children
|
|
5983
|
-
})
|
|
5984
|
-
const
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
role: "alert",
|
|
5991
|
-
id: id,
|
|
5992
|
-
className: classNames('alert alert-detach', typeClass, className),
|
|
5993
|
-
children: [(type === 'error' || type === 'negative') && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
|
|
5994
|
-
children: children
|
|
5995
|
-
})]
|
|
5996
|
-
});
|
|
5997
|
-
}
|
|
5998
|
-
const getAlertContents = ({
|
|
5999
|
-
children,
|
|
6000
|
-
className
|
|
6001
|
-
}) => {
|
|
6002
|
-
return /*#__PURE__*/jsx("div", {
|
|
6003
|
-
role: "alert",
|
|
6004
|
-
id: id,
|
|
6005
|
-
className: classNames('alert alert-detach p-x-2 p-y-1', typeClass, className),
|
|
5211
|
+
}) {
|
|
5212
|
+
const danger = type === 'negative' || type === 'error';
|
|
5213
|
+
return /*#__PURE__*/jsxs("div", {
|
|
5214
|
+
role: "alert",
|
|
5215
|
+
id: id,
|
|
5216
|
+
className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
5217
|
+
children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
|
|
6006
5218
|
children: children
|
|
6007
|
-
})
|
|
6008
|
-
};
|
|
6009
|
-
const AlertWithArrow = withArrow(getAlertContents, ArrowPosition.TOP_LEFT);
|
|
6010
|
-
return /*#__PURE__*/jsx(AlertWithArrow, {
|
|
6011
|
-
id,
|
|
6012
|
-
type,
|
|
6013
|
-
className,
|
|
6014
|
-
children
|
|
5219
|
+
})]
|
|
6015
5220
|
});
|
|
6016
|
-
}
|
|
5221
|
+
}
|
|
6017
5222
|
|
|
6018
5223
|
/*
|
|
6019
5224
|
* Inspired by:
|
|
@@ -6112,9 +5317,9 @@ function InputAddon({
|
|
|
6112
5317
|
const ref = useRef(null);
|
|
6113
5318
|
useResizeObserver(ref, entry => {
|
|
6114
5319
|
// TODO: Remove fallback once most browsers support `borderBoxSize`
|
|
6115
|
-
|
|
6116
|
-
if (
|
|
6117
|
-
setInputPadding(
|
|
5320
|
+
const inlineSize = entry.borderBoxSize?.[0]?.inlineSize;
|
|
5321
|
+
if (inlineSize != null) {
|
|
5322
|
+
setInputPadding(inlineSize);
|
|
6118
5323
|
} else {
|
|
6119
5324
|
const targetStyle = getComputedStyle(entry.target);
|
|
6120
5325
|
setInputPadding(entry.contentRect.width + Number.parseFloat(targetStyle.paddingInlineStart) + Number.parseFloat(targetStyle.paddingInlineEnd));
|
|
@@ -6261,35 +5466,33 @@ function BottomSheet({
|
|
|
6261
5466
|
theme: "personal",
|
|
6262
5467
|
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
6263
5468
|
isNotRootProvider: true,
|
|
6264
|
-
children: /*#__PURE__*/
|
|
5469
|
+
children: /*#__PURE__*/jsxs(Transition, {
|
|
6265
5470
|
show: open,
|
|
6266
5471
|
className: "np-bottom-sheet-v2-container",
|
|
6267
5472
|
beforeEnter: () => {
|
|
6268
5473
|
setFloatingKey(prev => prev + 1);
|
|
6269
5474
|
},
|
|
6270
5475
|
afterLeave: onCloseEnd,
|
|
6271
|
-
children: /*#__PURE__*/
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
5476
|
+
children: [/*#__PURE__*/jsx(Transition.Child, {
|
|
5477
|
+
enter: "np-bottom-sheet-v2-backdrop-container--enter",
|
|
5478
|
+
enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
|
|
5479
|
+
leave: "np-bottom-sheet-v2-backdrop-container--leave",
|
|
5480
|
+
leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
|
|
5481
|
+
children: /*#__PURE__*/jsx("div", {
|
|
5482
|
+
className: "np-bottom-sheet-v2-backdrop"
|
|
5483
|
+
})
|
|
5484
|
+
}), /*#__PURE__*/jsx("div", {
|
|
5485
|
+
className: "np-bottom-sheet-v2",
|
|
5486
|
+
children: /*#__PURE__*/jsx(Transition.Child, {
|
|
5487
|
+
className: "np-bottom-sheet-v2-content",
|
|
5488
|
+
enter: "np-bottom-sheet-v2-content--enter",
|
|
5489
|
+
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
5490
|
+
leave: "np-bottom-sheet-v2-content--leave",
|
|
5491
|
+
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
5492
|
+
children: /*#__PURE__*/jsx(FocusScope, {
|
|
6288
5493
|
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6289
5494
|
context: context,
|
|
6290
5495
|
initialFocus: initialFocusRef,
|
|
6291
|
-
guards: false,
|
|
6292
|
-
modal: false,
|
|
6293
5496
|
children: /*#__PURE__*/jsxs("div", {
|
|
6294
5497
|
// Force inner state invalidation on open
|
|
6295
5498
|
ref: refs.setFloating,
|
|
@@ -6318,8 +5521,8 @@ function BottomSheet({
|
|
|
6318
5521
|
}, floatingKey)
|
|
6319
5522
|
})
|
|
6320
5523
|
})
|
|
6321
|
-
})
|
|
6322
|
-
})
|
|
5524
|
+
})
|
|
5525
|
+
})]
|
|
6323
5526
|
})
|
|
6324
5527
|
})
|
|
6325
5528
|
})]
|
|
@@ -6417,11 +5620,9 @@ function Popover({
|
|
|
6417
5620
|
setFloatingKey(prev => prev + 1);
|
|
6418
5621
|
},
|
|
6419
5622
|
afterLeave: onCloseEnd,
|
|
6420
|
-
children: /*#__PURE__*/jsx(
|
|
5623
|
+
children: /*#__PURE__*/jsx(FocusScope, {
|
|
6421
5624
|
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
6422
5625
|
context: context,
|
|
6423
|
-
guards: false,
|
|
6424
|
-
modal: false,
|
|
6425
5626
|
children: /*#__PURE__*/jsx("div", {
|
|
6426
5627
|
// Force inner state invalidation on open
|
|
6427
5628
|
ref: refs.setFloating,
|
|
@@ -6542,6 +5743,7 @@ const defaultRenderTrigger = ({
|
|
|
6542
5743
|
})
|
|
6543
5744
|
})]
|
|
6544
5745
|
}),
|
|
5746
|
+
initialContentWidth: 24 + 4,
|
|
6545
5747
|
padding: 'sm'
|
|
6546
5748
|
},
|
|
6547
5749
|
disabled: disabled,
|
|
@@ -6825,6 +6027,7 @@ function SelectInputOptions({
|
|
|
6825
6027
|
})
|
|
6826
6028
|
}) : null, /*#__PURE__*/jsxs("section", {
|
|
6827
6029
|
ref: listboxContainerRef,
|
|
6030
|
+
tabIndex: -1,
|
|
6828
6031
|
className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
6829
6032
|
children: [resultsEmpty ? /*#__PURE__*/jsxs("div", {
|
|
6830
6033
|
id: statusId,
|
|
@@ -7450,7 +6653,6 @@ const Loader = ({
|
|
|
7450
6653
|
}, 1000);
|
|
7451
6654
|
}
|
|
7452
6655
|
return () => {
|
|
7453
|
-
// eslint-disable-next-line fp/no-mutation
|
|
7454
6656
|
cancelled = true;
|
|
7455
6657
|
clearTimeout(timeout);
|
|
7456
6658
|
};
|
|
@@ -9387,7 +8589,7 @@ const explodeNumberModel = number => {
|
|
|
9387
8589
|
};
|
|
9388
8590
|
};
|
|
9389
8591
|
|
|
9390
|
-
const DIGITS_MATCH = /^$|^(\+)|(
|
|
8592
|
+
const DIGITS_MATCH = /^$|^(\+)|(\d+)/g;
|
|
9391
8593
|
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
9392
8594
|
|
|
9393
8595
|
function sortArrayByProperty(arrayToSort, property) {
|
|
@@ -9473,7 +8675,8 @@ const PhoneNumberInput = ({
|
|
|
9473
8675
|
};
|
|
9474
8676
|
useEffect(() => {
|
|
9475
8677
|
if (broadcastedValue === null) {
|
|
9476
|
-
|
|
8678
|
+
setBroadcastedValue(internalValue);
|
|
8679
|
+
return;
|
|
9477
8680
|
}
|
|
9478
8681
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
9479
8682
|
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
@@ -9746,7 +8949,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
9746
8949
|
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
9747
8950
|
...commonProps,
|
|
9748
8951
|
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
9749
|
-
'aria-describedby': `${componentId}-title
|
|
8952
|
+
'aria-describedby': `${componentId}-title`,
|
|
9750
8953
|
'aria-disabled': isDisabled,
|
|
9751
8954
|
'data-value': value ?? undefined,
|
|
9752
8955
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -10399,8 +9602,8 @@ function Select({
|
|
|
10399
9602
|
}
|
|
10400
9603
|
};
|
|
10401
9604
|
function selectKeyboardFocusedOption() {
|
|
10402
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
10403
|
-
|
|
9605
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
9606
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
10404
9607
|
}
|
|
10405
9608
|
}
|
|
10406
9609
|
function moveFocusWithDifference(difference) {
|
|
@@ -10627,7 +9830,6 @@ function Select({
|
|
|
10627
9830
|
disabled: disabled,
|
|
10628
9831
|
"aria-controls": listboxId,
|
|
10629
9832
|
"aria-expanded": open,
|
|
10630
|
-
"aria-autocomplete": "none",
|
|
10631
9833
|
onClick: handleOnClick,
|
|
10632
9834
|
...buttonProps,
|
|
10633
9835
|
children: [selected ? /*#__PURE__*/jsx(Option$1, {
|
|
@@ -10743,12 +9945,11 @@ Select.defaultProps = {
|
|
|
10743
9945
|
|
|
10744
9946
|
const SegmentedControl = ({
|
|
10745
9947
|
name,
|
|
10746
|
-
|
|
9948
|
+
value,
|
|
10747
9949
|
mode = 'input',
|
|
10748
9950
|
segments,
|
|
10749
9951
|
onChange
|
|
10750
9952
|
}) => {
|
|
10751
|
-
const [selectedValue, setSelectedValue] = useState(defaultValue || segments[0].value);
|
|
10752
9953
|
const [animate, setAnimate] = useState(false);
|
|
10753
9954
|
const segmentsRef = useRef(null);
|
|
10754
9955
|
if (segments.length > 3) {
|
|
@@ -10759,7 +9960,7 @@ const SegmentedControl = ({
|
|
|
10759
9960
|
ref: /*#__PURE__*/createRef()
|
|
10760
9961
|
}));
|
|
10761
9962
|
const updateSegmentPosition = () => {
|
|
10762
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value ===
|
|
9963
|
+
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
|
|
10763
9964
|
// We grab the active segments style object from the ref
|
|
10764
9965
|
// and set the css variables to the selected segments width and x position.
|
|
10765
9966
|
// This is so we can animate the highlight to the selected segment
|
|
@@ -10772,6 +9973,7 @@ const SegmentedControl = ({
|
|
|
10772
9973
|
}
|
|
10773
9974
|
};
|
|
10774
9975
|
useEffect(() => {
|
|
9976
|
+
setAnimate(true);
|
|
10775
9977
|
updateSegmentPosition();
|
|
10776
9978
|
const handleWindowSizeChange = () => {
|
|
10777
9979
|
setAnimate(false);
|
|
@@ -10782,10 +9984,7 @@ const SegmentedControl = ({
|
|
|
10782
9984
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
10783
9985
|
};
|
|
10784
9986
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10785
|
-
}, [segmentsWithRefs,
|
|
10786
|
-
useEffect(() => {
|
|
10787
|
-
onChange(selectedValue);
|
|
10788
|
-
}, [onChange, selectedValue]);
|
|
9987
|
+
}, [segmentsWithRefs, value]);
|
|
10789
9988
|
return /*#__PURE__*/jsx("div", {
|
|
10790
9989
|
ref: segmentsRef,
|
|
10791
9990
|
"data-testid": "segmented-control",
|
|
@@ -10797,50 +9996,50 @@ const SegmentedControl = ({
|
|
|
10797
9996
|
'segmented-control__segments--no-animate': !animate
|
|
10798
9997
|
}),
|
|
10799
9998
|
role: mode !== 'input' ? 'tablist' : undefined,
|
|
10800
|
-
children: segmentsWithRefs.map(segment =>
|
|
10801
|
-
|
|
10802
|
-
htmlFor: segment.id,
|
|
10803
|
-
className: classNames('segmented-control__segment', {
|
|
10804
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10805
|
-
}),
|
|
10806
|
-
children: [/*#__PURE__*/jsx("input", {
|
|
10807
|
-
type: "radio",
|
|
10808
|
-
className: "segmented-control__radio-input",
|
|
10809
|
-
id: segment.id,
|
|
10810
|
-
name: name,
|
|
10811
|
-
value: segment.value,
|
|
10812
|
-
checked: selectedValue === segment.value,
|
|
10813
|
-
onChange: () => {
|
|
10814
|
-
setAnimate(true);
|
|
10815
|
-
setSelectedValue(segment.value);
|
|
10816
|
-
}
|
|
10817
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
10818
|
-
className: "segmented-control__text",
|
|
10819
|
-
as: "span",
|
|
10820
|
-
type: selectedValue === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10821
|
-
children: segment.label
|
|
10822
|
-
})]
|
|
10823
|
-
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10824
|
-
ref: segment.ref,
|
|
10825
|
-
type: "button",
|
|
10826
|
-
role: "tab",
|
|
10827
|
-
id: segment.id,
|
|
10828
|
-
"aria-controls": segment.controls,
|
|
10829
|
-
"aria-selected": selectedValue === segment.value,
|
|
10830
|
-
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10831
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10832
|
-
}),
|
|
10833
|
-
onClick: () => {
|
|
9999
|
+
children: segmentsWithRefs.map(segment => {
|
|
10000
|
+
const onSelect = () => {
|
|
10834
10001
|
setAnimate(true);
|
|
10835
|
-
|
|
10836
|
-
}
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10002
|
+
onChange(segment.value);
|
|
10003
|
+
};
|
|
10004
|
+
return mode === 'input' ? /*#__PURE__*/jsxs("label", {
|
|
10005
|
+
ref: segment.ref,
|
|
10006
|
+
htmlFor: segment.id,
|
|
10007
|
+
className: classNames('segmented-control__segment', {
|
|
10008
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10009
|
+
}),
|
|
10010
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
10011
|
+
type: "radio",
|
|
10012
|
+
className: "segmented-control__radio-input",
|
|
10013
|
+
id: segment.id,
|
|
10014
|
+
name: name,
|
|
10015
|
+
value: segment.value,
|
|
10016
|
+
checked: value === segment.value,
|
|
10017
|
+
onChange: onSelect
|
|
10018
|
+
}), /*#__PURE__*/jsx(Body, {
|
|
10019
|
+
className: "segmented-control__text",
|
|
10020
|
+
as: "span",
|
|
10021
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10022
|
+
children: segment.label
|
|
10023
|
+
})]
|
|
10024
|
+
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10025
|
+
ref: segment.ref,
|
|
10026
|
+
type: "button",
|
|
10027
|
+
role: "tab",
|
|
10028
|
+
id: segment.id,
|
|
10029
|
+
"aria-controls": segment.controls,
|
|
10030
|
+
"aria-selected": value === segment.value,
|
|
10031
|
+
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10032
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10033
|
+
}),
|
|
10034
|
+
onClick: onSelect,
|
|
10035
|
+
children: /*#__PURE__*/jsx(Body, {
|
|
10036
|
+
as: "span",
|
|
10037
|
+
className: "segmented-control__text",
|
|
10038
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10039
|
+
children: segment.label
|
|
10040
|
+
})
|
|
10041
|
+
}, segment.id);
|
|
10042
|
+
})
|
|
10844
10043
|
})
|
|
10845
10044
|
});
|
|
10846
10045
|
};
|
|
@@ -14050,7 +13249,7 @@ function CriticalCommsBanner({
|
|
|
14050
13249
|
type: AvatarType.ICON,
|
|
14051
13250
|
className: classNames(isModern ? 'm-r-2' : 'm-r-1'),
|
|
14052
13251
|
backgroundColor: isModern ? 'var(--color-sentiment-negative)' : 'var(--color-background-negative)',
|
|
14053
|
-
children: isModern ? /*#__PURE__*/jsx(AlertCircleFill, {}) : /*#__PURE__*/jsx(Alert$
|
|
13252
|
+
children: isModern ? /*#__PURE__*/jsx(AlertCircleFill, {}) : /*#__PURE__*/jsx(Alert$1, {
|
|
14054
13253
|
size: 24
|
|
14055
13254
|
})
|
|
14056
13255
|
}), /*#__PURE__*/jsxs("div", {
|
|
@@ -14834,10 +14033,10 @@ var th = {
|
|
|
14834
14033
|
"neptune.ClearButton.ariaLabel": "ล้าง",
|
|
14835
14034
|
"neptune.CloseButton.ariaLabel": "ปิด",
|
|
14836
14035
|
"neptune.DateInput.day.label": "วัน",
|
|
14837
|
-
"neptune.DateInput.day.placeholder": "
|
|
14036
|
+
"neptune.DateInput.day.placeholder": "วัน",
|
|
14838
14037
|
"neptune.DateInput.month.label": "เดือน",
|
|
14839
14038
|
"neptune.DateInput.year.label": "ปี",
|
|
14840
|
-
"neptune.DateInput.year.placeholder": "
|
|
14039
|
+
"neptune.DateInput.year.placeholder": "ปี",
|
|
14841
14040
|
"neptune.DateLookup.day": "วัน",
|
|
14842
14041
|
"neptune.DateLookup.goTo20YearView": "ไปที่มุมมอง 20 ปี",
|
|
14843
14042
|
"neptune.DateLookup.month": "เดือน",
|
|
@@ -15139,5 +14338,5 @@ const translations = {
|
|
|
15139
14338
|
'zh-HK': zhHK
|
|
15140
14339
|
};
|
|
15141
14340
|
|
|
15142
|
-
export { Accordion, ActionButton, ActionOption, Alert
|
|
14341
|
+
export { Accordion, ActionButton, ActionOption, Alert, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
15143
14342
|
//# sourceMappingURL=index.mjs.map
|