@janiscommerce/ui-web 1.4.0 → 1.5.0-beta.2
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 +423 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +428 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +10 -4
- package/package.json +7 -6
- package/CHANGELOG.md +0 -554
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('styled-components'), require('react-dom')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', 'styled-components', 'react-dom'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.main = {}, global.React, global.styled$j, global.ReactDOM
|
|
5
|
-
})(this, (function (exports, React, styled$j, ReactDOM
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('styled-components'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'styled-components', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.main = {}, global.React, global.styled$j, global.ReactDOM));
|
|
5
|
+
})(this, (function (exports, React, styled$j, ReactDOM) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -715,12 +715,12 @@
|
|
|
715
715
|
|
|
716
716
|
var uncurryThis$q = functionUncurryThis;
|
|
717
717
|
|
|
718
|
-
var id = 0;
|
|
718
|
+
var id$1 = 0;
|
|
719
719
|
var postfix = Math.random();
|
|
720
720
|
var toString$b = uncurryThis$q(1.0.toString);
|
|
721
721
|
|
|
722
722
|
var uid$2 = function (key) {
|
|
723
|
-
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$b(++id + postfix, 36);
|
|
723
|
+
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$b(++id$1 + postfix, 36);
|
|
724
724
|
};
|
|
725
725
|
|
|
726
726
|
var global$H = global$T;
|
|
@@ -3805,7 +3805,7 @@
|
|
|
3805
3805
|
var PATH_START = {};
|
|
3806
3806
|
var PATH = {};
|
|
3807
3807
|
var CANNOT_BE_A_BASE_URL_PATH = {};
|
|
3808
|
-
var QUERY = {};
|
|
3808
|
+
var QUERY$1 = {};
|
|
3809
3809
|
var FRAGMENT = {};
|
|
3810
3810
|
|
|
3811
3811
|
var URLState = function (url, isBase, base) {
|
|
@@ -3958,7 +3958,7 @@
|
|
|
3958
3958
|
url.port = base.port;
|
|
3959
3959
|
url.path = arraySlice$4(base.path);
|
|
3960
3960
|
url.query = '';
|
|
3961
|
-
state = QUERY;
|
|
3961
|
+
state = QUERY$1;
|
|
3962
3962
|
} else if (chr == '#') {
|
|
3963
3963
|
url.username = base.username;
|
|
3964
3964
|
url.password = base.password;
|
|
@@ -4094,7 +4094,7 @@
|
|
|
4094
4094
|
url.host = base.host;
|
|
4095
4095
|
url.path = arraySlice$4(base.path);
|
|
4096
4096
|
url.query = '';
|
|
4097
|
-
state = QUERY;
|
|
4097
|
+
state = QUERY$1;
|
|
4098
4098
|
} else if (chr == '#') {
|
|
4099
4099
|
url.host = base.host;
|
|
4100
4100
|
url.path = arraySlice$4(base.path);
|
|
@@ -4152,7 +4152,7 @@
|
|
|
4152
4152
|
if (chr != '/' && chr != '\\') continue;
|
|
4153
4153
|
} else if (!stateOverride && chr == '?') {
|
|
4154
4154
|
url.query = '';
|
|
4155
|
-
state = QUERY;
|
|
4155
|
+
state = QUERY$1;
|
|
4156
4156
|
} else if (!stateOverride && chr == '#') {
|
|
4157
4157
|
url.fragment = '';
|
|
4158
4158
|
state = FRAGMENT;
|
|
@@ -4191,7 +4191,7 @@
|
|
|
4191
4191
|
}
|
|
4192
4192
|
if (chr == '?') {
|
|
4193
4193
|
url.query = '';
|
|
4194
|
-
state = QUERY;
|
|
4194
|
+
state = QUERY$1;
|
|
4195
4195
|
} else if (chr == '#') {
|
|
4196
4196
|
url.fragment = '';
|
|
4197
4197
|
state = FRAGMENT;
|
|
@@ -4203,7 +4203,7 @@
|
|
|
4203
4203
|
case CANNOT_BE_A_BASE_URL_PATH:
|
|
4204
4204
|
if (chr == '?') {
|
|
4205
4205
|
url.query = '';
|
|
4206
|
-
state = QUERY;
|
|
4206
|
+
state = QUERY$1;
|
|
4207
4207
|
} else if (chr == '#') {
|
|
4208
4208
|
url.fragment = '';
|
|
4209
4209
|
state = FRAGMENT;
|
|
@@ -4211,7 +4211,7 @@
|
|
|
4211
4211
|
url.path[0] += percentEncode(chr, C0ControlPercentEncodeSet);
|
|
4212
4212
|
} break;
|
|
4213
4213
|
|
|
4214
|
-
case QUERY:
|
|
4214
|
+
case QUERY$1:
|
|
4215
4215
|
if (!stateOverride && chr == '#') {
|
|
4216
4216
|
url.fragment = '';
|
|
4217
4217
|
state = FRAGMENT;
|
|
@@ -4402,7 +4402,7 @@
|
|
|
4402
4402
|
} else {
|
|
4403
4403
|
if ('?' == charAt(search, 0)) search = stringSlice$1(search, 1);
|
|
4404
4404
|
this.query = '';
|
|
4405
|
-
this.parse(search, QUERY);
|
|
4405
|
+
this.parse(search, QUERY$1);
|
|
4406
4406
|
}
|
|
4407
4407
|
this.searchParams.update();
|
|
4408
4408
|
},
|
|
@@ -35825,6 +35825,419 @@
|
|
|
35825
35825
|
}));
|
|
35826
35826
|
};
|
|
35827
35827
|
|
|
35828
|
+
function warning(condition, message) {
|
|
35829
|
+
}
|
|
35830
|
+
|
|
35831
|
+
/**
|
|
35832
|
+
* react-collapsed v4.2.0
|
|
35833
|
+
*
|
|
35834
|
+
* Copyright (c) 2019-2024, Rogin Farrer
|
|
35835
|
+
*
|
|
35836
|
+
* This source code is licensed under the MIT license found in the
|
|
35837
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
35838
|
+
*
|
|
35839
|
+
* @license MIT
|
|
35840
|
+
*/
|
|
35841
|
+
var CollapseError = class extends Error {
|
|
35842
|
+
constructor(message) {
|
|
35843
|
+
super(`react-collapsed: ${message}`);
|
|
35844
|
+
}
|
|
35845
|
+
};
|
|
35846
|
+
var collapseWarning = (...args) => {
|
|
35847
|
+
return warning(args[0], `[react-collapsed] -- ${args[1]}`);
|
|
35848
|
+
};
|
|
35849
|
+
function useEvent(callback) {
|
|
35850
|
+
const ref = React.useRef(callback);
|
|
35851
|
+
React.useEffect(() => {
|
|
35852
|
+
ref.current = callback;
|
|
35853
|
+
});
|
|
35854
|
+
return React.useCallback((...args) => ref.current?.(...args), []);
|
|
35855
|
+
}
|
|
35856
|
+
function useControlledState(value, defaultValue, callback) {
|
|
35857
|
+
const [state, setState] = React.useState(defaultValue);
|
|
35858
|
+
const initiallyControlled = React.useRef(typeof value !== "undefined");
|
|
35859
|
+
const effectiveValue = initiallyControlled.current ? value : state;
|
|
35860
|
+
const cb = useEvent(callback);
|
|
35861
|
+
const onChange = React.useCallback(
|
|
35862
|
+
(update) => {
|
|
35863
|
+
const setter = update;
|
|
35864
|
+
const newValue = typeof update === "function" ? setter(effectiveValue) : update;
|
|
35865
|
+
if (!initiallyControlled.current) {
|
|
35866
|
+
setState(newValue);
|
|
35867
|
+
}
|
|
35868
|
+
cb?.(newValue);
|
|
35869
|
+
},
|
|
35870
|
+
[cb, effectiveValue]
|
|
35871
|
+
);
|
|
35872
|
+
React.useEffect(() => {
|
|
35873
|
+
collapseWarning(
|
|
35874
|
+
!(initiallyControlled.current && value == null),
|
|
35875
|
+
"`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."
|
|
35876
|
+
);
|
|
35877
|
+
collapseWarning(
|
|
35878
|
+
!(!initiallyControlled.current && value != null),
|
|
35879
|
+
"`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."
|
|
35880
|
+
);
|
|
35881
|
+
}, [value]);
|
|
35882
|
+
return [effectiveValue, onChange];
|
|
35883
|
+
}
|
|
35884
|
+
var QUERY = "(prefers-reduced-motion: reduce)";
|
|
35885
|
+
function usePrefersReducedMotion() {
|
|
35886
|
+
const [prefersReducedMotion, setPrefersReducedMotion] = React.useState(false);
|
|
35887
|
+
React.useEffect(() => {
|
|
35888
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
35889
|
+
return;
|
|
35890
|
+
}
|
|
35891
|
+
const mediaQueryList = window.matchMedia(QUERY);
|
|
35892
|
+
setPrefersReducedMotion(mediaQueryList.matches);
|
|
35893
|
+
const listener = (event) => {
|
|
35894
|
+
setPrefersReducedMotion(event.matches);
|
|
35895
|
+
};
|
|
35896
|
+
if (mediaQueryList.addEventListener) {
|
|
35897
|
+
mediaQueryList.addEventListener("change", listener);
|
|
35898
|
+
return () => {
|
|
35899
|
+
mediaQueryList.removeEventListener("change", listener);
|
|
35900
|
+
};
|
|
35901
|
+
} else if (mediaQueryList.addListener) {
|
|
35902
|
+
mediaQueryList.addListener(listener);
|
|
35903
|
+
return () => {
|
|
35904
|
+
mediaQueryList.removeListener(listener);
|
|
35905
|
+
};
|
|
35906
|
+
}
|
|
35907
|
+
return void 0;
|
|
35908
|
+
}, []);
|
|
35909
|
+
return prefersReducedMotion;
|
|
35910
|
+
}
|
|
35911
|
+
var __useId = React__namespace["useId".toString()] || (() => void 0);
|
|
35912
|
+
function useReactId() {
|
|
35913
|
+
const id2 = __useId();
|
|
35914
|
+
return id2 ?? "";
|
|
35915
|
+
}
|
|
35916
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
35917
|
+
var serverHandoffComplete = false;
|
|
35918
|
+
var id = 0;
|
|
35919
|
+
var genId = () => ++id;
|
|
35920
|
+
function useUniqueId(idFromProps) {
|
|
35921
|
+
const initialId = idFromProps || (serverHandoffComplete ? genId() : null);
|
|
35922
|
+
const [id2, setId] = React__namespace.useState(initialId);
|
|
35923
|
+
useIsomorphicLayoutEffect(() => {
|
|
35924
|
+
if (id2 === null) {
|
|
35925
|
+
setId(genId());
|
|
35926
|
+
}
|
|
35927
|
+
}, []);
|
|
35928
|
+
React__namespace.useEffect(() => {
|
|
35929
|
+
if (serverHandoffComplete === false) {
|
|
35930
|
+
serverHandoffComplete = true;
|
|
35931
|
+
}
|
|
35932
|
+
}, []);
|
|
35933
|
+
return id2 != null ? String(id2) : void 0;
|
|
35934
|
+
}
|
|
35935
|
+
function useId(idOverride) {
|
|
35936
|
+
const reactId = useReactId();
|
|
35937
|
+
const uniqueId = useUniqueId(idOverride);
|
|
35938
|
+
if (typeof idOverride === "string") {
|
|
35939
|
+
return idOverride;
|
|
35940
|
+
}
|
|
35941
|
+
if (typeof reactId === "string") {
|
|
35942
|
+
return reactId;
|
|
35943
|
+
}
|
|
35944
|
+
return uniqueId;
|
|
35945
|
+
}
|
|
35946
|
+
|
|
35947
|
+
// src/utils/setAnimationTimeout.ts
|
|
35948
|
+
function setAnimationTimeout(callback, timeout) {
|
|
35949
|
+
const startTime = performance.now();
|
|
35950
|
+
const frame = {};
|
|
35951
|
+
function call() {
|
|
35952
|
+
frame.id = requestAnimationFrame((now) => {
|
|
35953
|
+
if (now - startTime > timeout) {
|
|
35954
|
+
callback();
|
|
35955
|
+
} else {
|
|
35956
|
+
call();
|
|
35957
|
+
}
|
|
35958
|
+
});
|
|
35959
|
+
}
|
|
35960
|
+
call();
|
|
35961
|
+
return frame;
|
|
35962
|
+
}
|
|
35963
|
+
function clearAnimationTimeout(frame) {
|
|
35964
|
+
if (frame.id)
|
|
35965
|
+
cancelAnimationFrame(frame.id);
|
|
35966
|
+
}
|
|
35967
|
+
|
|
35968
|
+
// src/utils/index.ts
|
|
35969
|
+
function getElementHeight(el) {
|
|
35970
|
+
if (!el?.current) {
|
|
35971
|
+
collapseWarning(
|
|
35972
|
+
true,
|
|
35973
|
+
`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:
|
|
35974
|
+
|
|
35975
|
+
const collapseProps = getCollapseProps({refKey: 'innerRef'})`
|
|
35976
|
+
);
|
|
35977
|
+
return 0;
|
|
35978
|
+
}
|
|
35979
|
+
return el.current.scrollHeight;
|
|
35980
|
+
}
|
|
35981
|
+
function getAutoHeightDuration(height) {
|
|
35982
|
+
if (!height || typeof height === "string") {
|
|
35983
|
+
return 0;
|
|
35984
|
+
}
|
|
35985
|
+
const constant = height / 36;
|
|
35986
|
+
return Math.round((4 + 15 * constant ** 0.25 + constant / 5) * 10);
|
|
35987
|
+
}
|
|
35988
|
+
function assignRef(ref, value) {
|
|
35989
|
+
if (ref == null)
|
|
35990
|
+
return;
|
|
35991
|
+
if (typeof ref === "function") {
|
|
35992
|
+
ref(value);
|
|
35993
|
+
} else {
|
|
35994
|
+
try {
|
|
35995
|
+
ref.current = value;
|
|
35996
|
+
} catch (error) {
|
|
35997
|
+
throw new CollapseError(`Cannot assign value "${value}" to ref "${ref}"`);
|
|
35998
|
+
}
|
|
35999
|
+
}
|
|
36000
|
+
}
|
|
36001
|
+
function mergeRefs(...refs) {
|
|
36002
|
+
if (refs.every((ref) => ref == null)) {
|
|
36003
|
+
return null;
|
|
36004
|
+
}
|
|
36005
|
+
return (node) => {
|
|
36006
|
+
refs.forEach((ref) => {
|
|
36007
|
+
assignRef(ref, node);
|
|
36008
|
+
});
|
|
36009
|
+
};
|
|
36010
|
+
}
|
|
36011
|
+
function usePaddingWarning(element) {
|
|
36012
|
+
let warn = (el) => {
|
|
36013
|
+
};
|
|
36014
|
+
{
|
|
36015
|
+
warn = (el) => {
|
|
36016
|
+
if (!el?.current) {
|
|
36017
|
+
return;
|
|
36018
|
+
}
|
|
36019
|
+
const { paddingTop, paddingBottom } = window.getComputedStyle(el.current);
|
|
36020
|
+
const hasPadding = paddingTop && paddingTop !== "0px" || paddingBottom && paddingBottom !== "0px";
|
|
36021
|
+
collapseWarning(
|
|
36022
|
+
!hasPadding,
|
|
36023
|
+
`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:
|
|
36024
|
+
|
|
36025
|
+
Before: <div {...getCollapseProps({style: {padding: 10}})}>{children}</div>
|
|
36026
|
+
|
|
36027
|
+
After: <div {...getCollapseProps()}>
|
|
36028
|
+
<div style={{padding: 10}}>
|
|
36029
|
+
{children}
|
|
36030
|
+
</div>
|
|
36031
|
+
</div>`
|
|
36032
|
+
);
|
|
36033
|
+
};
|
|
36034
|
+
}
|
|
36035
|
+
React.useEffect(() => {
|
|
36036
|
+
warn(element);
|
|
36037
|
+
}, [element]);
|
|
36038
|
+
}
|
|
36039
|
+
|
|
36040
|
+
// src/index.ts
|
|
36041
|
+
var useLayoutEffect2 = typeof window === "undefined" ? React.useEffect : React.useLayoutEffect;
|
|
36042
|
+
function useCollapse({
|
|
36043
|
+
duration,
|
|
36044
|
+
easing = "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
36045
|
+
onTransitionStateChange: propOnTransitionStateChange = () => {
|
|
36046
|
+
},
|
|
36047
|
+
isExpanded: configIsExpanded,
|
|
36048
|
+
defaultExpanded = false,
|
|
36049
|
+
hasDisabledAnimation,
|
|
36050
|
+
id: id2,
|
|
36051
|
+
...initialConfig
|
|
36052
|
+
} = {}) {
|
|
36053
|
+
const onTransitionStateChange = useEvent(propOnTransitionStateChange);
|
|
36054
|
+
const uniqueId = useId(id2 ? `${id2}` : void 0);
|
|
36055
|
+
const [isExpanded, setExpanded] = useControlledState(
|
|
36056
|
+
configIsExpanded,
|
|
36057
|
+
defaultExpanded
|
|
36058
|
+
);
|
|
36059
|
+
const prevExpanded = React.useRef(isExpanded);
|
|
36060
|
+
const [isAnimating, setIsAnimating] = React.useState(false);
|
|
36061
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
36062
|
+
const disableAnimation = hasDisabledAnimation ?? prefersReducedMotion;
|
|
36063
|
+
const frameId = React.useRef();
|
|
36064
|
+
const endFrameId = React.useRef();
|
|
36065
|
+
const collapseElRef = React.useRef(null);
|
|
36066
|
+
const [toggleEl, setToggleEl] = React.useState(null);
|
|
36067
|
+
usePaddingWarning(collapseElRef);
|
|
36068
|
+
const collapsedHeight = `${initialConfig.collapsedHeight || 0}px`;
|
|
36069
|
+
function setStyles(newStyles) {
|
|
36070
|
+
if (!collapseElRef.current)
|
|
36071
|
+
return;
|
|
36072
|
+
const target = collapseElRef.current;
|
|
36073
|
+
for (const property in newStyles) {
|
|
36074
|
+
const value = newStyles[property];
|
|
36075
|
+
if (value) {
|
|
36076
|
+
target.style[property] = value;
|
|
36077
|
+
} else {
|
|
36078
|
+
target.style.removeProperty(property);
|
|
36079
|
+
}
|
|
36080
|
+
}
|
|
36081
|
+
}
|
|
36082
|
+
useLayoutEffect2(() => {
|
|
36083
|
+
const collapse = collapseElRef.current;
|
|
36084
|
+
if (!collapse)
|
|
36085
|
+
return;
|
|
36086
|
+
if (isExpanded === prevExpanded.current)
|
|
36087
|
+
return;
|
|
36088
|
+
prevExpanded.current = isExpanded;
|
|
36089
|
+
function getDuration(height) {
|
|
36090
|
+
if (disableAnimation) {
|
|
36091
|
+
return 0;
|
|
36092
|
+
}
|
|
36093
|
+
return duration ?? getAutoHeightDuration(height);
|
|
36094
|
+
}
|
|
36095
|
+
const getTransitionStyles = (height) => `height ${getDuration(height)}ms ${easing}`;
|
|
36096
|
+
const setTransitionEndTimeout = (duration2) => {
|
|
36097
|
+
function endTransition() {
|
|
36098
|
+
if (isExpanded) {
|
|
36099
|
+
setStyles({
|
|
36100
|
+
height: "",
|
|
36101
|
+
overflow: "",
|
|
36102
|
+
transition: "",
|
|
36103
|
+
display: ""
|
|
36104
|
+
});
|
|
36105
|
+
onTransitionStateChange("expandEnd");
|
|
36106
|
+
} else {
|
|
36107
|
+
setStyles({ transition: "" });
|
|
36108
|
+
onTransitionStateChange("collapseEnd");
|
|
36109
|
+
}
|
|
36110
|
+
setIsAnimating(false);
|
|
36111
|
+
}
|
|
36112
|
+
if (endFrameId.current) {
|
|
36113
|
+
clearAnimationTimeout(endFrameId.current);
|
|
36114
|
+
}
|
|
36115
|
+
endFrameId.current = setAnimationTimeout(endTransition, duration2);
|
|
36116
|
+
};
|
|
36117
|
+
setIsAnimating(true);
|
|
36118
|
+
if (isExpanded) {
|
|
36119
|
+
frameId.current = requestAnimationFrame(() => {
|
|
36120
|
+
onTransitionStateChange("expandStart");
|
|
36121
|
+
setStyles({
|
|
36122
|
+
display: "block",
|
|
36123
|
+
overflow: "hidden",
|
|
36124
|
+
height: collapsedHeight
|
|
36125
|
+
});
|
|
36126
|
+
frameId.current = requestAnimationFrame(() => {
|
|
36127
|
+
onTransitionStateChange("expanding");
|
|
36128
|
+
const height = getElementHeight(collapseElRef);
|
|
36129
|
+
setTransitionEndTimeout(getDuration(height));
|
|
36130
|
+
if (collapseElRef.current) {
|
|
36131
|
+
collapseElRef.current.style.transition = getTransitionStyles(height);
|
|
36132
|
+
collapseElRef.current.style.height = `${height}px`;
|
|
36133
|
+
}
|
|
36134
|
+
});
|
|
36135
|
+
});
|
|
36136
|
+
} else {
|
|
36137
|
+
frameId.current = requestAnimationFrame(() => {
|
|
36138
|
+
onTransitionStateChange("collapseStart");
|
|
36139
|
+
const height = getElementHeight(collapseElRef);
|
|
36140
|
+
setTransitionEndTimeout(getDuration(height));
|
|
36141
|
+
setStyles({
|
|
36142
|
+
transition: getTransitionStyles(height),
|
|
36143
|
+
height: `${height}px`
|
|
36144
|
+
});
|
|
36145
|
+
frameId.current = requestAnimationFrame(() => {
|
|
36146
|
+
onTransitionStateChange("collapsing");
|
|
36147
|
+
setStyles({
|
|
36148
|
+
height: collapsedHeight,
|
|
36149
|
+
overflow: "hidden"
|
|
36150
|
+
});
|
|
36151
|
+
});
|
|
36152
|
+
});
|
|
36153
|
+
}
|
|
36154
|
+
return () => {
|
|
36155
|
+
if (frameId.current)
|
|
36156
|
+
cancelAnimationFrame(frameId.current);
|
|
36157
|
+
if (endFrameId.current)
|
|
36158
|
+
clearAnimationTimeout(endFrameId.current);
|
|
36159
|
+
};
|
|
36160
|
+
}, [
|
|
36161
|
+
isExpanded,
|
|
36162
|
+
collapsedHeight,
|
|
36163
|
+
disableAnimation,
|
|
36164
|
+
duration,
|
|
36165
|
+
easing,
|
|
36166
|
+
onTransitionStateChange
|
|
36167
|
+
]);
|
|
36168
|
+
return {
|
|
36169
|
+
isExpanded,
|
|
36170
|
+
setExpanded,
|
|
36171
|
+
getToggleProps(args) {
|
|
36172
|
+
const { disabled, onClick, refKey, ...rest } = {
|
|
36173
|
+
refKey: "ref",
|
|
36174
|
+
onClick() {
|
|
36175
|
+
},
|
|
36176
|
+
disabled: false,
|
|
36177
|
+
...args
|
|
36178
|
+
};
|
|
36179
|
+
const isButton = toggleEl ? toggleEl.tagName === "BUTTON" : void 0;
|
|
36180
|
+
const theirRef = args?.[refKey || "ref"];
|
|
36181
|
+
const props = {
|
|
36182
|
+
id: `react-collapsed-toggle-${uniqueId}`,
|
|
36183
|
+
"aria-controls": `react-collapsed-panel-${uniqueId}`,
|
|
36184
|
+
"aria-expanded": isExpanded,
|
|
36185
|
+
onClick(evt) {
|
|
36186
|
+
if (disabled)
|
|
36187
|
+
return;
|
|
36188
|
+
onClick?.(evt);
|
|
36189
|
+
setExpanded((n) => !n);
|
|
36190
|
+
},
|
|
36191
|
+
[refKey || "ref"]: mergeRefs(theirRef, setToggleEl)
|
|
36192
|
+
};
|
|
36193
|
+
const buttonProps = {
|
|
36194
|
+
type: "button",
|
|
36195
|
+
disabled: disabled ? true : void 0
|
|
36196
|
+
};
|
|
36197
|
+
const fakeButtonProps = {
|
|
36198
|
+
"aria-disabled": disabled ? true : void 0,
|
|
36199
|
+
role: "button",
|
|
36200
|
+
tabIndex: disabled ? -1 : 0
|
|
36201
|
+
};
|
|
36202
|
+
if (isButton === false) {
|
|
36203
|
+
return { ...props, ...fakeButtonProps, ...rest };
|
|
36204
|
+
} else if (isButton === true) {
|
|
36205
|
+
return { ...props, ...buttonProps, ...rest };
|
|
36206
|
+
} else {
|
|
36207
|
+
return {
|
|
36208
|
+
...props,
|
|
36209
|
+
...buttonProps,
|
|
36210
|
+
...fakeButtonProps,
|
|
36211
|
+
...rest
|
|
36212
|
+
};
|
|
36213
|
+
}
|
|
36214
|
+
},
|
|
36215
|
+
getCollapseProps(args) {
|
|
36216
|
+
const { style, refKey } = { refKey: "ref", style: {}, ...args };
|
|
36217
|
+
const theirRef = args?.[refKey || "ref"];
|
|
36218
|
+
return {
|
|
36219
|
+
id: `react-collapsed-panel-${uniqueId}`,
|
|
36220
|
+
"aria-hidden": !isExpanded,
|
|
36221
|
+
"aria-labelledby": `react-collapsed-toggle-${uniqueId}`,
|
|
36222
|
+
role: "region",
|
|
36223
|
+
...args,
|
|
36224
|
+
[refKey || "ref"]: mergeRefs(collapseElRef, theirRef),
|
|
36225
|
+
style: {
|
|
36226
|
+
boxSizing: "border-box",
|
|
36227
|
+
...!isAnimating && !isExpanded ? {
|
|
36228
|
+
// collapsed and not animating
|
|
36229
|
+
display: collapsedHeight === "0px" ? "none" : "block",
|
|
36230
|
+
height: collapsedHeight,
|
|
36231
|
+
overflow: "hidden"
|
|
36232
|
+
} : {},
|
|
36233
|
+
// additional styles passed, e.g. getCollapseProps({style: {}})
|
|
36234
|
+
...style
|
|
36235
|
+
}
|
|
36236
|
+
};
|
|
36237
|
+
}
|
|
36238
|
+
};
|
|
36239
|
+
}
|
|
36240
|
+
|
|
35828
36241
|
var Wrapper = styled__default["default"].div.withConfig({
|
|
35829
36242
|
displayName: "styles__Wrapper",
|
|
35830
36243
|
componentId: "sc-mlx2bu-0"
|
|
@@ -35914,7 +36327,7 @@
|
|
|
35914
36327
|
return (_collapseState$state = collapseState[state]) === null || _collapseState$state === void 0 ? void 0 : _collapseState$state.call(collapseState);
|
|
35915
36328
|
};
|
|
35916
36329
|
|
|
35917
|
-
var _useCollapse =
|
|
36330
|
+
var _useCollapse = useCollapse({
|
|
35918
36331
|
isExpanded: isOpenState,
|
|
35919
36332
|
onTransitionStateChange: function onTransitionStateChange(state) {
|
|
35920
36333
|
return !disabled && triggerHandler(state);
|