@stackloop/ui 4.0.7 → 4.0.9
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 +29 -2
- package/dist/Input.d.ts +30 -7
- package/dist/Table.d.ts +5 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1846 -1788
- package/dist/index.js.map +1 -1
- package/dist/stackloop-ui.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -228,10 +228,10 @@ Call `setupRippleEffects()` only once per app (for example in `main.tsx`) to avo
|
|
|
228
228
|
**Input**:
|
|
229
229
|
- **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.
|
|
230
230
|
- **Props:**
|
|
231
|
-
- **`type`**: Native HTML input types plus `'phone' | 'country'`.
|
|
231
|
+
- **`type`**: Native HTML input types plus `'phone' | 'tel' | 'country'`.
|
|
232
232
|
- `type="date"` renders the library `DatePicker`.
|
|
233
233
|
- `type="country"` renders `CountrySelect`.
|
|
234
|
-
- `type="phone"`
|
|
234
|
+
- `type="phone"` and `type="tel"` render `PhoneInput`.
|
|
235
235
|
- **`value`**: `string | number | readonly string[] | Date`.
|
|
236
236
|
- **`onChange`**: `(value: string | Date) => void` — value-based callback used consistently across smart/native modes.
|
|
237
237
|
- **`onValueChange`**: `(value: string | Date) => void` — optional backward-compatible alias.
|
|
@@ -254,10 +254,14 @@ Call `setupRippleEffects()` only once per app (for example in `main.tsx`) to avo
|
|
|
254
254
|
import { Input } from '@stackloop/ui'
|
|
255
255
|
|
|
256
256
|
<Input label="Email" placeholder="you@example.com" />
|
|
257
|
+
<Input label="Phone" type="phone" value={phone} onChange={setPhone} />
|
|
258
|
+
<Input label="Telephone" type="tel" value={phone} onChange={setPhone} />
|
|
257
259
|
|
|
258
260
|
// Password with automatic toggle
|
|
259
261
|
<Input label="Password" type="password" placeholder="Enter password" />
|
|
260
262
|
|
|
263
|
+
|
|
264
|
+
- **Compatibility note:** Regular HTML input types still render a native `<input />`, so existing usage such as `type="email"`, `type="number"`, and `type="text"` remains unchanged.
|
|
261
265
|
// Phone (single combined value)
|
|
262
266
|
<Input
|
|
263
267
|
label="Phone"
|
|
@@ -393,6 +397,10 @@ Call `setupRippleEffects()` only once per app (for example in `main.tsx`) to avo
|
|
|
393
397
|
- **`loading`**: `boolean` — optional. Shows animated skeleton loading state when true.
|
|
394
398
|
- **`onRowClick`**: `(item: T) => void` — optional. Callback fired when a row is clicked. Adds hover effect and pointer cursor to rows.
|
|
395
399
|
- **`keyExtractor`**: `(item: T) => string` — required. Function to extract unique key from each data item for React reconciliation.
|
|
400
|
+
- **`selectable`**: `boolean` — optional (default: `false`). Adds a checkbox column with header-level select all and per-row selection.
|
|
401
|
+
- **`selectedKeys`**: `string[]` — optional. Controlled selected row keys.
|
|
402
|
+
- **`defaultSelectedKeys`**: `string[]` — optional. Initial selected row keys for uncontrolled mode.
|
|
403
|
+
- **`onSelectionChange`**: `(selectedKeys: string[], selectedItems: T[]) => void` — optional. Fires whenever selection changes.
|
|
396
404
|
- **`className`**: `string` — optional. Additional CSS classes for the table wrapper.
|
|
397
405
|
|
|
398
406
|
- **Column Interface:**
|
|
@@ -600,6 +608,25 @@ Call `setupRippleEffects()` only once per app (for example in `main.tsx`) to avo
|
|
|
600
608
|
/>
|
|
601
609
|
```
|
|
602
610
|
|
|
611
|
+
- **Selection Example:**
|
|
612
|
+
|
|
613
|
+
```jsx
|
|
614
|
+
const [selectedRows, setSelectedRows] = useState([])
|
|
615
|
+
|
|
616
|
+
<Table
|
|
617
|
+
data={users}
|
|
618
|
+
columns={columns}
|
|
619
|
+
keyExtractor={(user) => String(user.id)}
|
|
620
|
+
selectable
|
|
621
|
+
selectedKeys={selectedRows}
|
|
622
|
+
onSelectionChange={(keys, items) => {
|
|
623
|
+
setSelectedRows(keys)
|
|
624
|
+
console.log('Selected row IDs:', keys)
|
|
625
|
+
console.log('Selected row objects:', items)
|
|
626
|
+
}}
|
|
627
|
+
/>
|
|
628
|
+
```
|
|
629
|
+
|
|
603
630
|
**Dropdown**:
|
|
604
631
|
- **Description:** General-purpose select component with optional search, clear, and icons. Use this for general UI selections outside of forms. For form-specific needs with validation, use the **Select** component instead.
|
|
605
632
|
- **Props:**
|
package/dist/Input.d.ts
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { DatePicker } from './DatePicker';
|
|
3
|
+
import { CountrySelect } from './CountrySelect';
|
|
4
|
+
import { PhoneInput } from './PhoneInput';
|
|
5
|
+
type InputValue = string | Date;
|
|
6
|
+
type NativeInputType = Exclude<React.HTMLInputTypeAttribute, 'date' | 'phone' | 'country' | 'tel'>;
|
|
7
|
+
type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'onChange'> & {
|
|
8
|
+
type?: NativeInputType;
|
|
9
|
+
value?: string | number | readonly string[];
|
|
10
|
+
onChange?: (value: InputValue) => void;
|
|
11
|
+
onValueChange?: (value: InputValue) => void;
|
|
8
12
|
label?: string;
|
|
9
13
|
error?: string;
|
|
10
14
|
hint?: string;
|
|
11
15
|
leftIcon?: React.ReactNode;
|
|
12
16
|
rightIcon?: React.ReactNode;
|
|
13
17
|
animate?: boolean;
|
|
14
|
-
}
|
|
18
|
+
};
|
|
19
|
+
type PhoneInputFieldProps = Omit<React.ComponentProps<typeof PhoneInput>, 'value' | 'onChange'> & {
|
|
20
|
+
type: 'phone' | 'tel';
|
|
21
|
+
value?: string;
|
|
22
|
+
onChange?: (value: InputValue) => void;
|
|
23
|
+
onValueChange?: (value: InputValue) => void;
|
|
24
|
+
};
|
|
25
|
+
type CountrySelectInputProps = Omit<React.ComponentProps<typeof CountrySelect>, 'value' | 'onChange'> & {
|
|
26
|
+
type: 'country';
|
|
27
|
+
value?: string;
|
|
28
|
+
onChange?: (value: InputValue) => void;
|
|
29
|
+
onValueChange?: (value: InputValue) => void;
|
|
30
|
+
};
|
|
31
|
+
type DatePickerInputProps = Omit<React.ComponentProps<typeof DatePicker>, 'value' | 'onChange'> & {
|
|
32
|
+
type: 'date';
|
|
33
|
+
value?: Date;
|
|
34
|
+
onChange?: (value: InputValue) => void;
|
|
35
|
+
onValueChange?: (value: InputValue) => void;
|
|
36
|
+
};
|
|
37
|
+
export type InputProps = NativeInputProps | PhoneInputFieldProps | CountrySelectInputProps | DatePickerInputProps;
|
|
15
38
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
16
39
|
export {};
|
package/dist/Table.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export interface TableProps<T> {
|
|
|
13
13
|
loading?: boolean;
|
|
14
14
|
onRowClick?: (item: T) => void;
|
|
15
15
|
keyExtractor: (item: T) => string;
|
|
16
|
+
selectable?: boolean;
|
|
17
|
+
selectedKeys?: string[];
|
|
18
|
+
defaultSelectedKeys?: string[];
|
|
19
|
+
onSelectionChange?: (selectedKeys: string[], selectedItems: T[]) => void;
|
|
16
20
|
className?: string;
|
|
17
21
|
animate?: boolean;
|
|
18
22
|
}
|
|
19
|
-
export declare function Table<T>({ data, columns, loading, onRowClick, keyExtractor, className, animate }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function Table<T>({ data, columns, loading, onRowClick, keyExtractor, selectable, selectedKeys, defaultSelectedKeys, onSelectionChange, className, animate }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|