diginet-core-ui 1.3.90-beta.3 → 1.3.90-beta.5

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,35 +1,28 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
-
4
3
  import { css, jsx } from '@emotion/core';
4
+ import { Button, ButtonIcon, HelperText, InputBase, Label, Tooltip } from "../..";
5
+ import { getGlobal } from "../../../global";
6
+ import locale from "../../../locale";
5
7
  import PropTypes from 'prop-types';
6
8
  import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
7
9
  import { render } from 'react-dom';
8
- import { getGlobal } from "../../../global";
9
- import { date as moment, capitalizeSentenceCase, randomString, updatePosition } from "../../../utils";
10
+ import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexRow, itemsCenter, justifyEnd, left, mg, parseMaxWidth, parseMinWidth, parseWidthHeight, positionFixed, scale, top, z } from "../../../styles/general";
11
+ import { useTheme } from "../../../theme";
12
+ import { capitalizeSentenceCase, date as moment, randomString, updatePosition } from "../../../utils";
10
13
  import CalendarComp from "../calendar";
11
- import ControlComp from "../control";
12
- import { ButtonIcon, HelperText, InputBase, Label } from "../../index";
13
- import Button from "../../button";
14
- import Tooltip from "../../tooltip";
15
14
  import { isValidDate } from "../calendar/function";
16
- import { itemsCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexRow, justifyEnd, parseWidth, positionFixed } from "../../../styles/general";
17
- import theme from "../../../theme/settings";
15
+ import ControlComp from "../control";
18
16
  const {
19
- colors: {
20
- system: {
21
- white
22
- }
23
- },
24
- spacing,
25
17
  zIndex: zIndexCORE
26
- } = theme;
18
+ } = useTheme();
27
19
  const confirmText = getGlobal(['confirm']);
28
20
  const cancelText = getGlobal(['cancel']);
29
21
  const formatValue = (value, format, utc = false) => {
30
22
  return moment(value).format(format, utc);
31
23
  };
32
24
  const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
25
+ action = {},
33
26
  actionIconAt,
34
27
  clearAble,
35
28
  controls,
@@ -153,16 +146,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
153
146
  }
154
147
  return PickerCSS.picker(style, left + 400 > innerWidth ? innerWidth - 400 : left, width).styles;
155
148
  };
156
- // const createPortal = () => {
157
- // let portal = document.getElementById(unique.portal);
158
- // if (!portal) {
159
- // portal = document.createElement('div');
160
- // portal.id = unique.portal;
161
- // document.body.appendChild(portal);
162
- // }
163
- // portal.style.cssText = pickerCSS.portal;
164
- // return portal;
165
- // };
166
149
  const createBackground = () => {
167
150
  let background = document.getElementById(unique.backGr);
168
151
  if (!background) {
@@ -256,26 +239,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
256
239
  // iconRef.current && onSwap(true);
257
240
  ipRef.current && ipRef.current.blur();
258
241
  };
259
- // const updatePicker = () => {
260
- // const portal = document.body.querySelector(`#${unique.portal}`);
261
- // if (!portal) return;
262
- // const backGr = portal.querySelector(`#${unique.backGr}`);
263
- // if (!backGr) return;
264
- // const node = portal.querySelector(`#${unique.picker}`);
265
- // if (!node || !node.firstChild) return;
266
- // unmountComponentAtNode(node);
267
- // render(
268
- // <CalendarComp
269
- // ref={calRef}
270
- // actions={footerMemo}
271
- // defaultValue={displayValue.current}
272
- // value={focusedValue.current}
273
- // max={max}
274
- // min={min}
275
- // displayAnotherMonth={displayAnotherMonth}
276
- // onClick={onCalendarClick}
277
- // />, node);
278
- // };
279
242
  const onSwap = open => {
280
243
  const t = iconRef.current.childNodes[+open];
281
244
  if (open) {
@@ -448,6 +411,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
448
411
  useImperativeHandle(reference, () => {
449
412
  const currentRef = ref.current || {};
450
413
  const _instance = {
414
+ ...action,
451
415
  get: () => {
452
416
  return ref.current;
453
417
  },
@@ -479,11 +443,11 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
479
443
  error: isError,
480
444
  ref: ref,
481
445
  style: style
482
- }, !!label && jsx(Label, {
446
+ }, label ? jsx(Label, {
483
447
  disabled: disabled,
484
448
  required: required,
485
449
  ...labelProps
486
- }, label), jsx(Tooltip, {
450
+ }, label) : null, jsx(Tooltip, {
487
451
  title: (ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current = ipRef.current) === null || _ipRef$current === void 0 ? void 0 : _ipRef$current.clientWidth) < 200 ? ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current2 = ipRef.current) === null || _ipRef$current2 === void 0 ? void 0 : _ipRef$current2.value : ''
488
452
  }, jsx(InputBase, {
489
453
  inputProps: {
@@ -502,7 +466,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
502
466
  endIcon: endIcon,
503
467
  onKeyDown: e => e.preventDefault(),
504
468
  readOnly: true
505
- })), isError && jsx(HelperText, {
469
+ })), isError ? jsx(HelperText, {
506
470
  ...errorProps,
507
471
  style: {
508
472
  minHeight: 16,
@@ -510,7 +474,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
510
474
  top: '100%'
511
475
  },
512
476
  disabled: disabled
513
- }, error));
477
+ }, error) : null);
514
478
  }));
