@dloizides/ui-forms 1.40.0 → 1.42.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React2 = require('react');
3
+ var React37 = require('react');
4
4
  var reactNative = require('react-native');
5
5
  var uiFeedback = require('@dloizides/ui-feedback');
6
6
  var jsxRuntime = require('react/jsx-runtime');
@@ -12,12 +12,12 @@ var Svg = require('react-native-svg');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
14
 
15
- var React2__default = /*#__PURE__*/_interopDefault(React2);
15
+ var React37__default = /*#__PURE__*/_interopDefault(React37);
16
16
  var Svg__default = /*#__PURE__*/_interopDefault(Svg);
17
17
 
18
18
  // src/Field/Field.tsx
19
19
  function attachControlId(child, candidateId, describedById) {
20
- if (!React2__default.default.isValidElement(child) || child.type === React2__default.default.Fragment) {
20
+ if (!React37__default.default.isValidElement(child) || child.type === React37__default.default.Fragment) {
21
21
  return { node: child };
22
22
  }
23
23
  const props = child.props;
@@ -28,15 +28,15 @@ function attachControlId(child, candidateId, describedById) {
28
28
  if (describedById !== void 0 && props.describedById === void 0) {
29
29
  injected.describedById = describedById;
30
30
  }
31
- return { node: React2__default.default.cloneElement(element, injected), controlId };
31
+ return { node: React37__default.default.cloneElement(element, injected), controlId };
32
32
  }
33
33
  var IS_WEB = reactNative.Platform.OS === "web";
34
34
  function isAttributeHost(node) {
35
35
  return typeof node === "object" && node !== null && typeof node.setAttribute === "function";
36
36
  }
37
37
  function useHtmlFor(controlId) {
38
- const ref = React2.useRef(null);
39
- React2.useEffect(() => {
38
+ const ref = React37.useRef(null);
39
+ React37.useEffect(() => {
40
40
  const node = ref.current;
41
41
  if (!IS_WEB || !isAttributeHost(node)) return;
42
42
  const target = controlId !== void 0 && controlId !== "" ? node.ownerDocument?.getElementById(controlId) : null;
@@ -138,15 +138,15 @@ var labelVariantStyles = reactNative.StyleSheet.create({
138
138
  function resolveLabelVariantStyle(variant) {
139
139
  return variant === "control" ? labelVariantStyles.control : labelVariantStyles.field;
140
140
  }
141
- var FormGridContext = React2__default.default.createContext(null);
142
- var GapOwnedContext = React2__default.default.createContext(false);
141
+ var FormGridContext = React37__default.default.createContext(null);
142
+ var GapOwnedContext = React37__default.default.createContext(false);
143
143
  var FormGridProvider = FormGridContext.Provider;
144
144
  var GapOwnedProvider = GapOwnedContext.Provider;
145
145
  function useFormGridMetrics() {
146
- return React2__default.default.useContext(FormGridContext);
146
+ return React37__default.default.useContext(FormGridContext);
147
147
  }
148
148
  function useIsGapOwned() {
149
- return React2__default.default.useContext(GapOwnedContext);
149
+ return React37__default.default.useContext(GapOwnedContext);
150
150
  }
151
151
  var ERROR_LIGHT_STEPS = ["500", "600", "700"];
152
152
  var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
@@ -169,7 +169,7 @@ var styles = reactNative.StyleSheet.create({
169
169
  });
170
170
  var fieldSeq = 0;
171
171
  function useFieldIds() {
172
- const [ids] = React2__default.default.useState(() => {
172
+ const [ids] = React37__default.default.useState(() => {
173
173
  fieldSeq += 1;
174
174
  const seq = String(fieldSeq);
175
175
  return {
@@ -216,7 +216,7 @@ var Field = ({
216
216
  const hasLabel = labelText !== "";
217
217
  const marker = resolveFieldMarker(required, optional);
218
218
  const { hintId, errorId, controlId, labelId } = useFieldIds();
219
- const themeStyles = React2__default.default.useMemo(
219
+ const themeStyles = React37__default.default.useMemo(
220
220
  () => ({
221
221
  label: { color: colors.textSecondary },
222
222
  requiredMark: { color: errorColor },
@@ -268,7 +268,7 @@ var FormGrid = ({
268
268
  style,
269
269
  testID
270
270
  }) => {
271
- const metrics = React2__default.default.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
271
+ const metrics = React37__default.default.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
272
272
  return /* @__PURE__ */ jsxRuntime.jsx(FormGridProvider, { value: metrics, children: /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles2.grid, { gap }, style], testID, children }) }) });
273
273
  };
274
274
  var LABEL_LINE_PLACEHOLDER = "\xA0";
@@ -353,8 +353,8 @@ var InlineFieldRow = ({
353
353
  }) => {
354
354
  const { width } = reactNative.useWindowDimensions();
355
355
  const layout = inlineFieldRowLayout(width, fieldMaxWidth, inlineMinWidth);
356
- const rowStyle = React2.useMemo(() => [styles4.row, { gap }], [gap]);
357
- const fieldStyle = React2.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
356
+ const rowStyle = React37.useMemo(() => [styles4.row, { gap }], [gap]);
357
+ const fieldStyle = React37.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
358
358
  if (!layout.inline)
359
359
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
360
360
  field2,
@@ -535,7 +535,7 @@ var styles9 = reactNative.StyleSheet.create({
535
535
  });
536
536
  var sectionSeq = 0;
537
537
  function useSectionLegendId() {
538
- const [id] = React2__default.default.useState(() => {
538
+ const [id] = React37__default.default.useState(() => {
539
539
  sectionSeq += 1;
540
540
  return `form-section-legend-${String(sectionSeq)}`;
541
541
  });
@@ -793,8 +793,8 @@ function horizontalPlacement(rect2, viewportWidth) {
793
793
  return { left, width };
794
794
  }
795
795
  function useAnchorRect(ref, enabled) {
796
- const [rect2, setRect] = React2.useState(null);
797
- React2.useLayoutEffect(() => {
796
+ const [rect2, setRect] = React37.useState(null);
797
+ React37.useLayoutEffect(() => {
798
798
  if (!IS_WEB3 || !enabled) {
799
799
  setRect(null);
800
800
  return void 0;
@@ -843,8 +843,8 @@ function readViewportBottom() {
843
843
  return viewport === null ? window.innerHeight : viewport.offsetTop + viewport.height;
844
844
  }
845
845
  function useVisualViewportBottom(enabled) {
846
- const [bottom, setBottom] = React2.useState(null);
847
- React2.useLayoutEffect(() => {
846
+ const [bottom, setBottom] = React37.useState(null);
847
+ React37.useLayoutEffect(() => {
848
848
  if (!IS_WEB3 || !enabled) {
849
849
  setBottom(null);
850
850
  return void 0;
@@ -874,7 +874,7 @@ function scrollAnchorIntoView(ref, marginTop) {
874
874
  scrollNodeIntoView(node, anchorScrollBlock(node.getBoundingClientRect().bottom, readViewportBottom()));
875
875
  }
876
876
  function useKeepAnchorInRoom(ref, marginTop, enabled) {
877
- React2.useLayoutEffect(() => {
877
+ React37.useLayoutEffect(() => {
878
878
  if (!IS_WEB3 || !enabled) return void 0;
879
879
  const place = () => scrollAnchorIntoView(ref, marginTop);
880
880
  place();
@@ -888,7 +888,7 @@ var ESCAPE_KEY = "Escape";
888
888
  var LISTBOX_ROLE = { role: "listbox" };
889
889
  var KEEP_FIELD_FOCUS = { onMouseDown: (event) => event.preventDefault() };
890
890
  function useDismiss(anchorRef, menuRef, onDismiss) {
891
- React2.useEffect(() => {
891
+ React37.useEffect(() => {
892
892
  if (!IS_WEB4) return void 0;
893
893
  const onMouseDown = (event) => {
894
894
  const anchorNode = anchorRef.current;
@@ -910,7 +910,7 @@ function useDismiss(anchorRef, menuRef, onDismiss) {
910
910
  }, [anchorRef, menuRef, onDismiss]);
911
911
  }
912
912
  function useKeepHighlightInView(testID, highlightedValue) {
913
- React2.useEffect(() => {
913
+ React37.useEffect(() => {
914
914
  if (!IS_WEB4 || highlightedValue === void 0 || highlightedValue === "") return;
915
915
  scrollNodeIntoView(document.getElementById(optionDomId(testID, highlightedValue)), "nearest");
916
916
  }, [testID, highlightedValue]);
@@ -929,7 +929,7 @@ function AnchoredMenu({
929
929
  listbox,
930
930
  placement
931
931
  }) {
932
- const menuRef = React2__default.default.useRef(null);
932
+ const menuRef = React37__default.default.useRef(null);
933
933
  useDismiss(anchorRef, menuRef, onDismiss);
934
934
  useKeepHighlightInView(testID, listbox?.highlightedValue);
935
935
  const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
@@ -1004,27 +1004,27 @@ function useThemedInput(options = {}) {
1004
1004
  const { hasError = false, onFocus, onBlur, editable = true } = options;
1005
1005
  const { theme } = uiFeedback.useUi();
1006
1006
  const { colors, palette } = theme;
1007
- const [isFocused, setIsFocused] = React2.useState(false);
1008
- const [isHovered, setIsHovered] = React2.useState(false);
1009
- const handleFocus = React2.useCallback(
1007
+ const [isFocused, setIsFocused] = React37.useState(false);
1008
+ const [isHovered, setIsHovered] = React37.useState(false);
1009
+ const handleFocus = React37.useCallback(
1010
1010
  (e) => {
1011
1011
  setIsFocused(true);
1012
1012
  onFocus?.(e);
1013
1013
  },
1014
1014
  [onFocus]
1015
1015
  );
1016
- const handleBlur = React2.useCallback(
1016
+ const handleBlur = React37.useCallback(
1017
1017
  (e) => {
1018
1018
  setIsFocused(false);
1019
1019
  onBlur?.(e);
1020
1020
  },
1021
1021
  [onBlur]
1022
1022
  );
1023
- const handleHoverIn = React2.useCallback(() => setIsHovered(true), []);
1024
- const handleHoverOut = React2.useCallback(() => setIsHovered(false), []);
1023
+ const handleHoverIn = React37.useCallback(() => setIsHovered(true), []);
1024
+ const handleHoverOut = React37.useCallback(() => setIsHovered(false), []);
1025
1025
  const primary = palette.primary["500"];
1026
1026
  const errorColor = fieldErrorInk(theme);
1027
- const style = React2.useMemo(() => {
1027
+ const style = React37.useMemo(() => {
1028
1028
  const restBorder = hasError ? errorColor : colors.border;
1029
1029
  const focusBorder = hasError ? errorColor : primary;
1030
1030
  const editableBorder = isFocused ? focusBorder : isHovered ? withAlpha(colors.text, HOVER_BORDER_ALPHA) : restBorder;
@@ -1057,8 +1057,8 @@ function useThemedInput(options = {}) {
1057
1057
  errorColor,
1058
1058
  theme
1059
1059
  ]);
1060
- const focusBind = React2.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
1061
- const hoverBind = React2.useMemo(
1060
+ const focusBind = React37.useMemo(() => ({ onFocus: handleFocus, onBlur: handleBlur }), [handleFocus, handleBlur]);
1061
+ const hoverBind = React37.useMemo(
1062
1062
  () => IS_WEB5 ? { onMouseEnter: handleHoverIn, onMouseLeave: handleHoverOut } : {},
1063
1063
  [handleHoverIn, handleHoverOut]
1064
1064
  );
@@ -1089,7 +1089,7 @@ var boxStyles = reactNative.StyleSheet.create({
1089
1089
  textAlignVertical: "top"
1090
1090
  }
1091
1091
  });
1092
- var ThemedTextInput = React2__default.default.forwardRef(function ThemedTextInput2({
1092
+ var ThemedTextInput = React37__default.default.forwardRef(function ThemedTextInput2({
1093
1093
  hasError = false,
1094
1094
  describedById,
1095
1095
  requiredField = false,
@@ -1184,11 +1184,11 @@ function recentsEqual(a, b) {
1184
1184
 
1185
1185
  // src/useRecentValues/useRecentValues.ts
1186
1186
  function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
1187
- const [recents, setRecents] = React2.useState(() => readRecents(key).slice(0, max));
1188
- React2.useEffect(() => {
1187
+ const [recents, setRecents] = React37.useState(() => readRecents(key).slice(0, max));
1188
+ React37.useEffect(() => {
1189
1189
  setRecents(readRecents(key).slice(0, max));
1190
1190
  }, [key, max]);
1191
- const remember = React2.useCallback(
1191
+ const remember = React37.useCallback(
1192
1192
  (value) => {
1193
1193
  setRecents((current) => {
1194
1194
  const next = computeNextRecents(current, value, max);
@@ -1199,7 +1199,7 @@ function useRecentValues(key, max = DEFAULT_MAX_RECENTS) {
1199
1199
  },
1200
1200
  [key, max]
1201
1201
  );
1202
- const clear = React2.useCallback(() => {
1202
+ const clear = React37.useCallback(() => {
1203
1203
  clearRecents(key);
1204
1204
  setRecents([]);
1205
1205
  }, [key]);
@@ -1221,24 +1221,24 @@ function RecentInputField({
1221
1221
  const { theme } = uiFeedback.useUi();
1222
1222
  const { colors, palette } = theme;
1223
1223
  const { recents, remember } = useRecentValues(recentKey, recentMax);
1224
- const anchorRef = React2.useRef(null);
1225
- const latestText = React2.useRef(typeof value === "string" ? value : "");
1226
- const [isOpen, setIsOpen] = React2.useState(false);
1227
- const handleChange = React2.useCallback(
1224
+ const anchorRef = React37.useRef(null);
1225
+ const latestText = React37.useRef(typeof value === "string" ? value : "");
1226
+ const [isOpen, setIsOpen] = React37.useState(false);
1227
+ const handleChange = React37.useCallback(
1228
1228
  (text) => {
1229
1229
  latestText.current = text;
1230
1230
  onChangeText?.(text);
1231
1231
  },
1232
1232
  [onChangeText]
1233
1233
  );
1234
- const handleFocus = React2.useCallback(
1234
+ const handleFocus = React37.useCallback(
1235
1235
  (event) => {
1236
1236
  setIsOpen(true);
1237
1237
  onFocus?.(event);
1238
1238
  },
1239
1239
  [onFocus]
1240
1240
  );
1241
- const handleBlur = React2.useCallback(
1241
+ const handleBlur = React37.useCallback(
1242
1242
  (event) => {
1243
1243
  const blurredText = latestText.current;
1244
1244
  setTimeout(() => {
@@ -1249,7 +1249,7 @@ function RecentInputField({
1249
1249
  },
1250
1250
  [remember, onBlur]
1251
1251
  );
1252
- const handleSubmit = React2.useCallback(
1252
+ const handleSubmit = React37.useCallback(
1253
1253
  (event) => {
1254
1254
  remember(latestText.current);
1255
1255
  setIsOpen(false);
@@ -1257,7 +1257,7 @@ function RecentInputField({
1257
1257
  },
1258
1258
  [remember, onSubmitEditing]
1259
1259
  );
1260
- const pick = React2.useCallback(
1260
+ const pick = React37.useCallback(
1261
1261
  (picked) => {
1262
1262
  latestText.current = picked;
1263
1263
  onChangeText?.(picked);
@@ -1399,7 +1399,7 @@ function ChipContent({ icon, label, textStyle, numberOfLines }) {
1399
1399
  }
1400
1400
  function OutlineChip(props) {
1401
1401
  const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
1402
- const [hovered, setHovered] = React2__default.default.useState(false);
1402
+ const [hovered, setHovered] = React37__default.default.useState(false);
1403
1403
  const active = selected || hovered;
1404
1404
  const borderColor = active ? colors.primary : colors.border;
1405
1405
  const backgroundColor = selected ? colors.tint : colors.muted;
@@ -1499,8 +1499,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
1499
1499
  var NO_GROUP_PROPS = {};
1500
1500
  function useRadioKeyboard(config) {
1501
1501
  const { enabled, disabled, values, selectedIndex, onChange } = config;
1502
- const nodes = React2__default.default.useRef([]);
1503
- const chipRef = React2__default.default.useCallback((index) => (node) => {
1502
+ const nodes = React37__default.default.useRef([]);
1503
+ const chipRef = React37__default.default.useCallback((index) => (node) => {
1504
1504
  nodes.current[index] = node;
1505
1505
  }, []);
1506
1506
  const onKeyDown = (event) => {
@@ -1613,7 +1613,7 @@ var ChipSelector = ({
1613
1613
  const isRadioGroup = !multiple && singleSelectRole === "radio";
1614
1614
  const { theme } = uiFeedback.useUi();
1615
1615
  const { colors, palette } = theme;
1616
- const chipColors = React2__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
1616
+ const chipColors = React37__default.default.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
1617
1617
  function isSelected(optionValue) {
1618
1618
  if (multiple && Array.isArray(value))
1619
1619
  return value.includes(optionValue);
@@ -1709,12 +1709,12 @@ var FormSwitch = ({
1709
1709
  accessibilityHint
1710
1710
  }) => {
1711
1711
  const { theme } = uiFeedback.useUi();
1712
- const toggle = React2__default.default.useCallback(() => {
1712
+ const toggle2 = React37__default.default.useCallback(() => {
1713
1713
  if (!disabled) onValueChange(!value);
1714
1714
  }, [disabled, onValueChange, value]);
1715
1715
  const { colors } = theme;
1716
1716
  const hasDescription = typeof description === "string" && description !== "";
1717
- const themeStyles = React2__default.default.useMemo(() => {
1717
+ const themeStyles = React37__default.default.useMemo(() => {
1718
1718
  const labelStyle = { color: colors.text };
1719
1719
  const descriptionStyle = { color: colors.textSecondary };
1720
1720
  return { label: labelStyle, description: descriptionStyle };
@@ -1731,7 +1731,7 @@ var FormSwitch = ({
1731
1731
  {
1732
1732
  accessible: false,
1733
1733
  disabled,
1734
- onPress: toggle,
1734
+ onPress: toggle2,
1735
1735
  style: [styles13.container, containerStyle],
1736
1736
  tabIndex: -1,
1737
1737
  testID,
@@ -1837,8 +1837,8 @@ var FormCheckbox = ({
1837
1837
  const hintText = typeof hint === "string" && hint !== "" ? hint : description;
1838
1838
  const hasHint = typeof hintText === "string" && hintText !== "";
1839
1839
  const { hintId } = useFieldIds();
1840
- const [focused, setFocused] = React2__default.default.useState(false);
1841
- const themeStyles = React2__default.default.useMemo(() => {
1840
+ const [focused, setFocused] = React37__default.default.useState(false);
1841
+ const themeStyles = React37__default.default.useMemo(() => {
1842
1842
  const boxOn = checkboxBoxColors(colors, brand, true);
1843
1843
  const boxOff = checkboxBoxColors(colors, brand, false);
1844
1844
  const ring = { borderColor: brand };
@@ -1846,7 +1846,7 @@ var FormCheckbox = ({
1846
1846
  const hintStyle = { color: colors.textSecondary };
1847
1847
  return { boxOn, boxOff, ring, label: labelStyle, hint: hintStyle };
1848
1848
  }, [brand, colors]);
1849
- const toggle = () => {
1849
+ const toggle2 = () => {
1850
1850
  const next = !value;
1851
1851
  if (onValueChange) onValueChange(next);
1852
1852
  if (onChange) onChange(next);
@@ -1856,7 +1856,7 @@ var FormCheckbox = ({
1856
1856
  const key = event.key ?? "";
1857
1857
  if (!ACTIVATION_KEYS.includes(key)) return;
1858
1858
  if (typeof event.preventDefault === "function") event.preventDefault();
1859
- toggle();
1859
+ toggle2();
1860
1860
  };
1861
1861
  const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown } : {};
1862
1862
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1871,7 +1871,7 @@ var FormCheckbox = ({
1871
1871
  disabled,
1872
1872
  onBlur: () => setFocused(false),
1873
1873
  onFocus: () => setFocused(true),
1874
- onPress: toggle,
1874
+ onPress: toggle2,
1875
1875
  role: "checkbox",
1876
1876
  style: [
1877
1877
  styles14.container,
@@ -1907,10 +1907,10 @@ function nextHighlight(current, count, delta) {
1907
1907
  // src/SelectControl/useSelectListbox.ts
1908
1908
  var FORWARD = 1;
1909
1909
  var BACKWARD = -1;
1910
- function useSelectListbox({ options, isOpen, open, toggle, select }) {
1911
- const [row, setRow] = React2.useState(NO_HIGHLIGHT);
1910
+ function useSelectListbox({ options, isOpen, open, toggle: toggle2, select }) {
1911
+ const [row, setRow] = React37.useState(NO_HIGHLIGHT);
1912
1912
  const highlighted = isOpen ? options[row] : void 0;
1913
- React2.useEffect(() => {
1913
+ React37.useEffect(() => {
1914
1914
  if (!isOpen) setRow(NO_HIGHLIGHT);
1915
1915
  }, [isOpen]);
1916
1916
  const onKeyDown = (event) => {
@@ -1923,7 +1923,7 @@ function useSelectListbox({ options, isOpen, open, toggle, select }) {
1923
1923
  open();
1924
1924
  setRow((current) => nextHighlight(current, options.length, key === "ArrowDown" ? FORWARD : BACKWARD));
1925
1925
  } else if (highlighted !== void 0) select(highlighted.value);
1926
- else toggle();
1926
+ else toggle2();
1927
1927
  };
1928
1928
  return { highlighted, onKeyDown };
1929
1929
  }
@@ -1951,29 +1951,29 @@ function SelectControl({
1951
1951
  }) {
1952
1952
  const { theme } = uiFeedback.useUi();
1953
1953
  const { colors, palette } = theme;
1954
- const anchorRef = React2.useRef(null);
1955
- const [isOpen, setIsOpen] = React2.useState(false);
1956
- const selectedLabel = React2.useMemo(() => {
1954
+ const anchorRef = React37.useRef(null);
1955
+ const [isOpen, setIsOpen] = React37.useState(false);
1956
+ const selectedLabel = React37.useMemo(() => {
1957
1957
  const found = options.find((o) => o.value === value);
1958
1958
  return found?.label ?? placeholder;
1959
1959
  }, [options, placeholder, value]);
1960
- const close = React2.useCallback(() => {
1960
+ const close = React37.useCallback(() => {
1961
1961
  setIsOpen(false);
1962
1962
  }, []);
1963
- const open = React2.useCallback(() => {
1963
+ const open = React37.useCallback(() => {
1964
1964
  setIsOpen(true);
1965
1965
  }, []);
1966
- const toggle = React2.useCallback(() => {
1966
+ const toggle2 = React37.useCallback(() => {
1967
1967
  setIsOpen((prev) => !prev);
1968
1968
  }, []);
1969
- const select = React2.useCallback(
1969
+ const select = React37.useCallback(
1970
1970
  (next) => {
1971
1971
  onChange(next);
1972
1972
  setIsOpen(false);
1973
1973
  },
1974
1974
  [onChange]
1975
1975
  );
1976
- const listbox = useSelectListbox({ options, isOpen, open, toggle, select });
1976
+ const listbox = useSelectListbox({ options, isOpen, open, toggle: toggle2, select });
1977
1977
  const isListbox = menuAnchor !== void 0;
1978
1978
  const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
1979
1979
  const triggerAria = isListbox ? listboxTriggerAria(testID, isOpen && options.length > 0, listbox.highlighted) : {};
@@ -1990,7 +1990,7 @@ function SelectControl({
1990
1990
  "aria-haspopup": isListbox ? "listbox" : "menu",
1991
1991
  "aria-labelledby": labelledById,
1992
1992
  onBlur: isListbox ? close : void 0,
1993
- onPress: toggle,
1993
+ onPress: toggle2,
1994
1994
  style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
1995
1995
  testID: `${testID}-trigger`,
1996
1996
  children: [
@@ -2041,17 +2041,17 @@ var SelectField = ({
2041
2041
  };
2042
2042
  var CLOSE_DELAY_MS2 = 140;
2043
2043
  function useDelayedBlurClose(open, close) {
2044
- const timerRef = React2.useRef(null);
2045
- const cancelClose = React2.useCallback(() => {
2044
+ const timerRef = React37.useRef(null);
2045
+ const cancelClose = React37.useCallback(() => {
2046
2046
  if (timerRef.current !== null) clearTimeout(timerRef.current);
2047
2047
  timerRef.current = null;
2048
2048
  }, []);
2049
- React2.useEffect(() => cancelClose, [cancelClose]);
2050
- const handleFocus = React2.useCallback(() => {
2049
+ React37.useEffect(() => cancelClose, [cancelClose]);
2050
+ const handleFocus = React37.useCallback(() => {
2051
2051
  cancelClose();
2052
2052
  open();
2053
2053
  }, [cancelClose, open]);
2054
- const handleBlur = React2.useCallback(() => {
2054
+ const handleBlur = React37.useCallback(() => {
2055
2055
  cancelClose();
2056
2056
  timerRef.current = setTimeout(close, CLOSE_DELAY_MS2);
2057
2057
  }, [cancelClose, close]);
@@ -2094,10 +2094,10 @@ function isUnmatched(options, text) {
2094
2094
  var DEFAULT_TYPEAHEAD_DEBOUNCE_MS = 250;
2095
2095
  var IDLE = { results: [], isLoading: false, hasFailed: false, hasSettled: false };
2096
2096
  function useTypeaheadSearch(load, query, enabled, debounceMs) {
2097
- const [state, setState] = React2.useState(IDLE);
2098
- const loadRef = React2.useRef(load);
2097
+ const [state, setState] = React37.useState(IDLE);
2098
+ const loadRef = React37.useRef(load);
2099
2099
  loadRef.current = load;
2100
- React2.useEffect(() => {
2100
+ React37.useEffect(() => {
2101
2101
  if (!enabled) {
2102
2102
  setState(IDLE);
2103
2103
  return void 0;
@@ -2136,30 +2136,30 @@ function useTypeaheadRows(input, isOpen, isPicked) {
2136
2136
  const query = value.trim();
2137
2137
  const isSearching = search !== void 0 && isOpen && !isPicked && query.length >= minChars;
2138
2138
  const found = useTypeaheadSearch(search?.load, query, isSearching, search?.debounceMs ?? DEFAULT_TYPEAHEAD_DEBOUNCE_MS);
2139
- const staticRows = React2.useMemo(() => {
2139
+ const staticRows = React37.useMemo(() => {
2140
2140
  if (options === void 0 || options.some((o) => o.label === value)) return NO_ROWS;
2141
2141
  return suggestOptions(options, value, minChars, maxSuggestions);
2142
2142
  }, [options, value, minChars, maxSuggestions]);
2143
- const foundRows = React2.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
2143
+ const foundRows = React37.useMemo(() => found.results.slice(0, maxSuggestions), [found.results, maxSuggestions]);
2144
2144
  if (search === void 0) return { rows: staticRows, statusText: void 0 };
2145
2145
  return { rows: foundRows, statusText: searchStatusText(found, search) };
2146
2146
  }
2147
2147
  function useTypeaheadState(input) {
2148
2148
  const { search, value, onChange, onSubmit } = input;
2149
- const [isOpen, setIsOpen] = React2.useState(false);
2150
- const [picked, setPicked] = React2.useState(null);
2151
- const [highlightIndex, setHighlightIndex] = React2.useState(NO_HIGHLIGHT);
2149
+ const [isOpen, setIsOpen] = React37.useState(false);
2150
+ const [picked, setPicked] = React37.useState(null);
2151
+ const [highlightIndex, setHighlightIndex] = React37.useState(NO_HIGHLIGHT);
2152
2152
  const { rows, statusText } = useTypeaheadRows(input, isOpen, picked !== null && picked.label === value);
2153
2153
  const rowKey = rows.map((row) => row.value).join("\n");
2154
2154
  const highlighted = isOpen ? rows[highlightIndex] : void 0;
2155
- React2.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
2156
- React2.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
2157
- const open = React2.useCallback(() => setIsOpen(true), []);
2158
- const close = React2.useCallback(() => {
2155
+ React37.useEffect(() => setHighlightIndex(NO_HIGHLIGHT), [rowKey]);
2156
+ React37.useEffect(() => setPicked((current) => current !== null && current.label !== value ? null : current), [value]);
2157
+ const open = React37.useCallback(() => setIsOpen(true), []);
2158
+ const close = React37.useCallback(() => {
2159
2159
  setIsOpen(false);
2160
2160
  setHighlightIndex(NO_HIGHLIGHT);
2161
2161
  }, []);
2162
- const pick = React2.useCallback(
2162
+ const pick = React37.useCallback(
2163
2163
  (option) => {
2164
2164
  setPicked(option);
2165
2165
  onChange(option.label);
@@ -2168,14 +2168,14 @@ function useTypeaheadState(input) {
2168
2168
  },
2169
2169
  [onChange, search, close]
2170
2170
  );
2171
- const selectValue = React2.useCallback(
2171
+ const selectValue = React37.useCallback(
2172
2172
  (optionValue) => {
2173
2173
  const option = rows.find((row) => row.value === optionValue);
2174
2174
  if (option !== void 0) pick(option);
2175
2175
  },
2176
2176
  [rows, pick]
2177
2177
  );
2178
- const handleChange = React2.useCallback(
2178
+ const handleChange = React37.useCallback(
2179
2179
  (next) => {
2180
2180
  if (picked !== null) {
2181
2181
  setPicked(null);
@@ -2188,7 +2188,7 @@ function useTypeaheadState(input) {
2188
2188
  [picked, search, onChange]
2189
2189
  );
2190
2190
  const handleKeyPress = useTypeaheadKeys({ rowCount: rows.length, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick });
2191
- const handleSubmit = React2.useCallback(() => {
2191
+ const handleSubmit = React37.useCallback(() => {
2192
2192
  if (highlighted !== void 0) {
2193
2193
  pick(highlighted);
2194
2194
  return;
@@ -2200,7 +2200,7 @@ function useTypeaheadState(input) {
2200
2200
  }
2201
2201
  function useTypeaheadKeys(input) {
2202
2202
  const { rowCount, isOpen, highlighted, setIsOpen, setHighlightIndex, close, pick } = input;
2203
- return React2.useCallback(
2203
+ return React37.useCallback(
2204
2204
  (event) => {
2205
2205
  const { key } = event.nativeEvent;
2206
2206
  if (key === "ArrowDown" || key === "ArrowUp") {
@@ -2237,7 +2237,7 @@ function TypeaheadControlImpl(props, ref) {
2237
2237
  const maxSuggestions = ("search" in props ? props.search.maxResults : props.maxSuggestions) ?? DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
2238
2238
  const { theme } = uiFeedback.useUi();
2239
2239
  const { colors, palette } = theme;
2240
- const anchorRef = React2.useRef(null);
2240
+ const anchorRef = React37.useRef(null);
2241
2241
  const state = useTypeaheadState({ options, search, value, minChars, maxSuggestions, onChange, onSubmit });
2242
2242
  const { handleFocus, handleBlur } = useDelayedBlurClose(state.open, state.close);
2243
2243
  const showMenu = state.isOpen && (state.rows.length > 0 || state.statusText !== void 0);
@@ -2290,7 +2290,7 @@ function TypeaheadControlImpl(props, ref) {
2290
2290
  hasError ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [controlStyles.error, { color: fieldErrorInk(theme) }], testID: `${testID}-error`, children: error }) : null
2291
2291
  ] });
2292
2292
  }
2293
- var TypeaheadControl = React2.forwardRef(TypeaheadControlImpl);
2293
+ var TypeaheadControl = React37.forwardRef(TypeaheadControlImpl);
2294
2294
  var NATIVE_INPUT_BOX = {
2295
2295
  borderStyle: "solid",
2296
2296
  boxSizing: "border-box",
@@ -2342,8 +2342,733 @@ function WebDateInput({ fieldProps, context, webInputType }) {
2342
2342
  }
2343
2343
  );
2344
2344
  }
2345
+ var PATHS = {
2346
+ ["calendar" /* Calendar */]: "M7 3v3M17 3v3M4 9h16M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",
2347
+ ["previous" /* Previous */]: "M15 5l-7 7 7 7",
2348
+ ["next" /* Next */]: "M9 5l7 7-7 7"
2349
+ };
2350
+ var SIZE = 18;
2351
+ var STROKE = 2;
2352
+ function Glyph({ name, color }) {
2353
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { "aria-hidden": "true", fill: "none", height: SIZE, stroke: color, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: STROKE, viewBox: "0 0 24 24", width: SIZE, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: PATHS[name] }) });
2354
+ }
2355
+ var TINT_STEP = "100";
2356
+ function usePickerColors() {
2357
+ const { theme } = uiFeedback.useUi();
2358
+ const brand = theme.palette.primary["500"];
2359
+ return {
2360
+ text: theme.colors.text,
2361
+ textSecondary: theme.colors.textSecondary,
2362
+ border: theme.colors.border,
2363
+ surface: theme.colors.surface,
2364
+ brand,
2365
+ onBrand: designTokens.resolveOnBrand(brand),
2366
+ tint: theme.palette.primary[TINT_STEP] ?? theme.colors.background
2367
+ };
2368
+ }
2369
+ var FOCUSABLE = "button, select, input, [tabindex]";
2370
+ var RADIUS = 12;
2371
+ var SHEET_RADIUS = 16;
2372
+ var PAD = 12;
2373
+ var SHEET_MAX_HEIGHT = "90vh";
2374
+ function tabStops(container) {
2375
+ return Array.from(container.querySelectorAll(FOCUSABLE)).filter(
2376
+ (node) => node.tabIndex >= 0 && !node.hasAttribute("disabled") && node.getAttribute("aria-disabled") !== "true"
2377
+ );
2378
+ }
2379
+ function PickerDialog({ testID, sheet, onDismiss, children }) {
2380
+ const colors = usePickerColors();
2381
+ const ref = React37.useRef(null);
2382
+ const onKeyDown = (event) => {
2383
+ if (event.key === "Escape") {
2384
+ event.preventDefault();
2385
+ event.stopPropagation();
2386
+ onDismiss();
2387
+ return;
2388
+ }
2389
+ if (event.key !== "Tab" || ref.current === null) return;
2390
+ const stops = tabStops(ref.current);
2391
+ const first = stops[0];
2392
+ const last = stops[stops.length - 1];
2393
+ if (first === void 0 || last === void 0) return;
2394
+ const atEdge = event.shiftKey ? document.activeElement === first : document.activeElement === last;
2395
+ if (!atEdge) return;
2396
+ event.preventDefault();
2397
+ (event.shiftKey ? last : first).focus();
2398
+ };
2399
+ const shape = sheet ? { borderTopLeftRadius: SHEET_RADIUS, borderTopRightRadius: SHEET_RADIUS, maxHeight: SHEET_MAX_HEIGHT, overflowY: "auto" } : { borderRadius: RADIUS, boxShadow: `0 12px 32px ${colors.border}` };
2400
+ const style = { boxSizing: "border-box", padding: PAD, background: colors.surface, color: colors.text, border: `1px solid ${colors.border}`, fontFamily: "inherit", ...shape };
2401
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
2402
+ }
2403
+ function useAnchorRect2(anchorRef) {
2404
+ const [rect2, setRect] = React37.useState(null);
2405
+ React37.useEffect(() => {
2406
+ anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
2407
+ }, [anchorRef]);
2408
+ return rect2;
2409
+ }
2410
+
2411
+ // src/SearchSelect/DropdownPlacement.ts
2412
+ var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
2413
+ DropdownPlacement2["Below"] = "below";
2414
+ DropdownPlacement2["Above"] = "above";
2415
+ return DropdownPlacement2;
2416
+ })(DropdownPlacement || {});
2417
+
2418
+ // src/SearchSelect/utils/dropdownFrame.ts
2419
+ var MIN_PANEL_WIDTH = 240;
2420
+ var EDGE = 8;
2421
+ function placeDropdown(anchor, panelHeight, viewportHeight) {
2422
+ const roomBelow = viewportHeight - (anchor.y + anchor.height);
2423
+ if (roomBelow >= panelHeight) return "below" /* Below */;
2424
+ return anchor.y > roomBelow ? "above" /* Above */ : "below" /* Below */;
2425
+ }
2426
+ function dropdownFrame(anchor, panelHeight, viewportHeight) {
2427
+ const placement = placeDropdown(anchor, panelHeight, viewportHeight);
2428
+ const base = { placement, left: anchor.x, width: anchor.width };
2429
+ if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - anchor.y };
2430
+ return { ...base, top: anchor.y + anchor.height };
2431
+ }
2432
+ function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
2433
+ const width = Math.max(frame.width, Math.min(minWidth, viewportWidth - EDGE - EDGE));
2434
+ const left = Math.max(EDGE, Math.min(frame.left, viewportWidth - width - EDGE));
2435
+ return { ...frame, width, left: frame.width >= width ? frame.left : left };
2436
+ }
2437
+ function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel }) {
2438
+ const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
2439
+ const anchor = useAnchorRect2(anchorRef);
2440
+ const [panelHeight, setPanelHeight] = React37.useState(0);
2441
+ const onLayout = React37.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
2442
+ const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight), viewportWidth, minWidth);
2443
+ const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
2444
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
2445
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
2446
+ frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles15.dropdown, place, { opacity: progress, transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, scale === void 0 ? null : styles15.growFromField], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
2447
+ ] });
2448
+ }
2449
+ var styles15 = reactNative.StyleSheet.create({
2450
+ dropdown: { position: "absolute" },
2451
+ growFromField: { transformOrigin: "top left" }
2452
+ });
2453
+ function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children, progress, scale, accessibilityLabel }) {
2454
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.backdrop, children: [
2455
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
2456
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [{ transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, progress === void 0 ? null : { opacity: progress }], children })
2457
+ ] }) });
2458
+ }
2459
+ var styles16 = reactNative.StyleSheet.create({
2460
+ backdrop: { flex: 1, justifyContent: "flex-end" }
2461
+ });
2462
+ function useReducedMotion() {
2463
+ const [reduced, setReduced] = React37.useState(false);
2464
+ React37.useEffect(() => {
2465
+ let active = true;
2466
+ reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
2467
+ if (active) setReduced(value);
2468
+ }).catch(() => void 0);
2469
+ const subscription = reactNative.AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
2470
+ return () => {
2471
+ active = false;
2472
+ subscription?.remove();
2473
+ };
2474
+ }, []);
2475
+ return reduced;
2476
+ }
2477
+
2478
+ // src/DatePicker/data/defaultLabels.ts
2479
+ var DEFAULT_DATE_PICKER_LABELS = {
2480
+ dialog: "Choose a date",
2481
+ rangeDialog: "Choose a date range",
2482
+ openCalendar: "Open calendar",
2483
+ openCalendarHint: "Opens a calendar to pick the date",
2484
+ previousMonth: "Previous month",
2485
+ nextMonth: "Next month",
2486
+ monthHint: "Shows another month",
2487
+ month: "Month",
2488
+ year: "Year",
2489
+ dayHint: "Picks this day",
2490
+ setDate: "Set date",
2491
+ setDateHint: "Saves the picked date",
2492
+ clear: "Clear",
2493
+ clearHint: "Removes the date",
2494
+ cancel: "Cancel",
2495
+ cancelHint: "Closes without changes",
2496
+ apply: "Apply",
2497
+ applyHint: "Saves the picked range",
2498
+ presets: "Quick ranges",
2499
+ presetHint: "Sets the range to this period",
2500
+ today: "Today",
2501
+ last7Days: "Last 7 days",
2502
+ thisMonth: "This month",
2503
+ quarter: "Quarter",
2504
+ dayCount: "{{p1}} days",
2505
+ invalidDate: "Enter a real date",
2506
+ rangeSeparator: " \u2013 ",
2507
+ rangeOrder: "The start must be on or before the end",
2508
+ outOfRange: "This date is outside the allowed range"
2509
+ };
2510
+
2511
+ // src/DatePicker/utils/isoDate.ts
2512
+ var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2513
+ var MONTHS_IN_YEAR = 12;
2514
+ var DAYS_IN_WEEK = 7;
2515
+ var PAD2 = 2;
2516
+ var YEAR_PAD = 4;
2517
+ var SUNDAY = 0;
2518
+ var MONDAY = 1;
2519
+ var MS_PER_DAY = 864e5;
2520
+ var MONTH_PREFIX = "YYYY-MM".length;
2521
+ var EPOCH = { year: 1970, month: 1, day: 1 };
2522
+ function daysInMonth(year, month) {
2523
+ return new Date(Date.UTC(year, month, 0)).getUTCDate();
2524
+ }
2525
+ function isValidParts({ year, month, day }) {
2526
+ const inMonth = month >= 1 && month <= MONTHS_IN_YEAR;
2527
+ return Number.isInteger(year) && year > 0 && inMonth && Number.isInteger(day) && day >= 1 && day <= daysInMonth(year, month);
2528
+ }
2529
+ function parseIso(value) {
2530
+ const match = ISO_DATE.exec(value);
2531
+ if (match === null) return null;
2532
+ const parts = { year: Number(match[1]), month: Number(match[2]), day: Number(match[3]) };
2533
+ return isValidParts(parts) ? parts : null;
2534
+ }
2535
+ function toIso({ year, month, day }) {
2536
+ return `${String(year).padStart(YEAR_PAD, "0")}-${String(month).padStart(PAD2, "0")}-${String(day).padStart(PAD2, "0")}`;
2537
+ }
2538
+ function toUtc(iso) {
2539
+ const parts = parseIso(iso) ?? EPOCH;
2540
+ return new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
2541
+ }
2542
+ function fromUtc(date) {
2543
+ return toIso({ year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate() });
2544
+ }
2545
+ function addDays(iso, days) {
2546
+ const date = toUtc(iso);
2547
+ date.setUTCDate(date.getUTCDate() + days);
2548
+ return fromUtc(date);
2549
+ }
2550
+ function addMonths(iso, months) {
2551
+ const parts = parseIso(iso) ?? EPOCH;
2552
+ const index = parts.year * MONTHS_IN_YEAR + (parts.month - 1) + months;
2553
+ const year = Math.floor(index / MONTHS_IN_YEAR);
2554
+ const month = index % MONTHS_IN_YEAR + 1;
2555
+ return toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) });
2556
+ }
2557
+ function weekdayIndex(iso, firstDay = MONDAY) {
2558
+ const day = toUtc(iso).getUTCDay();
2559
+ const isoDay = day === SUNDAY ? DAYS_IN_WEEK : day;
2560
+ return (isoDay - firstDay + DAYS_IN_WEEK) % DAYS_IN_WEEK;
2561
+ }
2562
+ function daysBetweenInclusive(from, to) {
2563
+ return Math.round((toUtc(to).getTime() - toUtc(from).getTime()) / MS_PER_DAY) + 1;
2564
+ }
2565
+ function isWithinBounds(iso, min, max) {
2566
+ const aboveMin = min === void 0 || min === "" || iso >= min.slice(0, iso.length);
2567
+ const belowMax = max === void 0 || max === "" || iso <= max.slice(0, iso.length);
2568
+ return aboveMin && belowMax;
2569
+ }
2570
+ function clampToBounds(iso, min, max) {
2571
+ if (min !== void 0 && min !== "" && iso < min.slice(0, iso.length)) return min.slice(0, iso.length);
2572
+ if (max !== void 0 && max !== "" && iso > max.slice(0, iso.length)) return max.slice(0, iso.length);
2573
+ return iso;
2574
+ }
2575
+ function todayIso(now = /* @__PURE__ */ new Date()) {
2576
+ return toIso({ year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate() });
2577
+ }
2578
+ function monthStart(iso) {
2579
+ return `${iso.slice(0, MONTH_PREFIX)}-01`;
2580
+ }
2581
+
2582
+ // src/DatePicker/utils/weekStart.ts
2583
+ var MONDAY2 = 1;
2584
+ var SUNDAY2 = 7;
2585
+ var SUNDAY_REGIONS = /* @__PURE__ */ new Set(["US", "CA", "MX", "BR", "JP", "KR", "TW", "HK", "IL", "PH", "IN", "ZA", "SA", "PE", "CO", "VE", "GT", "HN", "PA", "PR", "DO", "SV", "TH", "ID"]);
2586
+ function weekFirstDay(locale) {
2587
+ try {
2588
+ const resolved = new Intl.Locale(locale ?? new Intl.DateTimeFormat().resolvedOptions().locale);
2589
+ const info = resolved;
2590
+ const first = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay;
2591
+ if (first !== void 0) return first;
2592
+ return SUNDAY_REGIONS.has(resolved.maximize().region ?? "") ? SUNDAY2 : MONDAY2;
2593
+ } catch {
2594
+ return MONDAY2;
2595
+ }
2596
+ }
2597
+ var DatePickerContext = React37.createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
2598
+ function DatePickerProvider({ labels, locale, today, children }) {
2599
+ const value = React37.useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today }), [labels, locale, today]);
2600
+ return /* @__PURE__ */ jsxRuntime.jsx(DatePickerContext.Provider, { value, children });
2601
+ }
2602
+ function useDatePickerConfig() {
2603
+ const config = React37.useContext(DatePickerContext);
2604
+ const firstDay = React37.useMemo(() => weekFirstDay(config.locale), [config.locale]);
2605
+ return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay };
2606
+ }
2607
+
2608
+ // src/DatePicker/utils/motionStyles.ts
2609
+ var OPEN_MS = 180;
2610
+ var MONTH_SLIDE_MS = 200;
2611
+ var MONTH_SLIDE_PX = 16;
2612
+ var OPEN_SCALE = 0.96;
2613
+ var EASE = "cubic-bezier(0.2, 0, 0, 1)";
2614
+ function resolveOpenMotion(reduced) {
2615
+ return reduced ? { durationMs: 0, fromScale: 1 } : { durationMs: OPEN_MS, fromScale: OPEN_SCALE };
2616
+ }
2617
+ function monthSlideStyle(entered, reduced, direction) {
2618
+ if (reduced || direction === 0) return {};
2619
+ return {
2620
+ opacity: entered ? 1 : 0,
2621
+ transform: entered ? "translateX(0px)" : `translateX(${direction * MONTH_SLIDE_PX}px)`,
2622
+ transition: `opacity ${MONTH_SLIDE_MS}ms ${EASE}, transform ${MONTH_SLIDE_MS}ms ${EASE}`
2623
+ };
2624
+ }
2625
+ function useOpenProgress() {
2626
+ const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
2627
+ const progress = React37.useRef(new reactNative.Animated.Value(0)).current;
2628
+ React37.useEffect(() => {
2629
+ reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
2630
+ }, [progress, durationMs]);
2631
+ return {
2632
+ progress,
2633
+ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [fromScale, 1] }),
2634
+ still: progress.interpolate({ inputRange: [0, 1], outputRange: [0, 0] })
2635
+ };
2636
+ }
2637
+ function PickerSurface({ anchorRef, phone, minWidth, label, testID, onDismiss, children }) {
2638
+ const { labels } = useDatePickerConfig();
2639
+ const { progress, scale, still } = useOpenProgress();
2640
+ const body = /* @__PURE__ */ jsxRuntime.jsx(PickerDialog, { sheet: phone, testID, onDismiss, children });
2641
+ if (phone) {
2642
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { accessibilityLabel: label, closeHint: labels.cancelHint, closeLabel: labels.cancel, progress, scale, testID, translateY: still, onDismiss, children: body });
2643
+ }
2644
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { accessibilityLabel: label, anchorRef, closeHint: labels.cancelHint, closeLabel: labels.cancel, minWidth, progress, scale, testID, translateY: still, onDismiss, children: body });
2645
+ }
2646
+
2647
+ // src/DatePicker/utils/calendarKeys.ts
2648
+ var DAYS_IN_WEEK2 = 7;
2649
+ var MONTHS_IN_YEAR2 = 12;
2650
+ var MONDAY3 = 1;
2651
+ var DAY_STEPS = {
2652
+ ArrowLeft: -1,
2653
+ ArrowRight: 1,
2654
+ ArrowUp: -DAYS_IN_WEEK2,
2655
+ ArrowDown: DAYS_IN_WEEK2
2656
+ };
2657
+ function nextFocusDay(iso, key, shiftKey = false, firstDay = MONDAY3) {
2658
+ const step = DAY_STEPS[key];
2659
+ if (step !== void 0) return addDays(iso, step);
2660
+ const monthStep = shiftKey ? MONTHS_IN_YEAR2 : 1;
2661
+ if (key === "PageUp") return addMonths(iso, -monthStep);
2662
+ if (key === "PageDown") return addMonths(iso, monthStep);
2663
+ if (key === "Home") return addDays(iso, -weekdayIndex(iso, firstDay));
2664
+ if (key === "End") return addDays(iso, DAYS_IN_WEEK2 - 1 - weekdayIndex(iso, firstDay));
2665
+ return null;
2666
+ }
2667
+
2668
+ // src/DatePicker/hooks/useGridFocus.ts
2669
+ function dayDomId(testID, iso) {
2670
+ return `${testID}-day-${iso}`;
2671
+ }
2672
+ function useGridFocus(initial, bounds, testID, onPick) {
2673
+ const { firstDay } = useDatePickerConfig();
2674
+ const [focusedDay, setFocusedDay] = React37.useState(initial);
2675
+ const focusPending = React37.useRef(true);
2676
+ const { min, max } = bounds;
2677
+ React37.useEffect(() => {
2678
+ if (!focusPending.current) return;
2679
+ focusPending.current = false;
2680
+ document.getElementById(dayDomId(testID, focusedDay))?.focus();
2681
+ }, [focusedDay, testID]);
2682
+ const moveTo = React37.useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
2683
+ const onDayKey = React37.useCallback(
2684
+ (event, iso) => {
2685
+ if (event.key === "Enter" || event.key === " ") {
2686
+ event.preventDefault();
2687
+ onPick(iso);
2688
+ return;
2689
+ }
2690
+ const next = nextFocusDay(iso, event.key, event.shiftKey, firstDay);
2691
+ if (next === null) return;
2692
+ event.preventDefault();
2693
+ focusPending.current = true;
2694
+ moveTo(next);
2695
+ },
2696
+ [moveTo, onPick, firstDay]
2697
+ );
2698
+ return { focusedDay, moveTo, onDayKey };
2699
+ }
2700
+ var DAY_CELL_PX = 44;
2701
+ var DAY_START = 8;
2702
+ var RING = 2;
2703
+ var FONT = 14;
2704
+ var BOLD = 700;
2705
+ var REGULAR = 400;
2706
+ function DayCell({ iso, state, testID, label, hint, onPick, onKey }) {
2707
+ const colors = usePickerColors();
2708
+ const { inRange, isEnd, isToday, enabled, focusable } = state;
2709
+ const cellStyle = { width: DAY_CELL_PX, height: DAY_CELL_PX, background: inRange && !isEnd ? colors.tint : "transparent" };
2710
+ const textColor = isEnd ? colors.onBrand : enabled ? colors.text : colors.textSecondary;
2711
+ const buttonStyle = {
2712
+ width: DAY_CELL_PX,
2713
+ height: DAY_CELL_PX,
2714
+ padding: 0,
2715
+ boxSizing: "border-box",
2716
+ borderRadius: DAY_CELL_PX / 2,
2717
+ border: `${RING}px solid ${isToday ? colors.brand : "transparent"}`,
2718
+ background: isEnd ? colors.brand : "transparent",
2719
+ color: textColor,
2720
+ textDecoration: enabled ? "none" : "line-through",
2721
+ fontFamily: "inherit",
2722
+ fontSize: FONT,
2723
+ fontWeight: isEnd || isToday ? BOLD : REGULAR,
2724
+ cursor: enabled ? "pointer" : "default"
2725
+ };
2726
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-selected": isEnd, role: "gridcell", style: cellStyle, children: /* @__PURE__ */ jsxRuntime.jsx(
2727
+ "button",
2728
+ {
2729
+ "aria-current": isToday ? "date" : void 0,
2730
+ "aria-label": label,
2731
+ "data-testid": dayDomId(testID, iso),
2732
+ disabled: !enabled,
2733
+ id: dayDomId(testID, iso),
2734
+ style: buttonStyle,
2735
+ tabIndex: focusable ? 0 : -1,
2736
+ title: hint,
2737
+ type: "button",
2738
+ onClick: () => onPick(iso),
2739
+ onKeyDown: (event) => onKey(event, iso),
2740
+ children: Number(iso.slice(DAY_START))
2741
+ }
2742
+ ) });
2743
+ }
2744
+
2745
+ // src/DatePicker/utils/formatDate.ts
2746
+ var SAMPLE_UTC = Date.UTC(2027, 5, 12);
2747
+ var TWO_DIGIT_YEAR = 100;
2748
+ var CENTURY = 2e3;
2749
+ var PART_COUNT = 3;
2750
+ var PAD3 = 2;
2751
+ var MONDAY4 = 1;
2752
+ var ISO_LIKE = /^\d{4}-\d{1,2}-\d{1,2}$/;
2753
+ var MONTH_INDEXES = Array.from({ length: 12 }, (_unused, index) => index);
2754
+ var WEEK_OFFSETS = Array.from({ length: 7 }, (_unused, index) => index);
2755
+ var UTC = "UTC";
2756
+ var PART_OF = { day: "day" /* Day */, month: "month" /* Month */, year: "year" /* Year */ };
2757
+ function utcOf(iso) {
2758
+ const parts = parseIso(iso);
2759
+ return parts === null ? null : new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
2760
+ }
2761
+ function formatWith(iso, locale, options) {
2762
+ const date = utcOf(iso);
2763
+ if (date === null) return iso;
2764
+ return new Intl.DateTimeFormat(locale, { ...options, timeZone: UTC }).format(date).replace(/,/g, "");
2765
+ }
2766
+ function formatDisplay(iso, locale) {
2767
+ return formatWith(iso, locale, { weekday: "short", day: "numeric", month: "short", year: "numeric" });
2768
+ }
2769
+ function formatShort(iso, locale, withYear = true) {
2770
+ return formatWith(iso, locale, withYear ? { day: "numeric", month: "short", year: "numeric" } : { day: "numeric", month: "short" });
2771
+ }
2772
+ function formatMonthYear(iso, locale) {
2773
+ return formatWith(iso, locale, { month: "long", year: "numeric" });
2774
+ }
2775
+ function monthNames(locale) {
2776
+ const format = new Intl.DateTimeFormat(locale, { month: "long", timeZone: UTC });
2777
+ return MONTH_INDEXES.map((month) => format.format(new Date(Date.UTC(2024, month, 1))));
2778
+ }
2779
+ function weekdayNames(locale, firstDay = MONDAY4) {
2780
+ const format = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: UTC });
2781
+ return WEEK_OFFSETS.map((offset) => format.format(new Date(Date.UTC(2024, 0, firstDay + offset))));
2782
+ }
2783
+ function typedOrder(locale) {
2784
+ const parts = new Intl.DateTimeFormat(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone: UTC }).formatToParts(new Date(SAMPLE_UTC));
2785
+ return parts.map((part) => PART_OF[part.type]).filter((part) => part !== void 0);
2786
+ }
2787
+ function formatTyped(iso, locale) {
2788
+ const parts = parseIso(iso);
2789
+ if (parts === null) return iso;
2790
+ const text = {
2791
+ ["day" /* Day */]: String(parts.day).padStart(PAD3, "0"),
2792
+ ["month" /* Month */]: String(parts.month).padStart(PAD3, "0"),
2793
+ ["year" /* Year */]: String(parts.year)
2794
+ };
2795
+ return typedOrder(locale).map((part) => text[part]).join("/");
2796
+ }
2797
+ function parseTyped(text, locale) {
2798
+ const trimmed = text.trim();
2799
+ if (ISO_LIKE.test(trimmed)) {
2800
+ const [year = 0, month = 0, day = 0] = trimmed.split("-").map(Number);
2801
+ const parts2 = { year, month, day };
2802
+ return isValidParts(parts2) ? toIso(parts2) : null;
2803
+ }
2804
+ const numbers2 = trimmed.split(/\D+/).filter((piece) => piece !== "").map(Number);
2805
+ if (numbers2.length !== PART_COUNT) return null;
2806
+ const order = typedOrder(locale);
2807
+ const read = (part) => numbers2[order.indexOf(part)] ?? 0;
2808
+ const rawYear = read("year" /* Year */);
2809
+ const parts = { year: rawYear < TWO_DIGIT_YEAR ? CENTURY + rawYear : rawYear, month: read("month" /* Month */), day: read("day" /* Day */) };
2810
+ return isValidParts(parts) ? toIso(parts) : null;
2811
+ }
2812
+
2813
+ // src/DatePicker/utils/monthGrid.ts
2814
+ var DAYS_IN_WEEK3 = 7;
2815
+ var MONDAY5 = 1;
2816
+ function buildMonthGrid(year, month, firstDay = MONDAY5) {
2817
+ const lead = weekdayIndex(toIso({ year, month, day: 1 }), firstDay);
2818
+ const cells = Array.from({ length: lead }, () => null);
2819
+ for (let day = 1; day <= daysInMonth(year, month); day += 1) cells.push(toIso({ year, month, day }));
2820
+ while (cells.length % DAYS_IN_WEEK3 !== 0) cells.push(null);
2821
+ const weeks = [];
2822
+ for (let start = 0; start < cells.length; start += DAYS_IN_WEEK3) weeks.push(cells.slice(start, start + DAYS_IN_WEEK3));
2823
+ return weeks;
2824
+ }
2825
+ var SHORT_DAY = 2;
2826
+ var DAYS_IN_WEEK4 = 7;
2827
+ var HEADER_LINE = 28;
2828
+ var CAPTION_FONT = 15;
2829
+ var WEEKDAY_FONT = 12;
2830
+ var BOLD2 = 700;
2831
+ var ROW = { display: "flex" };
2832
+ var EMPTY = { width: DAY_CELL_PX, height: DAY_CELL_PX };
2833
+ var FALLBACK = { year: 1970, month: 1};
2834
+ function MonthGrid({ month, selection, focusedDay, bounds, testID, onPick, onKey, showCaption = false, motion }) {
2835
+ const { labels, locale, today, firstDay } = useDatePickerConfig();
2836
+ const colors = usePickerColors();
2837
+ const parts = parseIso(month) ?? FALLBACK;
2838
+ const weeks = React37.useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
2839
+ const weekdays = React37.useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
2840
+ const title = formatMonthYear(month, locale);
2841
+ const end = selection.to === "" ? selection.from : selection.to;
2842
+ const stateOf = (iso) => ({
2843
+ inRange: selection.from !== "" && iso >= selection.from && iso <= end,
2844
+ isEnd: iso === selection.from || iso === selection.to,
2845
+ isToday: iso === today,
2846
+ enabled: isWithinBounds(iso, bounds.min, bounds.max),
2847
+ focusable: iso === focusedDay
2848
+ });
2849
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: DAYS_IN_WEEK4 * DAY_CELL_PX, margin: "0 auto", ...motion }, children: [
2850
+ showCaption ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", fontWeight: BOLD2, fontSize: CAPTION_FONT, lineHeight: `${a11y.MIN_TOUCH_TARGET_PX}px` }, children: title }) : null,
2851
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "aria-label": title, "data-testid": `${testID}-grid-${month.slice(0, "2026-11".length)}`, role: "grid", children: [
2852
+ /* @__PURE__ */ jsxRuntime.jsx("div", { role: "row", style: ROW, children: weekdays.map((name) => /* @__PURE__ */ jsxRuntime.jsx("div", { role: "columnheader", style: { width: DAY_CELL_PX, textAlign: "center", fontSize: WEEKDAY_FONT, lineHeight: `${HEADER_LINE}px`, color: colors.textSecondary }, children: name.slice(0, SHORT_DAY) }, name)) }),
2853
+ weeks.map((week, row) => /* @__PURE__ */ jsxRuntime.jsx("div", { role: "row", style: ROW, children: week.map(
2854
+ (iso, column) => iso === null ? /* @__PURE__ */ jsxRuntime.jsx("div", { role: "gridcell", style: EMPTY }, `empty-${column}`) : /* @__PURE__ */ jsxRuntime.jsx(DayCell, { hint: labels.dayHint, iso, label: formatDisplay(iso, locale), state: stateOf(iso), testID, onKey, onPick }, iso)
2855
+ ) }, `${month}-${row}`))
2856
+ ] })
2857
+ ] });
2858
+ }
2859
+ var YEARS_BACK = 100;
2860
+ var YEARS_AHEAD = 20;
2861
+ var ISO_LENGTH = 10;
2862
+ var FONT2 = 15;
2863
+ var BOLD3 = 700;
2864
+ var GAP = 4;
2865
+ var FALLBACK2 = { year: 1970, month: 1, day: 1 };
2866
+ function boundYear(bound) {
2867
+ return parseIso((bound ?? "").slice(0, ISO_LENGTH))?.year;
2868
+ }
2869
+ function yearOptions(current, bounds) {
2870
+ const first = Math.min(current, boundYear(bounds.min) ?? current - YEARS_BACK);
2871
+ const last = Math.max(current, boundYear(bounds.max) ?? current + YEARS_AHEAD);
2872
+ return Array.from({ length: last - first + 1 }, (_unused, index) => first + index);
2873
+ }
2874
+ function MonthHeader({ focusedDay, bounds, testID, onMove }) {
2875
+ const { labels, locale } = useDatePickerConfig();
2876
+ const colors = usePickerColors();
2877
+ const parts = parseIso(focusedDay) ?? FALLBACK2;
2878
+ const names = React37.useMemo(() => monthNames(locale), [locale]);
2879
+ const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
2880
+ const selectStyle = { minHeight: a11y.MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
2881
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
2882
+ /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.previousMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "previous" /* Previous */ }), testID: `${testID}-previous`, onPress: () => onMove(addMonths(focusedDay, -1)) }),
2883
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: GAP }, children: [
2884
+ /* @__PURE__ */ jsxRuntime.jsx("select", { "aria-label": labels.month, "data-testid": `${testID}-month`, style: selectStyle, title: labels.monthHint, value: parts.month, onChange: (event) => setMonthYear(parts.year, Number(event.target.value)), children: names.map((name, index) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: index + 1, children: name }, name)) }),
2885
+ /* @__PURE__ */ jsxRuntime.jsx("select", { "aria-label": labels.year, "data-testid": `${testID}-year`, style: selectStyle, title: labels.monthHint, value: parts.year, onChange: (event) => setMonthYear(Number(event.target.value), parts.month), children: yearOptions(parts.year, bounds).map((year) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: year, children: year }, year)) })
2886
+ ] }),
2887
+ /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.nextMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "next" /* Next */ }), testID: `${testID}-next`, onPress: () => onMove(addMonths(focusedDay, 1)) })
2888
+ ] });
2889
+ }
2890
+ var GAP2 = 8;
2891
+ function PickerFooter({ summary, children }) {
2892
+ const colors = usePickerColors();
2893
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: GAP2, borderTop: `1px solid ${colors.border}`, paddingTop: GAP2, marginTop: GAP2 }, children: [
2894
+ summary,
2895
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: GAP2, marginLeft: "auto" }, children })
2896
+ ] });
2897
+ }
2898
+ function useEntered(key, reduced) {
2899
+ const [enteredKey, setEnteredKey] = React37.useState(null);
2900
+ React37.useEffect(() => {
2901
+ if (reduced) return void 0;
2902
+ let inner = 0;
2903
+ const outer = requestAnimationFrame(() => {
2904
+ inner = requestAnimationFrame(() => setEnteredKey(key));
2905
+ });
2906
+ return () => {
2907
+ cancelAnimationFrame(outer);
2908
+ cancelAnimationFrame(inner);
2909
+ };
2910
+ }, [key, reduced]);
2911
+ return reduced || enteredKey === key;
2912
+ }
2913
+ function useMonthSlide(month) {
2914
+ const reduced = useReducedMotion();
2915
+ const previous = React37.useRef(month);
2916
+ const direction = React37.useRef(0);
2917
+ if (previous.current !== month) {
2918
+ direction.current = month > previous.current ? 1 : -1;
2919
+ previous.current = month;
2920
+ }
2921
+ const entered = useEntered(month, reduced);
2922
+ return monthSlideStyle(entered, reduced, direction.current);
2923
+ }
2924
+ function SingleCalendar({ value, bounds, testID, onCommit }) {
2925
+ const { labels, today } = useDatePickerConfig();
2926
+ const [draft, setDraft] = React37.useState(value);
2927
+ const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
2928
+ const month = monthStart(grid.focusedDay);
2929
+ const motion = useMonthSlide(month);
2930
+ const pick = (iso) => {
2931
+ setDraft(iso);
2932
+ grid.moveTo(iso);
2933
+ };
2934
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2935
+ /* @__PURE__ */ jsxRuntime.jsx(MonthHeader, { bounds, focusedDay: grid.focusedDay, testID, onMove: grid.moveTo }),
2936
+ /* @__PURE__ */ jsxRuntime.jsx(MonthGrid, { bounds, focusedDay: grid.focusedDay, month, motion, selection: { from: draft, to: draft }, testID, onKey: grid.onDayKey, onPick: pick }),
2937
+ /* @__PURE__ */ jsxRuntime.jsxs(PickerFooter, { children: [
2938
+ /* @__PURE__ */ jsxRuntime.jsx(uiButtons.Button, { accessibilityHint: labels.clearHint, accessibilityLabel: labels.clear, label: labels.clear, testID: `${testID}-clear`, variant: "ghost", onPress: () => onCommit("") }),
2939
+ /* @__PURE__ */ jsxRuntime.jsx(uiButtons.Button, { accessibilityHint: labels.setDateHint, accessibilityLabel: labels.setDate, disabled: draft === "", label: labels.setDate, testID: `${testID}-set`, onPress: () => onCommit(draft) })
2940
+ ] })
2941
+ ] });
2942
+ }
2943
+ function useIsPhone() {
2944
+ return !isWideFormLayout(reactNative.useWindowDimensions().width);
2945
+ }
2946
+ function useReturnFocus(open, target) {
2947
+ const wasOpen = React37.useRef(open);
2948
+ React37.useEffect(() => {
2949
+ if (wasOpen.current && !open) target.current?.focus();
2950
+ wasOpen.current = open;
2951
+ }, [open, target]);
2952
+ }
2953
+ function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage }) {
2954
+ const { labels, locale } = useDatePickerConfig();
2955
+ const [focused, setFocused] = React37.useState(false);
2956
+ const [text, setText] = React37.useState("");
2957
+ React37.useEffect(() => {
2958
+ setText((current) => {
2959
+ const parsed = current.trim() === "" ? "" : parseTyped(current, locale);
2960
+ if (parsed === null || parsed === value) return current;
2961
+ return value === "" ? "" : formatTyped(value, locale);
2962
+ });
2963
+ }, [value, locale]);
2964
+ const verdict = (typed) => {
2965
+ if (typed.trim() === "") return void 0;
2966
+ const parsed = parseTyped(typed, locale);
2967
+ if (parsed === null) return labels.invalidDate;
2968
+ return isWithinBounds(parsed, bounds.min, bounds.max) ? void 0 : rangeMessage ?? labels.outOfRange;
2969
+ };
2970
+ const onText = (next) => {
2971
+ setText(next);
2972
+ if (next.trim() === "") {
2973
+ onError?.(void 0);
2974
+ onChange("");
2975
+ return;
2976
+ }
2977
+ const parsed = parseTyped(next, locale);
2978
+ if (parsed === null) return;
2979
+ const message = verdict(next);
2980
+ onError?.(message);
2981
+ if (message === void 0) onChange(parsed);
2982
+ };
2983
+ const isReady = () => {
2984
+ if (!focused) return true;
2985
+ const message = verdict(text);
2986
+ onError?.(message);
2987
+ return message === void 0;
2988
+ };
2989
+ return {
2990
+ display: focused ? text : value === "" ? "" : format(value, locale),
2991
+ onText,
2992
+ onFocus: () => {
2993
+ setFocused(true);
2994
+ setText(value === "" ? "" : formatTyped(value, locale));
2995
+ },
2996
+ onBlur: () => {
2997
+ setFocused(false);
2998
+ if (verdict(text) !== void 0) onError?.(verdict(text));
2999
+ },
3000
+ isReady
3001
+ };
3002
+ }
3003
+ var SINGLE_PICKER_WIDTH = 340;
3004
+ var ICON_ROOM = 48;
3005
+ var ICON_SLOT = { position: "absolute", right: 2, top: 0, bottom: 0, display: "flex", alignItems: "center" };
3006
+ var anchorStyles = reactNative.StyleSheet.create({ wrap: { position: "relative", width: "100%" } });
3007
+ function DatePickerInput({ fieldProps, context, onTypedError }) {
3008
+ const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
3009
+ const { labels } = useDatePickerConfig();
3010
+ const phone = useIsPhone();
3011
+ const [open, setOpen] = React37.useState(false);
3012
+ const anchorRef = React37.useRef(null);
3013
+ const inputRef = React37.useRef(null);
3014
+ const bounds = { min, max };
3015
+ const typed = useTypedDate({ value, onChange, bounds, format: formatDisplay, onError: onTypedError });
3016
+ const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
3017
+ const focus = focusBind;
3018
+ const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
3019
+ const close = React37.useCallback(() => setOpen(false), []);
3020
+ useReturnFocus(open, inputRef);
3021
+ const commit = (iso) => {
3022
+ onTypedError?.(void 0);
3023
+ onChange(iso);
3024
+ close();
3025
+ };
3026
+ const onKeyDown = (event) => {
3027
+ if (event.key === "ArrowDown" && event.altKey) {
3028
+ event.preventDefault();
3029
+ setOpen(true);
3030
+ return;
3031
+ }
3032
+ if (event.key !== "Enter" || onSubmit === void 0) return;
3033
+ event.preventDefault();
3034
+ if (typed.isReady()) onSubmit();
3035
+ };
3036
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyles.wrap, children: [
3037
+ /* @__PURE__ */ jsxRuntime.jsx(
3038
+ "input",
3039
+ {
3040
+ ...webA11y,
3041
+ ...hoverBind,
3042
+ ref: inputRef,
3043
+ "aria-label": label,
3044
+ autoComplete: "off",
3045
+ "data-testid": testID,
3046
+ disabled,
3047
+ id: context.controlId,
3048
+ style: { ...buildNativeInputStyle(style), paddingInlineEnd: ICON_ROOM },
3049
+ title: accessibilityHint,
3050
+ type: "text",
3051
+ value: typed.display,
3052
+ onBlur: (event) => {
3053
+ focus.onBlur?.(event);
3054
+ typed.onBlur();
3055
+ },
3056
+ onChange: (event) => typed.onText(event.target.value),
3057
+ onFocus: (event) => {
3058
+ focus.onFocus?.(event);
3059
+ typed.onFocus();
3060
+ },
3061
+ onKeyDown
3062
+ }
3063
+ ),
3064
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: ICON_SLOT, children: /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.openCalendarHint, accessibilityLabel: labels.openCalendar, appearance: "ghost", disabled, renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "calendar" /* Calendar */ }), testID: `${testID}-calendar`, onPress: () => setOpen((current) => !current) }) }),
3065
+ open ? /* @__PURE__ */ jsxRuntime.jsx(PickerSurface, { anchorRef, label: labels.dialog, minWidth: SINGLE_PICKER_WIDTH, phone, testID: `${testID}-picker`, onDismiss: close, children: /* @__PURE__ */ jsxRuntime.jsx(SingleCalendar, { bounds, testID: `${testID}-picker`, value, onCommit: commit }) }) : null
3066
+ ] });
3067
+ }
2345
3068
  var IS_WEB7 = reactNative.Platform.OS === "web";
2346
- function TemporalInput({ fieldProps, context, webInputType }) {
3069
+ var DATE_TYPE = "date";
3070
+ function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
3071
+ if (IS_WEB7 && webInputType === DATE_TYPE) return /* @__PURE__ */ jsxRuntime.jsx(DatePickerInput, { context, fieldProps, onTypedError });
2347
3072
  if (IS_WEB7) return /* @__PURE__ */ jsxRuntime.jsx(WebDateInput, { context, fieldProps, webInputType });
2348
3073
  return /* @__PURE__ */ jsxRuntime.jsx(
2349
3074
  ThemedTextInput,
@@ -2364,11 +3089,269 @@ function TemporalInput({ fieldProps, context, webInputType }) {
2364
3089
  }
2365
3090
  function TemporalField({ fieldProps, webInputType }) {
2366
3091
  const { label, required, hint, error } = fieldProps;
2367
- return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType }) });
3092
+ const [typedError, setTypedError] = React37.useState(void 0);
3093
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
2368
3094
  }
2369
3095
  function DateField(props) {
2370
3096
  return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "date" });
2371
3097
  }
3098
+ function NativeDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, style, testID }) {
3099
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.dateRow, style], testID: `${testID}-range`, children: [
3100
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsxRuntime.jsx(DateField, { accessibilityHint: hint, label: fromLabel, testID: `${testID}-from`, value: value.from, onChange: (from) => onChange({ from, to: value.to }), onSubmit }) }),
3101
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsxRuntime.jsx(DateField, { accessibilityHint: hint, label: toLabel, testID: `${testID}-to`, value: value.to, onChange: (to) => onChange({ from: value.from, to }), onSubmit }) })
3102
+ ] });
3103
+ }
3104
+
3105
+ // src/DatePicker/utils/rangePresets.ts
3106
+ var RANGE_PRESETS = ["today" /* Today */, "last7Days" /* Last7Days */, "thisMonth" /* ThisMonth */, "quarter" /* Quarter */];
3107
+ var PRESET_LABEL = {
3108
+ ["today" /* Today */]: "today",
3109
+ ["last7Days" /* Last7Days */]: "last7Days",
3110
+ ["thisMonth" /* ThisMonth */]: "thisMonth",
3111
+ ["quarter" /* Quarter */]: "quarter"
3112
+ };
3113
+ var MONTHS_IN_QUARTER = 3;
3114
+ var EPOCH2 = { year: 1970, month: 1};
3115
+ function presetLabel(labels, preset) {
3116
+ return labels[PRESET_LABEL[preset]];
3117
+ }
3118
+ function quarterStart(today) {
3119
+ const parts = parseIso(today) ?? EPOCH2;
3120
+ const month = Math.floor((parts.month - 1) / MONTHS_IN_QUARTER) * MONTHS_IN_QUARTER + 1;
3121
+ return toIso({ year: parts.year, month, day: 1 });
3122
+ }
3123
+ function presetRange(preset, today) {
3124
+ if (preset === "last7Days" /* Last7Days */) return { from: addDays(today, -6), to: today };
3125
+ if (preset === "thisMonth" /* ThisMonth */) return { from: monthStart(today), to: today };
3126
+ if (preset === "quarter" /* Quarter */) return { from: quarterStart(today), to: today };
3127
+ return { from: today, to: today };
3128
+ }
3129
+ function matchingPreset(range, today) {
3130
+ return RANGE_PRESETS.find((preset) => {
3131
+ const span = presetRange(preset, today);
3132
+ return span.from === range.from && span.to === range.to;
3133
+ }) ?? null;
3134
+ }
3135
+ function pickRangeDay(range, day) {
3136
+ const open = range.from !== "" && range.to === "";
3137
+ if (!open) return { from: day, to: "" };
3138
+ return day < range.from ? { from: day, to: range.from } : { from: range.from, to: day };
3139
+ }
3140
+ var GAP3 = 8;
3141
+ var CHIP_PAD = 16;
3142
+ var FONT3 = 14;
3143
+ var BOLD4 = 700;
3144
+ var REGULAR2 = 400;
3145
+ var ACTIVE_BORDER = 2;
3146
+ function PresetChips({ active, testID, onPick }) {
3147
+ const { labels } = useDatePickerConfig();
3148
+ const colors = usePickerColors();
3149
+ const chipStyle = (isActive) => ({
3150
+ minHeight: a11y.MIN_TOUCH_TARGET_PX,
3151
+ padding: `0 ${CHIP_PAD}px`,
3152
+ borderRadius: a11y.MIN_TOUCH_TARGET_PX / 2,
3153
+ border: `${isActive ? ACTIVE_BORDER : 1}px solid ${isActive ? colors.brand : colors.border}`,
3154
+ background: colors.surface,
3155
+ color: colors.text,
3156
+ fontFamily: "inherit",
3157
+ fontSize: FONT3,
3158
+ fontWeight: isActive ? BOLD4 : REGULAR2,
3159
+ cursor: "pointer"
3160
+ });
3161
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-label": labels.presets, role: "group", style: { display: "flex", flexWrap: "wrap", gap: GAP3, marginBottom: GAP3 }, children: RANGE_PRESETS.map((preset) => /* @__PURE__ */ jsxRuntime.jsxs("button", { "aria-pressed": active === preset, "data-testid": `${testID}-preset-${preset}`, style: chipStyle(active === preset), title: labels.presetHint, type: "button", onClick: () => onPick(preset), children: [
3162
+ active === preset ? "\u2713 " : "",
3163
+ presetLabel(labels, preset)
3164
+ ] }, preset)) });
3165
+ }
3166
+ var GAP4 = 8;
3167
+ var FONT4 = 14;
3168
+ function PresetMenu({ active, testID, onPick }) {
3169
+ const { labels } = useDatePickerConfig();
3170
+ const colors = usePickerColors();
3171
+ const onChange = (event) => {
3172
+ const preset = RANGE_PRESETS.find((candidate) => candidate === event.target.value);
3173
+ if (preset !== void 0) onPick(preset);
3174
+ };
3175
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3176
+ "select",
3177
+ {
3178
+ "aria-label": labels.presets,
3179
+ "data-testid": `${testID}-presets`,
3180
+ style: { minHeight: a11y.MIN_TOUCH_TARGET_PX, width: "100%", marginBottom: GAP4, border: `1px solid ${colors.border}`, borderRadius: GAP4, background: colors.surface, color: colors.text, fontFamily: "inherit", fontSize: FONT4 },
3181
+ title: labels.presetHint,
3182
+ value: active ?? "",
3183
+ onChange,
3184
+ children: [
3185
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: labels.presets }),
3186
+ RANGE_PRESETS.map((preset) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: preset, children: presetLabel(labels, preset) }, preset))
3187
+ ]
3188
+ }
3189
+ );
3190
+ }
3191
+ var PHONE_LIST_HEIGHT = "min(56vh, 440px)";
3192
+ var MONTH_GAP = 32;
3193
+ var NAV_ROW = { position: "absolute", left: 0, right: 0, top: 0, display: "flex", justifyContent: "space-between", pointerEvents: "none" };
3194
+ var NAV_SLOT = { pointerEvents: "auto" };
3195
+ function RangeMonthsList({ months, grid }) {
3196
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": `${grid.testID}-months`, style: { maxHeight: PHONE_LIST_HEIGHT, overflowY: "auto" }, children: months.map((month) => /* @__PURE__ */ jsxRuntime.jsx(MonthGrid, { showCaption: true, month, ...grid }, month)) });
3197
+ }
3198
+ function RangeMonthsPair({ months, grid, motion, onShift }) {
3199
+ const { labels } = useDatePickerConfig();
3200
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
3201
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: NAV_ROW, children: [
3202
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: NAV_SLOT, children: /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.previousMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "previous" /* Previous */ }), testID: `${grid.testID}-previous`, onPress: () => onShift(-1) }) }),
3203
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: NAV_SLOT, children: /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.nextMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "next" /* Next */ }), testID: `${grid.testID}-next`, onPress: () => onShift(1) }) })
3204
+ ] }),
3205
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: MONTH_GAP }, children: months.map((month) => /* @__PURE__ */ jsxRuntime.jsx(MonthGrid, { showCaption: true, month, motion, ...grid }, month)) })
3206
+ ] });
3207
+ }
3208
+ var PHONE_MONTHS = 6;
3209
+ var DESKTOP_MONTHS = 2;
3210
+ var SUMMARY_FONT = 14;
3211
+ var SEMIBOLD = 600;
3212
+ function useRangeSummary(draft) {
3213
+ const { labels, locale } = useDatePickerConfig();
3214
+ if (draft.from === "") return "";
3215
+ if (draft.to === "") return formatShort(draft.from, locale);
3216
+ const days = labels.dayCount.replace("{{p1}}", String(daysBetweenInclusive(draft.from, draft.to)));
3217
+ return `${formatShort(draft.from, locale, false)}${labels.rangeSeparator}${formatShort(draft.to, locale)} \xB7 ${days}`;
3218
+ }
3219
+ function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
3220
+ const { labels, today } = useDatePickerConfig();
3221
+ const [draft, setDraft] = React37.useState(value);
3222
+ const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
3223
+ const pickDraft = React37.useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
3224
+ const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
3225
+ const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
3226
+ const [first, setFirst] = React37.useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
3227
+ const focusMonth = monthStart(focus.focusedDay);
3228
+ const last = addMonths(first, visible - 1);
3229
+ const motion = useMonthSlide(first);
3230
+ const summary = useRangeSummary(draft);
3231
+ React37.useEffect(() => {
3232
+ if (focusMonth < first) setFirst(focusMonth);
3233
+ else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
3234
+ }, [focusMonth, first, last, visible]);
3235
+ const pick = (iso) => {
3236
+ pickDraft(iso);
3237
+ focus.moveTo(iso);
3238
+ };
3239
+ const applyPreset = (preset) => {
3240
+ const range = presetRange(preset, today);
3241
+ setDraft(range);
3242
+ focus.moveTo(range.to);
3243
+ };
3244
+ const shift = (step) => {
3245
+ setFirst(addMonths(first, step));
3246
+ focus.moveTo(addMonths(focus.focusedDay, step));
3247
+ };
3248
+ const months = Array.from({ length: visible }, (_unused, index) => addMonths(first, index));
3249
+ const grid = { selection: draft, focusedDay: focus.focusedDay, bounds, testID, onPick: pick, onKey: focus.onDayKey };
3250
+ const presets = { active: matchingPreset(draft, today), testID, onPick: applyPreset };
3251
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3252
+ phone ? /* @__PURE__ */ jsxRuntime.jsx(PresetMenu, { ...presets }) : /* @__PURE__ */ jsxRuntime.jsx(PresetChips, { ...presets }),
3253
+ phone ? /* @__PURE__ */ jsxRuntime.jsx(RangeMonthsList, { grid, months }) : /* @__PURE__ */ jsxRuntime.jsx(RangeMonthsPair, { grid, months, motion, onShift: shift }),
3254
+ /* @__PURE__ */ jsxRuntime.jsxs(PickerFooter, { summary: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-live": "polite", "data-testid": `${testID}-summary`, style: { fontSize: SUMMARY_FONT, fontWeight: SEMIBOLD }, children: summary }), children: [
3255
+ /* @__PURE__ */ jsxRuntime.jsx(uiButtons.Button, { accessibilityHint: labels.cancelHint, accessibilityLabel: labels.cancel, label: labels.cancel, testID: `${testID}-cancel`, variant: "ghost", onPress: onCancel }),
3256
+ /* @__PURE__ */ jsxRuntime.jsx(
3257
+ uiButtons.Button,
3258
+ {
3259
+ accessibilityHint: labels.applyHint,
3260
+ accessibilityLabel: labels.apply,
3261
+ disabled: draft.from === "",
3262
+ label: labels.apply,
3263
+ testID: `${testID}-apply`,
3264
+ onPress: () => onApply({ from: draft.from, to: draft.to === "" ? draft.from : draft.to })
3265
+ }
3266
+ )
3267
+ ] })
3268
+ ] });
3269
+ }
3270
+ var RANGE_PICKER_WIDTH = 690;
3271
+ var GAP5 = 8;
3272
+ var NO_BOUNDS = {};
3273
+ var SEGMENT = { flex: 1, minWidth: 0, border: "none", background: "transparent", color: "inherit", font: "inherit", outline: "none", padding: 0 };
3274
+ function orNone(value) {
3275
+ return value !== "" ? value : void 0;
3276
+ }
3277
+ function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
3278
+ const { labels } = useDatePickerConfig();
3279
+ const phone = useIsPhone();
3280
+ const [open, setOpen] = React37.useState(false);
3281
+ const [fromError, setFromError] = React37.useState(void 0);
3282
+ const [toError, setToError] = React37.useState(void 0);
3283
+ const anchorRef = React37.useRef(null);
3284
+ const fromRef = React37.useRef(null);
3285
+ const from = useTypedDate({ value: value.from, onChange: (next) => onChange({ from: next, to: value.to }), bounds: { max: orNone(value.to) }, format: formatShort, onError: setFromError, rangeMessage: labels.rangeOrder });
3286
+ const to = useTypedDate({ value: value.to, onChange: (next) => onChange({ from: value.from, to: next }), bounds: { min: orNone(value.from) }, format: formatShort, onError: setToError, rangeMessage: labels.rangeOrder });
3287
+ const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
3288
+ const focus = focusBind;
3289
+ const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
3290
+ React37.useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
3291
+ const close = React37.useCallback(() => setOpen(false), []);
3292
+ useReturnFocus(open, fromRef);
3293
+ const onKeyDown = (event) => {
3294
+ if (event.key === "ArrowDown" && event.altKey) {
3295
+ event.preventDefault();
3296
+ setOpen(true);
3297
+ return;
3298
+ }
3299
+ if (event.key !== "Enter" || onSubmit === void 0) return;
3300
+ event.preventDefault();
3301
+ const ready = [from.isReady(), to.isReady()].every(Boolean);
3302
+ if (ready) onSubmit();
3303
+ };
3304
+ const segment = (side, typed) => /* @__PURE__ */ jsxRuntime.jsx(
3305
+ "input",
3306
+ {
3307
+ ...webA11y,
3308
+ ref: side === "from" /* From */ ? fromRef : void 0,
3309
+ "aria-label": side === "from" /* From */ ? fromLabel : toLabel,
3310
+ autoComplete: "off",
3311
+ "data-testid": `${testID}-${side}`,
3312
+ id: side === "from" /* From */ ? context.controlId : void 0,
3313
+ style: SEGMENT,
3314
+ title: hint,
3315
+ type: "text",
3316
+ value: typed.display,
3317
+ onBlur: (event) => {
3318
+ focus.onBlur?.(event);
3319
+ typed.onBlur();
3320
+ },
3321
+ onChange: (event) => typed.onText(event.target.value),
3322
+ onFocus: (event) => {
3323
+ focus.onFocus?.(event);
3324
+ typed.onFocus();
3325
+ },
3326
+ onKeyDown
3327
+ }
3328
+ );
3329
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyles.wrap, children: [
3330
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ...hoverBind, style: { ...buildNativeInputStyle(style), display: "flex", alignItems: "center", gap: GAP5, paddingInlineEnd: ICON_ROOM }, children: [
3331
+ segment("from" /* From */, from),
3332
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\u2192" }),
3333
+ segment("to" /* To */, to)
3334
+ ] }),
3335
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: ICON_SLOT, children: /* @__PURE__ */ jsxRuntime.jsx(uiButtons.IconButton, { accessibilityHint: labels.openCalendarHint, accessibilityLabel: labels.openCalendar, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsxRuntime.jsx(Glyph, { color, name: "calendar" /* Calendar */ }), testID: `${testID}-calendar`, onPress: () => setOpen((current) => !current) }) }),
3336
+ open ? /* @__PURE__ */ jsxRuntime.jsx(PickerSurface, { anchorRef, label: labels.rangeDialog, minWidth: RANGE_PICKER_WIDTH, phone, testID: `${testID}-picker`, onDismiss: close, children: /* @__PURE__ */ jsxRuntime.jsx(
3337
+ RangeCalendar,
3338
+ {
3339
+ bounds: NO_BOUNDS,
3340
+ phone,
3341
+ testID: `${testID}-picker`,
3342
+ value,
3343
+ onApply: (range) => {
3344
+ setFromError(void 0);
3345
+ setToError(void 0);
3346
+ onChange(range);
3347
+ close();
3348
+ },
3349
+ onCancel: close
3350
+ }
3351
+ ) }) : null
3352
+ ] });
3353
+ }
3354
+ var IS_WEB8 = reactNative.Platform.OS === "web";
2372
3355
  function DateRangeControl({
2373
3356
  value,
2374
3357
  onChange,
@@ -2380,30 +3363,12 @@ function DateRangeControl({
2380
3363
  testID
2381
3364
  }) {
2382
3365
  const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
2383
- return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.dateRow, style], testID: `${testID}-range`, children: [
2384
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsxRuntime.jsx(
2385
- DateField,
2386
- {
2387
- accessibilityHint: hint,
2388
- label: fromLabel,
2389
- testID: `${testID}-from`,
2390
- value: value.from,
2391
- onChange: (from) => onChange({ from, to: value.to }),
2392
- onSubmit
2393
- }
2394
- ) }),
2395
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsxRuntime.jsx(
2396
- DateField,
2397
- {
2398
- accessibilityHint: hint,
2399
- label: toLabel,
2400
- testID: `${testID}-to`,
2401
- value: value.to,
2402
- onChange: (to) => onChange({ from: value.from, to }),
2403
- onSubmit
2404
- }
2405
- ) })
2406
- ] }) });
3366
+ const { labels } = useDatePickerConfig();
3367
+ const [typedError, setTypedError] = React37.useState(void 0);
3368
+ if (!IS_WEB8) {
3369
+ return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
3370
+ }
3371
+ return /* @__PURE__ */ jsxRuntime.jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style, testID: `${testID}-range`, children: /* @__PURE__ */ jsxRuntime.jsx(Field, { error: typedError, label: `${fromLabel}${labels.rangeSeparator}${toLabel}`, children: (context) => /* @__PURE__ */ jsxRuntime.jsx(WebDateRange, { context, fromLabel, hint, testID, toLabel, value, onChange, onSubmit, onTypedError: setTypedError }) }) }) });
2407
3372
  }
2408
3373
  function DateTimeField(props) {
2409
3374
  return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "datetime-local" });
@@ -2439,7 +3404,7 @@ var ROW_GAP = 4;
2439
3404
  var TAB_PADDING = 4;
2440
3405
  var INDICATOR_WIDTH = 2;
2441
3406
  var TAB_FONT_SIZE = 12;
2442
- var styles15 = reactNative.StyleSheet.create({
3407
+ var styles17 = reactNative.StyleSheet.create({
2443
3408
  row: { flexDirection: "row", flexWrap: "nowrap", gap: ROW_GAP },
2444
3409
  tab: {
2445
3410
  borderBottomWidth: INDICATOR_WIDTH,
@@ -2479,13 +3444,13 @@ var StepperTab = ({
2479
3444
  accessibilityRole: "tab",
2480
3445
  accessibilityState: { selected },
2481
3446
  "aria-selected": selected,
2482
- style: [styles15.tab, { borderBottomColor: indicator }, ring.ringStyle],
3447
+ style: [styles17.tab, { borderBottomColor: indicator }, ring.ringStyle],
2483
3448
  testID,
2484
3449
  onBlur: ring.onBlur,
2485
3450
  onFocus: ring.onFocus,
2486
3451
  onPress: () => onStep(step.key),
2487
3452
  ...webKeyProps,
2488
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles15.text, { color: theme.colors.text }, selected ? styles15.textSelected : void 0], children: step.label })
3453
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles17.text, { color: theme.colors.text }, selected ? styles17.textSelected : void 0], children: step.label })
2489
3454
  }
2490
3455
  );
2491
3456
  };
@@ -2495,7 +3460,7 @@ var StepperTabs = ({
2495
3460
  onStep,
2496
3461
  stepHint,
2497
3462
  testID
2498
- }) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style: styles15.row, testID, children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
3463
+ }) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", style: styles17.row, testID, children: steps.map((step) => /* @__PURE__ */ jsxRuntime.jsx(
2499
3464
  StepperTab,
2500
3465
  {
2501
3466
  hint: stepHint,
@@ -2514,7 +3479,7 @@ function resolveStepNeighbours(steps, current) {
2514
3479
  return { previous: steps[index - 1] ?? null, next: steps[index + 1] ?? null };
2515
3480
  }
2516
3481
  var ROW_GAP2 = 8;
2517
- var styles16 = reactNative.StyleSheet.create({
3482
+ var styles18 = reactNative.StyleSheet.create({
2518
3483
  cell: { flex: 1, minWidth: 0 },
2519
3484
  row: { flexDirection: "row", gap: ROW_GAP2 }
2520
3485
  });
@@ -2526,8 +3491,8 @@ var StepperNav = ({
2526
3491
  testID
2527
3492
  }) => {
2528
3493
  const { previous, next } = resolveStepNeighbours(steps, current);
2529
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.row, testID, children: [
2530
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles16.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
3494
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.row, testID, children: [
3495
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles18.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
2531
3496
  uiButtons.Button,
2532
3497
  {
2533
3498
  fullWidth: true,
@@ -2543,7 +3508,7 @@ var StepperNav = ({
2543
3508
  }
2544
3509
  }
2545
3510
  ) }),
2546
- next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles16.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
3511
+ next === null ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles18.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
2547
3512
  uiButtons.Button,
2548
3513
  {
2549
3514
  fullWidth: true,
@@ -2558,18 +3523,18 @@ var StepperNav = ({
2558
3523
  ] });
2559
3524
  };
2560
3525
  var STATUS_FONT = 16;
2561
- var styles17 = reactNative.StyleSheet.create({
3526
+ var styles19 = reactNative.StyleSheet.create({
2562
3527
  line: { fontSize: STATUS_FONT }
2563
3528
  });
2564
3529
  function FormStatusLine({ message, testID, style }) {
2565
3530
  const { theme } = uiFeedback.useUi();
2566
3531
  if (message === null || message === void 0 || message === "") return null;
2567
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles17.line, { color: theme.colors.text }, style], testID, children: message });
3532
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles19.line, { color: theme.colors.text }, style], testID, children: message });
2568
3533
  }
2569
3534
  function useFocusFirstInvalid(refs) {
2570
- const latest = React2.useRef(refs);
3535
+ const latest = React37.useRef(refs);
2571
3536
  latest.current = refs;
2572
- return React2.useCallback((invalid) => {
3537
+ return React37.useCallback((invalid) => {
2573
3538
  const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
2574
3539
  first?.focus();
2575
3540
  }, []);
@@ -2578,8 +3543,8 @@ function isScrollable(node) {
2578
3543
  return "scrollIntoView" in Object(node);
2579
3544
  }
2580
3545
  function useKeepInView(trigger) {
2581
- const ref = React2.useRef(null);
2582
- React2.useEffect(() => {
3546
+ const ref = React37.useRef(null);
3547
+ React37.useEffect(() => {
2583
3548
  const node = ref.current;
2584
3549
  const hasTrigger = trigger !== void 0 && trigger !== null;
2585
3550
  if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
@@ -2588,13 +3553,13 @@ function useKeepInView(trigger) {
2588
3553
  }
2589
3554
  var DEFAULT_PREVIEW_PX = 48;
2590
3555
  var PREVIEW_RADIUS = 8;
2591
- var GAP = 8;
3556
+ var GAP6 = 8;
2592
3557
  var TITLE_FONT_SIZE = 14;
2593
3558
  var HELP_FONT_SIZE = 13;
2594
- var styles18 = reactNative.StyleSheet.create({
3559
+ var styles20 = reactNative.StyleSheet.create({
2595
3560
  help: { flex: 1, fontSize: HELP_FONT_SIZE },
2596
- root: { gap: GAP },
2597
- tile: { alignItems: "center", flexDirection: "row", gap: GAP },
3561
+ root: { gap: GAP6 },
3562
+ tile: { alignItems: "center", flexDirection: "row", gap: GAP6 },
2598
3563
  title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700" },
2599
3564
  toggle: { alignSelf: "flex-start", justifyContent: "center", minHeight: a11y.MIN_TOUCH_TARGET_PX },
2600
3565
  toggleText: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", textDecorationLine: "underline" }
@@ -2611,13 +3576,13 @@ var UploadWithLinkField = ({
2611
3576
  const { theme } = uiFeedback.useUi();
2612
3577
  const ring = uiButtons.useFocusRing();
2613
3578
  const url = value ?? "";
2614
- const [pasting, setPasting] = React2.useState(url !== "");
3579
+ const [pasting, setPasting] = React37.useState(url !== "");
2615
3580
  const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
2616
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.root, children: [
2617
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.title, { color: theme.colors.text }], children: labels.title }),
2618
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.tile, children: [
3581
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles20.root, children: [
3582
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.title, { color: theme.colors.text }], children: labels.title }),
3583
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles20.tile, children: [
2619
3584
  url === "" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [previewBox, { backgroundColor: theme.colors.border }] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Image, { accessible: false, source: { uri: url }, style: previewBox, testID: `${testID}-preview` }),
2620
- labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.help, { color: theme.colors.text }], children: labels.help })
3585
+ labels.help === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.help, { color: theme.colors.text }], children: labels.help })
2621
3586
  ] }),
2622
3587
  uploadControl,
2623
3588
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2628,12 +3593,12 @@ var UploadWithLinkField = ({
2628
3593
  accessibilityRole: "button",
2629
3594
  accessibilityState: { expanded: pasting },
2630
3595
  "aria-expanded": pasting,
2631
- style: [styles18.toggle, ring.ringStyle],
3596
+ style: [styles20.toggle, ring.ringStyle],
2632
3597
  testID: `${testID}-paste`,
2633
3598
  onBlur: ring.onBlur,
2634
3599
  onFocus: ring.onFocus,
2635
3600
  onPress: () => setPasting(!pasting),
2636
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
3601
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
2637
3602
  }
2638
3603
  ),
2639
3604
  pasting ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -2652,7 +3617,7 @@ var UploadWithLinkField = ({
2652
3617
  };
2653
3618
  var ACTION_GAP = 8;
2654
3619
  var GROUP_GAP = 16;
2655
- var styles19 = reactNative.StyleSheet.create({
3620
+ var styles21 = reactNative.StyleSheet.create({
2656
3621
  action: { alignItems: "flex-start", marginTop: ACTION_GAP },
2657
3622
  group: { marginBottom: GROUP_GAP }
2658
3623
  });
@@ -2669,13 +3634,13 @@ var AddOnRequest = ({
2669
3634
  disabled = false,
2670
3635
  style
2671
3636
  }) => {
2672
- const [requested, setRequested] = React2.useState(false);
3637
+ const [requested, setRequested] = React37.useState(false);
2673
3638
  const remove = () => {
2674
3639
  setRequested(false);
2675
3640
  onRemove();
2676
3641
  };
2677
3642
  if (!isAddOnOpen(hasValue, requested))
2678
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles19.action, style], children: /* @__PURE__ */ jsxRuntime.jsx(
3643
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles21.action, style], children: /* @__PURE__ */ jsxRuntime.jsx(
2679
3644
  uiButtons.Button,
2680
3645
  {
2681
3646
  accessibilityHint: addHint,
@@ -2687,9 +3652,9 @@ var AddOnRequest = ({
2687
3652
  onPress: () => setRequested(true)
2688
3653
  }
2689
3654
  ) });
2690
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles19.group, style], testID, children: [
3655
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles21.group, style], testID, children: [
2691
3656
  children,
2692
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles19.action, children: /* @__PURE__ */ jsxRuntime.jsx(
3657
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles21.action, children: /* @__PURE__ */ jsxRuntime.jsx(
2693
3658
  uiButtons.Button,
2694
3659
  {
2695
3660
  accessibilityHint: removeHint,
@@ -2706,7 +3671,7 @@ var AddOnRequest = ({
2706
3671
  var ROW_GAP3 = 8;
2707
3672
  var TEXT_SIZE = 13;
2708
3673
  var TEXT_LINE = 18;
2709
- var styles20 = reactNative.StyleSheet.create({
3674
+ var styles22 = reactNative.StyleSheet.create({
2710
3675
  row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
2711
3676
  text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
2712
3677
  });
@@ -2714,8 +3679,8 @@ var isFixBarVisible = (count) => count > 0;
2714
3679
  var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
2715
3680
  const { theme } = uiFeedback.useUi();
2716
3681
  if (!isFixBarVisible(count)) return null;
2717
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles20.row, style], testID, children: [
2718
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles20.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
3682
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles22.row, style], testID, children: [
3683
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles22.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
2719
3684
  /* @__PURE__ */ jsxRuntime.jsx(
2720
3685
  uiButtons.Button,
2721
3686
  {
@@ -2736,55 +3701,6 @@ var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
2736
3701
  SelectSurface2["Dropdown"] = "dropdown";
2737
3702
  return SelectSurface2;
2738
3703
  })(SelectSurface || {});
2739
- function useAnchorRect2(anchorRef) {
2740
- const [rect2, setRect] = React2.useState(null);
2741
- React2.useEffect(() => {
2742
- anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
2743
- }, [anchorRef]);
2744
- return rect2;
2745
- }
2746
-
2747
- // src/SearchSelect/DropdownPlacement.ts
2748
- var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
2749
- DropdownPlacement2["Below"] = "below";
2750
- DropdownPlacement2["Above"] = "above";
2751
- return DropdownPlacement2;
2752
- })(DropdownPlacement || {});
2753
-
2754
- // src/SearchSelect/utils/dropdownFrame.ts
2755
- var MIN_PANEL_WIDTH = 240;
2756
- var EDGE = 8;
2757
- function placeDropdown(anchor, panelHeight, viewportHeight) {
2758
- const roomBelow = viewportHeight - (anchor.y + anchor.height);
2759
- if (roomBelow >= panelHeight) return "below" /* Below */;
2760
- return anchor.y > roomBelow ? "above" /* Above */ : "below" /* Below */;
2761
- }
2762
- function dropdownFrame(anchor, panelHeight, viewportHeight) {
2763
- const placement = placeDropdown(anchor, panelHeight, viewportHeight);
2764
- const base = { placement, left: anchor.x, width: anchor.width };
2765
- if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - anchor.y };
2766
- return { ...base, top: anchor.y + anchor.height };
2767
- }
2768
- function fitDropdownWidth(frame, viewportWidth) {
2769
- const width = Math.max(frame.width, Math.min(MIN_PANEL_WIDTH, viewportWidth - EDGE - EDGE));
2770
- const left = Math.max(EDGE, Math.min(frame.left, viewportWidth - width - EDGE));
2771
- return { ...frame, width, left: frame.width >= width ? frame.left : left };
2772
- }
2773
- function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children }) {
2774
- const { height: viewportHeight, width: viewportWidth } = reactNative.useWindowDimensions();
2775
- const anchor = useAnchorRect2(anchorRef);
2776
- const [panelHeight, setPanelHeight] = React2.useState(0);
2777
- const onLayout = React2.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
2778
- const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight), viewportWidth);
2779
- const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
2780
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: [
2781
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
2782
- frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles21.dropdown, place, { opacity: progress, transform: [{ translateY }] }], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
2783
- ] });
2784
- }
2785
- var styles21 = reactNative.StyleSheet.create({
2786
- dropdown: { position: "absolute" }
2787
- });
2788
3704
  var ROW_PAD_H = 12;
2789
3705
  var ROW_GAP4 = 8;
2790
3706
  var OPTION_FONT2 = 14;
@@ -2802,21 +3718,21 @@ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPi
2802
3718
  accessibilityLabel: option.label,
2803
3719
  accessibilityRole: "button",
2804
3720
  accessibilityState: { selected: active, checked: current },
2805
- style: [styles22.row, active ? { backgroundColor: colors.surface } : null],
3721
+ style: [styles23.row, active ? { backgroundColor: colors.surface } : null],
2806
3722
  testID: `${testID}-option-${option.value}`,
2807
3723
  onPress: () => onPick(option),
2808
3724
  children: [
2809
3725
  renderLeading?.(option),
2810
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles22.label, children: [
2811
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.primary, { color: colors.text }], children: option.label }),
2812
- detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.secondary, { color: colors.textSecondary }], children: option.detail }) : null
3726
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles23.label, children: [
3727
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles23.primary, { color: colors.text }], children: option.label }),
3728
+ detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles23.secondary, { color: colors.textSecondary }], children: option.detail }) : null
2813
3729
  ] }),
