@inventreedb/ui 0.11.2 → 1.4.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.
Files changed (158) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/.vite/manifest.json +92 -5
  3. package/dist/components/Boundary.js +16 -7
  4. package/dist/components/Boundary.js.map +1 -1
  5. package/dist/components/InvenTreeTable.js +4 -3
  6. package/dist/components/InvenTreeTable.js.map +1 -1
  7. package/dist/components/RowActions.js +3 -2
  8. package/dist/components/RowActions.js.map +1 -1
  9. package/dist/components/StylishText.d.ts +6 -0
  10. package/dist/components/StylishText.js +36 -0
  11. package/dist/components/StylishText.js.map +1 -0
  12. package/dist/components/nav/DetailDrawer.css.d.ts +1 -0
  13. package/dist/components/nav/DetailDrawer.css.js +6 -0
  14. package/dist/components/nav/DetailDrawer.css.js.map +1 -0
  15. package/dist/components/nav/DetailDrawer.d.ts +22 -0
  16. package/dist/components/nav/DetailDrawer.js +66 -0
  17. package/dist/components/nav/DetailDrawer.js.map +1 -0
  18. package/dist/enums/ApiEndpoints.d.ts +1 -0
  19. package/dist/enums/ApiEndpoints.js +1 -0
  20. package/dist/enums/ApiEndpoints.js.map +1 -1
  21. package/dist/enums/ModelInformation.js +1 -0
  22. package/dist/enums/ModelInformation.js.map +1 -1
  23. package/dist/enums/ModelType.d.ts +9 -0
  24. package/dist/enums/ModelType.js.map +1 -1
  25. package/dist/enums/Roles.d.ts +1 -0
  26. package/dist/enums/Roles.js +1 -0
  27. package/dist/enums/Roles.js.map +1 -1
  28. package/dist/functions/Events.js +4 -3
  29. package/dist/functions/Events.js.map +1 -1
  30. package/dist/functions/Navigation.js +5 -2
  31. package/dist/functions/Navigation.js.map +1 -1
  32. package/dist/functions/Plugins.js +4 -2
  33. package/dist/functions/Plugins.js.map +1 -1
  34. package/dist/hooks/MonitorBackgroundTask.js +10 -8
  35. package/dist/hooks/MonitorBackgroundTask.js.map +1 -1
  36. package/dist/hooks/MonitorDataOutput.js +4 -3
  37. package/dist/hooks/MonitorDataOutput.js.map +1 -1
  38. package/dist/hooks/UseFilterSet.js +7 -6
  39. package/dist/hooks/UseFilterSet.js.map +1 -1
  40. package/dist/hooks/UseTable.js +1 -1
  41. package/dist/index.d.ts +5 -1
  42. package/dist/index.js +8 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js +40 -15
  45. package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js.map +1 -1
  46. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +1 -1
  47. package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -1
  48. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js +57 -62
  49. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js.map +1 -1
  50. package/dist/node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js.map +1 -1
  51. package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js +5 -3
  52. package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js.map +1 -1
  53. package/dist/node_modules/@mantine/hooks/esm/utils/random-id/random-id.js.map +1 -1
  54. package/dist/node_modules/@remix-run/router/dist/router.js +458 -0
  55. package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -0
  56. package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js +2 -2
  57. package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js.map +1 -1
  58. package/dist/node_modules/@sentry/core/build/esm/scope.js +6 -5
  59. package/dist/node_modules/@sentry/core/build/esm/scope.js.map +1 -1
  60. package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js +1 -1
  61. package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
  62. package/dist/node_modules/@sentry/core/build/esm/utils/is.js +1 -1
  63. package/dist/node_modules/@sentry/core/build/esm/utils/is.js.map +1 -1
  64. package/dist/node_modules/@sentry/core/build/esm/utils/misc.js +1 -1
  65. package/dist/node_modules/@sentry/core/build/esm/utils/misc.js.map +1 -1
  66. package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js +1 -1
  67. package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js.map +1 -1
  68. package/dist/node_modules/@sentry/core/build/esm/utils/time.js +1 -1
  69. package/dist/node_modules/@sentry/core/build/esm/utils/time.js.map +1 -1
  70. package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +6 -0
  71. package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
  72. package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +6 -0
  73. package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
  74. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js +6 -0
  75. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js.map +1 -1
  76. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +6 -0
  77. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
  78. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +6 -0
  79. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js.map +1 -1
  80. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +14 -0
  81. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -0
  82. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +6 -0
  83. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
  84. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +6 -0
  85. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
  86. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +6 -0
  87. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
  88. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +6 -0
  89. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
  90. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +6 -0
  91. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
  92. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +6 -0
  93. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
  94. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +6 -0
  95. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
  96. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +6 -0
  97. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
  98. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +6 -0
  99. package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
  100. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +31 -20
  101. package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
  102. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +27 -17
  103. package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
  104. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +179 -177
  105. package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
  106. package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +31 -21
  107. package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -1
  108. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +1 -1
  109. package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
  110. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +1 -1
  111. package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -1
  112. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -4
  113. package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
  114. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +10 -1
  115. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
  116. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +10 -1
  117. package/dist/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -1
  118. package/dist/node_modules/react-router/dist/index.js +714 -0
  119. package/dist/node_modules/react-router/dist/index.js.map +1 -0
  120. package/dist/node_modules/react-router-dom/dist/index.js +536 -0
  121. package/dist/node_modules/react-router-dom/dist/index.js.map +1 -0
  122. package/dist/node_modules/zustand/esm/react/shallow.js +13 -0
  123. package/dist/node_modules/zustand/esm/react/shallow.js.map +1 -0
  124. package/dist/node_modules/zustand/esm/vanilla/shallow.js +57 -0
  125. package/dist/node_modules/zustand/esm/vanilla/shallow.js.map +1 -0
  126. package/dist/states/LocalLibState.d.ts +17 -0
  127. package/dist/states/LocalLibState.js +16 -0
  128. package/dist/states/LocalLibState.js.map +1 -0
  129. package/dist/states/StoredTableState.js +2 -1
  130. package/dist/states/StoredTableState.js.map +1 -1
  131. package/dist/states/types.d.ts +3 -0
  132. package/dist/types/Forms.d.ts +13 -6
  133. package/dist/types/Panel.d.ts +26 -0
  134. package/dist/types/Plugins.d.ts +14 -2
  135. package/dist/types/Plugins.js +2 -2
  136. package/dist/types/Plugins.js.map +1 -1
  137. package/dist/types/Rendering.d.ts +53 -0
  138. package/dist/types/Tables.d.ts +5 -1
  139. package/dist/ui.css +4 -0
  140. package/lib/components/Boundary.tsx +6 -3
  141. package/lib/components/RowActions.tsx +2 -2
  142. package/lib/components/StylishText.tsx +46 -0
  143. package/lib/components/nav/DetailDrawer.css.ts +6 -0
  144. package/lib/components/nav/DetailDrawer.tsx +108 -0
  145. package/lib/enums/ApiEndpoints.tsx +1 -0
  146. package/lib/enums/ModelInformation.tsx +1 -0
  147. package/lib/enums/ModelType.tsx +13 -0
  148. package/lib/enums/Roles.tsx +1 -0
  149. package/lib/hooks/UseFilterSet.tsx +8 -8
  150. package/lib/index.ts +16 -0
  151. package/lib/states/LocalLibState.tsx +23 -0
  152. package/lib/states/types.tsx +7 -0
  153. package/lib/types/Forms.tsx +13 -6
  154. package/lib/types/Panel.tsx +30 -0
  155. package/lib/types/Plugins.tsx +20 -1
  156. package/lib/types/Rendering.tsx +60 -0
  157. package/lib/types/Tables.tsx +5 -1
  158. package/package.json +20 -17
