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.
Files changed (59) hide show
  1. package/esm/components/note/__internal__/status-icon/index.d.ts +1 -0
  2. package/esm/components/note/__internal__/status-icon/index.js +1 -0
  3. package/esm/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
  4. package/esm/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +4 -6
  5. package/esm/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
  6. package/esm/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
  7. package/esm/components/note/index.d.ts +2 -2
  8. package/esm/components/note/note.component.d.ts +28 -0
  9. package/esm/components/note/note.component.js +188 -46
  10. package/esm/components/note/note.style.d.ts +13 -0
  11. package/esm/components/note/note.style.js +0 -5
  12. package/esm/components/numeral-date/index.d.ts +2 -1
  13. package/esm/components/numeral-date/numeral-date.component.d.ts +81 -0
  14. package/esm/components/numeral-date/numeral-date.component.js +237 -128
  15. package/esm/components/numeral-date/numeral-date.style.d.ts +11 -0
  16. package/esm/components/sidebar/sidebar.component.d.ts +2 -2
  17. package/esm/components/sidebar/sidebar.component.js +106 -2
  18. package/esm/components/sidebar/sidebar.style.d.ts +1 -6
  19. package/esm/components/sidebar/sidebar.style.js +7 -2
  20. package/esm/components/text-editor/__internal__/decorators/index.d.ts +3 -0
  21. package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
  22. package/esm/components/text-editor/__internal__/utils/index.d.ts +1 -0
  23. package/esm/components/text-editor/__internal__/utils/utils.d.ts +28 -0
  24. package/esm/components/text-editor/text-editor.component.d.ts +8 -0
  25. package/esm/components/text-editor/text-editor.style.d.ts +3 -0
  26. package/esm/style/utils/width.d.ts +1 -1
  27. package/lib/components/note/__internal__/status-icon/index.d.ts +1 -0
  28. package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/index.js +2 -2
  29. package/lib/components/note/__internal__/{status-with-tooltip → status-icon}/package.json +1 -1
  30. package/lib/components/note/__internal__/status-icon/status-icon.component.d.ts +9 -0
  31. package/lib/components/note/__internal__/{status-with-tooltip/status.component.js → status-icon/status-icon.component.js} +5 -7
  32. package/lib/components/note/__internal__/status-icon/status-icon.style.d.ts +2 -0
  33. package/lib/components/note/__internal__/{status-with-tooltip/status.style.js → status-icon/status-icon.style.js} +0 -0
  34. package/lib/components/note/index.d.ts +2 -2
  35. package/lib/components/note/note.component.d.ts +28 -0
  36. package/lib/components/note/note.component.js +195 -55
  37. package/lib/components/note/note.style.d.ts +13 -0
  38. package/lib/components/note/note.style.js +0 -6
  39. package/lib/components/numeral-date/index.d.ts +2 -1
  40. package/lib/components/numeral-date/numeral-date.component.d.ts +81 -0
  41. package/lib/components/numeral-date/numeral-date.component.js +237 -128
  42. package/lib/components/numeral-date/numeral-date.style.d.ts +11 -0
  43. package/lib/components/sidebar/sidebar.component.d.ts +2 -2
  44. package/lib/components/sidebar/sidebar.component.js +106 -2
  45. package/lib/components/sidebar/sidebar.style.d.ts +1 -6
  46. package/lib/components/sidebar/sidebar.style.js +8 -2
  47. package/lib/components/text-editor/__internal__/decorators/index.d.ts +3 -0
  48. package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +7 -0
  49. package/lib/components/text-editor/__internal__/utils/index.d.ts +1 -0
  50. package/lib/components/text-editor/__internal__/utils/utils.d.ts +28 -0
  51. package/lib/components/text-editor/text-editor.component.d.ts +8 -0
  52. package/lib/components/text-editor/text-editor.style.d.ts +3 -0
  53. package/lib/style/utils/width.d.ts +1 -1
  54. package/package.json +3 -2
  55. package/esm/components/note/__internal__/status-with-tooltip/index.js +0 -1
  56. package/esm/components/note/note.d.ts +0 -30
  57. package/esm/components/numeral-date/numeral-date.d.ts +0 -97
  58. package/lib/components/note/note.d.ts +0 -30
  59. 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 marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
