@canonical/react-components 0.40.0 → 0.41.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/dist/components/ActionButton/ActionButton.js +5 -4
- package/dist/components/Chip/Chip.js +4 -5
- package/dist/components/ContextualMenu/ContextualMenu.js +5 -5
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +5 -5
- package/dist/components/MainTable/MainTable.js +1 -1
- package/dist/components/ModularTable/ModularTable.d.ts +1 -1
- package/dist/components/ModularTable/ModularTable.js +40 -22
- package/dist/components/Notification/Notification.d.ts +6 -1
- package/dist/components/Notification/Notification.js +8 -7
- package/dist/components/Pagination/PaginationButton/PaginationButton.js +5 -5
- package/dist/components/PasswordToggle/PasswordToggle.js +6 -6
- package/dist/components/SearchAndFilter/SearchAndFilter.js +23 -8
- package/dist/components/SearchBox/SearchBox.js +5 -5
- package/dist/components/Tooltip/Tooltip.js +9 -11
- package/dist/enums.js +5 -5
- package/dist/hooks/useWindowFitment.d.ts +12 -0
- package/dist/hooks/useWindowFitment.js +16 -4
- package/package.json +31 -31
- package/dist/testing/mock-scss.js +0 -4
|
@@ -45,13 +45,14 @@ exports.LOADER_MIN_DURATION = LOADER_MIN_DURATION;
|
|
|
45
45
|
var SUCCESS_DURATION = 2000; // duration (ms) success tick is displayed
|
|
46
46
|
|
|
47
47
|
exports.SUCCESS_DURATION = SUCCESS_DURATION;
|
|
48
|
-
var Label;
|
|
49
|
-
exports.Label = Label;
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
52
50
|
Label["WAITING"] = "Waiting for action to complete";
|
|
53
51
|
Label["SUCCESS"] = "Action completed";
|
|
54
|
-
|
|
52
|
+
return Label;
|
|
53
|
+
}({});
|
|
54
|
+
|
|
55
|
+
exports.Label = Label;
|
|
55
56
|
|
|
56
57
|
var ActionButton = function ActionButton(_ref) {
|
|
57
58
|
var appearance = _ref.appearance,
|
|
@@ -23,13 +23,12 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
23
23
|
|
|
24
24
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
25
|
|
|
26
|
-
var Label
|
|
27
|
-
exports.Label = Label;
|
|
28
|
-
|
|
29
|
-
(function (Label) {
|
|
26
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
30
27
|
Label["Dismiss"] = "Dismiss";
|
|
31
|
-
|
|
28
|
+
return Label;
|
|
29
|
+
}({});
|
|
32
30
|
|
|
31
|
+
exports.Label = Label;
|
|
33
32
|
var ChipType = {
|
|
34
33
|
CAUTION: "caution",
|
|
35
34
|
INFORMATION: "information",
|
|
@@ -49,17 +49,17 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
49
49
|
|
|
50
50
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
51
51
|
|
|
52
|
-
var Label
|
|
52
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
53
|
+
Label["Toggle"] = "Toggle menu";
|
|
54
|
+
return Label;
|
|
55
|
+
}({});
|
|
53
56
|
/**
|
|
54
57
|
* The props for the ContextualMenu component.
|
|
55
58
|
* @template L - The type of the link props.
|
|
56
59
|
*/
|
|
57
60
|
|
|
58
|
-
exports.Label = Label;
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
Label["Toggle"] = "Toggle menu";
|
|
62
|
-
})(Label || (exports.Label = Label = {}));
|
|
62
|
+
exports.Label = Label;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Get the node to use for positioning the menu.
|
|
@@ -48,17 +48,17 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
48
48
|
|
|
49
49
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
50
50
|
|
|
51
|
-
var Label
|
|
51
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
52
|
+
Label["Dropdown"] = "submenu";
|
|
53
|
+
return Label;
|
|
54
|
+
}({});
|
|
52
55
|
/**
|
|
53
56
|
* The type of the menu links.
|
|
54
57
|
* @template L - The type of the link props.
|
|
55
58
|
*/
|
|
56
59
|
|
|
57
|
-
exports.Label = Label;
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
Label["Dropdown"] = "submenu";
|
|
61
|
-
})(Label || (exports.Label = Label = {}));
|
|
61
|
+
exports.Label = Label;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Calculate the styles for the menu.
|
|
@@ -94,7 +94,7 @@ var generateHeaders = function generateHeaders(currentSortKey, currentSortDirect
|
|
|
94
94
|
return /*#__PURE__*/_react.default.createElement(_TableHeader.default, _extends({
|
|
95
95
|
key: index,
|
|
96
96
|
sort: sortDirection,
|
|
97
|
-
onClick: sortable ? updateSort.bind(_this, setSortKey, setSortDirection, sortKey, sortDirection) : undefined
|
|
97
|
+
onClick: sortable && sortKey ? updateSort.bind(_this, setSortKey, setSortDirection, sortKey, sortDirection) : undefined
|
|
98
98
|
}, props), content);
|
|
99
99
|
}); // When there is expanding content then provide an extra hidden header to
|
|
100
100
|
// account for the extra cell in the body rows.
|
|
@@ -37,5 +37,5 @@ export type Props<D extends Record<string, unknown>> = PropsWithSpread<{
|
|
|
37
37
|
getCellProps?: (cell: Cell<D>) => Partial<TableCellProps & HTMLProps<HTMLTableCellElement>>;
|
|
38
38
|
getRowId?: UseTableOptions<D>["getRowId"];
|
|
39
39
|
}, HTMLProps<HTMLTableElement>>;
|
|
40
|
-
declare function ModularTable({ data, columns, emptyMsg, footer, sortable, getHeaderProps, getRowProps, getCellProps, getRowId, ...props }: Props<
|
|
40
|
+
declare function ModularTable<D extends Record<string, unknown>>({ data, columns, emptyMsg, footer, sortable, getHeaderProps, getRowProps, getCellProps, getRowId, ...props }: Props<D>): JSX.Element;
|
|
41
41
|
export default ModularTable;
|
|
@@ -25,15 +25,49 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
27
27
|
|
|
28
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
29
|
+
|
|
30
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
|
+
|
|
28
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
33
|
|
|
30
34
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
35
|
|
|
32
36
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
var generateCell = function generateCell(cell, getCellProps) {
|
|
39
|
+
var _cell$column$getCellI, _cell$column;
|
|
40
|
+
|
|
41
|
+
var hasColumnIcon = cell.column.getCellIcon;
|
|
42
|
+
var iconName = hasColumnIcon && ((_cell$column$getCellI = (_cell$column = cell.column).getCellIcon) === null || _cell$column$getCellI === void 0 ? void 0 : _cell$column$getCellI.call(_cell$column, cell));
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_TableCell.default, cell.getCellProps([{
|
|
44
|
+
className: cell.column.className
|
|
45
|
+
}, {
|
|
46
|
+
className: hasColumnIcon ? "p-table__cell--icon-placeholder" : ""
|
|
47
|
+
}, _objectSpread({}, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell))]), iconName && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
48
|
+
name: iconName
|
|
49
|
+
}), cell.render("Cell"));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
var generateRows = function generateRows(rows, prepareRow, getRowProps, getCellProps) {
|
|
53
|
+
var tableRows = [];
|
|
54
|
+
rows.forEach(function (row) {
|
|
55
|
+
var _row$subRows;
|
|
35
56
|
|
|
36
|
-
|
|
57
|
+
// This function is responsible for lazily preparing a row for rendering.
|
|
58
|
+
// Any row that you intend to render in your table needs to be passed to this function before every render.
|
|
59
|
+
// see: https://react-table.tanstack.com/docs/api/useTable#instance-properties
|
|
60
|
+
prepareRow(row);
|
|
61
|
+
tableRows.push( /*#__PURE__*/_react.default.createElement(_TableRow.default, row.getRowProps(getRowProps === null || getRowProps === void 0 ? void 0 : getRowProps(row)), row.cells.map(function (cell) {
|
|
62
|
+
return generateCell(cell, getCellProps);
|
|
63
|
+
})));
|
|
64
|
+
|
|
65
|
+
if ((_row$subRows = row.subRows) !== null && _row$subRows !== void 0 && _row$subRows.length) {
|
|
66
|
+
tableRows = tableRows.concat(generateRows(row.subRows, prepareRow, getRowProps, getCellProps));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return tableRows;
|
|
70
|
+
};
|
|
37
71
|
|
|
38
72
|
function ModularTable(_ref) {
|
|
39
73
|
var data = _ref.data,
|
|
@@ -68,27 +102,11 @@ function ModularTable(_ref) {
|
|
|
68
102
|
}, {
|
|
69
103
|
className: column.getCellIcon ? "p-table__cell--icon-placeholder" : ""
|
|
70
104
|
}, _objectSpread({}, getHeaderProps === null || getHeaderProps === void 0 ? void 0 : getHeaderProps(column)), // Only call this if we want it to be sortable too.
|
|
71
|
-
sortable ? column.getSortByToggleProps(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// This function is responsible for lazily preparing a row for rendering.
|
|
75
|
-
// Any row that you intend to render in your table needs to be passed to this function before every render.
|
|
76
|
-
// see: https://react-table.tanstack.com/docs/api/useTable#instance-properties
|
|
77
|
-
prepareRow(row);
|
|
78
|
-
return /*#__PURE__*/_react.default.createElement(_TableRow.default, row.getRowProps(getRowProps === null || getRowProps === void 0 ? void 0 : getRowProps(row)), row.cells.map(function (cell) {
|
|
79
|
-
var _cell$column$getCellI, _cell$column;
|
|
80
|
-
|
|
81
|
-
var hasColumnIcon = cell.column.getCellIcon;
|
|
82
|
-
var iconName = hasColumnIcon && ((_cell$column$getCellI = (_cell$column = cell.column).getCellIcon) === null || _cell$column$getCellI === void 0 ? void 0 : _cell$column$getCellI.call(_cell$column, cell));
|
|
83
|
-
return /*#__PURE__*/_react.default.createElement(_TableCell.default, cell.getCellProps([{
|
|
84
|
-
className: cell.column.className
|
|
85
|
-
}, {
|
|
86
|
-
className: hasColumnIcon ? "p-table__cell--icon-placeholder" : ""
|
|
87
|
-
}, _objectSpread({}, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell))]), iconName && /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
88
|
-
name: iconName
|
|
89
|
-
}), cell.render("Cell"));
|
|
105
|
+
sortable ? column.getSortByToggleProps({
|
|
106
|
+
title: undefined
|
|
107
|
+
}) : {}])), column.render("Header"));
|
|
90
108
|
}));
|
|
91
|
-
}), showEmpty && /*#__PURE__*/_react.default.createElement(_TableRow.default, null, /*#__PURE__*/_react.default.createElement(_TableCell.default, {
|
|
109
|
+
})), /*#__PURE__*/_react.default.createElement("tbody", getTableBodyProps(), generateRows(rows, prepareRow, getRowProps, getCellProps), showEmpty && /*#__PURE__*/_react.default.createElement(_TableRow.default, null, /*#__PURE__*/_react.default.createElement(_TableCell.default, {
|
|
92
110
|
colSpan: columns.length
|
|
93
111
|
}, emptyMsg)), footer && /*#__PURE__*/_react.default.createElement(_TableRow.default, null, /*#__PURE__*/_react.default.createElement(_TableCell.default, {
|
|
94
112
|
colSpan: columns.length
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ElementType } from "react";
|
|
1
2
|
import type { HTMLProps, ReactNode } from "react";
|
|
2
3
|
import type { ClassName, PropsWithSpread, ValueOf } from "../../types";
|
|
3
4
|
export declare enum Label {
|
|
@@ -65,10 +66,14 @@ export type Props = PropsWithSpread<{
|
|
|
65
66
|
* The title of the notification.
|
|
66
67
|
*/
|
|
67
68
|
title?: ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* Optional element or component to use for the title.
|
|
71
|
+
*/
|
|
72
|
+
titleElement?: ElementType;
|
|
68
73
|
/**
|
|
69
74
|
* **Deprecated**. Use `severity` instead.
|
|
70
75
|
*/
|
|
71
76
|
type?: never;
|
|
72
77
|
}, HTMLProps<HTMLDivElement>>;
|
|
73
|
-
declare const Notification: ({ actions, borderless, children, className, close, inline, onDismiss, severity, status, timeout, timestamp, title, type, ...props }: Props) => JSX.Element;
|
|
78
|
+
declare const Notification: ({ actions, borderless, children, className, close, inline, onDismiss, severity, status, timeout, timestamp, title, titleElement: TitleComponent, type, ...props }: Props) => JSX.Element;
|
|
74
79
|
export default Notification;
|
|
@@ -15,7 +15,7 @@ var _Button = _interopRequireWildcard(require("../Button"));
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../../utils");
|
|
17
17
|
|
|
18
|
-
var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "type"];
|
|
18
|
+
var _excluded = ["actions", "borderless", "children", "className", "close", "inline", "onDismiss", "severity", "status", "timeout", "timestamp", "title", "titleElement", "type"];
|
|
19
19
|
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
21
|
|
|
@@ -31,13 +31,12 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
31
31
|
|
|
32
32
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
33
33
|
|
|
34
|
-
var Label
|
|
35
|
-
exports.Label = Label;
|
|
36
|
-
|
|
37
|
-
(function (Label) {
|
|
34
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
38
35
|
Label["Close"] = "Close notification";
|
|
39
|
-
|
|
36
|
+
return Label;
|
|
37
|
+
}({});
|
|
40
38
|
|
|
39
|
+
exports.Label = Label;
|
|
41
40
|
var NotificationSeverity = {
|
|
42
41
|
CAUTION: "caution",
|
|
43
42
|
INFORMATION: "information",
|
|
@@ -64,6 +63,8 @@ var Notification = function Notification(_ref) {
|
|
|
64
63
|
timeout = _ref.timeout,
|
|
65
64
|
timestamp = _ref.timestamp,
|
|
66
65
|
title = _ref.title,
|
|
66
|
+
_ref$titleElement = _ref.titleElement,
|
|
67
|
+
TitleComponent = _ref$titleElement === void 0 ? "h5" : _ref$titleElement,
|
|
67
68
|
type = _ref.type,
|
|
68
69
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
69
70
|
|
|
@@ -90,7 +91,7 @@ var Notification = function Notification(_ref) {
|
|
|
90
91
|
className: (0, _classnames.default)(className, (_classNames = {}, _defineProperty(_classNames, "p-notification--".concat(severity), !!severity), _defineProperty(_classNames, "p-notification", !severity), _defineProperty(_classNames, "is-borderless", borderless), _defineProperty(_classNames, "is-inline", inline), _classNames))
|
|
91
92
|
}, props), /*#__PURE__*/_react.default.createElement("div", {
|
|
92
93
|
className: "p-notification__content"
|
|
93
|
-
}, title && /*#__PURE__*/_react.default.createElement(
|
|
94
|
+
}, title && /*#__PURE__*/_react.default.createElement(TitleComponent, {
|
|
94
95
|
className: "p-notification__title",
|
|
95
96
|
"data-testid": "notification-title"
|
|
96
97
|
}, title), inline && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "\u2002"), /*#__PURE__*/_react.default.createElement("p", {
|
|
@@ -11,13 +11,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
var Label
|
|
15
|
-
exports.Label = Label;
|
|
16
|
-
|
|
17
|
-
(function (Label) {
|
|
14
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
18
15
|
Label["Next"] = "Next page";
|
|
19
16
|
Label["Previous"] = "Previous page";
|
|
20
|
-
|
|
17
|
+
return Label;
|
|
18
|
+
}({});
|
|
19
|
+
|
|
20
|
+
exports.Label = Label;
|
|
21
21
|
|
|
22
22
|
var PaginationButton = function PaginationButton(_ref) {
|
|
23
23
|
var direction = _ref.direction,
|
|
@@ -45,17 +45,17 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
45
45
|
|
|
46
46
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
47
|
|
|
48
|
-
var Label
|
|
48
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
49
|
+
Label["Hide"] = "Hide";
|
|
50
|
+
Label["Show"] = "Show";
|
|
51
|
+
return Label;
|
|
52
|
+
}({});
|
|
49
53
|
/**
|
|
50
54
|
* The props for the Password Toggle component.
|
|
51
55
|
*/
|
|
52
56
|
|
|
53
|
-
exports.Label = Label;
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
Label["Hide"] = "Hide";
|
|
57
|
-
Label["Show"] = "Show";
|
|
58
|
-
})(Label || (exports.Label = Label = {}));
|
|
58
|
+
exports.Label = Label;
|
|
59
59
|
|
|
60
60
|
var PasswordToggle = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
61
61
|
var caution = _ref.caution,
|
|
@@ -53,14 +53,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
53
53
|
|
|
54
54
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
55
55
|
|
|
56
|
-
var Label
|
|
57
|
-
exports.Label = Label;
|
|
58
|
-
|
|
59
|
-
(function (Label) {
|
|
56
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
60
57
|
Label["AddFilter"] = "Add filter";
|
|
61
58
|
Label["Clear"] = "Clear input";
|
|
62
59
|
Label["SearchAndFilter"] = "Search and filter";
|
|
63
|
-
|
|
60
|
+
return Label;
|
|
61
|
+
}({});
|
|
62
|
+
|
|
63
|
+
exports.Label = Label;
|
|
64
64
|
|
|
65
65
|
var SearchAndFilter = function SearchAndFilter(_ref) {
|
|
66
66
|
var _ref$existingSearchDa = _ref.existingSearchData,
|
|
@@ -99,9 +99,15 @@ var SearchAndFilter = function SearchAndFilter(_ref) {
|
|
|
99
99
|
searchContainerActive = _useState12[0],
|
|
100
100
|
setSearchContainerActive = _useState12[1];
|
|
101
101
|
|
|
102
|
+
var _useState13 = (0, _react.useState)(),
|
|
103
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
104
|
+
maxHeight = _useState14[0],
|
|
105
|
+
setMaxHeight = _useState14[1];
|
|
106
|
+
|
|
102
107
|
var searchAndFilterRef = (0, _react.useRef)(null);
|
|
103
108
|
var searchContainerRef = (0, _react.useRef)(null);
|
|
104
|
-
var searchBoxRef = (0, _react.useRef)(null);
|
|
109
|
+
var searchBoxRef = (0, _react.useRef)(null);
|
|
110
|
+
var panel = (0, _react.useRef)(); // Return searchData to parent component
|
|
105
111
|
|
|
106
112
|
(0, _react.useEffect)(function () {
|
|
107
113
|
var mounted = true;
|
|
@@ -242,7 +248,10 @@ var SearchAndFilter = function SearchAndFilter(_ref) {
|
|
|
242
248
|
|
|
243
249
|
resizeObserverSupported && ((_wrapperWidthObserver = wrapperWidthObserver) === null || _wrapperWidthObserver === void 0 ? void 0 : _wrapperWidthObserver.disconnect());
|
|
244
250
|
};
|
|
245
|
-
}, [searchData]);
|
|
251
|
+
}, [searchData]);
|
|
252
|
+
(0, _hooks.useWindowFitment)(panel.current, searchAndFilterRef.current, function (fitsWindow) {
|
|
253
|
+
return setMaxHeight(fitsWindow.fromBottom.spaceBelow - 16);
|
|
254
|
+
}, 0, !filterPanelHidden); // Add search prompt value to search on Enter key
|
|
246
255
|
|
|
247
256
|
var searchPromptKeyDown = function searchPromptKeyDown(e) {
|
|
248
257
|
if (e.key === "Enter") {
|
|
@@ -333,7 +342,13 @@ var SearchAndFilter = function SearchAndFilter(_ref) {
|
|
|
333
342
|
tabIndex: 0
|
|
334
343
|
}, "+", overflowSearchTermCounter)), (filterPanelData.length > 0 || searchTerm.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
|
|
335
344
|
className: "p-search-and-filter__panel",
|
|
336
|
-
"aria-hidden": filterPanelHidden
|
|
345
|
+
"aria-hidden": filterPanelHidden,
|
|
346
|
+
ref: panel,
|
|
347
|
+
style: {
|
|
348
|
+
maxHeight: maxHeight,
|
|
349
|
+
minHeight: "5rem",
|
|
350
|
+
overflowX: "auto"
|
|
351
|
+
}
|
|
337
352
|
}, /*#__PURE__*/_react.default.createElement("div", null, searchTerm.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
338
353
|
className: "p-search-and-filter__search-prompt",
|
|
339
354
|
onClick: function onClick() {
|
|
@@ -27,13 +27,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
27
27
|
|
|
28
28
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
29
|
|
|
30
|
-
var Label
|
|
31
|
-
exports.Label = Label;
|
|
32
|
-
|
|
33
|
-
(function (Label) {
|
|
30
|
+
var Label = /*#__PURE__*/function (Label) {
|
|
34
31
|
Label["Clear"] = "Clear search field";
|
|
35
32
|
Label["Search"] = "Search";
|
|
36
|
-
|
|
33
|
+
return Label;
|
|
34
|
+
}({});
|
|
35
|
+
|
|
36
|
+
exports.Label = Label;
|
|
37
37
|
|
|
38
38
|
var SearchBox = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwardedRef) {
|
|
39
39
|
var _ref$autocomplete = _ref.autocomplete,
|
|
@@ -279,26 +279,24 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
279
279
|
return child && /*#__PURE__*/_react.default.isValidElement(child) ? /*#__PURE__*/_react.default.cloneElement(child, {
|
|
280
280
|
"aria-describedby": tooltipId
|
|
281
281
|
}) : child;
|
|
282
|
-
})), /*#__PURE__*/_react.default.createElement(Portal, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
283
|
-
className: (0, _classnames.default)("p-tooltip--".concat(adjustedPosition), "is-detached",
|
|
284
|
-
"u-off-screen": !isOpen
|
|
285
|
-
}, tooltipClassName),
|
|
282
|
+
})), isOpen ? /*#__PURE__*/_react.default.createElement(Portal, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
283
|
+
className: (0, _classnames.default)("p-tooltip--".concat(adjustedPosition), "is-detached", tooltipClassName),
|
|
286
284
|
"data-testid": "tooltip-portal",
|
|
287
|
-
style: positionStyle
|
|
288
|
-
// isOpen
|
|
289
|
-
// ? (positionStyle as React.CSSProperties)
|
|
290
|
-
// : { left: -9999 }
|
|
291
|
-
// }
|
|
292
|
-
|
|
285
|
+
style: positionStyle
|
|
293
286
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
294
287
|
role: "tooltip",
|
|
295
288
|
className: "p-tooltip__message",
|
|
289
|
+
onClick: function onClick(event) {
|
|
290
|
+
// Prevent clicks inside the message from bubbling to parent
|
|
291
|
+
// click handlers.
|
|
292
|
+
event.stopPropagation();
|
|
293
|
+
},
|
|
296
294
|
ref: messageRef,
|
|
297
295
|
id: tooltipId,
|
|
298
296
|
style: {
|
|
299
297
|
zIndex: zIndex
|
|
300
298
|
}
|
|
301
|
-
}, message)))) : /*#__PURE__*/_react.default.createElement("span", {
|
|
299
|
+
}, message))) : null) : /*#__PURE__*/_react.default.createElement("span", {
|
|
302
300
|
className: className
|
|
303
301
|
}, children));
|
|
304
302
|
};
|
package/dist/enums.js
CHANGED
|
@@ -8,10 +8,10 @@ exports.Theme = void 0;
|
|
|
8
8
|
/**
|
|
9
9
|
* The Vanilla theme types.
|
|
10
10
|
*/
|
|
11
|
-
var Theme
|
|
12
|
-
exports.Theme = Theme;
|
|
13
|
-
|
|
14
|
-
(function (Theme) {
|
|
11
|
+
var Theme = /*#__PURE__*/function (Theme) {
|
|
15
12
|
Theme["DARK"] = "dark";
|
|
16
13
|
Theme["LIGHT"] = "light";
|
|
17
|
-
|
|
14
|
+
return Theme;
|
|
15
|
+
}({});
|
|
16
|
+
|
|
17
|
+
exports.Theme = Theme;
|
|
@@ -2,24 +2,36 @@ export type WindowFitment = {
|
|
|
2
2
|
fromTop: {
|
|
3
3
|
fitsAbove: boolean;
|
|
4
4
|
fitsBelow: boolean;
|
|
5
|
+
spaceAbove: number;
|
|
6
|
+
spaceBelow: number;
|
|
5
7
|
};
|
|
6
8
|
fromBottom: {
|
|
7
9
|
fitsAbove: boolean;
|
|
8
10
|
fitsBelow: boolean;
|
|
11
|
+
spaceAbove: number;
|
|
12
|
+
spaceBelow: number;
|
|
9
13
|
};
|
|
10
14
|
fromLeft: {
|
|
11
15
|
fitsLeft: boolean;
|
|
12
16
|
fitsRight: boolean;
|
|
17
|
+
spaceLeft: number;
|
|
18
|
+
spaceRight: number;
|
|
13
19
|
};
|
|
14
20
|
fromRight: {
|
|
15
21
|
fitsLeft: boolean;
|
|
16
22
|
fitsRight: boolean;
|
|
23
|
+
spaceLeft: number;
|
|
24
|
+
spaceRight: number;
|
|
17
25
|
};
|
|
18
26
|
fromCenter: {
|
|
19
27
|
fitsLeft: boolean;
|
|
20
28
|
fitsRight: boolean;
|
|
21
29
|
fitsAbove: boolean;
|
|
22
30
|
fitsBelow: boolean;
|
|
31
|
+
spaceLeft: number;
|
|
32
|
+
spaceRight: number;
|
|
33
|
+
spaceAbove: number;
|
|
34
|
+
spaceBelow: number;
|
|
23
35
|
fitsCentered: {
|
|
24
36
|
fitsAbove: boolean;
|
|
25
37
|
fitsBelow: boolean;
|
|
@@ -67,25 +67,37 @@ var useWindowFitment = function useWindowFitment(targetNode, referenceNode, call
|
|
|
67
67
|
callback({
|
|
68
68
|
fromTop: {
|
|
69
69
|
fitsAbove: referenceTop - heightIncludingSpace > windowTop,
|
|
70
|
-
fitsBelow: referenceTop + heightIncludingSpace < windowBottom
|
|
70
|
+
fitsBelow: referenceTop + heightIncludingSpace < windowBottom,
|
|
71
|
+
spaceAbove: Math.abs(windowTop - referenceTop),
|
|
72
|
+
spaceBelow: windowBottom - referenceTop
|
|
71
73
|
},
|
|
72
74
|
fromBottom: {
|
|
73
75
|
fitsAbove: referenceBottom - heightIncludingSpace > windowTop,
|
|
74
|
-
fitsBelow: referenceBottom + heightIncludingSpace < windowBottom
|
|
76
|
+
fitsBelow: referenceBottom + heightIncludingSpace < windowBottom,
|
|
77
|
+
spaceAbove: Math.abs(windowTop - referenceBottom),
|
|
78
|
+
spaceBelow: windowBottom - referenceBottom
|
|
75
79
|
},
|
|
76
80
|
fromLeft: {
|
|
77
81
|
fitsLeft: referenceLeft - widthIncludingSpace > windowLeft,
|
|
78
|
-
fitsRight: referenceLeft + widthIncludingSpace < windowRight
|
|
82
|
+
fitsRight: referenceLeft + widthIncludingSpace < windowRight,
|
|
83
|
+
spaceLeft: Math.abs(windowLeft - referenceLeft),
|
|
84
|
+
spaceRight: windowRight - referenceLeft
|
|
79
85
|
},
|
|
80
86
|
fromRight: {
|
|
81
87
|
fitsLeft: referenceRight - widthIncludingSpace > windowLeft,
|
|
82
|
-
fitsRight: referenceRight + widthIncludingSpace < windowRight
|
|
88
|
+
fitsRight: referenceRight + widthIncludingSpace < windowRight,
|
|
89
|
+
spaceLeft: Math.abs(windowLeft - referenceRight),
|
|
90
|
+
spaceRight: windowRight - referenceRight
|
|
83
91
|
},
|
|
84
92
|
fromCenter: {
|
|
85
93
|
fitsLeft: referenceCenterX - widthIncludingSpace > windowLeft,
|
|
86
94
|
fitsRight: referenceCenterX + widthIncludingSpace < windowRight,
|
|
87
95
|
fitsAbove: referenceCenterY - heightIncludingSpace > windowTop,
|
|
88
96
|
fitsBelow: referenceCenterY + heightIncludingSpace < windowBottom,
|
|
97
|
+
spaceAbove: Math.abs(windowTop - referenceCenterY),
|
|
98
|
+
spaceBelow: windowBottom - referenceCenterY,
|
|
99
|
+
spaceLeft: Math.abs(windowLeft - referenceCenterX),
|
|
100
|
+
spaceRight: windowRight - referenceCenterX,
|
|
89
101
|
fitsCentered: {
|
|
90
102
|
fitsLeft: referenceCenterX - widthFromCenter > windowLeft,
|
|
91
103
|
fitsRight: referenceCenterX + widthFromCenter < windowRight,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": "Huw Wilkins <huw.wilkins@canonical.com>",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://canonical.github.io/react-components",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.
|
|
26
|
-
"@babel/eslint-parser": "7.
|
|
27
|
-
"@babel/preset-typescript": "7.
|
|
28
|
-
"@percy/cli": "1.
|
|
29
|
-
"@percy/storybook": "4.3.
|
|
25
|
+
"@babel/cli": "7.21.5",
|
|
26
|
+
"@babel/eslint-parser": "7.21.3",
|
|
27
|
+
"@babel/preset-typescript": "7.21.5",
|
|
28
|
+
"@percy/cli": "1.24.0",
|
|
29
|
+
"@percy/storybook": "4.3.6",
|
|
30
30
|
"@storybook/addon-a11y": "6.5.16",
|
|
31
31
|
"@storybook/addon-controls": "6.5.16",
|
|
32
32
|
"@storybook/addon-docs": "6.5.16",
|
|
@@ -36,74 +36,74 @@
|
|
|
36
36
|
"@storybook/react": "6.5.16",
|
|
37
37
|
"@storybook/theming": "6.5.16",
|
|
38
38
|
"@testing-library/cypress": "9.0.0",
|
|
39
|
-
"@testing-library/dom": "
|
|
39
|
+
"@testing-library/dom": "9.2.0",
|
|
40
40
|
"@testing-library/jest-dom": "5.16.5",
|
|
41
41
|
"@testing-library/react": "12.1.5",
|
|
42
42
|
"@testing-library/react-hooks": "8.0.1",
|
|
43
43
|
"@testing-library/user-event": "14.4.3",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
45
|
-
"@typescript-eslint/parser": "5.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "5.59.1",
|
|
45
|
+
"@typescript-eslint/parser": "5.59.1",
|
|
46
46
|
"babel-jest": "27.5.1",
|
|
47
47
|
"babel-loader": "9.1.2",
|
|
48
48
|
"babel-plugin-module-resolver": "5.0.0",
|
|
49
|
-
"babel-plugin-typescript-to-proptypes": "2.
|
|
49
|
+
"babel-plugin-typescript-to-proptypes": "2.1.0",
|
|
50
50
|
"concurrently": "7.6.0",
|
|
51
51
|
"css-loader": "6.7.3",
|
|
52
|
-
"cypress": "12.
|
|
53
|
-
"deepmerge": "4.3.
|
|
54
|
-
"eslint": "8.
|
|
55
|
-
"eslint-config-prettier": "8.
|
|
52
|
+
"cypress": "12.11.0",
|
|
53
|
+
"deepmerge": "4.3.1",
|
|
54
|
+
"eslint": "8.39.0",
|
|
55
|
+
"eslint-config-prettier": "8.8.0",
|
|
56
56
|
"eslint-config-react-app": "7.0.1",
|
|
57
|
-
"eslint-plugin-cypress": "2.
|
|
57
|
+
"eslint-plugin-cypress": "2.13.3",
|
|
58
58
|
"eslint-plugin-flowtype": "8.0.3",
|
|
59
59
|
"eslint-plugin-import": "2.27.5",
|
|
60
60
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
61
61
|
"eslint-plugin-prettier": "4.2.1",
|
|
62
62
|
"eslint-plugin-react": "7.32.2",
|
|
63
63
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
64
|
-
"eslint-plugin-testing-library": "5.10.
|
|
64
|
+
"eslint-plugin-testing-library": "5.10.3",
|
|
65
65
|
"jest": "27.5.1",
|
|
66
66
|
"npm-package-json-lint": "5.4.2",
|
|
67
|
-
"prettier": "2.8.
|
|
67
|
+
"prettier": "2.8.8",
|
|
68
68
|
"react": "17.0.2",
|
|
69
69
|
"react-docgen-typescript-loader": "3.7.2",
|
|
70
70
|
"react-dom": "17.0.2",
|
|
71
|
-
"sass": "1.
|
|
71
|
+
"sass": "1.62.1",
|
|
72
72
|
"sass-loader": "10.4.1",
|
|
73
|
-
"style-loader": "3.3.
|
|
73
|
+
"style-loader": "3.3.2",
|
|
74
74
|
"stylelint": "14.16.1",
|
|
75
|
-
"stylelint-config-prettier": "9.0.
|
|
75
|
+
"stylelint-config-prettier": "9.0.5",
|
|
76
76
|
"stylelint-config-recommended-scss": "5.0.2",
|
|
77
77
|
"stylelint-order": "5.0.0",
|
|
78
78
|
"stylelint-prettier": "2.0.0",
|
|
79
79
|
"ts-jest": "27.1.5",
|
|
80
|
-
"tsc-alias": "1.8.
|
|
80
|
+
"tsc-alias": "1.8.6",
|
|
81
81
|
"typescript": "4.9.5",
|
|
82
|
-
"vanilla-framework": "3.
|
|
82
|
+
"vanilla-framework": "3.14.0",
|
|
83
83
|
"wait-on": "5.3.0",
|
|
84
|
-
"webpack": "5.
|
|
84
|
+
"webpack": "5.81.0"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@types/jest": "27.5.2",
|
|
88
|
-
"@types/node": "18.
|
|
89
|
-
"@types/react": "18.0
|
|
90
|
-
"@types/react-dom": "17.0.
|
|
88
|
+
"@types/node": "18.16.3",
|
|
89
|
+
"@types/react": "18.2.0",
|
|
90
|
+
"@types/react-dom": "17.0.20",
|
|
91
91
|
"@types/react-table": "7.7.14",
|
|
92
92
|
"classnames": "2.3.2",
|
|
93
|
-
"nanoid": "3.3.
|
|
93
|
+
"nanoid": "3.3.6",
|
|
94
94
|
"prop-types": "15.8.1",
|
|
95
95
|
"react-table": "7.8.0",
|
|
96
|
-
"react-useportal": "1.0.
|
|
96
|
+
"react-useportal": "1.0.18"
|
|
97
97
|
},
|
|
98
98
|
"resolutions": {
|
|
99
|
-
"@types/react": "18.0
|
|
100
|
-
"@types/react-dom": "17.0.
|
|
99
|
+
"@types/react": "18.2.0",
|
|
100
|
+
"@types/react-dom": "17.0.20",
|
|
101
101
|
"postcss": "^8.3.11"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^17.0.2 || ^18.0.0",
|
|
105
105
|
"react-dom": "^17.0.2 || ^18.0.0",
|
|
106
|
-
"vanilla-framework": "3.
|
|
106
|
+
"vanilla-framework": "3.14.0"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"build": "rm -rf dist && yarn build-local; yarn build-declaration",
|