jfs-components 0.0.54 → 0.0.56

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.
Files changed (55) hide show
  1. package/lib/commonjs/components/Accordion/Accordion.js +2 -34
  2. package/lib/commonjs/components/AppBar/AppBar.js +4 -36
  3. package/lib/commonjs/components/Drawer/Drawer.js +11 -4
  4. package/lib/commonjs/components/FilterBar/FilterBar.js +2 -34
  5. package/lib/commonjs/components/LazyList/LazyList.js +2 -34
  6. package/lib/commonjs/components/ListGroup/ListGroup.js +15 -9
  7. package/lib/commonjs/components/MoneyValue/MoneyValue.js +1 -1
  8. package/lib/commonjs/components/NavArrow/NavArrow.js +45 -44
  9. package/lib/commonjs/components/Numpad/Numpad.js +6 -5
  10. package/lib/commonjs/components/Section/Section.js +7 -8
  11. package/lib/commonjs/components/TextInput/TextInput.js +4 -38
  12. package/lib/commonjs/components/TransactionBubble/TransactionBubble.js +145 -0
  13. package/lib/commonjs/components/index.js +7 -0
  14. package/lib/commonjs/design-tokens/JFSThemeProvider.js +38 -3
  15. package/lib/commonjs/icons/registry.js +1 -1
  16. package/lib/commonjs/utils/react-utils.js +18 -13
  17. package/lib/module/components/Accordion/Accordion.js +1 -33
  18. package/lib/module/components/AppBar/AppBar.js +1 -34
  19. package/lib/module/components/Drawer/Drawer.js +11 -4
  20. package/lib/module/components/FilterBar/FilterBar.js +1 -35
  21. package/lib/module/components/LazyList/LazyList.js +1 -35
  22. package/lib/module/components/ListGroup/ListGroup.js +15 -9
  23. package/lib/module/components/MoneyValue/MoneyValue.js +1 -1
  24. package/lib/module/components/NavArrow/NavArrow.js +44 -44
  25. package/lib/module/components/Numpad/Numpad.js +5 -5
  26. package/lib/module/components/Section/Section.js +8 -9
  27. package/lib/module/components/TextInput/TextInput.js +2 -36
  28. package/lib/module/components/TransactionBubble/TransactionBubble.js +140 -0
  29. package/lib/module/components/index.js +1 -0
  30. package/lib/module/design-tokens/JFSThemeProvider.js +35 -3
  31. package/lib/module/icons/registry.js +1 -1
  32. package/lib/module/utils/react-utils.js +18 -13
  33. package/lib/typescript/src/components/ListGroup/ListGroup.d.ts +12 -7
  34. package/lib/typescript/src/components/NavArrow/NavArrow.d.ts +6 -11
  35. package/lib/typescript/src/components/TransactionBubble/TransactionBubble.d.ts +36 -0
  36. package/lib/typescript/src/components/index.d.ts +1 -0
  37. package/lib/typescript/src/design-tokens/JFSThemeProvider.d.ts +15 -0
  38. package/lib/typescript/src/icons/registry.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/src/components/Accordion/Accordion.tsx +1 -44
  41. package/src/components/AppBar/AppBar.tsx +1 -44
  42. package/src/components/Drawer/Drawer.tsx +12 -4
  43. package/src/components/FilterBar/FilterBar.tsx +1 -44
  44. package/src/components/LazyList/LazyList.tsx +1 -41
  45. package/src/components/ListGroup/ListGroup.tsx +21 -11
  46. package/src/components/MoneyValue/MoneyValue.tsx +1 -1
  47. package/src/components/NavArrow/NavArrow.tsx +46 -43
  48. package/src/components/Numpad/Numpad.tsx +5 -5
  49. package/src/components/Section/Section.tsx +8 -8
  50. package/src/components/TextInput/TextInput.tsx +1 -44
  51. package/src/components/TransactionBubble/TransactionBubble.tsx +152 -0
  52. package/src/components/index.ts +1 -0
  53. package/src/design-tokens/JFSThemeProvider.tsx +37 -2
  54. package/src/icons/registry.ts +1 -1
  55. package/src/utils/react-utils.ts +29 -21
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { View, Text, Pressable } from 'react-native';
5
+ import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
+ import MoneyValue from '../MoneyValue/MoneyValue';
7
+ import TransactionStatus from '../TransactionStatus/TransactionStatus';
8
+ import NavArrow from '../NavArrow/NavArrow';
9
+ import { cloneChildrenWithModes } from '../../utils/react-utils';
10
+ import { usePressableWebSupport } from '../../utils/web-platform-utils';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ /**
13
+ * TransactionBubble — Figma node 1517:1155.
14
+ *
15
+ * Layout (single horizontal row inside a rounded bordered pill):
16
+ *
17
+ * ┌──────────────────────────────────────────────┐
18
+ * │ Description Status · Date │
19
+ * │ ₹56 › │
20
+ * └──────────────────────────────────────────────┘
21
+ *
22
+ * Left column: description text + MoneyValue, stacked vertically with `transactionBubble/gap`.
23
+ * Right column: TransactionStatus + NavArrow, stacked vertically with `transactionBubble/statusWrap/gap`,
24
+ * right-aligned.
25
+ */
26
+ function TransactionBubble({
27
+ description = 'Payment to Uber India',
28
+ value = '56',
29
+ currency = '₹',
30
+ status = 'Expired',
31
+ date = '20 Mar 2025',
32
+ statusSlot,
33
+ children,
34
+ modes = {},
35
+ onPress,
36
+ style,
37
+ accessibilityLabel,
38
+ accessibilityHint,
39
+ webAccessibilityProps,
40
+ ...rest
41
+ }) {
42
+ const resolvedModes = {
43
+ ...modes,
44
+ 'Context3': 'Transaction Bubble'
45
+ };
46
+ const padding = Number(getVariableByName('transactionBubble/padding', resolvedModes)) || 16;
47
+ const radius = Number(getVariableByName('transactionBubble/radius', resolvedModes)) || 23;
48
+ const borderSize = Number(getVariableByName('transactionBubble/border/size', resolvedModes)) || 1;
49
+ const backgroundColor = getVariableByName('transactionBubble/background', resolvedModes) || '#ffffff';
50
+ const borderColor = getVariableByName('transactionBubble/border/color', resolvedModes) || '#e5e5e5';
51
+ const bubbleGap = Number(getVariableByName('transactionBubble/gap', resolvedModes)) || 8;
52
+ const wrapGap = Number(getVariableByName('transactionBubble/wrap/gap', resolvedModes)) || 8;
53
+ const descriptionColor = getVariableByName('transactionBubble/description/color', resolvedModes) || '#24262b';
54
+ const descriptionFontSize = Number(getVariableByName('transactionBubble/description/fontSize', resolvedModes)) || 14;
55
+ const descriptionLineHeight = Number(getVariableByName('transactionBubble/description/lineHeight', resolvedModes)) || 17;
56
+ const descriptionFontFamily = getVariableByName('transactionBubble/description/fontFamily', resolvedModes) || 'JioType Var';
57
+ const statusWrapGap = Number(getVariableByName('transactionBubble/statusWrap/gap', resolvedModes)) || 4;
58
+ const containerStyle = {
59
+ padding,
60
+ borderRadius: radius,
61
+ borderWidth: borderSize,
62
+ borderColor,
63
+ backgroundColor
64
+ };
65
+ const descriptionStyle = {
66
+ color: descriptionColor,
67
+ fontSize: descriptionFontSize,
68
+ lineHeight: descriptionLineHeight,
69
+ fontFamily: descriptionFontFamily
70
+ };
71
+ const processedChildren = children ? cloneChildrenWithModes(React.Children.toArray(children), resolvedModes) : null;
72
+ const processedStatusSlot = statusSlot ? cloneChildrenWithModes(React.Children.toArray(statusSlot), resolvedModes) : null;
73
+ const defaultAccessibilityLabel = accessibilityLabel || `${description} • ${status}`;
74
+ const webProps = usePressableWebSupport({
75
+ restProps: rest,
76
+ onPress,
77
+ disabled: false,
78
+ accessibilityLabel: defaultAccessibilityLabel,
79
+ webAccessibilityProps
80
+ });
81
+ const rightColumn = processedStatusSlot || /*#__PURE__*/_jsxs(View, {
82
+ style: {
83
+ alignItems: 'flex-end',
84
+ justifyContent: 'flex-end',
85
+ gap: statusWrapGap
86
+ },
87
+ children: [/*#__PURE__*/_jsx(TransactionStatus, {
88
+ status: status,
89
+ date: date,
90
+ modes: resolvedModes
91
+ }), /*#__PURE__*/_jsx(NavArrow, {
92
+ direction: "Forward",
93
+ modes: resolvedModes
94
+ })]
95
+ });
96
+ const mainContent = /*#__PURE__*/_jsxs(View, {
97
+ style: {
98
+ flexDirection: 'row',
99
+ gap: wrapGap
100
+ },
101
+ children: [/*#__PURE__*/_jsxs(View, {
102
+ style: {
103
+ flex: 1,
104
+ gap: bubbleGap
105
+ },
106
+ children: [/*#__PURE__*/_jsx(Text, {
107
+ style: descriptionStyle,
108
+ numberOfLines: 1,
109
+ children: description
110
+ }), /*#__PURE__*/_jsx(MoneyValue, {
111
+ value: value,
112
+ currency: currency,
113
+ modes: resolvedModes
114
+ })]
115
+ }), rightColumn]
116
+ });
117
+ if (onPress) {
118
+ return /*#__PURE__*/_jsxs(Pressable, {
119
+ onPress: onPress,
120
+ style: ({
121
+ pressed
122
+ }) => [containerStyle, style, pressed && {
123
+ opacity: 0.85
124
+ }],
125
+ accessibilityRole: "button",
126
+ accessibilityLabel: defaultAccessibilityLabel,
127
+ accessibilityHint: accessibilityHint,
128
+ ...webProps,
129
+ ...rest,
130
+ children: [mainContent, processedChildren]
131
+ });
132
+ }
133
+ return /*#__PURE__*/_jsxs(View, {
134
+ style: [containerStyle, style],
135
+ accessibilityLabel: defaultAccessibilityLabel,
136
+ accessibilityHint: accessibilityHint,
137
+ children: [mainContent, processedChildren]
138
+ });
139
+ }
140
+ export default TransactionBubble;
@@ -48,6 +48,7 @@ export { default as ThreadHero } from './ThreadHero/ThreadHero';
48
48
  export { Tooltip } from './Tooltip/Tooltip';
