@lumx/react 2.2.22-alpha-fix-generic-block.2 → 2.2.22-alpha-dart-sass.1

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 +1 @@
1
- {"version":3,"file":"FlexBox.js","sources":["../../../src/components/flex-box/FlexBox.tsx"],"sourcesContent":["import { Alignment, HorizontalAlignment, Orientation, VerticalAlignment } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport castArray from 'lodash/castArray';\nimport React, { forwardRef, ReactNode } from 'react';\nimport { Size } from '..';\n\nexport type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;\nexport type GapSize = Extract<Size, 'tiny' | 'regular' | 'medium' | 'big' | 'huge'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface FlexBoxProps extends GenericProps {\n /** Children elements. */\n children?: ReactNode;\n /** Whether the \"content filling space\" is enabled or not. */\n fillSpace?: boolean;\n /** Gap space between flexbox items. */\n gap?: GapSize;\n /** Flex horizontal alignment. */\n hAlign?: VerticalAlignment;\n /** Whether the \"auto margin\" is enabled all around or not. */\n marginAuto?: MarginAutoAlignment | MarginAutoAlignment[];\n /** Whether the \"content shrink\" is disabled or not. */\n noShrink?: boolean;\n /** Flex direction. */\n orientation?: Orientation;\n /** Flex vertical alignment. */\n vAlign?: HorizontalAlignment;\n /** Whether the \"flex wrap\" is enabled or not. */\n wrap?: boolean;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'FlexBox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * FlexBox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const FlexBox: Comp<FlexBoxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fillSpace,\n gap,\n hAlign,\n marginAuto,\n noShrink,\n orientation,\n vAlign,\n wrap,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n orientation: orientation ?? (wrap || hAlign || vAlign ? Orientation.horizontal : null),\n vAlign,\n hAlign,\n gap,\n }),\n wrap && `${CLASSNAME}--wrap`,\n fillSpace && `${CLASSNAME}--fill-space`,\n noShrink && `${CLASSNAME}--no-shrink`,\n marginAuto && castArray(marginAuto).map((align) => `${CLASSNAME}--margin-auto-${align}`),\n )}\n >\n {children}\n </div>\n );\n});\nFlexBox.displayName = COMPONENT_NAME;\nFlexBox.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","FlexBox","forwardRef","props","ref","children","className","fillSpace","gap","hAlign","marginAuto","noShrink","orientation","vAlign","wrap","forwardedProps","classNames","handleBasicClasses","prefix","Orientation","horizontal","castArray","map","align","displayName"],"mappings":";;;;;;AAkCA;;;AAGA,IAAMA,cAAc,GAAG,SAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;;;;;IAOaG,OAA2C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAE9EC,QAF8E,GAa9EF,KAb8E,CAE9EE,QAF8E;AAAA,MAG9EC,SAH8E,GAa9EH,KAb8E,CAG9EG,SAH8E;AAAA,MAI9EC,SAJ8E,GAa9EJ,KAb8E,CAI9EI,SAJ8E;AAAA,MAK9EC,GAL8E,GAa9EL,KAb8E,CAK9EK,GAL8E;AAAA,MAM9EC,MAN8E,GAa9EN,KAb8E,CAM9EM,MAN8E;AAAA,MAO9EC,UAP8E,GAa9EP,KAb8E,CAO9EO,UAP8E;AAAA,MAQ9EC,QAR8E,GAa9ER,KAb8E,CAQ9EQ,QAR8E;AAAA,MAS9EC,WAT8E,GAa9ET,KAb8E,CAS9ES,WAT8E;AAAA,MAU9EC,MAV8E,GAa9EV,KAb8E,CAU9EU,MAV8E;AAAA,MAW9EC,IAX8E,GAa9EX,KAb8E,CAW9EW,IAX8E;AAAA,MAY3EC,cAZ2E,4BAa9EZ,KAb8E;;AAelF,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQW,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CACjBV,SADiB,EAEjBW,kBAAkB,CAAC;AACfC,MAAAA,MAAM,EAAEnB,SADO;AAEfa,MAAAA,WAAW,EAAEA,WAAF,aAAEA,WAAF,cAAEA,WAAF,GAAkBE,IAAI,IAAIL,MAAR,IAAkBI,MAAlB,GAA2BM,WAAW,CAACC,UAAvC,GAAoD,IAFlE;AAGfP,MAAAA,MAAM,EAANA,MAHe;AAIfJ,MAAAA,MAAM,EAANA,MAJe;AAKfD,MAAAA,GAAG,EAAHA;AALe,KAAD,CAFD,EASjBM,IAAI,cAAOf,SAAP,WATa,EAUjBQ,SAAS,cAAOR,SAAP,iBAVQ,EAWjBY,QAAQ,cAAOZ,SAAP,gBAXS,EAYjBW,UAAU,IAAIW,SAAS,CAACX,UAAD,CAAT,CAAsBY,GAAtB,CAA0B,UAACC,KAAD;AAAA,uBAAcxB,SAAd,2BAAwCwB,KAAxC;AAAA,KAA1B,CAZG;AAHzB,MAkBKlB,QAlBL,CADJ;AAsBH,CArCoE;AAsCrEJ,OAAO,CAACuB,WAAR,GAAsB1B,cAAtB;AACAG,OAAO,CAACK,SAAR,GAAoBP,SAApB;;;;"}
1
+ {"version":3,"file":"FlexBox.js","sources":["../../../src/components/flex-box/FlexBox.tsx"],"sourcesContent":["import { Alignment, HorizontalAlignment, Orientation, VerticalAlignment } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport classNames from 'classnames';\nimport castArray from 'lodash/castArray';\nimport React, { forwardRef, ReactNode } from 'react';\nimport { Size } from '..';\n\nexport type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;\nexport type GapSize = Extract<Size, 'regular' | 'medium' | 'big' | 'huge'>;\n\n/**\n * Defines the props of the component.\n */\nexport interface FlexBoxProps extends GenericProps {\n /** Children elements. */\n children?: ReactNode;\n /** Whether the \"content filling space\" is enabled or not. */\n fillSpace?: boolean;\n /** Gap space between flexbox items. */\n gap?: GapSize;\n /** Flex horizontal alignment. */\n hAlign?: VerticalAlignment;\n /** Whether the \"auto margin\" is enabled all around or not. */\n marginAuto?: MarginAutoAlignment | MarginAutoAlignment[];\n /** Whether the \"content shrink\" is disabled or not. */\n noShrink?: boolean;\n /** Flex direction. */\n orientation?: Orientation;\n /** Flex vertical alignment. */\n vAlign?: HorizontalAlignment;\n /** Whether the \"flex wrap\" is enabled or not. */\n wrap?: boolean;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'FlexBox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * FlexBox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const FlexBox: Comp<FlexBoxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n fillSpace,\n gap,\n hAlign,\n marginAuto,\n noShrink,\n orientation,\n vAlign,\n wrap,\n ...forwardedProps\n } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n orientation: orientation ?? (wrap || hAlign || vAlign ? Orientation.horizontal : null),\n vAlign,\n hAlign,\n gap,\n }),\n wrap && `${CLASSNAME}--wrap`,\n fillSpace && `${CLASSNAME}--fill-space`,\n noShrink && `${CLASSNAME}--no-shrink`,\n marginAuto && castArray(marginAuto).map((align) => `${CLASSNAME}--margin-auto-${align}`),\n )}\n >\n {children}\n </div>\n );\n});\nFlexBox.displayName = COMPONENT_NAME;\nFlexBox.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","FlexBox","forwardRef","props","ref","children","className","fillSpace","gap","hAlign","marginAuto","noShrink","orientation","vAlign","wrap","forwardedProps","classNames","handleBasicClasses","prefix","Orientation","horizontal","castArray","map","align","displayName"],"mappings":";;;;;;AAkCA;;;AAGA,IAAMA,cAAc,GAAG,SAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;;;;;IAOaG,OAA2C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAE9EC,QAF8E,GAa9EF,KAb8E,CAE9EE,QAF8E;AAAA,MAG9EC,SAH8E,GAa9EH,KAb8E,CAG9EG,SAH8E;AAAA,MAI9EC,SAJ8E,GAa9EJ,KAb8E,CAI9EI,SAJ8E;AAAA,MAK9EC,GAL8E,GAa9EL,KAb8E,CAK9EK,GAL8E;AAAA,MAM9EC,MAN8E,GAa9EN,KAb8E,CAM9EM,MAN8E;AAAA,MAO9EC,UAP8E,GAa9EP,KAb8E,CAO9EO,UAP8E;AAAA,MAQ9EC,QAR8E,GAa9ER,KAb8E,CAQ9EQ,QAR8E;AAAA,MAS9EC,WAT8E,GAa9ET,KAb8E,CAS9ES,WAT8E;AAAA,MAU9EC,MAV8E,GAa9EV,KAb8E,CAU9EU,MAV8E;AAAA,MAW9EC,IAX8E,GAa9EX,KAb8E,CAW9EW,IAX8E;AAAA,MAY3EC,cAZ2E,4BAa9EZ,KAb8E;;AAelF,SACI;AACI,IAAA,GAAG,EAAEC;AADT,KAEQW,cAFR;AAGI,IAAA,SAAS,EAAEC,UAAU,CACjBV,SADiB,EAEjBW,kBAAkB,CAAC;AACfC,MAAAA,MAAM,EAAEnB,SADO;AAEfa,MAAAA,WAAW,EAAEA,WAAF,aAAEA,WAAF,cAAEA,WAAF,GAAkBE,IAAI,IAAIL,MAAR,IAAkBI,MAAlB,GAA2BM,WAAW,CAACC,UAAvC,GAAoD,IAFlE;AAGfP,MAAAA,MAAM,EAANA,MAHe;AAIfJ,MAAAA,MAAM,EAANA,MAJe;AAKfD,MAAAA,GAAG,EAAHA;AALe,KAAD,CAFD,EASjBM,IAAI,cAAOf,SAAP,WATa,EAUjBQ,SAAS,cAAOR,SAAP,iBAVQ,EAWjBY,QAAQ,cAAOZ,SAAP,gBAXS,EAYjBW,UAAU,IAAIW,SAAS,CAACX,UAAD,CAAT,CAAsBY,GAAtB,CAA0B,UAACC,KAAD;AAAA,uBAAcxB,SAAd,2BAAwCwB,KAAxC;AAAA,KAA1B,CAZG;AAHzB,MAkBKlB,QAlBL,CADJ;AAsBH,CArCoE;AAsCrEJ,OAAO,CAACuB,WAAR,GAAsB1B,cAAtB;AACAG,OAAO,CAACK,SAAR,GAAoBP,SAApB;;;;"}
@@ -1,11 +1,11 @@
1
1
  import { b as _objectWithoutProperties, f as _toArray, d as _slicedToArray, c as _extends } from './_rollupPluginBabelHelpers.js';
