@scripso-homepad/ui 0.4.21 → 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
@@ -1413,7 +1413,8 @@ function Select({
1413
1413
  labelClassName,
1414
1414
  errorClassName,
1415
1415
  hintClassName,
1416
- compact = false
1416
+ compact = false,
1417
+ allowDeselect = true
1417
1418
  }) {
1418
1419
  const wrapperRef = react.useRef(null);
1419
1420
  const triggerRef = react.useRef(null);
@@ -1517,6 +1518,9 @@ function Select({
1517
1518
  return;
1518
1519
  }
1519
1520
  if (selectedValues.includes(nextValue)) {
1521
+ if (allowDeselect) {
1522
+ onValueChange?.("");
1523
+ }
1520
1524
  closeMenu();
1521
1525
  return;
1522
1526
  }
@@ -1812,6 +1816,35 @@ function countryCodeToFlagEmoji(code) {
1812
1816
  ...upper.split("").map((char) => 127462 - 65 + char.charCodeAt(0))
1813
1817
  );
1814
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
+ });
1815
1848
  var DROPDOWN_GAP = 10;
1816
1849
  var DROPDOWN_HEIGHT = 186;
1817
1850
  var DROPDOWN_PADDING = 8;
@@ -1877,13 +1910,13 @@ function CountryCodeSelector({
1877
1910
  accessibilityRole: "button",
1878
1911
  onPress: () => handleSelect(item.code),
1879
1912
  style: [
1880
- styles5.option,
1881
- isSelected && styles5.optionSelected,
1882
- !isLast && styles5.optionSpacing
1913
+ styles6.option,
1914
+ isSelected && styles6.optionSelected,
1915
+ !isLast && styles6.optionSpacing
1883
1916
  ],
1884
1917
  children: [
1885
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles5.flag, children: countryCodeToFlagEmoji(item.code) }),
1886
- /* @__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 })
1887
1920
  ]
1888
1921
  },
1889
1922
  item.code
@@ -1893,8 +1926,8 @@ function CountryCodeSelector({
1893
1926
  reactNative.ScrollView,
1894
1927
  {
1895
1928
  ref: scrollRef,
1896
- style: styles5.dropdownScroll,
1897
- contentContainerStyle: styles5.dropdownContent,
1929
+ style: styles6.dropdownScroll,
1930
+ contentContainerStyle: styles6.dropdownContent,
1898
1931
  keyboardShouldPersistTaps: "handled",
1899
1932
  showsVerticalScrollIndicator: true,
1900
1933
  bounces: false,
@@ -1902,7 +1935,7 @@ function CountryCodeSelector({
1902
1935
  children: optionList
1903
1936
  }
1904
1937
  );
1905
- 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: [
1906
1939
  /* @__PURE__ */ jsxRuntime.jsxs(
1907
1940
  reactNative.Pressable,
1908
1941
  {
@@ -1911,13 +1944,13 @@ function CountryCodeSelector({
1911
1944
  disabled,
1912
1945
  onPress: handleOpen,
1913
1946
  style: [
1914
- styles5.trigger,
1915
- disabled ? styles5.triggerDisabled : styles5.triggerEnabled,
1916
- reactNative.Platform.OS === "web" ? styles5.triggerWeb : null
1947
+ styles6.trigger,
1948
+ disabled ? styles6.triggerDisabled : styles6.triggerEnabled,
1949
+ reactNative.Platform.OS === "web" ? styles6.triggerWeb : null
1917
1950
  ],
1918
1951
  children: [
1919
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles5.flag, children: countryCodeToFlagEmoji(selected.code) }),
1920
- /* @__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 }),
1921
1954
  /* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, { size: CHEVRON_SIZE, color: colors.stormGray100 })
1922
1955
  ]
1923
1956
  }
@@ -1929,11 +1962,11 @@ function CountryCodeSelector({
1929
1962
  transparent: true,
1930
1963
  animationType: "fade",
1931
1964
  onRequestClose: closeDropdown,
1932
- 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(
1933
1966
  reactNative.View,
1934
1967
  {
1935
1968
  style: [
1936
- styles5.dropdown,
1969
+ styles6.dropdown,
1937
1970
  {
1938
1971
  top: dropdownTop,
1939
1972
  left: anchor.x,
@@ -1947,7 +1980,7 @@ function CountryCodeSelector({
1947
1980
  )
1948
1981
  ] });
1949
1982
  }
1950
- var styles5 = reactNative.StyleSheet.create({
1983
+ var styles6 = reactNative.StyleSheet.create({
1951
1984
  root: {
1952
1985
  alignSelf: "flex-start",
1953
1986
  flexShrink: 0
@@ -1975,10 +2008,6 @@ var styles5 = reactNative.StyleSheet.create({
1975
2008
  triggerWeb: {
1976
2009
  width: "max-content"
1977
2010
  },
1978
- flag: {
1979
- fontSize: 18,
1980
- lineHeight: 24
1981
- },
1982
2011
  dialCode: {
1983
2012
  fontSize: fontSize.md,
1984
2013
  fontWeight: fontWeight.medium,
@@ -2077,7 +2106,7 @@ function PhoneInput({
2077
2106
  onChangeText?.(sanitizePhoneDigits(value));
2078
2107
  }
2079
2108
  const helperMessage = error ?? hint;
2080
- 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: [
2081
2110
  label ? /* @__PURE__ */ jsxRuntime.jsx(
2082
2111
  Label,
2083
2112
  {
@@ -2087,24 +2116,24 @@ function PhoneInput({
2087
2116
  children: label
2088
2117
  }
2089
2118
  ) : null,
2090
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.row, children: [
2119
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles7.row, children: [
2091
2120
  /* @__PURE__ */ jsxRuntime.jsx(
2092
2121
  CountryCodeSelector,
2093
2122
  {
2094
2123
  value: countryCode,
2095
2124
  onValueChange: onCountryCodeChange,
2096
2125
  disabled: isDisabled,
2097
- style: styles6.countrySelector
2126
+ style: styles7.countrySelector
2098
2127
  }
2099
2128
  ),
2100
- /* @__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(
2101
2130
  reactNative.View,
2102
2131
  {
2103
2132
  style: [
2104
2133
  inputFieldMetrics.containerBase,
2105
2134
  inputFieldMetrics.container,
2106
2135
  phoneFieldStyles.container,
2107
- styles6.phoneField
2136
+ styles7.phoneField
2108
2137
  ],
2109
2138
  children: /* @__PURE__ */ jsxRuntime.jsx(
2110
2139
  reactNative.TextInput,
@@ -2128,10 +2157,10 @@ function PhoneInput({
2128
2157
  }
2129
2158
  ) })
2130
2159
  ] }),
2131
- 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
2132
2161
  ] });
2133
2162
  }
