venice-ui 2.3.0 → 2.3.3

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.
@@ -125,7 +125,7 @@ const DropdownMenu = ({ size = 'medium', iconName = 'more_vert', header = false,
125
125
  headerTitle && (react_1.default.createElement(Typography_1.TextAccent, { color: Theme_1.Theme.colors.text }, headerTitle)),
126
126
  headerSubtitle && (react_1.default.createElement(Typography_1.TextLabel, { color: Theme_1.Theme.colors.text }, headerSubtitle)))),
127
127
  react_1.default.createElement(DropdownMenu_styles_1.DropdownMenuContent, null, options &&
128
- options.map((option) => (react_1.default.createElement(DropdownMenu_styles_1.DropdownMenuOption, { key: option.label, isDisable: isDisable(option.disableID, option.diasbled), onClick: () => handleClick(option.action, option.diasbled ? option.diasbled : false, option.disableID), isActive: option.isActive }, option.label)))),
128
+ options.map((option) => (react_1.default.createElement(DropdownMenu_styles_1.DropdownMenuOption, { key: option.label, isDisable: isDisable(option.disableID, option.disabled), onClick: () => handleClick(option.action, option.disabled ? option.disabled : false, option.disableID), isActive: option.isActive }, option.label)))),
129
129
  footer && (react_1.default.createElement(DropdownMenu_styles_1.DropdownMenuFooter, null, footerText && (react_1.default.createElement(Typography_1.Text, { action: true, onClick: handleFooterAction }, footerText)))))), document.body)));
130
130
  };
131
131
  exports.DropdownMenu = DropdownMenu;
@@ -39,17 +39,24 @@ const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disab
39
39
  ? numberValue
40
40
  : parseFloat(numberValue);
41
41
  };
42
- const debouncedHandleChange = (0, react_1.useCallback)((0, lodash_1.debounce)((name, value) => {
43
- handleChange(name, value);
44
- }, 300), [handleChange]);
42
+ const debouncedRef = (0, react_1.useRef)((0, lodash_1.debounce)((n, v) => {
43
+ handleChange(n, v);
44
+ }, 300));
45
+ (0, react_1.useEffect)(() => {
46
+ return () => {
47
+ debouncedRef.current.flush();
48
+ debouncedRef.current.cancel();
49
+ };
50
+ }, []);
45
51
  const onChange = (e) => {
46
52
  let returnedValue = type === 'number' || type === 'increase'
47
53
  ? calculateNumberValue(e.target.value)
48
54
  : e.target.value.toString();
49
55
  setInputValue(returnedValue);
50
- debouncedHandleChange(name, returnedValue);
56
+ debouncedRef.current(name, returnedValue);
51
57
  };
