@onetype/framework 2.0.44 → 2.0.46

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.
Files changed (31) hide show
  1. package/addons/core/assets/back/functions/import.js +3 -3
  2. package/addons/core/commands/front/directives/run.js +1 -1
  3. package/addons/core/commands/front/directives/submit.js +1 -1
  4. package/addons/render/directives/front/items/self/100-if.js +25 -22
  5. package/addons/render/directives/front/items/self/1000-render.js +36 -33
  6. package/addons/render/directives/front/items/self/110-show.js +23 -20
  7. package/addons/render/directives/front/items/self/160-slot.js +33 -30
  8. package/addons/render/directives/front/items/self/200-for.js +71 -68
  9. package/addons/render/directives/front/items/self/2000-base.js +36 -33
  10. package/addons/render/directives/front/items/self/500-click-outside.js +37 -34
  11. package/addons/render/directives/front/items/self/500-events.js +1 -1
  12. package/addons/render/directives/front/items/self/500-mouse-enter.js +1 -1
  13. package/addons/render/directives/front/items/self/500-mouse-leave.js +1 -1
  14. package/addons/render/directives/front/items/self/650-fetch.js +150 -149
  15. package/addons/render/directives/front/items/self/660-form.js +217 -219
  16. package/addons/render/directives/front/items/self/700-text.js +42 -39
  17. package/addons/render/directives/front/items/self/750-html.js +38 -35
  18. package/addons/render/directives/front/items/self/750-node.js +1 -1
  19. package/addons/render/elements/front/items/directives/element.js +2 -2
  20. package/addons/render/html/items/assets/favicon.js +1 -1
  21. package/addons/render/pages/front/items/directives/change.js +1 -1
  22. package/addons/render/transforms/js/items/self/transform.js +1 -1
  23. package/lib/boot/load.js +105 -0
  24. package/lib/load.js +2 -1
  25. package/lib/src/classes/addon/classes/item/mixins/get.js +12 -1
  26. package/lib/src/classes/addon/classes/item/mixins/set.js +24 -2
  27. package/lib/src/classes/addon/mixins/items.js +48 -4
  28. package/lib/src/mixins/addons.js +27 -29
  29. package/lib/src/mixins/dependencies.js +24 -17
  30. package/package.json +1 -1
  31. package/lib/events.js +0 -106
@@ -1,7 +1,7 @@
1
1
  import assets from '../addon.js';
2
2
  import onetype from '#framework/load.js';
3
3
 
