@shortfuse/materialdesignweb 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +57 -68
  2. package/components/Badge.js +2 -2
  3. package/components/BottomAppBar.js +3 -5
  4. package/components/Box.js +33 -3
  5. package/components/Button.js +48 -21
  6. package/components/Button.md +9 -9
  7. package/components/Card.js +9 -16
  8. package/components/Checkbox.js +45 -36
  9. package/components/CheckboxIcon.js +2 -2
  10. package/components/Chip.js +1 -1
  11. package/components/Dialog.js +228 -359
  12. package/components/DialogActions.js +2 -2
  13. package/components/Divider.js +3 -3
  14. package/components/ExtendedFab.js +4 -8
  15. package/components/Fab.js +1 -2
  16. package/components/FilterChip.js +4 -4
  17. package/components/Headline.js +1 -1
  18. package/components/Icon.js +8 -8
  19. package/components/IconButton.js +9 -14
  20. package/components/Input.js +273 -1
  21. package/components/Layout.js +485 -16
  22. package/components/List.js +6 -4
  23. package/components/ListItem.js +12 -12
  24. package/components/ListOption.js +21 -5
  25. package/components/Listbox.js +239 -0
  26. package/components/Menu.js +77 -526
  27. package/components/MenuItem.js +12 -14
  28. package/components/Nav.js +0 -2
  29. package/components/NavBar.js +8 -79
  30. package/components/NavDrawer.js +12 -11
  31. package/components/NavDrawerItem.js +2 -1
  32. package/components/NavItem.js +18 -8
  33. package/components/NavRail.js +15 -7
  34. package/components/NavRailItem.js +3 -1
  35. package/components/Popup.js +20 -0
  36. package/components/Progress.js +24 -23
  37. package/components/Radio.js +42 -35
  38. package/components/RadioIcon.js +3 -3
  39. package/components/Ripple.js +2 -3
  40. package/components/Search.js +85 -0
  41. package/components/SegmentedButton.js +1 -10
  42. package/components/SegmentedButtonGroup.js +16 -10
  43. package/components/Select.js +4 -4
  44. package/components/Shape.js +1 -1
  45. package/components/Slider.js +43 -50
  46. package/components/Snackbar.js +4 -5
  47. package/components/Surface.js +3 -3
  48. package/components/Switch.js +55 -21
  49. package/components/SwitchIcon.js +10 -8
  50. package/components/Tab.js +11 -9
  51. package/components/TabContent.js +4 -3
  52. package/components/TabList.js +2 -2
  53. package/components/TabPanel.js +11 -8
  54. package/components/TextArea.js +38 -35
  55. package/components/Tooltip.js +2 -2
  56. package/components/TopAppBar.js +65 -147
  57. package/core/Composition.js +985 -628
  58. package/core/CompositionAdapter.js +315 -0
  59. package/core/CustomElement.js +153 -90
  60. package/core/DomAdapter.js +586 -0
  61. package/core/ICustomElement.d.ts +2 -2
  62. package/core/css.js +8 -7
  63. package/core/customTypes.js +53 -31
  64. package/{utils → core}/jsonMergePatch.js +36 -14
  65. package/core/observe.js +111 -57
  66. package/core/optimizations.js +23 -0
  67. package/core/template.js +17 -11
  68. package/core/test.js +126 -0
  69. package/core/typings.d.ts +11 -5
  70. package/core/uid.js +13 -0
  71. package/dist/index.min.js +83 -152
  72. package/dist/index.min.js.map +4 -4
  73. package/dist/meta.json +1 -1
  74. package/mixins/AriaReflectorMixin.js +1 -2
  75. package/mixins/AriaToolbarMixin.js +2 -3
  76. package/mixins/ControlMixin.js +25 -17
  77. package/mixins/DensityMixin.js +0 -1
  78. package/mixins/FlexableMixin.js +1 -2
  79. package/mixins/FormAssociatedMixin.js +13 -10
  80. package/mixins/InputMixin.js +2 -9
  81. package/mixins/KeyboardNavMixin.js +14 -1
  82. package/mixins/PopupMixin.js +757 -0
  83. package/mixins/RTLObserverMixin.js +0 -1
  84. package/mixins/ResizeObserverMixin.js +0 -1
  85. package/mixins/RippleMixin.js +3 -4
  86. package/mixins/ScrollListenerMixin.js +41 -32
  87. package/mixins/SemiStickyMixin.js +151 -0
  88. package/mixins/ShapeMixin.js +29 -24
  89. package/mixins/StateMixin.js +11 -6
  90. package/mixins/SurfaceMixin.js +3 -57
  91. package/mixins/TextFieldMixin.js +57 -65
  92. package/mixins/ThemableMixin.js +78 -156
  93. package/mixins/TooltipTriggerMixin.js +7 -13
  94. package/mixins/TouchTargetMixin.js +4 -3
  95. package/package.json +9 -5
  96. package/theming/index.js +1 -1
  97. package/theming/themableMixinLoader.js +12 -0
  98. package/utils/{hct → material-color}/blend.js +8 -10
  99. package/utils/{hct → material-color/hct}/Cam16.js +196 -69
  100. package/utils/{hct → material-color/hct}/Hct.js +61 -19
  101. package/utils/{hct → material-color/hct}/ViewingConditions.js +3 -3
  102. package/utils/{hct → material-color/hct}/hctSolver.js +9 -16
  103. package/utils/{hct → material-color}/helper.js +11 -18
  104. package/utils/{hct → material-color/palettes}/CorePalette.js +79 -19
  105. package/utils/{hct → material-color/palettes}/TonalPalette.js +12 -4
  106. package/utils/material-color/scheme/Scheme.js +376 -0
  107. package/utils/{hct/colorUtils.js → material-color/utils/color.js} +61 -1
  108. package/utils/popup.js +46 -25
  109. package/components/ListSelect.js +0 -220
  110. package/components/Option.js +0 -91
  111. package/components/Pane.js +0 -281
  112. package/core/identify.js +0 -40
  113. package/utils/hct/Scheme.js +0 -587
  114. /package/utils/{hct/mathUtils.js → material-color/utils/math.js} +0 -0
