jfs-components 0.0.60 → 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.
- package/lib/commonjs/design-tokens/JFSThemeProvider.js +2 -38
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/react-utils.js +9 -3
- package/lib/module/design-tokens/JFSThemeProvider.js +2 -35
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/react-utils.js +9 -3
- package/lib/typescript/src/design-tokens/JFSThemeProvider.d.ts +0 -15
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/design-tokens/JFSThemeProvider.tsx +1 -37
- package/src/icons/registry.ts +1 -1
- package/src/utils/react-utils.ts +13 -3
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { createContext, useContext, useMemo
|
|
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
|
+
};
|