4
- assets.Fn('import', function(modules)
4
+ assets.Fn('import', function(modules, order = 10)
5
5
  {
6
6
  for (let i = 0; i < modules.length; i++)
7
7
  {
@@ -12,12 +12,12 @@ assets.Fn('import', function(modules)
12
12
  {
13
13
  if (registered.js)
14
14
  {
15
- assets.Item({ type: 'js', order: i, path: registered.js.path, ignore: registered.js.exclude || [] });
15
+ assets.Item({ type: 'js', order: order + i, path: registered.js.path, ignore: registered.js.exclude || [] });
16
16
  }
17
17
 
18
18
  if (registered.css)
19
19
  {
20
- assets.Item({ type: 'css', order: i, path: registered.css.path, ignore: registered.css.exclude || [] });
20
+ assets.Item({ type: 'css', order: order + i, path: registered.css.path, ignore: registered.css.exclude || [] });
21
21
  }
22
22
  }
23
23
  }
@@ -1,4 +1,4 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
3
  directives.ItemAdd({
4
4
  id: 'ot-command',
@@ -1,4 +1,4 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
3
  directives.ItemAdd({
4
4
  id: 'ot-command-submit',
@@ -1,25 +1,28 @@
1
- directives.ItemAdd({
2
- id: 'ot-if',
3
- icon: 'rule',
4
- name: 'If',
5
- description: 'Conditionally render elements based on expressions. Removes elements from DOM when condition is false.',
6
- category: 'control-flow',
7
- trigger: 'node',
8
- order: 100,
9
- strict: false,
10
- attributes: {
11
- 'ot-if': ['string']
12
- },
13
- code: function(data, item, compile, node, identifier)
14
- {
15
- const expression = data['ot-if'].value;
16
- const result = onetype.Function(expression, compile.data, false);
17
-
18
- if (!result)
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-if',
5
+ icon: 'rule',
6
+ name: 'If',
7
+ description: 'Conditionally render elements based on expressions. Removes elements from DOM when condition is false.',
8
+ category: 'control-flow',
9
+ trigger: 'node',
10
+ order: 100,
11
+ strict: false,
12
+ attributes: {
13
+ 'ot-if': ['string']
14
+ },
15
+ code: function(data, item, compile, node, identifier)
19
16
  {
20
- const placeholder = document.createComment('ot-if:' + identifier);
21
- node.replaceWith(placeholder);
22
- return false;
17
+ const expression = data['ot-if'].value;
18
+ const result = onetype.Function(expression, compile.data, false);
19
+
20
+ if (!result)
21
+ {
22
+ const placeholder = document.createComment('ot-if:' + identifier);
23
+ node.replaceWith(placeholder);
24
+ return false;
25
+ }
23
26
  }
24
- }
27
+ });
25
28
  });
@@ -1,37 +1,40 @@
1
- directives.ItemAdd({
2
- id: 'ot-render',
3
- icon: 'code',
4
- name: 'Render',
5
- description: 'Render components or elements into the DOM. Use <render name="property"> to inject render instances from the parent context.',
6
- category: 'content',
7
- trigger: 'node',
8
- order: 1000,
9
- tag: 'render',
10
- attributes: {
11
- 'name': ['string']
12
- },
13
- code: function(data, item, compile, node)
14
- {
15
- const name = data['name'].value;
16
-
17
- if(!name)
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-render',
5
+ icon: 'code',
6
+ name: 'Render',
7
+ description: 'Render components or elements into the DOM. Use <render name="property"> to inject render instances from the parent context.',
8
+ category: 'content',
9
+ trigger: 'node',
10
+ order: 1000,
11
+ tag: 'render',
12
+ attributes: {
13
+ 'name': ['string']
14
+ },
15
+ code: function(data, item, compile, node)
18
16
  {
19
- console.error('Render directive requires a name attribute');
20
- node.remove();
21
- return false;
22
- }
17
+ const name = data['name'].value;
23
18
 
24
- if(item[name] && item[name].Element)
25
- {
26
- item[name].Element.__otExternal = { name: 'render', key: name };
27
- node.replaceWith(item[name].Element);
28
- }
29
- else
30
- {
31
- console.warn(`Render property "${name}" not found or is not a render instance`);
32
- node.remove();
33
- }
19
+ if(!name)
20
+ {
21
+ console.error('Render directive requires a name attribute');
22
+ node.remove();
23
+ return false;
24
+ }
25
+
26
+ if(item[name] && item[name].Element)
27
+ {
28
+ item[name].Element.__otExternal = { name: 'render', key: name };
29
+ node.replaceWith(item[name].Element);
30
+ }
31
+ else
32
+ {
33
+ console.warn(`Render property "${name}" not found or is not a render instance`);
34
+ node.remove();
35
+ }
34
36
 
35
- return false;
36
- }
37
+ return false;
38
+ }
39
+ });
37
40
  });
@@ -1,23 +1,26 @@
1
- directives.ItemAdd({
2
- id: 'ot-show',
3
- icon: 'visibility',
4
- name: 'Show',
5
- description: 'Toggle element visibility with CSS display property. Hides elements when condition is false without removing from DOM.',
6
- category: 'control-flow',
7
- trigger: 'node',
8
- order: 110,
9
- attributes: {
10
- 'ot-show': ['string']
11
- },
12
- code: function(data, item, compile, node, identifier)
13
- {
14
- if(!onetype.Function(data['ot-show'].value, compile.data, false))
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-show',
5
+ icon: 'visibility',
6
+ name: 'Show',
7
+ description: 'Toggle element visibility with CSS display property. Hides elements when condition is false without removing from DOM.',
8
+ category: 'control-flow',
9
+ trigger: 'node',
10
+ order: 110,
11
+ attributes: {
12
+ 'ot-show': ['string']
13
+ },
14
+ code: function(data, item, compile, node, identifier)
15
15
  {
16
- node.style.display = 'none';
16
+ if(!onetype.Function(data['ot-show'].value, compile.data, false))
17
+ {
18
+ node.style.display = 'none';
19
+ }
20
+ else if(node.style.display === 'none')
21
+ {
22
+ node.style.display = '';
23
+ }
17
24
  }
18
- else if(node.style.display === 'none')
19
- {
20
- node.style.display = '';
21
- }
22
- }
25
+ });
23
26
  });
@@ -1,33 +1,36 @@
1
- directives.ItemAdd({
2
- id: 'ot-slot',
3
- icon: 'input',
4
- name: 'Slot',
5
- description: 'Insert slot content. Supports DOM elements and render instances.',
6
- category: 'content',
7
- trigger: 'node',
8
- order: 160,
9
- tag: 'slot',
10
- attributes: {
11
- 'name': ['string']
12
- },
13
- code: function(data, item, compile, node, id)
14
- {
15
- const name = data['name']?.value || 'default';
16
- const slot = item.Slots[name];
17
-
18
- if (slot && slot.Element)
19
- {
20
- slot.Element.__otExternal = { name: 'slot', key: name };
21
- node.replaceWith(slot.Element);
22
- }
23
- else if (slot && slot.html && slot.data)
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-slot',
5
+ icon: 'input',
6
+ name: 'Slot',
7
+ description: 'Insert slot content. Supports DOM elements and render instances.',
8
+ category: 'content',
9
+ trigger: 'node',
10
+ order: 160,
11
+ tag: 'slot',
12
+ attributes: {
13
+ 'name': ['string']
14
+ },
15
+ code: function(data, item, compile, node, id)
24
16
  {
25
- const compiled = item.Compile(slot.html, slot.data);
26
- node.replaceWith(...compiled.element.childNodes);
27
- }
28
- else
29
- {
30
- node.remove();
17
+ const name = data['name']?.value || 'default';
18
+ const slot = item.Slots[name];
19
+
20
+ if (slot && slot.Element)
21
+ {
22
+ slot.Element.__otExternal = { name: 'slot', key: name };
23
+ node.replaceWith(slot.Element);
24
+ }
25
+ else if (slot && slot.html && slot.data)
26
+ {
27
+ const compiled = item.Compile(slot.html, slot.data);
28
+ node.replaceWith(...compiled.element.childNodes);
29
+ }
30
+ else
31
+ {
32
+ node.remove();
33
+ }
31
34
  }
32
- }
35
+ });
33
36
  });
