domelemjs 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2022-present Viktor Bozzay <bozzay.viktor@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software
6
+ without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense,
8
+ and/or sell copies of the Software, and to permit persons to
9
+ whom the Software is furnished to do so, subject to the
10
+ following conditions:
11
+
12
+ The above copyright notice and this permission notice shall
13
+ be included in all copies or substantial portions of the
14
+ Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,142 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Document</title>
8
+ </head>
9
+ <body>
10
+ <script src="./index.js"></script>
11
+ <script>
12
+ /* használata */
13
+
14
+ let myDOM = {};
15
+
16
+ /* 1. Úgy is haszálhatom, hogy változóba hozom létre, és azt appendolom külön */
17
+
18
+ myDOM.selectControlContainer = DOMElem.Create({
19
+ tag: "div",
20
+ attrs: { class: "első próbálkozás" },
21
+ });
22
+
23
+ document.body.appendChild(myDOM.selectControlContainer);
24
+
25
+ /* 2. Úgy is használhatom, hogy a szülőelemet már az Elem létrehozásakor megadom neki, és akkor befűzi oda. */
26
+
27
+ function generateOption(options) {
28
+ return options.map((option) =>
29
+ DOMElem.Create({
30
+ tag: "option",
31
+ text: option,
32
+ })
33
+ );
34
+ }
35
+
36
+ let animals = ["Maci", "Nyuszi", "Cica", "Kutya"];
37
+ let animalOption = generateOption(animals);
38
+
39
+ myDOM.selectControl = DOMElem.Create({
40
+ tag: "label",
41
+ text: "állatkák:",
42
+ attrs: { for: "selectControl" },
43
+ parent: myDOM.selectControlContainer,
44
+ });
45
+
46
+ myDOM.selectControl = DOMElem.Create({
47
+ tag: "select",
48
+ attrs: { id: "selectControl" },
49
+ style: { color: "red" },
50
+ parent: myDOM.selectControlContainer,
51
+ children: animalOption,
52
+ });
53
+
54
+ /* 3. Úgy is haszálhatom, hogy egyből appendolom és azt változónak adom */
55
+
56
+ let plants = ["Fenyő", "Juhar", "Cédrus", "Mahagóni"];
57
+
58
+ myDOM.selectControl = myDOM.selectControl.appendChild(
59
+ DOMElem.Create({
60
+ tag: "label",
61
+ text: "fák:",
62
+ attrs: { for: "selectControl" },
63
+ parent: myDOM.selectControlContainer,
64
+ })
65
+ );
66
+ myDOM.selectControl = myDOM.selectControl.appendChild(
67
+ DOMElem.Create({
68
+ tag: "select",
69
+ attrs: { id: "selectControl" },
70
+ parent: myDOM.selectControlContainer,
71
+ children: generateOption(plants),
72
+ })
73
+ );
74
+
75
+ /* Példa egy komplexebb struktúra előállítására */
76
+
77
+ myDOM.dateFilterContainer = document.body.appendChild(
78
+ DOMElem.Create({
79
+ tag: "div",
80
+ attrs: { class: "dateFilter-Container", id: "dateFilter-Container" },
81
+ children: [
82
+ DOMElem.Create({
83
+ tag: "div",
84
+ attrs: {
85
+ class: "beginDate-container",
86
+ id: "beginDate-container",
87
+ },
88
+ children: [
89
+ DOMElem.Create({
90
+ tag: "label",
91
+ attrs: {
92
+ class: "beginDate-lable",
93
+ },
94
+ text: "Kezdő dátum: ",
95
+ }),
96
+ DOMElem.Create({
97
+ tag: "input",
98
+ attrs: {
99
+ type: "date",
100
+ class: "beginDate",
101
+ id: "beginDate",
102
+ },
103
+ eventStarter: "change",
104
+ eventFunction: function (e) {
105
+ e.preventDefault();
106
+ console.log(this.value);
107
+ },
108
+ }),
109
+ ],
110
+ }),
111
+ DOMElem.Create({
112
+ tag: "div",
113
+ attrs: { class: "endDate-container", id: "endDate-container" },
114
+ children: [
115
+ DOMElem.Create({
116
+ tag: "label",
117
+ attrs: {
118
+ class: "endDate-lable",
119
+ },
120
+ text: "Befejező dátum: ",
121
+ }),
122
+ DOMElem.Create({
123
+ tag: "input",
124
+ attrs: {
125
+ type: "date",
126
+ class: "endDate",
127
+ id: "endDate",
128
+ },
129
+ eventStarter: "change",
130
+ eventFunction: function (e) {
131
+ e.preventDefault();
132
+ console.log(this.value);
133
+ },
134
+ }),
135
+ ],
136
+ }),
137
+ ],
138
+ })
139
+ );
140
+ </script>
141
+ </body>
142
+ </html>
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Document</title>
8
+ </head>
9
+ <body>
10
+ <script src="./index.js"></script>
11
+ <script>
12
+ const app = createDOMElem({
13
+ tag: "div",
14
+ attrs: { id: "app" },
15
+ });
16
+
17
+ /* styling is easy */
18
+ createDOMElem({
19
+ tag: h1,
20
+ text: "Hello World!",
21
+ parent: app,
22
+ style: "color: red; background-color: green",
23
+ attrs: {
24
+ id: "title1",
25
+ class: "áéőúóüűöí/*-",
26
+ dataset: { text: "redText" },
27
+ },
28
+ });
29
+ createDOMElem({
30
+ tag: h2,
31
+ text: "It's amazing",
32
+ parent: app,
33
+ style: { color: "red", backgroundColor: "pink" },
34
+ attrs: [
35
+ {
36
+ id: "title2",
37
+ },
38
+ {
39
+ dataset: [{ text: "redText" }, { bg: "greenBG" }],
40
+ },
41
+ ],
42
+ });
43
+ createDOMElem({
44
+ tag: h3,
45
+ text: "I can write style as I want to",
46
+ parent: app,
47
+ style: ["color: red", "background-color: blue"],
48
+ attrs: { id: "title3" },
49
+ });
50
+ createDOMElem({
51
+ tag: h4,
52
+ text: "Awesome",
53
+ parent: app,
54
+ style: [{ color: "red" }, { backgroundColor: "green" }],
55
+ attrs: { id: "title4" },
56
+ });
57
+
58
+ /* creating a select with 2 options and eventHandler */
59
+ const selector = createDOMElem({
60
+ tag: select,
61
+ parent: app,
62
+ attrs: { id: "selector" },
63
+ children: [
64
+ {
65
+ tag: option,
66
+ text: "foo",
67
+ attrs: { value: "foo" },
68
+ },
69
+ {
70
+ tag: option,
71
+ text: "bar",
72
+ attrs: { value: "bar" },
73
+ },
74
+ ],
75
+ handleEvent: {
76
+ event: "change",
77
+ cb: (e) => console.log(e.target.value),
78
+ },
79
+ });
80
+
81
+ DOMElem.Create({
82
+ tag: div,
83
+ parent: app,
84
+ children: [
85
+ DOMElem.Create({
86
+ tag: label,
87
+ content: "Write Something",
88
+ attrs: { for: "inputText" },
89
+ }),
90
+ DOMElem.Create({ tag: "input", attrs: { id: "inputText" } }),
91
+ ],
92
+ });
93
+ </script>
94
+ </body>
95
+ </html>
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "domelemjs",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
+ "type": "module",
4
5
  "description": "With the help of this package the rendering of HTML elements form JavaScript become a easy job.",
5
6
  "main": "./dist/index.js",
6
7
  "prepublishOnly": "webpack --mode=production",
@@ -30,8 +31,14 @@
30
31
  "directories": {
31
32
  "test": "test"
32
33
  },
33
- "dependencies": {},
34
+ "dependencies": {
35
+ "makeCamelCase": "file:./src/Utils/makeCamelCase.mjs",
36
+ "makeThatArray": "file:./src/Utils/makeThatArray.mjs",
37
+ "noSpecChars": "file:./src/Utils/noSpecChars.mjs",
38
+ "domElemTypes": "file:./src/model/domElemTypes.mjs"
39
+ },
34
40
  "devDependencies": {
41
+ "url-loader": "^4.1.1",
35
42
  "clean-webpack-plugin": "^4.0.0",
36
43
  "css-loader": "^6.7.1",
37
44
  "html-webpack-plugin": "^5.5.0",