@synchra24/app-ui 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +16 -2
- package/custom-elements.json +423 -0
- package/dist/auto.js +1486 -8
- package/dist/index.d.ts +118 -2
- package/dist/index.js +1486 -8
- package/dist/react.d.ts +64 -1
- package/dist/synchra-app-ui.js +131 -8
- package/docs/AI-AGENT.md +20 -0
- package/docs/API.md +115 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,418 @@
|
|
|
1
|
+
// src/rich-text.js
|
|
2
|
+
function sanitizeRichText(value) {
|
|
3
|
+
const allowed = new Set(
|
|
4
|
+
"p div span b strong i em u s strike del h1 h2 h3 h4 h5 h6 ul ol li a img figure figcaption blockquote pre code table thead tbody tfoot tr th td br hr sup sub".split(
|
|
5
|
+
" "
|
|
6
|
+
)
|
|
7
|
+
);
|
|
8
|
+
const escape = (value2) => value2.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
9
|
+
const source = String(value || "").replace(
|
|
10
|
+
/<(script|style|iframe|object|svg|math)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,
|
|
11
|
+
""
|
|
12
|
+
);
|
|
13
|
+
const tag = /<\/?([a-zA-Z][\w:-]*)\b(?:[^"'<>]|"[^"]*"|'[^']*')*>/g;
|
|
14
|
+
let result = "", last = 0, match;
|
|
15
|
+
while (match = tag.exec(source)) {
|
|
16
|
+
result += source.slice(last, match.index).replace(/</g, "<");
|
|
17
|
+
last = tag.lastIndex;
|
|
18
|
+
const name = match[1].toLowerCase();
|
|
19
|
+
if (!allowed.has(name)) continue;
|
|
20
|
+
if (match[0][1] === "/") {
|
|
21
|
+
if (!["img", "br", "hr"].includes(name)) result += `</${name}>`;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const attributes = [];
|
|
25
|
+
for (const attr of match[0].matchAll(
|
|
26
|
+
/\s([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/g
|
|
27
|
+
)) {
|
|
28
|
+
const key2 = attr[1].toLowerCase(), v = attr[2] ?? attr[3] ?? attr[4] ?? "";
|
|
29
|
+
if (key2 === "href" && name === "a" && /^(https?:\/\/|mailto:|tel:|\/(?!\/)|#)/i.test(v))
|
|
30
|
+
attributes.push(`href="${escape(v)}"`);
|
|
31
|
+
if (key2 === "src" && name === "img" && /^(https?:\/\/|\/(?!\/)|data:image\/(png|jpe?g|webp|gif);base64,)/i.test(
|
|
32
|
+
v
|
|
33
|
+
))
|
|
34
|
+
attributes.push(`src="${escape(v)}"`);
|
|
35
|
+
if (["alt", "title"].includes(key2))
|
|
36
|
+
attributes.push(`${key2}="${escape(v)}"`);
|
|
37
|
+
if (["colspan", "rowspan", "width"].includes(key2) && /^\d{1,3}%?$/.test(v))
|
|
38
|
+
attributes.push(`${key2}="${v}"`);
|
|
39
|
+
if (key2 === "style") {
|
|
40
|
+
const styles2 = v.split(";").filter(
|
|
41
|
+
(d) => /^\s*(text-align\s*:\s*(left|right|center|justify)|font-weight\s*:\s*(bold|[4-9]00)|font-style\s*:\s*italic|text-decoration(?:-line)?\s*:\s*(underline|line-through))\s*$/i.test(
|
|
42
|
+
d
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
if (styles2.length)
|
|
46
|
+
attributes.push(`style="${escape(styles2.join(";"))}"`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
result += `<${name}${attributes.length ? " " + attributes.join(" ") : ""}>`;
|
|
50
|
+
}
|
|
51
|
+
return result + source.slice(last).replace(/</g, "<");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/editor-component.js
|
|
55
|
+
function editorComponents({ Component, contextFor: contextFor2, mobile }) {
|
|
56
|
+
class TextEditor extends Component {
|
|
57
|
+
static formAssociated = true;
|
|
58
|
+
static observedAttributes = [
|
|
59
|
+
"value",
|
|
60
|
+
"label",
|
|
61
|
+
"placeholder",
|
|
62
|
+
"disabled",
|
|
63
|
+
"readonly",
|
|
64
|
+
"name"
|
|
65
|
+
];
|
|
66
|
+
constructor() {
|
|
67
|
+
super(
|
|
68
|
+
`<style>:host{display:block}.label{padding:0;margin-bottom:10px;font-size:var(--s24-label-size);color:var(--s24-muted)}.editor-shell{border:1px solid var(--s24-border);border-radius:var(--s24-island-radius);overflow:hidden;background:var(--s24-field-bg)}.editor-toolbar{display:flex;flex-wrap:wrap;gap:6px;padding:10px;border-bottom:1px solid var(--s24-border);background:var(--s24-surface)}.editor-toolbar button{width:36px;height:36px;min-height:0;padding:0;border:1px solid transparent;border-radius:12px;background:var(--s24-button-bg);color:var(--s24-muted)}.editor-toolbar button:hover{color:var(--s24-accent);border-color:var(--s24-accent)}.editor-content{min-height:240px;padding:18px 22px;font-size:var(--s24-body-size);line-height:1.62;outline:none;overflow:auto;overflow-wrap:anywhere}.editor-content:empty:before{content:attr(data-placeholder);color:var(--s24-muted);pointer-events:none}.editor-content p{margin:0 0 12px}.editor-content img{max-width:100%;height:auto}.editor-content table{border-collapse:collapse;width:100%}.editor-content td,.editor-content th{border:1px solid var(--s24-border);padding:8px}:host([data-native=true]) .editor-toolbar{display:none}:host([data-native=true]) .editor-shell{border:0;border-radius:calc(20px * var(--s24-native-icon-scale));background:var(--s24-native-field-grey);box-shadow:0 0 0 1px var(--s24-island-border)}:host([data-native=true]) .editor-content{min-height:calc(140px * var(--s24-native-icon-scale));padding:10px;font-size:var(--s24-type-body-size);line-height:var(--s24-type-body-line-height);cursor:text}.editor-error{color:var(--s24-error);font-size:var(--s24-caption-size)}</style><div class="label"></div><div class="editor-shell"><div class="editor-toolbar" role="toolbar" aria-label="\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430"></div><div class="editor-content" role="textbox" aria-multiline="true"></div></div><p class="editor-error" role="alert" hidden></p>`
|
|
69
|
+
);
|
|
70
|
+
this.internals = this.attachInternals?.();
|
|
71
|
+
this._value = "";
|
|
72
|
+
this.control = this.shadowRoot.querySelector(".editor-content");
|
|
73
|
+
const tools = [
|
|
74
|
+
["formatBlock", "h1", "format_h1", "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1"],
|
|
75
|
+
["formatBlock", "h2", "format_h2", "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2"],
|
|
76
|
+
["bold", "", "format_bold", "\u0416\u0438\u0440\u043D\u044B\u0439"],
|
|
77
|
+
["italic", "", "format_italic", "\u041A\u0443\u0440\u0441\u0438\u0432"],
|
|
78
|
+
["underline", "", "format_underlined", "\u041F\u043E\u0434\u0447\u0435\u0440\u043A\u043D\u0443\u0442\u044B\u0439"],
|
|
79
|
+
["strikeThrough", "", "format_strikethrough", "\u0417\u0430\u0447\u0435\u0440\u043A\u043D\u0443\u0442\u044B\u0439"],
|
|
80
|
+
["justifyLeft", "", "format_align_left", "\u041F\u043E \u043B\u0435\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E"],
|
|
81
|
+
["justifyCenter", "", "format_align_center", "\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443"],
|
|
82
|
+
["justifyRight", "", "format_align_right", "\u041F\u043E \u043F\u0440\u0430\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E"],
|
|
83
|
+
[
|
|
84
|
+
"insertUnorderedList",
|
|
85
|
+
"",
|
|
86
|
+
"format_list_bulleted",
|
|
87
|
+
"\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A"
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
"insertOrderedList",
|
|
91
|
+
"",
|
|
92
|
+
"format_list_numbered",
|
|
93
|
+
"\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A"
|
|
94
|
+
],
|
|
95
|
+
["createLink", "", "link", "\u0421\u0441\u044B\u043B\u043A\u0430"],
|
|
96
|
+
["image", "", "add_photo_alternate", "\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435"],
|
|
97
|
+
["table", "", "table", "\u0422\u0430\u0431\u043B\u0438\u0446\u0430"],
|
|
98
|
+
["formatBlock", "blockquote", "format_quote", "\u0426\u0438\u0442\u0430\u0442\u0430"],
|
|
99
|
+
["formatBlock", "pre", "code", "\u041A\u043E\u0434"],
|
|
100
|
+
["removeFormat", "", "ink_eraser", "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435"]
|
|
101
|
+
];
|
|
102
|
+
for (const [command, value, icon, label] of tools) {
|
|
103
|
+
const button = document.createElement("button");
|
|
104
|
+
button.type = "button";
|
|
105
|
+
button.title = label;
|
|
106
|
+
button.setAttribute("aria-label", label);
|
|
107
|
+
const glyph = document.createElement("s24-icon");
|
|
108
|
+
glyph.setAttribute("name", icon);
|
|
109
|
+
glyph.setAttribute("size", "17");
|
|
110
|
+
button.append(glyph);
|
|
111
|
+
button.addEventListener("mousedown", (e) => e.preventDefault());
|
|
112
|
+
button.addEventListener(
|
|
113
|
+
"click",
|
|
114
|
+
() => void this.command(command, value)
|
|
115
|
+
);
|
|
116
|
+
this.shadowRoot.querySelector(".editor-toolbar").append(button);
|
|
117
|
+
}
|
|
118
|
+
this.control.addEventListener("click", () => {
|
|
119
|
+
if (mobile(this)) void this.open();
|
|
120
|
+
});
|
|
121
|
+
this.control.addEventListener("keydown", (e) => {
|
|
122
|
+
if (mobile(this) && ["Enter", " "].includes(e.key)) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
void this.open();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.control.addEventListener("input", () => {
|
|
128
|
+
this._value = sanitizeRichText(this.control.innerHTML);
|
|
129
|
+
this.renderedValue = this._value;
|
|
130
|
+
this.internals?.setFormValue(this._value);
|
|
131
|
+
this.event("s24-input", { value: this._value });
|
|
132
|
+
});
|
|
133
|
+
this.control.addEventListener("blur", () => {
|
|
134
|
+
if (!mobile(this)) {
|
|
135
|
+
this._value = this.value;
|
|
136
|
+
this.internals?.setFormValue(this.value);
|
|
137
|
+
this.event("s24-change", { value: this.value });
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.control.addEventListener("paste", (e) => {
|
|
141
|
+
if (mobile(this)) return;
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const html = e.clipboardData?.getData("text/html");
|
|
144
|
+
const plain = e.clipboardData?.getData("text/plain") || "";
|
|
145
|
+
document.execCommand(
|
|
146
|
+
html ? "insertHTML" : "insertText",
|
|
147
|
+
false,
|
|
148
|
+
html ? sanitizeRichText(html) : plain
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
connectedCallback() {
|
|
153
|
+
if (this.hasAttribute("value"))
|
|
154
|
+
this._value = sanitizeRichText(this.getAttribute("value"));
|
|
155
|
+
this.sync();
|
|
156
|
+
}
|
|
157
|
+
attributeChangedCallback(name) {
|
|
158
|
+
if (name === "value")
|
|
159
|
+
this._value = sanitizeRichText(this.getAttribute("value"));
|
|
160
|
+
this.sync();
|
|
161
|
+
}
|
|
162
|
+
_applyPlatform(runtime) {
|
|
163
|
+
super._applyPlatform(runtime);
|
|
164
|
+
this.dataset.native = String(runtime === "mobile");
|
|
165
|
+
this.sync();
|
|
166
|
+
}
|
|
167
|
+
get value() {
|
|
168
|
+
return this.control && !mobile(this) ? sanitizeRichText(this.control.innerHTML) : this._value;
|
|
169
|
+
}
|
|
170
|
+
set value(value) {
|
|
171
|
+
this._value = sanitizeRichText(value);
|
|
172
|
+
this.renderedValue = void 0;
|
|
173
|
+
this.sync();
|
|
174
|
+
}
|
|
175
|
+
formResetCallback() {
|
|
176
|
+
this.value = this.getAttribute("value") || "";
|
|
177
|
+
}
|
|
178
|
+
formDisabledCallback(disabled) {
|
|
179
|
+
this.formDisabled = disabled;
|
|
180
|
+
this.sync();
|
|
181
|
+
}
|
|
182
|
+
sync() {
|
|
183
|
+
if (!this.control) return;
|
|
184
|
+
const native = mobile(this), disabled = this.hasAttribute("disabled") || this.formDisabled, readonly = this.hasAttribute("readonly");
|
|
185
|
+
this.text(".label", this.getAttribute("label"));
|
|
186
|
+
this.shadowRoot.querySelector(".label").hidden = !this.hasAttribute("label");
|
|
187
|
+
this.control.setAttribute(
|
|
188
|
+
"aria-label",
|
|
189
|
+
this.getAttribute("label") || "\u0422\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440"
|
|
190
|
+
);
|
|
191
|
+
this.control.setAttribute("aria-disabled", String(!!disabled));
|
|
192
|
+
this.control.setAttribute("aria-readonly", String(!!readonly));
|
|
193
|
+
this.control.dataset.placeholder = this.getAttribute("placeholder") || "\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435\u2026";
|
|
194
|
+
this.control.contentEditable = String(!native && !disabled && !readonly);
|
|
195
|
+
this.control.tabIndex = disabled ? -1 : 0;
|
|
196
|
+
if (this.renderedValue !== this._value) {
|
|
197
|
+
this.control.innerHTML = this._value;
|
|
198
|
+
this.renderedValue = this._value;
|
|
199
|
+
}
|
|
200
|
+
for (const button of this.shadowRoot.querySelectorAll("button"))
|
|
201
|
+
button.disabled = disabled || readonly;
|
|
202
|
+
this.internals?.setFormValue(disabled ? null : this.value);
|
|
203
|
+
}
|
|
204
|
+
async open() {
|
|
205
|
+
if (this.hasAttribute("disabled") || this.hasAttribute("readonly") || this.opening)
|
|
206
|
+
return;
|
|
207
|
+
const sdk = contextFor2(this)?.sdk;
|
|
208
|
+
if (!mobile(this)) {
|
|
209
|
+
this.control.focus();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.opening = true;
|
|
213
|
+
try {
|
|
214
|
+
if (!sdk?.editRichText)
|
|
215
|
+
throw new Error(
|
|
216
|
+
sdk ? "\u0414\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24" : "\u041D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0432\u043D\u0443\u0442\u0440\u0438 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F Synchra24"
|
|
217
|
+
);
|
|
218
|
+
const result = await sdk.editRichText({
|
|
219
|
+
value: this.value,
|
|
220
|
+
label: this.getAttribute("label") || "\u0422\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440",
|
|
221
|
+
placeholder: this.getAttribute("placeholder") || ""
|
|
222
|
+
});
|
|
223
|
+
if (result?.supported === false)
|
|
224
|
+
throw new Error("\u0414\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24");
|
|
225
|
+
if (this.isConnected && !this.hasAttribute("disabled") && !result?.cancelled) {
|
|
226
|
+
this.value = result.value || "";
|
|
227
|
+
this.event("s24-change", { value: this.value });
|
|
228
|
+
}
|
|
229
|
+
} catch (error) {
|
|
230
|
+
this.text(".editor-error", error.message);
|
|
231
|
+
this.shadowRoot.querySelector(".editor-error").hidden = false;
|
|
232
|
+
this.event("s24-error", { message: error.message });
|
|
233
|
+
} finally {
|
|
234
|
+
this.opening = false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async command(command, value) {
|
|
238
|
+
if (this.hasAttribute("disabled") || this.hasAttribute("readonly"))
|
|
239
|
+
return;
|
|
240
|
+
this.control.focus();
|
|
241
|
+
if (command === "createLink") {
|
|
242
|
+
value = prompt("\u0412\u0441\u0442\u0430\u0432\u044C\u0442\u0435 \u0441\u0441\u044B\u043B\u043A\u0443") || "";
|
|
243
|
+
if (!/^(https?:\/\/|mailto:|tel:|\/|#)/i.test(value)) return;
|
|
244
|
+
}
|
|
245
|
+
if (command === "image") {
|
|
246
|
+
const sdk = contextFor2(this)?.sdk;
|
|
247
|
+
if (sdk?.capturePhoto) {
|
|
248
|
+
const result = await sdk.capturePhoto({ max_files: 1 });
|
|
249
|
+
const item = result.items?.[0];
|
|
250
|
+
const src = item?.preview || item?.url;
|
|
251
|
+
if (src)
|
|
252
|
+
document.execCommand(
|
|
253
|
+
"insertHTML",
|
|
254
|
+
false,
|
|
255
|
+
sanitizeRichText(`<img src="${src}">`)
|
|
256
|
+
);
|
|
257
|
+
} else {
|
|
258
|
+
this.event("s24-error", {
|
|
259
|
+
message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0439 \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u0432\u043D\u0443\u0442\u0440\u0438 Synchra24"
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (command === "table") {
|
|
265
|
+
const rows = Math.max(
|
|
266
|
+
1,
|
|
267
|
+
Math.min(12, Number(prompt("\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0441\u0442\u0440\u043E\u043A", "3")) || 3)
|
|
268
|
+
), cols = Math.max(
|
|
269
|
+
1,
|
|
270
|
+
Math.min(8, Number(prompt("\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0441\u0442\u043E\u043B\u0431\u0446\u043E\u0432", "3")) || 3)
|
|
271
|
+
);
|
|
272
|
+
document.execCommand(
|
|
273
|
+
"insertHTML",
|
|
274
|
+
false,
|
|
275
|
+
`<table><tbody>${Array.from(
|
|
276
|
+
{ length: rows },
|
|
277
|
+
() => `<tr>${"<td><br></td>".repeat(cols)}</tr>`
|
|
278
|
+
).join("")}</tbody></table><p><br></p>`
|
|
279
|
+
);
|
|
280
|
+
} else document.execCommand(command, false, value);
|
|
281
|
+
this._value = sanitizeRichText(this.control.innerHTML);
|
|
282
|
+
this.renderedValue = this._value;
|
|
283
|
+
this.internals?.setFormValue(this.value);
|
|
284
|
+
this.event("s24-change", { value: this.value });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return { "s24-text-editor": TextEditor };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/feedback-components.js
|
|
291
|
+
function feedbackComponents({ Component, contextFor: contextFor2, mobile }) {
|
|
292
|
+
class Info extends Component {
|
|
293
|
+
static observedAttributes = ["heading", "description", "label", "disabled"];
|
|
294
|
+
constructor() {
|
|
295
|
+
super(
|
|
296
|
+
`<style>:host{display:inline-flex;vertical-align:middle}.info-trigger{width:28px;height:28px;min-height:0;padding:2px;border:0;background:transparent;color:var(--s24-muted);border-radius:var(--s24-item-radius)}:host([data-native=true]) .info-trigger{width:calc(28px * var(--s24-native-icon-scale));height:calc(28px * var(--s24-native-icon-scale));border-radius:50%;background:var(--s24-island-bg);box-shadow:0 0 0 1px var(--s24-island-border)}.info-copy{white-space:pre-wrap;color:var(--s24-muted);font-size:var(--s24-body-size);font-weight:400}</style><button type="button" class="info-trigger"><s24-icon name="info" size="24"></s24-icon></button><s24-dialog><div class="info-copy"></div></s24-dialog><slot hidden></slot>`
|
|
297
|
+
);
|
|
298
|
+
this.shadowRoot.querySelector("button").addEventListener("click", () => void this.open());
|
|
299
|
+
this.shadowRoot.querySelector("slot").addEventListener("slotchange", () => this.sync());
|
|
300
|
+
this.shadowRoot.querySelector("s24-dialog").addEventListener("s24-close", () => this.event("s24-close", {}));
|
|
301
|
+
}
|
|
302
|
+
connectedCallback() {
|
|
303
|
+
this.sync();
|
|
304
|
+
}
|
|
305
|
+
attributeChangedCallback() {
|
|
306
|
+
this.sync();
|
|
307
|
+
}
|
|
308
|
+
_applyPlatform(runtime) {
|
|
309
|
+
super._applyPlatform(runtime);
|
|
310
|
+
this.dataset.native = String(runtime === "mobile");
|
|
311
|
+
}
|
|
312
|
+
sync() {
|
|
313
|
+
this.shadowRoot.querySelector("button").disabled = this.hasAttribute("disabled");
|
|
314
|
+
this.shadowRoot.querySelector("button").setAttribute(
|
|
315
|
+
"aria-label",
|
|
316
|
+
this.getAttribute("label") || this.getAttribute("heading") || "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F"
|
|
317
|
+
);
|
|
318
|
+
this.shadowRoot.querySelector("s24-dialog").setAttribute("heading", this.getAttribute("heading") || "\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F");
|
|
319
|
+
this.text(
|
|
320
|
+
".info-copy",
|
|
321
|
+
this.getAttribute("description") || this.textContent.trim()
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
async open() {
|
|
325
|
+
if (this.hasAttribute("disabled") || this.opening) return;
|
|
326
|
+
this.opening = true;
|
|
327
|
+
try {
|
|
328
|
+
const sdk = contextFor2(this)?.sdk;
|
|
329
|
+
if (mobile(this) && sdk) {
|
|
330
|
+
if (!sdk.showInfo)
|
|
331
|
+
throw new Error(
|
|
332
|
+
"\u0414\u043B\u044F \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u0438 \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24"
|
|
333
|
+
);
|
|
334
|
+
const result = await sdk.showInfo({
|
|
335
|
+
title: this.getAttribute("heading") || "",
|
|
336
|
+
description: this.getAttribute("description") || this.textContent.trim()
|
|
337
|
+
});
|
|
338
|
+
if (result?.supported === false)
|
|
339
|
+
throw new Error(
|
|
340
|
+
"\u0414\u043B\u044F \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440\u0430 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u0438 \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24"
|
|
341
|
+
);
|
|
342
|
+
this.event("s24-close", {});
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
this.sync();
|
|
346
|
+
this.shadowRoot.querySelector("s24-dialog").showModal();
|
|
347
|
+
} catch (error) {
|
|
348
|
+
this.event("s24-error", {
|
|
349
|
+
message: error instanceof Error ? error.message : "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044E"
|
|
350
|
+
});
|
|
351
|
+
} finally {
|
|
352
|
+
this.opening = false;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class Progress extends Component {
|
|
357
|
+
static observedAttributes = [
|
|
358
|
+
"value",
|
|
359
|
+
"max",
|
|
360
|
+
"state",
|
|
361
|
+
"steps",
|
|
362
|
+
"height",
|
|
363
|
+
"label",
|
|
364
|
+
"color"
|
|
365
|
+
];
|
|
366
|
+
constructor() {
|
|
367
|
+
super(
|
|
368
|
+
`<style>:host{display:block;width:100%}.progress{height:10px;border-radius:999px;background:var(--s24-border);overflow:hidden}.fill{display:block;height:100%;width:0;border-radius:inherit;background:var(--s24-accent);transition:width 200ms linear}:host([data-native=true]) .progress{height:calc(12px * var(--s24-native-icon-scale))}@media(prefers-reduced-motion:reduce){.fill{transition:none}}</style><div class="progress" role="progressbar"><i class="fill"></i></div>`
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
connectedCallback() {
|
|
372
|
+
this.sync();
|
|
373
|
+
}
|
|
374
|
+
attributeChangedCallback() {
|
|
375
|
+
this.sync();
|
|
376
|
+
}
|
|
377
|
+
_applyPlatform(runtime) {
|
|
378
|
+
super._applyPlatform(runtime);
|
|
379
|
+
this.dataset.native = String(runtime === "mobile");
|
|
380
|
+
this.sync();
|
|
381
|
+
}
|
|
382
|
+
get value() {
|
|
383
|
+
return Number(
|
|
384
|
+
this.getAttribute("value") ?? this.getAttribute("state") ?? 0
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
set value(v) {
|
|
388
|
+
this.setAttribute("value", String(v));
|
|
389
|
+
}
|
|
390
|
+
sync() {
|
|
391
|
+
const raw = this.value, value = Number.isFinite(raw) ? Math.max(0, raw) : 0;
|
|
392
|
+
const rawMax = Number(
|
|
393
|
+
this.getAttribute("max") ?? this.getAttribute("steps") ?? 100
|
|
394
|
+
), max = Number.isFinite(rawMax) && rawMax > 0 ? rawMax : 0;
|
|
395
|
+
const ratio = max ? Math.min(1, value / max) : value > 0 ? 1 : 0;
|
|
396
|
+
const track = this.shadowRoot.querySelector(".progress"), fill = this.shadowRoot.querySelector(".fill");
|
|
397
|
+
track.setAttribute("aria-valuemin", "0");
|
|
398
|
+
track.setAttribute("aria-valuemax", String(max || 1));
|
|
399
|
+
track.setAttribute(
|
|
400
|
+
"aria-valuenow",
|
|
401
|
+
String(max ? Math.min(max, value) : ratio)
|
|
402
|
+
);
|
|
403
|
+
track.setAttribute(
|
|
404
|
+
"aria-label",
|
|
405
|
+
this.getAttribute("label") || "\u041F\u0440\u043E\u0433\u0440\u0435\u0441\u0441"
|
|
406
|
+
);
|
|
407
|
+
const height = Number(this.getAttribute("height"));
|
|
408
|
+
track.style.height = height > 0 && Number.isFinite(height) ? `${height}px` : "";
|
|
409
|
+
fill.style.width = `${ratio * 100}%`;
|
|
410
|
+
fill.style.backgroundColor = this.getAttribute("color") || "";
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return { "s24-info": Info, "s24-progress": Progress };
|
|
414
|
+
}
|
|
415
|
+
|
|
1
416
|
// src/platform-tokens.js
|
|
2
417
|
var geometry = {
|
|
3
418
|
"web": {
|
|
@@ -402,6 +817,990 @@ var fontFaces = { "web": "@font-face {\n font-family: 'S24 Web Heading';\n fon
|
|
|
402
817
|
// src/native-empty.js
|
|
403
818
|
var nativeEmptySVG = '<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="512" height="512" x="0" y="0" viewBox="0 0 64 64" style="enable-background:new 0 0 512 512" xml:space="preserve" fill-rule="evenodd" class="">\n<g>\n <path d="M27.815 20.643a10.14 10.14 0 0 1 2.731-.641.5.5 0 1 0-.099-.995 11.111 11.111 0 0 0-3.001.707.499.499 0 1 0 .369.929zM32.996 19.983c1.182.089 2.264.108 3.252.066a.5.5 0 1 0-.041-.999c-.953.04-1.996.021-3.136-.065a.501.501 0 0 0-.075.998zM38.948 19.753c1.166-.219 2.155-.543 2.986-.942a.5.5 0 0 0-.433-.902c-.762.366-1.669.661-2.738.862a.5.5 0 1 0 .185.982zM43.972 17.422c.896-.865 1.422-1.861 1.659-2.874a.5.5 0 0 0-.974-.228c-.196.841-.636 1.665-1.379 2.382a.5.5 0 1 0 .694.72zM45.393 11.105c-.397-1.054-1.07-1.949-1.89-2.515a.5.5 0 0 0-.567.824c.663.457 1.2 1.189 1.521 2.043a.5.5 0 0 0 .936-.352zM32.365 8.588c.549-2.576 2.737-3.829 4.315-3.838.518-.003.967.119 1.2.431.138.185.18.433.127.737a.5.5 0 0 0 .986.17c.108-.625-.028-1.126-.312-1.505-.397-.533-1.125-.838-2.006-.833-1.921.011-4.62 1.494-5.288 4.63a.5.5 0 1 0 .978.208z" opacity="1" data-original="#738bab" class=""></path>\n <path d="M31.391 8.59c.677 3.12 3.366 4.596 5.282 4.608.949.005 1.718-.348 2.094-.959.227-.368.326-.837.22-1.41-.13-.705-.594-1.608-1.565-2.68a.5.5 0 1 0-.741.671c.676.747 1.077 1.384 1.253 1.919.133.408.13.735-.018.976-.134.217-.374.348-.663.42-.363.09-.798.083-1.257-.014-1.467-.31-3.149-1.537-3.627-3.743a.501.501 0 0 0-.978.212z" opacity="1" data-original="#738bab" class=""></path>\n <path fill="#fca311" d="M31.744 9.484h6.695a1 1 0 0 0 0-2h-6.695a1 1 0 0 0 0 2z" opacity="1" data-original="#2d74ff" class=""></path>\n <path d="M11.5 48.52v5.609c0 1.104.724 2.077 1.782 2.394l18 5.4a2.49 2.49 0 0 0 1.436 0l18-5.4a2.499 2.499 0 0 0 1.782-2.394v-7.997a.5.5 0 0 0-1 0v7.997c0 .662-.435 1.246-1.069 1.437l-18 5.4a1.506 1.506 0 0 1-.862 0l-18-5.4a1.502 1.502 0 0 1-1.069-1.437V48.52a.5.5 0 0 0-1 0z" opacity="1" data-original="#738bab" class=""></path>\n <path d="M10.336 37.19 6.51 42.862a1.498 1.498 0 0 0 .78 2.265l17.995 5.847a1.501 1.501 0 0 0 1.706-.585l5.423-8.002a.5.5 0 0 0-.26-.756l-20-6.49a.501.501 0 0 0-.308.952l19.367 6.284-5.05 7.451a.5.5 0 0 1-.569.195L7.599 44.176a.5.5 0 0 1-.26-.755l3.826-5.672a.5.5 0 1 0-.829-.559z" opacity="1" data-original="#738bab" class=""></path>\n <path d="m49.001 36.064-17.155 5.567a.5.5 0 1 0 .308.951l17.155-5.566a.5.5 0 0 0-.308-.952z" opacity="1" data-original="#738bab" class=""></path>\n <path d="m33.002 44.476 4.007 5.913c.375.553 1.07.791 1.706.585l17.995-5.847a1.498 1.498 0 0 0 .78-2.265l-5.075-7.525a.502.502 0 0 0-.695-.135.502.502 0 0 0-.135.695l5.076 7.524a.502.502 0 0 1-.26.755l-17.995 5.847a.5.5 0 0 1-.569-.195l-4.007-5.913a.5.5 0 0 0-.828.561zM15.192 35.104l16.963-5.522a.502.502 0 0 0 .258-.757l-4.841-7.12a1.5 1.5 0 0 0-1.704-.583L7.872 26.969a1.502 1.502 0 0 0-.78 2.266l4.493 6.662a.501.501 0 0 0 .83-.56l-4.494-6.661a.501.501 0 0 1 .26-.756l17.996-5.847a.5.5 0 0 1 .568.194l4.467 6.57-16.329 5.316a.5.5 0 0 0 .309.951z" opacity="1" data-original="#738bab" class=""></path>\n <path d="m31.845 29.582 20 6.51a.5.5 0 0 0 .57-.195l4.493-6.662a1.502 1.502 0 0 0-.78-2.266l-17.996-5.847a1.5 1.5 0 0 0-1.704.583l-3.498 5.144a.5.5 0 0 0 .827.563l3.498-5.145a.5.5 0 0 1 .568-.194l17.996 5.847a.503.503 0 0 1 .26.756l-4.283 6.349-19.641-6.394a.5.5 0 0 0-.31.951z" opacity="1" data-original="#738bab" class=""></path>\n <path fill="#fca311" d="M47.147 35.615 32 40.529l-15.147-4.914L32 30.684z" opacity="1" data-original="#2d74ff" class=""></path>\n <path d="M26.998 29.06c-.269-.379-.5-.76-.694-1.141a.5.5 0 0 0-.891.454c.215.423.471.846.77 1.267a.5.5 0 0 0 .815-.58zM25.611 25.839a5.483 5.483 0 0 1-.015-1.661.5.5 0 0 0-.99-.145 6.522 6.522 0 0 0 .017 1.961.5.5 0 0 0 .988-.155z" opacity="1" data-original="#738bab" class=""></path>\n</g>\n</svg>';
|
|
404
819
|
|
|
820
|
+
// src/search-styles.js
|
|
821
|
+
var searchStyles = `
|
|
822
|
+
:host(s24-search){display:block;width:100%;min-width:0}
|
|
823
|
+
:host(s24-search) .search-field{position:relative;display:flex;align-items:center;gap:12px;border:1px solid var(--s24-control-border);border-radius:var(--s24-field-radius);background:var(--s24-search-bg);padding:0 14px;height:var(--s24-control-height);min-height:var(--s24-control-height);box-sizing:border-box}
|
|
824
|
+
:host(s24-search) .search-field:focus-within{border-color:var(--s24-search-focus-border)}
|
|
825
|
+
:host(s24-search) .search-field input[type=search]{flex:1;min-width:0;width:100%;height:100%;min-height:0;padding:0;margin:0;border:0;border-radius:0;outline:none;box-shadow:none;background:transparent;font-family:var(--s24-input-font);font-size:var(--s24-control-size);line-height:normal;font-weight:400;color:var(--s24-text);appearance:none}
|
|
826
|
+
:host(s24-search) input[type=search]::-webkit-search-cancel-button{display:none}
|
|
827
|
+
:host(s24-search) .search-leading{flex-shrink:0;color:var(--s24-muted)}
|
|
828
|
+
:host(s24-search) .search-action{display:flex;align-items:center;justify-content:center;flex-shrink:0;min-width:0;min-height:0;width:26px;height:26px;border:0;border-radius:var(--s24-item-radius);padding:0;background:transparent;color:var(--s24-muted);box-shadow:none}
|
|
829
|
+
:host(s24-search) .search-action[data-empty=true]{display:none}
|
|
830
|
+
:host(s24-search) input::placeholder{color:var(--s24-muted);opacity:1}
|
|
831
|
+
:host(s24-search[data-segment-mobile]) .search-field{height:var(--s24-control-height);min-height:var(--s24-control-height);border:0;border-radius:calc(50px * var(--s24-native-icon-scale));padding:0 calc(12px * var(--s24-native-icon-scale));background:var(--s24-native-field-grey);box-shadow:inset 0 0 0 1px var(--s24-control-border)}
|
|
832
|
+
:host(s24-search[data-segment-mobile][small]) .search-field{height:calc(36px * var(--s24-native-icon-scale));min-height:calc(36px * var(--s24-native-icon-scale))}
|
|
833
|
+
:host(s24-search[data-segment-mobile]) .search-field input[type=search]{padding-right:calc(34px * var(--s24-native-icon-scale));font-size:var(--s24-control-size)}
|
|
834
|
+
:host(s24-search[data-segment-mobile]) .search-leading{display:none}
|
|
835
|
+
:host(s24-search[data-segment-mobile]) .search-action{display:flex;position:absolute;right:calc(7px * var(--s24-native-icon-scale));top:50%;transform:translateY(-50%);border-radius:0;width:calc(26px * var(--s24-native-icon-scale));height:calc(26px * var(--s24-native-icon-scale));padding:0}
|
|
836
|
+
:host(s24-search[data-segment-mobile]) input::placeholder{color:var(--s24-text);opacity:1}
|
|
837
|
+
:host(s24-search[disabled]){opacity:.5}
|
|
838
|
+
`;
|
|
839
|
+
|
|
840
|
+
// src/segmented-styles.js
|
|
841
|
+
var segmentedStyles = `
|
|
842
|
+
:host(s24-tabs[variant=segmented]){display:flex;gap:6px;padding:5px;background:var(--s24-segment-bg);border:1px solid var(--s24-control-border);border-radius:var(--s24-field-radius);width:100%;overflow:auto;min-height:50px;align-items:stretch}
|
|
843
|
+
:host(s24-tab[data-segmented]){flex:1 0 0;min-width:max-content;min-height:38px;display:flex;align-items:center;justify-content:center;padding:0 12px;gap:7px;border:1px solid transparent;border-radius:var(--s24-button-radius);color:var(--s24-muted);background:transparent;font-weight:var(--s24-button-weight);font-size:var(--s24-control-size);box-shadow:none;white-space:nowrap}
|
|
844
|
+
:host(s24-tab[data-segmented]) .tab-inner{display:flex;gap:7px;align-items:center;justify-content:center;border:0;padding:0}
|
|
845
|
+
:host(s24-tab[data-segmented][aria-selected=true]){background:var(--s24-active-bg);border-color:color-mix(in srgb,var(--s24-accent) 38%,transparent);color:var(--s24-accent);font-weight:var(--s24-button-weight);box-shadow:none}
|
|
846
|
+
:host(s24-tab[data-segmented][aria-selected=true]) .tab-inner{border:0;padding:0}
|
|
847
|
+
:host(s24-tabs[variant=segmented][data-segment-mobile]){padding:calc(3px * var(--s24-native-icon-scale));min-height:calc(38px * var(--s24-native-icon-scale));margin-top:10px;border:0;border-radius:calc(50px * var(--s24-native-icon-scale));background:var(--s24-native-field-grey);box-shadow:0 0 0 1px var(--s24-control-border)}
|
|
848
|
+
:host(s24-tab[data-segmented][data-segment-mobile]){min-height:calc(32px * var(--s24-native-icon-scale));border:0;border-radius:calc(50px * var(--s24-native-icon-scale));font-size:var(--s24-type-body-size);line-height:var(--s24-type-body-line-height);font-weight:400;color:var(--s24-text);padding:0 12px;background:transparent;box-shadow:none}
|
|
849
|
+
:host(s24-tab[data-segmented][data-segment-mobile][aria-selected=true]){background:var(--s24-island-bg);color:var(--s24-text);font-weight:700;box-shadow:0 0 0 1px var(--s24-control-border)}
|
|
850
|
+
:host(s24-tab[data-segment-mobile]) .tab-inner{gap:0}
|
|
851
|
+
.tab-inner slot{display:contents}
|
|
852
|
+
:host(s24-tab) .tab-count{display:inline-flex;align-items:center;justify-content:center;flex:0 0 24px;width:24px;height:20px;margin-left:0;border-radius:8px;background:color-mix(in srgb,var(--s24-accent) 16%,transparent);color:var(--s24-accent);font-size:var(--s24-caption-size);line-height:1}
|
|
853
|
+
:host(s24-tab[data-segment-mobile]) .tab-count{display:inline;font-size:inherit;line-height:inherit;font-weight:inherit;flex:initial;width:auto;height:auto;background:transparent;border:0;border-radius:0;padding:0;margin-left:4px;color:inherit}
|
|
854
|
+
`;
|
|
855
|
+
|
|
856
|
+
// src/widget-styles.js
|
|
857
|
+
var widgetStyles = `
|
|
858
|
+
:host(:not([data-mobile=true])) .employee-chips>[data-add]{display:none}
|
|
859
|
+
|
|
860
|
+
.employee-head{display:flex;align-items:center;gap:16px;justify-content:space-between;margin-bottom:14px}.employee-head .widget-label{font-weight:400;font-size:var(--s24-label-size);color:var(--s24-muted);margin-bottom:4px}.employee-summary{font-size:var(--s24-body-size)}.employee-empty{color:var(--s24-muted);font-size:var(--s24-control-size);margin:0}.employee-copy{display:grid;gap:2px;min-width:0}.employee-copy strong{font-size:var(--s24-control-size);line-height:1.25}.employee-copy small{font-size:var(--s24-caption-size);line-height:1.25;color:var(--s24-muted)}
|
|
861
|
+
|
|
862
|
+
:host{display:block;min-width:0}button{font:inherit;cursor:pointer}button:disabled{cursor:default;opacity:.5}button:focus-visible{outline:2px solid var(--s24-accent);outline-offset:3px}svg{width:24px;height:24px;fill:currentColor}img{object-fit:cover} [hidden]{display:none!important}
|
|
863
|
+
.widget-label{font-size:var(--s24-body-size);line-height:var(--s24-body-line-height);font-weight:600;margin-bottom:8px}.widget-description{font-size:var(--s24-label-size);line-height:var(--s24-body-line-height);color:var(--s24-muted);margin:4px 0 0}.widget-error{font-size:var(--s24-body-size);color:var(--s24-error);margin:8px 0 0}
|
|
864
|
+
.employee-chips{display:flex;flex-wrap:wrap;align-items:center;gap:12px}.employee-chip{display:flex;align-items:center;gap:10px;border:1px solid var(--s24-border);border-radius:var(--s24-field-radius);padding:6px 14px 6px 6px;min-height:54px;background:var(--s24-field-bg);max-width:100%;min-width:0;font-size:var(--s24-body-size);color:var(--s24-text)}.employee-chip>span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.employee-avatar{flex-shrink:0;width:36px;height:36px;border-radius:var(--s24-item-radius);display:flex;align-items:center;justify-content:center;background:var(--s24-field-bg);border:1px solid var(--s24-border);font-size:12px;overflow:hidden}.employee-avatar img{width:100%;height:100%}.chip-remove{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;background:transparent;border:0;color:var(--s24-muted);border-radius:var(--s24-item-radius)}.chip-remove svg{width:18px;height:18px}.employee-options{display:grid;gap:14px;max-height:50vh;overflow:auto;padding:16px 0}.employee-search{min-width:min(480px,65vw)}
|
|
865
|
+
.attachments{background:var(--s24-surface);border:1px solid var(--s24-border);border-radius:var(--s24-island-radius);padding:16px}.attachments-head{display:flex;gap:16px;align-items:center;justify-content:space-between}.attachments-head .widget-label{margin:0}.attachments-list{display:grid;gap:10px}.attachments-list:not(:empty){margin-top:14px}.attachment-item{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;background:var(--s24-field-bg);border:1px solid var(--s24-border);border-radius:var(--s24-field-radius);padding:12px}.attachment-preview{display:flex;align-items:center;justify-content:center;width:48px;height:48px;border-radius:var(--s24-item-radius);color:var(--s24-accent)}.attachment-meta{min-width:0}.attachment-meta strong,.attachment-meta small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-meta strong{font-size:var(--s24-body-size);font-weight:600}.attachment-meta small{font-size:var(--s24-caption-size);color:var(--s24-muted);margin-top:3px}.attachment-empty{padding:16px;border:1px dashed var(--s24-border);border-radius:var(--s24-field-radius);color:var(--s24-muted);text-align:center;margin-top:14px}.photo-add{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:8px;width:100%;padding:16px;border:1px dashed var(--s24-border);background:transparent;border-radius:var(--s24-field-radius);color:var(--s24-muted)}.photo-symbol{display:flex;align-items:center;justify-content:center;width:52px;height:52px;border:1px dashed currentColor;border-radius:12px}.photo-symbol svg{width:30px;height:30px}.attachments[data-kind=photo]:not([data-empty=true]) .attachments-list{grid-template-columns:repeat(auto-fill,minmax(100px,1fr));margin:0 0 12px}.attachments[data-kind=photo] .attachment-item{position:relative;display:block;padding:0;overflow:hidden;aspect-ratio:1}.attachments[data-kind=photo] .attachment-preview{width:100%;height:100%;border-radius:0}.attachments[data-kind=photo] .attachment-meta{display:none}.attachments[data-kind=photo] .attachment-item s24-circle-button{position:absolute;top:4px;right:4px;background:var(--s24-surface);border-radius:var(--s24-item-radius)}
|
|
866
|
+
.voice-heading{font-weight:600;margin-bottom:12px}.voice-rail{display:flex;align-items:center;gap:14px;padding:8px;background:var(--s24-field-bg);border:1px solid var(--s24-border);border-radius:var(--s24-island-radius);min-height:60px}.voice-hint{flex:1;color:var(--s24-muted);font-size:var(--s24-body-size);text-align:center}.voice-start,.voice-stop{width:44px;height:44px;padding:0;border-radius:var(--s24-item-radius);border:1px solid var(--s24-control-border);background:var(--s24-button-bg);color:var(--s24-accent);display:flex;align-items:center;justify-content:center;flex-shrink:0}.voice-stop{color:var(--s24-error)}.voice-result{display:flex;align-items:center;gap:12px;border:1px solid var(--s24-border);padding:8px;border-radius:var(--s24-island-radius)}audio{min-width:0;width:100%;height:42px}
|
|
867
|
+
:host([data-mobile=true]) .widget-label{font-weight:400;color:var(--s24-text);opacity:.7;margin-bottom:calc(12px * var(--s24-native-icon-scale));font-size:var(--s24-type-caption-size)}
|
|
868
|
+
:host([data-mobile=true]) .employee-avatar{width:calc(36px * var(--s24-native-icon-scale));height:calc(36px * var(--s24-native-icon-scale));border-radius:50%}
|
|
869
|
+
:host([data-mobile=true]) .attachments{padding:0;background:transparent;border:0}
|
|
870
|
+
:host([data-mobile=true]) .attachments-head{padding:0;margin-bottom:calc(12px * var(--s24-native-icon-scale))}
|
|
871
|
+
:host([data-mobile=true]) .attachments-head .widget-label{margin:0;font-size:var(--s24-type-body-size)}
|
|
872
|
+
:host([data-mobile=true]) .attachment-empty{display:none}
|
|
873
|
+
:host([data-mobile=true]) .attachments[data-kind=photo]{background:var(--s24-island-bg);box-shadow:0 0 0 1px var(--s24-island-border);border-radius:calc(20px * var(--s24-native-icon-scale));padding:calc(6px * var(--s24-native-icon-scale));display:flex;flex-wrap:wrap;align-items:center}
|
|
874
|
+
:host([data-mobile=true]) .attachments[data-kind=photo][data-empty=true]{flex-direction:column;padding-block:calc(12px * var(--s24-native-icon-scale))}
|
|
875
|
+
:host([data-mobile=true]) .photo-add{border:0;padding:calc(6px * var(--s24-native-icon-scale));gap:calc(6px * var(--s24-native-icon-scale));font-size:var(--s24-type-body-size);width:auto}
|
|
876
|
+
:host([data-mobile=true]) .photo-symbol{width:calc(52px * var(--s24-native-icon-scale));height:calc(52px * var(--s24-native-icon-scale));border-radius:calc(12px * var(--s24-native-icon-scale));box-shadow:0 0 0 2px var(--s24-island-bg),0 0 0 3px var(--s24-island-border)}
|
|
877
|
+
:host([data-mobile=true]) .photo-symbol svg{width:calc(30px * var(--s24-native-icon-scale));height:calc(30px * var(--s24-native-icon-scale))}
|
|
878
|
+
:host([data-mobile=true]) .attachments[data-kind=photo]:not([data-empty=true]) .photo-add>span:last-child{display:none}
|
|
879
|
+
:host([data-mobile=true]) .attachments[data-kind=photo]:not([data-empty=true]) .attachments-list{display:flex;flex-wrap:wrap;margin:0;gap:0;order:1}
|
|
880
|
+
:host([data-mobile=true]) .attachments[data-kind=photo] .attachment-item{width:calc(54px * var(--s24-native-icon-scale));height:calc(54px * var(--s24-native-icon-scale));border-radius:calc(12px * var(--s24-native-icon-scale));margin:calc(6px * var(--s24-native-icon-scale))}
|
|
881
|
+
:host([data-mobile=true]) .attachments[data-kind=photo] .attachment-item s24-circle-button{top:0;right:0;--s24-circle-small-size:24px}
|
|
882
|
+
:host([data-mobile=true]) .voice-rail{border-radius:100px;background:var(--s24-island-bg);box-shadow:0 0 0 1px var(--s24-island-border);border:0;padding:calc(6px * var(--s24-native-icon-scale));min-height:calc(58px * var(--s24-native-icon-scale));gap:0}
|
|
883
|
+
:host([data-mobile=true]) .voice-start,:host([data-mobile=true]) .voice-stop{width:calc(48px * var(--s24-native-icon-scale));height:calc(48px * var(--s24-native-icon-scale));border-radius:50%;background:var(--s24-background);color:var(--s24-native-warning)}
|
|
884
|
+
:host([data-mobile=true]) .voice-start svg{width:calc(30px * var(--s24-native-icon-scale));height:calc(30px * var(--s24-native-icon-scale))}
|
|
885
|
+
:host([data-mobile=true]) .voice-hint{font-size:var(--s24-type-body-size)}
|
|
886
|
+
:host([data-mobile=true]) .employee-head{margin-bottom:12px}
|
|
887
|
+
:host([data-mobile=true]) .employee-summary,:host([data-mobile=true]) .employee-web-add{display:none}
|
|
888
|
+
:host([data-mobile=true]) .employee-head .widget-label{margin:0}
|
|
889
|
+
:host([data-mobile=true]) .employee-chips{gap:0;flex-wrap:nowrap}
|
|
890
|
+
:host([data-mobile=true]) .employee-chip{border:0;padding:0;min-height:0;background:transparent;gap:6px;cursor:pointer}
|
|
891
|
+
:host([data-mobile=true]) .employee-copy strong{font-size:var(--s24-type-body-size);line-height:var(--s24-type-body-line-height);font-weight:400}
|
|
892
|
+
:host([data-mobile=true]) .employee-copy small{display:none}
|
|
893
|
+
:host([data-mobile=true]) .employee-chip+.employee-chip{margin-left:calc(-15px * var(--s24-native-icon-scale))}
|
|
894
|
+
:host([data-mobile=true]) .employee-chips>[data-add]{margin-left:calc(12px * var(--s24-native-icon-scale))}
|
|
895
|
+
:host([data-mobile=true]) .employee-chips>[data-add]:first-child{margin-left:0}
|
|
896
|
+
:host([data-mobile=true]) .employee-overflow{margin-inline:8px 0;padding:1px 4px;border:1px solid var(--s24-muted);border-radius:4px;font-size:var(--s24-type-caption-size)}
|
|
897
|
+
`;
|
|
898
|
+
var recorderStyles = `
|
|
899
|
+
:host(:not([data-mobile=true])) .attachments-head .widget-label{font-size:20px;line-height:26px}
|
|
900
|
+
.attachment-web-add::part(button){min-height:42px;height:42px;padding:0 16px;border-radius:16px;background:color-mix(in srgb,var(--s24-accent) 14%,transparent);border-color:color-mix(in srgb,var(--s24-accent) 38%,transparent);color:var(--s24-accent);font-weight:700}
|
|
901
|
+
:host(:not([data-mobile=true])) .voice-play{width:42px;height:42px;border-radius:12px}
|
|
902
|
+
:host(:not([data-mobile=true])) .voice-web-record{background:color-mix(in srgb,var(--s24-accent) 14%,transparent);border-color:color-mix(in srgb,var(--s24-accent) 38%,transparent);color:var(--s24-accent)}
|
|
903
|
+
.voice-delete{width:42px;height:42px;min-height:0;padding:0;border-radius:12px;background:var(--s24-button-bg);border:1px solid var(--s24-border);color:var(--s24-muted)}
|
|
904
|
+
:host([data-mobile=true]) .voice-delete{width:32px;height:32px;min-height:0;border:0;background:transparent}
|
|
905
|
+
|
|
906
|
+
.attachment-help{display:none}.attachment-preview:not(img){display:flex;flex-direction:column;gap:4px;background:color-mix(in srgb,var(--s24-accent) 12%,transparent)}.attachment-format{font-size:11px;text-transform:uppercase}
|
|
907
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .widget-description{display:none}
|
|
908
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-help{display:block;font-size:var(--s24-type-callout-size);color:var(--s24-muted);margin:0}
|
|
909
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachments-list:not(:empty){display:block;border-radius:16px;overflow:hidden;box-shadow:0 0 0 1px var(--s24-island-border);margin:0 0 12px}
|
|
910
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachments-list[data-single=true]{border-radius:50px}
|
|
911
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-item{padding:10px 12px;border:0;border-radius:0;background:var(--s24-island-bg);gap:8px}
|
|
912
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-item+.attachment-item{border-top:1px solid var(--s24-border)}
|
|
913
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-preview{width:38px;height:38px;border-radius:50%;color:white}
|
|
914
|
+
:host([data-mobile=true]) .attachment-format{text-transform:none;font-size:var(--s24-type-caption-size)}
|
|
915
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-meta strong{font-weight:400;font-size:var(--s24-type-callout-size)}
|
|
916
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-meta small{display:none}
|
|
917
|
+
.attachment-remove{padding:0;min-height:32px;width:32px;border:0;background:transparent;color:var(--s24-error)}
|
|
918
|
+
|
|
919
|
+
:host(:not([data-mobile=true])) .attachments{position:relative}
|
|
920
|
+
:host(:not([data-mobile=true])) .attachments-head{padding-right:132px;min-height:42px}
|
|
921
|
+
:host(:not([data-mobile=true])) .attachments-head .file-add,:host(:not([data-mobile=true])) .photo-add{display:none}
|
|
922
|
+
.attachment-web-add{position:absolute;right:16px;top:16px}
|
|
923
|
+
:host([data-mobile=true]) .attachment-web-add{display:none}
|
|
924
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo]:not([data-empty=true]) .attachments-list{grid-template-columns:1fr;margin:14px 0 0}
|
|
925
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-item{display:grid;grid-template-columns:auto minmax(0,1fr) auto;aspect-ratio:auto;padding:12px;overflow:visible}
|
|
926
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-preview{width:48px;height:48px;border-radius:var(--s24-item-radius)}
|
|
927
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-meta{display:block}
|
|
928
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-item s24-circle-button{position:static;background:transparent}
|
|
929
|
+
.voice-widget{padding:16px;background:var(--s24-surface);border:1px solid var(--s24-border);border-radius:24px}
|
|
930
|
+
.voice-head{display:flex;align-items:center;justify-content:space-between;gap:16px}.voice-heading{display:block;font-size:20px;line-height:26px;margin:0}.voice-description{display:block;font-size:14px;color:var(--s24-muted);margin-top:4px}
|
|
931
|
+
.voice-web-record{display:flex;gap:8px;min-height:42px;padding:0 16px;border:1px solid var(--s24-button-border);border-radius:16px;background:var(--s24-button-bg);font-size:14px;color:var(--s24-text);font-weight:700}.voice-web-record[data-recording=true]{background:var(--s24-danger-bg);border-color:var(--s24-danger-border);color:var(--s24-error)}
|
|
932
|
+
.voice-result{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:14px;padding:14px;margin-top:14px;border:1px solid var(--s24-border);border-radius:24px;background:var(--s24-field-bg)}
|
|
933
|
+
.voice-play{width:52px;height:52px;min-height:0;padding:0;border-radius:16px;background:color-mix(in srgb,var(--s24-accent) 12%,transparent);border:1px solid color-mix(in srgb,var(--s24-accent) 22%,transparent);color:var(--s24-accent)}.voice-main{min-width:0}.voice-bars{height:38px;display:flex;align-items:center;gap:5px;overflow:hidden}.voice-bars i{flex:1;min-width:3px;max-width:9px;border-radius:999px;background:color-mix(in srgb,var(--s24-accent) 42%,transparent)}.voice-bars i[data-played=true]{background:var(--s24-accent)}.voice-time{display:block;margin-top:7px;color:var(--s24-muted);font-size:14px}.voice-speed{display:none}.voice-widget audio{display:none}
|
|
934
|
+
:host([data-mobile=true]) .voice-widget{padding:0;border:0;background:transparent;border-radius:100px}
|
|
935
|
+
:host([data-mobile=true]) .voice-description,:host([data-mobile=true]) .voice-web-record{display:none}
|
|
936
|
+
:host([data-mobile=true]) .voice-head{margin-bottom:12px}
|
|
937
|
+
:host([data-mobile=true]) .voice-rail{display:block;padding:5px;min-height:0;border-radius:100px;background:var(--s24-island-bg)}
|
|
938
|
+
.voice-track{position:relative;height:calc(50px * var(--s24-native-icon-scale));border-radius:100px;background:var(--s24-background);overflow:hidden}
|
|
939
|
+
.voice-start{position:absolute;left:0;top:0;width:50px;height:50px;min-height:0;padding:0;touch-action:none;user-select:none;z-index:2;border-radius:50%;background:var(--s24-button-bg);color:var(--s24-native-warning);box-shadow:0 0 0 1px var(--s24-island-border)}
|
|
940
|
+
:host([data-mobile=true]) .voice-start{width:calc(50px * var(--s24-native-icon-scale));height:calc(50px * var(--s24-native-icon-scale));background:var(--s24-surface)}
|
|
941
|
+
.voice-hint{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:var(--s24-type-body-size);padding-left:42px;pointer-events:none}
|
|
942
|
+
.voice-live{position:absolute;left:16px;top:14px;color:var(--s24-error);font-size:var(--s24-type-body-size)}
|
|
943
|
+
:host([data-mobile=true]) .voice-result{display:flex;align-items:center;gap:0;margin:0;padding:6px;background:var(--s24-island-bg);border-radius:100px;box-shadow:0 0 0 1px var(--s24-island-border)}
|
|
944
|
+
:host([data-mobile=true]) .voice-play{width:38px;height:38px;min-height:0;border:0;background:transparent;color:var(--s24-muted);border-radius:50%}
|
|
945
|
+
:host([data-mobile=true]) .voice-speed{display:block;width:44px;min-width:44px;min-height:0;margin-left:6px;border:1px solid var(--s24-muted);border-radius:4px;padding:2px 0;background:transparent;color:var(--s24-muted);font-size:var(--s24-type-body-size)}
|
|
946
|
+
:host([data-mobile=true]) .voice-main{flex:1;margin-inline:12px;display:flex;align-items:center;gap:12px}.voice-main .voice-bars{flex:1}
|
|
947
|
+
:host([data-mobile=true]) .voice-bars{height:40px;gap:2px}:host([data-mobile=true]) .voice-bars i{height:max(4px,calc(15px * var(--bar,.3)))!important;max-width:3px;min-width:2px;background:var(--s24-muted)}:host([data-mobile=true]) .voice-bars i[data-played=true]{background:var(--s24-accent)}
|
|
948
|
+
:host([data-mobile=true]) .voice-time{min-width:56px;margin:0;font-size:var(--s24-type-callout-size)}
|
|
949
|
+
:host(:not([data-mobile=true])) .voice-play{width:42px;height:42px;border-radius:12px}
|
|
950
|
+
:host(:not([data-mobile=true])) .voice-web-record[data-recording=true]{min-height:36px;border-radius:12px;background:var(--s24-danger-bg);border-color:var(--s24-danger-border);color:var(--s24-error)}
|
|
951
|
+
`;
|
|
952
|
+
|
|
953
|
+
// src/widget-components.js
|
|
954
|
+
var localSequence = 0;
|
|
955
|
+
var attachmentID = () => globalThis.crypto?.randomUUID?.() || `attachment-${Date.now()}-${++localSequence}`;
|
|
956
|
+
var positiveIDs = (value) => [
|
|
957
|
+
...new Set(
|
|
958
|
+
(Array.isArray(value) ? value : []).filter(
|
|
959
|
+
(id) => Number.isSafeInteger(id) && id > 0
|
|
960
|
+
)
|
|
961
|
+
)
|
|
962
|
+
];
|
|
963
|
+
var limit = (element, name, fallback) => {
|
|
964
|
+
const n = Number(element.getAttribute(name));
|
|
965
|
+
return Number.isSafeInteger(n) && n > 0 ? n : fallback;
|
|
966
|
+
};
|
|
967
|
+
var safeURL = (value) => typeof value === "string" && /^(https?:\/\/|blob:|data:image\/(png|jpeg|webp|gif);base64,)/i.test(value) ? value : "";
|
|
968
|
+
var copy = (value) => ({ ...value });
|
|
969
|
+
function widgetComponents({ Component, contextFor: contextFor2, mobile, coreSVG: coreSVG2 }) {
|
|
970
|
+
class Widget extends Component {
|
|
971
|
+
static observedAttributes = [
|
|
972
|
+
"disabled",
|
|
973
|
+
"label",
|
|
974
|
+
"description",
|
|
975
|
+
"error",
|
|
976
|
+
"max",
|
|
977
|
+
"max-size"
|
|
978
|
+
];
|
|
979
|
+
constructor(template) {
|
|
980
|
+
super(
|
|
981
|
+
`<style>${widgetStyles}${recorderStyles}</style>${template}<p class="widget-error" role="alert" hidden></p>`
|
|
982
|
+
);
|
|
983
|
+
this.busy = false;
|
|
984
|
+
this.generation = 0;
|
|
985
|
+
}
|
|
986
|
+
_applyPlatform(runtime) {
|
|
987
|
+
super._applyPlatform(runtime);
|
|
988
|
+
this.dataset.mobile = String(runtime === "mobile");
|
|
989
|
+
this.sync?.();
|
|
990
|
+
}
|
|
991
|
+
get disabled() {
|
|
992
|
+
return this.hasAttribute("disabled");
|
|
993
|
+
}
|
|
994
|
+
set disabled(value) {
|
|
995
|
+
this.toggleAttribute("disabled", !!value);
|
|
996
|
+
}
|
|
997
|
+
get sdk() {
|
|
998
|
+
return contextFor2(this)?.sdk;
|
|
999
|
+
}
|
|
1000
|
+
connectedCallback() {
|
|
1001
|
+
this.sync();
|
|
1002
|
+
}
|
|
1003
|
+
disconnectedCallback() {
|
|
1004
|
+
this.generation++;
|
|
1005
|
+
}
|
|
1006
|
+
attributeChangedCallback() {
|
|
1007
|
+
this.sync();
|
|
1008
|
+
}
|
|
1009
|
+
clearError() {
|
|
1010
|
+
this.text(".widget-error", this.getAttribute("error"));
|
|
1011
|
+
this.shadowRoot.querySelector(".widget-error").hidden = !this.getAttribute("error");
|
|
1012
|
+
}
|
|
1013
|
+
fail(error) {
|
|
1014
|
+
const message = error instanceof Error ? error.message : "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435";
|
|
1015
|
+
this.text(".widget-error", message);
|
|
1016
|
+
this.shadowRoot.querySelector(".widget-error").hidden = false;
|
|
1017
|
+
this.event("s24-error", { message });
|
|
1018
|
+
}
|
|
1019
|
+
async run(action) {
|
|
1020
|
+
if (this.busy || this.disabled) return;
|
|
1021
|
+
this.busy = true;
|
|
1022
|
+
this.clearError();
|
|
1023
|
+
const generation = this.generation;
|
|
1024
|
+
this.sync();
|
|
1025
|
+
this.event("s24-busy", { busy: true });
|
|
1026
|
+
try {
|
|
1027
|
+
await action(
|
|
1028
|
+
() => this.isConnected && generation === this.generation && !this.disabled
|
|
1029
|
+
);
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
if (this.isConnected && generation === this.generation)
|
|
1032
|
+
this.fail(error);
|
|
1033
|
+
} finally {
|
|
1034
|
+
this.busy = false;
|
|
1035
|
+
if (this.isConnected) {
|
|
1036
|
+
this.sync();
|
|
1037
|
+
this.event("s24-busy", { busy: false });
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
labels() {
|
|
1042
|
+
const heading = this.shadowRoot.querySelector(".widget-label");
|
|
1043
|
+
if (heading) {
|
|
1044
|
+
heading.textContent = this.getAttribute("label") || this.defaultLabel;
|
|
1045
|
+
heading.hidden = !heading.textContent;
|
|
1046
|
+
}
|
|
1047
|
+
const desc = this.shadowRoot.querySelector(".widget-description");
|
|
1048
|
+
if (desc) {
|
|
1049
|
+
desc.textContent = this.getAttribute("description") || "";
|
|
1050
|
+
desc.hidden = !desc.textContent;
|
|
1051
|
+
}
|
|
1052
|
+
this.setAttribute("aria-busy", String(this.busy));
|
|
1053
|
+
for (const b of this.shadowRoot.querySelectorAll(
|
|
1054
|
+
"button,s24-circle-button"
|
|
1055
|
+
))
|
|
1056
|
+
b.disabled = this.busy || this.disabled;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
class Employees extends Widget {
|
|
1060
|
+
constructor() {
|
|
1061
|
+
super(
|
|
1062
|
+
`<div class="employee-head"><div><div class="widget-label"></div><strong class="employee-summary"></strong></div><s24-button class="employee-web-add" variant="secondary"><s24-icon name="group" size="18"></s24-icon>\u0412\u044B\u0431\u0440\u0430\u0442\u044C</s24-button></div><div class="employee-chips"></div><p class="employee-empty">\u0418\u0441\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u0438 \u043F\u043E\u043A\u0430 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u044B.</p><p class="widget-description" hidden></p><s24-dialog heading="\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432"><div class="employee-search"><s24-search placeholder="\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0430\u043C\u2026" aria-label="\u041F\u043E\u0438\u0441\u043A \u043F\u043E \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0430\u043C"></s24-search></div><div class="employee-options"></div><s24-button slot="footer" rounded block>\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C</s24-button></s24-dialog>`
|
|
1063
|
+
);
|
|
1064
|
+
this._value = [];
|
|
1065
|
+
this._employees = [];
|
|
1066
|
+
this.defaultLabel = "\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0438";
|
|
1067
|
+
this.shadowRoot.querySelector(".employee-web-add").addEventListener("click", () => void this.open());
|
|
1068
|
+
this.shadowRoot.querySelector(".employee-chips").addEventListener("click", (e) => {
|
|
1069
|
+
const remove = e.target.closest("[data-remove]");
|
|
1070
|
+
if (remove && !this.busy && !this.disabled) {
|
|
1071
|
+
this.value = this.value.filter(
|
|
1072
|
+
(id) => id !== Number(remove.dataset.remove)
|
|
1073
|
+
);
|
|
1074
|
+
this.changed();
|
|
1075
|
+
} else if (e.target.closest("[data-add]") || e.target.closest(".employee-chip"))
|
|
1076
|
+
void this.open();
|
|
1077
|
+
});
|
|
1078
|
+
this.shadowRoot.querySelector("s24-search").addEventListener("s24-input", (e) => {
|
|
1079
|
+
e.stopPropagation();
|
|
1080
|
+
this.options();
|
|
1081
|
+
});
|
|
1082
|
+
this.shadowRoot.querySelector("s24-dialog s24-button").addEventListener("click", () => {
|
|
1083
|
+
if (this.disabled) return;
|
|
1084
|
+
this.value = this.draft;
|
|
1085
|
+
this.shadowRoot.querySelector("s24-dialog").close();
|
|
1086
|
+
this.changed();
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
get value() {
|
|
1090
|
+
return [...this._value];
|
|
1091
|
+
}
|
|
1092
|
+
set value(value) {
|
|
1093
|
+
this._value = positiveIDs(value);
|
|
1094
|
+
this.sync();
|
|
1095
|
+
}
|
|
1096
|
+
get employees() {
|
|
1097
|
+
return this._employees.map(copy);
|
|
1098
|
+
}
|
|
1099
|
+
set employees(value) {
|
|
1100
|
+
this._employees = (Array.isArray(value) ? value : []).filter((p) => Number.isSafeInteger(p.profile_id) && p.profile_id > 0).map(copy);
|
|
1101
|
+
this.sync();
|
|
1102
|
+
}
|
|
1103
|
+
changed() {
|
|
1104
|
+
this.event("s24-change", {
|
|
1105
|
+
value: this.value,
|
|
1106
|
+
employees: this.employees.filter(
|
|
1107
|
+
(p) => this._value.includes(p.profile_id)
|
|
1108
|
+
)
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
sync() {
|
|
1112
|
+
if (!this.shadowRoot || !this._value) return;
|
|
1113
|
+
this.labels();
|
|
1114
|
+
this.shadowRoot.querySelector(".employee-web-add").disabled = this.disabled || this.busy;
|
|
1115
|
+
const chips = this.shadowRoot.querySelector(".employee-chips");
|
|
1116
|
+
chips.replaceChildren();
|
|
1117
|
+
const native = mobile(this);
|
|
1118
|
+
this.shadowRoot.querySelector(".widget-label").textContent = native ? `${this.getAttribute("label") || this.defaultLabel} (${this._value.length})` : this.getAttribute("label") || this.defaultLabel;
|
|
1119
|
+
this.text(
|
|
1120
|
+
".employee-summary",
|
|
1121
|
+
this._value.length ? `${this._value.length} \u0432\u044B\u0431\u0440\u0430\u043D\u043E` : "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432"
|
|
1122
|
+
);
|
|
1123
|
+
this.shadowRoot.querySelector(".employee-empty").hidden = native || !!this._value.length;
|
|
1124
|
+
for (const [index, id] of this._value.entries()) {
|
|
1125
|
+
if (native && index >= 5) break;
|
|
1126
|
+
const person = this._employees.find((p) => p.profile_id === id);
|
|
1127
|
+
const chip = document.createElement("span");
|
|
1128
|
+
chip.className = "employee-chip";
|
|
1129
|
+
if (native) {
|
|
1130
|
+
chip.setAttribute("role", "button");
|
|
1131
|
+
chip.tabIndex = this.disabled || this.busy ? -1 : 0;
|
|
1132
|
+
chip.addEventListener("keydown", (e) => {
|
|
1133
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1134
|
+
e.preventDefault();
|
|
1135
|
+
void this.open();
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
const avatar = document.createElement("span");
|
|
1140
|
+
avatar.className = "employee-avatar";
|
|
1141
|
+
const name = person?.name || `\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A \u2116 ${id}`;
|
|
1142
|
+
chip.setAttribute("aria-label", name);
|
|
1143
|
+
avatar.textContent = name.split(/\s+/).slice(0, 2).map((s) => s[0] || "").join("");
|
|
1144
|
+
const url = safeURL(person?.avatar);
|
|
1145
|
+
if (url) {
|
|
1146
|
+
const img = document.createElement("img");
|
|
1147
|
+
img.src = url;
|
|
1148
|
+
img.alt = "";
|
|
1149
|
+
avatar.replaceChildren(img);
|
|
1150
|
+
}
|
|
1151
|
+
const text = document.createElement("span");
|
|
1152
|
+
text.className = "employee-copy";
|
|
1153
|
+
const title = document.createElement("strong");
|
|
1154
|
+
const parts = name.split(/\s+/);
|
|
1155
|
+
title.textContent = native && this._value.length === 1 && parts.length >= 2 ? `${parts[0]} ${parts.slice(1, 3).map((p) => p[0] + ".").join("")}` : name;
|
|
1156
|
+
const position = document.createElement("small");
|
|
1157
|
+
position.textContent = person?.position || "";
|
|
1158
|
+
text.append(title, position);
|
|
1159
|
+
if (native && this._value.length !== 1) text.hidden = true;
|
|
1160
|
+
chip.append(avatar, text);
|
|
1161
|
+
chips.append(chip);
|
|
1162
|
+
}
|
|
1163
|
+
if (native && this._value.length > 5) {
|
|
1164
|
+
const count = document.createElement("span");
|
|
1165
|
+
count.className = "employee-overflow";
|
|
1166
|
+
count.textContent = `+${this._value.length - 5}`;
|
|
1167
|
+
chips.append(count);
|
|
1168
|
+
}
|
|
1169
|
+
const button = document.createElement("s24-circle-button");
|
|
1170
|
+
button.setAttribute("icon", "add");
|
|
1171
|
+
button.setAttribute("size", "medium");
|
|
1172
|
+
button.setAttribute("label", "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432");
|
|
1173
|
+
button.dataset.add = "";
|
|
1174
|
+
button.disabled = this.disabled || this.busy;
|
|
1175
|
+
chips.append(button);
|
|
1176
|
+
}
|
|
1177
|
+
options() {
|
|
1178
|
+
const root = this.shadowRoot.querySelector(".employee-options");
|
|
1179
|
+
root.replaceChildren();
|
|
1180
|
+
const query = this.shadowRoot.querySelector("s24-search").value.toLocaleLowerCase();
|
|
1181
|
+
const people = this._employees.filter(
|
|
1182
|
+
(p) => `${p.name} ${p.position || ""}`.toLocaleLowerCase().includes(query)
|
|
1183
|
+
);
|
|
1184
|
+
for (const person of people) {
|
|
1185
|
+
const row = document.createElement("s24-checkbox");
|
|
1186
|
+
row.setAttribute("label", person.name);
|
|
1187
|
+
row.textContent = person.name;
|
|
1188
|
+
row.setAttribute("description", person.position || "");
|
|
1189
|
+
row.checked = this.draft.includes(person.profile_id);
|
|
1190
|
+
row.disabled = this.disabled || !row.checked && this.draft.length >= limit(this, "max", 500);
|
|
1191
|
+
row.addEventListener("s24-change", (e) => {
|
|
1192
|
+
e.stopPropagation();
|
|
1193
|
+
this.draft = e.detail.checked ? positiveIDs([...this.draft, person.profile_id]) : this.draft.filter((id) => id !== person.profile_id);
|
|
1194
|
+
this.options();
|
|
1195
|
+
});
|
|
1196
|
+
root.append(row);
|
|
1197
|
+
}
|
|
1198
|
+
if (!people.length) {
|
|
1199
|
+
const p = document.createElement("p");
|
|
1200
|
+
p.textContent = this._employees.length ? "\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E" : "\u041F\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0441\u043F\u0438\u0441\u043E\u043A \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432 \u0432 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u043E employees \u0438\u043B\u0438 \u043E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432 Synchra24.";
|
|
1201
|
+
root.append(p);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
async open() {
|
|
1205
|
+
return this.run(async (active) => {
|
|
1206
|
+
if (this.sdk?.selectEmployees) {
|
|
1207
|
+
const result = await this.sdk.selectEmployees({
|
|
1208
|
+
profile_ids: this.value,
|
|
1209
|
+
all_users: !this.hasAttribute("subordinates-only"),
|
|
1210
|
+
max_selected: limit(this, "max", 500)
|
|
1211
|
+
});
|
|
1212
|
+
if (result?.supported !== false) {
|
|
1213
|
+
if (active() && !result?.cancelled) {
|
|
1214
|
+
const ids = positiveIDs(result.profile_ids);
|
|
1215
|
+
if (ids.length > limit(this, "max", 500))
|
|
1216
|
+
throw new Error("\u041F\u0440\u0435\u0432\u044B\u0448\u0435\u043D\u043E \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0447\u0438\u0441\u043B\u043E \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432");
|
|
1217
|
+
if (result.employees) {
|
|
1218
|
+
const byID = new Map(
|
|
1219
|
+
this._employees.map((p) => [p.profile_id, p])
|
|
1220
|
+
);
|
|
1221
|
+
for (const p of result.employees) byID.set(p.profile_id, p);
|
|
1222
|
+
this.employees = [...byID.values()];
|
|
1223
|
+
}
|
|
1224
|
+
this.value = ids;
|
|
1225
|
+
this.changed();
|
|
1226
|
+
}
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
} else if (mobile(this) && this.sdk?.selectEmployeeProfiles) {
|
|
1230
|
+
const result = await this.sdk.selectEmployeeProfiles({
|
|
1231
|
+
profile_ids: this.value,
|
|
1232
|
+
all_users: !this.hasAttribute("subordinates-only")
|
|
1233
|
+
});
|
|
1234
|
+
if (active() && !result?.cancelled && Array.isArray(result?.profile_ids)) {
|
|
1235
|
+
this.value = result.profile_ids;
|
|
1236
|
+
this.changed();
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
if (active()) {
|
|
1241
|
+
this.draft = this.value;
|
|
1242
|
+
this.options();
|
|
1243
|
+
this.shadowRoot.querySelector("s24-dialog").showModal();
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
class Attachments extends Widget {
|
|
1249
|
+
constructor(kind = "file") {
|
|
1250
|
+
super(
|
|
1251
|
+
`<section class="attachments"><div class="attachments-head"><div><div class="widget-label"></div><p class="widget-description" hidden></p></div><s24-circle-button icon="add" label="\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0444\u0430\u0439\u043B" size="medium" class="file-add"></s24-circle-button></div><s24-button class="attachment-web-add" size="small" variant="secondary"><s24-icon name="attach_file" size="18"></s24-icon>\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C</s24-button><div class="attachments-list"></div><button type="button" class="photo-add"><span class="photo-symbol"><s24-icon name="photo_camera" size="30"></s24-icon></span><span>\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0444\u043E\u0442\u043E</span></button><input type="file" hidden><div class="attachment-empty">\u0424\u0430\u0439\u043B\u044B \u043F\u043E\u043A\u0430 \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B</div><p class="attachment-help"></p></section>`
|
|
1252
|
+
);
|
|
1253
|
+
this.kind = kind;
|
|
1254
|
+
this._value = [];
|
|
1255
|
+
this.urls = /* @__PURE__ */ new Set();
|
|
1256
|
+
this.defaultLabel = kind === "photo" ? "" : "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u0435\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B";
|
|
1257
|
+
this.shadowRoot.querySelector(".attachment-web-add").addEventListener("click", () => void this.add());
|
|
1258
|
+
this.shadowRoot.querySelector(".file-add").addEventListener("click", () => void this.add());
|
|
1259
|
+
this.shadowRoot.querySelector(".photo-add").addEventListener("click", () => void this.add());
|
|
1260
|
+
this.input = this.shadowRoot.querySelector("input");
|
|
1261
|
+
this.input.accept = kind === "photo" ? "image/*" : "";
|
|
1262
|
+
this.input.multiple = true;
|
|
1263
|
+
this.input.addEventListener("change", () => {
|
|
1264
|
+
const files = [...this.input.files || []];
|
|
1265
|
+
this.input.value = "";
|
|
1266
|
+
void this.run(async (active) => {
|
|
1267
|
+
const next = [];
|
|
1268
|
+
for (const file of files) next.push(await this.localFile(file));
|
|
1269
|
+
if (active()) this.append(next);
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1272
|
+
this.shadowRoot.querySelector(".attachments-list").addEventListener("click", (e) => {
|
|
1273
|
+
const b = e.target.closest("[data-remove]");
|
|
1274
|
+
if (b && !this.disabled && !this.busy) {
|
|
1275
|
+
this.value = this._value.filter(
|
|
1276
|
+
(_, i) => i !== Number(b.dataset.remove)
|
|
1277
|
+
);
|
|
1278
|
+
this.changed();
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
get value() {
|
|
1283
|
+
return this._value.map(copy);
|
|
1284
|
+
}
|
|
1285
|
+
set value(value) {
|
|
1286
|
+
this._value = Array.isArray(value) ? value.map(copy) : [];
|
|
1287
|
+
this.sync();
|
|
1288
|
+
}
|
|
1289
|
+
disconnectedCallback() {
|
|
1290
|
+
super.disconnectedCallback();
|
|
1291
|
+
for (const url of this.urls) URL.revokeObjectURL(url);
|
|
1292
|
+
this.urls.clear();
|
|
1293
|
+
}
|
|
1294
|
+
async localFile(file) {
|
|
1295
|
+
if (file.size > limit(this, "max-size", 30 * 1024 * 1024))
|
|
1296
|
+
throw new Error("\u0420\u0430\u0437\u043C\u0435\u0440 \u0444\u0430\u0439\u043B\u0430 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u043B\u0438\u043C\u0438\u0442");
|
|
1297
|
+
if (this.kind === "photo" && !/^image\//.test(file.type))
|
|
1298
|
+
throw new Error("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435");
|
|
1299
|
+
if (this.upload) return this.upload(file);
|
|
1300
|
+
const url = URL.createObjectURL(file);
|
|
1301
|
+
this.urls.add(url);
|
|
1302
|
+
return {
|
|
1303
|
+
id: attachmentID(),
|
|
1304
|
+
name: file.name,
|
|
1305
|
+
size: file.size,
|
|
1306
|
+
type: file.type,
|
|
1307
|
+
localFile: file,
|
|
1308
|
+
url
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
append(items) {
|
|
1312
|
+
if (this._value.length + items.length > limit(this, "max", this.kind === "photo" ? 20 : 50))
|
|
1313
|
+
throw new Error("\u041F\u0440\u0435\u0432\u044B\u0448\u0435\u043D\u043E \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u043E\u0435 \u0447\u0438\u0441\u043B\u043E \u0432\u043B\u043E\u0436\u0435\u043D\u0438\u0439");
|
|
1314
|
+
for (const item of items)
|
|
1315
|
+
if (item.size > limit(this, "max-size", 30 * 1024 * 1024))
|
|
1316
|
+
throw new Error("\u0420\u0430\u0437\u043C\u0435\u0440 \u0444\u0430\u0439\u043B\u0430 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0435\u0442 \u0434\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u044B\u0439 \u043B\u0438\u043C\u0438\u0442");
|
|
1317
|
+
this.value = [...this._value, ...items];
|
|
1318
|
+
this.changed();
|
|
1319
|
+
}
|
|
1320
|
+
changed() {
|
|
1321
|
+
this.event("s24-change", { value: this.value });
|
|
1322
|
+
}
|
|
1323
|
+
sync() {
|
|
1324
|
+
if (!this._value || !this.kind) return;
|
|
1325
|
+
this.labels();
|
|
1326
|
+
const photo = this.kind === "photo";
|
|
1327
|
+
const root = this.shadowRoot.querySelector(".attachments");
|
|
1328
|
+
root.dataset.kind = this.kind;
|
|
1329
|
+
root.dataset.empty = String(!this._value.length);
|
|
1330
|
+
this.shadowRoot.querySelector(".attachments-head").hidden = mobile(this) && photo && !this.getAttribute("label");
|
|
1331
|
+
if (photo && !mobile(this))
|
|
1332
|
+
this.text(
|
|
1333
|
+
".attachments-head .widget-label",
|
|
1334
|
+
this.getAttribute("label") || "\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438"
|
|
1335
|
+
);
|
|
1336
|
+
this.shadowRoot.querySelector(".file-add").hidden = photo;
|
|
1337
|
+
this.shadowRoot.querySelector(".photo-add").hidden = !photo;
|
|
1338
|
+
this.shadowRoot.querySelector(".attachment-empty").hidden = mobile(this) && photo || !!this._value.length;
|
|
1339
|
+
const full = this._value.length >= limit(this, "max", photo ? 20 : 50);
|
|
1340
|
+
this.shadowRoot.querySelector(".photo-add").disabled = this.disabled || this.busy || full;
|
|
1341
|
+
this.shadowRoot.querySelector(".file-add").disabled = this.disabled || this.busy || full;
|
|
1342
|
+
this.shadowRoot.querySelector(".attachment-web-add").disabled = this.disabled || this.busy || full;
|
|
1343
|
+
const list = this.shadowRoot.querySelector(".attachments-list");
|
|
1344
|
+
list.replaceChildren();
|
|
1345
|
+
list.dataset.single = String(this._value.length === 1);
|
|
1346
|
+
this.shadowRoot.querySelector(".file-add").setAttribute("icon", mobile(this) ? "add_circle" : "add");
|
|
1347
|
+
this.text(
|
|
1348
|
+
".attachment-help",
|
|
1349
|
+
this.getAttribute("description") || "\u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u043B\u044E\u0431\u044B\u0435 \u0444\u0430\u0439\u043B\u044B \u0440\u0430\u0437\u043C\u0435\u0440\u043E\u043C \u0434\u043E 30 MB."
|
|
1350
|
+
);
|
|
1351
|
+
for (const [i, item] of this._value.entries()) {
|
|
1352
|
+
const row = document.createElement("div");
|
|
1353
|
+
row.className = "attachment-item";
|
|
1354
|
+
const preview = document.createElement(photo ? "img" : "span");
|
|
1355
|
+
preview.className = "attachment-preview";
|
|
1356
|
+
if (photo) {
|
|
1357
|
+
preview.src = safeURL(item.preview || item.url);
|
|
1358
|
+
preview.alt = item.name || "\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F";
|
|
1359
|
+
} else {
|
|
1360
|
+
const extension = (item.name || item.file || "").split(".").pop().toLowerCase().slice(0, 8);
|
|
1361
|
+
const format = document.createElement("span");
|
|
1362
|
+
format.className = "attachment-format";
|
|
1363
|
+
format.textContent = extension || "--";
|
|
1364
|
+
preview.append(format);
|
|
1365
|
+
if (mobile(this)) {
|
|
1366
|
+
const groups = [
|
|
1367
|
+
["png jpg jpeg svg gif tiff raw bmp", "#ffb703"],
|
|
1368
|
+
["pdf", "#e63946"],
|
|
1369
|
+
["xlsx xlsm xlsb xltx xls csv", "#52b788"],
|
|
1370
|
+
["mp3 aac ogg wav wma flac alac aiff", "#fb8b24"],
|
|
1371
|
+
["mp4 mov avi mkv wmv", "#ef476f"],
|
|
1372
|
+
["docs doc docx dotx dot rtf txt odt", "#3a86ff"],
|
|
1373
|
+
["xml json css html", "#fb5607"],
|
|
1374
|
+
["zip rar 7z tar", "#00b4d8"]
|
|
1375
|
+
];
|
|
1376
|
+
preview.style.background = groups.find(
|
|
1377
|
+
([keys]) => keys.split(" ").includes(extension)
|
|
1378
|
+
)?.[1] || "var(--s24-muted)";
|
|
1379
|
+
} else {
|
|
1380
|
+
const icon = document.createElement("s24-icon");
|
|
1381
|
+
icon.setAttribute("name", "description");
|
|
1382
|
+
icon.setAttribute("size", "16");
|
|
1383
|
+
preview.prepend(icon);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
const meta = document.createElement("div");
|
|
1387
|
+
meta.className = "attachment-meta";
|
|
1388
|
+
const name = document.createElement("strong");
|
|
1389
|
+
name.textContent = item.name || item.file || "\u0412\u043B\u043E\u0436\u0435\u043D\u0438\u0435";
|
|
1390
|
+
const size = document.createElement("small");
|
|
1391
|
+
size.textContent = item.size ? `${(item.size / 1048576).toFixed(1)} \u041C\u0411` : item.file ? "\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043D" : "";
|
|
1392
|
+
meta.append(name, size);
|
|
1393
|
+
const remove = document.createElement(
|
|
1394
|
+
!photo && mobile(this) ? "button" : "s24-circle-button"
|
|
1395
|
+
);
|
|
1396
|
+
if (!photo && mobile(this)) {
|
|
1397
|
+
remove.type = "button";
|
|
1398
|
+
remove.className = "attachment-remove";
|
|
1399
|
+
remove.innerHTML = '<s24-icon name="delete" size="32"></s24-icon>';
|
|
1400
|
+
remove.setAttribute("aria-label", `\u0423\u0434\u0430\u043B\u0438\u0442\u044C ${name.textContent}`);
|
|
1401
|
+
}
|
|
1402
|
+
remove.setAttribute("icon", "delete");
|
|
1403
|
+
remove.setAttribute("label", `\u0423\u0434\u0430\u043B\u0438\u0442\u044C ${name.textContent}`);
|
|
1404
|
+
remove.setAttribute("size", "small");
|
|
1405
|
+
remove.dataset.remove = String(i);
|
|
1406
|
+
remove.disabled = this.disabled || this.busy;
|
|
1407
|
+
row.append(preview, meta, remove);
|
|
1408
|
+
list.append(row);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
async add() {
|
|
1412
|
+
return this.run(async (active) => {
|
|
1413
|
+
const method = this.kind === "photo" ? "capturePhoto" : "attachFiles";
|
|
1414
|
+
if (this.sdk?.[method]) {
|
|
1415
|
+
const result = await this.sdk[method]({
|
|
1416
|
+
max_files: Math.max(
|
|
1417
|
+
1,
|
|
1418
|
+
limit(this, "max", this.kind === "photo" ? 20 : 50) - this._value.length
|
|
1419
|
+
),
|
|
1420
|
+
max_size: limit(this, "max-size", 30 * 1024 * 1024)
|
|
1421
|
+
});
|
|
1422
|
+
if (result?.supported !== false) {
|
|
1423
|
+
if (active() && !result?.cancelled) this.append(result.items || []);
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
if (mobile(this) && this.sdk?.[this.kind === "photo" ? "takePhoto" : "pickFile"]) {
|
|
1428
|
+
const result = await this.sdk[this.kind === "photo" ? "takePhoto" : "pickFile"]({ upload: true });
|
|
1429
|
+
if (result?.supported !== false) {
|
|
1430
|
+
if (active() && !result?.cancelled && result?.file)
|
|
1431
|
+
this.append([
|
|
1432
|
+
{
|
|
1433
|
+
...result,
|
|
1434
|
+
preview: result.base64 ? `data:${result.type || "image/jpeg"};base64,${result.base64}` : void 0
|
|
1435
|
+
}
|
|
1436
|
+
]);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
if (active()) this.input.click();
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
class Photos extends Attachments {
|
|
1445
|
+
constructor() {
|
|
1446
|
+
super("photo");
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
class Voice extends Attachments {
|
|
1450
|
+
constructor() {
|
|
1451
|
+
super("voice");
|
|
1452
|
+
this.defaultLabel = "\u0413\u043E\u043B\u043E\u0441\u043E\u0432\u043E\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435";
|
|
1453
|
+
this.shadowRoot.querySelector(".attachments").hidden = true;
|
|
1454
|
+
const wrap = document.createElement("section");
|
|
1455
|
+
wrap.className = "voice-widget";
|
|
1456
|
+
wrap.innerHTML = `<div class="voice-head"><div><strong class="voice-heading"></strong><span class="voice-description">\u0417\u0430\u043F\u0438\u0448\u0438\u0442\u0435 \u0433\u043E\u043B\u043E\u0441\u043E\u0432\u043E\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435.</span></div><button class="voice-web-record" type="button"><s24-icon name="mic" size="18"></s24-icon><span>\u0417\u0430\u043F\u0438\u0441\u0430\u0442\u044C</span></button></div><div class="voice-rail"><div class="voice-track"><span class="voice-hint">\u0421\u043C\u0430\u0445\u043D\u0438\u0442\u0435 \u0432\u043F\u0440\u0430\u0432\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438</span><span class="voice-live" hidden></span><button class="voice-start" type="button" aria-label="\u0421\u043C\u0430\u0445\u043D\u0438\u0442\u0435 \u0432\u043F\u0440\u0430\u0432\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438"><s24-icon name="mic" size="32"></s24-icon></button></div></div><div class="voice-result"><button class="voice-play" type="button" aria-label="\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438"><s24-icon name="play_arrow" size="24"></s24-icon></button><button class="voice-speed" type="button" aria-label="\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0434\u0435\u043D\u0438\u044F">\xD71</button><div class="voice-main"><div class="voice-bars"></div><span class="voice-time">00:00</span></div><button class="voice-delete" type="button" aria-label="\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C"><s24-icon name="delete" size="18"></s24-icon></button></div><audio preload="metadata"></audio>`;
|
|
1457
|
+
this.shadowRoot.insertBefore(
|
|
1458
|
+
wrap,
|
|
1459
|
+
this.shadowRoot.querySelector(".widget-error")
|
|
1460
|
+
);
|
|
1461
|
+
this.thumb = wrap.querySelector(".voice-start");
|
|
1462
|
+
this.thumb.addEventListener("pointerdown", (e) => {
|
|
1463
|
+
if (this.disabled || this.busy || this.value || this.recording) return;
|
|
1464
|
+
e.preventDefault();
|
|
1465
|
+
this.drag = { id: e.pointerId, start: e.clientX };
|
|
1466
|
+
this.thumb.setPointerCapture(e.pointerId);
|
|
1467
|
+
});
|
|
1468
|
+
this.thumb.addEventListener("pointermove", (e) => {
|
|
1469
|
+
if (!this.drag || e.pointerId !== this.drag.id) return;
|
|
1470
|
+
const track = wrap.querySelector(".voice-track");
|
|
1471
|
+
const max = Math.max(1, track.clientWidth - this.thumb.offsetWidth);
|
|
1472
|
+
const x = Math.max(0, Math.min(max, e.clientX - this.drag.start));
|
|
1473
|
+
this.thumb.style.transform = `translateX(${x}px)`;
|
|
1474
|
+
if (x >= max * 0.8 && !this.recording && !this.starting) {
|
|
1475
|
+
this.swiped = true;
|
|
1476
|
+
void this.record();
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
const release = () => {
|
|
1480
|
+
if (!this.drag) return;
|
|
1481
|
+
this.drag = null;
|
|
1482
|
+
this.thumb.style.transform = "";
|
|
1483
|
+
if (this.swiped) {
|
|
1484
|
+
this.swiped = false;
|
|
1485
|
+
this.stopRequested = true;
|
|
1486
|
+
void this.stop();
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
this.thumb.addEventListener("pointerup", release);
|
|
1490
|
+
this.thumb.addEventListener("pointercancel", release);
|
|
1491
|
+
this.thumb.addEventListener("lostpointercapture", release);
|
|
1492
|
+
this.thumb.addEventListener("keydown", (e) => {
|
|
1493
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1494
|
+
e.preventDefault();
|
|
1495
|
+
if (this.recording) void this.stop();
|
|
1496
|
+
else void this.record();
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
wrap.querySelector(".voice-web-record").addEventListener("click", () => {
|
|
1500
|
+
if (this.recording) void this.stop();
|
|
1501
|
+
else void this.record();
|
|
1502
|
+
});
|
|
1503
|
+
const audio = wrap.querySelector("audio");
|
|
1504
|
+
this.audio = audio;
|
|
1505
|
+
audio.addEventListener("timeupdate", () => this.updatePlayback());
|
|
1506
|
+
const wave = wrap.querySelector(".voice-bars");
|
|
1507
|
+
const seek = (e) => {
|
|
1508
|
+
if (!this.value || !Number.isFinite(audio.duration)) return;
|
|
1509
|
+
const box = wave.getBoundingClientRect();
|
|
1510
|
+
audio.currentTime = Math.max(0, Math.min(1, (e.clientX - box.left) / box.width)) * audio.duration;
|
|
1511
|
+
this.updatePlayback();
|
|
1512
|
+
};
|
|
1513
|
+
wave.addEventListener("pointerdown", (e) => {
|
|
1514
|
+
if (this.disabled) return;
|
|
1515
|
+
wave.setPointerCapture(e.pointerId);
|
|
1516
|
+
this.seeking = true;
|
|
1517
|
+
seek(e);
|
|
1518
|
+
});
|
|
1519
|
+
wave.addEventListener("pointermove", (e) => {
|
|
1520
|
+
if (this.seeking) seek(e);
|
|
1521
|
+
});
|
|
1522
|
+
wave.addEventListener("pointerup", () => {
|
|
1523
|
+
this.seeking = false;
|
|
1524
|
+
});
|
|
1525
|
+
wave.addEventListener("pointercancel", () => {
|
|
1526
|
+
this.seeking = false;
|
|
1527
|
+
});
|
|
1528
|
+
audio.addEventListener("ended", () => this.sync());
|
|
1529
|
+
audio.addEventListener("pause", () => this.sync());
|
|
1530
|
+
audio.addEventListener("play", () => this.sync());
|
|
1531
|
+
wrap.querySelector(".voice-play").addEventListener("click", () => {
|
|
1532
|
+
if (!this.value || this.recording) return;
|
|
1533
|
+
if (audio.paused) void audio.play().catch((e) => this.fail(e));
|
|
1534
|
+
else audio.pause();
|
|
1535
|
+
});
|
|
1536
|
+
wrap.querySelector(".voice-speed").addEventListener("click", () => {
|
|
1537
|
+
audio.playbackRate = audio.playbackRate >= 2 ? 1 : audio.playbackRate + 0.5;
|
|
1538
|
+
this.text(".voice-speed", `\xD7${audio.playbackRate}`);
|
|
1539
|
+
});
|
|
1540
|
+
wrap.querySelector(".voice-delete").addEventListener("click", () => {
|
|
1541
|
+
if (this.disabled || this.busy || this.recording) return;
|
|
1542
|
+
audio.pause();
|
|
1543
|
+
this.value = null;
|
|
1544
|
+
this.changed();
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
get value() {
|
|
1548
|
+
return this._value[0] ? copy(this._value[0]) : null;
|
|
1549
|
+
}
|
|
1550
|
+
set value(value) {
|
|
1551
|
+
this._value = value ? [copy(value)] : [];
|
|
1552
|
+
this.sync();
|
|
1553
|
+
}
|
|
1554
|
+
clock(ms) {
|
|
1555
|
+
const s = Math.max(0, Math.floor((ms || 0) / 1e3));
|
|
1556
|
+
return `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(
|
|
1557
|
+
s % 60
|
|
1558
|
+
).padStart(2, "0")}`;
|
|
1559
|
+
}
|
|
1560
|
+
updatePlayback() {
|
|
1561
|
+
const duration = this.value?.duration_ms || this.audio.duration * 1e3 || 0;
|
|
1562
|
+
const ratio = duration ? this.audio.currentTime * 1e3 / duration : 0;
|
|
1563
|
+
this.shadowRoot.querySelectorAll(".voice-bars i").forEach(
|
|
1564
|
+
(bar, i, all) => bar.dataset.played = String(i / all.length < ratio)
|
|
1565
|
+
);
|
|
1566
|
+
this.text(
|
|
1567
|
+
".voice-time",
|
|
1568
|
+
this.clock(
|
|
1569
|
+
this.audio.currentTime ? this.audio.currentTime * 1e3 : duration
|
|
1570
|
+
)
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
sync() {
|
|
1574
|
+
if (!this.shadowRoot.querySelector(".voice-widget")) return;
|
|
1575
|
+
this.labels();
|
|
1576
|
+
const item = this.value, native = mobile(this), recording = !!this.recording;
|
|
1577
|
+
this.text(
|
|
1578
|
+
".voice-heading",
|
|
1579
|
+
this.getAttribute("label") || this.defaultLabel
|
|
1580
|
+
);
|
|
1581
|
+
this.shadowRoot.querySelector(".voice-head").hidden = native && !this.getAttribute("label");
|
|
1582
|
+
this.shadowRoot.querySelector(".voice-rail").hidden = !native || !!item;
|
|
1583
|
+
this.shadowRoot.querySelector(".voice-result").hidden = native && !item;
|
|
1584
|
+
this.shadowRoot.querySelector(".voice-hint").hidden = recording;
|
|
1585
|
+
this.shadowRoot.querySelector(".voice-live").hidden = !recording;
|
|
1586
|
+
this.text(
|
|
1587
|
+
".voice-live",
|
|
1588
|
+
`\u25CF ${this.clock(recording ? Date.now() - this.started : 0)}`
|
|
1589
|
+
);
|
|
1590
|
+
this.thumb.disabled = this.disabled || this.busy;
|
|
1591
|
+
this.thumb.setAttribute(
|
|
1592
|
+
"aria-label",
|
|
1593
|
+
recording ? "\u041E\u0442\u043F\u0443\u0441\u0442\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C" : "\u0421\u043C\u0430\u0445\u043D\u0438\u0442\u0435 \u0432\u043F\u0440\u0430\u0432\u043E \u0434\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438"
|
|
1594
|
+
);
|
|
1595
|
+
const button = this.shadowRoot.querySelector(".voice-web-record");
|
|
1596
|
+
button.disabled = this.disabled || this.busy;
|
|
1597
|
+
button.dataset.recording = String(recording);
|
|
1598
|
+
button.querySelector("s24-icon").setAttribute("name", recording ? "stop" : "mic");
|
|
1599
|
+
button.querySelector("span").textContent = recording ? "\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C" : "\u0417\u0430\u043F\u0438\u0441\u0430\u0442\u044C";
|
|
1600
|
+
this.shadowRoot.querySelector(".voice-play s24-icon").setAttribute("size", native ? "38" : "18");
|
|
1601
|
+
this.shadowRoot.querySelector(".voice-delete s24-icon").setAttribute("size", native ? "32" : "18");
|
|
1602
|
+
this.shadowRoot.querySelector(".voice-play").setAttribute(
|
|
1603
|
+
"aria-label",
|
|
1604
|
+
this.audio?.paused ? "\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438" : "\u041F\u0430\u0443\u0437\u0430"
|
|
1605
|
+
);
|
|
1606
|
+
this.shadowRoot.querySelector(".voice-play").disabled = this.disabled || !item || recording;
|
|
1607
|
+
this.shadowRoot.querySelector(".voice-play s24-icon").setAttribute(
|
|
1608
|
+
"name",
|
|
1609
|
+
item ? this.audio?.paused ? native ? "play_circle" : "play_arrow" : native ? "pause_circle" : "pause" : "graphic_eq"
|
|
1610
|
+
);
|
|
1611
|
+
this.shadowRoot.querySelector(".voice-delete").hidden = !item || recording;
|
|
1612
|
+
this.shadowRoot.querySelector(".voice-speed").hidden = !native || !item;
|
|
1613
|
+
this.shadowRoot.querySelector(".voice-widget").dataset.recording = String(recording);
|
|
1614
|
+
const url = safeURL(item?.url) || (/^data:audio\/[\w.+-]+;base64,/.test(item?.preview || "") ? item.preview : "");
|
|
1615
|
+
if (this.audio && this.audio.getAttribute("src") !== url) {
|
|
1616
|
+
if (url) this.audio.src = url;
|
|
1617
|
+
else this.audio.removeAttribute("src");
|
|
1618
|
+
}
|
|
1619
|
+
const bars = this.shadowRoot.querySelector(".voice-bars");
|
|
1620
|
+
const values = item?.bars?.length ? item.bars : Array.from({ length: 40 }, () => 0.16);
|
|
1621
|
+
if (this.renderedBars !== values) {
|
|
1622
|
+
bars.replaceChildren(
|
|
1623
|
+
...values.slice(0, 120).map((value) => {
|
|
1624
|
+
const b = document.createElement("i");
|
|
1625
|
+
b.style.setProperty(
|
|
1626
|
+
"--bar",
|
|
1627
|
+
String(Math.max(0, Math.min(1, Number(value) || 0)))
|
|
1628
|
+
);
|
|
1629
|
+
b.style.height = `${Math.max(
|
|
1630
|
+
3,
|
|
1631
|
+
Math.min(1, Number(value) || 0) * 38
|
|
1632
|
+
)}px`;
|
|
1633
|
+
return b;
|
|
1634
|
+
})
|
|
1635
|
+
);
|
|
1636
|
+
this.renderedBars = values;
|
|
1637
|
+
}
|
|
1638
|
+
if (!recording) this.updatePlayback();
|
|
1639
|
+
else this.text(".voice-time", this.clock(Date.now() - this.started));
|
|
1640
|
+
}
|
|
1641
|
+
disconnectedCallback() {
|
|
1642
|
+
void this.cancel();
|
|
1643
|
+
this.audio?.pause();
|
|
1644
|
+
super.disconnectedCallback();
|
|
1645
|
+
}
|
|
1646
|
+
async cancel() {
|
|
1647
|
+
clearTimeout(this.recordTimer);
|
|
1648
|
+
clearInterval(this.tick);
|
|
1649
|
+
this.cancelRecording = true;
|
|
1650
|
+
if (this.session && this.sdk?.cancelVoiceRecording)
|
|
1651
|
+
await this.sdk.cancelVoiceRecording({ session_id: this.session }).catch(() => {
|
|
1652
|
+
});
|
|
1653
|
+
this.session = null;
|
|
1654
|
+
if (this.recorder?.state === "recording") this.recorder.stop();
|
|
1655
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
1656
|
+
this.recording = false;
|
|
1657
|
+
}
|
|
1658
|
+
async stop() {
|
|
1659
|
+
this.stopRequested = true;
|
|
1660
|
+
if (this.starting || this.stopping || !this.recording) return;
|
|
1661
|
+
this.stopping = true;
|
|
1662
|
+
clearTimeout(this.recordTimer);
|
|
1663
|
+
clearInterval(this.tick);
|
|
1664
|
+
this.busy = true;
|
|
1665
|
+
this.sync();
|
|
1666
|
+
try {
|
|
1667
|
+
let item;
|
|
1668
|
+
if (this.session) {
|
|
1669
|
+
const result = await this.sdk.stopVoiceRecording({
|
|
1670
|
+
session_id: this.session
|
|
1671
|
+
});
|
|
1672
|
+
if (result?.supported === false)
|
|
1673
|
+
throw new Error("\u0417\u0430\u043F\u0438\u0441\u044C \u0433\u043E\u043B\u043E\u0441\u0430 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430");
|
|
1674
|
+
item = result.items?.[0];
|
|
1675
|
+
} else if (this.recorder?.state === "recording") {
|
|
1676
|
+
const blob = await new Promise((resolve, reject) => {
|
|
1677
|
+
this.recorder.onstop = () => resolve(
|
|
1678
|
+
new Blob(this.chunks, {
|
|
1679
|
+
type: this.recorder.mimeType || "audio/webm"
|
|
1680
|
+
})
|
|
1681
|
+
);
|
|
1682
|
+
this.recorder.onerror = () => reject(new Error("\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u043F\u0438\u0441\u0430\u0442\u044C \u0437\u0432\u0443\u043A"));
|
|
1683
|
+
this.recorder.stop();
|
|
1684
|
+
});
|
|
1685
|
+
if (blob.size) {
|
|
1686
|
+
const ext = blob.type.includes("mp4") ? "m4a" : blob.type.includes("ogg") ? "ogg" : "webm";
|
|
1687
|
+
item = {
|
|
1688
|
+
...await this.localFile(
|
|
1689
|
+
new File([blob], `voice_${Date.now()}.${ext}`, {
|
|
1690
|
+
type: blob.type
|
|
1691
|
+
})
|
|
1692
|
+
),
|
|
1693
|
+
duration_ms: Date.now() - this.started,
|
|
1694
|
+
bars: this.liveBars
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
if (this.isConnected && !this.cancelRecording && item) {
|
|
1699
|
+
this.value = item;
|
|
1700
|
+
this.changed();
|
|
1701
|
+
}
|
|
1702
|
+
} catch (error) {
|
|
1703
|
+
if (this.isConnected) this.fail(error);
|
|
1704
|
+
} finally {
|
|
1705
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
1706
|
+
this.stream = null;
|
|
1707
|
+
this.session = null;
|
|
1708
|
+
this.recording = false;
|
|
1709
|
+
this.busy = false;
|
|
1710
|
+
this.stopping = false;
|
|
1711
|
+
this.audioContext?.close().catch(() => {
|
|
1712
|
+
});
|
|
1713
|
+
this.event("s24-recording", { recording: false });
|
|
1714
|
+
if (this.isConnected) this.sync();
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
async record() {
|
|
1718
|
+
if (this.disabled || this.busy || this.starting || this.recording) return;
|
|
1719
|
+
this.starting = true;
|
|
1720
|
+
this.stopRequested = false;
|
|
1721
|
+
this.cancelRecording = false;
|
|
1722
|
+
this.clearError();
|
|
1723
|
+
const generation = this.generation;
|
|
1724
|
+
try {
|
|
1725
|
+
if (this.sdk?.startVoiceRecording) {
|
|
1726
|
+
this.session = attachmentID();
|
|
1727
|
+
const result = await this.sdk.startVoiceRecording({
|
|
1728
|
+
session_id: this.session,
|
|
1729
|
+
max_duration: Math.min(limit(this, "max-duration", 300), 300)
|
|
1730
|
+
});
|
|
1731
|
+
if (result?.supported === false) {
|
|
1732
|
+
this.session = null;
|
|
1733
|
+
throw new Error("\u0414\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438 \u0433\u043E\u043B\u043E\u0441\u0430 \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24");
|
|
1734
|
+
}
|
|
1735
|
+
} else {
|
|
1736
|
+
if (this.sdk)
|
|
1737
|
+
throw new Error("\u0414\u043B\u044F \u0437\u0430\u043F\u0438\u0441\u0438 \u0433\u043E\u043B\u043E\u0441\u0430 \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 Synchra24");
|
|
1738
|
+
if (!navigator.mediaDevices?.getUserMedia || typeof MediaRecorder === "undefined")
|
|
1739
|
+
throw new Error("\u0417\u0430\u043F\u0438\u0441\u044C \u0433\u043E\u043B\u043E\u0441\u0430 \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u044D\u0442\u0438\u043C \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043E\u043C");
|
|
1740
|
+
this.stream = await navigator.mediaDevices.getUserMedia({
|
|
1741
|
+
audio: true
|
|
1742
|
+
});
|
|
1743
|
+
if (!this.isConnected || generation !== this.generation) {
|
|
1744
|
+
this.stream.getTracks().forEach((t) => t.stop());
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
this.chunks = [];
|
|
1748
|
+
this.liveBars = [];
|
|
1749
|
+
this.recorder = new MediaRecorder(this.stream);
|
|
1750
|
+
this.recorder.ondataavailable = (e) => {
|
|
1751
|
+
if (e.data.size) this.chunks.push(e.data);
|
|
1752
|
+
};
|
|
1753
|
+
this.recorder.start();
|
|
1754
|
+
if (globalThis.AudioContext) {
|
|
1755
|
+
this.audioContext = new AudioContext();
|
|
1756
|
+
const source = this.audioContext.createMediaStreamSource(
|
|
1757
|
+
this.stream
|
|
1758
|
+
);
|
|
1759
|
+
this.analyser = this.audioContext.createAnalyser();
|
|
1760
|
+
source.connect(this.analyser);
|
|
1761
|
+
this.analyser.fftSize = 64;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
if (!this.isConnected || generation !== this.generation) {
|
|
1765
|
+
await this.cancel();
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
this.value = null;
|
|
1769
|
+
this.started = Date.now();
|
|
1770
|
+
this.recording = true;
|
|
1771
|
+
this.event("s24-recording", { recording: true });
|
|
1772
|
+
this.tick = setInterval(() => {
|
|
1773
|
+
if (this.analyser) {
|
|
1774
|
+
const bins = new Uint8Array(this.analyser.frequencyBinCount);
|
|
1775
|
+
this.analyser.getByteFrequencyData(bins);
|
|
1776
|
+
this.liveBars.push(Math.max(0.08, Math.max(...bins) / 255));
|
|
1777
|
+
if (this.liveBars.length > 120) this.liveBars.shift();
|
|
1778
|
+
}
|
|
1779
|
+
this.sync();
|
|
1780
|
+
}, 200);
|
|
1781
|
+
this.recordTimer = setTimeout(
|
|
1782
|
+
() => void this.stop(),
|
|
1783
|
+
Math.min(limit(this, "max-duration", 300), 300) * 1e3
|
|
1784
|
+
);
|
|
1785
|
+
} catch (error) {
|
|
1786
|
+
if (this.isConnected) this.fail(error);
|
|
1787
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
1788
|
+
this.session = null;
|
|
1789
|
+
} finally {
|
|
1790
|
+
this.starting = false;
|
|
1791
|
+
if (this.isConnected) this.sync();
|
|
1792
|
+
if (this.stopRequested && this.recording) void this.stop();
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
return {
|
|
1797
|
+
"s24-employees": Employees,
|
|
1798
|
+
"s24-photos": Photos,
|
|
1799
|
+
"s24-files": Attachments,
|
|
1800
|
+
"s24-voice-recorder": Voice
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
|
|
405
1804
|
// src/material-symbols-data.js
|
|
406
1805
|
var coreIcons = { "add": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M457.308-457.308H242.693q-9.644 0-16.168-6.58-6.524-6.581-6.524-16.308t6.524-16.111q6.524-6.385 16.168-6.385h214.615v-214.615q0-9.644 6.58-16.168 6.581-6.524 16.308-6.524t16.111 6.524q6.385 6.524 6.385 16.168v214.615h214.615q9.644 0 16.168 6.58 6.524 6.581 6.524 16.308t-6.524 16.111q-6.524 6.385-16.168 6.385H502.692v214.615q0 9.644-6.58 16.168-6.581 6.524-16.308 6.524t-16.111-6.524q-6.385-6.524-6.385-16.168v-214.615Z"/></svg>', "remove": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M242.693-457.308q-9.644 0-16.168-6.58-6.524-6.581-6.524-16.308t6.524-16.111q6.524-6.385 16.168-6.385h474.614q9.644 0 16.168 6.58 6.524 6.581 6.524 16.308t-6.524 16.111q-6.524 6.385-16.168 6.385H242.693Z"/></svg>', "close": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480-448.001 266.923-234.924q-6.692 6.693-15.807 6.885-9.116.192-16.192-6.885-7.077-7.076-7.077-15.999 0-8.923 7.077-16L448.001-480 234.924-693.077q-6.693-6.692-6.885-15.807-.192-9.116 6.885-16.192 7.076-7.077 15.999-7.077 8.923 0 16 7.077L480-511.999l213.077-213.077q6.692-6.693 15.807-6.885 9.116-.192 16.192 6.885 7.077 7.076 7.077 15.999 0 8.923-7.077 16L511.999-480l213.077 213.077q6.693 6.692 6.885 15.807.192 9.116-6.885 16.192-7.076 7.077-15.999 7.077-8.923 0-16-7.077L480-448.001Z"/></svg>', "check": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m379.154-323.153 363-363.385q6.759-6.307 16.148-6.5 9.39-.192 16.467 6.553 6.692 7.129 6.692 16.499 0 9.371-6.692 16.063L399.385-278.539q-8.616 8.615-20.231 8.615-11.615 0-20.231-8.615L184.616-452.846q-6.692-6.759-6.577-16.149.116-9.389 7.245-16.466 7.129-6.692 16.307-6.692 9.178 0 16.255 6.692l161.308 162.308Z"/></svg>', "chevronright": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M536.924-480.615 358.77-659.154q-7.077-6.692-6.769-15.807.307-9.115 7.384-15.808 7.077-7.076 16.307-7.076 9.231 0 16.308 7.076l189.922 189.923q4.615 4.615 6.808 9.423 2.192 4.808 2.192 10.808 0 5.615-2.192 10.615-2.193 5-6.808 9.615L391.384-269.847q-6.692 6.692-15.807 6.577-9.115-.115-16.192-7.192t-7.077-16.307q0-9.231 7.077-16.308l177.539-177.538Z"/></svg>', "chevronleft": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m399.076-480.615 178.539 178.154q6.692 6.692 6.384 15.807-.307 9.115-7.384 16.192t-16.307 7.077q-9.231 0-16.308-7.077L354.078-460.385Q349.463-465 347.463-470t-2-10.615q0-6 2-10.808t6.615-9.423l190.538-190.923q6.692-6.692 16.307-6.884 9.615-.192 16.692 6.884 6.692 7.077 6.692 16.5t-6.692 16.115L399.076-480.615Z"/></svg>', "expandmore": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480-370.078q-6 0-10.808-2-4.807-2-9.423-6.615L269.847-568.616q-6.692-6.692-6.885-15.807-.192-9.115 6.885-16.192t16.307-7.077q9.231 0 16.307 7.077L480-423.076l177.539-177.539q6.692-6.692 15.807-6.884 9.115-.193 16.192 6.884t7.077 16.307q0 9.231-7.077 16.308L500.231-378.693q-4.616 4.615-9.423 6.615-4.808 2-10.808 2Z"/></svg>', "calendarmonth": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M197.694-100.001q-23.529 0-40.611-17.082-17.082-17.082-17.082-40.611v-579.227q0-23.529 17.082-40.611 17.082-17.082 40.611-17.082h73.846v-44.924q0-10.523 7.051-17.799 7.051-7.277 17.607-7.277 10.982 0 18.354 7.277 7.372 7.276 7.372 17.799v44.924h317.691v-45.585q0-10.631 6.936-17.523 6.936-6.892 17.222-6.892 10.712 0 17.892 6.978 7.179 6.979 7.179 17.329v45.693h73.462q23.529 0 40.611 17.082 17.082 17.082 17.082 40.611v579.227q0 23.529-17.082 40.611-17.082 17.082-40.611 17.082H197.694Zm0-45.384h564.612q4.616 0 8.463-3.846 3.846-3.847 3.846-8.463v-397.305h-589.23v397.305q0 4.616 3.846 8.463 3.847 3.846 8.463 3.846Zm-12.309-454.997h589.23v-136.539q0-4.616-3.846-8.463-3.847-3.846-8.463-3.846H197.694q-4.616 0-8.463 3.846-3.846 3.847-3.846 8.463v136.539Zm0 0V-749.23-600.382ZM480-396.923q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038T480-467.691q14.692 0 25.038 10.346t10.346 25.038q0 14.692-10.346 25.038T480-396.923Zm-160 0q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038T320-467.691q14.692 0 25.038 10.346t10.346 25.038q0 14.692-10.346 25.038T320-396.923Zm320 0q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038T640-467.691q14.692 0 25.038 10.346t10.346 25.038q0 14.692-10.346 25.038T640-396.923ZM480-240q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038 10.346-10.347 25.038-10.347t25.038 10.347q10.346 10.346 10.346 25.038t-10.346 25.038Q494.692-240 480-240Zm-160 0q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038 10.346-10.347 25.038-10.347t25.038 10.347q10.346 10.346 10.346 25.038t-10.346 25.038Q334.692-240 320-240Zm320 0q-14.692 0-25.038-10.346t-10.346-25.038q0-14.692 10.346-25.038 10.346-10.347 25.038-10.347t25.038 10.347q10.346 10.346 10.346 25.038t-10.346 25.038Q654.692-240 640-240Z"/></svg>', "schedule": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M504.922-489.307v-177.539q0-9.904-6.397-16.298-6.398-6.394-16.308-6.394-9.909 0-16.294 6.394-6.384 6.394-6.384 16.298v184.538q0 5.833 2 10.724t6 9.507l145.539 149.384q6.692 7.308 16.922 7.193 10.231-.116 17.307-7.193 7.077-7.076 7.077-16.807 0-9.73-7.077-16.422L504.922-489.307Zm-24.855 389.306q-78.221 0-147.397-29.92-69.176-29.92-120.989-81.71-51.814-51.791-81.747-120.936-29.933-69.146-29.933-147.366 0-78.221 29.92-147.397 29.92-69.176 81.71-120.989 51.791-51.814 120.936-81.747 69.146-29.933 147.366-29.933 78.221 0 147.397 29.92 69.176 29.92 120.989 81.71 51.814 51.791 81.747 120.936 29.933 69.146 29.933 147.366 0 78.221-29.92 147.397-29.92 69.176-81.71 120.989-51.791 51.814-120.936 81.747-69.146 29.933-147.366 29.933ZM480-480Zm0 334.615q138.077 0 236.346-98.269T814.615-480q0-138.077-98.269-236.346T480-814.615q-138.077 0-236.346 98.269T145.385-480q0 138.077 98.269 236.346T480-145.385Z"/></svg>', "search": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M379.154-342.078q-101.784 0-172.391-70.576-70.608-70.577-70.608-171 0-100.422 70.577-170.999 70.576-70.577 171.219-70.577t171.192 70.577q70.548 70.577 70.548 171.01 0 42.028-14.384 81.835-14.385 39.808-41.616 72.115L807.23-187.769q6.692 6.247 6.884 16.392.193 10.146-6.884 17.03t-17.03 6.884q-9.952 0-16.585-7.076L531.077-397.078q-29.848 26.414-69.61 40.707t-82.313 14.293Zm-.615-45.383q81.955 0 138.862-57.116 56.907-57.115 56.907-139.077 0-81.961-56.907-139.077-56.907-57.115-138.862-57.115-82.468 0-139.734 57.115-57.266 57.116-57.266 139.077 0 81.962 57.266 139.077 57.266 57.116 139.734 57.116Z"/></svg>', "keyboardhide": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m469.365-73.713-97.133-97.134q-6.616-6.615-3.122-15.731 3.494-9.115 13.353-9.115h195.69q9.5 0 12.865 9.115 3.366 9.116-3.25 15.731l-97.133 97.134q-4.271 4.634-10.453 4.634-6.182 0-10.817-4.635ZM157.694-300.002q-23.529 0-40.611-17.082-17.082-17.082-17.082-40.611v-404.612q0-23.529 17.082-40.611 17.082-17.082 40.611-17.082h644.612q23.529 0 40.611 17.082 17.082 17.082 17.082 40.611v404.612q0 23.529-17.082 40.611-17.082 17.082-40.611 17.082H157.694Zm0-45.384h644.612q4.616 0 8.463-3.846 3.846-3.847 3.846-8.463v-404.612q0-4.616-3.846-8.463-3.847-3.846-8.463-3.846H157.694q-4.616 0-8.463 3.846-3.846 3.847-3.846 8.463v404.612q0 4.616 3.846 8.463 3.847 3.846 8.463 3.846Zm197.845-63.077h249.538q11.586 0 19.831-8.105 8.246-8.105 8.246-20.154 0-11.664-8.246-19.779-8.245-8.115-19.831-8.115H355.539q-11.587 0-19.832 8.29-8.245 8.291-8.245 19.962 0 12.055 8.245 19.978 8.245 7.923 19.832 7.923Zm-210.154 63.077V-774.615-345.385Zm85.259-310.384q11.664 0 19.779-8.099 8.116-8.098 8.116-19.961 0-11.863-8.298-19.978-8.298-8.116-19.961-8.116-11.664 0-19.78 8.296-8.115 8.295-8.115 19.956 0 12.056 8.298 19.979 8.297 7.923 19.961 7.923Zm125.077 0q11.664 0 19.779-8.099 8.115-8.098 8.115-19.961 0-11.863-8.297-19.978-8.298-8.116-19.962-8.116-11.663 0-19.779 8.296-8.115 8.295-8.115 19.956 0 12.056 8.297 19.979 8.298 7.923 19.962 7.923Zm124.461 0q11.664 0 19.779-8.099 8.116-8.098 8.116-19.961 0-11.863-8.298-19.978-8.297-8.116-19.961-8.116-11.664 0-19.779 8.296-8.116 8.295-8.116 19.956 0 12.056 8.298 19.979 8.297 7.923 19.961 7.923Zm125.077 0q11.664 0 19.779-8.099 8.116-8.098 8.116-19.961 0-11.863-8.298-19.978-8.298-8.116-19.961-8.116-11.664 0-19.78 8.296Q577-695.332 577-683.671q0 12.056 8.298 19.979 8.297 7.923 19.961 7.923Zm124.461 0q11.664 0 19.78-8.099 8.115-8.098 8.115-19.961 0-11.863-8.298-19.978-8.297-8.116-19.961-8.116-11.664 0-19.779 8.296-8.116 8.295-8.116 19.956 0 12.056 8.298 19.979t19.961 7.923ZM230.644-531.923q11.664 0 19.779-8.298 8.116-8.297 8.116-19.961 0-11.664-8.298-19.779-8.298-8.116-19.961-8.116-11.664 0-19.78 8.298-8.115 8.297-8.115 19.961 0 11.664 8.298 19.779 8.297 8.116 19.961 8.116Zm125.077 0q11.664 0 19.779-8.298 8.115-8.297 8.115-19.961 0-11.664-8.297-19.779-8.298-8.116-19.962-8.116-11.663 0-19.779 8.298-8.115 8.297-8.115 19.961 0 11.664 8.297 19.779 8.298 8.116 19.962 8.116Zm124.461 0q11.664 0 19.779-8.298 8.116-8.297 8.116-19.961 0-11.664-8.298-19.779-8.297-8.116-19.961-8.116-11.664 0-19.779 8.298-8.116 8.297-8.116 19.961 0 11.664 8.298 19.779 8.297 8.116 19.961 8.116Zm125.077 0q11.664 0 19.779-8.298 8.116-8.297 8.116-19.961 0-11.664-8.298-19.779-8.298-8.116-19.961-8.116-11.664 0-19.78 8.298Q577-571.482 577-559.818q0 11.664 8.298 19.779 8.297 8.116 19.961 8.116Zm124.461 0q11.664 0 19.78-8.298 8.115-8.297 8.115-19.961 0-11.664-8.298-19.779-8.297-8.116-19.961-8.116-11.664 0-19.779 8.298-8.116 8.297-8.116 19.961 0 11.664 8.298 19.779 8.298 8.116 19.961 8.116Z"/></svg>', "keyboardarrowdown": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480-369.463q-6 0-10.808-2-4.807-2-9.423-6.615L269.847-568q-6.692-6.693-6.577-16.115.115-9.423 7.192-16.5t16.307-7.077q9.231 0 16.308 7.077L480-423.076l177.539-177.539q6.692-6.692 15.807-6.577 9.115.116 16.192 7.192 7.077 7.077 7.077 16.308 0 9.23-7.077 16.307L500.231-378.078q-4.616 4.615-9.423 6.615-4.808 2-10.808 2Z"/></svg>', "formatlistbulleted": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M407.385-208.385q-9.644 0-16.168-6.581-6.524-6.58-6.524-16.307 0-9.727 6.524-16.111 6.524-6.385 16.168-6.385h389.922q9.644 0 16.168 6.58 6.524 6.58 6.524 16.308 0 9.727-6.524 16.111-6.524 6.385-16.168 6.385H407.385Zm0-248.923q-9.644 0-16.168-6.58-6.524-6.581-6.524-16.308t6.524-16.111q6.524-6.385 16.168-6.385h389.922q9.644 0 16.168 6.58 6.524 6.581 6.524 16.308t-6.524 16.111q-6.524 6.385-16.168 6.385H407.385Zm0-249.538q-9.644 0-16.168-6.581-6.524-6.58-6.524-16.307 0-9.727 6.524-16.112 6.524-6.384 16.168-6.384h389.922q9.644 0 16.168 6.58 6.524 6.58 6.524 16.307 0 9.728-6.524 16.112-6.524 6.385-16.168 6.385H407.385ZM198.65-174.078q-24.069 0-41.051-16.392-16.982-16.391-16.982-40.492 0-24.1 16.699-40.8 16.699-16.699 40.8-16.699 24.101 0 40.492 17.174Q255-254.112 255-230.269q0 23.018-16.553 39.604-16.553 16.587-39.797 16.587Zm0-248.923q-24.069 0-41.051-16.88-16.982-16.881-16.982-40.119t17.06-40.119q17.06-16.88 41.017-16.88 23.132 0 39.719 16.88Q255-503.238 255-480t-16.553 40.119q-16.553 16.88-39.797 16.88Zm-1.034-249.538q-23.238 0-40.119-16.88-16.88-16.881-16.88-40.119t16.88-40.119q16.881-16.88 40.311-16.88 23.431 0 40.311 16.88Q255-752.776 255-729.538t-16.857 40.119q-16.856 16.88-40.527 16.88Z"/></svg>', "edit": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M185.385-185.385h40.923l468.538-467.923-40.923-40.923-468.538 467.923v40.923Zm-16.537 45.384q-12.52 0-20.683-8.164-8.164-8.163-8.164-20.683v-51.844q0-11.786 4.808-22.816t12.808-18.646l544.307-544.46q6.226-5.626 14.651-9.197 8.425-3.572 17.608-3.572 8.568 0 16.808 3.346 8.239 3.346 15.316 9.423l40.923 40.923q6.692 6.692 9.73 15.157 3.039 8.465 3.039 16.93 0 8.604-3.505 17.336-3.505 8.733-9.264 14.96L262.154-157.617q-7.616 8-18.646 12.808-11.03 4.808-22.816 4.808h-51.844Zm605.536-594.306-39.461-39.077 39.461 39.077Zm-99.75 60.673-20.711-20.597 40.923 40.923-20.212-20.326Z"/></svg>', "delete": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M278.309-140.001q-23.5 0-40.596-17.097-17.096-17.096-17.096-40.596v-544.228h-17.924q-9.644 0-16.168-6.581-6.524-6.58-6.524-16.307 0-9.727 6.524-16.112 6.524-6.384 16.168-6.384h148.384q0-11.846 8.245-19.961 8.245-8.116 19.832-8.116h201.692q11.586 0 19.832 8.245 8.245 8.246 8.245 19.832h148.384q9.644 0 16.168 6.58 6.524 6.58 6.524 16.307 0 9.728-6.524 16.112-6.524 6.385-16.168 6.385h-17.924v544.228q0 23.5-17.096 40.596-17.096 17.097-40.596 17.097H278.309ZM694-741.922H266v544.228q0 5.385 3.654 8.847 3.655 3.462 8.655 3.462h403.382q5 0 8.655-3.462 3.654-3.462 3.654-8.847v-544.228ZM404.119-269.846q9.727 0 16.112-6.524 6.384-6.524 6.384-16.168v-343.231q0-9.269-6.58-15.981-6.58-6.711-16.307-6.711-9.727 0-16.112 6.711-6.384 6.712-6.384 15.981v343.231q0 9.644 6.58 16.168 6.58 6.524 16.307 6.524Zm152.153 0q9.727 0 16.112-6.524 6.384-6.524 6.384-16.168v-343.231q0-9.269-6.58-15.981-6.58-6.711-16.307-6.711-9.727 0-16.112 6.711-6.384 6.712-6.384 15.981v343.231q0 9.644 6.58 16.168 6.58 6.524 16.307 6.524ZM266-741.922V-185.385-741.922Z"/></svg>', "info": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M482.426-290.001q9.728 0 16.112-6.524 6.384-6.523 6.384-16.168v-184.615q0-9.644-6.58-16.168-6.58-6.524-16.307-6.524-9.727 0-16.112 6.524-6.384 6.524-6.384 16.168v184.615q0 9.645 6.58 16.168 6.58 6.524 16.307 6.524Zm-2.477-293.998q11.551 0 19.416-7.609 7.865-7.61 7.865-18.858 0-12.098-7.823-20.046-7.824-7.948-19.389-7.948-11.902 0-19.575 8.006-7.673 8.005-7.673 19.84 0 11.311 7.814 18.963 7.814 7.652 19.365 7.652Zm.384 483.998q-78.955 0-147.978-29.92-69.024-29.92-120.756-81.71-51.732-51.791-81.665-120.777-29.933-68.986-29.933-147.833t29.92-148.056q29.92-69.209 81.71-120.522 51.791-51.314 120.777-81.247t147.833-29.933q78.847 0 148.056 29.92 69.209 29.92 120.522 81.21 51.314 51.291 81.247 120.629 29.933 69.337 29.933 147.907 0 78.955-29.92 147.978-29.92 69.024-81.21 120.572-51.291 51.547-120.629 81.664-69.337 30.118-147.907 30.118Zm-.025-45.384q139.384 0 236.846-97.769 97.461-97.769 97.461-237.154 0-139.384-97.247-236.846Q620.12-814.615 480-814.615q-139.077 0-236.846 97.247Q145.385-620.12 145.385-480q0 139.077 97.769 236.846t237.154 97.769ZM480-480Z"/></svg>', "arrowback": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M266.307-457.308 496-228q6.307 6.762 6.692 15.842.384 9.08-6.692 15.99-7.077 7.244-16 7.244t-16-7.077L200.147-459.855q-4.53-4.53-6.53-9.389-2-4.859-2-10.807 0-5.949 2-10.757 2-4.807 6.53-9.337L464-763.999q6.693-6.692 15.731-6.884 9.038-.193 16.269 6.884 7.076 7.231 7.076 16.077 0 8.846-7.076 15.538L266.307-502.692h491q9.913 0 16.302 6.391 6.39 6.392 6.39 16.308t-6.39 16.3q-6.389 6.385-16.302 6.385h-491Z"/></svg>', "refresh": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M481.539-180.001q-124.625 0-212.312-87.67-87.687-87.669-87.687-212.268t87.687-212.329q87.687-87.731 212.312-87.731 81.922 0 145.153 35.654 63.231 35.654 106.384 97.578v-110.54q0-9.903 6.398-16.297 6.398-6.395 16.308-6.395 9.909 0 16.294 6.395 6.384 6.394 6.384 16.297v173.999q0 12.519-8.163 20.682-8.164 8.164-20.683 8.164H575.615q-9.903 0-16.297-6.398t-6.394-16.307q0-9.91 6.394-16.294 6.394-6.385 16.297-6.385h135.308q-36.077-60.769-94.692-97.769-58.616-37-134.692-37-106.693 0-180.654 73.961Q226.924-586.692 226.924-480t73.961 180.654q73.961 73.961 180.654 73.961 74.81 0 138.943-40.269 64.133-40.27 94.979-108.039 3.462-8.692 12.269-13.038 8.808-4.346 17.426-.5 9.381 3.846 12.035 12.846t-.807 18.307Q720.461-275.54 646.19-227.771q-74.27 47.77-164.651 47.77Z"/></svg>', "settings": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M426.77-100.001q-10.923 0-19.615-7.077-8.692-7.077-10.308-18l-14.231-95.154q-20.538-7-44.231-20.346-23.692-13.346-40.846-28.27l-86.769 40q-10.923 4.462-21.846 1.116-10.923-3.346-17-13.654L118.54-335.77q-6.077-10.307-3.538-21.038 2.538-10.73 12.23-17.807l79.616-59q-2-10.539-2.885-23-.885-12.462-.885-23 0-10.154.885-22.616t2.885-24.154l-79.616-59q-9.692-7.077-12.038-18-2.346-10.922 3.731-21.23l52.999-93.23q6.077-9.923 17-13.461 10.923-3.539 21.846.923l86.384 39.231q18.308-14.924 41.231-28.078 22.924-13.154 43.847-19.538l14.615-96.154q1.616-10.923 10.308-18t19.615-7.077h106.46q10.923 0 19.615 7.077 8.692 7.077 10.308 18l14.231 95.538q22.077 8.154 44.154 20.231 22.077 12.077 39.769 28.001l88.308-39.231q10.923-4.462 21.538-.923 10.615 3.538 16.692 13.461l53.615 93.615q6.077 10.307 3.538 21.538-2.538 11.23-12.23 17.307l-81.154 58.539q2.769 11.923 3.462 24 .692 12.077.692 22.846 0 10.385-.885 22.154-.884 11.769-3.269 24.462l80 58.769q9.692 6.077 12.423 17.307 2.73 11.231-3.346 21.538l-52.615 94q-6.462 10.307-17.577 13.653-11.115 3.346-21.653-1.115l-87.539-40q-18.692 15.692-40.346 28.962-21.654 13.269-43.577 19.654l-14.231 95.538q-1.616 10.923-10.308 18t-19.615 7.077H426.77Zm10.384-45.384h85.307L536.846-257q31.846-8 59.423-23.846 27.577-15.847 52.731-40.231l104.461 45.231 40-70.847L701-414.923q4-17.77 6.307-33.5 2.308-15.731 2.308-31.577 0-16.615-2-31.961T701-544.307l93.23-69-40-70.847-105.615 45.231q-21.077-23.692-50.846-41.769Q568-698.769 536.461-703l-13.615-111.615h-85.692l-13.231 111.231q-33.23 6.615-61.192 22.653-27.961 16.039-52.115 41.424L205.77-684.154l-40 70.847 92.461 67.846q-4.385 15.846-6.692 32.153-2.308 16.308-2.308 33.693 0 16.615 2.308 32.538 2.307 15.923 6.307 32.154l-92.076 68.23 40 70.847 104.461-44.847q24 24.385 52.154 40.231 28.154 15.846 61.154 23.846l13.615 111.231Zm41.692-221.924q47.076 0 79.884-32.807 32.807-32.808 32.807-79.884t-32.807-79.884q-32.808-32.807-79.884-32.807-46.692 0-79.691 32.807-33 32.808-33 79.884t33 79.884q32.999 32.807 79.691 32.807ZM480-480Z"/></svg>', "person": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480-492.924q-57.749 0-95.22-37.471t-37.471-95.412q0-57.942 37.471-95.221 37.471-37.278 95.22-37.278t95.22 37.278q37.471 37.279 37.471 95.221 0 57.941-37.471 95.412-37.471 37.471-95.22 37.471ZM180.001-233.847v-29.769q0-32.23 17.077-56.153 17.077-23.923 44.385-36.769 63.153-28.077 121.756-42.308 58.604-14.23 116.769-14.23 58.166 0 116.473 14.538Q654.769-384 717.672-356.266q28.374 12.812 45.35 36.616 16.977 23.804 16.977 56.034v29.769q0 18.98-13.587 32.566-13.586 13.587-32.566 13.587H226.154q-18.98 0-32.566-13.587-13.587-13.586-13.587-32.566Zm45.384.769h509.23v-30.538q0-15.615-9.885-29.923-9.884-14.308-25.808-22.462-58.999-28.692-111.302-40.192-52.302-11.5-107.62-11.5-55.318 0-108.428 11.5t-111.11 40.192q-15.923 8.154-25.5 22.462t-9.577 29.923v30.538ZM480-538.307q37.461 0 62.384-24.924 24.923-24.923 24.923-62.384t-24.923-62.384Q517.461-712.922 480-712.922t-62.384 24.923q-24.923 24.923-24.923 62.384t24.923 62.384q24.923 24.924 62.384 24.924Zm0-87.308Zm0 392.537Z"/></svg>', "group": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M70.31-263.628q0-31.526 16.27-55.795 16.268-24.269 45.555-37.149 64.943-28.504 118.635-42.504 53.692-14 119.731-14 66.039 0 119.231 14 53.192 14 118.52 42.504 28.902 12.88 45.478 37.149 16.577 24.269 16.577 55.795v29.781q0 17.826-13.437 31.989-13.437 14.164-32.716 14.164H116.463q-18.98 0-32.567-13.587-13.586-13.586-13.586-32.566v-29.781Zm773.227 75.934H726.308q3.077-11.539 6.23-22.605 3.154-11.066 3.154-23.548v-28.615q0-53.384-22.633-87.646t-67.211-57.583q53.23 7.615 101.152 19.692 47.922 12.077 80.167 28.624 28.369 15.914 45.446 40.898 17.077 24.985 17.077 56.015v28.615q0 18.98-13.586 32.566-13.587 13.587-32.567 13.587Zm-473.036-305.23q-57.942 0-95.413-37.471-37.47-37.471-37.47-95.412 0-57.942 37.47-95.221 37.471-37.278 95.413-37.278t95.22 37.278Q503-683.749 503-625.807q0 57.941-37.279 95.412-37.278 37.471-95.22 37.471Zm315.958-132.883q0 57.941-37.278 95.412-37.279 37.471-95.358 37.471-6.824 0-14.554-.923t-14.499-3.384q21.431-23.371 32.523-56.117 11.092-32.747 11.092-72.315 0-39.567-11.539-70.605-11.538-31.038-32.076-58.115 6.384-1.462 14.499-2.692 8.115-1.231 14.499-1.231 58.134 0 95.413 37.278 37.278 37.279 37.278 95.221ZM115.694-233.078h509.23v-30.538q0-16-9.116-30.038-9.115-14.039-26.192-22.347-62.769-29.307-110.615-40.5-47.846-11.192-108.5-11.192t-108.808 11.192q-48.154 11.193-110.922 40.5-17.077 8.308-26.077 22.347-9 14.038-9 30.038v30.538Zm254.615-305.229q37.461 0 62.384-24.924 24.923-24.923 24.923-62.384t-24.923-62.384q-24.923-24.923-62.384-24.923-37.462 0-62.385 24.923-24.923 24.923-24.923 62.384t24.923 62.384q24.923 24.924 62.385 24.924Zm0 305.229Zm0-392.537Z"/></svg>', "menu": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M162.693-254.616q-9.644 0-16.168-6.581-6.524-6.58-6.524-16.307 0-9.727 6.524-16.112Q153.049-300 162.693-300h634.614q9.644 0 16.168 6.58 6.524 6.58 6.524 16.307 0 9.728-6.524 16.112-6.524 6.385-16.168 6.385H162.693Zm0-202.692q-9.644 0-16.168-6.58-6.524-6.581-6.524-16.308t6.524-16.111q6.524-6.385 16.168-6.385h634.614q9.644 0 16.168 6.58 6.524 6.581 6.524 16.308t-6.524 16.111q-6.524 6.385-16.168 6.385H162.693Zm0-202.692q-9.644 0-16.168-6.58-6.524-6.58-6.524-16.307 0-9.728 6.524-16.112 6.524-6.385 16.168-6.385h634.614q9.644 0 16.168 6.581 6.524 6.58 6.524 16.307 0 9.727-6.524 16.112Q806.951-660 797.307-660H162.693Z"/></svg>', "download": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M479.815-334.616q-5.815 0-10.623-2.192-4.807-2.193-9.346-6.731L330.309-473.076q-6.692-6.93-6.576-16.234.115-9.304 6.968-16.381 7.3-7.076 16.505-6.884 9.205.192 16.333 6.884l93.769 94.385v-346.001q0-9.663 6.567-16.177 6.567-6.515 16.307-6.515 9.741 0 16.125 6.515 6.385 6.514 6.385 16.177v346.001l94.384-94.385q6.492-6.692 15.707-6.384 9.216.308 16.684 7 6.653 7.146 6.477 16.534-.177 9.388-6.869 16.08L500.169-343.555q-4.554 4.554-9.546 6.747-4.992 2.192-10.808 2.192ZM237.694-180.001q-23.529 0-40.611-17.082-17.082-17.082-17.082-40.611v-102.614q0-9.663 6.567-16.178Q193.135-363 202.875-363q9.741 0 16.126 6.514 6.384 6.515 6.384 16.178v102.614q0 4.616 3.846 8.463 3.847 3.846 8.463 3.846h484.612q4.616 0 8.463-3.846 3.846-3.847 3.846-8.463v-102.614q0-9.663 6.567-16.178Q747.748-363 757.489-363t16.125 6.514q6.385 6.515 6.385 16.178v102.614q0 23.529-17.082 40.611-17.082 17.082-40.611 17.082H237.694Z"/></svg>', "visibility": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480.208-344.232q64.638 0 110.099-45.669 45.461-45.67 45.461-110.307 0-64.638-45.669-110.099-45.67-45.461-110.307-45.461-64.638 0-110.099 45.669-45.461 45.67-45.461 110.307 0 64.638 45.669 110.099 45.67 45.461 110.307 45.461Zm-.511-44.922q-46.312 0-78.428-32.418-32.115-32.419-32.115-78.731t32.418-78.428q32.419-32.115 78.731-32.115t78.428 32.418q32.115 32.419 32.115 78.731t-32.418 78.428q-32.419 32.115-78.731 32.115ZM480-220.001q-126.922 0-231.845-70.231-104.923-70.23-169.23-180.153-4.385-7.287-6.385-14.635t-2-15.083q0-7.735 2-15.007 2-7.272 6.385-14.505 64.307-109.923 169.23-180.153Q353.078-779.999 480-779.999t231.845 70.231q104.923 70.23 169.23 180.153 4.385 7.287 6.385 14.635t2 15.083q0 7.735-2 15.007-2 7.272-6.385 14.505-64.307 109.923-169.23 180.153Q606.922-220.001 480-220.001ZM480-500Zm-.169 234.615q119.246 0 218.823-63.769Q798.23-392.923 850.461-500 798.23-607.077 698.822-670.846q-99.408-63.769-218.653-63.769-119.246 0-218.823 63.769Q161.77-607.077 108.924-500q52.846 107.077 152.254 170.846 99.408 63.769 218.653 63.769Z"/></svg>', "visibilityoff": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="m620.153-434.386-34.768-34.768q19.769-63.539-26.962-110.269-46.73-46.731-109.269-25.962l-34.768-34.768q14.923-8.308 31.884-11.961 16.961-3.654 33.73-3.654 64.846 0 110.307 45.461T635.768-500q0 16.769-3.461 33.73-3.462 16.961-12.154 31.884Zm127.846 126.692-31.153-29.999q43.077-31.846 78.154-72.115 35.076-40.269 55.461-90.192-49.385-107.077-147.231-170.846-97.846-63.769-215.923-63.769-36.922 0-73.153 4.808-36.23 4.807-70.307 19.115l-34.846-35.461q41.385-17.923 85.307-25.884 43.923-7.962 89.538-7.962 128.923 0 236.038 69.538Q826.999-640.922 885.075-526q3 6.385 5 12.692 2 6.308 2 13.308t-1.692 13.308q-1.692 6.307-4.692 12.692-24.462 49.615-59.077 91.307-34.615 41.692-78.615 74.999ZM480-220.001q-127.922 0-233.461-70.038Q141.001-360.078 77.694-472q-4.385-6.615-6.077-13.308Q69.925-492 69.925-500t2.192-14.692q2.192-6.693 5.577-13.308 25.154-46.846 57.039-88 31.884-41.154 73.038-74.23L101.233-796.384q-6.693-6.692-6.577-15.808.115-9.115 6.577-16.192 7.076-7.076 16.307-7.076 9.23 0 16.307 7.076l689.46 689.46q6.077 6.077 6.077 14.692t-6.077 15.692q-6.462 7.692-15.692 7.692-9.231 0-16.308-7.077l-145.23-143q-39.846 16.539-81.462 23.731Q523-220.001 480-220.001Zm-241.23-438.23q-43.692 29.385-76.808 69.538-33.115 40.154-53.038 88.693 51.615 109.307 153.422 171.961 101.808 62.654 223.346 62.654 32.847 0 64.924-2.654 32.077-2.654 61.154-17.192l-70.924-70.924q-14.384 7.539-29.846 9.731-15.461 2.192-31 2.192-64.846 0-110.307-45.461T324.232-500q0-15.539 2.692-30.808t9.231-30.038l-97.385-97.385ZM531.462-517Zm-105.999 53.384Z"/></svg>', "checkcircle": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M421-380.153 319.538-482q-7.077-6.692-16.807-6.884-9.731-.192-17.423 7.5-7.077 7.077-7.077 16.807 0 9.731 7.077 16.807l115.461 116.077q8.616 9 20.231 9 11.615 0 20.231-9l232.076-231.692q7.308-7.692 7.5-17.423.192-9.73-7.5-17.422-7.692-7.077-17.73-6.769-10.038.307-17.115 7.384L421-380.153Zm59.067 280.152q-78.221 0-147.397-29.92-69.176-29.92-120.989-81.71-51.814-51.791-81.747-120.936-29.933-69.146-29.933-147.366 0-78.836 29.92-148.204 29.92-69.369 81.71-120.682 51.791-51.314 120.936-81.247 69.146-29.933 147.366-29.933 78.836 0 148.204 29.92 69.369 29.92 120.682 81.21 51.314 51.291 81.247 120.629 29.933 69.337 29.933 148.173 0 78.221-29.92 147.397-29.92 69.176-81.21 120.989-51.291 51.814-120.629 81.747-69.337 29.933-148.173 29.933ZM480-145.385q139.692 0 237.154-97.769Q814.615-340.923 814.615-480q0-139.692-97.461-237.154Q619.692-814.615 480-814.615q-139.077 0-236.846 97.461Q145.385-619.692 145.385-480q0 139.077 97.769 236.846T480-145.385ZM480-480Z"/></svg>', "error": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M479.982-290.77q11.902 0 19.575-7.655 7.673-7.656 7.673-19.558 0-11.902-7.655-19.575t-19.557-7.673q-11.902 0-19.575 7.656-7.673 7.655-7.673 19.557 0 11.902 7.655 19.575t19.557 7.673Zm2.438-141.076q9.734 0 16.118-6.519 6.384-6.519 6.384-16.173v-204.155q0-9.653-6.573-16.172t-16.307-6.519q-9.734 0-16.119 6.519-6.384 6.519-6.384 16.172v204.155q0 9.654 6.573 16.173 6.574 6.519 16.308 6.519Zm-2.087 331.845q-78.955 0-147.897-29.92t-120.755-81.71q-51.814-51.791-81.747-120.777t-29.933-148.025q0-78.655 29.92-147.864t81.71-120.522q51.791-51.314 120.777-81.247t148.025-29.933q78.655 0 147.864 29.92t120.522 81.21q51.314 51.291 81.247 120.629 29.933 69.337 29.933 147.907 0 78.955-29.92 147.897t-81.21 120.571q-51.291 51.629-120.629 81.746-69.337 30.118-147.907 30.118Zm.167-45.384q139.192 0 236.654-97.769 97.461-97.769 97.461-237.346 0-139.192-97.274-236.654Q620.067-814.615 480-814.615q-139.077 0-236.846 97.274T145.385-480q0 139.077 97.769 236.846T480.5-145.385ZM480-480Z"/></svg>', "warning": '<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M124.633-140.001q-8.554 0-15.055-4.02-6.502-4.019-10.114-10.596-3.846-6.061-4.23-13.646-.385-7.585 4.168-15.212L455.29-797.033q4.479-7.118 10.787-10.618 6.308-3.5 13.923-3.5t13.923 3.5q6.308 3.5 10.787 10.618l355.888 613.558q4.553 7.627 4.169 15.212-.385 7.585-4.231 13.646-3.612 6.577-10.114 10.596-6.501 4.02-15.055 4.02H124.633Zm28.598-45.384h653.538L480-749.23 153.231-185.385Zm329.797-60.077q10.703 0 17.76-7.24 7.058-7.24 7.058-17.942t-7.24-17.76q-7.24-7.057-17.942-7.057t-17.76 7.239q-7.058 7.24-7.058 17.942 0 10.703 7.24 17.76 7.24 7.058 17.942 7.058Zm.014-97.922q9.727 0 16.111-6.524 6.385-6.524 6.385-16.168v-172.462q0-9.644-6.58-16.168-6.58-6.524-16.308-6.524-9.727 0-16.111 6.524-6.385 6.524-6.385 16.168v172.462q0 9.644 6.58 16.168 6.581 6.524 16.308 6.524ZM480-467.307Z"/></svg>' };
|
|
407
1806
|
var catalogCount = 6492;
|
|
@@ -490,7 +1889,7 @@ function coreSVG(name, cls = "") {
|
|
|
490
1889
|
}
|
|
491
1890
|
|
|
492
1891
|
// src/index.js
|
|
493
|
-
var version = "0.
|
|
1892
|
+
var version = "0.2.0";
|
|
494
1893
|
var sessions = /* @__PURE__ */ new WeakMap();
|
|
495
1894
|
var contextKey = /* @__PURE__ */ Symbol.for("synchra24.ui.context.v1");
|
|
496
1895
|
function contextFor(element) {
|
|
@@ -631,6 +2030,7 @@ function connect(root, {
|
|
|
631
2030
|
set("selectPadding", mobile ? "0 12px" : "0 20px 0 22px");
|
|
632
2031
|
set("fieldText", !mobile && active === "light" ? next?.tokens?.["--text"] ?? "#111418" : colors.text);
|
|
633
2032
|
set("selectShadow", active === "dark" ? "0 24px 70px rgba(0,0,0,.44)" : "0 14px 38px rgba(17,24,39,.12)");
|
|
2033
|
+
set("segmentBg", active === "dark" ? "rgba(255,255,255,.035)" : "rgba(0,0,0,.035)");
|
|
634
2034
|
set("searchBg", active === "dark" ? "#171c22" : colors.inputGrey);
|
|
635
2035
|
set("searchBorder", active === "dark" ? "#373f49" : "#c8d0d8");
|
|
636
2036
|
set("searchFocusBorder", active === "dark" ? "#515d6b" : "#c8d0d8");
|
|
@@ -736,7 +2136,11 @@ function connect(root, {
|
|
|
736
2136
|
root.dataset.s24Runtime = activeRuntime;
|
|
737
2137
|
root.dataset.s24Theme = active;
|
|
738
2138
|
if (root[contextKey]) root[contextKey].runtime = activeRuntime;
|
|
739
|
-
|
|
2139
|
+
const apply = (parent) => parent.querySelectorAll("*").forEach((element) => {
|
|
2140
|
+
element._applyPlatform?.(activeRuntime);
|
|
2141
|
+
if (element.shadowRoot) apply(element.shadowRoot);
|
|
2142
|
+
});
|
|
2143
|
+
apply(root);
|
|
740
2144
|
root.querySelectorAll("s24-input,s24-textarea,s24-text,s24-typography").forEach((field) => field.sync?.());
|
|
741
2145
|
}
|
|
742
2146
|
update();
|
|
@@ -786,7 +2190,8 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
786
2190
|
_applyPlatform(runtime) {
|
|
787
2191
|
this._runtime = runtime;
|
|
788
2192
|
const style = this.shadowRoot.querySelector("style[data-s24-platform]");
|
|
789
|
-
const value = runtime === "mobile" ? mobileStyles + mobileExtras : "";
|
|
2193
|
+
const value = (runtime === "mobile" ? mobileStyles + mobileExtras : "") + segmentedStyles + searchStyles;
|
|
2194
|
+
this.toggleAttribute("data-segment-mobile", runtime === "mobile");
|
|
790
2195
|
if (style.textContent !== value) style.textContent = value;
|
|
791
2196
|
}
|
|
792
2197
|
text(selector, value) {
|
|
@@ -972,6 +2377,56 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
972
2377
|
this.control?.focus(options);
|
|
973
2378
|
}
|
|
974
2379
|
}
|
|
2380
|
+
class Search extends FormControl {
|
|
2381
|
+
static observedAttributes = [...FormControl.observedAttributes, "small", "maxlength"];
|
|
2382
|
+
constructor() {
|
|
2383
|
+
super(`<div class="field"><span class="label"></span><div class="search-field" part="field"><s24-icon class="search-leading" name="search" size="18" aria-hidden="true"></s24-icon><input type="search" enterkeyhint="search" part="input"><button class="search-action" type="button" aria-label="\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u0438\u0441\u043A"><s24-icon name="close" size="26" aria-hidden="true"></s24-icon></button></div><small class="hint"></small><small class="error"></small></div>`);
|
|
2384
|
+
this.control = this.shadowRoot.querySelector("input");
|
|
2385
|
+
this.action = this.shadowRoot.querySelector(".search-action");
|
|
2386
|
+
this.control.addEventListener("input", () => {
|
|
2387
|
+
this._value = this.control.value;
|
|
2388
|
+
this.sync();
|
|
2389
|
+
this.event("s24-input", { value: this.value });
|
|
2390
|
+
});
|
|
2391
|
+
this.control.addEventListener("change", () => this.event("s24-change", { value: this.value }));
|
|
2392
|
+
this.control.addEventListener("keydown", (e) => {
|
|
2393
|
+
if (e.key === "Enter") {
|
|
2394
|
+
e.preventDefault();
|
|
2395
|
+
this.event("s24-submit", { value: this.value });
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
this.action.addEventListener("click", () => {
|
|
2399
|
+
if (this.disabled) return;
|
|
2400
|
+
if (this.value) {
|
|
2401
|
+
this.value = "";
|
|
2402
|
+
this.event("s24-input", { value: "" });
|
|
2403
|
+
this.event("s24-change", { value: "" });
|
|
2404
|
+
}
|
|
2405
|
+
this.control.focus();
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
_applyPlatform(runtime) {
|
|
2409
|
+
super._applyPlatform(runtime);
|
|
2410
|
+
this.sync();
|
|
2411
|
+
}
|
|
2412
|
+
sync() {
|
|
2413
|
+
if (!this.control) return;
|
|
2414
|
+
this.labels();
|
|
2415
|
+
this.control.value = this.value;
|
|
2416
|
+
this.control.disabled = this.disabled;
|
|
2417
|
+
this.control.placeholder = this.getAttribute("placeholder") || "\u041F\u043E\u0438\u0441\u043A\u2026";
|
|
2418
|
+
this.control.setAttribute("aria-label", this.getAttribute("label") || this.getAttribute("aria-label") || this.control.placeholder);
|
|
2419
|
+
this.control.setAttribute("aria-invalid", String(!!this.getAttribute("error")));
|
|
2420
|
+
const max = this.getAttribute("maxlength");
|
|
2421
|
+
if (max !== null) this.control.setAttribute("maxlength", max);
|
|
2422
|
+
else this.control.removeAttribute("maxlength");
|
|
2423
|
+
this.action.disabled = this.disabled;
|
|
2424
|
+
this.action.dataset.empty = String(!this.value);
|
|
2425
|
+
this.action.setAttribute("aria-label", this.value ? "\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u043F\u043E\u0438\u0441\u043A" : "\u041F\u043E\u0438\u0441\u043A");
|
|
2426
|
+
this.action.querySelector("s24-icon").setAttribute("name", this.value ? "close" : "search");
|
|
2427
|
+
this.setForm(this.value);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
975
2430
|
class DateTimeField extends FormControl {
|
|
976
2431
|
static observedAttributes = [
|
|
977
2432
|
...FormControl.observedAttributes,
|
|
@@ -1544,9 +2999,9 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1544
2999
|
const counter = this.shadowRoot.querySelector(".field-count");
|
|
1545
3000
|
if (!counter) return;
|
|
1546
3001
|
counter.hidden = !this.hasAttribute("len");
|
|
1547
|
-
const
|
|
1548
|
-
counter.textContent = `${this.value.length}/${
|
|
1549
|
-
counter.style.color = this.value.length >
|
|
3002
|
+
const limit2 = Number(this.getAttribute("len"));
|
|
3003
|
+
counter.textContent = `${this.value.length}/${limit2}`;
|
|
3004
|
+
counter.style.color = this.value.length > limit2 ? "var(--s24-error)" : "";
|
|
1550
3005
|
}
|
|
1551
3006
|
validate() {
|
|
1552
3007
|
this.setForm(this.value);
|
|
@@ -2059,14 +3514,32 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2059
3514
|
}
|
|
2060
3515
|
}
|
|
2061
3516
|
class Tab extends Component {
|
|
3517
|
+
static observedAttributes = ["count"];
|
|
3518
|
+
_applyPlatform(runtime) {
|
|
3519
|
+
super._applyPlatform(runtime);
|
|
3520
|
+
this.sync();
|
|
3521
|
+
}
|
|
3522
|
+
connectedCallback() {
|
|
3523
|
+
this.sync();
|
|
3524
|
+
}
|
|
3525
|
+
attributeChangedCallback() {
|
|
3526
|
+
this.sync();
|
|
3527
|
+
}
|
|
3528
|
+
sync() {
|
|
3529
|
+
const badge = this.shadowRoot.querySelector(".tab-count");
|
|
3530
|
+
if (!badge) return;
|
|
3531
|
+
const count = this.getAttribute("count");
|
|
3532
|
+
badge.hidden = count === null || count === "";
|
|
3533
|
+
badge.textContent = this._runtime === "mobile" ? `(${count})` : count || "";
|
|
3534
|
+
}
|
|
2062
3535
|
constructor() {
|
|
2063
3536
|
super(
|
|
2064
|
-
'<style>.tab-inner{display:contents}:host{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--s24-border);border-radius:var(--s24-tab-radius);padding:var(--s24-tab-padding);color:var(--s24-muted);font-size:var(--s24-control-size);white-space:nowrap;flex-shrink:0;cursor:pointer}:host([aria-selected=true]){background:var(--s24-active-bg);border-color:var(--s24-accent);color:var(--s24-active-text)}:host(:focus-visible){outline:2px solid var(--s24-accent);outline-offset:2px}:host([disabled]){opacity:.45;cursor:not-allowed}</style><span class="tab-inner"><slot></slot></span>'
|
|
3537
|
+
'<style>.tab-inner{display:contents}:host{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--s24-border);border-radius:var(--s24-tab-radius);padding:var(--s24-tab-padding);color:var(--s24-muted);font-size:var(--s24-control-size);white-space:nowrap;flex-shrink:0;cursor:pointer}:host([aria-selected=true]){background:var(--s24-active-bg);border-color:var(--s24-accent);color:var(--s24-active-text)}:host(:focus-visible){outline:2px solid var(--s24-accent);outline-offset:2px}:host([disabled]){opacity:.45;cursor:not-allowed}</style><span class="tab-inner"><slot></slot><span class="tab-count" hidden></span></span>'
|
|
2065
3538
|
);
|
|
2066
3539
|
}
|
|
2067
3540
|
}
|
|
2068
3541
|
class Tabs extends Component {
|
|
2069
|
-
static observedAttributes = ["value"];
|
|
3542
|
+
static observedAttributes = ["value", "variant"];
|
|
2070
3543
|
constructor() {
|
|
2071
3544
|
super(
|
|
2072
3545
|
"<style>:host{display:flex;min-width:0;max-width:100%;gap:var(--s24-tab-gap);overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none;padding:3px 0}:host::-webkit-scrollbar{display:none}</style><slot></slot>"
|
|
@@ -2101,6 +3574,7 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2101
3574
|
(el) => el.getAttribute("value") === this.value && !el.hasAttribute("disabled")
|
|
2102
3575
|
) ?? tabs.find((el) => !el.hasAttribute("disabled"));
|
|
2103
3576
|
for (const tab of tabs) {
|
|
3577
|
+
tab.toggleAttribute("data-segmented", this.getAttribute("variant") === "segmented");
|
|
2104
3578
|
tab.setAttribute("role", "tab");
|
|
2105
3579
|
tab.setAttribute("aria-disabled", String(tab.hasAttribute("disabled")));
|
|
2106
3580
|
tab.setAttribute("aria-selected", String(tab === selected));
|
|
@@ -2399,10 +3873,14 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2399
3873
|
}
|
|
2400
3874
|
}
|
|
2401
3875
|
const components = {
|
|
3876
|
+
...widgetComponents({ Component, contextFor, mobile, coreSVG }),
|
|
3877
|
+
...feedbackComponents({ Component, contextFor, mobile }),
|
|
3878
|
+
...editorComponents({ Component, contextFor, mobile }),
|
|
2402
3879
|
"s24-icon": Icon,
|
|
2403
3880
|
"s24-typography": Typography,
|
|
2404
3881
|
"s24-button": Button,
|
|
2405
3882
|
"s24-circle-button": CircleButton,
|
|
3883
|
+
"s24-search": Search,
|
|
2406
3884
|
"s24-input": Input,
|
|
2407
3885
|
"s24-textarea": Textarea,
|
|
2408
3886
|
"s24-checkbox": Choice,
|