@vlrc-fe/components 1.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/README.md +193 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +42 -0
- package/dist/index10.cjs +1 -0
- package/dist/index10.js +85 -0
- package/dist/index100.cjs +1 -0
- package/dist/index100.js +65 -0
- package/dist/index101.cjs +1 -0
- package/dist/index101.js +48 -0
- package/dist/index102.cjs +1 -0
- package/dist/index102.js +67 -0
- package/dist/index103.cjs +1 -0
- package/dist/index103.js +151 -0
- package/dist/index104.cjs +1 -0
- package/dist/index104.js +23 -0
- package/dist/index105.cjs +1 -0
- package/dist/index105.js +27 -0
- package/dist/index106.cjs +1 -0
- package/dist/index106.js +53 -0
- package/dist/index107.cjs +1 -0
- package/dist/index107.js +161 -0
- package/dist/index108.cjs +1 -0
- package/dist/index108.js +16 -0
- package/dist/index109.cjs +1 -0
- package/dist/index11.cjs +1 -0
- package/dist/index11.js +86 -0
- package/dist/index12.cjs +1 -0
- package/dist/index12.js +122 -0
- package/dist/index13.cjs +1 -0
- package/dist/index13.js +14 -0
- package/dist/index14.cjs +1 -0
- package/dist/index14.js +16 -0
- package/dist/index15.cjs +1 -0
- package/dist/index15.js +115 -0
- package/dist/index16.cjs +1 -0
- package/dist/index16.js +727 -0
- package/dist/index17.cjs +1 -0
- package/dist/index17.js +348 -0
- package/dist/index18.cjs +1 -0
- package/dist/index18.js +76 -0
- package/dist/index19.cjs +1 -0
- package/dist/index19.js +14 -0
- package/dist/index2.cjs +1 -0
- package/dist/index2.js +122 -0
- package/dist/index20.cjs +1 -0
- package/dist/index20.js +116 -0
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +35 -0
- package/dist/index22.cjs +1 -0
- package/dist/index22.js +18 -0
- package/dist/index23.cjs +1 -0
- package/dist/index23.js +27 -0
- package/dist/index24.cjs +1 -0
- package/dist/index24.js +35 -0
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +97 -0
- package/dist/index26.cjs +1 -0
- package/dist/index26.js +28 -0
- package/dist/index27.cjs +1 -0
- package/dist/index27.js +14 -0
- package/dist/index28.cjs +1 -0
- package/dist/index28.js +67 -0
- package/dist/index29.cjs +1 -0
- package/dist/index29.js +13 -0
- package/dist/index3.cjs +1 -0
- package/dist/index3.js +8 -0
- package/dist/index30.cjs +1 -0
- package/dist/index30.js +35 -0
- package/dist/index31.cjs +1 -0
- package/dist/index31.js +43 -0
- package/dist/index32.cjs +1 -0
- package/dist/index32.js +14 -0
- package/dist/index33.cjs +1 -0
- package/dist/index33.js +64 -0
- package/dist/index34.cjs +1 -0
- package/dist/index34.js +23 -0
- package/dist/index35.cjs +1 -0
- package/dist/index35.js +34 -0
- package/dist/index36.cjs +1 -0
- package/dist/index36.js +27 -0
- package/dist/index37.cjs +1 -0
- package/dist/index37.js +26 -0
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +157 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +34 -0
- package/dist/index4.cjs +1 -0
- package/dist/index4.js +43 -0
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +46 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +118 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +125 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +26 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +88 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +221 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +166 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +126 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +15 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +9 -0
- package/dist/index5.cjs +1 -0
- package/dist/index5.js +24 -0
- package/dist/index50.cjs +1 -0
- package/dist/index50.js +17 -0
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +22 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +18 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +6 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +7 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +8 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +7 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +7 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +9 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +69 -0
- package/dist/index6.cjs +1 -0
- package/dist/index6.js +51 -0
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +11 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +202 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +124 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +32 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +20 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +69 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +32 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +11 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +280 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +157 -0
- package/dist/index7.cjs +1 -0
- package/dist/index7.js +88 -0
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +20 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +10 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +14 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +8 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +8 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +11 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +10 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +6 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +8 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +8 -0
- package/dist/index8.cjs +1 -0
- package/dist/index8.js +68 -0
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +10 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +11 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +15 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +11 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +11 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +6 -0
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +43 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +382 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +40 -0
- package/dist/index89.cjs +1 -0
- package/dist/index89.js +23 -0
- package/dist/index9.cjs +1 -0
- package/dist/index9.js +20 -0
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +59 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +55 -0
- package/dist/index92.cjs +1 -0
- package/dist/index92.js +54 -0
- package/dist/index93.cjs +1 -0
- package/dist/index93.js +57 -0
- package/dist/index94.cjs +1 -0
- package/dist/index94.js +57 -0
- package/dist/index95.cjs +1 -0
- package/dist/index95.js +88 -0
- package/dist/index96.cjs +1 -0
- package/dist/index96.js +66 -0
- package/dist/index97.cjs +1 -0
- package/dist/index97.js +594 -0
- package/dist/index98.cjs +9 -0
- package/dist/index98.js +30 -0
- package/dist/index99.cjs +1 -0
- package/dist/index99.js +50 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @vlrc-fe/components
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
ai_package_metadata:
|
|
5
|
+
package_name: "@vlrc-fe/components"
|
|
6
|
+
version: "workspace:*"
|
|
7
|
+
conventions:
|
|
8
|
+
import_hygiene:
|
|
9
|
+
main_app: "Do NOT manually import. Let Vite auto-import handle it (src/types/auto-imports.d.ts)."
|
|
10
|
+
local_packages: "Always use explicit relative or workspace imports. Packages compile without auto-imports."
|
|
11
|
+
component_rules:
|
|
12
|
+
props_typing: "Always declare props inline in the component signature. Avoid standalone interface/type Props for local components."
|
|
13
|
+
wrapper_preference: "Always prefer Select and MultiSelect wrapper components over Radix UI/Shadcn primitives."
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Reusable, optimized, and tree-shaken UI components built on top of **React 19**, **Tailwind CSS**, and **Radix UI/Shadcn** primitives for the VLRC project monorepo.
|
|
17
|
+
|
|
18
|
+
> [!IMPORTANT]
|
|
19
|
+
> **AUTO-IMPORT CONVENTION**: In the main web application (`src/`), **do not write explicit import statements** for any components in this package. They are dynamically parsed and registered by Vite into `src/types/auto-imports.d.ts`.
|
|
20
|
+
> **EXPLICIT PACKAGE IMPORTS**: Inside independent packages (like `packages/components` or `packages/hooks`), **always** write explicit imports because packages are compiled standalone using `tsc`.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 📚 Agent & Codex Skill Reference
|
|
25
|
+
|
|
26
|
+
This package is fully mapped and integrated with the custom **[platform-core-components Agent Skill](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/SKILL.md)**. When working inside this package or utilizing these components, refer to these segmented reference files:
|
|
27
|
+
1. **[Shadcn + TanStack DataTable Composition Guide](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/references/datatable.md)**
|
|
28
|
+
2. **[Form Containers & FormItem/FormBase Layouts Specification](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/references/forms.md)**
|
|
29
|
+
3. **[Custom Form Fields & Inputs API Manual](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/references/form-fields.md)**
|
|
30
|
+
4. **[Dialogs, ConfirmModal & useModalState Bindings](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/references/modals.md)**
|
|
31
|
+
5. **[Unified Graphic Icons Registry Guidelines](file:///Users/lvtruong/personal/vlrc/.agent/skills/platform-core-components/references/icons.md)**
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 📝 1. Shadcn Form Item & RHF Integration (`FormBase` & `FormItem`)
|
|
36
|
+
|
|
37
|
+
Form fields inside this repository inherit a highly structured validation wrapper component called `FormBase`. It bridges the standard **react-hook-form** controller with custom-wrapped **Shadcn UI Form Item** layouts.
|
|
38
|
+
|
|
39
|
+
### 1.1 Structural Layout & Features
|
|
40
|
+
When a field is rendered, `FormBase` automatically builds the following Shadcn structure:
|
|
41
|
+
1. **`<FormItem>` Container**: The primary layout block handling spacing. Supports:
|
|
42
|
+
- **Vertical (Default)**: Normal form inputs stacked sequentially.
|
|
43
|
+
- **Horizontal (`horizontal={true}`)**: Arranges labels and inputs side-by-side using unified grid properties. Perfect for dense settings panels.
|
|
44
|
+
- **Control First (`controlFirst={true}`)**: Renders the input control widget *before* the text label (used automatically by `FormCheckbox` and `FormRadioGroup` options).
|
|
45
|
+
2. **`<FieldLabel>`**: Displays the text label tied to the input via `htmlFor`.
|
|
46
|
+
- **Automatic required asterisk**: If the field rules specify `required: true` (or a string), `FormBase` automatically appends a red asterisk `<span className="text-red-500">*</span>` to the label.
|
|
47
|
+
3. **`<FieldDescription>`**: Displays supplementary description nodes or helper text.
|
|
48
|
+
4. **`<FieldError>`**: Listens to active RHF validation errors. If a field fails validation checks, the error message is instantly rendered below the input with appropriate red typography, omitting the need for developers to manually write error flags.
|
|
49
|
+
|
|
50
|
+
### 1.2 How `<Form>` Works
|
|
51
|
+
|
|
52
|
+
`<Form>` is literally `FormProvider` from `react-hook-form`. It provides form context so child components can use `useFormContext()`.
|
|
53
|
+
|
|
54
|
+
**Pattern**: Call `useForm()` → spread into `<Form {...form}>` → wrap a native `<form>` → fields receive `form.control`.
|
|
55
|
+
|
|
56
|
+
**Validation**: Done exclusively via `rules` prop on each field (standard RHF `RegisterOptions`). No Zod schemas.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
const { control, handleSubmit, reset } = useForm<LearningManagement.Course>();
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
|
|
63
|
+
<FormInput control={control} name="title" label="Tiêu đề" rules={{ required: true }} />
|
|
64
|
+
<FormCheckbox control={control} name="isActive" label="Hoạt động" />
|
|
65
|
+
<Button type="submit">Lưu</Button>
|
|
66
|
+
</form>
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
When splitting into child components, wrap with `<Form {...form}>` and use `useFormContext()` inside children to access `control` without prop drilling.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📊 2. DataTable (Shadcn + TanStack Table v8)
|
|
75
|
+
|
|
76
|
+
The `DataTable` component provides a rich, responsive, and performance-optimized data grid built on top of **Shadcn table structures** and **TanStack Table**.
|
|
77
|
+
|
|
78
|
+
### 2.1 API Definition
|
|
79
|
+
| Prop | Type | Default | Description |
|
|
80
|
+
| :--- | :--- | :--- | :--- |
|
|
81
|
+
| `columns` | `ColumnDef<T>[]` | - | **(Required)** TanStack-compliant column definitions. |
|
|
82
|
+
| `data` | `T[]` | - | **(Required)** Row data source array. |
|
|
83
|
+
| `isLoading` | `boolean` | `false` | Renders a custom glass-effect loader spinner overlay. |
|
|
84
|
+
| `pageSize` | `number` | `10` | Rows displayed per page. |
|
|
85
|
+
| `searchPlaceholder` | `string` | `'Tìm kiếm...'` | Search input placeholder. |
|
|
86
|
+
| `searchKey` | `string` | - | Accessor key for client-side search filtering. |
|
|
87
|
+
|
|
88
|
+
### 2.2 Standard Column Creators
|
|
89
|
+
To maintain UI consistency and eliminate copy-paste boilerplate, use the built-in column creators:
|
|
90
|
+
- **Checkbox Row Selection**: `createSelectionColumn<T>()` - Automatically inserts checkbox controls in headers and rows to select records.
|
|
91
|
+
- **Expandable Children Row caret**: `createExpanderColumn<T>()` - Inserts caret icons to toggle nested layouts.
|
|
92
|
+
- **Actions Panel Column**: `createRowActionsColumn<T>({ renderActions })` - Standardizes spacing for edit, view, and delete row action buttons.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
const columns = useMemo(() => [
|
|
96
|
+
createSelectionColumn<CourseRow>(),
|
|
97
|
+
{
|
|
98
|
+
accessorKey: 'name',
|
|
99
|
+
header: 'Tên bài học',
|
|
100
|
+
cell: ({ row }) => <span className="font-medium">{row.original.name}</span>
|
|
101
|
+
},
|
|
102
|
+
createRowActionsColumn<CourseRow>({
|
|
103
|
+
renderActions: ({ row }) => <Button onClick={() => handleEdit(row.original)}>Sửa</Button>
|
|
104
|
+
})
|
|
105
|
+
], []);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 📦 3. Specialized Custom Form Widgets
|
|
111
|
+
|
|
112
|
+
These pre-wrapped components are fully integrated with `FormBase` and automatically wire up under a `<Form>` container:
|
|
113
|
+
|
|
114
|
+
### 3.1 `FormSelect` (Single & Multi Mode)
|
|
115
|
+
Popover-based select box featuring real-time searchable keyword filters and custom item templates.
|
|
116
|
+
```tsx
|
|
117
|
+
<FormSelect
|
|
118
|
+
control={control}
|
|
119
|
+
name="level"
|
|
120
|
+
label="Trình độ"
|
|
121
|
+
options={[
|
|
122
|
+
{ value: 'A1', label: 'Cơ bản (A1)' },
|
|
123
|
+
{ value: 'B2', label: 'Nâng cao (B2)' }
|
|
124
|
+
]}
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 3.2 `FormMultiSelect`
|
|
129
|
+
A checkbox popover panel that renders selected elements as removable tag pills inside the trigger button.
|
|
130
|
+
```tsx
|
|
131
|
+
<FormMultiSelect
|
|
132
|
+
control={control}
|
|
133
|
+
name="topics"
|
|
134
|
+
label="Chủ đề chính"
|
|
135
|
+
options={[{ value: 'grammar', label: 'Ngữ pháp' }]}
|
|
136
|
+
showSelectAll
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3.3 `FormDatePicker`
|
|
141
|
+
Calendar selector supporting single date picking, time picking (`showTime`), month selection, and full date range queries (`isRangePicker: true`).
|
|
142
|
+
```tsx
|
|
143
|
+
<FormDatePicker
|
|
144
|
+
control={control}
|
|
145
|
+
name="schedule"
|
|
146
|
+
label="Lịch khai giảng"
|
|
147
|
+
isRangePicker={true}
|
|
148
|
+
/>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 3.4 `FormNumberInput`
|
|
152
|
+
Renders currency and number masks using `react-number-format`. Features increment/decrement steppers.
|
|
153
|
+
```tsx
|
|
154
|
+
<FormNumberInput
|
|
155
|
+
control={control}
|
|
156
|
+
name="price"
|
|
157
|
+
label="Học phí"
|
|
158
|
+
thousandSeparator=","
|
|
159
|
+
suffix=" VND"
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 3.5 `FormFileUpload`
|
|
164
|
+
Advanced file dropzone and uploader supporting avatar rendering (`variant="avatar"`) and S3-based immediate uploading with progress bars.
|
|
165
|
+
```tsx
|
|
166
|
+
<FormFileUpload
|
|
167
|
+
control={control}
|
|
168
|
+
name="avatar"
|
|
169
|
+
label="Ảnh đại diện"
|
|
170
|
+
variant="avatar"
|
|
171
|
+
autoUpload
|
|
172
|
+
uploadFile={async (file) => uploadToS3(file)}
|
|
173
|
+
/>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 🎨 4. Direct Wrappers & Design Tokens
|
|
179
|
+
|
|
180
|
+
Outside of active form contexts, you can directly import these components:
|
|
181
|
+
- **`Select` & `MultiSelect`**: Standard dropdown triggers.
|
|
182
|
+
- **`ConfirmModal` & `Modal`**: Dialog boxes.
|
|
183
|
+
- **`Icons`**: High-performance graphic library wrapper (Lucide React registry). Banned from importing directly in `src/` to prevent weight overheads.
|
|
184
|
+
- **`Button` / `Card` / `Badge`**: Semantic shadcn styling elements under standard Tailwind tokens.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 🛠 Package Scripts
|
|
189
|
+
|
|
190
|
+
Managed by Lerna and PNPM Workspaces:
|
|
191
|
+
- Build package: `pnpm build`
|
|
192
|
+
- Version package: `pnpm version:packages`
|
|
193
|
+
- Publish package: `pnpm publish:packages`
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./index3.cjs"),t=require("./index5.cjs"),n=require("./index6.cjs"),r=require("./index7.cjs"),i=require("./index8.cjs"),a=require("./index9.cjs"),o=require("./index10.cjs"),s=require("./index11.cjs"),c=require("./index12.cjs"),l=require("./index13.cjs"),u=require("./index14.cjs"),d=require("./index15.cjs"),f=require("./index16.cjs"),p=require("./index17.cjs"),m=require("./index19.cjs"),h=require("./index20.cjs"),g=require("./index21.cjs"),_=require("./index22.cjs"),v=require("./index23.cjs"),y=require("./index24.cjs"),b=require("./index25.cjs"),x=require("./index26.cjs"),S=require("./index27.cjs"),C=require("./index28.cjs"),w=require("./index29.cjs"),T=require("./index30.cjs"),E=require("./index31.cjs"),D=require("./index32.cjs"),O=require("./index33.cjs"),k=require("./index39.cjs"),A=require("./index41.cjs"),j=require("./index42.cjs"),M=require("./index43.cjs"),N=require("./index48.cjs"),P=require("./index49.cjs"),F=require("./index97.cjs"),I=require("./index101.cjs"),L=require("./index104.cjs"),R=require("./index105.cjs"),z=require("./index107.cjs"),B=require("./index109.cjs");exports.Accordion=t.Accordion,exports.AccordionContent=t.AccordionContent,exports.AccordionItem=t.AccordionItem,exports.AccordionTrigger=t.AccordionTrigger,exports.Badge=n.Badge,exports.Button=r.Button,exports.Calendar=i.Calendar,exports.CalendarDayButton=i.CalendarDayButton,exports.Card=a.Card,exports.CardAction=a.CardAction,exports.CardContent=a.CardContent,exports.CardDescription=a.CardDescription,exports.CardFooter=a.CardFooter,exports.CardHeader=a.CardHeader,exports.CardTitle=a.CardTitle,exports.Checkbox=o.Checkbox,exports.Clear=p.FileUploadClear,exports.FileUploadClear=p.FileUploadClear,exports.Command=c.Command,exports.CommandDialog=c.CommandDialog,exports.CommandEmpty=c.CommandEmpty,exports.CommandGroup=c.CommandGroup,exports.CommandInput=c.CommandInput,exports.CommandItem=c.CommandItem,exports.CommandList=c.CommandList,exports.CommandSeparator=c.CommandSeparator,exports.CommandShortcut=c.CommandShortcut,exports.ConfirmModal=e,exports.ConfirmationDialog=e,exports.DataTable=k,exports.Dialog=s.Dialog,exports.DialogClose=s.DialogClose,exports.DialogContent=s.DialogContent,exports.DialogDescription=s.DialogDescription,exports.DialogFooter=s.DialogFooter,exports.DialogHeader=s.DialogHeader,exports.DialogOverlay=s.DialogOverlay,exports.DialogPortal=s.DialogPortal,exports.DialogTitle=s.DialogTitle,exports.DialogTrigger=s.DialogTrigger,exports.DropdownMenu=l.DropdownMenu,exports.DropdownMenuCheckboxItem=l.DropdownMenuCheckboxItem,exports.DropdownMenuContent=l.DropdownMenuContent,exports.DropdownMenuGroup=l.DropdownMenuGroup,exports.DropdownMenuItem=l.DropdownMenuItem,exports.DropdownMenuLabel=l.DropdownMenuLabel,exports.DropdownMenuPortal=l.DropdownMenuPortal,exports.DropdownMenuRadioGroup=l.DropdownMenuRadioGroup,exports.DropdownMenuRadioItem=l.DropdownMenuRadioItem,exports.DropdownMenuSeparator=l.DropdownMenuSeparator,exports.DropdownMenuShortcut=l.DropdownMenuShortcut,exports.DropdownMenuSub=l.DropdownMenuSub,exports.DropdownMenuSubContent=l.DropdownMenuSubContent,exports.DropdownMenuSubTrigger=l.DropdownMenuSubTrigger,exports.DropdownMenuTrigger=l.DropdownMenuTrigger,exports.Dropzone=p.FileUploadDropzone,exports.FileUploadDropzone=p.FileUploadDropzone,exports.Field=f.Field,exports.FieldContent=f.FieldContent,exports.FieldDescription=f.FieldDescription,exports.FieldError=f.FieldError,exports.FieldGroup=f.FieldGroup,exports.FieldLabel=f.FieldLabel,exports.FieldLegend=f.FieldLegend,exports.FieldSeparator=f.FieldSeparator,exports.FieldSet=f.FieldSet,exports.FieldTitle=f.FieldTitle,exports.FileUpload=p.FileUploadRoot,exports.Root=p.FileUploadRoot,exports.FileUploadItem=p.FileUploadItem,exports.FileUploadItemDelete=p.FileUploadItemDelete,exports.ItemDelete=p.FileUploadItemDelete,exports.FileUploadItemMetadata=p.FileUploadItemMetadata,exports.ItemMetadata=p.FileUploadItemMetadata,exports.FileUploadItemPreview=p.FileUploadItemPreview,exports.ItemPreview=p.FileUploadItemPreview,exports.FileUploadItemProgress=p.FileUploadItemProgress,exports.ItemProgress=p.FileUploadItemProgress,exports.FileUploadList=p.FileUploadList,exports.List=p.FileUploadList,exports.FileUploadTrigger=p.FileUploadTrigger,exports.Trigger=p.FileUploadTrigger,exports.Form=m.Form,exports.FormCheckbox=M.FormCheckbox,exports.FormControl=m.FormControl,exports.FormDatePicker=F,exports.FormDescription=m.FormDescription,exports.FormField=m.FormField,exports.FormFileUpload=B,exports.FormInput=M.FormInput,exports.FormItem=m.FormItem,exports.FormLabel=m.FormLabel,exports.FormMessage=m.FormMessage,exports.FormMultiSelect=P,exports.FormNumberInput=I.FormNumberInput,exports.FormRadioGroup=z.FormRadio,exports.FormSelect=R.FormSelect,exports.FormSimpleSelect=M.FormSimpleSelect,exports.FormTextarea=M.FormTextarea,exports.Icons=j.Icons,exports.Input=h.Input,exports.Item=g.Item,exports.ItemActions=g.ItemActions,exports.ItemContent=g.ItemContent,exports.ItemDescription=g.ItemDescription,exports.ItemFooter=g.ItemFooter,exports.ItemGroup=g.ItemGroup,exports.ItemHeader=g.ItemHeader,exports.ItemMedia=g.ItemMedia,exports.ItemSeparator=g.ItemSeparator,exports.ItemTitle=g.ItemTitle,exports.Label=u.Label,exports.Modal=D.Modal,exports.MultiSelect=N,exports.Popover=_.Popover,exports.PopoverAnchor=_.PopoverAnchor,exports.PopoverContent=_.PopoverContent,exports.PopoverTrigger=_.PopoverTrigger,exports.Progress=v.Progress,exports.RadioGroup=y.RadioGroup,exports.RadioGroupItem=y.RadioGroupItem,exports.ScrollArea=b.ScrollArea,exports.ScrollBar=b.ScrollBar,exports.Select=L.BaseSelect,exports.SelectContent=x.SelectContent,exports.SelectGroup=x.SelectGroup,exports.SelectItem=x.SelectItem,exports.SelectLabel=x.SelectLabel,exports.SelectScrollDownButton=x.SelectScrollDownButton,exports.SelectScrollUpButton=x.SelectScrollUpButton,exports.SelectSeparator=x.SelectSeparator,exports.SelectTrigger=x.SelectTrigger,exports.SelectValue=x.SelectValue,exports.Separator=d.Separator,exports.Spinner=C.Spinner,exports.Table=w.Table,exports.TableBody=w.TableBody,exports.TableCaption=w.TableCaption,exports.TableCell=w.TableCell,exports.TableFooter=w.TableFooter,exports.TableHead=w.TableHead,exports.TableHeader=w.TableHeader,exports.TableRow=w.TableRow,exports.Textarea=T.Textarea,exports.Toaster=S.Toaster,exports.Tooltip=E.Tooltip,exports.TooltipContent=E.TooltipContent,exports.TooltipProvider=E.TooltipProvider,exports.TooltipTrigger=E.TooltipTrigger,exports.badgeVariants=n.badgeVariants,exports.buttonVariants=r.buttonVariants,exports.cardVariants=a.cardVariants,exports.createExpanderColumn=A.createExpanderColumn,exports.createRowActionsColumn=A.createRowActionsColumn,exports.createSelectionColumn=A.createSelectionColumn,exports.lazyLoad=O.lazyLoad,exports.useFileUpload=p.useStore,exports.useFormField=m.useFormField;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import e from "./index2.js";
|
|
2
|
+
import { Accordion as ee, AccordionContent as te, AccordionItem as ne, AccordionTrigger as re } from "./index4.js";
|
|
3
|
+
import { Badge as ie, badgeVariants as ae } from "./index5.js";
|
|
4
|
+
import { Button as oe, buttonVariants as se } from "./index6.js";
|
|
5
|
+
import { Calendar as ce, CalendarDayButton as le } from "./index7.js";
|
|
6
|
+
import { Card as ue, CardAction as t, CardContent as n, CardDescription as r, CardFooter as i, CardHeader as a, CardTitle as o, cardVariants as s } from "./index8.js";
|
|
7
|
+
import { Checkbox as c } from "./index9.js";
|
|
8
|
+
import { Dialog as l, DialogClose as u, DialogContent as d, DialogDescription as f, DialogFooter as p, DialogHeader as m, DialogOverlay as h, DialogPortal as g, DialogTitle as _, DialogTrigger as v } from "./index10.js";
|
|
9
|
+
import { Command as y, CommandDialog as b, CommandEmpty as x, CommandGroup as S, CommandInput as C, CommandItem as w, CommandList as T, CommandSeparator as E, CommandShortcut as D } from "./index11.js";
|
|
10
|
+
import { DropdownMenu as O, DropdownMenuCheckboxItem as k, DropdownMenuContent as A, DropdownMenuGroup as j, DropdownMenuItem as M, DropdownMenuLabel as N, DropdownMenuPortal as P, DropdownMenuRadioGroup as F, DropdownMenuRadioItem as I, DropdownMenuSeparator as L, DropdownMenuShortcut as R, DropdownMenuSub as z, DropdownMenuSubContent as B, DropdownMenuSubTrigger as V, DropdownMenuTrigger as H } from "./index12.js";
|
|
11
|
+
import { Label as U } from "./index13.js";
|
|
12
|
+
import { Separator as de } from "./index14.js";
|
|
13
|
+
import { Field as fe, FieldContent as pe, FieldDescription as me, FieldError as he, FieldGroup as ge, FieldLabel as _e, FieldLegend as ve, FieldSeparator as ye, FieldSet as be, FieldTitle as xe } from "./index15.js";
|
|
14
|
+
import { FileUploadClear as W, FileUploadDropzone as G, FileUploadItem as Se, FileUploadItemDelete as K, FileUploadItemMetadata as q, FileUploadItemPreview as J, FileUploadItemProgress as Y, FileUploadList as X, FileUploadRoot as Z, FileUploadTrigger as Q, useStore as Ce } from "./index16.js";
|
|
15
|
+
import { Form as we, FormControl as Te, FormDescription as Ee, FormField as De, FormItem as Oe, FormLabel as ke, FormMessage as Ae, useFormField as je } from "./index18.js";
|
|
16
|
+
import { Input as Me } from "./index19.js";
|
|
17
|
+
import { Item as $, ItemActions as Ne, ItemContent as Pe, ItemDescription as Fe, ItemFooter as Ie, ItemGroup as Le, ItemHeader as Re, ItemMedia as ze, ItemSeparator as Be, ItemTitle as Ve } from "./index20.js";
|
|
18
|
+
import { Popover as He, PopoverAnchor as Ue, PopoverContent as We, PopoverTrigger as Ge } from "./index21.js";
|
|
19
|
+
import { Progress as Ke } from "./index22.js";
|
|
20
|
+
import { RadioGroup as qe, RadioGroupItem as Je } from "./index23.js";
|
|
21
|
+
import { ScrollArea as Ye, ScrollBar as Xe } from "./index24.js";
|
|
22
|
+
import { SelectContent as Ze, SelectGroup as Qe, SelectItem as $e, SelectLabel as et, SelectScrollDownButton as tt, SelectScrollUpButton as nt, SelectSeparator as rt, SelectTrigger as it, SelectValue as at } from "./index25.js";
|
|
23
|
+
import { Toaster as ot } from "./index26.js";
|
|
24
|
+
import { Spinner as st } from "./index27.js";
|
|
25
|
+
import { Table as ct, TableBody as lt, TableCaption as ut, TableCell as dt, TableFooter as ft, TableHead as pt, TableHeader as mt, TableRow as ht } from "./index28.js";
|
|
26
|
+
import { Textarea as gt } from "./index29.js";
|
|
27
|
+
import { Tooltip as _t, TooltipContent as vt, TooltipProvider as yt, TooltipTrigger as bt } from "./index30.js";
|
|
28
|
+
import { Modal as xt } from "./index31.js";
|
|
29
|
+
import { lazyLoad as St } from "./index32.js";
|
|
30
|
+
import Ct from "./index38.js";
|
|
31
|
+
import { createExpanderColumn as wt, createRowActionsColumn as Tt, createSelectionColumn as Et } from "./index40.js";
|
|
32
|
+
import { Icons as Dt } from "./index41.js";
|
|
33
|
+
import { FormCheckbox as Ot, FormInput as kt, FormSimpleSelect as At, FormTextarea as jt } from "./index42.js";
|
|
34
|
+
import Mt from "./index47.js";
|
|
35
|
+
import Nt from "./index48.js";
|
|
36
|
+
import Pt from "./index96.js";
|
|
37
|
+
import { FormNumberInput as Ft } from "./index100.js";
|
|
38
|
+
import { BaseSelect as It } from "./index103.js";
|
|
39
|
+
import { FormSelect as Lt } from "./index104.js";
|
|
40
|
+
import { FormRadio as Rt } from "./index106.js";
|
|
41
|
+
import zt from "./index108.js";
|
|
42
|
+
export { ee as Accordion, te as AccordionContent, ne as AccordionItem, re as AccordionTrigger, ie as Badge, oe as Button, ce as Calendar, le as CalendarDayButton, ue as Card, t as CardAction, n as CardContent, r as CardDescription, i as CardFooter, a as CardHeader, o as CardTitle, c as Checkbox, W as Clear, W as FileUploadClear, y as Command, b as CommandDialog, x as CommandEmpty, S as CommandGroup, C as CommandInput, w as CommandItem, T as CommandList, E as CommandSeparator, D as CommandShortcut, e as ConfirmModal, e as ConfirmationDialog, Ct as DataTable, l as Dialog, u as DialogClose, d as DialogContent, f as DialogDescription, p as DialogFooter, m as DialogHeader, h as DialogOverlay, g as DialogPortal, _ as DialogTitle, v as DialogTrigger, O as DropdownMenu, k as DropdownMenuCheckboxItem, A as DropdownMenuContent, j as DropdownMenuGroup, M as DropdownMenuItem, N as DropdownMenuLabel, P as DropdownMenuPortal, F as DropdownMenuRadioGroup, I as DropdownMenuRadioItem, L as DropdownMenuSeparator, R as DropdownMenuShortcut, z as DropdownMenuSub, B as DropdownMenuSubContent, V as DropdownMenuSubTrigger, H as DropdownMenuTrigger, G as Dropzone, G as FileUploadDropzone, fe as Field, pe as FieldContent, me as FieldDescription, he as FieldError, ge as FieldGroup, _e as FieldLabel, ve as FieldLegend, ye as FieldSeparator, be as FieldSet, xe as FieldTitle, Z as FileUpload, Z as Root, Se as FileUploadItem, K as FileUploadItemDelete, K as ItemDelete, q as FileUploadItemMetadata, q as ItemMetadata, J as FileUploadItemPreview, J as ItemPreview, Y as FileUploadItemProgress, Y as ItemProgress, X as FileUploadList, X as List, Q as FileUploadTrigger, Q as Trigger, we as Form, Ot as FormCheckbox, Te as FormControl, Pt as FormDatePicker, Ee as FormDescription, De as FormField, zt as FormFileUpload, kt as FormInput, Oe as FormItem, ke as FormLabel, Ae as FormMessage, Nt as FormMultiSelect, Ft as FormNumberInput, Rt as FormRadioGroup, Lt as FormSelect, At as FormSimpleSelect, jt as FormTextarea, Dt as Icons, Me as Input, $ as Item, Ne as ItemActions, Pe as ItemContent, Fe as ItemDescription, Ie as ItemFooter, Le as ItemGroup, Re as ItemHeader, ze as ItemMedia, Be as ItemSeparator, Ve as ItemTitle, U as Label, xt as Modal, Mt as MultiSelect, He as Popover, Ue as PopoverAnchor, We as PopoverContent, Ge as PopoverTrigger, Ke as Progress, qe as RadioGroup, Je as RadioGroupItem, Ye as ScrollArea, Xe as ScrollBar, It as Select, Ze as SelectContent, Qe as SelectGroup, $e as SelectItem, et as SelectLabel, tt as SelectScrollDownButton, nt as SelectScrollUpButton, rt as SelectSeparator, it as SelectTrigger, at as SelectValue, de as Separator, st as Spinner, ct as Table, lt as TableBody, ut as TableCaption, dt as TableCell, ft as TableFooter, pt as TableHead, mt as TableHeader, ht as TableRow, gt as Textarea, ot as Toaster, _t as Tooltip, vt as TooltipContent, yt as TooltipProvider, bt as TooltipTrigger, ae as badgeVariants, se as buttonVariants, s as cardVariants, wt as createExpanderColumn, Tt as createRowActionsColumn, Et as createSelectionColumn, St as lazyLoad, Ce as useFileUpload, je as useFormField };
|
package/dist/index10.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./index2.cjs"),t=require("./index4.cjs");let n=require("lucide-react"),r=require("react");r=e.__toESM(r,1);let i=require("react/jsx-runtime"),a=require("@radix-ui/react-checkbox");a=e.__toESM(a,1);function o({className:e,...r}){return(0,i.jsx)(a.Root,{"data-slot":`checkbox`,className:t.cn(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...r,children:(0,i.jsx)(a.Indicator,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none`,children:(0,i.jsx)(n.CheckIcon,{className:`size-3.5`})})})}exports.Checkbox=o;
|
package/dist/index10.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { cn as e } from "./index3.js";
|
|
2
|
+
import { XIcon as t } from "lucide-react";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
import * as i from "@radix-ui/react-dialog";
|
|
6
|
+
//#region src/ui/dialog.tsx
|
|
7
|
+
function a({ ...e }) {
|
|
8
|
+
return /* @__PURE__ */ n(i.Root, {
|
|
9
|
+
"data-slot": "dialog",
|
|
10
|
+
...e
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function o({ ...e }) {
|
|
14
|
+
return /* @__PURE__ */ n(i.Trigger, {
|
|
15
|
+
"data-slot": "dialog-trigger",
|
|
16
|
+
...e
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function s({ ...e }) {
|
|
20
|
+
return /* @__PURE__ */ n(i.Portal, {
|
|
21
|
+
"data-slot": "dialog-portal",
|
|
22
|
+
...e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function c({ ...e }) {
|
|
26
|
+
return /* @__PURE__ */ n(i.Close, {
|
|
27
|
+
"data-slot": "dialog-close",
|
|
28
|
+
...e
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function l({ className: t, ...r }) {
|
|
32
|
+
return /* @__PURE__ */ n(i.Overlay, {
|
|
33
|
+
"data-slot": "dialog-overlay",
|
|
34
|
+
className: e("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", t),
|
|
35
|
+
...r
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function u({ className: a, children: o, showCloseButton: c = !0, ...u }) {
|
|
39
|
+
return /* @__PURE__ */ r(s, {
|
|
40
|
+
"data-slot": "dialog-portal",
|
|
41
|
+
children: [/* @__PURE__ */ n(l, {}), /* @__PURE__ */ r(i.Content, {
|
|
42
|
+
"data-slot": "dialog-content",
|
|
43
|
+
className: e("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg", a),
|
|
44
|
+
...u,
|
|
45
|
+
children: [o, c && /* @__PURE__ */ r(i.Close, {
|
|
46
|
+
"data-slot": "dialog-close",
|
|
47
|
+
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
48
|
+
children: [/* @__PURE__ */ n(t, {}), /* @__PURE__ */ n("span", {
|
|
49
|
+
className: "sr-only",
|
|
50
|
+
children: "Close"
|
|
51
|
+
})]
|
|
52
|
+
})]
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function d({ className: t, ...r }) {
|
|
57
|
+
return /* @__PURE__ */ n("div", {
|
|
58
|
+
"data-slot": "dialog-header",
|
|
59
|
+
className: e("flex flex-col gap-2 text-center sm:text-left", t),
|
|
60
|
+
...r
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function f({ className: t, ...r }) {
|
|
64
|
+
return /* @__PURE__ */ n("div", {
|
|
65
|
+
"data-slot": "dialog-footer",
|
|
66
|
+
className: e("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", t),
|
|
67
|
+
...r
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function p({ className: t, ...r }) {
|
|
71
|
+
return /* @__PURE__ */ n(i.Title, {
|
|
72
|
+
"data-slot": "dialog-title",
|
|
73
|
+
className: e("text-lg leading-none font-semibold", t),
|
|
74
|
+
...r
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function m({ className: t, ...r }) {
|
|
78
|
+
return /* @__PURE__ */ n(i.Description, {
|
|
79
|
+
"data-slot": "dialog-description",
|
|
80
|
+
className: e("text-muted-foreground text-sm", t),
|
|
81
|
+
...r
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { a as Dialog, c as DialogClose, u as DialogContent, m as DialogDescription, f as DialogFooter, d as DialogHeader, l as DialogOverlay, s as DialogPortal, p as DialogTitle, o as DialogTrigger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./index4.cjs");var t=[`[appearance:textfield]`,`[&::-webkit-outer-spin-button]:appearance-none`,`[&::-webkit-inner-spin-button]:appearance-none`,`rounded-r-none`,`relative`];function n({rules:n,inputClassName:r,stepper:i,min:a,max:o,onChange:s,passthroughProps:c}){let l=n?.required!==void 0&&n.required!==!1;return{isRequired:l,enhancedRules:(()=>{if(!n)return n;let e={...n};return l&&typeof e.required!=`string`&&typeof e.required!=`object`?e.required=`Trường này là bắt buộc`:typeof e.required==`object`&&!e.required.message&&(e.required={...e.required,message:`Trường này là bắt buộc`}),e})(),numericClass:e.cn(t,r),getHandlers:({currentValue:e,field:t})=>{let n=()=>{let n=Math.min((e??0)+i,o);t.onChange(n),s?.(n)},r=()=>{let n=Math.max((e??0)-i,a);t.onChange(n),s?.(n)};return{handleIncrement:n,handleDecrement:r,handleKeyDown:e=>{e.key===`ArrowUp`?(e.preventDefault(),n()):e.key===`ArrowDown`&&(e.preventDefault(),r()),c.onKeyDown&&c.onKeyDown(e)},handleBlur:()=>{let n=e;n!==void 0&&(n<a?(t.onChange(a),s?.(a)):n>o&&(t.onChange(o),s?.(o))),t.onBlur(),c.onBlur&&c.onBlur()},numericOnValueChange:e=>{let n=e.floatValue===void 0?void 0:e.floatValue;t.onChange(n),s?.(n)}}}}}exports.useFormNumberInput=n;
|
package/dist/index100.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cn as e } from "./index3.js";
|
|
2
|
+
import { FormBase as t } from "./index42.js";
|
|
3
|
+
import { NumericFormat as n } from "./index97.js";
|
|
4
|
+
import { StepperControls as r } from "./index98.js";
|
|
5
|
+
import { useFormNumberInput as i } from "./index99.js";
|
|
6
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
//#region src/Form/FormNumberInput/FormNumberInput.tsx
|
|
8
|
+
function s({ control: s, name: c, label: l, stepper: u = 1, min: d = "0", max: f = "100", minValue: p = -Infinity, maxValue: m = Infinity, thousandSeparator: h, placeholder: g, fixedDecimalScale: _ = !1, decimalScale: v = 0, suffix: y, prefix: b, inputClassName: x, onChange: S, rules: C, description: w, horizontal: T, controlFirst: E, ...D }) {
|
|
9
|
+
let { enhancedRules: O, numericClass: k, getHandlers: A } = i({
|
|
10
|
+
min: p,
|
|
11
|
+
max: m,
|
|
12
|
+
rules: C,
|
|
13
|
+
inputClassName: x,
|
|
14
|
+
stepper: u,
|
|
15
|
+
onChange: S,
|
|
16
|
+
passthroughProps: D
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ a(t, {
|
|
19
|
+
control: s,
|
|
20
|
+
name: c,
|
|
21
|
+
label: l,
|
|
22
|
+
description: w,
|
|
23
|
+
rules: O,
|
|
24
|
+
horizontal: T,
|
|
25
|
+
controlFirst: E,
|
|
26
|
+
children: ({ id: t, "aria-invalid": i, ...s }) => {
|
|
27
|
+
let c = s.value, { handleIncrement: l, handleDecrement: u, handleKeyDown: x, handleBlur: S, numericOnValueChange: C } = A({
|
|
28
|
+
currentValue: c,
|
|
29
|
+
field: s
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ o("div", {
|
|
32
|
+
className: "flex items-center",
|
|
33
|
+
children: [/* @__PURE__ */ a(n, {
|
|
34
|
+
min: d,
|
|
35
|
+
max: f,
|
|
36
|
+
"aria-invalid": i,
|
|
37
|
+
value: c ?? "",
|
|
38
|
+
onValueChange: C,
|
|
39
|
+
thousandSeparator: h,
|
|
40
|
+
decimalScale: v,
|
|
41
|
+
fixedDecimalScale: _,
|
|
42
|
+
allowNegative: p < 0,
|
|
43
|
+
valueIsNumericString: !1,
|
|
44
|
+
onBlur: S,
|
|
45
|
+
suffix: y,
|
|
46
|
+
prefix: b,
|
|
47
|
+
placeholder: g || "0",
|
|
48
|
+
getInputRef: s.ref,
|
|
49
|
+
onKeyDown: x,
|
|
50
|
+
name: s.name,
|
|
51
|
+
...D,
|
|
52
|
+
id: t,
|
|
53
|
+
className: e(k, D.className)
|
|
54
|
+
}), /* @__PURE__ */ a(r, {
|
|
55
|
+
onIncrement: l,
|
|
56
|
+
onDecrement: u,
|
|
57
|
+
disableIncrement: c !== void 0 && c >= m,
|
|
58
|
+
disableDecrement: c !== void 0 && c <= p
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { s as FormNumberInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./index4.cjs"),t=require("./index43.cjs"),n=require("./index98.cjs"),r=require("./index99.cjs"),i=require("./index100.cjs");let a=require("react/jsx-runtime");function o({control:o,name:s,label:c,stepper:l=1,min:u=`0`,max:d=`100`,minValue:f=-1/0,maxValue:p=1/0,thousandSeparator:m,placeholder:h,fixedDecimalScale:g=!1,decimalScale:_=0,suffix:v,prefix:y,inputClassName:b,onChange:x,rules:S,description:C,horizontal:w,controlFirst:T,...E}){let{enhancedRules:D,numericClass:O,getHandlers:k}=i.useFormNumberInput({min:f,max:p,rules:S,inputClassName:b,stepper:l,onChange:x,passthroughProps:E});return(0,a.jsx)(t.FormBase,{control:o,name:s,label:c,description:C,rules:D,horizontal:w,controlFirst:T,children:({id:t,"aria-invalid":i,...o})=>{let s=o.value,{handleIncrement:c,handleDecrement:l,handleKeyDown:b,handleBlur:x,numericOnValueChange:S}=k({currentValue:s,field:o});return(0,a.jsxs)(`div`,{className:`flex items-center`,children:[(0,a.jsx)(n.NumericFormat,{min:u,max:d,"aria-invalid":i,value:s??``,onValueChange:S,thousandSeparator:m,decimalScale:_,fixedDecimalScale:g,allowNegative:f<0,valueIsNumericString:!1,onBlur:x,suffix:v,prefix:y,placeholder:h||`0`,getInputRef:o.ref,onKeyDown:b,name:o.name,...E,id:t,className:e.cn(O,E.className)}),(0,a.jsx)(r.StepperControls,{onIncrement:c,onDecrement:l,disableIncrement:s!==void 0&&s>=p,disableDecrement:s!==void 0&&s<=f})]})}})}exports.FormNumberInput=o;
|
package/dist/index101.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { get as e, isNil as t } from "lodash-es";
|
|
2
|
+
//#region src/Form/FormSelect/useFormSelect.ts
|
|
3
|
+
function n(e) {
|
|
4
|
+
return e.isMulti === !0;
|
|
5
|
+
}
|
|
6
|
+
function r(r) {
|
|
7
|
+
let { options: i, injectOptions: a, placeholder: o = "Chọn...", description: s, disabled: c, isClearable: l = !0, isSearchable: u = !0, isLoading: d = !1, className: f, rules: p, onSearchTextChange: m, hasNextPage: h, isFetchingNextPage: g, fetchNextPage: _, maxTagCount: v = "responsive", tagRender: y, showSelectAll: b = !1 } = r, x = e(p, "required"), S = !t(x) && x !== !1, C = {
|
|
8
|
+
options: i,
|
|
9
|
+
injectOptions: a,
|
|
10
|
+
placeholder: o,
|
|
11
|
+
isClearable: l,
|
|
12
|
+
isSearchable: u,
|
|
13
|
+
isLoading: d,
|
|
14
|
+
className: f,
|
|
15
|
+
disabled: c,
|
|
16
|
+
onSearchTextChange: m,
|
|
17
|
+
hasNextPage: h,
|
|
18
|
+
isFetchingNextPage: g,
|
|
19
|
+
fetchNextPage: _,
|
|
20
|
+
maxTagCount: v,
|
|
21
|
+
tagRender: y,
|
|
22
|
+
showSelectAll: b
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
isRequired: S,
|
|
26
|
+
description: s,
|
|
27
|
+
enhancedRules: (() => {
|
|
28
|
+
if (!p) return p;
|
|
29
|
+
let e = { ...p };
|
|
30
|
+
return S && typeof e.required != "string" && typeof e.required != "object" ? e.required = "Trường này là bắt buộc" : typeof e.required == "object" && !e.required.message && (e.required = {
|
|
31
|
+
...e.required,
|
|
32
|
+
message: "Trường này là bắt buộc"
|
|
33
|
+
}), e;
|
|
34
|
+
})(),
|
|
35
|
+
baseSelectProps: C,
|
|
36
|
+
isMulti: n(r),
|
|
37
|
+
createChangeHandlers: (e) => ({
|
|
38
|
+
onChangeMulti: (t) => {
|
|
39
|
+
e.onChange(t), n(r) && r.onChange && r.onChange(t);
|
|
40
|
+
},
|
|
41
|
+
onChangeSingle: (t) => {
|
|
42
|
+
e.onChange(t), !n(r) && r.onChange && r.onChange(t);
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { r as useFormSelect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("lodash-es");function t(e){return e.isMulti===!0}function n(n){let{options:r,injectOptions:i,placeholder:a=`Chọn...`,description:o,disabled:s,isClearable:c=!0,isSearchable:l=!0,isLoading:u=!1,className:d,rules:f,onSearchTextChange:p,hasNextPage:m,isFetchingNextPage:h,fetchNextPage:g,maxTagCount:_=`responsive`,tagRender:v,showSelectAll:y=!1}=n,b=(0,e.get)(f,`required`),x=!(0,e.isNil)(b)&&b!==!1,S={options:r,injectOptions:i,placeholder:a,isClearable:c,isSearchable:l,isLoading:u,className:d,disabled:s,onSearchTextChange:p,hasNextPage:m,isFetchingNextPage:h,fetchNextPage:g,maxTagCount:_,tagRender:v,showSelectAll:y};return{isRequired:x,description:o,enhancedRules:(()=>{if(!f)return f;let e={...f};return x&&typeof e.required!=`string`&&typeof e.required!=`object`?e.required=`Trường này là bắt buộc`:typeof e.required==`object`&&!e.required.message&&(e.required={...e.required,message:`Trường này là bắt buộc`}),e})(),baseSelectProps:S,isMulti:t(n),createChangeHandlers:e=>({onChangeMulti:r=>{e.onChange(r),t(n)&&n.onChange&&n.onChange(r)},onChangeSingle:r=>{e.onChange(r),!t(n)&&n.onChange&&n.onChange(r)}})}}exports.useFormSelect=n;
|
package/dist/index102.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Badge as e } from "./index5.js";
|
|
2
|
+
import { Tooltip as t, TooltipContent as n, TooltipProvider as r, TooltipTrigger as i } from "./index30.js";
|
|
3
|
+
import { Icons as a } from "./index41.js";
|
|
4
|
+
import { useEffect as o, useRef as s, useState as c } from "react";
|
|
5
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
//#region src/Select/MultiSelectTags.tsx
|
|
7
|
+
function d({ selectedOptions: d, maxTagCount: f = "responsive", onRemove: p, disabled: m, tagRender: h }) {
|
|
8
|
+
let g = s(null), [_, v] = c(d.length), [y, b] = c([]);
|
|
9
|
+
o(() => {
|
|
10
|
+
if (f === "responsive" && g.current) {
|
|
11
|
+
let e = g.current, t = e.offsetWidth - 60, n = 0, r = 0, i = Array.from(e.children);
|
|
12
|
+
for (let e = 0; e < i.length; e++) {
|
|
13
|
+
let a = i[e];
|
|
14
|
+
if (a.classList.contains("select-tag")) {
|
|
15
|
+
let e = a.offsetWidth + 4;
|
|
16
|
+
if (n + e <= t) n += e, r++;
|
|
17
|
+
else break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
r < d.length ? (v(Math.max(1, r - 1)), b(d.slice(Math.max(1, r - 1)))) : (v(d.length), b([]));
|
|
21
|
+
} else typeof f == "number" ? (v(Math.min(f, d.length)), b(d.slice(f))) : (v(d.length), b([]));
|
|
22
|
+
}, [d, f]);
|
|
23
|
+
let x = h || ((t, n) => /* @__PURE__ */ u(e, {
|
|
24
|
+
variant: "secondary",
|
|
25
|
+
className: "select-tag flex items-center gap-1 px-2 py-0.5 text-xs whitespace-nowrap",
|
|
26
|
+
children: [
|
|
27
|
+
t.icon && /* @__PURE__ */ l("span", {
|
|
28
|
+
className: "text-xs",
|
|
29
|
+
children: t.icon
|
|
30
|
+
}),
|
|
31
|
+
/* @__PURE__ */ l("span", {
|
|
32
|
+
className: "truncate max-w-[100px]",
|
|
33
|
+
children: t.label
|
|
34
|
+
}),
|
|
35
|
+
!m && /* @__PURE__ */ l(a.XIcon, {
|
|
36
|
+
className: "w-3 h-3 cursor-pointer hover:text-destructive",
|
|
37
|
+
onClick: (e) => {
|
|
38
|
+
e.stopPropagation(), n();
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}, t.value));
|
|
43
|
+
return /* @__PURE__ */ u("div", {
|
|
44
|
+
ref: g,
|
|
45
|
+
className: "flex items-center gap-1 flex-wrap flex-1 min-w-0",
|
|
46
|
+
children: [d.slice(0, _).map((e) => x(e, () => p(e.value))), y.length > 0 && /* @__PURE__ */ l(r, { children: /* @__PURE__ */ u(t, { children: [/* @__PURE__ */ l(i, {
|
|
47
|
+
asChild: !0,
|
|
48
|
+
children: /* @__PURE__ */ u(e, {
|
|
49
|
+
variant: "outline",
|
|
50
|
+
className: "cursor-help text-xs px-2 py-0.5",
|
|
51
|
+
children: ["+", y.length]
|
|
52
|
+
})
|
|
53
|
+
}), /* @__PURE__ */ l(n, {
|
|
54
|
+
side: "bottom",
|
|
55
|
+
className: "max-w-xs",
|
|
56
|
+
children: /* @__PURE__ */ l("div", {
|
|
57
|
+
className: "flex flex-col gap-1",
|
|
58
|
+
children: y.map((e) => /* @__PURE__ */ u("div", {
|
|
59
|
+
className: "flex items-center gap-2 text-xs",
|
|
60
|
+
children: [e.icon && /* @__PURE__ */ l("span", { children: e.icon }), /* @__PURE__ */ l("span", { children: e.label })]
|
|
61
|
+
}, e.value))
|
|
62
|
+
})
|
|
63
|
+
})] }) })]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { d as MultiSelectTags };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./index6.cjs"),t=require("./index31.cjs"),n=require("./index42.cjs");let r=require("react"),i=require("react/jsx-runtime");function a({selectedOptions:a,maxTagCount:o=`responsive`,onRemove:s,disabled:c,tagRender:l}){let u=(0,r.useRef)(null),[d,f]=(0,r.useState)(a.length),[p,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{if(o===`responsive`&&u.current){let e=u.current,t=e.offsetWidth-60,n=0,r=0,i=Array.from(e.children);for(let e=0;e<i.length;e++){let a=i[e];if(a.classList.contains(`select-tag`)){let e=a.offsetWidth+4;if(n+e<=t)n+=e,r++;else break}}r<a.length?(f(Math.max(1,r-1)),m(a.slice(Math.max(1,r-1)))):(f(a.length),m([]))}else typeof o==`number`?(f(Math.min(o,a.length)),m(a.slice(o))):(f(a.length),m([]))},[a,o]);let h=l||((t,r)=>(0,i.jsxs)(e.Badge,{variant:`secondary`,className:`select-tag flex items-center gap-1 px-2 py-0.5 text-xs whitespace-nowrap`,children:[t.icon&&(0,i.jsx)(`span`,{className:`text-xs`,children:t.icon}),(0,i.jsx)(`span`,{className:`truncate max-w-[100px]`,children:t.label}),!c&&(0,i.jsx)(n.Icons.XIcon,{className:`w-3 h-3 cursor-pointer hover:text-destructive`,onClick:e=>{e.stopPropagation(),r()}})]},t.value));return(0,i.jsxs)(`div`,{ref:u,className:`flex items-center gap-1 flex-wrap flex-1 min-w-0`,children:[a.slice(0,d).map(e=>h(e,()=>s(e.value))),p.length>0&&(0,i.jsx)(t.TooltipProvider,{children:(0,i.jsxs)(t.Tooltip,{children:[(0,i.jsx)(t.TooltipTrigger,{asChild:!0,children:(0,i.jsxs)(e.Badge,{variant:`outline`,className:`cursor-help text-xs px-2 py-0.5`,children:[`+`,p.length]})}),(0,i.jsx)(t.TooltipContent,{side:`bottom`,className:`max-w-xs`,children:(0,i.jsx)(`div`,{className:`flex flex-col gap-1`,children:p.map(e=>(0,i.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[e.icon&&(0,i.jsx)(`span`,{children:e.icon}),(0,i.jsx)(`span`,{children:e.label})]},e.value))})})]})})]})}exports.MultiSelectTags=a;
|