diginet-core-ui 1.3.82 → 1.3.83

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.
@@ -5,7 +5,7 @@ import { Typography } from "../..";
5
5
  import OptionWrapper from "../../others/option-wrapper";
6
6
  import PropTypes from 'prop-types';
7
7
  import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
8
- import { flexRow, typographyTypes } from "../../../styles/general";
8
+ import { flexRow, parseMinHeight, typographyTypes } from "../../../styles/general";
9
9
  import { useTheme } from "../../../theme";
10
10
  import { classNames } from "../../../utils";
11
11
  const {
@@ -33,6 +33,7 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
33
33
  type,
34
34
  ...props
35
35
  }, reference) => {
36
+ if (!reference) reference = useRef(null);
36
37
  const ref = useRef(null);
37
38
  useImperativeHandle(reference, () => {
38
39
  const currentRef = ref.current || {};
@@ -71,19 +72,19 @@ const LabelContainerCSS = css`
71
72
  }
72
73
  `;
73
74
  const LabelRootCSS = css`
74
- min-height: 16px;
75
+ ${parseMinHeight(16)};
75
76
  margin: 0;
76
77
  word-break: break-all;
77
78
  `;
78
79
  Label.defaultProps = {
79
- type: 'h6',
80
+ children: '',
81
+ className: '',
80
82
  color: normal_label,
81
- lineClamp: 1,
82
- required: false,
83
83
  disabled: false,
84
+ lineClamp: 1,
84
85
  readOnly: false,
85
- className: '',
86
- children: ''
86
+ required: false,
87
+ type: 'h6'
87
88
  };
88
89
  Label.propTypes = {
89
90
  /** The content of the component. */
@@ -99,7 +100,7 @@ Label.propTypes = {
99
100
  /** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
100
101
  color: PropTypes.string,
101
102
  /** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
102
- lineClamp: PropTypes.number,
103
+ lineClamp: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
103
104
  /** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
104
105
  hoverTooltip: PropTypes.bool,
105
106
  /** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
@@ -1,10 +1,10 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import PropTypes from 'prop-types';
4
3
  import { jsx } from '@emotion/core';
5
- import Grid from '.';
4
+ import PropTypes from 'prop-types';
6
5
  import { makeStyles } from "../../theme";
7
6
  import { classNames } from "../../utils";
7
+ import Grid from '.';
8
8
  const useStyles = makeStyles({
9
9
  customCol: {
10
10
  '& .DGN-UI-Control': {
@@ -45,6 +45,7 @@ Col.defaultProps = {
45
45
  md: false,
46
46
  sm: false,
47
47
  style: {},
48
+ verticalAlign: 'auto',
48
49
  wrap: 'wrap',
49
50
  xl: false,
50
51
  xs: true,
@@ -67,6 +68,8 @@ Col.propTypes = {
67
68
  sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
68
69
  /** Style inline of component. */
69
70
  style: PropTypes.object,
71
+ /** Self-align of the grid item. */
72
+ verticalAlign: PropTypes.oneOf(['auto', 'start', 'center', 'end']),
70
73
  /** Defines the flex-wrap style property. It's applied for all screen sizes. */
71
74
  wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
72
75
  /** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
@@ -1,9 +1,9 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import PropTypes from 'prop-types';
4
3
  import { jsx } from '@emotion/core';
5
- import Grid from '.';
4
+ import PropTypes from 'prop-types';
6
5
  import { classNames } from "../../utils";
6
+ import Grid from '.';
7
7
  const checkChildren = children => {
8
8
  if (!children) return false;
9
9
  if (Array.isArray(children)) {
@@ -1,9 +1,9 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import PropTypes from 'prop-types';
4
3
  import { jsx } from '@emotion/core';
5
- import Grid from '.';
4
+ import PropTypes from 'prop-types';
6
5
  import { classNames } from "../../utils";
6
+ import Grid from '.';
7
7
  const checkChildren = children => {
8
8
  if (!children) return false;
9
9
  if (Array.isArray(children)) {
@@ -1,17 +1,17 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import { memo, useContext, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
3
+ import { css, jsx } from '@emotion/core';
4
4
  import PropTypes from 'prop-types';
5
- import { jsx, css } from '@emotion/core';
6
- import GridContext from "./context";
7
- import theme from "../../theme/settings";
8
- import { breakpointKeys } from "../../theme/createBreakpoints";
5
+ import { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef } from 'react';
9
6
  import { borderBox } from "../../styles/general";
7
+ import { useTheme } from "../../theme";
8
+ import { breakpointKeys } from "../../theme/createBreakpoints";
10
9
  import { classNames, handleBreakpoints } from "../../utils";
10
+ import GridContext from "./context";
11
11
  const {
12
12
  breakpoints: themeBreakpoints,
13
13
  spacing: themeSpacing
14
- } = theme;
14
+ } = useTheme();
15
15
  const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
16
16
  action = {},
17
17
  children,
@@ -30,6 +30,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
30
30
  spacing,
31
31
  style,
32
32
  topSpacing: topSpacingProp,
33
+ verticalAlign,
33
34
  wrap,
34
35
  xl,
35
36
  xs,
@@ -42,7 +43,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
42
43
  const topSpacing = topSpacingProp !== null && topSpacingProp !== void 0 ? topSpacingProp : rowSpacing;
43
44
  const leftSpacing = leftSpacingProp !== null && leftSpacingProp !== void 0 ? leftSpacingProp : columnSpacing;
44
45
  const ref = useRef(null);
45
- const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
46
+ const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap, verticalAlign);
46
47
  const _GridSpacingCSS = GridSpacingCSS(rowSpacing, columnSpacing, topSpacing, leftSpacing);
47
48
  const _HandleGridCSS = HandleGridCSS([xs, sm, md, lg, xl], columns);
48
49
  useImperativeHandle(reference, () => {
@@ -65,7 +66,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
65
66
  }, jsx(GridContext.Provider, {
66
67
  value: columns
67
68
  }, children));
68
- }, [columns, columnSpacing, leftSpacing, rowSpacing, topSpacing, children, className, container, direction, id, item, lg, md, sm, spacing, style, wrap, xl, xs, zeroMinWidth]);
69
+ }, [columns, columnSpacing, leftSpacing, rowSpacing, topSpacing, children, className, container, direction, id, item, lg, md, sm, spacing, style, verticalAlign, wrap, xl, xs, zeroMinWidth]);
69
70
  }));
70
71
  const getOffset = val => {
71
72
  const parse = parseFloat(val);
@@ -108,7 +109,7 @@ const handleGrid = (size, value, columns) => {
108
109
  ${css}
109
110
  }`;
110
111
  };
111
- const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
112
+ const GridCSS = (direction, zeroMinWidth, container, item, wrap, verticalAlign) => css`
112
113
  ${borderBox};
113
114
  ${container && `
114
115
  display: flex;
@@ -117,6 +118,7 @@ const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
117
118
  `};
118
119
  ${item && `
119
120
  margin: 0;
121
+ align-self: ${verticalAlign}
120
122
  `};
121
123
  ${zeroMinWidth && `min-width: 0;`}
122
124
  ${handleBreakpoints(direction, propValue => {
@@ -182,6 +184,7 @@ Grid.defaultProps = {
182
184
  sm: false,
183
185
  spacing: 0,
184
186
  style: {},
187
+ verticalAlign: 'auto',
185
188
  wrap: 'wrap',
186
189
  xl: false,
187
190
  xs: false,
@@ -218,6 +221,8 @@ Grid.propTypes = {
218
221
  spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
219
222
  /** Defines the vertical space of `container` components. */
220
223
  topSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
224
+ /** Self-align of the grid item. */
225
+ verticalAlign: PropTypes.oneOf(['auto', 'start', 'center', 'end']),
221
226
  /** Defines the flex-wrap style property. It's applied for all screen sizes. */
222
227
  wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
223
228
  /** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
@@ -182,7 +182,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
182
182
  };
183
183
  const updatePositionPopover = (el = null, cb) => {
184
184
  var _window, _window2, _anchor6, _anchorRect, _anchorRect2, _anchor7, _anchorRect3, _anchorRect4, _anchorRect5, _anchorRect6, _anchorRect7, _anchorRect8, _anchorRect9, _anchorRect10, _anchorRect11, _anchorRect12, _newDirectionObject, _newDirectionObject$t, _transformOrigin, _newDirectionObject2, _newDirectionObject2$, _transformOrigin2;
185
- setElement(el instanceof Element ? el : null);
185
+ if (el instanceof Element) setElement(el);
186
186
  if (!ref.current) {
187
187
  window.removeEventListener('resize', updatePositionPopover);
188
188
  return;
@@ -176,7 +176,7 @@ Typography.propTypes = {
176
176
  /** If `true`, hover will show tooltip when text clamped. */
177
177
  hoverTooltip: PropTypes.bool,
178
178
  /** The line-clamp property truncates text at a specific number of lines. */
179
- lineClamp: PropTypes.number,
179
+ lineClamp: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
180
180
  /** The component used for the root node. Either a string to use a HTML element or a component. */
181
181
  mapping: PropTypes.string,
182
182
  /** Callback fired when the component is clicked. */
@@ -2,18 +2,32 @@
2
2
  /* eslint-disable no-empty */
3
3
  /** @jsxRuntime classic */
4
4
  /** @jsx jsx */
5
- import { memo, forwardRef, useRef, useMemo } from 'react';
6
- import PropTypes from 'prop-types';
7
5
  import { jsx } from '@emotion/core';
6
+ import PropTypes from 'prop-types';
7
+ import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
8
+ import { classNames } from "../../../utils";
8
9
  const IconMenu = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
- type,
10
+ action,
11
+ className,
12
+ height,
13
+ id,
10
14
  name,
11
- width,
12
- height
13
- }, ref) => {
14
- if (!ref) {
15
- ref = useRef(null);
16
- }
15
+ style,
16
+ type,
17
+ width
18
+ }, reference) => {
19
+ if (!reference) reference = useRef(null);
20
+ const ref = useRef(null);
21
+ useImperativeHandle(reference, () => {
22
+ const currentRef = ref.current || {};
23
+ currentRef.element = ref.current;
24
+ const _instance = {
25
+ ...action
26
+ }; // methods
27
+ _instance.__proto__ = {}; // hidden methods
28
+ currentRef.instance = _instance;
29
+ return currentRef;
30
+ });
17
31
  const getResourceImage = fileName => {
18
32
  let icon = require("../../../assets/images/menu/dhr/Default.svg");
19
33
  try {
@@ -22,26 +36,36 @@ const IconMenu = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
22
36
  return icon;
23
37
  };
24
38
  return useMemo(() => jsx("img", {
39
+ ref: ref,
40
+ id: id,
41
+ className: classNames('DGN-UI-IconMenu', className),
42
+ style: style,
25
43
  src: getResourceImage(name + '.svg'),
26
44
  width: width,
27
45
  height: height,
28
- alt: ''
29
- }), [type, name, width, height]);
46
+ alt: name
47
+ }), [className, height, id, name, style, type, width]);
30
48
  }));
