Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 516b0c3

Browse files
author
Matt Goo
committed
Revert "feat(ripple): convert to ts (#4300)"
This reverts commit 47a9c38.
1 parent 8b27388 commit 516b0c3

File tree

16 files changed

+464
-420
lines changed

16 files changed

+464
-420
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/material-components-web/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import * as menu from '@material/menu/index';
4040
import * as menuSurface from '@material/menu-surface/index';
4141
import * as notchedOutline from '@material/notched-outline/index';
4242
import * as radio from '@material/radio/index';
43-
import * as ripple from '@material/ripple/index.ts';
43+
import * as ripple from '@material/ripple/index';
4444
import * as select from '@material/select/index';
4545
import * as selectionControl from '@material/selection-control/index.ts';
4646
import * as slider from '@material/slider/index';

packages/mdc-dom/events.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/mdc-dom/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* THE SOFTWARE.
2222
*/
2323

24-
import {EventType, SpecificEventListener} from './events';
2524
import * as ponyfill from './ponyfill';
2625

27-
export {ponyfill, EventType, SpecificEventListener};
26+
export {ponyfill};

packages/mdc-dom/ponyfill.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
* This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
2727
*/
2828

29+
interface MsElement extends Element {
30+
msMatchesSelector(selector: string): boolean;
31+
}
32+
2933
function closest(element: Element, selector: string): Element | null {
3034
if (element.closest) {
3135
return element.closest(selector);
@@ -44,7 +48,7 @@ function closest(element: Element, selector: string): Element | null {
4448
function matches(element: Element, selector: string): boolean {
4549
const nativeMatches = element.matches
4650
|| element.webkitMatchesSelector
47-
|| element.msMatchesSelector;
51+
|| (element as MsElement).msMatchesSelector;
4852
return nativeMatches.call(element, selector);
4953
}
5054

packages/mdc-ripple/adapter.ts renamed to packages/mdc-ripple/adapter.js

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* THE SOFTWARE.
2222
*/
2323

24+
/* eslint no-unused-vars: [2, {"args": "none"}] */
25+
2426
/**
2527
* Adapter for MDC Ripple. Provides an interface for managing
2628
* - classes
@@ -40,46 +42,75 @@
4042
* for more details.
4143
* https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
4244
*
45+
* @record
4346
*/
44-
import {EventType, SpecificEventListener} from '@material/dom/index';
45-
46-
interface Point {
47-
x: number;
48-
y: number;
49-
}
50-
51-
interface MDCRippleAdapter {
52-
browserSupportsCssVars(): boolean;
53-
54-
isUnbounded(): boolean;
55-
56-
isSurfaceActive(): boolean;
57-
58-
isSurfaceDisabled(): boolean;
59-
60-
addClass(className: string): void;
61-
62-
removeClass(className: string): void;
63-
64-
containsEventTarget(target: EventTarget | null): boolean;
65-
66-
registerInteractionHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
67-
68-
deregisterInteractionHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
69-
70-
registerDocumentInteractionHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
71-
72-
deregisterDocumentInteractionHandler<K extends EventType>(evtType: K, handler: SpecificEventListener<K>): void;
73-
74-
registerResizeHandler(handler: SpecificEventListener<'resize'>): void;
75-
76-
deregisterResizeHandler(handler: SpecificEventListener<'resize'>): void;
77-
78-
updateCssVariable(varName: string, value: string|null): void;
79-
80-
computeBoundingRect(): ClientRect;
81-
82-
getWindowPageOffset(): Point;
47+
class MDCRippleAdapter {
48+
/** @return {boolean} */
49+
browserSupportsCssVars() {}
50+
51+
/** @return {boolean} */
52+
isUnbounded() {}
53+
54+
/** @return {boolean} */
55+
isSurfaceActive() {}
56+
57+
/** @return {boolean} */
58+
isSurfaceDisabled() {}
59+
60+
/** @param {string} className */
61+
addClass(className) {}
62+
63+
/** @param {string} className */
64+
removeClass(className) {}
65+
66+
/** @param {!EventTarget} target */
67+
containsEventTarget(target) {}
68+
69+
/**
70+
* @param {string} evtType
71+
* @param {!Function} handler
72+
*/
73+
registerInteractionHandler(evtType, handler) {}
74+
75+
/**
76+
* @param {string} evtType
77+
* @param {!Function} handler
78+
*/
79+
deregisterInteractionHandler(evtType, handler) {}
80+
81+
/**
82+
* @param {string} evtType
83+
* @param {!Function} handler
84+
*/
85+
registerDocumentInteractionHandler(evtType, handler) {}
86+
87+
/**
88+
* @param {string} evtType
89+
* @param {!Function} handler
90+
*/
91+
deregisterDocumentInteractionHandler(evtType, handler) {}
92+
93+
/**
94+
* @param {!Function} handler
95+
*/
96+
registerResizeHandler(handler) {}
97+
98+
/**
99+
* @param {!Function} handler
100+
*/
101+
deregisterResizeHandler(handler) {}
102+
103+
/**
104+
* @param {string} varName
105+
* @param {?number|string} value
106+
*/
107+
updateCssVariable(varName, value) {}
108+
109+
/** @return {!ClientRect} */
110+
computeBoundingRect() {}
111+
112+
/** @return {{x: number, y: number}} */
113+
getWindowPageOffset() {}
83114
}
84115

85-
export {MDCRippleAdapter as default, Point};
116+
export default MDCRippleAdapter;

packages/mdc-ripple/constants.ts renamed to packages/mdc-ripple/constants.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ const cssClasses = {
2525
// Ripple is a special case where the "root" component is really a "mixin" of sorts,
2626
// given that it's an 'upgrade' to an existing component. That being said it is the root
2727
// CSS class that all other CSS classes derive from.
28+
ROOT: 'mdc-ripple-upgraded',
29+
UNBOUNDED: 'mdc-ripple-upgraded--unbounded',
2830
BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
2931
FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
3032
FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
31-
ROOT: 'mdc-ripple-upgraded',
32-
UNBOUNDED: 'mdc-ripple-upgraded--unbounded',
3333
};
3434

3535
const strings = {
36-
VAR_FG_SCALE: '--mdc-ripple-fg-scale',
37-
VAR_FG_SIZE: '--mdc-ripple-fg-size',
38-
VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
39-
VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
4036
VAR_LEFT: '--mdc-ripple-left',
4137
VAR_TOP: '--mdc-ripple-top',
38+
VAR_FG_SIZE: '--mdc-ripple-fg-size',
39+
VAR_FG_SCALE: '--mdc-ripple-fg-scale',
40+
VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
41+
VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
4242
};
4343

4444
const numbers = {
45+
PADDING: 10,
46+
INITIAL_ORIGIN_SCALE: 0.6,
4547
DEACTIVATION_TIMEOUT_MS: 225, // Corresponds to $mdc-ripple-translate-duration (i.e. activation animation duration)
4648
FG_DEACTIVATION_MS: 150, // Corresponds to $mdc-ripple-fade-out-duration (i.e. deactivation animation duration)
47-
INITIAL_ORIGIN_SCALE: 0.6,
48-
PADDING: 10,
4949
TAP_DELAY_MS: 300, // Delay between touch and simulated mouse events on touch devices
5050
};
5151

0 commit comments

Comments
 (0)