carbon-react 114.0.0 → 114.2.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 (65) hide show
  1. package/esm/__internal__/utils/helpers/events/events.d.ts +5 -0
  2. package/esm/__internal__/utils/helpers/events/events.js +7 -0
  3. package/esm/__spec_helper__/mock-match-media.d.ts +4 -7
  4. package/esm/__spec_helper__/mock-match-media.js +4 -4
  5. package/esm/components/i18n-provider/i18n-provider.component.js +3 -0
  6. package/esm/components/inline-inputs/inline-inputs.component.d.ts +3 -1
  7. package/esm/components/inline-inputs/inline-inputs.component.js +6 -3
  8. package/esm/components/pod/index.d.ts +2 -2
  9. package/esm/components/pod/pod.component.d.ts +47 -0
  10. package/esm/components/pod/pod.component.js +289 -258
  11. package/esm/components/pod/pod.config.d.ts +6 -0
  12. package/esm/components/pod/pod.config.js +2 -2
  13. package/esm/components/pod/pod.style.d.ts +44 -0
  14. package/esm/components/pod/pod.style.js +151 -103
  15. package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
  16. package/esm/components/tile/index.d.ts +2 -1
  17. package/esm/components/tile/tile-footer/index.d.ts +2 -1
  18. package/esm/components/tile/tile-footer/tile-footer.component.d.ts +9 -0
  19. package/esm/components/tile/tile-footer/tile-footer.component.js +160 -8
  20. package/esm/components/tile/tile-footer/tile-footer.style.d.ts +5 -0
  21. package/esm/components/tile/tile.component.d.ts +29 -0
  22. package/esm/components/tile/tile.component.js +330 -44
  23. package/esm/components/tile/tile.config.d.ts +2 -0
  24. package/esm/components/tile/tile.style.d.ts +12 -0
  25. package/esm/components/tile/tile.style.js +13 -21
  26. package/esm/hooks/useMediaQuery/useMediaQuery.js +2 -2
  27. package/esm/locales/en-gb.js +3 -0
  28. package/esm/locales/locale.d.ts +3 -0
  29. package/esm/locales/pl-pl.js +3 -0
  30. package/lib/__internal__/utils/helpers/events/events.d.ts +5 -0
  31. package/lib/__internal__/utils/helpers/events/events.js +7 -0
  32. package/lib/__spec_helper__/mock-match-media.d.ts +4 -7
  33. package/lib/__spec_helper__/mock-match-media.js +4 -4
  34. package/lib/components/i18n-provider/i18n-provider.component.js +3 -0
  35. package/lib/components/inline-inputs/inline-inputs.component.d.ts +3 -1
  36. package/lib/components/inline-inputs/inline-inputs.component.js +6 -3
  37. package/lib/components/pod/index.d.ts +2 -2
  38. package/lib/components/pod/pod.component.d.ts +47 -0
  39. package/lib/components/pod/pod.component.js +292 -259
  40. package/lib/components/pod/pod.config.d.ts +6 -0
  41. package/lib/components/pod/pod.config.js +4 -4
  42. package/lib/components/pod/pod.style.d.ts +44 -0
  43. package/lib/components/pod/pod.style.js +153 -106
  44. package/lib/components/show-edit-pod/show-edit-pod.style.js +4 -4
  45. package/lib/components/tile/index.d.ts +2 -1
  46. package/lib/components/tile/tile-footer/index.d.ts +2 -1
  47. package/lib/components/tile/tile-footer/tile-footer.component.d.ts +9 -0
  48. package/lib/components/tile/tile-footer/tile-footer.component.js +157 -11
  49. package/lib/components/tile/tile-footer/tile-footer.style.d.ts +5 -0
  50. package/lib/components/tile/tile.component.d.ts +29 -0
  51. package/lib/components/tile/tile.component.js +329 -46
  52. package/lib/components/tile/tile.config.d.ts +2 -0
  53. package/lib/components/tile/tile.style.d.ts +12 -0
  54. package/lib/components/tile/tile.style.js +13 -22
  55. package/lib/hooks/useMediaQuery/useMediaQuery.js +2 -2
  56. package/lib/locales/en-gb.js +3 -0
  57. package/lib/locales/locale.d.ts +3 -0
  58. package/lib/locales/pl-pl.js +3 -0
  59. package/package.json +6 -16
  60. package/esm/components/pod/pod.d.ts +0 -55
  61. package/esm/components/tile/tile-footer/tile-footer.d.ts +0 -13
  62. package/esm/components/tile/tile.d.ts +0 -46
  63. package/lib/components/pod/pod.d.ts +0 -55
  64. package/lib/components/tile/tile-footer/tile-footer.d.ts +0 -13
  65. package/lib/components/tile/tile.d.ts +0 -46
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  /**
2
3
  * JavaScript Events
3
4
  *
@@ -13,6 +14,10 @@ declare const Events: {
13
14
  * A method to determine if an event is of a particular type
14
15
  * */
