@mantine/nprogress 5.0.0-alpha.3 → 5.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cjs/NProgress.js +29 -28
- package/cjs/NProgress.js.map +1 -1
- package/cjs/NavigationProgress.js +125 -0
- package/cjs/NavigationProgress.js.map +1 -0
- package/cjs/events.js +15 -58
- package/cjs/events.js.map +1 -1
- package/cjs/index.js +8 -8
- package/cjs/mantine-nprogress/src/NavigationProgress.js +126 -0
- package/cjs/mantine-nprogress/src/NavigationProgress.js.map +1 -0
- package/cjs/mantine-nprogress/src/events.js +23 -0
- package/cjs/mantine-nprogress/src/events.js.map +1 -0
- package/cjs/mantine-nprogress/src/index.js +17 -0
- package/cjs/mantine-nprogress/src/index.js.map +1 -0
- package/cjs/mantine-styles/esm/theme/utils/get-default-z-index/get-default-z-index.js +17 -0
- package/cjs/mantine-styles/esm/theme/utils/get-default-z-index/get-default-z-index.js.map +1 -0
- package/esm/NProgress.js +30 -29
- package/esm/NProgress.js.map +1 -1
- package/esm/NavigationProgress.js +117 -0
- package/esm/NavigationProgress.js.map +1 -0
- package/esm/events.js +9 -51
- package/esm/events.js.map +1 -1
- package/esm/index.js +2 -2
- package/esm/mantine-nprogress/src/NavigationProgress.js +118 -0
- package/esm/mantine-nprogress/src/NavigationProgress.js.map +1 -0
- package/esm/mantine-nprogress/src/events.js +12 -0
- package/esm/mantine-nprogress/src/events.js.map +1 -0
- package/esm/mantine-nprogress/src/index.js +3 -0
- package/esm/mantine-nprogress/src/index.js.map +1 -0
- package/esm/mantine-styles/esm/theme/utils/get-default-z-index/get-default-z-index.js +13 -0
- package/esm/mantine-styles/esm/theme/utils/get-default-z-index/get-default-z-index.js.map +1 -0
- package/lib/NProgress.d.ts +2 -2
- package/lib/NProgress.d.ts.map +1 -1
- package/lib/NavigationProgress.d.ts +28 -0
- package/lib/NavigationProgress.d.ts.map +1 -0
- package/lib/events.d.ts +14 -26
- package/lib/events.d.ts.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
package/cjs/NProgress.js
CHANGED
|
@@ -25,14 +25,16 @@ function NProgress({
|
|
|
25
25
|
onFinish,
|
|
26
26
|
autoReset = false,
|
|
27
27
|
withinPortal = true,
|
|
28
|
-
zIndex = styles.getDefaultZIndex("
|
|
28
|
+
zIndex = styles.getDefaultZIndex("max")
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
30
|
+
const theme = core.useMantineTheme();
|
|
31
|
+
const shouldReduceMotion = hooks.useReducedMotion();
|
|
32
|
+
const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
31
33
|
const [_progress, setProgress] = React.useState(defaultProgress);
|
|
32
34
|
const [mounted, setMounted] = React.useState(true);
|
|
35
|
+
const [unmountProgress, setUnmountProgress] = React.useState(false);
|
|
33
36
|
const resetRef = React.useRef();
|
|
34
37
|
const unmountRef = React.useRef();
|
|
35
|
-
const unmountProgressRef = React.useRef(false);
|
|
36
38
|
const interval = hooks.useInterval(() => {
|
|
37
39
|
setProgress((amount) => {
|
|
38
40
|
let next = 0;
|
|
@@ -48,17 +50,6 @@ function NProgress({
|
|
|
48
50
|
return amount + next;
|
|
49
51
|
});
|
|
50
52
|
}, stepIntervalTime);
|
|
51
|
-
const cancelUnmount = () => {
|
|
52
|
-
if (unmountRef.current) {
|
|
53
|
-
window.clearTimeout(unmountRef.current);
|
|
54
|
-
unmountRef.current = null;
|
|
55
|
-
}
|
|
56
|
-
if (resetRef.current) {
|
|
57
|
-
window.clearTimeout(resetRef.current);
|
|
58
|
-
resetRef.current = null;
|
|
59
|
-
}
|
|
60
|
-
setMounted(true);
|
|
61
|
-
};
|
|
62
53
|
const set = (value) => setProgress(value);
|
|
63
54
|
const add = (value) => setProgress((c) => Math.min(c + value, 100));
|
|
64
55
|
const decrease = (value) => setProgress((c) => Math.max(c - value, 0));
|
|
@@ -68,10 +59,10 @@ function NProgress({
|
|
|
68
59
|
};
|
|
69
60
|
const stop = () => interval.stop();
|
|
70
61
|
const reset = () => {
|
|
71
|
-
|
|
62
|
+
setUnmountProgress(true);
|
|
72
63
|
stop();
|
|
73
64
|
setProgress(0);
|
|
74
|
-
|
|
65
|
+
window.setTimeout(() => setUnmountProgress(false), 0);
|
|
75
66
|
};
|
|
76
67
|
const ctx = {
|
|
77
68
|
set,
|
|
@@ -81,30 +72,39 @@ function NProgress({
|
|
|
81
72
|
stop,
|
|
82
73
|
reset
|
|
83
74
|
};
|
|
84
|
-
const
|
|
85
|
-
unmountRef.current
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
resetRef.current = window.setTimeout(() => {
|
|
89
|
-
resetRef.current = null;
|
|
90
|
-
reset();
|
|
91
|
-
}, exitTransitionDuration);
|
|
75
|
+
const cancelUnmount = () => {
|
|
76
|
+
if (unmountRef.current) {
|
|
77
|
+
window.clearTimeout(unmountRef.current);
|
|
78
|
+
unmountRef.current = null;
|
|
92
79
|
}
|
|
80
|
+
if (resetRef.current) {
|
|
81
|
+
window.clearTimeout(resetRef.current);
|
|
82
|
+
resetRef.current = null;
|
|
83
|
+
}
|
|
84
|
+
setMounted(true);
|
|
93
85
|
};
|
|
94
86
|
hooks.useDidUpdate(() => {
|
|
95
87
|
if (_progress >= 100) {
|
|
96
88
|
stop();
|
|
97
89
|
onFinish && onFinish();
|
|
98
|
-
unmountRef.current = window.setTimeout(
|
|
90
|
+
unmountRef.current = window.setTimeout(() => {
|
|
91
|
+
unmountRef.current = null;
|
|
92
|
+
setMounted(false);
|
|
93
|
+
if (autoReset) {
|
|
94
|
+
resetRef.current = window.setTimeout(() => {
|
|
95
|
+
resetRef.current = null;
|
|
96
|
+
reset();
|
|
97
|
+
}, reducedMotion ? 0 : exitTransitionDuration);
|
|
98
|
+
}
|
|
99
|
+
}, exitTimeout);
|
|
99
100
|
} else if (!mounted) {
|
|
100
101
|
cancelUnmount();
|
|
101
102
|
}
|
|
102
103
|
}, [_progress]);
|
|
103
104
|
events.useNProgressEvents(ctx);
|
|
104
105
|
return /* @__PURE__ */ React__default.createElement(core.OptionalPortal, {
|
|
105
|
-
withinPortal
|
|
106
|
-
|
|
107
|
-
}, !unmountProgressRef.current && /* @__PURE__ */ React__default.createElement(core.Progress, {
|
|
106
|
+
withinPortal
|
|
107
|
+
}, !unmountProgress && /* @__PURE__ */ React__default.createElement(core.Progress, {
|
|
108
108
|
radius: 0,
|
|
109
109
|
value: _progress,
|
|
110
110
|
size,
|
|
@@ -114,6 +114,7 @@ function NProgress({
|
|
|
114
114
|
top: 0,
|
|
115
115
|
left: 0,
|
|
116
116
|
position: "fixed",
|
|
117
|
+
zIndex,
|
|
117
118
|
width: "100vw",
|
|
118
119
|
backgroundColor: "transparent",
|
|
119
120
|
transitionProperty: "opacity",
|
package/cjs/NProgress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NProgress.js","sources":["../src/NProgress.tsx"],"sourcesContent":["import { OptionalPortal, Progress } from '@mantine/core';\nimport { useDidUpdate, useInterval, useReducedMotion } from '@mantine/hooks';\nimport { getDefaultZIndex, MantineColor } from '@mantine/styles';\nimport React, { useRef, useState } from 'react';\nimport { useNProgressEvents } from './events';\n\nexport interface NProgressProps {\n /** The default progress */\n defaultProgress?: number;\n\n /** The color of the progressbar */\n color?: MantineColor;\n\n /** The height of the progressbar */\n size?: number;\n\n /** Called when the progress is 100% */\n onFinish?: () => void;\n\n /** Automatically resets the progress when 100% is reached */\n autoReset?: boolean;\n\n /** Step delay in ms */\n stepIntervalTime?: number;\n\n /** Transition function (transition-timing-function) */\n progressTransition?: string;\n\n /** Transition duration in ms */\n progressTransitionDuration?: number;\n\n /** The time when the component should be unmounted after progress is 100% */\n exitTimeout?: number;\n\n /** Exit transition duration in ms */\n exitTransitionDuration?: number;\n\n /** Exit transition function (transition-timing-function)*/\n exitTransition?: string;\n\n /** Determines whether NProgress should be rendered within Portal, defaults to true */\n withinPortal?: boolean;\n\n /** NProgress container z-index */\n zIndex?:
|
|
1
|
+
{"version":3,"file":"NProgress.js","sources":["../src/NProgress.tsx"],"sourcesContent":["import { OptionalPortal, Progress, useMantineTheme } from '@mantine/core';\nimport { useDidUpdate, useInterval, useReducedMotion } from '@mantine/hooks';\nimport { getDefaultZIndex, MantineColor } from '@mantine/styles';\nimport React, { useRef, useState } from 'react';\nimport { useNProgressEvents } from './events';\n\nexport interface NProgressProps {\n /** The default progress */\n defaultProgress?: number;\n\n /** The color of the progressbar */\n color?: MantineColor;\n\n /** The height of the progressbar */\n size?: number;\n\n /** Called when the progress is 100% */\n onFinish?: () => void;\n\n /** Automatically resets the progress when 100% is reached */\n autoReset?: boolean;\n\n /** Step delay in ms */\n stepIntervalTime?: number;\n\n /** Transition function (transition-timing-function) */\n progressTransition?: string;\n\n /** Transition duration in ms */\n progressTransitionDuration?: number;\n\n /** The time when the component should be unmounted after progress is 100% */\n exitTimeout?: number;\n\n /** Exit transition duration in ms */\n exitTransitionDuration?: number;\n\n /** Exit transition function (transition-timing-function)*/\n exitTransition?: string;\n\n /** Determines whether NProgress should be rendered within Portal, defaults to true */\n withinPortal?: boolean;\n\n /** NProgress container z-index */\n zIndex?: React.CSSProperties['zIndex'];\n}\n\nexport function NProgress({\n defaultProgress = 0,\n color = 'blue',\n size = 2,\n stepIntervalTime = 500,\n progressTransition = 'ease',\n progressTransitionDuration = 600,\n exitTimeout = 700,\n exitTransitionDuration = 600,\n exitTransition = 'ease',\n onFinish,\n autoReset = false,\n withinPortal = true,\n zIndex = getDefaultZIndex('max'),\n}: NProgressProps) {\n const theme = useMantineTheme();\n const shouldReduceMotion = useReducedMotion();\n const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const [_progress, setProgress] = useState(defaultProgress);\n const [mounted, setMounted] = useState(true);\n const [unmountProgress, setUnmountProgress] = useState(false);\n const resetRef = useRef<number>();\n const unmountRef = useRef<number>();\n\n const interval = useInterval(() => {\n setProgress((amount) => {\n let next = 0;\n if (amount >= 0 && amount <= 20) {\n next = 10;\n } else if (amount >= 20 && amount <= 50) {\n next = 4;\n } else if (amount >= 50 && amount <= 80) {\n next = 2;\n } else if (amount >= 80 && amount <= 99) {\n next = 0.5;\n }\n\n return amount + next;\n });\n }, stepIntervalTime);\n\n const set = (value: React.SetStateAction<number>) => setProgress(value);\n const add = (value: number) => setProgress((c) => Math.min(c + value, 100));\n const decrease = (value: number) => setProgress((c) => Math.max(c - value, 0));\n const start = () => {\n interval.stop();\n interval.start();\n };\n const stop = () => interval.stop();\n const reset = () => {\n setUnmountProgress(true);\n stop();\n setProgress(0);\n window.setTimeout(() => setUnmountProgress(false), 0);\n };\n\n const ctx = {\n set,\n add,\n decrease,\n start,\n stop,\n reset,\n };\n\n const cancelUnmount = () => {\n if (unmountRef.current) {\n window.clearTimeout(unmountRef.current);\n unmountRef.current = null;\n }\n if (resetRef.current) {\n window.clearTimeout(resetRef.current);\n resetRef.current = null;\n }\n\n setMounted(true);\n };\n\n useDidUpdate(() => {\n if (_progress >= 100) {\n stop();\n onFinish && onFinish();\n unmountRef.current = window.setTimeout(() => {\n unmountRef.current = null;\n setMounted(false);\n\n if (autoReset) {\n resetRef.current = window.setTimeout(\n () => {\n resetRef.current = null;\n reset();\n },\n reducedMotion ? 0 : exitTransitionDuration\n );\n }\n }, exitTimeout);\n } else if (!mounted) {\n cancelUnmount();\n }\n }, [_progress]);\n\n useNProgressEvents(ctx);\n\n return (\n <OptionalPortal withinPortal={withinPortal}>\n {!unmountProgress && (\n <Progress\n radius={0}\n value={_progress}\n size={size}\n color={color}\n styles={{\n root: {\n top: 0,\n left: 0,\n position: 'fixed',\n zIndex,\n width: '100vw',\n backgroundColor: 'transparent',\n transitionProperty: 'opacity',\n transitionTimingFunction: exitTransition,\n transitionDuration: `${\n reducedMotion || _progress !== 100 ? 0 : exitTransitionDuration\n }ms`,\n opacity: mounted ? 1 : 0,\n },\n bar: {\n transitionProperty: 'width',\n transitionTimingFunction: progressTransition,\n transitionDuration: `${reducedMotion || !mounted ? 0 : progressTransitionDuration}ms`,\n },\n }}\n />\n )}\n </OptionalPortal>\n );\n}\n"],"names":["getDefaultZIndex","useMantineTheme","useReducedMotion","useState","useRef","useInterval","useDidUpdate","useNProgressEvents","React","OptionalPortal","Progress"],"mappings":";;;;;;;;;;;;;;AAKO,SAAS,SAAS,CAAC;AAC1B,EAAE,eAAe,GAAG,CAAC;AACrB,EAAE,KAAK,GAAG,MAAM;AAChB,EAAE,IAAI,GAAG,CAAC;AACV,EAAE,gBAAgB,GAAG,GAAG;AACxB,EAAE,kBAAkB,GAAG,MAAM;AAC7B,EAAE,0BAA0B,GAAG,GAAG;AAClC,EAAE,WAAW,GAAG,GAAG;AACnB,EAAE,sBAAsB,GAAG,GAAG;AAC9B,EAAE,cAAc,GAAG,MAAM;AACzB,EAAE,QAAQ;AACV,EAAE,SAAS,GAAG,KAAK;AACnB,EAAE,YAAY,GAAG,IAAI;AACrB,EAAE,MAAM,GAAGA,uBAAgB,CAAC,KAAK,CAAC;AAClC,CAAC,EAAE;AACH,EAAE,MAAM,KAAK,GAAGC,oBAAe,EAAE,CAAC;AAClC,EAAE,MAAM,kBAAkB,GAAGC,sBAAgB,EAAE,CAAC;AAChD,EAAE,MAAM,aAAa,GAAG,KAAK,CAAC,oBAAoB,GAAG,kBAAkB,GAAG,KAAK,CAAC;AAChF,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GAAGC,cAAQ,CAAC,eAAe,CAAC,CAAC;AAC7D,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,IAAI,CAAC,CAAC;AAC/C,EAAE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;AAChE,EAAE,MAAM,QAAQ,GAAGC,YAAM,EAAE,CAAC;AAC5B,EAAE,MAAM,UAAU,GAAGA,YAAM,EAAE,CAAC;AA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wBAAwB,EAAE,kBAAkB;AACpD,QAAQ,kBAAkB,EAAE,CAAC,EAAE,aAAa,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,0BAA0B,CAAC,EAAE,CAAC;AAC7F,OAAO;AACP,KAAK;AACL,GAAG,CAAC,CAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@mantine/core');
|
|
6
|
+
var hooks = require('@mantine/hooks');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var events = require('./events.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
|
|
14
|
+
function NavigationProgress({
|
|
15
|
+
initialProgress = 0,
|
|
16
|
+
color,
|
|
17
|
+
size = 3,
|
|
18
|
+
stepInterval = 500,
|
|
19
|
+
transitionDuration = 300,
|
|
20
|
+
exitTimeout = 500,
|
|
21
|
+
exitTransitionDuration = 400,
|
|
22
|
+
onFinish,
|
|
23
|
+
autoReset = false,
|
|
24
|
+
withinPortal = true,
|
|
25
|
+
zIndex = core.getDefaultZIndex("max")
|
|
26
|
+
}) {
|
|
27
|
+
const theme = core.useMantineTheme();
|
|
28
|
+
const shouldReduceMotion = hooks.useReducedMotion();
|
|
29
|
+
const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
30
|
+
const [_progress, setProgress] = React.useState(initialProgress);
|
|
31
|
+
const [mounted, setMounted] = React.useState(true);
|
|
32
|
+
const [unmountProgress, setUnmountProgress] = React.useState(false);
|
|
33
|
+
const resetRef = React.useRef();
|
|
34
|
+
const unmountRef = React.useRef();
|
|
35
|
+
const interval = hooks.useInterval(() => {
|
|
36
|
+
setProgress((amount) => {
|
|
37
|
+
let next = 0;
|
|
38
|
+
if (amount >= 0 && amount <= 20) {
|
|
39
|
+
next = 10;
|
|
40
|
+
} else if (amount >= 20 && amount <= 50) {
|
|
41
|
+
next = 4;
|
|
42
|
+
} else if (amount >= 50 && amount <= 80) {
|
|
43
|
+
next = 2;
|
|
44
|
+
} else if (amount >= 80 && amount <= 99) {
|
|
45
|
+
next = 0.5;
|
|
46
|
+
}
|
|
47
|
+
return amount + next;
|
|
48
|
+
});
|
|
49
|
+
}, stepInterval);
|
|
50
|
+
const set = (value) => setProgress(value);
|
|
51
|
+
const increment = (value) => setProgress((c) => Math.min(c + value, 100));
|
|
52
|
+
const decrement = (value) => setProgress((c) => Math.max(c - value, 0));
|
|
53
|
+
const start = () => {
|
|
54
|
+
interval.stop();
|
|
55
|
+
interval.start();
|
|
56
|
+
};
|
|
57
|
+
const stop = () => interval.stop();
|
|
58
|
+
const reset = () => {
|
|
59
|
+
setUnmountProgress(true);
|
|
60
|
+
stop();
|
|
61
|
+
setProgress(0);
|
|
62
|
+
window.setTimeout(() => setUnmountProgress(false), 0);
|
|
63
|
+
};
|
|
64
|
+
const cancelUnmount = () => {
|
|
65
|
+
if (unmountRef.current) {
|
|
66
|
+
window.clearTimeout(unmountRef.current);
|
|
67
|
+
unmountRef.current = null;
|
|
68
|
+
}
|
|
69
|
+
if (resetRef.current) {
|
|
70
|
+
window.clearTimeout(resetRef.current);
|
|
71
|
+
resetRef.current = null;
|
|
72
|
+
}
|
|
73
|
+
setMounted(true);
|
|
74
|
+
};
|
|
75
|
+
hooks.useDidUpdate(() => {
|
|
76
|
+
if (_progress >= 100) {
|
|
77
|
+
stop();
|
|
78
|
+
onFinish == null ? void 0 : onFinish();
|
|
79
|
+
unmountRef.current = window.setTimeout(() => {
|
|
80
|
+
unmountRef.current = null;
|
|
81
|
+
setMounted(false);
|
|
82
|
+
if (autoReset) {
|
|
83
|
+
resetRef.current = window.setTimeout(() => {
|
|
84
|
+
resetRef.current = null;
|
|
85
|
+
reset();
|
|
86
|
+
}, reducedMotion ? 0 : exitTransitionDuration);
|
|
87
|
+
}
|
|
88
|
+
}, exitTimeout);
|
|
89
|
+
} else if (!mounted) {
|
|
90
|
+
cancelUnmount();
|
|
91
|
+
}
|
|
92
|
+
}, [_progress]);
|
|
93
|
+
events.useNavigationProgressEvents({ start, stop, set, increment, decrement, reset });
|
|
94
|
+
return /* @__PURE__ */ React__default.createElement(core.OptionalPortal, {
|
|
95
|
+
withinPortal
|
|
96
|
+
}, !unmountProgress && /* @__PURE__ */ React__default.createElement(core.Progress, {
|
|
97
|
+
radius: 0,
|
|
98
|
+
value: _progress,
|
|
99
|
+
size,
|
|
100
|
+
color,
|
|
101
|
+
styles: {
|
|
102
|
+
root: {
|
|
103
|
+
position: "fixed",
|
|
104
|
+
top: 0,
|
|
105
|
+
left: 0,
|
|
106
|
+
right: 0,
|
|
107
|
+
zIndex,
|
|
108
|
+
backgroundColor: "transparent",
|
|
109
|
+
transitionProperty: "opacity",
|
|
110
|
+
transitionTimingFunction: theme.transitionTimingFunction,
|
|
111
|
+
transitionDuration: `${reducedMotion || _progress !== 100 ? 0 : exitTransitionDuration}ms`,
|
|
112
|
+
opacity: mounted ? 1 : 0
|
|
113
|
+
},
|
|
114
|
+
bar: {
|
|
115
|
+
position: "relative",
|
|
116
|
+
transitionProperty: "width",
|
|
117
|
+
transitionTimingFunction: theme.transitionTimingFunction,
|
|
118
|
+
transitionDuration: `${reducedMotion || !mounted ? 0 : transitionDuration}ms`
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
exports.NavigationProgress = NavigationProgress;
|
|
125
|
+
//# sourceMappingURL=NavigationProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationProgress.js","sources":["../src/NavigationProgress.tsx"],"sourcesContent":["import {\n OptionalPortal,\n Progress,\n useMantineTheme,\n getDefaultZIndex,\n MantineColor,\n} from '@mantine/core';\nimport { useDidUpdate, useInterval, useReducedMotion } from '@mantine/hooks';\nimport React, { useRef, useState } from 'react';\nimport { useNavigationProgressEvents } from './events';\n\nexport interface NavigationProgressProps {\n /** The default progress */\n initialProgress?: number;\n\n /** Key of theme.colors of any other valid CSS color */\n color?: MantineColor;\n\n /** The height of the progressbar in px */\n size?: number;\n\n /** Called when the progressbar reaches 100% */\n onFinish?(): void;\n\n /** Determines whether progress should be automatically reset when 100% is reached */\n autoReset?: boolean;\n\n /** Step interval in ms */\n stepInterval?: number;\n\n /** Transition duration in ms */\n transitionDuration?: number;\n\n /** Number of ms that should elapse before progressbar is hidden after reaching 100% */\n exitTimeout?: number;\n\n /** Exit transition duration in ms */\n exitTransitionDuration?: number;\n\n /** Determines whether progressbar should be rendered within Portal, defaults to true */\n withinPortal?: boolean;\n\n /** Progressbar z-index */\n zIndex?: React.CSSProperties['zIndex'];\n}\n\nexport function NavigationProgress({\n initialProgress = 0,\n color,\n size = 3,\n stepInterval = 500,\n transitionDuration = 300,\n exitTimeout = 500,\n exitTransitionDuration = 400,\n onFinish,\n autoReset = false,\n withinPortal = true,\n zIndex = getDefaultZIndex('max'),\n}: NavigationProgressProps) {\n const theme = useMantineTheme();\n const shouldReduceMotion = useReducedMotion();\n const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const [_progress, setProgress] = useState(initialProgress);\n const [mounted, setMounted] = useState(true);\n const [unmountProgress, setUnmountProgress] = useState(false);\n const resetRef = useRef<number>();\n const unmountRef = useRef<number>();\n\n const interval = useInterval(() => {\n setProgress((amount) => {\n let next = 0;\n if (amount >= 0 && amount <= 20) {\n next = 10;\n } else if (amount >= 20 && amount <= 50) {\n next = 4;\n } else if (amount >= 50 && amount <= 80) {\n next = 2;\n } else if (amount >= 80 && amount <= 99) {\n next = 0.5;\n }\n\n return amount + next;\n });\n }, stepInterval);\n\n const set = (value: React.SetStateAction<number>) => setProgress(value);\n const increment = (value: number) => setProgress((c) => Math.min(c + value, 100));\n const decrement = (value: number) => setProgress((c) => Math.max(c - value, 0));\n const start = () => {\n interval.stop();\n interval.start();\n };\n const stop = () => interval.stop();\n const reset = () => {\n setUnmountProgress(true);\n stop();\n setProgress(0);\n window.setTimeout(() => setUnmountProgress(false), 0);\n };\n\n const cancelUnmount = () => {\n if (unmountRef.current) {\n window.clearTimeout(unmountRef.current);\n unmountRef.current = null;\n }\n if (resetRef.current) {\n window.clearTimeout(resetRef.current);\n resetRef.current = null;\n }\n\n setMounted(true);\n };\n\n useDidUpdate(() => {\n if (_progress >= 100) {\n stop();\n onFinish?.();\n\n unmountRef.current = window.setTimeout(() => {\n unmountRef.current = null;\n setMounted(false);\n\n if (autoReset) {\n resetRef.current = window.setTimeout(\n () => {\n resetRef.current = null;\n reset();\n },\n reducedMotion ? 0 : exitTransitionDuration\n );\n }\n }, exitTimeout);\n } else if (!mounted) {\n cancelUnmount();\n }\n }, [_progress]);\n\n useNavigationProgressEvents({ start, stop, set, increment, decrement, reset });\n\n return (\n <OptionalPortal withinPortal={withinPortal}>\n {!unmountProgress && (\n <Progress\n radius={0}\n value={_progress}\n size={size}\n color={color}\n styles={{\n root: {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n zIndex,\n backgroundColor: 'transparent',\n transitionProperty: 'opacity',\n transitionTimingFunction: theme.transitionTimingFunction,\n transitionDuration: `${\n reducedMotion || _progress !== 100 ? 0 : exitTransitionDuration\n }ms`,\n opacity: mounted ? 1 : 0,\n },\n bar: {\n position: 'relative',\n transitionProperty: 'width',\n transitionTimingFunction: theme.transitionTimingFunction,\n transitionDuration: `${reducedMotion || !mounted ? 0 : transitionDuration}ms`,\n },\n }}\n />\n )}\n </OptionalPortal>\n );\n}\n"],"names":["getDefaultZIndex","useMantineTheme","useReducedMotion","useState","useRef","useInterval","useDidUpdate","useNavigationProgressEvents","React","OptionalPortal","Progress"],"mappings":";;;;;;;;;;;;;AASO,SAAS,kBAAkB,CAAC;AACnC,EAAE,eAAe,GAAG,CAAC;A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');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
function createEvent(type, detail) {
|
|
16
|
-
return new CustomEvent(type, { detail });
|
|
17
|
-
}
|
|
18
|
-
function addNProgress(progress) {
|
|
19
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.add, progress));
|
|
20
|
-
}
|
|
21
|
-
function decreaseNProgress(progress) {
|
|
22
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.decrease, progress));
|
|
23
|
-
}
|
|
24
|
-
function setNProgress(progress) {
|
|
25
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.set, progress));
|
|
26
|
-
}
|
|
27
|
-
function startNProgress() {
|
|
28
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.start));
|
|
29
|
-
}
|
|
30
|
-
function stopNProgress() {
|
|
31
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.stop));
|
|
32
|
-
}
|
|
33
|
-
function resetNProgress() {
|
|
34
|
-
window.dispatchEvent(createEvent(NPROGRESS_EVENTS.reset));
|
|
35
|
-
}
|
|
36
|
-
function useNProgressEvents(ctx) {
|
|
37
|
-
const events = {
|
|
38
|
-
add: (event) => ctx.add(event.detail),
|
|
39
|
-
decrease: (event) => ctx.decrease(event.detail),
|
|
40
|
-
set: (event) => ctx.set(event.detail),
|
|
41
|
-
start: ctx.start,
|
|
42
|
-
stop: ctx.stop,
|
|
43
|
-
reset: ctx.reset
|
|
44
|
-
};
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
Object.keys(events).forEach((event) => {
|
|
47
|
-
window.addEventListener(NPROGRESS_EVENTS[event], events[event]);
|
|
48
|
-
});
|
|
49
|
-
return () => {
|
|
50
|
-
Object.keys(events).forEach((event) => {
|
|
51
|
-
window.removeEventListener(NPROGRESS_EVENTS[event], events[event]);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
}
|
|
7
|
+
const [useNavigationProgressEvents, createEvent] = utils.createUseExternalEvents("mantine-nprogress");
|
|
8
|
+
const startNavigationProgress = createEvent("start");
|
|
9
|
+
const stopNavigationProgress = createEvent("stop");
|
|
10
|
+
const resetNavigationProgress = createEvent("reset");
|
|
11
|
+
const setNavigationProgress = createEvent("set");
|
|
12
|
+
const incrementNavigationProgress = createEvent("increment");
|
|
13
|
+
const decrementNavigationProgress = createEvent("decrement");
|
|
56
14
|
|
|
57
|
-
exports.NPROGRESS_EVENTS = NPROGRESS_EVENTS;
|
|
58
|
-
exports.addNProgress = addNProgress;
|
|
59
15
|
exports.createEvent = createEvent;
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
16
|
+
exports.decrementNavigationProgress = decrementNavigationProgress;
|
|
17
|
+
exports.incrementNavigationProgress = incrementNavigationProgress;
|
|
18
|
+
exports.resetNavigationProgress = resetNavigationProgress;
|
|
19
|
+
exports.setNavigationProgress = setNavigationProgress;
|
|
20
|
+
exports.startNavigationProgress = startNavigationProgress;
|
|
21
|
+
exports.stopNavigationProgress = stopNavigationProgress;
|
|
22
|
+
exports.useNavigationProgressEvents = useNavigationProgressEvents;
|
|
66
23
|
//# sourceMappingURL=events.js.map
|
package/cjs/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\n\nexport type NavigationProgressEvents = {\n start(): void;\n stop(): void;\n set(progress: number): void;\n increment(progress: number): void;\n decrement(progress: number): void;\n reset(): void;\n};\n\nexport const [useNavigationProgressEvents, createEvent] =\n createUseExternalEvents<NavigationProgressEvents>('mantine-nprogress');\n\nexport const startNavigationProgress = createEvent('start');\nexport const stopNavigationProgress = createEvent('stop');\nexport const resetNavigationProgress = createEvent('reset');\nexport const setNavigationProgress = createEvent('set');\nexport const incrementNavigationProgress = createEvent('increment');\nexport const decrementNavigationProgress = createEvent('decrement');\n"],"names":["createUseExternalEvents"],"mappings":";;;;;;AACY,MAAC,CAAC,2BAA2B,EAAE,WAAW,CAAC,GAAGA,6BAAuB,CAAC,mBAAmB,EAAE;AAC3F,MAAC,uBAAuB,GAAG,WAAW,CAAC,OAAO,EAAE;AAChD,MAAC,sBAAsB,GAAG,WAAW,CAAC,MAAM,EAAE;AAC9C,MAAC,uBAAuB,GAAG,WAAW,CAAC,OAAO,EAAE;AAChD,MAAC,qBAAqB,GAAG,WAAW,CAAC,KAAK,EAAE;AAC5C,MAAC,2BAA2B,GAAG,WAAW,CAAC,WAAW,EAAE;AACxD,MAAC,2BAA2B,GAAG,WAAW,CAAC,WAAW;;;;;;;;;;;"}
|
package/cjs/index.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var NavigationProgress = require('./NavigationProgress.js');
|
|
6
6
|
var events = require('./events.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
10
|
+
exports.NavigationProgress = NavigationProgress.NavigationProgress;
|
|
11
|
+
exports.decrementNavigationProgress = events.decrementNavigationProgress;
|
|
12
|
+
exports.incrementNavigationProgress = events.incrementNavigationProgress;
|
|
13
|
+
exports.resetNavigationProgress = events.resetNavigationProgress;
|
|
14
|
+
exports.setNavigationProgress = events.setNavigationProgress;
|
|
15
|
+
exports.startNavigationProgress = events.startNavigationProgress;
|
|
16
|
+
exports.stopNavigationProgress = events.stopNavigationProgress;
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@mantine/core');
|
|
6
|
+
var hooks = require('@mantine/hooks');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var events = require('./events.js');
|
|
9
|
+
var getDefaultZIndex = require('../../mantine-styles/esm/theme/utils/get-default-z-index/get-default-z-index.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
|
|
15
|
+
function NavigationProgress({
|
|
16
|
+
initialProgress = 0,
|
|
17
|
+
color,
|
|
18
|
+
size = 3,
|
|
19
|
+
stepInterval = 500,
|
|
20
|
+
transitionDuration = 600,
|
|
21
|
+
exitTimeout = 700,
|
|
22
|
+
exitTransitionDuration = 600,
|
|
23
|
+
onFinish,
|
|
24
|
+
autoReset = false,
|
|
25
|
+
withinPortal = true,
|
|
26
|
+
zIndex = getDefaultZIndex.getDefaultZIndex("max")
|
|
27
|
+
}) {
|
|
28
|
+
const theme = core.useMantineTheme();
|
|
29
|
+
const shouldReduceMotion = hooks.useReducedMotion();
|
|
30
|
+
const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;
|
|
31
|
+
const [_progress, setProgress] = React.useState(initialProgress);
|
|
32
|
+
const [mounted, setMounted] = React.useState(true);
|
|
33
|
+
const [unmountProgress, setUnmountProgress] = React.useState(false);
|
|
34
|
+
const resetRef = React.useRef();
|
|
35
|
+
const unmountRef = React.useRef();
|
|
36
|
+
const interval = hooks.useInterval(() => {
|
|
37
|
+
setProgress((amount) => {
|
|
38
|
+
let next = 0;
|
|
39
|
+
if (amount >= 0 && amount <= 20) {
|
|
40
|
+
next = 10;
|
|
41
|
+
} else if (amount >= 20 && amount <= 50) {
|
|
42
|
+
next = 4;
|
|
43
|
+
} else if (amount >= 50 && amount <= 80) {
|
|
44
|
+
next = 2;
|
|
45
|
+
} else if (amount >= 80 && amount <= 99) {
|
|
46
|
+
next = 0.5;
|
|
47
|
+
}
|
|
48
|
+
return amount + next;
|
|
49
|
+
});
|
|
50
|
+
}, stepInterval);
|
|
51
|
+
const set = (value) => setProgress(value);
|
|
52
|
+
const increment = (value) => setProgress((c) => Math.min(c + value, 100));
|
|
53
|
+
const decrement = (value) => setProgress((c) => Math.max(c - value, 0));
|
|
54
|
+
const start = () => {
|
|
55
|
+
interval.stop();
|
|
56
|
+
interval.start();
|
|
57
|
+
};
|
|
58
|
+
const stop = () => interval.stop();
|
|
59
|
+
const reset = () => {
|
|
60
|
+
setUnmountProgress(true);
|
|
61
|
+
stop();
|
|
62
|
+
setProgress(0);
|
|
63
|
+
window.setTimeout(() => setUnmountProgress(false), 0);
|
|
64
|
+
};
|
|
65
|
+
const cancelUnmount = () => {
|
|
66
|
+
if (unmountRef.current) {
|
|
67
|
+
window.clearTimeout(unmountRef.current);
|
|
68
|
+
unmountRef.current = null;
|
|
69
|
+
}
|
|
70
|
+
if (resetRef.current) {
|
|
71
|
+
window.clearTimeout(resetRef.current);
|
|
72
|
+
resetRef.current = null;
|
|
73
|
+
}
|
|
74
|
+
setMounted(true);
|
|
75
|
+
};
|
|
76
|
+
hooks.useDidUpdate(() => {
|
|
77
|
+
if (_progress >= 100) {
|
|
78
|
+
stop();
|
|
79
|
+
onFinish == null ? void 0 : onFinish();
|
|
80
|
+
unmountRef.current = window.setTimeout(() => {
|
|
81
|
+
unmountRef.current = null;
|
|
82
|
+
setMounted(false);
|
|
83
|
+
if (autoReset) {
|
|
84
|
+
resetRef.current = window.setTimeout(() => {
|
|
85
|
+
resetRef.current = null;
|
|
86
|
+
reset();
|
|
87
|
+
}, reducedMotion ? 0 : exitTransitionDuration);
|
|
88
|
+
}
|
|
89
|
+
}, exitTimeout);
|
|
90
|
+
} else if (!mounted) {
|
|
91
|
+
cancelUnmount();
|
|
92
|
+
}
|
|
93
|
+
}, [_progress]);
|
|
94
|
+
events.useNavigationProgressEvents({ start, stop, set, increment, decrement, reset });
|
|
95
|
+
return /* @__PURE__ */ React__default.createElement(core.OptionalPortal, {
|
|
96
|
+
withinPortal
|
|
97
|
+
}, !unmountProgress && /* @__PURE__ */ React__default.createElement(core.Progress, {
|
|
98
|
+
radius: 0,
|
|
99
|
+
value: _progress,
|
|
100
|
+
size,
|
|
101
|
+
color,
|
|
102
|
+
styles: {
|
|
103
|
+
root: {
|
|
104
|
+
position: "fixed",
|
|
105
|
+
top: 0,
|
|
106
|
+
left: 0,
|
|
107
|
+
right: 0,
|
|
108
|
+
zIndex,
|
|
109
|
+
backgroundColor: "transparent",
|
|
110
|
+
transitionProperty: "opacity",
|
|
111
|
+
transitionTimingFunction: theme.transitionTimingFunction,
|
|
112
|
+
transitionDuration: `${reducedMotion || _progress !== 100 ? 0 : exitTransitionDuration}ms`,
|
|
113
|
+
opacity: mounted ? 1 : 0
|
|
114
|
+
},
|
|
115
|
+
bar: {
|
|
116
|
+
position: "relative",
|
|
117
|
+
transitionProperty: "width",
|
|
118
|
+
transitionTimingFunction: theme.transitionTimingFunction,
|
|
119
|
+
transitionDuration: `${reducedMotion || !mounted ? 0 : transitionDuration}ms`
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
exports.NavigationProgress = NavigationProgress;
|
|
126
|
+
//# sourceMappingURL=NavigationProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationProgress.js","sources":["../../../src/NavigationProgress.tsx"],"sourcesContent":["import { OptionalPortal, Progress, useMantineTheme } from '@mantine/core';\nimport { useDidUpdate, useInterval, useReducedMotion } from '@mantine/hooks';\nimport { getDefaultZIndex, MantineColor } from '@mantine/styles';\nimport React, { useRef, useState } from 'react';\nimport { useNavigationProgressEvents } from './events';\n\nexport interface NavigationProgressProps {\n /** The default progress */\n initialProgress?: number;\n\n /** Key of theme.colors of any other valid CSS color */\n color?: MantineColor;\n\n /** The height of the progressbar in px */\n size?: number;\n\n /** Called when the progressbar reaches 100% */\n onFinish?(): void;\n\n /** Determines whether progress should be automatically reset when 100% is reached */\n autoReset?: boolean;\n\n /** Step interval in ms */\n stepInterval?: number;\n\n /** Transition duration in ms */\n transitionDuration?: number;\n\n /** Number of ms that should elapse before progressbar is hidden after reaching 100% */\n exitTimeout?: number;\n\n /** Exit transition duration in ms */\n exitTransitionDuration?: number;\n\n /** Determines whether progressbar should be rendered within Portal, defaults to true */\n withinPortal?: boolean;\n\n /** Progressbar z-index */\n zIndex?: React.CSSProperties['zIndex'];\n}\n\nexport function NavigationProgress({\n initialProgress = 0,\n color,\n size = 3,\n stepInterval = 500,\n transitionDuration = 600,\n exitTimeout = 700,\n exitTransitionDuration = 600,\n onFinish,\n autoReset = false,\n withinPortal = true,\n zIndex = getDefaultZIndex('max'),\n}: NavigationProgressProps) {\n const theme = useMantineTheme();\n const shouldReduceMotion = useReducedMotion();\n const reducedMotion = theme.respectReducedMotion ? shouldReduceMotion : false;\n const [_progress, setProgress] = useState(initialProgress);\n const [mounted, setMounted] = useState(true);\n const [unmountProgress, setUnmountProgress] = useState(false);\n const resetRef = useRef<number>();\n const unmountRef = useRef<number>();\n\n const interval = useInterval(() => {\n setProgress((amount) => {\n let next = 0;\n if (amount >= 0 && amount <= 20) {\n next = 10;\n } else if (amount >= 20 && amount <= 50) {\n next = 4;\n } else if (amount >= 50 && amount <= 80) {\n next = 2;\n } else if (amount >= 80 && amount <= 99) {\n next = 0.5;\n }\n\n return amount + next;\n });\n }, stepInterval);\n\n const set = (value: React.SetStateAction<number>) => setProgress(value);\n const increment = (value: number) => setProgress((c) => Math.min(c + value, 100));\n const decrement = (value: number) => setProgress((c) => Math.max(c - value, 0));\n const start = () => {\n interval.stop();\n interval.start();\n };\n const stop = () => interval.stop();\n const reset = () => {\n setUnmountProgress(true);\n stop();\n setProgress(0);\n window.setTimeout(() => setUnmountProgress(false), 0);\n };\n\n const cancelUnmount = () => {\n if (unmountRef.current) {\n window.clearTimeout(unmountRef.current);\n unmountRef.current = null;\n }\n if (resetRef.current) {\n window.clearTimeout(resetRef.current);\n resetRef.current = null;\n }\n\n setMounted(true);\n };\n\n useDidUpdate(() => {\n if (_progress >= 100) {\n stop();\n onFinish?.();\n\n unmountRef.current = window.setTimeout(() => {\n unmountRef.current = null;\n setMounted(false);\n\n if (autoReset) {\n resetRef.current = window.setTimeout(\n () => {\n resetRef.current = null;\n reset();\n },\n reducedMotion ? 0 : exitTransitionDuration\n );\n }\n }, exitTimeout);\n } else if (!mounted) {\n cancelUnmount();\n }\n }, [_progress]);\n\n useNavigationProgressEvents({ start, stop, set, increment, decrement, reset });\n\n return (\n <OptionalPortal withinPortal={withinPortal}>\n {!unmountProgress && (\n <Progress\n radius={0}\n value={_progress}\n size={size}\n color={color}\n styles={{\n root: {\n position: 'fixed',\n top: 0,\n left: 0,\n right: 0,\n zIndex,\n backgroundColor: 'transparent',\n transitionProperty: 'opacity',\n transitionTimingFunction: theme.transitionTimingFunction,\n transitionDuration: `${\n reducedMotion || _progress !== 100 ? 0 : exitTransitionDuration\n }ms`,\n opacity: mounted ? 1 : 0,\n },\n bar: {\n position: 'relative',\n transitionProperty: 'width',\n transitionTimingFunction: theme.transitionTimingFunction,\n transitionDuration: `${reducedMotion || !mounted ? 0 : transitionDuration}ms`,\n },\n }}\n />\n )}\n </OptionalPortal>\n );\n}\n"],"names":["getDefaultZIndex","useMantineTheme","useReducedMotion","useState","useRef","useInterval","useDidUpdate","useNavigationProgressEvents","React","OptionalPortal","Progress"],"mappings":";;;;;;;;;;;;;;AAKO,SAAS,kBAAkB,CAAC;AACnC,EAAE,eAAe,GAAG,CAAC;AACrB,EAAE,KAAK;AACP,EAAE,IAAI,GAAG,CAAC;AACV,EAAE,YAAY,GAAG,GA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aAAa,CAACC,mBAAc,EAAE;AAC7D,IAAI,YAAY;AAChB,GAAG,EAAE,CAAC,eAAe,oBAAoBD,cAAK,CAAC,aAAa,CAACE,aAAQ,EAAE;AACvE,IAAI,MAAM,EAAE,CAAC;AACb,IAAI,KAAK,EAAE,SAAS;AACpB,IAAI,IAAI;AACR,IAAI,KAAK;AACT,IAAI,MAAM,EAAE;AACZ,MAAM,IAAI,EAAE;AACZ,QAAQ,QAAQ,EAAE,OAAO;AACzB,QAAQ,GAAG,EAAE,CAAC;AACd,QAAQ,IAAI,EAAE,CAAC;AACf,QAAQ,KAAK,EAAE,CAAC;AAChB,QAAQ,MAAM;AACd,QAAQ,eAAe,EAAE,aAAa;AACtC,QAAQ,kBAAkB,EAAE,SAAS;AACrC,QAAQ,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;AAChE,QAAQ,kBAAkB,EAAE,CAAC,EAAE,aAAa,IAAI,SAAS,KAAK,GAAG,GAAG,CAAC,GAAG,sBAAsB,CAAC,EAAE,CAAC;AAClG,QAAQ,OAAO,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC;AAChC,OAAO;AACP,MAAM,GAAG,EAAE;AACX,QAAQ,QAAQ,EAAE,UAAU;AAC5B,QAAQ,kBAAkB,EAAE,OAAO;AACnC,QAAQ,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;AAChE,QAAQ,kBAAkB,EAAE,CAAC,EAAE,aAAa,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,kBAAkB,CAAC,EAAE,CAAC;AACrF,OAAO;AACP,KAAK;AACL,GAAG,CAAC,CAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var utils = require('@mantine/utils');
|
|
6
|
+
|
|
7
|
+
const [useNavigationProgressEvents, createEvent] = utils.createUseExternalEvents("mantine-nprogress");
|
|
8
|
+
const startNavigationProgress = createEvent("start");
|
|
9
|
+
const stopNavigationProgress = createEvent("stop");
|
|
10
|
+
const resetNavigationProgress = createEvent("reset");
|
|
11
|
+
const setNavigationProgress = createEvent("set");
|
|
12
|
+
const incrementNavigationProgress = createEvent("increment");
|
|
13
|
+
const decrementNavigationProgress = createEvent("decrement");
|
|
14
|
+
|
|
15
|
+
exports.createEvent = createEvent;
|
|
16
|
+
exports.decrementNavigationProgress = decrementNavigationProgress;
|
|
17
|
+
exports.incrementNavigationProgress = incrementNavigationProgress;
|
|
18
|
+
exports.resetNavigationProgress = resetNavigationProgress;
|
|
19
|
+
exports.setNavigationProgress = setNavigationProgress;
|
|
20
|
+
exports.startNavigationProgress = startNavigationProgress;
|
|
21
|
+
exports.stopNavigationProgress = stopNavigationProgress;
|
|
22
|
+
exports.useNavigationProgressEvents = useNavigationProgressEvents;
|
|
23
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sources":["../../../src/events.ts"],"sourcesContent":["import { createUseExternalEvents } from '@mantine/utils';\n\nexport type NavigationProgressEvents = {\n start(): void;\n stop(): void;\n set(progress: number): void;\n increment(progress: number): void;\n decrement(progress: number): void;\n reset(): void;\n};\n\nexport const [useNavigationProgressEvents, createEvent] =\n createUseExternalEvents<NavigationProgressEvents>('mantine-nprogress');\n\nexport const NPROGRESS_EVENTS = {\n add: 'mantine:add-nprogress',\n decrease: 'mantine:decrease-nprogress',\n set: 'mantine:set-nprogress',\n start: 'mantine:start-nprogress',\n stop: 'mantine:stop-nprogress',\n reset: 'mantine:reset-nprogress',\n} as const;\n\nexport const startNavigationProgress = createEvent('start');\nexport const stopNavigationProgress = createEvent('stop');\nexport const resetNavigationProgress = createEvent('reset');\nexport const setNavigationProgress = createEvent('set');\nexport const incrementNavigationProgress = createEvent('increment');\nexport const decrementNavigationProgress = createEvent('decrement');\n"],"names":["createUseExternalEvents"],"mappings":";;;;;;AACY,MAAC,CAAC,2BAA2B,EAAE,WAAW,CAAC,GAAGA,6BAAuB,CAAC,mBAAmB,EAAE;AAS3F,MAAC,uBAAuB,GAAG,WAAW,CAAC,OAAO,EAAE;AAChD,MAAC,sBAAsB,GAAG,WAAW,CAAC,MAAM,EAAE;AAC9C,MAAC,uBAAuB,GAAG,WAAW,CAAC,OAAO,EAAE;AAChD,MAAC,qBAAqB,GAAG,WAAW,CAAC,KAAK,EAAE;AAC5C,MAAC,2BAA2B,GAAG,WAAW,CAAC,WAAW,EAAE;AACxD,MAAC,2BAA2B,GAAG,WAAW,CAAC,WAAW;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var NavigationProgress = require('./NavigationProgress.js');
|
|
6
|
+
var events = require('./events.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.NavigationProgress = NavigationProgress.NavigationProgress;
|
|
11
|
+
exports.decrementNavigationProgress = events.decrementNavigationProgress;
|
|
12
|
+
exports.incrementNavigationProgress = events.incrementNavigationProgress;
|
|
13
|
+
exports.resetNavigationProgress = events.resetNavigationProgress;
|
|
14
|
+
exports.setNavigationProgress = events.setNavigationProgress;
|
|
15
|
+
exports.startNavigationProgress = events.startNavigationProgress;
|
|
16
|
+
exports.stopNavigationProgress = events.stopNavigationProgress;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|