idea-react 3.0.0-beta.0 → 3.0.0-beta.1

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.
Files changed (107) hide show
  1. package/AGENTS.md +11 -2
  2. package/ReadMe.md +62 -49
  3. package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
  4. package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
  5. package/dist/index.d.mts +1116 -442
  6. package/dist/index.d.ts +1116 -442
  7. package/dist/index.js +16 -16
  8. package/dist/index.mjs +15 -15
  9. package/dist/rolldown-runtime-5iZMYShA.js +1 -0
  10. package/dist/style.css +69 -66
  11. package/package.json +1 -1
  12. package/source/Accordion.tsx +137 -0
  13. package/source/Alert.tsx +138 -0
  14. package/source/Avatar.tsx +7 -1
  15. package/source/Badge.tsx +2 -0
  16. package/source/Breadcrumb.tsx +36 -0
  17. package/source/Button.tsx +40 -5
  18. package/source/ButtonGroup.tsx +10 -1
  19. package/source/Card.tsx +65 -4
  20. package/source/Carousel/index.tsx +391 -0
  21. package/source/Carousel/model.ts +113 -0
  22. package/source/Carousel/scroll.ts +79 -0
  23. package/source/Collapse.tsx +178 -0
  24. package/source/Drawer.tsx +127 -30
  25. package/source/{CodeBlock.tsx → Extension/CodeBlock/index.tsx} +23 -5
  26. package/source/Extension/CodeBlock/style.module.css +3 -0
  27. package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
  28. package/source/{EditorHTML.tsx → Extension/EditorHTML.tsx} +1 -1
  29. package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
  30. package/source/{Icon.tsx → Extension/Icon.tsx} +1 -7
  31. package/source/{Loading.tsx → Extension/Loading.tsx} +8 -3
  32. package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +3 -3
  33. package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
  34. package/source/Extension/OverlayBox.tsx +280 -0
  35. package/source/{PageNav.tsx → Extension/PageNav.tsx} +27 -9
  36. package/source/{ScrollNav → Extension/ScrollNav}/index.tsx +1 -1
  37. package/source/Extension/Select.tsx +127 -0
  38. package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
  39. package/source/{SpinnerButton.tsx → Extension/SpinnerButton.tsx} +2 -2
  40. package/source/{TableSpinner.tsx → Extension/TableSpinner.tsx} +1 -1
  41. package/source/{Timeline → Extension/Timeline}/index.tsx +1 -1
  42. package/source/{UserRank → Extension/UserRank}/index.tsx +4 -4
  43. package/source/Extension/index.ts +27 -0
  44. package/source/Form/Adorn.tsx +32 -11
  45. package/source/Form/Checkbox.tsx +11 -6
  46. package/source/Form/ChipInput.tsx +125 -0
  47. package/source/Form/Chips.tsx +42 -24
  48. package/source/Form/Combobox.tsx +337 -72
  49. package/source/Form/Control.tsx +50 -15
  50. package/source/Form/DatePicker.tsx +231 -40
  51. package/source/Form/DatePickerPlugin.ts +37 -0
  52. package/source/Form/Feedback.tsx +10 -4
  53. package/source/Form/FloatingLabel.tsx +24 -7
  54. package/source/Form/InputGroup.tsx +155 -5
  55. package/source/Form/OTP.tsx +138 -45
  56. package/source/Form/PasswordStrength.tsx +43 -17
  57. package/source/Form/Plugin.tsx +53 -0
  58. package/source/Form/Primitives.tsx +51 -9
  59. package/source/Form/Radio.tsx +20 -28
  60. package/source/Form/Range.tsx +103 -52
  61. package/source/Form/Switch.tsx +30 -7
  62. package/source/Form/index.ts +1 -0
  63. package/source/Grid.tsx +4 -0
  64. package/source/ListGroup.tsx +28 -15
  65. package/source/Menu.tsx +226 -17
  66. package/source/NativeDialog/index.tsx +109 -5
  67. package/source/Nav.tsx +18 -2
  68. package/source/NavOverflow/index.tsx +307 -0
  69. package/source/NavOverflow/model.ts +21 -0
  70. package/source/Navbar.tsx +18 -3
  71. package/source/Overlay.ts +163 -1
  72. package/source/Pagination.tsx +92 -0
  73. package/source/Placeholder.tsx +66 -0
  74. package/source/Popover.tsx +7 -2
  75. package/source/Progress/index.tsx +76 -0
  76. package/source/Progress/style.module.css +15 -0
  77. package/source/ScrollSpy/index.tsx +365 -0
  78. package/source/ScrollSpy/model.ts +17 -0
  79. package/source/Spinner.tsx +10 -0
  80. package/source/Stepper.tsx +85 -0
  81. package/source/Tab.tsx +248 -0
  82. package/source/Toast.tsx +46 -14
  83. package/source/ToggleButton.tsx +21 -7
  84. package/source/Toggler.tsx +108 -0
  85. package/source/Tooltip.tsx +6 -1
  86. package/source/index.ts +15 -27
  87. package/source/OverlayBox.tsx +0 -208
  88. package/source/Select.tsx +0 -95
  89. /package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +0 -0
  90. /package/source/{Countdown.tsx → Extension/Countdown.tsx} +0 -0
  91. /package/source/{Editor.tsx → Extension/Editor.tsx} +0 -0
  92. /package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.tsx +0 -0
  93. /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
  94. /package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +0 -0
  95. /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
  96. /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
  97. /package/source/{TextTruncate → Extension/TextTruncate}/index.tsx +0 -0
  98. /package/source/{Time.tsx → Extension/Time.tsx} +0 -0
  99. /package/source/{TimeDistance.tsx → Extension/TimeDistance.tsx} +0 -0
  100. /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
  101. /package/source/{TypeEcho → Extension/TypeEcho}/Content.tsx +0 -0
  102. /package/source/{TypeEcho → Extension/TypeEcho}/index.tsx +0 -0
  103. /package/source/{UserRank → Extension/UserRank}/Address.tsx +0 -0
  104. /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
  105. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
  106. /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.tsx +0 -0
  107. /package/source/{ZodiacBar.tsx → Extension/ZodiacBar.tsx} +0 -0
