@teamturing/react-kit 1.2.6 → 1.3.0
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/core/GradientText/index.d.ts +28 -34
- package/dist/core/StyledIcon/index.d.ts +1 -0
- package/dist/hook/useDevice.d.ts +29 -0
- package/dist/hook/useOutsideClick.d.ts +9 -0
- package/dist/hook/useProvidedOrCreatedRef.d.ts +6 -0
- package/dist/hook/useResize.d.ts +3 -0
- package/dist/hook/useToggleHandler.d.ts +11 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +532 -18
- package/esm/_virtual/_commonjsHelpers.js +3 -1
- package/esm/hook/useDevice.js +83 -0
- package/esm/hook/useOutsideClick.js +23 -0
- package/esm/hook/useProvidedOrCreatedRef.js +11 -0
- package/esm/hook/useResize.js +18 -0
- package/esm/hook/useToggleHandler.js +24 -0
- package/esm/index.js +6 -0
- package/esm/node_modules/lodash.debounce/index.js +363 -0
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var styled = require('styled-components');
|
|
5
5
|
|
|
6
|
-
function
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
7
10
|
var n = Object.create(null);
|
|
8
11
|
if (e) {
|
|
9
12
|
Object.keys(e).forEach(function (k) {
|
|
@@ -20,7 +23,8 @@ function _interopNamespaceDefault(e) {
|
|
|
20
23
|
return Object.freeze(n);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
var React__namespace = /*#__PURE__*/
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
24
28
|
|
|
25
29
|
const gray = {
|
|
26
30
|
gray50: '#F9FAFB',
|
|
@@ -566,6 +570,8 @@ const typography$1 = {
|
|
|
566
570
|
}
|
|
567
571
|
};
|
|
568
572
|
|
|
573
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
574
|
+
|
|
569
575
|
function getDefaultExportFromCjs (x) {
|
|
570
576
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
571
577
|
}
|
|
@@ -1631,7 +1637,7 @@ const spin = styled.keyframes`
|
|
|
1631
1637
|
transform: rotate(360deg);
|
|
1632
1638
|
}
|
|
1633
1639
|
`;
|
|
1634
|
-
const Spinner =
|
|
1640
|
+
const Spinner = styled__default.default(SvgProgressGradient)`
|
|
1635
1641
|
animation: ${spin} 1000ms infinite steps(8, end);
|
|
1636
1642
|
`;
|
|
1637
1643
|
Spinner.defaultProps = {
|
|
@@ -1662,12 +1668,12 @@ const wordBreak = system({
|
|
|
1662
1668
|
}
|
|
1663
1669
|
});
|
|
1664
1670
|
|
|
1665
|
-
const View =
|
|
1671
|
+
const View = styled__default.default.div`
|
|
1666
1672
|
${compose(layout, color, flexbox, background, border, position, shadow)}
|
|
1667
1673
|
${sx}
|
|
1668
1674
|
`;
|
|
1669
1675
|
|
|
1670
|
-
const UnstyledButton =
|
|
1676
|
+
const UnstyledButton = styled__default.default.button`
|
|
1671
1677
|
background: none;
|
|
1672
1678
|
border: 0;
|
|
1673
1679
|
padding: 0;
|
|
@@ -1694,7 +1700,7 @@ var hasRequiredReactJsxRuntime_production_min;
|
|
|
1694
1700
|
function requireReactJsxRuntime_production_min() {
|
|
1695
1701
|
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
1696
1702
|
hasRequiredReactJsxRuntime_production_min = 1;
|
|
1697
|
-
var f =
|
|
1703
|
+
var f = React__namespace.default,
|
|
1698
1704
|
k = Symbol.for("react.element"),
|
|
1699
1705
|
l = Symbol.for("react.fragment"),
|
|
1700
1706
|
m = Object.prototype.hasOwnProperty,
|
|
@@ -1748,7 +1754,7 @@ function requireReactJsxRuntime_development() {
|
|
|
1748
1754
|
if (process.env.NODE_ENV !== "production") {
|
|
1749
1755
|
(function () {
|
|
1750
1756
|
|
|
1751
|
-
var React
|
|
1757
|
+
var React = React__namespace.default;
|
|
1752
1758
|
|
|
1753
1759
|
// ATTENTION
|
|
1754
1760
|
// When adding new symbols to this file,
|
|
@@ -1779,7 +1785,7 @@ function requireReactJsxRuntime_development() {
|
|
|
1779
1785
|
}
|
|
1780
1786
|
return null;
|
|
1781
1787
|
}
|
|
1782
|
-
var ReactSharedInternals = React
|
|
1788
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
1783
1789
|
function error(format) {
|
|
1784
1790
|
{
|
|
1785
1791
|
{
|
|
@@ -2925,7 +2931,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
|
|
|
2925
2931
|
}) : null]
|
|
2926
2932
|
});
|
|
2927
2933
|
});
|
|
2928
|
-
const BaseButton =
|
|
2934
|
+
const BaseButton = styled__default.default(UnstyledButton)(({
|
|
2929
2935
|
$loading,
|
|
2930
2936
|
$disabled,
|
|
2931
2937
|
fillWidth
|
|
@@ -3173,7 +3179,7 @@ const BaseButton = styled(UnstyledButton)(({
|
|
|
3173
3179
|
}
|
|
3174
3180
|
}
|
|
3175
3181
|
}));
|
|
3176
|
-
const BaseSpinner =
|
|
3182
|
+
const BaseSpinner = styled__default.default(Spinner)(variant({
|
|
3177
3183
|
prop: 'size',
|
|
3178
3184
|
variants: {
|
|
3179
3185
|
l: {
|
|
@@ -3228,7 +3234,7 @@ const Chip = ({
|
|
|
3228
3234
|
trailingIcon: TrailingIcon,
|
|
3229
3235
|
children: [LeadingIcon ? /*#__PURE__*/jsxRuntimeExports.jsx(LeadingIcon, {}) : null, children, TrailingIcon ? /*#__PURE__*/jsxRuntimeExports.jsx(TrailingIcon, {}) : null]
|
|
3230
3236
|
});
|
|
3231
|
-
const BaseChip =
|
|
3237
|
+
const BaseChip = styled__default.default.span({
|
|
3232
3238
|
position: 'relative',
|
|
3233
3239
|
width: 'fit-content',
|
|
3234
3240
|
borderRadius: radii.full,
|
|
@@ -3384,7 +3390,7 @@ const BaseChip = styled.span({
|
|
|
3384
3390
|
}
|
|
3385
3391
|
}), sx);
|
|
3386
3392
|
|
|
3387
|
-
const Text =
|
|
3393
|
+
const Text = styled__default.default.span({
|
|
3388
3394
|
'display': 'block',
|
|
3389
3395
|
'whiteSpace': 'pre-wrap',
|
|
3390
3396
|
'& > span': {
|
|
@@ -3424,7 +3430,7 @@ Text.defaultProps = {
|
|
|
3424
3430
|
color: 'text/neutral'
|
|
3425
3431
|
};
|
|
3426
3432
|
|
|
3427
|
-
const GradientText =
|
|
3433
|
+
const GradientText = styled__default.default(Text)`
|
|
3428
3434
|
background: ${({
|
|
3429
3435
|
theme
|
|
3430
3436
|
}) => `linear-gradient(${theme.gradients['text/accent']})`};
|
|
@@ -3463,7 +3469,7 @@ const Grid = /*#__PURE__*/React.forwardRef(({
|
|
|
3463
3469
|
children: children
|
|
3464
3470
|
});
|
|
3465
3471
|
});
|
|
3466
|
-
const BaseGrid =
|
|
3472
|
+
const BaseGrid = styled__default.default(View)({
|
|
3467
3473
|
display: 'flex',
|
|
3468
3474
|
flexDirection: 'row'
|
|
3469
3475
|
}, variant({
|
|
@@ -3567,7 +3573,7 @@ const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
|
3567
3573
|
})
|
|
3568
3574
|
});
|
|
3569
3575
|
});
|
|
3570
|
-
const BaseIconButton =
|
|
3576
|
+
const BaseIconButton = styled__default.default(UnstyledButton)(({
|
|
3571
3577
|
$loading,
|
|
3572
3578
|
$disabled
|
|
3573
3579
|
}) => ({
|
|
@@ -3768,7 +3774,7 @@ const IconToggleButton = ({
|
|
|
3768
3774
|
children: /*#__PURE__*/jsxRuntimeExports.jsx(Icon, {})
|
|
3769
3775
|
});
|
|
3770
3776
|
};
|
|
3771
|
-
const BaseIconToggleButton =
|
|
3777
|
+
const BaseIconToggleButton = styled__default.default(UnstyledButton)(({
|
|
3772
3778
|
$disabled
|
|
3773
3779
|
}) => ({
|
|
3774
3780
|
'position': 'relative',
|
|
@@ -3855,7 +3861,7 @@ const ItemList = ({
|
|
|
3855
3861
|
});
|
|
3856
3862
|
};
|
|
3857
3863
|
|
|
3858
|
-
const Space =
|
|
3864
|
+
const Space = styled__default.default.div`
|
|
3859
3865
|
width: inherit;
|
|
3860
3866
|
${space};
|
|
3861
3867
|
${sx}
|
|
@@ -3875,7 +3881,7 @@ const Stack = /*#__PURE__*/React.forwardRef(({
|
|
|
3875
3881
|
...props,
|
|
3876
3882
|
children: children
|
|
3877
3883
|
}));
|
|
3878
|
-
const BaseStack =
|
|
3884
|
+
const BaseStack = styled__default.default(View)({
|
|
3879
3885
|
display: 'flex',
|
|
3880
3886
|
flexDirection: 'row',
|
|
3881
3887
|
flexWrap: 'wrap'
|
|
@@ -3931,6 +3937,508 @@ const StyledIcon = ({
|
|
|
3931
3937
|
children: /*#__PURE__*/jsxRuntimeExports.jsx(Icon, {})
|
|
3932
3938
|
});
|
|
3933
3939
|
|
|
3940
|
+
/**
|
|
3941
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
3942
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
3943
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
3944
|
+
* Released under MIT license <https://lodash.com/license>
|
|
3945
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
3946
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
3947
|
+
*/
|
|
3948
|
+
|
|
3949
|
+
/** Used as the `TypeError` message for "Functions" methods. */
|
|
3950
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
3951
|
+
|
|
3952
|
+
/** Used as references for various `Number` constants. */
|
|
3953
|
+
var NAN = 0 / 0;
|
|
3954
|
+
|
|
3955
|
+
/** `Object#toString` result references. */
|
|
3956
|
+
var symbolTag = '[object Symbol]';
|
|
3957
|
+
|
|
3958
|
+
/** Used to match leading and trailing whitespace. */
|
|
3959
|
+
var reTrim = /^\s+|\s+$/g;
|
|
3960
|
+
|
|
3961
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
3962
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
3963
|
+
|
|
3964
|
+
/** Used to detect binary string values. */
|
|
3965
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
3966
|
+
|
|
3967
|
+
/** Used to detect octal string values. */
|
|
3968
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
3969
|
+
|
|
3970
|
+
/** Built-in method references without a dependency on `root`. */
|
|
3971
|
+
var freeParseInt = parseInt;
|
|
3972
|
+
|
|
3973
|
+
/** Detect free variable `global` from Node.js. */
|
|
3974
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
3975
|
+
|
|
3976
|
+
/** Detect free variable `self`. */
|
|
3977
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
3978
|
+
|
|
3979
|
+
/** Used as a reference to the global object. */
|
|
3980
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
3981
|
+
|
|
3982
|
+
/** Used for built-in method references. */
|
|
3983
|
+
var objectProto = Object.prototype;
|
|
3984
|
+
|
|
3985
|
+
/**
|
|
3986
|
+
* Used to resolve the
|
|
3987
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
3988
|
+
* of values.
|
|
3989
|
+
*/
|
|
3990
|
+
var objectToString = objectProto.toString;
|
|
3991
|
+
|
|
3992
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
3993
|
+
var nativeMax = Math.max,
|
|
3994
|
+
nativeMin = Math.min;
|
|
3995
|
+
|
|
3996
|
+
/**
|
|
3997
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
3998
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
3999
|
+
*
|
|
4000
|
+
* @static
|
|
4001
|
+
* @memberOf _
|
|
4002
|
+
* @since 2.4.0
|
|
4003
|
+
* @category Date
|
|
4004
|
+
* @returns {number} Returns the timestamp.
|
|
4005
|
+
* @example
|
|
4006
|
+
*
|
|
4007
|
+
* _.defer(function(stamp) {
|
|
4008
|
+
* console.log(_.now() - stamp);
|
|
4009
|
+
* }, _.now());
|
|
4010
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
4011
|
+
*/
|
|
4012
|
+
var now = function () {
|
|
4013
|
+
return root.Date.now();
|
|
4014
|
+
};
|
|
4015
|
+
|
|
4016
|
+
/**
|
|
4017
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
4018
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
4019
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
4020
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
4021
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
4022
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
4023
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
4024
|
+
* calls to the debounced function return the result of the last `func`
|
|
4025
|
+
* invocation.
|
|
4026
|
+
*
|
|
4027
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
4028
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
4029
|
+
* is invoked more than once during the `wait` timeout.
|
|
4030
|
+
*
|
|
4031
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
4032
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
4033
|
+
*
|
|
4034
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
4035
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
4036
|
+
*
|
|
4037
|
+
* @static
|
|
4038
|
+
* @memberOf _
|
|
4039
|
+
* @since 0.1.0
|
|
4040
|
+
* @category Function
|
|
4041
|
+
* @param {Function} func The function to debounce.
|
|
4042
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
4043
|
+
* @param {Object} [options={}] The options object.
|
|
4044
|
+
* @param {boolean} [options.leading=false]
|
|
4045
|
+
* Specify invoking on the leading edge of the timeout.
|
|
4046
|
+
* @param {number} [options.maxWait]
|
|
4047
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
4048
|
+
* @param {boolean} [options.trailing=true]
|
|
4049
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
4050
|
+
* @returns {Function} Returns the new debounced function.
|
|
4051
|
+
* @example
|
|
4052
|
+
*
|
|
4053
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
4054
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
4055
|
+
*
|
|
4056
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
4057
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
4058
|
+
* 'leading': true,
|
|
4059
|
+
* 'trailing': false
|
|
4060
|
+
* }));
|
|
4061
|
+
*
|
|
4062
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
4063
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
4064
|
+
* var source = new EventSource('/stream');
|
|
4065
|
+
* jQuery(source).on('message', debounced);
|
|
4066
|
+
*
|
|
4067
|
+
* // Cancel the trailing debounced invocation.
|
|
4068
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
4069
|
+
*/
|
|
4070
|
+
function debounce(func, wait, options) {
|
|
4071
|
+
var lastArgs,
|
|
4072
|
+
lastThis,
|
|
4073
|
+
maxWait,
|
|
4074
|
+
result,
|
|
4075
|
+
timerId,
|
|
4076
|
+
lastCallTime,
|
|
4077
|
+
lastInvokeTime = 0,
|
|
4078
|
+
leading = false,
|
|
4079
|
+
maxing = false,
|
|
4080
|
+
trailing = true;
|
|
4081
|
+
if (typeof func != 'function') {
|
|
4082
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
4083
|
+
}
|
|
4084
|
+
wait = toNumber(wait) || 0;
|
|
4085
|
+
if (isObject(options)) {
|
|
4086
|
+
leading = !!options.leading;
|
|
4087
|
+
maxing = 'maxWait' in options;
|
|
4088
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
4089
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
4090
|
+
}
|
|
4091
|
+
function invokeFunc(time) {
|
|
4092
|
+
var args = lastArgs,
|
|
4093
|
+
thisArg = lastThis;
|
|
4094
|
+
lastArgs = lastThis = undefined;
|
|
4095
|
+
lastInvokeTime = time;
|
|
4096
|
+
result = func.apply(thisArg, args);
|
|
4097
|
+
return result;
|
|
4098
|
+
}
|
|
4099
|
+
function leadingEdge(time) {
|
|
4100
|
+
// Reset any `maxWait` timer.
|
|
4101
|
+
lastInvokeTime = time;
|
|
4102
|
+
// Start the timer for the trailing edge.
|
|
4103
|
+
timerId = setTimeout(timerExpired, wait);
|
|
4104
|
+
// Invoke the leading edge.
|
|
4105
|
+
return leading ? invokeFunc(time) : result;
|
|
4106
|
+
}
|
|
4107
|
+
function remainingWait(time) {
|
|
4108
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
4109
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
4110
|
+
result = wait - timeSinceLastCall;
|
|
4111
|
+
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
|
4112
|
+
}
|
|
4113
|
+
function shouldInvoke(time) {
|
|
4114
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
4115
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
4116
|
+
|
|
4117
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
4118
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
4119
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
4120
|
+
return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
4121
|
+
}
|
|
4122
|
+
function timerExpired() {
|
|
4123
|
+
var time = now();
|
|
4124
|
+
if (shouldInvoke(time)) {
|
|
4125
|
+
return trailingEdge(time);
|
|
4126
|
+
}
|
|
4127
|
+
// Restart the timer.
|
|
4128
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
4129
|
+
}
|
|
4130
|
+
function trailingEdge(time) {
|
|
4131
|
+
timerId = undefined;
|
|
4132
|
+
|
|
4133
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
4134
|
+
// debounced at least once.
|
|
4135
|
+
if (trailing && lastArgs) {
|
|
4136
|
+
return invokeFunc(time);
|
|
4137
|
+
}
|
|
4138
|
+
lastArgs = lastThis = undefined;
|
|
4139
|
+
return result;
|
|
4140
|
+
}
|
|
4141
|
+
function cancel() {
|
|
4142
|
+
if (timerId !== undefined) {
|
|
4143
|
+
clearTimeout(timerId);
|
|
4144
|
+
}
|
|
4145
|
+
lastInvokeTime = 0;
|
|
4146
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
4147
|
+
}
|
|
4148
|
+
function flush() {
|
|
4149
|
+
return timerId === undefined ? result : trailingEdge(now());
|
|
4150
|
+
}
|
|
4151
|
+
function debounced() {
|
|
4152
|
+
var time = now(),
|
|
4153
|
+
isInvoking = shouldInvoke(time);
|
|
4154
|
+
lastArgs = arguments;
|
|
4155
|
+
lastThis = this;
|
|
4156
|
+
lastCallTime = time;
|
|
4157
|
+
if (isInvoking) {
|
|
4158
|
+
if (timerId === undefined) {
|
|
4159
|
+
return leadingEdge(lastCallTime);
|
|
4160
|
+
}
|
|
4161
|
+
if (maxing) {
|
|
4162
|
+
// Handle invocations in a tight loop.
|
|
4163
|
+
timerId = setTimeout(timerExpired, wait);
|
|
4164
|
+
return invokeFunc(lastCallTime);
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
if (timerId === undefined) {
|
|
4168
|
+
timerId = setTimeout(timerExpired, wait);
|
|
4169
|
+
}
|
|
4170
|
+
return result;
|
|
4171
|
+
}
|
|
4172
|
+
debounced.cancel = cancel;
|
|
4173
|
+
debounced.flush = flush;
|
|
4174
|
+
return debounced;
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
/**
|
|
4178
|
+
* Checks if `value` is the
|
|
4179
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
4180
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
4181
|
+
*
|
|
4182
|
+
* @static
|
|
4183
|
+
* @memberOf _
|
|
4184
|
+
* @since 0.1.0
|
|
4185
|
+
* @category Lang
|
|
4186
|
+
* @param {*} value The value to check.
|
|
4187
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
4188
|
+
* @example
|
|
4189
|
+
*
|
|
4190
|
+
* _.isObject({});
|
|
4191
|
+
* // => true
|
|
4192
|
+
*
|
|
4193
|
+
* _.isObject([1, 2, 3]);
|
|
4194
|
+
* // => true
|
|
4195
|
+
*
|
|
4196
|
+
* _.isObject(_.noop);
|
|
4197
|
+
* // => true
|
|
4198
|
+
*
|
|
4199
|
+
* _.isObject(null);
|
|
4200
|
+
* // => false
|
|
4201
|
+
*/
|
|
4202
|
+
function isObject(value) {
|
|
4203
|
+
var type = typeof value;
|
|
4204
|
+
return !!value && (type == 'object' || type == 'function');
|
|
4205
|
+
}
|
|
4206
|
+
|
|
4207
|
+
/**
|
|
4208
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
4209
|
+
* and has a `typeof` result of "object".
|
|
4210
|
+
*
|
|
4211
|
+
* @static
|
|
4212
|
+
* @memberOf _
|
|
4213
|
+
* @since 4.0.0
|
|
4214
|
+
* @category Lang
|
|
4215
|
+
* @param {*} value The value to check.
|
|
4216
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
4217
|
+
* @example
|
|
4218
|
+
*
|
|
4219
|
+
* _.isObjectLike({});
|
|
4220
|
+
* // => true
|
|
4221
|
+
*
|
|
4222
|
+
* _.isObjectLike([1, 2, 3]);
|
|
4223
|
+
* // => true
|
|
4224
|
+
*
|
|
4225
|
+
* _.isObjectLike(_.noop);
|
|
4226
|
+
* // => false
|
|
4227
|
+
*
|
|
4228
|
+
* _.isObjectLike(null);
|
|
4229
|
+
* // => false
|
|
4230
|
+
*/
|
|
4231
|
+
function isObjectLike(value) {
|
|
4232
|
+
return !!value && typeof value == 'object';
|
|
4233
|
+
}
|
|
4234
|
+
|
|
4235
|
+
/**
|
|
4236
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
4237
|
+
*
|
|
4238
|
+
* @static
|
|
4239
|
+
* @memberOf _
|
|
4240
|
+
* @since 4.0.0
|
|
4241
|
+
* @category Lang
|
|
4242
|
+
* @param {*} value The value to check.
|
|
4243
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
4244
|
+
* @example
|
|
4245
|
+
*
|
|
4246
|
+
* _.isSymbol(Symbol.iterator);
|
|
4247
|
+
* // => true
|
|
4248
|
+
*
|
|
4249
|
+
* _.isSymbol('abc');
|
|
4250
|
+
* // => false
|
|
4251
|
+
*/
|
|
4252
|
+
function isSymbol(value) {
|
|
4253
|
+
return typeof value == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
/**
|
|
4257
|
+
* Converts `value` to a number.
|
|
4258
|
+
*
|
|
4259
|
+
* @static
|
|
4260
|
+
* @memberOf _
|
|
4261
|
+
* @since 4.0.0
|
|
4262
|
+
* @category Lang
|
|
4263
|
+
* @param {*} value The value to process.
|
|
4264
|
+
* @returns {number} Returns the number.
|
|
4265
|
+
* @example
|
|
4266
|
+
*
|
|
4267
|
+
* _.toNumber(3.2);
|
|
4268
|
+
* // => 3.2
|
|
4269
|
+
*
|
|
4270
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
4271
|
+
* // => 5e-324
|
|
4272
|
+
*
|
|
4273
|
+
* _.toNumber(Infinity);
|
|
4274
|
+
* // => Infinity
|
|
4275
|
+
*
|
|
4276
|
+
* _.toNumber('3.2');
|
|
4277
|
+
* // => 3.2
|
|
4278
|
+
*/
|
|
4279
|
+
function toNumber(value) {
|
|
4280
|
+
if (typeof value == 'number') {
|
|
4281
|
+
return value;
|
|
4282
|
+
}
|
|
4283
|
+
if (isSymbol(value)) {
|
|
4284
|
+
return NAN;
|
|
4285
|
+
}
|
|
4286
|
+
if (isObject(value)) {
|
|
4287
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
4288
|
+
value = isObject(other) ? other + '' : other;
|
|
4289
|
+
}
|
|
4290
|
+
if (typeof value != 'string') {
|
|
4291
|
+
return value === 0 ? value : +value;
|
|
4292
|
+
}
|
|
4293
|
+
value = value.replace(reTrim, '');
|
|
4294
|
+
var isBinary = reIsBinary.test(value);
|
|
4295
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
4296
|
+
}
|
|
4297
|
+
var lodash_debounce = debounce;
|
|
4298
|
+
var debounce$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_debounce);
|
|
4299
|
+
|
|
4300
|
+
const useResize = resizeCallback => {
|
|
4301
|
+
const handleResize = React.useCallback(() => resizeCallback?.(), []);
|
|
4302
|
+
React.useEffect(() => {
|
|
4303
|
+
handleResize();
|
|
4304
|
+
}, []);
|
|
4305
|
+
React.useEffect(() => {
|
|
4306
|
+
if (window) {
|
|
4307
|
+
const debouncedHandleResize = debounce$1(handleResize, 150);
|
|
4308
|
+
window.addEventListener('resize', debouncedHandleResize);
|
|
4309
|
+
return () => window.removeEventListener('resize', debouncedHandleResize);
|
|
4310
|
+
}
|
|
4311
|
+
}, []);
|
|
4312
|
+
};
|
|
4313
|
+
|
|
4314
|
+
var MobileOS = /*#__PURE__*/function (MobileOS) {
|
|
4315
|
+
MobileOS["Android"] = "android";
|
|
4316
|
+
MobileOS["iOS"] = "ios";
|
|
4317
|
+
MobileOS["Unknown"] = "unknown";
|
|
4318
|
+
MobileOS["WindowsPhone"] = "Windows Phone";
|
|
4319
|
+
return MobileOS;
|
|
4320
|
+
}(MobileOS || {});
|
|
4321
|
+
var DesktopOS = /*#__PURE__*/function (DesktopOS) {
|
|
4322
|
+
DesktopOS["Linux"] = "linux";
|
|
4323
|
+
DesktopOS["MacOS"] = "mac_os";
|
|
4324
|
+
DesktopOS["Unix"] = "unix";
|
|
4325
|
+
DesktopOS["Unknown"] = "unknown";
|
|
4326
|
+
DesktopOS["Windows"] = "windows";
|
|
4327
|
+
return DesktopOS;
|
|
4328
|
+
}(DesktopOS || {});
|
|
4329
|
+
const useDevice = () => {
|
|
4330
|
+
const [deviceState, setDeviceState] = React.useState();
|
|
4331
|
+
const handleResize = () => {
|
|
4332
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera || undefined;
|
|
4333
|
+
const isMobileDevice = () => {
|
|
4334
|
+
const regexs = [/(Android)(.+)(Mobile)/i, /BlackBerry/i, /iPhone|iPod/i, /Opera Mini/i, /IEMobile/i];
|
|
4335
|
+
return regexs.some(b => userAgent.match(b));
|
|
4336
|
+
};
|
|
4337
|
+
const isTabletDevice = () => {
|
|
4338
|
+
const regex = /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/;
|
|
4339
|
+
return regex.test(userAgent.toLowerCase());
|
|
4340
|
+
};
|
|
4341
|
+
const isDesktopDevice = () => !isMobileDevice() && !isTabletDevice();
|
|
4342
|
+
const isDesktop = isDesktopDevice();
|
|
4343
|
+
const isMobile = isMobileDevice();
|
|
4344
|
+
const isTablet = isTabletDevice();
|
|
4345
|
+
const getMobileOS = () => {
|
|
4346
|
+
if (isMobileDevice()) {
|
|
4347
|
+
if (/windows phone/i.test(userAgent)) return MobileOS.WindowsPhone;else if (/android/i.test(userAgent)) return MobileOS.Android;else if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) return MobileOS.iOS;
|
|
4348
|
+
return MobileOS.Unknown;
|
|
4349
|
+
} else return undefined;
|
|
4350
|
+
};
|
|
4351
|
+
const getDesktopOS = () => {
|
|
4352
|
+
if (isDesktopDevice()) {
|
|
4353
|
+
if (userAgent.indexOf('Win') !== -1) return DesktopOS.Windows;else if (userAgent.indexOf('Mac') !== -1) return DesktopOS.MacOS;else if (userAgent.indexOf('X11') !== -1) return DesktopOS.Unix;else if (userAgent.indexOf('Linux') !== -1) return DesktopOS.Linux;
|
|
4354
|
+
return DesktopOS.Unknown;
|
|
4355
|
+
} else return undefined;
|
|
4356
|
+
};
|
|
4357
|
+
const getDeviceOS = () => getMobileOS() ?? getDesktopOS();
|
|
4358
|
+
const mobileOS = getMobileOS();
|
|
4359
|
+
const isAndroidDevice = getDeviceOS() === MobileOS.Android;
|
|
4360
|
+
const isAppleDevice = getDeviceOS() === MobileOS.iOS || getDeviceOS() === DesktopOS.MacOS;
|
|
4361
|
+
const isUnknownMobileDevice = getDeviceOS() === MobileOS.Unknown;
|
|
4362
|
+
const desktopOS = getDesktopOS();
|
|
4363
|
+
const isWindowsDesktop = getDeviceOS() === DesktopOS.Windows;
|
|
4364
|
+
const isLinuxOrUnixDesktop = getDeviceOS() === DesktopOS.Linux || getDeviceOS() === DesktopOS.Unix;
|
|
4365
|
+
const supportedScreenOrientation = (screen?.orientation || {}).type ?? screen.mozOrientation ?? screen.msOrientation;
|
|
4366
|
+
const safariScreenOrientation = !screen?.orientation && matchMedia('(orientation: portrait)').matches ? 'portrait-primary' : 'landscape-primary';
|
|
4367
|
+
const initialScreenOrientation = supportedScreenOrientation ?? safariScreenOrientation ?? 'portrait-primary';
|
|
4368
|
+
let screenOrientation = initialScreenOrientation;
|
|
4369
|
+
if (screen.orientation) {
|
|
4370
|
+
screen.orientation.addEventListener('change', ev => screenOrientation = (ev.target ?? {}).type);
|
|
4371
|
+
}
|
|
4372
|
+
const isLandscapeOrientation = () => ['landscape-primary', 'landscape-secondary'].includes(screenOrientation);
|
|
4373
|
+
const isPortraitOrientation = () => ['portrait-primary', 'portrait-secondary'].includes(screenOrientation);
|
|
4374
|
+
setDeviceState({
|
|
4375
|
+
isDesktop,
|
|
4376
|
+
desktopOS,
|
|
4377
|
+
isWindowsDesktop,
|
|
4378
|
+
isLinuxOrUnixDesktop,
|
|
4379
|
+
isMobile,
|
|
4380
|
+
mobileOS,
|
|
4381
|
+
isAndroidDevice,
|
|
4382
|
+
isAppleDevice,
|
|
4383
|
+
isUnknownMobileDevice,
|
|
4384
|
+
isTablet,
|
|
4385
|
+
isLandscapeOrientation,
|
|
4386
|
+
isPortraitOrientation
|
|
4387
|
+
});
|
|
4388
|
+
};
|
|
4389
|
+
useResize(handleResize);
|
|
4390
|
+
return deviceState || {};
|
|
4391
|
+
};
|
|
4392
|
+
|
|
4393
|
+
/**
|
|
4394
|
+
* 특정 컴포넌트을 제외한 바깥쪽을 클릭했을 때를 핸들링하기 위한 훅입니다.
|
|
4395
|
+
*/
|
|
4396
|
+
const useOutsideClick = ({
|
|
4397
|
+
containerRef,
|
|
4398
|
+
onOutsideClick
|
|
4399
|
+
}) => {
|
|
4400
|
+
const handleClick = e => {
|
|
4401
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
4402
|
+
onOutsideClick(e);
|
|
4403
|
+
}
|
|
4404
|
+
};
|
|
4405
|
+
React.useEffect(() => {
|
|
4406
|
+
document.addEventListener('click', handleClick);
|
|
4407
|
+
return () => {
|
|
4408
|
+
document.removeEventListener('click', handleClick);
|
|
4409
|
+
};
|
|
4410
|
+
});
|
|
4411
|
+
};
|
|
4412
|
+
|
|
4413
|
+
/**
|
|
4414
|
+
* 제공된 `ref`가 없는 경우 새로운 `ref`를 만들어 사용하고, 있는 경우 제공된 ref를 사용할 수 있는 훅입니다.
|
|
4415
|
+
*/
|
|
4416
|
+
const useProvidedOrCreatedRef = providedRef => {
|
|
4417
|
+
const createdRef = React.useRef(null);
|
|
4418
|
+
return providedRef ?? createdRef;
|
|
4419
|
+
};
|
|
4420
|
+
|
|
4421
|
+
const useToggleHandler = ({
|
|
4422
|
+
initialState = false
|
|
4423
|
+
}) => {
|
|
4424
|
+
const [state, setState] = React.useState(initialState);
|
|
4425
|
+
const on = () => {
|
|
4426
|
+
setState(true);
|
|
4427
|
+
};
|
|
4428
|
+
const off = () => {
|
|
4429
|
+
setState(false);
|
|
4430
|
+
};
|
|
4431
|
+
const toggle = React.useCallback(() => {
|
|
4432
|
+
setState(prev => !prev);
|
|
4433
|
+
}, []);
|
|
4434
|
+
return {
|
|
4435
|
+
state,
|
|
4436
|
+
on,
|
|
4437
|
+
off,
|
|
4438
|
+
toggle
|
|
4439
|
+
};
|
|
4440
|
+
};
|
|
4441
|
+
|
|
3934
4442
|
exports.Button = Button;
|
|
3935
4443
|
exports.Chip = Chip;
|
|
3936
4444
|
exports.GradientText = GradientText;
|
|
@@ -3943,4 +4451,10 @@ exports.Spinner = Spinner;
|
|
|
3943
4451
|
exports.Stack = index;
|
|
3944
4452
|
exports.StyledIcon = StyledIcon;
|
|
3945
4453
|
exports.Text = Text;
|
|
4454
|
+
exports.UnstyledButton = UnstyledButton;
|
|
3946
4455
|
exports.View = View;
|
|
4456
|
+
exports.useDevice = useDevice;
|
|
4457
|
+
exports.useOutsideClick = useOutsideClick;
|
|
4458
|
+
exports.useProvidedOrCreatedRef = useProvidedOrCreatedRef;
|
|
4459
|
+
exports.useResize = useResize;
|
|
4460
|
+
exports.useToggleHandler = useToggleHandler;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
+
|
|
1
3
|
function getDefaultExportFromCjs (x) {
|
|
2
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3
5
|
}
|
|
4
6
|
|
|
5
|
-
export { getDefaultExportFromCjs };
|
|
7
|
+
export { commonjsGlobal, getDefaultExportFromCjs };
|