@onetype/framework 2.0.49 → 2.0.52
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/addons/core/commands/front/directives/run.js +1 -1
- package/addons/core/commands/front/directives/submit.js +1 -1
- package/addons/core/commands/front/functions/api.js +1 -1
- package/addons/core/database/back/addon.js +14 -0
- package/addons/core/database/back/events/addon.init.js +42 -0
- package/addons/core/database/back/events/addon.item.init.js +24 -0
- package/addons/core/database/back/functions/item/create.js +92 -0
- package/addons/core/database/back/functions/item/delete.js +34 -0
- package/addons/core/database/back/functions/item/save.js +13 -0
- package/addons/core/database/back/functions/item/update.js +90 -0
- package/addons/core/database/back/functions/items/builder.js +160 -0
- package/addons/core/database/back/functions/items/filter.js +32 -0
- package/addons/core/database/back/functions/items/filters.js +7 -0
- package/addons/core/database/back/functions/items/find.js +28 -0
- package/addons/core/database/back/functions/items/methods/aggregate.js +15 -0
- package/addons/core/database/back/functions/items/methods/count.js +12 -0
- package/addons/core/database/back/functions/items/methods/exists.js +8 -0
- package/addons/core/database/back/functions/items/methods/many.js +13 -0
- package/addons/core/database/back/functions/items/methods/one.js +8 -0
- package/addons/core/database/back/functions/items/methods/plain.js +29 -0
- package/addons/core/database/back/functions/items/methods/query.js +33 -0
- package/addons/core/database/back/functions/items/methods.js +142 -0
- package/addons/core/database/back/functions/items/transform/join.js +63 -0
- package/addons/core/database/back/functions/items/transform/translate.js +57 -0
- package/addons/core/database/back/functions/items/validation.js +125 -0
- package/addons/core/database/back/item/catch/add.js +1 -1
- package/addons/core/database/back/items/commands/create.js +54 -0
- package/addons/core/database/back/items/commands/delete.js +62 -0
- package/addons/core/database/back/items/commands/find.js +118 -0
- package/addons/core/database/back/items/commands/update.js +70 -0
- package/addons/core/database/back/load.js +27 -26
- package/addons/core/database/front/events/addon.init.js +42 -0
- package/addons/core/database/front/functions/create.js +11 -0
- package/addons/core/database/front/functions/delete.js +10 -0
- package/addons/core/database/front/functions/find.js +96 -142
- package/addons/core/database/front/functions/update.js +12 -0
- package/addons/float/popup/css/popup.css +141 -18
- package/addons/float/popup/js/addon.js +5 -0
- package/addons/float/popup/js/functions/confirm.js +100 -0
- package/addons/float/popup/js/functions/toast.js +1 -1
- package/addons/float/popup/js/items/directives/tooltip.js +5 -1
- package/addons/render/directives/front/addon.js +5 -0
- package/addons/render/directives/front/functions/process/data.js +19 -1
- package/addons/render/directives/front/functions/process/locale.js +46 -0
- package/addons/render/directives/front/functions/process.js +4 -1
- package/addons/render/directives/front/items/self/660-form.js +74 -163
- package/addons/render/directives/front/items/self/750-html.js +1 -1
- package/addons/render/elements/front/items/self/form/button/button.css +9 -0
- package/addons/render/elements/front/items/self/form/button/button.js +1 -1
- package/addons/render/elements/front/items/self/form/color/color.css +1 -1
- package/addons/render/elements/front/items/self/form/color/color.js +25 -10
- package/addons/render/elements/front/items/self/form/editor-markdown/editor-markdown.css +410 -0
- package/addons/render/elements/front/items/self/form/editor-markdown/editor-markdown.js +191 -0
- package/addons/render/elements/front/items/self/form/field/field.css +18 -4
- package/addons/render/elements/front/items/self/form/field/field.js +6 -1
- package/addons/render/elements/front/items/self/form/section/section.js +3 -1
- package/addons/render/elements/front/items/self/navigation/tabs/tabs.css +8 -3
- package/addons/render/pages/core/addon.js +1 -1
- package/addons/render/pages/front/items/directives/change.js +1 -1
- package/addons/render/pages/front/styles/page.css +0 -7
- package/addons/render/transforms/js/functions/data.js +21 -2
- package/lib/src/classes/addon/class.js +0 -16
- package/lib/src/classes/addon/classes/item/class.js +0 -2
- package/lib/src/classes/addon/classes/item/mixins/get.js +0 -1
- package/lib/src/classes/addon/classes/render/mixins/compile.js +3 -2
- package/lib/src/classes/addon/mixins/items.js +2 -0
- package/lib/src/mixins/addons.js +2 -0
- package/lib/src/mixins/data.js +10 -9
- package/lib/src/mixins/emitter.js +5 -1
- package/lib/src/mixins/form.js +4 -0
- package/lib/src/mixins/function.js +6 -1
- package/lib/src/mixins/language.js +55 -0
- package/lib/src/mixins/locale.js +49 -0
- package/lib/src/onetype.js +6 -11
- package/package.json +1 -1
- package/addons/core/database/back/events/addon.add.js +0 -18
- package/addons/core/database/back/events/middleware/addon.items.find.js +0 -24
- package/addons/core/database/back/events/middleware/item.crud.create.js +0 -24
- package/addons/core/database/back/events/middleware/item.crud.delete.js +0 -24
- package/addons/core/database/back/events/middleware/item.crud.update.js +0 -24
- package/addons/core/database/back/functions/create.js +0 -6
- package/addons/core/database/back/functions/delete.js +0 -6
- package/addons/core/database/back/functions/find/builder.js +0 -160
- package/addons/core/database/back/functions/find/count.js +0 -12
- package/addons/core/database/back/functions/find/filter.js +0 -37
- package/addons/core/database/back/functions/find/filters.js +0 -7
- package/addons/core/database/back/functions/find/many.js +0 -93
- package/addons/core/database/back/functions/find/methods.js +0 -235
- package/addons/core/database/back/functions/find/plain.js +0 -25
- package/addons/core/database/back/functions/find/validation.js +0 -214
- package/addons/core/database/back/functions/find.js +0 -25
- package/addons/core/database/back/functions/update.js +0 -6
- package/addons/core/database/back/item/functions/create.js +0 -94
- package/addons/core/database/back/item/functions/delete.js +0 -25
- package/addons/core/database/back/item/functions/find.js +0 -19
- package/addons/core/database/back/item/functions/save.js +0 -15
- package/addons/core/database/back/item/functions/transaction.js +0 -17
- package/addons/core/database/back/item/functions/update.js +0 -76
- package/addons/core/database/back/items/commands/expose.js +0 -321
- package/addons/core/database/front/events/addon.add.js +0 -13
- package/lib/src/classes/addon/classes/item/mixins/crud.js +0 -28
- package/lib/src/classes/addon/mixins/find.js +0 -12
- package/lib/src/classes/addon/mixins/table.js +0 -35
- package/lib/src/mixins/dependencies.js +0 -104
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
popup.Fn('confirm', function(title, description, options = {})
|
|
2
|
+
{
|
|
3
|
+
if(typeof description === 'object')
|
|
4
|
+
{
|
|
5
|
+
options = description;
|
|
6
|
+
description = '';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return new Promise((resolve) =>
|
|
10
|
+
{
|
|
11
|
+
const id = 'confirm-' + onetype.GenerateUID();
|
|
12
|
+
let resolved = false;
|
|
13
|
+
|
|
14
|
+
const close = (value) =>
|
|
15
|
+
{
|
|
16
|
+
if(resolved) return;
|
|
17
|
+
resolved = true;
|
|
18
|
+
overlay.Remove();
|
|
19
|
+
resolve(value);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const overlay = overlays.Item({
|
|
23
|
+
id: options.id || id,
|
|
24
|
+
position: { x: 'center', y: 'center' },
|
|
25
|
+
backdrop: options.backdrop ?? 0.4,
|
|
26
|
+
closeable: true,
|
|
27
|
+
escape: true,
|
|
28
|
+
onOpen: (item) =>
|
|
29
|
+
{
|
|
30
|
+
const element = item.Get('element');
|
|
31
|
+
|
|
32
|
+
if(element)
|
|
33
|
+
{
|
|
34
|
+
element.classList.add('ot-modal');
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
onClose: () => close(options.input ? null : false),
|
|
38
|
+
render: function()
|
|
39
|
+
{
|
|
40
|
+
this.value = options.value || '';
|
|
41
|
+
this.hasInput = !!options.input;
|
|
42
|
+
|
|
43
|
+
this.input = ({ value }) =>
|
|
44
|
+
{
|
|
45
|
+
this.value = value;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
this.cancel = () =>
|
|
49
|
+
{
|
|
50
|
+
close(this.hasInput ? null : false);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
this.submit = () =>
|
|
54
|
+
{
|
|
55
|
+
close(this.hasInput ? this.value : true);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.keydown = ({ event }) =>
|
|
59
|
+
{
|
|
60
|
+
if(event.key === 'Enter' && this.hasInput && this.value)
|
|
61
|
+
{
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
this.submit();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
this.title = title || '';
|
|
68
|
+
this.description = description || '';
|
|
69
|
+
this.hasIcon = !!options.icon;
|
|
70
|
+
this.icon = options.icon || '';
|
|
71
|
+
this.type = options.type || 'default';
|
|
72
|
+
this.confirmText = options.confirm || (this.hasInput ? 'Continue' : 'Confirm');
|
|
73
|
+
this.cancelText = options.cancel || 'Cancel';
|
|
74
|
+
this.confirmVariant = (this.type === 'danger') ? ['red', 'size-m'] : ['brand', 'size-m'];
|
|
75
|
+
this.placeholder = options.placeholder || '';
|
|
76
|
+
|
|
77
|
+
return /* html */ `
|
|
78
|
+
<div class="ot-confirm">
|
|
79
|
+
<div ot-if="hasIcon" :class="'icon ' + type"><i>{{ icon }}</i></div>
|
|
80
|
+
<h3 class="title">{{ title }}</h3>
|
|
81
|
+
<p ot-if="description" class="description">{{ description }}</p>
|
|
82
|
+
<div ot-if="hasInput" class="input">
|
|
83
|
+
<e-form-input
|
|
84
|
+
:value="value"
|
|
85
|
+
:placeholder="placeholder"
|
|
86
|
+
:_input="input"
|
|
87
|
+
:variant="['bg-2', 'border', 'size-m']"
|
|
88
|
+
ot-keydown="keydown"
|
|
89
|
+
></e-form-input>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="actions">
|
|
92
|
+
<e-form-button :text="cancelText" :variant="['bg-2', 'border', 'size-m']" :_click="cancel"></e-form-button>
|
|
93
|
+
<e-form-button :text="confirmText" :variant="confirmVariant" :_click="submit"></e-form-button>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
popup.Fn('toast', function(message, options = {})
|
|
2
2
|
{
|
|
3
|
-
const config = typeof message === 'object' ? message : {message};
|
|
3
|
+
const config = typeof message === 'object' ? message : { message, type: 'success' };
|
|
4
4
|
const id = 'toast-' + onetype.GenerateUID();
|
|
5
5
|
const duration = config.duration ?? options.duration ?? 5000;
|
|
6
6
|
|
|
@@ -9,7 +9,11 @@ onetype.AddonReady('directives', function(directives)
|
|
|
9
9
|
if ('otTooltipConfig' in node && !node.otTooltipShow)
|
|
10
10
|
{
|
|
11
11
|
node.otTooltipShow = true;
|
|
12
|
-
|
|
12
|
+
const cfg = node.otTooltipConfig;
|
|
13
|
+
const opts = {};
|
|
14
|
+
if(cfg.position) opts.position = cfg.position;
|
|
15
|
+
if(cfg.offset) opts.offset = cfg.offset;
|
|
16
|
+
node.otTooltipOverlay = popup.Fn('tooltip', node, cfg, opts);
|
|
13
17
|
break;
|
|
14
18
|
}
|
|
15
19
|
|
|
@@ -17,6 +17,11 @@ const directives = onetype.Addon('directives', (addon) =>
|
|
|
17
17
|
|
|
18
18
|
onetype.EmitOn('@addon.render.compile.before', (item, compile, node, identifier) =>
|
|
19
19
|
{
|
|
20
|
+
if(compile.locale !== false)
|
|
21
|
+
{
|
|
22
|
+
directives.Fn('process.locale', node);
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
directives.Fn('process', 'before', item, compile, node, identifier);
|
|
21
26
|
})
|
|
22
27
|
|
|
@@ -60,7 +60,25 @@ directives.Fn('process.data', function(attributes, node, compile)
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
try
|
|
64
|
+
{
|
|
65
|
+
attribute.value = onetype.DataDefineOne(attribute.value, definition);
|
|
66
|
+
}
|
|
67
|
+
catch(error)
|
|
68
|
+
{
|
|
69
|
+
const path = error.path && error.path.length
|
|
70
|
+
? attribute.name + '.' + error.path.join('.').replace(/\.\[/g, '[')
|
|
71
|
+
: attribute.name;
|
|
72
|
+
|
|
73
|
+
onetype.Error(400, 'Directive attribute :path: failed — :reason:', {
|
|
74
|
+
path,
|
|
75
|
+
reason: error.message,
|
|
76
|
+
value: attribute.value
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
attribute.value = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
data[attribute.name] = attribute;
|
|
65
83
|
|
|
66
84
|
if(find && node.removeAttribute)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const skip = ['id', 'class', 'style', 'href', 'src', 'action', 'method', 'type', 'name', 'value', 'for', 'role', 'tabindex', 'width', 'height', 'data', 'slot'];
|
|
2
|
+
|
|
3
|
+
directives.Fn('process.locale', function(node)
|
|
4
|
+
{
|
|
5
|
+
if(node.nodeType === 3)
|
|
6
|
+
{
|
|
7
|
+
const text = node.textContent.trim();
|
|
8
|
+
|
|
9
|
+
if(text && !text.includes('{{') && node.parentNode?.tagName !== 'I')
|
|
10
|
+
{
|
|
11
|
+
node.textContent = node.textContent.replace(text, onetype.LocaleGet(text));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if(node.nodeType === 1)
|
|
18
|
+
{
|
|
19
|
+
for(let i = 0; i < node.attributes.length; i++)
|
|
20
|
+
{
|
|
21
|
+
const attr = node.attributes[i];
|
|
22
|
+
|
|
23
|
+
if(attr.name.startsWith(':') || attr.name.startsWith('ot-'))
|
|
24
|
+
{
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if(skip.includes(attr.name))
|
|
29
|
+
{
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if(!attr.value || !attr.value.trim())
|
|
34
|
+
{
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
attr.value = onetype.LocaleGet(attr.value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for(let i = 0; i < node.childNodes.length; i++)
|
|
42
|
+
{
|
|
43
|
+
directives.Fn('process.locale', node.childNodes[i]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -84,5 +84,8 @@ directives.Fn('process', function(trigger, item, compile, node, identifier)
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
if(node.isConnected || node.parentNode)
|
|
88
|
+
{
|
|
89
|
+
directives.StoreGet('fn.attributes')(node, compile);
|
|
90
|
+
}
|
|
88
91
|
});
|
|
@@ -4,24 +4,25 @@ onetype.AddonReady('directives', function(directives)
|
|
|
4
4
|
id: 'ot-form',
|
|
5
5
|
icon: 'send',
|
|
6
6
|
name: 'Form',
|
|
7
|
-
description: 'Submit form data to endpoint and bind response to component data',
|
|
7
|
+
description: 'Submit form data to endpoint or callback and bind response to component data.',
|
|
8
8
|
category: 'data',
|
|
9
9
|
trigger: 'node',
|
|
10
10
|
order: 660,
|
|
11
|
+
strict: false,
|
|
11
12
|
tag: 'ot-form',
|
|
12
13
|
attributes: {
|
|
13
14
|
'post': ['string'],
|
|
14
15
|
'get': ['string'],
|
|
15
16
|
'endpoint': ['string'],
|
|
16
|
-
'
|
|
17
|
-
'bind': ['string'],
|
|
17
|
+
'bind': ['string', 'form'],
|
|
18
18
|
'method': ['string'],
|
|
19
19
|
'redirect': ['string'],
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
20
|
+
'_submit': ['function'],
|
|
21
|
+
'_success': ['function'],
|
|
22
|
+
'_error': ['function'],
|
|
23
|
+
'reset': ['boolean', false],
|
|
24
|
+
'stop': ['boolean', false],
|
|
25
|
+
'data': ['object', {}]
|
|
25
26
|
},
|
|
26
27
|
code: function(data, item, compile, node, identifier)
|
|
27
28
|
{
|
|
@@ -33,7 +34,6 @@ onetype.AddonReady('directives', function(directives)
|
|
|
33
34
|
methods.config();
|
|
34
35
|
methods.state();
|
|
35
36
|
methods.element();
|
|
36
|
-
methods.compile();
|
|
37
37
|
methods.handler();
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -42,45 +42,16 @@ onetype.AddonReady('directives', function(directives)
|
|
|
42
42
|
const post = data['post']?.value;
|
|
43
43
|
const get = data['get']?.value;
|
|
44
44
|
|
|
45
|
-
config.endpoint = post || get || data['endpoint']?.value ||
|
|
45
|
+
config.endpoint = post || get || data['endpoint']?.value || '';
|
|
46
46
|
config.bind = data['bind']?.value || 'form';
|
|
47
47
|
config.method = get ? 'GET' : (data['method']?.value || 'POST').toUpperCase();
|
|
48
48
|
config.redirect = data['redirect']?.value;
|
|
49
|
-
config.
|
|
50
|
-
config.
|
|
49
|
+
config.onSubmit = data['_submit']?.value;
|
|
50
|
+
config.onSuccess = data['_success']?.value;
|
|
51
|
+
config.onError = data['_error']?.value;
|
|
51
52
|
config.reset = data['reset']?.value || false;
|
|
52
53
|
config.stop = data['stop']?.value || false;
|
|
53
|
-
config.data =
|
|
54
|
-
config.url = methods.normalizeUrl(config.endpoint);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
methods.parseData = () =>
|
|
58
|
-
{
|
|
59
|
-
const dataAttr = data['data']?.value;
|
|
60
|
-
|
|
61
|
-
if(!dataAttr)
|
|
62
|
-
{
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try
|
|
67
|
-
{
|
|
68
|
-
return JSON.parse(dataAttr);
|
|
69
|
-
}
|
|
70
|
-
catch(e)
|
|
71
|
-
{
|
|
72
|
-
return onetype.Function(dataAttr, compile.data, false) || {};
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
methods.normalizeUrl = (endpoint) =>
|
|
77
|
-
{
|
|
78
|
-
if(/^https?:\/\//.test(endpoint))
|
|
79
|
-
{
|
|
80
|
-
return endpoint;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return endpoint.startsWith('/') ? endpoint : '/' + endpoint;
|
|
54
|
+
config.data = data['data']?.value || {};
|
|
84
55
|
};
|
|
85
56
|
|
|
86
57
|
methods.state = () =>
|
|
@@ -97,32 +68,21 @@ onetype.AddonReady('directives', function(directives)
|
|
|
97
68
|
|
|
98
69
|
methods.element = () =>
|
|
99
70
|
{
|
|
100
|
-
config.html = node.innerHTML;
|
|
101
71
|
config.form = document.createElement('form');
|
|
102
72
|
config.form.setAttribute('autocomplete', 'off');
|
|
103
73
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Array.from(node.attributes).forEach(attr =>
|
|
74
|
+
while(node.firstChild)
|
|
107
75
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
config.form.setAttribute(attr.name, attr.value);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
76
|
+
config.form.appendChild(node.firstChild);
|
|
77
|
+
}
|
|
114
78
|
|
|
115
|
-
|
|
116
|
-
{
|
|
117
|
-
const compiled = item.Compile(config.html, compile.data);
|
|
79
|
+
node.appendChild(config.form);
|
|
118
80
|
|
|
119
|
-
|
|
81
|
+
if(config.data && typeof config.data === 'object' && Object.keys(config.data).length)
|
|
120
82
|
{
|
|
121
|
-
|
|
83
|
+
Object.assign(compile.data, config.data);
|
|
84
|
+
requestAnimationFrame(() => onetype.FormSet(config.form, config.data));
|
|
122
85
|
}
|
|
123
|
-
|
|
124
|
-
node.replaceWith(config.form);
|
|
125
|
-
compile.children = false;
|
|
126
86
|
};
|
|
127
87
|
|
|
128
88
|
methods.handler = () =>
|
|
@@ -136,146 +96,97 @@ onetype.AddonReady('directives', function(directives)
|
|
|
136
96
|
event.stopPropagation();
|
|
137
97
|
}
|
|
138
98
|
|
|
139
|
-
|
|
99
|
+
const form = event.target.closest('form') || event.target;
|
|
100
|
+
|
|
101
|
+
await methods.submit(form);
|
|
140
102
|
};
|
|
141
103
|
};
|
|
142
104
|
|
|
143
|
-
methods.submit = async () =>
|
|
105
|
+
methods.submit = async (form) =>
|
|
144
106
|
{
|
|
145
107
|
const state = compile.data[config.bind];
|
|
146
|
-
const formData = methods.extract();
|
|
147
|
-
|
|
148
|
-
state.loading = true;
|
|
149
|
-
state.error = null;
|
|
150
|
-
|
|
151
|
-
try
|
|
152
|
-
{
|
|
153
|
-
const submitData = Object.assign({}, formData, config.data);
|
|
154
|
-
const response = await methods.fetch(submitData);
|
|
155
|
-
|
|
156
|
-
state.response = response.data !== undefined ? response.data : response;
|
|
157
|
-
state.error = null;
|
|
158
|
-
state.loading = false;
|
|
159
108
|
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
catch(err)
|
|
109
|
+
if(state.loading)
|
|
163
110
|
{
|
|
164
|
-
|
|
165
|
-
state.error = err.message;
|
|
166
|
-
state.loading = false;
|
|
167
|
-
|
|
168
|
-
methods.error(err);
|
|
169
|
-
}
|
|
170
|
-
finally
|
|
171
|
-
{
|
|
172
|
-
compile.data.Update();
|
|
111
|
+
return;
|
|
173
112
|
}
|
|
174
|
-
};
|
|
175
113
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const formData = {};
|
|
179
|
-
const inputs = config.form.querySelectorAll('input[name], textarea[name], select[name]');
|
|
114
|
+
const formData = onetype.FormGet(form);
|
|
115
|
+
const submitData = Object.assign({}, config.data, formData);
|
|
180
116
|
|
|
181
|
-
|
|
117
|
+
if(config.onSubmit)
|
|
182
118
|
{
|
|
183
|
-
const
|
|
119
|
+
const result = await config.onSubmit(submitData);
|
|
184
120
|
|
|
185
|
-
if(
|
|
121
|
+
if(result === false)
|
|
186
122
|
{
|
|
123
|
+
compile.data.Update();
|
|
187
124
|
return;
|
|
188
125
|
}
|
|
189
|
-
|
|
190
|
-
if(input.type === 'checkbox')
|
|
191
|
-
{
|
|
192
|
-
formData[name] = input.checked;
|
|
193
|
-
}
|
|
194
|
-
else if(input.type === 'radio')
|
|
195
|
-
{
|
|
196
|
-
if(input.checked)
|
|
197
|
-
{
|
|
198
|
-
formData[name] = input.value;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else
|
|
202
|
-
{
|
|
203
|
-
formData[name] = input.value;
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
return formData;
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
methods.fetch = async (data) =>
|
|
211
|
-
{
|
|
212
|
-
const response = await fetch(config.url, {
|
|
213
|
-
method: config.method,
|
|
214
|
-
headers: { 'Content-Type': 'application/json' },
|
|
215
|
-
body: JSON.stringify(data)
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
if(!response.ok)
|
|
219
|
-
{
|
|
220
|
-
throw onetype.Error(response.status, 'HTTP :status:.', {status: response.status});
|
|
221
126
|
}
|
|
222
127
|
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
methods.success = () =>
|
|
227
|
-
{
|
|
228
|
-
if(config.reset)
|
|
128
|
+
if(!config.endpoint)
|
|
229
129
|
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
{
|
|
235
|
-
onetype.AddonGet('pages')?.Fn('change', null, config.redirect);
|
|
130
|
+
state.response = submitData;
|
|
131
|
+
config.onSuccess && await config.onSuccess(submitData);
|
|
132
|
+
config.reset && form.reset();
|
|
133
|
+
compile.data.Update();
|
|
236
134
|
return;
|
|
237
135
|
}
|
|
238
136
|
|
|
239
|
-
|
|
137
|
+
state.loading = true;
|
|
138
|
+
state.error = null;
|
|
139
|
+
compile.data.Update();
|
|
140
|
+
|
|
141
|
+
try
|
|
240
142
|
{
|
|
241
|
-
const
|
|
143
|
+
const url = config.endpoint.startsWith('/') ? config.endpoint : '/' + config.endpoint;
|
|
144
|
+
|
|
145
|
+
const response = await fetch(url, {
|
|
146
|
+
method: config.method,
|
|
147
|
+
headers: { 'Content-Type': 'application/json' },
|
|
148
|
+
body: JSON.stringify(submitData)
|
|
149
|
+
});
|
|
242
150
|
|
|
243
|
-
if(
|
|
151
|
+
if(!response.ok)
|
|
244
152
|
{
|
|
245
|
-
|
|
153
|
+
throw onetype.Error(response.status, 'HTTP :status:.', { status: response.status });
|
|
246
154
|
}
|
|
247
|
-
}
|
|
248
155
|
|
|
249
|
-
|
|
250
|
-
bind: config.bind,
|
|
251
|
-
response: compile.data[config.bind].response
|
|
252
|
-
});
|
|
253
|
-
};
|
|
156
|
+
const result = await response.json();
|
|
254
157
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
158
|
+
state.response = result.data !== undefined ? result.data : result;
|
|
159
|
+
state.error = null;
|
|
160
|
+
state.loading = false;
|
|
258
161
|
|
|
259
|
-
|
|
260
|
-
{
|
|
261
|
-
const callback = onetype.Function(config.onError, compile.data, false);
|
|
162
|
+
config.reset && form.reset();
|
|
262
163
|
|
|
263
|
-
if(
|
|
164
|
+
if(config.redirect)
|
|
264
165
|
{
|
|
265
|
-
|
|
166
|
+
onetype.AddonGet('pages')?.Fn('change', null, config.redirect);
|
|
167
|
+
return;
|
|
266
168
|
}
|
|
169
|
+
|
|
170
|
+
config.onSuccess && config.onSuccess(state);
|
|
267
171
|
}
|
|
172
|
+
catch(error)
|
|
173
|
+
{
|
|
174
|
+
state.response = null;
|
|
175
|
+
state.error = error.message;
|
|
176
|
+
state.loading = false;
|
|
268
177
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
178
|
+
config.onError && config.onError(state);
|
|
179
|
+
}
|
|
180
|
+
finally
|
|
181
|
+
{
|
|
182
|
+
compile.data.Update();
|
|
183
|
+
}
|
|
273
184
|
};
|
|
274
185
|
|
|
275
186
|
methods.init();
|
|
276
187
|
}
|
|
277
188
|
});
|
|
278
|
-
|
|
189
|
+
|
|
279
190
|
document.addEventListener('submit', function(event)
|
|
280
191
|
{
|
|
281
192
|
const node = event.target;
|
|
@@ -26,7 +26,7 @@ onetype.AddonReady('directives', function(directives)
|
|
|
26
26
|
const originalChildren = compile.children;
|
|
27
27
|
compile.children = false;
|
|
28
28
|
|
|
29
|
-
const compiled = item.Compile(results, compile.data);
|
|
29
|
+
const compiled = item.Compile(results, compile.data, {locale: false});
|
|
30
30
|
const fragment = document.createDocumentFragment();
|
|
31
31
|
|
|
32
32
|
while(compiled.element.firstChild)
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
.e-64e877b > .holder
|
|
11
11
|
{
|
|
12
12
|
position: relative;
|
|
13
|
+
width: inherit;
|
|
13
14
|
display: inline-flex;
|
|
14
15
|
align-items: center;
|
|
15
16
|
justify-content: center;
|
|
@@ -147,6 +148,14 @@
|
|
|
147
148
|
|
|
148
149
|
/* ---- Solid color variants ---- */
|
|
149
150
|
|
|
151
|
+
.e-64e877b > .holder.dark { background: #000; border-color: #000; color: #fff; }
|
|
152
|
+
.e-64e877b > .holder.dark:hover { background: #1a1a1a; border-color: #1a1a1a; }
|
|
153
|
+
.e-64e877b > .holder.dark:focus-visible { box-shadow: 0 0 0 2px var(--ot-bg-1), 0 0 0 4px #000; }
|
|
154
|
+
|
|
155
|
+
body.dark .e-64e877b > .holder.dark { background: #fff; border-color: #fff; color: #000; }
|
|
156
|
+
body.dark .e-64e877b > .holder.dark:hover { background: #e5e5e5; border-color: #e5e5e5; }
|
|
157
|
+
body.dark .e-64e877b > .holder.dark:focus-visible { box-shadow: 0 0 0 2px var(--ot-bg-1), 0 0 0 4px #fff; }
|
|
158
|
+
|
|
150
159
|
.e-64e877b > .holder.brand { background: var(--ot-brand); border-color: var(--ot-brand); color: white; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 2px 8px var(--ot-brand-opacity); }
|
|
151
160
|
.e-64e877b > .holder.brand:hover { background: var(--ot-brand-hover); border-color: var(--ot-brand-hover); box-shadow: 0 4px 12px var(--ot-brand-opacity), 0 2px 4px rgba(0, 0, 0, 0.1); }
|
|
152
161
|
.e-64e877b > .holder.brand:focus-visible { box-shadow: 0 0 0 2px var(--ot-bg-1), 0 0 0 4px var(--ot-brand); }
|
|
@@ -46,7 +46,7 @@ onetype.AddonReady('elements', (elements) =>
|
|
|
46
46
|
type: 'array',
|
|
47
47
|
value: ['brand', 'size-m'],
|
|
48
48
|
options: [
|
|
49
|
-
'brand', 'blue', 'red', 'orange', 'green',
|
|
49
|
+
'brand', 'blue', 'red', 'orange', 'green', 'dark',
|
|
50
50
|
'soft-brand', 'soft-blue', 'soft-red', 'soft-orange', 'soft-green',
|
|
51
51
|
'outline-brand', 'outline-blue', 'outline-red', 'outline-orange', 'outline-green',
|
|
52
52
|
'bg-1', 'bg-2', 'bg-3', 'bg-4',
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
.e-21311850 > .holder.size-s > .input { font-size: var(--ot-size-s); }
|
|
149
149
|
|
|
150
150
|
.e-21311850 > .holder.size-m { height: var(--ot-height-m); padding: 0 var(--ot-spacing-s); }
|
|
151
|
-
.e-21311850 > .holder.size-m > .swatch { width: 22px; height: 22px; }
|
|
151
|
+
.e-21311850 > .holder.size-m > .swatch { width: 22px; height: 22px; border: 1px solid var(--ot-bg-2-border); }
|
|
152
152
|
.e-21311850 > .holder.size-m > .input { font-size: var(--ot-size-m); }
|
|
153
153
|
|
|
154
154
|
.e-21311850 > .holder.size-l { height: var(--ot-height-l); padding: 0 var(--ot-spacing-m); }
|