2
- import { Orientation, Size } from './components.js';
2
+ import { Orientation, Size, Alignment } from './components.js';
3
3
  import React, { forwardRef, Children } from 'react';
4
4
  import { g as getRootClassName, c as classnames } from './getRootClassName.js';
5
5
  import 'lodash/isBoolean';
6
- import isEmpty from 'lodash/isEmpty';
6
+ import 'lodash/isEmpty';
7
7
  import 'lodash/kebabCase';
8
- import noop from 'lodash/noop';
8
+ import 'lodash/noop';
9
9
  import { p as partitionMulti } from './partitionMulti.js';
10
10
  import { a as isComponentType } from './type.js';
11
11
  import { F as FlexBox } from './FlexBox.js';
@@ -24,29 +24,43 @@ var CLASSNAME = getRootClassName(COMPONENT_NAME);
24
24
  */
25
25
 
26
26
  var DEFAULT_PROPS = {
27
- gap: Size.big,
28
- orientation: Orientation.horizontal
27
+ gap: Size.regular,
28
+ orientation: Orientation.vertical,
29
+ hAlign: Alignment.center,
30
+ vAlign: Alignment.center
29
31
  };
30
- var Figure = noop.bind({});
32
+
33
+ var Figure = function Figure() {
34
+ return null;
35
+ };
36
+
31
37
  var isFigure = isComponentType(Figure);
32
- var Content = noop.bind({});
38
+
39
+ var Content = function Content() {
40
+ return null;
41
+ };
42
+
33
43
  var isContent = isComponentType(Content);
34
- var Actions = noop.bind({});
44
+
45
+ var Actions = function Actions() {
46
+ return null;
47
+ };
48
+
35
49
  var isActions = isComponentType(Actions);
36
50
  /**
37
51
  * The GenericBlock is a layout component made of 3 sections that can be
38
52
  * displayed either horizontally of vertically with the same gap between each section.
39
53
  *
40
54
  * The sections are:
41
- * - `Figure` => A visual element to display before the main content.
42
- * - `Content` => The main content displayed
43
- * - `Actions` => One or more actions to set after the element.
55
+ * * (Optional) `Figure` => A visual element to display before the main content.
56
+ * * (Required) `Content` => The main content displayed
57
+ * * (Optional) `Actions` => One or more actions to set after the element.
44
58
  *
45
59
  * @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076
46
60
  */
47
61
 
