ziko 0.49.6 → 0.50.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/ziko.cjs +374 -363
- package/dist/ziko.js +686 -971
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +678 -953
- package/package.json +4 -1
- package/src/{reactivity → --reactivity-deprecated}/hooks/head/useFavIcon.js +4 -4
- package/src/{reactivity → --reactivity-deprecated}/hooks/head/useTitle.js +1 -1
- package/src/{reactivity → --reactivity-deprecated}/hooks/index.js +3 -3
- package/src/{reactivity → --reactivity-deprecated}/index.js +1 -1
- package/src/{use → --use-deprecated}/index.js +1 -1
- package/src/{use/use-event-emmiter.js → --use-deprecated/use-event-emmiter.js.txt} +3 -3
- package/src/__ziko__/__state__.js +1 -1
- package/src/app/ziko-app.js +6 -6
- package/src/events/binders/custom-event.js +11 -7
- package/src/events/binders/index.js +69 -13
- package/src/events/details-setter/index.js +2 -0
- package/src/events/details-setter/key.js +14 -0
- package/src/events/{binders → details-setter}/pointer.js +1 -15
- package/src/events/{__Events__.js → events-map/index.js} +7 -3
- package/src/events/index.js +1 -1
- package/src/events/types/__Shared__.d.ts +3 -3
- package/src/events/types/clipboard.d.ts +2 -2
- package/src/events/types/focus.d.ts +2 -2
- package/src/events/types/pointer.d.ts +2 -2
- package/src/events/{__ZikoEvent__.js → ziko-event.js} +17 -16
- package/src/hooks/index.js +10 -2
- package/src/hooks/use-event-emitter.js +68 -0
- package/src/hooks/use-favicon.js +59 -0
- package/src/hooks/{use-channel.js → use-ipc.js} +5 -22
- package/src/hooks/use-media-query.js +59 -0
- package/src/hooks/use-root.js +73 -0
- package/src/hooks/use-storage.js +73 -47
- package/src/hooks/use-thread.js +55 -0
- package/src/hooks/use-title.js +43 -0
- package/src/index.js +1 -1
- package/src/ui/__methods__/events.js +19 -5
- package/src/ui/constructors/UIElement.js +14 -12
- package/src/ui/constructors/UIElementCore.js +3 -136
- package/types/hooks/index.d.ts +9 -2
- package/types/hooks/use-Thread.d.ts +33 -0
- package/types/hooks/use-event-emitter.d.ts +46 -0
- package/types/hooks/use-favicon.d.ts +41 -0
- package/types/hooks/{use-channel.d.ts → use-ipc.d.ts} +2 -2
- package/types/hooks/use-media-query.d.ts +24 -0
- package/types/hooks/use-root.d.ts +15 -0
- package/types/hooks/use-storage.d.ts +47 -0
- package/types/hooks/use-title.d.ts +37 -0
- package/src/events/binders/click.js +0 -20
- package/src/events/binders/clipboard.js +0 -16
- package/src/events/binders/drag.js +0 -16
- package/src/events/binders/focus.js +0 -16
- package/src/events/binders/hash.js +0 -16
- package/src/events/binders/key.js +0 -27
- package/src/events/binders/mouse.js +0 -16
- package/src/events/binders/touch.js +0 -16
- package/src/events/binders/wheel.js +0 -16
- package/src/events/index.d.ts.txt +0 -3
- /package/src/{reactivity → --reactivity-deprecated}/events/Input.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/ZikoEvent.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/__note__ +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/custom-event.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/hash.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/media.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/mouse.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/swipe.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/touch.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/useSuccesifKeys.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useCssLink.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useLinearGradient.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useMediaQuery.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRadialGradient.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRoot.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useStyle.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useTheme.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/_useCssText.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useHead.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useMeta.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/todo.md +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/idea +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/attributes.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/children.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/intersection.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/mutation.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/resize.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js.txt +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.txt +0 -0
- /package/src/{use → --use-deprecated}/use-channel.js.txt +0 -0
- /package/src/{use → --use-deprecated}/use-favicon.js +0 -0
- /package/src/{use → --use-deprecated}/use-link.js +0 -0
- /package/src/{use → --use-deprecated}/use-meta.js +0 -0
- /package/src/{use → --use-deprecated}/use-root.js +0 -0
- /package/src/{use → --use-deprecated}/use-storage.js.txt +0 -0
- /package/src/{use → --use-deprecated}/use-thread.js +0 -0
- /package/src/{use → --use-deprecated}/use-title.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/click-away.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/index.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/swipe.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/view.js +0 -0
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Tue Dec 02 2025 16:28:22 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -1072,35 +1072,6 @@ class UINode {
|
|
|
1072
1072
|
|
|
1073
1073
|
// globalThis.node = (node) => new UINode(node);
|
|
1074
1074
|
|
|
1075
|
-
function parseQueryParams$1(queryString) {
|
|
1076
|
-
const params = {};
|
|
1077
|
-
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1078
|
-
const [key, value] = match.split('=');
|
|
1079
|
-
params[key] = value;
|
|
1080
|
-
});
|
|
1081
|
-
return params;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
function defineParamsGetter$1(target ){
|
|
1085
|
-
Object.defineProperties(target, {
|
|
1086
|
-
'QueryParams': {
|
|
1087
|
-
get: function() {
|
|
1088
|
-
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1089
|
-
},
|
|
1090
|
-
configurable: false,
|
|
1091
|
-
enumerable: true
|
|
1092
|
-
},
|
|
1093
|
-
'HashParams': {
|
|
1094
|
-
get: function() {
|
|
1095
|
-
const hash = globalThis.location.hash.substring(1);
|
|
1096
|
-
return hash.split("#");
|
|
1097
|
-
},
|
|
1098
|
-
configurable: false,
|
|
1099
|
-
enumerable: true
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
1075
|
class UIStore extends Array {
|
|
1105
1076
|
constructor(...args) {
|
|
1106
1077
|
super(...args);
|
|
@@ -1134,6 +1105,141 @@ class UIStore extends Array {
|
|
|
1134
1105
|
// create the singleton
|
|
1135
1106
|
const __UI__ = new UIStore();
|
|
1136
1107
|
|
|
1108
|
+
// __init__global__()
|
|
1109
|
+
class UIElementCore extends UINode{
|
|
1110
|
+
constructor(){
|
|
1111
|
+
super();
|
|
1112
|
+
}
|
|
1113
|
+
init(element, name, type, render){
|
|
1114
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1115
|
+
if(typeof element === "string") {
|
|
1116
|
+
switch(type){
|
|
1117
|
+
case "html" : {
|
|
1118
|
+
element = globalThis?.document?.createElement(element);
|
|
1119
|
+
// console.log('1')
|
|
1120
|
+
} break;
|
|
1121
|
+
case "svg" : {
|
|
1122
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1123
|
+
// console.log('2')
|
|
1124
|
+
} break;
|
|
1125
|
+
default : throw Error("Not supported")
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
else this.target = element?.parentElement;
|
|
1129
|
+
Object.assign(this.cache, {
|
|
1130
|
+
name,
|
|
1131
|
+
isInteractive : false,
|
|
1132
|
+
parent:null,
|
|
1133
|
+
isBody:false,
|
|
1134
|
+
isRoot:false,
|
|
1135
|
+
isHidden: false,
|
|
1136
|
+
isFrozzen:false,
|
|
1137
|
+
legacyParent : null,
|
|
1138
|
+
attributes: {},
|
|
1139
|
+
filters: {},
|
|
1140
|
+
temp:{}
|
|
1141
|
+
});
|
|
1142
|
+
this.events = {
|
|
1143
|
+
ptr:null,
|
|
1144
|
+
mouse:null,
|
|
1145
|
+
wheel:null,
|
|
1146
|
+
key:null,
|
|
1147
|
+
drag:null,
|
|
1148
|
+
drop:null,
|
|
1149
|
+
click:null,
|
|
1150
|
+
clipboard:null,
|
|
1151
|
+
focus:null,
|
|
1152
|
+
swipe:null,
|
|
1153
|
+
custom:null,
|
|
1154
|
+
};
|
|
1155
|
+
this.observer={
|
|
1156
|
+
resize:null,
|
|
1157
|
+
intersection:null
|
|
1158
|
+
};
|
|
1159
|
+
if(element) Object.assign(this.cache,{element});
|
|
1160
|
+
// useDefaultStyle && this.style({
|
|
1161
|
+
// position: "relative",
|
|
1162
|
+
// boxSizing:"border-box",
|
|
1163
|
+
// margin:0,
|
|
1164
|
+
// padding:0,
|
|
1165
|
+
// width : "auto",
|
|
1166
|
+
// height : "auto"
|
|
1167
|
+
// });
|
|
1168
|
+
this.items = new UIStore();
|
|
1169
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1170
|
+
element && render && this?.render?.();
|
|
1171
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1172
|
+
}
|
|
1173
|
+
get element(){
|
|
1174
|
+
return this.cache.element;
|
|
1175
|
+
}
|
|
1176
|
+
[Symbol.iterator]() {
|
|
1177
|
+
return this.items[Symbol.iterator]();
|
|
1178
|
+
}
|
|
1179
|
+
maintain() {
|
|
1180
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1181
|
+
Object.defineProperty(this, i, {
|
|
1182
|
+
value: this.items[i],
|
|
1183
|
+
writable: true,
|
|
1184
|
+
configurable: true,
|
|
1185
|
+
enumerable: false
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
isInteractive(){
|
|
1190
|
+
return this.cache.isInteractive;
|
|
1191
|
+
}
|
|
1192
|
+
isUIElement(){
|
|
1193
|
+
return true;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function register_to_class(target, ...mixins){
|
|
1198
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1199
|
+
}
|
|
1200
|
+
function _register_to_class_(target, mixin) {
|
|
1201
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1202
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1203
|
+
const desc = descriptors[key];
|
|
1204
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1205
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1206
|
+
} else if (typeof desc.value === 'function') {
|
|
1207
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1208
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function parseQueryParams$1(queryString) {
|
|
1215
|
+
const params = {};
|
|
1216
|
+
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1217
|
+
const [key, value] = match.split('=');
|
|
1218
|
+
params[key] = value;
|
|
1219
|
+
});
|
|
1220
|
+
return params;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
function defineParamsGetter$1(target ){
|
|
1224
|
+
Object.defineProperties(target, {
|
|
1225
|
+
'QueryParams': {
|
|
1226
|
+
get: function() {
|
|
1227
|
+
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1228
|
+
},
|
|
1229
|
+
configurable: false,
|
|
1230
|
+
enumerable: true
|
|
1231
|
+
},
|
|
1232
|
+
'HashParams': {
|
|
1233
|
+
get: function() {
|
|
1234
|
+
const hash = globalThis.location.hash.substring(1);
|
|
1235
|
+
return hash.split("#");
|
|
1236
|
+
},
|
|
1237
|
+
configurable: false,
|
|
1238
|
+
enumerable: true
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1137
1243
|
const __Config__ = {
|
|
1138
1244
|
default:{
|
|
1139
1245
|
target:null,
|
|
@@ -1177,37 +1283,29 @@ const __CACHE__ = {
|
|
|
1177
1283
|
}
|
|
1178
1284
|
};
|
|
1179
1285
|
|
|
1180
|
-
class
|
|
1181
|
-
// private fields
|
|
1286
|
+
class UseIPC {
|
|
1182
1287
|
#channel;
|
|
1183
1288
|
#eventData;
|
|
1184
1289
|
#handlers;
|
|
1185
1290
|
#uuid;
|
|
1186
1291
|
#subscribers;
|
|
1187
|
-
#currentRooms;
|
|
1188
|
-
|
|
1292
|
+
#currentRooms;
|
|
1189
1293
|
constructor(name = "") {
|
|
1190
1294
|
this.#channel = new BroadcastChannel(name);
|
|
1191
1295
|
this.#eventData = new Map();
|
|
1192
1296
|
this.#handlers = new Map(); // Map<event, Array<{fn, rooms}>>
|
|
1193
1297
|
this.#uuid = "ziko-channel:" + Random.string(10);
|
|
1194
1298
|
this.#subscribers = new Set([this.#uuid]);
|
|
1195
|
-
this.#currentRooms = new Set();
|
|
1196
|
-
|
|
1299
|
+
this.#currentRooms = new Set();
|
|
1197
1300
|
this.#channel.addEventListener("message", (e) => {
|
|
1198
1301
|
const { last_sent_event, userId, eventData, rooms } = e.data;
|
|
1199
|
-
|
|
1200
1302
|
if (userId === this.#uuid) return; // ignore own messages
|
|
1201
|
-
|
|
1202
1303
|
// broadcast if no rooms, else check intersection
|
|
1203
1304
|
if (rooms && rooms.length && !rooms.some(r => this.#currentRooms.has(r))) return;
|
|
1204
|
-
|
|
1205
1305
|
this.#subscribers.add(userId);
|
|
1206
1306
|
this.#eventData = new Map(eventData);
|
|
1207
|
-
|
|
1208
1307
|
const handlersList = this.#handlers.get(last_sent_event);
|
|
1209
1308
|
if (!handlersList) return;
|
|
1210
|
-
|
|
1211
1309
|
handlersList.forEach(({ fn, rooms: handlerRooms }) => {
|
|
1212
1310
|
// trigger if listener has no room filter, or intersects subscriber rooms
|
|
1213
1311
|
if (!handlerRooms || handlerRooms.length === 0 ||
|
|
@@ -1221,24 +1319,20 @@ class UseChannel {
|
|
|
1221
1319
|
emit(event, data, rooms) {
|
|
1222
1320
|
this.#eventData.set(event, data);
|
|
1223
1321
|
if(typeof rooms === 'string') rooms = [rooms];
|
|
1224
|
-
|
|
1225
1322
|
this.#channel.postMessage({
|
|
1226
1323
|
eventData: Array.from(this.#eventData.entries()),
|
|
1227
1324
|
last_sent_event: event,
|
|
1228
1325
|
userId: this.#uuid,
|
|
1229
1326
|
rooms: rooms && rooms.length ? rooms : undefined
|
|
1230
1327
|
});
|
|
1231
|
-
|
|
1232
1328
|
return this;
|
|
1233
1329
|
}
|
|
1234
|
-
|
|
1235
1330
|
on(event, handler = console.log, rooms) {
|
|
1236
1331
|
if (!this.#handlers.has(event)) this.#handlers.set(event, []);
|
|
1237
1332
|
if(typeof rooms === 'string') rooms = [rooms];
|
|
1238
1333
|
this.#handlers.get(event).push({ fn: handler, rooms });
|
|
1239
1334
|
return this;
|
|
1240
1335
|
}
|
|
1241
|
-
|
|
1242
1336
|
off(event, handler) {
|
|
1243
1337
|
if (!this.#handlers.has(event)) return this;
|
|
1244
1338
|
this.#handlers.set(
|
|
@@ -1247,7 +1341,6 @@ class UseChannel {
|
|
|
1247
1341
|
);
|
|
1248
1342
|
return this;
|
|
1249
1343
|
}
|
|
1250
|
-
|
|
1251
1344
|
once(event, handler, rooms) {
|
|
1252
1345
|
const wrapper = (data) => {
|
|
1253
1346
|
handler(data);
|
|
@@ -1256,368 +1349,148 @@ class UseChannel {
|
|
|
1256
1349
|
this.on(event, wrapper, rooms);
|
|
1257
1350
|
return this;
|
|
1258
1351
|
}
|
|
1259
|
-
|
|
1260
1352
|
join(...rooms) {
|
|
1261
1353
|
rooms.forEach(r => this.#currentRooms.add(r));
|
|
1262
1354
|
return this;
|
|
1263
1355
|
}
|
|
1264
|
-
|
|
1265
1356
|
leave(...rooms) {
|
|
1266
1357
|
if (!rooms.length) this.#currentRooms.clear();
|
|
1267
1358
|
else rooms.forEach(r => this.#currentRooms.delete(r));
|
|
1268
1359
|
return this;
|
|
1269
1360
|
}
|
|
1270
|
-
|
|
1271
1361
|
close() {
|
|
1272
1362
|
this.#channel.close();
|
|
1273
1363
|
return this;
|
|
1274
1364
|
}
|
|
1275
|
-
|
|
1276
1365
|
}
|
|
1277
1366
|
|
|
1278
|
-
const
|
|
1367
|
+
const useIPC = (name) => new UseIPC(name);
|
|
1279
1368
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
this.cache={
|
|
1369
|
+
class UseStorage {
|
|
1370
|
+
constructor(storage, globalKey, initialValue, use_channel = true) {
|
|
1371
|
+
this.cache = {
|
|
1284
1372
|
storage,
|
|
1285
1373
|
globalKey,
|
|
1286
|
-
channel:
|
|
1287
|
-
oldItemKeys:new Set()
|
|
1374
|
+
channel: use_channel ? useIPC(`Ziko:useStorage-${globalKey}`) : null,
|
|
1375
|
+
oldItemKeys: new Set()
|
|
1288
1376
|
};
|
|
1289
|
-
|
|
1290
|
-
this.#
|
|
1377
|
+
|
|
1378
|
+
this.#init(initialValue, use_channel);
|
|
1291
1379
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1380
|
+
|
|
1381
|
+
get items() {
|
|
1382
|
+
const raw = this.cache.storage.getItem(this.cache.globalKey);
|
|
1383
|
+
if (!raw) return {};
|
|
1384
|
+
try {
|
|
1385
|
+
return JSON.parse(raw);
|
|
1386
|
+
} catch {
|
|
1387
|
+
return {};
|
|
1388
|
+
}
|
|
1294
1389
|
}
|
|
1390
|
+
|
|
1295
1391
|
#maintain() {
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
if(!initialValue)return;
|
|
1302
|
-
if(this.cache.storage[this.cache.globalKey]){
|
|
1303
|
-
Object.keys(this.items).forEach(key=>this.cache.oldItemKeys.add(key));
|
|
1304
|
-
// console.group("Ziko:useStorage")
|
|
1305
|
-
// console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`);
|
|
1306
|
-
// console.info(`%cWe'll keep the existing data.`,"background-color:#2222dd; color:gold;");
|
|
1307
|
-
// console.group("")
|
|
1392
|
+
const items = this.items;
|
|
1393
|
+
this.cache.oldItemKeys.forEach(k => delete this[k]);
|
|
1394
|
+
for (const key in items) {
|
|
1395
|
+
this[key] = items[key];
|
|
1396
|
+
this.cache.oldItemKeys.add(key);
|
|
1308
1397
|
}
|
|
1309
|
-
else this.set(initialValue);
|
|
1310
1398
|
}
|
|
1311
|
-
|
|
1312
|
-
this.cache.
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
return this
|
|
1317
|
-
}
|
|
1318
|
-
add(data){
|
|
1319
|
-
const db={
|
|
1320
|
-
...this.items,
|
|
1321
|
-
...data
|
|
1322
|
-
};
|
|
1323
|
-
this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(db));
|
|
1324
|
-
this.#maintain();
|
|
1325
|
-
return this;
|
|
1326
|
-
}
|
|
1327
|
-
remove(...keys){
|
|
1328
|
-
const db={...this.items};
|
|
1329
|
-
for(let i=0;i<keys.length;i++){
|
|
1330
|
-
delete db[keys[i]];
|
|
1331
|
-
delete this[keys[i]];
|
|
1399
|
+
#init(initialValue, use_channel) {
|
|
1400
|
+
if (use_channel && this.cache.channel) this.cache.channel.on("Ziko-Storage-Updated", () => this.#maintain());
|
|
1401
|
+
if (!initialValue) {
|
|
1402
|
+
this.#maintain();
|
|
1403
|
+
return;
|
|
1332
1404
|
}
|
|
1333
|
-
this.
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1405
|
+
if (this.cache.storage.getItem(this.cache.globalKey)) {
|
|
1406
|
+
const existing = this.items;
|
|
1407
|
+
Object.keys(existing).forEach(k => this.cache.oldItemKeys.add(k));
|
|
1408
|
+
this.#maintain();
|
|
1409
|
+
}
|
|
1410
|
+
else this.set(initialValue);
|
|
1338
1411
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1412
|
+
|
|
1413
|
+
set(data) {
|
|
1414
|
+
this.cache.storage.setItem(this.cache.globalKey, JSON.stringify(data));
|
|
1415
|
+
if (this.cache.channel) this.cache.channel.emit("Ziko-Storage-Updated", data);
|
|
1341
1416
|
this.#maintain();
|
|
1342
1417
|
return this;
|
|
1343
1418
|
}
|
|
1344
1419
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
this
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
defineParamsGetter$1(__Ziko__);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
__init__global__();
|
|
1384
|
-
class UIElementCore extends UINode{
|
|
1385
|
-
constructor(){
|
|
1386
|
-
super();
|
|
1387
|
-
}
|
|
1388
|
-
init(element, name, type, render){
|
|
1389
|
-
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1390
|
-
if(typeof element === "string") {
|
|
1391
|
-
switch(type){
|
|
1392
|
-
case "html" : {
|
|
1393
|
-
element = globalThis?.document?.createElement(element);
|
|
1394
|
-
// console.log('1')
|
|
1395
|
-
} break;
|
|
1396
|
-
case "svg" : {
|
|
1397
|
-
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1398
|
-
// console.log('2')
|
|
1399
|
-
} break;
|
|
1400
|
-
default : throw Error("Not supported")
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
else this.target = element?.parentElement;
|
|
1404
|
-
Object.assign(this.cache, {
|
|
1405
|
-
name,
|
|
1406
|
-
isInteractive : false,
|
|
1407
|
-
parent:null,
|
|
1408
|
-
isBody:false,
|
|
1409
|
-
isRoot:false,
|
|
1410
|
-
isHidden: false,
|
|
1411
|
-
isFrozzen:false,
|
|
1412
|
-
legacyParent : null,
|
|
1413
|
-
attributes: {},
|
|
1414
|
-
filters: {},
|
|
1415
|
-
temp:{}
|
|
1416
|
-
});
|
|
1417
|
-
this.events = {
|
|
1418
|
-
ptr:null,
|
|
1419
|
-
mouse:null,
|
|
1420
|
-
wheel:null,
|
|
1421
|
-
key:null,
|
|
1422
|
-
drag:null,
|
|
1423
|
-
drop:null,
|
|
1424
|
-
click:null,
|
|
1425
|
-
clipboard:null,
|
|
1426
|
-
focus:null,
|
|
1427
|
-
swipe:null,
|
|
1428
|
-
custom:null,
|
|
1429
|
-
};
|
|
1430
|
-
this.observer={
|
|
1431
|
-
resize:null,
|
|
1432
|
-
intersection:null
|
|
1433
|
-
};
|
|
1434
|
-
if(element) Object.assign(this.cache,{element});
|
|
1435
|
-
// useDefaultStyle && this.style({
|
|
1436
|
-
// position: "relative",
|
|
1437
|
-
// boxSizing:"border-box",
|
|
1438
|
-
// margin:0,
|
|
1439
|
-
// padding:0,
|
|
1440
|
-
// width : "auto",
|
|
1441
|
-
// height : "auto"
|
|
1442
|
-
// });
|
|
1443
|
-
this.items = new UIStore();
|
|
1444
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1445
|
-
element && render && this?.render?.();
|
|
1446
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
1447
|
-
}
|
|
1448
|
-
get element(){
|
|
1449
|
-
return this.cache.element;
|
|
1450
|
-
}
|
|
1451
|
-
[Symbol.iterator]() {
|
|
1452
|
-
return this.items[Symbol.iterator]();
|
|
1453
|
-
}
|
|
1454
|
-
maintain() {
|
|
1455
|
-
for (let i = 0; i < this.items.length; i++) {
|
|
1456
|
-
Object.defineProperty(this, i, {
|
|
1457
|
-
value: this.items[i],
|
|
1458
|
-
writable: true,
|
|
1459
|
-
configurable: true,
|
|
1460
|
-
enumerable: false
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
isInteractive(){
|
|
1465
|
-
return this.cache.isInteractive;
|
|
1466
|
-
}
|
|
1467
|
-
isUIElement(){
|
|
1468
|
-
return true;
|
|
1469
|
-
}
|
|
1470
|
-
// get st(){
|
|
1471
|
-
// return this.cache.style;
|
|
1472
|
-
// }
|
|
1473
|
-
// get attr(){
|
|
1474
|
-
// return this.cache.attributes;
|
|
1475
|
-
// }
|
|
1476
|
-
// get evt(){
|
|
1477
|
-
// return this.events;
|
|
1478
|
-
// }
|
|
1479
|
-
// get html(){
|
|
1480
|
-
// return this.element.innerHTML;
|
|
1481
|
-
// }
|
|
1482
|
-
// get text(){
|
|
1483
|
-
// return this.element.textContent;
|
|
1484
|
-
// }
|
|
1485
|
-
// get isBody(){
|
|
1486
|
-
// return this.element === globalThis?.document.body;
|
|
1487
|
-
// }
|
|
1488
|
-
// get parent(){
|
|
1489
|
-
// return this.cache.parent;
|
|
1490
|
-
// }
|
|
1491
|
-
// get width(){
|
|
1492
|
-
// return this.element.getBoundingClientRect().width;
|
|
1493
|
-
// }
|
|
1494
|
-
// get height(){
|
|
1495
|
-
// return this.element.getBoundingClientRect().height;
|
|
1496
|
-
// }
|
|
1497
|
-
// get top(){
|
|
1498
|
-
// return this.element.getBoundingClientRect().top;
|
|
1499
|
-
// }
|
|
1500
|
-
// get right(){
|
|
1501
|
-
// return this.element.getBoundingClientRect().right;
|
|
1502
|
-
// }
|
|
1503
|
-
// get bottom(){
|
|
1504
|
-
// return this.element.getBoundingClientRect().bottom;
|
|
1505
|
-
// }
|
|
1506
|
-
// get left(){
|
|
1507
|
-
// return this.element.getBoundingClientRect().left;
|
|
1508
|
-
// }
|
|
1509
|
-
// clone(render=false) {
|
|
1510
|
-
// // UI.__proto__=this.__proto__;
|
|
1511
|
-
// // if(this.items.length){
|
|
1512
|
-
// // const items = [...this.items].map(n=>n.clone());
|
|
1513
|
-
// // UI.append(...items);
|
|
1514
|
-
// // }
|
|
1515
|
-
// // else UI.element=this.element.cloneNode(true);
|
|
1516
|
-
// // return UI.mount(render);
|
|
1517
|
-
// }
|
|
1518
|
-
|
|
1519
|
-
// freeze(freeze){
|
|
1520
|
-
// this.cache.isFrozzen=freeze;
|
|
1521
|
-
// return this;
|
|
1522
|
-
// }
|
|
1523
|
-
// setTarget(tg) {
|
|
1524
|
-
// if(this.isBody) return ;
|
|
1525
|
-
// if (tg?.isUIElement) tg = tg.element;
|
|
1526
|
-
// this.unmount();
|
|
1527
|
-
// this.target = tg;
|
|
1528
|
-
// this.mount();
|
|
1529
|
-
// return this;
|
|
1530
|
-
// }
|
|
1531
|
-
// describe(label){
|
|
1532
|
-
// if(label)this.setAttr("aria-label",label)
|
|
1533
|
-
// }
|
|
1534
|
-
// get children() {
|
|
1535
|
-
// return [...this.element.children];
|
|
1536
|
-
// }
|
|
1537
|
-
// get cloneElement() {
|
|
1538
|
-
// return this.element.cloneNode(true);
|
|
1539
|
-
// }
|
|
1540
|
-
// setClasses(...value) {
|
|
1541
|
-
// this.setAttr("class", value.join(" "));
|
|
1542
|
-
// return this;
|
|
1543
|
-
// }
|
|
1544
|
-
// get classes(){
|
|
1545
|
-
// const classes=this.element.getAttribute("class");
|
|
1546
|
-
// return classes===null?[]:classes.split(" ");
|
|
1547
|
-
// }
|
|
1548
|
-
// addClass() {
|
|
1549
|
-
// /*this.setAttr("class", value);
|
|
1550
|
-
// return this;*/
|
|
1551
|
-
// }
|
|
1552
|
-
// setId(id) {
|
|
1553
|
-
// this.setAttr("id", id);
|
|
1554
|
-
// return this;
|
|
1555
|
-
// }
|
|
1556
|
-
// get id() {
|
|
1557
|
-
// return this.element.getAttribute("id");
|
|
1558
|
-
// }
|
|
1559
|
-
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1560
|
-
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1561
|
-
// this.events.swipe.onSwipe(...callbacks);
|
|
1562
|
-
// return this;
|
|
1563
|
-
// }
|
|
1564
|
-
// To Fix
|
|
1565
|
-
// onKeysDown({keys=[],callback}={}){
|
|
1566
|
-
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1567
|
-
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1568
|
-
// return this;
|
|
1569
|
-
// }
|
|
1570
|
-
// onSelect(...callbacks){
|
|
1571
|
-
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1572
|
-
// this.events.clipboard.onSelect(...callbacks);
|
|
1573
|
-
// return this;
|
|
1574
|
-
// }
|
|
1575
|
-
// on(event_name,...callbacks){
|
|
1576
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1577
|
-
// this.events.custom.on(event_name,...callbacks);
|
|
1578
|
-
// return this;
|
|
1579
|
-
// }
|
|
1580
|
-
// emit(event_name,detail={}){
|
|
1581
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1582
|
-
// this.events.custom.emit(event_name,detail);
|
|
1583
|
-
// return this;
|
|
1584
|
-
// }
|
|
1585
|
-
// watchAttr(callback){
|
|
1586
|
-
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1587
|
-
// return this;
|
|
1588
|
-
// }
|
|
1589
|
-
// watchChildren(callback){
|
|
1590
|
-
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1591
|
-
// return this;
|
|
1592
|
-
// }
|
|
1593
|
-
// watchSize(callback){
|
|
1594
|
-
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1595
|
-
// this.observer.resize.start();
|
|
1596
|
-
// return this;
|
|
1597
|
-
// }
|
|
1598
|
-
// watchIntersection(callback,config){
|
|
1599
|
-
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1600
|
-
// this.observer.intersection.start();
|
|
1601
|
-
// return this;
|
|
1602
|
-
// }
|
|
1420
|
+
add(data) {
|
|
1421
|
+
this.set({
|
|
1422
|
+
...this.items,
|
|
1423
|
+
...data
|
|
1424
|
+
});
|
|
1425
|
+
return this;
|
|
1426
|
+
}
|
|
1427
|
+
remove(...keys) {
|
|
1428
|
+
const items = { ...this.items };
|
|
1429
|
+
keys.forEach(key => {
|
|
1430
|
+
delete items[key];
|
|
1431
|
+
delete this[key];
|
|
1432
|
+
this.cache.oldItemKeys.delete(key);
|
|
1433
|
+
});
|
|
1434
|
+
this.set(items);
|
|
1435
|
+
return this;
|
|
1436
|
+
}
|
|
1437
|
+
get(key) {
|
|
1438
|
+
return this.items[key];
|
|
1439
|
+
}
|
|
1440
|
+
clear() {
|
|
1441
|
+
this.cache.storage.removeItem(this.cache.globalKey);
|
|
1442
|
+
this.cache.oldItemKeys.forEach(k => delete this[k]);
|
|
1443
|
+
this.cache.oldItemKeys.clear();
|
|
1444
|
+
this.#maintain();
|
|
1445
|
+
return this;
|
|
1446
|
+
}
|
|
1447
|
+
onStorageUpdated(callback) {
|
|
1448
|
+
if (this.cache.channel) {
|
|
1449
|
+
this.cache.channel.on("Ziko-Storage-Updated", callback);
|
|
1450
|
+
}
|
|
1451
|
+
return this;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1603
1454
|
|
|
1604
|
-
|
|
1455
|
+
// factory functions
|
|
1456
|
+
const useLocaleStorage = (key, initialValue, use_channel = true) =>
|
|
1457
|
+
new UseStorage(localStorage, key, initialValue, use_channel);
|
|
1458
|
+
|
|
1459
|
+
const useSessionStorage = (key, initialValue, use_channel = true) =>
|
|
1460
|
+
new UseStorage(sessionStorage, key, initialValue, use_channel);
|
|
1605
1461
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1462
|
+
var __State__ = {
|
|
1463
|
+
store : new Map(),
|
|
1464
|
+
index : 0,
|
|
1465
|
+
session_storage : null,
|
|
1466
|
+
register: function(state){
|
|
1467
|
+
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1468
|
+
if(!this.session) this.session_storage = useSessionStorage('ziko-state', {});
|
|
1469
|
+
const savedValue = this.session_storage.get(this.index);
|
|
1470
|
+
if(!savedValue) this.session_storage.add({[this.index] : state.value});
|
|
1471
|
+
else state.value = savedValue;
|
|
1472
|
+
}
|
|
1473
|
+
this.store.set(this.index++, state);
|
|
1474
|
+
},
|
|
1475
|
+
update: function(index, value){
|
|
1476
|
+
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1477
|
+
this.session_storage.add({[index] : value});
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
function __init__global__(){
|
|
1484
|
+
if ( !globalThis?.__Ziko__ ){
|
|
1485
|
+
globalThis.__Ziko__ = {
|
|
1486
|
+
__UI__,
|
|
1487
|
+
__HYDRATION__,
|
|
1488
|
+
__State__,
|
|
1489
|
+
__Config__,
|
|
1490
|
+
__CACHE__,
|
|
1491
|
+
};
|
|
1492
|
+
defineParamsGetter$1(__Ziko__);
|
|
1619
1493
|
}
|
|
1620
|
-
}
|
|
1621
1494
|
}
|
|
1622
1495
|
|
|
1623
1496
|
if(!globalThis.__Ziko__) __init__global__();
|
|
@@ -1880,7 +1753,11 @@ var DomMethods = /*#__PURE__*/Object.freeze({
|
|
|
1880
1753
|
unrenderAfter: unrenderAfter
|
|
1881
1754
|
});
|
|
1882
1755
|
|
|
1883
|
-
const
|
|
1756
|
+
const EventsMap = {
|
|
1757
|
+
'Custom' : [
|
|
1758
|
+
'emit',
|
|
1759
|
+
'on'
|
|
1760
|
+
],
|
|
1884
1761
|
'Click' : [
|
|
1885
1762
|
'Click',
|
|
1886
1763
|
'DblClick',
|
|
@@ -1940,21 +1817,7 @@ const getEvent=(event = "")=>{
|
|
|
1940
1817
|
return event.toLowerCase()
|
|
1941
1818
|
};
|
|
1942
1819
|
|
|
1943
|
-
|
|
1944
|
-
this.cache.currentEvent = event_name;
|
|
1945
|
-
this.cache.event = e;
|
|
1946
|
-
details_setter?.call(this);
|
|
1947
|
-
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1948
|
-
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1949
|
-
// else customizer?.call(null, this)
|
|
1950
|
-
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1951
|
-
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1952
|
-
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1953
|
-
|
|
1954
|
-
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1955
|
-
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1956
|
-
}
|
|
1957
|
-
class __ZikoEvent__ {
|
|
1820
|
+
class ZikoEvent {
|
|
1958
1821
|
constructor(target = null, Events = [], details_setter, customizer){
|
|
1959
1822
|
this.target = target;
|
|
1960
1823
|
this.cache = {
|
|
@@ -2098,92 +1961,24 @@ class __ZikoEvent__ {
|
|
|
2098
1961
|
|
|
2099
1962
|
return this;
|
|
2100
1963
|
}
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
2104
|
-
class ZikoEventClick extends __ZikoEvent__{
|
|
2105
|
-
constructor(target, customizer){
|
|
2106
|
-
super(target, Events.Click, details_setter$a, customizer);
|
|
2107
|
-
// register_click_away_event(target.element)
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
function details_setter$a(){
|
|
2111
|
-
if(this.currentEvent==="click") this.dx = 0;
|
|
2112
|
-
else this.dx = 1;
|
|
2113
|
-
// console.log(this.currentEvent)
|
|
2114
|
-
}
|
|
2115
|
-
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
2116
|
-
|
|
2117
|
-
class ZikoEventClipboard extends __ZikoEvent__{
|
|
2118
|
-
constructor(target, customizer){
|
|
2119
|
-
super(target, Events.Clipboard, details_setter$9, customizer);
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
function details_setter$9(){
|
|
2123
|
-
|
|
2124
|
-
}
|
|
2125
|
-
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
2126
|
-
|
|
2127
|
-
class ZikoEventCustom extends __ZikoEvent__{
|
|
2128
|
-
constructor(target, events, customizer){
|
|
2129
|
-
super(target, events, details_setter$8, customizer);
|
|
2130
|
-
}
|
|
2131
|
-
_register_events(events){
|
|
2132
|
-
super._register_events(events, null, null, false);
|
|
2133
|
-
return this;
|
|
2134
|
-
}
|
|
2135
|
-
emit(event_name, details = {}){
|
|
2136
|
-
const event=new Event(event_name);
|
|
2137
|
-
this.targetElement.dispatchEvent(event);
|
|
2138
|
-
return this;
|
|
2139
|
-
}
|
|
2140
|
-
on(event_name, ...callbacks){
|
|
2141
|
-
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2142
|
-
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2143
|
-
return this;
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
function details_setter$8(){
|
|
2147
|
-
|
|
2148
|
-
}
|
|
2149
|
-
const bindCustomEvent = (target, events, customizer) => new ZikoEventCustom(target, events, customizer);
|
|
2150
|
-
|
|
2151
|
-
class ZikoEventDrag extends __ZikoEvent__{
|
|
2152
|
-
constructor(target, customizer){
|
|
2153
|
-
super(target, Events.Drag, details_setter$7, customizer);
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
function details_setter$7(){
|
|
2157
|
-
|
|
2158
|
-
}
|
|
2159
|
-
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
2160
|
-
|
|
2161
|
-
class ZikoEventFocus extends __ZikoEvent__{
|
|
2162
|
-
constructor(target, customizer){
|
|
2163
|
-
super(target, Events.Focus, details_setter$6, customizer);
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
function details_setter$6(){
|
|
2167
|
-
|
|
2168
1964
|
}
|
|
2169
|
-
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
2170
|
-
|
|
2171
|
-
class ZikoEventHash extends __ZikoEvent__{
|
|
2172
|
-
constructor(target, customizer){
|
|
2173
|
-
super(target, Events.Hash, details_setter$5, customizer);
|
|
2174
|
-
}
|
|
2175
|
-
}
|
|
2176
|
-
function details_setter$5(){
|
|
2177
1965
|
|
|
2178
|
-
|
|
2179
|
-
|
|
1966
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
1967
|
+
this.cache.currentEvent = event_name;
|
|
1968
|
+
this.cache.event = e;
|
|
1969
|
+
details_setter?.call(this);
|
|
1970
|
+
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1971
|
+
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1972
|
+
// else customizer?.call(null, this)
|
|
1973
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1974
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1975
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1976
|
+
|
|
1977
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1978
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1979
|
+
}
|
|
2180
1980
|
|
|
2181
|
-
|
|
2182
|
-
constructor(target, customizer){
|
|
2183
|
-
super(target, Events.Key, details_setter$4, customizer);
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
function details_setter$4(){
|
|
1981
|
+
function key_details_setter(){
|
|
2187
1982
|
switch(this.currentEvent){
|
|
2188
1983
|
case "keydown" : {
|
|
2189
1984
|
this.kd = this.event.key;
|
|
@@ -2196,26 +1991,9 @@ function details_setter$4(){
|
|
|
2196
1991
|
} break;
|
|
2197
1992
|
|
|
2198
1993
|
}
|
|
2199
|
-
}
|
|
2200
|
-
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
2201
|
-
|
|
2202
|
-
class ZikoEventMouse extends __ZikoEvent__{
|
|
2203
|
-
constructor(target, customizer){
|
|
2204
|
-
super(target, Events.Mouse, details_setter$3, customizer);
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
function details_setter$3(){
|
|
2208
|
-
|
|
2209
|
-
}
|
|
2210
|
-
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1994
|
+
}
|
|
2211
1995
|
|
|
2212
|
-
|
|
2213
|
-
constructor(target, customizer){
|
|
2214
|
-
super(target, Events.Ptr, details_setter$2, customizer);
|
|
2215
|
-
this.isDown = false;
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
function details_setter$2(){
|
|
1996
|
+
function ptr_details_setter(){
|
|
2219
1997
|
switch(this.currentEvent){
|
|
2220
1998
|
case "pointerdown" : {
|
|
2221
1999
|
this.dx = parseInt(this.event.offsetX);
|
|
@@ -2247,28 +2025,135 @@ function details_setter$2(){
|
|
|
2247
2025
|
// if(this.currentEvent==="click") this.dx = 0
|
|
2248
2026
|
// else this.dx = 1
|
|
2249
2027
|
// console.log(this.currentEvent)
|
|
2250
|
-
}
|
|
2251
|
-
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
2028
|
+
}
|
|
2252
2029
|
|
|
2253
|
-
class
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2030
|
+
class ClickAwayEvent extends Event {
|
|
2031
|
+
constructor(originalEvent, targetElement) {
|
|
2032
|
+
super("clickaway", { bubbles: true, cancelable: true });
|
|
2033
|
+
this.originalEvent = originalEvent;
|
|
2034
|
+
this.targetElement = targetElement;
|
|
2035
|
+
}
|
|
2257
2036
|
}
|
|
2258
|
-
function details_setter$1(){
|
|
2259
2037
|
|
|
2038
|
+
function register_click_away_event(element) {
|
|
2039
|
+
console.log(element);
|
|
2040
|
+
function handler(e) {
|
|
2041
|
+
if (!element.contains(e.target)) {
|
|
2042
|
+
const clickAwayEvent = new ClickAwayEvent(e, element);
|
|
2043
|
+
element.dispatchEvent(clickAwayEvent);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
globalThis?.document?.addEventListener("click", handler);
|
|
2048
|
+
|
|
2049
|
+
return () => globalThis?.document?.removeEventListener("click", handler);
|
|
2050
|
+
|
|
2260
2051
|
}
|
|
2261
|
-
|
|
2052
|
+
|
|
2053
|
+
// // Example usage
|
|
2054
|
+
// const box = document.querySelector("#my-box");
|
|
2055
|
+
|
|
2056
|
+
// const stop = listenClickAway(box);
|
|
2057
|
+
|
|
2058
|
+
// box.addEventListener("clickaway", (e) => {
|
|
2059
|
+
// console.log("Clicked outside box!", e);
|
|
2060
|
+
// });
|
|
2061
|
+
|
|
2062
|
+
// // later, you can stop listening:
|
|
2063
|
+
// // stop();
|
|
2064
|
+
|
|
2065
|
+
const bind_click_event = (target, customizer) => {
|
|
2066
|
+
register_click_away_event(target.element);
|
|
2067
|
+
return new ZikoEvent(
|
|
2068
|
+
target,
|
|
2069
|
+
EventsMap.Click,
|
|
2070
|
+
null,
|
|
2071
|
+
customizer
|
|
2072
|
+
);
|
|
2073
|
+
};
|
|
2074
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEvent(
|
|
2075
|
+
target,
|
|
2076
|
+
EventsMap.Clipboard,
|
|
2077
|
+
null,
|
|
2078
|
+
customizer
|
|
2079
|
+
);
|
|
2080
|
+
const bind_drag_event = (target, customizer) => new ZikoEvent(
|
|
2081
|
+
target,
|
|
2082
|
+
EventsMap.Drag,
|
|
2083
|
+
null,
|
|
2084
|
+
customizer
|
|
2085
|
+
);
|
|
2086
|
+
const bind_focus_event = (target, customizer) => new ZikoEvent(
|
|
2087
|
+
target,
|
|
2088
|
+
EventsMap.Focus,
|
|
2089
|
+
null,
|
|
2090
|
+
customizer
|
|
2091
|
+
);
|
|
2092
|
+
const bind_key_event = (target, customizer) => new ZikoEvent(
|
|
2093
|
+
target,
|
|
2094
|
+
EventsMap.Key,
|
|
2095
|
+
key_details_setter,
|
|
2096
|
+
customizer
|
|
2097
|
+
);
|
|
2098
|
+
const bind_mouse_event = (target, customizer) => new ZikoEvent(
|
|
2099
|
+
target,
|
|
2100
|
+
EventsMap.Mouse,
|
|
2101
|
+
null,
|
|
2102
|
+
customizer
|
|
2103
|
+
);
|
|
2104
|
+
const bind_pointer_event = (target, customizer) => new ZikoEvent(
|
|
2105
|
+
target,
|
|
2106
|
+
EventsMap.Ptr,
|
|
2107
|
+
ptr_details_setter,
|
|
2108
|
+
customizer
|
|
2109
|
+
);
|
|
2110
|
+
const bind_touch_event = (target, customizer) => new ZikoEvent(
|
|
2111
|
+
target,
|
|
2112
|
+
EventsMap.Touch,
|
|
2113
|
+
null,
|
|
2114
|
+
customizer
|
|
2115
|
+
);
|
|
2116
|
+
const bind_wheel_event = (target, customizer) => new ZikoEvent(
|
|
2117
|
+
target,
|
|
2118
|
+
EventsMap.Wheel,
|
|
2119
|
+
null,
|
|
2120
|
+
customizer
|
|
2121
|
+
);
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
// function details_setter(){
|
|
2125
|
+
// if(this.currentEvent==="click") this.dx = 0
|
|
2126
|
+
// else this.dx = 1
|
|
2127
|
+
// // console.log(this.currentEvent)
|
|
2128
|
+
// }
|
|
2262
2129
|
|
|
2263
|
-
class
|
|
2264
|
-
constructor(target, customizer){
|
|
2265
|
-
super(target,
|
|
2130
|
+
class ZikoCustomEvent extends ZikoEvent{
|
|
2131
|
+
constructor(target, events, customizer){
|
|
2132
|
+
super(target, events, details_setter, customizer);
|
|
2133
|
+
}
|
|
2134
|
+
_register_events(events){
|
|
2135
|
+
super._register_events(events, null, null, false);
|
|
2136
|
+
return this;
|
|
2137
|
+
}
|
|
2138
|
+
emit(event_name, detail = {}){
|
|
2139
|
+
const event = new CustomEvent(event_name, {
|
|
2140
|
+
detail,
|
|
2141
|
+
bubbles: true,
|
|
2142
|
+
cancelable: true
|
|
2143
|
+
});
|
|
2144
|
+
this.targetElement.dispatchEvent(event);
|
|
2145
|
+
return this;
|
|
2146
|
+
}
|
|
2147
|
+
on(event_name, ...callbacks){
|
|
2148
|
+
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2149
|
+
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2150
|
+
return this;
|
|
2266
2151
|
}
|
|
2267
2152
|
}
|
|
2268
2153
|
function details_setter(){
|
|
2269
2154
|
|
|
2270
2155
|
}
|
|
2271
|
-
const
|
|
2156
|
+
const bind_custom_event = (target, events, customizer) => new ZikoCustomEvent(target, events, customizer);
|
|
2272
2157
|
|
|
2273
2158
|
const binderMap = {
|
|
2274
2159
|
ptr: bind_pointer_event,
|
|
@@ -2281,14 +2166,26 @@ const binderMap = {
|
|
|
2281
2166
|
wheel : bind_wheel_event
|
|
2282
2167
|
};
|
|
2283
2168
|
|
|
2284
|
-
const EventsMethodes = {
|
|
2169
|
+
const EventsMethodes = {
|
|
2170
|
+
on(event_name,...callbacks){
|
|
2171
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2172
|
+
this.events.custom.on(event_name,...callbacks);
|
|
2173
|
+
return this;
|
|
2174
|
+
},
|
|
2175
|
+
emit(event_name,detail={}){
|
|
2176
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2177
|
+
this.events.custom.emit(event_name,detail);
|
|
2178
|
+
return this;
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2285
2181
|
|
|
2286
|
-
Object.entries(
|
|
2182
|
+
Object.entries(EventsMap).forEach(([name, eventList]) => {
|
|
2183
|
+
const lname = name.toLowerCase();
|
|
2287
2184
|
eventList.forEach(event => {
|
|
2288
2185
|
const methodName = `on${event}`;
|
|
2289
2186
|
EventsMethodes[methodName] = function (...callbacks) {
|
|
2290
|
-
if (!this.events[
|
|
2291
|
-
this.events[
|
|
2187
|
+
if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
|
|
2188
|
+
this.events[lname][methodName](...callbacks);
|
|
2292
2189
|
return this;
|
|
2293
2190
|
};
|
|
2294
2191
|
});
|
|
@@ -2323,184 +2220,40 @@ function style(styles){
|
|
|
2323
2220
|
if(isStateGetter(value)){
|
|
2324
2221
|
const getter = value();
|
|
2325
2222
|
Object.assign(this.element.style, {[key] : getter.value});
|
|
2326
|
-
getter._subscribe(
|
|
2327
|
-
(newValue) => {
|
|
2328
|
-
console.log({newValue});
|
|
2329
|
-
Object.assign(this.element.style, {[key] : newValue});
|
|
2330
|
-
},
|
|
2331
|
-
// this
|
|
2332
|
-
);
|
|
2333
|
-
}
|
|
2334
|
-
else Object.assign(this.element.style, {[key] : value});
|
|
2335
|
-
}
|
|
2336
|
-
return this;
|
|
2337
|
-
}
|
|
2338
|
-
function size(width, height){
|
|
2339
|
-
return this.style({width, height})
|
|
2340
|
-
}
|
|
2341
|
-
function hide(){
|
|
2342
|
-
|
|
2343
|
-
}
|
|
2344
|
-
function show(){
|
|
2345
|
-
|
|
2346
|
-
}
|
|
2347
|
-
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2348
|
-
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2349
|
-
return this;
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2353
|
-
__proto__: null,
|
|
2354
|
-
animate: animate,
|
|
2355
|
-
hide: hide,
|
|
2356
|
-
show: show,
|
|
2357
|
-
size: size,
|
|
2358
|
-
style: style
|
|
2359
|
-
});
|
|
2360
|
-
|
|
2361
|
-
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
2362
|
-
this.event=e;
|
|
2363
|
-
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
2364
|
-
console.log({setter});
|
|
2365
|
-
if(setter)setter();
|
|
2366
|
-
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
2367
|
-
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
2368
|
-
return this;
|
|
2369
|
-
}
|
|
2370
|
-
class ZikoEvent{
|
|
2371
|
-
constructor(target){
|
|
2372
|
-
this.target=null;
|
|
2373
|
-
this.setTarget(target);
|
|
2374
|
-
this.__dispose=this.dispose.bind(this);
|
|
2375
|
-
// this.EventIndex=Garbage.Pointer.data.length;
|
|
2376
|
-
// Garbage.Pointer.data.push({event:this,index:this.EventIndex});
|
|
2377
|
-
}
|
|
2378
|
-
get targetElement(){
|
|
2379
|
-
return this.target.element
|
|
2380
|
-
}
|
|
2381
|
-
setTarget(UI){
|
|
2382
|
-
this.target=UI;
|
|
2383
|
-
return this;
|
|
2384
|
-
}
|
|
2385
|
-
__handle(event,handler,dispose){
|
|
2386
|
-
const EVENT=(event==="drag")?event:`${this.cache.prefixe}${event}`;
|
|
2387
|
-
this.dispose(dispose);
|
|
2388
|
-
this.targetElement?.addEventListener(EVENT,handler);
|
|
2389
|
-
return this;
|
|
2390
|
-
}
|
|
2391
|
-
__onEvent(event,dispose,...callbacks){
|
|
2392
|
-
if(callbacks.length===0){
|
|
2393
|
-
if(this.cache.callbacks.length>1){
|
|
2394
|
-
this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
2395
|
-
}
|
|
2396
|
-
else {
|
|
2397
|
-
return this;
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
else this.cache.callbacks[event]=callbacks.map(n=>e=>n.call(this,e));
|
|
2401
|
-
this.__handle(event,this.__controller[event],dispose);
|
|
2402
|
-
return this;
|
|
2403
|
-
}
|
|
2404
|
-
preventDefault(config={}){
|
|
2405
|
-
Object.assign(this.cache.preventDefault,config);
|
|
2406
|
-
return this;
|
|
2407
|
-
}
|
|
2408
|
-
pause(config={}){
|
|
2409
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2410
|
-
config={...all,...config};
|
|
2411
|
-
for(let key in config){
|
|
2412
|
-
if(config[key]){
|
|
2413
|
-
this.targetElement?.removeEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2414
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=true;
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
return this;
|
|
2418
|
-
}
|
|
2419
|
-
resume(config={}){
|
|
2420
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2421
|
-
config={...all,...config};
|
|
2422
|
-
for(let key in config){
|
|
2423
|
-
if(config[key]){
|
|
2424
|
-
this.targetElement?.addEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2425
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=false;
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
return this;
|
|
2429
|
-
}
|
|
2430
|
-
dispose(config={}){
|
|
2431
|
-
this.pause(config);
|
|
2432
|
-
return this;
|
|
2433
|
-
}
|
|
2434
|
-
stream(config={}){
|
|
2435
|
-
this.cache.stream.t0=Date.now();
|
|
2436
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2437
|
-
config={...all,...config};
|
|
2438
|
-
Object.assign(this.cache.stream.enabled,config);
|
|
2439
|
-
return this;
|
|
2440
|
-
}
|
|
2441
|
-
clear(config={}){
|
|
2442
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.clear).map(n=>[n,true]));
|
|
2443
|
-
config={...all,...config};
|
|
2444
|
-
for(let key in config){
|
|
2445
|
-
if(config[key]){
|
|
2446
|
-
this.cache.stream.history[key]=[];
|
|
2447
|
-
}
|
|
2223
|
+
getter._subscribe(
|
|
2224
|
+
(newValue) => {
|
|
2225
|
+
console.log({newValue});
|
|
2226
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2227
|
+
},
|
|
2228
|
+
// this
|
|
2229
|
+
);
|
|
2448
2230
|
}
|
|
2449
|
-
|
|
2231
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2450
2232
|
}
|
|
2233
|
+
return this;
|
|
2234
|
+
}
|
|
2235
|
+
function size(width, height){
|
|
2236
|
+
return this.style({width, height})
|
|
2237
|
+
}
|
|
2238
|
+
function hide(){
|
|
2239
|
+
|
|
2240
|
+
}
|
|
2241
|
+
function show(){
|
|
2242
|
+
|
|
2243
|
+
}
|
|
2244
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2245
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2246
|
+
return this;
|
|
2451
2247
|
}
|
|
2452
2248
|
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
prefixe:"",
|
|
2462
|
-
preventDefault:{
|
|
2463
|
-
},
|
|
2464
|
-
paused:{
|
|
2465
|
-
},
|
|
2466
|
-
stream:{
|
|
2467
|
-
enabled:{
|
|
2468
|
-
},
|
|
2469
|
-
clear:{
|
|
2470
|
-
},
|
|
2471
|
-
history:{
|
|
2472
|
-
}
|
|
2473
|
-
},
|
|
2474
|
-
callbacks:{
|
|
2475
|
-
}
|
|
2476
|
-
};
|
|
2477
|
-
this.__controller={
|
|
2478
|
-
};
|
|
2479
|
-
}
|
|
2480
|
-
#init(event_name){
|
|
2481
|
-
this.cache.preventDefault[event_name]=false;
|
|
2482
|
-
this.cache.paused[event_name]=false;
|
|
2483
|
-
this.cache.stream.enabled=false;
|
|
2484
|
-
this.cache.stream.clear=false;
|
|
2485
|
-
this.cache.stream.history=[];
|
|
2486
|
-
this.cache.callbacks[event_name]=[];
|
|
2487
|
-
this.__controller[event_name]=custom_event_controller(event_name).bind(this);
|
|
2488
|
-
return this;
|
|
2489
|
-
}
|
|
2490
|
-
on(event_name,...callbacks){
|
|
2491
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2492
|
-
this.__onEvent(event_name,{},...callbacks);
|
|
2493
|
-
return this;
|
|
2494
|
-
}
|
|
2495
|
-
emit(event_name,detail={}){
|
|
2496
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2497
|
-
this.detail=detail;
|
|
2498
|
-
const event=new Event(event_name);
|
|
2499
|
-
this.targetElement.dispatchEvent(event);
|
|
2500
|
-
return this;
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
const useCustomEvent=target=>new ZikoCustomEvent(target);
|
|
2249
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2250
|
+
__proto__: null,
|
|
2251
|
+
animate: animate,
|
|
2252
|
+
hide: hide,
|
|
2253
|
+
show: show,
|
|
2254
|
+
size: size,
|
|
2255
|
+
style: style
|
|
2256
|
+
});
|
|
2504
2257
|
|
|
2505
2258
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
2506
2259
|
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
@@ -2515,6 +2268,8 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
2515
2268
|
IndexingMethods,
|
|
2516
2269
|
EventsMethodes
|
|
2517
2270
|
);
|
|
2271
|
+
|
|
2272
|
+
// console.log(EventsMethodes)
|
|
2518
2273
|
if(element)this.init(element, name, type, render);
|
|
2519
2274
|
}
|
|
2520
2275
|
get element(){
|
|
@@ -2652,16 +2407,16 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
2652
2407
|
// this.events.clipboard.onSelect(...callbacks);
|
|
2653
2408
|
// return this;
|
|
2654
2409
|
// }
|
|
2655
|
-
on(event_name,...callbacks){
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
}
|
|
2660
|
-
emit(event_name,detail={}){
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
}
|
|
2410
|
+
// on(event_name,...callbacks){
|
|
2411
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2412
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
2413
|
+
// return this;
|
|
2414
|
+
// }
|
|
2415
|
+
// emit(event_name,detail={}){
|
|
2416
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2417
|
+
// this.events.custom.emit(event_name,detail);
|
|
2418
|
+
// return this;
|
|
2419
|
+
// }
|
|
2665
2420
|
// watchAttr(callback){
|
|
2666
2421
|
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
2667
2422
|
// return this;
|
|
@@ -4795,209 +4550,7 @@ const timeTaken = callback => {
|
|
|
4795
4550
|
return r;
|
|
4796
4551
|
};
|
|
4797
4552
|
|
|
4798
|
-
|
|
4799
|
-
constructor() {
|
|
4800
|
-
this.events = {};
|
|
4801
|
-
this.maxListeners = 10;
|
|
4802
|
-
}
|
|
4803
|
-
on(event, listener) {
|
|
4804
|
-
if (!this.events[event]) {
|
|
4805
|
-
this.events[event] = [];
|
|
4806
|
-
}
|
|
4807
|
-
this.events[event].push(listener);
|
|
4808
|
-
if (this.events[event].length > this.maxListeners) {
|
|
4809
|
-
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4810
|
-
}
|
|
4811
|
-
}
|
|
4812
|
-
once(event, listener) {
|
|
4813
|
-
const onceListener = (data) => {
|
|
4814
|
-
this.off(event, onceListener); // Remove the listener after it's been called
|
|
4815
|
-
listener(data);
|
|
4816
|
-
};
|
|
4817
|
-
this.on(event, onceListener);
|
|
4818
|
-
}
|
|
4819
|
-
|
|
4820
|
-
off(event, listener) {
|
|
4821
|
-
const listeners = this.events[event];
|
|
4822
|
-
if (listeners) {
|
|
4823
|
-
const index = listeners.indexOf(listener);
|
|
4824
|
-
if (index !== -1) {
|
|
4825
|
-
listeners.splice(index, 1);
|
|
4826
|
-
}
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
|
|
4830
|
-
emit(event, data) {
|
|
4831
|
-
const listeners = this.events[event];
|
|
4832
|
-
if (listeners) {
|
|
4833
|
-
listeners.forEach(listener => {
|
|
4834
|
-
listener(data);
|
|
4835
|
-
});
|
|
4836
|
-
}
|
|
4837
|
-
}
|
|
4838
|
-
|
|
4839
|
-
clear(event) {
|
|
4840
|
-
if (event) {
|
|
4841
|
-
delete this.events[event];
|
|
4842
|
-
} else {
|
|
4843
|
-
this.events = {};
|
|
4844
|
-
}
|
|
4845
|
-
}
|
|
4846
|
-
|
|
4847
|
-
setMaxListener(event, max) {
|
|
4848
|
-
this.maxListeners = max;
|
|
4849
|
-
}
|
|
4850
|
-
|
|
4851
|
-
removeAllListeners(event) {
|
|
4852
|
-
if (event) {
|
|
4853
|
-
this.events[event] = [];
|
|
4854
|
-
} else {
|
|
4855
|
-
this.events = {};
|
|
4856
|
-
}
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
|
-
|
|
4860
|
-
const useEventEmitter=()=>new UseEventEmitter();
|
|
4861
|
-
|
|
4862
|
-
class ZikoUseFavIcon{
|
|
4863
|
-
constructor(FavIcon,useEventEmitter=true){
|
|
4864
|
-
this.#init();
|
|
4865
|
-
this.cache={
|
|
4866
|
-
Emitter:null
|
|
4867
|
-
};
|
|
4868
|
-
if(useEventEmitter)this.useEventEmitter();
|
|
4869
|
-
this.set(FavIcon);
|
|
4870
|
-
}
|
|
4871
|
-
#init(){
|
|
4872
|
-
this.__FavIcon__ = document.querySelector("link[rel*='icon']") || document?.createElement('link');
|
|
4873
|
-
this.__FavIcon__.type = 'image/x-icon';
|
|
4874
|
-
this.__FavIcon__.rel = 'shortcut icon';
|
|
4875
|
-
return this;
|
|
4876
|
-
}
|
|
4877
|
-
set(href){
|
|
4878
|
-
if(href!==this.__FavIcon__.href){
|
|
4879
|
-
this.__FavIcon__.href=href;
|
|
4880
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:favicon-changed");
|
|
4881
|
-
}
|
|
4882
|
-
return this;
|
|
4883
|
-
}
|
|
4884
|
-
get current(){
|
|
4885
|
-
return document.__FavIcon__.href;
|
|
4886
|
-
}
|
|
4887
|
-
onChange(callback){
|
|
4888
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
|
|
4889
|
-
return this;
|
|
4890
|
-
}
|
|
4891
|
-
useEventEmitter(){
|
|
4892
|
-
this.cache.Emitter=useEventEmitter();
|
|
4893
|
-
return this;
|
|
4894
|
-
}
|
|
4895
|
-
|
|
4896
|
-
}
|
|
4897
|
-
const useFavIcon=(FavIcon,useEventEmitter)=>new ZikoUseFavIcon(FavIcon,useEventEmitter);
|
|
4898
|
-
|
|
4899
|
-
class ZikoMeta{
|
|
4900
|
-
constructor({viewport,charset,description,author,keywords}){
|
|
4901
|
-
this.document = globalThis?.document;
|
|
4902
|
-
this.meta={};
|
|
4903
|
-
this.init({viewport,charset,description,author,keywords});
|
|
4904
|
-
}
|
|
4905
|
-
init({viewport,charset,description,author,keywords}){
|
|
4906
|
-
viewport && this.setViewport(viewport);
|
|
4907
|
-
charset && this.setCharset(charset);
|
|
4908
|
-
description && this.describe(description);
|
|
4909
|
-
author && this.setAuthor(author);
|
|
4910
|
-
keywords && this.setKeywords(keywords);
|
|
4911
|
-
}
|
|
4912
|
-
set(key,value){
|
|
4913
|
-
key = key.toLowerCase();
|
|
4914
|
-
const isCharset = (key === "charset");
|
|
4915
|
-
const meta = isCharset ? document.querySelector("meta[charset]"):document.querySelector(`meta[name=${key}]`);
|
|
4916
|
-
this.meta=meta?? document?.createElement("meta");
|
|
4917
|
-
if(isCharset) this.meta.setAttribute("charset",value);
|
|
4918
|
-
else {
|
|
4919
|
-
this.meta.setAttribute("name",key);
|
|
4920
|
-
this.meta.setAttribute("content",value);
|
|
4921
|
-
}
|
|
4922
|
-
if(!meta)this.document.head.append(this.meta);
|
|
4923
|
-
return this;
|
|
4924
|
-
}
|
|
4925
|
-
setCharset(charset="utf-8"){
|
|
4926
|
-
this.set("charset",charset);
|
|
4927
|
-
return this;
|
|
4928
|
-
}
|
|
4929
|
-
describe(description){
|
|
4930
|
-
this.set("description",description);
|
|
4931
|
-
return this;
|
|
4932
|
-
}
|
|
4933
|
-
setViewport(viewport="width=device-width, initial-scale=1.0"){
|
|
4934
|
-
this.set("viewport",viewport);
|
|
4935
|
-
return this;
|
|
4936
|
-
}
|
|
4937
|
-
setKeywords(...keywords){
|
|
4938
|
-
// keywords.push("zikojs");
|
|
4939
|
-
keywords=[...new Set(keywords)].join(", ");
|
|
4940
|
-
this.set("keywords",keywords);
|
|
4941
|
-
return this;
|
|
4942
|
-
}
|
|
4943
|
-
setAuthor(author){
|
|
4944
|
-
this.set("author",author);
|
|
4945
|
-
return this;
|
|
4946
|
-
}
|
|
4947
|
-
}
|
|
4948
|
-
const useMeta=({viewport,charset,description,author,keywords})=>new ZikoMeta({viewport,charset,description,author,keywords});
|
|
4949
|
-
|
|
4950
|
-
class ZikoUseTitle{
|
|
4951
|
-
constructor(title=document.title,useEventEmitter=true){
|
|
4952
|
-
this.cache={
|
|
4953
|
-
Emitter:null
|
|
4954
|
-
};
|
|
4955
|
-
if(useEventEmitter)this.useEventEmitter();
|
|
4956
|
-
this.set(title);
|
|
4957
|
-
}
|
|
4958
|
-
useEventEmitter(){
|
|
4959
|
-
this.cache.Emitter=useEventEmitter();
|
|
4960
|
-
return this;
|
|
4961
|
-
}
|
|
4962
|
-
set(title){
|
|
4963
|
-
if(title!==document.title){
|
|
4964
|
-
document.title=title;
|
|
4965
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:title-changed");
|
|
4966
|
-
}
|
|
4967
|
-
return this;
|
|
4968
|
-
}
|
|
4969
|
-
get current(){
|
|
4970
|
-
return document.title;
|
|
4971
|
-
}
|
|
4972
|
-
onChange(callback){
|
|
4973
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:title-changed",callback);
|
|
4974
|
-
return this;
|
|
4975
|
-
}
|
|
4976
|
-
}
|
|
4977
|
-
const useTitle=(title, useEventEmitter)=>new ZikoUseTitle(title, useEventEmitter);
|
|
4978
|
-
|
|
4979
|
-
// import {useLink} from "./";
|
|
4980
|
-
class ZikoHead{
|
|
4981
|
-
constructor({title,lang,icon,meta,noscript}){
|
|
4982
|
-
this.html = globalThis?.document?.documentElement;
|
|
4983
|
-
this.head = globalThis?.document?.head;
|
|
4984
|
-
|
|
4985
|
-
title && useTitle(title);
|
|
4986
|
-
lang && this.setLang(lang);
|
|
4987
|
-
icon && useFavIcon(icon);
|
|
4988
|
-
meta && useMeta(meta);
|
|
4989
|
-
noscript && this.setNoScript();
|
|
4990
|
-
}
|
|
4991
|
-
setLang(lang){
|
|
4992
|
-
this.html.setAttribute("lang",lang);
|
|
4993
|
-
}
|
|
4994
|
-
setNoScript(content){
|
|
4995
|
-
|
|
4996
|
-
}
|
|
4997
|
-
}
|
|
4998
|
-
|
|
4999
|
-
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
5000
|
-
|
|
4553
|
+
// import { ZikoHead , useHead} from "../reactivity/hooks/head/index.js";
|
|
5001
4554
|
class ZikoApp {
|
|
5002
4555
|
constructor({head = null, wrapper = null, target = null}){
|
|
5003
4556
|
this.head = head;
|
|
@@ -5024,11 +4577,11 @@ class ZikoApp {
|
|
|
5024
4577
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5025
4578
|
return this;
|
|
5026
4579
|
}
|
|
5027
|
-
setHead(head){
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
}
|
|
4580
|
+
// setHead(head){
|
|
4581
|
+
// if(head instanceof ZikoHead) this.head = head;
|
|
4582
|
+
// else this.head = useHead(head);
|
|
4583
|
+
// return this;
|
|
4584
|
+
// }
|
|
5032
4585
|
|
|
5033
4586
|
}
|
|
5034
4587
|
const App = ({head, wrapper, target}) => new ZikoApp({head, wrapper, target});
|
|
@@ -5219,7 +4772,7 @@ function useDerived(deriveFn, sources) {
|
|
|
5219
4772
|
const subscribers = new Set();
|
|
5220
4773
|
|
|
5221
4774
|
sources.forEach(source => {
|
|
5222
|
-
const srcValue = source();
|
|
4775
|
+
const srcValue = source();
|
|
5223
4776
|
srcValue._subscribe(() => {
|
|
5224
4777
|
{
|
|
5225
4778
|
const newVal = deriveFn(...sources.map(s => s().value));
|
|
@@ -5248,95 +4801,267 @@ const useReactive = (nested_value) => mapfun$1(
|
|
|
5248
4801
|
nested_value
|
|
5249
4802
|
);
|
|
5250
4803
|
|
|
5251
|
-
class
|
|
5252
|
-
#
|
|
4804
|
+
class UseThread {
|
|
4805
|
+
#worker;
|
|
4806
|
+
#callbacks = new Map();
|
|
4807
|
+
#idCounter = 0;
|
|
4808
|
+
|
|
5253
4809
|
constructor() {
|
|
5254
|
-
|
|
5255
|
-
function
|
|
4810
|
+
const workerCode = `
|
|
4811
|
+
this.onmessage = function(e) {
|
|
4812
|
+
const { id, funStr, args, close } = e.data;
|
|
5256
4813
|
try {
|
|
5257
|
-
const func = new Function("return " +
|
|
5258
|
-
|
|
5259
|
-
postMessage({ result });
|
|
4814
|
+
const func = new Function("return " + funStr)();
|
|
4815
|
+
const result = func(...args);
|
|
4816
|
+
postMessage({ id, result });
|
|
5260
4817
|
} catch (error) {
|
|
5261
|
-
postMessage({ error: error.message });
|
|
4818
|
+
postMessage({ id, error: error.message });
|
|
5262
4819
|
} finally {
|
|
5263
|
-
if (
|
|
4820
|
+
if (close) self.close();
|
|
5264
4821
|
}
|
|
5265
4822
|
}
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
this
|
|
4823
|
+
`;
|
|
4824
|
+
const blob = new Blob([workerCode], { type: "text/javascript" });
|
|
4825
|
+
this.#worker = new Worker(URL.createObjectURL(blob));
|
|
4826
|
+
|
|
4827
|
+
this.#worker.addEventListener("message", (e) => {
|
|
4828
|
+
const { id, result, error } = e.data;
|
|
4829
|
+
const callback = this.#callbacks.get(id);
|
|
4830
|
+
if (!callback) return;
|
|
4831
|
+
|
|
4832
|
+
callback(result, error);
|
|
4833
|
+
this.#callbacks.delete(id);
|
|
4834
|
+
});
|
|
5269
4835
|
}
|
|
5270
|
-
call(func, callback, close = true) {
|
|
5271
|
-
|
|
5272
|
-
|
|
4836
|
+
call(func, callback, args = [], close = true) {
|
|
4837
|
+
if (typeof func !== "function") throw new TypeError("func must be a function");
|
|
4838
|
+
const id = ++this.#idCounter;
|
|
4839
|
+
this.#callbacks.set(id, callback);
|
|
4840
|
+
|
|
4841
|
+
this.#worker.postMessage({
|
|
4842
|
+
id,
|
|
4843
|
+
funStr: func.toString(),
|
|
4844
|
+
args,
|
|
5273
4845
|
close
|
|
5274
4846
|
});
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
4847
|
+
|
|
4848
|
+
return this;
|
|
4849
|
+
}
|
|
4850
|
+
|
|
4851
|
+
terminate() {
|
|
4852
|
+
this.#worker.terminate();
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4856
|
+
const useThread = (func, callback, args = [], close = true) => new UseThread().call(func, callback, args, close);
|
|
4857
|
+
|
|
4858
|
+
class UseEventEmitter {
|
|
4859
|
+
constructor(maxListeners = 10) {
|
|
4860
|
+
this.events = {};
|
|
4861
|
+
this.maxListeners = maxListeners;
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4864
|
+
on(event, listener) {
|
|
4865
|
+
if (!this.events[event]) this.events[event] = [];
|
|
4866
|
+
this.events[event].push(listener);
|
|
4867
|
+
if (this.events[event].length > this.maxListeners) {
|
|
4868
|
+
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4869
|
+
}
|
|
4870
|
+
return this;
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
once(event, listener) {
|
|
4874
|
+
const wrapper = (...args) => {
|
|
4875
|
+
this.off(event, wrapper);
|
|
4876
|
+
listener(...args);
|
|
5281
4877
|
};
|
|
4878
|
+
return this.on(event, wrapper);
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4881
|
+
off(event, listener) {
|
|
4882
|
+
const listeners = this.events[event];
|
|
4883
|
+
if (!listeners) return this;
|
|
4884
|
+
|
|
4885
|
+
const index = listeners.indexOf(listener);
|
|
4886
|
+
if (index !== -1) {
|
|
4887
|
+
listeners.splice(index, 1);
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
return this;
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4893
|
+
emit(event, data) {
|
|
4894
|
+
const listeners = this.events[event];
|
|
4895
|
+
if (!listeners) return false;
|
|
4896
|
+
|
|
4897
|
+
// Make a copy so removing listeners inside callbacks doesn't affect iteration
|
|
4898
|
+
[...listeners].forEach(listener => {
|
|
4899
|
+
try {
|
|
4900
|
+
listener(data);
|
|
4901
|
+
} catch (e) {
|
|
4902
|
+
console.error(`Error in listener for '${event}':`, e);
|
|
4903
|
+
}
|
|
4904
|
+
});
|
|
4905
|
+
|
|
4906
|
+
return true;
|
|
4907
|
+
}
|
|
4908
|
+
remove(event){
|
|
4909
|
+
delete this.events[event];
|
|
4910
|
+
return this;
|
|
4911
|
+
}
|
|
4912
|
+
clear() {
|
|
4913
|
+
this.events = {};
|
|
4914
|
+
return this;
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4917
|
+
setMaxListeners(max) {
|
|
4918
|
+
this.maxListeners = max;
|
|
5282
4919
|
return this;
|
|
5283
4920
|
}
|
|
5284
4921
|
}
|
|
5285
4922
|
|
|
5286
|
-
const
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
4923
|
+
const useEventEmitter = (maxListeners) => new UseEventEmitter(maxListeners);
|
|
4924
|
+
|
|
4925
|
+
/*
|
|
4926
|
+
[
|
|
4927
|
+
{
|
|
4928
|
+
query: '(min-width: 600px)',
|
|
4929
|
+
callback: () => console.log(1)
|
|
4930
|
+
},
|
|
4931
|
+
{
|
|
4932
|
+
query: '(max-width: 300px)',
|
|
4933
|
+
callback: () => console.log(2)
|
|
5290
4934
|
}
|
|
5291
|
-
|
|
5292
|
-
|
|
4935
|
+
]
|
|
4936
|
+
*/
|
|
4937
|
+
|
|
4938
|
+
class UseMediaQuery {
|
|
4939
|
+
#mediaQueryRules;
|
|
4940
|
+
#fallback;
|
|
4941
|
+
#lastCalledCallback = null;
|
|
4942
|
+
|
|
4943
|
+
constructor(mediaQueryRules = [], fallback = () => {}) {
|
|
4944
|
+
this.#mediaQueryRules = mediaQueryRules;
|
|
4945
|
+
this.#fallback = fallback;
|
|
4946
|
+
|
|
4947
|
+
this.#init();
|
|
4948
|
+
}
|
|
4949
|
+
|
|
4950
|
+
// PRIVATE: check if ANY rule matches
|
|
4951
|
+
#checkAllRules() {
|
|
4952
|
+
return this.#mediaQueryRules.some(
|
|
4953
|
+
({ query }) => globalThis.matchMedia(query).matches
|
|
4954
|
+
);
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
// PRIVATE: installs listeners and initial checks
|
|
4958
|
+
#init() {
|
|
4959
|
+
this.#mediaQueryRules.forEach(({ query, callback }) => {
|
|
4960
|
+
const mediaQueryList = globalThis.matchMedia(query);
|
|
4961
|
+
|
|
4962
|
+
const checkMatches = () => {
|
|
4963
|
+
const anyMatch = this.#checkAllRules();
|
|
4964
|
+
|
|
4965
|
+
if (mediaQueryList.matches) {
|
|
4966
|
+
callback();
|
|
4967
|
+
this.#lastCalledCallback = callback;
|
|
4968
|
+
} else if (!anyMatch && this.#lastCalledCallback !== this.#fallback) {
|
|
4969
|
+
this.#fallback();
|
|
4970
|
+
this.#lastCalledCallback = this.#fallback;
|
|
4971
|
+
}
|
|
4972
|
+
};
|
|
4973
|
+
|
|
4974
|
+
checkMatches();
|
|
4975
|
+
mediaQueryList.addEventListener("change", checkMatches);
|
|
4976
|
+
});
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
const useMediaQuery = (mediaQueryRules, fallback) =>
|
|
4981
|
+
new UseMediaQuery(mediaQueryRules, fallback);
|
|
4982
|
+
|
|
4983
|
+
class UseTitle {
|
|
4984
|
+
constructor(title = document.title, withEmitter = true) {
|
|
4985
|
+
this.cache = {
|
|
4986
|
+
emitter: null
|
|
4987
|
+
};
|
|
4988
|
+
|
|
4989
|
+
if (withEmitter) this.useEventEmitter();
|
|
4990
|
+
this.set(title);
|
|
4991
|
+
}
|
|
4992
|
+
|
|
4993
|
+
useEventEmitter() {
|
|
4994
|
+
this.cache.emitter = useEventEmitter();
|
|
4995
|
+
return this;
|
|
4996
|
+
}
|
|
4997
|
+
|
|
4998
|
+
setTitle(title) {
|
|
4999
|
+
if (title !== document.title) {
|
|
5000
|
+
document.title = title;
|
|
5001
|
+
|
|
5002
|
+
if (this.cache.emitter) {
|
|
5003
|
+
this.cache.emitter.emit("ziko:title-changed", title);
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
return this;
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
get current() {
|
|
5010
|
+
return document.title;
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
onChange(callback) {
|
|
5014
|
+
if (this.cache.emitter) {
|
|
5015
|
+
this.cache.emitter.on("ziko:title-changed", callback);
|
|
5016
|
+
}
|
|
5017
|
+
return this;
|
|
5018
|
+
}
|
|
5019
|
+
}
|
|
5020
|
+
|
|
5021
|
+
const useTitle = (title, withEmitter = true) => new UseTitle(title, withEmitter);
|
|
5293
5022
|
|
|
5294
5023
|
class UseRoot {
|
|
5295
|
-
constructor(PropsMap, {namespace = 'Ziko',
|
|
5024
|
+
constructor(PropsMap, { namespace = 'Ziko', ValidateCssProps = false } = {}) {
|
|
5296
5025
|
this.currentPropsMap = PropsMap;
|
|
5297
5026
|
this.namespace = namespace;
|
|
5298
5027
|
this.ValidateCssProps = ValidateCssProps;
|
|
5299
|
-
// this.pairs = {};
|
|
5300
|
-
// this.#maintain()
|
|
5301
5028
|
this.use(PropsMap);
|
|
5302
5029
|
}
|
|
5303
|
-
|
|
5304
|
-
|
|
5030
|
+
|
|
5031
|
+
use(PropsMap) {
|
|
5032
|
+
if (this.ValidateCssProps) ValidateCssPropsFn(PropsMap);
|
|
5305
5033
|
this.currentPropsMap = PropsMap;
|
|
5306
5034
|
this.#maintain();
|
|
5307
5035
|
return this;
|
|
5308
5036
|
}
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
const
|
|
5313
|
-
|
|
5314
|
-
cssProp,
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
// Object.assign(this.pairs, {
|
|
5318
|
-
// [prop] : `var(--${this.namespace}-${prop})`
|
|
5319
|
-
// })
|
|
5320
|
-
Object.defineProperty(this, prop, {
|
|
5037
|
+
|
|
5038
|
+
#maintain() {
|
|
5039
|
+
const root = globalThis?.document?.documentElement?.style;
|
|
5040
|
+
for (const prop in this.currentPropsMap) {
|
|
5041
|
+
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`;
|
|
5042
|
+
root.setProperty(cssProp, this.currentPropsMap[prop]);
|
|
5043
|
+
|
|
5044
|
+
Object.defineProperty(this, prop, {
|
|
5321
5045
|
value: `var(${cssProp})`,
|
|
5322
5046
|
writable: true,
|
|
5323
5047
|
configurable: true,
|
|
5324
|
-
enumerable: false
|
|
5325
|
-
|
|
5326
|
-
|
|
5048
|
+
enumerable: false
|
|
5049
|
+
});
|
|
5050
|
+
}
|
|
5327
5051
|
}
|
|
5328
5052
|
}
|
|
5329
5053
|
|
|
5330
|
-
function
|
|
5054
|
+
function ValidateCssPropsFn(PropsMap) {
|
|
5331
5055
|
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
5332
|
-
for (
|
|
5056
|
+
for (const key in PropsMap) {
|
|
5333
5057
|
if (!validProps.has(key)) {
|
|
5334
5058
|
throw new Error(`Invalid CSS property: "${key}"`);
|
|
5335
5059
|
}
|
|
5336
5060
|
}
|
|
5337
5061
|
}
|
|
5338
5062
|
|
|
5339
|
-
const useRoot = (PropsMap,
|
|
5063
|
+
const useRoot = (PropsMap, options = {}) => new UseRoot(PropsMap, options);
|
|
5064
|
+
|
|
5340
5065
|
|
|
5341
5066
|
// Usage
|
|
5342
5067
|
|
|
@@ -5427,4 +5152,4 @@ if(globalThis?.document){
|
|
|
5427
5152
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5428
5153
|
}
|
|
5429
5154
|
|
|
5430
|
-
export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, Utils, View, ZikoApp,
|
|
5155
|
+
export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_touch_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, e, elastic, fact, floor, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, zeros };
|