@transferwise/components 0.0.0-experimental-11854c7 → 0.0.0-experimental-bf4cb26
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 +36 -30
- package/build/index.js.map +1 -1
- package/build/index.mjs +36 -30
- package/build/index.mjs.map +1 -1
- package/build/types/dateInput/DateInput.d.ts +3 -2
- package/build/types/dateInput/DateInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dateInput/DateInput.rtl.spec.tsx +17 -0
- package/src/dateInput/DateInput.tsx +24 -18
package/build/index.mjs
CHANGED
|
@@ -2592,6 +2592,26 @@ const isMonthAndYearFormat = dateString => validDateString(dateString) && dateSt
|
|
|
2592
2592
|
const MDY = new Set(['en-US']);
|
|
2593
2593
|
const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
|
|
2594
2594
|
|
|
2595
|
+
const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
|
|
2596
|
+
const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
|
|
2597
|
+
const InputIdContext = /*#__PURE__*/createContext(undefined);
|
|
2598
|
+
const InputIdContextProvider = InputIdContext.Provider;
|
|
2599
|
+
const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
|
|
2600
|
+
const InputDescribedByProvider = InputDescribedByContext.Provider;
|
|
2601
|
+
const InputInvalidContext = /*#__PURE__*/createContext(undefined);
|
|
2602
|
+
const InputInvalidProvider = InputInvalidContext.Provider;
|
|
2603
|
+
function useInputAttributes({
|
|
2604
|
+
nonLabelable = false
|
|
2605
|
+
} = {}) {
|
|
2606
|
+
const labelId = useContext(FieldLabelIdContext);
|
|
2607
|
+
return {
|
|
2608
|
+
id: useContext(InputIdContext),
|
|
2609
|
+
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
2610
|
+
'aria-describedby': useContext(InputDescribedByContext),
|
|
2611
|
+
'aria-invalid': useContext(InputInvalidContext)
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2595
2615
|
var messages$9 = defineMessages({
|
|
2596
2616
|
monthLabel: {
|
|
2597
2617
|
id: "neptune.DateInput.month.label"
|
|
@@ -2616,7 +2636,7 @@ const convertToLocalMidnight = date => {
|
|
|
2616
2636
|
};
|
|
2617
2637
|
|
|
2618
2638
|
const DateInput = ({
|
|
2619
|
-
'aria-labelledby':
|
|
2639
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
2620
2640
|
'aria-label': ariaLabel,
|
|
2621
2641
|
disabled = false,
|
|
2622
2642
|
size = Size.MEDIUM,
|
|
@@ -2632,9 +2652,14 @@ const DateInput = ({
|
|
|
2632
2652
|
onFocus,
|
|
2633
2653
|
onBlur,
|
|
2634
2654
|
placeholders,
|
|
2635
|
-
id,
|
|
2655
|
+
id: idProp,
|
|
2636
2656
|
selectProps = {}
|
|
2637
2657
|
}) => {
|
|
2658
|
+
const inputAttributes = useInputAttributes({
|
|
2659
|
+
nonLabelable: true
|
|
2660
|
+
});
|
|
2661
|
+
const id = idProp ?? inputAttributes.id;
|
|
2662
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
|
|
2638
2663
|
const {
|
|
2639
2664
|
locale,
|
|
2640
2665
|
formatMessage
|
|
@@ -2671,9 +2696,9 @@ const DateInput = ({
|
|
|
2671
2696
|
const [year, setYear] = useState(() => getInitialDate('year'));
|
|
2672
2697
|
const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
|
|
2673
2698
|
const monthNames = getMonthNames(locale, monthFormat);
|
|
2674
|
-
dayLabel
|
|
2675
|
-
monthLabel
|
|
2676
|
-
yearLabel
|
|
2699
|
+
dayLabel ||= formatMessage(messages$9.dayLabel);
|
|
2700
|
+
monthLabel ||= formatMessage(messages$9.monthLabel);
|
|
2701
|
+
yearLabel ||= formatMessage(messages$9.yearLabel);
|
|
2677
2702
|
placeholders = {
|
|
2678
2703
|
day: placeholders?.day || formatMessage(messages$9.dayPlaceholder),
|
|
2679
2704
|
month: placeholders?.month || formatMessage(messages$9.monthLabel),
|
|
@@ -2864,6 +2889,7 @@ const DateInput = ({
|
|
|
2864
2889
|
const yearFirst = YMD.has(locale);
|
|
2865
2890
|
return /*#__PURE__*/jsx("div", {
|
|
2866
2891
|
className: "tw-date",
|
|
2892
|
+
...inputAttributes,
|
|
2867
2893
|
id: id,
|
|
2868
2894
|
"aria-labelledby": ariaLabelledBy,
|
|
2869
2895
|
"aria-label": ariaLabel,
|
|
@@ -2883,15 +2909,15 @@ const DateInput = ({
|
|
|
2883
2909
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
2884
2910
|
children: [getMonth(), getDay(), getYear()]
|
|
2885
2911
|
});
|
|
2886
|
-
}
|
|
2912
|
+
}
|
|
2913
|
+
if (yearFirst) {
|
|
2887
2914
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
2888
2915
|
children: [getYear(), getMonth(), getDay()]
|
|
2889
2916
|
});
|
|
2890
|
-
} else {
|
|
2891
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
2892
|
-
children: [getDay(), getMonth(), getYear()]
|
|
2893
|
-
});
|
|
2894
2917
|
}
|
|
2918
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
2919
|
+
children: [getDay(), getMonth(), getYear()]
|
|
2920
|
+
});
|
|
2895
2921
|
})()
|
|
2896
2922
|
})
|
|
2897
2923
|
});
|
|
@@ -4890,26 +4916,6 @@ function InlineAlert({
|
|
|
4890
4916
|
});
|
|
4891
4917
|
}
|
|
4892
4918
|
|
|
4893
|
-
const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
|
|
4894
|
-
const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
|
|
4895
|
-
const InputIdContext = /*#__PURE__*/createContext(undefined);
|
|
4896
|
-
const InputIdContextProvider = InputIdContext.Provider;
|
|
4897
|
-
const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
|
|
4898
|
-
const InputDescribedByProvider = InputDescribedByContext.Provider;
|
|
4899
|
-
const InputInvalidContext = /*#__PURE__*/createContext(undefined);
|
|
4900
|
-
const InputInvalidProvider = InputInvalidContext.Provider;
|
|
4901
|
-
function useInputAttributes({
|
|
4902
|
-
nonLabelable = false
|
|
4903
|
-
} = {}) {
|
|
4904
|
-
const labelId = useContext(FieldLabelIdContext);
|
|
4905
|
-
return {
|
|
4906
|
-
id: useContext(InputIdContext),
|
|
4907
|
-
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
4908
|
-
'aria-describedby': useContext(InputDescribedByContext),
|
|
4909
|
-
'aria-invalid': useContext(InputInvalidContext)
|
|
4910
|
-
};
|
|
4911
|
-
}
|
|
4912
|
-
|
|
4913
4919
|
const Label = ({
|
|
4914
4920
|
id,
|
|
4915
4921
|
htmlFor,
|