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.
@@ -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 const NavbarBrand: FC<ComponentPropsWithRef<'a'>> = ({ className, ...props }) => (
24
- <a {...props} className={classNames('navbar-brand', className)} />
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
- <div
61
- {...props}
62
- className={classNames(
63
- 'toast-container position-fixed p-3',
64
- TOAST_POSITION_CLASSES[position],
65
- className
66
- )}
67
- aria-live={ariaLive}
68
- aria-atomic={ariaAtomic}
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
@@ -13,6 +13,7 @@ export * from './Dialog';
13
13
  export * from './Drawer';
14
14
  export * from './Editor';
15
15
  export * from './EditorHTML';
16
+ export * from './Form';
16
17
  export * from './Grid';
17
18
  export * from './HorizontalMarquee';
18
19
  export * from './Icon';