@weavix/tracker-components 0.1.0 → 0.1.2
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 +191 -19
- package/build/cjs/components/Icon/EntityIcon/EntityIcon.js +2 -3
- package/build/cjs/components/Icon/EntityIcon/EntityIcon.js.map +1 -1
- package/build/cjs/components/Icon/GoalIcon/README.md +123 -0
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.classname.js.map +1 -1
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.css +0 -3
- package/build/cjs/components/Icon/IconRefuge/IconRefuge.css.map +1 -1
- package/build/cjs/components/Icon/IssueTypeIcon/IssueTypeIcon.js +30 -50
- package/build/cjs/components/Icon/IssueTypeIcon/IssueTypeIcon.js.map +1 -1
- package/build/cjs/components/Icon/IssueTypeIcon/README.md +146 -22
- package/build/cjs/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/cjs/components/Icon/MetaEntityIcon/README.md +136 -0
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.d.ts +4 -1
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.js +1 -0
- package/build/cjs/components/Icon/PortfolioIcon/PortfolioIcon.js.map +1 -1
- package/build/cjs/components/Icon/PortfolioIcon/README.md +94 -9
- package/build/cjs/components/Icon/ProjectIcon/README.md +133 -9
- package/build/cjs/components/MetaEntitiesSelect/README.md +10 -0
- package/build/cjs/components/PluginFieldsSelect/README.md +18 -0
- package/build/cjs/components/QueueSelect/README.md +10 -0
- package/build/cjs/components/TrackerDisclosure/README.md +205 -0
- package/build/esm/components/Icon/EntityIcon/EntityIcon.js +2 -3
- package/build/esm/components/Icon/EntityIcon/EntityIcon.js.map +1 -1
- package/build/esm/components/Icon/GoalIcon/README.md +123 -0
- package/build/esm/components/Icon/IconRefuge/IconRefuge.classname.js.map +1 -1
- package/build/esm/components/Icon/IconRefuge/IconRefuge.css +0 -3
- package/build/esm/components/Icon/IconRefuge/IconRefuge.css.map +1 -1
- package/build/esm/components/Icon/IconRefuge/IconRefuge.scss +0 -4
- package/build/esm/components/Icon/IssueTypeIcon/IssueTypeIcon.js +30 -50
- package/build/esm/components/Icon/IssueTypeIcon/IssueTypeIcon.js.map +1 -1
- package/build/esm/components/Icon/IssueTypeIcon/README.md +146 -22
- package/build/esm/components/Icon/KeyResultIcon/README.md +73 -0
- package/build/esm/components/Icon/MetaEntityIcon/README.md +136 -0
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.d.ts +4 -1
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.js +1 -0
- package/build/esm/components/Icon/PortfolioIcon/PortfolioIcon.js.map +1 -1
- package/build/esm/components/Icon/PortfolioIcon/README.md +94 -9
- package/build/esm/components/Icon/ProjectIcon/README.md +133 -9
- package/build/esm/components/MetaEntitiesSelect/README.md +10 -0
- package/build/esm/components/PluginFieldsSelect/README.md +18 -0
- package/build/esm/components/QueueSelect/README.md +10 -0
- package/build/esm/components/TrackerDisclosure/README.md +205 -0
- package/package.json +1 -1
- package/build/cjs/components/Icon/Icon.css +0 -33
- package/build/cjs/components/Icon/Icon.css.map +0 -1
- package/build/esm/components/Icon/Icon.css +0 -33
- package/build/esm/components/Icon/Icon.css.map +0 -1
- package/build/esm/components/Icon/Icon.scss +0 -46
|
@@ -1,51 +1,136 @@
|
|
|
1
1
|
# PortfolioIcon
|
|
2
2
|
|
|
3
3
|
<!-- description:start -->
|
|
4
|
-
|
|
4
|
+
Displays a colored icon for a Tracker portfolio entity. The icon color is deterministically derived from the `portfolioId`, so the same portfolio always renders the same color across sessions and environments.
|
|
5
5
|
<!-- description:end -->
|
|
6
6
|
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {PortfolioIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<PortfolioIcon portfolioId="portfolio-abc" />
|
|
13
|
+
```
|
|
14
|
+
|
|
7
15
|
## Component props
|
|
8
16
|
|
|
9
17
|
<!-- props:start -->
|
|
10
18
|
```ts
|
|
11
19
|
{
|
|
12
20
|
/**
|
|
13
|
-
* Portfolio ID used to generate a deterministic color
|
|
21
|
+
* Portfolio ID used to generate a deterministic color.
|
|
22
|
+
* Typically the string entity ID returned by the Tracker API.
|
|
14
23
|
*/
|
|
15
24
|
portfolioId: string;
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
|
-
* Additional class
|
|
27
|
+
* Additional CSS class applied to the root element.
|
|
18
28
|
*/
|
|
19
29
|
className?: string;
|
|
30
|
+
|
|
20
31
|
/**
|
|
21
|
-
* Entity type label
|
|
32
|
+
* Entity type label. Defaults to "portfolio".
|
|
22
33
|
*/
|
|
23
34
|
type?: string;
|
|
35
|
+
|
|
24
36
|
/**
|
|
25
|
-
* Size of the SVG icon inside the container in pixels
|
|
37
|
+
* Size of the SVG icon inside the container in pixels.
|
|
26
38
|
* @default 16
|
|
27
39
|
*/
|
|
28
40
|
size?: number;
|
|
41
|
+
|
|
29
42
|
/**
|
|
30
|
-
* Size of the icon container in pixels
|
|
43
|
+
* Size of the icon container (the colored square) in pixels.
|
|
31
44
|
* @default 24
|
|
32
45
|
*/
|
|
33
46
|
refugeSize?: number;
|
|
47
|
+
|
|
34
48
|
/**
|
|
35
|
-
* Whether to render a colored background behind the icon
|
|
49
|
+
* Whether to render a colored background behind the icon.
|
|
50
|
+
* `PortfolioIcon` defaults this to `false`; `EntityIcon`'s own default is `true`.
|
|
36
51
|
* @default false
|
|
37
52
|
*/
|
|
38
53
|
withBackground?: boolean;
|
|
54
|
+
|
|
39
55
|
/**
|
|
40
|
-
*
|
|
56
|
+
* Alpha (opacity) of the icon foreground color, in the range 0–1.
|
|
57
|
+
* @default 1
|
|
58
|
+
*/
|
|
59
|
+
colorAlpha?: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Border radius variant of the icon container.
|
|
41
63
|
* @default 'm'
|
|
42
64
|
*/
|
|
43
65
|
radius?: 'm' | 'l';
|
|
66
|
+
|
|
44
67
|
/**
|
|
45
|
-
* Alpha (opacity) of the icon color
|
|
68
|
+
* Alpha (opacity) of the icon foreground color.
|
|
46
69
|
* @default 1
|
|
47
70
|
*/
|
|
48
71
|
colorAlpha?: number;
|
|
49
72
|
}
|
|
50
73
|
```
|
|
51
74
|
<!-- props:end -->
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
### Default
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import {PortfolioIcon} from '@weavix/tracker-components';
|
|
84
|
+
|
|
85
|
+
<PortfolioIcon portfolioId="portfolio-abc" />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### With background
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<PortfolioIcon portfolioId="portfolio-abc" withBackground />
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Custom size
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<PortfolioIcon portfolioId="portfolio-abc" size={20} refugeSize={32} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Alongside portfolio name
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import {PortfolioIcon} from '@weavix/tracker-components';
|
|
104
|
+
|
|
105
|
+
export const PortfolioLabel = ({portfolio}: {portfolio: {id: string; name: string}}) => (
|
|
106
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
107
|
+
<PortfolioIcon portfolioId={portfolio.id} />
|
|
108
|
+
<span>{portfolio.name}</span>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Multiple portfolios (each gets a unique color)
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const portfolios = [
|
|
117
|
+
{id: 'port-1', name: 'Platform'},
|
|
118
|
+
{id: 'port-2', name: 'Growth'},
|
|
119
|
+
{id: 'port-3', name: 'Infrastructure'},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
portfolios.map((p) => (
|
|
123
|
+
<div key={p.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
124
|
+
<PortfolioIcon portfolioId={p.id} />
|
|
125
|
+
<span>{p.name}</span>
|
|
126
|
+
</div>
|
|
127
|
+
));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Notes
|
|
133
|
+
|
|
134
|
+
- Unlike [`ProjectIcon`](../ProjectIcon/README.md) and [`GoalIcon`](../GoalIcon/README.md), `PortfolioIcon` uses the **string `id`** (not `shortId`) for color generation.
|
|
135
|
+
- `withBackground` defaults to `false` for portfolios (vs `true` for projects). Pass `withBackground` explicitly if you want the colored square background.
|
|
136
|
+
- To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
|
|
@@ -1,51 +1,175 @@
|
|
|
1
1
|
# ProjectIcon
|
|
2
2
|
|
|
3
3
|
<!-- description:start -->
|
|
4
|
-
|
|
4
|
+
Displays a colored icon for a Tracker project entity. The icon color is deterministically derived from the `projectId`, so the same project always renders the same color across sessions and environments.
|
|
5
5
|
<!-- description:end -->
|
|
6
6
|
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {ProjectIcon} from '@weavix/tracker-components';
|
|
11
|
+
|
|
12
|
+
<ProjectIcon projectId={123} />
|
|
13
|
+
```
|
|
14
|
+
|
|
7
15
|
## Component props
|
|
8
16
|
|
|
9
17
|
<!-- props:start -->
|
|
10
18
|
```ts
|
|
11
19
|
{
|
|
12
20
|
/**
|
|
13
|
-
* Project ID used to generate a deterministic color
|
|
21
|
+
* Project ID used to generate a deterministic color.
|
|
22
|
+
* Accepts either the numeric shortId or a string entity ID.
|
|
14
23
|
*/
|
|
15
24
|
projectId?: number | string;
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
|
-
* Additional class
|
|
27
|
+
* Additional CSS class applied to the root element.
|
|
18
28
|
*/
|
|
19
29
|
className?: string;
|
|
30
|
+
|
|
20
31
|
/**
|
|
21
|
-
* Entity type label
|
|
32
|
+
* Entity type label. Defaults to "project".
|
|
22
33
|
*/
|
|
23
34
|
type?: string;
|
|
35
|
+
|
|
24
36
|
/**
|
|
25
|
-
* Size of the SVG icon inside the container in pixels
|
|
37
|
+
* Size of the SVG icon inside the container in pixels.
|
|
26
38
|
* @default 16
|
|
27
39
|
*/
|
|
28
40
|
size?: number;
|
|
41
|
+
|
|
29
42
|
/**
|
|
30
|
-
* Size of the icon container in pixels
|
|
43
|
+
* Size of the icon container (the colored square) in pixels.
|
|
31
44
|
* @default 24
|
|
32
45
|
*/
|
|
33
46
|
refugeSize?: number;
|
|
47
|
+
|
|
34
48
|
/**
|
|
35
|
-
* Whether to render a colored background behind the icon
|
|
49
|
+
* Whether to render a colored background behind the icon.
|
|
36
50
|
* @default true
|
|
37
51
|
*/
|
|
38
52
|
withBackground?: boolean;
|
|
53
|
+
|
|
39
54
|
/**
|
|
40
|
-
* Border radius variant of the icon container
|
|
55
|
+
* Border radius variant of the icon container.
|
|
41
56
|
* @default 'm'
|
|
42
57
|
*/
|
|
43
58
|
radius?: 'm' | 'l';
|
|
59
|
+
|
|
44
60
|
/**
|
|
45
|
-
* Alpha (opacity) of the icon color
|
|
61
|
+
* Alpha (opacity) of the icon foreground color.
|
|
46
62
|
* @default 1
|
|
47
63
|
*/
|
|
48
64
|
colorAlpha?: number;
|
|
49
65
|
}
|
|
50
66
|
```
|
|
51
67
|
<!-- props:end -->
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Default
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import {ProjectIcon} from '@weavix/tracker-components';
|
|
77
|
+
|
|
78
|
+
<ProjectIcon projectId={123} />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Without background
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Renders only the colored SVG, no background square
|
|
85
|
+
<ProjectIcon projectId={123} withBackground={false} />
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Custom size
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<ProjectIcon projectId={123} size={20} refugeSize={32} />
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Large radius
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<ProjectIcon projectId={123} radius="l" />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Alongside project name
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import {ProjectIcon} from '@weavix/tracker-components';
|
|
104
|
+
|
|
105
|
+
export const ProjectLabel = ({project}: {project: {shortId: number; name: string}}) => (
|
|
106
|
+
<div style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
107
|
+
<ProjectIcon projectId={project.shortId} />
|
|
108
|
+
<span>{project.name}</span>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Multiple projects (each gets a unique color)
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
const projects = [
|
|
117
|
+
{shortId: 1, name: 'Backend API'},
|
|
118
|
+
{shortId: 2, name: 'Mobile App'},
|
|
119
|
+
{shortId: 3, name: 'Design System'},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
projects.map((p) => (
|
|
123
|
+
<div key={p.shortId} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
124
|
+
<ProjectIcon projectId={p.shortId} />
|
|
125
|
+
<span>{p.name}</span>
|
|
126
|
+
</div>
|
|
127
|
+
));
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Rendering from a Tracker API response
|
|
131
|
+
|
|
132
|
+
The Tracker entities search endpoint returns `shortId` as a number — pass it directly:
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import React, {useEffect, useState} from 'react';
|
|
136
|
+
import {ProjectIcon} from '@weavix/tracker-components';
|
|
137
|
+
import type {MetaEntityV2} from '@weavix/tracker-api-types';
|
|
138
|
+
|
|
139
|
+
interface Props {
|
|
140
|
+
trackerApi: TrackerApi;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const ProjectList: React.FC<Props> = ({trackerApi}) => {
|
|
144
|
+
const [projects, setProjects] = useState<MetaEntityV2[]>([]);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
trackerApi.v3
|
|
148
|
+
.post['/entities/{entityType}/_search']({
|
|
149
|
+
pathParams: {entityType: 'project'},
|
|
150
|
+
queryParams: {fields: ['summary'], page: 1, perPage: 20},
|
|
151
|
+
bodyParams: {filter: {}, filterTypes: ['ALL'], input: ''},
|
|
152
|
+
})
|
|
153
|
+
.then((result) => setProjects(result.data));
|
|
154
|
+
}, [trackerApi]);
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<ul>
|
|
158
|
+
{projects.map((project) => (
|
|
159
|
+
<li key={project.id} style={{display: 'flex', alignItems: 'center', gap: 8}}>
|
|
160
|
+
<ProjectIcon projectId={project.shortId} />
|
|
161
|
+
<span>{project.fields?.summary?.value ?? project.id}</span>
|
|
162
|
+
</li>
|
|
163
|
+
))}
|
|
164
|
+
</ul>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Notes
|
|
172
|
+
|
|
173
|
+
- `withBackground` defaults to `true` for projects (vs `false` for [`PortfolioIcon`](../PortfolioIcon/README.md)).
|
|
174
|
+
- Pass `projectId` as the **numeric `shortId`** from the Tracker API for consistent color generation. String IDs are also accepted.
|
|
175
|
+
- To render the correct icon for an arbitrary meta entity type, use [`MetaEntityIcon`](../MetaEntityIcon/README.md) instead.
|
|
@@ -100,6 +100,16 @@ type MetaEntityV2 = {
|
|
|
100
100
|
|
|
101
101
|
`MetaEntitiesSelect` is data-agnostic — it accepts items via the `getItems` prop. You are responsible for fetching data from the Tracker API and passing it to the component.
|
|
102
102
|
|
|
103
|
+
Requires the `"tracker:entities:write"` permission in your plugin's `manifest.json`:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"permissions": {
|
|
108
|
+
"data": ["tracker:entities:write"]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
103
113
|
### Getting projects
|
|
104
114
|
|
|
105
115
|
Use the entities search endpoint to fetch projects (or other entity types):
|
|
@@ -235,6 +235,24 @@ type TrackerSelectItem = {
|
|
|
235
235
|
|
|
236
236
|
`PluginFieldsSelect` is data-agnostic — it accepts fields via the `fields` prop. You are responsible for fetching data from the Tracker API and passing it to the component.
|
|
237
237
|
|
|
238
|
+
Add the required permissions to your plugin's `manifest.json`:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"permissions": {
|
|
243
|
+
"data": [
|
|
244
|
+
"tracker:fields:read",
|
|
245
|
+
"tracker:fields:write",
|
|
246
|
+
"tracker:queues:read"
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
- `tracker:fields:read` — required for `GET /fields` and `POST /fields/_suggest`
|
|
253
|
+
- `tracker:fields:write` — required if your plugin writes field values back to Tracker
|
|
254
|
+
- `tracker:queues:read` — required when using `localFields: true` with queue keys (Flow 3)
|
|
255
|
+
|
|
238
256
|
There are three fetch flows depending on whether the user has typed anything and whether local (queue-specific) fields are needed.
|
|
239
257
|
|
|
240
258
|
### Flow 1 — Initial load (no user input)
|
|
@@ -178,6 +178,16 @@ type QueueSuggestItem = {
|
|
|
178
178
|
|
|
179
179
|
`QueueSelect` is data-agnostic — it accepts queues via the `queues` prop and search results via the `onSearch` callback. You are responsible for fetching data from the Tracker API and passing it to the component.
|
|
180
180
|
|
|
181
|
+
Requires the `"tracker:queues:read"` permission in your plugin's `manifest.json`:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"permissions": {
|
|
186
|
+
"data": ["tracker:queues:read"]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
181
191
|
There are two fetch flows depending on whether the user has typed anything in the search filter.
|
|
182
192
|
|
|
183
193
|
### Flow 1 — Initial load (no user input)
|
|
@@ -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,33 +0,0 @@
|
|
|
1
|
-
.tpc-Icon_priority_blocker {
|
|
2
|
-
color: var(--g-color-text-danger);
|
|
3
|
-
}
|
|
4
|
-
.tpc-Icon_priority_critical {
|
|
5
|
-
color: var(--g-color-text-warning-heavy);
|
|
6
|
-
}
|
|
7
|
-
.tpc-Icon_priority_trivial {
|
|
8
|
-
color: var(--g-color-text-hint);
|
|
9
|
-
}
|
|
10
|
-
.tpc-Icon_priority_normal, .tpc-Icon_priority_minor {
|
|
11
|
-
color: var(--g-color-text-secondary);
|
|
12
|
-
}
|
|
13
|
-
.tpc-Icon-background {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
border-radius: 50%;
|
|
20
|
-
}
|
|
21
|
-
.tpc-Icon-background_priority_blocker {
|
|
22
|
-
background: var(--g-color-base-danger-light);
|
|
23
|
-
}
|
|
24
|
-
.tpc-Icon-background_priority_critical {
|
|
25
|
-
background: var(--g-color-base-warning-light);
|
|
26
|
-
}
|
|
27
|
-
.tpc-Icon-background_priority_trivial {
|
|
28
|
-
background: var(--g-color-base-neutral-light);
|
|
29
|
-
}
|
|
30
|
-
.tpc-Icon-background_priority_normal, .tpc-Icon-background_priority_minor {
|
|
31
|
-
background: var(--g-color-base-neutral-light);
|
|
32
|
-
}
|
|
33
|
-
/*# sourceMappingURL=Icon.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["Icon.scss"],"names":[],"mappings":"AACI;EACI,iCAAA;AAAR;AAGI;EACI,wCAAA;AADR;AAII;EACI,+BAAA;AAFR;AAKI;EAEI,oCAAA;AAJR;AAOI;EACI,aAAA;EACA,mBAAA;EACA,uBAAA;EAEA,WAAA;EACA,YAAA;EAEA,kBAAA;AAPR;AAUI;EACI,4CAAA;AARR;AAWI;EACI,6CAAA;AATR;AAYI;EACI,6CAAA;AAVR;AAaI;EAEI,6CAAA;AAZR","file":"Icon.css","sourcesContent":[".tpc-Icon {\n &_priority_blocker {\n color: var(--g-color-text-danger);\n }\n\n &_priority_critical {\n color: var(--g-color-text-warning-heavy);\n }\n\n &_priority_trivial {\n color: var(--g-color-text-hint);\n }\n\n &_priority_normal,\n &_priority_minor {\n color: var(--g-color-text-secondary);\n }\n\n &-background {\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 100%;\n height: 100%;\n\n border-radius: 50%;\n }\n\n &-background_priority_blocker {\n background: var(--g-color-base-danger-light);\n }\n\n &-background_priority_critical {\n background: var(--g-color-base-warning-light);\n }\n\n &-background_priority_trivial {\n background: var(--g-color-base-neutral-light);\n }\n\n &-background_priority_normal,\n &-background_priority_minor {\n background: var(--g-color-base-neutral-light);\n }\n}\n"],"sourceRoot":""}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
.tpc-Icon_priority_blocker {
|
|
2
|
-
color: var(--g-color-text-danger);
|
|
3
|
-
}
|
|
4
|
-
.tpc-Icon_priority_critical {
|
|
5
|
-
color: var(--g-color-text-warning-heavy);
|
|
6
|
-
}
|
|
7
|
-
.tpc-Icon_priority_trivial {
|
|
8
|
-
color: var(--g-color-text-hint);
|
|
9
|
-
}
|
|
10
|
-
.tpc-Icon_priority_normal, .tpc-Icon_priority_minor {
|
|
11
|
-
color: var(--g-color-text-secondary);
|
|
12
|
-
}
|
|
13
|
-
.tpc-Icon-background {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
border-radius: 50%;
|
|
20
|
-
}
|
|
21
|
-
.tpc-Icon-background_priority_blocker {
|
|
22
|
-
background: var(--g-color-base-danger-light);
|
|
23
|
-
}
|
|
24
|
-
.tpc-Icon-background_priority_critical {
|
|
25
|
-
background: var(--g-color-base-warning-light);
|
|
26
|
-
}
|
|
27
|
-
.tpc-Icon-background_priority_trivial {
|
|
28
|
-
background: var(--g-color-base-neutral-light);
|
|
29
|
-
}
|
|
30
|
-
.tpc-Icon-background_priority_normal, .tpc-Icon-background_priority_minor {
|
|
31
|
-
background: var(--g-color-base-neutral-light);
|
|
32
|
-
}
|
|
33
|
-
/*# sourceMappingURL=Icon.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["Icon.scss"],"names":[],"mappings":"AACI;EACI,iCAAA;AAAR;AAGI;EACI,wCAAA;AADR;AAII;EACI,+BAAA;AAFR;AAKI;EAEI,oCAAA;AAJR;AAOI;EACI,aAAA;EACA,mBAAA;EACA,uBAAA;EAEA,WAAA;EACA,YAAA;EAEA,kBAAA;AAPR;AAUI;EACI,4CAAA;AARR;AAWI;EACI,6CAAA;AATR;AAYI;EACI,6CAAA;AAVR;AAaI;EAEI,6CAAA;AAZR","file":"Icon.css","sourcesContent":[".tpc-Icon {\n &_priority_blocker {\n color: var(--g-color-text-danger);\n }\n\n &_priority_critical {\n color: var(--g-color-text-warning-heavy);\n }\n\n &_priority_trivial {\n color: var(--g-color-text-hint);\n }\n\n &_priority_normal,\n &_priority_minor {\n color: var(--g-color-text-secondary);\n }\n\n &-background {\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 100%;\n height: 100%;\n\n border-radius: 50%;\n }\n\n &-background_priority_blocker {\n background: var(--g-color-base-danger-light);\n }\n\n &-background_priority_critical {\n background: var(--g-color-base-warning-light);\n }\n\n &-background_priority_trivial {\n background: var(--g-color-base-neutral-light);\n }\n\n &-background_priority_normal,\n &-background_priority_minor {\n background: var(--g-color-base-neutral-light);\n }\n}\n"],"sourceRoot":""}
|