2134
- var styles6 = reactNative.StyleSheet.create({
2163
+ var styles7 = reactNative.StyleSheet.create({
2135
2164
  wrapper: {
2136
2165
  width: "100%",
2137
2166
  gap: spacing.sm
@@ -3309,16 +3338,16 @@ function DatePicker(props) {
3309
3338
  reactNative.View,
3310
3339
  {
3311
3340
  ref: wrapperRef,
3312
- style: [styles7.wrapper, isFluidField && styles7.wrapperFluid, containerStyle],
3341
+ style: [styles8.wrapper, isFluidField && styles8.wrapperFluid, containerStyle],
3313
3342
  children: [
3314
- 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,
3315
3344
  /* @__PURE__ */ jsxRuntime.jsx(
3316
3345
  reactNative.View,
3317
3346
  {
3318
3347
  style: [
3319
3348
  fieldStyles.outline,
3320
- styles7.fieldOutline,
3321
- isFluidField && styles7.fieldOutlineFluid,
3349
+ styles8.fieldOutline,
3350
+ isFluidField && styles8.fieldOutlineFluid,
3322
3351
  fieldOutlineStyle
3323
3352
  ],
3324
3353
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -3331,7 +3360,7 @@ function DatePicker(props) {
3331
3360
  onPress: openPicker,
3332
3361
  style: [
3333
3362
  calendarFieldMetrics.container,
3334
- isFluidField && styles7.fieldContainerFluid,
3363
+ isFluidField && styles8.fieldContainerFluid,
3335
3364
  fieldStyles.container,
3336
3365
  fieldStyle
3337
3366
  ],
@@ -3344,7 +3373,7 @@ function DatePicker(props) {
3344
3373
  children: displayValue
3345
3374
  }
3346
3375
  ),
3347
- /* @__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(
3348
3377
  CalendarIcon,
3349
3378
  {
3350
3379
  size: CALENDAR_FIELD_ICON_SIZE,
@@ -3356,12 +3385,12 @@ function DatePicker(props) {
3356
3385
  )
3357
3386
  }
3358
3387
  ),
3359
- helperMessage ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { ref: helperRef, style: error ? styles7.error : styles7.hint, children: helperMessage }) : null,
3360
- /* @__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: [
3361
3390
  /* @__PURE__ */ jsxRuntime.jsx(
3362
3391
  reactNative.Pressable,
3363
3392
  {
3364
- style: styles7.backdrop,
3393
+ style: styles8.backdrop,
3365
3394
  onPress: closePicker,
3366
3395
  accessibilityRole: "button",
3367
3396
  accessibilityLabel: labels?.closeCalendar ?? translations.closeCalendar
@@ -3371,7 +3400,7 @@ function DatePicker(props) {
3371
3400
  reactNative.View,
3372
3401
  {
3373
3402
  style: [
3374
- styles7.panelPosition,
3403
+ styles8.panelPosition,
3375
3404
  {
3376
3405
  top: dropdownTop,
3377
3406
  left: panelLeft,
@@ -3419,7 +3448,7 @@ function DatePicker(props) {
3419
3448
  }
3420
3449
  );
3421
3450
  }
3422
- var styles7 = reactNative.StyleSheet.create({
3451
+ var styles8 = reactNative.StyleSheet.create({
3423
3452
  wrapper: {
3424
3453
  width: CALENDAR_FIELD_WIDTH,
3425
3454
  maxWidth: "100%",
@@ -3500,6 +3529,7 @@ exports.Calendar = Calendar;
3500
3529
  exports.CalendarIcon = CalendarIcon;
3501
3530
  exports.CalendarLocaleProvider = CalendarLocaleProvider;
3502
3531
  exports.CountryCodeSelector = CountryCodeSelector;
3532
+ exports.CountryFlag = CountryFlag;
3503
3533
  exports.DatePicker = DatePicker;
3504
3534
  exports.Input = Input;
3505
3535
  exports.Label = Label;
@@ -3511,6 +3541,7 @@ exports.buttonTypography = buttonTypography;
3511
3541
  exports.calendarTranslations = calendarTranslations;
3512
3542
  exports.colors = colors;
3513
3543
  exports.countries = countries;
3544
+ exports.countryCodeToFlagEmoji = countryCodeToFlagEmoji;
3514
3545
  exports.defaultCountry = defaultCountry;
3515
3546
  exports.emeraldGreen = emeraldGreen;
3516
3547
  exports.findCountry = findCountry;
@@ -3520,6 +3551,7 @@ exports.fonts = fonts;
3520
3551
  exports.formatLocalizedCalendarMonthYear = formatLocalizedCalendarMonthYear;
3521
3552
  exports.getCalendarMonthLabels = getCalendarMonthLabels;
3522
3553
  exports.getCalendarTranslations = getCalendarTranslations;
3554
+ exports.getCountryFlagImageUri = getCountryFlagImageUri;
3523
3555
  exports.labelTypography = labelTypography;
3524
3556
  exports.navy = navy;
3525
3557
  exports.radii = radii;