@react-aria/datepicker 3.5.0 → 3.7.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/dist/import.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import {createFocusManager as $cIPI0$createFocusManager, getFocusableTreeWalker as $cIPI0$getFocusableTreeWalker} from "@react-aria/focus";
2
- import {useId as $cIPI0$useId, useDescription as $cIPI0$useDescription, filterDOMProps as $cIPI0$filterDOMProps, mergeProps as $cIPI0$mergeProps, isMac as $cIPI0$isMac, scrollIntoViewport as $cIPI0$scrollIntoViewport, getScrollParent as $cIPI0$getScrollParent, useEvent as $cIPI0$useEvent, useLayoutEffect as $cIPI0$useLayoutEffect, isIOS as $cIPI0$isIOS, useLabels as $cIPI0$useLabels} from "@react-aria/utils";
2
+ import {useId as $cIPI0$useId, useDescription as $cIPI0$useDescription, filterDOMProps as $cIPI0$filterDOMProps, mergeProps as $cIPI0$mergeProps, useFormReset as $cIPI0$useFormReset, isMac as $cIPI0$isMac, scrollIntoViewport as $cIPI0$scrollIntoViewport, getScrollParent as $cIPI0$getScrollParent, useEvent as $cIPI0$useEvent, useLayoutEffect as $cIPI0$useLayoutEffect, isIOS as $cIPI0$isIOS, useLabels as $cIPI0$useLabels} from "@react-aria/utils";
3
3
  import $cIPI0$react, {useMemo as $cIPI0$useMemo, useRef as $cIPI0$useRef, useEffect as $cIPI0$useEffect} from "react";
4
4
  import {useField as $cIPI0$useField} from "@react-aria/label";
5
5
  import {useFocusWithin as $cIPI0$useFocusWithin, usePress as $cIPI0$usePress} from "@react-aria/interactions";
@@ -814,6 +814,7 @@ function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref, disableArrowNavig
814
814
  ]);
815
815
  // Open the popover on alt + arrow down
816
816
  let onKeyDown = (e)=>{
817
+ if (!e.currentTarget.contains(e.target)) return;
817
818
  if (e.altKey && (e.key === "ArrowDown" || e.key === "ArrowUp") && "setOpen" in state) {
818
819
  e.preventDefault();
819
820
  e.stopPropagation();
@@ -886,6 +887,7 @@ const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
886
887
  const $16f0b7bb276bc17e$export$300019f83c56d282 = "__role_" + Date.now();
887
888
  const $16f0b7bb276bc17e$export$7b3062cd49e80452 = "__focusManager_" + Date.now();
888
889
  function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
890
+ var _state_value;
889
891
  let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $cIPI0$useField)({
890
892
  ...props,
891
893
  labelElementType: "span"
@@ -950,6 +952,7 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
950
952
  }, [
951
953
  focusManager
952
954
  ]);
955
+ (0, $cIPI0$useFormReset)(props.inputRef, state.value, state.setValue);
953
956
  let domProps = (0, $cIPI0$filterDOMProps)(props);
954
957
  return {
955
958
  labelProps: {
@@ -966,12 +969,20 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
966
969
  if (props.onKeyUp) props.onKeyUp(e);
967
970
  }
968
971
  }),
972
+ inputProps: {
973
+ type: "hidden",
974
+ name: props.name,
975
+ value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || ""
976
+ },
969
977
  descriptionProps: descriptionProps,
970
978
  errorMessageProps: errorMessageProps
971
979
  };
972
980
  }
973
981
  function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
974
- return $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
982
+ var _state_timeValue;
983
+ let res = $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
984
+ res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || "";
985
+ return res;
975
986
  }
976
987
 
977
988
 
@@ -1051,8 +1062,9 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
1051
1062
  isDisabled: props.isDisabled,
1052
1063
  isReadOnly: props.isReadOnly,
1053
1064
  isRequired: props.isRequired,
1054
- validationState: state.validationState,
1055
- autoFocus: props.autoFocus
1065
+ isInvalid: state.isInvalid,
1066
+ autoFocus: props.autoFocus,
1067
+ name: props.name
1056
1068
  },
1057
1069
  descriptionProps: descriptionProps,
1058
1070
  errorMessageProps: errorMessageProps,
@@ -1080,7 +1092,7 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
1080
1092
  isReadOnly: props.isReadOnly,
1081
1093
  isDateUnavailable: props.isDateUnavailable,
1082
1094
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
1083
- validationState: state.validationState,
1095
+ isInvalid: state.isInvalid,
1084
1096
  errorMessage: props.errorMessage