515
479
  const hiddenStyle = {
516
480
  opacity: 0,
@@ -522,6 +486,7 @@ const activeStyle = {
522
486
  display: 'block'
523
487
  };
524
488
  const IconAreaCSS = unique => css`
489
+ ${displayFlex};
525
490
  ${flexRow};
526
491
  ${itemsCenter};
527
492
  color: inherit;
@@ -538,27 +503,28 @@ const IconAreaCSS = unique => css`
538
503
  }
539
504
  `;
540
505
  const ControlContainerCSS = css`
506
+ ${displayFlex};
541
507
  ${flexRow};
542
508
  ${justifyEnd};
543
- margin: ${spacing([0, 4, 4])};
509
+ ${mg([0, 4, 4])};
544
510
  `;
545
511
  const PickerCSS = {
546
512
  backGr: `background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: ${zIndexCORE(1)};`,
547
- picker: (position, left, width) => css`
513
+ picker: (position, positionLeft, width) => css`
548
514
  ${positionFixed};
549
515
  ${borderRadius4px};
550
- ${parseWidth(width)};
551
- background-color: ${white};
552
- height: max-content;
553
- left: ${left}px;
554
- top: ${position.top}px;
516
+ ${bgColor('system.white')};
517
+ ${parseWidthHeight(width, 'max-content')};
518
+ ${parseMinWidth(window.innerWidth <= 599 ? 280 : 314)};
519
+ ${parseMaxWidth(400)};
520
+ ${scale(0)};
521
+ ${left(positionLeft)};
522
+ ${top(position.top)};
555
523
  transform-origin: ${position.transformOrigin};
556
- max-width: 400px;
557
- min-width: ${window.innerWidth <= 599 ? 280 : 314}px;
558
524
  opacity: 0;
559
525
  transform: scale(0);
560
526
  transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
561
- z-index: ${zIndexCORE(2)};
527
+ ${z(2)};
562
528
  `,
