idea-react 3.0.0-alpha.1 → 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/ReadMe.md +68 -41
- package/dist/index.d.mts +153 -3
- package/dist/index.d.ts +153 -3
- package/dist/index.js +13 -13
- package/dist/index.mjs +15 -15
- package/package.json +4 -2
- package/source/Card.tsx +8 -0
- 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/Navbar.tsx +13 -3
- package/source/Toast.tsx +19 -13
- package/source/index.ts +1 -0
|
@@ -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/Navbar.tsx
CHANGED
|
@@ -20,9 +20,19 @@ export const Navbar: FC<NavbarProps> = ({ expand, theme, className, ...props })
|
|
|
20
20
|
/>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
export
|
|
24
|
-
<a {
|
|
25
|
-
|
|
23
|
+
export type NavbarBrandProps =
|
|
24
|
+
(ComponentPropsWithRef<'a'> & { as?: 'a' }) | (ComponentPropsWithRef<'span'> & { as: 'span' });
|
|
25
|
+
|
|
26
|
+
export const NavbarBrand: FC<NavbarBrandProps> = props => {
|
|
27
|
+
if (props.as === 'span') {
|
|
28
|
+
const { as: _as, className, ...spanProps } = props;
|
|
29
|
+
|
|
30
|
+
return <span {...spanProps} className={classNames('navbar-brand', className)} />;
|
|
31
|
+
}
|
|
32
|
+
const { as: _as, className, ...anchorProps } = props;
|
|
33
|
+
|
|
34
|
+
return <a {...anchorProps} className={classNames('navbar-brand', className)} />;
|
|
35
|
+
};
|
|
26
36
|
|
|
27
37
|
export const NavbarNav: FC<ComponentPropsWithRef<'ul'>> = ({ className, ...props }) => (
|
|
28
38
|
<ul {...props} className={classNames('navbar-nav', className)} />
|
package/source/Toast.tsx
CHANGED
|
@@ -47,7 +47,7 @@ interface ToastEntry extends ToastMessage {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export interface ToastContainerProps extends ComponentPropsWithRef<'div'> {
|
|
50
|
-
position?: ToastPosition;
|
|
50
|
+
position?: ToastPosition | 'static';
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export const ToastContainer: FC<ToastContainerProps> = ({
|
|
@@ -56,18 +56,24 @@ export const ToastContainer: FC<ToastContainerProps> = ({
|
|
|
56
56
|
'aria-live': ariaLive = 'polite',
|
|
57
57
|
'aria-atomic': ariaAtomic = true,
|
|
58
58
|
...props
|
|
59
|
-
}) =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
className
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
}) => {
|
|
60
|
+
const isStatic = position === 'static';
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
{...props}
|
|
65
|
+
className={classNames(
|
|
66
|
+
'toast-container',
|
|
67
|
+
!isStatic && 'position-fixed',
|
|
68
|
+
!isStatic && 'p-3',
|
|
69
|
+
isStatic ? 'position-static' : TOAST_POSITION_CLASSES[position],
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
aria-live={ariaLive}
|
|
73
|
+
aria-atomic={ariaAtomic}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
71
77
|
|
|
72
78
|
export interface ToastItemProps extends ComponentPropsWithRef<'div'> {
|
|
73
79
|
theme?: ComponentTheme;
|
package/source/index.ts
CHANGED