idea-react 3.0.0-rc.2 → 3.0.0-rc.4

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.
@@ -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
  }
@@ -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
 
@@ -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
@@ -3,8 +3,8 @@
3
3
  import classNames from 'classnames';
4
4
  import { action, computed, observable } from 'mobx';
5
5
  import { observer } from 'mobx-react';
6
- import { Component, ElementType } from 'react';
7
- import { scrollTo, uniqueID } from 'web-utility';
6
+ import { Component, ElementType, MouseEvent } from 'react';
7
+ import { uniqueID } from 'web-utility';
8
8
 
9
9
  import { Nav, NavLink, NavProps } from '../Base/Nav';
10
10
  import { AsProps, PolymorphicClassProps } from '../Helper/Polymorphic';
@@ -104,13 +104,14 @@ export class PageNav<T extends ElementType | undefined = 'nav'> extends Componen
104
104
  window.removeEventListener('resize', this.updateScrollY);
105
105
  }
106
106
 
107
- scrollTo = (meta: HeadingMeta) => () => {
108
- setTimeout(() => scrollTo(`[id="${meta.id}"]`));
107
+ handleItemClick = ({ currentTarget }: MouseEvent<HTMLAnchorElement>) => {
108
+ const id = currentTarget.hash.slice(1);
109
+ const meta = this.list.find(item => item.id === id);
109
110
 
110
- this.componentProps.onItemClick?.(meta);
111
+ if (meta) this.componentProps.onItemClick?.(meta);
111
112
  };
112
113
 
113
- renderLink = ({ id, level, text, top }: HeadingMeta) => {
114
+ renderLink = ({ id, level, text }: HeadingMeta) => {
114
115
  const { currentActiveId } = this,
115
116
  { depth = Infinity, minDepth = 1 } = this.componentProps;
116
117
 
@@ -126,7 +127,7 @@ export class PageNav<T extends ElementType | undefined = 'nav'> extends Componen
126
127
  style={{ paddingInlineStart: `${level - minDepth + 0.75}rem` }}
127
128
  href={`#${id}`}
128
129
  aria-current={currentActiveId === id ? 'location' : undefined}
129
- onClick={this.scrollTo({ id, level, text, top })}
130
+ onClick={this.handleItemClick}
130
131
  >
131
132
  {text}
132
133
  </NavLink>
@@ -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';
File without changes