563
529
  active: {
564
530
  opacity: 1,
@@ -576,12 +542,12 @@ DatePicker.defaultProps = {
576
542
  controls: false,
577
543
  disabled: false,
578
544
  displayAnotherMonth: true,
579
- displayFormat: 'dddd, DD MMMM YYYY',
545
+ displayFormat: locale.get() === 'vi' ? 'DD/MM/YYYY' : 'MM/DD/YYYY',
580
546
  pressESCToClose: true,
581
547
  readOnly: false,
582
548
  required: false,
583
- textAlign: 'start',
584
549
  returnFormat: 'YYYY-MM-DD',
550
+ textAlign: 'start',
585
551
  viewType: 'underlined'
586
552
  };
587
553
  DatePicker.propTypes = {
@@ -7,17 +7,12 @@ import locale from "../../../locale";
7
7
  import PropTypes from 'prop-types';
8
8
  import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
9
  import { render } from 'react-dom';
10
- import { itemsCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexCol, flexRow, justifyEnd, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, parseWidthHeight, pointerEventsNone, positionFixed, textCenter, userSelectNone, whiteSpaceNoWrap } from "../../../styles/general";
10
+ import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, justifyEnd, left, mg, parseHeight, parseMaxWidth, parseMinWidth, parseWidthHeight, pd, pointerEventsNone, positionFixed, textCenter, top, userSelectNone, whiteSpaceNoWrap } from "../../../styles/general";
11
11
  import { useTheme } from "../../../theme";
12
12
  import { capitalizeSentenceCase, classNames, date as moment, isEqual, randomString, updatePosition } from "../../../utils";
13
13
  import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from "../calendar/function";
14
14
  import ControlComp from "../control";
15
15
  const {
16
- colors: {
17
- system: {
18
- white: systemWhite
19
- }
20
- },
21
16
  boxShadows: {
22
17
  large: boxShadowsLarge
23
18
  },
@@ -811,32 +806,11 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
811
806
  if (ipRef.current.value !== '') {
812
807
  update(values.current);
813
808
  }
814
- // if (disabled) {
815
- // iconRef.current.childNodes[0].style.pointerEvents = 'none';
816
- // closePicker();
817
- // } else if (!readOnly) {
818
- // ipRef.current.addEventListener('focus', onInputFocus);
819
- // } else {
820
- // iconRef.current.childNodes[0].style.pointerEvents = 'none';
821
- // closePicker();
822
- // }
823
-
824
809
  if (isEnable) {
825
- // iconRef.current.childNodes[0].style.pointerEvents = 'none';
826
810
  closePicker();
827
811
  }
828
812
  return () => {
829
813
  if (!iconRef.current || !ipRef.current) return;
830
- // if (disabled) {
831
- // iconRef.current.childNodes[0].style.pointerEvents = null;
832
- // } else if (!readOnly) {
833
- // ipRef.current.removeEventListener('focus', onInputFocus);
834
- // } else {
835
- // iconRef.current.childNodes[0].style.pointerEvents = null;
836
- // }
837
- // if (isEnable) {
838
- // iconRef.current.childNodes[0].style.pointerEvents = null;
839
- // }
840
814
  closePicker();
841
815
  };
842
816
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
@@ -861,7 +835,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
861
835
  onClick: triggerFocus,
862
836
  className: `${unique.icon} ${unique.icon}-accept`,
863
837
  viewBox: true,
864
- name: 'CalendarNew'
838
+ name: 'Calendar'
865
839
  }), jsx(ButtonIcon, {
866
840
  viewType: 'ghost',
867
841
  onClick: onClear,
@@ -911,7 +885,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
911
885
  className: unique.tooltip,
912
886
  ref: tooltipRef
913
887
  }, jsx(Typography, {
914
- color: systemWhite,
888
+ color: 'system.white',
915
889
  type: 'p2'
916
890
  }));
917
891
  const pickerComp = jsx("div", {
@@ -1021,13 +995,6 @@ const buttonProps = {
1021
995
  }
1022
996
  };
1023
997
  const IconAreaCSS = css`
1024
- ${flexRow};
1025
- ${itemsCenter};
1026
- ${parseWidth(24)};
1027
- color: inherit;
1028
- & span {
1029
- padding: 0;
1030
- }
1031
998
  .${unique.icon} {
1032
999
  ${displayNone};
1033
1000
  ${cursorPointer};
@@ -1041,9 +1008,10 @@ const IconAreaCSS = css`
1041
1008
  }
1042
1009
  `;
1043
1010
  const ControlContainerCSS = css`
1011
+ ${displayFlex};
1044
1012
  ${flexRow};
1045
1013
  ${justifyEnd};
1046
- margin: ${spacing([0, 4, 4])};
1014
+ ${mg([0, 4, 4])};
1047
1015
  `;
1048
1016
  const pickerCSS = {
1049
1017
  backGr: `
