mtrl 0.10.4 → 0.10.6
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 +15 -5
- package/dist/README.md +15 -5
- package/dist/components/bottom-app-bar/bottom-app-bar.js +2 -1
- package/dist/components/bottom-app-bar/index.d.ts +3 -1
- package/dist/components/button/api.js +3 -0
- package/dist/components/button/constants.d.ts +2 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/types.d.ts +7 -1
- package/dist/components/button-group/button-group.js +25 -6
- package/dist/components/button-group/config.js +2 -2
- package/dist/components/button-group/constants.d.ts +8 -2
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/button-group/types.d.ts +5 -1
- package/dist/components/card/index.d.ts +21 -3
- package/dist/components/card/index.js +1 -1
- package/dist/components/card/types.d.ts +20 -4
- package/dist/components/carousel/api.d.ts +1 -0
- package/dist/components/carousel/api.js +4 -0
- package/dist/components/carousel/features/scroll.d.ts +1 -0
- package/dist/components/carousel/features/scroll.js +117 -2
- package/dist/components/carousel/types.d.ts +11 -0
- package/dist/components/checkbox/api.js +3 -0
- package/dist/components/checkbox/config.js +1 -0
- package/dist/components/checkbox/types.d.ts +8 -2
- package/dist/components/chips/types.d.ts +10 -2
- package/dist/components/datepicker/index.d.ts +3 -1
- package/dist/components/datepicker/index.js +1 -1
- package/dist/components/extended-fab/api.d.ts +2 -0
- package/dist/components/extended-fab/api.js +3 -0
- package/dist/components/extended-fab/config.d.ts +1 -0
- package/dist/components/extended-fab/config.js +1 -0
- package/dist/components/extended-fab/types.d.ts +2 -0
- package/dist/components/fab/api.d.ts +2 -0
- package/dist/components/fab/api.js +3 -0
- package/dist/components/fab/config.d.ts +1 -0
- package/dist/components/fab/config.js +1 -0
- package/dist/components/fab/constants.d.ts +2 -1
- package/dist/components/fab/types.d.ts +2 -0
- package/dist/components/fab-menu/fab-menu.js +2 -1
- package/dist/components/icon-button/api.js +3 -0
- package/dist/components/icon-button/constants.d.ts +2 -0
- package/dist/components/icon-button/types.d.ts +5 -0
- package/dist/components/index.d.ts +18 -5
- package/dist/components/index.js +2 -1
- package/dist/components/list/types.d.ts +5 -3
- package/dist/components/menu/features/keyboard.js +8 -5
- package/dist/components/menu/features/opener.js +1 -1
- package/dist/components/menu/index.d.ts +1 -0
- package/dist/components/navigation-rail/types.d.ts +2 -0
- package/dist/components/progress/features/canvas.js +1 -1
- package/dist/components/progress/features/colors.d.ts +2 -1
- package/dist/components/progress/features/colors.js +20 -10
- package/dist/components/radios/api.d.ts +1 -0
- package/dist/components/radios/api.js +3 -0
- package/dist/components/radios/constants.d.ts +9 -9
- package/dist/components/radios/radio.d.ts +1 -0
- package/dist/components/radios/radio.js +1 -0
- package/dist/components/radios/types.d.ts +10 -3
- package/dist/components/search/features/states.d.ts +2 -0
- package/dist/components/search/features/states.js +12 -1
- package/dist/components/search/features/structure.js +2 -0
- package/dist/components/search/types.d.ts +6 -6
- package/dist/components/segmented-button/config.js +2 -2
- package/dist/components/select/api.js +3 -0
- package/dist/components/select/constants.d.ts +1 -1
- package/dist/components/select/features.js +2 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/types.d.ts +6 -0
- package/dist/components/split-button/types.d.ts +5 -1
- package/dist/components/switch/api.js +3 -0
- package/dist/components/switch/config.js +1 -0
- package/dist/components/switch/index.d.ts +6 -2
- package/dist/components/switch/index.js +1 -1
- package/dist/components/switch/types.d.ts +6 -2
- package/dist/components/tabs/config.js +2 -2
- package/dist/components/tabs/index.d.ts +36 -3
- package/dist/components/tabs/index.js +2 -1
- package/dist/components/tabs/tab.js +8 -1
- package/dist/components/tabs/types.d.ts +3 -1
- package/dist/components/tabs/utils.js +2 -1
- package/dist/components/textfield/api.d.ts +5 -0
- package/dist/components/textfield/api.js +209 -188
- package/dist/components/textfield/config.js +4 -3
- package/dist/components/textfield/constants.d.ts +24 -7
- package/dist/components/textfield/constants.js +9 -7
- package/dist/components/textfield/features/index.d.ts +3 -1
- package/dist/components/textfield/features/index.js +1 -0
- package/dist/components/textfield/features/leading-icon.js +1 -0
- package/dist/components/textfield/features/placement.js +15 -2
- package/dist/components/textfield/features/required.d.ts +33 -0
- package/dist/components/textfield/features/required.js +50 -0
- package/dist/components/textfield/features/supporting-text.js +43 -21
- package/dist/components/textfield/features/trailing-icon.d.ts +23 -1
- package/dist/components/textfield/features/trailing-icon.js +39 -5
- package/dist/components/textfield/index.d.ts +16 -1
- package/dist/components/textfield/index.js +1 -0
- package/dist/components/textfield/textfield.js +2 -2
- package/dist/components/textfield/types.d.ts +33 -3
- package/dist/components/timepicker/types.d.ts +2 -1
- package/dist/components/toolbar/toolbar.js +2 -1
- package/dist/components/tooltip/api.js +20 -18
- package/dist/components/tooltip/constants.d.ts +4 -1
- package/dist/components/top-app-bar/index.d.ts +3 -1
- package/dist/components/top-app-bar/top-app-bar.d.ts +2 -57
- package/dist/components/top-app-bar/top-app-bar.js +2 -1
- package/dist/core/compose/features/input.d.ts +9 -2
- package/dist/core/utils/theme.d.ts +6 -2
- package/dist/core/utils/theme.js +12 -19
- package/dist/elements/carousel.d.ts +5 -0
- package/dist/elements/carousel.js +1 -0
- package/dist/elements/css/textfield.js +1 -1
- package/dist/elements/define.d.ts +8 -0
- package/dist/elements/define.js +2 -1
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/icon-button.d.ts +3 -2
- package/dist/elements/index.d.ts +15 -4
- package/dist/elements/index.js +2 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/elements/textfield.d.ts +1 -1
- package/dist/elements/textfield.js +1 -1
- package/dist/index.cjs +0 -0
- package/dist/package.json +1 -1
- package/dist/react/dialog.d.ts +3 -0
- package/dist/react/dialog.js +3 -0
- package/dist/react/index.d.ts +4 -1
- package/dist/react/index.js +2 -1
- package/dist/solid/dialog.d.ts +3 -0
- package/dist/solid/dialog.js +3 -0
- package/dist/solid/index.d.ts +4 -1
- package/dist/solid/index.js +2 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base.css +2 -2
- 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/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- 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-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/segmented-button.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 +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/textfield.css +2 -2
- 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/utilities.css +1 -1
- package/dist/styles.css +2 -2
- package/dist/svelte/Dialog.svelte +3 -0
- package/dist/svelte/index.d.ts +5 -1
- package/dist/svelte/index.js +5 -1
- package/dist/themes/autumn.css +2 -2
- package/dist/themes/baseline.css +2 -2
- package/dist/themes/brownbeige.css +2 -2
- package/dist/themes/browngreen.css +2 -2
- package/dist/themes/content.css +2 -2
- package/dist/themes/desert.css +2 -2
- package/dist/themes/expressive.css +2 -2
- package/dist/themes/fidelity.css +2 -2
- package/dist/themes/forest.css +2 -2
- package/dist/themes/fruit-salad.css +2 -2
- package/dist/themes/highcontrast.css +2 -2
- package/dist/themes/legacy.css +2 -2
- package/dist/themes/material.css +2 -2
- package/dist/themes/monochrome.css +2 -2
- package/dist/themes/neutral.css +2 -2
- package/dist/themes/ocean.css +2 -2
- package/dist/themes/rainbow.css +2 -2
- package/dist/themes/sageivory.css +2 -2
- package/dist/themes/spring.css +2 -2
- package/dist/themes/summer.css +2 -2
- package/dist/themes/sunset.css +2 -2
- package/dist/themes/tealcaramel.css +2 -2
- package/dist/themes/vibrant.css +2 -2
- package/dist/themes/winter.css +2 -2
- package/dist/vue/dialog.d.ts +3 -0
- package/dist/vue/dialog.js +3 -0
- package/dist/vue/index.d.ts +4 -1
- package/dist/vue/index.js +2 -1
- package/package.json +1 -1
- package/src/styles/abstract/_theme.scss +6 -6
- package/src/styles/abstract/_variables.scss +14 -4
- package/src/styles/components/_textfield.scss +61 -8
- package/src/styles/themes/_autumn.scss +173 -0
- package/src/styles/themes/_base-theme.scss +100 -12
- package/src/styles/themes/_baseline.scss +172 -0
- package/src/styles/themes/_brownbeige.scss +150 -0
- package/src/styles/themes/_browngreen.scss +183 -0
- package/src/styles/themes/_content.scss +148 -0
- package/src/styles/themes/_desert.scss +150 -0
- package/src/styles/themes/_expressive.scss +150 -0
- package/src/styles/themes/_fidelity.scss +148 -0
- package/src/styles/themes/_forest.scss +175 -0
- package/src/styles/themes/_fruit-salad.scss +150 -0
- package/src/styles/themes/_highcontrast.scss +74 -0
- package/src/styles/themes/_legacy.scss +181 -0
- package/src/styles/themes/_material.scss +181 -0
- package/src/styles/themes/_monochrome.scss +134 -0
- package/src/styles/themes/_neutral.scss +150 -0
- package/src/styles/themes/_ocean.scss +175 -0
- package/src/styles/themes/_rainbow.scss +150 -0
- package/src/styles/themes/_sageivory.scss +150 -0
- package/src/styles/themes/_spring.scss +171 -0
- package/src/styles/themes/_summer.scss +150 -0
- package/src/styles/themes/_sunset.scss +175 -0
- package/src/styles/themes/_tealcaramel.scss +150 -0
- package/src/styles/themes/_vibrant.scss +150 -0
- package/src/styles/themes/_winter.scss +181 -0
|
@@ -1,201 +1,222 @@
|
|
|
1
|
-
export const withAPI = ({ disabled, lifecycle }) => (component) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
component.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const PREFIX = component.config?.prefix || "mtrl";
|
|
33
|
-
const COMPONENT = component.config?.componentName || "textfield";
|
|
34
|
-
if (component.element.classList.contains(`${PREFIX}-${COMPONENT}--outlined`)) {
|
|
35
|
-
return "outlined";
|
|
36
|
-
}
|
|
37
|
-
return "filled";
|
|
38
|
-
},
|
|
39
|
-
setLabel(text) {
|
|
40
|
-
component.label?.setText(text);
|
|
41
|
-
if (component.updateElementPositions) {
|
|
42
|
-
component.schedulePositionUpdate?.();
|
|
43
|
-
}
|
|
44
|
-
return this;
|
|
45
|
-
},
|
|
46
|
-
getLabel() {
|
|
47
|
-
return component.label?.getText() || "";
|
|
48
|
-
},
|
|
49
|
-
get leadingIcon() {
|
|
50
|
-
return component.leadingIcon ?? null;
|
|
51
|
-
},
|
|
52
|
-
setLeadingIcon(html) {
|
|
53
|
-
if (component.setLeadingIcon) {
|
|
54
|
-
component.setLeadingIcon(html);
|
|
1
|
+
export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
2
|
+
const setTrailingDisabled = (off) => {
|
|
3
|
+
const icon = component.trailingIcon;
|
|
4
|
+
if (icon?.tagName === "BUTTON")
|
|
5
|
+
icon.disabled = off;
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
element: component.element,
|
|
9
|
+
field: component.field ?? component.element,
|
|
10
|
+
input: component.input,
|
|
11
|
+
getValue: component.getValue || (() => ""),
|
|
12
|
+
setValue(value) {
|
|
13
|
+
component.setValue?.(value);
|
|
14
|
+
return this;
|
|
15
|
+
},
|
|
16
|
+
setAttribute(name, value) {
|
|
17
|
+
component.setAttribute?.(name, value);
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
getAttribute(name) {
|
|
21
|
+
return component.getAttribute?.(name) || null;
|
|
22
|
+
},
|
|
23
|
+
removeAttribute(name) {
|
|
24
|
+
component.removeAttribute?.(name);
|
|
25
|
+
return this;
|
|
26
|
+
},
|
|
27
|
+
setVariant(variant) {
|
|
28
|
+
const PREFIX = component.config?.prefix || "mtrl";
|
|
29
|
+
const COMPONENT = component.config?.componentName || "textfield";
|
|
30
|
+
component.element.classList.remove(`${PREFIX}-${COMPONENT}--filled`, `${PREFIX}-${COMPONENT}--outlined`);
|
|
31
|
+
component.element.classList.add(`${PREFIX}-${COMPONENT}--${variant}`);
|
|
55
32
|
if (component.updateElementPositions) {
|
|
56
33
|
component.schedulePositionUpdate?.();
|
|
57
34
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
component.
|
|
64
|
-
|
|
65
|
-
component.schedulePositionUpdate?.();
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
getVariant() {
|
|
38
|
+
const PREFIX = component.config?.prefix || "mtrl";
|
|
39
|
+
const COMPONENT = component.config?.componentName || "textfield";
|
|
40
|
+
if (component.element.classList.contains(`${PREFIX}-${COMPONENT}--outlined`)) {
|
|
41
|
+
return "outlined";
|
|
66
42
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return component.trailingIcon ?? null;
|
|
72
|
-
},
|
|
73
|
-
setTrailingIcon(html) {
|
|
74
|
-
if (component.setTrailingIcon) {
|
|
75
|
-
component.setTrailingIcon(html);
|
|
43
|
+
return "filled";
|
|
44
|
+
},
|
|
45
|
+
setLabel(text) {
|
|
46
|
+
component.label?.setText(text);
|
|
76
47
|
if (component.updateElementPositions) {
|
|
77
48
|
component.schedulePositionUpdate?.();
|
|
78
49
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
return this;
|
|
51
|
+
},
|
|
52
|
+
getLabel() {
|
|
53
|
+
return component.label?.getText() || "";
|
|
54
|
+
},
|
|
55
|
+
get leadingIcon() {
|
|
56
|
+
return component.leadingIcon ?? null;
|
|
57
|
+
},
|
|
58
|
+
setLeadingIcon(html) {
|
|
59
|
+
if (component.setLeadingIcon) {
|
|
60
|
+
component.setLeadingIcon(html);
|
|
61
|
+
if (component.updateElementPositions) {
|
|
62
|
+
component.schedulePositionUpdate?.();
|
|
63
|
+
}
|
|
87
64
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
component.setSupportingText(text, isError);
|
|
97
|
-
}
|
|
98
|
-
return this;
|
|
99
|
-
},
|
|
100
|
-
removeSupportingText() {
|
|
101
|
-
if (component.removeSupportingText) {
|
|
102
|
-
component.removeSupportingText();
|
|
103
|
-
}
|
|
104
|
-
return this;
|
|
105
|
-
},
|
|
106
|
-
get prefixTextElement() {
|
|
107
|
-
return component.prefixTextElement ?? null;
|
|
108
|
-
},
|
|
109
|
-
setPrefixText(text) {
|
|
110
|
-
if (component.setPrefixText) {
|
|
111
|
-
component.setPrefixText(text);
|
|
112
|
-
if (component.updateElementPositions) {
|
|
113
|
-
component.schedulePositionUpdate?.();
|
|
65
|
+
return this;
|
|
66
|
+
},
|
|
67
|
+
removeLeadingIcon() {
|
|
68
|
+
if (component.removeLeadingIcon) {
|
|
69
|
+
component.removeLeadingIcon();
|
|
70
|
+
if (component.updateElementPositions) {
|
|
71
|
+
component.schedulePositionUpdate?.();
|
|
72
|
+
}
|
|
114
73
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (component.
|
|
122
|
-
component.
|
|
74
|
+
return this;
|
|
75
|
+
},
|
|
76
|
+
get trailingIcon() {
|
|
77
|
+
return component.trailingIcon ?? null;
|
|
78
|
+
},
|
|
79
|
+
setTrailingIcon(html, label) {
|
|
80
|
+
if (component.setTrailingIcon) {
|
|
81
|
+
component.setTrailingIcon(html, label);
|
|
82
|
+
if (component.updateElementPositions) {
|
|
83
|
+
component.schedulePositionUpdate?.();
|
|
84
|
+
}
|
|
123
85
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
86
|
+
return this;
|
|
87
|
+
},
|
|
88
|
+
removeTrailingIcon() {
|
|
89
|
+
if (component.removeTrailingIcon) {
|
|
90
|
+
component.removeTrailingIcon();
|
|
91
|
+
if (component.updateElementPositions) {
|
|
92
|
+
component.schedulePositionUpdate?.();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return this;
|
|
96
|
+
},
|
|
97
|
+
get supportingTextElement() {
|
|
98
|
+
return component.element.querySelector(`.${component.getClass("textfield__helper")}`);
|
|
99
|
+
},
|
|
100
|
+
setSupportingText(text, isError) {
|
|
101
|
+
if (component.setSupportingText) {
|
|
102
|
+
component.setSupportingText(text, isError);
|
|
103
|
+
}
|
|
104
|
+
return this;
|
|
105
|
+
},
|
|
106
|
+
removeSupportingText() {
|
|
107
|
+
if (component.removeSupportingText) {
|
|
108
|
+
component.removeSupportingText();
|
|
109
|
+
}
|
|
110
|
+
return this;
|
|
111
|
+
},
|
|
112
|
+
get prefixTextElement() {
|
|
113
|
+
return component.prefixTextElement ?? null;
|
|
114
|
+
},
|
|
115
|
+
setPrefixText(text) {
|
|
116
|
+
if (component.setPrefixText) {
|
|
117
|
+
component.setPrefixText(text);
|
|
118
|
+
if (component.updateElementPositions) {
|
|
119
|
+
component.schedulePositionUpdate?.();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return this;
|
|
123
|
+
},
|
|
124
|
+
removePrefixText() {
|
|
125
|
+
if (component.removePrefixText) {
|
|
126
|
+
component.removePrefixText();
|
|
127
|
+
if (component.updateElementPositions) {
|
|
128
|
+
component.schedulePositionUpdate?.();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return this;
|
|
132
|
+
},
|
|
133
|
+
get suffixTextElement() {
|
|
134
|
+
return component.suffixTextElement ?? null;
|
|
135
|
+
},
|
|
136
|
+
setSuffixText(text) {
|
|
137
|
+
if (component.setSuffixText) {
|
|
138
|
+
component.setSuffixText(text);
|
|
139
|
+
if (component.updateElementPositions) {
|
|
140
|
+
component.schedulePositionUpdate?.();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return this;
|
|
144
|
+
},
|
|
145
|
+
removeSuffixText() {
|
|
146
|
+
if (component.removeSuffixText) {
|
|
147
|
+
component.removeSuffixText();
|
|
148
|
+
if (component.updateElementPositions) {
|
|
149
|
+
component.schedulePositionUpdate?.();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return this;
|
|
153
|
+
},
|
|
154
|
+
updatePositions() {
|
|
155
|
+
if (component.input && component.element) {
|
|
156
|
+
const hasValue = component.input.value && component.input.value.length > 0;
|
|
157
|
+
const isAutofilled = component.input.matches?.(":-webkit-autofill") || false;
|
|
158
|
+
if (hasValue || isAutofilled) {
|
|
159
|
+
component.element.classList.remove(`${component.config?.prefix || "mtrl"}-textfield--empty`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
component.element.classList.add(`${component.config?.prefix || "mtrl"}-textfield--empty`);
|
|
163
|
+
}
|
|
135
164
|
}
|
|
136
|
-
}
|
|
137
|
-
return this;
|
|
138
|
-
},
|
|
139
|
-
removeSuffixText() {
|
|
140
|
-
if (component.removeSuffixText) {
|
|
141
|
-
component.removeSuffixText();
|
|
142
165
|
if (component.updateElementPositions) {
|
|
143
|
-
component.
|
|
166
|
+
component.updateElementPositions();
|
|
167
|
+
}
|
|
168
|
+
return this;
|
|
169
|
+
},
|
|
170
|
+
setError(error, message) {
|
|
171
|
+
if (component.setError) {
|
|
172
|
+
component.setError(error, message);
|
|
144
173
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
disable() {
|
|
195
|
-
disabled.disable();
|
|
196
|
-
return this;
|
|
197
|
-
},
|
|
198
|
-
destroy() {
|
|
199
|
-
lifecycle.destroy();
|
|
200
|
-
},
|
|
201
|
-
});
|
|
174
|
+
return this;
|
|
175
|
+
},
|
|
176
|
+
isError() {
|
|
177
|
+
return component.isError?.() || false;
|
|
178
|
+
},
|
|
179
|
+
setDensity(density) {
|
|
180
|
+
if (component.density?.set) {
|
|
181
|
+
component.density.set(density);
|
|
182
|
+
}
|
|
183
|
+
component.schedulePositionUpdate?.();
|
|
184
|
+
return this;
|
|
185
|
+
},
|
|
186
|
+
getDensity() {
|
|
187
|
+
return component.density?.current || "default";
|
|
188
|
+
},
|
|
189
|
+
on(event, handler) {
|
|
190
|
+
component.on?.(event, handler);
|
|
191
|
+
return this;
|
|
192
|
+
},
|
|
193
|
+
off(event, handler) {
|
|
194
|
+
component.off?.(event, handler);
|
|
195
|
+
return this;
|
|
196
|
+
},
|
|
197
|
+
enable() {
|
|
198
|
+
disabled.enable();
|
|
199
|
+
setTrailingDisabled(false);
|
|
200
|
+
return this;
|
|
201
|
+
},
|
|
202
|
+
isDisabled() {
|
|
203
|
+
return disabled.isDisabled();
|
|
204
|
+
},
|
|
205
|
+
disable() {
|
|
206
|
+
disabled.disable();
|
|
207
|
+
setTrailingDisabled(true);
|
|
208
|
+
return this;
|
|
209
|
+
},
|
|
210
|
+
setRequired(required) {
|
|
211
|
+
component.setRequired?.(required);
|
|
212
|
+
component.schedulePositionUpdate?.();
|
|
213
|
+
return this;
|
|
214
|
+
},
|
|
215
|
+
isRequired() {
|
|
216
|
+
return component.isRequired?.() ?? Boolean(component.input?.required);
|
|
217
|
+
},
|
|
218
|
+
destroy() {
|
|
219
|
+
lifecycle.destroy();
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createComponentConfig, createElementConfig, } from "../../core/config/component.js";
|
|
2
|
-
import {
|
|
2
|
+
import { TEXT_FIELD_DEFAULTS } from "./constants.js";
|
|
3
3
|
export const defaultConfig = {
|
|
4
|
-
type:
|
|
5
|
-
variant:
|
|
4
|
+
type: TEXT_FIELD_DEFAULTS.TYPE,
|
|
5
|
+
variant: TEXT_FIELD_DEFAULTS.VARIANT,
|
|
6
6
|
};
|
|
7
7
|
export const createBaseConfig = (config = {}) => createComponentConfig(defaultConfig, config, "textfield");
|
|
8
8
|
export const getElementConfig = (config) => createElementConfig(config, {
|
|
@@ -13,6 +13,7 @@ export const getApiConfig = (comp) => ({
|
|
|
13
13
|
disabled: {
|
|
14
14
|
enable: comp.disabled.enable,
|
|
15
15
|
disable: comp.disabled.disable,
|
|
16
|
+
isDisabled: comp.disabled.isDisabled,
|
|
16
17
|
},
|
|
17
18
|
lifecycle: {
|
|
18
19
|
destroy: comp.lifecycle.destroy,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Textfield variant constants
|
|
3
3
|
* @category Components
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
declare const TEXTFIELD_VARIANTS: {
|
|
6
6
|
/** Filled variant with background and animated label */
|
|
7
7
|
readonly FILLED: "filled";
|
|
8
8
|
/** Outlined variant with border and animated label */
|
|
@@ -12,7 +12,7 @@ export declare const TEXTFIELD_VARIANTS: {
|
|
|
12
12
|
* Textfield state constants
|
|
13
13
|
* @category Components
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
declare const TEXTFIELD_STATES: {
|
|
16
16
|
/** Textfield is active (focused) */
|
|
17
17
|
readonly ACTIVE: "active";
|
|
18
18
|
/** Textfield is inactive (not focused) */
|
|
@@ -24,7 +24,7 @@ export declare const TEXTFIELD_STATES: {
|
|
|
24
24
|
* Textfield type constants
|
|
25
25
|
* @category Components
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
declare const TEXTFIELD_TYPES: {
|
|
28
28
|
/** Standard text input */
|
|
29
29
|
readonly TEXT: "text";
|
|
30
30
|
/** Password input with obscured characters */
|
|
@@ -46,7 +46,7 @@ export declare const TEXTFIELD_TYPES: {
|
|
|
46
46
|
* Textfield event constants
|
|
47
47
|
* @category Components
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
declare const TEXTFIELD_EVENTS: {
|
|
50
50
|
/** Emitted on native input change; setValue() is silent */
|
|
51
51
|
readonly CHANGE: "change";
|
|
52
52
|
/** Fired during input */
|
|
@@ -55,6 +55,8 @@ export declare const TEXTFIELD_EVENTS: {
|
|
|
55
55
|
readonly FOCUS: "focus";
|
|
56
56
|
/** Fired when textfield loses focus */
|
|
57
57
|
readonly BLUR: "blur";
|
|
58
|
+
/** Fired when the trailing icon button is activated (`trailingIconLabel`; FLO-301) */
|
|
59
|
+
readonly TRAILING: "trailing";
|
|
58
60
|
/** Legacy name, not emitted; listen for keydown on the input and check key === "Enter" */
|
|
59
61
|
readonly ENTER: "enter";
|
|
60
62
|
/** Native input event only; not emitted through on() */
|
|
@@ -66,7 +68,7 @@ export declare const TEXTFIELD_EVENTS: {
|
|
|
66
68
|
* Textfield density constants
|
|
67
69
|
* @category Components
|
|
68
70
|
*/
|
|
69
|
-
|
|
71
|
+
declare const TEXTFIELD_DENSITY: {
|
|
70
72
|
/** Default density (56px height) */
|
|
71
73
|
readonly DEFAULT: "default";
|
|
72
74
|
/** Compact density (40px height) */
|
|
@@ -76,7 +78,7 @@ export declare const TEXTFIELD_DENSITY: {
|
|
|
76
78
|
* Default textfield configuration values
|
|
77
79
|
* @category Components
|
|
78
80
|
*/
|
|
79
|
-
|
|
81
|
+
declare const TEXTFIELD_DEFAULTS: {
|
|
80
82
|
/** Default input type */
|
|
81
83
|
readonly TYPE: "text";
|
|
82
84
|
/** Default visual variant */
|
|
@@ -98,7 +100,7 @@ export declare const TEXTFIELD_DEFAULTS: {
|
|
|
98
100
|
* CSS class names used by the textfield component
|
|
99
101
|
* @category Components
|
|
100
102
|
*/
|
|
101
|
-
|
|
103
|
+
declare const TEXTFIELD_CLASSES: {
|
|
102
104
|
/** Root element class */
|
|
103
105
|
readonly ROOT: "textfield";
|
|
104
106
|
/** Input element class */
|
|
@@ -152,3 +154,18 @@ export declare const TEXTFIELD_CLASSES: {
|
|
|
152
154
|
/** Multiline class */
|
|
153
155
|
readonly MULTILINE: "textfield--multiline";
|
|
154
156
|
};
|
|
157
|
+
export { TEXTFIELD_VARIANTS as TEXT_FIELD_VARIANTS, TEXTFIELD_STATES as TEXT_FIELD_STATES, TEXTFIELD_TYPES as TEXT_FIELD_TYPES, TEXTFIELD_EVENTS as TEXT_FIELD_EVENTS, TEXTFIELD_DENSITY as TEXT_FIELD_DENSITY, TEXTFIELD_DEFAULTS as TEXT_FIELD_DEFAULTS, TEXTFIELD_CLASSES as TEXT_FIELD_CLASSES,
|
|
158
|
+
/** @deprecated Use TEXT_FIELD_VARIANTS: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
159
|
+
TEXTFIELD_VARIANTS,
|
|
160
|
+
/** @deprecated Use TEXT_FIELD_STATES: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
161
|
+
TEXTFIELD_STATES,
|
|
162
|
+
/** @deprecated Use TEXT_FIELD_TYPES: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
163
|
+
TEXTFIELD_TYPES,
|
|
164
|
+
/** @deprecated Use TEXT_FIELD_EVENTS: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
165
|
+
TEXTFIELD_EVENTS,
|
|
166
|
+
/** @deprecated Use TEXT_FIELD_DENSITY: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
167
|
+
TEXTFIELD_DENSITY,
|
|
168
|
+
/** @deprecated Use TEXT_FIELD_DEFAULTS: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
169
|
+
TEXTFIELD_DEFAULTS,
|
|
170
|
+
/** @deprecated Use TEXT_FIELD_CLASSES: M3 writes "text field" as two words. Removed in 1.0 (FLO-383). */
|
|
171
|
+
TEXTFIELD_CLASSES, };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
const TEXTFIELD_VARIANTS = {
|
|
2
2
|
FILLED: "filled",
|
|
3
3
|
OUTLINED: "outlined",
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
const TEXTFIELD_STATES = {
|
|
6
6
|
ACTIVE: "active",
|
|
7
7
|
INACTIVE: "inactive",
|
|
8
8
|
DISABLED: "disabled",
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
const TEXTFIELD_TYPES = {
|
|
11
11
|
TEXT: "text",
|
|
12
12
|
PASSWORD: "password",
|
|
13
13
|
EMAIL: "email",
|
|
@@ -17,20 +17,21 @@ export const TEXTFIELD_TYPES = {
|
|
|
17
17
|
SEARCH: "search",
|
|
18
18
|
MULTILINE: "multiline",
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
const TEXTFIELD_EVENTS = {
|
|
21
21
|
CHANGE: "change",
|
|
22
22
|
INPUT: "input",
|
|
23
23
|
FOCUS: "focus",
|
|
24
24
|
BLUR: "blur",
|
|
25
|
+
TRAILING: "trailing",
|
|
25
26
|
ENTER: "enter",
|
|
26
27
|
KEYDOWN: "keydown",
|
|
27
28
|
KEYUP: "keyup",
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
+
const TEXTFIELD_DENSITY = {
|
|
30
31
|
DEFAULT: "default",
|
|
31
32
|
COMPACT: "compact",
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
+
const TEXTFIELD_DEFAULTS = {
|
|
34
35
|
TYPE: TEXTFIELD_TYPES.TEXT,
|
|
35
36
|
VARIANT: TEXTFIELD_VARIANTS.FILLED,
|
|
36
37
|
DENSITY: TEXTFIELD_DENSITY.DEFAULT,
|
|
@@ -40,7 +41,7 @@ export const TEXTFIELD_DEFAULTS = {
|
|
|
40
41
|
FLOAT_LABEL: true,
|
|
41
42
|
ANIMATION_DURATION: 150,
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
const TEXTFIELD_CLASSES = {
|
|
44
45
|
ROOT: "textfield",
|
|
45
46
|
INPUT: "textfield__input",
|
|
46
47
|
LABEL: "textfield__label",
|
|
@@ -66,3 +67,4 @@ export const TEXTFIELD_CLASSES = {
|
|
|
66
67
|
RTL: "textfield--rtl",
|
|
67
68
|
MULTILINE: "textfield--multiline",
|
|
68
69
|
};
|
|
70
|
+
export { TEXTFIELD_VARIANTS as TEXT_FIELD_VARIANTS, TEXTFIELD_STATES as TEXT_FIELD_STATES, TEXTFIELD_TYPES as TEXT_FIELD_TYPES, TEXTFIELD_EVENTS as TEXT_FIELD_EVENTS, TEXTFIELD_DENSITY as TEXT_FIELD_DENSITY, TEXTFIELD_DEFAULTS as TEXT_FIELD_DEFAULTS, TEXTFIELD_CLASSES as TEXT_FIELD_CLASSES, TEXTFIELD_VARIANTS, TEXTFIELD_STATES, TEXTFIELD_TYPES, TEXTFIELD_EVENTS, TEXTFIELD_DENSITY, TEXTFIELD_DEFAULTS, TEXTFIELD_CLASSES, };
|
|
@@ -8,8 +8,10 @@ export { withDensity } from "./density.js";
|
|
|
8
8
|
export { withError } from "./error.js";
|
|
9
9
|
export { withField } from "./field.js";
|
|
10
10
|
export { withCounter } from "./counter.js";
|
|
11
|
+
export { withRequired } from "./required.js";
|
|
11
12
|
export type { LeadingIconComponent, LeadingIconConfig } from "./leading-icon.js";
|
|
12
|
-
export type { TrailingIconComponent, TrailingIconConfig, } from "./trailing-icon.js";
|
|
13
|
+
export type { TrailingIconComponent, TrailingIconConfig, TextfieldTrailingPayload, } from "./trailing-icon.js";
|
|
14
|
+
export type { RequiredConfig, RequiredFeature } from "./required.js";
|
|
13
15
|
export type { PrefixTextComponent, PrefixTextConfig } from "./prefix-text.js";
|
|
14
16
|
export type { SuffixTextComponent, SuffixTextConfig } from "./suffix-text.js";
|
|
15
17
|
export type { SupportingTextComponent, SupportingTextConfig, } from "./supporting-text.js";
|
|
@@ -9,6 +9,7 @@ export const withLeadingIcon = (config) => (component) => {
|
|
|
9
9
|
return iconElement;
|
|
10
10
|
const element = document.createElement('span');
|
|
11
11
|
element.className = `${PREFIX}-${NAME}__leading-icon`;
|
|
12
|
+
element.setAttribute('aria-hidden', 'true');
|
|
12
13
|
fieldOf(component).appendChild(element);
|
|
13
14
|
component.element.classList.add(`${PREFIX}-${NAME}--with-leading-icon`);
|
|
14
15
|
if (component.input) {
|
|
@@ -18,9 +18,17 @@ export const withPlacement = () => (component) => {
|
|
|
18
18
|
const PREFIX = component.config.prefix || "mtrl";
|
|
19
19
|
const COMPONENT = component.config.componentName || "textfield";
|
|
20
20
|
let destroyed = false;
|
|
21
|
+
let listening = false;
|
|
22
|
+
const ensureListening = () => {
|
|
23
|
+
if (listening || destroyed)
|
|
24
|
+
return;
|
|
25
|
+
listening = true;
|
|
26
|
+
setupEventListeners();
|
|
27
|
+
};
|
|
21
28
|
const schedulePositionUpdate = () => {
|
|
22
29
|
if (destroyed)
|
|
23
30
|
return;
|
|
31
|
+
ensureListening();
|
|
24
32
|
schedule(measure);
|
|
25
33
|
};
|
|
26
34
|
const classObservers = new WeakMap();
|
|
@@ -97,6 +105,7 @@ export const withPlacement = () => (component) => {
|
|
|
97
105
|
};
|
|
98
106
|
};
|
|
99
107
|
const updateElementPositions = () => {
|
|
108
|
+
ensureListening();
|
|
100
109
|
measure()();
|
|
101
110
|
return component;
|
|
102
111
|
};
|
|
@@ -121,8 +130,12 @@ export const withPlacement = () => (component) => {
|
|
|
121
130
|
labelObserver.observe(labelEl);
|
|
122
131
|
}
|
|
123
132
|
};
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
const has = (modifier) => component.element.classList.contains(`${PREFIX}-${COMPONENT}--${modifier}`);
|
|
134
|
+
const needsPlacement = has("outlined") ||
|
|
135
|
+
has("with-leading-icon") ||
|
|
136
|
+
component.element.querySelector(`.${PREFIX}-${COMPONENT}__prefix, .${PREFIX}-${COMPONENT}__suffix`) !== null;
|
|
137
|
+
if (needsPlacement)
|
|
138
|
+
schedulePositionUpdate();
|
|
126
139
|
if ("lifecycle" in component && component.lifecycle?.destroy) {
|
|
127
140
|
const originalDestroy = component.lifecycle.destroy;
|
|
128
141
|
component.lifecycle.destroy = () => {
|