@inventreedb/ui 0.11.3 → 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.
- package/CHANGELOG.md +25 -0
- package/dist/.vite/manifest.json +6 -5
- package/dist/components/InvenTreeTable.js +4 -3
- package/dist/components/InvenTreeTable.js.map +1 -1
- package/dist/components/RowActions.js +3 -2
- package/dist/components/RowActions.js.map +1 -1
- package/dist/components/nav/DetailDrawer.d.ts +1 -0
- package/dist/components/nav/DetailDrawer.js +1 -0
- package/dist/components/nav/DetailDrawer.js.map +1 -1
- package/dist/enums/ModelInformation.js +1 -0
- package/dist/enums/ModelInformation.js.map +1 -1
- package/dist/functions/Events.js +4 -3
- package/dist/functions/Events.js.map +1 -1
- package/dist/functions/Navigation.js +5 -2
- package/dist/functions/Navigation.js.map +1 -1
- package/dist/functions/Plugins.js +4 -2
- package/dist/functions/Plugins.js.map +1 -1
- package/dist/hooks/MonitorBackgroundTask.js +10 -8
- package/dist/hooks/MonitorBackgroundTask.js.map +1 -1
- package/dist/hooks/MonitorDataOutput.js +4 -3
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/hooks/UseFilterSet.js +7 -6
- package/dist/hooks/UseFilterSet.js.map +1 -1
- package/dist/hooks/UseTable.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js +40 -15
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js +57 -62
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js +5 -3
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/utils/random-id/random-id.js.map +1 -1
- package/dist/node_modules/@remix-run/router/dist/router.js +10 -0
- package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -1
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js +2 -2
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/scope.js +6 -5
- package/dist/node_modules/@sentry/core/build/esm/scope.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +31 -20
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +27 -17
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +179 -177
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +31 -21
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -4
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -1
- package/dist/node_modules/react-router/dist/index.js +11 -1
- package/dist/node_modules/react-router/dist/index.js.map +1 -1
- package/dist/node_modules/react-router-dom/dist/index.js +10 -0
- package/dist/node_modules/react-router-dom/dist/index.js.map +1 -1
- package/dist/states/StoredTableState.js +2 -1
- package/dist/states/StoredTableState.js.map +1 -1
- package/dist/states/types.d.ts +3 -0
- package/dist/types/Forms.d.ts +2 -0
- package/dist/types/Panel.d.ts +26 -0
- package/dist/types/Plugins.d.ts +14 -2
- package/dist/types/Plugins.js +2 -2
- package/dist/types/Plugins.js.map +1 -1
- package/dist/types/Rendering.d.ts +53 -0
- package/dist/types/Tables.d.ts +3 -1
- package/lib/components/RowActions.tsx +2 -2
- package/lib/components/nav/DetailDrawer.tsx +1 -1
- package/lib/enums/ModelInformation.tsx +1 -0
- package/lib/hooks/UseFilterSet.tsx +8 -8
- package/lib/index.ts +9 -1
- package/lib/states/types.tsx +7 -0
- package/lib/types/Forms.tsx +2 -0
- package/lib/types/Panel.tsx +30 -0
- package/lib/types/Plugins.tsx +20 -1
- package/lib/types/Rendering.tsx +60 -0
- package/lib/types/Tables.tsx +3 -1
- package/package.json +18 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonitorDataOutput.js","sources":["../../lib/hooks/MonitorDataOutput.tsx"],"sourcesContent":["import { t } from '@lingui/core/macro';\nimport { useDocumentVisibility } from '@mantine/hooks';\nimport { notifications, showNotification } from '@mantine/notifications';\nimport { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';\nimport { type QueryClient, useQuery } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport { useEffect, useState } from 'react';\nimport { ProgressBar } from '../components/ProgressBar';\nimport { ApiEndpoints } from '../enums/ApiEndpoints';\nimport { apiUrl } from '../functions/Api';\n\nexport type MonitorDataOutputProps = {\n api: AxiosInstance;\n queryClient?: QueryClient;\n title: string;\n hostname?: string;\n id?: number;\n};\n\n/**\n * Hook for monitoring a data output process running on the server\n */\nexport default function useMonitorDataOutput(props: MonitorDataOutputProps) {\n const visibility = useDocumentVisibility();\n\n const [loading, setLoading] = useState<boolean>(false);\n\n useEffect(() => {\n if (!!props.id) {\n setLoading(true);\n showNotification({\n id: `data-output-${props.id}`,\n title: props.title,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: <ProgressBar size='lg' value={0} progressLabel />\n });\n } else setLoading(false);\n }, [props.id, props.title]);\n\n useQuery(\n {\n enabled: !!props.id && loading && visibility === 'visible',\n refetchInterval: 500,\n queryKey: ['data-output', props.id, props.title],\n queryFn: () =>\n props.api\n .get(apiUrl(ApiEndpoints.data_output, props.id))\n .then((response) => {\n const data = response?.data ?? {};\n\n if (!!data.errors || !!data.error) {\n setLoading(false);\n\n const error: string =\n data?.error ?? data?.errors?.error ?? t`Process failed`;\n\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n icon: <IconExclamationCircle />,\n autoClose: 2500,\n title: props.title,\n message: error,\n color: 'red'\n });\n } else if (data.complete) {\n setLoading(false);\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n autoClose: 2500,\n title: props.title,\n message: t`Process completed successfully`,\n color: 'green',\n icon: <IconCircleCheck />\n });\n\n if (data.output) {\n const url = data.output;\n const base = props.hostname ?? window.location.origin;\n\n const downloadUrl = new URL(url, base);\n\n window.open(downloadUrl.toString(), '_blank');\n }\n } else {\n notifications.update({\n id: `data-output-${props.id}`,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: (\n <ProgressBar\n size='lg'\n maximum={data.total}\n value={data.progress}\n progressLabel={data.total > 0}\n animated\n />\n )\n });\n }\n\n return data;\n })\n .catch((error: Error) => {\n console.error('Error in useMonitorDataOutput:', error);\n setLoading(false);\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n autoClose: 2500,\n title: props.title,\n message: error.message || t`Process failed`,\n color: 'red'\n });\n return {};\n })\n },\n props.queryClient\n );\n}\n"],"names":["useMonitorDataOutput","props","visibility","useDocumentVisibility","loading","setLoading","useState","useEffect","id","showNotification","title","autoClose","withCloseButton","message","useQuery","enabled","refetchInterval","queryKey","queryFn","api","get","apiUrl","ApiEndpoints","data_output","then","response","data","errors","error","_i18n","_","notifications","update","icon","color","complete","output","url","base","hostname","window","location","origin","downloadUrl","URL","open","toString","jsx","total","progress","catch","console","queryClient"],"mappings":";;;;;;;;AAAA,MAAA,QAAA,OAAA,YAAA,EAAA;AAEA,MAAA,gBAAA,OAAA,sBAAA,EAAA;;AAIA,MAAA,YAAA,OAAA,OAAA,EAAA;;AAgBA,SAAwBA,qBAAqBC,OAA+B;AAC1E,QAAMC,aAAaC,sBAAAA;AAEnB,QAAM,CAACC,SAASC,UAAU,IAAIC,SAAkB,KAAK;AAErDC,YAAU,MAAM;AACd,QAAI,CAAC,CAACN,MAAMO,IAAI;AACdH,iBAAW,IAAI;AACfI,uBAAiB;AAAA,QACfD,IAAI,eAAeP,MAAMO,EAAE;AAAA,QAC3BE,OAAOT,MAAMS;AAAAA,QACbN,SAAS;AAAA,QACTO,WAAW;AAAA,QACXC,iBAAiB;AAAA,QACjBC,+CAAU,aAAA,EAAY,MAAK,MAAK,OAAO,GAAG,eAAa,KAAA,CAAA;AAAA,MAAA,CACxD;AAAA,IACH,kBAAkB,KAAK;AAAA,EACzB,GAAG,CAACZ,MAAMO,IAAIP,MAAMS,KAAK,CAAC;AAE1BI,WACE;AAAA,IACEC,SAAS,CAAC,CAACd,MAAMO,MAAMJ,WAAWF,eAAe;AAAA,IACjDc,iBAAiB;AAAA,IACjBC,UAAU,CAAC,eAAehB,MAAMO,IAAIP,MAAMS,KAAK;AAAA,IAC/CQ,SAASA,MACPjB,MAAMkB,IACHC,IAAIC,OAAOC,aAAaC,aAAatB,MAAMO,EAAE,CAAC,EAC9CgB,KAAMC,CAAAA,aAAa
|
|
1
|
+
{"version":3,"file":"MonitorDataOutput.js","sources":["../../lib/hooks/MonitorDataOutput.tsx"],"sourcesContent":["import { t } from '@lingui/core/macro';\nimport { useDocumentVisibility } from '@mantine/hooks';\nimport { notifications, showNotification } from '@mantine/notifications';\nimport { IconCircleCheck, IconExclamationCircle } from '@tabler/icons-react';\nimport { type QueryClient, useQuery } from '@tanstack/react-query';\nimport type { AxiosInstance } from 'axios';\nimport { useEffect, useState } from 'react';\nimport { ProgressBar } from '../components/ProgressBar';\nimport { ApiEndpoints } from '../enums/ApiEndpoints';\nimport { apiUrl } from '../functions/Api';\n\nexport type MonitorDataOutputProps = {\n api: AxiosInstance;\n queryClient?: QueryClient;\n title: string;\n hostname?: string;\n id?: number;\n};\n\n/**\n * Hook for monitoring a data output process running on the server\n */\nexport default function useMonitorDataOutput(props: MonitorDataOutputProps) {\n const visibility = useDocumentVisibility();\n\n const [loading, setLoading] = useState<boolean>(false);\n\n useEffect(() => {\n if (!!props.id) {\n setLoading(true);\n showNotification({\n id: `data-output-${props.id}`,\n title: props.title,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: <ProgressBar size='lg' value={0} progressLabel />\n });\n } else setLoading(false);\n }, [props.id, props.title]);\n\n useQuery(\n {\n enabled: !!props.id && loading && visibility === 'visible',\n refetchInterval: 500,\n queryKey: ['data-output', props.id, props.title],\n queryFn: () =>\n props.api\n .get(apiUrl(ApiEndpoints.data_output, props.id))\n .then((response) => {\n const data = response?.data ?? {};\n\n if (!!data.errors || !!data.error) {\n setLoading(false);\n\n const error: string =\n data?.error ?? data?.errors?.error ?? t`Process failed`;\n\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n icon: <IconExclamationCircle />,\n autoClose: 2500,\n title: props.title,\n message: error,\n color: 'red'\n });\n } else if (data.complete) {\n setLoading(false);\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n autoClose: 2500,\n title: props.title,\n message: t`Process completed successfully`,\n color: 'green',\n icon: <IconCircleCheck />\n });\n\n if (data.output) {\n const url = data.output;\n const base = props.hostname ?? window.location.origin;\n\n const downloadUrl = new URL(url, base);\n\n window.open(downloadUrl.toString(), '_blank');\n }\n } else {\n notifications.update({\n id: `data-output-${props.id}`,\n loading: true,\n autoClose: false,\n withCloseButton: false,\n message: (\n <ProgressBar\n size='lg'\n maximum={data.total}\n value={data.progress}\n progressLabel={data.total > 0}\n animated\n />\n )\n });\n }\n\n return data;\n })\n .catch((error: Error) => {\n console.error('Error in useMonitorDataOutput:', error);\n setLoading(false);\n notifications.update({\n id: `data-output-${props.id}`,\n loading: false,\n autoClose: 2500,\n title: props.title,\n message: error.message || t`Process failed`,\n color: 'red'\n });\n return {};\n })\n },\n props.queryClient\n );\n}\n"],"names":["useMonitorDataOutput","props","visibility","useDocumentVisibility","loading","setLoading","useState","useEffect","id","showNotification","title","autoClose","withCloseButton","message","useQuery","enabled","refetchInterval","queryKey","queryFn","api","get","apiUrl","ApiEndpoints","data_output","then","response","data","errors","error","_i18n","_","notifications","update","icon","color","complete","output","url","base","hostname","window","location","origin","downloadUrl","URL","open","toString","jsx","total","progress","catch","console","queryClient"],"mappings":";;;;;;;;AAAA,MAAA,QAAA,OAAA,YAAA,EAAA;AAEA,MAAA,gBAAA,OAAA,sBAAA,EAAA;;AAIA,MAAA,YAAA,OAAA,OAAA,EAAA;;AAgBA,SAAwBA,qBAAqBC,OAA+B;AAC1E,QAAMC,aAAaC,sBAAAA;AAEnB,QAAM,CAACC,SAASC,UAAU,IAAIC,SAAkB,KAAK;AAErDC,YAAU,MAAM;AACd,QAAI,CAAC,CAACN,MAAMO,IAAI;AACdH,iBAAW,IAAI;AACfI,uBAAiB;AAAA,QACfD,IAAI,eAAeP,MAAMO,EAAE;AAAA,QAC3BE,OAAOT,MAAMS;AAAAA,QACbN,SAAS;AAAA,QACTO,WAAW;AAAA,QACXC,iBAAiB;AAAA,QACjBC,+CAAU,aAAA,EAAY,MAAK,MAAK,OAAO,GAAG,eAAa,KAAA,CAAA;AAAA,MAAA,CACxD;AAAA,IACH,kBAAkB,KAAK;AAAA,EACzB,GAAG,CAACZ,MAAMO,IAAIP,MAAMS,KAAK,CAAC;AAE1BI,WACE;AAAA,IACEC,SAAS,CAAC,CAACd,MAAMO,MAAMJ,WAAWF,eAAe;AAAA,IACjDc,iBAAiB;AAAA,IACjBC,UAAU,CAAC,eAAehB,MAAMO,IAAIP,MAAMS,KAAK;AAAA,IAC/CQ,SAASA,MACPjB,MAAMkB,IACHC,IAAIC,OAAOC,aAAaC,aAAatB,MAAMO,EAAE,CAAC,EAC9CgB,KAAMC,CAAAA,aAAa;;AAClB,YAAMC,QAAOD,qCAAUC,SAAQ,CAA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,OACd,OAAOtB,KAAKuB,UACZ,eAAevB,KAAKsB,QAAQ,GAC5B,UAAQ,KAAA,CAAA;AAAA,QAAA,CAGb;AAAA,MACH;AAEA,aAAOtB;AAAAA,IACT,CAAC,EACAwB,MAAM,CAACtB,UAAiB;AACvBuB,cAAQvB,MAAM,kCAAkCA,KAAK;AACrDvB,iBAAW,KAAK;AAChB0B,oBAAcC,OAAO;AAAA,QACnBxB,IAAI,eAAeP,MAAMO,EAAE;AAAA,QAC3BJ,SAAS;AAAA,QACTO,WAAW;AAAA,QACXD,OAAOT,MAAMS;AAAAA,QACbG,SAASe,MAAMf,WAAOgB,MAAAC;AAAAA;AAAAA,UAAI;AAAA,YAAAtB,IAAA;AAAA,UAAA;AAAA,QAAgB;AAAA,QAC1C0B,OAAO;AAAA,MAAA,CACR;AACD,aAAO,CAAA;AAAA,IACT,CAAC;AAAA,EAAA,GAEPjC,MAAMmD,WACR;AACF;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useLocalStorage } from "../node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js";
|
|
2
2
|
const useCallback = window["React"].useCallback;
|
|
3
|
+
const useEffect = window["React"].useEffect;
|
|
3
4
|
const useMemo = window["React"].useMemo;
|
|
4
5
|
function useFilterSet(filterKey, initialFilters) {
|
|
5
6
|
const [storedFilters, setStoredFilters] = useLocalStorage({
|
|
@@ -8,14 +9,14 @@ function useFilterSet(filterKey, initialFilters) {
|
|
|
8
9
|
sync: false,
|
|
9
10
|
getInitialValueInEffect: false
|
|
10
11
|
});
|
|
11
|
-
|
|
12
|
+
useEffect(() => {
|
|
12
13
|
if (storedFilters == null) {
|
|
13
|
-
|
|
14
|
-
setStoredFilters(filters);
|
|
15
|
-
return filters;
|
|
14
|
+
setStoredFilters(initialFilters || []);
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
}, [storedFilters, initialFilters, setStoredFilters]);
|
|
17
|
+
const activeFilters = useMemo(() => {
|
|
18
|
+
return storedFilters ?? initialFilters ?? [];
|
|
19
|
+
}, [storedFilters, initialFilters]);
|
|
19
20
|
const clearActiveFilters = useCallback(() => {
|
|
20
21
|
setStoredFilters([]);
|
|
21
22
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseFilterSet.js","sources":["../../lib/hooks/UseFilterSet.tsx"],"sourcesContent":["import { useLocalStorage } from '@mantine/hooks';\nimport { useCallback, useMemo } from 'react';\nimport type { FilterSetState, TableFilter } from '../types/Filters';\n\nexport default function useFilterSet(\n filterKey: string,\n initialFilters?: TableFilter[]\n): FilterSetState {\n // Array of active filters (saved to local storage)\n const [storedFilters, setStoredFilters] = useLocalStorage<\n TableFilter[] | null\n >({\n key: `inventree-filterset-${filterKey}`,\n defaultValue: null,\n sync: false,\n getInitialValueInEffect: false\n });\n\n
|
|
1
|
+
{"version":3,"file":"UseFilterSet.js","sources":["../../lib/hooks/UseFilterSet.tsx"],"sourcesContent":["import { useLocalStorage } from '@mantine/hooks';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport type { FilterSetState, TableFilter } from '../types/Filters';\n\nexport default function useFilterSet(\n filterKey: string,\n initialFilters?: TableFilter[]\n): FilterSetState {\n // Array of active filters (saved to local storage)\n const [storedFilters, setStoredFilters] = useLocalStorage<\n TableFilter[] | null\n >({\n key: `inventree-filterset-${filterKey}`,\n defaultValue: null,\n sync: false,\n getInitialValueInEffect: false\n });\n\n useEffect(() => {\n if (storedFilters == null) {\n setStoredFilters(initialFilters || []);\n }\n }, [storedFilters, initialFilters, setStoredFilters]);\n\n const activeFilters: TableFilter[] = useMemo(() => {\n return storedFilters ?? initialFilters ?? [];\n }, [storedFilters, initialFilters]);\n\n // Callback to clear all active filters from the table\n const clearActiveFilters = useCallback(() => {\n setStoredFilters([]);\n }, []);\n\n const setActiveFilters = useCallback(\n (filters: TableFilter[]) => {\n setStoredFilters(filters);\n },\n [setStoredFilters]\n );\n\n return {\n filterKey,\n activeFilters,\n setActiveFilters,\n clearActiveFilters\n };\n}\n"],"names":["useFilterSet","filterKey","initialFilters","storedFilters","setStoredFilters","useLocalStorage","key","defaultValue","sync","getInitialValueInEffect","useEffect","activeFilters","useMemo","clearActiveFilters","useCallback","setActiveFilters","filters"],"mappings":";AACA,MAAA,cAAA,OAAA,OAAA,EAAA;;;AAGA,SAAwBA,aACtBC,WACAC,gBACgB;AAEhB,QAAM,CAACC,eAAeC,gBAAgB,IAAIC,gBAExC;AAAA,IACAC,KAAK,uBAAuBL,SAAS;AAAA,IACrCM,cAAc;AAAA,IACdC,MAAM;AAAA,IACNC,yBAAyB;AAAA,EAAA,CAC1B;AAEDC,YAAU,MAAM;AACd,QAAIP,iBAAiB,MAAM;AACzBC,uBAAiBF,kBAAkB,EAAE;AAAA,IACvC;AAAA,EACF,GAAG,CAACC,eAAeD,gBAAgBE,gBAAgB,CAAC;AAEpD,QAAMO,gBAA+BC,QAAQ,MAAM;AACjD,WAAOT,iBAAiBD,kBAAkB,CAAA;AAAA,EAC5C,GAAG,CAACC,eAAeD,cAAc,CAAC;AAGlC,QAAMW,qBAAqBC,YAAY,MAAM;AAC3CV,qBAAiB,CAAA,CAAE;AAAA,EACrB,GAAG,CAAA,CAAE;AAEL,QAAMW,mBAAmBD,YACvB,CAACE,YAA2B;AAC1BZ,qBAAiBY,OAAO;AAAA,EAC1B,GACA,CAACZ,gBAAgB,CACnB;AAEA,SAAO;AAAA,IACLH;AAAAA,IACAU;AAAAA,IACAI;AAAAA,IACAF;AAAAA,EAAAA;AAEJ;"}
|
package/dist/hooks/UseTable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import useFilterSet from "./UseFilterSet.js";
|
|
2
1
|
import { randomId } from "../node_modules/@mantine/hooks/esm/utils/random-id/random-id.js";
|
|
2
|
+
import useFilterSet from "./UseFilterSet.js";
|
|
3
3
|
const useCallback = window["React"].useCallback;
|
|
4
4
|
const useMemo = window["React"].useMemo;
|
|
5
5
|
const useState = window["React"].useState;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { ModelType } from './enums/ModelType';
|
|
|
4
4
|
export type { ModelDict } from './enums/ModelInformation';
|
|
5
5
|
export { UserRoles, UserPermissions } from './enums/Roles';
|
|
6
6
|
export type { InvenTreePluginContext, InvenTreeFormsContext, InvenTreeTablesContext, ImporterDrawerContext, PluginVersion, StockAdjustmentFormsContext } from './types/Plugins';
|
|
7
|
+
export type { PanelIndicatorType, PanelType, PanelGroupType } from './types/Panel';
|
|
7
8
|
export type { RowAction, RowViewProps, TableColumn, TableColumnProps, TableState, InvenTreeTableProps, InvenTreeTableRenderProps } from './types/Tables';
|
|
8
9
|
export type { TableFilterChoice, TableFilterType, TableFilter, FilterSetState } from './types/Filters';
|
|
9
10
|
export type { ApiFormFieldChoice, ApiFormFieldHeader, ApiFormFieldType, ApiFormFieldSet, ApiFormProps, ApiFormModalProps, BulkEditApiFormModalProps } from './types/Forms';
|
|
@@ -31,6 +32,7 @@ export { default as useMonitorDataOutput, type MonitorDataOutputProps } from './
|
|
|
31
32
|
export { default as useMonitorBackgroundTask, type MonitorBackgroundTaskProps } from './hooks/MonitorBackgroundTask';
|
|
32
33
|
export { default as useFilterSet } from './hooks/UseFilterSet';
|
|
33
34
|
export { default as useTable, type TableStateExtraProps } from './hooks/UseTable';
|
|
34
|
-
export { type DrawerProps, DetailDrawer, DetailDrawerLink } from './components/nav/DetailDrawer';
|
|
35
|
+
export { type DrawerProps, DetailDrawer, DetailDrawerLink, DetailDrawerComponent } from './components/nav/DetailDrawer';
|
|
35
36
|
export { StylishText } from './components/StylishText';
|
|
36
37
|
export { type StoredTableStateProps, useStoredTableState } from './states/StoredTableState';
|
|
38
|
+
export { useLocalLibState } from './states/LocalLibState';
|
package/dist/index.js
CHANGED
|
@@ -25,9 +25,10 @@ import { default as default3 } from "./hooks/MonitorDataOutput.js";
|
|
|
25
25
|
import { default as default4 } from "./hooks/MonitorBackgroundTask.js";
|
|
26
26
|
import { default as default5 } from "./hooks/UseFilterSet.js";
|
|
27
27
|
import { default as default6 } from "./hooks/UseTable.js";
|
|
28
|
-
import { DetailDrawer, DetailDrawerLink } from "./components/nav/DetailDrawer.js";
|
|
28
|
+
import { DetailDrawer, DetailDrawerComponent, DetailDrawerLink } from "./components/nav/DetailDrawer.js";
|
|
29
29
|
import { StylishText } from "./components/StylishText.js";
|
|
30
30
|
import { useStoredTableState } from "./states/StoredTableState.js";
|
|
31
|
+
import { useLocalLibState } from "./states/LocalLibState.js";
|
|
31
32
|
export {
|
|
32
33
|
ActionButton,
|
|
33
34
|
AddItemButton,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
CopyableCell,
|
|
39
40
|
DefaultFallback,
|
|
40
41
|
DetailDrawer,
|
|
42
|
+
DetailDrawerComponent,
|
|
41
43
|
DetailDrawerLink,
|
|
42
44
|
INVENTREE_MANTINE_VERSION,
|
|
43
45
|
INVENTREE_PLUGIN_VERSION,
|
|
@@ -77,6 +79,7 @@ export {
|
|
|
77
79
|
shortenString,
|
|
78
80
|
showTimeoutNotification,
|
|
79
81
|
default5 as useFilterSet,
|
|
82
|
+
useLocalLibState,
|
|
80
83
|
default4 as useMonitorBackgroundTask,
|
|
81
84
|
default3 as useMonitorDataOutput,
|
|
82
85
|
useStoredTableState,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
const useState = window["React"].useState;
|
|
2
|
-
const useRef = window["React"].useRef;
|
|
3
1
|
const useCallback = window["React"].useCallback;
|
|
4
2
|
const useEffect = window["React"].useEffect;
|
|
3
|
+
const useRef = window["React"].useRef;
|
|
4
|
+
const useState = window["React"].useState;
|
|
5
5
|
function useDebouncedValue(value, wait, options = { leading: false }) {
|
|
6
6
|
const [_value, setValue] = useState(value);
|
|
7
7
|
const mountedRef = useRef(false);
|
|
8
8
|
const timeoutRef = useRef(null);
|
|
9
9
|
const cooldownRef = useRef(false);
|
|
10
|
-
const
|
|
10
|
+
const latestValueRef = useRef(value);
|
|
11
|
+
latestValueRef.current = value;
|
|
12
|
+
const cancel = useCallback(() => {
|
|
13
|
+
window.clearTimeout(timeoutRef.current);
|
|
14
|
+
timeoutRef.current = null;
|
|
15
|
+
cooldownRef.current = false;
|
|
16
|
+
}, []);
|
|
17
|
+
const flush = useCallback(() => {
|
|
18
|
+
if (timeoutRef.current) {
|
|
19
|
+
cancel();
|
|
20
|
+
cooldownRef.current = false;
|
|
21
|
+
setValue(latestValueRef.current);
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
11
24
|
useEffect(() => {
|
|
12
|
-
if (mountedRef.current) {
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
if (mountedRef.current) if (!cooldownRef.current && options.leading) {
|
|
26
|
+
cooldownRef.current = true;
|
|
27
|
+
setValue(value);
|
|
28
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
29
|
+
cooldownRef.current = false;
|
|
30
|
+
}, wait);
|
|
31
|
+
} else {
|
|
32
|
+
cancel();
|
|
33
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
34
|
+
cooldownRef.current = false;
|
|
15
35
|
setValue(value);
|
|
16
|
-
}
|
|
17
|
-
cancel();
|
|
18
|
-
timeoutRef.current = window.setTimeout(() => {
|
|
19
|
-
cooldownRef.current = false;
|
|
20
|
-
setValue(value);
|
|
21
|
-
}, wait);
|
|
22
|
-
}
|
|
36
|
+
}, wait);
|
|
23
37
|
}
|
|
24
|
-
}, [
|
|
38
|
+
}, [
|
|
39
|
+
value,
|
|
40
|
+
options.leading,
|
|
41
|
+
wait
|
|
42
|
+
]);
|
|
25
43
|
useEffect(() => {
|
|
26
44
|
mountedRef.current = true;
|
|
27
45
|
return cancel;
|
|
28
46
|
}, []);
|
|
29
|
-
return [
|
|
47
|
+
return [
|
|
48
|
+
_value,
|
|
49
|
+
cancel,
|
|
50
|
+
{
|
|
51
|
+
cancel,
|
|
52
|
+
flush
|
|
53
|
+
}
|
|
54
|
+
];
|
|
30
55
|
}
|
|
31
56
|
export {
|
|
32
57
|
useDebouncedValue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-debounced-value.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-debounced-value.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.mjs"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n//#region packages/@mantine/hooks/src/use-debounced-value/use-debounced-value.ts\nfunction useDebouncedValue(value, wait, options = { leading: false }) {\n\tconst [_value, setValue] = useState(value);\n\tconst mountedRef = useRef(false);\n\tconst timeoutRef = useRef(null);\n\tconst cooldownRef = useRef(false);\n\tconst latestValueRef = useRef(value);\n\tlatestValueRef.current = value;\n\tconst cancel = useCallback(() => {\n\t\twindow.clearTimeout(timeoutRef.current);\n\t\ttimeoutRef.current = null;\n\t\tcooldownRef.current = false;\n\t}, []);\n\tconst flush = useCallback(() => {\n\t\tif (timeoutRef.current) {\n\t\t\tcancel();\n\t\t\tcooldownRef.current = false;\n\t\t\tsetValue(latestValueRef.current);\n\t\t}\n\t}, []);\n\tuseEffect(() => {\n\t\tif (mountedRef.current) if (!cooldownRef.current && options.leading) {\n\t\t\tcooldownRef.current = true;\n\t\t\tsetValue(value);\n\t\t\ttimeoutRef.current = window.setTimeout(() => {\n\t\t\t\tcooldownRef.current = false;\n\t\t\t}, wait);\n\t\t} else {\n\t\t\tcancel();\n\t\t\ttimeoutRef.current = window.setTimeout(() => {\n\t\t\t\tcooldownRef.current = false;\n\t\t\t\tsetValue(value);\n\t\t\t}, wait);\n\t\t}\n\t}, [\n\t\tvalue,\n\t\toptions.leading,\n\t\twait\n\t]);\n\tuseEffect(() => {\n\t\tmountedRef.current = true;\n\t\treturn cancel;\n\t}, []);\n\treturn [\n\t\t_value,\n\t\tcancel,\n\t\t{\n\t\t\tcancel,\n\t\t\tflush\n\t\t}\n\t];\n}\n//#endregion\nexport { useDebouncedValue };\n\n//# sourceMappingURL=use-debounced-value.mjs.map"],"names":[],"mappings":"AACA,MAAA,cAAA,OAAA,OAAA,EAAA;;;;AAEA,SAAS,kBAAkB,OAAO,MAAM,UAAU,EAAE,SAAS,SAAS;AACrE,QAAM,CAAC,QAAQ,QAAQ,IAAI,SAAS,KAAK;AACzC,QAAM,aAAa,OAAO,KAAK;AAC/B,QAAM,aAAa,OAAO,IAAI;AAC9B,QAAM,cAAc,OAAO,KAAK;AAChC,QAAM,iBAAiB,OAAO,KAAK;AACnC,iBAAe,UAAU;AACzB,QAAM,SAAS,YAAY,MAAM;AAChC,WAAO,aAAa,WAAW,OAAO;AACtC,eAAW,UAAU;AACrB,gBAAY,UAAU;AAAA,EACvB,GAAG,CAAA,CAAE;AACL,QAAM,QAAQ,YAAY,MAAM;AAC/B,QAAI,WAAW,SAAS;AACvB,aAAM;AACN,kBAAY,UAAU;AACtB,eAAS,eAAe,OAAO;AAAA,IAChC;AAAA,EACD,GAAG,CAAA,CAAE;AACL,YAAU,MAAM;AACf,QAAI,WAAW,QAAS,KAAI,CAAC,YAAY,WAAW,QAAQ,SAAS;AACpE,kBAAY,UAAU;AACtB,eAAS,KAAK;AACd,iBAAW,UAAU,OAAO,WAAW,MAAM;AAC5C,oBAAY,UAAU;AAAA,MACvB,GAAG,IAAI;AAAA,IACR,OAAO;AACN,aAAM;AACN,iBAAW,UAAU,OAAO,WAAW,MAAM;AAC5C,oBAAY,UAAU;AACtB,iBAAS,KAAK;AAAA,MACf,GAAG,IAAI;AAAA,IACR;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACF,CAAE;AACD,YAAU,MAAM;AACf,eAAW,UAAU;AACrB,WAAO;AAAA,EACR,GAAG,CAAA,CAAE;AACL,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,IACH;AAAA,EACA;AACA;","x_google_ignoreList":[0]}
|
package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-document-visibility.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-document-visibility.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.mjs"],"sourcesContent":["\"use client\";\nimport { useEffect, useState } from \"react\";\n//#region packages/@mantine/hooks/src/use-document-visibility/use-document-visibility.ts\nfunction useDocumentVisibility() {\n\tconst [documentVisibility, setDocumentVisibility] = useState(\"visible\");\n\tuseEffect(() => {\n\t\tsetDocumentVisibility(document.visibilityState);\n\t\tconst listener = () => setDocumentVisibility(document.visibilityState);\n\t\tdocument.addEventListener(\"visibilitychange\", listener);\n\t\treturn () => document.removeEventListener(\"visibilitychange\", listener);\n\t}, []);\n\treturn documentVisibility;\n}\n//#endregion\nexport { useDocumentVisibility };\n\n//# sourceMappingURL=use-document-visibility.mjs.map"],"names":[],"mappings":"AACA,MAAA,YAAA,OAAA,OAAA,EAAA;;AAEA,SAAS,wBAAwB;AAChC,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAS,SAAS;AACtE,YAAU,MAAM;AACf,0BAAsB,SAAS,eAAe;AAC9C,UAAM,WAAW,MAAM,sBAAsB,SAAS,eAAe;AACrE,aAAS,iBAAiB,oBAAoB,QAAQ;AACtD,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,QAAQ;AAAA,EACvE,GAAG,CAAA,CAAE;AACL,SAAO;AACR;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useWindowEvent } from "../use-window-event/use-window-event.js";
|
|
2
2
|
const useCallback = window["React"].useCallback;
|
|
3
|
-
const useState = window["React"].useState;
|
|
4
3
|
const useEffect = window["React"].useEffect;
|
|
4
|
+
const useState = window["React"].useState;
|
|
5
5
|
function serializeJSON(value, hookName = "use-local-storage") {
|
|
6
6
|
try {
|
|
7
7
|
return JSON.stringify(value);
|
|
@@ -36,91 +36,86 @@ function createStorageHandler(type) {
|
|
|
36
36
|
try {
|
|
37
37
|
window[type].removeItem(key);
|
|
38
38
|
} catch (error) {
|
|
39
|
-
console.warn(
|
|
40
|
-
"use-local-storage: Failed to remove value from storage, localStorage is blocked"
|
|
41
|
-
);
|
|
39
|
+
console.warn("use-local-storage: Failed to remove value from storage, localStorage is blocked");
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
getItem,
|
|
44
|
+
setItem,
|
|
45
|
+
removeItem
|
|
46
|
+
};
|
|
45
47
|
}
|
|
46
48
|
function createStorage(type, hookName) {
|
|
47
49
|
const eventName = "mantine-local-storage";
|
|
48
50
|
const { getItem, setItem, removeItem } = createStorageHandler(type);
|
|
49
|
-
return function useStorage({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
storageBlockedOrSkipped = typeof window === "undefined" || !(type in window) || window[type] === null || !!skipStorage;
|
|
62
|
-
} catch (_e) {
|
|
63
|
-
storageBlockedOrSkipped = true;
|
|
64
|
-
}
|
|
65
|
-
if (storageBlockedOrSkipped) {
|
|
66
|
-
return defaultValue;
|
|
67
|
-
}
|
|
68
|
-
const storageValue = getItem(key);
|
|
69
|
-
return storageValue !== null ? deserialize(storageValue) : defaultValue;
|
|
70
|
-
},
|
|
71
|
-
[key, defaultValue]
|
|
72
|
-
);
|
|
51
|
+
return function useStorage({ key, defaultValue, getInitialValueInEffect = true, sync = true, deserialize = deserializeJSON, serialize = (value) => serializeJSON(value, hookName) }) {
|
|
52
|
+
const readStorageValue = useCallback((skipStorage) => {
|
|
53
|
+
let storageBlockedOrSkipped;
|
|
54
|
+
try {
|
|
55
|
+
storageBlockedOrSkipped = typeof window === "undefined" || !(type in window) || window[type] === null || !!skipStorage;
|
|
56
|
+
} catch (_e) {
|
|
57
|
+
storageBlockedOrSkipped = true;
|
|
58
|
+
}
|
|
59
|
+
if (storageBlockedOrSkipped) return defaultValue;
|
|
60
|
+
const storageValue = getItem(key);
|
|
61
|
+
return storageValue !== null ? deserialize(storageValue) : defaultValue;
|
|
62
|
+
}, [key, defaultValue]);
|
|
73
63
|
const [value, setValue] = useState(readStorageValue(getInitialValueInEffect));
|
|
74
|
-
const setStorageValue = useCallback(
|
|
75
|
-
(val) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
);
|
|
64
|
+
const setStorageValue = useCallback((val) => {
|
|
65
|
+
if (val instanceof Function) setValue((current) => {
|
|
66
|
+
const result = val(current);
|
|
67
|
+
setItem(key, serialize(result));
|
|
68
|
+
queueMicrotask(() => {
|
|
69
|
+
window.dispatchEvent(new CustomEvent(eventName, { detail: {
|
|
70
|
+
key,
|
|
71
|
+
value: result
|
|
72
|
+
} }));
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
});
|
|
76
|
+
else {
|
|
77
|
+
setItem(key, serialize(val));
|
|
78
|
+
window.dispatchEvent(new CustomEvent(eventName, { detail: {
|
|
79
|
+
key,
|
|
80
|
+
value: val
|
|
81
|
+
} }));
|
|
82
|
+
setValue(val);
|
|
83
|
+
}
|
|
84
|
+
}, [key]);
|
|
95
85
|
const removeStorageValue = useCallback(() => {
|
|
96
86
|
removeItem(key);
|
|
97
87
|
setValue(defaultValue);
|
|
98
|
-
window.dispatchEvent(new CustomEvent(eventName, { detail: {
|
|
88
|
+
window.dispatchEvent(new CustomEvent(eventName, { detail: {
|
|
89
|
+
key,
|
|
90
|
+
value: defaultValue
|
|
91
|
+
} }));
|
|
99
92
|
}, [key, defaultValue]);
|
|
100
93
|
useWindowEvent("storage", (event) => {
|
|
101
94
|
if (sync) {
|
|
102
|
-
if (event.storageArea === window[type] && event.key === key)
|
|
103
|
-
setValue(deserialize(event.newValue ?? void 0));
|
|
104
|
-
}
|
|
95
|
+
if (event.storageArea === window[type] && event.key === key) setValue(deserialize(event.newValue ?? void 0));
|
|
105
96
|
}
|
|
106
97
|
});
|
|
107
98
|
useWindowEvent(eventName, (event) => {
|
|
108
99
|
if (sync) {
|
|
109
|
-
if (event.detail.key === key)
|
|
110
|
-
setValue(event.detail.value);
|
|
111
|
-
}
|
|
100
|
+
if (event.detail.key === key) setValue(event.detail.value);
|
|
112
101
|
}
|
|
113
102
|
});
|
|
114
103
|
useEffect(() => {
|
|
115
|
-
if (defaultValue !== void 0 && value === void 0)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
104
|
+
if (defaultValue !== void 0 && value === void 0) setStorageValue(defaultValue);
|
|
105
|
+
}, [
|
|
106
|
+
defaultValue,
|
|
107
|
+
value,
|
|
108
|
+
setStorageValue
|
|
109
|
+
]);
|
|
119
110
|
useEffect(() => {
|
|
120
111
|
const val = readStorageValue();
|
|
121
112
|
val !== void 0 && setStorageValue(val);
|
|
122
113
|
}, [key]);
|
|
123
|
-
return [
|
|
114
|
+
return [
|
|
115
|
+
value === void 0 ? defaultValue : value,
|
|
116
|
+
setStorageValue,
|
|
117
|
+
removeStorageValue
|
|
118
|
+
];
|
|
124
119
|
};
|
|
125
120
|
}
|
|
126
121
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-storage.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-local-storage/create-storage.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"create-storage.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-local-storage/create-storage.mjs"],"sourcesContent":["\"use client\";\nimport { useWindowEvent } from \"../use-window-event/use-window-event.mjs\";\nimport { useCallback, useEffect, useState } from \"react\";\n//#region packages/@mantine/hooks/src/use-local-storage/create-storage.ts\nfunction serializeJSON(value, hookName = \"use-local-storage\") {\n\ttry {\n\t\treturn JSON.stringify(value);\n\t} catch (error) {\n\t\tthrow new Error(`@mantine/hooks ${hookName}: Failed to serialize the value`);\n\t}\n}\nfunction deserializeJSON(value) {\n\ttry {\n\t\treturn value && JSON.parse(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\nfunction createStorageHandler(type) {\n\tconst getItem = (key) => {\n\t\ttry {\n\t\t\treturn window[type].getItem(key);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"use-local-storage: Failed to get value from storage, localStorage is blocked\");\n\t\t\treturn null;\n\t\t}\n\t};\n\tconst setItem = (key, value) => {\n\t\ttry {\n\t\t\twindow[type].setItem(key, value);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"use-local-storage: Failed to set value to storage, localStorage is blocked\");\n\t\t}\n\t};\n\tconst removeItem = (key) => {\n\t\ttry {\n\t\t\twindow[type].removeItem(key);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"use-local-storage: Failed to remove value from storage, localStorage is blocked\");\n\t\t}\n\t};\n\treturn {\n\t\tgetItem,\n\t\tsetItem,\n\t\tremoveItem\n\t};\n}\nfunction createStorage(type, hookName) {\n\tconst eventName = type === \"localStorage\" ? \"mantine-local-storage\" : \"mantine-session-storage\";\n\tconst { getItem, setItem, removeItem } = createStorageHandler(type);\n\treturn function useStorage({ key, defaultValue, getInitialValueInEffect = true, sync = true, deserialize = deserializeJSON, serialize = (value) => serializeJSON(value, hookName) }) {\n\t\tconst readStorageValue = useCallback((skipStorage) => {\n\t\t\tlet storageBlockedOrSkipped;\n\t\t\ttry {\n\t\t\t\tstorageBlockedOrSkipped = typeof window === \"undefined\" || !(type in window) || window[type] === null || !!skipStorage;\n\t\t\t} catch (_e) {\n\t\t\t\tstorageBlockedOrSkipped = true;\n\t\t\t}\n\t\t\tif (storageBlockedOrSkipped) return defaultValue;\n\t\t\tconst storageValue = getItem(key);\n\t\t\treturn storageValue !== null ? deserialize(storageValue) : defaultValue;\n\t\t}, [key, defaultValue]);\n\t\tconst [value, setValue] = useState(readStorageValue(getInitialValueInEffect));\n\t\tconst setStorageValue = useCallback((val) => {\n\t\t\tif (val instanceof Function) setValue((current) => {\n\t\t\t\tconst result = val(current);\n\t\t\t\tsetItem(key, serialize(result));\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\twindow.dispatchEvent(new CustomEvent(eventName, { detail: {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tvalue: result\n\t\t\t\t\t} }));\n\t\t\t\t});\n\t\t\t\treturn result;\n\t\t\t});\n\t\t\telse {\n\t\t\t\tsetItem(key, serialize(val));\n\t\t\t\twindow.dispatchEvent(new CustomEvent(eventName, { detail: {\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: val\n\t\t\t\t} }));\n\t\t\t\tsetValue(val);\n\t\t\t}\n\t\t}, [key]);\n\t\tconst removeStorageValue = useCallback(() => {\n\t\t\tremoveItem(key);\n\t\t\tsetValue(defaultValue);\n\t\t\twindow.dispatchEvent(new CustomEvent(eventName, { detail: {\n\t\t\t\tkey,\n\t\t\t\tvalue: defaultValue\n\t\t\t} }));\n\t\t}, [key, defaultValue]);\n\t\tuseWindowEvent(\"storage\", (event) => {\n\t\t\tif (sync) {\n\t\t\t\tif (event.storageArea === window[type] && event.key === key) setValue(deserialize(event.newValue ?? void 0));\n\t\t\t}\n\t\t});\n\t\tuseWindowEvent(eventName, (event) => {\n\t\t\tif (sync) {\n\t\t\t\tif (event.detail.key === key) setValue(event.detail.value);\n\t\t\t}\n\t\t});\n\t\tuseEffect(() => {\n\t\t\tif (defaultValue !== void 0 && value === void 0) setStorageValue(defaultValue);\n\t\t}, [\n\t\t\tdefaultValue,\n\t\t\tvalue,\n\t\t\tsetStorageValue\n\t\t]);\n\t\tuseEffect(() => {\n\t\t\tconst val = readStorageValue();\n\t\t\tval !== void 0 && setStorageValue(val);\n\t\t}, [key]);\n\t\treturn [\n\t\t\tvalue === void 0 ? defaultValue : value,\n\t\t\tsetStorageValue,\n\t\t\tremoveStorageValue\n\t\t];\n\t};\n}\nfunction readValue(type) {\n\tconst { getItem } = createStorageHandler(type);\n\treturn function read({ key, defaultValue, deserialize = deserializeJSON }) {\n\t\tlet storageBlockedOrSkipped;\n\t\ttry {\n\t\t\tstorageBlockedOrSkipped = typeof window === \"undefined\" || !(type in window) || window[type] === null;\n\t\t} catch (_e) {\n\t\t\tstorageBlockedOrSkipped = true;\n\t\t}\n\t\tif (storageBlockedOrSkipped) return defaultValue;\n\t\tconst storageValue = getItem(key);\n\t\treturn storageValue !== null ? deserialize(storageValue) : defaultValue;\n\t};\n}\n//#endregion\nexport { createStorage, readValue };\n\n//# sourceMappingURL=create-storage.mjs.map"],"names":[],"mappings":";AAEA,MAAA,cAAA,OAAA,OAAA,EAAA;;;AAEA,SAAS,cAAc,OAAO,WAAW,qBAAqB;AAC7D,MAAI;AACH,WAAO,KAAK,UAAU,KAAK;AAAA,EAC5B,SAAS,OAAO;AACf,UAAM,IAAI,MAAM,kBAAkB,QAAQ,iCAAiC;AAAA,EAC5E;AACD;AACA,SAAS,gBAAgB,OAAO;AAC/B,MAAI;AACH,WAAO,SAAS,KAAK,MAAM,KAAK;AAAA,EACjC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AACA,SAAS,qBAAqB,MAAM;AACnC,QAAM,UAAU,CAAC,QAAQ;AACxB,QAAI;AACH,aAAO,OAAO,IAAI,EAAE,Q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WAAO;AAAA,MACN,UAAU,SAAS,eAAe;AAAA,MAClC;AAAA,MACA;AAAA,IACH;AAAA,EACC;AACD;","x_google_ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-local-storage.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-local-storage.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.mjs"],"sourcesContent":["\"use client\";\nimport { createStorage, readValue } from \"./create-storage.mjs\";\n//#region packages/@mantine/hooks/src/use-local-storage/use-local-storage.ts\nfunction useLocalStorage(props) {\n\treturn createStorage(\"localStorage\", \"use-local-storage\")(props);\n}\nconst readLocalStorageValue = readValue(\"localStorage\");\n//#endregion\nexport { readLocalStorageValue, useLocalStorage };\n\n//# sourceMappingURL=use-local-storage.mjs.map"],"names":[],"mappings":";AAGA,SAAS,gBAAgB,OAAO;AAC/B,SAAO,cAAc,gBAAgB,mBAAmB,EAAE,KAAK;AAChE;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const useEffect = window["React"].useEffect;
|
|
2
|
+
const useEffectEvent = window["React"].useEffectEvent;
|
|
2
3
|
function useWindowEvent(type, listener, options) {
|
|
4
|
+
const stableListener = useEffectEvent(listener);
|
|
3
5
|
useEffect(() => {
|
|
4
|
-
window.addEventListener(type,
|
|
5
|
-
return () => window.removeEventListener(type,
|
|
6
|
-
}, [type
|
|
6
|
+
window.addEventListener(type, stableListener, options);
|
|
7
|
+
return () => window.removeEventListener(type, stableListener, options);
|
|
8
|
+
}, [type]);
|
|
7
9
|
}
|
|
8
10
|
export {
|
|
9
11
|
useWindowEvent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-window-event.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-window-event/use-window-event.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"use-window-event.js","sources":["../../../../../../node_modules/@mantine/hooks/esm/use-window-event/use-window-event.mjs"],"sourcesContent":["\"use client\";\nimport { useEffect, useEffectEvent } from \"react\";\n//#region packages/@mantine/hooks/src/use-window-event/use-window-event.ts\nfunction useWindowEvent(type, listener, options) {\n\tconst stableListener = useEffectEvent(listener);\n\tuseEffect(() => {\n\t\twindow.addEventListener(type, stableListener, options);\n\t\treturn () => window.removeEventListener(type, stableListener, options);\n\t}, [type]);\n}\n//#endregion\nexport { useWindowEvent };\n\n//# sourceMappingURL=use-window-event.mjs.map"],"names":[],"mappings":"AACA,MAAA,YAAA,OAAA,OAAA,EAAA;;AAEA,SAAS,eAAe,MAAM,UAAU,SAAS;AAChD,QAAM,iBAAiB,eAAe,QAAQ;AAC9C,YAAU,MAAM;AACf,WAAO,iBAAiB,MAAM,gBAAgB,OAAO;AACrD,WAAO,MAAM,OAAO,oBAAoB,MAAM,gBAAgB,OAAO;AAAA,EACtE,GAAG,CAAC,IAAI,CAAC;AACV;","x_google_ignoreList":[0]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.js","sources":["../../../../../../../node_modules/@mantine/hooks/esm/utils/random-id/random-id.mjs"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"random-id.js","sources":["../../../../../../../node_modules/@mantine/hooks/esm/utils/random-id/random-id.mjs"],"sourcesContent":["\"use client\";\n//#region packages/@mantine/hooks/src/utils/random-id/random-id.ts\nfunction randomId(prefix = \"mantine-\") {\n\treturn `${prefix}${Math.random().toString(36).slice(2, 11)}`;\n}\n//#endregion\nexport { randomId };\n\n//# sourceMappingURL=random-id.mjs.map"],"names":[],"mappings":"AAEA,SAAS,SAAS,SAAS,YAAY;AACtC,SAAO,GAAG,MAAM,GAAG,KAAK,OAAM,EAAG,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AAC3D;","x_google_ignoreList":[0]}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @remix-run/router v1.23.2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
1
11
|
function _extends() {
|
|
2
12
|
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
3
13
|
for (var i = 1; i < arguments.length; i++) {
|