48
62
  var BaseGenericBlock = forwardRef(function (props, ref) {
49
- var _sections$figureChild, _ref4, _sections$figureChild2, _sections$figureChild3, _sections$contentChil, _ref5, _sections$contentChil2, _sections$contentChil3, _sections$actionsChil, _ref6, _sections$actionsChil2, _sections$actionsChil3;
63
+ var _ref4, _sections$figureChild, _sections$figureChild2, _ref5, _sections$contentChil, _sections$contentChil2, _ref6, _sections$actionsChil, _sections$actionsChil2;
50
64
 
51
65
  var className = props.className,
52
66
  figure = props.figure,
@@ -75,42 +89,48 @@ var BaseGenericBlock = forwardRef(function (props, ref) {
75
89
 
76
90
  return {
77
91
  figureChild: figureChild,
78
- figureChildProps: (_ref = figureChild) === null || _ref === void 0 ? void 0 : _ref.props,
92
+ figureChildProps: ((_ref = figureChild) === null || _ref === void 0 ? void 0 : _ref.props) || {},
79
93
  contentChild: contentChild,
80
- contentChildProps: (_ref2 = contentChild) === null || _ref2 === void 0 ? void 0 : _ref2.props,
94
+ contentChildProps: ((_ref2 = contentChild) === null || _ref2 === void 0 ? void 0 : _ref2.props) || {},
81
95
  actionsChild: actionsChild,
82
- actionsChildProps: (_ref3 = actionsChild) === null || _ref3 === void 0 ? void 0 : _ref3.props,
83
- otherChildren: otherChildren.filter(function (child) {
84
- return !isEmpty(child);
85
- })
96
+ actionsChildProps: ((_ref3 = actionsChild) === null || _ref3 === void 0 ? void 0 : _ref3.props) || {},
97
+ otherChildren: otherChildren
86
98
  };
87
99
  }, [children]);
100
+ var actionsVAlign = Alignment.center;
101
+
102
+ if (orientation === Orientation.horizontal) {
103
+ actionsVAlign = Alignment.right;
104
+ }
105
+
106
+ var contentVAlign = Alignment.center;
107
+
108
+ if (orientation === Orientation.horizontal) {
109
+ contentVAlign = Alignment.left;
110
+ }
111
+
88
112
  return React.createElement(FlexBox, _extends({
89
113
  ref: ref,
90
114
  className: classnames(className, CLASSNAME),
91
115
  gap: gap,
92
116
  orientation: orientation
93
- }, forwardedProps), (figure || ((_sections$figureChild = sections.figureChildProps) === null || _sections$figureChild === void 0 ? void 0 : _sections$figureChild.children)) && React.createElement(FlexBox, _extends({
94
- ref: (_ref4 = sections.figureChild) === null || _ref4 === void 0 ? void 0 : _ref4.ref,
95
- vAlign: forwardedProps.vAlign,
96
- hAlign: forwardedProps.hAlign
117
+ }, forwardedProps), React.createElement(FlexBox, _extends({
118
+ ref: (_ref4 = sections.figureChild) === null || _ref4 === void 0 ? void 0 : _ref4.ref
97
119
  }, figureProps, sections.figureChildProps, {
98
- className: classnames(figureProps === null || figureProps === void 0 ? void 0 : figureProps.className, (_sections$figureChild2 = sections.figureChildProps) === null || _sections$figureChild2 === void 0 ? void 0 : _sections$figureChild2.className, "".concat(CLASSNAME, "__figure"))
99
- }), figure, (_sections$figureChild3 = sections.figureChildProps) === null || _sections$figureChild3 === void 0 ? void 0 : _sections$figureChild3.children), (((_sections$contentChil = sections.contentChildProps) === null || _sections$contentChil === void 0 ? void 0 : _sections$contentChil.children) || sections.otherChildren.length > 0) && React.createElement(FlexBox, _extends({
120
+ className: classnames(figureProps === null || figureProps === void 0 ? void 0 : figureProps.className, (_sections$figureChild = sections.figureChildProps) === null || _sections$figureChild === void 0 ? void 0 : _sections$figureChild.className, "".concat(CLASSNAME, "__figure"))
121
+ }), figure, (_sections$figureChild2 = sections.figureChildProps) === null || _sections$figureChild2 === void 0 ? void 0 : _sections$figureChild2.children), children && React.createElement(FlexBox, _extends({
100
122
  ref: (_ref5 = sections.contentChild) === null || _ref5 === void 0 ? void 0 : _ref5.ref,
101
123
  orientation: Orientation.vertical,
102
124
  fillSpace: true,
103
- vAlign: forwardedProps.vAlign,
104
- hAlign: forwardedProps.hAlign
125
+ vAlign: contentVAlign
105
126
  }, contentProps, sections.contentChildProps, {
106
- className: classnames(contentProps === null || contentProps === void 0 ? void 0 : contentProps.className, (_sections$contentChil2 = sections.contentChildProps) === null || _sections$contentChil2 === void 0 ? void 0 : _sections$contentChil2.className, "".concat(CLASSNAME, "__content"))
107
- }), (_sections$contentChil3 = sections.contentChildProps) === null || _sections$contentChil3 === void 0 ? void 0 : _sections$contentChil3.children, sections.otherChildren), (actions || ((_sections$actionsChil = sections.actionsChildProps) === null || _sections$actionsChil === void 0 ? void 0 : _sections$actionsChil.children)) && React.createElement(FlexBox, _extends({
127
+ className: classnames(contentProps === null || contentProps === void 0 ? void 0 : contentProps.className, (_sections$contentChil = sections.contentChildProps) === null || _sections$contentChil === void 0 ? void 0 : _sections$contentChil.className, "".concat(CLASSNAME, "__content"))
128
+ }), (_sections$contentChil2 = sections.contentChildProps) === null || _sections$contentChil2 === void 0 ? void 0 : _sections$contentChil2.children, sections.otherChildren), React.createElement(FlexBox, _extends({
108
129
  ref: (_ref6 = sections.actionsChild) === null || _ref6 === void 0 ? void 0 : _ref6.ref,
109
- vAlign: forwardedProps.vAlign,
110
- hAlign: forwardedProps.hAlign
130
+ vAlign: actionsVAlign
111
131
  }, actionsProps, sections.actionsChildProps, {
112
- className: classnames(actionsProps === null || actionsProps === void 0 ? void 0 : actionsProps.className, (_sections$actionsChil2 = sections.actionsChildProps) === null || _sections$actionsChil2 === void 0 ? void 0 : _sections$actionsChil2.className, "".concat(CLASSNAME, "__actions"))
113
- }), actions, (_sections$actionsChil3 = sections.actionsChildProps) === null || _sections$actionsChil3 === void 0 ? void 0 : _sections$actionsChil3.children));
132
+ className: classnames(actionsProps === null || actionsProps === void 0 ? void 0 : actionsProps.className, (_sections$actionsChil = sections.actionsChildProps) === null || _sections$actionsChil === void 0 ? void 0 : _sections$actionsChil.className, "".concat(CLASSNAME, "__actions"))
133
+ }), actions, (_sections$actionsChil2 = sections.actionsChildProps) === null || _sections$actionsChil2 === void 0 ? void 0 : _sections$actionsChil2.children));
114
134
  });
115
135
  BaseGenericBlock.displayName = COMPONENT_NAME;
116
136
  BaseGenericBlock.className = CLASSNAME;
