@okam/directus-next-component 1.7.36 → 1.7.38

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 (41) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/components/DirectusFile/config.js +4 -4
  4. package/components/DirectusImg/index.js +2 -2
  5. package/components/DirectusImg/index.mjs +2 -2
  6. package/components/DirectusLink/index.js +2 -2
  7. package/components/DirectusLink/index.mjs +2 -2
  8. package/components/DirectusLink/interface.d.ts +4 -4
  9. package/components/DirectusVideo/index.js +2 -2
  10. package/components/DirectusVideo/index.mjs +2 -2
  11. package/index.d.ts +10 -9
  12. package/index.js +14 -10
  13. package/index.mjs +14 -10
  14. package/package.json +5 -4
  15. package/server.d.ts +4 -4
  16. package/server.js +12 -8
  17. package/server.mjs +12 -8
  18. package/types/index.d.ts +3 -0
  19. package/types/links.d.ts +2 -2
  20. package/types/{navigation-items.d.ts → navigationItems.d.ts} +5 -5
  21. package/{hooks/directus-file.d.ts → utils/getDirectusFile/index.d.ts} +8 -3
  22. package/{hooks/directus-file.js → utils/getDirectusFile/index.js} +7 -3
  23. package/{hooks/directus-file.mjs → utils/getDirectusFile/index.mjs} +6 -3
  24. package/utils/getDirectusLink/index.d.ts +8 -0
  25. package/utils/getDirectusLink/index.js +123 -0
  26. package/utils/getDirectusLink/index.mjs +123 -0
  27. package/utils/getDirectusMetadata/index.d.ts +15 -0
  28. package/{hooks/directus-metadata.js → utils/getDirectusMetadata/index.js} +11 -12
  29. package/{hooks/directus-metadata.mjs → utils/getDirectusMetadata/index.mjs} +10 -12
  30. package/utils/getDirectusSearchParams/index.d.ts +8 -0
  31. package/{hooks/directus-search-params.js → utils/getDirectusSearchParams/index.js} +2 -1
  32. package/{hooks/directus-search-params.mjs → utils/getDirectusSearchParams/index.mjs} +1 -1
  33. package/utils/getNavigationItems/index.d.ts +15 -0
  34. package/{hooks/navigation-items.js → utils/getNavigationItems/index.js} +6 -3
  35. package/{hooks/navigation-items.mjs → utils/getNavigationItems/index.mjs} +5 -3
  36. package/hooks/directus-link.d.ts +0 -4
  37. package/hooks/directus-link.js +0 -94
  38. package/hooks/directus-link.mjs +0 -95
  39. package/hooks/directus-metadata.d.ts +0 -7
  40. package/hooks/directus-search-params.d.ts +0 -4
  41. package/hooks/navigation-items.d.ts +0 -11
