@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/dist/index.js
CHANGED
|
@@ -8,10 +8,12 @@ var designTokens = require('@dloizides/design-tokens');
|
|
|
8
8
|
var uiButtons = require('@dloizides/ui-buttons');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
10
|
var a11y = require('@dloizides/a11y');
|
|
11
|
+
var Svg = require('react-native-svg');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
|
|
14
15
|
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
16
|
+
var Svg__default = /*#__PURE__*/_interopDefault(Svg);
|
|
15
17
|
|
|
16
18
|
// src/Field/Field.tsx
|
|
17
19
|
function attachControlId(child, candidateId, describedById) {
|
|
@@ -342,7 +344,7 @@ var styles4 = reactNative.StyleSheet.create({
|
|
|
342
344
|
}
|
|
343
345
|
});
|
|
344
346
|
var InlineFieldRow = ({
|
|
345
|
-
field,
|
|
347
|
+
field: field2,
|
|
346
348
|
action,
|
|
347
349
|
fieldMaxWidth,
|
|
348
350
|
inlineMinWidth,
|
|
@@ -355,11 +357,11 @@ var InlineFieldRow = ({
|
|
|
355
357
|
const fieldStyle = React2.useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
|
|
356
358
|
if (!layout.inline)
|
|
357
359
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
358
|
-
|
|
360
|
+
field2,
|
|
359
361
|
action
|
|
360
362
|
] });
|
|
361
363
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: rowStyle, testID, children: [
|
|
362
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: fieldStyle, children:
|
|
364
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: fieldStyle, children: field2 }),
|
|
363
365
|
/* @__PURE__ */ jsxRuntime.jsx(AlignToControl, { style: styles4.action, children: action })
|
|
364
366
|
] });
|
|
365
367
|
};
|
|
@@ -638,25 +640,25 @@ function readAnchorRect(ref) {
|
|
|
638
640
|
const r = node.getBoundingClientRect();
|
|
639
641
|
return { top: r.top, left: r.left, width: r.width, bottom: r.bottom };
|
|
640
642
|
}
|
|
641
|
-
function buildPortalPopoverStyle(
|
|
643
|
+
function buildPortalPopoverStyle(rect2, viewportBottom, viewportWidth) {
|
|
642
644
|
return {
|
|
643
|
-
...viewportBottom !== void 0 ? { maxHeight: menuMaxHeight(
|
|
645
|
+
...viewportBottom !== void 0 ? { maxHeight: menuMaxHeight(rect2.bottom, viewportBottom) } : null,
|
|
644
646
|
// RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
|
|
645
647
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
|
|
646
648
|
position: "fixed",
|
|
647
|
-
top:
|
|
648
|
-
...horizontalPlacement(
|
|
649
|
+
top: rect2.bottom + MENU_TOP_GAP2,
|
|
650
|
+
...horizontalPlacement(rect2, viewportWidth),
|
|
649
651
|
zIndex: MENU_PORTAL_Z_INDEX
|
|
650
652
|
};
|
|
651
653
|
}
|
|
652
|
-
function horizontalPlacement(
|
|
653
|
-
if (viewportWidth === void 0) return { left:
|
|
654
|
-
const width = Math.min(Math.max(
|
|
655
|
-
const left = Math.max(VIEWPORT_MARGIN, Math.min(
|
|
654
|
+
function horizontalPlacement(rect2, viewportWidth) {
|
|
655
|
+
if (viewportWidth === void 0) return { left: rect2.left, width: rect2.width };
|
|
656
|
+
const width = Math.min(Math.max(rect2.width, MENU_MIN_WIDTH), viewportWidth - 2 * VIEWPORT_MARGIN);
|
|
657
|
+
const left = Math.max(VIEWPORT_MARGIN, Math.min(rect2.left, viewportWidth - VIEWPORT_MARGIN - width));
|
|
656
658
|
return { left, width };
|
|
657
659
|
}
|
|
658
660
|
function useAnchorRect(ref, enabled) {
|
|
659
|
-
const [
|
|
661
|
+
const [rect2, setRect] = React2.useState(null);
|
|
660
662
|
React2.useLayoutEffect(() => {
|
|
661
663
|
if (!IS_WEB3 || !enabled) {
|
|
662
664
|
setRect(null);
|
|
@@ -690,7 +692,7 @@ function useAnchorRect(ref, enabled) {
|
|
|
690
692
|
if (observer !== null) observer.disconnect();
|
|
691
693
|
};
|
|
692
694
|
}, [ref, enabled]);
|
|
693
|
-
return IS_WEB3 && enabled ?
|
|
695
|
+
return IS_WEB3 && enabled ? rect2 : null;
|
|
694
696
|
}
|
|
695
697
|
function roomUnderAnchor(anchorBottom, viewportBottom) {
|
|
696
698
|
return viewportBottom - anchorBottom - MENU_TOP_GAP2 - VIEWPORT_MARGIN;
|
|
@@ -795,11 +797,11 @@ function AnchoredMenu({
|
|
|
795
797
|
const menuRef = React2__default.default.useRef(null);
|
|
796
798
|
useDismiss(anchorRef, menuRef, onDismiss);
|
|
797
799
|
useKeepHighlightInView(testID, listbox?.highlightedValue);
|
|
798
|
-
const
|
|
800
|
+
const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
|
|
799
801
|
const viewportBottom = useVisualViewportBottom(usePortal);
|
|
800
802
|
const { width: windowWidth } = reactNative.useWindowDimensions();
|
|
801
|
-
const portalStyle =
|
|
802
|
-
const menuWidth =
|
|
803
|
+
const portalStyle = rect2 !== null ? buildPortalPopoverStyle(rect2, viewportBottom ?? void 0, placement !== void 0 ? windowWidth : void 0) : null;
|
|
804
|
+
const menuWidth = rect2?.width ?? windowWidth;
|
|
803
805
|
const isListbox = listbox !== void 0;
|
|
804
806
|
const statusText = listbox?.statusText;
|
|
805
807
|
const rows = options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1893,6 +1895,7 @@ var RANK_VALUE_EXACT = 0;
|
|
|
1893
1895
|
var RANK_VALUE_PREFIX = 1;
|
|
1894
1896
|
var RANK_LABEL_PREFIX = 2;
|
|
1895
1897
|
var RANK_LABEL_CONTAINS = 3;
|
|
1898
|
+
var RANK_DETAIL_CONTAINS = 4;
|
|
1896
1899
|
var NO_MATCH = -1;
|
|
1897
1900
|
function rankOf(option, needle) {
|
|
1898
1901
|
const value = option.value.toLowerCase();
|
|
@@ -1901,6 +1904,7 @@ function rankOf(option, needle) {
|
|
|
1901
1904
|
if (value.startsWith(needle)) return RANK_VALUE_PREFIX;
|
|
1902
1905
|
if (label.startsWith(needle)) return RANK_LABEL_PREFIX;
|
|
1903
1906
|
if (label.includes(needle)) return RANK_LABEL_CONTAINS;
|
|
1907
|
+
if ((option.detail ?? "").toLowerCase().includes(needle)) return RANK_DETAIL_CONTAINS;
|
|
1904
1908
|
return NO_MATCH;
|
|
1905
1909
|
}
|
|
1906
1910
|
function suggestOptions(options, query, minChars, limit) {
|
|
@@ -2398,7 +2402,7 @@ function useFocusFirstInvalid(refs) {
|
|
|
2398
2402
|
const latest = React2.useRef(refs);
|
|
2399
2403
|
latest.current = refs;
|
|
2400
2404
|
return React2.useCallback((invalid) => {
|
|
2401
|
-
const first = invalid.map((
|
|
2405
|
+
const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
|
|
2402
2406
|
first?.focus();
|
|
2403
2407
|
}, []);
|
|
2404
2408
|
}
|
|
@@ -2558,10 +2562,1499 @@ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) =>
|
|
|
2558
2562
|
] });
|
|
2559
2563
|
};
|
|
2560
2564
|
|
|
2565
|
+
// src/SearchSelect/SelectSurface.ts
|
|
2566
|
+
var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
|
|
2567
|
+
SelectSurface2["Sheet"] = "sheet";
|
|
2568
|
+
SelectSurface2["Dropdown"] = "dropdown";
|
|
2569
|
+
return SelectSurface2;
|
|
2570
|
+
})(SelectSurface || {});
|
|
2571
|
+
function useAnchorRect2(anchorRef) {
|
|
2572
|
+
const [rect2, setRect] = React2.useState(null);
|
|
2573
|
+
React2.useEffect(() => {
|
|
2574
|
+
anchorRef.current?.measureInWindow((x, y, width, height) => setRect({ x, y, width, height }));
|
|
2575
|
+
}, [anchorRef]);
|
|
2576
|
+
return rect2;
|
|
2577
|
+
}
|
|
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
|
+
] });
|
|
2609
|
+
}
|
|
2610
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
2611
|
+
dropdown: { position: "absolute" }
|
|
2612
|
+
});
|
|
2613
|
+
var ROW_PAD_H = 12;
|
|
2614
|
+
var ROW_GAP4 = 8;
|
|
2615
|
+
var OPTION_FONT2 = 14;
|
|
2616
|
+
var DETAIL_FONT2 = 12;
|
|
2617
|
+
function OptionRow2({ option, active, current, renderLeading, renderDetail, onPick, optionHint, testID }) {
|
|
2618
|
+
const { theme } = uiFeedback.useUi();
|
|
2619
|
+
const { colors } = theme;
|
|
2620
|
+
const ref = useKeepInView(active ? option.value : null);
|
|
2621
|
+
const detailBelow = renderDetail === void 0 && option.detail !== void 0;
|
|
2622
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2623
|
+
reactNative.Pressable,
|
|
2624
|
+
{
|
|
2625
|
+
ref,
|
|
2626
|
+
accessibilityHint: optionHint,
|
|
2627
|
+
accessibilityLabel: option.label,
|
|
2628
|
+
accessibilityRole: "button",
|
|
2629
|
+
accessibilityState: { selected: active, checked: current },
|
|
2630
|
+
style: [styles19.row, active ? { backgroundColor: colors.surface } : null],
|
|
2631
|
+
testID: `${testID}-option-${option.value}`,
|
|
2632
|
+
onPress: () => onPick(option),
|
|
2633
|
+
children: [
|
|
2634
|
+
renderLeading?.(option),
|
|
2635
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles19.label, children: [
|
|
2636
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles19.primary, { color: colors.text }], children: option.label }),
|
|
2637
|
+
detailBelow ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles19.secondary, { color: colors.textSecondary }], children: option.detail }) : null
|
|
2638
|
+
] }),
|
|
2639
|
+
renderDetail?.(option)
|
|
2640
|
+
]
|
|
2641
|
+
}
|
|
2642
|
+
);
|
|
2643
|
+
}
|
|
2644
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
2645
|
+
row: { minHeight: a11y.MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
|
|
2646
|
+
label: { flex: 1 },
|
|
2647
|
+
primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
|
|
2648
|
+
secondary: { fontSize: DETAIL_FONT2 }
|
|
2649
|
+
});
|
|
2650
|
+
var ROW_PAD_H2 = 12;
|
|
2651
|
+
var ROW_GAP5 = 8;
|
|
2652
|
+
var HEADER_FONT = 11;
|
|
2653
|
+
function OptionSection({ title, options, offset, highlight, selectedValue, ...row }) {
|
|
2654
|
+
const { theme } = uiFeedback.useUi();
|
|
2655
|
+
const { colors } = theme;
|
|
2656
|
+
if (options.length === 0) return null;
|
|
2657
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
|
|
2658
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles20.header, { color: colors.textSecondary }], children: title }),
|
|
2659
|
+
options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
|
|
2660
|
+
] });
|
|
2661
|
+
}
|
|
2662
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2663
|
+
header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
|
|
2664
|
+
});
|
|
2665
|
+
function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children }) {
|
|
2666
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles21.backdrop, children: [
|
|
2667
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: reactNative.StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
|
|
2668
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: { transform: [{ translateY }] }, children })
|
|
2669
|
+
] }) });
|
|
2670
|
+
}
|
|
2671
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2672
|
+
backdrop: { flex: 1, justifyContent: "flex-end" }
|
|
2673
|
+
});
|
|
2674
|
+
var KEY_ESCAPE = "Escape";
|
|
2675
|
+
var PANEL_PAD = 8;
|
|
2676
|
+
var PANEL_RADIUS = 8;
|
|
2677
|
+
var SHEET_MAX_HEIGHT = 480;
|
|
2678
|
+
function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
|
|
2679
|
+
const { theme } = uiFeedback.useUi();
|
|
2680
|
+
const { colors } = theme;
|
|
2681
|
+
const progress = React2.useRef(new reactNative.Animated.Value(0)).current;
|
|
2682
|
+
const { durationMs } = motion;
|
|
2683
|
+
React2.useEffect(() => {
|
|
2684
|
+
reactNative.Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
|
|
2685
|
+
}, [progress, durationMs]);
|
|
2686
|
+
const leaving = React2.useRef(false);
|
|
2687
|
+
const leave = React2.useCallback((after) => {
|
|
2688
|
+
if (leaving.current) return;
|
|
2689
|
+
leaving.current = true;
|
|
2690
|
+
if (durationMs === 0) return after();
|
|
2691
|
+
reactNative.Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
|
|
2692
|
+
}, [progress, durationMs]);
|
|
2693
|
+
const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
|
|
2694
|
+
const dismiss = React2.useCallback(() => leave(close), [leave, close]);
|
|
2695
|
+
const pick = React2.useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
|
|
2696
|
+
const submit = React2.useCallback(() => submitNow(pick), [submitNow, pick]);
|
|
2697
|
+
const onKeyPress = React2.useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
|
|
2698
|
+
const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
|
|
2699
|
+
const isSheet = motion.surface === "sheet" /* Sheet */;
|
|
2700
|
+
const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
|
|
2701
|
+
const list = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles22.panel, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }], testID: `${testID}-panel`, children: [
|
|
2702
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2703
|
+
reactNative.TextInput,
|
|
2704
|
+
{
|
|
2705
|
+
autoFocus: true,
|
|
2706
|
+
accessibilityHint: labels.searchHint,
|
|
2707
|
+
accessibilityLabel: labels.search,
|
|
2708
|
+
placeholder: labels.search,
|
|
2709
|
+
placeholderTextColor: colors.textSecondary,
|
|
2710
|
+
style: [controlStyles.input, { color: colors.text, borderColor: colors.border }],
|
|
2711
|
+
testID: `${testID}-search`,
|
|
2712
|
+
value: state.query,
|
|
2713
|
+
onChangeText: state.setQuery,
|
|
2714
|
+
onKeyPress: (event) => onKeyPress(event.nativeEvent.key),
|
|
2715
|
+
onSubmitEditing: submit
|
|
2716
|
+
}
|
|
2717
|
+
),
|
|
2718
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ? styles22.sheetList : styles22.dropList, children: [
|
|
2719
|
+
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: 0, options: sections.recent, title: labels.recent }),
|
|
2720
|
+
/* @__PURE__ */ jsxRuntime.jsx(OptionSection, { ...shared, offset: sections.recent.length, options: sections.all, title: labels.all }),
|
|
2721
|
+
sections.flat.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.empty, { color: colors.textSecondary }], children: labels.empty }) : null
|
|
2722
|
+
] })
|
|
2723
|
+
] });
|
|
2724
|
+
if (!isSheet) return /* @__PURE__ */ jsxRuntime.jsx(DropdownSurface, { anchorRef, closeHint: labels.closeHint, closeLabel: labels.close, progress, testID, translateY, onDismiss: dismiss, children: list });
|
|
2725
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
|
|
2726
|
+
}
|
|
2727
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
2728
|
+
panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
|
|
2729
|
+
dropList: { maxHeight: MENU_MAX_HEIGHT },
|
|
2730
|
+
sheetList: { maxHeight: SHEET_MAX_HEIGHT },
|
|
2731
|
+
empty: { padding: PANEL_PAD }
|
|
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
|
+
}
|
|
2739
|
+
function useReducedMotion() {
|
|
2740
|
+
const [reduced, setReduced] = React2.useState(false);
|
|
2741
|
+
React2.useEffect(() => {
|
|
2742
|
+
let active = true;
|
|
2743
|
+
reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
|
|
2744
|
+
if (active) setReduced(value);
|
|
2745
|
+
}).catch(() => void 0);
|
|
2746
|
+
const subscription = reactNative.AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
|
|
2747
|
+
return () => {
|
|
2748
|
+
active = false;
|
|
2749
|
+
subscription.remove();
|
|
2750
|
+
};
|
|
2751
|
+
}, []);
|
|
2752
|
+
return reduced;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
// src/SearchSelect/utils/searchSelectModel.ts
|
|
2756
|
+
var MIN_QUERY = 1;
|
|
2757
|
+
function buildSearchSelectSections(options, query, recentValues) {
|
|
2758
|
+
const matches = query.trim() === "" ? options : suggestOptions(options, query, MIN_QUERY, options.length);
|
|
2759
|
+
const byValue = new Map(matches.map((option) => [option.value, option]));
|
|
2760
|
+
const recent = recentValues.map((value) => byValue.get(value)).filter((option) => option !== void 0);
|
|
2761
|
+
const recentSet = new Set(recent.map((option) => option.value));
|
|
2762
|
+
const all = matches.filter((option) => !recentSet.has(option.value));
|
|
2763
|
+
return { recent, all, flat: [...recent, ...all] };
|
|
2764
|
+
}
|
|
2765
|
+
function findOption(options, value) {
|
|
2766
|
+
return options.find((option) => option.value === value) ?? null;
|
|
2767
|
+
}
|
|
2768
|
+
function moveHighlight(index, count, step) {
|
|
2769
|
+
if (count === 0) return -1;
|
|
2770
|
+
if (index < 0) return step > 0 ? 0 : count - 1;
|
|
2771
|
+
return (index + step + count) % count;
|
|
2772
|
+
}
|
|
2773
|
+
function highlightAfterQuery(query) {
|
|
2774
|
+
return query.trim() === "" ? -1 : 0;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
// src/SearchSelect/hooks/useSearchSelectState.ts
|
|
2778
|
+
var KEY_DOWN = "ArrowDown";
|
|
2779
|
+
var KEY_UP = "ArrowUp";
|
|
2780
|
+
var KEY_ESCAPE2 = "Escape";
|
|
2781
|
+
function useSearchSelectState(options, recents, onChange, onClosed) {
|
|
2782
|
+
const [open, setOpen] = React2.useState(false);
|
|
2783
|
+
const [query, setQueryState] = React2.useState("");
|
|
2784
|
+
const [rawHighlight, setHighlight] = React2.useState(-1);
|
|
2785
|
+
const sections = React2.useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
|
|
2786
|
+
const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
|
|
2787
|
+
const active = sections.flat[highlight];
|
|
2788
|
+
const { remember } = recents;
|
|
2789
|
+
const close = React2.useCallback(() => {
|
|
2790
|
+
setOpen(false);
|
|
2791
|
+
setQueryState("");
|
|
2792
|
+
setHighlight(-1);
|
|
2793
|
+
onClosed();
|
|
2794
|
+
}, [onClosed]);
|
|
2795
|
+
const pick = React2.useCallback((option) => {
|
|
2796
|
+
remember(option.value);
|
|
2797
|
+
onChange(option.value);
|
|
2798
|
+
close();
|
|
2799
|
+
}, [remember, onChange, close]);
|
|
2800
|
+
const submit = React2.useCallback((via = pick) => {
|
|
2801
|
+
if (active !== void 0) via(active);
|
|
2802
|
+
}, [active, pick]);
|
|
2803
|
+
const setQuery = React2.useCallback((next) => {
|
|
2804
|
+
setQueryState(next);
|
|
2805
|
+
setHighlight(highlightAfterQuery(next));
|
|
2806
|
+
}, []);
|
|
2807
|
+
const onKey = React2.useCallback((key) => {
|
|
2808
|
+
const count = sections.flat.length;
|
|
2809
|
+
if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
|
|
2810
|
+
if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
|
|
2811
|
+
if (key === KEY_ESCAPE2) close();
|
|
2812
|
+
}, [sections.flat.length, highlight, close]);
|
|
2813
|
+
const openList = React2.useCallback(() => setOpen(true), []);
|
|
2814
|
+
return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
// src/SearchSelect/utils/searchSelectMotion.ts
|
|
2818
|
+
var PHONE_MAX_WIDTH = 600;
|
|
2819
|
+
var SHEET_TRAVEL_PX = 320;
|
|
2820
|
+
var DROPDOWN_TRAVEL_PX = -8;
|
|
2821
|
+
var SHEET_MS = 240;
|
|
2822
|
+
var DROPDOWN_MS = 160;
|
|
2823
|
+
function resolveSelectMotion(width, reducedMotion) {
|
|
2824
|
+
const isPhone = width < PHONE_MAX_WIDTH;
|
|
2825
|
+
const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
|
|
2826
|
+
if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
|
|
2827
|
+
return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
|
|
2828
|
+
}
|
|
2829
|
+
var CHEVRON = "\u25BE";
|
|
2830
|
+
var VALUE_GAP = 8;
|
|
2831
|
+
function SearchSelect(props) {
|
|
2832
|
+
const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail } = props;
|
|
2833
|
+
const { theme } = uiFeedback.useUi();
|
|
2834
|
+
const { colors } = theme;
|
|
2835
|
+
const triggerRef = React2.useRef(null);
|
|
2836
|
+
const anchorRef = React2.useRef(null);
|
|
2837
|
+
const { width } = reactNative.useWindowDimensions();
|
|
2838
|
+
const motion = resolveSelectMotion(width, useReducedMotion());
|
|
2839
|
+
const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
|
|
2840
|
+
const refocus = useDeferredFocus(triggerRef);
|
|
2841
|
+
const state = useSearchSelectState(options, recents, onChange, refocus);
|
|
2842
|
+
const selected = findOption(options, value);
|
|
2843
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: styles23.anchor, children: [
|
|
2844
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2845
|
+
reactNative.Pressable,
|
|
2846
|
+
{
|
|
2847
|
+
ref: triggerRef,
|
|
2848
|
+
accessibilityHint,
|
|
2849
|
+
accessibilityLabel,
|
|
2850
|
+
accessibilityRole: "button",
|
|
2851
|
+
accessibilityState: { expanded: state.open },
|
|
2852
|
+
style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
|
|
2853
|
+
testID,
|
|
2854
|
+
onPress: state.open ? state.close : state.openList,
|
|
2855
|
+
children: [
|
|
2856
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles23.value, children: [
|
|
2857
|
+
selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
|
|
2858
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? labels.placeholder }),
|
|
2859
|
+
selected !== null ? /* @__PURE__ */ jsxRuntime.jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
|
|
2860
|
+
] }),
|
|
2861
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: CHEVRON })
|
|
2862
|
+
]
|
|
2863
|
+
}
|
|
2864
|
+
),
|
|
2865
|
+
state.open ? /* @__PURE__ */ jsxRuntime.jsx(SearchSelectPanel, { anchorRef, labels, motion, renderDetail, renderLeading, selectedValue: value, state, testID }) : null
|
|
2866
|
+
] });
|
|
2867
|
+
}
|
|
2868
|
+
function SelectedDetail({ option, colors, renderDetail }) {
|
|
2869
|
+
if (renderDetail !== void 0) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderDetail(option) });
|
|
2870
|
+
if (option.detail === void 0) return null;
|
|
2871
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: option.detail });
|
|
2872
|
+
}
|
|
2873
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
2874
|
+
anchor: { position: "relative" },
|
|
2875
|
+
value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
|
|
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
|
+
}
|
|
2894
|
+
|
|
2895
|
+
// src/CountryFlag/data/flagPalette.ts
|
|
2896
|
+
var FLAG_PALETTE = {
|
|
2897
|
+
R: "#D52B1E",
|
|
2898
|
+
W: "#FFFFFF",
|
|
2899
|
+
B: "#0039A6",
|
|
2900
|
+
N: "#012169",
|
|
2901
|
+
S: "#6CACE4",
|
|
2902
|
+
G: "#009A44",
|
|
2903
|
+
D: "#006A4E",
|
|
2904
|
+
Y: "#FCD116",
|
|
2905
|
+
K: "#000000",
|
|
2906
|
+
O: "#FF8200",
|
|
2907
|
+
M: "#9E3039",
|
|
2908
|
+
A: "#8D1B3D",
|
|
2909
|
+
T: "#00778B",
|
|
2910
|
+
P: "#5B2C83",
|
|
2911
|
+
I: "#A7A8AA",
|
|
2912
|
+
C: "#D57800",
|
|
2913
|
+
E: "#002664"
|
|
2914
|
+
};
|
|
2915
|
+
var FLAG_FALLBACK_FILL = "#C8CDD2";
|
|
2916
|
+
var FLAG_EDGE = "#8A9199";
|
|
2917
|
+
|
|
2918
|
+
// src/CountryFlag/FlagShapeKind.ts
|
|
2919
|
+
var FlagShapeKind = /* @__PURE__ */ ((FlagShapeKind2) => {
|
|
2920
|
+
FlagShapeKind2["Rect"] = "rect";
|
|
2921
|
+
FlagShapeKind2["Circle"] = "circle";
|
|
2922
|
+
FlagShapeKind2["Polygon"] = "polygon";
|
|
2923
|
+
return FlagShapeKind2;
|
|
2924
|
+
})(FlagShapeKind || {});
|
|
2925
|
+
|
|
2926
|
+
// src/CountryFlag/data/flagDrawingsAtoL.ts
|
|
2927
|
+
var BLUE_ENSIGN = "HN j0,0,10,7";
|
|
2928
|
+
var AUSTRALIA = `${BLUE_ENSIGN} s5,10.5,1.6,W s15,3,0.9,W s13,7,0.9,W s17,6,0.9,W s15,11.5,0.9,W`;
|
|
2929
|
+
var SALTIRE_A = "p0,0,1.8,0,20,12.7,20,14,18.2,14,0,1.3";
|
|
2930
|
+
var SALTIRE_B = "p20,0,18.2,0,0,12.7,0,14,1.8,14,20,1.3";
|
|
2931
|
+
var SHIELD = "p13.5,3.5,16.5,3.5,16.5,8.5,15,10,13.5,8.5";
|
|
2932
|
+
var FLAG_DRAWINGS_A_TO_L = {
|
|
2933
|
+
AD: "VBYR p8.6,5.2,11.4,5.2,11.4,8,10,9.2,8.6,8,M",
|
|
2934
|
+
AG: "HR p0,0,20,0,10,14,K c10,7,2.6,Y p5,7,15,7,10,14,B p6.8,9.5,13.2,9.5,10,14,W",
|
|
2935
|
+
AI: `${BLUE_ENSIGN} c15,7,2.6,W c15,8,1.4,O`,
|
|
2936
|
+
AL: "HR p10,2.5,14,5,13,11,10,9,7,11,6,5,K",
|
|
2937
|
+
AO: "HRK s10,7,2.2,Y",
|
|
2938
|
+
AQ: "HS c10,7,3.5,W",
|
|
2939
|
+
AS: "HN p20,0,0,7,20,14,R p20,1.2,2.6,7,20,12.8,W",
|
|
2940
|
+
AU: AUSTRALIA,
|
|
2941
|
+
AW: "HS r0,9,20,0.8,Y r0,10.6,20,0.8,Y s3.5,3.5,2.2,W s3.5,3.5,1.6,R",
|
|
2942
|
+
BA: "HB p5,0,15,0,15,14,Y s4.2,1.2,0.8,W s5.7,3.5,0.8,W s7.2,5.8,0.8,W s8.7,8.1,0.8,W s10.2,10.4,0.8,W s11.7,12.7,0.8,W",
|
|
2943
|
+
BB: "VBYB p9.4,5,10,3,10.6,5,10.4,11,9.6,11,K p7.8,3.5,8.6,3.5,9,6.5,11,6.5,11.4,3.5,12.2,3.5,11.6,7.5,8.4,7.5,K",
|
|
2944
|
+
BF: "HRG s10,7,1.8,Y",
|
|
2945
|
+
BH: "HR p0,0,6,0,8,1.4,6,2.8,8,4.2,6,5.6,8,7,6,8.4,8,9.8,6,11.2,8,12.6,6,14,0,14,W",
|
|
2946
|
+
BI: `HR p0,0,10,7,0,14,G p20,0,10,7,20,14,G ${SALTIRE_A},W ${SALTIRE_B},W c10,7,3,W s10,5.8,0.8,R s9,7.8,0.8,R s11,7.8,0.8,R`,
|
|
2947
|
+
BJ: "HYR r0,0,8,14,G",
|
|
2948
|
+
BM: "HR j0,0,10,7 c15,7.5,2.6,W c15,8.4,1.4,R",
|
|
2949
|
+
BN: "HY p0,3,20,9,20,11.5,0,5.5,W p0,5.5,20,11.5,20,14,0,8,K c10,7,2.5,R",
|
|
2950
|
+
BQ: "HW p0,0,10,0,0,7,Y p20,4,20,14,6,14,B c5.5,6,2,K c5.5,6,1.5,W s5.5,6,1,R",
|
|
2951
|
+
BR: "HG p10,1.5,18.5,7,10,12.5,1.5,7,Y c10,7,3.4,N p6.8,6,13.2,7.6,13.2,8.2,6.8,6.6,W",
|
|
2952
|
+
BS: "HTYT p0,0,8,7,0,14,K",
|
|
2953
|
+
BT: "HO p0,0,20,0,0,14,Y c10,7,2.4,W",
|
|
2954
|
+
BW: "HS r0,5.2,20,3.6,W r0,5.8,20,2.4,K",
|
|
2955
|
+
BZ: "HB r0,0,20,1.2,R r0,12.8,20,1.2,R c10,7,3.8,W c10,7,2.8,G",
|
|
2956
|
+
CA: "HW r0,0,5,14,R r15,0,5,14,R p10,2.5,11,4.5,12,4,11.6,6.5,13.5,5.5,13,7,13.6,7.6,11.3,9,11.6,10,10.2,9.6,10.2,11.5,9.8,11.5,9.8,9.6,8.4,10,8.7,9,6.4,7.6,7,7,6.5,5.5,8.4,6.5,8,4,9,4.5,R",
|
|
2957
|
+
CC: "HG c4,4,2.2,Y p3.5,6,4.5,6,4.2,2.5,3.8,2.5,G c9,7,1.8,Y c9.6,7,1.5,G s16,3,0.8,Y s14,7,0.8,Y s18,7,0.8,Y s16,11,0.8,Y",
|
|
2958
|
+
CD: "HS p0,11,16,0,20,0,20,3,4,14,0,14,Y p0,12.2,17.6,0,20,0,20,1.8,2.4,14,0,14,R s4,3.5,2.2,Y",
|
|
2959
|
+
CF: "HBWGY r8.5,0,3,14,R s3,1.75,1.2,Y",
|
|
2960
|
+
CG: "HY p0,0,13,0,0,14,G p20,0,20,14,7,14,R",
|
|
2961
|
+
CK: `${BLUE_ENSIGN} c15,7,3,W c15,7,2.3,N`,
|
|
2962
|
+
CL: "HWR r0,0,7,7,B s3.5,3.5,1.8,W",
|
|
2963
|
+
CN: "HR s3.5,3.5,2.2,Y s7,1.4,0.7,Y s8.4,2.8,0.7,Y s8.4,4.9,0.7,Y s7,6.3,0.7,Y",
|
|
2964
|
+
CU: "HBWBWB p0,0,10,7,0,14,R s3.3,7,1.8,W",
|
|
2965
|
+
CV: "HB r0,7.4,20,1,W r0,8.4,20,1.2,R r0,9.6,20,1,W s7,6,0.6,Y s9.6,7,0.6,Y s9.6,11,0.6,Y s7,12,0.6,Y s4.4,11,0.6,Y s4.4,7,0.6,Y",
|
|
2966
|
+
CW: "HB r0,9,20,1.8,Y s3,3,1.4,W s5.5,5,1,W",
|
|
2967
|
+
CX: "HB p0,0,20,0,20,14,G c10,7,2,Y s3,10,0.8,W s5.5,12,0.8,W s6,8.5,0.8,W s3,6,0.6,W p13,3,17,2,15,4.5,Y",
|
|
2968
|
+
CY: "HW p3,6,7,4,13,3.5,17,2,15,5,11,7,6,7.5,C p6.5,10.5,9.5,9.2,9.5,10,G p13.5,10.5,10.5,9.2,10.5,10,G",
|
|
2969
|
+
CZ: "HWR p0,0,10,7,0,14,B",
|
|
2970
|
+
DJ: "HSG p0,0,10,7,0,14,W s3.5,7,1.4,R",
|
|
2971
|
+
DM: "HG r8.4,0,1,14,Y r9.4,0,1,14,K r10.4,0,1,14,W r0,5.4,20,1,Y r0,6.4,20,1,K r0,7.4,20,1,W c9.9,6.9,3,R c9.9,6.9,1.2,P",
|
|
2972
|
+
DO: "HW r0,0,8.5,5.5,N r11.5,0,8.5,5.5,R r0,8.5,8.5,5.5,R r11.5,8.5,8.5,5.5,N c10,7,1.2,G",
|
|
2973
|
+
DZ: "VGW c10,7,3.2,R c11.2,7,2.6,W s12.5,7,1.2,R",
|
|
2974
|
+
EC: "HYYBR c10,7,2,Y c10,7,1.4,S",
|
|
2975
|
+
EG: "HRWK p9,5.2,11,5.2,10.6,8.6,9.4,8.6,Y",
|
|
2976
|
+
EH: "HKWG p0,0,7,7,0,14,R c10,7,1.8,R c10.6,7,1.5,W s11,7,0.9,R",
|
|
2977
|
+
ER: "HGB p0,0,20,7,0,14,R c5,7,2.6,Y c5,7,2,R",
|
|
2978
|
+
FJ: "HS j0,0,10,7 r13.5,4,3.5,4.5,W r13.5,4,3.5,1.2,R",
|
|
2979
|
+
FK: `${BLUE_ENSIGN} c15,7,2.6,S c15,8.2,1.4,W`,
|
|
2980
|
+
FM: "HS s10,3.5,1.2,W s6.5,7,1.2,W s13.5,7,1.2,W s10,10.5,1.2,W",
|
|
2981
|
+
GB: "j0,0,20,14",
|
|
2982
|
+
GD: "HR p1.5,1.5,18.5,1.5,10,7,Y p1.5,12.5,18.5,12.5,10,7,Y p1.5,1.5,10,7,1.5,12.5,G p18.5,1.5,10,7,18.5,12.5,G c10,7,2,R s10,7,1.3,Y s5,0.75,0.6,Y s10,0.75,0.6,Y s15,0.75,0.6,Y s5,13.25,0.6,Y s10,13.25,0.6,Y s15,13.25,0.6,Y",
|
|
2983
|
+
GG: "HW r8.5,0,3,14,R r0,5.5,20,3,R r9.6,4.2,0.8,5.6,Y r7.2,6.6,5.6,0.8,Y",
|
|
2984
|
+
GH: "HRYG s10,7,2,K",
|
|
2985
|
+
GI: "HWWR r6.5,3,7,5,R r6.5,1.8,1.5,1.4,R r9.25,1.8,1.5,1.4,R r12,1.8,1.5,1.4,R p9.5,9.3,10.5,9.3,10.5,12,9.5,12,Y",
|
|
2986
|
+
GL: "HWR c7,7,4.5,R p2.5,7,3.1,9.25,4.75,10.9,7,11.5,9.25,10.9,10.9,9.25,11.5,7,W",
|
|
2987
|
+
GQ: "HGWR p0,0,5,7,0,14,B c10,7,1.3,G",
|
|
2988
|
+
GR: "HBWBWBWBWB r0,0,7.78,7.78,B r3.11,0,1.56,7.78,W r0,3.11,7.78,1.56,W",
|
|
2989
|
+
GS: `${BLUE_ENSIGN} c15,7,2.6,W c15,7.5,1.4,Y`,
|
|
2990
|
+
GU: "HR r1,1,18,12,N p10,3,13,7,10,11,7,7,S",
|
|
2991
|
+
GW: "HYG r0,0,7,14,R s3.5,7,2,K",
|
|
2992
|
+
GY: "HG p0,0,20,7,0,14,W p0,0.8,18.6,7,0,13.2,Y p0,0,10,7,0,14,K p0,1,8.6,7,0,13,R",
|
|
2993
|
+
HK: "HR s10,7,3.4,W s10,7,1,R",
|
|
2994
|
+
HM: AUSTRALIA,
|
|
2995
|
+
HN: "HBWB s10,7,0.9,B s6.5,5.8,0.9,B s6.5,8.2,0.9,B s13.5,5.8,0.9,B s13.5,8.2,0.9,B",
|
|
2996
|
+
HR: "HRWB r8.5,3.5,3,4,W r8.5,3.5,1,1,R r10.5,3.5,1,1,R r9.5,4.5,1,1,R r8.5,5.5,1,1,R r10.5,5.5,1,1,R r9.5,6.5,1,1,R",
|
|
2997
|
+
HT: "HBR r7,4.5,6,5,W r9.3,5.3,1.4,3.4,G",
|
|
2998
|
+
IL: "HW r0,1.4,20,2,B r0,10.6,20,2,B p10,4,12.6,8.5,7.4,8.5,B p10,10,7.4,5.5,12.6,5.5,B p10,4.8,11.9,8.1,8.1,8.1,W p10,9.2,8.1,5.9,11.9,5.9,W",
|
|
2999
|
+
IM: "HR p9.6,6.6,6.2,3.4,6.8,2.8,10.4,6.4,W p10,6.4,14.5,4.3,14.8,5.1,10.2,7.2,W p9.6,7.2,9.1,11.8,10,11.9,10.4,7,W",
|
|
3000
|
+
IN: "HOWG c10,7,1.8,N c10,7,1.4,W",
|
|
3001
|
+
IO: "HW r0,3,20,1,N r0,6,20,1,N r0,9,20,1,N r0,12,20,1,N j0,0,10,7 p14,10,15,10,14.8,5,14.2,5,G c14.5,5,1.4,G",
|
|
3002
|
+
IQ: "HRWK r7,5.6,6,1.4,G",
|
|
3003
|
+
JE: `HW ${SALTIRE_A},R ${SALTIRE_B},R p8.8,1.5,11.2,1.5,11.2,3.5,10,4.3,8.8,3.5,R c10,1.2,0.6,Y`,
|
|
3004
|
+
JM: `HG p0,0,10,7,0,14,K p20,0,10,7,20,14,K ${SALTIRE_A},Y ${SALTIRE_B},Y`,
|
|
3005
|
+
JO: "HKWG p0,0,10,7,0,14,R s3.5,7,1.2,W",
|
|
3006
|
+
KE: "HK r0,4.2,20,5.6,W r0,5,20,4,R r0,9.8,20,4.2,G p10,2,12.2,7,10,12,7.8,7,K p10,3,11.4,7,10,11,8.6,7,R r9.8,4,0.4,6,W",
|
|
3007
|
+
KH: "HBRRB p6,9.5,6.5,6.5,8,6.5,8.5,5,9.5,5,10,3.5,10.5,5,11.5,5,12,6.5,13.5,6.5,14,9.5,W",
|
|
3008
|
+
KI: "HR c10,7.2,3,Y r0,7,20,7,B r0,8.2,20,0.8,W r0,10.2,20,0.8,W r0,12.2,20,0.8,W p6.5,3.5,13.5,2.5,10.5,4.5,Y",
|
|
3009
|
+
KM: "HYWRB p0,0,9,7,0,14,G c3.2,7,2.2,W c4,7,1.9,G",
|
|
3010
|
+
KN: "HR p0,0,20,0,0,14,G p0,10,14.3,0,20,0,20,4,5.7,14,0,14,Y p0,11.6,16.6,0,20,0,20,2.4,3.4,14,0,14,K s7,8,0.9,W s13,4,0.9,W",
|
|
3011
|
+
KP: "HB r0,2.4,20,9.2,W r0,2.9,20,8.2,R c6.5,7,2.6,W s6.5,7,2.3,R",
|
|
3012
|
+
KR: "HW c10,7,3.4,R p6.6,7,7.1,8.7,8.3,9.9,10,10.4,11.7,9.9,12.9,8.7,13.4,7,B c8.3,7,1.7,R c11.7,7,1.7,B r3,2,2.4,0.5,K r3,3,2.4,0.5,K r3,4,2.4,0.5,K r14.6,10,2.4,0.5,K r14.6,11,2.4,0.5,K r14.6,12,2.4,0.5,K r3,10,2.4,0.5,K r3,11,2.4,0.5,K r3,12,2.4,0.5,K r14.6,2,2.4,0.5,K r14.6,3,2.4,0.5,K r14.6,4,2.4,0.5,K",
|
|
3013
|
+
KW: "HGWR p0,0,5,4.67,5,9.33,0,14,K",
|
|
3014
|
+
KY: `${BLUE_ENSIGN} c15,7,2.6,W c15,7.8,1.6,R`,
|
|
3015
|
+
KZ: "HS c10,6,2.2,Y p6,9,14,9,10,10.5,Y r1,0,1,14,Y",
|
|
3016
|
+
LB: "HR r0,3.5,20,7,W p10,4.2,13,9.5,7,9.5,G",
|
|
3017
|
+
LC: "HS p10,2,15,12,5,12,W p10,3.5,14,12,6,12,K p10,7,15,12,5,12,Y",
|
|
3018
|
+
LI: "HBR p3,4.5,3,2,4.2,3,5,1.5,5.8,3,7,2,7,4.5,Y",
|
|
3019
|
+
LK: "HY r1,1,2.5,12,G r3.5,1,2.5,12,O r7,1,12,12,A p9,11,17,11,16,4,13,3.5,11,5,Y",
|
|
3020
|
+
LR: "HRWRWRWRWRWR r0,0,6.36,6.36,N s3.18,3.18,1.8,W",
|
|
3021
|
+
LY: "HRKKG c10,7,2.2,W c10.7,7,1.8,K s12.2,7,0.9,W"
|
|
3022
|
+
};
|
|
3023
|
+
|
|
3024
|
+
// src/CountryFlag/data/flagDrawingsMtoZ.ts
|
|
3025
|
+
var USA = "HRWRWRWRWRWRWR r0,0,9,7.54,N s2,1.5,0.5,W s4.5,1.5,0.5,W s7,1.5,0.5,W s3.2,3.8,0.5,W s5.8,3.8,0.5,W s2,6,0.5,W s4.5,6,0.5,W s7,6,0.5,W";
|
|
3026
|
+
var TRIBAND_FIMBRIATED = "HK r0,4.2,20,5.6,W r0,5,20,4,R r0,9.8,20,4.2,G";
|
|
3027
|
+
var FLAG_DRAWINGS_M_TO_Z = {
|
|
3028
|
+
MA: "HR s10,7,3.2,G s10,7,2.4,R",
|
|
3029
|
+
MD: "VBYR p8.5,5,11.5,5,11,8.5,10,9.5,9,8.5,C",
|
|
3030
|
+
ME: "HY r1,1,18,12,R p10,4,13,6,12,10,10,9,8,10,7,6,Y",
|
|
3031
|
+
MG: "HRG r0,0,6.7,14,W",
|
|
3032
|
+
MH: "HN p0,14,20,0.2,20,2.5,O p0,14,20,2.5,20,4.8,W s4.5,4.5,2.2,W",
|
|
3033
|
+
MK: "HR p0,0,3,0,10,7,0,2,Y p20,0,17,0,10,7,20,2,Y p0,14,3,14,10,7,0,12,Y p20,14,17,14,10,7,20,12,Y p8.5,0,11.5,0,10,7,Y p8.5,14,11.5,14,10,7,Y p0,5.5,0,8.5,10,7,Y p20,5.5,20,8.5,10,7,Y c10,7,2.4,R c10,7,2,Y",
|
|
3034
|
+
MM: "HYGR s10,7.4,4,W",
|
|
3035
|
+
MO: "HG c10,8.5,1.8,W p7,10.5,13,10.5,12,11.2,8,11.2,W s10,4,0.9,Y s7.5,5,0.6,Y s12.5,5,0.6,Y s6,6.5,0.6,Y s14,6.5,0.6,Y",
|
|
3036
|
+
MP: "HB c10,7,3.4,O c10,7,2.8,B p9,10,11,10,10.6,4.5,9.4,4.5,I s10,7,1.8,W",
|
|
3037
|
+
MR: "HG r0,0,20,2,R r0,12,20,2,R c10,6.2,3,Y c10,5.2,2.8,G s10,5.4,1,Y",
|
|
3038
|
+
MS: `${BLUE_ENSIGN} c15,7,2.6,S c15,8.2,1.4,G`,
|
|
3039
|
+
MV: "HR r4,3.5,12,7,G c10,7,2.6,W c11,7,2.3,G",
|
|
3040
|
+
MX: "VGWR c10,6.8,1.5,M p8.2,7.6,11.8,7.6,11,9,9,9,G",
|
|
3041
|
+
MY: "HRWRWRWRWRWRWRW r0,0,10,8,N c4,4,2.6,Y c4.8,4,2.2,N s7.6,4,1.6,Y",
|
|
3042
|
+
MZ: "HG r0,4.5,20,5,W r0,5,20,4,K r0,9.5,20,4.5,Y p0,0,8,7,0,14,R s3,7,1.8,Y",
|
|
3043
|
+
NA: "HG p0,0,20,0,0,14,B p0,14,0,11,15.7,0,20,0,20,3,4.3,14,W p0,14,0,12.4,17.7,0,20,0,20,1.6,2.3,14,R s4.5,3.5,2.2,Y",
|
|
3044
|
+
NE: "HOWG c10,7,1.5,O",
|
|
3045
|
+
NF: "VGWG p10,2,12,11,8,11,G r9.6,11,0.8,1.5,G",
|
|
3046
|
+
NI: "HBWB p10,5.2,12,8.6,8,8.6,S",
|
|
3047
|
+
NP: "HW p2,0,14,6,5.5,6,14,13.5,2,13.5,B p3,1.2,11.5,5.5,4,5.5,11.5,12.8,3,12.8,R c5.5,4,1,W s5.5,10,1.3,W",
|
|
3048
|
+
NR: "HN r0,6.3,20,1.4,Y s5,10.5,1.8,W",
|
|
3049
|
+
NU: "HY j0,0,10,7 c5,3.5,1,N s5,3.5,0.8,Y",
|
|
3050
|
+
NZ: `${BLUE_ENSIGN} s15,3,1.1,W s15,3,0.7,R s12.5,7,1.1,W s12.5,7,0.7,R s17.5,6,1,W s17.5,6,0.6,R s15,11,1.2,W s15,11,0.8,R`,
|
|
3051
|
+
OM: "HWRG r0,0,5.5,14,R p1.5,2,4,2,2.75,3.5,W",
|
|
3052
|
+
PA: "HW r10,0,10,7,R r0,7,10,7,B s5,3.5,1.6,B s15,10.5,1.6,R",
|
|
3053
|
+
PG: "HK p0,0,20,0,20,14,R p12,3,17,2,16,4,13,6,Y s4,5,0.8,W s6.5,7,0.8,W s4,10,0.9,W s2,7,0.7,W",
|
|
3054
|
+
PH: "HBR p0,0,10,7,0,14,W c3.2,7,1.4,Y s1.2,1.8,0.6,Y s1.2,12.2,0.6,Y s7.8,7,0.6,Y",
|
|
3055
|
+
PK: "HG r0,0,5,14,W c12.5,7,3.4,W c13.5,6.3,3,G s14.8,5.5,1.2,W",
|
|
3056
|
+
PN: `${BLUE_ENSIGN} p13.5,4,16.5,4,16.5,8,15,9.5,13.5,8,G r13.5,4,3,1.5,S`,
|
|
3057
|
+
PR: "HRWRWR p0,0,10,7,0,14,B s3.5,7,1.8,W",
|
|
3058
|
+
PS: "HKWG p0,0,8,7,0,14,R",
|
|
3059
|
+
PY: "HRWB c10,7,1.6,Y c10,7,1.1,W",
|
|
3060
|
+
QA: "HA p0,0,5.5,0,7.5,0.78,5.5,1.56,7.5,2.33,5.5,3.11,7.5,3.89,5.5,4.67,7.5,5.44,5.5,6.22,7.5,7,5.5,7.78,7.5,8.56,5.5,9.33,7.5,10.11,5.5,10.89,7.5,11.67,5.5,12.44,7.5,13.22,5.5,14,0,14,W",
|
|
3061
|
+
SA: "HG r4,4,12,1.2,W r5,6,10,0.8,W r5,9,10,0.7,W r14.5,8.5,1.2,1.2,W",
|
|
3062
|
+
SB: "HG p0,0,20,0,0,14,B p0,13,18.6,0,20,0,20,1,1.4,14,0,14,Y s2.5,2,0.8,W s6.5,2,0.8,W s4.5,3.5,0.8,W s2.5,5,0.8,W s6.5,5,0.8,W",
|
|
3063
|
+
SC: "HG p0,14,0,0,6.7,0,B p0,14,6.7,0,13.3,0,Y p0,14,13.3,0,20,0,20,4.7,R p0,14,20,4.7,20,9.3,W",
|
|
3064
|
+
SD: "HRWK p0,0,7,7,0,14,G",
|
|
3065
|
+
SG: "HRW c4.5,3.5,2.6,W c5.5,3.5,2.4,R s6.5,1.9,0.5,W s5.3,3,0.5,W s7.7,3,0.5,W s5.8,4.6,0.5,W s7.2,4.6,0.5,W",
|
|
3066
|
+
SH: `${BLUE_ENSIGN} ${SHIELD},S r13.5,3.5,3,1.8,Y`,
|
|
3067
|
+
SI: "HWBR p3.5,2.5,6.5,2.5,6.5,6,5,7.2,3.5,6,B",
|
|
3068
|
+
SK: "HWBR p3.5,3.5,8,3.5,8,9,5.75,10.5,3.5,9,R p5.4,5,6.1,5,6.1,9,5.4,9,W",
|
|
3069
|
+
SM: "HWS c10,7,1.8,Y c10,7,1.2,G",
|
|
3070
|
+
SN: "VGYR s10,7,1.8,G",
|
|
3071
|
+
SO: "HS s10,7,3.2,W",
|
|
3072
|
+
SR: "HG r0,2.8,20,8.4,W r0,4.2,20,5.6,R s10,7,2.4,Y",
|
|
3073
|
+
SS: `${TRIBAND_FIMBRIATED} p0,0,8,7,0,14,B s3,7,1.5,Y`,
|
|
3074
|
+
ST: "HG r0,4,20,6,Y p0,0,6,7,0,14,R s10,7,1.3,K s14.5,7,1.3,K",
|
|
3075
|
+
SX: "HRB p0,0,10,7,0,14,W c3.6,7,1.6,Y c3.6,7,1.1,S",
|
|
3076
|
+
SY: "HRWK s7,7,1.3,G s13,7,1.3,G",
|
|
3077
|
+
SZ: "HB r0,3,20,8,Y r0,4,20,6,R p4,7,10,4.4,16,7,10,9.6,W p10,4.4,16,7,10,9.6,K",
|
|
3078
|
+
TC: `${BLUE_ENSIGN} ${SHIELD},Y`,
|
|
3079
|
+
TD: "VEYR",
|
|
3080
|
+
TG: "HGYGYG r0,0,8.4,8.4,R s4.2,4.2,2.2,W",
|
|
3081
|
+
TJ: "HRWG p8,7.5,12,7.5,11.5,5.8,10,6.6,8.5,5.8,Y",
|
|
3082
|
+
TK: "HN p4,10,16,9,15,11,6,11.5,Y s4,3,0.8,W s7,5,0.8,W s5,7,0.8,W s3,5.5,0.6,W",
|
|
3083
|
+
TL: "HR p0,0,10,7,0,14,Y p0,0,6.7,7,0,14,K s2.4,7,1.3,W",
|
|
3084
|
+
TM: "HG r2.5,0,3,14,A r3.4,0,0.4,14,O r4.2,0,0.4,14,O c9.5,4,2.4,W c10.3,3.6,2.2,G s12,3,0.6,W s12.5,4.6,0.6,W",
|
|
3085
|
+
TN: "HR c10,7,3.5,W c10.4,7,2.6,R c11.1,7,2.1,W s11.2,7,1.2,R",
|
|
3086
|
+
TO: "HR r0,0,8,7,W r3.3,1,1.4,5,R r1.5,2.8,5,1.4,R",
|
|
3087
|
+
TR: "HR c7.5,7,3.5,W c8.4,7,2.8,R s12.3,7,1.5,W",
|
|
3088
|
+
TT: "HR p0,0,5,0,20,10.5,20,14,15,14,0,3.5,W p0,0.7,1,0,4,0,20,11.3,20,13.3,19,14,16,14,0,2.7,K",
|
|
3089
|
+
TV: "HS j0,0,10,7 s13,9,0.7,Y s15,11,0.7,Y s17,8,0.7,Y s12,12,0.7,Y s16,4,0.7,Y s18,11.5,0.7,Y s14,6.5,0.7,Y s18.5,3,0.7,Y s11.5,9.5,0.7,Y",
|
|
3090
|
+
TW: "HR r0,0,10,7,N s5,3.5,2.4,W c5,3.5,1.3,N c5,3.5,1,W",
|
|
3091
|
+
TZ: "HB p0,0,20,0,0,14,G p0,11,15.7,0,20,0,20,3,4.3,14,0,14,Y p0,12.4,17.7,0,20,0,20,1.6,2.3,14,0,14,K",
|
|
3092
|
+
UM: USA,
|
|
3093
|
+
US: USA,
|
|
3094
|
+
UY: "HWBWBWBWBW r0,0,7.78,7.78,W s3.9,3.9,2.6,Y c3.9,3.9,1.5,Y",
|
|
3095
|
+
VA: "VYW p12,4,15,10,14.3,10.3,11.3,4.3,Y p15,4,12,10,12.7,10.3,15.7,4.3,I",
|
|
3096
|
+
VC: "VBYYG p7,7,8.3,4.5,9.6,7,8.3,9.5,G p10.4,7,11.7,4.5,13,7,11.7,9.5,G p8.7,9.5,10,7,11.3,9.5,10,12,G",
|
|
3097
|
+
VG: `${BLUE_ENSIGN} ${SHIELD},G r14.6,4.5,0.8,3.5,W`,
|
|
3098
|
+
VI: "HW p6,5,14,5,12,8,8,8,Y p9,4,11,4,11,10,9,10,Y r9.3,8.4,1.4,2,S",
|
|
3099
|
+
VN: "HR s10,7,3.6,Y",
|
|
3100
|
+
VU: "HRG r0,5.9,20,2.2,Y r0,6.4,20,1.2,K p0,0,10.4,7,0,14,Y p0,1.2,8.6,7,0,12.8,K c3.2,7,1.3,Y",
|
|
3101
|
+
WS: "HR r0,0,10,7,N s5,1.6,0.8,W s3,3.5,0.8,W s7,3,0.8,W s5,5.6,0.9,W s6,4.2,0.5,W",
|
|
3102
|
+
ZA: "HRB p0,0,1.6,0,9.4,4.6,20,4.6,20,9.4,9.4,9.4,1.6,14,0,14,W p0,0.9,8.6,5.6,20,5.6,20,8.4,8.6,8.4,0,13.1,0,11,6.6,7,0,3,G p0,3,6.6,7,0,11,Y p0,4,5,7,0,10,K",
|
|
3103
|
+
ZM: "HG r13,7,2.33,7,R r15.33,7,2.33,7,K r17.67,7,2.33,7,O p14,4,17,3,19,4,16.5,5,O",
|
|
3104
|
+
ZW: "HGYRKRYG p0,0,8.5,7,0,14,K p0,0.6,7.8,7,0,13.4,W s3,7,1.5,R p2.5,6.5,4,5.5,3.6,8,Y"
|
|
3105
|
+
};
|
|
3106
|
+
|
|
3107
|
+
// src/CountryFlag/data/flagDrawings.ts
|
|
3108
|
+
var FLAG_DRAWINGS = { ...FLAG_DRAWINGS_A_TO_L, ...FLAG_DRAWINGS_M_TO_Z };
|
|
3109
|
+
|
|
3110
|
+
// src/CountryFlag/data/flagSpecs.ts
|
|
3111
|
+
var FRENCH = "V BWR";
|
|
3112
|
+
var NORWAY = "N RWB";
|
|
3113
|
+
var FLAG_SPECS = {
|
|
3114
|
+
AE: "H GWK",
|
|
3115
|
+
AF: "V KRG",
|
|
3116
|
+
AM: "H RBO",
|
|
3117
|
+
AR: "H SWS",
|
|
3118
|
+
AT: "H RWR",
|
|
3119
|
+
AX: "N BYR",
|
|
3120
|
+
AZ: "H SRG",
|
|
3121
|
+
BD: "D DR",
|
|
3122
|
+
BE: "V KYR",
|
|
3123
|
+
BG: "H WGR",
|
|
3124
|
+
BL: FRENCH,
|
|
3125
|
+
BO: "H RYG",
|
|
3126
|
+
BV: NORWAY,
|
|
3127
|
+
BY: "H RRG",
|
|
3128
|
+
CH: "P RW",
|
|
3129
|
+
CI: "V OWG",
|
|
3130
|
+
CM: "V GRY",
|
|
3131
|
+
CO: "H YYBR",
|
|
3132
|
+
CR: "H BWRRWB",
|
|
3133
|
+
DE: "H KRY",
|
|
3134
|
+
DK: "N RW",
|
|
3135
|
+
EE: "H BKW",
|
|
3136
|
+
ES: "H RYYR",
|
|
3137
|
+
ET: "H GYR",
|
|
3138
|
+
FI: "N WB",
|
|
3139
|
+
FO: "N WRB",
|
|
3140
|
+
FR: FRENCH,
|
|
3141
|
+
GA: "H GYB",
|
|
3142
|
+
GE: "P WR",
|
|
3143
|
+
GF: FRENCH,
|
|
3144
|
+
GM: "H RBG",
|
|
3145
|
+
GN: "V RYG",
|
|
3146
|
+
GP: FRENCH,
|
|
3147
|
+
GT: "V SWS",
|
|
3148
|
+
HU: "H RWG",
|
|
3149
|
+
ID: "H RW",
|
|
3150
|
+
IE: "V GWO",
|
|
3151
|
+
IR: "H GWR",
|
|
3152
|
+
IS: "N BWR",
|
|
3153
|
+
IT: "V GWR",
|
|
3154
|
+
JP: "D WR",
|
|
3155
|
+
KG: "D RY",
|
|
3156
|
+
LA: "H RNR",
|
|
3157
|
+
LS: "H BWG",
|
|
3158
|
+
LT: "H YGR",
|
|
3159
|
+
LU: "H RWS",
|
|
3160
|
+
LV: "H MWM",
|
|
3161
|
+
MC: "H RW",
|
|
3162
|
+
MF: FRENCH,
|
|
3163
|
+
ML: "V GYR",
|
|
3164
|
+
MN: "V RBR",
|
|
3165
|
+
MQ: FRENCH,
|
|
3166
|
+
MT: "V WR",
|
|
3167
|
+
MU: "H RBYG",
|
|
3168
|
+
MW: "H KRG",
|
|
3169
|
+
NC: FRENCH,
|
|
3170
|
+
NG: "V GWG",
|
|
3171
|
+
NL: "H RWB",
|
|
3172
|
+
NO: NORWAY,
|
|
3173
|
+
PE: "V RWR",
|
|
3174
|
+
PF: FRENCH,
|
|
3175
|
+
PL: "H WR",
|
|
3176
|
+
PM: FRENCH,
|
|
3177
|
+
PT: "V GGRRR",
|
|
3178
|
+
PW: "D SY",
|
|
3179
|
+
RE: FRENCH,
|
|
3180
|
+
RO: "V BYR",
|
|
3181
|
+
RS: "H RBW",
|
|
3182
|
+
RU: "H WBR",
|
|
3183
|
+
RW: "H SSYG",
|
|
3184
|
+
SE: "N BY",
|
|
3185
|
+
SJ: NORWAY,
|
|
3186
|
+
SL: "H GWS",
|
|
3187
|
+
SV: "H BWB",
|
|
3188
|
+
TF: FRENCH,
|
|
3189
|
+
TH: "H RWNNWR",
|
|
3190
|
+
UA: "H BY",
|
|
3191
|
+
UG: "H KYRKYR",
|
|
3192
|
+
UZ: "H SWG",
|
|
3193
|
+
VE: "H YBR",
|
|
3194
|
+
WF: FRENCH,
|
|
3195
|
+
YE: "H RWK",
|
|
3196
|
+
YT: FRENCH
|
|
3197
|
+
};
|
|
3198
|
+
|
|
3199
|
+
// src/CountryFlag/utils/flagPrimitives.ts
|
|
3200
|
+
var FLAG_WIDTH = 20;
|
|
3201
|
+
var FLAG_HEIGHT = 14;
|
|
3202
|
+
var HALF = 2;
|
|
3203
|
+
var STAR_TIPS = 5;
|
|
3204
|
+
var STAR_INNER = 0.4;
|
|
3205
|
+
var DEGREES_HALF_TURN = 180;
|
|
3206
|
+
var STAR_START = -90;
|
|
3207
|
+
var DECIMALS = 100;
|
|
3208
|
+
var JACK_DIAGONAL = 0.12;
|
|
3209
|
+
var JACK_RED_DIAGONAL = 0.05;
|
|
3210
|
+
var JACK_WHITE_CROSS = 3;
|
|
3211
|
+
var JACK_RED_CROSS = 5;
|
|
3212
|
+
function rect(x, y, size, fill) {
|
|
3213
|
+
return { kind: "rect" /* Rect */, x, y, width: size[0], height: size[1], fill };
|
|
3214
|
+
}
|
|
3215
|
+
function field(fill) {
|
|
3216
|
+
return rect(0, 0, [FLAG_WIDTH, FLAG_HEIGHT], fill);
|
|
3217
|
+
}
|
|
3218
|
+
function circle(cx, cy, radius, fill) {
|
|
3219
|
+
return { kind: "circle" /* Circle */, x: cx, y: cy, width: radius * HALF, height: radius * HALF, fill };
|
|
3220
|
+
}
|
|
3221
|
+
function polygon(coords, fill) {
|
|
3222
|
+
const pairs = [];
|
|
3223
|
+
for (let i = 0; i + 1 < coords.length; i += HALF) pairs.push(`${coords[i]},${coords[i + 1]}`);
|
|
3224
|
+
return { kind: "polygon" /* Polygon */, x: 0, y: 0, width: 0, height: 0, fill, points: pairs.join(" ") };
|
|
3225
|
+
}
|
|
3226
|
+
function stripes(fills, vertical) {
|
|
3227
|
+
const step = (vertical ? FLAG_WIDTH : FLAG_HEIGHT) / fills.length;
|
|
3228
|
+
return fills.map((fill, i) => vertical ? rect(i * step, 0, [step, FLAG_HEIGHT], fill) : rect(0, i * step, [FLAG_WIDTH, step], fill));
|
|
3229
|
+
}
|
|
3230
|
+
function round(value) {
|
|
3231
|
+
return Math.round(value * DECIMALS) / DECIMALS;
|
|
3232
|
+
}
|
|
3233
|
+
function star(cx, cy, radius, fill) {
|
|
3234
|
+
const coords = [];
|
|
3235
|
+
for (let i = 0; i < STAR_TIPS * HALF; i++) {
|
|
3236
|
+
const r = i % HALF === 0 ? radius : radius * STAR_INNER;
|
|
3237
|
+
const angle = (STAR_START + i * DEGREES_HALF_TURN / STAR_TIPS) * Math.PI / DEGREES_HALF_TURN;
|
|
3238
|
+
coords.push(round(cx + r * Math.cos(angle)), round(cy + r * Math.sin(angle)));
|
|
3239
|
+
}
|
|
3240
|
+
return polygon(coords, fill);
|
|
3241
|
+
}
|
|
3242
|
+
function diagonals(box, share, fill) {
|
|
3243
|
+
const [x, y, w, h] = box;
|
|
3244
|
+
const dx = w * share;
|
|
3245
|
+
const dy = h * share;
|
|
3246
|
+
const right = x + w;
|
|
3247
|
+
const bottom = y + h;
|
|
3248
|
+
return [
|
|
3249
|
+
polygon([x, y, x + dx, y, right, bottom - dy, right, bottom, right - dx, bottom, x, y + dy], fill),
|
|
3250
|
+
polygon([right, y, right - dx, y, x, bottom - dy, x, bottom, x + dx, bottom, right, y + dy], fill)
|
|
3251
|
+
];
|
|
3252
|
+
}
|
|
3253
|
+
function cross(box, bar, fill) {
|
|
3254
|
+
const [x, y, w, h] = box;
|
|
3255
|
+
return [rect(x + (w - bar) / HALF, y, [bar, h], fill), rect(x, y + (h - bar) / HALF, [w, bar], fill)];
|
|
3256
|
+
}
|
|
3257
|
+
function unionJack(box, colors) {
|
|
3258
|
+
const [navy, white, red] = colors;
|
|
3259
|
+
const [x, y, w, h] = box;
|
|
3260
|
+
return [
|
|
3261
|
+
rect(x, y, [w, h], navy),
|
|
3262
|
+
...diagonals(box, JACK_DIAGONAL, white),
|
|
3263
|
+
...diagonals(box, JACK_RED_DIAGONAL, red),
|
|
3264
|
+
...cross(box, h / JACK_WHITE_CROSS, white),
|
|
3265
|
+
...cross(box, h / JACK_RED_CROSS, red)
|
|
3266
|
+
];
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
// src/CountryFlag/utils/flagDrawing.ts
|
|
3270
|
+
var OP_HORIZONTAL = "H";
|
|
3271
|
+
var OP_VERTICAL = "V";
|
|
3272
|
+
var OP_RECT = "r";
|
|
3273
|
+
var OP_CIRCLE = "c";
|
|
3274
|
+
var OP_POLYGON = "p";
|
|
3275
|
+
var OP_STAR = "s";
|
|
3276
|
+
var OP_JACK = "j";
|
|
3277
|
+
function fillOf(letter) {
|
|
3278
|
+
return FLAG_PALETTE[letter ?? ""] ?? FLAG_FALLBACK_FILL;
|
|
3279
|
+
}
|
|
3280
|
+
function numbers(values) {
|
|
3281
|
+
return values.map(Number);
|
|
3282
|
+
}
|
|
3283
|
+
function drawOp(op) {
|
|
3284
|
+
const kind = op.charAt(0);
|
|
3285
|
+
const body = op.slice(1);
|
|
3286
|
+
if (kind === OP_HORIZONTAL || kind === OP_VERTICAL) return stripes(Array.from(body, fillOf), kind === OP_VERTICAL);
|
|
3287
|
+
const args = body.split(",");
|
|
3288
|
+
const [a = 0, b = 0, c = 0, d = 0] = numbers(args);
|
|
3289
|
+
if (kind === OP_JACK) return unionJack([a, b, c, d], [fillOf("N"), fillOf("W"), fillOf("R")]);
|
|
3290
|
+
const fill = fillOf(args[args.length - 1]);
|
|
3291
|
+
if (kind === OP_RECT) return [rect(a, b, [c, d], fill)];
|
|
3292
|
+
if (kind === OP_CIRCLE) return [circle(a, b, c, fill)];
|
|
3293
|
+
if (kind === OP_STAR) return [star(a, b, c, fill)];
|
|
3294
|
+
if (kind === OP_POLYGON) return [polygon(numbers(args.slice(0, -1)), fill)];
|
|
3295
|
+
return [];
|
|
3296
|
+
}
|
|
3297
|
+
function drawFlag(drawing) {
|
|
3298
|
+
return drawing.split(" ").filter((op) => op !== "").flatMap(drawOp);
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
// src/CountryFlag/utils/flagShapes.ts
|
|
3302
|
+
var CROSS_X = 5.5;
|
|
3303
|
+
var CROSS_Y = 5.5;
|
|
3304
|
+
var CROSS_BAR = 3;
|
|
3305
|
+
var INNER_INSET = 1;
|
|
3306
|
+
var INNER_BAR = 1;
|
|
3307
|
+
var PLUS_ARM_X = 8.5;
|
|
3308
|
+
var PLUS_ARM_Y = 3;
|
|
3309
|
+
var PLUS_SPAN_X = 5;
|
|
3310
|
+
var PLUS_SPAN = 10;
|
|
3311
|
+
var PLUS_ARM_LEN = 8;
|
|
3312
|
+
var DISC_DIAMETER = 8;
|
|
3313
|
+
var HALF2 = 2;
|
|
3314
|
+
function nordic([ground = FLAG_FALLBACK_FILL, cross2 = FLAG_FALLBACK_FILL, inner]) {
|
|
3315
|
+
const shapes = [field(ground), rect(CROSS_X, 0, [CROSS_BAR, FLAG_HEIGHT], cross2), rect(0, CROSS_Y, [FLAG_WIDTH, CROSS_BAR], cross2)];
|
|
3316
|
+
if (inner === void 0) return shapes;
|
|
3317
|
+
return [...shapes, rect(CROSS_X + INNER_INSET, 0, [INNER_BAR, FLAG_HEIGHT], inner), rect(0, CROSS_Y + INNER_INSET, [FLAG_WIDTH, INNER_BAR], inner)];
|
|
3318
|
+
}
|
|
3319
|
+
function centredCross([ground = FLAG_FALLBACK_FILL, cross2 = FLAG_FALLBACK_FILL]) {
|
|
3320
|
+
return [field(ground), rect(PLUS_ARM_X, PLUS_ARM_Y, [CROSS_BAR, PLUS_ARM_LEN], cross2), rect(PLUS_SPAN_X, CROSS_Y, [PLUS_SPAN, CROSS_BAR], cross2)];
|
|
3321
|
+
}
|
|
3322
|
+
function disc([ground = FLAG_FALLBACK_FILL, mark = FLAG_FALLBACK_FILL]) {
|
|
3323
|
+
const circle2 = { kind: "circle" /* Circle */, x: FLAG_WIDTH / HALF2, y: FLAG_HEIGHT / HALF2, width: DISC_DIAMETER, height: DISC_DIAMETER, fill: mark };
|
|
3324
|
+
return [field(ground), circle2];
|
|
3325
|
+
}
|
|
3326
|
+
function isFallbackFlag(code) {
|
|
3327
|
+
const upper = code.toUpperCase();
|
|
3328
|
+
return FLAG_SPECS[upper] === void 0 && FLAG_DRAWINGS[upper] === void 0;
|
|
3329
|
+
}
|
|
3330
|
+
function flagShapes(code) {
|
|
3331
|
+
const upper = code.toUpperCase();
|
|
3332
|
+
const drawing = FLAG_DRAWINGS[upper];
|
|
3333
|
+
if (drawing !== void 0) return drawFlag(drawing);
|
|
3334
|
+
const spec = FLAG_SPECS[upper];
|
|
3335
|
+
if (spec === void 0) return [field(FLAG_FALLBACK_FILL)];
|
|
3336
|
+
const [layout = "", letters = ""] = spec.split(" ");
|
|
3337
|
+
const fills = Array.from(letters, (letter) => FLAG_PALETTE[letter] ?? FLAG_FALLBACK_FILL);
|
|
3338
|
+
if (layout === "V") return stripes(fills, true);
|
|
3339
|
+
if (layout === "N") return nordic(fills);
|
|
3340
|
+
if (layout === "P") return centredCross(fills);
|
|
3341
|
+
if (layout === "D") return disc(fills);
|
|
3342
|
+
return stripes(fills, false);
|
|
3343
|
+
}
|
|
3344
|
+
var EDGE_WIDTH = 0.5;
|
|
3345
|
+
var EDGE_INSET = 0.25;
|
|
3346
|
+
var HALF3 = 2;
|
|
3347
|
+
var VIEW_BOX = `0 0 ${FLAG_WIDTH} ${FLAG_HEIGHT}`;
|
|
3348
|
+
function drawShape(shape, key) {
|
|
3349
|
+
if (shape.kind === "circle" /* Circle */) return /* @__PURE__ */ jsxRuntime.jsx(Svg.Circle, { cx: shape.x, cy: shape.y, fill: shape.fill, r: shape.width / HALF3 }, key);
|
|
3350
|
+
if (shape.kind === "polygon" /* Polygon */) return /* @__PURE__ */ jsxRuntime.jsx(Svg.Polygon, { fill: shape.fill, points: shape.points }, key);
|
|
3351
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Svg.Rect, { fill: shape.fill, height: shape.height, width: shape.width, x: shape.x, y: shape.y }, key);
|
|
3352
|
+
}
|
|
3353
|
+
function CountryFlag({ code, testID }) {
|
|
3354
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Svg__default.default, { accessibilityElementsHidden: true, "aria-hidden": true, height: FLAG_HEIGHT, importantForAccessibility: "no-hide-descendants", testID, viewBox: VIEW_BOX, width: FLAG_WIDTH, children: [
|
|
3355
|
+
flagShapes(code).map((shape, index) => drawShape(shape, index)),
|
|
3356
|
+
/* @__PURE__ */ jsxRuntime.jsx(Svg.Rect, { fill: "none", height: FLAG_HEIGHT - EDGE_WIDTH, stroke: FLAG_EDGE, strokeWidth: EDGE_WIDTH, width: FLAG_WIDTH - EDGE_WIDTH, x: EDGE_INSET, y: EDGE_INSET })
|
|
3357
|
+
] });
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
// src/countries/countriesData.ts
|
|
3361
|
+
var COUNTRIES = [
|
|
3362
|
+
{ code: "AF", name: "Afghanistan" },
|
|
3363
|
+
{ code: "AX", name: "\xC5land Islands" },
|
|
3364
|
+
{ code: "AL", name: "Albania" },
|
|
3365
|
+
{ code: "DZ", name: "Algeria" },
|
|
3366
|
+
{ code: "AS", name: "American Samoa" },
|
|
3367
|
+
{ code: "AD", name: "Andorra" },
|
|
3368
|
+
{ code: "AO", name: "Angola" },
|
|
3369
|
+
{ code: "AI", name: "Anguilla" },
|
|
3370
|
+
{ code: "AQ", name: "Antarctica" },
|
|
3371
|
+
{ code: "AG", name: "Antigua and Barbuda" },
|
|
3372
|
+
{ code: "AR", name: "Argentina" },
|
|
3373
|
+
{ code: "AM", name: "Armenia" },
|
|
3374
|
+
{ code: "AW", name: "Aruba" },
|
|
3375
|
+
{ code: "AU", name: "Australia" },
|
|
3376
|
+
{ code: "AT", name: "Austria" },
|
|
3377
|
+
{ code: "AZ", name: "Azerbaijan" },
|
|
3378
|
+
{ code: "BS", name: "Bahamas" },
|
|
3379
|
+
{ code: "BH", name: "Bahrain" },
|
|
3380
|
+
{ code: "BD", name: "Bangladesh" },
|
|
3381
|
+
{ code: "BB", name: "Barbados" },
|
|
3382
|
+
{ code: "BY", name: "Belarus" },
|
|
3383
|
+
{ code: "BE", name: "Belgium" },
|
|
3384
|
+
{ code: "BZ", name: "Belize" },
|
|
3385
|
+
{ code: "BJ", name: "Benin" },
|
|
3386
|
+
{ code: "BM", name: "Bermuda" },
|
|
3387
|
+
{ code: "BT", name: "Bhutan" },
|
|
3388
|
+
{ code: "BO", name: "Bolivia" },
|
|
3389
|
+
{ code: "BQ", name: "Bonaire, Sint Eustatius and Saba" },
|
|
3390
|
+
{ code: "BA", name: "Bosnia and Herzegovina" },
|
|
3391
|
+
{ code: "BW", name: "Botswana" },
|
|
3392
|
+
{ code: "BV", name: "Bouvet Island" },
|
|
3393
|
+
{ code: "BR", name: "Brazil" },
|
|
3394
|
+
{ code: "IO", name: "British Indian Ocean Territory" },
|
|
3395
|
+
{ code: "BN", name: "Brunei Darussalam" },
|
|
3396
|
+
{ code: "BG", name: "Bulgaria" },
|
|
3397
|
+
{ code: "BF", name: "Burkina Faso" },
|
|
3398
|
+
{ code: "BI", name: "Burundi" },
|
|
3399
|
+
{ code: "CV", name: "Cabo Verde" },
|
|
3400
|
+
{ code: "KH", name: "Cambodia" },
|
|
3401
|
+
{ code: "CM", name: "Cameroon" },
|
|
3402
|
+
{ code: "CA", name: "Canada" },
|
|
3403
|
+
{ code: "KY", name: "Cayman Islands" },
|
|
3404
|
+
{ code: "CF", name: "Central African Republic" },
|
|
3405
|
+
{ code: "TD", name: "Chad" },
|
|
3406
|
+
{ code: "CL", name: "Chile" },
|
|
3407
|
+
{ code: "CN", name: "China" },
|
|
3408
|
+
{ code: "CX", name: "Christmas Island" },
|
|
3409
|
+
{ code: "CC", name: "Cocos (Keeling) Islands" },
|
|
3410
|
+
{ code: "CO", name: "Colombia" },
|
|
3411
|
+
{ code: "KM", name: "Comoros" },
|
|
3412
|
+
{ code: "CG", name: "Congo" },
|
|
3413
|
+
{ code: "CD", name: "Congo (Democratic Republic)" },
|
|
3414
|
+
{ code: "CK", name: "Cook Islands" },
|
|
3415
|
+
{ code: "CR", name: "Costa Rica" },
|
|
3416
|
+
{ code: "CI", name: "C\xF4te d'Ivoire" },
|
|
3417
|
+
{ code: "HR", name: "Croatia" },
|
|
3418
|
+
{ code: "CU", name: "Cuba" },
|
|
3419
|
+
{ code: "CW", name: "Cura\xE7ao" },
|
|
3420
|
+
{ code: "CY", name: "Cyprus" },
|
|
3421
|
+
{ code: "CZ", name: "Czechia" },
|
|
3422
|
+
{ code: "DK", name: "Denmark" },
|
|
3423
|
+
{ code: "DJ", name: "Djibouti" },
|
|
3424
|
+
{ code: "DM", name: "Dominica" },
|
|
3425
|
+
{ code: "DO", name: "Dominican Republic" },
|
|
3426
|
+
{ code: "EC", name: "Ecuador" },
|
|
3427
|
+
{ code: "EG", name: "Egypt" },
|
|
3428
|
+
{ code: "SV", name: "El Salvador" },
|
|
3429
|
+
{ code: "GQ", name: "Equatorial Guinea" },
|
|
3430
|
+
{ code: "ER", name: "Eritrea" },
|
|
3431
|
+
{ code: "EE", name: "Estonia" },
|
|
3432
|
+
{ code: "SZ", name: "Eswatini" },
|
|
3433
|
+
{ code: "ET", name: "Ethiopia" },
|
|
3434
|
+
{ code: "FK", name: "Falkland Islands" },
|
|
3435
|
+
{ code: "FO", name: "Faroe Islands" },
|
|
3436
|
+
{ code: "FJ", name: "Fiji" },
|
|
3437
|
+
{ code: "FI", name: "Finland" },
|
|
3438
|
+
{ code: "FR", name: "France" },
|
|
3439
|
+
{ code: "GF", name: "French Guiana" },
|
|
3440
|
+
{ code: "PF", name: "French Polynesia" },
|
|
3441
|
+
{ code: "TF", name: "French Southern Territories" },
|
|
3442
|
+
{ code: "GA", name: "Gabon" },
|
|
3443
|
+
{ code: "GM", name: "Gambia" },
|
|
3444
|
+
{ code: "GE", name: "Georgia" },
|
|
3445
|
+
{ code: "DE", name: "Germany" },
|
|
3446
|
+
{ code: "GH", name: "Ghana" },
|
|
3447
|
+
{ code: "GI", name: "Gibraltar" },
|
|
3448
|
+
{ code: "GR", name: "Greece" },
|
|
3449
|
+
{ code: "GL", name: "Greenland" },
|
|
3450
|
+
{ code: "GD", name: "Grenada" },
|
|
3451
|
+
{ code: "GP", name: "Guadeloupe" },
|
|
3452
|
+
{ code: "GU", name: "Guam" },
|
|
3453
|
+
{ code: "GT", name: "Guatemala" },
|
|
3454
|
+
{ code: "GG", name: "Guernsey" },
|
|
3455
|
+
{ code: "GN", name: "Guinea" },
|
|
3456
|
+
{ code: "GW", name: "Guinea-Bissau" },
|
|
3457
|
+
{ code: "GY", name: "Guyana" },
|
|
3458
|
+
{ code: "HT", name: "Haiti" },
|
|
3459
|
+
{ code: "HM", name: "Heard Island and McDonald Islands" },
|
|
3460
|
+
{ code: "VA", name: "Holy See" },
|
|
3461
|
+
{ code: "HN", name: "Honduras" },
|
|
3462
|
+
{ code: "HK", name: "Hong Kong" },
|
|
3463
|
+
{ code: "HU", name: "Hungary" },
|
|
3464
|
+
{ code: "IS", name: "Iceland" },
|
|
3465
|
+
{ code: "IN", name: "India" },
|
|
3466
|
+
{ code: "ID", name: "Indonesia" },
|
|
3467
|
+
{ code: "IR", name: "Iran" },
|
|
3468
|
+
{ code: "IQ", name: "Iraq" },
|
|
3469
|
+
{ code: "IE", name: "Ireland" },
|
|
3470
|
+
{ code: "IM", name: "Isle of Man" },
|
|
3471
|
+
{ code: "IL", name: "Israel" },
|
|
3472
|
+
{ code: "IT", name: "Italy" },
|
|
3473
|
+
{ code: "JM", name: "Jamaica" },
|
|
3474
|
+
{ code: "JP", name: "Japan" },
|
|
3475
|
+
{ code: "JE", name: "Jersey" },
|
|
3476
|
+
{ code: "JO", name: "Jordan" },
|
|
3477
|
+
{ code: "KZ", name: "Kazakhstan" },
|
|
3478
|
+
{ code: "KE", name: "Kenya" },
|
|
3479
|
+
{ code: "KI", name: "Kiribati" },
|
|
3480
|
+
{ code: "KP", name: "Korea (North)" },
|
|
3481
|
+
{ code: "KR", name: "Korea (South)" },
|
|
3482
|
+
{ code: "KW", name: "Kuwait" },
|
|
3483
|
+
{ code: "KG", name: "Kyrgyzstan" },
|
|
3484
|
+
{ code: "LA", name: "Laos" },
|
|
3485
|
+
{ code: "LV", name: "Latvia" },
|
|
3486
|
+
{ code: "LB", name: "Lebanon" },
|
|
3487
|
+
{ code: "LS", name: "Lesotho" },
|
|
3488
|
+
{ code: "LR", name: "Liberia" },
|
|
3489
|
+
{ code: "LY", name: "Libya" },
|
|
3490
|
+
{ code: "LI", name: "Liechtenstein" },
|
|
3491
|
+
{ code: "LT", name: "Lithuania" },
|
|
3492
|
+
{ code: "LU", name: "Luxembourg" },
|
|
3493
|
+
{ code: "MO", name: "Macao" },
|
|
3494
|
+
{ code: "MG", name: "Madagascar" },
|
|
3495
|
+
{ code: "MW", name: "Malawi" },
|
|
3496
|
+
{ code: "MY", name: "Malaysia" },
|
|
3497
|
+
{ code: "MV", name: "Maldives" },
|
|
3498
|
+
{ code: "ML", name: "Mali" },
|
|
3499
|
+
{ code: "MT", name: "Malta" },
|
|
3500
|
+
{ code: "MH", name: "Marshall Islands" },
|
|
3501
|
+
{ code: "MQ", name: "Martinique" },
|
|
3502
|
+
{ code: "MR", name: "Mauritania" },
|
|
3503
|
+
{ code: "MU", name: "Mauritius" },
|
|
3504
|
+
{ code: "YT", name: "Mayotte" },
|
|
3505
|
+
{ code: "MX", name: "Mexico" },
|
|
3506
|
+
{ code: "FM", name: "Micronesia" },
|
|
3507
|
+
{ code: "MD", name: "Moldova" },
|
|
3508
|
+
{ code: "MC", name: "Monaco" },
|
|
3509
|
+
{ code: "MN", name: "Mongolia" },
|
|
3510
|
+
{ code: "ME", name: "Montenegro" },
|
|
3511
|
+
{ code: "MS", name: "Montserrat" },
|
|
3512
|
+
{ code: "MA", name: "Morocco" },
|
|
3513
|
+
{ code: "MZ", name: "Mozambique" },
|
|
3514
|
+
{ code: "MM", name: "Myanmar" },
|
|
3515
|
+
{ code: "NA", name: "Namibia" },
|
|
3516
|
+
{ code: "NR", name: "Nauru" },
|
|
3517
|
+
{ code: "NP", name: "Nepal" },
|
|
3518
|
+
{ code: "NL", name: "Netherlands" },
|
|
3519
|
+
{ code: "NC", name: "New Caledonia" },
|
|
3520
|
+
{ code: "NZ", name: "New Zealand" },
|
|
3521
|
+
{ code: "NI", name: "Nicaragua" },
|
|
3522
|
+
{ code: "NE", name: "Niger" },
|
|
3523
|
+
{ code: "NG", name: "Nigeria" },
|
|
3524
|
+
{ code: "NU", name: "Niue" },
|
|
3525
|
+
{ code: "NF", name: "Norfolk Island" },
|
|
3526
|
+
{ code: "MK", name: "North Macedonia" },
|
|
3527
|
+
{ code: "MP", name: "Northern Mariana Islands" },
|
|
3528
|
+
{ code: "NO", name: "Norway" },
|
|
3529
|
+
{ code: "OM", name: "Oman" },
|
|
3530
|
+
{ code: "PK", name: "Pakistan" },
|
|
3531
|
+
{ code: "PW", name: "Palau" },
|
|
3532
|
+
{ code: "PS", name: "Palestine" },
|
|
3533
|
+
{ code: "PA", name: "Panama" },
|
|
3534
|
+
{ code: "PG", name: "Papua New Guinea" },
|
|
3535
|
+
{ code: "PY", name: "Paraguay" },
|
|
3536
|
+
{ code: "PE", name: "Peru" },
|
|
3537
|
+
{ code: "PH", name: "Philippines" },
|
|
3538
|
+
{ code: "PN", name: "Pitcairn" },
|
|
3539
|
+
{ code: "PL", name: "Poland" },
|
|
3540
|
+
{ code: "PT", name: "Portugal" },
|
|
3541
|
+
{ code: "PR", name: "Puerto Rico" },
|
|
3542
|
+
{ code: "QA", name: "Qatar" },
|
|
3543
|
+
{ code: "RE", name: "R\xE9union" },
|
|
3544
|
+
{ code: "RO", name: "Romania" },
|
|
3545
|
+
{ code: "RU", name: "Russian Federation" },
|
|
3546
|
+
{ code: "RW", name: "Rwanda" },
|
|
3547
|
+
{ code: "BL", name: "Saint Barth\xE9lemy" },
|
|
3548
|
+
{ code: "SH", name: "Saint Helena, Ascension and Tristan da Cunha" },
|
|
3549
|
+
{ code: "KN", name: "Saint Kitts and Nevis" },
|
|
3550
|
+
{ code: "LC", name: "Saint Lucia" },
|
|
3551
|
+
{ code: "MF", name: "Saint Martin (French part)" },
|
|
3552
|
+
{ code: "PM", name: "Saint Pierre and Miquelon" },
|
|
3553
|
+
{ code: "VC", name: "Saint Vincent and the Grenadines" },
|
|
3554
|
+
{ code: "WS", name: "Samoa" },
|
|
3555
|
+
{ code: "SM", name: "San Marino" },
|
|
3556
|
+
{ code: "ST", name: "Sao Tome and Principe" },
|
|
3557
|
+
{ code: "SA", name: "Saudi Arabia" },
|
|
3558
|
+
{ code: "SN", name: "Senegal" },
|
|
3559
|
+
{ code: "RS", name: "Serbia" },
|
|
3560
|
+
{ code: "SC", name: "Seychelles" },
|
|
3561
|
+
{ code: "SL", name: "Sierra Leone" },
|
|
3562
|
+
{ code: "SG", name: "Singapore" },
|
|
3563
|
+
{ code: "SX", name: "Sint Maarten (Dutch part)" },
|
|
3564
|
+
{ code: "SK", name: "Slovakia" },
|
|
3565
|
+
{ code: "SI", name: "Slovenia" },
|
|
3566
|
+
{ code: "SB", name: "Solomon Islands" },
|
|
3567
|
+
{ code: "SO", name: "Somalia" },
|
|
3568
|
+
{ code: "ZA", name: "South Africa" },
|
|
3569
|
+
{ code: "GS", name: "South Georgia and the South Sandwich Islands" },
|
|
3570
|
+
{ code: "SS", name: "South Sudan" },
|
|
3571
|
+
{ code: "ES", name: "Spain" },
|
|
3572
|
+
{ code: "LK", name: "Sri Lanka" },
|
|
3573
|
+
{ code: "SD", name: "Sudan" },
|
|
3574
|
+
{ code: "SR", name: "Suriname" },
|
|
3575
|
+
{ code: "SJ", name: "Svalbard and Jan Mayen" },
|
|
3576
|
+
{ code: "SE", name: "Sweden" },
|
|
3577
|
+
{ code: "CH", name: "Switzerland" },
|
|
3578
|
+
{ code: "SY", name: "Syrian Arab Republic" },
|
|
3579
|
+
{ code: "TW", name: "Taiwan" },
|
|
3580
|
+
{ code: "TJ", name: "Tajikistan" },
|
|
3581
|
+
{ code: "TZ", name: "Tanzania" },
|
|
3582
|
+
{ code: "TH", name: "Thailand" },
|
|
3583
|
+
{ code: "TL", name: "Timor-Leste" },
|
|
3584
|
+
{ code: "TG", name: "Togo" },
|
|
3585
|
+
{ code: "TK", name: "Tokelau" },
|
|
3586
|
+
{ code: "TO", name: "Tonga" },
|
|
3587
|
+
{ code: "TT", name: "Trinidad and Tobago" },
|
|
3588
|
+
{ code: "TN", name: "Tunisia" },
|
|
3589
|
+
{ code: "TR", name: "T\xFCrkiye" },
|
|
3590
|
+
{ code: "TM", name: "Turkmenistan" },
|
|
3591
|
+
{ code: "TC", name: "Turks and Caicos Islands" },
|
|
3592
|
+
{ code: "TV", name: "Tuvalu" },
|
|
3593
|
+
{ code: "UG", name: "Uganda" },
|
|
3594
|
+
{ code: "UA", name: "Ukraine" },
|
|
3595
|
+
{ code: "AE", name: "United Arab Emirates" },
|
|
3596
|
+
{ code: "GB", name: "United Kingdom" },
|
|
3597
|
+
{ code: "US", name: "United States" },
|
|
3598
|
+
{ code: "UM", name: "United States Minor Outlying Islands" },
|
|
3599
|
+
{ code: "UY", name: "Uruguay" },
|
|
3600
|
+
{ code: "UZ", name: "Uzbekistan" },
|
|
3601
|
+
{ code: "VU", name: "Vanuatu" },
|
|
3602
|
+
{ code: "VE", name: "Venezuela" },
|
|
3603
|
+
{ code: "VN", name: "Viet Nam" },
|
|
3604
|
+
{ code: "VG", name: "Virgin Islands (British)" },
|
|
3605
|
+
{ code: "VI", name: "Virgin Islands (U.S.)" },
|
|
3606
|
+
{ code: "WF", name: "Wallis and Futuna" },
|
|
3607
|
+
{ code: "EH", name: "Western Sahara" },
|
|
3608
|
+
{ code: "YE", name: "Yemen" },
|
|
3609
|
+
{ code: "ZM", name: "Zambia" },
|
|
3610
|
+
{ code: "ZW", name: "Zimbabwe" }
|
|
3611
|
+
];
|
|
3612
|
+
|
|
3613
|
+
// src/countries/countryOptions.ts
|
|
3614
|
+
var REGIONAL_INDICATOR_A = 127462;
|
|
3615
|
+
var CODE_A = 65;
|
|
3616
|
+
var TWO_LETTERS = /^[A-Z]{2}$/;
|
|
3617
|
+
var KNOWN_CODES = new Set(COUNTRIES.map((country) => country.code));
|
|
3618
|
+
function countryOptions(list = COUNTRIES) {
|
|
3619
|
+
return list.map((country) => ({ label: country.name, value: country.code, detail: country.code }));
|
|
3620
|
+
}
|
|
3621
|
+
function countryFlag(code) {
|
|
3622
|
+
const upper = code.toUpperCase();
|
|
3623
|
+
if (!TWO_LETTERS.test(upper)) return "";
|
|
3624
|
+
return String.fromCodePoint(...Array.from(upper, (letter) => REGIONAL_INDICATOR_A + letter.charCodeAt(0) - CODE_A));
|
|
3625
|
+
}
|
|
3626
|
+
function toCountryValue(input) {
|
|
3627
|
+
const upper = input.trim().toUpperCase();
|
|
3628
|
+
return KNOWN_CODES.has(upper) ? upper : "";
|
|
3629
|
+
}
|
|
3630
|
+
var CODE_FONT = 12;
|
|
3631
|
+
var DEFAULT_OPTIONS = countryOptions();
|
|
3632
|
+
var renderFlag = (option) => /* @__PURE__ */ jsxRuntime.jsx(CountryFlag, { code: option.value });
|
|
3633
|
+
function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries }) {
|
|
3634
|
+
const { theme } = uiFeedback.useUi();
|
|
3635
|
+
const { textSecondary } = theme.colors;
|
|
3636
|
+
const options = React2.useMemo(() => countries === void 0 ? DEFAULT_OPTIONS : countryOptions(countries), [countries]);
|
|
3637
|
+
const renderCode = React2.useCallback((option) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
|
|
3638
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3639
|
+
SearchSelect,
|
|
3640
|
+
{
|
|
3641
|
+
accessibilityHint,
|
|
3642
|
+
accessibilityLabel,
|
|
3643
|
+
labels,
|
|
3644
|
+
options,
|
|
3645
|
+
recentKey: "country",
|
|
3646
|
+
renderDetail: renderCode,
|
|
3647
|
+
renderLeading: renderFlag,
|
|
3648
|
+
testID,
|
|
3649
|
+
value: toCountryValue(value),
|
|
3650
|
+
onChange
|
|
3651
|
+
}
|
|
3652
|
+
);
|
|
3653
|
+
}
|
|
3654
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
3655
|
+
code: { fontSize: CODE_FONT }
|
|
3656
|
+
});
|
|
3657
|
+
function useBlurVerdict(validate) {
|
|
3658
|
+
const [verdict, setVerdict] = React2.useState(null);
|
|
3659
|
+
const onEdit = React2.useCallback(() => setVerdict(null), []);
|
|
3660
|
+
const onLeave = React2.useCallback(() => {
|
|
3661
|
+
const next = validate();
|
|
3662
|
+
setVerdict(next);
|
|
3663
|
+
return next;
|
|
3664
|
+
}, [validate]);
|
|
3665
|
+
return { verdict, onEdit, onLeave };
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3668
|
+
// src/IbanInput/data/ibanCountryLengths.ts
|
|
3669
|
+
var IBAN_LENGTHS = {
|
|
3670
|
+
AD: 24,
|
|
3671
|
+
AE: 23,
|
|
3672
|
+
AL: 28,
|
|
3673
|
+
AT: 20,
|
|
3674
|
+
AZ: 28,
|
|
3675
|
+
BA: 20,
|
|
3676
|
+
BE: 16,
|
|
3677
|
+
BG: 22,
|
|
3678
|
+
BH: 22,
|
|
3679
|
+
BI: 27,
|
|
3680
|
+
BR: 29,
|
|
3681
|
+
BY: 28,
|
|
3682
|
+
CH: 21,
|
|
3683
|
+
CR: 22,
|
|
3684
|
+
CY: 28,
|
|
3685
|
+
CZ: 24,
|
|
3686
|
+
DE: 22,
|
|
3687
|
+
DJ: 27,
|
|
3688
|
+
DK: 18,
|
|
3689
|
+
DO: 28,
|
|
3690
|
+
EE: 20,
|
|
3691
|
+
EG: 29,
|
|
3692
|
+
ES: 24,
|
|
3693
|
+
FI: 18,
|
|
3694
|
+
FK: 18,
|
|
3695
|
+
FO: 18,
|
|
3696
|
+
FR: 27,
|
|
3697
|
+
GB: 22,
|
|
3698
|
+
GE: 22,
|
|
3699
|
+
GI: 23,
|
|
3700
|
+
GL: 18,
|
|
3701
|
+
GR: 27,
|
|
3702
|
+
GT: 28,
|
|
3703
|
+
HN: 28,
|
|
3704
|
+
HR: 21,
|
|
3705
|
+
HU: 28,
|
|
3706
|
+
IE: 22,
|
|
3707
|
+
IL: 23,
|
|
3708
|
+
IQ: 23,
|
|
3709
|
+
IS: 26,
|
|
3710
|
+
IT: 27,
|
|
3711
|
+
JO: 30,
|
|
3712
|
+
KW: 30,
|
|
3713
|
+
KZ: 20,
|
|
3714
|
+
LB: 28,
|
|
3715
|
+
LC: 32,
|
|
3716
|
+
LI: 21,
|
|
3717
|
+
LT: 20,
|
|
3718
|
+
LU: 20,
|
|
3719
|
+
LV: 21,
|
|
3720
|
+
LY: 25,
|
|
3721
|
+
MC: 27,
|
|
3722
|
+
MD: 24,
|
|
3723
|
+
ME: 22,
|
|
3724
|
+
MK: 19,
|
|
3725
|
+
MN: 20,
|
|
3726
|
+
MR: 27,
|
|
3727
|
+
MT: 31,
|
|
3728
|
+
MU: 30,
|
|
3729
|
+
NI: 28,
|
|
3730
|
+
NL: 18,
|
|
3731
|
+
NO: 15,
|
|
3732
|
+
OM: 23,
|
|
3733
|
+
PK: 24,
|
|
3734
|
+
PL: 28,
|
|
3735
|
+
PS: 29,
|
|
3736
|
+
PT: 25,
|
|
3737
|
+
QA: 29,
|
|
3738
|
+
RO: 24,
|
|
3739
|
+
RS: 22,
|
|
3740
|
+
RU: 33,
|
|
3741
|
+
SA: 24,
|
|
3742
|
+
SC: 31,
|
|
3743
|
+
SD: 18,
|
|
3744
|
+
SE: 24,
|
|
3745
|
+
SI: 19,
|
|
3746
|
+
SK: 24,
|
|
3747
|
+
SM: 27,
|
|
3748
|
+
SO: 23,
|
|
3749
|
+
ST: 25,
|
|
3750
|
+
SV: 28,
|
|
3751
|
+
TL: 23,
|
|
3752
|
+
TN: 24,
|
|
3753
|
+
TR: 26,
|
|
3754
|
+
UA: 29,
|
|
3755
|
+
VA: 22,
|
|
3756
|
+
VG: 24,
|
|
3757
|
+
XK: 20,
|
|
3758
|
+
YE: 30
|
|
3759
|
+
};
|
|
3760
|
+
var IBAN_MAX_LENGTH = 34;
|
|
3761
|
+
var IBAN_REGISTERED_COUNTRY_COUNT = Object.keys(IBAN_LENGTHS).length;
|
|
3762
|
+
function ibanLengthFor(country) {
|
|
3763
|
+
return IBAN_LENGTHS[country] ?? null;
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
// src/IbanInput/utils/ibanFormat.ts
|
|
3767
|
+
var NOT_ALPHANUMERIC = /[^A-Za-z0-9]/g;
|
|
3768
|
+
var COUNTRY_PREFIX = /^[A-Z]{2}/;
|
|
3769
|
+
var COUNTRY_LENGTH = 2;
|
|
3770
|
+
var BIC8_LENGTH = 8;
|
|
3771
|
+
var BIC11_LENGTH = 11;
|
|
3772
|
+
var BRANCH_LENGTH = 3;
|
|
3773
|
+
var DEFAULT_GHOST = "0";
|
|
3774
|
+
var DEFAULT_BIC_GHOST = "X";
|
|
3775
|
+
function groupInFours(text) {
|
|
3776
|
+
return text.replace(/(.{4})(?=.)/g, "$1 ");
|
|
3777
|
+
}
|
|
3778
|
+
function cleaned(raw) {
|
|
3779
|
+
return raw.replace(NOT_ALPHANUMERIC, "").toUpperCase();
|
|
3780
|
+
}
|
|
3781
|
+
function draftIban(raw, ghostChar = DEFAULT_GHOST) {
|
|
3782
|
+
const text = cleaned(raw);
|
|
3783
|
+
const country = COUNTRY_PREFIX.test(text) ? text.slice(0, COUNTRY_LENGTH) : "";
|
|
3784
|
+
const expected = country === "" ? null : ibanLengthFor(country);
|
|
3785
|
+
const electronic = text.slice(0, expected ?? IBAN_MAX_LENGTH);
|
|
3786
|
+
const display = groupInFours(electronic);
|
|
3787
|
+
const mask = expected === null ? "" : groupInFours(ghostChar.repeat(expected));
|
|
3788
|
+
return { electronic, display, country, typed: electronic.length, expected, ghost: mask.slice(display.length) };
|
|
3789
|
+
}
|
|
3790
|
+
function ibanCounter(draft) {
|
|
3791
|
+
return draft.expected === null ? null : `${draft.typed} / ${draft.expected}`;
|
|
3792
|
+
}
|
|
3793
|
+
function draftBic(raw, ghostChar = DEFAULT_BIC_GHOST) {
|
|
3794
|
+
const value = cleaned(raw).slice(0, BIC11_LENGTH);
|
|
3795
|
+
const ghost = ghostChar.repeat(Math.max(0, BIC8_LENGTH - value.length));
|
|
3796
|
+
const branchLeft = value.length <= BIC8_LENGTH ? BRANCH_LENGTH : BIC11_LENGTH - value.length;
|
|
3797
|
+
return { value, ghost, branchGhost: ghostChar.repeat(branchLeft) };
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
// src/IbanInput/utils/ibanCaret.ts
|
|
3801
|
+
var GROUP = 4;
|
|
3802
|
+
var ALPHANUMERIC = /[A-Za-z0-9]/;
|
|
3803
|
+
function caretAfterEdit(raw, rawCaret) {
|
|
3804
|
+
const kept = Array.from(raw.slice(0, rawCaret)).filter((char) => ALPHANUMERIC.test(char)).length;
|
|
3805
|
+
const characters = Math.min(kept, draftIban(raw).electronic.length);
|
|
3806
|
+
return characters === 0 ? 0 : characters + Math.floor((characters - 1) / GROUP);
|
|
3807
|
+
}
|
|
3808
|
+
function rawCaretAfterChange(previous, previousCaret, next) {
|
|
3809
|
+
return Math.max(0, Math.min(next.length, previousCaret + next.length - previous.length));
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
// src/IbanInput/hooks/useIbanCaret.ts
|
|
3813
|
+
function useIbanCaret(display) {
|
|
3814
|
+
const [selection, setSelection] = React2.useState({ start: display.length, end: display.length });
|
|
3815
|
+
const onSelectionChange = React2.useCallback((event) => {
|
|
3816
|
+
setSelection(event.nativeEvent.selection);
|
|
3817
|
+
}, []);
|
|
3818
|
+
const placeAfterEdit = React2.useCallback((text) => {
|
|
3819
|
+
const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection.end, text));
|
|
3820
|
+
setSelection({ start: caret, end: caret });
|
|
3821
|
+
}, [display, selection.end]);
|
|
3822
|
+
const clamped = { start: Math.min(selection.start, display.length), end: Math.min(selection.end, display.length) };
|
|
3823
|
+
return { selection: clamped, onSelectionChange, placeAfterEdit };
|
|
3824
|
+
}
|
|
3825
|
+
var FONT_SIZE = 14;
|
|
3826
|
+
var LINE_HEIGHT = 20;
|
|
3827
|
+
var COUNTER_FONT = 12;
|
|
3828
|
+
var BRANCH_OPACITY = 0.5;
|
|
3829
|
+
var GAP2 = 8;
|
|
3830
|
+
var ghostStyles = reactNative.StyleSheet.create({
|
|
3831
|
+
field: { flex: 1, justifyContent: "center", minHeight: LINE_HEIGHT },
|
|
3832
|
+
mono: { fontFamily: "monospace", fontSize: FONT_SIZE, lineHeight: LINE_HEIGHT },
|
|
3833
|
+
layer: { position: "absolute", left: 0, top: 0, bottom: 0 },
|
|
3834
|
+
hidden: { opacity: 0 },
|
|
3835
|
+
branch: { opacity: BRANCH_OPACITY },
|
|
3836
|
+
input: { padding: 0, borderWidth: 0, minHeight: LINE_HEIGHT },
|
|
3837
|
+
counter: { fontSize: COUNTER_FONT, marginLeft: GAP2 }
|
|
3838
|
+
});
|
|
3839
|
+
|
|
3840
|
+
// src/IbanInput/data/IbanRejection.ts
|
|
3841
|
+
var IbanRejection = /* @__PURE__ */ ((IbanRejection2) => {
|
|
3842
|
+
IbanRejection2["None"] = "None";
|
|
3843
|
+
IbanRejection2["Missing"] = "Missing";
|
|
3844
|
+
IbanRejection2["IllegalCharacter"] = "IllegalCharacter";
|
|
3845
|
+
IbanRejection2["MalformedCountryCode"] = "MalformedCountryCode";
|
|
3846
|
+
IbanRejection2["MalformedCheckDigits"] = "MalformedCheckDigits";
|
|
3847
|
+
IbanRejection2["UnknownCountry"] = "UnknownCountry";
|
|
3848
|
+
IbanRejection2["WrongLengthForCountry"] = "WrongLengthForCountry";
|
|
3849
|
+
IbanRejection2["ChecksumFailed"] = "ChecksumFailed";
|
|
3850
|
+
return IbanRejection2;
|
|
3851
|
+
})(IbanRejection || {});
|
|
3852
|
+
|
|
3853
|
+
// src/IbanInput/utils/iban.ts
|
|
3854
|
+
var COUNTRY_LENGTH2 = 2;
|
|
3855
|
+
var PREFIX_LENGTH = 4;
|
|
3856
|
+
var MODULUS = 97;
|
|
3857
|
+
var VALID_REMAINDER = 1;
|
|
3858
|
+
var LETTER_OFFSET = 10;
|
|
3859
|
+
var DIGIT_SHIFT = 10;
|
|
3860
|
+
var LETTER_SHIFT = 100;
|
|
3861
|
+
var CODE_A2 = 65;
|
|
3862
|
+
var CODE_0 = 48;
|
|
3863
|
+
var LETTER = /^[A-Za-z]$/;
|
|
3864
|
+
var DIGIT = /^[0-9]$/;
|
|
3865
|
+
function refused(rejection, expectedLength = null) {
|
|
3866
|
+
return { rejection, electronic: null, expectedLength };
|
|
3867
|
+
}
|
|
3868
|
+
function stripSeparators(raw) {
|
|
3869
|
+
let out = "";
|
|
3870
|
+
for (const character of raw) {
|
|
3871
|
+
if (character === " ") continue;
|
|
3872
|
+
if (!LETTER.test(character) && !DIGIT.test(character)) return null;
|
|
3873
|
+
out += character.toUpperCase();
|
|
3874
|
+
}
|
|
3875
|
+
return out === "" ? null : out;
|
|
3876
|
+
}
|
|
3877
|
+
function shapeFailure(iban) {
|
|
3878
|
+
if (iban.length <= PREFIX_LENGTH) return refused("MalformedCountryCode" /* MalformedCountryCode */);
|
|
3879
|
+
if (!LETTER.test(iban.charAt(0)) || !LETTER.test(iban.charAt(1))) return refused("MalformedCountryCode" /* MalformedCountryCode */);
|
|
3880
|
+
if (!DIGIT.test(iban.charAt(2)) || !DIGIT.test(iban.charAt(3))) return refused("MalformedCheckDigits" /* MalformedCheckDigits */);
|
|
3881
|
+
const expected = ibanLengthFor(iban.slice(0, COUNTRY_LENGTH2));
|
|
3882
|
+
if (expected === null) return refused("UnknownCountry" /* UnknownCountry */);
|
|
3883
|
+
return iban.length === expected ? null : refused("WrongLengthForCountry" /* WrongLengthForCountry */, expected);
|
|
3884
|
+
}
|
|
3885
|
+
function mod97(iban) {
|
|
3886
|
+
let remainder = 0;
|
|
3887
|
+
for (let index = 0; index < iban.length; index++) {
|
|
3888
|
+
const character = iban.charAt((index + PREFIX_LENGTH) % iban.length);
|
|
3889
|
+
const code = character.charCodeAt(0);
|
|
3890
|
+
remainder = DIGIT.test(character) ? remainder * DIGIT_SHIFT + (code - CODE_0) : remainder * LETTER_SHIFT + (code - CODE_A2 + LETTER_OFFSET);
|
|
3891
|
+
remainder %= MODULUS;
|
|
3892
|
+
}
|
|
3893
|
+
return remainder;
|
|
3894
|
+
}
|
|
3895
|
+
function validateIban(raw) {
|
|
3896
|
+
if (raw === null || raw === void 0 || raw.trim() === "") return refused("Missing" /* Missing */);
|
|
3897
|
+
const normalised = stripSeparators(raw);
|
|
3898
|
+
if (normalised === null) return refused("IllegalCharacter" /* IllegalCharacter */);
|
|
3899
|
+
const failure = shapeFailure(normalised);
|
|
3900
|
+
if (failure !== null) return failure;
|
|
3901
|
+
if (mod97(normalised) !== VALID_REMAINDER) return refused("ChecksumFailed" /* ChecksumFailed */);
|
|
3902
|
+
return { rejection: "None" /* None */, electronic: normalised, expectedLength: null };
|
|
3903
|
+
}
|
|
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 }) {
|
|
3920
|
+
const { theme } = uiFeedback.useUi();
|
|
3921
|
+
const { colors } = theme;
|
|
3922
|
+
const draft = React2.useMemo(() => draftIban(value), [value]);
|
|
3923
|
+
const validate = React2.useCallback(() => validateIban(value), [value]);
|
|
3924
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
3925
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
3926
|
+
const counter = ibanCounter(draft);
|
|
3927
|
+
const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
|
|
3928
|
+
const onChangeText = React2.useCallback((text) => {
|
|
3929
|
+
onEdit();
|
|
3930
|
+
onVerdict?.(null);
|
|
3931
|
+
placeAfterEdit(text);
|
|
3932
|
+
onChange(draftIban(text).electronic);
|
|
3933
|
+
}, [onEdit, onVerdict, placeAfterEdit, onChange]);
|
|
3934
|
+
const onBlur = React2.useCallback(() => {
|
|
3935
|
+
const verdict2 = onLeave();
|
|
3936
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
3937
|
+
}, [onLeave, onVerdict, value]);
|
|
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
|
+
)
|
|
3965
|
+
] }),
|
|
3966
|
+
counter !== null ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { testID: `${testID}-counter`, style: [ghostStyles.counter, { color: colors.textSecondary }], children: counter }) : null
|
|
3967
|
+
] }),
|
|
3968
|
+
/* @__PURE__ */ jsxRuntime.jsx(RejectionLine, { message, testID })
|
|
3969
|
+
] });
|
|
3970
|
+
}
|
|
3971
|
+
|
|
3972
|
+
// src/IbanInput/data/BicRejection.ts
|
|
3973
|
+
var BicRejection = /* @__PURE__ */ ((BicRejection2) => {
|
|
3974
|
+
BicRejection2["None"] = "None";
|
|
3975
|
+
BicRejection2["Missing"] = "Missing";
|
|
3976
|
+
BicRejection2["IllegalCharacter"] = "IllegalCharacter";
|
|
3977
|
+
BicRejection2["WrongLength"] = "WrongLength";
|
|
3978
|
+
BicRejection2["MalformedInstitution"] = "MalformedInstitution";
|
|
3979
|
+
BicRejection2["MalformedCountry"] = "MalformedCountry";
|
|
3980
|
+
BicRejection2["MalformedLocation"] = "MalformedLocation";
|
|
3981
|
+
return BicRejection2;
|
|
3982
|
+
})(BicRejection || {});
|
|
3983
|
+
|
|
3984
|
+
// src/IbanInput/utils/bic.ts
|
|
3985
|
+
var BIC8_LENGTH2 = 8;
|
|
3986
|
+
var BIC11_LENGTH2 = 11;
|
|
3987
|
+
var COUNTRY_START = 4;
|
|
3988
|
+
var LOCATION_INDEX = 6;
|
|
3989
|
+
var ALPHANUMERIC2 = /^[A-Za-z0-9]*$/;
|
|
3990
|
+
var INSTITUTION = /^[A-Z]{4}/;
|
|
3991
|
+
var COUNTRY = /^[A-Z]{2}$/;
|
|
3992
|
+
var RESERVED_LOCATION = ["0", "1"];
|
|
3993
|
+
var refused2 = (rejection) => ({ rejection, electronic: null });
|
|
3994
|
+
function validateBic(raw) {
|
|
3995
|
+
if (raw === null || raw === void 0 || raw.trim() === "") return refused2("Missing" /* Missing */);
|
|
3996
|
+
const trimmed = raw.trim();
|
|
3997
|
+
if (!ALPHANUMERIC2.test(trimmed)) return refused2("IllegalCharacter" /* IllegalCharacter */);
|
|
3998
|
+
const bic = trimmed.toUpperCase();
|
|
3999
|
+
if (bic.length !== BIC8_LENGTH2 && bic.length !== BIC11_LENGTH2) return refused2("WrongLength" /* WrongLength */);
|
|
4000
|
+
if (!INSTITUTION.test(bic)) return refused2("MalformedInstitution" /* MalformedInstitution */);
|
|
4001
|
+
if (!COUNTRY.test(bic.slice(COUNTRY_START, LOCATION_INDEX))) return refused2("MalformedCountry" /* MalformedCountry */);
|
|
4002
|
+
if (RESERVED_LOCATION.includes(bic.charAt(LOCATION_INDEX))) return refused2("MalformedLocation" /* MalformedLocation */);
|
|
4003
|
+
return { rejection: "None" /* None */, electronic: bic };
|
|
4004
|
+
}
|
|
4005
|
+
function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, rejectionLabels }) {
|
|
4006
|
+
const { theme } = uiFeedback.useUi();
|
|
4007
|
+
const { colors } = theme;
|
|
4008
|
+
const draft = React2.useMemo(() => draftBic(value), [value]);
|
|
4009
|
+
const validate = React2.useCallback(() => validateBic(value), [value]);
|
|
4010
|
+
const { verdict, onEdit, onLeave } = useBlurVerdict(validate);
|
|
4011
|
+
const message = value === "" ? null : rejectionMessage(verdict?.rejection ?? null, "None" /* None */, rejectionLabels);
|
|
4012
|
+
const onChangeText = React2.useCallback((text) => {
|
|
4013
|
+
onEdit();
|
|
4014
|
+
onVerdict?.(null);
|
|
4015
|
+
onChange(draftBic(text).value);
|
|
4016
|
+
}, [onEdit, onVerdict, onChange]);
|
|
4017
|
+
const onBlur = React2.useCallback(() => {
|
|
4018
|
+
const verdict2 = onLeave();
|
|
4019
|
+
onVerdict?.(value === "" ? null : verdict2);
|
|
4020
|
+
}, [onLeave, onVerdict, value]);
|
|
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
|
+
] });
|
|
4047
|
+
}
|
|
4048
|
+
|
|
2561
4049
|
exports.AddOnRequest = AddOnRequest;
|
|
2562
4050
|
exports.AlignToControl = AlignToControl;
|
|
2563
4051
|
exports.AnchoredMenu = AnchoredMenu;
|
|
4052
|
+
exports.BicInput = BicInput;
|
|
4053
|
+
exports.BicRejection = BicRejection;
|
|
4054
|
+
exports.COUNTRIES = COUNTRIES;
|
|
2564
4055
|
exports.ChipSelector = ChipSelector;
|
|
4056
|
+
exports.CountryField = CountryField;
|
|
4057
|
+
exports.CountryFlag = CountryFlag;
|
|
2565
4058
|
exports.DEFAULT_MAX_RECENTS = DEFAULT_MAX_RECENTS;
|
|
2566
4059
|
exports.DEFAULT_OPTIONAL_LABEL = DEFAULT_OPTIONAL_LABEL;
|
|
2567
4060
|
exports.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
@@ -2570,8 +4063,12 @@ exports.DateField = DateField;
|
|
|
2570
4063
|
exports.DateInput = DateInput;
|
|
2571
4064
|
exports.DateRangeControl = DateRangeControl;
|
|
2572
4065
|
exports.DateTimeField = DateTimeField;
|
|
4066
|
+
exports.DropdownPlacement = DropdownPlacement;
|
|
4067
|
+
exports.FLAG_HEIGHT = FLAG_HEIGHT;
|
|
4068
|
+
exports.FLAG_WIDTH = FLAG_WIDTH;
|
|
2573
4069
|
exports.Field = Field;
|
|
2574
4070
|
exports.FixBar = FixBar;
|
|
4071
|
+
exports.FlagShapeKind = FlagShapeKind;
|
|
2575
4072
|
exports.FormActions = FormActions;
|
|
2576
4073
|
exports.FormCell = FormCell;
|
|
2577
4074
|
exports.FormCheckbox = FormCheckbox;
|
|
@@ -2581,32 +4078,65 @@ exports.FormSection = FormSection;
|
|
|
2581
4078
|
exports.FormStack = FormStack;
|
|
2582
4079
|
exports.FormStatusLine = FormStatusLine;
|
|
2583
4080
|
exports.FormSwitch = FormSwitch;
|
|
4081
|
+
exports.IBAN_MAX_LENGTH = IBAN_MAX_LENGTH;
|
|
4082
|
+
exports.IBAN_REGISTERED_COUNTRY_COUNT = IBAN_REGISTERED_COUNTRY_COUNT;
|
|
2584
4083
|
exports.INLINE_FIELD_ROW_MIN_WIDTH = INLINE_FIELD_ROW_MIN_WIDTH;
|
|
4084
|
+
exports.IbanInput = IbanInput;
|
|
4085
|
+
exports.IbanRejection = IbanRejection;
|
|
2585
4086
|
exports.InlineFieldRow = InlineFieldRow;
|
|
4087
|
+
exports.PHONE_MAX_WIDTH = PHONE_MAX_WIDTH;
|
|
2586
4088
|
exports.RESPONSIVE_FORM_DEFAULT_BREAKPOINT = RESPONSIVE_FORM_DEFAULT_BREAKPOINT;
|
|
2587
4089
|
exports.ResponsiveFormLayout = ResponsiveFormLayout;
|
|
4090
|
+
exports.SearchSelect = SearchSelect;
|
|
2588
4091
|
exports.SelectControl = SelectControl;
|
|
2589
4092
|
exports.SelectField = SelectField;
|
|
4093
|
+
exports.SelectSurface = SelectSurface;
|
|
2590
4094
|
exports.StepperNav = StepperNav;
|
|
2591
4095
|
exports.StepperTabs = StepperTabs;
|
|
2592
4096
|
exports.ThemedTextInput = ThemedTextInput;
|
|
2593
4097
|
exports.TypeaheadControl = TypeaheadControl;
|
|
2594
4098
|
exports.UploadWithLinkField = UploadWithLinkField;
|
|
4099
|
+
exports.buildSearchSelectSections = buildSearchSelectSections;
|
|
2595
4100
|
exports.controlStyles = controlStyles;
|
|
4101
|
+
exports.countryFlag = countryFlag;
|
|
4102
|
+
exports.countryOptions = countryOptions;
|
|
4103
|
+
exports.draftBic = draftBic;
|
|
4104
|
+
exports.draftIban = draftIban;
|
|
4105
|
+
exports.dropdownFrame = dropdownFrame;
|
|
4106
|
+
exports.findOption = findOption;
|
|
4107
|
+
exports.flagShapes = flagShapes;
|
|
2596
4108
|
exports.groupAriaChecked = groupAriaChecked;
|
|
4109
|
+
exports.groupInFours = groupInFours;
|
|
4110
|
+
exports.highlightAfterQuery = highlightAfterQuery;
|
|
4111
|
+
exports.ibanCounter = ibanCounter;
|
|
4112
|
+
exports.ibanLengthFor = ibanLengthFor;
|
|
2597
4113
|
exports.inlineFieldRowLayout = inlineFieldRowLayout;
|
|
2598
4114
|
exports.isAddOnOpen = isAddOnOpen;
|
|
4115
|
+
exports.isFallbackFlag = isFallbackFlag;
|
|
2599
4116
|
exports.isFixBarVisible = isFixBarVisible;
|
|
4117
|
+
exports.isOutside = isOutside;
|
|
2600
4118
|
exports.isUnmatched = isUnmatched;
|
|
2601
4119
|
exports.isWideFormLayout = isWideFormLayout;
|
|
4120
|
+
exports.moveHighlight = moveHighlight;
|
|
2602
4121
|
exports.nextHighlight = nextHighlight;
|
|
4122
|
+
exports.placeDropdown = placeDropdown;
|
|
4123
|
+
exports.rejectionMessage = rejectionMessage;
|
|
2603
4124
|
exports.resolveGroupSelection = resolveGroupSelection;
|
|
4125
|
+
exports.resolveSelectMotion = resolveSelectMotion;
|
|
2604
4126
|
exports.resolveStepNeighbours = resolveStepNeighbours;
|
|
2605
4127
|
exports.suggestOptions = suggestOptions;
|
|
4128
|
+
exports.toCountryValue = toCountryValue;
|
|
2606
4129
|
exports.toggleGroupSelection = toggleGroupSelection;
|
|
4130
|
+
exports.useBlurVerdict = useBlurVerdict;
|
|
4131
|
+
exports.useDeferredFocus = useDeferredFocus;
|
|
2607
4132
|
exports.useFocusFirstInvalid = useFocusFirstInvalid;
|
|
2608
4133
|
exports.useKeepInView = useKeepInView;
|
|
4134
|
+
exports.useOutsidePress = useOutsidePress;
|
|
2609
4135
|
exports.useRecentValues = useRecentValues;
|
|
4136
|
+
exports.useReducedMotion = useReducedMotion;
|
|
4137
|
+
exports.useSearchSelectState = useSearchSelectState;
|
|
2610
4138
|
exports.useThemedInput = useThemedInput;
|
|
4139
|
+
exports.validateBic = validateBic;
|
|
4140
|
+
exports.validateIban = validateIban;
|
|
2611
4141
|
//# sourceMappingURL=index.js.map
|
|
2612
4142
|
//# sourceMappingURL=index.js.map
|