@deque/cauldron-react 5.0.0-canary.4c176db1 → 5.0.0-canary.580313a7

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,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { SyntaxHighlighterProps } from 'react-syntax-highlighter';
3
- declare type Props = {
3
+ interface Props extends SyntaxHighlighterProps {
4
4
  children: string;
5
5
  language?: 'javascript' | 'css' | 'html' | 'yaml';
6
6
  className?: string;
7
- scrollable?: boolean;
8
- } & SyntaxHighlighterProps & React.HTMLAttributes<HTMLDivElement>;
7
+ tabIndex?: number;
8
+ }
9
9
  declare const Code: React.ComponentType<React.PropsWithChildren<Props>>;
10
10
  export default Code;
package/lib/index.js CHANGED
@@ -8157,35 +8157,9 @@ SyntaxHighlighter.registerLanguage('yaml', yaml_1);
8157
8157
  // HACK: This is a workaround for a bug in react-syntax-highlighter's types.
8158
8158
  var Highlighter = SyntaxHighlighter;
8159
8159
  var Code = function (_a) {
8160
- var children = _a.children, className = _a.className, _b = _a.scrollable, scrollable = _b === void 0 ? false : _b, props = tslib.__rest(_a, ["children", "className", "scrollable"]);
8161
- var ref = React.useRef(null);
8162
- var _c = tslib.__read(React.useState(false), 2), scrollableRegion = _c[0], setScrollableRegion = _c[1];
8163
- // react-syntax-highlighter does not provide direct access to its dom elements
8164
- // via refs, but we can specify the wrapping tags to bypass this limitation
8165
- // see: https://github.com/react-syntax-highlighter/react-syntax-highlighter/issues/335
8166
- var PreWithRef = function (preProps) { return (React__default.createElement("pre", tslib.__assign({}, preProps, { ref: ref }))); };
8167
- React.useEffect(function () {
8168
- var _a;
8169
- // Track the containing element because resize observer will not
8170
- // trigger once an element becomes scrollable
8171
- if (scrollable && ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement)) {
8172
- var listener = function () {
8173
- if (!ref.current) {
8174
- return;
8175
- }
8176
- var element = ref.current;
8177
- setScrollableRegion(element.clientWidth < element.scrollWidth);
8178
- };
8179
- var observer_1 = new ResizeObserver(listener);
8180
- observer_1.observe(ref.current.parentElement);
8181
- }
8182
- return function () {
8183
- setScrollableRegion(false);
8184
- };
8185
- }, [scrollable]);
8186
- return (React__default.createElement(Highlighter, tslib.__assign({}, props, { PreTag: PreWithRef, useInlineStyles: false, className: classNames('Code', className, {
8187
- 'Code--scrollable': scrollable
8188
- }), tabIndex: scrollableRegion ? 0 : undefined }), children));
8160
+ var children = _a.children, className = _a.className, tabIndex = _a.tabIndex, props = tslib.__rest(_a, ["children", "className", "tabIndex"]);
8161
+ return (React__default.createElement(React__default.Fragment, null,
8162
+ React__default.createElement(Highlighter, tslib.__assign({}, props, { useInlineStyles: false, className: classNames('Code', className), tabIndex: tabIndex }), children)));
8189
8163
  };
8190
8164
  Code.displayName = 'Code';
8191
8165
  Code.propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "5.0.0-canary.4c176db1",
3
+ "version": "5.0.0-canary.580313a7",
4
4
  "description": "Fully accessible react components library for Deque Cauldron",
5
5
  "homepage": "https://cauldron.dequelabs.com/",
6
6
  "publishConfig": {