odant-work 1.0.95 → 1.0.96
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/$server/$folder/$class/$ai/class.js +2 -0
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +1 -1
- package/$server/$folder/handlers/pages/form/$handler/class.js +2 -2
- package/$server/$folder/lib/explorer/explorer.js +1 -1
- package/oda/components/inputs/combobox/combobox.js +216 -14
- package/oda/components/inputs/input/input.js +26 -4
- package/oda/components/inputs/text/text.js +262 -88
- package/oda/components/layouts/editor-form/editor-form.js +12 -5
- package/oda/components/structure/controls-map.js +12 -3
- package/oda/components/structure/controls.js +1 -0
- package/package.json +1 -1
- package/sources/client/handler.js +3 -3
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
STATIC: [{
|
|
42
42
|
id: 'protocol',
|
|
43
43
|
type: 'String',
|
|
44
|
+
list: ['openai', 'anthropic', 'gigachat', 'yandex', 'ollama', 'local', 'custom'],
|
|
44
45
|
placeholder: 'openai | anthropic | gigachat | custom',
|
|
45
46
|
required: true,
|
|
46
47
|
}, {
|
|
@@ -85,6 +86,7 @@ export default {
|
|
|
85
86
|
}, {
|
|
86
87
|
id: 'effort',
|
|
87
88
|
type: 'String',
|
|
89
|
+
list: ['off', 'low', 'medium', 'high', 'xhigh'],
|
|
88
90
|
placeholder: 'off | low | medium | high | xhigh',
|
|
89
91
|
}, {
|
|
90
92
|
id: 'functionCalling',
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
imports: '~/lib//explorer.js',
|
|
5
5
|
extends: 'item-explorer',
|
|
6
6
|
template: /* html */`
|
|
7
|
-
<item-tree ~for="available" order="{{$for.index + 1}}"
|
|
7
|
+
<item-tree ~for="available" order="{{$for.index + 1}}" hidden slot='left-panel' show-status allow-focus hide-roots="1" hide-tops="0" :$item="$for.item" style="height: 0"></item-tree>
|
|
8
8
|
|
|
9
9
|
`,
|
|
10
10
|
list: ['/NODES'],
|
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
}
|
|
60
60
|
#tools item-node {
|
|
61
61
|
flex-shrink: 0;
|
|
62
|
-
border-radius:
|
|
62
|
+
border-radius: 8px;
|
|
63
63
|
padding: 3px 8px;
|
|
64
64
|
min-height: 30px;
|
|
65
65
|
align-items: center;
|
|
@@ -753,7 +753,7 @@ ODA({is: 'work-form',
|
|
|
753
753
|
:rainbow="saving"
|
|
754
754
|
:error-invert="isViewChanged && !!saveError"
|
|
755
755
|
:success-invert="isViewChanged && !saveError"
|
|
756
|
-
style="position: relative; align-items: center;"
|
|
756
|
+
style="position: relative; align-items: center; padding: 4px; border-radius: 8px;"
|
|
757
757
|
horizontal
|
|
758
758
|
>
|
|
759
759
|
<oda-icon
|
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
imports: 'oda//app-layout.js, oda//tabs.js, oda//icon, oda//button, ~/lib//tree.js, ~/lib//node-explorer.js, ~/lib//consultant.js, ~/lib//class-picker.js, ~/lib//support.js',
|
|
4
4
|
extends: 'oda-app-layout',
|
|
5
5
|
template: /*html*/`
|
|
6
|
-
<item-tree order="0" slot='left-panel'
|
|
6
|
+
<item-tree order="0" slot='left-panel' :clean-structure="cleanStructure" :items-selector :show-size show-status show-users allow-focus :hide-roots :hide-tops :$item style="height: 0"></item-tree>
|
|
7
7
|
<item-consultant order="3" slot='left-panel' id="consultant" label="ИИ" icon="bootstrap:robot" :$item hidden style="height: 0"></item-consultant>
|
|
8
8
|
<div flex vertical slot='main' style="overflow: hidden; position: relative;">
|
|
9
9
|
<call-form ~if="showCall" id="callForm"></call-form>
|
|
@@ -1,39 +1,241 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* oda-combobox-input —
|
|
2
|
+
* oda-combobox-input — ввод с выпадающим списком вариантов (dropdown + свободный/фильтруемый ввод).
|
|
3
|
+
* Варианты из items / list / field.items / field.list / field.options.
|
|
3
4
|
* Текст совпал с подписью варианта — value = значение варианта; иначе value = текст (allowOther) или ошибка.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
ODA({
|
|
7
8
|
is: 'oda-combobox-input',
|
|
8
|
-
imports: 'oda//input.js, oda//button.js',
|
|
9
|
+
imports: 'oda//input.js, oda//button.js, oda//icon.js',
|
|
9
10
|
extends: 'oda-options-input',
|
|
10
11
|
template: /*html*/`
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
<style>
|
|
13
|
+
.dd-toggle {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
transition: transform .15s ease;
|
|
16
|
+
}
|
|
17
|
+
.dd-toggle.open {
|
|
18
|
+
transform: rotate(180deg);
|
|
19
|
+
}
|
|
20
|
+
.dd-menu {
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 4px;
|
|
23
|
+
border: 1px solid var(--subtle-border, var(--border-color, #d0d7de));
|
|
24
|
+
border-radius: var(--radius-s, 8px);
|
|
25
|
+
background: var(--content-background, #fff);
|
|
26
|
+
color: var(--content-color, inherit);
|
|
27
|
+
box-shadow: var(--elevation-3, 0 8px 24px rgba(0, 0, 0, .14));
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
max-height: 260px;
|
|
31
|
+
font: inherit;
|
|
32
|
+
}
|
|
33
|
+
.dd-menu:popover-open {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
gap: 2px;
|
|
37
|
+
}
|
|
38
|
+
.dd-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
padding: 6px 10px;
|
|
43
|
+
border-radius: var(--radius-xs, 6px);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
user-select: none;
|
|
47
|
+
}
|
|
48
|
+
.dd-item:hover,
|
|
49
|
+
.dd-item.active {
|
|
50
|
+
background: var(--subtle-background, rgba(0, 0, 0, .05));
|
|
51
|
+
}
|
|
52
|
+
.dd-item.selected {
|
|
53
|
+
background: var(--accent-soft, rgba(37, 99, 235, .12));
|
|
54
|
+
color: var(--accent-color, inherit);
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
.dd-item.disabled {
|
|
58
|
+
opacity: .45;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
}
|
|
61
|
+
.dd-label {
|
|
62
|
+
flex: 1 1 auto;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
.dd-desc {
|
|
69
|
+
font-size: smaller;
|
|
70
|
+
opacity: .65;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
text-overflow: ellipsis;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
75
|
+
.dd-empty {
|
|
76
|
+
padding: 8px 10px;
|
|
77
|
+
font-size: smaller;
|
|
78
|
+
opacity: .65;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
<input class="control" part="control" :value="text" :placeholder="placeholderText"
|
|
82
|
+
:readonly="isReadonly" :disabled :required="isRequired"
|
|
83
|
+
@input="onInput($this.value)" @keydown="onKey($event)">
|
|
84
|
+
<oda-button ~if="!isEmpty && !isReadonly && !disabled" class="affix" icon="icons:close" :icon-size="14" title="Очистить" @tap.stop="clearValue()"></oda-button>
|
|
85
|
+
<oda-button ~if="options.length && !isReadonly && !disabled" class="affix dd-toggle" ~class="{ open: menuOpen }"
|
|
86
|
+
icon="icons:arrow-drop-down" :icon-size="18" title="Выбрать из списка"
|
|
87
|
+
@down.prevent.stop @tap.stop="toggleMenu()"></oda-button>
|
|
88
|
+
<div class="dd-menu" popover="auto" @toggle="onPopoverToggle($event)">
|
|
89
|
+
<div ~for="visibleOptions" style="display: contents">
|
|
90
|
+
<div class="dd-item"
|
|
91
|
+
~class="{ selected: isSelectedOption($for.item), active: $for.index === activeIndex, disabled: !!$for.item.disabled }"
|
|
92
|
+
@pointerdown.prevent="pickOption($for.item)">
|
|
93
|
+
<oda-icon ~if="$for.item.icon" :icon="$for.item.icon" :icon-size="16"></oda-icon>
|
|
94
|
+
<span class="dd-label">{{$for.item.label}}</span>
|
|
95
|
+
<span ~if="$for.item.description || $for.item.desc" class="dd-desc">{{$for.item.description || $for.item.desc}}</span>
|
|
96
|
+
<oda-icon ~if="isSelectedOption($for.item)" icon="icons:check" :icon-size="14"></oda-icon>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div ~if="!visibleOptions.length" class="dd-empty">Нет совпадений</div>
|
|
100
|
+
</div>
|
|
17
101
|
`,
|
|
18
102
|
$public: {
|
|
19
|
-
allowOther: true
|
|
103
|
+
allowOther: true,
|
|
20
104
|
},
|
|
21
|
-
/**
|
|
22
|
-
* value не отражается в атрибут: сброс (undefined) возвращался бы из `attributeChangedCallback` как null,
|
|
23
|
-
* а число варианта — строкой. `$type: String` тут нельзя: значение варианта бывает числом.
|
|
24
|
-
* Начальный атрибут value="…" при создании по-прежнему применяется.
|
|
25
|
-
*/
|
|
26
105
|
value: {
|
|
27
106
|
$public: false
|
|
28
107
|
},
|
|
108
|
+
menuOpen: false,
|
|
109
|
+
filterText: '',
|
|
110
|
+
activeIndex: -1,
|
|
29
111
|
/** подпись варианта для значения или само значение */
|
|
30
112
|
get text() {
|
|
31
113
|
return this.isEmpty ? '' : this.optionOf(this.value)?.label ?? String(this.value);
|
|
32
114
|
},
|
|
115
|
+
get visibleOptions() {
|
|
116
|
+
const list = this.options || [];
|
|
117
|
+
const q = String(this.filterText || '').trim().toLowerCase();
|
|
118
|
+
if (!q)
|
|
119
|
+
return list;
|
|
120
|
+
const matched = list.filter(o =>
|
|
121
|
+
String(o.label ?? '').toLowerCase().includes(q)
|
|
122
|
+
|| String(o.value ?? '').toLowerCase().includes(q)
|
|
123
|
+
);
|
|
124
|
+
return matched.length ? matched : list;
|
|
125
|
+
},
|
|
126
|
+
isSelectedOption(o) {
|
|
127
|
+
return !this.isEmpty && o && String(o.value) === String(this.value);
|
|
128
|
+
},
|
|
33
129
|
enter(text) {
|
|
34
130
|
const o = this.options.find(o => o.label === text);
|
|
35
131
|
this.value = o ? o.value : text || undefined;
|
|
36
132
|
},
|
|
133
|
+
onInput(text) {
|
|
134
|
+
this.filterText = text;
|
|
135
|
+
this.enter(text);
|
|
136
|
+
if (this.options.length && !this.menuOpen)
|
|
137
|
+
this.openMenu(false);
|
|
138
|
+
},
|
|
139
|
+
clearValue() {
|
|
140
|
+
this.filterText = '';
|
|
141
|
+
this.enter('');
|
|
142
|
+
this.closeMenu();
|
|
143
|
+
},
|
|
144
|
+
toggleMenu() {
|
|
145
|
+
if (this.menuOpen)
|
|
146
|
+
this.closeMenu();
|
|
147
|
+
else
|
|
148
|
+
this.openMenu(true);
|
|
149
|
+
},
|
|
150
|
+
openMenu(showAll = true) {
|
|
151
|
+
if (this.isReadonly || this.disabled || !this.options.length)
|
|
152
|
+
return;
|
|
153
|
+
if (showAll)
|
|
154
|
+
this.filterText = '';
|
|
155
|
+
const menu = this.$('.dd-menu');
|
|
156
|
+
if (!menu)
|
|
157
|
+
return;
|
|
158
|
+
const rect = this.getBoundingClientRect();
|
|
159
|
+
const vw = window.innerWidth || 0;
|
|
160
|
+
const vh = window.innerHeight || 0;
|
|
161
|
+
const spaceBelow = vh - rect.bottom - 8;
|
|
162
|
+
const spaceAbove = rect.top - 8;
|
|
163
|
+
const maxH = Math.min(260, Math.max(120, Math.max(spaceBelow, spaceAbove)));
|
|
164
|
+
const openUp = spaceBelow < 160 && spaceAbove > spaceBelow;
|
|
165
|
+
menu.style.position = 'fixed';
|
|
166
|
+
menu.style.left = Math.max(8, Math.min(rect.left, vw - Math.max(rect.width, 160) - 8)) + 'px';
|
|
167
|
+
menu.style.width = Math.max(rect.width, 140) + 'px';
|
|
168
|
+
menu.style.maxHeight = maxH + 'px';
|
|
169
|
+
if (openUp) {
|
|
170
|
+
menu.style.top = 'auto';
|
|
171
|
+
menu.style.bottom = Math.max(8, vh - rect.top + 4) + 'px';
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
menu.style.bottom = 'auto';
|
|
175
|
+
menu.style.top = Math.min(vh - 48, rect.bottom + 4) + 'px';
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
if (!menu.matches(':popover-open'))
|
|
179
|
+
menu.showPopover?.();
|
|
180
|
+
}
|
|
181
|
+
catch { /* ignore */ }
|
|
182
|
+
this.menuOpen = true;
|
|
183
|
+
const curIdx = this.visibleOptions.findIndex(o => this.isSelectedOption(o));
|
|
184
|
+
this.activeIndex = curIdx;
|
|
185
|
+
},
|
|
186
|
+
closeMenu() {
|
|
187
|
+
const menu = this.$('.dd-menu');
|
|
188
|
+
try {
|
|
189
|
+
if (menu?.matches?.(':popover-open'))
|
|
190
|
+
menu.hidePopover?.();
|
|
191
|
+
}
|
|
192
|
+
catch { /* ignore */ }
|
|
193
|
+
this.menuOpen = false;
|
|
194
|
+
this.activeIndex = -1;
|
|
195
|
+
},
|
|
196
|
+
onPopoverToggle(e) {
|
|
197
|
+
const open = e?.newState === 'open';
|
|
198
|
+
this.menuOpen = open;
|
|
199
|
+
if (!open) {
|
|
200
|
+
this.activeIndex = -1;
|
|
201
|
+
this.filterText = '';
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
pickOption(o) {
|
|
205
|
+
if (!o || o.disabled)
|
|
206
|
+
return;
|
|
207
|
+
this.filterText = '';
|
|
208
|
+
this.value = o.value;
|
|
209
|
+
this.closeMenu();
|
|
210
|
+
this.focus();
|
|
211
|
+
},
|
|
212
|
+
onKey(e) {
|
|
213
|
+
if (this.isReadonly || this.disabled || !this.options.length)
|
|
214
|
+
return;
|
|
215
|
+
if (e.key === 'ArrowDown') {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
if (!this.menuOpen)
|
|
218
|
+
this.openMenu(true);
|
|
219
|
+
else if (this.visibleOptions.length)
|
|
220
|
+
this.activeIndex = (this.activeIndex + 1) % this.visibleOptions.length;
|
|
221
|
+
}
|
|
222
|
+
else if (e.key === 'ArrowUp' && this.menuOpen && this.visibleOptions.length) {
|
|
223
|
+
e.preventDefault();
|
|
224
|
+
this.activeIndex = (this.activeIndex - 1 + this.visibleOptions.length) % this.visibleOptions.length;
|
|
225
|
+
}
|
|
226
|
+
else if (e.key === 'Enter' && this.menuOpen && this.activeIndex >= 0) {
|
|
227
|
+
const item = this.visibleOptions[this.activeIndex];
|
|
228
|
+
if (item && !item.disabled) {
|
|
229
|
+
e.preventDefault();
|
|
230
|
+
this.pickOption(item);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else if (e.key === 'Escape' && this.menuOpen) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
e.stopPropagation();
|
|
236
|
+
this.closeMenu();
|
|
237
|
+
}
|
|
238
|
+
},
|
|
37
239
|
get validationErrors() {
|
|
38
240
|
return this.isOther && !this.allowOther ? ['Выберите значение из списка'] : [];
|
|
39
241
|
}
|
|
@@ -193,21 +193,43 @@ ODA({
|
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
+
export function normalizeOptions(raw) {
|
|
197
|
+
if (!raw)
|
|
198
|
+
return [];
|
|
199
|
+
let arr;
|
|
200
|
+
if (Array.isArray(raw)) {
|
|
201
|
+
arr = raw;
|
|
202
|
+
}
|
|
203
|
+
else if (typeof raw === 'string') {
|
|
204
|
+
const sep = raw.includes('|') ? '|' : (raw.includes(';') ? ';' : ',');
|
|
205
|
+
arr = raw.split(sep).map(s => s.trim()).filter(Boolean);
|
|
206
|
+
}
|
|
207
|
+
else if (typeof raw === 'object') {
|
|
208
|
+
arr = Object.entries(raw).map(([value, label]) => ({ value, label: label == null ? String(value) : String(label) }));
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
return arr.map(i => i !== null && typeof i === 'object'
|
|
214
|
+
? { ...i, value: i.value ?? i.id ?? i.label, label: i.label ?? String(i.value ?? i.id ?? '') }
|
|
215
|
+
: { value: i, label: String(i) });
|
|
216
|
+
}
|
|
217
|
+
|
|
196
218
|
ODA({
|
|
197
219
|
is: 'oda-options-input',
|
|
198
220
|
extends: 'oda-input',
|
|
199
221
|
$public: {
|
|
200
|
-
/** варианты: значения или {value, label, icon, description, disabled}; иначе field.items / field.options */
|
|
222
|
+
/** варианты: значения или {value, label, icon, description, disabled}; иначе list / field.items / field.list / field.options */
|
|
201
223
|
items: {
|
|
202
224
|
$type: Array
|
|
203
225
|
},
|
|
226
|
+
/** настроечный список вариантов (массив, строка с разделителем | / ; / , или объект) — включает выпадающий выбор */
|
|
227
|
+
list: undefined,
|
|
204
228
|
/** разрешить своё значение вне списка */
|
|
205
229
|
allowOther: false
|
|
206
230
|
},
|
|
207
231
|
get options() {
|
|
208
|
-
return (this.items ?? this.field?.items ?? this.field?.
|
|
209
|
-
? { ...i, value: i.value ?? i.id ?? i.label, label: i.label ?? String(i.value ?? i.id ?? '') }
|
|
210
|
-
: { value: i, label: String(i) });
|
|
232
|
+
return normalizeOptions(this.items ?? this.list ?? this.field?.items ?? this.field?.list ?? this.field?.options);
|
|
211
233
|
},
|
|
212
234
|
optionOf(value) {
|
|
213
235
|
return this.options.find(o => String(o.value) === String(value));
|
|
@@ -1,88 +1,262 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* oda-text-input — строчный ввод текста на нативном input: text, password (с показом), email, url, tel, search.
|
|
3
|
-
* Тип — inputType, иначе field.type (если это один из типов текста), иначе text.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
/**
|
|
2
|
+
* oda-text-input — строчный ввод текста на нативном input: text, password (с показом), email, url, tel, search.
|
|
3
|
+
* Тип — inputType, иначе field.type (если это один из типов текста), иначе text.
|
|
4
|
+
* При наличии list (массив, строка с | / ; / , или объект) или field.list включает выпадающий список выбора (dropdown).
|
|
5
|
+
*/
|
|
6
|
+
import { normalizeOptions } from '/oda/components/inputs/input/input.js';
|
|
7
|
+
|
|
8
|
+
const TEXT_TYPES = ['text', 'password', 'email', 'url', 'tel', 'search'];
|
|
9
|
+
|
|
10
|
+
/** адрес электронной почты — выражение из спецификации HTML (то же, что у нативного type=email) */
|
|
11
|
+
const EMAIL = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
12
|
+
|
|
13
|
+
/** скомпилированные pattern (атрибут pattern сопоставляется со всем значением, как у нативного input) */
|
|
14
|
+
const PATTERNS = new Map();
|
|
15
|
+
function patternOf(pattern) {
|
|
16
|
+
if (!PATTERNS.has(pattern)) {
|
|
17
|
+
let re;
|
|
18
|
+
// нативный input компилирует pattern с флагом v, при ошибке — игнорирует его; запасной вариант — u
|
|
19
|
+
for (const flags of ['v', 'u']) {
|
|
20
|
+
try {
|
|
21
|
+
re = new RegExp('^(?:' + pattern + ')$', flags);
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
}
|
|
26
|
+
PATTERNS.set(pattern, re);
|
|
27
|
+
}
|
|
28
|
+
return PATTERNS.get(pattern);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ODA({
|
|
32
|
+
is: 'oda-text-input',
|
|
33
|
+
imports: 'oda//input.js, oda//button.js, oda//icon.js',
|
|
34
|
+
extends: 'oda-input',
|
|
35
|
+
template: /*html*/`
|
|
36
|
+
<style>
|
|
37
|
+
.dd-toggle {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
transition: transform .15s ease;
|
|
40
|
+
}
|
|
41
|
+
.dd-toggle.open {
|
|
42
|
+
transform: rotate(180deg);
|
|
43
|
+
}
|
|
44
|
+
.dd-menu {
|
|
45
|
+
margin: 0;
|
|
46
|
+
padding: 4px;
|
|
47
|
+
border: 1px solid var(--subtle-border, var(--border-color, #d0d7de));
|
|
48
|
+
border-radius: var(--radius-s, 8px);
|
|
49
|
+
background: var(--content-background, #fff);
|
|
50
|
+
color: var(--content-color, inherit);
|
|
51
|
+
box-shadow: var(--elevation-3, 0 8px 24px rgba(0, 0, 0, .14));
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
overflow-y: auto;
|
|
54
|
+
max-height: 260px;
|
|
55
|
+
font: inherit;
|
|
56
|
+
}
|
|
57
|
+
.dd-menu:popover-open {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
gap: 2px;
|
|
61
|
+
}
|
|
62
|
+
.dd-item {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: 8px;
|
|
66
|
+
padding: 6px 10px;
|
|
67
|
+
border-radius: var(--radius-xs, 6px);
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
.dd-item:hover,
|
|
73
|
+
.dd-item.active {
|
|
74
|
+
background: var(--subtle-background, rgba(0, 0, 0, .05));
|
|
75
|
+
}
|
|
76
|
+
.dd-item.selected {
|
|
77
|
+
background: var(--accent-soft, rgba(37, 99, 235, .12));
|
|
78
|
+
color: var(--accent-color, inherit);
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
}
|
|
81
|
+
.dd-item.disabled {
|
|
82
|
+
opacity: .45;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
.dd-label {
|
|
86
|
+
flex: 1 1 auto;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
<input class="control" part="control"
|
|
94
|
+
:type="nativeType" :value="value ?? ''" :placeholder="placeholderText"
|
|
95
|
+
:readonly="isReadonly" :disabled :required="isRequired"
|
|
96
|
+
:minlength="field?.minLength" :maxlength="field?.maxLength" :pattern="pattern || field?.pattern"
|
|
97
|
+
:autocomplete="autocomplete" :inputmode="inputMode"
|
|
98
|
+
@input="onTextInput($this.value)" @keydown="onTextKey($event)">
|
|
99
|
+
<oda-button ~if="textType === 'password'" class="affix" :icon="revealed ? 'icons:visibility-off' : 'icons:visibility'" :icon-size
|
|
100
|
+
title="Показать / скрыть" @tap.stop="revealed = !revealed"></oda-button>
|
|
101
|
+
<oda-button ~if="clearable && !isEmpty && !isReadonly" class="affix" icon="icons:close" :icon-size title="Очистить" @tap.stop="value = ''"></oda-button>
|
|
102
|
+
<oda-button ~if="listOptions.length && !isReadonly && !disabled" class="affix dd-toggle" ~class="{ open: menuOpen }"
|
|
103
|
+
icon="icons:arrow-drop-down" :icon-size="18" title="Выбрать из списка"
|
|
104
|
+
@down.prevent.stop @tap.stop="toggleMenu()"></oda-button>
|
|
105
|
+
<div ~if="listOptions.length" class="dd-menu" popover="auto" @toggle="onPopoverToggle($event)">
|
|
106
|
+
<div ~for="listOptions" style="display: contents">
|
|
107
|
+
<div class="dd-item"
|
|
108
|
+
~class="{ selected: isSelectedOption($for.item), active: $for.index === activeIndex, disabled: !!$for.item.disabled }"
|
|
109
|
+
@pointerdown.prevent="pickOption($for.item)">
|
|
110
|
+
<oda-icon ~if="$for.item.icon" :icon="$for.item.icon" :icon-size="16"></oda-icon>
|
|
111
|
+
<span class="dd-label">{{$for.item.label}}</span>
|
|
112
|
+
<oda-icon ~if="isSelectedOption($for.item)" icon="icons:check" :icon-size="14"></oda-icon>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
`,
|
|
117
|
+
$public: {
|
|
118
|
+
// без $def: пустое значение — undefined (как в данных); $def: '' вечно спорил
|
|
119
|
+
// с привязкой и давал цикл запись→нотификация→рендер (см. pitfalls §21)
|
|
120
|
+
value: {
|
|
121
|
+
$type: String
|
|
122
|
+
},
|
|
123
|
+
/** text | password | email | url | tel | search; пусто — по field.type */
|
|
124
|
+
inputType: '',
|
|
125
|
+
pattern: '',
|
|
126
|
+
autocomplete: 'off',
|
|
127
|
+
/** кнопка очистки */
|
|
128
|
+
clearable: false,
|
|
129
|
+
/** список вариантов (массив, строка с | / ; / , или объект) — включает выпадающий выбор */
|
|
130
|
+
list: undefined
|
|
131
|
+
},
|
|
132
|
+
revealed: false,
|
|
133
|
+
menuOpen: false,
|
|
134
|
+
activeIndex: -1,
|
|
135
|
+
get listOptions() {
|
|
136
|
+
return normalizeOptions(this.list ?? this.field?.list ?? this.field?.items ?? this.field?.options);
|
|
137
|
+
},
|
|
138
|
+
isSelectedOption(o) {
|
|
139
|
+
return !this.isEmpty && o && String(o.value) === String(this.value);
|
|
140
|
+
},
|
|
141
|
+
onTextInput(v) {
|
|
142
|
+
this.value = v;
|
|
143
|
+
},
|
|
144
|
+
toggleMenu() {
|
|
145
|
+
if (this.menuOpen)
|
|
146
|
+
this.closeMenu();
|
|
147
|
+
else
|
|
148
|
+
this.openMenu();
|
|
149
|
+
},
|
|
150
|
+
openMenu() {
|
|
151
|
+
if (this.isReadonly || this.disabled || !this.listOptions.length)
|
|
152
|
+
return;
|
|
153
|
+
const menu = this.$('.dd-menu');
|
|
154
|
+
if (!menu)
|
|
155
|
+
return;
|
|
156
|
+
const rect = this.getBoundingClientRect();
|
|
157
|
+
const vw = window.innerWidth || 0;
|
|
158
|
+
const vh = window.innerHeight || 0;
|
|
159
|
+
const spaceBelow = vh - rect.bottom - 8;
|
|
160
|
+
const spaceAbove = rect.top - 8;
|
|
161
|
+
const maxH = Math.min(260, Math.max(120, Math.max(spaceBelow, spaceAbove)));
|
|
162
|
+
const openUp = spaceBelow < 160 && spaceAbove > spaceBelow;
|
|
163
|
+
menu.style.position = 'fixed';
|
|
164
|
+
menu.style.left = Math.max(8, Math.min(rect.left, vw - Math.max(rect.width, 160) - 8)) + 'px';
|
|
165
|
+
menu.style.width = Math.max(rect.width, 140) + 'px';
|
|
166
|
+
menu.style.maxHeight = maxH + 'px';
|
|
167
|
+
if (openUp) {
|
|
168
|
+
menu.style.top = 'auto';
|
|
169
|
+
menu.style.bottom = Math.max(8, vh - rect.top + 4) + 'px';
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
menu.style.bottom = 'auto';
|
|
173
|
+
menu.style.top = Math.min(vh - 48, rect.bottom + 4) + 'px';
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
if (!menu.matches(':popover-open'))
|
|
177
|
+
menu.showPopover?.();
|
|
178
|
+
}
|
|
179
|
+
catch { /* ignore */ }
|
|
180
|
+
this.menuOpen = true;
|
|
181
|
+
this.activeIndex = this.listOptions.findIndex(o => this.isSelectedOption(o));
|
|
182
|
+
},
|
|
183
|
+
closeMenu() {
|
|
184
|
+
const menu = this.$('.dd-menu');
|
|
185
|
+
try {
|
|
186
|
+
if (menu?.matches?.(':popover-open'))
|
|
187
|
+
menu.hidePopover?.();
|
|
188
|
+
}
|
|
189
|
+
catch { /* ignore */ }
|
|
190
|
+
this.menuOpen = false;
|
|
191
|
+
this.activeIndex = -1;
|
|
192
|
+
},
|
|
193
|
+
onPopoverToggle(e) {
|
|
194
|
+
this.menuOpen = e?.newState === 'open';
|
|
195
|
+
if (!this.menuOpen)
|
|
196
|
+
this.activeIndex = -1;
|
|
197
|
+
},
|
|
198
|
+
pickOption(o) {
|
|
199
|
+
if (!o || o.disabled)
|
|
200
|
+
return;
|
|
201
|
+
this.value = String(o.value ?? '');
|
|
202
|
+
this.closeMenu();
|
|
203
|
+
this.focus();
|
|
204
|
+
},
|
|
205
|
+
onTextKey(e) {
|
|
206
|
+
if (this.isReadonly || this.disabled || !this.listOptions.length)
|
|
207
|
+
return;
|
|
208
|
+
if (e.key === 'ArrowDown') {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
if (!this.menuOpen)
|
|
211
|
+
this.openMenu();
|
|
212
|
+
else
|
|
213
|
+
this.activeIndex = (this.activeIndex + 1) % this.listOptions.length;
|
|
214
|
+
}
|
|
215
|
+
else if (e.key === 'ArrowUp' && this.menuOpen) {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
this.activeIndex = (this.activeIndex - 1 + this.listOptions.length) % this.listOptions.length;
|
|
218
|
+
}
|
|
219
|
+
else if (e.key === 'Enter' && this.menuOpen && this.activeIndex >= 0) {
|
|
220
|
+
const item = this.listOptions[this.activeIndex];
|
|
221
|
+
if (item && !item.disabled) {
|
|
222
|
+
e.preventDefault();
|
|
223
|
+
this.pickOption(item);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else if (e.key === 'Escape' && this.menuOpen) {
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
this.closeMenu();
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
get textType() {
|
|
233
|
+
const t = String(this.inputType || this.field?.type || 'text').toLowerCase();
|
|
234
|
+
return TEXT_TYPES.includes(t) ? t : 'text';
|
|
235
|
+
},
|
|
236
|
+
get nativeType() {
|
|
237
|
+
return this.textType === 'password' && this.revealed ? 'text' : this.textType;
|
|
238
|
+
},
|
|
239
|
+
get inputMode() {
|
|
240
|
+
return { email: 'email', url: 'url', tel: 'tel', search: 'search' }[this.textType] ?? 'text';
|
|
241
|
+
},
|
|
242
|
+
get validationErrors() {
|
|
243
|
+
return this.formatMessage ? [this.formatMessage] : [];
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* Проверка формата (email, url, pattern) по правилам нативного input, но без создания DOM
|
|
247
|
+
* и с русским текстом (нативное сообщение зависит от языка браузера). Пустое значение сюда не доходит.
|
|
248
|
+
*/
|
|
249
|
+
get formatMessage() {
|
|
250
|
+
const text = this.value ?? '';
|
|
251
|
+
if (this.textType === 'email' && !EMAIL.test(text))
|
|
252
|
+
return 'Введите адрес электронной почты';
|
|
253
|
+
if (this.textType === 'url' && !URL.canParse(text))
|
|
254
|
+
return 'Введите адрес в виде URL (например, https://example.com)';
|
|
255
|
+
const pattern = this.pattern || this.field?.pattern;
|
|
256
|
+
// нерабочий pattern нативный input игнорирует — игнорируем и мы
|
|
257
|
+
const re = pattern && patternOf(pattern);
|
|
258
|
+
if (re && !re.test(text))
|
|
259
|
+
return 'Значение не соответствует формату';
|
|
260
|
+
return '';
|
|
261
|
+
}
|
|
262
|
+
});
|
|
@@ -53,10 +53,17 @@ function cleanField(f, seen) {
|
|
|
53
53
|
field.catalog = f.catalog.trim();
|
|
54
54
|
if (f.analytic === true)
|
|
55
55
|
field.analytic = true;
|
|
56
|
+
const rawList = f.list !== undefined ? f.list : ((type !== 'Select' && type !== 'Radio') ? (f.items ?? f.options) : undefined);
|
|
57
|
+
if (rawList !== undefined && rawList !== null && rawList !== '') {
|
|
58
|
+
field.list = rawList;
|
|
59
|
+
if (f.allowOther !== undefined)
|
|
60
|
+
field.allowOther = Boolean(f.allowOther);
|
|
61
|
+
}
|
|
56
62
|
if (type === 'Select' || type === 'Radio') {
|
|
57
|
-
const
|
|
58
|
-
field.options =
|
|
59
|
-
.
|
|
63
|
+
const rawOpts = Array.isArray(f.options) ? f.options : (Array.isArray(f.items) ? f.items : (Array.isArray(f.list) ? f.list : []));
|
|
64
|
+
field.options = rawOpts
|
|
65
|
+
.map(o => o && typeof o === 'object' ? o : { value: String(o ?? ''), label: String(o ?? '') })
|
|
66
|
+
.filter(o => o && String(o.value ?? '').trim() !== '')
|
|
60
67
|
.map(o => ({
|
|
61
68
|
value: String(o.value).trim(),
|
|
62
69
|
label: String(o.label || o.value).trim(),
|
|
@@ -1055,7 +1062,7 @@ ODA({is: 'oda-editor-form-field',
|
|
|
1055
1062
|
<div class="field-row" ~if="!isBlockField" ~class="{ invalid: hasError, multiline: field?.type === 'Text' }">
|
|
1056
1063
|
<label class="field-label" ~class="{ compact: isCompactField }" :title="label">{{label}}<span class="req" ~if="required"> *</span>:</label>
|
|
1057
1064
|
<div class="editor-box">
|
|
1058
|
-
<div class="field-control" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :at="data?.time || ''" :allow-other="!!field.other" :borderless="false" dense no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1065
|
+
<div class="field-control" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :list="field?.list" :at="data?.time || ''" :allow-other="field?.allowOther !== undefined ? !!field.allowOther : (editor === 'oda-combobox-input' ? true : !!field.other)" :borderless="false" dense no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1059
1066
|
<div class="field-error" ~if="serverError">{{serverError}}</div>
|
|
1060
1067
|
</div>
|
|
1061
1068
|
</div>
|
|
@@ -1065,7 +1072,7 @@ ODA({is: 'oda-editor-form-field',
|
|
|
1065
1072
|
<span>{{label}}<span class="req" ~if="required"> *</span></span>
|
|
1066
1073
|
</div>
|
|
1067
1074
|
<div class="editor-box">
|
|
1068
|
-
<div ~if="field?.type !== 'Struct'" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :at="data?.time || ''" :allow-other="!!field.other" :borderless="false" no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1075
|
+
<div ~if="field?.type !== 'Struct'" ~is="editor" :value="data?.[field.id]" @value-changed="onFieldValueChanged($event)" :field :meta="field" :list="field?.list" :at="data?.time || ''" :allow-other="field?.allowOther !== undefined ? !!field.allowOther : (editor === 'oda-combobox-input' ? true : !!field.other)" :borderless="false" no-header :readonly="Boolean(readonly || field?.readonly || field?.disabled)" :disabled="Boolean(field?.disabled)"></div>
|
|
1069
1076
|
<div ~if="children?.length && expanded" class="children-box" horizontal :denied="formDesigner?.isItemDenied?.(null, groupLayer)">
|
|
1070
1077
|
<div class="group-item" ~for="visibleGroupItems"
|
|
1071
1078
|
~class="{designing: formDesigner?.designMode}"
|
|
@@ -22,6 +22,7 @@ export const CONTROLS = {
|
|
|
22
22
|
datetime: 'oda-date-input',
|
|
23
23
|
timestamp: 'oda-date-input',
|
|
24
24
|
select: 'oda-select-input',
|
|
25
|
+
combobox: 'oda-combobox-input',
|
|
25
26
|
radio: 'oda-radio-input',
|
|
26
27
|
tags: 'oda-tags-input',
|
|
27
28
|
color: 'oda-color-input',
|
|
@@ -39,15 +40,23 @@ export const CONTROLS = {
|
|
|
39
40
|
table: 'oda-table-input'
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
/** выбор тега по карте: field.control → путь `/` (link) → controls[type] → группа без типа (undefined) → controls.default */
|
|
43
|
+
/** выбор тега по карте: field.control → путь `/` (link) → field.list (выбор/дропдаун) → controls[type] → группа без типа (undefined) → controls.default */
|
|
43
44
|
export function controlOf(map = {}, field = {}) {
|
|
44
45
|
if (field.control)
|
|
45
46
|
return field.control;
|
|
46
47
|
const type = field.type;
|
|
47
48
|
if (typeof type === 'string' && type.startsWith('/'))
|
|
48
49
|
return map.link ?? map.default;
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const typeKey = type !== undefined ? String(type).toLowerCase() : '';
|
|
51
|
+
const hasList = field.list !== undefined && field.list !== null && field.list !== ''
|
|
52
|
+
&& (!Array.isArray(field.list) || field.list.length > 0);
|
|
53
|
+
if (hasList && !['select', 'radio', 'tags', 'list', 'link'].includes(typeKey)) {
|
|
54
|
+
if (field.allowOther === false)
|
|
55
|
+
return map.select ?? map.combobox ?? map.default;
|
|
56
|
+
return map.combobox ?? map.select ?? map.default;
|
|
57
|
+
}
|
|
58
|
+
if (type !== undefined && (type in map || typeKey in map))
|
|
59
|
+
return map[type] ?? map[typeKey];
|
|
51
60
|
if (field.fields && type === undefined)
|
|
52
61
|
return undefined;
|
|
53
62
|
return map.default;
|
|
@@ -8,6 +8,7 @@ import '/oda/components/inputs/numeric/numeric.js';
|
|
|
8
8
|
import '/oda/components/inputs/date/date.js';
|
|
9
9
|
import '/oda/components/inputs/checkbox/checkbox.js';
|
|
10
10
|
import '/oda/components/inputs/select/select.js';
|
|
11
|
+
import '/oda/components/inputs/combobox/combobox.js';
|
|
11
12
|
import '/oda/components/inputs/radio/radio.js';
|
|
12
13
|
import '/oda/components/inputs/color/color.js';
|
|
13
14
|
import '/oda/components/inputs/range/range.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.96",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
|
@@ -66,7 +66,7 @@ export class $handler extends $class{
|
|
|
66
66
|
return this.DATA?.allowUse;
|
|
67
67
|
}
|
|
68
68
|
async import(path, is){
|
|
69
|
-
path = (this.
|
|
69
|
+
path = (this.short || this.path) + '/~/' + (path || 'class.js');
|
|
70
70
|
if(!path.endsWith('.js'))
|
|
71
71
|
path += '.js';
|
|
72
72
|
const module = await import(path);
|
|
@@ -83,7 +83,7 @@ export class $handler extends $class{
|
|
|
83
83
|
}
|
|
84
84
|
if (!comp || typeof comp !== 'object')
|
|
85
85
|
return null;
|
|
86
|
-
const rawPath = this.
|
|
86
|
+
const rawPath = this.short || this.path || this.id;
|
|
87
87
|
const want = is || comp.is || rawExport.tag || makeViewTag(this.id, rawPath);
|
|
88
88
|
// Клонируем описание компонента с сохранением дескрипторов (геттеры/сеттеры),
|
|
89
89
|
// чтобы регистрация в WORK/ODA не мутировала кэшированный ES-модуль.
|
|
@@ -163,7 +163,7 @@ export class $handler extends $class{
|
|
|
163
163
|
async getModule() {
|
|
164
164
|
const $item = Reactor.activate(this);
|
|
165
165
|
$item.$context = await $item.$context;
|
|
166
|
-
const module = await import(`${$item.
|
|
166
|
+
const module = await import(`${$item.short || $item.path}/~/class.js`);
|
|
167
167
|
return module.default;
|
|
168
168
|
}
|
|
169
169
|
}
|