@@ -41,17 +41,17 @@
41
41
 
42
42
  ## Custom
43
43
  ```html
44
- <mdw-button class=mdw-custom ink=yellow>Custom text</mdw-button>
45
- <mdw-button class=mdw-custom elevated ink=yellow>Custom elevated</mdw-button>
46
- <mdw-button class=mdw-custom filled color=yellow>Custom filled</mdw-button>
47
- <mdw-button class=mdw-custom filled=tonal icon=add color=yellow-container>Custom tonal</mdw-button>
48
- <mdw-button class=mdw-custom outlined ink=yellow>Custom outlined</mdw-button>
44
+ <mdw-button ink=yellow>Custom text</mdw-button>
45
+ <mdw-button elevated ink=yellow>Custom elevated</mdw-button>
46
+ <mdw-button filled color=yellow>Custom filled</mdw-button>
47
+ <mdw-button filled=tonal icon=add color=yellow-container>Custom tonal</mdw-button>
48
+ <mdw-button outlined ink=yellow>Custom outlined</mdw-button>
49
49
  <mdw-button disabled outlined>Outlined (Disabled)</mdw-button>
50
50
  <mdw-button disabled outlined icon=add>Outlined icon (Disabled)</mdw-button>
51
- <mdw-button disabled class=mdw-custom ink=yellow>Custom text</mdw-button>
52
- <mdw-button disabled class=mdw-custom elevated=yellow>Custom elevated</mdw-button>
53
- <mdw-button disabled filled class=mdw-custom color=yellow>Custom filled</mdw-button>
54
- <mdw-button disabled filled=tonal class=mdw-custom icon=add color=yellow-container>Custom tonal</mdw-button>
51
+ <mdw-button disabled ink=yellow>Custom text</mdw-button>
52
+ <mdw-button disabled elevated=yellow>Custom elevated</mdw-button>
53
+ <mdw-button disabled filled color=yellow>Custom filled</mdw-button>
54
+ <mdw-button disabled filled=tonal icon=add color=yellow-container>Custom tonal</mdw-button>
55
55
  ```
56
56
 
57
57
  ```js
@@ -11,6 +11,7 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
11
11
  const SUPPORTS_INERT = 'inert' in HTMLElement.prototype;
12
12
 
13
13
  export default CustomElement
14
+ .extend()
14
15
  .mixin(ThemableMixin)
15
16
  .mixin(FlexableMixin)
16
17
  .mixin(SurfaceMixin)
@@ -18,7 +19,6 @@ export default CustomElement
18
19
  .mixin(FormAssociatedMixin) // Tap into FormAssociated for disabledState
19
20
  .mixin(StateMixin)
20
21
  .mixin(AriaReflectorMixin)
21
- .extend()
22
22
  .setStatic({
23
23
  delegatesFocus: true,
24
24
  })
@@ -43,9 +43,9 @@ export default CustomElement
43
43
  if (this.actionable) this.refs.action.focus();
44
44
  },
45
45
  })
46
- .html/* html */`
47
- <mdw-button _if={actionable} aria-label={actionLabel} id=action disabled={disabledState}></mdw-button>
48
- <div _if={showBlocker} id=inert-blocker></div>
46
+ .html`
47
+ <mdw-button mdw-if={actionable} aria-label={actionLabel} id=action disabled={disabledState}></mdw-button>
48
+ <div mdw-if={showBlocker} id=inert-blocker></div>
49
49
  <slot id=slot disabled={disabledState}></slot>
50
50
  `