@@ -1052,11 +1020,13 @@ const pickerCSS = {
1052
1020
  position: fixed;
1053
1021
  z-index: ${zIndexCORE(1)};`,
1054
1022
  container: css`
1023
+ ${displayFlex};
1055
1024
  ${flexCol};
1056
1025
  ${borderRadius4px};
1057
- background-color: ${systemWhite};
1026
+ ${bgColor('system.white')};
1058
1027
  box-shadow: ${boxShadowsLarge};
1059
1028
  .${unique.wrapper} {
1029
+ ${displayFlex};
1060
1030
  ${flexRow};
1061
1031
  ${parseMinWidth(633)};
1062
1032
  }
@@ -1069,8 +1039,8 @@ const pickerCSS = {
1069
1039
  ${whiteSpaceNoWrap};
1070
1040
  ${parseHeight(18)};
1071
1041
  ${parseMinWidth(65)};
1072
- background-color: rgba(21, 26, 48, 0.9);
1073
- padding: ${spacing([0.75, 1.5])};
1042
+ ${bgColor('rgba(21, 26, 48, 0.9)')};
1043
+ ${pd([0.75, 1.5])};
1074
1044
  transition: left 0.05s ease-in, top 0.05s ease-in;
1075
1045
  vertical-align: middle;
1076
1046
  visibility: hidden;
@@ -1080,7 +1050,8 @@ const pickerCSS = {
1080
1050
  @media only screen and (max-width: 599px) {
1081
1051
  ${parseMaxWidth(400)};
1082
1052
  .${unique.wrapper} {
1083
- flex-direction: column;
1053
+ ${displayFlex};
1054
+ ${flexCol};
1084
1055
  ${parseMinWidth(260)};
1085
1056
  }
1086
1057
  .${unique.divider} {
@@ -1096,8 +1067,8 @@ const pickerCSS = {
1096
1067
  ${parseWidthHeight(width, 'max-content')};
1097
1068
  ${parseMinWidth(window.innerWidth <= 633 ? 300 : 633)};
1098
1069
  ${parseMaxWidth(805)};
1099
- top: ${position.top}px;
1100
- left: ${position.left}px;
1070
+ ${top(position.top)};
1071
+ ${left(position.left)};
1101
1072
  opacity: 0;
1102
1073
  transform: scale(0);
1103
1074
  transform-origin: ${position.transformOrigin};
@@ -1138,8 +1109,6 @@ DateRangePicker.propTypes = {
1138
1109
  clearAble: PropTypes.bool,
1139
1110
  /** If `true`, the calendar will have a footer controls. */
1140
1111
  controls: PropTypes.bool,
1141
- /** The count unit when select. */
1142
- unitCount: PropTypes.oneOf(['day', 'night']),
1143
1112
  /** Default value of the component. */
1144
1113
  defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.instanceOf(Date)), PropTypes.arrayOf(PropTypes.string)]),
1145
1114
  /** If `true`, the component is disabled. */
@@ -1158,10 +1127,10 @@ DateRangePicker.propTypes = {
1158
1127
  label: PropTypes.string,
1159
1128
  /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
1160
1129
  labelProps: PropTypes.object,
1161
- /** Min value of date picker. */
1162
- min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
1163
1130
  /** Max value of date picker. */
1164
1131
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
1132
+ /** Min value of date picker. */
1133
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
1165
1134
  /** Callback fired when the value is changed. */
1166
1135
  onChange: PropTypes.func,
1167
1136
  /** The short hint displayed in the input before the user enters a value. */
@@ -1182,6 +1151,8 @@ DateRangePicker.propTypes = {
1182
1151
  style: PropTypes.object,
1183
1152
  /** Text align of the input. */
1184
1153
  textAlign: PropTypes.oneOf(['center', 'end', 'start']),
1154
+ /** The count unit when select. */
1155
+ unitCount: PropTypes.oneOf(['day', 'night']),
1185
1156
  /** The value of the input element, required for a controlled component. String must be [Date string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date): YYYY/MM/DD, MM/DD/YYYY,...*/
1186
1157
  value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string])),
1187
1158
  /** The variant to use. */
@@ -2,7 +2,6 @@
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { Popover } from "./..";
5
- import OptionWrapper from "../others/option-wrapper";
6
5
  import PropTypes from 'prop-types';
7
6
  import { forwardRef, Fragment, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
7
  import { breakAll, breakWord, cursorPointer, displayBlock, displayInlineBlock, italic, overflowHidden, parseHeight, parseMaxWidth, parseMinWidth, pd, positionRelative, textCapitalize, textCenter, textColor, textLineThrough, textLowercase, textunderline, textUppercase, whiteSpaceBreakSpaces } from "../../styles/general";
@@ -184,5 +183,4 @@ Typography.propTypes = {
184
183
  /** Applies the theme typography styles. */
185
184
  type: PropTypes.oneOf(arrTypeTypography)
186
185
  };
187
- export { Typography };
188
- export default OptionWrapper(Typography);
186
+ export default Typography;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.90-beta.3",
3
+ "version": "1.3.90-beta.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",