@@ -1,65 +1,116 @@
1
1
  'use client';
2
2
 
3
+ import type Range from 'bootstrap/js/src/range.js';
3
4
  import classNames from 'classnames';
4
- import { ComponentPropsWithRef, CSSProperties, FC, InputEvent } from 'react';
5
+ import { ComponentPropsWithoutRef, CSSProperties, forwardRef, Ref } from 'react';
5
6
 
6
- import type { ComponentTheme } from '../Button';
7
+ import { ComponentTheme } from '../Button';
8
+ import { FormPlugin } from './Plugin';
9
+ import { FormValidationProps } from './Primitives';
7
10
 
8
- export type FormRangeProps = Omit<ComponentPropsWithRef<'input'>, 'type'> & {
9
- bubble?: boolean;
10
- theme?: ComponentTheme;
11
- };
11
+ export type FormRangeProps = Omit<ComponentPropsWithoutRef<'input'>, 'type'> &
12
+ FormValidationProps & {
13
+ bubble?: boolean;
14
+ theme?: ComponentTheme;
15
+ formatter?: (value: number) => string;
16
+ wrapperClassName?: string;
17
+ onValueChange?: (value: number) => unknown;
18
+ };
12
19
 
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))));
20
+ interface FormRangeComponentProps extends FormRangeProps {
21
+ forwardedRef?: Ref<HTMLInputElement>;
22
+ }
30
23
 
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))));
24
+ class FormRangeComponent extends FormPlugin<FormRangeComponentProps, Range> {
25
+ protected configurationChanged = (previous: FormRangeComponentProps) =>
26
+ previous.bubble !== this.props.bubble ||
27
+ previous.formatter !== this.props.formatter ||
28
+ previous.list !== this.props.list ||
29
+ previous.min !== this.props.min ||
30
+ previous.max !== this.props.max;
38
31
 
39
- input.parentElement?.style.setProperty('--range-fill', value + '');
32
+ protected load = async () => {
33
+ const { default: Plugin } = await import('bootstrap/js/src/range.js');
34
+ const { bubble = false, formatter = null } = this.props;
40
35
 
41
- onInput?.(event);
36
+ return (element: HTMLDivElement) => {
37
+ element.addEventListener('changed.bs.range', this.handleValueChange);
38
+
39
+ return Plugin.getOrCreateInstance(element, { bubble, formatter });
40
+ };
42
41
  };
43
42
 
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
- };
43
+ protected updatePlugin = () => this.instance?.update();
44
+
45
+ protected dispose() {
46
+ this.element.current?.removeEventListener('changed.bs.range', this.handleValueChange);
47
+ super.dispose();
48
+ }
49
+
50
+ private handleValueChange = (event: Event) =>
51
+ this.props.onValueChange?.((event as Event & { value: number }).value);
52
+
53
+ render() {
54
+ const {
55
+ className,
56
+ wrapperClassName,
57
+ min = 0,
58
+ max = 100,
59
+ value,
60
+ defaultValue,
61
+ bubble,
62
+ theme,
63
+ formatter: _formatter,
64
+ onValueChange: _onValueChange,
65
+ forwardedRef,
66
+ validation,
67
+ style,
68
+ ...props
69
+ } = this.props;
70
+ const currentValue = Number(value ?? defaultValue ?? (Number(min) + Number(max)) / 2);
71
+ const fill =
72
+ Number(max) <= Number(min)
73
+ ? 0
74
+ : Math.max(
75
+ 0,
76
+ Math.min(1, (currentValue - Number(min)) / (Number(max) - Number(min)))
77
+ );
78
+
79
+ return (
80
+ <div
81
+ ref={this.element}
82
+ className={classNames(
83
+ 'form-range',
84
+ theme && `theme-${theme}`,
85
+ validation && `is-${validation}`,
86
+ wrapperClassName
87
+ )}
88
+ data-bs-bubble={bubble || undefined}
89
+ style={{ '--bs-range-fill': fill } as CSSProperties}
90
+ >
91
+ <input
92
+ {...props}
93
+ ref={forwardedRef}
94
+ type="range"
95
+ min={min}
96
+ max={max}
97
+ value={value}
98
+ defaultValue={defaultValue}
99
+ aria-invalid={validation ? validation === 'invalid' : props['aria-invalid']}
100
+ className={classNames(
101
+ 'form-range-input',
102
+ validation && `is-${validation}`,
103
+ className
104
+ )}
105
+ style={style}
106
+ />
107
+ </div>
108
+ );
109
+ }
110
+ }
111
+
112
+ export const FormRange = forwardRef<HTMLInputElement, FormRangeProps>((props, forwardedRef) => (
113
+ <FormRangeComponent {...props} forwardedRef={forwardedRef} />
114
+ ));
64
115
 