@@ -1,87 +1,90 @@
1
- directives.ItemAdd({
2
- id: 'ot-for',
3
- icon: 'repeat',
4
- name: 'For',
5
- description: 'Loop through arrays and objects to render multiple elements. Supports item and index variables for complex iterations.',
6
- category: 'control-flow',
7
- trigger: 'node',
8
- order: 200,
9
- attributes: {
10
- 'ot-for': ['string']
11
- },
12
- code: function(data, item, compile, node, identifier)
13
- {
14
- const expression = data['ot-for'].value;
15
- const match = expression.match(/(\w+)(?:\s*,\s*(\w+))?\s+in\s+(.+)/);
16
-
17
- if (!match)
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-for',
5
+ icon: 'repeat',
6
+ name: 'For',
7
+ description: 'Loop through arrays and objects to render multiple elements. Supports item and index variables for complex iterations.',
8
+ category: 'control-flow',
9
+ trigger: 'node',
10
+ order: 200,
11
+ attributes: {
12
+ 'ot-for': ['string']
13
+ },
14
+ code: function(data, item, compile, node, identifier)
18
15
  {
19
- onetype.Error(400, 'Invalid ot-for syntax. Expected: "item in items".');
20
- return;
21
- }
16
+ const expression = data['ot-for'].value;
17
+ const match = expression.match(/(\w+)(?:\s*,\s*(\w+))?\s+in\s+(.+)/);
22
18
 
23
- const originalChildren = compile.children;
24
- compile.children = false;
19
+ if (!match)
20
+ {
21
+ onetype.Error(400, 'Invalid ot-for syntax. Expected: "item in items".');
22
+ return;
23
+ }
25
24
 
26
- const forName = match[1];
27
- const forIndex = match[2] || forName + '_index';
28
- const forExpression = match[3];
25
+ const originalChildren = compile.children;
26
+ compile.children = false;
29
27
 
30
- try
31
- {
32
- let items = onetype.Function(forExpression, compile.data, false);
28
+ const forName = match[1];
29
+ const forIndex = match[2] || forName + '_index';
30
+ const forExpression = match[3];
33
31
 
34
- if (!Array.isArray(items) && items && typeof items === 'object')
32
+ try
35
33
  {
36
- if (items[Symbol.iterator])
34
+ let items = onetype.Function(forExpression, compile.data, false);
35
+
36
+ if (!Array.isArray(items) && items && typeof items === 'object')
37
37
  {
38
- items = Array.from(items);
38
+ if (items[Symbol.iterator])
39
+ {
40
+ items = Array.from(items);
41
+ }
42
+ else
43
+ {
44
+ items = Object.entries(items);
45
+ }
39
46
  }
40
- else
47
+ else if (!Array.isArray(items))
41
48
  {
42
- items = Object.entries(items);
49
+ throw onetype.Error(400, 'ot-for expects an array or iterable.');
43
50
  }
44
- }
45
- else if (!Array.isArray(items))
46
- {
47
- throw onetype.Error(400, 'ot-for expects an array or iterable.');
48
- }
49
-
50
- const html = node.outerHTML;
51
- const fragment = document.createDocumentFragment();
52
-
53
- items.forEach((value, index) =>
54
- {
55
- const loopData = Object.assign({}, compile.data);
56
- loopData[forName] = value;
57
- loopData[forIndex] = index;
58
51
 
59
- const compiled = item.Compile(html, loopData);
60
- const key = onetype.GenerateHash(index + ':' + (typeof value === 'object' ? JSON.stringify(value) : String(value)));
52
+ const html = node.outerHTML;
53
+ const fragment = document.createDocumentFragment();
61
54
 
62
- while(compiled.element.firstChild)
55
+ items.forEach((value, index) =>
63
56
  {
64
- const child = compiled.element.firstChild;
57
+ const loopData = Object.assign({}, compile.data);
58
+ loopData[forName] = value;
59
+ loopData[forIndex] = index;
60
+
61
+ const compiled = item.Compile(html, loopData);
62
+ const key = onetype.GenerateHash(index + ':' + (typeof value === 'object' ? JSON.stringify(value) : String(value)));
65
63
 
66
- if(child.nodeType === Node.ELEMENT_NODE)
64
+ while(compiled.element.firstChild)
67
65
  {
68
- child.setAttribute('ot-key', key);
69
- }
66
+ const child = compiled.element.firstChild;
70
67
 
71
- fragment.appendChild(child);
72
- }
73
- });
68
+ if(child.nodeType === Node.ELEMENT_NODE)
69
+ {
70
+ child.setAttribute('ot-key', key);
71
+ }
74
72
 
75
- node.before(fragment);
76
- node.remove();
77
- }
78
- catch (error)
79
- {
80
- onetype.Error(500, 'Error in ot-for directive.');
81
- }
82
- finally
83
- {
84
- compile.children = originalChildren;
73
+ fragment.appendChild(child);
74
+ }
75
+ });
76
+
77
+ node.before(fragment);
78
+ node.remove();
79
+ }
80
+ catch (error)
81
+ {
82
+ onetype.Error(500, 'Error in ot-for directive.');
83
+ }
84
+ finally
85
+ {
86
+ compile.children = originalChildren;
87
+ }
85
88
  }
