material 3.1.0 → 3.2.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 +3 -3
- package/dist/components/tabs/tab.js +8 -1
- package/dist/components/text-field/api.d.ts +2 -0
- package/dist/components/text-field/api.js +54 -63
- package/dist/core/shapes/material.js +0 -85
- package/dist/elements/button-group.d.ts +1 -0
- package/dist/elements/button-group.js +1 -0
- package/dist/elements/button.js +1 -1
- package/dist/elements/checkbox.d.ts +1 -0
- package/dist/elements/checkbox.js +1 -0
- package/dist/elements/css/hosts/badge.css +1 -1
- package/dist/elements/css/hosts/bottom-app-bar.css +1 -1
- package/dist/elements/css/hosts/bottom-sheet.css +1 -1
- package/dist/elements/css/hosts/button-group.css +1 -1
- package/dist/elements/css/hosts/button.css +1 -1
- package/dist/elements/css/hosts/card.css +1 -1
- package/dist/elements/css/hosts/carousel.css +1 -1
- package/dist/elements/css/hosts/checkbox.css +1 -1
- package/dist/elements/css/hosts/chips.css +1 -1
- package/dist/elements/css/hosts/datepicker.css +1 -1
- package/dist/elements/css/hosts/dialog.css +1 -1
- package/dist/elements/css/hosts/divider.css +1 -1
- package/dist/elements/css/hosts/drawer.css +1 -1
- package/dist/elements/css/hosts/icon-button.css +1 -1
- package/dist/elements/css/hosts/list.css +1 -1
- package/dist/elements/css/hosts/loading-indicator.css +1 -1
- package/dist/elements/css/hosts/menu.css +1 -1
- package/dist/elements/css/hosts/navigation-bar.css +1 -1
- package/dist/elements/css/hosts/navigation-rail.css +1 -1
- package/dist/elements/css/hosts/progress.css +1 -1
- package/dist/elements/css/hosts/radios.css +1 -1
- package/dist/elements/css/hosts/search.css +1 -1
- package/dist/elements/css/hosts/select.css +1 -1
- package/dist/elements/css/hosts/side-sheet.css +1 -1
- package/dist/elements/css/hosts/slider.css +1 -1
- package/dist/elements/css/hosts/snackbar.css +1 -1
- package/dist/elements/css/hosts/split-button.css +1 -1
- package/dist/elements/css/hosts/switch.css +1 -1
- package/dist/elements/css/hosts/tabs.css +1 -1
- package/dist/elements/css/hosts/timepicker.css +1 -1
- package/dist/elements/css/hosts/toolbar.css +1 -1
- package/dist/elements/css/hosts/tooltip.css +1 -1
- package/dist/elements/css/hosts/top-app-bar.css +1 -1
- package/dist/elements/css/tabs.css +1 -1
- package/dist/elements/css/tabs.js +1 -1
- package/dist/elements/datepicker.d.ts +1 -0
- package/dist/elements/datepicker.js +1 -0
- package/dist/elements/define.d.ts +8 -7
- package/dist/elements/define.js +77 -2
- package/dist/elements/icon-button.js +1 -1
- package/dist/elements/index.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/elements/preupgrade.js +1 -1
- package/dist/elements/select.js +1 -1
- package/dist/elements/split-button.d.ts +29 -12
- package/dist/elements/split-button.js +22 -3
- package/dist/elements/tabs.js +3 -1
- package/dist/elements/text-field.js +15 -0
- package/dist/package.json +1 -1
- package/dist/react/badge.js +0 -2
- package/dist/react/bottom-app-bar.js +0 -2
- package/dist/react/bottom-sheet.js +0 -2
- package/dist/react/button-group-item.js +0 -2
- package/dist/react/button-group.js +0 -2
- package/dist/react/button.js +0 -2
- package/dist/react/card.js +0 -2
- package/dist/react/carousel-item.js +0 -2
- package/dist/react/carousel.js +0 -2
- package/dist/react/checkbox.js +0 -2
- package/dist/react/chip.js +0 -2
- package/dist/react/chips.js +0 -2
- package/dist/react/datepicker.js +0 -2
- package/dist/react/dialog.js +0 -2
- package/dist/react/divider.js +0 -2
- package/dist/react/drawer-item.js +0 -2
- package/dist/react/drawer.js +0 -2
- package/dist/react/extended-fab.js +0 -2
- package/dist/react/fab-menu-item.js +0 -2
- package/dist/react/fab-menu.js +0 -2
- package/dist/react/fab.js +0 -2
- package/dist/react/icon-button.js +0 -2
- package/dist/react/list-item.js +0 -2
- package/dist/react/list.js +0 -2
- package/dist/react/loading-indicator.js +0 -2
- package/dist/react/menu-item.js +0 -2
- package/dist/react/menu.js +0 -2
- package/dist/react/navigation-bar-item.js +0 -2
- package/dist/react/navigation-bar.js +0 -2
- package/dist/react/navigation-rail-item.js +0 -2
- package/dist/react/navigation-rail.js +0 -2
- package/dist/react/progress.js +0 -2
- package/dist/react/radio.js +0 -2
- package/dist/react/radios.js +0 -2
- package/dist/react/search-suggestion.js +0 -2
- package/dist/react/search.js +0 -2
- package/dist/react/select-option.js +0 -2
- package/dist/react/select.js +0 -2
- package/dist/react/side-sheet.js +0 -2
- package/dist/react/slider.js +0 -2
- package/dist/react/snackbar.js +0 -2
- package/dist/react/split-button.js +0 -2
- package/dist/react/switch.js +0 -2
- package/dist/react/tab.js +0 -2
- package/dist/react/tabs.js +0 -2
- package/dist/react/text-field.js +0 -2
- package/dist/react/timepicker.js +0 -2
- package/dist/react/toolbar.js +0 -2
- package/dist/react/tooltip.js +0 -2
- package/dist/react/top-app-bar.js +0 -2
- package/dist/solid/badge.js +0 -2
- package/dist/solid/bottom-app-bar.js +0 -2
- package/dist/solid/bottom-sheet.js +0 -2
- package/dist/solid/button-group-item.js +0 -2
- package/dist/solid/button-group.js +0 -2
- package/dist/solid/button.js +0 -2
- package/dist/solid/card.js +0 -2
- package/dist/solid/carousel-item.js +0 -2
- package/dist/solid/carousel.js +0 -2
- package/dist/solid/checkbox.js +0 -2
- package/dist/solid/chip.js +0 -2
- package/dist/solid/chips.js +0 -2
- package/dist/solid/datepicker.js +0 -2
- package/dist/solid/dialog.js +0 -2
- package/dist/solid/divider.js +0 -2
- package/dist/solid/drawer-item.js +0 -2
- package/dist/solid/drawer.js +0 -2
- package/dist/solid/extended-fab.js +0 -2
- package/dist/solid/fab-menu-item.js +0 -2
- package/dist/solid/fab-menu.js +0 -2
- package/dist/solid/fab.js +0 -2
- package/dist/solid/icon-button.js +0 -2
- package/dist/solid/jsx.d.ts +2 -2
- package/dist/solid/list-item.js +0 -2
- package/dist/solid/list.js +0 -2
- package/dist/solid/loading-indicator.js +0 -2
- package/dist/solid/menu-item.js +0 -2
- package/dist/solid/menu.js +0 -2
- package/dist/solid/navigation-bar-item.js +0 -2
- package/dist/solid/navigation-bar.js +0 -2
- package/dist/solid/navigation-rail-item.js +0 -2
- package/dist/solid/navigation-rail.js +0 -2
- package/dist/solid/progress.js +0 -2
- package/dist/solid/radio.js +0 -2
- package/dist/solid/radios.js +0 -2
- package/dist/solid/search-suggestion.js +0 -2
- package/dist/solid/search.js +0 -2
- package/dist/solid/select-option.js +0 -2
- package/dist/solid/select.js +0 -2
- package/dist/solid/side-sheet.js +0 -2
- package/dist/solid/slider.js +0 -2
- package/dist/solid/snackbar.js +0 -2
- package/dist/solid/split-button.js +0 -2
- package/dist/solid/switch.js +0 -2
- package/dist/solid/tab.js +0 -2
- package/dist/solid/tabs.js +0 -2
- package/dist/solid/text-field.js +0 -2
- package/dist/solid/timepicker.js +0 -2
- package/dist/solid/toolbar.js +0 -2
- package/dist/solid/tooltip.js +0 -2
- package/dist/solid/top-app-bar.js +0 -2
- 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/contrast.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-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 +1 -1
- package/dist/styles/tabs.css +2 -2
- 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 +2 -2
- 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/dist/vue/badge.js +0 -2
- package/dist/vue/bottom-app-bar.js +0 -2
- package/dist/vue/bottom-sheet.js +0 -2
- package/dist/vue/button-group-item.js +0 -2
- package/dist/vue/button-group.js +0 -2
- package/dist/vue/button.js +0 -2
- package/dist/vue/card.js +0 -2
- package/dist/vue/carousel-item.js +0 -2
- package/dist/vue/carousel.js +0 -2
- package/dist/vue/checkbox.js +0 -2
- package/dist/vue/chip.js +0 -2
- package/dist/vue/chips.js +0 -2
- package/dist/vue/datepicker.js +0 -2
- package/dist/vue/dialog.js +0 -2
- package/dist/vue/divider.js +0 -2
- package/dist/vue/drawer-item.js +0 -2
- package/dist/vue/drawer.js +0 -2
- package/dist/vue/extended-fab.js +0 -2
- package/dist/vue/fab-menu-item.js +0 -2
- package/dist/vue/fab-menu.js +0 -2
- package/dist/vue/fab.js +0 -2
- package/dist/vue/icon-button.js +0 -2
- package/dist/vue/list-item.js +0 -2
- package/dist/vue/list.js +0 -2
- package/dist/vue/loading-indicator.js +0 -2
- package/dist/vue/menu-item.js +0 -2
- package/dist/vue/menu.js +0 -2
- package/dist/vue/navigation-bar-item.js +0 -2
- package/dist/vue/navigation-bar.js +0 -2
- package/dist/vue/navigation-rail-item.js +0 -2
- package/dist/vue/navigation-rail.js +0 -2
- package/dist/vue/progress.js +0 -2
- package/dist/vue/radio.js +0 -2
- package/dist/vue/radios.js +0 -2
- package/dist/vue/search-suggestion.js +0 -2
- package/dist/vue/search.js +0 -2
- package/dist/vue/select-option.js +0 -2
- package/dist/vue/select.js +0 -2
- package/dist/vue/side-sheet.js +0 -2
- package/dist/vue/slider.js +0 -2
- package/dist/vue/snackbar.js +0 -2
- package/dist/vue/split-button.js +0 -2
- package/dist/vue/switch.js +0 -2
- package/dist/vue/tab.js +0 -2
- package/dist/vue/tabs.js +0 -2
- package/dist/vue/text-field.js +0 -2
- package/dist/vue/timepicker.js +0 -2
- package/dist/vue/toolbar.js +0 -2
- package/dist/vue/tooltip.js +0 -2
- package/dist/vue/top-app-bar.js +0 -2
- package/package.json +1 -1
- package/src/styles/components/_tabs.scss +20 -11
- package/src/styles/elements/_button-group.scss +87 -24
- package/src/styles/elements/_datepicker.scss +1 -1
- package/src/styles/themes/_baseline.scss +13 -4
package/README.md
CHANGED
|
@@ -93,11 +93,11 @@ 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.4 kB |
|
|
95
95
|
| `createButton`, without code splitting (the progress indicator included) | 13.7 kB |
|
|
96
|
-
| `createButton`, `createTextField` and `createCheckbox`, without code splitting |
|
|
97
|
-
| Everything the root exports (`export * from 'material'`), without code splitting | 127.
|
|
96
|
+
| `createButton`, `createTextField` and `createCheckbox`, without code splitting | 20.0 kB |
|
|
97
|
+
| Everything the root exports (`export * from 'material'`), without code splitting | 127.1 kB |
|
|
98
98
|
| `material/styles/base` | 2.9 kB |
|
|
99
99
|
| `material/styles/base` and `material/styles/button` | 5.2 kB |
|
|
100
|
-
| `material/styles`, the full stylesheet | 62.
|
|
100
|
+
| `material/styles`, the full stylesheet | 62.8 kB |
|
|
101
101
|
<!-- /sizes -->
|
|
102
102
|
|
|
103
103
|
`material` publishes ESM only, so bundlers drop what you do not import. Each component's page on [md3.io/components](https://md3.io/components/) gives its size.
|
|
@@ -49,6 +49,7 @@ export const createTab = (config = {}) => {
|
|
|
49
49
|
for (const type of ["focus", "blur"]) {
|
|
50
50
|
button.element.addEventListener(type, (event) => baseComponent.emit?.(type, event));
|
|
51
51
|
}
|
|
52
|
+
const badgeAnchor = () => button.element.querySelector(`.${baseComponent.getClass("button__icon")},.${baseComponent.getClass("button__text")}`) ?? button.element;
|
|
52
53
|
const tab = {
|
|
53
54
|
...baseComponent,
|
|
54
55
|
button,
|
|
@@ -125,7 +126,7 @@ export const createTab = (config = {}) => {
|
|
|
125
126
|
const badgeConfig = {
|
|
126
127
|
label: content,
|
|
127
128
|
standalone: false,
|
|
128
|
-
target:
|
|
129
|
+
target: badgeAnchor(),
|
|
129
130
|
prefix: baseConfig.prefix,
|
|
130
131
|
...(baseConfig.badgeConfig || {}),
|
|
131
132
|
};
|
|
@@ -184,6 +185,12 @@ export const createTab = (config = {}) => {
|
|
|
184
185
|
this.element.classList.remove(`${this.getClass("tab")}--${layout}`);
|
|
185
186
|
});
|
|
186
187
|
this.element.classList.add(`${this.getClass("tab")}--${layoutClass}`);
|
|
188
|
+
const wrapper = this.badge?.wrapper;
|
|
189
|
+
const anchor = badgeAnchor();
|
|
190
|
+
if (wrapper && anchor !== this.element && wrapper.firstElementChild !== anchor) {
|
|
191
|
+
wrapper.replaceWith(...wrapper.childNodes);
|
|
192
|
+
this.badge?.attachTo(anchor);
|
|
193
|
+
}
|
|
187
194
|
},
|
|
188
195
|
};
|
|
189
196
|
if (baseConfig.badge !== undefined) {
|
|
@@ -24,4 +24,6 @@ type ComponentWithDensity = BaseComponent & {
|
|
|
24
24
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
25
25
|
*/
|
|
26
26
|
export declare const withAPI: ({ disabled, lifecycle }: ApiOptions) => (component: ComponentWithDensity) => TextFieldComponent;
|
|
27
|
+
/** Development diagnostic, shared by the factory and its element host. */
|
|
28
|
+
export declare const checkTrailingLabel: (element: HTMLElement) => void;
|
|
27
29
|
export {};
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import { warnDev } from "../../core/utils/warn.js";
|
|
1
2
|
export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
3
|
+
const element = component.element;
|
|
4
|
+
const classes = element.classList;
|
|
5
|
+
const fieldClass = component.getClass("text-field");
|
|
6
|
+
const variantClass = (variant) => `${fieldClass}--${variant}`;
|
|
7
|
+
const schedulePlacement = () => {
|
|
8
|
+
if (component.updateElementPositions)
|
|
9
|
+
component.schedulePositionUpdate?.();
|
|
10
|
+
};
|
|
2
11
|
const setTrailingDisabled = (off) => {
|
|
3
12
|
const icon = component.trailingIcon;
|
|
4
13
|
if (icon?.tagName === "BUTTON")
|
|
5
14
|
icon.disabled = off;
|
|
6
15
|
};
|
|
7
16
|
return {
|
|
8
|
-
element:
|
|
9
|
-
field: component.field ??
|
|
17
|
+
element: element,
|
|
18
|
+
field: component.field ?? element,
|
|
10
19
|
input: component.input,
|
|
11
20
|
getValue: component.getValue || (() => ""),
|
|
12
21
|
setValue(value) {
|
|
@@ -25,28 +34,20 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
25
34
|
return this;
|
|
26
35
|
},
|
|
27
36
|
setVariant(variant) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
component.element.classList.add(`${PREFIX}-${COMPONENT}--${variant}`);
|
|
32
|
-
if (component.updateElementPositions) {
|
|
33
|
-
component.schedulePositionUpdate?.();
|
|
34
|
-
}
|
|
37
|
+
classes.remove(variantClass("filled"), variantClass("outlined"));
|
|
38
|
+
classes.add(variantClass(variant));
|
|
39
|
+
schedulePlacement();
|
|
35
40
|
return this;
|
|
36
41
|
},
|
|
37
42
|
getVariant() {
|
|
38
|
-
|
|
39
|
-
const COMPONENT = component.config?.componentName || "text-field";
|
|
40
|
-
if (component.element.classList.contains(`${PREFIX}-${COMPONENT}--outlined`)) {
|
|
43
|
+
if (classes.contains(variantClass("outlined"))) {
|
|
41
44
|
return "outlined";
|
|
42
45
|
}
|
|
43
46
|
return "filled";
|
|
44
47
|
},
|
|
45
48
|
setLabel(text) {
|
|
46
49
|
component.label?.setText(text);
|
|
47
|
-
|
|
48
|
-
component.schedulePositionUpdate?.();
|
|
49
|
-
}
|
|
50
|
+
schedulePlacement();
|
|
50
51
|
return this;
|
|
51
52
|
},
|
|
52
53
|
getLabel() {
|
|
@@ -58,18 +59,14 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
58
59
|
setLeadingIcon(html) {
|
|
59
60
|
if (component.setLeadingIcon) {
|
|
60
61
|
component.setLeadingIcon(html);
|
|
61
|
-
|
|
62
|
-
component.schedulePositionUpdate?.();
|
|
63
|
-
}
|
|
62
|
+
schedulePlacement();
|
|
64
63
|
}
|
|
65
64
|
return this;
|
|
66
65
|
},
|
|
67
66
|
removeLeadingIcon() {
|
|
68
67
|
if (component.removeLeadingIcon) {
|
|
69
68
|
component.removeLeadingIcon();
|
|
70
|
-
|
|
71
|
-
component.schedulePositionUpdate?.();
|
|
72
|
-
}
|
|
69
|
+
schedulePlacement();
|
|
73
70
|
}
|
|
74
71
|
return this;
|
|
75
72
|
},
|
|
@@ -79,34 +76,26 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
79
76
|
setTrailingIcon(html, label) {
|
|
80
77
|
if (component.setTrailingIcon) {
|
|
81
78
|
component.setTrailingIcon(html, label);
|
|
82
|
-
|
|
83
|
-
component.schedulePositionUpdate?.();
|
|
84
|
-
}
|
|
79
|
+
schedulePlacement();
|
|
85
80
|
}
|
|
86
81
|
return this;
|
|
87
82
|
},
|
|
88
83
|
removeTrailingIcon() {
|
|
89
84
|
if (component.removeTrailingIcon) {
|
|
90
85
|
component.removeTrailingIcon();
|
|
91
|
-
|
|
92
|
-
component.schedulePositionUpdate?.();
|
|
93
|
-
}
|
|
86
|
+
schedulePlacement();
|
|
94
87
|
}
|
|
95
88
|
return this;
|
|
96
89
|
},
|
|
97
90
|
get supportingTextElement() {
|
|
98
|
-
return
|
|
91
|
+
return element.querySelector(`.${component.getClass("text-field__helper")}`);
|
|
99
92
|
},
|
|
100
93
|
setSupportingText(text, isError) {
|
|
101
|
-
|
|
102
|
-
component.setSupportingText(text, isError);
|
|
103
|
-
}
|
|
94
|
+
component.setSupportingText?.(text, isError);
|
|
104
95
|
return this;
|
|
105
96
|
},
|
|
106
97
|
removeSupportingText() {
|
|
107
|
-
|
|
108
|
-
component.removeSupportingText();
|
|
109
|
-
}
|
|
98
|
+
component.removeSupportingText?.();
|
|
110
99
|
return this;
|
|
111
100
|
},
|
|
112
101
|
get prefixTextElement() {
|
|
@@ -115,18 +104,14 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
115
104
|
setPrefixText(text) {
|
|
116
105
|
if (component.setPrefixText) {
|
|
117
106
|
component.setPrefixText(text);
|
|
118
|
-
|
|
119
|
-
component.schedulePositionUpdate?.();
|
|
120
|
-
}
|
|
107
|
+
schedulePlacement();
|
|
121
108
|
}
|
|
122
109
|
return this;
|
|
123
110
|
},
|
|
124
111
|
removePrefixText() {
|
|
125
112
|
if (component.removePrefixText) {
|
|
126
113
|
component.removePrefixText();
|
|
127
|
-
|
|
128
|
-
component.schedulePositionUpdate?.();
|
|
129
|
-
}
|
|
114
|
+
schedulePlacement();
|
|
130
115
|
}
|
|
131
116
|
return this;
|
|
132
117
|
},
|
|
@@ -136,55 +121,40 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
136
121
|
setSuffixText(text) {
|
|
137
122
|
if (component.setSuffixText) {
|
|
138
123
|
component.setSuffixText(text);
|
|
139
|
-
|
|
140
|
-
component.schedulePositionUpdate?.();
|
|
141
|
-
}
|
|
124
|
+
schedulePlacement();
|
|
142
125
|
}
|
|
143
126
|
return this;
|
|
144
127
|
},
|
|
145
128
|
removeSuffixText() {
|
|
146
129
|
if (component.removeSuffixText) {
|
|
147
130
|
component.removeSuffixText();
|
|
148
|
-
|
|
149
|
-
component.schedulePositionUpdate?.();
|
|
150
|
-
}
|
|
131
|
+
schedulePlacement();
|
|
151
132
|
}
|
|
152
133
|
return this;
|
|
153
134
|
},
|
|
154
135
|
updatePositions() {
|
|
155
|
-
if (component.input
|
|
156
|
-
const hasValue = component.input.value
|
|
136
|
+
if (component.input) {
|
|
137
|
+
const hasValue = component.input.value;
|
|
157
138
|
let isAutofilled = false;
|
|
158
139
|
try {
|
|
159
140
|
isAutofilled = component.input.matches?.(":-webkit-autofill") || false;
|
|
160
141
|
}
|
|
161
142
|
catch {
|
|
162
143
|
}
|
|
163
|
-
|
|
164
|
-
component.element.classList.remove(`${component.config?.prefix || "mtrl"}-text-field--empty`);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
component.element.classList.add(`${component.config?.prefix || "mtrl"}-text-field--empty`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (component.updateElementPositions) {
|
|
171
|
-
component.updateElementPositions();
|
|
144
|
+
classes.toggle(`${fieldClass}--empty`, !(hasValue || isAutofilled));
|
|
172
145
|
}
|
|
146
|
+
component.updateElementPositions?.();
|
|
173
147
|
return this;
|
|
174
148
|
},
|
|
175
149
|
setError(error, message) {
|
|
176
|
-
|
|
177
|
-
component.setError(error, message);
|
|
178
|
-
}
|
|
150
|
+
component.setError?.(error, message);
|
|
179
151
|
return this;
|
|
180
152
|
},
|
|
181
153
|
isError() {
|
|
182
154
|
return component.isError?.() || false;
|
|
183
155
|
},
|
|
184
156
|
setDensity(density) {
|
|
185
|
-
|
|
186
|
-
component.density.set(density);
|
|
187
|
-
}
|
|
157
|
+
component.density?.set?.(density);
|
|
188
158
|
component.schedulePositionUpdate?.();
|
|
189
159
|
return this;
|
|
190
160
|
},
|
|
@@ -193,6 +163,20 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
193
163
|
},
|
|
194
164
|
on(event, handler) {
|
|
195
165
|
component.on?.(event, handler);
|
|
166
|
+
if (event === "trailing" && /*#__PURE__*/ (() => {
|
|
167
|
+
try {
|
|
168
|
+
return process.env.NODE_ENV !== "production";
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
})() && process.env.NODE_ENV !== "production") {
|
|
174
|
+
const host = handler.__h;
|
|
175
|
+
if (host)
|
|
176
|
+
element.__h = host;
|
|
177
|
+
else if (component.trailingIcon?.tagName === "SPAN")
|
|
178
|
+
checkTrailingLabel(element.__h ?? element);
|
|
179
|
+
}
|
|
196
180
|
return this;
|
|
197
181
|
},
|
|
198
182
|
off(event, handler) {
|
|
@@ -225,3 +209,10 @@ export const withAPI = ({ disabled, lifecycle }) => (component) => {
|
|
|
225
209
|
},
|
|
226
210
|
};
|
|
227
211
|
};
|
|
212
|
+
const warned = /*#__PURE__*/ new WeakSet();
|
|
213
|
+
export const checkTrailingLabel = (element) => {
|
|
214
|
+
if (!warned.has(element)) {
|
|
215
|
+
warned.add(element);
|
|
216
|
+
warnDev('text-field', 'Set trailingIconLabel/trailing-icon-label');
|
|
217
|
+
}
|
|
218
|
+
};
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
// src/core/shapes/material.ts
|
|
2
|
-
//
|
|
3
|
-
// The Material 3 Expressive shapes: all 35 of Compose Material 3's
|
|
4
|
-
// `MaterialShapes`, built as it builds them (vertex lists repeated around a
|
|
5
|
-
// centre, stars, rectangles, circles), normalised into the unit square.
|
|
6
|
-
//
|
|
7
|
-
// Ported from androidx (Apache License 2.0, Copyright The Android Open Source
|
|
8
|
-
// Project): compose/material3/material3/src/commonMain/kotlin/androidx/compose/
|
|
9
|
-
// material3/MaterialShapes.kt at 080d2b3e5326ba80392d93442c4a51a02dc22650, on
|
|
10
|
-
// the geometry of androidx.graphics:graphics-shapes 1.0.1, the version Compose
|
|
11
|
-
// Material 3 depends on. test/fixtures/material-shapes.json holds every shape
|
|
12
|
-
// as Compose builds it (scripts/generate-material-shapes.kt), and the tests
|
|
13
|
-
// hold this port to it.
|
|
14
|
-
//
|
|
15
|
-
// Each shape is its own export, built once on first use, so a bundle carries
|
|
16
|
-
// only the shapes it names. `materialShape(name)` looks any of them up by name,
|
|
17
|
-
// and carries them all.
|
|
18
1
|
import { pointOnCurve } from "./cubic.js";
|
|
19
2
|
import { circle, normalizePolygon, polygonBounds, polygonMaxRadius, rectangle, regularPolygon, rotatePolygon, roundedPolygon, scalePolygon, star, } from "./polygon.js";
|
|
20
3
|
const cornerRound15 = { radius: 0.15 };
|
|
@@ -24,10 +7,6 @@ const cornerRound50 = { radius: 0.5 };
|
|
|
24
7
|
const cornerRound100 = { radius: 1 };
|
|
25
8
|
const point = (x, y, radius = 0, smoothing = 0) => ({ x, y, r: { radius, smoothing } });
|
|
26
9
|
const toRadians = (degrees) => (degrees / 360) * 2 * Math.PI;
|
|
27
|
-
/**
|
|
28
|
-
* Repeats a few points around the centre, `reps` times, optionally mirroring
|
|
29
|
-
* every other repetition (MaterialShapes.doRepeat)
|
|
30
|
-
*/
|
|
31
10
|
const repeat = (points, reps, cx, cy, mirroring) => {
|
|
32
11
|
const result = [];
|
|
33
12
|
if (mirroring) {
|
|
@@ -56,7 +35,6 @@ const repeat = (points, reps, cx, cy, mirroring) => {
|
|
|
56
35
|
}
|
|
57
36
|
return result;
|
|
58
37
|
};
|
|
59
|
-
/** MaterialShapes.customPolygon: points repeated around (0.5, 0.5) */
|
|
60
38
|
const custom = (pnr, reps, mirroring = false) => {
|
|
61
39
|
const points = repeat(pnr, reps, 0.5, 0.5, mirroring);
|
|
62
40
|
const vertices = [];
|
|
@@ -64,91 +42,55 @@ const custom = (pnr, reps, mirroring = false) => {
|
|
|
64
42
|
vertices.push(p.x, p.y);
|
|
65
43
|
return roundedPolygon(vertices, undefined, points.map((p) => p.r), 0.5, 0.5);
|
|
66
44
|
};
|
|
67
|
-
/** A shape built once, on first use, and normalised into the unit square */
|
|
68
45
|
const shape = (build) => {
|
|
69
46
|
let built;
|
|
70
47
|
return () => (built ?? (built = normalizePolygon(build())));
|
|
71
48
|
};
|
|
72
|
-
/** Circle */
|
|
73
49
|
export const shapeCircle = /*#__PURE__*/ shape(() => circle(10));
|
|
74
|
-
/** A rounded square */
|
|
75
50
|
export const shapeSquare = /*#__PURE__*/ shape(() => rectangle(1, 1, cornerRound30));
|
|
76
|
-
/** A slanted square */
|
|
77
51
|
export const shapeSlanted = /*#__PURE__*/ shape(() => custom([point(0.926, 0.97, 0.189, 0.811), point(-0.021, 0.967, 0.187, 0.057)], 2));
|
|
78
|
-
/** An arch */
|
|
79
52
|
export const shapeArch = /*#__PURE__*/ shape(() => rotatePolygon(regularPolygon(4, 1, 0, 0, undefined, [cornerRound100, cornerRound100, cornerRound20, cornerRound20]), -135));
|
|
80
|
-
/** A fan */
|
|
81
53
|
export const shapeFan = /*#__PURE__*/ shape(() => custom([point(1.004, 1.0, 0.148, 0.417), point(0.0, 1.0, 0.151), point(0.0, -0.003, 0.148), point(0.978, 0.02, 0.803)], 1));
|
|
82
|
-
/** An arrow */
|
|
83
54
|
export const shapeArrow = /*#__PURE__*/ shape(() => custom([point(0.5, 0.892, 0.313), point(-0.216, 1.05, 0.207), point(0.499, -0.16, 0.215, 1.0), point(1.225, 1.06, 0.211)], 1));
|
|
84
|
-
/** A semicircle */
|
|
85
55
|
export const shapeSemiCircle = /*#__PURE__*/ shape(() => rectangle(1.6, 1, undefined, [cornerRound20, cornerRound20, cornerRound100, cornerRound100]));
|
|
86
|
-
/** An oval */
|
|
87
56
|
export const shapeOval = /*#__PURE__*/ shape(() => rotatePolygon(scalePolygon(circle(), 1, 0.64), -45));
|
|
88
|
-
/** A pill */
|
|
89
57
|
export const shapePill = /*#__PURE__*/ shape(() => custom([point(0.961, 0.039, 0.426), point(1.001, 0.428), point(1.0, 0.609, 1.0)], 2, true));
|
|
90
|
-
/** A triangle */
|
|
91
58
|
export const shapeTriangle = /*#__PURE__*/ shape(() => rotatePolygon(regularPolygon(3, 1, 0, 0, cornerRound20), -90));
|
|
92
|
-
/** A diamond */
|
|
93
59
|
export const shapeDiamond = /*#__PURE__*/ shape(() => custom([point(0.5, 1.096, 0.151, 0.524), point(0.04, 0.5, 0.159)], 2));
|
|
94
|
-
/** A clam shell */
|
|
95
60
|
export const shapeClamShell = /*#__PURE__*/ shape(() => custom([point(0.171, 0.841, 0.159), point(-0.02, 0.5, 0.14), point(0.17, 0.159, 0.159)], 2));
|
|
96
|
-
/** A pentagon */
|
|
97
61
|
export const shapePentagon = /*#__PURE__*/ shape(() => custom([point(0.5, -0.009, 0.172), point(1.03, 0.365, 0.164), point(0.828, 0.97, 0.169)], 1, true));
|
|
98
|
-
/** A gem */
|
|
99
62
|
export const shapeGem = /*#__PURE__*/ shape(() => custom([point(0.499, 1.023, 0.241, 0.778), point(-0.005, 0.792, 0.208), point(0.073, 0.258, 0.228), point(0.433, -0.0, 0.491)], 1, true));
|
|
100
|
-
/** A sunny shape: an 8-point star */
|
|
101
63
|
export const shapeSunny = /*#__PURE__*/ shape(() => star(8, 1, 0.8, cornerRound15));
|
|
102
|
-
/** A very sunny shape */
|
|
103
64
|
export const shapeVerySunny = /*#__PURE__*/ shape(() => custom([point(0.5, 1.08, 0.085), point(0.358, 0.843, 0.085)], 8));
|
|
104
|
-
/** A 4-sided cookie */
|
|
105
65
|
export const shapeCookie4Sided = /*#__PURE__*/ shape(() => custom([point(1.237, 1.236, 0.258), point(0.5, 0.918, 0.233)], 4));
|
|
106
|
-
/** A 6-sided cookie */
|
|
107
66
|
export const shapeCookie6Sided = /*#__PURE__*/ shape(() => custom([point(0.723, 0.884, 0.394), point(0.5, 1.099, 0.398)], 6));
|
|
108
|
-
/** A 7-sided cookie */
|
|
109
67
|
export const shapeCookie7Sided = /*#__PURE__*/ shape(() => rotatePolygon(star(7, 1, 0.75, cornerRound50), -90));
|
|
110
|
-
/** A 9-sided cookie */
|
|
111
68
|
export const shapeCookie9Sided = /*#__PURE__*/ shape(() => rotatePolygon(star(9, 1, 0.8, cornerRound50), -90));
|
|
112
|
-
/** A 12-sided cookie */
|
|
113
69
|
export const shapeCookie12Sided = /*#__PURE__*/ shape(() => rotatePolygon(star(12, 1, 0.8, cornerRound50), -90));
|
|
114
|
-
/** A ghost-ish shape */
|
|
115
70
|
export const shapeGhostish = /*#__PURE__*/ shape(() => custom([point(0.5, 0, 1.0), point(1, 0, 1.0), point(1, 1.14, 0.254, 0.106), point(0.575, 0.906, 0.253)], 1, true));
|
|
116
|
-
/** A 4-leaf clover */
|
|
117
71
|
export const shapeClover4Leaf = /*#__PURE__*/ shape(() => custom([point(0.5, 0.074), point(0.725, -0.099, 0.476)], 4, true));
|
|
118
|
-
/** An 8-leaf clover */
|
|
119
72
|
export const shapeClover8Leaf = /*#__PURE__*/ shape(() => custom([point(0.5, 0.036), point(0.758, -0.101, 0.209)], 8));
|
|
120
|
-
/** A burst */
|
|
121
73
|
export const shapeBurst = /*#__PURE__*/ shape(() => custom([point(0.5, -0.006, 0.006), point(0.592, 0.158, 0.006)], 12));
|
|
122
|
-
/** A soft burst */
|
|
123
74
|
export const shapeSoftBurst = /*#__PURE__*/ shape(() => custom([point(0.193, 0.277, 0.053), point(0.176, 0.055, 0.053)], 10));
|
|
124
|
-
/** A boom */
|
|
125
75
|
export const shapeBoom = /*#__PURE__*/ shape(() => custom([point(0.457, 0.296, 0.007), point(0.5, -0.051, 0.007)], 15));
|
|
126
|
-
/** A soft boom */
|
|
127
76
|
export const shapeSoftBoom = /*#__PURE__*/ shape(() => custom([point(0.733, 0.454), point(0.839, 0.437, 0.532), point(0.949, 0.449, 0.439, 1.0), point(0.998, 0.478, 0.174)], 16, true));
|
|
128
|
-
/** A flower */
|
|
129
77
|
export const shapeFlower = /*#__PURE__*/ shape(() => custom([point(0.37, 0.187), point(0.416, 0.049, 0.381), point(0.479, 0.001, 0.095)], 8, true));
|
|
130
|
-
/** A puffy shape */
|
|
131
78
|
export const shapePuffy = /*#__PURE__*/ shape(() => scalePolygon(custom([
|
|
132
79
|
point(0.5, 0.053), point(0.545, -0.04, 0.405), point(0.67, -0.035, 0.426), point(0.717, 0.066, 0.574),
|
|
133
80
|
point(0.722, 0.128), point(0.777, 0.002, 0.36), point(0.914, 0.149, 0.66), point(0.926, 0.289, 0.66),
|
|
134
81
|
point(0.881, 0.346), point(0.94, 0.344, 0.126), point(1.003, 0.437, 0.255),
|
|
135
82
|
], 2, true), 1, 0.742));
|
|
136
|
-
/** A puffy diamond */
|
|
137
83
|
export const shapePuffyDiamond = /*#__PURE__*/ shape(() => custom([point(0.87, 0.13, 0.146), point(0.818, 0.357), point(1.0, 0.332, 0.853)], 4, true));
|
|
138
|
-
/** A pixelated circle */
|
|
139
84
|
export const shapePixelCircle = /*#__PURE__*/ shape(() => custom([
|
|
140
85
|
point(0.5, 0.0), point(0.704, 0.0), point(0.704, 0.065), point(0.843, 0.065),
|
|
141
86
|
point(0.843, 0.148), point(0.926, 0.148), point(0.926, 0.296), point(1.0, 0.296),
|
|
142
87
|
], 2, true));
|
|
143
|
-
/** A pixelated triangle */
|
|
144
88
|
export const shapePixelTriangle = /*#__PURE__*/ shape(() => custom([
|
|
145
89
|
point(0.11, 0.5), point(0.113, 0.0), point(0.287, 0.0), point(0.287, 0.087), point(0.421, 0.087),
|
|
146
90
|
point(0.421, 0.17), point(0.56, 0.17), point(0.56, 0.265), point(0.674, 0.265), point(0.675, 0.344),
|
|
147
91
|
point(0.789, 0.344), point(0.789, 0.439), point(0.888, 0.439),
|
|
148
92
|
], 1, true));
|
|
149
|
-
/** A bun */
|
|
150
93
|
export const shapeBun = /*#__PURE__*/ shape(() => custom([point(0.796, 0.5), point(0.853, 0.518, 1), point(0.992, 0.631, 1), point(0.968, 1.0, 1)], 2, true));
|
|
151
|
-
/** A heart */
|
|
152
94
|
export const shapeHeart = /*#__PURE__*/ shape(() => custom([point(0.5, 0.268, 0.016), point(0.792, -0.066, 0.958), point(1.064, 0.276, 1.0), point(0.501, 0.946, 0.129)], 1, true));
|
|
153
95
|
const byName = {
|
|
154
96
|
circle: shapeCircle,
|
|
@@ -187,16 +129,11 @@ const byName = {
|
|
|
187
129
|
bun: shapeBun,
|
|
188
130
|
heart: shapeHeart,
|
|
189
131
|
};
|
|
190
|
-
/** A Material shape by name, normalised into the unit square. Carries every shape; import `shapeX` to carry one. */
|
|
191
132
|
export const materialShape = (name) => byName[name]();
|
|
192
133
|
const num = (value) => {
|
|
193
134
|
const rounded = Math.round(value * 1000) / 1000;
|
|
194
135
|
return String(Object.is(rounded, -0) ? 0 : rounded);
|
|
195
136
|
};
|
|
196
|
-
/**
|
|
197
|
-
* A polygon's outline as an SVG path ("M … C … Z"), scaled by `size`: a
|
|
198
|
-
* normalised shape fills a `size` × `size` box. Coordinates keep three decimals.
|
|
199
|
-
*/
|
|
200
137
|
export const polygonPath = (polygon, size = 1) => {
|
|
201
138
|
const cubics = polygon.cubics;
|
|
202
139
|
if (!cubics.length)
|
|
@@ -207,25 +144,14 @@ export const polygonPath = (polygon, size = 1) => {
|
|
|
207
144
|
d += `C${s(c[2])} ${s(c[3])} ${s(c[4])} ${s(c[5])} ${s(c[6])} ${s(c[7])}`;
|
|
208
145
|
return `${d}Z`;
|
|
209
146
|
};
|
|
210
|
-
/** A Material shape as an SVG path in a `size` × `size` box. Carries every shape, as materialShape does. */
|
|
211
147
|
export const materialShapePath = (name, size = 1) => polygonPath(materialShape(name), size);
|
|
212
148
|
const TWO_PI = Math.PI * 2;
|
|
213
|
-
/**
|
|
214
|
-
* radialProfile without its star-shape check, for callers whose shapes are
|
|
215
|
-
* known to be star-shaped: the loading indicator's, which the tests check.
|
|
216
|
-
* The centroid, not the bounds centre, is the pivot: a pentagon's mass sits
|
|
217
|
-
* below the middle of its box, and turning it about the box would make it
|
|
218
|
-
* orbit.
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
149
|
export const sampleProfile = (polygon, samples = 360, stepsPerCubic = 24) => {
|
|
222
|
-
// The outline as a dense polygon
|
|
223
150
|
const points = [];
|
|
224
151
|
for (const cubic of polygon.cubics) {
|
|
225
152
|
for (let s = 0; s < stepsPerCubic; s++)
|
|
226
153
|
points.push(pointOnCurve(cubic, s / stepsPerCubic));
|
|
227
154
|
}
|
|
228
|
-
// Its area centroid (shoelace formula)
|
|
229
155
|
let area = 0;
|
|
230
156
|
let centerX = 0;
|
|
231
157
|
let centerY = 0;
|
|
@@ -246,7 +172,6 @@ export const sampleProfile = (polygon, samples = 360, stepsPerCubic = 24) => {
|
|
|
246
172
|
centerX = (bounds[0] + bounds[2]) / 2;
|
|
247
173
|
centerY = (bounds[1] + bounds[3]) / 2;
|
|
248
174
|
}
|
|
249
|
-
// The outline as (angle, radius) pairs, sorted by angle
|
|
250
175
|
const outline = [];
|
|
251
176
|
for (const [x, y] of points) {
|
|
252
177
|
const dx = x - centerX;
|
|
@@ -278,13 +203,6 @@ export const sampleProfile = (polygon, samples = 360, stepsPerCubic = 24) => {
|
|
|
278
203
|
}
|
|
279
204
|
return { radii, centerX, centerY, maxRadius };
|
|
280
205
|
};
|
|
281
|
-
/**
|
|
282
|
-
* Samples the outline at `samples` angles around the shape's area centroid.
|
|
283
|
-
* Throws for a shape that is not star-shaped around it. Of the Material
|
|
284
|
-
* shapes, 33 are; Puffy and PixelTriangle are not (their outlines double back
|
|
285
|
-
* as seen from the centroid, Puffy by about 0.1°): a ray from the centroid
|
|
286
|
-
* would cross the outline more than once, and the profile would be wrong.
|
|
287
|
-
*/
|
|
288
206
|
export const radialProfile = (polygon, samples = 360, stepsPerCubic = 24) => {
|
|
289
207
|
const profile = sampleProfile(polygon, samples, stepsPerCubic);
|
|
290
208
|
const { centerX, centerY } = profile;
|
|
@@ -293,9 +211,6 @@ export const radialProfile = (polygon, samples = 360, stepsPerCubic = 24) => {
|
|
|
293
211
|
for (let s = 0; s < stepsPerCubic; s++)
|
|
294
212
|
points.push(pointOnCurve(cubic, s / stepsPerCubic));
|
|
295
213
|
}
|
|
296
|
-
// Star-shaped around the centroid: walking the outline, the angle seen from
|
|
297
|
-
// the centroid only ever turns one way. A shape that doubles back (a heart's
|
|
298
|
-
// notch, an arch's inner curve) would be sampled wrong: refuse it.
|
|
299
214
|
let turn = 0;
|
|
300
215
|
for (let i = 0; i < points.length; i++) {
|
|
301
216
|
const [x0, y0] = points[i];
|
|
@@ -95,6 +95,7 @@ const buttonGroupSpec = {
|
|
|
95
95
|
name: "button-group",
|
|
96
96
|
create: (config) => createButtonGroup(config),
|
|
97
97
|
styles: ["progress", "button", "icon-button", "button-group"],
|
|
98
|
+
hostStyles: ":host{display:inline-flex}",
|
|
98
99
|
attributes: {
|
|
99
100
|
variant: { type: "string", config: "variant", update: (c, v) => void c.setVariant(String(v ?? "outlined")) },
|
|
100
101
|
kind: { type: "string", config: "kind" },
|
package/dist/elements/button.js
CHANGED
|
@@ -5,7 +5,7 @@ const buttonSpec = {
|
|
|
5
5
|
name: "button",
|
|
6
6
|
create: (config) => createButton({ ...config, type: "button" }),
|
|
7
7
|
styles: ["progress", "button"],
|
|
8
|
-
hostStyles: ":host{vertical-align:middle}",
|
|
8
|
+
hostStyles: ":host{display:inline-flex;vertical-align:middle}",
|
|
9
9
|
attributes: {
|
|
10
10
|
variant: { type: "string", config: "variant", update: (c, v) => void c.setVariant(String(v ?? "filled")) },
|
|
11
11
|
size: { type: "string", config: "size", update: (c, v) => void c.setSize(String(v ?? "s")) },
|
|
@@ -4,6 +4,7 @@ const checkboxSpec = {
|
|
|
4
4
|
name: "checkbox",
|
|
5
5
|
create: (config) => createCheckbox(config),
|
|
6
6
|
styles: ["checkbox"],
|
|
7
|
+
hostStyles: ":host{display:inline-flex}",
|
|
7
8
|
attributes: {
|
|
8
9
|
checked: { type: "boolean", config: "checked", update: (c, v) => void c.setValue(!!v) },
|
|
9
10
|
disabled: { type: "boolean", config: "disabled", update: (c, v) => void (v ? c.disable() : c.enable()) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex;vertical-align:middle}:host>*{position:relative}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:contents}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex;vertical-align:middle}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}:host([disabled]){pointer-events:none}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:contents}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}:host([orientation="vertical"]:not([hidden])){display:inline-block;align-self:stretch}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block;flex-shrink:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex;vertical-align:middle}:host::before{content:'';align-self:stretch;width:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:inline-flex;vertical-align:middle}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:contents}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host([hidden]){display:none}*,*::before,*::after{box-sizing:border-box}@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-property:opacity,color,background-color,border-color,outline-color,box-shadow,visibility!important;scroll-behavior:auto!important}}:host{display:block}
|