@tirth_jasoliya/ui 1.0.0 → 1.0.2
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 +49 -14
- 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 +51 -16
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
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
|
@@ -2271,6 +2271,7 @@ var AppContainer = ({
|
|
|
2271
2271
|
|
|
2272
2272
|
// src/components/layouts/app-header.tsx
|
|
2273
2273
|
import { ArrowLeftIcon, ChevronRight as ChevronRight2 } from "lucide-react";
|
|
2274
|
+
import { NavLink } from "react-router";
|
|
2274
2275
|
import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2275
2276
|
var AppHeader = ({
|
|
2276
2277
|
className,
|
|
@@ -2286,10 +2287,10 @@ var AppHeader = ({
|
|
|
2286
2287
|
className: "hover:bg-primary/20 inline-flex"
|
|
2287
2288
|
};
|
|
2288
2289
|
if (meta.backAction.href) {
|
|
2289
|
-
return /* @__PURE__ */ jsxs17(Button, { ...buttonProps, children: [
|
|
2290
|
+
return /* @__PURE__ */ jsx27(NavLink, { to: meta.backAction.href, children: /* @__PURE__ */ jsxs17(Button, { ...buttonProps, children: [
|
|
2290
2291
|
/* @__PURE__ */ jsx27(ArrowLeftIcon, { className: "size-6" }),
|
|
2291
2292
|
meta.backAction.content
|
|
2292
|
-
] });
|
|
2293
|
+
] }) });
|
|
2293
2294
|
}
|
|
2294
2295
|
return /* @__PURE__ */ jsxs17(Button, { ...buttonProps, onClick: meta.backAction.onClick, children: [
|
|
2295
2296
|
/* @__PURE__ */ jsx27(ArrowLeftIcon, { className: "size-6" }),
|
|
@@ -2690,7 +2691,7 @@ function createLayoutComponents({
|
|
|
2690
2691
|
}
|
|
2691
2692
|
|
|
2692
2693
|
// src/context/app-meta/context.tsx
|
|
2693
|
-
import { createContext as createContext2, useContext as useContext2, useState as useState6, useCallback as useCallback5 } from "react";
|
|
2694
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState6, useCallback as useCallback5, useMemo as useMemo3 } from "react";
|
|
2694
2695
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2695
2696
|
var AppMetaContext = createContext2(void 0);
|
|
2696
2697
|
var AppMetaProvider = ({ children }) => {
|
|
@@ -2700,16 +2701,26 @@ var AppMetaProvider = ({ children }) => {
|
|
|
2700
2701
|
breadcrumbs: []
|
|
2701
2702
|
});
|
|
2702
2703
|
const setMeta = useCallback5((partialMeta) => {
|
|
2703
|
-
setMetaState((prev) =>
|
|
2704
|
+
setMetaState((prev) => {
|
|
2705
|
+
const hasChanges = Object.keys(partialMeta).some(
|
|
2706
|
+
(key) => JSON.stringify(prev[key]) !== JSON.stringify(partialMeta[key])
|
|
2707
|
+
);
|
|
2708
|
+
return hasChanges ? { ...prev, ...partialMeta } : prev;
|
|
2709
|
+
});
|
|
2704
2710
|
}, []);
|
|
2705
2711
|
const resetMeta = useCallback5(() => {
|
|
2706
|
-
setMetaState({
|
|
2712
|
+
setMetaState((prev) => prev.title === "" && prev.description === "" && (prev.breadcrumbs?.length ?? 0) === 0 ? prev : {
|
|
2707
2713
|
title: "",
|
|
2708
2714
|
description: "",
|
|
2709
2715
|
breadcrumbs: []
|
|
2710
2716
|
});
|
|
2711
2717
|
}, []);
|
|
2712
|
-
|
|
2718
|
+
const contextValue = useMemo3(() => ({
|
|
2719
|
+
meta,
|
|
2720
|
+
setMeta,
|
|
2721
|
+
resetMeta
|
|
2722
|
+
}), [meta, setMeta, resetMeta]);
|
|
2723
|
+
return /* @__PURE__ */ jsx32(AppMetaContext.Provider, { value: contextValue, children });
|
|
2713
2724
|
};
|
|
2714
2725
|
function createTypedAppMetaContext() {
|
|
2715
2726
|
const TypedAppMetaContext = createContext2(void 0);
|
|
@@ -2720,16 +2731,28 @@ function createTypedAppMetaContext() {
|
|
|
2720
2731
|
breadcrumbs: []
|
|
2721
2732
|
});
|
|
2722
2733
|
const setMeta = useCallback5((partialMeta) => {
|
|
2723
|
-
setMetaState((prev) =>
|
|
2734
|
+
setMetaState((prev) => {
|
|
2735
|
+
const hasChanges = Object.keys(partialMeta).some((key) => {
|
|
2736
|
+
const prevValue = prev[key];
|
|
2737
|
+
const newValue = partialMeta[key];
|
|
2738
|
+
return JSON.stringify(prevValue) !== JSON.stringify(newValue);
|
|
2739
|
+
});
|
|
2740
|
+
return hasChanges ? { ...prev, ...partialMeta } : prev;
|
|
2741
|
+
});
|
|
2724
2742
|
}, []);
|
|
2725
2743
|
const resetMeta = useCallback5(() => {
|
|
2726
|
-
setMetaState({
|
|
2744
|
+
setMetaState((prev) => prev.title === "" && prev.description === "" && (prev.breadcrumbs?.length ?? 0) === 0 ? prev : {
|
|
2727
2745
|
title: "",
|
|
2728
2746
|
description: "",
|
|
2729
2747
|
breadcrumbs: []
|
|
2730
2748
|
});
|
|
2731
2749
|
}, []);
|
|
2732
|
-
|
|
2750
|
+
const contextValue = useMemo3(() => ({
|
|
2751
|
+
meta,
|
|
2752
|
+
setMeta,
|
|
2753
|
+
resetMeta
|
|
2754
|
+
}), [meta, setMeta, resetMeta]);
|
|
2755
|
+
return /* @__PURE__ */ jsx32(TypedAppMetaContext.Provider, { value: contextValue, children });
|
|
2733
2756
|
};
|
|
2734
2757
|
const useTypedAppMeta = () => {
|
|
2735
2758
|
const context = useContext2(TypedAppMetaContext);
|
|
@@ -2742,27 +2765,39 @@ function createTypedAppMetaContext() {
|
|
|
2742
2765
|
}
|
|
2743
2766
|
|
|
2744
2767
|
// src/context/app-meta/hooks.ts
|
|
2745
|
-
import { useEffect as useEffect5, useMemo as
|
|
2768
|
+
import { useEffect as useEffect5, useMemo as useMemo4 } from "react";
|
|
2746
2769
|
function createPageTemplateHook({
|
|
2747
2770
|
useTypedAppMeta
|
|
2748
2771
|
}) {
|
|
2749
2772
|
function usePageTemplate(options) {
|
|
2750
2773
|
const { setMeta, resetMeta } = useTypedAppMeta();
|
|
2751
|
-
const
|
|
2774
|
+
const backAction = useMemo4(() => {
|
|
2775
|
+
if (!options.backAction) return void 0;
|
|
2776
|
+
return {
|
|
2777
|
+
...options.backAction,
|
|
2778
|
+
onClick: options.backAction.onClick
|
|
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
|
}
|