86
- }
89
+ });
87
90
  });
@@ -1,45 +1,48 @@
1
- directives.ItemAdd({
2
- id: 'ot-base',
3
- trigger: 'after',
4
- order: 2000,
5
- code: function(data, item, compile, node)
6
- {
7
- const base = onetype.Base();
8
-
9
- if(!base)
1
+ onetype.AddonReady('directives', function(directives)
2
+ {
3
+ directives.ItemAdd({
4
+ id: 'ot-base',
5
+ trigger: 'after',
6
+ order: 2000,
7
+ code: function(data, item, compile, node)
10
8
  {
11
- return;
12
- }
9
+ const base = onetype.Base();
13
10
 
14
- const walk = (parent) =>
15
- {
16
- for(let i = 0; i < parent.childNodes.length; i++)
11
+ if(!base)
17
12
  {
18
- const child = parent.childNodes[i];
13
+ return;
14
+ }
19
15
 
20
- if(child.nodeType !== 1)
16
+ const walk = (parent) =>
17
+ {
18
+ for(let i = 0; i < parent.childNodes.length; i++)
21
19
  {
22
- continue;
23
- }
20
+ const child = parent.childNodes[i];
24
21
 
25
- if(child.tagName === 'A')
26
- {
27
- const href = child.getAttribute('href');
22
+ if(child.nodeType !== 1)
23
+ {
24
+ continue;
25
+ }
28
26
 
29
- if(href && href.startsWith('/') && !child.__base)
27
+ if(child.tagName === 'A')
30
28
  {
31
- child.setAttribute('href', base + href);
32
- child.__base = base;
29
+ const href = child.getAttribute('href');
30
+
31
+ if(href && href.startsWith('/') && !child.__base)
32
+ {
33
+ child.setAttribute('href', base + href);
34
+ child.__base = base;
35
+ }
33
36
  }
34
- }
35
37
 
36
- if(child.childNodes.length)
37
- {
38
- walk(child);
38
+ if(child.childNodes.length)
39
+ {
40
+ walk(child);
41
+ }
39
42
  }
40
- }
41
- };
43
+ };
42
44
 
43
- walk(node);
44
- }
45
- });
45
+ walk(node);
46
+ }
47
+ });
48
+ });
@@ -1,45 +1,48 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
- const tracked = new Set();
4
-
5
- document.addEventListener('click', function(event)
3
+ onetype.AddonReady('directives', function()
6
4
  {
7
- tracked.forEach((entry) =>
5
+ const tracked = new Set();
6
+
7
+ document.addEventListener('click', function(event)
8
8
  {
9
- if(!document.contains(entry.element))
9
+ tracked.forEach((entry) =>
10
10
  {
11
- tracked.delete(entry);
12
- return;
13
- }
11
+ if(!document.contains(entry.element))
12
+ {
13
+ tracked.delete(entry);
14
+ return;
15
+ }
14
16
 
15
- if(!entry.element.contains(event.target) && entry.element !== event.target)
16
- {
17
- entry.handler(event);
18
- }
17
+ if(!entry.element.contains(event.target) && entry.element !== event.target)
18
+ {
19
+ entry.handler(event);
20
+ }
21
+ });
19
22
  });
20
- });
21
-
22
- directives.ItemAdd({
23
- id: 'ot-click-outside',
24
- trigger: 'node',
25
- order: 500,
26
- attributes: { 'ot-click-outside': ['string'] },
27
- code: function(data, item, compile, node)
28
- {
29
- const attribute = data['ot-click-outside'].value;
30
23
 
31
- tracked.add({
32
- element: node,
33
- handler: (event) =>
34
- {
35
- const result = onetype.Function(attribute, compile.data, false);
24
+ directives.ItemAdd({
25
+ id: 'ot-click-outside',
26
+ trigger: 'node',
27
+ order: 500,
28
+ attributes: { 'ot-click-outside': ['string'] },
29
+ code: function(data, item, compile, node)
30
+ {
31
+ const attribute = data['ot-click-outside'].value;
36
32
 
37
- if(typeof result === 'function')
33
+ tracked.add({
34
+ element: node,
35
+ handler: (event) =>
38
36
  {
39
- result({ event });
37
+ const result = onetype.Function(attribute, compile.data, false);
38
+
39
+ if(typeof result === 'function')
40
+ {
41
+ result({ event });
42
+ }
40
43
  }
41
- }
42
- });
43
- }
44
+ });
45
+ }
46
+ });
44
47
  });
45
- });
48
+ });
@@ -1,4 +1,4 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
3
  const register = (config) =>
4
4
  {
@@ -1,4 +1,4 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
3
  directives.ItemAdd({
4
4
  id: 'ot-mouse-enter',
@@ -1,4 +1,4 @@
1
- onetype.AddonReady('directives', function()
1
+ onetype.AddonReady('directives', function(directives)
2
2
  {
3
3
  directives.ItemAdd({
4
4
  id: 'ot-mouse-leave',