@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.cjs CHANGED
@@ -1816,6 +1816,35 @@ function countryCodeToFlagEmoji(code) {
1816
1816
  ...upper.split("").map((char) => 127462 - 65 + char.charCodeAt(0))
1817
1817
  );
1818
1818
  }
1819
+ function getCountryFlagImageUri(code) {
1820
+ const lower = code.trim().toLowerCase();
1821
+ if (!/^[a-z]{2}$/.test(lower)) return null;
1822
+ return `https://flagcdn.com/w40/${lower}.png`;
1823
+ }
1824
+ var FLAG_HEIGHT = 18;
1825
+ var FLAG_WIDTH = 24;
1826
+ function CountryFlag({ code, style }) {
1827
+ const uri = getCountryFlagImageUri(code);
1828
+ if (uri === null) {
1829
+ return null;
1830
+ }
1831
+ return /* @__PURE__ */ jsxRuntime.jsx(
1832
+ reactNative.Image,
1833
+ {
1834
+ source: { uri },
1835
+ style: [styles5.flag, style],
1836
+ accessibilityIgnoresInvertColors: true,
1837
+ accessibilityLabel: `${code.trim().toUpperCase()} flag`
1838
+ }
1839
+ );
1840
+ }
1841
+ var styles5 = reactNative.StyleSheet.create({
1842
+ flag: {
1843
+ width: FLAG_WIDTH,
1844
+ height: FLAG_HEIGHT,
1845
+ borderRadius: 2
1846
+ }
1847
+ });
1819
1848
  var DROPDOWN_GAP = 10;
1820
1849
  var DROPDOWN_HEIGHT = 186;
1821
1850
  var DROPDOWN_PADDING = 8;
@@ -1881,13 +1910,13 @@ function CountryCodeSelector({
1881
1910
  accessibilityRole: "button",
1882
1911
  onPress: () => handleSelect(item.code),
1883
1912
  style: [
1884
- styles5.option,
1885
- isSelected && styles5.optionSelected,
1886
- !isLast && styles5.optionSpacing
1913
+ styles6.option,
1914
+ isSelected && styles6.optionSelected,
1915
+ !isLast && styles6.optionSpacing
1887
1916
  ],
1888
1917
  children: [
1889
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles5.flag, children: countryCodeToFlagEmoji(item.code) }),
1890
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles5.optionDialCode, children: item.dialCode })
1918
+ /* @__PURE__ */ jsxRuntime.jsx(CountryFlag, { code: item.code }),
1919
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles6.optionDialCode, children: item.dialCode })
1891
1920
  ]
1892
1921
  },
1893
1922
  item.code
@@ -1897,8 +1926,8 @@ function CountryCodeSelector({
1897
1926
  reactNative.ScrollView,
1898
1927
  {
1899
1928
  ref: scrollRef,
1900
- style: styles5.dropdownScroll,
1901
- contentContainerStyle: styles5.dropdownContent,
1929
+ style: styles6.dropdownScroll,
1930
+ contentContainerStyle: styles6.dropdownContent,
1902
1931
  keyboardShouldPersistTaps: "handled",
1903
1932
  showsVerticalScrollIndicator: true,
1904
1933
  bounces: false,
@@ -1906,7 +1935,7 @@ function CountryCodeSelector({
1906
1935
  children: optionList
1907
1936
  }
1908
1937
  );
1909
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: wrapperRef, style: [styles5.root, style], children: [
1938
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: wrapperRef, style: [styles6.root, style], children: [
1910
1939
  /* @__PURE__ */ jsxRuntime.jsxs(
1911
1940
  reactNative.Pressable,
1912
1941
  {
@@ -1915,13 +1944,13 @@ function CountryCodeSelector({
1915
1944
  disabled,
1916
1945
  onPress: handleOpen,
1917
1946
  style: [
1918
- styles5.trigger,
1919
- disabled ? styles5.triggerDisabled : styles5.triggerEnabled,
1920
- reactNative.Platform.OS === "web" ? styles5.triggerWeb : null
1947
+ styles6.trigger,
1948
+ disabled ? styles6.triggerDisabled : styles6.triggerEnabled,
1949
+ reactNative.Platform.OS === "web" ? styles6.triggerWeb : null
1921
1950
  ],
1922
1951
  children: [
1923
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles5.flag, children: countryCodeToFlagEmoji(selected.code) }),
1924
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles5.dialCode, { color: textColor }], children: selected.dialCode }),
1952
+ /* @__PURE__ */ jsxRuntime.jsx(CountryFlag, { code: selected.code }),
1953
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.dialCode, { color: textColor }], children: selected.dialCode }),
1925
1954
  /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, { size: CHEVRON_SIZE, color: colors.stormGray100 })
1926
1955
  ]
