diginet-core-ui 1.3.65-beta.1 → 1.3.65-beta.2
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.
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useEffect,
|
|
4
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
5
5
|
import useInput from '../../../utils/useInput';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { jsx, css } from '@emotion/core';
|
|
8
|
-
import { renderIcon } from '../../../utils';
|
|
9
8
|
import theme from '../../../theme/settings';
|
|
10
9
|
import { typography } from '../../../styles/typography';
|
|
11
10
|
const {
|
|
12
11
|
colors
|
|
13
12
|
} = theme;
|
|
14
13
|
import { getGlobal } from '../../../global';
|
|
14
|
+
import Icon from '../../../icons';
|
|
15
15
|
const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
16
|
type,
|
|
17
17
|
viewType,
|
|
@@ -588,26 +588,46 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
588
588
|
onFocus: onFocus,
|
|
589
589
|
...bind
|
|
590
590
|
}));
|
|
591
|
+
const StartIcon = useMemo(() => {
|
|
592
|
+
let node = startIcon;
|
|
593
|
+
|
|
594
|
+
if (typeof node === 'string') {
|
|
595
|
+
node = jsx(Icon, {
|
|
596
|
+
name: startIcon,
|
|
597
|
+
style: iconStyle
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return jsx("div", {
|
|
602
|
+
css: inputBaseIconCSS,
|
|
603
|
+
...startIconProps,
|
|
604
|
+
className: ['start-icon', startIconProps.className ? startIconProps.className : ''].join(' ').trim()
|
|
605
|
+
}, node);
|
|
606
|
+
}, [startIcon]);
|
|
607
|
+
const EndIcon = useMemo(() => {
|
|
608
|
+
let node = endIcon;
|
|
609
|
+
|
|
610
|
+
if (typeof node === 'string') {
|
|
611
|
+
node = jsx(Icon, {
|
|
612
|
+
name: endIcon,
|
|
613
|
+
style: iconStyle
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return jsx("div", {
|
|
618
|
+
css: inputBaseIconCSS,
|
|
619
|
+
...endIconProps,
|
|
620
|
+
className: ['end-icon', endIconProps.className ? endIconProps.className : ''].join(' ').trim()
|
|
621
|
+
}, ' ', node, ' ');
|
|
622
|
+
}, [endIcon]);
|
|
591
623
|
const InputComp = jsx("div", {
|
|
592
624
|
css: inputBaseRoot,
|
|
593
625
|
ref: ref,
|
|
594
626
|
...props,
|
|
595
627
|
className: ['DGN-UI-InputBase', newClass, className, status].join(' ').trim()
|
|
596
|
-
}, jsx("div", {
|
|
628
|
+
}, startIcon && StartIcon, jsx("div", {
|
|
597
629
|
css: inputBaseCSS
|
|
598
|
-
},
|
|
599
|
-
css: inputBaseIconCSS,
|
|
600
|
-
...startIconProps,
|
|
601
|
-
className: 'start-icon ' + (startIconProps.className ? startIconProps.className : '')
|
|
602
|
-
}, renderIcon(startIcon, typeof startIcon === 'string' && startIcon.length < 20 ? 'effect' : null, {
|
|
603
|
-
onClick: startIconProps.onClick ? null : () => inputBaseRef.current.focus(),
|
|
604
|
-
style: {
|
|
605
|
-
padding: 0,
|
|
606
|
-
minHeight: '24px',
|
|
607
|
-
...iconStyle
|
|
608
|
-
},
|
|
609
|
-
viewBox: true
|
|
610
|
-
})), jsx("input", {
|
|
630
|
+
}, jsx("input", {
|
|
611
631
|
type: type,
|
|
612
632
|
autoComplete: autoComplete,
|
|
613
633
|
placeholder: isEnabled ? placeholder : '',
|
|
@@ -627,18 +647,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
627
647
|
onBlur: onBlur,
|
|
628
648
|
onFocus: onFocus,
|
|
629
649
|
...bind
|
|
630
|
-
})),
|
|
631
|
-
css: inputBaseIconCSS,
|
|
632
|
-
...endIconProps,
|
|
633
|
-
className: 'end-icon ' + (endIconProps.className ? endIconProps.className : '')
|
|
634
|
-
}, renderIcon(endIcon, null, {
|
|
635
|
-
style: {
|
|
636
|
-
padding: 0,
|
|
637
|
-
minHeight: '24px',
|
|
638
|
-
...iconStyle
|
|
639
|
-
},
|
|
640
|
-
viewBox: true
|
|
641
|
-
})));
|
|
650
|
+
})), endIcon && EndIcon);
|
|
642
651
|
const InputBaseComp = multiline ? MultipleInputComp : InputComp;
|
|
643
652
|
/* End component */
|
|
644
653
|
|
|
@@ -724,10 +733,10 @@ InputBase.propTypes = {
|
|
|
724
733
|
required: PropTypes.bool,
|
|
725
734
|
|
|
726
735
|
/** icon element display in the left of input */
|
|
727
|
-
startIcon: PropTypes.
|
|
736
|
+
startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
728
737
|
|
|
729
738
|
/** icon element display in the right of input */
|
|
730
|
-
endIcon: PropTypes.
|
|
739
|
+
endIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
731
740
|
|
|
732
741
|
/** props of input in InputBase component */
|
|
733
742
|
inputProps: PropTypes.object,
|