@zohodesk/components 1.2.4 → 1.2.6
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.
- package/README.md +8 -0
- package/coverage/Button/Button.js.html +1 -1
- package/coverage/Button/css/Button.module.css.html +1 -1
- package/coverage/Button/css/cssJSLogic.js.html +1 -1
- package/coverage/Button/css/index.html +1 -1
- package/coverage/Button/index.html +1 -1
- package/coverage/Button/props/defaultProps.js.html +1 -1
- package/coverage/Button/props/index.html +1 -1
- package/coverage/Button/props/propTypes.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
- package/coverage/Buttongroup/index.html +1 -1
- package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
- package/coverage/Buttongroup/props/index.html +1 -1
- package/coverage/Buttongroup/props/propTypes.js.html +1 -1
- package/coverage/index.html +1 -1
- package/coverage/utils/dummyFunction.js.html +1 -1
- package/coverage/utils/index.html +1 -1
- package/es/AppContainer/AppContainer.js +3 -0
- package/es/v1/Accordion/Accordion.js +65 -0
- package/es/v1/Accordion/AccordionItem.js +57 -0
- package/es/v1/Accordion/index.js +2 -0
- package/es/v1/Animation/Animation.js +127 -0
- package/es/v1/AppContainer/AppContainer.js +137 -0
- package/es/v1/Avatar/Avatar.js +189 -0
- package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
- package/es/v1/Button/Button.js +68 -0
- package/es/v1/Buttongroup/Buttongroup.js +31 -0
- package/es/v1/Card/Card.js +271 -0
- package/es/v1/CheckBox/CheckBox.js +155 -0
- package/es/v1/DateTime/CalendarView.js +218 -0
- package/es/v1/DateTime/DateTime.js +783 -0
- package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
- package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
- package/es/v1/DateTime/DateWidget.js +1098 -0
- package/es/v1/DateTime/DaysRow.js +31 -0
- package/es/v1/DateTime/Time.js +166 -0
- package/es/v1/DateTime/YearView.js +264 -0
- package/es/v1/DateTime/index.js +1 -0
- package/es/v1/DropBox/DropBox.js +91 -0
- package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
- package/es/v1/DropDown/DropDown.js +73 -0
- package/es/v1/DropDown/DropDownHeading.js +44 -0
- package/es/v1/DropDown/DropDownItem.js +76 -0
- package/es/v1/DropDown/DropDownSearch.js +63 -0
- package/es/v1/DropDown/DropDownSeparator.js +15 -0
- package/es/v1/Heading/Heading.js +32 -0
- package/es/v1/Label/Label.js +40 -0
- package/es/v1/Layout/Box.js +115 -0
- package/es/v1/Layout/Container.js +132 -0
- package/es/v1/Layout/index.js +2 -0
- package/es/v1/ListItem/ListContainer.js +102 -0
- package/es/v1/ListItem/ListItem.js +124 -0
- package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
- package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
- package/es/v1/ListItem/ListItemWithIcon.js +127 -0
- package/es/v1/ListItem/ListItemWithRadio.js +105 -0
- package/es/v1/ListItem/index.js +6 -0
- package/es/v1/Modal/Modal.js +154 -0
- package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
- package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
- package/es/v1/MultiSelect/EmptyState.js +64 -0
- package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
- package/es/v1/MultiSelect/MultiSelect.js +1120 -0
- package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
- package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
- package/es/v1/MultiSelect/SelectedOptions.js +82 -0
- package/es/v1/MultiSelect/Suggestions.js +142 -0
- package/es/v1/MultiSelect/index.js +4 -0
- package/es/v1/PopOver/PopOver.js +211 -0
- package/es/v1/Popup/Popup.js +645 -0
- package/es/v1/Radio/Radio.js +115 -0
- package/es/v1/Responsive/CustomResponsive.js +195 -0
- package/es/v1/Responsive/RefWrapper.js +39 -0
- package/es/v1/Responsive/ResizeComponent.js +197 -0
- package/es/v1/Responsive/ResizeObserver.js +140 -0
- package/es/v1/Responsive/Responsive.js +194 -0
- package/es/v1/Responsive/index.js +9 -0
- package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
- package/es/v1/Ribbon/Ribbon.js +33 -0
- package/es/v1/RippleEffect/RippleEffect.js +24 -0
- package/es/v1/Select/GroupSelect.js +803 -0
- package/es/v1/Select/Select.js +969 -0
- package/es/v1/Select/SelectWithAvatar.js +344 -0
- package/es/v1/Select/SelectWithIcon.js +535 -0
- package/es/v1/Select/index.js +4 -0
- package/es/v1/Stencils/Stencils.js +26 -0
- package/es/v1/Switch/Switch.js +94 -0
- package/es/v1/Tab/Tab.js +108 -0
- package/es/v1/Tab/TabContent.js +30 -0
- package/es/v1/Tab/TabContentWrapper.js +29 -0
- package/es/v1/Tab/TabWrapper.js +57 -0
- package/es/v1/Tab/Tabs.js +612 -0
- package/es/v1/Tab/index.js +5 -0
- package/es/v1/Tag/Tag.js +134 -0
- package/es/v1/TextBox/TextBox.js +154 -0
- package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
- package/es/v1/Textarea/Textarea.js +102 -0
- package/es/v1/Tooltip/Tooltip.js +518 -0
- package/es/v1/Typography/Typography.js +38 -0
- package/es/v1/Typography/css/Typography.module.css +376 -0
- package/es/v1/Typography/css/cssJSLogic.js +46 -0
- package/es/v1/Typography/css/letterSpacingMap.js +12 -0
- package/es/v1/Typography/props/defaultProps.js +8 -0
- package/es/v1/Typography/props/propTypes.js +24 -0
- package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
- package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
- package/es/v1/semantic/Button/Button.js +53 -0
- package/es/v1/semantic/index.js +1 -0
- package/lib/AppContainer/AppContainer.js +5 -0
- package/lib/v1/Accordion/Accordion.js +96 -0
- package/lib/v1/Accordion/AccordionItem.js +68 -0
- package/lib/v1/Accordion/index.js +23 -0
- package/lib/v1/Animation/Animation.js +143 -0
- package/lib/v1/AppContainer/AppContainer.js +209 -0
- package/lib/v1/Avatar/Avatar.js +246 -0
- package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
- package/lib/v1/Button/Button.js +82 -0
- package/lib/v1/Buttongroup/Buttongroup.js +44 -0
- package/lib/v1/Card/Card.js +365 -0
- package/lib/v1/CheckBox/CheckBox.js +166 -0
- package/lib/v1/DateTime/CalendarView.js +285 -0
- package/lib/v1/DateTime/DateTime.js +872 -0
- package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
- package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
- package/lib/v1/DateTime/DateWidget.js +1125 -0
- package/lib/v1/DateTime/DaysRow.js +80 -0
- package/lib/v1/DateTime/Time.js +254 -0
- package/lib/v1/DateTime/YearView.js +325 -0
- package/lib/v1/DateTime/index.js +15 -0
- package/lib/v1/DropBox/DropBox.js +119 -0
- package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
- package/lib/v1/DropDown/DropDown.js +170 -0
- package/lib/v1/DropDown/DropDownHeading.js +93 -0
- package/lib/v1/DropDown/DropDownItem.js +127 -0
- package/lib/v1/DropDown/DropDownSearch.js +113 -0
- package/lib/v1/DropDown/DropDownSeparator.js +64 -0
- package/lib/v1/Heading/Heading.js +49 -0
- package/lib/v1/Label/Label.js +51 -0
- package/lib/v1/Layout/Box.js +128 -0
- package/lib/v1/Layout/Container.js +145 -0
- package/lib/v1/Layout/index.js +23 -0
- package/lib/v1/ListItem/ListContainer.js +120 -0
- package/lib/v1/ListItem/ListItem.js +138 -0
- package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
- package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
- package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
- package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
- package/lib/v1/ListItem/index.js +55 -0
- package/lib/v1/Modal/Modal.js +212 -0
- package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
- package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
- package/lib/v1/MultiSelect/EmptyState.js +112 -0
- package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
- package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
- package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
- package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
- package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
- package/lib/v1/MultiSelect/Suggestions.js +195 -0
- package/lib/v1/MultiSelect/index.js +39 -0
- package/lib/v1/PopOver/PopOver.js +293 -0
- package/lib/v1/Popup/Popup.js +715 -0
- package/lib/v1/Radio/Radio.js +126 -0
- package/lib/v1/Responsive/CustomResponsive.js +242 -0
- package/lib/v1/Responsive/RefWrapper.js +57 -0
- package/lib/v1/Responsive/ResizeComponent.js +268 -0
- package/lib/v1/Responsive/ResizeObserver.js +168 -0
- package/lib/v1/Responsive/Responsive.js +274 -0
- package/lib/v1/Responsive/index.js +55 -0
- package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
- package/lib/v1/Ribbon/Ribbon.js +44 -0
- package/lib/v1/RippleEffect/RippleEffect.js +39 -0
- package/lib/v1/Select/GroupSelect.js +877 -0
- package/lib/v1/Select/Select.js +1013 -0
- package/lib/v1/Select/SelectWithAvatar.js +394 -0
- package/lib/v1/Select/SelectWithIcon.js +597 -0
- package/lib/v1/Select/index.js +39 -0
- package/lib/v1/Stencils/Stencils.js +43 -0
- package/lib/v1/Switch/Switch.js +108 -0
- package/lib/v1/Tab/Tab.js +132 -0
- package/lib/v1/Tab/TabContent.js +42 -0
- package/lib/v1/Tab/TabContentWrapper.js +42 -0
- package/lib/v1/Tab/TabWrapper.js +89 -0
- package/lib/v1/Tab/Tabs.js +680 -0
- package/lib/v1/Tab/index.js +47 -0
- package/lib/v1/Tag/Tag.js +154 -0
- package/lib/v1/TextBox/TextBox.js +168 -0
- package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
- package/lib/v1/Textarea/Textarea.js +118 -0
- package/lib/v1/Tooltip/Tooltip.js +586 -0
- package/lib/v1/Typography/Typography.js +56 -0
- package/lib/v1/Typography/css/Typography.module.css +376 -0
- package/lib/v1/Typography/css/cssJSLogic.js +41 -0
- package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
- package/lib/v1/Typography/props/defaultProps.js +15 -0
- package/lib/v1/Typography/props/propTypes.js +35 -0
- package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
- package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
- package/lib/v1/semantic/Button/Button.js +63 -0
- package/lib/v1/semantic/index.js +15 -0
- package/package.json +1 -1
- package/result.json +1 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _ResizeObserver = _interopRequireDefault(require("./ResizeObserver"));
|
|
15
|
+
|
|
16
|
+
var _Common = require("../../utils/Common");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
+
|
|
28
|
+
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, descriptor.key, descriptor); } }
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
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); }; }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
43
|
+
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
|
+
|
|
46
|
+
var ResizeComponent = /*#__PURE__*/function (_React$Component) {
|
|
47
|
+
_inherits(ResizeComponent, _React$Component);
|
|
48
|
+
|
|
49
|
+
var _super = _createSuper(ResizeComponent);
|
|
50
|
+
|
|
51
|
+
function ResizeComponent(props) {
|
|
52
|
+
var _this;
|
|
53
|
+
|
|
54
|
+
_classCallCheck(this, ResizeComponent);
|
|
55
|
+
|
|
56
|
+
_this = _super.call(this, props);
|
|
57
|
+
_this.noSpaceForChildren = false;
|
|
58
|
+
_this.childrenCurrentList = [];
|
|
59
|
+
_this.widthCheck = (0, _Common.debounce)(_this.widthCheck.bind(_assertThisInitialized(_this)), 10); // this.widthCheck = this.widthCheck.bind(this);
|
|
60
|
+
|
|
61
|
+
_this.onResize = _this.onResize.bind(_assertThisInitialized(_this));
|
|
62
|
+
_this.onResizeMutation = _this.onResizeMutation.bind(_assertThisInitialized(_this));
|
|
63
|
+
_this.tabsObserver = new _ResizeObserver["default"](_this.onResize);
|
|
64
|
+
_this.tabObserver = new MutationObserver(_this.onResizeMutation);
|
|
65
|
+
_this.reset = _this.reset.bind(_assertThisInitialized(_this));
|
|
66
|
+
_this.constructChildren = _this.constructChildren.bind(_assertThisInitialized(_this));
|
|
67
|
+
_this.querySelector = _this.querySelector.bind(_assertThisInitialized(_this));
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_createClass(ResizeComponent, [{
|
|
72
|
+
key: "querySelector",
|
|
73
|
+
value: function querySelector() {
|
|
74
|
+
if (this.props.wrapperDivRef && this.props.wrapperDivRef.current) {
|
|
75
|
+
return this.props.wrapperDivRef.current.querySelectorAll('[data-responsive="true"]');
|
|
76
|
+
} else {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "onResizeMutation",
|
|
82
|
+
value: function onResizeMutation(mutations) {
|
|
83
|
+
var _this2 = this;
|
|
84
|
+
|
|
85
|
+
// console.log(mutations);
|
|
86
|
+
var childrenList = this.props.childrenList;
|
|
87
|
+
|
|
88
|
+
var _iterator = _createForOfIteratorHelper(mutations),
|
|
89
|
+
_step;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var mutation = _step.value;
|
|
94
|
+
|
|
95
|
+
if (mutation.type === 'childList') {
|
|
96
|
+
if (mutation.addedNodes.length) {
|
|
97
|
+
var newAdded = false;
|
|
98
|
+
mutation.addedNodes.forEach(function (mut) {
|
|
99
|
+
// Here we can listen for icon nodes. Confirm with bk
|
|
100
|
+
if (mut.attributes && mut.attributes['data-responsive'] && (childrenList.length !== _this2.querySelector().length || _this2.childrenCurrentList.length !== _this2.querySelector().length)) {
|
|
101
|
+
newAdded = true;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (newAdded) {
|
|
106
|
+
//console.log('A child node has been added ', mutation);
|
|
107
|
+
this.onResize();
|
|
108
|
+
}
|
|
109
|
+
} else if (mutation.removedNodes.length) {// ?? removed nodes ku check pannanum ah ??
|
|
110
|
+
// console.log('A child node has been removed ', mutation);
|
|
111
|
+
}
|
|
112
|
+
} else if (mutation.type === 'attributes') {//console.log('The ' + mutation.attributeName + ' attribute was modified.', mutation);
|
|
113
|
+
} else if (mutation.type === 'characterData') {// To Call While Changing InnerText, Remove Below line If Required. But It might affect Performance.
|
|
114
|
+
// this.onResize();
|
|
115
|
+
}
|
|
116
|
+
} // mutations.forEach(mutation => {
|
|
117
|
+
// if (mutation.target === foo &&
|
|
118
|
+
// mutation.attributeName === 'style' &&
|
|
119
|
+
// oldWidth !== foo.style.width) {
|
|
120
|
+
// foo.textContent = 'Width changed from ' +
|
|
121
|
+
// oldWidth + ' to ' + foo.style.width;
|
|
122
|
+
// oldWidth = foo.style.width;
|
|
123
|
+
// }
|
|
124
|
+
// });
|
|
125
|
+
|
|
126
|
+
} catch (err) {
|
|
127
|
+
_iterator.e(err);
|
|
128
|
+
} finally {
|
|
129
|
+
_iterator.f();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "componentDidMount",
|
|
134
|
+
value: function componentDidMount() {
|
|
135
|
+
if (this.props.wrapperDivRef && this.props.wrapperDivRef.current) {
|
|
136
|
+
this.tabsObserver.observe(this.props.wrapperDivRef.current);
|
|
137
|
+
this.tabObserver.observe(this.props.wrapperDivRef.current, {
|
|
138
|
+
characterData: true,
|
|
139
|
+
attributes: true,
|
|
140
|
+
childList: true,
|
|
141
|
+
subtree: true,
|
|
142
|
+
attributeFilter: ['data-responsive']
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "componentWillUnmount",
|
|
148
|
+
value: function componentWillUnmount() {
|
|
149
|
+
this.reset();
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "reset",
|
|
153
|
+
value: function reset() {
|
|
154
|
+
this.childrenCurrentList = [];
|
|
155
|
+
this.tabsObserver.disconnect();
|
|
156
|
+
this.tabObserver && this.tabObserver.disconnect();
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "componentDidUpdate",
|
|
160
|
+
value: function componentDidUpdate(prevProps) {
|
|
161
|
+
if (this.childrenCurrentList.length === 0) {
|
|
162
|
+
this.childrenCurrentList = this.querySelector();
|
|
163
|
+
this.widthCheck();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (this.props.resizeId !== prevProps.resizeId) {
|
|
167
|
+
// Completely reset the observers and set new observer if id is changed
|
|
168
|
+
this.reset();
|
|
169
|
+
|
|
170
|
+
if (this.props.wrapperDivRef && this.props.wrapperDivRef.current) {
|
|
171
|
+
this.tabsObserver.observe(this.props.wrapperDivRef.current);
|
|
172
|
+
this.tabObserver.observe(this.props.wrapperDivRef.current, {
|
|
173
|
+
characterData: true,
|
|
174
|
+
attributes: true,
|
|
175
|
+
childList: true,
|
|
176
|
+
subtree: true,
|
|
177
|
+
attributeFilter: ['data-responsive']
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "onResize",
|
|
184
|
+
value: function onResize() {
|
|
185
|
+
// if (this.childrenCurrentList.length !== 0) {
|
|
186
|
+
this.childrenCurrentList = [];
|
|
187
|
+
this.constructChildren(0, false); //}
|
|
188
|
+
} // shouldComponentUpdate() {
|
|
189
|
+
// return this.childrenCurrentList.length === 0
|
|
190
|
+
// }
|
|
191
|
+
|
|
192
|
+
}, {
|
|
193
|
+
key: "widthCheck",
|
|
194
|
+
value: function widthCheck() {
|
|
195
|
+
var wrapperDivRef = this.props.wrapperDivRef.current;
|
|
196
|
+
var moreDivRef = this.props.moreDivRef.current;
|
|
197
|
+
|
|
198
|
+
if (wrapperDivRef && this.childrenCurrentList.length > 0) {
|
|
199
|
+
var childrenWidthList = this.childrenCurrentList; // this.childrenCurrentList = childrenWidthList;
|
|
200
|
+
|
|
201
|
+
var moreWidth = (0, _Common.getElementSpace)(moreDivRef).neededSpace; //console.log(moreWidth,'moreWidth');
|
|
202
|
+
|
|
203
|
+
var totalWidth = (0, _Common.getElementSpace)(wrapperDivRef).availableInsideSpace - moreWidth;
|
|
204
|
+
var _childrenTotalWidth = 0;
|
|
205
|
+
var dataCount = 0;
|
|
206
|
+
this.noSpaceForChildren = false;
|
|
207
|
+
|
|
208
|
+
if (totalWidth <= moreWidth) {
|
|
209
|
+
this.noSpaceForChildren = true;
|
|
210
|
+
} else {
|
|
211
|
+
for (var i = 0; i < childrenWidthList.length; i++) {
|
|
212
|
+
var currentWidth = (0, _Common.getElementSpace)(childrenWidthList[i]).neededSpace;
|
|
213
|
+
_childrenTotalWidth += currentWidth; // console.log(_childrenTotalWidth, currentWidth, totalWidth)
|
|
214
|
+
|
|
215
|
+
if (i === childrenWidthList.length - 1 && moreWidth >= currentWidth) {
|
|
216
|
+
totalWidth += moreWidth;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (totalWidth <= _childrenTotalWidth) {
|
|
220
|
+
dataCount = i;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
this.constructChildren(dataCount, true);
|
|
227
|
+
} else {
|
|
228
|
+
this.constructChildren(0, false);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "constructChildren",
|
|
233
|
+
value: function constructChildren() {
|
|
234
|
+
var dataCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
235
|
+
var responsive = arguments.length > 1 ? arguments[1] : undefined;
|
|
236
|
+
var _this$props = this.props,
|
|
237
|
+
childrenList = _this$props.childrenList,
|
|
238
|
+
getData = _this$props.getData; // If the data count is zero we assume that we can render all the items - data count will be zero only when we want to calculate the whole list width
|
|
239
|
+
|
|
240
|
+
dataCount = dataCount || childrenList && childrenList.length;
|
|
241
|
+
getData({
|
|
242
|
+
responsiveHook: responsive,
|
|
243
|
+
validListCount: this.noSpaceForChildren ? 0 : dataCount
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}, {
|
|
247
|
+
key: "render",
|
|
248
|
+
value: function render() {
|
|
249
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.props.children);
|
|
250
|
+
}
|
|
251
|
+
}]);
|
|
252
|
+
|
|
253
|
+
return ResizeComponent;
|
|
254
|
+
}(_react["default"].Component);
|
|
255
|
+
|
|
256
|
+
exports["default"] = ResizeComponent;
|
|
257
|
+
ResizeComponent.propTypes = {
|
|
258
|
+
children: _propTypes["default"].node,
|
|
259
|
+
getData: _propTypes["default"].func,
|
|
260
|
+
resizeId: _propTypes["default"].number,
|
|
261
|
+
childrenList: _propTypes["default"].array,
|
|
262
|
+
wrapperDivRef: _propTypes["default"].any,
|
|
263
|
+
moreDivRef: _propTypes["default"].any
|
|
264
|
+
};
|
|
265
|
+
ResizeComponent.defaultProps = {
|
|
266
|
+
getData: function getData() {},
|
|
267
|
+
resizeId: null
|
|
268
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
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, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
|
|
14
|
+
var hasResizeObserver = !!window.ResizeObserver;
|
|
15
|
+
var mutationObserverOptions = {
|
|
16
|
+
//NOTE: we donot consider child Count
|
|
17
|
+
// childList: true,
|
|
18
|
+
attributes: true
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function getSize(element) {
|
|
22
|
+
var offsetHeight = element.offsetHeight,
|
|
23
|
+
offsetWidth = element.offsetWidth; // const { height, width } = element.getBoundingClientRect();
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
height: offsetHeight,
|
|
27
|
+
width: offsetWidth
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function dispatch() {
|
|
32
|
+
var resizeResponsive = new Event('resizeResponsive');
|
|
33
|
+
window.dispatchEvent(resizeResponsive);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!hasResizeObserver) {
|
|
37
|
+
var interval = null;
|
|
38
|
+
window.addEventListener('resize', function () {
|
|
39
|
+
clearTimeout(interval);
|
|
40
|
+
interval = setTimeout(dispatch, 100);
|
|
41
|
+
});
|
|
42
|
+
} // NOTE: this is not full polyfill , we just wrote what types of changes wlli
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var ResizeObserverPolyfill = /*#__PURE__*/function () {
|
|
46
|
+
function ResizeObserverPolyfill(onResize) {
|
|
47
|
+
_classCallCheck(this, ResizeObserverPolyfill);
|
|
48
|
+
|
|
49
|
+
// method finding
|
|
50
|
+
this.transitionEndHandler = this.transitionEndHandler.bind(this);
|
|
51
|
+
this.resizeHandlerDispatch = this.resizeHandlerDispatch.bind(this);
|
|
52
|
+
this.resizeHandler = this.resizeHandler.bind(this);
|
|
53
|
+
this.replaceResizeHandler = this.replaceResizeHandler.bind(this);
|
|
54
|
+
this.debounce = this.debounce.bind(this);
|
|
55
|
+
this.onResize = onResize;
|
|
56
|
+
this.targetNode = null;
|
|
57
|
+
this.size = {
|
|
58
|
+
height: 0,
|
|
59
|
+
width: 0
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (hasResizeObserver) {
|
|
63
|
+
this.resizeObserverInstance = new window.ResizeObserver(this.resizeHandlerDispatch);
|
|
64
|
+
} else {
|
|
65
|
+
this.mutationObserverInstance = new window.MutationObserver(this.resizeHandlerDispatch);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_createClass(ResizeObserverPolyfill, [{
|
|
70
|
+
key: "replaceResizeHandler",
|
|
71
|
+
value: function replaceResizeHandler(onResize) {
|
|
72
|
+
this.onResize = onResize;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "resizeHandler",
|
|
76
|
+
value: function resizeHandler() {
|
|
77
|
+
if (!this.targetNode) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var currentSize = getSize(this.targetNode); // if (this.size && shallowCompare(currentSize, this.size)) {
|
|
82
|
+
|
|
83
|
+
if (this.size && currentSize.height === this.size.height && currentSize.width === this.size.width) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.size = currentSize;
|
|
88
|
+
this.onResize(this.size, this.targetNode);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "resizeHandlerDispatch",
|
|
93
|
+
value: function resizeHandlerDispatch() {
|
|
94
|
+
if (!this.resizeHandler() || hasResizeObserver) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dispatch();
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "debounce",
|
|
102
|
+
value: function debounce() {
|
|
103
|
+
clearTimeout(this.interval);
|
|
104
|
+
this.interval = setTimeout(this.resizeHandler, 100);
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "transitionEndHandler",
|
|
108
|
+
value: function transitionEndHandler(event) {
|
|
109
|
+
if (event.propertyName.indexOf('color') === -1) {
|
|
110
|
+
this.resizeHandlerDispatch();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "addEventListeners",
|
|
115
|
+
value: function addEventListeners(targetNode) {
|
|
116
|
+
targetNode.addEventListener('transitionend', this.transitionEndHandler);
|
|
117
|
+
window.addEventListener('resizeResponsive', this.debounce);
|
|
118
|
+
targetNode.addEventListener('animationend', this.resizeHandlerDispatch);
|
|
119
|
+
targetNode.addEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "removeEventListeners",
|
|
123
|
+
value: function removeEventListeners(targetNode) {
|
|
124
|
+
targetNode.removeEventListener('transitionend', this.transitionEndHandler);
|
|
125
|
+
window.removeEventListener('resizeResponsive', this.debounce);
|
|
126
|
+
targetNode.removeEventListener('animationend', this.resizeHandlerDispatch);
|
|
127
|
+
targetNode.removeEventListener('webkitAnimationEnd', this.resizeHandlerDispatch);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "observe",
|
|
131
|
+
value: function observe(targetNode) {
|
|
132
|
+
this.targetNode = targetNode;
|
|
133
|
+
|
|
134
|
+
if (hasResizeObserver) {
|
|
135
|
+
this.resizeObserverInstance.observe(targetNode);
|
|
136
|
+
} else {
|
|
137
|
+
this.addEventListeners(targetNode);
|
|
138
|
+
this.mutationObserverInstance.observe(targetNode, mutationObserverOptions);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "replaceObservationElement",
|
|
143
|
+
value: function replaceObservationElement(targetNode) {
|
|
144
|
+
if (this.targetNode === targetNode) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.targetNode && this.disconnect();
|
|
149
|
+
targetNode && this.observe(targetNode);
|
|
150
|
+
targetNode && this.resizeHandlerDispatch();
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "disconnect",
|
|
154
|
+
value: function disconnect() {
|
|
155
|
+
this.targetNode && this.removeEventListeners(this.targetNode);
|
|
156
|
+
hasResizeObserver ? this.resizeObserverInstance.disconnect() : this.mutationObserverInstance.disconnect();
|
|
157
|
+
this.targetNode = null;
|
|
158
|
+
this.size = {
|
|
159
|
+
height: 0,
|
|
160
|
+
width: 0
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}]);
|
|
164
|
+
|
|
165
|
+
return ResizeObserverPolyfill;
|
|
166
|
+
}();
|
|
167
|
+
|
|
168
|
+
exports["default"] = ResizeObserverPolyfill;
|