idea-react 3.0.0-beta.5 → 3.0.0-rc.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.
Files changed (104) hide show
  1. package/AGENTS.md +5 -3
  2. package/ReadMe.md +71 -65
  3. package/dist/index.d.mts +894 -929
  4. package/dist/index.d.ts +894 -929
  5. package/dist/index.js +16 -16
  6. package/dist/index.mjs +15 -15
  7. package/dist/style.css +2 -2
  8. package/package.json +3 -7
  9. package/source/{Accordion.tsx → Base/Accordion.tsx} +2 -2
  10. package/source/{Alert.tsx → Base/Alert.tsx} +1 -1
  11. package/source/{Avatar.tsx → Base/Avatar.tsx} +1 -1
  12. package/source/{Badge.tsx → Base/Badge.tsx} +1 -1
  13. package/source/{Breadcrumb.tsx → Base/Breadcrumb.tsx} +1 -1
  14. package/source/{Button.tsx → Base/Button.tsx} +1 -1
  15. package/source/{ButtonGroup.tsx → Base/ButtonGroup.tsx} +1 -1
  16. package/source/{Card.tsx → Base/Card.tsx} +1 -1
  17. package/source/{Carousel → Base/Carousel}/index.tsx +2 -2
  18. package/source/{CloseButton.tsx → Base/CloseButton.tsx} +1 -1
  19. package/source/{Collapse.tsx → Base/Collapse.tsx} +1 -1
  20. package/source/{Drawer.tsx → Base/Drawer.tsx} +2 -2
  21. package/source/{ListGroup.tsx → Base/ListGroup.tsx} +2 -2
  22. package/source/{Menu.tsx → Base/Menu.tsx} +4 -4
  23. package/source/{NativeDialog → Base/NativeDialog}/index.tsx +2 -2
  24. package/source/{Nav.tsx → Base/Nav.tsx} +2 -1
  25. package/source/{NavOverflow → Base/NavOverflow}/index.tsx +2 -2
  26. package/source/{Navbar.tsx → Base/Navbar.tsx} +1 -1
  27. package/source/{Pagination.tsx → Base/Pagination.tsx} +1 -1
  28. package/source/{Placeholder.tsx → Base/Placeholder.tsx} +1 -1
  29. package/source/{Popover.tsx → Base/Popover.tsx} +6 -2
  30. package/source/{Progress → Base/Progress}/index.tsx +1 -1
  31. package/source/{ScrollSpy → Base/ScrollSpy}/index.tsx +1 -1
  32. package/source/{Spinner.tsx → Base/Spinner.tsx} +2 -2
  33. package/source/{Stack.tsx → Base/Stack.tsx} +1 -1
  34. package/source/{Stepper.tsx → Base/Stepper.tsx} +2 -2
  35. package/source/{Tab.tsx → Base/Tab.tsx} +60 -47
  36. package/source/{Toast.tsx → Base/Toast.tsx} +1 -1
  37. package/source/{ToggleButton.tsx → Base/ToggleButton.tsx} +2 -2
  38. package/source/{Toggler.tsx → Base/Toggler.tsx} +1 -1
  39. package/source/{Tooltip.tsx → Base/Tooltip.tsx} +6 -2
  40. package/source/Base/index.ts +31 -0
  41. package/source/Content/Images.tsx +29 -0
  42. package/source/{Table.tsx → Content/Tables.tsx} +2 -2
  43. package/source/Content/index.ts +2 -0
  44. package/source/Extension/ClickBoundary.tsx +1 -1
  45. package/source/Extension/CodeBlock.tsx +1 -1
  46. package/source/Extension/Countdown.tsx +1 -1
  47. package/source/Extension/HorizontalMarquee/index.tsx +1 -1
  48. package/source/Extension/Icon.tsx +1 -1
  49. package/source/Extension/Loading.tsx +2 -2
  50. package/source/Extension/MarkdownView.tsx +23 -0
  51. package/source/Extension/MonthCalendar.tsx +4 -4
  52. package/source/Extension/Nameplate.tsx +1 -1
  53. package/source/Extension/OverlayBox.tsx +9 -4
  54. package/source/Extension/PageNav.tsx +2 -2
  55. package/source/Extension/ScrollNav/Scroller.tsx +1 -1
  56. package/source/Extension/ScrollNav/index.tsx +2 -2
  57. package/source/Extension/ShareBox.tsx +1 -1
  58. package/source/Extension/SpinnerButton.tsx +3 -3
  59. package/source/Extension/TableSpinner.tsx +2 -2
  60. package/source/Extension/TextTruncate/index.tsx +1 -1
  61. package/source/Extension/Time.tsx +1 -1
  62. package/source/Extension/TimeDistance.tsx +1 -1
  63. package/source/Extension/Timeline/index.tsx +2 -2
  64. package/source/Extension/TypeEcho/Content.tsx +1 -1
  65. package/source/Extension/TypeEcho/index.tsx +1 -1
  66. package/source/Extension/UserRank/Address.tsx +1 -1
  67. package/source/Extension/UserRank/index.tsx +5 -5
  68. package/source/Extension/VerticalMarquee/index.tsx +1 -1
  69. package/source/Extension/ZodiacBar.tsx +1 -1
  70. package/source/Extension/index.ts +1 -3
  71. package/source/Form/Adorn.tsx +1 -1
  72. package/source/Form/Checkbox.tsx +2 -2
  73. package/source/Form/{Chips.tsx → Chip.tsx} +4 -11
  74. package/source/Form/ChipInput.tsx +2 -2
  75. package/source/Form/Combobox.tsx +2 -2
  76. package/source/Form/Control.tsx +1 -1
  77. package/source/Form/DatePicker.tsx +2 -2
  78. package/source/Form/Feedback.tsx +1 -1
  79. package/source/Form/FloatingLabel.tsx +1 -1
  80. package/source/Form/InputGroup.tsx +3 -3
  81. package/source/Form/OTP.tsx +1 -1
  82. package/source/Form/Primitives.tsx +8 -1
  83. package/source/Form/Radio.tsx +2 -2
  84. package/source/Form/Range.tsx +2 -2
  85. package/source/Form/Switch.tsx +2 -2
  86. package/source/Form/index.ts +1 -1
  87. package/source/{Overlay.ts → Helper/Overlay.ts} +1 -1
  88. package/source/{color.ts → Helper/color.ts} +1 -1
  89. package/source/Helper/index.ts +4 -0
  90. package/source/{Grid.tsx → Layout/Grid.tsx} +1 -1
  91. package/source/Layout/index.ts +1 -0
  92. package/source/index.ts +4 -38
  93. package/source/Extension/Editor.tsx +0 -78
  94. package/source/Extension/EditorHTML.tsx +0 -20
  95. package/source/Extension/Select.tsx +0 -128
  96. package/source/Image.tsx +0 -19
  97. /package/source/{Carousel → Base/Carousel}/model.ts +0 -0
  98. /package/source/{Carousel → Base/Carousel}/scroll.ts +0 -0
  99. /package/source/{Carousel → Base/Carousel}/style.module.css +0 -0
  100. /package/source/{NativeDialog → Base/NativeDialog}/style.module.css +0 -0
  101. /package/source/{NavOverflow → Base/NavOverflow}/model.ts +0 -0
  102. /package/source/{ScrollSpy → Base/ScrollSpy}/model.ts +0 -0
  103. /package/source/{Polymorphic.ts → Helper/Polymorphic.ts} +0 -0
  104. /package/source/{animate.ts → Helper/animate.ts} +0 -0
