@janiscommerce/ui-web 1.5.0-beta.3 → 1.5.0-beta.4
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/dist/index.esm.js +385 -247
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +385 -247
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -181,6 +181,61 @@ function _isNativeReflectConstruct() {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
function _construct(Parent, args, Class) {
|
|
185
|
+
if (_isNativeReflectConstruct()) {
|
|
186
|
+
_construct = Reflect.construct;
|
|
187
|
+
} else {
|
|
188
|
+
_construct = function _construct(Parent, args, Class) {
|
|
189
|
+
var a = [null];
|
|
190
|
+
a.push.apply(a, args);
|
|
191
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
192
|
+
var instance = new Constructor();
|
|
193
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
194
|
+
return instance;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return _construct.apply(null, arguments);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function _isNativeFunction(fn) {
|
|
202
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function _wrapNativeSuper(Class) {
|
|
206
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
207
|
+
|
|
208
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
209
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
210
|
+
|
|
211
|
+
if (typeof Class !== "function") {
|
|
212
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (typeof _cache !== "undefined") {
|
|
216
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
217
|
+
|
|
218
|
+
_cache.set(Class, Wrapper);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function Wrapper() {
|
|
222
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
226
|
+
constructor: {
|
|
227
|
+
value: Wrapper,
|
|
228
|
+
enumerable: false,
|
|
229
|
+
writable: true,
|
|
230
|
+
configurable: true
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
return _wrapNativeSuper(Class);
|
|
237
|
+
}
|
|
238
|
+
|
|
184
239
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
185
240
|
if (source == null) return {};
|
|
186
241
|
var target = {};
|
|
@@ -6983,7 +7038,7 @@ if (DESCRIPTORS$1 && !FUNCTION_NAME_EXISTS) {
|
|
|
6983
7038
|
});
|
|
6984
7039
|
}
|
|
6985
7040
|
|
|
6986
|
-
var _excluded$
|
|
7041
|
+
var _excluded$b = ["color", "name", "size", "styles", "pathStyles", "width", "height", "viewBox"];
|
|
6987
7042
|
|
|
6988
7043
|
var Icon = function Icon(_ref) {
|
|
6989
7044
|
var color = _ref.color,
|
|
@@ -6994,7 +7049,7 @@ var Icon = function Icon(_ref) {
|
|
|
6994
7049
|
width = _ref.width,
|
|
6995
7050
|
height = _ref.height,
|
|
6996
7051
|
viewBox = _ref.viewBox,
|
|
6997
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7052
|
+
props = _objectWithoutProperties(_ref, _excluded$b);
|
|
6998
7053
|
|
|
6999
7054
|
if (!icons[name]) return null;
|
|
7000
7055
|
var _icons$name = icons[name],
|
|
@@ -7080,7 +7135,7 @@ var styled$g = {
|
|
|
7080
7135
|
})(["text-overflow:ellipsis;overflow:hidden;"])
|
|
7081
7136
|
};
|
|
7082
7137
|
|
|
7083
|
-
var _excluded$
|
|
7138
|
+
var _excluded$a = ["backgroundColor", "borderColor", "children", "disabled", "icon", "iconColor", "iconSize", "onClick", "onDelete", "selected", "textColor", "variant", "hasLink"];
|
|
7084
7139
|
|
|
7085
7140
|
var Chip = function Chip(_ref) {
|
|
7086
7141
|
var backgroundColor = _ref.backgroundColor,
|
|
@@ -7096,7 +7151,7 @@ var Chip = function Chip(_ref) {
|
|
|
7096
7151
|
textColor = _ref.textColor,
|
|
7097
7152
|
variant = _ref.variant,
|
|
7098
7153
|
hasLink = _ref.hasLink,
|
|
7099
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7154
|
+
props = _objectWithoutProperties(_ref, _excluded$a);
|
|
7100
7155
|
|
|
7101
7156
|
if (!children && !icon) return null;
|
|
7102
7157
|
return /*#__PURE__*/React__default.createElement(styled$g.Chip, _extends$1({
|
|
@@ -7399,7 +7454,7 @@ var styled$e = {
|
|
|
7399
7454
|
})
|
|
7400
7455
|
};
|
|
7401
7456
|
|
|
7402
|
-
var _excluded$
|
|
7457
|
+
var _excluded$9 = ["children", "color", "hideLabel", "icon", "iconColor", "iconSize", "fontColor", "rounded", "styles", "variant", "disabled"];
|
|
7403
7458
|
|
|
7404
7459
|
var Button = function Button(_ref) {
|
|
7405
7460
|
var children = _ref.children,
|
|
@@ -7413,7 +7468,7 @@ var Button = function Button(_ref) {
|
|
|
7413
7468
|
styles = _ref.styles,
|
|
7414
7469
|
variant = _ref.variant,
|
|
7415
7470
|
disabled = _ref.disabled,
|
|
7416
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7471
|
+
props = _objectWithoutProperties(_ref, _excluded$9);
|
|
7417
7472
|
|
|
7418
7473
|
return /*#__PURE__*/React__default.createElement(styled$e.Button, _extends$1({
|
|
7419
7474
|
color: color,
|
|
@@ -7462,7 +7517,7 @@ var styled$d = {
|
|
|
7462
7517
|
})
|
|
7463
7518
|
};
|
|
7464
7519
|
|
|
7465
|
-
var _excluded$
|
|
7520
|
+
var _excluded$8 = ["autoComplete", "disabled", "defaultChecked", "onChange", "rounded", "styles", "value"];
|
|
7466
7521
|
|
|
7467
7522
|
var Checkbox = function Checkbox(_ref) {
|
|
7468
7523
|
var autoComplete = _ref.autoComplete,
|
|
@@ -7472,7 +7527,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
7472
7527
|
rounded = _ref.rounded,
|
|
7473
7528
|
styles = _ref.styles,
|
|
7474
7529
|
value = _ref.value,
|
|
7475
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7530
|
+
props = _objectWithoutProperties(_ref, _excluded$8);
|
|
7476
7531
|
|
|
7477
7532
|
var _useState = useState(!!value || defaultChecked),
|
|
7478
7533
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -7588,7 +7643,7 @@ var styled$b = {
|
|
|
7588
7643
|
iconCheckStyles: iconCheckStyles
|
|
7589
7644
|
};
|
|
7590
7645
|
|
|
7591
|
-
var _excluded$
|
|
7646
|
+
var _excluded$7 = ["autoComplete", "defaultChecked", "disabled", "id", "name", "onChange", "value"];
|
|
7592
7647
|
|
|
7593
7648
|
var Switch = function Switch(_ref) {
|
|
7594
7649
|
var autoComplete = _ref.autoComplete,
|
|
@@ -7598,7 +7653,7 @@ var Switch = function Switch(_ref) {
|
|
|
7598
7653
|
name = _ref.name,
|
|
7599
7654
|
onChange = _ref.onChange,
|
|
7600
7655
|
value = _ref.value,
|
|
7601
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
7656
|
+
props = _objectWithoutProperties(_ref, _excluded$7);
|
|
7602
7657
|
|
|
7603
7658
|
var _useState = useState(!!value || defaultChecked),
|
|
7604
7659
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -7770,7 +7825,7 @@ var styled$a = {
|
|
|
7770
7825
|
})(["position:absolute;flex-shrink:0;flex-grow:0;margin-right:8px;height:100%;"])
|
|
7771
7826
|
};
|
|
7772
7827
|
|
|
7773
|
-
var _excluded$
|
|
7828
|
+
var _excluded$6 = ["icon", "error", "disabled", "placeholder", "errorMessage", "autoComplete", "hasFloatingLabel", "value", "isTranslateActive", "defaultValue"];
|
|
7774
7829
|
|
|
7775
7830
|
var Input = /*#__PURE__*/function (_PureComponent) {
|
|
7776
7831
|
_inherits$2(Input, _PureComponent);
|
|
@@ -7866,7 +7921,7 @@ var Input = /*#__PURE__*/function (_PureComponent) {
|
|
|
7866
7921
|
value = _this$props$value === void 0 ? stateValue : _this$props$value,
|
|
7867
7922
|
isTranslateActive = _this$props.isTranslateActive;
|
|
7868
7923
|
_this$props.defaultValue;
|
|
7869
|
-
var props = _objectWithoutProperties(_this$props, _excluded$
|
|
7924
|
+
var props = _objectWithoutProperties(_this$props, _excluded$6);
|
|
7870
7925
|
|
|
7871
7926
|
var autoCompleteOff = props.type === 'password' ? 'new-password' : 'off';
|
|
7872
7927
|
var isFloating = isFocused || !!value.toString();
|
|
@@ -7979,7 +8034,7 @@ var styled$9 = {
|
|
|
7979
8034
|
})(["color:", ";font-size:12px;line-height:14px;display:block;word-break:break-word;"], palette.statusRed)
|
|
7980
8035
|
};
|
|
7981
8036
|
|
|
7982
|
-
var _excluded$
|
|
8037
|
+
var _excluded$5 = ["label", "error", "disabled", "placeholder", "autoComplete", "errorMessage", "hasFloatingLabel", "isTranslateActive", "value", "defaultValue"];
|
|
7983
8038
|
|
|
7984
8039
|
var Textarea = /*#__PURE__*/function (_PureComponent) {
|
|
7985
8040
|
_inherits$2(Textarea, _PureComponent);
|
|
@@ -8081,7 +8136,7 @@ var Textarea = /*#__PURE__*/function (_PureComponent) {
|
|
|
8081
8136
|
_this$props$value = _this$props.value,
|
|
8082
8137
|
value = _this$props$value === void 0 ? stateValue : _this$props$value;
|
|
8083
8138
|
_this$props.defaultValue;
|
|
8084
|
-
var props = _objectWithoutProperties(_this$props, _excluded$
|
|
8139
|
+
var props = _objectWithoutProperties(_this$props, _excluded$5);
|
|
8085
8140
|
|
|
8086
8141
|
var isFloating = isFocused || !!value;
|
|
8087
8142
|
return /*#__PURE__*/React__default.createElement(styled$9.Container, {
|
|
@@ -9578,14 +9633,14 @@ var styled$5 = {
|
|
|
9578
9633
|
})(["margin-right:8px;"])
|
|
9579
9634
|
};
|
|
9580
9635
|
|
|
9581
|
-
var _excluded$
|
|
9636
|
+
var _excluded$4 = ["href", "children", "target", "icon"];
|
|
9582
9637
|
|
|
9583
9638
|
var Link = function Link(_ref) {
|
|
9584
9639
|
var href = _ref.href,
|
|
9585
9640
|
children = _ref.children,
|
|
9586
9641
|
target = _ref.target,
|
|
9587
9642
|
icon = _ref.icon,
|
|
9588
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
9643
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
9589
9644
|
|
|
9590
9645
|
var renderIcon = function renderIcon() {
|
|
9591
9646
|
return icon ? /*#__PURE__*/React__default.createElement(styled$5.StyledIcon, {
|
|
@@ -9709,7 +9764,7 @@ var styled$4 = {
|
|
|
9709
9764
|
Overlay: Overlay
|
|
9710
9765
|
};
|
|
9711
9766
|
|
|
9712
|
-
var _excluded$
|
|
9767
|
+
var _excluded$3 = ["open", "position", "handleClose", "transitionDuration", "fullScreen", "closeOnClickAway", "children"];
|
|
9713
9768
|
|
|
9714
9769
|
var Drawer = function Drawer(_ref) {
|
|
9715
9770
|
var open = _ref.open,
|
|
@@ -9719,7 +9774,7 @@ var Drawer = function Drawer(_ref) {
|
|
|
9719
9774
|
fullScreen = _ref.fullScreen,
|
|
9720
9775
|
closeOnClickAway = _ref.closeOnClickAway,
|
|
9721
9776
|
children = _ref.children,
|
|
9722
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
9777
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
9723
9778
|
|
|
9724
9779
|
var drawerRef = useRef(null);
|
|
9725
9780
|
return /*#__PURE__*/React__default.createElement(ClickAwayListener, {
|
|
@@ -15860,10 +15915,10 @@ var markerHasEqualPosition = function markerHasEqualPosition() {
|
|
|
15860
15915
|
return hasEqualLat && hasEqualLng;
|
|
15861
15916
|
};
|
|
15862
15917
|
var isValidAnimation = function isValidAnimation() {
|
|
15863
|
-
var _window$google
|
|
15918
|
+
var _window$google;
|
|
15864
15919
|
|
|
15865
15920
|
var animation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15866
|
-
var validAnimations = (_window$google = window.google) === null || _window$google === void 0
|
|
15921
|
+
var validAnimations = (_window$google = window.google) === null || _window$google === void 0 || (_window$google = _window$google.maps) === null || _window$google === void 0 ? void 0 : _window$google.Animation;
|
|
15867
15922
|
if (!animation || !isObject$2(animation)) return false;
|
|
15868
15923
|
return (animation === null || animation === void 0 ? void 0 : animation.name) && validAnimations && validAnimations[animation === null || animation === void 0 ? void 0 : animation.name] !== undefined;
|
|
15869
15924
|
};
|
|
@@ -16094,7 +16149,7 @@ var Markers = function Markers(_ref) {
|
|
|
16094
16149
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, markers.map(function (marker, idx) {
|
|
16095
16150
|
var _marker$position, _marker$position2;
|
|
16096
16151
|
|
|
16097
|
-
var uniqueId = "".concat(marker === null || marker === void 0
|
|
16152
|
+
var uniqueId = "".concat(marker === null || marker === void 0 || (_marker$position = marker.position) === null || _marker$position === void 0 ? void 0 : _marker$position.lat, "-").concat(marker === null || marker === void 0 || (_marker$position2 = marker.position) === null || _marker$position2 === void 0 ? void 0 : _marker$position2.lng, "/").concat(idx.toString());
|
|
16098
16153
|
return /*#__PURE__*/React__default.createElement(Marker$1, {
|
|
16099
16154
|
markerData: _objectSpread2(_objectSpread2({}, marker), {}, {
|
|
16100
16155
|
infoWindowOpen: (marker === null || marker === void 0 ? void 0 : marker.showInfoWindow) || activeMarkerId === uniqueId
|
|
@@ -35347,7 +35402,7 @@ var styled$2 = {
|
|
|
35347
35402
|
})(["z-index:0;position:relative;right:0px;top:0px;background:", ";margin:10px;padding:4px 8px 6px;border-radius:2px;width:auto;box-shadow:rgba(0,0,0,0.3) 0px 1px 4px -1px;"], palette.white)
|
|
35348
35403
|
};
|
|
35349
35404
|
|
|
35350
|
-
var _excluded$
|
|
35405
|
+
var _excluded$2 = ["formattedAddress"];
|
|
35351
35406
|
|
|
35352
35407
|
var SearchBox = function SearchBox(_ref) {
|
|
35353
35408
|
var updateMarker = _ref.updateMarker;
|
|
@@ -35368,7 +35423,7 @@ var SearchBox = function SearchBox(_ref) {
|
|
|
35368
35423
|
|
|
35369
35424
|
case 4:
|
|
35370
35425
|
addressData = _context.sent;
|
|
35371
|
-
formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded$
|
|
35426
|
+
formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded$2);
|
|
35372
35427
|
if (updateMarker) updateMarker({
|
|
35373
35428
|
lat: newLat(),
|
|
35374
35429
|
lng: newLng(),
|
|
@@ -35402,7 +35457,7 @@ var SearchBox = function SearchBox(_ref) {
|
|
|
35402
35457
|
})));
|
|
35403
35458
|
};
|
|
35404
35459
|
|
|
35405
|
-
var _excluded = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "markerOptions", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
|
|
35460
|
+
var _excluded$1 = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "markerOptions", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
|
|
35406
35461
|
var Map$1 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
35407
35462
|
var _mapRef$current;
|
|
35408
35463
|
|
|
@@ -35425,7 +35480,7 @@ var Map$1 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
35425
35480
|
callbackOnSuccessDirections = _ref$callbackOnSucces === void 0 ? function () {} : _ref$callbackOnSucces,
|
|
35426
35481
|
_ref$callbackOnErrorD = _ref.callbackOnErrorDirections,
|
|
35427
35482
|
callbackOnErrorDirections = _ref$callbackOnErrorD === void 0 ? function () {} : _ref$callbackOnErrorD,
|
|
35428
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
35483
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
35429
35484
|
|
|
35430
35485
|
var _useJsApiLoader = useJsApiLoader({
|
|
35431
35486
|
googleMapsApiKey: googleMapsApiKey,
|
|
@@ -35680,131 +35735,185 @@ var ProgressBar = function ProgressBar(_ref) {
|
|
|
35680
35735
|
}));
|
|
35681
35736
|
};
|
|
35682
35737
|
|
|
35738
|
+
var isProduction = "production" === 'production';
|
|
35683
35739
|
function warning(condition, message) {
|
|
35740
|
+
if (!isProduction) {
|
|
35741
|
+
if (condition) {
|
|
35742
|
+
return;
|
|
35743
|
+
}
|
|
35744
|
+
|
|
35745
|
+
var text = "Warning: " + message;
|
|
35746
|
+
|
|
35747
|
+
if (typeof console !== 'undefined') {
|
|
35748
|
+
console.warn(text);
|
|
35749
|
+
}
|
|
35750
|
+
|
|
35751
|
+
try {
|
|
35752
|
+
throw Error(text);
|
|
35753
|
+
} catch (x) {}
|
|
35754
|
+
}
|
|
35684
35755
|
}
|
|
35685
35756
|
|
|
35686
|
-
|
|
35687
|
-
|
|
35688
|
-
|
|
35689
|
-
|
|
35690
|
-
|
|
35691
|
-
|
|
35692
|
-
|
|
35693
|
-
|
|
35694
|
-
|
|
35695
|
-
|
|
35696
|
-
|
|
35697
|
-
|
|
35698
|
-
super(`react-collapsed: ${message}`);
|
|
35757
|
+
var _excluded = ["duration", "easing", "onTransitionStateChange", "isExpanded", "defaultExpanded", "hasDisabledAnimation", "id"],
|
|
35758
|
+
_excluded2 = ["disabled", "onClick", "refKey"];
|
|
35759
|
+
|
|
35760
|
+
var CollapseError = /*#__PURE__*/function (_Error) {
|
|
35761
|
+
_inherits$2(CollapseError, _Error);
|
|
35762
|
+
|
|
35763
|
+
var _super = _createSuper(CollapseError);
|
|
35764
|
+
|
|
35765
|
+
function CollapseError(message) {
|
|
35766
|
+
_classCallCheck$2(this, CollapseError);
|
|
35767
|
+
|
|
35768
|
+
return _super.call(this, "react-collapsed: ".concat(message));
|
|
35699
35769
|
}
|
|
35700
|
-
|
|
35701
|
-
|
|
35702
|
-
|
|
35703
|
-
|
|
35770
|
+
|
|
35771
|
+
return _createClass$2(CollapseError);
|
|
35772
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
35773
|
+
|
|
35774
|
+
var collapseWarning = function collapseWarning() {
|
|
35775
|
+
return warning(arguments.length <= 0 ? undefined : arguments[0], "[react-collapsed] -- ".concat(arguments.length <= 1 ? undefined : arguments[1]));
|
|
35776
|
+
}; // src/utils/useEvent.ts
|
|
35777
|
+
|
|
35704
35778
|
function useEvent(callback) {
|
|
35705
|
-
|
|
35706
|
-
useEffect(()
|
|
35779
|
+
var ref = useRef(callback);
|
|
35780
|
+
useEffect(function () {
|
|
35707
35781
|
ref.current = callback;
|
|
35708
35782
|
});
|
|
35709
|
-
return useCallback(
|
|
35710
|
-
|
|
35783
|
+
return useCallback(function () {
|
|
35784
|
+
var _ref$current;
|
|
35785
|
+
|
|
35786
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35787
|
+
args[_key] = arguments[_key];
|
|
35788
|
+
}
|
|
35789
|
+
|
|
35790
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.call.apply(_ref$current, [ref].concat(args));
|
|
35791
|
+
}, []);
|
|
35792
|
+
} // src/utils/useControlledState.ts
|
|
35793
|
+
|
|
35711
35794
|
function useControlledState(value, defaultValue, callback) {
|
|
35712
|
-
|
|
35713
|
-
|
|
35714
|
-
|
|
35715
|
-
|
|
35716
|
-
|
|
35717
|
-
|
|
35718
|
-
|
|
35719
|
-
|
|
35720
|
-
|
|
35721
|
-
|
|
35722
|
-
|
|
35723
|
-
|
|
35724
|
-
|
|
35725
|
-
|
|
35726
|
-
|
|
35727
|
-
|
|
35728
|
-
|
|
35729
|
-
|
|
35730
|
-
|
|
35731
|
-
);
|
|
35732
|
-
collapseWarning(
|
|
35733
|
-
!(!initiallyControlled.current && value != null),
|
|
35734
|
-
"`isExpanded` state is changing from uncontrolled to controlled. useCollapse should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop."
|
|
35735
|
-
);
|
|
35795
|
+
var _useState = useState(defaultValue),
|
|
35796
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35797
|
+
state = _useState2[0],
|
|
35798
|
+
setState = _useState2[1];
|
|
35799
|
+
|
|
35800
|
+
var initiallyControlled = useRef(typeof value !== "undefined");
|
|
35801
|
+
var effectiveValue = initiallyControlled.current ? value : state;
|
|
35802
|
+
var cb = useEvent(callback);
|
|
35803
|
+
var onChange = useCallback(function (update) {
|
|
35804
|
+
var setter = update;
|
|
35805
|
+
var newValue = typeof update === "function" ? setter(effectiveValue) : update;
|
|
35806
|
+
|
|
35807
|
+
if (!initiallyControlled.current) {
|
|
35808
|
+
setState(newValue);
|
|
35809
|
+
}
|
|
35810
|
+
|
|
35811
|
+
cb === null || cb === void 0 || cb(newValue);
|
|
35812
|
+
}, [cb, effectiveValue]);
|
|
35813
|
+
useEffect(function () {
|
|
35814
|
+
collapseWarning(!(initiallyControlled.current && value == null), "`isExpanded` state is changing from controlled to uncontrolled. useCollapse should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop.");
|
|
35815
|
+
collapseWarning(!(!initiallyControlled.current && value != null), "`isExpanded` state is changing from uncontrolled to controlled. useCollapse should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop.");
|
|
35736
35816
|
}, [value]);
|
|
35737
35817
|
return [effectiveValue, onChange];
|
|
35738
|
-
}
|
|
35818
|
+
} // src/utils/usePrefersReducedMotion.ts
|
|
35739
35819
|
var QUERY = "(prefers-reduced-motion: reduce)";
|
|
35820
|
+
|
|
35740
35821
|
function usePrefersReducedMotion() {
|
|
35741
|
-
|
|
35742
|
-
|
|
35822
|
+
var _useState3 = useState(false),
|
|
35823
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35824
|
+
prefersReducedMotion = _useState4[0],
|
|
35825
|
+
setPrefersReducedMotion = _useState4[1];
|
|
35826
|
+
|
|
35827
|
+
useEffect(function () {
|
|
35743
35828
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
35744
35829
|
return;
|
|
35745
35830
|
}
|
|
35746
|
-
|
|
35831
|
+
|
|
35832
|
+
var mediaQueryList = window.matchMedia(QUERY);
|
|
35747
35833
|
setPrefersReducedMotion(mediaQueryList.matches);
|
|
35748
|
-
|
|
35834
|
+
|
|
35835
|
+
var listener = function listener(event) {
|
|
35749
35836
|
setPrefersReducedMotion(event.matches);
|
|
35750
35837
|
};
|
|
35838
|
+
|
|
35751
35839
|
if (mediaQueryList.addEventListener) {
|
|
35752
35840
|
mediaQueryList.addEventListener("change", listener);
|
|
35753
|
-
return ()
|
|
35841
|
+
return function () {
|
|
35754
35842
|
mediaQueryList.removeEventListener("change", listener);
|
|
35755
35843
|
};
|
|
35756
35844
|
} else if (mediaQueryList.addListener) {
|
|
35757
35845
|
mediaQueryList.addListener(listener);
|
|
35758
|
-
return ()
|
|
35846
|
+
return function () {
|
|
35759
35847
|
mediaQueryList.removeListener(listener);
|
|
35760
35848
|
};
|
|
35761
35849
|
}
|
|
35850
|
+
|
|
35762
35851
|
return void 0;
|
|
35763
35852
|
}, []);
|
|
35764
35853
|
return prefersReducedMotion;
|
|
35765
|
-
}
|
|
35766
|
-
|
|
35854
|
+
} // src/utils/useId.ts
|
|
35855
|
+
|
|
35856
|
+
var __useId = React["useId".toString()] || function () {
|
|
35857
|
+
return void 0;
|
|
35858
|
+
};
|
|
35859
|
+
|
|
35767
35860
|
function useReactId() {
|
|
35768
|
-
|
|
35769
|
-
|
|
35861
|
+
var id2 = __useId();
|
|
35862
|
+
|
|
35863
|
+
return id2 !== null && id2 !== void 0 ? id2 : "";
|
|
35770
35864
|
}
|
|
35865
|
+
|
|
35771
35866
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
35772
35867
|
var serverHandoffComplete = false;
|
|
35773
35868
|
var id = 0;
|
|
35774
|
-
|
|
35869
|
+
|
|
35870
|
+
var genId = function genId() {
|
|
35871
|
+
return ++id;
|
|
35872
|
+
};
|
|
35873
|
+
|
|
35775
35874
|
function useUniqueId(idFromProps) {
|
|
35776
|
-
|
|
35777
|
-
|
|
35778
|
-
|
|
35875
|
+
var initialId = idFromProps || (serverHandoffComplete ? genId() : null);
|
|
35876
|
+
|
|
35877
|
+
var _React$useState = React.useState(initialId),
|
|
35878
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
35879
|
+
id2 = _React$useState2[0],
|
|
35880
|
+
setId = _React$useState2[1];
|
|
35881
|
+
|
|
35882
|
+
useIsomorphicLayoutEffect(function () {
|
|
35779
35883
|
if (id2 === null) {
|
|
35780
35884
|
setId(genId());
|
|
35781
35885
|
}
|
|
35782
35886
|
}, []);
|
|
35783
|
-
React.useEffect(()
|
|
35887
|
+
React.useEffect(function () {
|
|
35784
35888
|
if (serverHandoffComplete === false) {
|
|
35785
35889
|
serverHandoffComplete = true;
|
|
35786
35890
|
}
|
|
35787
35891
|
}, []);
|
|
35788
35892
|
return id2 != null ? String(id2) : void 0;
|
|
35789
35893
|
}
|
|
35894
|
+
|
|
35790
35895
|
function useId(idOverride) {
|
|
35791
|
-
|
|
35792
|
-
|
|
35896
|
+
var reactId = useReactId();
|
|
35897
|
+
var uniqueId = useUniqueId(idOverride);
|
|
35898
|
+
|
|
35793
35899
|
if (typeof idOverride === "string") {
|
|
35794
35900
|
return idOverride;
|
|
35795
35901
|
}
|
|
35902
|
+
|
|
35796
35903
|
if (typeof reactId === "string") {
|
|
35797
35904
|
return reactId;
|
|
35798
35905
|
}
|
|
35906
|
+
|
|
35799
35907
|
return uniqueId;
|
|
35800
|
-
}
|
|
35908
|
+
} // src/utils/setAnimationTimeout.ts
|
|
35909
|
+
|
|
35801
35910
|
|
|
35802
|
-
// src/utils/setAnimationTimeout.ts
|
|
35803
35911
|
function setAnimationTimeout(callback, timeout) {
|
|
35804
|
-
|
|
35805
|
-
|
|
35912
|
+
var startTime = performance.now();
|
|
35913
|
+
var frame = {};
|
|
35914
|
+
|
|
35806
35915
|
function call() {
|
|
35807
|
-
frame.id = requestAnimationFrame((now)
|
|
35916
|
+
frame.id = requestAnimationFrame(function (now) {
|
|
35808
35917
|
if (now - startTime > timeout) {
|
|
35809
35918
|
callback();
|
|
35810
35919
|
} else {
|
|
@@ -35812,121 +35921,142 @@ function setAnimationTimeout(callback, timeout) {
|
|
|
35812
35921
|
}
|
|
35813
35922
|
});
|
|
35814
35923
|
}
|
|
35924
|
+
|
|
35815
35925
|
call();
|
|
35816
35926
|
return frame;
|
|
35817
35927
|
}
|
|
35928
|
+
|
|
35818
35929
|
function clearAnimationTimeout(frame) {
|
|
35819
|
-
if (frame.id)
|
|
35820
|
-
|
|
35821
|
-
}
|
|
35930
|
+
if (frame.id) cancelAnimationFrame(frame.id);
|
|
35931
|
+
} // src/utils/index.ts
|
|
35822
35932
|
|
|
35823
|
-
// src/utils/index.ts
|
|
35824
|
-
function getElementHeight(el) {
|
|
35825
|
-
if (!el?.current) {
|
|
35826
|
-
collapseWarning(
|
|
35827
|
-
true,
|
|
35828
|
-
`Was not able to find a ref to the collapse element via \`getCollapseProps\`. Ensure that the element exposes its \`ref\` prop. If it exposes the ref prop under a different name (like \`innerRef\`), use the \`refKey\` property to change it. Example:
|
|
35829
35933
|
|
|
35830
|
-
|
|
35831
|
-
|
|
35934
|
+
function getElementHeight(el) {
|
|
35935
|
+
if (!(el !== null && el !== void 0 && el.current)) {
|
|
35936
|
+
collapseWarning(true, "Was not able to find a ref to the collapse element via `getCollapseProps`. Ensure that the element exposes its `ref` prop. If it exposes the ref prop under a different name (like `innerRef`), use the `refKey` property to change it. Example:\n\nconst collapseProps = getCollapseProps({refKey: 'innerRef'})");
|
|
35832
35937
|
return 0;
|
|
35833
35938
|
}
|
|
35939
|
+
|
|
35834
35940
|
return el.current.scrollHeight;
|
|
35835
35941
|
}
|
|
35942
|
+
|
|
35836
35943
|
function getAutoHeightDuration(height) {
|
|
35837
35944
|
if (!height || typeof height === "string") {
|
|
35838
35945
|
return 0;
|
|
35839
35946
|
}
|
|
35840
|
-
|
|
35841
|
-
|
|
35947
|
+
|
|
35948
|
+
var constant = height / 36;
|
|
35949
|
+
return Math.round((4 + 15 * Math.pow(constant, 0.25) + constant / 5) * 10);
|
|
35842
35950
|
}
|
|
35951
|
+
|
|
35843
35952
|
function assignRef(ref, value) {
|
|
35844
|
-
if (ref == null)
|
|
35845
|
-
|
|
35953
|
+
if (ref == null) return;
|
|
35954
|
+
|
|
35846
35955
|
if (typeof ref === "function") {
|
|
35847
35956
|
ref(value);
|
|
35848
35957
|
} else {
|
|
35849
35958
|
try {
|
|
35850
35959
|
ref.current = value;
|
|
35851
35960
|
} catch (error) {
|
|
35852
|
-
throw new CollapseError(
|
|
35961
|
+
throw new CollapseError("Cannot assign value \"".concat(value, "\" to ref \"").concat(ref, "\""));
|
|
35853
35962
|
}
|
|
35854
35963
|
}
|
|
35855
35964
|
}
|
|
35856
|
-
|
|
35857
|
-
|
|
35965
|
+
|
|
35966
|
+
function mergeRefs() {
|
|
35967
|
+
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
35968
|
+
refs[_key2] = arguments[_key2];
|
|
35969
|
+
}
|
|
35970
|
+
|
|
35971
|
+
if (refs.every(function (ref) {
|
|
35972
|
+
return ref == null;
|
|
35973
|
+
})) {
|
|
35858
35974
|
return null;
|
|
35859
35975
|
}
|
|
35860
|
-
|
|
35861
|
-
|
|
35976
|
+
|
|
35977
|
+
return function (node) {
|
|
35978
|
+
refs.forEach(function (ref) {
|
|
35862
35979
|
assignRef(ref, node);
|
|
35863
35980
|
});
|
|
35864
35981
|
};
|
|
35865
35982
|
}
|
|
35983
|
+
|
|
35866
35984
|
function usePaddingWarning(element) {
|
|
35867
|
-
|
|
35868
|
-
|
|
35985
|
+
var warn = function warn(el) {};
|
|
35986
|
+
|
|
35869
35987
|
{
|
|
35870
|
-
warn = (el)
|
|
35871
|
-
if (!el
|
|
35988
|
+
warn = function warn(el) {
|
|
35989
|
+
if (!(el !== null && el !== void 0 && el.current)) {
|
|
35872
35990
|
return;
|
|
35873
35991
|
}
|
|
35874
|
-
const { paddingTop, paddingBottom } = window.getComputedStyle(el.current);
|
|
35875
|
-
const hasPadding = paddingTop && paddingTop !== "0px" || paddingBottom && paddingBottom !== "0px";
|
|
35876
|
-
collapseWarning(
|
|
35877
|
-
!hasPadding,
|
|
35878
|
-
`Padding applied to the collapse element will cause the animation to break and not perform as expected. To fix, apply equivalent padding to the direct descendent of the collapse element. Example:
|
|
35879
35992
|
|
|
35880
|
-
|
|
35993
|
+
var _window$getComputedSt = window.getComputedStyle(el.current),
|
|
35994
|
+
paddingTop = _window$getComputedSt.paddingTop,
|
|
35995
|
+
paddingBottom = _window$getComputedSt.paddingBottom;
|
|
35881
35996
|
|
|
35882
|
-
|
|
35883
|
-
<div style={{padding: 10}}>
|
|
35884
|
-
{children}
|
|
35885
|
-
</div>
|
|
35886
|
-
</div>`
|
|
35887
|
-
);
|
|
35997
|
+
var hasPadding = paddingTop && paddingTop !== "0px" || paddingBottom && paddingBottom !== "0px";
|
|
35998
|
+
collapseWarning(!hasPadding, "Padding applied to the collapse element will cause the animation to break and not perform as expected. To fix, apply equivalent padding to the direct descendent of the collapse element. Example:\n\nBefore: <div {...getCollapseProps({style: {padding: 10}})}>{children}</div>\n\nAfter: <div {...getCollapseProps()}>\n <div style={{padding: 10}}>\n {children}\n </div>\n </div>");
|
|
35888
35999
|
};
|
|
35889
36000
|
}
|
|
35890
|
-
|
|
36001
|
+
|
|
36002
|
+
useEffect(function () {
|
|
35891
36003
|
warn(element);
|
|
35892
36004
|
}, [element]);
|
|
35893
|
-
}
|
|
36005
|
+
} // src/index.ts
|
|
36006
|
+
|
|
35894
36007
|
|
|
35895
|
-
// src/index.ts
|
|
35896
36008
|
var useLayoutEffect2 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
35897
|
-
|
|
35898
|
-
|
|
35899
|
-
|
|
35900
|
-
|
|
35901
|
-
|
|
35902
|
-
|
|
35903
|
-
|
|
35904
|
-
|
|
35905
|
-
|
|
35906
|
-
|
|
35907
|
-
|
|
35908
|
-
|
|
35909
|
-
|
|
35910
|
-
|
|
35911
|
-
|
|
35912
|
-
|
|
35913
|
-
);
|
|
35914
|
-
|
|
35915
|
-
|
|
35916
|
-
|
|
35917
|
-
|
|
35918
|
-
|
|
35919
|
-
|
|
35920
|
-
|
|
35921
|
-
|
|
36009
|
+
|
|
36010
|
+
function useCollapse() {
|
|
36011
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
36012
|
+
duration = _ref.duration,
|
|
36013
|
+
_ref$easing = _ref.easing,
|
|
36014
|
+
easing = _ref$easing === void 0 ? "cubic-bezier(0.4, 0, 0.2, 1)" : _ref$easing,
|
|
36015
|
+
_ref$onTransitionStat = _ref.onTransitionStateChange,
|
|
36016
|
+
propOnTransitionStateChange = _ref$onTransitionStat === void 0 ? function () {} : _ref$onTransitionStat,
|
|
36017
|
+
configIsExpanded = _ref.isExpanded,
|
|
36018
|
+
_ref$defaultExpanded = _ref.defaultExpanded,
|
|
36019
|
+
defaultExpanded = _ref$defaultExpanded === void 0 ? false : _ref$defaultExpanded,
|
|
36020
|
+
hasDisabledAnimation = _ref.hasDisabledAnimation,
|
|
36021
|
+
id2 = _ref.id,
|
|
36022
|
+
initialConfig = _objectWithoutProperties(_ref, _excluded);
|
|
36023
|
+
|
|
36024
|
+
var onTransitionStateChange = useEvent(propOnTransitionStateChange);
|
|
36025
|
+
var uniqueId = useId(id2 ? "".concat(id2) : void 0);
|
|
36026
|
+
|
|
36027
|
+
var _useControlledState = useControlledState(configIsExpanded, defaultExpanded),
|
|
36028
|
+
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
36029
|
+
isExpanded = _useControlledState2[0],
|
|
36030
|
+
setExpanded = _useControlledState2[1];
|
|
36031
|
+
|
|
36032
|
+
var prevExpanded = useRef(isExpanded);
|
|
36033
|
+
|
|
36034
|
+
var _useState5 = useState(false),
|
|
36035
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
36036
|
+
isAnimating = _useState6[0],
|
|
36037
|
+
setIsAnimating = _useState6[1];
|
|
36038
|
+
|
|
36039
|
+
var prefersReducedMotion = usePrefersReducedMotion();
|
|
36040
|
+
var disableAnimation = hasDisabledAnimation !== null && hasDisabledAnimation !== void 0 ? hasDisabledAnimation : prefersReducedMotion;
|
|
36041
|
+
var frameId = useRef();
|
|
36042
|
+
var endFrameId = useRef();
|
|
36043
|
+
var collapseElRef = useRef(null);
|
|
36044
|
+
|
|
36045
|
+
var _useState7 = useState(null),
|
|
36046
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
36047
|
+
toggleEl = _useState8[0],
|
|
36048
|
+
setToggleEl = _useState8[1];
|
|
36049
|
+
|
|
35922
36050
|
usePaddingWarning(collapseElRef);
|
|
35923
|
-
|
|
36051
|
+
var collapsedHeight = "".concat(initialConfig.collapsedHeight || 0, "px");
|
|
36052
|
+
|
|
35924
36053
|
function setStyles(newStyles) {
|
|
35925
|
-
if (!collapseElRef.current)
|
|
35926
|
-
|
|
35927
|
-
|
|
35928
|
-
for (
|
|
35929
|
-
|
|
36054
|
+
if (!collapseElRef.current) return;
|
|
36055
|
+
var target = collapseElRef.current;
|
|
36056
|
+
|
|
36057
|
+
for (var property in newStyles) {
|
|
36058
|
+
var value = newStyles[property];
|
|
36059
|
+
|
|
35930
36060
|
if (value) {
|
|
35931
36061
|
target.style[property] = value;
|
|
35932
36062
|
} else {
|
|
@@ -35934,21 +36064,26 @@ function useCollapse({
|
|
|
35934
36064
|
}
|
|
35935
36065
|
}
|
|
35936
36066
|
}
|
|
35937
|
-
|
|
35938
|
-
|
|
35939
|
-
|
|
35940
|
-
|
|
35941
|
-
if (isExpanded === prevExpanded.current)
|
|
35942
|
-
return;
|
|
36067
|
+
|
|
36068
|
+
useLayoutEffect2(function () {
|
|
36069
|
+
var collapse = collapseElRef.current;
|
|
36070
|
+
if (!collapse) return;
|
|
36071
|
+
if (isExpanded === prevExpanded.current) return;
|
|
35943
36072
|
prevExpanded.current = isExpanded;
|
|
36073
|
+
|
|
35944
36074
|
function getDuration(height) {
|
|
35945
36075
|
if (disableAnimation) {
|
|
35946
36076
|
return 0;
|
|
35947
36077
|
}
|
|
35948
|
-
|
|
36078
|
+
|
|
36079
|
+
return duration !== null && duration !== void 0 ? duration : getAutoHeightDuration(height);
|
|
35949
36080
|
}
|
|
35950
|
-
|
|
35951
|
-
|
|
36081
|
+
|
|
36082
|
+
var getTransitionStyles = function getTransitionStyles(height) {
|
|
36083
|
+
return "height ".concat(getDuration(height), "ms ").concat(easing);
|
|
36084
|
+
};
|
|
36085
|
+
|
|
36086
|
+
var setTransitionEndTimeout = function setTransitionEndTimeout(duration2) {
|
|
35952
36087
|
function endTransition() {
|
|
35953
36088
|
if (isExpanded) {
|
|
35954
36089
|
setStyles({
|
|
@@ -35959,45 +36094,53 @@ function useCollapse({
|
|
|
35959
36094
|
});
|
|
35960
36095
|
onTransitionStateChange("expandEnd");
|
|
35961
36096
|
} else {
|
|
35962
|
-
setStyles({
|
|
36097
|
+
setStyles({
|
|
36098
|
+
transition: ""
|
|
36099
|
+
});
|
|
35963
36100
|
onTransitionStateChange("collapseEnd");
|
|
35964
36101
|
}
|
|
36102
|
+
|
|
35965
36103
|
setIsAnimating(false);
|
|
35966
36104
|
}
|
|
36105
|
+
|
|
35967
36106
|
if (endFrameId.current) {
|
|
35968
36107
|
clearAnimationTimeout(endFrameId.current);
|
|
35969
36108
|
}
|
|
36109
|
+
|
|
35970
36110
|
endFrameId.current = setAnimationTimeout(endTransition, duration2);
|
|
35971
36111
|
};
|
|
36112
|
+
|
|
35972
36113
|
setIsAnimating(true);
|
|
36114
|
+
|
|
35973
36115
|
if (isExpanded) {
|
|
35974
|
-
frameId.current = requestAnimationFrame(()
|
|
36116
|
+
frameId.current = requestAnimationFrame(function () {
|
|
35975
36117
|
onTransitionStateChange("expandStart");
|
|
35976
36118
|
setStyles({
|
|
35977
36119
|
display: "block",
|
|
35978
36120
|
overflow: "hidden",
|
|
35979
36121
|
height: collapsedHeight
|
|
35980
36122
|
});
|
|
35981
|
-
frameId.current = requestAnimationFrame(()
|
|
36123
|
+
frameId.current = requestAnimationFrame(function () {
|
|
35982
36124
|
onTransitionStateChange("expanding");
|
|
35983
|
-
|
|
36125
|
+
var height = getElementHeight(collapseElRef);
|
|
35984
36126
|
setTransitionEndTimeout(getDuration(height));
|
|
36127
|
+
|
|
35985
36128
|
if (collapseElRef.current) {
|
|
35986
36129
|
collapseElRef.current.style.transition = getTransitionStyles(height);
|
|
35987
|
-
collapseElRef.current.style.height =
|
|
36130
|
+
collapseElRef.current.style.height = "".concat(height, "px");
|
|
35988
36131
|
}
|
|
35989
36132
|
});
|
|
35990
36133
|
});
|
|
35991
36134
|
} else {
|
|
35992
|
-
frameId.current = requestAnimationFrame(()
|
|
36135
|
+
frameId.current = requestAnimationFrame(function () {
|
|
35993
36136
|
onTransitionStateChange("collapseStart");
|
|
35994
|
-
|
|
36137
|
+
var height = getElementHeight(collapseElRef);
|
|
35995
36138
|
setTransitionEndTimeout(getDuration(height));
|
|
35996
36139
|
setStyles({
|
|
35997
36140
|
transition: getTransitionStyles(height),
|
|
35998
|
-
height:
|
|
36141
|
+
height: "".concat(height, "px")
|
|
35999
36142
|
});
|
|
36000
|
-
frameId.current = requestAnimationFrame(()
|
|
36143
|
+
frameId.current = requestAnimationFrame(function () {
|
|
36001
36144
|
onTransitionStateChange("collapsing");
|
|
36002
36145
|
setStyles({
|
|
36003
36146
|
height: collapsedHeight,
|
|
@@ -36006,89 +36149,84 @@ function useCollapse({
|
|
|
36006
36149
|
});
|
|
36007
36150
|
});
|
|
36008
36151
|
}
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
if (endFrameId.current)
|
|
36013
|
-
clearAnimationTimeout(endFrameId.current);
|
|
36152
|
+
|
|
36153
|
+
return function () {
|
|
36154
|
+
if (frameId.current) cancelAnimationFrame(frameId.current);
|
|
36155
|
+
if (endFrameId.current) clearAnimationTimeout(endFrameId.current);
|
|
36014
36156
|
};
|
|
36015
|
-
}, [
|
|
36016
|
-
isExpanded,
|
|
36017
|
-
collapsedHeight,
|
|
36018
|
-
disableAnimation,
|
|
36019
|
-
duration,
|
|
36020
|
-
easing,
|
|
36021
|
-
onTransitionStateChange
|
|
36022
|
-
]);
|
|
36157
|
+
}, [isExpanded, collapsedHeight, disableAnimation, duration, easing, onTransitionStateChange]);
|
|
36023
36158
|
return {
|
|
36024
|
-
isExpanded,
|
|
36025
|
-
setExpanded,
|
|
36026
|
-
getToggleProps(args) {
|
|
36027
|
-
|
|
36159
|
+
isExpanded: isExpanded,
|
|
36160
|
+
setExpanded: setExpanded,
|
|
36161
|
+
getToggleProps: function getToggleProps(args) {
|
|
36162
|
+
var _refKey$onClick$disab = _objectSpread2({
|
|
36028
36163
|
refKey: "ref",
|
|
36029
|
-
onClick() {
|
|
36030
|
-
|
|
36031
|
-
|
|
36032
|
-
|
|
36033
|
-
|
|
36034
|
-
|
|
36035
|
-
|
|
36036
|
-
|
|
36037
|
-
|
|
36038
|
-
|
|
36164
|
+
onClick: function onClick() {},
|
|
36165
|
+
disabled: false
|
|
36166
|
+
}, args),
|
|
36167
|
+
disabled = _refKey$onClick$disab.disabled,
|
|
36168
|
+
_onClick = _refKey$onClick$disab.onClick,
|
|
36169
|
+
refKey = _refKey$onClick$disab.refKey,
|
|
36170
|
+
rest = _objectWithoutProperties(_refKey$onClick$disab, _excluded2);
|
|
36171
|
+
|
|
36172
|
+
var isButton = toggleEl ? toggleEl.tagName === "BUTTON" : void 0;
|
|
36173
|
+
var theirRef = args === null || args === void 0 ? void 0 : args[refKey || "ref"];
|
|
36174
|
+
|
|
36175
|
+
var props = _defineProperty({
|
|
36176
|
+
id: "react-collapsed-toggle-".concat(uniqueId),
|
|
36177
|
+
"aria-controls": "react-collapsed-panel-".concat(uniqueId),
|
|
36039
36178
|
"aria-expanded": isExpanded,
|
|
36040
|
-
onClick(evt) {
|
|
36041
|
-
if (disabled)
|
|
36042
|
-
|
|
36043
|
-
|
|
36044
|
-
|
|
36045
|
-
|
|
36046
|
-
|
|
36047
|
-
};
|
|
36048
|
-
|
|
36179
|
+
onClick: function onClick(evt) {
|
|
36180
|
+
if (disabled) return;
|
|
36181
|
+
_onClick === null || _onClick === void 0 || _onClick(evt);
|
|
36182
|
+
setExpanded(function (n) {
|
|
36183
|
+
return !n;
|
|
36184
|
+
});
|
|
36185
|
+
}
|
|
36186
|
+
}, refKey || "ref", mergeRefs(theirRef, setToggleEl));
|
|
36187
|
+
|
|
36188
|
+
var buttonProps = {
|
|
36049
36189
|
type: "button",
|
|
36050
36190
|
disabled: disabled ? true : void 0
|
|
36051
36191
|
};
|
|
36052
|
-
|
|
36192
|
+
var fakeButtonProps = {
|
|
36053
36193
|
"aria-disabled": disabled ? true : void 0,
|
|
36054
36194
|
role: "button",
|
|
36055
36195
|
tabIndex: disabled ? -1 : 0
|
|
36056
36196
|
};
|
|
36197
|
+
|
|
36057
36198
|
if (isButton === false) {
|
|
36058
|
-
return {
|
|
36199
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, props), fakeButtonProps), rest);
|
|
36059
36200
|
} else if (isButton === true) {
|
|
36060
|
-
return {
|
|
36201
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, props), buttonProps), rest);
|
|
36061
36202
|
} else {
|
|
36062
|
-
return {
|
|
36063
|
-
...props,
|
|
36064
|
-
...buttonProps,
|
|
36065
|
-
...fakeButtonProps,
|
|
36066
|
-
...rest
|
|
36067
|
-
};
|
|
36203
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, props), buttonProps), fakeButtonProps), rest);
|
|
36068
36204
|
}
|
|
36069
36205
|
},
|
|
36070
|
-
getCollapseProps(args) {
|
|
36071
|
-
|
|
36072
|
-
|
|
36073
|
-
|
|
36074
|
-
|
|
36206
|
+
getCollapseProps: function getCollapseProps(args) {
|
|
36207
|
+
var _objectSpread2$1;
|
|
36208
|
+
|
|
36209
|
+
var _refKey$style$args = _objectSpread2({
|
|
36210
|
+
refKey: "ref",
|
|
36211
|
+
style: {}
|
|
36212
|
+
}, args),
|
|
36213
|
+
style = _refKey$style$args.style,
|
|
36214
|
+
refKey = _refKey$style$args.refKey;
|
|
36215
|
+
|
|
36216
|
+
var theirRef = args === null || args === void 0 ? void 0 : args[refKey || "ref"];
|
|
36217
|
+
return _objectSpread2(_objectSpread2({
|
|
36218
|
+
id: "react-collapsed-panel-".concat(uniqueId),
|
|
36075
36219
|
"aria-hidden": !isExpanded,
|
|
36076
|
-
"aria-labelledby":
|
|
36077
|
-
role: "region"
|
|
36078
|
-
|
|
36079
|
-
|
|
36080
|
-
|
|
36081
|
-
|
|
36082
|
-
|
|
36083
|
-
|
|
36084
|
-
|
|
36085
|
-
|
|
36086
|
-
overflow: "hidden"
|
|
36087
|
-
} : {},
|
|
36088
|
-
// additional styles passed, e.g. getCollapseProps({style: {}})
|
|
36089
|
-
...style
|
|
36090
|
-
}
|
|
36091
|
-
};
|
|
36220
|
+
"aria-labelledby": "react-collapsed-toggle-".concat(uniqueId),
|
|
36221
|
+
role: "region"
|
|
36222
|
+
}, args), {}, (_objectSpread2$1 = {}, _defineProperty(_objectSpread2$1, refKey || "ref", mergeRefs(collapseElRef, theirRef)), _defineProperty(_objectSpread2$1, "style", _objectSpread2(_objectSpread2({
|
|
36223
|
+
boxSizing: "border-box"
|
|
36224
|
+
}, !isAnimating && !isExpanded ? {
|
|
36225
|
+
// collapsed and not animating
|
|
36226
|
+
display: collapsedHeight === "0px" ? "none" : "block",
|
|
36227
|
+
height: collapsedHeight,
|
|
36228
|
+
overflow: "hidden"
|
|
36229
|
+
} : {}), style)), _objectSpread2$1));
|
|
36092
36230
|
}
|
|
36093
36231
|
};
|
|
36094
36232
|
}
|