fn-input 0.0.13 → 0.0.14

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/README.md CHANGED
@@ -1,165 +1,212 @@
1
- # FNInput
2
-
3
- `FNInput` is a comprehensive, standalone Angular component library that provides a unified input solution. It consolidates labels, icons, and validation messages into a single, highly configurable component.
4
-
5
- ---
6
-
7
- ## 🌟 Features
8
-
9
- - **Unified Solution**: Combines label, input, icons, and validation messages.
10
- - **Standalone**: No project-level modules required.
11
- - **Dynamic Icons**: Supports SVG icons with variant and size configurations via `@arpudhabotupload/fn-icon-angular`.
12
- - **Intelligent Validation**: Automatic error and helper message rendering based on `FormControl` status.
13
- - **Advanced Input Types**:
14
- - **Text & Textarea**:
15
- - **Alphanumeric Filtering**: Restrict input to alphanumeric characters with custom patterns (e.g., address lines).
16
- - **Auto-resize**: Textareas automatically adjust height based on content.
17
- - **Case Enforcement**: Optional lowercase enforcement for specific fields.
18
- - **Email**: Robust email handling with automatic case correction and character filtering.
19
- - **Number & Currency**:
20
- - **Locale-aware Formatting**: Support for multiple currencies and locales (USD, MYR, EUR, GBP, JPY, CNY, INR).
21
- - **Smart Input**: Prevents non-numeric characters and enforces decimal limits.
22
- - **Group Separators**: Automatic comma insertion for readability.
23
- - **Password**:
24
- - **Strength Indicators**: Built-in logic for weak, medium, and strong password validation.
25
- - **Masking Toggle**: Easy visibility switching.
26
- - **Visibility Logic**: Conditionally show/hide fields based on other form control values.
27
- - **Copy to Clipboard**: Built-in support for copy buttons with toast feedback.
28
-
29
- ---
30
-
31
- ## 📦 Installation
32
-
33
- Install the library and its peer dependencies:
34
-
35
- ```bash
36
- npm install fn-input fn-label @arpudhabotupload/fn-icon-angular @ngx-translate/core rxjs
37
- ```
38
-
39
- ---
40
-
41
- ## ⚙️ Configuration
42
-
43
- Ensure you provide `HttpClient`, `TranslateService`, and necessary icons in your application configuration.
44
-
45
- ```typescript
46
- import { provideHttpClient } from '@angular/common/http';
47
- import { TranslateModule } from '@ngx-translate/core';
48
-
49
- // ... in your bootstrap providers
50
- providers: [
51
- provideHttpClient(),
52
- importProvidersFrom(TranslateModule.forRoot({...}))
53
- ]
54
- ```
55
-
56
- ---
57
-
58
- ## 🚀 Usage
59
-
60
- ### Simple Text Input
61
-
62
- ```html
63
- <fn-input
64
- [field]="{
65
- name: 'username',
66
- label: 'User Name',
67
- type: 'text',
68
- isAlphanumeric: true
69
- }"
70
- [form]="myFormGroup"
71
- >
72
- </fn-input>
73
- ```
74
-
75
- ### Currency Input
76
-
77
- ```html
78
- <fn-input
79
- [field]="{
80
- name: 'amount',
81
- label: 'Amount',
82
- type: 'number',
83
- isCurrency: true,
84
- currency: 'MYR'
85
- }"
86
- [form]="myFormGroup"
87
- >
88
- </fn-input>
89
- ```
90
-
91
- ### Password with Strength Indicator
92
-
93
- ```html
94
- <fn-input
95
- [field]="{
96
- name: 'password',
97
- label: 'Password',
98
- type: 'password',
99
- feedback: true
100
- }"
101
- [form]="myFormGroup"
102
- >
103
- </fn-input>
104
- ```
105
-
106
- ---
107
-
108
- ## 📄 API Reference
109
-
110
- ### Input Properties (`field` object)
111
-
112
- The `field` input accepts a configuration object based on `FNInputBase`, which can be one of:
113
-
114
- - `FNTextInputProps` (for `text`, `email`, `textarea`, `hidden`)
115
- - `FNPasswordProps`
116
- - `FNInputNumberProps`
117
-
118
- #### Common Properties
119
-
120
- | Property | Type | Default | Description |
121
- | :---------------- | :------------- | :----------- | :----------------------------------------------------------- |
122
- | `name` | `string` | **Required** | Key in the `FormGroup`. |
123
- | `label` | `string` | **Required** | Display label. |
124
- | `type` | `string` | `text` | `text`, `email`, `textarea`, `number`, `password`. |
125
- | `placeholder` | `string` | `undefined` | Optional placeholder text. |
126
- | `required` | `boolean` | `false` | Shows asterisk on label. |
127
- | `disabled` | `boolean` | `false` | Disables the input control. |
128
- | `hidden` | `boolean` | `false` | Completely hides the component. |
129
- | `isAlphanumeric` | `boolean` | `true` | Enables alphanumeric filtering. |
130
- | `isAddressLine` | `boolean` | `false` | Allows additional characters `( ) / ,` in alphanumeric mode. |
131
- | `rows` | `number` | `1` | Default rows for `textarea`. |
132
- | `helperText` | `string` | `undefined` | Persistent helper message below input. |
133
- | `prefix`/`suffix` | `FNInputAffix` | `undefined` | Icon or text to show at start/end of input. |
134
-
135
- #### Number & Currency Properties (`type: 'number'`)
136
-
137
- | Property | Type | Default | Description |
138
- | :------------ | :-------- | :------ | :---------------------------------- |
139
- | `isCurrency` | `boolean` | `false` | Enables currency formatting. |
140
- | `currency` | `string` | `'USD'` | Currency code (e.g., 'MYR', 'EUR'). |
141
- | `maxDecimals` | `number` | `2` | Max decimal places allowed. |
142
- | `useGrouping` | `boolean` | `true` | Use comma separators. |
143
-
144
- ---
145
-
146
- ## 🛠️ Injection Tokens
147
-
148
- For global configuration, you can use the following injection tokens:
149
-
150
- | Token | Type | Description |
151
- | :----------------- | :------------- | :----------------------------------------------------- |
152
- | `FN_TOAST_SERVICE` | `FNInputToast` | Provide a global toast service for clipboard feedback. |
153
-
154
- ---
155
-
156
- ## 🎨 UI Customization
157
-
158
- The component uses CSS variables for theme integration:
159
-
160
- - `--fn-sys-color-on-surface-variant`: Default text/icon color.
161
- - `--fn-sys-color-error`: Validation error color.
162
- - `--fn-sys-color-success`: Success state color.
163
- - `--fn-sys-font-family-base`: Primary font family.
164
-
165
- Detailed styles can be overridden by targeting classes like `.fn-input-container` or `.fn-field-wrapper`.
1
+ # FNInput
2
+
3
+ `FNInput` is a comprehensive, standalone Angular component library that provides a unified input solution. It consolidates labels, icons, and validation messages into a single, highly configurable component.
4
+
5
+ ---
6
+
7
+ ## 🌟 Features
8
+
9
+ - **Unified Solution**: Combines label, input, icons, and validation messages.
10
+ - **Standalone**: No project-level modules required.
11
+ - **Dynamic Icons**: Supports SVG icons with variant and size configurations via `@arpudhabotupload/fn-icon-angular`.
12
+ - **Intelligent Validation**: Automatic error and helper message rendering based on `FormControl` status.
13
+ - **Advanced Input Types**:
14
+ - **Text & Textarea**:
15
+ - **Alphanumeric Filtering**: Restrict input to alphanumeric characters with custom patterns (e.g., address lines).
16
+ - **Auto-resize**: Textareas automatically adjust height based on content.
17
+ - **Case Enforcement**: Optional lowercase enforcement for specific fields.
18
+ - **Email**: Robust email handling with automatic case correction and character filtering.
19
+ - **Number & Currency**:
20
+ - **Locale-aware Formatting**: Support for multiple currencies and locales (USD, MYR, EUR, GBP, JPY, CNY, INR).
21
+ - **Smart Input**: Prevents non-numeric characters and enforces decimal limits.
22
+ - **Group Separators**: Automatic comma insertion for readability.
23
+ - **Password**:
24
+ - **Strength Indicators**: Built-in logic for weak, medium, and strong password validation.
25
+ - **Masking Toggle**: Easy visibility switching.
26
+ - **Visibility Logic**: Conditionally show/hide fields based on other form control values.
27
+ - **Copy to Clipboard**: Built-in support for copy buttons with toast feedback using `fn-toast`.
28
+ - **Float Label Variants**: Support for 'in', 'over', and 'on' label placements.
29
+ - **Customizable Aesthetics**: Extensive use of CSS variables for theming.
30
+
31
+ ---
32
+
33
+ ## 📦 Installation
34
+
35
+ Install the library and its peer dependencies:
36
+
37
+ ```bash
38
+ npm install fn-input fn-label fn-toast @arpudhabotupload/fn-icon-angular @ngx-translate/core rxjs
39
+ ```
40
+
41
+ ---
42
+
43
+ ## ⚙️ Configuration
44
+
45
+ Ensure you provide `HttpClient`, `TranslateService`, and necessary icons in your application configuration.
46
+
47
+ ```typescript
48
+ import { provideHttpClient } from '@angular/common/http';
49
+ import { TranslateModule } from '@ngx-translate/core';
50
+
51
+ // ... in your bootstrap providers
52
+ providers: [
53
+ provideHttpClient(),
54
+ importProvidersFrom(TranslateModule.forRoot({...}))
55
+ ]
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 🚀 Usage
61
+
62
+ ### Simple Text Input
63
+
64
+ ```html
65
+ <fn-input
66
+ [field]="{
67
+ name: 'username',
68
+ label: 'User Name',
69
+ type: 'text',
70
+ isAlphanumeric: true
71
+ }"
72
+ [form]="myFormGroup"
73
+ >
74
+ </fn-input>
75
+ ```
76
+
77
+ ### Currency Input with Custom Locale
78
+
79
+ ```html
80
+ <fn-input
81
+ [field]="{
82
+ name: 'amount',
83
+ label: 'Amount',
84
+ type: 'number',
85
+ isCurrency: true,
86
+ currency: 'INR',
87
+ locale: 'en-IN'
88
+ }"
89
+ [form]="myFormGroup"
90
+ >
91
+ </fn-input>
92
+ ```
93
+
94
+ ### Password with Strength Indicator
95
+
96
+ ```html
97
+ <fn-input
98
+ [field]="{
99
+ name: 'password',
100
+ label: 'Password',
101
+ type: 'password',
102
+ feedback: true,
103
+ weakLabel: 'Weak Password',
104
+ mediumLabel: 'Medium Password',
105
+ strongLabel: 'Strong Password'
106
+ }"
107
+ [form]="myFormGroup"
108
+ >
109
+ </fn-input>
110
+ ```
111
+
112
+ ### Copy to Clipboard
113
+
114
+ ```html
115
+ <fn-input
116
+ [field]="{
117
+ name: 'referralCode',
118
+ label: 'Referral Code',
119
+ type: 'text',
120
+ isCopyText: true
121
+ }"
122
+ [form]="myFormGroup"
123
+ >
124
+ </fn-input>
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 📄 API Reference
130
+
131
+ ### Input Properties (`field` object)
132
+
133
+ The `field` input accepts a configuration object based on `FNInputBase`.
134
+
135
+ #### Common Properties (`FNInputCommonProps`)
136
+
137
+ | Property | Type | Default | Description |
138
+ | :-------------------- | :--------------------------- | :----------- | :----------------------------------------------------------- |
139
+ | `name` | `string` | **Required** | Key in the `FormGroup`. |
140
+ | `label` | `string` | **Required** | Display label. |
141
+ | `type` | `string` | `text` | `text`, `email`, `textarea`, `number`, `password`, `hidden`. |
142
+ | `placeholder` | `string` | `undefined` | Optional placeholder text. |
143
+ | `required` | `boolean` | `false` | Shows asterisk on label. |
144
+ | `disabled` | `boolean` | `false` | Disables the input control. |
145
+ | `hidden` | `boolean` | `false` | Completely hides the component. |
146
+ | `readOnly` | `boolean` | `false` | Sets the input to read-only. |
147
+ | `floatLabelVariant` | `'in' \| 'over' \| 'on'` | `'over'` | Label placement strategy. |
148
+ | `validators` | `ValidatorFn[]` | `[]` | Angular validators to apply. |
149
+ | `errors` | `{ [key: string]: string }` | `{}` | Custom error messages for validators. |
150
+ | `rows` | `number` | `1` | Default rows for `textarea`. |
151
+ | `prefix` | `FNInputAffix` | `undefined` | Icon or text at the start. |
152
+ | `suffix` | `FNInputAffix` | `undefined` | Icon or text at the end. |
153
+ | `helperText` | `string` | `undefined` | Persistent helper message. |
154
+ | `isAlphanumeric` | `boolean` | `false` | Enables alphanumeric filtering. |
155
+ | `isAddressLine` | `boolean` | `false` | Allows `( ) / ,` in alphanumeric mode. |
156
+ | `isCopyText` | `boolean` | `false` | Adds a copy button. |
157
+ | `visibilityCondition` | `FNInputVisibilityCondition` | `undefined` | Logic to show/hide based on other fields. |
158
+ | `labelVariant` | `TypeLabelVariant` | `undefined` | Custom label typography variant. |
159
+ | `statusLabel` | `TypeStatusLabel` | `'Standard'` | Label status color variant. |
160
+
161
+ #### Text & Email Properties (`FNTextInputProps`)
162
+
163
+ Extends `FNInputCommonProps`.
164
+
165
+ | Property | Type | Default | Description |
166
+ | :---------- | :------- | :---------- | :--------------------------------------------- |
167
+ | `maxLength` | `number` | `undefined` | Maximum characters allowed. |
168
+ | `icon` | `object` | `undefined` | Main icon configuration (name, variant, size). |
169
+
170
+ #### Password Properties (`FNPasswordProps`)
171
+
172
+ Extends `FNInputCommonProps`.
173
+
174
+ | Property | Type | Default | Description |
175
+ | :------------ | :-------- | :--------- | :-------------------------------- |
176
+ | `toggleMask` | `boolean` | `true` | Show/hide password toggle. |
177
+ | `feedback` | `boolean` | `false` | Show password strength indicator. |
178
+ | `weakLabel` | `string` | `'Weak'` | Label for weak strength. |
179
+ | `mediumLabel` | `string` | `'Medium'` | Label for medium strength. |
180
+ | `strongLabel` | `string` | `'Strong'` | Label for strong strength. |
181
+
182
+ #### Number & Currency Properties (`FNInputNumberProps`)
183
+
184
+ | Property | Type | Default | Description |
185
+ | :------------------ | :-------- | :-------- | :---------------------------------- |
186
+ | `isCurrency` | `boolean` | `false` | Enables currency formatting. |
187
+ | `currency` | `string` | `'USD'` | Currency code (e.g., 'MYR', 'INR'). |
188
+ | `locale` | `string` | `'en-US'` | Locale for formatting. |
189
+ | `minFractionDigits` | `number` | `2` | Min decimal places. |
190
+ | `maxFractionDigits` | `number` | `2` | Max decimal places. |
191
+ | `useGrouping` | `boolean` | `true` | Use group separators (commas). |
192
+ | `maxIntegerDigits` | `number` | `12` | Max integer digits allowed. |
193
+
194
+ ---
195
+
196
+ ## 🛠️ Injection Tokens
197
+
198
+ | Token | Type | Description |
199
+ | :----------------- | :------------- | :--------------------------------------------------------- |
200
+ | `FN_TOAST_SERVICE` | `FNInputToast` | Provide a global `FNToast` service for clipboard feedback. |
201
+
202
+ ---
203
+
204
+ ## 🎨 UI Customization
205
+
206
+ The component integrates with the `shared-ui` design system via CSS variables:
207
+
208
+ - `--fn-sys-color-on-surface-variant`: Icon/Text color.
209
+ - `--fn-sys-color-error`: Error state color.
210
+ - `--fn-sys-color-success`: Success/Valid color.
211
+ - `--fn-sys-font-family-base`: Primary typography.
212
+ - `--fn-sys-color-outline`: Input border color.