idea-react 3.0.0-beta.1 → 3.0.0-beta.3
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/AGENTS.md +12 -3
- package/ReadMe.md +34 -6
- package/dist/index.d.mts +313 -230
- package/dist/index.d.ts +313 -230
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +0 -3
- package/package.json +13 -13
- package/source/Accordion.tsx +61 -37
- package/source/Alert.tsx +30 -15
- package/source/Avatar.tsx +55 -50
- package/source/Badge.tsx +16 -16
- package/source/Breadcrumb.tsx +36 -22
- package/source/Button.tsx +63 -69
- package/source/ButtonGroup.tsx +21 -25
- package/source/Card.tsx +67 -59
- package/source/Carousel/index.tsx +22 -21
- package/source/CloseButton.tsx +20 -15
- package/source/Collapse.tsx +74 -19
- package/source/Drawer.tsx +40 -17
- package/source/Extension/ClickBoundary.tsx +24 -5
- package/source/Extension/CodeBlock.tsx +64 -0
- package/source/Extension/Countdown.tsx +21 -9
- package/source/Extension/Editor.tsx +53 -18
- package/source/Extension/EditorHTML.tsx +7 -3
- package/source/Extension/HorizontalMarquee/index.tsx +69 -45
- package/source/Extension/Icon.tsx +15 -14
- package/source/Extension/Loading.tsx +20 -17
- package/source/Extension/MonthCalendar.tsx +26 -10
- package/source/Extension/OverlayBox.tsx +28 -15
- package/source/Extension/PageNav.tsx +16 -7
- package/source/Extension/ScrollNav/Scroller.tsx +21 -5
- package/source/Extension/ScrollNav/index.tsx +32 -7
- package/source/Extension/Select.tsx +12 -11
- package/source/Extension/SpinnerButton.tsx +19 -24
- package/source/Extension/TableSpinner.tsx +10 -14
- package/source/Extension/TextTruncate/index.tsx +17 -13
- package/source/Extension/Time.tsx +7 -5
- package/source/Extension/TimeDistance.tsx +22 -18
- package/source/Extension/Timeline/index.tsx +37 -34
- package/source/Extension/TypeEcho/Content.tsx +79 -14
- package/source/Extension/TypeEcho/index.tsx +13 -5
- package/source/Extension/UserRank/Address.tsx +17 -15
- package/source/Extension/UserRank/index.tsx +79 -84
- package/source/Extension/VerticalMarquee/index.tsx +14 -16
- package/source/Extension/ZodiacBar.tsx +40 -32
- package/source/Form/Adorn.tsx +30 -32
- package/source/Form/Checkbox.tsx +9 -5
- package/source/Form/ChipInput.tsx +9 -5
- package/source/Form/Chips.tsx +41 -39
- package/source/Form/Combobox.tsx +80 -61
- package/source/Form/Control.tsx +53 -58
- package/source/Form/DatePicker.tsx +74 -65
- package/source/Form/Feedback.tsx +18 -19
- package/source/Form/FloatingLabel.tsx +16 -19
- package/source/Form/InputGroup.tsx +27 -26
- package/source/Form/OTP.tsx +30 -12
- package/source/Form/Primitives.tsx +47 -39
- package/source/Form/Radio.tsx +25 -22
- package/source/Form/Range.tsx +30 -12
- package/source/Form/Switch.tsx +73 -48
- package/source/Form/inputProps.ts +184 -0
- package/source/Grid.tsx +67 -59
- package/source/Image.tsx +10 -6
- package/source/ListGroup.tsx +57 -69
- package/source/Menu.tsx +128 -66
- package/source/NativeDialog/index.tsx +51 -29
- package/source/Nav.tsx +46 -46
- package/source/NavOverflow/index.tsx +26 -10
- package/source/Navbar.tsx +60 -55
- package/source/Pagination.tsx +63 -69
- package/source/Placeholder.tsx +47 -43
- package/source/Polymorphic.ts +57 -0
- package/source/Popover.tsx +34 -31
- package/source/Progress/index.tsx +59 -54
- package/source/ScrollSpy/index.tsx +48 -33
- package/source/Spinner.tsx +27 -23
- package/source/Stack.tsx +25 -0
- package/source/Stepper.tsx +46 -40
- package/source/Tab.tsx +40 -27
- package/source/Table.tsx +53 -42
- package/source/Toast.tsx +62 -47
- package/source/ToggleButton.tsx +65 -54
- package/source/Toggler.tsx +17 -8
- package/source/Tooltip.tsx +31 -29
- package/source/index.ts +2 -0
- package/tsconfig.json +2 -2
- package/source/Extension/CodeBlock/index.tsx +0 -58
- package/source/Extension/CodeBlock/style.module.css +0 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import './style.module.css';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { ComponentPropsWithRef, CSSProperties
|
|
4
|
+
import { ComponentPropsWithRef, CSSProperties } from 'react';
|
|
5
5
|
|
|
6
6
|
import { ComponentTheme } from '../Button';
|
|
7
|
+
import { polymorphic } from '../Polymorphic';
|
|
7
8
|
|
|
8
9
|
export interface ProgressProps extends ComponentPropsWithRef<'div'> {
|
|
9
10
|
value: number;
|
|
@@ -15,62 +16,66 @@ export interface ProgressProps extends ComponentPropsWithRef<'div'> {
|
|
|
15
16
|
barProps?: ComponentPropsWithRef<'div'>;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export const Progress
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
export const Progress = polymorphic<ProgressProps>(
|
|
20
|
+
({
|
|
21
|
+
as: Root = 'div',
|
|
22
|
+
value,
|
|
23
|
+
min = 0,
|
|
24
|
+
max = 100,
|
|
25
|
+
theme,
|
|
26
|
+
striped,
|
|
27
|
+
animated,
|
|
28
|
+
barProps = {},
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
}) => {
|
|
34
|
+
if (![value, min, max].every(Number.isFinite) || max <= min)
|
|
35
|
+
throw new RangeError('Progress requires finite values and max greater than min');
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const current = Math.min(max, Math.max(min, value));
|
|
38
|
+
const width = `${((current - min) / (max - min)) * 100}%`;
|
|
39
|
+
const progressStyle: CSSProperties & { '--_progress-width': string } = {
|
|
40
|
+
...style,
|
|
41
|
+
'--_progress-width': width
|
|
42
|
+
};
|
|
43
|
+
const { className: barClass, style: barStyle, ...barAttributes } = barProps;
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
>
|
|
52
|
-
<div
|
|
53
|
-
{...barAttributes}
|
|
54
|
-
className={classNames(
|
|
55
|
-
'progress-bar',
|
|
56
|
-
theme && `theme-${theme}`,
|
|
57
|
-
{
|
|
58
|
-
'progress-bar-striped': striped || animated,
|
|
59
|
-
'progress-bar-animated': animated
|
|
60
|
-
},
|
|
61
|
-
barClass
|
|
62
|
-
)}
|
|
63
|
-
style={barStyle}
|
|
45
|
+
return (
|
|
46
|
+
<Root
|
|
47
|
+
{...props}
|
|
48
|
+
className={classNames('progress', className)}
|
|
49
|
+
style={progressStyle}
|
|
50
|
+
role="progressbar"
|
|
51
|
+
aria-valuenow={current}
|
|
52
|
+
aria-valuemin={min}
|
|
53
|
+
aria-valuemax={max}
|
|
64
54
|
>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
<div
|
|
56
|
+
{...barAttributes}
|
|
57
|
+
className={classNames(
|
|
58
|
+
'progress-bar',
|
|
59
|
+
theme && `theme-${theme}`,
|
|
60
|
+
{
|
|
61
|
+
'progress-bar-striped': striped || animated,
|
|
62
|
+
'progress-bar-animated': animated
|
|
63
|
+
},
|
|
64
|
+
barClass
|
|
65
|
+
)}
|
|
66
|
+
style={barStyle}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</div>
|
|
70
|
+
</Root>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
73
|
);
|
|
74
|
-
|
|
75
74
|
Progress.displayName = 'Progress';
|
|
75
|
+
|
|
76
|
+
export const ProgressStack = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
77
|
+
({ as: Root = 'div', className, ...props }) => (
|
|
78
|
+
<Root {...props} className={classNames('progress-stacked', className)} />
|
|
79
|
+
)
|
|
80
|
+
);
|
|
76
81
|
ProgressStack.displayName = 'ProgressStack';
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
|
-
import { Component, ComponentPropsWithRef, createRef, ReactNode } from 'react';
|
|
5
|
+
import { Component, ComponentPropsWithRef, createRef, ElementType, ReactNode } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
|
|
8
|
+
import { AsProps, PolymorphicClassProps } from '../Polymorphic';
|
|
8
9
|
import { ScrollSpyModel } from './model';
|
|
9
10
|
|
|
10
11
|
export interface ScrollSpyProps extends Omit<
|
|
@@ -29,7 +30,15 @@ interface ScrollSpyEntry {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
@observer
|
|
32
|
-
export class ScrollSpy extends Component<
|
|
33
|
+
export class ScrollSpy<T extends ElementType | undefined = 'div'> extends Component<
|
|
34
|
+
PolymorphicClassProps<T, ScrollSpyProps>
|
|
35
|
+
> {
|
|
36
|
+
declare readonly props: PolymorphicClassProps<T, ScrollSpyProps>;
|
|
37
|
+
|
|
38
|
+
protected get componentProps(): Readonly<ScrollSpyProps & AsProps> {
|
|
39
|
+
return this.props;
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
static displayName = 'ScrollSpy';
|
|
34
43
|
|
|
35
44
|
root = createRef<HTMLDivElement>();
|
|
@@ -62,16 +71,16 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
62
71
|
|
|
63
72
|
componentDidUpdate(previous: ScrollSpyProps) {
|
|
64
73
|
if (
|
|
65
|
-
previous.children !== this.
|
|
66
|
-
previous.target !== this.
|
|
67
|
-
previous.rootMargin !== this.
|
|
68
|
-
previous.topMargin !== this.
|
|
69
|
-
previous.threshold !== this.
|
|
70
|
-
previous.scrollRoot !== this.
|
|
74
|
+
previous.children !== this.componentProps.children ||
|
|
75
|
+
previous.target !== this.componentProps.target ||
|
|
76
|
+
previous.rootMargin !== this.componentProps.rootMargin ||
|
|
77
|
+
previous.topMargin !== this.componentProps.topMargin ||
|
|
78
|
+
previous.threshold !== this.componentProps.threshold ||
|
|
79
|
+
previous.scrollRoot !== this.componentProps.scrollRoot
|
|
71
80
|
)
|
|
72
81
|
this.refresh();
|
|
73
82
|
|
|
74
|
-
if (previous.debug !== this.
|
|
83
|
+
if (previous.debug !== this.componentProps.debug) this.updateGuides();
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
componentWillUnmount() {
|
|
@@ -89,8 +98,8 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
89
98
|
const root = this.root.current;
|
|
90
99
|
if (!root) return;
|
|
91
100
|
|
|
92
|
-
const navigation = this.
|
|
93
|
-
? document.querySelector<HTMLElement>(this.
|
|
101
|
+
const navigation = this.componentProps.target
|
|
102
|
+
? document.querySelector<HTMLElement>(this.componentProps.target)
|
|
94
103
|
: root;
|
|
95
104
|
const links = [...(navigation?.querySelectorAll<HTMLAnchorElement>('a[href^="#"]') ?? [])];
|
|
96
105
|
|
|
@@ -128,14 +137,13 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
128
137
|
handleScroll = () => this.updateGuides();
|
|
129
138
|
|
|
130
139
|
private getRootHeight = () =>
|
|
131
|
-
this.
|
|
140
|
+
this.componentProps.scrollRoot === 'window'
|
|
132
141
|
? document.documentElement.clientHeight || window.innerHeight
|
|
133
142
|
: (this.root.current?.clientHeight ?? 0);
|
|
134
143
|
|
|
135
144
|
private getRootMargin = () => {
|
|
136
|
-
if (this.
|
|
137
|
-
|
|
138
|
-
const { topMargin = '12%' } = this.props;
|
|
145
|
+
if (this.componentProps.rootMargin != null) return this.componentProps.rootMargin;
|
|
146
|
+
const { topMargin = '12%' } = this.componentProps;
|
|
139
147
|
const value = Number.parseFloat(topMargin) || 0;
|
|
140
148
|
const height = this.getRootHeight();
|
|
141
149
|
const percent = topMargin.endsWith('%') ? value : height ? (value / height) * 100 : 12;
|
|
@@ -149,7 +157,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
149
157
|
this.intersecting.clear();
|
|
150
158
|
this.atBottom = false;
|
|
151
159
|
|
|
152
|
-
const root = this.
|
|
160
|
+
const root = this.componentProps.scrollRoot === 'window' ? null : this.root.current;
|
|
153
161
|
const observer = new window.IntersectionObserver(
|
|
154
162
|
entries => {
|
|
155
163
|
if (!this.mounted || this.observer !== observer) return;
|
|
@@ -159,7 +167,11 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
159
167
|
}
|
|
160
168
|
this.updateActive();
|
|
161
169
|
},
|
|
162
|
-
{
|
|
170
|
+
{
|
|
171
|
+
root,
|
|
172
|
+
rootMargin: this.getRootMargin(),
|
|
173
|
+
threshold: this.componentProps.threshold ?? [0]
|
|
174
|
+
}
|
|
163
175
|
);
|
|
164
176
|
this.observer = observer;
|
|
165
177
|
|
|
@@ -184,7 +196,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
184
196
|
};
|
|
185
197
|
|
|
186
198
|
handleNavigationClick = (event: globalThis.MouseEvent) => {
|
|
187
|
-
if (!this.
|
|
199
|
+
if (!this.componentProps.smoothScroll || event.defaultPrevented) return;
|
|
188
200
|
|
|
189
201
|
const link =
|
|
190
202
|
event.target instanceof Element
|
|
@@ -195,8 +207,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
195
207
|
|
|
196
208
|
event.preventDefault();
|
|
197
209
|
const root = this.root.current;
|
|
198
|
-
const { scrollRoot = 'self' } = this.
|
|
199
|
-
|
|
210
|
+
const { scrollRoot = 'self' } = this.componentProps;
|
|
200
211
|
if (scrollRoot === 'window')
|
|
201
212
|
window.scrollTo({
|
|
202
213
|
top: window.scrollY + entry.section.getBoundingClientRect().top,
|
|
@@ -231,15 +242,16 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
231
242
|
|
|
232
243
|
private updateGuides = () => {
|
|
233
244
|
const root = this.root.current;
|
|
234
|
-
if (!this.
|
|
245
|
+
if (!this.componentProps.debug || !root) return this.store.setGuides(undefined);
|
|
235
246
|
|
|
236
247
|
const rect = root.getBoundingClientRect();
|
|
237
248
|
const height = this.getRootHeight();
|
|
238
249
|
|
|
239
250
|
this.store.setGuides({
|
|
240
|
-
top: this.
|
|
241
|
-
left: this.
|
|
242
|
-
width:
|
|
251
|
+
top: this.componentProps.scrollRoot === 'window' ? 0 : rect.top,
|
|
252
|
+
left: this.componentProps.scrollRoot === 'window' ? 0 : rect.left,
|
|
253
|
+
width:
|
|
254
|
+
this.componentProps.scrollRoot === 'window' ? window.innerWidth : root.clientWidth,
|
|
243
255
|
height,
|
|
244
256
|
line: this.getActivationLine(height),
|
|
245
257
|
atBottom: this.atBottom
|
|
@@ -289,12 +301,12 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
289
301
|
if (current.id === this.store.activeId) return;
|
|
290
302
|
|
|
291
303
|
this.store.setActiveId(current.id);
|
|
292
|
-
this.
|
|
304
|
+
this.componentProps.onActiveChange?.(current.id);
|
|
293
305
|
};
|
|
294
306
|
|
|
295
307
|
renderDebug = () => {
|
|
296
308
|
const guides = this.store.guides;
|
|
297
|
-
if (!this.
|
|
309
|
+
if (!this.componentProps.debug || !guides) return null;
|
|
298
310
|
|
|
299
311
|
const { top, left, width, height, line, atBottom } = guides;
|
|
300
312
|
|
|
@@ -325,7 +337,10 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
325
337
|
};
|
|
326
338
|
|
|
327
339
|
render() {
|
|
340
|
+
const Root: ElementType = this.componentProps.as ?? 'div';
|
|
341
|
+
|
|
328
342
|
const {
|
|
343
|
+
as: _as,
|
|
329
344
|
children,
|
|
330
345
|
className,
|
|
331
346
|
debug: _debug,
|
|
@@ -339,18 +354,18 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
339
354
|
threshold: _threshold,
|
|
340
355
|
topMargin: _topMargin,
|
|
341
356
|
...props
|
|
342
|
-
} = this.
|
|
357
|
+
} = this.componentProps;
|
|
343
358
|
|
|
344
359
|
return (
|
|
345
|
-
<
|
|
360
|
+
<Root
|
|
346
361
|
{...props}
|
|
347
362
|
ref={this.root}
|
|
348
363
|
className={classNames('scrollspy', className)}
|
|
349
364
|
data-active-id={this.store.activeId || undefined}
|
|
350
|
-
data-bs-root-margin={this.
|
|
351
|
-
tabIndex={this.
|
|
352
|
-
onClick={this.
|
|
353
|
-
onKeyDown={this.
|
|
365
|
+
data-bs-root-margin={this.componentProps.rootMargin ?? undefined}
|
|
366
|
+
tabIndex={this.componentProps.tabIndex ?? 0}
|
|
367
|
+
onClick={this.componentProps.onClick}
|
|
368
|
+
onKeyDown={this.componentProps.onKeyDown}
|
|
354
369
|
>
|
|
355
370
|
{children}
|
|
356
371
|
<div
|
|
@@ -359,7 +374,7 @@ export class ScrollSpy extends Component<ScrollSpyProps> {
|
|
|
359
374
|
aria-hidden="true"
|
|
360
375
|
/>
|
|
361
376
|
{this.renderDebug()}
|
|
362
|
-
</
|
|
377
|
+
</Root>
|
|
363
378
|
);
|
|
364
379
|
}
|
|
365
380
|
}
|
package/source/Spinner.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ComponentTheme } from './Button';
|
|
5
5
|
import { Icon, IconProps } from './Extension/Icon';
|
|
6
|
+
import { polymorphic } from './Polymorphic';
|
|
6
7
|
|
|
7
8
|
export type SpinnerAnimation = 'border' | 'grow';
|
|
8
9
|
|
|
@@ -12,29 +13,32 @@ export interface SpinnerProps extends ComponentPropsWithRef<'span'> {
|
|
|
12
13
|
theme?: ComponentTheme;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const Spinner
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
export const Spinner = polymorphic<SpinnerProps>(
|
|
17
|
+
({
|
|
18
|
+
as: Root = 'span',
|
|
19
|
+
animation = 'border',
|
|
20
|
+
size,
|
|
21
|
+
theme,
|
|
22
|
+
className,
|
|
23
|
+
role = 'status',
|
|
24
|
+
...props
|
|
25
|
+
}) => (
|
|
26
|
+
<Root
|
|
27
|
+
{...props}
|
|
28
|
+
role={role}
|
|
29
|
+
className={classNames(
|
|
30
|
+
`spinner-${animation}`,
|
|
31
|
+
size && `spinner-${size}`,
|
|
32
|
+
theme && `theme-${theme}`,
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
33
37
|
);
|
|
38
|
+
Spinner.displayName = 'Spinner';
|
|
34
39
|
|
|
35
|
-
export const SpinnerIcon
|
|
36
|
-
<Icon {...props} className={classNames('spinner-rotate', className)} />
|
|
37
|
-
);
|
|
40
|
+
export const SpinnerIcon = polymorphic<IconProps>(({ as: RootAs, className, ...props }) => (
|
|
41
|
+
<Icon as={RootAs} {...props} className={classNames('spinner-rotate', className)} />
|
|
42
|
+
));
|
|
38
43
|
|
|
39
|
-
Spinner.displayName = 'Spinner';
|
|
40
44
|
SpinnerIcon.displayName = 'SpinnerIcon';
|
package/source/Stack.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { polymorphic } from './Polymorphic';
|
|
5
|
+
|
|
6
|
+
export type StackDirection = 'horizontal' | 'vertical';
|
|
7
|
+
|
|
8
|
+
export interface StackProps extends ComponentPropsWithRef<'div'> {
|
|
9
|
+
direction?: StackDirection;
|
|
10
|
+
gap?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Stack = polymorphic<StackProps>(
|
|
14
|
+
({ as: Root = 'div', direction = 'vertical', gap, className, ...props }) => (
|
|
15
|
+
<Root
|
|
16
|
+
{...props}
|
|
17
|
+
className={classNames(
|
|
18
|
+
direction === 'horizontal' ? 'hstack' : 'vstack',
|
|
19
|
+
gap !== undefined && `gap-${gap}`,
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
Stack.displayName = 'Stack';
|
package/source/Stepper.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import { ComponentTheme } from './Button';
|
|
5
5
|
import { Breakpoint } from './Grid';
|
|
6
|
+
import { polymorphic } from './Polymorphic';
|
|
6
7
|
|
|
7
8
|
export interface StepperProps extends ComponentPropsWithRef<'ol'> {
|
|
8
9
|
horizontal?: boolean | Breakpoint;
|
|
@@ -17,17 +18,23 @@ const stepperClasses = (horizontal: StepperProps['horizontal'], className?: stri
|
|
|
17
18
|
className
|
|
18
19
|
);
|
|
19
20
|
|
|
20
|
-
export const Stepper
|
|
21
|
-
|
|
21
|
+
export const Stepper = polymorphic<StepperProps>(
|
|
22
|
+
({ as: Root = 'ol', horizontal, className, ...props }) => (
|
|
23
|
+
<Root {...props} className={stepperClasses(horizontal, className)} />
|
|
24
|
+
)
|
|
22
25
|
);
|
|
26
|
+
Stepper.displayName = 'Stepper';
|
|
23
27
|
|
|
24
28
|
export interface StepperNavProps extends ComponentPropsWithRef<'nav'> {
|
|
25
29
|
horizontal?: StepperProps['horizontal'];
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export const StepperNav
|
|
29
|
-
|
|
32
|
+
export const StepperNav = polymorphic<StepperNavProps>(
|
|
33
|
+
({ as: Root = 'nav', horizontal, className, ...props }) => (
|
|
34
|
+
<Root {...props} className={stepperClasses(horizontal, className)} />
|
|
35
|
+
)
|
|
30
36
|
);
|
|
37
|
+
StepperNav.displayName = 'StepperNav';
|
|
31
38
|
|
|
32
39
|
interface StepStyle {
|
|
33
40
|
active?: boolean;
|
|
@@ -36,50 +43,49 @@ interface StepStyle {
|
|
|
36
43
|
|
|
37
44
|
export type StepperItemProps = ComponentPropsWithRef<'li'> & StepStyle;
|
|
38
45
|
|
|
39
|
-
export const StepperItem
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
export const StepperItem = polymorphic<StepperItemProps>(
|
|
47
|
+
({ as: Root = 'li', active, theme, className, ...props }) => (
|
|
48
|
+
<Root
|
|
49
|
+
{...props}
|
|
50
|
+
className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
44
53
|
);
|
|
54
|
+
StepperItem.displayName = 'StepperItem';
|
|
45
55
|
|
|
46
56
|
export type StepperLinkProps = ComponentPropsWithRef<'a'> & StepStyle;
|
|
47
57
|
|
|
48
|
-
export const StepperLink
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
export const StepperLink = polymorphic<StepperLinkProps>(
|
|
59
|
+
({ as: Root = 'a', active, theme, className, ...props }) => (
|
|
60
|
+
<Root
|
|
61
|
+
{...props}
|
|
62
|
+
className={classNames('stepper-item', { active }, theme && `theme-${theme}`, className)}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
53
65
|
);
|
|
66
|
+
StepperLink.displayName = 'StepperLink';
|
|
54
67
|
|
|
55
68
|
export type StepperButtonProps = ComponentPropsWithRef<'button'> & StepStyle;
|
|
56
69
|
|
|
57
|
-
export const StepperButton
|
|
58
|
-
active,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
theme && `theme-${theme}`,
|
|
71
|
-
className
|
|
72
|
-
)}
|
|
73
|
-
/>
|
|
70
|
+
export const StepperButton = polymorphic<StepperButtonProps>(
|
|
71
|
+
({ as: Root = 'button', active, theme, className, type = 'button', ...props }) => (
|
|
72
|
+
<Root
|
|
73
|
+
{...props}
|
|
74
|
+
type={type}
|
|
75
|
+
className={classNames(
|
|
76
|
+
'stepper-item p-0 border-0 bg-transparent',
|
|
77
|
+
{ active },
|
|
78
|
+
theme && `theme-${theme}`,
|
|
79
|
+
className
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
74
83
|
);
|
|
84
|
+
StepperButton.displayName = 'StepperButton';
|
|
75
85
|
|
|
76
|
-
export const StepperOverflow
|
|
77
|
-
|
|
86
|
+
export const StepperOverflow = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
87
|
+
({ as: Root = 'div', className, ...props }) => (
|
|
88
|
+
<Root {...props} className={classNames('stepper-overflow', className)} />
|
|
89
|
+
)
|
|
78
90
|
);
|
|
79
|
-
|
|
80
|
-
Stepper.displayName = 'Stepper';
|
|
81
|
-
StepperNav.displayName = 'StepperNav';
|
|
82
|
-
StepperItem.displayName = 'StepperItem';
|
|
83
|
-
StepperLink.displayName = 'StepperLink';
|
|
84
|
-
StepperButton.displayName = 'StepperButton';
|
|
85
91
|
StepperOverflow.displayName = 'StepperOverflow';
|