1085
1097
  }
1086
1098
  };
@@ -1412,7 +1424,7 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
1412
1424
  let firstSegment = (0, $cIPI0$useMemo)(()=>state.segments.find((s)=>s.isEditable), [
1413
1425
  state.segments
1414
1426
  ]);
1415
- if (segment !== firstSegment && state.validationState !== "invalid") ariaDescribedBy = undefined;
1427
+ if (segment !== firstSegment && !state.isInvalid) ariaDescribedBy = undefined;
1416
1428
  let id = (0, $cIPI0$useId)();
1417
1429
  let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
1418
1430
  // Prepend the label passed from the field to each segment name.
@@ -1433,7 +1445,7 @@ function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
1433
1445
  segmentProps: (0, $cIPI0$mergeProps)(spinButtonProps, labelProps, {
1434
1446
  id: id,
1435
1447
  ...touchPropOverrides,
1436
- "aria-invalid": state.validationState === "invalid" ? "true" : undefined,
1448
+ "aria-invalid": state.isInvalid ? "true" : undefined,
1437
1449
  "aria-describedby": ariaDescribedBy,
1438
1450
  "aria-readonly": state.isReadOnly || !segment.isEditable ? "true" : undefined,
1439
1451
  "data-placeholder": segment.isPlaceholder || undefined,
@@ -1546,7 +1558,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
1546
1558
  isDisabled: props.isDisabled,
1547
1559
  isReadOnly: props.isReadOnly,
1548
1560
  isRequired: props.isRequired,
1549
- validationState: state.validationState
1561
+ isInvalid: state.isInvalid
1550
1562
  };
1551
1563
  let domProps = (0, $cIPI0$filterDOMProps)(props);
1552
1564
  let { focusWithinProps: focusWithinProps } = (0, $cIPI0$useFocusWithin)({
@@ -1595,13 +1607,15 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
1595
1607
  ...commonFieldProps,
1596
1608
  value: (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start,
1597
1609
  onChange: (start)=>state.setDateTime("start", start),
1598
- autoFocus: props.autoFocus
1610
+ autoFocus: props.autoFocus,
1611
+ name: props.startName
1599
1612
  },
1600
1613
  endFieldProps: {
1601
1614
  ...endFieldProps,
1602
1615
  ...commonFieldProps,
1603
1616
  value: (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end,
1604
- onChange: (end)=>state.setDateTime("end", end)
1617
+ onChange: (end)=>state.setDateTime("end", end),
1618
+ name: props.endName
1605
1619
  },
1606
1620
  descriptionProps: descriptionProps,
1607
1621
  errorMessageProps: errorMessageProps,
@@ -1616,7 +1630,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
1616
1630
  isDateUnavailable: props.isDateUnavailable,
1617
1631
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
1618
1632
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
1619
- validationState: state.validationState,
1633
+ isInvalid: state.isInvalid,
1620
1634
  errorMessage: props.errorMessage
1621
1635
  }
1622
1636
  };
package/dist/main.js CHANGED
@@ -824,6 +824,7 @@ function $715562ad3b4cced4$export$4a931266a3838b86(state, ref, disableArrowNavig
824
824
  ]);
825
825
  // Open the popover on alt + arrow down
826
826
  let onKeyDown = (e)=>{
827
+ if (!e.currentTarget.contains(e.target)) return;
827
828
  if (e.altKey && (e.key === "ArrowDown" || e.key === "ArrowUp") && "setOpen" in state) {
828
829
  e.preventDefault();
829
830
  e.stopPropagation();
@@ -896,6 +897,7 @@ const $4acc2f407c169e55$export$653eddfc964b0f8a = new WeakMap();
896
897
  const $4acc2f407c169e55$export$300019f83c56d282 = "__role_" + Date.now();
897
898
  const $4acc2f407c169e55$export$7b3062cd49e80452 = "__focusManager_" + Date.now();
898
899
  function $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref) {
900
+ var _state_value;
899
901
  let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $IwcIq$reactarialabel.useField)({
900
902
  ...props,
901
903
  labelElementType: "span"
@@ -960,6 +962,7 @@ function $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref) {
960
962
  }, [
961
963
  focusManager
962
964
  ]);
965
+ (0, $IwcIq$reactariautils.useFormReset)(props.inputRef, state.value, state.setValue);
963
966
  let domProps = (0, $IwcIq$reactariautils.filterDOMProps)(props);
964
967
  return {
965
968
  labelProps: {
@@ -976,12 +979,20 @@ function $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref) {
976
979
  if (props.onKeyUp) props.onKeyUp(e);
977
980
  }
978
981
  }),
982
+ inputProps: {
983
+ type: "hidden",
984
+ name: props.name,
985
+ value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || ""
986
+ },
979
987
  descriptionProps: descriptionProps,
980
988
  errorMessageProps: errorMessageProps
981
989
  };
