idea-react 3.0.0-beta.0 → 3.0.0-beta.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/AGENTS.md +19 -2
- package/ReadMe.md +95 -54
- package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
- package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
- package/dist/index.d.mts +1232 -474
- package/dist/index.d.ts +1232 -474
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/rolldown-runtime-5iZMYShA.js +1 -0
- package/dist/style.css +66 -66
- package/package.json +1 -1
- package/source/Accordion.tsx +161 -0
- package/source/Alert.tsx +153 -0
- package/source/Avatar.tsx +57 -46
- package/source/Badge.tsx +17 -15
- package/source/Breadcrumb.tsx +50 -0
- package/source/Button.tsx +69 -40
- package/source/ButtonGroup.tsx +23 -18
- package/source/Card.tsx +86 -17
- package/source/Carousel/index.tsx +392 -0
- package/source/Carousel/model.ts +113 -0
- package/source/Carousel/scroll.ts +79 -0
- package/source/CloseButton.tsx +20 -15
- package/source/Collapse.tsx +233 -0
- package/source/Drawer.tsx +158 -38
- package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +24 -5
- package/source/Extension/CodeBlock.tsx +64 -0
- package/source/{Countdown.tsx → Extension/Countdown.tsx} +21 -9
- package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
- package/source/Extension/Editor.tsx +78 -0
- package/source/Extension/EditorHTML.tsx +20 -0
- package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
- package/source/Extension/HorizontalMarquee/index.tsx +85 -0
- package/source/Extension/Icon.tsx +19 -0
- package/source/Extension/Loading.tsx +30 -0
- package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +29 -13
- package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
- package/source/Extension/OverlayBox.tsx +293 -0
- package/source/{PageNav.tsx → Extension/PageNav.tsx} +43 -16
- package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +21 -5
- package/source/Extension/ScrollNav/index.tsx +47 -0
- package/source/Extension/Select.tsx +128 -0
- package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
- package/source/Extension/SpinnerButton.tsx +30 -0
- package/source/Extension/TableSpinner.tsx +22 -0
- package/source/Extension/TextTruncate/index.tsx +29 -0
- package/source/Extension/Time.tsx +17 -0
- package/source/Extension/TimeDistance.tsx +45 -0
- package/source/Extension/Timeline/index.tsx +63 -0
- package/source/Extension/TypeEcho/Content.tsx +123 -0
- package/source/Extension/TypeEcho/index.tsx +22 -0
- package/source/Extension/UserRank/Address.tsx +22 -0
- package/source/Extension/UserRank/index.tsx +106 -0
- package/source/Extension/VerticalMarquee/index.tsx +23 -0
- package/source/Extension/ZodiacBar.tsx +59 -0
- package/source/Extension/index.ts +27 -0
- package/source/Form/Adorn.tsx +45 -26
- package/source/Form/Checkbox.tsx +20 -11
- package/source/Form/ChipInput.tsx +129 -0
- package/source/Form/Chips.tsx +57 -37
- package/source/Form/Combobox.tsx +362 -78
- package/source/Form/Control.tsx +72 -42
- package/source/Form/DatePicker.tsx +245 -45
- package/source/Form/DatePickerPlugin.ts +37 -0
- package/source/Form/Feedback.tsx +21 -16
- package/source/Form/FloatingLabel.tsx +21 -7
- package/source/Form/InputGroup.tsx +162 -11
- package/source/Form/OTP.tsx +156 -45
- package/source/Form/PasswordStrength.tsx +43 -17
- package/source/Form/Plugin.tsx +53 -0
- package/source/Form/Primitives.tsx +70 -20
- package/source/Form/Radio.tsx +35 -40
- package/source/Form/Range.tsx +125 -56
- package/source/Form/Switch.tsx +53 -27
- package/source/Form/index.ts +1 -0
- package/source/Grid.tsx +68 -56
- package/source/Image.tsx +10 -6
- package/source/ListGroup.tsx +59 -58
- package/source/Menu.tsx +317 -46
- package/source/NativeDialog/index.tsx +148 -22
- package/source/Nav.tsx +49 -33
- package/source/NavOverflow/index.tsx +323 -0
- package/source/NavOverflow/model.ts +21 -0
- package/source/Navbar.tsx +65 -45
- package/source/Overlay.ts +163 -1
- package/source/Pagination.tsx +86 -0
- package/source/Placeholder.tsx +70 -0
- package/source/Polymorphic.ts +57 -0
- package/source/Popover.tsx +34 -26
- package/source/Progress/index.tsx +81 -0
- package/source/Progress/style.module.css +15 -0
- package/source/ScrollSpy/index.tsx +380 -0
- package/source/ScrollSpy/model.ts +17 -0
- package/source/Spinner.tsx +31 -17
- package/source/Stack.tsx +25 -0
- package/source/Stepper.tsx +91 -0
- package/source/Tab.tsx +261 -0
- package/source/Table.tsx +53 -42
- package/source/Toast.tsx +93 -46
- package/source/ToggleButton.tsx +47 -30
- package/source/Toggler.tsx +117 -0
- package/source/Tooltip.tsx +31 -24
- package/source/index.ts +17 -27
- package/source/CodeBlock.tsx +0 -40
- package/source/Editor.tsx +0 -43
- package/source/EditorHTML.tsx +0 -16
- package/source/HorizontalMarquee/index.tsx +0 -61
- package/source/Icon.tsx +0 -24
- package/source/Loading.tsx +0 -22
- package/source/OverlayBox.tsx +0 -208
- package/source/ScrollNav/index.tsx +0 -22
- package/source/Select.tsx +0 -95
- package/source/SpinnerButton.tsx +0 -35
- package/source/TableSpinner.tsx +0 -26
- package/source/TextTruncate/index.tsx +0 -25
- package/source/Time.tsx +0 -15
- package/source/TimeDistance.tsx +0 -41
- package/source/Timeline/index.tsx +0 -60
- package/source/TypeEcho/Content.tsx +0 -58
- package/source/TypeEcho/index.tsx +0 -14
- package/source/UserRank/Address.tsx +0 -20
- package/source/UserRank/index.tsx +0 -111
- package/source/VerticalMarquee/index.tsx +0 -25
- package/source/ZodiacBar.tsx +0 -51
- /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
- /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
- /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
- /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
- /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
- /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
|
@@ -6,14 +6,19 @@ import {
|
|
|
6
6
|
ComponentPropsWithRef,
|
|
7
7
|
createRef,
|
|
8
8
|
DialogHTMLAttributes,
|
|
9
|
-
|
|
9
|
+
ElementType,
|
|
10
10
|
KeyboardEvent,
|
|
11
11
|
MouseEvent,
|
|
12
12
|
SyntheticEvent
|
|
13
13
|
} from 'react';
|
|
14
14
|
|
|
15
|
+
import { Breakpoint } from '../Grid';
|
|
16
|
+
import { AsProps, polymorphic, PolymorphicClassProps } from '../Polymorphic';
|
|
15
17
|
import styles from './style.module.css';
|
|
16
18
|
|
|
19
|
+
const transitionMilliseconds = (value: string) =>
|
|
20
|
+
(parseFloat(value) || 0) * (value.trim().endsWith('ms') ? 1 : 1000);
|
|
21
|
+
|
|
17
22
|
export interface NativeDialogProps extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open'> {
|
|
18
23
|
modal?: boolean;
|
|
19
24
|
dialog?: boolean;
|
|
@@ -21,110 +26,230 @@ export interface NativeDialogProps extends Omit<DialogHTMLAttributes<HTMLDialogE
|
|
|
21
26
|
keyboard?: boolean;
|
|
22
27
|
backdrop?: boolean | 'static';
|
|
23
28
|
open?: boolean;
|
|
29
|
+
size?: 'sm' | 'lg' | 'xl';
|
|
30
|
+
fullscreen?: boolean | Breakpoint;
|
|
31
|
+
scrollable?: boolean;
|
|
32
|
+
animation?: 'fade' | 'instant' | 'slide-down' | 'slide-up';
|
|
33
|
+
scroll?: boolean;
|
|
24
34
|
}
|
|
25
35
|
|
|
26
|
-
export const DialogHeader
|
|
27
|
-
|
|
36
|
+
export const DialogHeader = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
37
|
+
({ as: Root = 'div', className, ...props }) => (
|
|
38
|
+
<Root {...props} className={classNames('dialog-header', className)} />
|
|
39
|
+
)
|
|
28
40
|
);
|
|
41
|
+
DialogHeader.displayName = 'DialogHeader';
|
|
29
42
|
|
|
30
|
-
export const DialogTitle
|
|
31
|
-
|
|
43
|
+
export const DialogTitle = polymorphic<ComponentPropsWithRef<'h1'>>(
|
|
44
|
+
({ as: Root = 'h1', className, ...props }) => (
|
|
45
|
+
<Root {...props} className={classNames('dialog-title', className)} />
|
|
46
|
+
)
|
|
32
47
|
);
|
|
48
|
+
DialogTitle.displayName = 'DialogTitle';
|
|
33
49
|
|
|
34
|
-
export const DialogBody
|
|
35
|
-
|
|
50
|
+
export const DialogBody = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
51
|
+
({ as: Root = 'div', className, ...props }) => (
|
|
52
|
+
<Root {...props} className={classNames('dialog-body', className)} />
|
|
53
|
+
)
|
|
36
54
|
);
|
|
55
|
+
DialogBody.displayName = 'DialogBody';
|
|
37
56
|
|
|
38
|
-
export const DialogFooter
|
|
39
|
-
|
|
57
|
+
export const DialogFooter = polymorphic<ComponentPropsWithRef<'div'>>(
|
|
58
|
+
({ as: Root = 'div', className, ...props }) => (
|
|
59
|
+
<Root {...props} className={classNames('dialog-footer', className)} />
|
|
60
|
+
)
|
|
40
61
|
);
|
|
62
|
+
DialogFooter.displayName = 'DialogFooter';
|
|
63
|
+
|
|
64
|
+
export class NativeDialog<T extends ElementType | undefined = 'dialog'> extends Component<
|
|
65
|
+
PolymorphicClassProps<T, NativeDialogProps>
|
|
66
|
+
> {
|
|
67
|
+
declare readonly props: PolymorphicClassProps<T, NativeDialogProps>;
|
|
68
|
+
|
|
69
|
+
protected get componentProps(): Readonly<NativeDialogProps & AsProps> {
|
|
70
|
+
return this.props;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static scrollLocks = new Set<NativeDialog<ElementType>>();
|
|
74
|
+
static bodyOverflow = '';
|
|
41
75
|
|
|
42
|
-
export class NativeDialog extends Component<NativeDialogProps> {
|
|
43
76
|
element = createRef<HTMLDialogElement>();
|
|
44
77
|
returnFocus?: HTMLElement;
|
|
78
|
+
switchingMode = false;
|
|
79
|
+
closeTimer?: ReturnType<typeof setTimeout>;
|
|
45
80
|
|
|
46
81
|
get open() {
|
|
47
82
|
return this.element.current?.open ?? false;
|
|
48
83
|
}
|
|
49
84
|
|
|
50
85
|
componentDidMount() {
|
|
51
|
-
if (this.
|
|
86
|
+
if (this.componentProps.open) this.show();
|
|
52
87
|
}
|
|
53
88
|
|
|
54
|
-
componentDidUpdate({ open }: NativeDialogProps) {
|
|
55
|
-
|
|
89
|
+
componentDidUpdate({ open, modal, scroll }: NativeDialogProps) {
|
|
90
|
+
const modeChanged = this.componentProps.modal !== modal;
|
|
91
|
+
const openChanged = this.componentProps.open !== open;
|
|
92
|
+
const wasOpen = this.open;
|
|
93
|
+
if (!openChanged && !modeChanged && this.componentProps.scroll === scroll) return;
|
|
56
94
|
|
|
57
|
-
if (this.
|
|
95
|
+
if (this.open && this.componentProps.modal !== modal) {
|
|
96
|
+
this.switchingMode = true;
|
|
97
|
+
this.close();
|
|
98
|
+
}
|
|
99
|
+
if (this.componentProps.scroll) this.unlockScroll();
|
|
100
|
+
else if (this.open && this.componentProps.modal !== false) this.lockScroll();
|
|
101
|
+
|
|
102
|
+
if (!openChanged && !modeChanged) return;
|
|
103
|
+
|
|
104
|
+
if (this.componentProps.open || (!openChanged && modeChanged && wasOpen)) this.show();
|
|
58
105
|
else this.close();
|
|
59
106
|
}
|
|
60
107
|
|
|
61
108
|
show = () => {
|
|
109
|
+
clearTimeout(this.closeTimer);
|
|
110
|
+
this.element.current?.classList.remove('hiding');
|
|
62
111
|
if (this.open) return;
|
|
112
|
+
|
|
63
113
|
const element = this.element.current;
|
|
64
114
|
if (!element) return;
|
|
65
|
-
|
|
115
|
+
|
|
116
|
+
if (!this.switchingMode && document.activeElement instanceof HTMLElement)
|
|
66
117
|
this.returnFocus = document.activeElement;
|
|
67
|
-
if (this.
|
|
118
|
+
if (this.componentProps.modal === false) element.show();
|
|
68
119
|
else element.showModal();
|
|
120
|
+
if (this.componentProps.modal !== false && !this.componentProps.scroll) this.lockScroll();
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
lockScroll = () => {
|
|
124
|
+
const { scrollLocks } = NativeDialog;
|
|
125
|
+
|
|
126
|
+
if (!scrollLocks.size) {
|
|
127
|
+
NativeDialog.bodyOverflow = document.body.style.overflow;
|
|
128
|
+
document.body.style.overflow = 'hidden';
|
|
129
|
+
}
|
|
130
|
+
scrollLocks.add(this);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
unlockScroll = () => {
|
|
134
|
+
const { scrollLocks } = NativeDialog;
|
|
135
|
+
|
|
136
|
+
if (!scrollLocks.delete(this)) return;
|
|
137
|
+
if (!scrollLocks.size) document.body.style.overflow = NativeDialog.bodyOverflow;
|
|
69
138
|
};
|
|
70
139
|
|
|
71
140
|
close = () => {
|
|
141
|
+
const element = this.element.current;
|
|
142
|
+
if (!this.open || !element || this.switchingMode) return this.finishClose();
|
|
143
|
+
|
|
144
|
+
const { transitionDuration, transitionDelay } = getComputedStyle(element);
|
|
145
|
+
const durations = transitionDuration.split(',').map(transitionMilliseconds);
|
|
146
|
+
const delays = transitionDelay.split(',').map(transitionMilliseconds);
|
|
147
|
+
const duration = Math.max(
|
|
148
|
+
0,
|
|
149
|
+
...durations.map((value, index) => value + delays[index % delays.length])
|
|
150
|
+
);
|
|
151
|
+
if (!duration) return this.finishClose();
|
|
152
|
+
if (element.classList.contains('hiding')) return;
|
|
153
|
+
|
|
154
|
+
element.classList.add('hiding');
|
|
155
|
+
this.closeTimer = setTimeout(this.finishClose, duration);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
finishClose = () => {
|
|
159
|
+
clearTimeout(this.closeTimer);
|
|
160
|
+
this.element.current?.classList.remove('hiding');
|
|
161
|
+
this.unlockScroll();
|
|
162
|
+
|
|
72
163
|
if (!this.open) return;
|
|
164
|
+
|
|
73
165
|
this.element.current?.close();
|
|
74
166
|
this.returnFocus?.focus();
|
|
75
167
|
};
|
|
76
168
|
|
|
169
|
+
handleClose = (event: SyntheticEvent<HTMLDialogElement>) => {
|
|
170
|
+
if (!this.switchingMode) this.componentProps.onClose?.(event);
|
|
171
|
+
|
|
172
|
+
if (!this.open) {
|
|
173
|
+
this.unlockScroll();
|
|
174
|
+
this.returnFocus?.focus();
|
|
175
|
+
}
|
|
176
|
+
this.switchingMode = false;
|
|
177
|
+
};
|
|
178
|
+
|
|
77
179
|
componentWillUnmount() {
|
|
78
|
-
this.
|
|
180
|
+
this.finishClose();
|
|
79
181
|
}
|
|
80
182
|
|
|
81
183
|
handleCancel = (event: SyntheticEvent<HTMLDialogElement>) => {
|
|
82
|
-
const { onCancel, keyboard = true } = this.
|
|
184
|
+
const { onCancel, keyboard = true } = this.componentProps;
|
|
83
185
|
onCancel?.(event);
|
|
186
|
+
|
|
84
187
|
const { defaultPrevented } = event;
|
|
85
188
|
event.preventDefault();
|
|
189
|
+
|
|
86
190
|
if (keyboard && !defaultPrevented) this.close();
|
|
87
191
|
};
|
|
88
192
|
|
|
89
193
|
handleKeyDown = (event: KeyboardEvent<HTMLDialogElement>) => {
|
|
90
|
-
const { onKeyDown, keyboard = true } = this.
|
|
194
|
+
const { onKeyDown, keyboard = true } = this.componentProps;
|
|
91
195
|
onKeyDown?.(event);
|
|
196
|
+
|
|
92
197
|
const { key, defaultPrevented } = event;
|
|
93
198
|
if (key !== 'Escape' || !keyboard || defaultPrevented) return;
|
|
199
|
+
|
|
94
200
|
event.preventDefault();
|
|
95
201
|
this.close();
|
|
96
202
|
};
|
|
97
203
|
|
|
98
204
|
handleClick = (event: MouseEvent<HTMLDialogElement>) => {
|
|
99
|
-
const { onClick, backdrop = true } = this.
|
|
205
|
+
const { onClick, backdrop = true } = this.componentProps;
|
|
100
206
|
onClick?.(event);
|
|
207
|
+
|
|
101
208
|
const { defaultPrevented, target, currentTarget, clientX, clientY } = event;
|
|
102
209
|
if (backdrop !== true || defaultPrevented || target !== currentTarget) return;
|
|
210
|
+
|
|
103
211
|
const { left, right, top, bottom } = currentTarget.getBoundingClientRect();
|
|
104
212
|
if (clientX < left || clientX > right || clientY < top || clientY > bottom) this.close();
|
|
105
213
|
};
|
|
106
214
|
|
|
107
215
|
render() {
|
|
216
|
+
const Root: ElementType = this.componentProps.as ?? 'dialog';
|
|
217
|
+
|
|
108
218
|
const {
|
|
219
|
+
as: _as,
|
|
109
220
|
open: _open,
|
|
110
221
|
modal: _modal,
|
|
111
222
|
keyboard: _keyboard,
|
|
112
223
|
backdrop = true,
|
|
113
224
|
theme,
|
|
114
225
|
dialog = true,
|
|
226
|
+
size,
|
|
227
|
+
fullscreen,
|
|
228
|
+
scrollable,
|
|
229
|
+
animation = 'fade',
|
|
230
|
+
scroll: _scroll,
|
|
115
231
|
className,
|
|
116
232
|
onCancel: _onCancel,
|
|
117
233
|
onClick: _onClick,
|
|
118
234
|
onKeyDown: _onKeyDown,
|
|
235
|
+
onClose: _onClose,
|
|
119
236
|
...props
|
|
120
|
-
} = this.
|
|
237
|
+
} = this.componentProps;
|
|
121
238
|
|
|
122
239
|
return (
|
|
123
|
-
<
|
|
240
|
+
<Root
|
|
124
241
|
{...props}
|
|
125
242
|
ref={this.element}
|
|
126
243
|
className={classNames(
|
|
127
244
|
dialog && 'dialog',
|
|
245
|
+
dialog && size && `dialog-${size}`,
|
|
246
|
+
dialog &&
|
|
247
|
+
fullscreen &&
|
|
248
|
+
(fullscreen === true
|
|
249
|
+
? 'dialog-fullscreen'
|
|
250
|
+
: `${fullscreen}-down:dialog-fullscreen`),
|
|
251
|
+
dialog && scrollable && 'dialog-scrollable',
|
|
252
|
+
dialog && animation !== 'fade' && `dialog-${animation}`,
|
|
128
253
|
backdrop === false && styles.hiddenBackdrop,
|
|
129
254
|
className
|
|
130
255
|
)}
|
|
@@ -133,6 +258,7 @@ export class NativeDialog extends Component<NativeDialogProps> {
|
|
|
133
258
|
onCancel={this.handleCancel}
|
|
134
259
|
onKeyDown={this.handleKeyDown}
|
|
135
260
|
onClick={this.handleClick}
|
|
261
|
+
onClose={this.handleClose}
|
|
136
262
|
/>
|
|
137
263
|
);
|
|
138
264
|
}
|
package/source/Nav.tsx
CHANGED
|
@@ -1,52 +1,68 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef
|
|
2
|
+
import { ComponentPropsWithRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { polymorphic } from './Polymorphic';
|
|
3
5
|
|
|
4
6
|
export interface NavProps extends ComponentPropsWithRef<'nav'> {
|
|
5
7
|
variant?: 'tabs' | 'pills' | 'underline';
|
|
6
8
|
vertical?: boolean;
|
|
7
9
|
fill?: boolean;
|
|
8
10
|
justified?: boolean;
|
|
11
|
+
cardHeader?: boolean;
|
|
12
|
+
navbar?: boolean;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export const Nav
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export const Nav = polymorphic<NavProps>(
|
|
16
|
+
({
|
|
17
|
+
as: Root = 'nav',
|
|
18
|
+
variant,
|
|
19
|
+
vertical,
|
|
20
|
+
fill,
|
|
21
|
+
justified,
|
|
22
|
+
cardHeader,
|
|
23
|
+
navbar,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}) => (
|
|
27
|
+
<Root
|
|
28
|
+
{...props}
|
|
29
|
+
className={classNames(
|
|
30
|
+
'nav',
|
|
31
|
+
navbar && 'navbar-nav',
|
|
32
|
+
variant && `nav-${variant}`,
|
|
33
|
+
cardHeader && variant === 'tabs' && 'card-header-tabs',
|
|
34
|
+
vertical && (variant === 'pills' ? 'nav-pills-vertical' : 'flex-column'),
|
|
35
|
+
{ 'nav-fill': fill, 'nav-justified': justified },
|
|
36
|
+
className
|
|
37
|
+
)}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
22
40
|
);
|
|
41
|
+
Nav.displayName = 'Nav';
|
|
23
42
|
|
|
24
|
-
export const NavItem
|
|
25
|
-
|
|
43
|
+
export const NavItem = polymorphic<ComponentPropsWithRef<'li'>>(
|
|
44
|
+
({ as: Root = 'li', className, ...props }) => (
|
|
45
|
+
<Root {...props} className={classNames('nav-item', className)} />
|
|
46
|
+
)
|
|
26
47
|
);
|
|
48
|
+
NavItem.displayName = 'NavItem';
|
|
27
49
|
|
|
28
50
|
export interface NavLinkProps extends ComponentPropsWithRef<'a'> {
|
|
29
51
|
disabled?: boolean;
|
|
52
|
+
active?: boolean;
|
|
30
53
|
}
|
|
31
54
|
|
|
32
|
-
export const NavLink
|
|
33
|
-
disabled,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
aria-disabled={disabled || undefined}
|
|
45
|
-
className={classNames('nav-link', { disabled, 'pe-none': disabled }, className)}
|
|
46
|
-
onClick={disabled ? undefined : onClick}
|
|
47
|
-
/>
|
|
55
|
+
export const NavLink = polymorphic<NavLinkProps>(
|
|
56
|
+
({ as: Root = 'a', disabled, active, className, href, onClick, tabIndex, ...props }) => (
|
|
57
|
+
<Root
|
|
58
|
+
{...props}
|
|
59
|
+
href={disabled ? undefined : href}
|
|
60
|
+
tabIndex={disabled ? -1 : tabIndex}
|
|
61
|
+
aria-disabled={disabled || undefined}
|
|
62
|
+
aria-current={active ? 'page' : props['aria-current']}
|
|
63
|
+
className={classNames('nav-link', { active, disabled, 'pe-none': disabled }, className)}
|
|
64
|
+
onClick={disabled ? undefined : onClick}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
48
67
|
);
|
|
49
|
-
|
|
50
|
-
Nav.displayName = 'Nav';
|
|
51
|
-
NavItem.displayName = 'NavItem';
|
|
52
68
|
NavLink.displayName = 'NavLink';
|