65
116
  FormRange.displayName = 'FormRange';
@@ -1,20 +1,29 @@
1
1
  import classNames from 'classnames';
2
- import { ComponentPropsWithRef, FC, PropsWithChildren } from 'react';
2
+ import { ComponentPropsWithRef, CSSProperties, FC, PropsWithChildren } from 'react';
3
3
 
4
4
  import type { ComponentTheme } from '../Button';
5
+ import { FormValidationProps } from './Primitives';
5
6
 
6
7
  export type FormSwitchProps = Omit<ComponentPropsWithRef<'label'>, 'children'> &
7
- PropsWithChildren<{
8
- inputProps?: Omit<ComponentPropsWithRef<'input'>, 'type'>;
9
- size?: 'sm' | 'lg';
10
- theme?: ComponentTheme;
11
- }>;
8
+ PropsWithChildren<
9
+ FormValidationProps & {
10
+ inputProps?: Omit<ComponentPropsWithRef<'input'>, 'type'>;
11
+ size?: 'sm' | 'lg';
12
+ theme?: ComponentTheme;
13
+ width?: string;
14
+ indicatorWidth?: string;
15
+ }
16
+ >;
12
17
 
13
18
  export const FormSwitch: FC<FormSwitchProps> = ({
14
19
  className,
15
20
  inputProps,
16
21
  size,
17
22
  theme,
23
+ validation,
24
+ width,
25
+ indicatorWidth,
26
+ style,
18
27
  children,
19
28
  ...props
20
29
  }) => (
@@ -24,10 +33,24 @@ export const FormSwitch: FC<FormSwitchProps> = ({
24
33
  'switch',
25
34
  size && `switch-${size}`,
26
35
  theme && `theme-${theme}`,
36
+ validation && `is-${validation}`,
27
37
  className
28
38
  )}
39
+ style={
40
+ {
41
+ '--bs-switch-width': width,
42
+ '--bs-switch-indicator-width': indicatorWidth,
43
+ ...style
44
+ } as CSSProperties
45
+ }
29
46
  >
30
- <input {...inputProps} type="checkbox" />
47
+ <input
48
+ role="switch"
49
+ {...inputProps}
50
+ type="checkbox"
51
+ aria-invalid={validation ? validation === 'invalid' : inputProps?.['aria-invalid']}
52
+ className={classNames(validation && `is-${validation}`, inputProps?.className)}
53
+ />
31
54
  {children}
32
55
  </label>
33
56
  );
