@scripso-homepad/ui 0.4.22 → 0.4.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { GestureResponderEvent, StyleProp, ViewStyle, TextStyle, TextInputProps, TextProps } from 'react-native';
3
+ import { GestureResponderEvent, StyleProp, ViewStyle, TextStyle, TextInputProps, ImageStyle, TextProps } from 'react-native';
4
4
 
5
5
  type ButtonVariant = "white" | "primary" | "green" | "gray";
6
6
  type ButtonSize = "lg" | "sm";
@@ -131,6 +131,21 @@ interface CountryCodeSelectorProps {
131
131
  }
132
132
  declare function CountryCodeSelector({ value, onValueChange, options, disabled, style, className, }: CountryCodeSelectorProps): react.JSX.Element;
133
133
 
134
+ type CountryFlagProps = {
135
+ code: string;
136
+ style?: StyleProp<ImageStyle>;
137
+ };
138
+ /** Renders a country flag image (works on Windows; emoji flags do not). */
139
+ declare function CountryFlag({ code, style }: CountryFlagProps): react.JSX.Element | null;
140
+
141
+ /** ISO 3166-1 alpha-2 country code → flag emoji. Prefer CountryFlag images on Windows. */
142
+ declare function countryCodeToFlagEmoji(code: string): string;
143
+ /**
144
+ * PNG flag URL (flagcdn). Windows does not render regional-indicator flag emoji,
145
+ * so UI should use images instead of countryCodeToFlagEmoji.
146
+ */
147
+ declare function getCountryFlagImageUri(code: string): string | null;
148
+
134
149
  type DateRange = {
135
150
  start: Date;
136
151
  end?: Date;
@@ -525,4 +540,4 @@ declare const shadows: {
525
540
  };
526
541
  };
527
542
 
528
- export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarIcon, type CalendarLabels, type CalendarLocale, CalendarLocaleProvider, type CalendarLocaleProviderProps, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type CalendarTranslationKey$1 as CalendarTranslationKey, type CalendarTranslations, type Country, CountryCodeSelector, type CountryCodeSelectorProps, DatePicker, type DatePickerProps, type DatePickerRangeProps, type DatePickerSingleProps, type DateRange, type EmeraldGreenStep, Input, type InputProps, Label, type LabelProps, LockIcon, type MultipleSelectProps, type NavyStep, PhoneInput, type PhoneInputProps, type RubyRedStep, Select, type SelectOption, type SelectProps, type SingleSelectProps, type StormGrayStep, brand, buttonTypography, calendarTranslations, colors, countries, defaultCountry, emeraldGreen, findCountry, fontSize, fontWeight, fonts, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, labelTypography, navy, radii, resolveCalendarLocale, resolveWeekdayLabels, rubyRed, shadows, spacing, stormGray, typographyScale, useCalendarLocale };
543
+ export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarIcon, type CalendarLabels, type CalendarLocale, CalendarLocaleProvider, type CalendarLocaleProviderProps, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type CalendarTranslationKey$1 as CalendarTranslationKey, type CalendarTranslations, type Country, CountryCodeSelector, type CountryCodeSelectorProps, CountryFlag, type CountryFlagProps, DatePicker, type DatePickerProps, type DatePickerRangeProps, type DatePickerSingleProps, type DateRange, type EmeraldGreenStep, Input, type InputProps, Label, type LabelProps, LockIcon, type MultipleSelectProps, type NavyStep, PhoneInput, type PhoneInputProps, type RubyRedStep, Select, type SelectOption, type SelectProps, type SingleSelectProps, type StormGrayStep, brand, buttonTypography, calendarTranslations, colors, countries, countryCodeToFlagEmoji, defaultCountry, emeraldGreen, findCountry, fontSize, fontWeight, fonts, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, getCountryFlagImageUri, labelTypography, navy, radii, resolveCalendarLocale, resolveWeekdayLabels, rubyRed, shadows, spacing, stormGray, typographyScale, useCalendarLocale };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { GestureResponderEvent, StyleProp, ViewStyle, TextStyle, TextInputProps, TextProps } from 'react-native';
3
+ import { GestureResponderEvent, StyleProp, ViewStyle, TextStyle, TextInputProps, ImageStyle, TextProps } from 'react-native';
4
4
 
5
5
  type ButtonVariant = "white" | "primary" | "green" | "gray";
6
6
  type ButtonSize = "lg" | "sm";
@@ -131,6 +131,21 @@ interface CountryCodeSelectorProps {
131
131
  }
