@tirth_jasoliya/ui 1.0.0 → 1.0.1
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.cjs +47 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -395,4 +395,4 @@ declare class GeneralHelper {
|
|
|
395
395
|
}) => React$1.JSX.Element;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
export { type AppMeta, AppMetaProvider, DataTable, DataTableActionBar, DataTableActionBarAction, DataTableActionBarSelection, type DataTableProps, DataTemplate, DataTemplateActionBar, DataTemplateActionBarAction, DataTemplateActionBarSelection, type DataTemplateProps, GeneralHelper, createLayoutComponents, createPageTemplateHook, createTypedAppMetaContext };
|
|
398
|
+
export { type AppMeta, AppMetaProvider, DataTable, DataTableActionBar, DataTableActionBarAction, DataTableActionBarSelection, type DataTableProps, DataTemplate, DataTemplateActionBar, DataTemplateActionBarAction, DataTemplateActionBarSelection, type DataTemplateProps, GeneralHelper, type GroupColumnDef, createLayoutComponents, createPageTemplateHook, createTypedAppMetaContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -395,4 +395,4 @@ declare class GeneralHelper {
|
|
|
395
395
|
}) => React$1.JSX.Element;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
export { type AppMeta, AppMetaProvider, DataTable, DataTableActionBar, DataTableActionBarAction, DataTableActionBarSelection, type DataTableProps, DataTemplate, DataTemplateActionBar, DataTemplateActionBarAction, DataTemplateActionBarSelection, type DataTemplateProps, GeneralHelper, createLayoutComponents, createPageTemplateHook, createTypedAppMetaContext };
|
|
398
|
+
export { type AppMeta, AppMetaProvider, DataTable, DataTableActionBar, DataTableActionBarAction, DataTableActionBarSelection, type DataTableProps, DataTemplate, DataTemplateActionBar, DataTemplateActionBarAction, DataTemplateActionBarSelection, type DataTemplateProps, GeneralHelper, type GroupColumnDef, createLayoutComponents, createPageTemplateHook, createTypedAppMetaContext };
|
package/dist/index.js
CHANGED
|
@@ -2690,7 +2690,7 @@ function createLayoutComponents({
|
|
|
2690
2690
|
}
|
|
2691
2691
|
|
|
2692
2692
|
// src/context/app-meta/context.tsx
|
|
2693
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState6, useCallback as useCallback5 } from "react";
|
|
2693
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState6, useCallback as useCallback5, useMemo as useMemo3 } from "react";
|
|
2694
2694
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2695
2695
|
var AppMetaContext = createContext2(void 0);
|
|
2696
2696
|
var AppMetaProvider = ({ children }) => {
|
|
@@ -2700,16 +2700,26 @@ var AppMetaProvider = ({ children }) => {
|
|
|
2700
2700
|
breadcrumbs: []
|
|
2701
2701
|
});
|
|
2702
2702
|
const setMeta = useCallback5((partialMeta) => {
|
|
2703
|
-
setMetaState((prev) =>
|
|
2703
|
+
setMetaState((prev) => {
|
|
2704
|
+
const hasChanges = Object.keys(partialMeta).some(
|
|
2705
|
+
(key) => JSON.stringify(prev[key]) !== JSON.stringify(partialMeta[key])
|
|
2706
|
+
);
|
|
2707
|
+
return hasChanges ? { ...prev, ...partialMeta } : prev;
|
|
2708
|
+
});
|
|
2704
2709
|
}, []);
|
|
2705
2710
|
const resetMeta = useCallback5(() => {
|
|
2706
|
-
setMetaState({
|
|
2711
|
+
setMetaState((prev) => prev.title === "" && prev.description === "" && (prev.breadcrumbs?.length ?? 0) === 0 ? prev : {
|
|
2707
2712
|
title: "",
|
|
2708
2713
|
description: "",
|
|
2709
2714
|
breadcrumbs: []
|
|
2710
2715
|
});
|
|
2711
2716
|
}, []);
|
|
2712
|
-
|
|
2717
|
+
const contextValue = useMemo3(() => ({
|
|
2718
|
+
meta,
|
|
2719
|
+
setMeta,
|
|
2720
|
+
resetMeta
|
|
2721
|
+
}), [meta, setMeta, resetMeta]);
|
|
2722
|
+
return /* @__PURE__ */ jsx32(AppMetaContext.Provider, { value: contextValue, children });
|
|
2713
2723
|
};
|
|
2714
2724
|
function createTypedAppMetaContext() {
|
|
2715
2725
|
const TypedAppMetaContext = createContext2(void 0);
|
|
@@ -2720,16 +2730,28 @@ function createTypedAppMetaContext() {
|
|
|
2720
2730
|
breadcrumbs: []
|
|
2721
2731
|
});
|
|
2722
2732
|
const setMeta = useCallback5((partialMeta) => {
|
|
2723
|
-
setMetaState((prev) =>
|
|
2733
|
+
setMetaState((prev) => {
|
|
2734
|
+
const hasChanges = Object.keys(partialMeta).some((key) => {
|
|
2735
|
+
const prevValue = prev[key];
|
|
2736
|
+
const newValue = partialMeta[key];
|
|
2737
|
+
return JSON.stringify(prevValue) !== JSON.stringify(newValue);
|
|
2738
|
+
});
|
|
2739
|
+
return hasChanges ? { ...prev, ...partialMeta } : prev;
|
|
2740
|
+
});
|
|
2724
2741
|
}, []);
|
|
2725
2742
|
const resetMeta = useCallback5(() => {
|
|
2726
|
-
setMetaState({
|
|
2743
|
+
setMetaState((prev) => prev.title === "" && prev.description === "" && (prev.breadcrumbs?.length ?? 0) === 0 ? prev : {
|
|
2727
2744
|
title: "",
|
|
2728
2745
|
description: "",
|
|
2729
2746
|
breadcrumbs: []
|
|
2730
2747
|
});
|
|
2731
2748
|
}, []);
|
|
2732
|
-
|
|
2749
|
+
const contextValue = useMemo3(() => ({
|
|
2750
|
+
meta,
|
|
2751
|
+
setMeta,
|
|
2752
|
+
resetMeta
|
|
2753
|
+
}), [meta, setMeta, resetMeta]);
|
|
2754
|
+
return /* @__PURE__ */ jsx32(TypedAppMetaContext.Provider, { value: contextValue, children });
|
|
2733
2755
|
};
|
|
2734
2756
|
const useTypedAppMeta = () => {
|
|
2735
2757
|
const context = useContext2(TypedAppMetaContext);
|
|
@@ -2742,27 +2764,40 @@ function createTypedAppMetaContext() {
|
|
|
2742
2764
|
}
|
|
2743
2765
|
|
|
2744
2766
|
// src/context/app-meta/hooks.ts
|
|
2745
|
-
import { useEffect as useEffect5, useMemo as
|
|
2767
|
+
import { useEffect as useEffect5, useMemo as useMemo4 } from "react";
|
|
2746
2768
|
function createPageTemplateHook({
|
|
2747
2769
|
useTypedAppMeta
|
|
2748
2770
|
}) {
|
|
2749
2771
|
function usePageTemplate(options) {
|
|
2750
2772
|
const { setMeta, resetMeta } = useTypedAppMeta();
|
|
2751
|
-
const
|
|
2773
|
+
const backAction = useMemo4(() => {
|
|
2774
|
+
if (!options.backAction) return void 0;
|
|
2775
|
+
return {
|
|
2776
|
+
...options.backAction,
|
|
2777
|
+
onClick: options.backAction.onClick
|
|
2778
|
+
// Keep as is - we'll handle stabilization differently
|
|
2779
|
+
};
|
|
2780
|
+
}, [options.backAction?.content, options.backAction?.href, options.backAction?.onClick?.toString()]);
|
|
2781
|
+
const metadata = useMemo4(() => options.metadata, [JSON.stringify(options.metadata)]);
|
|
2782
|
+
const stableOptions = useMemo4(() => ({
|
|
2783
|
+
...options,
|
|
2784
|
+
backAction,
|
|
2785
|
+
metadata
|
|
2786
|
+
}), [
|
|
2752
2787
|
options.title,
|
|
2753
2788
|
options.description,
|
|
2754
2789
|
options.breadcrumbs,
|
|
2755
2790
|
options.primaryActions,
|
|
2756
2791
|
options.secondaryActions,
|
|
2757
|
-
options.backAction,
|
|
2758
2792
|
options.pagination,
|
|
2759
|
-
options.
|
|
2760
|
-
|
|
2793
|
+
options.status,
|
|
2794
|
+
backAction,
|
|
2795
|
+
metadata
|
|
2761
2796
|
]);
|
|
2762
2797
|
useEffect5(() => {
|
|
2763
|
-
setMeta(
|
|
2798
|
+
setMeta(stableOptions);
|
|
2764
2799
|
return () => resetMeta();
|
|
2765
|
-
}, [
|
|
2800
|
+
}, [stableOptions, setMeta, resetMeta]);
|
|
2766
2801
|
}
|
|
2767
2802
|
return { usePageTemplate };
|
|
2768
2803
|
}
|