dyvix-ui 0.0.2 → 0.0.4
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/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- package/LICENSE +21 -21
- package/README.md +51 -1
- package/components/modal/dependencies/animations.json +15 -5
- package/components/modal/dependencies/elements.json +31 -31
- package/components/modal/dependencies/style/elements.css +59 -59
- package/components/modal/modal.jsx +142 -144
- package/logo.png +0 -0
- package/package.json +28 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: "[BUG]"
|
|
5
|
+
labels: need triage
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS: [e.g. iOS]
|
|
28
|
+
- Browser [e.g. chrome, safari]
|
|
29
|
+
- Version [e.g. 22]
|
|
30
|
+
|
|
31
|
+
**Smartphone (please complete the following information):**
|
|
32
|
+
- Device: [e.g. iPhone6]
|
|
33
|
+
- OS: [e.g. iOS8.1]
|
|
34
|
+
- Browser [e.g. stock browser, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: "[Feature ]"
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
A clear and brief description of the feature.
|
|
12
|
+
|
|
13
|
+
## Motivation
|
|
14
|
+
Why this feature should be added?
|
|
15
|
+
|
|
16
|
+
## Details
|
|
17
|
+
How can this be implemented?
|
|
18
|
+
|
|
19
|
+
## Example Usage
|
|
20
|
+
```jsx
|
|
21
|
+
// How would this look in code?
|
|
22
|
+
```
|
|
23
|
+
## Additional details
|
|
24
|
+
Any other context, screenshots, or references.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 younisayoub
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 younisayoub
|
|
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/README.md
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img width="100" height="100" alt="Dyvix logo" src="https://raw.githubusercontent.com/younisdev/dyvix-ui/main/logo.png" />
|
|
3
|
+
<br />
|
|
4
|
+
Dyvix UI
|
|
5
|
+
</h1>
|
|
6
|
+
<h4 align="center">
|
|
7
|
+
Dyvix is an open source, modern, config-driven, animated component UI library. Beautiful by default, customizable by design.
|
|
8
|
+
</h4>
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://img.shields.io/npm/v/dyvix-ui?color=bf5af2&style=flat-square" />
|
|
11
|
+
<img src="https://img.shields.io/npm/l/dyvix-ui?color=0ea5e9&style=flat-square" />
|
|
12
|
+
<img src="https://img.shields.io/github/stars/younisdev/dyvix-ui?color=ff6ac1&style=flat-square" />
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# React
|
|
17
|
+
npm i dyvix-ui
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Basic usage
|
|
21
|
+
```jsx
|
|
22
|
+
import { Modal } from 'dyvix-ui'
|
|
23
|
+
|
|
24
|
+
function ModalExample()
|
|
25
|
+
{
|
|
26
|
+
|
|
27
|
+
return(
|
|
28
|
+
<Modal
|
|
29
|
+
title="Register"
|
|
30
|
+
type="form"
|
|
31
|
+
animation="bubble"
|
|
32
|
+
Id="register-modal"
|
|
33
|
+
Class="modal"
|
|
34
|
+
elements={[
|
|
35
|
+
{ type: "text", placeholder: ["First Name", "Last Name"], id: "name", name: ["firstName", "lastName"], className: "ex-text", amount: 2 },
|
|
36
|
+
{ type: "email", placeholder: "Email", id: "email", name: "email", className: "ex-text", amount: 1 },
|
|
37
|
+
{ type: "password", placeholder: "Password", id: "password", name: "password", className: "ex-text", amount: 1 },
|
|
38
|
+
]}
|
|
39
|
+
onSubmit={(data) => console.log(data)}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Contributing
|
|
46
|
+
|
|
47
|
+
Feel free to open meaningful issues and prs.
|
|
48
|
+
|
|
49
|
+
## Note
|
|
50
|
+
|
|
51
|
+
This project is still in early alpha expect some bugs and unfinished code.
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"element": "text",
|
|
4
|
-
"tag": "input",
|
|
5
|
-
"tag-type": "text",
|
|
6
|
-
"default-class": "modal-text",
|
|
7
|
-
"aria": {
|
|
8
|
-
"role": "textbox",
|
|
9
|
-
"aria-required": false,
|
|
10
|
-
"aria-label": ""
|
|
11
|
-
},
|
|
12
|
-
"inherited-element": ["email", "password", "search", "url", "tel"],
|
|
13
|
-
"supports-placeholder": true,
|
|
14
|
-
"is_custom": false,
|
|
15
|
-
"requires-options": false,
|
|
16
|
-
"r-variant": true
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"element": "select",
|
|
20
|
-
"tag": "select",
|
|
21
|
-
"default-class": "select",
|
|
22
|
-
"aria": {
|
|
23
|
-
"role": "combobox",
|
|
24
|
-
"aria-required": false,
|
|
25
|
-
"aria-label": ""
|
|
26
|
-
},
|
|
27
|
-
"supports-placeholder": true,
|
|
28
|
-
"is_custom": true,
|
|
29
|
-
"requires-options": true,
|
|
30
|
-
"r-variant": true
|
|
31
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"element": "text",
|
|
4
|
+
"tag": "input",
|
|
5
|
+
"tag-type": "text",
|
|
6
|
+
"default-class": "modal-text",
|
|
7
|
+
"aria": {
|
|
8
|
+
"role": "textbox",
|
|
9
|
+
"aria-required": false,
|
|
10
|
+
"aria-label": ""
|
|
11
|
+
},
|
|
12
|
+
"inherited-element": ["email", "password", "search", "url", "tel"],
|
|
13
|
+
"supports-placeholder": true,
|
|
14
|
+
"is_custom": false,
|
|
15
|
+
"requires-options": false,
|
|
16
|
+
"r-variant": true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"element": "select",
|
|
20
|
+
"tag": "select",
|
|
21
|
+
"default-class": "select",
|
|
22
|
+
"aria": {
|
|
23
|
+
"role": "combobox",
|
|
24
|
+
"aria-required": false,
|
|
25
|
+
"aria-label": ""
|
|
26
|
+
},
|
|
27
|
+
"supports-placeholder": true,
|
|
28
|
+
"is_custom": true,
|
|
29
|
+
"requires-options": true,
|
|
30
|
+
"r-variant": true
|
|
31
|
+
}
|
|
32
32
|
]
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
.modal
|
|
2
|
-
{
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
margin: 5rem auto;
|
|
6
|
-
width: 30rem;
|
|
7
|
-
height: 30rem;
|
|
8
|
-
font-family: "Geist";
|
|
9
|
-
border: 1px solid black;
|
|
10
|
-
border-radius: 50%;
|
|
11
|
-
}
|
|
12
|
-
#modal-header
|
|
13
|
-
{
|
|
14
|
-
width: 100%;
|
|
15
|
-
text-align: center;
|
|
16
|
-
font-size: xx-large;
|
|
17
|
-
font-weight: bolder;
|
|
18
|
-
margin-bottom: 0;
|
|
19
|
-
}
|
|
20
|
-
.grouped-elements
|
|
21
|
-
{
|
|
22
|
-
display: flex;
|
|
23
|
-
gap: 20px;
|
|
24
|
-
flex-direction: row;
|
|
25
|
-
margin: .5rem auto;
|
|
26
|
-
width: 80%;
|
|
27
|
-
margin-top: 1rem;
|
|
28
|
-
}
|
|
29
|
-
.grouped-elements input {
|
|
30
|
-
flex: 1;
|
|
31
|
-
max-width: 15rem;
|
|
32
|
-
min-width: 0;
|
|
33
|
-
}
|
|
34
|
-
.grouped-elements:first-of-type
|
|
35
|
-
{
|
|
36
|
-
margin-top: 3rem;
|
|
37
|
-
}
|
|
38
|
-
.modal-text
|
|
39
|
-
{
|
|
40
|
-
width: 100%;
|
|
41
|
-
border: 1px solid rgba(255,255,255,0.2);
|
|
42
|
-
border-radius: 1rem;
|
|
43
|
-
height: 25px;
|
|
44
|
-
margin: 0 auto;
|
|
45
|
-
background: transparent;
|
|
46
|
-
padding: 0.5rem 1rem;
|
|
47
|
-
}
|
|
48
|
-
.modal-text:focus {
|
|
49
|
-
outline: none;
|
|
50
|
-
border-color: #0ea5e9;
|
|
51
|
-
}
|
|
52
|
-
.modal-btn {
|
|
53
|
-
width: 8rem;
|
|
54
|
-
height: 2.5rem;
|
|
55
|
-
margin: 1rem auto;
|
|
56
|
-
border: 1px solid black;
|
|
57
|
-
border-radius: 1rem;
|
|
58
|
-
background-color: #0ea5e9;
|
|
59
|
-
margin-top: 3rem;
|
|
1
|
+
.modal
|
|
2
|
+
{
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
margin: 5rem auto;
|
|
6
|
+
width: 30rem;
|
|
7
|
+
height: 30rem;
|
|
8
|
+
font-family: "Geist";
|
|
9
|
+
border: 1px solid black;
|
|
10
|
+
border-radius: 50%;
|
|
11
|
+
}
|
|
12
|
+
#modal-header
|
|
13
|
+
{
|
|
14
|
+
width: 100%;
|
|
15
|
+
text-align: center;
|
|
16
|
+
font-size: xx-large;
|
|
17
|
+
font-weight: bolder;
|
|
18
|
+
margin-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
.grouped-elements
|
|
21
|
+
{
|
|
22
|
+
display: flex;
|
|
23
|
+
gap: 20px;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
margin: .5rem auto;
|
|
26
|
+
width: 80%;
|
|
27
|
+
margin-top: 1rem;
|
|
28
|
+
}
|
|
29
|
+
.grouped-elements input {
|
|
30
|
+
flex: 1;
|
|
31
|
+
max-width: 15rem;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
}
|
|
34
|
+
.grouped-elements:first-of-type
|
|
35
|
+
{
|
|
36
|
+
margin-top: 3rem;
|
|
37
|
+
}
|
|
38
|
+
.modal-text
|
|
39
|
+
{
|
|
40
|
+
width: 100%;
|
|
41
|
+
border: 1px solid rgba(255,255,255,0.2);
|
|
42
|
+
border-radius: 1rem;
|
|
43
|
+
height: 25px;
|
|
44
|
+
margin: 0 auto;
|
|
45
|
+
background: transparent;
|
|
46
|
+
padding: 0.5rem 1rem;
|
|
47
|
+
}
|
|
48
|
+
.modal-text:focus {
|
|
49
|
+
outline: none;
|
|
50
|
+
border-color: #0ea5e9;
|
|
51
|
+
}
|
|
52
|
+
.modal-btn {
|
|
53
|
+
width: 8rem;
|
|
54
|
+
height: 2.5rem;
|
|
55
|
+
margin: 1rem auto;
|
|
56
|
+
border: 1px solid black;
|
|
57
|
+
border-radius: 1rem;
|
|
58
|
+
background-color: #0ea5e9;
|
|
59
|
+
margin-top: 3rem;
|
|
60
60
|
}
|
|
@@ -1,144 +1,142 @@
|
|
|
1
|
-
import elementsData from "./dependencies/elements.json"
|
|
2
|
-
import SelectEngine from "../select/SelectEngine";
|
|
3
|
-
import "./dependencies/style/elements.css"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if(
|
|
64
|
-
{
|
|
65
|
-
console.error(
|
|
66
|
-
return null
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
prototype
|
|
144
|
-
*/
|
|
1
|
+
import elementsData from "./dependencies/elements.json"
|
|
2
|
+
import SelectEngine from "../select/SelectEngine";
|
|
3
|
+
import "./dependencies/style/elements.css"
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
const defaultElement = {type: "!", placeholder: ["!"], id: "!", className: "!", amount: 1 };
|
|
7
|
+
const supportedTypes = ["text", "select", "email", "password", "search", "url", "tel"]
|
|
8
|
+
const componentsMap = {"SelectEngine": SelectEngine};
|
|
9
|
+
|
|
10
|
+
function Modal({title, type, elements, animation, Id, Class, onSubmit})
|
|
11
|
+
{
|
|
12
|
+
const [data, SetData] = React.useState({});
|
|
13
|
+
const fields = SerializeData(title, type, elements, animation, Id, Class, onSubmit);
|
|
14
|
+
|
|
15
|
+
function handelInputChange(name, value)
|
|
16
|
+
{
|
|
17
|
+
SetData(prev => ({...prev, [name]: value}))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if(fields === null)
|
|
21
|
+
{
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//console.log(fields);
|
|
26
|
+
//console.log(elementsData);
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<div className={Class} id={Id}>
|
|
30
|
+
<h3 id="modal-header">{title}</h3>
|
|
31
|
+
|
|
32
|
+
{fields.map((field, i) => {
|
|
33
|
+
const elementDef = elementsData.find(e => e.element === field.type) || elementsData.find(e => e["inherited-element"]?.includes(field.type));
|
|
34
|
+
const Tag = elementDef.is_custom? componentsMap[elementDef.tag] : elementDef.tag;
|
|
35
|
+
|
|
36
|
+
return(
|
|
37
|
+
<div className="grouped-elements" key={field.id || i} >
|
|
38
|
+
{Array.from({ length: field.amount }, (_, j) => {
|
|
39
|
+
const name = Array.isArray(field.name) ? field.name[j] : field.name
|
|
40
|
+
const Tagprobs = {
|
|
41
|
+
className: elementDef["default-class"],
|
|
42
|
+
role: elementDef.aria.role,
|
|
43
|
+
...(elementDef["supports-placeholder"] && ({placeholder: Array.isArray(field.placeholder) ? field.placeholder[j] : field.placeholder })),
|
|
44
|
+
...(elementDef["tag-type"] && ({ type: elementDef["tag-type"] }))
|
|
45
|
+
}
|
|
46
|
+
return <Tag key={j} {...Tagprobs} onChange={(e) => handelInputChange(name, e.target.value)} />
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
})}
|
|
53
|
+
<button className="modal-btn" onClick={()=> onSubmit(data)}>Submit</button>
|
|
54
|
+
</div>
|
|
55
|
+
</>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function SerializeData(title, type, elements, animation, Id, Class, onSubmit)
|
|
60
|
+
{
|
|
61
|
+
const validator = ValidateInput(title, type, elements, animation, Id, Class, onSubmit)
|
|
62
|
+
|
|
63
|
+
if(validator.status !== 1)
|
|
64
|
+
{
|
|
65
|
+
console.error(validator.error)
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const normalizedElements = elements.map(ele => ({...defaultElement, ...ele}));
|
|
70
|
+
const eleValidator = validateElements(normalizedElements);
|
|
71
|
+
|
|
72
|
+
if(eleValidator.status !== 1)
|
|
73
|
+
{
|
|
74
|
+
console.error(eleValidator.error)
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return normalizedElements;
|
|
79
|
+
}
|
|
80
|
+
function ValidateInput(title, type, elements = [], animation, Id, Class, onSubmit)
|
|
81
|
+
{
|
|
82
|
+
if(!title)
|
|
83
|
+
{
|
|
84
|
+
return {status: -1, error: "Please provide a title"};
|
|
85
|
+
}
|
|
86
|
+
if (!Array.isArray(elements) || !elements.every(ele => typeof ele === 'object'))
|
|
87
|
+
{
|
|
88
|
+
return {status: -1, error: "Element should be provided as an array of objects."};
|
|
89
|
+
}
|
|
90
|
+
if(animation && typeof animation === 'string')
|
|
91
|
+
{
|
|
92
|
+
// todo when you figure out animations configue you need to write a great validation here
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if(onSubmit !== null && typeof onSubmit !== 'function')
|
|
96
|
+
{
|
|
97
|
+
return {status: -1, error: "onSubmit should be provided as a function."};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {status: 1};
|
|
101
|
+
}
|
|
102
|
+
function validateElements(elements)
|
|
103
|
+
{
|
|
104
|
+
|
|
105
|
+
for(const element of elements)
|
|
106
|
+
{
|
|
107
|
+
if(!supportedTypes.includes(element.type))
|
|
108
|
+
{
|
|
109
|
+
return {status: -1, error: "Elements should include a valid type."};
|
|
110
|
+
}
|
|
111
|
+
if(element.amount < 1 || element.amount > 3)
|
|
112
|
+
{
|
|
113
|
+
return {status: -1, error: "Element amount should be positive and less than 3."};
|
|
114
|
+
}
|
|
115
|
+
else if (element.amount > 1)
|
|
116
|
+
{
|
|
117
|
+
if (!Array.isArray(element.placeholder) || element.placeholder.length !== element.amount)
|
|
118
|
+
{
|
|
119
|
+
return {status: -1, error: "Element placeholder should be provided as an array of the same length as the provided amount."};
|
|
120
|
+
}
|
|
121
|
+
if (!Array.isArray(element.name) || element.name.length !== element.amount)
|
|
122
|
+
{
|
|
123
|
+
return {status: -1, error: "Element name should be provided as an array of the same length as the provided amount."};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
{
|
|
128
|
+
if(typeof element.placeholder !== "string")
|
|
129
|
+
{
|
|
130
|
+
return {status: -1, error: "Element placeholder should be provided as string when the amount is set to 1."};
|
|
131
|
+
}
|
|
132
|
+
if(typeof element.name !== "string")
|
|
133
|
+
{
|
|
134
|
+
return {status: -1, error: "Element name should be provided as string when the amount is set to 1."};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return {status: 1};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default Modal;
|
package/logo.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dyvix-ui",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
1
|
+
{
|
|
2
|
+
"name": "dyvix-ui",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "Dyvix is an open source, modern, config-driven, animated component UI library. Beautiful by default, customizable by design.",
|
|
5
|
+
"main": "index.jsx",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"react": ">=18.0.0",
|
|
10
|
+
"react-dom": ">=18.0.0"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"react": "^18.3.1",
|
|
14
|
+
"react-dom": "^18.3.1",
|
|
15
|
+
"vite": "^8.0.0"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"ui-kit",
|
|
20
|
+
"config",
|
|
21
|
+
"gsap",
|
|
22
|
+
"animation",
|
|
23
|
+
"components",
|
|
24
|
+
"ui-library"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"gsap": "^3.14.2"
|
|
28
|
+
}
|
|
7
29
|
}
|