zs3-ui-components 1.2.2 → 1.2.3

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.

Potentially problematic release.


This version of zs3-ui-components might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zs3-ui-components",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,318 +0,0 @@
1
- /**
2
- * Opcions per al mètode emit
3
- */
4
- export interface EmitOptions {
5
- /** Si és true, no es bloqueja l'event quan el component està disabled/loading */
6
- skipDisabledCheck?: boolean;
7
- /** Si és true, l'event és cancelable */
8
- cancelable?: boolean;
9
- /** Si és true, l'event fa bubbling */
10
- bubbles?: boolean;
11
- /** Si és true, l'event travessa shadow DOM boundaries */
12
- composed?: boolean;
13
- }
14
- /**
15
- * Interfície per opcions de configuració del component base
16
- */
17
- export interface BaseComponentOptions {
18
- useShadowDOM?: boolean;
19
- shadowMode?: 'open' | 'closed';
20
- delegatesFocus?: boolean;
21
- slotAssignment?: 'manual' | 'named';
22
- clonable?: boolean;
23
- serializable?: boolean;
24
- }
25
- /**
26
- * Tipus per atributs observats
27
- */
28
- export type AttributeChangeCallback = (name: string, oldValue: string | null, newValue: string | null) => void;
29
- /**
30
- * Base component class for ZS3 components.
31
- * Provides common functionality shared across all ZS3 components.
32
- * Follows modern Web Components standards and best practices.
33
- *
34
- * @example
35
- * class MyComponent extends $BaseComponent {
36
- * static observedAttributes = ['value', 'disabled'];
37
- *
38
- * constructor() {
39
- * super({ useShadowDOM: true, shadowMode: 'open' });
40
- * }
41
- *
42
- * render() {
43
- * this.shadowRoot.innerHTML = `<div>Content</div>`;
44
- * }
45
- * }
46
- */
47
- export declare abstract class $BaseComponent extends HTMLElement {
48
- /**
49
- * Shadow root reference (if using Shadow DOM)
50
- */
51
- protected _shadowRoot: ShadowRoot | null;
52
- /**
53
- * Component initialization state
54
- */
55
- protected _initialized: boolean;
56
- /**
57
- * Component mounted state
58
- */
59
- protected _mounted: boolean;
60
- /**
61
- * Attribute change handlers
62
- */
63
- protected _attributeHandlers: Map<string, AttributeChangeCallback>;
64
- /**
65
- * Event cleanup functions
66
- */
67
- protected _cleanupFunctions: Array<() => void>;
68
- /**
69
- * Theme change handler reference
70
- */
71
- private _themeChangeHandler;
72
- /**
73
- * Locale change handler reference
74
- */
75
- private _localeChangeHandler;
76
- /**
77
- * Component configuration options
78
- */
79
- protected _options: BaseComponentOptions;
80
- /**
81
- * Selector de l'element intern sobre el qual s'aplica l'efecte float.
82
- * Els components fills han de definir aquesta propietat si volen suportar float.
83
- * @example this._floatTargetSelector = 'button' // per zs3-button
84
- * @example this._floatTargetSelector = '.toolbar' // per zs3-toolbar
85
- */
86
- protected _floatTargetSelector: string | null;
87
- /**
88
- * Selector de l'element contenidor que es mourà.
89
- * Els components fills han de definir aquesta propietat si volen suportar move.
90
- * @example this._moveContainerSelector = '.window' // per zs3-window
91
- */
92
- protected _moveContainerSelector: string | null;
93
- /**
94
- * Selector de l'element sobre el qual es fa el click per arrossegar (drag handle).
95
- * Si no es defineix, s'usa el mateix element que _moveContainerSelector.
96
- * @example this._moveDragSelector = '.title-bar' // per zs3-window
97
- */
98
- protected _moveDragSelector: string | null;
99
- /**
100
- * Initializes the base component
101
- * @param options - Configuration options for the component
102
- */
103
- constructor(options?: BaseComponentOptions);
104
- /**
105
- * Initialize component (called in constructor)
106
- * Override this method to perform setup logic
107
- */
108
- protected initialize(): void;
109
- /**
110
- * Get the root element (shadow root or element itself)
111
- */
112
- protected get root(): ShadowRoot | HTMLElement;
113
- /**
114
- * Query selector within the component's root
115
- * @param selector - CSS selector to query
116
- * @returns Found element or null
117
- */
118
- protected qs<T extends HTMLElement = HTMLElement>(selector: string): T | null;
119
- /**
120
- * Query all matching elements within the component's root
121
- * @param selector - CSS selector to query
122
- * @returns NodeList of found elements
123
- */
124
- protected qsAll<T extends HTMLElement = HTMLElement>(selector: string): NodeListOf<T>;
125
- /**
126
- * Register an attribute change handler
127
- * @param attributeName - Name of the attribute to observe
128
- * @param handler - Callback function
129
- */
130
- protected onAttributeChange(attributeName: string, handler: AttributeChangeCallback): void;
131
- /**
132
- * Add event listener with automatic cleanup
133
- * @param element - Element to attach listener to
134
- * @param event - Event name
135
- * @param handler - Event handler
136
- * @param options - Event listener options
137
- */
138
- protected addManagedEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement | Window | Document, event: K | string, handler: EventListener, options?: AddEventListenerOptions): void;
139
- /**
140
- * Emit a custom event
141
- * @param eventName - Name of the event
142
- * @param detail - Event detail data
143
- * @param options - Emit options
144
- */
145
- protected emit<T>(eventName: string, detail?: T, options?: EmitOptions): boolean;
146
- /**
147
- * Emit lifecycle event (internal use)
148
- * Uses emit with skipDisabledCheck=true since lifecycle events
149
- * should always fire regardless of disabled/loading state
150
- * @param eventName - Event name
151
- * @param detail - Event detail
152
- */
153
- protected emitLifecycleEvent(eventName: string, detail?: Record<string, unknown>): void;
154
- /**
155
- * Get attribute as boolean
156
- * @param name - Attribute name
157
- * @param defaultValue - Default value if attribute is not set
158
- */
159
- getBooleanAttribute(name: string, defaultValue?: boolean): boolean;
160
- /**
161
- * Get attribute as number
162
- * @param name - Attribute name
163
- * @param defaultValue - Default value if attribute is not set or invalid
164
- */
165
- getNumberAttribute(name: string, defaultValue?: number): number;
166
- /**
167
- * Get attribute as array (comma-separated)
168
- * @param name - Attribute name
169
- * @param defaultValue - Default value if attribute is not set
170
- */
171
- protected getArrayAttribute(name: string, defaultValue?: string[]): string[];
172
- /**
173
- * Set boolean attribute
174
- * @param name - Attribute name
175
- * @param value - Boolean value
176
- */
177
- setBooleanAttribute(name: string, value: boolean): void;
178
- /**
179
- * Aplica l'efecte float al component si està configurat.
180
- * Aquest mètode es crida automàticament després de mount i després de cada render.
181
- * Els components fills han de definir `_floatTargetSelector` per activar aquesta funcionalitat.
182
- */
183
- protected applyFloatEffect(): void;
184
- /**
185
- * Aplica l'efecte move (drag & drop) al component si està configurat.
186
- * Aquest mètode es crida automàticament després de mount i després de cada render.
187
- * Els components fills han de definir `_moveContainerSelector` per activar aquesta funcionalitat.
188
- * - Si `_moveContainerSelector` és ':host', es mou el component sencer.
189
- * - Opcionalment poden definir `_moveDragSelector` per especificar un element diferent per fer el drag.
190
- *
191
- * L'atribut `move` pot tenir els valors: 'x' (horitzontal), 'y' (vertical), 'xy' (ambdós)
192
- */
193
- protected applyMoveEffect(): void;
194
- /**
195
- * Request an animation frame update
196
- * Useful for batching DOM updates
197
- */
198
- protected requestUpdate(): Promise<void>;
199
- /**
200
- * Debounce a function call
201
- * @param fn - Function to debounce
202
- * @param delay - Delay in milliseconds
203
- */
204
- protected debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
205
- /**
206
- * Safely update innerHTML with sanitization warning
207
- * @param html - HTML string to set
208
- * @param target - Target element (defaults to root)
209
- */
210
- protected setHTML(html: string, target?: HTMLElement | ShadowRoot): void;
211
- /**
212
- * Called when the element is inserted into the DOM
213
- * Standard Web Components lifecycle method
214
- */
215
- connectedCallback(): void;
216
- /**
217
- * Called when the element is removed from the DOM
218
- * Standard Web Components lifecycle method
219
- */
220
- disconnectedCallback(): void;
221
- /**
222
- * Called when the element is adopted into a new document
223
- * Standard Web Components lifecycle method
224
- */
225
- adoptedCallback(): void;
226
- /**
227
- * Called when an observed attribute changes
228
- * Standard Web Components lifecycle method
229
- * @param name - Attribute name
230
- * @param oldValue - Previous value
231
- * @param newValue - New value
232
- */
233
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
234
- /**
235
- * Hook called before component is mounted
236
- * Override this in subclasses for custom logic
237
- */
238
- protected beforeMount(): void;
239
- /**
240
- * Hook called after component is mounted
241
- * Override this in subclasses for custom logic
242
- */
243
- protected afterMount(): void;
244
- /**
245
- * Hook called before component is unmounted
246
- * Override this in subclasses for cleanup logic
247
- */
248
- protected beforeUnmount(): void;
249
- /**
250
- * Hook called when component is adopted to new document
251
- * Override this in subclasses for custom logic
252
- */
253
- protected onAdopted(): void;
254
- /**
255
- * Internal handler for theme change events
256
- * @param e - Theme change event
257
- */
258
- private handleThemeChange;
259
- /**
260
- * Hook called when theme changes
261
- * Override this in subclasses for custom theme handling
262
- * @param theme - New theme name
263
- */
264
- protected onThemeChange(_theme: string): void;
265
- /**
266
- * Internal handler for locale change events
267
- * @param e - Locale change event
268
- */
269
- private handleLocaleChange;
270
- /**
271
- * Hook called when locale changes
272
- * Override this in subclasses for custom locale handling
273
- * @param locale - New locale code
274
- */
275
- protected onLocaleChange(_locale: string): void;
276
- /**
277
- * Translate a key using the i18n system
278
- * @param key - Translation key
279
- * @param params - Optional parameters for interpolation
280
- * @returns Translated string or key if not found
281
- */
282
- protected t(key: string, params?: Record<string, string | number>): string;
283
- /**
284
- * Check if a translation exists
285
- * @param key - Translation key
286
- * @returns True if translation exists
287
- */
288
- protected hasTranslation(key: string): boolean;
289
- /**
290
- * Get translated attribute value
291
- * If i18n-{attrName} attribute exists, translate that key
292
- * Otherwise return the original attribute value or default
293
- * @param attrName - Attribute name
294
- * @param defaultValue - Default value if no attribute
295
- */
296
- protected getTranslatedAttribute(attrName: string, defaultValue?: string): string;
297
- /**
298
- * Hook called when an attribute changes
299
- * Override this in subclasses for custom logic
300
- * @param name - Attribute name
301
- * @param oldValue - Previous value
302
- * @param newValue - New value
303
- */
304
- protected onAttributeChanged(_name: string, _oldValue: string | null, _newValue: string | null): void;
305
- /**
306
- * Render the component
307
- * This should be overridden by subclasses to define rendering logic
308
- */
309
- abstract render(): void;
310
- /**
311
- * Get component state (for debugging)
312
- */
313
- getState(): Record<string, unknown>;
314
- /**
315
- * Force re-render
316
- */
317
- forceUpdate(): void;
318
- }