@zohodesk/components 1.0.0-alpha-263 → 1.0.0-alpha-265

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 (76) hide show
  1. package/README.md +11 -0
  2. package/css_error.log +1 -0
  3. package/es/DateTime/DateTime.js +26 -65
  4. package/es/DateTime/dateFormatUtils/dateFormats.js +43 -0
  5. package/es/DateTime/dateFormatUtils/index.js +27 -0
  6. package/es/DateTime/props/propTypes.js +2 -1
  7. package/es/DropBox/DropBox.js +68 -244
  8. package/es/DropBox/DropBoxElement/DropBoxElement.js +118 -0
  9. package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +432 -0
  10. package/es/DropBox/DropBoxElement/css/cssJSLogic.js +89 -0
  11. package/es/DropBox/DropBoxElement/props/defaultProps.js +18 -0
  12. package/es/DropBox/DropBoxElement/props/propTypes.js +45 -0
  13. package/es/DropBox/DropBoxElement/useDropboxPosCalc.js +51 -0
  14. package/es/DropBox/css/DropBox.module.css +59 -0
  15. package/es/DropBox/css/cssJSLogic.js +14 -0
  16. package/es/DropBox/props/defaultProps.js +9 -17
  17. package/es/DropBox/props/propTypes.js +9 -43
  18. package/es/MultiSelect/AdvancedMultiSelect.js +0 -2
  19. package/es/MultiSelect/MultiSelect.js +0 -3
  20. package/es/Popup/Popup.js +2 -3
  21. package/es/Tab/Tab.js +1 -1
  22. package/es/Tab/Tabs.js +10 -5
  23. package/es/Tab/__tests__/Tab.spec.js +5 -11
  24. package/es/Tab/props/propTypes.js +1 -1
  25. package/es/css.js +2 -1
  26. package/es/utils/Common.js +4 -0
  27. package/es/utils/css/mergeStyle.js +25 -11
  28. package/lib/DateTime/DateTime.js +25 -61
  29. package/lib/DateTime/dateFormatUtils/dateFormats.js +51 -0
  30. package/lib/DateTime/dateFormatUtils/index.js +31 -3
  31. package/lib/DateTime/props/propTypes.js +8 -1
  32. package/lib/DropBox/DropBox.js +65 -276
  33. package/lib/DropBox/DropBoxElement/DropBoxElement.js +117 -0
  34. package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +432 -0
  35. package/lib/DropBox/DropBoxElement/css/cssJSLogic.js +72 -0
  36. package/lib/DropBox/DropBoxElement/props/defaultProps.js +25 -0
  37. package/lib/DropBox/DropBoxElement/props/propTypes.js +53 -0
  38. package/lib/DropBox/DropBoxElement/useDropboxPosCalc.js +55 -0
  39. package/lib/DropBox/css/DropBox.module.css +59 -0
  40. package/lib/DropBox/css/cssJSLogic.js +18 -0
  41. package/lib/DropBox/props/defaultProps.js +15 -19
  42. package/lib/DropBox/props/propTypes.js +15 -45
  43. package/lib/MultiSelect/AdvancedMultiSelect.js +0 -1
  44. package/lib/MultiSelect/MultiSelect.js +0 -2
  45. package/lib/Popup/Popup.js +1 -2
  46. package/lib/Tab/Tabs.js +7 -2
  47. package/lib/Tab/__tests__/Tab.spec.js +17 -22
  48. package/lib/Tab/props/propTypes.js +1 -1
  49. package/lib/css.js +2 -1
  50. package/lib/utils/Common.js +7 -1
  51. package/lib/utils/css/mergeStyle.js +25 -11
  52. package/package.json +1 -1
  53. package/docs/external/active-line.js +0 -72
  54. package/docs/external/autorefresh.js +0 -47
  55. package/docs/external/codemirror.js +0 -9681
  56. package/docs/external/css/hopscotch.css +0 -576
  57. package/docs/external/css/styleGuide.css +0 -1100
  58. package/docs/external/css.js +0 -466
  59. package/docs/external/designTokens.js +0 -1
  60. package/docs/external/foldcode.js +0 -152
  61. package/docs/external/format.js +0 -129
  62. package/docs/external/htmlmixed.js +0 -84
  63. package/docs/external/images/bottom.png +0 -0
  64. package/docs/external/images/bottombg.jpg +0 -0
  65. package/docs/external/images/desk.png +0 -0
  66. package/docs/external/images/desklogo.png +0 -0
  67. package/docs/external/images/menu.png +0 -0
  68. package/docs/external/index.html +0 -127
  69. package/docs/external/javascript.js +0 -422
  70. package/docs/external/jsx.js +0 -148
  71. package/docs/external/matchbrackets.js +0 -145
  72. package/docs/external/xml.js +0 -322
  73. package/docs/package.json +0 -41
  74. package/docs/src/index.js +0 -1311
  75. package/es/DropBox/DropBox.module.css +0 -405
  76. package/lib/DropBox/DropBox.module.css +0 -405
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.addZero = addZero;
7
+ exports.addZeroIfNeeded = addZeroIfNeeded;
7
8
  exports.arrayIsNotEqual = arrayIsNotEqual;
