@semcore/notice 2.1.0 → 3.1.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/src/Notice.js ADDED
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import createComponent, { Component, sstyled, Root } from '@semcore/core';
3
+ import { Box } from '@semcore/flex-box';
4
+ import CloseXS from '@semcore/icon/lib/Close/xs';
5
+ import resolveColor from '@semcore/utils/lib/color';
6
+ import { FadeInOut } from '@semcore/animation';
7
+
8
+ import style from './style/notice.shadow.css';
9
+
10
+ function isCustomTheme(theme) {
11
+ return !['danger', 'warning', 'success', 'info'].includes(theme);
12
+ }
13
+
14
+ class RootNotice extends Component {
15
+ static displayName = 'Notice';
16
+ static style = style;
17
+ static defaultProps = {
18
+ use: 'secondary',
19
+ theme: 'info',
20
+ duration: 200,
21
+ };
22
+
23
+ getLabelProps() {
24
+ const { theme } = this.asProps;
25
+ return {
26
+ theme,
27
+ };
28
+ }
29
+
30
+ render() {
31
+ const SNotice = Root;
32
+ const { Children, styles, hidden, theme } = this.asProps;
33
+ const color = resolveColor(theme);
34
+ const useTheme = isCustomTheme(theme) ? 'custom' : theme;
35
+
36
+ return sstyled(styles)(
37
+ <SNotice
38
+ render={FadeInOut}
39
+ visible={!hidden}
40
+ use:theme={useTheme}
41
+ backgroundColor={color}
42
+ role="alert"
43
+ >
44
+ <Children />
45
+ </SNotice>,
46
+ );
47
+ }
48
+ }
49
+
50
+ function Label({ styles, theme }) {
51
+ const SLabel = Root;
52
+ const useTheme = isCustomTheme(theme) ? 'custom' : theme;
53
+ const color = resolveColor(theme);
54
+ return sstyled(styles)(<SLabel render={Box} use:theme={useTheme} color={color} />);
55
+ }
56
+
57
+ function Actions({ styles }) {
58
+ const SActions = Root;
59
+ return sstyled(styles)(<SActions render={Box} />);
60
+ }
61
+
62
+ function Content({ styles }) {
63
+ const SContent = Root;
64
+ return sstyled(styles)(<SContent render={Box} />);
65
+ }
66
+
67
+ function CloseIcon({ styles }) {
68
+ const SCloseIcon = Root;
69
+ return sstyled(styles)(
70
+ <SCloseIcon render={Box} tag={CloseXS} color="stone" interactive aria-label="Close alert" />,
71
+ );
72
+ }
73
+
74
+ export default createComponent(RootNotice, {
75
+ Label,
76
+ Actions,
77
+ Content,
78
+ CloseIcon,
79
+ });
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import createComponent, { Component, Root } from '@semcore/core';
3
+ import isNode from '@semcore/utils/lib/isNode';
4
+ import Notice from './Notice';
5
+
6
+ class NoticeSmart extends Component {
7
+ static displayName = 'NoticeSmart';
8
+
9
+ static defaultProps = {
10
+ theme: 'info',
11
+ };
12
+
13
+ render() {
14
+ const SNoticeSmart = Root;
15
+ const { Children, label, actions, closable, onClose } = this.asProps;
16
+ return (
17
+ <SNoticeSmart render={Notice}>
18
+ {isNode(label) && <Notice.Label>{label}</Notice.Label>}
19
+ <Notice.Content>
20
+ <Children />
21
+ {isNode(actions) && <Notice.Actions>{actions}</Notice.Actions>}
22
+ </Notice.Content>
23
+ {closable && <Notice.CloseIcon onClick={onClose} />}
24
+ </SNoticeSmart>
25
+ );
26
+ }
27
+ }
28
+
29
+ export default createComponent(NoticeSmart);
package/src/index.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { CProps, PropGetterFn, ReturnEl } from '@semcore/core';
2
+ import { Box, IBoxProps } from '@semcore/flex-box';
3
+ import { IIconProps } from '@semcore/icon';
4
+
5
+ export type NoticeTheme = 'danger' | 'warning' | 'success' | 'info' | string;
6
+ export type NoticeUse = 'primary' | 'secondary';
7
+
8
+ export interface INoticeProps extends IBoxProps {
9
+ /** Property for managing visibility of Notice */
10
+ hidden?: boolean;
11
+ /** Notice type
12
+ * @default secondary
13
+ */
14
+ use?: NoticeUse;
15
+ /**
16
+ * Notice theme
17
+ * @default info
18
+ */
19
+ theme?: NoticeTheme;
20
+ /** Duration of animation, ms
21
+ * @default 200
22
+ */
23
+ duration?: number;
24
+ }
25
+
26
+ export interface INoticeLabelProps extends IBoxProps {
27
+ theme?: NoticeTheme;
28
+ }
29
+
30
+ export interface INoticeContext {
31
+ getLabelProps: PropGetterFn;
32
+ }
33
+
34
+ export interface INoticeSmartProps extends INoticeProps {
35
+ /**
36
+ * A custom element for additional information
37
+ */
38
+ label?: React.ReactNode;
39
+ /**
40
+ * Custom action element
41
+ */
42
+ actions?: React.ReactNode;
43
+ /**
44
+ * Adds a Close icon
45
+ */
46
+ closable?: boolean;
47
+ /**
48
+ * Callback on a click on the close button
49
+ */
50
+ onClose?: (event: React.SyntheticEvent) => void;
51
+ }
52
+
53
+ declare const Notice: (<T>(props: CProps<INoticeProps & T, INoticeContext>) => ReturnEl) & {
54
+ Label: <T>(props: INoticeLabelProps & T) => ReturnEl;
55
+ Actions: typeof Box;
56
+ Content: typeof Box;
57
+ CloseIcon: <T>(props: IIconProps & T) => ReturnEl;
58
+ };
59
+
60
+ declare const NoticeSmart: <T>(props: CProps<INoticeSmartProps & T>) => ReturnEl;
61
+
62
+ export { NoticeSmart };
63
+ export default Notice;
package/src/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { default as Notice } from './Notice';
2
+
3
+ export default Notice;
4
+ export { default as NoticeSmart } from './NoticeSmart';
@@ -2,9 +2,17 @@
2
2
 
