@hoddy-ui/core 1.0.89 → 1.0.90

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.
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode, FC } from 'react';
2
- import { ViewStyle, TextStyle, NativeSyntheticEvent, NativeScrollEvent, TextInputProps } from 'react-native';
2
+ import { ViewStyle, TextStyle, NativeSyntheticEvent, NativeScrollEvent, TextInputProps, TextProps } from 'react-native';
3
3
 
4
4
  type ThemeTypes = "dark" | "light";
5
5
  type ThemeModes = "dark" | "light" | "default";
@@ -193,7 +193,7 @@ interface TextFieldProps extends TextInputProps {
193
193
  onFocus?: () => void;
194
194
  onBlur?: () => void;
195
195
  }
196
- interface TypographyProps {
196
+ interface TypographyProps extends TextProps {
197
197
  children: ReactNode;
198
198
  color?: colorTypes | (string & {});
199
199
  style?: TextStyle | ViewStyle;
@@ -203,6 +203,7 @@ interface TypographyProps {
203
203
  gutterBottom?: number;
204
204
  numberOfLines?: number;
205
205
  adjustsFontSizeToFit?: boolean;
206
+ fontFamily?: string;
206
207
  fontWeight?: 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
207
208
  }
208
209
  interface SafeAreaViewProps {
@@ -255,6 +256,7 @@ interface DividerProps {
255
256
  type configProps = {
256
257
  googleMapApiKey?: string;
257
258
  colors?: extraColorTypes;
259
+ fontFamily?: string;
258
260
  };
259
261
  declare function initialize(config: configProps): void;
260
262
 
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode, FC } from 'react';
2
- import { ViewStyle, TextStyle, NativeSyntheticEvent, NativeScrollEvent, TextInputProps } from 'react-native';
2
+ import { ViewStyle, TextStyle, NativeSyntheticEvent, NativeScrollEvent, TextInputProps, TextProps } from 'react-native';
3
3
 
4
4
  type ThemeTypes = "dark" | "light";
5
5
  type ThemeModes = "dark" | "light" | "default";
@@ -193,7 +193,7 @@ interface TextFieldProps extends TextInputProps {
193
193
  onFocus?: () => void;
194
194
  onBlur?: () => void;
195
195
  }
196
- interface TypographyProps {
196
+ interface TypographyProps extends TextProps {
197
197
  children: ReactNode;
198
198
  color?: colorTypes | (string & {});
199
199
  style?: TextStyle | ViewStyle;
@@ -203,6 +203,7 @@ interface TypographyProps {
203
203
  gutterBottom?: number;
204
204
  numberOfLines?: number;
205
205
  adjustsFontSizeToFit?: boolean;
206
+ fontFamily?: string;
206
207
  fontWeight?: 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
207
208
  }
208
209
  interface SafeAreaViewProps {
@@ -255,6 +256,7 @@ interface DividerProps {
255
256
  type configProps = {
256
257
  googleMapApiKey?: string;
257
258
  colors?: extraColorTypes;
259
+ fontFamily?: string;
258
260
  };
259
261
  declare function initialize(config: configProps): void;
260
262
 
@@ -206,24 +206,25 @@ function colors(theme) {
206
206
  }
207
207
 
208
208
  // ../src/config/KeyManager.ts
209
- var apiKey = {
209
+ var config = {
210
210
  GOOGLE_MAP_API_KEY: ""
211
211
  };
212
- function setApiKey(key) {
213
- apiKey = key;
212
+ function setConfig(key) {
213
+ config = key;
214
214
  }
215
- function getApiKey() {
216
- return apiKey;
215
+ function getConfig() {
216
+ return config;
217
217
  }
218
218
 
219
219
  // ../src/config/index.ts
220
- function initialize(config) {
220
+ function initialize(config2) {
221
221
  try {
222
- setApiKey({
223
- GOOGLE_MAP_API_KEY: config.googleMapApiKey
222
+ setConfig({
223
+ GOOGLE_MAP_API_KEY: config2.googleMapApiKey,
224
+ DEFAULT_FONT_FAMILY: config2.fontFamily
224
225
  });
225
- if (config.colors)
226
- setExtraColors(config.colors);
226
+ if (config2.colors)
227
+ setExtraColors(config2.colors);
227
228
  } catch (error) {
228
229
  console.error("Error reading the config file:", error);
229
230
  }
@@ -268,6 +269,8 @@ var Typography = (0, import_react.forwardRef)(
268
269
  numberOfLines,
269
270
  adjustsFontSizeToFit,
270
271
  fontWeight = 400,
272
+ fontFamily,
273
+ // NEW PROP ADDED
271
274
  ...props
272
275
  }, ref) => {
273
276
  const colors2 = useColors();
@@ -290,7 +293,9 @@ var Typography = (0, import_react.forwardRef)(
290
293
  textTransform: textCase,
291
294
  alignItems: "center",
292
295
  textAlign: align,
293
- fontWeight: fontWeight.toString()
296
+ fontWeight: fontWeight.toString(),
297
+ fontFamily: fontFamily || getConfig().DEFAULT_FONT_FAMILY || "System"
298
+ // Use custom font if provided, else default
294
299
  }
295
300
  });
296
301
  return /* @__PURE__ */ import_react.default.createElement(
@@ -299,7 +304,7 @@ var Typography = (0, import_react.forwardRef)(
299
304
  ref,
300
305
  numberOfLines,
301
306
  adjustsFontSizeToFit,
302
- style: { ...styles2.text, ...style },
307
+ style: [styles2.text, style],
303
308
  ...props
304
309
  },
305
310
  children
@@ -635,6 +640,7 @@ var LinkButton = ({
635
640
  text: {
636
641
  fontSize: (0, import_react_native_size_matters6.moderateScale)(fontSize),
637
642
  fontWeight,
643
+ fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
638
644
  color: disabled ? "#777" : colors2[color].main
639
645
  }
640
646
  });
@@ -741,7 +747,8 @@ var Button = (0, import_react8.forwardRef)(
741
747
  text: {
742
748
  color: disabled ? variant === "text" || variant === "outlined" ? colors2.black[1] : colors2[color].text : colors2[color][variant === "text" || variant === "outlined" ? "main" : "text"],
743
749
  fontWeight: variant === "outlined" ? "700" : "500",
744
- fontSize: size === "small" ? "12@ms" : "16@ms"
750
+ fontSize: size === "small" ? "12@ms" : "16@ms",
751
+ fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System"
745
752
  }
746
753
  });
747
754
  return /* @__PURE__ */ import_react8.default.createElement(
@@ -918,14 +925,21 @@ var Popup = ({
918
925
  }
919
926
  });
920
927
  import_react11.default.useEffect(() => {
921
- setShow(open);
922
- setTimeout(() => {
923
- setShowSecondary(open);
924
- }, 500);
928
+ if (open) {
929
+ setShow(open);
930
+ setTimeout(() => {
931
+ setShowSecondary(open);
932
+ }, 500);
933
+ } else {
934
+ closeAction();
935
+ }
925
936
  }, [open]);
926
937
  const closeAction = () => {
927
- setShow(false);
928
- onClose();
938
+ setShowSecondary(false);
939
+ setTimeout(() => {
940
+ setShow(false);
941
+ onClose();
942
+ }, 300);
929
943
  };
930
944
  return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, /* @__PURE__ */ import_react11.default.createElement(
931
945
  import_react_native11.Modal,
@@ -1350,8 +1364,10 @@ var TextField = ({
1350
1364
  }) => {
1351
1365
  const colors2 = useColors();
1352
1366
  const [focused, setFocused] = (0, import_react16.useState)(false);
1353
- const labelAnim = (0, import_react16.useRef)(new import_react_native16.Animated.Value(0)).current;
1354
1367
  const height = (0, import_react_native_size_matters14.moderateScale)(variant === "text" ? 50 : 45) * (size === "large" ? 1.2 : size === "small" ? 0.8 : 1);
1368
+ const labelAnim = (0, import_react16.useRef)(
1369
+ new import_react_native16.Animated.Value(height / (0, import_react_native_size_matters14.moderateScale)(variant === "text" ? 2.5 : 3.2))
1370
+ ).current;
1355
1371
  import_react16.default.useEffect(() => {
1356
1372
  if (focused || value) {
1357
1373
  import_react_native16.Animated.timing(labelAnim, {
@@ -1393,6 +1409,7 @@ var TextField = ({
1393
1409
  paddingLeft: variant === "text" ? 0 : (0, import_react_native_size_matters14.moderateScale)(15),
1394
1410
  paddingRight: (0, import_react_native_size_matters14.moderateScale)(10),
1395
1411
  paddingTop: "11@vs",
1412
+ fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
1396
1413
  color: colors2.black[1],
1397
1414
  zIndex: 10
1398
1415
  // backgroundColor: "#284",
@@ -1404,6 +1421,7 @@ var TextField = ({
1404
1421
  paddingTop: "13@ms"
1405
1422
  },
1406
1423
  label: {
1424
+ fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
1407
1425
  position: "absolute",
1408
1426
  left: variant === "text" ? 0 : (0, import_react_native_size_matters14.moderateScale)(15),
1409
1427
  fontSize: focused || value ? "10@s" : "13@s",
@@ -1494,15 +1512,33 @@ var TextField = ({
1494
1512
  style: styles2.input
1495
1513
  }
1496
1514
  ),
1497
- end && /* @__PURE__ */ import_react16.default.createElement(import_react_native16.View, { style: { marginRight: 20 } }, end),
1498
- options && /* @__PURE__ */ import_react16.default.createElement(import_react_native16.View, { style: { marginRight: 20 } }, /* @__PURE__ */ import_react16.default.createElement(
1499
- import_vector_icons8.Ionicons,
1515
+ end && /* @__PURE__ */ import_react16.default.createElement(
1516
+ import_react_native16.View,
1500
1517
  {
1501
- name: "chevron-down",
1502
- color: colors2.textSecondary.main,
1503
- size: 24
1504
- }
1505
- ))
1518
+ style: {
1519
+ marginRight: 20,
1520
+ paddingTop: variant === "text" ? (0, import_react_native_size_matters14.ms)(13) : 0
1521
+ }
1522
+ },
1523
+ end
1524
+ ),
1525
+ options && /* @__PURE__ */ import_react16.default.createElement(
1526
+ import_react_native16.View,
1527
+ {
1528
+ style: {
1529
+ marginRight: variant === "text" ? 0 : 20,
1530
+ paddingTop: variant === "text" ? (0, import_react_native_size_matters14.ms)(13) : 0
1531
+ }
1532
+ },
1533
+ /* @__PURE__ */ import_react16.default.createElement(
1534
+ import_vector_icons8.Ionicons,
1535
+ {
1536
+ name: "chevron-down",
1537
+ color: colors2.textSecondary.main,
1538
+ size: 24
1539
+ }
1540
+ )
1541
+ )
1506
1542
  ), helperText && /* @__PURE__ */ import_react16.default.createElement(
1507
1543
  Typography_default,
1508
1544
  {
@@ -1581,13 +1617,13 @@ var TextField2 = ({
1581
1617
  alignSelf: "stretch",
1582
1618
  paddingLeft: (0, import_react_native_size_matters14.moderateScale)(10),
1583
1619
  paddingRight: (0, import_react_native_size_matters14.moderateScale)(10),
1584
- color: colors2.dark.light,
1620
+ color: colors2.dark.main,
1585
1621
  zIndex: 10
1586
1622
  // backgroundColor: "#284",
1587
1623
  },
1588
1624
  inputText: {
1589
1625
  fontSize: "14@ms",
1590
- color: colors2.dark.light,
1626
+ color: colors2.dark.main,
1591
1627
  paddingLeft: (0, import_react_native_size_matters14.moderateScale)(10)
1592
1628
  },
1593
1629
  placeholder: {
@@ -1715,12 +1751,12 @@ var TextField_default = TextField;
1715
1751
  var Location = __toESM(require("expo-location"));
1716
1752
  var import_react_native_size_matters15 = require("react-native-size-matters");
1717
1753
  setTimeout(() => {
1718
- const { GOOGLE_MAP_API_KEY } = getApiKey();
1754
+ const { GOOGLE_MAP_API_KEY } = getConfig();
1719
1755
  if (GOOGLE_MAP_API_KEY)
1720
1756
  Location.setGoogleApiKey(GOOGLE_MAP_API_KEY);
1721
1757
  }, 500);
1722
1758
  var getPredictionsFromCoords = async (coords) => {
1723
- const { GOOGLE_MAP_API_KEY } = getApiKey();
1759
+ const { GOOGLE_MAP_API_KEY } = getConfig();
1724
1760
  if (!GOOGLE_MAP_API_KEY)
1725
1761
  console.error(
1726
1762
  "Google map api key needs to be set to use this component \nMake sure to run initialize() with a valid google map api key"
@@ -1755,7 +1791,7 @@ var Locator = ({
1755
1791
  float = true,
1756
1792
  country = "ng"
1757
1793
  }) => {
1758
- const { GOOGLE_MAP_API_KEY } = getApiKey();
1794
+ const { GOOGLE_MAP_API_KEY } = getConfig();
1759
1795
  const [changed, setChanged] = (0, import_react17.useState)(false);
1760
1796
  const [value, setValue] = (0, import_react17.useState)("");
1761
1797
  const [prediction, setPrediction] = (0, import_react17.useState)([]);
@@ -2005,6 +2041,36 @@ var OTPInput = ({
2005
2041
  () => Array(length).fill(0).map((_) => import_react20.default.createRef()),
2006
2042
  [length]
2007
2043
  );
2044
+ console.log("v", value);
2045
+ const onChangeHandler = (val, index) => {
2046
+ if (value.length >= length && val.length > 0)
2047
+ return;
2048
+ if (val.length > 1) {
2049
+ console.log("reached", val);
2050
+ const digits = val.replace(/\D/g, "").slice(0, length);
2051
+ onChange(digits);
2052
+ if (digits.length === length) {
2053
+ inputRefs[length - 1].current?.focus();
2054
+ }
2055
+ return;
2056
+ }
2057
+ if (val.length === 0) {
2058
+ const newValue2 = value.slice(0, index) + value.slice(index + 1);
2059
+ onChange(newValue2);
2060
+ if (index > 0) {
2061
+ inputRefs[index - 1].current?.focus();
2062
+ }
2063
+ return;
2064
+ }
2065
+ const digit = val.replace(/\D/g, "").slice(0, 1);
2066
+ if (!digit)
2067
+ return;
2068
+ const newValue = value.slice(0, index) + digit + value.slice(index + 1);
2069
+ onChange(newValue);
2070
+ if (index < length - 1) {
2071
+ inputRefs[index + 1].current?.focus();
2072
+ }
2073
+ };
2008
2074
  const colors2 = useColors();
2009
2075
  const styles2 = import_react_native_size_matters19.ScaledSheet.create({
2010
2076
  root: {},
@@ -2027,27 +2093,7 @@ var OTPInput = ({
2027
2093
  import_react_native22.TextInput,
2028
2094
  {
2029
2095
  ref: inputRefs[index],
2030
- onChangeText: (val) => {
2031
- if (val.length === 1) {
2032
- if (index !== length - 1)
2033
- inputRefs[index + 1].current?.focus();
2034
- let text = value;
2035
- text = text.slice(0, index) + val + text.slice(index + 1);
2036
- onChange(text);
2037
- } else if (val.length === 0) {
2038
- if (index !== 0) {
2039
- inputRefs[index - 1].current?.focus();
2040
- let text = value;
2041
- text = text.slice(0, index);
2042
- onChange(text);
2043
- } else
2044
- onChange("");
2045
- } else {
2046
- let text = val.replace(/\D/g, "").slice(0, length);
2047
- onChange(text);
2048
- inputRefs[text.length < length - 1 ? text.length : length - 1]?.current?.focus();
2049
- }
2050
- },
2096
+ onChangeText: (val) => onChangeHandler(val, index),
2051
2097
  value: value[index] || "",
2052
2098
  blurOnSubmit: false,
2053
2099
  keyboardType: "number-pad",