juxscript 1.1.239 → 1.1.243
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/index.js +7 -137
- package/lib/components/dataframe.ts +0 -569
- package/lib/components/tag.ts +68 -0
- package/lib/styles/shadcn.css +20 -7
- package/lib/utils/idgen.ts +6 -0
- package/package.json +5 -6
- package/index.d.ts +0 -239
- package/index.d.ts.map +0 -1
- package/lib/components/alert.d.ts +0 -36
- package/lib/components/alert.d.ts.map +0 -1
- package/lib/components/alert.js +0 -172
- package/lib/components/alert.ts +0 -219
- package/lib/components/app.d.ts +0 -89
- package/lib/components/app.d.ts.map +0 -1
- package/lib/components/app.js +0 -175
- package/lib/components/app.ts +0 -247
- package/lib/components/badge.d.ts +0 -26
- package/lib/components/badge.d.ts.map +0 -1
- package/lib/components/badge.js +0 -91
- package/lib/components/badge.ts +0 -118
- package/lib/components/base/Animations.d.ts +0 -36
- package/lib/components/base/Animations.d.ts.map +0 -1
- package/lib/components/base/Animations.js +0 -70
- package/lib/components/base/Animations.ts +0 -112
- package/lib/components/base/BaseComponent.d.ts +0 -294
- package/lib/components/base/BaseComponent.d.ts.map +0 -1
- package/lib/components/base/BaseComponent.js +0 -735
- package/lib/components/base/BaseComponent.ts +0 -884
- package/lib/components/base/FormInput.d.ts +0 -77
- package/lib/components/base/FormInput.d.ts.map +0 -1
- package/lib/components/base/FormInput.js +0 -171
- package/lib/components/base/FormInput.ts +0 -237
- package/lib/components/blueprint.d.ts +0 -40
- package/lib/components/blueprint.d.ts.map +0 -1
- package/lib/components/blueprint.js +0 -327
- package/lib/components/button.d.ts +0 -70
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js +0 -177
- package/lib/components/button.ts +0 -237
- package/lib/components/card.d.ts +0 -35
- package/lib/components/card.d.ts.map +0 -1
- package/lib/components/card.js +0 -130
- package/lib/components/card.ts +0 -177
- package/lib/components/chart.d.ts +0 -49
- package/lib/components/chart.d.ts.map +0 -1
- package/lib/components/chart.js +0 -205
- package/lib/components/chart.ts +0 -254
- package/lib/components/checkbox.d.ts +0 -33
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js +0 -202
- package/lib/components/checkbox.ts +0 -260
- package/lib/components/code.d.ts +0 -52
- package/lib/components/code.d.ts.map +0 -1
- package/lib/components/code.js +0 -201
- package/lib/components/code.ts +0 -260
- package/lib/components/container.d.ts +0 -60
- package/lib/components/container.d.ts.map +0 -1
- package/lib/components/container.js +0 -195
- package/lib/components/container.ts +0 -259
- package/lib/components/data.d.ts +0 -36
- package/lib/components/data.d.ts.map +0 -1
- package/lib/components/data.js +0 -110
- package/lib/components/data.ts +0 -135
- package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
- package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
- package/lib/components/dataframe/DataFrameSource.js +0 -421
- package/lib/components/dataframe/DataFrameSource.ts +0 -532
- package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
- package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
- package/lib/components/dataframe/ImportSettingsModal.js +0 -442
- package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
- package/lib/components/dataframe.d.ts +0 -110
- package/lib/components/dataframe.d.ts.map +0 -1
- package/lib/components/dataframe.js +0 -470
- package/lib/components/datepicker.d.ts +0 -40
- package/lib/components/datepicker.d.ts.map +0 -1
- package/lib/components/datepicker.js +0 -193
- package/lib/components/datepicker.ts +0 -251
- package/lib/components/dialog.d.ts +0 -39
- package/lib/components/dialog.d.ts.map +0 -1
- package/lib/components/dialog.js +0 -131
- package/lib/components/dialog.ts +0 -178
- package/lib/components/divider.d.ts +0 -31
- package/lib/components/divider.d.ts.map +0 -1
- package/lib/components/divider.js +0 -72
- package/lib/components/divider.ts +0 -104
- package/lib/components/dropdown-menu.d.ts +0 -42
- package/lib/components/dropdown-menu.d.ts.map +0 -1
- package/lib/components/dropdown-menu.js +0 -177
- package/lib/components/dropdown-menu.ts +0 -214
- package/lib/components/dropdown.d.ts +0 -41
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -136
- package/lib/components/dropdown.ts +0 -188
- package/lib/components/element.d.ts +0 -51
- package/lib/components/element.d.ts.map +0 -1
- package/lib/components/element.js +0 -209
- package/lib/components/element.ts +0 -271
- package/lib/components/event-chain.d.ts +0 -9
- package/lib/components/event-chain.d.ts.map +0 -1
- package/lib/components/event-chain.js +0 -33
- package/lib/components/fileupload.d.ts +0 -98
- package/lib/components/fileupload.d.ts.map +0 -1
- package/lib/components/fileupload.js +0 -351
- package/lib/components/fileupload.ts +0 -449
- package/lib/components/grid.d.ts +0 -88
- package/lib/components/grid.d.ts.map +0 -1
- package/lib/components/grid.js +0 -208
- package/lib/components/grid.ts +0 -295
- package/lib/components/heading.d.ts +0 -25
- package/lib/components/heading.d.ts.map +0 -1
- package/lib/components/heading.js +0 -83
- package/lib/components/heading.ts +0 -113
- package/lib/components/helpers.d.ts +0 -9
- package/lib/components/helpers.d.ts.map +0 -1
- package/lib/components/helpers.js +0 -30
- package/lib/components/helpers.ts +0 -41
- package/lib/components/hero.d.ts +0 -60
- package/lib/components/hero.d.ts.map +0 -1
- package/lib/components/hero.js +0 -239
- package/lib/components/hero.ts +0 -302
- package/lib/components/history/StateHistory.d.ts +0 -91
- package/lib/components/history/StateHistory.d.ts.map +0 -1
- package/lib/components/history/StateHistory.js +0 -154
- package/lib/components/history/StateHistory.ts +0 -200
- package/lib/components/icon.d.ts +0 -36
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js +0 -135
- package/lib/components/icon.ts +0 -182
- package/lib/components/icons.d.ts +0 -25
- package/lib/components/icons.d.ts.map +0 -1
- package/lib/components/icons.js +0 -440
- package/lib/components/icons.ts +0 -464
- package/lib/components/image.d.ts +0 -42
- package/lib/components/image.d.ts.map +0 -1
- package/lib/components/image.js +0 -204
- package/lib/components/image.ts +0 -260
- package/lib/components/include.d.ts +0 -86
- package/lib/components/include.d.ts.map +0 -1
- package/lib/components/include.js +0 -238
- package/lib/components/include.ts +0 -281
- package/lib/components/input.d.ts +0 -85
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js +0 -362
- package/lib/components/input.ts +0 -473
- package/lib/components/layer.d.ts +0 -72
- package/lib/components/layer.d.ts.map +0 -1
- package/lib/components/layer.js +0 -219
- package/lib/components/layer.ts +0 -304
- package/lib/components/link.d.ts +0 -41
- package/lib/components/link.d.ts.map +0 -1
- package/lib/components/link.js +0 -216
- package/lib/components/link.ts +0 -268
- package/lib/components/list.d.ts +0 -83
- package/lib/components/list.d.ts.map +0 -1
- package/lib/components/list.js +0 -314
- package/lib/components/list.ts +0 -423
- package/lib/components/loading.d.ts +0 -25
- package/lib/components/loading.d.ts.map +0 -1
- package/lib/components/loading.js +0 -76
- package/lib/components/loading.ts +0 -104
- package/lib/components/menu.d.ts +0 -38
- package/lib/components/menu.d.ts.map +0 -1
- package/lib/components/menu.js +0 -205
- package/lib/components/menu.ts +0 -279
- package/lib/components/modal.d.ts +0 -97
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js +0 -463
- package/lib/components/modal.ts +0 -576
- package/lib/components/nav.d.ts +0 -46
- package/lib/components/nav.d.ts.map +0 -1
- package/lib/components/nav.js +0 -193
- package/lib/components/nav.ts +0 -261
- package/lib/components/paragraph.d.ts +0 -30
- package/lib/components/paragraph.d.ts.map +0 -1
- package/lib/components/paragraph.js +0 -93
- package/lib/components/paragraph.ts +0 -123
- package/lib/components/pen.d.ts +0 -125
- package/lib/components/pen.d.ts.map +0 -1
- package/lib/components/pen.js +0 -443
- package/lib/components/pen.ts +0 -567
- package/lib/components/progress.d.ts +0 -40
- package/lib/components/progress.d.ts.map +0 -1
- package/lib/components/progress.js +0 -116
- package/lib/components/progress.ts +0 -163
- package/lib/components/radio.d.ts +0 -43
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js +0 -226
- package/lib/components/radio.ts +0 -303
- package/lib/components/registry.d.ts +0 -34
- package/lib/components/registry.d.ts.map +0 -1
- package/lib/components/registry.js +0 -163
- package/lib/components/registry.ts +0 -193
- package/lib/components/req.d.ts +0 -155
- package/lib/components/req.d.ts.map +0 -1
- package/lib/components/req.js +0 -253
- package/lib/components/req.ts +0 -303
- package/lib/components/script.d.ts +0 -14
- package/lib/components/script.d.ts.map +0 -1
- package/lib/components/script.js +0 -33
- package/lib/components/script.ts +0 -41
- package/lib/components/select.d.ts +0 -42
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js +0 -209
- package/lib/components/select.ts +0 -281
- package/lib/components/sidebar.d.ts +0 -59
- package/lib/components/sidebar.d.ts.map +0 -1
- package/lib/components/sidebar.js +0 -298
- package/lib/components/sidebar.ts +0 -395
- package/lib/components/stack/BaseStack.d.ts +0 -65
- package/lib/components/stack/BaseStack.d.ts.map +0 -1
- package/lib/components/stack/BaseStack.js +0 -274
- package/lib/components/stack/BaseStack.ts +0 -328
- package/lib/components/stack/HStack.d.ts +0 -18
- package/lib/components/stack/HStack.d.ts.map +0 -1
- package/lib/components/stack/HStack.js +0 -22
- package/lib/components/stack/HStack.ts +0 -25
- package/lib/components/stack/VStack.d.ts +0 -19
- package/lib/components/stack/VStack.d.ts.map +0 -1
- package/lib/components/stack/VStack.js +0 -23
- package/lib/components/stack/VStack.ts +0 -26
- package/lib/components/stack/ZStack.d.ts +0 -18
- package/lib/components/stack/ZStack.d.ts.map +0 -1
- package/lib/components/stack/ZStack.js +0 -22
- package/lib/components/stack/ZStack.ts +0 -25
- package/lib/components/style.d.ts +0 -14
- package/lib/components/style.d.ts.map +0 -1
- package/lib/components/style.js +0 -33
- package/lib/components/style.ts +0 -41
- package/lib/components/switch.d.ts +0 -34
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js +0 -209
- package/lib/components/switch.ts +0 -272
- package/lib/components/table.d.ts +0 -137
- package/lib/components/table.d.ts.map +0 -1
- package/lib/components/table.js +0 -1019
- package/lib/components/table.ts +0 -1225
- package/lib/components/tabs.d.ts +0 -53
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js +0 -275
- package/lib/components/tabs.ts +0 -349
- package/lib/components/theme-toggle.d.ts +0 -45
- package/lib/components/theme-toggle.d.ts.map +0 -1
- package/lib/components/theme-toggle.js +0 -218
- package/lib/components/theme-toggle.ts +0 -297
- package/lib/components/tooltip.d.ts +0 -31
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js +0 -112
- package/lib/components/tooltip.ts +0 -148
- package/lib/components/watcher.d.ts +0 -195
- package/lib/components/watcher.d.ts.map +0 -1
- package/lib/components/watcher.js +0 -241
- package/lib/components/watcher.ts +0 -261
- package/lib/components/write.d.ts +0 -107
- package/lib/components/write.d.ts.map +0 -1
- package/lib/components/write.js +0 -222
- package/lib/components/write.ts +0 -272
- package/lib/data/DataPipeline.d.ts +0 -113
- package/lib/data/DataPipeline.d.ts.map +0 -1
- package/lib/data/DataPipeline.js +0 -359
- package/lib/data/DataPipeline.ts +0 -452
- package/lib/facades/dataframe.jux +0 -0
- package/lib/globals.d.ts +0 -21
- package/lib/reactivity/state.d.ts +0 -36
- package/lib/reactivity/state.d.ts.map +0 -1
- package/lib/reactivity/state.js +0 -67
- package/lib/reactivity/state.ts +0 -78
- package/lib/storage/DataFrame.d.ts +0 -284
- package/lib/storage/DataFrame.d.ts.map +0 -1
- package/lib/storage/DataFrame.js +0 -1022
- package/lib/storage/DataFrame.ts +0 -1195
- package/lib/storage/DataFrameSource.d.ts +0 -158
- package/lib/storage/DataFrameSource.d.ts.map +0 -1
- package/lib/storage/DataFrameSource.js +0 -409
- package/lib/storage/DataFrameSource.ts +0 -556
- package/lib/storage/FileStorage.d.ts +0 -53
- package/lib/storage/FileStorage.d.ts.map +0 -1
- package/lib/storage/FileStorage.js +0 -80
- package/lib/storage/FileStorage.ts +0 -95
- package/lib/storage/IndexedDBDriver.d.ts +0 -75
- package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
- package/lib/storage/IndexedDBDriver.js +0 -177
- package/lib/storage/IndexedDBDriver.ts +0 -226
- package/lib/storage/TabularDriver.d.ts +0 -118
- package/lib/storage/TabularDriver.d.ts.map +0 -1
- package/lib/storage/TabularDriver.js +0 -731
- package/lib/storage/TabularDriver.ts +0 -874
- package/lib/utils/codeparser.d.ts +0 -29
- package/lib/utils/codeparser.d.ts.map +0 -1
- package/lib/utils/codeparser.js +0 -409
- package/lib/utils/fetch.d.ts +0 -176
- package/lib/utils/fetch.d.ts.map +0 -1
- package/lib/utils/fetch.js +0 -427
- package/lib/utils/formatId.d.ts +0 -16
- package/lib/utils/formatId.d.ts.map +0 -1
- package/lib/utils/formatId.js +0 -27
- package/lib/utils/path-resolver.js +0 -23
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
2
|
-
|
|
3
|
-
const TRIGGER_EVENTS = [] as const;
|
|
4
|
-
const CALLBACK_EVENTS = ['select'] as const;
|
|
5
|
-
|
|
6
|
-
export interface DropdownMenuItem {
|
|
7
|
-
type?: 'item' | 'label' | 'separator';
|
|
8
|
-
label?: string;
|
|
9
|
-
value?: string;
|
|
10
|
-
shortcut?: string;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
submenu?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface DropdownMenuOptions {
|
|
16
|
-
trigger?: string;
|
|
17
|
-
items?: DropdownMenuItem[];
|
|
18
|
-
style?: string;
|
|
19
|
-
class?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type DropdownMenuState = BaseState & {
|
|
23
|
-
trigger: string;
|
|
24
|
-
items: DropdownMenuItem[];
|
|
25
|
-
open: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export class DropdownMenu extends BaseComponent<DropdownMenuState> {
|
|
29
|
-
private _wrapper: HTMLElement | null = null;
|
|
30
|
-
private _menuEl: HTMLElement | null = null;
|
|
31
|
-
|
|
32
|
-
constructor(id: string, options: DropdownMenuOptions = {}) {
|
|
33
|
-
super(id, {
|
|
34
|
-
trigger: options.trigger ?? 'Open',
|
|
35
|
-
items: options.items ?? [],
|
|
36
|
-
open: false,
|
|
37
|
-
style: options.style ?? '',
|
|
38
|
-
class: options.class ?? ''
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected getTriggerEvents(): readonly string[] { return TRIGGER_EVENTS; }
|
|
43
|
-
protected getCallbackEvents(): readonly string[] { return CALLBACK_EVENTS; }
|
|
44
|
-
|
|
45
|
-
/* ═══════════════════════ FLUENT API ═══════════════════════ */
|
|
46
|
-
|
|
47
|
-
trigger(value: string): this { this.state.trigger = value; return this; }
|
|
48
|
-
|
|
49
|
-
items(value: DropdownMenuItem[]): this { this.state.items = value; return this; }
|
|
50
|
-
|
|
51
|
-
addItem(item: DropdownMenuItem): this {
|
|
52
|
-
this.state.items = [...this.state.items, item];
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
separator(): this {
|
|
57
|
-
return this.addItem({ type: 'separator' });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
label(text: string): this {
|
|
61
|
-
return this.addItem({ type: 'label', label: text });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
item(label: string, value?: string, shortcut?: string): this {
|
|
65
|
-
return this.addItem({ label, value: value ?? label, shortcut });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
open(): this {
|
|
69
|
-
this.state.open = true;
|
|
70
|
-
if (this._menuEl) this._menuEl.style.display = 'flex';
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
close(): this {
|
|
75
|
-
this.state.open = false;
|
|
76
|
-
if (this._menuEl) this._menuEl.style.display = 'none';
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
toggle(): this {
|
|
81
|
-
return this.state.open ? this.close() : this.open();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
update(prop: string, value: any): void { }
|
|
85
|
-
|
|
86
|
-
/* ═══════════════════════ RENDER ═══════════════════════ */
|
|
87
|
-
|
|
88
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this {
|
|
89
|
-
const container = this._setupContainer(targetId);
|
|
90
|
-
const { trigger, items, style, class: className } = this.state;
|
|
91
|
-
|
|
92
|
-
// Inject styles once
|
|
93
|
-
if (!document.getElementById('jux-dropdown-menu-styles')) {
|
|
94
|
-
const styleEl = document.createElement('style');
|
|
95
|
-
styleEl.id = 'jux-dropdown-menu-styles';
|
|
96
|
-
styleEl.textContent = `
|
|
97
|
-
.jux-dmenu-wrapper { position:relative; display:inline-block; }
|
|
98
|
-
.jux-dmenu-trigger { display:inline-flex; align-items:center; gap:4px; padding:8px 16px; font-size:14px; font-weight:500; border-radius:6px; border:1px solid hsl(var(--border,0 0% 80%)); background:hsl(var(--background,0 0% 100%)); color:hsl(var(--foreground,0 0% 9%)); cursor:pointer; transition:background .15s; }
|
|
99
|
-
.jux-dmenu-trigger:hover { background:hsl(var(--accent,0 0% 96%)); }
|
|
100
|
-
.jux-dmenu-menu { position:absolute; top:calc(100% + 4px); left:0; min-width:220px; padding:4px; border-radius:8px; border:1px solid hsl(var(--border,0 0% 90%)); background:hsl(var(--popover,0 0% 100%)); color:hsl(var(--popover-foreground,0 0% 9%)); box-shadow:0 4px 12px rgba(0,0,0,.08),0 1px 3px rgba(0,0,0,.06); z-index:100; display:none; flex-direction:column; animation:jux-dmenu-in .12s ease-out; }
|
|
101
|
-
@keyframes jux-dmenu-in { from{opacity:0;transform:translateY(-4px) scale(.98)} to{opacity:1;transform:translateY(0) scale(1)} }
|
|
102
|
-
.jux-dmenu-label { padding:6px 8px 4px; font-size:12px; font-weight:600; color:hsl(var(--muted-foreground,0 0% 45%)); user-select:none; }
|
|
103
|
-
.jux-dmenu-sep { height:1px; margin:4px -4px; background:hsl(var(--border,0 0% 90%)); }
|
|
104
|
-
.jux-dmenu-item { display:flex; align-items:center; justify-content:space-between; width:100%; padding:6px 8px; font-size:14px; border-radius:4px; border:none; background:transparent; color:hsl(var(--popover-foreground,0 0% 9%)); cursor:pointer; text-align:left; transition:background .1s; gap:8px; font-family:inherit; }
|
|
105
|
-
.jux-dmenu-item:hover { background:hsl(var(--accent,0 0% 96%)); }
|
|
106
|
-
.jux-dmenu-item:focus-visible { outline:2px solid hsl(var(--ring,0 0% 63%)); outline-offset:-2px; }
|
|
107
|
-
.jux-dmenu-item[disabled] { opacity:.5; pointer-events:none; }
|
|
108
|
-
.jux-dmenu-item-label { flex:1; }
|
|
109
|
-
.jux-dmenu-shortcut { font-size:12px; color:hsl(var(--muted-foreground,0 0% 45%)); letter-spacing:.04em; }
|
|
110
|
-
.jux-dmenu-arrow { font-size:10px; color:hsl(var(--muted-foreground,0 0% 45%)); }
|
|
111
|
-
`;
|
|
112
|
-
document.head.appendChild(styleEl);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const wrapper = document.createElement('div');
|
|
116
|
-
wrapper.className = 'jux-dmenu-wrapper';
|
|
117
|
-
wrapper.id = this._id;
|
|
118
|
-
if (className) wrapper.className += ` ${className}`;
|
|
119
|
-
if (style) wrapper.setAttribute('style', style);
|
|
120
|
-
|
|
121
|
-
const triggerBtn = document.createElement('button');
|
|
122
|
-
triggerBtn.className = 'jux-dmenu-trigger';
|
|
123
|
-
triggerBtn.textContent = trigger;
|
|
124
|
-
triggerBtn.type = 'button';
|
|
125
|
-
wrapper.appendChild(triggerBtn);
|
|
126
|
-
|
|
127
|
-
const menu = document.createElement('div');
|
|
128
|
-
menu.className = 'jux-dmenu-menu';
|
|
129
|
-
this._menuEl = menu;
|
|
130
|
-
|
|
131
|
-
this._buildItems(menu, items);
|
|
132
|
-
|
|
133
|
-
wrapper.appendChild(menu);
|
|
134
|
-
|
|
135
|
-
// Toggle
|
|
136
|
-
triggerBtn.addEventListener('click', (e) => { e.stopPropagation(); this.toggle(); });
|
|
137
|
-
document.addEventListener('click', (e) => { if (!wrapper.contains(e.target as Node)) this.close(); });
|
|
138
|
-
|
|
139
|
-
// Keyboard
|
|
140
|
-
triggerBtn.addEventListener('keydown', (e) => {
|
|
141
|
-
if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {
|
|
142
|
-
e.preventDefault(); this.open();
|
|
143
|
-
const first = menu.querySelector('.jux-dmenu-item:not([disabled])') as HTMLElement;
|
|
144
|
-
if (first) first.focus();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
menu.addEventListener('keydown', (e) => {
|
|
149
|
-
const btns = Array.from(menu.querySelectorAll('.jux-dmenu-item:not([disabled])')) as HTMLElement[];
|
|
150
|
-
const idx = btns.indexOf(document.activeElement as HTMLElement);
|
|
151
|
-
if (e.key === 'ArrowDown') { e.preventDefault(); btns[(idx + 1) % btns.length]?.focus(); }
|
|
152
|
-
else if (e.key === 'ArrowUp') { e.preventDefault(); btns[(idx - 1 + btns.length) % btns.length]?.focus(); }
|
|
153
|
-
else if (e.key === 'Escape') { this.close(); triggerBtn.focus(); }
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
this._wireStandardEvents(wrapper);
|
|
157
|
-
container.appendChild(wrapper);
|
|
158
|
-
this._wrapper = wrapper;
|
|
159
|
-
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private _buildItems(menu: HTMLElement, items: DropdownMenuItem[]): void {
|
|
164
|
-
menu.innerHTML = '';
|
|
165
|
-
|
|
166
|
-
items.forEach(item => {
|
|
167
|
-
if (item.type === 'separator') {
|
|
168
|
-
const sep = document.createElement('div');
|
|
169
|
-
sep.className = 'jux-dmenu-sep';
|
|
170
|
-
menu.appendChild(sep);
|
|
171
|
-
} else if (item.type === 'label') {
|
|
172
|
-
const lbl = document.createElement('div');
|
|
173
|
-
lbl.className = 'jux-dmenu-label';
|
|
174
|
-
lbl.textContent = item.label ?? '';
|
|
175
|
-
menu.appendChild(lbl);
|
|
176
|
-
} else {
|
|
177
|
-
const btn = document.createElement('button');
|
|
178
|
-
btn.className = 'jux-dmenu-item';
|
|
179
|
-
btn.type = 'button';
|
|
180
|
-
if (item.disabled) btn.disabled = true;
|
|
181
|
-
|
|
182
|
-
const labelSpan = document.createElement('span');
|
|
183
|
-
labelSpan.className = 'jux-dmenu-item-label';
|
|
184
|
-
labelSpan.textContent = item.label ?? '';
|
|
185
|
-
btn.appendChild(labelSpan);
|
|
186
|
-
|
|
187
|
-
if (item.submenu) {
|
|
188
|
-
const arrow = document.createElement('span');
|
|
189
|
-
arrow.className = 'jux-dmenu-arrow';
|
|
190
|
-
arrow.textContent = '›';
|
|
191
|
-
btn.appendChild(arrow);
|
|
192
|
-
} else if (item.shortcut) {
|
|
193
|
-
const sc = document.createElement('span');
|
|
194
|
-
sc.className = 'jux-dmenu-shortcut';
|
|
195
|
-
sc.textContent = item.shortcut;
|
|
196
|
-
btn.appendChild(sc);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
btn.addEventListener('click', (e) => {
|
|
200
|
-
if (!item.disabled) {
|
|
201
|
-
this._triggerCallback('select', item.value || item.label, e, this);
|
|
202
|
-
this.close();
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
menu.appendChild(btn);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function dropdownMenu(id: string, options: DropdownMenuOptions = {}): DropdownMenu {
|
|
213
|
-
return new DropdownMenu(id, options);
|
|
214
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
export interface DropdownItem {
|
|
3
|
-
label?: string;
|
|
4
|
-
icon?: string;
|
|
5
|
-
divider?: boolean;
|
|
6
|
-
click?: () => void;
|
|
7
|
-
value?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface DropdownOptions {
|
|
10
|
-
triggerLabel?: string;
|
|
11
|
-
items?: DropdownItem[];
|
|
12
|
-
position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
|
|
13
|
-
style?: string;
|
|
14
|
-
class?: string;
|
|
15
|
-
}
|
|
16
|
-
type DropdownState = {
|
|
17
|
-
triggerLabel: string;
|
|
18
|
-
items: DropdownItem[];
|
|
19
|
-
position: string;
|
|
20
|
-
open: boolean;
|
|
21
|
-
style: string;
|
|
22
|
-
class: string;
|
|
23
|
-
};
|
|
24
|
-
export declare class Dropdown extends BaseComponent<DropdownState> {
|
|
25
|
-
private _dropdown;
|
|
26
|
-
private _menu;
|
|
27
|
-
constructor(id: string, options?: DropdownOptions);
|
|
28
|
-
protected getTriggerEvents(): readonly string[];
|
|
29
|
-
protected getCallbackEvents(): readonly string[];
|
|
30
|
-
triggerLabel(value: string): this;
|
|
31
|
-
items(value: DropdownItem[]): this;
|
|
32
|
-
position(value: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'): this;
|
|
33
|
-
open(): this;
|
|
34
|
-
close(): this;
|
|
35
|
-
toggle(): this;
|
|
36
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
37
|
-
update(prop: string, value: any): void;
|
|
38
|
-
}
|
|
39
|
-
export declare function dropdown(id: string, options?: DropdownOptions): Dropdown;
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,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EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAE5E"}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [];
|
|
5
|
-
const CALLBACK_EVENTS = ['select'];
|
|
6
|
-
export class Dropdown extends BaseComponent {
|
|
7
|
-
constructor(id, options = {}) {
|
|
8
|
-
super(id, {
|
|
9
|
-
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
10
|
-
items: options.items ?? [],
|
|
11
|
-
position: options.position ?? 'bottom-left',
|
|
12
|
-
open: false,
|
|
13
|
-
style: options.style ?? '',
|
|
14
|
-
class: options.class ?? ''
|
|
15
|
-
});
|
|
16
|
-
this._dropdown = null;
|
|
17
|
-
this._menu = null;
|
|
18
|
-
}
|
|
19
|
-
getTriggerEvents() {
|
|
20
|
-
return TRIGGER_EVENTS;
|
|
21
|
-
}
|
|
22
|
-
getCallbackEvents() {
|
|
23
|
-
return CALLBACK_EVENTS;
|
|
24
|
-
}
|
|
25
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
26
|
-
* FLUENT API
|
|
27
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
28
|
-
triggerLabel(value) {
|
|
29
|
-
this.state.triggerLabel = value;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
items(value) {
|
|
33
|
-
this.state.items = value;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
position(value) {
|
|
37
|
-
this.state.position = value;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
open() {
|
|
41
|
-
this.state.open = true;
|
|
42
|
-
if (this._menu) {
|
|
43
|
-
this._menu.style.display = 'block';
|
|
44
|
-
}
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
close() {
|
|
48
|
-
this.state.open = false;
|
|
49
|
-
if (this._menu) {
|
|
50
|
-
this._menu.style.display = 'none';
|
|
51
|
-
}
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
toggle() {
|
|
55
|
-
return this.state.open ? this.close() : this.open();
|
|
56
|
-
}
|
|
57
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
58
|
-
* RENDER
|
|
59
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
60
|
-
render(targetId) {
|
|
61
|
-
const container = this._setupContainer(targetId);
|
|
62
|
-
const { triggerLabel, items, position, style, class: className } = this.state;
|
|
63
|
-
const wrapper = document.createElement('div');
|
|
64
|
-
wrapper.className = 'jux-dropdown';
|
|
65
|
-
wrapper.id = this._id;
|
|
66
|
-
if (className)
|
|
67
|
-
wrapper.className += ` ${className}`;
|
|
68
|
-
if (style)
|
|
69
|
-
wrapper.setAttribute('style', style);
|
|
70
|
-
// Trigger button
|
|
71
|
-
const triggerBtn = document.createElement('button');
|
|
72
|
-
triggerBtn.className = 'jux-dropdown-trigger';
|
|
73
|
-
triggerBtn.textContent = triggerLabel;
|
|
74
|
-
triggerBtn.type = 'button';
|
|
75
|
-
// Dropdown menu
|
|
76
|
-
const menu = document.createElement('div');
|
|
77
|
-
menu.className = `jux-dropdown-menu jux-dropdown-${position}`;
|
|
78
|
-
menu.style.display = 'none';
|
|
79
|
-
this._menu = menu;
|
|
80
|
-
items.forEach(item => {
|
|
81
|
-
if (item.divider) {
|
|
82
|
-
const divider = document.createElement('div');
|
|
83
|
-
divider.className = 'jux-dropdown-divider';
|
|
84
|
-
menu.appendChild(divider);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
const menuItem = document.createElement('button');
|
|
88
|
-
menuItem.className = 'jux-dropdown-item';
|
|
89
|
-
menuItem.type = 'button';
|
|
90
|
-
if (item.icon) {
|
|
91
|
-
const icon = document.createElement('span');
|
|
92
|
-
icon.className = 'jux-dropdown-icon';
|
|
93
|
-
icon.textContent = item.icon;
|
|
94
|
-
menuItem.appendChild(icon);
|
|
95
|
-
}
|
|
96
|
-
if (item.label) {
|
|
97
|
-
const label = document.createElement('span');
|
|
98
|
-
label.textContent = item.label;
|
|
99
|
-
menuItem.appendChild(label);
|
|
100
|
-
}
|
|
101
|
-
// For each item click handler in the dropdown, replace with:
|
|
102
|
-
menuItem.addEventListener('click', (e) => {
|
|
103
|
-
const value = item.value || item.label || '';
|
|
104
|
-
if (item.click)
|
|
105
|
-
item.click();
|
|
106
|
-
this._triggerCallback('select', value, e, this);
|
|
107
|
-
this.close();
|
|
108
|
-
});
|
|
109
|
-
menu.appendChild(menuItem);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
// Toggle on trigger click
|
|
113
|
-
triggerBtn.addEventListener('click', (e) => {
|
|
114
|
-
e.stopPropagation();
|
|
115
|
-
this.toggle();
|
|
116
|
-
});
|
|
117
|
-
// Close on outside click
|
|
118
|
-
document.addEventListener('click', (e) => {
|
|
119
|
-
if (this._dropdown && !this._dropdown.contains(e.target)) {
|
|
120
|
-
this.close();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
wrapper.appendChild(triggerBtn);
|
|
124
|
-
wrapper.appendChild(menu);
|
|
125
|
-
this._wireStandardEvents(wrapper);
|
|
126
|
-
container.appendChild(wrapper);
|
|
127
|
-
this._dropdown = wrapper;
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
update(prop, value) {
|
|
131
|
-
// No reactive updates needed
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export function dropdown(id, options = {}) {
|
|
135
|
-
return new Dropdown(id, options);
|
|
136
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
3
|
-
|
|
4
|
-
// Event definitions
|
|
5
|
-
const TRIGGER_EVENTS = [] as const;
|
|
6
|
-
const CALLBACK_EVENTS = ['select'] as const;
|
|
7
|
-
|
|
8
|
-
export interface DropdownItem {
|
|
9
|
-
label?: string;
|
|
10
|
-
icon?: string;
|
|
11
|
-
divider?: boolean;
|
|
12
|
-
click?: () => void;
|
|
13
|
-
value?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface DropdownOptions {
|
|
17
|
-
triggerLabel?: string;
|
|
18
|
-
items?: DropdownItem[];
|
|
19
|
-
position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
|
|
20
|
-
style?: string;
|
|
21
|
-
class?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type DropdownState = {
|
|
25
|
-
triggerLabel: string;
|
|
26
|
-
items: DropdownItem[];
|
|
27
|
-
position: string;
|
|
28
|
-
open: boolean;
|
|
29
|
-
style: string;
|
|
30
|
-
class: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export class Dropdown extends BaseComponent<DropdownState> {
|
|
34
|
-
private _dropdown: HTMLElement | null = null;
|
|
35
|
-
private _menu: HTMLElement | null = null;
|
|
36
|
-
|
|
37
|
-
constructor(id: string, options: DropdownOptions = {}) {
|
|
38
|
-
super(id, {
|
|
39
|
-
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
40
|
-
items: options.items ?? [],
|
|
41
|
-
position: options.position ?? 'bottom-left',
|
|
42
|
-
open: false,
|
|
43
|
-
style: options.style ?? '',
|
|
44
|
-
class: options.class ?? ''
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected getTriggerEvents(): readonly string[] {
|
|
49
|
-
return TRIGGER_EVENTS;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected getCallbackEvents(): readonly string[] {
|
|
53
|
-
return CALLBACK_EVENTS;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
57
|
-
* FLUENT API
|
|
58
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
59
|
-
|
|
60
|
-
triggerLabel(value: string): this {
|
|
61
|
-
this.state.triggerLabel = value;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
items(value: DropdownItem[]): this {
|
|
66
|
-
this.state.items = value;
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
position(value: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'): this {
|
|
71
|
-
this.state.position = value;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
open(): this {
|
|
76
|
-
this.state.open = true;
|
|
77
|
-
if (this._menu) {
|
|
78
|
-
this._menu.style.display = 'block';
|
|
79
|
-
}
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
close(): this {
|
|
84
|
-
this.state.open = false;
|
|
85
|
-
if (this._menu) {
|
|
86
|
-
this._menu.style.display = 'none';
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
toggle(): this {
|
|
92
|
-
return this.state.open ? this.close() : this.open();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
96
|
-
* RENDER
|
|
97
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
98
|
-
|
|
99
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this {
|
|
100
|
-
const container = this._setupContainer(targetId);
|
|
101
|
-
|
|
102
|
-
const { triggerLabel, items, position, style, class: className } = this.state;
|
|
103
|
-
|
|
104
|
-
const wrapper = document.createElement('div');
|
|
105
|
-
wrapper.className = 'jux-dropdown';
|
|
106
|
-
wrapper.id = this._id;
|
|
107
|
-
if (className) wrapper.className += ` ${className}`;
|
|
108
|
-
if (style) wrapper.setAttribute('style', style);
|
|
109
|
-
|
|
110
|
-
// Trigger button
|
|
111
|
-
const triggerBtn = document.createElement('button');
|
|
112
|
-
triggerBtn.className = 'jux-dropdown-trigger';
|
|
113
|
-
triggerBtn.textContent = triggerLabel;
|
|
114
|
-
triggerBtn.type = 'button';
|
|
115
|
-
|
|
116
|
-
// Dropdown menu
|
|
117
|
-
const menu = document.createElement('div');
|
|
118
|
-
menu.className = `jux-dropdown-menu jux-dropdown-${position}`;
|
|
119
|
-
menu.style.display = 'none';
|
|
120
|
-
this._menu = menu;
|
|
121
|
-
|
|
122
|
-
items.forEach(item => {
|
|
123
|
-
if (item.divider) {
|
|
124
|
-
const divider = document.createElement('div');
|
|
125
|
-
divider.className = 'jux-dropdown-divider';
|
|
126
|
-
menu.appendChild(divider);
|
|
127
|
-
} else {
|
|
128
|
-
const menuItem = document.createElement('button');
|
|
129
|
-
menuItem.className = 'jux-dropdown-item';
|
|
130
|
-
menuItem.type = 'button';
|
|
131
|
-
|
|
132
|
-
if (item.icon) {
|
|
133
|
-
const icon = document.createElement('span');
|
|
134
|
-
icon.className = 'jux-dropdown-icon';
|
|
135
|
-
icon.textContent = item.icon;
|
|
136
|
-
menuItem.appendChild(icon);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (item.label) {
|
|
140
|
-
const label = document.createElement('span');
|
|
141
|
-
label.textContent = item.label;
|
|
142
|
-
menuItem.appendChild(label);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// For each item click handler in the dropdown, replace with:
|
|
146
|
-
menuItem.addEventListener('click', (e) => {
|
|
147
|
-
const value = item.value || item.label || '';
|
|
148
|
-
if (item.click) item.click();
|
|
149
|
-
this._triggerCallback('select', value, e, this);
|
|
150
|
-
this.close();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
menu.appendChild(menuItem);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// Toggle on trigger click
|
|
158
|
-
triggerBtn.addEventListener('click', (e) => {
|
|
159
|
-
e.stopPropagation();
|
|
160
|
-
this.toggle();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// Close on outside click
|
|
164
|
-
document.addEventListener('click', (e) => {
|
|
165
|
-
if (this._dropdown && !this._dropdown.contains(e.target as Node)) {
|
|
166
|
-
this.close();
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
wrapper.appendChild(triggerBtn);
|
|
171
|
-
wrapper.appendChild(menu);
|
|
172
|
-
|
|
173
|
-
this._wireStandardEvents(wrapper);
|
|
174
|
-
|
|
175
|
-
container.appendChild(wrapper);
|
|
176
|
-
this._dropdown = wrapper;
|
|
177
|
-
|
|
178
|
-
return this;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
update(prop: string, value: any): void {
|
|
182
|
-
// No reactive updates needed
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function dropdown(id: string, options: DropdownOptions = {}): Dropdown {
|
|
187
|
-
return new Dropdown(id, options);
|
|
188
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
export interface ElementOptions {
|
|
3
|
-
tagType?: string;
|
|
4
|
-
className?: string;
|
|
5
|
-
text?: string;
|
|
6
|
-
innerHTML?: string;
|
|
7
|
-
attributes?: Record<string, string>;
|
|
8
|
-
styles?: Record<string, string>;
|
|
9
|
-
style?: string;
|
|
10
|
-
class?: string;
|
|
11
|
-
}
|
|
12
|
-
type ElementState = {
|
|
13
|
-
tagType: string;
|
|
14
|
-
className: string;
|
|
15
|
-
text: string;
|
|
16
|
-
innerHTML: string;
|
|
17
|
-
attributes: Record<string, string>;
|
|
18
|
-
styles: Record<string, string>;
|
|
19
|
-
style: string;
|
|
20
|
-
class: string;
|
|
21
|
-
};
|
|
22
|
-
export declare class Element extends BaseComponent<ElementState> {
|
|
23
|
-
private _element;
|
|
24
|
-
constructor(id: string, options?: ElementOptions);
|
|
25
|
-
protected getTriggerEvents(): readonly string[];
|
|
26
|
-
protected getCallbackEvents(): readonly string[];
|
|
27
|
-
tagType(value: string): Element;
|
|
28
|
-
className(value: string): Element;
|
|
29
|
-
text(value: string): Element;
|
|
30
|
-
innerHTML(value: string): Element;
|
|
31
|
-
write(content: string, asHTML?: boolean, newLine?: boolean): Element;
|
|
32
|
-
prepend(content: string, asHTML?: boolean, newLine?: boolean): Element;
|
|
33
|
-
clear(): Element;
|
|
34
|
-
/**
|
|
35
|
-
* Append child component or HTML element
|
|
36
|
-
*/
|
|
37
|
-
append(child: any): Element;
|
|
38
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
39
|
-
update(prop: string, value: any): void;
|
|
40
|
-
}
|
|
41
|
-
export declare function element(id: string, options?: ElementOptions): Element;
|
|
42
|
-
export declare function header(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
43
|
-
export declare function footer(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
44
|
-
export declare function main(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
45
|
-
export declare function aside(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
46
|
-
export declare function section(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
47
|
-
export declare function article(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
48
|
-
export declare function div(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
49
|
-
export declare function span(id: string, options?: Omit<ElementOptions, 'tagType'>): Element;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=element.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC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