@gaddario98/react-core 2.0.3 → 2.0.5

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/index.mjs CHANGED
@@ -1,4 +1,12 @@
1
- export*from'@gaddario98/react-auth';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as React from'react';import React__default,{useReducer,useEffect,useDebugValue,useCallback,useContext,createContext,useRef,useState,memo,useMemo,useLayoutEffect}from'react';import {useApiValues as useApiValues$1,useApiConfigValue as useApiConfigValue$1,useApi as useApi$1,queriesAtom as queriesAtom$1}from'@gaddario98/react-queries';import {c}from'react/compiler-runtime';import {atomStateGenerator as atomStateGenerator$1,storage as storage$1}from'@gaddario98/react-state';import equal from'fast-deep-equal';import {useFormValues as useFormValues$1,useFormManager as useFormManager$1}from'@gaddario98/react-form';import {useSyncExternalStoreWithSelector}from'use-sync-external-store/shim/with-selector.js';/******************************************************************************
1
+ import {atomStateGenerator as atomStateGenerator$1,storage as storage$1}from'@gaddario98/react-state';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import*as React from'react';import React__default,{useReducer,useEffect,useDebugValue,useCallback,useContext,createContext,useRef,useState,memo,useMemo,useLayoutEffect}from'react';import {useApiValues as useApiValues$1,useApiConfigValue as useApiConfigValue$1,useApi as useApi$1,queriesAtom as queriesAtom$1}from'@gaddario98/react-queries';import {c}from'react/compiler-runtime';import equal from'fast-deep-equal';import {useFormValues as useFormValues$1,useFormManager as useFormManager$1}from'@gaddario98/react-form';import {useSyncExternalStoreWithSelector}from'use-sync-external-store/shim/with-selector.js';const {
2
+ atom: authAtom,
3
+ useValue: useAuthValue,
4
+ useState: useAuthState
5
+ } = atomStateGenerator$1({
6
+ defaultValue: null,
7
+ key: 'reactAuthStore',
8
+ persist: true
9
+ });/******************************************************************************
2
10
  Copyright (c) Microsoft Corporation.
3
11
 
4
12
  Permission to use, copy, modify, and/or distribute this software for any
@@ -20710,4 +20718,136 @@ function createExtractor(allData, cache, usedKeys) {
20710
20718
  */
