@dloizides/ui-forms 1.32.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/CHANGELOG.md +11 -0
- package/dist/index.d.mts +283 -1
- package/dist/index.d.ts +283 -1
- package/dist/index.js +1547 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1506 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `SearchSelect`: type to filter by name and detail, Recent then All, arrow keys + Enter + Esc, phone sheet / computer unfold, reduced motion = no slide (FINREG-INPUTS-1 "Searchable dropdowns, shared country field, formatted IBAN/BIC inputs").
|
|
7
|
+
- `CountryField` + `COUNTRIES` (ISO 3166-1 alpha-2, 249): drawn SVG flag (`CountryFlag`, needs peer `react-native-svg >=13.0.0`), name, grey code; stores the code only.
|
|
8
|
+
- `SearchSelect`: `renderDetail` slot, typing highlights the first match, web outside press closes the dropdown; `IbanInput` keeps the caret through regrouping.
|
|
9
|
+
- `IbanInput` / `BicInput` + pure `validateIban` / `validateBic` / `draftIban` / `draftBic`, same verdicts as `Finreg.Core.Banking` on a shared fixture list.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- `suggestOptions` also matches an option's `detail` (ranked last).
|
|
13
|
+
|
|
3
14
|
## 1.32.0
|
|
4
15
|
|
|
5
16
|
KEFI-LAUNCH-1 "Do every open Kefi task" (UI-COMPOSE-1 extraction from kefi-web landing parity).
|
package/dist/index.d.mts
CHANGED
|
@@ -1275,4 +1275,286 @@ declare const isFixBarVisible: (count: number) => boolean;
|
|
|
1275
1275
|
/** A bar above Save: a pre-localized message naming the fields that stop the save, and a Show button. */
|
|
1276
1276
|
declare const FixBar: ({ count, message, showLabel, showHint, onShow, testID, style }: FixBarProps) => React.ReactElement | null;
|
|
1277
1277
|
|
|
1278
|
-
|
|
1278
|
+
/** PRE-LOCALIZED strings for a SearchSelect; the package never translates. */
|
|
1279
|
+
interface SearchSelectLabels {
|
|
1280
|
+
placeholder: string;
|
|
1281
|
+
search: string;
|
|
1282
|
+
searchHint: string;
|
|
1283
|
+
recent: string;
|
|
1284
|
+
all: string;
|
|
1285
|
+
empty: string;
|
|
1286
|
+
optionHint: string;
|
|
1287
|
+
close: string;
|
|
1288
|
+
closeHint: string;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
interface SearchSelectProps {
|
|
1292
|
+
options: readonly ControlOption[];
|
|
1293
|
+
value: string;
|
|
1294
|
+
onChange: (value: string) => void;
|
|
1295
|
+
accessibilityLabel: string;
|
|
1296
|
+
accessibilityHint: string;
|
|
1297
|
+
labels: SearchSelectLabels;
|
|
1298
|
+
testID: string;
|
|
1299
|
+
recentKey?: string;
|
|
1300
|
+
renderLeading?: (option: ControlOption) => React.ReactNode;
|
|
1301
|
+
renderDetail?: (option: ControlOption) => React.ReactNode;
|
|
1302
|
+
}
|
|
1303
|
+
/** A select you can type into to filter; the value is always a picked option, never typed text. */
|
|
1304
|
+
declare function SearchSelect(props: SearchSelectProps): React.ReactElement;
|
|
1305
|
+
|
|
1306
|
+
/** How the option list opens: a sheet from below (phone) or a list unfolding under the field. */
|
|
1307
|
+
declare enum SelectSurface {
|
|
1308
|
+
Sheet = "sheet",
|
|
1309
|
+
Dropdown = "dropdown"
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/** The open list: recently picked matches first, then every other match; `flat` is the walk order. */
|
|
1313
|
+
interface SearchSelectSections {
|
|
1314
|
+
readonly recent: readonly ControlOption[];
|
|
1315
|
+
readonly all: readonly ControlOption[];
|
|
1316
|
+
readonly flat: readonly ControlOption[];
|
|
1317
|
+
}
|
|
1318
|
+
/** Filters by label, value and detail, then splits the matches into Recent and All. */
|
|
1319
|
+
declare function buildSearchSelectSections(options: readonly ControlOption[], query: string, recentValues: readonly string[]): SearchSelectSections;
|
|
1320
|
+
/** The option whose value is `value`, or `null`; a value that is no option shows the placeholder. */
|
|
1321
|
+
declare function findOption(options: readonly ControlOption[], value: string): ControlOption | null;
|
|
1322
|
+
/** Moves the highlight by `step`, wrapping at both ends; `-1` means nothing highlighted. */
|
|
1323
|
+
declare function moveHighlight(index: number, count: number, step: number): number;
|
|
1324
|
+
/** The highlight after the search text changes: the first match while there is text, nothing when empty. */
|
|
1325
|
+
declare function highlightAfterQuery(query: string): number;
|
|
1326
|
+
|
|
1327
|
+
/** Below this window width the list opens as a sheet from the bottom. */
|
|
1328
|
+
declare const PHONE_MAX_WIDTH = 600;
|
|
1329
|
+
/** Where the list slides from and how long it takes. */
|
|
1330
|
+
interface SelectMotion {
|
|
1331
|
+
readonly surface: SelectSurface;
|
|
1332
|
+
readonly fromY: number;
|
|
1333
|
+
readonly durationMs: number;
|
|
1334
|
+
}
|
|
1335
|
+
/** Sheet on a phone, unfolding list on a computer; reduced motion keeps the surface and drops the slide. */
|
|
1336
|
+
declare function resolveSelectMotion(width: number, reducedMotion: boolean): SelectMotion;
|
|
1337
|
+
|
|
1338
|
+
/** Open state, query, highlight and the actions of one SearchSelect. */
|
|
1339
|
+
interface SearchSelectState {
|
|
1340
|
+
open: boolean;
|
|
1341
|
+
query: string;
|
|
1342
|
+
highlight: number;
|
|
1343
|
+
active: ControlOption | undefined;
|
|
1344
|
+
sections: SearchSelectSections;
|
|
1345
|
+
openList: () => void;
|
|
1346
|
+
close: () => void;
|
|
1347
|
+
setQuery: (query: string) => void;
|
|
1348
|
+
pick: (option: ControlOption) => void;
|
|
1349
|
+
submit: (via?: (option: ControlOption) => void) => void;
|
|
1350
|
+
onKey: (key: string) => void;
|
|
1351
|
+
}
|
|
1352
|
+
/** Only `pick` calls `onChange`, so the value is always an option, never typed text; Enter picks only through `submit`. */
|
|
1353
|
+
declare function useSearchSelectState(options: readonly ControlOption[], recents: RecentValues, onChange: (value: string) => void, onClosed: () => void): SearchSelectState;
|
|
1354
|
+
|
|
1355
|
+
/** True when the user asked the system to reduce motion. */
|
|
1356
|
+
declare function useReducedMotion(): boolean;
|
|
1357
|
+
|
|
1358
|
+
/** True when `target` lies outside `container`; false when `container` is no DOM node. */
|
|
1359
|
+
declare function isOutside(container: unknown, target: EventTarget | null): boolean;
|
|
1360
|
+
/** On web, calls `onOutside` for a pointer press that starts outside the view behind `ref`. */
|
|
1361
|
+
declare function useOutsidePress(ref: RefObject<View | null>, onOutside: () => void): void;
|
|
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
|
+
|
|
1391
|
+
interface CountryFlagProps {
|
|
1392
|
+
code: string;
|
|
1393
|
+
testID?: string;
|
|
1394
|
+
}
|
|
1395
|
+
/** A 20x14 drawn flag for a 2-letter country code; decorative, the country name carries the meaning. */
|
|
1396
|
+
declare function CountryFlag({ code, testID }: CountryFlagProps): React.ReactElement;
|
|
1397
|
+
|
|
1398
|
+
declare enum FlagShapeKind {
|
|
1399
|
+
Rect = "rect",
|
|
1400
|
+
Circle = "circle",
|
|
1401
|
+
Polygon = "polygon"
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
declare const FLAG_WIDTH = 20;
|
|
1405
|
+
declare const FLAG_HEIGHT = 14;
|
|
1406
|
+
interface FlagShape {
|
|
1407
|
+
readonly kind: FlagShapeKind;
|
|
1408
|
+
readonly x: number;
|
|
1409
|
+
readonly y: number;
|
|
1410
|
+
readonly width: number;
|
|
1411
|
+
readonly height: number;
|
|
1412
|
+
readonly fill: string;
|
|
1413
|
+
readonly points?: string;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/** True when the country has no drawn flag and shows the generic one. */
|
|
1417
|
+
declare function isFallbackFlag(code: string): boolean;
|
|
1418
|
+
/** The shapes that draw the flag of a 2-letter code; a generic flag for a code with no drawn flag. */
|
|
1419
|
+
declare function flagShapes(code: string): FlagShape[];
|
|
1420
|
+
|
|
1421
|
+
/** One ISO 3166-1 alpha-2 country. */
|
|
1422
|
+
interface Country {
|
|
1423
|
+
readonly code: string;
|
|
1424
|
+
readonly name: string;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
interface CountryFieldProps {
|
|
1428
|
+
value: string;
|
|
1429
|
+
onChange: (code: string) => void;
|
|
1430
|
+
accessibilityLabel: string;
|
|
1431
|
+
accessibilityHint: string;
|
|
1432
|
+
labels: SearchSelectLabels;
|
|
1433
|
+
testID: string;
|
|
1434
|
+
countries?: readonly Country[];
|
|
1435
|
+
}
|
|
1436
|
+
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code only. */
|
|
1437
|
+
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries }: CountryFieldProps): React.ReactElement;
|
|
1438
|
+
|
|
1439
|
+
/** ISO 3166-1 alpha-2 countries (249) with English short names. */
|
|
1440
|
+
declare const COUNTRIES: readonly Country[];
|
|
1441
|
+
|
|
1442
|
+
/** Countries as select options: name as the label, the 2-letter code as value and detail. */
|
|
1443
|
+
declare function countryOptions(list?: readonly Country[]): ControlOption[];
|
|
1444
|
+
/** The flag emoji for a 2-letter code, or '' for anything else. */
|
|
1445
|
+
declare function countryFlag(code: string): string;
|
|
1446
|
+
/** The stored value for an input: a known 2-letter code in upper case, else ''. */
|
|
1447
|
+
declare function toCountryValue(input: string): string;
|
|
1448
|
+
|
|
1449
|
+
/** Why an IBAN was refused; member names match `Finreg.Core.Banking.IbanRejection`. */
|
|
1450
|
+
declare enum IbanRejection {
|
|
1451
|
+
None = "None",
|
|
1452
|
+
Missing = "Missing",
|
|
1453
|
+
IllegalCharacter = "IllegalCharacter",
|
|
1454
|
+
MalformedCountryCode = "MalformedCountryCode",
|
|
1455
|
+
MalformedCheckDigits = "MalformedCheckDigits",
|
|
1456
|
+
UnknownCountry = "UnknownCountry",
|
|
1457
|
+
WrongLengthForCountry = "WrongLengthForCountry",
|
|
1458
|
+
ChecksumFailed = "ChecksumFailed"
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/** The outcome of validating one IBAN; `electronic` (upper case, no spaces) is set only when valid. */
|
|
1462
|
+
interface IbanVerdict {
|
|
1463
|
+
readonly rejection: IbanRejection;
|
|
1464
|
+
readonly electronic: string | null;
|
|
1465
|
+
readonly expectedLength: number | null;
|
|
1466
|
+
}
|
|
1467
|
+
/** Validates an IBAN with the same rules as `Finreg.Core.Banking.Iban.Validate`. */
|
|
1468
|
+
declare function validateIban(raw: string | null | undefined): IbanVerdict;
|
|
1469
|
+
|
|
1470
|
+
/** Why a BIC was refused; member names match `Finreg.Core.Banking.BicRejection`. */
|
|
1471
|
+
declare enum BicRejection {
|
|
1472
|
+
None = "None",
|
|
1473
|
+
Missing = "Missing",
|
|
1474
|
+
IllegalCharacter = "IllegalCharacter",
|
|
1475
|
+
WrongLength = "WrongLength",
|
|
1476
|
+
MalformedInstitution = "MalformedInstitution",
|
|
1477
|
+
MalformedCountry = "MalformedCountry",
|
|
1478
|
+
MalformedLocation = "MalformedLocation"
|
|
1479
|
+
}
|
|
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
|
+
|
|
1497
|
+
/** The outcome of validating one BIC; `electronic` (upper case, trimmed) is set only when valid. */
|
|
1498
|
+
interface BicVerdict {
|
|
1499
|
+
readonly rejection: BicRejection;
|
|
1500
|
+
readonly electronic: string | null;
|
|
1501
|
+
}
|
|
1502
|
+
/** Validates a BIC with the same rules as `Finreg.Core.Banking.Bic.Validate`. */
|
|
1503
|
+
declare function validateBic(raw: string | null | undefined): BicVerdict;
|
|
1504
|
+
|
|
1505
|
+
interface BicInputProps {
|
|
1506
|
+
value: string;
|
|
1507
|
+
onChange: (bic: string) => void;
|
|
1508
|
+
onVerdict?: (verdict: BicVerdict | null) => void;
|
|
1509
|
+
accessibilityLabel: string;
|
|
1510
|
+
accessibilityHint: string;
|
|
1511
|
+
testID: string;
|
|
1512
|
+
rejectionLabels?: BicRejectionLabels;
|
|
1513
|
+
}
|
|
1514
|
+
/** A BIC box that upper-cases as you type, ghosts the optional branch and validates on leave. */
|
|
1515
|
+
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }: BicInputProps): React.ReactElement;
|
|
1516
|
+
|
|
1517
|
+
/** The longest IBAN ISO 13616 permits. */
|
|
1518
|
+
declare const IBAN_MAX_LENGTH = 34;
|
|
1519
|
+
/** How many countries the registry table covers. */
|
|
1520
|
+
declare const IBAN_REGISTERED_COUNTRY_COUNT: number;
|
|
1521
|
+
/** The registered IBAN length for an upper-case country code, or `null` when it is not registered. */
|
|
1522
|
+
declare function ibanLengthFor(country: string): number | null;
|
|
1523
|
+
|
|
1524
|
+
/** What an IBAN field shows while typing: stored form, grouped display, counter and ghost tail. */
|
|
1525
|
+
interface IbanDraft {
|
|
1526
|
+
readonly electronic: string;
|
|
1527
|
+
readonly display: string;
|
|
1528
|
+
readonly country: string;
|
|
1529
|
+
readonly typed: number;
|
|
1530
|
+
readonly expected: number | null;
|
|
1531
|
+
readonly ghost: string;
|
|
1532
|
+
}
|
|
1533
|
+
/** What a BIC field shows while typing: stored form, the required ghost and the optional branch ghost. */
|
|
1534
|
+
interface BicDraft {
|
|
1535
|
+
readonly value: string;
|
|
1536
|
+
readonly ghost: string;
|
|
1537
|
+
readonly branchGhost: string;
|
|
1538
|
+
}
|
|
1539
|
+
/** Groups a string in blocks of four separated by single spaces. */
|
|
1540
|
+
declare function groupInFours(text: string): string;
|
|
1541
|
+
/** Upper-cases, strips separators, caps at the country length and groups an IBAN as typed. */
|
|
1542
|
+
declare function draftIban(raw: string, ghostChar?: string): IbanDraft;
|
|
1543
|
+
/** The "typed / expected" counter, or `null` before the country is known. */
|
|
1544
|
+
declare function ibanCounter(draft: IbanDraft): string | null;
|
|
1545
|
+
/** Upper-cases and caps a BIC at 11, with ghosts for the required part and the optional branch. */
|
|
1546
|
+
declare function draftBic(raw: string, ghostChar?: string): BicDraft;
|
|
1547
|
+
|
|
1548
|
+
/** A verdict that appears only when the field is left and clears on the next edit. */
|
|
1549
|
+
interface BlurVerdict<T> {
|
|
1550
|
+
verdict: T | null;
|
|
1551
|
+
onEdit: () => void;
|
|
1552
|
+
onLeave: () => T;
|
|
1553
|
+
}
|
|
1554
|
+
/** Runs `validate` on leave only, so an error never shows while typing. */
|
|
1555
|
+
declare function useBlurVerdict<T>(validate: () => T): BlurVerdict<T>;
|
|
1556
|
+
|
|
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
|
@@ -1275,4 +1275,286 @@ declare const isFixBarVisible: (count: number) => boolean;
|
|
|
1275
1275
|
/** A bar above Save: a pre-localized message naming the fields that stop the save, and a Show button. */
|
|
1276
1276
|
declare const FixBar: ({ count, message, showLabel, showHint, onShow, testID, style }: FixBarProps) => React.ReactElement | null;
|
|
1277
1277
|
|
|
1278
|
-
|
|
1278
|
+
/** PRE-LOCALIZED strings for a SearchSelect; the package never translates. */
|
|
1279
|
+
interface SearchSelectLabels {
|
|
1280
|
+
placeholder: string;
|
|
1281
|
+
search: string;
|
|
1282
|
+
searchHint: string;
|
|
1283
|
+
recent: string;
|
|
1284
|
+
all: string;
|
|
1285
|
+
empty: string;
|
|
1286
|
+
optionHint: string;
|
|
1287
|
+
close: string;
|
|
1288
|
+
closeHint: string;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
interface SearchSelectProps {
|
|
1292
|
+
options: readonly ControlOption[];
|
|
1293
|
+
value: string;
|
|
1294
|
+
onChange: (value: string) => void;
|
|
1295
|
+
accessibilityLabel: string;
|
|
1296
|
+
accessibilityHint: string;
|
|
1297
|
+
labels: SearchSelectLabels;
|
|
1298
|
+
testID: string;
|
|
1299
|
+
recentKey?: string;
|
|
1300
|
+
renderLeading?: (option: ControlOption) => React.ReactNode;
|
|
1301
|
+
renderDetail?: (option: ControlOption) => React.ReactNode;
|
|
1302
|
+
}
|
|
1303
|
+
/** A select you can type into to filter; the value is always a picked option, never typed text. */
|
|
1304
|
+
declare function SearchSelect(props: SearchSelectProps): React.ReactElement;
|
|
1305
|
+
|
|
1306
|
+
/** How the option list opens: a sheet from below (phone) or a list unfolding under the field. */
|
|
1307
|
+
declare enum SelectSurface {
|
|
1308
|
+
Sheet = "sheet",
|
|
1309
|
+
Dropdown = "dropdown"
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/** The open list: recently picked matches first, then every other match; `flat` is the walk order. */
|
|
1313
|
+
interface SearchSelectSections {
|
|
1314
|
+
readonly recent: readonly ControlOption[];
|
|
1315
|
+
readonly all: readonly ControlOption[];
|
|
1316
|
+
readonly flat: readonly ControlOption[];
|
|
1317
|
+
}
|
|
1318
|
+
/** Filters by label, value and detail, then splits the matches into Recent and All. */
|
|
1319
|
+
declare function buildSearchSelectSections(options: readonly ControlOption[], query: string, recentValues: readonly string[]): SearchSelectSections;
|
|
1320
|
+
/** The option whose value is `value`, or `null`; a value that is no option shows the placeholder. */
|
|
1321
|
+
declare function findOption(options: readonly ControlOption[], value: string): ControlOption | null;
|
|
1322
|
+
/** Moves the highlight by `step`, wrapping at both ends; `-1` means nothing highlighted. */
|
|
1323
|
+
declare function moveHighlight(index: number, count: number, step: number): number;
|
|
1324
|
+
/** The highlight after the search text changes: the first match while there is text, nothing when empty. */
|
|
1325
|
+
declare function highlightAfterQuery(query: string): number;
|
|
1326
|
+
|
|
1327
|
+
/** Below this window width the list opens as a sheet from the bottom. */
|
|
1328
|
+
declare const PHONE_MAX_WIDTH = 600;
|
|
1329
|
+
/** Where the list slides from and how long it takes. */
|
|
1330
|
+
interface SelectMotion {
|
|
1331
|
+
readonly surface: SelectSurface;
|
|
1332
|
+
readonly fromY: number;
|
|
1333
|
+
readonly durationMs: number;
|
|
1334
|
+
}
|
|
1335
|
+
/** Sheet on a phone, unfolding list on a computer; reduced motion keeps the surface and drops the slide. */
|
|
1336
|
+
declare function resolveSelectMotion(width: number, reducedMotion: boolean): SelectMotion;
|
|
1337
|
+
|
|
1338
|
+
/** Open state, query, highlight and the actions of one SearchSelect. */
|
|
1339
|
+
interface SearchSelectState {
|
|
1340
|
+
open: boolean;
|
|
1341
|
+
query: string;
|
|
1342
|
+
highlight: number;
|
|
1343
|
+
active: ControlOption | undefined;
|
|
1344
|
+
sections: SearchSelectSections;
|
|
1345
|
+
openList: () => void;
|
|
1346
|
+
close: () => void;
|
|
1347
|
+
setQuery: (query: string) => void;
|
|
1348
|
+
pick: (option: ControlOption) => void;
|
|
1349
|
+
submit: (via?: (option: ControlOption) => void) => void;
|
|
1350
|
+
onKey: (key: string) => void;
|
|
1351
|
+
}
|
|
1352
|
+
/** Only `pick` calls `onChange`, so the value is always an option, never typed text; Enter picks only through `submit`. */
|
|
1353
|
+
declare function useSearchSelectState(options: readonly ControlOption[], recents: RecentValues, onChange: (value: string) => void, onClosed: () => void): SearchSelectState;
|
|
1354
|
+
|
|
1355
|
+
/** True when the user asked the system to reduce motion. */
|
|
1356
|
+
declare function useReducedMotion(): boolean;
|
|
1357
|
+
|
|
1358
|
+
/** True when `target` lies outside `container`; false when `container` is no DOM node. */
|
|
1359
|
+
declare function isOutside(container: unknown, target: EventTarget | null): boolean;
|
|
1360
|
+
/** On web, calls `onOutside` for a pointer press that starts outside the view behind `ref`. */
|
|
1361
|
+
declare function useOutsidePress(ref: RefObject<View | null>, onOutside: () => void): void;
|
|
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
|
+
|
|
1391
|
+
interface CountryFlagProps {
|
|
1392
|
+
code: string;
|
|
1393
|
+
testID?: string;
|
|
1394
|
+
}
|
|
1395
|
+
/** A 20x14 drawn flag for a 2-letter country code; decorative, the country name carries the meaning. */
|
|
1396
|
+
declare function CountryFlag({ code, testID }: CountryFlagProps): React.ReactElement;
|
|
1397
|
+
|
|
1398
|
+
declare enum FlagShapeKind {
|
|
1399
|
+
Rect = "rect",
|
|
1400
|
+
Circle = "circle",
|
|
1401
|
+
Polygon = "polygon"
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
declare const FLAG_WIDTH = 20;
|
|
1405
|
+
declare const FLAG_HEIGHT = 14;
|
|
1406
|
+
interface FlagShape {
|
|
1407
|
+
readonly kind: FlagShapeKind;
|
|
1408
|
+
readonly x: number;
|
|
1409
|
+
readonly y: number;
|
|
1410
|
+
readonly width: number;
|
|
1411
|
+
readonly height: number;
|
|
1412
|
+
readonly fill: string;
|
|
1413
|
+
readonly points?: string;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/** True when the country has no drawn flag and shows the generic one. */
|
|
1417
|
+
declare function isFallbackFlag(code: string): boolean;
|
|
1418
|
+
/** The shapes that draw the flag of a 2-letter code; a generic flag for a code with no drawn flag. */
|
|
1419
|
+
declare function flagShapes(code: string): FlagShape[];
|
|
1420
|
+
|
|
1421
|
+
/** One ISO 3166-1 alpha-2 country. */
|
|
1422
|
+
interface Country {
|
|
1423
|
+
readonly code: string;
|
|
1424
|
+
readonly name: string;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
interface CountryFieldProps {
|
|
1428
|
+
value: string;
|
|
1429
|
+
onChange: (code: string) => void;
|
|
1430
|
+
accessibilityLabel: string;
|
|
1431
|
+
accessibilityHint: string;
|
|
1432
|
+
labels: SearchSelectLabels;
|
|
1433
|
+
testID: string;
|
|
1434
|
+
countries?: readonly Country[];
|
|
1435
|
+
}
|
|
1436
|
+
/** A searchable country field: flag, name and grey code; stores the ISO 3166-1 alpha-2 code only. */
|
|
1437
|
+
declare function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries }: CountryFieldProps): React.ReactElement;
|
|
1438
|
+
|
|
1439
|
+
/** ISO 3166-1 alpha-2 countries (249) with English short names. */
|
|
1440
|
+
declare const COUNTRIES: readonly Country[];
|
|
1441
|
+
|
|
1442
|
+
/** Countries as select options: name as the label, the 2-letter code as value and detail. */
|
|
1443
|
+
declare function countryOptions(list?: readonly Country[]): ControlOption[];
|
|
1444
|
+
/** The flag emoji for a 2-letter code, or '' for anything else. */
|
|
1445
|
+
declare function countryFlag(code: string): string;
|
|
1446
|
+
/** The stored value for an input: a known 2-letter code in upper case, else ''. */
|
|
1447
|
+
declare function toCountryValue(input: string): string;
|
|
1448
|
+
|
|
1449
|
+
/** Why an IBAN was refused; member names match `Finreg.Core.Banking.IbanRejection`. */
|
|
1450
|
+
declare enum IbanRejection {
|
|
1451
|
+
None = "None",
|
|
1452
|
+
Missing = "Missing",
|
|
1453
|
+
IllegalCharacter = "IllegalCharacter",
|
|
1454
|
+
MalformedCountryCode = "MalformedCountryCode",
|
|
1455
|
+
MalformedCheckDigits = "MalformedCheckDigits",
|
|
1456
|
+
UnknownCountry = "UnknownCountry",
|
|
1457
|
+
WrongLengthForCountry = "WrongLengthForCountry",
|
|
1458
|
+
ChecksumFailed = "ChecksumFailed"
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
/** The outcome of validating one IBAN; `electronic` (upper case, no spaces) is set only when valid. */
|
|
1462
|
+
interface IbanVerdict {
|
|
1463
|
+
readonly rejection: IbanRejection;
|
|
1464
|
+
readonly electronic: string | null;
|
|
1465
|
+
readonly expectedLength: number | null;
|
|
1466
|
+
}
|
|
1467
|
+
/** Validates an IBAN with the same rules as `Finreg.Core.Banking.Iban.Validate`. */
|
|
1468
|
+
declare function validateIban(raw: string | null | undefined): IbanVerdict;
|
|
1469
|
+
|
|
1470
|
+
/** Why a BIC was refused; member names match `Finreg.Core.Banking.BicRejection`. */
|
|
1471
|
+
declare enum BicRejection {
|
|
1472
|
+
None = "None",
|
|
1473
|
+
Missing = "Missing",
|
|
1474
|
+
IllegalCharacter = "IllegalCharacter",
|
|
1475
|
+
WrongLength = "WrongLength",
|
|
1476
|
+
MalformedInstitution = "MalformedInstitution",
|
|
1477
|
+
MalformedCountry = "MalformedCountry",
|
|
1478
|
+
MalformedLocation = "MalformedLocation"
|
|
1479
|
+
}
|
|
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
|
+
|
|
1497
|
+
/** The outcome of validating one BIC; `electronic` (upper case, trimmed) is set only when valid. */
|
|
1498
|
+
interface BicVerdict {
|
|
1499
|
+
readonly rejection: BicRejection;
|
|
1500
|
+
readonly electronic: string | null;
|
|
1501
|
+
}
|
|
1502
|
+
/** Validates a BIC with the same rules as `Finreg.Core.Banking.Bic.Validate`. */
|
|
1503
|
+
declare function validateBic(raw: string | null | undefined): BicVerdict;
|
|
1504
|
+
|
|
1505
|
+
interface BicInputProps {
|
|
1506
|
+
value: string;
|
|
1507
|
+
onChange: (bic: string) => void;
|
|
1508
|
+
onVerdict?: (verdict: BicVerdict | null) => void;
|
|
1509
|
+
accessibilityLabel: string;
|
|
1510
|
+
accessibilityHint: string;
|
|
1511
|
+
testID: string;
|
|
1512
|
+
rejectionLabels?: BicRejectionLabels;
|
|
1513
|
+
}
|
|
1514
|
+
/** A BIC box that upper-cases as you type, ghosts the optional branch and validates on leave. */
|
|
1515
|
+
declare function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }: BicInputProps): React.ReactElement;
|
|
1516
|
+
|
|
1517
|
+
/** The longest IBAN ISO 13616 permits. */
|
|
1518
|
+
declare const IBAN_MAX_LENGTH = 34;
|
|
1519
|
+
/** How many countries the registry table covers. */
|
|
1520
|
+
declare const IBAN_REGISTERED_COUNTRY_COUNT: number;
|
|
1521
|
+
/** The registered IBAN length for an upper-case country code, or `null` when it is not registered. */
|
|
1522
|
+
declare function ibanLengthFor(country: string): number | null;
|
|
1523
|
+
|
|
1524
|
+
/** What an IBAN field shows while typing: stored form, grouped display, counter and ghost tail. */
|
|
1525
|
+
interface IbanDraft {
|
|
1526
|
+
readonly electronic: string;
|
|
1527
|
+
readonly display: string;
|
|
1528
|
+
readonly country: string;
|
|
1529
|
+
readonly typed: number;
|
|
1530
|
+
readonly expected: number | null;
|
|
1531
|
+
readonly ghost: string;
|
|
1532
|
+
}
|
|
1533
|
+
/** What a BIC field shows while typing: stored form, the required ghost and the optional branch ghost. */
|
|
1534
|
+
interface BicDraft {
|
|
1535
|
+
readonly value: string;
|
|
1536
|
+
readonly ghost: string;
|
|
1537
|
+
readonly branchGhost: string;
|
|
1538
|
+
}
|
|
1539
|
+
/** Groups a string in blocks of four separated by single spaces. */
|
|
1540
|
+
declare function groupInFours(text: string): string;
|
|
1541
|
+
/** Upper-cases, strips separators, caps at the country length and groups an IBAN as typed. */
|
|
1542
|
+
declare function draftIban(raw: string, ghostChar?: string): IbanDraft;
|
|
1543
|
+
/** The "typed / expected" counter, or `null` before the country is known. */
|
|
1544
|
+
declare function ibanCounter(draft: IbanDraft): string | null;
|
|
1545
|
+
/** Upper-cases and caps a BIC at 11, with ghosts for the required part and the optional branch. */
|
|
1546
|
+
declare function draftBic(raw: string, ghostChar?: string): BicDraft;
|
|
1547
|
+
|
|
1548
|
+
/** A verdict that appears only when the field is left and clears on the next edit. */
|
|
1549
|
+
interface BlurVerdict<T> {
|
|
1550
|
+
verdict: T | null;
|
|
1551
|
+
onEdit: () => void;
|
|
1552
|
+
onLeave: () => T;
|
|
1553
|
+
}
|
|
1554
|
+
/** Runs `validate` on leave only, so an error never shows while typing. */
|
|
1555
|
+
declare function useBlurVerdict<T>(validate: () => T): BlurVerdict<T>;
|
|
1556
|
+
|
|
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 };
|