3
3
  SNotice {
4
4
  display: flex;
5
- padding: media(15px);
6
5
  font-size: var(--fs-100);
7
6
  line-height: var(--lh-100);
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ SNotice[use='primary'] {
11
+ padding: 8px 32px;
12
+ }
13
+
14
+ SNotice[use='secondary'] {
15
+ padding: 15px;
8
16
  border-style: solid;
9
17
  border-width: 1px;
10
18
  border-radius: 2px;
@@ -12,22 +20,33 @@ SNotice {
12
20
 
13
21
  SNotice[theme='info'] {
14
22
  background-color: color-mod(var(--light-blue) alpha(15%));
15
- border-color: color-mod(var(--light-blue) alpha(25%));
23
+
24
+ &[use='secondary'] {
25
+ border-color: color-mod(var(--light-blue) alpha(25%));
26
+ }
16
27
  }
17
28
 
18
29
  SNotice[theme='danger'] {
19
30
  background-color: color-mod(var(--red) alpha(10%));
20
- border-color: color-mod(var(--red) alpha(20%));
31
+
32
+ &[use='secondary'] {
33
+ border-color: color-mod(var(--red) alpha(20%));
34
+ }
21
35
  }
22
36
 
23
37
  SNotice[theme='warning'] {
24
38
  background-color: color-mod(var(--light-orange) alpha(15%));
25
- border-color: color-mod(var(--light-orange) alpha(40%));
39
+
40
+ &[use='secondary'] {
41
+ border-color: color-mod(var(--light-orange) alpha(40%));
42
+ }
26
43
  }
27
44
 
28
45
  SNotice[theme='success'] {
29
46
  background-color: color-mod(var(--green) alpha(15%));
30
- border-color: color-mod(var(--green) alpha(30%));
47
+ &[use='secondary'] {
48
+ border-color: color-mod(var(--green) alpha(30%));
49
+ }
31
50
  }
32
51
 
33
52
  SContent {
@@ -37,18 +56,18 @@ SContent {
37
56
 
38
57
  SActions {
39
58
  flex-shrink: 0;
40
- margin-top: media(12px);
41
-
42
- & > * + * {
43
- margin-left: media(8px);
44
- }
59
+ margin-top: 12px;
45
60
  }
46
61
 
47
62
  SLabel {
48
- margin-right: media(8px);
63
+ margin-right: 8px;
49
64
  display: inline-flex;
50
65
  }
51
66
 
67
+ SLabel[theme='danger'] {
68
+ color: var(--red);
69
+ }
70
+
52
71
  SLabel[theme='info'] {
53
72
  color: var(--stone);
54
73
  }
@@ -58,27 +77,22 @@ SLabel[theme='success'] {
58
77
  }
59
78
 
60
79
  SLabel[theme='warning'] {
61
- color: var(--orange);
80
+ color: var(--light-orange);
62
81
  }
63
82
 
64
- SLabel[theme='danger'] {
65
- color: var(--red);
83
+ SLabel[theme='custom'] {
84
+ color: var(--color);
66
85
  }
67
86
 
68
87
  SCloseIcon {
69
88
  flex-shrink: 0;
70
- margin-left: media(16px);
89
+ margin-left: 16px;
71
90
  }
72
91
 
73
- .animate--enter {
74
- opacity: 0.01;
75
- }
92
+ SNotice[theme='custom'] {
93
+ background-color: var(--backgroundColor);
76
94
 
77
- .animate--enter-active,
78
- .animate--exit {
79
- opacity: 1;
80
- }
81
-
82
- .animate--exit-active {
83
- opacity: 0.01;
95
+ &[use='secondary'] {
96
+ border-color: var(--backgroundColor);
97
+ }
84
98
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/NoticeSmart/index.tsx"],"names":["NoticeSmart","SNoticeSmart","Root","asProps","Children","label","actions","closable","onClose","Notice","Component","theme"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;IAqBMA,W;;;;;;;;;;;;6BAOK;AACP,UAAMC,YAAY,GAAG,KAAKC,IAA1B;AADO,0BAEiD,KAAKC,OAFtD;AAAA,UAECC,QAFD,iBAECA,QAFD;AAAA,UAEWC,KAFX,iBAEWA,KAFX;AAAA,UAEkBC,OAFlB,iBAEkBA,OAFlB;AAAA,UAE2BC,QAF3B,iBAE2BA,QAF3B;AAAA,UAEqCC,OAFrC,iBAEqCA,OAFrC;AAGP,0BACE,gCAAC,YAAD;AAAc,QAAA,MAAM,EAAEC;AAAtB,SACG,wBAAOJ,KAAP,kBAAiB,gCAAC,kBAAD,CAAQ,KAAR,QAAeA,KAAf,CADpB,eAEE,gCAAC,kBAAD,CAAQ,OAAR,qBACE,gCAAC,QAAD,OADF,EAEG,wBAAOC,OAAP,kBAAmB,gCAAC,kBAAD,CAAQ,OAAR,QAAiBA,OAAjB,CAFtB,CAFF,EAMGC,QAAQ,iBAAI,gCAAC,kBAAD,CAAQ,SAAR;AAAkB,QAAA,OAAO,EAAEC;AAA3B,QANf,CADF;AAUD;;;EApBuBE,e;;iCAApBV,W,iBACiB,a;iCADjBA,W,kBAGkB;AACpBW,EAAAA,KAAK,EAAE;AADa,C;;eAoBT,sBACbX,WADa,C","sourcesContent":["import React, { HTMLAttributes } from 'react';\nimport createComponent, { Component, Merge } from '@semcore/core';\nimport isNode from '@semcore/utils/lib/isNode';\nimport Notice, { INoticeProps } from '../Notice';\n\nexport interface INoticeSmartProps extends INoticeProps {\n /**\n * A custom element for additional information\n */\n label?: React.ReactNode;\n /**\n * Custom action element\n */\n actions?: React.ReactNode;\n /**\n * Adds a Close icon\n */\n closable?: boolean;\n /**\n * Callback on a click on the close button\n */\n onClose?: (event: React.SyntheticEvent) => void;\n}\n\nclass NoticeSmart extends Component<INoticeSmartProps> {\n static displayName = 'NoticeSmart';\n\n static defaultProps = {\n theme: 'info',\n };\n\n render() {\n const SNoticeSmart = this.Root;\n const { Children, label, actions, closable, onClose } = this.asProps;\n return (\n <SNoticeSmart render={Notice}>\n {isNode(label) && <Notice.Label>{label}</Notice.Label>}\n <Notice.Content>\n <Children />\n {isNode(actions) && <Notice.Actions>{actions}</Notice.Actions>}\n </Notice.Content>\n {closable && <Notice.CloseIcon onClick={onClose} />}\n </SNoticeSmart>\n );\n }\n}\n\nexport default createComponent<Merge<INoticeSmartProps, HTMLAttributes<HTMLDivElement>>>(\n NoticeSmart,\n);\n"],"file":"index.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/NoticeSmart/index.tsx"],"names":["React","createComponent","Component","isNode","Notice","NoticeSmart","SNoticeSmart","Root","asProps","Children","label","actions","closable","onClose","theme"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,OAAOC,eAAP,IAA0BC,SAA1B,QAAkD,qBAAlD;AACA,OAAOC,MAAP,MAAmB,iCAAnB;AACA,OAAOC,MAAP,MAAqC,WAArC;;IAqBMC,W;;;;;;;;;;;;;6BAOK;AACP,UAAMC,YAAY,GAAG,KAAKC,IAA1B;AADO,0BAEiD,KAAKC,OAFtD;AAAA,UAECC,QAFD,iBAECA,QAFD;AAAA,UAEWC,KAFX,iBAEWA,KAFX;AAAA,UAEkBC,OAFlB,iBAEkBA,OAFlB;AAAA,UAE2BC,QAF3B,iBAE2BA,QAF3B;AAAA,UAEqCC,OAFrC,iBAEqCA,OAFrC;AAGP,0BACE,oBAAC,YAAD;AAAc,QAAA,MAAM,EAAET;AAAtB,SACGD,MAAM,CAACO,KAAD,CAAN,iBAAiB,oBAAC,MAAD,CAAQ,KAAR,QAAeA,KAAf,CADpB,eAEE,oBAAC,MAAD,CAAQ,OAAR,qBACE,oBAAC,QAAD,OADF,EAEGP,MAAM,CAACQ,OAAD,CAAN,iBAAmB,oBAAC,MAAD,CAAQ,OAAR,QAAiBA,OAAjB,CAFtB,CAFF,EAMGC,QAAQ,iBAAI,oBAAC,MAAD,CAAQ,SAAR;AAAkB,QAAA,OAAO,EAAEC;AAA3B,QANf,CADF;AAUD;;;;EApBuBX,S;;gBAApBG,W,iBACiB,a;;gBADjBA,W,kBAGkB;AACpBS,EAAAA,KAAK,EAAE;AADa,C;;AAoBxB,eAAeb,eAAe,CAC5BI,WAD4B,CAA9B","sourcesContent":["import React, { HTMLAttributes } from 'react';\nimport createComponent, { Component, Merge } from '@semcore/core';\nimport isNode from '@semcore/utils/lib/isNode';\nimport Notice, { INoticeProps } from '../Notice';\n\nexport interface INoticeSmartProps extends INoticeProps {\n /**\n * A custom element for additional information\n */\n label?: React.ReactNode;\n /**\n * Custom action element\n */\n actions?: React.ReactNode;\n /**\n * Adds a Close icon\n */\n closable?: boolean;\n /**\n * Callback on a click on the close button\n */\n onClose?: (event: React.SyntheticEvent) => void;\n}\n\nclass NoticeSmart extends Component<INoticeSmartProps> {\n static displayName = 'NoticeSmart';\n\n static defaultProps = {\n theme: 'info',\n };\n\n render() {\n const SNoticeSmart = this.Root;\n const { Children, label, actions, closable, onClose } = this.asProps;\n return (\n <SNoticeSmart render={Notice}>\n {isNode(label) && <Notice.Label>{label}</Notice.Label>}\n <Notice.Content>\n <Children />\n {isNode(actions) && <Notice.Actions>{actions}</Notice.Actions>}\n </Notice.Content>\n {closable && <Notice.CloseIcon onClick={onClose} />}\n </SNoticeSmart>\n );\n }\n}\n\nexport default createComponent<Merge<INoticeSmartProps, HTMLAttributes<HTMLDivElement>>>(\n NoticeSmart,\n);\n"],"file":"index.js"}
@@ -1,50 +0,0 @@
1
- import React, { HTMLAttributes, SVGAttributes } from 'react';
2
- import { Component, Merge, PropGetter } from '@semcore/core';
3
- import { IBoxProps } from '@semcore/flex-box';
4
- import { IIconProps } from '@semcore/icon';
5
- export declare type NoticeTheme = 'danger' | 'warning' | 'success' | 'info';
6
- export interface INoticeProps extends IBoxProps {
7
- /** Property for managing visibility of Notice */
8
- hidden?: boolean;
9
- /**
10
- * Notice theme
11
- * @default info
12
- */
13
- theme?: NoticeTheme;
14
- /** Duration of animation, ms
15
- * @default 200
16
- */
17
- duration?: number;
18
- /**
19
- * Property for managing visibility of Notice
20
- * @deprecated v2.0.0 {@link INoticeProps.hidden}
21
- * */
22
- invisible?: boolean;
23
- }
24
- export interface INoticeLabelProps extends IBoxProps {
25
- theme?: NoticeTheme;
26
- }
27
- export interface INoticeContext extends INoticeProps {
28
- getLabelProps: PropGetter<RootNotice['getLabelProps']>;
29
- }
30
- declare class RootNotice extends Component<INoticeProps> {
31
- static displayName: string;
32
- static style: any;
33
- static defaultProps: {
34
- theme: string;
35
- duration: number;
36
- };
37
- getLabelProps(): {
38
- theme: NoticeTheme;
39
- };
40
- render(): any;
41
- }
42
- declare const _default: import("@semcore/core").ComponentType<Merge<INoticeProps, React.HTMLAttributes<HTMLDivElement>>, {
43
- Label: Merge<INoticeLabelProps, HTMLAttributes<HTMLDivElement>>;
44
- Actions: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
45
- Content: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
46
- CloseIcon: Merge<IBoxProps & IIconProps, SVGAttributes<SVGElement>>;
47
- }, INoticeContext, {
48
- [key: string]: (arg: unknown) => void;
49
- }, null>;
50
- export default _default;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { Merge } from '@semcore/core';
3
- import { INoticeProps } from '../Notice';
4
- export interface INoticeSmartProps extends INoticeProps {
5
- /**
6
- * A custom element for additional information
7
- */
8
- label?: React.ReactNode;
9
- /**
10
- * Custom action element
11
- */
12
- actions?: React.ReactNode;
13
- /**
14
- * Adds a Close icon
15
- */
16
- closable?: boolean;
17
- /**
18
- * Callback on a click on the close button
19
- */
20
- onClose?: (event: React.SyntheticEvent) => void;
21
- }
22
- declare const _default: import("@semcore/core").ComponentType<Merge<INoticeSmartProps, React.HTMLAttributes<HTMLDivElement>>, {}, {}, {
23
- [key: string]: (arg: unknown) => void;
24
- }, null>;
25
- export default _default;
package/src/Notice.tsx DELETED
@@ -1,129 +0,0 @@
1
- import React, { HTMLAttributes, SVGAttributes } from 'react';
2
- import { CSSTransition } from 'react-transition-group';
3
- import createComponent, {
4
- Component,
5
- IFunctionProps,
6
- Merge,
7
- PropGetter,
8
- styled,
9
- } from '@semcore/core';
10
- import { Box, IBoxProps } from '@semcore/flex-box';
11
- import { IIconProps } from '@semcore/icon';
12
- import CloseAltS from '@semcore/icon/lib/CloseAlt/s';
13
- import logger from '@semcore/utils/lib/logger';
14
-
15
- import style from './style/notice.shadow.css';
16
-
17
- export type NoticeTheme = 'danger' | 'warning' | 'success' | 'info';
18
-
19
- export interface INoticeProps extends IBoxProps {
20
- /** Property for managing visibility of Notice */
21
- hidden?: boolean;
22
- /**
23
- * Notice theme
24
- * @default info
25
- */
26
- theme?: NoticeTheme;
27
- /** Duration of animation, ms
28
- * @default 200
29
- */
30
- duration?: number;
31
- /**
32
- * Property for managing visibility of Notice
33
- * @deprecated v2.0.0 {@link INoticeProps.hidden}
34
- * */
35
- invisible?: boolean;
36
- }
37
-
38
- export interface INoticeLabelProps extends IBoxProps {
39
- theme?: NoticeTheme;
40
- }
41
-
42
- export interface INoticeContext extends INoticeProps {
43
- getLabelProps: PropGetter<RootNotice['getLabelProps']>;
44
- }
45
-
46
- class RootNotice extends Component<INoticeProps> {
47
- static displayName = 'Notice';
48
- static style = style;
49
- static defaultProps = {
50
- theme: 'info',
51
- duration: 200,
52
- };
53
-
54
- getLabelProps() {
55
- const { theme } = this.asProps;
56
- return {
57
- theme,
58
- };
59
- }
60
-
61
- render() {
62
- const SNotice = this.Root;
63
- const { styles, hidden, theme, duration, invisible, ...other } = this.asProps;
64
-
65
- logger.warn(
66
- invisible !== undefined,
67
- "Свойство 'invisible' является устаревшим, используйте 'hidden'",
68
- other['data-ui-name'] || RootNotice.displayName,
69
- );
70
-
71
- const transitionDuration = `${duration}ms`;
72
- return styled(styles)`
73
- .animate--exit-active,
74
- .animate--enter-active {
75
- transition: opacity ${transitionDuration} ease-out;
76
- }
77
- `(
78
- <CSSTransition
79
- in={invisible !== undefined ? !invisible : !hidden}
80
- timeout={duration}
81
- classNames={{
82
- enterActive: styled.styles['animate--enter-active'],
83
- exitActive: styled.styles['animate--exit-active'],
84
- enter: styled.styles['animate--enter'],
85
- exit: styled.styles['animate--exit'],
86
- }}
87
- unmountOnExit
88
- >
89
- <SNotice render={Box} theme={theme} />
90
- </CSSTransition>,
91
- );
92
- }
93
- }
94
-
95
- function Label(props: IFunctionProps<INoticeLabelProps>) {
96
- const { Root: SLabel, styles, theme } = props;
97
- return styled(styles)(<SLabel render={Box} theme={theme} />);
98
- }
99
-
100
- function Actions(props: IFunctionProps<IBoxProps>) {
101
- const { Root: SActions, styles } = props;
102
- return styled(styles)(<SActions render={Box} />);
103
- }
104
-
105
- function Content(props: IFunctionProps<IBoxProps>) {
106
- const { Root: SContent, styles } = props;
107
- return styled(styles)(<SContent render={Box} />);
108
- }
109
-
110
- function CloseIcon(props: IFunctionProps<IBoxProps & IIconProps>) {
111
- const { Root: SCloseIcon, styles } = props;
112
- return styled(styles)(<SCloseIcon render={Box} tag={CloseAltS} color="stone" interactive />);
113
- }
114
-
115
- export default createComponent<
116
- Merge<INoticeProps, HTMLAttributes<HTMLDivElement>>,
117
- {
118
- Label: Merge<INoticeLabelProps, HTMLAttributes<HTMLDivElement>>;
119
- Actions: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
120
- Content: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
121
- CloseIcon: Merge<IBoxProps & IIconProps, SVGAttributes<SVGElement>>;
122
- },
123
- INoticeContext
124
- >(RootNotice, {
125
- Label,
126
- Actions,
127
- Content,
128
- CloseIcon,
129
- });
@@ -1,50 +0,0 @@
1
- import React, { HTMLAttributes } from 'react';
2
- import createComponent, { Component, Merge } from '@semcore/core';
3
- import isNode from '@semcore/utils/lib/isNode';
4
- import Notice, { INoticeProps } from '../Notice';
5
-
6
- export interface INoticeSmartProps extends INoticeProps {
7
- /**
8
- * A custom element for additional information
9
- */
10
- label?: React.ReactNode;
11
- /**
12
- * Custom action element
13
- */
14
- actions?: React.ReactNode;
15
- /**
16
- * Adds a Close icon
17
- */
18
- closable?: boolean;
19
- /**
20
- * Callback on a click on the close button
21
- */
22
- onClose?: (event: React.SyntheticEvent) => void;
23
- }
24
-
25
- class NoticeSmart extends Component<INoticeSmartProps> {
26
- static displayName = 'NoticeSmart';
27
-
28
- static defaultProps = {
29
- theme: 'info',
30
- };
31
-
32
- render() {
33
- const SNoticeSmart = this.Root;
34
- const { Children, label, actions, closable, onClose } = this.asProps;
35
- return (
36
- <SNoticeSmart render={Notice}>
37
- {isNode(label) && <Notice.Label>{label}</Notice.Label>}
38
- <Notice.Content>
39
- <Children />
40
- {isNode(actions) && <Notice.Actions>{actions}</Notice.Actions>}
41
- </Notice.Content>
42
- {closable && <Notice.CloseIcon onClick={onClose} />}
43
- </SNoticeSmart>
44
- );
45
- }
46
- }
47
-
48
- export default createComponent<Merge<INoticeSmartProps, HTMLAttributes<HTMLDivElement>>>(
49
- NoticeSmart,
50
- );
package/src/index.tsx DELETED
@@ -1,10 +0,0 @@
1
- import { default as NoticeSmart } from './NoticeSmart';
2
-
3
- export * from './NoticeSmart';
4
-
5
- import { default as Notice } from './Notice';
6
-
7
- export * from './Notice';
8
-
9
- export default Notice;
10
- export { NoticeSmart };