132
132
  declare function CountryCodeSelector({ value, onValueChange, options, disabled, style, className, }: CountryCodeSelectorProps): react.JSX.Element;
133
133
 
134
+ type CountryFlagProps = {
135
+ code: string;
136
+ style?: StyleProp<ImageStyle>;
137
+ };
138
+ /** Renders a country flag image (works on Windows; emoji flags do not). */
139
+ declare function CountryFlag({ code, style }: CountryFlagProps): react.JSX.Element | null;
140
+
141
+ /** ISO 3166-1 alpha-2 country code → flag emoji. Prefer CountryFlag images on Windows. */
142
+ declare function countryCodeToFlagEmoji(code: string): string;
143
+ /**
144
+ * PNG flag URL (flagcdn). Windows does not render regional-indicator flag emoji,
145
+ * so UI should use images instead of countryCodeToFlagEmoji.
146
+ */
147
+ declare function getCountryFlagImageUri(code: string): string | null;
148
+
134
149
  type DateRange = {
135
150
  start: Date;
136
151
  end?: Date;
@@ -525,4 +540,4 @@ declare const shadows: {
525
540
  };
526
541
  };
527
542
 
528
- export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarIcon, type CalendarLabels, type CalendarLocale, CalendarLocaleProvider, type CalendarLocaleProviderProps, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type CalendarTranslationKey$1 as CalendarTranslationKey, type CalendarTranslations, type Country, CountryCodeSelector, type CountryCodeSelectorProps, DatePicker, type DatePickerProps, type DatePickerRangeProps, type DatePickerSingleProps, type DateRange, type EmeraldGreenStep, Input, type InputProps, Label, type LabelProps, LockIcon, type MultipleSelectProps, type NavyStep, PhoneInput, type PhoneInputProps, type RubyRedStep, Select, type SelectOption, type SelectProps, type SingleSelectProps, type StormGrayStep, brand, buttonTypography, calendarTranslations, colors, countries, defaultCountry, emeraldGreen, findCountry, fontSize, fontWeight, fonts, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, labelTypography, navy, radii, resolveCalendarLocale, resolveWeekdayLabels, rubyRed, shadows, spacing, stormGray, typographyScale, useCalendarLocale };
543
+ export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarIcon, type CalendarLabels, type CalendarLocale, CalendarLocaleProvider, type CalendarLocaleProviderProps, type CalendarProps, type CalendarRangeProps, type CalendarSingleProps, type CalendarTranslationKey$1 as CalendarTranslationKey, type CalendarTranslations, type Country, CountryCodeSelector, type CountryCodeSelectorProps, CountryFlag, type CountryFlagProps, DatePicker, type DatePickerProps, type DatePickerRangeProps, type DatePickerSingleProps, type DateRange, type EmeraldGreenStep, Input, type InputProps, Label, type LabelProps, LockIcon, type MultipleSelectProps, type NavyStep, PhoneInput, type PhoneInputProps, type RubyRedStep, Select, type SelectOption, type SelectProps, type SingleSelectProps, type StormGrayStep, brand, buttonTypography, calendarTranslations, colors, countries, countryCodeToFlagEmoji, defaultCountry, emeraldGreen, findCountry, fontSize, fontWeight, fonts, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, getCountryFlagImageUri, labelTypography, navy, radii, resolveCalendarLocale, resolveWeekdayLabels, rubyRed, shadows, spacing, stormGray, typographyScale, useCalendarLocale };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spacing, colors, fontWeight, fontSize, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-KJYQA5OY.js';
2
2
  export { Button, Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray, typographyScale } from './chunk-KJYQA5OY.js';
3
3
  import { createContext, useRef, useState, useMemo, useEffect, useLayoutEffect, useContext, isValidElement, cloneElement } from 'react';
4
- import { Platform, StyleSheet, Animated, Easing, View, Pressable, Text, Modal, ScrollView, TextInput, Dimensions } from 'react-native';
4
+ import { Platform, StyleSheet, Animated, Easing, View, Pressable, Text, Modal, ScrollView, Image, TextInput, Dimensions } from 'react-native';
5
5
  import Svg2, { Path } from 'react-native-svg';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
 
@@ -886,6 +886,35 @@ function countryCodeToFlagEmoji(code) {
886
886
  ...upper.split("").map((char) => 127462 - 65 + char.charCodeAt(0))
887
887
  );
888
888
  }