15
16
  isEventType: (ev: React.SyntheticEvent | Event, type: string) => boolean;
17
+ /**
18
+ * Determines if event is a keyboard event
19
+ */
20
+ isKeyboardEvent: (ev: React.SyntheticEvent | Event) => ev is React.KeyboardEvent<Element> | KeyboardEvent;
16
21
  /**
17
22
  * Determines if a number key along the top of the keyboard or a number key on the
18
23
  * keypad is pressed
@@ -18,6 +18,13 @@ const Events = {
18
18
  return ev.type === type;
19
19
  },
20
20
 
21
+ /**
22
+ * Determines if event is a keyboard event
23
+ */
24
+ isKeyboardEvent: ev => {
25
+ return ["keydown", "keypress", "keyup"].includes(ev.type);
26
+ },
27
+
21
28
  /**
22
29
  * Determines if a number key along the top of the keyboard or a number key on the
23
30
  * keypad is pressed
@@ -1,8 +1,5 @@
1
- declare function setupMatchMediaMock(): void;
2
- declare function mockMatchMedia(
3
- matches?: boolean
4
- ): {
5
- removeListener: jest.Mock;
1
+ /// <reference types="jest" />
2
+ export declare const setupMatchMediaMock: () => void;
3
+ export declare const mockMatchMedia: (matches: boolean) => {
4
+ removeEventListener: jest.Mock<any, any>;
6
5
  };
7
-
8
- export { setupMatchMediaMock, mockMatchMedia };
@@ -1,6 +1,6 @@
1
1
  let mocked = false;
2
2
  let _matches = false;
3
- const removeListener = jest.fn();
3
+ const removeEventListener = jest.fn();
4
4
  export const setupMatchMediaMock = () => {
5
5
  if (!global.window) {
6
6
  return;
@@ -14,8 +14,8 @@ export const setupMatchMediaMock = () => {
14
14
  matches: _matches,
15
15
  media: query,
16
16
  onchange: null,
17
- addListener: noop,
18
- removeListener,
17
+ addEventListener: noop,
18
+ removeEventListener,
19
19
  dispatchEvent: noop
20
20
  })
21
21
  });
@@ -28,6 +28,6 @@ export const mockMatchMedia = matches => {
28
28
 
29
29
  _matches = matches;
30
30
  return {
31
- removeListener
31
+ removeEventListener
32
32
  };
33
33
  };
@@ -73,6 +73,9 @@ I18nProvider.propTypes = {
73
73
  "records": PropTypes.func.isRequired,
74
74
  "show": PropTypes.func.isRequired
75
75
  }),
76
+ "pod": PropTypes.shape({
77
+ "undo": PropTypes.func.isRequired
78
+ }),
76
79
  "progressTracker": PropTypes.shape({
77
80
  "of": PropTypes.func.isRequired
78
81
  }),
@@ -14,10 +14,12 @@ export interface InlineInputsProps extends StyledContentContainerProps, StyledIn
14
14
  htmlFor?: string;
15
15
  /** Defines the label text for the heading. */
16
16
  label?: string;
17
+ /** Flag to configure component as mandatory. */
18
+ required?: boolean;
17
19
  }
