@deque/cauldron-react 4.1.0-canary.fcf29799 → 4.2.0-canary.abded4e2
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 +6 -0
- package/lib/components/Icon/types.d.ts +1 -1
- package/lib/components/LoaderOverlay/index.d.ts +2 -0
- package/lib/index.js +48 -10
- package/lib/minus.js +25 -0
- package/lib/utils/is-browser/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,3 +11,9 @@ and pull in the styles:
|
|
|
11
11
|
```sh
|
|
12
12
|
$ npm install @deque/cauldron-styles --save
|
|
13
13
|
```
|
|
14
|
+
|
|
15
|
+
## server-side rendering
|
|
16
|
+
|
|
17
|
+
Avoid referencing `window` properties, such as `document`, unless you are sure the code will only be executed in a browser environment. For instance, it is safe to reference `document` in an [Effect Hook](https://reactjs.org/docs/hooks-effect.html) or a lifecycle method like `componentDidMount()`, but not in the `render()` method of a class component.
|
|
18
|
+
|
|
19
|
+
Ensuring you only reference these objects when it is safe to do so will ensure that library consumers can use Cauldron with platforms that use an SSR engine, such as GatsbyJS and NextJS.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* GENERATED CODE. DO NOT EDIT DIRECTLY!
|
|
3
3
|
*/
|
|
4
4
|
/** IconType represents each valid icon type. */
|
|
5
|
-
export declare type IconType = 'add-user' | 'arrow-circle-up' | 'arrow-circle-down' | 'arrow-circle-left' | 'arrow-circle-right' | 'arrow-up' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrows-alt' | 'bolt' | 'caution' | 'check-circle' | 'check-shield' | 'check-solid' | 'check' | 'checkbox-checked' | 'checkbox-unchecked' | 'chevron-double-up' | 'chevron-double-down' | 'chevron-double-left' | 'chevron-double-right' | 'chevron-up' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'close' | 'code' | 'copy' | 'download' | 'exchange' | 'external-link' | 'eye' | 'filter' | 'flag' | 'gears' | 'grid' | 'hamburger-menu' | 'highlight' | 'info-circle-alt' | 'info-circle' | 'info-square' | 'kabob' | 'list' | 'lock' | 'magnifying-glass' | 'menu' | 'new-releases' | 'new' | 'no' | 'pencil' | 'plus' | 'question-circle' | 'radio-checked' | 'radio-unchecked' | 'recycle' | 'resend' | 'robot' | 'run-again' | 'save' | 'share' | 'sort-triangle' | 'sort' | 'star' | 'sun' | 'tag' | 'target' | 'trash' | 'triangle-up' | 'triangle-down' | 'triangle-left' | 'triangle-right' | 'upload';
|
|
5
|
+
export declare type IconType = 'add-user' | 'arrow-circle-up' | 'arrow-circle-down' | 'arrow-circle-left' | 'arrow-circle-right' | 'arrow-up' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrows-alt' | 'bolt' | 'caution' | 'check-circle' | 'check-shield' | 'check-solid' | 'check' | 'checkbox-checked' | 'checkbox-unchecked' | 'chevron-double-up' | 'chevron-double-down' | 'chevron-double-left' | 'chevron-double-right' | 'chevron-up' | 'chevron-down' | 'chevron-left' | 'chevron-right' | 'close' | 'code' | 'copy' | 'download' | 'exchange' | 'external-link' | 'eye' | 'filter' | 'flag' | 'gears' | 'grid' | 'hamburger-menu' | 'highlight' | 'info-circle-alt' | 'info-circle' | 'info-square' | 'kabob' | 'list' | 'lock' | 'magnifying-glass' | 'menu' | 'minus' | 'new-releases' | 'new' | 'no' | 'pencil' | 'plus' | 'question-circle' | 'radio-checked' | 'radio-unchecked' | 'recycle' | 'resend' | 'robot' | 'run-again' | 'save' | 'share' | 'sort-triangle' | 'sort' | 'star' | 'sun' | 'tag' | 'target' | 'trash' | 'triangle-up' | 'triangle-down' | 'triangle-left' | 'triangle-right' | 'upload';
|
|
6
6
|
/** iconTypes holds each valid icon type. */
|
|
7
7
|
export declare const iconTypes: string[];
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
interface LoaderOverlayProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
variant?: 'large' | 'small';
|
|
4
4
|
label?: string;
|
|
5
|
+
focusOnInitialRender?: boolean;
|
|
6
|
+
children?: React.ReactNode;
|
|
5
7
|
}
|
|
6
8
|
declare const LoaderOverlay: React.ForwardRefExoticComponent<LoaderOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
9
|
export default LoaderOverlay;
|
package/lib/index.js
CHANGED
|
@@ -164,6 +164,7 @@ var iconTypes = [
|
|
|
164
164
|
'lock',
|
|
165
165
|
'magnifying-glass',
|
|
166
166
|
'menu',
|
|
167
|
+
'minus',
|
|
167
168
|
'new-releases',
|
|
168
169
|
'new',
|
|
169
170
|
'no',
|
|
@@ -229,6 +230,7 @@ function __variableDynamicImportRuntime0__(path) {
|
|
|
229
230
|
case './icons/lock.svg': return Promise.resolve().then(function () { return require('./lock.js'); });
|
|
230
231
|
case './icons/magnifying-glass.svg': return Promise.resolve().then(function () { return require('./magnifying-glass.js'); });
|
|
231
232
|
case './icons/menu.svg': return Promise.resolve().then(function () { return require('./menu.js'); });
|
|
233
|
+
case './icons/minus.svg': return Promise.resolve().then(function () { return require('./minus.js'); });
|
|
232
234
|
case './icons/new-releases.svg': return Promise.resolve().then(function () { return require('./new-releases.js'); });
|
|
233
235
|
case './icons/new.svg': return Promise.resolve().then(function () { return require('./new.js'); });
|
|
234
236
|
case './icons/no.svg': return Promise.resolve().then(function () { return require('./no.js'); });
|
|
@@ -446,7 +448,18 @@ var MenuItem = /** @class */ (function (_super) {
|
|
|
446
448
|
|
|
447
449
|
var MENU_BREAKPOINT = 1024;
|
|
448
450
|
|
|
449
|
-
|
|
451
|
+
function isBrowser() {
|
|
452
|
+
return (typeof window !== 'undefined' &&
|
|
453
|
+
!!window.document &&
|
|
454
|
+
!!window.document.createElement);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
var isWide = function () {
|
|
458
|
+
if (!isBrowser()) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
return window.innerWidth >= MENU_BREAKPOINT;
|
|
462
|
+
};
|
|
450
463
|
|
|
451
464
|
var TopBar = /** @class */ (function (_super) {
|
|
452
465
|
tslib.__extends(TopBar, _super);
|
|
@@ -1282,10 +1295,11 @@ var Dialog = /** @class */ (function (_super) {
|
|
|
1282
1295
|
};
|
|
1283
1296
|
Dialog.prototype.render = function () {
|
|
1284
1297
|
var _this = this;
|
|
1285
|
-
var _a = this.props, dialogRef = _a.dialogRef, forceAction = _a.forceAction, className = _a.className, children = _a.children, closeButtonText = _a.closeButtonText, heading = _a.heading, show = _a.show,
|
|
1286
|
-
if (!show) {
|
|
1298
|
+
var _a = this.props, dialogRef = _a.dialogRef, forceAction = _a.forceAction, className = _a.className, children = _a.children, closeButtonText = _a.closeButtonText, heading = _a.heading, show = _a.show, other = tslib.__rest(_a, ["dialogRef", "forceAction", "className", "children", "closeButtonText", "heading", "show"]);
|
|
1299
|
+
if (!show || !isBrowser()) {
|
|
1287
1300
|
return null;
|
|
1288
1301
|
}
|
|
1302
|
+
var portal = this.props.portal || document.body;
|
|
1289
1303
|
var close = !forceAction ? (React__default.createElement("button", { className: "Dialog__close", type: "button", onClick: this.close },
|
|
1290
1304
|
React__default.createElement(Icon, { type: "close", "aria-hidden": "true" }),
|
|
1291
1305
|
React__default.createElement(Offscreen, null, closeButtonText))) : null;
|
|
@@ -1413,6 +1427,9 @@ var SkipLink = /** @class */ (function (_super) {
|
|
|
1413
1427
|
React__default.createElement("span", { className: "SkipLink__item--second" }, targetText))));
|
|
1414
1428
|
};
|
|
1415
1429
|
SkipLink.prototype.onClick = function () {
|
|
1430
|
+
if (!isBrowser()) {
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1416
1433
|
var element = document.querySelector(this.props.target);
|
|
1417
1434
|
if (element) {
|
|
1418
1435
|
element.tabIndex = -1;
|
|
@@ -1589,7 +1606,7 @@ function Tooltip(_a) {
|
|
|
1589
1606
|
targetElement === null || targetElement === void 0 ? void 0 : targetElement.setAttribute(association, [id, attrText].filter(Boolean).join(' '));
|
|
1590
1607
|
}
|
|
1591
1608
|
}, [targetElement, id]);
|
|
1592
|
-
return showTooltip || hideElementOnHidden
|
|
1609
|
+
return (showTooltip || hideElementOnHidden) && isBrowser()
|
|
1593
1610
|
? reactDom.createPortal(React__default.createElement("div", tslib.__assign({ id: id, className: classNames('Tooltip', "Tooltip--" + placement, className, {
|
|
1594
1611
|
TooltipInfo: variant === 'info',
|
|
1595
1612
|
'Tooltip--hidden': !showTooltip && hideElementOnHidden,
|
|
@@ -1907,10 +1924,11 @@ var Pointout = /** @class */ (function (_super) {
|
|
|
1907
1924
|
var _this = this;
|
|
1908
1925
|
var _c;
|
|
1909
1926
|
var _d = this.state, show = _d.show, style = _d.style, offscreenContentFocus = _d.offscreenContentFocus, headingId = _d.headingId;
|
|
1910
|
-
var _e = this.props, heading = _e.heading, ftpoRef = _e.ftpoRef, children = _e.children, noArrow = _e.noArrow, dismissText = _e.dismissText, previousText = _e.previousText, nextText = _e.nextText, showNext = _e.showNext, showPrevious = _e.showPrevious, arrowPosition = _e.arrowPosition, position = _e.position, className = _e.className, target = _e.target, disableOffscreenPointout = _e.disableOffscreenPointout,
|
|
1911
|
-
if (!show) {
|
|
1927
|
+
var _e = this.props, heading = _e.heading, ftpoRef = _e.ftpoRef, children = _e.children, noArrow = _e.noArrow, dismissText = _e.dismissText, previousText = _e.previousText, nextText = _e.nextText, showNext = _e.showNext, showPrevious = _e.showPrevious, arrowPosition = _e.arrowPosition, position = _e.position, className = _e.className, target = _e.target, disableOffscreenPointout = _e.disableOffscreenPointout, previousButtonProps = _e.previousButtonProps, nextButtonProps = _e.nextButtonProps, closeButtonProps = _e.closeButtonProps;
|
|
1928
|
+
if (!show || !isBrowser()) {
|
|
1912
1929
|
return null;
|
|
1913
1930
|
}
|
|
1931
|
+
var portal = this.props.portal || document.body;
|
|
1914
1932
|
var FTPO = (React__default.createElement("div", { className: classNames(className, 'Pointout', (_a = {
|
|
1915
1933
|
'Pointout--no-arrow': noArrow,
|
|
1916
1934
|
'Pointout--auto': !!target
|
|
@@ -2007,6 +2025,9 @@ var Pointout = /** @class */ (function (_super) {
|
|
|
2007
2025
|
*/
|
|
2008
2026
|
var queryAll = function (selector, context) {
|
|
2009
2027
|
if (context === void 0) { context = document; }
|
|
2028
|
+
if (!isBrowser()) {
|
|
2029
|
+
return [];
|
|
2030
|
+
}
|
|
2010
2031
|
return Array.prototype.slice.call(context.querySelectorAll(selector));
|
|
2011
2032
|
};
|
|
2012
2033
|
|
|
@@ -7979,22 +8000,39 @@ function AxeLoader() {
|
|
|
7979
8000
|
}
|
|
7980
8001
|
|
|
7981
8002
|
var LoaderOverlay = React__default.forwardRef(function (_a, ref) {
|
|
7982
|
-
var className = _a.className, variant = _a.variant, label = _a.label, other = tslib.__rest(_a, ["className", "variant", "label"]);
|
|
8003
|
+
var className = _a.className, variant = _a.variant, label = _a.label, children = _a.children, focusOnInitialRender = _a.focusOnInitialRender, other = tslib.__rest(_a, ["className", "variant", "label", "children", "focusOnInitialRender"]);
|
|
8004
|
+
var overlayRef = typeof ref === 'function' || !ref ? React.createRef() : ref;
|
|
8005
|
+
React.useEffect(function () {
|
|
8006
|
+
if (!!focusOnInitialRender && overlayRef.current) {
|
|
8007
|
+
setTimeout(function () {
|
|
8008
|
+
var _a;
|
|
8009
|
+
return (_a = overlayRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
8010
|
+
});
|
|
8011
|
+
}
|
|
8012
|
+
return;
|
|
8013
|
+
}, [overlayRef.current]);
|
|
8014
|
+
React.useEffect(function () {
|
|
8015
|
+
if (typeof ref === 'function') {
|
|
8016
|
+
ref(overlayRef.current);
|
|
8017
|
+
}
|
|
8018
|
+
}, [ref]);
|
|
7983
8019
|
return (React__default.createElement("div", tslib.__assign({ className: classNames('Loader__overlay', className, variant === 'large'
|
|
7984
8020
|
? 'Loader__overlay--large'
|
|
7985
8021
|
: variant === 'small'
|
|
7986
8022
|
? 'Loader__overlay--small'
|
|
7987
|
-
: ''), ref:
|
|
8023
|
+
: ''), ref: overlayRef, tabIndex: -1 }, other),
|
|
7988
8024
|
React__default.createElement("div", { className: "Loader__overlay__loader" },
|
|
7989
8025
|
React__default.createElement(Loader, { variant: variant }),
|
|
7990
8026
|
React__default.createElement(AxeLoader, null)),
|
|
7991
8027
|
label ? React__default.createElement("span", { className: "Loader__overlay__label" }, label) : null,
|
|
7992
|
-
|
|
8028
|
+
children));
|
|
7993
8029
|
});
|
|
7994
8030
|
LoaderOverlay.propTypes = {
|
|
7995
8031
|
className: PropTypes.string,
|
|
7996
8032
|
variant: PropTypes.oneOf(['large', 'small']),
|
|
7997
|
-
label: PropTypes.string
|
|
8033
|
+
label: PropTypes.string,
|
|
8034
|
+
focusOnInitialRender: PropTypes.bool,
|
|
8035
|
+
children: PropTypes.node
|
|
7998
8036
|
};
|
|
7999
8037
|
LoaderOverlay.displayName = 'LoaderOverlay';
|
|
8000
8038
|
|
package/lib/minus.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var React__default = _interopDefault(React);
|
|
7
|
+
|
|
8
|
+
var _path;
|
|
9
|
+
|
|
10
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
|
|
12
|
+
const SvgMinus = props => /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
+
overflow: "visible",
|
|
15
|
+
preserveAspectRatio: "none",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
height: 24,
|
|
18
|
+
width: 24
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
d: "M19 13H5v-2h14v2z",
|
|
21
|
+
vectorEffect: "non-scaling-stroke",
|
|
22
|
+
fill: "currentColor"
|
|
23
|
+
})));
|
|
24
|
+
|
|
25
|
+
exports.default = SvgMinus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBrowser(): boolean;
|