diginet-core-ui 1.3.78 → 1.3.79

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.
Files changed (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
5
4
  import useInput from '../../../utils/useInput';
@@ -8,20 +7,19 @@ import { jsx, css } from '@emotion/core';
8
7
  import { getGlobal } from '../../../global';
9
8
  import Icon from '../../../icons';
10
9
  import { Typography } from '../..';
11
- import { useTheme } from '../../../theme';
12
- import { classNames } from '../../../utils';
10
+ import { useTheme, useColor as colors } from '../../../theme';
11
+ import { classNames, refType as ref } from '../../../utils';
13
12
  import { alignCenter, border, borderBox, borderNone, borderRadius4px, displayBlock, flexRow, outlineNone, parseHeight, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative } from '../../../styles/general';
14
13
  const {
15
14
  colors: {
16
- danger,
17
- info,
18
- success,
19
- warning,
20
15
  system: {
21
16
  active: systemActive,
22
17
  white: systemWhite,
23
18
  disabled: systemDisabled
24
19
  },
20
+ semantic: {
21
+ info: semanticInfo
22
+ },
25
23
  fill: {
26
24
  hover: fillHover,
27
25
  disabled: fillDisabled
@@ -80,12 +78,10 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
80
78
  ...props
81
79
  }, reference) => {
82
80
  if (!autoWidth && inputProps !== null && inputProps !== void 0 && inputProps.autoWidth) autoWidth = inputProps.autoWidth;
83
-
84
81
  const _onChange = e => {
85
82
  onChange && onChange(e);
86
83
  dynamicWidth(e);
87
84
  };
88
-
89
85
  const {
90
86
  bind,
91
87
  value
@@ -97,24 +93,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
97
93
  const styleInputBase = useRef(null);
98
94
  const widthInit = useRef(null);
99
95
  const isEnabled = !readOnly && !disabled;
100
-
101
- const _InputBaseRootCSS = InputBaseRootCSS(autoWidth, readOnly);
102
-
103
- const _InputCSS = InputCSS(autoWidth, isEnabled, hoverTooltip, endIcon);
104
-
96
+ const _InputBaseCSS = InputBaseCSS(readOnly, status);
97
+ const _SingleLineCSS = SingleLineCSS(autoWidth);
98
+ const _InputCSS = InputCSS(autoWidth, isEnabled, hoverTooltip);
105
99
  const _TypoCSS = TypoCSS(disabled);
106
-
107
100
  const _TextAreaCSS = TextAreaCSS(resize, readOnly);
101
+ const _MultilineCSS = MultilineCSS(_TextAreaCSS.name, rows, maxRows);
102
+ const _InputBaseIconCSS = InputBaseIconCSS(multiline);
108
103
 
109
- const _MultilineCSS = MultilineCSS(_TextAreaCSS.name, readOnly, rows, maxRows);
110
104
  /* Start handler */
111
-
112
-
113
105
  const onInputTextArea = e => {
114
106
  if (!/\d+/.test(rows)) {
115
107
  const el = e.target;
116
108
  const defaultHeight = 24;
117
-
118
109
  if (el.value) {
119
110
  el.style.height = 0;
120
111
  el.style.height = Math.max(defaultHeight, el.scrollHeight) + 'px';
@@ -122,10 +113,8 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
122
113
  el.style.height = defaultHeight + 'px';
123
114
  }
124
115
  }
125
-
126
116
  !!onInput && onInput(e);
127
117
  };
128
-
129
118
  useEffect(() => {
130
119
  if (defaultValue !== undefined && defaultValue !== '') {
131
120
  if (multiline && !/\d+/.test(rows)) {
@@ -138,18 +127,15 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
138
127
  if (multiline && !/\d+/.test(rows) && !(inputBaseRef.current.value || inputBaseRef.current.value === 0)) {
139
128
  inputBaseRef.current.style.height = '24px';
140
129
  }
141
-
142
130
  if (autoFocus) {
143
131
  inputBaseRef.current.focus();
144
132
  }
145
133
  }, [multiline]);
146
134
  useEffect(() => {
147
135
  const defaultHeight = 24;
148
-
149
136
  if (valueProp !== undefined) {
150
137
  valueArray.current.push(valueProp);
151
138
  inputBaseRef.current.value = valueProp;
152
-
153
139
  if (multiline && !/\d+/.test(rows)) {
154
140
  inputBaseRef.current.style.height = 0;
155
141
  inputBaseRef.current.style.height = Math.max(defaultHeight, inputBaseRef.current.scrollHeight) + 'px';
@@ -161,7 +147,6 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
161
147
  });
162
148
  }
163
149
  }
164
-
165
150
  return () => {
166
151
  if (valueProp !== undefined && multiline && !/\d+/.test(rows) && inputBaseRef.current) {
167
152
  inputBaseRef.current.style.height = defaultHeight + 'px';
@@ -172,22 +157,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
172
157
 
173
158
  useImperativeHandle(reference, () => {
174
159
  const currentRef = inputBaseRef.current || {};
175
- const _instance = { ...action
160
+ const _instance = {
161
+ ...action
176
162
  }; // methods
177
-
178
163
  _instance.__proto__ = {}; // hidden methods
179
-
180
164
  currentRef.instance = _instance;
181
165
  return currentRef;
182
166
  });
183
-
184
167
  const saveInitInfo = refs => {
185
168
  if (!autoWidth) return;
186
169
  const style = window.getComputedStyle(refs) || refs.currentStyle;
187
170
  if (!widthInit.current) widthInit.current = parseInt(style.width);
188
171
  styleInputBase.current = style;
189
172
  };
190
-
191
173
  const dynamicWidth = e => {
192
174
  if (!autoWidth || !inputBaseRef.current) return;
193
175
  if (!canvas || !styleInputBase.current || !inputBaseRef.current) return;
@@ -198,72 +180,65 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
198
180
  } = context.measureText(e.target.value);
199
181
  inputBaseRef.current.style.width = `${Math.max(width, widthInit.current)}px`;
200
182
  };
201
- /* Start component */
202
-
203
183
 
204
- const newClass = (viewType === 'outlined' ? 'outlined' : 'underlined') + (nonStyle ? ' non-style' : '');
205
- const MultipleInputComp = jsx("div", {
206
- css: _MultilineCSS,
207
- className: classNames('DGN-UI-InputBase', newClass, className, disabled && 'disabled'),
208
- ref: ref,
209
- ...props
210
- }, jsx("textarea", {
211
- placeholder: isEnabled ? placeholder : '',
212
- defaultValue: defaultValue,
213
- ...inputProps,
214
- css: _TextAreaCSS,
215
- readOnly: readOnly,
216
- style: inputStyle || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
217
- className: classNames(inputProps.className),
218
- ref: inputBaseRef,
219
- onKeyDown: onKeyDown,
220
- onKeyUp: onKeyUp,
221
- onInput: onInputTextArea,
222
- onBlur: onBlur,
223
- onFocus: onFocus,
224
- disabled: disabled,
225
- ...bind
226
- }));
184
+ /* Start component */
185
+ const newClass = viewType + (viewType === 'none' || nonStyle ? ' non-style' : '');
227
186
  const StartIcon = useMemo(() => {
228
187
  let node = startIcon;
229
-
230
188
  if (typeof node === 'string') {
231
189
  node = jsx(Icon, {
232
190
  name: startIcon,
233
191
  style: iconStyle
234
192
  });
235
193
  }
236
-
237
194
  return jsx("div", {
238
- css: InputBaseIconCSS,
195
+ css: _InputBaseIconCSS,
239
196
  ...startIconProps,
240
- className: classNames('start-icon', startIconProps.className)
197
+ className: classNames('DGN-UI-InputBase-Start-Icon', startIconProps.className)
241
198
  }, node);
242
199
  }, [startIcon]);
243
200
  const EndIcon = useMemo(() => {
244
201
  let node = endIcon;
245
-
246
202
  if (typeof node === 'string') {
247
203
  node = jsx(Icon, {
248
204
  name: endIcon,
249
205
  style: iconStyle
250
206
  });
251
207
  }
252
-
253
208
  return jsx("div", {
254
- css: InputBaseIconCSS,
209
+ css: _InputBaseIconCSS,
255
210
  ...endIconProps,
256
- className: classNames('end-icon', endIconProps.className)
211
+ className: classNames('DGN-UI-InputBase-End-Icon', endIconProps.className)
257
212
  }, ' ', node, ' ');
258
213
  }, [endIcon]);
214
+ const MultipleInputComp = jsx("div", {
215
+ css: [_InputBaseCSS, _MultilineCSS],
216
+ className: classNames('DGN-UI-InputBase', newClass, className, disabled && 'disabled'),
217
+ ref: ref,
218
+ ...props
219
+ }, startIcon && StartIcon, jsx("textarea", {
220
+ placeholder: isEnabled ? placeholder : '',
221
+ defaultValue: defaultValue,
222
+ ...inputProps,
223
+ css: _TextAreaCSS,
224
+ readOnly: readOnly,
225
+ style: inputStyle || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
226
+ className: classNames('DGN-UI-InputBase-Textarea', inputProps.className),
227
+ ref: inputBaseRef,
228
+ onKeyDown: onKeyDown,
229
+ onKeyUp: onKeyUp,
230
+ onInput: onInputTextArea,
231
+ onBlur: onBlur,
232
+ onFocus: onFocus,
233
+ disabled: disabled,
234
+ ...bind
235
+ }), endIcon && EndIcon);
259
236
  const InputComp = jsx("div", {
260
- css: _InputBaseRootCSS,
237
+ css: [[_InputBaseCSS, _SingleLineCSS]],
261
238
  ref: ref,
262
239
  ...props,
263
- className: classNames('DGN-UI-InputBase', newClass, className, status, disabled && 'disabled')
264
- }, startIcon && StartIcon, jsx("div", {
265
- css: InputBaseCSS
266
- }, jsx("input", {
240
+ className: classNames('DGN-UI-InputBase', newClass, className, disabled && 'disabled')
241
+ }, startIcon && StartIcon, jsx("input", {
267
242
  type: type,
268
243
  autoComplete: autoComplete,
269
244
  placeholder: isEnabled ? placeholder : '',
@@ -271,7 +246,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
271
246
  ...inputProps,
272
247
  readOnly: readOnly,
273
248
  style: inputStyle || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
274
- className: classNames(newClass, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
249
+ className: classNames('DGN-UI-InputBase-Input', newClass, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
275
250
  ref: refs => {
276
251
  if (!refs) return;
277
252
  inputBaseRef.current = refs;
@@ -292,43 +267,92 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
292
267
  hoverTooltip: true,
293
268
  type: 'p1',
294
269
  style: {
295
- lineHeight: '24px'
270
+ lineHeight: '26px',
271
+ width: '100%'
296
272
  }
297
- }, value !== null && value !== void 0 ? value : '')), endIcon && EndIcon);
273
+ }, value !== null && value !== void 0 ? value : ''), endIcon && EndIcon);
298
274
  /* End component */
299
275
 
300
276
  return multiline ? MultipleInputComp : InputComp;
301
277
  }));
302
-
303
- const InputBaseRootCSS = (autoWidth, readOnly) => css`
278
+ const InputBaseCSS = (readOnly, status) => css`
304
279
  ${flexRow};
305
- ${alignCenter};
306
280
  ${positionRelative};
307
- ${parseWidthHeight(autoWidth ? 'max-content' : 'auto', 'max-content')}
308
- flex: 1 1 auto;
281
+ ${borderBox};
309
282
  &:hover,
310
283
  &:focus-within {
311
- .start-icon:not(.non-effect) {
284
+ .DGN-UI-InputBase-Start-Icon:not(.non-effect) {
312
285
  path {
313
286
  fill: ${systemActive};
314
287
  }
315
288
  }
316
289
  }
317
- &:focus-within {
318
- border-bottom-color: ${info};
290
+ &.disabled {
291
+ ${pointerEventsNone};
292
+ border-color: ${lineDisabled} !important;
293
+ &::before {
294
+ border-bottom-color: ${lineDisabled} !important;
295
+ }
296
+ &.outlined {
297
+ background-color: ${fillDisabled};
298
+ }
299
+ .DGN-UI-InputBase-Start-Icon,
300
+ .DGN-UI-InputBase-End-Icon {
301
+ &:not(.non-effect),
302
+ &.allow-disabled {
303
+ path {
304
+ fill: ${systemDisabled};
305
+ }
306
+ }
307
+ }
308
+ }
309
+ &.outlined {
310
+ ${border(1, lineNormal)};
311
+ ${borderRadius4px};
312
+ padding: ${spacing([1.75, 4])};
313
+ &:not(:focus-within):hover {
314
+ ${!readOnly && `
315
+ background-color: ${fillHover};
316
+ border-color: ${lineHover};
317
+ input, textarea {
318
+ ::placeholder {
319
+ color: ${systemActive};
320
+ }
321
+ }
322
+ `};
323
+ }
324
+ &:focus-within {
325
+ ${!readOnly && `
326
+ border-color: ${lineFocus};
327
+ box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
328
+ &::after {
329
+ border-color: inherit;
330
+ }
331
+ `}
332
+ }
319
333
  &::after {
320
- border-bottom-color: inherit;
321
- transform: scaleX(1);
334
+ content: '';
335
+ ${positionAbsolute};
336
+ ${borderRadius4px};
337
+ ${pointerEventsNone};
338
+ ${border(2, 'transparent')};
339
+ left: -2px;
340
+ right: -2px;
341
+ top: -2px;
342
+ bottom: -2px;
322
343
  }
323
344
  }
324
345
  &.underlined {
325
346
  padding-bottom: ${spacing([1])};
326
347
  padding-top: ${spacing([1])};
327
348
  &:not(:focus-within):hover {
328
- &::before {
329
- ${!readOnly && `border-bottom-color: ${lineHover}`};
330
- }
331
- input {
349
+ ${!readOnly && `
350
+ &::before {
351
+ border-bottom-color: ${lineHover};
352
+ }
353
+ `};
354
+ input,
355
+ textarea {
332
356
  ::placeholder {
333
357
  color: ${systemActive};
334
358
  }
@@ -336,12 +360,11 @@ const InputBaseRootCSS = (autoWidth, readOnly) => css`
336
360
  }
337
361
  &:focus-within {
338
362
  ${!readOnly && `
339
- border-bottom-color: ${lineFocus};
340
- &::after {
341
- border-bottom-color: inherit;
342
- transform: scaleX(1);
343
- }
344
- `}
363
+ &::after {
364
+ border-bottom-color: ${lineFocus};
365
+ transform: scaleX(1);
366
+ }
367
+ `}
345
368
  }
346
369
  &::before {
347
370
  content: '';
@@ -363,56 +386,14 @@ const InputBaseRootCSS = (autoWidth, readOnly) => css`
363
386
  transition: all 0.2s ease;
364
387
  }
365
388
  }
366
- &.outlined {
367
- ${border(1, lineNormal)};
368
- ${borderRadius4px};
369
- ${parseHeight(40)};
370
- ${borderBox};
371
- background-color: ${systemWhite};
372
- &:not(:focus-within):hover {
373
- ${!readOnly && `
374
- background-color: ${fillHover};
375
- border-color: ${lineHover};
376
- input {
377
- ::placeholder {
378
- color: ${systemActive};
379
- }
380
- }
381
-
382
- `};
383
- }
384
- &:focus-within {
385
- ${!readOnly && `
386
- border-color: ${lineFocus};
387
- box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
388
- &::after {
389
- border-color: inherit;
390
- }
391
- `}
392
- }
393
- &::after {
394
- content: '';
395
- ${positionAbsolute};
396
- ${border(2, 'transparent')};
397
- ${borderRadius4px};
398
- ${pointerEventsNone};
399
- left: -2px;
400
- right: -2px;
401
- top: -2px;
402
- bottom: -2px;
403
- }
404
- .start-icon {
405
- margin-left: ${spacing([4])};
406
- }
407
- .end-icon {
408
- margin-right: ${spacing([4])};
409
- }
410
- }
411
389
  &.non-style {
390
+ padding-bottom: ${spacing([1])};
391
+ padding-top: ${spacing([1])};
412
392
  border-color: transparent !important;
413
393
  box-shadow: none !important;
414
394
  background-color: transparent !important;
415
- input {
395
+ input,
396
+ textarea {
416
397
  background-color: transparent !important;
417
398
  }
418
399
  &:before,
@@ -420,62 +401,32 @@ const InputBaseRootCSS = (autoWidth, readOnly) => css`
420
401
  border-color: transparent !important;
421
402
  }
422
403
  }
423
- &.info {
424
- border-color: ${info} !important;
425
- &::before {
426
- border-color: ${info} !important;
427
- }
428
- }
429
- &.success {
430
- border-color: ${success} !important;
431
- &::before {
432
- border-color: ${success} !important;
433
- }
434
- }
435
- &.warning {
436
- border-color: ${warning} !important;
437
- &::before {
438
- border-color: ${warning} !important;
439
- }
440
- }
441
- &.danger {
442
- border-color: ${danger} !important;
443
- &::before {
444
- border-color: ${danger} !important;
445
- }
446
- }
447
- &.disabled {
448
- ${pointerEventsNone};
449
- border-color: ${lineDisabled} !important;
450
- &::before {
451
- border-bottom-color: ${lineDisabled} !important;
452
- }
453
- &.outlined {
454
- background-color: ${fillDisabled};
455
- }
456
- .start-icon,
457
- .end-icon {
458
- &:not(.non-effect),
459
- &.allow-disabled {
460
- path {
461
- fill: ${systemDisabled};
462
- }
463
- }
464
- }
465
- }
404
+ ${status !== 'default' && `border-color: ${colors[status]} !important;&::before {
405
+ border-color: ${colors[status]} !important;
406
+ }`}
466
407
  & + .DGN-UI-HelperText {
467
408
  ${positionAbsolute};
468
409
  min-height: 16px;
469
410
  top: 100%;
470
411
  }
471
412
  `;
472
-
473
- const InputBaseCSS = css`
474
- ${flexRow};
413
+ const SingleLineCSS = autoWidth => css`
414
+ ${parseWidthHeight(autoWidth ? 'max-content' : 'auto', 'max-content')}
415
+ ${alignCenter};
475
416
  flex: 1 1 auto;
417
+ &:focus-within {
418
+ border-bottom-color: ${semanticInfo};
419
+ &::after {
420
+ border-bottom-color: inherit;
421
+ transform: scaleX(1);
422
+ }
423
+ }
424
+ &.outlined {
425
+ ${parseHeight(40)};
426
+ background-color: ${systemWhite};
427
+ }
476
428
  `;
477
-
478
- const InputCSS = (autoWidth, isEnabled, hoverTooltip, endIcon) => css`
429
+ const InputCSS = (autoWidth, isEnabled, hoverTooltip) => css`
479
430
  ${parseWidthHeight(autoWidth ? '10px' : '100%', 24)};
480
431
  ${borderNone};
481
432
  ${outlineNone};
@@ -483,6 +434,7 @@ const InputCSS = (autoWidth, isEnabled, hoverTooltip, endIcon) => css`
483
434
  color: ${textMain};
484
435
  background-color: transparent;
485
436
  padding-top: 0;
437
+ padding-bottom: 0;
486
438
  ${paragraph1};
487
439
  text-overflow: ellipsis;
488
440
  &::placeholder {
@@ -496,13 +448,7 @@ const InputCSS = (autoWidth, isEnabled, hoverTooltip, endIcon) => css`
496
448
  &:hover {
497
449
  color: ${systemActive};
498
450
  }
499
- &.outlined {
500
- padding-bottom: inherit;
501
- padding-left: ${spacing([4])};
502
- padding-right: ${endIcon ? 0 : spacing([4])};
503
- }
504
451
  &.underlined {
505
- padding-bottom: 0;
506
452
  padding-left: 0;
507
453
  padding-right: 0;
508
454
  }
@@ -511,14 +457,8 @@ const InputCSS = (autoWidth, isEnabled, hoverTooltip, endIcon) => css`
511
457
  }
512
458
  ${!isEnabled && hoverTooltip && 'display: none'};
513
459
  `;
514
-
515
460
  const TypoCSS = disabled => css`
516
461
  ${parseHeight(24)};
517
- &.outlined {
518
- padding-bottom: inherit;
519
- padding-left: ${spacing([4])};
520
- padding-right: ${spacing([4])};
521
- }
522
462
  &:focus {
523
463
  background-color: transparent;
524
464
  color: ${systemActive};
@@ -528,16 +468,32 @@ const TypoCSS = disabled => css`
528
468
  }
529
469
  ${disabled && 'user-select: none'};
530
470
  `;
531
-
471
+ const MultilineCSS = (TextAreaCSSName, rows, maxRows) => css`
472
+ ${parseWidthHeight('100%', 'max-content')};
473
+ &.outlined {
474
+ .css-${TextAreaCSSName} {
475
+ ${parseHeight(24)};
476
+ ${rows && /\d+/.test(rows) && `height: ${20 * rows + 4}px`};
477
+ ${maxRows && /\d+/.test(maxRows) && `max-height: ${20 * maxRows + 4}px`};
478
+ }
479
+ }
480
+ &.underlined {
481
+ .css-${TextAreaCSSName} {
482
+ ${parseHeight(24)};
483
+ ${rows && /\d+/.test(rows) && `height: ${20 * rows + 4}px`};
484
+ ${maxRows && /\d+/.test(maxRows) && `max-height: ${20 * maxRows + 4}px`};
485
+ }
486
+ }
487
+ `;
532
488
  const TextAreaCSS = (resize, readOnly) => css`
533
489
  ${displayBlock};
534
- color: ${textMain};
535
490
  ${paragraph1};
536
491
  ${borderNone};
537
492
  ${outlineNone};
538
493
  ${positionRelative};
539
494
  ${borderBox};
540
495
  ${parseWidth('100%')};
496
+ color: ${textMain};
541
497
  min-height: max-content;
542
498
  min-width: max-content;
543
499
  background-color: transparent;
@@ -546,12 +502,12 @@ const TextAreaCSS = (resize, readOnly) => css`
546
502
  resize: ${resize};
547
503
  &:hover:not(:focus-within) {
548
504
  ${!readOnly && `
549
- border-color: ${systemActive};
550
- color: ${systemActive};
551
- ::placeholder {
552
- color: ${systemActive};
553
- }
554
- `};
505
+ border-color: ${systemActive};
506
+ color: ${systemActive};
507
+ ::placeholder {
508
+ color: ${systemActive};
509
+ }
510
+ `};
555
511
  }
556
512
  &:focus-within {
557
513
  color: ${systemActive};
@@ -568,118 +524,17 @@ const TextAreaCSS = (resize, readOnly) => css`
568
524
  background-clip: content-box;
569
525
  }
570
526
  `;
571
-
572
- const MultilineCSS = (TextAreaCSSName, readOnly, rows, maxRows) => css`
573
- ${displayBlock};
574
- ${positionRelative};
575
- ${borderBox};
576
- ${parseWidthHeight('100%', 'max-content')};
577
- &.outlined {
578
- ${border(1, lineNormal)};
579
- ${borderRadius4px};
580
- padding: ${spacing([1.75, 4])};
581
- .css-${TextAreaCSSName} {
582
- ${parseHeight(24)};
583
- ${rows && /\d+/.test(rows) && `height: ${20 * rows + 4}px`};
584
- ${maxRows && /\d+/.test(maxRows) && `max-height: ${20 * maxRows + 4}px`};
585
- }
586
- &:not(:focus-within):hover {
587
- ${!readOnly && `
588
- background-color: ${fillHover};
589
- border-color: ${lineHover};
590
- `};
591
- }
592
- &:focus-within {
593
- ${!readOnly && `
594
- border-color: ${lineFocus};
595
- box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
596
- &::after {
597
- border-color: inherit;
598
- }
599
- `}
600
- }
601
- &::after {
602
- content: '';
603
- ${positionAbsolute};
604
- ${borderRadius4px};
605
- ${pointerEventsNone};
606
- ${border(2, 'transparent')}
607
- left: -2px;
608
- right: -2px;
609
- top: -2px;
610
- bottom: -2px;
611
- }
612
- }
613
- &.underlined {
614
- border: 0;
615
- padding: ${spacing(1, 0)};
616
- .css-${TextAreaCSSName} {
617
- ${parseHeight(24)};
618
- ${rows && /\d+/.test(rows) && `height: ${20 * rows + 4}px`};
619
- ${maxRows && /\d+/.test(maxRows) && `max-height: ${20 * maxRows + 4}px`};
620
- }
621
- &:not(:focus-within):hover {
622
- ${!readOnly && `
623
- &::before {
624
- border-bottom-color: ${lineHover};
625
- }
626
- `};
627
- }
628
- &:focus-within {
629
- ${!readOnly && `
630
- &::after {
631
- border-bottom-color: ${lineFocus};
632
- transform: scaleX(1);
633
- }
634
- `}
635
- }
636
- &::before {
637
- content: '';
638
- ${positionAbsolute};
639
- left: 0;
640
- right: 0;
641
- bottom: 0;
642
- border-bottom: 1px solid ${lineNormal};
643
- }
644
- &::after {
645
- content: '';
646
- ${positionAbsolute};
647
- left: 0px;
648
- right: 0px;
649
- bottom: -1px;
650
- border-bottom: 2px solid transparent;
651
- transform: scaleX(0);
652
- transform-origin: center;
653
- transition: all 0.2s ease;
654
- }
655
- }
656
- &.disabled {
657
- ${pointerEventsNone};
658
- resize: none;
659
- &.outlined {
660
- background-color: ${fillDisabled};
661
- }
662
- &.underlined::before {
663
- border-bottom-color: ${fillDisabled} !important;
664
- }
665
- }
666
- & + .DGN-UI-HelperText {
667
- ${positionAbsolute};
668
- min-height: 16px;
669
- top: 100%;
670
- }
671
- `;
672
-
673
- const InputBaseIconCSS = css`
527
+ const InputBaseIconCSS = multiple => css`
674
528
  ${flexRow};
529
+ ${multiple && 'align-self: flex-end'};
675
530
  color: inherit;
676
- &.start-icon {
531
+ &.DGN-UI-InputBase-Start-Icon {
677
532
  margin-right: ${spacing([1])};
678
533
  & + input {
679
534
  padding-left: 0;
680
535
  }
681
536
  }
682
- &.end-icon {
537
+ &.DGN-UI-InputBase-End-Icon {
683
538
  margin-left: ${spacing([1])};
684
539
  }
685
540
  `;
@@ -706,103 +561,67 @@ InputBase.defaultProps = {
706
561
  viewType: 'underlined'
707
562
  };
708
563
  InputBase.propTypes = {
709
- /** the type of border you want to display */
710
- viewType: PropTypes.oneOf(['underlined', 'outlined']),
711
-
712
- /** default value is displayed for first render */
713
- defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
714
-
715
- /** the displayed value for each change */
716
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
717
-
718
- /** hints for input */
719
- placeholder: PropTypes.string,
720
-
721
- /** type auto complete of input (like new-password) */
564
+ /** This prop helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill). */
722
565
  autoComplete: PropTypes.string,
723
-
724
- /** allow resize multiline input (resize css style) */
725
- resize: PropTypes.string,
726
-
727
- /** class for InputBase component */
566
+ /** If `true`, the input element is focused during the first mount. */
567
+ autoFocus: PropTypes.bool,
568
+ /** If `true`, the width of the component will automatically be set according to the contents inside the input, don't run with multiline = true */
569
+ autoWidth: PropTypes.bool,
570
+ /** Class for component. */
728
571
  className: PropTypes.string,
729
-
730
- /** the number of rows of textarea */
731
- rows: PropTypes.number,
732
-
733
- /** the maximum of rows of textarea */
734
- maxRows: PropTypes.number,
735
-
736
- /** status type to display color for input (only available for type is inform) */
737
- status: PropTypes.oneOf(['default', 'warning', 'success', 'danger', 'info']),
738
-
739
- /** use multiline input if true */
740
- multiline: PropTypes.bool,
741
-
742
- /** transparent border color if true */
743
- nonStyle: PropTypes.bool,
744
-
745
- /** prevent all event if true, hide all icon */
572
+ /** The default value. Use when the component is not controlled. */
573
+ defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
574
+ /** The number of milliseconds to wait before call onChange. */
575
+ delayOnChange: PropTypes.number,
576
+ /** If `true`, the component is disabled.*/
746
577
  disabled: PropTypes.bool,
747
-
748
- /** prevent all event if true */
749
- readOnly: PropTypes.bool,
750
-
751
- /** autofocus after first render */
752
- autoFocus: PropTypes.bool,
753
-
754
- /** At least one character is required */
755
- required: PropTypes.bool,
756
-
757
- /** icon element display in the left of input */
758
- startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
759
-
760
- /** icon element display in the right of input */
578
+ /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the right of input. */
761
579
  endIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
762
-
763
- /** props of input in InputBase component */
764
- inputProps: PropTypes.object,
765
-
766
- /** props of start icon in InputBase component */
767
- startIconProps: PropTypes.object,
768
-
769
- /** props of end icon in InputBase component */
580
+ /** Props of end icon. */
770
581
  endIconProps: PropTypes.object,
771
-
772
- /** style inline of icon in InputBase component */
582
+ /** Style inline of icon. */
773
583
  iconStyle: PropTypes.object,
774
-
775
- /** style inline of input in InputBase component */
584
+ /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
585
+ inputProps: PropTypes.object,
586
+ /** Pass a ref to the input element. */
587
+ inputRef: ref,
588
+ /** Style inline of input element. */
776
589
  inputStyle: PropTypes.object,
777
-
778
- /** The function to get ref of Dropdown component */
779
- refs: PropTypes.func,
780
-
781
- /** on key down function */
782
- onKeyDown: PropTypes.func,
783
-
784
- /** on key up function */
785
- onKeyUp: PropTypes.func,
786
-
787
- /** on input function */
788
- onInput: PropTypes.func,
789
-
790
- /** on change function */
791
- onChange: PropTypes.func,
792
-
793
- /** on blur function */
590
+ /** Maximum number of rows to display when multiline option is set to true. */
591
+ maxRows: PropTypes.number,
592
+ /** If `true`, a textarea element is rendered. */
593
+ multiline: PropTypes.bool,
594
+ /** Callback fired when the input is blurred. */
794
595
  onBlur: PropTypes.func,
795
-
796
- /** on focus function */
596
+ /** Callback fired when the value is changed. */
597
+ onChange: PropTypes.func,
598
+ /** Callback fired when the input is focused. */
797
599
  onFocus: PropTypes.func,
798
-
799
- /** inputRef of InputBase component */
800
- inputRef: PropTypes.any,
801
-
802
- /** delayOnChange of InputBase component */
803
- delayOnChange: PropTypes.number,
804
-
805
- /** autoWidth of TextInput component, don't run with multiline = true */
806
- autoWidth: PropTypes.bool
600
+ /** Callback fired when input. */
601
+ onInput: PropTypes.func,
602
+ /** Callback fired when pressing a key. */
603
+ onKeyDown: PropTypes.func,
604
+ /** Callback fired when releases a key. */
605
+ onKeyUp: PropTypes.func,
606
+ /** The short hint displayed in the input before the user enters a value. */
607
+ placeholder: PropTypes.string,
608
+ /** If `true`, the component is readonly. */
609
+ readOnly: PropTypes.bool,
610
+ /** If `true`, the input element is required. */
611
+ required: PropTypes.bool,
612
+ /** allow resize multiline input (resize css style) */
613
+ resize: PropTypes.string,
614
+ /** Number of rows to display when multiline option is set to true. */
615
+ rows: PropTypes.number,
616
+ /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the left of input. */
617
+ startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
618
+ /** Props of start icon. */
619
+ startIconProps: PropTypes.object,
620
+ /** Status type to display color for input. */
621
+ status: PropTypes.oneOf(['default', 'warning', 'success', 'danger', 'info']),
622
+ /** The value of the input element, required for a controlled component. */
623
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
624
+ /** The variant to use. */
625
+ viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
807
626
  };
808
627
  export default InputBase;