31
49
  IconMenu.defaultProps = {
50
+ className: '',
51
+ height: '100%',
32
52
  name: 'Default',
33
53
  type: 'dhr',
34
54
  width: '100%',
35
- height: '100%'
55
+ style: {}
36
56
  };
37
57
  IconMenu.propTypes = {
38
- /** Menu type (DHR || ERP || BEM). */
39
- type: PropTypes.oneOf(['dhr', 'erp', 'bem']),
58
+ /** Class for component. */
59
+ className: PropTypes.string,
60
+ /** Height of icon. */
61
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
40
62
  /** Name of icon. */
41
63
  name: PropTypes.string,
64
+ /** Menu type (DHR || ERP || BEM). */
65
+ type: PropTypes.oneOf(['dhr', 'erp', 'bem']),
42
66
  /** Width of icon. */
43
67
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
44
- /** Height of icon. */
45
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
68
+ /** Style inline of component. */
69
+ style: PropTypes.object
46
70
  };
47
71
  export default IconMenu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.82",
3
+ "version": "1.3.83",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,6 +38,12 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.83
42
+ - \[Changed\]: IconMenu – Add prop className, style
43
+ - \[Changed\]: Grid – Add prop verticalAlign
44
+ - \[Changed\]: Label– Add lineClamp auto
45
+ - \[Fixed\]: Popover – Fix bug not save last position of anchor
46
+
41
47
  ## 1.3.82
