@daoyi/nmtl-ui 2.0.1-beta.48 → 2.0.1-beta.49
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.
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { c as _objectWithoutProperties } from './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
2
|
+
import React__default, { useMemo } from 'react';
|
|
3
|
+
import { c as classNames } from './index-f491ebce.js';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { q as queryString } from './index-7b60a97d.js';
|
|
6
|
+
import { useHistory, Link } from 'react-router-dom';
|
|
7
|
+
import { Tooltip } from '@material-ui/core';
|
|
8
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
9
|
+
|
|
10
|
+
var css_248z = ".forwardLink {\n width: -moz-fit-content;\n width: fit-content; }\n .forwardLink__link {\n color: unset;\n text-decoration: none;\n cursor: pointer; }\n .forwardLink__link--disabled {\n cursor: not-allowed; }\n";
|
|
11
|
+
styleInject(css_248z);
|
|
12
|
+
|
|
13
|
+
var _excluded = ["className", "title", "target", "disabled", "children", "tip", "onClick"];
|
|
14
|
+
var locale = '/zh-tw'; // 20230318 暫時寫死,若套件納入語系控制,可將其置換
|
|
15
|
+
|
|
16
|
+
var ForwardLink = function ForwardLink(_ref) {
|
|
17
|
+
var className = _ref.className,
|
|
18
|
+
title = _ref.title,
|
|
19
|
+
target = _ref.target,
|
|
20
|
+
disabled = _ref.disabled,
|
|
21
|
+
children = _ref.children,
|
|
22
|
+
tip = _ref.tip;
|
|
23
|
+
_ref.onClick;
|
|
24
|
+
var rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var history = useHistory();
|
|
26
|
+
var _useMemo = useMemo(function () {
|
|
27
|
+
var _rest$pathname;
|
|
28
|
+
if (disabled) return {};
|
|
29
|
+
/*
|
|
30
|
+
* 若將 search 寫在 pathname 中,意即 pathname=/asd?zxc=qwe
|
|
31
|
+
* 會導致換頁時 React route dom 無法匹配 => 空白畫面
|
|
32
|
+
* 若真有此情況發生 需把 search 提領出來
|
|
33
|
+
*/
|
|
34
|
+
var foundIndex = (_rest$pathname = rest.pathname) === null || _rest$pathname === void 0 ? void 0 : _rest$pathname.indexOf('?');
|
|
35
|
+
if (foundIndex > -1) return {
|
|
36
|
+
pathname: rest.pathname.substring(0, foundIndex),
|
|
37
|
+
search: rest.pathname.substring(foundIndex)
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
pathname: rest.pathname || '/',
|
|
41
|
+
search: typeof rest.search === 'string' ? rest.search : queryString.stringify(rest.search)
|
|
42
|
+
};
|
|
43
|
+
}, [history, disabled, rest.pathname, rest.search]),
|
|
44
|
+
_useMemo$pathname = _useMemo.pathname,
|
|
45
|
+
pathname = _useMemo$pathname === void 0 ? '' : _useMemo$pathname,
|
|
46
|
+
_useMemo$search = _useMemo.search,
|
|
47
|
+
search = _useMemo$search === void 0 ? '' : _useMemo$search;
|
|
48
|
+
var linkComponent = /*#__PURE__*/React__default.createElement("div", {
|
|
49
|
+
className: classNames('forwardLink', className)
|
|
50
|
+
}, disabled ? /*#__PURE__*/React__default.createElement("div", {
|
|
51
|
+
title: tip ? undefined : title,
|
|
52
|
+
className: "forwardLink__link--disabled"
|
|
53
|
+
}, children) : /*#__PURE__*/React__default.createElement(Link, {
|
|
54
|
+
className: "forwardLink__link",
|
|
55
|
+
target: target,
|
|
56
|
+
title: tip ? undefined : title,
|
|
57
|
+
to: {
|
|
58
|
+
pathname: "".concat(locale).concat(pathname),
|
|
59
|
+
search: search
|
|
60
|
+
}
|
|
61
|
+
}, children));
|
|
62
|
+
if (tip) {
|
|
63
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
64
|
+
title: tip,
|
|
65
|
+
placement: "top"
|
|
66
|
+
}, linkComponent);
|
|
67
|
+
}
|
|
68
|
+
return linkComponent;
|
|
69
|
+
};
|
|
70
|
+
ForwardLink.defaultProps = {
|
|
71
|
+
className: undefined,
|
|
72
|
+
title: undefined,
|
|
73
|
+
target: '_blank',
|
|
74
|
+
disabled: undefined,
|
|
75
|
+
children: undefined,
|
|
76
|
+
search: undefined,
|
|
77
|
+
tip: undefined,
|
|
78
|
+
onClick: function onClick() {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
84
|
+
ForwardLink.propTypes = {
|
|
85
|
+
/** Css Name */
|
|
86
|
+
className: PropTypes.string,
|
|
87
|
+
/** DOM title */
|
|
88
|
+
title: PropTypes.string,
|
|
89
|
+
/** DOM title */
|
|
90
|
+
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
91
|
+
/** 是否取消點擊 */
|
|
92
|
+
disabled: PropTypes.bool,
|
|
93
|
+
/** 子項目 */
|
|
94
|
+
children: PropTypes.node,
|
|
95
|
+
/** 欲前往的連結 */
|
|
96
|
+
pathname: PropTypes.string.isRequired,
|
|
97
|
+
/** 欲前往連結的參數 */
|
|
98
|
+
search: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
99
|
+
/** 彈跳提示文字 */
|
|
100
|
+
tip: PropTypes.string,
|
|
101
|
+
/** 元件被點即時的callback,返回false會停止元件導向 */
|
|
102
|
+
onClick: PropTypes.func
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { ForwardLink as F };
|
|
@@ -1,105 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
var css_248z = ".forwardLink {\n width: -moz-fit-content;\n width: fit-content; }\n .forwardLink__link {\n color: unset;\n text-decoration: none;\n cursor: pointer; }\n .forwardLink__link--disabled {\n cursor: not-allowed; }\n";
|
|
11
|
-
styleInject(css_248z);
|
|
12
|
-
|
|
13
|
-
var _excluded = ["className", "title", "target", "disabled", "children", "tip", "onClick"];
|
|
14
|
-
var locale = '/zh-tw'; // 20230318 暫時寫死,若套件納入語系控制,可將其置換
|
|
15
|
-
|
|
16
|
-
var ForwardLink = function ForwardLink(_ref) {
|
|
17
|
-
var className = _ref.className,
|
|
18
|
-
title = _ref.title,
|
|
19
|
-
target = _ref.target,
|
|
20
|
-
disabled = _ref.disabled,
|
|
21
|
-
children = _ref.children,
|
|
22
|
-
tip = _ref.tip;
|
|
23
|
-
_ref.onClick;
|
|
24
|
-
var rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
-
var history = useHistory();
|
|
26
|
-
var _useMemo = useMemo(function () {
|
|
27
|
-
var _rest$pathname;
|
|
28
|
-
if (disabled) return {};
|
|
29
|
-
/*
|
|
30
|
-
* 若將 search 寫在 pathname 中,意即 pathname=/asd?zxc=qwe
|
|
31
|
-
* 會導致換頁時 React route dom 無法匹配 => 空白畫面
|
|
32
|
-
* 若真有此情況發生 需把 search 提領出來
|
|
33
|
-
*/
|
|
34
|
-
var foundIndex = (_rest$pathname = rest.pathname) === null || _rest$pathname === void 0 ? void 0 : _rest$pathname.indexOf('?');
|
|
35
|
-
if (foundIndex > -1) return {
|
|
36
|
-
pathname: rest.pathname.substring(0, foundIndex),
|
|
37
|
-
search: rest.pathname.substring(foundIndex)
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
pathname: rest.pathname || '/',
|
|
41
|
-
search: typeof rest.search === 'string' ? rest.search : queryString.stringify(rest.search)
|
|
42
|
-
};
|
|
43
|
-
}, [history, disabled, rest.pathname, rest.search]),
|
|
44
|
-
_useMemo$pathname = _useMemo.pathname,
|
|
45
|
-
pathname = _useMemo$pathname === void 0 ? '' : _useMemo$pathname,
|
|
46
|
-
_useMemo$search = _useMemo.search,
|
|
47
|
-
search = _useMemo$search === void 0 ? '' : _useMemo$search;
|
|
48
|
-
var linkComponent = /*#__PURE__*/React__default.createElement("div", {
|
|
49
|
-
className: classNames('forwardLink', className)
|
|
50
|
-
}, disabled ? /*#__PURE__*/React__default.createElement("div", {
|
|
51
|
-
title: tip ? undefined : title,
|
|
52
|
-
className: "forwardLink__link--disabled"
|
|
53
|
-
}, children) : /*#__PURE__*/React__default.createElement(Link, {
|
|
54
|
-
className: "forwardLink__link",
|
|
55
|
-
target: target,
|
|
56
|
-
title: tip ? undefined : title,
|
|
57
|
-
to: {
|
|
58
|
-
pathname: "".concat(locale).concat(pathname),
|
|
59
|
-
search: search
|
|
60
|
-
}
|
|
61
|
-
}, children));
|
|
62
|
-
if (tip) {
|
|
63
|
-
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
64
|
-
title: tip,
|
|
65
|
-
placement: "top"
|
|
66
|
-
}, linkComponent);
|
|
67
|
-
}
|
|
68
|
-
return linkComponent;
|
|
69
|
-
};
|
|
70
|
-
ForwardLink.defaultProps = {
|
|
71
|
-
className: undefined,
|
|
72
|
-
title: undefined,
|
|
73
|
-
target: '_blank',
|
|
74
|
-
disabled: undefined,
|
|
75
|
-
children: undefined,
|
|
76
|
-
search: undefined,
|
|
77
|
-
tip: undefined,
|
|
78
|
-
onClick: function onClick() {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
84
|
-
ForwardLink.propTypes = {
|
|
85
|
-
/** Css Name */
|
|
86
|
-
className: PropTypes.string,
|
|
87
|
-
/** DOM title */
|
|
88
|
-
title: PropTypes.string,
|
|
89
|
-
/** DOM title */
|
|
90
|
-
target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
|
|
91
|
-
/** 是否取消點擊 */
|
|
92
|
-
disabled: PropTypes.bool,
|
|
93
|
-
/** 子項目 */
|
|
94
|
-
children: PropTypes.node,
|
|
95
|
-
/** 欲前往的連結 */
|
|
96
|
-
pathname: PropTypes.string.isRequired,
|
|
97
|
-
/** 欲前往連結的參數 */
|
|
98
|
-
search: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
99
|
-
/** 彈跳提示文字 */
|
|
100
|
-
tip: PropTypes.string,
|
|
101
|
-
/** 元件被點即時的callback,返回false會停止元件導向 */
|
|
102
|
-
onClick: PropTypes.func
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { ForwardLink as default };
|
|
1
|
+
export { F as default } from './ForwardLink-4759cf99.js';
|
|
2
|
+
import './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import './index-f491ebce.js';
|
|
5
|
+
import 'prop-types';
|
|
6
|
+
import './index-7b60a97d.js';
|
|
7
|
+
import 'react-router-dom';
|
|
8
|
+
import '@material-ui/core';
|
|
9
|
+
import './style-inject.es-1f59c1d0.js';
|
|
@@ -2,7 +2,11 @@ import { a as _slicedToArray } from './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
|
2
2
|
import React__default, { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { c as classNames } from './index-f491ebce.js';
|
|
5
|
+
import { F as ForwardLink } from './ForwardLink-4759cf99.js';
|
|
5
6
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
7
|
+
import './index-7b60a97d.js';
|
|
8
|
+
import 'react-router-dom';
|
|
9
|
+
import '@material-ui/core';
|
|
6
10
|
|
|
7
11
|
var css_248z = ".keywordTicker {\n width: 100%;\n display: flex;\n justify-content: flex-start;\n align-items: center; }\n .keywordTicker__track {\n display: flex;\n width: 100%;\n padding: 20px 0px;\n background-color: #ece8c0;\n overflow: hidden;\n margin-left: -80px;\n padding-left: 100px;\n z-index: 1;\n position: relative; }\n .keywordTicker__items {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n flex-wrap: nowrap;\n position: relative; }\n .keywordTicker-item {\n width: auto;\n display: flex;\n justify-content: center;\n align-items: center;\n white-space: nowrap;\n cursor: pointer; }\n .keywordTicker-text {\n font-size: 1.5rem;\n z-index: 2;\n font-weight: bold;\n color: #825c0d;\n border-left: 2px solid #fff;\n padding: 0px 40px; }\n .keywordTicker__img {\n z-index: 2;\n position: relative;\n display: flex; }\n .keywordTicker__img img {\n height: 100%;\n max-height: 195px;\n image-rendering: -webkit-optimize-contrast;\n position: relative; }\n .keywordTicker--fake {\n position: absolute;\n opacity: 0;\n width: 100%; }\n\n@media only screen and (max-width: 768px) {\n .keywordTicker-text {\n font-size: 1.5rem;\n padding: 0px 15px; }\n .keywordTicker__img img {\n max-height: 104px;\n left: -60px; }\n .keywordTicker__track {\n padding: 10px 0px;\n margin-left: -100px; } }\n\n@media only screen and (max-width: 484px) {\n .keywordTicker-text {\n font-size: 14px; } }\n";
|
|
8
12
|
styleInject(css_248z);
|
|
@@ -99,14 +103,15 @@ var KeywordTicker = function KeywordTicker(_ref) {
|
|
|
99
103
|
// 固定移動速度並計算動畫時間
|
|
100
104
|
var distance = startLine + wordsWidth - step; // 減掉單次畫面溢出的長度
|
|
101
105
|
var duration = distance / speed;
|
|
102
|
-
var initTracking = words.current.animate(
|
|
106
|
+
var initTracking = words.current.animate(
|
|
103
107
|
// keyframes
|
|
104
|
-
{
|
|
108
|
+
[{
|
|
105
109
|
left: "".concat(start, "px")
|
|
106
110
|
}, {
|
|
107
111
|
left: "-".concat(end, "px")
|
|
108
|
-
}],
|
|
109
|
-
|
|
112
|
+
}],
|
|
113
|
+
// timing options
|
|
114
|
+
{
|
|
110
115
|
duration: duration,
|
|
111
116
|
iterations: Infinity
|
|
112
117
|
});
|
|
@@ -129,27 +134,32 @@ var KeywordTicker = function KeywordTicker(_ref) {
|
|
|
129
134
|
backgroundColor: backgroundColor
|
|
130
135
|
},
|
|
131
136
|
onMouseEnter: function onMouseEnter() {
|
|
132
|
-
|
|
137
|
+
return tracking === null || tracking === void 0 ? void 0 : tracking.pause();
|
|
133
138
|
},
|
|
134
139
|
onMouseLeave: function onMouseLeave() {
|
|
135
|
-
|
|
140
|
+
return tracking === null || tracking === void 0 ? void 0 : tracking.play();
|
|
136
141
|
}
|
|
137
142
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
138
143
|
className: "keywordTicker__items",
|
|
139
144
|
ref: words
|
|
140
145
|
}, (result || []).map(function (_ref4, index) {
|
|
141
146
|
var keyword = _ref4.keyword;
|
|
142
|
-
return /*#__PURE__*/React__default.createElement(
|
|
143
|
-
className: "keywordTicker-item",
|
|
147
|
+
return /*#__PURE__*/React__default.createElement(ForwardLink, {
|
|
144
148
|
key: index.toString(),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
className: "keywordTicker-item",
|
|
150
|
+
pathname: "/knowledge/keyword",
|
|
151
|
+
search: {
|
|
152
|
+
keyword: keyword
|
|
153
|
+
},
|
|
154
|
+
disabled: _onClick
|
|
148
155
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
149
156
|
className: "keywordTicker-text",
|
|
150
157
|
style: {
|
|
151
158
|
color: fontColor,
|
|
152
159
|
borderColor: borderColor
|
|
160
|
+
},
|
|
161
|
+
onClick: function onClick() {
|
|
162
|
+
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(keyword);
|
|
153
163
|
}
|
|
154
164
|
}, keyword));
|
|
155
165
|
}))));
|
|
@@ -160,7 +170,7 @@ KeywordTicker.defaultProps = {
|
|
|
160
170
|
tickerStyles: undefined,
|
|
161
171
|
tickerAttribute: undefined,
|
|
162
172
|
setTickerAttribute: function setTickerAttribute() {},
|
|
163
|
-
onClick:
|
|
173
|
+
onClick: undefined
|
|
164
174
|
};
|
|
165
175
|
KeywordTicker.propTypes = {
|
|
166
176
|
/** Css Name */
|
package/package.json
CHANGED