@jackens/nnn 2026.4.11 → 2026.4.13
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/nnn.js +28 -29
- package/package.json +1 -1
- package/readme.md +1 -1
package/nnn.js
CHANGED
|
@@ -67,15 +67,14 @@ var isRecord = (arg) => typeof arg === "object" && arg != null && !isArray(arg);
|
|
|
67
67
|
|
|
68
68
|
// src/nnn/h.ts
|
|
69
69
|
var XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
70
|
-
var _h = (
|
|
71
|
-
const createElement = namespaceUri == null ? (tag) => document.createElement(tag) : (tag) => document.createElementNS(namespaceUri, tag);
|
|
70
|
+
var _h = (createElement, tagOrNode, ...args) => {
|
|
72
71
|
const node = isString(tagOrNode) ? createElement(tagOrNode) : tagOrNode;
|
|
73
72
|
args.forEach((arg) => {
|
|
74
73
|
let child = null;
|
|
75
74
|
if (arg instanceof Node) {
|
|
76
75
|
child = arg;
|
|
77
76
|
} else if (isArray(arg)) {
|
|
78
|
-
child = _h(
|
|
77
|
+
child = _h(createElement, ...arg);
|
|
79
78
|
} else if (isRecord(arg)) {
|
|
80
79
|
for (const name in arg) {
|
|
81
80
|
const value = arg[name];
|
|
@@ -121,8 +120,8 @@ var _h = (namespaceUri, tagOrNode, ...args) => {
|
|
|
121
120
|
});
|
|
122
121
|
return node;
|
|
123
122
|
};
|
|
124
|
-
var h = _h.bind(null,
|
|
125
|
-
var s = _h.bind(null, "http://www.w3.org/2000/svg");
|
|
123
|
+
var h = _h.bind(null, document.createElement);
|
|
124
|
+
var s = _h.bind(null, document.createElementNS.bind(document, "http://www.w3.org/2000/svg"));
|
|
126
125
|
var svgUse = (id, ...args) => s("svg", ["use", { "xlink:href": "#" + id }], ...args);
|
|
127
126
|
|
|
128
127
|
// src/nnn/fixPlTypography.ts
|
|
@@ -304,31 +303,9 @@ var newNounForm = (locale, forms) => (value) => forms[(PLURAL_RULES[locale] ??=
|
|
|
304
303
|
var omit = (ref, keys) => Object.fromEntries(Object.entries(ref).filter(([key]) => !keys.includes(key)));
|
|
305
304
|
// src/nnn/pick.ts
|
|
306
305
|
var pick = (ref, keys) => Object.fromEntries(Object.entries(ref).filter(([key]) => keys.includes(key)));
|
|
307
|
-
// src/nnn/vivify.ts
|
|
308
|
-
var ARRAY_INDEX_REGEXP = /^(0|[1-9]\d*)$/;
|
|
309
|
-
var isObject = (ref) => typeof ref === "object";
|
|
310
|
-
var getTarget = (parent, parentKey, key) => parent[parentKey] ??= isString(key) && ARRAY_INDEX_REGEXP.test(key) ? [] : {};
|
|
311
|
-
var _vivify = (parent, parentKey) => new Proxy(parent, {
|
|
312
|
-
get(_, key) {
|
|
313
|
-
const target = getTarget(parent, parentKey, key);
|
|
314
|
-
const value = target[key];
|
|
315
|
-
return isString(key) && isObject(target) && (value == null || isObject(value)) ? _vivify(target, key) : value;
|
|
316
|
-
},
|
|
317
|
-
set(_, key, value) {
|
|
318
|
-
const target = getTarget(parent, parentKey, key);
|
|
319
|
-
target[key] = value;
|
|
320
|
-
return true;
|
|
321
|
-
},
|
|
322
|
-
deleteProperty(_, key) {
|
|
323
|
-
const target = getTarget(parent, parentKey, key);
|
|
324
|
-
return delete target[key];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
var vivify = (ref) => _vivify({ _: ref }, "_");
|
|
328
|
-
|
|
329
306
|
// src/nnn/rwd.ts
|
|
330
307
|
var rwd = (root, selector, cellWidthPx, cellHeightPx, ...specs) => {
|
|
331
|
-
const main =
|
|
308
|
+
const main = root[selector] ??= {};
|
|
332
309
|
main.boxSizing = "border-box";
|
|
333
310
|
main.display = "block";
|
|
334
311
|
main.float = "left";
|
|
@@ -336,7 +313,8 @@ var rwd = (root, selector, cellWidthPx, cellHeightPx, ...specs) => {
|
|
|
336
313
|
main.height = `${cellHeightPx}px`;
|
|
337
314
|
specs.sort(([a], [b]) => a - b);
|
|
338
315
|
for (let [maxWidth, width, height] of specs) {
|
|
339
|
-
const
|
|
316
|
+
const mediaSelector = `@media(min-width:${cellWidthPx * maxWidth}px)`;
|
|
317
|
+
const node = maxWidth === 1 ? main : (root[mediaSelector] ??= {})[selector] ??= {};
|
|
340
318
|
width ??= 1;
|
|
341
319
|
height ??= 1;
|
|
342
320
|
let gcd = 100 * width;
|
|
@@ -357,6 +335,27 @@ var uuidV1 = (date = new Date, node = Math.random().toString(16).slice(2)) => {
|
|
|
357
335
|
counter = counter + 1 & 16383;
|
|
358
336
|
return time.slice(-8).concat("-", time.slice(-12, -8), -1, time.slice(-15, -12), "-", (8 | counter >> 12).toString(16), (ZEROS + (counter & 4095).toString(16)).slice(-3), "-", (ZEROS + node).slice(-12));
|
|
359
337
|
};
|
|
338
|
+
// src/nnn/vivify.ts
|
|
339
|
+
var ARRAY_INDEX_REGEXP = /^(0|[1-9]\d*)$/;
|
|
340
|
+
var isObject = (ref) => typeof ref === "object";
|
|
341
|
+
var getTarget = (parent, parentKey, key) => parent[parentKey] ??= isString(key) && ARRAY_INDEX_REGEXP.test(key) ? [] : {};
|
|
342
|
+
var _vivify = (parent, parentKey) => new Proxy(parent, {
|
|
343
|
+
get(_, key) {
|
|
344
|
+
const target = getTarget(parent, parentKey, key);
|
|
345
|
+
const value = target[key];
|
|
346
|
+
return isString(key) && isObject(target) && (value == null || isObject(value)) ? _vivify(target, key) : value;
|
|
347
|
+
},
|
|
348
|
+
set(_, key, value) {
|
|
349
|
+
const target = getTarget(parent, parentKey, key);
|
|
350
|
+
target[key] = value;
|
|
351
|
+
return true;
|
|
352
|
+
},
|
|
353
|
+
deleteProperty(_, key) {
|
|
354
|
+
const target = getTarget(parent, parentKey, key);
|
|
355
|
+
return delete target[key];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
var vivify = (ref) => _vivify({ _: ref }, "_");
|
|
360
359
|
export {
|
|
361
360
|
vivify,
|
|
362
361
|
uuidV1,
|
package/package.json
CHANGED