New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@medly-components/core

Package Overview
Dependencies
Maintainers
1
Versions
468
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@medly-components/core - npm Package Compare versions

Comparing version

to
1.0.0-beta.7

dist/components/Modal/ModalPopup/index.d.ts

19

CHANGELOG.md

@@ -6,2 +6,21 @@ # Change Log

# [1.0.0-beta.7](https://github.com/medlypharmacy/medly-components/compare/@medly-components/core@1.0.0-beta.6...@medly-components/core@1.0.0-beta.7) (2019-12-17)
### Bug Fixes
* **core:** fix cell data render issue after data load ([eba41b2](https://github.com/medlypharmacy/medly-components/commit/eba41b20a3052ee76030d4d9a45f1073af3d9889))
* **core:** fix modal close issue ([f2d8fe9](https://github.com/medlypharmacy/medly-components/commit/f2d8fe9553f9efdbeb96c8b5b213844f0c472777))
* **core:** fix spelling mistake ([2f06441](https://github.com/medlypharmacy/medly-components/commit/2f06441eef85ad54dd530ce9f7e274f53dd72d0b))
### Features
* **core:** add feature to show loading cells in table ([bd7f691](https://github.com/medlypharmacy/medly-components/commit/bd7f691c3dcc36b7850a7eade7247ddebf98e012))
* **core:** add prop in column config to take max with to fit the content ([3d3ca68](https://github.com/medlypharmacy/medly-components/commit/3d3ca68c451e0a8a340554be2bfd1384ee9fbd4f))
# [1.0.0-beta.6](https://github.com/medlypharmacy/medly-components/compare/@medly-components/core@1.0.0-beta.5...@medly-components/core@1.0.0-beta.6) (2019-12-10)

@@ -8,0 +27,0 @@

31

dist/components/Modal/Modal.js
"use strict";
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -10,6 +8,4 @@ value: true

var _utils = require("@medly-components/utils");
var _react = _interopRequireDefault(require("react"));
var _react = _interopRequireWildcard(require("react"));
var _CloseModalContext = _interopRequireDefault(require("./CloseModalContext"));

@@ -25,8 +21,6 @@

var _ModalPopup = _interopRequireDefault(require("./ModalPopup"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

@@ -37,15 +31,10 @@

var Modal = function Modal(props) {
var innerRef = (0, _react.useRef)(null);
(0, _utils.useOuterClickNotifier)(props.onCloseModal, innerRef);
var onCloseModal = props.onCloseModal,
var open = props.open,
onCloseModal = props.onCloseModal,
children = props.children,
restProps = _objectWithoutProperties(props, ["onCloseModal", "children"]);
restProps = _objectWithoutProperties(props, ["open", "onCloseModal", "children"]);
if (!props.open) return null;
return _react["default"].createElement(_Modal.ModalBackgroundStyled, restProps, _react["default"].createElement(_Modal.ModalStyled, {
ref: innerRef
}, _react["default"].createElement(_CloseModalContext["default"].Provider, {
return open && _react["default"].createElement(_Modal.ModalBackgroundStyled, restProps, _react["default"].createElement(_CloseModalContext["default"].Provider, {
value: onCloseModal
}, children)));
}, _react["default"].createElement(_ModalPopup["default"], null, children)));
};

@@ -58,5 +47,5 @@

Modal.displayName = 'Modal';
Modal.Style = _Modal.ModalBackgroundStyled;
Modal.Header = _ModalHeader["default"];
Modal.Content = _ModalContent["default"];
Modal.Actions = _ModalActions["default"];
Modal.Style = _Modal.ModalStyled;
Modal.Actions = _ModalActions["default"];
export declare const ModalBackgroundStyled: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, {}, never>;
export declare const ModalStyled: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, {}, never>;

@@ -6,18 +6,6 @@ "use strict";

});
exports.ModalStyled = exports.ModalBackgroundStyled = void 0;
exports.ModalBackgroundStyled = void 0;
var _theme = require("@medly-components/theme");
var _utils = require("@medly-components/utils");
function _templateObject2() {
var data = _taggedTemplateLiteral(["\n background: ", ";\n padding: ", " ", ";\n border-radius: 5px;\n width: 50%;\n height: auto;\n max-height: 80%;\n overflow: hidden;\n overflow-y: auto;\n"]);
_templateObject2 = function _templateObject2() {
return data;
};
return data;
}
function _templateObject() {

@@ -36,16 +24,2 @@ var data = _taggedTemplateLiteral(["\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.6);\n z-index: 1000;\n ", "\n"]);

var ModalBackgroundStyled = (0, _utils.styled)('div')(_templateObject(), (0, _utils.centerAligned)());
exports.ModalBackgroundStyled = ModalBackgroundStyled;
var ModalStyled = (0, _utils.styled)('div')(_templateObject2(), function (_ref) {
var theme = _ref.theme;
return theme.modal.bgColor;
}, function (_ref2) {
var theme = _ref2.theme;
return theme.spacing.L;
}, function (_ref3) {
var theme = _ref3.theme;
return theme.spacing.XL;
});
exports.ModalStyled = ModalStyled;
ModalStyled.defaultProps = {
theme: _theme.defaultTheme
};
exports.ModalBackgroundStyled = ModalBackgroundStyled;

@@ -38,3 +38,4 @@ "use strict";

onRowSelection = props.onRowSelection,
addColumnMaxSize = props.addColumnMaxSize;
addColumnMaxSize = props.addColumnMaxSize,
isLoading = props.isLoading;

@@ -47,3 +48,4 @@ var handleRowClick = function handleRowClick(rowData) {

var getRow = function getRow(rowData) {
var getRow = function getRow() {
var rowData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var configs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : columns;

@@ -60,2 +62,3 @@ var field = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';

}, getRow(rowData[config.field], config.children, config.field))) : cells.push(_react["default"].createElement(_Cell["default"], _extends({
isLoading: isLoading,
disabled: rowData[rowDisableKey],

@@ -62,0 +65,0 @@ key: index,

@@ -8,2 +8,3 @@ import { ColumnConfig, Data } from '../types';

rowDisableKey: string;
isLoading?: boolean;
addColumnMaxSize: (field: string, value: number) => void;

@@ -10,0 +11,0 @@ onRowSelection?: (id: number) => void;

@@ -25,4 +25,4 @@ "use strict";

var Cell = function Cell(props) {
var childRef = (0, _react.useRef)(null);
var addColumnMaxSize = props.addColumnMaxSize,
var childRef = (0, _react.useRef)(null),
addColumnMaxSize = props.addColumnMaxSize,
config = props.config,

@@ -34,3 +34,4 @@ data = props.data,

onRowSelection = props.onRowSelection,
dottedFieldName = props.dottedFieldName;
dottedFieldName = props.dottedFieldName,
isLoading = props.isLoading;
(0, _react.useEffect)(function () {

@@ -43,3 +44,3 @@ if (childRef.current) {

var stopPropogation = function stopPropogation(e) {
var stopPropagation = function stopPropagation(e) {
return e.stopPropagation();

@@ -53,15 +54,13 @@ },

var textAlign = config.align || (config.formatter === 'numeric' ? 'right' : 'left');
return _react["default"].createElement(Styled.Cell, {
hide: config.hide,
frozen: config.frozen,
align: textAlign
}, config.field === 'medly-table-checkbox' ? _react["default"].createElement(_Checkbox["default"], {
disabled: disabled,
ref: childRef,
checked: selectedRows.includes(rowId),
onChange: handleRowSelection(rowId),
onClick: stopPropogation,
name: "active"
}) : function () {
var rowSelectionCheckbox = (0, _react.useMemo)(function () {
return _react["default"].createElement(_Checkbox["default"], {
disabled: disabled,
ref: childRef,
checked: selectedRows.includes(rowId),
onChange: handleRowSelection(rowId),
onClick: stopPropagation,
name: "active"
});
}, [selectedRows]),
formatedCell = (0, _react.useCallback)(function () {
switch (config.formatter) {

@@ -77,3 +76,3 @@ case 'boolean':

var Component = config.component;
return _react["default"].createElement(Styled.Div, {
return _react["default"].createElement(Styled.CustomComponentWrapper, {
ref: childRef

@@ -93,3 +92,21 @@ }, _react["default"].createElement(Component, {

}
}());
}, [data, isLoading]);
var textAlign = (0, _react.useMemo)(function () {
return config.align || (config.formatter === 'numeric' ? 'right' : 'left');
}, []);
if (isLoading) {
return _react["default"].createElement(Styled.Cell, {
hide: config.hide,
frozen: config.frozen
}, _react["default"].createElement(Styled.LoadingDiv, {
ref: childRef
}));
}
return _react["default"].createElement(Styled.Cell, {
hide: config.hide,
frozen: config.frozen,
align: textAlign
}, config.field === 'medly-table-checkbox' ? rowSelectionCheckbox : formatedCell());
};

@@ -96,0 +113,0 @@

import { StyledProps } from './types';
export declare const Div: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, {}, never>;
export declare const CustomComponentWrapper: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, {}, never>;
export declare const LoadingDiv: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, {}, never>;
export declare const Cell: import("styled-components").StyledComponent<"div", import("@medly-components/theme").Theme, StyledProps, never>;

@@ -6,3 +6,3 @@ "use strict";

});
exports.Cell = exports.Div = void 0;
exports.Cell = exports.LoadingDiv = exports.CustomComponentWrapper = void 0;

@@ -19,2 +19,12 @@ var _icons = require("@medly-components/icons");

function _templateObject4() {
var data = _taggedTemplateLiteral(["\n position: sticky;\n left: 0;\n z-index: 2;\n background-color: inherit;\n\n * {\n z-index: 2;\n }\n "]);
_templateObject4 = function _templateObject4() {
return data;
};
return data;
}
function _templateObject3() {

@@ -31,3 +41,3 @@ var data = _taggedTemplateLiteral(["\n opacity: ", ";\n padding: ", ";\n position: relative;\n display: flex;\n justify-content: ", ";\n align-items: center;\n overflow: hidden;\n border-right: 1px solid ", ";\n\n ", " {\n display: flex;\n margin: 0px;\n ", " {\n margin-right: 0px;\n }\n }\n\n ", " {\n white-space: nowrap;\n }\n\n ", "\n"]);

function _templateObject2() {
var data = _taggedTemplateLiteral([""]);
var data = _taggedTemplateLiteral(["\n @keyframes placeHolderShimmer {\n 0% {\n background-position: -468px 0;\n }\n 100% {\n background-position: 468px 0;\n }\n }\n width: 100%;\n height: 100%;\n animation-duration: 1.25s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: placeHolderShimmer;\n animation-timing-function: linear;\n background: ", ";\n background: linear-gradient(\n to right,\n ", " 8%,\n ", " 18%,\n ", " 33%\n );\n background-size: 800px 104px;\n position: relative;\n"]);

@@ -42,3 +52,3 @@ _templateObject2 = function _templateObject2() {

function _templateObject() {
var data = _taggedTemplateLiteral(["\n position: sticky;\n left: 0;\n z-index: 2;\n background-color: inherit;\n\n * {\n z-index: 2;\n }\n"]);
var data = _taggedTemplateLiteral([""]);

@@ -54,23 +64,33 @@ _templateObject = function _templateObject() {

var frozen = function frozen() {
return (0, _utils.css)(_templateObject());
};
var Div = (0, _utils.styled)('div')(_templateObject2());
exports.Div = Div;
var Cell = (0, _utils.styled)('div')(_templateObject3(), function (_ref) {
var hide = _ref.hide;
return hide ? 0 : 1;
var CustomComponentWrapper = (0, _utils.styled)('div')(_templateObject());
exports.CustomComponentWrapper = CustomComponentWrapper;
var LoadingDiv = (0, _utils.styled)('div')(_templateObject2(), function (_ref) {
var theme = _ref.theme;
return theme.colors.grey[100];
}, function (_ref2) {
var hide = _ref2.hide;
return hide ? '0' : '5px 10px';
var theme = _ref2.theme;
return theme.colors.grey[100];
}, function (_ref3) {
var align = _ref3.align;
return align === 'right' ? 'flex-end' : align === 'center' ? 'center' : 'flex-start';
var theme = _ref3.theme;
return theme.colors.grey[200];
}, function (_ref4) {
var theme = _ref4.theme;
return theme.colors.grey[100];
});
exports.LoadingDiv = LoadingDiv;
var Cell = (0, _utils.styled)('div')(_templateObject3(), function (_ref5) {
var hide = _ref5.hide;
return hide ? 0 : 1;
}, function (_ref6) {
var hide = _ref6.hide;
return hide ? '0' : '5px 10px';
}, function (_ref7) {
var align = _ref7.align;
return align === 'right' ? 'flex-end' : align === 'center' ? 'center' : 'flex-start';
}, function (_ref8) {
var theme = _ref8.theme;
return theme.table.borderColor;
}, _Checkbox["default"].Style, _icons.SvgIcon, _Text["default"].Style, function (props) {
return props.frozen && frozen();
return props.frozen && (0, _utils.css)(_templateObject4());
});
exports.Cell = Cell;

@@ -13,2 +13,3 @@ import { HTMLProps } from '@medly-components/utils';

dottedFieldName: string;
isLoading?: boolean;
selectedRows?: number[];

@@ -15,0 +16,0 @@ onRowSelection?: (id: number) => void;

@@ -28,3 +28,3 @@ "use strict";

var FavouriteColor = (0, _utils.styled)('div')(_templateObject());
var FavoriteColor = (0, _utils.styled)('div')(_templateObject());
var columns = [{

@@ -34,3 +34,4 @@ title: 'Name',

formatter: 'text-short',
frozen: true
frozen: true,
fitContent: true
}, {

@@ -62,3 +63,3 @@ title: 'Marks',

}, {
title: 'Favourite Color',
title: 'Favorite Color',
field: 'color',

@@ -76,3 +77,3 @@ formatter: 'react-component',

});
return _react["default"].createElement(FavouriteColor, null, chips);
return _react["default"].createElement(FavoriteColor, null, chips);
},

@@ -79,0 +80,0 @@ sort: true

@@ -74,2 +74,3 @@ "use strict";

}, _react["default"].createElement(_GroupCell.GroupCellTitle, null, config.title), headCell(config.children, config.field))) : cells.push(_react["default"].createElement(_HeadCell["default"], {
fitContent: config.fitContent,
maxColumnSizes: maxColumnSizes,

@@ -76,0 +77,0 @@ sortField: sortField,

@@ -44,3 +44,4 @@ "use strict";

onWidthChange = props.onWidthChange,
maxColumnSizes = props.maxColumnSizes;
maxColumnSizes = props.maxColumnSizes,
columnMaxSize = maxColumnSizes[field];

@@ -56,2 +57,5 @@ var cellEl = (0, _react.useRef)(null),

}, [sortField]);
(0, _react.useEffect)(function () {
cellEl && props.fitContent && onWidthChange(columnMaxSize, field);
}, [columnMaxSize]);

@@ -88,3 +92,3 @@ var onMouseMove = function onMouseMove(e) {

e.preventDefault();
onWidthChange(maxColumnSizes[field], field);
onWidthChange(columnMaxSize, field);
};

@@ -91,0 +95,0 @@

@@ -19,3 +19,3 @@ "use strict";

function _templateObject3() {
var data = _taggedTemplateLiteral(["\n padding: ", ";\n text-overflow: initial;\n white-space: normal;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n\n height: 100%;\n align-items: flex-end;\n\n *:first-child {\n margin-right: auto;\n }\n\n ", " {\n overflow: auto;\n white-space: unset;\n text-overflow: unset;\n }\n\n ", " {\n cursor: pointer;\n margin-right: 5px;\n }\n\n ", "\n"]);
var data = _taggedTemplateLiteral(["\n padding: ", ";\n text-overflow: initial;\n white-space: normal;\n border-right: 1px solid ", ";\n border-bottom: 1px solid ", ";\n\n height: 100%;\n align-items: flex-end;\n\n ", " {\n overflow: auto;\n white-space: unset;\n text-overflow: unset;\n width: 100%;\n text-align: center;\n }\n\n ", " {\n cursor: pointer;\n margin-right: 5px;\n }\n\n ", "\n"]);

@@ -22,0 +22,0 @@ _templateObject3 = function _templateObject3() {

@@ -6,4 +6,7 @@ export declare type SortOrder = 'asc' | 'desc';

field?: string;
maxColumnSizes: {};
maxColumnSizes: {
[k: string]: number;
};
enableSorting?: boolean;
fitContent?: boolean;
sortField?: string;

@@ -10,0 +13,0 @@ onWidthChange?: (width: number, key: string) => void;

@@ -8,5 +8,7 @@ /// <reference types="react" />

isSelectAllDisable?: boolean;
maxColumnSizes?: {};
maxColumnSizes: {
[k: string]: number;
};
onSelectAllClick?: (id: number) => void;
onSort?: (field: string, order: SortOrder) => void;
}

@@ -48,2 +48,14 @@ "use strict";

var loadingBodyData = [{
id: 0
}, {
id: 1
}, {
id: 2
}, {
id: 3
}, {
id: 4
}];
var Table = function Table(props) {

@@ -58,2 +70,3 @@ var data = props.data,

onRowSelection = props.onRowSelection,
isLoading = props.isLoading,
checkboxColumnConfig = {

@@ -124,12 +137,11 @@ title: 'ch',

maxColumnSizes: maxColumnSizes,
isSelectAllDisable: isSelectAllDisable,
onSelectAllClick: toggleId,
isAllRowSelected: ids.isAllSelected
isAllRowSelected: ids.isAllSelected,
isSelectAllDisable: isLoading || isSelectAllDisable
});
}, [columns, ids, isSelectAllDisable]),
}, [columns, ids, isSelectAllDisable, isLoading]),
body = (0, _react.useMemo)(function () {
return _react["default"].createElement(_Body["default"], {
isLoading: isLoading,
columns: columns,
data: data,
onRowClick: onRowClick,
uniqueKeyName: uniqueKeyName,

@@ -139,5 +151,7 @@ rowDisableKey: rowDisableKey,

selectedRows: selectedIds.value,
onRowSelection: toggleId
onRowSelection: toggleId,
data: isLoading ? loadingBodyData : data,
onRowClick: !isLoading && onRowClick
});
}, [columns, data, selectedIds]);
}, [columns, data, selectedIds, isLoading]);
return _react["default"].createElement(_Table.TableStyled, {

@@ -154,3 +168,4 @@ isRowClickable: onRowClick ? true : false

selectedRows: [],
isSelectable: false
isSelectable: false,
isLoading: false
};

@@ -157,0 +172,0 @@ Table.displayName = 'Table';

@@ -18,11 +18,23 @@ /// <reference types="react" />

export interface ColumnConfig {
/** To freeze the component on the left */
frozen?: boolean;
/** To show sort icons */
sort?: boolean;
/** To hide the column */
hide?: boolean;
/** This will be handled by the component */
size?: string;
/** Title of the column */
title: string;
/** Field name in the data */
field: string;
/** Column will take max width to fit content */
fitContent?: boolean;
/** Column content alignment */
align?: 'left' | 'right' | 'center';
/** Nested Column */
children?: ColumnConfig[];
/** Column formatter */
formatter: keyof ColumnsWidth;
/** Custom component */
component?: React.SFC<{

@@ -51,2 +63,4 @@ data: any;

isSelectable?: boolean;
/** Shows placeholder shimmer */
isLoading?: boolean;
/** Ids of default selected rows */

@@ -53,0 +67,0 @@ selectedRows?: number[];

{
"name": "@medly-components/core",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"main": "dist/index.js",

@@ -29,5 +29,5 @@ "types": "dist/index.d.ts",

"@datepicker-react/styled": "^1.7.1",
"@medly-components/icons": "^1.0.0-beta.6",
"@medly-components/icons": "^1.0.0-beta.7",
"@medly-components/theme": "^1.0.0-beta.5",
"@medly-components/utils": "^1.0.0-beta.5"
"@medly-components/utils": "^1.0.0-beta.6"
},

@@ -34,0 +34,0 @@ "devDependencies": {