@tempots/beatui 0.14.0 → 0.15.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/beatui.css +1 -1
- package/dist/index.es.js +2682 -2353
- package/dist/index.umd.js +18 -18
- 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/index.d.ts +1 -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/package.json +3 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Controller } from './controller';
|
|
2
|
+
import { Signal } from '@tempots/dom';
|
|
3
|
+
import { Path } from './path';
|
|
4
|
+
import { ControllerValidation } from './controller-validation';
|
|
5
|
+
/**
|
|
6
|
+
* Specialized controller for color values with validation and transformation utilities
|
|
7
|
+
*/
|
|
8
|
+
export declare class ColorController extends Controller<string> {
|
|
9
|
+
constructor(path: Path, change: (value: string) => void, value: Signal<string>, status: Signal<ControllerValidation>, parent: {
|
|
10
|
+
disabled: Signal<boolean>;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Validates that the current value is a valid color
|
|
14
|
+
*/
|
|
15
|
+
readonly isValidColor: import("@tempots/dom").Computed<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Validates that the current value is a valid hex color
|
|
18
|
+
*/
|
|
19
|
+
readonly isValidHex: import("@tempots/dom").Computed<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the normalized hex color (always 6 characters with # prefix)
|
|
22
|
+
*/
|
|
23
|
+
readonly normalizedHex: import("@tempots/dom").Computed<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Sets the color value with automatic normalization for hex colors
|
|
26
|
+
* @param color - The color value to set
|
|
27
|
+
*/
|
|
28
|
+
readonly setColor: (color: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Sets a hex color value
|
|
31
|
+
* @param hex - The hex color value (with or without #)
|
|
32
|
+
*/
|
|
33
|
+
readonly setHex: (hex: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Sets an RGB color value
|
|
36
|
+
* @param r - Red value (0-255)
|
|
37
|
+
* @param g - Green value (0-255)
|
|
38
|
+
* @param b - Blue value (0-255)
|
|
39
|
+
*/
|
|
40
|
+
readonly setRgb: (r: number, g: number, b: number) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Gets RGB values from the current color
|
|
43
|
+
* @returns RGB values or null if not a valid hex color
|
|
44
|
+
*/
|
|
45
|
+
readonly getRgb: () => {
|
|
46
|
+
r: number;
|
|
47
|
+
g: number;
|
|
48
|
+
b: number;
|
|
49
|
+
} | null;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a controller that transforms between different color formats
|
|
52
|
+
* @param format - The target color format ('hex', 'rgb', 'hsl')
|
|
53
|
+
* @returns A new controller with format transformation
|
|
54
|
+
*/
|
|
55
|
+
readonly withFormat: (format: "hex" | "rgb" | "hsl") => Controller<string>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a ColorController from a regular Controller<string>
|
|
59
|
+
* @param controller - The base string controller
|
|
60
|
+
* @returns A new ColorController with color-specific functionality
|
|
61
|
+
*/
|
|
62
|
+
export declare function createColorController(controller: Controller<string>): ColorController;
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to create color input options from a ColorController
|
|
65
|
+
* @param controller - The ColorController instance
|
|
66
|
+
* @returns Input options compatible with ColorInput component
|
|
67
|
+
*/
|
|
68
|
+
export declare function colorInputOptionsFromController(controller: ColorController): {
|
|
69
|
+
id: string;
|
|
70
|
+
disabled: Signal<boolean>;
|
|
71
|
+
value: import("@tempots/dom").Computed<string>;
|
|
72
|
+
hasError: Signal<boolean>;
|
|
73
|
+
onChange: (color: string) => void;
|
|
74
|
+
onInput: (color: string) => void;
|
|
75
|
+
};
|
|
@@ -10,6 +10,7 @@ export type CommonInputOptions = {
|
|
|
10
10
|
name?: Value<string>;
|
|
11
11
|
placeholder?: Value<string>;
|
|
12
12
|
id?: Value<string>;
|
|
13
|
+
required?: Value<boolean>;
|
|
13
14
|
};
|
|
14
15
|
export type InputOptions<V> = Merge<CommonInputOptions, {
|
|
15
16
|
value: Value<V>;
|
|
@@ -19,7 +20,7 @@ export type InputOptions<V> = Merge<CommonInputOptions, {
|
|
|
19
20
|
onInput?: (value: V) => void;
|
|
20
21
|
onBlur?: () => void;
|
|
21
22
|
}>;
|
|
22
|
-
export declare const CommonInputAttributes: ({ autocomplete, autofocus, class: cls, disabled, name, placeholder, id, }: CommonInputOptions) => import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
|
|
23
|
+
export declare const CommonInputAttributes: ({ autocomplete, autofocus, class: cls, disabled, name, placeholder, id, required, hasError, }: CommonInputOptions) => import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
|
|
23
24
|
export declare const inputOptionsFromController: <T>(controller: Controller<T>) => {
|
|
24
25
|
id: string;
|
|
25
26
|
disabled: import("@tempots/dom").Signal<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tabs';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TNode, Value } from '@tempots/dom';
|
|
2
|
+
import { ControlSize } from '../../theme';
|
|
3
|
+
export interface TabItem {
|
|
4
|
+
/** Unique identifier for the tab */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Tab label content */
|
|
7
|
+
label: TNode;
|
|
8
|
+
/** Tab content to display when active */
|
|
9
|
+
content: () => TNode;
|
|
10
|
+
/** Whether the tab is disabled */
|
|
11
|
+
disabled?: Value<boolean>;
|
|
12
|
+
/** ARIA label for accessibility */
|
|
13
|
+
ariaLabel?: Value<string>;
|
|
14
|
+
}
|
|
15
|
+
export type TabsDirection = 'horizontal' | 'vertical';
|
|
16
|
+
export interface TabsOptions {
|
|
17
|
+
/** Array of tab items */
|
|
18
|
+
items: TabItem[];
|
|
19
|
+
/** Currently active tab key */
|
|
20
|
+
value: Value<string>;
|
|
21
|
+
/** Callback when tab changes */
|
|
22
|
+
onChange?: (key: string) => void;
|
|
23
|
+
/** Size of the tabs */
|
|
24
|
+
size?: Value<ControlSize>;
|
|
25
|
+
/** Whether tabs are disabled */
|
|
26
|
+
disabled?: Value<boolean>;
|
|
27
|
+
/** Orientation of the tabs */
|
|
28
|
+
orientation?: Value<TabsDirection>;
|
|
29
|
+
/** Whether to show tab content */
|
|
30
|
+
showContent?: Value<boolean>;
|
|
31
|
+
/** ARIA label for the tab list */
|
|
32
|
+
ariaLabel?: Value<string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Tabs component that provides tabbed navigation with content panels.
|
|
36
|
+
* Follows WAI-ARIA tabs pattern with proper keyboard navigation and accessibility.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const activeTab = prop('tab1')
|
|
41
|
+
*
|
|
42
|
+
* Tabs({
|
|
43
|
+
* items: [
|
|
44
|
+
* { key: 'tab1', label: 'First Tab', content: html.div('Content 1') },
|
|
45
|
+
* { key: 'tab2', label: 'Second Tab', content: html.div('Content 2') },
|
|
46
|
+
* ],
|
|
47
|
+
* value: activeTab,
|
|
48
|
+
* onChange: activeTab.set
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function Tabs(options: TabsOptions): TNode;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color validation utilities for BeatUI color inputs
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Validates if a string is a valid hex color
|
|
6
|
+
* @param color - The color string to validate
|
|
7
|
+
* @returns true if valid hex color, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidHexColor(color: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Validates if a string is a valid RGB color
|
|
12
|
+
* @param color - The color string to validate (e.g., "rgb(255, 0, 0)")
|
|
13
|
+
* @returns true if valid RGB color, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function isValidRgbColor(color: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Validates if a string is a valid RGBA color
|
|
18
|
+
* @param color - The color string to validate (e.g., "rgba(255, 0, 0, 0.5)")
|
|
19
|
+
* @returns true if valid RGBA color, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
export declare function isValidRgbaColor(color: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Validates if a string is a valid HSL color
|
|
24
|
+
* @param color - The color string to validate (e.g., "hsl(120, 100%, 50%)")
|
|
25
|
+
* @returns true if valid HSL color, false otherwise
|
|
26
|
+
*/
|
|
27
|
+
export declare function isValidHslColor(color: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Validates if a string is any valid color format
|
|
30
|
+
* @param color - The color string to validate
|
|
31
|
+
* @returns true if valid color in any supported format, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidColor(color: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes a hex color to always include the # prefix and be 6 characters
|
|
36
|
+
* @param color - The hex color to normalize
|
|
37
|
+
* @returns normalized hex color or null if invalid
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizeHexColor(color: string): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Converts RGB values to hex color
|
|
42
|
+
* @param r - Red value (0-255)
|
|
43
|
+
* @param g - Green value (0-255)
|
|
44
|
+
* @param b - Blue value (0-255)
|
|
45
|
+
* @returns hex color string
|
|
46
|
+
*/
|
|
47
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Converts hex color to RGB values
|
|
50
|
+
* @param hex - Hex color string (with or without #)
|
|
51
|
+
* @returns RGB values object or null if invalid
|
|
52
|
+
*/
|
|
53
|
+
export declare function hexToRgb(hex: string): {
|
|
54
|
+
r: number;
|
|
55
|
+
g: number;
|
|
56
|
+
b: number;
|
|
57
|
+
} | null;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the contrast ratio between two colors
|
|
60
|
+
* @param color1 - First color (hex format)
|
|
61
|
+
* @param color2 - Second color (hex format)
|
|
62
|
+
* @returns contrast ratio or null if invalid colors
|
|
63
|
+
*/
|
|
64
|
+
export declare function getContrastRatio(color1: string, color2: string): number | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempots/beatui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"registry": "https://registry.npmjs.org/"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@tempots/dom": "28.
|
|
57
|
+
"@tempots/dom": "28.4.5",
|
|
58
58
|
"@tempots/std": "0.22.1",
|
|
59
|
-
"@tempots/ui": "6.
|
|
59
|
+
"@tempots/ui": "6.4.1"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"@tempots/dom": {
|