@@ -0,0 +1,536 @@
1
+ import { UNSAFE_NavigationContext as NavigationContext, useHref, useNavigate, useLocation, useResolvedPath, UNSAFE_DataRouterStateContext as DataRouterStateContext, UNSAFE_useRouteId as useRouteId, UNSAFE_RouteContext as RouteContext, UNSAFE_DataRouterContext as DataRouterContext } from "../../react-router/dist/index.js";
2
+ import { Route, Routes, UNSAFE_LocationContext, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromChildren2, useInRouterContext, useParams, useRouteError, useRoutes } from "../../react-router/dist/index.js";
3
+ import { stripBasename, UNSAFE_warning as warning, createPath, UNSAFE_invariant as invariant, matchPath, joinPaths } from "../../@remix-run/router/dist/router.js";
4
+ import { AbortedDeferredError, Action, isRouteErrorResponse, matchRoutes, parsePath, resolvePath } from "../../@remix-run/router/dist/router.js";
5
+ /**
6
+ * React Router DOM v6.30.3
7
+ *
8
+ * Copyright (c) Remix Software Inc.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE.md file in the root directory of this source tree.
12
+ *
13
+ * @license MIT
14
+ */
15
+ const React = window["React"];
16
+ const ReactDOM = window["ReactDOM"];
17
+ function _extends() {
18
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
19
+ for (var i = 1; i < arguments.length; i++) {
20
+ var source = arguments[i];
21
+ for (var key in source) {
22
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
23
+ target[key] = source[key];
24
+ }
25
+ }
26
+ }
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
31
+ function _objectWithoutPropertiesLoose(source, excluded) {
32
+ if (source == null) return {};
33
+ var target = {};
34
+ var sourceKeys = Object.keys(source);
35
+ var key, i;
36
+ for (i = 0; i < sourceKeys.length; i++) {
37
+ key = sourceKeys[i];
38
+ if (excluded.indexOf(key) >= 0) continue;
39
+ target[key] = source[key];
40
+ }
41
+ return target;
42
+ }
43
+ const defaultMethod = "get";
44
+ const defaultEncType = "application/x-www-form-urlencoded";
45
+ function isHtmlElement(object) {
46
+ return object != null && typeof object.tagName === "string";
47
+ }
48
+ function isButtonElement(object) {
49
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
50
+ }
51
+ function isFormElement(object) {
52
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
53
+ }
54
+ function isInputElement(object) {
55
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
56
+ }
57
+ function isModifiedEvent(event) {
58
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
59
+ }
60
+ function shouldProcessLinkClick(event, target) {
61
+ return event.button === 0 && // Ignore everything but left clicks
62
+ (!target || target === "_self") && // Let browser handle "target=_blank" etc.
63
+ !isModifiedEvent(event);
64
+ }
65
+ let _formDataSupportsSubmitter = null;
66
+ function isFormDataSubmitterSupported() {
67
+ if (_formDataSupportsSubmitter === null) {
68
+ try {
69
+ new FormData(
70
+ document.createElement("form"),
71
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
72
+ 0
73
+ );
74
+ _formDataSupportsSubmitter = false;
75
+ } catch (e) {
76
+ _formDataSupportsSubmitter = true;
77
+ }
78
+ }
79
+ return _formDataSupportsSubmitter;
80
+ }
81
+ const supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
82
+ function getFormEncType(encType) {
83
+ if (encType != null && !supportedFormEncTypes.has(encType)) {
84
+ process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
85
+ return null;
86
+ }
87
+ return encType;
88
+ }
89
+ function getFormSubmissionInfo(target, basename) {
90
+ let method;
91
+ let action;
92
+ let encType;
93
+ let formData;
94
+ let body;
95
+ if (isFormElement(target)) {
96
+ let attr = target.getAttribute("action");
97
+ action = attr ? stripBasename(attr, basename) : null;
98
+ method = target.getAttribute("method") || defaultMethod;
99
+ encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
100
+ formData = new FormData(target);
101
+ } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
102
+ let form = target.form;
103
+ if (form == null) {
104
+ throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
105
+ }
106
+ let attr = target.getAttribute("formaction") || form.getAttribute("action");
107
+ action = attr ? stripBasename(attr, basename) : null;
108
+ method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
109
+ encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
110
+ formData = new FormData(form, target);
111
+ if (!isFormDataSubmitterSupported()) {
112
+ let {
113
+ name,
114
+ type,
115
+ value
116
+ } = target;
117
+ if (type === "image") {
118
+ let prefix = name ? name + "." : "";
119
+ formData.append(prefix + "x", "0");
120
+ formData.append(prefix + "y", "0");
121
+ } else if (name) {
122
+ formData.append(name, value);
123
+ }
124
+ }
125
+ } else if (isHtmlElement(target)) {
126
+ throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
127
+ } else {
128
+ method = defaultMethod;
129
+ action = null;
130
+ encType = defaultEncType;
131
+ body = target;
132
+ }
133
+ if (formData && encType === "text/plain") {
134
+ body = formData;
135
+ formData = void 0;
136
+ }
137
+ return {
138
+ action,
139
+ method: method.toLowerCase(),
140
+ encType,
141
+ formData,
142
+ body
143
+ };
144
+ }
145
+ const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"], _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
146
+ const REACT_ROUTER_VERSION = "6";
147
+ try {
148
+ window.__reactRouterVersion = REACT_ROUTER_VERSION;
149
+ } catch (e) {
150
+ }
151
+ const ViewTransitionContext = /* @__PURE__ */ React.createContext({
152
+ isTransitioning: false
153
+ });
154
+ if (process.env.NODE_ENV !== "production") {
155
+ ViewTransitionContext.displayName = "ViewTransition";
156
+ }
157
+ const FetchersContext = /* @__PURE__ */ React.createContext(/* @__PURE__ */ new Map());
158
+ if (process.env.NODE_ENV !== "production") {
159
+ FetchersContext.displayName = "Fetchers";
160
+ }
161
+ const START_TRANSITION = "startTransition";
162
+ React[START_TRANSITION];
163
+ const FLUSH_SYNC = "flushSync";
164
+ ReactDOM[FLUSH_SYNC];
165
+ const USE_ID = "useId";
166
+ React[USE_ID];
167
+ if (process.env.NODE_ENV !== "production") ;
168
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
169
+ const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
170
+ const Link = /* @__PURE__ */ React.forwardRef(function LinkWithRef(_ref7, ref) {
171
+ let {
172
+ onClick,
173
+ relative,
174
+ reloadDocument,
175
+ replace,
176
+ state,
177
+ target,
178
+ to,
179
+ preventScrollReset,
180
+ viewTransition
181
+ } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
182
+ let {
183
+ basename
184
+ } = React.useContext(NavigationContext);
185
+ let absoluteHref;
186
+ let isExternal = false;
187
+ if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
188
+ absoluteHref = to;
189
+ if (isBrowser) {
190
+ try {
191
+ let currentUrl = new URL(window.location.href);
192
+ let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
193
+ let path = stripBasename(targetUrl.pathname, basename);
194
+ if (targetUrl.origin === currentUrl.origin && path != null) {
195
+ to = path + targetUrl.search + targetUrl.hash;
196
+ } else {
197
+ isExternal = true;
198
+ }
199
+ } catch (e) {
200
+ process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
201
+ }
202
+ }
203
+ }
204
+ let href = useHref(to, {
205
+ relative
206
+ });
207
+ let internalOnClick = useLinkClickHandler(to, {
208
+ replace,
209
+ state,
210
+ target,
211
+ preventScrollReset,
212
+ relative,
213
+ viewTransition
214
+ });
215
+ function handleClick(event) {
216
+ if (onClick) onClick(event);
217
+ if (!event.defaultPrevented) {
218
+ internalOnClick(event);
219
+ }
220
+ }
221
+ return (
222
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
223
+ /* @__PURE__ */ React.createElement("a", _extends({}, rest, {
224
+ href: absoluteHref || href,
225
+ onClick: isExternal || reloadDocument ? onClick : handleClick,
226
+ ref,
227
+ target
228
+ }))
229
+ );
230
+ });
231
+ if (process.env.NODE_ENV !== "production") {
232
+ Link.displayName = "Link";
233
+ }
234
+ const NavLink = /* @__PURE__ */ React.forwardRef(function NavLinkWithRef(_ref8, ref) {
235
+ let {
236
+ "aria-current": ariaCurrentProp = "page",
237
+ caseSensitive = false,
238
+ className: classNameProp = "",
239
+ end = false,
240
+ style: styleProp,
241
+ to,
242
+ viewTransition,
243
+ children
244
+ } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
245
+ let path = useResolvedPath(to, {
246
+ relative: rest.relative
247
+ });
248
+ let location = useLocation();
249
+ let routerState = React.useContext(DataRouterStateContext);
250
+ let {
251
+ navigator,
252
+ basename
253
+ } = React.useContext(NavigationContext);
254
+ let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
255
+ // eslint-disable-next-line react-hooks/rules-of-hooks
256
+ useViewTransitionState(path) && viewTransition === true;
257
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
258
+ let locationPathname = location.pathname;
259
+ let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
260
+ if (!caseSensitive) {
261
+ locationPathname = locationPathname.toLowerCase();
262
+ nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
263
+ toPathname = toPathname.toLowerCase();
264
+ }
265
+ if (nextLocationPathname && basename) {
266
+ nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
267
+ }
268
+ const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
269
+ let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
270
+ let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
271
+ let renderProps = {
272
+ isActive,
273
+ isPending,
274
+ isTransitioning
275
+ };
276
+ let ariaCurrent = isActive ? ariaCurrentProp : void 0;
277
+ let className;
278
+ if (typeof classNameProp === "function") {
279
+ className = classNameProp(renderProps);
280
+ } else {
281
+ className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
282
+ }
283
+ let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
284
+ return /* @__PURE__ */ React.createElement(Link, _extends({}, rest, {
285
+ "aria-current": ariaCurrent,
286
+ className,
287
+ ref,
288
+ style,
289
+ to,
290
+ viewTransition
291
+ }), typeof children === "function" ? children(renderProps) : children);
292
+ });
293
+ if (process.env.NODE_ENV !== "production") {
294
+ NavLink.displayName = "NavLink";
295
+ }
296
+ const Form = /* @__PURE__ */ React.forwardRef((_ref9, forwardedRef) => {
297
+ let {
298
+ fetcherKey,
299
+ navigate,
300
+ reloadDocument,
301
+ replace,
302
+ state,
303
+ method = defaultMethod,
304
+ action,
305
+ onSubmit,
306
+ relative,
307
+ preventScrollReset,
308
+ viewTransition
309
+ } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
310
+ let submit = useSubmit();
311
+ let formAction = useFormAction(action, {
312
+ relative
313
+ });
314
+ let formMethod = method.toLowerCase() === "get" ? "get" : "post";
315
+ let submitHandler = (event) => {
316
+ onSubmit && onSubmit(event);
317
+ if (event.defaultPrevented) return;
318
+ event.preventDefault();
319
+ let submitter = event.nativeEvent.submitter;
320
+ let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
321
+ submit(submitter || event.currentTarget, {
322
+ fetcherKey,
323
+ method: submitMethod,
324
+ navigate,
325
+ replace,
326
+ state,
327
+ relative,
328
+ preventScrollReset,
329
+ viewTransition
330
+ });
331
+ };
332
+ return /* @__PURE__ */ React.createElement("form", _extends({
333
+ ref: forwardedRef,
334
+ method: formMethod,
335
+ action: formAction,
336
+ onSubmit: reloadDocument ? onSubmit : submitHandler
337
+ }, props));
338
+ });
339
+ if (process.env.NODE_ENV !== "production") {
340
+ Form.displayName = "Form";
341
+ }
342
+ if (process.env.NODE_ENV !== "production") ;
343
+ var DataRouterHook;
344
+ (function(DataRouterHook2) {
345
+ DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
346
+ DataRouterHook2["UseSubmit"] = "useSubmit";
347
+ DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
348
+ DataRouterHook2["UseFetcher"] = "useFetcher";
349
+ DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
350
+ })(DataRouterHook || (DataRouterHook = {}));
351
+ var DataRouterStateHook;
352
+ (function(DataRouterStateHook2) {
353
+ DataRouterStateHook2["UseFetcher"] = "useFetcher";
354
+ DataRouterStateHook2["UseFetchers"] = "useFetchers";
355
+ DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
356
+ })(DataRouterStateHook || (DataRouterStateHook = {}));
357
+ function getDataRouterConsoleError(hookName) {
358
+ return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
359
+ }
360
+ function useDataRouterContext(hookName) {
361
+ let ctx = React.useContext(DataRouterContext);
362
+ !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
363
+ return ctx;
364
+ }
365
+ function useLinkClickHandler(to, _temp) {
366
+ let {
367
+ target,
368
+ replace: replaceProp,
369
+ state,
370
+ preventScrollReset,
371
+ relative,
372
+ viewTransition
373
+ } = _temp === void 0 ? {} : _temp;
374
+ let navigate = useNavigate();
375
+ let location = useLocation();
376
+ let path = useResolvedPath(to, {
377
+ relative
378
+ });
379
+ return React.useCallback((event) => {
380
+ if (shouldProcessLinkClick(event, target)) {
381
+ event.preventDefault();
382
+ let replace = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
383
+ navigate(to, {
384
+ replace,
385
+ state,
386
+ preventScrollReset,
387
+ relative,
388
+ viewTransition
389
+ });
390
+ }
391
+ }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
392
+ }
393
+ function validateClientSideSubmission() {
394
+ if (typeof document === "undefined") {
395
+ throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
396
+ }
397
+ }
398
+ let fetcherId = 0;
399
+ let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
400
+ function useSubmit() {
401
+ let {
402
+ router
403
+ } = useDataRouterContext(DataRouterHook.UseSubmit);
404
+ let {
405
+ basename
406
+ } = React.useContext(NavigationContext);
407
+ let currentRouteId = useRouteId();
408
+ return React.useCallback(function(target, options) {
409
+ if (options === void 0) {
410
+ options = {};
411
+ }
412
+ validateClientSideSubmission();
413
+ let {
414
+ action,
415
+ method,
416
+ encType,
417
+ formData,
418
+ body
419
+ } = getFormSubmissionInfo(target, basename);
420
+ if (options.navigate === false) {
421
+ let key = options.fetcherKey || getUniqueFetcherId();
422
+ router.fetch(key, currentRouteId, options.action || action, {
423
+ preventScrollReset: options.preventScrollReset,
424
+ formData,
425
+ body,
426
+ formMethod: options.method || method,
427
+ formEncType: options.encType || encType,
428
+ flushSync: options.flushSync
429
+ });
430
+ } else {
431
+ router.navigate(options.action || action, {
432
+ preventScrollReset: options.preventScrollReset,
433
+ formData,
434
+ body,
435
+ formMethod: options.method || method,
436
+ formEncType: options.encType || encType,
437
+ replace: options.replace,
438
+ state: options.state,
439
+ fromRouteId: currentRouteId,
440
+ flushSync: options.flushSync,
441
+ viewTransition: options.viewTransition
442
+ });
443
+ }
444
+ }, [router, basename, currentRouteId]);
445
+ }
446
+ function useFormAction(action, _temp2) {
447
+ let {
448
+ relative
449
+ } = _temp2 === void 0 ? {} : _temp2;
450
+ let {
451
+ basename
452
+ } = React.useContext(NavigationContext);
453
+ let routeContext = React.useContext(RouteContext);
454
+ !routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
455
+ let [match] = routeContext.matches.slice(-1);
456
+ let path = _extends({}, useResolvedPath(action ? action : ".", {
457
+ relative
458
+ }));
459
+ let location = useLocation();
460
+ if (action == null) {
461
+ path.search = location.search;
462
+ let params = new URLSearchParams(path.search);
463
+ let indexValues = params.getAll("index");
464
+ let hasNakedIndexParam = indexValues.some((v) => v === "");
465
+ if (hasNakedIndexParam) {
466
+ params.delete("index");
467
+ indexValues.filter((v) => v).forEach((v) => params.append("index", v));
468
+ let qs = params.toString();
469
+ path.search = qs ? "?" + qs : "";
470
+ }
471
+ }
472
+ if ((!action || action === ".") && match.route.index) {
473
+ path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
474
+ }
475
+ if (basename !== "/") {
476
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
477
+ }
478
+ return createPath(path);
479
+ }
480
+ function useViewTransitionState(to, opts) {
481
+ if (opts === void 0) {
482
+ opts = {};
483
+ }
484
+ let vtContext = React.useContext(ViewTransitionContext);
485
+ !(vtContext != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
486
+ let {
487
+ basename
488
+ } = useDataRouterContext(DataRouterHook.useViewTransitionState);
489
+ let path = useResolvedPath(to, {
490
+ relative: opts.relative
491
+ });
492
+ if (!vtContext.isTransitioning) {
493
+ return false;
494
+ }
495
+ let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
496
+ let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
497
+ return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
498
+ }
499
+ export {
500
+ AbortedDeferredError,
501
+ Form,
502
+ Link,
503
+ NavLink,
504
+ Action as NavigationType,
505
+ Route,
506
+ Routes,
507
+ DataRouterContext as UNSAFE_DataRouterContext,
508
+ DataRouterStateContext as UNSAFE_DataRouterStateContext,
509
+ FetchersContext as UNSAFE_FetchersContext,
510
+ UNSAFE_LocationContext,
511
+ NavigationContext as UNSAFE_NavigationContext,
512
+ RouteContext as UNSAFE_RouteContext,
513
+ ViewTransitionContext as UNSAFE_ViewTransitionContext,
514
+ useRouteId as UNSAFE_useRouteId,
515
+ createPath,
516
+ createRoutesFromChildren,
517
+ createRoutesFromChildren2 as createRoutesFromElements,
518
+ isRouteErrorResponse,
519
+ matchPath,
520
+ matchRoutes,
521
+ parsePath,
522
+ resolvePath,
523
+ useFormAction,
524
+ useHref,
525
+ useInRouterContext,
526
+ useLinkClickHandler,
527
+ useLocation,
528
+ useNavigate,
529
+ useParams,
530
+ useResolvedPath,
531
+ useRouteError,
532
+ useRoutes,
533
+ useSubmit,
534
+ useViewTransitionState
535
+ };
536
+ //# sourceMappingURL=index.js.map