@cocreate/unique 1.11.22 → 1.12.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.
- package/CHANGELOG.md +22 -0
- package/CoCreate.config.js +2 -2
- package/demo/index.html +4 -4
- package/docs/index.html +28 -28
- package/package.json +4 -5
- package/src/client.js +11 -9
- package/src/server.js +7 -5
- package/webpack.config.js +79 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.11.23...v1.12.0) (2023-08-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* crud attributes renamed ([3bd1c3c](https://github.com/CoCreate-app/CoCreate-unique/commit/3bd1c3c216a38b079bdb208517dfe0973b347992))
|
|
7
|
+
* replace -target -selector ([ebc7301](https://github.com/CoCreate-app/CoCreate-unique/commit/ebc73012cd92322d8fa235f9c63f32388afc957b))
|
|
8
|
+
* webpack.config and package.json make use of mode=production instead of process.env ([2397f48](https://github.com/CoCreate-app/CoCreate-unique/commit/2397f481daf071537c0e6ec12808d7f594f88071))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* name attribute and variable renamed to key ([16d5987](https://github.com/CoCreate-app/CoCreate-unique/commit/16d5987e3f9f11843b078584ac87b1f02344c31c))
|
|
14
|
+
* update template_id to render-selector attribute. update filter attributes to filter selector-attributes ([bd5a958](https://github.com/CoCreate-app/CoCreate-unique/commit/bd5a958d8000f559cc14f64b6e98e3a9349039e3))
|
|
15
|
+
|
|
16
|
+
## [1.11.23](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.11.22...v1.11.23) (2023-06-14)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* Update dependencies versions for [@cocreate](https://github.com/cocreate) libraries ([03623fc](https://github.com/CoCreate-app/CoCreate-unique/commit/03623fc5a9a20e92d87f65834115061df64b90e2))
|
|
22
|
+
|
|
1
23
|
## [1.11.22](https://github.com/CoCreate-app/CoCreate-unique/compare/v1.11.21...v1.11.22) (2023-06-11)
|
|
2
24
|
|
|
3
25
|
|
package/CoCreate.config.js
CHANGED
package/demo/index.html
CHANGED
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
</style>
|
|
36
36
|
|
|
37
37
|
<body class="padding:20px">
|
|
38
|
-
<form
|
|
38
|
+
<form array="users" object realtime="false">
|
|
39
39
|
<input
|
|
40
40
|
type="text"
|
|
41
41
|
unique
|
|
42
42
|
class="floating-label"
|
|
43
43
|
placeholder="Name"
|
|
44
|
-
|
|
44
|
+
key="name" />
|
|
45
45
|
<input
|
|
46
46
|
type="text"
|
|
47
47
|
unique
|
|
48
48
|
class="floating-label"
|
|
49
49
|
placeholder="Email"
|
|
50
|
-
|
|
50
|
+
key="email" />
|
|
51
51
|
<button
|
|
52
52
|
actions="validate, save"
|
|
53
53
|
class="position:fixed bottom:15px right:15px background:dodgerblue grow-hover border-radius:50% padding:15px">
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
</button>
|
|
58
58
|
</form>
|
|
59
59
|
|
|
60
|
-
<div template
|
|
60
|
+
<div template>
|
|
61
61
|
<p class="{{status}} {{type}}">{{message}}</p>
|
|
62
62
|
<a actions="removeElement">X</a>
|
|
63
63
|
</div>
|
package/docs/index.html
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
sizes="32x32"
|
|
12
12
|
href="https://cocreate.app/images/favicon.ico" />
|
|
13
13
|
<meta
|
|
14
|
-
|
|
14
|
+
key="description"
|
|
15
15
|
content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
|
|
16
16
|
<meta
|
|
17
|
-
|
|
17
|
+
key="keywords"
|
|
18
18
|
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
<meta
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
<link
|
|
30
30
|
rel="stylesheet"
|
|
31
31
|
href="/docs/index.css"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
array="files"
|
|
33
|
+
object="60888216117c640e7596303f"
|
|
34
|
+
key="src"
|
|
35
35
|
type="text/css"
|
|
36
36
|
save="true" />
|
|
37
37
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
scroll="sticky-nav,hide-nav"
|
|
45
45
|
scroll-up="10"
|
|
46
46
|
scroll-down="10"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
array="files"
|
|
48
|
+
object="60395ef42b3ac232657040fd"
|
|
49
|
+
key="src"></nav>
|
|
50
50
|
<sidenav
|
|
51
51
|
id="menuL"
|
|
52
52
|
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
53
53
|
resizable
|
|
54
|
-
resize-
|
|
54
|
+
resize-selector="[content_id='content']"
|
|
55
55
|
resize-property="margin-left"
|
|
56
56
|
resize-value="width">
|
|
57
57
|
<menu
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
array="files"
|
|
59
|
+
object="603717b07de7fb350ae9fec8"
|
|
60
|
+
key="src"></menu>
|
|
61
61
|
<div resize="right"></div>
|
|
62
62
|
</sidenav>
|
|
63
63
|
<main
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
share-width="700"
|
|
81
81
|
share-media="https://cdn.cocreate.app/docs/unique.png"
|
|
82
82
|
hover="display:block!important"
|
|
83
|
-
hover-
|
|
83
|
+
hover-selector=".social-networks">
|
|
84
84
|
<div class="display:none social-networks">
|
|
85
85
|
<a
|
|
86
86
|
class="margin-right:15px"
|
|
@@ -139,11 +139,11 @@
|
|
|
139
139
|
class="border-bottom:1px_solid_lightgrey"
|
|
140
140
|
scroll
|
|
141
141
|
scroll-intersect="color:dodgerblue"
|
|
142
|
-
scroll-
|
|
142
|
+
scroll-selector="#unique-install-section">
|
|
143
143
|
<span
|
|
144
144
|
class="display:flex align-items:center width:fit-content"
|
|
145
145
|
hover="display:block!important"
|
|
146
|
-
hover-
|
|
146
|
+
hover-selector="[href='#unique-install']">
|
|
147
147
|
<h2 class="padding:5px_0px">Install</h2>
|
|
148
148
|
<a
|
|
149
149
|
class="margin-left:10px display:none"
|
|
@@ -165,11 +165,11 @@
|
|
|
165
165
|
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
166
166
|
scroll
|
|
167
167
|
scroll-intersect="color:dodgerblue"
|
|
168
|
-
scroll-
|
|
168
|
+
scroll-selector="#unique-usage-section">
|
|
169
169
|
<span
|
|
170
170
|
class="display:flex align-items:center width:fit-content"
|
|
171
171
|
hover="display:block!important"
|
|
172
|
-
hover-
|
|
172
|
+
hover-selector="[href='#unique-usage']">
|
|
173
173
|
<h2 class="padding:5px_0px">Usage</h2>
|
|
174
174
|
<a
|
|
175
175
|
class="margin-left:10px display:none"
|
|
@@ -200,11 +200,11 @@
|
|
|
200
200
|
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
201
201
|
scroll
|
|
202
202
|
scroll-intersect="color:dodgerblue"
|
|
203
|
-
scroll-
|
|
203
|
+
scroll-selector="#unique-attributes-section">
|
|
204
204
|
<span
|
|
205
205
|
class="display:flex align-items:center width:fit-content"
|
|
206
206
|
hover="display:block!important"
|
|
207
|
-
hover-
|
|
207
|
+
hover-selector="[href='#unique-attributes']">
|
|
208
208
|
<h2 class="padding:5px_0px">Attributes</h2>
|
|
209
209
|
<a
|
|
210
210
|
class="margin-left:10px display:none"
|
|
@@ -253,11 +253,11 @@
|
|
|
253
253
|
class="border-bottom:1px_solid_lightgrey"
|
|
254
254
|
scroll
|
|
255
255
|
scroll-intersect="color:dodgerblue"
|
|
256
|
-
scroll-
|
|
256
|
+
scroll-selector="#unique-demo-section">
|
|
257
257
|
<span
|
|
258
258
|
class="display:flex align-items:center width:fit-content"
|
|
259
259
|
hover="display:block!important"
|
|
260
|
-
hover-
|
|
260
|
+
hover-selector="[href='#unique-demo']">
|
|
261
261
|
<h2 class="padding:5px_0px">Demo</h2>
|
|
262
262
|
<a
|
|
263
263
|
class="margin-left:10px display:none"
|
|
@@ -281,12 +281,12 @@
|
|
|
281
281
|
<textarea
|
|
282
282
|
type="code"
|
|
283
283
|
lang="html"
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
array="demos"
|
|
285
|
+
object=""
|
|
286
|
+
key="demo"
|
|
287
287
|
save="false"
|
|
288
288
|
id="demo"
|
|
289
|
-
input-
|
|
289
|
+
input-selector=".demopreview"
|
|
290
290
|
input-attribute="value"
|
|
291
291
|
input-events="input, onload"
|
|
292
292
|
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
show="#eye-slash"
|
|
310
310
|
hide="#eye, #demo-preview"
|
|
311
311
|
toggle="code-height"
|
|
312
|
-
toggle-
|
|
312
|
+
toggle-selector="#demo-code"
|
|
313
313
|
><i
|
|
314
314
|
class="height:18px fill:#505050"
|
|
315
315
|
src="/assets/svg/eye.svg"></i
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
show="#eye, #demo-preview"
|
|
322
322
|
hide="#eye-slash"
|
|
323
323
|
toggle="code-height"
|
|
324
|
-
toggle-
|
|
324
|
+
toggle-selector="#demo-code"
|
|
325
325
|
><i
|
|
326
326
|
class="height:20px fill:#505050"
|
|
327
327
|
src="/assets/svg/eye-slash.svg"></i
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
<a
|
|
349
349
|
class="margin-right:5px"
|
|
350
350
|
fullscreen
|
|
351
|
-
fullscreen-
|
|
351
|
+
fullscreen-selector="#playground"></a>
|
|
352
352
|
</div>
|
|
353
353
|
</div>
|
|
354
354
|
<!-- End SandBox -->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/unique",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "A simple unique component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unique",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"start": "npx webpack --config webpack.config.js",
|
|
28
|
-
"build": "
|
|
28
|
+
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
29
29
|
"dev": "npx webpack --config webpack.config.js --watch",
|
|
30
30
|
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
31
31
|
},
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
"webpack-log": "^3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cocreate/
|
|
62
|
-
"@cocreate/
|
|
63
|
-
"@cocreate/uuid": "^1.4.26"
|
|
61
|
+
"@cocreate/crud-client": "^1.21.24",
|
|
62
|
+
"@cocreate/uuid": "^1.4.28"
|
|
64
63
|
}
|
|
65
64
|
}
|
package/src/client.js
CHANGED
|
@@ -36,41 +36,43 @@ function setInputEvent(input) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Checks if a value is unique. This is a helper function for CRUD operations that need to be performed on
|
|
39
|
+
* Checks if a value is unique. This is a helper function for CRUD operations that need to be performed on objects in order to make sure they are unique.
|
|
40
40
|
*
|
|
41
41
|
* @param element - The element that is being checked for uniqueness. It should have the attribute ` name `
|
|
42
42
|
*/
|
|
43
43
|
async function isUnique(element) {
|
|
44
|
-
let
|
|
44
|
+
let key = element.getAttribute('key');
|
|
45
45
|
let value = element.getValue();
|
|
46
46
|
let request = {
|
|
47
|
+
method: 'read.object',
|
|
47
48
|
db: 'indexeddb',
|
|
48
|
-
|
|
49
|
+
array: element.getAttribute('array'),
|
|
49
50
|
filter: {
|
|
50
51
|
query: [{
|
|
51
|
-
|
|
52
|
+
key,
|
|
52
53
|
value,
|
|
53
54
|
operator: '$eq'
|
|
54
55
|
}]
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
let data = await crud.
|
|
59
|
+
let data = await crud.send(request)
|
|
59
60
|
let response = {
|
|
60
61
|
element,
|
|
61
|
-
|
|
62
|
+
key,
|
|
62
63
|
unique: true
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
// If a
|
|
66
|
-
if (data.
|
|
66
|
+
// If a object is returned, unique is set to false
|
|
67
|
+
if (data.object && data.object.length) {
|
|
67
68
|
response.unique = false;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
// If indexedb response is unique is true, check server response
|
|
71
72
|
if (response.unique) {
|
|
72
73
|
delete request.storage
|
|
73
|
-
|
|
74
|
+
request.method = 'isUnique'
|
|
75
|
+
response = await crud.socket.send(request)
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
// Set unique attribute on the element
|
package/src/server.js
CHANGED
|
@@ -17,7 +17,7 @@ class CoCreateUnique {
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Checks if a
|
|
20
|
+
* Checks if a object is unique by sending a message to the socket. This is a blocking call so it returns a Promise
|
|
21
21
|
*
|
|
22
22
|
* @param socket - the socket to send the message to
|
|
23
23
|
* @param data - the data to read from the database usually an object
|
|
@@ -27,16 +27,18 @@ class CoCreateUnique {
|
|
|
27
27
|
async isUnique(socket, data) {
|
|
28
28
|
const self = this
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
data.method = 'read.object'
|
|
31
|
+
this.crud.send(data).then((data) => {
|
|
31
32
|
let response = {
|
|
33
|
+
method: 'isUnique',
|
|
32
34
|
unique: true,
|
|
33
35
|
uid: data.uid
|
|
34
36
|
};
|
|
35
|
-
// If the
|
|
36
|
-
if (data.
|
|
37
|
+
// If the object is unique
|
|
38
|
+
if (data.object.length) {
|
|
37
39
|
response.unique = false;
|
|
38
40
|
}
|
|
39
|
-
return self.wsManager.send(socket,
|
|
41
|
+
return self.wsManager.send(socket, response);
|
|
40
42
|
})
|
|
41
43
|
} catch (error) {
|
|
42
44
|
console.log(error);
|
package/webpack.config.js
CHANGED
|
@@ -1,84 +1,90 @@
|
|
|
1
1
|
const path = require("path")
|
|
2
2
|
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
3
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
-
let isProduction = process.env.NODE_ENV === "production"
|
|
5
4
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
5
|
|
|
7
|
-
module.exports = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
output: {
|
|
12
|
-
path: path.resolve(__dirname, "dist"),
|
|
13
|
-
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
-
libraryTarget: "umd",
|
|
15
|
-
libraryExport: "default",
|
|
16
|
-
library: ["CoCreate", "unique"],
|
|
17
|
-
globalObject: "this",
|
|
18
|
-
},
|
|
6
|
+
module.exports = (env, argv) => {
|
|
7
|
+
let isProduction = false
|
|
8
|
+
if (argv.mode === 'production')
|
|
9
|
+
isProduction = true
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
filename: "[name].css",
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
// Default mode for Webpack is production.
|
|
27
|
-
// Depending on mode Webpack will apply different things
|
|
28
|
-
// on final bundle. For now we don't need production's JavaScript
|
|
29
|
-
// minifying and other thing so let's set mode to development
|
|
30
|
-
mode: isProduction ? "production" : "development",
|
|
31
|
-
module: {
|
|
32
|
-
rules: [
|
|
33
|
-
{
|
|
34
|
-
test: /.js$/,
|
|
35
|
-
exclude: /(node_modules)/,
|
|
36
|
-
use: {
|
|
37
|
-
loader: "babel-loader",
|
|
38
|
-
options: {
|
|
39
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
40
|
-
},
|
|
11
|
+
const config = {
|
|
12
|
+
entry: {
|
|
13
|
+
"CoCreate-unique": "./src/index.js",
|
|
41
14
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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", "unique"],
|
|
21
|
+
globalObject: "this",
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
plugins: [
|
|
25
|
+
new CleanWebpackPlugin(),
|
|
26
|
+
new MiniCssExtractPlugin({
|
|
27
|
+
filename: "[name].css",
|
|
28
|
+
}),
|
|
48
29
|
],
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
},
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
// add source map
|
|
58
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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,
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
83
|
+
cacheGroups: {
|
|
84
|
+
defaultVendors: false,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
return config
|
|
90
|
+
}
|