jfs-components 0.0.2 → 0.0.3

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.
@@ -3,10 +3,12 @@ import { View, type StyleProp, type ViewStyle, type TextStyle } from 'react-nati
3
3
  type MoneyValueProps = {
4
4
  value?: string | number;
5
5
  currency?: string;
6
+ negative?: boolean;
6
7
  modes?: Record<string, any>;
7
8
  style?: StyleProp<ViewStyle>;
8
9
  valueStyle?: StyleProp<TextStyle>;
9
10
  currencyStyle?: StyleProp<TextStyle>;
11
+ negativeSignStyle?: StyleProp<TextStyle>;
10
12
  accessibilityLabel?: string;
11
13
  accessibilityHint?: string;
12
14
  } & React.ComponentProps<typeof View>;
@@ -20,18 +22,23 @@ type MoneyValueProps = {
20
22
  * (e.g. "INR", "USD"). When an ISO code is provided, it will be mapped to the
21
23
  * appropriate symbol, with special care to support INR and other major currencies.
22
24
  *
25
+ * Negative values are auto-detected from the value prop (e.g., -500 or "-500").
26
+ * The `negative` prop can be used to explicitly override this behavior.
27
+ *
23
28
  * @component
24
29
  * @param {Object} props
25
- * @param {string|number} [props.value="500"] - Monetary value to display.
30
+ * @param {string|number} [props.value="500"] - Monetary value to display. Negative values are auto-detected.
26
31
  * @param {string} [props.currency="₹"] - Currency symbol or ISO code (e.g. "INR").
32
+ * @param {boolean} [props.negative] - Explicitly override negative display. If undefined, auto-detects from value.
27
33
  * @param {Object} [props.modes={}] - Modes object passed directly to `getVariableByName`.
28
34
  * Example: {"MoneyValue / Theme": "Default"}
29
35
  * @param {Object} [props.style] - Optional container style overrides.
30
36
  * @param {Object} [props.valueStyle] - Optional value text style overrides.
31
37
  * @param {Object} [props.currencyStyle] - Optional currency text style overrides.
38
+ * @param {Object} [props.negativeSignStyle] - Optional negative sign text style overrides.
32
39
  * @param {string} [props.accessibilityLabel] - Accessibility label for screen readers. If not provided, generates from value and currency
33
40
  * @param {string} [props.accessibilityHint] - Additional accessibility hint for screen readers
34
41
  */
35
- declare function MoneyValue({ value, currency, modes, style, valueStyle, currencyStyle, accessibilityLabel, accessibilityHint, ...rest }: MoneyValueProps): import("react/jsx-runtime").JSX.Element;
42
+ declare function MoneyValue({ value, currency, negative, modes, style, valueStyle, currencyStyle, negativeSignStyle, accessibilityLabel, accessibilityHint, ...rest }: MoneyValueProps): import("react/jsx-runtime").JSX.Element;
36
43
  export default MoneyValue;
37
44
  //# sourceMappingURL=MoneyValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MoneyValue.d.ts","sourceRoot":"","sources":["../../../../src/components/MoneyValue/MoneyValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAsCzF,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,UAAU,CAAC,EAClB,KAAa,EACb,QAAc,EACd,KAAU,EACV,KAAK,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,eAAe,2CAoEjB;AAED,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"MoneyValue.d.ts","sourceRoot":"","sources":["../../../../src/components/MoneyValue/MoneyValue.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAQ,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAsCzF,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,UAAU,CAAC,EAClB,KAAa,EACb,QAAc,EACd,QAAQ,EACR,KAAU,EACV,KAAK,EACL,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,eAAe,2CA+FjB;AAED,eAAe,UAAU,CAAA"}
@@ -4,7 +4,7 @@
4
4
  * Auto-generated from SVG files in src/icons/
5
5
  * DO NOT EDIT MANUALLY - Run "npm run icons:generate" to regenerate
6
6
  *
7
- * Generated: 2026-01-17T17:17:24.583Z
7
+ * Generated: 2026-01-19T09:31:13.862Z
8
8
  */
9
9
  export declare const iconRegistry: Record<string, {
10
10
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jfs-components",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "React Native Jio Finance Components Library",
5
5
  "author": "sunshuaiqi@gmail.com",
6
6
  "license": "MIT",
@@ -40,10 +40,12 @@ const CURRENCY_SYMBOLS = {
40
40
  type MoneyValueProps = {
41
41
  value?: string | number;
42
42
  currency?: string;
43
+ negative?: boolean;
43
44
  modes?: Record<string, any>;
44
45
  style?: StyleProp<ViewStyle>;
45
46
  valueStyle?: StyleProp<TextStyle>;
46
47
  currencyStyle?: StyleProp<TextStyle>;
48
+ negativeSignStyle?: StyleProp<TextStyle>;
47
49
  accessibilityLabel?: string;
48
50
  accessibilityHint?: string;
49
51
  } & React.ComponentProps<typeof View>;
@@ -58,29 +60,54 @@ type MoneyValueProps = {
58
60
  * (e.g. "INR", "USD"). When an ISO code is provided, it will be mapped to the
59
61
  * appropriate symbol, with special care to support INR and other major currencies.
60
62
  *
63
+ * Negative values are auto-detected from the value prop (e.g., -500 or "-500").
64
+ * The `negative` prop can be used to explicitly override this behavior.
65
+ *
61
66
  * @component
62
67
  * @param {Object} props
63
- * @param {string|number} [props.value="500"] - Monetary value to display.
68
+ * @param {string|number} [props.value="500"] - Monetary value to display. Negative values are auto-detected.
64
69
  * @param {string} [props.currency="₹"] - Currency symbol or ISO code (e.g. "INR").
70
+ * @param {boolean} [props.negative] - Explicitly override negative display. If undefined, auto-detects from value.
65
71
  * @param {Object} [props.modes={}] - Modes object passed directly to `getVariableByName`.
66
72
  * Example: {"MoneyValue / Theme": "Default"}
67
73
  * @param {Object} [props.style] - Optional container style overrides.
68
74
  * @param {Object} [props.valueStyle] - Optional value text style overrides.
69
75
  * @param {Object} [props.currencyStyle] - Optional currency text style overrides.
76
+ * @param {Object} [props.negativeSignStyle] - Optional negative sign text style overrides.
70
77
  * @param {string} [props.accessibilityLabel] - Accessibility label for screen readers. If not provided, generates from value and currency
71
78
  * @param {string} [props.accessibilityHint] - Additional accessibility hint for screen readers
72
79
  */
73
80
  function MoneyValue({
74
81
  value = '500',
75
82
  currency = '₹',
83
+ negative,
76
84
  modes = {},
77
85
  style,
78
86
  valueStyle,
79
87
  currencyStyle,
88
+ negativeSignStyle,
80
89
  accessibilityLabel,
81
90
  accessibilityHint,
82
91
  ...rest
83
92
  }: MoneyValueProps) {
93
+ // Auto-detect negative from value and compute display value
94
+ const { isNegative, displayValue } = React.useMemo(() => {
95
+ const stringValue = String(value)
96
+ const trimmed = stringValue.trim()
97
+ const valueIsNegative = trimmed.startsWith('-') || (typeof value === 'number' && value < 0)
98
+
99
+ // Strip leading minus sign for display (we show it separately)
100
+ const absoluteValue = trimmed.startsWith('-') ? trimmed.slice(1) : trimmed
101
+
102
+ // Use explicit negative prop if provided, otherwise use auto-detected
103
+ const showNegative = negative !== undefined ? negative : valueIsNegative
104
+
105
+ return {
106
+ isNegative: showNegative,
107
+ displayValue: absoluteValue,
108
+ }
109
+ }, [value, negative])
110
+
84
111
  // Resolve typography and layout tokens from Figma
85
112
  const textColor =
86
113
  getVariableByName('moneyValue/text/color', modes) || '#0f0d0a'
@@ -122,7 +149,7 @@ function MoneyValue({
122
149
 
123
150
  // Generate default accessibility label from value and currency
124
151
  const defaultAccessibilityLabel = accessibilityLabel ||
125
- `${resolvedCurrency} ${value}`
152
+ `${isNegative ? 'negative ' : ''}${resolvedCurrency} ${displayValue}`
126
153
 
127
154
  return (
128
155
  <View
@@ -132,6 +159,15 @@ function MoneyValue({
132
159
  accessibilityHint={accessibilityHint}
133
160
  {...rest}
134
161
  >
162
+ {isNegative && (
163
+ <Text
164
+ style={[baseTextStyle, negativeSignStyle]}
165
+ accessibilityElementsHidden={true}
166
+ importantForAccessibility="no"
167
+ >
168
+ -
169
+ </Text>
170
+ )}
135
171
  <Text
136
172
  style={[baseTextStyle, currencyStyle]}
137
173
  accessibilityElementsHidden={true}
@@ -144,7 +180,7 @@ function MoneyValue({
144
180
  accessibilityElementsHidden={true}
145
181
  importantForAccessibility="no"
146
182
  >
147
- {value}
183
+ {displayValue}
148
184
  </Text>
149
185
  </View>
150
186
  )
@@ -4,7 +4,7 @@
4
4
  * Auto-generated from SVG files in src/icons/
5
5
  * DO NOT EDIT MANUALLY - Run "npm run icons:generate" to regenerate
6
6
  *
7
- * Generated: 2026-01-17T17:17:24.583Z
7
+ * Generated: 2026-01-19T09:31:13.862Z
8
8
  */
9
9
 
10
10
  // Icon name to SVG data mapping