@@ -1,5 +1,6 @@
1
1
  export * from './Adorn';
2
2
  export * from './Checkbox';
3
+ export * from './ChipInput';
3
4
  export * from './Chips';
4
5
  export * from './Combobox';
5
6
  export * from './Control';
package/source/Grid.tsx CHANGED
@@ -90,3 +90,7 @@ export const Col: FC<ColProps> = ({ span, sm, md, lg, xl, '2xl': xxl, className,
90
90
  />
91
91
  );
92
92
  };
93
+
94
+ Container.displayName = 'Container';
95
+ Row.displayName = 'Row';
96
+ Col.displayName = 'Col';
@@ -6,32 +6,45 @@ import type { Breakpoint } from './Grid';
6
6
 
7
7
  export type ListGroupHorizontal = boolean | Breakpoint;
8
8
 
9
- export interface ListGroupProps extends ComponentPropsWithRef<'ul'> {
9
+ interface ListGroupStyleProps {
10
10
  flush?: boolean;
11
11
  numbered?: boolean;
12
12
  horizontal?: ListGroupHorizontal;
13
13
  }
14
14
 
15
+ export type ListGroupProps = ListGroupStyleProps &
16
+ (
17
+ | (ComponentPropsWithRef<'ul'> & { as?: 'ul' })
18
+ | (ComponentPropsWithRef<'ol'> & { as: 'ol' })
19
+ | (ComponentPropsWithRef<'div'> & { as: 'div' })
20
+ );
21
+
15
22
  export const ListGroup: FC<ListGroupProps> = ({
16
23
  flush,
17
24
  numbered,
18
25
  horizontal,
19
26
  className,
20
27
  ...props
21
- }) => (
22
- <ul
23
- {...props}
24
- className={classNames(
25
- 'list-group',
26
- { 'list-group-flush': flush, 'list-group-numbered': numbered },
27
- horizontal &&
28
- (horizontal === true
29
- ? 'list-group-horizontal'
30
- : `${horizontal}:list-group-horizontal`),
31
- className
32
- )}
33
- />
34
- );
28
+ }) => {
29
+ const classes = classNames(
30
+ 'list-group',
31
+ { 'list-group-flush': flush, 'list-group-numbered': numbered },
32
+ horizontal &&
33
+ (horizontal === true ? 'list-group-horizontal' : `${horizontal}:list-group-horizontal`),
34
+ className
35
+ );
36
+
37
+ if (props.as === 'ol') {
38
+ const { as: _as, ...attributes } = props;
39
+ return <ol {...attributes} className={classes} />;
40
+ }
41
+ if (props.as === 'div') {
42
+ const { as: _as, ...attributes } = props;
43
+ return <div {...attributes} className={classes} />;
44
+ }
45
+ const { as: _as, ...attributes } = props;
46
+ return <ul {...attributes} className={classes} />;
47
+ };
35
48
 
36
49
  interface ListGroupItemStyleProps {
37
50
  theme?: ComponentTheme;