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