softable-pixels-web 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 +22 -0
- package/dist/TabSwitch-D6OPAUjC.js +304 -0
- package/dist/TabSwitch-D6OPAUjC.js.map +1 -0
- package/dist/ThemeContext-CRXby8a0.js +539 -0
- package/dist/ThemeContext-CRXby8a0.js.map +1 -0
- package/dist/index-CZOu4S--.d.ts +69 -0
- package/dist/index-jFi4YRO5.d.ts +277 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/mask-modules.d.ts +144 -0
- package/dist/mask-modules.js +705 -0
- package/dist/mask-modules.js.map +1 -0
- package/dist/tab-switch.d.ts +2 -0
- package/dist/tab-switch.js +3 -0
- package/dist/theme-context.d.ts +2 -0
- package/dist/theme-context.js +3 -0
- package/package.json +67 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/functions/deepMerge.d.ts
|
|
4
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */
|
|
5
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/contexts/ThemeContext/types.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* ThemeName
|
|
10
|
+
* ---------
|
|
11
|
+
* A theme identifier string.
|
|
12
|
+
*
|
|
13
|
+
* Examples:
|
|
14
|
+
* - "light"
|
|
15
|
+
* - "dark"
|
|
16
|
+
* - "dev"
|
|
17
|
+
* - "prod"
|
|
18
|
+
* - "brandA"
|
|
19
|
+
*/
|
|
20
|
+
type ThemeName = string;
|
|
21
|
+
/**
|
|
22
|
+
* ThemeMode
|
|
23
|
+
* ---------
|
|
24
|
+
* The value users can select at runtime.
|
|
25
|
+
*
|
|
26
|
+
* - `"system"`: resolves automatically to `"light"` or `"dark"` using
|
|
27
|
+
* the OS/browser preference (`prefers-color-scheme`).
|
|
28
|
+
* - any other string: treated as a concrete theme name.
|
|
29
|
+
*
|
|
30
|
+
* Examples:
|
|
31
|
+
* - "system" (default)
|
|
32
|
+
* - "light"
|
|
33
|
+
* - "dark"
|
|
34
|
+
* - "dev"
|
|
35
|
+
*/
|
|
36
|
+
type ThemeMode = 'system' | ThemeName;
|
|
37
|
+
/**
|
|
38
|
+
* ThemeTokens
|
|
39
|
+
* ----------
|
|
40
|
+
* The fully-resolved theme object used by the component library.
|
|
41
|
+
*
|
|
42
|
+
* IMPORTANT:
|
|
43
|
+
* - Inside the library, components should assume `ThemeTokens` is complete.
|
|
44
|
+
* - Consumers are allowed to pass partial theme objects (DeepPartial), but the
|
|
45
|
+
* ThemeProvider MUST merge them on top of a complete base theme (light/dark defaults),
|
|
46
|
+
* ensuring the final `theme` is always safe to read at runtime.
|
|
47
|
+
*
|
|
48
|
+
* Design principles:
|
|
49
|
+
* - Keep tokens semantic (primary/surface/text/border) rather than raw palette names.
|
|
50
|
+
* - Provide neutral tokens (background/surface/border/text) + semantic intents (success/warning/etc).
|
|
51
|
+
* - Keep the structure stable; adding tokens is non-breaking, removing is breaking.
|
|
52
|
+
*/
|
|
53
|
+
interface ThemeTokens {
|
|
54
|
+
/**
|
|
55
|
+
* Color tokens.
|
|
56
|
+
*
|
|
57
|
+
* Suggested usage:
|
|
58
|
+
* - `primary`: brand accent color (buttons, highlights)
|
|
59
|
+
* - `secondary`: secondary text or subtle accents
|
|
60
|
+
* - intents (`success`, `warning`, `error`, `info`): feedback states
|
|
61
|
+
* - `background`: main page background
|
|
62
|
+
* - `surface`: elevated surface (cards, panels)
|
|
63
|
+
* - `border`: borders/dividers
|
|
64
|
+
* - `text`: primary/secondary/disabled/inverse text colors
|
|
65
|
+
*/
|
|
66
|
+
colors: {
|
|
67
|
+
/** Main brand/accent color */
|
|
68
|
+
primary: string;
|
|
69
|
+
/** Secondary accent or subtle text color */
|
|
70
|
+
secondary: string;
|
|
71
|
+
/** Semantic colors (feedback) */
|
|
72
|
+
success: string;
|
|
73
|
+
warning: string;
|
|
74
|
+
error: string;
|
|
75
|
+
info: string;
|
|
76
|
+
/** Neutral surfaces */
|
|
77
|
+
background: string;
|
|
78
|
+
surface: string;
|
|
79
|
+
/** Border colors */
|
|
80
|
+
border: {
|
|
81
|
+
/** Primary border/divider color */
|
|
82
|
+
primary: string;
|
|
83
|
+
/** Secondary border color (less prominent) */
|
|
84
|
+
secondary: string;
|
|
85
|
+
};
|
|
86
|
+
/** Text colors */
|
|
87
|
+
text: {
|
|
88
|
+
/** Primary text color */
|
|
89
|
+
primary: string;
|
|
90
|
+
/** Secondary text color (muted) */
|
|
91
|
+
secondary: string;
|
|
92
|
+
/** Disabled text color */
|
|
93
|
+
disabled: string;
|
|
94
|
+
/** Text color to use on top of strong backgrounds (e.g. primary buttons) */
|
|
95
|
+
inverse: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Spacing scale (in px numbers, usually converted to `px` in styles).
|
|
100
|
+
* Keeps spacing consistent across components.
|
|
101
|
+
*/
|
|
102
|
+
spacing: Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl', number>;
|
|
103
|
+
/**
|
|
104
|
+
* Border radius scale (in px numbers).
|
|
105
|
+
*/
|
|
106
|
+
borderRadius: Record<'none' | 'sm' | 'md' | 'lg' | 'full', number>;
|
|
107
|
+
/**
|
|
108
|
+
* Font size scale (in px numbers).
|
|
109
|
+
*/
|
|
110
|
+
fontSize: Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl', number>;
|
|
111
|
+
/**
|
|
112
|
+
* Font weight scale (numeric values).
|
|
113
|
+
*/
|
|
114
|
+
fontWeight: Record<'normal' | 'medium' | 'semibold' | 'bold', number>;
|
|
115
|
+
/**
|
|
116
|
+
* Shadow tokens (CSS shadow strings).
|
|
117
|
+
*/
|
|
118
|
+
shadows: Record<'sm' | 'md' | 'lg' | 'xl', string>;
|
|
119
|
+
/**
|
|
120
|
+
* Extension point.
|
|
121
|
+
*
|
|
122
|
+
* Allows consumers to add custom tokens without type errors.
|
|
123
|
+
* The library should avoid relying on unknown keys unless explicitly supported.
|
|
124
|
+
*/
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* ThemeRegistry
|
|
129
|
+
* -------------
|
|
130
|
+
* A registry of theme entries by name.
|
|
131
|
+
*
|
|
132
|
+
* Rules:
|
|
133
|
+
* - `light` and `dark` must always exist.
|
|
134
|
+
* - Each entry can be:
|
|
135
|
+
* - a full `ThemeTokens`, OR
|
|
136
|
+
* - a `DeepPartial<ThemeTokens>` patch (recommended)
|
|
137
|
+
*
|
|
138
|
+
* Why allow DeepPartial?
|
|
139
|
+
* - Consumers typically want to override only a few tokens, like `colors.primary`,
|
|
140
|
+
* without having to redefine the entire token set.
|
|
141
|
+
*
|
|
142
|
+
* IMPORTANT:
|
|
143
|
+
* - Registry entries should be treated as patches by the ThemeProvider.
|
|
144
|
+
* - The ThemeProvider should always merge patches on top of a complete base theme
|
|
145
|
+
* (usually the library's default light/dark tokens) to guarantee runtime safety.
|
|
146
|
+
*/
|
|
147
|
+
type ThemeRegistry = {
|
|
148
|
+
light: DeepPartial<ThemeTokens> | ThemeTokens;
|
|
149
|
+
dark: DeepPartial<ThemeTokens> | ThemeTokens;
|
|
150
|
+
} & Record<string, DeepPartial<ThemeTokens> | ThemeTokens>;
|
|
151
|
+
/**
|
|
152
|
+
* ThemeContextData
|
|
153
|
+
* ---------------
|
|
154
|
+
* The runtime API exposed by `useTheme()`.
|
|
155
|
+
*
|
|
156
|
+
* Fields:
|
|
157
|
+
* - `mode`: the selected mode ("system" or a theme name)
|
|
158
|
+
* - `resolvedName`: the actual applied theme name (never "system")
|
|
159
|
+
* - `theme`: the resolved theme tokens (should always be complete)
|
|
160
|
+
* - `isLoading`: provider initialization flag
|
|
161
|
+
*
|
|
162
|
+
* Methods:
|
|
163
|
+
* - `setTheme(mode)`: sets the selected theme mode
|
|
164
|
+
* - `toggleTheme(a?, b?)`: toggles between two theme names (defaults to light/dark)
|
|
165
|
+
*/
|
|
166
|
+
type ThemeContextData = {
|
|
167
|
+
/** Selected mode (a theme name or "system") */
|
|
168
|
+
mode: ThemeMode;
|
|
169
|
+
/** Resolved theme name (never "system") */
|
|
170
|
+
resolvedName: ThemeName;
|
|
171
|
+
/** Fully resolved tokens (should be complete) */
|
|
172
|
+
theme: ThemeTokens;
|
|
173
|
+
/** True while provider initializes (first render) */
|
|
174
|
+
isLoading: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Sets the selected theme mode.
|
|
177
|
+
*
|
|
178
|
+
* Examples:
|
|
179
|
+
* - setTheme("system")
|
|
180
|
+
* - setTheme("light")
|
|
181
|
+
* - setTheme("dark")
|
|
182
|
+
* - setTheme("dev")
|
|
183
|
+
*/
|
|
184
|
+
setTheme: (mode: ThemeMode) => void;
|
|
185
|
+
/**
|
|
186
|
+
* Toggles between two theme names (defaults to "light" and "dark").
|
|
187
|
+
*
|
|
188
|
+
* Examples:
|
|
189
|
+
* - toggleTheme() // light <-> dark
|
|
190
|
+
* - toggleTheme("dev", "prod") // dev <-> prod
|
|
191
|
+
*/
|
|
192
|
+
toggleTheme: (a?: ThemeName, b?: ThemeName) => void;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Theme Persistence Adapter
|
|
196
|
+
* ------------------------
|
|
197
|
+
* Optional persistence layer for the selected `mode`.
|
|
198
|
+
*
|
|
199
|
+
* Rules:
|
|
200
|
+
* - Persist the *selected* `mode` (including `"system"`), not the resolvedName.
|
|
201
|
+
* - `get()` can return null/undefined when nothing is stored.
|
|
202
|
+
*/
|
|
203
|
+
type ThemePersistence = {
|
|
204
|
+
/** Read the saved mode. Return null/undefined when absent. */
|
|
205
|
+
get: () => ThemeMode | null | undefined;
|
|
206
|
+
/** Persist the mode. */
|
|
207
|
+
set: (mode: ThemeMode) => void;
|
|
208
|
+
/** Optional: clear persistence (reset). */
|
|
209
|
+
clear?: () => void;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Props for ThemeProvider.
|
|
213
|
+
*/
|
|
214
|
+
type ThemeProviderProps = PropsWithChildren & {
|
|
215
|
+
/**
|
|
216
|
+
* Optional theme registry overrides.
|
|
217
|
+
*
|
|
218
|
+
* - The library ships with built-in `light` and `dark` themes (always complete).
|
|
219
|
+
* - You can override them partially (patch).
|
|
220
|
+
* - You can add additional named themes (e.g. `dev`, `prod`, `brandA`).
|
|
221
|
+
*/
|
|
222
|
+
themes?: Partial<ThemeRegistry>;
|
|
223
|
+
/**
|
|
224
|
+
* Initial selected mode.
|
|
225
|
+
*
|
|
226
|
+
* - `"system"` (default): resolves to `"light"` or `"dark"` based on OS settings.
|
|
227
|
+
* - Any string theme name: resolves directly to that theme name.
|
|
228
|
+
*/
|
|
229
|
+
defaultMode?: ThemeMode;
|
|
230
|
+
/**
|
|
231
|
+
* Optional final patch applied on top of the resolved theme.
|
|
232
|
+
* Useful for temporary/section-level overrides without defining a whole new theme.
|
|
233
|
+
*/
|
|
234
|
+
override?: Partial<ThemeTokens>;
|
|
235
|
+
/**
|
|
236
|
+
* Quick persistence toggle (localStorage).
|
|
237
|
+
*
|
|
238
|
+
* When `true` and `persistence` is NOT provided, ThemeProvider will:
|
|
239
|
+
* - restore initial mode from `localStorage.getItem(storageKey)`
|
|
240
|
+
* - persist mode changes to `localStorage.setItem(storageKey, mode)`
|
|
241
|
+
*
|
|
242
|
+
* Default: false
|
|
243
|
+
*/
|
|
244
|
+
persist?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Storage key used when `persist` is enabled (localStorage mode).
|
|
247
|
+
*
|
|
248
|
+
* Default: "px-theme"
|
|
249
|
+
*/
|
|
250
|
+
storageKey?: string;
|
|
251
|
+
/**
|
|
252
|
+
* Advanced persistence adapter.
|
|
253
|
+
*
|
|
254
|
+
* When provided, it takes priority over `persist`.
|
|
255
|
+
* Allows persistence via cookies, server, indexedDB, etc.
|
|
256
|
+
*/
|
|
257
|
+
persistence?: ThemePersistence;
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/contexts/ThemeContext/index.d.ts
|
|
261
|
+
/**
|
|
262
|
+
* ThemeProvider
|
|
263
|
+
* -------------
|
|
264
|
+
* Provides theme state + resolved theme tokens to your app.
|
|
265
|
+
*/
|
|
266
|
+
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
267
|
+
/**
|
|
268
|
+
* useTheme()
|
|
269
|
+
*
|
|
270
|
+
* Returns the current theme context.
|
|
271
|
+
*
|
|
272
|
+
* @throws If called outside of `<ThemeProvider />`.
|
|
273
|
+
*/
|
|
274
|
+
declare function useTheme(): ThemeContextData;
|
|
275
|
+
//#endregion
|
|
276
|
+
export { ThemeName as a, ThemeRegistry as c, ThemeMode as i, ThemeTokens as l, useTheme as n, ThemePersistence as o, ThemeContextData as r, ThemeProviderProps as s, ThemeProvider as t };
|
|
277
|
+
//# sourceMappingURL=index-jFi4YRO5.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as SwitchOption, r as TabSwitchProps, t as TabSwitch } from "./index-CZOu4S--.js";
|
|
2
|
+
import { a as ThemeName, c as ThemeRegistry, i as ThemeMode, l as ThemeTokens, n as useTheme, o as ThemePersistence, r as ThemeContextData, s as ThemeProviderProps, t as ThemeProvider } from "./index-jFi4YRO5.js";
|
|
3
|
+
export { SwitchOption, TabSwitch, TabSwitchProps, ThemeContextData, ThemeMode, ThemeName, ThemePersistence, ThemeProvider, ThemeProviderProps, ThemeRegistry, ThemeTokens, useTheme };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
//#region src/services/MaskModule/enums.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Supported locales (country + language region).
|
|
4
|
+
*
|
|
5
|
+
* Extend this enum as needed for new countries.
|
|
6
|
+
*/
|
|
7
|
+
declare enum Locale {
|
|
8
|
+
BR = "pt-BR",
|
|
9
|
+
// Brazil
|
|
10
|
+
US = "en-US",
|
|
11
|
+
// United States
|
|
12
|
+
AR = "es-AR",
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Types of masks supported in the system.
|
|
16
|
+
*
|
|
17
|
+
* Add new types as needed for different data formats.
|
|
18
|
+
*/
|
|
19
|
+
declare enum MaskType {
|
|
20
|
+
CPF = "CPF",
|
|
21
|
+
CNPJ = "CNPJ",
|
|
22
|
+
DOCUMENT = "DOCUMENT",
|
|
23
|
+
PHONE = "PHONE",
|
|
24
|
+
DATE = "DATE",
|
|
25
|
+
FLOAT = "FLOAT",
|
|
26
|
+
INTEGER = "INTEGER",
|
|
27
|
+
MONEY = "MONEY",
|
|
28
|
+
ZIP_CODE = "ZIP_CODE",
|
|
29
|
+
NUMERIC_SYMBOL = "NUMERIC_SYMBOL",
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/services/MaskModule/types.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Represents a generic mask.
|
|
35
|
+
*
|
|
36
|
+
* A mask is responsible for formatting and unformatting (removing formatting) from a value.
|
|
37
|
+
*/
|
|
38
|
+
interface Mask {
|
|
39
|
+
/**
|
|
40
|
+
* Optional minimum length of the masked string.
|
|
41
|
+
*/
|
|
42
|
+
minLength?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Optional maximum length of the masked string.
|
|
45
|
+
*/
|
|
46
|
+
maxLength?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Formats a plain string into a masked format.
|
|
49
|
+
* @param value - Raw string (e.g., "12345678901").
|
|
50
|
+
* @returns Masked string (e.g., "123.456.789-01").
|
|
51
|
+
*/
|
|
52
|
+
format(value: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Removes all mask characters from a formatted string.
|
|
55
|
+
* @param value - Masked string (e.g., "123.456.789-01").
|
|
56
|
+
* @returns Unmasked string (e.g., "12345678901").
|
|
57
|
+
*/
|
|
58
|
+
unmask(value: string): string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Represents a validator for a masked value.
|
|
62
|
+
*
|
|
63
|
+
* A validator checks whether a masked value is valid based on rules.
|
|
64
|
+
*/
|
|
65
|
+
interface Validator {
|
|
66
|
+
/**
|
|
67
|
+
* Validates whether the input value is valid.
|
|
68
|
+
* @param value - Masked string.
|
|
69
|
+
* @returns `true` if valid, `false` otherwise.
|
|
70
|
+
*/
|
|
71
|
+
validate(value: string): boolean;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/services/MaskModule/base/BaseMask.d.ts
|
|
75
|
+
/**
|
|
76
|
+
* Abstract class that provides default behavior for most masks.
|
|
77
|
+
* - Implements unmask() by removing all non-numeric characters.
|
|
78
|
+
* - Supports optional maxLength and minLength constraints.
|
|
79
|
+
*/
|
|
80
|
+
declare abstract class BaseMask implements Mask {
|
|
81
|
+
/**
|
|
82
|
+
* Maximum length of the masked string (optional).
|
|
83
|
+
*/
|
|
84
|
+
maxLength?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Minimum length of the masked string (optional).
|
|
87
|
+
*/
|
|
88
|
+
minLength?: number;
|
|
89
|
+
constructor(minLength?: number, maxLength?: number);
|
|
90
|
+
/**
|
|
91
|
+
* Removes all non-numeric characters from a string.
|
|
92
|
+
* @param value - Masked or unmasked string.
|
|
93
|
+
* @returns Plain string with digits only.
|
|
94
|
+
*/
|
|
95
|
+
unmask(value: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Must be implemented by each concrete mask class.
|
|
98
|
+
* Applies the mask format to the input string.
|
|
99
|
+
* @param value - Raw string.
|
|
100
|
+
* @returns Masked string.
|
|
101
|
+
*/
|
|
102
|
+
abstract format(value: string): string;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/services/MaskModule/base/BaseValidator.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* Abstract class providing common validation utilities.
|
|
108
|
+
* - Supports regex validation.
|
|
109
|
+
* - Supports min and max length validation.
|
|
110
|
+
*/
|
|
111
|
+
declare abstract class BaseValidator implements Validator {
|
|
112
|
+
protected pattern?: RegExp;
|
|
113
|
+
protected minLength?: number;
|
|
114
|
+
protected maxLength?: number;
|
|
115
|
+
constructor(options?: {
|
|
116
|
+
pattern?: RegExp;
|
|
117
|
+
minLength?: number;
|
|
118
|
+
maxLength?: number;
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Validates the input value based on:
|
|
122
|
+
* - Pattern matching (if defined)
|
|
123
|
+
* - Min length (if defined)
|
|
124
|
+
* - Max length (if defined)
|
|
125
|
+
*
|
|
126
|
+
* Override this method if you need custom validation logic.
|
|
127
|
+
*
|
|
128
|
+
* @param value - Value to validate (usually masked string)
|
|
129
|
+
* @returns true if valid, false otherwise
|
|
130
|
+
*/
|
|
131
|
+
validate(value: string): boolean;
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/services/MaskModule/MaskModule.d.ts
|
|
135
|
+
declare const MaskModule: {
|
|
136
|
+
registerMask(locale: Locale, type: MaskType, mask: BaseMask): void;
|
|
137
|
+
registerValidator(locale: Locale, type: MaskType, validator: BaseValidator): void;
|
|
138
|
+
getMask(locale: Locale, type: MaskType): BaseMask | undefined;
|
|
139
|
+
getValidator(locale: Locale, type: MaskType): BaseValidator | undefined;
|
|
140
|
+
reset(): void;
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { Locale, MaskModule, MaskType };
|
|
144
|
+
//# sourceMappingURL=mask-modules.d.ts.map
|