@toptal/picasso-container 3.1.3-alpha-MP-669-first-batch-of-rework-e1cd7f6d1.22 → 3.1.3-alpha-MP-669-first-batch-of-rework-c1fb81067.24

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.
@@ -7,14 +7,11 @@ declare type ContainerType = 'div' | 'span';
7
7
  declare type DirectionType = 'row' | 'column' | 'row-reverse' | 'column-reverse';
8
8
  declare type WrapType = 'wrap' | 'nowrap' | 'wrap-reverse';
9
9
  declare type BorderableType = 'transparent' | 'white';
10
+ declare type BorderedType<V extends VariantType> = V extends BorderableType ? boolean : never;
10
11
  export interface Props<V extends VariantType = VariantType> extends StandardProps, HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
11
12
  /** Content of Container */
12
13
  children?: ReactNode;
13
- /**
14
- * Whether container should act as inline element `display: inline-block`
15
- *
16
- * @default false
17
- */
14
+ /** Whether container should act as inline element `display: inline-block` */
18
15
  inline?: boolean;
19
16
  /** Use flexbox */
20
17
  flex?: boolean;
@@ -27,20 +24,12 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
27
24
  /** Defines flex-wrap style property */
28
25
  wrap?: WrapType;
29
26
  /** Whether (`white`, `transparent`) container has border or not */
30
- bordered?: V extends BorderableType ? boolean : never;
31
- /**
32
- * Whether container has 8px border-radius applied or not
33
- *
34
- * @default false
35
- */
27
+ bordered?: BorderedType<V>;
28
+ /** Whether container has 8px border-radius applied or not */
36
29
  rounded?: boolean;
37
30
  /** Style variant of Notification */
38
31
  variant?: V;
39
- /**
40
- * Component used for the root node
41
- *
42
- * @default div
43
- */
32
+ /** Component used for the root node */
44
33
  as?: ContainerType;
45
34
  /** Text align of the inner text */
46
35
  align?: PropTypes.Alignment;
@@ -57,12 +46,20 @@ export interface Props<V extends VariantType = VariantType> extends StandardProp
57
46
  /** Gap between elements for a flex container */
58
47
  gap?: SpacingType;
59
48
  }
49
+ /**
50
+ * Separate component is needed for proper Storybook props display
51
+ */
52
+ export declare const ContainerFunction: {
53
+ <V extends "transparent" | "red" | "green" | "white" | "yellow" | "blue" | "grey">({ as, inline, rounded, bordered, ref, ...props }: Props<V> & {
54
+ ref?: Ref<HTMLDivElement> | undefined;
55
+ }): JSX.Element;
56
+ displayName: string;
57
+ };
60
58
  declare type ContainerProps = {
61
59
  <V extends VariantType = VariantType>(props: Props<V> & {
62
60
  ref?: Ref<HTMLDivElement> | null;
63
61
  }): ReactElement;
64
62
  displayName?: string;
65
- defaultProps?: Partial<Props<VariantType>>;
66
63
  };
67
64
  /**
68
65
  * Container component used for spacing 2 elements
@@ -1 +1 @@
1
- {"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAKzE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI/E,aAAK,aAAa,GAAG,KAAK,GAAG,MAAM,CAAA;AAEnC,aAAK,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,CAAA;AAExE,aAAK,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAA;AAElD,aAAK,cAAc,GAAG,aAAa,GAAG,OAAO,CAAA;AAE7C,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CACxD,SAAQ,aAAa,EACnB,cAAc,CAAC,cAAc,GAAG,eAAe,CAAC;IAClD,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;OA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,cAAc,CAAA;IAC3B,iDAAiD;IACjD,cAAc,CAAC,EAAE,kBAAkB,CAAA;IACnC,uCAAuC;IACvC,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,mEAAmE;IACnE,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC1B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,uCAAuC;IACvC,EAAE,CAAC,EAAE,aAAa,CAAA;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAA;IAC3B,wDAAwD;IACxD,GAAG,CAAC,EAAE,WAAW,CAAA;IACjB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,yDAAyD;IACzD,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,qDAAqD;IACrD,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,gDAAgD;IAChD,GAAG,CAAC,EAAE,WAAW,CAAA;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;CAyF7B,CAAA;AAID,aAAK,cAAc,GAAG;IACpB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAClC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG;QAAE,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,GAAG,IAAI,CAAA;KAAE,GACrD,YAAY,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,cAGL,CAAA;AAInB,eAAe,SAAS,CAAA;AACxB,YAAY,EAAE,WAAW,EAAE,CAAA"}
@@ -10,19 +10,19 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React from 'react';
13
- import { documentable, forwardRef } from '@toptal/picasso-utils';
13
+ import { forwardRef } from '@toptal/picasso-utils';
14
14
  import { twMerge } from '@toptal/picasso-tailwind-merge';
15
15
  import { alignmentClasses, variantClassesByColor } from './styles';
16
16
  import { getSpacingClasses, getSpacingStyles } from './utils';
17
17
  /**
18
- * Container component used for spacing 2 elements
18
+ * Separate component is needed for proper Storybook props display
19
19
  */
