@canonical/react-components 2.2.0 → 2.2.2
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/ContextualMenu/ContextualMenu.stories.d.ts +1 -0
- package/dist/components/ContextualMenu/ContextualMenu.stories.js +19 -1
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +1 -0
- package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +28 -1
- package/dist/components/CustomSelect/CustomSelectDropdown/CustomSelectDropdown.d.ts +0 -1
- package/dist/components/CustomSelect/CustomSelectDropdown/CustomSelectDropdown.js +1 -23
- package/dist/components/ModularTable/ModularTable.d.ts +1 -1
- package/dist/components/ModularTable/ModularTable.js +1 -1
- package/dist/components/SearchBox/SearchBox.js +5 -3
- package/dist/esm/components/ContextualMenu/ContextualMenu.stories.d.ts +1 -0
- package/dist/esm/components/ContextualMenu/ContextualMenu.stories.js +18 -0
- package/dist/esm/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +1 -0
- package/dist/esm/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +26 -0
- package/dist/esm/components/CustomSelect/CustomSelectDropdown/CustomSelectDropdown.d.ts +0 -1
- package/dist/esm/components/CustomSelect/CustomSelectDropdown/CustomSelectDropdown.js +0 -21
- package/dist/esm/components/ModularTable/ModularTable.d.ts +1 -1
- package/dist/esm/components/ModularTable/ModularTable.js +1 -1
- package/dist/esm/components/SearchBox/SearchBox.js +6 -4
- package/package.json +2 -2
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.Toggle = exports.OverflowingContainer = exports.Default = exports.ChildFunction = exports.ChildElement = void 0;
|
|
6
|
+
exports.default = exports.Toggle = exports.OverflowingContainer = exports.InsideModal = exports.Default = exports.ChildFunction = exports.ChildElement = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
9
9
|
var _ContextualMenu = _interopRequireDefault(require("./ContextualMenu"));
|
|
10
|
+
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
const ScrollTemplate = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
12
13
|
style: {
|
|
@@ -104,4 +105,21 @@ const ChildElement = exports.ChildElement = {
|
|
|
104
105
|
position: "right",
|
|
105
106
|
toggleLabel: "Click me!"
|
|
106
107
|
}
|
|
108
|
+
};
|
|
109
|
+
const InsideModal = exports.InsideModal = {
|
|
110
|
+
name: "Inside modal",
|
|
111
|
+
args: {
|
|
112
|
+
links: Array.from({
|
|
113
|
+
length: 5
|
|
114
|
+
}, (_, index) => ({
|
|
115
|
+
children: "Link ".concat(index + 1),
|
|
116
|
+
onClick: () => {}
|
|
117
|
+
})),
|
|
118
|
+
hasToggleIcon: true,
|
|
119
|
+
position: "right",
|
|
120
|
+
toggleLabel: "Click me!"
|
|
121
|
+
},
|
|
122
|
+
render: args => /*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
123
|
+
title: "Contextual Menu inside Modal"
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement(Template, args))
|
|
107
125
|
};
|
|
@@ -39,5 +39,6 @@ export type Props<L = null> = {
|
|
|
39
39
|
* @return The new position.
|
|
40
40
|
*/
|
|
41
41
|
export declare const adjustForWindow: (position: Position, fitsWindow: WindowFitment) => Position;
|
|
42
|
+
export declare const getNearestParentsZIndex: (element: HTMLElement | null) => string;
|
|
42
43
|
declare const ContextualMenuDropdown: <L>({ adjustedPosition, autoAdjust, handleClose, constrainPanelWidth, dropdownClassName, dropdownContent, id, isOpen, links, position, positionCoords, positionNode, scrollOverflow, setAdjustedPosition, contextualMenuClassName, ...props }: Props<L>) => React.JSX.Element;
|
|
43
44
|
export default ContextualMenuDropdown;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.adjustForWindow = exports.Label = void 0;
|
|
6
|
+
exports.getNearestParentsZIndex = exports.default = exports.adjustForWindow = exports.Label = void 0;
|
|
7
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _hooks = require("../../../hooks");
|
|
@@ -134,6 +134,22 @@ const getClosestScrollableParent = node => {
|
|
|
134
134
|
}
|
|
135
135
|
return document.body;
|
|
136
136
|
};
|
|
137
|
+
|
|
138
|
+
// nearest parents z-index that is not 0 or auto
|
|
139
|
+
const getNearestParentsZIndex = element => {
|
|
140
|
+
if (!window || !element) {
|
|
141
|
+
return "0";
|
|
142
|
+
}
|
|
143
|
+
const zIndex = window.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
144
|
+
if (!element.parentElement) {
|
|
145
|
+
return zIndex;
|
|
146
|
+
}
|
|
147
|
+
if (zIndex === "auto" || zIndex === "0" || zIndex === "") {
|
|
148
|
+
return getNearestParentsZIndex(element.parentElement);
|
|
149
|
+
}
|
|
150
|
+
return zIndex;
|
|
151
|
+
};
|
|
152
|
+
exports.getNearestParentsZIndex = getNearestParentsZIndex;
|
|
137
153
|
const ContextualMenuDropdown = _ref => {
|
|
138
154
|
let {
|
|
139
155
|
adjustedPosition,
|
|
@@ -206,6 +222,17 @@ const ContextualMenuDropdown = _ref => {
|
|
|
206
222
|
(0, _react.useEffect)(() => {
|
|
207
223
|
updateVerticalPosition();
|
|
208
224
|
}, [updateVerticalPosition]);
|
|
225
|
+
(0, _react.useEffect)(() => {
|
|
226
|
+
if (!dropdown.current) return;
|
|
227
|
+
|
|
228
|
+
// align z-index: when we are in a modal context, we want the dropdown to be above the modal
|
|
229
|
+
// apply the nearest parents z-index + 1
|
|
230
|
+
const zIndex = getNearestParentsZIndex(positionNode);
|
|
231
|
+
if (parseInt(zIndex) > 0) {
|
|
232
|
+
var _dropdown$current$par;
|
|
233
|
+
(_dropdown$current$par = dropdown.current.parentElement) === null || _dropdown$current$par === void 0 || _dropdown$current$par.style.setProperty("z-index", zIndex + 1);
|
|
234
|
+
}
|
|
235
|
+
}, [positionNode]);
|
|
209
236
|
return (
|
|
210
237
|
/*#__PURE__*/
|
|
211
238
|
// Vanilla Framework uses .p-contextual-menu parent modifier classnames to determine the correct position of the .p-contextual-menu__dropdown dropdown (left, center, right).
|
|
@@ -19,7 +19,6 @@ export declare const adjustDropdownHeightBelow: (dropdown: HTMLUListElement) =>
|
|
|
19
19
|
export declare const adjustDropdownHeightAbove: (dropdown: HTMLUListElement, search: HTMLInputElement | null) => void;
|
|
20
20
|
export declare const dropdownIsAbove: (dropdown: HTMLUListElement) => boolean;
|
|
21
21
|
export declare const adjustDropdownHeight: (dropdown: HTMLUListElement | null, search: HTMLInputElement | null) => void;
|
|
22
|
-
export declare const getNearestParentsZIndex: (element: HTMLElement | null) => string;
|
|
23
22
|
export declare const getOptionText: (option: CustomSelectOption) => string;
|
|
24
23
|
declare const CustomSelectDropdown: FC<Props>;
|
|
25
24
|
export default CustomSelectDropdown;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getOptionText = exports.
|
|
6
|
+
exports.getOptionText = exports.dropdownIsAbove = exports.default = exports.adjustDropdownHeightBelow = exports.adjustDropdownHeightAbove = exports.adjustDropdownHeight = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -87,20 +87,6 @@ const adjustDropdownHeight = (dropdown, search) => {
|
|
|
87
87
|
adjustDropdownHeightBelow(dropdown);
|
|
88
88
|
};
|
|
89
89
|
exports.adjustDropdownHeight = adjustDropdownHeight;
|
|
90
|
-
const getNearestParentsZIndex = element => {
|
|
91
|
-
if (!document.defaultView || !element) {
|
|
92
|
-
return "0";
|
|
93
|
-
}
|
|
94
|
-
const zIndex = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
95
|
-
if (!element.parentElement) {
|
|
96
|
-
return zIndex;
|
|
97
|
-
}
|
|
98
|
-
if (zIndex === "auto" || zIndex === "0" || zIndex === "") {
|
|
99
|
-
return getNearestParentsZIndex(element.parentElement);
|
|
100
|
-
}
|
|
101
|
-
return zIndex;
|
|
102
|
-
};
|
|
103
|
-
exports.getNearestParentsZIndex = getNearestParentsZIndex;
|
|
104
90
|
const getOptionText = option => {
|
|
105
91
|
if (option.text) {
|
|
106
92
|
return option.text;
|
|
@@ -139,14 +125,6 @@ const CustomSelectDropdown = _ref => {
|
|
|
139
125
|
// align width with wrapper toggle width
|
|
140
126
|
const toggleWidth = (_toggle$getBoundingCl = toggle === null || toggle === void 0 || (_toggle$getBoundingCl2 = toggle.getBoundingClientRect()) === null || _toggle$getBoundingCl2 === void 0 ? void 0 : _toggle$getBoundingCl2.width) !== null && _toggle$getBoundingCl !== void 0 ? _toggle$getBoundingCl : 0;
|
|
141
127
|
dropdownRef.current.style.setProperty("min-width", "".concat(toggleWidth, "px"));
|
|
142
|
-
|
|
143
|
-
// align z-index: when we are in a modal context, we want the dropdown to be above the modal
|
|
144
|
-
// apply the nearest parents z-index + 1
|
|
145
|
-
const zIndex = getNearestParentsZIndex(toggle);
|
|
146
|
-
if (parseInt(zIndex) > 0) {
|
|
147
|
-
var _dropdownRef$current$;
|
|
148
|
-
(_dropdownRef$current$ = dropdownRef.current.parentElement) === null || _dropdownRef$current$ === void 0 || _dropdownRef$current$.style.setProperty("z-index", zIndex + 1);
|
|
149
|
-
}
|
|
150
128
|
}
|
|
151
129
|
setTimeout(() => {
|
|
152
130
|
var _dropdownRef$current;
|
|
@@ -57,7 +57,7 @@ ModularTable components accepts `columns` and `data` arguments in the same forma
|
|
|
57
57
|
`columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
|
|
58
58
|
`data` - The data array that you want to display on the table.
|
|
59
59
|
### Important note!
|
|
60
|
-
Values passed to both of these params have to
|
|
60
|
+
Values passed to both of these params have to be memoized (for example via{" "}
|
|
61
61
|
<code>React.useMemo</code>). Memoization ensures that our data isn't recreated
|
|
62
62
|
on every render. If we didn't use <code>React.useMemo</code>, the table would
|
|
63
63
|
think it was receiving new data on every render and attempt to recalulate a
|
|
@@ -53,7 +53,7 @@ ModularTable components accepts `columns` and `data` arguments in the same forma
|
|
|
53
53
|
`columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
|
|
54
54
|
`data` - The data array that you want to display on the table.
|
|
55
55
|
### Important note!
|
|
56
|
-
Values passed to both of these params have to
|
|
56
|
+
Values passed to both of these params have to be memoized (for example via{" "}
|
|
57
57
|
<code>React.useMemo</code>). Memoization ensures that our data isn't recreated
|
|
58
58
|
on every render. If we didn't use <code>React.useMemo</code>, the table would
|
|
59
59
|
think it was receiving new data on every render and attempt to recalulate a
|
|
@@ -23,6 +23,8 @@ let Label = exports.Label = /*#__PURE__*/function (Label) {
|
|
|
23
23
|
*/
|
|
24
24
|
const SearchBox = /*#__PURE__*/_react.default.forwardRef((_ref, forwardedRef) => {
|
|
25
25
|
let {
|
|
26
|
+
name = "search",
|
|
27
|
+
id = "search",
|
|
26
28
|
autocomplete = "on",
|
|
27
29
|
className,
|
|
28
30
|
disabled,
|
|
@@ -60,13 +62,13 @@ const SearchBox = /*#__PURE__*/_react.default.forwardRef((_ref, forwardedRef) =>
|
|
|
60
62
|
className: (0, _classnames.default)("p-search-box", className)
|
|
61
63
|
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
62
64
|
className: "u-off-screen",
|
|
63
|
-
htmlFor:
|
|
65
|
+
htmlFor: id
|
|
64
66
|
}, placeholder || "Search"), /*#__PURE__*/_react.default.createElement("input", _extends({
|
|
65
67
|
autoComplete: autocomplete,
|
|
66
68
|
className: "p-search-box__input",
|
|
67
69
|
disabled: disabled,
|
|
68
|
-
id:
|
|
69
|
-
name:
|
|
70
|
+
id: id,
|
|
71
|
+
name: name,
|
|
70
72
|
onChange: evt => onChange === null || onChange === void 0 ? void 0 : onChange(evt.target.value),
|
|
71
73
|
onKeyDown: onKeyDown,
|
|
72
74
|
placeholder: placeholder,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Button from "../Button";
|
|
3
3
|
import ContextualMenu from "./ContextualMenu";
|
|
4
|
+
import Modal from "../Modal";
|
|
4
5
|
var ScrollTemplate = args => /*#__PURE__*/React.createElement("div", {
|
|
5
6
|
style: {
|
|
6
7
|
maxWidth: "30rem",
|
|
@@ -97,4 +98,21 @@ export var ChildElement = {
|
|
|
97
98
|
position: "right",
|
|
98
99
|
toggleLabel: "Click me!"
|
|
99
100
|
}
|
|
101
|
+
};
|
|
102
|
+
export var InsideModal = {
|
|
103
|
+
name: "Inside modal",
|
|
104
|
+
args: {
|
|
105
|
+
links: Array.from({
|
|
106
|
+
length: 5
|
|
107
|
+
}, (_, index) => ({
|
|
108
|
+
children: "Link ".concat(index + 1),
|
|
109
|
+
onClick: () => {}
|
|
110
|
+
})),
|
|
111
|
+
hasToggleIcon: true,
|
|
112
|
+
position: "right",
|
|
113
|
+
toggleLabel: "Click me!"
|
|
114
|
+
},
|
|
115
|
+
render: args => /*#__PURE__*/React.createElement(Modal, {
|
|
116
|
+
title: "Contextual Menu inside Modal"
|
|
117
|
+
}, /*#__PURE__*/React.createElement(Template, args))
|
|
100
118
|
};
|
package/dist/esm/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts
CHANGED
|
@@ -39,5 +39,6 @@ export type Props<L = null> = {
|
|
|
39
39
|
* @return The new position.
|
|
40
40
|
*/
|
|
41
41
|
export declare const adjustForWindow: (position: Position, fitsWindow: WindowFitment) => Position;
|
|
42
|
+
export declare const getNearestParentsZIndex: (element: HTMLElement | null) => string;
|
|
42
43
|
declare const ContextualMenuDropdown: <L>({ adjustedPosition, autoAdjust, handleClose, constrainPanelWidth, dropdownClassName, dropdownContent, id, isOpen, links, position, positionCoords, positionNode, scrollOverflow, setAdjustedPosition, contextualMenuClassName, ...props }: Props<L>) => React.JSX.Element;
|
|
43
44
|
export default ContextualMenuDropdown;
|
|
@@ -134,6 +134,21 @@ var getClosestScrollableParent = node => {
|
|
|
134
134
|
}
|
|
135
135
|
return document.body;
|
|
136
136
|
};
|
|
137
|
+
|
|
138
|
+
// nearest parents z-index that is not 0 or auto
|
|
139
|
+
export var getNearestParentsZIndex = element => {
|
|
140
|
+
if (!window || !element) {
|
|
141
|
+
return "0";
|
|
142
|
+
}
|
|
143
|
+
var zIndex = window.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
144
|
+
if (!element.parentElement) {
|
|
145
|
+
return zIndex;
|
|
146
|
+
}
|
|
147
|
+
if (zIndex === "auto" || zIndex === "0" || zIndex === "") {
|
|
148
|
+
return getNearestParentsZIndex(element.parentElement);
|
|
149
|
+
}
|
|
150
|
+
return zIndex;
|
|
151
|
+
};
|
|
137
152
|
var ContextualMenuDropdown = _ref => {
|
|
138
153
|
var {
|
|
139
154
|
adjustedPosition,
|
|
@@ -206,6 +221,17 @@ var ContextualMenuDropdown = _ref => {
|
|
|
206
221
|
useEffect(() => {
|
|
207
222
|
updateVerticalPosition();
|
|
208
223
|
}, [updateVerticalPosition]);
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
if (!dropdown.current) return;
|
|
226
|
+
|
|
227
|
+
// align z-index: when we are in a modal context, we want the dropdown to be above the modal
|
|
228
|
+
// apply the nearest parents z-index + 1
|
|
229
|
+
var zIndex = getNearestParentsZIndex(positionNode);
|
|
230
|
+
if (parseInt(zIndex) > 0) {
|
|
231
|
+
var _dropdown$current$par;
|
|
232
|
+
(_dropdown$current$par = dropdown.current.parentElement) === null || _dropdown$current$par === void 0 || _dropdown$current$par.style.setProperty("z-index", zIndex + 1);
|
|
233
|
+
}
|
|
234
|
+
}, [positionNode]);
|
|
209
235
|
return (
|
|
210
236
|
/*#__PURE__*/
|
|
211
237
|
// Vanilla Framework uses .p-contextual-menu parent modifier classnames to determine the correct position of the .p-contextual-menu__dropdown dropdown (left, center, right).
|
|
@@ -19,7 +19,6 @@ export declare const adjustDropdownHeightBelow: (dropdown: HTMLUListElement) =>
|
|
|
19
19
|
export declare const adjustDropdownHeightAbove: (dropdown: HTMLUListElement, search: HTMLInputElement | null) => void;
|
|
20
20
|
export declare const dropdownIsAbove: (dropdown: HTMLUListElement) => boolean;
|
|
21
21
|
export declare const adjustDropdownHeight: (dropdown: HTMLUListElement | null, search: HTMLInputElement | null) => void;
|
|
22
|
-
export declare const getNearestParentsZIndex: (element: HTMLElement | null) => string;
|
|
23
22
|
export declare const getOptionText: (option: CustomSelectOption) => string;
|
|
24
23
|
declare const CustomSelectDropdown: FC<Props>;
|
|
25
24
|
export default CustomSelectDropdown;
|
|
@@ -74,19 +74,6 @@ export var adjustDropdownHeight = (dropdown, search) => {
|
|
|
74
74
|
}
|
|
75
75
|
adjustDropdownHeightBelow(dropdown);
|
|
76
76
|
};
|
|
77
|
-
export var getNearestParentsZIndex = element => {
|
|
78
|
-
if (!document.defaultView || !element) {
|
|
79
|
-
return "0";
|
|
80
|
-
}
|
|
81
|
-
var zIndex = document.defaultView.getComputedStyle(element, null).getPropertyValue("z-index");
|
|
82
|
-
if (!element.parentElement) {
|
|
83
|
-
return zIndex;
|
|
84
|
-
}
|
|
85
|
-
if (zIndex === "auto" || zIndex === "0" || zIndex === "") {
|
|
86
|
-
return getNearestParentsZIndex(element.parentElement);
|
|
87
|
-
}
|
|
88
|
-
return zIndex;
|
|
89
|
-
};
|
|
90
77
|
export var getOptionText = option => {
|
|
91
78
|
if (option.text) {
|
|
92
79
|
return option.text;
|
|
@@ -124,14 +111,6 @@ var CustomSelectDropdown = _ref => {
|
|
|
124
111
|
// align width with wrapper toggle width
|
|
125
112
|
var toggleWidth = (_toggle$getBoundingCl = toggle === null || toggle === void 0 || (_toggle$getBoundingCl2 = toggle.getBoundingClientRect()) === null || _toggle$getBoundingCl2 === void 0 ? void 0 : _toggle$getBoundingCl2.width) !== null && _toggle$getBoundingCl !== void 0 ? _toggle$getBoundingCl : 0;
|
|
126
113
|
dropdownRef.current.style.setProperty("min-width", "".concat(toggleWidth, "px"));
|
|
127
|
-
|
|
128
|
-
// align z-index: when we are in a modal context, we want the dropdown to be above the modal
|
|
129
|
-
// apply the nearest parents z-index + 1
|
|
130
|
-
var zIndex = getNearestParentsZIndex(toggle);
|
|
131
|
-
if (parseInt(zIndex) > 0) {
|
|
132
|
-
var _dropdownRef$current$;
|
|
133
|
-
(_dropdownRef$current$ = dropdownRef.current.parentElement) === null || _dropdownRef$current$ === void 0 || _dropdownRef$current$.style.setProperty("z-index", zIndex + 1);
|
|
134
|
-
}
|
|
135
114
|
}
|
|
136
115
|
setTimeout(() => {
|
|
137
116
|
var _dropdownRef$current;
|
|
@@ -57,7 +57,7 @@ ModularTable components accepts `columns` and `data` arguments in the same forma
|
|
|
57
57
|
`columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
|
|
58
58
|
`data` - The data array that you want to display on the table.
|
|
59
59
|
### Important note!
|
|
60
|
-
Values passed to both of these params have to
|
|
60
|
+
Values passed to both of these params have to be memoized (for example via{" "}
|
|
61
61
|
<code>React.useMemo</code>). Memoization ensures that our data isn't recreated
|
|
62
62
|
on every render. If we didn't use <code>React.useMemo</code>, the table would
|
|
63
63
|
think it was receiving new data on every render and attempt to recalulate a
|
|
@@ -50,7 +50,7 @@ ModularTable components accepts `columns` and `data` arguments in the same forma
|
|
|
50
50
|
`columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
|
|
51
51
|
`data` - The data array that you want to display on the table.
|
|
52
52
|
### Important note!
|
|
53
|
-
Values passed to both of these params have to
|
|
53
|
+
Values passed to both of these params have to be memoized (for example via{" "}
|
|
54
54
|
<code>React.useMemo</code>). Memoization ensures that our data isn't recreated
|
|
55
55
|
on every render. If we didn't use <code>React.useMemo</code>, the table would
|
|
56
56
|
think it was receiving new data on every render and attempt to recalulate a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["autocomplete", "className", "disabled", "externallyControlled", "onChange", "onSearch", "onClear", "placeholder", "shouldBlurOnSearch", "shouldRefocusAfterReset", "value"];
|
|
1
|
+
var _excluded = ["name", "id", "autocomplete", "className", "disabled", "externallyControlled", "onChange", "onSearch", "onClear", "placeholder", "shouldBlurOnSearch", "shouldRefocusAfterReset", "value"];
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -17,6 +17,8 @@ export var Label = /*#__PURE__*/function (Label) {
|
|
|
17
17
|
*/
|
|
18
18
|
var SearchBox = /*#__PURE__*/React.forwardRef((_ref, forwardedRef) => {
|
|
19
19
|
var {
|
|
20
|
+
name = "search",
|
|
21
|
+
id = "search",
|
|
20
22
|
autocomplete = "on",
|
|
21
23
|
className,
|
|
22
24
|
disabled,
|
|
@@ -54,13 +56,13 @@ var SearchBox = /*#__PURE__*/React.forwardRef((_ref, forwardedRef) => {
|
|
|
54
56
|
className: classNames("p-search-box", className)
|
|
55
57
|
}, /*#__PURE__*/React.createElement("label", {
|
|
56
58
|
className: "u-off-screen",
|
|
57
|
-
htmlFor:
|
|
59
|
+
htmlFor: id
|
|
58
60
|
}, placeholder || "Search"), /*#__PURE__*/React.createElement("input", _extends({
|
|
59
61
|
autoComplete: autocomplete,
|
|
60
62
|
className: "p-search-box__input",
|
|
61
63
|
disabled: disabled,
|
|
62
|
-
id:
|
|
63
|
-
name:
|
|
64
|
+
id: id,
|
|
65
|
+
name: name,
|
|
64
66
|
onChange: evt => _onChange === null || _onChange === void 0 ? void 0 : _onChange(evt.target.value),
|
|
65
67
|
onKeyDown: onKeyDown,
|
|
66
68
|
placeholder: placeholder,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"author": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"tsc-alias": "1.8.10",
|
|
94
94
|
"typescript": "5.7.3",
|
|
95
95
|
"typescript-eslint": "8.24.1",
|
|
96
|
-
"vanilla-framework": "4.
|
|
96
|
+
"vanilla-framework": "4.23.0",
|
|
97
97
|
"wait-on": "8.0.2",
|
|
98
98
|
"webpack": "5.98.0"
|
|
99
99
|
},
|