aprog 1.6.6 → 1.6.8
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/README.md +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/paginate.js +21 -11
- package/src/redirect.js +8 -0
- package/src/storage.js +25 -4
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ onInput: (event) => {
|
|
|
144
144
|
Загальний список методів:
|
|
145
145
|
|
|
146
146
|
- *dump(...args), dd(...args)*
|
|
147
|
-
- *redirect(url, { newTab: bool, replace: bool }), reload(delaySeconds)*
|
|
147
|
+
- *redirect(url, { newTab: bool, replace: bool }), reload(delaySeconds), validateEmail(email), validatePassword(password)*
|
|
148
148
|
- *encrypt(str), decrypt(encryptedStr)*
|
|
149
149
|
|
|
150
150
|
- *div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea, table, caption, thead, tbody, tr, th, td, pre, attachCustomTitle*
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export {
|
|
|
6
6
|
firstKey, isArray, checkArrays, isNumber, isString, isPromise, ucfirst, deepEqual, nodeListToObject
|
|
7
7
|
} from './src/aprog.js';
|
|
8
8
|
export { dump, dd } from './src/debugger.js';
|
|
9
|
-
export { redirect, reload } from './src/redirect.js';
|
|
9
|
+
export { redirect, reload, validateEmail, validatePassword } from './src/redirect.js';
|
|
10
10
|
export { router, navigateTo, navi } from './src/router.js';
|
|
11
11
|
export { encrypt, decrypt } from './src/shifrator.js';
|
|
12
12
|
export { gemini } from './src/OpenAI.js';
|
package/package.json
CHANGED
package/src/paginate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {storage} from "./storage.js";
|
|
2
2
|
import {button, div} from "./aprog.js";
|
|
3
3
|
|
|
4
|
-
export const paginate = ({ count = 0, currentPage = 1, onPageChange = () => {}, colors = {} } = {}) => {
|
|
4
|
+
export const paginate = ({ count = 0, currentPage = 1, onPageChange = () => {}, colors = {}, customStyles = {} } = {}) => {
|
|
5
5
|
const defaultColors = {
|
|
6
6
|
defaultColor: "#043458",
|
|
7
7
|
backgroundColor: "#ffffff",
|
|
@@ -9,21 +9,31 @@ export const paginate = ({ count = 0, currentPage = 1, onPageChange = () => {},
|
|
|
9
9
|
borderRadius: "0.5rem",
|
|
10
10
|
fontSize: "16px",
|
|
11
11
|
borderWidth: "0.0313rem",
|
|
12
|
-
border: "border: ${theme.borderWidth} solid ${theme.defaultColor}
|
|
12
|
+
border: "border: ${theme.borderWidth} solid ${theme.defaultColor}",
|
|
13
|
+
|
|
14
|
+
paginateBlock: {
|
|
15
|
+
width: "width: 100vw",
|
|
16
|
+
margin: "margin: 20px 0",
|
|
17
|
+
padding: "padding: 0 20px",
|
|
18
|
+
display: "display: flex",
|
|
19
|
+
alignItems: "align-items: center",
|
|
20
|
+
justifyContent: "justify-content: center",
|
|
21
|
+
gap: "gap: 5px"
|
|
22
|
+
}
|
|
13
23
|
};
|
|
14
24
|
|
|
15
|
-
const theme = { ...defaultColors, ...colors };
|
|
25
|
+
const theme = { ...defaultColors, ...colors, ...customStyles };
|
|
16
26
|
|
|
17
27
|
const styles = `
|
|
18
28
|
<style>
|
|
19
29
|
.paginate-block {
|
|
20
|
-
width
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
display
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
gap
|
|
30
|
+
${theme.paginateBlock.width};
|
|
31
|
+
${theme.paginateBlock.margin};
|
|
32
|
+
${theme.paginateBlock.padding};
|
|
33
|
+
${theme.paginateBlock.display};
|
|
34
|
+
${theme.paginateBlock.alignItems};
|
|
35
|
+
${theme.paginateBlock.justifyContent};
|
|
36
|
+
${theme.paginateBlock.gap};
|
|
27
37
|
}
|
|
28
38
|
.paginate-btn,
|
|
29
39
|
.paginate-dots,
|
|
@@ -34,7 +44,7 @@ export const paginate = ({ count = 0, currentPage = 1, onPageChange = () => {},
|
|
|
34
44
|
font-weight: 600;
|
|
35
45
|
color: ${theme.defaultColor};
|
|
36
46
|
background: ${theme.backgroundColor};
|
|
37
|
-
${theme.border}
|
|
47
|
+
${theme.border};
|
|
38
48
|
border-radius: ${theme.borderRadius};
|
|
39
49
|
cursor: pointer;
|
|
40
50
|
box-shadow: ${theme.boxShadow};
|
package/src/redirect.js
CHANGED
|
@@ -9,3 +9,11 @@ export const redirect = (url, { newTab = false, replace = false } = {}) => {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const reload = (delaySeconds = 0.7) => setTimeout(() => window.location.reload(), (delaySeconds * 1000));
|
|
12
|
+
|
|
13
|
+
export const validateEmail = (email) => {
|
|
14
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const validatePassword = (password) => {
|
|
18
|
+
return /^(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{6,}$/.test(password);
|
|
19
|
+
};
|
package/src/storage.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
export const cookie = {
|
|
2
|
+
/**
|
|
3
|
+
* Отримати значення cookie по імені
|
|
4
|
+
* @param {string} name
|
|
5
|
+
* @returns {string|null}
|
|
6
|
+
*/
|
|
2
7
|
get(name) {
|
|
3
8
|
const cookies = document.cookie.split('; ');
|
|
4
9
|
for (let cookie of cookies) {
|
|
5
|
-
|
|
10
|
+
const index = cookie.indexOf('=');
|
|
11
|
+
if (index === -1) continue;
|
|
12
|
+
|
|
13
|
+
const key = cookie.substring(0, index);
|
|
14
|
+
const value = cookie.substring(index + 1);
|
|
15
|
+
|
|
6
16
|
if (key === name) {
|
|
7
17
|
return decodeURIComponent(value);
|
|
8
18
|
}
|
|
@@ -10,18 +20,29 @@ export const cookie = {
|
|
|
10
20
|
return null;
|
|
11
21
|
},
|
|
12
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Встановити cookie
|
|
25
|
+
* @param {string} name
|
|
26
|
+
* @param {string} value
|
|
27
|
+
* @param {number} days
|
|
28
|
+
*/
|
|
13
29
|
set(name, value, days = 7) {
|
|
14
30
|
let expires = "";
|
|
15
31
|
if (days) {
|
|
16
|
-
|
|
32
|
+
const date = new Date();
|
|
17
33
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
18
34
|
expires = "; expires=" + date.toUTCString();
|
|
19
35
|
}
|
|
20
|
-
|
|
36
|
+
const safeValue = encodeURIComponent(value);
|
|
37
|
+
document.cookie = `${name}=${safeValue}${expires}; path=/`;
|
|
21
38
|
},
|
|
22
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Видалити cookie
|
|
42
|
+
* @param {string} name
|
|
43
|
+
*/
|
|
23
44
|
delete(name) {
|
|
24
|
-
document.cookie = name
|
|
45
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
25
46
|
}
|
|
26
47
|
};
|
|
27
48
|
|