@mailstep/design-system 0.7.59 → 0.7.61-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.7.59",
3
+ "version": "0.7.61-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -15,9 +15,13 @@ var DataRow = function (_a) {
15
15
  }
16
16
  }, [onRowAction, allowRowSelectOnAction, onUxChange]);
17
17
  var handleRowClick = React.useCallback(function (e) {
18
+ var _a;
18
19
  // test whether I should trigger event or not (because of possible button/link/input/etc in cell)
19
20
  var classes = Object.values(e.target.classList);
20
- if (!classes.includes('dataRow') && !classes.includes('cell'))
21
+ // find children of parent that has propagation attribute
22
+ var parent = e.target.closest('.cell');
23
+ var canPropagation = ((_a = parent === null || parent === void 0 ? void 0 : parent.querySelectorAll('[data-propagation="true"]')) === null || _a === void 0 ? void 0 : _a.length) > 0;
24
+ if (!classes.includes('dataRow') && !classes.includes('cell') && !canPropagation)
21
25
  return;
22
26
  if (onUxChange && allowRowSelect)
23
27
  onUxChange('selectedRow', rowData.id);
@@ -1,4 +1,4 @@
1
- import { FlagAppearanceType } from '../../../../Elements/HighlightBox/HighlightBox';
1
+ import type { FlagAppearanceType } from '../../../../Elements/HighlightBox/HighlightBox';
2
2
  type Props = {
3
3
  value: string;
4
4
  appearanceMap: Record<string, FlagAppearanceType>;
@@ -15,8 +15,8 @@ var __assign = (this && this.__assign) || function () {
15
15
  };
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { useMemo } from 'react';
18
- import styled from '@xstyled/styled-components';
19
18
  import HighlightBox from '../../../../Elements/HighlightBox';
19
+ import styled from '@xstyled/styled-components';
20
20
  var Center = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"], ["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"])));
21
21
  export var EnumInCell = function (_a) {
22
22
  var value = _a.value, enumObj = _a.enumObj, appearanceMap = _a.appearanceMap, size = _a.size;
@@ -28,6 +28,6 @@ export var EnumInCell = function (_a) {
28
28
  }, [appearanceMap, value]);
29
29
  if (!finalLabel)
30
30
  return null;
31
- return (_jsx(Center, { children: _jsx(HighlightBox, __assign({}, coloringProp, { size: size, prefix: "grid", children: finalLabel })) }));
31
+ return (_jsx(Center, { "data-propagation": "true", children: _jsx(HighlightBox, __assign({}, coloringProp, { size: size, prefix: "grid", children: finalLabel })) }));
32
32
  };
33
33
  var templateObject_1;
@@ -0,0 +1,4 @@
1
+ import type { DataCellProps } from '../../types';
2
+ export declare const ComplexCell: (props: DataCellProps<{
3
+ id: string;
4
+ }>) => JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
3
+ export var ComplexCell = function (props) {
4
+ var handleActionClick = useCallback(function () {
5
+ var _a;
6
+ if (props.onRowAction) {
7
+ (_a = props.onRowAction(props.rowData.id, 'get_invoice', null)) === null || _a === void 0 ? void 0 : _a.catch(function (error) {
8
+ console.error(error);
9
+ });
10
+ }
11
+ }, [props]);
12
+ return _jsxs("button", { onClick: handleActionClick, children: [" download ", props.rowData.id, " "] });
13
+ };
@@ -0,0 +1,6 @@
1
+ import type { DataCellProps } from '../../types';
2
+ type CellProps = DataCellProps<{
3
+ enumColumn: string;
4
+ }>;
5
+ export declare const EnumCellExample: ({ rowData }: CellProps) => JSX.Element;
6
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { EnumInCell } from '../../components/gridCells/EnumInCell';
3
+ var packagingTypeAppearance = {
4
+ 'option A': 'neutralSubtle',
5
+ 'option B': 'orangeSubtle',
6
+ 'option C': 'greenSubtle'
7
+ };
8
+ var PackagingTypeTrans = {
9
+ 'option A': function () { return 'option A'; },
10
+ 'option B': function () { return 'option B'; },
11
+ 'option C': function () { return 'option C'; }
12
+ };
13
+ export var EnumCellExample = function (_a) {
14
+ var rowData = _a.rowData;
15
+ return _jsx(EnumInCell, { value: rowData.enumColumn, enumObj: PackagingTypeTrans, appearanceMap: packagingTypeAppearance });
16
+ };
@@ -4,7 +4,7 @@ import { LinguiContainer } from '../../../../utils/LinguiContainer';
4
4
  import withReduxActions from '../../HoC/withReduxActions';
5
5
  import { useAddFilter } from '../../hooks/useAddFilter';
6
6
  import { ExtraControlButtonPosition } from '../../types';
7
- import { onRowEditClick, onRowReadClick, onRowAction, onBatchAction } from '../utils/actions';
7
+ import { onRowEditClick, onRowReadClick, onRowAction, onRowClick, onBatchAction } from '../utils/actions';
8
8
  import { columnDefinitions, enumColumn } from '../utils/columnDefinition';
9
9
  import { ReduxGrid, createRandomData, enumValues, gridDummyActions } from '../utils/utils';
10
10
  import withRedux from '../utils/withRedux';
@@ -47,7 +47,7 @@ export default {
47
47
  title: 'Blocks/CommonGrid',
48
48
  decorators: [withRedux]
49
49
  };
50
- export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, getRowsPerPage: getRowsPerPage, quickFilter: "textColumn", extraControlButtons: extraControlButtons, comparators: comparators, gridName: "gridName" })] })); };
50
+ export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowClick: onRowClick, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, getRowsPerPage: getRowsPerPage, quickFilter: "textColumn", extraControlButtons: extraControlButtons, comparators: comparators, gridName: "gridName" })] })); };
51
51
  ComplexWithPaginationAndRedux.story = {
52
52
  name: 'Complex, with pagination and redux'
53
53
  };
