dom-render 1.0.46 → 1.0.50

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/Config.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface Config {
18
18
  onElementInit?: (name: string, obj: any, rawSet: RawSet) => void;
19
19
  onAttrInit?: (name: string, attrValue: string, obj: any, rawSet: RawSet) => void;
20
20
  proxyExcludeTyps?: ConstructorType<any>[];
21
+ proxyExcludeOnBeforeReturnSets?: string[];
22
+ proxyExcludeOnBeforeReturnGets?: string[];
21
23
  scripts?: {
22
24
  [n: string]: any;
23
25
  };
@@ -14,7 +14,7 @@ export declare class DomRenderProxy<T extends object> implements ProxyHandler<T>
14
14
  initRender(target: Node): void;
15
15
  getRawSets(): RawSet[];
16
16
  render(raws?: RawSet[]): void;
17
- root(paths: string[], value: any): void;
17
+ root(paths: string[], value?: any, lastDoneExecute?: boolean): string[];
18
18
  set(target: T, p: string | symbol, value: any, receiver: T): boolean;
19
19
  get(target: T, p: string | symbol, receiver: any): any;
20
20
  has(target: T, p: string | symbol): boolean;
package/DomRenderProxy.js CHANGED
@@ -2,6 +2,7 @@ import { RawSet } from './RawSet';
2
2
  import { eventManager } from './events/EventManager';
3
3
  import { ScriptUtils } from './utils/script/ScriptUtils';
4
4
  import { Shield } from './types/Types';
5
+ var excludeGetSetPropertys = ['onBeforeReturnGet', 'onBeforeReturnSet', '__domrender_components', '__render', '_DomRender_isFinal', '_domRender_ref', '_rawSets', '_domRender_proxy', '_targets', '_DomRender_origin', '_DomRender_ref', '_DomRender_proxy'];
5
6
  var DomRenderProxy = (function () {
6
7
  function DomRenderProxy(_domRender_origin, target, config) {
7
8
  this._domRender_origin = _domRender_origin;
@@ -84,14 +85,17 @@ var DomRenderProxy = (function () {
84
85
  }
85
86
  });
86
87
  };
87
- DomRenderProxy.prototype.root = function (paths, value) {
88
+ DomRenderProxy.prototype.root = function (paths, value, lastDoneExecute) {
88
89
  var _this = this;
90
+ if (lastDoneExecute === void 0) { lastDoneExecute = true; }
91
+ var fullPaths = [];
89
92
  if (this._domRender_ref.size > 0) {
90
93
  this._domRender_ref.forEach(function (it, key) {
91
94
  if ('_DomRender_isProxy' in key) {
92
95
  it.forEach(function (sit) {
93
96
  var _a;
94
- (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value);
97
+ var items = (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value, lastDoneExecute);
98
+ fullPaths.push(items.join(','));
95
99
  });
96
100
  }
97
101
  });
@@ -99,39 +103,47 @@ var DomRenderProxy = (function () {
99
103
  else {
100
104
  var strings = paths.reverse();
101
105
  var fullPathStr_1 = strings.join('.');
102
- var iterable = this._rawSets.get(fullPathStr_1);
103
- var front = strings.slice(0, strings.length - 1).join('.');
104
- var last = strings[strings.length - 1];
105
- if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn('this.' + front, this._domRender_proxy))) {
106
- var aIterable = this._rawSets.get(front);
107
- if (aIterable) {
108
- this.render(Array.from(aIterable));
106
+ if (lastDoneExecute) {
107
+ var iterable = this._rawSets.get(fullPathStr_1);
108
+ var front = strings.slice(0, strings.length - 1).join('.');
109
+ var last = strings[strings.length - 1];
110
+ if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn('this.' + front, this._domRender_proxy))) {
111
+ var aIterable = this._rawSets.get(front);
112
+ if (aIterable) {
113
+ this.render(Array.from(aIterable));
114
+ }
109
115
  }
110
- }
111
- else if (iterable) {
112
- this.render(Array.from(iterable));
113
- }
114
- this._targets.forEach(function (it) {
115
- if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
116
- var targets = eventManager.findAttrElements(it, _this.config);
117
- eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
116
+ else if (iterable) {
117
+ this.render(Array.from(iterable));
118
118
  }
119
- });
119
+ this._targets.forEach(function (it) {
120
+ if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
121
+ var targets = eventManager.findAttrElements(it, _this.config);
122
+ eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
123
+ }
124
+ });
125
+ }
126
+ fullPaths.push(fullPathStr_1);
120
127
  }
128
+ return fullPaths;
121
129
  };
122
130
  DomRenderProxy.prototype.set = function (target, p, value, receiver) {
123
- var _a, _b;
131
+ var _a, _b, _c, _d;
124
132
  if (typeof p === 'string') {
125
133
  value = this.proxy(receiver, value, p);
126
134
  }
127
135
  target[p] = value;
136
+ var fullPath;
128
137
  if (typeof p === 'string') {
129
- this.root([p], value);
138
+ fullPath = this.root([p], value);
139
+ }
140
+ if (('onBeforeReturnSet' in receiver) && typeof p === 'string' && !((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeOnBeforeReturnSets) !== null && _b !== void 0 ? _b : []).concat(excludeGetSetPropertys).includes(p)) {
141
+ (_d = (_c = receiver) === null || _c === void 0 ? void 0 : _c.onBeforeReturnSet) === null || _d === void 0 ? void 0 : _d.call(_c, p, value, fullPath);
130
142
  }
131
- (_b = (_a = receiver) === null || _a === void 0 ? void 0 : _a.onBeforeReturnSet) === null || _b === void 0 ? void 0 : _b.call(_a, p, value);
132
143
  return true;
133
144
  };
134
145
  DomRenderProxy.prototype.get = function (target, p, receiver) {
146
+ var _a, _b, _c, _d;
135
147
  if (p === '_DomRender_origin') {
136
148
  return this._domRender_origin;
137
149
  }
@@ -146,6 +158,9 @@ var DomRenderProxy = (function () {
146
158
  if (it_1 && typeof it_1 === 'object' && ('_DomRender_isProxy' in it_1) && Object.prototype.toString.call(it_1._DomRender_origin) === '[object Date]') {
147
159
  it_1 = it_1._DomRender_origin;
148
160
  }
161
+ if (('onBeforeReturnGet' in receiver) && typeof p === 'string' && !((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeOnBeforeReturnGets) !== null && _b !== void 0 ? _b : []).concat(excludeGetSetPropertys).includes(p)) {
162
+ (_d = (_c = receiver) === null || _c === void 0 ? void 0 : _c.onBeforeReturnGet) === null || _d === void 0 ? void 0 : _d.call(_c, p, it_1, this.root([p], it_1, false));
163
+ }
149
164
  return it_1;
150
165
  }
151
166
  };
package/README.MD CHANGED
@@ -2,7 +2,8 @@
2
2
  [![npm version](https://img.shields.io/badge/npm-v1.0.44-blue)](https://www.npmjs.com/package/dom-render) [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE.md) [![Chat](https://img.shields.io/badge/discord-20%20online-brightgreen?logo=discord)](https://discord.gg/PW56dpns) [![Github](https://img.shields.io/badge/-github-black?logo=github)](https://github.com/visualkhh/dom-render)
3
3
  # Our primary goals are
4
4
  - view template engine
5
- - Dom control and reorder using web component
5
+ - Dom control and reorder
6
+ - all internal variables are managed by proxy. (DomRenderProxy)
6
7
  ---
7
8
 
8
9
  # 🚀 Quick start
@@ -33,7 +34,7 @@ data.name = 'modify name';
33
34
  ## dr-if
34
35
  ```html
35
36
  <div dr-if="true">true</div>
36
- <div dr-if="this.gender==='M'"> gender: M</div>
37
+ <div dr-if="this.gender==='M'">gender: M</div>
37
38
  ```
38
39
  ## dr-for, dr-for-of
39
40
  ```html
@@ -84,6 +85,11 @@ dr-event
84
85
  ```
85
86
 
86
87
  ## dr-value, value-link
88
+ dr-value
89
+ - The value is assigned the first time.
90
+
91
+ dr-value-link
92
+ - Value and variable values are referencing each other. It affects each other when changing. (Immediate reflection event: input)
87
93
  ```html
88
94
  dr-value: <input type="text" dr-value="this.office.name"> <br>
89
95
  dr-value-link: <input type="text" dr-value-link="this.office.addr.street"> <br>
@@ -92,11 +98,24 @@ dr-value-link: <input type="text" dr-value-link="this.office.addr.street"> <br>
92
98
  ## dr-attr
93
99
  ```html
94
100
  <textarea dr-attr="{rows: this.age/2, cols: this.age}"></textarea>
101
+ <div dr-attr="{wow: '123', good: 123444}"></div>
102
+ <div dr-attr="['wow=123', 'good=123444']"></div>
103
+ <div dr-attr="'wow=123, good=123444'"></div>
104
+ ```
105
+
106
+ ## dr-class
107
+ ```html
108
+ <div dr-class="{big: this.age > 50, red: this.age > 50}">
109
+ <div dr-class="'big yellow ' + (this.age > 50 ? 'old' : 'young')">
110
+ <div dr-class="['small', 'yellow']">
95
111
  ```
96
112
 
97
113
  ## dr-style
98
114
  ```html
99
- <div dr-style="{fontSize: this.age+'px'}"> style </div>
115
+ <div dr-style="{fontSize: this.age + 'px'}"> style </div>
116
+ <div dr-style="{'font-size': '20px'}"> style</div>
117
+ <div dr-style="'font-size: ' + this.age +'px; margin: ' + this.age + 'px'"> style </div>
118
+ <div dr-style="['font-size: ' + this.age +'px', 'margin: ' + this.age + 'px']"> style </div>
100
119
  ```
101
120
 
102
121
 
@@ -126,9 +145,15 @@ to-be
126
145
  </select>
127
146
  ```
128
147
 
148
+ ---
149
+ # LifeCycle
150
+ ```
151
+ * OnInitRender
152
+ - onInitRender(): init render call
153
+ ```
129
154
  ---
130
155
 
131
- # script
156
+ # Script
132
157
  ```typescript
133
158
  new DomRender.run(obj, target, {
134
159
  scripts: {
@@ -148,7 +173,7 @@ const data = config.scripts.concat('head', 'tail')
148
173
  ```
149
174
 
150
175
  ---
151
- # component
176
+ # Component
152
177
  ```typescript
153
178
  export namespace Profile {
154
179
  export const templat = '<div>aaaaa${this.name}aaaaa </div>';
@@ -180,10 +205,183 @@ using component
180
205
  - $innerHTML: element innerHTML string
181
206
  ---
182
207
 
183
- # LifeCycle
208
+ # validation
209
+ ```html
210
+ <div class="row mb-3">
211
+ <div class="col">
212
+ <span>아이디</span>
213
+ <input class="w-100" type="text" name="id" placeholder="아이디" dr-value-link="this.form.id.value" dr-event-blur="this.form.id.valid()" required/>
214
+ <span dr-on-init="this.form.id.msgElement" class="d-none"></span>
215
+ </div>
216
+ </div>
217
+ <div class="row mb-3">
218
+ <div class="col">
219
+ <span>비밀번호</span>
220
+ <input class="w-100" type="password" name="id" placeholder="숫자, 영문, 특수문자 조합 최소 8자~20자" dr-value-link="this.form.password.value" dr-event-blur="this.form.password.valid()" required/>
221
+ <span dr-on-init="this.form.password.msgElement" >password valid message section</span>
222
+ <input class="w-100" type="password" name="id" placeholder="비밀번호 재입력" dr-value-link="this.form.confirmPassword" required/>
223
+ <span dr-class="{'d-block': this.form.password != this.form.confirmPassword, 'text-danger': this.form.password != this.form.confirmPassword}">2nd input password valid message section</span>
224
+ </div>
225
+ </div>
226
+ <div class="row mb-3">
227
+ <div class="col">
228
+ <span>이메일</span>
229
+ <input class="w-100" type="email" name="id" placeholder="이메일" dr-value-link="this.form.email" required/>
230
+ <span class="">2nd input password valid message section</span>
231
+ </div>
232
+ </div>
233
+ </div>
184
234
  ```
185
- * OnInitRender
186
- - onInitRender(): init render call
235
+ ```typescript
236
+ class SignUp {
237
+ public form = new class extends Validation {
238
+ id = new class extends Validation {
239
+ public msgElement!: HTMLElement;
240
+ valid(): boolean {
241
+ let valid = false;
242
+ if (this.length == 0) {
243
+ this.msgElement.className = 'd-block text-danger';
244
+ this.msgElement.textContent = '아이디를 입력해주세요.';
245
+ } else if (this.length < 3 || this.length > 20) {
246
+ this.msgElement.className = 'd-block text-danger';
247
+ this.msgElement.textContent = '아이디는 4글자 이상 20자 미만 이어야 합니다.';
248
+ } else {
249
+ let isExist = false;
250
+ if (isExist) {
251
+ this.msgElement.className = 'd-block text-danger';
252
+ this.msgElement.textContent = '이미 사용중인 아이디입니다. 다른 아이디를 이용해주세요.';
253
+ } else {
254
+ this.msgElement.className = 'd-block text-success';
255
+ this.msgElement.textContent = '사용 가능한 아이디입니다.';
256
+ valid = true;
257
+ }
258
+ }
259
+ return valid;
260
+ }
261
+ }();
262
+ password = new class extends Validation {
263
+ public msgElement!: HTMLElement;
264
+ valid(): boolean {
265
+ let valid = false;
266
+ let regExp = /^.*(?=.)(?=.*[0-9])(?=.*[a-zA-Z]).*$/;
267
+ const ERROR_REQUIRE_PW = '비밀번호를 입력해주세요.';
268
+ const ERROR_PW_LENGTH = '비밀번호는 8글자~20글자로 이루어져야 합니다.';
269
+ const ERROR_PW_REGEXP = '비밀번호는 숫자, 영문, 특수문자 조합으로 이루어져야 합니다.';
270
+ const SUCCESS_AVAILABLE_USER_PW = '사용 가능한 비밀번호입니다.';
271
+ if (this.length == 0) {
272
+ this.msgElement.className = 'd-block text-danger';
273
+ this.msgElement.textContent = ERROR_REQUIRE_PW;
274
+ } else if (this.length < 8 || this.length > 20) {
275
+ this.msgElement.className = 'd-block text-danger';
276
+ this.msgElement.textContent = ERROR_PW_LENGTH;
277
+ } else {
278
+ if (regExp.test(this.value)) {
279
+ this.msgElement.className = 'd-block text-success';
280
+ this.msgElement.textContent = SUCCESS_AVAILABLE_USER_PW;
281
+ valid = true;
282
+ } else {
283
+ this.msgElement.className = 'd-block text-danger';
284
+ this.msgElement.textContent = ERROR_PW_REGEXP;
285
+ }
286
+ }
287
+ return valid;
288
+ }
289
+ }();
290
+ confirmPassword = new class extends Validation {
291
+ value = '';
292
+ valid(): boolean {
293
+ return true;
294
+ }
295
+ }();
296
+ email = new class extends Validation {
297
+ value = '';
298
+ valid(): boolean {
299
+ return true;
300
+ }
301
+ }();
302
+ valid() {
303
+ return this.childValid()
304
+ }
305
+ }();
306
+ }
307
+ ```
308
+
309
+ # Detect Get, Set
310
+ OnBeforeReturnSet
311
+ ```typescript
312
+ export interface OnBeforeReturnSet {
313
+ onBeforeReturnSet(name: string, value: any, fullPath?: string[]): void;
314
+ }
315
+ ```
316
+ OnBeforeReturnGet
317
+ ```typescript
318
+ export interface OnBeforeReturnGet {
319
+ onBeforeReturnGet(name: string, value: any, fullPath?: string[]): void;
320
+ }
321
+ ```
322
+
323
+ using detect
324
+ ```typescript
325
+ {
326
+ name: 'dom-render'
327
+ onBeforeReturnSet: (name: string, value: any, fullpath: string[]) => {
328
+ console.log('set name-->', name, value, fullpath);
329
+ }
330
+ onBeforeReturnGet: (name: string, value: any, fullpath: string[]) => {
331
+ console.log('get name-->', name, value, fullpath);
332
+ }
333
+ }
334
+ ```
335
+ exclude detect property: Config
336
+ - proxyExcludeOnBeforeReturnGets: ['propertyName']
337
+ - proxyExcludeOnBeforeReturnSets: ['propertyName']
338
+ ---
339
+
340
+ # Proxy
341
+ all internal variables are managed by proxy. (DomRenderProxy)
342
+ ### exclude proxy (situation: Maximum call stack error)
343
+ exclude detect property: Config
344
+ - proxyExcludeTyps: [Class...]
345
+
346
+ Code base
347
+ ```typescript
348
+ // frezz
349
+ {name : Object.freeze({...})}
350
+
351
+ // Shield Object type: {[k: string]: any}
352
+ {name : new Shield()}
353
+
354
+ // DomRenderProxy Final
355
+ {name : DomRenderProxy.final({...})}
356
+ ```
357
+ ---
358
+ # Config
359
+ ```typescript
360
+ export type TargetElement = {
361
+ _name: string,
362
+ template?: string,
363
+ styles?: string[],
364
+ callBack: (target: Element, obj: any, rawSet: RawSet) => DocumentFragment,
365
+ complete?: (target: Element, obj: any, rawSet: RawSet) => void
366
+ };
367
+
368
+ export type TargetAttr = {
369
+ name: string,
370
+ callBack: (target: Element, attrValue: string, obj: any, rawSet: RawSet) => DocumentFragment,
371
+ complete?: (target: Element, attrValue: string, obj: any, rawSet: RawSet) => void
372
+ };
373
+
374
+ export interface Config {
375
+ targetElements?: TargetElement[];
376
+ targetAttrs?: TargetAttr[];
377
+ onElementInit?: (name: string, obj: any, rawSet: RawSet) => void;
378
+ onAttrInit?: (name: string, attrValue: string, obj: any, rawSet: RawSet) => void;
379
+ proxyExcludeTyps?: ConstructorType<any>[];
380
+ proxyExcludeOnBeforeReturnSets?: string[];
381
+ proxyExcludeOnBeforeReturnGets?: string[];
382
+ scripts?: { [n: string]: any };
383
+ applyEvents?: { attrName: string, callBack: (elements: Element, attrValue: string, obj: any) => void }[];
384
+ }
187
385
  ```
188
386
  ----
189
387
  # License
package/dist/Config.d.ts CHANGED
@@ -18,6 +18,8 @@ export interface Config {
18
18
  onElementInit?: (name: string, obj: any, rawSet: RawSet) => void;
19
19
  onAttrInit?: (name: string, attrValue: string, obj: any, rawSet: RawSet) => void;
20
20
  proxyExcludeTyps?: ConstructorType<any>[];
21
+ proxyExcludeOnBeforeReturnSets?: string[];
22
+ proxyExcludeOnBeforeReturnGets?: string[];
21
23
  scripts?: {
22
24
  [n: string]: any;
23
25
  };
@@ -14,7 +14,7 @@ export declare class DomRenderProxy<T extends object> implements ProxyHandler<T>
14
14
  initRender(target: Node): void;
15
15
  getRawSets(): RawSet[];
16
16
  render(raws?: RawSet[]): void;
17
- root(paths: string[], value: any): void;
17
+ root(paths: string[], value?: any, lastDoneExecute?: boolean): string[];
18
18
  set(target: T, p: string | symbol, value: any, receiver: T): boolean;
19
19
  get(target: T, p: string | symbol, receiver: any): any;
20
20
  has(target: T, p: string | symbol): boolean;
package/dist/bundle.js CHANGED
@@ -370,9 +370,23 @@ var eventManager = new (function () {
370
370
  target: it
371
371
  })
372
372
  }));
373
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
374
- var _b = _a[_i], key = _b[0], value = _b[1];
375
- it.setAttribute(key, String(value));
373
+ if (typeof data === 'string') {
374
+ data.split(',').forEach(function (sit) {
375
+ var _a = sit.split('='), key = _a[0], value = _a[1];
376
+ it.setAttribute(key.trim(), value.trim());
377
+ });
378
+ }
379
+ else if (Array.isArray(data)) {
380
+ data.forEach(function (sit) {
381
+ var _a = sit.split('='), key = _a[0], value = _a[1];
382
+ it.setAttribute(key.trim(), value.trim());
383
+ });
384
+ }
385
+ else {
386
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
387
+ var _b = _a[_i], key = _b[0], value = _b[1];
388
+ it.setAttribute(key, String(value));
389
+ }
376
390
  }
377
391
  }
378
392
  });
@@ -387,10 +401,18 @@ var eventManager = new (function () {
387
401
  target: it
388
402
  })
389
403
  }));
390
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
391
- var _b = _a[_i], key = _b[0], value = _b[1];
392
- if (it instanceof HTMLElement) {
393
- it.style[key] = String(value);
404
+ if (typeof data === 'string') {
405
+ it.setAttribute('style', data);
406
+ }
407
+ else if (Array.isArray(data)) {
408
+ it.setAttribute('style', data.join(';'));
409
+ }
410
+ else {
411
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
412
+ var _b = _a[_i], key = _b[0], value = _b[1];
413
+ if (it instanceof HTMLElement) {
414
+ it.style[key] = String(value);
415
+ }
394
416
  }
395
417
  }
396
418
  }
@@ -406,14 +428,22 @@ var eventManager = new (function () {
406
428
  target: it
407
429
  })
408
430
  }));
409
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
410
- var _b = _a[_i], key = _b[0], value = _b[1];
411
- if (it instanceof HTMLElement) {
412
- if (value) {
413
- it.classList.add(key);
414
- }
415
- else {
416
- it.classList.remove(key);
431
+ if (typeof data === 'string') {
432
+ it.setAttribute('class', data);
433
+ }
434
+ else if (Array.isArray(data)) {
435
+ it.setAttribute('class', data.join(' '));
436
+ }
437
+ else {
438
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
439
+ var _b = _a[_i], key = _b[0], value = _b[1];
440
+ if (it instanceof HTMLElement) {
441
+ if (value) {
442
+ it.classList.add(key);
443
+ }
444
+ else {
445
+ it.classList.remove(key);
446
+ }
417
447
  }
418
448
  }
419
449
  }
@@ -1031,6 +1061,7 @@ var Shield = (function () {
1031
1061
  return Shield;
1032
1062
  }());
1033
1063
 
1064
+ var excludeGetSetPropertys = ['onBeforeReturnGet', 'onBeforeReturnSet', '__domrender_components', '__render', '_DomRender_isFinal', '_domRender_ref', '_rawSets', '_domRender_proxy', '_targets', '_DomRender_origin', '_DomRender_ref', '_DomRender_proxy'];
1034
1065
  var DomRenderProxy = (function () {
1035
1066
  function DomRenderProxy(_domRender_origin, target, config) {
1036
1067
  this._domRender_origin = _domRender_origin;
@@ -1113,14 +1144,17 @@ var DomRenderProxy = (function () {
1113
1144
  }
1114
1145
  });
1115
1146
  };
1116
- DomRenderProxy.prototype.root = function (paths, value) {
1147
+ DomRenderProxy.prototype.root = function (paths, value, lastDoneExecute) {
1117
1148
  var _this = this;
1149
+ if (lastDoneExecute === void 0) { lastDoneExecute = true; }
1150
+ var fullPaths = [];
1118
1151
  if (this._domRender_ref.size > 0) {
1119
1152
  this._domRender_ref.forEach(function (it, key) {
1120
1153
  if ('_DomRender_isProxy' in key) {
1121
1154
  it.forEach(function (sit) {
1122
1155
  var _a;
1123
- (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value);
1156
+ var items = (_a = key._DomRender_proxy) === null || _a === void 0 ? void 0 : _a.root(paths.concat(sit), value, lastDoneExecute);
1157
+ fullPaths.push(items.join(','));
1124
1158
  });
1125
1159
  }
1126
1160
  });
@@ -1128,39 +1162,47 @@ var DomRenderProxy = (function () {
1128
1162
  else {
1129
1163
  var strings = paths.reverse();
1130
1164
  var fullPathStr_1 = strings.join('.');
1131
- var iterable = this._rawSets.get(fullPathStr_1);
1132
- var front = strings.slice(0, strings.length - 1).join('.');
1133
- var last = strings[strings.length - 1];
1134
- if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn('this.' + front, this._domRender_proxy))) {
1135
- var aIterable = this._rawSets.get(front);
1136
- if (aIterable) {
1137
- this.render(Array.from(aIterable));
1165
+ if (lastDoneExecute) {
1166
+ var iterable = this._rawSets.get(fullPathStr_1);
1167
+ var front = strings.slice(0, strings.length - 1).join('.');
1168
+ var last = strings[strings.length - 1];
1169
+ if (!isNaN(Number(last)) && Array.isArray(ScriptUtils.evalReturn('this.' + front, this._domRender_proxy))) {
1170
+ var aIterable = this._rawSets.get(front);
1171
+ if (aIterable) {
1172
+ this.render(Array.from(aIterable));
1173
+ }
1138
1174
  }
1139
- }
1140
- else if (iterable) {
1141
- this.render(Array.from(iterable));
1142
- }
1143
- this._targets.forEach(function (it) {
1144
- if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
1145
- var targets = eventManager.findAttrElements(it, _this.config);
1146
- eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
1175
+ else if (iterable) {
1176
+ this.render(Array.from(iterable));
1147
1177
  }
1148
- });
1178
+ this._targets.forEach(function (it) {
1179
+ if (it.nodeType === Node.DOCUMENT_FRAGMENT_NODE || it.nodeType === Node.ELEMENT_NODE) {
1180
+ var targets = eventManager.findAttrElements(it, _this.config);
1181
+ eventManager.changeVar(_this._domRender_proxy, targets, "this." + fullPathStr_1);
1182
+ }
1183
+ });
1184
+ }
1185
+ fullPaths.push(fullPathStr_1);
1149
1186
  }
1187
+ return fullPaths;
1150
1188
  };
1151
1189
  DomRenderProxy.prototype.set = function (target, p, value, receiver) {
1152
- var _a, _b;
1190
+ var _a, _b, _c, _d;
1153
1191
  if (typeof p === 'string') {
1154
1192
  value = this.proxy(receiver, value, p);
1155
1193
  }
1156
1194
  target[p] = value;
1195
+ var fullPath;
1157
1196
  if (typeof p === 'string') {
1158
- this.root([p], value);
1197
+ fullPath = this.root([p], value);
1198
+ }
1199
+ if (('onBeforeReturnSet' in receiver) && typeof p === 'string' && !((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeOnBeforeReturnSets) !== null && _b !== void 0 ? _b : []).concat(excludeGetSetPropertys).includes(p)) {
1200
+ (_d = (_c = receiver) === null || _c === void 0 ? void 0 : _c.onBeforeReturnSet) === null || _d === void 0 ? void 0 : _d.call(_c, p, value, fullPath);
1159
1201
  }
1160
- (_b = (_a = receiver) === null || _a === void 0 ? void 0 : _a.onBeforeReturnSet) === null || _b === void 0 ? void 0 : _b.call(_a, p, value);
1161
1202
  return true;
1162
1203
  };
1163
1204
  DomRenderProxy.prototype.get = function (target, p, receiver) {
1205
+ var _a, _b, _c, _d;
1164
1206
  if (p === '_DomRender_origin') {
1165
1207
  return this._domRender_origin;
1166
1208
  }
@@ -1175,6 +1217,9 @@ var DomRenderProxy = (function () {
1175
1217
  if (it_1 && typeof it_1 === 'object' && ('_DomRender_isProxy' in it_1) && Object.prototype.toString.call(it_1._DomRender_origin) === '[object Date]') {
1176
1218
  it_1 = it_1._DomRender_origin;
1177
1219
  }
1220
+ if (('onBeforeReturnGet' in receiver) && typeof p === 'string' && !((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.proxyExcludeOnBeforeReturnGets) !== null && _b !== void 0 ? _b : []).concat(excludeGetSetPropertys).includes(p)) {
1221
+ (_d = (_c = receiver) === null || _c === void 0 ? void 0 : _c.onBeforeReturnGet) === null || _d === void 0 ? void 0 : _d.call(_c, p, it_1, this.root([p], it_1, false));
1222
+ }
1178
1223
  return it_1;
1179
1224
  }
1180
1225
  };
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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any, fullPath?: string[]): void;
3
3
  }
@@ -1,3 +1,3 @@
1
1
  export interface OnBeforeReturnSet {
2
- onBeforeReturnSet(name: string, value: any): void;
2
+ onBeforeReturnSet(name: string, value: any, fullPath?: string[]): void;
3
3
  }
@@ -0,0 +1,8 @@
1
+ export declare abstract class Validation {
2
+ value: string;
3
+ abstract valid(): boolean;
4
+ childValid(): boolean;
5
+ childInValid(): boolean;
6
+ get length(): number;
7
+ [name: string]: Validation | string | undefined | Element | any;
8
+ }
@@ -127,9 +127,23 @@ export var eventManager = new (function () {
127
127
  target: it
128
128
  })
129
129
  }));
130
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
131
- var _b = _a[_i], key = _b[0], value = _b[1];
132
- it.setAttribute(key, String(value));
130
+ if (typeof data === 'string') {
131
+ data.split(',').forEach(function (sit) {
132
+ var _a = sit.split('='), key = _a[0], value = _a[1];
133
+ it.setAttribute(key.trim(), value.trim());
134
+ });
135
+ }
136
+ else if (Array.isArray(data)) {
137
+ data.forEach(function (sit) {
138
+ var _a = sit.split('='), key = _a[0], value = _a[1];
139
+ it.setAttribute(key.trim(), value.trim());
140
+ });
141
+ }
142
+ else {
143
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
144
+ var _b = _a[_i], key = _b[0], value = _b[1];
145
+ it.setAttribute(key, String(value));
146
+ }
133
147
  }
134
148
  }
135
149
  });
@@ -144,10 +158,18 @@ export var eventManager = new (function () {
144
158
  target: it
145
159
  })
146
160
  }));
147
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
148
- var _b = _a[_i], key = _b[0], value = _b[1];
149
- if (it instanceof HTMLElement) {
150
- it.style[key] = String(value);
161
+ if (typeof data === 'string') {
162
+ it.setAttribute('style', data);
163
+ }
164
+ else if (Array.isArray(data)) {
165
+ it.setAttribute('style', data.join(';'));
166
+ }
167
+ else {
168
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
169
+ var _b = _a[_i], key = _b[0], value = _b[1];
170
+ if (it instanceof HTMLElement) {
171
+ it.style[key] = String(value);
172
+ }
151
173
  }
152
174
  }
153
175
  }
@@ -163,14 +185,22 @@ export var eventManager = new (function () {
163
185
  target: it
164
186
  })
165
187
  }));
166
- for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
167
- var _b = _a[_i], key = _b[0], value = _b[1];
168
- if (it instanceof HTMLElement) {
169
- if (value) {
170
- it.classList.add(key);
171
- }
172
- else {
173
- it.classList.remove(key);
188
+ if (typeof data === 'string') {
189
+ it.setAttribute('class', data);
190
+ }
191
+ else if (Array.isArray(data)) {
192
+ it.setAttribute('class', data.join(' '));
193
+ }
194
+ else {
195
+ for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
196
+ var _b = _a[_i], key = _b[0], value = _b[1];
197
+ if (it instanceof HTMLElement) {
198
+ if (value) {
199
+ it.classList.add(key);
200
+ }
201
+ else {
202
+ it.classList.remove(key);
203
+ }
174
204
  }
175
205
  }
176
206
  }
@@ -1,3 +1,3 @@
1
1
  export interface OnBeforeReturnGet {
2
- onBeforeReturnGet(name: string, value: any): void;
2
+ onBeforeReturnGet(name: string, value: any, fullPath?: string[]): void;
3
3
  }
@@ -1,3 +1,3 @@
1
1
  export interface OnBeforeReturnSet {
2
- onBeforeReturnSet(name: string, value: any): void;
2
+ onBeforeReturnSet(name: string, value: any, fullPath?: string[]): void;
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dom-render",
3
- "version": "1.0.46",
3
+ "version": "1.0.50",
4
4
  "main": "DomRender.js",
5
5
  "license": "MIT",
6
6
  "description": "dom-render",
@@ -55,7 +55,7 @@
55
55
  "bundle:watch": "rollup -c -w",
56
56
  "dev:start": "npm run start --workspace=dev",
57
57
  "dev:serve": "npm run serve --workspace=dev",
58
- "npm-build": "npm run build && cp package.json dist && cp README.MD dist",
58
+ "npm-build": "npm run build && cp package.json dist && cp .npmignore dist && cp README.MD dist",
59
59
  "npm-publish": "npm run npm-build && npm publish ./dist",
60
60
  "tsc": "tsc",
61
61
  "tsc:watch": "rm -rf ./dist && mkdir dist && cp package.json dist && tsc --watch --sourceMap true",
@@ -0,0 +1,8 @@
1
+ export declare abstract class Validation {
2
+ value: string;
3
+ abstract valid(): boolean;
4
+ childValid(): boolean;
5
+ childInValid(): boolean;
6
+ get length(): number;
7
+ [name: string]: Validation | string | undefined | Element | any;
8
+ }
@@ -0,0 +1,25 @@
1
+ var Validation = (function () {
2
+ function Validation() {
3
+ this.value = '';
4
+ }
5
+ Validation.prototype.childValid = function () {
6
+ return !this.childInValid();
7
+ };
8
+ Validation.prototype.childInValid = function () {
9
+ var inValid = Object.entries(this).filter(function (_a) {
10
+ var k = _a[0], v = _a[1];
11
+ return (v instanceof Validation) && !v.valid();
12
+ });
13
+ return inValid.length > 0;
14
+ };
15
+ Object.defineProperty(Validation.prototype, "length", {
16
+ get: function () {
17
+ var _a, _b;
18
+ return (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
19
+ },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+ return Validation;
24
+ }());
25
+ export { Validation };
package/assets/banner.png DELETED
Binary file