889
+ function getCountryFlagImageUri(code) {
890
+ const lower = code.trim().toLowerCase();
891
+ if (!/^[a-z]{2}$/.test(lower)) return null;
892
+ return `https://flagcdn.com/w40/${lower}.png`;
893
+ }
894
+ var FLAG_HEIGHT = 18;
895
+ var FLAG_WIDTH = 24;
896
+ function CountryFlag({ code, style }) {
897
+ const uri = getCountryFlagImageUri(code);
898
+ if (uri === null) {
899
+ return null;
900
+ }
901
+ return /* @__PURE__ */ jsx(
902
+ Image,
903
+ {
904
+ source: { uri },
905
+ style: [styles2.flag, style],
906
+ accessibilityIgnoresInvertColors: true,
907
+ accessibilityLabel: `${code.trim().toUpperCase()} flag`
908
+ }
909
+ );
910
+ }
911
+ var styles2 = StyleSheet.create({
912
+ flag: {
913
+ width: FLAG_WIDTH,
914
+ height: FLAG_HEIGHT,
915
+ borderRadius: 2
916
+ }
917
+ });
889
918
  var DROPDOWN_GAP = 10;
890
919
  var DROPDOWN_HEIGHT = 186;
891
920
  var DROPDOWN_PADDING = 8;
