@mailstep/design-system 0.5.0-beta.21 → 0.5.0-beta.23

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.5.0-beta.21",
3
+ "version": "0.5.0-beta.23",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -1,5 +1,4 @@
1
1
  import { DataCellProps } from '../../types';
2
2
  type Props = DataCellProps<{}>;
3
- export declare const Tooltip: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
4
- declare const Image: ({ rowData, column }: Props) => JSX.Element | null;
5
- export default Image;
3
+ export declare const HoverBubble: ({ rowData, column }: Props) => JSX.Element | null;
4
+ export {};
@@ -6,8 +6,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import styled from '@xstyled/styled-components';
7
7
  import get from 'lodash/fp/get';
8
8
  var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n\n :hover {\n cursor: pointer;\n .tooltip {\n display: block;\n }\n }\n"], ["\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n\n :hover {\n cursor: pointer;\n .tooltip {\n display: block;\n }\n }\n"])));
9
- export var Tooltip = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-content: center;\n justify-content: center;\n margin-bottom: 2;\n\n div {\n display: none;\n position: absolute;\n background-color: white;\n color: gray;\n border-color: gray;\n border: 1px solid;\n border-radius: md;\n padding: 2 3;\n margin: 1;\n z-index: 1;\n box-shadow: tooltipBoxShadow;\n transform: translateY(-100%);\n\n max-width: 400px;\n line-break: anywhere;\n white-space: initial;\n }\n"], ["\n display: flex;\n align-content: center;\n justify-content: center;\n margin-bottom: 2;\n\n div {\n display: none;\n position: absolute;\n background-color: white;\n color: gray;\n border-color: gray;\n border: 1px solid;\n border-radius: md;\n padding: 2 3;\n margin: 1;\n z-index: 1;\n box-shadow: tooltipBoxShadow;\n transform: translateY(-100%);\n\n max-width: 400px;\n line-break: anywhere;\n white-space: initial;\n }\n"])));
10
- var Image = function (_a) {
9
+ var Tooltip = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n align-content: center;\n justify-content: center;\n margin-bottom: 2;\n\n div {\n display: none;\n position: absolute;\n background-color: white;\n color: gray;\n border-color: gray;\n border: 1px solid;\n border-radius: md;\n padding: 2 3;\n margin: 1;\n z-index: 1;\n box-shadow: tooltipBoxShadow;\n transform: translateY(-100%);\n\n max-width: 400px;\n line-break: anywhere;\n white-space: initial;\n }\n"], ["\n display: flex;\n align-content: center;\n justify-content: center;\n margin-bottom: 2;\n\n div {\n display: none;\n position: absolute;\n background-color: white;\n color: gray;\n border-color: gray;\n border: 1px solid;\n border-radius: md;\n padding: 2 3;\n margin: 1;\n z-index: 1;\n box-shadow: tooltipBoxShadow;\n transform: translateY(-100%);\n\n max-width: 400px;\n line-break: anywhere;\n white-space: initial;\n }\n"])));
10
+ export var HoverBubble = function (_a) {
11
11
  var rowData = _a.rowData, column = _a.column;
12
12
  var value = get(column.name, rowData);
13
13
  if (value) {
@@ -15,5 +15,4 @@ var Image = function (_a) {
15
15
  }
16
16
  return null;
17
17
  };
18
- export default Image;
19
18
  var templateObject_1, templateObject_2;
@@ -0,0 +1,7 @@
1
+ import { DataCellProps } from '../../types';
2
+ type SwitchData = {
3
+ id: string;
4
+ };
5
+ type Props = DataCellProps<SwitchData>;
6
+ export declare const ToggleCell: ({ rowData, column, onRowAction }: Props) => JSX.Element;
7
+ export {};
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useCallback } from 'react';
3
+ import { SwitchInCell } from './SwitchInCell';
4
+ import get from 'lodash/fp/get';
5
+ export var ToggleCell = function (_a) {
6
+ var _b;
7
+ var rowData = _a.rowData, column = _a.column, onRowAction = _a.onRowAction;
8
+ var inverse = !!((_b = column === null || column === void 0 ? void 0 : column.passProps) === null || _b === void 0 ? void 0 : _b.inverse);
9
+ var rawValue = get(column.name, rowData);
10
+ var value = inverse ? !rawValue : !!rawValue;
11
+ var actionName = "toggle_".concat(column.name);
12
+ var _c = React.useState(value), isChecked = _c[0], setIsChecked = _c[1];
13
+ React.useEffect(function () {
14
+ setIsChecked(value);
15
+ }, [rowData.id]);
16
+ var onSwitchChange = useCallback(function () {
17
+ if (!onRowAction)
18
+ return;
19
+ var ret = onRowAction(rowData.id, actionName, !isChecked);
20
+ if (ret) {
21
+ // promise returned = we wait for result
22
+ ret.then(function () { return setIsChecked(!isChecked); });
23
+ }
24
+ else {
25
+ // no promise = we fake feedback
26
+ setIsChecked(!isChecked);
27
+ }
28
+ }, [onRowAction, rowData.id, actionName, isChecked]);
29
+ return _jsx(SwitchInCell, { checked: isChecked, onChange: onSwitchChange });
30
+ };
@@ -9,4 +9,6 @@ export { IconButtonInCell } from './IconButtonInCell';
9
9
  export { SwitchInCell } from './SwitchInCell';
10
10
  export { ImageCell } from './ImageCell';
11
11
  export { EnumInCell } from './EnumInCell';
12
+ export { HoverBubble } from './HoverBubble';
12
13
  export { RowActionsCell } from './RowActionsCell';
14
+ export { ToggleCell } from './ToggleCell';
@@ -9,4 +9,6 @@ export { IconButtonInCell } from './IconButtonInCell';
9
9
  export { SwitchInCell } from './SwitchInCell';
10
10
  export { ImageCell } from './ImageCell';
11
11
  export { EnumInCell } from './EnumInCell';
12
+ export { HoverBubble } from './HoverBubble';
12
13
  export { RowActionsCell } from './RowActionsCell';
14
+ export { ToggleCell } from './ToggleCell';
@@ -0,0 +1,3 @@
1
+ import { FloatingButtonProps, Item } from '../types';
2
+ declare const useFloatingButton: (hasPermission: any, onClick?: () => void, options?: Item[], onSelect?: ((value: string) => void) | undefined) => FloatingButtonProps | undefined;
3
+ export default useFloatingButton;
@@ -0,0 +1,13 @@
1
+ import { useMemo } from 'react';
2
+ var useFloatingButton = function (hasPermission, onClick, options, onSelect) {
3
+ return useMemo(function () {
4
+ if (!hasPermission)
5
+ return;
6
+ return {
7
+ onClick: onClick,
8
+ options: options,
9
+ onSelect: onSelect,
10
+ };
11
+ }, [hasPermission, onClick, options, onSelect]);
12
+ };
13
+ export default useFloatingButton;
@@ -1,9 +1,10 @@
1
1
  import CommonGrid from './CommonGridContainer';
2
2
  import withReduxActions from './HoC/withReduxActions';
3
3
  import reducer, { actionPrefix, createActions, createSelectors, createFullSelector, actionTypes } from './store';
4
+ import useFloatingButton from './hooks/useFloatingButton';
4
5
  import * as Types from './types';
5
6
  import * as utils from './utils/public';
6
7
  export * from './StandardButtons';
7
8
  export * from './components/gridCells';
8
9
  export default CommonGrid;
9
- export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils };
10
+ export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils, useFloatingButton, };
@@ -1,9 +1,10 @@
1
1
  import CommonGrid from './CommonGridContainer';
2
2
  import withReduxActions from './HoC/withReduxActions';
3
3
  import reducer, { actionPrefix, createActions, createSelectors, createFullSelector, actionTypes } from './store';
4
+ import useFloatingButton from './hooks/useFloatingButton';
4
5
  import * as Types from './types';
5
6
  import * as utils from './utils/public';
6
7
  export * from './StandardButtons';
7
8
  export * from './components/gridCells';
8
9
  export default CommonGrid;
9
- export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils };
10
+ export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, utils, useFloatingButton, };
@@ -157,6 +157,7 @@ export type DataCellProps<T> = {
157
157
  rowData: T;
158
158
  onRowAction?: (id: string, field: string, value: any) => void | Promise<any>;
159
159
  column: ColumnDefinition;
160
+ children?: React.ReactNode;
160
161
  };
161
162
  type SingleColumnConfig = {
162
163
  isHidden?: boolean;