20711
20719
  function withMemo(Component, propsAreEqual) {
20712
20720
  return memo(Component, propsAreEqual);
20713
- }export{AppProviders,DEFAULT_FORM_ENTRY,DEFAULT_MUTATION_ENTRY,DEFAULT_QUERY_ENTRY,DefaultContainer,DefaultFormContainer,FormField,FormManager,MemoizationCache,MetadataStoreProvider,PageGenerator,QueriesProvider,RenderComponents,ab2str,algorithm,apiConfigAtom,apiRequest,applyMetadataToDom,atomStateGenerator,buildArticleJsonLd,buildBreadcrumbListJsonLd,buildFAQPageJsonLd,buildOrganizationJsonLd,buildProductJsonLd,buildWebSiteJsonLd,clearMetadataLog,cn,collectMetadataToHtml,createExtractor,createFormSelector,createMetadataStore,createMutationSelector,createQuerySelector,createScopeFormsAtom,createScopeMutationsAtom,createScopePageVariablesAtom,createScopeQueriesAtom,createServerTranslator,decryptData,deepEqual,encryptData,fetchRequest,formAtom,formConfigAtom,generateLlmsFullTxt,generateLlmsTxt,generateRobotsTxt,generateSitemapEntries,generateSitemapXml,getCompositeKey,getFormCompositeKey,getMetadata,getMetadataLog,getPageConfig,getPageVariablesCompositeKey,importKey,isStableValue,localizationConfigAtom,logMetadata,memoPropsComparator,memoize,mutationsAtom,optimizeDeps,pageConfigAtom,pageToMarkdown,pageVariablesAtom,pageVariablesAtomFamily,queriesAtom,resetMetadata,resolveMetadata,resolveTranslation,setCustomStorage,setDefaultFormContainer,setMetadata,setMetadataLogging,shallowEqual,storage,str2ab,toNextHeadTags,toNextMetadata,useApi,useApiConfigReset,useApiConfigState,useApiConfigValue,useApiValues,useApplyMetadata,useFormConfigReset,useFormConfigState,useFormConfigValue,useFormData,useFormManager,useFormState,useFormValue,useFormValues,useGenerateContent,useGenerateContentRender,useInvalidateQueries,useJotaiForm,useJotaiMutations,useJotaiQueries,useLocalizationActions,useLocalizationConfigReset,useLocalizationConfigState,useLocalizationConfigValue,useMetadata,useMetadataStore,useMultipleMutation,useMultipleQuery,useMultipleWebSocket,useMutateApi,usePageConfig,usePageConfigReset,usePageConfigState,usePageConfigValue,useQueryApi,useSetFormState,useTranslatedText,useTranslation,useViewSettings,useWebSocket,withMemo};//# sourceMappingURL=index.mjs.map
20721
+ }const {
20722
+ useState: useNotificationState
20723
+ } = atomStateGenerator$1({
20724
+ defaultValue: null,
20725
+ key: 'reactNotificationAtom',
20726
+ persist: false
20727
+ });const useNotificationSet = () => {
20728
+ const [, setValue] = useNotificationState();
20729
+ return setValue;
20730
+ };
20731
+ const useNotification = t0 => {
20732
+ const $ = c(10);
20733
+ const ns = "notifications" ;
20734
+ const setNotification = useNotificationSet();
20735
+ let t1;
20736
+ if ($[0] !== ns || $[1] !== setNotification) {
20737
+ t1 = {
20738
+ setNotification,
20739
+ ns
20740
+ };
20741
+ $[0] = ns;
20742
+ $[1] = setNotification;
20743
+ $[2] = t1;
20744
+ } else {
20745
+ t1 = $[2];
20746
+ }
20747
+ const ref = useRef(t1);
20748
+ let t2;
20749
+ let t3;
20750
+ if ($[3] !== ns || $[4] !== setNotification) {
20751
+ t2 = () => {
20752
+ ref.current = {
20753
+ setNotification,
20754
+ ns
20755
+ };
20756
+ };
20757
+ t3 = [setNotification, ns];
20758
+ $[3] = ns;
20759
+ $[4] = setNotification;
20760
+ $[5] = t2;
20761
+ $[6] = t3;
20762
+ } else {
20763
+ t2 = $[5];
20764
+ t3 = $[6];
20765
+ }
20766
+ useEffect(t2, t3);
20767
+ let t4;
20768
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
20769
+ t4 = notification => {
20770
+ ref.current.setNotification(Object.assign(Object.assign({
20771
+ ns: ref.current.ns
20772
+ }, notification), {
20773
+ id: Date.now().toString()
20774
+ }));
20775
+ };
20776
+ $[7] = t4;
20777
+ } else {
20778
+ t4 = $[7];
20779
+ }
20780
+ const showNotification = t4;
20781
+ let t5;
20782
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
20783
+ t5 = () => {
20784
+ ref.current.setNotification(null);
20785
+ };
20786
+ $[8] = t5;
20787
+ } else {
20788
+ t5 = $[8];
20789
+ }
20790
+ const clearNotification = t5;
20791
+ let t6;
20792
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
20793
+ t6 = {
20794
+ showNotification,
20795
+ clearNotification
20796
+ };
20797
+ $[9] = t6;
20798
+ } else {
20799
+ t6 = $[9];
20800
+ }
20801
+ return t6;
20802
+ };/**
20803
+ * Hook per accedere a tutte le configurazioni dei plugin di core
20804
+ * Fornisce un'interfaccia centralizzata per le impostazioni dell'applicazione
20805
+ */
20806
+ const isLogged = authState => !!(authState === null || authState === void 0 ? void 0 : authState.id) && !!authState.isLogged;
20807
+ const useCoreConfig = ({
20808
+ form,
20809
+ localization,
20810
+ pages,
20811
+ apiConfig
20812
+ }) => {
20813
+ const auth = useAuthValue();
20814
+ const {
20815
+ t: translateText
20816
+ } = useTranslation();
20817
+ const {
20818
+ showNotification
20819
+ } = useNotification();
20820
+ const [currentFormConfig, setFormConfig] = useFormConfigState();
20821
+ const [currentLocalizationConfig, setLocalizationConfig] = useLocalizationConfigState();
20822
+ const [currentPageConfig, setPageConfig] = usePageConfigState();
20823
+ const [currentApiConfig, setApiConfig] = useApiConfigState();
20824
+ useEffect(() => {
20825
+ setFormConfig(Object.assign(Object.assign({
20826
+ translateText,
20827
+ showNotification
20828
+ }, currentFormConfig), form));
20829
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20830
+ }, [translateText, showNotification, form]);
20831
+ useEffect(() => {
20832
+ setLocalizationConfig(Object.assign(Object.assign({}, currentLocalizationConfig), localization));
20833
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20834
+ }, [JSON.stringify(localization)]);
20835
+ useEffect(() => {
20836
+ setPageConfig(Object.assign(Object.assign(Object.assign({
20837
+ authValues: auth
20838
+ }, currentPageConfig), pages), {
20839
+ isLogged
20840
+ }));
20841
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20842
+ }, [pages, JSON.stringify(auth)]);
20843
+ useEffect(() => {
20844
+ setApiConfig(Object.assign(Object.assign({
20845
+ defaultHeaders: {
20846
+ Authorization: (auth === null || auth === void 0 ? void 0 : auth.token) ? `Bearer ${auth.token}` : ""
20847
+ },
20848
+ showNotification,
20849
+ validateAuthFn: () => !!(auth === null || auth === void 0 ? void 0 : auth.isLogged)
20850
+ }, currentApiConfig), apiConfig));
20851
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20852
+ }, [apiConfig, showNotification, JSON.stringify(auth)]);
20853
+ };export{AppProviders,DEFAULT_FORM_ENTRY,DEFAULT_MUTATION_ENTRY,DEFAULT_QUERY_ENTRY,DefaultContainer,DefaultFormContainer,FormField,FormManager,MemoizationCache,MetadataStoreProvider,PageGenerator,QueriesProvider,RenderComponents,ab2str,algorithm,apiConfigAtom,apiRequest,applyMetadataToDom,atomStateGenerator,authAtom,buildArticleJsonLd,buildBreadcrumbListJsonLd,buildFAQPageJsonLd,buildOrganizationJsonLd,buildProductJsonLd,buildWebSiteJsonLd,clearMetadataLog,cn,collectMetadataToHtml,createExtractor,createFormSelector,createMetadataStore,createMutationSelector,createQuerySelector,createScopeFormsAtom,createScopeMutationsAtom,createScopePageVariablesAtom,createScopeQueriesAtom,createServerTranslator,decryptData,deepEqual,encryptData,fetchRequest,formAtom,formConfigAtom,generateLlmsFullTxt,generateLlmsTxt,generateRobotsTxt,generateSitemapEntries,generateSitemapXml,getCompositeKey,getFormCompositeKey,getMetadata,getMetadataLog,getPageConfig,getPageVariablesCompositeKey,importKey,isStableValue,localizationConfigAtom,logMetadata,memoPropsComparator,memoize,mutationsAtom,optimizeDeps,pageConfigAtom,pageToMarkdown,pageVariablesAtom,pageVariablesAtomFamily,queriesAtom,resetMetadata,resolveMetadata,resolveTranslation,setCustomStorage,setDefaultFormContainer,setMetadata,setMetadataLogging,shallowEqual,storage,str2ab,toNextHeadTags,toNextMetadata,useApi,useApiConfigReset,useApiConfigState,useApiConfigValue,useApiValues,useApplyMetadata,useAuthState,useAuthValue,useCoreConfig,useFormConfigReset,useFormConfigState,useFormConfigValue,useFormData,useFormManager,useFormState,useFormValue,useFormValues,useGenerateContent,useGenerateContentRender,useInvalidateQueries,useJotaiForm,useJotaiMutations,useJotaiQueries,useLocalizationActions,useLocalizationConfigReset,useLocalizationConfigState,useLocalizationConfigValue,useMetadata,useMetadataStore,useMultipleMutation,useMultipleQuery,useMultipleWebSocket,useMutateApi,usePageConfig,usePageConfigReset,usePageConfigState,usePageConfigValue,useQueryApi,useSetFormState,useTranslatedText,useTranslation,useViewSettings,useWebSocket,withMemo};//# sourceMappingURL=index.mjs.map