carbon-react 129.0.0 → 130.0.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/esm/components/flat-table/sort/sort.component.d.ts +7 -5
- package/esm/components/flat-table/sort/sort.component.js +8 -4
- package/esm/locales/__internal__/es-es.js +3 -0
- package/esm/locales/en-gb.js +3 -0
- package/esm/locales/locale.d.ts +7 -4
- package/lib/components/flat-table/sort/sort.component.d.ts +7 -5
- package/lib/components/flat-table/sort/sort.component.js +8 -4
- package/lib/locales/__internal__/es-es.js +3 -0
- package/lib/locales/en-gb.js +3 -0
- package/lib/locales/locale.d.ts +7 -4
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface SortProps {
|
|
3
3
|
/** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
|
|
4
|
-
sortType?: "ascending" | "descending"
|
|
5
|
-
/** Callback fired when the
|
|
4
|
+
sortType?: "ascending" | "descending";
|
|
5
|
+
/** Callback fired when the component is clicked */
|
|
6
6
|
onClick?: () => void;
|
|
7
|
-
/** Sets the content of
|
|
8
|
-
children?:
|
|
7
|
+
/** Sets the text content of the component */
|
|
8
|
+
children?: string;
|
|
9
|
+
/** Sets the accessible name of the component */
|
|
10
|
+
accessibleName?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare const Sort: ({ children, onClick, sortType }: SortProps) => React.JSX.Element;
|
|
12
|
+
export declare const Sort: ({ children, onClick, sortType, accessibleName, }: SortProps) => React.JSX.Element;
|
|
11
13
|
export default Sort;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React, { useRef, useContext } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import Event from "../../../__internal__/utils/helpers/events";
|
|
4
|
+
import Typography from "../../typography";
|
|
4
5
|
import { StyledSort, StyledSpaceHolder, StyledSortIcon } from "./sort.style";
|
|
5
6
|
import guid from "../../../__internal__/utils/helpers/guid";
|
|
7
|
+
import useLocale from "../../../hooks/__internal__/useLocale";
|
|
6
8
|
import { FlatTableThemeContext } from "../flat-table.component";
|
|
7
9
|
export const Sort = ({
|
|
8
10
|
children,
|
|
9
11
|
onClick,
|
|
10
|
-
sortType
|
|
12
|
+
sortType,
|
|
13
|
+
accessibleName
|
|
11
14
|
}) => {
|
|
12
15
|
const id = useRef(guid());
|
|
16
|
+
const locale = useLocale();
|
|
13
17
|
const onKeyDown = e => {
|
|
14
18
|
if (Event.isEnterOrSpaceKey(e)) {
|
|
15
19
|
e.preventDefault();
|
|
@@ -20,10 +24,10 @@ export const Sort = ({
|
|
|
20
24
|
const {
|
|
21
25
|
colorTheme
|
|
22
26
|
} = useContext(FlatTableThemeContext);
|
|
23
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
24
|
-
|
|
27
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
|
|
28
|
+
screenReaderOnly: true,
|
|
25
29
|
id: id.current
|
|
26
|
-
},
|
|
30
|
+
}, accessibleName || locale.sort.accessibleName(children, sortType)), /*#__PURE__*/React.createElement(StyledSort, {
|
|
27
31
|
role: "button",
|
|
28
32
|
onKeyDown: onKeyDown,
|
|
29
33
|
tabIndex: 0,
|
|
@@ -150,6 +150,9 @@ const esES = {
|
|
|
150
150
|
close: () => "Cerrar"
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
|
+
sort: {
|
|
154
|
+
accessibleName: (sortContent, sortType) => `Ordenar todo ${sortContent || "contenido"}${sortType ? ` en orden ${sortType === "ascending" ? "ascendente" : "descendente"}.` : " en orden ascendente o descendente."}`
|
|
155
|
+
},
|
|
153
156
|
splitButton: {
|
|
154
157
|
ariaLabel: () => "Mostrar más"
|
|
155
158
|
},
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -152,6 +152,9 @@ const enGB = {
|
|
|
152
152
|
close: () => "Close"
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
|
+
sort: {
|
|
156
|
+
accessibleName: (sortContent, sortType) => `Sort all ${sortContent || "contents"}${sortType ? ` in an ${sortType} order.` : " in an ascending or descending order."}`
|
|
157
|
+
},
|
|
155
158
|
splitButton: {
|
|
156
159
|
ariaLabel: () => "Show more"
|
|
157
160
|
},
|
package/esm/locales/locale.d.ts
CHANGED
|
@@ -127,18 +127,21 @@ interface Locale {
|
|
|
127
127
|
close: () => string;
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
|
+
sort: {
|
|
131
|
+
accessibleName: (sortContent?: string, sortType?: "ascending" | "descending") => string;
|
|
132
|
+
};
|
|
130
133
|
splitButton: {
|
|
131
134
|
ariaLabel: () => string;
|
|
132
135
|
};
|
|
133
|
-
switch: {
|
|
134
|
-
on: () => string;
|
|
135
|
-
off: () => string;
|
|
136
|
-
};
|
|
137
136
|
stepFlow: {
|
|
138
137
|
stepLabel: (currentStep: number, totalSteps: number) => string;
|
|
139
138
|
screenReaderOnlyTitle: (title: string, currentStep: number, totalSteps: number, category?: string) => string;
|
|
140
139
|
closeIconAriaLabel?: () => string;
|
|
141
140
|
};
|
|
141
|
+
switch: {
|
|
142
|
+
on: () => string;
|
|
143
|
+
off: () => string;
|
|
144
|
+
};
|
|
142
145
|
textEditor: {
|
|
143
146
|
tooltipMessages: {
|
|
144
147
|
bold: () => string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface SortProps {
|
|
3
3
|
/** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
|
|
4
|
-
sortType?: "ascending" | "descending"
|
|
5
|
-
/** Callback fired when the
|
|
4
|
+
sortType?: "ascending" | "descending";
|
|
5
|
+
/** Callback fired when the component is clicked */
|
|
6
6
|
onClick?: () => void;
|
|
7
|
-
/** Sets the content of
|
|
8
|
-
children?:
|
|
7
|
+
/** Sets the text content of the component */
|
|
8
|
+
children?: string;
|
|
9
|
+
/** Sets the accessible name of the component */
|
|
10
|
+
accessibleName?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare const Sort: ({ children, onClick, sortType }: SortProps) => React.JSX.Element;
|
|
12
|
+
export declare const Sort: ({ children, onClick, sortType, accessibleName, }: SortProps) => React.JSX.Element;
|
|
11
13
|
export default Sort;
|
|
@@ -7,8 +7,10 @@ exports.default = exports.Sort = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events"));
|
|
10
|
+
var _typography = _interopRequireDefault(require("../../typography"));
|
|
10
11
|
var _sort = require("./sort.style");
|
|
11
12
|
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
13
|
+
var _useLocale = _interopRequireDefault(require("../../../hooks/__internal__/useLocale"));
|
|
12
14
|
var _flatTable = require("../flat-table.component");
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -16,9 +18,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
16
18
|
const Sort = ({
|
|
17
19
|
children,
|
|
18
20
|
onClick,
|
|
19
|
-
sortType
|
|
21
|
+
sortType,
|
|
22
|
+
accessibleName
|
|
20
23
|
}) => {
|
|
21
24
|
const id = (0, _react.useRef)((0, _guid.default)());
|
|
25
|
+
const locale = (0, _useLocale.default)();
|
|
22
26
|
const onKeyDown = e => {
|
|
23
27
|
if (_events.default.isEnterOrSpaceKey(e)) {
|
|
24
28
|
e.preventDefault();
|
|
@@ -29,10 +33,10 @@ const Sort = ({
|
|
|
29
33
|
const {
|
|
30
34
|
colorTheme
|
|
31
35
|
} = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
|
|
32
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
33
|
-
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_typography.default, {
|
|
37
|
+
screenReaderOnly: true,
|
|
34
38
|
id: id.current
|
|
35
|
-
},
|
|
39
|
+
}, accessibleName || locale.sort.accessibleName(children, sortType)), /*#__PURE__*/_react.default.createElement(_sort.StyledSort, {
|
|
36
40
|
role: "button",
|
|
37
41
|
onKeyDown: onKeyDown,
|
|
38
42
|
tabIndex: 0,
|
|
@@ -156,6 +156,9 @@ const esES = {
|
|
|
156
156
|
close: () => "Cerrar"
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
|
+
sort: {
|
|
160
|
+
accessibleName: (sortContent, sortType) => `Ordenar todo ${sortContent || "contenido"}${sortType ? ` en orden ${sortType === "ascending" ? "ascendente" : "descendente"}.` : " en orden ascendente o descendente."}`
|
|
161
|
+
},
|
|
159
162
|
splitButton: {
|
|
160
163
|
ariaLabel: () => "Mostrar más"
|
|
161
164
|
},
|
package/lib/locales/en-gb.js
CHANGED
|
@@ -158,6 +158,9 @@ const enGB = {
|
|
|
158
158
|
close: () => "Close"
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
|
+
sort: {
|
|
162
|
+
accessibleName: (sortContent, sortType) => `Sort all ${sortContent || "contents"}${sortType ? ` in an ${sortType} order.` : " in an ascending or descending order."}`
|
|
163
|
+
},
|
|
161
164
|
splitButton: {
|
|
162
165
|
ariaLabel: () => "Show more"
|
|
163
166
|
},
|
package/lib/locales/locale.d.ts
CHANGED
|
@@ -127,18 +127,21 @@ interface Locale {
|
|
|
127
127
|
close: () => string;
|
|
128
128
|
};
|
|
129
129
|
};
|
|
130
|
+
sort: {
|
|
131
|
+
accessibleName: (sortContent?: string, sortType?: "ascending" | "descending") => string;
|
|
132
|
+
};
|
|
130
133
|
splitButton: {
|
|
131
134
|
ariaLabel: () => string;
|
|
132
135
|
};
|
|
133
|
-
switch: {
|
|
134
|
-
on: () => string;
|
|
135
|
-
off: () => string;
|
|
136
|
-
};
|
|
137
136
|
stepFlow: {
|
|
138
137
|
stepLabel: (currentStep: number, totalSteps: number) => string;
|
|
139
138
|
screenReaderOnlyTitle: (title: string, currentStep: number, totalSteps: number, category?: string) => string;
|
|
140
139
|
closeIconAriaLabel?: () => string;
|
|
141
140
|
};
|
|
141
|
+
switch: {
|
|
142
|
+
on: () => string;
|
|
143
|
+
off: () => string;
|
|
144
|
+
};
|
|
142
145
|
textEditor: {
|
|
143
146
|
tooltipMessages: {
|
|
144
147
|
bold: () => string;
|