carbon-react 111.9.1 → 111.10.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/note/__internal__/status-icon/index.d.ts +1 -0
- package/esm/components/note/__internal__/status-icon/index.js +1 -0
- package/esm/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
- package/esm/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +4 -6
- package/esm/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
- package/esm/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
- package/esm/components/note/index.d.ts +2 -2
- package/esm/components/note/note.component.d.ts +28 -0
- package/esm/components/note/note.component.js +188 -46
- package/esm/components/note/note.style.d.ts +13 -0
- package/esm/components/note/note.style.js +0 -5
- package/esm/components/numeral-date/index.d.ts +2 -1
- package/esm/components/numeral-date/numeral-date.component.d.ts +81 -0
- package/esm/components/numeral-date/numeral-date.component.js +237 -128
- package/esm/components/numeral-date/numeral-date.style.d.ts +11 -0
- package/esm/components/sidebar/sidebar.component.d.ts +2 -2
- package/esm/components/sidebar/sidebar.component.js +106 -2
- package/esm/components/sidebar/sidebar.style.d.ts +1 -6
- package/esm/components/sidebar/sidebar.style.js +7 -2
- package/esm/components/text-editor/__internal__/decorators/index.d.ts +3 -0
- package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
- package/esm/components/text-editor/__internal__/utils/index.d.ts +1 -0
- package/esm/components/text-editor/__internal__/utils/utils.d.ts +28 -0
- package/esm/components/text-editor/text-editor.component.d.ts +8 -0
- package/esm/components/text-editor/text-editor.style.d.ts +3 -0
- package/esm/style/utils/width.d.ts +1 -1
- package/lib/components/note/__internal__/status-icon/index.d.ts +1 -0
- package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/index.js +2 -2
- package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/package.json +1 -1
- package/lib/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
- package/lib/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +5 -7
- package/lib/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
- package/lib/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
- package/lib/components/note/index.d.ts +2 -2
- package/lib/components/note/note.component.d.ts +28 -0
- package/lib/components/note/note.component.js +195 -55
- package/lib/components/note/note.style.d.ts +13 -0
- package/lib/components/note/note.style.js +0 -6
- package/lib/components/numeral-date/index.d.ts +2 -1
- package/lib/components/numeral-date/numeral-date.component.d.ts +81 -0
- package/lib/components/numeral-date/numeral-date.component.js +237 -128
- package/lib/components/numeral-date/numeral-date.style.d.ts +11 -0
- package/lib/components/sidebar/sidebar.component.d.ts +2 -2
- package/lib/components/sidebar/sidebar.component.js +106 -2
- package/lib/components/sidebar/sidebar.style.d.ts +1 -6
- package/lib/components/sidebar/sidebar.style.js +8 -2
- package/lib/components/text-editor/__internal__/decorators/index.d.ts +3 -0
- package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
- package/lib/components/text-editor/__internal__/utils/index.d.ts +1 -0
- package/lib/components/text-editor/__internal__/utils/utils.d.ts +28 -0
- package/lib/components/text-editor/text-editor.component.d.ts +8 -0
- package/lib/components/text-editor/text-editor.style.d.ts +3 -0
- package/lib/style/utils/width.d.ts +1 -1
- package/package.json +3 -2
- package/esm/components/note/__internal__/status-with-tooltip/index.js +0 -1
- package/esm/components/note/note.d.ts +0 -30
- package/esm/components/numeral-date/numeral-date.d.ts +0 -97
- package/lib/components/note/note.d.ts +0 -30
- package/lib/components/numeral-date/numeral-date.d.ts +0 -97
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || 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
2
|
|
|
3
|
-
import React, { useContext, useState, useEffect, useRef } from "react";
|
|
3
|
+
import React, { useContext, useState, useEffect, useRef, useMemo } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import invariant from "invariant";
|
|
7
6
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
8
7
|
import Events from "../../__internal__/utils/helpers/events";
|
|
@@ -17,8 +16,8 @@ import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
|
|
|
17
16
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
18
17
|
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
19
18
|
import NumeralDateContext from "./numeral-date-context";
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
export const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
|
|
20
|
+
const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
|
|
22
21
|
|
|
23
22
|
const isDayValid = day => day ? +day > 0 && +day < 32 : true;
|
|
24
23
|
|
|
@@ -75,7 +74,13 @@ const NumeralDate = ({
|
|
|
75
74
|
const isControlled = useRef(value !== undefined);
|
|
76
75
|
const initialValue = isControlled.current ? value : defaultValue;
|
|
77
76
|
const refs = useRef(dateFormat.map(() => /*#__PURE__*/React.createRef()));
|
|
78
|
-
const [internalMessages, setInternalMessages] = useState({
|
|
77
|
+
const [internalMessages, setInternalMessages] = useState({ ...Object.fromEntries(dateFormat.map(datePart => [datePart, ""]))
|
|
78
|
+
});
|
|
79
|
+
const hasCorrectDateFormat = useMemo(() => {
|
|
80
|
+
const isAllowed = !dateFormat || ALLOWED_DATE_FORMATS.find(allowedDateFormat => JSON.stringify(allowedDateFormat) === JSON.stringify(dateFormat));
|
|
81
|
+
return isAllowed;
|
|
82
|
+
}, [dateFormat]);
|
|
83
|
+
!hasCorrectDateFormat ? process.env.NODE_ENV !== "production" ? invariant(false, incorrectDateFormatMessage) : invariant(false) : void 0;
|
|
79
84
|
useEffect(() => {
|
|
80
85
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
81
86
|
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
|
|
@@ -85,10 +90,7 @@ const NumeralDate = ({
|
|
|
85
90
|
mm: l.numeralDate.validation.month(),
|
|
86
91
|
yyyy: l.numeralDate.validation.year()
|
|
87
92
|
};
|
|
88
|
-
const [dateValue, setDateValue] = useState({ ...(initialValue || dateFormat.
|
|
89
|
-
dateObject[key] = "";
|
|
90
|
-
return dateObject;
|
|
91
|
-
}, {}))
|
|
93
|
+
const [dateValue, setDateValue] = useState({ ...(initialValue || Object.fromEntries(dateFormat.map(datePart => [datePart, ""])))
|
|
92
94
|
});
|
|
93
95
|
|
|
94
96
|
const createCustomEventObject = newValue => ({
|
|
@@ -99,18 +101,18 @@ const NumeralDate = ({
|
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
|
|
102
|
-
const onKeyPress =
|
|
103
|
-
const isValidKey = Events.isNumberKey(
|
|
104
|
+
const onKeyPress = event => {
|
|
105
|
+
const isValidKey = Events.isNumberKey(event) || Events.isTabKey(event) || event.key === "Delete" || event.key === "Backspace";
|
|
104
106
|
|
|
105
107
|
if (!isValidKey) {
|
|
106
|
-
|
|
108
|
+
event.preventDefault();
|
|
107
109
|
}
|
|
108
110
|
};
|
|
109
111
|
|
|
110
|
-
const handleChange = (
|
|
112
|
+
const handleChange = (event, datePart) => {
|
|
111
113
|
const {
|
|
112
114
|
value: newValue
|
|
113
|
-
} =
|
|
115
|
+
} = event.target;
|
|
114
116
|
|
|
115
117
|
if (newValue.length <= datePart.length) {
|
|
116
118
|
const newDateValue = { ...dateValue,
|
|
@@ -129,8 +131,9 @@ const NumeralDate = ({
|
|
|
129
131
|
const internalValidationEnabled = enableInternalError || enableInternalWarning;
|
|
130
132
|
/* istanbul ignore else */
|
|
131
133
|
|
|
132
|
-
if (
|
|
133
|
-
const
|
|
134
|
+
if (internalValidationEnabled) {
|
|
135
|
+
const newDatePart = dateValue[datePart];
|
|
136
|
+
const errorMessage = validations[datePart](newDatePart) ? "" : validationMessages[datePart];
|
|
134
137
|
setInternalMessages(prev => ({ ...prev,
|
|
135
138
|
[datePart]: errorMessage
|
|
136
139
|
}));
|
|
@@ -146,7 +149,7 @@ const NumeralDate = ({
|
|
|
146
149
|
}, 5);
|
|
147
150
|
};
|
|
148
151
|
|
|
149
|
-
const internalMessage = Object.keys(internalMessages).reduce((
|
|
152
|
+
const internalMessage = Object.keys(internalMessages).reduce((combinedMessage, datePart) => internalMessages[datePart] ? `${combinedMessage + internalMessages[datePart]}\n` : combinedMessage, "");
|
|
150
153
|
const internalError = enableInternalError ? internalMessage + error : error;
|
|
151
154
|
const internalWarning = enableInternalWarning ? internalMessage + warning : warning;
|
|
152
155
|
return /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
@@ -183,7 +186,7 @@ const NumeralDate = ({
|
|
|
183
186
|
const isMiddle = index === 1;
|
|
184
187
|
const validation = error || warning || info;
|
|
185
188
|
const isStringValidation = typeof validation === "string";
|
|
186
|
-
const hasValidationIcon = isStringValidation && validation.length;
|
|
189
|
+
const hasValidationIcon = isStringValidation && !!validation.length;
|
|
187
190
|
return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
|
|
188
191
|
value: {
|
|
189
192
|
disableErrorBorder: index !== 0
|
|
@@ -224,118 +227,224 @@ const NumeralDate = ({
|
|
|
224
227
|
};
|
|
225
228
|
|
|
226
229
|
NumeralDate.propTypes = {
|
|
227
|
-
|
|
228
|
-
...marginPropTypes,
|
|
229
|
-
|
|
230
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
230
|
+
"adaptiveLabelBreakpoint": PropTypes.number,
|
|
231
231
|
"data-component": PropTypes.string,
|
|
232
|
-
|
|
233
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
234
232
|
"data-element": PropTypes.string,
|
|
235
|
-
|
|
236
|
-
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
237
233
|
"data-role": PropTypes.string,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
234
|
+
"dateFormat": PropTypes.shape({
|
|
235
|
+
"__@iterator": PropTypes.func.isRequired,
|
|
236
|
+
"0": PropTypes.oneOf(["dd"]).isRequired,
|
|
237
|
+
"1": PropTypes.oneOf(["mm"]).isRequired,
|
|
238
|
+
"2": PropTypes.oneOf(["yyyy"]).isRequired,
|
|
239
|
+
"concat": PropTypes.func.isRequired,
|
|
240
|
+
"entries": PropTypes.func.isRequired,
|
|
241
|
+
"every": PropTypes.func.isRequired,
|
|
242
|
+
"filter": PropTypes.func.isRequired,
|
|
243
|
+
"find": PropTypes.func.isRequired,
|
|
244
|
+
"findIndex": PropTypes.func.isRequired,
|
|
245
|
+
"flat": PropTypes.func.isRequired,
|
|
246
|
+
"flatMap": PropTypes.func.isRequired,
|
|
247
|
+
"forEach": PropTypes.func.isRequired,
|
|
248
|
+
"includes": PropTypes.func.isRequired,
|
|
249
|
+
"indexOf": PropTypes.func.isRequired,
|
|
250
|
+
"join": PropTypes.func.isRequired,
|
|
251
|
+
"keys": PropTypes.func.isRequired,
|
|
252
|
+
"lastIndexOf": PropTypes.func.isRequired,
|
|
253
|
+
"length": PropTypes.oneOf([3]).isRequired,
|
|
254
|
+
"map": PropTypes.func.isRequired,
|
|
255
|
+
"reduce": PropTypes.func.isRequired,
|
|
256
|
+
"reduceRight": PropTypes.func.isRequired,
|
|
257
|
+
"slice": PropTypes.func.isRequired,
|
|
258
|
+
"some": PropTypes.func.isRequired,
|
|
259
|
+
"toLocaleString": PropTypes.func.isRequired,
|
|
260
|
+
"toString": PropTypes.func.isRequired,
|
|
261
|
+
"values": PropTypes.func.isRequired
|
|
262
|
+
}),
|
|
263
|
+
"defaultValue": PropTypes.shape({
|
|
264
|
+
"dd": PropTypes.string.isRequired,
|
|
265
|
+
"mm": PropTypes.string.isRequired
|
|
266
|
+
}),
|
|
267
|
+
"disabled": PropTypes.bool,
|
|
268
|
+
"enableInternalError": PropTypes.bool,
|
|
269
|
+
"enableInternalWarning": PropTypes.bool,
|
|
270
|
+
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
271
|
+
"fieldHelp": PropTypes.node,
|
|
272
|
+
"helpAriaLabel": PropTypes.string,
|
|
273
|
+
"id": PropTypes.string,
|
|
274
|
+
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
275
|
+
"label": PropTypes.string,
|
|
276
|
+
"labelAlign": PropTypes.oneOf(["left", "right"]),
|
|
277
|
+
"labelHelp": PropTypes.node,
|
|
278
|
+
"labelInline": PropTypes.bool,
|
|
279
|
+
"labelSpacing": PropTypes.oneOf([1, 2]),
|
|
280
|
+
"labelWidth": PropTypes.number,
|
|
281
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
282
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
283
|
+
"description": PropTypes.string,
|
|
284
|
+
"toString": PropTypes.func.isRequired,
|
|
285
|
+
"valueOf": PropTypes.func.isRequired
|
|
286
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
287
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
288
|
+
"description": PropTypes.string,
|
|
289
|
+
"toString": PropTypes.func.isRequired,
|
|
290
|
+
"valueOf": PropTypes.func.isRequired
|
|
291
|
+
}), PropTypes.string]),
|
|
292
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
293
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
294
|
+
"description": PropTypes.string,
|
|
295
|
+
"toString": PropTypes.func.isRequired,
|
|
296
|
+
"valueOf": PropTypes.func.isRequired
|
|
297
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
298
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
299
|
+
"description": PropTypes.string,
|
|
300
|
+
"toString": PropTypes.func.isRequired,
|
|
301
|
+
"valueOf": PropTypes.func.isRequired
|
|
302
|
+
}), PropTypes.string]),
|
|
303
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
304
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
305
|
+
"description": PropTypes.string,
|
|
306
|
+
"toString": PropTypes.func.isRequired,
|
|
307
|
+
"valueOf": PropTypes.func.isRequired
|
|
308
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
309
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
310
|
+
"description": PropTypes.string,
|
|
311
|
+
"toString": PropTypes.func.isRequired,
|
|
312
|
+
"valueOf": PropTypes.func.isRequired
|
|
313
|
+
}), PropTypes.string]),
|
|
314
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
315
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
316
|
+
"description": PropTypes.string,
|
|
317
|
+
"toString": PropTypes.func.isRequired,
|
|
318
|
+
"valueOf": PropTypes.func.isRequired
|
|
319
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
320
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
321
|
+
"description": PropTypes.string,
|
|
322
|
+
"toString": PropTypes.func.isRequired,
|
|
323
|
+
"valueOf": PropTypes.func.isRequired
|
|
324
|
+
}), PropTypes.string]),
|
|
325
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
326
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
327
|
+
"description": PropTypes.string,
|
|
328
|
+
"toString": PropTypes.func.isRequired,
|
|
329
|
+
"valueOf": PropTypes.func.isRequired
|
|
330
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
331
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
332
|
+
"description": PropTypes.string,
|
|
333
|
+
"toString": PropTypes.func.isRequired,
|
|
334
|
+
"valueOf": PropTypes.func.isRequired
|
|
335
|
+
}), PropTypes.string]),
|
|
336
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
337
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
338
|
+
"description": PropTypes.string,
|
|
339
|
+
"toString": PropTypes.func.isRequired,
|
|
340
|
+
"valueOf": PropTypes.func.isRequired
|
|
341
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
342
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
343
|
+
"description": PropTypes.string,
|
|
344
|
+
"toString": PropTypes.func.isRequired,
|
|
345
|
+
"valueOf": PropTypes.func.isRequired
|
|
346
|
+
}), PropTypes.string]),
|
|
347
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
348
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
349
|
+
"description": PropTypes.string,
|
|
350
|
+
"toString": PropTypes.func.isRequired,
|
|
351
|
+
"valueOf": PropTypes.func.isRequired
|
|
352
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
353
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
354
|
+
"description": PropTypes.string,
|
|
355
|
+
"toString": PropTypes.func.isRequired,
|
|
356
|
+
"valueOf": PropTypes.func.isRequired
|
|
357
|
+
}), PropTypes.string]),
|
|
358
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
359
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
360
|
+
"description": PropTypes.string,
|
|
361
|
+
"toString": PropTypes.func.isRequired,
|
|
362
|
+
"valueOf": PropTypes.func.isRequired
|
|
363
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
364
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
365
|
+
"description": PropTypes.string,
|
|
366
|
+
"toString": PropTypes.func.isRequired,
|
|
367
|
+
"valueOf": PropTypes.func.isRequired
|
|
368
|
+
}), PropTypes.string]),
|
|
369
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
370
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
371
|
+
"description": PropTypes.string,
|
|
372
|
+
"toString": PropTypes.func.isRequired,
|
|
373
|
+
"valueOf": PropTypes.func.isRequired
|
|
374
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
375
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
376
|
+
"description": PropTypes.string,
|
|
377
|
+
"toString": PropTypes.func.isRequired,
|
|
378
|
+
"valueOf": PropTypes.func.isRequired
|
|
379
|
+
}), PropTypes.string]),
|
|
380
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
381
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
382
|
+
"description": PropTypes.string,
|
|
383
|
+
"toString": PropTypes.func.isRequired,
|
|
384
|
+
"valueOf": PropTypes.func.isRequired
|
|
385
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
386
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
387
|
+
"description": PropTypes.string,
|
|
388
|
+
"toString": PropTypes.func.isRequired,
|
|
389
|
+
"valueOf": PropTypes.func.isRequired
|
|
390
|
+
}), PropTypes.string]),
|
|
391
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
392
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
393
|
+
"description": PropTypes.string,
|
|
394
|
+
"toString": PropTypes.func.isRequired,
|
|
395
|
+
"valueOf": PropTypes.func.isRequired
|
|
396
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
397
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
398
|
+
"description": PropTypes.string,
|
|
399
|
+
"toString": PropTypes.func.isRequired,
|
|
400
|
+
"valueOf": PropTypes.func.isRequired
|
|
401
|
+
}), PropTypes.string]),
|
|
402
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
403
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
404
|
+
"description": PropTypes.string,
|
|
405
|
+
"toString": PropTypes.func.isRequired,
|
|
406
|
+
"valueOf": PropTypes.func.isRequired
|
|
407
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
408
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
409
|
+
"description": PropTypes.string,
|
|
410
|
+
"toString": PropTypes.func.isRequired,
|
|
411
|
+
"valueOf": PropTypes.func.isRequired
|
|
412
|
+
}), PropTypes.string]),
|
|
413
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
414
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
415
|
+
"description": PropTypes.string,
|
|
416
|
+
"toString": PropTypes.func.isRequired,
|
|
417
|
+
"valueOf": PropTypes.func.isRequired
|
|
418
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
419
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
420
|
+
"description": PropTypes.string,
|
|
421
|
+
"toString": PropTypes.func.isRequired,
|
|
422
|
+
"valueOf": PropTypes.func.isRequired
|
|
423
|
+
}), PropTypes.string]),
|
|
424
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
425
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
426
|
+
"description": PropTypes.string,
|
|
427
|
+
"toString": PropTypes.func.isRequired,
|
|
428
|
+
"valueOf": PropTypes.func.isRequired
|
|
429
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
430
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
431
|
+
"description": PropTypes.string,
|
|
432
|
+
"toString": PropTypes.func.isRequired,
|
|
433
|
+
"valueOf": PropTypes.func.isRequired
|
|
434
|
+
}), PropTypes.string]),
|
|
435
|
+
"name": PropTypes.string,
|
|
436
|
+
"onBlur": PropTypes.func,
|
|
437
|
+
"onChange": PropTypes.func,
|
|
438
|
+
"readOnly": PropTypes.bool,
|
|
439
|
+
"required": PropTypes.bool,
|
|
440
|
+
"size": PropTypes.oneOf(["large", "medium", "small"]),
|
|
441
|
+
"tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
|
|
442
|
+
"validationOnLabel": PropTypes.bool,
|
|
443
|
+
"value": PropTypes.shape({
|
|
444
|
+
"dd": PropTypes.string.isRequired,
|
|
445
|
+
"mm": PropTypes.string.isRequired
|
|
446
|
+
}),
|
|
447
|
+
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
340
448
|
};
|
|
449
|
+
export { NumeralDate };
|
|
341
450
|
export default NumeralDate;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface StyledDateFieldProps {
|
|
2
|
+
isEnd?: boolean;
|
|
3
|
+
isMiddle?: boolean;
|
|
4
|
+
isYearInput?: boolean;
|
|
5
|
+
hasValidationIcon?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const StyledNumeralDate: import("styled-components").StyledComponent<"div", any, {
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const StyledDateField: import("styled-components").StyledComponent<"div", any, StyledDateFieldProps, never>;
|
|
11
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { PaddingProps } from "styled-system";
|
|
2
|
+
import { PaddingProps, WidthProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
4
|
declare type CustomRefObject<T> = {
|
|
5
5
|
current?: T | null;
|
|
@@ -8,7 +8,7 @@ export interface SidebarContextProps {
|
|
|
8
8
|
isInSidebar?: boolean;
|
|
9
9
|
}
|
|
10
10
|
export declare const SidebarContext: React.Context<SidebarContextProps>;
|
|
11
|
-
export interface SidebarProps extends PaddingProps, TagProps {
|
|
11
|
+
export interface SidebarProps extends PaddingProps, TagProps, WidthProps {
|
|
12
12
|
/** Prop to specify the aria-describedby property of the component */
|
|
13
13
|
"aria-describedby"?: string;
|
|
14
14
|
/**
|
|
@@ -31,6 +31,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
31
31
|
role = "dialog",
|
|
32
32
|
focusableContainers,
|
|
33
33
|
focusableSelectors,
|
|
34
|
+
width,
|
|
34
35
|
...rest
|
|
35
36
|
}, ref) => {
|
|
36
37
|
const locale = useLocale();
|
|
@@ -76,7 +77,9 @@ const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
76
77
|
"data-element": "sidebar",
|
|
77
78
|
onCancel: onCancel,
|
|
78
79
|
role: role
|
|
79
|
-
}, filterStyledSystemPaddingProps(rest)
|
|
80
|
+
}, filterStyledSystemPaddingProps(rest), {
|
|
81
|
+
width: width
|
|
82
|
+
}), header && /*#__PURE__*/React.createElement(SidebarHeader, {
|
|
80
83
|
id: headerId
|
|
81
84
|
}, header), closeIcon(), /*#__PURE__*/React.createElement(Box, _extends({
|
|
82
85
|
"data-element": "sidebar-content",
|
|
@@ -283,7 +286,108 @@ Sidebar.propTypes = {
|
|
|
283
286
|
"valueOf": PropTypes.func.isRequired
|
|
284
287
|
}), PropTypes.string]),
|
|
285
288
|
"role": PropTypes.string,
|
|
286
|
-
"size": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"])
|
|
289
|
+
"size": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "small"]),
|
|
290
|
+
"width": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
291
|
+
"__@iterator": PropTypes.func.isRequired,
|
|
292
|
+
"anchor": PropTypes.func.isRequired,
|
|
293
|
+
"at": PropTypes.func.isRequired,
|
|
294
|
+
"big": PropTypes.func.isRequired,
|
|
295
|
+
"blink": PropTypes.func.isRequired,
|
|
296
|
+
"bold": PropTypes.func.isRequired,
|
|
297
|
+
"charAt": PropTypes.func.isRequired,
|
|
298
|
+
"charCodeAt": PropTypes.func.isRequired,
|
|
299
|
+
"codePointAt": PropTypes.func.isRequired,
|
|
300
|
+
"concat": PropTypes.func.isRequired,
|
|
301
|
+
"endsWith": PropTypes.func.isRequired,
|
|
302
|
+
"fixed": PropTypes.func.isRequired,
|
|
303
|
+
"fontcolor": PropTypes.func.isRequired,
|
|
304
|
+
"fontsize": PropTypes.func.isRequired,
|
|
305
|
+
"includes": PropTypes.func.isRequired,
|
|
306
|
+
"indexOf": PropTypes.func.isRequired,
|
|
307
|
+
"italics": PropTypes.func.isRequired,
|
|
308
|
+
"lastIndexOf": PropTypes.func.isRequired,
|
|
309
|
+
"length": PropTypes.number.isRequired,
|
|
310
|
+
"link": PropTypes.func.isRequired,
|
|
311
|
+
"localeCompare": PropTypes.func.isRequired,
|
|
312
|
+
"match": PropTypes.func.isRequired,
|
|
313
|
+
"matchAll": PropTypes.func.isRequired,
|
|
314
|
+
"normalize": PropTypes.func.isRequired,
|
|
315
|
+
"padEnd": PropTypes.func.isRequired,
|
|
316
|
+
"padStart": PropTypes.func.isRequired,
|
|
317
|
+
"repeat": PropTypes.func.isRequired,
|
|
318
|
+
"replace": PropTypes.func.isRequired,
|
|
319
|
+
"search": PropTypes.func.isRequired,
|
|
320
|
+
"slice": PropTypes.func.isRequired,
|
|
321
|
+
"small": PropTypes.func.isRequired,
|
|
322
|
+
"split": PropTypes.func.isRequired,
|
|
323
|
+
"startsWith": PropTypes.func.isRequired,
|
|
324
|
+
"strike": PropTypes.func.isRequired,
|
|
325
|
+
"sub": PropTypes.func.isRequired,
|
|
326
|
+
"substr": PropTypes.func.isRequired,
|
|
327
|
+
"substring": PropTypes.func.isRequired,
|
|
328
|
+
"sup": PropTypes.func.isRequired,
|
|
329
|
+
"toLocaleLowerCase": PropTypes.func.isRequired,
|
|
330
|
+
"toLocaleUpperCase": PropTypes.func.isRequired,
|
|
331
|
+
"toLowerCase": PropTypes.func.isRequired,
|
|
332
|
+
"toString": PropTypes.func.isRequired,
|
|
333
|
+
"toUpperCase": PropTypes.func.isRequired,
|
|
334
|
+
"trim": PropTypes.func.isRequired,
|
|
335
|
+
"trimEnd": PropTypes.func.isRequired,
|
|
336
|
+
"trimLeft": PropTypes.func.isRequired,
|
|
337
|
+
"trimRight": PropTypes.func.isRequired,
|
|
338
|
+
"trimStart": PropTypes.func.isRequired,
|
|
339
|
+
"valueOf": PropTypes.func.isRequired
|
|
340
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
341
|
+
"__@iterator": PropTypes.func.isRequired,
|
|
342
|
+
"anchor": PropTypes.func.isRequired,
|
|
343
|
+
"at": PropTypes.func.isRequired,
|
|
344
|
+
"big": PropTypes.func.isRequired,
|
|
345
|
+
"blink": PropTypes.func.isRequired,
|
|
346
|
+
"bold": PropTypes.func.isRequired,
|
|
347
|
+
"charAt": PropTypes.func.isRequired,
|
|
348
|
+
"charCodeAt": PropTypes.func.isRequired,
|
|
349
|
+
"codePointAt": PropTypes.func.isRequired,
|
|
350
|
+
"concat": PropTypes.func.isRequired,
|
|
351
|
+
"endsWith": PropTypes.func.isRequired,
|
|
352
|
+
"fixed": PropTypes.func.isRequired,
|
|
353
|
+
"fontcolor": PropTypes.func.isRequired,
|
|
354
|
+
"fontsize": PropTypes.func.isRequired,
|
|
355
|
+
"includes": PropTypes.func.isRequired,
|
|
356
|
+
"indexOf": PropTypes.func.isRequired,
|
|
357
|
+
"italics": PropTypes.func.isRequired,
|
|
358
|
+
"lastIndexOf": PropTypes.func.isRequired,
|
|
359
|
+
"length": PropTypes.number.isRequired,
|
|
360
|
+
"link": PropTypes.func.isRequired,
|
|
361
|
+
"localeCompare": PropTypes.func.isRequired,
|
|
362
|
+
"match": PropTypes.func.isRequired,
|
|
363
|
+
"matchAll": PropTypes.func.isRequired,
|
|
364
|
+
"normalize": PropTypes.func.isRequired,
|
|
365
|
+
"padEnd": PropTypes.func.isRequired,
|
|
366
|
+
"padStart": PropTypes.func.isRequired,
|
|
367
|
+
"repeat": PropTypes.func.isRequired,
|
|
368
|
+
"replace": PropTypes.func.isRequired,
|
|
369
|
+
"search": PropTypes.func.isRequired,
|
|
370
|
+
"slice": PropTypes.func.isRequired,
|
|
371
|
+
"small": PropTypes.func.isRequired,
|
|
372
|
+
"split": PropTypes.func.isRequired,
|
|
373
|
+
"startsWith": PropTypes.func.isRequired,
|
|
374
|
+
"strike": PropTypes.func.isRequired,
|
|
375
|
+
"sub": PropTypes.func.isRequired,
|
|
376
|
+
"substr": PropTypes.func.isRequired,
|
|
377
|
+
"substring": PropTypes.func.isRequired,
|
|
378
|
+
"sup": PropTypes.func.isRequired,
|
|
379
|
+
"toLocaleLowerCase": PropTypes.func.isRequired,
|
|
380
|
+
"toLocaleUpperCase": PropTypes.func.isRequired,
|
|
381
|
+
"toLowerCase": PropTypes.func.isRequired,
|
|
382
|
+
"toString": PropTypes.func.isRequired,
|
|
383
|
+
"toUpperCase": PropTypes.func.isRequired,
|
|
384
|
+
"trim": PropTypes.func.isRequired,
|
|
385
|
+
"trimEnd": PropTypes.func.isRequired,
|
|
386
|
+
"trimLeft": PropTypes.func.isRequired,
|
|
387
|
+
"trimRight": PropTypes.func.isRequired,
|
|
388
|
+
"trimStart": PropTypes.func.isRequired,
|
|
389
|
+
"valueOf": PropTypes.func.isRequired
|
|
390
|
+
}), PropTypes.string])
|
|
287
391
|
};
|
|
288
392
|
export { Sidebar };
|
|
289
393
|
Sidebar.displayName = "Sidebar";
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
2
|
import { SidebarProps } from "./sidebar.component";
|
|
3
|
-
declare
|
|
4
|
-
onCancel?: SidebarProps["onCancel"];
|
|
5
|
-
position?: SidebarProps["position"];
|
|
6
|
-
size?: SidebarProps["size"];
|
|
7
|
-
};
|
|
8
|
-
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, StyledSidebarProps & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
3
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<"div", any, Pick<SidebarProps, "width" | "onCancel" | "size" | "position"> & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>>, never>;
|
|
9
4
|
export default StyledSidebar;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
+
import computeWidth from "../../style/utils/width";
|
|
2
3
|
import baseTheme from "../../style/themes/base";
|
|
3
4
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
4
5
|
import { calculateFormSpacingValues, calculateWidthValue } from "../../style/utils/form-style-utils";
|
|
@@ -23,7 +24,8 @@ const StyledSidebar = styled.div`
|
|
|
23
24
|
onCancel,
|
|
24
25
|
position,
|
|
25
26
|
size,
|
|
26
|
-
theme
|
|
27
|
+
theme,
|
|
28
|
+
width
|
|
27
29
|
}) => css`
|
|
28
30
|
background: var(--colorsUtilityMajor025);
|
|
29
31
|
border-radius: 1px;
|
|
@@ -34,9 +36,12 @@ const StyledSidebar = styled.div`
|
|
|
34
36
|
top: 0;
|
|
35
37
|
z-index: ${theme.zIndex.fullScreenModal};
|
|
36
38
|
|
|
37
|
-
${size && css`
|
|
39
|
+
${!width && size && css`
|
|
38
40
|
width: ${SIDEBAR_SIZES_CSS[size]};
|
|
39
41
|
`}
|
|
42
|
+
${width && computeWidth({
|
|
43
|
+
width
|
|
44
|
+
})}
|
|
40
45
|
|
|
41
46
|
${position && css`
|
|
42
47
|
box-shadow: var(--boxShadow300);
|