@@ -1 +1 @@
1
- {"version":3,"file":"GenericBlock.js","sources":["../../../src/components/generic-block/GenericBlock.tsx"],"sourcesContent":["import React, { Children, forwardRef, ReactElement, ReactNode } from 'react';\nimport classNames from 'classnames';\nimport isEmpty from 'lodash/isEmpty';\nimport noop from 'lodash/noop';\nimport { Comp, getRootClassName, isComponentType, partitionMulti } from '@lumx/react/utils';\nimport { Orientation, Size, FlexBox, FlexBoxProps } from '@lumx/react';\n\nexport interface GenericBlockProps extends FlexBoxProps {\n /**\n * Component to use as visual element.\n */\n figure?: ReactNode;\n /**\n * Actions to set after the main content.\n */\n actions?: ReactNode;\n /**\n * Main content to display or sections components\n * ({@see GenericBlock.Figure}, {@see GenericBlock.Content} & {@see GenericBlock.Actions})\n */\n children: ReactNode;\n /**\n * Orientation of the 3 sections\n */\n orientation?: FlexBoxProps['orientation'];\n /**\n * Horizontal alignment.\n */\n hAlign?: FlexBoxProps['hAlign'];\n /**\n * Vertical alignment.\n */\n vAlign?: FlexBoxProps['vAlign'];\n /**\n * The props to forward to the content.\n * By default, the content will have the same alignment as wrapper.\n */\n contentProps?: Omit<FlexBoxProps, 'children'>;\n /**\n * props to forward to the actions element.\n */\n actionsProps?: Omit<FlexBoxProps, 'children'>;\n /**\n * props to forward to the figure element.\n */\n figureProps?: Omit<FlexBoxProps, 'children'>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'GenericBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<GenericBlockProps> = {\n gap: Size.big,\n orientation: Orientation.horizontal,\n};\n\ntype BaseGenericBlock = Comp<GenericBlockProps, HTMLDivElement>;\n\ninterface GenericBlock extends BaseGenericBlock {\n /**\n * Use `GenericBlock.Figure` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"figure\" section of the block (instead of using `figure` and `figureProps` props).\n */\n Figure: Comp<FlexBoxProps>;\n /**\n * Use `GenericBlock.Content` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"content\" section of the block (instead of using `content` and `contentProps` props).\n */\n Content: Comp<FlexBoxProps>;\n /**\n * Use `GenericBlock.Actions` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"actions\" section of the block (instead of using `actions` and `actionsProps` props).\n */\n Actions: Comp<FlexBoxProps>;\n}\n\nconst Figure = noop.bind({}) as Comp<FlexBoxProps>;\nconst isFigure = isComponentType(Figure);\n\nconst Content = noop.bind({}) as Comp<FlexBoxProps>;\nconst isContent = isComponentType(Content);\n\nconst Actions = noop.bind({}) as Comp<FlexBoxProps>;\nconst isActions = isComponentType(Actions);\n\n/**\n * The GenericBlock is a layout component made of 3 sections that can be\n * displayed either horizontally of vertically with the same gap between each section.\n *\n * The sections are:\n * - `Figure` => A visual element to display before the main content.\n * - `Content` => The main content displayed\n * - `Actions` => One or more actions to set after the element.\n *\n * @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076\n */\nconst BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {\n const {\n className,\n figure,\n figureProps,\n children,\n actions,\n actionsProps,\n gap,\n orientation,\n contentProps,\n ...forwardedProps\n } = props;\n\n const sections = React.useMemo(() => {\n // Split children by section type\n const [[figureChild], [contentChild], [actionsChild], ...otherChildren] = partitionMulti(\n Children.toArray(children),\n [isFigure, isContent, isActions],\n );\n return {\n figureChild,\n figureChildProps: (figureChild as ReactElement)?.props,\n contentChild,\n contentChildProps: (contentChild as ReactElement)?.props,\n actionsChild,\n actionsChildProps: (actionsChild as ReactElement)?.props,\n otherChildren: otherChildren.filter((child) => !isEmpty(child)),\n };\n }, [children]);\n\n return (\n <FlexBox\n ref={ref}\n className={classNames(className, CLASSNAME)}\n gap={gap}\n orientation={orientation}\n {...forwardedProps}\n >\n {(figure || sections.figureChildProps?.children) && (\n <FlexBox\n ref={(sections.figureChild as any)?.ref}\n vAlign={forwardedProps.vAlign}\n hAlign={forwardedProps.hAlign}\n {...figureProps}\n {...sections.figureChildProps}\n className={classNames(\n figureProps?.className,\n sections.figureChildProps?.className,\n `${CLASSNAME}__figure`,\n )}\n >\n {figure}\n {sections.figureChildProps?.children}\n </FlexBox>\n )}\n\n {(sections.contentChildProps?.children || sections.otherChildren.length > 0) && (\n <FlexBox\n ref={(sections.contentChild as any)?.ref}\n orientation={Orientation.vertical}\n fillSpace\n vAlign={forwardedProps.vAlign}\n hAlign={forwardedProps.hAlign}\n {...contentProps}\n {...sections.contentChildProps}\n className={classNames(\n contentProps?.className,\n sections.contentChildProps?.className,\n `${CLASSNAME}__content`,\n )}\n >\n {sections.contentChildProps?.children}\n {sections.otherChildren}\n </FlexBox>\n )}\n\n {(actions || sections.actionsChildProps?.children) && (\n <FlexBox\n ref={(sections.actionsChild as any)?.ref}\n vAlign={forwardedProps.vAlign}\n hAlign={forwardedProps.hAlign}\n {...actionsProps}\n {...sections.actionsChildProps}\n className={classNames(\n actionsProps?.className,\n sections.actionsChildProps?.className,\n `${CLASSNAME}__actions`,\n )}\n >\n {actions}\n {sections.actionsChildProps?.children}\n </FlexBox>\n )}\n </FlexBox>\n );\n});\nBaseGenericBlock.displayName = COMPONENT_NAME;\nBaseGenericBlock.className = CLASSNAME;\nBaseGenericBlock.defaultProps = DEFAULT_PROPS;\n\nexport const GenericBlock: GenericBlock = Object.assign(BaseGenericBlock, { Figure, Content, Actions });\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","gap","Size","big","orientation","Orientation","horizontal","Figure","noop","bind","isFigure","isComponentType","Content","isContent","Actions","isActions","BaseGenericBlock","forwardRef","props","ref","className","figure","figureProps","children","actions","actionsProps","contentProps","forwardedProps","sections","React","useMemo","partitionMulti","Children","toArray","figureChild","contentChild","actionsChild","otherChildren","figureChildProps","contentChildProps","actionsChildProps","filter","child","isEmpty","classNames","vAlign","hAlign","length","vertical","displayName","defaultProps","GenericBlock","Object","assign"],"mappings":";;;;;;;;;;;;AAgDA;;;AAGA,IAAMA,cAAc,GAAG,cAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAyC,GAAG;AAC9CC,EAAAA,GAAG,EAAEC,IAAI,CAACC,GADoC;AAE9CC,EAAAA,WAAW,EAAEC,WAAW,CAACC;AAFqB,CAAlD;AAyBA,IAAMC,MAAM,GAAGC,IAAI,CAACC,IAAL,CAAU,EAAV,CAAf;AACA,IAAMC,QAAQ,GAAGC,eAAe,CAACJ,MAAD,CAAhC;AAEA,IAAMK,OAAO,GAAGJ,IAAI,CAACC,IAAL,CAAU,EAAV,CAAhB;AACA,IAAMI,SAAS,GAAGF,eAAe,CAACC,OAAD,CAAjC;AAEA,IAAME,OAAO,GAAGN,IAAI,CAACC,IAAL,CAAU,EAAV,CAAhB;AACA,IAAMM,SAAS,GAAGJ,eAAe,CAACG,OAAD,CAAjC;AAEA;;;;;;;;;;;;AAWA,IAAME,gBAAkC,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA;;AAAA,MAE9DC,SAF8D,GAY9DF,KAZ8D,CAE9DE,SAF8D;AAAA,MAG9DC,MAH8D,GAY9DH,KAZ8D,CAG9DG,MAH8D;AAAA,MAI9DC,WAJ8D,GAY9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A4BnB,SAFX,YAGdtB,SAHc;AARzB,gCAcK8B,QAAQ,CAACW,iBAdd,2DAcK,uBAA4BhB,QAdjC,EAeKK,QAAQ,CAACS,aAfd,CA1BR,EA6CK,CAACb,OAAO,8BAAII,QAAQ,CAACY,iBAAb,0DAAI,sBAA4BjB,QAAhC,CAAR,KACG,oBAAC,OAAD;AACI,IAAA,GAAG,WAAGK,QAAQ,CAACQ,YAAZ,0CAAE,MAAgCjB,GADzC;AAEI,IAAA,MAAM,EAAEQ,cAAc,CAACkB,MAF3B;AAGI,IAAA,MAAM,EAAElB,cAAc,CAACmB;AAH3B,KAIQrB,YAJR,EAKQG,QAAQ,CAACY,iBALjB;AAMI,IAAA,SAAS,EAAEI,UAAU,CACjBnB,YADiB,aACjBA,YADiB,uBACjBA,YAAY,CAAEL,SADG,4BAEjBQ,QAAQ,CAACY,iBAFQ,2DAEjB,uBAA4BpB,SAFX,YAGdtB,SAHc;AANzB,MAYK0B,OAZL,4BAaKI,QAAQ,CAACY,iBAbd,2DAaK,uBAA4BjB,QAbjC,CA9CR,CADJ;AAiEH,CAhGoD,CAArD;AAiGAP,gBAAgB,CAACiC,WAAjB,GAA+BpD,cAA/B;AACAmB,gBAAgB,CAACI,SAAjB,GAA6BtB,SAA7B;AACAkB,gBAAgB,CAACkC,YAAjB,GAAgClD,aAAhC;IAEamD,YAA0B,GAAGC,MAAM,CAACC,MAAP,CAAcrC,gBAAd,EAAgC;AAAET,EAAAA,MAAM,EAANA,MAAF;AAAUK,EAAAA,OAAO,EAAPA,OAAV;AAAmBE,EAAAA,OAAO,EAAPA;AAAnB,CAAhC;;;;"}
1
+ {"version":3,"file":"GenericBlock.js","sources":["../../../src/components/generic-block/GenericBlock.tsx"],"sourcesContent":["import React, { Children, forwardRef, ReactElement, ReactNode } from 'react';\nimport classNames from 'classnames';\nimport { Comp, getRootClassName, isComponentType, partitionMulti } from '@lumx/react/utils';\nimport { Orientation, Size, FlexBox, FlexBoxProps, Alignment, HorizontalAlignment } from '@lumx/react';\n\nexport interface GenericBlockProps extends FlexBoxProps {\n /**\n * Component to use as visual element.\n */\n figure?: ReactNode;\n /**\n * Actions to set after the main content.\n */\n actions?: ReactNode;\n /**\n * Main content to display or sections components\n * ({@see GenericBlock.Figure}, {@see GenericBlock.Content} & {@see GenericBlock.Actions})\n */\n children: ReactNode;\n /**\n * Orientation of the 3 sections\n */\n orientation?: FlexBoxProps['orientation'];\n /**\n * Horizontal alignment.\n */\n hAlign?: FlexBoxProps['hAlign'];\n /**\n * Vertical alignment.\n */\n vAlign?: FlexBoxProps['vAlign'];\n /**\n * The props to forward to the content.\n * By default, the content will have the same alignment as wrapper.\n */\n contentProps?: Omit<FlexBoxProps, 'children'>;\n /**\n * props to forward to the actions element.\n */\n actionsProps?: Omit<FlexBoxProps, 'children'>;\n /**\n * props to forward to the figure element.\n */\n figureProps?: Omit<FlexBoxProps, 'children'>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'GenericBlock';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<GenericBlockProps> = {\n gap: Size.regular,\n orientation: Orientation.vertical,\n hAlign: Alignment.center,\n vAlign: Alignment.center,\n};\n\ntype BaseGenericBlock = Comp<GenericBlockProps, HTMLDivElement>;\n\ninterface GenericBlock extends BaseGenericBlock {\n /**\n * Use `GenericBlock.Figure` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"figure\" section of the block (instead of using `figure` and `figureProps` props).\n */\n Figure: Comp<FlexBoxProps>;\n /**\n * Use `GenericBlock.Content` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"content\" section of the block (instead of using `content` and `contentProps` props).\n */\n Content: Comp<FlexBoxProps>;\n /**\n * Use `GenericBlock.Actions` component as children of the `GenericBlock` component as an alternative way to inject\n * the \"actions\" section of the block (instead of using `actions` and `actionsProps` props).\n */\n Actions: Comp<FlexBoxProps>;\n}\n\nconst Figure = (() => null) as any;\nconst isFigure = isComponentType(Figure);\n\nconst Content = (() => null) as any;\nconst isContent = isComponentType(Content);\n\nconst Actions = (() => null) as any;\nconst isActions = isComponentType(Actions);\n\n/**\n * The GenericBlock is a layout component made of 3 sections that can be\n * displayed either horizontally of vertically with the same gap between each section.\n *\n * The sections are:\n * * (Optional) `Figure` => A visual element to display before the main content.\n * * (Required) `Content` => The main content displayed\n * * (Optional) `Actions` => One or more actions to set after the element.\n *\n * @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076\n */\nconst BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {\n const {\n className,\n figure,\n figureProps,\n children,\n actions,\n actionsProps,\n gap,\n orientation,\n contentProps,\n ...forwardedProps\n } = props;\n\n const sections = React.useMemo(() => {\n // Split children by section type\n const [[figureChild], [contentChild], [actionsChild], ...otherChildren] = partitionMulti(\n Children.toArray(children),\n [isFigure, isContent, isActions],\n );\n return {\n figureChild,\n figureChildProps: (figureChild as ReactElement)?.props || {},\n contentChild,\n contentChildProps: (contentChild as ReactElement)?.props || {},\n actionsChild,\n actionsChildProps: (actionsChild as ReactElement)?.props || {},\n otherChildren,\n };\n }, [children]);\n\n let actionsVAlign: HorizontalAlignment = Alignment.center;\n if (orientation === Orientation.horizontal) {\n actionsVAlign = Alignment.right;\n }\n let contentVAlign: HorizontalAlignment = Alignment.center;\n if (orientation === Orientation.horizontal) {\n contentVAlign = Alignment.left;\n }\n\n return (\n <FlexBox\n ref={ref}\n className={classNames(className, CLASSNAME)}\n gap={gap}\n orientation={orientation}\n {...forwardedProps}\n >\n <FlexBox\n ref={(sections.figureChild as any)?.ref}\n {...figureProps}\n {...sections.figureChildProps}\n className={classNames(\n figureProps?.className,\n sections.figureChildProps?.className,\n `${CLASSNAME}__figure`,\n )}\n >\n {figure}\n {sections.figureChildProps?.children}\n </FlexBox>\n\n {children && (\n <FlexBox\n ref={(sections.contentChild as any)?.ref}\n orientation={Orientation.vertical}\n fillSpace\n vAlign={contentVAlign}\n {...contentProps}\n {...sections.contentChildProps}\n className={classNames(\n contentProps?.className,\n sections.contentChildProps?.className,\n `${CLASSNAME}__content`,\n )}\n >\n {sections.contentChildProps?.children}\n {sections.otherChildren}\n </FlexBox>\n )}\n\n <FlexBox\n ref={(sections.actionsChild as any)?.ref}\n vAlign={actionsVAlign}\n {...actionsProps}\n {...sections.actionsChildProps}\n className={classNames(\n actionsProps?.className,\n sections.actionsChildProps?.className,\n `${CLASSNAME}__actions`,\n )}\n >\n {actions}\n {sections.actionsChildProps?.children}\n </FlexBox>\n </FlexBox>\n );\n});\nBaseGenericBlock.displayName = COMPONENT_NAME;\nBaseGenericBlock.className = CLASSNAME;\nBaseGenericBlock.defaultProps = DEFAULT_PROPS;\n\nexport const GenericBlock: GenericBlock = Object.assign(BaseGenericBlock, { Figure, Content, Actions });\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","gap","Size","regular","orientation","Orientation","vertical","hAlign","Alignment","center","vAlign","Figure","isFigure","isComponentType","Content","isContent","Actions","isActions","BaseGenericBlock","forwardRef","props","ref","className","figure","figureProps","children","actions","actionsProps","contentProps","forwardedProps","sections","React","useMemo","partitionMulti","Children","toArray","figureChild","contentChild","actionsChild","otherChildren","figureChildProps","contentChildProps","actionsChildProps","actionsVAlign","horizontal","right","contentVAlign","left","classNames","displayName","defaultProps","GenericBlock","Object","assign"],"mappings":";;;;;;;;;;;;AA8CA;;;AAGA,IAAMA,cAAc,GAAG,cAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAyC,GAAG;AAC9CC,EAAAA,GAAG,EAAEC,IAAI,CAACC,OADoC;AAE9CC,EAAAA,WAAW,EAAEC,WAAW,CAACC,QAFqB;AAG9CC,EAAAA,MAAM,EAAEC,SAAS,CAACC,MAH4B;AAI9CC,EAAAA,MAAM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AAgB,CAACgC,YAAjB,GAAgClD,aAAhC;IAEamD,YAA0B,GAAGC,MAAM,CAACC,MAAP,CAAcnC,gBAAd,EAAgC;AAAEP,EAAAA,MAAM,EAANA,MAAF;AAAUG,EAAAA,OAAO,EAAPA,OAAV;AAAmBE,EAAAA,OAAO,EAAPA;AAAnB,CAAhC;;;;"}
package/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^2.2.22-alpha-fix-generic-block.2",
11
- "@lumx/icons": "^2.2.22-alpha-fix-generic-block.2",
10
+ "@lumx/core": "^2.2.22-alpha-dart-sass.1",
11
+ "@lumx/icons": "^2.2.22-alpha-dart-sass.1",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.2.6",
@@ -120,6 +120,6 @@
120
120
  "build:storybook": "cd storybook && ./build"