1927
1956
  }
@@ -1933,11 +1962,11 @@ function CountryCodeSelector({
1933
1962
  transparent: true,
1934
1963
  animationType: "fade",
1935
1964
  onRequestClose: closeDropdown,
1936
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style: styles5.overlay, onPress: closeDropdown, children: anchor ? /* @__PURE__ */ jsxRuntime.jsx(
1965
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { style: styles6.overlay, onPress: closeDropdown, children: anchor ? /* @__PURE__ */ jsxRuntime.jsx(
1937
1966
  reactNative.View,
1938
1967
  {
1939
1968
  style: [
1940
- styles5.dropdown,
1969
+ styles6.dropdown,
1941
1970
  {
1942
1971
  top: dropdownTop,
1943
1972
  left: anchor.x,
@@ -1951,7 +1980,7 @@ function CountryCodeSelector({
1951
1980
  )
1952
1981
  ] });
1953
1982
  }
1954
- var styles5 = reactNative.StyleSheet.create({
1983
+ var styles6 = reactNative.StyleSheet.create({
1955
1984
  root: {
1956
1985
  alignSelf: "flex-start",
1957
1986
  flexShrink: 0
@@ -1979,10 +2008,6 @@ var styles5 = reactNative.StyleSheet.create({
1979
2008
  triggerWeb: {
1980
2009
  width: "max-content"
1981
2010
  },
1982
- flag: {
1983
- fontSize: 18,
1984
- lineHeight: 24
1985
- },
1986
2011
  dialCode: {
1987
2012
  fontSize: fontSize.md,
1988
2013
  fontWeight: fontWeight.medium,
@@ -2081,7 +2106,7 @@ function PhoneInput({
2081
2106
  onChangeText?.(sanitizePhoneDigits(value));
2082
2107
  }
2083
2108
  const helperMessage = error ?? hint;
2084
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: wrapperRef, style: [styles6.wrapper, containerStyle], children: [
2109
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: wrapperRef, style: [styles7.wrapper, containerStyle], children: [
2085
2110
  label ? /* @__PURE__ */ jsxRuntime.jsx(
2086
2111
  Label,
2087
2112
  {
@@ -2091,24 +2116,24 @@ function PhoneInput({
2091
2116
  children: label
2092
2117
  }
2093
2118
  ) : null,
2094
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.row, children: [
2119
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles7.row, children: [
2095
2120
  /* @__PURE__ */ jsxRuntime.jsx(
2096
2121
  CountryCodeSelector,
2097
2122
  {
2098
2123
  value: countryCode,
2099
2124
  onValueChange: onCountryCodeChange,
2100
2125
  disabled: isDisabled,
2101
- style: styles6.countrySelector
2126
+ style: styles7.countrySelector
2102
2127
  }
2103
2128
  ),
2104
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [phoneFieldStyles.outline, styles6.phoneOutline], children: /* @__PURE__ */ jsxRuntime.jsx(
2129
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [phoneFieldStyles.outline, styles7.phoneOutline], children: /* @__PURE__ */ jsxRuntime.jsx(
2105
2130
  reactNative.View,
2106
2131
  {
2107
2132
  style: [
2108
2133
  inputFieldMetrics.containerBase,
2109
2134
  inputFieldMetrics.container,
2110
2135
  phoneFieldStyles.container,
2111
- styles6.phoneField
2136
+ styles7.phoneField
2112
2137
  ],
2113
2138
  children: /* @__PURE__ */ jsxRuntime.jsx(
2114
2139
  reactNative.TextInput,
@@ -2132,10 +2157,10 @@ function PhoneInput({
2132
2157
  }
2133
2158
  ) })
2134
2159
  ] }),
2135
- helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles6.error : styles6.hint, children: helperMessage }) : null
2160
+ helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles7.error : styles7.hint, children: helperMessage }) : null
2136
2161
  ] });
2137
2162
  }
2138
- var styles6 = reactNative.StyleSheet.create({
2163
+ var styles7 = reactNative.StyleSheet.create({
2139
2164
  wrapper: {
2140
2165
  width: "100%",
2141
2166
  gap: spacing.sm
@@ -3313,16 +3338,16 @@ function DatePicker(props) {
3313
3338
  reactNative.View,
3314
3339
  {
3315
3340
  ref: wrapperRef,
3316
- style: [styles7.wrapper, isFluidField && styles7.wrapperFluid, containerStyle],
3341
+ style: [styles8.wrapper, isFluidField && styles8.wrapperFluid, containerStyle],
3317
3342
  children: [
3318
- label ? /* @__PURE__ */ jsxRuntime.jsx(Label, { disabled, style: styles7.label, className: labelClassName, children: label }) : null,
3343
+ label ? /* @__PURE__ */ jsxRuntime.jsx(Label, { disabled, style: styles8.label, className: labelClassName, children: label }) : null,
3319
3344
  /* @__PURE__ */ jsxRuntime.jsx(
3320
3345
  reactNative.View,
3321
3346
  {
3322
3347
  style: [
3323
3348
  fieldStyles.outline,
3324
- styles7.fieldOutline,
3325
- isFluidField && styles7.fieldOutlineFluid,
3349
+ styles8.fieldOutline,
3350
+ isFluidField && styles8.fieldOutlineFluid,
3326
3351
  fieldOutlineStyle
3327
3352
  ],
3328
3353
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -3335,7 +3360,7 @@ function DatePicker(props) {
3335
3360
  onPress: openPicker,
3336
3361
  style: [
3337
3362
  calendarFieldMetrics.container,
3338
- isFluidField && styles7.fieldContainerFluid,
3363
+ isFluidField && styles8.fieldContainerFluid,
3339
3364
  fieldStyles.container,
3340
3365
  fieldStyle
3341
3366
  ],
@@ -3348,7 +3373,7 @@ function DatePicker(props) {
3348
3373
  children: displayValue
3349
3374
  }
3350
3375
  ),
3351
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles7.iconSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
3376
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles8.iconSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
3352
3377
  CalendarIcon,
3353
3378
  {
3354
3379
  size: CALENDAR_FIELD_ICON_SIZE,
@@ -3360,12 +3385,12 @@ function DatePicker(props) {
3360
3385
  )
3361
3386
  }
3362
3387
  ),
3363
- helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles7.error : styles7.hint, children: helperMessage }) : null,
3364
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closePicker, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles7.modalRoot, children: [
3388
+ helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles8.error : styles8.hint, children: helperMessage }) : null,
3389
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closePicker, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles8.modalRoot, children: [
3365
3390
  /* @__PURE__ */ jsxRuntime.jsx(
3366
3391
  reactNative.Pressable,
3367
3392
  {
3368
- style: styles7.backdrop,
3393
+ style: styles8.backdrop,
3369
3394
  onPress: closePicker,
3370
3395
  accessibilityRole: "button",
3371
3396
  accessibilityLabel: labels?.closeCalendar ?? translations.closeCalendar
@@ -3375,7 +3400,7 @@ function DatePicker(props) {
3375
3400
  reactNative.View,
3376
3401
  {
3377
3402
  style: [
3378
- styles7.panelPosition,
3403
+ styles8.panelPosition,
3379
3404
  {
3380
3405
  top: dropdownTop,
3381
3406
  left: panelLeft,
@@ -3423,7 +3448,7 @@ function DatePicker(props) {
3423
3448
  }
3424
3449
  );
3425
3450
  }
3426
- var styles7 = reactNative.StyleSheet.create({
3451
+ var styles8 = reactNative.StyleSheet.create({
3427
3452
  wrapper: {
3428
3453
  width: CALENDAR_FIELD_WIDTH,
3429
3454
  maxWidth: "100%",
@@ -3504,6 +3529,7 @@ exports.Calendar = Calendar;
3504
3529
  exports.CalendarIcon = CalendarIcon;
3505
3530
  exports.CalendarLocaleProvider = CalendarLocaleProvider;
3506
3531
  exports.CountryCodeSelector = CountryCodeSelector;
3532
+ exports.CountryFlag = CountryFlag;
3507
3533
  exports.DatePicker = DatePicker;
3508
3534
  exports.Input = Input;
3509
3535
  exports.Label = Label;
@@ -3515,6 +3541,7 @@ exports.buttonTypography = buttonTypography;
3515
3541
  exports.calendarTranslations = calendarTranslations;
3516
3542
  exports.colors = colors;
3517
3543
  exports.countries = countries;
3544
+ exports.countryCodeToFlagEmoji = countryCodeToFlagEmoji;
3518
3545
  exports.defaultCountry = defaultCountry;
3519
3546
  exports.emeraldGreen = emeraldGreen;
3520
3547
  exports.findCountry = findCountry;
@@ -3524,6 +3551,7 @@ exports.fonts = fonts;
3524
3551
  exports.formatLocalizedCalendarMonthYear = formatLocalizedCalendarMonthYear;
3525
3552
  exports.getCalendarMonthLabels = getCalendarMonthLabels;
3526
3553
  exports.getCalendarTranslations = getCalendarTranslations;
3554
+ exports.getCountryFlagImageUri = getCountryFlagImageUri;
3527
3555
  exports.labelTypography = labelTypography;
3528
3556
  exports.navy = navy;
3529
3557
  exports.radii = radii;