@thecb/components 6.3.1-beta.5 → 6.3.1-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.3.1-beta.5",
3
+ "version": "6.3.1-beta.8",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,7 +10,7 @@ export interface ButtonWithActionProps {
10
10
  textExtraStyles?: string;
11
11
  contentOverride?: boolean;
12
12
  extraStyles?: string;
13
- tabIndex?: number;
13
+ tabIndex?: string;
14
14
  }
15
15
 
16
16
  export const ButtonWithAction: React.FC<Expand<ButtonWithActionProps> &
@@ -5,7 +5,6 @@ import withWindowSize from "../../withWindowSize";
5
5
 
6
6
  import { fallbackValues } from "./Card.theme";
7
7
 
8
- import Box from "../layouts/Box";
9
8
  import BoxWithShadow from "../box-with-shadow";
10
9
  import Cover from "../layouts/Cover";
11
10
  import Stack from "../layouts/Stack";
@@ -15,23 +14,28 @@ import CardText from "./CardText";
15
14
  import CardHeader from "./CardHeader";
16
15
 
17
16
  const Card = ({
18
- themeValues,
19
- children,
17
+ borderRadius = "4px",
20
18
  extraStyles,
21
- width = "276px",
22
- text,
23
- titleText,
24
- titleVariant = "small",
19
+ headerAs = "h2",
20
+ headerText,
21
+ headerVariant = "small",
25
22
  imgSrc,
26
23
  imgHeight = "150px",
27
24
  imgObjectFit = "none",
28
- headerText,
29
- headerVariant = "small",
30
- borderRadius = "4px",
31
- padding = "24px"
25
+ imgAltText,
26
+ padding = "24px",
27
+ text,
28
+ titleText,
29
+ titleVariant = "small",
30
+ themeValues,
31
+ width = "276px",
32
+ children
32
33
  }) => {
33
34
  const numberOfChildren =
34
- children.length + (imgSrc ? 1 : 0) + (text ? 1 : 0) + (headerText ? 1 : 0);
35
+ (Array.isArray(children) ? children.length : 1) +
36
+ (text ? 1 : 0) +
37
+ (imgSrc ? 1 : 0) +
38
+ (headerText ? 1 : 0);
35
39
 
36
40
  return (
37
41
  <BoxWithShadow
@@ -43,7 +47,7 @@ const Card = ({
43
47
  minWidth={width}
44
48
  extraStyles={extraStyles}
45
49
  >
46
- <Cover singleChild>
50
+ <Cover singleChild fillCenter>
47
51
  <Stack fullHeight childGap="0" bottomItem={numberOfChildren}>
48
52
  {headerText && (
49
53
  <CardHeader
@@ -53,6 +57,7 @@ const Card = ({
53
57
  backgroundColor={themeValues.headerBackgroundColor}
54
58
  borderRadius={borderRadius}
55
59
  padding={padding}
60
+ as={headerAs}
56
61
  ></CardHeader>
57
62
  )}
58
63
  {imgSrc && (
@@ -61,18 +66,18 @@ const Card = ({
61
66
  objectFit={imgObjectFit}
62
67
  backgroundColor={themeValues.imageBackgroundColor}
63
68
  src={imgSrc}
69
+ alt={imgAltText}
70
+ />
71
+ )}
72
+ {text && (
73
+ <CardText
74
+ padding={padding}
75
+ titleText={titleText}
76
+ text={text}
77
+ titleVariant={titleVariant}
64
78
  />
65
79
  )}
66
- <Box padding={padding}>
67
- {text && (
68
- <CardText
69
- titleText={titleText}
70
- text={text}
71
- titleVariant={titleVariant}
72
- />
73
- )}
74
- {children}
75
- </Box>
80
+ {children}
76
81
  </Stack>
77
82
  </Cover>
78
83
  </BoxWithShadow>
@@ -4,12 +4,13 @@ import Box from "../layouts/Box";
4
4
  import Title from "../title";
5
5
 
6
6
  export const CardHeader = ({
7
+ backgroundColor,
8
+ borderRadius,
9
+ as,
7
10
  headerText,
8
11
  headerColor,
9
12
  headerVariant,
10
- backgroundColor,
11
- padding,
12
- borderRadius
13
+ padding
13
14
  }) => {
14
15
  return (
15
16
  <Box
@@ -17,7 +18,7 @@ export const CardHeader = ({
17
18
  background={backgroundColor}
18
19
  borderRadius={`${borderRadius} ${borderRadius} 0 0`}
19
20
  >
20
- <Title variant={headerVariant} color={headerColor}>
21
+ <Title as={as} variant={headerVariant} color={headerColor}>
21
22
  {headerText}
22
23
  </Title>
23
24
  </Box>
@@ -5,32 +5,37 @@ import withWindowSize from "../../withWindowSize";
5
5
 
6
6
  import { fallbackValues } from "./CardText.theme";
7
7
 
8
+ import Box from "../layouts/Box";
8
9
  import Cover from "../layouts/Cover";
9
10
  import Paragraph from "../paragraph";
10
11
  import Stack from "../layouts/Stack";
11
12
  import Title from "../title";
12
13
 
13
14
  export const CardText = ({
15
+ padding,
14
16
  text,
15
17
  titleText,
16
18
  titleVariant = "small",
17
19
  themeValues
18
20
  }) => {
19
21
  return (
20
- <Cover>
21
- <Stack>
22
- {titleText && (
23
- <Title
24
- variant={titleVariant}
25
- color={themeValues.titleColor}
26
- weight={themeValues?.titleWeight}
27
- >
28
- {titleText}
29
- </Title>
30
- )}
31
- <Paragraph color={themeValues.textColor}>{text}</Paragraph>
32
- </Stack>
33
- </Cover>
22
+ <Box padding={padding}>
23
+ <Cover>
24
+ <Stack>
25
+ {titleText && (
26
+ <Title
27
+ as="p"
28
+ variant={titleVariant}
29
+ color={themeValues.titleColor}
30
+ weight={themeValues.titleWeight}
31
+ >
32
+ {titleText}
33
+ </Title>
34
+ )}
35
+ <Paragraph color={themeValues.textColor}>{text}</Paragraph>
36
+ </Stack>
37
+ </Cover>
38
+ </Box>
34
39
  );
35
40
  };
36
41
 
@@ -8,5 +8,5 @@ const textColor = BRIGHT_GREY;
8
8
  export const fallbackValues = {
9
9
  titleColor,
10
10
  titleWeight,
11
- titleWeight
11
+ textColor
12
12
  };
@@ -8,6 +8,7 @@ export interface CardProps {
8
8
  extraStyles?: string;
9
9
  imgSrc?: string;
10
10
  imgHeight?: string;
11
+ imgAltText?: string;
11
12
  imgObjectFit?:
12
13
  | "contain"
13
14
  | "cover"
@@ -19,6 +20,7 @@ export interface CardProps {
19
20
  | "revert"
20
21
  | "revert-layer"
21
22
  | "unset";
23
+ headerAs?: string;
22
24
  headerText?: string;
23
25
  headerVariant?: string;
24
26
  borderRadius?: string;
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface CollapsibleSectionProps {
5
+ isOpen: boolean;
6
+ toggleSection?: () => void;
7
+ isMobile?: boolean;
8
+ supportsTouch?: boolean;
9
+ title?: string;
10
+ customPadding?: string;
11
+ initiallyOpen?: boolean;
12
+ openHeight?: string;
13
+ customTitle?: boolean;
14
+ stackTitle?: boolean;
15
+ stackTitleContent?: JSX.Element;
16
+ sectionGap?: string;
17
+ name?: string;
18
+ index?: number;
19
+ }
20
+
21
+ export const CollapsibleSection: React.FC<Expand<CollapsibleSectionProps> &
22
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface EditableTableProps {
5
+ title?: any;
6
+ renderItem?: (items: any) => JSX.Element;
7
+ items: any;
8
+ isMobile?: boolean;
9
+ }
10
+
11
+ export const EditableTable: React.FC<Expand<EditableTableProps> &
12
+ React.HTMLAttributes<HTMLElement>>;
13
+
14
+ export interface TableListItemProps {
15
+ borderTopItem?: boolean;
16
+ canEdit?: boolean;
17
+ canRemove?: boolean;
18
+ isMobile?: boolean;
19
+ title?: any;
20
+ value?: any;
21
+ }
22
+
23
+ export const TableListItem: React.FC<Expand<TableListItemProps> &
24
+ React.HTMLAttributes<HTMLElement>>;
@@ -1 +1,2 @@
1
+ export * from "./collapsible-section";
1
2
  export * from "./footer-with-subfooter";