@stoplight/elements-core 7.7.0 → 7.7.1

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,3 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import type { RouterType } from '../types';
3
- export declare const RouterTypeContext: React.Context<RouterType>;
3
+ export declare const RouterTypeContext: React.Context<RouterType | null>;
4
+ export declare const useRouterType: () => RouterType | null;
package/index.esm.js CHANGED
@@ -2088,9 +2088,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2088
2088
  return description;
2089
2089
  }
2090
2090
 
2091
- const RouterTypeContext = React.createContext('history');
2091
+ const RouterTypeContext = React.createContext(null);
2092
+ const useRouterType = () => {
2093
+ return React.useContext(RouterTypeContext);
2094
+ };
2092
2095
 
2093
- const LinkHeading = React.memo(function LinkHeading(_a) {
2096
+ const LinkHeading = React.memo(function LinkHeading(props) {
2097
+ const isUsingRouter = !!useRouterType();
2098
+ const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
2099
+ return React.createElement(Comp, Object.assign({}, props));
2100
+ });
2101
+ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
2094
2102
  var { id: _id } = _a, props = __rest(_a, ["id"]);
2095
2103
  const { pathname } = useLocation();
2096
2104
  const routerKind = React.useContext(RouterTypeContext);
package/index.js CHANGED
@@ -2142,9 +2142,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2142
2142
  return description;
2143
2143
  }
2144
2144
 
2145
- const RouterTypeContext = React__namespace.createContext('history');
2145
+ const RouterTypeContext = React__namespace.createContext(null);
2146
+ const useRouterType = () => {
2147
+ return React__namespace.useContext(RouterTypeContext);
2148
+ };
2146
2149
 
2147
- const LinkHeading = React__namespace.memo(function LinkHeading(_a) {
2150
+ const LinkHeading = React__namespace.memo(function LinkHeading(props) {
2151
+ const isUsingRouter = !!useRouterType();
2152
+ const Comp = isUsingRouter ? CustomLinkHeading : mosaic.LinkHeading;
2153
+ return React__namespace.createElement(Comp, Object.assign({}, props));
2154
+ });
2155
+ const CustomLinkHeading = React__namespace.memo(function LinkHeading(_a) {
2148
2156
  var { id: _id } = _a, props = tslib.__rest(_a, ["id"]);
2149
2157
  const { pathname } = reactRouterDom.useLocation();
2150
2158
  const routerKind = React__namespace.useContext(RouterTypeContext);
package/index.mjs CHANGED
@@ -2088,9 +2088,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2088
2088
  return description;
2089
2089
  }
2090
2090
 
2091
- const RouterTypeContext = React.createContext('history');
2091
+ const RouterTypeContext = React.createContext(null);
2092
+ const useRouterType = () => {
2093
+ return React.useContext(RouterTypeContext);
2094
+ };
2092
2095
 
2093
- const LinkHeading = React.memo(function LinkHeading(_a) {
2096
+ const LinkHeading = React.memo(function LinkHeading(props) {
2097
+ const isUsingRouter = !!useRouterType();
2098
+ const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
2099
+ return React.createElement(Comp, Object.assign({}, props));
2100
+ });
2101
+ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
2094
2102
  var { id: _id } = _a, props = __rest(_a, ["id"]);
2095
2103
  const { pathname } = useLocation();
2096
2104
  const routerKind = React.useContext(RouterTypeContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.7.0",
3
+ "version": "7.7.1",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",