121
121
  },
122
122
  "sideEffects": false,
123
- "version": "2.2.22-alpha-fix-generic-block.2",
124
- "gitHead": "4670b30d082cf206ed04d3fc365825d17048b2de"
123
+ "version": "2.2.22-alpha-dart-sass.1",
124
+ "gitHead": "c08fe7cee4e0d7b083670d4de6c2bd5e3807d7db"
125
125
  }
@@ -18,7 +18,7 @@ const flexViewKnobConfigs: Array<
18
18
  ['fillSpace', boolean],
19
19
  ['noShrink', boolean],
20
20
  ['wrap', boolean],
21
- ['gap', select, [DEFAULT_PROPS.gap, Size.tiny, Size.regular, Size.medium, Size.big, Size.huge]],
21
+ ['gap', select, [DEFAULT_PROPS.gap, Size.regular, Size.medium, Size.big, Size.huge]],
22
22
  ['hAlign', select, [DEFAULT_PROPS.hAlign, Alignment.center, Alignment.top, Alignment.bottom]],
23
23
  ['vAlign', select, [DEFAULT_PROPS.vAlign, Alignment.center, Alignment.right, Alignment.left]],
24
24
  ['orientation', select, [undefined, Orientation.horizontal, Orientation.vertical]],
@@ -6,7 +6,7 @@ import React, { forwardRef, ReactNode } from 'react';
6
6
  import { Size } from '..';