8
9
  exports.convertTwoDigitToYear = convertTwoDigitToYear;
9
10
  exports.convertYearToTwoDigit = convertYearToTwoDigit;
10
11
  exports.getDayDetails = getDayDetails;
11
12
  exports.getDayEnd = getDayEnd;
12
13
  exports.getHourDetails = getHourDetails;
14
+ exports.getHourSuggestions = getHourSuggestions;
13
15
  exports.getIsCurrentYear = getIsCurrentYear;
14
16
  exports.getIsDeleteTyped = getIsDeleteTyped;
15
17
  exports.getIsEmptyHour = getIsEmptyHour;
@@ -19,6 +21,7 @@ exports.getIsNoonValueTyped = getIsNoonValueTyped;
19
21
  exports.getIsNumberTyped = getIsNumberTyped;
20
22
  exports.getIsSupportedKey = getIsSupportedKey;
21
23
  exports.getMinuteDetails = getMinuteDetails;
24
+ exports.getMinuteSuggestions = getMinuteSuggestions;
22
25
  exports.getMonthDetails = getMonthDetails;
23
26
  exports.getNoonDetails = getNoonDetails;
24
27
  exports.getYearDetails = getYearDetails;
@@ -130,12 +133,37 @@ function getHourDetails(is24Hour) {
130
133
  endPoint: is24Hour ? 23 : 12
131
134
  };
132
135
  }
136
+ function getHourSuggestions(is24Hour) {
137
+ var _getHourDetails = getHourDetails(is24Hour),
138
+ startPoint = _getHourDetails.startPoint,
139
+ endPoint = _getHourDetails.endPoint;
140
+ var hourArr = [];
141
+ for (var hour = startPoint; hour <= endPoint; hour++) {
142
+ var htxt = addZeroIfNeeded(hour);
143
+ hourArr.push(htxt);
144
+ }
145
+ return hourArr;
146
+ }
133
147
  function getMinuteDetails() {
134
148
  return {
135
149
  startPoint: 0,
136
150
  endPoint: 59
137
151
  };
138
152
  }