52
58
  const onBlurValidation = () => {
59
+ debouncedRef.current.flush();
53
60
  if (type === 'number' || type === 'increase') {
54
61
  let validateValue = inputValue;
55
62
  if (isNaN(parseFloat(validateValue.toString()))) {
@@ -68,6 +75,7 @@ const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disab
68
75
  };
69
76
  const onKeyDown = (e) => {
70
77
  if (handleSubmit && e.key === 'Enter') {
78
+ debouncedRef.current.flush();
71
79
  handleSubmit();
72
80
  }
73
81
  };
@@ -9,11 +9,11 @@ const react_1 = __importDefault(require("react"));
9
9
  const Section_styles_1 = require("./Section.styles");
10
10
  const Theme_1 = require("../../Theme");
11
11
  const Button_1 = require("../Button");
12
- const Section = ({ title, children, titlePosition = 'left', noPadding = false, theme = Theme_1.mainTheme, backgroundColor = theme.contentBackground, action, actionLabel = 'action', }) => {
13
- return (react_1.default.createElement(Section_styles_1.SectionElement, { backgroundColor: backgroundColor },
14
- title && (react_1.default.createElement(Section_styles_1.SectionTitle, { titlePosition: titlePosition, noPadding: noPadding, withAction: titlePosition === 'left' && !!action },
12
+ const Section = ({ title, children, titlePosition = 'left', noHorizontalPadding = false, noTopPadding = false, theme = Theme_1.mainTheme, backgroundColor = theme.contentBackground, action, actionLabel = 'action', }) => {
13
+ return (react_1.default.createElement(Section_styles_1.SectionElement, { backgroundColor: backgroundColor, noTopPadding: noTopPadding },
14
+ title && (react_1.default.createElement(Section_styles_1.SectionTitle, { titlePosition: titlePosition, noPadding: noHorizontalPadding, withAction: titlePosition === 'left' && !!action },
15
15
  react_1.default.createElement(Typography_1.TextSubHeader, null, title),
16
16
  titlePosition === 'left' && !!action && (react_1.default.createElement(Button_1.Button, { text: actionLabel, onClick: action, size: "small", mode: "secondary" })))),
17
- react_1.default.createElement(Section_styles_1.SectionContent, { noPadding: noPadding }, children)));
17
+ react_1.default.createElement(Section_styles_1.SectionContent, { noPadding: noHorizontalPadding }, children)));
18
18
  };
19
19
  exports.Section = Section;
@@ -12,6 +12,7 @@ exports.SectionElement = styled_components_1.default.div `
12
12
  overflow: auto;
13
13
  padding: ${Theme_1.Theme.padding.l} 0;
14
14
  background-color: ${(p) => p.backgroundColor};
15
+ ${(p) => p.noTopPadding && `padding-top: 0;`}
15
16
  `;
16
17
  exports.SectionTitle = styled_components_1.default.div `
17
18
  width: 100%;
@@ -10,16 +10,19 @@ const DropdownMenu_1 = require("../DropdownMenu");
10
10
  const Theme_1 = require("../../Theme");
11
11
  const date_fns_1 = require("date-fns");
12
12
  const tableHelper_1 = require("./tableHelper");
13
- const Cell = ({ header, theme = Theme_1.mainTheme, moreActions, item, marked = false, }) => {
13
+ const Cell = ({ header, theme = Theme_1.mainTheme, moreActions, item, marked = false, isDisabled = false, }) => {
14
14
  if (header.action) {
15
+ const cellAction = item.disabled
16
+ ? moreActions.map((a) => ({ ...a, disabled: true }))
17
+ : moreActions.map((a) => ({ ...a }));
15
18
  return (react_1.default.createElement(Table_styles_1.OptionTableCell, null,
16
19
  react_1.default.createElement(Table_styles_1.OptionTableCellWrapper, { onClick: (e) => e.stopPropagation() },
17
- react_1.default.createElement(DropdownMenu_1.DropdownMenu, { options: moreActions, targetID: item.id, iconName: "more_vert", iconColor: theme.tableMoreIconColor, iconHoverColor: theme.tableHoverMoreIconColor, iconBgHoverColor: "transparent", position: "right" }))));
20
+ react_1.default.createElement(DropdownMenu_1.DropdownMenu, { options: cellAction, targetID: item.id, iconName: "more_vert", iconColor: theme.tableMoreIconColor, iconHoverColor: theme.tableHoverMoreIconColor, iconBgHoverColor: "transparent", position: "right" }))));
18
21
  }
19
22
  if (header.scope) {
20
- return (react_1.default.createElement(Table_styles_1.TableCell, { marked: marked }, (0, tableHelper_1.getValueFormScope)(item[header.valueSource], header.scope)));
23
+ return (react_1.default.createElement(Table_styles_1.TableCell, { marked: marked, disabled: isDisabled }, (0, tableHelper_1.getValueFormScope)(item[header.valueSource], header.scope)));
21
24
  }
22
- return (react_1.default.createElement(Table_styles_1.TableCell, { marked: marked }, header.date
25
+ return (react_1.default.createElement(Table_styles_1.TableCell, { marked: marked, disabled: isDisabled }, header.date
23
26
  ? item[header.valueSource] !== undefined
24
27
  ? (0, date_fns_1.format)(item[header.valueSource], 'dd-MM-yyyy')
25
28
  : ''
@@ -87,9 +87,11 @@ const Table = ({ theme = Theme_1.mainTheme, headers, elements, hover = true, sel
87
87
  react_1.default.createElement(Table_styles_1.TableWrapper, { cellPadding: "0", cellSpacing: "0" },
88
88
  react_1.default.createElement(Table_styles_1.TableHead, null,
89
89
  react_1.default.createElement(Table_styles_1.TableRow, { hover: false, selectable: false, active: false }, tableProps.headers.map((header) => (react_1.default.createElement(HeaderCell_1.HeaderCell, { key: `header_${header.name}`, header: header, sortable: sortable, handleSort: handleHeaderCellClick, sort: tableProps.sort }))))),
90
- react_1.default.createElement("tbody", null, paginatedElements.map((item) => (react_1.default.createElement(Table_styles_1.TableRow, { key: `table_row_${item.id}`, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header, index) => {
91
- return (react_1.default.createElement(Cell_1.Cell, { key: `cell_${header.name}_${item.id}`, header: header, moreActions: moreActions, item: item, theme: theme, marked: item.marked && index === 0 }));
92
- })))))),
90
+ react_1.default.createElement("tbody", null, paginatedElements.map((item) => {
91
+ return (react_1.default.createElement(Table_styles_1.TableRow, { key: `table_row_${item.id}`, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header, index) => {
92
+ return (react_1.default.createElement(Cell_1.Cell, { key: `cell_${header.name}_${item.id}`, header: header, moreActions: moreActions, item: item, theme: theme, marked: item.marked && index === 0, isDisabled: item.disabled }));
93
+ })));
94
+ }))),
93
95
  ifPagination && (react_1.default.createElement(Pagination_1.Pagination, { currentPage: currentPage, totalPages: totalPages, pageSize: currentPageSize, onPageChange: setCurrentPage, onPageSizeChange: setCurrentPageSize }))));
94
96
  };
95
97
  exports.Table = Table;
@@ -62,6 +62,9 @@ exports.TableCell = styled_components_1.default.td `
62
62
  border-left:2px solid ${p.theme.action};
63
63
  padding-left:6px;
64
64
  `}
65
+ ${p => p.disabled && `
66
+ color: ${p.theme.inputDisabledTextColor}!important;
67
+ `}
65
68
  `;
66
69
  exports.OptionTableCell = styled_components_1.default.td `
67
70
  text-align: center;
@@ -42,7 +42,7 @@ exports.TooltipWrapper = styled_components_1.default.div `
42
42
  `;
43
43
  exports.TooltipPivot = styled_components_1.default.span `
44
44
  position: absolute;
45
- left: 50%;
45
+ left: 18px;
46
46
  transform: translateX(-50%);
47
47
  width: 0;
48
48
  height: 0;
@@ -99,6 +99,6 @@ export const DropdownMenu = ({ size = 'medium', iconName = 'more_vert', header =
99
99
  headerTitle && (React.createElement(TextAccent, { color: Theme.colors.text }, headerTitle)),
100
100
  headerSubtitle && (React.createElement(TextLabel, { color: Theme.colors.text }, headerSubtitle)))),
101
101
  React.createElement(DropdownMenuContent, null, options &&
102
- options.map((option) => (React.createElement(DropdownMenuOption, { key: option.label, isDisable: isDisable(option.disableID, option.diasbled), onClick: () => handleClick(option.action, option.diasbled ? option.diasbled : false, option.disableID), isActive: option.isActive }, option.label)))),
102
+ options.map((option) => (React.createElement(DropdownMenuOption, { key: option.label, isDisable: isDisable(option.disableID, option.disabled), onClick: () => handleClick(option.action, option.disabled ? option.disabled : false, option.disableID), isActive: option.isActive }, option.label)))),
103
103
  footer && (React.createElement(DropdownMenuFooter, null, footerText && (React.createElement(Text, { action: true, onClick: handleFooterAction }, footerText)))))), document.body)));