package/CHANGELOG.md CHANGED
@@ -1,3 +1,64 @@
1
+ ## 1.7.38 (2026-01-15)
2
+
3
+ ### 🚀 Features
4
+
5
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
6
+ - **directus-next-component:** directus link supports search params ([21a3e46](https://github.com/OKAMca/stack/commit/21a3e46))
7
+
8
+ ### 🩹 Fixes
9
+
10
+ - **directus-next-component:** valid directus link href error handling ([#365](https://github.com/OKAMca/stack/pull/365))
11
+ - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
12
+ - **directus-next:** bump version ([e9441ad](https://github.com/OKAMca/stack/commit/e9441ad))
13
+ - **directus-next-component:** core-lib in externals deps ([9b04ca0](https://github.com/OKAMca/stack/commit/9b04ca0))
14
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
15
+
16
+ ### ⚠️ Breaking Changes
17
+
18
+ - Consumers must now have react and react-dom in their own
19
+
20
+ ### 🧱 Updated Dependencies
21
+
22
+ - Updated next-component to 1.3.0
23
+ - Updated directus-next to 1.2.12
24
+
25
+ ### ❤️ Thank You
26
+
27
+ - Marie-Maxime Tanguay @marie-maxime
28
+ - Pierre-Olivier Clerson @poclerson
29
+ - poclerson
30
+
31
+ ## 1.7.37 (2026-01-14)
32
+
33
+ ### 🚀 Features
34
+
35
+ - ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
36
+ - **directus-next-component:** directus link supports search params ([21a3e46](https://github.com/OKAMca/stack/commit/21a3e46))
37
+
38
+ ### 🩹 Fixes
39
+
40
+ - **directus-next-component:** valid directus link href error handling ([#365](https://github.com/OKAMca/stack/pull/365))
41
+ - ⚠️ functions starting with "use" should be reserved to react hooks ([68f1f8f](https://github.com/OKAMca/stack/commit/68f1f8f))
42
+ - **directus-next:** bump version ([e9441ad](https://github.com/OKAMca/stack/commit/e9441ad))
43
+ - **directus-next-component:** core-lib in externals deps ([9b04ca0](https://github.com/OKAMca/stack/commit/9b04ca0))
44
+ - update vite-plugin-dts to version 3 ([5d33c77](https://github.com/OKAMca/stack/commit/5d33c77))
45
+
46
+ ### ⚠️ Breaking Changes
47
+
48
+ - Consumers must now have react and react-dom in their own
49
+
50
+ ### 🧱 Updated Dependencies
51
+
52
+ - Updated stack-ui to 1.44.0
53
+ - Updated next-component to 1.2.4
54
+ - Updated directus-next to 1.2.11
55
+
56
+ ### ❤️ Thank You
57
+
58
+ - Marie-Maxime Tanguay @marie-maxime
59
+ - Pierre-Olivier Clerson @poclerson
60
+ - poclerson
61
+
1
62
  ## 1.7.36 (2026-01-13)
2
63
 
3
64
  ### 🚀 Features
package/README.md CHANGED
@@ -89,7 +89,7 @@ const depthMap: Record<number, object> = {
89
89
  }
90
90
 
91
91
  // Loop recursively through navigation items and assign style based on depth
92
- function renderTree(tree: Nullable<TNavigationItemsTree>): React.ReactNode {
92
+ function renderTree(tree: Nullable<TTNavigationItemsTree>): React.ReactNode {
93
93
  if (!tree) return null
94
94
  const { children, link, linkProps, depth } = tree
95
95
  const style = depthMap[depth]
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
- const index = require("../DirectusImg/index.js");
3
- const index$1 = require("../DirectusVideo/index.js");
2
+ const index$1 = require("../DirectusImg/index.js");
3
+ const index = require("../DirectusVideo/index.js");
4
4
  const directusFileConfig = {
5
- image: index,
6
- video: index$1
5
+ image: index$1,
6
+ video: index
7
7
  };
8
8
  module.exports = directusFileConfig;
@@ -2,10 +2,10 @@
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const nextComponent = require("@okam/next-component");
4
4
  const thumbhash = require("unlazy/thumbhash");
5
- const directusFile = require("../../hooks/directus-file.js");
5
+ const index = require("../../utils/getDirectusFile/index.js");
6
6
  const DirectusImg = (props) => {
7
7
  const { fit, baseUrl, focal_point_x: focalPointX, focal_point_y: focalPointY, thumbhash: thumbhash$1, width, height } = props;
8
- const fileProps = directusFile(props, baseUrl, { fit });
8
+ const fileProps = index.getDirectusFile(props, baseUrl, { fit });
9
9
  if (!fileProps) return null;
10
10
  const hasFocalPoint = !!focalPointX && !!focalPointY && !!width && !!height;
11
11
  const style = hasFocalPoint ? {
@@ -1,10 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Img } from "@okam/next-component";
3
3
  import { createPngDataUri } from "unlazy/thumbhash";
4
- import useDirectusFile from "../../hooks/directus-file.mjs";
4
+ import { getDirectusFile } from "../../utils/getDirectusFile/index.mjs";
5
5
  const DirectusImg = (props) => {
6
6
  const { fit, baseUrl, focal_point_x: focalPointX, focal_point_y: focalPointY, thumbhash, width, height } = props;
7
- const fileProps = useDirectusFile(props, baseUrl, { fit });
7
+ const fileProps = getDirectusFile(props, baseUrl, { fit });
8
8
  if (!fileProps) return null;
9
9
  const hasFocalPoint = !!focalPointX && !!focalPointY && !!width && !!height;
10
10
  const style = hasFocalPoint ? {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const stackUi = require("@okam/stack-ui");
4
- const directusLink = require("../../hooks/directus-link.js");
4
+ const index = require("../../utils/getDirectusLink/index.js");
5
5
  const DirectusLink = (props) => {
6
6
  const { type, componentsConfig } = props;
7
- const linkProps = directusLink(props);
7
+ const linkProps = index.getDirectusLink(props);
8
8
  if (!type) return null;
9
9
  const LinkComponent = componentsConfig == null ? void 0 : componentsConfig[type];
10
10
  if (LinkComponent) return /* @__PURE__ */ jsxRuntime.jsx(LinkComponent, { ...props });
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Anchor } from "@okam/stack-ui";
3
- import useDirectusLink from "../../hooks/directus-link.mjs";
3
+ import { getDirectusLink } from "../../utils/getDirectusLink/index.mjs";
4
4
  const DirectusLink = (props) => {
5
5
  const { type, componentsConfig } = props;
6
- const linkProps = useDirectusLink(props);
6
+ const linkProps = getDirectusLink(props);
7
7
  if (!type) return null;
8
8
  const LinkComponent = componentsConfig == null ? void 0 : componentsConfig[type];
9
9
  if (LinkComponent) return /* @__PURE__ */ jsx(LinkComponent, { ...props });
@@ -2,13 +2,13 @@ import { TDefaultComponent, TAnchorProps } from '../../../../../stack/stack-ui/s
2
2
  import { AriaAttributes, ComponentType } from 'react';
3
3
  import { TLinks } from '../../types/links';
4
4
 
5
- export type TDirectusLink = Omit<TDefaultComponent, 'children'> & Omit<Partial<TLinks>, 'tokens'> & AriaAttributes;
6
- export interface TUseDirectusLink extends TDirectusLink {
5
+ export type DirectusLink = Omit<TDefaultComponent, 'children'> & Omit<Partial<TLinks>, 'tokens'> & AriaAttributes;
6
+ export interface TGetDirectusLink extends DirectusLink {
7
7
  propsConfig?: TDirectusLinkPropsConfig;
8
8
  }
9
- export interface TDirectusLinkProps extends TDirectusLink {
9
+ export interface TDirectusLinkProps extends DirectusLink {
10
10
  componentsConfig?: TDirectusLinkComponentsConfig;
11
11
  propsConfig?: TDirectusLinkPropsConfig;
12
12
  }
13
13
  export type TDirectusLinkComponentsConfig = Record<string, ComponentType<TDirectusLinkProps>>;
14
- export type TDirectusLinkPropsConfig<ReturnProps extends TAnchorProps = TAnchorProps> = Record<string, (props: TUseDirectusLink) => ReturnProps>;
14
+ export type TDirectusLinkPropsConfig<ReturnProps extends TAnchorProps = TAnchorProps> = Record<string, (props: TGetDirectusLink) => ReturnProps>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const stackUi = require("@okam/stack-ui");
4
- const directusFile = require("../../hooks/directus-file.js");
4
+ const index = require("../../utils/getDirectusFile/index.js");
5
5
  const DirectusVideo = (props) => {
6
6
  const { baseUrl } = props;
7
- const fileProps = directusFile(props, baseUrl);
7
+ const fileProps = index.getDirectusFile(props, baseUrl);
8
8
  if (!fileProps) return null;
9
9
  const { type } = fileProps;
10
10
  return /* @__PURE__ */ jsxRuntime.jsx(stackUi.Video, { ...fileProps, type: type ?? void 0 });
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Video } from "@okam/stack-ui";
3
- import useDirectusFile from "../../hooks/directus-file.mjs";
3
+ import { getDirectusFile } from "../../utils/getDirectusFile/index.mjs";
4
4
  const DirectusVideo = (props) => {
5
5
  const { baseUrl } = props;
6
- const fileProps = useDirectusFile(props, baseUrl);
6
+ const fileProps = getDirectusFile(props, baseUrl);
7
7
  if (!fileProps) return null;
8
8
  const { type } = fileProps;
9
9
  return /* @__PURE__ */ jsx(Video, { ...fileProps, type: type ?? void 0 });
package/index.d.ts CHANGED
@@ -2,12 +2,17 @@ export { default as DirectusLink } from './components/DirectusLink';
2
2
  export { default as DirectusImg } from './components/DirectusImg';
3
3
  export { default as DirectusVideo } from './components/DirectusVideo';
4
4
  export { default as DirectusFile } from './components/DirectusFile';
5
- export { default as useDirectusFile } from './hooks/directus-file';
6
- export { default as useDirectusLink } from './hooks/directus-link';
7
- export { default as getDirectusSearchParams } from './hooks/directus-search-params';
8
- export { default as useNavigationItems } from './hooks/navigation-items';
9
- export { default as useMetadata } from './hooks/directus-metadata';
5
+ export { getDirectusFile, useDirectusFile } from './utils/getDirectusFile';
6
+ export { getDirectusLink, useDirectusLink } from './utils/getDirectusLink';
7
+ export { getNavigationItems, useNavigationItems } from './utils/getNavigationItems';
8
+ export { getMetadata, useMetadata } from './utils/getDirectusMetadata';
9
+ export { getDirectusSearchParams } from './utils/getDirectusSearchParams';
10
10
  export { logger as DirectusNextComponent } from './logger';
11
+ export * from './types';
12
+ export type { TDirectusLinkProps, TDirectusLinkPropsConfig, TDirectusLinkComponentsConfig, } from './components/DirectusLink/interface';
13
+ export type { TDirectusFileProps } from './components/DirectusFile/interface';
14
+ export type { TDirectusImgProps } from './components/DirectusImg/interface';
15
+ export type { TDirectusVideoProps } from './components/DirectusVideo/interface';
11
16
  export type {
12
17
  /**
13
18
  * @deprecated Import from `@okam/directus-next` instead
@@ -17,7 +22,3 @@ export type {
17
22
  /**
18
23
  * @deprecated Import from `@okam/directus-next` instead
19
24
  */ TPageSettings, } from '../../directus-next/src/index.ts';
20
- export type { TNavigationItems, TNavigationItemsTree } from './types/navigation-items';
21
- export type { TLinks, SearchParams } from './types/links';
22
- export type { TDirectusLinkProps, TUseDirectusLink, TDirectusLink, TDirectusLinkPropsConfig, TDirectusLinkComponentsConfig, } from './components/DirectusLink/interface';
23
- export type { TMetadataOptions } from './types/metadata';
package/index.js CHANGED
@@ -4,19 +4,23 @@ const index = require("./components/DirectusLink/index.js");
4
4
  const index$1 = require("./components/DirectusImg/index.js");
5
5
  const index$2 = require("./components/DirectusVideo/index.js");
6
6
  const index$3 = require("./components/DirectusFile/index.js");
7
- const directusFile = require("./hooks/directus-file.js");
8
- const directusLink = require("./hooks/directus-link.js");
9
- const directusSearchParams = require("./hooks/directus-search-params.js");
10
- const navigationItems = require("./hooks/navigation-items.js");
11
- const directusMetadata = require("./hooks/directus-metadata.js");
7
+ const index$4 = require("./utils/getDirectusFile/index.js");
8
+ const index$5 = require("./utils/getDirectusLink/index.js");
9
+ const index$6 = require("./utils/getNavigationItems/index.js");
10
+ const index$7 = require("./utils/getDirectusMetadata/index.js");
11
+ const index$8 = require("./utils/getDirectusSearchParams/index.js");
12
12
  const logger = require("./logger.js");
13
13
  exports.DirectusLink = index;
14
14
  exports.DirectusImg = index$1;
15
15
  exports.DirectusVideo = index$2;
16
16
  exports.DirectusFile = index$3;
17
- exports.useDirectusFile = directusFile;
18
- exports.useDirectusLink = directusLink;
19
- exports.getDirectusSearchParams = directusSearchParams;
20
- exports.useNavigationItems = navigationItems;
21
- exports.useMetadata = directusMetadata;
17
+ exports.getDirectusFile = index$4.getDirectusFile;
18
+ exports.useDirectusFile = index$4.useDirectusFile;
19
+ exports.getDirectusLink = index$5.getDirectusLink;
20
+ exports.useDirectusLink = index$5.useDirectusLink;
21
+ exports.getNavigationItems = index$6.getNavigationItems;
22
+ exports.useNavigationItems = index$6.useNavigationItems;
23
+ exports.getMetadata = index$7.getMetadata;
24
+ exports.useMetadata = index$7.useMetadata;
25
+ exports.getDirectusSearchParams = index$8.getDirectusSearchParams;
22
26
  exports.DirectusNextComponent = logger.logger;
package/index.mjs CHANGED
@@ -2,11 +2,11 @@ import { default as default2 } from "./components/DirectusLink/index.mjs";
2
2
  import { default as default3 } from "./components/DirectusImg/index.mjs";
3
3
  import { default as default4 } from "./components/DirectusVideo/index.mjs";
4
4
  import { default as default5 } from "./components/DirectusFile/index.mjs";
5
- import { default as default6 } from "./hooks/directus-file.mjs";
6
- import { default as default7 } from "./hooks/directus-link.mjs";
7
- import { default as default8 } from "./hooks/directus-search-params.mjs";
8
- import { default as default9 } from "./hooks/navigation-items.mjs";
9
- import { default as default10 } from "./hooks/directus-metadata.mjs";
5
+ import { getDirectusFile, useDirectusFile } from "./utils/getDirectusFile/index.mjs";
6
+ import { getDirectusLink, useDirectusLink } from "./utils/getDirectusLink/index.mjs";
7
+ import { getNavigationItems, useNavigationItems } from "./utils/getNavigationItems/index.mjs";
8
+ import { getMetadata, useMetadata } from "./utils/getDirectusMetadata/index.mjs";
9
+ import { getDirectusSearchParams } from "./utils/getDirectusSearchParams/index.mjs";
10
10
  import { logger } from "./logger.mjs";
11
11
  export {
12
12
  default5 as DirectusFile,
@@ -14,9 +14,13 @@ export {
14
14
  default2 as DirectusLink,
15
15
  logger as DirectusNextComponent,
16
16
  default4 as DirectusVideo,
17
- default8 as getDirectusSearchParams,
18
- default6 as useDirectusFile,
19
- default7 as useDirectusLink,
20
- default10 as useMetadata,
21
- default9 as useNavigationItems
17
+ getDirectusFile,
18
+ getDirectusLink,
19
+ getDirectusSearchParams,
20
+ getMetadata,
21
+ getNavigationItems,
22
+ useDirectusFile,
23
+ useDirectusLink,
24
+ useMetadata,
25
+ useNavigationItems
22
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okam/directus-next-component",
3
- "version": "1.7.36",
3
+ "version": "1.7.38",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -33,13 +33,14 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@okam/logger": "1.1.0",
36
- "@okam/next-component": "1.2.3",
37
- "@okam/stack-ui": "1.43.0",
36
+ "@okam/next-component": "1.3.0",
37
+ "@okam/stack-ui": "1.44.0",
38
38
  "@react-spring/web": "^10.0.3",
39
39
  "next": "^15.0.0",
40
40
  "radashi": "^12.3.0",
41
41
  "unlazy": "^0.12.1",
42
- "@okam/directus-next": "1.2.10"
42
+ "@okam/directus-next": "1.2.12",
43
+ "zod": "^4.2.1"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "react": "^18.0.0 || ^19.0.0"
package/server.d.ts CHANGED
@@ -4,7 +4,7 @@ export { default as DirectusImg } from './components/DirectusImg';
4
4
  export { default as DirectusLink } from './components/DirectusLink';
5
5
  export { default as DirectusVideo } from './components/DirectusVideo';
6
6
  export { logger as DirectusNextComponent } from './logger';
7
- export { default as useDirectusFile } from './hooks/directus-file';
8
- export { default as useDirectusLink } from './hooks/directus-link';
9
- export { default as useNavigationItems } from './hooks/navigation-items';
10
- export { default as useMetadata } from './hooks/directus-metadata';
7
+ export { getDirectusFile, useDirectusFile } from './utils/getDirectusFile';
8
+ export { getDirectusLink, useDirectusLink } from './utils/getDirectusLink';
9
+ export { getNavigationItems, useNavigationItems } from './utils/getNavigationItems';
10
+ export { getMetadata, useMetadata } from './utils/getDirectusMetadata';
package/server.js CHANGED
@@ -6,17 +6,21 @@ const index$1 = require("./components/DirectusImg/index.js");
6
6
  const index$2 = require("./components/DirectusLink/index.js");
7
7
  const index$3 = require("./components/DirectusVideo/index.js");
8
8
  const logger = require("./logger.js");
9
- const directusFile = require("./hooks/directus-file.js");
10
- const directusLink = require("./hooks/directus-link.js");
11
- const navigationItems = require("./hooks/navigation-items.js");
12
- const directusMetadata = require("./hooks/directus-metadata.js");
9
+ const index$4 = require("./utils/getDirectusFile/index.js");
10
+ const index$5 = require("./utils/getDirectusLink/index.js");
11
+ const index$6 = require("./utils/getNavigationItems/index.js");
12
+ const index$7 = require("./utils/getDirectusMetadata/index.js");
13
13
  exports.withDirectus = withDirectus;
14
14
  exports.DirectusFile = index;
15
15
  exports.DirectusImg = index$1;
16
16
  exports.DirectusLink = index$2;
17
17
  exports.DirectusVideo = index$3;
18
18
  exports.DirectusNextComponent = logger.logger;
19
- exports.useDirectusFile = directusFile;
20
- exports.useDirectusLink = directusLink;
21
- exports.useNavigationItems = navigationItems;
22
- exports.useMetadata = directusMetadata;
19
+ exports.getDirectusFile = index$4.getDirectusFile;
20
+ exports.useDirectusFile = index$4.useDirectusFile;
21
+ exports.getDirectusLink = index$5.getDirectusLink;
22
+ exports.useDirectusLink = index$5.useDirectusLink;
23
+ exports.getNavigationItems = index$6.getNavigationItems;
24
+ exports.useNavigationItems = index$6.useNavigationItems;
25
+ exports.getMetadata = index$7.getMetadata;
26
+ exports.useMetadata = index$7.useMetadata;
package/server.mjs CHANGED
@@ -4,19 +4,23 @@ import { default as default4 } from "./components/DirectusImg/index.mjs";
4
4
  import { default as default5 } from "./components/DirectusLink/index.mjs";
5
5
  import { default as default6 } from "./components/DirectusVideo/index.mjs";
6
6
  import { logger } from "./logger.mjs";
7
- import { default as default7 } from "./hooks/directus-file.mjs";
8
- import { default as default8 } from "./hooks/directus-link.mjs";
9
- import { default as default9 } from "./hooks/navigation-items.mjs";
10
- import { default as default10 } from "./hooks/directus-metadata.mjs";
7
+ import { getDirectusFile, useDirectusFile } from "./utils/getDirectusFile/index.mjs";
8
+ import { getDirectusLink, useDirectusLink } from "./utils/getDirectusLink/index.mjs";
9
+ import { getNavigationItems, useNavigationItems } from "./utils/getNavigationItems/index.mjs";
10
+ import { getMetadata, useMetadata } from "./utils/getDirectusMetadata/index.mjs";
11
11
  export {
12
12
  default3 as DirectusFile,
13
13
  default4 as DirectusImg,
14
14
  default5 as DirectusLink,
15
15
  logger as DirectusNextComponent,
16
16
  default6 as DirectusVideo,
17
- default7 as useDirectusFile,
18
- default8 as useDirectusLink,
19
- default10 as useMetadata,
20
- default9 as useNavigationItems,
17
+ getDirectusFile,
18
+ getDirectusLink,
19
+ getMetadata,
20
+ getNavigationItems,
21
+ useDirectusFile,
22
+ useDirectusLink,
23
+ useMetadata,
24
+ useNavigationItems,
21
25
  default2 as withDirectus
22
26
  };
@@ -0,0 +1,3 @@
1
+ export * from './links';
2
+ export * from './metadata';
3
+ export * from './navigationItems';
package/types/links.d.ts CHANGED
@@ -16,9 +16,9 @@ export interface TLinks {
16
16
  type?: Nullable<string>;
17
17
  collection?: Nullable<TPageSettings>;
18
18
  file?: Nullable<TFiles>;
19
- params?: Nullable<Nullable<SearchParams>[]>;
19
+ params?: Nullable<Nullable<TSearchParams>[]>;
20
20
  }
21
- export interface SearchParams {
21
+ export interface TSearchParams {
22
22
  id?: string;
23
23
  name?: Nullable<string>;
24
24
  value?: Nullable<string>;
@@ -21,11 +21,11 @@ export type TNavigationItemsBase<Link> = {
21
21
  tokens?: any | null;
22
22
  variant?: string | null;
23
23
  } & Link;
24
- export type TNavigationItemsParents<NavigationItems, Link, Depth extends number> = Depth extends never ? TNavigationItemsBase<Link> : {
25
- parent?: Nullable<TNavigationItemsParents<NavigationItems, Link, Depth>>;
24
+ export type TNavigationItemsParents<TNavigationItems, Link, Depth extends number> = Depth extends never ? TNavigationItemsBase<Link> : {
25
+ parent?: Nullable<TNavigationItemsParents<TNavigationItems, Link, Depth>>;
26
26
  } & TNavigationItemsBase<Link>;
27
- export type TNavigationItemsChildren<NavigationItems, Link, Depth extends number> = Depth extends never ? TNavigationItemsBase<Link> : {
28
- children?: Nullable<Nullable<TNavigationItemsChildren<NavigationItems, Link, DepthLimit[Depth]>>[]>;
27
+ export type TNavigationItemsChildren<TNavigationItems, Link, Depth extends number> = Depth extends never ? TNavigationItemsBase<Link> : {
28
+ children?: Nullable<Nullable<TNavigationItemsChildren<TNavigationItems, Link, DepthLimit[Depth]>>[]>;
29
29
  } & TNavigationItemsBase<Link>;
30
- export type TNavigationItems<NavigationItems, Link, Depth extends number> = TNavigationItemsChildren<NavigationItems, Link, Depth> & TNavigationItemsParents<NavigationItems, Link, Depth>;
30
+ export type TNavigationItems<Items, Link, Depth extends number> = TNavigationItemsChildren<Items, Link, Depth> & TNavigationItemsParents<Items, Link, Depth>;
31
31
  export {};
@@ -1,7 +1,8 @@
1
- import { TFiles } from '../../../directus-next/src/index.ts';
2
- import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
1
+ import { TFiles } from '../../../../directus-next/src/index.ts';
2
+ import { Nullable } from '../../../../../stack/stack-ui/src/index.ts';
3
3
 
4
- export default function useDirectusFile(file: Nullable<TFiles>, baseUrl?: URL, searchParams?: Record<string, Nullable<string>>): {
4
+ export declare function getDirectusUrl(file: Nullable<TFiles>, baseUrl?: URL, searchParams?: Record<string, Nullable<string>>): URL | null;
5
+ export declare function getDirectusFile(file: Nullable<TFiles>, baseUrl?: URL, searchParams?: Record<string, Nullable<string>>): {
5
6
  tags?: any | null;
6
7
  location?: string | null;
7
8
  storage?: string | null;
@@ -23,3 +24,7 @@ export default function useDirectusFile(file: Nullable<TFiles>, baseUrl?: URL, s
23
24
  title: string | undefined;
24
25
  id: string;
25
26
  } | null;
27
+ /**
28
+ * @deprecated Use `getDirectusFile` instead
29
+ */
30
+ export declare const useDirectusFile: typeof getDirectusFile;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- const logger = require("../logger.js");
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const logger = require("../../logger.js");
3
4
  const IMG_DOMAIN = process.env.NEXT_PUBLIC_IMG_DOMAIN;
4
5
  const IMG_PORT = process.env.NEXT_PUBLIC_IMG_PORT;
5
6
  const IMG_PROTOCOL = process.env.NEXT_PUBLIC_IMG_PROTOCOL ?? "https";
@@ -23,7 +24,7 @@ function getDirectusUrl(file, baseUrl, searchParams) {
23
24
  return null;
24
25
  }
25
26
  }
26
- function useDirectusFile(file, baseUrl, searchParams) {
27
+ function getDirectusFile(file, baseUrl, searchParams) {
27
28
  const { description, width, height, title, id, ...rest } = file ?? {};
28
29
  if (!file || !id) return null;
29
30
  const url = getDirectusUrl(file, baseUrl, searchParams);
@@ -38,4 +39,7 @@ function useDirectusFile(file, baseUrl, searchParams) {
38
39
  ...rest
39
40
  };
40
41
  }
41
- module.exports = useDirectusFile;
42
+ const useDirectusFile = getDirectusFile;
43
+ exports.getDirectusFile = getDirectusFile;
44
+ exports.getDirectusUrl = getDirectusUrl;
45
+ exports.useDirectusFile = useDirectusFile;
@@ -1,4 +1,4 @@
1
- import { logger } from "../logger.mjs";
1
+ import { logger } from "../../logger.mjs";
2
2
  const IMG_DOMAIN = process.env.NEXT_PUBLIC_IMG_DOMAIN;
3
3
  const IMG_PORT = process.env.NEXT_PUBLIC_IMG_PORT;
4
4
  const IMG_PROTOCOL = process.env.NEXT_PUBLIC_IMG_PROTOCOL ?? "https";
@@ -22,7 +22,7 @@ function getDirectusUrl(file, baseUrl, searchParams) {
22
22
  return null;
23
23
  }
24
24
  }
25
- function useDirectusFile(file, baseUrl, searchParams) {
25
+ function getDirectusFile(file, baseUrl, searchParams) {
26
26
  const { description, width, height, title, id, ...rest } = file ?? {};
27
27
  if (!file || !id) return null;
28
28
  const url = getDirectusUrl(file, baseUrl, searchParams);
@@ -37,6 +37,9 @@ function useDirectusFile(file, baseUrl, searchParams) {
37
37
  ...rest
38
38
  };
39
39
  }
40
+ const useDirectusFile = getDirectusFile;
40
41
  export {
41
- useDirectusFile as default
42
+ getDirectusFile,
43
+ getDirectusUrl,
44
+ useDirectusFile
42
45
  };
@@ -0,0 +1,8 @@
1
+ import { TAnchorProps } from '../../../../../stack/stack-ui/src/index.ts';
2
+ import { TGetDirectusLink } from '../../components/DirectusLink/interface';
3
+
4
+ export declare function getDirectusLink(props: TGetDirectusLink): TAnchorProps;
5
+ /**
6
+ * @deprecated Use `getDirectusLink` instead
7
+ */
8
+ export declare const useDirectusLink: typeof getDirectusLink;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Link = require("next/link.js");
4
+ const zod = require("zod");
5
+ const index = require("../getDirectusFile/index.js");
6
+ const index$1 = require("../getDirectusSearchParams/index.js");
7
+ const absoluteUrlSchema = zod.z.url({ protocol: /^(https?|mailto|tel)$/ });
8
+ const relativeUrlSchema = zod.z.string().regex(/^[/#?]/, {
9
+ error: (error) => `Invalid href ${error.input}. Must be a valid absolute URL or start with /, # or ?`
10
+ });
11
+ const hrefSchema = zod.z.union([absoluteUrlSchema, relativeUrlSchema]).transform((value) => {
12
+ try {
13
+ return new URL(value);
14
+ } catch (error) {
15
+ return new URL(value, "http://localhost");
16
+ }
17
+ });
18
+ function withSearchParams(url, searchParams) {
19
+ searchParams.forEach((value, name) => {
20
+ url.searchParams.append(name, value);
21
+ });
22
+ return url;
23
+ }
24
+ function getCompleteHref(href, params, type) {
25
+ if (!href) return null;
26
+ const searchParams = index$1.getDirectusSearchParams(params);
27
+ const url = hrefSchema.parse(href);
28
+ const completeUrl = withSearchParams(url, searchParams);
29
+ if (type === "relative") {
30
+ const { origin } = completeUrl;
31
+ if (href.startsWith("#")) {
32
+ return completeUrl.href.replace(origin, "").substring(1);
33
+ }
34
+ return completeUrl.href.replace(origin, "");
35
+ }
36
+ return completeUrl.href;
37
+ }
38
+ function getFile(props) {
39
+ const { file, params } = props;
40
+ const { filename_download: filenameDownload } = file ?? {};
41
+ const { src } = index.getDirectusFile(file) ?? {};
42
+ const href = getCompleteHref(src, params, "absolute");
43
+ return {
44
+ href: href ?? void 0,
45
+ download: filenameDownload ?? true
46
+ };
47
+ }
48
+ function getCollection(props) {
49
+ var _a, _b;
50
+ const { collection, target, params } = props;
51
+ const href = getCompleteHref((_b = (_a = collection == null ? void 0 : collection.translations) == null ? void 0 : _a[0]) == null ? void 0 : _b.path, params, "relative");
52
+ return {
53
+ href: href ?? void 0,
54
+ target: target ?? void 0
55
+ };
56
+ }
57
+ function getExternalLink(props) {
58
+ const { external_link: externalLink, target, params } = props;
59
+ const href = getCompleteHref(externalLink, params, "absolute");
60
+ return {
61
+ href: href ?? void 0,
62
+ target: target ?? void 0
63
+ };
64
+ }
65
+ function getAnchor(props) {
66
+ const { anchor, params } = props;
67
+ const href = getCompleteHref(anchor, params, "relative");
68
+ return { href: href ?? void 0 };
69
+ }
70
+ const defaultPropsConfig = {
71
+ collection: getCollection,
72
+ // eslint-disable-next-line @typescript-eslint/naming-convention
73
+ "external-link": getExternalLink,
74
+ file: getFile,
75
+ anchor: getAnchor
76
+ };
77
+ function getDirectusLink(props) {
78
+ var _a;
79
+ const {
80
+ type,
81
+ label,
82
+ prefetch,
83
+ replace,
84
+ scroll,
85
+ tokens,
86
+ themeName,
87
+ customTheme,
88
+ propsConfig,
89
+ as = Link,
90
+ target,
91
+ anchor,
92
+ collection,
93
+ external_link: externalLink,
94
+ file,
95
+ id,
96
+ params,
97
+ ...rest
98
+ } = props;
99
+ if (!type) return {};
100
+ const finalConfig = { ...defaultPropsConfig, ...propsConfig ?? {} };
101
+ const linkProps = ((_a = finalConfig[type]) == null ? void 0 : _a.call(finalConfig, props)) ?? {};
102
+ const { href, ...restOfLinkProps } = linkProps;
103
+ if (!href) return {};
104
+ return {
105
+ ...rest,
106
+ as,
107
+ ...themeName ? { themeName } : {},
108
+ ...customTheme ? { customTheme } : {},
109
+ ...tokens ? { tokens } : {},
110
+ nextLinkProps: {
111
+ href,
112
+ prefetch: prefetch ?? void 0,
113
+ scroll: scroll ?? void 0,
114
+ replace: replace ?? void 0
115
+ },
116
+ href,
117
+ children: label,
118
+ ...restOfLinkProps
119
+ };
120
+ }
121
+ const useDirectusLink = getDirectusLink;
122
+ exports.getDirectusLink = getDirectusLink;
123
+ exports.useDirectusLink = useDirectusLink;
@@ -0,0 +1,123 @@
1
+ import Link from "next/link.js";
2
+ import { z } from "zod";
3
+ import { getDirectusFile } from "../getDirectusFile/index.mjs";
4
+ import { getDirectusSearchParams } from "../getDirectusSearchParams/index.mjs";
5
+ const absoluteUrlSchema = z.url({ protocol: /^(https?|mailto|tel)$/ });
6
+ const relativeUrlSchema = z.string().regex(/^[/#?]/, {
7
+ error: (error) => `Invalid href ${error.input}. Must be a valid absolute URL or start with /, # or ?`
8
+ });
9
+ const hrefSchema = z.union([absoluteUrlSchema, relativeUrlSchema]).transform((value) => {
10
+ try {
11
+ return new URL(value);
12
+ } catch (error) {
13
+ return new URL(value, "http://localhost");
14
+ }
15
+ });
16
+ function withSearchParams(url, searchParams) {
17
+ searchParams.forEach((value, name) => {
18
+ url.searchParams.append(name, value);
19
+ });
20
+ return url;
21
+ }
22
+ function getCompleteHref(href, params, type) {
23
+ if (!href) return null;
24
+ const searchParams = getDirectusSearchParams(params);
25
+ const url = hrefSchema.parse(href);
26
+ const completeUrl = withSearchParams(url, searchParams);
27
+ if (type === "relative") {
28
+ const { origin } = completeUrl;
29
+ if (href.startsWith("#")) {
30
+ return completeUrl.href.replace(origin, "").substring(1);
31
+ }
32
+ return completeUrl.href.replace(origin, "");
33
+ }
34
+ return completeUrl.href;
35
+ }
36
+ function getFile(props) {
37
+ const { file, params } = props;
38
+ const { filename_download: filenameDownload } = file ?? {};
39
+ const { src } = getDirectusFile(file) ?? {};
40
+ const href = getCompleteHref(src, params, "absolute");
41
+ return {
42
+ href: href ?? void 0,
43
+ download: filenameDownload ?? true
44
+ };
45
+ }
46
+ function getCollection(props) {
47
+ var _a, _b;
48
+ const { collection, target, params } = props;
49
+ const href = getCompleteHref((_b = (_a = collection == null ? void 0 : collection.translations) == null ? void 0 : _a[0]) == null ? void 0 : _b.path, params, "relative");
50
+ return {
51
+ href: href ?? void 0,
52
+ target: target ?? void 0
53
+ };
54
+ }
55
+ function getExternalLink(props) {
56
+ const { external_link: externalLink, target, params } = props;
57
+ const href = getCompleteHref(externalLink, params, "absolute");
58
+ return {
59
+ href: href ?? void 0,
60
+ target: target ?? void 0
61
+ };
62
+ }
63
+ function getAnchor(props) {
64
+ const { anchor, params } = props;
65
+ const href = getCompleteHref(anchor, params, "relative");
66
+ return { href: href ?? void 0 };
67
+ }
68
+ const defaultPropsConfig = {
69
+ collection: getCollection,
70
+ // eslint-disable-next-line @typescript-eslint/naming-convention
71
+ "external-link": getExternalLink,
72
+ file: getFile,
73
+ anchor: getAnchor
74
+ };
75
+ function getDirectusLink(props) {
76
+ var _a;
77
+ const {
78
+ type,
79
+ label,
80
+ prefetch,
81
+ replace,
82
+ scroll,
83
+ tokens,
84
+ themeName,
85
+ customTheme,
86
+ propsConfig,
87
+ as = Link,
88
+ target,
89
+ anchor,
90
+ collection,
91
+ external_link: externalLink,
92
+ file,
93
+ id,
94
+ params,
95
+ ...rest
96
+ } = props;
97
+ if (!type) return {};
98
+ const finalConfig = { ...defaultPropsConfig, ...propsConfig ?? {} };
99
+ const linkProps = ((_a = finalConfig[type]) == null ? void 0 : _a.call(finalConfig, props)) ?? {};
100
+ const { href, ...restOfLinkProps } = linkProps;
101
+ if (!href) return {};
102
+ return {
103
+ ...rest,
104
+ as,
105
+ ...themeName ? { themeName } : {},
106
+ ...customTheme ? { customTheme } : {},
107
+ ...tokens ? { tokens } : {},
108
+ nextLinkProps: {
109
+ href,
110
+ prefetch: prefetch ?? void 0,
111
+ scroll: scroll ?? void 0,
112
+ replace: replace ?? void 0
113
+ },
114
+ href,
115
+ children: label,
116
+ ...restOfLinkProps
117
+ };
118
+ }
119
+ const useDirectusLink = getDirectusLink;
120
+ export {
121
+ getDirectusLink,
122
+ useDirectusLink
123
+ };
@@ -0,0 +1,15 @@
1
+ import { TPageSettings, TPageSettingsTranslation } from '../../../../directus-next/src/index.ts';
2
+ import { Nullable } from '../../../../../stack/stack-ui/src/index.ts';
3
+ import { Metadata } from 'next';
4
+ import { OpenGraph } from 'next/dist/lib/metadata/types/opengraph-types';
5
+ import { TDirectusFileProps } from '../../components/DirectusFile/interface';
6
+ import { TMetadataOptions } from '../../types/metadata';
7
+
8
+ export declare function getOpenGraphImage(image: Nullable<TDirectusFileProps>, options: TMetadataOptions): Nullable<Exclude<OpenGraph['images'], OpenGraph['images'][]>>;
9
+ export declare function getMetadata<TPageProps extends {
10
+ pageSettings: TPageSettings;
11
+ }>(pageProps: TPageProps, options: TMetadataOptions, defaultProps?: Partial<TPageSettingsTranslation>): Metadata;
12
+ /**
13
+ * @deprecated Use `getMetadata` instead
14
+ */
15
+ export declare const useMetadata: typeof getMetadata;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- require("react/jsx-runtime");
3
- require("@okam/next-component");
4
- const directusFile = require("./directus-file.js");
5
- require("@okam/stack-ui");
6
- require("next/link.js");
7
- require("../logger.js");
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
3
  const radashi = require("radashi");
4
+ const index = require("../getDirectusFile/index.js");
9
5
  function withFallbacks(pageProps, options) {
10
6
  var _a, _b;
11
7
  const { pageSettings } = pageProps ?? {};
@@ -28,8 +24,8 @@ function getOpenGraphImageFallback(fallbackImage, options) {
28
24
  const dimensions = limitOpenGraphImageDimensions(width, height, options == null ? void 0 : options.ogImageMaxWidth, options == null ? void 0 : options.ogImageMaxHeight);
29
25
  return { ...fallbackImage, ...dimensions, url: src };
30
26
  }
31
- function useOpenGraphImage(image, options) {
32
- const directusImage = directusFile(image);
27
+ function getOpenGraphImage(image, options) {
28
+ const directusImage = index.getDirectusFile(image);
33
29
  const { src, alt } = directusImage ?? {};
34
30
  const { width: limitedWidth, height: limitedHeight } = ((directusImage == null ? void 0 : directusImage.width) && (directusImage == null ? void 0 : directusImage.height) ? limitOpenGraphImageDimensions(
35
31
  directusImage.width,
@@ -52,7 +48,7 @@ function useOpenGraphImage(image, options) {
52
48
  url: imgHref
53
49
  };
54
50
  }
55
- function useMetadata(pageProps, options, defaultProps) {
51
+ function getMetadata(pageProps, options, defaultProps) {
56
52
  var _a;
57
53
  const { title, image } = withFallbacks(pageProps, options);
58
54
  const { pageSettings } = pageProps ?? {};
@@ -60,8 +56,8 @@ function useMetadata(pageProps, options, defaultProps) {
60
56
  const metaDescription = (defaultProps == null ? void 0 : defaultProps.meta_description) ?? (translation == null ? void 0 : translation.meta_description);
61
57
  const noFollow = (defaultProps == null ? void 0 : defaultProps.no_follow) ?? (translation == null ? void 0 : translation.no_follow);
62
58
  const noIndex = (defaultProps == null ? void 0 : defaultProps.no_index) ?? (translation == null ? void 0 : translation.no_index);
63
- const directusImage = directusFile(image);
64
- const openGraphImage = useOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
59
+ const directusImage = index.getDirectusFile(image);
60
+ const openGraphImage = getOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
65
61
  const openGraphType = options.openGraphTypeConfig[(pageSettings == null ? void 0 : pageSettings.belongs_to_collection) ?? ""] ?? "website";
66
62
  const alternates = options.createAlternateUrls(pageSettings);
67
63
  const { canonical } = alternates;
@@ -89,4 +85,7 @@ function useMetadata(pageProps, options, defaultProps) {
89
85
  };
90
86
  return metadata;
91
87
  }
92
- module.exports = useMetadata;
88
+ const useMetadata = getMetadata;
89
+ exports.getMetadata = getMetadata;
90
+ exports.getOpenGraphImage = getOpenGraphImage;
91
+ exports.useMetadata = useMetadata;
@@ -1,10 +1,5 @@
1
- import "react/jsx-runtime";
2
- import "@okam/next-component";
3
- import useDirectusFile from "./directus-file.mjs";
4
- import "@okam/stack-ui";
5
- import "next/link.js";
6
- import "../logger.mjs";
7
1
  import { min } from "radashi";
2
+ import { getDirectusFile } from "../getDirectusFile/index.mjs";
8
3
  function withFallbacks(pageProps, options) {
9
4
  var _a, _b;
10
5
  const { pageSettings } = pageProps ?? {};
@@ -27,8 +22,8 @@ function getOpenGraphImageFallback(fallbackImage, options) {
27
22
  const dimensions = limitOpenGraphImageDimensions(width, height, options == null ? void 0 : options.ogImageMaxWidth, options == null ? void 0 : options.ogImageMaxHeight);
28
23
  return { ...fallbackImage, ...dimensions, url: src };
29
24
  }
30
- function useOpenGraphImage(image, options) {
31
- const directusImage = useDirectusFile(image);
25
+ function getOpenGraphImage(image, options) {
26
+ const directusImage = getDirectusFile(image);
32
27
  const { src, alt } = directusImage ?? {};
33
28
  const { width: limitedWidth, height: limitedHeight } = ((directusImage == null ? void 0 : directusImage.width) && (directusImage == null ? void 0 : directusImage.height) ? limitOpenGraphImageDimensions(
34
29
  directusImage.width,
@@ -51,7 +46,7 @@ function useOpenGraphImage(image, options) {
51
46
  url: imgHref
52
47
  };
53
48
  }
54
- function useMetadata(pageProps, options, defaultProps) {
49
+ function getMetadata(pageProps, options, defaultProps) {
55
50
  var _a;
56
51
  const { title, image } = withFallbacks(pageProps, options);
57
52
  const { pageSettings } = pageProps ?? {};
@@ -59,8 +54,8 @@ function useMetadata(pageProps, options, defaultProps) {
59
54
  const metaDescription = (defaultProps == null ? void 0 : defaultProps.meta_description) ?? (translation == null ? void 0 : translation.meta_description);
60
55
  const noFollow = (defaultProps == null ? void 0 : defaultProps.no_follow) ?? (translation == null ? void 0 : translation.no_follow);
61
56
  const noIndex = (defaultProps == null ? void 0 : defaultProps.no_index) ?? (translation == null ? void 0 : translation.no_index);
62
- const directusImage = useDirectusFile(image);
63
- const openGraphImage = useOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
57
+ const directusImage = getDirectusFile(image);
58
+ const openGraphImage = getOpenGraphImage(directusImage, options) ?? getOpenGraphImageFallback(options == null ? void 0 : options.ogFallbackImage, options);
64
59
  const openGraphType = options.openGraphTypeConfig[(pageSettings == null ? void 0 : pageSettings.belongs_to_collection) ?? ""] ?? "website";
65
60
  const alternates = options.createAlternateUrls(pageSettings);
66
61
  const { canonical } = alternates;
@@ -88,6 +83,9 @@ function useMetadata(pageProps, options, defaultProps) {
88
83
  };
89
84
  return metadata;
90
85
  }
86
+ const useMetadata = getMetadata;
91
87
  export {
92
- useMetadata as default
88
+ getMetadata,
89
+ getOpenGraphImage,
90
+ useMetadata
93
91
  };
@@ -0,0 +1,8 @@
1
+ import { Nullable } from '../../../../../stack/stack-ui/src/index.ts';
2
+ import { TSearchParams } from '../../types/links';
3
+
4
+ export declare function getDirectusSearchParams(params: Nullable<Nullable<TSearchParams>[]>): URLSearchParams;
5
+ /**
6
+ * @deprecated Use `getDirectusSearchParams` instead
7
+ */
8
+ export declare const useDirectusSearchParams: typeof getDirectusSearchParams;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
3
  const radashi = require("radashi");
3
4
  function getDirectusSearchParams(params) {
4
5
  const searchParams = new URLSearchParams();
@@ -11,4 +12,4 @@ function getDirectusSearchParams(params) {
11
12
  });
12
13
  return searchParams;
13
14
  }
14
- module.exports = getDirectusSearchParams;
15
+ exports.getDirectusSearchParams = getDirectusSearchParams;
@@ -11,5 +11,5 @@ function getDirectusSearchParams(params) {
11
11
  return searchParams;
12
12
  }
13
13
  export {
14
- getDirectusSearchParams as default
14
+ getDirectusSearchParams
15
15
  };
@@ -0,0 +1,15 @@
1
+ import { Nullable } from '../../../../../stack/stack-ui/src/index.ts';
2
+ import { TDirectusLinkProps } from '../../components/DirectusLink/interface';
3
+ import { TNavigationItems, TNavigationItemsTree } from '../../types/navigationItems';
4
+
5
+ /**
6
+ *
7
+ * @param navigationItems A tree of navigation items, with parents and children
8
+ * @param onNavigationItem Called when a navigation item is about to be added to the tree
9
+ * @returns A tree of navigation items with ready-to-use DirectusLink components
10
+ */
11
+ export declare function getNavigationItems<Depth extends number, Link, Items extends TNavigationItems<Items, Link, Depth> = TNavigationItems<unknown, Link, Depth>>(items: Nullable<Nullable<TNavigationItems<Items, Link, Depth>>[]>, onNavigationItem: (item: Nullable<TNavigationItems<Items, Link, Depth>>) => Nullable<TDirectusLinkProps>): Nullable<Nullable<TNavigationItemsTree>[]>;
12
+ /**
13
+ * @deprecated Use `getNavigationItems` instead
14
+ */
15
+ export declare const useNavigationItems: typeof getNavigationItems;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
3
  const jsxRuntime = require("react/jsx-runtime");
3
- const index = require("../components/DirectusLink/index.js");
4
+ const index = require("../../components/DirectusLink/index.js");
4
5
  function createLinkProps(item, onNavigationItem) {
5
6
  const { tokens, variant } = item ?? {};
6
7
  const link = onNavigationItem(item);
@@ -39,7 +40,7 @@ function createChildrenTree(item, onNavigationItem, depth = 1) {
39
40
  depth
40
41
  };
41
42
  }
42
- function useNavigationItems(items, onNavigationItem) {
43
+ function getNavigationItems(items, onNavigationItem) {
43
44
  const tree = items == null ? void 0 : items.map((item) => {
44
45
  const { children, parent } = item ?? {};
45
46
  const linkProps = createLinkProps(item, onNavigationItem);
@@ -55,4 +56,6 @@ function useNavigationItems(items, onNavigationItem) {
55
56
  });
56
57
  return tree;
57
58
  }
58
- module.exports = useNavigationItems;
59
+ const useNavigationItems = getNavigationItems;
60
+ exports.getNavigationItems = getNavigationItems;
61
+ exports.useNavigationItems = useNavigationItems;
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import DirectusLink from "../components/DirectusLink/index.mjs";
2
+ import DirectusLink from "../../components/DirectusLink/index.mjs";
3
3
  function createLinkProps(item, onNavigationItem) {
4
4
  const { tokens, variant } = item ?? {};
5
5
  const link = onNavigationItem(item);
@@ -38,7 +38,7 @@ function createChildrenTree(item, onNavigationItem, depth = 1) {
38
38
  depth
39
39
  };
40
40
  }
41
- function useNavigationItems(items, onNavigationItem) {
41
+ function getNavigationItems(items, onNavigationItem) {
42
42
  const tree = items == null ? void 0 : items.map((item) => {
43
43
  const { children, parent } = item ?? {};
44
44
  const linkProps = createLinkProps(item, onNavigationItem);
@@ -54,6 +54,8 @@ function useNavigationItems(items, onNavigationItem) {
54
54
  });
55
55
  return tree;
56
56
  }
57
+ const useNavigationItems = getNavigationItems;
57
58
  export {
58
- useNavigationItems as default
59
+ getNavigationItems,
60
+ useNavigationItems
59
61
  };
@@ -1,4 +0,0 @@
1
- import { TAnchorProps } from '../../../../stack/stack-ui/src/index.ts';
2
- import { TUseDirectusLink } from '../components/DirectusLink/interface';
3
-
4
- export default function useDirectusLink(props: TUseDirectusLink): TAnchorProps;
@@ -1,94 +0,0 @@
1
- "use strict";
2
- const Link = require("next/link.js");
3
- const logger = require("../logger.js");
4
- const directusFile = require("./directus-file.js");
5
- const directusSearchParams = require("./directus-search-params.js");
6
- function useFile(props) {
7
- const { file } = props;
8
- const { filename_download: filenameDownload } = file ?? {};
9
- const { src } = directusFile(file) ?? {};
10
- return {
11
- href: src,
12
- download: filenameDownload ?? true
13
- };
14
- }
15
- function useCollection(props) {
16
- var _a, _b;
17
- const { collection, target } = props;
18
- return {
19
- href: ((_b = (_a = collection == null ? void 0 : collection.translations) == null ? void 0 : _a[0]) == null ? void 0 : _b.path) ?? void 0,
20
- target: target ?? void 0
21
- };
22
- }
23
- function useExternalLink(props) {
24
- const { external_link: externalLink, target } = props;
25
- return {
26
- href: externalLink ?? void 0,
27
- target: target ?? void 0
28
- };
29
- }
30
- function useAnchor(props) {
31
- const { anchor } = props;
32
- return { href: anchor ?? void 0 };
33
- }
34
- const defaultPropsConfig = {
35
- collection: useCollection,
36
- // eslint-disable-next-line @typescript-eslint/naming-convention
37
- "external-link": useExternalLink,
38
- file: useFile,
39
- anchor: useAnchor
40
- };
41
- function useDirectusLink(props) {
42
- var _a;
43
- const {
44
- type,
45
- label,
46
- prefetch,
47
- replace,
48
- scroll,
49
- tokens,
50
- themeName,
51
- customTheme,
52
- propsConfig,
53
- as = Link,
54
- target,
55
- anchor,
56
- collection,
57
- external_link: externalLink,
58
- file,
59
- id,
60
- params,
61
- ...rest
62
- } = props;
63
- const searchParams = directusSearchParams(params);
64
- if (!type) return {};
65
- const finalConfig = { ...defaultPropsConfig, ...propsConfig ?? {} };
66
- const linkProps = ((_a = finalConfig[type]) == null ? void 0 : _a.call(finalConfig, props)) ?? {};
67
- const { href, ...restOfLinkProps } = linkProps;
68
- if (!href) return {};
69
- if (!URL.canParse(href)) {
70
- logger.logger.log("Invalid href", "error", { href });
71
- return {};
72
- }
73
- const hrefUrl = new URL(href);
74
- searchParams.forEach((value, name) => {
75
- hrefUrl.searchParams.append(name, value);
76
- });
77
- return {
78
- ...rest,
79
- as,
80
- ...themeName ? { themeName } : {},
81
- ...customTheme ? { customTheme } : {},
82
- ...tokens ? { tokens } : {},
83
- nextLinkProps: {
84
- href: hrefUrl.toString(),
85
- prefetch: prefetch ?? void 0,
86
- scroll: scroll ?? void 0,
87
- replace: replace ?? void 0
88
- },
89
- href: hrefUrl.toString(),
90
- children: label,
91
- ...restOfLinkProps
92
- };
93
- }
94
- module.exports = useDirectusLink;
@@ -1,95 +0,0 @@
1
- import Link from "next/link.js";
2
- import { logger } from "../logger.mjs";
3
- import useDirectusFile from "./directus-file.mjs";
4
- import getDirectusSearchParams from "./directus-search-params.mjs";
5
- function useFile(props) {
6
- const { file } = props;
7
- const { filename_download: filenameDownload } = file ?? {};
8
- const { src } = useDirectusFile(file) ?? {};
9
- return {
10
- href: src,
11
- download: filenameDownload ?? true
12
- };
13
- }
14
- function useCollection(props) {
15
- var _a, _b;
16
- const { collection, target } = props;
17
- return {
18
- href: ((_b = (_a = collection == null ? void 0 : collection.translations) == null ? void 0 : _a[0]) == null ? void 0 : _b.path) ?? void 0,
19
- target: target ?? void 0
20
- };
21
- }
22
- function useExternalLink(props) {
23
- const { external_link: externalLink, target } = props;
24
- return {
25
- href: externalLink ?? void 0,
26
- target: target ?? void 0
27
- };
28
- }
29
- function useAnchor(props) {
30
- const { anchor } = props;
31
- return { href: anchor ?? void 0 };
32
- }
33
- const defaultPropsConfig = {
34
- collection: useCollection,
35
- // eslint-disable-next-line @typescript-eslint/naming-convention
36
- "external-link": useExternalLink,
37
- file: useFile,
38
- anchor: useAnchor
39
- };
40
- function useDirectusLink(props) {
41
- var _a;
42
- const {
43
- type,
44
- label,
45
- prefetch,
46
- replace,
47
- scroll,
48
- tokens,
49
- themeName,
50
- customTheme,
51
- propsConfig,
52
- as = Link,
53
- target,
54
- anchor,
55
- collection,
56
- external_link: externalLink,
57
- file,
58
- id,
59
- params,
60
- ...rest
61
- } = props;
62
- const searchParams = getDirectusSearchParams(params);
63
- if (!type) return {};
64
- const finalConfig = { ...defaultPropsConfig, ...propsConfig ?? {} };
65
- const linkProps = ((_a = finalConfig[type]) == null ? void 0 : _a.call(finalConfig, props)) ?? {};
66
- const { href, ...restOfLinkProps } = linkProps;
67
- if (!href) return {};
68
- if (!URL.canParse(href)) {
69
- logger.log("Invalid href", "error", { href });
70
- return {};
71
- }
72
- const hrefUrl = new URL(href);
73
- searchParams.forEach((value, name) => {
74
- hrefUrl.searchParams.append(name, value);
75
- });
76
- return {
77
- ...rest,
78
- as,
79
- ...themeName ? { themeName } : {},
80
- ...customTheme ? { customTheme } : {},
81
- ...tokens ? { tokens } : {},
82
- nextLinkProps: {
83
- href: hrefUrl.toString(),
84
- prefetch: prefetch ?? void 0,
85
- scroll: scroll ?? void 0,
86
- replace: replace ?? void 0
87
- },
88
- href: hrefUrl.toString(),
89
- children: label,
90
- ...restOfLinkProps
91
- };
92
- }
93
- export {
94
- useDirectusLink as default
95
- };
@@ -1,7 +0,0 @@
1
- import { TPageSettings, TPageSettingsTranslation } from '../../../directus-next/src/index.ts';
2
- import { Metadata } from 'next';
3
- import { TMetadataOptions } from '../types/metadata';
4
-
5
- export default function useMetadata<TPageProps extends {
6
- pageSettings: TPageSettings;
7
- }>(pageProps: TPageProps, options: TMetadataOptions, defaultProps?: Partial<TPageSettingsTranslation>): Metadata;
@@ -1,4 +0,0 @@
1
- import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
2
- import { SearchParams } from '../types/links';
3
-
4
- export default function getDirectusSearchParams(params: Nullable<Nullable<SearchParams>[]>): URLSearchParams;
@@ -1,11 +0,0 @@
1
- import { Nullable } from '../../../../stack/stack-ui/src/index.ts';
2
- import { TDirectusLinkProps } from '../components/DirectusLink/interface';
3
- import { TNavigationItems, TNavigationItemsTree } from '../types/navigation-items';
4
-
5
- /**
6
- *
7
- * @param navigationItems A tree of navigation items, with parents and children
8
- * @param onNavigationItem Called when a navigation item is about to be added to the tree
9
- * @returns A tree of navigation items with ready-to-use DirectusLink components
10
- */
11
- export default function useNavigationItems<Depth extends number, Link, NavigationItems extends TNavigationItems<NavigationItems, Link, Depth> = TNavigationItems<unknown, Link, Depth>>(items: Nullable<Nullable<TNavigationItems<NavigationItems, Link, Depth>>[]>, onNavigationItem: (item: Nullable<TNavigationItems<NavigationItems, Link, Depth>>) => Nullable<TDirectusLinkProps>): Nullable<Nullable<TNavigationItemsTree>[]>;