@weavix/tracker-components 0.1.0 → 0.1.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.
@@ -0,0 +1,205 @@
1
+ # TrackerDisclosure
2
+
3
+ <!-- description:start -->
4
+ A collapsible section component with Tracker-specific styling. Extends Gravity UI [`Disclosure`](https://gravity-ui.com/components/disclosure) with a configurable chevron arrow (position and size), an optional toolbar slot rendered alongside the summary, and BEM class name hooks for fine-grained styling.
5
+ <!-- description:end -->
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import {TrackerDisclosure} from '@weavix/tracker-components';
11
+
12
+ <TrackerDisclosure summary="Section title" defaultExpanded>
13
+ Content goes here
14
+ </TrackerDisclosure>
15
+ ```
16
+
17
+ ## Component props
18
+
19
+ <!-- props:start -->
20
+ ```ts
21
+ {
22
+ /**
23
+ * Content shown in the clickable summary / header row.
24
+ * Accepts a string or any ReactNode.
25
+ */
26
+ summary?: ReactNode;
27
+
28
+ /**
29
+ * Content rendered inside the collapsible body.
30
+ */
31
+ children?: ReactNode;
32
+
33
+ /**
34
+ * Whether the section is expanded on first render (uncontrolled).
35
+ * @default false
36
+ */
37
+ defaultExpanded?: boolean;
38
+
39
+ /**
40
+ * Controlled expanded state. When provided, you must also handle onUpdate.
41
+ */
42
+ expanded?: boolean;
43
+
44
+ /**
45
+ * Callback fired when the expanded state changes.
46
+ */
47
+ onUpdate?: (expanded: boolean) => void;
48
+
49
+ /**
50
+ * Whether the disclosure is disabled (non-interactive).
51
+ * @default false
52
+ */
53
+ disabled?: boolean;
54
+
55
+ /**
56
+ * Position of the chevron arrow relative to the summary text.
57
+ * @default 'end'
58
+ */
59
+ arrowPosition?: 'start' | 'end';
60
+
61
+ /**
62
+ * Size of the chevron arrow icon in pixels.
63
+ * @default 20
64
+ */
65
+ arrowSize?: number;
66
+
67
+ /**
68
+ * Optional ReactNode rendered to the right of the toggle button inside the
69
+ * summary row. Useful for action buttons (edit, delete, add, …).
70
+ */
71
+ toolbar?: ReactNode;
72
+
73
+ /**
74
+ * Additional CSS class applied to the root element.
75
+ */
76
+ className?: string;
77
+
78
+ /**
79
+ * Additional CSS class applied to the summary row wrapper.
80
+ */
81
+ summaryClassName?: string;
82
+
83
+ /**
84
+ * Additional CSS class applied to the toggle `<button>` element.
85
+ */
86
+ toggleClassName?: string;
87
+
88
+ /**
89
+ * Additional CSS class applied to the chevron arrow icon.
90
+ */
91
+ arrowClassName?: string;
92
+ }
93
+ ```
94
+ <!-- props:end -->
95
+
96
+ > **Note:** `TrackerDisclosure` accepts all props from Gravity UI [`DisclosureProps`](https://gravity-ui.com/components/disclosure) in addition to the Tracker-specific ones listed above.
97
+
98
+ ---
99
+
100
+ ## Examples
101
+
102
+ ### Basic (uncontrolled)
103
+
104
+ ```tsx
105
+ import {TrackerDisclosure} from '@weavix/tracker-components';
106
+
107
+ <TrackerDisclosure summary="Sprint details" defaultExpanded>
108
+ <p>Sprint 42 — 14 issues, 3 in progress.</p>
109
+ </TrackerDisclosure>
110
+ ```
111
+
112
+ ---
113
+
114
+ ### Controlled
115
+
116
+ ```tsx
117
+ import React, {useState} from 'react';
118
+ import {TrackerDisclosure} from '@weavix/tracker-components';
119
+
120
+ export const ControlledExample = () => {
121
+ const [expanded, setExpanded] = useState(false);
122
+
123
+ return (
124
+ <TrackerDisclosure
125
+ summary="Filters"
126
+ expanded={expanded}
127
+ onUpdate={setExpanded}
128
+ >
129
+ <p>Filter content here.</p>
130
+ </TrackerDisclosure>
131
+ );
132
+ };
133
+ ```
134
+
135
+ ---
136
+
137
+ ### Arrow at start
138
+
139
+ ```tsx
140
+ <TrackerDisclosure summary="Description" arrowPosition="start">
141
+ <p>Content with the chevron on the left.</p>
142
+ </TrackerDisclosure>
143
+ ```
144
+
145
+ ---
146
+
147
+ ### With toolbar
148
+
149
+ The `toolbar` prop renders additional content (e.g. action buttons) to the right of the toggle button, inside the summary row but outside the toggle click area.
150
+
151
+ ```tsx
152
+ import {Button} from '@gravity-ui/uikit';
153
+ import {TrackerDisclosure} from '@weavix/tracker-components';
154
+
155
+ <TrackerDisclosure
156
+ summary="Attachments"
157
+ toolbar={
158
+ <Button size="s" view="flat" onClick={() => openUploadDialog()}>
159
+ Add file
160
+ </Button>
161
+ }
162
+ >
163
+ <AttachmentList />
164
+ </TrackerDisclosure>
165
+ ```
166
+
167
+ ---
168
+
169
+ ### Disabled
170
+
171
+ ```tsx
172
+ <TrackerDisclosure summary="Locked section" disabled defaultExpanded>
173
+ <p>This section cannot be collapsed by the user.</p>
174
+ </TrackerDisclosure>
175
+ ```
176
+
177
+ ---
178
+
179
+ ### Multiple sections (accordion-like)
180
+
181
+ ```tsx
182
+ import React, {useState} from 'react';
183
+ import {TrackerDisclosure} from '@weavix/tracker-components';
184
+
185
+ const SECTIONS = ['Details', 'Attachments', 'Comments'];
186
+
187
+ export const AccordionExample = () => {
188
+ const [openIndex, setOpenIndex] = useState<number | null>(0);
189
+
190
+ return (
191
+ <>
192
+ {SECTIONS.map((title, i) => (
193
+ <TrackerDisclosure
194
+ key={title}
195
+ summary={title}
196
+ expanded={openIndex === i}
197
+ onUpdate={(open) => setOpenIndex(open ? i : null)}
198
+ >
199
+ <p>Content for {title}</p>
200
+ </TrackerDisclosure>
201
+ ))}
202
+ </>
203
+ );
204
+ };
205
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavix/tracker-components",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared UI components for Yandex Tracker plugins",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/esm/index.js",