@stackloop/ui 3.3.5 → 4.0.0

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.

Potentially problematic release.


This version of @stackloop/ui might be problematic. Click here for more details.

package/README.md CHANGED
@@ -199,16 +199,25 @@ Components with the `animate` prop:
199
199
  ```
200
200
 
201
201
  **Input**:
202
- - **Description:** Text input with label, error and optional icons. Includes automatic password visibility toggle for password inputs.
202
+ - **Description:** Unified input API with smart type routing. Supports native text/password/email/etc plus `phone`, `country`, and `date` while keeping a consistent `value` + `onChange` pattern.
203
203
  - **Props:**
204
+ - **`type`**: Native HTML input types plus `'phone' | 'country'`.
205
+ - `type="date"` renders the library `DatePicker`.
206
+ - `type="country"` renders `CountrySelect`.
207
+ - `type="phone"` renders `PhoneInput`.
208
+ - **`value`**: `string | number | readonly string[] | Date`.
209
+ - **`onChange`**: `(value: string | Date) => void` — value-based callback used consistently across smart/native modes.
210
+ - **`onValueChange`**: `(value: string | Date) => void` — optional backward-compatible alias.
204
211
  - **`label`**: `string` — optional.
205
212
  - **`error`**: `string` — optional.
206
213
  - **`hint`**: `string` — optional.
207
214
  - **`leftIcon`** / **`rightIcon`**: `ReactNode` — optional.
208
215
  - **`className`**: `string` — optional.
209
- - Inherits `input` HTML attributes.
216
+ - Inherits most `input` HTML attributes.
210
217
  - **Features:**
211
218
  - **Password Toggle:** When `type="password"`, automatically displays an Eye/EyeOff icon to toggle password visibility. This overrides any custom `rightIcon`.
219
+ - **Consistent Value API:** Same controlled pattern for text, phone, country, and date.
220
+ - **Lightweight Composition:** Smart types reuse existing specialized components instead of duplicating logic.
212
221
  - **Icon Support:** Display icons on left or right side of input
213
222
  - **Validation:** Built-in error and hint display
214
223
  - **Accessibility:** Proper labels and ARIA attributes
@@ -221,6 +230,32 @@ Components with the `animate` prop:
221
230
 
222
231
  // Password with automatic toggle
223
232
  <Input label="Password" type="password" placeholder="Enter password" />
233
+
234
+ // Phone (single combined value)
235
+ <Input
236
+ label="Phone"
237
+ type="phone"
238
+ value={phone}
239
+ onChange={(nextValue) => setPhone(String(nextValue))}
240
+ />
241
+
242
+ // Country
243
+ <Input
244
+ label="Country"
245
+ type="country"
246
+ value={country}
247
+ onChange={(nextValue) => setCountry(String(nextValue))}
248
+ />
249
+
250
+ // Date
251
+ <Input
252
+ label="Date"
253
+ type="date"
254
+ value={selectedDate}
255
+ onChange={(nextValue) => {
256
+ if (nextValue instanceof Date) setSelectedDate(nextValue)
257
+ }}
258
+ />
224
259
 
225
260
  // With icons
226
261
  <Input
@@ -231,10 +266,10 @@ Components with the `animate` prop:
231
266
  ```
232
267
 
233
268
  **PhoneInput**:
234
- - **Description:** Phone number input with a country calling code selector and optional locale-based default.
269
+ - **Description:** Phone input with country selector and a single editable value field (country code + number in the same input).
235
270
  - **Props:**
236
271
  - **`value`**: `string` — optional.
237
- - **`onChange`**: `(dialCode: string, value: string) => void` — optional.
272
+ - **`onChange`**: `(value: string) => void` — optional.
238
273
  - **`country`**: `string` — optional ISO2 override (e.g. `US`).
239
274
  - **`defaultCountry`**: `string` — default: `'US'`.
240
275
  - **`autoDetect`**: `boolean` — default: `true`. Uses `navigator.language` to select a country.
@@ -248,6 +283,10 @@ Components with the `animate` prop:
248
283
  - **`animate`**: `boolean` — default: `true`.
249
284
  - **`className`**: `string` — optional.
250
285
  - Inherits standard `input` HTML attributes.
286
+ - **Behavior:**
287
+ - Default selected country auto-fills dial code when the input is empty.
288
+ - User can edit/delete the dial code directly in the same input.
289
+ - Dropdown opens up or down based on available viewport space.
251
290
  - **Usage:**
252
291
 
253
292
  ```jsx
@@ -256,7 +295,7 @@ Components with the `animate` prop:
256
295
  <PhoneInput
257
296
  label="Phone"
258
297
  value={phone}
259
- onChange={(dialCode, value) => setPhone(`${dialCode}${value}`)}
298
+ onChange={setPhone}
260
299
  required
261
300
  hint="Include area code"
262
301
  searchable
package/dist/Input.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import React from 'react';
2
- export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
2
+ type SmartInputType = React.HTMLInputTypeAttribute | 'country' | 'phone';
3
+ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> {
4
+ type?: SmartInputType;
5
+ value?: string | number | readonly string[] | Date;
6
+ onChange?: (value: string | Date) => void;
7
+ onValueChange?: (value: string | Date) => void;
3
8
  label?: string;
4
9
  error?: string;
5
10
  hint?: string;
@@ -8,3 +13,4 @@ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>
8
13
  animate?: boolean;
9
14
  }
10
15
  export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
16
+ export {};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { type Country } from './countries';
3
3
  export interface PhoneInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
4
4
  value?: string;
5
- onChange?: (dialCode: string, value: string) => void;
5
+ onChange?: (value: string) => void;
6
6
  country?: string;
7
7
  defaultCountry?: string;
8
8
  autoDetect?: boolean;
package/dist/Toast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export type ToastVariant = 'success' | 'error' | 'warning' | 'info' | 'default';
2
+ export type ToastVariant = 'success' | 'error' | 'warning' | 'info' | 'default' | 'loading';
3
3
  export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
4
4
  export interface Toast {
5
5
  id: string;