@mantine_nprogress-umd

UMD of @mantine/nprogress

目前为 2024-07-04 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/499644/1405089/%40mantine_nprogress-umd.js

  1. // ==UserScript==
  2. // @name @mantine_nprogress-umd
  3. // @namespace flomk.userscripts
  4. // @version 1.0
  5. // @description UMD of @mantine/nprogress
  6. // @author flomk
  7. // ==/UserScript==
  8.  
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@mantine/core'), require('@mantine/hooks')) :
  11. typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@mantine/core', '@mantine/hooks'], factory) :
  12. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MantineNavigationProgress = {}, global.ReactJSXRuntime, global.React, global.Mantine, global.MantineHooks));
  13. })(this, (function (exports, jsxRuntime, react, core, hooks) { 'use strict';
  14.  
  15. /* esm.sh - esbuild bundle(@mantine/nprogress@7.11.1) es2022 development */
  16. // ../esmd/npm/@mantine/nprogress@7.11.1/node_modules/.pnpm/@mantine+nprogress@7.11.1_@mantine+core@7.11.1_@mantine+hooks@7.11.1_react-dom@18.3.1_react@18.3.1/node_modules/@mantine/nprogress/esm/NavigationProgress.mjs
  17. function createStore(initialState) {
  18. let state = initialState;
  19. let initialized = false;
  20. const listeners = /* @__PURE__ */ new Set();
  21. return {
  22. getState() {
  23. return state;
  24. },
  25. updateState(value) {
  26. state = typeof value === "function" ? value(state) : value;
  27. },
  28. setState(value) {
  29. this.updateState(value);
  30. listeners.forEach((listener) => listener(state));
  31. },
  32. initialize(value) {
  33. if (!initialized) {
  34. state = value;
  35. initialized = true;
  36. }
  37. },
  38. subscribe(callback) {
  39. listeners.add(callback);
  40. return () => listeners.delete(callback);
  41. }
  42. };
  43. }
  44. function useStore(store) {
  45. return react.useSyncExternalStore(
  46. store.subscribe,
  47. () => store.getState(),
  48. () => store.getState()
  49. );
  50. }
  51.  
  52. // ../esmd/npm/@mantine/nprogress@7.11.1/node_modules/.pnpm/@mantine+nprogress@7.11.1_@mantine+core@7.11.1_@mantine+hooks@7.11.1_react-dom@18.3.1_react@18.3.1/node_modules/@mantine/nprogress/esm/nprogress.store.mjs
  53. function getIntervalProgressValue(currentProgress) {
  54. let next = 0.5;
  55. if (currentProgress >= 0 && currentProgress <= 20) {
  56. next = 10;
  57. } else if (currentProgress >= 20 && currentProgress <= 50) {
  58. next = 4;
  59. } else if (currentProgress >= 50 && currentProgress <= 80) {
  60. next = 2;
  61. } else if (currentProgress >= 80 && currentProgress <= 99) {
  62. next = 1;
  63. } else if (currentProgress >= 99 && currentProgress <= 100) {
  64. next = 0;
  65. }
  66. return currentProgress + next;
  67. }
  68. var createNprogressStore = () => createStore({
  69. mounted: false,
  70. progress: 0,
  71. interval: 0,
  72. step: 1,
  73. stepInterval: 100,
  74. timeouts: []
  75. });
  76. var useNprogress = (store) => useStore(store);
  77. function updateNavigationProgressStateAction(update, store) {
  78. const state = store.getState();
  79. store.setState({ ...state, ...update(store.getState()) });
  80. }
  81. function decrementNavigationProgressAction(store) {
  82. updateNavigationProgressStateAction(
  83. (state) => ({ progress: Math.max(state.progress - state.step, 0) }),
  84. store
  85. );
  86. }
  87. function setNavigationProgressAction(value, store) {
  88. updateNavigationProgressStateAction(
  89. () => ({ progress: hooks.clamp(value, 0, 100), mounted: true }),
  90. store
  91. );
  92. }
  93. function cleanupNavigationProgressAction(store) {
  94. updateNavigationProgressStateAction((state) => {
  95. window.clearInterval(state.interval);
  96. state.timeouts.forEach((timeout) => window.clearTimeout(timeout));
  97. return { timeouts: [] };
  98. }, store);
  99. }
  100. function completeNavigationProgressAction(store) {
  101. cleanupNavigationProgressAction(store);
  102. updateNavigationProgressStateAction((state) => {
  103. const mountedTimeout = window.setTimeout(() => {
  104. updateNavigationProgressStateAction(() => ({ mounted: false }), store);
  105. }, 50);
  106. const resetTimeout = window.setTimeout(() => {
  107. updateNavigationProgressStateAction(() => ({ progress: 0 }), store);
  108. }, state.stepInterval + 50);
  109. return { progress: 100, timeouts: [mountedTimeout, resetTimeout] };
  110. }, store);
  111. }
  112. function startNavigationProgressAction(store) {
  113. updateNavigationProgressStateAction(
  114. (s) => ({ progress: getIntervalProgressValue(s.progress), mounted: true }),
  115. store
  116. );
  117. updateNavigationProgressStateAction((state) => {
  118. window.clearInterval(state.interval);
  119. const interval = window.setInterval(() => {
  120. updateNavigationProgressStateAction(
  121. (s) => ({ progress: getIntervalProgressValue(s.progress), mounted: true }),
  122. store
  123. );
  124. }, state.stepInterval);
  125. return { interval, mounted: true };
  126. }, store);
  127. }
  128. function stopNavigationProgressAction(store) {
  129. updateNavigationProgressStateAction((state) => {
  130. window.clearInterval(state.interval);
  131. return { interval: -1 };
  132. }, store);
  133. }
  134. function resetNavigationProgressAction(store) {
  135. cleanupNavigationProgressAction(store);
  136. stopNavigationProgressAction(store);
  137. updateNavigationProgressStateAction(() => ({ progress: 0, mounted: false }), store);
  138. }
  139. function incrementNavigationProgressAction(store) {
  140. updateNavigationProgressStateAction((state) => {
  141. const nextValue = Math.min(state.progress + state.step, 100);
  142. const nextMounted = nextValue !== 100 && nextValue !== 0;
  143. if (!nextMounted) {
  144. const timeout = window.setTimeout(
  145. () => resetNavigationProgressAction(store),
  146. state.stepInterval + 50
  147. );
  148. return {
  149. progress: nextValue,
  150. mounted: nextMounted,
  151. timeouts: [...state.timeouts, timeout]
  152. };
  153. }
  154. return {
  155. progress: nextValue,
  156. mounted: nextMounted
  157. };
  158. }, store);
  159. }
  160. function createNprogress() {
  161. const store = createNprogressStore();
  162. const actions = {
  163. start: () => startNavigationProgressAction(store),
  164. stop: () => stopNavigationProgressAction(store),
  165. reset: () => resetNavigationProgressAction(store),
  166. set: (value) => setNavigationProgressAction(value, store),
  167. increment: () => incrementNavigationProgressAction(store),
  168. decrement: () => decrementNavigationProgressAction(store),
  169. complete: () => completeNavigationProgressAction(store),
  170. cleanup: () => cleanupNavigationProgressAction(store)
  171. };
  172. return [store, actions];
  173. }
  174. var [nprogressStore, nprogress] = createNprogress();
  175. var {
  176. start: startNavigationProgress,
  177. stop: stopNavigationProgress,
  178. reset: resetNavigationProgress,
  179. set: setNavigationProgress,
  180. increment: incrementNavigationProgress,
  181. decrement: decrementNavigationProgress,
  182. complete: completeNavigationProgress,
  183. cleanup: cleanupNavigationProgress
  184. } = nprogress;
  185.  
  186. // ../esmd/npm/@mantine/nprogress@7.11.1/node_modules/.pnpm/@mantine+nprogress@7.11.1_@mantine+core@7.11.1_@mantine+hooks@7.11.1_react-dom@18.3.1_react@18.3.1/node_modules/@mantine/nprogress/esm/NavigationProgress.module.css.mjs
  187. var classes = { "root": "m_8f2832ae", "section": "m_7a0fe999" };
  188.  
  189. // ../esmd/npm/@mantine/nprogress@7.11.1/node_modules/.pnpm/@mantine+nprogress@7.11.1_@mantine+core@7.11.1_@mantine+hooks@7.11.1_react-dom@18.3.1_react@18.3.1/node_modules/@mantine/nprogress/esm/NavigationProgress.mjs
  190. function NavigationProgress({
  191. initialProgress = 0,
  192. color,
  193. size = 3,
  194. stepInterval = 500,
  195. withinPortal = true,
  196. portalProps,
  197. zIndex = core.getDefaultZIndex("max"),
  198. store = nprogressStore,
  199. ...others
  200. }) {
  201. store.initialize({
  202. mounted: false,
  203. progress: initialProgress,
  204. interval: -1,
  205. step: 1,
  206. stepInterval,
  207. timeouts: []
  208. });
  209. const state = useNprogress(store);
  210. react.useEffect(() => () => resetNavigationProgressAction(store), [store]);
  211. return /* @__PURE__ */ jsxRuntime.jsx(core.OptionalPortal, { ...portalProps, withinPortal, children: /* @__PURE__ */ jsxRuntime.jsx(
  212. core.Progress,
  213. {
  214. radius: 0,
  215. value: state.progress,
  216. size,
  217. color,
  218. classNames: classes,
  219. "data-mounted": state.mounted || void 0,
  220. __vars: { "--nprogress-z-index": zIndex?.toString() },
  221. ...others
  222. }
  223. ) });
  224. }
  225. NavigationProgress.displayName = "@mantine/nprogress/NavigationProgress";
  226.  
  227. exports.NavigationProgress = NavigationProgress;
  228. exports.cleanupNavigationProgress = cleanupNavigationProgress;
  229. exports.cleanupNavigationProgressAction = cleanupNavigationProgressAction;
  230. exports.completeNavigationProgress = completeNavigationProgress;
  231. exports.completeNavigationProgressAction = completeNavigationProgressAction;
  232. exports.createNprogress = createNprogress;
  233. exports.createNprogressStore = createNprogressStore;
  234. exports.decrementNavigationProgress = decrementNavigationProgress;
  235. exports.decrementNavigationProgressAction = decrementNavigationProgressAction;
  236. exports.incrementNavigationProgress = incrementNavigationProgress;
  237. exports.incrementNavigationProgressAction = incrementNavigationProgressAction;
  238. exports.nprogress = nprogress;
  239. exports.nprogressStore = nprogressStore;
  240. exports.resetNavigationProgress = resetNavigationProgress;
  241. exports.resetNavigationProgressAction = resetNavigationProgressAction;
  242. exports.setNavigationProgress = setNavigationProgress;
  243. exports.setNavigationProgressAction = setNavigationProgressAction;
  244. exports.startNavigationProgress = startNavigationProgress;
  245. exports.startNavigationProgressAction = startNavigationProgressAction;
  246. exports.stopNavigationProgress = stopNavigationProgress;
  247. exports.stopNavigationProgressAction = stopNavigationProgressAction;
  248. exports.updateNavigationProgressStateAction = updateNavigationProgressStateAction;
  249. exports.useNprogress = useNprogress;
  250.  
  251. }));

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址