@@ -951,13 +980,13 @@ function CountryCodeSelector({
951
980
  accessibilityRole: "button",
952
981
  onPress: () => handleSelect(item.code),
953
982
  style: [
954
- styles2.option,
955
- isSelected && styles2.optionSelected,
956
- !isLast && styles2.optionSpacing
983
+ styles3.option,
984
+ isSelected && styles3.optionSelected,
985
+ !isLast && styles3.optionSpacing
957
986
  ],
958
987
  children: [
959
- /* @__PURE__ */ jsx(Text, { style: styles2.flag, children: countryCodeToFlagEmoji(item.code) }),
960
- /* @__PURE__ */ jsx(Text, { style: styles2.optionDialCode, children: item.dialCode })
988
+ /* @__PURE__ */ jsx(CountryFlag, { code: item.code }),
989
+ /* @__PURE__ */ jsx(Text, { style: styles3.optionDialCode, children: item.dialCode })
961
990
  ]
962
991
  },
963
992
  item.code
@@ -967,8 +996,8 @@ function CountryCodeSelector({
967
996
  ScrollView,
968
997
  {
969
998
  ref: scrollRef,
970
- style: styles2.dropdownScroll,
971
- contentContainerStyle: styles2.dropdownContent,
999
+ style: styles3.dropdownScroll,
1000
+ contentContainerStyle: styles3.dropdownContent,
972
1001
  keyboardShouldPersistTaps: "handled",
973
1002
  showsVerticalScrollIndicator: true,
974
1003
  bounces: false,
@@ -976,7 +1005,7 @@ function CountryCodeSelector({
976
1005
  children: optionList
977
1006
  }
978
1007
  );
979
- return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles2.root, style], children: [
1008
+ return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.root, style], children: [
980
1009
  /* @__PURE__ */ jsxs(
981
1010
  Pressable,
982
1011
  {
@@ -985,13 +1014,13 @@ function CountryCodeSelector({
985
1014
  disabled,
986
1015
  onPress: handleOpen,
987
1016
  style: [
988
- styles2.trigger,
989
- disabled ? styles2.triggerDisabled : styles2.triggerEnabled,
990
- Platform.OS === "web" ? styles2.triggerWeb : null
1017
+ styles3.trigger,
1018
+ disabled ? styles3.triggerDisabled : styles3.triggerEnabled,
1019
+ Platform.OS === "web" ? styles3.triggerWeb : null
991
1020
  ],
992
1021
  children: [
993
- /* @__PURE__ */ jsx(Text, { style: styles2.flag, children: countryCodeToFlagEmoji(selected.code) }),
994
- /* @__PURE__ */ jsx(Text, { style: [styles2.dialCode, { color: textColor }], children: selected.dialCode }),
1022
+ /* @__PURE__ */ jsx(CountryFlag, { code: selected.code }),
1023
+ /* @__PURE__ */ jsx(Text, { style: [styles3.dialCode, { color: textColor }], children: selected.dialCode }),
995
1024
  /* @__PURE__ */ jsx(ChevronDownIcon, { size: CHEVRON_SIZE, color: colors.stormGray100 })
996
1025
  ]
997
1026
  }
@@ -1003,11 +1032,11 @@ function CountryCodeSelector({
1003
1032
  transparent: true,
1004
1033
  animationType: "fade",
1005
1034
  onRequestClose: closeDropdown,
1006
- children: /* @__PURE__ */ jsx(Pressable, { style: styles2.overlay, onPress: closeDropdown, children: anchor ? /* @__PURE__ */ jsx(
1035
+ children: /* @__PURE__ */ jsx(Pressable, { style: styles3.overlay, onPress: closeDropdown, children: anchor ? /* @__PURE__ */ jsx(
1007
1036
  View,
1008
1037
  {
1009
1038
  style: [
1010
- styles2.dropdown,
1039
+ styles3.dropdown,
1011
1040
  {
1012
1041
  top: dropdownTop,
1013
1042
  left: anchor.x,
@@ -1021,7 +1050,7 @@ function CountryCodeSelector({
1021
1050
  )
1022
1051
  ] });
1023
1052
  }
1024
- var styles2 = StyleSheet.create({
1053
+ var styles3 = StyleSheet.create({
1025
1054
  root: {
1026
1055
  alignSelf: "flex-start",
1027
1056
  flexShrink: 0
@@ -1049,10 +1078,6 @@ var styles2 = StyleSheet.create({
1049
1078
  triggerWeb: {
1050
1079
  width: "max-content"
1051
1080
  },
1052
- flag: {
1053
- fontSize: 18,
1054
- lineHeight: 24
1055
- },
1056
1081
  dialCode: {
1057
1082
  fontSize: fontSize.md,
1058
1083
  fontWeight: fontWeight.medium,
@@ -1151,7 +1176,7 @@ function PhoneInput({
1151
1176
  onChangeText?.(sanitizePhoneDigits(value));
1152
1177
  }
1153
1178
  const helperMessage = error ?? hint;
1154
- return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
1179
+ return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles4.wrapper, containerStyle], children: [
1155
1180
  label ? /* @__PURE__ */ jsx(
1156
1181
  Label,
1157
1182
  {
@@ -1161,24 +1186,24 @@ function PhoneInput({
1161
1186
  children: label
1162
1187
  }
1163
1188
  ) : null,
1164
- /* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
1189
+ /* @__PURE__ */ jsxs(View, { style: styles4.row, children: [
1165
1190
  /* @__PURE__ */ jsx(
1166
1191
  CountryCodeSelector,
1167
1192
  {
1168
1193
  value: countryCode,
1169
1194
  onValueChange: onCountryCodeChange,
1170
1195
  disabled: isDisabled,
1171
- style: styles3.countrySelector
1196
+ style: styles4.countrySelector
1172
1197
  }
1173
1198
  ),
1174
- /* @__PURE__ */ jsx(View, { style: [phoneFieldStyles.outline, styles3.phoneOutline], children: /* @__PURE__ */ jsx(
1199
+ /* @__PURE__ */ jsx(View, { style: [phoneFieldStyles.outline, styles4.phoneOutline], children: /* @__PURE__ */ jsx(
1175
1200
  View,
1176
1201
  {
1177
1202
  style: [
1178
1203
  inputFieldMetrics.containerBase,
1179
1204
  inputFieldMetrics.container,
1180
1205
  phoneFieldStyles.container,
1181
- styles3.phoneField
1206
+ styles4.phoneField
1182
1207
  ],
1183
1208
  children: /* @__PURE__ */ jsx(
1184
1209
  TextInput,
@@ -1202,10 +1227,10 @@ function PhoneInput({
1202
1227
  }
1203
1228
  ) })
1204
1229
  ] }),
1205
- helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles3.error : styles3.hint, children: helperMessage }) : null
1230
+ helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles4.error : styles4.hint, children: helperMessage }) : null
1206
1231
  ] });
1207
1232
  }
1208
- var styles3 = StyleSheet.create({
1233
+ var styles4 = StyleSheet.create({
1209
1234
  wrapper: {
1210
1235
  width: "100%",
1211
1236
  gap: spacing.sm
@@ -2383,16 +2408,16 @@ function DatePicker(props) {
2383
2408
  View,
2384
2409
  {
2385
2410
  ref: wrapperRef,
2386
- style: [styles4.wrapper, isFluidField && styles4.wrapperFluid, containerStyle],
2411
+ style: [styles5.wrapper, isFluidField && styles5.wrapperFluid, containerStyle],
2387
2412
  children: [
2388
- label ? /* @__PURE__ */ jsx(Label, { disabled, style: styles4.label, className: labelClassName, children: label }) : null,
2413
+ label ? /* @__PURE__ */ jsx(Label, { disabled, style: styles5.label, className: labelClassName, children: label }) : null,
2389
2414
  /* @__PURE__ */ jsx(
2390
2415
  View,
2391
2416
  {
2392
2417
  style: [
2393
2418
  fieldStyles.outline,
2394
- styles4.fieldOutline,
2395
- isFluidField && styles4.fieldOutlineFluid,
2419
+ styles5.fieldOutline,
2420
+ isFluidField && styles5.fieldOutlineFluid,
2396
2421
  fieldOutlineStyle
2397
2422
  ],
2398
2423
  children: /* @__PURE__ */ jsxs(
@@ -2405,7 +2430,7 @@ function DatePicker(props) {
2405
2430
  onPress: openPicker,
2406
2431
  style: [
2407
2432
  calendarFieldMetrics.container,
2408
- isFluidField && styles4.fieldContainerFluid,
2433
+ isFluidField && styles5.fieldContainerFluid,
2409
2434
  fieldStyles.container,
2410
2435
  fieldStyle
2411
2436
  ],
@@ -2418,7 +2443,7 @@ function DatePicker(props) {
2418
2443
  children: displayValue
2419
2444
  }
2420
2445
  ),
2421
- /* @__PURE__ */ jsx(View, { style: styles4.iconSlot, children: /* @__PURE__ */ jsx(
2446
+ /* @__PURE__ */ jsx(View, { style: styles5.iconSlot, children: /* @__PURE__ */ jsx(
2422
2447
  CalendarIcon,
2423
2448
  {
2424
2449
  size: CALENDAR_FIELD_ICON_SIZE,
@@ -2430,12 +2455,12 @@ function DatePicker(props) {
2430
2455
  )
2431
2456
  }
2432
2457
  ),
2433
- helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles4.error : styles4.hint, children: helperMessage }) : null,
2434
- /* @__PURE__ */ jsx(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closePicker, children: /* @__PURE__ */ jsxs(View, { style: styles4.modalRoot, children: [
2458
+ helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles5.error : styles5.hint, children: helperMessage }) : null,
2459
+ /* @__PURE__ */ jsx(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closePicker, children: /* @__PURE__ */ jsxs(View, { style: styles5.modalRoot, children: [
2435
2460
  /* @__PURE__ */ jsx(
2436
2461
  Pressable,
2437
2462
  {
2438
- style: styles4.backdrop,
2463
+ style: styles5.backdrop,
2439
2464
  onPress: closePicker,
2440
2465
  accessibilityRole: "button",
2441
2466
  accessibilityLabel: labels?.closeCalendar ?? translations.closeCalendar
@@ -2445,7 +2470,7 @@ function DatePicker(props) {
2445
2470
  View,
2446
2471
  {
2447
2472
  style: [
2448
- styles4.panelPosition,
2473
+ styles5.panelPosition,
2449
2474
  {
2450
2475
  top: dropdownTop,
2451
2476
  left: panelLeft,
@@ -2493,7 +2518,7 @@ function DatePicker(props) {
2493
2518
  }
2494
2519
  );
2495
2520
  }
2496
- var styles4 = StyleSheet.create({
2521
+ var styles5 = StyleSheet.create({
2497
2522
  wrapper: {
2498
2523
  width: CALENDAR_FIELD_WIDTH,
2499
2524
  maxWidth: "100%",
@@ -2569,6 +2594,6 @@ function LockIcon({
2569
2594
  ) });
2570
2595
  }
2571
2596
 
2572
- export { Calendar, CalendarIcon, CalendarLocaleProvider, CountryCodeSelector, DatePicker, LockIcon, PhoneInput, Select, calendarTranslations, countries, defaultCountry, findCountry, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, resolveCalendarLocale, resolveWeekdayLabels, useCalendarLocale };
2597
+ export { Calendar, CalendarIcon, CalendarLocaleProvider, CountryCodeSelector, CountryFlag, DatePicker, LockIcon, PhoneInput, Select, calendarTranslations, countries, countryCodeToFlagEmoji, defaultCountry, findCountry, formatLocalizedCalendarMonthYear, getCalendarMonthLabels, getCalendarTranslations, getCountryFlagImageUri, resolveCalendarLocale, resolveWeekdayLabels, useCalendarLocale };
2573
2598
  //# sourceMappingURL=index.js.map
2574
2599
  //# sourceMappingURL=index.js.map