51
51
  .css`
@@ -53,14 +53,12 @@ export default CustomElement
53
53
 
54
54
  :host {
55
55
  --mdw-shape__size: 12px;
56
- --mdw-surface__tint: var(--mdw-surface__tint__0);
57
- --mdw-surface__tint__raised: var(--mdw-surface__tint);
58
56
 
59
57
  --mdw-surface__shadow__resting: none;
60
58
  --mdw-surface__shadow__raised: var(--mdw-surface__shadow__resting);
61
59
  /* padding-inline: 12px; */
62
60
 
63
- --mdw-bg: var(--mdw-color__surface);
61
+ --mdw-bg: var(--mdw-color__surface-container);
64
62
  --mdw-ink: var(--mdw-color__on-surface);
65
63
  position: relative;
66
64
 
@@ -77,32 +75,28 @@ export default CustomElement
77
75
  }
78
76
 
79
77
  :host(:where([filled])) {
80
- --mdw-bg: var(--mdw-color__surface-variant);
78
+ --mdw-bg: var(--mdw-color__surface-container-highest);
81
79
  --mdw-ink: var(--mdw-color__on-surface-variant);
82
80
  }
83
81
 
84
82
  :host(:where([elevated])) {
85
- --mdw-bg: var(--mdw-color__surface);
83
+ --mdw-bg: var(--mdw-color__surface-container-low);
86
84
  --mdw-ink: var(--mdw-color__on-surface);
87
85
  }
88
86
 
89
87
  :host([filled]) {
90
- --mdw-surface__tint: var(--mdw-surface__tint__0);
91
88
  --mdw-surface__shadow__resting: var(--mdw-surface__shadow__0);
92
89
  }
93
90
 
94
91
  :host([filled][actionable]) {
95
- --mdw-surface__tint__raised: var(--mdw-surface__tint__1);
96
92
  --mdw-surface__shadow__raised: var(--mdw-surface__shadow__1);
97
93
  }
98
94
 
99
95
  :host([elevated]) {
100
- --mdw-surface__tint: var(--mdw-surface__tint__1);
101
96
  --mdw-surface__shadow__resting: var(--mdw-surface__shadow__1);
102
97
  }
103
98
 
104
99
  :host([elevated][actionable]) {
105
- --mdw-surface__tint__raised: var(--mdw-surface__tint__2);
106
100
  --mdw-surface__shadow__raised: var(--mdw-surface__shadow__2);
107
101
  }
108
102
 
@@ -142,7 +136,7 @@ export default CustomElement
142
136
  }
143
137
 
144
138
  #shape[disabled][elevated] {
145
- background-color: rgba(var(--mdw-color__surface-variant));
139
+ background-color: rgba(var(--mdw-color__surface-container-highest));
146
140
  }
147
141
 
148
142
  #action {
@@ -161,8 +155,7 @@ export default CustomElement
161
155
  `
