@seip/blue-bird 1.1.3 → 1.1.4

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.
@@ -0,0 +1,423 @@
1
+ /**
2
+ * Blue Bird CSS & JS Frontend Type Definitions
3
+ * Complete IDE IntelliSense and autocompletion for components and UI helpers.
4
+ * @module bluebird
5
+ */
6
+
7
+ /**
8
+ * Valid UI component names supported by the Blue Bird JS runtime.
9
+ */
10
+ export type BlueBirdComponent =
11
+ | "snackbar"
12
+ | "toast"
13
+ | "tab"
14
+ | "command"
15
+ | "popover"
16
+ | "drawer"
17
+ | "modal"
18
+ | "carousel"
19
+ | "theme"
20
+ | "copy"
21
+ | "datatable"
22
+ | "table";
23
+
24
+ /**
25
+ * Configuration options for the Snackbar component.
26
+ */
27
+ export interface BlueBirdSnackbarOptions {
28
+ /** Text message to display inside the snackbar. */
29
+ message?: string;
30
+ /** Visual theme variant. Defaults to 'info'. */
31
+ type?: "info" | "success" | "error" | "warning";
32
+ /** Duration in milliseconds before auto-dismissing. Defaults to 3000ms. */
33
+ duration?: number;
34
+ }
35
+
36
+ /**
37
+ * Configuration options for the Multi-Toast Notification System.
38
+ */
39
+ export interface BlueBirdToastOptions {
40
+ /** Optional bold header title for the toast. */
41
+ title?: string;
42
+ /** Optional detailed subtitle or description. */
43
+ description?: string;
44
+ /** Main body message content. */
45
+ message?: string;
46
+ /** Visual type styling. Defaults to 'info'. */
47
+ type?: "info" | "success" | "error" | "warning";
48
+ /** Screen position anchor. Defaults to 'bottom-right'. */
49
+ position?:
50
+ | "top-left"
51
+ | "top-right"
52
+ | "bottom-left"
53
+ | "bottom-right"
54
+ | "top-center"
55
+ | "bottom-center";
56
+ /** Auto-dismiss duration in milliseconds (set to 0 for persistent toast). Defaults to 4000ms. */
57
+ duration?: number;
58
+ }
59
+
60
+ /**
61
+ * Options for switching tab panels.
62
+ */
63
+ export interface BlueBirdTabOptions {
64
+ /** The element ID of the target .tab-content panel to activate. */
65
+ id: string;
66
+ }
67
+
68
+ /**
69
+ * Options for the Command Palette (`Ctrl+K` / `Cmd+K`).
70
+ */
71
+ export interface BlueBirdCommandOptions {
72
+ /** Action to perform on the command palette modal. Defaults to 'toggle'. */
73
+ action?: "open" | "close" | "toggle";
74
+ }
75
+
76
+ /**
77
+ * Options for Popover elements.
78
+ */
79
+ export interface BlueBirdPopoverOptions {
80
+ /** ID or data-popover-id of the target popover element. */
81
+ id: string;
82
+ /** Action to perform. Defaults to 'toggle'. */
83
+ action?: "open" | "close" | "toggle";
84
+ }
85
+
86
+ /**
87
+ * Options for Side Drawers and off-canvas menus.
88
+ */
89
+ export interface BlueBirdDrawerOptions {
90
+ /** Element ID of the .drawer container. */
91
+ id: string;
92
+ /** Action to perform. Defaults to 'toggle'. */
93
+ action?: "open" | "close" | "toggle";
94
+ }
95
+
96
+ /**
97
+ * Options for Dialog Modals.
98
+ */
99
+ export interface BlueBirdModalOptions {
100
+ /** Element ID of the .modal container. */
101
+ id: string;
102
+ /** Action to perform. Defaults to 'toggle'. */
103
+ action?: "open" | "close" | "toggle";
104
+ }
105
+
106
+ /**
107
+ * Options for Image / Content Carousels.
108
+ */
109
+ export interface BlueBirdCarouselOptions {
110
+ /** Optional element ID of the target .carousel. */
111
+ id?: string;
112
+ /** Carousel slide navigation action. */
113
+ action?: "next" | "prev" | "goto";
114
+ /** Target 0-based slide index when using action: 'goto'. */
115
+ index?: number;
116
+ }
117
+
118
+ /**
119
+ * Options for Color Theme switcher.
120
+ */
121
+ export interface BlueBirdThemeOptions {
122
+ /** Action to perform on application theme. */
123
+ action?: "toggle" | "set";
124
+ /** Target theme when using action: 'set'. */
125
+ theme?: "light" | "dark";
126
+ }
127
+
128
+ /**
129
+ * Options for Clipboard copying helper.
130
+ */
131
+ export interface BlueBirdCopyOptions {
132
+ /** Text string to copy to clipboard. */
133
+ text: string;
134
+ /** Whether to show automatic snackbar/toast feedback on copy. Defaults to true. */
135
+ feedback?: boolean;
136
+ }
137
+
138
+ /**
139
+ * Column definition for ResponsiveDataTable.
140
+ */
141
+ export interface ResponsiveDataTableColumn<T = any> {
142
+ /** The data key property name. */
143
+ key: keyof T | string;
144
+ /** Custom header title text. If omitted, key is used. */
145
+ title?: string;
146
+ }
147
+
148
+ /**
149
+ * Configuration options for ResponsiveDataTable.
150
+ */
151
+ export interface ResponsiveDataTableOptions<T = any> {
152
+ /** Array of data objects to display. */
153
+ data?: T[];
154
+ /** Column definitions. */
155
+ columns?: ResponsiveDataTableColumn<T>[];
156
+ /** Rows per page. Defaults to 10. */
157
+ rowsPerPage?: number;
158
+ /** Enable search input. Defaults to true. */
159
+ search?: boolean;
160
+ /** Enable pagination controls. Defaults to true. */
161
+ pagination?: boolean;
162
+ /** Custom header titles mapping ({ key: 'Custom Title' }). */
163
+ headerTitles?: Record<string, string>;
164
+ /** Key names to display in the card header on mobile view. Defaults to ['id']. */
165
+ summaryFields?: string[];
166
+ /** Enable edit button or provide click callback `(event, item) => void`. */
167
+ edit?: boolean | ((event: MouseEvent, item: T) => void) | string;
168
+ /** Enable delete button or provide click callback `(event, item) => void`. */
169
+ delete?: boolean | ((event: MouseEvent, item: T) => void) | string;
170
+ /** Responsive mobile breakpoint in pixels. Defaults to 768. */
171
+ breakpoint?: number;
172
+ /** Container element or ID. */
173
+ container?: string | HTMLElement;
174
+ /** Container ID alias. */
175
+ id?: string;
176
+ }
177
+
178
+ /**
179
+ * Responsive Data Table class with mobile card layout, live search, and pagination.
180
+ */
181
+ export class ResponsiveDataTable<T = any> {
182
+ container: HTMLElement;
183
+ options: ResponsiveDataTableOptions<T>;
184
+ currentPage: number;
185
+ filteredData: T[];
186
+ isMobile: boolean;
187
+
188
+ /**
189
+ * Initializes a new ResponsiveDataTable instance.
190
+ * @param containerId - ID of the container element or HTMLElement.
191
+ * @param options - Table configuration options.
192
+ * @example
193
+ * const table = new ResponsiveDataTable('users-table', {
194
+ * data: [{ id: 1, name: 'Alice', email: 'alice@example.com' }],
195
+ * columns: [
196
+ * { key: 'id', title: 'ID' },
197
+ * { key: 'name', title: 'Name' },
198
+ * { key: 'email', title: 'Email' }
199
+ * ],
200
+ * rowsPerPage: 10,
201
+ * search: true,
202
+ * pagination: true,
203
+ * edit: (e, user) => console.log('Edit', user),
204
+ * delete: (e, user) => console.log('Delete', user)
205
+ * });
206
+ */
207
+ constructor(containerId: string | HTMLElement, options?: ResponsiveDataTableOptions<T>);
208
+
209
+ /** Updates the table with new data and resets to page 1. */
210
+ updateData(newData: T[]): void;
211
+
212
+ /** Updates the column schema and re-renders table. */
213
+ updateColumns(newColumns: ResponsiveDataTableColumn<T>[]): void;
214
+
215
+ /** Navigates to the specified page number. */
216
+ changePage(page: number): void;
217
+ }
218
+
219
+ /**
220
+ * Universal Blue Bird JavaScript helper function.
221
+ */
222
+ export interface BlueBirdHelper {
223
+ /**
224
+ * Displays a single notification snackbar at the bottom of the screen.
225
+ * @param component - Component identifier ('snackbar').
226
+ * @param options - Configuration options.
227
+ * @example
228
+ * bluebird('snackbar', {
229
+ * message: 'Changes saved successfully!',
230
+ * type: 'success',
231
+ * duration: 3000
232
+ * });
233
+ */
234
+ (component: "snackbar", options?: BlueBirdSnackbarOptions): void;
235
+
236
+ /**
237
+ * Spawns a floating toast notification in the specified screen position.
238
+ * @param component - Component identifier ('toast').
239
+ * @param options - Toast configuration options.
240
+ * @example
241
+ * bluebird('toast', {
242
+ * title: 'New Message',
243
+ * message: 'You received a notification from Alice',
244
+ * type: 'info',
245
+ * position: 'top-right',
246
+ * duration: 4000
247
+ * });
248
+ */
249
+ (component: "toast", options?: BlueBirdToastOptions): void;
250
+
251
+ /**
252
+ * Activates a tab content panel and highlights its corresponding tab trigger.
253
+ * @param component - Component identifier ('tab').
254
+ * @param options - Target tab ID.
255
+ * @example
256
+ * bluebird('tab', { id: 'tab-security' });
257
+ */
258
+ (component: "tab", options?: BlueBirdTabOptions): void;
259
+
260
+ /**
261
+ * Controls the global command palette modal (`Ctrl+K` / `Cmd+K`).
262
+ * @param component - Component identifier ('command').
263
+ * @param options - Action to perform.
264
+ * @example
265
+ * bluebird('command', { action: 'open' });
266
+ */
267
+ (component: "command", options?: BlueBirdCommandOptions): void;
268
+
269
+ /**
270
+ * Shows, hides, or toggles a popover dropdown by element ID.
271
+ * @param component - Component identifier ('popover').
272
+ * @param options - Popover target ID and action.
273
+ * @example
274
+ * bluebird('popover', { id: 'user-profile-menu', action: 'toggle' });
275
+ */
276
+ (component: "popover", options?: BlueBirdPopoverOptions): void;
277
+
278
+ /**
279
+ * Opens or closes a slide-out drawer menu with background backdrop.
280
+ * @param component - Component identifier ('drawer').
281
+ * @param options - Drawer element ID and action.
282
+ * @example
283
+ * bluebird('drawer', { id: 'mobile-nav', action: 'open' });
284
+ */
285
+ (component: "drawer", options?: BlueBirdDrawerOptions): void;
286
+
287
+ /**
288
+ * Shows or hides an accessible dialog modal.
289
+ * @param component - Component identifier ('modal').
290
+ * @param options - Modal element ID and action.
291
+ * @example
292
+ * bluebird('modal', { id: 'delete-confirm-modal', action: 'open' });
293
+ */
294
+ (component: "modal", options?: BlueBirdModalOptions): void;
295
+
296
+ /**
297
+ * Controls carousel slides navigation (next, previous, or jump to index).
298
+ * @param component - Component identifier ('carousel').
299
+ * @param options - Carousel ID and slide action.
300
+ * @example
301
+ * bluebird('carousel', { id: 'hero-slider', action: 'next' });
302
+ */
303
+ (component: "carousel", options?: BlueBirdCarouselOptions): void;
304
+
305
+ /**
306
+ * Toggles or sets the color theme mode (light / dark) and persists preference to localStorage.
307
+ * @param component - Component identifier ('theme').
308
+ * @param options - Theme action and target mode.
309
+ * @example
310
+ * bluebird('theme', { action: 'toggle' });
311
+ */
312
+ (component: "theme", options?: BlueBirdThemeOptions): void;
313
+
314
+ /**
315
+ * Copies text string to clipboard with optional user feedback.
316
+ * @param component - Component identifier ('copy').
317
+ * @param options - Text to copy.
318
+ * @example
319
+ * bluebird('copy', { text: 'https://myapp.com', feedback: true });
320
+ */
321
+ (component: "copy", options?: BlueBirdCopyOptions): void;
322
+
323
+ /**
324
+ * Initializes and renders a ResponsiveDataTable.
325
+ * @param component - Component identifier ('datatable' | 'table').
326
+ * @param options - Data table options and container ID.
327
+ * @example
328
+ * bluebird('datatable', {
329
+ * container: 'users-table',
330
+ * data: [{ id: 1, name: 'Alice' }],
331
+ * columns: [{ key: 'id', title: 'ID' }, { key: 'name', title: 'Name' }]
332
+ * });
333
+ */
334
+ <T = any>(
335
+ component: "datatable" | "table",
336
+ options: ResponsiveDataTableOptions<T>
337
+ ): ResponsiveDataTable<T>;
338
+
339
+ /**
340
+ * Shorthand snackbar invocation.
341
+ * @param options - Snackbar options object.
342
+ * @example
343
+ * bluebird({ message: 'Quick alert message', type: 'warning' });
344
+ */
345
+ (options: BlueBirdSnackbarOptions): void;
346
+
347
+ /**
348
+ * Generic component dispatcher.
349
+ */
350
+ (component: string, options?: any): any;
351
+ }
352
+
353
+ /**
354
+ * Modern fetch wrapper with automatic CSRF token support, credentials inclusion, and JSON error handling.
355
+ * @param url - Target endpoint URL. Defaults to '/'.
356
+ * @param method - HTTP method. Defaults to 'GET'.
357
+ * @param body - JSON body object. Defaults to false.
358
+ * @param bodyForm - FormData payload. Defaults to false.
359
+ * @param headers - Custom HTTP headers.
360
+ * @returns Parsed JSON response.
361
+ * @example
362
+ * const data = await Http('/api/users', 'POST', { name: 'Alice' });
363
+ */
364
+ export function Http<T = any>(
365
+ url?: string,
366
+ method?: string,
367
+ body?: any,
368
+ bodyForm?: FormData | boolean,
369
+ headers?: Record<string, string>
370
+ ): Promise<T>;
371
+
372
+ /**
373
+ * Extracts a query parameter from the current URL search string.
374
+ * @param name - Query parameter key name.
375
+ * @returns Parameter value string or null.
376
+ * @example
377
+ * const userId = getUrlParameter('id');
378
+ */
379
+ export function getUrlParameter(name: string): string | null;
380
+
381
+ /**
382
+ * Displays a single notification snackbar at the bottom of the screen.
383
+ * @param options - Snackbar configuration options.
384
+ */
385
+ export function snackbar(options: BlueBirdSnackbarOptions): void;
386
+
387
+ /**
388
+ * Spawns a floating toast notification.
389
+ * @param options - Toast configuration options.
390
+ */
391
+ export function toast(options: BlueBirdToastOptions): void;
392
+
393
+ declare global {
394
+ /** Global Blue Bird Frontend Helper */
395
+ const bluebird: BlueBirdHelper;
396
+ /** Responsive Data Table class */
397
+ const ResponsiveDataTable: typeof import("./bluebird.js").ResponsiveDataTable;
398
+ /** Modern fetch wrapper with automatic CSRF token support */
399
+ const Http: typeof import("./bluebird.js").Http;
400
+ /** Extracts a query parameter from the current URL search string */
401
+ const getUrlParameter: typeof import("./bluebird.js").getUrlParameter;
402
+ /** Displays a single notification snackbar */
403
+ const snackbar: typeof import("./bluebird.js").snackbar;
404
+ /** Spawns a floating toast notification */
405
+ const toast: typeof import("./bluebird.js").toast;
406
+
407
+ interface Window {
408
+ /** Global Blue Bird Frontend Helper */
409
+ bluebird: BlueBirdHelper;
410
+ /** Responsive Data Table class */
411
+ ResponsiveDataTable: typeof ResponsiveDataTable;
412
+ /** Modern fetch wrapper with automatic CSRF token support */
413
+ Http: typeof Http;
414
+ /** Extracts a query parameter from the current URL search string */
415
+ getUrlParameter: typeof getUrlParameter;
416
+ /** Displays a single notification snackbar */
417
+ snackbar: typeof snackbar;
418
+ /** Spawns a floating toast notification */
419
+ toast: typeof toast;
420
+ }
421
+ }
422
+
423
+ export default bluebird;