@cocreate/validation 1.16.0 → 1.16.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## [1.16.2](https://github.com/CoCreate-app/CoCreate-validation/compare/v1.16.1...v1.16.2) (2025-04-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added css-loader ([37549c8](https://github.com/CoCreate-app/CoCreate-validation/commit/37549c8543a4787532613702ba14d251f54af287))
7
+ * update query attributes ([806aeb1](https://github.com/CoCreate-app/CoCreate-validation/commit/806aeb1890e71f06ca0cb0a6f38a643fcfe31135))
8
+ * updated cocreate modules versions ([b32ac43](https://github.com/CoCreate-app/CoCreate-validation/commit/b32ac437b26b7950f6ea385a63017bdf7640ba71))
9
+ * webpack.config and devdependencies ([ee37891](https://github.com/CoCreate-app/CoCreate-validation/commit/ee37891783b587d77c8d25c630cabdfd0f7a39b3))
10
+
11
+ ## [1.16.1](https://github.com/CoCreate-app/CoCreate-validation/compare/v1.16.0...v1.16.1) (2025-04-11)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * dispatch end event on action element rather than document ([e415c5f](https://github.com/CoCreate-app/CoCreate-validation/commit/e415c5fb8da8e1892cdb530d606c8453e2f1d158))
17
+
1
18
  # [1.16.0](https://github.com/CoCreate-app/CoCreate-validation/compare/v1.15.6...v1.16.0) (2024-11-04)
2
19
 
3
20
 
package/docs/index.html CHANGED
@@ -1,263 +1,263 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <title>CoCreate-validation Documentation | CoCreateJS</title>
8
- <link
9
- rel="icon"
10
- type="image/png"
11
- sizes="32x32"
12
- href="https://cocreate.app/images/favicon.ico" />
13
- <meta
14
- name="description"
15
- content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
16
- <meta
17
- name="keywords"
18
- content="helper classes, utility classes, css framework, css library, inline style classes" />
19
- <meta name="robots" content="index,follow" />
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <title>CoCreate-validation Documentation | CoCreateJS</title>
8
+ <link
9
+ rel="icon"
10
+ type="image/png"
11
+ sizes="32x32"
12
+ href="https://cocreate.app/images/favicon.ico" />
13
+ <meta
14
+ name="description"
15
+ content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
16
+ <meta
17
+ name="keywords"
18
+ content="helper classes, utility classes, css framework, css library, inline style classes" />
19
+ <meta name="robots" content="index,follow" />
20
20
 
21
- <link
22
- rel="stylesheet"
23
- href="../index.css"
24
- array="files"
25
- object="60888216117c640e7596303f"
26
- key="src"
27
- type="text/css"
28
- save="true" />
21
+ <link
22
+ rel="stylesheet"
23
+ href="../index.css"
24
+ array="files"
25
+ object="60888216117c640e7596303f"
26
+ key="src"
27
+ type="text/css"
28
+ save="true" />
29
29
 
30
- <link rel="manifest" href="/manifest.webmanifest" />
31
- </head>
30
+ <link rel="manifest" href="/manifest.webmanifest" />
31
+ </head>
32
32
 
33
- <body>
34
- <!-- Navbar -->
35
- <nav
36
- class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
37
- content_id="content"
38
- scroll="sticky-nav,"
39
- scroll-up="5"
40
- scroll-down="5"
41
- path="../"
42
- src="../components/navbar.html"></nav>
43
- <sidenav
44
- id="menuL"
45
- class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
46
- resizable
47
- resize-selector="[content_id='content']"
48
- resize-property="margin-left"
49
- resize-value="width">
50
- <menu
51
- array="files"
52
- object="603717b07de7fb350ae9fec8"
53
- key="src"></menu>
54
- <div resize="right"></div>
55
- </sidenav>
56
- <main
57
- class="padding-top:15px padding:15px@lg@xl"
58
- content_id="content"
59
- id="cocreate-validation">
60
- <div
61
- class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
62
- <div class="display:flex align-items:center">
63
- <h2>CoCreate-validation</h2>
64
- </div>
65
- <div
66
- class="display:flex align-items:center font-size:20px"
67
- share-height="600"
68
- share-width="500"
69
- share-media="https://via.placeholder.com/300/09f/fff.png">
70
- <a
71
- href="https://github.com/CoCreate-app/CoCreate-validation"
72
- target="_blank"
73
- class="margin-right:15px"
74
- ><i src="/assets/svg/github.svg"></i
75
- ></a>
76
- <a
77
- class="margin-right:15px share"
78
- share-network="twitter"
79
- title="Share on twitter"
80
- ><i src="/assets/svg/twitter.svg"></i
81
- ></a>
82
- <a
83
- class="margin-right:15px share"
84
- share-network="facebook"
85
- title="Share on Facebook"
86
- ><i src="/assets/svg/facebook.svg"></i
87
- ></a>
88
- <a
89
- class="margin-right:15px share"
90
- share-network="instagram"
91
- title="Share on instagram"
92
- ><i src="/assets/svg/instagram.svg"></i
93
- ></a>
94
- <a
95
- class="margin-right:15px share"
96
- share-network="share"
97
- title="Share on share"
98
- ><i src="/assets/svg/share-alt.svg"></i
99
- ></a>
100
- </div>
101
- </div>
102
- <h1 class="max-width:500px margin:20px_10px">
103
- A headless vinilla javascript micro component. Easy
104
- configuration using HTML5 attributes or Javscript api.
105
- </h1>
106
- <div id="validation-section" class="display:flex flex-wrap:wrap">
107
- <div class="flex-grow:1 width:300px padding:20px_10px">
108
- <h2
109
- class="border-bottom:1px_solid_lightgrey padding:5px_0px">
110
- Install
111
- </h2>
112
- <pre
113
- class="margin-top:15px"><code class="language-javascript">npm install cocreate-validation</code></pre>
114
- <p class="padding:10px_0px">Or you can use cdn link:</p>
115
- <pre><code class="language-javascript">https://cdn.cocreate.app/js/CoCreate-validation.min.js</code></pre>
33
+ <body>
34
+ <!-- Navbar -->
35
+ <nav
36
+ class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
37
+ content_id="content"
38
+ scroll="sticky-nav,"
39
+ scroll-up="5"
40
+ scroll-down="5"
41
+ path="../"
42
+ src="../components/navbar.html"></nav>
43
+ <sidenav
44
+ id="menuL"
45
+ class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
46
+ resizable
47
+ resize-query="[content_id='content']"
48
+ resize-property="margin-left"
49
+ resize-value="width">
50
+ <menu
51
+ array="files"
52
+ object="603717b07de7fb350ae9fec8"
53
+ key="src"></menu>
54
+ <div resize="right"></div>
55
+ </sidenav>
56
+ <main
57
+ class="padding-top:15px padding:15px@lg@xl"
58
+ content_id="content"
59
+ id="cocreate-validation">
60
+ <div
61
+ class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
62
+ <div class="display:flex align-items:center">
63
+ <h2>CoCreate-validation</h2>
64
+ </div>
65
+ <div
66
+ class="display:flex align-items:center font-size:20px"
67
+ share-height="600"
68
+ share-width="500"
69
+ share-media="https://via.placeholder.com/300/09f/fff.png">
70
+ <a
71
+ href="https://github.com/CoCreate-app/CoCreate-validation"
72
+ target="_blank"
73
+ class="margin-right:15px"
74
+ ><i src="/assets/svg/github.svg"></i
75
+ ></a>
76
+ <a
77
+ class="margin-right:15px share"
78
+ share-network="twitter"
79
+ title="Share on twitter"
80
+ ><i src="/assets/svg/twitter.svg"></i
81
+ ></a>
82
+ <a
83
+ class="margin-right:15px share"
84
+ share-network="facebook"
85
+ title="Share on Facebook"
86
+ ><i src="/assets/svg/facebook.svg"></i
87
+ ></a>
88
+ <a
89
+ class="margin-right:15px share"
90
+ share-network="instagram"
91
+ title="Share on instagram"
92
+ ><i src="/assets/svg/instagram.svg"></i
93
+ ></a>
94
+ <a
95
+ class="margin-right:15px share"
96
+ share-network="share"
97
+ title="Share on share"
98
+ ><i src="/assets/svg/share-alt.svg"></i
99
+ ></a>
100
+ </div>
101
+ </div>
102
+ <h1 class="max-width:500px margin:20px_10px">
103
+ A headless vinilla javascript micro component. Easy
104
+ configuration using HTML5 attributes or Javscript api.
105
+ </h1>
106
+ <div id="validation-section" class="display:flex flex-wrap:wrap">
107
+ <div class="flex-grow:1 width:300px padding:20px_10px">
108
+ <h2
109
+ class="border-bottom:1px_solid_lightgrey padding:5px_0px">
110
+ Install
111
+ </h2>
112
+ <pre
113
+ class="margin-top:15px"><code class="language-javascript">npm install cocreate-validation</code></pre>
114
+ <p class="padding:10px_0px">Or you can use cdn link:</p>
115
+ <pre><code class="language-javascript">https://cdn.cocreate.app/js/CoCreate-validation.min.js</code></pre>
116
116
 
117
- <h2
118
- class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
119
- Usage
120
- </h2>
121
- <p class="padding:10px_0px">validation usage content</p>
122
- <pre><code class="language-html">&lt;div&gt;&lt;/div&gt;</code></pre>
117
+ <h2
118
+ class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
119
+ Usage
120
+ </h2>
121
+ <p class="padding:10px_0px">validation usage content</p>
122
+ <pre><code class="language-html">&lt;div&gt;&lt;/div&gt;</code></pre>
123
123
 
124
- <h2
125
- class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
126
- Reference
127
- </h2>
128
- <p class="padding:10px_0px">
129
- This is validation reference content
130
- </p>
131
- <pre><code class="language-javascript">&lt;div&gt;&lt;/div&gt;</code></pre>
132
- <p class="padding:10px_0px">
133
- This is validation reference content
134
- </p>
124
+ <h2
125
+ class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
126
+ Reference
127
+ </h2>
128
+ <p class="padding:10px_0px">
129
+ This is validation reference content
130
+ </p>
131
+ <pre><code class="language-javascript">&lt;div&gt;&lt;/div&gt;</code></pre>
132
+ <p class="padding:10px_0px">
133
+ This is validation reference content
134
+ </p>
135
135
 
136
- <h2
137
- class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
138
- Attributes
139
- </h2>
140
- <ul class="list-style-type:none">
141
- <li
142
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
143
- <h4>
144
- <span>validation</span>
145
- <span class="cocreate-badge success"
146
- >string</span
147
- >
148
- <span class="cocreate-badge warning"
149
- >optional</span
150
- >
151
- </h4>
152
- <p>validation-attribute</p>
153
- </li>
154
- <li
155
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
156
- <h4>
157
- <span>validation</span>
158
- <span class="cocreate-badge success"
159
- >string</span
160
- >
161
- <span class="cocreate-badge warning"
162
- >optional</span
163
- >
164
- </h4>
165
- <p>validation-attribute</p>
166
- </li>
167
- </ul>
168
- </div>
136
+ <h2
137
+ class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
138
+ Attributes
139
+ </h2>
140
+ <ul class="list-style-type:none">
141
+ <li
142
+ class="padding:15px_0px border-bottom:1px_solid_lightgrey">
143
+ <h4>
144
+ <span>validation</span>
145
+ <span class="cocreate-badge success"
146
+ >string</span
147
+ >
148
+ <span class="cocreate-badge warning"
149
+ >optional</span
150
+ >
151
+ </h4>
152
+ <p>validation-attribute</p>
153
+ </li>
154
+ <li
155
+ class="padding:15px_0px border-bottom:1px_solid_lightgrey">
156
+ <h4>
157
+ <span>validation</span>
158
+ <span class="cocreate-badge success"
159
+ >string</span
160
+ >
161
+ <span class="cocreate-badge warning"
162
+ >optional</span
163
+ >
164
+ </h4>
165
+ <p>validation-attribute</p>
166
+ </li>
167
+ </ul>
168
+ </div>
169
169
 
170
- <div
171
- class="flex-grow:1 width:300px padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
172
- <!-- SandBox -->
173
- <h2
174
- class="border-bottom:1px_solid_lightgrey padding:5px_0px">
175
- Demo
176
- </h2>
177
- <div
178
- class="position:sticky top:0 padding:10px_0px height:100vh">
179
- <!-- SandBox -->
180
- <div
181
- class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
182
- id="playground">
183
- <div
184
- id="demo-code"
185
- resizable
186
- class="position:relative height:50%">
187
- <textarea
188
- type="code"
189
- lang="html"
190
- array="demos"
191
- object=""
192
- key="demo"
193
- save="false"
194
- id="demo"
195
- input-selector=".demopreview"
196
- input-attribute="value"
197
- input-events="input, onload"
198
- class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
199
- <div
200
- resize="bottom"
201
- class="background:lightgrey"></div>
202
- </div>
170
+ <div
171
+ class="flex-grow:1 width:300px padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
172
+ <!-- SandBox -->
173
+ <h2
174
+ class="border-bottom:1px_solid_lightgrey padding:5px_0px">
175
+ Demo
176
+ </h2>
177
+ <div
178
+ class="position:sticky top:0 padding:10px_0px height:100vh">
179
+ <!-- SandBox -->
180
+ <div
181
+ class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
182
+ id="playground">
183
+ <div
184
+ id="demo-code"
185
+ resizable
186
+ class="position:relative height:50%">
187
+ <textarea
188
+ type="code"
189
+ lang="html"
190
+ array="demos"
191
+ object=""
192
+ key="demo"
193
+ save="false"
194
+ id="demo"
195
+ input-query=".demopreview"
196
+ input-attribute="value"
197
+ input-events="input, onload"
198
+ class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
199
+ <div
200
+ resize="bottom"
201
+ class="background:lightgrey"></div>
202
+ </div>
203
203
 
204
- <div
205
- id="demo-preview"
206
- class="position:relative overflow:auto background-color:white">
207
- <div class="demopreview padding:20px"></div>
208
- </div>
204
+ <div
205
+ id="demo-preview"
206
+ class="position:relative overflow:auto background-color:white">
207
+ <div class="demopreview padding:20px"></div>
208
+ </div>
209
209
 
210
- <div
211
- class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
212
- <a
213
- class="margin-right:10px"
214
- id="eye"
215
- show="#eye-slash"
216
- hide="#eye, #demo-preview"
217
- toggle="code-height"
218
- toggle-selector="#demo-code"
219
- ><i
220
- class="height:18px"
221
- src="/assets/svg/eye.svg"></i
222
- ></a>
223
- <a
224
- class="margin-right:10px"
225
- hidden
226
- id="eye-slash"
227
- show="#eye, #demo-preview"
228
- hide="#eye-slash"
229
- toggle="code-height"
230
- toggle-selector="#demo-code"
231
- ><i src="/assets/svg/eye-slash.svg"></i
232
- ></a>
233
- <a
234
- class="margin-right:10px"
235
- id="code"
236
- show="#code-slash"
237
- hide="#code, #demo-code"
238
- ><i src="/assets/svg/code.svg"></i
239
- ></a>
240
- <a
241
- class="margin-right:10px"
242
- hidden
243
- id="code-slash"
244
- show="#code, #demo-code"
245
- hide="#code-slash"
246
- ><i
247
- class="height:18px"
248
- src="/assets/svg/code.svg"></i
249
- ></a>
250
- <a
251
- class="margin-right:5px"
252
- fullscreen
253
- fullscreen-selector="#playground"></a>
254
- </div>
255
- </div>
256
- <!-- End SandBox -->
257
- </div>
258
- </div>
259
- </div>
260
- </main>
261
- <script src="https://CoCreate.app/dist/CoCreate.js"></script>
262
- </body>
210
+ <div
211
+ class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
212
+ <a
213
+ class="margin-right:10px"
214
+ id="eye"
215
+ show="#eye-slash"
216
+ hide="#eye, #demo-preview"
217
+ toggle="code-height"
218
+ toggle-query="#demo-code"
219
+ ><i
220
+ class="height:18px"
221
+ src="/assets/svg/eye.svg"></i
222
+ ></a>
223
+ <a
224
+ class="margin-right:10px"
225
+ hidden
226
+ id="eye-slash"
227
+ show="#eye, #demo-preview"
228
+ hide="#eye-slash"
229
+ toggle="code-height"
230
+ toggle-query="#demo-code"
231
+ ><i src="/assets/svg/eye-slash.svg"></i
232
+ ></a>
233
+ <a
234
+ class="margin-right:10px"
235
+ id="code"
236
+ show="#code-slash"
237
+ hide="#code, #demo-code"
238
+ ><i src="/assets/svg/code.svg"></i
239
+ ></a>
240
+ <a
241
+ class="margin-right:10px"
242
+ hidden
243
+ id="code-slash"
244
+ show="#code, #demo-code"
245
+ hide="#code-slash"
246
+ ><i
247
+ class="height:18px"
248
+ src="/assets/svg/code.svg"></i
249
+ ></a>
250
+ <a
251
+ class="margin-right:5px"
252
+ fullscreen
253
+ fullscreen-query="#playground"></a>
254
+ </div>
255
+ </div>
256
+ <!-- End SandBox -->
257
+ </div>
258
+ </div>
259
+ </div>
260
+ </main>
261
+ <script src="https://CoCreate.app/dist/CoCreate.js"></script>
262
+ </body>
263
263
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/validation",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
4
4
  "description": "A simple validation component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "validation",
@@ -45,20 +45,16 @@
45
45
  },
46
46
  "main": "./src/index.js",
47
47
  "devDependencies": {
48
- "@babel/core": "^7.9.6",
49
- "@babel/preset-env": "^7.9.6",
50
- "babel-loader": "^8.1.0",
51
- "clean-webpack-plugin": "^3.0.0",
52
- "file-loader": "^6.2.0",
48
+ "css-loader": "^5.1.3",
49
+ "esbuild": "^0.25.2",
50
+ "esbuild-loader": "^4.3.0",
53
51
  "mini-css-extract-plugin": "^1.5.0",
54
- "style-loader": "^3.3.1",
55
- "terser-webpack-plugin": "^5.1.1",
56
52
  "webpack": "^5.24.4",
57
53
  "webpack-cli": "^4.5.0",
58
54
  "webpack-log": "^3.0.1"
59
55
  },
60
56
  "dependencies": {
61
- "@cocreate/actions": "^1.18.2",
62
- "@cocreate/render": "^1.41.0"
57
+ "@cocreate/actions": "^1.21.0",
58
+ "@cocreate/render": "^1.45.1"
63
59
  }
64
60
  }
package/src/index.js CHANGED
@@ -6,81 +6,82 @@
6
6
  ********************************************************************************/
7
7
 
8
8
  /*globals CustomEvent*/
9
- import actions from '@cocreate/actions';
9
+ import actions from "@cocreate/actions";
10
10
  // import render from '@cocreate/render';
11
- import { matches } from './validations/matches';
12
- import { required } from './validations/required';
13
- import { unique } from './validations/unique';
14
- import { subdomain } from './validations/subdomain';
15
- import { length } from './validations/length';
16
- import { email } from './validations/email';
11
+ import { matches } from "./validations/matches";
12
+ import { required } from "./validations/required";
13
+ import { unique } from "./validations/unique";
14
+ import { subdomain } from "./validations/subdomain";
15
+ import { length } from "./validations/length";
16
+ import { email } from "./validations/email";
17
17
 
18
18
  const validations = new Map();
19
- validations.set('matches', matches);
20
- validations.set('required', required);
21
- validations.set('subdomain', subdomain);
22
- validations.set('unique', unique);
23
- validations.set('length', length);
24
- validations.set('email', email);
19
+ validations.set("matches", matches);
20
+ validations.set("required", required);
21
+ validations.set("subdomain", subdomain);
22
+ validations.set("unique", unique);
23
+ validations.set("length", length);
24
+ validations.set("email", email);
25
25
 
26
- const selectors = '[matches], [required], [unique], [subdomain], [length], [email]';
26
+ const selectors =
27
+ "[matches], [required], [unique], [subdomain], [length], [email]";
27
28
 
28
- async function validate(btn, params) {
29
- let validateElements;
30
- let validateSelectors = [];
31
- let failedElements = [];
29
+ async function validate(action) {
30
+ let btn = action.element;
31
+ let params = action.params;
32
+ let validateElements;
33
+ let validateSelectors = [];
34
+ let failedElements = [];
32
35
 
33
- if (params) {
34
- let selector = params
35
- for (let [validation] of validations) {
36
- let vSelctor = `${selector}[${validation}]`;
37
- validateSelectors.push(vSelctor);
38
- }
39
- let validSelectors = validateSelectors.join(', ');
40
- validateElements = document.querySelectorAll(validSelectors);
41
- if (!validateElements.length) {
42
- let element = document.querySelector(selector);
43
- if (element)
44
- validateElements = element.querySelectorAll(selectors);
45
- }
46
- } else {
47
- let element = btn.closest('form');
48
- validateElements = element.querySelectorAll(selectors);
49
- }
36
+ if (params) {
37
+ let selector = params;
38
+ for (let [validation] of validations) {
39
+ let vSelctor = `${selector}[${validation}]`;
40
+ validateSelectors.push(vSelctor);
41
+ }
42
+ let validSelectors = validateSelectors.join(", ");
43
+ validateElements = document.querySelectorAll(validSelectors);
44
+ if (!validateElements.length) {
45
+ let element = document.querySelector(selector);
46
+ if (element) validateElements = element.querySelectorAll(selectors);
47
+ }
48
+ } else {
49
+ let element = btn.closest("form");
50
+ validateElements = element.querySelectorAll(selectors);
51
+ }
50
52
 
53
+ for (let [validation, func] of validations) {
54
+ let elements = [];
55
+ for (let element of validateElements) {
56
+ // let validationSelectors = element.getAttribute('validate').replace(/ /g, '').split(',');
57
+ if (element.hasAttribute(validation)) {
58
+ elements.push(element);
59
+ }
60
+ }
61
+ if (elements.length) {
62
+ let failedEls = await func(elements);
63
+ if (failedEls) failedElements.push(failedEls);
64
+ }
65
+ }
66
+ for (let element of validateElements) {
67
+ let isValid = element.getAttribute("validation");
68
+ if (isValid == "false") failedElements.push(element);
69
+ }
51
70
 
52
- for (let [validation, func] of validations) {
53
- let elements = [];
54
- for (let element of validateElements) {
55
- // let validationSelectors = element.getAttribute('validate').replace(/ /g, '').split(',');
56
- if (element.hasAttribute(validation)) {
57
- elements.push(element);
58
- }
59
- }
60
- if (elements.length) {
61
- let failedEls = await func(elements);
62
- if (failedEls)
63
- failedElements.push(failedEls);
64
- }
65
- }
66
- for (let element of validateElements) {
67
- let isValid = element.getAttribute('validation');
68
- if (isValid == 'false')
69
- failedElements.push(element);
70
- }
71
-
72
- if (failedElements.length == 0) {
73
- document.dispatchEvent(new CustomEvent('validate', {
74
- detail: {}
75
- }));
76
- }
71
+ if (failedElements.length == 0) {
72
+ btn.dispatchEvent(
73
+ new CustomEvent("validate", {
74
+ detail: {}
75
+ })
76
+ );
77
+ }
77
78
  }
78
79
 
79
80
  actions.init({
80
- name: "validate",
81
- callback: (action) => {
82
- validate(action.element, action.params);
83
- }
81
+ name: "validate",
82
+ callback: (action) => {
83
+ validate(action);
84
+ }
84
85
  });
85
86
 
86
- export default { validations };
87
+ export default { validations };
package/webpack.config.js CHANGED
@@ -1,90 +1,65 @@
1
- const path = require("path")
2
- const TerserPlugin = require("terser-webpack-plugin")
3
- const MiniCssExtractPlugin = require("mini-css-extract-plugin")
4
- const { CleanWebpackPlugin } = require("clean-webpack-plugin")
5
-
6
- module.exports = (env, argv) => {
7
- let isProduction = false
8
- if (argv.mode === 'production')
9
- isProduction = true
10
-
11
- const config = {
12
- entry: {
13
- "CoCreate-validation": "./src/index.js",
14
- },
15
- output: {
16
- path: path.resolve(__dirname, "dist"),
17
- filename: isProduction ? "[name].min.js" : "[name].js",
18
- libraryTarget: "umd",
19
- libraryExport: "default",
20
- library: ["CoCreate", "validation"],
21
- globalObject: "this",
22
- },
23
-
24
- plugins: [
25
- new CleanWebpackPlugin(),
26
- new MiniCssExtractPlugin({
27
- filename: "[name].css",
28
- }),
29
- ],
30
- // Default mode for Webpack is production.
31
- // Depending on mode Webpack will apply different things
32
- // on final bundle. For now we don't need production's JavaScript
33
- // minifying and other thing so let's set mode to development
34
- mode: isProduction ? "production" : "development",
35
- module: {
36
- rules: [
37
- {
38
- test: /.js$/,
39
- exclude: /(node_modules)/,
40
- use: {
41
- loader: "babel-loader",
42
- options: {
43
- plugins: ["@babel/plugin-transform-modules-commonjs"],
44
- },
45
- },
46
- },
47
- {
48
- test: /.css$/i,
49
- use: [
50
- { loader: "style-loader", options: { injectType: "linkTag" } },
51
- "file-loader",
52
- ],
53
- },
54
- ],
55
- },
56
-
57
- // add source map
58
- ...(isProduction ? {} : { devtool: "eval-source-map" }),
59
-
60
- optimization: {
61
- minimize: true,
62
- minimizer: [
63
- new TerserPlugin({
64
- extractComments: true,
65
- // cache: true,
66
- parallel: true,
67
- // sourceMap: true, // Must be set to true if using source-maps in production
68
- terserOptions: {
69
- // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
70
- // extractComments: 'all',
71
- compress: {
72
- drop_console: true,
73
- },
74
- },
75
- }),
76
- ],
77
- splitChunks: {
78
- chunks: "all",
79
- minSize: 200,
80
- // maxSize: 99999,
81
- //minChunks: 1,
82
-
83
- cacheGroups: {
84
- defaultVendors: false,
85
- },
86
- },
87
- },
88
- }
89
- return config
90
- }
1
+ const path = require("path");
2
+ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
3
+ const { EsbuildPlugin } = require("esbuild-loader");
4
+ const { FileUploader } = require("@cocreate/webpack");
5
+
6
+ module.exports = async (env, argv) => {
7
+ const isProduction = argv && argv.mode === "production";
8
+ const config = {
9
+ entry: {
10
+ "CoCreate-validation": "./src/index.js"
11
+ },
12
+ output: {
13
+ path: path.resolve(__dirname, "dist"),
14
+ filename: isProduction ? "[name].min.js" : "[name].js",
15
+ libraryExport: "default",
16
+ library: ["CoCreate", "validation"],
17
+ clean: true
18
+ },
19
+ plugins: [
20
+ new MiniCssExtractPlugin({
21
+ filename: isProduction ? "[name].min.css" : "[name].css"
22
+ }),
23
+ new FileUploader(env, argv)
24
+ ],
25
+ mode: isProduction ? "production" : "development",
26
+ devtool: isProduction ? "source-map" : "eval-source-map",
27
+ module: {
28
+ rules: [
29
+ {
30
+ test: /.js$/,
31
+ exclude: /node_modules/,
32
+ use: {
33
+ loader: "esbuild-loader",
34
+ options: {
35
+ loader: "js",
36
+ target: "es2017"
37
+ }
38
+ }
39
+ },
40
+ {
41
+ test: /.css$/i,
42
+ use: [MiniCssExtractPlugin.loader, "css-loader"]
43
+ }
44
+ ]
45
+ },
46
+ optimization: {
47
+ minimize: isProduction,
48
+ minimizer: [
49
+ new EsbuildPlugin({
50
+ target: "es2017",
51
+ css: true
52
+ })
53
+ ],
54
+ splitChunks: {
55
+ cacheGroups: {
56
+ defaultVendors: false
57
+ }
58
+ }
59
+ },
60
+ performance: {
61
+ hints: isProduction ? "warning" : false
62
+ }
63
+ };
64
+ return config;
65
+ };