21
- const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
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.reduce((dateObject, key) => {
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 = ev => {
103
- const isValidKey = Events.isNumberKey(ev) || Events.isTabKey(ev) || ev.key === "Delete" || ev.key === "Backspace";
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
- ev.preventDefault();
108
+ event.preventDefault();
107
109
  }
108
110
  };
109
111
 
110
- const handleChange = (e, datePart) => {
112
+ const handleChange = (event, datePart) => {
111
113
  const {
112
114
  value: newValue
113
- } = e.target;
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 (validations[datePart] && internalValidationEnabled) {
133
- const errorMessage = validations[datePart](dateValue[datePart]) ? "" : validationMessages[datePart];
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((string, key) => internalMessages[key] ? `${string + internalMessages[key]}\n` : string, "");
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
- /** Filtered styled system margin props */
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
- /** If true, the component will be disabled */
240
- disabled: PropTypes.bool,
241
-
242
- /** If true, the component will be read-only */
243
- readOnly: PropTypes.bool,
244
-
245
- /** Array of strings to define custom input layout.
246
- Allowed formats:
247
- ['dd', 'mm', 'yyyy'],
248
- ['mm', 'dd', 'yyyy'],
249
- ['dd', 'mm'],
250
- ['mm', 'dd'],
251
- ['mm', 'yyyy'] */
252
- dateFormat: (props, propName, componentName) => {
253
- const dateFormat = props[propName];
254
- const isAllowed = !dateFormat || ALLOWED_DATE_FORMATS.find(allowedDateFormat => JSON.stringify(allowedDateFormat) === JSON.stringify(dateFormat));
255
-
256
- if (!isAllowed) {
257
- return new Error(`Forbidden prop \`${propName}\` supplied to \`${componentName}\`. ` + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']");
258
- }
259
-
260
- return null;
261
- },
262
-
263
- /** Default value for use in uncontrolled mode */
264
- defaultValue: PropTypes.object,
265
-
266
- /** Value for use in controlled mode */
267
- value: PropTypes.object,
268
-
269
- /** Indicate that error has occurred
270
- Pass string to display icon, tooltip and red border
271
- Pass true boolean to only display red border */
272
- error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
273
-
274
- /** Indicate that warning has occurred
275
- Pass string to display icon, tooltip and orange border
276
- Pass true boolean to only display orange border */
277
- warning: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
278
-
279
- /** Indicate additional information
280
- Pass string to display icon, tooltip and blue border
281
- Pass true boolean to only display blue border */
282
- info: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
283
-
284
- /** Blur event handler */
285
- onBlur: PropTypes.func,
286
-
287
- /** Change event handler */
288
- onChange: PropTypes.func,
289
-
290
- /** `id` for events */
291
- id: PropTypes.string,
292
-
293
- /** `name` for events */
294
- name: PropTypes.string,
295
-
296
- /** When true, validation icon will be placed on label instead of being placed on the input */
297
- validationOnLabel: PropTypes.bool,
298
-
299
- /** When true, enables the internal errors to be displayed */
300
- enableInternalError: PropTypes.bool,
301
-
302
- /** When true, enables the internal warnings to be displayed */
303
- enableInternalWarning: PropTypes.bool,
304
-
305
- /** Label */
306
- label: PropTypes.string,
307
-
308
- /** Text applied to label help tooltip */
309
- labelHelp: PropTypes.node,
310
-
311
- /** When true, label is placed in line with an input */
312
- labelInline: PropTypes.bool,
313
-
314
- /** Label alignment. Works only when labelInline is true */
315
- labelAlign: PropTypes.oneOf(["left", "right"]),
316
-
317
- /** Width of a label in percentage. Works only when labelInline is true */
318
- labelWidth: PropTypes.number,
319
-
320
- /** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
321
- labelSpacing: PropTypes.oneOf([1, 2]),
322
-
323
- /** Help content to be displayed under an input */
324
- fieldHelp: PropTypes.node,
325
-
326
- /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
327
- adaptiveLabelBreakpoint: PropTypes.number,
328
-
329
- /** Flag to configure component as mandatory */
330
- required: PropTypes.bool,
331
-
332
- /** Size of an input */
333
- size: PropTypes.oneOf(["small", "medium", "large"]),
334
-
335
- /** Overrides the default tooltip position */
336
- tooltipPosition: PropTypes.oneOf(["top", "bottom", "left", "right"]),
337
-
338
- /** Aria label for rendered help component */
339
- helpAriaLabel: PropTypes.string
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)), header && /*#__PURE__*/React.createElement(SidebarHeader, {
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 type StyledSidebarProps = {
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);
@@ -0,0 +1,3 @@
1
+ declare var _default: CompositeDecorator;
2
+ export default _default;
3
+ import { CompositeDecorator } from "draft-js";