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
package/source/Form/Range.tsx
CHANGED
|
@@ -1,65 +1,134 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import type Range from 'bootstrap/js/src/range.js';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
import { ComponentPropsWithoutRef, CSSProperties, forwardRef, Ref } from 'react';
|
|
6
|
+
|
|
7
|
+
import { ComponentTheme } from '../Button';
|
|
8
|
+
import { AsProps, polymorphic } from '../Polymorphic';
|
|
9
|
+
import { FormPlugin } from './Plugin';
|
|
10
|
+
import { FormValidationProps } from './Primitives';
|
|
11
|
+
|
|
12
|
+
export type FormRangeProps = Omit<ComponentPropsWithoutRef<'input'>, 'type'> &
|
|
13
|
+
FormValidationProps & {
|
|
14
|
+
bubble?: boolean;
|
|
15
|
+
theme?: ComponentTheme;
|
|
16
|
+
formatter?: (value: number) => string;
|
|
17
|
+
wrapperClassName?: string;
|
|
18
|
+
onValueChange?: (value: number) => unknown;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface FormRangeComponentProps extends FormRangeProps, AsProps {
|
|
22
|
+
forwardedRef?: Ref<HTMLElement>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class FormRangeComponent extends FormPlugin<FormRangeComponentProps, Range> {
|
|
26
|
+
protected configurationChanged = (previous: FormRangeComponentProps) =>
|
|
27
|
+
previous.bubble !== this.props.bubble ||
|
|
28
|
+
previous.formatter !== this.props.formatter ||
|
|
29
|
+
previous.list !== this.props.list ||
|
|
30
|
+
previous.min !== this.props.min ||
|
|
31
|
+
previous.max !== this.props.max;
|
|
32
|
+
|
|
33
|
+
protected load = async () => {
|
|
34
|
+
const { default: Plugin } = await import('bootstrap/js/src/range.js');
|
|
35
|
+
const { bubble = false, formatter = null } = this.props;
|
|
36
|
+
|
|
37
|
+
return (element: HTMLDivElement) => {
|
|
38
|
+
element.addEventListener('changed.bs.range', this.handleValueChange);
|
|
39
|
+
|
|
40
|
+
return Plugin.getOrCreateInstance(element, { bubble, formatter });
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
protected updatePlugin = () => this.instance?.update();
|
|
45
|
+
|
|
46
|
+
protected dispose() {
|
|
47
|
+
this.element.current?.removeEventListener('changed.bs.range', this.handleValueChange);
|
|
48
|
+
super.dispose();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private handleValueChange = (event: Event) =>
|
|
52
|
+
this.props.onValueChange?.((event as Event & { value: number }).value);
|
|
53
|
+
|
|
54
|
+
private forwardRef = (element: HTMLElement | null) => {
|
|
55
|
+
const { forwardedRef } = this.props;
|
|
38
56
|
|
|
39
|
-
|
|
57
|
+
if (typeof forwardedRef === 'function') forwardedRef(element);
|
|
58
|
+
else if (forwardedRef) forwardedRef.current = element;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
private setRootRef = (element: HTMLDivElement | null) => {
|
|
62
|
+
this.element.current = element;
|
|
40
63
|
|
|
41
|
-
|
|
64
|
+
if (this.props.as) this.forwardRef(element);
|
|
42
65
|
};
|
|
43
66
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
render() {
|
|
68
|
+
const {
|
|
69
|
+
as: Root = 'div',
|
|
70
|
+
className,
|
|
71
|
+
wrapperClassName,
|
|
72
|
+
min = 0,
|
|
73
|
+
max = 100,
|
|
74
|
+
value,
|
|
75
|
+
defaultValue,
|
|
76
|
+
bubble,
|
|
77
|
+
theme,
|
|
78
|
+
formatter: _formatter,
|
|
79
|
+
onValueChange: _onValueChange,
|
|
80
|
+
forwardedRef: _forwardedRef,
|
|
81
|
+
validation,
|
|
82
|
+
style,
|
|
83
|
+
...props
|
|
84
|
+
} = this.props;
|
|
85
|
+
const currentValue = Number(value ?? defaultValue ?? (Number(min) + Number(max)) / 2);
|
|
86
|
+
const fill =
|
|
87
|
+
Number(max) <= Number(min)
|
|
88
|
+
? 0
|
|
89
|
+
: Math.max(
|
|
90
|
+
0,
|
|
91
|
+
Math.min(1, (currentValue - Number(min)) / (Number(max) - Number(min)))
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Root
|
|
96
|
+
{...(this.props.as ? props : {})}
|
|
97
|
+
ref={this.setRootRef}
|
|
98
|
+
className={classNames(
|
|
99
|
+
'form-range',
|
|
100
|
+
theme && `theme-${theme}`,
|
|
101
|
+
validation && `is-${validation}`,
|
|
102
|
+
wrapperClassName
|
|
103
|
+
)}
|
|
104
|
+
data-bs-bubble={bubble || undefined}
|
|
105
|
+
style={{ '--bs-range-fill': fill } as CSSProperties}
|
|
106
|
+
>
|
|
107
|
+
<input
|
|
108
|
+
{...(this.props.as ? {} : props)}
|
|
109
|
+
ref={this.props.as ? undefined : this.forwardRef}
|
|
110
|
+
name={props.name}
|
|
111
|
+
type="range"
|
|
112
|
+
min={min}
|
|
113
|
+
max={max}
|
|
114
|
+
value={value}
|
|
115
|
+
defaultValue={defaultValue}
|
|
116
|
+
aria-invalid={validation ? validation === 'invalid' : props['aria-invalid']}
|
|
117
|
+
className={classNames(
|
|
118
|
+
'form-range-input',
|
|
119
|
+
validation && `is-${validation}`,
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
style={style}
|
|
123
|
+
/>
|
|
124
|
+
</Root>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
64
128
|
|
|
129
|
+
export const FormRange = polymorphic<FormRangeProps & { ref?: Ref<HTMLInputElement> }>(
|
|
130
|
+
forwardRef<HTMLInputElement, FormRangeProps & AsProps>((props, forwardedRef) => (
|
|
131
|
+
<FormRangeComponent {...props} forwardedRef={forwardedRef} />
|
|
132
|
+
))
|
|
133
|
+
);
|
|
65
134
|
FormRange.displayName = 'FormRange';
|
package/source/Form/Switch.tsx
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { ComponentPropsWithRef,
|
|
2
|
+
import { ComponentPropsWithRef, CSSProperties, PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
4
|
import type { ComponentTheme } from '../Button';
|
|
5
|
+
import { polymorphic } from '../Polymorphic';
|
|
6
|
+
import { FormValidationProps } from './Primitives';
|
|
5
7
|
|
|
6
8
|
export type FormSwitchProps = Omit<ComponentPropsWithRef<'label'>, 'children'> &
|
|
7
|
-
PropsWithChildren<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
PropsWithChildren<
|
|
10
|
+
FormValidationProps & {
|
|
11
|
+
inputProps?: Omit<ComponentPropsWithRef<'input'>, 'type'>;
|
|
12
|
+
size?: 'sm' | 'lg';
|
|
13
|
+
theme?: ComponentTheme;
|
|
14
|
+
width?: string;
|
|
15
|
+
indicatorWidth?: string;
|
|
16
|
+
}
|
|
17
|
+
>;
|
|
12
18
|
|
|
13
|
-
export const FormSwitch
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
export const FormSwitch = polymorphic<FormSwitchProps>(
|
|
20
|
+
({
|
|
21
|
+
as: Root = 'label',
|
|
22
|
+
className,
|
|
23
|
+
inputProps,
|
|
24
|
+
size,
|
|
25
|
+
theme,
|
|
26
|
+
validation,
|
|
27
|
+
width,
|
|
28
|
+
indicatorWidth,
|
|
29
|
+
style,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}) => (
|
|
33
|
+
<Root
|
|
34
|
+
{...props}
|
|
35
|
+
className={classNames(
|
|
36
|
+
'switch',
|
|
37
|
+
size && `switch-${size}`,
|
|
38
|
+
theme && `theme-${theme}`,
|
|
39
|
+
validation && `is-${validation}`,
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
style={
|
|
43
|
+
{
|
|
44
|
+
'--bs-switch-width': width,
|
|
45
|
+
'--bs-switch-indicator-width': indicatorWidth,
|
|
46
|
+
...style
|
|
47
|
+
} as CSSProperties
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<input
|
|
51
|
+
role="switch"
|
|
52
|
+
{...inputProps}
|
|
53
|
+
type="checkbox"
|
|
54
|
+
aria-invalid={validation ? validation === 'invalid' : inputProps?.['aria-invalid']}
|
|
55
|
+
className={classNames(validation && `is-${validation}`, inputProps?.className)}
|
|
56
|
+
/>
|
|
57
|
+
{children}
|
|
58
|
+
</Root>
|
|
59
|
+
)
|
|
33
60
|
);
|
|
34
|
-
|
|
35
61
|
FormSwitch.displayName = 'FormSwitch';
|
package/source/Form/index.ts
CHANGED
package/source/Grid.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
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 type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
5
7
|
export type ColSize = number | 'auto';
|
|
@@ -10,15 +12,18 @@ export interface ContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
10
12
|
breakpoint?: Breakpoint;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const Container
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export const Container = polymorphic<ContainerProps>(
|
|
16
|
+
({ as: Root = 'div', fluid, breakpoint, className, ...props }) => (
|
|
17
|
+
<Root
|
|
18
|
+
{...props}
|
|
19
|
+
className={classNames(
|
|
20
|
+
breakpoint ? `${breakpoint}:container` : fluid ? 'container-fluid' : 'container',
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
21
25
|
);
|
|
26
|
+
Container.displayName = 'Container';
|
|
22
27
|
|
|
23
28
|
export type RowCols = number | 'auto';
|
|
24
29
|
|
|
@@ -31,29 +36,33 @@ export interface RowProps extends ComponentPropsWithRef<'div'> {
|
|
|
31
36
|
'2xl'?: RowCols;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
export const Row
|
|
35
|
-
|
|
36
|
-
[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
export const Row = polymorphic<RowProps>(
|
|
40
|
+
({ as: Root = 'div', cols, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
41
|
+
const sizes: [Breakpoint, RowCols | undefined][] = [
|
|
42
|
+
['sm', sm],
|
|
43
|
+
['md', md],
|
|
44
|
+
['lg', lg],
|
|
45
|
+
['xl', xl],
|
|
46
|
+
['2xl', xxl]
|
|
47
|
+
];
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
return (
|
|
50
|
+
<Root
|
|
51
|
+
{...props}
|
|
52
|
+
className={classNames(
|
|
53
|
+
'row',
|
|
54
|
+
cols !== undefined && `row-cols-${cols}`,
|
|
55
|
+
sizes.map(
|
|
56
|
+
([breakpoint, size]) =>
|
|
57
|
+
size !== undefined && `${breakpoint}:row-cols-${size}`
|
|
58
|
+
),
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
Row.displayName = 'Row';
|
|
57
66
|
|
|
58
67
|
export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
59
68
|
span?: ColSize;
|
|
@@ -64,29 +73,32 @@ export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
|
64
73
|
'2xl'?: BreakpointColSize;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
export const Col
|
|
68
|
-
|
|
69
|
-
[
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
export const Col = polymorphic<ColProps>(
|
|
77
|
+
({ as: Root = 'div', span, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
78
|
+
const sizes: [Breakpoint, BreakpointColSize | undefined][] = [
|
|
79
|
+
['sm', sm],
|
|
80
|
+
['md', md],
|
|
81
|
+
['lg', lg],
|
|
82
|
+
['xl', xl],
|
|
83
|
+
['2xl', xxl]
|
|
84
|
+
];
|
|
85
|
+
const sized = sizes.some(([, size]) => size !== undefined);
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
87
|
+
return (
|
|
88
|
+
<Root
|
|
89
|
+
{...props}
|
|
90
|
+
className={classNames(
|
|
91
|
+
!span && !sized && 'col',
|
|
92
|
+
span !== undefined && `col-${span}`,
|
|
93
|
+
sizes.map(
|
|
94
|
+
([breakpoint, size]) =>
|
|
95
|
+
size !== undefined &&
|
|
96
|
+
(size === true ? `${breakpoint}:col` : `${breakpoint}:col-${size}`)
|
|
97
|
+
),
|
|
98
|
+
className
|
|
99
|
+
)}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
Col.displayName = 'Col';
|
package/source/Image.tsx
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
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 ImageProps extends ComponentPropsWithRef<'img'> {
|
|
5
7
|
fluid?: boolean;
|
|
6
8
|
thumbnail?: boolean;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export const Image
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export const Image = polymorphic<ImageProps>(
|
|
12
|
+
({ as: Root = 'img', fluid, thumbnail, className, ...props }) => (
|
|
13
|
+
<Root
|
|
14
|
+
{...props}
|
|
15
|
+
className={classNames({ 'img-fluid': fluid, 'img-thumbnail': thumbnail }, className)}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
14
18
|
);
|
|
15
19
|
Image.displayName = 'Image';
|
package/source/ListGroup.tsx
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
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 type { Breakpoint } from './Grid';
|
|
6
|
+
import { polymorphic } from './Polymorphic';
|
|
6
7
|
|
|
7
8
|
export type ListGroupHorizontal = boolean | Breakpoint;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
interface ListGroupStyleProps {
|
|
10
11
|
flush?: boolean;
|
|
11
12
|
numbered?: boolean;
|
|
12
13
|
horizontal?: ListGroupHorizontal;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
export type ListGroupProps = ListGroupStyleProps &
|
|
17
|
+
(
|
|
18
|
+
| (ComponentPropsWithRef<'ul'> & { as?: 'ul' })
|
|
19
|
+
| (ComponentPropsWithRef<'ol'> & { as: 'ol' })
|
|
20
|
+
| (ComponentPropsWithRef<'div'> & { as: 'div' })
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const ListGroup = polymorphic<ListGroupStyleProps & ComponentPropsWithRef<'ul'>>(
|
|
24
|
+
({ as: Root = 'ul', flush, numbered, horizontal, className, ...props }) => {
|
|
25
|
+
const classes = classNames(
|
|
25
26
|
'list-group',
|
|
26
27
|
{ 'list-group-flush': flush, 'list-group-numbered': numbered },
|
|
27
28
|
horizontal &&
|
|
@@ -29,9 +30,12 @@ export const ListGroup: FC<ListGroupProps> = ({
|
|
|
29
30
|
? 'list-group-horizontal'
|
|
30
31
|
: `${horizontal}:list-group-horizontal`),
|
|
31
32
|
className
|
|
32
|
-
)
|
|
33
|
-
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return <Root {...props} className={classes} />;
|
|
36
|
+
}
|
|
34
37
|
);
|
|
38
|
+
ListGroup.displayName = 'ListGroup';
|
|
35
39
|
|
|
36
40
|
interface ListGroupItemStyleProps {
|
|
37
41
|
theme?: ComponentTheme;
|
|
@@ -54,50 +58,47 @@ const isLink = (props: ListGroupItemElementAttributes): props is ListGroupItemLi
|
|
|
54
58
|
const isButton = (props: ListGroupItemElementAttributes): props is ListGroupItemButtonAttributes =>
|
|
55
59
|
typeof props.type === 'string';
|
|
56
60
|
|
|
57
|
-
export const ListGroupItem
|
|
58
|
-
theme,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
className,
|
|
63
|
-
...props
|
|
64
|
-
}) => {
|
|
65
|
-
const classes = classNames(
|
|
66
|
-
'list-group-item',
|
|
67
|
-
theme && `theme-${theme}`,
|
|
68
|
-
action && 'list-group-item-action',
|
|
69
|
-
{ active, disabled },
|
|
70
|
-
disabled && 'pe-none',
|
|
71
|
-
className
|
|
72
|
-
);
|
|
61
|
+
export const ListGroupItem = polymorphic<ListGroupItemProps>(
|
|
62
|
+
({ as: RootAs, theme, action, active, disabled, className, ...props }) => {
|
|
63
|
+
const Root = RootAs ?? 'a';
|
|
64
|
+
const Root1 = RootAs ?? 'button';
|
|
65
|
+
const Root2 = RootAs ?? 'li';
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
onClick={disabled ? undefined : props.onClick}
|
|
83
|
-
/>
|
|
84
|
-
) : isButton(props) ? (
|
|
85
|
-
<button
|
|
86
|
-
{...props}
|
|
87
|
-
type={props.type || 'button'}
|
|
88
|
-
className={classes}
|
|
89
|
-
aria-current={active ? 'true' : undefined}
|
|
90
|
-
disabled={disabled}
|
|
91
|
-
/>
|
|
92
|
-
) : (
|
|
93
|
-
<li
|
|
94
|
-
{...(props as ListGroupItemAttributes)}
|
|
95
|
-
className={classes}
|
|
96
|
-
aria-current={active ? 'true' : undefined}
|
|
97
|
-
aria-disabled={disabled || undefined}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
67
|
+
const classes = classNames(
|
|
68
|
+
'list-group-item',
|
|
69
|
+
theme && `theme-${theme}`,
|
|
70
|
+
action && 'list-group-item-action',
|
|
71
|
+
{ active, disabled },
|
|
72
|
+
disabled && 'pe-none',
|
|
73
|
+
className
|
|
74
|
+
);
|
|
101
75
|
|
|
102
|
-
|
|
76
|
+
return isLink(props) ? (
|
|
77
|
+
<Root
|
|
78
|
+
{...props}
|
|
79
|
+
className={classes}
|
|
80
|
+
href={disabled ? undefined : props.href}
|
|
81
|
+
aria-current={active ? 'true' : undefined}
|
|
82
|
+
aria-disabled={disabled || undefined}
|
|
83
|
+
tabIndex={disabled ? -1 : props.tabIndex}
|
|
84
|
+
onClick={disabled ? undefined : props.onClick}
|
|
85
|
+
/>
|
|
86
|
+
) : isButton(props) ? (
|
|
87
|
+
<Root1
|
|
88
|
+
{...props}
|
|
89
|
+
type={props.type || 'button'}
|
|
90
|
+
className={classes}
|
|
91
|
+
aria-current={active ? 'true' : undefined}
|
|
92
|
+
disabled={disabled}
|
|
93
|
+
/>
|
|
94
|
+
) : (
|
|
95
|
+
<Root2
|
|
96
|
+
{...(props as ListGroupItemAttributes)}
|
|
97
|
+
className={classes}
|
|
98
|
+
aria-current={active ? 'true' : undefined}
|
|
99
|
+
aria-disabled={disabled || undefined}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
103
104
|
ListGroupItem.displayName = 'ListGroupItem';
|