myst-to-react 0.14.0 → 0.14.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.
package/dist/block.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import type { GenericParent } from 'myst-common';
2
2
  import type { NodeRenderer } from '@myst-theme/providers';
3
- export declare function Block({ id, node, className, }: {
4
- id: string;
3
+ export declare function Block({ node, className }: {
5
4
  node: GenericParent;
6
5
  className?: string;
7
- }): import("react/jsx-runtime").JSX.Element;
8
- export declare const BlockRenderer: NodeRenderer;
6
+ }): import("react/jsx-runtime").JSX.Element | null;
9
7
  declare const BLOCK_RENDERERS: Record<string, NodeRenderer>;
10
8
  export default BLOCK_RENDERERS;
11
9
  //# sourceMappingURL=block.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,wBAAgB,KAAK,CAAC,EACpB,EAAE,EACF,IAAI,EACJ,SAAS,GACV,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAuBA;AAED,eAAO,MAAM,aAAa,EAAE,YAI3B,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAEjD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,kDAoBrF;AAED,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAEjD,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/block.js CHANGED
@@ -2,27 +2,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Details } from './dropdown.js';
3
3
  import { MyST } from './MyST.js';
4
4
  import classNames from 'classnames';
5
- import { useGridSystemProvider } from '@myst-theme/providers';
6
- export function Block({ id, node, className, }) {
5
+ export function Block({ node, className }) {
7
6
  var _a, _b;
8
- const grid = useGridSystemProvider();
9
- const subGrid = node.visibility === 'hide' ? '' : `${grid} subgrid-gap col-screen`;
10
- const dataClassName = typeof ((_a = node.data) === null || _a === void 0 ? void 0 : _a.class) === 'string' ? (_b = node.data) === null || _b === void 0 ? void 0 : _b.class : undefined;
11
- // Hide the subgrid if either the dataClass or the className exists and includes `col-`
12
- const noSubGrid = (dataClassName && dataClassName.includes('col-')) || (className && className.includes('col-'));
13
- const block = (_jsx("div", { id: id, className: classNames('relative group/block', className, dataClassName, {
14
- [subGrid]: !noSubGrid,
15
- hidden: node.visibility === 'remove',
16
- }), children: _jsx(MyST, { ast: node.children }) }, `block-${id}`));
7
+ const cn = classNames(className, node.class, {
8
+ [(_a = node.data) === null || _a === void 0 ? void 0 : _a.class]: typeof ((_b = node.data) === null || _b === void 0 ? void 0 : _b.class) === 'string',
9
+ });
10
+ if (node.visibility === 'remove')
11
+ return null;
12
+ // Only wrap this in a block if the block has a class name or an identifier
13
+ // Otherwise pass through the contents as is.
14
+ // This allows children (e.g. margin) access to the grid-system
15
+ const block = cn || node.identifier ? (_jsx("div", { id: node.identifier, className: cn, children: _jsx(MyST, { ast: node.children }) })) : (_jsx(MyST, { ast: node.children }));
17
16
  if (node.visibility === 'hide') {
18
17
  return _jsx(Details, { title: "Block", children: block });
19
18
  }
20
19
  return block;
21
20
  }
22
- export const BlockRenderer = ({ node, className }) => {
23
- return (_jsx(Block, { id: node.key, node: node, className: classNames(node.class, className) }, node.key));
24
- };
25
21
  const BLOCK_RENDERERS = {
26
- block: BlockRenderer,
22
+ block: Block,
27
23
  };
28
24
  export default BLOCK_RENDERERS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myst-to-react",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@heroicons/react": "^2.0.18",
24
- "@myst-theme/providers": "^0.14.0",
24
+ "@myst-theme/providers": "^0.14.1",
25
25
  "@scienceicons/react": "^0.0.11",
26
26
  "@radix-ui/react-hover-card": "^1.0.6",
27
27
  "buffer": "^6.0.3",