@ntlab/ntjs-repo 3.0.0

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.
@@ -0,0 +1,266 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2023-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
26
+ const JQuery = ScriptManager.require('JQuery');
27
+
28
+ /**
29
+ * JQuery/PostErrorHelper script repository.
30
+ */
31
+ class PostErrorHelper extends JQuery {
32
+
33
+ initialize() {
34
+ this.name = 'PostErrorHelper';
35
+ this.position = ScriptRepository.POSITION_FIRST;
36
+ this.addDependencies(['JQuery', 'JQuery/ScrollTo']);
37
+ }
38
+
39
+ getScript() {
40
+ const err = 'Error';
41
+ return `
42
+ $.errformat = {REPLACE: 0, INPLACE: 1, ASLIST: 2};
43
+ $.errhelper = function(container, options) {
44
+ const helper = {
45
+ container: null,
46
+ errorContainer: null,
47
+ errorFormat: $.errformat.ASLIST,
48
+ requiredSelector: '.required',
49
+ errClass: null,
50
+ parentSelector: null,
51
+ parentClass: 'error',
52
+ listClass: 'error_list',
53
+ toggleClass: null,
54
+ inplace: null,
55
+ focused: null,
56
+ visibilityUseClass: false,
57
+ getError(err, fmt, sep) {
58
+ let error = '';
59
+ if (!Array.isArray(err)) {
60
+ err = [err];
61
+ }
62
+ err.forEach(e => {
63
+ if (error.length && sep) {
64
+ error = error + sep;
65
+ }
66
+ e = Array.isArray(e) ? e.join(': ') : e;
67
+ if (fmt) {
68
+ error = error + $.util.template(fmt, {error: e});
69
+ } else {
70
+ error = error + e;
71
+ }
72
+ });
73
+ return error;
74
+ },
75
+ doShow(el, show = true) {
76
+ const self = this;
77
+ if (self.visibilityUseClass && self.toggleClass) {
78
+ if (show) {
79
+ el.removeClass(self.toggleClass);
80
+ } else {
81
+ el.addClass(self.toggleClass);
82
+ }
83
+ } else {
84
+ if (show) {
85
+ el.show();
86
+ } else {
87
+ el.hide();
88
+ }
89
+ }
90
+ },
91
+ showError(el) {
92
+ const self = this;
93
+ self.doShow(el, true);
94
+ if (self.toggleClass) {
95
+ el.removeClass(self.toggleClass);
96
+ el.parents().removeClass(self.toggleClass);
97
+ }
98
+ },
99
+ addErrorClass(el) {
100
+ const self = this;
101
+ if (self.errClass) {
102
+ if (el.is('input[type="hidden"]')) {
103
+ el = el.siblings('input');
104
+ }
105
+ el.addClass(self.errClass);
106
+ }
107
+ },
108
+ addError(err, el, errtype) {
109
+ const self = this;
110
+ errtype = errtype ? errtype : $.errformat.REPLACE;
111
+ if (Array.isArray(el)) {
112
+ el.forEach(function(x) {
113
+ self.showError(x);
114
+ });
115
+ el = el[el.length - 1];
116
+ }
117
+ let error;
118
+ switch (errtype) {
119
+ case $.errformat.REPLACE:
120
+ error = self.getError(err, null, ', ');
121
+ if (error.length) {
122
+ el.html(error);
123
+ self.addErrorClass(el);
124
+ self.showError(el);
125
+ }
126
+ break;
127
+ case $.errformat.INPLACE:
128
+ error = self.getError(err, null, ', ');
129
+ if (typeof self.inplace === 'function') {
130
+ let iel = self.inplace(el, error);
131
+ self.addErrorClass(iel);
132
+ self.showError(iel);
133
+ }
134
+ break;
135
+ case $.errformat.ASLIST:
136
+ error = self.getError(err, '<li>%error%</li>');
137
+ let ul = el.find('ul.' + self.listClass);
138
+ if (ul.length) {
139
+ ul.append(error);
140
+ } else {
141
+ $('<ul class="' + self.listClass + '">' + error + '</ul>').appendTo(el);
142
+ }
143
+ self.addErrorClass(el);
144
+ self.showError(el);
145
+ break;
146
+ }
147
+ },
148
+ handleError(err) {
149
+ let handled = false;
150
+ // reference self using variable
151
+ if (Array.isArray(err)) {
152
+ const el = $('#' + err[0]);
153
+ // check if error element is exist
154
+ if (el.length) {
155
+ handled = true;
156
+ helper.addError(err[1], helper.errorFormat === $.errformat.ASLIST ? el.parent() : el, helper.errorFormat);
157
+ if (helper.parentClass) {
158
+ if (helper.parentSelector) {
159
+ el.parents(helper.parentSelector).addClass(helper.parentClass).show();
160
+ } else {
161
+ el.parent().addClass(helper.parentClass).show();
162
+ }
163
+ }
164
+ if (helper.focused === null) {
165
+ if (el.is('input[type="hidden"]')) {
166
+ helper.focused = el.siblings('input');
167
+ } else {
168
+ helper.focused = el;
169
+ }
170
+ }
171
+ } else {
172
+ err = err[0] + ': ' + err[1];
173
+ }
174
+ }
175
+ if (!handled) {
176
+ // error message shown in container
177
+ if (helper.errorContainer) {
178
+ helper.addError(err, helper.errorContainer, helper.errorFormat);
179
+ } else {
180
+ if ($.ntdlg) {
181
+ $.ntdlg.message('dlgerr', '$err', err, $.ntdlg.ICON_ERROR);
182
+ } else {
183
+ alert(err);
184
+ }
185
+ }
186
+ }
187
+ },
188
+ focusError() {
189
+ const self = this;
190
+ if (self.focused != null) {
191
+ $.scrollto(self.focused);
192
+ self.focused.focus();
193
+ }
194
+ },
195
+ resetError() {
196
+ const self = this;
197
+ self.focused = null;
198
+ if (self.container) {
199
+ if (self.listClass) {
200
+ self.container.find('.' + self.listClass).remove();
201
+ }
202
+ if (self.errClass) {
203
+ self.container.find('.' + self.errClass).removeClass(self.errClass);
204
+ }
205
+ if (self.parentClass) {
206
+ if (self.parentSelector) {
207
+ self.container.find(self.parentSelector).removeClass(self.parentClass);
208
+ } else {
209
+ self.container.find('.' + self.parentClass).removeClass(self.parentClass);
210
+ }
211
+ }
212
+ }
213
+ if (self.errorContainer) {
214
+ if (Array.isArray(self.errorContainer)) {
215
+ self.doShow(self.errorContainer[0], false);
216
+ } else {
217
+ self.doShow(self.errorContainer, false);
218
+ }
219
+ }
220
+ if (typeof self.onErrReset === 'function') {
221
+ self.onErrReset(self);
222
+ }
223
+ }
224
+ }
225
+ helper.container = container;
226
+ options = options ? options : {};
227
+ $.util.applyProp(['errorContainer', 'errorFormat', 'requiredSelector', 'parentSelector', 'parentClass',
228
+ 'errClass', 'listClass', 'toggleClass', 'visibilityUseClass', 'inplace', 'onErrReset'], options, helper);
229
+ if (typeof helper.errorContainer === 'string' && helper.container) {
230
+ let p = helper.container;
231
+ const containers = helper.errorContainer.split(' ');
232
+ const items = [];
233
+ while (true) {
234
+ if (containers.length === 0) {
235
+ break;
236
+ }
237
+ const selector = containers.shift();
238
+ const el = p.find(selector);
239
+ if (el.length) {
240
+ p = el;
241
+ items.push(el);
242
+ } else {
243
+ break;
244
+ }
245
+ }
246
+ if (items.length) {
247
+ if (items.length > 1) {
248
+ helper.errorContainer = items;
249
+ } else {
250
+ helper.errorContainer = items[0];
251
+ }
252
+ } else {
253
+ delete helper.errorContainer;
254
+ }
255
+ }
256
+ return helper;
257
+ }
258
+ `;
259
+ }
260
+
261
+ static instance() {
262
+ return new this();
263
+ }
264
+ }
265
+
266
+ module.exports = PostErrorHelper;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2023-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
26
+ const JQuery = ScriptManager.require('JQuery');
27
+
28
+ /**
29
+ * JQuery/PostHandler script repository.
30
+ */
31
+ class PostHandler extends JQuery {
32
+
33
+ initialize() {
34
+ this.name = 'PostHandler';
35
+ this.position = ScriptRepository.POSITION_FIRST;
36
+ this.addDependencies(['JQuery', 'JQuery/PostErrorHelper']);
37
+ }
38
+
39
+ getScript() {
40
+ return `
41
+ $.extend({
42
+ handlePostData(data, errhelper, success_cb, error_cb) {
43
+ $.postErr = null;
44
+ const json = typeof(data) === 'object' ? data : $.parseJSON(data);
45
+ if (json.success) {
46
+ if (typeof success_cb === 'function') {
47
+ success_cb(json);
48
+ }
49
+ } else {
50
+ if (json.error) {
51
+ if (!Array.isArray(json.error)) {
52
+ json.error = [json.error];
53
+ }
54
+ json.error.forEach(err => {
55
+ errhelper.handleError(err);
56
+ });
57
+ }
58
+ if (typeof error_cb === 'function') {
59
+ error_cb(json);
60
+ }
61
+ }
62
+ },
63
+ urlPost(url, callback, errhelper) {
64
+ errhelper = errhelper ? errhelper : $.errhelper();
65
+ $.post(url).done(function(data) {
66
+ $.handlePostData(data, errhelper, callback);
67
+ });
68
+ }
69
+ });
70
+ `;
71
+ }
72
+
73
+ static instance() {
74
+ return new this();
75
+ }
76
+ }
77
+
78
+ module.exports = PostHandler;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2023-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
26
+ const JQuery = ScriptManager.require('JQuery');
27
+
28
+ /**
29
+ * JQuery/ScrollTo script repository.
30
+ */
31
+ class ScrollTo extends JQuery {
32
+
33
+ initialize() {
34
+ this.name = 'ScrollTo';
35
+ this.position = ScriptRepository.POSITION_MIDDLE;
36
+ this.addDependencies(['JQuery']);
37
+ }
38
+
39
+ getScript() {
40
+ return `
41
+ $.scrollto = function(el) {
42
+ if (typeof el === 'string') {
43
+ el = $(el);
44
+ }
45
+ if (el.length) {
46
+ const top = el.offset().top;
47
+ const w = $(window);
48
+ const t = w.scrollTop();
49
+ const h = w.height();
50
+ if (top < t || top > t + h) {
51
+ const ptop = parseInt($(document.body).css('padding-top'));
52
+ w.scrollTop(top - ptop);
53
+ }
54
+ }
55
+ }`;
56
+ }
57
+
58
+ static instance() {
59
+ return new this();
60
+ }
61
+ }
62
+
63
+ module.exports = ScrollTo;
package/JQuery/Util.js ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { ScriptRepository, ScriptManager } = require('@ntlab/ntjs');
26
+ const JQuery = ScriptManager.require('JQuery');
27
+
28
+ /**
29
+ * JQuery/Util script repository.
30
+ */
31
+ class Util extends JQuery {
32
+
33
+ initialize() {
34
+ this.name = 'Util';
35
+ this.position = ScriptRepository.POSITION_FIRST;
36
+ this.addDependencies(['JQuery', 'JQuery/Define']);
37
+ }
38
+
39
+ getScript() {
40
+ return `
41
+ $.define('util', {
42
+ template(tmpl, replaces) {
43
+ for (const n in replaces) {
44
+ const re = new RegExp('%' + n + '%', 'g');
45
+ tmpl = tmpl.replace(re, replaces[n]);
46
+ }
47
+ return tmpl;
48
+ },
49
+ copyProp(prop, src, dest, remove) {
50
+ if (src[prop] !== undefined) {
51
+ dest[prop] = src[prop];
52
+ if (remove) {
53
+ delete src[prop];
54
+ }
55
+ }
56
+ },
57
+ applyProp(props, src, dest, remove) {
58
+ const self = this;
59
+ if (src && dest) {
60
+ if (typeof props === 'object') {
61
+ if (Array.isArray(props)) {
62
+ for (let i = 0; i < props.length; i++) {
63
+ const prop = props[i];
64
+ self.copyProp(prop, src, dest, remove);
65
+ }
66
+ } else {
67
+ for (const prop in props) {
68
+ self.copyProp(prop, src, dest, remove);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ },
74
+ bindEvent(el, event, handlers) {
75
+ if (typeof handlers[event] === 'function') {
76
+ el.on(event, handlers[event]);
77
+ }
78
+ },
79
+ applyEvent(el, events, handlers) {
80
+ const self = this;
81
+ if (typeof events === 'object') {
82
+ if (Array.isArray(events)) {
83
+ for (let i = 0; i < events.length; i++) {
84
+ const event = events[i];
85
+ self.bindEvent(el, event, handlers);
86
+ }
87
+ } else {
88
+ for (event in events) {
89
+ self.bindEvent(el, event, handlers);
90
+ }
91
+ }
92
+ }
93
+ },
94
+ dump(o, p) {
95
+ if (typeof o === 'object') {
96
+ for (const a in o) {
97
+ $.util.dump(o[a], (p !== undefined ? p + '.' : '') + a);
98
+ }
99
+ } else {
100
+ alert((p !== undefined ? p + ' = ' : '') + o);
101
+ }
102
+ }
103
+ });
104
+ `;
105
+ }
106
+
107
+ static instance() {
108
+ return new this();
109
+ }
110
+ }
111
+
112
+ module.exports = Util;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { Script, ScriptAsset } = require('@ntlab/ntjs');
26
+ const debug = require('debug')('script:JQuery');
27
+
28
+ /**
29
+ * JQuery script repository.
30
+ */
31
+ class JQuery extends Script {
32
+
33
+ constructor() {
34
+ super('JQuery', 'jquery');
35
+ }
36
+
37
+ initialize() {
38
+ this.assetPath = this.repository;
39
+ this.addAsset(ScriptAsset.JAVASCRIPT, 'jquery.min');
40
+ }
41
+
42
+ initRepository(repository) {
43
+ if (JQuery.getOption('xhr')) {
44
+ debug('Init repository for XHR');
45
+ repository.wrapSize = 2;
46
+ repository.wrapper = `
47
+ (function($) {
48
+ (function loader(f) {
49
+ if (document.ntloader && !document.ntloader.isScriptLoaded()) {
50
+ setTimeout(function() {
51
+ loader(f);
52
+ }, 100);
53
+ } else {
54
+ f($);
55
+ }
56
+ })(function($) {%s});
57
+ })(jQuery);`;
58
+ } else {
59
+ debug('Init repository for normal request');
60
+ repository.wrapSize = 1;
61
+ repository.wrapper = `
62
+ (function($) {%s})(jQuery);`;
63
+ }
64
+ }
65
+
66
+ static instance() {
67
+ return new this();
68
+ }
69
+ }
70
+
71
+ module.exports = JQuery;
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2025 Toha <tohenk@yahoo.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Popper.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2023-2025 Toha <tohenk@yahoo.com>
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ * of the Software, and to permit persons to whom the Software is furnished to do
11
+ * so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const { Script, ScriptAsset } = require('@ntlab/ntjs');
26
+
27
+ class Popper extends Script {
28
+
29
+ initialize() {
30
+ this.name = 'Popper';
31
+ this.assetPath = 'popper.js';
32
+ this.version = version;
33
+ const versions = [Popper.UMD, Popper.ESM, Popper.CJS];
34
+ if (versions.indexOf(this.version) >= 0) {
35
+ this.getAsset().setPath(ScriptAsset.JAVASCRIPT, this.version);
36
+ } else {
37
+ throw new Error(`Popper version not supported %{this.version}`);
38
+ }
39
+ this.addAsset(ScriptAsset.JAVASCRIPT, 'popper.min');
40
+ }
41
+
42
+ static get UMD() {
43
+ return 'umd';
44
+ }
45
+
46
+ static get ESM() {
47
+ return 'esm';
48
+ }
49
+
50
+ static get CJS() {
51
+ return 'cjs';
52
+ }
53
+
54
+ static setVersion(v) {
55
+ version = v;
56
+ }
57
+
58
+ static instance() {
59
+ return new this();
60
+ }
61
+ }
62
+
63
+ let version = Popper.UMD;
64
+
65
+ module.exports = Popper;
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # NODE-NTJS Script Repository
2
+
3
+ A collection of NODE-NTJS scripts.