104
104
  };
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { ThemeProvider } from 'styled-components';
3
3
  import { Aligment } from '../Aligment';
4
4
  import { InputTextElement, InputLabelElement, InputErrorMsg, InputWrapper, EyeIconWrapper, IconsWrapper, InputReadOnlyElement, Prefix, } from './Input.styles';
@@ -13,17 +13,24 @@ export const Input = ({ label, labelPosition = 'top', value, type = 'text', name
13
13
  ? numberValue
14
14
  : parseFloat(numberValue);
15
15
  };
16
- const debouncedHandleChange = useCallback(debounce((name, value) => {
17
- handleChange(name, value);
18
- }, 300), [handleChange]);
16
+ const debouncedRef = useRef(debounce((n, v) => {
17
+ handleChange(n, v);
18
+ }, 300));
19
+ useEffect(() => {
20
+ return () => {
21
+ debouncedRef.current.flush();
22
+ debouncedRef.current.cancel();
23
+ };
24
+ }, []);
19
25
  const onChange = (e) => {
20
26
  let returnedValue = type === 'number' || type === 'increase'
21
27
  ? calculateNumberValue(e.target.value)
22
28
  : e.target.value.toString();
23
29
  setInputValue(returnedValue);
24
- debouncedHandleChange(name, returnedValue);
30
+ debouncedRef.current(name, returnedValue);
25
31
  };
26
32
  const onBlurValidation = () => {
33
+ debouncedRef.current.flush();
27
34
  if (type === 'number' || type === 'increase') {
28
35
  let validateValue = inputValue;
29
36
  if (isNaN(parseFloat(validateValue.toString()))) {
@@ -42,6 +49,7 @@ export const Input = ({ label, labelPosition = 'top', value, type = 'text', name
42
49
  };
43
50
  const onKeyDown = (e) => {
44
51
  if (handleSubmit && e.key === 'Enter') {
52
+ debouncedRef.current.flush();
45
53
  handleSubmit();
46
54
  }
47
55
  };
@@ -3,10 +3,10 @@ import React from 'react';
3
3
  import { SectionElement, SectionTitle, SectionContent } from './Section.styles';
4
4
  import { mainTheme } from '../../Theme';
5
5
  import { Button } from '../Button';
6
- export const Section = ({ title, children, titlePosition = 'left', noPadding = false, theme = mainTheme, backgroundColor = theme.contentBackground, action, actionLabel = 'action', }) => {
7
- return (React.createElement(SectionElement, { backgroundColor: backgroundColor },
8
- title && (React.createElement(SectionTitle, { titlePosition: titlePosition, noPadding: noPadding, withAction: titlePosition === 'left' && !!action },
6
+ export const Section = ({ title, children, titlePosition = 'left', noHorizontalPadding = false, noTopPadding = false, theme = mainTheme, backgroundColor = theme.contentBackground, action, actionLabel = 'action', }) => {
7
+ return (React.createElement(SectionElement, { backgroundColor: backgroundColor, noTopPadding: noTopPadding },
8
+ title && (React.createElement(SectionTitle, { titlePosition: titlePosition, noPadding: noHorizontalPadding, withAction: titlePosition === 'left' && !!action },
9
9
  React.createElement(TextSubHeader, null, title),
10
10
  titlePosition === 'left' && !!action && (React.createElement(Button, { text: actionLabel, onClick: action, size: "small", mode: "secondary" })))),
11
- React.createElement(SectionContent, { noPadding: noPadding }, children)));
11
+ React.createElement(SectionContent, { noPadding: noHorizontalPadding }, children)));
12
12
  };
@@ -6,6 +6,7 @@ export const SectionElement = styled.div `
6
6
  overflow: auto;
7
7
  padding: ${Theme.padding.l} 0;
8
8
  background-color: ${(p) => p.backgroundColor};
9
+ ${(p) => p.noTopPadding && `padding-top: 0;`}
9
10
  `;
10
11
  export const SectionTitle = styled.div `
11
12
  width: 100%;
@@ -4,16 +4,19 @@ import { DropdownMenu } from '../DropdownMenu';
4
4
  import { mainTheme } from '../../Theme';
5
5
  import { format } from 'date-fns';
6
6
  import { getValueFormScope } from './tableHelper';
7
- export const Cell = ({ header, theme = mainTheme, moreActions, item, marked = false, }) => {
7
+ export const Cell = ({ header, theme = mainTheme, moreActions, item, marked = false, isDisabled = false, }) => {
8
8
  if (header.action) {
9
+ const cellAction = item.disabled
10
+ ? moreActions.map((a) => ({ ...a, disabled: true }))
11
+ : moreActions.map((a) => ({ ...a }));
9
12
  return (React.createElement(OptionTableCell, null,
10
13
  React.createElement(OptionTableCellWrapper, { onClick: (e) => e.stopPropagation() },
11
- React.createElement(DropdownMenu, { options: moreActions, targetID: item.id, iconName: "more_vert", iconColor: theme.tableMoreIconColor, iconHoverColor: theme.tableHoverMoreIconColor, iconBgHoverColor: "transparent", position: "right" }))));
14
+ React.createElement(DropdownMenu, { options: cellAction, targetID: item.id, iconName: "more_vert", iconColor: theme.tableMoreIconColor, iconHoverColor: theme.tableHoverMoreIconColor, iconBgHoverColor: "transparent", position: "right" }))));
12
15
  }
13
16
  if (header.scope) {
14
- return (React.createElement(TableCell, { marked: marked }, getValueFormScope(item[header.valueSource], header.scope)));
17
+ return (React.createElement(TableCell, { marked: marked, disabled: isDisabled }, getValueFormScope(item[header.valueSource], header.scope)));
15
18
  }
16
- return (React.createElement(TableCell, { marked: marked }, header.date
19
+ return (React.createElement(TableCell, { marked: marked, disabled: isDisabled }, header.date
17
20
  ? item[header.valueSource] !== undefined
18
21
  ? format(item[header.valueSource], 'dd-MM-yyyy')
19
22
  : ''
@@ -61,8 +61,10 @@ export const Table = ({ theme = mainTheme, headers, elements, hover = true, sele
61
61
  React.createElement(TableWrapper, { cellPadding: "0", cellSpacing: "0" },
62
62
  React.createElement(TableHead, null,
63
63
  React.createElement(TableRow, { hover: false, selectable: false, active: false }, tableProps.headers.map((header) => (React.createElement(HeaderCell, { key: `header_${header.name}`, header: header, sortable: sortable, handleSort: handleHeaderCellClick, sort: tableProps.sort }))))),
64
- React.createElement("tbody", null, paginatedElements.map((item) => (React.createElement(TableRow, { key: `table_row_${item.id}`, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header, index) => {
65
- return (React.createElement(Cell, { key: `cell_${header.name}_${item.id}`, header: header, moreActions: moreActions, item: item, theme: theme, marked: item.marked && index === 0 }));
66
- })))))),
64
+ React.createElement("tbody", null, paginatedElements.map((item) => {
65
+ return (React.createElement(TableRow, { key: `table_row_${item.id}`, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header, index) => {
66
+ return (React.createElement(Cell, { key: `cell_${header.name}_${item.id}`, header: header, moreActions: moreActions, item: item, theme: theme, marked: item.marked && index === 0, isDisabled: item.disabled }));
67
+ })));
68
+ }))),
67
69
  ifPagination && (React.createElement(Pagination, { currentPage: currentPage, totalPages: totalPages, pageSize: currentPageSize, onPageChange: setCurrentPage, onPageSizeChange: setCurrentPageSize }))));
68
70
  };
@@ -56,6 +56,9 @@ export const TableCell = styled.td `
56
56
  border-left:2px solid ${p.theme.action};
57
57
  padding-left:6px;
58
58
  `}
59
+ ${p => p.disabled && `
60
+ color: ${p.theme.inputDisabledTextColor}!important;
61
+ `}
59
62
  `;
60
63
  export const OptionTableCell = styled.td `
61
64
  text-align: center;
@@ -16,7 +16,7 @@ export const TooltipWrapper = styled.div `
16
16
  `;
17
17
  export const TooltipPivot = styled.span `
18
18
  position: absolute;
19
- left: 50%;
19
+ left: 18px;
20
20
  transform: translateX(-50%);
21
21
  width: 0;
22
22
  height: 0;
@@ -3,7 +3,8 @@ import { TitlePosition } from '../../types';
3
3
  export interface ISectionProps {
4
4
  title?: string;
5
5
  titlePosition?: TitlePosition;
6
- noPadding?: boolean;
6
+ noHorizontalPadding?: boolean;
7
+ noTopPadding?: boolean;
7
8
  backgroundColor?: string;
8
9
  children: React.ReactNode;
9
10
  theme?: any;
@@ -1,6 +1,7 @@
1
1
  import { TitlePosition } from '../../types';
2
2
  interface ISectionStyles {
3
3
  backgroundColor: string;
4
+ noTopPadding?: boolean;
4
5
  }
5
6
  export declare const SectionElement: import("styled-components").StyledComponent<"div", any, ISectionStyles, never>;
6
7
  interface ISectionTitleStyle {
@@ -7,6 +7,7 @@ interface ICell {
7
7
  moreActions: IAction[];
8
8
  item: any;
9
9
  marked?: boolean;
10
+ isDisabled?: boolean;
10
11
  }
11
12
  export declare const Cell: FC<ICell>;
12
13
  export {};
@@ -18,6 +18,7 @@ export declare const TableRow: import("styled-components").StyledComponent<"tr",
18
18
  interface ITableCellProps {
19
19
  theme: any;
20
20
  marked: boolean;
21
+ disabled: boolean;
21
22
  }
22
23
  export declare const TableCell: import("styled-components").StyledComponent<"td", any, ITableCellProps, never>;
23
24
  export declare const OptionTableCell: import("styled-components").StyledComponent<"td", any, {}, never>;
@@ -8,7 +8,7 @@ export interface IAction {
8
8
  label: string | number;
9
9
  disableID?: string;
10
10
  isActive?: boolean;
11
- diasbled?: boolean;
11
+ disabled?: boolean;
12
12
  }
13
13
  export interface IIconsActions {
14
14
  iconName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venice-ui",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "module": "./dist/esm/index.js",