@creopse/react 0.0.10 → 0.0.11
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/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/{index-4XGApE5d.js → index-B7GqfDTJ.js} +18 -13
- package/dist/{index-ZewuA4XM.cjs → index-C3UpNpqk.cjs} +18 -13
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/types/hooks/config.d.ts +1 -0
- package/types/hooks/helper.d.ts +5 -5
- package/types/types/plugin.d.ts +1 -0
package/dist/hooks/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../index-
|
|
3
|
+
const index = require("../index-C3UpNpqk.cjs");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const react = require("@inertiajs/react");
|
|
6
6
|
const useProps = () => {
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PropsContext, b as useApi, u as useHelper, a as ResolveSectionsContext, c as cloneDeep } from "../index-
|
|
2
|
-
import { d } from "../index-
|
|
1
|
+
import { P as PropsContext, b as useApi, u as useHelper, a as ResolveSectionsContext, c as cloneDeep } from "../index-B7GqfDTJ.js";
|
|
2
|
+
import { d } from "../index-B7GqfDTJ.js";
|
|
3
3
|
import { useContext, useState, useEffect, useCallback, useMemo } from "react";
|
|
4
4
|
import { usePage } from "@inertiajs/react";
|
|
5
5
|
const useProps = () => {
|
|
@@ -6949,7 +6949,7 @@ const useMediaQuery = (query) => {
|
|
|
6949
6949
|
const useHelper = () => {
|
|
6950
6950
|
const page = usePage();
|
|
6951
6951
|
const { request } = useApi();
|
|
6952
|
-
const { apiBaseUrl } = useConfig();
|
|
6952
|
+
const { apiBaseUrl, langKey } = useConfig();
|
|
6953
6953
|
const currentRoutePath = useMemo(() => page.url, [page.url]);
|
|
6954
6954
|
const resolveUrl = useCallback(
|
|
6955
6955
|
(path) => {
|
|
@@ -6990,15 +6990,19 @@ const useHelper = () => {
|
|
|
6990
6990
|
},
|
|
6991
6991
|
[fileUrl]
|
|
6992
6992
|
);
|
|
6993
|
-
const getTranslation = useCallback(
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
6993
|
+
const getTranslation = useCallback(
|
|
6994
|
+
(data, lang2) => {
|
|
6995
|
+
let parsedData;
|
|
6996
|
+
if (!lang2) lang2 = localStorage.getItem(langKey) || "en";
|
|
6997
|
+
try {
|
|
6998
|
+
parsedData = JSON.parse(data);
|
|
6999
|
+
} catch (e) {
|
|
7000
|
+
parsedData = {};
|
|
7001
|
+
}
|
|
7002
|
+
return parsedData ? parsedData[lang2.toUpperCase()] || parsedData[lang2] || parsedData["en"] || "" : "";
|
|
7003
|
+
},
|
|
7004
|
+
[langKey]
|
|
7005
|
+
);
|
|
7002
7006
|
const tr = useCallback(
|
|
7003
7007
|
(data, lang2) => {
|
|
7004
7008
|
return getTranslation(data, lang2);
|
|
@@ -7074,8 +7078,9 @@ const useHelper = () => {
|
|
|
7074
7078
|
(label) => languages.find((l) => l.label === label)?.value,
|
|
7075
7079
|
[languages]
|
|
7076
7080
|
);
|
|
7077
|
-
const
|
|
7081
|
+
const updateLang = useCallback(
|
|
7078
7082
|
async (val, reload = true, updateUserPrefs = true) => {
|
|
7083
|
+
localStorage.setItem(langKey, val);
|
|
7079
7084
|
if (page.props.isUserLoggedIn && updateUserPrefs) {
|
|
7080
7085
|
const userPrefs = page.props.userData?.preferences || {
|
|
7081
7086
|
inAppNotifEnabled: Bool.TRUE,
|
|
@@ -7093,7 +7098,7 @@ const useHelper = () => {
|
|
|
7093
7098
|
}
|
|
7094
7099
|
if (reload) location.reload();
|
|
7095
7100
|
},
|
|
7096
|
-
[page.props, request]
|
|
7101
|
+
[langKey, page.props, request]
|
|
7097
7102
|
);
|
|
7098
7103
|
const displayFormErrors = useCallback(
|
|
7099
7104
|
(errors, displayError) => {
|
|
@@ -7183,7 +7188,7 @@ const useHelper = () => {
|
|
|
7183
7188
|
displayFormErrors,
|
|
7184
7189
|
resolveHtmlLinks,
|
|
7185
7190
|
resolveUrl,
|
|
7186
|
-
|
|
7191
|
+
updateLang,
|
|
7187
7192
|
languages,
|
|
7188
7193
|
getImage,
|
|
7189
7194
|
fileUrl,
|
|
@@ -6950,7 +6950,7 @@ const useMediaQuery = (query) => {
|
|
|
6950
6950
|
const useHelper = () => {
|
|
6951
6951
|
const page = react.usePage();
|
|
6952
6952
|
const { request } = useApi();
|
|
6953
|
-
const { apiBaseUrl } = useConfig();
|
|
6953
|
+
const { apiBaseUrl, langKey } = useConfig();
|
|
6954
6954
|
const currentRoutePath = React.useMemo(() => page.url, [page.url]);
|
|
6955
6955
|
const resolveUrl = React.useCallback(
|
|
6956
6956
|
(path) => {
|
|
@@ -6991,15 +6991,19 @@ const useHelper = () => {
|
|
|
6991
6991
|
},
|
|
6992
6992
|
[fileUrl]
|
|
6993
6993
|
);
|
|
6994
|
-
const getTranslation = React.useCallback(
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
6994
|
+
const getTranslation = React.useCallback(
|
|
6995
|
+
(data, lang2) => {
|
|
6996
|
+
let parsedData;
|
|
6997
|
+
if (!lang2) lang2 = localStorage.getItem(langKey) || "en";
|
|
6998
|
+
try {
|
|
6999
|
+
parsedData = JSON.parse(data);
|
|
7000
|
+
} catch (e) {
|
|
7001
|
+
parsedData = {};
|
|
7002
|
+
}
|
|
7003
|
+
return parsedData ? parsedData[lang2.toUpperCase()] || parsedData[lang2] || parsedData["en"] || "" : "";
|
|
7004
|
+
},
|
|
7005
|
+
[langKey]
|
|
7006
|
+
);
|
|
7003
7007
|
const tr = React.useCallback(
|
|
7004
7008
|
(data, lang2) => {
|
|
7005
7009
|
return getTranslation(data, lang2);
|
|
@@ -7075,8 +7079,9 @@ const useHelper = () => {
|
|
|
7075
7079
|
(label) => languages.find((l) => l.label === label)?.value,
|
|
7076
7080
|
[languages]
|
|
7077
7081
|
);
|
|
7078
|
-
const
|
|
7082
|
+
const updateLang = React.useCallback(
|
|
7079
7083
|
async (val, reload = true, updateUserPrefs = true) => {
|
|
7084
|
+
localStorage.setItem(langKey, val);
|
|
7080
7085
|
if (page.props.isUserLoggedIn && updateUserPrefs) {
|
|
7081
7086
|
const userPrefs = page.props.userData?.preferences || {
|
|
7082
7087
|
inAppNotifEnabled: Bool.TRUE,
|
|
@@ -7094,7 +7099,7 @@ const useHelper = () => {
|
|
|
7094
7099
|
}
|
|
7095
7100
|
if (reload) location.reload();
|
|
7096
7101
|
},
|
|
7097
|
-
[page.props, request]
|
|
7102
|
+
[langKey, page.props, request]
|
|
7098
7103
|
);
|
|
7099
7104
|
const displayFormErrors = React.useCallback(
|
|
7100
7105
|
(errors, displayError) => {
|
|
@@ -7184,7 +7189,7 @@ const useHelper = () => {
|
|
|
7184
7189
|
displayFormErrors,
|
|
7185
7190
|
resolveHtmlLinks,
|
|
7186
7191
|
resolveUrl,
|
|
7187
|
-
|
|
7192
|
+
updateLang,
|
|
7188
7193
|
languages,
|
|
7189
7194
|
getImage,
|
|
7190
7195
|
fileUrl,
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const index = require("./index-
|
|
4
|
+
const index = require("./index-C3UpNpqk.cjs");
|
|
5
5
|
require("@inertiajs/react");
|
|
6
6
|
const reactDom = require("react-dom");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React__default, { useState, useEffect, createContext, useRef, useLayoutEffect, useId, useContext, useInsertionEffect, useMemo, useCallback, Children, isValidElement, Fragment, createElement, forwardRef, Component } from "react";
|
|
3
|
-
import { u as useHelper, s as slideToId, E as EditorMessageType, R as RouterContext, C as ConfigContext, a as ResolveSectionsContext, P as PropsContext } from "./index-
|
|
3
|
+
import { u as useHelper, s as slideToId, E as EditorMessageType, R as RouterContext, C as ConfigContext, a as ResolveSectionsContext, P as PropsContext } from "./index-B7GqfDTJ.js";
|
|
4
4
|
import "@inertiajs/react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
var jsxRuntime = { exports: {} };
|
package/package.json
CHANGED
package/types/hooks/config.d.ts
CHANGED
package/types/hooks/helper.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ export declare const useHelper: () => {
|
|
|
10
10
|
isLgScreen: boolean;
|
|
11
11
|
isMdScreen: boolean;
|
|
12
12
|
isSmScreen: boolean;
|
|
13
|
-
getTranslation: (data: any, lang
|
|
13
|
+
getTranslation: (data: any, lang?: string) => string;
|
|
14
14
|
getLangageLabel: (value: string) => string | undefined;
|
|
15
15
|
getLanguageValue: (label: string) => string | undefined;
|
|
16
16
|
ckEditorToolbarItems: string[];
|
|
17
17
|
displayFormErrors: (errors: any, displayError: (message: string) => void) => void;
|
|
18
|
-
resolveHtmlLinks: (data: string | null | undefined, lang
|
|
18
|
+
resolveHtmlLinks: (data: string | null | undefined, lang?: string) => string;
|
|
19
19
|
resolveUrl: (path: string) => string;
|
|
20
|
-
|
|
20
|
+
updateLang: (val: string, reload?: boolean, updateUserPrefs?: boolean) => Promise<void>;
|
|
21
21
|
languages: Language[];
|
|
22
22
|
getImage: (path: string, size?: "small" | "medium" | "large" | "original") => Promise<string>;
|
|
23
23
|
fileUrl: (path: string) => string;
|
|
@@ -25,6 +25,6 @@ export declare const useHelper: () => {
|
|
|
25
25
|
openLink: (str: string) => void;
|
|
26
26
|
openMenu: (menu?: MenuItemModel) => void;
|
|
27
27
|
getMenuHref: (menu: MenuItemModel) => string;
|
|
28
|
-
rHtml: (data: string | null | undefined, lang
|
|
29
|
-
tr: (data: any, lang
|
|
28
|
+
rHtml: (data: string | null | undefined, lang?: string) => string;
|
|
29
|
+
tr: (data: any, lang?: string) => string;
|
|
30
30
|
};
|