@dloizides/ui-forms 1.41.0 → 1.42.1
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.d.mts +54 -6
- package/dist/index.d.ts +54 -6
- package/dist/index.js +1193 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1081 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Platform, StyleSheet, TextInput, View, Text, useWindowDimensions, ScrollView, Pressable, Switch,
|
|
1
|
+
import React37, { forwardRef, createContext, useState, useCallback, useMemo, useRef, useEffect, useLayoutEffect, useContext } from 'react';
|
|
2
|
+
import { Platform, StyleSheet, TextInput, View, Text, useWindowDimensions, ScrollView, Pressable, Switch, AccessibilityInfo, Image, Animated, TouchableOpacity, Modal } from 'react-native';
|
|
3
3
|
import { useUi } from '@dloizides/ui-feedback';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { Z_INDEX, focusRingOutline, readableScaleInk } from '@dloizides/design-tokens';
|
|
6
|
-
import { themeFocusRingColor, Button, useFocusRing } from '@dloizides/ui-buttons';
|
|
5
|
+
import { Z_INDEX, focusRingOutline, readableScaleInk, resolveOnBrand } from '@dloizides/design-tokens';
|
|
6
|
+
import { themeFocusRingColor, Button, useFocusRing, IconButton } from '@dloizides/ui-buttons';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
|
|
9
9
|
import Svg, { Rect, Circle, Polygon } from 'react-native-svg';
|
|
10
10
|
|
|
11
11
|
// src/Field/Field.tsx
|
|
12
12
|
function attachControlId(child, candidateId, describedById) {
|
|
13
|
-
if (!
|
|
13
|
+
if (!React37.isValidElement(child) || child.type === React37.Fragment) {
|
|
14
14
|
return { node: child };
|
|
15
15
|
}
|
|
16
16
|
const props = child.props;
|
|
@@ -21,7 +21,7 @@ function attachControlId(child, candidateId, describedById) {
|
|
|
21
21
|
if (describedById !== void 0 && props.describedById === void 0) {
|
|
22
22
|
injected.describedById = describedById;
|
|
23
23
|
}
|
|
24
|
-
return { node:
|
|
24
|
+
return { node: React37.cloneElement(element, injected), controlId };
|
|
25
25
|
}
|
|
26
26
|
var IS_WEB = Platform.OS === "web";
|
|
27
27
|
function isAttributeHost(node) {
|
|
@@ -131,15 +131,15 @@ var labelVariantStyles = StyleSheet.create({
|
|
|
131
131
|
function resolveLabelVariantStyle(variant) {
|
|
132
132
|
return variant === "control" ? labelVariantStyles.control : labelVariantStyles.field;
|
|
133
133
|
}
|
|
134
|
-
var FormGridContext =
|
|
135
|
-
var GapOwnedContext =
|
|
134
|
+
var FormGridContext = React37.createContext(null);
|
|
135
|
+
var GapOwnedContext = React37.createContext(false);
|
|
136
136
|
var FormGridProvider = FormGridContext.Provider;
|
|
137
137
|
var GapOwnedProvider = GapOwnedContext.Provider;
|
|
138
138
|
function useFormGridMetrics() {
|
|
139
|
-
return
|
|
139
|
+
return React37.useContext(FormGridContext);
|
|
140
140
|
}
|
|
141
141
|
function useIsGapOwned() {
|
|
142
|
-
return
|
|
142
|
+
return React37.useContext(GapOwnedContext);
|
|
143
143
|
}
|
|
144
144
|
var ERROR_LIGHT_STEPS = ["500", "600", "700"];
|
|
145
145
|
var ERROR_DARK_STEPS = ["300", "200", "400", "100", "500"];
|
|
@@ -162,7 +162,7 @@ var styles = StyleSheet.create({
|
|
|
162
162
|
});
|
|
163
163
|
var fieldSeq = 0;
|
|
164
164
|
function useFieldIds() {
|
|
165
|
-
const [ids] =
|
|
165
|
+
const [ids] = React37.useState(() => {
|
|
166
166
|
fieldSeq += 1;
|
|
167
167
|
const seq = String(fieldSeq);
|
|
168
168
|
return {
|
|
@@ -209,7 +209,7 @@ var Field = ({
|
|
|
209
209
|
const hasLabel = labelText !== "";
|
|
210
210
|
const marker = resolveFieldMarker(required, optional);
|
|
211
211
|
const { hintId, errorId, controlId, labelId } = useFieldIds();
|
|
212
|
-
const themeStyles =
|
|
212
|
+
const themeStyles = React37.useMemo(
|
|
213
213
|
() => ({
|
|
214
214
|
label: { color: colors.textSecondary },
|
|
215
215
|
requiredMark: { color: errorColor },
|
|
@@ -261,7 +261,7 @@ var FormGrid = ({
|
|
|
261
261
|
style,
|
|
262
262
|
testID
|
|
263
263
|
}) => {
|
|
264
|
-
const metrics =
|
|
264
|
+
const metrics = React37.useMemo(() => ({ minWidth, basis }), [minWidth, basis]);
|
|
265
265
|
return /* @__PURE__ */ jsx(FormGridProvider, { value: metrics, children: /* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsx(View, { style: [styles2.grid, { gap }, style], testID, children }) }) });
|
|
266
266
|
};
|
|
267
267
|
var LABEL_LINE_PLACEHOLDER = "\xA0";
|
|
@@ -528,7 +528,7 @@ var styles9 = StyleSheet.create({
|
|
|
528
528
|
});
|
|
529
529
|
var sectionSeq = 0;
|
|
530
530
|
function useSectionLegendId() {
|
|
531
|
-
const [id] =
|
|
531
|
+
const [id] = React37.useState(() => {
|
|
532
532
|
sectionSeq += 1;
|
|
533
533
|
return `form-section-legend-${String(sectionSeq)}`;
|
|
534
534
|
});
|
|
@@ -922,7 +922,7 @@ function AnchoredMenu({
|
|
|
922
922
|
listbox,
|
|
923
923
|
placement
|
|
924
924
|
}) {
|
|
925
|
-
const menuRef =
|
|
925
|
+
const menuRef = React37.useRef(null);
|
|
926
926
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
927
927
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
928
928
|
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
@@ -1082,7 +1082,7 @@ var boxStyles = StyleSheet.create({
|
|
|
1082
1082
|
textAlignVertical: "top"
|
|
1083
1083
|
}
|
|
1084
1084
|
});
|
|
1085
|
-
var ThemedTextInput =
|
|
1085
|
+
var ThemedTextInput = React37.forwardRef(function ThemedTextInput2({
|
|
1086
1086
|
hasError = false,
|
|
1087
1087
|
describedById,
|
|
1088
1088
|
requiredField = false,
|
|
@@ -1392,7 +1392,7 @@ function ChipContent({ icon, label, textStyle, numberOfLines }) {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
function OutlineChip(props) {
|
|
1394
1394
|
const { option, selected, disabled, colors, testID, accessibilityHint, onPress } = props;
|
|
1395
|
-
const [hovered, setHovered] =
|
|
1395
|
+
const [hovered, setHovered] = React37.useState(false);
|
|
1396
1396
|
const active = selected || hovered;
|
|
1397
1397
|
const borderColor = active ? colors.primary : colors.border;
|
|
1398
1398
|
const backgroundColor = selected ? colors.tint : colors.muted;
|
|
@@ -1492,8 +1492,8 @@ function radioTabIndex(index, selectedIndex, disabled) {
|
|
|
1492
1492
|
var NO_GROUP_PROPS = {};
|
|
1493
1493
|
function useRadioKeyboard(config) {
|
|
1494
1494
|
const { enabled, disabled, values, selectedIndex, onChange } = config;
|
|
1495
|
-
const nodes =
|
|
1496
|
-
const chipRef =
|
|
1495
|
+
const nodes = React37.useRef([]);
|
|
1496
|
+
const chipRef = React37.useCallback((index) => (node) => {
|
|
1497
1497
|
nodes.current[index] = node;
|
|
1498
1498
|
}, []);
|
|
1499
1499
|
const onKeyDown = (event) => {
|
|
@@ -1606,7 +1606,7 @@ var ChipSelector = ({
|
|
|
1606
1606
|
const isRadioGroup = !multiple && singleSelectRole === "radio";
|
|
1607
1607
|
const { theme } = useUi();
|
|
1608
1608
|
const { colors, palette } = theme;
|
|
1609
|
-
const chipColors =
|
|
1609
|
+
const chipColors = React37.useMemo(() => buildChipColors(colors, palette), [colors, palette]);
|
|
1610
1610
|
function isSelected(optionValue) {
|
|
1611
1611
|
if (multiple && Array.isArray(value))
|
|
1612
1612
|
return value.includes(optionValue);
|
|
@@ -1702,12 +1702,12 @@ var FormSwitch = ({
|
|
|
1702
1702
|
accessibilityHint
|
|
1703
1703
|
}) => {
|
|
1704
1704
|
const { theme } = useUi();
|
|
1705
|
-
const toggle2 =
|
|
1705
|
+
const toggle2 = React37.useCallback(() => {
|
|
1706
1706
|
if (!disabled) onValueChange(!value);
|
|
1707
1707
|
}, [disabled, onValueChange, value]);
|
|
1708
1708
|
const { colors } = theme;
|
|
1709
1709
|
const hasDescription = typeof description === "string" && description !== "";
|
|
1710
|
-
const themeStyles =
|
|
1710
|
+
const themeStyles = React37.useMemo(() => {
|
|
1711
1711
|
const labelStyle = { color: colors.text };
|
|
1712
1712
|
const descriptionStyle = { color: colors.textSecondary };
|
|
1713
1713
|
return { label: labelStyle, description: descriptionStyle };
|
|
@@ -1830,8 +1830,8 @@ var FormCheckbox = ({
|
|
|
1830
1830
|
const hintText = typeof hint === "string" && hint !== "" ? hint : description;
|
|
1831
1831
|
const hasHint = typeof hintText === "string" && hintText !== "";
|
|
1832
1832
|
const { hintId } = useFieldIds();
|
|
1833
|
-
const [focused, setFocused] =
|
|
1834
|
-
const themeStyles =
|
|
1833
|
+
const [focused, setFocused] = React37.useState(false);
|
|
1834
|
+
const themeStyles = React37.useMemo(() => {
|
|
1835
1835
|
const boxOn = checkboxBoxColors(colors, brand, true);
|
|
1836
1836
|
const boxOff = checkboxBoxColors(colors, brand, false);
|
|
1837
1837
|
const ring = { borderColor: brand };
|
|
@@ -2335,8 +2335,751 @@ function WebDateInput({ fieldProps, context, webInputType }) {
|
|
|
2335
2335
|
}
|
|
2336
2336
|
);
|
|
2337
2337
|
}
|
|
2338
|
+
var PATHS = {
|
|
2339
|
+
["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",
|
|
2340
|
+
["previous" /* Previous */]: "M15 5l-7 7 7 7",
|
|
2341
|
+
["next" /* Next */]: "M9 5l7 7-7 7"
|
|
2342
|
+
};
|
|
2343
|
+
var SIZE = 18;
|
|
2344
|
+
var STROKE = 2;
|
|
2345
|
+
function Glyph({ name, color }) {
|
|
2346
|
+
return /* @__PURE__ */ 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__ */ jsx("path", { d: PATHS[name] }) });
|
|
2347
|
+
}
|
|
2348
|
+
var TINT_STEP = "100";
|
|
2349
|
+
function usePickerColors() {
|
|
2350
|
+
const { theme } = useUi();
|
|
2351
|
+
const brand = theme.palette.primary["500"];
|
|
2352
|
+
return {
|
|
2353
|
+
text: theme.colors.text,
|
|
2354
|
+
textSecondary: theme.colors.textSecondary,
|
|
2355
|
+
border: theme.colors.border,
|
|
2356
|
+
surface: theme.colors.surface,
|
|
2357
|
+
brand,
|
|
2358
|
+
onBrand: resolveOnBrand(brand),
|
|
2359
|
+
tint: theme.palette.primary[TINT_STEP] ?? theme.colors.background
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
var FOCUSABLE = "button, select, input, [tabindex]";
|
|
2363
|
+
var RADIUS = 12;
|
|
2364
|
+
var SHEET_RADIUS = 16;
|
|
2365
|
+
var PAD = 12;
|
|
2366
|
+
var SHEET_MAX_HEIGHT = "90vh";
|
|
2367
|
+
function tabStops(container) {
|
|
2368
|
+
return Array.from(container.querySelectorAll(FOCUSABLE)).filter(
|
|
2369
|
+
(node) => node.tabIndex >= 0 && !node.hasAttribute("disabled") && node.getAttribute("aria-disabled") !== "true"
|
|
2370
|
+
);
|
|
2371
|
+
}
|
|
2372
|
+
function PickerDialog({ testID, sheet, onDismiss, children }) {
|
|
2373
|
+
const colors = usePickerColors();
|
|
2374
|
+
const ref = useRef(null);
|
|
2375
|
+
const onKeyDown = (event) => {
|
|
2376
|
+
if (event.key === "Escape") {
|
|
2377
|
+
event.preventDefault();
|
|
2378
|
+
event.stopPropagation();
|
|
2379
|
+
onDismiss();
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
if (event.key !== "Tab" || ref.current === null) return;
|
|
2383
|
+
const stops = tabStops(ref.current);
|
|
2384
|
+
const first = stops[0];
|
|
2385
|
+
const last = stops[stops.length - 1];
|
|
2386
|
+
if (first === void 0 || last === void 0) return;
|
|
2387
|
+
const atEdge = event.shiftKey ? document.activeElement === first : document.activeElement === last;
|
|
2388
|
+
if (!atEdge) return;
|
|
2389
|
+
event.preventDefault();
|
|
2390
|
+
(event.shiftKey ? last : first).focus();
|
|
2391
|
+
};
|
|
2392
|
+
const shape = sheet ? { borderTopLeftRadius: SHEET_RADIUS, borderTopRightRadius: SHEET_RADIUS, width: "100%", maxHeight: SHEET_MAX_HEIGHT, overflowY: "auto" } : { borderRadius: RADIUS, boxShadow: `0 12px 32px ${colors.border}` };
|
|
2393
|
+
const style = { boxSizing: "border-box", padding: PAD, background: colors.surface, color: colors.text, border: `1px solid ${colors.border}`, fontFamily: "inherit", ...shape };
|
|
2394
|
+
return /* @__PURE__ */ jsx("div", { ref, "data-testid": testID, "data-variant": sheet ? "sheet" : "popover", style, onKeyDown, children });
|
|
2395
|
+
}
|
|
2396
|
+
function useAnchorRect2(anchorRef) {
|
|
2397
|
+
const [rect2, setRect] = useState(null);
|
|
2398
|
+
useEffect(() => {
|
|
2399
|
+
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2400
|
+
}, [anchorRef]);
|
|
2401
|
+
return rect2;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
// src/SearchSelect/DropdownPlacement.ts
|
|
2405
|
+
var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
|
|
2406
|
+
DropdownPlacement2["Below"] = "below";
|
|
2407
|
+
DropdownPlacement2["Above"] = "above";
|
|
2408
|
+
return DropdownPlacement2;
|
|
2409
|
+
})(DropdownPlacement || {});
|
|
2410
|
+
|
|
2411
|
+
// src/SearchSelect/utils/dropdownFrame.ts
|
|
2412
|
+
var MIN_PANEL_WIDTH = 240;
|
|
2413
|
+
var EDGE = 8;
|
|
2414
|
+
function placeDropdown(anchor, panelHeight, viewportHeight) {
|
|
2415
|
+
const roomBelow = viewportHeight - (anchor.y + anchor.height);
|
|
2416
|
+
if (roomBelow >= panelHeight) return "below" /* Below */;
|
|
2417
|
+
return anchor.y > roomBelow ? "above" /* Above */ : "below" /* Below */;
|
|
2418
|
+
}
|
|
2419
|
+
function clampTop(top, panelHeight, viewportHeight) {
|
|
2420
|
+
return Math.max(EDGE, Math.min(top, viewportHeight - panelHeight - EDGE));
|
|
2421
|
+
}
|
|
2422
|
+
function dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow = false) {
|
|
2423
|
+
const placement = preferBelow ? "below" /* Below */ : placeDropdown(anchor, panelHeight, viewportHeight);
|
|
2424
|
+
const base = { placement, left: anchor.x, width: anchor.width };
|
|
2425
|
+
if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - clampTop(anchor.y - panelHeight, panelHeight, viewportHeight) - panelHeight };
|
|
2426
|
+
return { ...base, top: clampTop(anchor.y + anchor.height, panelHeight, viewportHeight) };
|
|
2427
|
+
}
|
|
2428
|
+
function fitDropdownWidth(frame, viewportWidth, minWidth = MIN_PANEL_WIDTH) {
|
|
2429
|
+
const width = Math.max(frame.width, Math.min(minWidth, viewportWidth - EDGE - EDGE));
|
|
2430
|
+
const left = Math.max(EDGE, Math.min(frame.left, viewportWidth - width - EDGE));
|
|
2431
|
+
return { ...frame, width, left: frame.width >= width ? frame.left : left };
|
|
2432
|
+
}
|
|
2433
|
+
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children, minWidth, scale, accessibilityLabel, preferBelow = false }) {
|
|
2434
|
+
const { height: viewportHeight, width: viewportWidth } = useWindowDimensions();
|
|
2435
|
+
const anchor = useAnchorRect2(anchorRef);
|
|
2436
|
+
const [panelHeight, setPanelHeight] = useState(0);
|
|
2437
|
+
const onLayout = useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2438
|
+
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight, preferBelow), viewportWidth, minWidth);
|
|
2439
|
+
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2440
|
+
return /* @__PURE__ */ jsxs(Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: [
|
|
2441
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2442
|
+
frame !== null ? /* @__PURE__ */ jsx(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
|
|
2443
|
+
] });
|
|
2444
|
+
}
|
|
2445
|
+
var styles15 = StyleSheet.create({
|
|
2446
|
+
dropdown: { position: "absolute" },
|
|
2447
|
+
growFromField: { transformOrigin: "top left" }
|
|
2448
|
+
});
|
|
2449
|
+
function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children, progress, scale, accessibilityLabel }) {
|
|
2450
|
+
return /* @__PURE__ */ jsx(Modal, { transparent: true, visible: true, animationType: "none", "aria-label": accessibilityLabel, onRequestClose: onDismiss, children: /* @__PURE__ */ jsxs(View, { style: styles16.backdrop, children: [
|
|
2451
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2452
|
+
/* @__PURE__ */ jsx(Animated.View, { testID: `${testID}-sheet`, style: [styles16.sheet, { transform: scale === void 0 ? [{ translateY }] : [{ translateY }, { scale }] }, progress === void 0 ? null : { opacity: progress }], children })
|
|
2453
|
+
] }) });
|
|
2454
|
+
}
|
|
2455
|
+
var styles16 = StyleSheet.create({
|
|
2456
|
+
backdrop: { flex: 1, justifyContent: "flex-end" },
|
|
2457
|
+
sheet: { width: "100%", alignSelf: "stretch" }
|
|
2458
|
+
});
|
|
2459
|
+
function useReducedMotion() {
|
|
2460
|
+
const [reduced, setReduced] = useState(false);
|
|
2461
|
+
useEffect(() => {
|
|
2462
|
+
let active = true;
|
|
2463
|
+
AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2464
|
+
if (active) setReduced(value);
|
|
2465
|
+
}).catch(() => void 0);
|
|
2466
|
+
const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
|
|
2467
|
+
return () => {
|
|
2468
|
+
active = false;
|
|
2469
|
+
subscription?.remove();
|
|
2470
|
+
};
|
|
2471
|
+
}, []);
|
|
2472
|
+
return reduced;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
// src/DatePicker/data/defaultLabels.ts
|
|
2476
|
+
var DEFAULT_DATE_PICKER_LABELS = {
|
|
2477
|
+
dialog: "Choose a date",
|
|
2478
|
+
rangeDialog: "Choose a date range",
|
|
2479
|
+
openCalendar: "Open calendar",
|
|
2480
|
+
openCalendarHint: "Opens a calendar to pick the date",
|
|
2481
|
+
previousMonth: "Previous month",
|
|
2482
|
+
nextMonth: "Next month",
|
|
2483
|
+
monthHint: "Shows another month",
|
|
2484
|
+
month: "Month",
|
|
2485
|
+
year: "Year",
|
|
2486
|
+
dayHint: "Picks this day",
|
|
2487
|
+
setDate: "Set date",
|
|
2488
|
+
setDateHint: "Saves the picked date",
|
|
2489
|
+
clear: "Clear",
|
|
2490
|
+
clearHint: "Removes the date",
|
|
2491
|
+
cancel: "Cancel",
|
|
2492
|
+
cancelHint: "Closes without changes",
|
|
2493
|
+
apply: "Apply",
|
|
2494
|
+
applyHint: "Saves the picked range",
|
|
2495
|
+
presets: "Quick ranges",
|
|
2496
|
+
presetHint: "Sets the range to this period",
|
|
2497
|
+
today: "Today",
|
|
2498
|
+
last7Days: "Last 7 days",
|
|
2499
|
+
thisMonth: "This month",
|
|
2500
|
+
quarter: "Quarter",
|
|
2501
|
+
dayCount: "{{p1}} days",
|
|
2502
|
+
invalidDate: "Enter a real date",
|
|
2503
|
+
rangeSeparator: " \u2013 ",
|
|
2504
|
+
rangeOrder: "The start must be on or before the end",
|
|
2505
|
+
outOfRange: "This date is outside the allowed range"
|
|
2506
|
+
};
|
|
2507
|
+
|
|
2508
|
+
// src/DatePicker/utils/isoDate.ts
|
|
2509
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2510
|
+
var MONTHS_IN_YEAR = 12;
|
|
2511
|
+
var DAYS_IN_WEEK = 7;
|
|
2512
|
+
var PAD2 = 2;
|
|
2513
|
+
var YEAR_PAD = 4;
|
|
2514
|
+
var SUNDAY = 0;
|
|
2515
|
+
var MONDAY = 1;
|
|
2516
|
+
var MS_PER_DAY = 864e5;
|
|
2517
|
+
var MONTH_PREFIX = "YYYY-MM".length;
|
|
2518
|
+
var EPOCH = { year: 1970, month: 1, day: 1 };
|
|
2519
|
+
function daysInMonth(year, month) {
|
|
2520
|
+
return new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
2521
|
+
}
|
|
2522
|
+
function isValidParts({ year, month, day }) {
|
|
2523
|
+
const inMonth = month >= 1 && month <= MONTHS_IN_YEAR;
|
|
2524
|
+
return Number.isInteger(year) && year > 0 && inMonth && Number.isInteger(day) && day >= 1 && day <= daysInMonth(year, month);
|
|
2525
|
+
}
|
|
2526
|
+
function parseIso(value) {
|
|
2527
|
+
const match = ISO_DATE.exec(value);
|
|
2528
|
+
if (match === null) return null;
|
|
2529
|
+
const parts = { year: Number(match[1]), month: Number(match[2]), day: Number(match[3]) };
|
|
2530
|
+
return isValidParts(parts) ? parts : null;
|
|
2531
|
+
}
|
|
2532
|
+
function toIso({ year, month, day }) {
|
|
2533
|
+
return `${String(year).padStart(YEAR_PAD, "0")}-${String(month).padStart(PAD2, "0")}-${String(day).padStart(PAD2, "0")}`;
|
|
2534
|
+
}
|
|
2535
|
+
function toUtc(iso) {
|
|
2536
|
+
const parts = parseIso(iso) ?? EPOCH;
|
|
2537
|
+
return new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
|
|
2538
|
+
}
|
|
2539
|
+
function fromUtc(date) {
|
|
2540
|
+
return toIso({ year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate() });
|
|
2541
|
+
}
|
|
2542
|
+
function addDays(iso, days) {
|
|
2543
|
+
const date = toUtc(iso);
|
|
2544
|
+
date.setUTCDate(date.getUTCDate() + days);
|
|
2545
|
+
return fromUtc(date);
|
|
2546
|
+
}
|
|
2547
|
+
function addMonths(iso, months) {
|
|
2548
|
+
const parts = parseIso(iso) ?? EPOCH;
|
|
2549
|
+
const index = parts.year * MONTHS_IN_YEAR + (parts.month - 1) + months;
|
|
2550
|
+
const year = Math.floor(index / MONTHS_IN_YEAR);
|
|
2551
|
+
const month = index % MONTHS_IN_YEAR + 1;
|
|
2552
|
+
return toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) });
|
|
2553
|
+
}
|
|
2554
|
+
function weekdayIndex(iso, firstDay = MONDAY) {
|
|
2555
|
+
const day = toUtc(iso).getUTCDay();
|
|
2556
|
+
const isoDay = day === SUNDAY ? DAYS_IN_WEEK : day;
|
|
2557
|
+
return (isoDay - firstDay + DAYS_IN_WEEK) % DAYS_IN_WEEK;
|
|
2558
|
+
}
|
|
2559
|
+
function daysBetweenInclusive(from, to) {
|
|
2560
|
+
return Math.round((toUtc(to).getTime() - toUtc(from).getTime()) / MS_PER_DAY) + 1;
|
|
2561
|
+
}
|
|
2562
|
+
function isWithinBounds(iso, min, max) {
|
|
2563
|
+
const aboveMin = min === void 0 || min === "" || iso >= min.slice(0, iso.length);
|
|
2564
|
+
const belowMax = max === void 0 || max === "" || iso <= max.slice(0, iso.length);
|
|
2565
|
+
return aboveMin && belowMax;
|
|
2566
|
+
}
|
|
2567
|
+
function clampToBounds(iso, min, max) {
|
|
2568
|
+
if (min !== void 0 && min !== "" && iso < min.slice(0, iso.length)) return min.slice(0, iso.length);
|
|
2569
|
+
if (max !== void 0 && max !== "" && iso > max.slice(0, iso.length)) return max.slice(0, iso.length);
|
|
2570
|
+
return iso;
|
|
2571
|
+
}
|
|
2572
|
+
function todayIso(now = /* @__PURE__ */ new Date()) {
|
|
2573
|
+
return toIso({ year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate() });
|
|
2574
|
+
}
|
|
2575
|
+
function monthStart(iso) {
|
|
2576
|
+
return `${iso.slice(0, MONTH_PREFIX)}-01`;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// src/DatePicker/utils/weekStart.ts
|
|
2580
|
+
var MONDAY2 = 1;
|
|
2581
|
+
var SUNDAY2 = 7;
|
|
2582
|
+
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"]);
|
|
2583
|
+
function weekFirstDay(locale) {
|
|
2584
|
+
try {
|
|
2585
|
+
const resolved = new Intl.Locale(locale ?? new Intl.DateTimeFormat().resolvedOptions().locale);
|
|
2586
|
+
const info = resolved;
|
|
2587
|
+
const first = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay;
|
|
2588
|
+
if (first !== void 0) return first;
|
|
2589
|
+
return SUNDAY_REGIONS.has(resolved.maximize().region ?? "") ? SUNDAY2 : MONDAY2;
|
|
2590
|
+
} catch {
|
|
2591
|
+
return MONDAY2;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
var DatePickerContext = createContext({ labels: DEFAULT_DATE_PICKER_LABELS });
|
|
2595
|
+
function DatePickerProvider({ labels, locale, today, children }) {
|
|
2596
|
+
const value = useMemo(() => ({ labels: { ...DEFAULT_DATE_PICKER_LABELS, ...labels }, locale, today }), [labels, locale, today]);
|
|
2597
|
+
return /* @__PURE__ */ jsx(DatePickerContext.Provider, { value, children });
|
|
2598
|
+
}
|
|
2599
|
+
function useDatePickerConfig() {
|
|
2600
|
+
const config = useContext(DatePickerContext);
|
|
2601
|
+
const firstDay = useMemo(() => weekFirstDay(config.locale), [config.locale]);
|
|
2602
|
+
return { labels: config.labels, locale: config.locale, today: config.today ?? todayIso(), firstDay };
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
// src/DatePicker/utils/motionStyles.ts
|
|
2606
|
+
var OPEN_MS = 180;
|
|
2607
|
+
var MONTH_SLIDE_MS = 200;
|
|
2608
|
+
var MONTH_SLIDE_PX = 16;
|
|
2609
|
+
var OPEN_SCALE = 0.96;
|
|
2610
|
+
var EASE = "cubic-bezier(0.2, 0, 0, 1)";
|
|
2611
|
+
function resolveOpenMotion(reduced) {
|
|
2612
|
+
return reduced ? { durationMs: 0, fromScale: 1 } : { durationMs: OPEN_MS, fromScale: OPEN_SCALE };
|
|
2613
|
+
}
|
|
2614
|
+
function monthSlideStyle(entered, reduced, direction) {
|
|
2615
|
+
if (reduced || direction === 0) return {};
|
|
2616
|
+
return {
|
|
2617
|
+
opacity: entered ? 1 : 0,
|
|
2618
|
+
transform: entered ? "translateX(0px)" : `translateX(${direction * MONTH_SLIDE_PX}px)`,
|
|
2619
|
+
transition: `opacity ${MONTH_SLIDE_MS}ms ${EASE}, transform ${MONTH_SLIDE_MS}ms ${EASE}`
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
function useOpenProgress() {
|
|
2623
|
+
const { durationMs, fromScale } = resolveOpenMotion(useReducedMotion());
|
|
2624
|
+
const progress = useRef(new Animated.Value(0)).current;
|
|
2625
|
+
useEffect(() => {
|
|
2626
|
+
Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
2627
|
+
}, [progress, durationMs]);
|
|
2628
|
+
return {
|
|
2629
|
+
progress,
|
|
2630
|
+
scale: progress.interpolate({ inputRange: [0, 1], outputRange: [fromScale, 1] }),
|
|
2631
|
+
still: progress.interpolate({ inputRange: [0, 1], outputRange: [0, 0] })
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
function PickerSurface({ anchorRef, phone, minWidth, label, testID, onDismiss, children }) {
|
|
2635
|
+
const { labels } = useDatePickerConfig();
|
|
2636
|
+
const { progress, scale, still } = useOpenProgress();
|
|
2637
|
+
const body = /* @__PURE__ */ jsx(PickerDialog, { sheet: phone, testID, onDismiss, children });
|
|
2638
|
+
if (phone) {
|
|
2639
|
+
return /* @__PURE__ */ jsx(SheetSurface, { accessibilityLabel: label, closeHint: labels.cancelHint, closeLabel: labels.cancel, progress, testID, translateY: still, onDismiss, children: body });
|
|
2640
|
+
}
|
|
2641
|
+
return /* @__PURE__ */ jsx(DropdownSurface, { accessibilityLabel: label, anchorRef, closeHint: labels.cancelHint, closeLabel: labels.cancel, minWidth, preferBelow: true, progress, scale, testID, translateY: still, onDismiss, children: body });
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
// src/DatePicker/utils/calendarKeys.ts
|
|
2645
|
+
var DAYS_IN_WEEK2 = 7;
|
|
2646
|
+
var MONTHS_IN_YEAR2 = 12;
|
|
2647
|
+
var MONDAY3 = 1;
|
|
2648
|
+
var DAY_STEPS = {
|
|
2649
|
+
ArrowLeft: -1,
|
|
2650
|
+
ArrowRight: 1,
|
|
2651
|
+
ArrowUp: -DAYS_IN_WEEK2,
|
|
2652
|
+
ArrowDown: DAYS_IN_WEEK2
|
|
2653
|
+
};
|
|
2654
|
+
function nextFocusDay(iso, key, shiftKey = false, firstDay = MONDAY3) {
|
|
2655
|
+
const step = DAY_STEPS[key];
|
|
2656
|
+
if (step !== void 0) return addDays(iso, step);
|
|
2657
|
+
const monthStep = shiftKey ? MONTHS_IN_YEAR2 : 1;
|
|
2658
|
+
if (key === "PageUp") return addMonths(iso, -monthStep);
|
|
2659
|
+
if (key === "PageDown") return addMonths(iso, monthStep);
|
|
2660
|
+
if (key === "Home") return addDays(iso, -weekdayIndex(iso, firstDay));
|
|
2661
|
+
if (key === "End") return addDays(iso, DAYS_IN_WEEK2 - 1 - weekdayIndex(iso, firstDay));
|
|
2662
|
+
return null;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
// src/DatePicker/hooks/useGridFocus.ts
|
|
2666
|
+
function dayDomId(testID, iso) {
|
|
2667
|
+
return `${testID}-day-${iso}`;
|
|
2668
|
+
}
|
|
2669
|
+
function useGridFocus(initial, bounds, testID, onPick) {
|
|
2670
|
+
const { firstDay } = useDatePickerConfig();
|
|
2671
|
+
const [focusedDay, setFocusedDay] = useState(initial);
|
|
2672
|
+
const focusPending = useRef(true);
|
|
2673
|
+
const { min, max } = bounds;
|
|
2674
|
+
useEffect(() => {
|
|
2675
|
+
if (!focusPending.current) return;
|
|
2676
|
+
focusPending.current = false;
|
|
2677
|
+
document.getElementById(dayDomId(testID, focusedDay))?.focus();
|
|
2678
|
+
}, [focusedDay, testID]);
|
|
2679
|
+
const moveTo = useCallback((iso) => setFocusedDay(clampToBounds(iso, min, max)), [min, max]);
|
|
2680
|
+
const onDayKey = useCallback(
|
|
2681
|
+
(event, iso) => {
|
|
2682
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2683
|
+
event.preventDefault();
|
|
2684
|
+
onPick(iso);
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
const next = nextFocusDay(iso, event.key, event.shiftKey, firstDay);
|
|
2688
|
+
if (next === null) return;
|
|
2689
|
+
event.preventDefault();
|
|
2690
|
+
focusPending.current = true;
|
|
2691
|
+
moveTo(next);
|
|
2692
|
+
},
|
|
2693
|
+
[moveTo, onPick, firstDay]
|
|
2694
|
+
);
|
|
2695
|
+
return { focusedDay, moveTo, onDayKey };
|
|
2696
|
+
}
|
|
2697
|
+
var DAY_CELL_PX = 44;
|
|
2698
|
+
var DAY_START = 8;
|
|
2699
|
+
var RING = 2;
|
|
2700
|
+
var FONT = 14;
|
|
2701
|
+
var BOLD = 700;
|
|
2702
|
+
var REGULAR = 400;
|
|
2703
|
+
function DayCell({ iso, state, testID, label, hint, onPick, onKey }) {
|
|
2704
|
+
const colors = usePickerColors();
|
|
2705
|
+
const { inRange, isEnd, isToday, enabled, focusable } = state;
|
|
2706
|
+
const cellStyle = { width: DAY_CELL_PX, height: DAY_CELL_PX, flexShrink: 0, background: inRange && !isEnd ? colors.tint : "transparent" };
|
|
2707
|
+
const textColor = isEnd ? colors.onBrand : enabled ? colors.text : colors.textSecondary;
|
|
2708
|
+
const buttonStyle = {
|
|
2709
|
+
width: DAY_CELL_PX,
|
|
2710
|
+
height: DAY_CELL_PX,
|
|
2711
|
+
padding: 0,
|
|
2712
|
+
boxSizing: "border-box",
|
|
2713
|
+
borderRadius: DAY_CELL_PX / 2,
|
|
2714
|
+
border: `${RING}px solid ${isToday ? colors.brand : "transparent"}`,
|
|
2715
|
+
background: isEnd ? colors.brand : "transparent",
|
|
2716
|
+
color: textColor,
|
|
2717
|
+
textDecoration: enabled ? "none" : "line-through",
|
|
2718
|
+
fontFamily: "inherit",
|
|
2719
|
+
fontSize: FONT,
|
|
2720
|
+
fontWeight: isEnd || isToday ? BOLD : REGULAR,
|
|
2721
|
+
cursor: enabled ? "pointer" : "default"
|
|
2722
|
+
};
|
|
2723
|
+
return /* @__PURE__ */ jsx("div", { "aria-selected": isEnd, role: "gridcell", style: cellStyle, children: /* @__PURE__ */ jsx(
|
|
2724
|
+
"button",
|
|
2725
|
+
{
|
|
2726
|
+
"aria-current": isToday ? "date" : void 0,
|
|
2727
|
+
"aria-label": label,
|
|
2728
|
+
"data-testid": dayDomId(testID, iso),
|
|
2729
|
+
disabled: !enabled,
|
|
2730
|
+
id: dayDomId(testID, iso),
|
|
2731
|
+
style: buttonStyle,
|
|
2732
|
+
tabIndex: focusable ? 0 : -1,
|
|
2733
|
+
title: hint,
|
|
2734
|
+
type: "button",
|
|
2735
|
+
onClick: () => onPick(iso),
|
|
2736
|
+
onKeyDown: (event) => onKey(event, iso),
|
|
2737
|
+
children: Number(iso.slice(DAY_START))
|
|
2738
|
+
}
|
|
2739
|
+
) });
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
// src/DatePicker/utils/formatDate.ts
|
|
2743
|
+
var SAMPLE_UTC = Date.UTC(2027, 5, 12);
|
|
2744
|
+
var TWO_DIGIT_YEAR = 100;
|
|
2745
|
+
var CENTURY = 2e3;
|
|
2746
|
+
var PART_COUNT = 3;
|
|
2747
|
+
var PAD3 = 2;
|
|
2748
|
+
var MONDAY4 = 1;
|
|
2749
|
+
var ISO_LIKE = /^\d{4}-\d{1,2}-\d{1,2}$/;
|
|
2750
|
+
var MONTH_INDEXES = Array.from({ length: 12 }, (_unused, index) => index);
|
|
2751
|
+
var WEEK_OFFSETS = Array.from({ length: 7 }, (_unused, index) => index);
|
|
2752
|
+
var UTC = "UTC";
|
|
2753
|
+
var PART_OF = { day: "day" /* Day */, month: "month" /* Month */, year: "year" /* Year */ };
|
|
2754
|
+
function utcOf(iso) {
|
|
2755
|
+
const parts = parseIso(iso);
|
|
2756
|
+
return parts === null ? null : new Date(Date.UTC(parts.year, parts.month - 1, parts.day));
|
|
2757
|
+
}
|
|
2758
|
+
function formatWith(iso, locale, options) {
|
|
2759
|
+
const date = utcOf(iso);
|
|
2760
|
+
if (date === null) return iso;
|
|
2761
|
+
return new Intl.DateTimeFormat(locale, { ...options, timeZone: UTC }).format(date).replace(/,/g, "");
|
|
2762
|
+
}
|
|
2763
|
+
function formatDisplay(iso, locale) {
|
|
2764
|
+
return formatWith(iso, locale, { weekday: "short", day: "numeric", month: "short", year: "numeric" });
|
|
2765
|
+
}
|
|
2766
|
+
function formatShort(iso, locale, withYear = true) {
|
|
2767
|
+
return formatWith(iso, locale, withYear ? { day: "numeric", month: "short", year: "numeric" } : { day: "numeric", month: "short" });
|
|
2768
|
+
}
|
|
2769
|
+
function formatMonthYear(iso, locale) {
|
|
2770
|
+
return formatWith(iso, locale, { month: "long", year: "numeric" });
|
|
2771
|
+
}
|
|
2772
|
+
function monthNames(locale) {
|
|
2773
|
+
const format = new Intl.DateTimeFormat(locale, { month: "long", timeZone: UTC });
|
|
2774
|
+
return MONTH_INDEXES.map((month) => format.format(new Date(Date.UTC(2024, month, 1))));
|
|
2775
|
+
}
|
|
2776
|
+
function weekdayNames(locale, firstDay = MONDAY4) {
|
|
2777
|
+
const format = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: UTC });
|
|
2778
|
+
return WEEK_OFFSETS.map((offset) => format.format(new Date(Date.UTC(2024, 0, firstDay + offset))));
|
|
2779
|
+
}
|
|
2780
|
+
function typedOrder(locale) {
|
|
2781
|
+
const parts = new Intl.DateTimeFormat(locale, { day: "numeric", month: "numeric", year: "numeric", timeZone: UTC }).formatToParts(new Date(SAMPLE_UTC));
|
|
2782
|
+
return parts.map((part) => PART_OF[part.type]).filter((part) => part !== void 0);
|
|
2783
|
+
}
|
|
2784
|
+
function formatTyped(iso, locale) {
|
|
2785
|
+
const parts = parseIso(iso);
|
|
2786
|
+
if (parts === null) return iso;
|
|
2787
|
+
const text = {
|
|
2788
|
+
["day" /* Day */]: String(parts.day).padStart(PAD3, "0"),
|
|
2789
|
+
["month" /* Month */]: String(parts.month).padStart(PAD3, "0"),
|
|
2790
|
+
["year" /* Year */]: String(parts.year)
|
|
2791
|
+
};
|
|
2792
|
+
return typedOrder(locale).map((part) => text[part]).join("/");
|
|
2793
|
+
}
|
|
2794
|
+
function parseTyped(text, locale) {
|
|
2795
|
+
const trimmed = text.trim();
|
|
2796
|
+
if (ISO_LIKE.test(trimmed)) {
|
|
2797
|
+
const [year = 0, month = 0, day = 0] = trimmed.split("-").map(Number);
|
|
2798
|
+
const parts2 = { year, month, day };
|
|
2799
|
+
return isValidParts(parts2) ? toIso(parts2) : null;
|
|
2800
|
+
}
|
|
2801
|
+
const numbers2 = trimmed.split(/\D+/).filter((piece) => piece !== "").map(Number);
|
|
2802
|
+
if (numbers2.length !== PART_COUNT) return null;
|
|
2803
|
+
const order = typedOrder(locale);
|
|
2804
|
+
const read = (part) => numbers2[order.indexOf(part)] ?? 0;
|
|
2805
|
+
const rawYear = read("year" /* Year */);
|
|
2806
|
+
const parts = { year: rawYear < TWO_DIGIT_YEAR ? CENTURY + rawYear : rawYear, month: read("month" /* Month */), day: read("day" /* Day */) };
|
|
2807
|
+
return isValidParts(parts) ? toIso(parts) : null;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
// src/DatePicker/utils/monthGrid.ts
|
|
2811
|
+
var DAYS_IN_WEEK3 = 7;
|
|
2812
|
+
var MONDAY5 = 1;
|
|
2813
|
+
function buildMonthGrid(year, month, firstDay = MONDAY5) {
|
|
2814
|
+
const lead = weekdayIndex(toIso({ year, month, day: 1 }), firstDay);
|
|
2815
|
+
const cells = Array.from({ length: lead }, () => null);
|
|
2816
|
+
for (let day = 1; day <= daysInMonth(year, month); day += 1) cells.push(toIso({ year, month, day }));
|
|
2817
|
+
while (cells.length % DAYS_IN_WEEK3 !== 0) cells.push(null);
|
|
2818
|
+
const weeks = [];
|
|
2819
|
+
for (let start = 0; start < cells.length; start += DAYS_IN_WEEK3) weeks.push(cells.slice(start, start + DAYS_IN_WEEK3));
|
|
2820
|
+
return weeks;
|
|
2821
|
+
}
|
|
2822
|
+
var SHORT_DAY = 2;
|
|
2823
|
+
var DAYS_IN_WEEK4 = 7;
|
|
2824
|
+
var HEADER_LINE = 28;
|
|
2825
|
+
var CAPTION_FONT = 15;
|
|
2826
|
+
var WEEKDAY_FONT = 12;
|
|
2827
|
+
var BOLD2 = 700;
|
|
2828
|
+
var ROW = { display: "flex" };
|
|
2829
|
+
var EMPTY = { width: DAY_CELL_PX, height: DAY_CELL_PX, flexShrink: 0 };
|
|
2830
|
+
var FALLBACK = { year: 1970, month: 1};
|
|
2831
|
+
function MonthGrid({ month, selection, focusedDay, bounds, testID, onPick, onKey, showCaption = false, motion }) {
|
|
2832
|
+
const { labels, locale, today, firstDay } = useDatePickerConfig();
|
|
2833
|
+
const colors = usePickerColors();
|
|
2834
|
+
const parts = parseIso(month) ?? FALLBACK;
|
|
2835
|
+
const weeks = useMemo(() => buildMonthGrid(parts.year, parts.month, firstDay), [parts.year, parts.month, firstDay]);
|
|
2836
|
+
const weekdays = useMemo(() => weekdayNames(locale, firstDay), [locale, firstDay]);
|
|
2837
|
+
const title = formatMonthYear(month, locale);
|
|
2838
|
+
const end = selection.to === "" ? selection.from : selection.to;
|
|
2839
|
+
const stateOf = (iso) => ({
|
|
2840
|
+
inRange: selection.from !== "" && iso >= selection.from && iso <= end,
|
|
2841
|
+
isEnd: iso === selection.from || iso === selection.to,
|
|
2842
|
+
isToday: iso === today,
|
|
2843
|
+
enabled: isWithinBounds(iso, bounds.min, bounds.max),
|
|
2844
|
+
focusable: iso === focusedDay
|
|
2845
|
+
});
|
|
2846
|
+
return /* @__PURE__ */ jsxs("div", { style: { width: DAYS_IN_WEEK4 * DAY_CELL_PX, margin: "0 auto", ...motion }, children: [
|
|
2847
|
+
showCaption ? /* @__PURE__ */ jsx("div", { style: { textAlign: "center", fontWeight: BOLD2, fontSize: CAPTION_FONT, lineHeight: `${MIN_TOUCH_TARGET_PX}px` }, children: title }) : null,
|
|
2848
|
+
/* @__PURE__ */ jsxs("div", { "aria-label": title, "data-testid": `${testID}-grid-${month.slice(0, "2026-11".length)}`, role: "grid", children: [
|
|
2849
|
+
/* @__PURE__ */ jsx("div", { role: "row", style: ROW, children: weekdays.map((name) => /* @__PURE__ */ 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)) }),
|
|
2850
|
+
weeks.map((week, row) => /* @__PURE__ */ jsx("div", { role: "row", style: ROW, children: week.map(
|
|
2851
|
+
(iso, column) => iso === null ? /* @__PURE__ */ jsx("div", { role: "gridcell", style: EMPTY }, `empty-${column}`) : /* @__PURE__ */ jsx(DayCell, { hint: labels.dayHint, iso, label: formatDisplay(iso, locale), state: stateOf(iso), testID, onKey, onPick }, iso)
|
|
2852
|
+
) }, `${month}-${row}`))
|
|
2853
|
+
] })
|
|
2854
|
+
] });
|
|
2855
|
+
}
|
|
2856
|
+
var YEARS_BACK = 100;
|
|
2857
|
+
var YEARS_AHEAD = 20;
|
|
2858
|
+
var ISO_LENGTH = 10;
|
|
2859
|
+
var FONT2 = 15;
|
|
2860
|
+
var BOLD3 = 700;
|
|
2861
|
+
var GAP = 4;
|
|
2862
|
+
var FALLBACK2 = { year: 1970, month: 1, day: 1 };
|
|
2863
|
+
function boundYear(bound) {
|
|
2864
|
+
return parseIso((bound ?? "").slice(0, ISO_LENGTH))?.year;
|
|
2865
|
+
}
|
|
2866
|
+
function yearOptions(current, bounds) {
|
|
2867
|
+
const first = Math.min(current, boundYear(bounds.min) ?? current - YEARS_BACK);
|
|
2868
|
+
const last = Math.max(current, boundYear(bounds.max) ?? current + YEARS_AHEAD);
|
|
2869
|
+
return Array.from({ length: last - first + 1 }, (_unused, index) => first + index);
|
|
2870
|
+
}
|
|
2871
|
+
function MonthHeader({ focusedDay, bounds, testID, onMove }) {
|
|
2872
|
+
const { labels, locale } = useDatePickerConfig();
|
|
2873
|
+
const colors = usePickerColors();
|
|
2874
|
+
const parts = parseIso(focusedDay) ?? FALLBACK2;
|
|
2875
|
+
const names = useMemo(() => monthNames(locale), [locale]);
|
|
2876
|
+
const setMonthYear = (year, month) => onMove(toIso({ year, month, day: Math.min(parts.day, daysInMonth(year, month)) }));
|
|
2877
|
+
const selectStyle = { minHeight: MIN_TOUCH_TARGET_PX, border: "none", background: "transparent", color: colors.text, fontWeight: BOLD3, fontSize: FONT2, fontFamily: "inherit", cursor: "pointer" };
|
|
2878
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
2879
|
+
/* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.previousMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "previous" /* Previous */ }), testID: `${testID}-previous`, onPress: () => onMove(addMonths(focusedDay, -1)) }),
|
|
2880
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: GAP }, children: [
|
|
2881
|
+
/* @__PURE__ */ 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__ */ jsx("option", { value: index + 1, children: name }, name)) }),
|
|
2882
|
+
/* @__PURE__ */ 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__ */ jsx("option", { value: year, children: year }, year)) })
|
|
2883
|
+
] }),
|
|
2884
|
+
/* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.nextMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "next" /* Next */ }), testID: `${testID}-next`, onPress: () => onMove(addMonths(focusedDay, 1)) })
|
|
2885
|
+
] });
|
|
2886
|
+
}
|
|
2887
|
+
var GAP2 = 8;
|
|
2888
|
+
function PickerFooter({ summary, children }) {
|
|
2889
|
+
const colors = usePickerColors();
|
|
2890
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: GAP2, borderTop: `1px solid ${colors.border}`, paddingTop: GAP2, marginTop: GAP2 }, children: [
|
|
2891
|
+
summary,
|
|
2892
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: GAP2, marginLeft: "auto" }, children })
|
|
2893
|
+
] });
|
|
2894
|
+
}
|
|
2895
|
+
function useEntered(key, reduced) {
|
|
2896
|
+
const [enteredKey, setEnteredKey] = useState(null);
|
|
2897
|
+
useEffect(() => {
|
|
2898
|
+
if (reduced) return void 0;
|
|
2899
|
+
let inner = 0;
|
|
2900
|
+
const outer = requestAnimationFrame(() => {
|
|
2901
|
+
inner = requestAnimationFrame(() => setEnteredKey(key));
|
|
2902
|
+
});
|
|
2903
|
+
return () => {
|
|
2904
|
+
cancelAnimationFrame(outer);
|
|
2905
|
+
cancelAnimationFrame(inner);
|
|
2906
|
+
};
|
|
2907
|
+
}, [key, reduced]);
|
|
2908
|
+
return reduced || enteredKey === key;
|
|
2909
|
+
}
|
|
2910
|
+
function useMonthSlide(month) {
|
|
2911
|
+
const reduced = useReducedMotion();
|
|
2912
|
+
const previous = useRef(month);
|
|
2913
|
+
const direction = useRef(0);
|
|
2914
|
+
if (previous.current !== month) {
|
|
2915
|
+
direction.current = month > previous.current ? 1 : -1;
|
|
2916
|
+
previous.current = month;
|
|
2917
|
+
}
|
|
2918
|
+
const entered = useEntered(month, reduced);
|
|
2919
|
+
return monthSlideStyle(entered, reduced, direction.current);
|
|
2920
|
+
}
|
|
2921
|
+
function SingleCalendar({ value, bounds, testID, onCommit }) {
|
|
2922
|
+
const { labels, today } = useDatePickerConfig();
|
|
2923
|
+
const [draft, setDraft] = useState(value);
|
|
2924
|
+
const grid = useGridFocus(clampToBounds(value !== "" ? value : today, bounds.min, bounds.max), bounds, testID, setDraft);
|
|
2925
|
+
const month = monthStart(grid.focusedDay);
|
|
2926
|
+
const motion = useMonthSlide(month);
|
|
2927
|
+
const pick = (iso) => {
|
|
2928
|
+
setDraft(iso);
|
|
2929
|
+
grid.moveTo(iso);
|
|
2930
|
+
};
|
|
2931
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2932
|
+
/* @__PURE__ */ jsx(MonthHeader, { bounds, focusedDay: grid.focusedDay, testID, onMove: grid.moveTo }),
|
|
2933
|
+
/* @__PURE__ */ jsx(MonthGrid, { bounds, focusedDay: grid.focusedDay, month, motion, selection: { from: draft, to: draft }, testID, onKey: grid.onDayKey, onPick: pick }),
|
|
2934
|
+
/* @__PURE__ */ jsxs(PickerFooter, { children: [
|
|
2935
|
+
/* @__PURE__ */ jsx(Button, { accessibilityHint: labels.clearHint, accessibilityLabel: labels.clear, label: labels.clear, testID: `${testID}-clear`, variant: "ghost", onPress: () => onCommit("") }),
|
|
2936
|
+
/* @__PURE__ */ jsx(Button, { accessibilityHint: labels.setDateHint, accessibilityLabel: labels.setDate, disabled: draft === "", label: labels.setDate, testID: `${testID}-set`, onPress: () => onCommit(draft) })
|
|
2937
|
+
] })
|
|
2938
|
+
] });
|
|
2939
|
+
}
|
|
2940
|
+
function useIsPhone() {
|
|
2941
|
+
return !isWideFormLayout(useWindowDimensions().width);
|
|
2942
|
+
}
|
|
2943
|
+
function useReturnFocus(open, target) {
|
|
2944
|
+
const wasOpen = useRef(open);
|
|
2945
|
+
useEffect(() => {
|
|
2946
|
+
const closed = wasOpen.current && !open;
|
|
2947
|
+
wasOpen.current = open;
|
|
2948
|
+
if (!closed) return void 0;
|
|
2949
|
+
const timer = setTimeout(() => target.current?.focus(), 0);
|
|
2950
|
+
return () => clearTimeout(timer);
|
|
2951
|
+
}, [open, target]);
|
|
2952
|
+
}
|
|
2953
|
+
function useTypedDate({ value, onChange, bounds, format, onError, rangeMessage }) {
|
|
2954
|
+
const { labels, locale } = useDatePickerConfig();
|
|
2955
|
+
const [focused, setFocused] = useState(false);
|
|
2956
|
+
const [text, setText] = useState("");
|
|
2957
|
+
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
|
+
|
|
3004
|
+
// src/DatePicker/utils/fieldWidth.ts
|
|
3005
|
+
var FONT_PX = 14;
|
|
3006
|
+
var GLYPH_EM = 0.62;
|
|
3007
|
+
var PAD_INLINE = 12;
|
|
3008
|
+
var BORDER = 1;
|
|
3009
|
+
var PLACEHOLDER_CHARS = 15;
|
|
3010
|
+
function closedFieldMinWidth(text, iconRoom) {
|
|
3011
|
+
const chars = Math.max(text.length, PLACEHOLDER_CHARS);
|
|
3012
|
+
return Math.ceil(chars * FONT_PX * GLYPH_EM) + PAD_INLINE + iconRoom + BORDER + BORDER;
|
|
3013
|
+
}
|
|
3014
|
+
var SINGLE_PICKER_WIDTH = 340;
|
|
3015
|
+
var ICON_ROOM = 48;
|
|
3016
|
+
var ICON_SLOT = { position: "absolute", right: 2, top: 0, bottom: 0, display: "flex", alignItems: "center" };
|
|
3017
|
+
var anchorStyles = StyleSheet.create({ wrap: { position: "relative", width: "100%" } });
|
|
3018
|
+
function DatePickerInput({ fieldProps, context, onTypedError }) {
|
|
3019
|
+
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
3020
|
+
const { labels } = useDatePickerConfig();
|
|
3021
|
+
const phone = useIsPhone();
|
|
3022
|
+
const [open, setOpen] = useState(false);
|
|
3023
|
+
const anchorRef = useRef(null);
|
|
3024
|
+
const inputRef = useRef(null);
|
|
3025
|
+
const bounds = { min, max };
|
|
3026
|
+
const typed = useTypedDate({ value, onChange, bounds, format: formatDisplay, onError: onTypedError });
|
|
3027
|
+
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
3028
|
+
const focus = focusBind;
|
|
3029
|
+
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError, required });
|
|
3030
|
+
const close = useCallback(() => setOpen(false), []);
|
|
3031
|
+
useReturnFocus(open, inputRef);
|
|
3032
|
+
const commit = (iso) => {
|
|
3033
|
+
onTypedError?.(void 0);
|
|
3034
|
+
onChange(iso);
|
|
3035
|
+
close();
|
|
3036
|
+
};
|
|
3037
|
+
const onKeyDown = (event) => {
|
|
3038
|
+
if (event.key === "ArrowDown" && event.altKey) {
|
|
3039
|
+
event.preventDefault();
|
|
3040
|
+
setOpen(true);
|
|
3041
|
+
return;
|
|
3042
|
+
}
|
|
3043
|
+
if (event.key !== "Enter" || onSubmit === void 0) return;
|
|
3044
|
+
event.preventDefault();
|
|
3045
|
+
if (typed.isReady()) onSubmit();
|
|
3046
|
+
};
|
|
3047
|
+
return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: [anchorStyles.wrap, { minWidth: closedFieldMinWidth(typed.display, ICON_ROOM) }], testID: `${testID}-anchor`, children: [
|
|
3048
|
+
/* @__PURE__ */ jsx(
|
|
3049
|
+
"input",
|
|
3050
|
+
{
|
|
3051
|
+
...webA11y,
|
|
3052
|
+
...hoverBind,
|
|
3053
|
+
ref: inputRef,
|
|
3054
|
+
"aria-label": label,
|
|
3055
|
+
autoComplete: "off",
|
|
3056
|
+
"data-testid": testID,
|
|
3057
|
+
disabled,
|
|
3058
|
+
id: context.controlId,
|
|
3059
|
+
style: { ...buildNativeInputStyle(style), paddingInlineEnd: ICON_ROOM },
|
|
3060
|
+
title: accessibilityHint,
|
|
3061
|
+
type: "text",
|
|
3062
|
+
value: typed.display,
|
|
3063
|
+
onBlur: (event) => {
|
|
3064
|
+
focus.onBlur?.(event);
|
|
3065
|
+
typed.onBlur();
|
|
3066
|
+
},
|
|
3067
|
+
onChange: (event) => typed.onText(event.target.value),
|
|
3068
|
+
onFocus: (event) => {
|
|
3069
|
+
focus.onFocus?.(event);
|
|
3070
|
+
typed.onFocus();
|
|
3071
|
+
},
|
|
3072
|
+
onKeyDown
|
|
3073
|
+
}
|
|
3074
|
+
),
|
|
3075
|
+
/* @__PURE__ */ jsx("div", { style: ICON_SLOT, children: /* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.openCalendarHint, accessibilityLabel: labels.openCalendar, appearance: "ghost", disabled, renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "calendar" /* Calendar */ }), testID: `${testID}-calendar`, onPress: () => setOpen((current) => !current) }) }),
|
|
3076
|
+
open ? /* @__PURE__ */ jsx(PickerSurface, { anchorRef, label: labels.dialog, minWidth: SINGLE_PICKER_WIDTH, phone, testID: `${testID}-picker`, onDismiss: close, children: /* @__PURE__ */ jsx(SingleCalendar, { bounds, testID: `${testID}-picker`, value, onCommit: commit }) }) : null
|
|
3077
|
+
] });
|
|
3078
|
+
}
|
|
2338
3079
|
var IS_WEB7 = Platform.OS === "web";
|
|
2339
|
-
|
|
3080
|
+
var DATE_TYPE = "date";
|
|
3081
|
+
function TemporalInput({ fieldProps, context, webInputType, onTypedError }) {
|
|
3082
|
+
if (IS_WEB7 && webInputType === DATE_TYPE) return /* @__PURE__ */ jsx(DatePickerInput, { context, fieldProps, onTypedError });
|
|
2340
3083
|
if (IS_WEB7) return /* @__PURE__ */ jsx(WebDateInput, { context, fieldProps, webInputType });
|
|
2341
3084
|
return /* @__PURE__ */ jsx(
|
|
2342
3085
|
ThemedTextInput,
|
|
@@ -2357,11 +3100,269 @@ function TemporalInput({ fieldProps, context, webInputType }) {
|
|
|
2357
3100
|
}
|
|
2358
3101
|
function TemporalField({ fieldProps, webInputType }) {
|
|
2359
3102
|
const { label, required, hint, error } = fieldProps;
|
|
2360
|
-
|
|
3103
|
+
const [typedError, setTypedError] = useState(void 0);
|
|
3104
|
+
return /* @__PURE__ */ jsx(Field, { error: error ?? typedError, hint, label, required, children: (context) => /* @__PURE__ */ jsx(TemporalInput, { context, fieldProps, webInputType, onTypedError: setTypedError }) });
|
|
2361
3105
|
}
|
|
2362
3106
|
function DateField(props) {
|
|
2363
3107
|
return /* @__PURE__ */ jsx(TemporalField, { fieldProps: props, webInputType: "date" });
|
|
2364
3108
|
}
|
|
3109
|
+
function NativeDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, style, testID }) {
|
|
3110
|
+
return /* @__PURE__ */ jsxs(View, { style: [controlStyles.dateRow, style], testID: `${testID}-range`, children: [
|
|
3111
|
+
/* @__PURE__ */ jsx(View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsx(DateField, { accessibilityHint: hint, label: fromLabel, testID: `${testID}-from`, value: value.from, onChange: (from) => onChange({ from, to: value.to }), onSubmit }) }),
|
|
3112
|
+
/* @__PURE__ */ jsx(View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsx(DateField, { accessibilityHint: hint, label: toLabel, testID: `${testID}-to`, value: value.to, onChange: (to) => onChange({ from: value.from, to }), onSubmit }) })
|
|
3113
|
+
] });
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
// src/DatePicker/utils/rangePresets.ts
|
|
3117
|
+
var RANGE_PRESETS = ["today" /* Today */, "last7Days" /* Last7Days */, "thisMonth" /* ThisMonth */, "quarter" /* Quarter */];
|
|
3118
|
+
var PRESET_LABEL = {
|
|
3119
|
+
["today" /* Today */]: "today",
|
|
3120
|
+
["last7Days" /* Last7Days */]: "last7Days",
|
|
3121
|
+
["thisMonth" /* ThisMonth */]: "thisMonth",
|
|
3122
|
+
["quarter" /* Quarter */]: "quarter"
|
|
3123
|
+
};
|
|
3124
|
+
var MONTHS_IN_QUARTER = 3;
|
|
3125
|
+
var EPOCH2 = { year: 1970, month: 1};
|
|
3126
|
+
function presetLabel(labels, preset) {
|
|
3127
|
+
return labels[PRESET_LABEL[preset]];
|
|
3128
|
+
}
|
|
3129
|
+
function quarterStart(today) {
|
|
3130
|
+
const parts = parseIso(today) ?? EPOCH2;
|
|
3131
|
+
const month = Math.floor((parts.month - 1) / MONTHS_IN_QUARTER) * MONTHS_IN_QUARTER + 1;
|
|
3132
|
+
return toIso({ year: parts.year, month, day: 1 });
|
|
3133
|
+
}
|
|
3134
|
+
function presetRange(preset, today) {
|
|
3135
|
+
if (preset === "last7Days" /* Last7Days */) return { from: addDays(today, -6), to: today };
|
|
3136
|
+
if (preset === "thisMonth" /* ThisMonth */) return { from: monthStart(today), to: today };
|
|
3137
|
+
if (preset === "quarter" /* Quarter */) return { from: quarterStart(today), to: today };
|
|
3138
|
+
return { from: today, to: today };
|
|
3139
|
+
}
|
|
3140
|
+
function matchingPreset(range, today) {
|
|
3141
|
+
return RANGE_PRESETS.find((preset) => {
|
|
3142
|
+
const span = presetRange(preset, today);
|
|
3143
|
+
return span.from === range.from && span.to === range.to;
|
|
3144
|
+
}) ?? null;
|
|
3145
|
+
}
|
|
3146
|
+
function pickRangeDay(range, day) {
|
|
3147
|
+
const open = range.from !== "" && range.to === "";
|
|
3148
|
+
if (!open) return { from: day, to: "" };
|
|
3149
|
+
return day < range.from ? { from: day, to: range.from } : { from: range.from, to: day };
|
|
3150
|
+
}
|
|
3151
|
+
var GAP3 = 8;
|
|
3152
|
+
var CHIP_PAD = 16;
|
|
3153
|
+
var FONT3 = 14;
|
|
3154
|
+
var BOLD4 = 700;
|
|
3155
|
+
var REGULAR2 = 400;
|
|
3156
|
+
var ACTIVE_BORDER = 2;
|
|
3157
|
+
function PresetChips({ active, testID, onPick }) {
|
|
3158
|
+
const { labels } = useDatePickerConfig();
|
|
3159
|
+
const colors = usePickerColors();
|
|
3160
|
+
const chipStyle = (isActive) => ({
|
|
3161
|
+
minHeight: MIN_TOUCH_TARGET_PX,
|
|
3162
|
+
padding: `0 ${CHIP_PAD}px`,
|
|
3163
|
+
borderRadius: MIN_TOUCH_TARGET_PX / 2,
|
|
3164
|
+
border: `${isActive ? ACTIVE_BORDER : 1}px solid ${isActive ? colors.brand : colors.border}`,
|
|
3165
|
+
background: colors.surface,
|
|
3166
|
+
color: colors.text,
|
|
3167
|
+
fontFamily: "inherit",
|
|
3168
|
+
fontSize: FONT3,
|
|
3169
|
+
fontWeight: isActive ? BOLD4 : REGULAR2,
|
|
3170
|
+
cursor: "pointer"
|
|
3171
|
+
});
|
|
3172
|
+
return /* @__PURE__ */ jsx("div", { "aria-label": labels.presets, role: "group", style: { display: "flex", flexWrap: "wrap", gap: GAP3, marginBottom: GAP3 }, children: RANGE_PRESETS.map((preset) => /* @__PURE__ */ jsxs("button", { "aria-pressed": active === preset, "data-testid": `${testID}-preset-${preset}`, style: chipStyle(active === preset), title: labels.presetHint, type: "button", onClick: () => onPick(preset), children: [
|
|
3173
|
+
active === preset ? "\u2713 " : "",
|
|
3174
|
+
presetLabel(labels, preset)
|
|
3175
|
+
] }, preset)) });
|
|
3176
|
+
}
|
|
3177
|
+
var GAP4 = 8;
|
|
3178
|
+
var FONT4 = 14;
|
|
3179
|
+
function PresetMenu({ active, testID, onPick }) {
|
|
3180
|
+
const { labels } = useDatePickerConfig();
|
|
3181
|
+
const colors = usePickerColors();
|
|
3182
|
+
const onChange = (event) => {
|
|
3183
|
+
const preset = RANGE_PRESETS.find((candidate) => candidate === event.target.value);
|
|
3184
|
+
if (preset !== void 0) onPick(preset);
|
|
3185
|
+
};
|
|
3186
|
+
return /* @__PURE__ */ jsxs(
|
|
3187
|
+
"select",
|
|
3188
|
+
{
|
|
3189
|
+
"aria-label": labels.presets,
|
|
3190
|
+
"data-testid": `${testID}-presets`,
|
|
3191
|
+
style: { minHeight: 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 },
|
|
3192
|
+
title: labels.presetHint,
|
|
3193
|
+
value: active ?? "",
|
|
3194
|
+
onChange,
|
|
3195
|
+
children: [
|
|
3196
|
+
/* @__PURE__ */ jsx("option", { value: "", children: labels.presets }),
|
|
3197
|
+
RANGE_PRESETS.map((preset) => /* @__PURE__ */ jsx("option", { value: preset, children: presetLabel(labels, preset) }, preset))
|
|
3198
|
+
]
|
|
3199
|
+
}
|
|
3200
|
+
);
|
|
3201
|
+
}
|
|
3202
|
+
var PHONE_LIST_HEIGHT = "min(56vh, 440px)";
|
|
3203
|
+
var MONTH_GAP = 32;
|
|
3204
|
+
var NAV_ROW = { position: "absolute", left: 0, right: 0, top: 0, display: "flex", justifyContent: "space-between", pointerEvents: "none" };
|
|
3205
|
+
var NAV_SLOT = { pointerEvents: "auto" };
|
|
3206
|
+
function RangeMonthsList({ months, grid }) {
|
|
3207
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": `${grid.testID}-months`, style: { maxHeight: PHONE_LIST_HEIGHT, overflowY: "auto" }, children: months.map((month) => /* @__PURE__ */ jsx(MonthGrid, { showCaption: true, month, ...grid }, month)) });
|
|
3208
|
+
}
|
|
3209
|
+
function RangeMonthsPair({ months, grid, motion, onShift }) {
|
|
3210
|
+
const { labels } = useDatePickerConfig();
|
|
3211
|
+
return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
3212
|
+
/* @__PURE__ */ jsxs("div", { style: NAV_ROW, children: [
|
|
3213
|
+
/* @__PURE__ */ jsx("div", { style: NAV_SLOT, children: /* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.previousMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "previous" /* Previous */ }), testID: `${grid.testID}-previous`, onPress: () => onShift(-1) }) }),
|
|
3214
|
+
/* @__PURE__ */ jsx("div", { style: NAV_SLOT, children: /* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.monthHint, accessibilityLabel: labels.nextMonth, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "next" /* Next */ }), testID: `${grid.testID}-next`, onPress: () => onShift(1) }) })
|
|
3215
|
+
] }),
|
|
3216
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", gap: MONTH_GAP }, children: months.map((month) => /* @__PURE__ */ jsx(MonthGrid, { showCaption: true, month, motion, ...grid }, month)) })
|
|
3217
|
+
] });
|
|
3218
|
+
}
|
|
3219
|
+
var PHONE_MONTHS = 6;
|
|
3220
|
+
var DESKTOP_MONTHS = 2;
|
|
3221
|
+
var SUMMARY_FONT = 14;
|
|
3222
|
+
var SEMIBOLD = 600;
|
|
3223
|
+
function useRangeSummary(draft) {
|
|
3224
|
+
const { labels, locale } = useDatePickerConfig();
|
|
3225
|
+
if (draft.from === "") return "";
|
|
3226
|
+
if (draft.to === "") return formatShort(draft.from, locale);
|
|
3227
|
+
const days = labels.dayCount.replace("{{p1}}", String(daysBetweenInclusive(draft.from, draft.to)));
|
|
3228
|
+
return `${formatShort(draft.from, locale, false)}${labels.rangeSeparator}${formatShort(draft.to, locale)} \xB7 ${days}`;
|
|
3229
|
+
}
|
|
3230
|
+
function RangeCalendar({ value, bounds, phone, testID, onApply, onCancel }) {
|
|
3231
|
+
const { labels, today } = useDatePickerConfig();
|
|
3232
|
+
const [draft, setDraft] = useState(value);
|
|
3233
|
+
const initialDay = clampToBounds(value.from !== "" ? value.from : today, bounds.min, bounds.max);
|
|
3234
|
+
const pickDraft = useCallback((iso) => setDraft((current) => pickRangeDay(current, iso)), []);
|
|
3235
|
+
const focus = useGridFocus(initialDay, bounds, testID, pickDraft);
|
|
3236
|
+
const visible = phone ? PHONE_MONTHS : DESKTOP_MONTHS;
|
|
3237
|
+
const [first, setFirst] = useState(() => monthStart(phone ? initialDay : addMonths(initialDay, 1 - DESKTOP_MONTHS)));
|
|
3238
|
+
const focusMonth = monthStart(focus.focusedDay);
|
|
3239
|
+
const last = addMonths(first, visible - 1);
|
|
3240
|
+
const motion = useMonthSlide(first);
|
|
3241
|
+
const summary = useRangeSummary(draft);
|
|
3242
|
+
useEffect(() => {
|
|
3243
|
+
if (focusMonth < first) setFirst(focusMonth);
|
|
3244
|
+
else if (focusMonth > last) setFirst(addMonths(focusMonth, 1 - visible));
|
|
3245
|
+
}, [focusMonth, first, last, visible]);
|
|
3246
|
+
const pick = (iso) => {
|
|
3247
|
+
pickDraft(iso);
|
|
3248
|
+
focus.moveTo(iso);
|
|
3249
|
+
};
|
|
3250
|
+
const applyPreset = (preset) => {
|
|
3251
|
+
const range = presetRange(preset, today);
|
|
3252
|
+
setDraft(range);
|
|
3253
|
+
focus.moveTo(range.to);
|
|
3254
|
+
};
|
|
3255
|
+
const shift = (step) => {
|
|
3256
|
+
setFirst(addMonths(first, step));
|
|
3257
|
+
focus.moveTo(addMonths(focus.focusedDay, step));
|
|
3258
|
+
};
|
|
3259
|
+
const months = Array.from({ length: visible }, (_unused, index) => addMonths(first, index));
|
|
3260
|
+
const grid = { selection: draft, focusedDay: focus.focusedDay, bounds, testID, onPick: pick, onKey: focus.onDayKey };
|
|
3261
|
+
const presets = { active: matchingPreset(draft, today), testID, onPick: applyPreset };
|
|
3262
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3263
|
+
phone ? /* @__PURE__ */ jsx(PresetMenu, { ...presets }) : /* @__PURE__ */ jsx(PresetChips, { ...presets }),
|
|
3264
|
+
phone ? /* @__PURE__ */ jsx(RangeMonthsList, { grid, months }) : /* @__PURE__ */ jsx(RangeMonthsPair, { grid, months, motion, onShift: shift }),
|
|
3265
|
+
/* @__PURE__ */ jsxs(PickerFooter, { summary: /* @__PURE__ */ jsx("span", { "aria-live": "polite", "data-testid": `${testID}-summary`, style: { fontSize: SUMMARY_FONT, fontWeight: SEMIBOLD }, children: summary }), children: [
|
|
3266
|
+
/* @__PURE__ */ jsx(Button, { accessibilityHint: labels.cancelHint, accessibilityLabel: labels.cancel, label: labels.cancel, testID: `${testID}-cancel`, variant: "ghost", onPress: onCancel }),
|
|
3267
|
+
/* @__PURE__ */ jsx(
|
|
3268
|
+
Button,
|
|
3269
|
+
{
|
|
3270
|
+
accessibilityHint: labels.applyHint,
|
|
3271
|
+
accessibilityLabel: labels.apply,
|
|
3272
|
+
disabled: draft.from === "",
|
|
3273
|
+
label: labels.apply,
|
|
3274
|
+
testID: `${testID}-apply`,
|
|
3275
|
+
onPress: () => onApply({ from: draft.from, to: draft.to === "" ? draft.from : draft.to })
|
|
3276
|
+
}
|
|
3277
|
+
)
|
|
3278
|
+
] })
|
|
3279
|
+
] });
|
|
3280
|
+
}
|
|
3281
|
+
var RANGE_PICKER_WIDTH = 690;
|
|
3282
|
+
var GAP5 = 8;
|
|
3283
|
+
var NO_BOUNDS = {};
|
|
3284
|
+
var SEGMENT = { flex: 1, minWidth: 0, border: "none", background: "transparent", color: "inherit", font: "inherit", outline: "none", padding: 0 };
|
|
3285
|
+
function orNone(value) {
|
|
3286
|
+
return value !== "" ? value : void 0;
|
|
3287
|
+
}
|
|
3288
|
+
function WebDateRange({ value, onChange, onSubmit, fromLabel, toLabel, hint, testID, context, onTypedError }) {
|
|
3289
|
+
const { labels } = useDatePickerConfig();
|
|
3290
|
+
const phone = useIsPhone();
|
|
3291
|
+
const [open, setOpen] = useState(false);
|
|
3292
|
+
const [fromError, setFromError] = useState(void 0);
|
|
3293
|
+
const [toError, setToError] = useState(void 0);
|
|
3294
|
+
const anchorRef = useRef(null);
|
|
3295
|
+
const fromRef = useRef(null);
|
|
3296
|
+
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 });
|
|
3297
|
+
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 });
|
|
3298
|
+
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: true });
|
|
3299
|
+
const focus = focusBind;
|
|
3300
|
+
const webA11y = webFieldA11y({ describedById: context.describedById, hasError: context.hasError });
|
|
3301
|
+
useEffect(() => onTypedError(fromError ?? toError), [fromError, toError, onTypedError]);
|
|
3302
|
+
const close = useCallback(() => setOpen(false), []);
|
|
3303
|
+
useReturnFocus(open, fromRef);
|
|
3304
|
+
const onKeyDown = (event) => {
|
|
3305
|
+
if (event.key === "ArrowDown" && event.altKey) {
|
|
3306
|
+
event.preventDefault();
|
|
3307
|
+
setOpen(true);
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
if (event.key !== "Enter" || onSubmit === void 0) return;
|
|
3311
|
+
event.preventDefault();
|
|
3312
|
+
const ready = [from.isReady(), to.isReady()].every(Boolean);
|
|
3313
|
+
if (ready) onSubmit();
|
|
3314
|
+
};
|
|
3315
|
+
const segment = (side, typed) => /* @__PURE__ */ jsx(
|
|
3316
|
+
"input",
|
|
3317
|
+
{
|
|
3318
|
+
...webA11y,
|
|
3319
|
+
ref: side === "from" /* From */ ? fromRef : void 0,
|
|
3320
|
+
"aria-label": side === "from" /* From */ ? fromLabel : toLabel,
|
|
3321
|
+
autoComplete: "off",
|
|
3322
|
+
"data-testid": `${testID}-${side}`,
|
|
3323
|
+
id: side === "from" /* From */ ? context.controlId : void 0,
|
|
3324
|
+
style: SEGMENT,
|
|
3325
|
+
title: hint,
|
|
3326
|
+
type: "text",
|
|
3327
|
+
value: typed.display,
|
|
3328
|
+
onBlur: (event) => {
|
|
3329
|
+
focus.onBlur?.(event);
|
|
3330
|
+
typed.onBlur();
|
|
3331
|
+
},
|
|
3332
|
+
onChange: (event) => typed.onText(event.target.value),
|
|
3333
|
+
onFocus: (event) => {
|
|
3334
|
+
focus.onFocus?.(event);
|
|
3335
|
+
typed.onFocus();
|
|
3336
|
+
},
|
|
3337
|
+
onKeyDown
|
|
3338
|
+
}
|
|
3339
|
+
);
|
|
3340
|
+
return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: anchorStyles.wrap, children: [
|
|
3341
|
+
/* @__PURE__ */ jsxs("div", { ...hoverBind, style: { ...buildNativeInputStyle(style), display: "flex", alignItems: "center", gap: GAP5, paddingInlineEnd: ICON_ROOM }, children: [
|
|
3342
|
+
segment("from" /* From */, from),
|
|
3343
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2192" }),
|
|
3344
|
+
segment("to" /* To */, to)
|
|
3345
|
+
] }),
|
|
3346
|
+
/* @__PURE__ */ jsx("div", { style: ICON_SLOT, children: /* @__PURE__ */ jsx(IconButton, { accessibilityHint: labels.openCalendarHint, accessibilityLabel: labels.openCalendar, appearance: "ghost", renderIcon: (color) => /* @__PURE__ */ jsx(Glyph, { color, name: "calendar" /* Calendar */ }), testID: `${testID}-calendar`, onPress: () => setOpen((current) => !current) }) }),
|
|
3347
|
+
open ? /* @__PURE__ */ jsx(PickerSurface, { anchorRef, label: labels.rangeDialog, minWidth: RANGE_PICKER_WIDTH, phone, testID: `${testID}-picker`, onDismiss: close, children: /* @__PURE__ */ jsx(
|
|
3348
|
+
RangeCalendar,
|
|
3349
|
+
{
|
|
3350
|
+
bounds: NO_BOUNDS,
|
|
3351
|
+
phone,
|
|
3352
|
+
testID: `${testID}-picker`,
|
|
3353
|
+
value,
|
|
3354
|
+
onApply: (range) => {
|
|
3355
|
+
setFromError(void 0);
|
|
3356
|
+
setToError(void 0);
|
|
3357
|
+
onChange(range);
|
|
3358
|
+
close();
|
|
3359
|
+
},
|
|
3360
|
+
onCancel: close
|
|
3361
|
+
}
|
|
3362
|
+
) }) : null
|
|
3363
|
+
] });
|
|
3364
|
+
}
|
|
3365
|
+
var IS_WEB8 = Platform.OS === "web";
|
|
2365
3366
|
function DateRangeControl({
|
|
2366
3367
|
value,
|
|
2367
3368
|
onChange,
|
|
@@ -2373,30 +3374,12 @@ function DateRangeControl({
|
|
|
2373
3374
|
testID
|
|
2374
3375
|
}) {
|
|
2375
3376
|
const hint = accessibilityHint ?? `${fromLabel} \u2013 ${toLabel}`;
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
testID: `${testID}-from`,
|
|
2383
|
-
value: value.from,
|
|
2384
|
-
onChange: (from) => onChange({ from, to: value.to }),
|
|
2385
|
-
onSubmit
|
|
2386
|
-
}
|
|
2387
|
-
) }),
|
|
2388
|
-
/* @__PURE__ */ jsx(View, { style: controlStyles.dateCol, children: /* @__PURE__ */ jsx(
|
|
2389
|
-
DateField,
|
|
2390
|
-
{
|
|
2391
|
-
accessibilityHint: hint,
|
|
2392
|
-
label: toLabel,
|
|
2393
|
-
testID: `${testID}-to`,
|
|
2394
|
-
value: value.to,
|
|
2395
|
-
onChange: (to) => onChange({ from: value.from, to }),
|
|
2396
|
-
onSubmit
|
|
2397
|
-
}
|
|
2398
|
-
) })
|
|
2399
|
-
] }) });
|
|
3377
|
+
const { labels } = useDatePickerConfig();
|
|
3378
|
+
const [typedError, setTypedError] = useState(void 0);
|
|
3379
|
+
if (!IS_WEB8) {
|
|
3380
|
+
return /* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsx(NativeDateRange, { fromLabel, hint, style, testID, toLabel, value, onChange, onSubmit }) });
|
|
3381
|
+
}
|
|
3382
|
+
return /* @__PURE__ */ jsx(GapOwnedProvider, { value: true, children: /* @__PURE__ */ jsx(View, { style, testID: `${testID}-range`, children: /* @__PURE__ */ jsx(Field, { error: typedError, label: `${fromLabel}${labels.rangeSeparator}${toLabel}`, children: (context) => /* @__PURE__ */ jsx(WebDateRange, { context, fromLabel, hint, testID, toLabel, value, onChange, onSubmit, onTypedError: setTypedError }) }) }) });
|
|
2400
3383
|
}
|
|
2401
3384
|
function DateTimeField(props) {
|
|
2402
3385
|
return /* @__PURE__ */ jsx(TemporalField, { fieldProps: props, webInputType: "datetime-local" });
|
|
@@ -2432,7 +3415,7 @@ var ROW_GAP = 4;
|
|
|
2432
3415
|
var TAB_PADDING = 4;
|
|
2433
3416
|
var INDICATOR_WIDTH = 2;
|
|
2434
3417
|
var TAB_FONT_SIZE = 12;
|
|
2435
|
-
var
|
|
3418
|
+
var styles17 = StyleSheet.create({
|
|
2436
3419
|
row: { flexDirection: "row", flexWrap: "nowrap", gap: ROW_GAP },
|
|
2437
3420
|
tab: {
|
|
2438
3421
|
borderBottomWidth: INDICATOR_WIDTH,
|
|
@@ -2472,13 +3455,13 @@ var StepperTab = ({
|
|
|
2472
3455
|
accessibilityRole: "tab",
|
|
2473
3456
|
accessibilityState: { selected },
|
|
2474
3457
|
"aria-selected": selected,
|
|
2475
|
-
style: [
|
|
3458
|
+
style: [styles17.tab, { borderBottomColor: indicator }, ring.ringStyle],
|
|
2476
3459
|
testID,
|
|
2477
3460
|
onBlur: ring.onBlur,
|
|
2478
3461
|
onFocus: ring.onFocus,
|
|
2479
3462
|
onPress: () => onStep(step.key),
|
|
2480
3463
|
...webKeyProps,
|
|
2481
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
3464
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles17.text, { color: theme.colors.text }, selected ? styles17.textSelected : void 0], children: step.label })
|
|
2482
3465
|
}
|
|
2483
3466
|
);
|
|
2484
3467
|
};
|
|
@@ -2488,7 +3471,7 @@ var StepperTabs = ({
|
|
|
2488
3471
|
onStep,
|
|
2489
3472
|
stepHint,
|
|
2490
3473
|
testID
|
|
2491
|
-
}) => /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", style:
|
|
3474
|
+
}) => /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", style: styles17.row, testID, children: steps.map((step) => /* @__PURE__ */ jsx(
|
|
2492
3475
|
StepperTab,
|
|
2493
3476
|
{
|
|
2494
3477
|
hint: stepHint,
|
|
@@ -2507,7 +3490,7 @@ function resolveStepNeighbours(steps, current) {
|
|
|
2507
3490
|
return { previous: steps[index - 1] ?? null, next: steps[index + 1] ?? null };
|
|
2508
3491
|
}
|
|
2509
3492
|
var ROW_GAP2 = 8;
|
|
2510
|
-
var
|
|
3493
|
+
var styles18 = StyleSheet.create({
|
|
2511
3494
|
cell: { flex: 1, minWidth: 0 },
|
|
2512
3495
|
row: { flexDirection: "row", gap: ROW_GAP2 }
|
|
2513
3496
|
});
|
|
@@ -2519,8 +3502,8 @@ var StepperNav = ({
|
|
|
2519
3502
|
testID
|
|
2520
3503
|
}) => {
|
|
2521
3504
|
const { previous, next } = resolveStepNeighbours(steps, current);
|
|
2522
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
2523
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
3505
|
+
return /* @__PURE__ */ jsxs(View, { style: styles18.row, testID, children: [
|
|
3506
|
+
/* @__PURE__ */ jsx(View, { style: styles18.cell, children: /* @__PURE__ */ jsx(
|
|
2524
3507
|
Button,
|
|
2525
3508
|
{
|
|
2526
3509
|
fullWidth: true,
|
|
@@ -2536,7 +3519,7 @@ var StepperNav = ({
|
|
|
2536
3519
|
}
|
|
2537
3520
|
}
|
|
2538
3521
|
) }),
|
|
2539
|
-
next === null ? null : /* @__PURE__ */ jsx(View, { style:
|
|
3522
|
+
next === null ? null : /* @__PURE__ */ jsx(View, { style: styles18.cell, children: /* @__PURE__ */ jsx(
|
|
2540
3523
|
Button,
|
|
2541
3524
|
{
|
|
2542
3525
|
fullWidth: true,
|
|
@@ -2551,13 +3534,13 @@ var StepperNav = ({
|
|
|
2551
3534
|
] });
|
|
2552
3535
|
};
|
|
2553
3536
|
var STATUS_FONT = 16;
|
|
2554
|
-
var
|
|
3537
|
+
var styles19 = StyleSheet.create({
|
|
2555
3538
|
line: { fontSize: STATUS_FONT }
|
|
2556
3539
|
});
|
|
2557
3540
|
function FormStatusLine({ message, testID, style }) {
|
|
2558
3541
|
const { theme } = useUi();
|
|
2559
3542
|
if (message === null || message === void 0 || message === "") return null;
|
|
2560
|
-
return /* @__PURE__ */ jsx(Text, { role: "alert", style: [
|
|
3543
|
+
return /* @__PURE__ */ jsx(Text, { role: "alert", style: [styles19.line, { color: theme.colors.text }, style], testID, children: message });
|
|
2561
3544
|
}
|
|
2562
3545
|
function useFocusFirstInvalid(refs) {
|
|
2563
3546
|
const latest = useRef(refs);
|
|
@@ -2581,13 +3564,13 @@ function useKeepInView(trigger) {
|
|
|
2581
3564
|
}
|
|
2582
3565
|
var DEFAULT_PREVIEW_PX = 48;
|
|
2583
3566
|
var PREVIEW_RADIUS = 8;
|
|
2584
|
-
var
|
|
3567
|
+
var GAP6 = 8;
|
|
2585
3568
|
var TITLE_FONT_SIZE = 14;
|
|
2586
3569
|
var HELP_FONT_SIZE = 13;
|
|
2587
|
-
var
|
|
3570
|
+
var styles20 = StyleSheet.create({
|
|
2588
3571
|
help: { flex: 1, fontSize: HELP_FONT_SIZE },
|
|
2589
|
-
root: { gap:
|
|
2590
|
-
tile: { alignItems: "center", flexDirection: "row", gap:
|
|
3572
|
+
root: { gap: GAP6 },
|
|
3573
|
+
tile: { alignItems: "center", flexDirection: "row", gap: GAP6 },
|
|
2591
3574
|
title: { fontSize: TITLE_FONT_SIZE, fontWeight: "700" },
|
|
2592
3575
|
toggle: { alignSelf: "flex-start", justifyContent: "center", minHeight: MIN_TOUCH_TARGET_PX },
|
|
2593
3576
|
toggleText: { fontSize: TITLE_FONT_SIZE, fontWeight: "700", textDecorationLine: "underline" }
|
|
@@ -2606,11 +3589,11 @@ var UploadWithLinkField = ({
|
|
|
2606
3589
|
const url = value ?? "";
|
|
2607
3590
|
const [pasting, setPasting] = useState(url !== "");
|
|
2608
3591
|
const previewBox = { borderRadius: PREVIEW_RADIUS, height: previewSize, width: previewSize };
|
|
2609
|
-
return /* @__PURE__ */ jsxs(View, { style:
|
|
2610
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
2611
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
3592
|
+
return /* @__PURE__ */ jsxs(View, { style: styles20.root, children: [
|
|
3593
|
+
/* @__PURE__ */ jsx(Text, { style: [styles20.title, { color: theme.colors.text }], children: labels.title }),
|
|
3594
|
+
/* @__PURE__ */ jsxs(View, { style: styles20.tile, children: [
|
|
2612
3595
|
url === "" ? /* @__PURE__ */ jsx(View, { style: [previewBox, { backgroundColor: theme.colors.border }] }) : /* @__PURE__ */ jsx(Image, { accessible: false, source: { uri: url }, style: previewBox, testID: `${testID}-preview` }),
|
|
2613
|
-
labels.help === void 0 ? null : /* @__PURE__ */ jsx(Text, { style: [
|
|
3596
|
+
labels.help === void 0 ? null : /* @__PURE__ */ jsx(Text, { style: [styles20.help, { color: theme.colors.text }], children: labels.help })
|
|
2614
3597
|
] }),
|
|
2615
3598
|
uploadControl,
|
|
2616
3599
|
/* @__PURE__ */ jsx(
|
|
@@ -2621,12 +3604,12 @@ var UploadWithLinkField = ({
|
|
|
2621
3604
|
accessibilityRole: "button",
|
|
2622
3605
|
accessibilityState: { expanded: pasting },
|
|
2623
3606
|
"aria-expanded": pasting,
|
|
2624
|
-
style: [
|
|
3607
|
+
style: [styles20.toggle, ring.ringStyle],
|
|
2625
3608
|
testID: `${testID}-paste`,
|
|
2626
3609
|
onBlur: ring.onBlur,
|
|
2627
3610
|
onFocus: ring.onFocus,
|
|
2628
3611
|
onPress: () => setPasting(!pasting),
|
|
2629
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
3612
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles20.toggleText, { color: theme.colors.text }], children: labels.pasteToggle })
|
|
2630
3613
|
}
|
|
2631
3614
|
),
|
|
2632
3615
|
pasting ? /* @__PURE__ */ jsx(
|
|
@@ -2645,7 +3628,7 @@ var UploadWithLinkField = ({
|
|
|
2645
3628
|
};
|
|
2646
3629
|
var ACTION_GAP = 8;
|
|
2647
3630
|
var GROUP_GAP = 16;
|
|
2648
|
-
var
|
|
3631
|
+
var styles21 = StyleSheet.create({
|
|
2649
3632
|
action: { alignItems: "flex-start", marginTop: ACTION_GAP },
|
|
2650
3633
|
group: { marginBottom: GROUP_GAP }
|
|
2651
3634
|
});
|
|
@@ -2668,7 +3651,7 @@ var AddOnRequest = ({
|
|
|
2668
3651
|
onRemove();
|
|
2669
3652
|
};
|
|
2670
3653
|
if (!isAddOnOpen(hasValue, requested))
|
|
2671
|
-
return /* @__PURE__ */ jsx(View, { style: [
|
|
3654
|
+
return /* @__PURE__ */ jsx(View, { style: [styles21.action, style], children: /* @__PURE__ */ jsx(
|
|
2672
3655
|
Button,
|
|
2673
3656
|
{
|
|
2674
3657
|
accessibilityHint: addHint,
|
|
@@ -2680,9 +3663,9 @@ var AddOnRequest = ({
|
|
|
2680
3663
|
onPress: () => setRequested(true)
|
|
2681
3664
|
}
|
|
2682
3665
|
) });
|
|
2683
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
3666
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles21.group, style], testID, children: [
|
|
2684
3667
|
children,
|
|
2685
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
3668
|
+
/* @__PURE__ */ jsx(View, { style: styles21.action, children: /* @__PURE__ */ jsx(
|
|
2686
3669
|
Button,
|
|
2687
3670
|
{
|
|
2688
3671
|
accessibilityHint: removeHint,
|
|
@@ -2699,7 +3682,7 @@ var AddOnRequest = ({
|
|
|
2699
3682
|
var ROW_GAP3 = 8;
|
|
2700
3683
|
var TEXT_SIZE = 13;
|
|
2701
3684
|
var TEXT_LINE = 18;
|
|
2702
|
-
var
|
|
3685
|
+
var styles22 = StyleSheet.create({
|
|
2703
3686
|
row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
|
|
2704
3687
|
text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
|
|
2705
3688
|
});
|
|
@@ -2707,8 +3690,8 @@ var isFixBarVisible = (count) => count > 0;
|
|
|
2707
3690
|
var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
|
|
2708
3691
|
const { theme } = useUi();
|
|
2709
3692
|
if (!isFixBarVisible(count)) return null;
|
|
2710
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
2711
|
-
/* @__PURE__ */ jsx(Text, { role: "alert", style: [
|
|
3693
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles22.row, style], testID, children: [
|
|
3694
|
+
/* @__PURE__ */ jsx(Text, { role: "alert", style: [styles22.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
|
|
2712
3695
|
/* @__PURE__ */ jsx(
|
|
2713
3696
|
Button,
|
|
2714
3697
|
{
|
|
@@ -2729,55 +3712,6 @@ var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
|
2729
3712
|
SelectSurface2["Dropdown"] = "dropdown";
|
|
2730
3713
|
return SelectSurface2;
|
|
2731
3714
|
})(SelectSurface || {});
|
|
2732
|
-
function useAnchorRect2(anchorRef) {
|
|
2733
|
-
const [rect2, setRect] = useState(null);
|
|
2734
|
-
useEffect(() => {
|
|
2735
|
-
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2736
|
-
}, [anchorRef]);
|
|
2737
|
-
return rect2;
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
// src/SearchSelect/DropdownPlacement.ts
|
|
2741
|
-
var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
|
|
2742
|
-
DropdownPlacement2["Below"] = "below";
|
|
2743
|
-
DropdownPlacement2["Above"] = "above";
|
|
2744
|
-
return DropdownPlacement2;
|
|
2745
|
-
})(DropdownPlacement || {});
|
|
2746
|
-
|
|
2747
|
-
// src/SearchSelect/utils/dropdownFrame.ts
|
|
2748
|
-
var MIN_PANEL_WIDTH = 240;
|
|
2749
|
-
var EDGE = 8;
|
|
2750
|
-
function placeDropdown(anchor, panelHeight, viewportHeight) {
|
|
2751
|
-
const roomBelow = viewportHeight - (anchor.y + anchor.height);
|
|
2752
|
-
if (roomBelow >= panelHeight) return "below" /* Below */;
|
|
2753
|
-
return anchor.y > roomBelow ? "above" /* Above */ : "below" /* Below */;
|
|
2754
|
-
}
|
|
2755
|
-
function dropdownFrame(anchor, panelHeight, viewportHeight) {
|
|
2756
|
-
const placement = placeDropdown(anchor, panelHeight, viewportHeight);
|
|
2757
|
-
const base = { placement, left: anchor.x, width: anchor.width };
|
|
2758
|
-
if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - anchor.y };
|
|
2759
|
-
return { ...base, top: anchor.y + anchor.height };
|
|
2760
|
-
}
|
|
2761
|
-
function fitDropdownWidth(frame, viewportWidth) {
|
|
2762
|
-
const width = Math.max(frame.width, Math.min(MIN_PANEL_WIDTH, viewportWidth - EDGE - EDGE));
|
|
2763
|
-
const left = Math.max(EDGE, Math.min(frame.left, viewportWidth - width - EDGE));
|
|
2764
|
-
return { ...frame, width, left: frame.width >= width ? frame.left : left };
|
|
2765
|
-
}
|
|
2766
|
-
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2767
|
-
const { height: viewportHeight, width: viewportWidth } = useWindowDimensions();
|
|
2768
|
-
const anchor = useAnchorRect2(anchorRef);
|
|
2769
|
-
const [panelHeight, setPanelHeight] = useState(0);
|
|
2770
|
-
const onLayout = useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2771
|
-
const frame = anchor === null ? null : fitDropdownWidth(dropdownFrame(anchor, panelHeight, viewportHeight), viewportWidth);
|
|
2772
|
-
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2773
|
-
return /* @__PURE__ */ jsxs(Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: [
|
|
2774
|
-
/* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2775
|
-
frame !== null ? /* @__PURE__ */ jsx(Animated.View, { style: [styles21.dropdown, place, { opacity: progress, transform: [{ translateY }] }], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
|
|
2776
|
-
] });
|
|
2777
|
-
}
|
|
2778
|
-
var styles21 = StyleSheet.create({
|
|
2779
|
-
dropdown: { position: "absolute" }
|
|
2780
|
-
});
|
|
2781
3715
|
var ROW_PAD_H = 12;
|
|
2782
3716
|
var ROW_GAP4 = 8;
|
|
2783
3717
|
var OPTION_FONT2 = 14;
|
|
@@ -2795,21 +3729,21 @@ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPi
|
|
|
2795
3729
|
accessibilityLabel: option.label,
|
|
2796
3730
|
accessibilityRole: "button",
|
|
2797
3731
|
accessibilityState: { selected: active, checked: current },
|
|
2798
|
-
style: [
|
|
3732
|
+
style: [styles23.row, active ? { backgroundColor: colors.surface } : null],
|
|
2799
3733
|
testID: `${testID}-option-${option.value}`,
|
|
2800
3734
|
onPress: () => onPick(option),
|
|
2801
3735
|
children: [
|
|
2802
3736
|
renderLeading?.(option),
|
|
2803
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2804
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
2805
|
-
detailBelow ? /* @__PURE__ */ jsx(Text, { style: [
|
|
3737
|
+
/* @__PURE__ */ jsxs(View, { style: styles23.label, children: [
|
|
3738
|
+
/* @__PURE__ */ jsx(Text, { style: [styles23.primary, { color: colors.text }], children: option.label }),
|
|
3739
|
+
detailBelow ? /* @__PURE__ */ jsx(Text, { style: [styles23.secondary, { color: colors.textSecondary }], children: option.detail }) : null
|
|
2806
3740
|
] }),
|
|
2807
3741
|
renderDetail?.(option)
|
|
2808
3742
|
]
|
|
2809
3743
|
}
|
|
2810
3744
|
);
|
|
2811
3745
|
}
|
|
2812
|
-
var
|
|
3746
|
+
var styles23 = StyleSheet.create({
|
|
2813
3747
|
row: { minHeight: MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
|
|
2814
3748
|
label: { flex: 1 },
|
|
2815
3749
|
primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
|
|
@@ -2823,26 +3757,17 @@ function OptionSection({ title, options, offset, highlight, selectedValue, ...ro
|
|
|
2823
3757
|
const { colors } = theme;
|
|
2824
3758
|
if (options.length === 0) return null;
|
|
2825
3759
|
return /* @__PURE__ */ jsxs(View, { children: [
|
|
2826
|
-
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [
|
|
3760
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles24.header, { color: colors.textSecondary }], children: title }),
|
|
2827
3761
|
options.map((option, index) => /* @__PURE__ */ jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
|
|
2828
3762
|
] });
|
|
2829
3763
|
}
|
|
2830
|
-
var styles23 = StyleSheet.create({
|
|
2831
|
-
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
2832
|
-
});
|
|
2833
|
-
function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2834
|
-
return /* @__PURE__ */ jsx(Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: /* @__PURE__ */ jsxs(View, { style: styles24.backdrop, children: [
|
|
2835
|
-
/* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2836
|
-
/* @__PURE__ */ jsx(Animated.View, { style: { transform: [{ translateY }] }, children })
|
|
2837
|
-
] }) });
|
|
2838
|
-
}
|
|
2839
3764
|
var styles24 = StyleSheet.create({
|
|
2840
|
-
|
|
3765
|
+
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
2841
3766
|
});
|
|
2842
3767
|
var KEY_ESCAPE = "Escape";
|
|
2843
3768
|
var PANEL_PAD = 8;
|
|
2844
3769
|
var PANEL_RADIUS = 8;
|
|
2845
|
-
var
|
|
3770
|
+
var SHEET_MAX_HEIGHT2 = 480;
|
|
2846
3771
|
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
2847
3772
|
const { theme } = useUi();
|
|
2848
3773
|
const { colors } = theme;
|
|
@@ -2895,24 +3820,9 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
|
|
|
2895
3820
|
var styles25 = StyleSheet.create({
|
|
2896
3821
|
panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
|
|
2897
3822
|
dropList: { maxHeight: MENU_MAX_HEIGHT },
|
|
2898
|
-
sheetList: { maxHeight:
|
|
3823
|
+
sheetList: { maxHeight: SHEET_MAX_HEIGHT2 },
|
|
2899
3824
|
empty: { padding: PANEL_PAD }
|
|
2900
3825
|
});
|
|
2901
|
-
function useReducedMotion() {
|
|
2902
|
-
const [reduced, setReduced] = useState(false);
|
|
2903
|
-
useEffect(() => {
|
|
2904
|
-
let active = true;
|
|
2905
|
-
AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2906
|
-
if (active) setReduced(value);
|
|
2907
|
-
}).catch(() => void 0);
|
|
2908
|
-
const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
|
|
2909
|
-
return () => {
|
|
2910
|
-
active = false;
|
|
2911
|
-
subscription.remove();
|
|
2912
|
-
};
|
|
2913
|
-
}, []);
|
|
2914
|
-
return reduced;
|
|
2915
|
-
}
|
|
2916
3826
|
function useRefocusOnClose(open, ref) {
|
|
2917
3827
|
const wasOpen = useRef(false);
|
|
2918
3828
|
useEffect(() => {
|
|
@@ -4021,7 +4931,7 @@ var FONT_SIZE = 14;
|
|
|
4021
4931
|
var LINE_HEIGHT = 20;
|
|
4022
4932
|
var COUNTER_FONT = 12;
|
|
4023
4933
|
var BRANCH_OPACITY = 0.5;
|
|
4024
|
-
var
|
|
4934
|
+
var GAP7 = 8;
|
|
4025
4935
|
var INPUT_PAD_V2 = 13;
|
|
4026
4936
|
var ghostStyles = StyleSheet.create({
|
|
4027
4937
|
field: { flex: 1, justifyContent: "center", minHeight: LINE_HEIGHT },
|
|
@@ -4031,7 +4941,7 @@ var ghostStyles = StyleSheet.create({
|
|
|
4031
4941
|
branch: { opacity: BRANCH_OPACITY },
|
|
4032
4942
|
input: { padding: 0, paddingVertical: INPUT_PAD_V2, borderWidth: 0, minHeight: LINE_HEIGHT },
|
|
4033
4943
|
trigger: { paddingVertical: 0 },
|
|
4034
|
-
counter: { fontSize: COUNTER_FONT, marginLeft:
|
|
4944
|
+
counter: { fontSize: COUNTER_FONT, marginLeft: GAP7 }
|
|
4035
4945
|
});
|
|
4036
4946
|
|
|
4037
4947
|
// src/IbanInput/data/IbanRejection.ts
|
|
@@ -4302,14 +5212,14 @@ var DOT_INNER = 8;
|
|
|
4302
5212
|
var ROW_GAP6 = 10;
|
|
4303
5213
|
var PAD_H2 = 12;
|
|
4304
5214
|
var PAD_V2 = 8;
|
|
4305
|
-
var
|
|
5215
|
+
var RADIUS2 = 8;
|
|
4306
5216
|
var LABEL_SIZE = 14;
|
|
4307
5217
|
var DESCRIPTION_SIZE = 12;
|
|
4308
5218
|
var DESCRIPTION_LINE = 16;
|
|
4309
5219
|
var styles31 = StyleSheet.create({
|
|
4310
5220
|
row: {
|
|
4311
5221
|
alignItems: "center",
|
|
4312
|
-
borderRadius:
|
|
5222
|
+
borderRadius: RADIUS2,
|
|
4313
5223
|
borderWidth: 1,
|
|
4314
5224
|
columnGap: ROW_GAP6,
|
|
4315
5225
|
flexDirection: "row",
|
|
@@ -4368,7 +5278,7 @@ var styles32 = StyleSheet.create({
|
|
|
4368
5278
|
function RadioList(props) {
|
|
4369
5279
|
const { options, value, onChange, optionTestIDPrefix, label, error, required = false, disabled = false, testID } = props;
|
|
4370
5280
|
const { theme } = useUi();
|
|
4371
|
-
const colors =
|
|
5281
|
+
const colors = React37.useMemo(() => buildChipColors(theme.colors, theme.palette), [theme.colors, theme.palette]);
|
|
4372
5282
|
const selectedIndex = options.findIndex((option) => option.value === value);
|
|
4373
5283
|
const radio = useRadioKeyboard({ enabled: true, disabled, values: options.map((option) => option.value), selectedIndex, onChange });
|
|
4374
5284
|
return /* @__PURE__ */ jsx(Field, { error, label, required, testID, children: ({ describedById, hasError }) => /* @__PURE__ */ jsx(
|
|
@@ -4523,12 +5433,12 @@ var SubmitError = ({ message, testID }) => {
|
|
|
4523
5433
|
};
|
|
4524
5434
|
var toggle = (list, id) => list.includes(id) ? list.filter((item) => item !== id) : [...list, id];
|
|
4525
5435
|
function useDecisionPanel(outcomes, onSubmit) {
|
|
4526
|
-
const [outcome, setOutcome] =
|
|
4527
|
-
const [note, setNote] =
|
|
4528
|
-
const [reasons, setReasons] =
|
|
4529
|
-
const [checked, setChecked] =
|
|
4530
|
-
const [error, setError] =
|
|
4531
|
-
const [pending, setPending] =
|
|
5436
|
+
const [outcome, setOutcome] = React37.useState("");
|
|
5437
|
+
const [note, setNote] = React37.useState("");
|
|
5438
|
+
const [reasons, setReasons] = React37.useState([]);
|
|
5439
|
+
const [checked, setChecked] = React37.useState([]);
|
|
5440
|
+
const [error, setError] = React37.useState(null);
|
|
5441
|
+
const [pending, setPending] = React37.useState(null);
|
|
4532
5442
|
const submit = async (override) => {
|
|
4533
5443
|
const target = override ?? outcome;
|
|
4534
5444
|
const problem = validateDecision(outcomes, target, note);
|
|
@@ -4583,6 +5493,6 @@ function DecisionPanel(props) {
|
|
|
4583
5493
|
] });
|
|
4584
5494
|
}
|
|
4585
5495
|
|
|
4586
|
-
export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, buildSearchSelectSections, canRemoveLine, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateDecision, validateIban };
|
|
5496
|
+
export { ActionBar, AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipLabelWrap, ChipSelector, CountryField, CountryFlag, DEFAULT_DATE_PICKER_LABELS, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DatePickerProvider, DateRangeControl, DateTimeField, DecisionPanel, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, GatedChecklist, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, LINE_ITEMS_WIDE_MIN_WIDTH, LineItems, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, RadioList, ResponsiveFormLayout, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, actionBarPosition, buildSearchSelectSections, canRemoveLine, controlStyles, countryFieldOptions, countryFlag, countryOptions, defaultDecisionVariant, draftBic, draftIban, dropdownFrame, findOption, fitDropdownWidth, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isChecklistComplete, isFallbackFlag, isFixBarVisible, isLineItemsWide, isOutside, isUnmatched, isWideFormLayout, leadFirst, lineItemColumnFlex, lineNumberOf, moveHighlight, nextHighlight, placeDropdown, radioRowIdentity, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateDecision, validateIban };
|
|
4587
5497
|
//# sourceMappingURL=index.mjs.map
|
|
4588
5498
|
//# sourceMappingURL=index.mjs.map
|