@nodehive/nextjs 0.2.1 → 0.3.0

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.
@@ -0,0 +1,5 @@
1
+ import type { SmartActionsToolbarAction } from './toolbar/types.js';
2
+ type Insertable = SmartActionsToolbarAction | SmartActionsToolbarAction[];
3
+ export declare function insertBefore(actions: SmartActionsToolbarAction[], anchorId: string, items: Insertable): SmartActionsToolbarAction[];
4
+ export declare function insertAfter(actions: SmartActionsToolbarAction[], anchorId: string, items: Insertable): SmartActionsToolbarAction[];
5
+ export {};
@@ -0,0 +1,16 @@
1
+ function toList(items) {
2
+ return Array.isArray(items) ? items : [items];
3
+ }
4
+ export function insertBefore(actions, anchorId, items) {
5
+ const additions = toList(items);
6
+ const index = actions.findIndex(action => action.id === anchorId);
7
+ if (index === -1) return [...actions, ...additions];
8
+ return [...actions.slice(0, index), ...additions, ...actions.slice(index)];
9
+ }
10
+ export function insertAfter(actions, anchorId, items) {
11
+ const additions = toList(items);
12
+ const index = actions.findIndex(action => action.id === anchorId);
13
+ if (index === -1) return [...actions, ...additions];
14
+ return [...actions.slice(0, index + 1), ...additions, ...actions.slice(index + 1)];
15
+ }
16
+ //# sourceMappingURL=ordering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordering.js","names":["toList","items","Array","isArray","insertBefore","actions","anchorId","additions","index","findIndex","action","id","slice","insertAfter"],"sources":["../../../src/smart-actions/internal/ordering.ts"],"sourcesContent":["import type { SmartActionsToolbarAction } from './toolbar/types.ts';\n\ntype Insertable = SmartActionsToolbarAction | SmartActionsToolbarAction[];\n\nfunction toList(items: Insertable): SmartActionsToolbarAction[] {\n return Array.isArray(items) ? items : [items];\n}\n\nexport function insertBefore(\n actions: SmartActionsToolbarAction[],\n anchorId: string,\n items: Insertable\n): SmartActionsToolbarAction[] {\n const additions = toList(items);\n const index = actions.findIndex((action) => action.id === anchorId);\n if (index === -1) return [...actions, ...additions];\n return [...actions.slice(0, index), ...additions, ...actions.slice(index)];\n}\n\nexport function insertAfter(\n actions: SmartActionsToolbarAction[],\n anchorId: string,\n items: Insertable\n): SmartActionsToolbarAction[] {\n const additions = toList(items);\n const index = actions.findIndex((action) => action.id === anchorId);\n if (index === -1) return [...actions, ...additions];\n return [\n ...actions.slice(0, index + 1),\n ...additions,\n ...actions.slice(index + 1),\n ];\n}\n"],"mappings":"AAIA,SAASA,MAAMA,CAACC,KAAiB,EAA+B;EAC9D,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAC;AAC/C;AAEA,OAAO,SAASG,YAAYA,CAC1BC,OAAoC,EACpCC,QAAgB,EAChBL,KAAiB,EACY;EAC7B,MAAMM,SAAS,GAAGP,MAAM,CAACC,KAAK,CAAC;EAC/B,MAAMO,KAAK,GAAGH,OAAO,CAACI,SAAS,CAAEC,MAAM,IAAKA,MAAM,CAACC,EAAE,KAAKL,QAAQ,CAAC;EACnE,IAAIE,KAAK,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAGH,OAAO,EAAE,GAAGE,SAAS,CAAC;EACnD,OAAO,CAAC,GAAGF,OAAO,CAACO,KAAK,CAAC,CAAC,EAAEJ,KAAK,CAAC,EAAE,GAAGD,SAAS,EAAE,GAAGF,OAAO,CAACO,KAAK,CAACJ,KAAK,CAAC,CAAC;AAC5E;AAEA,OAAO,SAASK,WAAWA,CACzBR,OAAoC,EACpCC,QAAgB,EAChBL,KAAiB,EACY;EAC7B,MAAMM,SAAS,GAAGP,MAAM,CAACC,KAAK,CAAC;EAC/B,MAAMO,KAAK,GAAGH,OAAO,CAACI,SAAS,CAAEC,MAAM,IAAKA,MAAM,CAACC,EAAE,KAAKL,QAAQ,CAAC;EACnE,IAAIE,KAAK,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAGH,OAAO,EAAE,GAAGE,SAAS,CAAC;EACnD,OAAO,CACL,GAAGF,OAAO,CAACO,KAAK,CAAC,CAAC,EAAEJ,KAAK,GAAG,CAAC,CAAC,EAC9B,GAAGD,SAAS,EACZ,GAAGF,OAAO,CAACO,KAAK,CAACJ,KAAK,GAAG,CAAC,CAAC,CAC5B;AACH","ignoreList":[]}
@@ -1,7 +1,6 @@
1
1
  import type { NodeHiveClient } from 'nodehive-js';
