@transferwise/components 46.30.1 → 46.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +190 -57
- package/build/index.js.map +1 -1
- package/build/index.mjs +189 -58
- package/build/index.mjs.map +1 -1
- package/build/types/dateInput/DateInput.d.ts +5 -4
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +11 -4
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/field/Field.d.ts +12 -0
- package/build/types/field/Field.d.ts.map +1 -0
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/Input.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/_common.d.ts +2 -2
- package/build/types/inputs/_common.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +24 -0
- package/build/types/inputs/contexts.d.ts.map +1 -0
- package/build/types/label/Label.d.ts +9 -0
- package/build/types/label/Label.d.ts.map +1 -0
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/switch/Switch.d.ts +6 -3
- package/build/types/switch/Switch.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/dateInput/DateInput.rtl.spec.tsx +17 -0
- package/src/dateInput/DateInput.tsx +28 -22
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +2 -2
- package/src/dateLookup/DateLookup.rtl.spec.tsx +21 -0
- package/src/dateLookup/DateLookup.state.spec.js +5 -5
- package/src/dateLookup/DateLookup.tests.story.tsx +4 -11
- package/src/dateLookup/DateLookup.tsx +24 -9
- package/src/dateLookup/DateLookup.view.spec.js +11 -11
- package/src/field/Field.spec.tsx +95 -0
- package/src/field/Field.story.tsx +59 -0
- package/src/field/Field.tsx +70 -0
- package/src/index.ts +4 -0
- package/src/inputs/Input.tsx +5 -3
- package/src/inputs/SelectInput.spec.tsx +10 -0
- package/src/inputs/SelectInput.tsx +9 -4
- package/src/inputs/TextArea.tsx +6 -3
- package/src/inputs/_ButtonInput.tsx +2 -2
- package/src/inputs/_common.ts +2 -2
- package/src/inputs/contexts.tsx +45 -0
- package/src/label/Label.spec.tsx +26 -0
- package/src/label/Label.story.tsx +37 -0
- package/src/label/Label.tsx +20 -0
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +16 -22
- package/src/phoneNumberInput/PhoneNumberInput.tsx +14 -2
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +14 -0
- package/src/radioGroup/RadioGroup.story.tsx +26 -0
- package/src/radioGroup/RadioGroup.tsx +4 -1
- package/src/switch/Switch.spec.tsx +10 -0
- package/src/switch/Switch.tsx +22 -13
- package/src/utilities/logActionRequired.js +1 -1
package/build/index.js
CHANGED
|
@@ -826,7 +826,7 @@ function Title({
|
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
function logActionRequired(message) {
|
|
829
|
-
if (
|
|
829
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
|
|
830
830
|
// eslint-disable-next-line no-console
|
|
831
831
|
console.warn(message);
|
|
832
832
|
}
|
|
@@ -2622,6 +2622,36 @@ const isMonthAndYearFormat = dateString => validDateString(dateString) && dateSt
|
|
|
2622
2622
|
const MDY = new Set(['en-US']);
|
|
2623
2623
|
const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
|
|
2624
2624
|
|
|
2625
|
+
const FieldLabelIdContext = /*#__PURE__*/React.createContext(undefined);
|
|
2626
|
+
const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
|
|
2627
|
+
const InputIdContext = /*#__PURE__*/React.createContext(undefined);
|
|
2628
|
+
const InputIdContextProvider = InputIdContext.Provider;
|
|
2629
|
+
const InputDescribedByContext = /*#__PURE__*/React.createContext(undefined);
|
|
2630
|
+
const InputDescribedByProvider = InputDescribedByContext.Provider;
|
|
2631
|
+
const InputInvalidContext = /*#__PURE__*/React.createContext(undefined);
|
|
2632
|
+
const InputInvalidProvider = InputInvalidContext.Provider;
|
|
2633
|
+
function useInputAttributes({
|
|
2634
|
+
nonLabelable
|
|
2635
|
+
} = {}) {
|
|
2636
|
+
const labelId = React.useContext(FieldLabelIdContext);
|
|
2637
|
+
return {
|
|
2638
|
+
id: React.useContext(InputIdContext),
|
|
2639
|
+
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
2640
|
+
'aria-describedby': React.useContext(InputDescribedByContext),
|
|
2641
|
+
'aria-invalid': React.useContext(InputInvalidContext)
|
|
2642
|
+
};
|
|
2643
|
+
}
|
|
2644
|
+
function withInputAttributes(Component, args) {
|
|
2645
|
+
function ComponentWithInputAttributes(props) {
|
|
2646
|
+
return /*#__PURE__*/jsxRuntime.jsx(Component, {
|
|
2647
|
+
inputAttributes: useInputAttributes(args),
|
|
2648
|
+
...props
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
|
|
2652
|
+
return ComponentWithInputAttributes;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2625
2655
|
var messages$9 = reactIntl.defineMessages({
|
|
2626
2656
|
monthLabel: {
|
|
2627
2657
|
id: "neptune.DateInput.month.label"
|
|
@@ -2646,7 +2676,7 @@ const convertToLocalMidnight = date => {
|
|
|
2646
2676
|
};
|
|
2647
2677
|
|
|
2648
2678
|
const DateInput = ({
|
|
2649
|
-
'aria-labelledby':
|
|
2679
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
2650
2680
|
'aria-label': ariaLabel,
|
|
2651
2681
|
disabled = false,
|
|
2652
2682
|
size = exports.Size.MEDIUM,
|
|
@@ -2662,9 +2692,14 @@ const DateInput = ({
|
|
|
2662
2692
|
onFocus,
|
|
2663
2693
|
onBlur,
|
|
2664
2694
|
placeholders,
|
|
2665
|
-
id,
|
|
2695
|
+
id: idProp,
|
|
2666
2696
|
selectProps = {}
|
|
2667
2697
|
}) => {
|
|
2698
|
+
const inputAttributes = useInputAttributes({
|
|
2699
|
+
nonLabelable: true
|
|
2700
|
+
});
|
|
2701
|
+
const id = idProp ?? inputAttributes.id;
|
|
2702
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
|
|
2668
2703
|
const {
|
|
2669
2704
|
locale,
|
|
2670
2705
|
formatMessage
|
|
@@ -2701,9 +2736,9 @@ const DateInput = ({
|
|
|
2701
2736
|
const [year, setYear] = React.useState(() => getInitialDate('year'));
|
|
2702
2737
|
const [lastBroadcastedValue, setLastBroadcastedValue] = React.useState(getDateObject);
|
|
2703
2738
|
const monthNames = getMonthNames(locale, monthFormat);
|
|
2704
|
-
dayLabel
|
|
2705
|
-
monthLabel
|
|
2706
|
-
yearLabel
|
|
2739
|
+
dayLabel ||= formatMessage(messages$9.dayLabel);
|
|
2740
|
+
monthLabel ||= formatMessage(messages$9.monthLabel);
|
|
2741
|
+
yearLabel ||= formatMessage(messages$9.yearLabel);
|
|
2707
2742
|
placeholders = {
|
|
2708
2743
|
day: placeholders?.day || formatMessage(messages$9.dayPlaceholder),
|
|
2709
2744
|
month: placeholders?.month || formatMessage(messages$9.monthLabel),
|
|
@@ -2894,6 +2929,7 @@ const DateInput = ({
|
|
|
2894
2929
|
const yearFirst = YMD.has(locale);
|
|
2895
2930
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2896
2931
|
className: "tw-date",
|
|
2932
|
+
...inputAttributes,
|
|
2897
2933
|
id: id,
|
|
2898
2934
|
"aria-labelledby": ariaLabelledBy,
|
|
2899
2935
|
"aria-label": ariaLabel,
|
|
@@ -2913,15 +2949,15 @@ const DateInput = ({
|
|
|
2913
2949
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2914
2950
|
children: [getMonth(), getDay(), getYear()]
|
|
2915
2951
|
});
|
|
2916
|
-
}
|
|
2952
|
+
}
|
|
2953
|
+
if (yearFirst) {
|
|
2917
2954
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2918
2955
|
children: [getYear(), getMonth(), getDay()]
|
|
2919
2956
|
});
|
|
2920
|
-
} else {
|
|
2921
|
-
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2922
|
-
children: [getDay(), getMonth(), getYear()]
|
|
2923
|
-
});
|
|
2924
2957
|
}
|
|
2958
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2959
|
+
children: [getDay(), getMonth(), getYear()]
|
|
2960
|
+
});
|
|
2925
2961
|
})()
|
|
2926
2962
|
})
|
|
2927
2963
|
});
|
|
@@ -4022,18 +4058,23 @@ class DateLookup extends React.PureComponent {
|
|
|
4022
4058
|
open
|
|
4023
4059
|
} = this.state;
|
|
4024
4060
|
const {
|
|
4061
|
+
inputAttributes,
|
|
4062
|
+
id: idProp,
|
|
4063
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
4025
4064
|
size,
|
|
4026
4065
|
placeholder,
|
|
4027
4066
|
label,
|
|
4028
|
-
'aria-labelledby': ariaLabelledBy,
|
|
4029
4067
|
monthFormat,
|
|
4030
4068
|
disabled,
|
|
4031
4069
|
clearable,
|
|
4032
4070
|
value
|
|
4033
4071
|
} = this.props;
|
|
4072
|
+
const id = idProp ?? inputAttributes?.id;
|
|
4073
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
|
|
4034
4074
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4035
4075
|
ref: this.element,
|
|
4036
|
-
|
|
4076
|
+
...inputAttributes,
|
|
4077
|
+
id: id,
|
|
4037
4078
|
"aria-labelledby": ariaLabelledBy,
|
|
4038
4079
|
className: "input-group",
|
|
4039
4080
|
onKeyDown: this.handleKeyDown,
|
|
@@ -4057,6 +4098,9 @@ class DateLookup extends React.PureComponent {
|
|
|
4057
4098
|
});
|
|
4058
4099
|
}
|
|
4059
4100
|
}
|
|
4101
|
+
var DateLookup$1 = withInputAttributes(DateLookup, {
|
|
4102
|
+
nonLabelable: true
|
|
4103
|
+
});
|
|
4060
4104
|
|
|
4061
4105
|
const NavigationOption = /*#__PURE__*/React.forwardRef(({
|
|
4062
4106
|
as: component = 'button',
|
|
@@ -4903,6 +4947,84 @@ const FlowNavigation = ({
|
|
|
4903
4947
|
});
|
|
4904
4948
|
};
|
|
4905
4949
|
|
|
4950
|
+
function InlineAlert({
|
|
4951
|
+
id,
|
|
4952
|
+
type = 'neutral',
|
|
4953
|
+
className,
|
|
4954
|
+
children
|
|
4955
|
+
}) {
|
|
4956
|
+
const danger = type === 'negative' || type === 'error';
|
|
4957
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
4958
|
+
role: "alert",
|
|
4959
|
+
id: id,
|
|
4960
|
+
className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
4961
|
+
children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4962
|
+
children: children
|
|
4963
|
+
})]
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4966
|
+
|
|
4967
|
+
const Label = ({
|
|
4968
|
+
id,
|
|
4969
|
+
htmlFor,
|
|
4970
|
+
className,
|
|
4971
|
+
children
|
|
4972
|
+
}) => {
|
|
4973
|
+
return /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
4974
|
+
id: id,
|
|
4975
|
+
htmlFor: htmlFor,
|
|
4976
|
+
className: classNames__default.default('control-label d-flex flex-column gap-y-1 m-b-0', className),
|
|
4977
|
+
children: children
|
|
4978
|
+
});
|
|
4979
|
+
};
|
|
4980
|
+
|
|
4981
|
+
const Field = ({
|
|
4982
|
+
id,
|
|
4983
|
+
label,
|
|
4984
|
+
hint,
|
|
4985
|
+
error,
|
|
4986
|
+
className,
|
|
4987
|
+
children
|
|
4988
|
+
}) => {
|
|
4989
|
+
const hasError = Boolean(error);
|
|
4990
|
+
const hasHint = Boolean(hint) && !hasError;
|
|
4991
|
+
const labelId = reactId.useId();
|
|
4992
|
+
const fallbackInputId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
|
|
4993
|
+
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
4994
|
+
const descriptionId = reactId.useId(); // TODO: Use `React.useId()` when react>=18
|
|
4995
|
+
return /*#__PURE__*/jsxRuntime.jsx(FieldLabelIdContextProvider, {
|
|
4996
|
+
value: labelId,
|
|
4997
|
+
children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
|
|
4998
|
+
value: inputId,
|
|
4999
|
+
children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
|
|
5000
|
+
value: hasError || hasHint ? descriptionId : undefined,
|
|
5001
|
+
children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
|
|
5002
|
+
value: hasError,
|
|
5003
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5004
|
+
className: classNames__default.default('form-group d-block', {
|
|
5005
|
+
'has-error': hasError,
|
|
5006
|
+
'has-info': hasHint
|
|
5007
|
+
}, className),
|
|
5008
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
|
|
5009
|
+
id: labelId,
|
|
5010
|
+
htmlFor: inputId,
|
|
5011
|
+
children: [label, children]
|
|
5012
|
+
}), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
5013
|
+
type: exports.Sentiment.NEUTRAL,
|
|
5014
|
+
id: descriptionId,
|
|
5015
|
+
children: hint
|
|
5016
|
+
}), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
5017
|
+
type: exports.Sentiment.NEGATIVE,
|
|
5018
|
+
id: descriptionId,
|
|
5019
|
+
children: error
|
|
5020
|
+
})]
|
|
5021
|
+
})
|
|
5022
|
+
})
|
|
5023
|
+
})
|
|
5024
|
+
})
|
|
5025
|
+
});
|
|
5026
|
+
};
|
|
5027
|
+
|
|
4906
5028
|
const HeaderAction = ({
|
|
4907
5029
|
action
|
|
4908
5030
|
}) => {
|
|
@@ -5235,20 +5357,16 @@ const Info = ({
|
|
|
5235
5357
|
});
|
|
5236
5358
|
};
|
|
5237
5359
|
|
|
5238
|
-
function
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
|
|
5249
|
-
children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5250
|
-
children: children
|
|
5251
|
-
})]
|
|
5360
|
+
function inputClassNameBase({
|
|
5361
|
+
size = 'auto'
|
|
5362
|
+
} = {}) {
|
|
5363
|
+
return classNames__default.default('form-control',
|
|
5364
|
+
// TODO: Deprecate
|
|
5365
|
+
'np-form-control', {
|
|
5366
|
+
'np-form-control--size-auto': size === 'auto',
|
|
5367
|
+
'np-form-control--size-sm': size === 'sm',
|
|
5368
|
+
'np-form-control--size-md': size === 'md',
|
|
5369
|
+
'np-form-control--size-lg': size === 'lg'
|
|
5252
5370
|
});
|
|
5253
5371
|
}
|
|
5254
5372
|
|
|
@@ -5370,29 +5488,17 @@ function InputAddon({
|
|
|
5370
5488
|
});
|
|
5371
5489
|
}
|
|
5372
5490
|
|
|
5373
|
-
function formControlClassNameBase({
|
|
5374
|
-
size = 'auto'
|
|
5375
|
-
} = {}) {
|
|
5376
|
-
return classNames__default.default('form-control',
|
|
5377
|
-
// TODO: Deprecate
|
|
5378
|
-
'np-form-control', {
|
|
5379
|
-
'np-form-control--size-auto': size === 'auto',
|
|
5380
|
-
'np-form-control--size-sm': size === 'sm',
|
|
5381
|
-
'np-form-control--size-md': size === 'md',
|
|
5382
|
-
'np-form-control--size-lg': size === 'lg'
|
|
5383
|
-
});
|
|
5384
|
-
}
|
|
5385
|
-
|
|
5386
5491
|
const Input = /*#__PURE__*/React.forwardRef(function Input({
|
|
5387
5492
|
size = 'auto',
|
|
5388
5493
|
shape = 'rectangle',
|
|
5389
5494
|
className,
|
|
5390
5495
|
...restProps
|
|
5391
5496
|
}, reference) {
|
|
5497
|
+
const inputAttributes = useInputAttributes();
|
|
5392
5498
|
const inputPaddings = useInputPaddings();
|
|
5393
5499
|
return /*#__PURE__*/jsxRuntime.jsx("input", {
|
|
5394
5500
|
ref: reference,
|
|
5395
|
-
className: classNames__default.default(className,
|
|
5501
|
+
className: classNames__default.default(className, inputClassNameBase({
|
|
5396
5502
|
size
|
|
5397
5503
|
}), 'np-input', {
|
|
5398
5504
|
'np-input--shape-rectangle': shape === 'rectangle',
|
|
@@ -5401,6 +5507,7 @@ const Input = /*#__PURE__*/React.forwardRef(function Input({
|
|
|
5401
5507
|
// eslint-disable-next-line react/forbid-dom-props
|
|
5402
5508
|
,
|
|
5403
5509
|
style: inputPaddings,
|
|
5510
|
+
...inputAttributes,
|
|
5404
5511
|
...restProps
|
|
5405
5512
|
});
|
|
5406
5513
|
});
|
|
@@ -5822,12 +5929,6 @@ const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function Polymorp
|
|
|
5822
5929
|
});
|
|
5823
5930
|
});
|
|
5824
5931
|
|
|
5825
|
-
var messages$5 = reactIntl.defineMessages({
|
|
5826
|
-
noResultsFound: {
|
|
5827
|
-
id: "neptune.SelectInput.noResultsFound"
|
|
5828
|
-
}
|
|
5829
|
-
});
|
|
5830
|
-
|
|
5831
5932
|
function PreventScroll() {
|
|
5832
5933
|
overlays.usePreventScroll();
|
|
5833
5934
|
return null;
|
|
@@ -5947,7 +6048,7 @@ const ButtonInput = /*#__PURE__*/React.forwardRef(function ButtonInput({
|
|
|
5947
6048
|
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
5948
6049
|
ref: ref,
|
|
5949
6050
|
type: "button",
|
|
5950
|
-
className: classNames__default.default(className,
|
|
6051
|
+
className: classNames__default.default(className, inputClassNameBase({
|
|
5951
6052
|
size
|
|
5952
6053
|
}), 'np-button-input')
|
|
5953
6054
|
// eslint-disable-next-line react/forbid-dom-props
|
|
@@ -6063,6 +6164,12 @@ function Popover({
|
|
|
6063
6164
|
});
|
|
6064
6165
|
}
|
|
6065
6166
|
|
|
6167
|
+
var messages$5 = reactIntl.defineMessages({
|
|
6168
|
+
noResultsFound: {
|
|
6169
|
+
id: "neptune.SelectInput.noResultsFound"
|
|
6170
|
+
}
|
|
6171
|
+
});
|
|
6172
|
+
|
|
6066
6173
|
function searchableString(value) {
|
|
6067
6174
|
return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
|
|
6068
6175
|
}
|
|
@@ -6182,7 +6289,7 @@ function SelectInputClearButton({
|
|
|
6182
6289
|
}
|
|
6183
6290
|
const noop = () => {};
|
|
6184
6291
|
function SelectInput({
|
|
6185
|
-
id,
|
|
6292
|
+
id: idProp,
|
|
6186
6293
|
name,
|
|
6187
6294
|
multiple,
|
|
6188
6295
|
placeholder,
|
|
@@ -6203,6 +6310,8 @@ function SelectInput({
|
|
|
6203
6310
|
onClose,
|
|
6204
6311
|
onClear
|
|
6205
6312
|
}) {
|
|
6313
|
+
const inputAttributes = useInputAttributes();
|
|
6314
|
+
const id = idProp ?? inputAttributes.id;
|
|
6206
6315
|
const [open, setOpen] = React.useState(false);
|
|
6207
6316
|
const initialized = React.useRef(false);
|
|
6208
6317
|
const handleClose = useEffectEvent(onClose ?? (() => {}));
|
|
@@ -6263,6 +6372,7 @@ function SelectInput({
|
|
|
6263
6372
|
ref(node);
|
|
6264
6373
|
triggerRef.current = node;
|
|
6265
6374
|
},
|
|
6375
|
+
...inputAttributes,
|
|
6266
6376
|
id,
|
|
6267
6377
|
...mergeProps__default.default({
|
|
6268
6378
|
onClick: () => {
|
|
@@ -6616,9 +6726,11 @@ const TextArea = /*#__PURE__*/React.forwardRef(function TextArea({
|
|
|
6616
6726
|
className,
|
|
6617
6727
|
...restProps
|
|
6618
6728
|
}, reference) {
|
|
6729
|
+
const inputAttributes = useInputAttributes();
|
|
6619
6730
|
return /*#__PURE__*/jsxRuntime.jsx("textarea", {
|
|
6620
6731
|
ref: reference,
|
|
6621
|
-
className: classNames__default.default(className,
|
|
6732
|
+
className: classNames__default.default(className, inputClassNameBase(), 'np-text-area'),
|
|
6733
|
+
...inputAttributes,
|
|
6622
6734
|
...restProps
|
|
6623
6735
|
});
|
|
6624
6736
|
});
|
|
@@ -8735,6 +8847,12 @@ const PhoneNumberInput = ({
|
|
|
8735
8847
|
return explodeNumberModel(cleanValue);
|
|
8736
8848
|
});
|
|
8737
8849
|
const [broadcastedValue, setBroadcastedValue] = React.useState(null);
|
|
8850
|
+
const [suffixDirty, setSuffixDirty] = React.useState(false);
|
|
8851
|
+
React.useEffect(() => {
|
|
8852
|
+
if (internalValue.suffix) {
|
|
8853
|
+
setSuffixDirty(true);
|
|
8854
|
+
}
|
|
8855
|
+
}, [internalValue.suffix]);
|
|
8738
8856
|
const countriesByPrefix = React.useMemo(() => groupCountriesByPrefix(sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3')), [disabledCountries]);
|
|
8739
8857
|
const onSuffixChange = event => {
|
|
8740
8858
|
const suffix = event.target.value;
|
|
@@ -8798,6 +8916,11 @@ const PhoneNumberInput = ({
|
|
|
8798
8916
|
format: country?.phoneFormat
|
|
8799
8917
|
}));
|
|
8800
8918
|
},
|
|
8919
|
+
onClose: () => {
|
|
8920
|
+
if (suffixDirty) {
|
|
8921
|
+
onBlur?.();
|
|
8922
|
+
}
|
|
8923
|
+
},
|
|
8801
8924
|
...selectProps
|
|
8802
8925
|
})
|
|
8803
8926
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -8817,7 +8940,7 @@ const PhoneNumberInput = ({
|
|
|
8817
8940
|
onChange: onSuffixChange,
|
|
8818
8941
|
onPaste: onPaste,
|
|
8819
8942
|
onFocus: onFocus,
|
|
8820
|
-
onBlur: onBlur
|
|
8943
|
+
onBlur: () => onBlur?.()
|
|
8821
8944
|
})
|
|
8822
8945
|
})
|
|
8823
8946
|
})]
|
|
@@ -9364,9 +9487,13 @@ function RadioGroup({
|
|
|
9364
9487
|
selectedValue: controlledValue,
|
|
9365
9488
|
onChange
|
|
9366
9489
|
}) {
|
|
9490
|
+
const inputAttributes = useInputAttributes({
|
|
9491
|
+
nonLabelable: true
|
|
9492
|
+
});
|
|
9367
9493
|
const [uncontrolledValue, setUncontrolledValue] = React.useState(controlledValue);
|
|
9368
9494
|
return radios.length > 0 ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
9369
9495
|
role: "radiogroup",
|
|
9496
|
+
...inputAttributes,
|
|
9370
9497
|
children: radios.map(({
|
|
9371
9498
|
value = '',
|
|
9372
9499
|
...restProps
|
|
@@ -10478,13 +10605,18 @@ const Summary = ({
|
|
|
10478
10605
|
};
|
|
10479
10606
|
|
|
10480
10607
|
const Switch = props => {
|
|
10608
|
+
const inputAttributes = useInputAttributes({
|
|
10609
|
+
nonLabelable: true
|
|
10610
|
+
});
|
|
10481
10611
|
const {
|
|
10482
10612
|
isModern
|
|
10483
10613
|
} = componentsTheming.useTheme();
|
|
10484
10614
|
const {
|
|
10485
10615
|
checked,
|
|
10486
10616
|
className,
|
|
10487
|
-
id,
|
|
10617
|
+
id = inputAttributes.id,
|
|
10618
|
+
'aria-label': ariaLabel,
|
|
10619
|
+
'aria-labelledby': ariaLabelledbyProp,
|
|
10488
10620
|
onClick,
|
|
10489
10621
|
disabled
|
|
10490
10622
|
} = props;
|
|
@@ -10515,19 +10647,18 @@ const Switch = props => {
|
|
|
10515
10647
|
})
|
|
10516
10648
|
});
|
|
10517
10649
|
};
|
|
10518
|
-
const
|
|
10519
|
-
const ariaLabelledby = ariaLabel ? undefined : props['aria-labelledby'];
|
|
10520
|
-
logActionRequiredIf('Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.', !ariaLabel && !ariaLabelledby);
|
|
10650
|
+
const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
|
|
10521
10651
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
10522
10652
|
className: classNames__default.default('np-switch', {
|
|
10523
10653
|
'np-switch--unchecked': !checked,
|
|
10524
10654
|
'np-switch--checked': checked,
|
|
10525
|
-
disabled
|
|
10655
|
+
disabled
|
|
10526
10656
|
}, className),
|
|
10527
10657
|
tabIndex: 0,
|
|
10528
10658
|
role: "switch",
|
|
10529
10659
|
"aria-checked": checked,
|
|
10530
10660
|
"aria-label": ariaLabel,
|
|
10661
|
+
...inputAttributes,
|
|
10531
10662
|
"aria-labelledby": ariaLabelledby,
|
|
10532
10663
|
id: id,
|
|
10533
10664
|
"aria-disabled": disabled,
|
|
@@ -14406,7 +14537,7 @@ exports.CriticalCommsBanner = CriticalCommsBanner;
|
|
|
14406
14537
|
exports.DEFAULT_LANG = DEFAULT_LANG;
|
|
14407
14538
|
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
14408
14539
|
exports.DateInput = DateInput;
|
|
14409
|
-
exports.DateLookup = DateLookup;
|
|
14540
|
+
exports.DateLookup = DateLookup$1;
|
|
14410
14541
|
exports.Decision = Decision;
|
|
14411
14542
|
exports.DefinitionList = DefinitionList$1;
|
|
14412
14543
|
exports.Dimmer = Dimmer$1;
|
|
@@ -14415,6 +14546,7 @@ exports.Display = Display;
|
|
|
14415
14546
|
exports.Drawer = Drawer$1;
|
|
14416
14547
|
exports.DropFade = DropFade;
|
|
14417
14548
|
exports.Emphasis = Emphasis;
|
|
14549
|
+
exports.Field = Field;
|
|
14418
14550
|
exports.FlowNavigation = FlowNavigation;
|
|
14419
14551
|
exports.Header = Header;
|
|
14420
14552
|
exports.Image = Image;
|
|
@@ -14424,6 +14556,7 @@ exports.Input = Input;
|
|
|
14424
14556
|
exports.InputGroup = InputGroup;
|
|
14425
14557
|
exports.InputWithDisplayFormat = InputWithDisplayFormat;
|
|
14426
14558
|
exports.InstructionsList = InstructionsList;
|
|
14559
|
+
exports.Label = Label;
|
|
14427
14560
|
exports.LanguageProvider = LanguageProvider;
|
|
14428
14561
|
exports.Link = Link;
|
|
14429
14562
|
exports.ListItem = ListItem$1;
|