@readme/markdown 15.4.0 → 15.5.0
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/components/Accordion/index.tsx +5 -1
- package/components/Tabs/index.tsx +9 -1
- package/dist/hooks/useRestartAnimatedImages/index.d.ts +14 -0
- package/dist/lib/utils/mdxish/mdxish-expression.d.ts +7 -0
- package/dist/lib/utils/mdxish/mdxish-get-component-name.d.ts +2 -0
- package/dist/main.js +233 -215
- package/dist/main.node.js +233 -215
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/list-item.d.ts +2 -2
- package/dist/processor/compile/table-cell-block-markers.d.ts +11 -0
- package/dist/processor/compile/text.d.ts +3 -2
- package/dist/processor/transform/mdxish/evaluate-expressions.d.ts +11 -5
- package/dist/render-fixture.node.js +233 -215
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
- package/dist/processor/transform/mdxish/components/self-closing-blocks.d.ts +0 -21
- package/dist/processor/transform/mdxish/components/snake-case-components.d.ts +0 -28
- package/dist/processor/transform/mdxish/restore-snake-case-component-name.d.ts +0 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
+
import { useRestartAnimatedImagesOnReveal } from '../../hooks/useRestartAnimatedImages';
|
|
3
4
|
import Icon from '../Icon';
|
|
4
5
|
|
|
5
6
|
import './style.scss';
|
|
@@ -8,6 +9,7 @@ interface Props extends React.PropsWithChildren<{ icon?: string; iconColor?: str
|
|
|
8
9
|
|
|
9
10
|
const Accordion = ({ children, icon, iconColor, title }: Props) => {
|
|
10
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const contentRef = useRestartAnimatedImagesOnReveal<HTMLDivElement>(isOpen);
|
|
11
13
|
|
|
12
14
|
return (
|
|
13
15
|
<details className="Accordion" onToggle={() => setIsOpen(!isOpen)}>
|
|
@@ -16,7 +18,9 @@ const Accordion = ({ children, icon, iconColor, title }: Props) => {
|
|
|
16
18
|
{icon && <Icon className="Accordion-icon" icon={icon} iconColor={iconColor} />}
|
|
17
19
|
{title}
|
|
18
20
|
</summary>
|
|
19
|
-
<div className="Accordion-content">
|
|
21
|
+
<div ref={contentRef} className="Accordion-content">
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
20
24
|
</details>
|
|
21
25
|
);
|
|
22
26
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
+
import useRestartAnimatedImages from '../../hooks/useRestartAnimatedImages';
|
|
3
4
|
import Icon from '../Icon';
|
|
4
5
|
|
|
5
6
|
import './style.scss';
|
|
@@ -14,6 +15,7 @@ interface TabsProps {
|
|
|
14
15
|
|
|
15
16
|
const Tabs = ({ children }: TabsProps) => {
|
|
16
17
|
const [activeTab, setActiveTab] = useState(0);
|
|
18
|
+
const panelRefs = useRestartAnimatedImages(activeTab);
|
|
17
19
|
// React passes `children` as a single element when there's only one child, so normalize.
|
|
18
20
|
const tabs = React.Children.toArray(children) as React.ReactElement[];
|
|
19
21
|
|
|
@@ -38,7 +40,13 @@ const Tabs = ({ children }: TabsProps) => {
|
|
|
38
40
|
<section>
|
|
39
41
|
{/* Keep every panel mounted so runtime Tailwind can scan inactive tabs' classes on first paint */}
|
|
40
42
|
{tabs.map((tab, index: number) => (
|
|
41
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
key={tab.key}
|
|
45
|
+
ref={el => {
|
|
46
|
+
panelRefs.current[index] = el;
|
|
47
|
+
}}
|
|
48
|
+
hidden={index !== activeTab}
|
|
49
|
+
>
|
|
42
50
|
{tab}
|
|
43
51
|
</div>
|
|
44
52
|
))}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restarts GIF playback inside the panel that just became active.
|
|
3
|
+
*
|
|
4
|
+
* Tabs keep every panel mounted, so an <img> is never re-created and a GIF is
|
|
5
|
+
* shown mid-loop (or frozen on its last frame) when its tab is re-selected.
|
|
6
|
+
*
|
|
7
|
+
* @returns a ref to attach to each panel element, indexed by tab.
|
|
8
|
+
*/
|
|
9
|
+
export default function useRestartAnimatedImages(activeIndex: number): import("react").MutableRefObject<HTMLDivElement[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Restarts GIF playback inside an element that has just been revealed after being hidden —
|
|
12
|
+
* a collapsed <details>, whose images have been animating out of sight since page load.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useRestartAnimatedImagesOnReveal<T extends HTMLElement>(isRevealed: boolean): import("react").MutableRefObject<T>;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect the capitalized names an expression uses as JSX tags. Parsed rather than pattern
|
|
3
|
+
* matched: `{count < Max ? <Foo/> : <Bar/>}` puts a capitalized name straight after a `<` without
|
|
4
|
+
* it being a tag, and only the parser can tell the two apart. Unparseable input yields nothing —
|
|
5
|
+
* evaluation is about to throw on it anyway.
|
|
6
|
+
*/
|
|
7
|
+
export declare const jsxComponentNames: (expression: string) => string[];
|
|
1
8
|
/**
|
|
2
9
|
* Evaluate an expression body, transforming JSX to `React.createElement` only when the
|
|
3
10
|
* parsed estree actually contains a JSX node. The raw `Function()` evaluator can't parse
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CustomComponents } from '../../../types';
|
|
2
|
+
/** Convert a string to PascalCase */
|
|
3
|
+
export declare function toPascalCase(str: string): string;
|
|
2
4
|
/**
|
|
3
5
|
* Find a component in the components hash using case-insensitive matching.
|
|
4
6
|
* Returns the actual key from the map, or null if not found.
|