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,19 +1,30 @@
1
1
  import classNames from 'classnames';
2
2
  import { ComponentPropsWithRef, FC } from 'react';
3
3
 
4
- export type FormAdornmentProps = Omit<ComponentPropsWithRef<'label'>, 'htmlFor'> & {
5
- end?: boolean;
6
- size?: 'sm' | 'lg';
7
- htmlFor?: string;
8
- };
9
-
10
- export const FormAdornment: FC<FormAdornmentProps> = ({ className, end, size, ...props }) => (
4
+ import { Icon, IconProps } from '../Extension/Icon';
5
+ import { FormValidationProps } from './Primitives';
6
+
7
+ export type FormAdornmentProps = Omit<ComponentPropsWithRef<'label'>, 'htmlFor'> &
8
+ FormValidationProps & {
9
+ end?: boolean;
10
+ size?: 'sm' | 'lg';
11
+ htmlFor?: string;
12
+ };
13
+
14
+ export const FormAdornment: FC<FormAdornmentProps> = ({
15
+ className,
16
+ end,
17
+ size,
18
+ validation,
19
+ ...props
20
+ }) => (
11
21
  <label
12
22
  {...props}
13
23
  className={classNames(
14
24
  'form-control form-adorn',
15
25
  end && 'form-adorn-end',
16
- size && `form-adorn-${size}`,
26
+ size && `form-control-${size}`,
27
+ validation && `is-${validation}`,
17
28
  className
18
29
  )}
19
30
  />
@@ -29,10 +40,20 @@ export const FormAdornmentText: FC<FormAdornmentTextProps> = ({ className, ...pr
29
40
 
30
41
  FormAdornmentText.displayName = 'FormAdornmentText';
31
42
 
32
- export type FormGhostProps = ComponentPropsWithRef<'input'>;
43
+ export const FormAdornmentIcon: FC<IconProps> = ({ className, ...props }) => (
44
+ <Icon {...props} className={classNames('form-adorn-icon', className)} />
45
+ );
46
+
47
+ FormAdornmentIcon.displayName = 'FormAdornmentIcon';
33
48
 
34
- export const FormGhost: FC<FormGhostProps> = ({ className, ...props }) => (
35
- <input {...props} className={classNames('form-ghost', className)} />
49
+ export type FormGhostProps = ComponentPropsWithRef<'input'> & FormValidationProps;
50
+
51
+ export const FormGhost: FC<FormGhostProps> = ({ className, validation, ...props }) => (
52
+ <input
53
+ {...props}
54
+ aria-invalid={validation ? validation === 'invalid' : props['aria-invalid']}
55
+ className={classNames('form-ghost', validation && `is-${validation}`, className)}
56
+ />
36
57
  );
37
58
 
38
59
  FormGhost.displayName = 'FormGhost';
@@ -4,12 +4,14 @@ import classNames from 'classnames';
4
4
  import { Component, ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
5
5
 
6
6
  import type { ComponentTheme } from '../Button';
7
+ import { FormValidationProps } from './Primitives';
7
8
 
8
- export type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'size'> & {
9
- size?: 'sm' | 'lg';
10
- theme?: ComponentTheme;
11
- indeterminate?: boolean;
12
- };
9
+ export type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'size'> &
10
+ FormValidationProps & {
11
+ size?: 'sm' | 'lg';
12
+ theme?: ComponentTheme;
13
+ indeterminate?: boolean;
14
+ };
13
15
 
14
16
  interface CheckboxComponentProps extends CheckboxProps {
15
17
  forwardedRef?: Ref<HTMLInputElement>;
@@ -44,6 +46,7 @@ class CheckboxComponent extends Component<CheckboxComponentProps> {
44
46
  className,
45
47
  size,
46
48
  theme,
49
+ validation,
47
50
  indeterminate,
48
51
  forwardedRef: _forwardedRef,
49
52
  ...props
@@ -54,11 +57,13 @@ class CheckboxComponent extends Component<CheckboxComponentProps> {
54
57
  {...props}
55
58
  ref={this.setInputRef}
56
59
  type="checkbox"
57
- aria-checked={indeterminate ? 'mixed' : undefined}
60
+ aria-invalid={validation ? validation === 'invalid' : props['aria-invalid']}
61
+ aria-checked={indeterminate ? 'mixed' : props['aria-checked']}
58
62
  className={classNames(
59
63
  'check',
60
64
  size && `check-${size}`,
61
65
  theme && `theme-${theme}`,
66
+ validation && `is-${validation}`,
62
67
  className
63
68
  )}
64
69
  />
@@ -0,0 +1,125 @@
1
+ 'use client';
2
+
3
+ import type Chips from 'bootstrap/js/src/chips.js';
4
+ import classNames from 'classnames';
5
+ import { ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
6
+ import { renderToStaticMarkup } from 'react-dom/server';
7
+
8
+ import { ComponentTheme } from '../Button';
9
+ import { Icon } from '../Extension/Icon';
10
+ import { FormPlugin } from './Plugin';
11
+ import { FormValidationProps } from './Primitives';
12
+
13
+ export type ChipInputProps = ComponentPropsWithoutRef<'div'> &
14
+ FormValidationProps & {
15
+ theme?: ComponentTheme;
16
+ separator?: string | null;
17
+ allowDuplicates?: boolean;
18
+ maxChips?: number | null;
19
+ createOnBlur?: boolean;
20
+ dismissible?: boolean;
21
+ placeholder?: string;
22
+ onValuesChange?: (values: string[]) => unknown;
23
+ };
24
+
25
+ interface ChipInputComponentProps extends ChipInputProps {
26
+ forwardedRef?: Ref<HTMLDivElement>;
27
+ }
28
+
29
+ class ChipInputComponent extends FormPlugin<ChipInputComponentProps, Pick<Chips, 'dispose'>> {
30
+ protected configurationChanged = (previous: ChipInputComponentProps) =>
31
+ previous.separator !== this.props.separator ||
32
+ previous.allowDuplicates !== this.props.allowDuplicates ||
33
+ previous.maxChips !== this.props.maxChips ||
34
+ previous.createOnBlur !== this.props.createOnBlur ||
35
+ previous.dismissible !== this.props.dismissible ||
36
+ previous.placeholder !== this.props.placeholder;
37
+
38
+ protected load = async () => {
39
+ const [{ default: Plugin }, { default: EventHandler }] = await Promise.all([
40
+ import('bootstrap/js/src/chips.js'),
41
+ import('bootstrap/js/src/dom/event-handler.js')
42
+ ]);
43
+ const {
44
+ separator = ',',
45
+ allowDuplicates = false,
46
+ maxChips = null,
47
+ createOnBlur = true,
48
+ dismissible = true,
49
+ placeholder = ''
50
+ } = this.props;
51
+
52
+ return (element: HTMLDivElement) => {
53
+ const instance = Plugin.getOrCreateInstance(element, {
54
+ separator,
55
+ allowDuplicates,
56
+ maxChips,
57
+ createOnBlur,
58
+ dismissible,
59
+ placeholder,
60
+ dismissIcon: renderToStaticMarkup(<Icon name="x-lg" aria-hidden="true" />)
61
+ });
62
+ element.addEventListener('change.bs.chips', this.handleValuesChange);
63
+
64
+ return {
65
+ dispose: () => {
66
+ element.removeEventListener('change.bs.chips', this.handleValuesChange);
67
+ EventHandler.off(element, '.bs.chips');
68
+ instance.dispose();
69
+ }
70
+ };
71
+ };
72
+ };
73
+
74
+ private handleValuesChange = (event: Event) =>
75
+ this.props.onValuesChange?.((event as Event & { values: string[] }).values);
76
+
77
+ private setRef = (element: HTMLDivElement | null) => {
78
+ this.element.current = element;
79
+ const { forwardedRef } = this.props;
80
+
81
+ if (typeof forwardedRef === 'function') forwardedRef(element);
82
+ else if (forwardedRef) forwardedRef.current = element;
83
+ };
84
+
85
+ render() {
86
+ const {
87
+ className,
88
+ theme,
89
+ separator,
90
+ allowDuplicates,
91
+ maxChips,
92
+ createOnBlur,
93
+ dismissible: _dismissible,
94
+ placeholder: _placeholder,
95
+ onValuesChange: _onValuesChange,
96
+ forwardedRef: _forwardedRef,
97
+ validation,
98
+ ...props
99
+ } = this.props;
100
+
101
+ return (
102
+ <div
103
+ {...props}
104
+ ref={this.setRef}
105
+ className={classNames(
106
+ 'chip-input',
107
+ theme && `theme-${theme}`,
108
+ validation && `is-${validation}`,
109
+ className
110
+ )}
111
+ data-bs-chips=""
112
+ data-bs-separator={separator}
113
+ data-bs-allow-duplicates={allowDuplicates}
114
+ data-bs-max-chips={maxChips}
115
+ data-bs-create-on-blur={createOnBlur}
116
+ />
117
+ );
118
+ }
119
+ }
120
+
121
+ export const ChipInput = forwardRef<HTMLDivElement, ChipInputProps>((props, forwardedRef) => (
122
+ <ChipInputComponent {...props} forwardedRef={forwardedRef} />
123
+ ));
124
+
125
+ ChipInput.displayName = 'ChipInput';
@@ -1,51 +1,69 @@
1
1
  import classNames from 'classnames';
2
2
  import { ComponentPropsWithRef, FC } from 'react';
3
3
 
4
- import type { ComponentTheme } from '../Button';
4
+ import { ComponentTheme } from '../Button';
5
+ import { Icon, IconProps } from '../Extension/Icon';
5
6
 
6
7
  export type ChipProps = ComponentPropsWithRef<'button'> & {
7
8
  active?: boolean;
8
9
  theme?: ComponentTheme;
9
10
  };
10
11
 
11
- export const Chip: FC<ChipProps> = ({ className, active, disabled, theme, ...props }) => (
12
+ export const Chip: FC<ChipProps> = ({ className, active, theme, ...props }) => (
12
13
  <button
13
14
  {...props}
14
15
  className={classNames('chip', active && 'active', theme && `theme-${theme}`, className)}
15
16
  type="button"
16
17
  aria-pressed={active}
17
- disabled={disabled}
18
18
  />
19
19
  );
20
20
 
21
21
  Chip.displayName = 'Chip';
22
22
 
23
- export type ChipInputProps = ComponentPropsWithRef<'div'> & {
24
- theme?: ComponentTheme;
25
- separator?: string;
26
- allowDuplicates?: boolean;
27
- maxChips?: number;
28
- createOnBlur?: boolean;
29
- };
23
+ export const ChipIcon: FC<IconProps> = ({ className, ...props }) => (
24
+ <Icon {...props} className={classNames('chip-icon', className)} />
25
+ );
30
26
 
31
- export const ChipInput: FC<ChipInputProps> = ({
27
+ ChipIcon.displayName = 'ChipIcon';
28
+
29
+ export const ChipImage: FC<ComponentPropsWithRef<'img'>> = ({ className, alt = '', ...props }) => (
30
+ <img {...props} alt={alt} className={classNames('chip-img', className)} />
31
+ );
32
+
33
+ ChipImage.displayName = 'ChipImage';
34
+
35
+ export const ChipDismiss: FC<ComponentPropsWithRef<'button'>> = ({
32
36
  className,
33
- theme,
34
- separator,
35
- allowDuplicates,
36
- maxChips,
37
- createOnBlur,
37
+ children,
38
+ 'aria-label': label = 'Remove',
38
39
  ...props
39
40
  }) => (
40
- <div
41
+ <button
42
+ {...props}
43
+ type="button"
44
+ aria-label={label}
45
+ className={classNames('chip-dismiss', className)}
46
+ >
47
+ {children ?? <Icon name="x-lg" aria-hidden="true" />}
48
+ </button>
49
+ );
50
+
51
+ ChipDismiss.displayName = 'ChipDismiss';
52
+
53
+ export type ChipTokenProps = ComponentPropsWithRef<'span'> & Pick<ChipProps, 'active' | 'theme'>;
54
+
55
+ export const ChipToken: FC<ChipTokenProps> = ({ className, active, theme, ...props }) => (
56
+ <span
41
57
  {...props}
42
- className={classNames('chip-input', theme && `theme-${theme}`, className)}
43
- data-bs-chips=""
44
- data-bs-separator={separator}
45
- data-bs-allow-duplicates={allowDuplicates}
46
- data-bs-max-chips={maxChips}
47
- data-bs-create-on-blur={createOnBlur}
58
+ tabIndex={props.tabIndex ?? 0}
59
+ className={classNames('chip', active && 'active', theme && `theme-${theme}`, className)}
48
60
  />
49
61
  );
50
62
 
51
- ChipInput.displayName = 'ChipInput';
63
+ ChipToken.displayName = 'ChipToken';
64
+
65
+ export const ChipInputLabel: FC<ComponentPropsWithRef<'label'>> = ({ className, ...props }) => (
66
+ <label {...props} className={classNames('chip-input-label', className)} />
67
+ );
68
+
69
+ ChipInputLabel.displayName = 'ChipInputLabel';