7
7
 
8
8
  export type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;
9
- export type GapSize = Extract<Size, 'tiny' | 'regular' | 'medium' | 'big' | 'huge'>;
9
+ export type GapSize = Extract<Size, 'regular' | 'medium' | 'big' | 'huge'>;
10
10
 
11
11
  /**
12
12
  * Defines the props of the component.
@@ -0,0 +1,90 @@
1
+ import React from 'react';
2
+ import { mdiPencil } from '@lumx/icons';
3
+ import { GenericBlock, Button, Icon, Size, Orientation, Alignment } from '@lumx/react';
4
+ import { HasTheme } from '@lumx/react/utils';
5
+
6
+ export default { title: 'LumX components/generic-block/GenericBlock' };
7
+
8
+ const redBorderStyle = { border: '1px solid red' };
9
+
10
+ /**
11
+ * Fill sections using props
12
+ */
13
+ export const SectionsInProps = ({ theme }: HasTheme) => (
14
+ <GenericBlock
15
+ figure={<Icon icon={mdiPencil} size={Size.m} />}
16
+ actionsProps={{ style: redBorderStyle }}
17
+ figureProps={{ style: redBorderStyle }}
18
+ contentProps={{ style: redBorderStyle }}
19
+ actions={<Button theme={theme}>Button</Button>}
20
+ >
21
+ Content
22
+ </GenericBlock>
23
+ );
24
+
25
+ /**
26
+ * Fill sections using child section components.
27
+ */
28
+ export const SectionsInChildren = ({ theme }: HasTheme) => (
29
+ <GenericBlock>
30
+ <GenericBlock.Figure style={redBorderStyle}>
31
+ <Icon icon={mdiPencil} size={Size.m} />
32
+ </GenericBlock.Figure>
33
+ <GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
34
+ <GenericBlock.Actions style={redBorderStyle}>
35
+ <Button theme={theme}>Button</Button>
36
+ </GenericBlock.Actions>
37
+ </GenericBlock>
38
+ );
39
+
40
+ export const Vertical = ({ theme }: HasTheme) => (
41
+ <GenericBlock orientation={Orientation.vertical}>
42
+ <GenericBlock.Figure style={redBorderStyle}>
43
+ <Icon icon={mdiPencil} size={Size.m} />
44
+ </GenericBlock.Figure>
45
+ <GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
46
+ <GenericBlock.Actions fillSpace style={redBorderStyle}>
47
+ <Button theme={theme}>Button</Button>
48
+ </GenericBlock.Actions>
49
+ </GenericBlock>
50
+ );
51
+
52
+ export const Horizontal = ({ theme }: HasTheme) => (
53
+ <GenericBlock orientation={Orientation.horizontal}>
54
+ <GenericBlock.Figure style={redBorderStyle}>
55
+ <Icon icon={mdiPencil} size={Size.m} />
56
+ </GenericBlock.Figure>
57
+ <GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
58
+ <GenericBlock.Actions style={redBorderStyle}>
59
+ <Button theme={theme}>Button</Button>
60
+ </GenericBlock.Actions>
61
+ </GenericBlock>
62
+ );
63
+
64
+ export const HorizontalTop = ({ theme }: HasTheme) => (
65
+ <GenericBlock orientation={Orientation.horizontal} hAlign={Alignment.top}>
66
+ <GenericBlock.Figure style={redBorderStyle}>
67
+ <Icon icon={mdiPencil} size={Size.m} />
68
+ </GenericBlock.Figure>
69
+ <GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
70
+ <GenericBlock.Actions style={redBorderStyle}>
71
+ <Button theme={theme}>Button</Button>
72
+ </GenericBlock.Actions>
73
+ </GenericBlock>
74
+ );
75
+
76
+ export const GapSizes = ({ theme }: HasTheme) =>
77
+ [Size.regular, Size.big, Size.huge].map((gap) => (
78
+ <GenericBlock key={gap} orientation={Orientation.vertical} gap={gap} style={{ marginBottom: 40 }}>
79
+ <GenericBlock.Figure style={redBorderStyle}>
80
+ <Icon icon={mdiPencil} size={Size.m} />
81
+ </GenericBlock.Figure>
82
+ <GenericBlock.Content style={redBorderStyle}>
83
+ <h2>{gap} gap size</h2>
84
+ <p>block description</p>
85
+ </GenericBlock.Content>
86
+ <GenericBlock.Actions style={redBorderStyle}>
87
+ <Button theme={theme}>Button</Button>
88
+ </GenericBlock.Actions>
89
+ </GenericBlock>
90
+ ));
@@ -3,7 +3,7 @@ import { mount, shallow } from 'enzyme';
3
3
  import 'jest-enzyme';
4
4
  import { commonTestsSuite } from '@lumx/react/testing/utils';
5
5
 
6
- import { GenericBlock, GenericBlockProps } from '.';
6
+ import { GenericBlock, GenericBlockProps } from './GenericBlock';
7
7
 
8
8
  const CLASSNAME = GenericBlock.className as string;
9
9
 