20
- export const Container = documentable(forwardRef((_a, ref) => {
21
- var { as = 'div', inline = false, rounded = false } = _a, props = __rest(_a, ["as", "inline", "rounded"]);
22
- const { children, className, flex, direction, alignItems, justifyContent, bordered = false, wrap, style, variant, align, top, bottom, left, right, padded, gap,
20
+ export const ContainerFunction = function ContainerFunction(_a) {
21
+ var { as = 'div', inline = false, rounded = false, bordered = false, ref } = _a, props = __rest(_a, ["as", "inline", "rounded", "bordered", "ref"]);
22
+ const { children, className, flex, direction, alignItems, justifyContent, wrap, style, variant, align, top, bottom, left, right, padded, gap,
23
23
  // Avoid passing external classes inside the rest props
24
24
  /* eslint-disable @typescript-eslint/no-unused-vars */
25
- classes: externalClasses } = props, rest = __rest(props, ["children", "className", "flex", "direction", "alignItems", "justifyContent", "bordered", "wrap", "style", "variant", "align", "top", "bottom", "left", "right", "padded", "gap", "classes"]);
25
+ classes: externalClasses } = props, rest = __rest(props, ["children", "className", "flex", "direction", "alignItems", "justifyContent", "wrap", "style", "variant", "align", "top", "bottom", "left", "right", "padded", "gap", "classes"]);
26
26
  const Component = as;
27
27
  const spacingProps = { gap, padded, top, bottom, right, left };
28
28
  const isBorderedVariant = !variant || variant === 'white' || variant === 'transparent';
@@ -35,12 +35,15 @@ export const Container = documentable(forwardRef((_a, ref) => {
35
35
  ? 'inline-block'
36
36
  : '';
37
37
  };
38
- return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: twMerge(variant && variantClassesByColor[variant], getSpacingClasses(spacingProps), typeof align === 'string' && alignmentClasses.textAlign[align], alignItems && alignmentClasses.alignItems[alignItems], justifyContent && alignmentClasses.justifyContent[justifyContent], wrap && alignmentClasses.wrap[wrap], bordered &&
39
- isBorderedVariant &&
40
- 'border border-solid border-gray-200', rounded && 'rounded-md', getDisplayValue(inline, flex), direction &&
38
+ return (React.createElement(Component, Object.assign({}, rest, { ref: ref, className: twMerge(variant && variantClassesByColor[variant], getSpacingClasses(spacingProps), typeof align === 'string' && alignmentClasses.textAlign[align], alignItems && alignmentClasses.alignItems[alignItems], justifyContent && alignmentClasses.justifyContent[justifyContent], wrap && alignmentClasses.wrap[wrap], bordered && isBorderedVariant && 'border border-solid border-gray-200', rounded && 'rounded-md', getDisplayValue(inline, flex), direction &&
41
39
  direction !== 'row' &&
42
40
  alignmentClasses.direction[direction], className), style: Object.assign(Object.assign({}, getSpacingStyles(spacingProps)), style) }), children));
43
- }));
41
+ };
42
+ ContainerFunction.displayName = 'ContainerFunction';
43
+ /**
44
+ * Container component used for spacing 2 elements
45
+ */
46
+ export const Container = forwardRef((props, ref) => ContainerFunction(Object.assign(Object.assign({}, props), { ref })));
44
47
  Container.displayName = 'Container';
45
48
  export default Container;
46
49
  //# sourceMappingURL=Container.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":";;;;;;;;;;;AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAuE7D;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAmB,YAAY,CACnD,UAAU,CACR,CACE,EAAmE,EACnE,GAA+B,EAC/B,EAAE;QAFF,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,O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c,CAAC,EAEjE,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAEnC,QAAQ;YACN,iBAAiB;YACjB,qCAAqC,EACvC,OAAO,IAAI,YAAY,EAEvB,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,EAE7B,SAAS;YACP,SAAS,KAAK,KAAK;YACnB,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,EAEvC,SAAS,CACV,EACD,KAAK,kCAEA,gBAAgB,CAAC,YAAY,CAAC,GAC9B,KAAK,MAGT,QAAQ,CACC,CACb,CAAA;AACH,CAAC,CACgB,CACpB,CAAA;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/Container/Container.tsx"],"names":[],"mappings":";;;;;;;;;;;AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAsD7D;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,iBAAiB,CAEzD,EAOgD;QAPhD,EACA,EAAE,GAAG,KAAK,EACV,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAwB,EACnC,GAAG,OAE6C,EAD7C,KAAK,cANR,8CAOD,CADS;IAER,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,KAAK,EACL,OAAO,EACP,KAAK,EACL,GAAG,EACH,MAAM,EACN,IAAI,EACJ,KAAK,EACL,MAAM,EACN,GAAG;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D,KAAK,kCAEA,gBAAgB,CAAC,YAAY,CAAC,GAC9B,KAAK,MAGT,QAAQ,CACC,CACb,CAAA;AACH,CAAC,CAAA;AAED,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAA;AASnD;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAmB,UAAU,CACjD,CAAwB,KAAe,EAAE,GAA+B,EAAE,EAAE,CAC1E,iBAAiB,iCAAM,KAAK,KAAE,GAAG,IAAG,CACrB,CAAA;AAEnB,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA;AAEnC,eAAe,SAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-container",
3
- "version": "3.1.3-alpha-MP-669-first-batch-of-rework-e1cd7f6d1.22+e1cd7f6d1",
3
+ "version": "3.1.3-alpha-MP-669-first-batch-of-rework-c1fb81067.24+c1fb81067",
4
4
  "description": "Toptal UI components library - Container",
5
5
  "homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
6
6
  "bugs": {
@@ -26,7 +26,7 @@
26
26
  "prepublishOnly": "yarn build:package"
27
27
  },
28
28
  "dependencies": {
29
- "@toptal/picasso-utils": "3.1.1-alpha-MP-669-first-batch-of-rework-e1cd7f6d1.22+e1cd7f6d1"
29
+ "@toptal/picasso-utils": "3.1.1-alpha-MP-669-first-batch-of-rework-c1fb81067.24+c1fb81067"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@toptal/picasso-provider": "*",
@@ -35,8 +35,8 @@
35
35
  "react": ">=16.12.0 < 19.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@toptal/picasso-provider": "5.0.1-alpha-MP-669-first-batch-of-rework-e1cd7f6d1.289+e1cd7f6d1",
39
- "@toptal/picasso-test-utils": "1.1.2-alpha-MP-669-first-batch-of-rework-e1cd7f6d1.368+e1cd7f6d1"
38
+ "@toptal/picasso-provider": "5.0.1-alpha-MP-669-first-batch-of-rework-c1fb81067.291+c1fb81067",
39
+ "@toptal/picasso-test-utils": "1.1.2-alpha-MP-669-first-batch-of-rework-c1fb81067.370+c1fb81067"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
@@ -46,5 +46,5 @@
46
46
  "!dist-package/tsconfig.tsbuildinfo",
47
47
  "src"
48
48
  ],
49
- "gitHead": "e1cd7f6d145874c583419c992840043ba6ac330b"
49
+ "gitHead": "c1fb81067638a739fa725a4befdad405a78db876"
50
50
  }
@@ -4,7 +4,7 @@ import type { SpacingType } from '@toptal/picasso-provider'
4
4
  import type { StandardProps } from '@toptal/picasso-shared'
5
5
  import type { HTMLAttributes, ReactElement, ReactNode, Ref } from 'react'
6
6
  import React from 'react'
7
- import { documentable, forwardRef } from '@toptal/picasso-utils'
7
+ import { forwardRef } from '@toptal/picasso-utils'
8
8
  import { twMerge } from '@toptal/picasso-tailwind-merge'
9
9
 
10
10
  import type { AlignItemsType, JustifyContentType, VariantType } from './styles'
@@ -19,16 +19,15 @@ type WrapType = 'wrap' | 'nowrap' | 'wrap-reverse'
19
19
 
20
20
  type BorderableType = 'transparent' | 'white'
21
21
 
22
+ type BorderedType<V extends VariantType> = V extends BorderableType
23
+ ? boolean
24
+ : never
22
25
  export interface Props<V extends VariantType = VariantType>
23
26
  extends StandardProps,
24
27
  HTMLAttributes<HTMLDivElement | HTMLSpanElement> {
25
28
  /** Content of Container */
26
29
  children?: ReactNode
27
- /**
28
- * Whether container should act as inline element `display: inline-block`
29
- *
30
- * @default false
31
- */
30
+ /** Whether container should act as inline element `display: inline-block` */
32
31
  inline?: boolean
33
32
  /** Use flexbox */
34
33
  flex?: boolean
@@ -41,20 +40,12 @@ export interface Props<V extends VariantType = VariantType>
41
40
  /** Defines flex-wrap style property */
42
41
  wrap?: WrapType
43
42
  /** Whether (`white`, `transparent`) container has border or not */
44
- bordered?: V extends BorderableType ? boolean : never
45
- /**
46
- * Whether container has 8px border-radius applied or not
47
- *
48
- * @default false
49
- */
43
+ bordered?: BorderedType<V>
44
+ /** Whether container has 8px border-radius applied or not */
50
45
  rounded?: boolean
51
46
  /** Style variant of Notification */
52
47
  variant?: V
53
- /**
54
- * Component used for the root node
55
- *
56
- * @default div
57
- */
48
+ /** Component used for the root node */
58
49
  as?: ContainerType
59
50
  /** Text align of the inner text */
60
51
  align?: PropTypes.Alignment
@@ -72,108 +63,116 @@ export interface Props<V extends VariantType = VariantType>
72
63
  gap?: SpacingType
73
64
  }
74
65
 
66
+ /**
67
+ * Separate component is needed for proper Storybook props display
68
+ */
69
+ export const ContainerFunction = function ContainerFunction<
70
+ V extends VariantType
71
+ >({
72
+ as = 'div',
73
+ inline = false,
74
+ rounded = false,
75
+ bordered = false as BorderedType<V>,
76
+ ref,
77
+ ...props
78
+ }: Props<V> & { ref?: Ref<HTMLDivElement> | null }) {
79
+ const {
80
+ children,
81
+ className,
82
+ flex,
83
+ direction,
84
+ alignItems,
85
+ justifyContent,
86
+ wrap,
87
+ style,
88
+ variant,
89
+ align,
90
+ top,
91
+ bottom,
92
+ left,
93
+ right,
94
+ padded,
95
+ gap,
96
+ // Avoid passing external classes inside the rest props
97
+ /* eslint-disable @typescript-eslint/no-unused-vars */
98
+ classes: externalClasses,
99
+ ...rest
100
+ } = props
101
+
102
+ const Component = as
103
+
104
+ const spacingProps = { gap, padded, top, bottom, right, left }
105
+ const isBorderedVariant =
106
+ !variant || variant === 'white' || variant === 'transparent'
107
+
108
+ const getDisplayValue = (
109
+ isInline: boolean | undefined,
110
+ isFlex: boolean | undefined
111
+ ) => {
112
+ return isFlex
113
+ ? isInline
114
+ ? 'inline-flex'
115
+ : 'flex'
116
+ : isInline
117
+ ? 'inline-block'
118
+ : ''
119
+ }
120
+
121
+ return (
122
+ <Component
123
+ {...rest}
124
+ ref={ref}
125
+ className={twMerge(
126
+ variant && variantClassesByColor[variant],
127
+
128
+ getSpacingClasses(spacingProps),
129
+
130
+ typeof align === 'string' && alignmentClasses.textAlign[align],
131
+
132
+ alignItems && alignmentClasses.alignItems[alignItems],
133
+
134
+ justifyContent && alignmentClasses.justifyContent[justifyContent],
135
+
136
+ wrap && alignmentClasses.wrap[wrap],
137
+
138
+ bordered && isBorderedVariant && 'border border-solid border-gray-200',
139
+ rounded && 'rounded-md',
140
+
141
+ getDisplayValue(inline, flex),
142
+
143
+ direction &&
144
+ direction !== 'row' &&
145
+ alignmentClasses.direction[direction],
146
+
147
+ className
148
+ )}
149
+ style={{
150
+ // used for deprecated spacing props (typeof number)
151
+ ...getSpacingStyles(spacingProps),
152
+ ...style,
153
+ }}
154
+ >
155
+ {children}
156
+ </Component>
157
+ )
158
+ }
159
+
160
+ ContainerFunction.displayName = 'ContainerFunction'
161
+
75
162
  type ContainerProps = {
76
163
  <V extends VariantType = VariantType>(
77
164
  props: Props<V> & { ref?: Ref<HTMLDivElement> | null }
78
165
  ): ReactElement
79
166
  displayName?: string
80
- defaultProps?: Partial<Props<VariantType>>
81
167
  }
82
168
 
83
169
  /**
84
170
  * Container component used for spacing 2 elements
85
171
  */
86
- export const Container: ContainerProps = documentable(
87
- forwardRef<Props, HTMLDivElement>(
88
- <V extends VariantType>(
89
- { as = 'div', inline = false, rounded = false, ...props }: Props<V>,
90
- ref: Ref<HTMLDivElement> | null
91
- ) => {
92
- const {
93
- children,
94
- className,
95
- flex,
96
- direction,
97
- alignItems,
98
- justifyContent,
99
- bordered = false,
100
- wrap,
101
- style,
102
- variant,
103
- align,
104
- top,
105
- bottom,
106
- left,
107
- right,
108
- padded,
109
- gap,
110
- // Avoid passing external classes inside the rest props
111
- /* eslint-disable @typescript-eslint/no-unused-vars */
112
- classes: externalClasses,
113
- ...rest
114
- } = props
115
-
116
- const Component = as
117
-
118
- const spacingProps = { gap, padded, top, bottom, right, left }
119
- const isBorderedVariant =
120
- !variant || variant === 'white' || variant === 'transparent'
121
-
122
- const getDisplayValue = (
123
- isInline: boolean | undefined,
124
- isFlex: boolean | undefined
125
- ) => {
126
- return isFlex
127
- ? isInline
128
- ? 'inline-flex'
129
- : 'flex'
130
- : isInline
131
- ? 'inline-block'
132
- : ''
133
- }
134
-
135
- return (
136
- <Component
137
- {...rest}
138
- ref={ref}
139
- className={twMerge(
140
- variant && variantClassesByColor[variant],
141
-
142
- getSpacingClasses(spacingProps),
143
-
144
- typeof align === 'string' && alignmentClasses.textAlign[align],
145
-
146
- alignItems && alignmentClasses.alignItems[alignItems],
147
-
148
- justifyContent && alignmentClasses.justifyContent[justifyContent],
149
-
150
- wrap && alignmentClasses.wrap[wrap],
151
-
152
- bordered &&
153
- isBorderedVariant &&
154
- 'border border-solid border-gray-200',
155
- rounded && 'rounded-md',
156
-
157
- getDisplayValue(inline, flex),
158
-
159
- direction &&
160
- direction !== 'row' &&
161
- alignmentClasses.direction[direction],
162
-
163
- className
164
- )}
165
- style={{
166
- // used for deprecated spacing props (typeof number)
167
- ...getSpacingStyles(spacingProps),
168
- ...style,
169
- }}
170
- >
171
- {children}
172
- </Component>
173
- )
174
- }
175
- ) as ContainerProps
176
- )
172
+ export const Container: ContainerProps = forwardRef<Props, HTMLDivElement>(
173
+ <V extends VariantType>(props: Props<V>, ref: Ref<HTMLDivElement> | null) =>
174
+ ContainerFunction({ ...props, ref })
175
+ ) as ContainerProps
177
176
 
178
177
  Container.displayName = 'Container'
179
178
 
@@ -1,4 +1,4 @@
1
- import { Container } from '../Container'
1
+ import { ContainerFunction } from '../Container'
2
2
  import PicassoBook from '~/.storybook/components/PicassoBook'
3
3
 
4
4
  const page = PicassoBook.section('Layout').createPage(
@@ -9,9 +9,16 @@ const page = PicassoBook.section('Layout').createPage(
9
9
  `
10
10
  )
11
11
 
12
- page
13
- .createTabChapter('Props')
14
- .addComponentDocs({ component: Container, name: 'Container' })
12
+ page.createTabChapter('Props').addComponentDocs({
13
+ component: ContainerFunction,
14
+ name: 'ContainerFunction',
15
+ additionalDocs: {
16
+ bordered: {
17
+ type: 'boolean',
18
+ defaultValue: 'false',
19
+ },
20
+ },
21
+ })
15
22
 
16
23
  page
17
24
  .createChapter()