@diplodoc/tabs-extension 3.9.0 → 3.10.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/README.md +12 -3
- package/build/common.d.ts +15 -0
- package/build/plugin/find.d.ts +26 -2
- package/build/plugin/generate.d.ts +12 -3
- package/build/plugin/index.d.ts +1 -0
- package/build/plugin/index.js +470 -23
- package/build/plugin/index.js.map +4 -4
- package/build/plugin/transform.d.ts +10 -1
- package/build/plugin/types.d.ts +2 -0
- package/build/plugin/utils/index.d.ts +10 -1
- package/build/plugin/utils/strings.d.ts +0 -1
- package/build/plugin/utils/tabs.d.ts +30 -1
- package/build/plugin/variants/index.d.ts +10 -2
- package/build/plugin/variants/regular.d.ts +1 -1
- package/build/plugin/variants/types.d.ts +6 -1
- package/build/react/TabsRuntime.d.ts +11 -1
- package/build/react/index.js +4 -4
- package/build/react/index.js.map +2 -2
- package/build/react/useDiplodocTabs.d.ts +13 -8
- package/build/runtime/TabsController.d.ts +61 -7
- package/build/runtime/index.css +1 -1
- package/build/runtime/index.css.map +3 -3
- package/build/runtime/index.js +1 -1
- package/build/runtime/index.js.map +3 -3
- package/build/runtime/utils.d.ts +22 -0
- package/package.json +14 -8
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Diplodoc tabs extension
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.org/package/@diplodoc/tabs-extension)
|
|
4
|
+
[](https://sonarcloud.io/summary/overall?id=diplodoc-platform_tabs-extension)
|
|
5
|
+
[](https://sonarcloud.io/summary/overall?id=diplodoc-platform_tabs-extension)
|
|
6
|
+
[](https://sonarcloud.io/summary/overall?id=diplodoc-platform_tabs-extension)
|
|
7
|
+
[](https://sonarcloud.io/summary/overall?id=diplodoc-platform_tabs-extension)
|
|
8
|
+
[](https://sonarcloud.io/summary/overall?id=diplodoc-platform_tabs-extension)
|
|
4
9
|
|
|
5
10
|
This is an extension of the Diplodoc platform, which allows adding switchable tabs in the documentation.
|
|
6
11
|
|
|
@@ -73,7 +78,7 @@ Options:
|
|
|
73
78
|
(Default: `_assets/tabs-extension.css`)<br>
|
|
74
79
|
|
|
75
80
|
- `bundle` - boolean flag to enable/disable copying of bundled runtime to target directory.<br>
|
|
76
|
-
Where target
|
|
81
|
+
Where target directory is `<transformer output option>/<plugin runtime option>`<br>
|
|
77
82
|
Default: `true`<br>
|
|
78
83
|
|
|
79
84
|
- `containerClasses` - additional classes which will be added to tab's container node. It allows to customize the tabs view.<br>
|
|
@@ -106,10 +111,10 @@ Example:
|
|
|
106
111
|
{% endlist %}
|
|
107
112
|
```
|
|
108
113
|
|
|
109
|
-
Additionally, you can use different render
|
|
114
|
+
Additionally, you can use different render modes with:
|
|
110
115
|
|
|
111
116
|
```
|
|
112
|
-
{% list tabs <regular | radio | dropdown> %}
|
|
117
|
+
{% list tabs <regular | radio | dropdown | accordion> %}
|
|
113
118
|
|
|
114
119
|
- Tab 1
|
|
115
120
|
|
|
@@ -245,6 +250,10 @@ export const App: React.FC = () => {
|
|
|
245
250
|
}
|
|
246
251
|
```
|
|
247
252
|
|
|
253
|
+
## Documentation
|
|
254
|
+
|
|
255
|
+
- **For AI agents** — see [AGENTS.md](AGENTS.md) and the guides in [docs/AGENTS/](docs/AGENTS/) (core concepts, dev infrastructure).
|
|
256
|
+
|
|
248
257
|
## For contributors
|
|
249
258
|
|
|
250
259
|
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
package/build/common.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared constants, types and globals for the tabs extension.
|
|
3
|
+
* Used by both the MarkdownIt plugin (compile-time) and the runtime controller (DOM).
|
|
4
|
+
*/
|
|
1
5
|
import { type TabsController } from './runtime/TabsController';
|
|
6
|
+
/** Regex to match the opening `{% list tabs ... %}` tag (optionally backtick-escaped). */
|
|
2
7
|
export declare const TAB_RE: RegExp;
|
|
8
|
+
/** CSS class names for tab structure. */
|
|
3
9
|
export declare const TABS_CLASSNAME = "yfm-tabs";
|
|
4
10
|
export declare const TAB_CLASSNAME = "yfm-tab";
|
|
5
11
|
export declare const TAB_PANEL_CLASSNAME = "yfm-tab-panel";
|
|
6
12
|
export declare const TABS_LIST_CLASSNAME = "yfm-tab-list";
|
|
7
13
|
export declare const ACTIVE_CLASSNAME = "active";
|
|
8
14
|
export declare const TAB_GROUP_CLASSNAME = "yfm-tab-group";
|
|
15
|
+
/** Data attributes used by the runtime to identify groups, keys, variants and active state. */
|
|
9
16
|
export declare const TAB_ACTIVE_KEY = "data-diplodoc-is-active";
|
|
10
17
|
export declare const GROUP_DATA_KEY = "data-diplodoc-group";
|
|
11
18
|
export declare const TAB_DATA_KEY = "data-diplodoc-key";
|
|
@@ -14,31 +21,39 @@ export declare const TAB_DATA_ID = "data-diplodoc-id";
|
|
|
14
21
|
export declare const DEFAULT_TABS_GROUP_PREFIX = "defaultTabsGroup-";
|
|
15
22
|
export declare const ACTIVE_TAB_TEXT = "{selected}";
|
|
16
23
|
export declare const TAB_FORCED_OPEN = "data-diplodoc-forced";
|
|
24
|
+
/** Dropdown variant: container, menu and select element class names. */
|
|
17
25
|
export declare const TABS_DROPDOWN_CLASSNAME = "yfm-tabs-dropdown";
|
|
18
26
|
export declare const TABS_DROPDOWN_MENU_CLASSNAME = "yfm-tabs-dropdown-menu";
|
|
19
27
|
export declare const TABS_DROPDOWN_SELECT = "yfm-tabs-dropdown-select";
|
|
28
|
+
/** Accordion variant. */
|
|
20
29
|
export declare const TABS_ACCORDION_CLASSNAME = "yfm-tabs-accordion";
|
|
21
30
|
export declare const TABS_ACCORDION_CLIENT_HEIGHT = "data-yfm-tabs-accordion-client-heights";
|
|
31
|
+
/** Radio (vertical) variant. */
|
|
22
32
|
export declare const TABS_RADIO_CLASSNAME = "yfm-tabs-vertical";
|
|
23
33
|
export declare const VERTICAL_TAB_CLASSNAME = "yfm-vertical-tab";
|
|
24
34
|
export declare const TAB_DATA_VERTICAL_TAB = "data-diplodoc-vertical-tab";
|
|
25
35
|
export declare const TAB_RADIO_KEY = "data-diplodoc-input";
|
|
36
|
+
/** Available tab block variants (regular horizontal, radio, dropdown, accordion). */
|
|
26
37
|
export declare enum TabsVariants {
|
|
27
38
|
Regular = "regular",
|
|
28
39
|
Radio = "radio",
|
|
29
40
|
Dropdown = "dropdown",
|
|
30
41
|
Accordion = "accordion"
|
|
31
42
|
}
|
|
43
|
+
/** Which variants are enabled in the plugin (others fall back to Regular). */
|
|
32
44
|
export type EnabledVariants = Partial<Record<TabsVariants, boolean>>;
|
|
45
|
+
/** Identifies a tab: group id, tab key (from content), and variant. */
|
|
33
46
|
export interface Tab {
|
|
34
47
|
group?: string;
|
|
35
48
|
key: string;
|
|
36
49
|
variant: TabsVariants;
|
|
37
50
|
}
|
|
51
|
+
/** Payload passed to onSelectTab handlers when a tab is switched. */
|
|
38
52
|
export interface SelectedTabEvent {
|
|
39
53
|
tab: Tab;
|
|
40
54
|
currentTabId?: string;
|
|
41
55
|
}
|
|
56
|
+
/** Symbol under which the global TabsController instance is stored on `window`. */
|
|
42
57
|
export declare const GLOBAL_SYMBOL: unique symbol;
|
|
43
58
|
declare global {
|
|
44
59
|
interface Window {
|
package/build/plugin/find.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing of `{% list tabs %}` blocks: locate open/close tags, parse props, and extract tab items
|
|
3
|
+
* from the list tokens between them.
|
|
4
|
+
*/
|
|
5
|
+
import type { RuntimeTab, TabsProps } from './types';
|
|
6
|
+
import type { IDGenerator } from '@diplodoc/utils';
|
|
1
7
|
import Token from 'markdown-it/lib/token';
|
|
2
|
-
|
|
3
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Parse `{% list tabs group=... %}` content into variant and group id.
|
|
10
|
+
* @param content - Raw tag content after "list tabs"
|
|
11
|
+
* @param generateID - per-file isolated ID generator used for default group id
|
|
12
|
+
* @returns Parsed props (variant, group)
|
|
13
|
+
*/
|
|
14
|
+
export declare function props(content: string, generateID: IDGenerator): TabsProps;
|
|
4
15
|
type Result = {
|
|
5
16
|
step: number;
|
|
6
17
|
} | {
|
|
@@ -8,6 +19,19 @@ type Result = {
|
|
|
8
19
|
closeTokenIndex: number;
|
|
9
20
|
extraTokensAfterClose: number;
|
|
10
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Check if tokens at index start a valid `{% list tabs %}` block.
|
|
24
|
+
* @param tokens - Full token list
|
|
25
|
+
* @param index - Start index
|
|
26
|
+
* @returns Either a step to advance, or the block content and close index for replacement
|
|
27
|
+
*/
|
|
11
28
|
export declare function tryToFindTabs(tokens: Token[], index: number): Result;
|
|
29
|
+
/**
|
|
30
|
+
* Extract tab items (name + tokens) from list tokens between list open and close/endlist.
|
|
31
|
+
* @param tokens - Full token list
|
|
32
|
+
* @param idx - Index after list open
|
|
33
|
+
* @param closeTokenIdx - Index of {% endlist %} paragraph
|
|
34
|
+
* @returns Array of RuntimeTab
|
|
35
|
+
*/
|
|
12
36
|
export declare function findTabs(tokens: Token[], idx: number, closeTokenIdx: number): RuntimeTab[];
|
|
13
37
|
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import type Token from 'markdown-it/lib/token';
|
|
1
2
|
import type StateCore from 'markdown-it/lib/rules_core/state_core';
|
|
2
|
-
import { RuntimeTab } from './types';
|
|
3
|
-
import { TabsGenerationProps } from './variants/types';
|
|
4
|
-
|
|
3
|
+
import type { RuntimeTab } from './types';
|
|
4
|
+
import type { TabsGenerationProps } from './variants/types';
|
|
5
|
+
/**
|
|
6
|
+
* Generate markdown-it tokens for a tabs block based on the chosen variant.
|
|
7
|
+
* Delegates to the variant-specific generator (regular, radio, dropdown, accordion).
|
|
8
|
+
* @param tabs - Parsed tab items
|
|
9
|
+
* @param state - MarkdownIt state
|
|
10
|
+
* @param props - Generation options (containerClasses, tabsGroup, runId, variant)
|
|
11
|
+
* @returns Token array for the block
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateTabsTokens(tabs: RuntimeTab[], state: StateCore, props: TabsGenerationProps): Token[];
|
package/build/plugin/index.d.ts
CHANGED