@@ -20,51 +20,43 @@ describe(`<${GenericBlock.displayName}>`, () => {
20
20
  // 1. Test render via snapshot.
21
21
  describe('Snapshots and structure', () => {
22
22
  it('should render default', () => {
23
- const wrapper = shallow(
24
- <GenericBlock figure="figure" actions="actions">
25
- Content
26
- </GenericBlock>,
27
- );
23
+ const wrapper = shallow(<GenericBlock>Content</GenericBlock>);
28
24
 
29
- expect(wrapper.prop('gap')).toBe('big');
30
- expect(wrapper.prop('orientation')).toBe('horizontal');
25
+ expect(wrapper.prop('gap')).toBe('regular');
26
+ expect(wrapper.prop('hAlign')).toBe('center');
27
+ expect(wrapper.prop('orientation')).toBe('vertical');
28
+ expect(wrapper.prop('vAlign')).toBe('center');
31
29
 
32
30
  const figure = wrapper.find('.lumx-generic-block__figure');
33
- expect(figure).toHaveLength(1);
31
+ expect(figure).toBeDefined();
34
32
 
35
33
  const content = wrapper.find('.lumx-generic-block__content');
36
- expect(content).toHaveLength(1);
37
34
  expect(content.prop('fillSpace')).toBe(true);
35
+ expect(content.prop('vAlign')).toBe('center');
38
36
  expect(content.prop('orientation')).toBe('vertical');
39
37
 
40
38
  const actions = wrapper.find('.lumx-generic-block__actions');
41
- expect(actions).toHaveLength(1);
39
+ expect(actions.prop('vAlign')).toBe('center');
42
40
  });
43
41
 
44
- it('should forward vAlign & hAlign', () => {
45
- const wrapper = shallow(
46
- <GenericBlock figure="figure" actions="actions" vAlign="left" hAlign="bottom">
47
- Content
48
- </GenericBlock>,
49
- );
42
+ it('should render horizontal', () => {
43
+ const wrapper = shallow(<GenericBlock orientation="horizontal">Content</GenericBlock>);
50
44
 
51
- expect(wrapper.prop('vAlign')).toBe('left');
52
- expect(wrapper.prop('hAlign')).toBe('bottom');
45
+ expect(wrapper.prop('gap')).toBe('regular');
46
+ expect(wrapper.prop('hAlign')).toBe('center');
47
+ expect(wrapper.prop('orientation')).toBe('horizontal');
48
+ expect(wrapper.prop('vAlign')).toBe('center');
53
49
 
54
50
  const figure = wrapper.find('.lumx-generic-block__figure');
55
- expect(figure).toHaveLength(1);
56
- expect(figure.prop('vAlign')).toBe('left');
57
- expect(figure.prop('hAlign')).toBe('bottom');
51
+ expect(figure).toBeDefined();
58
52
 
59
53
  const content = wrapper.find('.lumx-generic-block__content');
60
- expect(content).toHaveLength(1);
54
+ expect(content.prop('fillSpace')).toBe(true);
61
55
  expect(content.prop('vAlign')).toBe('left');
62
- expect(content.prop('hAlign')).toBe('bottom');
56
+ expect(content.prop('orientation')).toBe('vertical');
63
57
 
64
58
  const actions = wrapper.find('.lumx-generic-block__actions');
65
- expect(actions).toHaveLength(1);
66
- expect(actions.prop('vAlign')).toBe('left');
67
- expect(actions.prop('hAlign')).toBe('bottom');
59
+ expect(actions.prop('vAlign')).toBe('right');
68
60
  });
69
61
 
70
62
  it('should combine figure props', () => {
@@ -82,9 +74,6 @@ describe(`<${GenericBlock.displayName}>`, () => {
82
74
  expect(figure.prop('fillSpace')).toBe(true);
83
75
  expect(figure.prop('vAlign')).toBe('left');
84
76
  expect(figure).toHaveText('Figure 1Figure 2');
85
-
86
- expect(wrapper.find('.lumx-generic-block__content')).toHaveLength(0);
87
- expect(wrapper.find('.lumx-generic-block__actions')).toHaveLength(0);
88
77
  });
89
78
 
90
79
  it('should combine content props', () => {
@@ -103,9 +92,6 @@ describe(`<${GenericBlock.displayName}>`, () => {
103
92
  expect(content.prop('fillSpace')).toBe(true);
104
93
  expect(content.prop('vAlign')).toBe('left');
105
94
  expect(content).toHaveText('Content 2Content 1');
106
-
107
- expect(wrapper.find('.lumx-generic-block__figure')).toHaveLength(0);
108
- expect(wrapper.find('.lumx-generic-block__actions')).toHaveLength(0);
109
95
  });
110
96
 
111
97
  it('should combine actions props', () => {
@@ -123,9 +109,6 @@ describe(`<${GenericBlock.displayName}>`, () => {
123
109
  expect(actions.prop('fillSpace')).toBe(true);
124
110
  expect(actions.prop('vAlign')).toBe('left');
125
111
  expect(actions).toHaveText('Actions 1Actions 2');
126
-
127
- expect(wrapper.find('.lumx-generic-block__figure')).toHaveLength(0);
128
- expect(wrapper.find('.lumx-generic-block__content')).toHaveLength(0);
129
112
  });
130
113
 
131
114
  it('should forward refs', () => {
@@ -1,9 +1,7 @@
1
1
  import React, { Children, forwardRef, ReactElement, ReactNode } from 'react';
2
2
  import classNames from 'classnames';
3
- import isEmpty from 'lodash/isEmpty';
4
- import noop from 'lodash/noop';
5
3
  import { Comp, getRootClassName, isComponentType, partitionMulti } from '@lumx/react/utils';
6
- import { Orientation, Size, FlexBox, FlexBoxProps } from '@lumx/react';
4
+ import { Orientation, Size, FlexBox, FlexBoxProps, Alignment, HorizontalAlignment } from '@lumx/react';
7
5
 
8
6
  export interface GenericBlockProps extends FlexBoxProps {
9
7
  /**
@@ -60,8 +58,10 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
60
58
  * Component default props.
61
59
  */
62
60
  const DEFAULT_PROPS: Partial<GenericBlockProps> = {
63
- gap: Size.big,
64
- orientation: Orientation.horizontal,
61
+ gap: Size.regular,
62
+ orientation: Orientation.vertical,
63
+ hAlign: Alignment.center,
64
+ vAlign: Alignment.center,
65
65
  };
66
66
 
67
67
  type BaseGenericBlock = Comp<GenericBlockProps, HTMLDivElement>;
@@ -84,13 +84,13 @@ interface GenericBlock extends BaseGenericBlock {
84
84
  Actions: Comp<FlexBoxProps>;
85
85
  }
86
86
 
87
- const Figure = noop.bind({}) as Comp<FlexBoxProps>;
87
+ const Figure = (() => null) as any;
88
88
  const isFigure = isComponentType(Figure);
89
89
 
90
- const Content = noop.bind({}) as Comp<FlexBoxProps>;
90
+ const Content = (() => null) as any;
91
91
  const isContent = isComponentType(Content);
92
92
 
93
- const Actions = noop.bind({}) as Comp<FlexBoxProps>;
93
+ const Actions = (() => null) as any;
94
94
  const isActions = isComponentType(Actions);
95
95
 
96
96
  /**
@@ -98,9 +98,9 @@ const isActions = isComponentType(Actions);
98
98
  * displayed either horizontally of vertically with the same gap between each section.
99
99
  *
100
100
  * The sections are:
101
- * - `Figure` => A visual element to display before the main content.
102
- * - `Content` => The main content displayed
103
- * - `Actions` => One or more actions to set after the element.
101
+ * * (Optional) `Figure` => A visual element to display before the main content.
102
+ * * (Required) `Content` => The main content displayed
103
+ * * (Optional) `Actions` => One or more actions to set after the element.
104
104
  *
105
105
  * @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076
106
106
  */
@@ -126,15 +126,24 @@ const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
126
126
  );
127
127
  return {
128
128
  figureChild,
129
- figureChildProps: (figureChild as ReactElement)?.props,
129
+ figureChildProps: (figureChild as ReactElement)?.props || {},
130
130
  contentChild,
131
- contentChildProps: (contentChild as ReactElement)?.props,
131
+ contentChildProps: (contentChild as ReactElement)?.props || {},
132
132
  actionsChild,
133
- actionsChildProps: (actionsChild as ReactElement)?.props,
134
- otherChildren: otherChildren.filter((child) => !isEmpty(child)),
133
+ actionsChildProps: (actionsChild as ReactElement)?.props || {},
134
+ otherChildren,
135
135
  };
136
136
  }, [children]);
137
137
 
138
+ let actionsVAlign: HorizontalAlignment = Alignment.center;
139
+ if (orientation === Orientation.horizontal) {
140
+ actionsVAlign = Alignment.right;
141
+ }
142
+ let contentVAlign: HorizontalAlignment = Alignment.center;
143
+ if (orientation === Orientation.horizontal) {
144
+ contentVAlign = Alignment.left;
145
+ }
146
+
138
147
  return (
139
148
  <FlexBox
140
149
  ref={ref}
@@ -143,31 +152,26 @@ const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
143
152
  orientation={orientation}
144
153
  {...forwardedProps}
145
154
  >
146
- {(figure || sections.figureChildProps?.children) && (
147
- <FlexBox
148
- ref={(sections.figureChild as any)?.ref}
149
- vAlign={forwardedProps.vAlign}
150
- hAlign={forwardedProps.hAlign}
151
- {...figureProps}
152
- {...sections.figureChildProps}
153
- className={classNames(
154
- figureProps?.className,
155
- sections.figureChildProps?.className,
156
- `${CLASSNAME}__figure`,
157
- )}
158
- >
159
- {figure}
160
- {sections.figureChildProps?.children}
161
- </FlexBox>
162
- )}
155
+ <FlexBox
156
+ ref={(sections.figureChild as any)?.ref}
157
+ {...figureProps}
158
+ {...sections.figureChildProps}
159
+ className={classNames(
160
+ figureProps?.className,
161
+ sections.figureChildProps?.className,
162
+ `${CLASSNAME}__figure`,
163
+ )}
164
+ >
165
+ {figure}
166
+ {sections.figureChildProps?.children}
167
+ </FlexBox>
163
168
 
164
- {(sections.contentChildProps?.children || sections.otherChildren.length > 0) && (
169
+ {children && (
165
170
  <FlexBox
166
171
  ref={(sections.contentChild as any)?.ref}
167
172
  orientation={Orientation.vertical}
168
173
  fillSpace
169
- vAlign={forwardedProps.vAlign}
170
- hAlign={forwardedProps.hAlign}
174
+ vAlign={contentVAlign}
171
175
  {...contentProps}
172
176
  {...sections.contentChildProps}
173
177
  className={classNames(
@@ -181,23 +185,20 @@ const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
181
185
  </FlexBox>
182
186
  )}
183
187
 
184
- {(actions || sections.actionsChildProps?.children) && (
185
- <FlexBox
186
- ref={(sections.actionsChild as any)?.ref}
187
- vAlign={forwardedProps.vAlign}
188
- hAlign={forwardedProps.hAlign}
189
- {...actionsProps}
190
- {...sections.actionsChildProps}
191
- className={classNames(
192
- actionsProps?.className,
193
- sections.actionsChildProps?.className,
194
- `${CLASSNAME}__actions`,
195
- )}
196
- >
197
- {actions}
198
- {sections.actionsChildProps?.children}
199
- </FlexBox>
200
- )}
188
+ <FlexBox
189
+ ref={(sections.actionsChild as any)?.ref}
190
+ vAlign={actionsVAlign}
191
+ {...actionsProps}
192
+ {...sections.actionsChildProps}
193
+ className={classNames(
194
+ actionsProps?.className,
195
+ sections.actionsChildProps?.className,
196
+ `${CLASSNAME}__actions`,
197
+ )}
198
+ >
199
+ {actions}
200
+ {sections.actionsChildProps?.children}
201
+ </FlexBox>
201
202
  </FlexBox>
202
203
  );
203
204
  });
package/types.d.ts CHANGED
@@ -1096,7 +1096,7 @@ export interface FlagProps extends GenericProps, HasTheme {
1096
1096
  */
1097
1097
  export declare const Flag: Comp<FlagProps, HTMLDivElement>;
1098
1098
  export declare type MarginAutoAlignment = Extract<Alignment, "top" | "bottom" | "right" | "left">;
1099
- export declare type GapSize = Extract<Size, "tiny" | "regular" | "medium" | "big" | "huge">;
1099
+ export declare type GapSize = Extract<Size, "regular" | "medium" | "big" | "huge">;
1100
1100
  /**
1101
1101
  * Defines the props of the component.
1102
1102
  */
@@ -1,106 +0,0 @@
1
- import React from 'react';
2
- import { mdiPencil } from '@lumx/icons';
3
- import { GenericBlock, Button, Icon, Size } from '@lumx/react';
4
-
5
- export default { title: 'LumX components/generic-block/GenericBlock' };
6
-
7
- const redBorderStyle = { border: '1px solid red' };
8
-
9
- export const SectionsInProps = ({ theme }) => (
10
- <GenericBlock
11
- figure={<Icon icon={mdiPencil} size={Size.m} />}
12
- actionsProps={{ style: redBorderStyle }}
13
- figureProps={{ style: redBorderStyle }}
14
- contentProps={{ style: redBorderStyle }}
15
- actions={<Button theme={theme}>Button</Button>}
16
- >
17
- Content
18
- </GenericBlock>
19
- );
20
-
21
- export const SectionsInChildren = ({ theme }) => (
22
- <GenericBlock>
23
- <GenericBlock.Figure style={redBorderStyle}>
24
- <Icon icon={mdiPencil} size={Size.m} />
25
- </GenericBlock.Figure>
26
- <GenericBlock.Content style={redBorderStyle}>Content</GenericBlock.Content>
27
- <GenericBlock.Actions style={redBorderStyle}>
28
- <Button theme={theme}>Button</Button>
29
- </GenericBlock.Actions>
30
- </GenericBlock>
31
- );
32
-
33
- const Template = ({ theme, ...props }) => (
34
- <GenericBlock {...props}>
35
- <GenericBlock.Figure style={redBorderStyle} {...props.figureProps}>
36
- <Icon icon={mdiPencil} size={Size.m} />
37
- </GenericBlock.Figure>
38
- <GenericBlock.Content style={redBorderStyle} {...props.contentProps}>
39
- {props.content || 'Content'}
40
- </GenericBlock.Content>
41
- <GenericBlock.Actions style={redBorderStyle} {...props.actionsProps}>
42
- <Button theme={theme}>Button</Button>
43
- </GenericBlock.Actions>
44
- </GenericBlock>
45
- );
46
-
47
- export const Vertical = Template.bind({});
48
- Vertical.args = {
49
- orientation: 'vertical',
50
- };
51
-
52
- export const VerticalAlignCenter = Template.bind({});
53
- VerticalAlignCenter.args = {
54
- orientation: 'vertical',
55
- vAlign: 'center',
56
- };
57
-
58
- export const VerticalOverflow = Template.bind({});
59
- VerticalOverflow.args = {
60
- orientation: 'vertical',
61
- style: { width: 300 },
62
- content: (
63
- <span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
64
- _________________________________________________________________
65
- </span>
66
- ),
67
- };
68
-
69
- export const Horizontal = Template.bind({});
70
- Horizontal.args = {
71
- orientation: 'horizontal',
72
- };
73
-
74
- export const HorizontalAlignRightBottom = Template.bind({});
75
- HorizontalAlignRightBottom.args = {
76
- orientation: 'horizontal',
77
- vAlign: 'right',
78
- hAlign: 'bottom',
79
- };
80
-
81
- export const HorizontalOverflow = Template.bind({});
82
- HorizontalOverflow.args = {
83
- orientation: 'horizontal',
84
- style: { width: 300 },
85
- content: (
86
- <span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
87
- _________________________________________________________________
88
- </span>
89
- ),
90
- };
91
-
92
- export const GapSizes = ({ theme }) =>
93
- [Size.regular, Size.big, Size.huge].map((gap) => (
94
- <GenericBlock key={gap} orientation="vertical" gap={gap} style={{ marginBottom: 40 }}>
95
- <GenericBlock.Figure style={redBorderStyle}>
96
- <Icon icon={mdiPencil} size={Size.m} />
97
- </GenericBlock.Figure>
98
- <GenericBlock.Content style={redBorderStyle}>
99
- <h2>{gap} gap size</h2>
100
- <p>block description</p>
101
- </GenericBlock.Content>
102
- <GenericBlock.Actions style={redBorderStyle}>
103
- <Button theme={theme}>Button</Button>
104
- </GenericBlock.Actions>
105
- </GenericBlock>
106
- ));