@synchra24/app-ui 0.1.0 → 0.3.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 +17 -0
- package/README.md +24 -2
- package/custom-elements.json +465 -0
- package/dist/auto.js +1745 -24
- package/dist/index.d.ts +146 -2
- package/dist/index.js +1745 -24
- package/dist/react.d.ts +66 -1
- package/dist/synchra-app-ui.js +131 -8
- package/docs/AI-AGENT.md +28 -0
- package/docs/API.md +181 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/package.json +3 -2
package/dist/auto.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,1232 @@ 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/sheet-schema.js
|
|
857
|
+
var object = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
858
|
+
var text = (value, max = 500) => typeof value === "string" && value.length <= max;
|
|
859
|
+
var optionalText = (value, max = 500) => value === void 0 || text(value, max);
|
|
860
|
+
var optionalBoolean = (value) => value === void 0 || typeof value === "boolean";
|
|
861
|
+
var namePattern = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;
|
|
862
|
+
function parseSheetDefinition(value) {
|
|
863
|
+
if (!object(value) || value.version !== 1 || !text(value.title) || !value.title.trim() || !optionalText(value.description, 2e3))
|
|
864
|
+
return null;
|
|
865
|
+
try {
|
|
866
|
+
if (JSON.stringify(value).length > 131072)
|
|
867
|
+
return null;
|
|
868
|
+
} catch {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
const names = /* @__PURE__ */ new Set();
|
|
872
|
+
let count = 0;
|
|
873
|
+
const nodes = (items, depth) => {
|
|
874
|
+
if (!Array.isArray(items) || depth > 4)
|
|
875
|
+
return false;
|
|
876
|
+
return items.every((node) => {
|
|
877
|
+
if (!object(node) || ++count > 100)
|
|
878
|
+
return false;
|
|
879
|
+
if (node.type === "divider")
|
|
880
|
+
return true;
|
|
881
|
+
if (node.type === "text")
|
|
882
|
+
return text(node.text, 8e3) && (node.tone === void 0 || ["default", "secondary"].includes(node.tone));
|
|
883
|
+
if (node.type === "section")
|
|
884
|
+
return text(node.title) && optionalText(node.description, 2e3) && nodes(node.children, depth + 1);
|
|
885
|
+
if (!["input", "select", "toggle"].includes(node.type) || !text(node.name, 64) || !namePattern.test(node.name) || names.has(node.name) || !text(node.label) || !optionalText(node.description, 2e3) || !optionalText(node.placeholder) || !optionalBoolean(node.required) || !optionalBoolean(node.disabled))
|
|
886
|
+
return false;
|
|
887
|
+
names.add(node.name);
|
|
888
|
+
if (node.type === "toggle")
|
|
889
|
+
return optionalBoolean(node.value);
|
|
890
|
+
if (!optionalText(node.value, 8e3))
|
|
891
|
+
return false;
|
|
892
|
+
if (node.type === "input")
|
|
893
|
+
return optionalBoolean(node.multiline) && (node.maxLength === void 0 || Number.isSafeInteger(node.maxLength) && node.maxLength > 0 && node.maxLength <= 8e3);
|
|
894
|
+
if (!Array.isArray(node.options) || !node.options.length || node.options.length > 200)
|
|
895
|
+
return false;
|
|
896
|
+
const options = /* @__PURE__ */ new Set();
|
|
897
|
+
return node.options.every((o) => {
|
|
898
|
+
if (!object(o) || !text(o.value, 256) || !text(o.label) || !optionalBoolean(o.disabled) || options.has(o.value))
|
|
899
|
+
return false;
|
|
900
|
+
options.add(o.value);
|
|
901
|
+
return true;
|
|
902
|
+
}) && (node.value === void 0 || node.options.some((o) => o.value === node.value && !o.disabled));
|
|
903
|
+
});
|
|
904
|
+
};
|
|
905
|
+
if (!nodes(value.content, 0) || !Array.isArray(value.actions) || !value.actions.length || value.actions.length > 3)
|
|
906
|
+
return null;
|
|
907
|
+
const actionIds = /* @__PURE__ */ new Set();
|
|
908
|
+
if (!value.actions.every((a) => {
|
|
909
|
+
if (!object(a) || !text(a.id, 64) || !namePattern.test(a.id) || actionIds.has(a.id) || !text(a.label) || !["submit", "cancel", "reset"].includes(a.kind) || !optionalBoolean(a.primary))
|
|
910
|
+
return false;
|
|
911
|
+
actionIds.add(a.id);
|
|
912
|
+
return true;
|
|
913
|
+
}))
|
|
914
|
+
return null;
|
|
915
|
+
const definition = JSON.parse(JSON.stringify(value));
|
|
916
|
+
if (value.resetValues !== void 0 && (!object(value.resetValues) || !validSheetValues(definition, value.resetValues, false)))
|
|
917
|
+
return null;
|
|
918
|
+
return definition;
|
|
919
|
+
}
|
|
920
|
+
function sheetFields(definition) {
|
|
921
|
+
const result = [];
|
|
922
|
+
const visit = (nodes) => nodes.forEach((node) => {
|
|
923
|
+
if (node.type === "section")
|
|
924
|
+
visit(node.children);
|
|
925
|
+
else if ("name" in node)
|
|
926
|
+
result.push(node);
|
|
927
|
+
});
|
|
928
|
+
visit(definition.content);
|
|
929
|
+
return result;
|
|
930
|
+
}
|
|
931
|
+
function validSheetValues(definition, values, required = true) {
|
|
932
|
+
if (!object(values))
|
|
933
|
+
return false;
|
|
934
|
+
const fields = sheetFields(definition);
|
|
935
|
+
if (Object.keys(values).some((key2) => !fields.some((field) => field.name === key2)))
|
|
936
|
+
return false;
|
|
937
|
+
return fields.every((field) => {
|
|
938
|
+
const value = values[field.name];
|
|
939
|
+
if (value === void 0)
|
|
940
|
+
return !required;
|
|
941
|
+
if (field.type === "toggle")
|
|
942
|
+
return typeof value === "boolean" && (!field.disabled || value === (field.value ?? false));
|
|
943
|
+
if (!text(value, field.type === "input" ? field.maxLength ?? 8e3 : 256) || required && field.required && !value.trim())
|
|
944
|
+
return false;
|
|
945
|
+
if (field.disabled && value !== (field.value ?? ""))
|
|
946
|
+
return false;
|
|
947
|
+
return field.type !== "select" || value === "" && (!required || !field.required) || field.options.some((o) => o.value === value && !o.disabled);
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// src/sheet-component.js
|
|
952
|
+
function sheetComponents({ Component, contextFor: contextFor2, mobile }) {
|
|
953
|
+
class Sheet extends Component {
|
|
954
|
+
constructor() {
|
|
955
|
+
super("<style>:host{display:contents}</style><slot></slot>");
|
|
956
|
+
this.dialog = this.ownerDocument.createElement("s24-dialog");
|
|
957
|
+
this.dialog.addEventListener("s24-close", (event) => {
|
|
958
|
+
event.stopPropagation();
|
|
959
|
+
if (!this._settled && this._resolve) this._finish({ supported: true, cancelled: true });
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
connectedCallback() {
|
|
963
|
+
if (!this.dialog.parentNode) this.append(this.dialog);
|
|
964
|
+
}
|
|
965
|
+
disconnectedCallback() {
|
|
966
|
+
this.close();
|
|
967
|
+
}
|
|
968
|
+
async show(definition) {
|
|
969
|
+
if (this._resolve) throw new Error("Sheet is already open");
|
|
970
|
+
const parsed = parseSheetDefinition(definition);
|
|
971
|
+
if (!parsed) throw new TypeError("Invalid sheet definition version 1");
|
|
972
|
+
this._definition = parsed;
|
|
973
|
+
this._values = {};
|
|
974
|
+
this._fields = [];
|
|
975
|
+
const visit = (nodes) => nodes.forEach((node) => {
|
|
976
|
+
if (node.type === "section") visit(node.children);
|
|
977
|
+
else if (node.name) {
|
|
978
|
+
this._fields.push(node);
|
|
979
|
+
this._values[node.name] = node.value ?? (node.type === "toggle" ? false : "");
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
visit(this._definition.content);
|
|
983
|
+
this._settled = false;
|
|
984
|
+
const result = new Promise((resolve) => {
|
|
985
|
+
this._resolve = resolve;
|
|
986
|
+
});
|
|
987
|
+
const sdk = contextFor2(this)?.sdk;
|
|
988
|
+
if (mobile(this) && sdk?.getCapabilities?.().nativeSheet === 1 && sdk.openSheet) {
|
|
989
|
+
const id = "sheet_" + (globalThis.crypto?.randomUUID?.() ?? Math.random().toString(36).slice(2));
|
|
990
|
+
this._native = { sdk, id };
|
|
991
|
+
Promise.resolve(sdk.openSheet(this._definition, { id })).then((reply) => {
|
|
992
|
+
if (this._native?.id !== id) return;
|
|
993
|
+
if (reply.supported === false) {
|
|
994
|
+
this._native = null;
|
|
995
|
+
this._renderWeb();
|
|
996
|
+
} else this._finish(reply);
|
|
997
|
+
}).catch((error) => {
|
|
998
|
+
if (this._native?.id !== id) return;
|
|
999
|
+
this._finish({ supported: true, cancelled: true });
|
|
1000
|
+
this.event("s24-error", { message: error.message });
|
|
1001
|
+
});
|
|
1002
|
+
} else this._renderWeb();
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
_renderWeb() {
|
|
1006
|
+
const doc = this.ownerDocument, definition = this._definition;
|
|
1007
|
+
this.dialog.replaceChildren();
|
|
1008
|
+
this.dialog.setAttribute("heading", definition.title);
|
|
1009
|
+
if (definition.description) this.dialog.setAttribute("description", definition.description);
|
|
1010
|
+
else this.dialog.removeAttribute("description");
|
|
1011
|
+
const render = (nodes, parent) => {
|
|
1012
|
+
for (const node of nodes) {
|
|
1013
|
+
let element;
|
|
1014
|
+
if (node.type === "section") {
|
|
1015
|
+
element = doc.createElement("s24-stack");
|
|
1016
|
+
const title = doc.createElement("s24-text");
|
|
1017
|
+
title.setAttribute("bold", "");
|
|
1018
|
+
title.textContent = node.title;
|
|
1019
|
+
element.append(title);
|
|
1020
|
+
if (node.description) {
|
|
1021
|
+
const description = doc.createElement("s24-text");
|
|
1022
|
+
description.setAttribute("muted", "");
|
|
1023
|
+
description.textContent = node.description;
|
|
1024
|
+
element.append(description);
|
|
1025
|
+
}
|
|
1026
|
+
render(node.children, element);
|
|
1027
|
+
} else if (node.type === "text") {
|
|
1028
|
+
element = doc.createElement("s24-text");
|
|
1029
|
+
element.textContent = node.text;
|
|
1030
|
+
if (node.tone === "secondary") element.setAttribute("muted", "");
|
|
1031
|
+
} else if (node.type === "divider") element = doc.createElement("s24-divider");
|
|
1032
|
+
else {
|
|
1033
|
+
element = doc.createElement(node.type === "select" ? "s24-select" : node.type === "toggle" ? "s24-switch" : node.multiline ? "s24-textarea" : "s24-input");
|
|
1034
|
+
for (const attr of ["label", "description", "placeholder"]) if (node[attr]) element.setAttribute(attr, node[attr]);
|
|
1035
|
+
for (const attr of ["disabled", "required"]) if (node[attr]) element.setAttribute(attr, "");
|
|
1036
|
+
if (node.maxLength) element.setAttribute("maxlength", String(node.maxLength));
|
|
1037
|
+
if (node.type === "select") element.options = node.options;
|
|
1038
|
+
if (node.type === "toggle") element.checked = this._values[node.name];
|
|
1039
|
+
else element.value = this._values[node.name];
|
|
1040
|
+
element.dataset.sheetField = node.name;
|
|
1041
|
+
element.addEventListener(node.type === "input" ? "s24-input" : "s24-change", (event) => {
|
|
1042
|
+
this._values[node.name] = node.type === "toggle" ? event.detail.checked : event.detail.value;
|
|
1043
|
+
element.removeAttribute("error");
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
parent.append(element);
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
const stack = doc.createElement("s24-stack");
|
|
1050
|
+
render(definition.content, stack);
|
|
1051
|
+
this.dialog.append(stack);
|
|
1052
|
+
for (const action of definition.actions) {
|
|
1053
|
+
const button = doc.createElement("s24-button");
|
|
1054
|
+
button.slot = "footer";
|
|
1055
|
+
button.textContent = action.label;
|
|
1056
|
+
button.setAttribute("variant", action.primary ? "primary" : "secondary");
|
|
1057
|
+
button.addEventListener("click", () => {
|
|
1058
|
+
if (action.kind === "cancel") {
|
|
1059
|
+
this.close();
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
if (action.kind === "reset") {
|
|
1063
|
+
for (const field of this._fields) this._values[field.name] = field.disabled ? field.value ?? (field.type === "toggle" ? false : "") : definition.resetValues?.[field.name] ?? field.value ?? (field.type === "toggle" ? false : "");
|
|
1064
|
+
this._renderWeb();
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
let valid = true;
|
|
1068
|
+
for (const field of this._fields) if (field.required && !String(this._values[field.name] ?? "").trim()) {
|
|
1069
|
+
[...this.dialog.querySelectorAll("[data-sheet-field]")].find((el) => el.dataset.sheetField === field.name)?.setAttribute("error", "\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u043F\u043E\u043B\u0435");
|
|
1070
|
+
valid = false;
|
|
1071
|
+
}
|
|
1072
|
+
if (valid) this._finish({ supported: true, cancelled: false, action: action.id, values: { ...this._values } });
|
|
1073
|
+
});
|
|
1074
|
+
this.dialog.append(button);
|
|
1075
|
+
}
|
|
1076
|
+
this.dialog.showModal();
|
|
1077
|
+
}
|
|
1078
|
+
_finish(result) {
|
|
1079
|
+
if (!this._resolve || this._settled) return;
|
|
1080
|
+
this._settled = true;
|
|
1081
|
+
const resolve = this._resolve;
|
|
1082
|
+
this._resolve = null;
|
|
1083
|
+
this._native = null;
|
|
1084
|
+
this.dialog.close();
|
|
1085
|
+
if (!result.cancelled) this.event("s24-submit", result);
|
|
1086
|
+
this.event("s24-close", result);
|
|
1087
|
+
resolve(result);
|
|
1088
|
+
}
|
|
1089
|
+
close() {
|
|
1090
|
+
if (this._native) this._native.sdk.closeSheet?.(this._native.id).catch(() => {
|
|
1091
|
+
});
|
|
1092
|
+
if (this._resolve) this._finish({ supported: true, cancelled: true });
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
return { "s24-sheet": Sheet };
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// src/widget-styles.js
|
|
1099
|
+
var widgetStyles = `
|
|
1100
|
+
:host(:not([data-mobile=true])) .employee-chips>[data-add]{display:none}
|
|
1101
|
+
|
|
1102
|
+
.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)}
|
|
1103
|
+
|
|
1104
|
+
: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}
|
|
1105
|
+
.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}
|
|
1106
|
+
.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)}
|
|
1107
|
+
.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)}
|
|
1108
|
+
.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}
|
|
1109
|
+
: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)}
|
|
1110
|
+
: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%}
|
|
1111
|
+
:host([data-mobile=true]) .attachments{padding:0;background:transparent;border:0}
|
|
1112
|
+
:host([data-mobile=true]) .attachments-head{padding:0;margin-bottom:calc(12px * var(--s24-native-icon-scale))}
|
|
1113
|
+
:host([data-mobile=true]) .attachments-head .widget-label{margin:0;font-size:var(--s24-type-body-size)}
|
|
1114
|
+
:host([data-mobile=true]) .attachment-empty{display:none}
|
|
1115
|
+
: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}
|
|
1116
|
+
:host([data-mobile=true]) .attachments[data-kind=photo][data-empty=true]{flex-direction:column;padding-block:calc(12px * var(--s24-native-icon-scale))}
|
|
1117
|
+
: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}
|
|
1118
|
+
: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)}
|
|
1119
|
+
:host([data-mobile=true]) .photo-symbol svg{width:calc(30px * var(--s24-native-icon-scale));height:calc(30px * var(--s24-native-icon-scale))}
|
|
1120
|
+
:host([data-mobile=true]) .attachments[data-kind=photo]:not([data-empty=true]) .photo-add>span:last-child{display:none}
|
|
1121
|
+
: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}
|
|
1122
|
+
: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))}
|
|
1123
|
+
:host([data-mobile=true]) .attachments[data-kind=photo] .attachment-item s24-circle-button{top:0;right:0;--s24-circle-small-size:24px}
|
|
1124
|
+
: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}
|
|
1125
|
+
: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)}
|
|
1126
|
+
:host([data-mobile=true]) .voice-start svg{width:calc(30px * var(--s24-native-icon-scale));height:calc(30px * var(--s24-native-icon-scale))}
|
|
1127
|
+
:host([data-mobile=true]) .voice-hint{font-size:var(--s24-type-body-size)}
|
|
1128
|
+
:host([data-mobile=true]) .employee-head{margin-bottom:12px}
|
|
1129
|
+
:host([data-mobile=true]) .employee-summary,:host([data-mobile=true]) .employee-web-add{display:none}
|
|
1130
|
+
:host([data-mobile=true]) .employee-head .widget-label{margin:0}
|
|
1131
|
+
:host([data-mobile=true]) .employee-chips{gap:0;flex-wrap:nowrap}
|
|
1132
|
+
:host([data-mobile=true]) .employee-chip{border:0;padding:0;min-height:0;background:transparent;gap:6px;cursor:pointer}
|
|
1133
|
+
: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}
|
|
1134
|
+
:host([data-mobile=true]) .employee-copy small{display:none}
|
|
1135
|
+
:host([data-mobile=true]) .employee-chip+.employee-chip{margin-left:calc(-15px * var(--s24-native-icon-scale))}
|
|
1136
|
+
:host([data-mobile=true]) .employee-chips>[data-add]{margin-left:calc(12px * var(--s24-native-icon-scale))}
|
|
1137
|
+
:host([data-mobile=true]) .employee-chips>[data-add]:first-child{margin-left:0}
|
|
1138
|
+
: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)}
|
|
1139
|
+
`;
|
|
1140
|
+
var recorderStyles = `
|
|
1141
|
+
:host(:not([data-mobile=true])) .attachments-head .widget-label{font-size:20px;line-height:26px}
|
|
1142
|
+
.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}
|
|
1143
|
+
:host(:not([data-mobile=true])) .voice-play{width:42px;height:42px;border-radius:12px}
|
|
1144
|
+
: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)}
|
|
1145
|
+
.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)}
|
|
1146
|
+
:host([data-mobile=true]) .voice-delete{width:32px;height:32px;min-height:0;border:0;background:transparent}
|
|
1147
|
+
|
|
1148
|
+
.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}
|
|
1149
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .widget-description{display:none}
|
|
1150
|
+
: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}
|
|
1151
|
+
: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}
|
|
1152
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachments-list[data-single=true]{border-radius:50px}
|
|
1153
|
+
: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}
|
|
1154
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-item+.attachment-item{border-top:1px solid var(--s24-border)}
|
|
1155
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-preview{width:38px;height:38px;border-radius:50%;color:white}
|
|
1156
|
+
:host([data-mobile=true]) .attachment-format{text-transform:none;font-size:var(--s24-type-caption-size)}
|
|
1157
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-meta strong{font-weight:400;font-size:var(--s24-type-callout-size)}
|
|
1158
|
+
:host([data-mobile=true]) .attachments[data-kind=file] .attachment-meta small{display:none}
|
|
1159
|
+
.attachment-remove{padding:0;min-height:32px;width:32px;border:0;background:transparent;color:var(--s24-error)}
|
|
1160
|
+
|
|
1161
|
+
:host(:not([data-mobile=true])) .attachments{position:relative}
|
|
1162
|
+
:host(:not([data-mobile=true])) .attachments-head{padding-right:132px;min-height:42px}
|
|
1163
|
+
:host(:not([data-mobile=true])) .attachments-head .file-add,:host(:not([data-mobile=true])) .photo-add{display:none}
|
|
1164
|
+
.attachment-web-add{position:absolute;right:16px;top:16px}
|
|
1165
|
+
:host([data-mobile=true]) .attachment-web-add{display:none}
|
|
1166
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo]:not([data-empty=true]) .attachments-list{grid-template-columns:1fr;margin:14px 0 0}
|
|
1167
|
+
: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}
|
|
1168
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-preview{width:48px;height:48px;border-radius:var(--s24-item-radius)}
|
|
1169
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-meta{display:block}
|
|
1170
|
+
:host(:not([data-mobile=true])) .attachments[data-kind=photo] .attachment-item s24-circle-button{position:static;background:transparent}
|
|
1171
|
+
.voice-widget{padding:16px;background:var(--s24-surface);border:1px solid var(--s24-border);border-radius:24px}
|
|
1172
|
+
.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}
|
|
1173
|
+
.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)}
|
|
1174
|
+
.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)}
|
|
1175
|
+
.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}
|
|
1176
|
+
:host([data-mobile=true]) .voice-widget{padding:0;border:0;background:transparent;border-radius:100px}
|
|
1177
|
+
:host([data-mobile=true]) .voice-description,:host([data-mobile=true]) .voice-web-record{display:none}
|
|
1178
|
+
:host([data-mobile=true]) .voice-head{margin-bottom:12px}
|
|
1179
|
+
:host([data-mobile=true]) .voice-rail{display:block;padding:5px;min-height:0;border-radius:100px;background:var(--s24-island-bg)}
|
|
1180
|
+
.voice-track{position:relative;height:calc(50px * var(--s24-native-icon-scale));border-radius:100px;background:var(--s24-background);overflow:hidden}
|
|
1181
|
+
.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)}
|
|
1182
|
+
: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)}
|
|
1183
|
+
.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}
|
|
1184
|
+
.voice-live{position:absolute;left:16px;top:14px;color:var(--s24-error);font-size:var(--s24-type-body-size)}
|
|
1185
|
+
: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)}
|
|
1186
|
+
:host([data-mobile=true]) .voice-play{width:38px;height:38px;min-height:0;border:0;background:transparent;color:var(--s24-muted);border-radius:50%}
|
|
1187
|
+
: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)}
|
|
1188
|
+
:host([data-mobile=true]) .voice-main{flex:1;margin-inline:12px;display:flex;align-items:center;gap:12px}.voice-main .voice-bars{flex:1}
|
|
1189
|
+
: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)}
|
|
1190
|
+
:host([data-mobile=true]) .voice-time{min-width:56px;margin:0;font-size:var(--s24-type-callout-size)}
|
|
1191
|
+
:host(:not([data-mobile=true])) .voice-play{width:42px;height:42px;border-radius:12px}
|
|
1192
|
+
: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)}
|
|
1193
|
+
`;
|
|
1194
|
+
|
|
1195
|
+
// src/widget-components.js
|
|
1196
|
+
var localSequence = 0;
|
|
1197
|
+
var attachmentID = () => globalThis.crypto?.randomUUID?.() || `attachment-${Date.now()}-${++localSequence}`;
|
|
1198
|
+
var positiveIDs = (value) => [
|
|
1199
|
+
...new Set(
|
|
1200
|
+
(Array.isArray(value) ? value : []).filter(
|
|
1201
|
+
(id) => Number.isSafeInteger(id) && id > 0
|
|
1202
|
+
)
|
|
1203
|
+
)
|
|
1204
|
+
];
|
|
1205
|
+
var limit = (element, name, fallback) => {
|
|
1206
|
+
const n = Number(element.getAttribute(name));
|
|
1207
|
+
return Number.isSafeInteger(n) && n > 0 ? n : fallback;
|
|
1208
|
+
};
|
|
1209
|
+
var safeURL = (value) => typeof value === "string" && /^(https?:\/\/|blob:|data:image\/(png|jpeg|webp|gif);base64,)/i.test(value) ? value : "";
|
|
1210
|
+
var copy = (value) => ({ ...value });
|
|
1211
|
+
function widgetComponents({ Component, contextFor: contextFor2, mobile, coreSVG: coreSVG2 }) {
|
|
1212
|
+
class Widget extends Component {
|
|
1213
|
+
static observedAttributes = [
|
|
1214
|
+
"disabled",
|
|
1215
|
+
"label",
|
|
1216
|
+
"description",
|
|
1217
|
+
"error",
|
|
1218
|
+
"max",
|
|
1219
|
+
"max-size"
|
|
1220
|
+
];
|
|
1221
|
+
constructor(template) {
|
|
1222
|
+
super(
|
|
1223
|
+
`<style>${widgetStyles}${recorderStyles}</style>${template}<p class="widget-error" role="alert" hidden></p>`
|
|
1224
|
+
);
|
|
1225
|
+
this.busy = false;
|
|
1226
|
+
this.generation = 0;
|
|
1227
|
+
}
|
|
1228
|
+
_applyPlatform(runtime) {
|
|
1229
|
+
super._applyPlatform(runtime);
|
|
1230
|
+
this.dataset.mobile = String(runtime === "mobile");
|
|
1231
|
+
this.sync?.();
|
|
1232
|
+
}
|
|
1233
|
+
get disabled() {
|
|
1234
|
+
return this.hasAttribute("disabled");
|
|
1235
|
+
}
|
|
1236
|
+
set disabled(value) {
|
|
1237
|
+
this.toggleAttribute("disabled", !!value);
|
|
1238
|
+
}
|
|
1239
|
+
get sdk() {
|
|
1240
|
+
return contextFor2(this)?.sdk;
|
|
1241
|
+
}
|
|
1242
|
+
connectedCallback() {
|
|
1243
|
+
this.sync();
|
|
1244
|
+
}
|
|
1245
|
+
disconnectedCallback() {
|
|
1246
|
+
this.generation++;
|
|
1247
|
+
}
|
|
1248
|
+
attributeChangedCallback() {
|
|
1249
|
+
this.sync();
|
|
1250
|
+
}
|
|
1251
|
+
clearError() {
|
|
1252
|
+
this.text(".widget-error", this.getAttribute("error"));
|
|
1253
|
+
this.shadowRoot.querySelector(".widget-error").hidden = !this.getAttribute("error");
|
|
1254
|
+
}
|
|
1255
|
+
fail(error) {
|
|
1256
|
+
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";
|
|
1257
|
+
this.text(".widget-error", message);
|
|
1258
|
+
this.shadowRoot.querySelector(".widget-error").hidden = false;
|
|
1259
|
+
this.event("s24-error", { message });
|
|
1260
|
+
}
|
|
1261
|
+
async run(action) {
|
|
1262
|
+
if (this.busy || this.disabled) return;
|
|
1263
|
+
this.busy = true;
|
|
1264
|
+
this.clearError();
|
|
1265
|
+
const generation = this.generation;
|
|
1266
|
+
this.sync();
|
|
1267
|
+
this.event("s24-busy", { busy: true });
|
|
1268
|
+
try {
|
|
1269
|
+
await action(
|
|
1270
|
+
() => this.isConnected && generation === this.generation && !this.disabled
|
|
1271
|
+
);
|
|
1272
|
+
} catch (error) {
|
|
1273
|
+
if (this.isConnected && generation === this.generation)
|
|
1274
|
+
this.fail(error);
|
|
1275
|
+
} finally {
|
|
1276
|
+
this.busy = false;
|
|
1277
|
+
if (this.isConnected) {
|
|
1278
|
+
this.sync();
|
|
1279
|
+
this.event("s24-busy", { busy: false });
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
labels() {
|
|
1284
|
+
const heading = this.shadowRoot.querySelector(".widget-label");
|
|
1285
|
+
if (heading) {
|
|
1286
|
+
heading.textContent = this.getAttribute("label") || this.defaultLabel;
|
|
1287
|
+
heading.hidden = !heading.textContent;
|
|
1288
|
+
}
|
|
1289
|
+
const desc = this.shadowRoot.querySelector(".widget-description");
|
|
1290
|
+
if (desc) {
|
|
1291
|
+
desc.textContent = this.getAttribute("description") || "";
|
|
1292
|
+
desc.hidden = !desc.textContent;
|
|
1293
|
+
}
|
|
1294
|
+
this.setAttribute("aria-busy", String(this.busy));
|
|
1295
|
+
for (const b of this.shadowRoot.querySelectorAll(
|
|
1296
|
+
"button,s24-circle-button"
|
|
1297
|
+
))
|
|
1298
|
+
b.disabled = this.busy || this.disabled;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
class Employees extends Widget {
|
|
1302
|
+
constructor() {
|
|
1303
|
+
super(
|
|
1304
|
+
`<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>`
|
|
1305
|
+
);
|
|
1306
|
+
this._value = [];
|
|
1307
|
+
this._employees = [];
|
|
1308
|
+
this.defaultLabel = "\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u0438";
|
|
1309
|
+
this.shadowRoot.querySelector(".employee-web-add").addEventListener("click", () => void this.open());
|
|
1310
|
+
this.shadowRoot.querySelector(".employee-chips").addEventListener("click", (e) => {
|
|
1311
|
+
const remove = e.target.closest("[data-remove]");
|
|
1312
|
+
if (remove && !this.busy && !this.disabled) {
|
|
1313
|
+
this.value = this.value.filter(
|
|
1314
|
+
(id) => id !== Number(remove.dataset.remove)
|
|
1315
|
+
);
|
|
1316
|
+
this.changed();
|
|
1317
|
+
} else if (e.target.closest("[data-add]") || e.target.closest(".employee-chip"))
|
|
1318
|
+
void this.open();
|
|
1319
|
+
});
|
|
1320
|
+
this.shadowRoot.querySelector("s24-search").addEventListener("s24-input", (e) => {
|
|
1321
|
+
e.stopPropagation();
|
|
1322
|
+
this.options();
|
|
1323
|
+
});
|
|
1324
|
+
this.shadowRoot.querySelector("s24-dialog s24-button").addEventListener("click", () => {
|
|
1325
|
+
if (this.disabled) return;
|
|
1326
|
+
this.value = this.draft;
|
|
1327
|
+
this.shadowRoot.querySelector("s24-dialog").close();
|
|
1328
|
+
this.changed();
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
get value() {
|
|
1332
|
+
return [...this._value];
|
|
1333
|
+
}
|
|
1334
|
+
set value(value) {
|
|
1335
|
+
this._value = positiveIDs(value);
|
|
1336
|
+
this.sync();
|
|
1337
|
+
}
|
|
1338
|
+
get employees() {
|
|
1339
|
+
return this._employees.map(copy);
|
|
1340
|
+
}
|
|
1341
|
+
set employees(value) {
|
|
1342
|
+
this._employees = (Array.isArray(value) ? value : []).filter((p) => Number.isSafeInteger(p.profile_id) && p.profile_id > 0).map(copy);
|
|
1343
|
+
this.sync();
|
|
1344
|
+
}
|
|
1345
|
+
changed() {
|
|
1346
|
+
this.event("s24-change", {
|
|
1347
|
+
value: this.value,
|
|
1348
|
+
employees: this.employees.filter(
|
|
1349
|
+
(p) => this._value.includes(p.profile_id)
|
|
1350
|
+
)
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
sync() {
|
|
1354
|
+
if (!this.shadowRoot || !this._value) return;
|
|
1355
|
+
this.labels();
|
|
1356
|
+
this.shadowRoot.querySelector(".employee-web-add").disabled = this.disabled || this.busy;
|
|
1357
|
+
const chips = this.shadowRoot.querySelector(".employee-chips");
|
|
1358
|
+
chips.replaceChildren();
|
|
1359
|
+
const native = mobile(this);
|
|
1360
|
+
this.shadowRoot.querySelector(".widget-label").textContent = native ? `${this.getAttribute("label") || this.defaultLabel} (${this._value.length})` : this.getAttribute("label") || this.defaultLabel;
|
|
1361
|
+
this.text(
|
|
1362
|
+
".employee-summary",
|
|
1363
|
+
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"
|
|
1364
|
+
);
|
|
1365
|
+
this.shadowRoot.querySelector(".employee-empty").hidden = native || !!this._value.length;
|
|
1366
|
+
for (const [index, id] of this._value.entries()) {
|
|
1367
|
+
if (native && index >= 5) break;
|
|
1368
|
+
const person = this._employees.find((p) => p.profile_id === id);
|
|
1369
|
+
const chip = document.createElement("span");
|
|
1370
|
+
chip.className = "employee-chip";
|
|
1371
|
+
if (native) {
|
|
1372
|
+
chip.setAttribute("role", "button");
|
|
1373
|
+
chip.tabIndex = this.disabled || this.busy ? -1 : 0;
|
|
1374
|
+
chip.addEventListener("keydown", (e) => {
|
|
1375
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1376
|
+
e.preventDefault();
|
|
1377
|
+
void this.open();
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
const avatar = document.createElement("span");
|
|
1382
|
+
avatar.className = "employee-avatar";
|
|
1383
|
+
const name = person?.name || `\u0421\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A \u2116 ${id}`;
|
|
1384
|
+
chip.setAttribute("aria-label", name);
|
|
1385
|
+
avatar.textContent = name.split(/\s+/).slice(0, 2).map((s) => s[0] || "").join("");
|
|
1386
|
+
const url = safeURL(person?.avatar);
|
|
1387
|
+
if (url) {
|
|
1388
|
+
const img = document.createElement("img");
|
|
1389
|
+
img.src = url;
|
|
1390
|
+
img.alt = "";
|
|
1391
|
+
avatar.replaceChildren(img);
|
|
1392
|
+
}
|
|
1393
|
+
const text2 = document.createElement("span");
|
|
1394
|
+
text2.className = "employee-copy";
|
|
1395
|
+
const title = document.createElement("strong");
|
|
1396
|
+
const parts = name.split(/\s+/);
|
|
1397
|
+
title.textContent = native && this._value.length === 1 && parts.length >= 2 ? `${parts[0]} ${parts.slice(1, 3).map((p) => p[0] + ".").join("")}` : name;
|
|
1398
|
+
const position = document.createElement("small");
|
|
1399
|
+
position.textContent = person?.position || "";
|
|
1400
|
+
text2.append(title, position);
|
|
1401
|
+
if (native && this._value.length !== 1) text2.hidden = true;
|
|
1402
|
+
chip.append(avatar, text2);
|
|
1403
|
+
chips.append(chip);
|
|
1404
|
+
}
|
|
1405
|
+
if (native && this._value.length > 5) {
|
|
1406
|
+
const count = document.createElement("span");
|
|
1407
|
+
count.className = "employee-overflow";
|
|
1408
|
+
count.textContent = `+${this._value.length - 5}`;
|
|
1409
|
+
chips.append(count);
|
|
1410
|
+
}
|
|
1411
|
+
const button = document.createElement("s24-circle-button");
|
|
1412
|
+
button.setAttribute("icon", "add");
|
|
1413
|
+
button.setAttribute("size", "medium");
|
|
1414
|
+
button.setAttribute("label", "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A\u043E\u0432");
|
|
1415
|
+
button.dataset.add = "";
|
|
1416
|
+
button.disabled = this.disabled || this.busy;
|
|
1417
|
+
chips.append(button);
|
|
1418
|
+
}
|
|
1419
|
+
options() {
|
|
1420
|
+
const root = this.shadowRoot.querySelector(".employee-options");
|
|
1421
|
+
root.replaceChildren();
|
|
1422
|
+
const query = this.shadowRoot.querySelector("s24-search").value.toLocaleLowerCase();
|
|
1423
|
+
const people = this._employees.filter(
|
|
1424
|
+
(p) => `${p.name} ${p.position || ""}`.toLocaleLowerCase().includes(query)
|
|
1425
|
+
);
|
|
1426
|
+
for (const person of people) {
|
|
1427
|
+
const row = document.createElement("s24-checkbox");
|
|
1428
|
+
row.setAttribute("label", person.name);
|
|
1429
|
+
row.textContent = person.name;
|
|
1430
|
+
row.setAttribute("description", person.position || "");
|
|
1431
|
+
row.checked = this.draft.includes(person.profile_id);
|
|
1432
|
+
row.disabled = this.disabled || !row.checked && this.draft.length >= limit(this, "max", 500);
|
|
1433
|
+
row.addEventListener("s24-change", (e) => {
|
|
1434
|
+
e.stopPropagation();
|
|
1435
|
+
this.draft = e.detail.checked ? positiveIDs([...this.draft, person.profile_id]) : this.draft.filter((id) => id !== person.profile_id);
|
|
1436
|
+
this.options();
|
|
1437
|
+
});
|
|
1438
|
+
root.append(row);
|
|
1439
|
+
}
|
|
1440
|
+
if (!people.length) {
|
|
1441
|
+
const p = document.createElement("p");
|
|
1442
|
+
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.";
|
|
1443
|
+
root.append(p);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
async open() {
|
|
1447
|
+
return this.run(async (active) => {
|
|
1448
|
+
if (this.sdk?.selectEmployees) {
|
|
1449
|
+
const result = await this.sdk.selectEmployees({
|
|
1450
|
+
profile_ids: this.value,
|
|
1451
|
+
all_users: !this.hasAttribute("subordinates-only"),
|
|
1452
|
+
max_selected: limit(this, "max", 500)
|
|
1453
|
+
});
|
|
1454
|
+
if (result?.supported !== false) {
|
|
1455
|
+
if (active() && !result?.cancelled) {
|
|
1456
|
+
const ids = positiveIDs(result.profile_ids);
|
|
1457
|
+
if (ids.length > limit(this, "max", 500))
|
|
1458
|
+
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");
|
|
1459
|
+
if (result.employees) {
|
|
1460
|
+
const byID = new Map(
|
|
1461
|
+
this._employees.map((p) => [p.profile_id, p])
|
|
1462
|
+
);
|
|
1463
|
+
for (const p of result.employees) byID.set(p.profile_id, p);
|
|
1464
|
+
this.employees = [...byID.values()];
|
|
1465
|
+
}
|
|
1466
|
+
this.value = ids;
|
|
1467
|
+
this.changed();
|
|
1468
|
+
}
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
} else if (mobile(this) && this.sdk?.selectEmployeeProfiles) {
|
|
1472
|
+
const result = await this.sdk.selectEmployeeProfiles({
|
|
1473
|
+
profile_ids: this.value,
|
|
1474
|
+
all_users: !this.hasAttribute("subordinates-only")
|
|
1475
|
+
});
|
|
1476
|
+
if (active() && !result?.cancelled && Array.isArray(result?.profile_ids)) {
|
|
1477
|
+
this.value = result.profile_ids;
|
|
1478
|
+
this.changed();
|
|
1479
|
+
}
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
if (active()) {
|
|
1483
|
+
this.draft = this.value;
|
|
1484
|
+
this.options();
|
|
1485
|
+
this.shadowRoot.querySelector("s24-dialog").showModal();
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
class Attachments extends Widget {
|
|
1491
|
+
constructor(kind = "file") {
|
|
1492
|
+
super(
|
|
1493
|
+
`<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>`
|
|
1494
|
+
);
|
|
1495
|
+
this.kind = kind;
|
|
1496
|
+
this._value = [];
|
|
1497
|
+
this.urls = /* @__PURE__ */ new Set();
|
|
1498
|
+
this.defaultLabel = kind === "photo" ? "" : "\u041F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u0435\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B";
|
|
1499
|
+
this.shadowRoot.querySelector(".attachment-web-add").addEventListener("click", () => void this.add());
|
|
1500
|
+
this.shadowRoot.querySelector(".file-add").addEventListener("click", () => void this.add());
|
|
1501
|
+
this.shadowRoot.querySelector(".photo-add").addEventListener("click", () => void this.add());
|
|
1502
|
+
this.input = this.shadowRoot.querySelector("input");
|
|
1503
|
+
this.input.accept = kind === "photo" ? "image/*" : "";
|
|
1504
|
+
this.input.multiple = true;
|
|
1505
|
+
this.input.addEventListener("change", () => {
|
|
1506
|
+
const files = [...this.input.files || []];
|
|
1507
|
+
this.input.value = "";
|
|
1508
|
+
void this.run(async (active) => {
|
|
1509
|
+
const next = [];
|
|
1510
|
+
for (const file of files) next.push(await this.localFile(file));
|
|
1511
|
+
if (active()) this.append(next);
|
|
1512
|
+
});
|
|
1513
|
+
});
|
|
1514
|
+
this.shadowRoot.querySelector(".attachments-list").addEventListener("click", (e) => {
|
|
1515
|
+
const b = e.target.closest("[data-remove]");
|
|
1516
|
+
if (b && !this.disabled && !this.busy) {
|
|
1517
|
+
this.value = this._value.filter(
|
|
1518
|
+
(_, i) => i !== Number(b.dataset.remove)
|
|
1519
|
+
);
|
|
1520
|
+
this.changed();
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
get value() {
|
|
1525
|
+
return this._value.map(copy);
|
|
1526
|
+
}
|
|
1527
|
+
set value(value) {
|
|
1528
|
+
this._value = Array.isArray(value) ? value.map(copy) : [];
|
|
1529
|
+
this.sync();
|
|
1530
|
+
}
|
|
1531
|
+
disconnectedCallback() {
|
|
1532
|
+
super.disconnectedCallback();
|
|
1533
|
+
for (const url of this.urls) URL.revokeObjectURL(url);
|
|
1534
|
+
this.urls.clear();
|
|
1535
|
+
}
|
|
1536
|
+
async localFile(file) {
|
|
1537
|
+
if (file.size > limit(this, "max-size", 30 * 1024 * 1024))
|
|
1538
|
+
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");
|
|
1539
|
+
if (this.kind === "photo" && !/^image\//.test(file.type))
|
|
1540
|
+
throw new Error("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435");
|
|
1541
|
+
if (this.upload) return this.upload(file);
|
|
1542
|
+
const url = URL.createObjectURL(file);
|
|
1543
|
+
this.urls.add(url);
|
|
1544
|
+
return {
|
|
1545
|
+
id: attachmentID(),
|
|
1546
|
+
name: file.name,
|
|
1547
|
+
size: file.size,
|
|
1548
|
+
type: file.type,
|
|
1549
|
+
localFile: file,
|
|
1550
|
+
url
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
append(items) {
|
|
1554
|
+
if (this._value.length + items.length > limit(this, "max", this.kind === "photo" ? 20 : 50))
|
|
1555
|
+
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");
|
|
1556
|
+
for (const item of items)
|
|
1557
|
+
if (item.size > limit(this, "max-size", 30 * 1024 * 1024))
|
|
1558
|
+
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");
|
|
1559
|
+
this.value = [...this._value, ...items];
|
|
1560
|
+
this.changed();
|
|
1561
|
+
}
|
|
1562
|
+
changed() {
|
|
1563
|
+
this.event("s24-change", { value: this.value });
|
|
1564
|
+
}
|
|
1565
|
+
sync() {
|
|
1566
|
+
if (!this._value || !this.kind) return;
|
|
1567
|
+
this.labels();
|
|
1568
|
+
const photo = this.kind === "photo";
|
|
1569
|
+
const root = this.shadowRoot.querySelector(".attachments");
|
|
1570
|
+
root.dataset.kind = this.kind;
|
|
1571
|
+
root.dataset.empty = String(!this._value.length);
|
|
1572
|
+
this.shadowRoot.querySelector(".attachments-head").hidden = mobile(this) && photo && !this.getAttribute("label");
|
|
1573
|
+
if (photo && !mobile(this))
|
|
1574
|
+
this.text(
|
|
1575
|
+
".attachments-head .widget-label",
|
|
1576
|
+
this.getAttribute("label") || "\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u0438"
|
|
1577
|
+
);
|
|
1578
|
+
this.shadowRoot.querySelector(".file-add").hidden = photo;
|
|
1579
|
+
this.shadowRoot.querySelector(".photo-add").hidden = !photo;
|
|
1580
|
+
this.shadowRoot.querySelector(".attachment-empty").hidden = mobile(this) && photo || !!this._value.length;
|
|
1581
|
+
const full = this._value.length >= limit(this, "max", photo ? 20 : 50);
|
|
1582
|
+
this.shadowRoot.querySelector(".photo-add").disabled = this.disabled || this.busy || full;
|
|
1583
|
+
this.shadowRoot.querySelector(".file-add").disabled = this.disabled || this.busy || full;
|
|
1584
|
+
this.shadowRoot.querySelector(".attachment-web-add").disabled = this.disabled || this.busy || full;
|
|
1585
|
+
const list = this.shadowRoot.querySelector(".attachments-list");
|
|
1586
|
+
list.replaceChildren();
|
|
1587
|
+
list.dataset.single = String(this._value.length === 1);
|
|
1588
|
+
this.shadowRoot.querySelector(".file-add").setAttribute("icon", mobile(this) ? "add_circle" : "add");
|
|
1589
|
+
this.text(
|
|
1590
|
+
".attachment-help",
|
|
1591
|
+
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."
|
|
1592
|
+
);
|
|
1593
|
+
for (const [i, item] of this._value.entries()) {
|
|
1594
|
+
const row = document.createElement("div");
|
|
1595
|
+
row.className = "attachment-item";
|
|
1596
|
+
const preview = document.createElement(photo ? "img" : "span");
|
|
1597
|
+
preview.className = "attachment-preview";
|
|
1598
|
+
if (photo) {
|
|
1599
|
+
preview.src = safeURL(item.preview || item.url);
|
|
1600
|
+
preview.alt = item.name || "\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F";
|
|
1601
|
+
} else {
|
|
1602
|
+
const extension = (item.name || item.file || "").split(".").pop().toLowerCase().slice(0, 8);
|
|
1603
|
+
const format = document.createElement("span");
|
|
1604
|
+
format.className = "attachment-format";
|
|
1605
|
+
format.textContent = extension || "--";
|
|
1606
|
+
preview.append(format);
|
|
1607
|
+
if (mobile(this)) {
|
|
1608
|
+
const groups = [
|
|
1609
|
+
["png jpg jpeg svg gif tiff raw bmp", "#ffb703"],
|
|
1610
|
+
["pdf", "#e63946"],
|
|
1611
|
+
["xlsx xlsm xlsb xltx xls csv", "#52b788"],
|
|
1612
|
+
["mp3 aac ogg wav wma flac alac aiff", "#fb8b24"],
|
|
1613
|
+
["mp4 mov avi mkv wmv", "#ef476f"],
|
|
1614
|
+
["docs doc docx dotx dot rtf txt odt", "#3a86ff"],
|
|
1615
|
+
["xml json css html", "#fb5607"],
|
|
1616
|
+
["zip rar 7z tar", "#00b4d8"]
|
|
1617
|
+
];
|
|
1618
|
+
preview.style.background = groups.find(
|
|
1619
|
+
([keys]) => keys.split(" ").includes(extension)
|
|
1620
|
+
)?.[1] || "var(--s24-muted)";
|
|
1621
|
+
} else {
|
|
1622
|
+
const icon = document.createElement("s24-icon");
|
|
1623
|
+
icon.setAttribute("name", "description");
|
|
1624
|
+
icon.setAttribute("size", "16");
|
|
1625
|
+
preview.prepend(icon);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
const meta = document.createElement("div");
|
|
1629
|
+
meta.className = "attachment-meta";
|
|
1630
|
+
const name = document.createElement("strong");
|
|
1631
|
+
name.textContent = item.name || item.file || "\u0412\u043B\u043E\u0436\u0435\u043D\u0438\u0435";
|
|
1632
|
+
const size = document.createElement("small");
|
|
1633
|
+
size.textContent = item.size ? `${(item.size / 1048576).toFixed(1)} \u041C\u0411` : item.file ? "\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043D" : "";
|
|
1634
|
+
meta.append(name, size);
|
|
1635
|
+
const remove = document.createElement(
|
|
1636
|
+
!photo && mobile(this) ? "button" : "s24-circle-button"
|
|
1637
|
+
);
|
|
1638
|
+
if (!photo && mobile(this)) {
|
|
1639
|
+
remove.type = "button";
|
|
1640
|
+
remove.className = "attachment-remove";
|
|
1641
|
+
remove.innerHTML = '<s24-icon name="delete" size="32"></s24-icon>';
|
|
1642
|
+
remove.setAttribute("aria-label", `\u0423\u0434\u0430\u043B\u0438\u0442\u044C ${name.textContent}`);
|
|
1643
|
+
}
|
|
1644
|
+
remove.setAttribute("icon", "delete");
|
|
1645
|
+
remove.setAttribute("label", `\u0423\u0434\u0430\u043B\u0438\u0442\u044C ${name.textContent}`);
|
|
1646
|
+
remove.setAttribute("size", "small");
|
|
1647
|
+
remove.dataset.remove = String(i);
|
|
1648
|
+
remove.disabled = this.disabled || this.busy;
|
|
1649
|
+
row.append(preview, meta, remove);
|
|
1650
|
+
list.append(row);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
async add() {
|
|
1654
|
+
return this.run(async (active) => {
|
|
1655
|
+
const method = this.kind === "photo" ? "capturePhoto" : "attachFiles";
|
|
1656
|
+
if (this.sdk?.[method]) {
|
|
1657
|
+
const result = await this.sdk[method]({
|
|
1658
|
+
max_files: Math.max(
|
|
1659
|
+
1,
|
|
1660
|
+
limit(this, "max", this.kind === "photo" ? 20 : 50) - this._value.length
|
|
1661
|
+
),
|
|
1662
|
+
max_size: limit(this, "max-size", 30 * 1024 * 1024)
|
|
1663
|
+
});
|
|
1664
|
+
if (result?.supported !== false) {
|
|
1665
|
+
if (active() && !result?.cancelled) this.append(result.items || []);
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (mobile(this) && this.sdk?.[this.kind === "photo" ? "takePhoto" : "pickFile"]) {
|
|
1670
|
+
const result = await this.sdk[this.kind === "photo" ? "takePhoto" : "pickFile"]({ upload: true });
|
|
1671
|
+
if (result?.supported !== false) {
|
|
1672
|
+
if (active() && !result?.cancelled && result?.file)
|
|
1673
|
+
this.append([
|
|
1674
|
+
{
|
|
1675
|
+
...result,
|
|
1676
|
+
preview: result.base64 ? `data:${result.type || "image/jpeg"};base64,${result.base64}` : void 0
|
|
1677
|
+
}
|
|
1678
|
+
]);
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
if (active()) this.input.click();
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
class Photos extends Attachments {
|
|
1687
|
+
constructor() {
|
|
1688
|
+
super("photo");
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
class Voice extends Attachments {
|
|
1692
|
+
constructor() {
|
|
1693
|
+
super("voice");
|
|
1694
|
+
this.defaultLabel = "\u0413\u043E\u043B\u043E\u0441\u043E\u0432\u043E\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435";
|
|
1695
|
+
this.shadowRoot.querySelector(".attachments").hidden = true;
|
|
1696
|
+
const wrap = document.createElement("section");
|
|
1697
|
+
wrap.className = "voice-widget";
|
|
1698
|
+
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>`;
|
|
1699
|
+
this.shadowRoot.insertBefore(
|
|
1700
|
+
wrap,
|
|
1701
|
+
this.shadowRoot.querySelector(".widget-error")
|
|
1702
|
+
);
|
|
1703
|
+
this.thumb = wrap.querySelector(".voice-start");
|
|
1704
|
+
this.thumb.addEventListener("pointerdown", (e) => {
|
|
1705
|
+
if (this.disabled || this.busy || this.value || this.recording) return;
|
|
1706
|
+
e.preventDefault();
|
|
1707
|
+
this.drag = { id: e.pointerId, start: e.clientX };
|
|
1708
|
+
this.thumb.setPointerCapture(e.pointerId);
|
|
1709
|
+
});
|
|
1710
|
+
this.thumb.addEventListener("pointermove", (e) => {
|
|
1711
|
+
if (!this.drag || e.pointerId !== this.drag.id) return;
|
|
1712
|
+
const track = wrap.querySelector(".voice-track");
|
|
1713
|
+
const max = Math.max(1, track.clientWidth - this.thumb.offsetWidth);
|
|
1714
|
+
const x = Math.max(0, Math.min(max, e.clientX - this.drag.start));
|
|
1715
|
+
this.thumb.style.transform = `translateX(${x}px)`;
|
|
1716
|
+
if (x >= max * 0.8 && !this.recording && !this.starting) {
|
|
1717
|
+
this.swiped = true;
|
|
1718
|
+
void this.record();
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
const release = () => {
|
|
1722
|
+
if (!this.drag) return;
|
|
1723
|
+
this.drag = null;
|
|
1724
|
+
this.thumb.style.transform = "";
|
|
1725
|
+
if (this.swiped) {
|
|
1726
|
+
this.swiped = false;
|
|
1727
|
+
this.stopRequested = true;
|
|
1728
|
+
void this.stop();
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
this.thumb.addEventListener("pointerup", release);
|
|
1732
|
+
this.thumb.addEventListener("pointercancel", release);
|
|
1733
|
+
this.thumb.addEventListener("lostpointercapture", release);
|
|
1734
|
+
this.thumb.addEventListener("keydown", (e) => {
|
|
1735
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1736
|
+
e.preventDefault();
|
|
1737
|
+
if (this.recording) void this.stop();
|
|
1738
|
+
else void this.record();
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
wrap.querySelector(".voice-web-record").addEventListener("click", () => {
|
|
1742
|
+
if (this.recording) void this.stop();
|
|
1743
|
+
else void this.record();
|
|
1744
|
+
});
|
|
1745
|
+
const audio = wrap.querySelector("audio");
|
|
1746
|
+
this.audio = audio;
|
|
1747
|
+
audio.addEventListener("timeupdate", () => this.updatePlayback());
|
|
1748
|
+
const wave = wrap.querySelector(".voice-bars");
|
|
1749
|
+
const seek = (e) => {
|
|
1750
|
+
if (!this.value || !Number.isFinite(audio.duration)) return;
|
|
1751
|
+
const box = wave.getBoundingClientRect();
|
|
1752
|
+
audio.currentTime = Math.max(0, Math.min(1, (e.clientX - box.left) / box.width)) * audio.duration;
|
|
1753
|
+
this.updatePlayback();
|
|
1754
|
+
};
|
|
1755
|
+
wave.addEventListener("pointerdown", (e) => {
|
|
1756
|
+
if (this.disabled) return;
|
|
1757
|
+
wave.setPointerCapture(e.pointerId);
|
|
1758
|
+
this.seeking = true;
|
|
1759
|
+
seek(e);
|
|
1760
|
+
});
|
|
1761
|
+
wave.addEventListener("pointermove", (e) => {
|
|
1762
|
+
if (this.seeking) seek(e);
|
|
1763
|
+
});
|
|
1764
|
+
wave.addEventListener("pointerup", () => {
|
|
1765
|
+
this.seeking = false;
|
|
1766
|
+
});
|
|
1767
|
+
wave.addEventListener("pointercancel", () => {
|
|
1768
|
+
this.seeking = false;
|
|
1769
|
+
});
|
|
1770
|
+
audio.addEventListener("ended", () => this.sync());
|
|
1771
|
+
audio.addEventListener("pause", () => this.sync());
|
|
1772
|
+
audio.addEventListener("play", () => this.sync());
|
|
1773
|
+
wrap.querySelector(".voice-play").addEventListener("click", () => {
|
|
1774
|
+
if (!this.value || this.recording) return;
|
|
1775
|
+
if (audio.paused) void audio.play().catch((e) => this.fail(e));
|
|
1776
|
+
else audio.pause();
|
|
1777
|
+
});
|
|
1778
|
+
wrap.querySelector(".voice-speed").addEventListener("click", () => {
|
|
1779
|
+
audio.playbackRate = audio.playbackRate >= 2 ? 1 : audio.playbackRate + 0.5;
|
|
1780
|
+
this.text(".voice-speed", `\xD7${audio.playbackRate}`);
|
|
1781
|
+
});
|
|
1782
|
+
wrap.querySelector(".voice-delete").addEventListener("click", () => {
|
|
1783
|
+
if (this.disabled || this.busy || this.recording) return;
|
|
1784
|
+
audio.pause();
|
|
1785
|
+
this.value = null;
|
|
1786
|
+
this.changed();
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
get value() {
|
|
1790
|
+
return this._value[0] ? copy(this._value[0]) : null;
|
|
1791
|
+
}
|
|
1792
|
+
set value(value) {
|
|
1793
|
+
this._value = value ? [copy(value)] : [];
|
|
1794
|
+
this.sync();
|
|
1795
|
+
}
|
|
1796
|
+
clock(ms) {
|
|
1797
|
+
const s = Math.max(0, Math.floor((ms || 0) / 1e3));
|
|
1798
|
+
return `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(
|
|
1799
|
+
s % 60
|
|
1800
|
+
).padStart(2, "0")}`;
|
|
1801
|
+
}
|
|
1802
|
+
updatePlayback() {
|
|
1803
|
+
const duration = this.value?.duration_ms || this.audio.duration * 1e3 || 0;
|
|
1804
|
+
const ratio = duration ? this.audio.currentTime * 1e3 / duration : 0;
|
|
1805
|
+
this.shadowRoot.querySelectorAll(".voice-bars i").forEach(
|
|
1806
|
+
(bar, i, all) => bar.dataset.played = String(i / all.length < ratio)
|
|
1807
|
+
);
|
|
1808
|
+
this.text(
|
|
1809
|
+
".voice-time",
|
|
1810
|
+
this.clock(
|
|
1811
|
+
this.audio.currentTime ? this.audio.currentTime * 1e3 : duration
|
|
1812
|
+
)
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
sync() {
|
|
1816
|
+
if (!this.shadowRoot.querySelector(".voice-widget")) return;
|
|
1817
|
+
this.labels();
|
|
1818
|
+
const item = this.value, native = mobile(this), recording = !!this.recording;
|
|
1819
|
+
this.text(
|
|
1820
|
+
".voice-heading",
|
|
1821
|
+
this.getAttribute("label") || this.defaultLabel
|
|
1822
|
+
);
|
|
1823
|
+
this.shadowRoot.querySelector(".voice-head").hidden = native && !this.getAttribute("label");
|
|
1824
|
+
this.shadowRoot.querySelector(".voice-rail").hidden = !native || !!item;
|
|
1825
|
+
this.shadowRoot.querySelector(".voice-result").hidden = native && !item;
|
|
1826
|
+
this.shadowRoot.querySelector(".voice-hint").hidden = recording;
|
|
1827
|
+
this.shadowRoot.querySelector(".voice-live").hidden = !recording;
|
|
1828
|
+
this.text(
|
|
1829
|
+
".voice-live",
|
|
1830
|
+
`\u25CF ${this.clock(recording ? Date.now() - this.started : 0)}`
|
|
1831
|
+
);
|
|
1832
|
+
this.thumb.disabled = this.disabled || this.busy;
|
|
1833
|
+
this.thumb.setAttribute(
|
|
1834
|
+
"aria-label",
|
|
1835
|
+
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"
|
|
1836
|
+
);
|
|
1837
|
+
const button = this.shadowRoot.querySelector(".voice-web-record");
|
|
1838
|
+
button.disabled = this.disabled || this.busy;
|
|
1839
|
+
button.dataset.recording = String(recording);
|
|
1840
|
+
button.querySelector("s24-icon").setAttribute("name", recording ? "stop" : "mic");
|
|
1841
|
+
button.querySelector("span").textContent = recording ? "\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C" : "\u0417\u0430\u043F\u0438\u0441\u0430\u0442\u044C";
|
|
1842
|
+
this.shadowRoot.querySelector(".voice-play s24-icon").setAttribute("size", native ? "38" : "18");
|
|
1843
|
+
this.shadowRoot.querySelector(".voice-delete s24-icon").setAttribute("size", native ? "32" : "18");
|
|
1844
|
+
this.shadowRoot.querySelector(".voice-play").setAttribute(
|
|
1845
|
+
"aria-label",
|
|
1846
|
+
this.audio?.paused ? "\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438" : "\u041F\u0430\u0443\u0437\u0430"
|
|
1847
|
+
);
|
|
1848
|
+
this.shadowRoot.querySelector(".voice-play").disabled = this.disabled || !item || recording;
|
|
1849
|
+
this.shadowRoot.querySelector(".voice-play s24-icon").setAttribute(
|
|
1850
|
+
"name",
|
|
1851
|
+
item ? this.audio?.paused ? native ? "play_circle" : "play_arrow" : native ? "pause_circle" : "pause" : "graphic_eq"
|
|
1852
|
+
);
|
|
1853
|
+
this.shadowRoot.querySelector(".voice-delete").hidden = !item || recording;
|
|
1854
|
+
this.shadowRoot.querySelector(".voice-speed").hidden = !native || !item;
|
|
1855
|
+
this.shadowRoot.querySelector(".voice-widget").dataset.recording = String(recording);
|
|
1856
|
+
const url = safeURL(item?.url) || (/^data:audio\/[\w.+-]+;base64,/.test(item?.preview || "") ? item.preview : "");
|
|
1857
|
+
if (this.audio && this.audio.getAttribute("src") !== url) {
|
|
1858
|
+
if (url) this.audio.src = url;
|
|
1859
|
+
else this.audio.removeAttribute("src");
|
|
1860
|
+
}
|
|
1861
|
+
const bars = this.shadowRoot.querySelector(".voice-bars");
|
|
1862
|
+
const values = item?.bars?.length ? item.bars : Array.from({ length: 40 }, () => 0.16);
|
|
1863
|
+
if (this.renderedBars !== values) {
|
|
1864
|
+
bars.replaceChildren(
|
|
1865
|
+
...values.slice(0, 120).map((value) => {
|
|
1866
|
+
const b = document.createElement("i");
|
|
1867
|
+
b.style.setProperty(
|
|
1868
|
+
"--bar",
|
|
1869
|
+
String(Math.max(0, Math.min(1, Number(value) || 0)))
|
|
1870
|
+
);
|
|
1871
|
+
b.style.height = `${Math.max(
|
|
1872
|
+
3,
|
|
1873
|
+
Math.min(1, Number(value) || 0) * 38
|
|
1874
|
+
)}px`;
|
|
1875
|
+
return b;
|
|
1876
|
+
})
|
|
1877
|
+
);
|
|
1878
|
+
this.renderedBars = values;
|
|
1879
|
+
}
|
|
1880
|
+
if (!recording) this.updatePlayback();
|
|
1881
|
+
else this.text(".voice-time", this.clock(Date.now() - this.started));
|
|
1882
|
+
}
|
|
1883
|
+
disconnectedCallback() {
|
|
1884
|
+
void this.cancel();
|
|
1885
|
+
this.audio?.pause();
|
|
1886
|
+
super.disconnectedCallback();
|
|
1887
|
+
}
|
|
1888
|
+
async cancel() {
|
|
1889
|
+
clearTimeout(this.recordTimer);
|
|
1890
|
+
clearInterval(this.tick);
|
|
1891
|
+
this.cancelRecording = true;
|
|
1892
|
+
if (this.session && this.sdk?.cancelVoiceRecording)
|
|
1893
|
+
await this.sdk.cancelVoiceRecording({ session_id: this.session }).catch(() => {
|
|
1894
|
+
});
|
|
1895
|
+
this.session = null;
|
|
1896
|
+
if (this.recorder?.state === "recording") this.recorder.stop();
|
|
1897
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
1898
|
+
this.recording = false;
|
|
1899
|
+
}
|
|
1900
|
+
async stop() {
|
|
1901
|
+
this.stopRequested = true;
|
|
1902
|
+
if (this.starting || this.stopping || !this.recording) return;
|
|
1903
|
+
this.stopping = true;
|
|
1904
|
+
clearTimeout(this.recordTimer);
|
|
1905
|
+
clearInterval(this.tick);
|
|
1906
|
+
this.busy = true;
|
|
1907
|
+
this.sync();
|
|
1908
|
+
try {
|
|
1909
|
+
let item;
|
|
1910
|
+
if (this.session) {
|
|
1911
|
+
const result = await this.sdk.stopVoiceRecording({
|
|
1912
|
+
session_id: this.session
|
|
1913
|
+
});
|
|
1914
|
+
if (result?.supported === false)
|
|
1915
|
+
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");
|
|
1916
|
+
item = result.items?.[0];
|
|
1917
|
+
} else if (this.recorder?.state === "recording") {
|
|
1918
|
+
const blob = await new Promise((resolve, reject) => {
|
|
1919
|
+
this.recorder.onstop = () => resolve(
|
|
1920
|
+
new Blob(this.chunks, {
|
|
1921
|
+
type: this.recorder.mimeType || "audio/webm"
|
|
1922
|
+
})
|
|
1923
|
+
);
|
|
1924
|
+
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"));
|
|
1925
|
+
this.recorder.stop();
|
|
1926
|
+
});
|
|
1927
|
+
if (blob.size) {
|
|
1928
|
+
const ext = blob.type.includes("mp4") ? "m4a" : blob.type.includes("ogg") ? "ogg" : "webm";
|
|
1929
|
+
item = {
|
|
1930
|
+
...await this.localFile(
|
|
1931
|
+
new File([blob], `voice_${Date.now()}.${ext}`, {
|
|
1932
|
+
type: blob.type
|
|
1933
|
+
})
|
|
1934
|
+
),
|
|
1935
|
+
duration_ms: Date.now() - this.started,
|
|
1936
|
+
bars: this.liveBars
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
if (this.isConnected && !this.cancelRecording && item) {
|
|
1941
|
+
this.value = item;
|
|
1942
|
+
this.changed();
|
|
1943
|
+
}
|
|
1944
|
+
} catch (error) {
|
|
1945
|
+
if (this.isConnected) this.fail(error);
|
|
1946
|
+
} finally {
|
|
1947
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
1948
|
+
this.stream = null;
|
|
1949
|
+
this.session = null;
|
|
1950
|
+
this.recording = false;
|
|
1951
|
+
this.busy = false;
|
|
1952
|
+
this.stopping = false;
|
|
1953
|
+
this.audioContext?.close().catch(() => {
|
|
1954
|
+
});
|
|
1955
|
+
this.event("s24-recording", { recording: false });
|
|
1956
|
+
if (this.isConnected) this.sync();
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
async record() {
|
|
1960
|
+
if (this.disabled || this.busy || this.starting || this.recording) return;
|
|
1961
|
+
this.starting = true;
|
|
1962
|
+
this.stopRequested = false;
|
|
1963
|
+
this.cancelRecording = false;
|
|
1964
|
+
this.clearError();
|
|
1965
|
+
const generation = this.generation;
|
|
1966
|
+
try {
|
|
1967
|
+
if (this.sdk?.startVoiceRecording) {
|
|
1968
|
+
this.session = attachmentID();
|
|
1969
|
+
const result = await this.sdk.startVoiceRecording({
|
|
1970
|
+
session_id: this.session,
|
|
1971
|
+
max_duration: Math.min(limit(this, "max-duration", 300), 300)
|
|
1972
|
+
});
|
|
1973
|
+
if (result?.supported === false) {
|
|
1974
|
+
this.session = null;
|
|
1975
|
+
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");
|
|
1976
|
+
}
|
|
1977
|
+
} else {
|
|
1978
|
+
if (this.sdk)
|
|
1979
|
+
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");
|
|
1980
|
+
if (!navigator.mediaDevices?.getUserMedia || typeof MediaRecorder === "undefined")
|
|
1981
|
+
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");
|
|
1982
|
+
this.stream = await navigator.mediaDevices.getUserMedia({
|
|
1983
|
+
audio: true
|
|
1984
|
+
});
|
|
1985
|
+
if (!this.isConnected || generation !== this.generation) {
|
|
1986
|
+
this.stream.getTracks().forEach((t) => t.stop());
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
this.chunks = [];
|
|
1990
|
+
this.liveBars = [];
|
|
1991
|
+
this.recorder = new MediaRecorder(this.stream);
|
|
1992
|
+
this.recorder.ondataavailable = (e) => {
|
|
1993
|
+
if (e.data.size) this.chunks.push(e.data);
|
|
1994
|
+
};
|
|
1995
|
+
this.recorder.start();
|
|
1996
|
+
if (globalThis.AudioContext) {
|
|
1997
|
+
this.audioContext = new AudioContext();
|
|
1998
|
+
const source = this.audioContext.createMediaStreamSource(
|
|
1999
|
+
this.stream
|
|
2000
|
+
);
|
|
2001
|
+
this.analyser = this.audioContext.createAnalyser();
|
|
2002
|
+
source.connect(this.analyser);
|
|
2003
|
+
this.analyser.fftSize = 64;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
if (!this.isConnected || generation !== this.generation) {
|
|
2007
|
+
await this.cancel();
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
this.value = null;
|
|
2011
|
+
this.started = Date.now();
|
|
2012
|
+
this.recording = true;
|
|
2013
|
+
this.event("s24-recording", { recording: true });
|
|
2014
|
+
this.tick = setInterval(() => {
|
|
2015
|
+
if (this.analyser) {
|
|
2016
|
+
const bins = new Uint8Array(this.analyser.frequencyBinCount);
|
|
2017
|
+
this.analyser.getByteFrequencyData(bins);
|
|
2018
|
+
this.liveBars.push(Math.max(0.08, Math.max(...bins) / 255));
|
|
2019
|
+
if (this.liveBars.length > 120) this.liveBars.shift();
|
|
2020
|
+
}
|
|
2021
|
+
this.sync();
|
|
2022
|
+
}, 200);
|
|
2023
|
+
this.recordTimer = setTimeout(
|
|
2024
|
+
() => void this.stop(),
|
|
2025
|
+
Math.min(limit(this, "max-duration", 300), 300) * 1e3
|
|
2026
|
+
);
|
|
2027
|
+
} catch (error) {
|
|
2028
|
+
if (this.isConnected) this.fail(error);
|
|
2029
|
+
this.stream?.getTracks().forEach((t) => t.stop());
|
|
2030
|
+
this.session = null;
|
|
2031
|
+
} finally {
|
|
2032
|
+
this.starting = false;
|
|
2033
|
+
if (this.isConnected) this.sync();
|
|
2034
|
+
if (this.stopRequested && this.recording) void this.stop();
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
return {
|
|
2039
|
+
"s24-employees": Employees,
|
|
2040
|
+
"s24-photos": Photos,
|
|
2041
|
+
"s24-files": Attachments,
|
|
2042
|
+
"s24-voice-recorder": Voice
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
|
|
405
2046
|
// src/material-symbols-data.js
|
|
406
2047
|
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
2048
|
var catalogCount = 6492;
|
|
@@ -490,7 +2131,7 @@ function coreSVG(name, cls = "") {
|
|
|
490
2131
|
}
|
|
491
2132
|
|
|
492
2133
|
// src/index.js
|
|
493
|
-
var version = "0.
|
|
2134
|
+
var version = "0.3.0";
|
|
494
2135
|
var sessions = /* @__PURE__ */ new WeakMap();
|
|
495
2136
|
var contextKey = /* @__PURE__ */ Symbol.for("synchra24.ui.context.v1");
|
|
496
2137
|
function contextFor(element) {
|
|
@@ -631,6 +2272,7 @@ function connect(root, {
|
|
|
631
2272
|
set("selectPadding", mobile ? "0 12px" : "0 20px 0 22px");
|
|
632
2273
|
set("fieldText", !mobile && active === "light" ? next?.tokens?.["--text"] ?? "#111418" : colors.text);
|
|
633
2274
|
set("selectShadow", active === "dark" ? "0 24px 70px rgba(0,0,0,.44)" : "0 14px 38px rgba(17,24,39,.12)");
|
|
2275
|
+
set("segmentBg", active === "dark" ? "rgba(255,255,255,.035)" : "rgba(0,0,0,.035)");
|
|
634
2276
|
set("searchBg", active === "dark" ? "#171c22" : colors.inputGrey);
|
|
635
2277
|
set("searchBorder", active === "dark" ? "#373f49" : "#c8d0d8");
|
|
636
2278
|
set("searchFocusBorder", active === "dark" ? "#515d6b" : "#c8d0d8");
|
|
@@ -736,7 +2378,11 @@ function connect(root, {
|
|
|
736
2378
|
root.dataset.s24Runtime = activeRuntime;
|
|
737
2379
|
root.dataset.s24Theme = active;
|
|
738
2380
|
if (root[contextKey]) root[contextKey].runtime = activeRuntime;
|
|
739
|
-
|
|
2381
|
+
const apply = (parent) => parent.querySelectorAll("*").forEach((element) => {
|
|
2382
|
+
element._applyPlatform?.(activeRuntime);
|
|
2383
|
+
if (element.shadowRoot) apply(element.shadowRoot);
|
|
2384
|
+
});
|
|
2385
|
+
apply(root);
|
|
740
2386
|
root.querySelectorAll("s24-input,s24-textarea,s24-text,s24-typography").forEach((field) => field.sync?.());
|
|
741
2387
|
}
|
|
742
2388
|
update();
|
|
@@ -786,7 +2432,8 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
786
2432
|
_applyPlatform(runtime) {
|
|
787
2433
|
this._runtime = runtime;
|
|
788
2434
|
const style = this.shadowRoot.querySelector("style[data-s24-platform]");
|
|
789
|
-
const value = runtime === "mobile" ? mobileStyles + mobileExtras : "";
|
|
2435
|
+
const value = (runtime === "mobile" ? mobileStyles + mobileExtras : "") + segmentedStyles + searchStyles;
|
|
2436
|
+
this.toggleAttribute("data-segment-mobile", runtime === "mobile");
|
|
790
2437
|
if (style.textContent !== value) style.textContent = value;
|
|
791
2438
|
}
|
|
792
2439
|
text(selector, value) {
|
|
@@ -972,6 +2619,56 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
972
2619
|
this.control?.focus(options);
|
|
973
2620
|
}
|
|
974
2621
|
}
|
|
2622
|
+
class Search extends FormControl {
|
|
2623
|
+
static observedAttributes = [...FormControl.observedAttributes, "small", "maxlength"];
|
|
2624
|
+
constructor() {
|
|
2625
|
+
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>`);
|
|
2626
|
+
this.control = this.shadowRoot.querySelector("input");
|
|
2627
|
+
this.action = this.shadowRoot.querySelector(".search-action");
|
|
2628
|
+
this.control.addEventListener("input", () => {
|
|
2629
|
+
this._value = this.control.value;
|
|
2630
|
+
this.sync();
|
|
2631
|
+
this.event("s24-input", { value: this.value });
|
|
2632
|
+
});
|
|
2633
|
+
this.control.addEventListener("change", () => this.event("s24-change", { value: this.value }));
|
|
2634
|
+
this.control.addEventListener("keydown", (e) => {
|
|
2635
|
+
if (e.key === "Enter") {
|
|
2636
|
+
e.preventDefault();
|
|
2637
|
+
this.event("s24-submit", { value: this.value });
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2640
|
+
this.action.addEventListener("click", () => {
|
|
2641
|
+
if (this.disabled) return;
|
|
2642
|
+
if (this.value) {
|
|
2643
|
+
this.value = "";
|
|
2644
|
+
this.event("s24-input", { value: "" });
|
|
2645
|
+
this.event("s24-change", { value: "" });
|
|
2646
|
+
}
|
|
2647
|
+
this.control.focus();
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
_applyPlatform(runtime) {
|
|
2651
|
+
super._applyPlatform(runtime);
|
|
2652
|
+
this.sync();
|
|
2653
|
+
}
|
|
2654
|
+
sync() {
|
|
2655
|
+
if (!this.control) return;
|
|
2656
|
+
this.labels();
|
|
2657
|
+
this.control.value = this.value;
|
|
2658
|
+
this.control.disabled = this.disabled;
|
|
2659
|
+
this.control.placeholder = this.getAttribute("placeholder") || "\u041F\u043E\u0438\u0441\u043A\u2026";
|
|
2660
|
+
this.control.setAttribute("aria-label", this.getAttribute("label") || this.getAttribute("aria-label") || this.control.placeholder);
|
|
2661
|
+
this.control.setAttribute("aria-invalid", String(!!this.getAttribute("error")));
|
|
2662
|
+
const max = this.getAttribute("maxlength");
|
|
2663
|
+
if (max !== null) this.control.setAttribute("maxlength", max);
|
|
2664
|
+
else this.control.removeAttribute("maxlength");
|
|
2665
|
+
this.action.disabled = this.disabled;
|
|
2666
|
+
this.action.dataset.empty = String(!this.value);
|
|
2667
|
+
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");
|
|
2668
|
+
this.action.querySelector("s24-icon").setAttribute("name", this.value ? "close" : "search");
|
|
2669
|
+
this.setForm(this.value);
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
975
2672
|
class DateTimeField extends FormControl {
|
|
976
2673
|
static observedAttributes = [
|
|
977
2674
|
...FormControl.observedAttributes,
|
|
@@ -1039,10 +2736,10 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1039
2736
|
if (!this.control) return;
|
|
1040
2737
|
this.labels();
|
|
1041
2738
|
this.control.disabled = this.disabled;
|
|
1042
|
-
const
|
|
1043
|
-
this.text(".selected",
|
|
2739
|
+
const text2 = this.displayValue();
|
|
2740
|
+
this.text(".selected", text2);
|
|
1044
2741
|
const label = this.getAttribute("label") || this.getAttribute("aria-label") || (this.kind === "date" ? "\u0414\u0430\u0442\u0430" : "\u0412\u0440\u0435\u043C\u044F");
|
|
1045
|
-
this.control.setAttribute("aria-label", `${label}: ${
|
|
2742
|
+
this.control.setAttribute("aria-label", `${label}: ${text2}`);
|
|
1046
2743
|
this.control.setAttribute(
|
|
1047
2744
|
"aria-invalid",
|
|
1048
2745
|
String(Boolean(this.getAttribute("error")))
|
|
@@ -1067,10 +2764,10 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1067
2764
|
this.value = value;
|
|
1068
2765
|
this.event("s24-change", { value: this.value });
|
|
1069
2766
|
}
|
|
1070
|
-
button(
|
|
2767
|
+
button(text2, fn, attrs = {}) {
|
|
1071
2768
|
const b = this.ownerDocument.createElement("button");
|
|
1072
2769
|
b.type = "button";
|
|
1073
|
-
b.textContent =
|
|
2770
|
+
b.textContent = text2;
|
|
1074
2771
|
for (const [k, v] of Object.entries(attrs)) b.setAttribute(k, String(v));
|
|
1075
2772
|
b.addEventListener("click", fn);
|
|
1076
2773
|
return b;
|
|
@@ -1427,9 +3124,9 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1427
3124
|
formatter = new Intl.NumberFormat("ru-RU");
|
|
1428
3125
|
}
|
|
1429
3126
|
const format = (v) => formatter.format(v) + (this.getAttribute("suffix") || "");
|
|
1430
|
-
const
|
|
1431
|
-
this.control.setAttribute("aria-valuetext",
|
|
1432
|
-
this.text("output",
|
|
3127
|
+
const text2 = format(this.valueAsNumber);
|
|
3128
|
+
this.control.setAttribute("aria-valuetext", text2);
|
|
3129
|
+
this.text("output", text2);
|
|
1433
3130
|
const scale = this.shadowRoot.querySelectorAll(".slider-scale span");
|
|
1434
3131
|
scale[0].textContent = this.getAttribute("start-label") ?? format(Number(this.control.min));
|
|
1435
3132
|
scale[1].textContent = this.getAttribute("middle-label") || "";
|
|
@@ -1544,9 +3241,9 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1544
3241
|
const counter = this.shadowRoot.querySelector(".field-count");
|
|
1545
3242
|
if (!counter) return;
|
|
1546
3243
|
counter.hidden = !this.hasAttribute("len");
|
|
1547
|
-
const
|
|
1548
|
-
counter.textContent = `${this.value.length}/${
|
|
1549
|
-
counter.style.color = this.value.length >
|
|
3244
|
+
const limit2 = Number(this.getAttribute("len"));
|
|
3245
|
+
counter.textContent = `${this.value.length}/${limit2}`;
|
|
3246
|
+
counter.style.color = this.value.length > limit2 ? "var(--s24-error)" : "";
|
|
1550
3247
|
}
|
|
1551
3248
|
validate() {
|
|
1552
3249
|
this.setForm(this.value);
|
|
@@ -1988,10 +3685,10 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
1988
3685
|
const list = this.hasAttribute("list-item");
|
|
1989
3686
|
this.shadowRoot.querySelector(".content").className = `content ${list ? "list" : ""}`;
|
|
1990
3687
|
this.shadowRoot.querySelector(".dot").hidden = !list;
|
|
1991
|
-
const
|
|
1992
|
-
this.shadowRoot.querySelector(".plain").hidden =
|
|
1993
|
-
this.shadowRoot.querySelector(".plain").textContent =
|
|
1994
|
-
this.shadowRoot.querySelector("slot").hidden =
|
|
3688
|
+
const text2 = this.getAttribute("text");
|
|
3689
|
+
this.shadowRoot.querySelector(".plain").hidden = text2 === null;
|
|
3690
|
+
this.shadowRoot.querySelector(".plain").textContent = text2 || "";
|
|
3691
|
+
this.shadowRoot.querySelector("slot").hidden = text2 !== null;
|
|
1995
3692
|
}
|
|
1996
3693
|
}
|
|
1997
3694
|
class Text extends Typography {
|
|
@@ -2059,14 +3756,32 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2059
3756
|
}
|
|
2060
3757
|
}
|
|
2061
3758
|
class Tab extends Component {
|
|
3759
|
+
static observedAttributes = ["count"];
|
|
3760
|
+
_applyPlatform(runtime) {
|
|
3761
|
+
super._applyPlatform(runtime);
|
|
3762
|
+
this.sync();
|
|
3763
|
+
}
|
|
3764
|
+
connectedCallback() {
|
|
3765
|
+
this.sync();
|
|
3766
|
+
}
|
|
3767
|
+
attributeChangedCallback() {
|
|
3768
|
+
this.sync();
|
|
3769
|
+
}
|
|
3770
|
+
sync() {
|
|
3771
|
+
const badge = this.shadowRoot.querySelector(".tab-count");
|
|
3772
|
+
if (!badge) return;
|
|
3773
|
+
const count = this.getAttribute("count");
|
|
3774
|
+
badge.hidden = count === null || count === "";
|
|
3775
|
+
badge.textContent = this._runtime === "mobile" ? `(${count})` : count || "";
|
|
3776
|
+
}
|
|
2062
3777
|
constructor() {
|
|
2063
3778
|
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>'
|
|
3779
|
+
'<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
3780
|
);
|
|
2066
3781
|
}
|
|
2067
3782
|
}
|
|
2068
3783
|
class Tabs extends Component {
|
|
2069
|
-
static observedAttributes = ["value"];
|
|
3784
|
+
static observedAttributes = ["value", "variant"];
|
|
2070
3785
|
constructor() {
|
|
2071
3786
|
super(
|
|
2072
3787
|
"<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 +3816,7 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2101
3816
|
(el) => el.getAttribute("value") === this.value && !el.hasAttribute("disabled")
|
|
2102
3817
|
) ?? tabs.find((el) => !el.hasAttribute("disabled"));
|
|
2103
3818
|
for (const tab of tabs) {
|
|
3819
|
+
tab.toggleAttribute("data-segmented", this.getAttribute("variant") === "segmented");
|
|
2104
3820
|
tab.setAttribute("role", "tab");
|
|
2105
3821
|
tab.setAttribute("aria-disabled", String(tab.hasAttribute("disabled")));
|
|
2106
3822
|
tab.setAttribute("aria-selected", String(tab === selected));
|
|
@@ -2319,16 +4035,16 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2319
4035
|
b.setAttribute("role", "option");
|
|
2320
4036
|
b.setAttribute("aria-selected", String(item.value === this.value));
|
|
2321
4037
|
b.disabled = Boolean(item.disabled);
|
|
2322
|
-
const
|
|
4038
|
+
const text2 = this.ownerDocument.createElement("span");
|
|
2323
4039
|
const label = this.ownerDocument.createElement("span");
|
|
2324
4040
|
label.className = "option-label";
|
|
2325
4041
|
label.textContent = item.label;
|
|
2326
|
-
|
|
2327
|
-
b.append(
|
|
4042
|
+
text2.append(label);
|
|
4043
|
+
b.append(text2);
|
|
2328
4044
|
if (item.description) {
|
|
2329
4045
|
const small = this.ownerDocument.createElement("small");
|
|
2330
4046
|
small.textContent = item.description;
|
|
2331
|
-
|
|
4047
|
+
text2.append(small);
|
|
2332
4048
|
}
|
|
2333
4049
|
list.append(b);
|
|
2334
4050
|
}
|
|
@@ -2399,10 +4115,15 @@ function defineComponents(registry = globalThis.customElements) {
|
|
|
2399
4115
|
}
|
|
2400
4116
|
}
|
|
2401
4117
|
const components = {
|
|
4118
|
+
...widgetComponents({ Component, contextFor, mobile, coreSVG }),
|
|
4119
|
+
...feedbackComponents({ Component, contextFor, mobile }),
|
|
4120
|
+
...sheetComponents({ Component, contextFor, mobile }),
|
|
4121
|
+
...editorComponents({ Component, contextFor, mobile }),
|
|
2402
4122
|
"s24-icon": Icon,
|
|
2403
4123
|
"s24-typography": Typography,
|
|
2404
4124
|
"s24-button": Button,
|
|
2405
4125
|
"s24-circle-button": CircleButton,
|
|
4126
|
+
"s24-search": Search,
|
|
2406
4127
|
"s24-input": Input,
|
|
2407
4128
|
"s24-textarea": Textarea,
|
|
2408
4129
|
"s24-checkbox": Choice,
|