@dloizides/ui-forms 1.33.0 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +50 -14
- package/dist/index.d.ts +50 -14
- package/dist/index.js +147 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -80
- 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({
|
|
@@ -2713,6 +2730,12 @@ var styles22 = reactNative.StyleSheet.create({
|
|
|
2713
2730
|
sheetList: { maxHeight: SHEET_MAX_HEIGHT },
|
|
2714
2731
|
empty: { padding: PANEL_PAD }
|
|
2715
2732
|
});
|
|
2733
|
+
var AFTER_SURFACE_UNMOUNT_MS = 0;
|
|
2734
|
+
function useDeferredFocus(ref) {
|
|
2735
|
+
return React2.useCallback(() => {
|
|
2736
|
+
setTimeout(() => ref.current?.focus(), AFTER_SURFACE_UNMOUNT_MS);
|
|
2737
|
+
}, [ref]);
|
|
2738
|
+
}
|
|
2716
2739
|
function useReducedMotion() {
|
|
2717
2740
|
const [reduced, setReduced] = React2.useState(false);
|
|
2718
2741
|
React2.useEffect(() => {
|
|
@@ -2814,7 +2837,7 @@ function SearchSelect(props) {
|
|
|
2814
2837
|
const { width } = reactNative.useWindowDimensions();
|
|
2815
2838
|
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
2816
2839
|
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
2817
|
-
const refocus =
|
|
2840
|
+
const refocus = useDeferredFocus(triggerRef);
|
|
2818
2841
|
const state = useSearchSelectState(options, recents, onChange, refocus);
|
|
2819
2842
|
const selected = findOption(options, value);
|
|
2820
2843
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles23.anchor, children: [
|
|
@@ -2851,6 +2874,23 @@ var styles23 = reactNative.StyleSheet.create({
|
|
|
2851
2874
|
anchor: { position: "relative" },
|
|
2852
2875
|
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
2853
2876
|
});
|
|
2877
|
+
function isContainer(node) {
|
|
2878
|
+
return "contains" in Object(node);
|
|
2879
|
+
}
|
|
2880
|
+
function isOutside(container, target) {
|
|
2881
|
+
if (!isContainer(container)) return false;
|
|
2882
|
+
return !(target instanceof Node && container.contains(target));
|
|
2883
|
+
}
|
|
2884
|
+
function useOutsidePress(ref, onOutside) {
|
|
2885
|
+
React2.useEffect(() => {
|
|
2886
|
+
if (reactNative.Platform.OS !== "web" || typeof document === "undefined") return void 0;
|
|
2887
|
+
const onPointerDown = (event) => {
|
|
2888
|
+
if (isOutside(ref.current, event.target)) onOutside();
|
|
2889
|
+
};
|
|
2890
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
2891
|
+
return () => document.removeEventListener("pointerdown", onPointerDown, true);
|
|
2892
|
+
}, [ref, onOutside]);
|
|
2893
|
+
}
|
|
2854
2894
|
|
|
2855
2895
|
// src/CountryFlag/data/flagPalette.ts
|
|
2856
2896
|
var FLAG_PALETTE = {
|
|
@@ -3861,12 +3901,28 @@ function validateIban(raw) {
|
|
|
3861
3901
|
if (mod97(normalised) !== VALID_REMAINDER) return refused("ChecksumFailed" /* ChecksumFailed */);
|
|
3862
3902
|
return { rejection: "None" /* None */, electronic: normalised, expectedLength: null };
|
|
3863
3903
|
}
|
|
3864
|
-
|
|
3904
|
+
var LINE_GAP = 4;
|
|
3905
|
+
function RejectionLine({ message, testID }) {
|
|
3906
|
+
const { theme } = uiFeedback.useUi();
|
|
3907
|
+
if (message === null) return null;
|
|
3908
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityLiveRegion: "polite", style: [styles25.line, { color: fieldErrorInk(theme) }], testID: `${testID}-rejection`, children: message });
|
|
3909
|
+
}
|
|
3910
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
3911
|
+
line: { marginTop: LINE_GAP }
|
|
3912
|
+
});
|
|
3913
|
+
|
|
3914
|
+
// src/IbanInput/utils/rejectionMessage.ts
|
|
3915
|
+
function rejectionMessage(rejection, none, labels) {
|
|
3916
|
+
if (labels === void 0 || rejection === null || rejection === none) return null;
|
|
3917
|
+
return labels[rejection];
|
|
3918
|
+
}
|
|
3919
|
+
function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels, placeholder }) {
|
|
3865
3920
|
const { theme } = uiFeedback.useUi();
|
|
3866
3921
|
const { colors } = theme;
|
|
3867
3922
|
const draft = React2.useMemo(() => draftIban(value), [value]);
|
|
3868
3923
|
const validate = React2.useCallback(() => validateIban(value), [value]);
|
|
3869
|
-
const { onEdit, onLeave } = useBlurVerdict(validate);
|
|
3924
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
3925
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
3870
3926
|
const counter = ibanCounter(draft);
|
|
3871
3927
|
const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
3872
3928
|
const onChangeText = React2.useCallback((text) => {
|
|
@@ -3876,37 +3932,40 @@ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibili
|
|
|
3876
3932
|
onChange(draftIban(text).electronic);
|
|
3877
3933
|
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
3878
3934
|
const onBlur = React2.useCallback(() => {
|
|
3879
|
-
const
|
|
3880
|
-
onVerdict?.(value === "" ? null :
|
|
3935
|
+
const verdict2 = onLeave();
|
|
3936
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
3881
3937
|
}, [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
|
-
|
|
3938
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
3939
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: [
|
|
3940
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: ghostStyles.field, children: [
|
|
3941
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
|
|
3942
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ghostStyles.hidden, children: draft.display }),
|
|
3943
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary }, children: draft.ghost })
|
|
3944
|
+
] }),
|
|
3945
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3946
|
+
reactNative.TextInput,
|
|
3947
|
+
{
|
|
3948
|
+
accessibilityHint,
|
|
3949
|
+
accessibilityLabel,
|
|
3950
|
+
autoCapitalize: "characters",
|
|
3951
|
+
autoComplete: "off",
|
|
3952
|
+
autoCorrect: false,
|
|
3953
|
+
placeholder: draft.display === "" ? placeholder : void 0,
|
|
3954
|
+
placeholderTextColor: colors.textSecondary,
|
|
3955
|
+
selection,
|
|
3956
|
+
spellCheck: false,
|
|
3957
|
+
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
3958
|
+
testID,
|
|
3959
|
+
value: draft.display,
|
|
3960
|
+
onBlur,
|
|
3961
|
+
onChangeText,
|
|
3962
|
+
onSelectionChange
|
|
3963
|
+
}
|
|
3964
|
+
)
|
|
3887
3965
|
] }),
|
|
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
|
-
)
|
|
3966
|
+
counter !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { testID: `${testID}-counter`, style: [ghostStyles.counter, { color: colors.textSecondary }], children: counter }) : null
|
|
3908
3967
|
] }),
|
|
3909
|
-
|
|
3968
|
+
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
3910
3969
|
] });
|
|
3911
3970
|
}
|
|
3912
3971
|
|
|
@@ -3943,44 +4002,48 @@ function validateBic(raw) {
|
|
|
3943
4002
|
if (RESERVED_LOCATION.includes(bic.charAt(LOCATION_INDEX))) return refused2("MalformedLocation" /* MalformedLocation */);
|
|
3944
4003
|
return { rejection: "None" /* None */, electronic: bic };
|
|
3945
4004
|
}
|
|
3946
|
-
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID }) {
|
|
4005
|
+
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }) {
|
|
3947
4006
|
const { theme } = uiFeedback.useUi();
|
|
3948
4007
|
const { colors } = theme;
|
|
3949
4008
|
const draft = React2.useMemo(() => draftBic(value), [value]);
|
|
3950
4009
|
const validate = React2.useCallback(() => validateBic(value), [value]);
|
|
3951
|
-
const { onEdit, onLeave } = useBlurVerdict(validate);
|
|
4010
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
4011
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
3952
4012
|
const onChangeText = React2.useCallback((text) => {
|
|
3953
4013
|
onEdit();
|
|
3954
4014
|
onVerdict?.(null);
|
|
3955
4015
|
onChange(draftBic(text).value);
|
|
3956
4016
|
}, [onEdit, onVerdict, onChange]);
|
|
3957
4017
|
const onBlur = React2.useCallback(() => {
|
|
3958
|
-
const
|
|
3959
|
-
onVerdict?.(value === "" ? null :
|
|
4018
|
+
const verdict2 = onLeave();
|
|
4019
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
3960
4020
|
}, [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
|
-
|
|
4021
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
4022
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: ghostStyles.field, children: [
|
|
4023
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
|
|
4024
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: ghostStyles.hidden, children: draft.value }),
|
|
4025
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary }, children: draft.ghost }),
|
|
4026
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [ghostStyles.branch, { color: colors.textSecondary }], children: draft.branchGhost })
|
|
4027
|
+
] }),
|
|
4028
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4029
|
+
reactNative.TextInput,
|
|
4030
|
+
{
|
|
4031
|
+
accessibilityHint,
|
|
4032
|
+
accessibilityLabel,
|
|
4033
|
+
autoCapitalize: "characters",
|
|
4034
|
+
autoComplete: "off",
|
|
4035
|
+
autoCorrect: false,
|
|
4036
|
+
spellCheck: false,
|
|
4037
|
+
style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
|
|
4038
|
+
testID,
|
|
4039
|
+
value: draft.value,
|
|
4040
|
+
onBlur,
|
|
4041
|
+
onChangeText
|
|
4042
|
+
}
|
|
4043
|
+
)
|
|
4044
|
+
] }) }),
|
|
4045
|
+
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
4046
|
+
] });
|
|
3984
4047
|
}
|
|
3985
4048
|
|
|
3986
4049
|
exports.AddOnRequest = AddOnRequest;
|
|
@@ -4000,6 +4063,7 @@ exports.DateField = DateField;
|
|
|
4000
4063
|
exports.DateInput = DateInput;
|
|
4001
4064
|
exports.DateRangeControl = DateRangeControl;
|
|
4002
4065
|
exports.DateTimeField = DateTimeField;
|
|
4066
|
+
exports.DropdownPlacement = DropdownPlacement;
|
|
4003
4067
|
exports.FLAG_HEIGHT = FLAG_HEIGHT;
|
|
4004
4068
|
exports.FLAG_WIDTH = FLAG_WIDTH;
|
|
4005
4069
|
exports.Field = Field;
|
|
@@ -4038,6 +4102,7 @@ exports.countryFlag = countryFlag;
|
|
|
4038
4102
|
exports.countryOptions = countryOptions;
|
|
4039
4103
|
exports.draftBic = draftBic;
|
|
4040
4104
|
exports.draftIban = draftIban;
|
|
4105
|
+
exports.dropdownFrame = dropdownFrame;
|
|
4041
4106
|
exports.findOption = findOption;
|
|
4042
4107
|
exports.flagShapes = flagShapes;
|
|
4043
4108
|
exports.groupAriaChecked = groupAriaChecked;
|
|
@@ -4054,6 +4119,8 @@ exports.isUnmatched = isUnmatched;
|
|
|
4054
4119
|
exports.isWideFormLayout = isWideFormLayout;
|
|
4055
4120
|
exports.moveHighlight = moveHighlight;
|
|
4056
4121
|
exports.nextHighlight = nextHighlight;
|
|
4122
|
+
exports.placeDropdown = placeDropdown;
|
|
4123
|
+
exports.rejectionMessage = rejectionMessage;
|
|
4057
4124
|
exports.resolveGroupSelection = resolveGroupSelection;
|
|
4058
4125
|
exports.resolveSelectMotion = resolveSelectMotion;
|
|
4059
4126
|
exports.resolveStepNeighbours = resolveStepNeighbours;
|
|
@@ -4061,6 +4128,7 @@ exports.suggestOptions = suggestOptions;
|
|
|
4061
4128
|
exports.toCountryValue = toCountryValue;
|
|
4062
4129
|
exports.toggleGroupSelection = toggleGroupSelection;
|
|
4063
4130
|
exports.useBlurVerdict = useBlurVerdict;
|
|
4131
|
+
exports.useDeferredFocus = useDeferredFocus;
|
|
4064
4132
|
exports.useFocusFirstInvalid = useFocusFirstInvalid;
|
|
4065
4133
|
exports.useKeepInView = useKeepInView;
|
|
4066
4134
|
exports.useOutsidePress = useOutsidePress;
|