material 3.3.4 → 3.4.1
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/README.md +2 -2
- package/dist/components/badge/api.js +7 -5
- package/dist/components/badge/config.js +3 -15
- package/dist/components/badge/features.js +6 -10
- package/dist/components/chips/chip/chip.js +3 -0
- package/dist/components/chips/types.d.ts +1 -0
- package/dist/components/dialog/api.js +109 -109
- package/dist/components/dialog/config.js +0 -52
- package/dist/components/dialog/dialog.js +2 -2
- package/dist/components/dialog/features.js +113 -65
- package/dist/components/dialog/types.d.ts +2 -3
- package/dist/components/search/features/input.js +1 -1
- package/dist/components/search/features/structure.js +1 -1
- package/dist/components/search/types.d.ts +1 -0
- package/dist/components/select/features.js +2 -0
- package/dist/components/select/types.d.ts +1 -0
- package/dist/components/slider/features/dom.js +27 -9
- package/dist/components/tabs/tab.js +2 -1
- package/dist/components/text-field/config.js +21 -1
- package/dist/components/text-field/types.d.ts +1 -0
- package/dist/core/compose/features/badge.js +1 -1
- package/dist/core/compose/features/textinput.d.ts +1 -0
- package/dist/core/compose/features/textinput.js +1 -0
- package/dist/core/dom/focus.js +2 -2
- package/dist/elements/css/dialog.css +1 -1
- package/dist/elements/css/dialog.js +1 -1
- package/dist/elements/css/switch.css +1 -1
- package/dist/elements/css/switch.js +1 -1
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/package.json +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +1 -1
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +2 -2
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +2 -2
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +2 -2
- package/dist/themes/autumn-contrast.css +1 -1
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline-contrast.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige-contrast.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/content-contrast.css +1 -1
- package/dist/themes/content.css +1 -1
- package/dist/themes/desert-contrast.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/expressive-contrast.css +1 -1
- package/dist/themes/expressive.css +1 -1
- package/dist/themes/fidelity-contrast.css +1 -1
- package/dist/themes/fidelity.css +1 -1
- package/dist/themes/forest-contrast.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/fruit-salad-contrast.css +1 -1
- package/dist/themes/fruit-salad.css +1 -1
- package/dist/themes/highcontrast-contrast.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/monochrome-contrast.css +1 -1
- package/dist/themes/monochrome.css +1 -1
- package/dist/themes/neutral-contrast.css +1 -1
- package/dist/themes/neutral.css +1 -1
- package/dist/themes/ocean-contrast.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/rainbow-contrast.css +1 -1
- package/dist/themes/rainbow.css +1 -1
- package/dist/themes/sageivory-contrast.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring-contrast.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer-contrast.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset-contrast.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel-contrast.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/vibrant-contrast.css +1 -1
- package/dist/themes/vibrant.css +1 -1
- package/package.json +1 -1
- package/src/styles/components/_dialog.scss +8 -0
- package/src/styles/components/_switch.scss +15 -5
package/README.md
CHANGED
|
@@ -93,8 +93,8 @@ What a bundler keeps, minified and gzipped (kB is 1,000 bytes), measured from th
|
|
|
93
93
|
|--------|-----:|
|
|
94
94
|
| `createButton` from `material`, with code splitting: the initial chunks (the progress indicator loads on demand) | 7.6 kB |
|
|
95
95
|
| `createButton`, without code splitting (the progress indicator included) | 13.9 kB |
|
|
96
|
-
| `createButton`, `createTextField` and `createCheckbox`, without code splitting | 20.
|
|
97
|
-
| Everything the root exports (`export * from 'material'`), without code splitting | 127.
|
|
96
|
+
| `createButton`, `createTextField` and `createCheckbox`, without code splitting | 20.4 kB |
|
|
97
|
+
| Everything the root exports (`export * from 'material'`), without code splitting | 127.3 kB |
|
|
98
98
|
| `material/styles/base` | 2.9 kB |
|
|
99
99
|
| `material/styles/base` and `material/styles/button` | 5.2 kB |
|
|
100
100
|
| `material/styles`, the full stylesheet | 63.7 kB |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBadgeOverflow, isEmptyBadgeLabel } from "./config.js";
|
|
1
|
+
import { isBadgeOverflow, isEmptyBadgeLabel, smallBadgeLabel } from "./config.js";
|
|
2
2
|
import { formatBadgeLabel } from "./config.js";
|
|
3
3
|
const VARIANT_SMALL = "small";
|
|
4
4
|
const ALL_COLORS = [
|
|
@@ -21,10 +21,12 @@ export const withAPI = ({ visibility, lifecycle }) => (component) => {
|
|
|
21
21
|
component.config.label = label;
|
|
22
22
|
if (component.config.variant === VARIANT_SMALL) {
|
|
23
23
|
component.element.textContent = "";
|
|
24
|
+
component.element.setAttribute("aria-label", smallBadgeLabel(label));
|
|
24
25
|
return badgeComponent;
|
|
25
26
|
}
|
|
26
27
|
const formattedLabel = formatBadgeLabel(label, component.config.max);
|
|
27
28
|
component.element.textContent = formattedLabel;
|
|
29
|
+
component.element.removeAttribute("aria-label");
|
|
28
30
|
component.element.classList.remove(`${component.getClass("badge")}--overflow`);
|
|
29
31
|
if (isBadgeOverflow(label, component.config.max)) {
|
|
30
32
|
component.element.classList.add(`${component.getClass("badge")}--overflow`);
|
|
@@ -81,14 +83,14 @@ export const withAPI = ({ visibility, lifecycle }) => (component) => {
|
|
|
81
83
|
});
|
|
82
84
|
component.element.classList.add(`${component.getClass("badge")}--${variant}`);
|
|
83
85
|
component.config.variant = variant;
|
|
86
|
+
component.element.removeAttribute("aria-hidden");
|
|
87
|
+
component.element.setAttribute("role", "status");
|
|
84
88
|
if (variant === VARIANT_SMALL) {
|
|
85
89
|
component.element.textContent = "";
|
|
86
|
-
component.element.
|
|
87
|
-
component.element.setAttribute("aria-hidden", "true");
|
|
90
|
+
component.element.setAttribute("aria-label", smallBadgeLabel(component.config.label));
|
|
88
91
|
}
|
|
89
92
|
else {
|
|
90
|
-
component.element.removeAttribute("aria-
|
|
91
|
-
component.element.setAttribute("role", "status");
|
|
93
|
+
component.element.removeAttribute("aria-label");
|
|
92
94
|
if (component.config.label !== undefined) {
|
|
93
95
|
badgeComponent.setLabel(component.config.label);
|
|
94
96
|
}
|
|
@@ -7,22 +7,10 @@ export const defaultConfig = {
|
|
|
7
7
|
label: "",
|
|
8
8
|
visible: true,
|
|
9
9
|
};
|
|
10
|
+
export const smallBadgeLabel = (label) => typeof label === "string" && isNaN(+label)
|
|
11
|
+
? label.trim() : "New notification";
|
|
10
12
|
export const createBaseConfig = (config = {}) => createComponentConfig(defaultConfig, config, "badge");
|
|
11
|
-
export const getElementConfig = (config) => {
|
|
12
|
-
const attributes = {};
|
|
13
|
-
if (config.variant !== "small") {
|
|
14
|
-
attributes.role = "status";
|
|
15
|
-
}
|
|
16
|
-
const formattedLabel = config.variant === "small"
|
|
17
|
-
? ""
|
|
18
|
-
: formatBadgeLabel(config.label || "", config.max);
|
|
19
|
-
return createElementConfig(config, {
|
|
20
|
-
tag: "span",
|
|
21
|
-
attributes,
|
|
22
|
-
className: config.class,
|
|
23
|
-
text: formattedLabel,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
13
|
+
export const getElementConfig = (config) => createElementConfig(config, { tag: "span" });
|
|
26
14
|
export const getApiConfig = (comp) => ({
|
|
27
15
|
visibility: {
|
|
28
16
|
show: () => comp.visibility.show(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatBadgeLabel, isBadgeOverflow, isEmptyBadgeLabel } from "./config.js";
|
|
1
|
+
import { formatBadgeLabel, isBadgeOverflow, isEmptyBadgeLabel, smallBadgeLabel } from "./config.js";
|
|
2
2
|
const VARIANT_SMALL = 'small';
|
|
3
3
|
const VARIANT_LARGE = 'large';
|
|
4
4
|
const COLOR_ERROR = 'error';
|
|
@@ -38,16 +38,14 @@ export const withVisibility = () => (component) => {
|
|
|
38
38
|
export const withVariant = (config) => (component) => {
|
|
39
39
|
const variant = config.variant || VARIANT_LARGE;
|
|
40
40
|
component.element.classList.add(`${component.getClass('badge')}--${variant}`);
|
|
41
|
+
component.element.setAttribute('role', 'status');
|
|
41
42
|
if (variant === VARIANT_SMALL) {
|
|
42
|
-
component.element.
|
|
43
|
-
component.element.
|
|
43
|
+
component.element.setAttribute('aria-label', smallBadgeLabel(config.label));
|
|
44
|
+
component.element.removeAttribute('aria-hidden');
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
|
-
component.element.
|
|
47
|
-
|
|
48
|
-
const formattedLabel = formatBadgeLabel(config.label, config.max);
|
|
49
|
-
component.element.textContent = formattedLabel;
|
|
50
|
-
}
|
|
47
|
+
component.element.removeAttribute('aria-label');
|
|
48
|
+
component.element.textContent = formatBadgeLabel(config.label ?? '', config.max);
|
|
51
49
|
}
|
|
52
50
|
return component;
|
|
53
51
|
};
|
|
@@ -70,8 +68,6 @@ export const withMax = (config) => (component) => {
|
|
|
70
68
|
}
|
|
71
69
|
component.config.max = config.max;
|
|
72
70
|
if (config.label !== undefined) {
|
|
73
|
-
const formattedLabel = formatBadgeLabel(config.label, config.max);
|
|
74
|
-
component.element.textContent = formattedLabel;
|
|
75
71
|
if (isBadgeOverflow(config.label, config.max)) {
|
|
76
72
|
component.element.classList.add(`${component.getClass('badge')}--overflow`);
|
|
77
73
|
}
|
|
@@ -90,6 +90,7 @@ const createChip = (config = {}) => {
|
|
|
90
90
|
root.classList.toggle(base.getClass("chip--avatar"), !!avatar);
|
|
91
91
|
action.disabled = disabled;
|
|
92
92
|
if (oneActionCell) {
|
|
93
|
+
root.setAttribute("aria-label", label.textContent ?? "");
|
|
93
94
|
if (selectable)
|
|
94
95
|
root.setAttribute("aria-selected", String(selected));
|
|
95
96
|
root.setAttribute("aria-disabled", String(disabled));
|
|
@@ -114,6 +115,8 @@ const createChip = (config = {}) => {
|
|
|
114
115
|
if (!options.cell)
|
|
115
116
|
root.setAttribute("aria-label", text);
|
|
116
117
|
}
|
|
118
|
+
if (options.ariaLabel)
|
|
119
|
+
(oneActionCell ? root : action).setAttribute("aria-label", options.ariaLabel);
|
|
117
120
|
};
|
|
118
121
|
let made = false;
|
|
119
122
|
const animateChanges = () => {
|
|
@@ -1,113 +1,113 @@
|
|
|
1
1
|
import { removeClass } from "../../core/dom/classes.js";
|
|
2
2
|
import { hideFromTopLayer } from "../../core/dom/layer.js";
|
|
3
|
-
export const withAPI = (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
3
|
+
export const withAPI = (component) => {
|
|
4
|
+
const options = component;
|
|
5
|
+
return {
|
|
6
|
+
...component,
|
|
7
|
+
open() {
|
|
8
|
+
options.visibility.open();
|
|
9
|
+
return this;
|
|
10
|
+
},
|
|
11
|
+
close() {
|
|
12
|
+
options.visibility.close();
|
|
13
|
+
return this;
|
|
14
|
+
},
|
|
15
|
+
toggle(open) {
|
|
16
|
+
options.visibility.toggle(open);
|
|
17
|
+
return this;
|
|
18
|
+
},
|
|
19
|
+
isOpen() {
|
|
20
|
+
return options.visibility.isOpen();
|
|
21
|
+
},
|
|
22
|
+
setTitle(title) {
|
|
23
|
+
options.content.setTitle(title);
|
|
24
|
+
return this;
|
|
25
|
+
},
|
|
26
|
+
getTitle() {
|
|
27
|
+
return options.content.getTitle();
|
|
28
|
+
},
|
|
29
|
+
setSubtitle(subtitle) {
|
|
30
|
+
options.content.setSubtitle(subtitle);
|
|
31
|
+
return this;
|
|
32
|
+
},
|
|
33
|
+
getSubtitle() {
|
|
34
|
+
return options.content.getSubtitle();
|
|
35
|
+
},
|
|
36
|
+
setContent(content) {
|
|
37
|
+
options.content.setContent(content);
|
|
38
|
+
return this;
|
|
39
|
+
},
|
|
40
|
+
getContent() {
|
|
41
|
+
return options.content.getContent();
|
|
42
|
+
},
|
|
43
|
+
addButton(button) {
|
|
44
|
+
options.buttons.addButton(button);
|
|
45
|
+
return this;
|
|
46
|
+
},
|
|
47
|
+
removeButton(indexOrText) {
|
|
48
|
+
options.buttons.removeButton(indexOrText);
|
|
49
|
+
return this;
|
|
50
|
+
},
|
|
51
|
+
getButtons() {
|
|
52
|
+
return options.buttons.getButtons();
|
|
53
|
+
},
|
|
54
|
+
setFooterAlignment(alignment) {
|
|
55
|
+
options.buttons.setFooterAlignment(alignment);
|
|
56
|
+
return this;
|
|
57
|
+
},
|
|
58
|
+
toggleDivider(show) {
|
|
59
|
+
options.divider.toggleDivider(show);
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
62
|
+
hasDivider() {
|
|
63
|
+
return options.divider.hasDivider();
|
|
64
|
+
},
|
|
65
|
+
setSize(size) {
|
|
66
|
+
options.size.setSize(size);
|
|
67
|
+
return this;
|
|
68
|
+
},
|
|
69
|
+
on(event, handler) {
|
|
70
|
+
options.on(event, handler);
|
|
71
|
+
return this;
|
|
72
|
+
},
|
|
73
|
+
off(event, handler) {
|
|
74
|
+
options.off(event, handler);
|
|
75
|
+
return this;
|
|
76
|
+
},
|
|
77
|
+
getHeaderElement() {
|
|
78
|
+
return options.content.getHeaderElement();
|
|
79
|
+
},
|
|
80
|
+
getContentElement() {
|
|
81
|
+
return options.content.getContentElement();
|
|
82
|
+
},
|
|
83
|
+
getFooterElement() {
|
|
84
|
+
return options.content.getFooterElement();
|
|
85
|
+
},
|
|
86
|
+
confirm(options) {
|
|
86
87
|
return component.confirm(options || { message: "Are you sure?" });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
options.focus.releaseFocus();
|
|
88
|
+
},
|
|
89
|
+
destroy() {
|
|
90
|
+
const wasOpen = this.isOpen();
|
|
91
|
+
options.visibility.cancel();
|
|
92
|
+
if (wasOpen) {
|
|
93
|
+
const dialogVisibleClass = `${component.getClass("dialog")}--visible`;
|
|
94
|
+
const overlayVisibleClass = `${component.getClass("dialog__overlay")}--visible`;
|
|
95
|
+
removeClass(component.element, dialogVisibleClass);
|
|
96
|
+
removeClass(component.overlay, overlayVisibleClass);
|
|
97
|
+
hideFromTopLayer(component.element);
|
|
98
|
+
if (options.focus && options.focus.releaseFocus) {
|
|
99
|
+
options.focus.releaseFocus();
|
|
100
|
+
}
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
102
|
+
options.lifecycle.destroy();
|
|
103
|
+
if (component.overlay && component.overlay.parentNode) {
|
|
104
|
+
component.overlay.parentNode.removeChild(component.overlay);
|
|
105
|
+
}
|
|
106
|
+
if (component.element.parentNode !== component.overlay) {
|
|
107
|
+
component.element.remove();
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
element: component.element,
|
|
111
|
+
overlay: component.overlay,
|
|
112
|
+
};
|
|
113
|
+
};
|
|
@@ -35,56 +35,4 @@ export const getElementConfig = (config) => {
|
|
|
35
35
|
className: config.class
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
-
export const getOverlayConfig = () => {
|
|
39
|
-
return {
|
|
40
|
-
tag: 'div',
|
|
41
|
-
attributes: {},
|
|
42
|
-
className: ''
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
export const getApiConfig = (comp) => ({
|
|
46
|
-
visibility: {
|
|
47
|
-
open: () => comp.visibility.open(),
|
|
48
|
-
close: () => comp.visibility.close(),
|
|
49
|
-
toggle: (visible) => comp.visibility.toggle(visible),
|
|
50
|
-
isOpen: () => comp.visibility.isOpen(),
|
|
51
|
-
cancel: () => comp.visibility.cancel()
|
|
52
|
-
},
|
|
53
|
-
content: {
|
|
54
|
-
setTitle: (title) => comp.content.setTitle(title),
|
|
55
|
-
getTitle: () => comp.content.getTitle(),
|
|
56
|
-
setSubtitle: (subtitle) => comp.content.setSubtitle(subtitle),
|
|
57
|
-
getSubtitle: () => comp.content.getSubtitle(),
|
|
58
|
-
setContent: (content) => comp.content.setContent(content),
|
|
59
|
-
getContent: () => comp.content.getContent(),
|
|
60
|
-
getHeaderElement: () => comp.content.getHeaderElement(),
|
|
61
|
-
getContentElement: () => comp.content.getContentElement(),
|
|
62
|
-
getFooterElement: () => comp.content.getFooterElement()
|
|
63
|
-
},
|
|
64
|
-
buttons: {
|
|
65
|
-
addButton: (button) => comp.buttons.addButton(button),
|
|
66
|
-
removeButton: (indexOrText) => comp.buttons.removeButton(indexOrText),
|
|
67
|
-
getButtons: () => comp.buttons.getButtons(),
|
|
68
|
-
setFooterAlignment: (alignment) => comp.buttons.setFooterAlignment(alignment)
|
|
69
|
-
},
|
|
70
|
-
focus: {
|
|
71
|
-
trapFocus: () => comp.focus.trapFocus(),
|
|
72
|
-
releaseFocus: () => comp.focus.releaseFocus()
|
|
73
|
-
},
|
|
74
|
-
size: {
|
|
75
|
-
setSize: (size) => comp.size.setSize(size)
|
|
76
|
-
},
|
|
77
|
-
divider: {
|
|
78
|
-
toggleDivider: (show) => comp.divider.toggleDivider(show),
|
|
79
|
-
hasDivider: () => comp.divider.hasDivider()
|
|
80
|
-
},
|
|
81
|
-
events: {
|
|
82
|
-
on: (event, handler) => comp.on(event, handler),
|
|
83
|
-
off: (event, handler) => comp.off(event, handler),
|
|
84
|
-
trigger: (event, data) => comp.emit(event, data)
|
|
85
|
-
},
|
|
86
|
-
lifecycle: {
|
|
87
|
-
destroy: () => comp.lifecycle.destroy()
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
38
|
export default defaultConfig;
|
|
@@ -3,11 +3,11 @@ import { createBase, withElement } from "../../core/compose/component.js";
|
|
|
3
3
|
import { withEvents, withLifecycle } from "../../core/compose/features/index.js";
|
|
4
4
|
import { withStructure, withVisibility, withContent, withButtons, withSize, withConfirm, withDivider } from "./features.js";
|
|
5
5
|
import { withAPI } from "./api.js";
|
|
6
|
-
import { createBaseConfig, getElementConfig
|
|
6
|
+
import { createBaseConfig, getElementConfig } from "./config.js";
|
|
7
7
|
const createDialog = (config = {}) => {
|
|
8
8
|
const baseConfig = createBaseConfig(config);
|
|
9
9
|
try {
|
|
10
|
-
const dialog = pipe(createBase, withEvents(), withElement(getElementConfig(baseConfig)), withStructure(baseConfig, () => dialog), withVisibility(() => dialog), withContent(), withButtons(() => dialog), withSize(), withDivider(), withConfirm(), withLifecycle(),
|
|
10
|
+
const dialog = pipe(createBase, withEvents(), withElement(getElementConfig(baseConfig)), withStructure(baseConfig, () => dialog), withVisibility(() => dialog), withContent(), withButtons(() => dialog), withSize(), withDivider(), withConfirm(), withLifecycle(), withAPI)(baseConfig);
|
|
11
11
|
if (baseConfig.on) {
|
|
12
12
|
Object.entries(baseConfig.on).forEach(([event, handler]) => {
|
|
13
13
|
if (typeof handler === 'function') {
|