idea-react 3.0.0-alpha.0 → 3.0.0-beta.0
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 +31 -10
- package/ReadMe.md +75 -41
- package/dist/index.d.mts +451 -100
- package/dist/index.d.ts +451 -100
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +5 -5
- package/package.json +7 -8
- package/source/Avatar.tsx +65 -12
- package/source/Button.tsx +13 -4
- package/source/ButtonGroup.tsx +28 -0
- package/source/Card.tsx +34 -0
- package/source/ClickBoundary.tsx +6 -5
- package/source/CloseButton.tsx +23 -0
- package/source/CodeBlock.tsx +5 -3
- package/source/Countdown.tsx +2 -0
- package/source/Drawer.tsx +62 -0
- package/source/Editor.tsx +5 -8
- package/source/Form/Adorn.tsx +38 -0
- package/source/Form/Checkbox.tsx +73 -0
- package/source/Form/Chips.tsx +51 -0
- package/source/Form/Combobox.tsx +109 -0
- package/source/Form/Control.tsx +59 -0
- package/source/Form/DatePicker.tsx +89 -0
- package/source/Form/Feedback.tsx +29 -0
- package/source/Form/FloatingLabel.tsx +15 -0
- package/source/Form/InputGroup.tsx +23 -0
- package/source/Form/OTP.tsx +48 -0
- package/source/Form/PasswordStrength.tsx +157 -0
- package/source/Form/Primitives.tsx +46 -0
- package/source/Form/Radio.tsx +51 -0
- package/source/Form/Range.tsx +65 -0
- package/source/Form/Switch.tsx +35 -0
- package/source/Form/index.ts +15 -0
- package/source/Grid.tsx +92 -0
- package/source/HorizontalMarquee/index.tsx +4 -10
- package/source/Image.tsx +15 -0
- package/source/ListGroup.tsx +103 -0
- package/source/LiveTSX.tsx +1 -1
- package/source/Loading.tsx +4 -3
- package/source/Menu.tsx +99 -1
- package/source/MonthCalendar.tsx +60 -22
- package/source/NativeDialog/index.tsx +37 -1
- package/source/Nav.tsx +52 -0
- package/source/Navbar.tsx +58 -1
- package/source/Overlay.ts +22 -0
- package/source/OverlayBox.tsx +200 -32
- package/source/PageNav.tsx +56 -32
- package/source/Popover.tsx +36 -0
- package/source/ScrollNav/Scroller.tsx +107 -0
- package/source/ScrollNav/index.tsx +12 -99
- package/source/Select.tsx +66 -55
- package/source/ShareBox.tsx +5 -11
- package/source/Spinner.tsx +30 -0
- package/source/SpinnerButton.tsx +8 -10
- package/source/Table.tsx +59 -0
- package/source/TableSpinner.tsx +7 -5
- package/source/{TextTruncate.tsx → TextTruncate/Content.tsx} +24 -20
- package/source/TextTruncate/index.tsx +25 -0
- package/source/Time.tsx +7 -33
- package/source/TimeDistance.tsx +1 -1
- package/source/Timeline/index.tsx +7 -7
- package/source/Toast.tsx +120 -29
- package/source/ToggleButton.tsx +47 -0
- package/source/Tooltip.tsx +32 -0
- package/source/TypeEcho/Content.tsx +58 -0
- package/source/TypeEcho/index.tsx +14 -0
- package/source/UserRank/index.module.less +9 -20
- package/source/UserRank/index.tsx +35 -32
- package/source/VerticalMarquee/index.module.less +0 -1
- package/source/VerticalMarquee/index.tsx +3 -5
- package/source/ZodiacBar.tsx +1 -1
- package/source/animate.ts +4 -2
- package/source/color.ts +3 -5
- package/source/index.ts +14 -0
- package/source/TypeEcho.tsx +0 -49
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export type FormFloatingLabelProps = ComponentPropsWithRef<'div'> & {
|
|
5
|
+
always?: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const FormFloatingLabel: FC<FormFloatingLabelProps> = ({ className, always, ...props }) => (
|
|
9
|
+
<div
|
|
10
|
+
{...props}
|
|
11
|
+
className={classNames('form-floating', always && 'form-floating-always', className)}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
FormFloatingLabel.displayName = 'FormFloatingLabel';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export type InputGroupProps = ComponentPropsWithRef<'div'> & {
|
|
5
|
+
size?: 'sm' | 'lg';
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const InputGroup: FC<InputGroupProps> = ({ className, size, ...props }) => (
|
|
9
|
+
<div
|
|
10
|
+
{...props}
|
|
11
|
+
className={classNames('input-group', size && `input-group-${size}`, className)}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
InputGroup.displayName = 'InputGroup';
|
|
16
|
+
|
|
17
|
+
export type InputGroupTextProps = ComponentPropsWithRef<'span'>;
|
|
18
|
+
|
|
19
|
+
export const InputGroupText: FC<InputGroupTextProps> = ({ className, ...props }) => (
|
|
20
|
+
<span {...props} className={classNames('input-group-text', className)} />
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
InputGroupText.displayName = 'InputGroupText';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export type OTPInputProps = Omit<ComponentPropsWithRef<'input'>, 'type' | 'maxLength'> & {
|
|
5
|
+
length: number;
|
|
6
|
+
type?: 'numeric' | 'alphanumeric' | 'alpha';
|
|
7
|
+
mask?: boolean;
|
|
8
|
+
groups?: number[];
|
|
9
|
+
separator?: string;
|
|
10
|
+
connected?: boolean;
|
|
11
|
+
size?: 'sm' | 'lg';
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const OTPInput: FC<OTPInputProps> = ({
|
|
15
|
+
className,
|
|
16
|
+
length,
|
|
17
|
+
type = 'numeric',
|
|
18
|
+
mask,
|
|
19
|
+
groups,
|
|
20
|
+
separator,
|
|
21
|
+
connected,
|
|
22
|
+
size,
|
|
23
|
+
...props
|
|
24
|
+
}) => (
|
|
25
|
+
<div
|
|
26
|
+
className={classNames('otp', connected && 'otp-connected', size && `otp-${size}`)}
|
|
27
|
+
data-bs-otp=""
|
|
28
|
+
data-bs-length={length}
|
|
29
|
+
data-bs-type={type}
|
|
30
|
+
data-bs-mask={mask || undefined}
|
|
31
|
+
data-bs-groups={groups ? JSON.stringify(groups) : undefined}
|
|
32
|
+
data-bs-separator={separator}
|
|
33
|
+
>
|
|
34
|
+
<input
|
|
35
|
+
{...props}
|
|
36
|
+
type="text"
|
|
37
|
+
maxLength={length}
|
|
38
|
+
autoComplete={props.autoComplete || 'one-time-code'}
|
|
39
|
+
inputMode={type === 'numeric' ? 'numeric' : 'text'}
|
|
40
|
+
pattern={
|
|
41
|
+
type === 'numeric' ? '[0-9]*' : type === 'alpha' ? '[a-zA-Z]*' : '[a-zA-Z0-9]*'
|
|
42
|
+
}
|
|
43
|
+
className={classNames('otp-input', className)}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
OTPInput.displayName = 'OTPInput';
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Component, ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
|
|
5
|
+
|
|
6
|
+
export type PasswordStrengthLevel = 'weak' | 'fair' | 'good' | 'strong';
|
|
7
|
+
|
|
8
|
+
export interface PasswordStrengthProps extends ComponentPropsWithoutRef<'div'> {
|
|
9
|
+
input?: string | HTMLInputElement | null;
|
|
10
|
+
variant?: 'segments' | 'bar';
|
|
11
|
+
minLength?: number;
|
|
12
|
+
messages?: Partial<Record<PasswordStrengthLevel, string>>;
|
|
13
|
+
weights?: Record<string, number>;
|
|
14
|
+
thresholds?: number[];
|
|
15
|
+
scorer?: (password: string) => number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface PasswordStrengthComponentProps extends PasswordStrengthProps {
|
|
19
|
+
forwardedRef?: Ref<HTMLDivElement>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface StrengthInstance {
|
|
23
|
+
dispose(): void;
|
|
24
|
+
getStrength(): string | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const levels: PasswordStrengthLevel[] = ['weak', 'fair', 'good', 'strong'];
|
|
28
|
+
|
|
29
|
+
class PasswordStrengthComponent extends Component<PasswordStrengthComponentProps> {
|
|
30
|
+
private meter?: HTMLDivElement;
|
|
31
|
+
private instance?: StrengthInstance;
|
|
32
|
+
private instanceElement?: HTMLDivElement;
|
|
33
|
+
private passwordInput?: HTMLInputElement;
|
|
34
|
+
private mounted = false;
|
|
35
|
+
|
|
36
|
+
componentDidMount() {
|
|
37
|
+
this.mounted = true;
|
|
38
|
+
this.initialize();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
componentDidUpdate(previousProps: PasswordStrengthProps) {
|
|
42
|
+
if (
|
|
43
|
+
previousProps.input !== this.props.input ||
|
|
44
|
+
previousProps.minLength !== this.props.minLength ||
|
|
45
|
+
previousProps.messages !== this.props.messages ||
|
|
46
|
+
previousProps.weights !== this.props.weights ||
|
|
47
|
+
previousProps.thresholds !== this.props.thresholds ||
|
|
48
|
+
previousProps.scorer !== this.props.scorer ||
|
|
49
|
+
previousProps.variant !== this.props.variant
|
|
50
|
+
) {
|
|
51
|
+
this.dispose();
|
|
52
|
+
this.initialize();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
componentWillUnmount() {
|
|
57
|
+
this.mounted = false;
|
|
58
|
+
this.dispose();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private initialize = async () => {
|
|
62
|
+
const element = this.meter;
|
|
63
|
+
if (!element) return;
|
|
64
|
+
|
|
65
|
+
const { default: Strength } = await import('bootstrap/js/src/strength.js');
|
|
66
|
+
const { input, minLength, messages, weights, thresholds, scorer } = this.props;
|
|
67
|
+
const config = {
|
|
68
|
+
...(input !== undefined && { input }),
|
|
69
|
+
...(minLength !== undefined && { minLength }),
|
|
70
|
+
...(messages !== undefined && {
|
|
71
|
+
messages: { ...Strength.Default.messages, ...messages }
|
|
72
|
+
}),
|
|
73
|
+
...(weights !== undefined && { weights }),
|
|
74
|
+
...(thresholds !== undefined && { thresholds }),
|
|
75
|
+
...(scorer !== undefined && { scorer })
|
|
76
|
+
};
|
|
77
|
+
if (!this.mounted || this.meter !== element) return;
|
|
78
|
+
|
|
79
|
+
this.instanceElement = element;
|
|
80
|
+
this.instance = Strength.getOrCreateInstance(element, config);
|
|
81
|
+
this.passwordInput =
|
|
82
|
+
typeof input === 'string'
|
|
83
|
+
? document.querySelector<HTMLInputElement>(input) || undefined
|
|
84
|
+
: input ||
|
|
85
|
+
element.parentElement?.querySelector<HTMLInputElement>(
|
|
86
|
+
'input[type="password"]'
|
|
87
|
+
) ||
|
|
88
|
+
undefined;
|
|
89
|
+
this.passwordInput?.addEventListener('input', this.handleInput);
|
|
90
|
+
this.passwordInput?.addEventListener('change', this.handleInput);
|
|
91
|
+
this.handleInput();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
private handleInput = () => {
|
|
95
|
+
const strength = this.instance?.getStrength();
|
|
96
|
+
const levelIndex = strength ? levels.indexOf(strength as PasswordStrengthLevel) + 1 : 0;
|
|
97
|
+
const element = this.instanceElement;
|
|
98
|
+
|
|
99
|
+
element?.setAttribute('aria-valuenow', String(levelIndex));
|
|
100
|
+
element?.setAttribute('aria-valuetext', strength || 'Empty');
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
private dispose = () => {
|
|
104
|
+
this.passwordInput?.removeEventListener('input', this.handleInput);
|
|
105
|
+
this.passwordInput?.removeEventListener('change', this.handleInput);
|
|
106
|
+
this.instance?.dispose();
|
|
107
|
+
this.instance = undefined;
|
|
108
|
+
this.instanceElement = undefined;
|
|
109
|
+
this.passwordInput = undefined;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
private setMeterRef = (element: HTMLDivElement | null) => {
|
|
113
|
+
this.meter = element || undefined;
|
|
114
|
+
const { forwardedRef } = this.props;
|
|
115
|
+
|
|
116
|
+
if (typeof forwardedRef === 'function') forwardedRef(element);
|
|
117
|
+
else if (forwardedRef) forwardedRef.current = element;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
render() {
|
|
121
|
+
const {
|
|
122
|
+
className,
|
|
123
|
+
input: _input,
|
|
124
|
+
minLength: _minLength,
|
|
125
|
+
messages: _messages,
|
|
126
|
+
weights: _weights,
|
|
127
|
+
thresholds: _thresholds,
|
|
128
|
+
scorer: _scorer,
|
|
129
|
+
forwardedRef: _forwardedRef,
|
|
130
|
+
variant = 'segments',
|
|
131
|
+
...props
|
|
132
|
+
} = this.props;
|
|
133
|
+
const isBar = variant === 'bar';
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div
|
|
137
|
+
{...props}
|
|
138
|
+
ref={this.setMeterRef}
|
|
139
|
+
className={classNames(isBar ? 'strength-bar' : 'strength', className)}
|
|
140
|
+
role="meter"
|
|
141
|
+
aria-valuemin={0}
|
|
142
|
+
aria-valuemax={levels.length}
|
|
143
|
+
aria-valuenow={0}
|
|
144
|
+
aria-valuetext="Empty"
|
|
145
|
+
>
|
|
146
|
+
{!isBar && levels.map(level => <div key={level} className="strength-segment" />)}
|
|
147
|
+
{!isBar && <span className="strength-text" />}
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export const PasswordStrength = forwardRef<HTMLDivElement, PasswordStrengthProps>(
|
|
154
|
+
(props, forwardedRef) => <PasswordStrengthComponent {...props} forwardedRef={forwardedRef} />
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
PasswordStrength.displayName = 'PasswordStrength';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export type FormProps = ComponentPropsWithRef<'form'>;
|
|
5
|
+
|
|
6
|
+
export const Form: FC<FormProps> = props => <form {...props} />;
|
|
7
|
+
|
|
8
|
+
Form.displayName = 'Form';
|
|
9
|
+
|
|
10
|
+
export type FormFieldsetProps = ComponentPropsWithRef<'fieldset'>;
|
|
11
|
+
|
|
12
|
+
export const FormFieldset: FC<FormFieldsetProps> = props => <fieldset {...props} />;
|
|
13
|
+
|
|
14
|
+
FormFieldset.displayName = 'FormFieldset';
|
|
15
|
+
|
|
16
|
+
export type FormFieldProps = ComponentPropsWithRef<'div'>;
|
|
17
|
+
|
|
18
|
+
export const FormField: FC<FormFieldProps> = ({ className, ...props }) => (
|
|
19
|
+
<div {...props} className={classNames('form-field', className)} />
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
FormField.displayName = 'FormField';
|
|
23
|
+
|
|
24
|
+
export type FormGroupProps = ComponentPropsWithRef<'div'>;
|
|
25
|
+
|
|
26
|
+
export const FormGroup: FC<FormGroupProps> = ({ className, ...props }) => (
|
|
27
|
+
<div {...props} className={classNames('form-group', className)} />
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
FormGroup.displayName = 'FormGroup';
|
|
31
|
+
|
|
32
|
+
export type FormFieldContentProps = ComponentPropsWithRef<'div'>;
|
|
33
|
+
|
|
34
|
+
export const FormFieldContent: FC<FormFieldContentProps> = ({ className, ...props }) => (
|
|
35
|
+
<div {...props} className={classNames('form-field-content', className)} />
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
FormFieldContent.displayName = 'FormFieldContent';
|
|
39
|
+
|
|
40
|
+
export type FormLabelProps = ComponentPropsWithRef<'label'>;
|
|
41
|
+
|
|
42
|
+
export const FormLabel: FC<FormLabelProps> = ({ className, ...props }) => (
|
|
43
|
+
<label {...props} className={classNames('form-label', className)} />
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
FormLabel.displayName = 'FormLabel';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ComponentTheme } from '../Button';
|
|
5
|
+
|
|
6
|
+
export type RadioProps = Omit<ComponentPropsWithRef<'input'>, 'type' | 'size'> & {
|
|
7
|
+
size?: 'sm' | 'lg';
|
|
8
|
+
theme?: ComponentTheme;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Radio: FC<RadioProps> = ({ className, size, theme, ...props }) => (
|
|
12
|
+
<input
|
|
13
|
+
{...props}
|
|
14
|
+
type="radio"
|
|
15
|
+
className={classNames(
|
|
16
|
+
'radio',
|
|
17
|
+
size && `radio-${size}`,
|
|
18
|
+
theme && `theme-${theme}`,
|
|
19
|
+
className
|
|
20
|
+
)}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
Radio.displayName = 'Radio';
|
|
25
|
+
|
|
26
|
+
export type FormCheckProps = Omit<ComponentPropsWithRef<'input'>, 'type' | 'size'> & {
|
|
27
|
+
type?: 'checkbox' | 'radio';
|
|
28
|
+
size?: 'sm' | 'lg';
|
|
29
|
+
theme?: ComponentTheme;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const FormCheck: FC<FormCheckProps> = ({
|
|
33
|
+
className,
|
|
34
|
+
type = 'checkbox',
|
|
35
|
+
size,
|
|
36
|
+
theme,
|
|
37
|
+
...props
|
|
38
|
+
}) => (
|
|
39
|
+
<input
|
|
40
|
+
{...props}
|
|
41
|
+
type={type}
|
|
42
|
+
className={classNames(
|
|
43
|
+
type === 'checkbox' ? 'check' : 'radio',
|
|
44
|
+
size && `${type === 'checkbox' ? 'check' : 'radio'}-${size}`,
|
|
45
|
+
theme && `theme-${theme}`,
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
FormCheck.displayName = 'FormCheck';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { ComponentPropsWithRef, CSSProperties, FC, InputEvent } from 'react';
|
|
5
|
+
|
|
6
|
+
import type { ComponentTheme } from '../Button';
|
|
7
|
+
|
|
8
|
+
export type FormRangeProps = Omit<ComponentPropsWithRef<'input'>, 'type'> & {
|
|
9
|
+
bubble?: boolean;
|
|
10
|
+
theme?: ComponentTheme;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const FormRange: FC<FormRangeProps> = ({
|
|
14
|
+
className,
|
|
15
|
+
min = 0,
|
|
16
|
+
max = 100,
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
bubble,
|
|
20
|
+
theme,
|
|
21
|
+
onInput,
|
|
22
|
+
style,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
const currentValue = Number(value ?? defaultValue ?? min);
|
|
26
|
+
const fill =
|
|
27
|
+
Number(max) <= Number(min)
|
|
28
|
+
? 0
|
|
29
|
+
: Math.max(0, Math.min(1, (currentValue - Number(min)) / (Number(max) - Number(min))));
|
|
30
|
+
|
|
31
|
+
const handleInput = (event: InputEvent<HTMLInputElement>) => {
|
|
32
|
+
const input = event.currentTarget;
|
|
33
|
+
const range = Number(input.value);
|
|
34
|
+
const value =
|
|
35
|
+
Number(max) <= Number(min)
|
|
36
|
+
? 0
|
|
37
|
+
: Math.max(0, Math.min(1, (range - Number(min)) / (Number(max) - Number(min))));
|
|
38
|
+
|
|
39
|
+
input.parentElement?.style.setProperty('--range-fill', value + '');
|
|
40
|
+
|
|
41
|
+
onInput?.(event);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={classNames('form-range', theme && `theme-${theme}`)}
|
|
47
|
+
data-bs-bubble={bubble || undefined}
|
|
48
|
+
style={{ '--range-fill': fill } as CSSProperties}
|
|
49
|
+
>
|
|
50
|
+
<input
|
|
51
|
+
{...props}
|
|
52
|
+
type="range"
|
|
53
|
+
min={min}
|
|
54
|
+
max={max}
|
|
55
|
+
value={value}
|
|
56
|
+
defaultValue={defaultValue}
|
|
57
|
+
className={classNames('form-range-input', className)}
|
|
58
|
+
style={style}
|
|
59
|
+
onInput={handleInput}
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
FormRange.displayName = 'FormRange';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC, PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ComponentTheme } from '../Button';
|
|
5
|
+
|
|
6
|
+
export type FormSwitchProps = Omit<ComponentPropsWithRef<'label'>, 'children'> &
|
|
7
|
+
PropsWithChildren<{
|
|
8
|
+
inputProps?: Omit<ComponentPropsWithRef<'input'>, 'type'>;
|
|
9
|
+
size?: 'sm' | 'lg';
|
|
10
|
+
theme?: ComponentTheme;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
export const FormSwitch: FC<FormSwitchProps> = ({
|
|
14
|
+
className,
|
|
15
|
+
inputProps,
|
|
16
|
+
size,
|
|
17
|
+
theme,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}) => (
|
|
21
|
+
<label
|
|
22
|
+
{...props}
|
|
23
|
+
className={classNames(
|
|
24
|
+
'switch',
|
|
25
|
+
size && `switch-${size}`,
|
|
26
|
+
theme && `theme-${theme}`,
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
>
|
|
30
|
+
<input {...inputProps} type="checkbox" />
|
|
31
|
+
{children}
|
|
32
|
+
</label>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
FormSwitch.displayName = 'FormSwitch';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './Adorn';
|
|
2
|
+
export * from './Checkbox';
|
|
3
|
+
export * from './Chips';
|
|
4
|
+
export * from './Combobox';
|
|
5
|
+
export * from './Control';
|
|
6
|
+
export * from './DatePicker';
|
|
7
|
+
export * from './Feedback';
|
|
8
|
+
export * from './FloatingLabel';
|
|
9
|
+
export * from './InputGroup';
|
|
10
|
+
export * from './OTP';
|
|
11
|
+
export * from './PasswordStrength';
|
|
12
|
+
export * from './Primitives';
|
|
13
|
+
export * from './Radio';
|
|
14
|
+
export * from './Range';
|
|
15
|
+
export * from './Switch';
|
package/source/Grid.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
5
|
+
export type ColSize = number | 'auto';
|
|
6
|
+
export type BreakpointColSize = ColSize | true;
|
|
7
|
+
|
|
8
|
+
export interface ContainerProps extends ComponentPropsWithRef<'div'> {
|
|
9
|
+
fluid?: boolean;
|
|
10
|
+
breakpoint?: Breakpoint;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Container: FC<ContainerProps> = ({ fluid, breakpoint, className, ...props }) => (
|
|
14
|
+
<div
|
|
15
|
+
{...props}
|
|
16
|
+
className={classNames(
|
|
17
|
+
breakpoint ? `${breakpoint}:container` : fluid ? 'container-fluid' : 'container',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type RowCols = number | 'auto';
|
|
24
|
+
|
|
25
|
+
export interface RowProps extends ComponentPropsWithRef<'div'> {
|
|
26
|
+
cols?: RowCols;
|
|
27
|
+
sm?: RowCols;
|
|
28
|
+
md?: RowCols;
|
|
29
|
+
lg?: RowCols;
|
|
30
|
+
xl?: RowCols;
|
|
31
|
+
'2xl'?: RowCols;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Row: FC<RowProps> = ({ cols, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
35
|
+
const sizes: [Breakpoint, RowCols | undefined][] = [
|
|
36
|
+
['sm', sm],
|
|
37
|
+
['md', md],
|
|
38
|
+
['lg', lg],
|
|
39
|
+
['xl', xl],
|
|
40
|
+
['2xl', xxl]
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
{...props}
|
|
46
|
+
className={classNames(
|
|
47
|
+
'row',
|
|
48
|
+
cols !== undefined && `row-cols-${cols}`,
|
|
49
|
+
sizes.map(
|
|
50
|
+
([breakpoint, size]) => size !== undefined && `${breakpoint}:row-cols-${size}`
|
|
51
|
+
),
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export interface ColProps extends ComponentPropsWithRef<'div'> {
|
|
59
|
+
span?: ColSize;
|
|
60
|
+
sm?: BreakpointColSize;
|
|
61
|
+
md?: BreakpointColSize;
|
|
62
|
+
lg?: BreakpointColSize;
|
|
63
|
+
xl?: BreakpointColSize;
|
|
64
|
+
'2xl'?: BreakpointColSize;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Col: FC<ColProps> = ({ span, sm, md, lg, xl, '2xl': xxl, className, ...props }) => {
|
|
68
|
+
const sizes: [Breakpoint, BreakpointColSize | undefined][] = [
|
|
69
|
+
['sm', sm],
|
|
70
|
+
['md', md],
|
|
71
|
+
['lg', lg],
|
|
72
|
+
['xl', xl],
|
|
73
|
+
['2xl', xxl]
|
|
74
|
+
];
|
|
75
|
+
const sized = sizes.some(([, size]) => size !== undefined);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
{...props}
|
|
80
|
+
className={classNames(
|
|
81
|
+
!span && !sized && 'col',
|
|
82
|
+
span !== undefined && `col-${span}`,
|
|
83
|
+
sizes.map(
|
|
84
|
+
([breakpoint, size]) =>
|
|
85
|
+
size !== undefined &&
|
|
86
|
+
(size === true ? `${breakpoint}:col` : `${breakpoint}:col-${size}`)
|
|
87
|
+
),
|
|
88
|
+
className
|
|
89
|
+
)}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -13,7 +13,7 @@ export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
|
13
13
|
height,
|
|
14
14
|
...props
|
|
15
15
|
}) => (
|
|
16
|
-
<div className={`overflow-hidden
|
|
16
|
+
<div className={`overflow-hidden max-w-100 ${className}`} {...props}>
|
|
17
17
|
<div
|
|
18
18
|
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
19
|
style={{
|
|
@@ -45,23 +45,17 @@ export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
|
45
45
|
// @ts-expect-error remove after React 19 released
|
|
46
46
|
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
47
|
>
|
|
48
|
-
<div
|
|
49
|
-
className={`d-inline-block overflow-hidden mw-100 ${style.scrollContainer}`}
|
|
50
|
-
>
|
|
48
|
+
<div className={`d-inline-block overflow-hidden max-w-100 ${style.scrollContainer}`}>
|
|
51
49
|
<div
|
|
52
50
|
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
53
51
|
>
|
|
54
52
|
{children}
|
|
55
53
|
</div>
|
|
56
|
-
<HorizontalMarquee duration={duration}>
|
|
57
|
-
{children}
|
|
58
|
-
</HorizontalMarquee>
|
|
54
|
+
<HorizontalMarquee duration={duration}>{children}</HorizontalMarquee>
|
|
59
55
|
</div>
|
|
60
56
|
</div>
|
|
61
57
|
) : (
|
|
62
|
-
<HorizontalMarquee {...{ maxWidth, duration, height }}>
|
|
63
|
-
{children}
|
|
64
|
-
</HorizontalMarquee>
|
|
58
|
+
<HorizontalMarquee {...{ maxWidth, duration, height }}>{children}</HorizontalMarquee>
|
|
65
59
|
);
|
|
66
60
|
|
|
67
61
|
HorizontalMarquee.displayName = 'HorizontalMarquee';
|
package/source/Image.tsx
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { ComponentPropsWithRef, FC } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface ImageProps extends ComponentPropsWithRef<'img'> {
|
|
5
|
+
fluid?: boolean;
|
|
6
|
+
thumbnail?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Image: FC<ImageProps> = ({ fluid, thumbnail, className, ...props }) => (
|
|
10
|
+
<img
|
|
11
|
+
{...props}
|
|
12
|
+
className={classNames({ 'img-fluid': fluid, 'img-thumbnail': thumbnail }, className)}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
Image.displayName = 'Image';
|