hrenpack_js 3.0.1 → 3.1.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.
Files changed (3) hide show
  1. package/index.d.ts +204 -0
  2. package/index.js +928 -0
  3. package/package.json +3 -1
package/index.d.ts ADDED
@@ -0,0 +1,204 @@
1
+ // @ts-nocheck
2
+
3
+ // ===== File: arraywork.d.ts =====
4
+ declare function arrayIsEmpty(arr: any[]): boolean;
5
+ declare function arraysIsEqual(array1: any[], array2: any[], strict?: boolean): boolean;
6
+ //# sourceMappingURL=arraywork.d.ts.map
7
+
8
+ // ===== File: auto.d.ts =====
9
+ declare const stylesRoot: CSSStyleDeclaration;
10
+ //# sourceMappingURL=auto.d.ts.map
11
+
12
+ // ===== File: classes.d.ts =====
13
+ declare class ClickableLinksFactory {
14
+ private readonly urlRegex;
15
+ private walk;
16
+ private get_anchor;
17
+ private get_clickToCopy;
18
+ clickableLinks(element: HTMLElement): void;
19
+ clickToCopyLinks(element: HTMLElement): void;
20
+ get generatedElements(): NodeListOf<HTMLElement>;
21
+ }
22
+ declare class GETParamsManager {
23
+ private params;
24
+ constructor();
25
+ get<T = string>(key: string, defaultValue?: T): T | string | null;
26
+ set(key: string, value: string | number | boolean): void;
27
+ delete(key: string): void;
28
+ all(): Record<string, string>;
29
+ clear(): void;
30
+ private updateURL;
31
+ }
32
+ //# sourceMappingURL=classes.d.ts.map
33
+
34
+ // ===== File: compiler.d.ts =====
35
+ declare function downloadTextAsFile(filename: string, text: string): void;
36
+ //# sourceMappingURL=compiler.d.ts.map
37
+
38
+ // ===== File: cookie.d.ts =====
39
+ declare function getCookie(name: string): NullStr;
40
+ declare function setCookie(name: string, value: string, days?: NullNum, path?: string): void;
41
+ declare function hasCookie(name: string): boolean;
42
+ //# sourceMappingURL=cookie.d.ts.map
43
+
44
+ // ===== File: exceptions.d.ts =====
45
+ declare class NotAuthorizedError extends Error {
46
+ constructor();
47
+ }
48
+ //# sourceMappingURL=exceptions.d.ts.map
49
+
50
+ // ===== File: get_element_types.d.ts =====
51
+ declare function button_submit(parent: HTMLElement): HTMLButtonElement | null;
52
+ //# sourceMappingURL=get_element_types.d.ts.map
53
+
54
+ // ===== File: html.d.ts =====
55
+ declare const escapeChars: StringDict;
56
+ declare function togglePassword(passwordInput: HTMLInputElement): void;
57
+ declare function isTextWrapped(element: HTMLElement): boolean;
58
+ declare function notArrayEmpty(array: any[]): boolean;
59
+ declare function get_tagName(element: HTMLElement): string;
60
+ declare function element_toHTMLText(element: HTMLElement): string;
61
+ declare function element_to_div(element: HTMLElement): HTMLDivElement;
62
+ declare function password_format(shownPasswordHTML: string, hiddenPasswordHTML: string): void;
63
+ declare function escapeHTML(html: string): string;
64
+ declare function strFormat(template: string, ...args: any[]): string;
65
+ declare function elementToHyperlink(element: HTMLElement, href: string, cursorPointer?: boolean, preventDefault?: boolean): HTMLElement;
66
+ //# sourceMappingURL=html.d.ts.map
67
+
68
+ // ===== File: input.d.ts =====
69
+ declare function getInputCursorPosition(input: HTMLInputElement): number;
70
+ declare function copyInputToClipboard(input: HTMLInputElement): void;
71
+ declare function clearInput_and_addLastSymbol(input: HTMLInputElement): void;
72
+ declare function getInputLabel(input: HTMLInputElement): HTMLLabelElement;
73
+ //# sourceMappingURL=input.d.ts.map
74
+
75
+ // ===== File: link.d.ts =====
76
+ declare function loadCSS(href: string): void;
77
+ //# sourceMappingURL=link.d.ts.map
78
+
79
+ // ===== File: notifications.d.ts =====
80
+ declare function pushNotification(title?: string, body?: string, icon?: NullStr): void;
81
+ declare class HyperTextNotification {
82
+ bottom: string;
83
+ right: string;
84
+ backgroundColor: string;
85
+ color: string;
86
+ padding: string;
87
+ borderRadius: string;
88
+ timeout: number;
89
+ constructor({ bottom, right, backgroundColor, color, padding, borderRadius, timeout }?: {
90
+ bottom?: string | undefined;
91
+ right?: string | undefined;
92
+ backgroundColor?: string | undefined;
93
+ color?: string | undefined;
94
+ padding?: string | undefined;
95
+ borderRadius?: string | undefined;
96
+ timeout?: number | undefined;
97
+ });
98
+ show(message: string, timeout?: number): void;
99
+ }
100
+ //# sourceMappingURL=notifications.d.ts.map
101
+
102
+ // ===== File: styles.d.ts =====
103
+ declare function input_type_fc(input: HTMLInputElement): boolean;
104
+ declare function input_form_control(form: HTMLFormElement): void;
105
+ declare function input_form_control_unline(form: HTMLFormElement): void;
106
+ declare function intToPixel(number?: NumStr): string;
107
+ //# sourceMappingURL=styles.d.ts.map
108
+
109
+ // ===== File: system.d.ts =====
110
+ declare function getSystemTheme(): NullStr;
111
+ declare function copyTextToClipboard(text: string): void;
112
+ declare function redirectBackOrClose(default_url?: string): void;
113
+ declare function getHost(): string;
114
+ //# sourceMappingURL=system.d.ts.map
115
+
116
+ // ===== File: tags.d.ts =====
117
+ type StepElementStatus = 'uncomplete' | 'active' | 'complete';
118
+ interface StepbarElement extends HTMLElement {
119
+ currentStep: number;
120
+ }
121
+ declare class AbbreviatedNumber extends HTMLElement {
122
+ isShortened: boolean;
123
+ originalNumber: number;
124
+ constructor();
125
+ static get observedAttributes(): string[];
126
+ private toggle;
127
+ private getCurrentLang;
128
+ private formatNumber;
129
+ private render;
130
+ }
131
+ declare class StepElement extends HTMLElement {
132
+ constructor();
133
+ static get observedAttributes(): string[];
134
+ get index(): number;
135
+ private get active();
136
+ private set active(value);
137
+ private get completed();
138
+ private set completed(value);
139
+ get label(): string;
140
+ set label(value: string);
141
+ private reset;
142
+ get status(): StepElementStatus;
143
+ set status(value: StepElementStatus);
144
+ connectedCallback(): void;
145
+ }
146
+ declare class Stepbar extends HTMLElement {
147
+ private _observer;
148
+ constructor();
149
+ static get observedAttributes(): string[];
150
+ attributeChangedCallback(name: string, oldValue: any, newValue: any): void;
151
+ connectedCallback(): void;
152
+ disconnectedCallback(): void;
153
+ private updateSteps;
154
+ get currentStep(): number;
155
+ set currentStep(step: number);
156
+ }
157
+ declare class HTMLFile extends HTMLElement {
158
+ constructor();
159
+ get src(): string;
160
+ set src(value: string);
161
+ static get observedAttributes(): string[];
162
+ connectedCallback(): void;
163
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
164
+ private loadContent;
165
+ private executeScripts;
166
+ private loadExternalScript;
167
+ private executeInlineScript;
168
+ private get loaded();
169
+ reload(): Promise<void>;
170
+ get content(): string;
171
+ }
172
+ declare class ClickToCopy extends HTMLElement {
173
+ private notification;
174
+ constructor();
175
+ get notificationText(): string;
176
+ set notificationText(value: string);
177
+ get isNotified(): boolean;
178
+ set isNotified(value: boolean);
179
+ connectedCallback(): void;
180
+ }
181
+ //# sourceMappingURL=tags.d.ts.map
182
+
183
+ // ===== File: types.d.ts =====
184
+ type NullStr = string | null;
185
+ type NullNum = number | null;
186
+ type Dict = {
187
+ [key: string]: any;
188
+ };
189
+ type StringDict = {
190
+ [key: string]: string;
191
+ };
192
+ type NumStr = number | string;
193
+ //# sourceMappingURL=types.d.ts.map
194
+
195
+ // ===== File: url.d.ts =====
196
+ declare function isAbsoluteUrl(url: string): boolean;
197
+ declare function combineUrls(baseUrl: string, relativeUrl: string): string;
198
+ declare function getScriptSite(script: HTMLScriptElement): string;
199
+ //# sourceMappingURL=url.d.ts.map
200
+
201
+ // ===== File: uuid.d.ts =====
202
+ declare function generateUUIDv4(): string;
203
+ //# sourceMappingURL=uuid.d.ts.map
204
+
package/index.js ADDED
@@ -0,0 +1,928 @@
1
+ // @ts-nocheck
2
+
3
+ // ===== File: arraywork.js =====
4
+ "use strict";
5
+ function arrayIsEmpty(arr) {
6
+ return arr.length === 0 || !arr[0];
7
+ }
8
+ function arraysIsEqual(array1, array2, strict = true) {
9
+ if (array1.length !== array2.length)
10
+ return false;
11
+ if (strict)
12
+ return array1.every((value, index) => value === array2[index]);
13
+ else {
14
+ array1.forEach(element => {
15
+ if (!array2.includes(element))
16
+ return false;
17
+ });
18
+ return true;
19
+ }
20
+ }
21
+ //# sourceMappingURL=arraywork.js.map
22
+
23
+ // ===== File: auto.js =====
24
+ "use strict";
25
+ const stylesRoot = getComputedStyle(document.documentElement);
26
+ //# sourceMappingURL=auto.js.map
27
+
28
+ // ===== File: classes.js =====
29
+ "use strict";
30
+ class ClickableLinksFactory {
31
+ constructor() {
32
+ Object.defineProperty(this, "urlRegex", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: /(https?:\/\/[^\s]+)/g
37
+ });
38
+ }
39
+ walk(node, isClickToCopy) {
40
+ if (node.nodeType === Node.TEXT_NODE) {
41
+ const text = node.textContent || '';
42
+ const func = isClickToCopy ? this.get_clickToCopy : this.get_anchor;
43
+ if (this.urlRegex.test(text)) {
44
+ const parent = node.parentNode;
45
+ const newContent = text.replace(this.urlRegex, url => {
46
+ return func(url);
47
+ });
48
+ if (!parent)
49
+ return;
50
+ const tempDiv = document.createElement('div');
51
+ tempDiv.innerHTML = newContent;
52
+ while (tempDiv.firstChild) {
53
+ parent.insertBefore(tempDiv.firstChild, node);
54
+ }
55
+ parent.removeChild(node);
56
+ }
57
+ }
58
+ else {
59
+ node.childNodes.forEach(child => {
60
+ this.walk(child, isClickToCopy);
61
+ });
62
+ }
63
+ }
64
+ get_anchor(url) {
65
+ return `<a href="${url}" target="_blank" rel="noopener noreferrer" data-clf-generated>${url}</a>`;
66
+ }
67
+ get_clickToCopy(url) {
68
+ return `<click-to-copy data-clf-generated>${url}</click-to-copy>`;
69
+ }
70
+ clickableLinks(element) {
71
+ this.walk(element, false);
72
+ }
73
+ clickToCopyLinks(element) {
74
+ this.walk(element, true);
75
+ }
76
+ get generatedElements() {
77
+ return document.querySelectorAll('[data-clf-generated]');
78
+ }
79
+ }
80
+ class GETParamsManager {
81
+ constructor() {
82
+ Object.defineProperty(this, "params", {
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true,
86
+ value: void 0
87
+ });
88
+ this.params = new URLSearchParams(window.location.search);
89
+ }
90
+ get(key, defaultValue) {
91
+ const value = this.params.get(key);
92
+ if (value === null)
93
+ return defaultValue || null;
94
+ if (defaultValue !== undefined) {
95
+ switch (typeof defaultValue) {
96
+ case 'number':
97
+ return Number(value);
98
+ case 'boolean':
99
+ return (value === 'true');
100
+ default:
101
+ return value;
102
+ }
103
+ }
104
+ return value;
105
+ }
106
+ set(key, value) {
107
+ this.params.set(key, String(value));
108
+ this.updateURL();
109
+ }
110
+ delete(key) {
111
+ this.params.delete(key);
112
+ this.updateURL();
113
+ }
114
+ all() {
115
+ const result = {};
116
+ for (const [key, value] of this.params.entries()) {
117
+ result[key] = value;
118
+ }
119
+ return result;
120
+ }
121
+ clear() {
122
+ const keys = Array.from(this.params.keys());
123
+ keys.forEach(key => this.params.delete(key));
124
+ this.updateURL();
125
+ }
126
+ updateURL() {
127
+ const newUrl = `${window.location.pathname}?${this.params.toString()}`;
128
+ window.history.pushState({}, '', newUrl);
129
+ }
130
+ }
131
+ //# sourceMappingURL=classes.js.map
132
+
133
+ // ===== File: compiler.js =====
134
+ "use strict";
135
+ function downloadTextAsFile(filename, text) {
136
+ const blob = new Blob([text], { type: 'text/plain' });
137
+ const url = URL.createObjectURL(blob);
138
+ console.log(url);
139
+ const a = document.createElement('a');
140
+ a.href = url;
141
+ a.download = filename;
142
+ a.click();
143
+ URL.revokeObjectURL(url);
144
+ }
145
+ //# sourceMappingURL=compiler.js.map
146
+
147
+ // ===== File: cookie.js =====
148
+ "use strict";
149
+ function getCookie(name) {
150
+ const nameEQ = `${name}=`;
151
+ const cookiesArray = document.cookie.split(';');
152
+ cookiesArray.forEach(cookie => {
153
+ cookie = cookie.trim();
154
+ if (cookie.indexOf(nameEQ) === 0) {
155
+ return cookie.substring(nameEQ.length, cookie.length);
156
+ }
157
+ });
158
+ return null;
159
+ }
160
+ function setCookie(name, value, days = null, path = '/') {
161
+ let expires;
162
+ if (!days) {
163
+ expires = '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
164
+ }
165
+ else {
166
+ const date = new Date();
167
+ date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
168
+ expires = `; expires=${date.toUTCString()}`;
169
+ }
170
+ document.cookie = `${name}=${value || ''}${expires}; path=${path}`;
171
+ }
172
+ function hasCookie(name) {
173
+ return getCookie(name) != null;
174
+ }
175
+ //# sourceMappingURL=cookie.js.map
176
+
177
+ // ===== File: exceptions.js =====
178
+ "use strict";
179
+ class NotAuthorizedError extends Error {
180
+ constructor() {
181
+ super("Пользователь не авторизован");
182
+ this.name = 'NotAuthorizedError';
183
+ }
184
+ }
185
+ //# sourceMappingURL=exceptions.js.map
186
+
187
+ // ===== File: get_element_types.js =====
188
+ "use strict";
189
+ function button_submit(parent) {
190
+ const buttons = parent.querySelectorAll('button');
191
+ let submit = null;
192
+ buttons.forEach(button => {
193
+ if (button.type === 'submit')
194
+ submit = button;
195
+ });
196
+ return submit;
197
+ }
198
+ //# sourceMappingURL=get_element_types.js.map
199
+
200
+ // ===== File: html.js =====
201
+ "use strict";
202
+ const escapeChars = {
203
+ '<': '&lt;',
204
+ '>': '&gt;',
205
+ '&': '&amp;',
206
+ '"': '&quot;',
207
+ "'": '&#39;'
208
+ };
209
+ function togglePassword(passwordInput) {
210
+ const passwordType = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
211
+ passwordInput.setAttribute('type', passwordType);
212
+ }
213
+ function isTextWrapped(element) {
214
+ const elementHeight = element.clientHeight;
215
+ const scrollHeight = element.scrollHeight;
216
+ return scrollHeight > elementHeight;
217
+ }
218
+ function notArrayEmpty(array) {
219
+ return array.length > 0;
220
+ }
221
+ function get_tagName(element) {
222
+ return element.tagName.toLowerCase();
223
+ }
224
+ function element_toHTMLText(element) {
225
+ const tag = get_tagName(element);
226
+ const attrs = element.attributes;
227
+ let text = `<${tag}`;
228
+ if (attrs.length > 0) {
229
+ for (let attr of attrs) {
230
+ text += ` ${attr.name}="${attr.value}"`;
231
+ }
232
+ }
233
+ text += `>${element.innerHTML}</${tag}>`;
234
+ return text;
235
+ }
236
+ function element_to_div(element) {
237
+ const div = document.createElement('div');
238
+ div.innerHTML = element.outerHTML;
239
+ return div;
240
+ }
241
+ function password_format(shownPasswordHTML, hiddenPasswordHTML) {
242
+ document.addEventListener('DOMContentLoaded', () => {
243
+ const forms = document.querySelectorAll('form');
244
+ forms.forEach(form => {
245
+ const inputs = form.querySelectorAll('input[type="password"]');
246
+ inputs.forEach(input => {
247
+ const wrapper = document.createElement('div');
248
+ wrapper.style.position = 'relative';
249
+ wrapper.style.display = 'inline-block';
250
+ wrapper.style.width = '100%';
251
+ input.parentNode.insertBefore(wrapper, input);
252
+ wrapper.appendChild(input);
253
+ const toggleBtn = document.createElement('button');
254
+ toggleBtn.type = 'button';
255
+ toggleBtn.className = 'show-password-btn';
256
+ toggleBtn.innerHTML = hiddenPasswordHTML;
257
+ toggleBtn.style.cssText = `
258
+ position: absolute;
259
+ left: 45%;
260
+ top: 50%;
261
+ transform: translateY(-50%);
262
+ cursor: pointer;
263
+ user-select: none;
264
+ background: none;
265
+ border: none;
266
+ padding: 0;
267
+ `;
268
+ toggleBtn.addEventListener('click', () => {
269
+ const isShowing = input.type === 'text';
270
+ input.type = isShowing ? 'password' : 'text';
271
+ toggleBtn.innerHTML = isShowing ? hiddenPasswordHTML : shownPasswordHTML;
272
+ });
273
+ wrapper.appendChild(toggleBtn);
274
+ });
275
+ });
276
+ });
277
+ }
278
+ function escapeHTML(html) {
279
+ return html.replace(/[<>"']/g, function (i) {
280
+ return escapeChars[i] || i;
281
+ });
282
+ }
283
+ function strFormat(template, ...args) {
284
+ return template.replace(/{(\w+)}/g, (match, key) => {
285
+ if (args.length > 0 && typeof args[0] === 'object' && args[0][key] !== undefined) {
286
+ return args[0][key];
287
+ }
288
+ const index = parseInt(key);
289
+ if (!isNaN(index) && args[index] !== undefined) {
290
+ return args[index];
291
+ }
292
+ return match;
293
+ });
294
+ }
295
+ function elementToHyperlink(element, href, cursorPointer = true, preventDefault = false) {
296
+ element.addEventListener('click', function (elem) {
297
+ if (elem.button === 0)
298
+ window.location.href = href;
299
+ else if (elem.button === 1)
300
+ window.open(href, '_blank');
301
+ });
302
+ if (preventDefault) {
303
+ element.addEventListener('auxclick', function (elem) {
304
+ if (elem.button === 1)
305
+ elem.preventDefault();
306
+ });
307
+ }
308
+ if (cursorPointer)
309
+ element.style.cursor = 'pointer';
310
+ return element;
311
+ }
312
+ //# sourceMappingURL=html.js.map
313
+
314
+ // ===== File: input.js =====
315
+ "use strict";
316
+ function getInputCursorPosition(input) {
317
+ const start = input.selectionStart;
318
+ if (start == null)
319
+ throw new Error("Incorrect input type");
320
+ return start - 1;
321
+ }
322
+ function copyInputToClipboard(input) {
323
+ const disabled = input.hasAttribute("disabled");
324
+ if (disabled)
325
+ input.removeAttribute('disabled');
326
+ navigator.clipboard.writeText(input.value)
327
+ .then(() => { })
328
+ .catch(err => {
329
+ console.error('Не удалось скопировать текст: ', err);
330
+ })
331
+ .finally(() => {
332
+ if (disabled)
333
+ input.setAttribute('disabled', '');
334
+ });
335
+ }
336
+ function clearInput_and_addLastSymbol(input) {
337
+ input.value = input.value[getInputCursorPosition(input)] || '';
338
+ }
339
+ function getInputLabel(input) {
340
+ const label = document.querySelector(`label[for="${input.id}"]`);
341
+ if (!label)
342
+ throw new Error("Label не найден. Возможно, вы не использовали атрибут for в нем");
343
+ return label;
344
+ }
345
+ //# sourceMappingURL=input.js.map
346
+
347
+ // ===== File: link.js =====
348
+ "use strict";
349
+ function loadCSS(href) {
350
+ const link = document.createElement('link');
351
+ link.rel = 'stylesheet';
352
+ link.type = 'text/css';
353
+ link.href = href;
354
+ document.head.appendChild(link);
355
+ }
356
+ //# sourceMappingURL=link.js.map
357
+
358
+ // ===== File: notifications.js =====
359
+ "use strict";
360
+ function pushNotification(title = "Уведомление", body = "Текст уведомления", icon = null) {
361
+ if (Notification.permission !== "granted") {
362
+ Notification.requestPermission().then(permission => {
363
+ if (permission === "granted") {
364
+ if (icon)
365
+ new Notification(title, { body: body, icon: icon });
366
+ else
367
+ new Notification(title, { body: body });
368
+ }
369
+ });
370
+ }
371
+ else {
372
+ if (icon)
373
+ new Notification(title, { body: body, icon: icon });
374
+ else
375
+ new Notification(title, { body: body });
376
+ }
377
+ }
378
+ class HyperTextNotification {
379
+ constructor({ bottom = '20', right = '20', backgroundColor = '#121212', color = '#ededed', padding = '15', borderRadius = '5', timeout = 3 } = {}) {
380
+ Object.defineProperty(this, "bottom", {
381
+ enumerable: true,
382
+ configurable: true,
383
+ writable: true,
384
+ value: void 0
385
+ });
386
+ Object.defineProperty(this, "right", {
387
+ enumerable: true,
388
+ configurable: true,
389
+ writable: true,
390
+ value: void 0
391
+ });
392
+ Object.defineProperty(this, "backgroundColor", {
393
+ enumerable: true,
394
+ configurable: true,
395
+ writable: true,
396
+ value: void 0
397
+ });
398
+ Object.defineProperty(this, "color", {
399
+ enumerable: true,
400
+ configurable: true,
401
+ writable: true,
402
+ value: void 0
403
+ });
404
+ Object.defineProperty(this, "padding", {
405
+ enumerable: true,
406
+ configurable: true,
407
+ writable: true,
408
+ value: void 0
409
+ });
410
+ Object.defineProperty(this, "borderRadius", {
411
+ enumerable: true,
412
+ configurable: true,
413
+ writable: true,
414
+ value: void 0
415
+ });
416
+ Object.defineProperty(this, "timeout", {
417
+ enumerable: true,
418
+ configurable: true,
419
+ writable: true,
420
+ value: void 0
421
+ });
422
+ this.bottom = intToPixel(bottom);
423
+ this.right = intToPixel(right);
424
+ this.backgroundColor = backgroundColor;
425
+ this.color = color;
426
+ this.padding = intToPixel(padding);
427
+ this.borderRadius = intToPixel(borderRadius);
428
+ this.timeout = timeout;
429
+ }
430
+ show(message, timeout = 0) {
431
+ const notification = document.createElement("div");
432
+ notification.textContent = message;
433
+ notification.style.position = "fixed";
434
+ notification.style.bottom = this.bottom;
435
+ notification.style.right = this.right;
436
+ notification.style.backgroundColor = this.backgroundColor;
437
+ notification.style.color = this.color;
438
+ notification.style.padding = this.padding;
439
+ notification.style.borderRadius = this.borderRadius;
440
+ notification.style.zIndex = "1000";
441
+ const actualTimeout = timeout === 0 ? this.timeout : timeout;
442
+ document.body.appendChild(notification);
443
+ setTimeout(() => {
444
+ if (document.body.contains(notification)) {
445
+ document.body.removeChild(notification);
446
+ }
447
+ }, actualTimeout * 1000);
448
+ }
449
+ }
450
+ //# sourceMappingURL=notifications.js.map
451
+
452
+ // ===== File: styles.js =====
453
+ "use strict";
454
+ function input_type_fc(input) {
455
+ return input.type !== 'hidden' && input.type !== 'reset' && input.type !== 'checkbox' && input.type !== 'radio';
456
+ }
457
+ function input_form_control(form) {
458
+ const inputs = form.querySelectorAll('input');
459
+ const selects = form.querySelectorAll('select');
460
+ const areas = form.querySelectorAll('textarea');
461
+ inputs.forEach(input => {
462
+ if (input_type_fc(input))
463
+ input.classList.add('form-control');
464
+ });
465
+ selects.forEach(select => {
466
+ select.classList.add('form-control');
467
+ });
468
+ areas.forEach(textarea => {
469
+ textarea.classList.add('form-control');
470
+ });
471
+ }
472
+ function input_form_control_unline(form) {
473
+ console.log(form.id);
474
+ const inputs = form.querySelectorAll('input');
475
+ const selects = form.querySelectorAll('select');
476
+ const areas = form.querySelectorAll('textarea');
477
+ inputs.forEach(input => {
478
+ if (input_type_fc(input))
479
+ input.classList.add('form-control-unline');
480
+ });
481
+ selects.forEach(select => {
482
+ select.classList.add('form-control-unline');
483
+ });
484
+ areas.forEach(textarea => {
485
+ textarea.classList.add('form-control-unline');
486
+ });
487
+ }
488
+ function intToPixel(number = '0') {
489
+ number = number.toString();
490
+ if (parseInt(number) === 0)
491
+ return '0';
492
+ return !isNaN(parseInt(number)) ? number + 'px' : number;
493
+ }
494
+ //# sourceMappingURL=styles.js.map
495
+
496
+ // ===== File: system.js =====
497
+ "use strict";
498
+ function getSystemTheme() {
499
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').media !== 'not all') {
500
+ const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
501
+ return isDark ? 'dark' : 'light';
502
+ }
503
+ return null;
504
+ }
505
+ function copyTextToClipboard(text) {
506
+ navigator.clipboard.writeText(text)
507
+ .then(() => { })
508
+ .catch(err => {
509
+ console.error('Не удалось скопировать текст: ', err);
510
+ });
511
+ }
512
+ function redirectBackOrClose(default_url = '/') {
513
+ if (document.referrer && document.referrer !== window.location.href) {
514
+ window.history.back();
515
+ }
516
+ else {
517
+ window.close();
518
+ setTimeout(() => {
519
+ if (!window.closed) {
520
+ window.location.href = default_url;
521
+ }
522
+ }, 100);
523
+ }
524
+ }
525
+ function getHost() {
526
+ return window.location.protocol + '//' + window.location.host;
527
+ }
528
+ //# sourceMappingURL=system.js.map
529
+
530
+ // ===== File: tags.js =====
531
+ "use strict";
532
+ class AbbreviatedNumber extends HTMLElement {
533
+ constructor() {
534
+ super();
535
+ Object.defineProperty(this, "isShortened", {
536
+ enumerable: true,
537
+ configurable: true,
538
+ writable: true,
539
+ value: void 0
540
+ });
541
+ Object.defineProperty(this, "originalNumber", {
542
+ enumerable: true,
543
+ configurable: true,
544
+ writable: true,
545
+ value: void 0
546
+ });
547
+ this.isShortened = true;
548
+ this.originalNumber = parseFloat(this.textContent?.trim() || '0');
549
+ this.render();
550
+ this.addEventListener('click', this.toggle.bind(this));
551
+ if (isNaN(this.originalNumber))
552
+ throw new TypeError('The value must be a number');
553
+ }
554
+ static get observedAttributes() {
555
+ return ['lang', 'use_comma'];
556
+ }
557
+ toggle() {
558
+ this.isShortened = !this.isShortened;
559
+ this.render();
560
+ }
561
+ getCurrentLang() {
562
+ return this.getAttribute('lang') || document.documentElement.getAttribute('lang') || 'en';
563
+ }
564
+ formatNumber(num, lang) {
565
+ num = parseFloat(num.toString().replace(/[^\d.-]/g, ''));
566
+ if (isNaN(num))
567
+ return this.originalNumber.toString();
568
+ const useComma = this.hasAttribute('use_comma');
569
+ const separator = useComma ? ',' : '.';
570
+ const round = (value, digits) => {
571
+ if (digits === 0)
572
+ return Math.round(value);
573
+ const factor = Math.pow(10, digits);
574
+ return Math.round(value * factor) / factor;
575
+ };
576
+ const format = (value, digits) => {
577
+ const rounded = round(value, digits);
578
+ let str = rounded.toString();
579
+ if (digits > 0 && str.includes('.')) {
580
+ str = str.replace(/\.?0+$/, '');
581
+ }
582
+ return str.replace('.', separator);
583
+ };
584
+ const getFractionDigits = (value) => {
585
+ if (value < 10)
586
+ return 2;
587
+ if (value < 100)
588
+ return 1;
589
+ return 0;
590
+ };
591
+ if (lang.startsWith('ru')) {
592
+ if (num >= 1000000000000) {
593
+ const value = num / 1000000000000;
594
+ return format(value, getFractionDigits(value)) + ' трлн.';
595
+ }
596
+ if (num >= 1000000000) {
597
+ const value = num / 1000000000;
598
+ return format(value, getFractionDigits(value)) + ' млрд.';
599
+ }
600
+ if (num >= 1000000) {
601
+ const value = num / 1000000;
602
+ return format(value, getFractionDigits(value)) + ' млн.';
603
+ }
604
+ if (num >= 1000) {
605
+ const value = num / 1000;
606
+ return format(value, getFractionDigits(value)) + ' тыс.';
607
+ }
608
+ }
609
+ else {
610
+ if (num >= 1000000000000) {
611
+ const value = num / 1000000000000;
612
+ return format(value, getFractionDigits(value)) + 'T';
613
+ }
614
+ if (num >= 1000000000) {
615
+ const value = num / 1000000000;
616
+ return format(value, getFractionDigits(value)) + 'B';
617
+ }
618
+ if (num >= 1000000) {
619
+ const value = num / 1000000;
620
+ return format(value, getFractionDigits(value)) + 'M';
621
+ }
622
+ if (num >= 1000) {
623
+ const value = num / 1000;
624
+ return format(value, getFractionDigits(value)) + 'K';
625
+ }
626
+ }
627
+ return format(num, 0);
628
+ }
629
+ render() {
630
+ const lang = this.getCurrentLang();
631
+ this.textContent = this.isShortened
632
+ ? this.formatNumber(this.originalNumber, lang)
633
+ : this.originalNumber.toString();
634
+ }
635
+ }
636
+ class StepElement extends HTMLElement {
637
+ constructor() {
638
+ super();
639
+ if (this.textContent)
640
+ this.label = this.textContent;
641
+ this.innerHTML = `
642
+ <div data-sb-generated="circle"></div>
643
+ <div data-sb-generated="label"><slot></slot></div>
644
+ `;
645
+ }
646
+ static get observedAttributes() {
647
+ return ['active', 'completed', 'label'];
648
+ }
649
+ get index() {
650
+ return Array.from(this.parentNode.children).indexOf(this) + 1;
651
+ }
652
+ get active() {
653
+ return this.hasAttribute('active');
654
+ }
655
+ set active(force) {
656
+ this.toggleAttribute('active', force);
657
+ }
658
+ get completed() {
659
+ return this.hasAttribute('completed');
660
+ }
661
+ set completed(force) {
662
+ this.toggleAttribute('completed', force);
663
+ }
664
+ get label() {
665
+ return this.getAttribute('label') || "";
666
+ }
667
+ set label(value) {
668
+ this.setAttribute('label', value);
669
+ }
670
+ reset() {
671
+ this.active = false;
672
+ this.completed = false;
673
+ }
674
+ get status() {
675
+ if (this.active)
676
+ return 'active';
677
+ else if (this.completed)
678
+ return 'complete';
679
+ else
680
+ return 'uncomplete';
681
+ }
682
+ set status(value) {
683
+ this.reset();
684
+ switch (value) {
685
+ case 'complete':
686
+ this.completed = true;
687
+ break;
688
+ case 'active':
689
+ this.active = true;
690
+ break;
691
+ case 'uncomplete':
692
+ break;
693
+ default:
694
+ throw new TypeError(`Unknown status: ${value}`);
695
+ }
696
+ }
697
+ connectedCallback() {
698
+ this.querySelector('[data-sb-generated="circle"]').textContent = this.index.toString();
699
+ this.querySelector('[data-sb-generated="label"]').textContent = this.label;
700
+ const parent = this.parentElement;
701
+ const currentStep = parent.currentStep || 1;
702
+ if (this.index === currentStep)
703
+ this.active = true;
704
+ else if (this.index < currentStep)
705
+ this.completed = true;
706
+ }
707
+ }
708
+ class Stepbar extends HTMLElement {
709
+ constructor() {
710
+ super();
711
+ Object.defineProperty(this, "_observer", {
712
+ enumerable: true,
713
+ configurable: true,
714
+ writable: true,
715
+ value: void 0
716
+ });
717
+ this.attachShadow({ mode: 'open' });
718
+ this.shadowRoot.innerHTML = `
719
+ <slot></slot>
720
+ `;
721
+ }
722
+ static get observedAttributes() {
723
+ return ['current'];
724
+ }
725
+ attributeChangedCallback(name, oldValue, newValue) {
726
+ if (name === 'current') {
727
+ this.updateSteps();
728
+ }
729
+ }
730
+ connectedCallback() {
731
+ if (!this._observer) {
732
+ this._observer = new MutationObserver(() => this.updateSteps());
733
+ this._observer.observe(this, { childList: true });
734
+ }
735
+ this.updateSteps();
736
+ }
737
+ disconnectedCallback() {
738
+ if (this._observer) {
739
+ this._observer.disconnect();
740
+ }
741
+ }
742
+ updateSteps() {
743
+ const currentStep = parseInt(this.getAttribute('current') || '1');
744
+ const elements = Array.from(this.children).filter((el) => el.tagName === 'SB-ELEMENT');
745
+ elements.forEach((element, index) => {
746
+ const stepNumber = index + 1;
747
+ element.status = 'uncomplete';
748
+ if (stepNumber < currentStep) {
749
+ element.status = 'complete';
750
+ }
751
+ else if (stepNumber === currentStep) {
752
+ element.status = 'active';
753
+ }
754
+ });
755
+ }
756
+ get currentStep() {
757
+ return parseInt(this.getAttribute('current') || '1');
758
+ }
759
+ set currentStep(step) {
760
+ this.setAttribute('current', step.toString());
761
+ }
762
+ }
763
+ class HTMLFile extends HTMLElement {
764
+ constructor() {
765
+ super();
766
+ }
767
+ get src() {
768
+ return this.getAttribute('src') || '';
769
+ }
770
+ set src(value) {
771
+ if (value) {
772
+ this.setAttribute('src', value);
773
+ }
774
+ else {
775
+ this.removeAttribute('src');
776
+ }
777
+ }
778
+ static get observedAttributes() {
779
+ return ['src'];
780
+ }
781
+ connectedCallback() {
782
+ this.loadContent();
783
+ }
784
+ attributeChangedCallback(name, oldValue, newValue) {
785
+ if (name === 'src' && oldValue !== newValue && this.isConnected) {
786
+ this.loadContent();
787
+ }
788
+ }
789
+ async loadContent() {
790
+ const src = this.src;
791
+ if (!src)
792
+ return;
793
+ try {
794
+ const response = await fetch(src);
795
+ const content = await response.text();
796
+ this.innerHTML = content;
797
+ await this.executeScripts();
798
+ }
799
+ catch (error) {
800
+ this.innerHTML = `Ошибка загрузки: ${error.message}`;
801
+ }
802
+ }
803
+ async executeScripts() {
804
+ const scripts = this.querySelectorAll('script');
805
+ for (const script of scripts) {
806
+ if (script.src) {
807
+ await this.loadExternalScript(script.src);
808
+ }
809
+ else {
810
+ this.executeInlineScript(script.textContent || '');
811
+ }
812
+ script.remove();
813
+ }
814
+ }
815
+ loadExternalScript(src) {
816
+ return new Promise((resolve, reject) => {
817
+ const newScript = document.createElement('script');
818
+ newScript.src = src;
819
+ newScript.onload = resolve;
820
+ newScript.onerror = reject;
821
+ document.head.appendChild(newScript);
822
+ });
823
+ }
824
+ executeInlineScript(code) {
825
+ try {
826
+ const newScript = document.createElement('script');
827
+ newScript.textContent = code;
828
+ document.head.appendChild(newScript);
829
+ document.head.removeChild(newScript);
830
+ }
831
+ catch (error) {
832
+ console.error('Ошибка выполнения скрипта:', error);
833
+ }
834
+ }
835
+ get loaded() {
836
+ return this.hasAttribute('data-loaded');
837
+ }
838
+ reload() {
839
+ return this.loadContent();
840
+ }
841
+ get content() {
842
+ return this.innerHTML;
843
+ }
844
+ }
845
+ class ClickToCopy extends HTMLElement {
846
+ constructor() {
847
+ super();
848
+ Object.defineProperty(this, "notification", {
849
+ enumerable: true,
850
+ configurable: true,
851
+ writable: true,
852
+ value: void 0
853
+ });
854
+ this.notification = new HyperTextNotification({ backgroundColor: 'rgba(192,0,192,0.8)' });
855
+ }
856
+ get notificationText() {
857
+ return this.getAttribute('text') || "Скопировано";
858
+ }
859
+ set notificationText(value) {
860
+ if (value)
861
+ this.setAttribute('text', value);
862
+ else
863
+ this.removeAttribute('text');
864
+ }
865
+ get isNotified() {
866
+ return this.hasAttribute('notified');
867
+ }
868
+ set isNotified(value) {
869
+ if (value)
870
+ this.setAttribute('notified', '');
871
+ else
872
+ this.removeAttribute('notified');
873
+ }
874
+ connectedCallback() {
875
+ this.addEventListener('click', () => {
876
+ navigator.clipboard.writeText(this.textContent || '');
877
+ if (this.isNotified)
878
+ this.notification.show(this.notificationText);
879
+ });
880
+ }
881
+ }
882
+ customElements.define('sb-element', StepElement);
883
+ customElements.define('step-bar', Stepbar);
884
+ customElements.define('ab-num', AbbreviatedNumber);
885
+ customElements.define('include-html', HTMLFile);
886
+ customElements.define('click-to-copy', ClickToCopy);
887
+ //# sourceMappingURL=tags.js.map
888
+
889
+ // ===== File: url.js =====
890
+ "use strict";
891
+ function isAbsoluteUrl(url) {
892
+ try {
893
+ new URL(url);
894
+ return true;
895
+ }
896
+ catch (e) {
897
+ return url[0] === '/' || url[0] === '\\';
898
+ }
899
+ }
900
+ function combineUrls(baseUrl, relativeUrl) {
901
+ try {
902
+ if (!baseUrl) {
903
+ if (relativeUrl.startsWith('/'))
904
+ return relativeUrl;
905
+ return '/' + relativeUrl;
906
+ }
907
+ return new URL(relativeUrl, baseUrl).toString();
908
+ }
909
+ catch (error) {
910
+ throw new Error(`Invalid URL combination: ${baseUrl}, ${relativeUrl}`);
911
+ }
912
+ }
913
+ function getScriptSite(script) {
914
+ return new URL(script.src).origin;
915
+ }
916
+ //# sourceMappingURL=url.js.map
917
+
918
+ // ===== File: uuid.js =====
919
+ "use strict";
920
+ function generateUUIDv4() {
921
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
922
+ const r = Math.random() * 16 | 0;
923
+ const v = c === 'x' ? r : (r & 0x3 | 0x8);
924
+ return v.toString(16);
925
+ });
926
+ }
927
+ //# sourceMappingURL=uuid.js.map
928
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrenpack_js",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Универсальная frontend библиотека javascript/typescript для большинства задач",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -18,6 +18,8 @@
18
18
  },
19
19
  "homepage": "https://github.com/MagIlyasDOMA/hrenpack_js#readme",
20
20
  "devDependencies": {
21
+ "@hren/add-copyright": "^1.0.0",
22
+ "@hren/typescript-bundler": "^1.0.2",
21
23
  "typescript": "^5.9.3"
22
24
  }
23
25
  }