@t007/input 0.0.8 → 0.0.9
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/index.global.js +19 -5
- package/dist/index.js +3 -3
- package/dist/standalone.js +19 -5
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
+
// ../utils/node_modules/sia-reactor/dist/chunk-DW7Z7YEA.js
|
|
4
|
+
function isDef(val) {
|
|
5
|
+
return "undefined" !== typeof val;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
// ../utils/dist/index.js
|
|
9
|
+
function isSym(val) {
|
|
10
|
+
return "symbol" === typeof val;
|
|
11
|
+
}
|
|
12
|
+
function isStr(val) {
|
|
13
|
+
return "string" === typeof val;
|
|
14
|
+
}
|
|
15
|
+
function isArr(obj) {
|
|
16
|
+
return Array.isArray(obj);
|
|
17
|
+
}
|
|
4
18
|
function isSameURL(src1, src2) {
|
|
5
|
-
if (
|
|
19
|
+
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
6
20
|
try {
|
|
7
21
|
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
8
22
|
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
@@ -28,7 +42,7 @@
|
|
|
28
42
|
var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
|
|
29
43
|
function loadResource(req, type = "style", { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts = 3, retryKey = false } = {}, w = window) {
|
|
30
44
|
w.t007 ??= {}, w.t007._resourceCache ??= {};
|
|
31
|
-
if (req === VIRTUAL_RESOURCE ||
|
|
45
|
+
if (req === VIRTUAL_RESOURCE || isSym(req)) return Promise.resolve();
|
|
32
46
|
const src = req;
|
|
33
47
|
if (w.t007._resourceCache[src]) return w.t007._resourceCache[src];
|
|
34
48
|
const existing = type === "script" ? Array.prototype.find.call(w.document.scripts, (s) => isSameURL(s.src, src)) : type === "style" ? Array.prototype.find.call(w.document.styleSheets, (s) => isSameURL(s.href, src)) : null;
|
|
@@ -124,7 +138,7 @@
|
|
|
124
138
|
});
|
|
125
139
|
return update(), t007._scrollers.get(el);
|
|
126
140
|
}
|
|
127
|
-
if (
|
|
141
|
+
if (isDef(window)) {
|
|
128
142
|
window.t007 ??= {};
|
|
129
143
|
t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
130
144
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
|
@@ -261,7 +275,7 @@
|
|
|
261
275
|
labelEl.append(outline);
|
|
262
276
|
}
|
|
263
277
|
const inputEl = field2.inputEl = createEl(isTextArea ? "textarea" : isSelect ? "select" : "input", { className: `t007-input${className ? ` ${className}` : ""}`, placeholder });
|
|
264
|
-
if (isSelect &&
|
|
278
|
+
if (isSelect && isArr(options)) inputEl.innerHTML = options.map((opt) => isStr(opt) ? `<option value="${opt}">${opt}</option>` : `<option value="${opt.value}">${opt.option}</option>`).join("");
|
|
265
279
|
if (!isSelect && !isTextArea) inputEl.type = type;
|
|
266
280
|
if (custom) inputEl.setAttribute("custom", custom);
|
|
267
281
|
if (minSize) inputEl.setAttribute("minsize", minSize);
|
|
@@ -430,7 +444,7 @@
|
|
|
430
444
|
}
|
|
431
445
|
};
|
|
432
446
|
var { field, handleFormValidation } = formManager;
|
|
433
|
-
if (
|
|
447
|
+
if (isDef(window)) {
|
|
434
448
|
t007.FM = t007.formManager = formManager;
|
|
435
449
|
t007.field = field;
|
|
436
450
|
t007.handleFormValidation = handleFormValidation;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.js
|
|
2
|
-
import { createEl, loadResource, initScrollAssist } from "@t007/utils";
|
|
2
|
+
import { isArr, isDef, isStr, createEl, loadResource, initScrollAssist } from "@t007/utils";
|
|
3
3
|
var formManager = {
|
|
4
4
|
forms: document.getElementsByClassName("t007-input-form"),
|
|
5
5
|
violationKeys: ["valueMissing", "typeMismatch", "patternMismatch", "stepMismatch", "tooShort", "tooLong", "rangeUnderflow", "rangeOverflow", "badInput", "customError"],
|
|
@@ -125,7 +125,7 @@ var formManager = {
|
|
|
125
125
|
labelEl.append(outline);
|
|
126
126
|
}
|
|
127
127
|
const inputEl = field2.inputEl = createEl(isTextArea ? "textarea" : isSelect ? "select" : "input", { className: `t007-input${className ? ` ${className}` : ""}`, placeholder });
|
|
128
|
-
if (isSelect &&
|
|
128
|
+
if (isSelect && isArr(options)) inputEl.innerHTML = options.map((opt) => isStr(opt) ? `<option value="${opt}">${opt}</option>` : `<option value="${opt.value}">${opt.option}</option>`).join("");
|
|
129
129
|
if (!isSelect && !isTextArea) inputEl.type = type;
|
|
130
130
|
if (custom) inputEl.setAttribute("custom", custom);
|
|
131
131
|
if (minSize) inputEl.setAttribute("minsize", minSize);
|
|
@@ -294,7 +294,7 @@ var formManager = {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
var { field, handleFormValidation } = formManager;
|
|
297
|
-
if (
|
|
297
|
+
if (isDef(window)) {
|
|
298
298
|
t007.FM = t007.formManager = formManager;
|
|
299
299
|
t007.field = field;
|
|
300
300
|
t007.handleFormValidation = handleFormValidation;
|
package/dist/standalone.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
// ../utils/node_modules/sia-reactor/dist/chunk-DW7Z7YEA.js
|
|
2
|
+
function isDef(val) {
|
|
3
|
+
return "undefined" !== typeof val;
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// ../utils/dist/index.js
|
|
7
|
+
function isSym(val) {
|
|
8
|
+
return "symbol" === typeof val;
|
|
9
|
+
}
|
|
10
|
+
function isStr(val) {
|
|
11
|
+
return "string" === typeof val;
|
|
12
|
+
}
|
|
13
|
+
function isArr(obj) {
|
|
14
|
+
return Array.isArray(obj);
|
|
15
|
+
}
|
|
2
16
|
function isSameURL(src1, src2) {
|
|
3
|
-
if (
|
|
17
|
+
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
4
18
|
try {
|
|
5
19
|
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
6
20
|
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
@@ -26,7 +40,7 @@ function assignEl(el, props, dataset, styles) {
|
|
|
26
40
|
var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
|
|
27
41
|
function loadResource(req, type = "style", { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts = 3, retryKey = false } = {}, w = window) {
|
|
28
42
|
w.t007 ??= {}, w.t007._resourceCache ??= {};
|
|
29
|
-
if (req === VIRTUAL_RESOURCE ||
|
|
43
|
+
if (req === VIRTUAL_RESOURCE || isSym(req)) return Promise.resolve();
|
|
30
44
|
const src = req;
|
|
31
45
|
if (w.t007._resourceCache[src]) return w.t007._resourceCache[src];
|
|
32
46
|
const existing = type === "script" ? Array.prototype.find.call(w.document.scripts, (s) => isSameURL(s.src, src)) : type === "style" ? Array.prototype.find.call(w.document.styleSheets, (s) => isSameURL(s.href, src)) : null;
|
|
@@ -122,7 +136,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "tmg-video-c
|
|
|
122
136
|
});
|
|
123
137
|
return update(), t007._scrollers.get(el);
|
|
124
138
|
}
|
|
125
|
-
if (
|
|
139
|
+
if (isDef(window)) {
|
|
126
140
|
window.t007 ??= {};
|
|
127
141
|
t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
128
142
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
|
@@ -259,7 +273,7 @@ var formManager = {
|
|
|
259
273
|
labelEl.append(outline);
|
|
260
274
|
}
|
|
261
275
|
const inputEl = field2.inputEl = createEl(isTextArea ? "textarea" : isSelect ? "select" : "input", { className: `t007-input${className ? ` ${className}` : ""}`, placeholder });
|
|
262
|
-
if (isSelect &&
|
|
276
|
+
if (isSelect && isArr(options)) inputEl.innerHTML = options.map((opt) => isStr(opt) ? `<option value="${opt}">${opt}</option>` : `<option value="${opt.value}">${opt.option}</option>`).join("");
|
|
263
277
|
if (!isSelect && !isTextArea) inputEl.type = type;
|
|
264
278
|
if (custom) inputEl.setAttribute("custom", custom);
|
|
265
279
|
if (minSize) inputEl.setAttribute("minsize", minSize);
|
|
@@ -428,7 +442,7 @@ var formManager = {
|
|
|
428
442
|
}
|
|
429
443
|
};
|
|
430
444
|
var { field, handleFormValidation } = formManager;
|
|
431
|
-
if (
|
|
445
|
+
if (isDef(window)) {
|
|
432
446
|
t007.FM = t007.formManager = formManager;
|
|
433
447
|
t007.field = field;
|
|
434
448
|
t007.handleFormValidation = handleFormValidation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/input",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "A lightweight, pure JS input system.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"monkey-patch"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@t007/utils": "
|
|
60
|
+
"@t007/utils": "^0.0.9"
|
|
61
61
|
}
|
|
62
62
|
}
|