@dloizides/ui-forms 1.33.0 → 1.34.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 +50 -14
- package/dist/index.d.ts +50 -14
- package/dist/index.js +156 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1360,6 +1360,34 @@ declare function isOutside(container: unknown, target: EventTarget | null): bool
|
|
|
1360
1360
|
/** On web, calls `onOutside` for a pointer press that starts outside the view behind `ref`. */
|
|
1361
1361
|
declare function useOutsidePress(ref: RefObject<View | null>, onOutside: () => void): void;
|
|
1362
1362
|
|
|
1363
|
+
declare enum DropdownPlacement {
|
|
1364
|
+
Below = "below",
|
|
1365
|
+
Above = "above"
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
interface AnchorRect {
|
|
1369
|
+
x: number;
|
|
1370
|
+
y: number;
|
|
1371
|
+
width: number;
|
|
1372
|
+
height: number;
|
|
1373
|
+
}
|
|
1374
|
+
interface DropdownFrame {
|
|
1375
|
+
placement: DropdownPlacement;
|
|
1376
|
+
left: number;
|
|
1377
|
+
width: number;
|
|
1378
|
+
top?: number;
|
|
1379
|
+
bottom?: number;
|
|
1380
|
+
}
|
|
1381
|
+
/** Opens below when the list fits there, else on whichever side has more room. */
|
|
1382
|
+
declare function placeDropdown(anchor: AnchorRect, panelHeight: number, viewportHeight: number): DropdownPlacement;
|
|
1383
|
+
/** The window frame for the list next to `anchor`, on the side `placeDropdown` picks. */
|
|
1384
|
+
declare function dropdownFrame(anchor: AnchorRect, panelHeight: number, viewportHeight: number): DropdownFrame;
|
|
1385
|
+
|
|
1386
|
+
/** Focuses `ref` on the next tick, after the closing list surface has left the page. */
|
|
1387
|
+
declare function useDeferredFocus(ref: RefObject<{
|
|
1388
|
+
focus: () => void;
|
|
1389
|
+
} | null>): () => void;
|
|
1390
|
+
|
|
1363
1391
|
interface CountryFlagProps {
|
|
1364
1392
|
code: string;
|
|
1365
1393
|
testID?: string;
|
|
@@ -1439,18 +1467,6 @@ interface IbanVerdict {
|
|
|
1439
1467
|
/** Validates an IBAN with the same rules as `Finreg.Core.Banking.Iban.Validate`. */
|
|
1440
1468
|
declare function validateIban(raw: string | null | undefined): IbanVerdict;
|
|
1441
1469
|
|
|
1442
|
-
interface IbanInputProps {
|
|
1443
|
-
value: string;
|
|
1444
|
-
onChange: (electronic: string) => void;
|
|
1445
|
-
onVerdict?: (verdict: IbanVerdict | null) => void;
|
|
1446
|
-
accessibilityLabel: string;
|
|
1447
|
-
accessibilityHint: string;
|
|
1448
|
-
testID: string;
|
|
1449
|
-
placeholder?: string;
|
|
1450
|
-
}
|
|
1451
|
-
/** An IBAN box that groups in fours as you type, stores no spaces and validates on leave. */
|
|
1452
|
-
declare function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, placeholder }: IbanInputProps): React.ReactElement;
|
|
1453
|
-
|
|
1454
1470
|
/** Why a BIC was refused; member names match `Finreg.Core.Banking.BicRejection`. */
|
|
1455
1471
|
declare enum BicRejection {
|
|
1456
1472
|
None = "None",
|
|
@@ -1462,6 +1478,22 @@ declare enum BicRejection {
|
|
|
1462
1478
|
MalformedLocation = "MalformedLocation"
|
|
1463
1479
|
}
|
|
1464
1480
|
|
|
1481
|
+
type IbanRejectionLabels = Readonly<Record<Exclude<IbanRejection, IbanRejection.None>, string>>;
|
|
1482
|
+
type BicRejectionLabels = Readonly<Record<Exclude<BicRejection, BicRejection.None>, string>>;
|
|
1483
|
+
|
|
1484
|
+
interface IbanInputProps {
|
|
1485
|
+
value: string;
|
|
1486
|
+
onChange: (electronic: string) => void;
|
|
1487
|
+
onVerdict?: (verdict: IbanVerdict | null) => void;
|
|
1488
|
+
accessibilityLabel: string;
|
|
1489
|
+
accessibilityHint: string;
|
|
1490
|
+
testID: string;
|
|
1491
|
+
rejectionLabels?: IbanRejectionLabels;
|
|
1492
|
+
placeholder?: string;
|
|
1493
|
+
}
|
|
1494
|
+
/** An IBAN box that groups in fours as you type, stores no spaces and validates on leave. */
|
|
1495
|
+
declare function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder }: IbanInputProps): React.ReactElement;
|
|
1496
|
+
|
|
1465
1497
|
/** The outcome of validating one BIC; `electronic` (upper case, trimmed) is set only when valid. */
|
|
1466
1498
|
interface BicVerdict {
|
|
1467
1499
|
readonly rejection: BicRejection;
|
|
@@ -1477,9 +1509,10 @@ interface BicInputProps {
|
|
|
1477
1509
|
accessibilityLabel: string;
|
|
1478
1510
|
accessibilityHint: string;
|
|
1479
1511
|
testID: string;
|
|
1512
|
+
rejectionLabels?: BicRejectionLabels;
|
|
1480
1513
|
}
|
|
1481
1514
|
/** A BIC box that upper-cases as you type, ghosts the optional branch and validates on leave. */
|
|
1482
|
-
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID }: BicInputProps): React.ReactElement;
|
|
1515
|
+
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }: BicInputProps): React.ReactElement;
|
|
1483
1516
|
|
|
1484
1517
|
/** The longest IBAN ISO 13616 permits. */
|
|
1485
1518
|
declare const IBAN_MAX_LENGTH = 34;
|
|
@@ -1521,4 +1554,7 @@ interface BlurVerdict<T> {
|
|
|
1521
1554
|
/** Runs `validate` on leave only, so an error never shows while typing. */
|
|
1522
1555
|
declare function useBlurVerdict<T>(validate: () => T): BlurVerdict<T>;
|
|
1523
1556
|
|
|
1524
|
-
|
|
1557
|
+
/** The pre-localized message for a refusal, or null when there is no verdict, it passed, or no labels were given. */
|
|
1558
|
+
declare function rejectionMessage<R extends string, N extends R>(rejection: R | null, none: N, labels: Readonly<Record<Exclude<R, N>, string>> | undefined): string | null;
|
|
1559
|
+
|
|
1560
|
+
export { AddOnRequest, type AddOnRequestProps, AlignToControl, type AlignToControlProps, type AnchorRect, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuPlacement, type AnchoredMenuProps, type BicDraft, BicInput, type BicInputProps, BicRejection, type BicRejectionLabels, type BicVerdict, type BlurVerdict, COUNTRIES, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, type Country, CountryField, type CountryFieldProps, CountryFlag, type CountryFlagProps, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateInput, type DateInputProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, type DropdownFrame, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, FixBar, type FixBarProps, type FlagShape, FlagShapeKind, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStack, type FormStackProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, type IbanDraft, IbanInput, type IbanInputProps, IbanRejection, type IbanRejectionLabels, type IbanVerdict, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, type RecentValues, ResponsiveFormLayout, type ResponsiveFormLayoutProps, SearchSelect, type SearchSelectLabels, type SearchSelectProps, type SearchSelectSections, type SearchSelectState, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type SelectMenuAnchor, type SelectMotion, SelectSurface, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, buildSearchSelectSections, controlStyles, countryFlag, countryOptions, draftBic, draftIban, dropdownFrame, findOption, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isFallbackFlag, isFixBarVisible, isOutside, isUnmatched, isWideFormLayout, moveHighlight, nextHighlight, placeDropdown, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateIban };
|
package/dist/index.d.ts
CHANGED
|
@@ -1360,6 +1360,34 @@ declare function isOutside(container: unknown, target: EventTarget | null): bool
|
|
|
1360
1360
|
/** On web, calls `onOutside` for a pointer press that starts outside the view behind `ref`. */
|
|
1361
1361
|
declare function useOutsidePress(ref: RefObject<View | null>, onOutside: () => void): void;
|
|
1362
1362
|
|
|
1363
|
+
declare enum DropdownPlacement {
|
|
1364
|
+
Below = "below",
|
|
1365
|
+
Above = "above"
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
interface AnchorRect {
|
|
1369
|
+
x: number;
|
|
1370
|
+
y: number;
|
|
1371
|
+
width: number;
|
|
1372
|
+
height: number;
|
|
1373
|
+
}
|
|
1374
|
+
interface DropdownFrame {
|
|
1375
|
+
placement: DropdownPlacement;
|
|
1376
|
+
left: number;
|
|
1377
|
+
width: number;
|
|
1378
|
+
top?: number;
|
|
1379
|
+
bottom?: number;
|
|
1380
|
+
}
|
|
1381
|
+
/** Opens below when the list fits there, else on whichever side has more room. */
|
|
1382
|
+
declare function placeDropdown(anchor: AnchorRect, panelHeight: number, viewportHeight: number): DropdownPlacement;
|
|
1383
|
+
/** The window frame for the list next to `anchor`, on the side `placeDropdown` picks. */
|
|
1384
|
+
declare function dropdownFrame(anchor: AnchorRect, panelHeight: number, viewportHeight: number): DropdownFrame;
|
|
1385
|
+
|
|
1386
|
+
/** Focuses `ref` on the next tick, after the closing list surface has left the page. */
|
|
1387
|
+
declare function useDeferredFocus(ref: RefObject<{
|
|
1388
|
+
focus: () => void;
|
|
1389
|
+
} | null>): () => void;
|
|
1390
|
+
|
|
1363
1391
|
interface CountryFlagProps {
|
|
1364
1392
|
code: string;
|
|
1365
1393
|
testID?: string;
|
|
@@ -1439,18 +1467,6 @@ interface IbanVerdict {
|
|
|
1439
1467
|
/** Validates an IBAN with the same rules as `Finreg.Core.Banking.Iban.Validate`. */
|
|
1440
1468
|
declare function validateIban(raw: string | null | undefined): IbanVerdict;
|
|
1441
1469
|
|
|
1442
|
-
interface IbanInputProps {
|
|
1443
|
-
value: string;
|
|
1444
|
-
onChange: (electronic: string) => void;
|
|
1445
|
-
onVerdict?: (verdict: IbanVerdict | null) => void;
|
|
1446
|
-
accessibilityLabel: string;
|
|
1447
|
-
accessibilityHint: string;
|
|
1448
|
-
testID: string;
|
|
1449
|
-
placeholder?: string;
|
|
1450
|
-
}
|
|
1451
|
-
/** An IBAN box that groups in fours as you type, stores no spaces and validates on leave. */
|
|
1452
|
-
declare function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, placeholder }: IbanInputProps): React.ReactElement;
|
|
1453
|
-
|
|
1454
1470
|
/** Why a BIC was refused; member names match `Finreg.Core.Banking.BicRejection`. */
|
|
1455
1471
|
declare enum BicRejection {
|
|
1456
1472
|
None = "None",
|
|
@@ -1462,6 +1478,22 @@ declare enum BicRejection {
|
|
|
1462
1478
|
MalformedLocation = "MalformedLocation"
|
|
1463
1479
|
}
|
|
1464
1480
|
|
|
1481
|
+
type IbanRejectionLabels = Readonly<Record<Exclude<IbanRejection, IbanRejection.None>, string>>;
|
|
1482
|
+
type BicRejectionLabels = Readonly<Record<Exclude<BicRejection, BicRejection.None>, string>>;
|
|
1483
|
+
|
|
1484
|
+
interface IbanInputProps {
|
|
1485
|
+
value: string;
|
|
1486
|
+
onChange: (electronic: string) => void;
|
|
1487
|
+
onVerdict?: (verdict: IbanVerdict | null) => void;
|
|
1488
|
+
accessibilityLabel: string;
|
|
1489
|
+
accessibilityHint: string;
|
|
1490
|
+
testID: string;
|
|
1491
|
+
rejectionLabels?: IbanRejectionLabels;
|
|
1492
|
+
placeholder?: string;
|
|
1493
|
+
}
|
|
1494
|
+
/** An IBAN box that groups in fours as you type, stores no spaces and validates on leave. */
|
|
1495
|
+
declare function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder }: IbanInputProps): React.ReactElement;
|
|
1496
|
+
|
|
1465
1497
|
/** The outcome of validating one BIC; `electronic` (upper case, trimmed) is set only when valid. */
|
|
1466
1498
|
interface BicVerdict {
|
|
1467
1499
|
readonly rejection: BicRejection;
|
|
@@ -1477,9 +1509,10 @@ interface BicInputProps {
|
|
|
1477
1509
|
accessibilityLabel: string;
|
|
1478
1510
|
accessibilityHint: string;
|
|
1479
1511
|
testID: string;
|
|
1512
|
+
rejectionLabels?: BicRejectionLabels;
|
|
1480
1513
|
}
|
|
1481
1514
|
/** A BIC box that upper-cases as you type, ghosts the optional branch and validates on leave. */
|
|
1482
|
-
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID }: BicInputProps): React.ReactElement;
|
|
1515
|
+
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }: BicInputProps): React.ReactElement;
|
|
1483
1516
|
|
|
1484
1517
|
/** The longest IBAN ISO 13616 permits. */
|
|
1485
1518
|
declare const IBAN_MAX_LENGTH = 34;
|
|
@@ -1521,4 +1554,7 @@ interface BlurVerdict<T> {
|
|
|
1521
1554
|
/** Runs `validate` on leave only, so an error never shows while typing. */
|
|
1522
1555
|
declare function useBlurVerdict<T>(validate: () => T): BlurVerdict<T>;
|
|
1523
1556
|
|
|
1524
|
-
|
|
1557
|
+
/** The pre-localized message for a refusal, or null when there is no verdict, it passed, or no labels were given. */
|
|
1558
|
+
declare function rejectionMessage<R extends string, N extends R>(rejection: R | null, none: N, labels: Readonly<Record<Exclude<R, N>, string>> | undefined): string | null;
|
|
1559
|
+
|
|
1560
|
+
export { AddOnRequest, type AddOnRequestProps, AlignToControl, type AlignToControlProps, type AnchorRect, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuPlacement, type AnchoredMenuProps, type BicDraft, BicInput, type BicInputProps, BicRejection, type BicRejectionLabels, type BicVerdict, type BlurVerdict, COUNTRIES, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, type Country, CountryField, type CountryFieldProps, CountryFlag, type CountryFlagProps, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateInput, type DateInputProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, type DropdownFrame, DropdownPlacement, FLAG_HEIGHT, FLAG_WIDTH, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, FixBar, type FixBarProps, type FlagShape, FlagShapeKind, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStack, type FormStackProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, type IbanDraft, IbanInput, type IbanInputProps, IbanRejection, type IbanRejectionLabels, type IbanVerdict, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, type RecentValues, ResponsiveFormLayout, type ResponsiveFormLayoutProps, SearchSelect, type SearchSelectLabels, type SearchSelectProps, type SearchSelectSections, type SearchSelectState, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type SelectMenuAnchor, type SelectMotion, SelectSurface, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, buildSearchSelectSections, controlStyles, countryFlag, countryOptions, draftBic, draftIban, dropdownFrame, findOption, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isFallbackFlag, isFixBarVisible, isOutside, isUnmatched, isWideFormLayout, moveHighlight, nextHighlight, placeDropdown, rejectionMessage, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useDeferredFocus, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateIban };
|
package/dist/index.js
CHANGED
|
@@ -2568,30 +2568,47 @@ var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
|
2568
2568
|
SelectSurface2["Dropdown"] = "dropdown";
|
|
2569
2569
|
return SelectSurface2;
|
|
2570
2570
|
})(SelectSurface || {});
|
|
2571
|
-
function
|
|
2572
|
-
|
|
2573
|
-
}
|
|
2574
|
-
function isOutside(container, target) {
|
|
2575
|
-
if (!isContainer(container)) return false;
|
|
2576
|
-
return !(target instanceof Node && container.contains(target));
|
|
2577
|
-
}
|
|
2578
|
-
function useOutsidePress(ref, onOutside) {
|
|
2571
|
+
function useAnchorRect2(anchorRef) {
|
|
2572
|
+
const [rect2, setRect] = React2.useState(null);
|
|
2579
2573
|
React2.useEffect(() => {
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
};
|
|
2584
|
-
document.addEventListener("pointerdown", onPointerDown, true);
|
|
2585
|
-
return () => document.removeEventListener("pointerdown", onPointerDown, true);
|
|
2586
|
-
}, [ref, onOutside]);
|
|
2574
|
+
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2575
|
+
}, [anchorRef]);
|
|
2576
|
+
return rect2;
|
|
2587
2577
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2578
|
+
|
|
2579
|
+
// src/SearchSelect/DropdownPlacement.ts
|
|
2580
|
+
var DropdownPlacement = /* @__PURE__ */ ((DropdownPlacement2) => {
|
|
2581
|
+
DropdownPlacement2["Below"] = "below";
|
|
2582
|
+
DropdownPlacement2["Above"] = "above";
|
|
2583
|
+
return DropdownPlacement2;
|
|
2584
|
+
})(DropdownPlacement || {});
|
|
2585
|
+
|
|
2586
|
+
// src/SearchSelect/utils/dropdownFrame.ts
|
|
2587
|
+
function placeDropdown(anchor, panelHeight, viewportHeight) {
|
|
2588
|
+
const roomBelow = viewportHeight - (anchor.y + anchor.height);
|
|
2589
|
+
if (roomBelow >= panelHeight) return "below" /* Below */;
|
|
2590
|
+
return anchor.y > roomBelow ? "above" /* Above */ : "below" /* Below */;
|
|
2591
|
+
}
|
|
2592
|
+
function dropdownFrame(anchor, panelHeight, viewportHeight) {
|
|
2593
|
+
const placement = placeDropdown(anchor, panelHeight, viewportHeight);
|
|
2594
|
+
const base = { placement, left: anchor.x, width: anchor.width };
|
|
2595
|
+
if (placement === "above" /* Above */) return { ...base, bottom: viewportHeight - anchor.y };
|
|
2596
|
+
return { ...base, top: anchor.y + anchor.height };
|
|
2597
|
+
}
|
|
2598
|
+
function DropdownSurface({ progress, translateY, anchorRef, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2599
|
+
const { height: viewportHeight } = reactNative.useWindowDimensions();
|
|
2600
|
+
const anchor = useAnchorRect2(anchorRef);
|
|
2601
|
+
const [panelHeight, setPanelHeight] = React2.useState(0);
|
|
2602
|
+
const onLayout = React2.useCallback((event) => setPanelHeight(event.nativeEvent.layout.height), []);
|
|
2603
|
+
const frame = anchor === null ? null : dropdownFrame(anchor, panelHeight, viewportHeight);
|
|
2604
|
+
const place = frame === null ? null : { left: frame.left, width: frame.width, top: frame.top, bottom: frame.bottom };
|
|
2605
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: [
|
|
2606
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2607
|
+
frame !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles18.dropdown, place, { opacity: progress, transform: [{ translateY }] }], testID: `${testID}-dropdown-${frame.placement}`, onLayout, children }) : null
|
|
2608
|
+
] });
|
|
2592
2609
|
}
|
|
2593
2610
|
var styles18 = reactNative.StyleSheet.create({
|
|
2594
|
-
dropdown: { position: "absolute"
|
|
2611
|
+
dropdown: { position: "absolute" }
|
|
2595
2612
|
});
|
|
2596
2613
|
var ROW_PAD_H = 12;
|
|
2597
2614
|
var ROW_GAP4 = 8;
|
|
@@ -2704,7 +2721,7 @@ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, re
|
|
|
2704
2721
|
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.empty, { color: colors.textSecondary }], children: labels.empty }) : null
|
|
2705
2722
|
] })
|
|
2706
2723
|
] });
|
|
2707
|
-
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, progress, translateY, onDismiss: dismiss, children: list });
|
|
2724
|
+
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, closeHint: labels.closeHint, closeLabel: labels.close, progress, testID, translateY, onDismiss: dismiss, children: list });
|
|
2708
2725
|
return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
|
|
2709
2726
|
}
|
|
2710
2727
|
var styles22 = reactNative.StyleSheet.create({
|
|
@@ -2728,6 +2745,13 @@ function useReducedMotion() {
|
|
|
2728
2745
|
}, []);
|
|
2729
2746
|
return reduced;
|
|
2730
2747
|
}
|
|
2748
|
+
function useRefocusOnClose(open, ref) {
|
|
2749
|
+
const wasOpen = React2.useRef(false);
|
|
2750
|
+
React2.useEffect(() => {
|
|
2751
|
+
if (wasOpen.current && !open) ref.current?.focus();
|
|
2752
|
+
wasOpen.current = open;
|
|
2753
|
+
}, [open, ref]);
|
|
2754
|
+
}
|
|
2731
2755
|
|
|
2732
2756
|
// src/SearchSelect/utils/searchSelectModel.ts
|
|
2733
2757
|
var MIN_QUERY = 1;
|
|
@@ -2805,6 +2829,7 @@ function resolveSelectMotion(width, reducedMotion) {
|
|
|
2805
2829
|
}
|
|
2806
2830
|
var CHEVRON = "\u25BE";
|
|
2807
2831
|
var VALUE_GAP = 8;
|
|
2832
|
+
var NOTHING_ON_CLOSE = () => void 0;
|
|
2808
2833
|
function SearchSelect(props) {
|
|
2809
2834
|
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail } = props;
|
|
2810
2835
|
const { theme } = uiFeedback.useUi();
|
|
@@ -2814,8 +2839,8 @@ function SearchSelect(props) {
|
|
|
2814
2839
|
const { width } = reactNative.useWindowDimensions();
|
|
2815
2840
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
2816
2841
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2842
|
+
const state = useSearchSelectState(options, recents, onChange, NOTHING_ON_CLOSE);
|
|
2843
|
+
useRefocusOnClose(state.open, triggerRef);
|
|
2819
2844
|
const selected = findOption(options, value);
|
|
2820
2845
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles23.anchor, children: [
|
|
2821
2846
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2851,6 +2876,29 @@ var styles23 = reactNative.StyleSheet.create({
|
|
|
2851
2876
|
anchor: { position: "relative" },
|
|
2852
2877
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
2853
2878
|
});
|
|
2879
|
+
function isContainer(node) {
|
|
2880
|
+
return "contains" in Object(node);
|
|
2881
|
+
}
|
|
2882
|
+
function isOutside(container, target) {
|
|
2883
|
+
if (!isContainer(container)) return false;
|
|
2884
|
+
return !(target instanceof Node && container.contains(target));
|
|
2885
|
+
}
|
|
2886
|
+
function useOutsidePress(ref, onOutside) {
|
|
2887
|
+
React2.useEffect(() => {
|
|
2888
|
+
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
2889
|
+
const onPointerDown = (event) => {
|
|
2890
|
+
if (isOutside(ref.current, event.target)) onOutside();
|
|
2891
|
+
};
|
|
2892
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
2893
|
+
return () => document.removeEventListener("pointerdown", onPointerDown, true);
|
|
2894
|
+
}, [ref, onOutside]);
|
|
2895
|
+
}
|
|
2896
|
+
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
2897
|
+
function useDeferredFocus(ref) {
|
|
2898
|
+
return React2.useCallback(() => {
|
|
2899
|
+
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
2900
|
+
}, [ref]);
|
|
2901
|
+
}
|
|
2854
2902
|
|
|
2855
2903
|
// src/CountryFlag/data/flagPalette.ts
|
|
2856
2904
|
var FLAG_PALETTE = {
|
|
@@ -3861,12 +3909,28 @@ function validateIban(raw) {
|
|
|
3861
3909
|
if (mod97(normalised) !== VALID_REMAINDER) return refused("ChecksumFailed" /* ChecksumFailed */);
|
|
3862
3910
|
return { rejection: "None" /* None */, electronic: normalised, expectedLength: null };
|
|
3863
3911
|
}
|
|
3864
|
-
|
|
3912
|
+
var LINE_GAP = 4;
|
|
3913
|
+
function RejectionLine({ message, testID }) {
|
|
3914
|
+
const { theme } = uiFeedback.useUi();
|
|
3915
|
+
if (message === null) return null;
|
|
3916
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [styles25.line, { color: fieldErrorInk(theme) }], testID: `${testID}-rejection`, children: message });
|
|
3917
|
+
}
|
|
3918
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
3919
|
+
line: { marginTop: LINE_GAP }
|
|
3920
|
+
});
|
|
3921
|
+
|
|
3922
|
+
// src/IbanInput/utils/rejectionMessage.ts
|
|
3923
|
+
function rejectionMessage(rejection, none, labels) {
|
|
3924
|
+
if (labels === void 0 || rejection === null || rejection === none) return null;
|
|
3925
|
+
return labels[rejection];
|
|
3926
|
+
}
|
|
3927
|
+
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder }) {
|
|
3865
3928
|
const { theme } = uiFeedback.useUi();
|
|
3866
3929
|
const { colors } = theme;
|
|
3867
3930
|
const draft = React2.useMemo(() => draftIban(value), [value]);
|
|
3868
3931
|
const validate = React2.useCallback(() => validateIban(value), [value]);
|
|
3869
|
-
const { onEdit, onLeave } = useBlurVerdict(validate);
|
|
3932
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
3933
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
3870
3934
|
const counter = ibanCounter(draft);
|
|
3871
3935
|
const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
3872
3936
|
const onChangeText = React2.useCallback((text) => {
|
|
@@ -3876,37 +3940,40 @@ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibili
|
|
|
3876
3940
|
onChange(draftIban(text).electronic);
|
|
3877
3941
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
3878
3942
|
const onBlur = React2.useCallback(() => {
|
|
3879
|
-
const
|
|
3880
|
-
onVerdict?.(value === "" ? null :
|
|
3943
|
+
const verdict2 = onLeave();
|
|
3944
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
3881
3945
|
}, [onLeave, onVerdict, value]);
|
|
3882
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, {
|
|
3883
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3884
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.
|
|
3885
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3886
|
-
|
|
3946
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
3947
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: [
|
|
3948
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: ghostStyles.field, children: [
|
|
3949
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
|
|
3950
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ghostStyles.hidden, children: draft.display }),
|
|
3951
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary }, children: draft.ghost })
|
|
3952
|
+
] }),
|
|
3953
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3954
|
+
reactNative.TextInput,
|
|
3955
|
+
{
|
|
3956
|
+
accessibilityHint,
|
|
3957
|
+
accessibilityLabel,
|
|
3958
|
+
autoCapitalize: "characters",
|
|
3959
|
+
autoComplete: "off",
|
|
3960
|
+
autoCorrect: false,
|
|
3961
|
+
placeholder: draft.display === "" ? placeholder : void 0,
|
|
3962
|
+
placeholderTextColor: colors.textSecondary,
|
|
3963
|
+
selection,
|
|
3964
|
+
spellCheck: false,
|
|
3965
|
+
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
3966
|
+
testID,
|
|
3967
|
+
value: draft.display,
|
|
3968
|
+
onBlur,
|
|
3969
|
+
onChangeText,
|
|
3970
|
+
onSelectionChange
|
|
3971
|
+
}
|
|
3972
|
+
)
|
|
3887
3973
|
] }),
|
|
3888
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3889
|
-
reactNative.TextInput,
|
|
3890
|
-
{
|
|
3891
|
-
accessibilityHint,
|
|
3892
|
-
accessibilityLabel,
|
|
3893
|
-
autoCapitalize: "characters",
|
|
3894
|
-
autoComplete: "off",
|
|
3895
|
-
autoCorrect: false,
|
|
3896
|
-
placeholder: draft.display === "" ? placeholder : void 0,
|
|
3897
|
-
placeholderTextColor: colors.textSecondary,
|
|
3898
|
-
selection,
|
|
3899
|
-
spellCheck: false,
|
|
3900
|
-
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
3901
|
-
testID,
|
|
3902
|
-
value: draft.display,
|
|
3903
|
-
onBlur,
|
|
3904
|
-
onChangeText,
|
|
3905
|
-
onSelectionChange
|
|
3906
|
-
}
|
|
3907
|
-
)
|
|
3974
|
+
counter !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { testID: `${testID}-counter`, style: [ghostStyles.counter, { color: colors.textSecondary }], children: counter }) : null
|
|
3908
3975
|
] }),
|
|
3909
|
-
|
|
3976
|
+
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
3910
3977
|
] });
|
|
3911
3978
|
}
|
|
3912
3979
|
|
|
@@ -3943,44 +4010,48 @@ function validateBic(raw) {
|
|
|
3943
4010
|
if (RESERVED_LOCATION.includes(bic.charAt(LOCATION_INDEX))) return refused2("MalformedLocation" /* MalformedLocation */);
|
|
3944
4011
|
return { rejection: "None" /* None */, electronic: bic };
|
|
3945
4012
|
}
|
|
3946
|
-
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID }) {
|
|
4013
|
+
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }) {
|
|
3947
4014
|
const { theme } = uiFeedback.useUi();
|
|
3948
4015
|
const { colors } = theme;
|
|
3949
4016
|
const draft = React2.useMemo(() => draftBic(value), [value]);
|
|
3950
4017
|
const validate = React2.useCallback(() => validateBic(value), [value]);
|
|
3951
|
-
const { onEdit, onLeave } = useBlurVerdict(validate);
|
|
4018
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
4019
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
3952
4020
|
const onChangeText = React2.useCallback((text) => {
|
|
3953
4021
|
onEdit();
|
|
3954
4022
|
onVerdict?.(null);
|
|
3955
4023
|
onChange(draftBic(text).value);
|
|
3956
4024
|
}, [onEdit, onVerdict, onChange]);
|
|
3957
4025
|
const onBlur = React2.useCallback(() => {
|
|
3958
|
-
const
|
|
3959
|
-
onVerdict?.(value === "" ? null :
|
|
4026
|
+
const verdict2 = onLeave();
|
|
4027
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
3960
4028
|
}, [onLeave, onVerdict, value]);
|
|
3961
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3962
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3963
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
4029
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
4030
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: ghostStyles.field, children: [
|
|
4031
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
|
|
4032
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ghostStyles.hidden, children: draft.value }),
|
|
4033
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary }, children: draft.ghost }),
|
|
4034
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [ghostStyles.branch, { color: colors.textSecondary }], children: draft.branchGhost })
|
|
4035
|
+
] }),
|
|
4036
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4037
|
+
reactNative.TextInput,
|
|
4038
|
+
{
|
|
4039
|
+
accessibilityHint,
|
|
4040
|
+
accessibilityLabel,
|
|
4041
|
+
autoCapitalize: "characters",
|
|
4042
|
+
autoComplete: "off",
|
|
4043
|
+
autoCorrect: false,
|
|
4044
|
+
spellCheck: false,
|
|
4045
|
+
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
4046
|
+
testID,
|
|
4047
|
+
value: draft.value,
|
|
4048
|
+
onBlur,
|
|
4049
|
+
onChangeText
|
|
4050
|
+
}
|
|
4051
|
+
)
|
|
4052
|
+
] }) }),
|
|
4053
|
+
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
4054
|
+
] });
|
|
3984
4055
|
}
|
|
3985
4056
|
|
|
3986
4057
|
exports.AddOnRequest = AddOnRequest;
|
|
@@ -4000,6 +4071,7 @@ exports.DateField = DateField;
|
|
|
4000
4071
|
exports.DateInput = DateInput;
|
|
4001
4072
|
exports.DateRangeControl = DateRangeControl;
|
|
4002
4073
|
exports.DateTimeField = DateTimeField;
|
|
4074
|
+
exports.DropdownPlacement = DropdownPlacement;
|
|
4003
4075
|
exports.FLAG_HEIGHT = FLAG_HEIGHT;
|
|
4004
4076
|
exports.FLAG_WIDTH = FLAG_WIDTH;
|
|
4005
4077
|
exports.Field = Field;
|
|
@@ -4038,6 +4110,7 @@ exports.countryFlag = countryFlag;
|
|
|
4038
4110
|
exports.countryOptions = countryOptions;
|
|
4039
4111
|
exports.draftBic = draftBic;
|
|
4040
4112
|
exports.draftIban = draftIban;
|
|
4113
|
+
exports.dropdownFrame = dropdownFrame;
|
|
4041
4114
|
exports.findOption = findOption;
|
|
4042
4115
|
exports.flagShapes = flagShapes;
|
|
4043
4116
|
exports.groupAriaChecked = groupAriaChecked;
|
|
@@ -4054,6 +4127,8 @@ exports.isUnmatched = isUnmatched;
|
|
|
4054
4127
|
exports.isWideFormLayout = isWideFormLayout;
|
|
4055
4128
|
exports.moveHighlight = moveHighlight;
|
|
4056
4129
|
exports.nextHighlight = nextHighlight;
|
|
4130
|
+
exports.placeDropdown = placeDropdown;
|
|
4131
|
+
exports.rejectionMessage = rejectionMessage;
|
|
4057
4132
|
exports.resolveGroupSelection = resolveGroupSelection;
|
|
4058
4133
|
exports.resolveSelectMotion = resolveSelectMotion;
|
|
4059
4134
|
exports.resolveStepNeighbours = resolveStepNeighbours;
|
|
@@ -4061,6 +4136,7 @@ exports.suggestOptions = suggestOptions;
|
|
|
4061
4136
|
exports.toCountryValue = toCountryValue;
|
|
4062
4137
|
exports.toggleGroupSelection = toggleGroupSelection;
|
|
4063
4138
|
exports.useBlurVerdict = useBlurVerdict;
|
|
4139
|
+
exports.useDeferredFocus = useDeferredFocus;
|
|
4064
4140
|
exports.useFocusFirstInvalid = useFocusFirstInvalid;
|
|
4065
4141
|
exports.useKeepInView = useKeepInView;
|
|
4066
4142
|
exports.useOutsidePress = useOutsidePress;
|