@tempots/beatui 0.14.0 → 0.16.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 +167 -5
- package/dist/{ar-C__uXRig.js → ar-C7sFBvd3.js} +4 -1
- package/dist/beatui.css +1 -1
- package/dist/{de-CaqDmb7M.js → de-g1A7pWNb.js} +4 -1
- package/dist/{es-D2MgpsFw.js → es-VVHXE2N_.js} +4 -1
- package/dist/{fa-7Lh__M6_.js → fa-CJNIz_z3.js} +4 -1
- package/dist/{fr-BFb9eub-.js → fr-CV72Obmu.js} +4 -1
- package/dist/{he-DCxEMw1h.js → he-B7FDQHq5.js} +4 -1
- package/dist/{hi-Bbnlpps9.js → hi-BCajgsBt.js} +4 -1
- package/dist/index.es.js +3146 -2598
- package/dist/index.umd.js +18 -18
- package/dist/{it-CWTDpmhc.js → it-BeJHf7Ur.js} +4 -1
- package/dist/{ja-C1Nynl79.js → ja-D5YyTu5k.js} +4 -1
- package/dist/{ko-BnQv3_8f.js → ko-DNqvHWiZ.js} +4 -1
- package/dist/{nl-CH2009II.js → nl-Cdbu51NB.js} +4 -1
- package/dist/{pl-Cd4dZDyG.js → pl-Bru8UPLn.js} +7 -4
- package/dist/{pt-CZER9j0r.js → pt-LCfmUFgc.js} +4 -1
- package/dist/{ru-CCEGJYwF.js → ru-D7gTuXxP.js} +4 -1
- package/dist/{tr-BVIGQcgy.js → tr-DlFekEUg.js} +4 -1
- package/dist/types/beatui-i18n/default.d.ts +2 -0
- package/dist/types/beatui-i18n/locales/en.d.ts +2 -0
- package/dist/types/beatui-i18n/translations.d.ts +2 -0
- package/dist/types/components/data/index.d.ts +1 -0
- package/dist/types/components/data/unstyled-drop-zone.d.ts +12 -0
- package/dist/types/components/form/control/file-control.d.ts +11 -0
- package/dist/types/components/form/control/index.d.ts +1 -0
- package/dist/types/components/form/controller/color-controller.d.ts +75 -0
- package/dist/types/components/form/controller/index.d.ts +1 -0
- package/dist/types/components/form/input/color-input.d.ts +2 -0
- package/dist/types/components/form/input/file-input.d.ts +11 -0
- package/dist/types/components/form/input/index.d.ts +2 -0
- package/dist/types/components/form/input/input-options.d.ts +2 -1
- package/dist/types/components/navigation/index.d.ts +1 -0
- package/dist/types/components/navigation/tabs/index.d.ts +1 -0
- package/dist/types/components/navigation/tabs/tabs.d.ts +52 -0
- package/dist/types/utils/color-validation.d.ts +64 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/{ur-BVAP8WLA.js → ur-mIO25A6L.js} +4 -1
- package/dist/{vi-Dv4aIcRH.js → vi-Dw_DDZWP.js} +4 -1
- package/dist/{zh-BcAbijvs.js → zh-Dojj6P4C.js} +4 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# TODO
|
|
2
2
|
|
|
3
3
|
- [ ] Form
|
|
4
|
+
|
|
4
5
|
- [ ] submitting
|
|
5
6
|
- [ ] validation strategy
|
|
6
7
|
- [ ] validate on submit
|
|
@@ -74,45 +75,49 @@ Import the CSS in your main CSS file or entry point:
|
|
|
74
75
|
Or import it in your JavaScript/TypeScript entry point:
|
|
75
76
|
|
|
76
77
|
```typescript
|
|
77
|
-
import '@tempots/beatui/css'
|
|
78
|
+
import '@tempots/beatui/css'
|
|
78
79
|
```
|
|
79
80
|
|
|
80
81
|
## Usage
|
|
81
82
|
|
|
82
83
|
```typescript
|
|
83
|
-
import { createButton, createCard } from '@tempots/beatui'
|
|
84
|
+
import { createButton, createCard } from '@tempots/beatui'
|
|
84
85
|
|
|
85
86
|
// Create a button
|
|
86
87
|
const button = createButton({
|
|
87
88
|
text: 'Click me',
|
|
88
89
|
variant: 'filled',
|
|
89
90
|
onClick: () => console.log('Button clicked'),
|
|
90
|
-
})
|
|
91
|
+
})
|
|
91
92
|
|
|
92
93
|
// Create a card with the button
|
|
93
94
|
const card = createCard({
|
|
94
95
|
title: 'My Card',
|
|
95
96
|
content: 'This is a card component from BeatUI Library',
|
|
96
97
|
children: [button],
|
|
97
|
-
})
|
|
98
|
+
})
|
|
98
99
|
|
|
99
100
|
// Add the card to the DOM
|
|
100
|
-
document.body.appendChild(card)
|
|
101
|
+
document.body.appendChild(card)
|
|
101
102
|
```
|
|
102
103
|
|
|
103
104
|
## Available Components
|
|
104
105
|
|
|
105
106
|
### Form Components
|
|
107
|
+
|
|
106
108
|
- Button - Interactive buttons with multiple variants
|
|
107
109
|
- Input - Text input fields with validation
|
|
108
110
|
- Checkbox - Checkbox inputs with custom styling
|
|
111
|
+
- Color Input - Color picker input with validation and format conversion
|
|
109
112
|
- Tags Input - Multi-tag input field
|
|
110
113
|
|
|
111
114
|
### Layout Components
|
|
115
|
+
|
|
112
116
|
- App Shell - Application layout structure
|
|
113
117
|
- Overlay - Modal and overlay components
|
|
114
118
|
|
|
115
119
|
### Data Components
|
|
120
|
+
|
|
116
121
|
- Tag - Individual tag component
|
|
117
122
|
|
|
118
123
|
## CSS Architecture
|
|
@@ -185,12 +190,14 @@ pnpm run release:commit:dry
|
|
|
185
190
|
### Release Process
|
|
186
191
|
|
|
187
192
|
Each release script follows this workflow:
|
|
193
|
+
|
|
188
194
|
1. **Prepare**: Clean previous builds, build package, run all tests
|
|
189
195
|
2. **Version**: Update the version number in package.json and create git tag
|
|
190
196
|
3. **Publish**: Publish to npm (bypassing git checks since version step creates changes)
|
|
191
197
|
4. **Commit**: Add package.json changes and commit with release message
|
|
192
198
|
|
|
193
199
|
The workflow ensures that:
|
|
200
|
+
|
|
194
201
|
- All tests pass before any version changes
|
|
195
202
|
- Package builds successfully before publishing
|
|
196
203
|
- Git tags are created for version tracking
|
|
@@ -211,11 +218,13 @@ The workflow ensures that:
|
|
|
211
218
|
**Automatic Git Commits (Default)**
|
|
212
219
|
|
|
213
220
|
The main release scripts automatically commit version changes after successful publish:
|
|
221
|
+
|
|
214
222
|
- Add the updated `package.json` to git staging
|
|
215
223
|
- Create a commit with the message: `chore: release @tempots/beatui@{version}`
|
|
216
224
|
- This keeps your git history in sync with published versions
|
|
217
225
|
|
|
218
226
|
Example commit messages:
|
|
227
|
+
|
|
219
228
|
- `chore: release @tempots/beatui@1.0.0`
|
|
220
229
|
- `chore: release @tempots/beatui@1.1.0`
|
|
221
230
|
- `chore: release @tempots/beatui@1.0.1`
|
|
@@ -223,6 +232,7 @@ Example commit messages:
|
|
|
223
232
|
**Manual Git Handling**
|
|
224
233
|
|
|
225
234
|
If you prefer to handle git commits manually, use the `:no-commit` variants:
|
|
235
|
+
|
|
226
236
|
- `pnpm run release:patch:no-commit`
|
|
227
237
|
- `pnpm run release:minor:no-commit`
|
|
228
238
|
- `pnpm run release:major:no-commit`
|
|
@@ -230,6 +240,158 @@ If you prefer to handle git commits manually, use the `:no-commit` variants:
|
|
|
230
240
|
|
|
231
241
|
These scripts will publish successfully but leave git operations to you.
|
|
232
242
|
|
|
243
|
+
## Color Picker Component
|
|
244
|
+
|
|
245
|
+
The Color Picker component provides an intuitive interface for color selection with comprehensive validation and format conversion capabilities.
|
|
246
|
+
|
|
247
|
+
### Basic Usage
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { ColorInput, prop } from '@tempots/beatui'
|
|
251
|
+
|
|
252
|
+
const color = prop('#3b82f6')
|
|
253
|
+
|
|
254
|
+
const colorPicker = ColorInput({
|
|
255
|
+
value: color,
|
|
256
|
+
onChange: newColor => console.log('Color changed:', newColor),
|
|
257
|
+
id: 'my-color-picker',
|
|
258
|
+
})
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### With Form Controller
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import {
|
|
265
|
+
ColorInput,
|
|
266
|
+
createColorController,
|
|
267
|
+
colorInputOptionsFromController,
|
|
268
|
+
useForm,
|
|
269
|
+
isValidHexColor,
|
|
270
|
+
} from '@tempots/beatui'
|
|
271
|
+
import { z } from 'zod'
|
|
272
|
+
|
|
273
|
+
const { controller } = useForm({
|
|
274
|
+
schema: z.object({
|
|
275
|
+
primaryColor: z
|
|
276
|
+
.string()
|
|
277
|
+
.refine(isValidHexColor, 'Must be a valid hex color'),
|
|
278
|
+
secondaryColor: z
|
|
279
|
+
.string()
|
|
280
|
+
.refine(isValidHexColor, 'Must be a valid hex color'),
|
|
281
|
+
}),
|
|
282
|
+
defaultValue: {
|
|
283
|
+
primaryColor: '#3b82f6',
|
|
284
|
+
secondaryColor: '#10b981',
|
|
285
|
+
},
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
const primaryColorController = createColorController(
|
|
289
|
+
controller.field('primaryColor')
|
|
290
|
+
)
|
|
291
|
+
const secondaryColorController = createColorController(
|
|
292
|
+
controller.field('secondaryColor')
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
// Use with input options
|
|
296
|
+
const primaryColorInput = ColorInput(
|
|
297
|
+
colorInputOptionsFromController(primaryColorController)
|
|
298
|
+
)
|
|
299
|
+
const secondaryColorInput = ColorInput(
|
|
300
|
+
colorInputOptionsFromController(secondaryColorController)
|
|
301
|
+
)
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Color Controller Features
|
|
305
|
+
|
|
306
|
+
The `ColorController` extends the base `Controller` with color-specific functionality:
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// Validation
|
|
310
|
+
controller.isValidColor.value // boolean - validates any supported color format
|
|
311
|
+
controller.isValidHex.value // boolean - validates hex colors specifically
|
|
312
|
+
|
|
313
|
+
// Normalization
|
|
314
|
+
controller.normalizedHex.value // string - always returns 6-character hex with #
|
|
315
|
+
|
|
316
|
+
// Color manipulation
|
|
317
|
+
controller.setColor('#f00') // Sets and normalizes hex colors
|
|
318
|
+
controller.setHex('#ff0000') // Sets hex color specifically
|
|
319
|
+
controller.setRgb(255, 0, 0) // Sets color from RGB values
|
|
320
|
+
|
|
321
|
+
// Format conversion
|
|
322
|
+
controller.getRgb() // Returns { r: 255, g: 0, b: 0 } or null
|
|
323
|
+
controller.withFormat('rgb') // Returns controller with RGB format transformation
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Color Validation Utilities
|
|
327
|
+
|
|
328
|
+
BeatUI includes comprehensive color validation utilities:
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import {
|
|
332
|
+
isValidHexColor,
|
|
333
|
+
isValidRgbColor,
|
|
334
|
+
isValidRgbaColor,
|
|
335
|
+
isValidHslColor,
|
|
336
|
+
isValidColor,
|
|
337
|
+
normalizeHexColor,
|
|
338
|
+
rgbToHex,
|
|
339
|
+
hexToRgb,
|
|
340
|
+
getContrastRatio,
|
|
341
|
+
} from '@tempots/beatui'
|
|
342
|
+
|
|
343
|
+
// Validation
|
|
344
|
+
isValidHexColor('#ff0000') // true
|
|
345
|
+
isValidRgbColor('rgb(255, 0, 0)') // true
|
|
346
|
+
isValidColor('#invalid') // false
|
|
347
|
+
|
|
348
|
+
// Normalization and conversion
|
|
349
|
+
normalizeHexColor('#f00') // '#ff0000'
|
|
350
|
+
rgbToHex(255, 0, 0) // '#ff0000'
|
|
351
|
+
hexToRgb('#ff0000') // { r: 255, g: 0, b: 0 }
|
|
352
|
+
|
|
353
|
+
// Accessibility
|
|
354
|
+
getContrastRatio('#000000', '#ffffff') // 21 (maximum contrast)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Supported Color Formats
|
|
358
|
+
|
|
359
|
+
- **Hex Colors**: `#fff`, `#ffffff`, `fff`, `ffffff`
|
|
360
|
+
- **RGB Colors**: `rgb(255, 0, 0)`
|
|
361
|
+
- **RGBA Colors**: `rgba(255, 0, 0, 0.5)`
|
|
362
|
+
- **HSL Colors**: `hsl(0, 100%, 50%)`
|
|
363
|
+
|
|
364
|
+
### Features
|
|
365
|
+
|
|
366
|
+
- **Native HTML5 Color Input**: Uses the browser's native color picker
|
|
367
|
+
- **Automatic Normalization**: Hex colors are automatically normalized to 6-character format
|
|
368
|
+
- **Format Conversion**: Convert between hex, RGB, and other color formats
|
|
369
|
+
- **Validation**: Comprehensive validation for all supported color formats
|
|
370
|
+
- **Accessibility**: WCAG contrast ratio calculation for accessibility compliance
|
|
371
|
+
- **Form Integration**: Seamless integration with BeatUI's form system
|
|
372
|
+
- **TypeScript Support**: Full type safety with TypeScript
|
|
373
|
+
- **Responsive Design**: Works across all device sizes
|
|
374
|
+
- **Dark Mode**: Full dark mode support
|
|
375
|
+
|
|
376
|
+
### CSS Classes
|
|
377
|
+
|
|
378
|
+
The Color Picker uses the following CSS classes:
|
|
379
|
+
|
|
380
|
+
- `.bc-color-input` - Main color input styling
|
|
381
|
+
- `.bc-input-container` - Container wrapper (inherited from InputContainer)
|
|
382
|
+
- `.bc-input-container--error` - Error state styling
|
|
383
|
+
|
|
384
|
+
### Browser Support
|
|
385
|
+
|
|
386
|
+
The Color Picker component uses the HTML5 `<input type="color">` element, which is supported in:
|
|
387
|
+
|
|
388
|
+
- Chrome 20+
|
|
389
|
+
- Firefox 29+
|
|
390
|
+
- Safari 12.1+
|
|
391
|
+
- Edge 14+
|
|
392
|
+
|
|
393
|
+
For older browsers, the input will gracefully degrade to a text input.
|
|
394
|
+
|
|
233
395
|
## License
|
|
234
396
|
|
|
235
397
|
MIT
|
|
@@ -39,7 +39,10 @@ const e = {
|
|
|
39
39
|
fa: () => "الفارسية",
|
|
40
40
|
ur: () => "الأردية",
|
|
41
41
|
// input
|
|
42
|
-
emailPlaceholderText: () => "بريدك الإلكتروني"
|
|
42
|
+
emailPlaceholderText: () => "بريدك الإلكتروني",
|
|
43
|
+
// drop zone
|
|
44
|
+
dropZoneInstructions: () => "اسحب وأفلت الملفات هنا",
|
|
45
|
+
dropZoneInstructionsWithClick: () => "اسحب وأفلت الملفات هنا، أو اضغط Enter أو Space لفتح محدد الملفات"
|
|
43
46
|
};
|
|
44
47
|
export {
|
|
45
48
|
e as default
|