carbon-react 125.7.0 → 125.9.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__/fieldset/fieldset.component.d.ts +13 -1
- package/esm/__internal__/fieldset/fieldset.component.js +20 -4
- package/esm/__internal__/fieldset/fieldset.style.d.ts +6 -1
- package/esm/__internal__/fieldset/fieldset.style.js +27 -1
- package/esm/__internal__/label/label.component.d.ts +6 -2
- package/esm/__internal__/label/label.component.js +7 -3
- package/esm/components/box/box.component.d.ts +3 -1
- package/esm/components/box/box.component.js +4 -1
- package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +6 -1
- package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.js +4 -1
- package/esm/components/button-toggle/button-toggle.style.d.ts +15 -0
- package/esm/components/button-toggle/button-toggle.style.js +3 -3
- package/esm/components/heading/heading.style.d.ts +1 -1
- package/esm/components/image/image.component.d.ts +1 -1
- package/esm/components/image/image.component.js +11 -1
- package/esm/components/image/image.style.d.ts +18 -2
- package/esm/components/image/image.style.js +26 -2
- package/esm/components/tile/flex-tile-cell/flex-tile-cell.component.js +1 -0
- package/esm/components/time/__internal__/time-toggle/index.d.ts +2 -0
- package/esm/components/time/__internal__/time-toggle/index.js +1 -0
- package/esm/components/time/__internal__/time-toggle/time-toggle.component.d.ts +20 -0
- package/esm/components/time/__internal__/time-toggle/time-toggle.component.js +52 -0
- package/esm/components/time/__internal__/time-toggle/time-toggle.style.d.ts +8 -0
- package/esm/components/time/__internal__/time-toggle/time-toggle.style.js +19 -0
- package/esm/components/time/index.d.ts +2 -0
- package/esm/components/time/index.js +1 -0
- package/esm/components/time/time.component.d.ts +73 -0
- package/esm/components/time/time.component.js +428 -0
- package/esm/components/time/time.style.d.ts +6 -0
- package/esm/components/time/time.style.js +19 -0
- package/esm/components/typography/typography.component.d.ts +7 -1
- package/esm/components/typography/typography.component.js +3 -1
- package/esm/components/typography/typography.style.js +5 -0
- package/esm/locales/__internal__/pl-pl.js +8 -0
- package/esm/locales/en-gb.js +8 -0
- package/esm/locales/locale.d.ts +8 -0
- package/lib/__internal__/fieldset/fieldset.component.d.ts +13 -1
- package/lib/__internal__/fieldset/fieldset.component.js +19 -3
- package/lib/__internal__/fieldset/fieldset.style.d.ts +6 -1
- package/lib/__internal__/fieldset/fieldset.style.js +27 -1
- package/lib/__internal__/label/label.component.d.ts +6 -2
- package/lib/__internal__/label/label.component.js +7 -3
- package/lib/components/box/box.component.d.ts +3 -1
- package/lib/components/box/box.component.js +4 -1
- package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +6 -1
- package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.js +4 -1
- package/lib/components/button-toggle/button-toggle.style.d.ts +15 -0
- package/lib/components/button-toggle/button-toggle.style.js +4 -4
- package/lib/components/heading/heading.style.d.ts +1 -1
- package/lib/components/image/image.component.d.ts +1 -1
- package/lib/components/image/image.component.js +11 -1
- package/lib/components/image/image.style.d.ts +18 -2
- package/lib/components/image/image.style.js +26 -2
- package/lib/components/tile/flex-tile-cell/flex-tile-cell.component.js +1 -0
- package/lib/components/time/__internal__/time-toggle/index.d.ts +2 -0
- package/lib/components/time/__internal__/time-toggle/index.js +13 -0
- package/lib/components/time/__internal__/time-toggle/package.json +6 -0
- package/lib/components/time/__internal__/time-toggle/time-toggle.component.d.ts +20 -0
- package/lib/components/time/__internal__/time-toggle/time-toggle.component.js +61 -0
- package/lib/components/time/__internal__/time-toggle/time-toggle.style.d.ts +8 -0
- package/lib/components/time/__internal__/time-toggle/time-toggle.style.js +26 -0
- package/lib/components/time/index.d.ts +2 -0
- package/lib/components/time/index.js +13 -0
- package/lib/components/time/package.json +6 -0
- package/lib/components/time/time.component.d.ts +73 -0
- package/lib/components/time/time.component.js +437 -0
- package/lib/components/time/time.style.d.ts +6 -0
- package/lib/components/time/time.style.js +26 -0
- package/lib/components/typography/typography.component.d.ts +7 -1
- package/lib/components/typography/typography.component.js +3 -1
- package/lib/components/typography/typography.style.js +5 -0
- package/lib/locales/__internal__/pl-pl.js +8 -0
- package/lib/locales/en-gb.js +8 -0
- package/lib/locales/locale.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { ValidationProps } from "../../__internal__/validations";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
import { Sizes } from "../../__internal__/input/input-presentation.component";
|
|
6
|
+
import { ToggleDataProps } from "./__internal__/time-toggle";
|
|
7
|
+
export declare type ToggleValue = "AM" | "PM";
|
|
8
|
+
export declare type TimeValue = {
|
|
9
|
+
hours: string;
|
|
10
|
+
minutes: string;
|
|
11
|
+
period?: ToggleValue;
|
|
12
|
+
};
|
|
13
|
+
export interface TimeInputEvent {
|
|
14
|
+
target: {
|
|
15
|
+
name?: string;
|
|
16
|
+
id: string;
|
|
17
|
+
value: TimeValue;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface TimeInputProps extends Omit<TagProps, "data-component">, Omit<ValidationProps, "info"> {
|
|
21
|
+
/** Set an id value on the input */
|
|
22
|
+
id?: string;
|
|
23
|
+
/** Override the default label text */
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Override the default aria-label text */
|
|
26
|
+
"aria-label"?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TimeProps extends Omit<TagProps, "data-component">, MarginProps {
|
|
29
|
+
/** Label text for the component */
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Sets the size of the inputs */
|
|
32
|
+
size?: Sizes;
|
|
33
|
+
/** Additional hint text rendered above the input elements */
|
|
34
|
+
inputHint?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Set custom `data-` and `id` attributes on the input element.
|
|
37
|
+
* Set the `label` and `aria-label` values for the associated Label element.
|
|
38
|
+
* Set the `error` and `warning` states for the input
|
|
39
|
+
* */
|
|
40
|
+
hoursInputProps?: TimeInputProps;
|
|
41
|
+
/**
|
|
42
|
+
* Set custom `data-` and `id` attributes on the input element.
|
|
43
|
+
* Set the `label` and `aria-label` values for the associated Label element.
|
|
44
|
+
* Set the `error` and `warning` states for the input
|
|
45
|
+
* */
|
|
46
|
+
minutesInputProps?: TimeInputProps;
|
|
47
|
+
/** The value of the input elements */
|
|
48
|
+
value: TimeValue;
|
|
49
|
+
/** Callback to handle change events in input elements */
|
|
50
|
+
onChange: (ev: TimeInputEvent) => void;
|
|
51
|
+
/** Set a name value on the component */
|
|
52
|
+
name?: string;
|
|
53
|
+
/** Callback called when focus is lost on input elements */
|
|
54
|
+
onBlur?: (ev?: React.FocusEvent<HTMLInputElement>) => void;
|
|
55
|
+
/** Flag to configure component as mandatory */
|
|
56
|
+
required?: boolean;
|
|
57
|
+
/** Flag to configure component as optional */
|
|
58
|
+
isOptional?: boolean;
|
|
59
|
+
/** If true, the component will be disabled */
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
/** If true, the component will be read-only */
|
|
62
|
+
readOnly?: boolean;
|
|
63
|
+
/** Set custom data- attributes on the toggle elements */
|
|
64
|
+
toggleProps?: ToggleDataProps;
|
|
65
|
+
}
|
|
66
|
+
export declare type TimeHandle = {
|
|
67
|
+
/** Programmatically focus the hours input. */
|
|
68
|
+
focusHoursInput: () => void;
|
|
69
|
+
/** Programmatically focus the minutes input. */
|
|
70
|
+
focusMinutesInput: () => void;
|
|
71
|
+
} | null;
|
|
72
|
+
declare const Time: React.ForwardRefExoticComponent<TimeProps & React.RefAttributes<TimeHandle>>;
|
|
73
|
+
export default Time;
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import React, { useCallback, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import guid from "../../__internal__/utils/helpers/guid";
|
|
5
|
+
import useLocale from "../../hooks/__internal__/useLocale";
|
|
6
|
+
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
7
|
+
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
|
|
8
|
+
import Fieldset from "../../__internal__/fieldset";
|
|
9
|
+
import Box from "../box";
|
|
10
|
+
import { ErrorBorder } from "../textbox/textbox.style";
|
|
11
|
+
import ValidationMessage from "../../__internal__/validation-message";
|
|
12
|
+
import Number from "../number";
|
|
13
|
+
import Typography from "../typography";
|
|
14
|
+
import { StyledLabel as Label, StyledHintText as Hint } from "./time.style";
|
|
15
|
+
import { TimeToggle } from "./__internal__/time-toggle";
|
|
16
|
+
const Time = /*#__PURE__*/React.forwardRef(({
|
|
17
|
+
label,
|
|
18
|
+
size = "medium",
|
|
19
|
+
inputHint,
|
|
20
|
+
hoursInputProps = {},
|
|
21
|
+
minutesInputProps = {},
|
|
22
|
+
value,
|
|
23
|
+
name,
|
|
24
|
+
onChange,
|
|
25
|
+
onBlur,
|
|
26
|
+
required,
|
|
27
|
+
isOptional,
|
|
28
|
+
disabled,
|
|
29
|
+
readOnly,
|
|
30
|
+
toggleProps = {},
|
|
31
|
+
...rest
|
|
32
|
+
}, ref) => {
|
|
33
|
+
const {
|
|
34
|
+
id: hoursInputId,
|
|
35
|
+
label: hoursLabel,
|
|
36
|
+
"aria-label": hoursAriaLabel,
|
|
37
|
+
error: hoursError,
|
|
38
|
+
warning: hoursWarning
|
|
39
|
+
} = hoursInputProps;
|
|
40
|
+
const {
|
|
41
|
+
id: minutesInputId,
|
|
42
|
+
label: minutesLabel,
|
|
43
|
+
"aria-label": minutesAriaLabel,
|
|
44
|
+
error: minutesError,
|
|
45
|
+
warning: minutesWarning
|
|
46
|
+
} = minutesInputProps;
|
|
47
|
+
const internalHrsId = useRef(hoursInputId || guid());
|
|
48
|
+
const internalMinsId = useRef(minutesInputId || guid());
|
|
49
|
+
const inputHintId = useRef(guid());
|
|
50
|
+
const internalId = useRef(`${internalHrsId.current} ${internalMinsId.current}`);
|
|
51
|
+
const {
|
|
52
|
+
hours: hourValue,
|
|
53
|
+
minutes: minuteValue,
|
|
54
|
+
period: toggleValue
|
|
55
|
+
} = value;
|
|
56
|
+
const [inputValues, setInputValues] = useState([hourValue, minuteValue]);
|
|
57
|
+
const locale = useLocale();
|
|
58
|
+
const showToggle = toggleValue !== undefined;
|
|
59
|
+
const [period, setPeriod] = useState(toggleValue);
|
|
60
|
+
const hrsLabel = hoursLabel || locale.time.hoursLabelText();
|
|
61
|
+
const minsLabel = minutesLabel || locale.time.minutesLabelText();
|
|
62
|
+
const hrsAriaLabel = hoursAriaLabel || locale.time.hoursAriaLabelText();
|
|
63
|
+
const minsAriaLabel = minutesAriaLabel || locale.time.minutesAriaLabelText();
|
|
64
|
+
const hoursRef = useRef(null);
|
|
65
|
+
const minsRef = useRef(null);
|
|
66
|
+
const computedValidations = (hrs, mins) => {
|
|
67
|
+
const hoursIsString = typeof hrs === "string";
|
|
68
|
+
const minutesIsString = typeof mins === "string";
|
|
69
|
+
if (!hoursIsString && !minutesIsString) {
|
|
70
|
+
return hrs || mins;
|
|
71
|
+
}
|
|
72
|
+
if (hoursIsString && !minutesIsString) {
|
|
73
|
+
return hrs;
|
|
74
|
+
}
|
|
75
|
+
if (minutesIsString && !hoursIsString) {
|
|
76
|
+
return mins;
|
|
77
|
+
}
|
|
78
|
+
return `${hrs} ${mins}`;
|
|
79
|
+
};
|
|
80
|
+
const error = computedValidations(hoursError, minutesError);
|
|
81
|
+
const warning = computedValidations(hoursWarning, minutesWarning);
|
|
82
|
+
const hasValidationFailure = !!(error || warning);
|
|
83
|
+
const {
|
|
84
|
+
validationId,
|
|
85
|
+
ariaDescribedBy
|
|
86
|
+
} = useInputAccessibility({
|
|
87
|
+
id: internalId.current,
|
|
88
|
+
validationRedesignOptIn: true,
|
|
89
|
+
error,
|
|
90
|
+
warning
|
|
91
|
+
});
|
|
92
|
+
const combinedAriaDescribedBy = [ariaDescribedBy, inputHintId.current].filter(Boolean).join(" ");
|
|
93
|
+
useImperativeHandle(ref, () => ({
|
|
94
|
+
focusHoursInput() {
|
|
95
|
+
hoursRef.current?.focus();
|
|
96
|
+
},
|
|
97
|
+
focusMinutesInput() {
|
|
98
|
+
minsRef.current?.focus();
|
|
99
|
+
}
|
|
100
|
+
}), []);
|
|
101
|
+
const handleChange = (ev, inputName) => {
|
|
102
|
+
const hours = inputName === "hrs" ? ev.target.value : inputValues[0];
|
|
103
|
+
const minutes = inputName === "mins" ? ev.target.value : inputValues[1];
|
|
104
|
+
setInputValues([hours, minutes]);
|
|
105
|
+
onChange({
|
|
106
|
+
target: {
|
|
107
|
+
name,
|
|
108
|
+
id: internalId.current,
|
|
109
|
+
value: {
|
|
110
|
+
hours,
|
|
111
|
+
minutes,
|
|
112
|
+
period
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
const handlePeriodChange = periodName => {
|
|
118
|
+
const [hours, minutes] = inputValues;
|
|
119
|
+
setPeriod(periodName);
|
|
120
|
+
onChange({
|
|
121
|
+
target: {
|
|
122
|
+
name,
|
|
123
|
+
id: internalId.current,
|
|
124
|
+
value: {
|
|
125
|
+
hours,
|
|
126
|
+
minutes,
|
|
127
|
+
period: periodName
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const handleBlur = useCallback(ev => {
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
if (hoursRef.current !== document.activeElement && minsRef.current !== document.activeElement) {
|
|
135
|
+
onBlur?.(ev);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}, [onBlur]);
|
|
139
|
+
return /*#__PURE__*/React.createElement(Fieldset, _extends({
|
|
140
|
+
legend: label,
|
|
141
|
+
legendMargin: {
|
|
142
|
+
mb: 0
|
|
143
|
+
},
|
|
144
|
+
width: "min-content",
|
|
145
|
+
isRequired: required,
|
|
146
|
+
isOptional: isOptional,
|
|
147
|
+
isDisabled: disabled,
|
|
148
|
+
name: name,
|
|
149
|
+
id: internalId.current
|
|
150
|
+
}, rest, tagComponent("time", rest), {
|
|
151
|
+
"aria-describedby": combinedAriaDescribedBy
|
|
152
|
+
}), inputHint && /*#__PURE__*/React.createElement(Hint, {
|
|
153
|
+
id: inputHintId.current,
|
|
154
|
+
isDisabled: disabled
|
|
155
|
+
}, inputHint), /*#__PURE__*/React.createElement(Box, {
|
|
156
|
+
position: "relative"
|
|
157
|
+
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
158
|
+
validationId: validationId,
|
|
159
|
+
error: error,
|
|
160
|
+
warning: warning
|
|
161
|
+
}), hasValidationFailure && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
162
|
+
warning: !!(!error && warning)
|
|
163
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
164
|
+
display: "flex"
|
|
165
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Label, {
|
|
166
|
+
"aria-label": hrsAriaLabel,
|
|
167
|
+
htmlFor: internalHrsId.current,
|
|
168
|
+
disabled: disabled
|
|
169
|
+
}, hrsLabel), /*#__PURE__*/React.createElement(Number, _extends({}, hoursInputProps, {
|
|
170
|
+
label: undefined,
|
|
171
|
+
"data-component": "hours",
|
|
172
|
+
ref: hoursRef,
|
|
173
|
+
value: hourValue,
|
|
174
|
+
onChange: ev => handleChange(ev, "hrs"),
|
|
175
|
+
onBlur: handleBlur,
|
|
176
|
+
id: internalHrsId.current,
|
|
177
|
+
size: size,
|
|
178
|
+
error: !!hoursError,
|
|
179
|
+
warning: !!hoursWarning,
|
|
180
|
+
disabled: disabled,
|
|
181
|
+
readOnly: readOnly
|
|
182
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
183
|
+
display: "flex",
|
|
184
|
+
flexDirection: "column",
|
|
185
|
+
justifyContent: "center",
|
|
186
|
+
mx: 1,
|
|
187
|
+
"aria-hidden": "true"
|
|
188
|
+
}, /*#__PURE__*/React.createElement("span", null, "\xA0"), /*#__PURE__*/React.createElement(Typography, {
|
|
189
|
+
isDisabled: disabled,
|
|
190
|
+
variant: "span",
|
|
191
|
+
mb: "-4px"
|
|
192
|
+
}, ":")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Label, {
|
|
193
|
+
"aria-label": minsAriaLabel,
|
|
194
|
+
htmlFor: internalMinsId.current,
|
|
195
|
+
disabled: disabled
|
|
196
|
+
}, minsLabel), /*#__PURE__*/React.createElement(Number, _extends({}, minutesInputProps, {
|
|
197
|
+
label: undefined,
|
|
198
|
+
"data-component": "minutes",
|
|
199
|
+
ref: minsRef,
|
|
200
|
+
value: minuteValue,
|
|
201
|
+
onChange: ev => handleChange(ev, "mins"),
|
|
202
|
+
onBlur: handleBlur,
|
|
203
|
+
id: internalMinsId.current,
|
|
204
|
+
size: size,
|
|
205
|
+
error: !!minutesError,
|
|
206
|
+
warning: !!minutesWarning,
|
|
207
|
+
disabled: disabled,
|
|
208
|
+
readOnly: readOnly
|
|
209
|
+
}))), showToggle && /*#__PURE__*/React.createElement(Box, {
|
|
210
|
+
display: "flex",
|
|
211
|
+
flexDirection: "column",
|
|
212
|
+
justifyContent: "flex-end"
|
|
213
|
+
}, /*#__PURE__*/React.createElement(TimeToggle, {
|
|
214
|
+
toggleProps: toggleProps,
|
|
215
|
+
size: size,
|
|
216
|
+
onChange: handlePeriodChange,
|
|
217
|
+
toggleValue: toggleValue,
|
|
218
|
+
disabled: disabled || readOnly
|
|
219
|
+
})))));
|
|
220
|
+
});
|
|
221
|
+
Time.propTypes = {
|
|
222
|
+
"children": PropTypes.node,
|
|
223
|
+
"data-element": PropTypes.string,
|
|
224
|
+
"data-role": PropTypes.string,
|
|
225
|
+
"disabled": PropTypes.bool,
|
|
226
|
+
"hoursInputProps": PropTypes.shape({
|
|
227
|
+
"aria-label": PropTypes.string,
|
|
228
|
+
"data-element": PropTypes.string,
|
|
229
|
+
"data-role": PropTypes.string,
|
|
230
|
+
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
231
|
+
"id": PropTypes.string,
|
|
232
|
+
"label": PropTypes.string,
|
|
233
|
+
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
234
|
+
}),
|
|
235
|
+
"inputHint": PropTypes.string,
|
|
236
|
+
"isOptional": PropTypes.bool,
|
|
237
|
+
"label": PropTypes.string,
|
|
238
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
239
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
240
|
+
"description": PropTypes.string,
|
|
241
|
+
"toString": PropTypes.func.isRequired,
|
|
242
|
+
"valueOf": PropTypes.func.isRequired
|
|
243
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
244
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
245
|
+
"description": PropTypes.string,
|
|
246
|
+
"toString": PropTypes.func.isRequired,
|
|
247
|
+
"valueOf": PropTypes.func.isRequired
|
|
248
|
+
}), PropTypes.string]),
|
|
249
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
250
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
251
|
+
"description": PropTypes.string,
|
|
252
|
+
"toString": PropTypes.func.isRequired,
|
|
253
|
+
"valueOf": PropTypes.func.isRequired
|
|
254
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
255
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
256
|
+
"description": PropTypes.string,
|
|
257
|
+
"toString": PropTypes.func.isRequired,
|
|
258
|
+
"valueOf": PropTypes.func.isRequired
|
|
259
|
+
}), PropTypes.string]),
|
|
260
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
261
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
262
|
+
"description": PropTypes.string,
|
|
263
|
+
"toString": PropTypes.func.isRequired,
|
|
264
|
+
"valueOf": PropTypes.func.isRequired
|
|
265
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
266
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
267
|
+
"description": PropTypes.string,
|
|
268
|
+
"toString": PropTypes.func.isRequired,
|
|
269
|
+
"valueOf": PropTypes.func.isRequired
|
|
270
|
+
}), PropTypes.string]),
|
|
271
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
272
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
273
|
+
"description": PropTypes.string,
|
|
274
|
+
"toString": PropTypes.func.isRequired,
|
|
275
|
+
"valueOf": PropTypes.func.isRequired
|
|
276
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
277
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
278
|
+
"description": PropTypes.string,
|
|
279
|
+
"toString": PropTypes.func.isRequired,
|
|
280
|
+
"valueOf": PropTypes.func.isRequired
|
|
281
|
+
}), PropTypes.string]),
|
|
282
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
283
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
284
|
+
"description": PropTypes.string,
|
|
285
|
+
"toString": PropTypes.func.isRequired,
|
|
286
|
+
"valueOf": PropTypes.func.isRequired
|
|
287
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
288
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
289
|
+
"description": PropTypes.string,
|
|
290
|
+
"toString": PropTypes.func.isRequired,
|
|
291
|
+
"valueOf": PropTypes.func.isRequired
|
|
292
|
+
}), PropTypes.string]),
|
|
293
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
294
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
295
|
+
"description": PropTypes.string,
|
|
296
|
+
"toString": PropTypes.func.isRequired,
|
|
297
|
+
"valueOf": PropTypes.func.isRequired
|
|
298
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
299
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
300
|
+
"description": PropTypes.string,
|
|
301
|
+
"toString": PropTypes.func.isRequired,
|
|
302
|
+
"valueOf": PropTypes.func.isRequired
|
|
303
|
+
}), PropTypes.string]),
|
|
304
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
305
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
306
|
+
"description": PropTypes.string,
|
|
307
|
+
"toString": PropTypes.func.isRequired,
|
|
308
|
+
"valueOf": PropTypes.func.isRequired
|
|
309
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
310
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
311
|
+
"description": PropTypes.string,
|
|
312
|
+
"toString": PropTypes.func.isRequired,
|
|
313
|
+
"valueOf": PropTypes.func.isRequired
|
|
314
|
+
}), PropTypes.string]),
|
|
315
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
316
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
317
|
+
"description": PropTypes.string,
|
|
318
|
+
"toString": PropTypes.func.isRequired,
|
|
319
|
+
"valueOf": PropTypes.func.isRequired
|
|
320
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
321
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
322
|
+
"description": PropTypes.string,
|
|
323
|
+
"toString": PropTypes.func.isRequired,
|
|
324
|
+
"valueOf": PropTypes.func.isRequired
|
|
325
|
+
}), PropTypes.string]),
|
|
326
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
327
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
328
|
+
"description": PropTypes.string,
|
|
329
|
+
"toString": PropTypes.func.isRequired,
|
|
330
|
+
"valueOf": PropTypes.func.isRequired
|
|
331
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
332
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
333
|
+
"description": PropTypes.string,
|
|
334
|
+
"toString": PropTypes.func.isRequired,
|
|
335
|
+
"valueOf": PropTypes.func.isRequired
|
|
336
|
+
}), PropTypes.string]),
|
|
337
|
+
"minutesInputProps": PropTypes.shape({
|
|
338
|
+
"aria-label": PropTypes.string,
|
|
339
|
+
"data-element": PropTypes.string,
|
|
340
|
+
"data-role": PropTypes.string,
|
|
341
|
+
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
342
|
+
"id": PropTypes.string,
|
|
343
|
+
"label": PropTypes.string,
|
|
344
|
+
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
345
|
+
}),
|
|
346
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
347
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
348
|
+
"description": PropTypes.string,
|
|
349
|
+
"toString": PropTypes.func.isRequired,
|
|
350
|
+
"valueOf": PropTypes.func.isRequired
|
|
351
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
352
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
353
|
+
"description": PropTypes.string,
|
|
354
|
+
"toString": PropTypes.func.isRequired,
|
|
355
|
+
"valueOf": PropTypes.func.isRequired
|
|
356
|
+
}), PropTypes.string]),
|
|
357
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
358
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
359
|
+
"description": PropTypes.string,
|
|
360
|
+
"toString": PropTypes.func.isRequired,
|
|
361
|
+
"valueOf": PropTypes.func.isRequired
|
|
362
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
363
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
364
|
+
"description": PropTypes.string,
|
|
365
|
+
"toString": PropTypes.func.isRequired,
|
|
366
|
+
"valueOf": PropTypes.func.isRequired
|
|
367
|
+
}), PropTypes.string]),
|
|
368
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
369
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
370
|
+
"description": PropTypes.string,
|
|
371
|
+
"toString": PropTypes.func.isRequired,
|
|
372
|
+
"valueOf": PropTypes.func.isRequired
|
|
373
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
374
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
375
|
+
"description": PropTypes.string,
|
|
376
|
+
"toString": PropTypes.func.isRequired,
|
|
377
|
+
"valueOf": PropTypes.func.isRequired
|
|
378
|
+
}), PropTypes.string]),
|
|
379
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
380
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
381
|
+
"description": PropTypes.string,
|
|
382
|
+
"toString": PropTypes.func.isRequired,
|
|
383
|
+
"valueOf": PropTypes.func.isRequired
|
|
384
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
385
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
386
|
+
"description": PropTypes.string,
|
|
387
|
+
"toString": PropTypes.func.isRequired,
|
|
388
|
+
"valueOf": PropTypes.func.isRequired
|
|
389
|
+
}), PropTypes.string]),
|
|
390
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
391
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
392
|
+
"description": PropTypes.string,
|
|
393
|
+
"toString": PropTypes.func.isRequired,
|
|
394
|
+
"valueOf": PropTypes.func.isRequired
|
|
395
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
396
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
397
|
+
"description": PropTypes.string,
|
|
398
|
+
"toString": PropTypes.func.isRequired,
|
|
399
|
+
"valueOf": PropTypes.func.isRequired
|
|
400
|
+
}), PropTypes.string]),
|
|
401
|
+
"name": PropTypes.string,
|
|
402
|
+
"onBlur": PropTypes.func,
|
|
403
|
+
"onChange": PropTypes.func.isRequired,
|
|
404
|
+
"readOnly": PropTypes.bool,
|
|
405
|
+
"required": PropTypes.bool,
|
|
406
|
+
"size": PropTypes.oneOf(["large", "medium", "small"]),
|
|
407
|
+
"toggleProps": PropTypes.shape({
|
|
408
|
+
"amToggleProps": PropTypes.shape({
|
|
409
|
+
"data-element": PropTypes.string,
|
|
410
|
+
"data-role": PropTypes.string
|
|
411
|
+
}),
|
|
412
|
+
"pmToggleProps": PropTypes.shape({
|
|
413
|
+
"data-element": PropTypes.string,
|
|
414
|
+
"data-role": PropTypes.string
|
|
415
|
+
}),
|
|
416
|
+
"wrapperProps": PropTypes.shape({
|
|
417
|
+
"data-element": PropTypes.string,
|
|
418
|
+
"data-role": PropTypes.string
|
|
419
|
+
})
|
|
420
|
+
}),
|
|
421
|
+
"value": PropTypes.shape({
|
|
422
|
+
"hours": PropTypes.string.isRequired,
|
|
423
|
+
"minutes": PropTypes.string.isRequired,
|
|
424
|
+
"period": PropTypes.oneOf(["AM", "PM"])
|
|
425
|
+
}).isRequired
|
|
426
|
+
};
|
|
427
|
+
Time.displayName = "Time";
|
|
428
|
+
export default Time;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledLabel: import("styled-components").StyledComponent<import("react").MemoExoticComponent<({ align, as, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, className, "aria-label": ariaLabel, }: import("../../__internal__/label").LabelProps) => import("react").JSX.Element>, any, {}, never>;
|
|
3
|
+
export declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {
|
|
4
|
+
isDisabled?: boolean | undefined;
|
|
5
|
+
hasError?: boolean | undefined;
|
|
6
|
+
}, never>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import Label from "../../__internal__/label";
|
|
3
|
+
export const StyledLabel = styled(Label)`
|
|
4
|
+
label {
|
|
5
|
+
font-weight: var(--fontWeights500);
|
|
6
|
+
}
|
|
7
|
+
`;
|
|
8
|
+
export const StyledHintText = styled.div`
|
|
9
|
+
::after {
|
|
10
|
+
content: " ";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
margin-top: 0px;
|
|
14
|
+
margin-bottom: var(--spacing150);
|
|
15
|
+
color: ${({
|
|
16
|
+
isDisabled
|
|
17
|
+
}) => isDisabled ? "var(--colorsUtilityYin030)" : "var(--colorsUtilityYin055)"};
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
`;
|
|
@@ -49,9 +49,15 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
49
49
|
/** Set whether it will be visually hidden
|
|
50
50
|
* NOTE: This is for screen readers only and will make a lot of the other props redundant */
|
|
51
51
|
screenReaderOnly?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @private
|
|
54
|
+
* @ignore
|
|
55
|
+
* Override the default color of the rendered element to match disabled styling
|
|
56
|
+
* */
|
|
57
|
+
isDisabled?: boolean;
|
|
52
58
|
}
|
|
53
59
|
export declare const Typography: {
|
|
54
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
60
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, isDisabled, ...rest }: TypographyProps): React.JSX.Element;
|
|
55
61
|
displayName: string;
|
|
56
62
|
};
|
|
57
63
|
export default Typography;
|
|
@@ -29,6 +29,7 @@ export const Typography = ({
|
|
|
29
29
|
children,
|
|
30
30
|
className,
|
|
31
31
|
screenReaderOnly,
|
|
32
|
+
isDisabled,
|
|
32
33
|
...rest
|
|
33
34
|
}) => {
|
|
34
35
|
return /*#__PURE__*/React.createElement(StyledTypography, _extends({
|
|
@@ -52,7 +53,8 @@ export const Typography = ({
|
|
|
52
53
|
bg: bg,
|
|
53
54
|
opacity: opacity,
|
|
54
55
|
className: className,
|
|
55
|
-
screenReaderOnly: screenReaderOnly
|
|
56
|
+
screenReaderOnly: screenReaderOnly,
|
|
57
|
+
isDisabled: isDisabled
|
|
56
58
|
}, tagComponent(dataComponent, rest), filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest)), children);
|
|
57
59
|
};
|
|
58
60
|
Typography.displayName = "Typography";
|
|
@@ -190,6 +190,11 @@ const StyledTypography = styled.span.attrs(({
|
|
|
190
190
|
backgroundColor,
|
|
191
191
|
...rest
|
|
192
192
|
})}
|
|
193
|
+
${({
|
|
194
|
+
isDisabled
|
|
195
|
+
}) => isDisabled && css`
|
|
196
|
+
color: var(--colorsUtilityYin030);
|
|
197
|
+
`}
|
|
193
198
|
`;
|
|
194
199
|
StyledTypography.defaultProps = {
|
|
195
200
|
theme: baseTheme
|
|
@@ -198,6 +198,14 @@ const plPL = {
|
|
|
198
198
|
tileSelect: {
|
|
199
199
|
deselect: () => "Odznacz"
|
|
200
200
|
},
|
|
201
|
+
time: {
|
|
202
|
+
amText: () => "AM",
|
|
203
|
+
pmText: () => "PM",
|
|
204
|
+
hoursLabelText: () => "Hrs.",
|
|
205
|
+
minutesLabelText: () => "Min.",
|
|
206
|
+
hoursAriaLabelText: () => "Godziny",
|
|
207
|
+
minutesAriaLabelText: () => "Minuty"
|
|
208
|
+
},
|
|
201
209
|
toast: {
|
|
202
210
|
ariaLabels: {
|
|
203
211
|
close: () => "Zamknij"
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -163,6 +163,14 @@ const enGB = {
|
|
|
163
163
|
tileSelect: {
|
|
164
164
|
deselect: () => "Deselect"
|
|
165
165
|
},
|
|
166
|
+
time: {
|
|
167
|
+
amText: () => "AM",
|
|
168
|
+
pmText: () => "PM",
|
|
169
|
+
hoursLabelText: () => "Hrs.",
|
|
170
|
+
minutesLabelText: () => "Mins.",
|
|
171
|
+
hoursAriaLabelText: () => "Hours",
|
|
172
|
+
minutesAriaLabelText: () => "Minutes"
|
|
173
|
+
},
|
|
166
174
|
toast: {
|
|
167
175
|
ariaLabels: {
|
|
168
176
|
close: () => "Close"
|
package/esm/locales/locale.d.ts
CHANGED
|
@@ -138,6 +138,14 @@ interface Locale {
|
|
|
138
138
|
tileSelect: {
|
|
139
139
|
deselect: () => string;
|
|
140
140
|
};
|
|
141
|
+
time: {
|
|
142
|
+
amText: () => string;
|
|
143
|
+
pmText: () => string;
|
|
144
|
+
hoursLabelText: () => string;
|
|
145
|
+
minutesLabelText: () => string;
|
|
146
|
+
hoursAriaLabelText: () => string;
|
|
147
|
+
minutesAriaLabelText: () => string;
|
|
148
|
+
};
|
|
141
149
|
toast: {
|
|
142
150
|
ariaLabels: {
|
|
143
151
|
close: () => string;
|
|
@@ -22,6 +22,18 @@ export interface FieldsetProps extends MarginProps {
|
|
|
22
22
|
isRequired?: boolean;
|
|
23
23
|
/** Controls whether group behaviour should be enabled */
|
|
24
24
|
blockGroupBehaviour?: boolean;
|
|
25
|
+
/** Margin props for the legend element */
|
|
26
|
+
legendMargin?: Pick<MarginProps, "mb">;
|
|
27
|
+
/** Any valid CSS string to set the component's width */
|
|
28
|
+
width?: string;
|
|
29
|
+
/** Flag to configure component as optional in Form */
|
|
30
|
+
isOptional?: boolean;
|
|
31
|
+
/** Apply disabled styling to the legend content */
|
|
32
|
+
isDisabled?: boolean;
|
|
33
|
+
/** Set a name value on the component */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Set an id value on the component */
|
|
36
|
+
id?: string;
|
|
25
37
|
}
|
|
26
|
-
declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, ...rest }: FieldsetProps) => React.JSX.Element;
|
|
38
|
+
declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, ...rest }: FieldsetProps) => React.JSX.Element;
|
|
27
39
|
export default Fieldset;
|