@intlayer/design-system 4.0.2 → 4.0.4
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/dist/.vite/manifest.json +58 -197
- package/dist/components/Accordion/Accordion.cjs +1 -1
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +1 -1
- package/dist/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/components/Auth/AuthModal/index.cjs +1 -1
- package/dist/components/Auth/AuthModal/index.mjs +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs +2 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.cjs.map +1 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs +2 -1
- package/dist/components/Auth/ExternalsLoginButtons/ExternalsLoginButtons.mjs.map +1 -1
- package/dist/components/Auth/useAuth/index.cjs +8 -4
- package/dist/components/Auth/useAuth/index.cjs.map +1 -1
- package/dist/components/Auth/useAuth/index.d.ts +3 -1
- package/dist/components/Auth/useAuth/index.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/index.mjs +8 -4
- package/dist/components/Auth/useAuth/index.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.cjs +6 -3
- package/dist/components/Auth/useAuth/useCSRF.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.d.ts +2 -1
- package/dist/components/Auth/useAuth/useCSRF.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useCSRF.mjs +5 -2
- package/dist/components/Auth/useAuth/useCSRF.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.cjs +6 -5
- package/dist/components/Auth/useAuth/useOAuth2.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.d.ts +2 -1
- package/dist/components/Auth/useAuth/useOAuth2.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useOAuth2.mjs +5 -4
- package/dist/components/Auth/useAuth/useOAuth2.mjs.map +1 -1
- package/dist/components/Auth/useAuth/useSession.cjs +6 -3
- package/dist/components/Auth/useAuth/useSession.cjs.map +1 -1
- package/dist/components/Auth/useAuth/useSession.d.ts +2 -1
- package/dist/components/Auth/useAuth/useSession.d.ts.map +1 -1
- package/dist/components/Auth/useAuth/useSession.mjs +6 -3
- package/dist/components/Auth/useAuth/useSession.mjs.map +1 -1
- package/dist/components/Auth/useUser/index.cjs +1 -1
- package/dist/components/Auth/useUser/index.mjs +1 -1
- package/dist/components/Container/index.d.ts +2 -2
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs +4 -16
- package/dist/components/DictionaryEditor/DictionaryEditor.cjs.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs +4 -16
- package/dist/components/DictionaryEditor/DictionaryEditor.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/ArrayWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/EnumerationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs +2 -1
- package/dist/components/DictionaryEditor/NodeWrapper/NestedObjectWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs +3 -3
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.cjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs +2 -2
- package/dist/components/DictionaryEditor/NodeWrapper/StringWrapper.mjs.map +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/TranslationWrapper.mjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.cjs +1 -1
- package/dist/components/DictionaryEditor/NodeWrapper/index.mjs +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs +2 -9
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.cjs.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs +2 -9
- package/dist/components/DictionaryEditor/ValidDictionaryChangeButtons.mjs.map +1 -1
- package/dist/components/DictionaryEditor/index.cjs +0 -8
- package/dist/components/DictionaryEditor/index.cjs.map +1 -1
- package/dist/components/DictionaryEditor/index.d.ts +0 -2
- package/dist/components/DictionaryEditor/index.d.ts.map +1 -1
- package/dist/components/DictionaryEditor/index.mjs +1 -9
- package/dist/components/DictionaryEditor/index.mjs.map +1 -1
- package/dist/components/DictionaryEditor/useEditedContentStore.d.ts +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs +3 -21
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs +3 -21
- package/dist/components/DictionaryFieldEditor/DictionariesSelector/DictionariesSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryCreationForm/DictionaryCreationForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs +4 -2
- package/dist/components/DictionaryFieldEditor/DictionaryDetails/DictionaryDetailsForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs +5 -31
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs +6 -32
- package/dist/components/DictionaryFieldEditor/DictionaryFieldEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs +8 -37
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs +6 -35
- package/dist/components/DictionaryFieldEditor/EditorView/EditorView.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs +6 -24
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs +5 -23
- package/dist/components/DictionaryFieldEditor/EditorView/TextEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs +2 -29
- package/dist/components/DictionaryFieldEditor/JSONEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs +2 -29
- package/dist/components/DictionaryFieldEditor/JSONEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs +9 -33
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs +4 -28
- package/dist/components/DictionaryFieldEditor/NavigationView/NavigationViewNode.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs +3 -43
- package/dist/components/DictionaryFieldEditor/NodeEditor.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs +3 -43
- package/dist/components/DictionaryFieldEditor/NodeEditor.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs +4 -27
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs +3 -26
- package/dist/components/DictionaryFieldEditor/NodeTypeSelector.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs +9 -19
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.cjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.d.ts.map +1 -1
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs +9 -19
- package/dist/components/DictionaryFieldEditor/SaveForm/SaveForm.mjs.map +1 -1
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.cjs +2 -2
- package/dist/components/DictionaryFieldEditor/VersionSwitcherDropDown/VersionSwitcherContext.mjs +2 -2
- package/dist/components/EditableField/EditableFieldLayout.cjs +7 -3
- package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs +7 -3
- package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/components/IDE/CodeContext.cjs +2 -2
- package/dist/components/IDE/CodeContext.mjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.cjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContent.mjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.cjs +2 -2
- package/dist/components/LocaleSwitcherContentDropDown/LocaleSwitcherContentContext.mjs +2 -2
- package/dist/components/Modal/Modal.cjs +12 -8
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +12 -8
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs +3 -3
- package/dist/components/Navbar/MobileNavbar.mjs +3 -3
- package/dist/components/Navbar/index.cjs +2 -2
- package/dist/components/Navbar/index.mjs +2 -2
- package/dist/components/RightDrawer/RightDrawer.cjs +34 -18
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs +33 -17
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs +2 -2
- package/dist/components/SwitchSelector/index.mjs +2 -2
- package/dist/components/TabSelector/TabSelector.cjs +2 -2
- package/dist/components/TabSelector/TabSelector.mjs +2 -2
- package/dist/components/index.cjs +0 -8
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.mjs +0 -8
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/hooks/intlayerAPIHooks.cjs +5 -1
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +49 -49
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +5 -1
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.cjs +14 -0
- package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync/useAsync.mjs +14 -0
- package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.cjs +3 -2
- package/dist/hooks/useGetAllDictionaries.cjs.map +1 -1
- package/dist/hooks/useGetAllDictionaries.d.ts +2 -2
- package/dist/hooks/useGetAllDictionaries.d.ts.map +1 -1
- package/dist/hooks/useGetAllDictionaries.mjs +3 -2
- package/dist/hooks/useGetAllDictionaries.mjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.cjs +10 -7
- package/dist/hooks/useIntlayerAPI.cjs.map +1 -1
- package/dist/hooks/useIntlayerAPI.d.ts +8 -2
- package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
- package/dist/hooks/useIntlayerAPI.mjs +10 -7
- package/dist/hooks/useIntlayerAPI.mjs.map +1 -1
- package/dist/hooks/usePersistedStore.cjs +25 -15
- package/dist/hooks/usePersistedStore.cjs.map +1 -1
- package/dist/hooks/usePersistedStore.d.ts +2 -1
- package/dist/hooks/usePersistedStore.d.ts.map +1 -1
- package/dist/hooks/usePersistedStore.mjs +26 -16
- package/dist/hooks/usePersistedStore.mjs.map +1 -1
- package/dist/hooks/useScrollBlockage/index.cjs +5 -31
- package/dist/hooks/useScrollBlockage/index.cjs.map +1 -1
- package/dist/hooks/useScrollBlockage/index.mjs +5 -31
- package/dist/hooks/useScrollBlockage/index.mjs.map +1 -1
- package/dist/hooks/useScrollDetection.cjs +1 -1
- package/dist/hooks/useScrollDetection.mjs +1 -1
- package/dist/index-B-VAyQ9R.js +673 -0
- package/dist/index-B-VAyQ9R.js.map +1 -0
- package/dist/index-B-adg6xa.js +206 -0
- package/dist/index-B-adg6xa.js.map +1 -0
- package/dist/index-BIV0x_z2.js +206 -0
- package/dist/index-BIV0x_z2.js.map +1 -0
- package/dist/index-BNH9wXVj.cjs +205 -0
- package/dist/index-BNH9wXVj.cjs.map +1 -0
- package/dist/index-Cg-S9ry9.cjs +77 -0
- package/dist/index-Cg-S9ry9.cjs.map +1 -0
- package/dist/index-D69JRZcQ.js +206 -0
- package/dist/index-D69JRZcQ.js.map +1 -0
- package/dist/index-DAsui9u9.cjs +205 -0
- package/dist/index-DAsui9u9.cjs.map +1 -0
- package/dist/index-O_7rYrbW.js +78 -0
- package/dist/index-O_7rYrbW.js.map +1 -0
- package/dist/index-SOIahRpS.cjs +205 -0
- package/dist/index-SOIahRpS.cjs.map +1 -0
- package/dist/index-T-TjVQoD.js +671 -0
- package/dist/index-T-TjVQoD.js.map +1 -0
- package/dist/index-f8_VC6c8.cjs +672 -0
- package/dist/index-f8_VC6c8.cjs.map +1 -0
- package/dist/index-llGIfxqV.cjs +670 -0
- package/dist/index-llGIfxqV.cjs.map +1 -0
- package/dist/tailwind.css +1 -1
- package/dist/useGetAllDictionaries-B1sqs2IB.cjs +34 -0
- package/dist/useGetAllDictionaries-B1sqs2IB.cjs.map +1 -0
- package/dist/useGetAllDictionaries-BbH8vTkY.js +35 -0
- package/dist/useGetAllDictionaries-BbH8vTkY.js.map +1 -0
- package/dist/useGetAllDictionaries-Bgkytpa2.cjs +34 -0
- package/dist/useGetAllDictionaries-Bgkytpa2.cjs.map +1 -0
- package/dist/useGetAllDictionaries-D8ma3h41.cjs +33 -0
- package/dist/useGetAllDictionaries-D8ma3h41.cjs.map +1 -0
- package/dist/useGetAllDictionaries-DHgHEbD5.js +34 -0
- package/dist/useGetAllDictionaries-DHgHEbD5.js.map +1 -0
- package/dist/useGetAllDictionaries-DUzm0rIa.js +35 -0
- package/dist/useGetAllDictionaries-DUzm0rIa.js.map +1 -0
- package/package.json +24 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getIntlayerAPI } from "@intlayer/api";
|
|
1
2
|
import { useMemo } from "react";
|
|
2
|
-
import { g as getIntlayerAPI } from "../index-DcWYZrJW.js";
|
|
3
3
|
import { useAuth } from "../components/Auth/useAuth/index.mjs";
|
|
4
|
-
const useIntlayerAuth = (
|
|
4
|
+
const useIntlayerAuth = (props) => {
|
|
5
5
|
const { csrfToken, oAuth2AccessToken } = useAuth();
|
|
6
6
|
const headers = useMemo(
|
|
7
7
|
() => oAuth2AccessToken?.accessToken ? {
|
|
@@ -14,11 +14,14 @@ const useIntlayerAuth = (options) => {
|
|
|
14
14
|
[csrfToken]
|
|
15
15
|
);
|
|
16
16
|
return useMemo(
|
|
17
|
-
() => getIntlayerAPI(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
() => getIntlayerAPI(
|
|
18
|
+
{
|
|
19
|
+
headers,
|
|
20
|
+
body,
|
|
21
|
+
...props?.options ?? {}
|
|
22
|
+
},
|
|
23
|
+
props?.intlayerConfiguration
|
|
24
|
+
),
|
|
22
25
|
[body, headers]
|
|
23
26
|
);
|
|
24
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayerAPI.mjs","sources":["../../src/hooks/useIntlayerAPI.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useIntlayerAPI.mjs","sources":["../../src/hooks/useIntlayerAPI.ts"],"sourcesContent":["import { getIntlayerAPI, type FetcherOptions } from '@intlayer/api';\nimport { type IntlayerConfig } from '@intlayer/config/client';\nimport { useMemo } from 'react';\nimport { useAuth } from '../components/Auth/useAuth';\n\ntype UseIntlayerAuthProps = {\n options?: FetcherOptions;\n intlayerConfiguration?: IntlayerConfig;\n};\n\nexport const useIntlayerAuth = (props?: UseIntlayerAuthProps) => {\n const { csrfToken, oAuth2AccessToken } = useAuth();\n\n const headers = useMemo(\n () =>\n oAuth2AccessToken?.accessToken\n ? {\n Authorization: `Bearer ${oAuth2AccessToken.accessToken}`,\n }\n : undefined,\n [oAuth2AccessToken?.accessToken]\n );\n\n const body = useMemo(\n () => (csrfToken ? { csrf_token: csrfToken } : undefined),\n [csrfToken]\n );\n\n return useMemo(\n () =>\n getIntlayerAPI(\n {\n headers,\n body,\n ...(props?.options ?? {}),\n },\n props?.intlayerConfiguration\n ),\n [body, headers]\n );\n};\n"],"names":[],"mappings":";;;AAUa,MAAA,kBAAkB,CAAC,UAAiC;AAC/D,QAAM,EAAE,WAAW,kBAAkB,IAAI,QAAQ;AAEjD,QAAM,UAAU;AAAA,IACd,MACE,mBAAmB,cACf;AAAA,MACE,eAAe,UAAU,kBAAkB,WAAW;AAAA,IAAA,IAExD;AAAA,IACN,CAAC,mBAAmB,WAAW;AAAA,EACjC;AAEA,QAAM,OAAO;AAAA,IACX,MAAO,YAAY,EAAE,YAAY,UAAc,IAAA;AAAA,IAC/C,CAAC,SAAS;AAAA,EACZ;AAEO,SAAA;AAAA,IACL,MACE;AAAA,MACE;AAAA,QACE;AAAA,QACA;AAAA,QACA,GAAI,OAAO,WAAW,CAAA;AAAA,MACxB;AAAA,MACA,OAAO;AAAA,IACT;AAAA,IACF,CAAC,MAAM,OAAO;AAAA,EAChB;AACF;"}
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require$$0 = require("react");
|
|
5
|
-
const usePersistedStore = (key,
|
|
5
|
+
const usePersistedStore = (key, initialState) => {
|
|
6
6
|
const [state, setState] = require$$0.useState(() => {
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
if (initialState !== void 0) {
|
|
8
|
+
const result = typeof initialState === "function" ? initialState() : initialState;
|
|
9
|
+
if (typeof window === "undefined") return result;
|
|
10
|
+
const persistedState = localStorage?.getItem(key);
|
|
11
|
+
if (persistedState) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(persistedState);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
14
17
|
}
|
|
18
|
+
return result;
|
|
15
19
|
}
|
|
16
20
|
return void 0;
|
|
17
21
|
});
|
|
@@ -23,15 +27,21 @@ const usePersistedStore = (key, initialValue) => {
|
|
|
23
27
|
} catch (e) {
|
|
24
28
|
console.error(e);
|
|
25
29
|
}
|
|
26
|
-
} else if (
|
|
27
|
-
setState(
|
|
30
|
+
} else if (initialState !== void 0 && state === void 0) {
|
|
31
|
+
setState(initialState);
|
|
28
32
|
}
|
|
29
33
|
}, [key, state]);
|
|
30
|
-
require$$0.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const setStateWrapper = require$$0.useCallback(
|
|
35
|
+
(valueOrUpdater) => {
|
|
36
|
+
setState((prev) => {
|
|
37
|
+
const newValue = typeof valueOrUpdater === "function" ? valueOrUpdater(prev) : valueOrUpdater;
|
|
38
|
+
localStorage?.setItem(key, JSON.stringify(newValue));
|
|
39
|
+
return newValue;
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
[key, setState]
|
|
43
|
+
);
|
|
44
|
+
return require$$0.useMemo(() => [state, setStateWrapper], [state, setStateWrapper]);
|
|
35
45
|
};
|
|
36
46
|
exports.usePersistedStore = usePersistedStore;
|
|
37
47
|
//# sourceMappingURL=usePersistedStore.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedStore.cjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"usePersistedStore.cjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport {\n useState,\n useEffect,\n useCallback,\n type SetStateAction,\n type Dispatch,\n useMemo,\n} from 'react';\n\nexport const usePersistedStore = <S>(\n key: string,\n initialState?: S | (() => S)\n): [S, Dispatch<SetStateAction<S>>] => {\n const [state, setState] = useState<S>(() => {\n // If you have an initial value on the client, send a message out immediately\n if (initialState !== undefined) {\n const result: S =\n typeof initialState === 'function'\n ? (initialState as () => S)()\n : initialState;\n\n if (typeof window === 'undefined') return result;\n\n const persistedState = localStorage?.getItem(key);\n\n if (persistedState) {\n try {\n return JSON.parse(persistedState);\n } catch (e) {\n console.error(e);\n }\n }\n\n return result;\n }\n\n return undefined as S;\n });\n\n useEffect(() => {\n const persistedState = localStorage?.getItem(key);\n\n if (persistedState && state === undefined) {\n try {\n setState(JSON.parse(persistedState));\n } catch (e) {\n console.error(e);\n }\n } else if (initialState !== undefined && state === undefined) {\n setState(initialState);\n }\n }, [key, state]);\n\n /**\n * Allows setting state either directly or via a functional update.\n * If passed a function, we merge/update based on the previous state.\n */\n const setStateWrapper: typeof setState = useCallback(\n (valueOrUpdater: SetStateAction<S>) => {\n setState((prev) => {\n const newValue: S =\n typeof valueOrUpdater === 'function'\n ? (valueOrUpdater as (prevVal: S) => S)(prev)\n : valueOrUpdater;\n\n localStorage?.setItem(key, JSON.stringify(newValue));\n\n return newValue;\n });\n },\n [key, setState]\n );\n\n return useMemo(() => [state, setStateWrapper], [state, setStateWrapper]);\n};\n"],"names":["useState","useEffect","useCallback","useMemo"],"mappings":";;;;AAWa,MAAA,oBAAoB,CAC/B,KACA,iBACqC;AACrC,QAAM,CAAC,OAAO,QAAQ,IAAIA,oBAAY,MAAM;AAE1C,QAAI,iBAAiB,QAAW;AAC9B,YAAM,SACJ,OAAO,iBAAiB,aACnB,aACD,IAAA;AAEF,UAAA,OAAO,WAAW,YAAoB,QAAA;AAEpC,YAAA,iBAAiB,cAAc,QAAQ,GAAG;AAEhD,UAAI,gBAAgB;AACd,YAAA;AACK,iBAAA,KAAK,MAAM,cAAc;AAAA,iBACzB,GAAG;AACV,kBAAQ,MAAM,CAAC;AAAA,QAAA;AAAA,MACjB;AAGK,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EAAA,CACR;AAEDC,aAAAA,UAAU,MAAM;AACR,UAAA,iBAAiB,cAAc,QAAQ,GAAG;AAE5C,QAAA,kBAAkB,UAAU,QAAW;AACrC,UAAA;AACO,iBAAA,KAAK,MAAM,cAAc,CAAC;AAAA,eAC5B,GAAG;AACV,gBAAQ,MAAM,CAAC;AAAA,MAAA;AAAA,IAER,WAAA,iBAAiB,UAAa,UAAU,QAAW;AAC5D,eAAS,YAAY;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,KAAK,KAAK,CAAC;AAMf,QAAM,kBAAmCC,WAAA;AAAA,IACvC,CAAC,mBAAsC;AACrC,eAAS,CAAC,SAAS;AACjB,cAAM,WACJ,OAAO,mBAAmB,aACrB,eAAqC,IAAI,IAC1C;AAEN,sBAAc,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AAE5C,eAAA;AAAA,MAAA,CACR;AAAA,IACH;AAAA,IACA,CAAC,KAAK,QAAQ;AAAA,EAChB;AAEO,SAAAC,WAAAA,QAAQ,MAAM,CAAC,OAAO,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC;AACzE;;"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { SetStateAction, Dispatch } from 'react';
|
|
2
|
+
export declare const usePersistedStore: <S>(key: string, initialState?: S | (() => S)) => [S, Dispatch<SetStateAction<S>>];
|
|
2
3
|
//# sourceMappingURL=usePersistedStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedStore.d.ts","sourceRoot":"","sources":["../../src/hooks/usePersistedStore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePersistedStore.d.ts","sourceRoot":"","sources":["../../src/hooks/usePersistedStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,QAAQ,EAEd,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,CAAC,OAC5B,MAAM,iBACI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAC3B,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CA8DjC,CAAC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
const usePersistedStore = (key,
|
|
2
|
+
import { useState, useEffect, useCallback, useMemo } from "react";
|
|
3
|
+
const usePersistedStore = (key, initialState) => {
|
|
4
4
|
const [state, setState] = useState(() => {
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
if (initialState !== void 0) {
|
|
6
|
+
const result = typeof initialState === "function" ? initialState() : initialState;
|
|
7
|
+
if (typeof window === "undefined") return result;
|
|
8
|
+
const persistedState = localStorage?.getItem(key);
|
|
9
|
+
if (persistedState) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(persistedState);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error(e);
|
|
14
|
+
}
|
|
12
15
|
}
|
|
16
|
+
return result;
|
|
13
17
|
}
|
|
14
18
|
return void 0;
|
|
15
19
|
});
|
|
@@ -21,15 +25,21 @@ const usePersistedStore = (key, initialValue) => {
|
|
|
21
25
|
} catch (e) {
|
|
22
26
|
console.error(e);
|
|
23
27
|
}
|
|
24
|
-
} else if (
|
|
25
|
-
setState(
|
|
28
|
+
} else if (initialState !== void 0 && state === void 0) {
|
|
29
|
+
setState(initialState);
|
|
26
30
|
}
|
|
27
31
|
}, [key, state]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const setStateWrapper = useCallback(
|
|
33
|
+
(valueOrUpdater) => {
|
|
34
|
+
setState((prev) => {
|
|
35
|
+
const newValue = typeof valueOrUpdater === "function" ? valueOrUpdater(prev) : valueOrUpdater;
|
|
36
|
+
localStorage?.setItem(key, JSON.stringify(newValue));
|
|
37
|
+
return newValue;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
[key, setState]
|
|
41
|
+
);
|
|
42
|
+
return useMemo(() => [state, setStateWrapper], [state, setStateWrapper]);
|
|
33
43
|
};
|
|
34
44
|
export {
|
|
35
45
|
usePersistedStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePersistedStore.mjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"file":"usePersistedStore.mjs","sources":["../../src/hooks/usePersistedStore.ts"],"sourcesContent":["'use client';\n\nimport {\n useState,\n useEffect,\n useCallback,\n type SetStateAction,\n type Dispatch,\n useMemo,\n} from 'react';\n\nexport const usePersistedStore = <S>(\n key: string,\n initialState?: S | (() => S)\n): [S, Dispatch<SetStateAction<S>>] => {\n const [state, setState] = useState<S>(() => {\n // If you have an initial value on the client, send a message out immediately\n if (initialState !== undefined) {\n const result: S =\n typeof initialState === 'function'\n ? (initialState as () => S)()\n : initialState;\n\n if (typeof window === 'undefined') return result;\n\n const persistedState = localStorage?.getItem(key);\n\n if (persistedState) {\n try {\n return JSON.parse(persistedState);\n } catch (e) {\n console.error(e);\n }\n }\n\n return result;\n }\n\n return undefined as S;\n });\n\n useEffect(() => {\n const persistedState = localStorage?.getItem(key);\n\n if (persistedState && state === undefined) {\n try {\n setState(JSON.parse(persistedState));\n } catch (e) {\n console.error(e);\n }\n } else if (initialState !== undefined && state === undefined) {\n setState(initialState);\n }\n }, [key, state]);\n\n /**\n * Allows setting state either directly or via a functional update.\n * If passed a function, we merge/update based on the previous state.\n */\n const setStateWrapper: typeof setState = useCallback(\n (valueOrUpdater: SetStateAction<S>) => {\n setState((prev) => {\n const newValue: S =\n typeof valueOrUpdater === 'function'\n ? (valueOrUpdater as (prevVal: S) => S)(prev)\n : valueOrUpdater;\n\n localStorage?.setItem(key, JSON.stringify(newValue));\n\n return newValue;\n });\n },\n [key, setState]\n );\n\n return useMemo(() => [state, setStateWrapper], [state, setStateWrapper]);\n};\n"],"names":[],"mappings":";;AAWa,MAAA,oBAAoB,CAC/B,KACA,iBACqC;AACrC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,MAAM;AAE1C,QAAI,iBAAiB,QAAW;AAC9B,YAAM,SACJ,OAAO,iBAAiB,aACnB,aACD,IAAA;AAEF,UAAA,OAAO,WAAW,YAAoB,QAAA;AAEpC,YAAA,iBAAiB,cAAc,QAAQ,GAAG;AAEhD,UAAI,gBAAgB;AACd,YAAA;AACK,iBAAA,KAAK,MAAM,cAAc;AAAA,iBACzB,GAAG;AACV,kBAAQ,MAAM,CAAC;AAAA,QAAA;AAAA,MACjB;AAGK,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EAAA,CACR;AAED,YAAU,MAAM;AACR,UAAA,iBAAiB,cAAc,QAAQ,GAAG;AAE5C,QAAA,kBAAkB,UAAU,QAAW;AACrC,UAAA;AACO,iBAAA,KAAK,MAAM,cAAc,CAAC;AAAA,eAC5B,GAAG;AACV,gBAAQ,MAAM,CAAC;AAAA,MAAA;AAAA,IAER,WAAA,iBAAiB,UAAa,UAAU,QAAW;AAC5D,eAAS,YAAY;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,KAAK,KAAK,CAAC;AAMf,QAAM,kBAAmC;AAAA,IACvC,CAAC,mBAAsC;AACrC,eAAS,CAAC,SAAS;AACjB,cAAM,WACJ,OAAO,mBAAmB,aACrB,eAAqC,IAAI,IAC1C;AAEN,sBAAc,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AAE5C,eAAA;AAAA,MAAA,CACR;AAAA,IACH;AAAA,IACA,CAAC,KAAK,QAAQ;AAAA,EAChB;AAEO,SAAA,QAAQ,MAAM,CAAC,OAAO,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC;AACzE;"}
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
disableScroll = false,
|
|
11
|
-
element,
|
|
12
|
-
key = "unnamed_blocker"
|
|
13
|
-
} = props ?? {};
|
|
14
|
-
const { isElementScrollBlocked, addBlockage, removeBlockage } = hooks_useScrollBlockage_useScrollBlockageStore.useScrollBlockageStore(
|
|
15
|
-
shallow.useShallow((s) => ({
|
|
16
|
-
isElementScrollBlocked: s.isElementScrollBlocked,
|
|
17
|
-
addBlockage: s.addBlockage,
|
|
18
|
-
removeBlockage: s.removeBlockage
|
|
19
|
-
}))
|
|
20
|
-
);
|
|
21
|
-
const containerElement = hooks_useGetElementOrWindow.useGetElementOrWindow(element);
|
|
22
|
-
require$$0.useEffect(() => {
|
|
23
|
-
const el = element ?? window.document.body;
|
|
24
|
-
if (disableScroll) {
|
|
25
|
-
addBlockage(key, el);
|
|
26
|
-
} else {
|
|
27
|
-
removeBlockage(key, el);
|
|
28
|
-
}
|
|
29
|
-
}, [addBlockage, disableScroll, element, key, removeBlockage]);
|
|
30
|
-
const isScrollBlocked = containerElement ? isElementScrollBlocked(containerElement) : false;
|
|
31
|
-
return { isScrollBlocked };
|
|
32
|
-
};
|
|
33
|
-
exports.useScrollBlockage = useScrollBlockage;
|
|
3
|
+
require("react");
|
|
4
|
+
const hooks_useScrollBlockage_index = require("../../index-Cg-S9ry9.cjs");
|
|
5
|
+
require("../useGetElementOrWindow.cjs");
|
|
6
|
+
require("./useScrollBlockageStore.cjs");
|
|
7
|
+
exports.useScrollBlockage = hooks_useScrollBlockage_index.useScrollBlockage;
|
|
34
8
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useScrollBlockageStore } from "./useScrollBlockageStore.mjs";
|
|
6
|
-
const useScrollBlockage = (props) => {
|
|
7
|
-
const {
|
|
8
|
-
disableScroll = false,
|
|
9
|
-
element,
|
|
10
|
-
key = "unnamed_blocker"
|
|
11
|
-
} = props ?? {};
|
|
12
|
-
const { isElementScrollBlocked, addBlockage, removeBlockage } = useScrollBlockageStore(
|
|
13
|
-
useShallow((s) => ({
|
|
14
|
-
isElementScrollBlocked: s.isElementScrollBlocked,
|
|
15
|
-
addBlockage: s.addBlockage,
|
|
16
|
-
removeBlockage: s.removeBlockage
|
|
17
|
-
}))
|
|
18
|
-
);
|
|
19
|
-
const containerElement = useGetElementOrWindow(element);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const el = element ?? window.document.body;
|
|
22
|
-
if (disableScroll) {
|
|
23
|
-
addBlockage(key, el);
|
|
24
|
-
} else {
|
|
25
|
-
removeBlockage(key, el);
|
|
26
|
-
}
|
|
27
|
-
}, [addBlockage, disableScroll, element, key, removeBlockage]);
|
|
28
|
-
const isScrollBlocked = containerElement ? isElementScrollBlocked(containerElement) : false;
|
|
29
|
-
return { isScrollBlocked };
|
|
30
|
-
};
|
|
1
|
+
import "react";
|
|
2
|
+
import { u } from "../../index-O_7rYrbW.js";
|
|
3
|
+
import "../useGetElementOrWindow.mjs";
|
|
4
|
+
import "./useScrollBlockageStore.mjs";
|
|
31
5
|
export {
|
|
32
|
-
useScrollBlockage
|
|
6
|
+
u as useScrollBlockage
|
|
33
7
|
};
|
|
34
8
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require$$0 = require("react");
|
|
5
5
|
const hooks_useGetElementOrWindow = require("./useGetElementOrWindow.cjs");
|
|
6
|
-
const hooks_useScrollBlockage_index = require("
|
|
6
|
+
const hooks_useScrollBlockage_index = require("../index-Cg-S9ry9.cjs");
|
|
7
7
|
const useScrollDetection = (props) => {
|
|
8
8
|
const {
|
|
9
9
|
isEnabled = true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState, useCallback, useEffect } from "react";
|
|
3
3
|
import { useGetElementOrWindow } from "./useGetElementOrWindow.mjs";
|
|
4
|
-
import { useScrollBlockage } from "
|
|
4
|
+
import { u as useScrollBlockage } from "../index-O_7rYrbW.js";
|
|
5
5
|
const useScrollDetection = (props) => {
|
|
6
6
|
const {
|
|
7
7
|
isEnabled = true,
|