@canonical/react-components 0.21.0 → 0.30.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.
- package/README.md +4 -4
- package/dist/components/AccordionSection/AccordionSection.js +0 -13
- package/dist/components/ActionButton/ActionButton.js +2 -5
- package/dist/components/Button/Button.d.ts +1 -2
- package/dist/components/Button/Button.js +2 -16
- package/dist/components/Chip/Chip.d.ts +1 -1
- package/dist/components/Chip/Chip.js +26 -29
- package/dist/components/CodeSnippet/CodeSnippetBlock.js +1 -12
- package/dist/components/CodeSnippet/CodeSnippetDropdown.js +1 -8
- package/dist/components/ContextualMenu/ContextualMenu.js +1 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +0 -16
- package/dist/components/Field/Field.js +0 -16
- package/dist/components/Icon/Icon.d.ts +8 -0
- package/dist/components/Icon/Icon.js +9 -1
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.js +30 -9
- package/dist/components/Link/Link.d.ts +1 -5
- package/dist/components/Link/Link.js +1 -4
- package/dist/components/List/List.js +1 -15
- package/dist/components/Modal/Modal.js +66 -17
- package/dist/components/Notification/Notification.js +5 -5
- package/dist/components/PaginationButton/PaginationButton.js +1 -8
- package/dist/components/PaginationItem/PaginationItem.js +0 -7
- package/dist/components/PasswordToggle/PasswordToggle.d.ts +99 -0
- package/dist/components/PasswordToggle/PasswordToggle.js +107 -0
- package/dist/components/PasswordToggle/index.d.ts +2 -0
- package/dist/components/PasswordToggle/index.js +15 -0
- package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +3 -4
- package/dist/components/SearchBox/SearchBox.d.ts +9 -8
- package/dist/components/SearchBox/SearchBox.js +22 -22
- package/dist/components/SummaryButton/SummaryButton.js +0 -11
- package/dist/components/Tabs/Tabs.js +1 -7
- package/dist/components/Tooltip/Tooltip.js +1 -12
- package/dist/hooks/useListener.js +1 -7
- package/dist/hooks/usePrevious.js +1 -7
- package/dist/hooks/useThrottle.js +1 -7
- package/dist/hooks/useWindowFitment.js +1 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/package.json +62 -56
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ This is a collection of components designed to be the way to consume [Vanilla Fr
|
|
|
6
6
|
|
|
7
7
|
See the [component docs](https://canonical-web-and-design.github.io/react-components/) for usage instructions.
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|

|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
@@ -36,9 +36,9 @@ Please file any issues at [GitHub](https://github.com/canonical-web-and-design/r
|
|
|
36
36
|
You might want to:
|
|
37
37
|
|
|
38
38
|
- [View the source](https://github.com/canonical-web-and-design/react-components) on GitHub.
|
|
39
|
-
- Read about [developing components](https://github.com/canonical-web-and-design/react-components/blob/
|
|
40
|
-
- Find out how to [publish to NPM](https://github.com/canonical-web-and-design/react-components/blob/
|
|
41
|
-
- Know how to [publish the docs](https://github.com/canonical-web-and-design/react-components/blob/
|
|
39
|
+
- Read about [developing components](https://github.com/canonical-web-and-design/react-components/blob/main/HACKING.md).
|
|
40
|
+
- Find out how to [publish to NPM](https://github.com/canonical-web-and-design/react-components/blob/main/PUBLISH-NPM-PACKAGE.md).
|
|
41
|
+
- Know how to [publish the docs](https://github.com/canonical-web-and-design/react-components/blob/main/PUBLISHING-DOCS.md) to GitHub Pages.
|
|
42
42
|
|
|
43
43
|
## Developing locally using this repository
|
|
44
44
|
|
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _nanoid = require("nanoid");
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -17,8 +15,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
17
15
|
|
|
18
16
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
17
|
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
18
|
var AccordionSection = function AccordionSection(_ref) {
|
|
23
19
|
var content = _ref.content,
|
|
24
20
|
expanded = _ref.expanded,
|
|
@@ -63,14 +59,5 @@ var AccordionSection = function AccordionSection(_ref) {
|
|
|
63
59
|
}, content));
|
|
64
60
|
};
|
|
65
61
|
|
|
66
|
-
AccordionSection.propTypes = {
|
|
67
|
-
content: _propTypes.default.node,
|
|
68
|
-
expanded: _propTypes.default.string,
|
|
69
|
-
headingLevel: _propTypes.default.number,
|
|
70
|
-
onTitleClick: _propTypes.default.func,
|
|
71
|
-
sectionKey: _propTypes.default.string,
|
|
72
|
-
setExpanded: _propTypes.default.func,
|
|
73
|
-
title: _propTypes.default.string
|
|
74
|
-
};
|
|
75
62
|
var _default = AccordionSection;
|
|
76
63
|
exports.default = _default;
|
|
@@ -11,8 +11,6 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _Button = require("../Button");
|
|
15
|
-
|
|
16
14
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
17
15
|
|
|
18
16
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
@@ -47,8 +45,7 @@ var SUCCESS_DURATION = 2000; // duration (ms) success tick is displayed
|
|
|
47
45
|
exports.SUCCESS_DURATION = SUCCESS_DURATION;
|
|
48
46
|
|
|
49
47
|
var ActionButton = function ActionButton(_ref) {
|
|
50
|
-
var
|
|
51
|
-
appearance = _ref$appearance === void 0 ? _Button.ButtonAppearance.NEUTRAL : _ref$appearance,
|
|
48
|
+
var appearance = _ref.appearance,
|
|
52
49
|
children = _ref.children,
|
|
53
50
|
className = _ref.className,
|
|
54
51
|
_ref$disabled = _ref.disabled,
|
|
@@ -126,7 +123,7 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
126
123
|
return window.clearTimeout(successTimeout);
|
|
127
124
|
};
|
|
128
125
|
}, [showSuccess]);
|
|
129
|
-
var buttonClasses = (0, _classnames.default)(className, "p-action-button", "p-button--".concat(appearance), {
|
|
126
|
+
var buttonClasses = (0, _classnames.default)(className, "p-action-button", appearance ? "p-button--".concat(appearance) : "p-button", {
|
|
130
127
|
"is-processing": showLoader || showSuccess,
|
|
131
128
|
"is-disabled": disabled,
|
|
132
129
|
"is-inline": inline
|
|
@@ -5,7 +5,6 @@ export declare const ButtonAppearance: {
|
|
|
5
5
|
readonly BRAND: "brand";
|
|
6
6
|
readonly LINK: "link";
|
|
7
7
|
readonly NEGATIVE: "negative";
|
|
8
|
-
readonly NEUTRAL: "neutral";
|
|
9
8
|
readonly POSITIVE: "positive";
|
|
10
9
|
};
|
|
11
10
|
/**
|
|
@@ -34,7 +33,7 @@ export declare type Props<P = null> = {
|
|
|
34
33
|
*/
|
|
35
34
|
disabled?: boolean;
|
|
36
35
|
/**
|
|
37
|
-
* Optional element or component to use instead of
|
|
36
|
+
* Optional element or component to use instead of `button`.
|
|
38
37
|
*/
|
|
39
38
|
element?: ElementType | ComponentType<P>;
|
|
40
39
|
/**
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.ButtonAppearance = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
9
|
|
|
12
10
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -24,7 +22,6 @@ var ButtonAppearance = {
|
|
|
24
22
|
BRAND: "brand",
|
|
25
23
|
LINK: "link",
|
|
26
24
|
NEGATIVE: "negative",
|
|
27
|
-
NEUTRAL: "neutral",
|
|
28
25
|
POSITIVE: "positive"
|
|
29
26
|
};
|
|
30
27
|
/**
|
|
@@ -39,8 +36,7 @@ exports.ButtonAppearance = ButtonAppearance;
|
|
|
39
36
|
* @template P - The type of the props if providing a component to `element`
|
|
40
37
|
*/
|
|
41
38
|
var Button = function Button(_ref) {
|
|
42
|
-
var
|
|
43
|
-
appearance = _ref$appearance === void 0 ? ButtonAppearance.NEUTRAL : _ref$appearance,
|
|
39
|
+
var appearance = _ref.appearance,
|
|
44
40
|
children = _ref.children,
|
|
45
41
|
className = _ref.className,
|
|
46
42
|
dense = _ref.dense,
|
|
@@ -53,7 +49,7 @@ var Button = function Button(_ref) {
|
|
|
53
49
|
small = _ref.small,
|
|
54
50
|
buttonProps = _objectWithoutProperties(_ref, ["appearance", "children", "className", "dense", "disabled", "element", "hasIcon", "inline", "onClick", "small"]);
|
|
55
51
|
|
|
56
|
-
var classes = (0, _classnames.default)("p-button--".concat(appearance), {
|
|
52
|
+
var classes = (0, _classnames.default)(appearance ? "p-button--".concat(appearance) : "p-button", {
|
|
57
53
|
"has-icon": hasIcon,
|
|
58
54
|
"is-dense": dense,
|
|
59
55
|
"is-disabled": Component !== "button" && disabled,
|
|
@@ -76,15 +72,5 @@ var Button = function Button(_ref) {
|
|
|
76
72
|
}, disabledProp, buttonProps), children);
|
|
77
73
|
};
|
|
78
74
|
|
|
79
|
-
Button.propTypes = {
|
|
80
|
-
children: _propTypes.default.node,
|
|
81
|
-
dense: _propTypes.default.bool,
|
|
82
|
-
disabled: _propTypes.default.bool,
|
|
83
|
-
element: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.elementType]),
|
|
84
|
-
hasIcon: _propTypes.default.bool,
|
|
85
|
-
inline: _propTypes.default.bool,
|
|
86
|
-
onClick: _propTypes.default.func,
|
|
87
|
-
small: _propTypes.default.bool
|
|
88
|
-
};
|
|
89
75
|
var _default = Button;
|
|
90
76
|
exports.default = _default;
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
|
|
12
10
|
var _utils = require("../../utils");
|
|
@@ -39,40 +37,39 @@ var Chip = function Chip(_ref) {
|
|
|
39
37
|
};
|
|
40
38
|
|
|
41
39
|
var chipValue = (0, _utils.highlightSubString)(value, subString).text;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"aria-pressed": selected,
|
|
45
|
-
role: "button",
|
|
46
|
-
tabIndex: !onDismiss ? 0 : null,
|
|
47
|
-
onClick: onClick,
|
|
48
|
-
onKeyDown: function onKeyDown(e) {
|
|
49
|
-
return _onKeyDown(e);
|
|
50
|
-
}
|
|
51
|
-
}, lead && /*#__PURE__*/_react.default.createElement("span", {
|
|
40
|
+
|
|
41
|
+
var chipContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, lead && /*#__PURE__*/_react.default.createElement("span", {
|
|
52
42
|
className: "p-chip__lead"
|
|
53
43
|
}, lead.toUpperCase()), /*#__PURE__*/_react.default.createElement("span", {
|
|
54
44
|
className: "p-chip__value",
|
|
55
45
|
dangerouslySetInnerHTML: {
|
|
56
46
|
__html: quoteValue ? "'".concat(chipValue, "'") : chipValue
|
|
57
47
|
}
|
|
58
|
-
})
|
|
59
|
-
className: "p-chip__dismiss",
|
|
60
|
-
onClick: function onClick() {
|
|
61
|
-
return onDismiss();
|
|
62
|
-
}
|
|
63
|
-
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
64
|
-
className: "p-icon--close"
|
|
65
|
-
}, "Dismiss")) : null);
|
|
66
|
-
};
|
|
48
|
+
}));
|
|
67
49
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
if (onDismiss) {
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
52
|
+
className: "p-chip",
|
|
53
|
+
"aria-pressed": selected
|
|
54
|
+
}, chipContent, /*#__PURE__*/_react.default.createElement("button", {
|
|
55
|
+
className: "p-chip__dismiss",
|
|
56
|
+
onClick: function onClick() {
|
|
57
|
+
return onDismiss();
|
|
58
|
+
}
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
60
|
+
className: "p-icon--close"
|
|
61
|
+
}, "Dismiss")));
|
|
62
|
+
} else {
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
64
|
+
className: "p-chip",
|
|
65
|
+
"aria-pressed": selected,
|
|
66
|
+
onClick: onClick,
|
|
67
|
+
onKeyDown: function onKeyDown(e) {
|
|
68
|
+
return _onKeyDown(e);
|
|
69
|
+
}
|
|
70
|
+
}, chipContent);
|
|
71
|
+
}
|
|
76
72
|
};
|
|
73
|
+
|
|
77
74
|
var _default = Chip;
|
|
78
75
|
exports.default = _default;
|
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = CodeSnippetBlock;
|
|
7
7
|
exports.CodeSnippetBlockAppearance = void 0;
|
|
8
8
|
|
|
9
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
|
|
11
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
10
|
|
|
13
11
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -75,13 +73,4 @@ function CodeSnippetBlock(_ref) {
|
|
|
75
73
|
}))), /*#__PURE__*/_react.default.createElement("pre", {
|
|
76
74
|
className: className
|
|
77
75
|
}, /*#__PURE__*/_react.default.createElement("code", null, isNumbered ? numberedCode : code)), content);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
CodeSnippetBlock.propTypes = {
|
|
81
|
-
code: _propTypes.default.string.isRequired,
|
|
82
|
-
content: _propTypes.default.node,
|
|
83
|
-
dropdowns: _propTypes.default.array,
|
|
84
|
-
stacked: _propTypes.default.bool,
|
|
85
|
-
title: _propTypes.default.string,
|
|
86
|
-
wrapLines: _propTypes.default.bool
|
|
87
|
-
};
|
|
76
|
+
}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = CodeSnippetDropdown;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
|
|
12
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -35,9 +33,4 @@ function CodeSnippetDropdown(_ref) {
|
|
|
35
33
|
key: value + "" || label
|
|
36
34
|
}, props), label);
|
|
37
35
|
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
CodeSnippetDropdown.propTypes = {
|
|
41
|
-
onChange: _propTypes.default.func.isRequired,
|
|
42
|
-
options: _propTypes.default.array.isRequired
|
|
43
|
-
};
|
|
36
|
+
}
|
|
@@ -236,7 +236,7 @@ var ContextualMenu = function ContextualMenu(_ref) {
|
|
|
236
236
|
},
|
|
237
237
|
type: "button"
|
|
238
238
|
}, toggleProps), toggleLabelFirst ? labelNode : null, hasToggleIcon ? /*#__PURE__*/_react.default.createElement("i", {
|
|
239
|
-
className: (0, _classnames.default)("p-icon--
|
|
239
|
+
className: (0, _classnames.default)("p-icon--chevron-down p-contextual-menu__indicator", {
|
|
240
240
|
"is-light": ["negative", "positive"].includes(toggleAppearance)
|
|
241
241
|
})
|
|
242
242
|
}) : null, toggleLabelFirst ? null : labelNode) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.adjustForWindow = void 0;
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
11
|
|
|
14
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -225,19 +223,5 @@ var ContextualMenuDropdown = function ContextualMenuDropdown(_ref) {
|
|
|
225
223
|
})));
|
|
226
224
|
};
|
|
227
225
|
|
|
228
|
-
ContextualMenuDropdown.propTypes = {
|
|
229
|
-
adjustedPosition: _propTypes.default.oneOf(["left", "center", "right"]),
|
|
230
|
-
autoAdjust: _propTypes.default.bool,
|
|
231
|
-
closePortal: _propTypes.default.func,
|
|
232
|
-
constrainPanelWidth: _propTypes.default.bool,
|
|
233
|
-
dropdownClassName: _propTypes.default.string,
|
|
234
|
-
dropdownContent: _propTypes.default.node,
|
|
235
|
-
id: _propTypes.default.string,
|
|
236
|
-
isOpen: _propTypes.default.bool,
|
|
237
|
-
links: _propTypes.default.array,
|
|
238
|
-
position: _propTypes.default.oneOf(["left", "center", "right"]),
|
|
239
|
-
setAdjustedPosition: _propTypes.default.func,
|
|
240
|
-
wrapperClass: _propTypes.default.string
|
|
241
|
-
};
|
|
242
226
|
var _default = ContextualMenuDropdown;
|
|
243
227
|
exports.default = _default;
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
9
|
|
|
12
10
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -91,19 +89,5 @@ var Field = function Field(_ref) {
|
|
|
91
89
|
}, content) : content);
|
|
92
90
|
};
|
|
93
91
|
|
|
94
|
-
Field.propTypes = {
|
|
95
|
-
caution: _propTypes.default.node,
|
|
96
|
-
children: _propTypes.default.node,
|
|
97
|
-
error: _propTypes.default.node,
|
|
98
|
-
forId: _propTypes.default.string,
|
|
99
|
-
help: _propTypes.default.node,
|
|
100
|
-
isSelect: _propTypes.default.bool,
|
|
101
|
-
label: _propTypes.default.node,
|
|
102
|
-
labelClassName: _propTypes.default.string,
|
|
103
|
-
labelFirst: _propTypes.default.bool,
|
|
104
|
-
required: _propTypes.default.bool,
|
|
105
|
-
stacked: _propTypes.default.bool,
|
|
106
|
-
success: _propTypes.default.node
|
|
107
|
-
};
|
|
108
92
|
var _default = Field;
|
|
109
93
|
exports.default = _default;
|
|
@@ -24,6 +24,14 @@ export declare const ICONS: {
|
|
|
24
24
|
readonly success: "success";
|
|
25
25
|
readonly user: "user";
|
|
26
26
|
readonly warning: "warning";
|
|
27
|
+
readonly facebook: "facebook";
|
|
28
|
+
readonly twitter: "twitter";
|
|
29
|
+
readonly instagram: "instagram";
|
|
30
|
+
readonly linkedin: "linkedin";
|
|
31
|
+
readonly youtube: "youtube";
|
|
32
|
+
readonly github: "github";
|
|
33
|
+
readonly rss: "rss";
|
|
34
|
+
readonly email: "email";
|
|
27
35
|
};
|
|
28
36
|
export declare type Props = PropsWithSpread<{
|
|
29
37
|
/**
|
|
@@ -40,7 +40,15 @@ var ICONS = {
|
|
|
40
40
|
spinner: "spinner",
|
|
41
41
|
success: "success",
|
|
42
42
|
user: "user",
|
|
43
|
-
warning: "warning"
|
|
43
|
+
warning: "warning",
|
|
44
|
+
facebook: "facebook",
|
|
45
|
+
twitter: "twitter",
|
|
46
|
+
instagram: "instagram",
|
|
47
|
+
linkedin: "linkedin",
|
|
48
|
+
youtube: "youtube",
|
|
49
|
+
github: "github",
|
|
50
|
+
rss: "rss",
|
|
51
|
+
email: "email"
|
|
44
52
|
};
|
|
45
53
|
exports.ICONS = ICONS;
|
|
46
54
|
|
|
@@ -13,6 +13,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _Field = _interopRequireDefault(require("../Field"));
|
|
15
15
|
|
|
16
|
+
var _CheckboxInput = _interopRequireDefault(require("../CheckboxInput"));
|
|
17
|
+
|
|
18
|
+
var _RadioInput = _interopRequireDefault(require("../RadioInput"));
|
|
19
|
+
|
|
16
20
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
21
|
|
|
18
22
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -42,30 +46,47 @@ var Input = function Input(_ref) {
|
|
|
42
46
|
inputProps = _objectWithoutProperties(_ref, ["caution", "className", "error", "help", "id", "label", "labelClassName", "required", "stacked", "success", "takeFocus", "type", "wrapperClassName"]);
|
|
43
47
|
|
|
44
48
|
var inputRef = (0, _react.useRef)(null);
|
|
45
|
-
var
|
|
49
|
+
var fieldLabel = !["checkbox", "radio"].includes(type) ? label : "";
|
|
50
|
+
|
|
51
|
+
var input = /*#__PURE__*/_react.default.createElement("input", _extends({
|
|
52
|
+
className: (0, _classnames.default)("p-form-validation__input", className),
|
|
53
|
+
id: id,
|
|
54
|
+
ref: inputRef,
|
|
55
|
+
required: required,
|
|
56
|
+
type: type,
|
|
57
|
+
"aria-invalid": !!error
|
|
58
|
+
}, inputProps));
|
|
59
|
+
|
|
46
60
|
(0, _react.useEffect)(function () {
|
|
47
61
|
if (takeFocus) {
|
|
48
62
|
inputRef.current.focus();
|
|
49
63
|
}
|
|
50
64
|
}, [takeFocus]);
|
|
65
|
+
|
|
66
|
+
if (type === "checkbox") {
|
|
67
|
+
input = /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, _extends({
|
|
68
|
+
label: label,
|
|
69
|
+
id: id
|
|
70
|
+
}, inputProps));
|
|
71
|
+
} else if (type === "radio") {
|
|
72
|
+
input = /*#__PURE__*/_react.default.createElement(_RadioInput.default, _extends({
|
|
73
|
+
label: label,
|
|
74
|
+
id: id
|
|
75
|
+
}, inputProps));
|
|
76
|
+
}
|
|
77
|
+
|
|
51
78
|
return /*#__PURE__*/_react.default.createElement(_Field.default, {
|
|
52
79
|
caution: caution,
|
|
53
80
|
className: wrapperClassName,
|
|
54
81
|
error: error,
|
|
55
82
|
forId: id,
|
|
56
83
|
help: help,
|
|
57
|
-
label:
|
|
84
|
+
label: fieldLabel,
|
|
58
85
|
labelClassName: labelClassName,
|
|
59
|
-
labelFirst: labelFirst,
|
|
60
86
|
required: required,
|
|
61
87
|
stacked: stacked,
|
|
62
88
|
success: success
|
|
63
|
-
},
|
|
64
|
-
className: (0, _classnames.default)("p-form-validation__input", className),
|
|
65
|
-
id: id,
|
|
66
|
-
ref: inputRef,
|
|
67
|
-
type: type
|
|
68
|
-
}, inputProps)));
|
|
89
|
+
}, input);
|
|
69
90
|
};
|
|
70
91
|
|
|
71
92
|
var _default = Input;
|
|
@@ -9,10 +9,6 @@ export declare type Props = PropsWithSpread<{
|
|
|
9
9
|
* Optional class(es) to pass to the wrapping anchor element.
|
|
10
10
|
*/
|
|
11
11
|
className?: ClassName;
|
|
12
|
-
/**
|
|
13
|
-
* Whether the link should have external styling.
|
|
14
|
-
*/
|
|
15
|
-
external?: boolean;
|
|
16
12
|
/**
|
|
17
13
|
* Whether the link should have inverted styling.
|
|
18
14
|
*/
|
|
@@ -26,5 +22,5 @@ export declare type Props = PropsWithSpread<{
|
|
|
26
22
|
*/
|
|
27
23
|
top?: boolean;
|
|
28
24
|
}, HTMLProps<HTMLAnchorElement>>;
|
|
29
|
-
declare const Link: ({ children, className,
|
|
25
|
+
declare const Link: ({ children, className, href, inverted, soft, top, ...props }: Props) => JSX.Element;
|
|
30
26
|
export default Link;
|
|
@@ -20,8 +20,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
20
20
|
var Link = function Link(_ref) {
|
|
21
21
|
var children = _ref.children,
|
|
22
22
|
className = _ref.className,
|
|
23
|
-
_ref$external = _ref.external,
|
|
24
|
-
external = _ref$external === void 0 ? false : _ref$external,
|
|
25
23
|
_ref$href = _ref.href,
|
|
26
24
|
href = _ref$href === void 0 ? "#" : _ref$href,
|
|
27
25
|
_ref$inverted = _ref.inverted,
|
|
@@ -30,11 +28,10 @@ var Link = function Link(_ref) {
|
|
|
30
28
|
soft = _ref$soft === void 0 ? false : _ref$soft,
|
|
31
29
|
_ref$top = _ref.top,
|
|
32
30
|
top = _ref$top === void 0 ? false : _ref$top,
|
|
33
|
-
props = _objectWithoutProperties(_ref, ["children", "className", "
|
|
31
|
+
props = _objectWithoutProperties(_ref, ["children", "className", "href", "inverted", "soft", "top"]);
|
|
34
32
|
|
|
35
33
|
var link = /*#__PURE__*/_react.default.createElement("a", _extends({
|
|
36
34
|
className: (0, _classnames.default)(className, {
|
|
37
|
-
"p-link--external": external,
|
|
38
35
|
"p-link--inverted": inverted,
|
|
39
36
|
"p-link--soft": soft,
|
|
40
37
|
"p-top__link": top
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
9
|
|
|
12
10
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -30,7 +28,7 @@ var generateItems = function generateItems(items, ticked, inline, stepped) {
|
|
|
30
28
|
var TitleComponent = "h3";
|
|
31
29
|
var liProps;
|
|
32
30
|
|
|
33
|
-
if (_react.default.isValidElement(item) || typeof item === "string" || typeof item === "number") {
|
|
31
|
+
if ( /*#__PURE__*/_react.default.isValidElement(item) || typeof item === "string" || typeof item === "number") {
|
|
34
32
|
content = item;
|
|
35
33
|
} else if (item && _typeof(item) === "object" && "content" in item) {
|
|
36
34
|
if ("titleElement" in item) {
|
|
@@ -104,17 +102,5 @@ var List = function List(_ref) {
|
|
|
104
102
|
}, props), generateItems(items, ticked, inline || middot || stretch, stepped));
|
|
105
103
|
};
|
|
106
104
|
|
|
107
|
-
List.propTypes = {
|
|
108
|
-
items: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.array]).isRequired,
|
|
109
|
-
detailed: _propTypes.default.bool,
|
|
110
|
-
divided: _propTypes.default.bool,
|
|
111
|
-
inline: _propTypes.default.bool,
|
|
112
|
-
isDark: _propTypes.default.bool,
|
|
113
|
-
middot: _propTypes.default.bool,
|
|
114
|
-
split: _propTypes.default.bool,
|
|
115
|
-
stepped: _propTypes.default.bool,
|
|
116
|
-
stretch: _propTypes.default.bool,
|
|
117
|
-
ticked: _propTypes.default.bool
|
|
118
|
-
};
|
|
119
105
|
var _default = List;
|
|
120
106
|
exports.default = _default;
|
|
@@ -33,39 +33,88 @@ var Modal = function Modal(_ref) {
|
|
|
33
33
|
title = _ref.title,
|
|
34
34
|
wrapperProps = _objectWithoutProperties(_ref, ["buttonRow", "children", "className", "close", "title"]);
|
|
35
35
|
|
|
36
|
+
// list of focusable selectors is based on this Stack Overflow answer:
|
|
37
|
+
// https://stackoverflow.com/a/30753870/3732840
|
|
38
|
+
var focusableElementSelectors = 'a[href]:not([tabindex="-1"]), button:not([disabled]), textarea:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), area[href]:not([tabindex="-1"]), iframe:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), [contentEditable=true]:not([tabindex="-1"])';
|
|
36
39
|
var descriptionId = (0, _react.useRef)((0, _nanoid.nanoid)());
|
|
37
|
-
var titleId = (0, _react.useRef)((0, _nanoid.nanoid)());
|
|
38
|
-
|
|
40
|
+
var titleId = (0, _react.useRef)((0, _nanoid.nanoid)());
|
|
41
|
+
var shouldClose = (0, _react.useRef)(false);
|
|
42
|
+
var modalRef = (0, _react.useRef)(null);
|
|
43
|
+
var focusableModalElements = (0, _react.useRef)(null);
|
|
44
|
+
|
|
45
|
+
var handleTabKey = function handleTabKey(e) {
|
|
46
|
+
if (focusableModalElements.current.length > 0) {
|
|
47
|
+
var firstElement = focusableModalElements.current[0];
|
|
48
|
+
var lastElement = focusableModalElements.current[focusableModalElements.current.length - 1];
|
|
49
|
+
|
|
50
|
+
if (!e.shiftKey && document.activeElement === lastElement) {
|
|
51
|
+
firstElement.focus();
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
}
|
|
39
54
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Close panel if Esc keydown detected
|
|
44
|
-
if (close) {
|
|
45
|
-
close();
|
|
46
|
-
}
|
|
55
|
+
if (e.shiftKey && document.activeElement === firstElement) {
|
|
56
|
+
lastElement.focus();
|
|
57
|
+
return e.preventDefault();
|
|
47
58
|
}
|
|
48
|
-
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
49
61
|
|
|
62
|
+
var keyListenersMap = new Map([[27, close], [9, handleTabKey]]);
|
|
63
|
+
(0, _react.useEffect)(function () {
|
|
64
|
+
modalRef.current.focus();
|
|
65
|
+
}, [modalRef]);
|
|
66
|
+
(0, _react.useEffect)(function () {
|
|
67
|
+
var _focusableModalElemen;
|
|
50
68
|
|
|
51
|
-
|
|
69
|
+
focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
|
|
70
|
+
(_focusableModalElemen = focusableModalElements.current[0]) === null || _focusableModalElemen === void 0 ? void 0 : _focusableModalElemen.focus();
|
|
71
|
+
}, []);
|
|
72
|
+
(0, _react.useEffect)(function () {
|
|
73
|
+
var keyDown = function keyDown(e) {
|
|
74
|
+
var listener = keyListenersMap.get(e.keyCode);
|
|
75
|
+
return listener && listener(e);
|
|
76
|
+
};
|
|
52
77
|
|
|
78
|
+
document.addEventListener("keydown", keyDown);
|
|
53
79
|
return function () {
|
|
54
80
|
document.removeEventListener("keydown", keyDown);
|
|
55
81
|
};
|
|
56
|
-
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
var handleContentOnMouseDown = function handleContentOnMouseDown() {
|
|
85
|
+
shouldClose.current = false;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var handleContentOnMouseUp = function handleContentOnMouseUp() {
|
|
89
|
+
shouldClose.current = false;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var handleOverlayOnMouseDown = function handleOverlayOnMouseDown(event) {
|
|
93
|
+
if (event.target === modalRef.current) {
|
|
94
|
+
shouldClose.current = true;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var handleOverlayOnClick = function handleOverlayOnClick() {
|
|
99
|
+
if (shouldClose.current) {
|
|
100
|
+
close();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
57
104
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
58
105
|
className: (0, _classnames.default)("p-modal", className),
|
|
59
|
-
onClick:
|
|
60
|
-
|
|
106
|
+
onClick: handleOverlayOnClick,
|
|
107
|
+
onMouseDown: handleOverlayOnMouseDown
|
|
108
|
+
}, wrapperProps, {
|
|
109
|
+
ref: modalRef
|
|
110
|
+
}), /*#__PURE__*/_react.default.createElement("section", {
|
|
61
111
|
className: "p-modal__dialog",
|
|
62
112
|
role: "dialog",
|
|
63
113
|
"aria-modal": "true",
|
|
64
114
|
"aria-labelledby": titleId.current,
|
|
65
115
|
"aria-describedby": descriptionId.current,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
116
|
+
onMouseDown: handleContentOnMouseDown,
|
|
117
|
+
onMouseUp: handleContentOnMouseUp
|
|
69
118
|
}, !!title && /*#__PURE__*/_react.default.createElement("header", {
|
|
70
119
|
className: "p-modal__header"
|
|
71
120
|
}, /*#__PURE__*/_react.default.createElement("h2", {
|