idea-react 3.0.0-rc.1 → 3.0.0-rc.3

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/dist/style.css CHANGED
@@ -1,7 +1,7 @@
1
1
  .HR-isq_paused .carousel-indicators .active:after {
2
2
  animation-play-state: paused;
3
3
  }
4
- .rDVV3q_hiddenBackdrop {
4
+ .h491eq_hiddenBackdrop {
5
5
  --bs-dialog-backdrop-bg: transparent;
6
6
  --bs-dialog-backdrop-blur: 0;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-react",
3
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.3",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "author": "shiy2008@gmail.com",
6
6
  "description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.",
@@ -36,7 +36,7 @@
36
36
  "html2canvas": "^1.4.1",
37
37
  "iterable-observer": "^1.1.1",
38
38
  "lodash": "^4.18.1",
39
- "marked": "^18.1.3",
39
+ "marked": "^18.2.0",
40
40
  "mobx-react-helper": "^0.5.4",
41
41
  "react-live": "^5.0.1",
42
42
  "shiki": "^4.6.0",
@@ -74,11 +74,11 @@
74
74
  "koapache": "^3.0.0",
75
75
  "less": "^4.9.1",
76
76
  "lint-staged": "^17.6.0",
77
- "mobx": "^7.1.5",
77
+ "mobx": "^7.1.6",
78
78
  "mobx-react": "^10.0.3",
79
79
  "parcel": "~2.16.4",
80
80
  "postcss": "^8.5.32",
81
- "prettier": "^3.9.10",
81
+ "prettier": "^3.10.0",
82
82
  "prettier-plugin-css-order": "^2.2.0",
83
83
  "process": "^0.11.10",
84
84
  "prop-types": "15.8.1",
@@ -44,7 +44,7 @@ export const Button = polymorphic<ButtonProps>(
44
44
  const link = isButtonLink(attributes);
45
45
  const Root = RootAs ?? (link ? 'a' : 'button');
46
46
  const nativeButton = Root === 'button';
47
- const role = attributes.role ?? 'button';
47
+ const role = attributes.role ?? (link ? 'link' : 'button');
48
48
  const onClick =
49
49
  !nativeButton && disabled
50
50
  ? typeof Root === 'string'
@@ -19,7 +19,7 @@ import styles from './style.module.css';
19
19
  const transitionMilliseconds = (value: string) =>
20
20
  (parseFloat(value) || 0) * (value.trim().endsWith('ms') ? 1 : 1000);
21
21
 
22
- export interface NativeDialogProps extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open'> {
22
+ export interface DialogProps extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open'> {
23
23
  modal?: boolean;
24
24
  dialog?: boolean;
25
25
  theme?: 'light' | 'dark';
@@ -61,16 +61,16 @@ export const DialogFooter = polymorphic<ComponentPropsWithRef<'div'>>(
61
61
  );
62
62
  DialogFooter.displayName = 'DialogFooter';
63
63
 
64
- export class NativeDialog<T extends ElementType | undefined = 'dialog'> extends Component<
65
- PolymorphicClassProps<T, NativeDialogProps>
64
+ export class Dialog<T extends ElementType | undefined = 'dialog'> extends Component<
65
+ PolymorphicClassProps<T, DialogProps>
66
66
  > {
67
- declare readonly props: PolymorphicClassProps<T, NativeDialogProps>;
67
+ declare readonly props: PolymorphicClassProps<T, DialogProps>;
68
68
 
69
- protected get componentProps(): Readonly<NativeDialogProps & AsProps> {
69
+ protected get componentProps(): Readonly<DialogProps & AsProps> {
70
70
  return this.props;
71
71
  }
72
72
 
73
- static scrollLocks = new Set<NativeDialog<ElementType>>();
73
+ static scrollLocks = new Set<Dialog<ElementType>>();
74
74
  static bodyOverflow = '';
75
75
 
76
76
  element = createRef<HTMLDialogElement>();
@@ -86,7 +86,7 @@ export class NativeDialog<T extends ElementType | undefined = 'dialog'> extends
86
86
  if (this.componentProps.open) this.show();
87
87
  }
88
88
 
89
- componentDidUpdate({ open, modal, scroll }: NativeDialogProps) {
89
+ componentDidUpdate({ open, modal, scroll }: DialogProps) {
90
90
  const modeChanged = this.componentProps.modal !== modal;
91
91
  const openChanged = this.componentProps.open !== open;
92
92
  const wasOpen = this.open;
@@ -121,20 +121,20 @@ export class NativeDialog<T extends ElementType | undefined = 'dialog'> extends
121
121
  };
122
122
 
123
123
  lockScroll = () => {
124
- const { scrollLocks } = NativeDialog;
124
+ const { scrollLocks } = Dialog;
125
125
 
126
126
  if (!scrollLocks.size) {
127
- NativeDialog.bodyOverflow = document.body.style.overflow;
127
+ Dialog.bodyOverflow = document.body.style.overflow;
128
128
  document.body.style.overflow = 'hidden';
129
129
  }
130
130
  scrollLocks.add(this);
131
131
  };
132
132
 
133
133
  unlockScroll = () => {
134
- const { scrollLocks } = NativeDialog;
134
+ const { scrollLocks } = Dialog;
135
135
 
136
136
  if (!scrollLocks.delete(this)) return;
137
- if (!scrollLocks.size) document.body.style.overflow = NativeDialog.bodyOverflow;
137
+ if (!scrollLocks.size) document.body.style.overflow = Dialog.bodyOverflow;
138
138
  };
139
139
 
140
140
  close = () => {
@@ -8,7 +8,7 @@ import { Component, ComponentPropsWithRef, createRef, ElementType, ReactNode } f
8
8
  import { AsProps, polymorphic, PolymorphicClassProps } from '../Helper/Polymorphic';
9
9
  import { Breakpoint } from '../Layout/Grid';
10
10
  import { CloseButton } from './CloseButton';
11
- import { NativeDialog, NativeDialogProps } from './NativeDialog';
11
+ import { Dialog, DialogProps } from './Dialog';
12
12
 
13
13
  export type DrawerPlacement = 'start' | 'end' | 'top' | 'bottom';
14
14
 
@@ -41,7 +41,7 @@ export const DrawerFooter = polymorphic<ComponentPropsWithRef<'div'>>(
41
41
  DrawerFooter.displayName = 'DrawerFooter';
42
42
 
43
43
  export interface DrawerProps extends Omit<
44
- NativeDialogProps,
44
+ DialogProps,
45
45
  'dialog' | 'onClose' | 'title' | 'animation' | 'fullscreen'
46
46
  > {
47
47
  title?: ReactNode;
@@ -78,7 +78,7 @@ export class Drawer<T extends ElementType | undefined = 'dialog'> extends Compon
78
78
 
79
79
  @observable accessor expanded = false;
80
80
 
81
- dialog = createRef<NativeDialog<ElementType>>();
81
+ dialog = createRef<Dialog<ElementType>>();
82
82
  media?: MediaQueryList;
83
83
  dismissed = false;
84
84
 
@@ -146,7 +146,7 @@ export class Drawer<T extends ElementType | undefined = 'dialog'> extends Compon
146
146
  } = this.componentProps;
147
147
 
148
148
  return (
149
- <NativeDialog
149
+ <Dialog
150
150
  as={this.componentProps.as}
151
151
  {...props}
152
152
  ref={this.dialog}
@@ -176,7 +176,7 @@ export class Drawer<T extends ElementType | undefined = 'dialog'> extends Compon
176
176
  </DrawerHeader>
177
177
  <DrawerBody className={bodyClassName}>{children}</DrawerBody>
178
178
  {footer && <DrawerFooter>{footer}</DrawerFooter>}
179
- </NativeDialog>
179
+ </Dialog>
180
180
  );
181
181
  }
182
182
  }
@@ -26,45 +26,31 @@ export const Placeholder = polymorphic<PlaceholderProps>(
26
26
  <Root
27
27
  {...props}
28
28
  className={classNames(
29
- 'placeholder',
30
- size && `placeholder-${size}`,
31
- animation && `placeholder-${animation}`,
32
- theme && `bg-${theme}`,
29
+ animation ? `placeholder-${animation}` : 'placeholder',
30
+ !animation && size && `placeholder-${size}`,
31
+ !animation && theme && `bg-${theme}`,
33
32
  className
34
33
  )}
35
- style={{ width, ...style }}
34
+ style={{ width: animation ? undefined : width, ...style }}
36
35
  aria-hidden={hidden}
37
36
  />
38
37
  )
39
38
  );
40
39
  Placeholder.displayName = 'Placeholder';
41
40
 
42
- export interface PlaceholderAnimationProps extends ComponentPropsWithRef<'div'> {
43
- animation?: PlaceholderProps['animation'];
44
- }
45
-
46
- export const PlaceholderAnimation = polymorphic<PlaceholderAnimationProps>(
47
- ({ as: Root = 'div', animation = 'wave', className, ...props }) => (
48
- <Root
49
- {...props}
50
- className={classNames(`placeholder-${animation}`, className)}
51
- aria-hidden="true"
52
- />
53
- )
54
- );
55
- PlaceholderAnimation.displayName = 'PlaceholderAnimation';
56
-
57
41
  export type PlaceholderButtonProps = ButtonProps;
58
42
 
59
43
  export const PlaceholderButton = polymorphic<PlaceholderButtonProps>(
60
- ({ as: RootAs, className, ...props }) => (
44
+ ({ as: RootAs, className, children = '\u00a0', ...props }) => (
61
45
  <Button
62
46
  as={RootAs}
63
47
  {...props}
64
48
  className={classNames('placeholder', className)}
65
49
  aria-hidden="true"
66
50
  disabled
67
- />
51
+ >
52
+ {children}
53
+ </Button>
68
54
  )
69
55
  );
70
56
  PlaceholderButton.displayName = 'PlaceholderButton';
@@ -9,11 +9,11 @@ export * from './Card';
9
9
  export * from './Carousel';
10
10
  export * from './CloseButton';
11
11
  export * from './Collapse';
12
+ export * from './Dialog';
12
13
  export * from './Drawer';
13
14
  export * from './Fade';
14
15
  export * from './ListGroup';
15
16
  export * from './Menu';
16
- export * from './NativeDialog';
17
17
  export * from './Nav';
18
18
  export * from './Navbar';
19
19
  export * from './NavOverflow';
@@ -2,7 +2,7 @@ import classNames from 'classnames';
2
2
  import { ComponentPropsWithRef } from 'react';
3
3
 
4
4
  import { polymorphic } from '../Helper/Polymorphic';
5
- import { Image, ImageProps } from './Images';
5
+ import { Image, ImageProps } from './Image';
6
6
 
7
7
  export type FigureProps = ComponentPropsWithRef<'figure'>;
8
8
 
@@ -10,26 +10,35 @@ export interface TableProps extends ComponentPropsWithRef<'table'> {
10
10
  hover?: boolean;
11
11
  bordered?: boolean;
12
12
  borderless?: boolean;
13
+ card?: boolean;
13
14
  small?: boolean;
14
15
  responsive?: boolean | Breakpoint;
16
+ stacked?: boolean | Breakpoint;
17
+ verticalAlign?: 'baseline' | 'top' | 'middle' | 'bottom' | 'text-top' | 'text-bottom';
18
+ captionTop?: boolean;
15
19
  }
16
20
 
17
21
  export const Table = polymorphic<TableProps>(
18
22
  ({
19
23
  as: RootAs,
24
+ className,
25
+ children,
20
26
  striped,
21
27
  stripedColumns,
22
28
  hover,
23
29
  bordered,
24
30
  borderless,
31
+ card,
25
32
  small,
26
33
  responsive,
27
- className,
28
- children,
34
+ stacked,
35
+ verticalAlign,
36
+ captionTop,
29
37
  ...props
30
38
  }) => {
31
39
  const Root = RootAs ?? 'div';
32
40
  const TableRoot = !responsive && RootAs ? RootAs : 'table';
41
+ const hasWrapper = !!responsive || !!card;
33
42
 
34
43
  const table = (
35
44
  <TableRoot
@@ -44,6 +53,10 @@ export const Table = polymorphic<TableProps>(
44
53
  'table-borderless': borderless,
45
54
  'table-sm': small
46
55
  },
56
+ stacked === true && 'table-stacked',
57
+ typeof stacked === 'string' && `${stacked}:table-stacked`,
58
+ verticalAlign && `align-${verticalAlign}`,
59
+ captionTop && 'caption-top',
47
60
  responsive && RootAs ? undefined : className
48
61
  )}
49
62
  >
@@ -51,15 +64,16 @@ export const Table = polymorphic<TableProps>(
51
64
  </TableRoot>
52
65
  );
53
66
 
54
- return !responsive ? (
67
+ return !hasWrapper ? (
55
68
  table
56
69
  ) : (
57
70
  <Root
58
- {...(RootAs ? props : {})}
71
+ {...(responsive && RootAs ? props : {})}
59
72
  className={classNames(
60
- 'table-responsive',
61
- responsive !== true && `${responsive}:table-responsive`,
62
- RootAs && className
73
+ responsive && 'table-responsive',
74
+ responsive && responsive !== true && `${responsive}:table-responsive`,
75
+ card && 'table-card',
76
+ responsive && RootAs && className
63
77
  )}
64
78
  >
65
79
  {table}
@@ -1,3 +1,3 @@
1
1
  export * from './Figure';
2
- export * from './Images';
2
+ export * from './Image';
3
3
  export * from './Tables';
@@ -3,17 +3,17 @@ import { action, observable } from 'mobx';
3
3
  import { observer } from 'mobx-react';
4
4
  import { FC } from 'react';
5
5
 
6
- export class DialogClose extends Error {
6
+ export class DialogBoxClose extends Error {
7
7
  constructor(message = 'Dialog closed') {
8
8
  super(message);
9
9
  }
10
10
  }
11
11
 
12
- export interface DialogProps<T = unknown> {
12
+ export interface DialogBoxProps<T = unknown> {
13
13
  defer?: Defer<T>;
14
14
  }
15
15
 
16
- export class Dialog<I extends object = {}, O = unknown> {
16
+ export class DialogBox<I extends object = {}, O = unknown> {
17
17
  @observable
18
18
  accessor input = {} as I;
19
19
 
@@ -22,11 +22,11 @@ export class Dialog<I extends object = {}, O = unknown> {
22
22
 
23
23
  Component: FC<I>;
24
24
 
25
- constructor(Factory: FC<I & DialogProps<O>>) {
25
+ constructor(Factory: FC<I & DialogBoxProps<O>>) {
26
26
  this.Component = observer(props => (
27
27
  <Factory {...props} {...this.input} defer={this.defer} />
28
28
  ));
29
- this.Component.displayName = 'DialogComponent';
29
+ this.Component.displayName = 'DialogBoxComponent';
30
30
  }
31
31
 
32
32
  @action
@@ -6,7 +6,7 @@ import { observer } from 'mobx-react';
6
6
  import { Component, createRef, HTMLAttributes, MouseEvent } from 'react';
7
7
  import { blobOf } from 'web-utility';
8
8
 
9
- import { Image } from '../Content/Images';
9
+ import { Image } from '../Content/Image';
10
10
  import { Loading } from './Loading';
11
11
 
12
12
  export async function elementToImage(element: HTMLElement, type?: string, quality?: number) {
@@ -1,7 +1,7 @@
1
1
  import { HTMLAttributes } from 'react';
2
2
 
3
3
  import { Badge } from '../../Base/Badge';
4
- import { Image } from '../../Content/Images';
4
+ import { Image } from '../../Content/Image';
5
5
  import { Table } from '../../Content/Tables';
6
6
  import { polymorphic } from '../../Helper/Polymorphic';
7
7
  import { Col, Container, Row } from '../../Layout/Grid';
@@ -5,18 +5,19 @@ import { ComponentTheme } from '../Base/Button';
5
5
  import { Icon, IconProps } from '../Extension/Icon';
6
6
  import { polymorphic } from '../Helper/Polymorphic';
7
7
 
8
- export type ChipProps = ComponentPropsWithRef<'button'> & {
8
+ export type ChipProps = ComponentPropsWithRef<'span'> & {
9
9
  active?: boolean;
10
10
  theme?: ComponentTheme;
11
+ type?: ComponentPropsWithRef<'button'>['type'];
11
12
  };
12
13
 
13
14
  export const Chip = polymorphic<ChipProps>(
14
- ({ as: Root = 'button', className, active, theme, type = 'button', ...props }) => (
15
+ ({ as: Root = 'span', className, active, theme, type = 'button', ...props }) => (
15
16
  <Root
16
17
  {...props}
17
18
  className={classNames('chip', { active }, theme && `theme-${theme}`, className)}
18
19
  type={Root === 'button' ? type : undefined}
19
- aria-pressed={active}
20
+ aria-pressed={Root === 'button' ? active : undefined}
20
21
  />
21
22
  )
22
23
  );
@@ -49,16 +50,3 @@ export const ChipDismiss = polymorphic<ComponentPropsWithRef<'button'>>(
49
50
  )
50
51
  );
51
52
  ChipDismiss.displayName = 'ChipDismiss';
52
-
53
- export type ChipTokenProps = ComponentPropsWithRef<'span'> & Pick<ChipProps, 'active' | 'theme'>;
54
-
55
- export const ChipToken = polymorphic<ChipTokenProps>(
56
- ({ as: Root = 'span', className, active, theme, ...props }) => (
57
- <Root
58
- {...props}
59
- tabIndex={props.tabIndex ?? 0}
60
- className={classNames('chip', { active }, theme && `theme-${theme}`, className)}
61
- />
62
- )
63
- );
64
- ChipToken.displayName = 'ChipToken';
File without changes