@brandup/ui-kit 1.0.44 → 1.0.45
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/package.json +2 -2
- package/source/index.ts +1 -0
- package/source/modal.ts +3 -1
- package/source/utils/text.ts +20 -0
package/package.json
CHANGED
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
"type": "module",
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
|
-
"version": "1.0.
|
|
28
|
+
"version": "1.0.45",
|
|
29
29
|
"main": "source/index.ts",
|
|
30
30
|
"types": "source/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@brandup/ui-app": "^2.0.
|
|
32
|
+
"@brandup/ui-app": "^2.0.9"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"source",
|
package/source/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const SCROLLABLE_CLASS = "ui-scrollable";
|
|
|
9
9
|
|
|
10
10
|
export { default as Modal, MODAL_CLASS, MODAL_OPENED_CLASS, MODAL_CLOSE_COMMAND, type ModalOptions } from "./modal";
|
|
11
11
|
export { IS_TOUCH_DEVICE } from "./utils/compatibility";
|
|
12
|
+
export { textTag } from "./utils/text";
|
|
12
13
|
import "./styles.less";
|
|
13
14
|
|
|
14
15
|
export const uiKitMiddlewareFactory = () => new UiKitMiddleware();
|
package/source/modal.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "./modal.less"; // стили окна
|
|
2
2
|
|
|
3
3
|
import { DOM, UIElement } from "@brandup/ui";
|
|
4
|
+
import { textTag } from "./utils/text";
|
|
4
5
|
import closeIcon from "../svg/x.svg";
|
|
5
6
|
|
|
6
7
|
export const MODAL_CLASS = "ui-modal";
|
|
@@ -53,7 +54,8 @@ export default abstract class Modal extends UIElement {
|
|
|
53
54
|
),
|
|
54
55
|
DOM.tag("div", { class: "modal-window", role: "dialog", "aria-modal": "true" }, [
|
|
55
56
|
DOM.tag("div", { class: "modal-header" }, [
|
|
56
|
-
|
|
57
|
+
// the title is host data — text, not markup (see textTag)
|
|
58
|
+
options.title ? textTag("div", { class: "modal-title" }, options.title) : null,
|
|
57
59
|
DOM.tag(
|
|
58
60
|
"button",
|
|
59
61
|
{ type: "button", class: "modal-close", title: "Закрыть", command: MODAL_CLOSE_COMMAND },
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DOM, type ElementOptions } from "@brandup/ui";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates an element holding `text` as text, never as markup.
|
|
5
|
+
*
|
|
6
|
+
* A string child of `DOM.tag` is inserted as HTML — that is how svg icons reach buttons. Anything
|
|
7
|
+
* coming from the user or from the host markup (message text, variable names and keys, window
|
|
8
|
+
* titles) must go through here instead: otherwise an `<img onerror>` typed into a field would
|
|
9
|
+
* execute once it is shown back.
|
|
10
|
+
*/
|
|
11
|
+
export function textTag<T extends keyof HTMLElementTagNameMap>(
|
|
12
|
+
tagName: T,
|
|
13
|
+
options: ElementOptions | null,
|
|
14
|
+
text: string
|
|
15
|
+
): HTMLElementTagNameMap[T] {
|
|
16
|
+
const elem = DOM.tag(tagName, options);
|
|
17
|
+
elem.textContent = text;
|
|
18
|
+
|
|
19
|
+
return elem;
|
|
20
|
+
}
|