@yokowasis/types-webcomponents 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/index.d.ts +488 -0
  4. package/package.json +24 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yokowasis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @yokowasis/types-webcomponents
2
+
3
+ TypeScript type definitions for the custom elements in the yokowasis webcomponents project.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -D @yokowasis/types-webcomponents
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ pnpm add -D @yokowasis/types-webcomponents
15
+ ```
16
+
17
+ ## What it provides
18
+
19
+ - `HTMLElementTagNameMap` entries for custom elements like `cs-dashboard`, `cs-data-table`, `cs-input`, and more.
20
+ - JSX intrinsic element typing.
21
+ - Svelte `svelteHTML.IntrinsicElements` typing.
22
+ - Global helper typings for `toast`, `getVal`, and `setVal`.
23
+
24
+ ## Usage
25
+
26
+ No runtime import is required. Ensure your `tsconfig.json` includes the package types (usually automatic under `node_modules`).
package/index.d.ts ADDED
@@ -0,0 +1,488 @@
1
+ type CSIcons =
2
+ | "add"
3
+ | "apps"
4
+ | "calendar"
5
+ | "cancel"
6
+ | "check"
7
+ | "chevron_left"
8
+ | "chevron_right"
9
+ | "cloud"
10
+ | "dashboard"
11
+ | "delete"
12
+ | "document"
13
+ | "dropdown"
14
+ | "edit"
15
+ | "error"
16
+ | "excel"
17
+ | "home"
18
+ | "info"
19
+ | "invoice"
20
+ | "key"
21
+ | "list"
22
+ | "mail"
23
+ | "maintenance"
24
+ | "pdf"
25
+ | "reload"
26
+ | "send"
27
+ | "server"
28
+ | "signin"
29
+ | "signout"
30
+ | "signup"
31
+ | "upload"
32
+ | "user"
33
+ | "warning"
34
+ | "word";
35
+
36
+ type ToastPosition = "top-right" | "top-left" | "bottom-right" | "bottom-left";
37
+ type ToastType =
38
+ | "primary"
39
+ | "secondary"
40
+ | "success"
41
+ | "danger"
42
+ | "info"
43
+ | "warning";
44
+ type DataTableFieldType =
45
+ | "text"
46
+ | "number"
47
+ | "password"
48
+ | "date"
49
+ | "time"
50
+ | "select"
51
+ | "radio"
52
+ | "checkbox"
53
+ | "upload"
54
+ | "rtf";
55
+
56
+ interface DashboardNavChild {
57
+ title: string;
58
+ link: string;
59
+ }
60
+
61
+ interface DashboardNavItem {
62
+ title: string;
63
+ link?: string;
64
+ icon?: string;
65
+ active?: boolean;
66
+ childs?: DashboardNavChild[];
67
+ }
68
+
69
+ interface DashboardTopLink {
70
+ title: string;
71
+ icon?: string;
72
+ link?: string;
73
+ }
74
+
75
+ interface DataTableColumn {
76
+ key: string;
77
+ title: string;
78
+ type?: DataTableFieldType;
79
+ data?: string | string[];
80
+ dataValue?: string | string[];
81
+ renderer?: (
82
+ value: unknown,
83
+ row: Record<string, unknown>,
84
+ rowIndex: number,
85
+ column: DataTableColumn,
86
+ ) => string;
87
+ readonly?: boolean;
88
+ placeholder?: string;
89
+ note?: string;
90
+ }
91
+
92
+ interface CSDashboardElement extends HTMLElement {
93
+ logo: string;
94
+ title: string;
95
+ subtitle: string;
96
+ sidebar: Record<string, DashboardNavItem[]>;
97
+ breadcrumb: string[];
98
+ links: DashboardTopLink[];
99
+ activePath: string;
100
+ }
101
+
102
+ interface CSInputElement extends HTMLElement {
103
+ value: string;
104
+ label?: string;
105
+ icon?: CSIcons;
106
+ type?: "text" | "number" | "password" | "date" | "time";
107
+ note?: string;
108
+ mode?: string;
109
+ readonly?: string | boolean;
110
+ placeholder?: string;
111
+ theme?: "mui" | "tailwind" | string;
112
+ onchange?: (event: Event) => void;
113
+ }
114
+
115
+ interface CSSelectElement extends HTMLElement {
116
+ value?: string;
117
+ data?: string;
118
+ dataValue?: string;
119
+ label?: string;
120
+ placeholder?: string;
121
+ onchange?: (event: CustomEvent<{ target: { value: string } }>) => void;
122
+ }
123
+
124
+ interface CSRadioElement extends HTMLElement {
125
+ type: "radio" | "checkbox";
126
+ value?: string;
127
+ label?: string;
128
+ data?: string;
129
+ dataValue?: string;
130
+ cols?: number | string;
131
+ note?: string;
132
+ style?: string;
133
+ onchange?: (event: CustomEvent<{ target: HTMLInputElement }>) => void;
134
+ }
135
+
136
+ interface CSUploadElement extends HTMLElement {
137
+ value?: string;
138
+ label?: string;
139
+ note?: string;
140
+ mode?: string;
141
+ limit?: number | string;
142
+ server?: string;
143
+ onchange?: (event: Event | CustomEvent<{ target: HTMLInputElement }>) => void;
144
+ uploadBlob(blob: Blob, filename: string, server: string): Promise<string>;
145
+ fetchFileSize(url: string): Promise<void>;
146
+ formatFileSize(bytes: number): string;
147
+ }
148
+
149
+ interface CSRTFElement extends HTMLElement {
150
+ value?: string;
151
+ rows?: number | string;
152
+ label?: string;
153
+ placeholder?: string;
154
+ note?: string;
155
+ toolbar?: string;
156
+ server?: string;
157
+ mode?: string;
158
+ editorReady: boolean;
159
+ onchange?: (event: CustomEvent<{ target: unknown }>) => void;
160
+ uploadBlob(blob: Blob, filename: string, server: string): Promise<string>;
161
+ remove(): void;
162
+ }
163
+
164
+ interface CSModalElement extends HTMLElement {
165
+ open?: boolean;
166
+ title?: string;
167
+ width?: string;
168
+ confirmText?: string;
169
+ confirm?: () => void;
170
+ close?: () => void;
171
+ show(): void;
172
+ hide(): void;
173
+ }
174
+
175
+ interface CSDataTableElement extends HTMLElement {
176
+ columns: DataTableColumn[];
177
+ data: Array<Record<string, unknown>>;
178
+ onAdd?: (payload: Record<string, unknown>) => unknown;
179
+ onEdit?: (
180
+ payload: Record<string, unknown>,
181
+ row: Record<string, unknown>,
182
+ rowIndex: number,
183
+ ) => unknown;
184
+ onDelete?: (row: Record<string, unknown>, rowIndex: number) => unknown;
185
+ }
186
+
187
+ interface CSSortableElement extends HTMLElement {
188
+ deleteable?: "" | "true" | "false";
189
+ insertable?: "" | "true" | "false";
190
+ readonly items: Element[];
191
+ }
192
+
193
+ interface CSToastElement extends HTMLElement {
194
+ showToast(
195
+ message: string,
196
+ type?: ToastType,
197
+ position?: ToastPosition,
198
+ durationMs?: number,
199
+ ): void;
200
+ showLoadingToast(
201
+ message?: string,
202
+ position?: ToastPosition,
203
+ ): HTMLElement | null;
204
+ removeToast(toastEl?: HTMLElement | null): void;
205
+ getToastContainer(position: ToastPosition): HTMLElement | null;
206
+ }
207
+
208
+ interface CSSidebarElement extends HTMLElement {
209
+ title?: string;
210
+ description?: string;
211
+ links?: string;
212
+ urls?: string;
213
+ logo?: string;
214
+ show?: string;
215
+ }
216
+
217
+ interface CSInfoCardElement extends HTMLElement {
218
+ title?: string;
219
+ value?: string;
220
+ unit?: string;
221
+ link?: string;
222
+ background?: string;
223
+ }
224
+
225
+ interface CSIconElement extends HTMLElement {
226
+ c?: CSIcons;
227
+ icon?: CSIcons;
228
+ color?: string;
229
+ invert?: "" | "true" | "false";
230
+ }
231
+
232
+ interface CSListIconElement extends HTMLElement {}
233
+
234
+ type CSIntrinsicElements = {
235
+ "cs-dashboard": Partial<CSDashboardElement> & {
236
+ id: string;
237
+ logo?: string;
238
+ title?: string;
239
+ subtitle?: string;
240
+ breadcrumb?: string;
241
+ sidebar?: Record<string, DashboardNavItem[]>;
242
+ links?: DashboardTopLink[];
243
+ activePath?: string;
244
+ onbreadcrumbclick?: (
245
+ event: CustomEvent<{ index: number; item: string }>,
246
+ ) => void;
247
+ };
248
+ "cs-input": Partial<CSInputElement> & {
249
+ id: string;
250
+ value?: string;
251
+ label?: string;
252
+ icon?: CSIcons;
253
+ type?: "text" | "number" | "password" | "date" | "time";
254
+ note?: string;
255
+ mode?: "dark" | string;
256
+ readonly?: "readonly" | "true" | "false" | boolean;
257
+ placeholder?: string;
258
+ theme?: "mui" | "tailwind" | string;
259
+ onchange?: (event: Event) => void;
260
+ };
261
+ "cs-select": Partial<CSSelectElement> & {
262
+ id: string;
263
+ value?: string;
264
+ label?: string;
265
+ data?: string | string[];
266
+ dataValue?: string | string[];
267
+ "data-value"?: string;
268
+ datavalue?: string;
269
+ placeholder?: string;
270
+ onchange?: (event: CustomEvent<{ target: { value: string } }>) => void;
271
+ };
272
+ "cs-radio": Partial<CSRadioElement> & {
273
+ id: string;
274
+ type: "radio" | "checkbox";
275
+ value?: string;
276
+ label?: string;
277
+ data?: string | string[];
278
+ dataValue?: string | string[];
279
+ "data-value"?: string;
280
+ datavalue?: string;
281
+ cols?: number | string;
282
+ note?: string;
283
+ style?: string;
284
+ onchange?: (event: CustomEvent<{ target: HTMLInputElement }>) => void;
285
+ };
286
+ "cs-upload": Partial<CSUploadElement> & {
287
+ id: string;
288
+ value?: string;
289
+ label?: string;
290
+ note?: string;
291
+ mode?: "dark" | string;
292
+ limit?: number | string;
293
+ server?: string;
294
+ onchange?: (
295
+ event: Event | CustomEvent<{ target: HTMLInputElement }>,
296
+ ) => void;
297
+ };
298
+ "cs-rtf": Partial<CSRTFElement> & {
299
+ id?: string;
300
+ value?: string;
301
+ rows?: number | string;
302
+ label?: string;
303
+ placeholder?: string;
304
+ note?: string;
305
+ toolbar?: string;
306
+ server?: string;
307
+ mode?: "dark" | string;
308
+ onchange?: (event: CustomEvent<{ target: unknown }>) => void;
309
+ onready?: (event: CustomEvent<{ editor: unknown; id: string }>) => void;
310
+ };
311
+ "cs-modal": Partial<CSModalElement> & {
312
+ id?: string;
313
+ open?: boolean | "" | "true" | "false";
314
+ title?: string;
315
+ width?: string;
316
+ "confirm-text"?: string;
317
+ onconfirm?: (event: CustomEvent<{ target: CSModalElement }>) => void;
318
+ onclose?: (event: CustomEvent) => void;
319
+ children?: unknown;
320
+ };
321
+ "cs-data-table": Partial<CSDataTableElement> & {
322
+ id?: string;
323
+ title?: string;
324
+ columns?: DataTableColumn[] | string;
325
+ data?: Array<Record<string, unknown>> | string;
326
+ "page-size"?: number | string;
327
+ "page-size-options"?: string;
328
+ download?: boolean | "" | "true" | "false";
329
+ import?: boolean | "" | "true" | "false";
330
+ onadd?: (event: CustomEvent<{ payload: Record<string, unknown> }>) => void;
331
+ onedit?: (
332
+ event: CustomEvent<{
333
+ payload: Record<string, unknown>;
334
+ row: Record<string, unknown>;
335
+ rowIndex: number;
336
+ }>,
337
+ ) => void;
338
+ ondelete?: (
339
+ event: CustomEvent<{ row: Record<string, unknown>; rowIndex: number }>,
340
+ ) => void;
341
+ onimport?: (
342
+ event: CustomEvent<{ successCount: number; skippedCount: number }>,
343
+ ) => void;
344
+ "ondelete-checked"?: (
345
+ event: CustomEvent<{
346
+ deleted: Array<{ row: Record<string, unknown>; rowIndex: number }>;
347
+ }>,
348
+ ) => void;
349
+ };
350
+ "cs-sortable": Partial<CSSortableElement> & {
351
+ id?: string;
352
+ deleteable?: boolean | "" | "true" | "false";
353
+ insertable?: boolean | "" | "true" | "false";
354
+ "oncs-insert"?: (event: CustomEvent<{}>) => void;
355
+ "oncs-delete"?: (
356
+ event: CustomEvent<{ index: number; item: Element | null }>,
357
+ ) => void;
358
+ "oncs-reorder"?: (
359
+ event: CustomEvent<{ from: number; to: number; items: Element[] }>,
360
+ ) => void;
361
+ };
362
+ "cs-toast": Partial<CSToastElement> & {
363
+ id?: string;
364
+ };
365
+ "cs-sidebar": Partial<CSSidebarElement> & {
366
+ id: string;
367
+ title?: string;
368
+ description?: string;
369
+ links?: string | string[];
370
+ urls?: string | string[];
371
+ logo?: string;
372
+ show?: string;
373
+ };
374
+ "cs-infocard": Partial<CSInfoCardElement> & {
375
+ id?: string;
376
+ title?: string;
377
+ "btn-title"?: string;
378
+ value?: string;
379
+ unit?: string;
380
+ link?: string;
381
+ background?: string;
382
+ };
383
+ "i-c": Partial<CSIconElement> & {
384
+ id?: string;
385
+ c?: CSIcons;
386
+ icon?: CSIcons;
387
+ color?: string;
388
+ invert?: boolean | "" | "true" | "false";
389
+ };
390
+ "list-icon": Partial<CSListIconElement>;
391
+ };
392
+
393
+ declare module "solid-js" {
394
+ namespace JSX {
395
+ interface IntrinsicElements extends CSIntrinsicElements {}
396
+ }
397
+ }
398
+
399
+ declare module "react" {
400
+ namespace JSX {
401
+ interface IntrinsicElements extends CSIntrinsicElements {}
402
+ }
403
+ }
404
+
405
+ declare global {
406
+ const toast: {
407
+ push: (
408
+ message: string,
409
+ duration?: number,
410
+ position?: ToastPosition,
411
+ ) => void;
412
+ error: (
413
+ message: string,
414
+ duration?: number,
415
+ position?: ToastPosition,
416
+ ) => void;
417
+ info: (
418
+ message: string,
419
+ duration?: number,
420
+ position?: ToastPosition,
421
+ ) => void;
422
+ success: (
423
+ message: string,
424
+ duration?: number,
425
+ position?: ToastPosition,
426
+ ) => void;
427
+ warn: (
428
+ message: string,
429
+ duration?: number,
430
+ position?: ToastPosition,
431
+ ) => void;
432
+ warning: (
433
+ message: string,
434
+ duration?: number,
435
+ position?: ToastPosition,
436
+ ) => void;
437
+ loading: (message: string, position?: ToastPosition) => HTMLElement | null;
438
+ hide: (toastEl?: HTMLElement | null) => void;
439
+ dismiss: (toastEl?: HTMLElement | null) => void;
440
+ };
441
+
442
+ const setVal: (id: string, value: string) => void;
443
+ const getVal: (id: string) => string;
444
+
445
+ interface Window {
446
+ showToast: (
447
+ message: string,
448
+ type?: ToastType,
449
+ position?: ToastPosition,
450
+ durationMs?: number,
451
+ ) => void;
452
+ showLoadingToast: (
453
+ message?: string,
454
+ position?: ToastPosition,
455
+ ) => HTMLElement | null;
456
+ removeToast: (toastEl?: HTMLElement | null) => void;
457
+ toast: typeof toast;
458
+ getVal: (id: string) => string;
459
+ setVal: (id: string, value: string) => void;
460
+ }
461
+
462
+ interface HTMLElementTagNameMap {
463
+ "cs-dashboard": CSDashboardElement;
464
+ "cs-input": CSInputElement;
465
+ "cs-select": CSSelectElement;
466
+ "cs-radio": CSRadioElement;
467
+ "cs-upload": CSUploadElement;
468
+ "cs-rtf": CSRTFElement;
469
+ "cs-modal": CSModalElement;
470
+ "cs-data-table": CSDataTableElement;
471
+ "cs-sortable": CSSortableElement;
472
+ "cs-toast": CSToastElement;
473
+ "cs-sidebar": CSSidebarElement;
474
+ "cs-infocard": CSInfoCardElement;
475
+ "i-c": CSIconElement;
476
+ "list-icon": CSListIconElement;
477
+ }
478
+
479
+ namespace svelteHTML {
480
+ interface IntrinsicElements extends CSIntrinsicElements {}
481
+ }
482
+
483
+ namespace JSX {
484
+ interface IntrinsicElements extends CSIntrinsicElements {}
485
+ }
486
+ }
487
+
488
+ export {};
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@yokowasis/types-webcomponents",
3
+ "version": "1.0.0",
4
+ "description": "Type definitions for yokowasis webcomponents custom elements",
5
+ "types": "index.d.ts",
6
+ "files": [
7
+ "index.d.ts",
8
+ "README.md"
9
+ ],
10
+ "keywords": [
11
+ "types",
12
+ "typescript",
13
+ "webcomponents",
14
+ "custom-elements",
15
+ "svelte",
16
+ "react",
17
+ "solid-js"
18
+ ],
19
+ "license": "MIT",
20
+ "author": "yokowasis",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ }
24
+ }