49
49
  export { default as TransactionDetails } from './TransactionDetails/TransactionDetails';
50
50
  export { default as TransactionStatus } from './TransactionStatus/TransactionStatus';
51
+ export { default as TransactionBubble } from './TransactionBubble/TransactionBubble';
51
52
  export { default as UpiHandle } from './UpiHandle/UpiHandle';
52
53
  export { default as VStack } from './VStack/VStack';
53
54
  export { default as ChipGroup } from './ChipGroup/ChipGroup';
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
- import React, { createContext, useContext, useMemo } from 'react';
3
+ import React, { createContext, useContext, useMemo, useState, useEffect } from 'react';
4
4
  import { getVariableByName } from './figma-variables-resolver';
5
+ import * as Font from 'expo-font';
5
6
 
6
7
  /**
7
8
  * Shape of the TokenContext
@@ -22,7 +23,6 @@ export const JFSThemeProvider = ({
22
23
  children
23
24
  }) => {
24
25
  const value = useMemo(() => {
25
- // We bind the current modes to getVariableByName so consumers don't have to pass it
26
26
  const getVariable = name => getVariableByName(name, modes);
27
27
  return {
28
28
  modes,
@@ -53,4 +53,36 @@ export const useTokens = () => {
53
53
  };
54
54
  }
55
55
  return context;
56
- };
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
+ }