42
48
  - \[Fixed\]: CircularProgress – Fix transform rotate wrong inside flex column
43
49
 
package/utils/index.js CHANGED
@@ -1,30 +1,31 @@
1
1
  import * as utils from '.';
2
- export * from "./array/array";
2
+ export { default as capitalize } from "./string/capitalize";
3
+ export { default as capitalizeSentenceCase } from "./string/capitalizeSentenceCase";
3
4
  export { default as classNames } from "./classNames";
4
- export * from "./date";
5
5
  export { default as date } from "./date";
6
6
  export { default as getFileType } from "./getFileType";
7
7
  export { default as handleBreakpoints } from "./handleBreakpoints";
8
8
  export { default as isMobile } from "./isMobile";
9
9
  export { default as mapParent } from "./map-parent";
10
+ export { default as onValidate } from "./validate";
10
11
  export { default as parseTextToHTML } from "./parseHTML";
11
12
  export { default as promisify } from "./promisify";
12
13
  export { default as randomString } from "./randomString";
13
14
  export { default as refType } from "./refType";
14
15
  export { default as removeUnicode } from "./remove-unicode";
15
- export * from "./render-portal";
16
16
  export { default as renderHTML } from "./renderHTML";
17
17
  export { default as renderIcon } from "./renderIcon";
18
- export * from "./sb-template";
19
18
  export { default as SbTemplate } from "./sb-template";
20
- export { default as capitalize } from "./string/capitalize";
21
- export { default as capitalizeSentenceCase } from "./string/capitalizeSentenceCase";
22
- export * from "./string/string";
23
19
  export { default as updatePosition } from "./updatePosition";
24
20
  export { default as useDelayUnmount } from "./useDelayUnmount";
21
+ export { default as useInput } from "./useInput";
25
22
  export { default as useMediaQuery } from "./useMediaQuery";
26
23
  export { default as useOnClickOutside } from "./useOnClickOutside";
27
24
  export { default as usePortal } from "./usePortal";
25
+ export * from "./array/array";
26
+ export * from "./date";
27
+ export * from "./render-portal";
28
+ export * from "./sb-template";
29
+ export * from "./string/string";
28
30
  export * from "./validate";
29
- export { default as onValidate } from "./validate";
30
31
  export default utils;