@rescui/tab-list 0.17.0 → 0.17.1-RUI-293-Update-menu-component-7a032357e.20
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 +4 -3
- package/lib/_virtual/index.css.js +12 -12
- package/lib/index.css +180 -194
- package/lib/index.d.ts +6 -6
- package/lib/index.js +1 -1
- package/lib/parts/deep-map.d.ts +2 -2
- package/lib/parts/separator.p.module.css.js +3 -3
- package/lib/parts/tab-list-context.d.ts +13 -13
- package/lib/parts/tab-list.p.module.css.js +25 -16
- package/lib/parts/tab-separator.d.ts +8 -8
- package/lib/parts/tab.d.ts +35 -35
- package/lib/parts/use-indicator.d.ts +13 -13
- package/lib/parts/use-roving-tab-index.d.ts +8 -8
- package/lib/parts/use-scrollable-list.d.ts +18 -18
- package/lib/parts/use-scrollable-list.js +5 -8
- package/lib/tab-list.d.ts +43 -42
- package/lib/tab-list.js +78 -23
- package/llm/components/tab-list.md +447 -0
- package/llm/index.md +2 -0
- package/package.json +10 -9
- package/lib/parts/with-scroll-arrows.d.ts +0 -28
- package/lib/parts/with-scroll-arrows.js +0 -101
- package/lib/parts/with-scroll-arrows.p.module.css.js +0 -14
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# TabList
|
|
2
|
+
|
|
3
|
+
TabList is a component for tab-like navigation panels with an animated \`activity indicator\`. Built with adaptivity in mind, it can be used to create tabs that are similar to [react-tabs](https://github.com/reactjs/react-tabs), and it can also handle more specialized cases, such as ones where the tab panel is used more like a horizontal switcher component.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Features showcase
|
|
8
|
+
|
|
9
|
+
`TabList` component works only as a controlled component. It requires `value` and `onChange` props to function properly.
|
|
10
|
+
|
|
11
|
+
Basic view modes of `TabList` component:
|
|
12
|
+
|
|
13
|
+
#### Using TabSeparator for tabs inside and outside container components
|
|
14
|
+
|
|
15
|
+
In `default` mode `TabList` doesn't render the line below the tabs. The package has a `TabSeparator` component, making it easier to create UIs where the whole screen width is underlined. You can achieve this by placing `TabSeparator` component outside the container `div`s.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { useState } from 'react';
|
|
19
|
+
import { TabList, Tab, TabSeparator } from '@rescui/tab-list';
|
|
20
|
+
|
|
21
|
+
const ContentSwitcher = ({ index, children }) => {
|
|
22
|
+
return children[index];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const MyTabs = () => {
|
|
26
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
27
|
+
return (
|
|
28
|
+
<div className="rs-docs-offset-top-24">
|
|
29
|
+
<style>
|
|
30
|
+
{`.my-container {
|
|
31
|
+
max-width: 400px;
|
|
32
|
+
margin: 0 auto;
|
|
33
|
+
}`}
|
|
34
|
+
</style>
|
|
35
|
+
<div className="my-container">
|
|
36
|
+
<TabList value={activeIndex} onChange={v => setActiveIndex(v)}>
|
|
37
|
+
<Tab>First</Tab>
|
|
38
|
+
<Tab>Second</Tab>
|
|
39
|
+
<Tab>Third</Tab>
|
|
40
|
+
</TabList>
|
|
41
|
+
</div>
|
|
42
|
+
<TabSeparator />
|
|
43
|
+
<div className="my-container">
|
|
44
|
+
<ContentSwitcher index={activeIndex}>
|
|
45
|
+
<div>First</div>
|
|
46
|
+
<div>Second</div>
|
|
47
|
+
<div>Third</div>
|
|
48
|
+
</ContentSwitcher>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
render(<MyTabs />);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Content Switcher made of TabList with default values
|
|
58
|
+
|
|
59
|
+
`TabList` enumerates `Tab` children components, so by default it has different keys for `onChange` prop function. It's possible to use `TabList` with regular React `useState` hook like this:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { useState } from 'react';
|
|
63
|
+
import { TabList, Tab, TabSeparator } from '@rescui/tab-list';
|
|
64
|
+
import { Switcher } from '@rescui/switcher';
|
|
65
|
+
|
|
66
|
+
const ContentSwitcher = ({ index, children }) => {
|
|
67
|
+
return children[index];
|
|
68
|
+
};
|
|
69
|
+
const MyTabs = () => {
|
|
70
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
71
|
+
return (
|
|
72
|
+
<div>
|
|
73
|
+
<Switcher
|
|
74
|
+
size="xs"
|
|
75
|
+
value={activeIndex}
|
|
76
|
+
options={[
|
|
77
|
+
{ label: 'First', value: 0 },
|
|
78
|
+
{ label: 'Second', value: 1 },
|
|
79
|
+
{ label: 'Third', value: 2 }
|
|
80
|
+
]}
|
|
81
|
+
onChange={v => setActiveIndex(v)}
|
|
82
|
+
className="rs-docs-offset-top-12"
|
|
83
|
+
/>
|
|
84
|
+
<TabList
|
|
85
|
+
value={activeIndex}
|
|
86
|
+
onChange={v => setActiveIndex(v)}
|
|
87
|
+
className="rs-docs-offset-top-12"
|
|
88
|
+
>
|
|
89
|
+
<Tab>First</Tab>
|
|
90
|
+
<Tab>Second</Tab>
|
|
91
|
+
<Tab>Third</Tab>
|
|
92
|
+
</TabList>
|
|
93
|
+
<TabSeparator />
|
|
94
|
+
<div className="rs-docs-offset-top-12">
|
|
95
|
+
<ContentSwitcher index={activeIndex}>
|
|
96
|
+
<div>First</div>
|
|
97
|
+
<div>Second</div>
|
|
98
|
+
<div>Third</div>
|
|
99
|
+
</ContentSwitcher>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
render(<MyTabs />);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Switcher with custom values on Tabs and component for tab content
|
|
109
|
+
|
|
110
|
+
`TabList` component works as radio button-like control with custom `value` on `Tab` components
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { useState } from 'react';
|
|
114
|
+
import { TabList, Tab, TabSeparator } from '@rescui/tab-list';
|
|
115
|
+
import { Switcher } from '@rescui/switcher';
|
|
116
|
+
|
|
117
|
+
const Content = ({ activeTab }) => {
|
|
118
|
+
switch (activeTab) {
|
|
119
|
+
case 'first':
|
|
120
|
+
return <div>First</div>;
|
|
121
|
+
case 'second':
|
|
122
|
+
return <div>Second</div>;
|
|
123
|
+
case 'third':
|
|
124
|
+
return <div>Third</div>;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const MyTabs = () => {
|
|
129
|
+
const [activeTab, setActiveTab] = useState('second');
|
|
130
|
+
return (
|
|
131
|
+
<div>
|
|
132
|
+
<div>
|
|
133
|
+
<Switcher
|
|
134
|
+
size="xs"
|
|
135
|
+
value={activeTab}
|
|
136
|
+
options={[
|
|
137
|
+
{ label: 'First', value: 'first' },
|
|
138
|
+
{ label: 'Second', value: 'second' },
|
|
139
|
+
{ label: 'Third', value: 'third' }
|
|
140
|
+
]}
|
|
141
|
+
onChange={tab => setActiveTab(tab)}
|
|
142
|
+
className="rs-docs-offset-top-12"
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
145
|
+
<TabList
|
|
146
|
+
value={activeTab}
|
|
147
|
+
onChange={v => setActiveTab(v)}
|
|
148
|
+
className="rs-docs-offset-top-12"
|
|
149
|
+
>
|
|
150
|
+
<Tab value="first">First</Tab>
|
|
151
|
+
<Tab value="second">Second</Tab>
|
|
152
|
+
<Tab value="third">Third</Tab>
|
|
153
|
+
</TabList>
|
|
154
|
+
<TabSeparator />
|
|
155
|
+
<div className="rs-docs-offset-top-12">
|
|
156
|
+
<Content activeTab={activeTab} />
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
render(<MyTabs />);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### SEO tip: render the content from every tab and hide it with display: none
|
|
166
|
+
|
|
167
|
+
Content could be rendered to DOM and hidden with CSS. This is a usefull trick for SEO optimization.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { useState, cloneElement } from 'react';
|
|
171
|
+
import { TabList, Tab, TabSeparator } from '@rescui/tab-list';
|
|
172
|
+
|
|
173
|
+
const CSSContentSwitcher = ({ index, children }) => {
|
|
174
|
+
return children.map((ch, i) => {
|
|
175
|
+
const chStyles = ch.props.style || {};
|
|
176
|
+
const addStyles = i === index ? {} : { display: 'none' };
|
|
177
|
+
return cloneElement(ch, { key: i, style: { ...chStyles, ...addStyles } });
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const MyTabs = () => {
|
|
182
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
183
|
+
return (
|
|
184
|
+
<div className="rs-docs-offset-top-24">
|
|
185
|
+
<TabList value={activeIndex} onChange={v => setActiveIndex(v)}>
|
|
186
|
+
<Tab>First</Tab>
|
|
187
|
+
<Tab>Second</Tab>
|
|
188
|
+
<Tab>Third</Tab>
|
|
189
|
+
</TabList>
|
|
190
|
+
<TabSeparator />
|
|
191
|
+
<CSSContentSwitcher index={activeIndex}>
|
|
192
|
+
<div>First</div>
|
|
193
|
+
<div>Second</div>
|
|
194
|
+
<div>Third</div>
|
|
195
|
+
</CSSContentSwitcher>
|
|
196
|
+
</div>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
render(<MyTabs />);
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Controls for the e2e tests
|
|
204
|
+
|
|
205
|
+
When testing the page, you can get access to the arrows with `data-e2e` attributes. You should set the scope with the `data-e2e` attribute from the outside.
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
import { useState, cloneElement } from 'react';
|
|
209
|
+
import { TabList, Tab, TabSeparator } from '@rescui/tab-list';
|
|
210
|
+
|
|
211
|
+
const CSSContentSwitcher = ({ index, children }) => {
|
|
212
|
+
return children.map((ch, i) => {
|
|
213
|
+
const chStyles = ch.props.style || {};
|
|
214
|
+
const addStyles = i === index ? {} : { display: 'none' };
|
|
215
|
+
return cloneElement(ch, { key: i, style: { ...chStyles, ...addStyles } });
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
const MyTabs = () => {
|
|
219
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
220
|
+
return (
|
|
221
|
+
<div className="rs-docs-offset-top-24" style={{ width: 240 }}>
|
|
222
|
+
<TabList
|
|
223
|
+
value={activeIndex}
|
|
224
|
+
onChange={v => setActiveIndex(v)}
|
|
225
|
+
data-e2e={'example-tabs'}
|
|
226
|
+
>
|
|
227
|
+
<Tab>First</Tab>
|
|
228
|
+
<Tab>Second</Tab>
|
|
229
|
+
<Tab>Third</Tab>
|
|
230
|
+
<Tab>Fourth</Tab>
|
|
231
|
+
<Tab>Fifth</Tab>
|
|
232
|
+
<Tab>Sixth</Tab>
|
|
233
|
+
</TabList>
|
|
234
|
+
<TabSeparator />
|
|
235
|
+
<CSSContentSwitcher index={activeIndex}>
|
|
236
|
+
<div>First</div>
|
|
237
|
+
<div>Second</div>
|
|
238
|
+
<div>Third</div>
|
|
239
|
+
<div>Fourth</div>
|
|
240
|
+
<div>Fifth</div>
|
|
241
|
+
<div>Sixth</div>
|
|
242
|
+
</CSSContentSwitcher>
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
render(<MyTabs />);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Now you can get access to the arrows using the `[data-e2e="example-tabs__left-arrow"]` and `[data-e2e="example-tabs__right-arrow"]` selectors.
|
|
251
|
+
|
|
252
|
+
#### Custom background
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { useState } from 'react';
|
|
256
|
+
import { TabList, Tab } from '@rescui/tab-list';
|
|
257
|
+
|
|
258
|
+
const backgroundColor = '#F4F4F4';
|
|
259
|
+
|
|
260
|
+
const MyTabs = () => {
|
|
261
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
262
|
+
return (
|
|
263
|
+
<div style={{ width: 260, padding: 10, backgroundColor }}>
|
|
264
|
+
<TabList value={activeIndex} onChange={v => setActiveIndex(v)}>
|
|
265
|
+
<Tab>First</Tab>
|
|
266
|
+
<Tab>Second</Tab>
|
|
267
|
+
<Tab>Third</Tab>
|
|
268
|
+
<Tab>Fourth</Tab>
|
|
269
|
+
<Tab>Fifth</Tab>
|
|
270
|
+
<Tab>Sixth</Tab>
|
|
271
|
+
</TabList>
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
render(<MyTabs />);
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### Custom comparator
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
import { useState } from 'react';
|
|
283
|
+
import { TabList, Tab } from '@rescui/tab-list';
|
|
284
|
+
|
|
285
|
+
const Content = ({ activeIndex }) => {
|
|
286
|
+
switch (activeIndex) {
|
|
287
|
+
case 0:
|
|
288
|
+
return <div>First</div>;
|
|
289
|
+
case 1:
|
|
290
|
+
return <div>Second</div>;
|
|
291
|
+
case 2:
|
|
292
|
+
return <div>Third</div>;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const TabsWithCustomComparator = () => {
|
|
297
|
+
const [active, setActive] = useState({ value: 0 });
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<div>
|
|
301
|
+
<TabList
|
|
302
|
+
value={active}
|
|
303
|
+
onChange={v => setActive(v)}
|
|
304
|
+
compareValues={(obj1, obj2) => obj1.value === obj2.value}
|
|
305
|
+
>
|
|
306
|
+
<Tab value={{ value: 0 }}>First</Tab>
|
|
307
|
+
<Tab value={{ value: 1 }}>Second</Tab>
|
|
308
|
+
<Tab value={{ value: 2 }}>Third</Tab>
|
|
309
|
+
</TabList>
|
|
310
|
+
<div style={{ marginTop: '10px' }}>
|
|
311
|
+
<Content activeIndex={active.value} />
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
render(<TabsWithCustomComparator />);
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### Tabs as links
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
import { useState } from 'react';
|
|
324
|
+
import { TabList, Tab } from '@rescui/tab-list';
|
|
325
|
+
|
|
326
|
+
const Demo = () => {
|
|
327
|
+
const [activeTab, setActiveTab] = useState('second');
|
|
328
|
+
return (
|
|
329
|
+
<div>
|
|
330
|
+
<TabList
|
|
331
|
+
value={activeTab}
|
|
332
|
+
onChange={v => setActiveTab(v)}
|
|
333
|
+
className="rs-docs-offset-top-12"
|
|
334
|
+
>
|
|
335
|
+
<Tab href="#first" value="first">
|
|
336
|
+
First
|
|
337
|
+
</Tab>
|
|
338
|
+
<Tab href="#second" value="second">
|
|
339
|
+
Second
|
|
340
|
+
</Tab>
|
|
341
|
+
<Tab href="#third" value="third">
|
|
342
|
+
Third
|
|
343
|
+
</Tab>
|
|
344
|
+
</TabList>
|
|
345
|
+
</div>
|
|
346
|
+
);
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
render(<Demo />);
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## CSS Mixins API
|
|
353
|
+
|
|
354
|
+
#### `Tab` mixins
|
|
355
|
+
|
|
356
|
+
| Mixin name | Details |
|
|
357
|
+
| --- | --- |
|
|
358
|
+
| `rs-tab-icon-left` | prop: `iconPosition`<br><br>value: `"left"` |
|
|
359
|
+
| `rs-tab-icon-right` | prop: `iconPosition`<br><br>value: `"right"` |
|
|
360
|
+
|
|
361
|
+
#### `TabList` mixins
|
|
362
|
+
|
|
363
|
+
| Mixin name | Details |
|
|
364
|
+
| --- | --- |
|
|
365
|
+
| `rs-tab-list-size-m` | prop: `size`<br><br>value: `"m"` |
|
|
366
|
+
| `rs-tab-list-size-l` | prop: `size`<br><br>value: `"l"` |
|
|
367
|
+
| `rs-tab-list-mode-classic` | prop: `mode`<br><br>value: `"classic"` |
|
|
368
|
+
| `rs-tab-list-mode-rock` | prop: `mode`<br><br>value: `"rock"` |
|
|
369
|
+
| `rs-tab-list-sparse-true` | prop: `sparse`<br><br>value: `true` |
|
|
370
|
+
| `rs-tab-list-sparse-false` | prop: `sparse`<br><br>value: `false` |
|
|
371
|
+
| `rs-tab-list-short-true` | prop: `short`<br><br>value: `true` |
|
|
372
|
+
| `rs-tab-list-short-false` | prop: `short`<br><br>value: `false` |
|
|
373
|
+
|
|
374
|
+
#### Demo
|
|
375
|
+
|
|
376
|
+
Instead of separate classes, it may be a single class with `@media` queries inside:
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
import { TabList, Tab } from '@rescui/tab-list';
|
|
380
|
+
import { useState } from 'react';
|
|
381
|
+
import { TeamOutlineIcon, WinOutlineIcon, ThumbsUpOutlineIcon } from '@rescui/icons';
|
|
382
|
+
|
|
383
|
+
const MyTabList = ({ className }) => {
|
|
384
|
+
const [activeIndex, setActiveIndex] = useState(1);
|
|
385
|
+
return (
|
|
386
|
+
<div style={{ padding: 12, backgroundColor: 'var(--rs-color-black-t5)' }}>
|
|
387
|
+
<TabList
|
|
388
|
+
value={activeIndex}
|
|
389
|
+
onChange={v => setActiveIndex(v)}
|
|
390
|
+
className={className}
|
|
391
|
+
>
|
|
392
|
+
<Tab className="my-tab" icon={<TeamOutlineIcon />}>
|
|
393
|
+
First
|
|
394
|
+
</Tab>
|
|
395
|
+
<Tab className="my-tab" icon={<WinOutlineIcon />}>
|
|
396
|
+
Second
|
|
397
|
+
</Tab>
|
|
398
|
+
<Tab className="my-tab" icon={<ThumbsUpOutlineIcon />}>
|
|
399
|
+
Third
|
|
400
|
+
</Tab>
|
|
401
|
+
</TabList>
|
|
402
|
+
</div>
|
|
403
|
+
);
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
render(
|
|
407
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
|
408
|
+
<div>
|
|
409
|
+
<p>Default:</p>
|
|
410
|
+
<MyTabList />
|
|
411
|
+
</div>
|
|
412
|
+
<div>
|
|
413
|
+
<p>Var1:</p>
|
|
414
|
+
<MyTabList className={`my-tab-list-var-1`} />
|
|
415
|
+
</div>
|
|
416
|
+
<div>
|
|
417
|
+
<p>Var1 & Var2 combined:</p>
|
|
418
|
+
<MyTabList className={`my-tab-list-var-1 my-tab-list-var-2`} />
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
);
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
```postcss
|
|
425
|
+
@import '@rescui/tab-list/lib/public-api.p.css';
|
|
426
|
+
|
|
427
|
+
.my-tab-list-var-1 {
|
|
428
|
+
@mixin rs-tab-list-size-l;
|
|
429
|
+
@mixin rs-tab-list-mode-rock;
|
|
430
|
+
@mixin rs-tab-list-sparse-true;
|
|
431
|
+
@mixin rs-tab-list-short-true;
|
|
432
|
+
|
|
433
|
+
.my-tab {
|
|
434
|
+
@mixin rs-tab-icon-right;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
.my-tab-list-var-2 {
|
|
438
|
+
@mixin rs-tab-list-size-m;
|
|
439
|
+
@mixin rs-tab-list-mode-classic;
|
|
440
|
+
@mixin rs-tab-list-sparse-false;
|
|
441
|
+
@mixin rs-tab-list-short-false;
|
|
442
|
+
|
|
443
|
+
.my-tab {
|
|
444
|
+
@mixin rs-tab-icon-left;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
package/llm/index.md
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rescui/tab-list",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1-RUI-293-Update-menu-component-7a032357e.20+7a032357e",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "JetBrains",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"src:main": "src/index.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"lib",
|
|
12
|
+
"llm",
|
|
12
13
|
"LICENSE.txt"
|
|
13
14
|
],
|
|
14
15
|
"publishConfig": {
|
|
@@ -16,8 +17,8 @@
|
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@babel/runtime-corejs3": "^7.26.0",
|
|
19
|
-
"@rescui/button": "
|
|
20
|
-
"@rescui/use-resize-observer": "
|
|
20
|
+
"@rescui/button": "0.24.1-RUI-293-Update-menu-component-7a032357e.20+7a032357e",
|
|
21
|
+
"@rescui/use-resize-observer": "0.3.1-RUI-293-Update-menu-component-7a032357e.167+7a032357e",
|
|
21
22
|
"classnames": "^2.2.6"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
@@ -26,16 +27,16 @@
|
|
|
26
27
|
"react": ">=16.8.0 <20"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@rescui/colors": "
|
|
30
|
-
"@rescui/postcss-preset-library": "
|
|
31
|
-
"@rescui/scripts": "
|
|
32
|
-
"@rescui/typography": "
|
|
33
|
-
"@rescui/visual-regression": "
|
|
30
|
+
"@rescui/colors": "0.3.1-RUI-293-Update-menu-component-7a032357e.55+7a032357e",
|
|
31
|
+
"@rescui/postcss-preset-library": "0.2.2",
|
|
32
|
+
"@rescui/scripts": "0.5.2",
|
|
33
|
+
"@rescui/typography": "0.27.1-RUI-293-Update-menu-component-7a032357e.20+7a032357e",
|
|
34
|
+
"@rescui/visual-regression": "0.1.4"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"build": "rescui-scripts build && yarn run build-pcss-api",
|
|
37
38
|
"build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
|
|
38
39
|
},
|
|
39
40
|
"nx": {},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "7a032357e8f31abbf69e18aa6b7ef2d75e40f42e"
|
|
41
42
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Theme } from '@rescui/ui-contexts';
|
|
3
|
-
import { ScrollableListCompareValueType } from './use-scrollable-list';
|
|
4
|
-
export declare type WithScrollArrowsProps<T> = {
|
|
5
|
-
theme?: Theme;
|
|
6
|
-
value: T;
|
|
7
|
-
/** @ignore */
|
|
8
|
-
compareValues?: ScrollableListCompareValueType<T>;
|
|
9
|
-
onChange: (value: T) => void;
|
|
10
|
-
/** Identifier for e2e tests */
|
|
11
|
-
'data-e2e'?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare type WithScrollArrowsWrappedComponentProps<T> = {
|
|
14
|
-
selectedId?: number;
|
|
15
|
-
activeNodeRef?: React.MutableRefObject<HTMLElement>;
|
|
16
|
-
tabRefs?: React.MutableRefObject<Map<number, HTMLElement>>;
|
|
17
|
-
value: T;
|
|
18
|
-
onChange: (value: T) => void;
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
theme?: Theme;
|
|
21
|
-
containerRef?: React.MutableRefObject<HTMLElement>;
|
|
22
|
-
};
|
|
23
|
-
declare type OmittedWrappedComponentProps<P, T> = Omit<P, keyof WithScrollArrowsWrappedComponentProps<T>>;
|
|
24
|
-
export declare const withScrollArrows: <T, P extends WithScrollArrowsWrappedComponentProps<T>>(WrappedComponent: React.FC<WithScrollArrowsWrappedComponentProps<T>>, CompareItem: React.ElementType, arrowHeight?: string) => {
|
|
25
|
-
<OT extends T>({ compareValues, value, onChange, children, theme: themeFromProps, ["data-e2e"]: e2eId, ...restProps }: React.PropsWithChildren<WithScrollArrowsProps<OT> & OmittedWrappedComponentProps<P, OT>>): React.ReactElement | null;
|
|
26
|
-
displayName: string;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import cn from 'classnames';
|
|
4
|
-
import { Button } from '@rescui/button';
|
|
5
|
-
import { useThemeWithUndefined } from '@rescui/ui-contexts';
|
|
6
|
-
import LeftOutlineIcon from '../_virtual/left-outline.js';
|
|
7
|
-
import RightOutlineIcon from '../_virtual/right-outline.js';
|
|
8
|
-
import { useScrollableList } from './use-scrollable-list.js';
|
|
9
|
-
import styles from './with-scroll-arrows.p.module.css.js';
|
|
10
|
-
|
|
11
|
-
const compareTabsDefault = (activeValue, tabValue) => activeValue === tabValue;
|
|
12
|
-
|
|
13
|
-
const withScrollArrows = function (WrappedComponent, CompareItem) {
|
|
14
|
-
let arrowHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '100%';
|
|
15
|
-
|
|
16
|
-
const WithScrollArrowsComponent = _ref => {
|
|
17
|
-
let {
|
|
18
|
-
compareValues = compareTabsDefault,
|
|
19
|
-
value,
|
|
20
|
-
onChange,
|
|
21
|
-
children,
|
|
22
|
-
theme: themeFromProps,
|
|
23
|
-
['data-e2e']: e2eId,
|
|
24
|
-
...restProps
|
|
25
|
-
} = _ref;
|
|
26
|
-
const theme = useThemeWithUndefined(themeFromProps);
|
|
27
|
-
const {
|
|
28
|
-
selectedId,
|
|
29
|
-
prepareDirectionScroller,
|
|
30
|
-
activeNodeRef,
|
|
31
|
-
tabRefs,
|
|
32
|
-
scrollableRef,
|
|
33
|
-
containerRef,
|
|
34
|
-
childrenWithValues,
|
|
35
|
-
showLeftArrow,
|
|
36
|
-
showRightArrow
|
|
37
|
-
} = useScrollableList({
|
|
38
|
-
children,
|
|
39
|
-
compareValues,
|
|
40
|
-
value,
|
|
41
|
-
CompareItem
|
|
42
|
-
});
|
|
43
|
-
const arrowStyles = {
|
|
44
|
-
height: arrowHeight
|
|
45
|
-
};
|
|
46
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
className: cn(styles.wrapper, styles[theme])
|
|
48
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
-
className: cn(styles.arrow, styles.arrowLeft, showLeftArrow && styles.shown),
|
|
50
|
-
"data-e2e": e2eId,
|
|
51
|
-
style: arrowStyles,
|
|
52
|
-
"data-test": 'scrollable-list-arrow-left-wrapper'
|
|
53
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
54
|
-
theme: theme,
|
|
55
|
-
mode: "clear",
|
|
56
|
-
notFocusable: true,
|
|
57
|
-
onClick: prepareDirectionScroller('left'),
|
|
58
|
-
icon: /*#__PURE__*/React.createElement(LeftOutlineIcon, {
|
|
59
|
-
"data-render-all-sizes": true
|
|
60
|
-
}),
|
|
61
|
-
size: "s",
|
|
62
|
-
"data-e2e": e2eId ? `${e2eId}__left-arrow` : null,
|
|
63
|
-
"data-test": 'scrollable-list-arrow-left'
|
|
64
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
65
|
-
className: cn(styles.scrollable, showLeftArrow && styles.withLeftArrow, showRightArrow && styles.withRightArrow),
|
|
66
|
-
ref: scrollableRef,
|
|
67
|
-
tabIndex: -1
|
|
68
|
-
}, /*#__PURE__*/React.createElement(WrappedComponent, {
|
|
69
|
-
selectedId: selectedId,
|
|
70
|
-
activeNodeRef: activeNodeRef,
|
|
71
|
-
tabRefs: tabRefs,
|
|
72
|
-
value: value,
|
|
73
|
-
onChange: onChange,
|
|
74
|
-
theme: theme,
|
|
75
|
-
"data-e2e": e2eId,
|
|
76
|
-
containerRef: containerRef,
|
|
77
|
-
...restProps
|
|
78
|
-
}, childrenWithValues)), /*#__PURE__*/React.createElement("div", {
|
|
79
|
-
className: cn(styles.arrow, styles.arrowRight, showRightArrow && styles.shown),
|
|
80
|
-
style: arrowStyles,
|
|
81
|
-
"data-test": 'scrollable-list-arrow-right-wrapper'
|
|
82
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
83
|
-
theme: theme,
|
|
84
|
-
mode: "clear",
|
|
85
|
-
notFocusable: true,
|
|
86
|
-
onClick: prepareDirectionScroller('right'),
|
|
87
|
-
icon: /*#__PURE__*/React.createElement(RightOutlineIcon, {
|
|
88
|
-
"data-render-all-sizes": true
|
|
89
|
-
}),
|
|
90
|
-
className: styles.arrowButton,
|
|
91
|
-
size: "s",
|
|
92
|
-
"data-e2e": e2eId ? `${e2eId}__right-arrow` : null,
|
|
93
|
-
"data-test": 'scrollable-list-arrow-right'
|
|
94
|
-
})));
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
WithScrollArrowsComponent.displayName = `withScrollArrows(${WrappedComponent.displayName || WrappedComponent.name})`;
|
|
98
|
-
return WithScrollArrowsComponent;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export { withScrollArrows };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var styles = {
|
|
2
|
-
"light": "_light_l17k0g_9",
|
|
3
|
-
"dark": "_dark_l17k0g_12",
|
|
4
|
-
"wrapper": "_wrapper_l17k0g_16",
|
|
5
|
-
"scrollable": "_scrollable_l17k0g_23",
|
|
6
|
-
"arrow": "_arrow_l17k0g_52",
|
|
7
|
-
"shown": "_shown_l17k0g_72",
|
|
8
|
-
"arrowLeft": "_arrowLeft_l17k0g_80",
|
|
9
|
-
"arrowRight": "_arrowRight_l17k0g_85",
|
|
10
|
-
"withLeftArrow": "_withLeftArrow_l17k0g_91",
|
|
11
|
-
"withRightArrow": "_withRightArrow_l17k0g_100",
|
|
12
|
-
"arrowButton": "_arrowButton_l17k0g_121"
|
|
13
|
-
};
|
|
14
|
-
export { styles as default };
|