@akanjs/ui 0.9.42 → 0.9.44

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.
Files changed (48) hide show
  1. package/Clipboard.d.ts +7 -0
  2. package/Data/CardList.d.ts +1 -1
  3. package/Data/Dashboard.d.ts +2 -3
  4. package/Data/Item.d.ts +4 -4
  5. package/Data/ListContainer.d.ts +10 -6
  6. package/Data/TableList.d.ts +1 -1
  7. package/Model/AdminPanel.d.ts +31 -0
  8. package/Model/index.d.ts +1 -0
  9. package/Model/index_.d.ts +1 -0
  10. package/System/Client.d.ts +8 -2
  11. package/cjs/Clipboard.js +70 -0
  12. package/cjs/Data/Item.js +2 -5
  13. package/cjs/Data/ListContainer.js +7 -14
  14. package/cjs/Data/QueryMaker.js +4 -11
  15. package/cjs/Layout/BottomTab.js +8 -1
  16. package/cjs/Model/AdminPanel.js +46 -0
  17. package/cjs/Model/index.js +2 -1
  18. package/cjs/Model/index_.js +2 -0
  19. package/cjs/Signal/Listener.js +3 -3
  20. package/cjs/Signal/Message.js +2 -2
  21. package/cjs/Signal/PubSub.js +4 -7
  22. package/cjs/System/CSR.js +5 -3
  23. package/cjs/System/Client.js +6 -2
  24. package/cjs/System/Common.js +24 -28
  25. package/cjs/System/Reconnect.js +1 -1
  26. package/cjs/System/SSR.js +6 -3
  27. package/cjs/System/ThemeToggle.js +1 -1
  28. package/cjs/index.js +2 -0
  29. package/esm/Clipboard.js +51 -0
  30. package/esm/Data/Item.js +2 -5
  31. package/esm/Data/ListContainer.js +7 -14
  32. package/esm/Data/QueryMaker.js +4 -12
  33. package/esm/Layout/BottomTab.js +8 -1
  34. package/esm/Model/AdminPanel.js +27 -0
  35. package/esm/Model/index.js +3 -1
  36. package/esm/Model/index_.js +2 -0
  37. package/esm/Signal/Listener.js +3 -3
  38. package/esm/Signal/Message.js +2 -2
  39. package/esm/Signal/PubSub.js +4 -7
  40. package/esm/System/CSR.js +5 -3
  41. package/esm/System/Client.js +7 -2
  42. package/esm/System/Common.js +25 -29
  43. package/esm/System/Reconnect.js +1 -1
  44. package/esm/System/SSR.js +6 -3
  45. package/esm/System/ThemeToggle.js +1 -1
  46. package/esm/index.js +2 -0
  47. package/index.d.ts +1 -0
  48. package/package.json +1 -1
