cedro 0.1.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.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/index.html +13 -0
- package/package.json +18 -0
- package/src/core/application.core.ts +182 -0
- package/src/core/index.ts +8 -0
- package/src/core/jsxsupport.ts +100 -0
- package/src/core/screeen.core.ts +81 -0
- package/src/core/seo.ts +79 -0
- package/src/core/themes.core.ts +237 -0
- package/src/index.ts +16 -0
- package/src/interfaces/application.interface.ts +45 -0
- package/src/interfaces/screen.interface.ts +17 -0
- package/src/interfaces/themes.interface.ts +19 -0
- package/src/interfaces/widget.interface.ts +123 -0
- package/src/types/vector2d.type.ts +4 -0
- package/src/ui/Icon.ui.ts +70 -0
- package/src/ui/IconButton.ui.ts +70 -0
- package/src/ui/button.ui.ts +88 -0
- package/src/ui/colors.ui.ts +7 -0
- package/src/ui/dialog.tsx +398 -0
- package/src/ui/index.ts +24 -0
- package/src/ui/label.ui.ts +61 -0
- package/src/ui/menu.ui.ts +192 -0
- package/src/ui/select.ui.ts +74 -0
- package/src/ui/styles/button.css +237 -0
- package/src/ui/styles/dialog.css +48 -0
- package/src/ui/styles/main.css +93 -0
- package/src/ui/styles/menu.css +56 -0
- package/src/ui/styles/textbox.css +35 -0
- package/src/ui/styles/theme/dark.css +37 -0
- package/src/ui/styles/theme/light.css +37 -0
- package/src/ui/textbox.ui.ts +132 -0
- package/src/ui/widget.builder.ui.tsx +676 -0
- package/src/ui/widget.collection.ts +19 -0
- package/src/ui/widget.ui.ts +832 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
import { IWidget } from "../interfaces/widget.interface";
|
|
2
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { Button, ButonVariants } from "./button.ui";
|
|
4
|
+
import { InputTypes, Textbox } from "./textbox.ui";
|
|
5
|
+
import { Colors } from "./colors.ui";
|
|
6
|
+
import { IconButton } from "./IconButton.ui";
|
|
7
|
+
import { Icon, IconVariants } from "./Icon.ui";
|
|
8
|
+
import { Menu } from "./menu.ui";
|
|
9
|
+
import { Select } from "./select.ui";
|
|
10
|
+
|
|
11
|
+
export interface XSelectProps {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
width?: number | null;
|
|
15
|
+
height?: number | null;
|
|
16
|
+
classNames?: string | null;
|
|
17
|
+
children: any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface XSelectOptionProps {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
icon?: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates a select option component with the given properties.
|
|
28
|
+
*
|
|
29
|
+
* @param {XSelectOptionProps} id - The unique identifier for the option.
|
|
30
|
+
* @param {XSelectOptionProps} label - The label for the option.
|
|
31
|
+
* @param {XSelectOptionProps | null} icon - The optional icon for the option.
|
|
32
|
+
* @return {JSX.Element} The select option component.
|
|
33
|
+
*/
|
|
34
|
+
export const XSelectOption = ({
|
|
35
|
+
id,
|
|
36
|
+
label,
|
|
37
|
+
icon = null,
|
|
38
|
+
}: XSelectOptionProps) => {
|
|
39
|
+
return (
|
|
40
|
+
<div id={id} widget-label={label} widget-icon={icon} w-select-option>
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Render a custom select component.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} id - The ID of the select component.
|
|
50
|
+
* @param {string} title - The title of the select component.
|
|
51
|
+
* @param {number|null} width - The width of the select component, or null if not set.
|
|
52
|
+
* @param {number|null} height - The height of the select component, or null if not set.
|
|
53
|
+
* @param {string|null} classNames - The class names for the select component, or null if not set.
|
|
54
|
+
* @param {ReactNode} children - The child components to be rendered inside the select component.
|
|
55
|
+
* @return {ReactElement} The rendered select component.
|
|
56
|
+
*/
|
|
57
|
+
export const XSelect = ({
|
|
58
|
+
id,
|
|
59
|
+
title,
|
|
60
|
+
width = null,
|
|
61
|
+
height = null,
|
|
62
|
+
classNames = null,
|
|
63
|
+
children,
|
|
64
|
+
}: XSelectProps) => {
|
|
65
|
+
return (
|
|
66
|
+
<div
|
|
67
|
+
id={id}
|
|
68
|
+
w-select
|
|
69
|
+
widget-title={title}
|
|
70
|
+
widget-width={width}
|
|
71
|
+
widget-height={height}
|
|
72
|
+
widget-class={classNames}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export interface XMenuProps {
|
|
80
|
+
id: string;
|
|
81
|
+
triggerId: string;
|
|
82
|
+
children: any;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface XMenuOptionProps {
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
88
|
+
icon?: string | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const XMenuOption = ({ id, label, icon = null }: XMenuOptionProps) => {
|
|
92
|
+
return (
|
|
93
|
+
<div id={id} widget-label={label} widget-icon={icon} w-menu-option>
|
|
94
|
+
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Renders an XMenu component.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} id - The ID of the XMenu component.
|
|
103
|
+
* @param {string} triggerId - The ID of the trigger element for the XMenu component.
|
|
104
|
+
* @param {ReactNode} children - The content to be rendered inside the XMenu component.
|
|
105
|
+
* @returns {JSX.Element} - The rendered XMenu component.
|
|
106
|
+
*/
|
|
107
|
+
export const XMenu = ({ id, triggerId, children }: XMenuProps) => {
|
|
108
|
+
return (
|
|
109
|
+
<div id={id} widget-trigger-id={triggerId} w-menu>
|
|
110
|
+
{children}
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export interface XIconProps {
|
|
116
|
+
id: string;
|
|
117
|
+
variant?: IconVariants | null;
|
|
118
|
+
icon: string;
|
|
119
|
+
classNames?: string | null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const XIcon = ({ id, variant, icon, classNames = null }: XIconProps) => {
|
|
123
|
+
return (
|
|
124
|
+
<span
|
|
125
|
+
id={id}
|
|
126
|
+
widget-variant={variant}
|
|
127
|
+
widget-icon={icon}
|
|
128
|
+
widget-class={classNames}
|
|
129
|
+
w-icon
|
|
130
|
+
>
|
|
131
|
+
|
|
132
|
+
</span>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export interface XIconButtonProps {
|
|
137
|
+
id: string;
|
|
138
|
+
title?: string | null;
|
|
139
|
+
size?: number | null;
|
|
140
|
+
variant?: ButonVariants | null;
|
|
141
|
+
color?: Colors | null;
|
|
142
|
+
icon: string;
|
|
143
|
+
classNames?: string | null;
|
|
144
|
+
visible?: boolean | null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Renders an `XIconButton` component.
|
|
149
|
+
*
|
|
150
|
+
* @param {XIconButtonProps} id - The ID of the icon button.
|
|
151
|
+
* @param {string} title - The title of the icon button.
|
|
152
|
+
* @param {string} size - The size of the icon button.
|
|
153
|
+
* @param {string} variant - The variant of the icon button.
|
|
154
|
+
* @param {string} color - The color of the icon button.
|
|
155
|
+
* @param {string} icon - The icon of the icon button.
|
|
156
|
+
* @param {string} className - The classes to apply separatesd by a space.
|
|
157
|
+
* @param {boolean} visible - The visible state of the icon button.
|
|
158
|
+
* @return {JSX.Element} The rendered `XIconButton` component.
|
|
159
|
+
*/
|
|
160
|
+
export const XIconButton = ({
|
|
161
|
+
id,
|
|
162
|
+
title = null,
|
|
163
|
+
size,
|
|
164
|
+
variant,
|
|
165
|
+
color,
|
|
166
|
+
icon,
|
|
167
|
+
classNames = null,
|
|
168
|
+
visible = true,
|
|
169
|
+
}: XIconButtonProps) => {
|
|
170
|
+
return (
|
|
171
|
+
<span
|
|
172
|
+
id={id}
|
|
173
|
+
widget-text={title}
|
|
174
|
+
widget-size={size}
|
|
175
|
+
widget-variant={variant}
|
|
176
|
+
widget-color={color}
|
|
177
|
+
widget-icon={icon}
|
|
178
|
+
widget-class={classNames}
|
|
179
|
+
widget-visible={visible}
|
|
180
|
+
w-iconbutton
|
|
181
|
+
>
|
|
182
|
+
|
|
183
|
+
</span>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export interface XButtonProps {
|
|
188
|
+
id: string;
|
|
189
|
+
title: string;
|
|
190
|
+
size?: number | null;
|
|
191
|
+
variant?: ButonVariants | null;
|
|
192
|
+
color?: Colors | null;
|
|
193
|
+
width?: number | null;
|
|
194
|
+
height?: number | null;
|
|
195
|
+
classNames?: string | null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Renders an XButton component.
|
|
200
|
+
*
|
|
201
|
+
* @param {XButtonProps} id - The id of the button.
|
|
202
|
+
* @param {XButtonProps} title - The title of the button.
|
|
203
|
+
* @return {JSX.Element} The rendered XButton component.
|
|
204
|
+
*/
|
|
205
|
+
export const XButton = ({
|
|
206
|
+
id,
|
|
207
|
+
title,
|
|
208
|
+
size,
|
|
209
|
+
variant,
|
|
210
|
+
color,
|
|
211
|
+
width = null,
|
|
212
|
+
height = null,
|
|
213
|
+
classNames = null,
|
|
214
|
+
}: XButtonProps) => {
|
|
215
|
+
return (
|
|
216
|
+
<button
|
|
217
|
+
id={id}
|
|
218
|
+
widget-text={title}
|
|
219
|
+
widget-size={size}
|
|
220
|
+
widget-variant={variant}
|
|
221
|
+
widget-color={color}
|
|
222
|
+
widget-width={width}
|
|
223
|
+
widget-height={height}
|
|
224
|
+
widget-class={classNames}
|
|
225
|
+
>
|
|
226
|
+
|
|
227
|
+
</button>
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export interface XTextBoxProps {
|
|
232
|
+
id: string;
|
|
233
|
+
title: string;
|
|
234
|
+
type?: InputTypes | null;
|
|
235
|
+
width?: number | null;
|
|
236
|
+
height?: number | null;
|
|
237
|
+
classNames?: string | null;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Renders a custom text box component.
|
|
242
|
+
*
|
|
243
|
+
* @param {XTextBoxProps} id - The ID of the text box.
|
|
244
|
+
* @param {XTextBoxProps} title - The title of the text box.
|
|
245
|
+
* @return {JSX.Element} The rendered text box component.
|
|
246
|
+
*/
|
|
247
|
+
export const XTextBox = ({
|
|
248
|
+
id,
|
|
249
|
+
title,
|
|
250
|
+
type = null,
|
|
251
|
+
width = null,
|
|
252
|
+
height = null,
|
|
253
|
+
classNames = null,
|
|
254
|
+
}: XTextBoxProps) => {
|
|
255
|
+
return (
|
|
256
|
+
<input
|
|
257
|
+
id={id}
|
|
258
|
+
w-textbox
|
|
259
|
+
widget-title={title}
|
|
260
|
+
widget-input-type={type}
|
|
261
|
+
widget-width={width}
|
|
262
|
+
widget-height={height}
|
|
263
|
+
widget-class={classNames}
|
|
264
|
+
>
|
|
265
|
+
|
|
266
|
+
</input>
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export interface XSeparatorProps {
|
|
271
|
+
size: number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Renders a horizontal separator with a specific size.
|
|
276
|
+
*
|
|
277
|
+
* @param {XSeparatorProps} size - The size of the separator.
|
|
278
|
+
* @return {JSX.Element} A div element representing the separator.
|
|
279
|
+
*/
|
|
280
|
+
export const XSeparator = ({ size }: XSeparatorProps) => {
|
|
281
|
+
return <div widget-size={size}> </div>;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* A component that adds horizontal or vertical spacing.
|
|
286
|
+
*
|
|
287
|
+
* @return {JSX.Element} A div element with a non-breaking space.
|
|
288
|
+
*/
|
|
289
|
+
export const XSpacer = () => {
|
|
290
|
+
return <div> </div>;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export interface XVerticalContainerProps {
|
|
294
|
+
children: any;
|
|
295
|
+
padding: number;
|
|
296
|
+
overflow?: boolean | null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Renders a vertical container with the given padding and children.
|
|
301
|
+
*
|
|
302
|
+
* @param {XVerticalContainerProps} padding - The padding of the container.
|
|
303
|
+
* @param {React.ReactNode} children - The children components to render inside the container.
|
|
304
|
+
* @return {React.ReactNode} The rendered vertical container.
|
|
305
|
+
*/
|
|
306
|
+
export const XVerticalContainer = ({
|
|
307
|
+
padding,
|
|
308
|
+
children,
|
|
309
|
+
overflow = false,
|
|
310
|
+
}: XVerticalContainerProps) => {
|
|
311
|
+
return (
|
|
312
|
+
<div
|
|
313
|
+
id="section1Container"
|
|
314
|
+
widget-align={WidgetAlignTypes.VERTICAL}
|
|
315
|
+
widget-padding={padding}
|
|
316
|
+
widget-overflow={overflow}
|
|
317
|
+
>
|
|
318
|
+
{children}
|
|
319
|
+
</div>
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export interface XHorizontalContainerProps {
|
|
324
|
+
children: any;
|
|
325
|
+
padding: number;
|
|
326
|
+
size?: number | null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Renders a horizontal container component.
|
|
331
|
+
*
|
|
332
|
+
* @param {XHorizontalContainerProps} props - The props for the component.
|
|
333
|
+
* @param {number} props.padding - The padding value for the container.
|
|
334
|
+
* @param {ReactNode} props.children - The children to render inside the container.
|
|
335
|
+
* @return {ReactElement} The rendered horizontal container component.
|
|
336
|
+
*/
|
|
337
|
+
export const XHorizontalContainer = ({
|
|
338
|
+
padding,
|
|
339
|
+
children,
|
|
340
|
+
size = null,
|
|
341
|
+
}: XHorizontalContainerProps) => {
|
|
342
|
+
return (
|
|
343
|
+
<div
|
|
344
|
+
id="section1Container"
|
|
345
|
+
widget-align={WidgetAlignTypes.HORIZONTAL}
|
|
346
|
+
widget-padding={padding}
|
|
347
|
+
widget-size={size}
|
|
348
|
+
>
|
|
349
|
+
{children}
|
|
350
|
+
</div>
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Creates a widget based on the provided content and parent.
|
|
356
|
+
*
|
|
357
|
+
* @param {any} content - The content for the widget.
|
|
358
|
+
* @param {IWidget | null} parent - The parent widget.
|
|
359
|
+
* @return {Widget | null} The created widget.
|
|
360
|
+
*/
|
|
361
|
+
export function createWidget(
|
|
362
|
+
content: any,
|
|
363
|
+
parent: IWidget | null = null,
|
|
364
|
+
freedom: boolean = false
|
|
365
|
+
): Widget | null {
|
|
366
|
+
let id = content.id;
|
|
367
|
+
const tagName = content.tagName;
|
|
368
|
+
|
|
369
|
+
if (tagName) {
|
|
370
|
+
if (!id) {
|
|
371
|
+
id = parent?.id + Math.random().toString().substring(0, 10);
|
|
372
|
+
}
|
|
373
|
+
const dataType =
|
|
374
|
+
content.getAttribute("widget-type") === null
|
|
375
|
+
? WidgetTypes.FILL
|
|
376
|
+
: parseInt(content.getAttribute("widget-type")); // parseInt(content.getAttribute("widget-type"));
|
|
377
|
+
const dataAlign =
|
|
378
|
+
content.getAttribute("widget-align") === null
|
|
379
|
+
? WidgetAlignTypes.HORIZONTAL
|
|
380
|
+
: parseInt(content.getAttribute("widget-align"));
|
|
381
|
+
|
|
382
|
+
const dataPadding =
|
|
383
|
+
content.getAttribute("widget-padding") === null
|
|
384
|
+
? 0
|
|
385
|
+
: parseInt(content.getAttribute("widget-padding"));
|
|
386
|
+
|
|
387
|
+
const dataSize: number | null =
|
|
388
|
+
content.getAttribute("widget-size") === null
|
|
389
|
+
? null
|
|
390
|
+
: parseInt(content.getAttribute("widget-size"));
|
|
391
|
+
|
|
392
|
+
if (tagName.toLowerCase() === "button") {
|
|
393
|
+
const newButton = new Button(id, parent as Widget);
|
|
394
|
+
const dataText = content.getAttribute("widget-text");
|
|
395
|
+
|
|
396
|
+
const dataVariant = content.getAttribute("widget-variant");
|
|
397
|
+
const dataColor = content.getAttribute("widget-color");
|
|
398
|
+
|
|
399
|
+
const dataWidth = content.getAttribute("widget-width");
|
|
400
|
+
const dataHeight = content.getAttribute("widget-height");
|
|
401
|
+
|
|
402
|
+
const dataClases = content.getAttribute("widget-class");
|
|
403
|
+
|
|
404
|
+
if (dataSize) {
|
|
405
|
+
newButton.setFixedSize(dataSize);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (dataVariant) {
|
|
409
|
+
newButton.setVariant(dataVariant);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (dataColor) {
|
|
413
|
+
newButton.setColor(dataColor);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (freedom) {
|
|
417
|
+
newButton.setType(WidgetTypes.FREE);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (dataWidth) {
|
|
421
|
+
newButton.setInitialW(dataWidth);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (dataHeight) {
|
|
425
|
+
newButton.setInitialH(dataHeight);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (dataClases) {
|
|
429
|
+
const clases = dataClases.split(" ");
|
|
430
|
+
for (const clase of clases) {
|
|
431
|
+
newButton.addClass(clase);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
newButton.setAlign(dataAlign);
|
|
436
|
+
newButton.setType(dataType);
|
|
437
|
+
newButton.setPadding(dataPadding);
|
|
438
|
+
newButton.setText(dataText);
|
|
439
|
+
window.w.set(id, newButton);
|
|
440
|
+
return newButton;
|
|
441
|
+
} else if (content.getAttribute("w-textbox")) {
|
|
442
|
+
const newTextbox = new Textbox(id, parent as Widget);
|
|
443
|
+
const dataTitle = content.getAttribute("widget-title");
|
|
444
|
+
|
|
445
|
+
const dataInputType = content.getAttribute("widget-input-type");
|
|
446
|
+
|
|
447
|
+
const dataWidth = content.getAttribute("widget-width");
|
|
448
|
+
const dataHeight = content.getAttribute("widget-height");
|
|
449
|
+
|
|
450
|
+
const dataClases = content.getAttribute("widget-class");
|
|
451
|
+
|
|
452
|
+
if (dataInputType) {
|
|
453
|
+
newTextbox.setInputType(dataInputType);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (dataSize) {
|
|
457
|
+
newTextbox.setFixedSize(dataSize);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (dataWidth) {
|
|
461
|
+
newTextbox.setInitialW(dataWidth);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (dataHeight) {
|
|
465
|
+
newTextbox.setInitialH(dataHeight);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (dataClases) {
|
|
469
|
+
const clases = dataClases.split(" ");
|
|
470
|
+
for (const clase of clases) {
|
|
471
|
+
newTextbox.addClass(clase);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
newTextbox.setAlign(dataAlign);
|
|
476
|
+
newTextbox.setType(dataType);
|
|
477
|
+
newTextbox.setPadding(dataPadding);
|
|
478
|
+
newTextbox.setTitle(dataTitle);
|
|
479
|
+
window.w.set(id, newTextbox);
|
|
480
|
+
return newTextbox;
|
|
481
|
+
} else if (content.getAttribute("w-iconbutton")) {
|
|
482
|
+
const dataIcon = content.getAttribute("widget-icon");
|
|
483
|
+
const dataClases = content.getAttribute("widget-class");
|
|
484
|
+
const dataVisible = content.getAttribute("widget-visible");
|
|
485
|
+
const newIconButton = new IconButton(
|
|
486
|
+
id,
|
|
487
|
+
dataIcon,
|
|
488
|
+
parent as Widget
|
|
489
|
+
);
|
|
490
|
+
const dataTitle = content.getAttribute("widget-text");
|
|
491
|
+
if (dataSize) {
|
|
492
|
+
newIconButton.setFixedSize(dataSize);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (dataClases) {
|
|
496
|
+
const clases = dataClases.split(" ");
|
|
497
|
+
for (const clase of clases) {
|
|
498
|
+
newIconButton.addClass(clase);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (!dataVisible) {
|
|
503
|
+
newIconButton.setVisible(false);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
newIconButton.setAlign(dataAlign);
|
|
507
|
+
newIconButton.setType(dataType);
|
|
508
|
+
newIconButton.setPadding(dataPadding);
|
|
509
|
+
newIconButton.setText(dataTitle);
|
|
510
|
+
window.w.set(id, newIconButton);
|
|
511
|
+
return newIconButton;
|
|
512
|
+
} else if (content.getAttribute("w-icon")) {
|
|
513
|
+
const dataIcon = content.getAttribute("widget-icon");
|
|
514
|
+
const dataVariant = content.getAttribute("widget-variant");
|
|
515
|
+
const dataClases = content.getAttribute("widget-class");
|
|
516
|
+
const newIcon = new Icon(
|
|
517
|
+
id,
|
|
518
|
+
dataIcon,
|
|
519
|
+
dataVariant,
|
|
520
|
+
parent as Widget
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
if (dataClases) {
|
|
524
|
+
const clases = dataClases.split(" ");
|
|
525
|
+
for (const clase of clases) {
|
|
526
|
+
newIcon.addClass(clase);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
newIcon.setAlign(dataAlign);
|
|
531
|
+
newIcon.setType(dataType);
|
|
532
|
+
newIcon.setPadding(dataPadding);
|
|
533
|
+
|
|
534
|
+
window.w.set(id, newIcon);
|
|
535
|
+
return newIcon;
|
|
536
|
+
} else if (content.getAttribute("w-menu")) {
|
|
537
|
+
const dataTriggerId = content.getAttribute("widget-trigger-id");
|
|
538
|
+
const newMenu = new Menu(id, dataTriggerId, null);
|
|
539
|
+
|
|
540
|
+
(content as HTMLElement).childNodes.forEach((child) => {
|
|
541
|
+
const optionMenu = child as HTMLElement;
|
|
542
|
+
if ((optionMenu as HTMLElement).getAttribute("w-menu-option")) {
|
|
543
|
+
const dataOptionId = optionMenu.getAttribute("id");
|
|
544
|
+
const dataOptionLabel =
|
|
545
|
+
optionMenu.getAttribute("widget-label");
|
|
546
|
+
const dataOptionIcon = optionMenu.getAttribute(
|
|
547
|
+
"widget-icon"
|
|
548
|
+
)
|
|
549
|
+
? optionMenu.getAttribute("widget-icon")
|
|
550
|
+
: "";
|
|
551
|
+
|
|
552
|
+
if (dataOptionId) {
|
|
553
|
+
newMenu.addOption(
|
|
554
|
+
dataOptionId,
|
|
555
|
+
dataOptionIcon || "",
|
|
556
|
+
dataOptionLabel || ""
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
window.w.set(id, newMenu);
|
|
563
|
+
return newMenu;
|
|
564
|
+
} else if (content.getAttribute("w-select")) {
|
|
565
|
+
const newSelect = new Select(id, parent as Widget);
|
|
566
|
+
|
|
567
|
+
(content as HTMLElement).childNodes.forEach((child) => {
|
|
568
|
+
const optionSelect = child as HTMLElement;
|
|
569
|
+
if (
|
|
570
|
+
(optionSelect as HTMLElement).getAttribute(
|
|
571
|
+
"w-select-option"
|
|
572
|
+
)
|
|
573
|
+
) {
|
|
574
|
+
const dataItemId = optionSelect.getAttribute("id");
|
|
575
|
+
const dataItemLabel =
|
|
576
|
+
optionSelect.getAttribute("widget-label");
|
|
577
|
+
const dataItemIcon = optionSelect.getAttribute(
|
|
578
|
+
"widget-icon"
|
|
579
|
+
)
|
|
580
|
+
? optionSelect.getAttribute("widget-icon")
|
|
581
|
+
: "";
|
|
582
|
+
|
|
583
|
+
if (dataItemId) {
|
|
584
|
+
newSelect.addItem(
|
|
585
|
+
dataItemId,
|
|
586
|
+
dataItemLabel || "",
|
|
587
|
+
dataItemIcon || ""
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
const dataTitle = content.getAttribute("widget-title");
|
|
594
|
+
const dataWidth = content.getAttribute("widget-width");
|
|
595
|
+
const dataHeight = content.getAttribute("widget-height");
|
|
596
|
+
const dataClases = content.getAttribute("widget-class");
|
|
597
|
+
|
|
598
|
+
if (dataWidth) {
|
|
599
|
+
newSelect.setInitialW(dataWidth);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (dataHeight) {
|
|
603
|
+
newSelect.setInitialH(dataHeight);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (dataClases) {
|
|
607
|
+
const clases = dataClases.split(" ");
|
|
608
|
+
for (const clase of clases) {
|
|
609
|
+
newSelect.addClass(clase);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
newSelect.setType(dataType);
|
|
614
|
+
newSelect.setAlign(dataAlign);
|
|
615
|
+
newSelect.setPadding(dataPadding);
|
|
616
|
+
newSelect.setTitle(dataTitle);
|
|
617
|
+
|
|
618
|
+
window.w.set(id, newSelect);
|
|
619
|
+
return newSelect;
|
|
620
|
+
} else {
|
|
621
|
+
const newWidget = new Widget(id, tagName, parent);
|
|
622
|
+
|
|
623
|
+
const dataClases = content.getAttribute("widget-class");
|
|
624
|
+
|
|
625
|
+
if (dataClases) {
|
|
626
|
+
const clases = dataClases.split(" ");
|
|
627
|
+
for (const clase of clases) {
|
|
628
|
+
newWidget.addClass(clase);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
newWidget.setAlign(dataAlign);
|
|
633
|
+
|
|
634
|
+
newWidget.setPadding(dataPadding);
|
|
635
|
+
|
|
636
|
+
if (dataSize) {
|
|
637
|
+
newWidget.setFixedSize(dataSize);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (dataType === WidgetTypes.FREE) {
|
|
641
|
+
freedom = true;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
if (!freedom) {
|
|
645
|
+
newWidget.setType(dataType);
|
|
646
|
+
} else {
|
|
647
|
+
newWidget.setType(WidgetTypes.FREE);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const dataOverflow = content.getAttribute("widget-overflow");
|
|
651
|
+
|
|
652
|
+
if (dataOverflow) {
|
|
653
|
+
newWidget.setOverflow(true);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
content.getAttributeNames().forEach((key: string) => {
|
|
657
|
+
newWidget
|
|
658
|
+
.getBody()
|
|
659
|
+
.setAttribute(key, content.getAttribute(key));
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
(content as HTMLElement).childNodes.forEach((child) => {
|
|
663
|
+
if (child.hasChildNodes() == true) {
|
|
664
|
+
createWidget(child, newWidget, freedom);
|
|
665
|
+
} else {
|
|
666
|
+
newWidget.getBody().appendChild(child);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
//console.log("new widget", newWidget);
|
|
670
|
+
window.w.set(id, newWidget);
|
|
671
|
+
return newWidget;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return content;
|
|
676
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IWidget } from "../interfaces/widget.interface";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
w: Map<string, IWidget>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var w: Map<string, IWidget>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const initWidgetCollection = () => {
|
|
12
|
+
|
|
13
|
+
if(!window.w) {
|
|
14
|
+
window.w = new Map<string, IWidget>();
|
|
15
|
+
w = window.w;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|