@dtdot/lego 2.0.0-18 → 2.0.0-19

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.
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { CardSize } from './Card.context';
3
3
  export interface CardProps {
4
- children: React.ReactNode;
5
- size?: CardSize;
6
- padded?: boolean;
7
- onClick?: () => void;
4
+ 'children': React.ReactNode;
5
+ 'size'?: CardSize;
6
+ 'padded'?: boolean;
7
+ 'onClick'?: () => void;
8
+ 'data-testid'?: string;
8
9
  }
9
10
  declare const Card: {
10
- ({ children, padded, size, onClick }: CardProps): JSX.Element;
11
+ ({ children, padded, size, onClick, "data-testid": dataTestId }: CardProps): JSX.Element;
11
12
  ToggleSection: ({ heading, enabled, setEnabled, children, "data-testid": dataTestId, }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
12
13
  Actions: ({ children }: import("./_CardActions.component").CardActionsProps) => React.ReactPortal | null;
13
14
  Action: ({ children, onClick }: import("./_CardActions.component").CardActionProps) => JSX.Element;
@@ -69,7 +69,7 @@ const CardOuter = styled(motion.div) `
69
69
  cursor: ${(props) => (props.usePointer ? 'pointer' : 'default')};
70
70
  padding: ${(props) => (props.padded ? '16px' : 0)};
71
71
  `;
72
- const Card = ({ children, padded, size = 'sm', onClick }) => {
72
+ const Card = ({ children, padded, size = 'sm', onClick, 'data-testid': dataTestId }) => {
73
73
  const actionsRef = useRef(null);
74
74
  const [htmlActionsRef, setHtmlActionsRef] = useState();
75
75
  const [showActions, setShowActions] = useState(false);
@@ -94,7 +94,7 @@ const Card = ({ children, padded, size = 'sm', onClick }) => {
94
94
  scale: 1.005,
95
95
  boxShadow: theme.shadows.xlarge,
96
96
  }
97
- : {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-testid": 'card' },
97
+ : {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-testid": dataTestId || 'card' },
98
98
  React.createElement(CardActionsContainer, { ref: actionsRef }),
99
99
  React.createElement(CardInner, null, children))));
100
100
  };
@@ -4,15 +4,16 @@ import { Status } from '../../theme/theme.types';
4
4
  export type InlineCardSize = 'fill' | 'xs' | 'sm' | 'md' | 'lg';
5
5
  export type DragVariant = Status;
6
6
  export interface InlineCardProps extends React.HTMLAttributes<HTMLDivElement> {
7
- children: React.ReactNode;
8
- size?: InlineCardSize;
9
- value?: string;
10
- gestureLeftIcon?: IconProp;
11
- gestureLeftVariant?: DragVariant;
12
- onGestureLeft?: () => void;
7
+ 'children': React.ReactNode;
8
+ 'size'?: InlineCardSize;
9
+ 'value'?: string;
10
+ 'gestureLeftIcon'?: IconProp;
11
+ 'gestureLeftVariant'?: DragVariant;
12
+ 'onGestureLeft'?: () => void;
13
+ 'data-testid'?: string;
13
14
  }
14
15
  declare const InlineCard: {
15
- ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }: InlineCardProps): JSX.Element;
16
+ ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, "data-testid": dataTestId, }: InlineCardProps): JSX.Element;
16
17
  Media: ({ children, variant }: import("./_InlineCardMedia.component").InlineCardMediaProps) => JSX.Element;
17
18
  Content: ({ children, center }: import("./_InlineCardContent.component").InlineCardContentProps) => JSX.Element;
18
19
  Meta: ({ children }: import("./_InlineCardMeta.component").InlineCardMetaProps) => JSX.Element;
@@ -105,7 +105,7 @@ const SelectIconContainer = styled.div `
105
105
 
106
106
  color: ${(props) => props.theme.colours.statusInfo.contrast};
107
107
  `;
108
- const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }) => {
108
+ const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, 'data-testid': dataTestId, }) => {
109
109
  const { value: selectedValues, onToggle } = useContext(InlineCardSelectionContext);
110
110
  const isSelectable = !!onToggle;
111
111
  const isSelected = selectedValues?.length && value && selectedValues.includes(value);
@@ -136,7 +136,7 @@ const InlineCard = ({ children, size, value, onClick, gestureLeftIcon, gestureLe
136
136
  };
137
137
  return (React.createElement(CardWrapper, { size: size },
138
138
  React.createElement(CardActionBackground, { style: { opacity, backgroundColor: gestureLeftTheme.main } }, gestureLeftIcon && (React.createElement(FontAwesomeIcon, { style: { fontSize: '20px', color: gestureLeftTheme.contrast }, icon: gestureLeftIcon }))),
139
- React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, ref: ref, style: { x }, animate: { x: gestureLeftActivated ? -bounds.width : undefined, opacity: gestureLeftActivated ? 0 : undefined }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick || isSelectable, onClick: handleClick, "data-testid": 'inline-card' }, children),
139
+ React.createElement(CardOuter, { drag: onGestureLeft ? 'x' : undefined, onDragEnd: handleDragEnd, ref: ref, style: { x }, animate: { x: gestureLeftActivated ? -bounds.width : undefined, opacity: gestureLeftActivated ? 0 : undefined }, dragConstraints: { left: 0, right: 0 }, usePointer: !!onClick || isSelectable, onClick: handleClick, "data-testid": dataTestId || 'inline-card' }, children),
140
140
  isSelectable && isSelected ? (React.createElement(SelectChecked, null,
141
141
  React.createElement(SelectIconContainer, null,
142
142
  React.createElement(FontAwesomeIcon, { icon: faCheck })))) : null));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "2.0.0-18",
3
+ "version": "2.0.0-19",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {