jfs-components 0.0.61 → 0.0.62

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.
@@ -13,7 +13,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
13
13
  */
14
14
  function cloneChildrenWithModes(children, modes, forcedModes) {
15
15
  const result = [];
16
- _react.default.Children.forEach(children, child => {
16
+
17
+ // toArray assigns stable keys to sibling lists and flattens top-level Fragments.
18
+ // Raw arrays from flattenChildren / concat have no keys; forEach alone does not add them.
19
+ _react.default.Children.forEach(_react.default.Children.toArray(children), child => {
17
20
  if (! /*#__PURE__*/_react.default.isValidElement(child)) {
18
21
  if (child !== null && child !== undefined) {
19
22
  result.push(child);
@@ -25,7 +28,7 @@ function cloneChildrenWithModes(children, modes, forcedModes) {
25
28
  // so recurse into their children and process each one individually.
26
29
  if (child.type === _react.default.Fragment) {
27
30
  const fragment = child;
28
- result.push(...cloneChildrenWithModes(fragment.props.children, modes, forcedModes));
31
+ result.push(...cloneChildrenWithModes(_react.default.Children.toArray(fragment.props.children ?? null), modes, forcedModes));
29
32
  return;
30
33
  }
31
34
  const childChildren = child.props?.children;
@@ -53,7 +56,10 @@ function cloneChildrenWithModes(children, modes, forcedModes) {
53
56
  modes: mergedModes
54
57
  }, processedChildren));
55
58
  });
56
- return result;
59
+
60
+ // Ensure the returned list always has keys for each entry (cloneElement can drop
61
+ // keys in some paths; Views that render this array require keyed siblings).
62
+ return _react.default.Children.toArray(result);
57
63
  }
58
64
 
59
65
  /**
@@ -79,8 +79,7 @@ function ListGroup({
79
79
  // propagate modes. Both props are interchangeable; when both are provided
80
80
  // the slot items render first, followed by children.
81
81
  const rawItems = [...(listGroupSlot ? flattenChildren(listGroupSlot) : []), ...(children ? flattenChildren(children) : [])];
82
- const keyedItems = React.Children.toArray(rawItems);
83
- const processedSlot = keyedItems.length > 0 ? cloneChildrenWithModes(keyedItems, modes) : null;
82
+ const processedSlot = rawItems.length > 0 ? cloneChildrenWithModes(rawItems, modes) : null;
84
83
 
85
84
  // Use provided accessibilityLabel or fall back to label
86
85
  const defaultAccessibilityLabel = accessibilityLabel || label || "List group";
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
- import React, { createContext, useContext, useMemo, useState, useEffect } from 'react';
3
+ import React, { createContext, useContext, useMemo } from 'react';
4
4
  import { getVariableByName } from './figma-variables-resolver';
5
- import * as Font from 'expo-font';
6
5
 
7
6
  /**
8
7
  * Shape of the TokenContext
@@ -53,36 +52,4 @@ export const useTokens = () => {
53
52
  };
54
53
  }
55
54
  return context;
56
- };
57
-
58
- /**
59
- * Returns the JFS font map. The TTF is encapsulated within the package at
60
- * src/assets/fonts/JioType Var.ttf (included via package.json "files").
61
- * Call this inside load functions to avoid top-level require errors if font missing.
62
- */
63
- export const getJFSFonts = () => ({
64
- 'JioType Var': require('../assets/fonts/JioType Var.ttf')
65
- });
66
-
67
- /**
68
- * Hook for loading JFS fonts using expo-font. This improves Android font support by explicitly registering
69
- * the custom 'JioType Var' font (encapsulated in the package) via Font.loadAsync before components render.
70
- * Without it, Android defaults to Roboto. Call at app root (e.g. before JFSThemeProvider). Returns loaded state.
71
- * See getJFSFonts() for direct use with Font.loadAsync. Handles missing font gracefully for web/Storybook.
72
- */
73
- export function useJFSFonts() {
74
- const [fontsLoaded, setFontsLoaded] = useState(false);
75
- useEffect(() => {
76
- async function loadJFSFonts() {
77
- try {
78
- await Font.loadAsync(getJFSFonts());
79
- setFontsLoaded(true);
80
- } catch (error) {
81
- console.warn('Failed to load JFS fonts (this is common in web/Storybook or if font file missing):', error);
82
- setFontsLoaded(true);
83
- }
84
- }
85
- loadJFSFonts();
86
- }, []);
87
- return fontsLoaded;
88
- }
55
+ };