2814
3730
  renderDetail?.(option)
2815
3731
  ]
2816
3732
  }
2817
3733
  );
2818
3734
  }
2819
- var styles22 = reactNative.StyleSheet.create({
3735
+ var styles23 = reactNative.StyleSheet.create({
2820
3736
  row: { minHeight: a11y.MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
2821
3737
  label: { flex: 1 },
2822
3738
  primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
@@ -2830,46 +3746,37 @@ function OptionSection({ title, options, offset, highlight, selectedValue, ...ro
2830
3746
  const { colors } = theme;
2831
3747
  if (options.length === 0) return null;
2832
3748
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
2833
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles23.header, { color: colors.textSecondary }], children: title }),
3749
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles24.header, { color: colors.textSecondary }], children: title }),
2834
3750
  options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
2835
3751
  ] });
2836
3752
  }
2837
- var styles23 = reactNative.StyleSheet.create({
2838
- header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
2839
- });
2840
- function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children }) {
2841
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles24.backdrop, children: [
2842
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
2843
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ translateY }] }, children })
2844
- ] }) });
2845
- }
2846
3753
  var styles24 = reactNative.StyleSheet.create({
2847
- backdrop: { flex: 1, justifyContent: "flex-end" }
3754
+ header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
2848
3755
  });
