@k-int/stripes-kint-components 2.6.5 → 2.6.6
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/CHANGELOG.md
CHANGED
|
@@ -255,12 +255,24 @@ var ActionListFieldArray = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
|
255
255
|
actionFunction = function actionFunction() {
|
|
256
256
|
return toggleEditing(data.id);
|
|
257
257
|
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
var ariaLabel = "action-".concat(action.name, "[").concat(data.rowIndex, "]");
|
|
261
|
+
|
|
262
|
+
if (action !== null && action !== void 0 && action.ariaLabel) {
|
|
263
|
+
if (typeof action.ariaLabel === 'function') {
|
|
264
|
+
ariaLabel = action.ariaLabel(data);
|
|
265
|
+
} else if (typeof action.ariaLabel === 'string') {
|
|
266
|
+
ariaLabel = action.ariaLabel;
|
|
267
|
+
} else {
|
|
268
|
+
throw new Error("Provided ariaLabel for action \"".concat(action.name, "\" must be a function or a string."));
|
|
269
|
+
}
|
|
258
270
|
} // If we're handed an icon, use that for the action button
|
|
259
271
|
|
|
260
272
|
|
|
261
273
|
if (action.icon) {
|
|
262
274
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.IconButton, {
|
|
263
|
-
ariaLabel:
|
|
275
|
+
ariaLabel: ariaLabel,
|
|
264
276
|
disabled: editing,
|
|
265
277
|
icon: action.icon,
|
|
266
278
|
onClick: function onClick() {
|
|
@@ -274,6 +286,7 @@ var ActionListFieldArray = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, r
|
|
|
274
286
|
|
|
275
287
|
|
|
276
288
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
289
|
+
ariaLabel: ariaLabel,
|
|
277
290
|
disabled: editing,
|
|
278
291
|
marginBottom0: true,
|
|
279
292
|
onClick: function onClick() {
|
package/package.json
CHANGED
|
@@ -183,12 +183,23 @@ const ActionListFieldArray = forwardRef(({
|
|
|
183
183
|
actionFunction = () => toggleEditing(data.id);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
let ariaLabel = `action-${action.name}[${data.rowIndex}]`;
|
|
187
|
+
if (action?.ariaLabel) {
|
|
188
|
+
if (typeof action.ariaLabel === 'function') {
|
|
189
|
+
ariaLabel = action.ariaLabel(data);
|
|
190
|
+
} else if (typeof action.ariaLabel === 'string') {
|
|
191
|
+
ariaLabel = action.ariaLabel;
|
|
192
|
+
} else {
|
|
193
|
+
throw new Error(`Provided ariaLabel for action "${action.name}" must be a function or a string.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
186
197
|
// If we're handed an icon, use that for the action button
|
|
187
198
|
if (action.icon) {
|
|
188
199
|
return (
|
|
189
200
|
<IconButton
|
|
190
201
|
key={`action-${action.name}[${data.rowIndex}]`}
|
|
191
|
-
ariaLabel={
|
|
202
|
+
ariaLabel={ariaLabel}
|
|
192
203
|
disabled={editing}
|
|
193
204
|
icon={action.icon}
|
|
194
205
|
onClick={() => (actionFunction ? actionFunction() : () => null)}
|
|
@@ -201,6 +212,7 @@ const ActionListFieldArray = forwardRef(({
|
|
|
201
212
|
return (
|
|
202
213
|
<Button
|
|
203
214
|
key={`action-${action.name}[${data.rowIndex}]`}
|
|
215
|
+
ariaLabel={ariaLabel}
|
|
204
216
|
disabled={editing}
|
|
205
217
|
marginBottom0
|
|
206
218
|
onClick={() => (actionFunction ? actionFunction() : () => null)}
|
|
@@ -89,7 +89,7 @@ const myRef = useRef();
|
|
|
89
89
|
|
|
90
90
|
Name | Type | Description | default | required
|
|
91
91
|
--- | --- | --- | --- | ---
|
|
92
|
-
actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop will give the associated icon button an aria-label
|
|
92
|
+
actionAssigner | function | A function which will be passed the entire row object, and can use that to assign an array of actions valid for that row, in the form `{ name: 'actionName', label: "Action Label", icon: 'someIcon', callback: () => null, to: toObject, ariaLabel: () => null }`. The prop `name` is required, but `label` and `icon` are optional props. The `callback` prop will be prioritised ahead of the deprecated actionCalls prop. The `ariaLabel` prop, which can be either a static string or a function accepting the row data and returning a string, will give the associated icon button an aria-label. If a `to` prop is passed, then the resulting button will be rendered as a <Link/> element, as per Stripes Button/IconButton.| | ✓ |
|
|
93
93
|
actionCalls (DEPRECATED) | object<function> | An object with keys matching any "actions" the `actionAssigner` may have assigned (In addition to special case `create`, if relevant), and values which are functions. These functions will be handed the row as a parameter. THESE CAN NOW BE PASSED AS "callback" in the actionAssigner. | {} | ✕ |
|
|
94
94
|
columnMapping | object | An object which will act on the rendered MultiColumnList headers to map the labels for each `visibleField` | | ✕ |
|
|
95
95
|
contentData | array | An array of objects to render along with their actions | | ✓ |
|