venice-ui 2.3.1 → 2.3.4

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.
@@ -39,17 +39,23 @@ 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
+ };
49
+ }, []);
45
50
  const onChange = (e) => {
46
51
  let returnedValue = type === 'number' || type === 'increase'
47
52
  ? calculateNumberValue(e.target.value)
48
53
  : e.target.value.toString();
49
54
  setInputValue(returnedValue);
50
- debouncedHandleChange(name, returnedValue);
55
+ debouncedRef.current(name, returnedValue);
51
56
  };
52
57
  const onBlurValidation = () => {
58
+ debouncedRef.current.flush();
53
59
  if (type === 'number' || type === 'increase') {
54
60
  let validateValue = inputValue;
55
61
  if (isNaN(parseFloat(validateValue.toString()))) {
@@ -68,6 +74,7 @@ const Input = ({ label, labelPosition = 'top', value, type = 'text', name, disab
68
74
  };
69
75
  const onKeyDown = (e) => {
70
76
  if (handleSubmit && e.key === 'Enter') {
77
+ debouncedRef.current.flush();
71
78
  handleSubmit();
72
79
  }
73
80
  };
@@ -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%;
@@ -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;
@@ -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,23 @@ 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
+ };
23
+ }, []);
19
24
  const onChange = (e) => {
20
25
  let returnedValue = type === 'number' || type === 'increase'
21
26
  ? calculateNumberValue(e.target.value)
22
27
  : e.target.value.toString();
23
28
  setInputValue(returnedValue);
24
- debouncedHandleChange(name, returnedValue);
29
+ debouncedRef.current(name, returnedValue);
25
30
  };
26
31
  const onBlurValidation = () => {
32
+ debouncedRef.current.flush();
27
33
  if (type === 'number' || type === 'increase') {
28
34
  let validateValue = inputValue;
29
35
  if (isNaN(parseFloat(validateValue.toString()))) {
@@ -42,6 +48,7 @@ export const Input = ({ label, labelPosition = 'top', value, type = 'text', name
42
48
  };
43
49
  const onKeyDown = (e) => {
44
50
  if (handleSubmit && e.key === 'Enter') {
51
+ debouncedRef.current.flush();
45
52
  handleSubmit();
46
53
  }
47
54
  };
@@ -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%;
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venice-ui",
3
- "version": "2.3.1",
3
+ "version": "2.3.4",
4
4
  "description": "Component library",
5
5
  "main": "index.js",
6
6
  "module": "./dist/esm/index.js",