package/Clipboard.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { type ReactElement } from "react";
2
+ export interface ClipboardProps {
3
+ text?: string;
4
+ clipboardMessage?: string;
5
+ className?: string;
6
+ }
7
+ export declare const Clipboard: ({ text, className }: ClipboardProps) => ReactElement;
@@ -21,7 +21,7 @@ interface CardListProps<T extends string, Input, Full extends {
21
21
  init?: FetchInitForm<Input, Full, Filter>;
22
22
  sliceName: string;
23
23
  columns: DataColumn<any>[];
24
- actions?: DataAction<Light>[] | ((item: Light, idx: number) => DataAction<Light>[]);
24
+ actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
25
25
  renderItem: (args: DataItemProps<T, Full, Light>) => ReactNode;
26
26
  renderLoading?: () => ReactNode;
27
27
  renderTemplate?: (props: any) => ReactNode | null;
@@ -1,5 +1,4 @@
1
- import { StoreOf } from "@akanjs/store";
2
- export interface DashboardProps<T extends string, State, SL extends StoreOf<T, State>> {
1
+ export interface DashboardProps<T extends string, State> {
3
2
  className?: string;
4
3
  summary: {
5
4
  [key: string]: any;
@@ -12,4 +11,4 @@ export interface DashboardProps<T extends string, State, SL extends StoreOf<T, S
12
11
  presents?: string[];
13
12
  hidePresents?: boolean;
14
13
  }
15
- export default function Dashboard<T extends string, State, SL extends StoreOf<T, State>>({ className, summary, sliceName, queryMap, columns, presents, hidePresents, }: DashboardProps<T, State, SL>): import("react/jsx-runtime").JSX.Element;
14
+ export default function Dashboard<T extends string, State>({ className, summary, sliceName, queryMap, columns, presents, hidePresents, }: DashboardProps<T, State>): import("react/jsx-runtime").JSX.Element;
package/Data/Item.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Dayjs } from "@akanjs/base";
2
2
  import { DataAction, DataColumn } from "@akanjs/client";
3
- import React, { ReactNode } from "react";
3
+ import { ReactNode } from "react";
4
4
  export declare const convToAntdColumn: (column: DataColumn<any>) => {
5
5
  key: string;
6
6
  dataIndex: string;
@@ -37,7 +37,7 @@ interface ItemProps<T extends string, Full extends {
37
37
  onClick?: () => void;
38
38
  cover?: ReactNode;
39
39
  title?: ReactNode;
40
- actions?: DataAction<Light>[];
40
+ actions?: DataAction[];
41
41
  columns?: DataColumn<any>[];
42
42
  children?: ReactNode;
43
43
  }
@@ -61,7 +61,7 @@ interface ActionProps<T extends string, M extends {
61
61
  }, L extends {
62
62
  id: string;
63
63
  }> {
64
- action: DataAction<L>;
64
+ action: DataAction;
65
65
  model: L;
66
66
  sliceName: string;
67
67
  }
@@ -71,4 +71,4 @@ export declare const Action: <T extends string, M extends {
71
71
  id: string;
72
72
  }>({ action, model, sliceName, outline, }: ActionProps<T, M, L> & {
73
73
  outline?: boolean;
74
- }) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
74
+ }) => import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -2,7 +2,7 @@ import { DataAction, DataColumn, DataTool, ModelInsightProps, ModelProps } from
2
2
  import { SortType } from "@akanjs/constant";
3
3
  import { type FetchInitForm } from "@akanjs/signal";
4
4
  import { ReactNode } from "react";
5
- interface ListContainerProps<T extends string, State, Input, Full extends {
5
+ export interface ListContainerProps<T extends string, State, Input, Full extends {
6
6
  id: string;
7
7
  }, Light extends {
8
8
  id: string;
@@ -14,20 +14,25 @@ interface ListContainerProps<T extends string, State, Input, Full extends {
14
14
  [key: string]: any;
15
15
  };
16
16
  init?: FetchInitForm<Input, Full, Sort>;
17
- sliceName: string;
17
+ sliceName: T;
18
18
  create?: boolean;
19
19
  title?: string;
20
20
  sort?: SortType;
21
21
  columns?: DataColumn<any>[];
22
22
  tools?: DataTool[] | ((modelList: Light[]) => DataTool[]);
23
- actions?: DataAction<Light>[] | ((item: Light, idx: number) => DataAction<Light>[]);
24
- renderDashboard?: ({ summary, hidePresents }: any) => ReactNode;
23
+ actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
24
+ renderDashboard?: ({ summary, hidePresents, }: {
25
+ summary: {
26
+ [key: string]: any;
27
+ };
28
+ hidePresents?: boolean;
29
+ }) => ReactNode;
25
30
  renderItem?: (props: ModelProps<any, any>) => ReactNode;
26
31
  renderTemplate?: (props: any) => ReactNode | null;
27
32
  renderTitle?: (model: Full) => string | ReactNode;
28
33
  renderView?: (model: Full) => ReactNode | null;
29
34
  renderQueryMaker?: () => ReactNode;
30
- renderInsight?: (props: ModelInsightProps<any>) => ReactNode;
35
+ renderInsight?: (props: ModelInsightProps) => ReactNode;
31
36
  renderLoading?: () => ReactNode;
32
37
  }
33
38
  export default function ListContainer<T extends string, State, Input, Full extends {
@@ -35,4 +40,3 @@ export default function ListContainer<T extends string, State, Input, Full exten
35
40
  }, Light extends {
36
41
  id: string;
37
42
  }, Sort extends SortType>({ className, cardListClassName, type, query, init, create, sliceName, title, sort, columns, actions, tools, renderDashboard, renderItem, renderTemplate, renderTitle, renderView, renderQueryMaker, renderInsight, renderLoading, }: ListContainerProps<T, State, Input, Full, Light, Sort>): import("react/jsx-runtime").JSX.Element;
38
- export {};
@@ -15,7 +15,7 @@ interface TableListProps<T extends string, Input, Full extends {
15
15
  renderTemplate?: (props: any) => ReactNode | null;
16
16
  renderTitle?: (model: Full) => string | ReactNode;
17
17
  renderView?: (model: Full) => ReactNode | null;
18
- actions?: DataAction<Light>[] | ((item: Light, idx: number) => DataAction<Light>[]);
18
+ actions?: DataAction[] | ((item: Light, idx: number) => DataAction[]);
19
19
  onItemClick?: (item: Light, idx: number) => void;
20
20
  }
21
21
  export default function TableList<T extends string, Input, Full extends {
@@ -0,0 +1,31 @@
1
+ import { type SortType } from "@akanjs/constant";
2
+ import type { ListContainerProps } from "../Data/ListContainer";
3
+ interface AdminPanelProps<T extends string, State, Input, Full extends {
4
+ id: string;
5
+ }, Light extends {
6
+ id: string;
7
+ }, Sort extends SortType> extends ListContainerProps<T, State, Input, Full, Light, Sort> {
8
+ sliceName: T;
9
+ components: {
10
+ Template: {
11
+ [key: string]: any;
12
+ };
13
+ Unit: {
14
+ [key: string]: any;
15
+ };
16
+ View: {
17
+ [key: string]: any;
18
+ };
19
+ };
20
+ queryMap?: {
21
+ [key: string]: any;
22
+ };
23
+ summaryColumns?: string[];
24
+ insightColumns?: string[];
25
+ }
26
+ export default function AdminPanel<T extends string, State, Input, Full extends {
27
+ id: string;
28
+ }, Light extends {
29
+ id: string;
30
+ }, Sort extends SortType>({ sliceName, components, summaryColumns, insightColumns, renderInsight, renderDashboard, ...props }: AdminPanelProps<T, State, Input, Full, Light, Sort>): import("react/jsx-runtime").JSX.Element;
31
+ export {};
package/Model/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export declare const Model: {
12
12
  ViewEditModal: typeof import("./ViewEditModal").default;
13
13
  Edit: typeof import("./Edit").default;
14
14
  New: typeof import("./New").default;
15
+ AdminPanel: typeof import("./AdminPanel").default;
15
16
  };
package/Model/index_.d.ts CHANGED
@@ -11,3 +11,4 @@ export declare const ViewWrapper: typeof import("./ViewWrapper").default;
11
11
  export declare const ViewEditModal: typeof import("./ViewEditModal").default;
12
12
  export declare const Edit: typeof import("./Edit").default;
13
13
  export declare const New: typeof import("./New").default;
14
+ export declare const AdminPanel: typeof import("./AdminPanel").default;
@@ -3,7 +3,7 @@ import { type Location, type TransitionStyle } from "@akanjs/client";
3
3
  import { HTMLAttributes, RefObject } from "react";
4
4
  export declare const Client: {
5
5
  (): import("react/jsx-runtime").JSX.Element;
6
- Wrapper: ({ children, theme }: ClientWrapperProps) => import("react/jsx-runtime").JSX.Element;
6
+ Wrapper: ({ children, theme, lang, dictionary }: ClientWrapperProps) => import("react/jsx-runtime").JSX.Element;
7
7
  Bridge: ({ env, lang, mePromise, selfPromise, theme, prefix, gaTrackingId }: ClientBridgeProps) => "" | import("react/jsx-runtime").JSX.Element | undefined;
8
8
  Inner: () => import("react/jsx-runtime").JSX.Element;
9
9
  NextBridge: ({ lang, prefix }: ClientNextBridgeProps) => null;
@@ -11,8 +11,14 @@ export declare const Client: {
11
11
  interface ClientWrapperProps {
12
12
  children: any;
13
13
  theme?: string;
14
+ lang?: string;
15
+ dictionary?: {
16
+ [key: string]: {
17
+ [key: string]: string;
18
+ };
19
+ };
14
20
  }
15
- export declare const ClientWrapper: ({ children, theme }: ClientWrapperProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const ClientWrapper: ({ children, theme, lang, dictionary }: ClientWrapperProps) => import("react/jsx-runtime").JSX.Element;
16
22
  interface ClientPathWrapperProps extends Omit<HTMLAttributes<HTMLDivElement>, "style"> {
17
23
  bind?: () => any;
18
24
  wrapperRef?: RefObject<HTMLDivElement | null> | null;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Clipboard_exports = {};
20
+ __export(Clipboard_exports, {
21
+ Clipboard: () => Clipboard
22
+ });
23
+ module.exports = __toCommonJS(Clipboard_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_client = require("@akanjs/client");
26
+ var import_react = require("react");
27
+ var import_fa = require("react-icons/fa");
28
+ var import_md = require("react-icons/md");
29
+ const Clipboard = ({ text, className }) => {
30
+ const [isCopied, setIsCopied] = (0, import_react.useState)(false);
31
+ (0, import_react.useEffect)(() => {
32
+ if (isCopied) {
33
+ setTimeout(() => {
34
+ setIsCopied(false);
35
+ }, 2e3);
36
+ }
37
+ }, [isCopied]);
38
+ const handleCopy = async () => {
39
+ if (!text)
40
+ return;
41
+ await navigator.clipboard.writeText(text);
42
+ setIsCopied(true);
43
+ };
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
45
+ "button",
46
+ {
47
+ onClick: async () => {
48
+ await handleCopy();
49
+ },
50
+ className: (0, import_client.clsx)(
51
+ "flex h-6 w-6 items-center justify-center rounded-md bg-white/30 text-white transition-all duration-300 hover:bg-white/20",
52
+ className
53
+ ),
54
+ children: [
55
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_fa.FaCheck,
57
+ {
58
+ className: `absolute h-4 w-4 transition-opacity duration-300 ${isCopied ? "opacity-100" : "opacity-0"}`
59
+ }
60
+ ),
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
62
+ import_md.MdContentCopy,
63
+ {
64
+ className: `absolute h-4 w-4 transition-opacity duration-300 ${isCopied ? "opacity-0" : "opacity-100"}`
65
+ }
66
+ )
67
+ ]
68
+ }
69
+ );
70
+ };
package/cjs/Data/Item.js CHANGED
@@ -89,10 +89,7 @@ function Item({
89
89
  }) {
90
90
  const { l } = (0, import_next.usePage)();
91
91
  const strActions = actions.filter((action) => typeof action === "string").map((action, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Action, { action, outline: false, model, sliceName }, idx));
92
- const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({
93
- key: idx,
94
- label: typeof action !== "string" ? action.render() : null
95
- }));
92
+ const customActions = actions.filter((action) => typeof action !== "string").map((action, idx) => ({ key: idx, label: action }));
96
93
  const extraCols = columns.filter((column) => {
97
94
  const key = typeof column === "string" ? column : column.key;
98
95
  return !["id", "status", "createdAt"].includes(key);
@@ -184,7 +181,7 @@ const Action = ({
184
181
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: `btn btn-square btn-ghost btn-sm m-1 text-center ${outline && "btn-outline border-dashed"}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ai.AiOutlineDelete, {}) })
185
182
  },
186
183
  action
187
- ) : action.render();
184
+ ) : action;
188
185
  };
189
186
  const statusColors = {
190
187
  active: "badge-info badge-outline",
@@ -57,19 +57,12 @@ function ListContainer({
57
57
  title,
58
58
  sort,
59
59
  columns = ["id", "createdAt", "updatedAt"],
60
- actions,
60
+ actions = ["remove", "edit", "view"],
61
61
  tools = [],
62
62
  renderDashboard,
63
63
  renderItem,
64
64
  renderTemplate,
65
- renderTitle = (model) => model.id ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "flex items-center justify-center py-3 text-lg sm:justify-start md:text-2xl", children: [
66
- sliceName,
67
- " - ",
68
- model.id
69
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "flex items-center justify-center py-3 text-lg sm:justify-start md:text-2xl", children: [
70
- "New ",
71
- sliceName
72
- ] }),
65
+ renderTitle,
73
66
  renderView,
74
67
  renderQueryMaker = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}),
75
68
  renderInsight,
@@ -78,7 +71,6 @@ function ListContainer({
78
71
  const { l } = (0, import_next.usePage)();
79
72
  const storeUse = import_store.st.use;
80
73
  const storeDo = import_store.st.do;
81
- const storeGet = import_store.st.get;
82
74
  const refName = import_store.st.slice[sliceName].refName;
83
75
  const [modelName, modelClassName] = [refName, (0, import_common.capitalize)(refName)];
84
76
  if (refName !== sliceName)
@@ -111,6 +103,7 @@ function ListContainer({
111
103
  const cnst = (0, import_constant.getCnstMeta)(sliceName);
112
104
  const limitOfModel = storeUse[namesOfSlice.limitOfModel]();
113
105
  const sortOfModel = storeUse[namesOfSlice.sortOfModel]();
106
+ const RenderTitle = renderTitle ?? ((model) => `${l(`${refName}.modelName`)} - ${model.id ? model.id : "New"}`);
114
107
  const ModelDashboard = () => {
115
108
  const summary = storeUse.summary();
116
109
  const summaryLoading = storeUse.summaryLoading();
@@ -260,11 +253,11 @@ ${body}`], { type: "text/csv;charset=utf-8" });
260
253
  import_CardList.default,
261
254
  {
262
255
  sliceName,
263
- renderItem: renderItem ?? (({ [sliceName]: model }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: model.id }, model.id)),
256
+ renderItem: renderItem ?? (({ [sliceName]: model }) => null),
264
257
  renderLoading,
265
258
  renderTemplate,
266
259
  renderView,
267
- renderTitle,
260
+ renderTitle: RenderTitle,
268
261
  columns,
269
262
  actions,
270
263
  cardListClassName
@@ -276,10 +269,10 @@ ${body}`], { type: "text/csv;charset=utf-8" });
276
269
  sliceName,
277
270
  actions,
278
271
  renderTemplate,
279
- renderTitle,
272
+ renderTitle: RenderTitle,
280
273
  renderView
281
274
  }
282
275
  ),
283
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Model.Model.EditModal, { sliceName, renderTitle, children: RenderTemplate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTemplate, {}) : null })
276
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Model.Model.EditModal, { sliceName, renderTitle: RenderTitle, children: RenderTemplate ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RenderTemplate, {}) : null })
284
277
  ] });
285
278
  }
@@ -41,9 +41,7 @@ function QueryMaker({ className, sliceName, query }) {
41
41
  const storeDo = import_store.st.do;
42
42
  const cnst = (0, import_constant.getCnstMeta)(sliceName);
43
43
  const isModelSearchable = (0, import_constant.hasTextField)(cnst.Full);
44
- const summaryRef = cnst.Summary;
45
44
  const { subMenu, filter } = import_store.st.use.searchParams();
46
- const summaryQueryMap = (0, import_constant.getQueryMap)(summaryRef);
47
45
  const filterRef = cnst.Filter;
48
46
  const filterQueryMap = (0, import_constant.getFilterQueryMap)(filterRef);
49
47
  const defaultQuerySetting = { ...isModelSearchable ? searchQuerySetting : byStatusQuerySetting, ...query ?? {} };
@@ -51,12 +49,7 @@ function QueryMaker({ className, sliceName, query }) {
51
49
  const [querySetting, setQuerySetting] = (0, import_react.useState)(defaultQuerySetting);
52
50
  const getQuery = (0, import_react.useCallback)(
53
51
  (querySetting2) => {
54
- if (summaryQueryMap[querySetting2.queryKey]) {
55
- const query2 = typeof summaryQueryMap[querySetting2.queryKey] === "function" ? summaryQueryMap[querySetting2.queryKey]() : summaryQueryMap[querySetting2.queryKey] ?? null;
56
- if (!query2)
57
- throw new Error(`Query not found`);
58
- return query2;
59
- } else if (querySetting2.queryKey === "search") {
52
+ if (querySetting2.queryKey === "search") {
60
53
  const query2 = querySetting2.arg;
61
54
  return query2;
62
55
  } else {
@@ -91,8 +84,8 @@ function QueryMaker({ className, sliceName, query }) {
91
84
  import_Select.Select,
92
85
  {
93
86
  value: querySetting.queryKey,
94
- options: Object.keys(summaryQueryMap).map((queryKey) => ({
95
- label: l.qry(sliceName, queryKey),
87
+ options: Object.keys(filterQueryMap).map((queryKey) => ({
88
+ label: l.field("summary", queryKey),
96
89
  value: queryKey
97
90
  })),
98
91
  onChange: (queryKey) => {
@@ -125,7 +118,7 @@ function QueryMaker({ className, sliceName, query }) {
125
118
  ),
126
119
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_bi.BiSearch, { className: "size-4 opacity-70" })
127
120
  ] })
128
- ] }) : summaryQueryMap[querySetting.queryKey] ? null : (0, import_constant.getFilterArgMetas)(filterRef, querySetting.queryKey).map((queryArgMeta, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
121
+ ] }) : (0, import_constant.getFilterArgMetas)(filterRef, querySetting.queryKey).map((queryArgMeta, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
129
122
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-gray-500", children: l.qarg(sliceName, querySetting.queryKey, queryArgMeta.name) }),
130
123
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
124
  QueryArg,
@@ -24,14 +24,21 @@ module.exports = __toCommonJS(BottomTab_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_client = require("@akanjs/client");
26
26
  var import_next = require("@akanjs/next");
27
+ var import_react = require("react");
27
28
  var import_Link = require("../Link");
28
29
  var import_BottomInset = require("./BottomInset");
29
30
  const BottomTab = ({ className, tabs, height = 64 }) => {
30
- const { lang } = (0, import_next.usePage)();
31
+ const { lang, path } = (0, import_next.usePage)();
32
+ const [isRendered, setIsRendered] = (0, import_react.useState)(false);
31
33
  const isActiveTab = (tabHref) => {
34
+ if (!isRendered)
35
+ return false;
32
36
  const locationPath = window.location.pathname.startsWith(`/${lang}`) ? window.location.pathname.slice(lang.length + 1) === "" ? "/" : window.location.pathname.slice(lang.length + 1) : window.location.pathname;
33
37
  return tabHref === "/" ? locationPath === tabHref : locationPath.startsWith(tabHref);
34
38
  };
39
+ (0, import_react.useEffect)(() => {
40
+ setIsRendered(true);
41
+ }, []);
35
42
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BottomInset.BottomInset, { className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
36
43
  "div",
37
44
  {
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var AdminPanel_exports = {};
19
+ __export(AdminPanel_exports, {
20
+ default: () => AdminPanel
21
+ });
22
+ module.exports = __toCommonJS(AdminPanel_exports);
23
+ var import_jsx_runtime = require("react/jsx-runtime");
24
+ var import_Data = require("../Data");
25
+ function AdminPanel({
26
+ sliceName,
27
+ components,
28
+ summaryColumns = ["totalAdmin"],
29
+ insightColumns = ["count"],
30
+ renderInsight = ({ insight }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Data.Data.Insight, { insight, sliceName, columns: insightColumns }),
31
+ renderDashboard = ({ summary }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Data.Data.Dashboard, { summary, sliceName, columns: summaryColumns, queryMap: {} }),
32
+ ...props
33
+ }) {
34
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
35
+ import_Data.Data.ListContainer,
36
+ {
37
+ sliceName,
38
+ renderItem: components.Unit.General,
39
+ renderInsight,
40
+ renderDashboard,
41
+ renderTemplate: components.Template.General,
42
+ renderView: (model) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(components.View.General, { ...{ [sliceName]: model } }),
43
+ ...props
44
+ }
45
+ );
46
+ }
@@ -34,5 +34,6 @@ const Model = {
34
34
  ViewWrapper: import_index.ViewWrapper,
35
35
  ViewEditModal: import_index.ViewEditModal,
36
36
  Edit: import_index.Edit,
37
- New: import_index.New
37
+ New: import_index.New,
38
+ AdminPanel: import_index.AdminPanel
38
39
  };
@@ -27,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var index_exports = {};
29
29
  __export(index_exports, {
30
+ AdminPanel: () => AdminPanel,
30
31
  Edit: () => Edit,
31
32
  EditModal: () => EditModal,
32
33
  EditWrapper: () => EditWrapper,
@@ -56,3 +57,4 @@ const ViewWrapper = (0, import_next.lazy)(() => import("./ViewWrapper"));
56
57
  const ViewEditModal = (0, import_next.lazy)(() => import("./ViewEditModal"));
57
58
  const Edit = (0, import_next.lazy)(() => import("./Edit"));
58
59
  const New = (0, import_next.lazy)(() => import("./New"));
60
+ const AdminPanel = (0, import_next.lazy)(() => import("./AdminPanel"));
@@ -32,9 +32,9 @@ const ListenerResult = ({ status, data }) => {
32
32
  const dataStr = typeof data === "object" ? JSON.stringify(data, null, 2) : data;
33
33
  const ref = (0, import_react.useRef)(null);
34
34
  (0, import_react.useEffect)(() => {
35
- if (ref.current) {
36
- ref.current.scrollTop = ref.current.scrollHeight;
37
- }
35
+ if (!ref.current)
36
+ return;
37
+ ref.current.scrollTop = ref.current.scrollHeight;
38
38
  }, [dataStr]);
39
39
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
40
40
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -168,7 +168,7 @@ const MessageTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
168
168
  const [uploadRequest, setUploadRequest] = (0, import_react.useState)({});
169
169
  const [stopListen, setStopListen] = (0, import_react.useState)(null);
170
170
  const [messages, setMessages] = (0, import_react.useState)("");
171
- const [response, setResponse] = (0, import_react.useState)({ status: "ready", data: null });
171
+ const [response, setResponse] = (0, import_react.useState)({ status: "ready", data: "" });
172
172
  const onSend = async () => {
173
173
  const request = { ...JSON.parse(gqlRequest), ...uploadRequest };
174
174
  const argData = [...gqlArgMetas, ...uploadArgMetas].sort((a, b) => a.idx - b.idx).map((argMeta) => request[argMeta.name]);
@@ -180,7 +180,7 @@ const MessageTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
180
180
  const request = { ...JSON.parse(gqlRequest), ...uploadRequest };
181
181
  const fetchFn = import_signal.fetch[`listen${(0, import_common.capitalize)(gqlMeta.key)}`].bind(import_signal.fetch);
182
182
  setResponse({ status: "loading", data: messages });
183
- const stopListen2 = fetchFn(({ event, data }) => {
183
+ const stopListen2 = fetchFn((data) => {
184
184
  setMessages(
185
185
  (prev) => typeof data === "boolean" ? data : typeof data === "string" ? `${prev}
186
186
  ${data}` : typeof data === "object" ? [...prev && prev.length ? [...prev] : [], data] : data
@@ -167,18 +167,15 @@ const PubSubTry = ({ sigRef, gqlMeta, gqlArgMetas, uploadArgMetas }) => {
167
167
  const [gqlRequest, setGqlRequest] = (0, import_react.useState)(requestExample);
168
168
  const [uploadRequest, setUploadRequest] = (0, import_react.useState)({});
169
169
  const [unsubscribe, setUnsubscribe] = (0, import_react.useState)(null);
170
- const [messages, setMessages] = (0, import_react.useState)(null);
171
- const [response, setResponse] = (0, import_react.useState)({
172
- status: "ready",
173
- data: null
174
- });
170
+ const [messages, setMessages] = (0, import_react.useState)("");
171
+ const [response, setResponse] = (0, import_react.useState)({ status: "ready", data: "" });
175
172
  const onSubscribe = () => {
176
- setResponse({ status: "loading", data: null });
173
+ setResponse({ status: "loading", data: "" });
177
174
  const request = { ...JSON.parse(gqlRequest), ...uploadRequest };
178
175
  const argData = [...gqlArgMetas, ...uploadArgMetas].sort((a, b) => a.idx - b.idx).map((argMeta) => request[argMeta.name]);
179
176
  const fetchFn = import_signal.fetch[`subscribe${(0, import_common.capitalize)(gqlMeta.key)}`].bind(import_signal.fetch);
180
177
  setResponse({ status: "loading", data: messages });
181
- const unsubscribe2 = fetchFn([...argData], (data) => {
178
+ const unsubscribe2 = fetchFn(...argData, (data) => {
182
179
  setMessages(
183
180
  (prev) => typeof data === "boolean" ? data : typeof data === "string" ? `${prev}
184
181
  ${data}` : typeof data === "object" ? [
package/cjs/System/CSR.js CHANGED
@@ -24,6 +24,7 @@ __export(CSR_exports, {
24
24
  module.exports = __toCommonJS(CSR_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
26
  var import_client = require("@akanjs/client");
27
+ var import_dictionary = require("@akanjs/dictionary");
27
28
  var import_next = require("@akanjs/next");
28
29
  var import_store = require("@akanjs/store");
29
30
  var import_ui = require("@akanjs/ui");
@@ -61,10 +62,11 @@ const CSRProvider = ({
61
62
  of,
62
63
  loader: async () => {
63
64
  const { lang } = await params;
64
- return { lang };
65
+ const dictionary = await import_dictionary.serverTranslator.getDictionary(lang);
66
+ return { lang, dictionary };
65
67
  },
66
- render: ({ lang }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Wrapper, { theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
+ render: ({ lang, dictionary }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Client.Client.Wrapper, { theme, lang, dictionary, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
70
  CSRWrapper,
69
71
  {
70
72
  className,
@@ -39,14 +39,18 @@ var import_next_themes = require("next-themes");
39
39
  var import_react = require("react");
40
40
  var import_Gtag = require("./Gtag");
41
41
  var import_Messages = require("./Messages");
42
+ var import_Reconnect = require("./Reconnect");
42
43
  const Client = () => {
43
44
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
44
45
  };
45
- const ClientWrapper = ({ children, theme }) => {
46
+ const ClientWrapper = ({ children, theme, lang = "en", dictionary = {} }) => {
46
47
  (0, import_react.useEffect)(() => {
47
48
  import_common.Logger.rawLog(import_base.logo);
48
49
  }, []);
49
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_next_themes.ThemeProvider, { defaultTheme: theme, children });
50
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_next_themes.ThemeProvider, { defaultTheme: theme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_client.dictionaryContext.Provider, { value: dictionary, children: [
51
+ children,
52
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Reconnect.Reconnect, {})
53
+ ] }) });
50
54
  };
51
55
  Client.Wrapper = ClientWrapper;
52
56
  const ClientPathWrapper = ({