2849
3756
  var KEY_ESCAPE = "Escape";
2850
3757
  var PANEL_PAD = 8;
2851
3758
  var PANEL_RADIUS = 8;
2852
- var SHEET_MAX_HEIGHT = 480;
3759
+ var SHEET_MAX_HEIGHT2 = 480;
2853
3760
  function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
2854
3761
  const { theme } = uiFeedback.useUi();
2855
3762
  const { colors } = theme;
2856
- const progress = React2.useRef(new reactNative.Animated.Value(0)).current;
3763
+ const progress = React37.useRef(new reactNative.Animated.Value(0)).current;
2857
3764
  const { durationMs } = motion;
2858
- React2.useEffect(() => {
3765
+ React37.useEffect(() => {
2859
3766
  reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
2860
3767
  }, [progress, durationMs]);
2861
- const leaving = React2.useRef(false);
2862
- const leave = React2.useCallback((after) => {
3768
+ const leaving = React37.useRef(false);
3769
+ const leave = React37.useCallback((after) => {
2863
3770
  if (leaving.current) return;
2864
3771
  leaving.current = true;
2865
3772
  if (durationMs === 0) return after();
2866
3773
  reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
2867
3774
  }, [progress, durationMs]);
2868
3775
  const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
2869
- const dismiss = React2.useCallback(() => leave(close), [leave, close]);
2870
- const pick = React2.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
2871
- const submit = React2.useCallback(() => submitNow(pick), [submitNow, pick]);
2872
- const onKeyPress = React2.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
3776
+ const dismiss = React37.useCallback(() => leave(close), [leave, close]);
3777
+ const pick = React37.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
3778
+ const submit = React37.useCallback(() => submitNow(pick), [submitNow, pick]);
3779
+ const onKeyPress = React37.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
2873
3780
  const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
2874
3781
  const isSheet = motion.surface === "sheet" /* Sheet */;
2875
3782
  const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
@@ -2902,27 +3809,12 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
2902
3809
  var styles25 = reactNative.StyleSheet.create({
2903
3810
  panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
2904
3811
  dropList: { maxHeight: MENU_MAX_HEIGHT },
2905
- sheetList: { maxHeight: SHEET_MAX_HEIGHT },
3812
+ sheetList: { maxHeight: SHEET_MAX_HEIGHT2 },
2906
3813
  empty: { padding: PANEL_PAD }
2907
3814
  });
2908
- function useReducedMotion() {
2909
- const [reduced, setReduced] = React2.useState(false);
2910
- React2.useEffect(() => {
2911
- let active = true;
2912
- reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
2913
- if (active) setReduced(value);
2914
- }).catch(() => void 0);
2915
- const subscription = reactNative.AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
2916
- return () => {
2917
- active = false;
2918
- subscription.remove();
2919
- };
2920
- }, []);
2921
- return reduced;
2922
- }
2923
3815
  function useRefocusOnClose(open, ref) {
2924
- const wasOpen = React2.useRef(false);
2925
- React2.useEffect(() => {
3816
+ const wasOpen = React37.useRef(false);
3817
+ React37.useEffect(() => {
2926
3818
  if (wasOpen.current && !open) ref.current?.focus();
2927
3819
  wasOpen.current = open;
2928
3820
  }, [open, ref]);
@@ -2955,38 +3847,38 @@ var KEY_DOWN = "ArrowDown";
2955
3847
  var KEY_UP = "ArrowUp";
2956
3848
  var KEY_ESCAPE2 = "Escape";
2957
3849
  function useSearchSelectState(options, recents, onChange, onClosed) {
2958
- const [open, setOpen] = React2.useState(false);
2959
- const [query, setQueryState] = React2.useState("");
2960
- const [rawHighlight, setHighlight] = React2.useState(-1);
2961
- const sections = React2.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
3850
+ const [open, setOpen] = React37.useState(false);
3851
+ const [query, setQueryState] = React37.useState("");
3852
+ const [rawHighlight, setHighlight] = React37.useState(-1);
3853
+ const sections = React37.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
2962
3854
  const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
2963
3855
  const active = sections.flat[highlight];
2964
3856
  const { remember } = recents;
2965
- const close = React2.useCallback(() => {
3857
+ const close = React37.useCallback(() => {
2966
3858
  setOpen(false);
2967
3859
  setQueryState("");
2968
3860
  setHighlight(-1);
2969
3861
  onClosed();
2970
3862
  }, [onClosed]);
2971
- const pick = React2.useCallback((option) => {
3863
+ const pick = React37.useCallback((option) => {
2972
3864
  remember(option.value);
2973
3865
  onChange(option.value);
2974
3866
  close();
2975
3867
  }, [remember, onChange, close]);
2976
- const submit = React2.useCallback((via = pick) => {
3868
+ const submit = React37.useCallback((via = pick) => {
2977
3869
  if (active !== void 0) via(active);
2978
3870
  }, [active, pick]);
2979
- const setQuery = React2.useCallback((next) => {
3871
+ const setQuery = React37.useCallback((next) => {
2980
3872
  setQueryState(next);
2981
3873
  setHighlight(highlightAfterQuery(next));
2982
3874
  }, []);
2983
- const onKey = React2.useCallback((key) => {
3875
+ const onKey = React37.useCallback((key) => {
2984
3876
  const count = sections.flat.length;
2985
3877
  if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
2986
3878
  if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
2987
3879
  if (key === KEY_ESCAPE2) close();
2988
3880
  }, [sections.flat.length, highlight, close]);
2989
- const openList = React2.useCallback(() => setOpen(true), []);
3881
+ const openList = React37.useCallback(() => setOpen(true), []);
2990
3882
  return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
2991
3883
  }
2992
3884
 
@@ -3010,8 +3902,8 @@ function SearchSelect(props) {
3010
3902
  const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail, renderTrigger, onBlur } = props;
3011
3903
  const { theme } = uiFeedback.useUi();
3012
3904
  const { colors } = theme;
3013
- const triggerRef = React2.useRef(null);
3014
- const anchorRef = React2.useRef(null);
3905
+ const triggerRef = React37.useRef(null);
3906
+ const anchorRef = React37.useRef(null);
3015
3907
  const { width } = reactNative.useWindowDimensions();
3016
3908
  const motion = resolveSelectMotion(width, useReducedMotion());
3017
3909
  const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
@@ -3019,9 +3911,9 @@ function SearchSelect(props) {
3019
3911
  useRefocusOnClose(state.open, triggerRef);
3020
3912
  const selected = findOption(options, value);
3021
3913
  const onPress = state.open ? state.close : state.openList;
3022
- const openRef = React2.useRef(state.open);
3914
+ const openRef = React37.useRef(state.open);
3023
3915
  openRef.current = state.open;
3024
- const onTriggerBlur = React2.useCallback(() => {
3916
+ const onTriggerBlur = React37.useCallback(() => {
3025
3917
  if (!openRef.current) onBlur?.();
3026
3918
  }, [onBlur]);
3027
3919
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles26.anchor, children: [
@@ -3071,7 +3963,7 @@ function isOutside(container, target) {
3071
3963
  return !(target instanceof Node && container.contains(target));
3072
3964
  }
3073
3965
  function useOutsidePress(ref, onOutside) {
3074
- React2.useEffect(() => {
3966
+ React37.useEffect(() => {
3075
3967
  if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
3076
3968
  const onPointerDown = (event) => {
3077
3969
  if (isOutside(ref.current, event.target)) onOutside();
@@ -3082,7 +3974,7 @@ function useOutsidePress(ref, onOutside) {
3082
3974
  }
3083
3975
  var AFTER_SURFACE_UNMOUNT_MS = 0;
3084
3976
  function useDeferredFocus(ref) {
3085
- return React2.useCallback(() => {
3977
+ return React37.useCallback(() => {
3086
3978
  setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
3087
3979
  }, [ref]);
3088
3980
  }
@@ -3834,8 +4726,8 @@ var renderFlag = (option) => option.value === NO_COUNTRY2 ? null : /* @__PURE__
3834
4726
  function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries, noneLabel, onBlur }) {
3835
4727
  const { theme } = uiFeedback.useUi();
3836
4728
  const { textSecondary } = theme.colors;
3837
- const options = React2.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
3838
- const renderCode = React2.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles27.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
4729
+ const options = React37.useMemo(() => countryFieldOptions(countries, noneLabel), [countries, noneLabel]);
4730
+ const renderCode = React37.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles27.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
3839
4731
  return /* @__PURE__ */ jsxRuntime.jsx(
3840
4732
  SearchSelect,
3841
4733
  {
@@ -3857,9 +4749,9 @@ var styles27 = reactNative.StyleSheet.create({
3857
4749
  code: { fontSize: CODE_FONT }
3858
4750
  });
3859
4751
  function useBlurVerdict(validate) {
3860
- const [verdict, setVerdict] = React2.useState(null);
3861
- const onEdit = React2.useCallback(() => setVerdict(null), []);
3862
- const onLeave = React2.useCallback(() => {
4752
+ const [verdict, setVerdict] = React37.useState(null);
4753
+ const onEdit = React37.useCallback(() => setVerdict(null), []);
4754
+ const onLeave = React37.useCallback(() => {
3863
4755
  const next = validate();
3864
4756
  setVerdict(next);
3865
4757
  return next;
@@ -4013,11 +4905,11 @@ function rawCaretAfterChange(previous, previousCaret, next) {
4013
4905
 
4014
4906
  // src/IbanInput/hooks/useIbanCaret.ts
4015
4907
  function useIbanCaret(display) {
4016
- const [selection, setSelection] = React2.useState({ start: display.length, end: display.length });
4017
- const onSelectionChange = React2.useCallback((event) => {
4908
+ const [selection, setSelection] = React37.useState({ start: display.length, end: display.length });
4909
+ const onSelectionChange = React37.useCallback((event) => {
4018
4910
  setSelection(event.nativeEvent.selection);
4019
4911
  }, []);
4020
- const placeAfterEdit = React2.useCallback((text) => {
4912
+ const placeAfterEdit = React37.useCallback((text) => {
4021
4913
  const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection.end, text));
4022
4914
  setSelection({ start: caret, end: caret });
4023
4915
  }, [display, selection.end]);
@@ -4028,7 +4920,7 @@ var FONT_SIZE = 14;
4028
4920
  var LINE_HEIGHT = 20;
4029
4921
  var COUNTER_FONT = 12;
4030
4922
  var BRANCH_OPACITY = 0.5;
4031
- var GAP2 = 8;
4923
+ var GAP7 = 8;
4032
4924
  var INPUT_PAD_V2 = 13;
4033
4925
  var ghostStyles = reactNative.StyleSheet.create({
4034
4926
  field: { flex: 1, justifyContent: "center", minHeight: LINE_HEIGHT },
@@ -4038,7 +4930,7 @@ var ghostStyles = reactNative.StyleSheet.create({
4038
4930
  branch: { opacity: BRANCH_OPACITY },
4039
4931
  input: { padding: 0, paddingVertical: INPUT_PAD_V2, borderWidth: 0, minHeight: LINE_HEIGHT },
4040
4932
  trigger: { paddingVertical: 0 },
4041
- counter: { fontSize: COUNTER_FONT, marginLeft: GAP2 }
4933
+ counter: { fontSize: COUNTER_FONT, marginLeft: GAP7 }
4042
4934
  });
4043
4935
 
4044
4936
  // src/IbanInput/data/IbanRejection.ts
@@ -4123,19 +5015,19 @@ function rejectionMessage(rejection, none, labels) {
4123
5015
  function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
4124
5016
  const { theme } = uiFeedback.useUi();
4125
5017
  const { colors } = theme;
4126
- const draft = React2.useMemo(() => draftIban(value), [value]);
4127
- const validate = React2.useCallback(() => validateIban(value), [value]);
5018
+ const draft = React37.useMemo(() => draftIban(value), [value]);
5019
+ const validate = React37.useCallback(() => validateIban(value), [value]);
4128
5020
  const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
4129
5021
  const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
4130
5022
  const counter = ibanCounter(draft);
4131
5023
  const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
4132
- const onChangeText = React2.useCallback((text) => {
5024
+ const onChangeText = React37.useCallback((text) => {
4133
5025
  onEdit();
4134
5026
  onVerdict?.(null);
4135
5027
  placeAfterEdit(text);
4136
5028
  onChange(draftIban(text).electronic);
4137
5029
  }, [onEdit, onVerdict, placeAfterEdit, onChange]);
4138
- const onBlur = React2.useCallback(() => {
5030
+ const onBlur = React37.useCallback(() => {
4139
5031
  const verdict2 = onLeave();
4140
5032
  onVerdict?.(value === "" ? null : verdict2);
4141
5033
  onLeft?.();
@@ -4210,16 +5102,16 @@ function validateBic(raw) {
4210
5102
  function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder, onBlur: onLeft }) {
4211
5103
  const { theme } = uiFeedback.useUi();
4212
5104
  const { colors } = theme;
4213
- const draft = React2.useMemo(() => draftBic(value), [value]);
4214
- const validate = React2.useCallback(() => validateBic(value), [value]);
5105
+ const draft = React37.useMemo(() => draftBic(value), [value]);
5106
+ const validate = React37.useCallback(() => validateBic(value), [value]);
4215
5107
  const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
4216
5108
  const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
4217
- const onChangeText = React2.useCallback((text) => {
5109
+ const onChangeText = React37.useCallback((text) => {
4218
5110
  onEdit();
4219
5111
  onVerdict?.(null);
4220
5112
  onChange(draftBic(text).value);
4221
5113
  }, [onEdit, onVerdict, onChange]);
4222
- const onBlur = React2.useCallback(() => {
5114
+ const onBlur = React37.useCallback(() => {
4223
5115
  const verdict2 = onLeave();
4224
5116
  onVerdict?.(value === "" ? null : verdict2);
4225
5117
  onLeft?.();
@@ -4253,7 +5145,344 @@ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilit
4253
5145
  /* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
4254
5146
  ] });
4255
5147
  }
5148
+ var BAR_GAP = 8;
5149
+ var PAD_V = 10;
5150
+ var PAD_H = 16;
5151
+ var TEXT_SIZE2 = 13;
5152
+ var TEXT_LINE2 = 18;
5153
+ var styles29 = reactNative.StyleSheet.create({
5154
+ bar: { borderTopWidth: 1, paddingHorizontal: PAD_H, paddingVertical: PAD_V, rowGap: BAR_GAP },
5155
+ actions: { flexDirection: "row", flexWrap: "wrap", gap: BAR_GAP },
5156
+ message: { fontSize: TEXT_SIZE2, fontWeight: "700", lineHeight: TEXT_LINE2 }
5157
+ });
5158
+ var PINNED = { position: "sticky", bottom: 0, zIndex: 1 };
5159
+ var actionBarPosition = (sticky, os) => sticky && os === "web" ? "sticky" : "relative";
5160
+ var ActionBar = ({ children, message, sticky = false, testID, style }) => {
5161
+ const { theme } = uiFeedback.useUi();
5162
+ const { colors } = theme;
5163
+ const pinned = actionBarPosition(sticky, reactNative.Platform.OS) === "sticky" ? PINNED : null;
5164
+ const hasMessage = message !== void 0 && message !== "";
5165
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles29.bar, { backgroundColor: colors.surface, borderTopColor: colors.border }, pinned, style], testID, children: [
5166
+ hasMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "status", style: [styles29.message, { color: colors.text }], testID: `${testID}-message`, children: message }) : null,
5167
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles29.actions, children })
5168
+ ] });
5169
+ };
5170
+
5171
+ // src/GatedChecklist/isChecklistComplete.ts
5172
+ var isChecklistComplete = (items, checked) => items.every((item) => checked.includes(item.id));
5173
+ var TITLE_SIZE = 13;
5174
+ var TITLE_GAP = 6;
5175
+ var styles30 = reactNative.StyleSheet.create({
5176
+ title: { fontSize: TITLE_SIZE, fontWeight: "700", marginBottom: TITLE_GAP }
5177
+ });
5178
+ var GatedChecklist = ({ title, items, checked, onToggle, testID, disabled = false, children }) => {
5179
+ const { theme } = uiFeedback.useUi();
5180
+ const complete = isChecklistComplete(items, checked);
5181
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { testID, children: [
5182
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles30.title, { color: theme.colors.text }], children: title }),
5183
+ items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
5184
+ FormCheckbox,
5185
+ {
5186
+ description: item.description,
5187
+ disabled,
5188
+ label: item.label,
5189
+ testID: `${testID}-item-${item.id}`,
5190
+ value: checked.includes(item.id),
5191
+ onValueChange: () => onToggle(item.id)
5192
+ },
5193
+ item.id
5194
+ )),
5195
+ children?.(complete)
5196
+ ] });
5197
+ };
5198
+ var MIN_TARGET_PX2 = 44;
5199
+ var DOT_SIZE = 18;
5200
+ var DOT_INNER = 8;
5201
+ var ROW_GAP6 = 10;
5202
+ var PAD_H2 = 12;
5203
+ var PAD_V2 = 8;
5204
+ var RADIUS2 = 8;
5205
+ var LABEL_SIZE = 14;
5206
+ var DESCRIPTION_SIZE = 12;
5207
+ var DESCRIPTION_LINE = 16;
5208
+ var styles31 = reactNative.StyleSheet.create({
5209
+ row: {
5210
+ alignItems: "center",
5211
+ borderRadius: RADIUS2,
5212
+ borderWidth: 1,
5213
+ columnGap: ROW_GAP6,
5214
+ flexDirection: "row",
5215
+ minHeight: MIN_TARGET_PX2,
5216
+ paddingHorizontal: PAD_H2,
5217
+ paddingVertical: PAD_V2
5218
+ },
5219
+ dot: { alignItems: "center", borderRadius: DOT_SIZE / 2, borderWidth: 2, height: DOT_SIZE, justifyContent: "center", width: DOT_SIZE },
5220
+ dotInner: { borderRadius: DOT_INNER / 2, height: DOT_INNER, width: DOT_INNER },
5221
+ text: { flex: 1, flexShrink: 1 },
5222
+ label: { fontSize: LABEL_SIZE, fontWeight: "600" },
5223
+ description: { fontSize: DESCRIPTION_SIZE, lineHeight: DESCRIPTION_LINE }
5224
+ });
5225
+ function RadioRow({ option, identity, colors, tabIndex, hostRef, onPress }) {
5226
+ const { checked, disabled } = identity.accessibilityState;
5227
+ const accent = checked ? colors.primary : colors.border;
5228
+ const hasDescription = option.description !== void 0 && option.description !== "";
5229
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5230
+ reactNative.Pressable,
5231
+ {
5232
+ ref: hostRef,
5233
+ accessibilityHint: option.hint,
5234
+ accessibilityLabel: identity.accessibilityLabel,
5235
+ accessibilityRole: "radio",
5236
+ accessibilityState: identity.accessibilityState,
5237
+ "aria-checked": checked,
5238
+ disabled,
5239
+ style: [styles31.row, { borderColor: accent, backgroundColor: checked ? colors.tint : colors.muted }],
5240
+ tabIndex,
5241
+ testID: identity.testID,
5242
+ onPress,
5243
+ children: [
5244
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles31.dot, { borderColor: accent }], children: checked ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles31.dotInner, { backgroundColor: colors.primary }] }) : null }),
5245
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles31.text, children: [
5246
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.label, { color: checked ? colors.primary : colors.textStrong }], children: option.label }),
5247
+ hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles31.description, { color: colors.textMuted }], testID: `${identity.testID}-description`, children: option.description }) : null
5248
+ ] })
5249
+ ]
5250
+ }
5251
+ );
5252
+ }
5253
+
5254
+ // src/RadioList/utils/radioRowIdentity.ts
5255
+ var radioRowIdentity = (option, selected, disabled, prefix) => {
5256
+ const hasDescription = option.description !== void 0 && option.description !== "";
5257
+ return {
5258
+ testID: `${prefix}-${String(option.value)}`,
5259
+ accessibilityLabel: hasDescription ? `${option.label}, ${String(option.description)}` : option.label,
5260
+ accessibilityState: { checked: selected, selected, disabled }
5261
+ };
5262
+ };
5263
+ var ROW_GAP7 = 8;
5264
+ var styles32 = reactNative.StyleSheet.create({
5265
+ list: { rowGap: ROW_GAP7 }
5266
+ });
5267
+ function RadioList(props) {
5268
+ const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
5269
+ const { theme } = uiFeedback.useUi();
5270
+ const colors = React37__default.default.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
5271
+ const selectedIndex = options.findIndex((option) => option.value === value);
5272
+ const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
5273
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsxRuntime.jsx(
5274
+ reactNative.View,
5275
+ {
5276
+ accessibilityRole: "radiogroup",
5277
+ style: styles32.list,
5278
+ ...webFieldA11y({ describedById, hasError }),
5279
+ ...radio.groupProps,
5280
+ children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
5281
+ RadioRow,
5282
+ {
5283
+ colors,
5284
+ hostRef: radio.chipRef(index),
5285
+ identity: radioRowIdentity(option, index === selectedIndex, disabled, optionTestIDPrefix),
5286
+ option,
5287
+ tabIndex: radio.tabIndexFor(index),
5288
+ onPress: () => onChange(option.value)
5289
+ },
5290
+ String(option.value)
5291
+ ))
5292
+ }
5293
+ ) });
5294
+ }
5295
+
5296
+ // src/DecisionPanel/utils/decisionRules.ts
5297
+ var validateDecision = (outcomes, outcome, note) => {
5298
+ const chosen = outcomes.find((item) => item.value === outcome);
5299
+ if (chosen === void 0) return "choose";
5300
+ const noteMissing = chosen.noteRequired === true && note.trim() === "";
5301
+ return noteMissing ? "note" : null;
5302
+ };
5303
+ var defaultDecisionVariant = (width) => isWideFormLayout(width) ? "sticky-bar" : "choose-then-submit";
5304
+ var leadFirst = (outcomes, lead) => [
5305
+ ...outcomes.filter((item) => item.value === lead),
5306
+ ...outcomes.filter((item) => item.value !== lead)
5307
+ ];
5308
+ var toneVariant = (tone) => {
5309
+ if (tone === "primary") return "primary";
5310
+ return tone === "danger" ? "danger" : "secondary";
5311
+ };
5312
+ var NOTE_LINES = 3;
5313
+ function DecisionNote({ state, labels, testID, disabled }) {
5314
+ const error = state.error === "note" ? labels.noteRequiredError : void 0;
5315
+ return /* @__PURE__ */ jsxRuntime.jsx(
5316
+ FormField,
5317
+ {
5318
+ multiline: true,
5319
+ editable: !disabled,
5320
+ error,
5321
+ label: labels.note,
5322
+ numberOfLines: NOTE_LINES,
5323
+ placeholder: labels.notePlaceholder,
5324
+ testID: `${testID}-note`,
5325
+ value: state.note,
5326
+ onChangeText: state.setNote
5327
+ }
5328
+ );
5329
+ }
5330
+ var BUTTON_BASIS = "40%";
5331
+ var styles33 = reactNative.StyleSheet.create({
5332
+ cell: { flexBasis: BUTTON_BASIS, flexGrow: 1 }
5333
+ });
5334
+ function OutcomeButtons({ outcomes, pending, disabled, testID, onPress }) {
5335
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: outcomes.map((item) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles33.cell, children: /* @__PURE__ */ jsxRuntime.jsx(
5336
+ uiButtons.Button,
5337
+ {
5338
+ fullWidth: true,
5339
+ accessibilityHint: item.hint,
5340
+ accessibilityLabel: item.label,
5341
+ disabled: disabled || pending !== null && pending !== item.value,
5342
+ label: item.label,
5343
+ loading: pending === item.value,
5344
+ testID: `${testID}-action-${item.value}`,
5345
+ variant: toneVariant(item.tone),
5346
+ onPress: () => onPress(item.value)
5347
+ }
5348
+ ) }, item.value)) });
5349
+ }
5350
+ var retone = (item, lead) => {
5351
+ if (item.value === lead) return { ...item, tone: "primary" };
5352
+ return item.tone === "primary" ? { ...item, tone: "neutral" } : item;
5353
+ };
5354
+ function ChecksDriveDecision(props) {
5355
+ const { state, outcomes, labels, testID, disabled, reasons = [], leadOutcome } = props;
5356
+ const ordered = leadFirst(outcomes, leadOutcome).map((item) => retone(item, leadOutcome));
5357
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5358
+ reasons.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
5359
+ ChipSelector,
5360
+ {
5361
+ multiple: true,
5362
+ chipTestIDPrefix: `${testID}-reason`,
5363
+ disabled,
5364
+ label: labels.reasons,
5365
+ options: reasons,
5366
+ testID: `${testID}-reasons`,
5367
+ value: state.reasons,
5368
+ variant: "outline",
5369
+ onChange: state.toggleReason
5370
+ }
5371
+ ) : null,
5372
+ /* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
5373
+ /* @__PURE__ */ jsxRuntime.jsx(ActionBar, { message: labels.message, testID: `${testID}-bar`, children: /* @__PURE__ */ jsxRuntime.jsx(OutcomeButtons, { disabled, outcomes: ordered, pending: state.pending, testID, onPress: state.submit }) })
5374
+ ] });
5375
+ }
5376
+ function ChooseThenSubmitDecision(props) {
5377
+ const { state, outcomes, labels, testID, disabled } = props;
5378
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5379
+ /* @__PURE__ */ jsxRuntime.jsx(
5380
+ RadioList,
5381
+ {
5382
+ disabled,
5383
+ error: state.error === "choose" ? labels.chooseError : void 0,
5384
+ optionTestIDPrefix: `${testID}-outcome`,
5385
+ options: outcomes,
5386
+ testID: `${testID}-outcomes`,
5387
+ value: state.outcome === "" ? void 0 : state.outcome,
5388
+ onChange: state.choose
5389
+ }
5390
+ ),
5391
+ /* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
5392
+ /* @__PURE__ */ jsxRuntime.jsx(
5393
+ uiButtons.Button,
5394
+ {
5395
+ fullWidth: true,
5396
+ accessibilityHint: labels.submitHint,
5397
+ accessibilityLabel: labels.submit,
5398
+ disabled,
5399
+ label: labels.submit,
5400
+ loading: state.pending !== null,
5401
+ testID: `${testID}-submit`,
5402
+ onPress: () => state.submit()
5403
+ }
5404
+ )
5405
+ ] });
5406
+ }
5407
+ function StickyBarDecision(props) {
5408
+ const { state, outcomes, labels, testID, disabled } = props;
5409
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5410
+ /* @__PURE__ */ jsxRuntime.jsx(DecisionNote, { ...props }),
5411
+ /* @__PURE__ */ jsxRuntime.jsx(ActionBar, { sticky: true, message: labels.message, testID: `${testID}-bar`, children: /* @__PURE__ */ jsxRuntime.jsx(OutcomeButtons, { disabled, outcomes, pending: state.pending, testID, onPress: state.submit }) })
5412
+ ] });
5413
+ }
5414
+ var TEXT_SIZE3 = 13;
5415
+ var TEXT_LINE3 = 18;
5416
+ var styles34 = reactNative.StyleSheet.create({
5417
+ text: { fontSize: TEXT_SIZE3, fontWeight: "700", lineHeight: TEXT_LINE3 }
5418
+ });
5419
+ var SubmitError = ({ message, testID }) => {
5420
+ const { theme } = uiFeedback.useUi();
5421
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { role: "alert", style: [styles34.text, { color: fieldErrorInk(theme) }], testID, children: message });
5422
+ };
5423
+ var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
5424
+ function useDecisionPanel(outcomes, onSubmit) {
5425
+ const [outcome, setOutcome] = React37__default.default.useState("");
5426
+ const [note, setNote] = React37__default.default.useState("");
5427
+ const [reasons, setReasons] = React37__default.default.useState([]);
5428
+ const [checked, setChecked] = React37__default.default.useState([]);
5429
+ const [error, setError] = React37__default.default.useState(null);
5430
+ const [pending, setPending] = React37__default.default.useState(null);
5431
+ const submit = async (override) => {
5432
+ const target = override ?? outcome;
5433
+ const problem = validateDecision(outcomes, target, note);
5434
+ setError(problem);
5435
+ if (problem !== null || target === "") return;
5436
+ setPending(target);
5437
+ try {
5438
+ await onSubmit({ outcome: target, note, reasons });
5439
+ } catch {
5440
+ setError("submit");
5441
+ } finally {
5442
+ setPending(null);
5443
+ }
5444
+ };
5445
+ return {
5446
+ outcome,
5447
+ note,
5448
+ reasons,
5449
+ checked,
5450
+ error,
5451
+ pending,
5452
+ choose: (next) => {
5453
+ setOutcome(next);
5454
+ setError(null);
5455
+ },
5456
+ setNote,
5457
+ toggleReason: (reason) => setReasons((list) => toggle(list, reason)),
5458
+ toggleCheck: (id) => setChecked((list) => toggle(list, id)),
5459
+ submit
5460
+ };
5461
+ }
5462
+ var TITLE_SIZE2 = 15;
5463
+ var PANEL_GAP = 12;
5464
+ var styles35 = reactNative.StyleSheet.create({
5465
+ panel: { rowGap: PANEL_GAP },
5466
+ title: { fontSize: TITLE_SIZE2, fontWeight: "700" }
5467
+ });
5468
+ function renderVariant(variant, props) {
5469
+ if (variant === "sticky-bar") return /* @__PURE__ */ jsxRuntime.jsx(StickyBarDecision, { ...props });
5470
+ if (variant === "checks-drive") return /* @__PURE__ */ jsxRuntime.jsx(ChecksDriveDecision, { ...props });
5471
+ return /* @__PURE__ */ jsxRuntime.jsx(ChooseThenSubmitDecision, { ...props });
5472
+ }
5473
+ function DecisionPanel(props) {
5474
+ const { variant, outcomes, onSubmit, labels, testID, reasons, leadOutcome, checklist, disabled = false, style } = props;
5475
+ const { theme } = uiFeedback.useUi();
5476
+ const state = useDecisionPanel(outcomes, onSubmit);
5477
+ const body = (locked) => renderVariant(variant, { state, outcomes, labels, testID, disabled: disabled || locked, reasons, leadOutcome });
5478
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles35.panel, style], testID, children: [
5479
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles35.title, { color: theme.colors.text }], children: labels.title }),
5480
+ checklist !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(GatedChecklist, { checked: state.checked, items: checklist.items, testID: `${testID}-checklist`, title: checklist.title, onToggle: state.toggleCheck, children: (complete) => body(!complete) }) : body(false),
5481
+ state.error === "submit" ? /* @__PURE__ */ jsxRuntime.jsx(SubmitError, { message: labels.submitError, testID: `${testID}-error` }) : null
5482
+ ] });
5483
+ }
4256
5484
 
5485
+ exports.ActionBar = ActionBar;
4257
5486
  exports.AddOnRequest = AddOnRequest;
4258
5487
  exports.AlignToControl = AlignToControl;
4259
5488
  exports.AnchoredMenu = AnchoredMenu;
@@ -4264,14 +5493,17 @@ exports.ChipLabelWrap = ChipLabelWrap;
4264
5493
  exports.ChipSelector = ChipSelector;
4265
5494
  exports.CountryField = CountryField;
4266
5495
  exports.CountryFlag = CountryFlag;
5496
+ exports.DEFAULT_DATE_PICKER_LABELS = DEFAULT_DATE_PICKER_LABELS;
4267
5497
  exports.DEFAULT_MAX_RECENTS = DEFAULT_MAX_RECENTS;
4268
5498
  exports.DEFAULT_OPTIONAL_LABEL = DEFAULT_OPTIONAL_LABEL;
4269
5499
  exports.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
4270
5500
  exports.DEFAULT_TYPEAHEAD_MIN_CHARS = DEFAULT_TYPEAHEAD_MIN_CHARS;
4271
5501
  exports.DateField = DateField;
4272
5502
  exports.DateInput = DateInput;
5503
+ exports.DatePickerProvider = DatePickerProvider;
4273
5504
  exports.DateRangeControl = DateRangeControl;
4274
5505
  exports.DateTimeField = DateTimeField;
5506
+ exports.DecisionPanel = DecisionPanel;
4275
5507
  exports.DropdownPlacement = DropdownPlacement;
4276
5508
  exports.FLAG_HEIGHT = FLAG_HEIGHT;
4277
5509
  exports.FLAG_WIDTH = FLAG_WIDTH;
@@ -4287,6 +5519,7 @@ exports.FormSection = FormSection;
4287
5519
  exports.FormStack = FormStack;
4288
5520
  exports.FormStatusLine = FormStatusLine;
4289
5521
  exports.FormSwitch = FormSwitch;
5522
+ exports.GatedChecklist = GatedChecklist;
4290
5523
  exports.IBAN_MAX_LENGTH = IBAN_MAX_LENGTH;
4291
5524
  exports.IBAN_REGISTERED_COUNTRY_COUNT = IBAN_REGISTERED_COUNTRY_COUNT;
4292
5525
  exports.INLINE_FIELD_ROW_MIN_WIDTH = INLINE_FIELD_ROW_MIN_WIDTH;
@@ -4297,6 +5530,7 @@ exports.LINE_ITEMS_WIDE_MIN_WIDTH = LINE_ITEMS_WIDE_MIN_WIDTH;
4297
5530
  exports.LineItems = LineItems;
4298
5531
  exports.PHONE_MAX_WIDTH = PHONE_MAX_WIDTH;
4299
5532
  exports.RESPONSIVE_FORM_DEFAULT_BREAKPOINT = RESPONSIVE_FORM_DEFAULT_BREAKPOINT;
5533
+ exports.RadioList = RadioList;
4300
5534
  exports.ResponsiveFormLayout = ResponsiveFormLayout;
4301
5535
  exports.SearchSelect = SearchSelect;
4302
5536
  exports.SelectControl = SelectControl;
@@ -4307,12 +5541,14 @@ exports.StepperTabs = StepperTabs;
4307
5541
  exports.ThemedTextInput = ThemedTextInput;
4308
5542
  exports.TypeaheadControl = TypeaheadControl;
4309
5543
  exports.UploadWithLinkField = UploadWithLinkField;
5544
+ exports.actionBarPosition = actionBarPosition;
4310
5545
  exports.buildSearchSelectSections = buildSearchSelectSections;
4311
5546
  exports.canRemoveLine = canRemoveLine;
4312
5547
  exports.controlStyles = controlStyles;
4313
5548
  exports.countryFieldOptions = countryFieldOptions;
4314
5549
  exports.countryFlag = countryFlag;
4315
5550
  exports.countryOptions = countryOptions;
5551
+ exports.defaultDecisionVariant = defaultDecisionVariant;
4316
5552
  exports.draftBic = draftBic;
4317
5553
  exports.draftIban = draftIban;
4318
5554
  exports.dropdownFrame = dropdownFrame;
@@ -4326,17 +5562,20 @@ exports.ibanCounter = ibanCounter;
4326
5562
  exports.ibanLengthFor = ibanLengthFor;
4327
5563
  exports.inlineFieldRowLayout = inlineFieldRowLayout;
4328
5564
  exports.isAddOnOpen = isAddOnOpen;
5565
+ exports.isChecklistComplete = isChecklistComplete;
4329
5566
  exports.isFallbackFlag = isFallbackFlag;
4330
5567
  exports.isFixBarVisible = isFixBarVisible;
4331
5568
  exports.isLineItemsWide = isLineItemsWide;
4332
5569
  exports.isOutside = isOutside;
4333
5570
  exports.isUnmatched = isUnmatched;
4334
5571
  exports.isWideFormLayout = isWideFormLayout;
5572
+ exports.leadFirst = leadFirst;
4335
5573
  exports.lineItemColumnFlex = lineItemColumnFlex;
4336
5574
  exports.lineNumberOf = lineNumberOf;
4337
5575
  exports.moveHighlight = moveHighlight;
4338
5576
  exports.nextHighlight = nextHighlight;
4339
5577
  exports.placeDropdown = placeDropdown;
5578
+ exports.radioRowIdentity = radioRowIdentity;
4340
5579
  exports.rejectionMessage = rejectionMessage;
4341
5580
  exports.resolveGroupSelection = resolveGroupSelection;
4342
5581
  exports.resolveSelectMotion = resolveSelectMotion;
@@ -4354,6 +5593,7 @@ exports.useReducedMotion = useReducedMotion;
4354
5593
  exports.useSearchSelectState = useSearchSelectState;
4355
5594
  exports.useThemedInput = useThemedInput;
4356
5595
  exports.validateBic = validateBic;
5596
+ exports.validateDecision = validateDecision;
4357
5597
  exports.validateIban = validateIban;
4358
5598
  //# sourceMappingURL=index.js.map
4359
5599
  //# sourceMappingURL=index.js.map