2
- import type { SmartActionsDictionaryOverrides, SmartActionsLabels } from './i18n.js';
2
+ import type { SmartActionsDictionaryOverrides } from './i18n.js';
3
3
  import { type SmartActionsBuilder } from './smart-actions-config.js';
4
- import type { SmartActionsToolbarAction } from './toolbar/types.js';
5
4
  interface SmartActionsButtonProps {
6
5
  lang: string;
7
6
  nodeId?: number;
@@ -17,16 +16,12 @@ interface SmartActionsButtonProps {
17
16
  dictionaryOverrides?: SmartActionsDictionaryOverrides;
18
17
  /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */
19
18
  accountHref?: string | null;
20
- extraActions?: (context: {
21
- lang: string;
22
- labels: SmartActionsLabels;
23
- /** Resolved editor UI locale (Drupal user preference, falls back to lang). */
24
- editorLocale: string;
25
- }) => SmartActionsToolbarAction[];
26
19
  /**
27
- * Reorders/filters the built-in actions (same pattern as PuckWrapper's
28
- * plugins callback). Receives the default action list (profile, injected
29
- * extras, backend edit, refresh, logout) and returns the final list.
20
+ * Composes the toolbar actions (same pattern as PuckWrapper's plugins
21
+ * callback). Receives the default list (profile, backend edit, refresh,
22
+ * logout) plus { lang, labels, editorLocale } and returns the final list.
23
+ * Use it to add, reorder, or remove actions; build locale-aware actions
24
+ * (e.g. the Puck actions) with the provided editorLocale.
30
25
  */
31
26
  actions?: SmartActionsBuilder;
32
27
  }
@@ -38,5 +33,5 @@ interface SmartActionsButtonProps {
38
33
  *
39
34
  * Requires the `motion` peer (toolbar animation); see the module README.
40
35
  */
41
- export default function SmartActionsButton({ lang, nodeId, drupalBaseUrl, launcherIconSrc, createUserClient, logout, dictionaryOverrides, accountHref, extraActions, actions, }: SmartActionsButtonProps): Promise<import("react").JSX.Element>;
36
+ export default function SmartActionsButton({ lang, nodeId, drupalBaseUrl, launcherIconSrc, createUserClient, logout, dictionaryOverrides, accountHref, actions, }: SmartActionsButtonProps): Promise<import("react").JSX.Element>;
42
37
  export {};
@@ -20,7 +20,6 @@ export default async function SmartActionsButton({
20
20
  logout,
21
21
  dictionaryOverrides,
22
22
  accountHref,
23
- extraActions,
24
23
  actions
25
24
  }) {
26
25
  const {
@@ -37,16 +36,12 @@ export default async function SmartActionsButton({
37
36
  });
38
37
  const toolbarActions = getSmartActionsConfig({
39
38
  lang,
39
+ editorLocale,
40
40
  backendEditUrl,
41
41
  userImageUrl,
42
42
  labels,
43
43
  logout,
44
44
  accountHref,
45
- extraActions: extraActions?.({
46
- lang,
47
- labels,
48
- editorLocale
49
- }),
50
45
  buildActions: actions
51
46
  });
52
47
  return /*#__PURE__*/_jsx(SignedIn, {
@@ -1 +1 @@
1
- {"version":3,"file":"smart-actions-button.js","names":["SignedIn","getSmartActionsContext","getSmartActionsConfig","SmartActionsToolbarClient","jsx","_jsx","SmartActionsButton","lang","nodeId","drupalBaseUrl","launcherIconSrc","createUserClient","logout","dictionaryOverrides","accountHref","extraActions","actions","labels","editorLocale","userImageUrl","backendEditUrl","toolbarActions","buildActions","children","collapse","launcherAction"],"sources":["../../../src/smart-actions/internal/smart-actions-button.tsx"],"sourcesContent":["import type { NodeHiveClient } from 'nodehive-js';\n\nimport { SignedIn } from '../../auth/server.ts';\nimport { getSmartActionsContext } from './get-smart-actions-context.ts';\nimport type {\n SmartActionsDictionaryOverrides,\n SmartActionsLabels,\n} from './i18n.ts';\nimport {\n getSmartActionsConfig,\n type SmartActionsBuilder,\n} from './smart-actions-config.tsx';\nimport SmartActionsToolbarClient from './smart-actions-toolbar-client.tsx';\nimport type { SmartActionsToolbarAction } from './toolbar/types.ts';\n\ninterface SmartActionsButtonProps {\n lang: string;\n nodeId?: number;\n /** Drupal base URL for the backend edit deep link. */\n drupalBaseUrl?: string;\n /** Toolbar launcher icon; defaults to /metadata/nodehive-icon.svg from the project public folder. */\n launcherIconSrc?: string;\n /** Project client factory, e.g. createUserClient from the auth binding. */\n createUserClient: () => NodeHiveClient;\n /** Project logout Server Action (Server Action so Next's CSRF applies). */\n logout: () => Promise<void>;\n /** Per-section label overrides merged over the resolved dictionary. */\n dictionaryOverrides?: SmartActionsDictionaryOverrides;\n /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */\n accountHref?: string | null;\n extraActions?: (context: {\n lang: string;\n labels: SmartActionsLabels;\n /** Resolved editor UI locale (Drupal user preference, falls back to lang). */\n editorLocale: string;\n }) => SmartActionsToolbarAction[];\n /**\n * Reorders/filters the built-in actions (same pattern as PuckWrapper's\n * plugins callback). Receives the default action list (profile, injected\n * extras, backend edit, refresh, logout) and returns the final list.\n */\n actions?: SmartActionsBuilder;\n}\n\n/**\n * Server entry point for the floating editor toolbar. Renders only for a\n * signed-in session (via `<SignedIn>`).\n *\n * Dynamic RSC (reads `cookies()` via the session gate); under `cacheComponents`, mount inside a `<Suspense>` boundary. See the smart-actions README.\n *\n * Requires the `motion` peer (toolbar animation); see the module README.\n */\nexport default async function SmartActionsButton({\n lang,\n nodeId,\n drupalBaseUrl,\n launcherIconSrc,\n createUserClient,\n logout,\n dictionaryOverrides,\n accountHref,\n extraActions,\n actions,\n}: SmartActionsButtonProps) {\n const { labels, editorLocale, userImageUrl, backendEditUrl } =\n await getSmartActionsContext({\n createUserClient,\n lang,\n nodeId,\n drupalBaseUrl,\n dictionaryOverrides,\n });\n const toolbarActions = getSmartActionsConfig({\n lang,\n backendEditUrl,\n userImageUrl,\n labels,\n logout,\n accountHref,\n extraActions: extraActions?.({ lang, labels, editorLocale }),\n buildActions: actions,\n });\n return (\n <SignedIn>\n <SmartActionsToolbarClient\n launcherIconSrc={launcherIconSrc}\n actions={toolbarActions}\n labels={{\n collapse: labels.collapse,\n launcherAction: labels.launcherAction,\n toolbarActions: labels.toolbarActions,\n }}\n />\n </SignedIn>\n );\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,sBAAsB,QAAQ,gCAAgC;AAKvE,SACEC,qBAAqB,QAEhB,2BAA4B;AACnC,OAAOC,yBAAyB,MAAM,mCAAoC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAgC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,kBAAkBA,CAAC;EAC/CC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,eAAe;EACfC,gBAAgB;EAChBC,MAAM;EACNC,mBAAmB;EACnBC,WAAW;EACXC,YAAY;EACZC;AACuB,CAAC,EAAE;EAC1B,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,YAAY;IAAEC;EAAe,CAAC,GAC1D,MAAMnB,sBAAsB,CAAC;IAC3BU,gBAAgB;IAChBJ,IAAI;IACJC,MAAM;IACNC,aAAa;IACbI;EACF,CAAC,CAAC;EACJ,MAAMQ,cAAc,GAAGnB,qBAAqB,CAAC;IAC3CK,IAAI;IACJa,cAAc;IACdD,YAAY;IACZF,MAAM;IACNL,MAAM;IACNE,WAAW;IACXC,YAAY,EAAEA,YAAY,GAAG;MAAER,IAAI;MAAEU,MAAM;MAAEC;IAAa,CAAC,CAAC;IAC5DI,YAAY,EAAEN;EAChB,CAAC,CAAC;EACF,oBACEX,IAAA,CAACL,QAAQ;IAAAuB,QAAA,eACPlB,IAAA,CAACF,yBAAyB;MACxBO,eAAe,EAAEA,eAAgB;MACjCM,OAAO,EAAEK,cAAe;MACxBJ,MAAM,EAAE;QACNO,QAAQ,EAAEP,MAAM,CAACO,QAAQ;QACzBC,cAAc,EAAER,MAAM,CAACQ,cAAc;QACrCJ,cAAc,EAAEJ,MAAM,CAACI;MACzB;IAAE,CACH;EAAC,CACM,CAAC;AAEf","ignoreList":[]}
1
+ {"version":3,"file":"smart-actions-button.js","names":["SignedIn","getSmartActionsContext","getSmartActionsConfig","SmartActionsToolbarClient","jsx","_jsx","SmartActionsButton","lang","nodeId","drupalBaseUrl","launcherIconSrc","createUserClient","logout","dictionaryOverrides","accountHref","actions","labels","editorLocale","userImageUrl","backendEditUrl","toolbarActions","buildActions","children","collapse","launcherAction"],"sources":["../../../src/smart-actions/internal/smart-actions-button.tsx"],"sourcesContent":["import type { NodeHiveClient } from 'nodehive-js';\n\nimport { SignedIn } from '../../auth/server.ts';\nimport { getSmartActionsContext } from './get-smart-actions-context.ts';\nimport type { SmartActionsDictionaryOverrides } from './i18n.ts';\nimport {\n getSmartActionsConfig,\n type SmartActionsBuilder,\n} from './smart-actions-config.tsx';\nimport SmartActionsToolbarClient from './smart-actions-toolbar-client.tsx';\n\ninterface SmartActionsButtonProps {\n lang: string;\n nodeId?: number;\n /** Drupal base URL for the backend edit deep link. */\n drupalBaseUrl?: string;\n /** Toolbar launcher icon; defaults to /metadata/nodehive-icon.svg from the project public folder. */\n launcherIconSrc?: string;\n /** Project client factory, e.g. createUserClient from the auth binding. */\n createUserClient: () => NodeHiveClient;\n /** Project logout Server Action (Server Action so Next's CSRF applies). */\n logout: () => Promise<void>;\n /** Per-section label overrides merged over the resolved dictionary. */\n dictionaryOverrides?: SmartActionsDictionaryOverrides;\n /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */\n accountHref?: string | null;\n /**\n * Composes the toolbar actions (same pattern as PuckWrapper's plugins\n * callback). Receives the default list (profile, backend edit, refresh,\n * logout) plus { lang, labels, editorLocale } and returns the final list.\n * Use it to add, reorder, or remove actions; build locale-aware actions\n * (e.g. the Puck actions) with the provided editorLocale.\n */\n actions?: SmartActionsBuilder;\n}\n\n/**\n * Server entry point for the floating editor toolbar. Renders only for a\n * signed-in session (via `<SignedIn>`).\n *\n * Dynamic RSC (reads `cookies()` via the session gate); under `cacheComponents`, mount inside a `<Suspense>` boundary. See the smart-actions README.\n *\n * Requires the `motion` peer (toolbar animation); see the module README.\n */\nexport default async function SmartActionsButton({\n lang,\n nodeId,\n drupalBaseUrl,\n launcherIconSrc,\n createUserClient,\n logout,\n dictionaryOverrides,\n accountHref,\n actions,\n}: SmartActionsButtonProps) {\n const { labels, editorLocale, userImageUrl, backendEditUrl } =\n await getSmartActionsContext({\n createUserClient,\n lang,\n nodeId,\n drupalBaseUrl,\n dictionaryOverrides,\n });\n const toolbarActions = getSmartActionsConfig({\n lang,\n editorLocale,\n backendEditUrl,\n userImageUrl,\n labels,\n logout,\n accountHref,\n buildActions: actions,\n });\n return (\n <SignedIn>\n <SmartActionsToolbarClient\n launcherIconSrc={launcherIconSrc}\n actions={toolbarActions}\n labels={{\n collapse: labels.collapse,\n launcherAction: labels.launcherAction,\n toolbarActions: labels.toolbarActions,\n }}\n />\n </SignedIn>\n );\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,sBAAsB,QAAQ,gCAAgC;AAEvE,SACEC,qBAAqB,QAEhB,2BAA4B;AACnC,OAAOC,yBAAyB,MAAM,mCAAoC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA2B3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAeC,kBAAkBA,CAAC;EAC/CC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,eAAe;EACfC,gBAAgB;EAChBC,MAAM;EACNC,mBAAmB;EACnBC,WAAW;EACXC;AACuB,CAAC,EAAE;EAC1B,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC,YAAY;IAAEC;EAAe,CAAC,GAC1D,MAAMlB,sBAAsB,CAAC;IAC3BU,gBAAgB;IAChBJ,IAAI;IACJC,MAAM;IACNC,aAAa;IACbI;EACF,CAAC,CAAC;EACJ,MAAMO,cAAc,GAAGlB,qBAAqB,CAAC;IAC3CK,IAAI;IACJU,YAAY;IACZE,cAAc;IACdD,YAAY;IACZF,MAAM;IACNJ,MAAM;IACNE,WAAW;IACXO,YAAY,EAAEN;EAChB,CAAC,CAAC;EACF,oBACEV,IAAA,CAACL,QAAQ;IAAAsB,QAAA,eACPjB,IAAA,CAACF,yBAAyB;MACxBO,eAAe,EAAEA,eAAgB;MACjCK,OAAO,EAAEK,cAAe;MACxBJ,MAAM,EAAE;QACNO,QAAQ,EAAEP,MAAM,CAACO,QAAQ;QACzBC,cAAc,EAAER,MAAM,CAACQ,cAAc;QACrCJ,cAAc,EAAEJ,MAAM,CAACI;MACzB;IAAE,CACH;EAAC,CACM,CAAC;AAEf","ignoreList":[]}
@@ -3,19 +3,20 @@ import type { SmartActionsToolbarAction } from './toolbar/types.js';
3
3
  export type SmartActionsBuilderContext = {
4
4
  lang: string;
5
5
  labels: SmartActionsLabels;
6
+ editorLocale: string;
6
7
  };
7
8
  export type SmartActionsBuilder = (defaults: SmartActionsToolbarAction[], context: SmartActionsBuilderContext) => SmartActionsToolbarAction[];
8
9
  type SmartActionsConfigContext = {
9
10
  lang: string;
11
+ editorLocale: string;
10
12
  backendEditUrl: string | null;
11
13
  userImageUrl?: string | null;
12
14
  labels: SmartActionsLabels;
13
15
  logout: () => Promise<void>;
14
16
  /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */
15
17
  accountHref?: string | null;
16
- extraActions?: SmartActionsToolbarAction[];
17
- /** Reorders/filters the default actions (profile, extras, backend edit, refresh, logout). */
18
+ /** Composes the default actions (profile, backend edit, refresh, logout). */
18
19
  buildActions?: SmartActionsBuilder;
19
20
  };
20
- export declare function getSmartActionsConfig({ lang, backendEditUrl, userImageUrl, labels, logout, accountHref, extraActions, buildActions, }: SmartActionsConfigContext): SmartActionsToolbarAction[];
21
+ export declare function getSmartActionsConfig({ lang, editorLocale, backendEditUrl, userImageUrl, labels, logout, accountHref, buildActions, }: SmartActionsConfigContext): SmartActionsToolbarAction[];
21
22
  export {};
@@ -4,12 +4,12 @@ import RefreshPage from "./refresh-page.js";
4
4
  import UserProfile from "./user-profile.js";
5
5
  export function getSmartActionsConfig({
6
6
  lang,
7
+ editorLocale,
7
8
  backendEditUrl,
8
9
  userImageUrl,
9
10
  labels,
10
11
  logout,
11
12
  accountHref,
12
- extraActions = [],
13
13
  buildActions
14
14
  }) {
15
15
  const profileHref = accountHref === undefined ? `/${lang}/nodehive/account` : accountHref;
@@ -48,10 +48,11 @@ export function getSmartActionsConfig({
48
48
  label: labels.logout
49
49
  }
50
50
  }];
51
- const defaults = [...(profile ? [profile] : []), ...extraActions, ...rest];
51
+ const defaults = [...(profile ? [profile] : []), ...rest];
52
52
  return buildActions ? buildActions(defaults, {
53
53
  lang,
54
- labels
54
+ labels,
55
+ editorLocale
55
56
  }) : defaults;
56
57
  }
57
58
  //# sourceMappingURL=smart-actions-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smart-actions-config.js","names":["BackendEditLink","LogoutForm","RefreshPage","UserProfile","getSmartActionsConfig","lang","backendEditUrl","userImageUrl","labels","logout","accountHref","extraActions","buildActions","profileHref","undefined","profile","id","label","account","Component","props","href","imageUrl","rest","nodeHive","isVisible","Boolean","refresh","defaults"],"sources":["../../../src/smart-actions/internal/smart-actions-config.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\nimport BackendEditLink from './backend-edit-link.tsx';\nimport type { SmartActionsLabels } from './i18n.ts';\nimport LogoutForm from './logout-form.tsx';\nimport RefreshPage from './refresh-page.tsx';\nimport type { SmartActionsToolbarAction } from './toolbar/types.ts';\nimport UserProfile from './user-profile.tsx';\n\nexport type SmartActionsBuilderContext = {\n lang: string;\n labels: SmartActionsLabels;\n};\n\nexport type SmartActionsBuilder = (\n defaults: SmartActionsToolbarAction[],\n context: SmartActionsBuilderContext\n) => SmartActionsToolbarAction[];\n\ntype ActionComponent = ComponentType<Record<string, unknown>>;\n\ntype SmartActionsConfigContext = {\n lang: string;\n backendEditUrl: string | null;\n userImageUrl?: string | null;\n labels: SmartActionsLabels;\n logout: () => Promise<void>;\n /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */\n accountHref?: string | null;\n extraActions?: SmartActionsToolbarAction[];\n /** Reorders/filters the default actions (profile, extras, backend edit, refresh, logout). */\n buildActions?: SmartActionsBuilder;\n};\n\nexport function getSmartActionsConfig({\n lang,\n backendEditUrl,\n userImageUrl,\n labels,\n logout,\n accountHref,\n extraActions = [],\n buildActions,\n}: SmartActionsConfigContext): SmartActionsToolbarAction[] {\n const profileHref =\n accountHref === undefined ? `/${lang}/nodehive/account` : accountHref;\n\n const profile: SmartActionsToolbarAction | null =\n profileHref === null\n ? null\n : {\n id: 'user-profile',\n label: labels.account,\n Component: UserProfile as unknown as ActionComponent,\n props: {\n href: profileHref,\n imageUrl: userImageUrl,\n label: labels.account,\n },\n };\n\n const rest: SmartActionsToolbarAction[] = [\n {\n id: 'backend-edit',\n label: labels.nodeHive,\n isVisible: Boolean(backendEditUrl),\n Component: BackendEditLink as unknown as ActionComponent,\n props: { href: backendEditUrl, label: labels.nodeHive },\n },\n {\n id: 'refresh-page',\n label: labels.refresh,\n Component: RefreshPage as unknown as ActionComponent,\n props: { label: labels.refresh },\n },\n {\n id: 'logout',\n label: labels.logout,\n Component: LogoutForm as unknown as ActionComponent,\n props: { logout, label: labels.logout },\n },\n ];\n\n const defaults = [...(profile ? [profile] : []), ...extraActions, ...rest];\n return buildActions ? buildActions(defaults, { lang, labels }) : defaults;\n}\n"],"mappings":"AAEA,OAAOA,eAAe,MAAM,wBAAyB;AAErD,OAAOC,UAAU,MAAM,kBAAmB;AAC1C,OAAOC,WAAW,MAAM,mBAAoB;AAE5C,OAAOC,WAAW,MAAM,mBAAoB;AA2B5C,OAAO,SAASC,qBAAqBA,CAAC;EACpCC,IAAI;EACJC,cAAc;EACdC,YAAY;EACZC,MAAM;EACNC,MAAM;EACNC,WAAW;EACXC,YAAY,GAAG,EAAE;EACjBC;AACyB,CAAC,EAA+B;EACzD,MAAMC,WAAW,GACfH,WAAW,KAAKI,SAAS,GAAG,IAAIT,IAAI,mBAAmB,GAAGK,WAAW;EAEvE,MAAMK,OAAyC,GAC7CF,WAAW,KAAK,IAAI,GAChB,IAAI,GACJ;IACEG,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAET,MAAM,CAACU,OAAO;IACrBC,SAAS,EAAEhB,WAAyC;IACpDiB,KAAK,EAAE;MACLC,IAAI,EAAER,WAAW;MACjBS,QAAQ,EAAEf,YAAY;MACtBU,KAAK,EAAET,MAAM,CAACU;IAChB;EACF,CAAC;EAEP,MAAMK,IAAiC,GAAG,CACxC;IACEP,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAET,MAAM,CAACgB,QAAQ;IACtBC,SAAS,EAAEC,OAAO,CAACpB,cAAc,CAAC;IAClCa,SAAS,EAAEnB,eAA6C;IACxDoB,KAAK,EAAE;MAAEC,IAAI,EAAEf,cAAc;MAAEW,KAAK,EAAET,MAAM,CAACgB;IAAS;EACxD,CAAC,EACD;IACER,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAET,MAAM,CAACmB,OAAO;IACrBR,SAAS,EAAEjB,WAAyC;IACpDkB,KAAK,EAAE;MAAEH,KAAK,EAAET,MAAM,CAACmB;IAAQ;EACjC,CAAC,EACD;IACEX,EAAE,EAAE,QAAQ;IACZC,KAAK,EAAET,MAAM,CAACC,MAAM;IACpBU,SAAS,EAAElB,UAAwC;IACnDmB,KAAK,EAAE;MAAEX,MAAM;MAAEQ,KAAK,EAAET,MAAM,CAACC;IAAO;EACxC,CAAC,CACF;EAED,MAAMmB,QAAQ,GAAG,CAAC,IAAIb,OAAO,GAAG,CAACA,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAGJ,YAAY,EAAE,GAAGY,IAAI,CAAC;EAC1E,OAAOX,YAAY,GAAGA,YAAY,CAACgB,QAAQ,EAAE;IAAEvB,IAAI;IAAEG;EAAO,CAAC,CAAC,GAAGoB,QAAQ;AAC3E","ignoreList":[]}
1
+ {"version":3,"file":"smart-actions-config.js","names":["BackendEditLink","LogoutForm","RefreshPage","UserProfile","getSmartActionsConfig","lang","editorLocale","backendEditUrl","userImageUrl","labels","logout","accountHref","buildActions","profileHref","undefined","profile","id","label","account","Component","props","href","imageUrl","rest","nodeHive","isVisible","Boolean","refresh","defaults"],"sources":["../../../src/smart-actions/internal/smart-actions-config.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\n\nimport BackendEditLink from './backend-edit-link.tsx';\nimport type { SmartActionsLabels } from './i18n.ts';\nimport LogoutForm from './logout-form.tsx';\nimport RefreshPage from './refresh-page.tsx';\nimport type { SmartActionsToolbarAction } from './toolbar/types.ts';\nimport UserProfile from './user-profile.tsx';\n\nexport type SmartActionsBuilderContext = {\n lang: string;\n labels: SmartActionsLabels;\n editorLocale: string;\n};\n\nexport type SmartActionsBuilder = (\n defaults: SmartActionsToolbarAction[],\n context: SmartActionsBuilderContext\n) => SmartActionsToolbarAction[];\n\ntype ActionComponent = ComponentType<Record<string, unknown>>;\n\ntype SmartActionsConfigContext = {\n lang: string;\n editorLocale: string;\n backendEditUrl: string | null;\n userImageUrl?: string | null;\n labels: SmartActionsLabels;\n logout: () => Promise<void>;\n /** Account link target; null omits the profile action. Defaults to /{lang}/nodehive/account. */\n accountHref?: string | null;\n /** Composes the default actions (profile, backend edit, refresh, logout). */\n buildActions?: SmartActionsBuilder;\n};\n\nexport function getSmartActionsConfig({\n lang,\n editorLocale,\n backendEditUrl,\n userImageUrl,\n labels,\n logout,\n accountHref,\n buildActions,\n}: SmartActionsConfigContext): SmartActionsToolbarAction[] {\n const profileHref =\n accountHref === undefined ? `/${lang}/nodehive/account` : accountHref;\n\n const profile: SmartActionsToolbarAction | null =\n profileHref === null\n ? null\n : {\n id: 'user-profile',\n label: labels.account,\n Component: UserProfile as unknown as ActionComponent,\n props: {\n href: profileHref,\n imageUrl: userImageUrl,\n label: labels.account,\n },\n };\n\n const rest: SmartActionsToolbarAction[] = [\n {\n id: 'backend-edit',\n label: labels.nodeHive,\n isVisible: Boolean(backendEditUrl),\n Component: BackendEditLink as unknown as ActionComponent,\n props: { href: backendEditUrl, label: labels.nodeHive },\n },\n {\n id: 'refresh-page',\n label: labels.refresh,\n Component: RefreshPage as unknown as ActionComponent,\n props: { label: labels.refresh },\n },\n {\n id: 'logout',\n label: labels.logout,\n Component: LogoutForm as unknown as ActionComponent,\n props: { logout, label: labels.logout },\n },\n ];\n\n const defaults = [...(profile ? [profile] : []), ...rest];\n return buildActions\n ? buildActions(defaults, { lang, labels, editorLocale })\n : defaults;\n}\n"],"mappings":"AAEA,OAAOA,eAAe,MAAM,wBAAyB;AAErD,OAAOC,UAAU,MAAM,kBAAmB;AAC1C,OAAOC,WAAW,MAAM,mBAAoB;AAE5C,OAAOC,WAAW,MAAM,mBAAoB;AA4B5C,OAAO,SAASC,qBAAqBA,CAAC;EACpCC,IAAI;EACJC,YAAY;EACZC,cAAc;EACdC,YAAY;EACZC,MAAM;EACNC,MAAM;EACNC,WAAW;EACXC;AACyB,CAAC,EAA+B;EACzD,MAAMC,WAAW,GACfF,WAAW,KAAKG,SAAS,GAAG,IAAIT,IAAI,mBAAmB,GAAGM,WAAW;EAEvE,MAAMI,OAAyC,GAC7CF,WAAW,KAAK,IAAI,GAChB,IAAI,GACJ;IACEG,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAER,MAAM,CAACS,OAAO;IACrBC,SAAS,EAAEhB,WAAyC;IACpDiB,KAAK,EAAE;MACLC,IAAI,EAAER,WAAW;MACjBS,QAAQ,EAAEd,YAAY;MACtBS,KAAK,EAAER,MAAM,CAACS;IAChB;EACF,CAAC;EAEP,MAAMK,IAAiC,GAAG,CACxC;IACEP,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAER,MAAM,CAACe,QAAQ;IACtBC,SAAS,EAAEC,OAAO,CAACnB,cAAc,CAAC;IAClCY,SAAS,EAAEnB,eAA6C;IACxDoB,KAAK,EAAE;MAAEC,IAAI,EAAEd,cAAc;MAAEU,KAAK,EAAER,MAAM,CAACe;IAAS;EACxD,CAAC,EACD;IACER,EAAE,EAAE,cAAc;IAClBC,KAAK,EAAER,MAAM,CAACkB,OAAO;IACrBR,SAAS,EAAEjB,WAAyC;IACpDkB,KAAK,EAAE;MAAEH,KAAK,EAAER,MAAM,CAACkB;IAAQ;EACjC,CAAC,EACD;IACEX,EAAE,EAAE,QAAQ;IACZC,KAAK,EAAER,MAAM,CAACC,MAAM;IACpBS,SAAS,EAAElB,UAAwC;IACnDmB,KAAK,EAAE;MAAEV,MAAM;MAAEO,KAAK,EAAER,MAAM,CAACC;IAAO;EACxC,CAAC,CACF;EAED,MAAMkB,QAAQ,GAAG,CAAC,IAAIb,OAAO,GAAG,CAACA,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,GAAGQ,IAAI,CAAC;EACzD,OAAOX,YAAY,GACfA,YAAY,CAACgB,QAAQ,EAAE;IAAEvB,IAAI;IAAEI,MAAM;IAAEH;EAAa,CAAC,CAAC,GACtDsB,QAAQ;AACd","ignoreList":[]}
@@ -2,4 +2,5 @@ export { getSmartActionsContext, type SmartActionsContext, } from './internal/ge
2
2
  export type { SmartActionsDictionaryOverrides } from './internal/i18n.js';
3
3
  export { default as SmartActionsButton } from './internal/smart-actions-button.js';
4
4
  export type { SmartActionsBuilder, SmartActionsBuilderContext, } from './internal/smart-actions-config.js';
5
+ export { insertAfter, insertBefore } from './internal/ordering.js';
5
6
  export type { SmartActionsToolbarAction } from './internal/toolbar/types.js';
@@ -1,4 +1,5 @@
1
1
  // Server entry: keeps next/headers-dependent code out of the client index.
2
2
  export { getSmartActionsContext } from "./internal/get-smart-actions-context.js";
3
3
  export { default as SmartActionsButton } from "./internal/smart-actions-button.js";
4
+ export { insertAfter, insertBefore } from "./internal/ordering.js";
4
5
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["getSmartActionsContext","default","SmartActionsButton"],"sources":["../../src/smart-actions/server.ts"],"sourcesContent":["// Server entry: keeps next/headers-dependent code out of the client index.\nexport {\n getSmartActionsContext,\n type SmartActionsContext,\n} from './internal/get-smart-actions-context.ts';\nexport type { SmartActionsDictionaryOverrides } from './internal/i18n.ts';\nexport { default as SmartActionsButton } from './internal/smart-actions-button.tsx';\nexport type {\n SmartActionsBuilder,\n SmartActionsBuilderContext,\n} from './internal/smart-actions-config.tsx';\nexport type { SmartActionsToolbarAction } from './internal/toolbar/types.ts';\n"],"mappings":"AAAA;AACA,SACEA,sBAAsB,QAEjB,yCAAyC;AAEhD,SAASC,OAAO,IAAIC,kBAAkB,QAAQ,oCAAqC","ignoreList":[]}
1
+ {"version":3,"file":"server.js","names":["getSmartActionsContext","default","SmartActionsButton","insertAfter","insertBefore"],"sources":["../../src/smart-actions/server.ts"],"sourcesContent":["// Server entry: keeps next/headers-dependent code out of the client index.\nexport {\n getSmartActionsContext,\n type SmartActionsContext,\n} from './internal/get-smart-actions-context.ts';\nexport type { SmartActionsDictionaryOverrides } from './internal/i18n.ts';\nexport { default as SmartActionsButton } from './internal/smart-actions-button.tsx';\nexport type {\n SmartActionsBuilder,\n SmartActionsBuilderContext,\n} from './internal/smart-actions-config.tsx';\nexport { insertAfter, insertBefore } from './internal/ordering.ts';\nexport type { SmartActionsToolbarAction } from './internal/toolbar/types.ts';\n"],"mappings":"AAAA;AACA,SACEA,sBAAsB,QAEjB,yCAAyC;AAEhD,SAASC,OAAO,IAAIC,kBAAkB,QAAQ,oCAAqC;AAKnF,SAASC,WAAW,EAAEC,YAAY,QAAQ,wBAAwB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodehive/nextjs",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "NodeHive Next.js infrastructure modules: auth, puck-editor, visual-editor, smart-actions",
5
5
  "license": "MIT",
6
6
  "author": "NETNODE AG <info@netnode.ch>",