@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/CHANGELOG.md +33 -0
- package/lib/cjs/Notice.js +84 -113
- package/lib/cjs/Notice.js.map +1 -1
- package/lib/cjs/{NoticeSmart/index.js → NoticeSmart.js} +9 -9
- package/lib/cjs/NoticeSmart.js.map +1 -0
- package/lib/cjs/index.js +3 -27
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/notice.shadow.css +39 -25
- package/lib/es6/Notice.js +88 -110
- package/lib/es6/Notice.js.map +1 -1
- package/lib/es6/{NoticeSmart/index.js → NoticeSmart.js} +9 -8
- package/lib/es6/NoticeSmart.js.map +1 -0
- package/lib/es6/index.js +1 -4
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/notice.shadow.css +39 -25
- package/lib/types/index.d.ts +62 -5
- package/package.json +6 -8
- package/src/Notice.js +79 -0
- package/src/NoticeSmart.js +29 -0
- package/src/index.d.ts +63 -0
- package/src/index.js +4 -0
- package/src/style/notice.shadow.css +39 -25
- package/lib/cjs/NoticeSmart/index.js.map +0 -1
- package/lib/es6/NoticeSmart/index.js.map +0 -1
- package/lib/types/Notice.d.ts +0 -50
- package/lib/types/NoticeSmart/index.d.ts +0 -25
- package/src/Notice.tsx +0 -129
- package/src/NoticeSmart/index.tsx +0 -50
- package/src/index.tsx +0 -10
package/lib/es6/Notice.js
CHANGED
|
@@ -1,73 +1,60 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
import
|
|
7
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
8
|
+
import { assignProps as _assignProps5 } from "@semcore/core";
|
|
9
|
+
import { assignProps as _assignProps4 } from "@semcore/core";
|
|
10
|
+
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
11
|
+
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps } from "@semcore/core";
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
17
|
|
|
10
18
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
19
|
|
|
12
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
21
|
|
|
14
22
|
import React from 'react';
|
|
15
|
-
import {
|
|
16
|
-
import createComponent, { Component, styled, css, __css__, set, create, map } from '@semcore/core';
|
|
23
|
+
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
17
24
|
import { Box } from '@semcore/flex-box';
|
|
18
|
-
import
|
|
19
|
-
import
|
|
25
|
+
import CloseXS from '@semcore/icon/lib/Close/xs';
|
|
26
|
+
import resolveColor from '@semcore/utils/lib/color';
|
|
27
|
+
import { FadeInOut } from '@semcore/animation';
|
|
20
28
|
|
|
21
29
|
/*__reshadow-styles__:"./style/notice.shadow.css"*/
|
|
22
|
-
var
|
|
30
|
+
var style = (
|
|
23
31
|
/*__reshadow_css_start__*/
|
|
24
|
-
|
|
32
|
+
_sstyled.insert(
|
|
25
33
|
/*__inner_css_start__*/
|
|
26
|
-
".
|
|
34
|
+
".___SNotice_1cprg_gg_{display:flex;font-size:12px;line-height:1.5;box-sizing:border-box}.___SNotice_1cprg_gg_._use_primary_1cprg_gg_{padding:8px 32px}.___SNotice_1cprg_gg_._use_secondary_1cprg_gg_{padding:15px;border-style:solid;border-width:1px;border-radius:2px}.___SNotice_1cprg_gg_._theme_info_1cprg_gg_{background-color:rgba(43,148,225,.15)}.___SNotice_1cprg_gg_._theme_info_1cprg_gg_._use_secondary_1cprg_gg_{border-color:rgba(43,148,225,.25)}.___SNotice_1cprg_gg_._theme_danger_1cprg_gg_{background-color:rgba(237,45,45,.1)}.___SNotice_1cprg_gg_._theme_danger_1cprg_gg_._use_secondary_1cprg_gg_{border-color:rgba(237,45,45,.2)}.___SNotice_1cprg_gg_._theme_warning_1cprg_gg_{background-color:rgba(249,177,89,.15)}.___SNotice_1cprg_gg_._theme_warning_1cprg_gg_._use_secondary_1cprg_gg_{border-color:rgba(249,177,89,.4)}.___SNotice_1cprg_gg_._theme_success_1cprg_gg_{background-color:rgba(79,174,51,.15)}.___SNotice_1cprg_gg_._theme_success_1cprg_gg_._use_secondary_1cprg_gg_{border-color:rgba(79,174,51,.3)}.___SContent_1cprg_gg_{flex:1 1 auto;width:100%}.___SActions_1cprg_gg_{flex-shrink:0;margin-top:12px}.___SLabel_1cprg_gg_{margin-right:8px;display:inline-flex}.___SLabel_1cprg_gg_._theme_danger_1cprg_gg_{color:#ed2d2d}.___SLabel_1cprg_gg_._theme_info_1cprg_gg_{color:#a6b0b3}.___SLabel_1cprg_gg_._theme_success_1cprg_gg_{color:#4fae33}.___SLabel_1cprg_gg_._theme_warning_1cprg_gg_{color:#f9b159}.___SLabel_1cprg_gg_._theme_custom_1cprg_gg_{color:var(--color_1du3pp1)}.___SCloseIcon_1cprg_gg_{flex-shrink:0;margin-left:16px}.___SNotice_1cprg_gg_._theme_custom_1cprg_gg_{background-color:var(--backgroundColor_1du3pp1)}.___SNotice_1cprg_gg_._theme_custom_1cprg_gg_._use_secondary_1cprg_gg_{border-color:var(--backgroundColor_1du3pp1)}"
|
|
27
35
|
/*__inner_css_end__*/
|
|
28
|
-
, "
|
|
36
|
+
, "1du3pp1_gg_")
|
|
29
37
|
/*__reshadow_css_end__*/
|
|
30
38
|
, {
|
|
31
|
-
"__SNotice": "
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
})
|
|
46
|
-
style = _extends({}, _ref);
|
|
47
|
-
|
|
48
|
-
if (false) {
|
|
49
|
-
/*__reshadow_css_start__*/
|
|
50
|
-
__css__(
|
|
51
|
-
/*__inner_css_start__*/
|
|
52
|
-
"@media (max-width: 768px) {.___SNotice_65f22_gg_ {\n padding: 19.5px;\n font-size: 15.6px;\n}\n\n.___SActions_65f22_gg_ {\n margin-top: 15.6px\n}\n\n.___SActions_65f22_gg_ > * + * {\n margin-left: 10.4px;\n }\n\n.___SLabel_65f22_gg_ {\n margin-right: 10.4px;\n}\n\n.___SCloseIcon_65f22_gg_ {\n margin-left: 20.8px;\n}}"
|
|
53
|
-
/*__inner_css_end__*/
|
|
54
|
-
, "5yj58v_gg_")
|
|
55
|
-
/*__reshadow_css_end__*/
|
|
56
|
-
;
|
|
57
|
-
}
|
|
39
|
+
"__SNotice": "___SNotice_1cprg_gg_",
|
|
40
|
+
"_use_primary": "_use_primary_1cprg_gg_",
|
|
41
|
+
"_use_secondary": "_use_secondary_1cprg_gg_",
|
|
42
|
+
"_theme_info": "_theme_info_1cprg_gg_",
|
|
43
|
+
"_theme_danger": "_theme_danger_1cprg_gg_",
|
|
44
|
+
"_theme_warning": "_theme_warning_1cprg_gg_",
|
|
45
|
+
"_theme_success": "_theme_success_1cprg_gg_",
|
|
46
|
+
"__SContent": "___SContent_1cprg_gg_",
|
|
47
|
+
"__SActions": "___SActions_1cprg_gg_",
|
|
48
|
+
"__SLabel": "___SLabel_1cprg_gg_",
|
|
49
|
+
"_theme_custom": "_theme_custom_1cprg_gg_",
|
|
50
|
+
"--color": "--color_1du3pp1",
|
|
51
|
+
"__SCloseIcon": "___SCloseIcon_1cprg_gg_",
|
|
52
|
+
"--backgroundColor": "--backgroundColor_1du3pp1"
|
|
53
|
+
});
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/*__inner_css_start__*/
|
|
63
|
-
"._animate--enter-active_6p638_gg_,._animate--exit-active_tr6oy_gg_{transition:opacity var(--13urk6b_0) ease-out}"
|
|
64
|
-
/*__inner_css_end__*/
|
|
65
|
-
, "d6h9sm_gg_")
|
|
66
|
-
/*__reshadow_css_end__*/
|
|
67
|
-
, {
|
|
68
|
-
"animate--exit-active": "_animate--exit-active_tr6oy_gg_",
|
|
69
|
-
"animate--enter-active": "_animate--enter-active_6p638_gg_"
|
|
70
|
-
})]);
|
|
55
|
+
function isCustomTheme(theme) {
|
|
56
|
+
return !['danger', 'warning', 'success', 'info'].includes(theme);
|
|
57
|
+
}
|
|
71
58
|
|
|
72
59
|
var RootNotice = /*#__PURE__*/function (_Component) {
|
|
73
60
|
_inherits(RootNotice, _Component);
|
|
@@ -91,35 +78,23 @@ var RootNotice = /*#__PURE__*/function (_Component) {
|
|
|
91
78
|
}, {
|
|
92
79
|
key: "render",
|
|
93
80
|
value: function render() {
|
|
94
|
-
var
|
|
81
|
+
var _ref = this ? this.asProps : arguments[0],
|
|
82
|
+
_ref6;
|
|
95
83
|
|
|
84
|
+
var SNotice = FadeInOut;
|
|
96
85
|
var _this$asProps = this.asProps,
|
|
86
|
+
Children = _this$asProps.Children,
|
|
97
87
|
styles = _this$asProps.styles,
|
|
98
88
|
hidden = _this$asProps.hidden,
|
|
99
|
-
theme = _this$asProps.theme
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}), /*#__PURE__*/React.createElement(CSSTransition, map("CSSTransition", {
|
|
109
|
-
"in": invisible !== undefined ? !invisible : !hidden,
|
|
110
|
-
timeout: duration,
|
|
111
|
-
classNames: {
|
|
112
|
-
enterActive: styled.styles['animate--enter-active'],
|
|
113
|
-
exitActive: styled.styles['animate--exit-active'],
|
|
114
|
-
enter: styled.styles['animate--enter'],
|
|
115
|
-
exit: styled.styles['animate--exit']
|
|
116
|
-
},
|
|
117
|
-
unmountOnExit: true,
|
|
118
|
-
$$style: styled.$$style
|
|
119
|
-
}), /*#__PURE__*/React.createElement(SNotice, map("SNotice", {
|
|
120
|
-
render: Box,
|
|
121
|
-
theme: theme
|
|
122
|
-
})))));
|
|
89
|
+
theme = _this$asProps.theme;
|
|
90
|
+
var color = resolveColor(theme);
|
|
91
|
+
var useTheme = isCustomTheme(theme) ? 'custom' : theme;
|
|
92
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(SNotice, _ref6.cn("SNotice", _objectSpread({}, _assignProps({
|
|
93
|
+
"visible": !hidden,
|
|
94
|
+
"use:theme": useTheme,
|
|
95
|
+
"backgroundColor": color,
|
|
96
|
+
"role": "alert"
|
|
97
|
+
}, _ref))), /*#__PURE__*/React.createElement(Children, _ref6.cn("Children", {})));
|
|
123
98
|
}
|
|
124
99
|
}]);
|
|
125
100
|
|
|
@@ -131,53 +106,56 @@ _defineProperty(RootNotice, "displayName", 'Notice');
|
|
|
131
106
|
_defineProperty(RootNotice, "style", style);
|
|
132
107
|
|
|
133
108
|
_defineProperty(RootNotice, "defaultProps", {
|
|
109
|
+
use: 'secondary',
|
|
134
110
|
theme: 'info',
|
|
135
111
|
duration: 200
|
|
136
112
|
});
|
|
137
113
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
theme =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
114
|
+
function Label(_ref11) {
|
|
115
|
+
var _ref2 = this ? this.asProps : arguments[0],
|
|
116
|
+
_ref7;
|
|
117
|
+
|
|
118
|
+
var styles = _ref11.styles,
|
|
119
|
+
theme = _ref11.theme;
|
|
120
|
+
var SLabel = Box;
|
|
121
|
+
var useTheme = isCustomTheme(theme) ? 'custom' : theme;
|
|
122
|
+
var color = resolveColor(theme);
|
|
123
|
+
return _ref7 = sstyled(styles), /*#__PURE__*/React.createElement(SLabel, _ref7.cn("SLabel", _objectSpread({}, _assignProps2({
|
|
124
|
+
"use:theme": useTheme,
|
|
125
|
+
"color": color
|
|
126
|
+
}, _ref2))));
|
|
148
127
|
}
|
|
149
128
|
|
|
150
|
-
|
|
129
|
+
function Actions(_ref12) {
|
|
130
|
+
var _ref3 = this ? this.asProps : arguments[0],
|
|
131
|
+
_ref8;
|
|
151
132
|
|
|
152
|
-
|
|
153
|
-
var SActions =
|
|
154
|
-
|
|
155
|
-
return styled((set([styled_190, styles]), /*#__PURE__*/React.createElement(SActions, map("SActions", {
|
|
156
|
-
render: Box
|
|
157
|
-
}))));
|
|
133
|
+
var styles = _ref12.styles;
|
|
134
|
+
var SActions = Box;
|
|
135
|
+
return _ref8 = sstyled(styles), /*#__PURE__*/React.createElement(SActions, _ref8.cn("SActions", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
158
136
|
}
|
|
159
137
|
|
|
160
|
-
|
|
138
|
+
function Content(_ref13) {
|
|
139
|
+
var _ref4 = this ? this.asProps : arguments[0],
|
|
140
|
+
_ref9;
|
|
161
141
|
|
|
162
|
-
|
|
163
|
-
var SContent =
|
|
164
|
-
|
|
165
|
-
return styled((set([styled_1f4, styles]), /*#__PURE__*/React.createElement(SContent, map("SContent", {
|
|
166
|
-
render: Box
|
|
167
|
-
}))));
|
|
142
|
+
var styles = _ref13.styles;
|
|
143
|
+
var SContent = Box;
|
|
144
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SContent, _ref9.cn("SContent", _objectSpread({}, _assignProps4({}, _ref4))));
|
|
168
145
|
}
|
|
169
146
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
tag:
|
|
178
|
-
color: "stone",
|
|
179
|
-
interactive: true
|
|
180
|
-
|
|
147
|
+
function CloseIcon(_ref14) {
|
|
148
|
+
var _ref5 = this ? this.asProps : arguments[0],
|
|
149
|
+
_ref10;
|
|
150
|
+
|
|
151
|
+
var styles = _ref14.styles;
|
|
152
|
+
var SCloseIcon = Box;
|
|
153
|
+
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SCloseIcon, _ref10.cn("SCloseIcon", _objectSpread({}, _assignProps5({
|
|
154
|
+
"tag": CloseXS,
|
|
155
|
+
"color": "stone",
|
|
156
|
+
"interactive": true,
|
|
157
|
+
"aria-label": "Close alert"
|
|
158
|
+
}, _ref5))));
|
|
181
159
|
}
|
|
182
160
|
|
|
183
161
|
export default createComponent(RootNotice, {
|
package/lib/es6/Notice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Notice.
|
|
1
|
+
{"version":3,"sources":["../../src/Notice.js"],"names":["React","createComponent","Component","sstyled","Root","Box","CloseXS","resolveColor","FadeInOut","isCustomTheme","theme","includes","RootNotice","asProps","SNotice","Children","styles","hidden","color","useTheme","style","use","duration","Label","SLabel","Actions","SActions","Content","SContent","CloseIcon","SCloseIcon"],"mappings":"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","sourcesContent":["import React from 'react';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Box } from '@semcore/flex-box';\nimport CloseXS from '@semcore/icon/lib/Close/xs';\nimport resolveColor from '@semcore/utils/lib/color';\nimport { FadeInOut } from '@semcore/animation';\n\nimport style from './style/notice.shadow.css';\n\nfunction isCustomTheme(theme) {\n return !['danger', 'warning', 'success', 'info'].includes(theme);\n}\n\nclass RootNotice extends Component {\n static displayName = 'Notice';\n static style = style;\n static defaultProps = {\n use: 'secondary',\n theme: 'info',\n duration: 200,\n };\n\n getLabelProps() {\n const { theme } = this.asProps;\n return {\n theme,\n };\n }\n\n render() {\n const SNotice = Root;\n const { Children, styles, hidden, theme } = this.asProps;\n const color = resolveColor(theme);\n const useTheme = isCustomTheme(theme) ? 'custom' : theme;\n\n return sstyled(styles)(\n <SNotice\n render={FadeInOut}\n visible={!hidden}\n use:theme={useTheme}\n backgroundColor={color}\n role=\"alert\"\n >\n <Children />\n </SNotice>,\n );\n }\n}\n\nfunction Label({ styles, theme }) {\n const SLabel = Root;\n const useTheme = isCustomTheme(theme) ? 'custom' : theme;\n const color = resolveColor(theme);\n return sstyled(styles)(<SLabel render={Box} use:theme={useTheme} color={color} />);\n}\n\nfunction Actions({ styles }) {\n const SActions = Root;\n return sstyled(styles)(<SActions render={Box} />);\n}\n\nfunction Content({ styles }) {\n const SContent = Root;\n return sstyled(styles)(<SContent render={Box} />);\n}\n\nfunction CloseIcon({ styles }) {\n const SCloseIcon = Root;\n return sstyled(styles)(\n <SCloseIcon render={Box} tag={CloseXS} color=\"stone\" interactive aria-label=\"Close alert\" />,\n );\n}\n\nexport default createComponent(RootNotice, {\n Label,\n Actions,\n Content,\n CloseIcon,\n});\n"],"file":"Notice.js"}
|
|
@@ -4,15 +4,16 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
+
import { assignProps as _assignProps } from "@semcore/core";
|
|
7
8
|
|
|
8
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
10
|
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
12
|
|
|
12
13
|
import React from 'react';
|
|
13
|
-
import createComponent, { Component } from '@semcore/core';
|
|
14
|
+
import createComponent, { Component, Root } from '@semcore/core';
|
|
14
15
|
import isNode from '@semcore/utils/lib/isNode';
|
|
15
|
-
import Notice from '
|
|
16
|
+
import Notice from './Notice';
|
|
16
17
|
|
|
17
18
|
var NoticeSmart = /*#__PURE__*/function (_Component) {
|
|
18
19
|
_inherits(NoticeSmart, _Component);
|
|
@@ -28,16 +29,16 @@ var NoticeSmart = /*#__PURE__*/function (_Component) {
|
|
|
28
29
|
_createClass(NoticeSmart, [{
|
|
29
30
|
key: "render",
|
|
30
31
|
value: function render() {
|
|
31
|
-
var
|
|
32
|
+
var _ref = this ? this.asProps : arguments[0];
|
|
33
|
+
|
|
34
|
+
var SNoticeSmart = Notice;
|
|
32
35
|
var _this$asProps = this.asProps,
|
|
33
36
|
Children = _this$asProps.Children,
|
|
34
37
|
label = _this$asProps.label,
|
|
35
38
|
actions = _this$asProps.actions,
|
|
36
39
|
closable = _this$asProps.closable,
|
|
37
40
|
onClose = _this$asProps.onClose;
|
|
38
|
-
return /*#__PURE__*/React.createElement(SNoticeSmart, {
|
|
39
|
-
render: Notice
|
|
40
|
-
}, isNode(label) && /*#__PURE__*/React.createElement(Notice.Label, null, label), /*#__PURE__*/React.createElement(Notice.Content, null, /*#__PURE__*/React.createElement(Children, null), isNode(actions) && /*#__PURE__*/React.createElement(Notice.Actions, null, actions)), closable && /*#__PURE__*/React.createElement(Notice.CloseIcon, {
|
|
41
|
+
return /*#__PURE__*/React.createElement(SNoticeSmart, _assignProps({}, _ref), isNode(label) && /*#__PURE__*/React.createElement(Notice.Label, null, label), /*#__PURE__*/React.createElement(Notice.Content, null, /*#__PURE__*/React.createElement(Children, null), isNode(actions) && /*#__PURE__*/React.createElement(Notice.Actions, null, actions)), closable && /*#__PURE__*/React.createElement(Notice.CloseIcon, {
|
|
41
42
|
onClick: onClose
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
@@ -53,4 +54,4 @@ _defineProperty(NoticeSmart, "defaultProps", {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
export default createComponent(NoticeSmart);
|
|
56
|
-
//# sourceMappingURL=
|
|
57
|
+
//# sourceMappingURL=NoticeSmart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/NoticeSmart.js"],"names":["React","createComponent","Component","Root","isNode","Notice","NoticeSmart","SNoticeSmart","asProps","Children","label","actions","closable","onClose","theme"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,IAArC,QAAiD,eAAjD;AACA,OAAOC,MAAP,MAAmB,2BAAnB;AACA,OAAOC,MAAP,MAAmB,UAAnB;;IAEMC,W;;;;;;;;;;;;;WAOJ,kBAAS;AAAA;;AACP,UAAMC,YAAY,GAGMF,MAHxB;AADO,0BAEiD,KAAKG,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,0BACGT,MAAM,CAACM,KAAD,CAAN,iBAAiB,oBAAC,MAAD,CAAQ,KAAR,QAAeA,KAAf,CADpB,eAEE,oBAAC,MAAD,CAAQ,OAAR,qBACE,oBAAC,QAAD,OADF,EAEGN,MAAM,CAACO,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;;gBAApBI,W,iBACiB,a;;gBADjBA,W,kBAGkB;AACpBQ,EAAAA,KAAK,EAAE;AADa,C;;AAoBxB,eAAeb,eAAe,CAACK,WAAD,CAA9B","sourcesContent":["import React from 'react';\nimport createComponent, { Component, Root } from '@semcore/core';\nimport isNode from '@semcore/utils/lib/isNode';\nimport Notice from './Notice';\n\nclass NoticeSmart extends Component {\n static displayName = 'NoticeSmart';\n\n static defaultProps = {\n theme: 'info',\n };\n\n render() {\n const SNoticeSmart = 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(NoticeSmart);\n"],"file":"NoticeSmart.js"}
|
package/lib/es6/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { default as NoticeSmart } from './NoticeSmart';
|
|
2
|
-
export * from './NoticeSmart';
|
|
3
1
|
import { default as Notice } from './Notice';
|
|
4
|
-
export * from './Notice';
|
|
5
2
|
export default Notice;
|
|
6
|
-
export { NoticeSmart };
|
|
3
|
+
export { default as NoticeSmart } from './NoticeSmart';
|
|
7
4
|
//# sourceMappingURL=index.js.map
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.
|
|
1
|
+
{"version":3,"sources":["../../src/index.js"],"names":["default","Notice","NoticeSmart"],"mappings":"AAAA,SAASA,OAAO,IAAIC,MAApB,QAAkC,UAAlC;AAEA,eAAeA,MAAf;AACA,SAASD,OAAO,IAAIE,WAApB,QAAuC,eAAvC","sourcesContent":["import { default as Notice } from './Notice';\n\nexport default Notice;\nexport { default as NoticeSmart } from './NoticeSmart';\n"],"file":"index.js"}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
41
|
-
|
|
42
|
-
& > * + * {
|
|
43
|
-
margin-left: media(8px);
|
|
44
|
-
}
|
|
59
|
+
margin-top: 12px;
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
SLabel {
|
|
48
|
-
margin-right:
|
|
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='
|
|
65
|
-
color: var(--
|
|
83
|
+
SLabel[theme='custom'] {
|
|
84
|
+
color: var(--color);
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
SCloseIcon {
|
|
69
88
|
flex-shrink: 0;
|
|
70
|
-
margin-left:
|
|
89
|
+
margin-left: 16px;
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
92
|
+
SNotice[theme='custom'] {
|
|
93
|
+
background-color: var(--backgroundColor);
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.animate--exit-active {
|
|
83
|
-
opacity: 0.01;
|
|
95
|
+
&[use='secondary'] {
|
|
96
|
+
border-color: var(--backgroundColor);
|
|
97
|
+
}
|
|
84
98
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
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
|
+
|
|
6
62
|
export { NoticeSmart };
|
|
63
|
+
export default Notice;
|
package/package.json
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/notice",
|
|
3
3
|
"description": "SEMRush Notice Component",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.1.2",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
|
-
"sideEffects":
|
|
9
|
-
"lib/*/Notice.js"
|
|
10
|
-
],
|
|
8
|
+
"sideEffects": false,
|
|
11
9
|
"author": "Roman Lysov <r.lysov@semrush.com>",
|
|
12
10
|
"license": "MIT",
|
|
13
11
|
"scripts": {
|
|
14
|
-
"build": "build",
|
|
12
|
+
"build": "build --source=js",
|
|
15
13
|
"test": "jest"
|
|
16
14
|
},
|
|
17
15
|
"dependencies": {
|
|
16
|
+
"@semcore/animation": "^1",
|
|
18
17
|
"@semcore/utils": "^3.15",
|
|
19
18
|
"@semcore/flex-box": "^4",
|
|
20
|
-
"@semcore/icon": "^2"
|
|
21
|
-
"react-transition-group": "^4.4"
|
|
19
|
+
"@semcore/icon": "^2"
|
|
22
20
|
},
|
|
23
21
|
"peerDependencies": {
|
|
24
|
-
"@semcore/core": "^1",
|
|
22
|
+
"@semcore/core": "^1.11",
|
|
25
23
|
"react": "16.8 - 17"
|
|
26
24
|
},
|
|
27
25
|
"jest": {
|