@legalaidalberta/luic 0.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.
- package/CHANGELOG.md +93 -0
- package/README.md +73 -0
- package/dist/components/card/card.d.ts +6 -0
- package/dist/components/card/card.stories.d.ts +24 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/checkbox/checkbox.d.ts +24 -0
- package/dist/components/checkbox/checkbox.stories.d.ts +47 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/color-picker/color-picker.d.ts +32 -0
- package/dist/components/color-picker/color-picker.stories.d.ts +74 -0
- package/dist/components/color-picker/index.d.ts +1 -0
- package/dist/components/currency-input/currency-input.d.ts +48 -0
- package/dist/components/currency-input/currency-input.stories.d.ts +86 -0
- package/dist/components/currency-input/index.d.ts +1 -0
- package/dist/components/data-table/data-table.d.ts +100 -0
- package/dist/components/data-table/data-table.stories.d.ts +82 -0
- package/dist/components/data-table/index.d.ts +1 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/date-picker.stories.d.ts +65 -0
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/file-upload/file-upload.d.ts +44 -0
- package/dist/components/file-upload/file-upload.stories.d.ts +72 -0
- package/dist/components/file-upload/index.d.ts +1 -0
- package/dist/components/multi-select/index.d.ts +1 -0
- package/dist/components/multi-select/multi-select.d.ts +63 -0
- package/dist/components/multi-select/multi-select.stories.d.ts +71 -0
- package/dist/components/numeric-input/index.d.ts +1 -0
- package/dist/components/numeric-input/numeric-input.d.ts +65 -0
- package/dist/components/numeric-input/numeric-input.stories.d.ts +90 -0
- package/dist/components/password-input/index.d.ts +1 -0
- package/dist/components/password-input/password-input.d.ts +32 -0
- package/dist/components/password-input/password-input.stories.d.ts +64 -0
- package/dist/components/percentage-input/index.d.ts +1 -0
- package/dist/components/percentage-input/percentage-input.d.ts +44 -0
- package/dist/components/percentage-input/percentage-input.stories.d.ts +78 -0
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/radio.d.ts +26 -0
- package/dist/components/radio/radio.stories.d.ts +46 -0
- package/dist/components/rating/index.d.ts +1 -0
- package/dist/components/rating/rating.d.ts +51 -0
- package/dist/components/rating/rating.stories.d.ts +81 -0
- package/dist/components/search-input/index.d.ts +1 -0
- package/dist/components/search-input/search-input.d.ts +35 -0
- package/dist/components/search-input/search-input.stories.d.ts +64 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/select.d.ts +41 -0
- package/dist/components/select/select.stories.d.ts +47 -0
- package/dist/components/shared/FormErrorText.d.ts +12 -0
- package/dist/components/shared/FormField.d.ts +61 -0
- package/dist/components/shared/FormHelperText.d.ts +12 -0
- package/dist/components/shared/FormLabel.d.ts +25 -0
- package/dist/components/shared/index.d.ts +7 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/slider.d.ts +59 -0
- package/dist/components/slider/slider.stories.d.ts +86 -0
- package/dist/components/tag-input/index.d.ts +1 -0
- package/dist/components/tag-input/tag-input.d.ts +55 -0
- package/dist/components/tag-input/tag-input.stories.d.ts +68 -0
- package/dist/components/text-input/index.d.ts +1 -0
- package/dist/components/text-input/text-input.d.ts +24 -0
- package/dist/components/text-input/text-input.stories.d.ts +54 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/textarea.d.ts +36 -0
- package/dist/components/textarea/textarea.stories.d.ts +68 -0
- package/dist/components/time-picker/index.d.ts +1 -0
- package/dist/components/time-picker/time-picker.d.ts +37 -0
- package/dist/components/time-picker/time-picker.stories.d.ts +73 -0
- package/dist/components/toggle/index.d.ts +1 -0
- package/dist/components/toggle/toggle.d.ts +34 -0
- package/dist/components/toggle/toggle.stories.d.ts +61 -0
- package/dist/components/url-input/index.d.ts +1 -0
- package/dist/components/url-input/url-input.d.ts +28 -0
- package/dist/components/url-input/url-input.stories.d.ts +60 -0
- package/dist/hooks/useControllableValue.d.ts +44 -0
- package/dist/hooks/useFormField.d.ts +73 -0
- package/dist/index.d.ts +27 -0
- package/dist/luic.cjs.js +6 -0
- package/dist/luic.es.js +2475 -0
- package/dist/luic.umd.js +6 -0
- package/dist/styles.css +2 -0
- package/dist/types/common.d.ts +59 -0
- package/dist/utils/cn.d.ts +18 -0
- package/package.json +77 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @luic/ui
|
|
2
|
+
|
|
3
|
+
## 0.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added 5 essential form control components with full TypeScript support, accessibility features, and comprehensive test coverage
|
|
8
|
+
|
|
9
|
+
**New Components**:
|
|
10
|
+
|
|
11
|
+
- **Checkbox** - Form checkbox with label, error states, and helper text support
|
|
12
|
+
- **Radio** - Radio button component for single selection from groups
|
|
13
|
+
- **TextInput** - Versatile text input supporting all HTML input types (text, email, password, tel, url, number)
|
|
14
|
+
- **Select** - Dropdown select component with option groups and disabled state support
|
|
15
|
+
- **Toggle** - Animated switch/toggle component with on/off labels
|
|
16
|
+
|
|
17
|
+
**Features**:
|
|
18
|
+
|
|
19
|
+
- Full TypeScript support with exported prop interfaces
|
|
20
|
+
- Tailwind CSS v4 styling with `laaui:` prefix
|
|
21
|
+
- Comprehensive accessibility (ARIA attributes, semantic HTML)
|
|
22
|
+
- Error and helper text states for all components
|
|
23
|
+
- Disabled states with proper visual feedback
|
|
24
|
+
- Forward ref support for all components
|
|
25
|
+
- 76 passing tests with browser-mode testing
|
|
26
|
+
- Complete Storybook documentation with multiple examples per component
|
|
27
|
+
|
|
28
|
+
**Component Props**:
|
|
29
|
+
All form components share common props:
|
|
30
|
+
|
|
31
|
+
- `label` - Label text for the input
|
|
32
|
+
- `error` - Error message to display (takes precedence over helperText)
|
|
33
|
+
- `helperText` - Helper text displayed below the input
|
|
34
|
+
- `disabled` - Disabled state
|
|
35
|
+
|
|
36
|
+
**Usage Examples**:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Checkbox, Radio, TextInput, Select, Toggle } from '@laa/ui';
|
|
40
|
+
|
|
41
|
+
// Checkbox
|
|
42
|
+
<Checkbox
|
|
43
|
+
label="I agree to terms"
|
|
44
|
+
helperText="You must accept to continue"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
// Radio
|
|
48
|
+
<Radio
|
|
49
|
+
name="shipping"
|
|
50
|
+
label="Express Shipping"
|
|
51
|
+
helperText="2-3 business days"
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
// TextInput
|
|
55
|
+
<TextInput
|
|
56
|
+
label="Email"
|
|
57
|
+
type="email"
|
|
58
|
+
placeholder="john@example.com"
|
|
59
|
+
error="Invalid email address"
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
// Select
|
|
63
|
+
<Select
|
|
64
|
+
label="Country"
|
|
65
|
+
options={[
|
|
66
|
+
{ value: 'us', label: 'United States' },
|
|
67
|
+
{ value: 'ca', label: 'Canada' }
|
|
68
|
+
]}
|
|
69
|
+
placeholder="Select a country"
|
|
70
|
+
/>
|
|
71
|
+
|
|
72
|
+
// Toggle
|
|
73
|
+
<Toggle
|
|
74
|
+
label="Dark mode"
|
|
75
|
+
onLabel="On"
|
|
76
|
+
offLabel="Off"
|
|
77
|
+
/>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Migration**:
|
|
81
|
+
No breaking changes. All new components are additions to the library.
|
|
82
|
+
|
|
83
|
+
**Testing**:
|
|
84
|
+
All components include comprehensive test coverage:
|
|
85
|
+
|
|
86
|
+
- Checkbox: 11 tests
|
|
87
|
+
- Radio: 12 tests
|
|
88
|
+
- TextInput: 14 tests
|
|
89
|
+
- Select: 16 tests
|
|
90
|
+
- Toggle: 16 tests
|
|
91
|
+
|
|
92
|
+
**Storybook**:
|
|
93
|
+
Each component includes multiple story variants demonstrating different states and use cases. View the Storybook documentation for interactive examples.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ title, description }: {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {
|
|
10
|
+
title: {
|
|
11
|
+
control: {
|
|
12
|
+
type: "text";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
description: {
|
|
16
|
+
control: {
|
|
17
|
+
type: "text";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
export declare const Primary: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card } from './card';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { BaseFormFieldProps } from '../../types/common';
|
|
3
|
+
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'id'>, BaseFormFieldProps {
|
|
4
|
+
/**
|
|
5
|
+
* Custom ID for the checkbox element
|
|
6
|
+
* If not provided, a unique ID will be generated
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Checkbox component with built-in label, error, and helper text support
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Checkbox
|
|
16
|
+
* label="I agree to the terms and conditions"
|
|
17
|
+
* helperText="You must accept to continue"
|
|
18
|
+
* error={errors.agree}
|
|
19
|
+
* checked={formData.agree}
|
|
20
|
+
* onChange={(e) => setFormData({ ...formData, agree: e.target.checked })}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const Checkbox: import('react').ForwardRefExoticComponent<CheckboxProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import('react').ForwardRefExoticComponent<import('./checkbox').CheckboxProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
label: {
|
|
8
|
+
control: {
|
|
9
|
+
type: "text";
|
|
10
|
+
};
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
error: {
|
|
14
|
+
control: {
|
|
15
|
+
type: "text";
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
helperText: {
|
|
20
|
+
control: {
|
|
21
|
+
type: "text";
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
disabled: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "boolean";
|
|
28
|
+
};
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
checked: {
|
|
32
|
+
control: {
|
|
33
|
+
type: "boolean";
|
|
34
|
+
};
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export default meta;
|
|
40
|
+
type Story = StoryObj<typeof meta>;
|
|
41
|
+
export declare const Default: Story;
|
|
42
|
+
export declare const Checked: Story;
|
|
43
|
+
export declare const WithHelperText: Story;
|
|
44
|
+
export declare const WithError: Story;
|
|
45
|
+
export declare const Disabled: Story;
|
|
46
|
+
export declare const DisabledChecked: Story;
|
|
47
|
+
export declare const MultipleCheckboxes: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Checkbox, type CheckboxProps } from './checkbox';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { BaseFormFieldProps } from '../../types/common';
|
|
3
|
+
export interface ColorPickerProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'type'>, BaseFormFieldProps {
|
|
4
|
+
/**
|
|
5
|
+
* Custom ID for the input element
|
|
6
|
+
* If not provided, a unique ID will be generated
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to show the color preview swatch
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
showPreview?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to show the hex value
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
showHexValue?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ColorPicker component for selecting colors
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ColorPicker
|
|
26
|
+
* label="Brand Color"
|
|
27
|
+
* value={color}
|
|
28
|
+
* onChange={(e) => setColor(e.target.value)}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const ColorPicker: import('react').ForwardRefExoticComponent<ColorPickerProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import('react').ForwardRefExoticComponent<import('./color-picker').ColorPickerProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
label: {
|
|
8
|
+
control: {
|
|
9
|
+
type: "text";
|
|
10
|
+
};
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
error: {
|
|
14
|
+
control: {
|
|
15
|
+
type: "text";
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
helperText: {
|
|
20
|
+
control: {
|
|
21
|
+
type: "text";
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
disabled: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "boolean";
|
|
28
|
+
};
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
control: {
|
|
33
|
+
type: "boolean";
|
|
34
|
+
};
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
showPreview: {
|
|
38
|
+
control: {
|
|
39
|
+
type: "boolean";
|
|
40
|
+
};
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
showHexValue: {
|
|
44
|
+
control: {
|
|
45
|
+
type: "boolean";
|
|
46
|
+
};
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
value: {
|
|
50
|
+
control: {
|
|
51
|
+
type: "color";
|
|
52
|
+
};
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export default meta;
|
|
58
|
+
type Story = StoryObj<typeof meta>;
|
|
59
|
+
export declare const Default: Story;
|
|
60
|
+
export declare const WithHelperText: Story;
|
|
61
|
+
export declare const WithError: Story;
|
|
62
|
+
export declare const Required: Story;
|
|
63
|
+
export declare const Disabled: Story;
|
|
64
|
+
export declare const WithoutPreview: Story;
|
|
65
|
+
export declare const WithoutHexValue: Story;
|
|
66
|
+
export declare const MinimalDisplay: Story;
|
|
67
|
+
export declare const PrimaryColor: Story;
|
|
68
|
+
export declare const SecondaryColor: Story;
|
|
69
|
+
export declare const SuccessColor: Story;
|
|
70
|
+
export declare const ErrorColor: Story;
|
|
71
|
+
export declare const WarningColor: Story;
|
|
72
|
+
export declare const BackgroundColor: Story;
|
|
73
|
+
export declare const TextColor: Story;
|
|
74
|
+
export declare const ThemeCustomization: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker, type ColorPickerProps } from './color-picker';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
import { BaseFormFieldProps } from '../../types/common';
|
|
3
|
+
export interface CurrencyInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'id' | 'type'>, BaseFormFieldProps {
|
|
4
|
+
/**
|
|
5
|
+
* Custom ID for the input element
|
|
6
|
+
* If not provided, a unique ID will be generated
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Currency symbol to display
|
|
11
|
+
* @default '$'
|
|
12
|
+
*/
|
|
13
|
+
currencySymbol?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Position of the currency symbol
|
|
16
|
+
* @default 'left'
|
|
17
|
+
*/
|
|
18
|
+
symbolPosition?: 'left' | 'right';
|
|
19
|
+
/**
|
|
20
|
+
* Minimum value
|
|
21
|
+
*/
|
|
22
|
+
min?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Maximum value
|
|
25
|
+
*/
|
|
26
|
+
max?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Step for increment/decrement
|
|
29
|
+
* @default 0.01
|
|
30
|
+
*/
|
|
31
|
+
step?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* CurrencyInput component for entering monetary values
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <CurrencyInput
|
|
39
|
+
* label="Product Price"
|
|
40
|
+
* value={price}
|
|
41
|
+
* onChange={(e) => setPrice(e.target.value)}
|
|
42
|
+
* currencySymbol="$"
|
|
43
|
+
* min={0}
|
|
44
|
+
* step={0.01}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const CurrencyInput: import('react').ForwardRefExoticComponent<CurrencyInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import('react').ForwardRefExoticComponent<import('./currency-input').CurrencyInputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
label: {
|
|
8
|
+
control: {
|
|
9
|
+
type: "text";
|
|
10
|
+
};
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
error: {
|
|
14
|
+
control: {
|
|
15
|
+
type: "text";
|
|
16
|
+
};
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
helperText: {
|
|
20
|
+
control: {
|
|
21
|
+
type: "text";
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
disabled: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "boolean";
|
|
28
|
+
};
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
control: {
|
|
33
|
+
type: "boolean";
|
|
34
|
+
};
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
currencySymbol: {
|
|
38
|
+
control: {
|
|
39
|
+
type: "text";
|
|
40
|
+
};
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
symbolPosition: {
|
|
44
|
+
control: {
|
|
45
|
+
type: "select";
|
|
46
|
+
};
|
|
47
|
+
options: string[];
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
min: {
|
|
51
|
+
control: {
|
|
52
|
+
type: "number";
|
|
53
|
+
};
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
max: {
|
|
57
|
+
control: {
|
|
58
|
+
type: "number";
|
|
59
|
+
};
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
step: {
|
|
63
|
+
control: {
|
|
64
|
+
type: "number";
|
|
65
|
+
};
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default meta;
|
|
71
|
+
type Story = StoryObj<typeof meta>;
|
|
72
|
+
export declare const Default: Story;
|
|
73
|
+
export declare const WithHelperText: Story;
|
|
74
|
+
export declare const WithError: Story;
|
|
75
|
+
export declare const Required: Story;
|
|
76
|
+
export declare const Disabled: Story;
|
|
77
|
+
export declare const WithMinMax: Story;
|
|
78
|
+
export declare const EuroSymbol: Story;
|
|
79
|
+
export declare const PoundSymbol: Story;
|
|
80
|
+
export declare const YenSymbol: Story;
|
|
81
|
+
export declare const SymbolOnRight: Story;
|
|
82
|
+
export declare const ProductPrice: Story;
|
|
83
|
+
export declare const SalaryInput: Story;
|
|
84
|
+
export declare const DiscountPrice: Story;
|
|
85
|
+
export declare const BudgetInput: Story;
|
|
86
|
+
export declare const MultipleInputs: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CurrencyInput, type CurrencyInputProps } from './currency-input';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TableHTMLAttributes } from 'react';
|
|
2
|
+
import { BaseFormFieldProps } from '../../types/common';
|
|
3
|
+
export interface DataTableColumn<T = unknown> {
|
|
4
|
+
/**
|
|
5
|
+
* Unique key for the column
|
|
6
|
+
*/
|
|
7
|
+
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* Header text to display
|
|
10
|
+
*/
|
|
11
|
+
header: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional custom render function for cell content
|
|
14
|
+
* @param row - The row data
|
|
15
|
+
* @returns React node to render in the cell
|
|
16
|
+
*/
|
|
17
|
+
render?: (row: T) => React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Optional width for the column
|
|
20
|
+
*/
|
|
21
|
+
width?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional className for the column cells
|
|
24
|
+
*/
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface DataTableProps<T = unknown> extends Omit<TableHTMLAttributes<HTMLTableElement>, 'id'>, BaseFormFieldProps {
|
|
28
|
+
/**
|
|
29
|
+
* Custom ID for the table element
|
|
30
|
+
* If not provided, a unique ID will be generated
|
|
31
|
+
*/
|
|
32
|
+
id?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Array of column definitions
|
|
35
|
+
*/
|
|
36
|
+
columns: DataTableColumn<T>[];
|
|
37
|
+
/**
|
|
38
|
+
* Array of data rows
|
|
39
|
+
*/
|
|
40
|
+
data: T[];
|
|
41
|
+
/**
|
|
42
|
+
* Key to use for row identification (must be unique)
|
|
43
|
+
* Can be a string property name or a function that returns a unique identifier
|
|
44
|
+
*/
|
|
45
|
+
rowKey: keyof T | ((row: T) => string | number);
|
|
46
|
+
/**
|
|
47
|
+
* Whether rows can be selected with checkboxes
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
selectable?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Controlled selected rows (array of row keys)
|
|
53
|
+
*/
|
|
54
|
+
selectedRows?: (string | number)[];
|
|
55
|
+
/**
|
|
56
|
+
* Callback when selection changes
|
|
57
|
+
* @param selectedRows - Array of selected row keys
|
|
58
|
+
*/
|
|
59
|
+
onSelectionChange?: (selectedRows: (string | number)[]) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Callback when a row is clicked
|
|
62
|
+
* @param row - The clicked row data
|
|
63
|
+
*/
|
|
64
|
+
onRowClick?: (row: T) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to highlight rows on hover
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
hoverable?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether to show striped rows
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
striped?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Size variant
|
|
77
|
+
* @default 'md'
|
|
78
|
+
*/
|
|
79
|
+
size?: 'sm' | 'md' | 'lg';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* DataTable component for displaying tabular data with optional row selection
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* <DataTable
|
|
87
|
+
* columns={[
|
|
88
|
+
* { key: 'id', header: 'ID' },
|
|
89
|
+
* { key: 'name', header: 'Name' },
|
|
90
|
+
* { key: 'email', header: 'Email' },
|
|
91
|
+
* ]}
|
|
92
|
+
* data={users}
|
|
93
|
+
* rowKey="id"
|
|
94
|
+
* selectable
|
|
95
|
+
* selectedRows={selected}
|
|
96
|
+
* onSelectionChange={setSelected}
|
|
97
|
+
* />
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare const DataTable: import('react').ForwardRefExoticComponent<DataTableProps<unknown> & import('react').RefAttributes<HTMLTableElement>>;
|