idea-react 3.0.0-beta.4 → 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.
- package/AGENTS.md +6 -3
- package/ReadMe.md +71 -65
- package/dist/index.d.mts +902 -930
- package/dist/index.d.ts +902 -930
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/style.css +4 -1
- package/package.json +3 -7
- package/source/{Accordion.tsx → Base/Accordion.tsx} +2 -2
- package/source/{Alert.tsx → Base/Alert.tsx} +1 -1
- package/source/{Avatar.tsx → Base/Avatar.tsx} +1 -1
- package/source/{Badge.tsx → Base/Badge.tsx} +1 -1
- package/source/{Breadcrumb.tsx → Base/Breadcrumb.tsx} +1 -1
- package/source/{Button.tsx → Base/Button.tsx} +1 -1
- package/source/{ButtonGroup.tsx → Base/ButtonGroup.tsx} +1 -1
- package/source/{Card.tsx → Base/Card.tsx} +1 -1
- package/source/{Carousel → Base/Carousel}/index.tsx +120 -59
- package/source/{Carousel → Base/Carousel}/model.ts +12 -8
- package/source/Base/Carousel/style.module.css +3 -0
- package/source/{CloseButton.tsx → Base/CloseButton.tsx} +1 -1
- package/source/{Collapse.tsx → Base/Collapse.tsx} +1 -1
- package/source/{Drawer.tsx → Base/Drawer.tsx} +2 -2
- package/source/{ListGroup.tsx → Base/ListGroup.tsx} +2 -2
- package/source/{Menu.tsx → Base/Menu.tsx} +4 -4
- package/source/{NativeDialog → Base/NativeDialog}/index.tsx +2 -2
- package/source/{Nav.tsx → Base/Nav.tsx} +2 -1
- package/source/{NavOverflow → Base/NavOverflow}/index.tsx +2 -2
- package/source/{Navbar.tsx → Base/Navbar.tsx} +1 -1
- package/source/{Pagination.tsx → Base/Pagination.tsx} +1 -1
- package/source/{Placeholder.tsx → Base/Placeholder.tsx} +1 -1
- package/source/{Popover.tsx → Base/Popover.tsx} +6 -2
- package/source/{Progress → Base/Progress}/index.tsx +1 -1
- package/source/{ScrollSpy → Base/ScrollSpy}/index.tsx +1 -1
- package/source/{Spinner.tsx → Base/Spinner.tsx} +2 -2
- package/source/{Stack.tsx → Base/Stack.tsx} +1 -1
- package/source/{Stepper.tsx → Base/Stepper.tsx} +2 -2
- package/source/{Tab.tsx → Base/Tab.tsx} +60 -47
- package/source/{Toast.tsx → Base/Toast.tsx} +1 -1
- package/source/{ToggleButton.tsx → Base/ToggleButton.tsx} +2 -2
- package/source/{Toggler.tsx → Base/Toggler.tsx} +1 -1
- package/source/{Tooltip.tsx → Base/Tooltip.tsx} +6 -2
- package/source/Base/index.ts +31 -0
- package/source/Content/Images.tsx +29 -0
- package/source/{Table.tsx → Content/Tables.tsx} +2 -2
- package/source/Content/index.ts +2 -0
- package/source/Extension/ClickBoundary.tsx +1 -1
- package/source/Extension/CodeBlock.tsx +1 -1
- package/source/Extension/Countdown.tsx +1 -1
- package/source/Extension/HorizontalMarquee/index.tsx +1 -1
- package/source/Extension/Icon.tsx +1 -1
- package/source/Extension/Loading.tsx +2 -2
- package/source/Extension/MarkdownView.tsx +23 -0
- package/source/Extension/MonthCalendar.tsx +4 -4
- package/source/Extension/Nameplate.tsx +1 -1
- package/source/Extension/OverlayBox.tsx +9 -4
- package/source/Extension/PageNav.tsx +2 -2
- package/source/Extension/ScrollNav/Scroller.tsx +1 -1
- package/source/Extension/ScrollNav/index.tsx +2 -2
- package/source/Extension/ShareBox.tsx +1 -1
- package/source/Extension/SpinnerButton.tsx +3 -3
- package/source/Extension/TableSpinner.tsx +2 -2
- package/source/Extension/TextTruncate/index.tsx +1 -1
- package/source/Extension/Time.tsx +1 -1
- package/source/Extension/TimeDistance.tsx +1 -1
- package/source/Extension/Timeline/index.tsx +2 -2
- package/source/Extension/TypeEcho/Content.tsx +1 -1
- package/source/Extension/TypeEcho/index.tsx +1 -1
- package/source/Extension/UserRank/Address.tsx +1 -1
- package/source/Extension/UserRank/index.tsx +5 -5
- package/source/Extension/VerticalMarquee/index.tsx +1 -1
- package/source/Extension/ZodiacBar.tsx +1 -1
- package/source/Extension/index.ts +1 -3
- package/source/Form/Adorn.tsx +1 -1
- package/source/Form/Checkbox.tsx +2 -2
- package/source/Form/{Chips.tsx → Chip.tsx} +4 -11
- package/source/Form/ChipInput.tsx +2 -2
- package/source/Form/Combobox.tsx +2 -2
- package/source/Form/Control.tsx +1 -1
- package/source/Form/DatePicker.tsx +2 -2
- package/source/Form/Feedback.tsx +1 -1
- package/source/Form/FloatingLabel.tsx +1 -1
- package/source/Form/InputGroup.tsx +3 -3
- package/source/Form/OTP.tsx +1 -1
- package/source/Form/Primitives.tsx +8 -1
- package/source/Form/Radio.tsx +2 -2
- package/source/Form/Range.tsx +2 -2
- package/source/Form/Switch.tsx +2 -2
- package/source/Form/index.ts +1 -1
- package/source/{Overlay.ts → Helper/Overlay.ts} +1 -1
- package/source/{color.ts → Helper/color.ts} +1 -1
- package/source/Helper/index.ts +4 -0
- package/source/{Grid.tsx → Layout/Grid.tsx} +1 -1
- package/source/Layout/index.ts +1 -0
- package/source/index.ts +4 -38
- package/source/Extension/Editor.tsx +0 -78
- package/source/Extension/EditorHTML.tsx +0 -20
- package/source/Extension/Select.tsx +0 -128
- package/source/Image.tsx +0 -19
- /package/source/{Carousel → Base/Carousel}/scroll.ts +0 -0
- /package/source/{NativeDialog → Base/NativeDialog}/style.module.css +0 -0
- /package/source/{NavOverflow → Base/NavOverflow}/model.ts +0 -0
- /package/source/{ScrollSpy → Base/ScrollSpy}/model.ts +0 -0
- /package/source/{Polymorphic.ts → Helper/Polymorphic.ts} +0 -0
- /package/source/{animate.ts → Helper/animate.ts} +0 -0
|
@@ -2,18 +2,16 @@ export * from './ClickBoundary';
|
|
|
2
2
|
export * from './CodeBlock';
|
|
3
3
|
export * from './Countdown';
|
|
4
4
|
export * from './Dialog';
|
|
5
|
-
export * from './Editor';
|
|
6
|
-
export * from './EditorHTML';
|
|
7
5
|
export * from './HorizontalMarquee';
|
|
8
6
|
export * from './Icon';
|
|
9
7
|
export * from './LiveTSX';
|
|
10
8
|
export * from './Loading';
|
|
9
|
+
export * from './MarkdownView';
|
|
11
10
|
export * from './MonthCalendar';
|
|
12
11
|
export * from './Nameplate';
|
|
13
12
|
export * from './OverlayBox';
|
|
14
13
|
export * from './PageNav';
|
|
15
14
|
export * from './ScrollNav';
|
|
16
|
-
export * from './Select';
|
|
17
15
|
export * from './ShareBox';
|
|
18
16
|
export * from './SpinnerButton';
|
|
19
17
|
export * from './TableSpinner';
|
package/source/Form/Adorn.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import { Icon, IconProps } from '../Extension/Icon';
|
|
5
|
-
import { polymorphic } from '../Polymorphic';
|
|
5
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
6
6
|
import { FormValidationProps } from './Primitives';
|
|
7
7
|
|
|
8
8
|
export type FormAdornmentProps = Omit<ComponentPropsWithRef<'label'>, 'htmlFor'> &
|
package/source/Form/Checkbox.tsx
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { Component, ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
|
|
5
5
|
|
|
6
|
-
import type { ComponentTheme } from '../Button';
|
|
7
|
-
import { AsProps, polymorphic } from '../Polymorphic';
|
|
6
|
+
import type { ComponentTheme } from '../Base/Button';
|
|
7
|
+
import { AsProps, polymorphic } from '../Helper/Polymorphic';
|
|
8
8
|
import { FormValidationProps } from './Primitives';
|
|
9
9
|
|
|
10
10
|
export type CheckboxProps = Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'size'> &
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { ComponentTheme } from '../Button';
|
|
4
|
+
import { ComponentTheme } from '../Base/Button';
|
|
5
5
|
import { Icon, IconProps } from '../Extension/Icon';
|
|
6
|
-
import { polymorphic } from '../Polymorphic';
|
|
6
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
7
7
|
|
|
8
8
|
export type ChipProps = ComponentPropsWithRef<'button'> & {
|
|
9
9
|
active?: boolean;
|
|
@@ -11,11 +11,11 @@ export type ChipProps = ComponentPropsWithRef<'button'> & {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const Chip = polymorphic<ChipProps>(
|
|
14
|
-
({ as: Root = 'button', className, active, theme, ...props }) => (
|
|
14
|
+
({ as: Root = 'button', className, active, theme, type = 'button', ...props }) => (
|
|
15
15
|
<Root
|
|
16
16
|
{...props}
|
|
17
17
|
className={classNames('chip', { active }, theme && `theme-${theme}`, className)}
|
|
18
|
-
type=
|
|
18
|
+
type={Root === 'button' ? type : undefined}
|
|
19
19
|
aria-pressed={active}
|
|
20
20
|
/>
|
|
21
21
|
)
|
|
@@ -62,10 +62,3 @@ export const ChipToken = polymorphic<ChipTokenProps>(
|
|
|
62
62
|
)
|
|
63
63
|
);
|
|
64
64
|
ChipToken.displayName = 'ChipToken';
|
|
65
|
-
|
|
66
|
-
export const ChipInputLabel = polymorphic<ComponentPropsWithRef<'label'>>(
|
|
67
|
-
({ as: Root = 'label', className, ...props }) => (
|
|
68
|
-
<Root {...props} className={classNames('chip-input-label', className)} />
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
ChipInputLabel.displayName = 'ChipInputLabel';
|
|
@@ -5,9 +5,9 @@ import classNames from 'classnames';
|
|
|
5
5
|
import { ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
|
|
6
6
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
7
7
|
|
|
8
|
-
import { ComponentTheme } from '../Button';
|
|
8
|
+
import { ComponentTheme } from '../Base/Button';
|
|
9
9
|
import { Icon } from '../Extension/Icon';
|
|
10
|
-
import { AsProps, polymorphic } from '../Polymorphic';
|
|
10
|
+
import { AsProps, polymorphic } from '../Helper/Polymorphic';
|
|
11
11
|
import { FormPlugin } from './Plugin';
|
|
12
12
|
import { FormValidationProps } from './Primitives';
|
|
13
13
|
|
package/source/Form/Combobox.tsx
CHANGED
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
ReactNode
|
|
18
18
|
} from 'react';
|
|
19
19
|
|
|
20
|
+
import { Menu, MenuHeader, MenuItemContent, MenuItemDescription } from '../Base/Menu';
|
|
20
21
|
import { Icon } from '../Extension/Icon';
|
|
21
|
-
import {
|
|
22
|
-
import { AsProps, polymorphic, PolymorphicClassProps } from '../Polymorphic';
|
|
22
|
+
import { AsProps, polymorphic, PolymorphicClassProps } from '../Helper/Polymorphic';
|
|
23
23
|
import { FormValidationProps } from './Primitives';
|
|
24
24
|
|
|
25
25
|
export interface ComboboxOptionProps extends ComponentPropsWithRef<'button'> {
|
package/source/Form/Control.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
5
5
|
import { FormValidationProps } from './Primitives';
|
|
6
6
|
|
|
7
7
|
const CONTROL_SIZES = {
|
|
@@ -4,9 +4,9 @@ import Datepicker, { type DatepickerConfig } from 'bootstrap/js/src/datepicker.j
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Button, ButtonProps } from '../Button';
|
|
7
|
+
import { Button, ButtonProps } from '../Base/Button';
|
|
8
8
|
import { Icon } from '../Extension/Icon';
|
|
9
|
-
import { AsProps, polymorphic, PolymorphicComponent } from '../Polymorphic';
|
|
9
|
+
import { AsProps, polymorphic, PolymorphicComponent } from '../Helper/Polymorphic';
|
|
10
10
|
import { FormPlugin } from './Plugin';
|
|
11
11
|
import { FormValidationProps } from './Primitives';
|
|
12
12
|
|
package/source/Form/Feedback.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
5
5
|
|
|
6
6
|
export type FormTextProps = ComponentPropsWithRef<'small'> & {
|
|
7
7
|
block?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { Children, ComponentPropsWithRef, isValidElement, ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
5
5
|
import { FormLabel } from './Primitives';
|
|
6
6
|
|
|
7
7
|
export type FormFloatingLabelProps = ComponentPropsWithRef<'div'> & {
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
ReactElement
|
|
13
13
|
} from 'react';
|
|
14
14
|
|
|
15
|
-
import { Button, ButtonProps } from '../Button';
|
|
16
|
-
import { Menu, MenuProps } from '../Menu';
|
|
17
|
-
import { polymorphic } from '../Polymorphic';
|
|
15
|
+
import { Button, ButtonProps } from '../Base/Button';
|
|
16
|
+
import { Menu, MenuProps } from '../Base/Menu';
|
|
17
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
18
18
|
|
|
19
19
|
export type InputGroupProps = ComponentPropsWithRef<'div'> & {
|
|
20
20
|
size?: 'sm' | 'lg';
|
package/source/Form/OTP.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import type OtpInput from 'bootstrap/js/src/otp-input.js';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { ComponentPropsWithoutRef, forwardRef, Ref } from 'react';
|
|
6
6
|
|
|
7
|
-
import { AsProps, polymorphic } from '../Polymorphic';
|
|
7
|
+
import { AsProps, polymorphic } from '../Helper/Polymorphic';
|
|
8
8
|
import { FormPlugin } from './Plugin';
|
|
9
9
|
import { FormValidationProps } from './Primitives';
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
5
5
|
|
|
6
6
|
export type FormProps = ComponentPropsWithRef<'form'> & {
|
|
7
7
|
validated?: boolean;
|
|
@@ -78,6 +78,13 @@ export const FormLabel = polymorphic<FormLabelProps>(
|
|
|
78
78
|
);
|
|
79
79
|
FormLabel.displayName = 'FormLabel';
|
|
80
80
|
|
|
81
|
+
export const ChipInputLabel = polymorphic<ComponentPropsWithRef<'label'>>(
|
|
82
|
+
({ as: Root = 'label', className, ...props }) => (
|
|
83
|
+
<Root {...props} className={classNames('chip-input-label', className)} />
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
ChipInputLabel.displayName = 'ChipInputLabel';
|
|
87
|
+
|
|
81
88
|
export type FormLegendProps = ComponentPropsWithRef<'legend'> &
|
|
82
89
|
Pick<FormLabelProps, 'column' | 'controlSize'>;
|
|
83
90
|
|
package/source/Form/Radio.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import type { ComponentTheme } from '../Button';
|
|
5
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import type { ComponentTheme } from '../Base/Button';
|
|
5
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
6
6
|
import { Checkbox, CheckboxProps } from './Checkbox';
|
|
7
7
|
import { FormValidationProps } from './Primitives';
|
|
8
8
|
|
package/source/Form/Range.tsx
CHANGED
|
@@ -4,8 +4,8 @@ import type Range from 'bootstrap/js/src/range.js';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { ComponentPropsWithoutRef, CSSProperties, forwardRef, Ref } from 'react';
|
|
6
6
|
|
|
7
|
-
import { ComponentTheme } from '../Button';
|
|
8
|
-
import { AsProps, polymorphic } from '../Polymorphic';
|
|
7
|
+
import { ComponentTheme } from '../Base/Button';
|
|
8
|
+
import { AsProps, polymorphic } from '../Helper/Polymorphic';
|
|
9
9
|
import { FormPlugin } from './Plugin';
|
|
10
10
|
import { FormValidationProps } from './Primitives';
|
|
11
11
|
|
package/source/Form/Switch.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef, CSSProperties, PropsWithChildren, Ref } from 'react';
|
|
3
3
|
|
|
4
|
-
import type { ComponentTheme } from '../Button';
|
|
5
|
-
import { polymorphic } from '../Polymorphic';
|
|
4
|
+
import type { ComponentTheme } from '../Base/Button';
|
|
5
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
6
6
|
import { splitInputProps } from './inputProps';
|
|
7
7
|
import { FormValidationProps } from './Primitives';
|
|
8
8
|
|
package/source/Form/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { action, observable } from 'mobx';
|
|
2
2
|
import { ComponentPropsWithRef, CSSProperties } from 'react';
|
|
3
3
|
|
|
4
|
-
import { Breakpoint } from '
|
|
4
|
+
import { Breakpoint } from '../Layout/Grid';
|
|
5
5
|
|
|
6
6
|
export type OverlayPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
7
7
|
export type FloatingPlacement = OverlayPlacement | `${OverlayPlacement}-${'start' | 'end'}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { ComponentPropsWithRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { polymorphic } from '
|
|
4
|
+
import { polymorphic } from '../Helper/Polymorphic';
|
|
5
5
|
|
|
6
6
|
export type Breakpoint = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
7
7
|
export type ColSize = number | 'auto';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Grid';
|
package/source/index.ts
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
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 './
|
|
18
|
-
export * from './
|
|
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
|
|
File without changes
|
|
File without changes
|