@zohodesk/components 1.0.0-temp-220.10 → 1.0.0-temp-229
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/.cli/config/variables/variableMapping.json +8 -1
- package/.cli/propValidation_report.html +1 -1
- package/README.md +13 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +11 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +11 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +11 -0
- package/es/AppContainer/AppContainer.js +5 -4
- package/es/Card/Card.js +35 -8
- package/es/Card/props/defaultProps.js +2 -1
- package/es/Card/props/propTypes.js +2 -1
- package/es/Popup/Popup.js +92 -200
- package/es/Provider/Config.js +1 -2
- package/es/Provider/LibraryContext.js +7 -3
- package/es/deprecated/Switch/Switch.js +94 -0
- package/es/deprecated/Switch/props/defaultProps.js +11 -0
- package/es/deprecated/Switch/props/propTypes.js +28 -0
- package/es/v1/Switch/Switch.js +122 -78
- package/es/v1/Switch/__tests__/Switch.spec.js +30 -0
- package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
- package/es/v1/Switch/contants/index.js +24 -0
- package/es/v1/Switch/css/Switch_v1.module.css +134 -0
- package/es/v1/Switch/css/cssJSLogic.js +48 -0
- package/es/v1/Switch/props/defaultProps.js +8 -8
- package/es/v1/Switch/props/propTypes.js +30 -22
- package/es/v1/Switch/useSwitch.js +33 -0
- package/lib/AppContainer/AppContainer.js +7 -6
- package/lib/Card/Card.js +50 -23
- package/lib/Card/props/defaultProps.js +2 -1
- package/lib/Card/props/propTypes.js +2 -1
- package/lib/Popup/Popup.js +147 -272
- package/lib/Provider/Config.js +1 -2
- package/lib/Provider/LibraryContext.js +7 -3
- package/lib/deprecated/Switch/Switch.js +108 -0
- package/lib/deprecated/Switch/props/defaultProps.js +18 -0
- package/lib/deprecated/Switch/props/propTypes.js +39 -0
- package/lib/v1/Switch/Switch.js +130 -79
- package/lib/v1/Switch/__tests__/Switch.spec.js +37 -0
- package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
- package/lib/v1/Switch/contants/index.js +34 -0
- package/lib/v1/Switch/css/Switch_v1.module.css +134 -0
- package/lib/v1/Switch/css/cssJSLogic.js +37 -0
- package/lib/v1/Switch/props/defaultProps.js +10 -10
- package/lib/v1/Switch/props/propTypes.js +32 -24
- package/lib/v1/Switch/useSwitch.js +56 -0
- package/package.json +10 -6
- package/es/Popup/Registry.js +0 -37
- package/lib/Popup/Registry.js +0 -47
- package/result.json +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useSwitch = props => {
|
|
4
|
+
const {
|
|
5
|
+
isChecked: isCheckedProp,
|
|
6
|
+
isDefaultChecked,
|
|
7
|
+
onChange,
|
|
8
|
+
isReadOnly,
|
|
9
|
+
isDisabled
|
|
10
|
+
} = props;
|
|
11
|
+
const isControlled = isCheckedProp !== undefined;
|
|
12
|
+
const [internalChecked, setInternalChecked] = useState(isDefaultChecked);
|
|
13
|
+
const isChecked = isControlled ? isCheckedProp : internalChecked;
|
|
14
|
+
|
|
15
|
+
const handleChange = e => {
|
|
16
|
+
if (isReadOnly || isDisabled) return;
|
|
17
|
+
|
|
18
|
+
if (!isControlled) {
|
|
19
|
+
setInternalChecked(!isChecked);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
onChange?.({
|
|
23
|
+
isChecked: !isChecked
|
|
24
|
+
}, e);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
isChecked,
|
|
29
|
+
handleChange
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default useSwitch;
|
|
@@ -148,14 +148,15 @@ var AppContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
148
148
|
|
|
149
149
|
if (this.containerElement && needTooltip) {
|
|
150
150
|
this.containerElement.removeEventListener('mouseover', this.handleOver, false);
|
|
151
|
-
this.containerElement.
|
|
151
|
+
this.containerElement.removeEventListener('mouseout', this.removeTimeout, false);
|
|
152
152
|
this.tooltipRef.unObserveElement();
|
|
153
|
-
(0, _Config.setLibraryConfig)({
|
|
154
|
-
getTooltipContainer: function getTooltipContainer() {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
153
|
}
|
|
154
|
+
|
|
155
|
+
(0, _Config.setLibraryConfig)({
|
|
156
|
+
getTooltipContainer: function getTooltipContainer() {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
159
160
|
}
|
|
160
161
|
}, {
|
|
161
162
|
key: "render",
|
package/lib/Card/Card.js
CHANGED
|
@@ -175,7 +175,9 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
175
175
|
_this2.to = from + 3 * limit;
|
|
176
176
|
_this2.isFetching = false;
|
|
177
177
|
_this2.lastScrollTop = 0;
|
|
178
|
-
_this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2));
|
|
178
|
+
_this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2));
|
|
179
|
+
_this2.setScrollRef = _this2.setScrollRef.bind(_assertThisInitialized(_this2));
|
|
180
|
+
_this2.childEleRef = null; //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
|
|
179
181
|
//this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
|
|
180
182
|
|
|
181
183
|
return _this2;
|
|
@@ -204,7 +206,8 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
204
206
|
noMoreData = _this$props3.noMoreData,
|
|
205
207
|
scrollAt = _this$props3.scrollAt,
|
|
206
208
|
noNeedUpScroll = _this$props3.noNeedUpScroll,
|
|
207
|
-
isPercentageScroll = _this$props3.isPercentageScroll
|
|
209
|
+
isPercentageScroll = _this$props3.isPercentageScroll,
|
|
210
|
+
isRecentOnTop = _this$props3.isRecentOnTop;
|
|
208
211
|
|
|
209
212
|
if (scrollTop > this.lastScrollTop) {
|
|
210
213
|
this.scrollDirection = 'down';
|
|
@@ -215,9 +218,12 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
215
218
|
this.lastScrollTop = scrollTop;
|
|
216
219
|
|
|
217
220
|
if (fetchData && !this.isFetching) {
|
|
218
|
-
|
|
221
|
+
var nextFetchDirection = isRecentOnTop ? 'down' : 'up';
|
|
222
|
+
|
|
223
|
+
if (this.scrollDirection === nextFetchDirection && !noMoreData) {
|
|
219
224
|
var scrollingPercentage = (scrollTop + offsetHeight) / (scrollHeight - scrollAt) * 100;
|
|
220
|
-
var
|
|
225
|
+
var scrolledUpPercentage = (scrollHeight - scrollTop) / (scrollHeight - scrollAt) * 100;
|
|
226
|
+
var prefetch = isRecentOnTop ? isPercentageScroll ? scrollingPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit') : scrollHeight - scrollAt <= scrollTop + offsetHeight : isPercentageScroll ? scrolledUpPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit') : scrollTop <= scrollAt;
|
|
221
227
|
|
|
222
228
|
if (prefetch) {
|
|
223
229
|
this.isFetching = true;
|
|
@@ -229,7 +235,9 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
229
235
|
});
|
|
230
236
|
}
|
|
231
237
|
} else {
|
|
232
|
-
|
|
238
|
+
var _prefetch = isRecentOnTop ? 0 >= scrollTop - scrollAt : scrollHeight - scrollAt <= scrollTop + offsetHeight;
|
|
239
|
+
|
|
240
|
+
if (_prefetch && this.from !== 0 && !noNeedUpScroll) {
|
|
233
241
|
this.isFetching = true;
|
|
234
242
|
fetchData(this.from - this.limit, this.to - this.limit, this.scrollDirection).then(function () {
|
|
235
243
|
_this3.to = _this3.to - _this3.limit;
|
|
@@ -242,9 +250,12 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
242
250
|
}
|
|
243
251
|
|
|
244
252
|
if (fetchData && !noNeedUpScroll) {
|
|
245
|
-
|
|
253
|
+
var topFetch = isRecentOnTop ? !noNeedUpScroll : !noMoreData;
|
|
254
|
+
var bottomFetch = isRecentOnTop ? !noMoreData : !noNeedUpScroll;
|
|
255
|
+
|
|
256
|
+
if (this.from !== 0 && scrollTop === 0 && topFetch) {
|
|
246
257
|
scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
|
|
247
|
-
} else if (scrollHeight === scrollTop + offsetHeight &&
|
|
258
|
+
} else if (scrollHeight === scrollTop + offsetHeight && bottomFetch) {
|
|
248
259
|
scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
|
|
249
260
|
}
|
|
250
261
|
} // if (isScrollShadow) {
|
|
@@ -262,21 +273,36 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
262
273
|
// }
|
|
263
274
|
// }
|
|
264
275
|
|
|
276
|
+
}, {
|
|
277
|
+
key: "setScrollRef",
|
|
278
|
+
value: function setScrollRef(el) {
|
|
279
|
+
var _this$props4 = this.props,
|
|
280
|
+
scrollAt = _this$props4.scrollAt,
|
|
281
|
+
isRecentOnTop = _this$props4.isRecentOnTop;
|
|
282
|
+
|
|
283
|
+
if (el && !isRecentOnTop) {
|
|
284
|
+
requestAnimationFrame(function () {
|
|
285
|
+
el.scrollTop = el.scrollHeight + Number(scrollAt);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
this.childEleRef && this.childEleRef(el);
|
|
290
|
+
}
|
|
265
291
|
}, {
|
|
266
292
|
key: "render",
|
|
267
293
|
value: function render() {
|
|
268
294
|
var _this4 = this;
|
|
269
295
|
|
|
270
|
-
var _this$
|
|
271
|
-
onClick = _this$
|
|
272
|
-
children = _this$
|
|
273
|
-
isScrollAttribute = _this$
|
|
274
|
-
dataId = _this$
|
|
275
|
-
eleRef = _this$
|
|
276
|
-
_this$
|
|
277
|
-
customClass = _this$
|
|
278
|
-
htmlId = _this$
|
|
279
|
-
a11y = _this$
|
|
296
|
+
var _this$props5 = this.props,
|
|
297
|
+
onClick = _this$props5.onClick,
|
|
298
|
+
children = _this$props5.children,
|
|
299
|
+
isScrollAttribute = _this$props5.isScrollAttribute,
|
|
300
|
+
dataId = _this$props5.dataId,
|
|
301
|
+
eleRef = _this$props5.eleRef,
|
|
302
|
+
_this$props5$customCl = _this$props5.customClass,
|
|
303
|
+
customClass = _this$props5$customCl === void 0 ? '' : _this$props5$customCl,
|
|
304
|
+
htmlId = _this$props5.htmlId,
|
|
305
|
+
a11y = _this$props5.a11y;
|
|
280
306
|
var isScroll = this.state.isScroll;
|
|
281
307
|
var role = a11y.role;
|
|
282
308
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
@@ -295,6 +321,7 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
295
321
|
isScroll: isScroll
|
|
296
322
|
});
|
|
297
323
|
} else if (child.type === CardContent || _this4.props.childTypes && child.type === _this4.props.childTypes.cardContent) {
|
|
324
|
+
_this4.childEleRef = child.props.eleRef;
|
|
298
325
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
299
326
|
id: htmlId,
|
|
300
327
|
role: role,
|
|
@@ -302,7 +329,7 @@ var Card = /*#__PURE__*/function (_Component3) {
|
|
|
302
329
|
scroll: child.props.scroll,
|
|
303
330
|
preventParentScroll: child.props.preventParentScroll,
|
|
304
331
|
onScroll: _this4.onScroll,
|
|
305
|
-
eleRef:
|
|
332
|
+
eleRef: _this4.setScrollRef,
|
|
306
333
|
isScrollAttribute: child.props.isScrollAttribute,
|
|
307
334
|
dataId: child.props.dataId,
|
|
308
335
|
shrink: child.props.shrink,
|
|
@@ -344,11 +371,11 @@ var CardFooter = /*#__PURE__*/function (_Component4) {
|
|
|
344
371
|
_createClass(CardFooter, [{
|
|
345
372
|
key: "render",
|
|
346
373
|
value: function render() {
|
|
347
|
-
var _this$
|
|
348
|
-
children = _this$
|
|
349
|
-
dataId = _this$
|
|
350
|
-
customClass = _this$
|
|
351
|
-
dataSelectorId = _this$
|
|
374
|
+
var _this$props6 = this.props,
|
|
375
|
+
children = _this$props6.children,
|
|
376
|
+
dataId = _this$props6.dataId,
|
|
377
|
+
customClass = _this$props6.customClass,
|
|
378
|
+
dataSelectorId = _this$props6.dataSelectorId;
|
|
352
379
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
353
380
|
className: "".concat(customClass),
|
|
354
381
|
dataId: dataId,
|
|
@@ -50,7 +50,8 @@ var Card_propTypes = {
|
|
|
50
50
|
role: _propTypes["default"].string
|
|
51
51
|
}),
|
|
52
52
|
isPercentageScroll: _propTypes["default"].bool,
|
|
53
|
-
eleRef: _propTypes["default"].func
|
|
53
|
+
eleRef: _propTypes["default"].func,
|
|
54
|
+
isRecentOnTop: _propTypes["default"].bool
|
|
54
55
|
};
|
|
55
56
|
exports.Card_propTypes = Card_propTypes;
|
|
56
57
|
var CardFooter_propTypes = {
|