@atom-learning/components 6.16.0-beta.1 → 6.16.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,15 @@
1
1
  import * as React$1 from "react";
2
2
  //#region src/components/router-provider/RouterProvider.tsx
3
3
  var RouterContext = React$1.createContext({});
4
- var RouterProvider = ({ link, children }) => /* @__PURE__ */ React$1.createElement(RouterContext.Provider, { value: { link } }, children);
4
+ var RouterProvider = ({ link, children }) => {
5
+ const value = React$1.useMemo(() => ({ link }), [link]);
6
+ return /* @__PURE__ */ React$1.createElement(RouterContext.Provider, { value }, children);
7
+ };
5
8
  var isAbsoluteUrl = (url) => /^https?:\/\//.test(url || "");
9
+ var EMPTY = {};
6
10
  var useRouterLinkProps = (href, { reloadDocument } = {}) => {
7
11
  const { link } = React$1.useContext(RouterContext);
8
- if (!link || !href || isAbsoluteUrl(href) || reloadDocument) return {};
12
+ if (!link || !href || isAbsoluteUrl(href) || reloadDocument) return EMPTY;
9
13
  return { as: link };
10
14
  };
11
15
  RouterProvider.displayName = "RouterProvider";
@@ -1 +1 @@
1
- {"version":3,"file":"RouterProvider.js","names":[],"sources":["../../../src/components/router-provider/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\ntype LinkComponent = React.ComponentType<\n React.AnchorHTMLAttributes<HTMLAnchorElement>\n>\n\ntype RouterContextValue = {\n link?: LinkComponent\n}\n\nconst RouterContext = React.createContext<RouterContextValue>({})\n\ntype RouterProviderProps = {\n link: LinkComponent\n children: React.ReactNode\n}\n\nexport const RouterProvider = ({ link, children }: RouterProviderProps) => (\n <RouterContext.Provider value={{ link }}>{children}</RouterContext.Provider>\n)\n\nconst isAbsoluteUrl = (url?: string) => /^https?:\\/\\//.test(url || '')\n\nexport const useRouterLinkProps = (\n href?: string,\n { reloadDocument }: { reloadDocument?: boolean } = {}\n): { as?: LinkComponent } => {\n const { link } = React.useContext(RouterContext)\n\n if (!link || !href || isAbsoluteUrl(href) || reloadDocument) {\n return {}\n }\n\n return { as: link }\n}\n\nRouterProvider.displayName = 'RouterProvider'\n"],"mappings":";;AAUA,IAAM,gBAAgB,QAAM,cAAkC,EAAE,CAAC;AAOjE,IAAa,kBAAkB,EAAE,MAAM,eACrC,wBAAA,cAAC,cAAc,UAAf,EAAwB,OAAO,EAAE,MAAM,EAAqC,EAAlC,SAAkC;AAG9E,IAAM,iBAAiB,QAAiB,eAAe,KAAK,OAAO,GAAG;AAEtE,IAAa,sBACX,MACA,EAAE,mBAAiD,EAAE,KAC1B;CAC3B,MAAM,EAAE,SAAS,QAAM,WAAW,cAAc;AAEhD,KAAI,CAAC,QAAQ,CAAC,QAAQ,cAAc,KAAK,IAAI,eAC3C,QAAO,EAAE;AAGX,QAAO,EAAE,IAAI,MAAM;;AAGrB,eAAe,cAAc"}
1
+ {"version":3,"file":"RouterProvider.js","names":[],"sources":["../../../src/components/router-provider/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\n\ntype LinkComponent = React.ComponentType<\n React.AnchorHTMLAttributes<HTMLAnchorElement>\n>\n\ntype RouterContextValue = {\n link?: LinkComponent\n}\n\nconst RouterContext = React.createContext<RouterContextValue>({})\n\ntype RouterProviderProps = {\n link: LinkComponent\n children: React.ReactNode\n}\n\nexport const RouterProvider = ({ link, children }: RouterProviderProps) => {\n const value = React.useMemo<RouterContextValue>(() => ({ link }), [link])\n return <RouterContext.Provider value={value}>{children}</RouterContext.Provider>\n}\n\nconst isAbsoluteUrl = (url?: string) => /^https?:\\/\\//.test(url || '')\n\nconst EMPTY: { as?: LinkComponent } = {}\n\nexport const useRouterLinkProps = (\n href?: string,\n { reloadDocument }: { reloadDocument?: boolean } = {}\n): { as?: LinkComponent } => {\n const { link } = React.useContext(RouterContext)\n\n if (!link || !href || isAbsoluteUrl(href) || reloadDocument) {\n return EMPTY\n }\n\n return { as: link }\n}\n\nRouterProvider.displayName = 'RouterProvider'\n"],"mappings":";;AAUA,IAAM,gBAAgB,QAAM,cAAkC,EAAE,CAAC;AAOjE,IAAa,kBAAkB,EAAE,MAAM,eAAoC;CACzE,MAAM,QAAQ,QAAM,eAAmC,EAAE,MAAM,GAAG,CAAC,KAAK,CAAC;AACzE,QAAO,wBAAA,cAAC,cAAc,UAAf,EAA+B,OAA0C,EAAlC,SAAkC;;AAGlF,IAAM,iBAAiB,QAAiB,eAAe,KAAK,OAAO,GAAG;AAEtE,IAAM,QAAgC,EAAE;AAExC,IAAa,sBACX,MACA,EAAE,mBAAiD,EAAE,KAC1B;CAC3B,MAAM,EAAE,SAAS,QAAM,WAAW,cAAc;AAEhD,KAAI,CAAC,QAAQ,CAAC,QAAQ,cAAc,KAAK,IAAI,eAC3C,QAAO;AAGT,QAAO,EAAE,IAAI,MAAM;;AAGrB,eAAe,cAAc"}
package/dist/index.cjs.js CHANGED
@@ -488,11 +488,15 @@ var getExternalAnchorProps = (url) => isExternalUrl(url) ? {
488
488
  //#endregion
489
489
  //#region src/components/router-provider/RouterProvider.tsx
490
490
  var RouterContext = react.createContext({});
491
- var RouterProvider = ({ link, children }) => /* @__PURE__ */ react.createElement(RouterContext.Provider, { value: { link } }, children);
491
+ var RouterProvider = ({ link, children }) => {
492
+ const value = react.useMemo(() => ({ link }), [link]);
493
+ return /* @__PURE__ */ react.createElement(RouterContext.Provider, { value }, children);
494
+ };
492
495
  var isAbsoluteUrl = (url) => /^https?:\/\//.test(url || "");
496
+ var EMPTY = {};
493
497
  var useRouterLinkProps = (href, { reloadDocument } = {}) => {
494
498
  const { link } = react.useContext(RouterContext);
495
- if (!link || !href || isAbsoluteUrl(href) || reloadDocument) return {};
499
+ if (!link || !href || isAbsoluteUrl(href) || reloadDocument) return EMPTY;
496
500
  return { as: link };
497
501
  };
498
502
  RouterProvider.displayName = "RouterProvider";