162
156
  .on({
163
157
  composed() {
164
- const { slot, surface, surfaceTint, shape, outline } = this.refs;
165
- shape.append(surfaceTint);
158
+ const { slot, surface, shape, outline } = this.refs;
166
159
  surface.append(shape);
167
160
  outline.removeAttribute('pressed');
168
161
  outline.removeAttribute('focused');
@@ -8,12 +8,12 @@ import ThemableMixin from '../mixins/ThemableMixin.js';
8
8
  import TouchTargetMixin from '../mixins/TouchTargetMixin.js';
9
9
 
10
10
  export default CustomElement
11
+ .extend()
11
12
  .mixin(ThemableMixin)
12
13
  .mixin(StateMixin)
13
14
  .mixin(RippleMixin)
14
15
  .mixin(InputMixin)
15
16
  .mixin(TouchTargetMixin)
16
- .extend()
17
17
  .set({
18
18
  stateLayer: true,
19
19
  type: 'checkbox',
@@ -32,6 +32,33 @@ export default CustomElement
32
32
  return (indeterminate ? indeterminateIcon : icon);
33
33
  },
34
34
  })
35
+ .html`
36
+ <div id=checkbox errored={erroredState} selected={checked}>
37
+ <mdw-checkbox-icon id=icon errored={erroredState} disabled={disabledState}
38
+ icon={_determinateIcon} selected={checked}>
39
+ </mdw-checkbox-icon>
40
+ </div>
41
+ <slot id=slot></slot>
42
+ `
43
+ .rootEvents({
44
+ click(event) {
45
+ const { control } = this.refs;
46
+ if (event.target !== control) {
47
+ // Label-like click
48
+ event.stopPropagation();
49
+ control.click();
50
+ }
51
+ },
52
+ })
53
+ .on({
54
+ composed() {
55
+ const { control, checkbox, state, rippleContainer } = this.refs;
56
+ checkbox.append(state, rippleContainer);
57
+
58
+ // Indeterminate must be manually expressed for ARIA
59
+ control.setAttribute('aria-checked', '{_ariaChecked}');
60
+ },
61
+ })
35
62
  .css`
36
63
  /* https://m3.material.io/components/checkbox/specs */
37
64
 
@@ -50,7 +77,15 @@ export default CustomElement
50
77
  transition: none 100ms cubic-bezier(0.4, 0.0, 1, 1);
51
78
  }
52
79
 
53
- :host([disabled]) {
80
+ :host(:disabled) {
81
+ cursor: not-allowed;
82
+
83
+ opacity: 0.38;
84
+ }
85
+
86
+ :host([internals-disabled]) {
87
+ cursor: not-allowed;
88
+
54
89
  opacity: 0.38;
55
90
  }
56
91
 
@@ -60,28 +95,18 @@ export default CustomElement
60
95
  line-height: 18px;
61
96
  }
62
97
 
63
- :host(:empty) #checkbox {
64
- transform: none;
65
- }
66
-
67
98
  #control {
68
99
  grid-column: 1/1;
69
100
 
70
101
  cursor: inherit;
71
102
  }
72
103
 
73
- #label {
74
- cursor: inherit;
75
- }
76
-
77
- #label[disabled] {
78
- cursor: not-allowed;
79
- }
80
-
81
104
  #state,
82
105
  #ripple-container {
83
- inset-block-start: 50%;
84
- inset-inline-start: 50%;
106
+ /* stylelint-disable-next-line liberty/use-logical-spec */
107
+ top: 50%;
108
+ /* stylelint-disable-next-line liberty/use-logical-spec */
109
+ left: 50%;
85
110
 
86
111
  block-size: 40px;
87
112
  inline-size: 40px;
@@ -117,30 +142,14 @@ export default CustomElement
117
142
  color: rgb(var(--mdw-color__error));
118
143
  }
119
144
 
145
+ :host(:empty) #checkbox {
146
+ transform: none;
147
+ }
148
+
120
149
  #icon {
121
150
  --mdw-ink: inherit;
122
151
  --mdw-bg: inherit;
123
152
  --disabled-opacity: 1;
124
153
  }
125
154
  `
126
- .on({
127
- composed({ html }) {
128
- const { label, control, state, rippleContainer, touchTarget } = this.refs;
129
- label.append(html`
130
- ${touchTarget}
131
- ${control}
132
- <div id=checkbox errored={erroredState} selected={checked}>
133
- <mdw-checkbox-icon id=icon errored={erroredState} disabled={disabledState}
134
- icon={_determinateIcon} selected={checked}>
135
- </mdw-checkbox-icon>
136
- ${state}
137
- ${rippleContainer}
138
- </div>
139
- <slot id=slot></slot>
140
- `);
141
-
142
- // Indeterminate must be manually expressed for ARIA
143
- control.setAttribute('aria-checked', '{_ariaChecked}');
144
- },
145
- })
146
155
  .autoRegister('mdw-checkbox');
@@ -4,6 +4,7 @@ import ShapeMixin from '../mixins/ShapeMixin.js';
4
4
  import ThemableMixin from '../mixins/ThemableMixin.js';
5
5
 
6
6
  export default CustomElement
7
+ .extend()
7
8
  .mixin(ThemableMixin)
8
9
  .mixin(ShapeMixin)
9
10
  .observe({
@@ -114,7 +115,7 @@ export default CustomElement
114
115
  .on({
115
116
  composed({ html }) {
116
117
  const { outline, shape } = this.refs;
117
- outline.removeAttribute('_if');
118
+ outline.removeAttribute('mdw-if');
118
119
  outline.setAttribute('selected', '{selected}');
119
120
  outline.setAttribute('errored', '{errored}');
120
121
  outline.setAttribute('disabled', '{disabled}');
@@ -125,5 +126,4 @@ export default CustomElement
125
126
  `);
126
127
  },
127
128
  })
128
- .extend()
129
129
  .autoRegister('mdw-checkbox-icon');
@@ -49,7 +49,7 @@ export default Button
49
49
  slot.setAttribute('disabled', '{disabledState}');
50
50
  slot.removeAttribute('ink');
51
51
  slot.removeAttribute('color');
52
- outline.setAttribute('_if', '{!elevated}');
52
+ outline.setAttribute('mdw-if', '{!elevated}');
53
53
  outline.setAttribute('ink', '{ink}');
54
54
  outline.setAttribute('color', '{color}');
55
55
  icon.setAttribute('ink', inline(({ ink, iconInk }) => iconInk ?? ink ?? 'primary'));