153
+ function getMinuteSuggestions() {
154
+ var _getMinuteDetails = getMinuteDetails(),
155
+ startPoint = _getMinuteDetails.startPoint,
156
+ endPoint = _getMinuteDetails.endPoint;
157
+ var minArr = [];
158
+ for (var minute = startPoint; minute <= endPoint; minute++) {
159
+ var mtxt = addZeroIfNeeded(minute);
160
+ minArr.push(mtxt);
161
+ }
162
+ return minArr;
163
+ }
164
+ function addZeroIfNeeded(value) {
165
+ return value < 10 ? "0".concat(value) : value;
166
+ }
139
167
  function getIsNoonValueTyped(event) {
140
168
  var keyCode = event.keyCode;
141
169
  if (keyCode === 65 || keyCode === 77 || keyCode === 80) {
@@ -178,9 +206,9 @@ function getIsEmptyValue(value, startPoint, endPoint) {
178
206
  return true;
179
207
  }
180
208
  function getIsEmptyHour(value, is24Hour) {
181
- var _getHourDetails = getHourDetails(is24Hour),
182
- startPoint = _getHourDetails.startPoint,
183
- endPoint = _getHourDetails.endPoint;
209
+ var _getHourDetails2 = getHourDetails(is24Hour),
210
+ startPoint = _getHourDetails2.startPoint,
211
+ endPoint = _getHourDetails2.endPoint;
184
212
  return getIsEmptyValue(value, startPoint, endPoint);
185
213
  }
186
214
  function getIsEmptyYear(value, yearLength) {
@@ -5,7 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.YearView_propTypes = exports.Span_propTypes = exports.DateWidget_propTypes = exports.DateTime_propTypes = exports.CalendarView_propTypes = void 0;
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _dateFormats = require("../dateFormatUtils/dateFormats");
8
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
16
  var CalendarView_propTypes = {
10
17
  dataId: _propTypes["default"].string,
11
18
  date: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
@@ -81,7 +88,7 @@ var DateWidget_propTypes = {
81
88
  className: _propTypes["default"].string,
82
89
  closePopupOnly: _propTypes["default"].func,
83
90
  dataId: _propTypes["default"].string,
84
- dateFormat: _propTypes["default"].oneOf(['yyyy/MM/dd', 'MM/dd/yyyy', 'dd/MM/yyyy', 'yyyy-MM-dd', 'MM-dd-yyyy', 'dd-MM-yyyy', 'yyyy.MM.dd', 'MM.dd.yyyy', 'dd.MM.yyyy', 'dd/MMMM/YY', 'dd/MMM/YY']),
91
+ dateFormat: _propTypes["default"].oneOf(_toConsumableArray(_dateFormats.dataFormatList)),
85
92
  defaultPosition: _propTypes["default"].oneOf(['top', 'bottom', 'right', 'left']),
86
93
  defaultTime: _propTypes["default"].string,
87
94
  getContainerRef: _propTypes["default"].func,
@@ -4,289 +4,78 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = exports.DropBoxElement = void 0;
7
+ exports["default"] = DropBox;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _defaultProps = require("./props/defaultProps");
10
- var _propTypes = require("./props/propTypes");
11
- var _Common = require("../utils/Common");
9
+ var _FocusScope = _interopRequireDefault(require("@zohodesk/a11y/es/FocusScope/FocusScope"));
12
10
  var _Modal = _interopRequireDefault(require("../Modal/Modal"));
13
- var _DropBoxModule = _interopRequireDefault(require("./DropBox.module.css"));
14
- var _DropBoxPositionMapping = require("./DropBoxPositionMapping.json");
15
- var _ZindexProvider = require("../Provider/ZindexProvider");
16
11
  var _Config = require("../Provider/Config");
17
12
  var _LibraryContextInit = _interopRequireDefault(require("../Provider/LibraryContextInit"));
18
- var _FocusScope = _interopRequireDefault(require("@zohodesk/a11y/es/FocusScope/FocusScope"));
13
+ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
14
+ var _DropBoxElement = _interopRequireDefault(require("./DropBoxElement/DropBoxElement"));
15
+ var _defaultProps = require("./props/defaultProps");
16
+ var _propTypes = require("./props/propTypes");
17
+ var _Common = require("./../utils/Common");
18
+ var _DropBoxModule = _interopRequireDefault(require("./css/DropBox.module.css"));
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
22
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
25
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
29
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
- var DropBoxElement = /*#__PURE__*/function (_React$Component) {
36
- _inherits(DropBoxElement, _React$Component);
37
- var _super = _createSuper(DropBoxElement);
38
- function DropBoxElement(props) {
39
- var _this;
40
- _classCallCheck(this, DropBoxElement);
41
- _this = _super.call(this, props);
42
- _this.getRef = _this.getRef.bind(_assertThisInitialized(_this));
43
- return _this;
44
- }
45
- _createClass(DropBoxElement, [{
46
- key: "getRef",
47
- value: function getRef(ele) {
48
- var _this$props = this.props,
49
- getRef = _this$props.getRef,
50
- forwardRef = _this$props.forwardRef;
51
- getRef && getRef(ele);
52
- if (forwardRef) {
53
- forwardRef.current = ele;
54
- }
55
- }
56
- }, {
57
- key: "render",
58
- value: function render() {
59
- var _this$props2 = this.props,
60
- children = _this$props2.children,
61
- isAnimate = _this$props2.isAnimate,
62
- isArrow = _this$props2.isArrow,
63
- arrowPosition = _this$props2.arrowPosition,
64
- boxPosition = _this$props2.boxPosition,
65
- size = _this$props2.size,
66
- right = _this$props2.right,
67
- left = _this$props2.left,
68
- top = _this$props2.top,
69
- arrowRight = _this$props2.arrowRight,
70
- arrowLeft = _this$props2.arrowLeft,
71
- arrowTop = _this$props2.arrowTop,
72
- arrowBottom = _this$props2.arrowBottom,
73
- bottom = _this$props2.bottom,
74
- onClick = _this$props2.onClick,
75
- isRadius = _this$props2.isRadius,
76
- animationStyle = _this$props2.animationStyle,
77
- isActive = _this$props2.isActive,
78
- dataId = _this$props2.dataId,
79
- dataSelectorId = _this$props2.dataSelectorId,
80
- isModel = _this$props2.isModel,
81
- isAbsolutePositioningNeeded = _this$props2.isAbsolutePositioningNeeded,
82
- tourId = _this$props2.tourId,
83
- isBoxPaddingNeed = _this$props2.isBoxPaddingNeed,
84
- isPadding = _this$props2.isPadding,
85
- customClass = _this$props2.customClass,
86
- htmlId = _this$props2.htmlId,
87
- a11y = _this$props2.a11y,
88
- direction = _this$props2.direction,
89
- tabIndex = _this$props2.tabIndex,
90
- palette = _this$props2.palette,
91
- positionsOffset = _this$props2.positionsOffset,
92
- targetOffset = _this$props2.targetOffset,
93
- zIndexStyle = _this$props2.zIndexStyle,
94
- customStyle = _this$props2.customStyle,
95
- subContainerRef = _this$props2.subContainerRef;
96
- var _ref = this.context || {},
97
- isReducedMotion = _ref.isReducedMotion;
98
- if (!isAbsolutePositioningNeeded && size === 'default' && !isActive) {
99
- isAbsolutePositioningNeeded = true;
100
- }
101
- var role = a11y.role,
102
- ariaMultiselectable = a11y.ariaMultiselectable,
103
- ariaLabelledby = a11y.ariaLabelledby;
104
- var _customClass$customDr = customClass.customDropBox,
105
- customDropBox = _customClass$customDr === void 0 ? '' : _customClass$customDr,
106
- _customClass$customMo = customClass.customMobileDropBox,
107
- customMobileDropBox = _customClass$customMo === void 0 ? '' : _customClass$customMo,
108
- _customClass$customDr2 = customClass.customDropBoxWrap,
109
- customDropBoxWrap = _customClass$customDr2 === void 0 ? '' : _customClass$customDr2,
110
- _customClass$customMo2 = customClass.customMobileDropBoxWrap,
111
- customMobileDropBoxWrap = _customClass$customMo2 === void 0 ? '' : _customClass$customMo2;
112
- var unit = 'rem';
113
- var boxstyle = {};
114
- var arrowstyle = {};
115
- var needBoxStyle = right || left || top || bottom;
116
- var needArrowStyle = arrowLeft || arrowRight || arrowTop || arrowBottom;
117
- if (needBoxStyle) {
118
- boxstyle = !isModel ? direction === 'rtl' ? {
119
- right: [(0, _Common.remConvert)(left)] + unit,
120
- left: [(0, _Common.remConvert)(right)] + unit,
121
- top: [(0, _Common.remConvert)(top)] + unit,
122
- bottom: [(0, _Common.remConvert)(bottom)] + unit
123
- } : {
124
- right: [(0, _Common.remConvert)(right)] + unit,
125
- left: [(0, _Common.remConvert)(left)] + unit,
126
- top: [(0, _Common.remConvert)(top)] + unit,
127
- bottom: [(0, _Common.remConvert)(bottom)] + unit
128
- } : {};
129
- }
130
- if (needArrowStyle) {
131
- arrowstyle = !isModel ? direction === 'rtl' ? {
132
- right: [(0, _Common.remConvert)(arrowLeft)] + unit,
133
- left: [(0, _Common.remConvert)(arrowRight)] + unit,
134
- top: [(0, _Common.remConvert)(arrowTop)] + unit,
135
- bottom: [(0, _Common.remConvert)(arrowBottom)] + unit
136
- } : {
137
- right: [(0, _Common.remConvert)(arrowRight)] + unit,
138
- left: [(0, _Common.remConvert)(arrowLeft)] + unit,
139
- top: [(0, _Common.remConvert)(arrowTop)] + unit,
140
- bottom: [(0, _Common.remConvert)(arrowBottom)] + unit
141
- } : {};
142
- }
143
- boxPosition = boxPosition && boxPosition != 'undefined' ? boxPosition : 'bottomCenter';
144
- var boxDirection = _DropBoxPositionMapping.positionMapping[boxPosition].direction; /*getting box direction*/
145
- if (isAbsolutePositioningNeeded) {
146
- arrowPosition = arrowPosition ? arrowPosition : _DropBoxPositionMapping.positionMapping[boxPosition].arrowPosition;
147
- boxPosition = _DropBoxPositionMapping.positionMapping[boxPosition].positionStyle;
148
- } else {
149
- arrowPosition = _DropBoxPositionMapping.positionMapping[boxPosition].arrowPosition;
150
- }
151
- var boxClassName = "".concat(_DropBoxModule["default"].main, " ").concat(!isActive ? _DropBoxModule["default"].hidden : '', " ").concat(isModel ? "".concat(_DropBoxModule["default"].responsive, " ").concat(customMobileDropBoxWrap) : "".concat(customDropBoxWrap, " ").concat(size ? _DropBoxModule["default"][size] : '', " ").concat(isActive ? "".concat(isArrow ? "".concat(_DropBoxModule["default"][boxDirection], " ").concat(isAbsolutePositioningNeeded ? _DropBoxModule["default"]["arrow".concat(boxDirection)] : '') : isPadding ? _DropBoxModule["default"]["paddingSpace_".concat(boxDirection)] : '') : '', " ").concat(isAbsolutePositioningNeeded ? "".concat(_DropBoxModule["default"].container, " ").concat(_DropBoxModule["default"][boxPosition]) : _DropBoxModule["default"].fixedContainer));
152
- var subContainerClass = "".concat(_DropBoxModule["default"].subContainer, " ").concat(isModel ? " ".concat(customMobileDropBox, " ").concat(_DropBoxModule["default"].mobRadius, " ").concat(isActive ? _DropBoxModule["default"].slideUp : '', " ") : "".concat(customDropBox, " ").concat(_DropBoxModule["default"]["".concat(boxDirection, "_shadow")], " ").concat(isRadius ? _DropBoxModule["default"].radius : '', " ").concat(isAnimate && !isReducedMotion && isActive ? animationStyle === 'default' ? _DropBoxModule["default"].fadeIn : _DropBoxModule["default"].bounce : '', " ").concat(isBoxPaddingNeed ? _DropBoxModule["default"].boxPadding : ''));
153
-
154
- // setting inlineStyle for dropbox
155
- var inlineStyle = !isModel ? isAbsolutePositioningNeeded ? needBoxStyle && boxstyle : positionsOffset && positionsOffset[boxPosition] || {} : {};
156
- if (zIndexStyle) {
157
- inlineStyle = Object.assign({}, inlineStyle, zIndexStyle);
158
- }
159
- if (!isModel && !isAbsolutePositioningNeeded && size === 'default' && targetOffset && isActive) {
160
- inlineStyle = Object.assign({}, inlineStyle, {
161
- width: targetOffset.width
162
- });
163
- }
164
- if (customStyle) {
165
- inlineStyle = Object.assign({}, inlineStyle, customStyle);
166
- }
167
- return /*#__PURE__*/_react["default"].createElement("div", {
168
- className: boxClassName,
169
- "data-id": "".concat(dataId),
170
- "data-selector-id": dataSelectorId,
171
- ref: this.getRef,
172
- style: inlineStyle,
173
- "data-tour": tourId,
174
- "data-position": boxPosition,
175
- id: htmlId,
176
- role: role,
177
- "aria-multiselectable": ariaMultiselectable,
178
- "aria-labelledby": ariaLabelledby,
179
- tabIndex: tabIndex
180
- }, /*#__PURE__*/_react["default"].createElement("div", {
181
- tabIndex: "-1",
182
- className: "".concat(subContainerClass, " ").concat(_DropBoxModule["default"]["".concat(palette, "Palette")]),
183
- onClick: onClick,
184
- "data-id": "".concat(dataId, "_subcontainer"),
185
- "data-selector-id": "".concat(dataSelectorId, "_subcontainer"),
186
- ref: subContainerRef
187
- }, isModel ? /*#__PURE__*/_react["default"].createElement("div", {
188
- className: _DropBoxModule["default"].closeBar
189
- }) : null, isArrow && !isModel && /*#__PURE__*/_react["default"].createElement("div", {
190
- className: _DropBoxModule["default"][arrowPosition],
191
- style: needArrowStyle && arrowstyle,
192
- "data-id": "".concat(dataId, "_arrow"),
193
- "data-selector-id": "".concat(dataSelectorId, "_arrow")
194
- }, /*#__PURE__*/_react["default"].createElement("div", {
195
- className: _DropBoxModule["default"].arrowShape
196
- })), children));
23
+ function DropBox(props) {
24
+ var focusRef = (0, _react.useRef)(null);
25
+ var DropBoxContext = (0, _react.useContext)(_LibraryContextInit["default"]);
26
+ var needResponsive = props.needResponsive,
27
+ portalId = props.portalId,
28
+ isActive = props.isActive,
29
+ isAbsolutePositioningNeeded = props.isAbsolutePositioningNeeded,
30
+ isRestrictScroll = props.isRestrictScroll,
31
+ needFocusScope = props.needFocusScope,
32
+ onClose = props.onClose;
33
+ var _ref = DropBoxContext || {},
34
+ direction = _ref.direction;
35
+ var windowWidth,
36
+ mobileWidth = (0, _Config.getLibraryConfig)('mobileWidth'),
37
+ isModel = false;
38
+ if (needResponsive) {
39
+ windowWidth = window.innerWidth;
40
+ if (windowWidth <= mobileWidth) {
41
+ isModel = true;
197
42
  }
198
- }]);
199
- return DropBoxElement;
200
- }(_react["default"].Component);
201
- exports.DropBoxElement = DropBoxElement;
202
- var DropBox = /*#__PURE__*/function (_React$Component2) {
203
- _inherits(DropBox, _React$Component2);
204
- var _super2 = _createSuper(DropBox);
205
- function DropBox(props) {
206
- var _this2;
207
- _classCallCheck(this, DropBox);
208
- _this2 = _super2.call(this, props);
209
- _this2.getNextIndex = (0, _ZindexProvider.getZIndex)(_assertThisInitialized(_this2));
210
- _this2.onFreezeClick = _this2.onFreezeClick.bind(_assertThisInitialized(_this2));
211
- _this2.createRef = /*#__PURE__*/_react["default"].createRef();
212
- return _this2;
213
43
  }
214
- _createClass(DropBox, [{
215
- key: "onFreezeClick",
216
- value: function onFreezeClick(e) {
217
- e && e.stopPropagation();
218
- }
219
- }, {
220
- key: "render",
221
- value: function render() {
222
- var _this$props3 = this.props,
223
- needResponsive = _this$props3.needResponsive,
224
- portalId = _this$props3.portalId,
225
- isActive = _this$props3.isActive,
226
- isAbsolutePositioningNeeded = _this$props3.isAbsolutePositioningNeeded,
227
- needAutoZindex = _this$props3.needAutoZindex,
228
- isRestrictScroll = _this$props3.isRestrictScroll,
229
- needFocusScope = _this$props3.needFocusScope,
230
- onClose = _this$props3.onClose;
231
- var windowWidth,
232
- mobileWidth = (0, _Config.getLibraryConfig)('mobileWidth'),
233
- isModel = false;
234
- if (needResponsive) {
235
- windowWidth = window.innerWidth;
236
- if (windowWidth <= mobileWidth) {
237
- isModel = true;
238
- }
239
- }
240
- var zIndexStyle = isActive && needAutoZindex ? {
241
- zIndex: this.getNextIndex()
242
- } : {};
243
- var _ref2 = this.context || {},
244
- direction = _ref2.direction;
245
- var dropBoxEle = needFocusScope ? /*#__PURE__*/_react["default"].createElement(_FocusScope["default"], {
246
- focusClose: onClose,
247
- elementRef: this.createRef,
248
- autoFocus: true,
249
- restoreFocus: true,
250
- focusArrowLoop: true,
251
- enableEnterAction: true
252
- }, /*#__PURE__*/_react["default"].createElement(DropBoxElement, _extends({
253
- isModel: isModel,
254
- direction: direction
255
- }, this.props, {
256
- zIndexStyle: zIndexStyle,
257
- subContainerRef: this.createRef
258
- }))) : /*#__PURE__*/_react["default"].createElement(DropBoxElement, _extends({
259
- isModel: isModel,
260
- direction: direction
261
- }, this.props, {
262
- zIndexStyle: zIndexStyle
263
- }));
264
- return isModel && isActive ? /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
265
- portalId: portalId
266
- }, /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
267
- className: "".concat(_DropBoxModule["default"].freezeLayer, " ").concat(_DropBoxModule["default"].freeze),
268
- style: zIndexStyle,
269
- onClick: this.onFreezeClick
270
- }), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
271
- portalId: portalId
272
- }, /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, isRestrictScroll ? /*#__PURE__*/_react["default"].createElement("div", {
273
- className: _DropBoxModule["default"].freezeLayer,
274
- style: zIndexStyle,
275
- onClick: this.onFreezeClick
276
- }) : null, dropBoxEle)) : dropBoxEle;
277
- }
278
- }]);
279
- return DropBox;
280
- }(_react["default"].Component);
281
- exports["default"] = DropBox;
282
- DropBox.propTypes = _propTypes.propTypes;
283
- DropBox.contextType = _LibraryContextInit["default"];
284
- DropBox.defaultProps = _defaultProps.defaultProps;
285
- // if (__DOCS__) {
286
- // DropBox.docs = {
287
- // componentGroup: 'Atom',
288
- // folderName: 'Style Guide',
289
- // external: true,
290
- // description: ' '
291
- // };
292
- // }
44
+ var _cssJSLogic = (0, _cssJSLogic2["default"])(props),
45
+ zIndexStyle = _cssJSLogic.zIndexStyle;
46
+ var dropBoxEle = needFocusScope ? /*#__PURE__*/_react["default"].createElement(_FocusScope["default"], {
47
+ focusClose: onClose,
48
+ elementRef: focusRef,
49
+ autoFocus: true,
50
+ restoreFocus: true,
51
+ focusArrowLoop: true,
52
+ enableEnterAction: true
53
+ }, /*#__PURE__*/_react["default"].createElement(_DropBoxElement["default"], _extends({
54
+ isModel: isModel,
55
+ direction: direction
56
+ }, props, {
57
+ zIndexStyle: zIndexStyle,
58
+ subContainerRef: focusRef
59
+ }))) : /*#__PURE__*/_react["default"].createElement(_DropBoxElement["default"], _extends({
60
+ isModel: isModel,
61
+ subContainerRef: focusRef,
62
+ direction: direction
63
+ }, props, {
64
+ zIndexStyle: zIndexStyle
65
+ }));
66
+ return isModel && isActive ? /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
67
+ portalId: portalId
68
+ }, /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
69
+ className: "".concat(_DropBoxModule["default"].freezeLayer, " ").concat(_DropBoxModule["default"].freeze),
70
+ style: zIndexStyle,
71
+ onClick: _Common.cancelBubblingEffect
72
+ }), dropBoxEle)) : !isAbsolutePositioningNeeded && isActive ? /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
73
+ portalId: portalId
74
+ }, /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, isRestrictScroll ? /*#__PURE__*/_react["default"].createElement("div", {
75
+ className: _DropBoxModule["default"].freezeLayer,
76
+ style: zIndexStyle,
77
+ onClick: _Common.cancelBubblingEffect
78
+ }) : null, dropBoxEle)) : dropBoxEle;
79
+ }
80
+ DropBox.propTypes = _propTypes.DropBoxPropTypes;
81
+ DropBox.defaultProps = _defaultProps.DropBoxDefaultProps;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = DropBoxElement;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _useDropboxPosCalc2 = _interopRequireDefault(require("./useDropboxPosCalc"));
9
+ var _cssJSLogic2 = _interopRequireDefault(require("./css/cssJSLogic"));
10
+ var _DropBoxPositionMapping = require("../DropBoxPositionMapping.json");
11
+ var _defaultProps = require("./props/defaultProps");
12
+ var _propTypes = require("./props/propTypes");
13
+ var _utils = require("../../utils");
14
+ var _DropBoxElementModule = _interopRequireDefault(require("./css/DropBoxElement.module.css"));
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ function DropBoxElement(props) {
17
+ var children = props.children,
18
+ isAnimate = props.isAnimate,
19
+ isArrow = props.isArrow,
20
+ arrowPosition = props.arrowPosition,
21
+ boxPosition = props.boxPosition,
22
+ size = props.size,
23
+ onClick = props.onClick,
24
+ isActive = props.isActive,
25
+ dataId = props.dataId,
26
+ dataSelectorId = props.dataSelectorId,
27
+ isModel = props.isModel,
28
+ isAbsolutePositioningNeeded = props.isAbsolutePositioningNeeded,
29
+ tourId = props.tourId,
30
+ htmlId = props.htmlId,
31
+ a11y = props.a11y,
32
+ tabIndex = props.tabIndex,
33
+ palette = props.palette,
34
+ subContainerRef = props.subContainerRef,
35
+ customStyle = props.customStyle;
36
+ var FireOnAnimationEnd = function FireOnAnimationEnd() {
37
+ var element = subContainerRef && subContainerRef.current.classList;
38
+ (isAnimate ? _DropBoxElementModule["default"].fadeIn : _DropBoxElementModule["default"].bounce).split(' ').map(function (rmStyle) {
39
+ if (element && element.contains(rmStyle)) {
40
+ element.remove(rmStyle);
41
+ }
42
+ });
43
+ };
44
+ var getRef = function getRef(ele) {
45
+ var getRef = props.getRef,
46
+ forwardRef = props.forwardRef;
47
+ getRef && getRef(ele);
48
+ if (forwardRef) {
49
+ forwardRef.current = ele;
50
+ }
51
+ };
52
+ if (!isAbsolutePositioningNeeded && size === 'default' && !isActive) {
53
+ isAbsolutePositioningNeeded = true;
54
+ }
55
+ var role = a11y.role,
56
+ ariaMultiselectable = a11y.ariaMultiselectable,
57
+ ariaLabelledby = a11y.ariaLabelledby;
58
+ boxPosition = boxPosition && boxPosition != 'undefined' ? boxPosition : 'bottomCenter';
59
+ var boxDirection = _DropBoxPositionMapping.positionMapping[boxPosition].direction;
60
+ if (isAbsolutePositioningNeeded) {
61
+ arrowPosition = arrowPosition ? arrowPosition : _DropBoxPositionMapping.positionMapping[boxPosition].arrowPosition;
62
+ boxPosition = _DropBoxPositionMapping.positionMapping[boxPosition].positionStyle;
63
+ } else {
64
+ arrowPosition = _DropBoxPositionMapping.positionMapping[boxPosition].arrowPosition;
65
+ }
66
+ var _useDropboxPosCalc = (0, _useDropboxPosCalc2["default"])(props),
67
+ arrowstyle = _useDropboxPosCalc.arrowstyle,
68
+ boxstyle = _useDropboxPosCalc.boxstyle,
69
+ needBoxStyle = _useDropboxPosCalc.needBoxStyle;
70
+ var mergedStyle = (0, _utils.mergeStyle)(_DropBoxElementModule["default"], customStyle);
71
+ var _cssJSLogic = (0, _cssJSLogic2["default"])({
72
+ props: props,
73
+ style: mergedStyle,
74
+ customState: {
75
+ boxPosition: boxPosition,
76
+ boxDirection: boxDirection,
77
+ boxstyle: boxstyle,
78
+ needBoxStyle: needBoxStyle
79
+ }
80
+ }),
81
+ boxClassName = _cssJSLogic.boxClassName,
82
+ subContainerClass = _cssJSLogic.subContainerClass,
83
+ inlineStyle = _cssJSLogic.inlineStyle;
84
+ return /*#__PURE__*/_react["default"].createElement("div", {
85
+ className: boxClassName,
86
+ "data-id": "".concat(dataId),
87
+ "data-selector-id": dataSelectorId,
88
+ ref: getRef,
89
+ style: inlineStyle,
90
+ "data-tour": tourId,
91
+ "data-position": boxPosition,
92
+ id: htmlId,
93
+ role: role,
94
+ "aria-multiselectable": ariaMultiselectable,
95
+ "aria-labelledby": ariaLabelledby,
96
+ tabIndex: tabIndex,
97
+ onAnimationEnd: FireOnAnimationEnd
98
+ }, /*#__PURE__*/_react["default"].createElement("div", {
99
+ tabIndex: "-1",
100
+ className: "".concat(subContainerClass, " ").concat(_DropBoxElementModule["default"]["".concat(palette, "Palette")]),
101
+ onClick: onClick,
102
+ "data-id": "".concat(dataId, "_subcontainer"),
103
+ "data-selector-id": "".concat(dataSelectorId, "_subcontainer"),
104
+ ref: subContainerRef
105
+ }, isModel ? /*#__PURE__*/_react["default"].createElement("div", {
106
+ className: _DropBoxElementModule["default"].closeBar
107
+ }) : null, isArrow && !isModel && /*#__PURE__*/_react["default"].createElement("div", {
108
+ className: _DropBoxElementModule["default"][arrowPosition],
109
+ style: arrowstyle,
110
+ "data-id": "".concat(dataId, "_arrow"),
111
+ "data-selector-id": "".concat(dataSelectorId, "_arrow")
112
+ }, /*#__PURE__*/_react["default"].createElement("div", {
113
+ className: _DropBoxElementModule["default"].arrowShape
114
+ })), children));
115
+ }
116
+ DropBoxElement.propTypes = _propTypes.DropBoxElementPropTypes;
117
+ DropBoxElement.defaultProps = _defaultProps.DropBoxElementDefaultProps;