@twreporter/react-components 9.0.2 → 9.1.0-rc.0
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 +22 -0
- package/lib/badge/badge.stories.js +3 -9
- package/lib/badge/index.js +8 -24
- package/lib/bookmark-list/bookmark.js +20 -69
- package/lib/bookmark-list/bookmarks.js +10 -40
- package/lib/bookmark-list/customized-link.js +4 -14
- package/lib/bookmark-list/image-wrapper.js +9 -36
- package/lib/bookmark-list/index.js +36 -91
- package/lib/bookmark-list/redirect-to-sign-in.js +1 -10
- package/lib/bookmark-list/stories/bookmark.stories.js +3 -9
- package/lib/bookmark-widget/index.js +91 -220
- package/lib/button/components/iconButton.js +15 -34
- package/lib/button/components/iconWithTextButton.js +16 -31
- package/lib/button/components/link.js +27 -45
- package/lib/button/components/menuButton.js +18 -38
- package/lib/button/components/pillButton.js +31 -60
- package/lib/button/components/textButton.js +29 -61
- package/lib/button/components/toggleButton.js +11 -31
- package/lib/button/enums/index.js +4 -7
- package/lib/button/index.js +5 -18
- package/lib/button/stories/iconButton.stories.js +4 -15
- package/lib/button/stories/iconWithTextButton.stories.js +4 -13
- package/lib/button/stories/link.stories.js +9 -27
- package/lib/button/stories/menuButton.stories.js +3 -10
- package/lib/button/stories/pillButton.stories.js +4 -15
- package/lib/button/stories/textButton.stories.js +4 -15
- package/lib/button/stories/toggleButton.stories.js +3 -8
- package/lib/button/utils/size.js +3 -8
- package/lib/button/utils/theme.js +11 -102
- package/lib/card/components/article-card.js +31 -59
- package/lib/card/components/dialog.js +7 -22
- package/lib/card/components/short-story.js +24 -44
- package/lib/card/index.js +2 -8
- package/lib/card/stories/articleCard.stories.js +3 -14
- package/lib/card/stories/dialog.stories.js +3 -11
- package/lib/card/stories/shortStory.stories.js +3 -16
- package/lib/checkbox/checkbox.stories.js +3 -8
- package/lib/checkbox/index.js +10 -31
- package/lib/color.stories.js +9 -34
- package/lib/confirmation/index.js +7 -29
- package/lib/customized-link.js +5 -18
- package/lib/divider.js +3 -19
- package/lib/divider.stories.js +5 -18
- package/lib/donation-link.js +2 -14
- package/lib/empty-state/enums/index.js +2 -3
- package/lib/empty-state/index.js +20 -41
- package/lib/empty-state/stories/empty-guide.stories.js +3 -11
- package/lib/error/index.js +3 -8
- package/lib/error/message.js +3 -44
- package/lib/footer/constants/links.js +10 -16
- package/lib/footer/footer.stories.js +3 -10
- package/lib/footer/index.js +5 -40
- package/lib/footer/link.js +15 -46
- package/lib/footer/logo.js +12 -32
- package/lib/hook/index.js +3 -18
- package/lib/hook/use-bookmark.js +21 -47
- package/lib/hook/use-font-face-observer.js +9 -24
- package/lib/hook/use-outside-click.js +4 -9
- package/lib/icon/enum/index.js +5 -9
- package/lib/icon/index.js +49 -105
- package/lib/icon/stories/arrow.stories.js +7 -16
- package/lib/icon/stories/article.stories.js +2 -7
- package/lib/icon/stories/bookmark.stories.js +6 -14
- package/lib/icon/stories/changeIconColor.stories.js +2 -12
- package/lib/icon/stories/clock.stories.js +2 -7
- package/lib/icon/stories/copy.stories.js +2 -7
- package/lib/icon/stories/cross.stories.js +2 -7
- package/lib/icon/stories/hamburger.stories.js +2 -7
- package/lib/icon/stories/home.stories.js +2 -7
- package/lib/icon/stories/letter.stories.js +2 -7
- package/lib/icon/stories/loading.stories.js +2 -7
- package/lib/icon/stories/member.stories.js +2 -7
- package/lib/icon/stories/printer.stories.js +2 -7
- package/lib/icon/stories/search.stories.js +2 -7
- package/lib/icon/stories/share.stories.js +2 -7
- package/lib/icon/stories/socialMedia.stories.js +2 -8
- package/lib/icon/stories/text.stories.js +2 -7
- package/lib/icon/stories/topic.stories.js +2 -7
- package/lib/image-with-fallback.js +22 -52
- package/lib/input/components/search-bar.js +40 -85
- package/lib/input/components/text-field.js +20 -40
- package/lib/input/enums/index.js +6 -8
- package/lib/input/index.js +2 -7
- package/lib/input/stories/search-bar.stories.js +3 -16
- package/lib/input/stories/text-field.stories.js +3 -14
- package/lib/input/utils/theme.js +2 -9
- package/lib/is-fetching-wrapper.js +16 -48
- package/lib/junior-link.js +6 -29
- package/lib/link-with-tracker.js +14 -47
- package/lib/listing-page/components/card-list.js +20 -51
- package/lib/listing-page/components/image.js +15 -46
- package/lib/listing-page/components/list-item.js +18 -65
- package/lib/listing-page/components/list.js +17 -61
- package/lib/listing-page/components/page-content.js +2 -12
- package/lib/listing-page/components/topics/index.js +26 -74
- package/lib/listing-page/components/topics/post-item.js +14 -47
- package/lib/listing-page/components/topics/posts.js +1 -10
- package/lib/listing-page/components/topics/section.js +3 -25
- package/lib/listing-page/components/topics/topic-item.js +17 -56
- package/lib/listing-page/constants/mockup-spec.js +2 -3
- package/lib/listing-page/constants/predefined-css.js +2 -10
- package/lib/listing-page/constants/prop-types.js +2 -7
- package/lib/listing-page/constants/topics.js +2 -3
- package/lib/listing-page/index.js +2 -8
- package/lib/listing-page/stories/cardList.stories.js +3 -10
- package/lib/logo/components/logo-footer.js +6 -21
- package/lib/logo/components/logo-header.js +7 -23
- package/lib/logo/components/logo-loading-fallback.js +4 -13
- package/lib/logo/components/logo-symbol.js +7 -23
- package/lib/logo/index.js +2 -9
- package/lib/logo/stories/logoFooter.stories.js +2 -8
- package/lib/logo/stories/logoHeader.stories.js +3 -9
- package/lib/logo/stories/logoLoadingFallback.stories.js +2 -8
- package/lib/logo/stories/logoSymbol.stories.js +3 -9
- package/lib/logo/utils/path.js +2 -9
- package/lib/material-icon.js +9 -17
- package/lib/mobile-member-role-card/index.js +22 -49
- package/lib/mobile-member-role-card/stories/member-role-card.stories.js +3 -12
- package/lib/mobile-pop-up-modal.js +10 -44
- package/lib/more.js +10 -37
- package/lib/pagination/index.js +17 -83
- package/lib/podcast-link.js +6 -29
- package/lib/rwd.js +6 -26
- package/lib/shared-enum.js +2 -3
- package/lib/side-bar/index.js +16 -59
- package/lib/simple-header/index.js +2 -12
- package/lib/simple-header/simpleHeader.stories.js +3 -8
- package/lib/snack-bar/components/snack-bar.js +9 -20
- package/lib/snack-bar/hooks/use-snack-bar.js +12 -25
- package/lib/snack-bar/index.js +2 -7
- package/lib/snack-bar/stories/snackBar.stories.js +12 -29
- package/lib/snack-bar/utils/theme.js +3 -9
- package/lib/storybook/constants/index.js +3 -11
- package/lib/storybook/utils/get-enum-arg.js +2 -5
- package/lib/table-of-contents/index.js +62 -128
- package/lib/text/constants/headline-type.js +5 -8
- package/lib/text/enums/index.js +3 -5
- package/lib/text/headline.js +14 -41
- package/lib/text/paragraph.js +13 -34
- package/lib/text/stories/headline.stories.js +8 -21
- package/lib/text/stories/paragraph.stories.js +6 -17
- package/lib/text/utils/webfonts.js +9 -22
- package/lib/title-bar/components/tab.js +27 -69
- package/lib/title-bar/components/title1.js +6 -17
- package/lib/title-bar/components/title2.js +7 -23
- package/lib/title-bar/index.js +2 -8
- package/lib/title-bar/stories/tab.stories.js +5 -12
- package/lib/title-bar/stories/title1.stories.js +5 -12
- package/lib/title-bar/stories/title2.stories.js +3 -11
- package/lib/utils/link-with-params.js +0 -5
- package/package.json +4 -4
- package/lib/hook/use-store.js +0 -46
package/lib/side-bar/index.js
CHANGED
|
@@ -1,74 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.AnchorWrapper = AnchorWrapper;
|
|
9
8
|
exports["default"] = void 0;
|
|
10
|
-
|
|
11
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
|
|
13
10
|
var _react = _interopRequireDefault(require("react"));
|
|
14
|
-
|
|
15
11
|
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
16
|
-
|
|
17
12
|
var _reactWaypoint = require("react-waypoint");
|
|
18
|
-
|
|
19
13
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
20
|
-
|
|
21
14
|
var _smoothScroll = _interopRequireDefault(require("@twreporter/core/lib/utils/smooth-scroll"));
|
|
22
|
-
|
|
23
15
|
var _excluded = ["children"];
|
|
24
|
-
|
|
25
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
26
|
-
|
|
27
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
28
|
-
|
|
29
18
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
30
|
-
|
|
31
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
32
|
-
|
|
33
20
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
|
|
35
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
36
|
-
|
|
21
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
37
22
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
38
|
-
|
|
23
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
24
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
39
25
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
40
|
-
|
|
41
26
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
42
|
-
|
|
43
27
|
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); }; }
|
|
44
|
-
|
|
45
28
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
46
|
-
|
|
47
29
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
48
|
-
|
|
49
30
|
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; } }
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } // lodash
|
|
32
|
+
// twreporter
|
|
53
33
|
var _ = {
|
|
54
34
|
get: _get["default"]
|
|
55
35
|
};
|
|
36
|
+
|
|
56
37
|
/**
|
|
57
38
|
* Get react component display name
|
|
58
39
|
*
|
|
59
40
|
* @param {object} DecoratedComponent
|
|
60
41
|
* @returns {string} display name of react component
|
|
61
42
|
*/
|
|
62
|
-
|
|
63
43
|
function getDisplayName(DecoratedComponent) {
|
|
64
44
|
return DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
|
|
65
45
|
}
|
|
66
|
-
|
|
67
46
|
function AnchorWrapper(_ref) {
|
|
68
47
|
var children = _ref.children;
|
|
69
48
|
return _react["default"].Children.only(children);
|
|
70
49
|
}
|
|
71
|
-
|
|
72
50
|
AnchorWrapper.defaultProps = {
|
|
73
51
|
anchorLabel: '',
|
|
74
52
|
showAnchor: false
|
|
@@ -79,6 +57,7 @@ AnchorWrapper.propTypes = {
|
|
|
79
57
|
showAnchor: _propTypes["default"].bool,
|
|
80
58
|
children: _propTypes["default"].element.isRequired
|
|
81
59
|
};
|
|
60
|
+
|
|
82
61
|
/**
|
|
83
62
|
* `decorateSideBar`
|
|
84
63
|
* returns a High Order Component adding the side bar functionalities onto `DecoratedComponent`.
|
|
@@ -141,22 +120,16 @@ AnchorWrapper.propTypes = {
|
|
|
141
120
|
* @param {Object} DecoratedComponent A React component wants to have side bar functionality
|
|
142
121
|
* @returns {Object} A React component with side bar functionalities
|
|
143
122
|
*/
|
|
144
|
-
|
|
145
123
|
function decorateSideBar(DecoratedComponent) {
|
|
146
124
|
var firstSection = 'first';
|
|
147
125
|
var lastSection = 'last';
|
|
148
126
|
var secondLastSection = 'second-last';
|
|
149
|
-
|
|
150
127
|
var DecoratedSideBar = /*#__PURE__*/function (_React$PureComponent) {
|
|
151
128
|
_inherits(DecoratedSideBar, _React$PureComponent);
|
|
152
|
-
|
|
153
129
|
var _super = _createSuper(DecoratedSideBar);
|
|
154
|
-
|
|
155
130
|
function DecoratedSideBar(props) {
|
|
156
131
|
var _this;
|
|
157
|
-
|
|
158
132
|
_classCallCheck(this, DecoratedSideBar);
|
|
159
|
-
|
|
160
133
|
_this = _super.call(this, props);
|
|
161
134
|
_this.state = {
|
|
162
135
|
currentSection: '',
|
|
@@ -164,12 +137,11 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
164
137
|
};
|
|
165
138
|
_this.handleClickAnchor = _this._handleClickAnchor.bind(_assertThisInitialized(_this));
|
|
166
139
|
_this.handleOnEnter = _this._handleOnEnter.bind(_assertThisInitialized(_this));
|
|
167
|
-
_this.handleOnLeave = _this._handleOnLeave.bind(_assertThisInitialized(_this));
|
|
168
|
-
|
|
140
|
+
_this.handleOnLeave = _this._handleOnLeave.bind(_assertThisInitialized(_this));
|
|
141
|
+
// moduleID to Module
|
|
169
142
|
_this.moduleMap = {};
|
|
170
143
|
return _this;
|
|
171
144
|
}
|
|
172
|
-
|
|
173
145
|
_createClass(DecoratedSideBar, [{
|
|
174
146
|
key: "componentWillUnmount",
|
|
175
147
|
value: function componentWillUnmount() {
|
|
@@ -181,13 +153,10 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
181
153
|
if (e) {
|
|
182
154
|
e.preventDefault();
|
|
183
155
|
}
|
|
184
|
-
|
|
185
156
|
var node = this.moduleMap[moduleID];
|
|
186
|
-
|
|
187
157
|
if (node) {
|
|
188
158
|
(0, _smoothScroll["default"])(node.offsetTop);
|
|
189
159
|
}
|
|
190
|
-
|
|
191
160
|
return null;
|
|
192
161
|
}
|
|
193
162
|
}, {
|
|
@@ -198,6 +167,7 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
198
167
|
currentSection: nextSection
|
|
199
168
|
});
|
|
200
169
|
}
|
|
170
|
+
|
|
201
171
|
/**
|
|
202
172
|
* Function will be invoked when the section is out of viewport.
|
|
203
173
|
* Currently only handle the first section and last section.
|
|
@@ -208,7 +178,6 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
208
178
|
* @param {string} props.currentPosition - One of `Waypoint.below`, `Waypoint.above`, `Waypoint.inside`, `Waypoint.invisible`
|
|
209
179
|
* @param {string} order - Section order, could be 'first' or 'last'
|
|
210
180
|
*/
|
|
211
|
-
|
|
212
181
|
}, {
|
|
213
182
|
key: "_handleOnLeave",
|
|
214
183
|
value: function _handleOnLeave(onLeaveSection, props, order) {
|
|
@@ -220,9 +189,9 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
220
189
|
currentSection: this.state.previousSection,
|
|
221
190
|
previousSection: onLeaveSection
|
|
222
191
|
});
|
|
223
|
-
}
|
|
224
|
-
|
|
192
|
+
}
|
|
225
193
|
|
|
194
|
+
// leave the sections controlled by side bar
|
|
226
195
|
this.setState({
|
|
227
196
|
currentSection: '',
|
|
228
197
|
previousSection: onLeaveSection
|
|
@@ -233,13 +202,10 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
233
202
|
key: "render",
|
|
234
203
|
value: function render() {
|
|
235
204
|
var _this2 = this;
|
|
236
|
-
|
|
237
205
|
var _this$props = this.props,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
206
|
+
children = _this$props.children,
|
|
207
|
+
passThroughProps = _objectWithoutProperties(_this$props, _excluded);
|
|
241
208
|
var modules;
|
|
242
|
-
|
|
243
209
|
if (!children) {
|
|
244
210
|
modules = [];
|
|
245
211
|
} else if (Array.isArray(children)) {
|
|
@@ -247,23 +213,19 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
247
213
|
} else {
|
|
248
214
|
modules = [children];
|
|
249
215
|
}
|
|
250
|
-
|
|
251
216
|
var anchors = modules.map(function (module) {
|
|
252
217
|
var anchorObj = {
|
|
253
218
|
id: _.get(module.props, 'anchorId'),
|
|
254
219
|
label: _.get(module.props, 'anchorLabel', ''),
|
|
255
220
|
show: _.get(module.props, 'showAnchor', false)
|
|
256
221
|
};
|
|
257
|
-
|
|
258
222
|
if (anchorObj.id) {
|
|
259
223
|
return anchorObj;
|
|
260
224
|
}
|
|
261
225
|
});
|
|
262
226
|
var webSiteContent = modules.map(function (module, index) {
|
|
263
227
|
var moduleID = _.get(anchors, [index, 'id'], "side_bar_module_".concat(index));
|
|
264
|
-
|
|
265
228
|
var order;
|
|
266
|
-
|
|
267
229
|
if (index === 0) {
|
|
268
230
|
order = firstSection;
|
|
269
231
|
} else if (index === modules.length - 1) {
|
|
@@ -271,7 +233,6 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
271
233
|
} else if (index === modules.length - 2) {
|
|
272
234
|
order = secondLastSection;
|
|
273
235
|
}
|
|
274
|
-
|
|
275
236
|
return /*#__PURE__*/_react["default"].createElement(_reactWaypoint.Waypoint, {
|
|
276
237
|
key: moduleID,
|
|
277
238
|
onLeave: function onLeave(props) {
|
|
@@ -298,10 +259,8 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
298
259
|
}, passThroughProps), webSiteContent);
|
|
299
260
|
}
|
|
300
261
|
}]);
|
|
301
|
-
|
|
302
262
|
return DecoratedSideBar;
|
|
303
263
|
}(_react["default"].PureComponent);
|
|
304
|
-
|
|
305
264
|
DecoratedSideBar.displayName = "SideBarHOC(".concat(getDisplayName(DecoratedComponent), ")");
|
|
306
265
|
DecoratedSideBar.defaultProps = {
|
|
307
266
|
children: []
|
|
@@ -311,6 +270,4 @@ function decorateSideBar(DecoratedComponent) {
|
|
|
311
270
|
};
|
|
312
271
|
return (0, _hoistNonReactStatics["default"])(DecoratedSideBar, DecoratedComponent);
|
|
313
272
|
}
|
|
314
|
-
|
|
315
|
-
var _default = decorateSideBar;
|
|
316
|
-
exports["default"] = _default;
|
|
273
|
+
var _default = exports["default"] = decorateSideBar;
|
|
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.SimpleHeader = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _logo = require("../logo");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
11
|
var HeaderContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
17
12
|
displayName: "simple-header__HeaderContainer",
|
|
18
13
|
componentId: "sc-4xugf-0"
|
|
19
14
|
})(["display:flex;justify-content:center;align-items:center;height:64px;"]);
|
|
20
|
-
|
|
21
15
|
var Logo = /*#__PURE__*/(0, _styledComponents["default"])(_logo.LogoHeader).withConfig({
|
|
22
16
|
displayName: "simple-header__Logo",
|
|
23
17
|
componentId: "sc-4xugf-1"
|
|
24
18
|
})(["width:144px;height:21px;"]);
|
|
25
|
-
|
|
26
|
-
var SimpleHeader = function SimpleHeader(props) {
|
|
19
|
+
var SimpleHeader = exports.SimpleHeader = function SimpleHeader(props) {
|
|
27
20
|
return /*#__PURE__*/_react["default"].createElement(HeaderContainer, props, /*#__PURE__*/_react["default"].createElement(Logo, null));
|
|
28
21
|
};
|
|
29
|
-
|
|
30
|
-
exports.SimpleHeader = SimpleHeader;
|
|
31
|
-
var _default = SimpleHeader;
|
|
32
|
-
exports["default"] = _default;
|
|
22
|
+
var _default = exports["default"] = SimpleHeader;
|
|
@@ -4,17 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.simpleHeader = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _ = _interopRequireDefault(require("."));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
var _default = {
|
|
9
|
+
var _default = exports["default"] = {
|
|
13
10
|
title: 'Header/Simple Header',
|
|
14
11
|
component: _["default"]
|
|
15
12
|
};
|
|
16
|
-
exports
|
|
17
|
-
var simpleHeader = {
|
|
13
|
+
var simpleHeader = exports.simpleHeader = {
|
|
18
14
|
args: {}
|
|
19
|
-
};
|
|
20
|
-
exports.simpleHeader = simpleHeader;
|
|
15
|
+
};
|
|
@@ -4,26 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _theme = require("../utils/theme");
|
|
15
|
-
|
|
16
11
|
var _paragraph = require("../../text/paragraph");
|
|
17
|
-
|
|
18
12
|
var _rwd = require("../../rwd");
|
|
19
|
-
|
|
20
13
|
var _theme2 = require("@twreporter/core/lib/constants/theme");
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
15
|
// util
|
|
16
|
+
|
|
25
17
|
// component
|
|
18
|
+
|
|
26
19
|
// @twreporter
|
|
20
|
+
|
|
27
21
|
var SnackBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
28
22
|
displayName: "snack-bar__SnackBarContainer",
|
|
29
23
|
componentId: "roennm-0"
|
|
@@ -32,17 +26,14 @@ var SnackBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig
|
|
|
32
26
|
}, function (props) {
|
|
33
27
|
return props.$bgColor;
|
|
34
28
|
});
|
|
35
|
-
|
|
36
29
|
var SnackBar = function SnackBar(_ref) {
|
|
37
30
|
var _ref$text = _ref.text,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
32
|
+
_ref$theme = _ref.theme,
|
|
33
|
+
theme = _ref$theme === void 0 ? _theme2.THEME.normal : _ref$theme;
|
|
42
34
|
var _getSnackBarTheme = (0, _theme.getSnackBarTheme)(theme),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
color = _getSnackBarTheme.color,
|
|
36
|
+
bgColor = _getSnackBarTheme.bgColor;
|
|
46
37
|
return /*#__PURE__*/_react["default"].createElement(SnackBarContainer, {
|
|
47
38
|
$color: color,
|
|
48
39
|
$bgColor: bgColor
|
|
@@ -52,11 +43,9 @@ var SnackBar = function SnackBar(_ref) {
|
|
|
52
43
|
text: text
|
|
53
44
|
})));
|
|
54
45
|
};
|
|
55
|
-
|
|
56
46
|
SnackBar.propTypes = {
|
|
57
47
|
text: _propTypes["default"].string,
|
|
58
48
|
theme: _propTypes["default"].oneOf(Object.values(_theme2.THEME))
|
|
59
49
|
};
|
|
60
50
|
SnackBar.THEME = _theme2.THEME;
|
|
61
|
-
var _default = SnackBar;
|
|
62
|
-
exports["default"] = _default;
|
|
51
|
+
var _default = exports["default"] = SnackBar;
|
|
@@ -4,50 +4,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
-
|
|
12
9
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
|
|
14
10
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
19
|
-
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
|
-
|
|
22
14
|
var useSnackBar = function useSnackBar() {
|
|
23
15
|
var _useState = (0, _react.useState)(false),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
showSnackBar = _useState2[0],
|
|
18
|
+
setShowSnackBar = _useState2[1];
|
|
28
19
|
var _useState3 = (0, _react.useState)(''),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
21
|
+
snackBarText = _useState4[0],
|
|
22
|
+
setSnackBarText = _useState4[1];
|
|
33
23
|
var toastr = function toastr(_ref) {
|
|
34
24
|
var _ref$text = _ref.text,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
26
|
+
_ref$timeout = _ref.timeout,
|
|
27
|
+
timeout = _ref$timeout === void 0 ? 3000 : _ref$timeout;
|
|
38
28
|
setSnackBarText(text);
|
|
39
29
|
setShowSnackBar(true);
|
|
40
30
|
setTimeout(function () {
|
|
41
31
|
setShowSnackBar(false);
|
|
42
32
|
}, timeout);
|
|
43
33
|
};
|
|
44
|
-
|
|
45
34
|
return {
|
|
46
35
|
toastr: toastr,
|
|
47
36
|
showSnackBar: showSnackBar,
|
|
48
37
|
snackBarText: snackBarText
|
|
49
38
|
};
|
|
50
39
|
};
|
|
51
|
-
|
|
52
|
-
var _default = useSnackBar;
|
|
53
|
-
exports["default"] = _default;
|
|
40
|
+
var _default = exports["default"] = useSnackBar;
|
package/lib/snack-bar/index.js
CHANGED
|
@@ -16,15 +16,10 @@ Object.defineProperty(exports, "useSnackBar", {
|
|
|
16
16
|
return _useSnackBar["default"];
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
19
|
var _snackBar = _interopRequireDefault(require("./components/snack-bar"));
|
|
21
|
-
|
|
22
20
|
var _useSnackBar = _interopRequireDefault(require("./hooks/use-snack-bar"));
|
|
23
|
-
|
|
24
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
26
|
-
var _default = {
|
|
22
|
+
var _default = exports["default"] = {
|
|
27
23
|
SnackBar: _snackBar["default"],
|
|
28
24
|
useSnackBar: _useSnackBar["default"]
|
|
29
|
-
};
|
|
30
|
-
exports["default"] = _default;
|
|
25
|
+
};
|
|
@@ -4,80 +4,65 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.snackBar = exports["default"] = exports.clickToShow = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _useSnackBar2 = _interopRequireDefault(require("../hooks/use-snack-bar"));
|
|
15
|
-
|
|
16
11
|
var _snackBar = _interopRequireDefault(require("../components/snack-bar"));
|
|
17
|
-
|
|
18
12
|
var _button = require("../../button");
|
|
19
|
-
|
|
20
13
|
var _constants = require("../../storybook/constants");
|
|
21
|
-
|
|
22
14
|
var _random = _interopRequireDefault(require("lodash/random"));
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
26
16
|
/* eslint react/display-name:0 */
|
|
17
|
+
|
|
27
18
|
// hooks
|
|
19
|
+
|
|
28
20
|
// components
|
|
21
|
+
|
|
29
22
|
// storybook
|
|
23
|
+
|
|
30
24
|
// lodash
|
|
25
|
+
|
|
31
26
|
var _ = {
|
|
32
27
|
random: _random["default"]
|
|
33
28
|
};
|
|
34
|
-
var _default = {
|
|
29
|
+
var _default = exports["default"] = {
|
|
35
30
|
title: 'Snack Bar',
|
|
36
31
|
component: _snackBar["default"],
|
|
37
32
|
argTypes: {
|
|
38
33
|
theme: _constants.THEME_STORYBOOK_ARG_TYPE
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
|
-
exports
|
|
42
|
-
var snackBar = {
|
|
36
|
+
var snackBar = exports.snackBar = {
|
|
43
37
|
args: {
|
|
44
38
|
text: '系統作業文字',
|
|
45
39
|
theme: _snackBar["default"].THEME.normal
|
|
46
40
|
}
|
|
47
41
|
};
|
|
48
|
-
exports.snackBar = snackBar;
|
|
49
|
-
|
|
50
42
|
var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
51
43
|
displayName: "snackBarstories__Container",
|
|
52
44
|
componentId: "sc-1vgclkn-0"
|
|
53
45
|
})(["display:flex;flex-direction:column;align-items:center;width:fit-content;"]);
|
|
54
|
-
|
|
55
46
|
var SnackBarContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
56
47
|
displayName: "snackBarstories__SnackBarContainer",
|
|
57
48
|
componentId: "sc-1vgclkn-1"
|
|
58
49
|
})(["margin-bottom:4px;transition:opacity 1s;opacity:", ";"], function (props) {
|
|
59
50
|
return props.$showSnackBar ? 1 : 0;
|
|
60
51
|
});
|
|
61
|
-
|
|
62
52
|
var ClickToShowSnackBar = function ClickToShowSnackBar(_ref) {
|
|
63
53
|
var timeout = _ref.timeout;
|
|
64
|
-
|
|
65
54
|
var _useSnackBar = (0, _useSnackBar2["default"])(),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
toastr = _useSnackBar.toastr,
|
|
56
|
+
showSnackBar = _useSnackBar.showSnackBar,
|
|
57
|
+
snackBarText = _useSnackBar.snackBarText;
|
|
70
58
|
var handleClick = function handleClick() {
|
|
71
59
|
var textPool = ['click!', 'hahaha', 'hello', 'world', 'yoyo'];
|
|
72
|
-
|
|
73
60
|
var text = textPool[_.random(0, 4)];
|
|
74
|
-
|
|
75
61
|
toastr({
|
|
76
62
|
text: text,
|
|
77
63
|
timeout: timeout
|
|
78
64
|
});
|
|
79
65
|
};
|
|
80
|
-
|
|
81
66
|
return /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(SnackBarContainer, {
|
|
82
67
|
$showSnackBar: showSnackBar
|
|
83
68
|
}, /*#__PURE__*/_react["default"].createElement(_snackBar["default"], {
|
|
@@ -87,11 +72,10 @@ var ClickToShowSnackBar = function ClickToShowSnackBar(_ref) {
|
|
|
87
72
|
onClick: handleClick
|
|
88
73
|
}));
|
|
89
74
|
};
|
|
90
|
-
|
|
91
75
|
ClickToShowSnackBar.propTypes = {
|
|
92
76
|
timeout: _propTypes["default"].number
|
|
93
77
|
};
|
|
94
|
-
var clickToShow = {
|
|
78
|
+
var clickToShow = exports.clickToShow = {
|
|
95
79
|
render: function render(props) {
|
|
96
80
|
return /*#__PURE__*/_react["default"].createElement(ClickToShowSnackBar, props);
|
|
97
81
|
},
|
|
@@ -103,5 +87,4 @@ var clickToShow = {
|
|
|
103
87
|
args: {
|
|
104
88
|
timeout: 800
|
|
105
89
|
}
|
|
106
|
-
};
|
|
107
|
-
exports.clickToShow = clickToShow;
|
|
90
|
+
};
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getSnackBarTheme = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _color = require("@twreporter/core/lib/constants/color");
|
|
9
|
-
|
|
10
|
-
var getSnackBarTheme = function getSnackBarTheme(theme) {
|
|
8
|
+
var getSnackBarTheme = exports.getSnackBarTheme = function getSnackBarTheme(theme) {
|
|
11
9
|
switch (theme) {
|
|
12
10
|
case 'photography':
|
|
13
11
|
return {
|
|
14
12
|
color: _color.colorGrayscale.gray800,
|
|
15
13
|
bgColor: _color.colorGrayscale.gray200
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
case 'normal':
|
|
19
16
|
default:
|
|
20
17
|
return {
|
|
@@ -23,9 +20,6 @@ var getSnackBarTheme = function getSnackBarTheme(theme) {
|
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
exports.getSnackBarTheme = getSnackBarTheme;
|
|
28
|
-
var _default = {
|
|
23
|
+
var _default = exports["default"] = {
|
|
29
24
|
getSnackBarTheme: getSnackBarTheme
|
|
30
|
-
};
|
|
31
|
-
exports["default"] = _default;
|
|
25
|
+
};
|
|
@@ -4,24 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.THEME_STORYBOOK_ARG_TYPE = exports.SIZE_STORYBOOK_ARG_TYPE = exports.BRANCH_STORYBOOK_ARG_TYPE = void 0;
|
|
7
|
-
|
|
8
7
|
var _getEnumArg = require("../utils/get-enum-arg");
|
|
9
|
-
|
|
10
8
|
var _releaseBranch = require("@twreporter/core/lib/constants/release-branch");
|
|
11
|
-
|
|
12
9
|
var _theme = require("@twreporter/core/lib/constants/theme");
|
|
13
|
-
|
|
14
10
|
var _sharedEnum = require("../../shared-enum");
|
|
15
|
-
|
|
16
|
-
var BRANCH_STORYBOOK_ARG_TYPE = {
|
|
11
|
+
var BRANCH_STORYBOOK_ARG_TYPE = exports.BRANCH_STORYBOOK_ARG_TYPE = {
|
|
17
12
|
defaultValue: _releaseBranch.BRANCH.master,
|
|
18
13
|
options: [_releaseBranch.BRANCH.master, _releaseBranch.BRANCH.staging, _releaseBranch.BRANCH.preview, _releaseBranch.BRANCH.release],
|
|
19
14
|
control: {
|
|
20
15
|
type: 'radio'
|
|
21
16
|
}
|
|
22
17
|
};
|
|
23
|
-
exports.
|
|
24
|
-
var
|
|
25
|
-
exports.THEME_STORYBOOK_ARG_TYPE = THEME_STORYBOOK_ARG_TYPE;
|
|
26
|
-
var SIZE_STORYBOOK_ARG_TYPE = (0, _getEnumArg.getRadioArg)(_sharedEnum.Size, _sharedEnum.Size.S);
|
|
27
|
-
exports.SIZE_STORYBOOK_ARG_TYPE = SIZE_STORYBOOK_ARG_TYPE;
|
|
18
|
+
var THEME_STORYBOOK_ARG_TYPE = exports.THEME_STORYBOOK_ARG_TYPE = (0, _getEnumArg.getRadioArg)(_theme.THEME, _theme.THEME.normal);
|
|
19
|
+
var SIZE_STORYBOOK_ARG_TYPE = exports.SIZE_STORYBOOK_ARG_TYPE = (0, _getEnumArg.getRadioArg)(_sharedEnum.Size, _sharedEnum.Size.S);
|
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getRadioArg = void 0;
|
|
7
|
-
|
|
8
|
-
var getRadioArg = function getRadioArg(enumObject, defaultValue) {
|
|
7
|
+
var getRadioArg = exports.getRadioArg = function getRadioArg(enumObject, defaultValue) {
|
|
9
8
|
return {
|
|
10
9
|
defaultValue: defaultValue,
|
|
11
10
|
options: Object.values(enumObject),
|
|
@@ -13,6 +12,4 @@ var getRadioArg = function getRadioArg(enumObject, defaultValue) {
|
|
|
13
12
|
type: 'radio'
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.getRadioArg = getRadioArg;
|
|
15
|
+
};
|