@react-md/divider
Advanced tools
Comparing version 2.0.0-alpha.12 to 2.0.0-alpha.13
@@ -23,26 +23,16 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import React, { forwardRef } from "react"; | ||
import React, { forwardRef, } from "react"; | ||
import cn from "classnames"; | ||
import { bem } from "@react-md/utils"; | ||
var block = bem("rmd-divider"); | ||
var Divider = function (providedProps) { | ||
var _a = providedProps, inset = _a.inset, vertical = _a.vertical, forwardedRef = _a.forwardedRef, className = _a.className, props = __rest(_a, ["inset", "vertical", "forwardedRef", "className"]); | ||
function Divider(_a, ref) { | ||
var _b = _a.inset, inset = _b === void 0 ? false : _b, _c = _a.vertical, vertical = _c === void 0 ? false : _c, _d = _a.role, role = _d === void 0 ? "separator" : _d, className = _a.className, props = __rest(_a, ["inset", "vertical", "role", "className"]); | ||
var Component = (vertical ? "div" : "hr"); | ||
return (React.createElement(Component, __assign({}, props, { ref: forwardedRef, className: cn(block({ inset: !vertical && inset, vertical: vertical }), className) }))); | ||
}; | ||
var defaultProps = { | ||
role: "separator", | ||
inset: false, | ||
vertical: false, | ||
}; | ||
Divider.defaultProps = defaultProps; | ||
return (React.createElement(Component, __assign({}, props, { ref: ref, role: role, className: cn(block({ inset: !vertical && inset, vertical: vertical }), className) }))); | ||
} | ||
var ForwardedDivider = forwardRef(Divider); | ||
if (process.env.NODE_ENV !== "production") { | ||
Divider.displayName = "Divider"; | ||
var PropTypes = null; | ||
try { | ||
PropTypes = require("prop-types"); | ||
} | ||
catch (e) { } | ||
if (PropTypes) { | ||
Divider.propTypes = { | ||
var PropTypes = require("prop-types"); | ||
ForwardedDivider.propTypes = { | ||
role: PropTypes.string, | ||
@@ -53,4 +43,5 @@ inset: PropTypes.bool, | ||
} | ||
catch (e) { } | ||
} | ||
export default forwardRef(function (props, ref) { return (React.createElement(Divider, __assign({}, props, { forwardedRef: ref }))); }); | ||
export default ForwardedDivider; | ||
//# sourceMappingURL=Divider.js.map |
@@ -55,26 +55,19 @@ var __assign = (this && this.__assign) || function () { | ||
/** | ||
* This component is used to create a vertical divider based on a parent element's | ||
* height. This is really only needed when the parent element **has no defined height**. | ||
* If there is a defined height, this component is not worth much as the height can | ||
* be computed in css as normal. This really just fixes the issue that the height would | ||
* be set to `auto` (which computes to 0 most of the time) when it is not set on a parent | ||
* element. | ||
* This component is used to create a vertical divider based on a parent | ||
* element's height. This is really only needed when the parent element **has no | ||
* defined height**. If there is a defined height, this component is not worth | ||
* much as the height can be computed in css as normal. This really just fixes | ||
* the issue that the height would be set to `auto` (which computes to 0 most of | ||
* the time) when it is not set on a parent element. | ||
*/ | ||
var VerticalDivider = function (providedProps) { | ||
var _a = providedProps, style = _a.style, maxHeight = _a.maxHeight, forwardedRef = _a.forwardedRef, props = __rest(_a, ["style", "maxHeight", "forwardedRef"]); | ||
var _b = useVerticalDividerHeight(maxHeight, forwardedRef), ref = _b.ref, height = _b.height; | ||
function VerticalDivider(_a, forwardedRef) { | ||
var style = _a.style, _b = _a.maxHeight, maxHeight = _b === void 0 ? 1 : _b, props = __rest(_a, ["style", "maxHeight"]); | ||
var _c = useVerticalDividerHeight(maxHeight, forwardedRef), ref = _c.ref, height = _c.height; | ||
return React.createElement(Divider, __assign({}, props, { style: __assign(__assign({}, style), { height: height }), ref: ref, vertical: true })); | ||
}; | ||
var defaultProps = { | ||
maxHeight: 1, | ||
}; | ||
VerticalDivider.defaultProps = defaultProps; | ||
} | ||
var ForwardedVerticalDivider = forwardRef(VerticalDivider); | ||
if (process.env.NODE_ENV !== "production") { | ||
var PropTypes = null; | ||
try { | ||
PropTypes = require("prop-types"); | ||
} | ||
catch (e) { } | ||
if (PropTypes) { | ||
VerticalDivider.propTypes = { | ||
var PropTypes = require("prop-types"); | ||
ForwardedVerticalDivider.propTypes = { | ||
maxHeight: PropTypes.number, | ||
@@ -84,3 +77,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
_validateMaxHeight: function (_a, _, componentName) { | ||
var maxHeight = _a.maxHeight; | ||
var _b = _a.maxHeight, maxHeight = _b === void 0 ? 1 : _b; | ||
if (maxHeight < 0) { | ||
@@ -94,4 +87,5 @@ return new Error("The maxHeight prop for `" + componentName + "` must be a number greater " + | ||
} | ||
catch (e) { } | ||
} | ||
export default forwardRef(function (props, ref) { return React.createElement(VerticalDivider, __assign({}, props, { forwardedRef: ref })); }); | ||
export default ForwardedVerticalDivider; | ||
//# sourceMappingURL=VerticalDivider.js.map |
@@ -39,22 +39,12 @@ "use strict"; | ||
var block = utils_1.bem("rmd-divider"); | ||
var Divider = function (providedProps) { | ||
var _a = providedProps, inset = _a.inset, vertical = _a.vertical, forwardedRef = _a.forwardedRef, className = _a.className, props = __rest(_a, ["inset", "vertical", "forwardedRef", "className"]); | ||
function Divider(_a, ref) { | ||
var _b = _a.inset, inset = _b === void 0 ? false : _b, _c = _a.vertical, vertical = _c === void 0 ? false : _c, _d = _a.role, role = _d === void 0 ? "separator" : _d, className = _a.className, props = __rest(_a, ["inset", "vertical", "role", "className"]); | ||
var Component = (vertical ? "div" : "hr"); | ||
return (react_1.default.createElement(Component, __assign({}, props, { ref: forwardedRef, className: classnames_1.default(block({ inset: !vertical && inset, vertical: vertical }), className) }))); | ||
}; | ||
var defaultProps = { | ||
role: "separator", | ||
inset: false, | ||
vertical: false, | ||
}; | ||
Divider.defaultProps = defaultProps; | ||
return (react_1.default.createElement(Component, __assign({}, props, { ref: ref, role: role, className: classnames_1.default(block({ inset: !vertical && inset, vertical: vertical }), className) }))); | ||
} | ||
var ForwardedDivider = react_1.forwardRef(Divider); | ||
if (process.env.NODE_ENV !== "production") { | ||
Divider.displayName = "Divider"; | ||
var PropTypes = null; | ||
try { | ||
PropTypes = require("prop-types"); | ||
} | ||
catch (e) { } | ||
if (PropTypes) { | ||
Divider.propTypes = { | ||
var PropTypes = require("prop-types"); | ||
ForwardedDivider.propTypes = { | ||
role: PropTypes.string, | ||
@@ -65,4 +55,5 @@ inset: PropTypes.bool, | ||
} | ||
catch (e) { } | ||
} | ||
exports.default = react_1.forwardRef(function (props, ref) { return (react_1.default.createElement(Divider, __assign({}, props, { forwardedRef: ref }))); }); | ||
exports.default = ForwardedDivider; | ||
//# sourceMappingURL=Divider.js.map |
@@ -68,26 +68,19 @@ "use strict"; | ||
/** | ||
* This component is used to create a vertical divider based on a parent element's | ||
* height. This is really only needed when the parent element **has no defined height**. | ||
* If there is a defined height, this component is not worth much as the height can | ||
* be computed in css as normal. This really just fixes the issue that the height would | ||
* be set to `auto` (which computes to 0 most of the time) when it is not set on a parent | ||
* element. | ||
* This component is used to create a vertical divider based on a parent | ||
* element's height. This is really only needed when the parent element **has no | ||
* defined height**. If there is a defined height, this component is not worth | ||
* much as the height can be computed in css as normal. This really just fixes | ||
* the issue that the height would be set to `auto` (which computes to 0 most of | ||
* the time) when it is not set on a parent element. | ||
*/ | ||
var VerticalDivider = function (providedProps) { | ||
var _a = providedProps, style = _a.style, maxHeight = _a.maxHeight, forwardedRef = _a.forwardedRef, props = __rest(_a, ["style", "maxHeight", "forwardedRef"]); | ||
var _b = useVerticalDividerHeight(maxHeight, forwardedRef), ref = _b.ref, height = _b.height; | ||
function VerticalDivider(_a, forwardedRef) { | ||
var style = _a.style, _b = _a.maxHeight, maxHeight = _b === void 0 ? 1 : _b, props = __rest(_a, ["style", "maxHeight"]); | ||
var _c = useVerticalDividerHeight(maxHeight, forwardedRef), ref = _c.ref, height = _c.height; | ||
return react_1.default.createElement(Divider_1.default, __assign({}, props, { style: __assign(__assign({}, style), { height: height }), ref: ref, vertical: true })); | ||
}; | ||
var defaultProps = { | ||
maxHeight: 1, | ||
}; | ||
VerticalDivider.defaultProps = defaultProps; | ||
} | ||
var ForwardedVerticalDivider = react_1.forwardRef(VerticalDivider); | ||
if (process.env.NODE_ENV !== "production") { | ||
var PropTypes = null; | ||
try { | ||
PropTypes = require("prop-types"); | ||
} | ||
catch (e) { } | ||
if (PropTypes) { | ||
VerticalDivider.propTypes = { | ||
var PropTypes = require("prop-types"); | ||
ForwardedVerticalDivider.propTypes = { | ||
maxHeight: PropTypes.number, | ||
@@ -97,3 +90,3 @@ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
_validateMaxHeight: function (_a, _, componentName) { | ||
var maxHeight = _a.maxHeight; | ||
var _b = _a.maxHeight, maxHeight = _b === void 0 ? 1 : _b; | ||
if (maxHeight < 0) { | ||
@@ -107,4 +100,5 @@ return new Error("The maxHeight prop for `" + componentName + "` must be a number greater " + | ||
} | ||
catch (e) { } | ||
} | ||
exports.default = react_1.forwardRef(function (props, ref) { return react_1.default.createElement(VerticalDivider, __assign({}, props, { forwardedRef: ref })); }); | ||
exports.default = ForwardedVerticalDivider; | ||
//# sourceMappingURL=VerticalDivider.js.map |
{ | ||
"name": "@react-md/divider", | ||
"version": "2.0.0-alpha.12", | ||
"version": "2.0.0-alpha.13", | ||
"description": "This package is used to create horizontal or vertical dividers in your application.", | ||
@@ -38,4 +38,4 @@ "scripts": { | ||
"dependencies": { | ||
"@react-md/theme": "^2.0.0-alpha.12", | ||
"@react-md/utils": "^2.0.0-alpha.12", | ||
"@react-md/theme": "^2.0.0-alpha.13", | ||
"@react-md/utils": "^2.0.0-alpha.13", | ||
"classnames": "^2.2.6" | ||
@@ -52,3 +52,3 @@ }, | ||
}, | ||
"gitHead": "b31afe8dc076cf0647ac3e99dc0b61f8f4b7b0e2" | ||
"gitHead": "47959dd8c691deae0310c7cd01b3c275699e6f8c" | ||
} |
@@ -8,4 +8,4 @@ import React, { HTMLAttributes } from "react"; | ||
* | ||
* If you want to create a divider that is centered, you most likely want | ||
* to use the `rmd-divider-theme-update-var` mixin instead to update the | ||
* If you want to create a divider that is centered, you most likely want to | ||
* use the `rmd-divider-theme-update-var` mixin instead to update the | ||
* `max-size` of the divider. | ||
@@ -15,13 +15,13 @@ */ | ||
/** | ||
* Boolean if the divider should be vertical instead of horizontal. This | ||
* will change the divider to be rendered as a `<div>` instead of an `<hr>`. | ||
* Boolean if the divider should be vertical instead of horizontal. This will | ||
* change the divider to be rendered as a `<div>` instead of an `<hr>`. | ||
* | ||
* Note: If your parent element of the divider does not have a static height set, | ||
* you **must** manually set the height of the divider to a static non-percentage | ||
* number OR use the `VerticalDivider` component instead to automagically create | ||
* a valid percentage height. | ||
* Note: If your parent element of the divider does not have a static height | ||
* set, you **must** manually set the height of the divider to a static | ||
* non-percentage number OR use the `VerticalDivider` component instead to | ||
* automagically create a valid percentage height. | ||
*/ | ||
vertical?: boolean; | ||
} | ||
declare const _default: React.ForwardRefExoticComponent<DividerProps & React.RefAttributes<DividerElement>>; | ||
export default _default; | ||
declare const ForwardedDivider: React.ForwardRefExoticComponent<DividerProps & React.RefAttributes<DividerElement>>; | ||
export default ForwardedDivider; |
import React, { HTMLAttributes, Ref } from "react"; | ||
export interface VerticalDividerProps extends HTMLAttributes<HTMLDivElement> { | ||
/** | ||
* The max height for the vertical divider. This number **must** be greater than 0 to work | ||
* correctly. | ||
* The max height for the vertical divider. This number **must** be greater | ||
* than 0 to work correctly. | ||
* | ||
@@ -26,3 +26,3 @@ * When the value is between 0 and 1, it will be used as a multiplier with the | ||
export declare function useVerticalDividerHeight(maxHeight: number, forwardedRef?: Ref<HTMLDivElement | null> | undefined): VerticalDividerHeight; | ||
declare const _default: React.ForwardRefExoticComponent<VerticalDividerProps & React.RefAttributes<HTMLDivElement>>; | ||
export default _default; | ||
declare const ForwardedVerticalDivider: React.ForwardRefExoticComponent<VerticalDividerProps & React.RefAttributes<HTMLDivElement>>; | ||
export default ForwardedVerticalDivider; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43
389898
719