@molecule/app-amount-input-react 1.0.0 → 1.0.2

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 (2) hide show
  1. package/README.md +158 -0
  2. package/package.json +17 -10
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-04T01:49:59.720Z
7
+ -->
8
+
9
+ # @molecule/app-amount-input-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ React amount input with type toggle.
16
+
17
+ Exports:
18
+
19
+ - `<AmountInput>` — large currency input with income/expense toggle.
20
+ - `AmountType` — `'income' | 'expense' | 'transfer' | 'other'`.
21
+ - `formatCurrency` — convenience re-export.
22
+
23
+ ## Quick Start
24
+
25
+ ```tsx
26
+ import { AmountInput } from '@molecule/app-amount-input-react'
27
+
28
+ const [amount, setAmount] = useState<number | ''>(0)
29
+ const [type, setType] = useState<'income' | 'expense'>('expense')
30
+
31
+ <AmountInput
32
+ amount={amount}
33
+ onAmountChange={setAmount}
34
+ type={type}
35
+ onTypeChange={(t) => setType(t as 'income' | 'expense')}
36
+ currencySymbol="$"
37
+ size="lg"
38
+ />
39
+ ```
40
+
41
+ ## Type
42
+
43
+ `feature`
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ npm install @molecule/app-amount-input-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
49
+ npm install -D @types/react
50
+ ```
51
+
52
+ ## API
53
+
54
+ ### Interfaces
55
+
56
+ #### `AmountInputProps`
57
+
58
+ Props for {@link AmountInput}.
59
+
60
+ ```typescript
61
+ interface AmountInputProps {
62
+ /** Current numeric amount (major units). */
63
+ amount: number | ''
64
+ /** Called whenever the amount text changes. */
65
+ onAmountChange: (amount: number | '') => void
66
+ /** Optional type (income/expense/transfer) toggle. */
67
+ type?: AmountType
68
+ /** Called when the user changes the type. When omitted, the toggle is hidden. */
69
+ onTypeChange?: (type: AmountType) => void
70
+ /** Type options to show in the toggle. Defaults to `['income', 'expense']`. */
71
+ typeOptions?: AmountType[]
72
+ /**
73
+ * Optional per-type label overrides. A value provided for a type wins over
74
+ * the translated / `defaultValue` label (prop > `t()` > default), letting a
75
+ * consumer relabel the toggle without wiring a locale bond.
76
+ */
77
+ typeLabels?: Partial<Record<AmountType, string>>
78
+ /** Currency symbol or label rendered to the left of the input. Defaults to `'$'`. */
79
+ currencySymbol?: string
80
+ /**
81
+ * Accessible label for the numeric input. Overrides the translated /
82
+ * `defaultValue` `'Amount'` (prop > `t()` > default).
83
+ */
84
+ ariaLabel?: string
85
+ /** Input size. */
86
+ size?: 'md' | 'lg' | 'xl'
87
+ /** Extra classes. */
88
+ className?: string
89
+ }
90
+ ```
91
+
92
+ ### Types
93
+
94
+ #### `AmountType`
95
+
96
+ Transaction type used to categorise an amount entry.
97
+
98
+ ```typescript
99
+ type AmountType = 'income' | 'expense' | 'transfer' | 'other'
100
+ ```
101
+
102
+ ### Functions
103
+
104
+ #### `AmountInput(props)`
105
+
106
+ Large transaction-style amount input with optional type toggle +
107
+ currency symbol. Common in budgeting, expense-reporting, and
108
+ financial-form UX.
109
+
110
+ ```typescript
111
+ function AmountInput({
112
+ amount,
113
+ onAmountChange,
114
+ type,
115
+ onTypeChange,
116
+ typeOptions = ['income', 'expense'],
117
+ typeLabels,
118
+ currencySymbol = '$',
119
+ ariaLabel,
120
+ size = 'lg',
121
+ className,
122
+ }: AmountInputProps): ReactElement<unknown, string | JSXElementConstructor<any>>
123
+ ```
124
+
125
+ - `props` — Component props (see {@link AmountInputProps}).
126
+
127
+ #### `formatCurrency(amount, currency, locale)`
128
+
129
+ Formats a numeric amount as a localized currency string.
130
+
131
+ ```typescript
132
+ function formatCurrency(amount: number, currency?: string, locale?: string): string
133
+ ```
134
+
135
+ ## Injection Notes
136
+
137
+ ### Requirements
138
+
139
+ Peer dependencies:
140
+
141
+ - `@molecule/app-react` ^1.0.1
142
+ - `@molecule/app-ui` ^1.0.1
143
+ - `@molecule/app-ui-react` ^1.0.1
144
+ - `react` ^18.0.0 || ^19.0.0
145
+
146
+ ### Runtime Dependencies
147
+
148
+ - `@molecule/app-react`
149
+ - `@molecule/app-ui`
150
+ - `@molecule/app-ui-react`
151
+ - `react`
152
+
153
+ All user-facing text flows through `t()` with English `defaultValue`
154
+ fallbacks under the `amountInput.*` keys, so a wired locale bond (or the
155
+ host app's own locale) can translate the type-toggle labels and the input's
156
+ accessible name. Both are also overridable per-instance without a bond: the
157
+ `typeLabels` prop relabels the toggle and `ariaLabel` sets the input's
158
+ accessible name (prop > `t()` > default).
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@molecule/app-amount-input-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Large amount input with income/expense toggle + currency symbol",
5
+ "homepage": "https://www.molecule.dev/packages/app-amount-input-react",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
7
8
  "types": "dist/index.d.ts",
@@ -17,7 +18,8 @@
17
18
  }
18
19
  },
19
20
  "files": [
20
- "dist"
21
+ "dist",
22
+ "README.md"
21
23
  ],
22
24
  "keywords": [
23
25
  "molecule",
@@ -25,23 +27,28 @@
25
27
  "react"
26
28
  ],
27
29
  "license": "Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/molecule-dev/molecule.git",
33
+ "directory": "packages/app/features/amount-input-react"
34
+ },
28
35
  "peerDependencies": {
29
- "@molecule/app-react": "^1.0.0",
30
- "@molecule/app-ui": "^1.0.0",
31
- "@molecule/app-ui-react": "^1.0.0",
36
+ "@molecule/app-react": "^1.0.1",
37
+ "@molecule/app-ui": "^1.0.1",
38
+ "@molecule/app-ui-react": "^1.0.1",
32
39
  "react": "^18.0.0 || ^19.0.0"
33
40
  },
34
41
  "devDependencies": {
35
- "@molecule/app-i18n": "1.0.0",
36
- "@molecule/app-react": "1.0.0",
37
- "@molecule/app-ui": "1.0.0",
38
- "@molecule/app-ui-react": "1.0.0",
42
+ "@molecule/app-i18n": "1.0.2",
43
+ "@molecule/app-react": "1.5.1",
44
+ "@molecule/app-ui": "1.1.1",
45
+ "@molecule/app-ui-react": "1.0.2",
39
46
  "@types/node": "26.1.2",
40
47
  "@types/react": "19.2.17",
41
48
  "@types/react-dom": "19.2.3",
42
49
  "react": "19.2.8",
43
50
  "react-dom": "19.2.8",
44
51
  "typescript": "6.0.3",
45
- "vitest": "4.1.10"
52
+ "vitest": "4.1.11"
46
53
  }
47
54
  }