idea-react 3.0.0-beta.0 → 3.0.0-beta.2
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 +19 -2
- package/ReadMe.md +95 -54
- package/dist/DatePickerPlugin-CpGuQRsi.js +1 -0
- package/dist/DatePickerPlugin-DB3nnslN.mjs +1 -0
- package/dist/index.d.mts +1232 -474
- package/dist/index.d.ts +1232 -474
- package/dist/index.js +16 -16
- package/dist/index.mjs +15 -15
- package/dist/rolldown-runtime-5iZMYShA.js +1 -0
- package/dist/style.css +66 -66
- package/package.json +1 -1
- package/source/Accordion.tsx +161 -0
- package/source/Alert.tsx +153 -0
- package/source/Avatar.tsx +57 -46
- package/source/Badge.tsx +17 -15
- package/source/Breadcrumb.tsx +50 -0
- package/source/Button.tsx +69 -40
- package/source/ButtonGroup.tsx +23 -18
- package/source/Card.tsx +86 -17
- package/source/Carousel/index.tsx +392 -0
- package/source/Carousel/model.ts +113 -0
- package/source/Carousel/scroll.ts +79 -0
- package/source/CloseButton.tsx +20 -15
- package/source/Collapse.tsx +233 -0
- package/source/Drawer.tsx +158 -38
- package/source/{ClickBoundary.tsx → Extension/ClickBoundary.tsx} +24 -5
- package/source/Extension/CodeBlock.tsx +64 -0
- package/source/{Countdown.tsx → Extension/Countdown.tsx} +21 -9
- package/source/{Dialog.tsx → Extension/Dialog.tsx} +10 -6
- package/source/Extension/Editor.tsx +78 -0
- package/source/Extension/EditorHTML.tsx +20 -0
- package/source/{HorizontalMarquee → Extension/HorizontalMarquee}/index.module.less +1 -3
- package/source/Extension/HorizontalMarquee/index.tsx +85 -0
- package/source/Extension/Icon.tsx +19 -0
- package/source/Extension/Loading.tsx +30 -0
- package/source/{MonthCalendar.tsx → Extension/MonthCalendar.tsx} +29 -13
- package/source/{Nameplate.tsx → Extension/Nameplate.tsx} +1 -1
- package/source/Extension/OverlayBox.tsx +293 -0
- package/source/{PageNav.tsx → Extension/PageNav.tsx} +43 -16
- package/source/{ScrollNav → Extension/ScrollNav}/Scroller.tsx +21 -5
- package/source/Extension/ScrollNav/index.tsx +47 -0
- package/source/Extension/Select.tsx +128 -0
- package/source/{ShareBox.tsx → Extension/ShareBox.tsx} +1 -1
- package/source/Extension/SpinnerButton.tsx +30 -0
- package/source/Extension/TableSpinner.tsx +22 -0
- package/source/Extension/TextTruncate/index.tsx +29 -0
- package/source/Extension/Time.tsx +17 -0
- package/source/Extension/TimeDistance.tsx +45 -0
- package/source/Extension/Timeline/index.tsx +63 -0
- package/source/Extension/TypeEcho/Content.tsx +123 -0
- package/source/Extension/TypeEcho/index.tsx +22 -0
- package/source/Extension/UserRank/Address.tsx +22 -0
- package/source/Extension/UserRank/index.tsx +106 -0
- package/source/Extension/VerticalMarquee/index.tsx +23 -0
- package/source/Extension/ZodiacBar.tsx +59 -0
- package/source/Extension/index.ts +27 -0
- package/source/Form/Adorn.tsx +45 -26
- package/source/Form/Checkbox.tsx +20 -11
- package/source/Form/ChipInput.tsx +129 -0
- package/source/Form/Chips.tsx +57 -37
- package/source/Form/Combobox.tsx +362 -78
- package/source/Form/Control.tsx +72 -42
- package/source/Form/DatePicker.tsx +245 -45
- package/source/Form/DatePickerPlugin.ts +37 -0
- package/source/Form/Feedback.tsx +21 -16
- package/source/Form/FloatingLabel.tsx +21 -7
- package/source/Form/InputGroup.tsx +162 -11
- package/source/Form/OTP.tsx +156 -45
- package/source/Form/PasswordStrength.tsx +43 -17
- package/source/Form/Plugin.tsx +53 -0
- package/source/Form/Primitives.tsx +70 -20
- package/source/Form/Radio.tsx +35 -40
- package/source/Form/Range.tsx +125 -56
- package/source/Form/Switch.tsx +53 -27
- package/source/Form/index.ts +1 -0
- package/source/Grid.tsx +68 -56
- package/source/Image.tsx +10 -6
- package/source/ListGroup.tsx +59 -58
- package/source/Menu.tsx +317 -46
- package/source/NativeDialog/index.tsx +148 -22
- package/source/Nav.tsx +49 -33
- package/source/NavOverflow/index.tsx +323 -0
- package/source/NavOverflow/model.ts +21 -0
- package/source/Navbar.tsx +65 -45
- package/source/Overlay.ts +163 -1
- package/source/Pagination.tsx +86 -0
- package/source/Placeholder.tsx +70 -0
- package/source/Polymorphic.ts +57 -0
- package/source/Popover.tsx +34 -26
- package/source/Progress/index.tsx +81 -0
- package/source/Progress/style.module.css +15 -0
- package/source/ScrollSpy/index.tsx +380 -0
- package/source/ScrollSpy/model.ts +17 -0
- package/source/Spinner.tsx +31 -17
- package/source/Stack.tsx +25 -0
- package/source/Stepper.tsx +91 -0
- package/source/Tab.tsx +261 -0
- package/source/Table.tsx +53 -42
- package/source/Toast.tsx +93 -46
- package/source/ToggleButton.tsx +47 -30
- package/source/Toggler.tsx +117 -0
- package/source/Tooltip.tsx +31 -24
- package/source/index.ts +17 -27
- package/source/CodeBlock.tsx +0 -40
- package/source/Editor.tsx +0 -43
- package/source/EditorHTML.tsx +0 -16
- package/source/HorizontalMarquee/index.tsx +0 -61
- package/source/Icon.tsx +0 -24
- package/source/Loading.tsx +0 -22
- package/source/OverlayBox.tsx +0 -208
- package/source/ScrollNav/index.tsx +0 -22
- package/source/Select.tsx +0 -95
- package/source/SpinnerButton.tsx +0 -35
- package/source/TableSpinner.tsx +0 -26
- package/source/TextTruncate/index.tsx +0 -25
- package/source/Time.tsx +0 -15
- package/source/TimeDistance.tsx +0 -41
- package/source/Timeline/index.tsx +0 -60
- package/source/TypeEcho/Content.tsx +0 -58
- package/source/TypeEcho/index.tsx +0 -14
- package/source/UserRank/Address.tsx +0 -20
- package/source/UserRank/index.tsx +0 -111
- package/source/VerticalMarquee/index.tsx +0 -25
- package/source/ZodiacBar.tsx +0 -51
- /package/source/{LiveTSX.tsx → Extension/LiveTSX.tsx} +0 -0
- /package/source/{ScrollNav → Extension/ScrollNav}/index.module.less +0 -0
- /package/source/{TextTruncate → Extension/TextTruncate}/Content.tsx +0 -0
- /package/source/{Timeline → Extension/Timeline}/index.module.less +0 -0
- /package/source/{UserRank → Extension/UserRank}/index.module.less +0 -0
- /package/source/{VerticalMarquee → Extension/VerticalMarquee}/index.module.less +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { ButtonHTMLAttributes, Component, ElementType, KeyboardEvent, MouseEvent } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button, ComponentTheme } from './Button';
|
|
7
|
+
import { AsProps, PolymorphicClassProps } from './Polymorphic';
|
|
8
|
+
|
|
9
|
+
export interface TogglerProps extends Omit<ButtonHTMLAttributes<HTMLElement>, 'value'> {
|
|
10
|
+
as?: 'button' | 'div' | 'span';
|
|
11
|
+
target?: string;
|
|
12
|
+
attribute?: string;
|
|
13
|
+
value?: string | number | boolean | null;
|
|
14
|
+
theme?: ComponentTheme;
|
|
15
|
+
variant?: 'solid' | 'outline' | 'subtle' | 'text' | 'link';
|
|
16
|
+
onToggled?: (targets: HTMLElement[]) => unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class Toggler<T extends ElementType | undefined = 'button'> extends Component<
|
|
20
|
+
PolymorphicClassProps<T, TogglerProps>
|
|
21
|
+
> {
|
|
22
|
+
static displayName = 'Toggler';
|
|
23
|
+
|
|
24
|
+
declare readonly props: PolymorphicClassProps<T, TogglerProps>;
|
|
25
|
+
|
|
26
|
+
protected get componentProps(): Readonly<Omit<TogglerProps, 'as'> & AsProps> {
|
|
27
|
+
return this.props;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
31
|
+
this.componentProps.onClick?.(event);
|
|
32
|
+
|
|
33
|
+
if (event.defaultPrevented || this.componentProps.disabled) return;
|
|
34
|
+
|
|
35
|
+
const { target, attribute = 'class', value, onToggled } = this.componentProps;
|
|
36
|
+
const targets = target
|
|
37
|
+
? [...document.querySelectorAll<HTMLElement>(target)]
|
|
38
|
+
: [event.currentTarget];
|
|
39
|
+
const changes = targets.map(element => ({
|
|
40
|
+
element,
|
|
41
|
+
attribute: element.dataset.bsAttribute ?? attribute,
|
|
42
|
+
value: element.dataset.bsValue ?? value
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
if (changes.some(({ attribute }) => attribute.toLowerCase() === 'id'))
|
|
46
|
+
throw new TypeError('Toggler cannot change the id attribute');
|
|
47
|
+
|
|
48
|
+
for (const { element, attribute, value } of changes) {
|
|
49
|
+
if (value == null) continue;
|
|
50
|
+
|
|
51
|
+
const text = String(value);
|
|
52
|
+
const before = new window.CustomEvent('toggle.bs.toggler', { cancelable: true });
|
|
53
|
+
|
|
54
|
+
if (!element.dispatchEvent(before)) continue;
|
|
55
|
+
|
|
56
|
+
if (attribute === 'class') {
|
|
57
|
+
for (const name of text.split(/\s+/).filter(Boolean))
|
|
58
|
+
element.classList.toggle(name);
|
|
59
|
+
} else if (element.getAttribute(attribute) === text) element.removeAttribute(attribute);
|
|
60
|
+
else element.setAttribute(attribute, text);
|
|
61
|
+
|
|
62
|
+
element.dispatchEvent(new window.CustomEvent('toggled.bs.toggler'));
|
|
63
|
+
}
|
|
64
|
+
onToggled?.(targets);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
handleKeyDown = (event: KeyboardEvent<HTMLElement>) => {
|
|
68
|
+
this.componentProps.onKeyDown?.(event);
|
|
69
|
+
|
|
70
|
+
if (
|
|
71
|
+
!event.defaultPrevented &&
|
|
72
|
+
!this.componentProps.disabled &&
|
|
73
|
+
(event.key === 'Enter' || event.key === ' ')
|
|
74
|
+
) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
event.currentTarget.click();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
render() {
|
|
81
|
+
const {
|
|
82
|
+
as: Tag = 'button',
|
|
83
|
+
target: _target,
|
|
84
|
+
attribute: _attribute,
|
|
85
|
+
value: _value,
|
|
86
|
+
onToggled: _onToggled,
|
|
87
|
+
theme,
|
|
88
|
+
variant,
|
|
89
|
+
disabled,
|
|
90
|
+
...props
|
|
91
|
+
} = this.componentProps;
|
|
92
|
+
|
|
93
|
+
return Tag === 'button' ? (
|
|
94
|
+
<Button
|
|
95
|
+
{...props}
|
|
96
|
+
theme={theme}
|
|
97
|
+
variant={variant}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
onClick={this.handleClick}
|
|
100
|
+
/>
|
|
101
|
+
) : (
|
|
102
|
+
<Tag
|
|
103
|
+
{...props}
|
|
104
|
+
className={classNames(
|
|
105
|
+
theme && `theme-${theme}`,
|
|
106
|
+
variant && `btn-${variant}`,
|
|
107
|
+
props.className
|
|
108
|
+
)}
|
|
109
|
+
role={props.role ?? 'button'}
|
|
110
|
+
tabIndex={disabled ? -1 : (props.tabIndex ?? 0)}
|
|
111
|
+
aria-disabled={disabled || undefined}
|
|
112
|
+
onClick={this.handleClick}
|
|
113
|
+
onKeyDown={this.handleKeyDown}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/source/Tooltip.tsx
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { FC } from 'react';
|
|
3
2
|
|
|
4
3
|
import { OVERLAY_ARROW_POSITIONS, OVERLAY_DIRECTIONS, OverlayTriggerProps } from './Overlay';
|
|
4
|
+
import { polymorphic } from './Polymorphic';
|
|
5
5
|
|
|
6
6
|
export type TooltipProps = OverlayTriggerProps;
|
|
7
7
|
|
|
8
|
-
export const Tooltip
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
export const Tooltip = polymorphic<TooltipProps>(
|
|
9
|
+
({
|
|
10
|
+
as: Root = 'div',
|
|
11
|
+
placement = 'top',
|
|
12
|
+
show = true,
|
|
13
|
+
role = 'tooltip',
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
arrowStyle,
|
|
17
|
+
...props
|
|
18
|
+
}) => (
|
|
19
|
+
<Root
|
|
20
|
+
{...props}
|
|
21
|
+
className={classNames(
|
|
22
|
+
'tooltip',
|
|
23
|
+
{ show },
|
|
24
|
+
`bs-tooltip-${OVERLAY_DIRECTIONS[placement]}`,
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
role={role}
|
|
28
|
+
hidden={!show}
|
|
29
|
+
data-bs-placement={placement}
|
|
30
|
+
>
|
|
31
|
+
<div
|
|
32
|
+
style={arrowStyle}
|
|
33
|
+
className={classNames('tooltip-arrow', OVERLAY_ARROW_POSITIONS[placement])}
|
|
34
|
+
/>
|
|
35
|
+
<div className="tooltip-inner">{children}</div>
|
|
36
|
+
</Root>
|
|
37
|
+
)
|
|
30
38
|
);
|
|
31
|
-
|
|
32
39
|
Tooltip.displayName = 'Tooltip';
|
package/source/index.ts
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
1
|
+
export * from './Accordion';
|
|
2
|
+
export * from './Alert';
|
|
1
3
|
export * from './animate';
|
|
2
4
|
export * from './Avatar';
|
|
3
5
|
export * from './Badge';
|
|
6
|
+
export * from './Breadcrumb';
|
|
4
7
|
export * from './Button';
|
|
5
8
|
export * from './ButtonGroup';
|
|
6
9
|
export * from './Card';
|
|
7
|
-
export * from './
|
|
10
|
+
export * from './Carousel';
|
|
8
11
|
export * from './CloseButton';
|
|
9
|
-
export * from './
|
|
12
|
+
export * from './Collapse';
|
|
10
13
|
export * from './color';
|
|
11
|
-
export * from './Countdown';
|
|
12
|
-
export * from './Dialog';
|
|
13
14
|
export * from './Drawer';
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './EditorHTML';
|
|
15
|
+
export * from './Extension';
|
|
16
16
|
export * from './Form';
|
|
17
17
|
export * from './Grid';
|
|
18
|
-
export * from './HorizontalMarquee';
|
|
19
|
-
export * from './Icon';
|
|
20
18
|
export * from './Image';
|
|
21
19
|
export * from './ListGroup';
|
|
22
|
-
export * from './LiveTSX';
|
|
23
|
-
export * from './Loading';
|
|
24
20
|
export * from './Menu';
|
|
25
|
-
export * from './MonthCalendar';
|
|
26
|
-
export * from './Nameplate';
|
|
27
21
|
export * from './NativeDialog';
|
|
28
22
|
export * from './Nav';
|
|
29
23
|
export * from './Navbar';
|
|
30
|
-
export * from './
|
|
31
|
-
export * from './
|
|
24
|
+
export * from './NavOverflow';
|
|
25
|
+
export * from './Overlay';
|
|
26
|
+
export * from './Pagination';
|
|
27
|
+
export * from './Placeholder';
|
|
28
|
+
export * from './Polymorphic';
|
|
32
29
|
export * from './Popover';
|
|
33
|
-
export * from './
|
|
34
|
-
export * from './
|
|
35
|
-
export * from './ShareBox';
|
|
30
|
+
export * from './Progress';
|
|
31
|
+
export * from './ScrollSpy';
|
|
36
32
|
export * from './Spinner';
|
|
37
|
-
export * from './
|
|
33
|
+
export * from './Stack';
|
|
34
|
+
export * from './Stepper';
|
|
35
|
+
export * from './Tab';
|
|
38
36
|
export * from './Table';
|
|
39
|
-
export * from './TableSpinner';
|
|
40
|
-
export * from './TextTruncate';
|
|
41
|
-
export * from './Time';
|
|
42
|
-
export * from './TimeDistance';
|
|
43
|
-
export * from './Timeline';
|
|
44
37
|
export * from './Toast';
|
|
45
38
|
export * from './ToggleButton';
|
|
39
|
+
export * from './Toggler';
|
|
46
40
|
export * from './Tooltip';
|
|
47
|
-
export * from './TypeEcho';
|
|
48
|
-
export * from './UserRank';
|
|
49
|
-
export * from './VerticalMarquee';
|
|
50
|
-
export * from './ZodiacBar';
|
package/source/CodeBlock.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import js from '@shikijs/langs/javascript';
|
|
2
|
-
import jsx from '@shikijs/langs/jsx';
|
|
3
|
-
import tsx from '@shikijs/langs/tsx';
|
|
4
|
-
import ts from '@shikijs/langs/typescript';
|
|
5
|
-
import githubDark from '@shikijs/themes/github-dark';
|
|
6
|
-
import githubLight from '@shikijs/themes/github-light';
|
|
7
|
-
import { FC, HTMLAttributes, isValidElement } from 'react';
|
|
8
|
-
import reactElementToJSXString from 'react-element-to-jsx-string';
|
|
9
|
-
import { createHighlighterCoreSync } from 'shiki/core';
|
|
10
|
-
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
11
|
-
|
|
12
|
-
const highlighter = createHighlighterCoreSync({
|
|
13
|
-
themes: [githubLight, githubDark],
|
|
14
|
-
langs: [js, jsx, ts, tsx],
|
|
15
|
-
engine: createJavaScriptRegexEngine()
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export interface CodeBlockProps extends HTMLAttributes<HTMLPreElement> {
|
|
19
|
-
language: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const CodeBlock: FC<CodeBlockProps> = ({ className = '', language, children, ...props }) => {
|
|
23
|
-
const sourceCode =
|
|
24
|
-
typeof children === 'string'
|
|
25
|
-
? children
|
|
26
|
-
: reactElementToJSXString(isValidElement(children) ? children : <>{children}</>);
|
|
27
|
-
|
|
28
|
-
const __html = highlighter.codeToHtml(sourceCode, {
|
|
29
|
-
lang: language,
|
|
30
|
-
themes: { light: 'github-light', dark: 'github-dark' },
|
|
31
|
-
defaultColor: 'light',
|
|
32
|
-
structure: 'inline'
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<pre className={`m-0 shiki language-${language} ${className}`} {...props}>
|
|
37
|
-
<code dangerouslySetInnerHTML={{ __html }} className={`language-${language}`} />
|
|
38
|
-
</pre>
|
|
39
|
-
);
|
|
40
|
-
};
|
package/source/Editor.tsx
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { EditorCore, WrapperProps } from '@react-editor-js/core';
|
|
4
|
-
import { observable } from 'mobx';
|
|
5
|
-
import { observer } from 'mobx-react';
|
|
6
|
-
import { Component, InputHTMLAttributes, PropsWithoutRef } from 'react';
|
|
7
|
-
import { createReactEditorJS } from 'react-editor-js';
|
|
8
|
-
|
|
9
|
-
const ReactEditorJS = createReactEditorJS();
|
|
10
|
-
|
|
11
|
-
export type EditorProps = PropsWithoutRef<
|
|
12
|
-
WrapperProps & Pick<InputHTMLAttributes<HTMLInputElement>, 'name' | 'required'>
|
|
13
|
-
>;
|
|
14
|
-
|
|
15
|
-
@observer
|
|
16
|
-
export class Editor extends Component<EditorProps> {
|
|
17
|
-
static displayName = 'Editor';
|
|
18
|
-
|
|
19
|
-
private core?: EditorCore;
|
|
20
|
-
|
|
21
|
-
@observable
|
|
22
|
-
accessor innerValue = this.props.defaultValue;
|
|
23
|
-
|
|
24
|
-
save = async () => this.core && (this.innerValue = await this.core.save());
|
|
25
|
-
|
|
26
|
-
render() {
|
|
27
|
-
const { name, required, children: _children, ...editorProps } = this.props,
|
|
28
|
-
{ innerValue } = this;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="form-control" tabIndex={-1} onBlur={this.save}>
|
|
32
|
-
<input hidden {...{ name, required }} value={JSON.stringify(innerValue)} />
|
|
33
|
-
<ReactEditorJS
|
|
34
|
-
{...editorProps}
|
|
35
|
-
onInitialize={core => {
|
|
36
|
-
this.core = core;
|
|
37
|
-
editorProps.onInitialize?.(core);
|
|
38
|
-
}}
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
package/source/EditorHTML.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { OutputData } from '@editorjs/editorjs';
|
|
2
|
-
import createParser from 'editorjs-html';
|
|
3
|
-
import { FC, HTMLAttributes } from 'react';
|
|
4
|
-
|
|
5
|
-
export const parser = createParser({
|
|
6
|
-
link: ({ data: { link } }: Record<string, any>) => `<a href="${link}">${link}</a>`
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export interface EditorHTMLProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
|
-
data: OutputData;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const EditorHTML: FC<EditorHTMLProps> = ({ data, ...props }) => (
|
|
14
|
-
<article {...props} dangerouslySetInnerHTML={{ __html: parser.parse(data) }} />
|
|
15
|
-
);
|
|
16
|
-
EditorHTML.displayName = 'EditorHTML';
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
import * as style from './index.module.less';
|
|
4
|
-
|
|
5
|
-
export type HorizontalMarqueeProps = HTMLAttributes<HTMLDivElement> &
|
|
6
|
-
Partial<Record<'maxWidth' | 'duration' | 'height', string>>;
|
|
7
|
-
|
|
8
|
-
export const HorizontalMarquee: FC<HorizontalMarqueeProps> = ({
|
|
9
|
-
className = '',
|
|
10
|
-
children,
|
|
11
|
-
maxWidth = '100%',
|
|
12
|
-
duration,
|
|
13
|
-
height,
|
|
14
|
-
...props
|
|
15
|
-
}) => (
|
|
16
|
-
<div className={`overflow-hidden max-w-100 ${className}`} {...props}>
|
|
17
|
-
<div
|
|
18
|
-
className={`d-inline-block align-top text-nowrap ${style.scrollWrap}`}
|
|
19
|
-
style={{
|
|
20
|
-
maxWidth,
|
|
21
|
-
animationDuration: duration,
|
|
22
|
-
height,
|
|
23
|
-
lineHeight: height
|
|
24
|
-
}}
|
|
25
|
-
>
|
|
26
|
-
<div
|
|
27
|
-
className={`d-inline-block ${style.scrollItem}`}
|
|
28
|
-
style={{ animationDuration: duration }}
|
|
29
|
-
>
|
|
30
|
-
{children}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export const HorizontalMarqueeBox: FC<HorizontalMarqueeProps> = ({
|
|
37
|
-
children,
|
|
38
|
-
maxWidth,
|
|
39
|
-
duration,
|
|
40
|
-
height
|
|
41
|
-
}) =>
|
|
42
|
-
height ? (
|
|
43
|
-
<div
|
|
44
|
-
className={`overflow-hidden ${style.scrollHeightWrap}`}
|
|
45
|
-
// @ts-expect-error remove after React 19 released
|
|
46
|
-
style={{ maxWidth: maxWidth, '--scroll-height': height }}
|
|
47
|
-
>
|
|
48
|
-
<div className={`d-inline-block overflow-hidden max-w-100 ${style.scrollContainer}`}>
|
|
49
|
-
<div
|
|
50
|
-
className={`d-block overflow-hidden text-wrap text-break ${style.unScrollItem}`}
|
|
51
|
-
>
|
|
52
|
-
{children}
|
|
53
|
-
</div>
|
|
54
|
-
<HorizontalMarquee duration={duration}>{children}</HorizontalMarquee>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
) : (
|
|
58
|
-
<HorizontalMarquee {...{ maxWidth, duration, height }}>{children}</HorizontalMarquee>
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
HorizontalMarquee.displayName = 'HorizontalMarquee';
|
package/source/Icon.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { FC, HTMLAttributes, PropsWithRef } from 'react';
|
|
3
|
-
|
|
4
|
-
export type IconProps = PropsWithRef<
|
|
5
|
-
HTMLAttributes<HTMLSpanElement> & {
|
|
6
|
-
name: string;
|
|
7
|
-
size?: number;
|
|
8
|
-
}
|
|
9
|
-
>;
|
|
10
|
-
export const Icon: FC<IconProps> = ({
|
|
11
|
-
className,
|
|
12
|
-
style,
|
|
13
|
-
name,
|
|
14
|
-
size,
|
|
15
|
-
...props
|
|
16
|
-
}) => (
|
|
17
|
-
<span
|
|
18
|
-
className={classNames(`bi-${name}`, className)}
|
|
19
|
-
style={{ fontSize: size && `${size}rem`, ...style }}
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
Icon.displayName = 'Icon';
|
package/source/Loading.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Spinner } from './Spinner';
|
|
4
|
-
|
|
5
|
-
export type LoadingProps = HTMLAttributes<HTMLDivElement>;
|
|
6
|
-
|
|
7
|
-
export const Loading: FC<LoadingProps> = ({
|
|
8
|
-
className = '',
|
|
9
|
-
children = 'Loading...',
|
|
10
|
-
...props
|
|
11
|
-
}) => (
|
|
12
|
-
<div
|
|
13
|
-
className={`fixed-top h-100 w-100 d-flex justify-content-center align-items-center opacity-25 bg-black ${className}`}
|
|
14
|
-
{...props}
|
|
15
|
-
>
|
|
16
|
-
<Spinner theme="success" />
|
|
17
|
-
|
|
18
|
-
<span className="ms-3 fg-white">{children}</span>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
Loading.displayName = 'Loading';
|
package/source/OverlayBox.tsx
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { action, observable } from 'mobx';
|
|
5
|
-
import { observer } from 'mobx-react';
|
|
6
|
-
import {
|
|
7
|
-
cloneElement,
|
|
8
|
-
Component,
|
|
9
|
-
createRef,
|
|
10
|
-
FocusEvent,
|
|
11
|
-
HTMLAttributes,
|
|
12
|
-
isValidElement,
|
|
13
|
-
KeyboardEvent,
|
|
14
|
-
MouseEvent,
|
|
15
|
-
ReactElement,
|
|
16
|
-
ReactNode
|
|
17
|
-
} from 'react';
|
|
18
|
-
import { uniqueID } from 'web-utility';
|
|
19
|
-
|
|
20
|
-
import { OverlayPlacement } from './Overlay';
|
|
21
|
-
import { Popover } from './Popover';
|
|
22
|
-
import { Tooltip } from './Tooltip';
|
|
23
|
-
|
|
24
|
-
export type OverlayTrigger = 'click' | 'focus' | 'hover';
|
|
25
|
-
|
|
26
|
-
export interface OverlayBoxProps extends Omit<
|
|
27
|
-
HTMLAttributes<HTMLSpanElement>,
|
|
28
|
-
'children' | 'title'
|
|
29
|
-
> {
|
|
30
|
-
title: ReactNode;
|
|
31
|
-
detail?: ReactNode;
|
|
32
|
-
placement?: OverlayPlacement;
|
|
33
|
-
trigger?: OverlayTrigger | OverlayTrigger[];
|
|
34
|
-
delay?: number | { show: number; hide: number };
|
|
35
|
-
overlayClassName?: string;
|
|
36
|
-
children: ReactElement<{ 'aria-describedby'?: string }>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const PLACEMENT_CLASSES: Record<OverlayPlacement, string> = {
|
|
40
|
-
top: 'bottom-100 start-50 translate-middle-x',
|
|
41
|
-
right: 'top-50 start-100 translate-middle-y',
|
|
42
|
-
bottom: 'top-100 start-50 translate-middle-x',
|
|
43
|
-
left: 'top-50 end-100 translate-middle-y'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const OVERLAY_GAPS: Record<OverlayPlacement, Record<'popover' | 'tooltip', string>> = {
|
|
47
|
-
top: { popover: 'mb-3', tooltip: 'mb-2' },
|
|
48
|
-
right: { popover: 'ms-3', tooltip: 'ms-2' },
|
|
49
|
-
bottom: { popover: 'mt-3', tooltip: 'mt-2' },
|
|
50
|
-
left: { popover: 'me-3', tooltip: 'me-2' }
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
@observer
|
|
54
|
-
export class OverlayBox extends Component<OverlayBoxProps> {
|
|
55
|
-
static displayName = 'OverlayBox';
|
|
56
|
-
|
|
57
|
-
@observable accessor open = false;
|
|
58
|
-
|
|
59
|
-
id = uniqueID();
|
|
60
|
-
root = createRef<HTMLSpanElement>();
|
|
61
|
-
timer?: ReturnType<typeof setTimeout>;
|
|
62
|
-
|
|
63
|
-
@action
|
|
64
|
-
setOpen = (open: boolean) => (this.open = open);
|
|
65
|
-
|
|
66
|
-
hide = () => {
|
|
67
|
-
clearTimeout(this.timer);
|
|
68
|
-
this.setOpen(false);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
setOpenAfterDelay = (open: boolean) => {
|
|
72
|
-
clearTimeout(this.timer);
|
|
73
|
-
|
|
74
|
-
const { delay } = this.props;
|
|
75
|
-
const timeout = typeof delay === 'number' ? delay : delay?.[open ? 'show' : 'hide'];
|
|
76
|
-
|
|
77
|
-
if (!timeout) return this.setOpen(open);
|
|
78
|
-
|
|
79
|
-
this.timer = setTimeout(() => this.setOpen(open), timeout);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
componentWillUnmount() {
|
|
83
|
-
document.removeEventListener('pointerdown', this.handleOutside);
|
|
84
|
-
clearTimeout(this.timer);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
componentDidMount() {
|
|
88
|
-
document.addEventListener('pointerdown', this.handleOutside);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
hasTrigger = (trigger: OverlayTrigger) => {
|
|
92
|
-
const triggers: OverlayTrigger[] = this.props.trigger
|
|
93
|
-
? Array.isArray(this.props.trigger)
|
|
94
|
-
? this.props.trigger
|
|
95
|
-
: [this.props.trigger]
|
|
96
|
-
: ['hover', 'focus'];
|
|
97
|
-
|
|
98
|
-
return triggers.includes(trigger);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
handleMouseEnter = (event: MouseEvent<HTMLSpanElement>) => {
|
|
102
|
-
this.props.onMouseEnter?.(event);
|
|
103
|
-
|
|
104
|
-
if (this.hasTrigger('hover')) this.setOpenAfterDelay(true);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
handleMouseLeave = (event: MouseEvent<HTMLSpanElement>) => {
|
|
108
|
-
this.props.onMouseLeave?.(event);
|
|
109
|
-
|
|
110
|
-
if (this.hasTrigger('hover') && !this.root.current?.contains(document.activeElement))
|
|
111
|
-
this.setOpenAfterDelay(false);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
handleFocus = (event: FocusEvent<HTMLSpanElement>) => {
|
|
115
|
-
this.props.onFocus?.(event);
|
|
116
|
-
|
|
117
|
-
if (this.hasTrigger('focus')) this.setOpenAfterDelay(true);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
handleBlur = (event: FocusEvent<HTMLSpanElement>) => {
|
|
121
|
-
this.props.onBlur?.(event);
|
|
122
|
-
|
|
123
|
-
if (this.hasTrigger('focus') && !event.currentTarget.contains(event.relatedTarget))
|
|
124
|
-
this.setOpenAfterDelay(false);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
handleClick = (event: MouseEvent<HTMLSpanElement>) => {
|
|
128
|
-
this.props.onClick?.(event);
|
|
129
|
-
|
|
130
|
-
if (!event.defaultPrevented && this.hasTrigger('click')) this.setOpenAfterDelay(!this.open);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
handleOutside = ({ target }: PointerEvent) => {
|
|
134
|
-
if (target instanceof Node && !this.root.current?.contains(target)) this.hide();
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
handleKeyDown = (event: KeyboardEvent<HTMLSpanElement>) => {
|
|
138
|
-
this.props.onKeyDown?.(event);
|
|
139
|
-
|
|
140
|
-
if (event.key === 'Escape' && this.open) {
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
this.hide();
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
render() {
|
|
147
|
-
const {
|
|
148
|
-
title,
|
|
149
|
-
detail,
|
|
150
|
-
placement = 'top',
|
|
151
|
-
trigger: _trigger,
|
|
152
|
-
delay: _delay,
|
|
153
|
-
overlayClassName,
|
|
154
|
-
children,
|
|
155
|
-
className = '',
|
|
156
|
-
onMouseEnter: _onMouseEnter,
|
|
157
|
-
onMouseLeave: _onMouseLeave,
|
|
158
|
-
onFocus: _onFocus,
|
|
159
|
-
onBlur: _onBlur,
|
|
160
|
-
onClick: _onClick,
|
|
161
|
-
onKeyDown: _onKeyDown,
|
|
162
|
-
...props
|
|
163
|
-
} = this.props;
|
|
164
|
-
const id = this.open ? this.id : undefined;
|
|
165
|
-
const position = PLACEMENT_CLASSES[placement];
|
|
166
|
-
const gap = OVERLAY_GAPS[placement][detail ? 'popover' : 'tooltip'];
|
|
167
|
-
const overlayClass = classNames('position-absolute w-max', position, gap, overlayClassName);
|
|
168
|
-
const trigger = isValidElement(children)
|
|
169
|
-
? cloneElement(children, {
|
|
170
|
-
'aria-describedby':
|
|
171
|
-
[children.props['aria-describedby'], id].filter(Boolean).join(' ') ||
|
|
172
|
-
undefined
|
|
173
|
-
})
|
|
174
|
-
: children;
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<span
|
|
178
|
-
{...props}
|
|
179
|
-
ref={this.root}
|
|
180
|
-
className={`position-relative d-inline-block ${className}`}
|
|
181
|
-
onMouseEnter={this.handleMouseEnter}
|
|
182
|
-
onMouseLeave={this.handleMouseLeave}
|
|
183
|
-
onFocus={this.handleFocus}
|
|
184
|
-
onBlur={this.handleBlur}
|
|
185
|
-
onClick={this.handleClick}
|
|
186
|
-
onKeyDown={this.handleKeyDown}
|
|
187
|
-
>
|
|
188
|
-
{trigger}
|
|
189
|
-
|
|
190
|
-
{this.open &&
|
|
191
|
-
(detail ? (
|
|
192
|
-
<Popover
|
|
193
|
-
id={id}
|
|
194
|
-
className={overlayClass}
|
|
195
|
-
title={title}
|
|
196
|
-
placement={placement}
|
|
197
|
-
>
|
|
198
|
-
{detail}
|
|
199
|
-
</Popover>
|
|
200
|
-
) : (
|
|
201
|
-
<Tooltip id={id} className={overlayClass} placement={placement}>
|
|
202
|
-
{title}
|
|
203
|
-
</Tooltip>
|
|
204
|
-
))}
|
|
205
|
-
</span>
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
}
|