@rmwc/base
Advanced tools
Comparing version 14.0.0-alpha.0 to 14.0.1-alpha.0
@@ -11,7 +11,7 @@ "use strict"; | ||
var finalProps = element ? element.props(rest) : rest; | ||
var finalRef = element ? exports.mergeRefs(ref, element.reactRef) : ref; | ||
var finalRef = element ? (0, exports.mergeRefs)(ref, element.reactRef) : ref; | ||
return react_1.default.createElement(TagEl, tslib_1.__assign({}, finalProps, { ref: finalRef })); | ||
}); | ||
var useClassNames = function (props, classNames) { | ||
return classnames_1.default.apply(void 0, tslib_1.__spreadArray(tslib_1.__spreadArray([props.className], tslib_1.__read((!!props.theme ? with_theme_1.parseThemeOptions(props.theme) : []))), tslib_1.__read((typeof classNames === 'function' ? classNames(props) : classNames)))); | ||
return classnames_1.default.apply(void 0, tslib_1.__spreadArray(tslib_1.__spreadArray([props.className], tslib_1.__read((!!props.theme ? (0, with_theme_1.parseThemeOptions)(props.theme) : [])), false), tslib_1.__read((typeof classNames === 'function' ? classNames(props) : classNames)), false)); | ||
}; | ||
@@ -18,0 +18,0 @@ exports.useClassNames = useClassNames; |
@@ -54,3 +54,3 @@ import { SpecificEventListener } from '@material/base/types'; | ||
getProps: () => Props; | ||
emit: <T>(evtType: string, evtData: T, shouldBubble?: boolean | undefined) => CustomEvent<any>; | ||
emit: <T>(evtType: string, evtData: T, shouldBubble?: boolean) => CustomEvent<any>; | ||
}) => Foundation; | ||
@@ -57,0 +57,0 @@ props: Props; |
@@ -103,3 +103,3 @@ "use strict"; | ||
// handle className | ||
var mergedClasses = classnames_1.default(className, tslib_1.__spreadArray([], tslib_1.__read(this._classes))); | ||
var mergedClasses = (0, classnames_1.default)(className, tslib_1.__spreadArray([], tslib_1.__read(this._classes), false)); | ||
// handle styles | ||
@@ -115,3 +115,3 @@ var mergedStyles = tslib_1.__assign(tslib_1.__assign({}, this._style), style); | ||
? propertyName | ||
: strings_1.toCamel(propertyName); | ||
: (0, strings_1.toCamel)(propertyName); | ||
if (this._style[propertyName] !== value) { | ||
@@ -177,6 +177,6 @@ this._style[propertyName] = value; | ||
var foundationFactory = _a.foundation, inputProps = _a.props, elementsInput = _a.elements, api = _a.api; | ||
var _b = tslib_1.__read(react_1.useState(0), 2), setIteration = _b[1]; | ||
var props = react_1.useRef(inputProps); | ||
var _b = tslib_1.__read((0, react_1.useState)(0), 2), setIteration = _b[1]; | ||
var props = (0, react_1.useRef)(inputProps); | ||
props.current = inputProps; | ||
var elements = react_1.useMemo(function () { | ||
var elements = (0, react_1.useMemo)(function () { | ||
return Object.keys(elementsInput).reduce(function (acc, key) { | ||
@@ -191,3 +191,3 @@ acc[key] = new FoundationElement(function () { | ||
[]); | ||
var foundation = react_1.useMemo(function () { | ||
var foundation = (0, react_1.useMemo)(function () { | ||
// init foundation | ||
@@ -199,18 +199,18 @@ var f = foundationFactory(tslib_1.__assign(tslib_1.__assign({}, elements), { getProps: function () { return props.current; }, emit: function () { | ||
} | ||
return emitFactory(props.current).apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args))); | ||
return emitFactory(props.current).apply(void 0, tslib_1.__spreadArray([], tslib_1.__read(args), false)); | ||
} })); | ||
// handle apiRefs | ||
api && component_1.handleRef(props.current.apiRef, api(tslib_1.__assign({ foundation: f }, elements))); | ||
api && (0, component_1.handleRef)(props.current.apiRef, api(tslib_1.__assign({ foundation: f }, elements))); | ||
return f; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
react_1.useEffect(function () { | ||
(0, react_1.useEffect)(function () { | ||
var f = foundation; | ||
f.init(); | ||
api && component_1.handleRef(props.current.apiRef, api(tslib_1.__assign({ foundation: f }, elements))); | ||
component_1.handleRef(props.current.foundationRef, f); | ||
api && (0, component_1.handleRef)(props.current.apiRef, api(tslib_1.__assign({ foundation: f }, elements))); | ||
(0, component_1.handleRef)(props.current.foundationRef, f); | ||
return function () { | ||
f.destroy(); | ||
component_1.handleRef(props.current.apiRef, null); | ||
component_1.handleRef(props.current.foundationRef, null); | ||
(0, component_1.handleRef)(props.current.apiRef, null); | ||
(0, component_1.handleRef)(props.current.foundationRef, null); | ||
Object.values(elements).map(function (element) { return element.destroy(); }); | ||
@@ -217,0 +217,0 @@ // @ts-ignore |
{ | ||
"name": "@rmwc/base", | ||
"version": "14.0.0-alpha.0", | ||
"version": "14.0.1-alpha.0", | ||
"description": "RMWC base module", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
"@material/dom": "^14.0.0", | ||
"@rmwc/types": "^14.0.0-alpha.0", | ||
"@rmwc/types": "^14.0.1-alpha.0", | ||
"@types/classnames": "^2.3.1", | ||
@@ -43,0 +43,0 @@ "classnames": "^2.3.1", |
@@ -10,5 +10,5 @@ "use strict"; | ||
var Portal = function (props) { | ||
var portalContext = react_1.useContext(PortalContext_1.PortalContext); | ||
var portalContext = (0, react_1.useContext)(PortalContext_1.PortalContext); | ||
var setPortalElement = portalContext === null || portalContext === void 0 ? void 0 : portalContext.setPortalElement; | ||
var portalRef = react_1.useCallback(function (node) { | ||
var portalRef = (0, react_1.useCallback)(function (node) { | ||
if (node !== null && setPortalElement) { | ||
@@ -23,5 +23,5 @@ setPortalElement(node); | ||
var children = _a.children, renderTo = _a.renderTo, menuSurfaceDomPositionRef = _a.menuSurfaceDomPositionRef; | ||
var _b = tslib_1.__read(react_1.useState(), 2), portalEl = _b[0], setPortalEl = _b[1]; | ||
var portalElementFromContext = react_1.useContext(PortalContext_1.PortalContext).portalElement; | ||
react_1.useEffect(function () { | ||
var _b = tslib_1.__read((0, react_1.useState)(), 2), portalEl = _b[0], setPortalEl = _b[1]; | ||
var portalElementFromContext = (0, react_1.useContext)(PortalContext_1.PortalContext).portalElement; | ||
(0, react_1.useEffect)(function () { | ||
var _a, _b; | ||
@@ -41,3 +41,3 @@ var element = undefined; | ||
if (!element) { | ||
console.warn("The selector you provided for renderToPortal \"" + renderTo + "\" didn't find any elements."); | ||
console.warn("The selector you provided for renderToPortal \"".concat(renderTo, "\" didn't find any elements.")); | ||
} | ||
@@ -57,3 +57,3 @@ } | ||
if (portalEl) { | ||
return (react_1.default.createElement("div", { ref: menuSurfaceDomPositionRef }, react_dom_1.createPortal(children, portalEl))); | ||
return (react_1.default.createElement("div", { ref: menuSurfaceDomPositionRef }, (0, react_dom_1.createPortal)(children, portalEl))); | ||
} | ||
@@ -60,0 +60,0 @@ else { |
@@ -10,6 +10,6 @@ "use strict"; | ||
}; | ||
exports.PortalContext = react_1.createContext(exports.portalContextDefaultValues); | ||
exports.PortalContext = (0, react_1.createContext)(exports.portalContextDefaultValues); | ||
var PortalProvider = function (_a) { | ||
var children = _a.children; | ||
var _b = tslib_1.__read(react_1.useState(null), 2), element = _b[0], setElement = _b[1]; | ||
var _b = tslib_1.__read((0, react_1.useState)(null), 2), element = _b[0], setElement = _b[1]; | ||
return (react_1.default.createElement(exports.PortalContext.Provider, { value: { | ||
@@ -16,0 +16,0 @@ portalElement: element, |
@@ -7,3 +7,3 @@ "use strict"; | ||
if (process && process.env && process.env.NODE_ENV !== 'production') { | ||
console.warn("RMWC Deprecation Warning: " + message); | ||
console.warn("RMWC Deprecation Warning: ".concat(message)); | ||
} | ||
@@ -28,4 +28,4 @@ }; | ||
/* istanbul ignore next */ | ||
exports.deprecationWarning((displayName || | ||
'') + " component prop '" + oldPropName + "' has been removed from and is no longer a valid prop."); | ||
(0, exports.deprecationWarning)("".concat(displayName || | ||
'', " component prop '").concat(oldPropName, "' has been removed from and is no longer a valid prop.")); | ||
} | ||
@@ -36,7 +36,7 @@ else { | ||
if (props[newPropName] !== props[oldPropName]) { | ||
propTransformMessage = " The old value has also been converted from '" + props[oldPropName] + "' to '" + props[newPropName] + "'"; | ||
propTransformMessage = " The old value has also been converted from '".concat(props[oldPropName], "' to '").concat(props[newPropName], "'"); | ||
} | ||
/* istanbul ignore next */ | ||
exports.deprecationWarning((displayName || | ||
'') + " component prop '" + oldPropName + "' has been replaced with '" + newPropName + "'. " + propTransformMessage); | ||
(0, exports.deprecationWarning)("".concat(displayName || | ||
'', " component prop '").concat(oldPropName, "' has been replaced with '").concat(newPropName, "'. ").concat(propTransformMessage)); | ||
} | ||
@@ -43,0 +43,0 @@ delete props[oldPropName]; |
@@ -48,3 +48,3 @@ "use strict"; | ||
} | ||
var rVal = (_a = this.array).push.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(items))); | ||
var rVal = (_a = this.array).push.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(items), false)); | ||
this.trigger('change'); | ||
@@ -51,0 +51,0 @@ return rVal; |
@@ -36,2 +36,2 @@ export interface FocusOptions { | ||
} | ||
export declare const focusTrapFactory: (el: HTMLElement, focusOptions?: FocusOptions | undefined) => FocusTrap; | ||
export declare const focusTrapFactory: (el: HTMLElement, focusOptions?: FocusOptions) => FocusTrap; |
@@ -11,7 +11,7 @@ "use strict"; | ||
: props.label | ||
? prefix + "-" + props.label | ||
: random_id_1.randomId(prefix); | ||
var _a = tslib_1.__read(react_1.useState(idToUse), 1), id = _a[0]; | ||
? "".concat(prefix, "-").concat(props.label) | ||
: (0, random_id_1.randomId)(prefix); | ||
var _a = tslib_1.__read((0, react_1.useState)(idToUse), 1), id = _a[0]; | ||
return id; | ||
}; | ||
exports.useId = useId; |
@@ -6,3 +6,2 @@ "use strict"; | ||
if (element instanceof Element) { | ||
/* istanbul ignore else */ | ||
if (element && element.closest) { | ||
@@ -14,3 +13,3 @@ return element.closest(selector); | ||
while (el) { | ||
if (exports.matches(el, selector)) { | ||
if ((0, exports.matches)(el, selector)) { | ||
return el; | ||
@@ -17,0 +16,0 @@ } |
@@ -13,5 +13,5 @@ "use strict"; | ||
window.requestAnimationFrame(function () { | ||
_iteration >= frames ? callback() : exports.raf(callback, frames, _iteration + 1); | ||
_iteration >= frames ? callback() : (0, exports.raf)(callback, frames, _iteration + 1); | ||
}); | ||
}; | ||
exports.raf = raf; |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
export declare const randomId: (prefix?: string | undefined) => string; | ||
export declare const randomId: (prefix?: string) => string; |
@@ -12,4 +12,4 @@ "use strict"; | ||
: (Math.random() + Math.random() + 1).toString(36).substring(2); | ||
return prefix + "-" + id; | ||
return "".concat(prefix, "-").concat(id); | ||
}; | ||
exports.randomId = randomId; |
@@ -18,6 +18,6 @@ "use strict"; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, test_utils_1.act(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
case 0: return [4 /*yield*/, (0, test_utils_1.act)(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, exports.wait(timeout)]; | ||
case 0: return [4 /*yield*/, (0, exports.wait)(timeout)]; | ||
case 1: | ||
@@ -24,0 +24,0 @@ _a.sent(); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var knobFunc = knobTypes[knobType]; | ||
var _a = tslib_1.__read(react_1.useState(defaultValue), 2), stateValue = _a[0], _stateSetter = _a[1]; | ||
var _a = tslib_1.__read((0, react_1.useState)(defaultValue), 2), stateValue = _a[0], _stateSetter = _a[1]; | ||
var knobValue = knobFunc(name, stateValue); | ||
@@ -15,0 +15,0 @@ var stateSetter = function (value) { |
@@ -9,4 +9,4 @@ "use strict"; | ||
var child = react_1.default.Children.only(props.children); | ||
return react_1.default.cloneElement(child, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, props), child.props), { className: classnames_1.default(props.className, child.props.className), style: tslib_1.__assign(tslib_1.__assign({}, child.props.style), props.style) })); | ||
return react_1.default.cloneElement(child, tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, props), child.props), { className: (0, classnames_1.default)(props.className, child.props.className), style: tslib_1.__assign(tslib_1.__assign({}, child.props.style), props.style) })); | ||
}; | ||
exports.wrapChild = wrapChild; |
@@ -15,3 +15,3 @@ "use strict"; | ||
.filter(function (v) { return !!v; }) | ||
.map(function (v) { return "mdc-theme--" + strings_1.toDashCase(v); }); | ||
.map(function (v) { return "mdc-theme--".concat((0, strings_1.toDashCase)(v)); }); | ||
}; | ||
@@ -26,3 +26,3 @@ exports.parseThemeOptions = parseThemeOptions; | ||
if (theme) { | ||
var classes = classnames_1.default(className, exports.parseThemeOptions(theme)); | ||
var classes = (0, classnames_1.default)(className, (0, exports.parseThemeOptions)(theme)); | ||
return react_1.default.createElement(Component, tslib_1.__assign({ className: classes }, rest)); | ||
@@ -29,0 +29,0 @@ } |
@@ -12,3 +12,3 @@ import { __assign, __read, __rest, __spreadArray, __values } from "tslib"; | ||
export var useClassNames = function (props, classNames) { | ||
return classNamesFunc.apply(void 0, __spreadArray(__spreadArray([props.className], __read((!!props.theme ? parseThemeOptions(props.theme) : []))), __read((typeof classNames === 'function' ? classNames(props) : classNames)))); | ||
return classNamesFunc.apply(void 0, __spreadArray(__spreadArray([props.className], __read((!!props.theme ? parseThemeOptions(props.theme) : [])), false), __read((typeof classNames === 'function' ? classNames(props) : classNames)), false)); | ||
}; | ||
@@ -15,0 +15,0 @@ export var mergeRefs = function () { |
@@ -54,3 +54,3 @@ import { SpecificEventListener } from '@material/base/types'; | ||
getProps: () => Props; | ||
emit: <T>(evtType: string, evtData: T, shouldBubble?: boolean | undefined) => CustomEvent<any>; | ||
emit: <T>(evtType: string, evtData: T, shouldBubble?: boolean) => CustomEvent<any>; | ||
}) => Foundation; | ||
@@ -57,0 +57,0 @@ props: Props; |
@@ -100,3 +100,3 @@ import { __assign, __read, __spreadArray } from "tslib"; | ||
// handle className | ||
var mergedClasses = classNames(className, __spreadArray([], __read(this._classes))); | ||
var mergedClasses = classNames(className, __spreadArray([], __read(this._classes), false)); | ||
// handle styles | ||
@@ -193,3 +193,3 @@ var mergedStyles = __assign(__assign({}, this._style), style); | ||
} | ||
return emitFactory(props.current).apply(void 0, __spreadArray([], __read(args))); | ||
return emitFactory(props.current).apply(void 0, __spreadArray([], __read(args), false)); | ||
} })); | ||
@@ -196,0 +196,0 @@ // handle apiRefs |
{ | ||
"name": "@rmwc/base", | ||
"version": "14.0.0-alpha.0", | ||
"version": "14.0.1-alpha.0", | ||
"description": "RMWC base module", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
"@material/dom": "^14.0.0", | ||
"@rmwc/types": "^14.0.0-alpha.0", | ||
"@rmwc/types": "^14.0.1-alpha.0", | ||
"@types/classnames": "^2.3.1", | ||
@@ -43,0 +43,0 @@ "classnames": "^2.3.1", |
@@ -35,3 +35,3 @@ import { __assign, __read } from "tslib"; | ||
if (!element) { | ||
console.warn("The selector you provided for renderToPortal \"" + renderTo + "\" didn't find any elements."); | ||
console.warn("The selector you provided for renderToPortal \"".concat(renderTo, "\" didn't find any elements.")); | ||
} | ||
@@ -38,0 +38,0 @@ } |
import { __assign } from "tslib"; | ||
export var deprecationWarning = function (message) { | ||
if (process && process.env && process.env.NODE_ENV !== 'production') { | ||
console.warn("RMWC Deprecation Warning: " + message); | ||
console.warn("RMWC Deprecation Warning: ".concat(message)); | ||
} | ||
@@ -23,4 +23,4 @@ }; | ||
/* istanbul ignore next */ | ||
deprecationWarning((displayName || | ||
'') + " component prop '" + oldPropName + "' has been removed from and is no longer a valid prop."); | ||
deprecationWarning("".concat(displayName || | ||
'', " component prop '").concat(oldPropName, "' has been removed from and is no longer a valid prop.")); | ||
} | ||
@@ -31,7 +31,7 @@ else { | ||
if (props[newPropName] !== props[oldPropName]) { | ||
propTransformMessage = " The old value has also been converted from '" + props[oldPropName] + "' to '" + props[newPropName] + "'"; | ||
propTransformMessage = " The old value has also been converted from '".concat(props[oldPropName], "' to '").concat(props[newPropName], "'"); | ||
} | ||
/* istanbul ignore next */ | ||
deprecationWarning((displayName || | ||
'') + " component prop '" + oldPropName + "' has been replaced with '" + newPropName + "'. " + propTransformMessage); | ||
deprecationWarning("".concat(displayName || | ||
'', " component prop '").concat(oldPropName, "' has been replaced with '").concat(newPropName, "'. ").concat(propTransformMessage)); | ||
} | ||
@@ -38,0 +38,0 @@ delete props[oldPropName]; |
@@ -45,3 +45,3 @@ import { __extends, __read, __spreadArray } from "tslib"; | ||
} | ||
var rVal = (_a = this.array).push.apply(_a, __spreadArray([], __read(items))); | ||
var rVal = (_a = this.array).push.apply(_a, __spreadArray([], __read(items), false)); | ||
this.trigger('change'); | ||
@@ -48,0 +48,0 @@ return rVal; |
@@ -36,2 +36,2 @@ export interface FocusOptions { | ||
} | ||
export declare const focusTrapFactory: (el: HTMLElement, focusOptions?: FocusOptions | undefined) => FocusTrap; | ||
export declare const focusTrapFactory: (el: HTMLElement, focusOptions?: FocusOptions) => FocusTrap; |
@@ -8,3 +8,3 @@ import { __read } from "tslib"; | ||
: props.label | ||
? prefix + "-" + props.label | ||
? "".concat(prefix, "-").concat(props.label) | ||
: randomId(prefix); | ||
@@ -11,0 +11,0 @@ var _a = __read(useState(idToUse), 1), id = _a[0]; |
export var closest = function (element, selector) { | ||
if (element instanceof Element) { | ||
/* istanbul ignore else */ | ||
if (element && element.closest) { | ||
@@ -5,0 +4,0 @@ return element.closest(selector); |
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
export declare const randomId: (prefix?: string | undefined) => string; | ||
export declare const randomId: (prefix?: string) => string; |
@@ -9,3 +9,3 @@ /** | ||
: (Math.random() + Math.random() + 1).toString(36).substring(2); | ||
return prefix + "-" + id; | ||
return "".concat(prefix, "-").concat(id); | ||
}; |
@@ -12,3 +12,3 @@ import { __assign, __rest } from "tslib"; | ||
.filter(function (v) { return !!v; }) | ||
.map(function (v) { return "mdc-theme--" + toDashCase(v); }); | ||
.map(function (v) { return "mdc-theme--".concat(toDashCase(v)); }); | ||
}; | ||
@@ -15,0 +15,0 @@ /** |
{ | ||
"name": "@rmwc/base", | ||
"version": "14.0.0-alpha.0", | ||
"version": "14.0.1-alpha.0", | ||
"description": "RMWC base module", | ||
@@ -40,3 +40,3 @@ "main": "dist/index.js", | ||
"@material/dom": "^14.0.0", | ||
"@rmwc/types": "^14.0.0-alpha.0", | ||
"@rmwc/types": "^14.0.1-alpha.0", | ||
"@types/classnames": "^2.3.1", | ||
@@ -43,0 +43,0 @@ "classnames": "^2.3.1", |
110113
113
2554
Updated@rmwc/types@^14.0.1-alpha.0