package/source/index.ts CHANGED
@@ -1,40 +1,6 @@
1
- export * from './Accordion';
2
- export * from './Alert';
3
- export * from './animate';
4
- export * from './Avatar';
5
- export * from './Badge';
6
- export * from './Breadcrumb';
7
- export * from './Button';
8
- export * from './ButtonGroup';
9
- export * from './Card';
10
- export * from './Carousel';
11
- export * from './CloseButton';
12
- export * from './Collapse';
13
- export * from './color';
14
- export * from './Drawer';
1
+ export * from './Base';
2
+ export * from './Content';
15
3
  export * from './Extension';
16
4
  export * from './Form';
17
- export * from './Grid';
18
- export * from './Image';
19
- export * from './ListGroup';
20
- export * from './Menu';
21
- export * from './NativeDialog';
22
- export * from './Nav';
23
- export * from './Navbar';
24
- export * from './NavOverflow';
25
- export * from './Overlay';
26
- export * from './Pagination';
27
- export * from './Placeholder';
28
- export * from './Polymorphic';
29
- export * from './Popover';
30
- export * from './Progress';
31
- export * from './ScrollSpy';
32
- export * from './Spinner';
33
- export * from './Stack';
34
- export * from './Stepper';
35
- export * from './Tab';
36
- export * from './Table';
37
- export * from './Toast';
38
- export * from './ToggleButton';
39
- export * from './Toggler';
40
- export * from './Tooltip';
5
+ export * from './Helper';
6
+ export * from './Layout';
@@ -1,78 +0,0 @@
1
- 'use client';
2
-
3
- import { EditorCore, WrapperProps } from '@react-editor-js/core';
4
- import classNames from 'classnames';
5
- import { action, observable } from 'mobx';
6
- import { observer } from 'mobx-react';
7
- import { Component, ComponentPropsWithRef, ElementType, FocusEvent } from 'react';
8
- import { createReactEditorJS } from 'react-editor-js';
9
-
10
- import { AsProps, PolymorphicClassProps } from '../Polymorphic';
11
-
12
- const ReactEditorJS = createReactEditorJS();
13
-
14
- export type EditorProps = WrapperProps &
15
- Pick<ComponentPropsWithRef<'input'>, 'name' | 'required'> &
16
- Pick<ComponentPropsWithRef<'div'>, 'className' | 'style' | 'tabIndex' | 'onBlur'>;
17
-
18
- @observer
19
- export class Editor<T extends ElementType | undefined = 'div'> extends Component<
20
- PolymorphicClassProps<T, EditorProps>
21
- > {
22
- declare readonly props: PolymorphicClassProps<T, EditorProps>;
23
-
24
- protected get componentProps(): Readonly<EditorProps & AsProps> {
25
- return this.props;
26
- }
27
-
28
- static displayName = 'Editor';
29
-
30
- private core?: EditorCore;
31
-
32
- @observable
33
- accessor innerValue = this.componentProps.defaultValue;
34
-
35
- setInnerValue = action((value: typeof this.innerValue) => (this.innerValue = value));
36
-
37
- handleBlur = async (event: FocusEvent<HTMLDivElement>) => {
38
- this.componentProps.onBlur?.(event);
39
-
40
- if (this.core) this.setInnerValue(await this.core.save());
41
- };
42
-
43
- initialize = (core: EditorCore) => {
44
- this.componentProps.onInitialize?.(core);
45
-
46
- this.core = core;
47
- };
48
-
49
- render() {
50
- const Root: ElementType = this.componentProps.as ?? 'div';
51
-
52
- const {
53
- as: _as,
54
- name,
55
- required,
56
- className,
57
- style,
58
- tabIndex = -1,
59
- onBlur: _onBlur,
60
- children: _children,
61
- ...editorProps
62
- } = this.componentProps,
63
- { innerValue } = this;
64
-
65
- return (
66
- <Root
67
- {...(this.componentProps.as ? editorProps : {})}
68
- className={classNames('form-control', className)}
69
- style={style}
70
- tabIndex={tabIndex}
71
- onBlur={this.handleBlur}
72
- >
73
- <input hidden {...{ name, required }} value={JSON.stringify(innerValue)} />
74
- <ReactEditorJS {...editorProps} onInitialize={this.initialize} />
75
- </Root>
76
- );
77
- }
78
- }
@@ -1,20 +0,0 @@
1
- import { OutputData } from '@editorjs/editorjs';
2
- import createParser from 'editorjs-html';
3
- import { HTMLAttributes } from 'react';
4
-
5
- import { polymorphic } from '../Polymorphic';
6
-
7
- export const parser = createParser({
8
- link: ({ data: { link } }) => `<a href="${link}">${link}</a>`
9
- });
10
-
11
- export interface EditorHTMLProps extends HTMLAttributes<HTMLDivElement> {
12
- data: OutputData;
13
- }
14
-
15
- export const EditorHTML = polymorphic<EditorHTMLProps>(
16
- ({ as: Root = 'article', data, ...props }) => (
17
- <Root {...props} dangerouslySetInnerHTML={{ __html: parser.parse(data) }} />
18
- )
19
- );
20
- EditorHTML.displayName = 'EditorHTML';
@@ -1,128 +0,0 @@
1
- 'use client';
2
-
3
- import classNames from 'classnames';
4
- import {
5
- ButtonHTMLAttributes,
6
- Children,
7
- cloneElement,
8
- Component,
9
- isValidElement,
10
- MouseEvent,
11
- ReactElement,
12
- ReactNode
13
- } from 'react';
14
-
15
- import { ButtonProps } from '../Button';
16
- import { Menu } from '../Menu';
17
- import { polymorphic } from '../Polymorphic';
18
-
19
- export interface OptionProps extends ButtonHTMLAttributes<HTMLButtonElement> {
20
- value?: string;
21
- }
22
-
23
- export const Option = polymorphic<OptionProps>(
24
- ({ as: Root = 'button', value, className, children, ...props }) => (
25
- <Root
26
- {...props}
27
- type="button"
28
- className={classNames('menu-item', className)}
29
- data-value={value}
30
- >
31
- {children}
32
- </Root>
33
- )
34
- );
35
- Option.displayName = 'Option';
36
-
37
- export type SelectProps = Pick<
38
- ButtonProps,
39
- 'className' | 'style' | 'size' | 'theme' | 'variant' | 'disabled' | 'children'
40
- > & {
41
- align?: 'start' | 'end';
42
- menuClassName?: string;
43
- value?: string;
44
- name?: string;
45
- placeholder?: ReactNode;
46
- 'aria-label'?: string;
47
- onChange?: (value: string) => unknown;
48
- valueRender?: (value: string) => ReactNode;
49
- };
50
-
51
- export class Select extends Component<SelectProps> {
52
- static displayName = 'Select';
53
-
54
- private handleSelect = ({ target, defaultPrevented }: MouseEvent<HTMLDivElement>) => {
55
- if (defaultPrevented || this.props.disabled || !(target instanceof Element)) return;
56
-
57
- const option = target.closest<HTMLButtonElement>('[data-value]');
58
-
59
- if (option && !option.disabled && option.getAttribute('aria-disabled') !== 'true')
60
- this.props.onChange?.(option.dataset.value ?? '');
61
- };
62
-
63
- private renderOption = (child: ReactNode) =>
64
- isValidElement<OptionProps>(child) && child.type === Option
65
- ? cloneElement(child, {
66
- className: classNames(
67
- child.props.className,
68
- child.props.value === this.props.value && 'selected'
69
- ),
70
- 'aria-selected': child.props.value === this.props.value
71
- })
72
- : child;
73
-
74
- render() {
75
- const {
76
- align,
77
- className,
78
- menuClassName,
79
- children,
80
- theme = 'primary',
81
- variant = 'solid',
82
- size,
83
- disabled,
84
- style,
85
- value,
86
- onChange: _onChange,
87
- valueRender,
88
- name,
89
- placeholder,
90
- 'aria-label': label
91
- } = this.props;
92
- const current = Children.toArray(children).find(
93
- node =>
94
- isValidElement<OptionProps>(node) &&
95
- node.type === Option &&
96
- node.props.value === value
97
- ) as ReactElement<OptionProps> | undefined;
98
-
99
- return (
100
- <>
101
- <Menu
102
- align={align}
103
- className="w-100"
104
- menuClassName={menuClassName}
105
- label={valueRender?.(value ?? '') ?? current?.props.children ?? placeholder}
106
- toggleProps={{
107
- className: classNames(
108
- 'w-100 d-flex justify-content-between align-items-center',
109
- className
110
- ),
111
- theme,
112
- variant,
113
- size,
114
- disabled,
115
- style,
116
- 'aria-label': label
117
- }}
118
- onClick={this.handleSelect}
119
- >
120
- {Children.map(children, this.renderOption)}
121
- </Menu>
122
- {name && (
123
- <input type="hidden" name={name} value={value ?? ''} disabled={disabled} />
124
- )}
125
- </>
126
- );
127
- }
128
- }
package/source/Image.tsx DELETED
@@ -1,19 +0,0 @@
1
- import classNames from 'classnames';
2
- import { ComponentPropsWithRef } from 'react';
3
-
4
- import { polymorphic } from './Polymorphic';
5
-
6
- export interface ImageProps extends ComponentPropsWithRef<'img'> {
7
- fluid?: boolean;
8
- thumbnail?: boolean;
9
- }
10
-
11
- export const Image = polymorphic<ImageProps>(
12
- ({ as: Root = 'img', fluid, thumbnail, className, ...props }) => (
13
- <Root
14
- {...props}
15
- className={classNames({ 'img-fluid': fluid, 'img-thumbnail': thumbnail }, className)}
16
- />
17
- )
18
- );
19
- Image.displayName = 'Image';
File without changes
File without changes
File without changes
File without changes