@cocreate/elements 1.12.12 → 1.13.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 CHANGED
@@ -1,3 +1,26 @@
1
+ # [1.13.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.12.12...v1.13.0) (2022-11-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * crud.getAttr renamed to crud.getAttributes ([2aad3ae](https://github.com/CoCreate-app/CoCreate-elements/commit/2aad3ae39f92448e1832c87c23fa5327732c43bc))
7
+ * data.document[0] ([f5929a7](https://github.com/CoCreate-app/CoCreate-elements/commit/f5929a7f17745fa3713077bd3735d0ca736b1fd9))
8
+ * if document_id pending return ([e2ab044](https://github.com/CoCreate-app/CoCreate-elements/commit/e2ab044de1d871b061677fff497fca20f48cdd27))
9
+ * if no document_id or filter return ([7edbd6c](https://github.com/CoCreate-app/CoCreate-elements/commit/7edbd6c1b92cc883d3e6a701470755bbecdd8225))
10
+ * removed await from crud.save ([14229f1](https://github.com/CoCreate-app/CoCreate-elements/commit/14229f15a861d4dc156c2ceff7147646f0526494))
11
+ * renamed crud.checkAttrValue to crud.checkValue ([3e159fa](https://github.com/CoCreate-app/CoCreate-elements/commit/3e159fab0e7176c186545f828838bf5de29ca1f1))
12
+ * renamed data.data to data.document, relocated prototype setValue and getValue to @cocreate/element-prototype ([bf863e8](https://github.com/CoCreate-app/CoCreate-elements/commit/bf863e8b413e0841c9b9f8894b0243c03cb0ff49))
13
+ * renamed fiter.setFilter to filter.init ([0a56f60](https://github.com/CoCreate-app/CoCreate-elements/commit/0a56f60d1681f76ea3463f00d044992c9200d81d))
14
+ * typo ([24ad3fe](https://github.com/CoCreate-app/CoCreate-elements/commit/24ad3fedefee09bab03c98a49fe59c5d3382019d))
15
+
16
+
17
+ ### Features
18
+
19
+ * Ability to use filter attribute to crud data. bump crud@cocreate/crud--client ([0206cb2](https://github.com/CoCreate-app/CoCreate-elements/commit/0206cb2fb27dbf8a28c0fc8b82daf1c5730192f8))
20
+ * Add @cocreate/element-prototype ([1628ffa](https://github.com/CoCreate-app/CoCreate-elements/commit/1628ffafe61faa5ddf8eddbaff61a4100b0ae8db))
21
+ * added crud.getAttributeNames to observer attributeName param, this will allow observing custom attributes ([f52e23d](https://github.com/CoCreate-app/CoCreate-elements/commit/f52e23de8555d7060203b377d39238d43933befd))
22
+ * supports rendering multiple db, database, collection and documents ([00a67e5](https://github.com/CoCreate-app/CoCreate-elements/commit/00a67e59ae8c26ebccc2ca3aadb38eb780d1c558))
23
+
1
24
  ## [1.12.12](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.12.11...v1.12.12) (2022-10-02)
2
25
 
3
26
 
package/demo/index.html CHANGED
@@ -6,10 +6,11 @@
6
6
  <link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
7
7
  </head>
8
8
  <body>
9
- <form collection="test" document_id="62844ba35b660d9424e352a0" class="margin:20px">
10
- <input name="test">
11
- <h1 name="name"></h1>
12
- <h2 name="name1"></h2>
9
+ <form collection="test" document_id="6365199c6647d05d3edad570" class="margin:20px">
10
+ <input name="name">
11
+ <!-- <p name document>eeeeeer</p>
12
+ <h1 name="name" contenteditable></h1>
13
+ <h2 name="name"></h2>
13
14
  <h3 name="color" ></h3>
14
15
  <h4 name="search"></h4>
15
16
  <h5 name="date"></h5>
@@ -17,7 +18,7 @@
17
18
  <p name="date-time"></p>
18
19
  <span name="date-time"></span>
19
20
  <div name="text_area" classs="domeditor"></div>
20
- <span name="personal_info.email"></span>
21
+ <span name="personal_info.email"></span> -->
21
22
  </form>
22
23
 
23
24
  <!--<script src="../dist/CoCreate-elements.js"></script>-->
@@ -17,9 +17,9 @@
17
17
  <div class="display:flex flex-wrap:wrap" fetch-collection="contacts" template_id="grid">
18
18
 
19
19
  <div template_id="grid" class="template card margin:10px padding:20px background:gainsboro:hover">
20
- <a pass_to="form-fields" pass-document_id="{{data._id}}">
21
- <h4 collection="contacts" document_id="{{data._id}}" name="fullname">Name</h4>
22
- <h4>{{data._id}}</h4>
20
+ <a pass_to="form-fields" pass-document_id="{{document._id}}">
21
+ <h4 collection="contacts" document_id="{{document._id}}" name="fullname">Name</h4>
22
+ <h4>{{document._id}}</h4>
23
23
  </a>
24
24
  </div>
25
25
 
@@ -14,17 +14,17 @@
14
14
  <!--<ul id="a123"> hello </ul>-->
15
15
 
16
16
  <cocreate-select class="floating-label" id="collection" placeholder="collection:" set-value="#document_id" set-value-key="setcollection" active>
17
- <ul fetch-collections template_id="collection" class="options z-index:7 margin-top:5px">
18
- <cc-option class="option template" template_id="collection" value="{{data.name}}">
19
- <span>{{data.name}}</span>
17
+ <ul fetch-collection template_id="collection" class="options z-index:7 margin-top:5px">
18
+ <cc-option class="option template" template_id="collection" value="{{collection.name}}">
19
+ <span>{{collection.name}}</span>
20
20
  </cc-option>
21
21
  </ul>
22
22
  </cocreate-select>
23
23
 
24
24
  <cocreate-select class="floating-label" id="document_id" placeholder="document_id:" active>
25
25
  <ul fetch-collection="{{setcollection}}" template_id="document_id" class="options z-index:7 margin-top:5px">
26
- <cc-option class="option template" template_id="document_id" value="{{data._id}}">
27
- <span>{{data._id}}</span>
26
+ <cc-option class="option template" template_id="document_id" value="{{document._id}}">
27
+ <span>{{document._id}}</span>
28
28
  </cc-option>
29
29
  </ul>
30
30
  </cocreate-select>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.12.12",
3
+ "version": "1.13.0",
4
4
  "description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
5
5
  "keywords": [
6
6
  "elements",
@@ -64,6 +64,7 @@
64
64
  "@cocreate/actions": "^1.5.12",
65
65
  "@cocreate/crud-client": "^1.12.12",
66
66
  "@cocreate/docs": "^1.3.18",
67
+ "@cocreate/element-prototype": "^1.0.0",
67
68
  "@cocreate/observer": "^1.5.17",
68
69
  "@cocreate/utils": "^1.10.12"
69
70
  }
package/src/getValue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import observer from '@cocreate/observer';
2
- import { setValue } from './setValue';
2
+ import '@cocreate/element-prototype';
3
3
 
4
4
  const valueEls = new Map();
5
5
 
@@ -63,8 +63,8 @@ function setValueByFind(valueEl, mutation) {
63
63
  value = valueEl.getAttribute('value');
64
64
  else if(valueEl.getValue)
65
65
  value = valueEl.getValue();
66
- else
67
- value = getValue(valueEl);
66
+ // else
67
+ // value = getValue(valueEl);
68
68
  if (!value) return;
69
69
  let elements = mutation || valueEls.get(valueEl);
70
70
 
@@ -97,62 +97,8 @@ function setValueByFind(valueEl, mutation) {
97
97
  }
98
98
  }
99
99
  else
100
- setValue(element, value);
101
- }
102
- }
103
-
104
- var getValue = (element) => {
105
- let value = element.value;
106
- let prefix = element.getAttribute('value-prefix') || "";
107
- let suffix = element.getAttribute('value-suffix') || "";
108
-
109
- if (element.type === "checkbox") {
110
- let el_name = element.getAttribute('name');
111
- let checkboxs = document.querySelectorAll(`input[type=checkbox][name='${el_name}']`);
112
- if (checkboxs.length > 1) {
113
- value = [];
114
- checkboxs.forEach(el => {
115
- if (el.checked) value.push(el.value);
116
- });
117
- }
118
- else {
119
- value = element.checked;
120
- }
121
- }
122
- else if (element.type === "number") {
123
- value = Number(value);
124
- }
125
- else if (element.type === "password") {
126
- value = __encryptPassword(value);
100
+ element.setValue(value);
127
101
  }
128
- else if (element.tagName == "SELECT" && element.hasAttribute('multiple')) {
129
- let options = element.selectedOptions;
130
- value = [];
131
- for (let i = 0; i < options.length; i++) {
132
- value.push(options[i].value);
133
- }
134
- }
135
- else if (element.tagName == 'INPUT' || element.tagName == 'TEXTAREA' || element.tagName == 'SELECT') {
136
- value = element.value;
137
- }
138
- else if (element.tagName === 'IFRAME') {
139
- value = element.srcdoc;
140
- }
141
- else if (element.hasAttribute('value')){
142
- value = element.getAttribute('value');
143
- }
144
- else {
145
- value = element.innerHTML;
146
- }
147
- if (prefix || suffix)
148
- value = prefix + value + suffix;
149
-
150
- return value;
151
- };
152
-
153
- function __encryptPassword(str) {
154
- let encodedString = btoa(str);
155
- return encodedString;
156
102
  }
157
103
 
158
104
  observer.init({
@@ -164,4 +110,4 @@ observer.init({
164
110
  }
165
111
  });
166
112
 
167
- export { initGetValues, getValue };
113
+ export { initGetValues };
package/src/index.js CHANGED
@@ -1,13 +1,22 @@
1
1
  import observer from '@cocreate/observer';
2
2
  import action from '@cocreate/actions';
3
- import crud from '@cocreate/crud-client';
4
- import { initSetValues, setValue } from './setValue';
5
- import { initGetValues, getValue } from './getValue';
3
+ import CRUD from '@cocreate/crud-client';
4
+ import ccfilter from '@cocreate/filter';
5
+ import '@cocreate/element-prototype';
6
+ import { initSetValues} from './setValue';
7
+ import { initGetValues} from './getValue';
6
8
  import './fetchSrc';
7
- import './HTMLElement';
8
9
 
9
- const selector = "[collection][document_id][name]:not(cocreate-select, link), input, textarea, select, [contenteditable]";
10
+ let crud
11
+ if(CRUD && CRUD.default)
12
+ crud = CRUD.default
13
+ else
14
+ crud = CRUD
15
+
16
+
17
+ const selector = "[collection][name]:not(cocreate-select, link), input, textarea, select, [contenteditable]";
10
18
  const initializing = new Map();
19
+ const els = new Map();
11
20
 
12
21
  function init() {
13
22
  let elements = document.querySelectorAll(selector);
@@ -17,20 +26,39 @@ function init() {
17
26
 
18
27
  function initElements(elements) {
19
28
  let documents = new Map();
29
+ // let els = []
20
30
  for (let element of elements){
21
31
  let doc = initElement(element);
22
32
  if (doc) {
23
- let collection = doc.collection;
24
- let document_id = doc.document_id;
33
+ let key = JSON.stringify(doc)
34
+ let item = documents.get(key);
35
+ if (item)
36
+ doc.elements = [...item.elements, element]
37
+ else
38
+ doc.elements = [element]
39
+
40
+ // let collection = doc.collection;
41
+ // let document_id = doc.document_id;
42
+ // let filter = doc.filter;
25
43
  let initialize = initializing.get(element)
26
- if (!initialize || initialize.collection != collection && initialize.document_id != document_id){
27
- initializing.set(element, {collection, document_id});
28
- documents.set(`${collection}${document_id}`, {collection, document_id});
44
+ if (!initialize){
45
+ initializing.set(element, key);
46
+ documents.set(key, doc);
47
+ // els.set(key, doc);
48
+ // els.push(element)
49
+ } else {
50
+ // if (document_id && initialize.document_id != document_id || filter && JSON.stringify(initialize.filter) != JSON.stringify(filter)){
51
+ if (initialize != key){
52
+ initializing.set(element, key);
53
+ documents.set(key, doc);
54
+ // els.set(key, doc);
55
+ // els.push(element)
56
+ }
29
57
  }
30
58
  }
31
59
  }
32
60
 
33
- read(documents, elements);
61
+ read(documents);
34
62
  }
35
63
 
36
64
  function initElement(el) {
@@ -44,69 +72,96 @@ function initElement(el) {
44
72
  return;
45
73
  }
46
74
 
47
- const { collection, document_id, name, isRead } = crud.getAttr(el);
48
- if (!collection || !document_id || !name) return;
49
- if (!document_id.match(/^[0-9a-fA-F]{24}$/)) return;
50
- if (!crud.checkAttrValue(collection) || !crud.checkAttrValue(name)) return;
75
+ const { collection, document_id, name, isRead } = crud.getAttributes(el);
76
+ if (!collection || !name) return;
77
+
78
+ if (document_id)
79
+ if (!document_id.match(/^[0-9a-fA-F]{24}$/)) return;
80
+
81
+ let filter
82
+ if (el.hasAttribute('filter_id') || el.hasAttribute('filter-name' ) || el.hasAttribute('filter-sort-name')) {
83
+ filter = ccfilter.init(el, "filter_id");
84
+ }
85
+
86
+ if (!crud.checkValue(collection) || !crud.checkValue(name)) return;
51
87
 
52
88
  if (isRead == 'false') return;
53
- return {collection, document_id};
89
+ if (!document_id && !filter) return;
90
+
91
+ return {collection, document_id, filter};
54
92
  }
55
93
 
56
- async function read(documents, elements) {
94
+ async function read(documents) {
57
95
  if (documents && documents.size > 0) {
58
- for (let [key, {collection, document_id}] of documents) {
96
+ for (let [key, {collection, document_id, filter, elements}] of documents) {
59
97
  documents.delete(key);
60
- var responseData = await crud.readDocument({
61
- collection: collection,
62
- document_id: document_id,
63
- });
64
- setData(elements, responseData);
98
+
99
+ let data = {collection}
100
+ if (document_id)
101
+ data.document = {_id: document_id}
102
+ if (filter)
103
+ data.filter = filter
104
+
105
+ let response = await crud.readDocument(data);
106
+ setData(elements, response);
65
107
  }
66
108
  }
67
109
  }
68
110
 
69
111
  function setData(elements, data) {
70
112
  let isRendered = false;
71
- if (!data.data) return;
113
+ if (!data.document || !data.document[0]) return;
114
+ let key = getKey(data)
115
+
72
116
  if (!elements) {
73
- let collection = data.collection;
74
- let document_id = data.document_id;
75
- let selector = `[collection='${collection}'][document_id='${document_id}']:not(cocreate-select, link)`;
76
- elements = document.querySelectorAll(selector);
117
+ // ToDo: handle db and database, create key and get elements by key
118
+ elements = els.get(key)
119
+ // let collection = data.document[0].collection;
120
+ // let document_id = data.document[0]._id;
121
+ // let selector = `[collection='${collection}'][document_id='${document_id}']:not(cocreate-select, link)`;
122
+ // elements = document.querySelectorAll(selector);
123
+ } else {
124
+ let eles = els.get(key)
125
+ if (eles && eles.length)
126
+ els.set(key, [...eles, ...elements])
127
+ else
128
+ els.set(key, elements)
77
129
  }
78
-
130
+ if (!elements || elements.length == 0)
131
+ return
132
+
79
133
  elements.forEach((el) => {
80
- const { collection, document_id, name, isRead, isUpdate, isCrdt } = crud.getAttr(el);
134
+ const { collection, document_id, name, isRead, isUpdate, isCrdt } = crud.getAttributes(el);
81
135
  if (el.hasAttribute('actions')) return;
82
136
  if (isRead == "false" || isUpdate == "false" || isCrdt == "true") return;
83
137
 
84
- if (data['collection'] == collection && data['document_id'] == document_id) {
138
+ // if (data.document[0]['collection'] == collection && data.document[0]['_id'] == document_id) {
85
139
  let value;
86
140
  let valueType = el.getAttribute('value-type');
87
141
  if(valueType == 'object' || valueType == 'json'){
88
142
  // if (name == 'data')
89
143
  // value = JSON.stringify(data[name])
90
144
  // else
91
- value = JSON.stringify(data.data[name])
145
+ value = JSON.stringify(data.document[0][name])
92
146
  value = decodeURIComponent(value)
93
147
  } else
94
- value = crud.getObjectValueByPath(data.data, name);
148
+ value = crud.getObjectValueByPath(data.document[0], name);
95
149
 
96
150
  el.setValue(value);
97
151
 
98
152
  isRendered = true;
99
- }
153
+ // }
100
154
  initializing.delete(el)
101
155
 
102
156
  });
103
157
 
158
+
104
159
  if (isRendered) {
105
160
  // ToDo: Replace with custom event
106
161
  const event = new CustomEvent('CoCreateElements-rendered', {
107
162
  eventType: 'rendered',
108
163
  detail: {
109
- data: data
164
+ data
110
165
  }
111
166
  });
112
167
 
@@ -114,9 +169,24 @@ function setData(elements, data) {
114
169
  }
115
170
  }
116
171
 
172
+ function getKey(data) {
173
+ let key = {};
174
+ let attributes = ["db", "database", "collection", "index", "document"]
175
+
176
+ for (let attribute of attributes) {
177
+ let value = data[attribute]
178
+ if (value) {
179
+ if (attribute == 'document')
180
+ key[attribute] = value
181
+ }
182
+ }
183
+ key.document = data.document[0]._id
184
+ return JSON.stringify(key)
185
+ }
186
+
117
187
  async function save(element) {
118
- let value = getValue(element);
119
- await crud.save(element, value);
188
+ let value = element.getValue();
189
+ crud.save(element, value);
120
190
  }
121
191
 
122
192
  function __initSocket() {
@@ -130,8 +200,8 @@ function __initEvents(el) {
130
200
  if (!elementEvents.has(el)) {
131
201
  if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT' || el.hasAttribute('contenteditable')) {
132
202
  el.addEventListener('input', function(e) {
133
- const {document_id, name, isRealtime, isCrdt} = crud.getAttr(el);
134
- if (isCrdt == "true" && document_id || isRealtime == "false" || name == "_id") return;
203
+ const {document_id, name, isRealtime, isCrdt} = crud.getAttributes(el);
204
+ if (isCrdt == "true" && document_id && document_id != 'pending' || isRealtime == "false" || name == "_id") return;
135
205
  if (document_id && e.detail && e.detail.skip == true) return;
136
206
  save(el);
137
207
  });
@@ -153,10 +223,10 @@ observer.init({
153
223
  observer.init({
154
224
  name: 'CoCreateElementsAttributes',
155
225
  observe: ['attributes'],
156
- attributeName: ['collection', 'document_id', 'name'],
226
+ attributeName: crud.getAttributeNames(['collection', 'document_id', 'name']),
157
227
  target: selector,
158
228
  callback: function(mutation) {
159
- let {collection, document_id, name} = crud.getAttr(mutation.target);
229
+ let {collection, document_id, name} = crud.getAttributes(mutation.target);
160
230
  if(collection && document_id && name)
161
231
  initElements([mutation.target]);
162
232
  }
@@ -176,4 +246,4 @@ initGetValues();
176
246
  initSetValues();
177
247
 
178
248
 
179
- export default {initElements, initElement, save, getValue, setValue};
249
+ export default {initElements, initElement, save};
package/src/setValue.js CHANGED
@@ -1,6 +1,13 @@
1
1
  import observer from '@cocreate/observer';
2
- import crud from '@cocreate/crud-client';
2
+ import CRUD from '@cocreate/crud-client';
3
3
  import { queryDocumentSelectorAll } from '@cocreate/utils';
4
+ import '@cocreate/element-prototype';
5
+
6
+ let crud
7
+ if(CRUD && CRUD.default)
8
+ crud = CRUD.default
9
+ else
10
+ crud = CRUD
4
11
 
5
12
  function initSetValues() {
6
13
  var elements = document.querySelectorAll('[set-value], [set-value-closest]');
@@ -76,152 +83,11 @@ function setValueByFind(element){
76
83
  setValueMap.set(element, value)
77
84
  }
78
85
  else
79
- setValue(element, value);
86
+ element.setValue(value);
80
87
  }
81
88
 
82
89
  }
83
90
 
84
- var setValue = (el, value) => {
85
- if (value === null || value === undefined) return;
86
- let valueType = el.getAttribute('value-type');
87
-
88
- if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT') {
89
- const {isCrdt} = crud.getAttr(el);
90
- if (isCrdt == "true" || el.type === 'file') return;
91
-
92
- if (el.type == 'checkbox') {
93
- if (value.includes(el.value)) {
94
- el.checked = true;
95
- }
96
- else {
97
- el.checked = false;
98
- }
99
- }
100
- else if (el.type === 'radio') {
101
- el.value == value ? el.checked = true : el.checked = false;
102
- }
103
- else if (el.type === 'password') {
104
- el.value = __decryptPassword(value);
105
- }
106
- else if (el.tagName == "SELECT" && el.hasAttribute('multiple') && Array.isArray(value)) {
107
- let options = el.options;
108
- for (let i = 0; i < options.length; i++) {
109
- if (value.includes(options[i].value)) {
110
- options[i].selected = "selected";
111
- }
112
- }
113
- }
114
- else
115
- el.value = value;
116
- dispatchEvents(el)
117
- }
118
- else if (el.tagName === 'IMG' || el.tagName === 'SOURCE')
119
- el.src = value;
120
-
121
- else if (el.tagName === 'IFRAME')
122
- el.srcdoc = value;
123
-
124
- else if (el.tagName === 'DIV') {
125
- if (el.hasAttribute("value")) {
126
- el.setAttribute("value", value);
127
- }
128
-
129
- if (el.classList.contains('domEditor') || el.hasAttribute('get-value') || el.hasAttribute('get-value-closest')) {
130
- if (el.getAttribute('data-domEditor') == "replace") {
131
- let newElement = document.createElement("div");
132
- newElement.innerHTML = value;
133
- let parentNode = el.parentNode;
134
- if (parentNode) {
135
- if (newElement.children[0]) {
136
- parentNode.replaceChild(newElement.children[0], el);
137
- }
138
- else {
139
- parentNode.replaceChild(newElement, el);
140
- }
141
- }
142
- }
143
- else {
144
- if (valueType == 'string' || valueType == 'text')
145
- el.textContent = value;
146
- else
147
- el.innerHTML = value;
148
- }
149
- }
150
- }
151
-
152
- else if (el.tagName === 'SCRIPT'){
153
- setScript(el, value);
154
- }
155
- else {
156
- if (el.hasAttribute('contenteditable') && el == document.activeElement) return;
157
- if (valueType == 'string' || valueType == 'text')
158
- el.textContent = value;
159
- else
160
- el.innerHTML = value;
161
- if (el.hasAttribute("value")) {
162
- el.setAttribute("value", value);
163
- }
164
- }
165
- if (el.getAttribute('contenteditable'))
166
- dispatchEvents(el);
167
-
168
- if (el.tagName == 'HEAD' || el.tagName == 'BODY') {
169
- el.removeAttribute('collection');
170
- el.removeAttribute('document_id');
171
- el.removeAttribute('pass_id');
172
-
173
- let scripts = el.querySelectorAll('script');
174
- for (let script of scripts) {
175
- setScript(script)
176
- }
177
- }
178
- };
179
-
180
- function setScript(script, value) {
181
- let newScript = document.createElement('script');
182
- newScript.attributes = script.attributes;
183
- newScript.innerHTML = script.innerHTML;
184
- if (value) {
185
- if (script.hasAttribute("src"))
186
- newScript.src = value;
187
- else
188
- newScript.innerHTML = value;
189
- }
190
- script.replaceWith(newScript);
191
- }
192
-
193
- function __decryptPassword(str) {
194
- if (!str) return "";
195
- let decode_str = atob(str);
196
- return decode_str;
197
- }
198
-
199
- function dispatchEvents(el) {
200
- let inputEvent = new CustomEvent('input', {
201
- bubbles: true,
202
- detail: {
203
- skip: true
204
- },
205
- });
206
- Object.defineProperty(inputEvent, 'target', {
207
- writable: false,
208
- value: el
209
- });
210
- el.dispatchEvent(inputEvent);
211
-
212
- let changeEvent = new CustomEvent('change', {
213
- bubbles: true,
214
- detail: {
215
- skip: true
216
- },
217
- });
218
- Object.defineProperty(changeEvent, 'target', {
219
- writable: false,
220
- value: el
221
- });
222
- el.dispatchEvent(changeEvent);
223
- }
224
-
225
91
  observer.init({
226
92
  name: 'set-value',
227
93
  observe: ['addedNodes'],
@@ -231,4 +97,4 @@ observer.init({
231
97
  }
232
98
  });
233
99
 
234
- export { initSetValues, setValue };
100
+ export { initSetValues };
@@ -1,30 +0,0 @@
1
- import { setValue } from './setValue';
2
- import { getValue } from './getValue';
3
-
4
- HTMLElement.prototype.getValue = function() {
5
- let value = getValue(this)
6
- return value;
7
- };
8
-
9
- HTMLElement.prototype.setValue = function(value) {
10
- setValue(this, value)
11
- };
12
-
13
- HTMLInputElement.prototype.getValue = function() {
14
- let value = getValue(this)
15
- return value;
16
- };
17
-
18
- HTMLInputElement.prototype.setValue = function(value) {
19
- setValue(this, value)
20
- };
21
-
22
- HTMLHeadingElement.prototype.getValue = function() {
23
- let value = getValue(this)
24
- return value;
25
- };
26
-
27
- HTMLHeadingElement.prototype.setValue = function(value) {
28
- setValue(this, value)
29
- };
30
-