shadcn-data-views 1.0.3 → 1.0.5
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 +77 -1
- package/dist/index.d.mts +848 -2
- package/dist/index.d.ts +848 -2
- package/dist/index.js +2513 -696
- package/dist/index.mjs +2464 -652
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ A powerful, schema-driven data view component for React, built with modern aesth
|
|
|
17
17
|
- **Form**: auto-generated input forms.
|
|
18
18
|
- **Backend Agnostic**: You provide the `dbClient` implementation. It works with any data source: REST APIs, Supabase, Firebase, or even LocalStorage.
|
|
19
19
|
- **Beautiful Design**: Built with modern design principles (shadcn-like), featuring smooth transitions and a clean aesthetic.
|
|
20
|
+
- **Global Ready (i18n)**: Built-in support for 10 languages with automatic RTL support (e.g., Arabic).
|
|
20
21
|
- **Type-Safe**: Written in TypeScript with comprehensive type definitions.
|
|
21
22
|
|
|
22
23
|
## Use Cases
|
|
@@ -105,13 +106,88 @@ export default function App() {
|
|
|
105
106
|
<DataViews
|
|
106
107
|
schema={mySchema}
|
|
107
108
|
dbClient={dbClient}
|
|
108
|
-
config={{
|
|
109
|
+
config={{
|
|
110
|
+
defaultView: 'grid',
|
|
111
|
+
language: 'es' // Optional: set language (defaults to 'en')
|
|
112
|
+
}}
|
|
109
113
|
/>
|
|
110
114
|
</div>
|
|
111
115
|
);
|
|
112
116
|
}
|
|
113
117
|
```
|
|
114
118
|
|
|
119
|
+
### Color Palette
|
|
120
|
+
|
|
121
|
+
The package includes 50 predefined colors for select field options. You can import and use them when defining your schema:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { PRESET_COLORS } from 'shadcn-data-views';
|
|
125
|
+
|
|
126
|
+
const mySchema: TableSchema = {
|
|
127
|
+
id: 'tasks',
|
|
128
|
+
name: 'Tasks',
|
|
129
|
+
fields: [
|
|
130
|
+
{
|
|
131
|
+
id: 'status',
|
|
132
|
+
name: 'Status',
|
|
133
|
+
type: 'select',
|
|
134
|
+
options: [
|
|
135
|
+
{ id: 'todo', name: 'To Do', color: 'gray' },
|
|
136
|
+
{ id: 'in_progress', name: 'In Progress', color: 'blue' },
|
|
137
|
+
{ id: 'done', name: 'Done', color: 'green' },
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Available colors include: `red`, `blue`, `green`, `yellow`, `orange`, `purple`, `pink`, `brown`, `gray`, `cyan`, `magenta`, `lime`, `indigo`, `teal`, `violet`, `rose`, `fuchsia`, `sky`, `emerald`, `amber`, and many more. See `PRESET_COLORS` export for the full list.
|
|
145
|
+
|
|
146
|
+
### Internationalization (i18n)
|
|
147
|
+
|
|
148
|
+
The package supports 10 languages with automatic RTL (Right-to-Left) support:
|
|
149
|
+
|
|
150
|
+
**Supported Languages:**
|
|
151
|
+
|
|
152
|
+
| Code | Language | Native | Direction |
|
|
153
|
+
|------|----------|--------|-----------|
|
|
154
|
+
| `en` | English | English | LTR |
|
|
155
|
+
| `es` | Spanish | Español | LTR |
|
|
156
|
+
| `zh` | Chinese | 中文 | LTR |
|
|
157
|
+
| `ar` | Arabic | العربية | **RTL** |
|
|
158
|
+
| `hi` | Hindi | हिन्दी | LTR |
|
|
159
|
+
| `fr` | French | Français | LTR |
|
|
160
|
+
| `pt` | Portuguese | Português | LTR |
|
|
161
|
+
| `ru` | Russian | Русский | LTR |
|
|
162
|
+
| `de` | German | Deutsch | LTR |
|
|
163
|
+
| `ja` | Japanese | 日本語 | LTR |
|
|
164
|
+
|
|
165
|
+
**Usage:**
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { DataViews } from 'shadcn-data-views';
|
|
169
|
+
|
|
170
|
+
<DataViews
|
|
171
|
+
schema={mySchema}
|
|
172
|
+
dbClient={myClient}
|
|
173
|
+
config={{ language: 'ar' }} // Arabic with RTL support
|
|
174
|
+
/>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The component automatically:
|
|
178
|
+
- Translates all UI text
|
|
179
|
+
- Applies RTL layout for Arabic
|
|
180
|
+
- Maintains proper text direction for all elements
|
|
181
|
+
|
|
182
|
+
You can also import translation utilities:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { getTranslation, getDirection, LANGUAGES } from 'shadcn-data-views';
|
|
186
|
+
|
|
187
|
+
const text = getTranslation('es', 'addRecord'); // "Agregar Registro"
|
|
188
|
+
const dir = getDirection('ar'); // "rtl"
|
|
189
|
+
```
|
|
190
|
+
|
|
115
191
|
### Configuration
|
|
116
192
|
|
|
117
193
|
You can customize the component via the `config` prop:
|