@nodehive/nextjs 0.6.0 → 0.7.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.
Files changed (74) hide show
  1. package/README.md +9 -0
  2. package/dist/puck-editor/index.d.ts +1 -1
  3. package/dist/puck-editor/index.js +1 -1
  4. package/dist/puck-editor/index.js.map +1 -1
  5. package/dist/puck-editor/internal/api/client.d.ts +4 -4
  6. package/dist/puck-editor/internal/api/client.js +14 -6
  7. package/dist/puck-editor/internal/api/client.js.map +1 -1
  8. package/dist/puck-editor/internal/api/create-puck-api.js +1 -1
  9. package/dist/puck-editor/internal/api/create-puck-api.js.map +1 -1
  10. package/dist/puck-editor/internal/api/handlers/template.d.ts +1 -1
  11. package/dist/puck-editor/internal/api/handlers/template.js +16 -4
  12. package/dist/puck-editor/internal/api/handlers/template.js.map +1 -1
  13. package/dist/puck-editor/internal/api/handlers/upload.js +6 -3
  14. package/dist/puck-editor/internal/api/handlers/upload.js.map +1 -1
  15. package/dist/puck-editor/internal/api/media-upload.d.ts +2 -2
  16. package/dist/puck-editor/internal/api/media-upload.js +6 -1
  17. package/dist/puck-editor/internal/api/media-upload.js.map +1 -1
  18. package/dist/puck-editor/internal/editor/picker-model.d.ts +1 -1
  19. package/dist/puck-editor/internal/editor/puck-editor.js +148 -134
  20. package/dist/puck-editor/internal/editor/puck-editor.js.map +1 -1
  21. package/dist/puck-editor/internal/editor-config.d.ts +5 -2
  22. package/dist/puck-editor/internal/editor-config.js +32 -26
  23. package/dist/puck-editor/internal/editor-config.js.map +1 -1
  24. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js +323 -290
  25. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js.map +1 -1
  26. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js +3 -2
  27. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js.map +1 -1
  28. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js +3 -4
  29. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js.map +1 -1
  30. package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts +2 -2
  31. package/dist/puck-editor/internal/fields/media-selector/use-media-library.js +118 -101
  32. package/dist/puck-editor/internal/fields/media-selector/use-media-library.js.map +1 -1
  33. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js +3 -2
  34. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js.map +1 -1
  35. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts +21 -13
  36. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js +9 -35
  37. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js.map +1 -1
  38. package/dist/puck-editor/internal/fields/node-selector/node-selector-field.d.ts +12 -0
  39. package/dist/puck-editor/internal/fields/node-selector/node-selector-field.js +56 -0
  40. package/dist/puck-editor/internal/fields/node-selector/node-selector-field.js.map +1 -0
  41. package/dist/puck-editor/internal/locale.d.ts +2 -6
  42. package/dist/puck-editor/internal/locale.js +6 -8
  43. package/dist/puck-editor/internal/locale.js.map +1 -1
  44. package/dist/puck-editor/internal/native-puck-dictionaries.d.ts +2 -0
  45. package/dist/puck-editor/internal/native-puck-dictionaries.js +160 -0
  46. package/dist/puck-editor/internal/native-puck-dictionaries.js.map +1 -0
  47. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts +1 -2
  48. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js +4 -4
  49. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js.map +1 -1
  50. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts +1 -2
  51. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js +0 -2
  52. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js.map +1 -1
  53. package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts +2 -2
  54. package/dist/puck-editor/internal/plugins/agent-plugin/templates.js +7 -7
  55. package/dist/puck-editor/internal/plugins/agent-plugin/templates.js.map +1 -1
  56. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js +3 -1
  57. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js.map +1 -1
  58. package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts +1 -1
  59. package/dist/puck-editor/internal/plugins/templates-plugin/templates.js +3 -3
  60. package/dist/puck-editor/internal/plugins/templates-plugin/templates.js.map +1 -1
  61. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js +32 -37
  62. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js.map +1 -1
  63. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts +1 -1
  64. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js +95 -72
  65. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js.map +1 -1
  66. package/dist/puck-editor/internal/puck-wrapper.d.ts +1 -1
  67. package/dist/puck-editor/internal/puck-wrapper.js +89 -83
  68. package/dist/puck-editor/internal/puck-wrapper.js.map +1 -1
  69. package/dist/puck-editor/internal/use-puck-overlay.d.ts +3 -2
  70. package/dist/puck-editor/internal/use-puck-overlay.js +67 -56
  71. package/dist/puck-editor/internal/use-puck-overlay.js.map +1 -1
  72. package/dist/puck-editor/puck-theme.css +3 -3
  73. package/dist/theme.css +2 -2
  74. package/package.json +20 -20
