carbon-react 116.2.2 → 117.1.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/__internal__/character-count/character-count.component.d.ts +2 -2
- package/esm/__internal__/character-count/character-count.component.js +16 -7
- package/esm/components/date/date.d.ts +0 -1
- package/esm/components/decimal/decimal.component.js +1 -0
- package/esm/components/grouped-character/grouped-character.component.js +2 -2
- package/esm/components/i18n-provider/i18n-provider.component.js +5 -0
- package/esm/components/number/number.component.js +2 -2
- package/esm/components/select/filterable-select/filterable-select.component.js +11 -1
- package/esm/components/select/filterable-select/filterable-select.d.ts +4 -0
- package/esm/components/select/multi-select/multi-select.component.js +10 -0
- package/esm/components/select/multi-select/multi-select.d.ts +4 -0
- package/esm/components/select/select-textbox/select-textbox.component.js +11 -2
- package/esm/components/select/select-textbox/select-textbox.d.ts +4 -0
- package/esm/components/select/simple-select/simple-select.component.js +10 -0
- package/esm/components/select/simple-select/simple-select.d.ts +4 -0
- package/esm/components/textarea/textarea.component.d.ts +3 -3
- package/esm/components/textarea/textarea.component.js +17 -10
- package/esm/components/textbox/textbox.component.d.ts +3 -3
- package/esm/components/textbox/textbox.component.js +18 -9
- package/esm/components/textbox/textbox.style.d.ts +3 -2
- package/esm/components/textbox/textbox.style.js +10 -2
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -8
- package/esm/locales/en-gb.js +5 -0
- package/esm/locales/locale.d.ts +5 -0
- package/esm/locales/pl-pl.d.ts +2 -0
- package/esm/locales/pl-pl.js +17 -0
- package/lib/__internal__/character-count/character-count.component.d.ts +2 -2
- package/lib/__internal__/character-count/character-count.component.js +17 -7
- package/lib/components/date/date.d.ts +0 -1
- package/lib/components/decimal/decimal.component.js +1 -0
- package/lib/components/grouped-character/grouped-character.component.js +2 -2
- package/lib/components/i18n-provider/i18n-provider.component.js +5 -0
- package/lib/components/number/number.component.js +2 -2
- package/lib/components/select/filterable-select/filterable-select.component.js +11 -1
- package/lib/components/select/filterable-select/filterable-select.d.ts +4 -0
- package/lib/components/select/multi-select/multi-select.component.js +10 -0
- package/lib/components/select/multi-select/multi-select.d.ts +4 -0
- package/lib/components/select/select-textbox/select-textbox.component.js +11 -2
- package/lib/components/select/select-textbox/select-textbox.d.ts +4 -0
- package/lib/components/select/simple-select/simple-select.component.js +10 -0
- package/lib/components/select/simple-select/simple-select.d.ts +4 -0
- package/lib/components/textarea/textarea.component.d.ts +3 -3
- package/lib/components/textarea/textarea.component.js +15 -7
- package/lib/components/textbox/textbox.component.d.ts +3 -3
- package/lib/components/textbox/textbox.component.js +17 -7
- package/lib/components/textbox/textbox.style.d.ts +3 -2
- package/lib/components/textbox/textbox.style.js +11 -2
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +6 -1
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +9 -7
- package/lib/locales/en-gb.js +5 -0
- package/lib/locales/locale.d.ts +5 -0
- package/lib/locales/pl-pl.d.ts +2 -0
- package/lib/locales/pl-pl.js +19 -1
- package/package.json +1 -1
|
@@ -41,6 +41,8 @@ var _box = _interopRequireDefault(require("../box"));
|
|
|
41
41
|
|
|
42
42
|
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
43
43
|
|
|
44
|
+
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
45
|
+
|
|
44
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
47
|
|
|
46
48
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -66,6 +68,7 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
66
68
|
labelSpacing,
|
|
67
69
|
id,
|
|
68
70
|
formattedValue,
|
|
71
|
+
inputHint,
|
|
69
72
|
fieldHelp,
|
|
70
73
|
error,
|
|
71
74
|
warning,
|
|
@@ -102,13 +105,11 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
102
105
|
"data-role": dataRole,
|
|
103
106
|
enforceCharacterLimit = true,
|
|
104
107
|
characterLimit,
|
|
105
|
-
warnOverLimit = false,
|
|
106
108
|
helpAriaLabel,
|
|
107
109
|
...props
|
|
108
110
|
}, ref) => {
|
|
109
111
|
const characterCountValue = typeof value === "string" ? value : "";
|
|
110
|
-
const [maxLength, characterCount] = (0, _useCharacterCount.default)(characterCountValue,
|
|
111
|
-
typeof characterLimit === "string" ? parseInt(characterLimit, 10) : characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
112
|
+
const [maxLength, characterCount, characterCountHintId, characterCountHint] = (0, _useCharacterCount.default)(characterCountValue, characterLimit, enforceCharacterLimit);
|
|
112
113
|
const {
|
|
113
114
|
validationRedesignOptIn
|
|
114
115
|
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
@@ -139,6 +140,12 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
139
140
|
label,
|
|
140
141
|
fieldHelp
|
|
141
142
|
});
|
|
143
|
+
const hintId = (0, _react.useRef)((0, _guid.default)());
|
|
144
|
+
const characterCountHintIdValue = characterCount ? characterCountHintId : undefined;
|
|
145
|
+
const inputHintIdValue = inputHint ? hintId.current : undefined;
|
|
146
|
+
const hintIdValue = characterLimit ? characterCountHintIdValue : inputHintIdValue;
|
|
147
|
+
const ariaDescribedByValues = [validationRedesignOptIn ? undefined : ariaDescribedBy, hintIdValue];
|
|
148
|
+
const ariaDescribedByValue = ariaDescribedByValues.filter(Boolean).join(" ");
|
|
142
149
|
const hasIconInside = !!(inputIcon || validationIconId && !validationOnLabel);
|
|
143
150
|
|
|
144
151
|
const input = /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
|
|
@@ -162,7 +169,7 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
162
169
|
align: align,
|
|
163
170
|
"aria-invalid": !!error,
|
|
164
171
|
"aria-labelledby": ariaLabelledBy,
|
|
165
|
-
"aria-describedby":
|
|
172
|
+
"aria-describedby": ariaDescribedByValue,
|
|
166
173
|
autoFocus: autoFocus,
|
|
167
174
|
deferTimeout: deferTimeout,
|
|
168
175
|
disabled: disabled,
|
|
@@ -224,7 +231,10 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
224
231
|
"data-element": dataElement,
|
|
225
232
|
validationIconId: validationRedesignOptIn ? undefined : validationIconId,
|
|
226
233
|
validationRedesignOptIn: validationRedesignOptIn
|
|
227
|
-
}, (0, _utils.filterStyledSystemMarginProps)(props)),
|
|
234
|
+
}, (0, _utils.filterStyledSystemMarginProps)(props)), characterLimit || inputHint ? /*#__PURE__*/_react.default.createElement(_textbox.StyledInputHint, {
|
|
235
|
+
id: hintIdValue,
|
|
236
|
+
"data-element": "input-hint"
|
|
237
|
+
}, characterCountHint || inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
228
238
|
position: "relative"
|
|
229
239
|
}, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
|
|
230
240
|
error: error,
|
|
@@ -297,7 +307,7 @@ Textbox.propTypes = {
|
|
|
297
307
|
"autoFocus": _propTypes.default.bool,
|
|
298
308
|
"autoSave": _propTypes.default.string,
|
|
299
309
|
"capture": _propTypes.default.oneOfType([_propTypes.default.oneOf(["environment", "user"]), _propTypes.default.bool]),
|
|
300
|
-
"characterLimit": _propTypes.default.
|
|
310
|
+
"characterLimit": _propTypes.default.number,
|
|
301
311
|
"checked": _propTypes.default.bool,
|
|
302
312
|
"children": _propTypes.default.node,
|
|
303
313
|
"className": _propTypes.default.string,
|
|
@@ -341,6 +351,7 @@ Textbox.propTypes = {
|
|
|
341
351
|
"id": _propTypes.default.string,
|
|
342
352
|
"info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
343
353
|
"inlist": _propTypes.default.any,
|
|
354
|
+
"inputHint": _propTypes.default.string,
|
|
344
355
|
"inputIcon": _propTypes.default.oneOf(["add", "admin", "alert_on", "alert", "analysis", "arrow_bottom_right_circle", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_top_left_circle", "arrow_up", "arrow", "arrows_left_right", "attach", "bank_with_card", "bank", "basket_with_squares", "basket", "bed", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "box_arrow_left", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "car_lock", "car_money", "car_repair", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "cash", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "construction", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "dashboard", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "drill", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "form_refresh", "gift", "go", "graduation_hat", "graph", "grid", "hand_cash_coins", "hand_cash_note", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "laptop", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "palm_tree", "pause_circle", "pause", "pdf", "people_switch", "people", "percentage_boxed", "person_info", "person_tick", "person", "petrol_pump", "phone", "piggy_bank", "plane", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "theatre_masks", "three_boxes", "tick_circle", "tick_thick", "tick", "true_tick", "u_turn_left", "u_turn_right", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
345
356
|
"inputMode": _propTypes.default.oneOf(["decimal", "email", "none", "numeric", "search", "tel", "text", "url"]),
|
|
346
357
|
"inputRef": _propTypes.default.func,
|
|
@@ -764,7 +775,6 @@ Textbox.propTypes = {
|
|
|
764
775
|
"value": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.number, _propTypes.default.string]),
|
|
765
776
|
"vocab": _propTypes.default.string,
|
|
766
777
|
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
767
|
-
"warnOverLimit": _propTypes.default.bool,
|
|
768
778
|
"width": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
769
779
|
};
|
|
770
780
|
Textbox.displayName = "Textbox";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
|
|
2
2
|
warning: boolean;
|
|
3
3
|
}, never>;
|
|
4
|
-
declare const
|
|
5
|
-
|
|
4
|
+
declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
5
|
+
declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export { StyledHintText, ErrorBorder, StyledInputHint };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ErrorBorder = exports.StyledHintText = void 0;
|
|
6
|
+
exports.StyledInputHint = exports.ErrorBorder = exports.StyledHintText = void 0;
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
@@ -25,7 +25,16 @@ const ErrorBorder = _styledComponents.default.span`
|
|
|
25
25
|
`}
|
|
26
26
|
`;
|
|
27
27
|
exports.ErrorBorder = ErrorBorder;
|
|
28
|
-
const
|
|
28
|
+
const StyledInputHint = _styledComponents.default.p`
|
|
29
|
+
display: block;
|
|
30
|
+
flex: 1;
|
|
31
|
+
margin-top: -3px;
|
|
32
|
+
margin-bottom: 8px;
|
|
33
|
+
color: var(--colorsUtilityYin055);
|
|
34
|
+
white-space: pre-wrap;
|
|
35
|
+
`;
|
|
36
|
+
exports.StyledInputHint = StyledInputHint;
|
|
37
|
+
const StyledHintText = _styledComponents.default.div`
|
|
29
38
|
margin-top: 0px;
|
|
30
39
|
margin-bottom: 8px;
|
|
31
40
|
color: var(--colorsUtilityYin055);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const useCharacterCount: (value?: string, characterLimit?: number | undefined,
|
|
2
|
+
declare const useCharacterCount: (value?: string, characterLimit?: number | undefined, enforceCharacterLimit?: boolean) => [
|
|
3
|
+
number | undefined,
|
|
4
|
+
JSX.Element | null,
|
|
5
|
+
string | undefined,
|
|
6
|
+
string | null
|
|
7
|
+
];
|
|
3
8
|
export default useCharacterCount;
|
|
@@ -11,17 +11,19 @@ var _characterCount = _interopRequireDefault(require("../../../__internal__/char
|
|
|
11
11
|
|
|
12
12
|
var _useLocale = _interopRequireDefault(require("../useLocale"));
|
|
13
13
|
|
|
14
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
15
|
+
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
16
18
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
19
|
|
|
18
20
|
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
21
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
|
|
22
|
+
const useCharacterCount = (value = "", characterLimit, enforceCharacterLimit = true) => {
|
|
23
23
|
const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
|
|
24
24
|
const l = (0, _useLocale.default)();
|
|
25
|
+
const hintString = l.characterCount.hintString();
|
|
26
|
+
const hintId = (0, _react.useRef)((0, _guid.default)());
|
|
25
27
|
const isOverLimit = (0, _react.useMemo)(() => {
|
|
26
28
|
if (value && isCharacterLimitValid) {
|
|
27
29
|
return value.length > characterLimit;
|
|
@@ -30,11 +32,11 @@ const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, en
|
|
|
30
32
|
return false;
|
|
31
33
|
}, [value, characterLimit, isCharacterLimitValid]);
|
|
32
34
|
return [enforceCharacterLimit && isCharacterLimitValid ? characterLimit : undefined, isCharacterLimitValid ? /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
33
|
-
isOverLimit: isOverLimit
|
|
34
|
-
value:
|
|
35
|
-
limit:
|
|
35
|
+
isOverLimit: isOverLimit,
|
|
36
|
+
value: value.length,
|
|
37
|
+
limit: characterLimit,
|
|
36
38
|
"data-element": "character-limit"
|
|
37
|
-
}) : null];
|
|
39
|
+
}) : null, hintId.current, isCharacterLimitValid ? hintString : null];
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
var _default = useCharacterCount;
|
package/lib/locales/en-gb.js
CHANGED
|
@@ -25,6 +25,11 @@ const enGB = {
|
|
|
25
25
|
no: () => "No",
|
|
26
26
|
yes: () => "Yes"
|
|
27
27
|
},
|
|
28
|
+
characterCount: {
|
|
29
|
+
hintString: () => "Input contains a character counter",
|
|
30
|
+
tooManyCharacters: (count, formattedCount) => count === 1 ? `You have ${formattedCount} character too many` : `You have ${formattedCount} characters too many`,
|
|
31
|
+
charactersLeft: (count, formattedCount) => count === 1 ? `You have ${formattedCount} character remaining` : `You have ${formattedCount} characters remaining`
|
|
32
|
+
},
|
|
28
33
|
date: {
|
|
29
34
|
dateFnsLocale: () => _dateFnsLocales.enGB
|
|
30
35
|
},
|
package/lib/locales/locale.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ interface Locale {
|
|
|
11
11
|
batchSelection: {
|
|
12
12
|
selected: (count: number | string) => string;
|
|
13
13
|
};
|
|
14
|
+
characterCount: {
|
|
15
|
+
hintString: () => string;
|
|
16
|
+
tooManyCharacters: (count: number, formattedCount: string) => string;
|
|
17
|
+
charactersLeft: (count: number, formattedCount: string) => string;
|
|
18
|
+
};
|
|
14
19
|
confirm: {
|
|
15
20
|
no: () => string;
|
|
16
21
|
yes: () => string;
|
package/lib/locales/pl-pl.d.ts
CHANGED
package/lib/locales/pl-pl.js
CHANGED
|
@@ -3,12 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.PolishPlurals = exports.PolishPlural = void 0;
|
|
7
7
|
|
|
8
8
|
var _dateFnsLocales = require("./date-fns-locales");
|
|
9
9
|
|
|
10
10
|
const isSingular = count => (typeof count === "string" ? parseInt(count) : count) === 1;
|
|
11
11
|
|
|
12
|
+
const PolishPlural = (singularNominativ, pluralNominativ, pluralGenitive, value) => {
|
|
13
|
+
if (value === 1) {
|
|
14
|
+
return singularNominativ;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20)) {
|
|
18
|
+
return pluralNominativ;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return pluralGenitive;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.PolishPlurals = exports.PolishPlural = PolishPlural;
|
|
12
25
|
const plPL = {
|
|
13
26
|
locale: () => "pl-PL",
|
|
14
27
|
actions: {
|
|
@@ -25,6 +38,11 @@ const plPL = {
|
|
|
25
38
|
no: () => "Nie",
|
|
26
39
|
yes: () => "Tak"
|
|
27
40
|
},
|
|
41
|
+
characterCount: {
|
|
42
|
+
hintString: () => "Pole zawiera licznik znaków",
|
|
43
|
+
tooManyCharacters: (count, formattedCount) => `Masz o ${formattedCount} ${PolishPlural("znak", "znaki", "znaków", count)} za dużo`,
|
|
44
|
+
charactersLeft: (count, formattedCount) => `Masz ${formattedCount} ${PolishPlural("pozostały", "pozostałe", "pozostałych", count)} ${PolishPlural("znak", "znaki", "znaków", count)}`
|
|
45
|
+
},
|
|
28
46
|
date: {
|
|
29
47
|
dateFnsLocale: () => _dateFnsLocales.pl
|
|
30
48
|
},
|