982
990
  }
983
991
  function $4acc2f407c169e55$export$4c842f6a241dc825(props, state, ref) {
984
- return $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref);
992
+ var _state_timeValue;
993
+ let res = $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref);
994
+ res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || "";
995
+ return res;
985
996
  }
986
997
 
987
998
 
@@ -1061,8 +1072,9 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
1061
1072
  isDisabled: props.isDisabled,
1062
1073
  isReadOnly: props.isReadOnly,
1063
1074
  isRequired: props.isRequired,
1064
- validationState: state.validationState,
1065
- autoFocus: props.autoFocus
1075
+ isInvalid: state.isInvalid,
1076
+ autoFocus: props.autoFocus,
1077
+ name: props.name
1066
1078
  },
1067
1079
  descriptionProps: descriptionProps,
1068
1080
  errorMessageProps: errorMessageProps,
@@ -1090,7 +1102,7 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
1090
1102
  isReadOnly: props.isReadOnly,
1091
1103
  isDateUnavailable: props.isDateUnavailable,
1092
1104
  defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
1093
- validationState: state.validationState,
1105
+ isInvalid: state.isInvalid,
1094
1106
  errorMessage: props.errorMessage
1095
1107
  }
1096
1108
  };
@@ -1422,7 +1434,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
1422
1434
  let firstSegment = (0, $IwcIq$react.useMemo)(()=>state.segments.find((s)=>s.isEditable), [
1423
1435
  state.segments
1424
1436
  ]);
1425
- if (segment !== firstSegment && state.validationState !== "invalid") ariaDescribedBy = undefined;
1437
+ if (segment !== firstSegment && !state.isInvalid) ariaDescribedBy = undefined;
1426
1438
  let id = (0, $IwcIq$reactariautils.useId)();
1427
1439
  let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
1428
1440
  // Prepend the label passed from the field to each segment name.
@@ -1443,7 +1455,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
1443
1455
  segmentProps: (0, $IwcIq$reactariautils.mergeProps)(spinButtonProps, labelProps, {
1444
1456
  id: id,
1445
1457
  ...touchPropOverrides,
1446
- "aria-invalid": state.validationState === "invalid" ? "true" : undefined,
1458
+ "aria-invalid": state.isInvalid ? "true" : undefined,
1447
1459
  "aria-describedby": ariaDescribedBy,
1448
1460
  "aria-readonly": state.isReadOnly || !segment.isEditable ? "true" : undefined,
1449
1461
  "data-placeholder": segment.isPlaceholder || undefined,
@@ -1556,7 +1568,7 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
1556
1568
  isDisabled: props.isDisabled,
1557
1569
  isReadOnly: props.isReadOnly,
1558
1570
  isRequired: props.isRequired,
1559
- validationState: state.validationState
1571
+ isInvalid: state.isInvalid
1560
1572
  };
1561
1573
  let domProps = (0, $IwcIq$reactariautils.filterDOMProps)(props);
1562
1574
  let { focusWithinProps: focusWithinProps } = (0, $IwcIq$reactariainteractions.useFocusWithin)({
@@ -1605,13 +1617,15 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
1605
1617
  ...commonFieldProps,
1606
1618
  value: (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start,
1607
1619
  onChange: (start)=>state.setDateTime("start", start),
1608
- autoFocus: props.autoFocus
1620
+ autoFocus: props.autoFocus,
1621
+ name: props.startName
1609
1622
  },
1610
1623
  endFieldProps: {
1611
1624
  ...endFieldProps,
1612
1625
  ...commonFieldProps,
1613
1626
  value: (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end,
1614
- onChange: (end)=>state.setDateTime("end", end)
1627
+ onChange: (end)=>state.setDateTime("end", end),
1628
+ name: props.endName
1615
1629
  },
1616
1630
  descriptionProps: descriptionProps,
1617
1631
  errorMessageProps: errorMessageProps,
@@ -1626,7 +1640,7 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
1626
1640
  isDateUnavailable: props.isDateUnavailable,
1627
1641
  allowsNonContiguousRanges: props.allowsNonContiguousRanges,
1628
1642
  defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
1629
- validationState: state.validationState,
1643
+ isInvalid: state.isInvalid,
1630
1644
  errorMessage: props.errorMessage
1631
1645
  }
1632
1646
  };