@@ -1,4 +1,5 @@
1
1
  export declare const onRowEditClick: (id: string, props: object) => void;
2
2
  export declare const onRowReadClick: (id: string, props: object) => void;
3
3
  export declare const onRowAction: (id: string, field: string, value: string | boolean) => void;
4
+ export declare const onRowClick: (id: string, field: string, value: string | boolean) => void;
4
5
  export declare const onBatchAction: (action: string, affectedRows: object[]) => void;
@@ -1,6 +1,7 @@
1
1
  export var onRowEditClick = function (id, props) { return console.log('onRowEditClick', id, props); };
2
2
  export var onRowReadClick = function (id, props) { return console.log('onRowReadClick', id, props); };
3
3
  export var onRowAction = function (id, field, value) { return console.log('onRowAction', id, field, value); };
4
+ export var onRowClick = function (id, field, value) { return console.log('onRowClick', id, field, value); };
4
5
  export var onBatchAction = function (action, affectedRows) {
5
6
  console.log('onBatchAction called', action, affectedRows);
6
7
  };
@@ -1,6 +1,5 @@
1
- import { ColumnDefinition } from '../../types';
1
+ import type { ColumnDefinition } from '../../types';
2
2
  export declare const oversizedArrayColumns = 25;
3
- export declare const enumValues: string[];
4
3
  export declare const oversizedColumnDefinition: {
5
4
  name: string;
6
5
  title: string;
@@ -1,15 +1,7 @@
1
- import { jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
1
+ import { ComplexCell } from '../components/ComplexCell';
2
+ import { EnumCellExample } from '../components/EnumCellExample';
3
+ import { enumValues } from './utils';
3
4
  export var oversizedArrayColumns = 25;
4
- export var enumValues = ['option A', 'option B', 'option C'];
5
- var ComplexCell = function (props) {
6
- var handleActionClick = React.useCallback(function () {
7
- if (props.onRowAction)
8
- props.onRowAction(props.rowData.id, 'get_invoice', null);
9
- // // eslint-disable-next-line react-hooks/exhaustive-deps
10
- }, [props.rowData, props.onRowAction]);
11
- return _jsxs("button", { onClick: handleActionClick, children: [" download ", props.rowData.id, " "] });
12
- };
13
5
  export var oversizedColumnDefinition = new Array(oversizedArrayColumns).fill(null).map(function (unused, index) { return ({
14
6
  name: "column_".concat(index),
15
7
  title: "column_".concat(index),
@@ -22,7 +14,8 @@ export var enumColumn = {
22
14
  filterOptions: enumValues.map(function (v) { return ({ value: v, label: v }); }),
23
15
  filterExtraProps: { isMulti: true, checkAllButton: true },
24
16
  filtering: true,
25
- sorting: false
17
+ sorting: false,
18
+ cellComponent: EnumCellExample
26
19
  };
27
20
  export var columnDefinitions = [
28
21
  {
@@ -92,7 +85,7 @@ export var columnDefinitions = [
92
85
  },
93
86
  {
94
87
  name: 'complexColumn',
95
- title: 'Complex Column',
88
+ title: 'Custom Cell Component Column1',
96
89
  flexBasis: 350,
97
90
  cellComponent: ComplexCell
98
91
  },
@@ -1,2 +1,7 @@
1
1
  import { type FC } from 'react';
2
- export declare const CheckedCircle: FC;
2
+ type CheckedCircleProps = {
3
+ checked?: boolean;
4
+ color?: string;
5
+ };
6
+ export declare const CheckedCircle: FC<CheckedCircleProps>;
7
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Icon from '../Icon';
3
3
  import { CheckedCircleContainer } from './styles';
4
- export var CheckedCircle = function () {
5
- return (_jsx(CheckedCircleContainer, { children: _jsx(Icon, { icon: "check", size: "12px" }) }));
4
+ export var CheckedCircle = function (_a) {
5
+ var _b = _a.checked, checked = _b === void 0 ? true : _b, _c = _a.color, color = _c === void 0 ? 'red1' : _c;
6
+ return _jsx(CheckedCircleContainer, { color: color, children: checked && _jsx(Icon, { icon: "check", size: "12px" }) });
6
7
  };
@@ -2,10 +2,16 @@
2
2
  import type { StoryObj } from '@storybook/react';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: import("react").FC;
5
+ component: import("react").FC<{
6
+ checked?: boolean | undefined;
7
+ color?: string | undefined;
8
+ }>;
6
9
  tags: string[];
7
10
  argTypes: {};
8
11
  };
9
12
  export default meta;
10
13
  type Story = StoryObj<typeof meta>;
11
14
  export declare const Default: Story;
15
+ export declare const Checked: Story;
16
+ export declare const CheckedGreen: Story;
17
+ export declare const Unchecked: Story;
@@ -9,3 +9,19 @@ export default meta;
9
9
  export var Default = {
10
10
  args: {}
11
11
  };
12
+ export var Checked = {
13
+ args: {
14
+ checked: true
15
+ }
16
+ };
17
+ export var CheckedGreen = {
18
+ args: {
19
+ checked: true,
20
+ color: 'green60'
21
+ }
22
+ };
23
+ export var Unchecked = {
24
+ args: {
25
+ checked: false
26
+ }
27
+ };
@@ -1 +1,3 @@
1
- export declare const CheckedCircleContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
1
+ export declare const CheckedCircleContainer: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
2
+ color: string;
3
+ }, never>;
@@ -3,5 +3,11 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import styled, { th } from '@xstyled/styled-components';
6
- export var CheckedCircleContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"], ["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"])), th.color('red1'), th.color('red1'));
6
+ export var CheckedCircleContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"], ["\n border-radius: 50%;\n border: 8px solid ", ";\n color: ", ";\n height: 36px;\n width: 36px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: white;\n"])), function (_a) {
7
+ var color = _a.color;
8
+ return th.color(color);
9
+ }, function (_a) {
10
+ var color = _a.color;
11
+ return th.color(color);
12
+ });
7
13
  var templateObject_1;