18
20
  export declare const InlineInputsContext: React.Context<InlineInputsContextProps>;
19
21
  declare const InlineInputs: {
20
- ({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, }: InlineInputsProps): JSX.Element;
22
+ ({ adaptiveLabelBreakpoint, label, htmlFor, children, className, gutter, inputWidth, labelInline, labelWidth, required, }: InlineInputsProps): JSX.Element;
21
23
  displayName: string;
22
24
  };
23
25
  export default InlineInputs;
@@ -28,7 +28,8 @@ const InlineInputs = ({
28
28
  gutter = "none",
29
29
  inputWidth,
30
30
  labelInline = true,
31
- labelWidth
31
+ labelWidth,
32
+ required
32
33
  }) => {
33
34
  const labelId = useRef(createGuid());
34
35
  const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
@@ -43,7 +44,8 @@ const InlineInputs = ({
43
44
  return /*#__PURE__*/React.createElement(Label, {
44
45
  labelId: labelId.current,
45
46
  inline: inlineLabel,
46
- htmlFor: htmlFor
47
+ htmlFor: htmlFor,
48
+ isRequired: required
47
49
  }, label);
48
50
  }
49
51
 
@@ -69,7 +71,8 @@ InlineInputs.propTypes = {
69
71
  "inputWidth": PropTypes.number,
70
72
  "label": PropTypes.string,
71
73
  "labelInline": PropTypes.bool,
72
- "labelWidth": PropTypes.number
74
+ "labelWidth": PropTypes.number,
75
+ "required": PropTypes.bool
73
76
  };
74
77
  InlineInputs.displayName = "InlineInputs";
75
78
  export default InlineInputs;
@@ -1,2 +1,2 @@
1
- export { default } from "./pod";
2
- export * from "./pod";
1
+ export { default } from "./pod.component";
2
+ export type { PodProps } from "./pod.component";
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { PodAlignment, PodSize, PodVariant } from "./pod.config";
4
+ export interface PodProps extends MarginProps {
5
+ /** Identifier used for testing purposes, applied to the root element of the component. */
6
+ "data-element"?: string;
7
+ /** Identifier used for testing purposes, applied to the root element of the component. */
8
+ "data-role"?: string;
9
+ /** Aligns the title to left, right or center */
10
+ alignTitle?: PodAlignment;
11
+ /** Enables/disables the border around the pod. */
12
+ border?: boolean;
13
+ /** Children elements */
14
+ children?: React.ReactNode;
15
+ /** Custom className */
16
+ className?: string;
17
+ /** Determines the padding around the pod */
18
+ size?: PodSize;
19
+ /** Prop to apply a theme to the Pod */
20
+ variant?: PodVariant;
21
+ /** Title for the pod h4 element always shown */
22
+ title?: string | React.ReactNode;
23
+ /** Optional subtitle for the pod */
24
+ subtitle?: string;
25
+ /** A component to render as a Pod footer */
26
+ footer?: string | React.ReactNode;
27
+ /** Supplies an edit action to the pod */
28
+ onEdit?: string | Record<string, unknown> | ((ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void);
29
+ /** Supplies a delete action to the pod */
30
+ onDelete?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
31
+ /** Supplies an undo action to the pod in soft delete state. */
32
+ onUndo?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
33
+ /** Sets softboolean; delete state */
34
+ softDelete?: boolean;
35
+ /** Determines if the editable pod content should be full width */
36
+ editContentFullWidth?: boolean;
37
+ /** Determines if the edit button should be hidden until the user hovers over the content */
38
+ displayEditButtonOnHover?: boolean;
39
+ /** Determines if clicking the pod content calls the onEdit action */
40
+ triggerEditOnContent?: boolean;
41
+ /** Sets Pod height, number is changed to pixels and string is passed as raw css value */
42
+ height?: string | number;
43
+ /** Renders edit button inside the pod if it exists. */
44
+ internalEditButton?: boolean;
45
+ }
46
+ declare const Pod: React.ForwardRefExoticComponent<PodProps & React.RefAttributes<HTMLDivElement>>;
47
+ export default Pod;