nodality 1.0.0-beta.1
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/dist/animator.cjs.js +1 -0
- package/dist/animator.esm.js +1 -0
- package/dist/audionew.cjs.js +1 -0
- package/dist/audionew.esm.js +1 -0
- package/dist/base.cjs.js +1 -0
- package/dist/base.esm.js +1 -0
- package/dist/betaDesktopBar.esm.js +1 -0
- package/dist/betaMobileBar.esm.js +1 -0
- package/dist/bundle.umd.js +1 -0
- package/dist/button.cjs.js +1 -0
- package/dist/button.esm.js +1 -0
- package/dist/cardGetter.cjs.js +1 -0
- package/dist/cardGetter.esm.js +1 -0
- package/dist/center.cjs.js +1 -0
- package/dist/center.esm.js +1 -0
- package/dist/checkbox.cjs.js +1 -0
- package/dist/checkbox.esm.js +1 -0
- package/dist/code.cjs.js +1 -0
- package/dist/code.esm.js +1 -0
- package/dist/container.cjs.js +1 -0
- package/dist/container.esm.js +1 -0
- package/dist/datalist.cjs.js +1 -0
- package/dist/datalist.esm.js +1 -0
- package/dist/designer.cjs.js +1 -0
- package/dist/designer.esm.js +1 -0
- package/dist/dropdown.cjs.js +1 -0
- package/dist/dropdown.esm.js +1 -0
- package/dist/elementMapper.cjs.js +1 -0
- package/dist/elementMapper.esm.js +1 -0
- package/dist/finalresult.esm.js +1 -0
- package/dist/flexCard.cjs.js +1 -0
- package/dist/flexCard.esm.js +1 -0
- package/dist/flexGrid.cjs.js +1 -0
- package/dist/flexGrid.esm.js +1 -0
- package/dist/flexRow.cjs.js +1 -0
- package/dist/flexRow.esm.js +1 -0
- package/dist/floatingInput.cjs.js +1 -0
- package/dist/floatingInput.esm.js +1 -0
- package/dist/free.cjs.js +1 -0
- package/dist/free.esm.js +1 -0
- package/dist/horizontalScroller.esm.js +1 -0
- package/dist/image.cjs.js +1 -0
- package/dist/image.esm.js +1 -0
- package/dist/imagePicker.cjs.js +1 -0
- package/dist/imagePicker.esm.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/link.cjs.js +1 -0
- package/dist/link.esm.js +1 -0
- package/dist/linkGetter.cjs.js +1 -0
- package/dist/linkGetter.esm.js +1 -0
- package/dist/metaAdder.cjs.js +1 -0
- package/dist/metaAdder.esm.js +1 -0
- package/dist/modal2025.cjs.js +1 -0
- package/dist/modal2025.esm.js +1 -0
- package/dist/multiswitchers.esm.js +1 -0
- package/dist/newNavBar.cjs.js +1 -0
- package/dist/newNavBar.esm.js +1 -0
- package/dist/picker.cjs.js +1 -0
- package/dist/picker.esm.js +1 -0
- package/dist/progress.cjs.js +1 -0
- package/dist/progress.esm.js +1 -0
- package/dist/radio.cjs.js +1 -0
- package/dist/radio.esm.js +1 -0
- package/dist/range.cjs.js +1 -0
- package/dist/range.esm.js +1 -0
- package/dist/sideBar.cjs.js +1 -0
- package/dist/sideBar.esm.js +1 -0
- package/dist/sideNavBar.cjs.js +1 -0
- package/dist/sideNavBar.esm.js +1 -0
- package/dist/simpleBar.cjs.js +1 -0
- package/dist/simpleBar.esm.js +1 -0
- package/dist/stack.cjs.js +1 -0
- package/dist/stack.esm.js +1 -0
- package/dist/table.cjs.js +1 -0
- package/dist/table.esm.js +1 -0
- package/dist/text.cjs.js +1 -0
- package/dist/text.esm.js +1 -0
- package/dist/textField.cjs.js +1 -0
- package/dist/textField.esm.js +1 -0
- package/dist/wrap.cjs.js +1 -0
- package/dist/wrap.esm.js +1 -0
- package/dist/zoomCard.cjs.js +1 -0
- package/dist/zoomCard.esm.js +1 -0
- package/layout/<head> +59 -0
- package/layout/DEADJOE +49 -0
- package/layout/DEPRECATED-PARAGRAPH.js +103 -0
- package/layout/animator.js +1915 -0
- package/layout/audio.js +145 -0
- package/layout/audionew.js +70 -0
- package/layout/base-2.js +92 -0
- package/layout/base.js +161 -0
- package/layout/betaDesktopBar.js +126 -0
- package/layout/betaMobileBar.js +293 -0
- package/layout/box.js +29 -0
- package/layout/button.js +516 -0
- package/layout/cards.js +136 -0
- package/layout/center.js +143 -0
- package/layout/checkbox.js +183 -0
- package/layout/cleanRow.js +775 -0
- package/layout/code.js +60 -0
- package/layout/container.js +1005 -0
- package/layout/custom.js +289 -0
- package/layout/divImage.js +209 -0
- package/layout/dropdown.js +154 -0
- package/layout/dropdown2025.js +152 -0
- package/layout/edit.sh +39 -0
- package/layout/emptyElement.js +21 -0
- package/layout/externalStylesheet.js +19 -0
- package/layout/flexCard.js +220 -0
- package/layout/flexGrid.js +192 -0
- package/layout/flexrow.js +866 -0
- package/layout/footer.js +83 -0
- package/layout/formComponents/custom.js +0 -0
- package/layout/formComponents/dataList.js +183 -0
- package/layout/formComponents/edit.sh +39 -0
- package/layout/formComponents/floatingInput.js +163 -0
- package/layout/formComponents/form-all.js +161 -0
- package/layout/formComponents/form.js +76 -0
- package/layout/formComponents/imagePicker.js +266 -0
- package/layout/formComponents/picker.js +208 -0
- package/layout/formComponents/radio.js +231 -0
- package/layout/formComponents/radiogroup.js +231 -0
- package/layout/formComponents/range.js +158 -0
- package/layout/free.js +232 -0
- package/layout/grid-new.js +299 -0
- package/layout/grid.js +190 -0
- package/layout/gridSwitcher.js +188 -0
- package/layout/group.js +163 -0
- package/layout/header.js +175 -0
- package/layout/hello.html +126 -0
- package/layout/horizontalScroller.js +222 -0
- package/layout/image-old.js +487 -0
- package/layout/image.js +1039 -0
- package/layout/index.js +183 -0
- package/layout/label.js +50 -0
- package/layout/link.js +1085 -0
- package/layout/list-OLD.js +0 -0
- package/layout/list.js +127 -0
- package/layout/metaAdder.js +17 -0
- package/layout/modal2025.js +142 -0
- package/layout/modernwrap.js +92 -0
- package/layout/multiswitcher.js +224 -0
- package/layout/multiswitcherBeta.js +63 -0
- package/layout/navBar-OLD.js +261 -0
- package/layout/navBar.js +371 -0
- package/layout/navFactor/customDiv.js +60 -0
- package/layout/navFactor/edit.sh +39 -0
- package/layout/newFlatAdder.js +41 -0
- package/layout/newNavBar copy 2.js +915 -0
- package/layout/newNavBar copy.js +774 -0
- package/layout/newNavBar.js +925 -0
- package/layout/offsetContainer.js +395 -0
- package/layout/progress.js +111 -0
- package/layout/remWin.sh +20 -0
- package/layout/row.js +208 -0
- package/layout/savedNewNavBar.js +437 -0
- package/layout/scrollvideo.js +120 -0
- package/layout/sideBar.js +183 -0
- package/layout/sideNavBar.js +313 -0
- package/layout/simpleBar.js +25 -0
- package/layout/slider2025.js +198 -0
- package/layout/spacer.js +44 -0
- package/layout/stack.js +76 -0
- package/layout/styler.js +113 -0
- package/layout/switcher.js +102 -0
- package/layout/table.js +155 -0
- package/layout/text.js +1685 -0
- package/layout/textField.js +282 -0
- package/layout/ulist.js +147 -0
- package/layout/video.js +70 -0
- package/layout/withoutNew.js +60 -0
- package/layout/wrap.js +140 -0
- package/layout/zoomCard.js +219 -0
- package/lib/cardGetter.js +80 -0
- package/lib/designer.js +875 -0
- package/lib/elementMapper.js +1428 -0
- package/lib/linkGetter.js +202 -0
- package/package.json +33 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import {Animator} from "../animator.js";
|
|
2
|
+
|
|
3
|
+
class RadioGroup /*extends Animator*/ {
|
|
4
|
+
constructor(){
|
|
5
|
+
// super();
|
|
6
|
+
this.el = null;
|
|
7
|
+
this.radioCount = 0;
|
|
8
|
+
// this.setup();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
set(objects){
|
|
12
|
+
|
|
13
|
+
this.options = objects;
|
|
14
|
+
console.log("ORARA");
|
|
15
|
+
console.log(this.options);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
this.radioCount = objects.items.length;
|
|
19
|
+
|
|
20
|
+
let wrap = document.createElement("div");
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
let obj = objects.items;
|
|
24
|
+
|
|
25
|
+
for (var i = 0; i < obj.length; i++){
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
let label = document.createElement("label");
|
|
29
|
+
|
|
30
|
+
if (obj.font){
|
|
31
|
+
label.style.font = obj.font;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (obj.color){
|
|
35
|
+
label.style.color = obj.color;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (obj.exact){
|
|
39
|
+
label.style.fontSize = obj.exact;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
let node = document.createTextNode(obj[i]);
|
|
46
|
+
label.appendChild(node);
|
|
47
|
+
label.setAttribute("for", obj[i]);
|
|
48
|
+
|
|
49
|
+
let card = document.createElement("input");
|
|
50
|
+
card.setAttribute("type", "radio");
|
|
51
|
+
card.setAttribute("id", `S${i}`);
|
|
52
|
+
card.setAttribute("value", obj[i].split(" ").join(""));
|
|
53
|
+
|
|
54
|
+
card.style.appearance = 'none';
|
|
55
|
+
card.style.width = '20px';
|
|
56
|
+
card.style.height = '20px';
|
|
57
|
+
card.style.border = this.options.tint ? `2px solid ${this.options.tint}` : '2px solid #007BFF';
|
|
58
|
+
card.style.borderRadius = '50%';
|
|
59
|
+
card.style.outline = 'none';
|
|
60
|
+
card.style.cursor = 'pointer';
|
|
61
|
+
card.style.transition = '0.3s';
|
|
62
|
+
|
|
63
|
+
// card.addEventListener('change', () => {
|
|
64
|
+
// alert("change");
|
|
65
|
+
/* if (card.checked) {
|
|
66
|
+
card.style.backgroundColor = '#007BFF';
|
|
67
|
+
card.style.boxShadow = '0 0 0 2px #0056b3 inset';
|
|
68
|
+
} else {
|
|
69
|
+
card.style.backgroundColor = 'transparent';
|
|
70
|
+
card.style.boxShadow = 'none';
|
|
71
|
+
}*/
|
|
72
|
+
// });
|
|
73
|
+
|
|
74
|
+
this.options.font && (label.style.fontFamily = this.options.font);
|
|
75
|
+
|
|
76
|
+
if (objects.multiple){
|
|
77
|
+
card.setAttribute("name", obj[i].split(" ").join(""));
|
|
78
|
+
} else {
|
|
79
|
+
card.setAttribute("name", objects.name);
|
|
80
|
+
// card.setAttribute("name", "same");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
/* card.addEventListener("change", () => {
|
|
85
|
+
let picked = card.options[card.selectedIndex].value;
|
|
86
|
+
console.log(picked);
|
|
87
|
+
});*/
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
wrap.appendChild(card);
|
|
91
|
+
wrap.appendChild(label);
|
|
92
|
+
wrap.innerHTML += "</br>";
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.el = wrap;
|
|
97
|
+
|
|
98
|
+
this.responsive();
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
padding(val){
|
|
105
|
+
this.el.style.padding = val;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getCheckedValues(){
|
|
110
|
+
console.log("NOW");
|
|
111
|
+
|
|
112
|
+
var values = [];
|
|
113
|
+
|
|
114
|
+
for (var i = 0; i < this.radioCount; i++){
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if (document.querySelector(`#S${i}`).checked) {
|
|
118
|
+
let value = document.querySelector(`#S${i}`);
|
|
119
|
+
console.log("VALUE IS " + value.value);
|
|
120
|
+
values.push(value.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
return values;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
toCode() {
|
|
130
|
+
/*let objString = JSON.stringify(
|
|
131
|
+
this.options,
|
|
132
|
+
(key, value) => (typeof key === "string" && key !== "" ? value : value),
|
|
133
|
+
4
|
|
134
|
+
);*/
|
|
135
|
+
|
|
136
|
+
// 155735 preventing problem, no removal
|
|
137
|
+
let objString = JSON.stringify(this.options, null, 4);
|
|
138
|
+
objString = objString.replace(/"(\w+)"(?=\s*:)/g, '$1');
|
|
139
|
+
return [`new RadioGroup().set(${objString})`];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
responsive(){
|
|
145
|
+
let query = window.matchMedia("(max-device-width: 415px)");
|
|
146
|
+
|
|
147
|
+
// window.matchMedia(query)
|
|
148
|
+
if (query.matches){
|
|
149
|
+
this.el.style.fontSize = "1.7em";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
render(div){
|
|
158
|
+
if (div){
|
|
159
|
+
document.querySelector(div).appendChild(this.el);
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
} else {
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
console.log("MULA");
|
|
170
|
+
// console.log(this.el.children[0]);
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
for (var i = 0; i < this.el.children.length; i++){
|
|
175
|
+
|
|
176
|
+
let card = this.el.children[i];
|
|
177
|
+
// console.log(card.toString());
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if (card.toString() === "[object HTMLInputElement]") {
|
|
183
|
+
card.addEventListener('change', () => {
|
|
184
|
+
if (card.checked) {
|
|
185
|
+
card.style.backgroundColor = this.options.tint ? this.options.tint : '#007BFF';
|
|
186
|
+
card.style.boxShadow = this.options.tint ?`0 0 0 2px ${this.options.tint} inset` : '0 0 0 2px #0056b3 inset';
|
|
187
|
+
|
|
188
|
+
// Reset styles for other radio buttons in the group
|
|
189
|
+
for (let j = 0; j < this.el.children.length; j++) {
|
|
190
|
+
const sibling = this.el.children[j];
|
|
191
|
+
// alert(this.options.multiple);
|
|
192
|
+
// Check if the sibling is an input element
|
|
193
|
+
if (sibling.tagName === 'INPUT' && sibling.type === 'radio') {
|
|
194
|
+
// Avoid resetting the current radio button
|
|
195
|
+
if (this.options.multiple === false && sibling !== card) {
|
|
196
|
+
sibling.style.backgroundColor = 'transparent';
|
|
197
|
+
sibling.style.boxShadow = 'none';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
card.style.backgroundColor = 'transparent';
|
|
203
|
+
card.style.boxShadow = 'none';
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
return this.el;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
window.RadioGroup = RadioGroup;
|
|
231
|
+
export { RadioGroup };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {Animator} from "../animator.js";
|
|
2
|
+
|
|
3
|
+
class Range {
|
|
4
|
+
constructor(obj) {
|
|
5
|
+
this.el = null;
|
|
6
|
+
this.minLabel = null;
|
|
7
|
+
this.maxLabel = null;
|
|
8
|
+
this.currentLabel = null;
|
|
9
|
+
// this.setup(obj);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
padding(val) {
|
|
13
|
+
this.el.style.padding = val;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toCode() {
|
|
18
|
+
const objString = JSON.stringify(this.options, null, 4);
|
|
19
|
+
return [`new Range().set(${objString})`];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
set(obj) {
|
|
23
|
+
this.options = obj;
|
|
24
|
+
// Create slider input
|
|
25
|
+
let slider = document.createElement("input");
|
|
26
|
+
slider.setAttribute("id", "slider");
|
|
27
|
+
slider.setAttribute("type", "range");
|
|
28
|
+
slider.setAttribute("min", obj.min);
|
|
29
|
+
slider.setAttribute("max", obj.max);
|
|
30
|
+
slider.setAttribute("value", obj.min);
|
|
31
|
+
|
|
32
|
+
slider.style.width = obj.width ?? "100%";
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if (!obj.plain){
|
|
38
|
+
// Default slider styling
|
|
39
|
+
slider.style.setProperty("-webkit-appearance", "none");
|
|
40
|
+
slider.style.appearance = "none";
|
|
41
|
+
slider.style.height = "9px";
|
|
42
|
+
slider.style.background = obj.style.trackColor ?? "orange";
|
|
43
|
+
slider.style.borderRadius = "5px";
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Create and append thumb styles
|
|
48
|
+
const thumbCSS = `
|
|
49
|
+
#slider::-webkit-slider-thumb {
|
|
50
|
+
-webkit-appearance: none;
|
|
51
|
+
appearance: none;
|
|
52
|
+
width: 25px;
|
|
53
|
+
height: 25px;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
background: ${obj.style.thumbColor ?? "4CAF50"};
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
const style = document.createElement('style');
|
|
60
|
+
style.appendChild(document.createTextNode(thumbCSS));
|
|
61
|
+
document.head.appendChild(style);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Create labels
|
|
65
|
+
let wrapper = document.createElement("div");
|
|
66
|
+
wrapper.style.display = "flex";
|
|
67
|
+
wrapper.style.flexDirection = "column";
|
|
68
|
+
wrapper.style.alignItems = "center";
|
|
69
|
+
wrapper.style.width = "100%";
|
|
70
|
+
|
|
71
|
+
let labelWrapper = document.createElement("div");
|
|
72
|
+
labelWrapper.style.display = "flex";
|
|
73
|
+
labelWrapper.style.justifyContent = "space-between";
|
|
74
|
+
// labelWrapper.style.width = "100%";
|
|
75
|
+
labelWrapper.style.width = obj.width ?? "100%";
|
|
76
|
+
|
|
77
|
+
this.minLabel = document.createElement("span");
|
|
78
|
+
this.minLabel.textContent = obj.min;
|
|
79
|
+
|
|
80
|
+
this.maxLabel = document.createElement("span");
|
|
81
|
+
this.maxLabel.textContent = obj.max;
|
|
82
|
+
|
|
83
|
+
this.currentLabel = document.createElement("span");
|
|
84
|
+
this.currentLabel.textContent = slider.value;
|
|
85
|
+
|
|
86
|
+
obj.font && (this.currentLabel.style.fontFamily = obj.font);
|
|
87
|
+
obj.font && (this.minLabel.style.fontFamily = obj.font);
|
|
88
|
+
obj.font && (this.maxLabel.style.fontFamily = obj.font);
|
|
89
|
+
|
|
90
|
+
if (!obj.plain){
|
|
91
|
+
labelWrapper.appendChild(this.minLabel);
|
|
92
|
+
labelWrapper.appendChild(this.currentLabel);
|
|
93
|
+
labelWrapper.appendChild(this.maxLabel);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Update current label on slider input
|
|
97
|
+
slider.addEventListener("input", () => {
|
|
98
|
+
this.currentLabel.textContent = slider.value;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Mobile-specific styles
|
|
102
|
+
let query = window.matchMedia("(max-device-width: 415px)");
|
|
103
|
+
if (query.matches) {
|
|
104
|
+
if (!obj.plain){
|
|
105
|
+
slider.style.height = "20px";
|
|
106
|
+
slider.style.background = obj.style.trackColor ?? "1abc9C";
|
|
107
|
+
slider.style.borderRadius = "10px";
|
|
108
|
+
slider.style.fontSize = "3rem";
|
|
109
|
+
slider.style.width = "80%";
|
|
110
|
+
|
|
111
|
+
const mobileThumbCSS = `
|
|
112
|
+
#slider::-webkit-slider-thumb {
|
|
113
|
+
-webkit-appearance: none;
|
|
114
|
+
appearance: none;
|
|
115
|
+
width: 25px;
|
|
116
|
+
height: 25px;
|
|
117
|
+
border-radius: 50%;
|
|
118
|
+
background: ${obj.style.thumbColor ?? "blue"};
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const mobileStyle = document.createElement('style');
|
|
124
|
+
mobileStyle.appendChild(document.createTextNode(mobileThumbCSS));
|
|
125
|
+
document.head.appendChild(mobileStyle);
|
|
126
|
+
} else {
|
|
127
|
+
slider.style.width = "80%";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
wrapper.appendChild(labelWrapper);
|
|
132
|
+
wrapper.appendChild(slider);
|
|
133
|
+
|
|
134
|
+
this.el = wrapper;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
value() {
|
|
139
|
+
return this.el.querySelector("#slider").value;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
render(div) {
|
|
143
|
+
if (div) {
|
|
144
|
+
document.querySelector(div).appendChild(this.el);
|
|
145
|
+
} else {
|
|
146
|
+
return this.el;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
window.Range = Range;
|
|
158
|
+
export { Range };
|
package/layout/free.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {Animator} from "./animator.js";
|
|
2
|
+
|
|
3
|
+
class Free extends Animator {
|
|
4
|
+
constructor(){
|
|
5
|
+
super();
|
|
6
|
+
this.res = document.createElement("div");
|
|
7
|
+
this.res.style.display = "grid";
|
|
8
|
+
this.attributes = {};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
set(obj){
|
|
12
|
+
this.options = obj;
|
|
13
|
+
this.attributes = obj;
|
|
14
|
+
this.templateCols = obj.templateCols;
|
|
15
|
+
// alert(this.templateCols);
|
|
16
|
+
|
|
17
|
+
if (obj.templateCols) { // condition wrong
|
|
18
|
+
this.res.style.gridTemplateColumns = `repeat(${obj.templateCols.cols}, 1fr)`;
|
|
19
|
+
this.res.style.gridTemplateRows = `repeat(${obj.templateCols.cols}, 1fr)`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
this.res.style.height = obj.height ? obj.height : "600px";
|
|
24
|
+
|
|
25
|
+
obj.positions && (this.storedPositions = obj.positions); //this.generateGridPositions(obj.position);
|
|
26
|
+
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// move this function into free class
|
|
32
|
+
generateGridPositions(attractions, rows = 30, cols = 50) {
|
|
33
|
+
const container = document.createElement("div");
|
|
34
|
+
container.classList.add("container");
|
|
35
|
+
container.style.display = "grid";
|
|
36
|
+
container.style.gridTemplateColumns = `repeat(${cols}, 1fr)`;
|
|
37
|
+
container.style.gridTemplateRows = `repeat(${rows}, 1fr)`;
|
|
38
|
+
container.style.width = "100%";
|
|
39
|
+
container.style.height = "100vh";
|
|
40
|
+
|
|
41
|
+
let defaultPositions = attractions.map((_, index) => ({
|
|
42
|
+
row: Math.floor(rows / 2) + index, // Slightly offset to avoid exact overlap
|
|
43
|
+
col: Math.floor(cols / 2) + index
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
// Function to compute resulting force vector for a specific element
|
|
47
|
+
function computeForceVector(targetIndex) {
|
|
48
|
+
let forceX = 0;
|
|
49
|
+
let forceY = 0;
|
|
50
|
+
|
|
51
|
+
attractions.forEach((attr, index) => {
|
|
52
|
+
const { weight, direction } = attr;
|
|
53
|
+
const targetPosition = defaultPositions[targetIndex];
|
|
54
|
+
const attractionPosition = defaultPositions[index];
|
|
55
|
+
|
|
56
|
+
// Calculate the distance between the target and the attraction
|
|
57
|
+
const dx = targetPosition.col - attractionPosition.col;
|
|
58
|
+
const dy = targetPosition.row - attractionPosition.row;
|
|
59
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
60
|
+
|
|
61
|
+
// Add a softening factor: make the force fall off gradually with distance
|
|
62
|
+
const scalingFactor = 1 / (distance + 1); // Smaller influence for greater distance
|
|
63
|
+
|
|
64
|
+
// Scale the force by the weight and the softening factor
|
|
65
|
+
const scaledWeight = weight * scalingFactor;
|
|
66
|
+
|
|
67
|
+
// Apply the force
|
|
68
|
+
switch (direction) {
|
|
69
|
+
case "L":
|
|
70
|
+
forceX -= scaledWeight;
|
|
71
|
+
break;
|
|
72
|
+
case "R":
|
|
73
|
+
forceX += scaledWeight;
|
|
74
|
+
break;
|
|
75
|
+
case "U":
|
|
76
|
+
forceY -= scaledWeight;
|
|
77
|
+
break;
|
|
78
|
+
case "B":
|
|
79
|
+
forceY += scaledWeight;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return { forceX, forceY };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
attractions.forEach((attr, index) => {
|
|
88
|
+
let { row, col } = defaultPositions[index];
|
|
89
|
+
|
|
90
|
+
// Compute the force vector for the current element
|
|
91
|
+
const { forceX, forceY } = computeForceVector(index);
|
|
92
|
+
|
|
93
|
+
// Apply the force to determine new position (apply moderate force)
|
|
94
|
+
col = Math.max(1, Math.min(cols, col + Math.round(forceX)));
|
|
95
|
+
row = Math.max(1, Math.min(rows, row + Math.round(forceY)));
|
|
96
|
+
|
|
97
|
+
console.log(this.items.map(el => el.id));
|
|
98
|
+
console.log(attr.attract.slice(1));
|
|
99
|
+
// alert("#" + attr.attract.slice(1));
|
|
100
|
+
const element = this.items.filter(el => el.id === attr.attract.slice(1))[0].render(); //Array(this.res.children).filter(el => el.getAttribute("id") === attr.attract.slice(1)); //this.res.querySelector("#" + attr.attract.slice(1));//document.createElement("div");
|
|
101
|
+
console.log(element);
|
|
102
|
+
|
|
103
|
+
// element.id = attr.attract.slice(1);
|
|
104
|
+
element.style.gridRowStart = row;
|
|
105
|
+
element.style.gridRowEnd = row + 3; // Example height of 3 grid cells
|
|
106
|
+
element.style.gridColumnStart = col;
|
|
107
|
+
element.style.gridColumnEnd = col + 5; // Example width of 5 grid cells
|
|
108
|
+
|
|
109
|
+
element.style.border = `3px solid #${Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0')}`;//[]
|
|
110
|
+
|
|
111
|
+
/*if (element.toString() === "[HTMLParagaphElement]"){
|
|
112
|
+
element.style.width = "fit-content";
|
|
113
|
+
}*/
|
|
114
|
+
|
|
115
|
+
// Optional: Add some content or styles for better visibility
|
|
116
|
+
// element.textContent = `${attr.attract.slice(1)}`
|
|
117
|
+
|
|
118
|
+
//\n(${forceX.toFixed(2)}, ${forceY.toFixed(2)})`;
|
|
119
|
+
element.style.display = "flex";
|
|
120
|
+
element.style.alignItems = "center";
|
|
121
|
+
element.style.justifyContent = "center";
|
|
122
|
+
element.style.fontWeight = "bold";
|
|
123
|
+
element.style.color = "white";
|
|
124
|
+
// alert(element)
|
|
125
|
+
this.res.appendChild(element);
|
|
126
|
+
|
|
127
|
+
// this.res.style.border = "3px solid #1abc9c";
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// document.body.appendChild(container);
|
|
131
|
+
console.log("ARAO");
|
|
132
|
+
console.log(this.res.children.length);
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
add(items){
|
|
138
|
+
this.items = items;
|
|
139
|
+
|
|
140
|
+
// Render each component in the grid container
|
|
141
|
+
for (const component of items) {
|
|
142
|
+
this.res.appendChild(component.render());
|
|
143
|
+
// alert("PP");
|
|
144
|
+
// console.log("ORAA");
|
|
145
|
+
// console.log(this.res.children.length);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// alert("PP");
|
|
149
|
+
// alert(this.res);
|
|
150
|
+
|
|
151
|
+
if (this.storedPositions){
|
|
152
|
+
this.generateGridPositions(this.storedPositions);
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
console.log("MORAA");
|
|
157
|
+
console.log(this.res.children.length);
|
|
158
|
+
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* toCode(){
|
|
163
|
+
let codeStr = `new Free()`;
|
|
164
|
+
|
|
165
|
+
// 16:01:09 09/11/24 What????
|
|
166
|
+
// Convert attributes to .set({...}) format if there are any attributes
|
|
167
|
+
if (Object.keys(this.attributes).length > 0) {
|
|
168
|
+
codeStr += `.set(${JSON.stringify(this.attributes, null, 2).replace(/"([^"]+)":/g, '$1:')})`;
|
|
169
|
+
|
|
170
|
+
// codeStr += `.set(${JSON.stringify(this.attributes, null, 2)})`;
|
|
171
|
+
} else {
|
|
172
|
+
codeStr += `.set({})`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
codeStr += `.add([\n`;
|
|
176
|
+
|
|
177
|
+
// Generate the code for each item and join with commas only between items
|
|
178
|
+
codeStr += this.items
|
|
179
|
+
.map(item => item.toCode().join("").trim()) // Trim any line breaks or whitespace around the item code
|
|
180
|
+
.join(",\n"); // Insert commas only between items
|
|
181
|
+
|
|
182
|
+
codeStr += `\n])`;
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
return codeStr;
|
|
186
|
+
}*/
|
|
187
|
+
|
|
188
|
+
toCode() {
|
|
189
|
+
if (this.excludeFromCodeTrue){
|
|
190
|
+
// this.code = ["new Text('').set({})"];
|
|
191
|
+
return [""];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const objString = JSON
|
|
195
|
+
.stringify(this.options, null, 4)
|
|
196
|
+
.replace(/"([^"]+)":/g, '$1:');
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
var codeStr = "";
|
|
200
|
+
codeStr += `.add([\n`;
|
|
201
|
+
|
|
202
|
+
// Generate the code for each item and join with commas only between items
|
|
203
|
+
codeStr += this.items
|
|
204
|
+
.map(item => item.toCode().join("").trim()) // Trim any line breaks or whitespace around the item code
|
|
205
|
+
.join(",\n"); // Insert commas only between items
|
|
206
|
+
|
|
207
|
+
codeStr += `\n])`;
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
return [`new Free().set(${objString})${codeStr}`];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
render(div){
|
|
214
|
+
|
|
215
|
+
// ARE THERE CHILDREN
|
|
216
|
+
console.log("CHILDREN IN RENDER");
|
|
217
|
+
console.log(this.res.children.length);
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
if (div){
|
|
221
|
+
document.querySelector(div).appendChild(this.res);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
// alert("PP");
|
|
228
|
+
// alert(this.res);
|
|
229
|
+
return this.res;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export { Free };
|