@stacksjs/components 0.2.5 → 0.2.8
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 +2 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/useCopyCode.d.ts +1 -1
- package/dist/composables/useDarkMode.d.ts +1 -1
- package/dist/composables/useSEO.d.ts +2 -2
- package/dist/composables/utilities/index.d.ts +2 -1
- package/dist/composables/utilities/useClickOutside.d.ts +1 -1
- package/dist/composables/utilities/useFocusTrap.d.ts +1 -1
- package/dist/composables/utilities/useKeyboard.d.ts +1 -1
- package/dist/composables/utilities/useLocalStorage.d.ts +2 -2
- package/dist/composables/utilities/useMediaQuery.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -6
- package/dist/ui/accordion/index.d.ts +1 -1
- package/dist/ui/audio/index.d.ts +1 -1
- package/dist/ui/auth/index.d.ts +1 -1
- package/dist/ui/avatar/index.d.ts +1 -1
- package/dist/ui/badge/index.d.ts +1 -1
- package/dist/ui/breadcrumb/index.d.ts +1 -1
- package/dist/ui/button/index.d.ts +3 -3
- package/dist/ui/calendar/index.d.ts +1 -1
- package/dist/ui/card/index.d.ts +1 -1
- package/dist/ui/checkbox/index.d.ts +1 -1
- package/dist/ui/combobox/index.d.ts +1 -1
- package/dist/ui/command-palette/index.d.ts +1 -1
- package/dist/ui/dialog/index.d.ts +1 -1
- package/dist/ui/drawer/index.d.ts +1 -1
- package/dist/ui/dropdown/index.d.ts +1 -1
- package/dist/ui/form/index.d.ts +4 -4
- package/dist/ui/image/index.d.ts +1 -1
- package/dist/ui/input/index.d.ts +7 -7
- package/dist/ui/listbox/index.d.ts +1 -1
- package/dist/ui/navigator/index.d.ts +1 -1
- package/dist/ui/notification/index.d.ts +1 -1
- package/dist/ui/pagination/index.d.ts +1 -1
- package/dist/ui/payment/index.d.ts +1 -1
- package/dist/ui/popover/index.d.ts +1 -1
- package/dist/ui/portal/index.d.ts +1 -1
- package/dist/ui/progress/index.d.ts +1 -1
- package/dist/ui/radio/index.d.ts +1 -1
- package/dist/ui/radio-group/index.d.ts +1 -1
- package/dist/ui/select/index.d.ts +1 -1
- package/dist/ui/sidebar/index.d.ts +2 -2
- package/dist/ui/skeleton/index.d.ts +1 -1
- package/dist/ui/spinner/index.d.ts +1 -1
- package/dist/ui/stepper/index.d.ts +1 -1
- package/dist/ui/storage/index.d.ts +3 -14
- package/dist/ui/switch/index.d.ts +1 -1
- package/dist/ui/table/index.d.ts +1 -1
- package/dist/ui/tabs/index.d.ts +1 -1
- package/dist/ui/teleport/index.d.ts +1 -1
- package/dist/ui/textarea/index.d.ts +1 -1
- package/dist/ui/tooltip/index.d.ts +1 -1
- package/dist/ui/transition/index.d.ts +1 -1
- package/dist/ui/video/index.d.ts +1 -1
- package/dist/ui/virtual-list/index.d.ts +1 -1
- package/dist/ui/virtual-table/index.d.ts +1 -1
- package/dist/utils/accessibility.d.ts +30 -15
- package/dist/utils/animation/easing.d.ts +1 -76
- package/dist/utils/animation/helpers.d.ts +2 -9
- package/dist/utils/animation/index.d.ts +2 -1
- package/dist/utils/animation/keyframes.d.ts +2 -1
- package/dist/utils/error-handling.d.ts +22 -26
- package/dist/utils/highlighter.d.ts +2 -1
- package/dist/utils/i18n.d.ts +91 -48
- package/dist/utils/keep-alive.d.ts +1 -1
- package/dist/utils/lazy-loading.d.ts +2 -2
- package/dist/utils/prop-validation.d.ts +7 -6
- package/dist/utils/theme.d.ts +1 -1
- package/package.json +6 -6
- package/src/composables/utilities/useLocalStorage.ts +4 -4
- package/src/ui/storage/index.ts +1 -1
- package/src/utils/accessibility.ts +1 -1
- package/src/utils/animation/easing.ts +1 -1
- package/src/utils/animation/helpers.ts +1 -1
- package/src/utils/animation/keyframes.ts +1 -1
- package/src/utils/error-handling.ts +1 -1
- package/src/utils/i18n.ts +1 -1
- package/src/utils/lazy-loading.ts +1 -1
- package/src/utils/prop-validation.ts +5 -5
- package/dist/CodeBlock-mwex82cm.stx +0 -57
- package/dist/Footer-xdaf02nr.stx +0 -66
- package/dist/Hero-9vvp7pxf.stx +0 -25
- package/dist/Installation-33bj4rm7.stx +0 -39
|
@@ -39,23 +39,6 @@ export declare function handleError(error: Error, options?: {
|
|
|
39
39
|
/** Whether to log the error to console */
|
|
40
40
|
logError?: boolean
|
|
41
41
|
}): void;
|
|
42
|
-
/**
|
|
43
|
-
* Create a wrapped function that catches and handles errors
|
|
44
|
-
*
|
|
45
|
-
* @param fn - Function to wrap
|
|
46
|
-
* @param component - Component name for error context
|
|
47
|
-
* @param eventName - Event name for error context
|
|
48
|
-
* @returns Wrapped function
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const safeHandler = wrapErrorHandler(
|
|
53
|
-
* () => { /* ... * / },
|
|
54
|
-
* 'Button',
|
|
55
|
-
* 'onClick'
|
|
56
|
-
* )
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
42
|
/* ... * / },
|
|
60
43
|
* 'Button',
|
|
61
44
|
* 'onClick'
|
|
@@ -124,40 +107,53 @@ export declare function createDebugger(component: string): {
|
|
|
124
107
|
export declare function errorBoundary<T>(component: string, renderFn: () => T, fallback: T): T;
|
|
125
108
|
/**
|
|
126
109
|
* Error types for common scenarios
|
|
110
|
+
* @defaultValue
|
|
111
|
+
* ```ts
|
|
112
|
+
* {
|
|
113
|
+
* invalidProp: (component: string, prop: string, received: any, expected: any) => unknown,
|
|
114
|
+
* requiredProp: (component: string, prop: string) => unknown,
|
|
115
|
+
* invalidType: (component: string, prop: string, received: any, expected: string) => unknown,
|
|
116
|
+
* componentNotFound: (componentName: string) => unknown,
|
|
117
|
+
* invalidChildren: (component: string, received: any, expected: string) => unknown,
|
|
118
|
+
* stateUpdate: (component: string, stateName: string, error: Error) => unknown,
|
|
119
|
+
* eventHandler: (component: string, eventName: string, error: Error) => unknown,
|
|
120
|
+
* render: (component: string, error: Error) => unknown
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
127
123
|
*/
|
|
128
124
|
export declare const ErrorTypes: {
|
|
129
125
|
/**
|
|
130
126
|
* Invalid prop value error
|
|
131
127
|
*/
|
|
132
|
-
invalidProp(component: string, prop: string, received: any, expected: any)
|
|
128
|
+
invalidProp: (component: string, prop: string, received: any, expected: any) => unknown;
|
|
133
129
|
/**
|
|
134
130
|
* Required prop missing error
|
|
135
131
|
*/
|
|
136
|
-
requiredProp(component: string, prop: string)
|
|
132
|
+
requiredProp: (component: string, prop: string) => unknown;
|
|
137
133
|
/**
|
|
138
134
|
* Invalid prop type error
|
|
139
135
|
*/
|
|
140
|
-
invalidType(component: string, prop: string, received: any, expected: string)
|
|
136
|
+
invalidType: (component: string, prop: string, received: any, expected: string) => unknown;
|
|
141
137
|
/**
|
|
142
138
|
* Component not found error
|
|
143
139
|
*/
|
|
144
|
-
componentNotFound(componentName: string)
|
|
140
|
+
componentNotFound: (componentName: string) => unknown;
|
|
145
141
|
/**
|
|
146
142
|
* Invalid children error
|
|
147
143
|
*/
|
|
148
|
-
invalidChildren(component: string, received: any, expected: string)
|
|
144
|
+
invalidChildren: (component: string, received: any, expected: string) => unknown;
|
|
149
145
|
/**
|
|
150
146
|
* State update error
|
|
151
147
|
*/
|
|
152
|
-
stateUpdate(component: string, stateName: string, error: Error)
|
|
148
|
+
stateUpdate: (component: string, stateName: string, error: Error) => unknown;
|
|
153
149
|
/**
|
|
154
150
|
* Event handler error
|
|
155
151
|
*/
|
|
156
|
-
eventHandler(component: string, eventName: string, error: Error)
|
|
152
|
+
eventHandler: (component: string, eventName: string, error: Error) => unknown;
|
|
157
153
|
/**
|
|
158
154
|
* Render error
|
|
159
155
|
*/
|
|
160
|
-
render(component: string, error: Error)
|
|
156
|
+
render: (component: string, error: Error) => unknown
|
|
161
157
|
};
|
|
162
158
|
/**
|
|
163
159
|
* Error context information
|
|
@@ -179,4 +175,4 @@ export declare class ComponentError extends Error {
|
|
|
179
175
|
constructor(component: string, message: string, context?: ErrorContext);
|
|
180
176
|
static formatMessage(component: string, message: string, context: ErrorContext): string;
|
|
181
177
|
toJSON(): { name: string, message: string, component: string, context: ErrorContext | undefined, stack: string | undefined };
|
|
182
|
-
}
|
|
178
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Highlighter as TSHighlighter } from 'ts-syntax-highlighter';
|
|
1
2
|
/**
|
|
2
3
|
* Initialize or get the syntax highlighter instance
|
|
3
4
|
*/
|
|
@@ -24,4 +25,4 @@ export declare interface HighlightResult {
|
|
|
24
25
|
html: string
|
|
25
26
|
language: string
|
|
26
27
|
theme: string
|
|
27
|
-
}
|
|
28
|
+
}
|
package/dist/utils/i18n.d.ts
CHANGED
|
@@ -69,60 +69,31 @@ export declare function d(date: Date | number, format?: string): string;
|
|
|
69
69
|
* @returns Formatted number string
|
|
70
70
|
*/
|
|
71
71
|
export declare function n(value: number, format?: string): string;
|
|
72
|
-
/**
|
|
73
|
-
* RTL (Right-to-Left) language detection
|
|
74
|
-
*
|
|
75
|
-
* @param locale - Locale code
|
|
76
|
-
* @returns Whether locale is RTL
|
|
77
|
-
*/
|
|
78
|
-
export declare function isRTL(locale: string): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Load locale messages dynamically
|
|
81
|
-
*
|
|
82
|
-
* @param locale - Locale code
|
|
83
|
-
* @param loadFn - Function to load messages
|
|
84
|
-
* @returns Promise of messages
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* const messages = await loadLocaleMessages('es', async () => {
|
|
89
|
-
* const module = await import('./locales/es.json')
|
|
90
|
-
* return module.default
|
|
91
|
-
* })
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
export declare function loadLocaleMessages(locale: string, loadFn: () => Promise<Messages>): Promise<Messages>;
|
|
95
72
|
/**
|
|
96
73
|
* Predefined pluralization rules for common languages
|
|
97
74
|
*/
|
|
98
75
|
export declare const pluralRules: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
fr: unknown;
|
|
106
|
-
pt_BR: unknown;
|
|
107
|
-
Croatian
|
|
76
|
+
en: (count) => unknown;
|
|
77
|
+
de: (count) => unknown;
|
|
78
|
+
nl: (count) => unknown;
|
|
79
|
+
sv: (count) => unknown;
|
|
80
|
+
fr: (count) => unknown;
|
|
81
|
+
pt_BR: (count) => unknown;
|
|
108
82
|
ru: (count) => unknown;
|
|
109
|
-
// Polish
|
|
110
83
|
pl: (count) => unknown;
|
|
111
|
-
Slovak
|
|
112
84
|
cs: (count) => unknown;
|
|
113
|
-
// Arabic
|
|
114
85
|
ar: (count) => unknown;
|
|
115
|
-
Vietnamese
|
|
116
86
|
ja: () => unknown;
|
|
117
87
|
ko: () => unknown;
|
|
118
88
|
zh: () => unknown;
|
|
119
89
|
th: () => unknown;
|
|
120
|
-
vi: () => unknown
|
|
121
|
-
}
|
|
90
|
+
vi: () => unknown;
|
|
91
|
+
}
|
|
92
|
+
|
|
122
93
|
/**
|
|
123
94
|
* Common date/time format presets
|
|
124
95
|
*/
|
|
125
|
-
export
|
|
96
|
+
export const dateTimeFormats: Record<string, Intl.DateTimeFormatOptions> = {
|
|
126
97
|
short: {
|
|
127
98
|
year: 'numeric';
|
|
128
99
|
month: 'numeric';
|
|
@@ -149,12 +120,13 @@ export declare const dateTimeFormats: {
|
|
|
149
120
|
day: 'numeric';
|
|
150
121
|
hour: 'numeric';
|
|
151
122
|
minute: 'numeric'
|
|
152
|
-
}
|
|
153
123
|
};
|
|
124
|
+
}
|
|
125
|
+
|
|
154
126
|
/**
|
|
155
127
|
* Common number format presets
|
|
156
128
|
*/
|
|
157
|
-
export
|
|
129
|
+
export const numberFormats: Record<string, Intl.NumberFormatOptions> = {
|
|
158
130
|
decimal: {
|
|
159
131
|
style: 'decimal';
|
|
160
132
|
minimumFractionDigits: 2;
|
|
@@ -171,14 +143,85 @@ export declare const numberFormats: {
|
|
|
171
143
|
};
|
|
172
144
|
compact: {
|
|
173
145
|
notation: 'compact'
|
|
174
|
-
}
|
|
175
146
|
};
|
|
147
|
+
}
|
|
148
|
+
|
|
176
149
|
/**
|
|
177
|
-
*
|
|
150
|
+
* RTL (Right-to-Left) language detection
|
|
178
151
|
*
|
|
179
|
-
*
|
|
152
|
+
* @param locale - Locale code
|
|
153
|
+
* @returns Whether locale is RTL
|
|
180
154
|
*/
|
|
181
|
-
export
|
|
155
|
+
export function isRTL(locale: () => unknown;
|
|
156
|
+
loadFn: () => unknown;
|
|
157
|
+
): Promise<Messages> {
|
|
158
|
+
try {
|
|
159
|
+
return await loadFn()
|
|
160
|
+
}
|
|
161
|
+
catch: (error) => unknown;
|
|
162
|
+
es: {
|
|
163
|
+
common: {
|
|
164
|
+
loading: 'Cargando...';
|
|
165
|
+
error: 'Error';
|
|
166
|
+
retry: 'Reintentar';
|
|
167
|
+
cancel: 'Cancelar';
|
|
168
|
+
confirm: 'Confirmar';
|
|
169
|
+
close: 'Cerrar';
|
|
170
|
+
save: 'Guardar';
|
|
171
|
+
delete: 'Eliminar';
|
|
172
|
+
edit: 'Editar';
|
|
173
|
+
search: 'Buscar';
|
|
174
|
+
clear: 'Limpiar';
|
|
175
|
+
submit: 'Enviar';
|
|
176
|
+
reset: 'Restablecer'
|
|
177
|
+
};
|
|
178
|
+
form: {
|
|
179
|
+
required: 'Este campo es obligatorio';
|
|
180
|
+
invalid: 'Valor inválido';
|
|
181
|
+
tooShort: 'El valor es demasiado corto (mínimo {min} caracteres)';
|
|
182
|
+
tooLong: 'El valor es demasiado largo (máximo {max} caracteres)';
|
|
183
|
+
invalidEmail: 'Dirección de correo electrónico inválida';
|
|
184
|
+
invalidUrl: 'URL inválida'
|
|
185
|
+
};
|
|
186
|
+
pagination: {
|
|
187
|
+
previous: 'Anterior';
|
|
188
|
+
next: 'Siguiente';
|
|
189
|
+
page: 'Página {page}';
|
|
190
|
+
of: 'de {total}'
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
fr: {
|
|
194
|
+
common: {
|
|
195
|
+
loading: 'Chargement...';
|
|
196
|
+
error: 'Erreur';
|
|
197
|
+
retry: 'Réessayer';
|
|
198
|
+
cancel: 'Annuler';
|
|
199
|
+
confirm: 'Confirmer';
|
|
200
|
+
close: 'Fermer';
|
|
201
|
+
save: 'Enregistrer';
|
|
202
|
+
delete: 'Supprimer';
|
|
203
|
+
edit: 'Modifier';
|
|
204
|
+
search: 'Rechercher';
|
|
205
|
+
clear: 'Effacer';
|
|
206
|
+
submit: 'Soumettre';
|
|
207
|
+
reset: 'Réinitialiser'
|
|
208
|
+
};
|
|
209
|
+
form: {
|
|
210
|
+
required: 'Ce champ est obligatoire';
|
|
211
|
+
invalid: 'Valeur invalide';
|
|
212
|
+
tooShort: 'La valeur est trop courte (minimum {min} caractères)';
|
|
213
|
+
tooLong: 'La valeur est trop longue (maximum {max} caractères)';
|
|
214
|
+
invalidEmail: 'Adresse e-mail invalide';
|
|
215
|
+
invalidUrl: 'URL invalide'
|
|
216
|
+
};
|
|
217
|
+
pagination: {
|
|
218
|
+
previous: 'Précédent';
|
|
219
|
+
next: 'Suivant';
|
|
220
|
+
page: 'Page {page}';
|
|
221
|
+
of: 'sur {total}'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
182
225
|
/**
|
|
183
226
|
* I18n configuration
|
|
184
227
|
*/
|
|
@@ -234,12 +277,12 @@ export declare interface I18n {
|
|
|
234
277
|
* Translation messages structure
|
|
235
278
|
*/
|
|
236
279
|
export type MessageValue = string | { [key: string]: MessageValue }
|
|
237
|
-
export type Messages = Record<string, MessageValue
|
|
280
|
+
export type Messages = Record<string, MessageValue>;
|
|
238
281
|
/**
|
|
239
282
|
* Locale messages
|
|
240
283
|
*/
|
|
241
|
-
export type LocaleMessages = Record<string, Messages
|
|
284
|
+
export type LocaleMessages = Record<string, Messages>;
|
|
242
285
|
/**
|
|
243
286
|
* Pluralization rules
|
|
244
287
|
*/
|
|
245
|
-
export type PluralRule = (
|
|
288
|
+
export type PluralRule = (_count: number, _locale: string) => number;
|
|
@@ -54,7 +54,7 @@ export declare function lazyLoad<T = any>(element: Element | null, importFn: ()
|
|
|
54
54
|
* @param options - Lazy load options
|
|
55
55
|
* @returns Cleanup function
|
|
56
56
|
*/
|
|
57
|
-
export declare function lazyLoadAll<T = any>(elements: Element[] | NodeListOf<Element>, importFn: ((
|
|
57
|
+
export declare function lazyLoadAll<T = any>(elements: Element[] | NodeListOf<Element>, importFn: ((_element: Element) => Promise<T>) | (() => Promise<T>), options?: LazyLoadOptions): () => void;
|
|
58
58
|
/**
|
|
59
59
|
* Preload a module without executing it
|
|
60
60
|
*
|
|
@@ -171,4 +171,4 @@ export declare interface LazyComponent<T = any> {
|
|
|
171
171
|
/**
|
|
172
172
|
* Lazy load state
|
|
173
173
|
*/
|
|
174
|
-
export type LazyLoadState = 'idle' | 'loading' | 'loaded' | 'error'
|
|
174
|
+
export type LazyLoadState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
@@ -43,7 +43,7 @@ export declare function createPropValidator(componentName: string, schema: PropS
|
|
|
43
43
|
* @param name - Name for error messages
|
|
44
44
|
* @throws Error if validation fails
|
|
45
45
|
*/
|
|
46
|
-
export declare function assertProp<T>(value: any, validator: Validator<T>, name?:
|
|
46
|
+
export declare function assertProp<T>(value: any, validator: Validator<T>, name?: string): asserts value is T;
|
|
47
47
|
/**
|
|
48
48
|
* Warn if prop doesn't match validator (non-throwing)
|
|
49
49
|
*
|
|
@@ -51,7 +51,7 @@ export declare function assertProp<T>(value: any, validator: Validator<T>, name?
|
|
|
51
51
|
* @param validator - Validator to use
|
|
52
52
|
* @param name - Name for warning messages
|
|
53
53
|
*/
|
|
54
|
-
export declare function warnProp(value: any, validator: Validator, name?:
|
|
54
|
+
export declare function warnProp(value: any, validator: Validator, name?: string): void;
|
|
55
55
|
/**
|
|
56
56
|
* PropTypes - collection of common validators
|
|
57
57
|
*/
|
|
@@ -94,13 +94,14 @@ export declare interface ValidationResult {
|
|
|
94
94
|
/**
|
|
95
95
|
* Prop schema definition
|
|
96
96
|
*/
|
|
97
|
-
export type PropSchema = Record<string, Validator
|
|
97
|
+
export type PropSchema = Record<string, Validator>;
|
|
98
98
|
/**
|
|
99
99
|
* Base validator class
|
|
100
100
|
*/
|
|
101
101
|
declare class Validator<T = any> implements PropValidator<T> {
|
|
102
102
|
public validate: (value: any, propName: string, componentName: string) => boolean;
|
|
103
103
|
public message: (value: any, propName: string, componentName: string) => string;
|
|
104
|
-
public isRequired?:
|
|
105
|
-
constructor(validate: (value: any, propName: string, componentName: string) => boolean, message: (value: any, propName: string, componentName: string) => string, isRequired?:
|
|
106
|
-
|
|
104
|
+
public isRequired?: boolean;
|
|
105
|
+
constructor(validate: (value: any, propName: string, componentName: string) => boolean, message: (value: any, propName: string, componentName: string) => string, isRequired?: boolean);
|
|
106
|
+
get required(): Validator<T>;
|
|
107
|
+
}
|
package/dist/utils/theme.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"prepublishOnly": "bun run build"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@
|
|
59
|
-
"@stacksjs/stx": "0.2.
|
|
60
|
-
"bun-plugin-stx": "0.2.
|
|
58
|
+
"@cwcss/crosswind": "^0.1.3",
|
|
59
|
+
"@stacksjs/stx": "0.2.8",
|
|
60
|
+
"bun-plugin-stx": "0.2.8",
|
|
61
61
|
"ts-syntax-highlighter": "^0.2.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@types/bun": "^1.3.
|
|
64
|
+
"@types/bun": "^1.3.9",
|
|
65
65
|
"bun-plugin-dtsx": "^0.9.9",
|
|
66
|
-
"pickier": "^0.1.
|
|
66
|
+
"pickier": "^0.1.20",
|
|
67
67
|
"typescript": "^5.9.3"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* Options for useLocalStorage hook
|
|
16
16
|
*/
|
|
17
17
|
export interface UseLocalStorageOptions<T> {
|
|
18
|
-
/** Custom serializer function
|
|
18
|
+
/** Custom serializer function - defaults to JSON.stringify */
|
|
19
19
|
serializer?: (value: T) => string
|
|
20
|
-
/** Custom deserializer function
|
|
20
|
+
/** Custom deserializer function - defaults to JSON.parse */
|
|
21
21
|
deserializer?: (value: string) => T
|
|
22
22
|
/** Error handler function */
|
|
23
23
|
onError?: (error: Error) => void
|
|
@@ -37,7 +37,7 @@ export function useLocalStorage<T>(
|
|
|
37
37
|
options: UseLocalStorageOptions<T> = {},
|
|
38
38
|
): {
|
|
39
39
|
value: T
|
|
40
|
-
setValue: (newValue: T | ((
|
|
40
|
+
setValue: (newValue: T | ((_prev: T) => T)) => void
|
|
41
41
|
removeValue: () => void
|
|
42
42
|
} {
|
|
43
43
|
const {
|
|
@@ -68,7 +68,7 @@ export function useLocalStorage<T>(
|
|
|
68
68
|
function setValue(newValue: T | ((prev: T) => T)) {
|
|
69
69
|
try {
|
|
70
70
|
// Allow value to be a function for same API as useState
|
|
71
|
-
const valueToStore = typeof newValue === 'function' ? (newValue as (
|
|
71
|
+
const valueToStore = typeof newValue === 'function' ? (newValue as (_prev: T) => T)(value) : newValue
|
|
72
72
|
|
|
73
73
|
value = valueToStore
|
|
74
74
|
|
package/src/ui/storage/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface StorageOptions {
|
|
|
7
7
|
compress?: boolean // Compress large objects
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type StorageWatchCallback = (
|
|
10
|
+
type StorageWatchCallback = (_newValue: any, _oldValue: any, _key: string) => void
|
|
11
11
|
|
|
12
12
|
export class StorageManager {
|
|
13
13
|
private storage: globalThis.Storage
|
|
@@ -112,7 +112,7 @@ export interface FocusTrapOptions {
|
|
|
112
112
|
/** Click outside deactivates trap */
|
|
113
113
|
clickOutsideDeactivates?: boolean
|
|
114
114
|
/** Allow outside click without deactivating */
|
|
115
|
-
allowOutsideClick?: boolean | ((
|
|
115
|
+
allowOutsideClick?: boolean | ((_event: MouseEvent) => boolean)
|
|
116
116
|
/** Callback when activated */
|
|
117
117
|
onActivate?: () => void
|
|
118
118
|
/** Callback when deactivated */
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* Easing function type signature
|
|
21
21
|
*/
|
|
22
|
-
export type EasingFunction = (
|
|
22
|
+
export type EasingFunction = (_t: number, _b: number, _c: number, _d: number) => number
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Linear easing - no acceleration
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
export interface CSSAnimationOptions {
|
|
20
20
|
/** Animation duration (e.g., '300ms', '1s') */
|
|
21
21
|
duration?: string
|
|
22
|
-
/** Timing function
|
|
22
|
+
/** Timing function, e.g. 'ease', 'linear', 'cubic-bezier(...)' */
|
|
23
23
|
timing?: string
|
|
24
24
|
/** Delay before animation (e.g., '100ms') */
|
|
25
25
|
delay?: string
|
|
@@ -32,7 +32,7 @@ export interface Keyframe {
|
|
|
32
32
|
export interface AnimationOptions {
|
|
33
33
|
/** Animation duration in milliseconds */
|
|
34
34
|
duration?: number
|
|
35
|
-
/** Easing function
|
|
35
|
+
/** Easing function, CSS easing string */
|
|
36
36
|
easing?: string
|
|
37
37
|
/** Delay before animation starts in milliseconds */
|
|
38
38
|
delay?: number
|
package/src/utils/i18n.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type LocaleMessages = Record<string, Messages>
|
|
|
36
36
|
/**
|
|
37
37
|
* Pluralization rules
|
|
38
38
|
*/
|
|
39
|
-
export type PluralRule = (
|
|
39
|
+
export type PluralRule = (_count: number, _locale: string) => number
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* I18n configuration
|
|
@@ -311,7 +311,7 @@ export function lazyLoad<T = any>(
|
|
|
311
311
|
*/
|
|
312
312
|
export function lazyLoadAll<T = any>(
|
|
313
313
|
elements: Element[] | NodeListOf<Element>,
|
|
314
|
-
importFn: ((
|
|
314
|
+
importFn: ((_element: Element) => Promise<T>) | (() => Promise<T>),
|
|
315
315
|
options: LazyLoadOptions = {},
|
|
316
316
|
): () => void {
|
|
317
317
|
const cleanupFunctions: Array<() => void> = []
|
|
@@ -169,7 +169,7 @@ export const PropTypes: {
|
|
|
169
169
|
return new Validator(
|
|
170
170
|
(value, propName, componentName) =>
|
|
171
171
|
validators.some(v => v.validate(value, propName, componentName)),
|
|
172
|
-
(
|
|
172
|
+
(_value, propName, componentName) =>
|
|
173
173
|
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected one of the specified types.`,
|
|
174
174
|
)
|
|
175
175
|
},
|
|
@@ -186,7 +186,7 @@ export const PropTypes: {
|
|
|
186
186
|
return false
|
|
187
187
|
return value.every((item, index) => validator.validate(item, `${propName}[${index}]`, componentName))
|
|
188
188
|
},
|
|
189
|
-
(
|
|
189
|
+
(_value, propName, componentName) =>
|
|
190
190
|
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected array of specified type.`,
|
|
191
191
|
)
|
|
192
192
|
},
|
|
@@ -213,7 +213,7 @@ export const PropTypes: {
|
|
|
213
213
|
|
|
214
214
|
return true
|
|
215
215
|
},
|
|
216
|
-
(
|
|
216
|
+
(_value, propName, componentName) =>
|
|
217
217
|
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected object matching specified shape.`,
|
|
218
218
|
)
|
|
219
219
|
},
|
|
@@ -226,7 +226,7 @@ export const PropTypes: {
|
|
|
226
226
|
instanceOf<T>(expectedClass: new (...args: any[]) => T): Validator<T> {
|
|
227
227
|
return new Validator(
|
|
228
228
|
value => value instanceof expectedClass,
|
|
229
|
-
(
|
|
229
|
+
(_value, propName, componentName) =>
|
|
230
230
|
`Invalid prop \`${propName}\` supplied to \`${componentName}\`, expected instance of \`${expectedClass.name}\`.`,
|
|
231
231
|
)
|
|
232
232
|
},
|
|
@@ -239,7 +239,7 @@ export const PropTypes: {
|
|
|
239
239
|
*/
|
|
240
240
|
custom(
|
|
241
241
|
validatorFn: (value: any, propName: string, componentName: string) => boolean,
|
|
242
|
-
errorMessage: string | ((
|
|
242
|
+
errorMessage: string | ((_value: any, _propName: string, _componentName: string) => string),
|
|
243
243
|
): Validator {
|
|
244
244
|
const messageGenerator = typeof errorMessage === 'string'
|
|
245
245
|
? () => errorMessage
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { highlight, applyHeadwindClasses } from '../utils/highlighter'
|
|
3
|
-
|
|
4
|
-
export const code = $props.code || ''
|
|
5
|
-
export const language = $props.language || 'typescript'
|
|
6
|
-
export const theme = $props.theme || 'auto'
|
|
7
|
-
export const lineNumbers = $props.lineNumbers !== false
|
|
8
|
-
export const copyable = $props.copyable !== false
|
|
9
|
-
export const className = $props.className || ''
|
|
10
|
-
|
|
11
|
-
export let highlightedCode = ''
|
|
12
|
-
export let copied = false
|
|
13
|
-
|
|
14
|
-
// Highlight the code
|
|
15
|
-
const result = await highlight(code, { language, theme, lineNumbers })
|
|
16
|
-
highlightedCode = applyHeadwindClasses(result.html, className)
|
|
17
|
-
|
|
18
|
-
export async function copyToClipboard() {
|
|
19
|
-
try {
|
|
20
|
-
await navigator.clipboard.writeText(code)
|
|
21
|
-
copied = true
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
copied = false
|
|
24
|
-
}, 2000)
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.error('Failed to copy code:', err)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<div class="relative group">
|
|
32
|
-
{!! highlightedCode !!}
|
|
33
|
-
|
|
34
|
-
@if(copyable)
|
|
35
|
-
<button
|
|
36
|
-
@click="copyToClipboard"
|
|
37
|
-
class="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 px-3 py-1.5 bg-neutral-800 hover:bg-neutral-700 text-white text-xs rounded-md font-medium"
|
|
38
|
-
aria-label="Copy code"
|
|
39
|
-
>
|
|
40
|
-
@if(copied)
|
|
41
|
-
<span class="flex items-center gap-1.5">
|
|
42
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
43
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
|
44
|
-
</svg>
|
|
45
|
-
Copied!
|
|
46
|
-
</span>
|
|
47
|
-
@else
|
|
48
|
-
<span class="flex items-center gap-1.5">
|
|
49
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
50
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
|
51
|
-
</svg>
|
|
52
|
-
Copy
|
|
53
|
-
</span>
|
|
54
|
-
@endif
|
|
55
|
-
</button>
|
|
56
|
-
@endif
|
|
57
|
-
</div>
|