@@ -1,49 +1,55 @@
1
1
  'use client';
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
- import { createContext, useContext } from 'react';
4
+ import { createContext, createElement, useContext } from 'react';
5
5
  import { configurePuckApi } from "./api/client.js";
6
6
  import { resolveContentModel } from "./content-model.js";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const PuckEditorConfigContext = /*#__PURE__*/createContext({});
7
+ import { requireContentLocale } from "./locale.js";
8
+ const PuckEditorConfigContext = /*#__PURE__*/createContext(undefined);
9
9
 
10
10
  /**
11
11
  * Mounted by PuckWrapper. Headless setups that use useMediaLibrary or
12
12
  * MediaSelectorField outside PuckWrapper mount this provider themselves.
13
13
  */
14
- export function PuckEditorConfigProvider(t0) {
15
- const $ = _c(3);
16
- const {
17
- config,
18
- children
19
- } = t0;
20
- if (typeof window !== "undefined") {
14
+ export function PuckEditorConfigProvider({
15
+ config,
16
+ children
17
+ }) {
18
+ requireContentLocale(config.contentLocale);
19
+ if (typeof window !== 'undefined') {
21
20
  configurePuckApi(config.api);
22
21
  }
22
+ return /*#__PURE__*/createElement(PuckEditorConfigContext.Provider, {
23
+ value: config
24
+ }, children);
25
+ }
26
+ export function usePuckEditorConfig() {
27
+ const config = useContext(PuckEditorConfigContext);
28
+ if (!config) {
29
+ throw new Error("puck-editor: mount PuckEditorConfigProvider with an explicit contentLocale before using editor fields or hooks.");
30
+ }
31
+ return config;
32
+ }
33
+ export function usePuckContentLocale() {
34
+ const $ = _c(2);
35
+ const t0 = usePuckEditorConfig();
23
36
  let t1;
24
- if ($[0] !== children || $[1] !== config) {
25
- t1 = /*#__PURE__*/_jsx(PuckEditorConfigContext.Provider, {
26
- value: config,
27
- children: children
28
- });
29
- $[0] = children;
30
- $[1] = config;
31
- $[2] = t1;
37
+ if ($[0] !== t0.contentLocale) {
38
+ t1 = requireContentLocale(t0.contentLocale);
39
+ $[0] = t0.contentLocale;
40
+ $[1] = t1;
32
41
  } else {
33
- t1 = $[2];
42
+ t1 = $[1];
34
43
  }
35
44
  return t1;
36
45
  }
37
- export function usePuckEditorConfig() {
38
- return useContext(PuckEditorConfigContext);
39
- }
40
46
 
41
- /** Resolved content model; defaults apply without a provider (headless). */
47
+ /** Resolved content model; defaults apply without a provider (rendering). */
42
48
  export function usePuckContentModel() {
43
49
  const $ = _c(2);
44
50
  const {
45
51
  contentModel
46
- } = useContext(PuckEditorConfigContext);
52
+ } = useContext(PuckEditorConfigContext) ?? {};
47
53
  let t0;
48
54
  if ($[0] !== contentModel) {
49
55
  t0 = resolveContentModel(contentModel);
@@ -55,10 +61,10 @@ export function usePuckContentModel() {
55
61
  return t0;
56
62
  }
57
63
  export function usePuckPropTransforms() {
58
- return useContext(PuckEditorConfigContext).propTransforms;
64
+ return useContext(PuckEditorConfigContext)?.propTransforms;
59
65
  }
60
66
  const NO_BUILTINS = [];
61
67
  export function useBuiltinTemplates() {
62
- return useContext(PuckEditorConfigContext).builtinTemplates ?? NO_BUILTINS;
68
+ return useContext(PuckEditorConfigContext)?.builtinTemplates ?? NO_BUILTINS;
63
69
  }
64
70
  //# sourceMappingURL=editor-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-config.js","names":["c","_c","createContext","useContext","configurePuckApi","resolveContentModel","jsx","_jsx","PuckEditorConfigContext","PuckEditorConfigProvider","t0","$","config","children","window","api","t1","Provider","usePuckEditorConfig","usePuckContentModel","contentModel","usePuckPropTransforms","propTransforms","NO_BUILTINS","useBuiltinTemplates","builtinTemplates"],"sources":["../../../src/puck-editor/internal/editor-config.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, useContext, type ReactNode } from 'react';\n\nimport { configurePuckApi, type PuckApiInjection } from './api/client.ts';\nimport {\n resolveContentModel,\n type PuckContentModel,\n type PuckContentModelInput,\n type PuckPropTransforms,\n} from './content-model.ts';\nimport type { BuiltinTemplate } from './plugins/templates-plugin/templates.ts';\n\nexport type PuckEditorConfig = {\n /**\n * Absolute Drupal base URL used to absolutize relative media URIs\n * (thumbnails). Injected by the project instead of reading NEXT_PUBLIC_*\n * env in module code — env inlining is not guaranteed inside packages.\n */\n drupalBaseUrl?: string;\n /**\n * Drupal content-model overrides. Pass the same value to createPuckApi so\n * the editor UI and the publish validation stay in sync.\n */\n contentModel?: PuckContentModelInput;\n builtinTemplates?: BuiltinTemplate[];\n /**\n * Prop migrations applied wherever stored Puck data enters the editor\n * (page data and template inserts). Pass the same transforms to\n * parsePuckData in the live-render path so both paths stay in sync.\n */\n propTransforms?: PuckPropTransforms;\n /**\n * Overrides for the editor API calls (base path and/or fetch). Defaults to\n * NEXT_PUBLIC_NODEHIVE_PUCK_API_BASE (or /api/puck) and the global fetch, so\n * leaving this unset keeps the current behavior.\n */\n api?: PuckApiInjection;\n};\n\nconst PuckEditorConfigContext = createContext<PuckEditorConfig>({});\n\n/**\n * Mounted by PuckWrapper. Headless setups that use useMediaLibrary or\n * MediaSelectorField outside PuckWrapper mount this provider themselves.\n */\nexport function PuckEditorConfigProvider({\n config,\n children,\n}: {\n config: PuckEditorConfig;\n children: ReactNode;\n}) {\n if (typeof window !== 'undefined') {\n configurePuckApi(config.api);\n }\n return (\n <PuckEditorConfigContext.Provider value={config}>\n {children}\n </PuckEditorConfigContext.Provider>\n );\n}\n\nexport function usePuckEditorConfig(): PuckEditorConfig {\n return useContext(PuckEditorConfigContext);\n}\n\n/** Resolved content model; defaults apply without a provider (headless). */\nexport function usePuckContentModel(): PuckContentModel {\n const { contentModel } = useContext(PuckEditorConfigContext);\n return resolveContentModel(contentModel);\n}\n\nexport function usePuckPropTransforms(): PuckPropTransforms | undefined {\n return useContext(PuckEditorConfigContext).propTransforms;\n}\n\nconst NO_BUILTINS: BuiltinTemplate[] = [];\n\nexport function useBuiltinTemplates(): BuiltinTemplate[] {\n return useContext(PuckEditorConfigContext).builtinTemplates ?? NO_BUILTINS;\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,CAAA,IAAAC,EAAA;AAEb,SAASC,aAAa,EAAEC,UAAU,QAAwB,OAAO;AAEjE,SAASC,gBAAgB,QAA+B,iBAAiB;AACzE,SACEC,mBAAmB,QAId,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA8B5B,MAAMC,uBAAuB,gBAAGN,aAAa,CAAmB,CAAC,CAAC,CAAC;;AAEnE;AACA;AACA;AACA;AACA,OAAO,SAAAO,yBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAV,EAAA;EAAkC;IAAAW,MAAA;IAAAC;EAAA,IAAAH,EAMxC;EACC,IAAI,OAAOI,MAAM,KAAK,WAAW;IAC/BV,gBAAgB,CAACQ,MAAM,CAAAG,GAAI,CAAC;EAAA;EAC7B,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAE,QAAA,IAAAF,CAAA,QAAAC,MAAA;IAECI,EAAA,gBAAAT,IAAA,CAAAC,uBAAA,CAAAS,QAAA;MAAyCL,KAAM,EAANA,MAAM;MAAAC,QAAA,EAC5CA;IAAQ,CACuB,CAAC;IAAAF,CAAA,MAAAE,QAAA;IAAAF,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EAAA,OAFnCK,EAEmC;AAAA;AAIvC,OAAO,SAAAE,oBAAA;EAAA,OACEf,UAAU,CAACK,uBAAuB,CAAC;AAAA;;AAG5C;AACA,OAAO,SAAAW,oBAAA;EAAA,MAAAR,CAAA,GAAAV,EAAA;EACL;IAAAmB;EAAA,IAAyBjB,UAAU,CAACK,uBAAuB,CAAC;EAAC,IAAAE,EAAA;EAAA,IAAAC,CAAA,QAAAS,YAAA;IACtDV,EAAA,GAAAL,mBAAmB,CAACe,YAAY,CAAC;IAAAT,CAAA,MAAAS,YAAA;IAAAT,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OAAjCD,EAAiC;AAAA;AAG1C,OAAO,SAAAW,sBAAA;EAAA,OACElB,UAAU,CAACK,uBAAuB,CAAC,CAAAc,cAAe;AAAA;AAG3D,MAAMC,WAA8B,GAAG,EAAE;AAEzC,OAAO,SAAAC,oBAAA;EAAA,OACErB,UAAU,CAACK,uBAAuB,CAAC,CAAAiB,gBAAgC,IAAnEF,WAAmE;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"editor-config.js","names":["c","_c","createContext","createElement","useContext","configurePuckApi","resolveContentModel","requireContentLocale","PuckEditorConfigContext","undefined","PuckEditorConfigProvider","config","children","contentLocale","window","api","Provider","value","usePuckEditorConfig","Error","usePuckContentLocale","$","t0","t1","usePuckContentModel","contentModel","usePuckPropTransforms","propTransforms","NO_BUILTINS","useBuiltinTemplates","builtinTemplates"],"sources":["../../../src/puck-editor/internal/editor-config.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n createElement,\n useContext,\n type ReactNode,\n} from 'react';\n\nimport { configurePuckApi, type PuckApiInjection } from './api/client.ts';\nimport {\n resolveContentModel,\n type PuckContentModel,\n type PuckContentModelInput,\n type PuckPropTransforms,\n} from './content-model.ts';\nimport { requireContentLocale } from './locale.ts';\nimport type { BuiltinTemplate } from './plugins/templates-plugin/templates.ts';\n\nexport type PuckEditorConfig = {\n /** Authoritative content language, independent of the editor UI locale. */\n contentLocale: string;\n /**\n * Absolute Drupal base URL used to absolutize relative media URIs\n * (thumbnails). Injected by the project instead of reading NEXT_PUBLIC_*\n * env in module code — env inlining is not guaranteed inside packages.\n */\n drupalBaseUrl?: string;\n /**\n * Drupal content-model overrides. Pass the same value to createPuckApi so\n * the editor UI and the publish validation stay in sync.\n */\n contentModel?: PuckContentModelInput;\n builtinTemplates?: BuiltinTemplate[];\n /**\n * Prop migrations applied wherever stored Puck data enters the editor\n * (page data and template inserts). Pass the same transforms to\n * parsePuckData in the live-render path so both paths stay in sync.\n */\n propTransforms?: PuckPropTransforms;\n /**\n * Overrides for the editor API calls (base path and/or fetch). Defaults to\n * NEXT_PUBLIC_NODEHIVE_PUCK_API_BASE (or /api/puck) and the global fetch, so\n * leaving this unset keeps the current behavior.\n */\n api?: PuckApiInjection;\n};\n\nconst PuckEditorConfigContext = createContext<PuckEditorConfig | undefined>(\n undefined\n);\n\n/**\n * Mounted by PuckWrapper. Headless setups that use useMediaLibrary or\n * MediaSelectorField outside PuckWrapper mount this provider themselves.\n */\nexport function PuckEditorConfigProvider({\n config,\n children,\n}: {\n config: PuckEditorConfig;\n children: ReactNode;\n}) {\n requireContentLocale(config.contentLocale);\n if (typeof window !== 'undefined') {\n configurePuckApi(config.api);\n }\n return createElement(\n PuckEditorConfigContext.Provider,\n { value: config },\n children\n );\n}\n\nexport function usePuckEditorConfig(): PuckEditorConfig {\n const config = useContext(PuckEditorConfigContext);\n if (!config) {\n throw new Error(\n 'puck-editor: mount PuckEditorConfigProvider with an explicit contentLocale before using editor fields or hooks.'\n );\n }\n return config;\n}\n\nexport function usePuckContentLocale(): string {\n return requireContentLocale(usePuckEditorConfig().contentLocale);\n}\n\n/** Resolved content model; defaults apply without a provider (rendering). */\nexport function usePuckContentModel(): PuckContentModel {\n const { contentModel } = useContext(PuckEditorConfigContext) ?? {};\n return resolveContentModel(contentModel);\n}\n\nexport function usePuckPropTransforms(): PuckPropTransforms | undefined {\n return useContext(PuckEditorConfigContext)?.propTransforms;\n}\n\nconst NO_BUILTINS: BuiltinTemplate[] = [];\n\nexport function useBuiltinTemplates(): BuiltinTemplate[] {\n return useContext(PuckEditorConfigContext)?.builtinTemplates ?? NO_BUILTINS;\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,CAAA,IAAAC,EAAA;AAEb,SACEC,aAAa,EACbC,aAAa,EACbC,UAAU,QAEL,OAAO;AAEd,SAASC,gBAAgB,QAA+B,iBAAiB;AACzE,SACEC,mBAAmB,QAId,oBAAoB;AAC3B,SAASC,oBAAoB,QAAQ,aAAa;AAgClD,MAAMC,uBAAuB,gBAAGN,aAAa,CAC3CO,SACF,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAC;EACvCC,MAAM;EACNC;AAIF,CAAC,EAAE;EACDL,oBAAoB,CAACI,MAAM,CAACE,aAAa,CAAC;EAC1C,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjCT,gBAAgB,CAACM,MAAM,CAACI,GAAG,CAAC;EAC9B;EACA,oBAAOZ,aAAa,CAClBK,uBAAuB,CAACQ,QAAQ,EAChC;IAAEC,KAAK,EAAEN;EAAO,CAAC,EACjBC,QACF,CAAC;AACH;AAEA,OAAO,SAAAM,oBAAA;EACL,MAAAP,MAAA,GAAeP,UAAU,CAACI,uBAAuB,CAAC;EAClD,IAAI,CAACG,MAAM;IACT,MAAM,IAAIQ,KAAK,CACb,iHACF,CAAC;EAAC;EACH,OACMR,MAAM;AAAA;AAGf,OAAO,SAAAS,qBAAA;EAAA,MAAAC,CAAA,GAAApB,EAAA;EACuB,MAAAqB,EAAA,GAAAJ,mBAAmB,CAAC,CAAC;EAAA,IAAAK,EAAA;EAAA,IAAAF,CAAA,QAAAC,EAAA,CAAAT,aAAA;IAA1CU,EAAA,GAAAhB,oBAAoB,CAACe,EAAqB,CAAAT,aAAc,CAAC;IAAAQ,CAAA,MAAAC,EAAA,CAAAT,aAAA;IAAAQ,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAAA,OAAzDE,EAAyD;AAAA;;AAGlE;AACA,OAAO,SAAAC,oBAAA;EAAA,MAAAH,CAAA,GAAApB,EAAA;EACL;IAAAwB;EAAA,IAAyBrB,UAAU,CAACI,uBAA6B,CAAC,IAAzC,CAAwC,CAAC;EAAC,IAAAc,EAAA;EAAA,IAAAD,CAAA,QAAAI,YAAA;IAC5DH,EAAA,GAAAhB,mBAAmB,CAACmB,YAAY,CAAC;IAAAJ,CAAA,MAAAI,YAAA;IAAAJ,CAAA,MAAAC,EAAA;EAAA;IAAAA,EAAA,GAAAD,CAAA;EAAA;EAAA,OAAjCC,EAAiC;AAAA;AAG1C,OAAO,SAAAI,sBAAA;EAAA,OACEtB,UAAU,CAACI,uBAAuC,CAAC,EAAAmB,cAAA;AAAA;AAG5D,MAAMC,WAA8B,GAAG,EAAE;AAEzC,OAAO,SAAAC,oBAAA;EAAA,OACEzB,UAAU,CAACI,uBAAyC,CAAC,EAAAsB,gBAAe,IAApEF,WAAoE;AAAA","ignoreList":[]}