@twreporter/react-components 8.21.0-rc.1 → 8.21.0-rc.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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [8.21.0-rc.2](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-components@8.21.0-rc.1...@twreporter/react-components@8.21.0-rc.2) (2023-11-13)
7
+
8
+
9
+ ### Features
10
+
11
+ * add `InheritLinkButton` component & story ([81788c5](https://github.com/twreporter/twreporter-npm-packages/commit/81788c5cbe4ac208656a83ae9dd565f1e06bb587))
12
+
13
+
14
+
15
+
16
+
6
17
  # [8.21.0-rc.1](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/react-components@8.21.0-rc.0...@twreporter/react-components@8.21.0-rc.1) (2023-11-13)
7
18
 
8
19
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports["default"] = exports.InheritLinkButton = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -19,7 +19,8 @@ var _enums = require("../enums");
19
19
 
20
20
  var _color2 = require("@twreporter/core/lib/constants/color");
21
21
 
22
- var _excluded = ["type", "link", "text", "weight", "TextComponent", "disabled"];
22
+ var _excluded = ["type", "link", "text", "weight", "TextComponent", "disabled"],
23
+ _excluded2 = ["type", "link", "text"];
23
24
 
24
25
  var _decoration, _color;
25
26
 
@@ -37,16 +38,24 @@ var style = {
37
38
  decoration: (_decoration = {}, _defineProperty(_decoration, _enums.LinkType.DEFAULT, 'none'), _defineProperty(_decoration, _enums.LinkType.UNDERLINE, 'underline'), _decoration),
38
39
  color: (_color = {}, _defineProperty(_color, _enums.LinkType.DEFAULT, _color2.COLOR_SEMANTIC.info), _defineProperty(_color, _enums.LinkType.UNDERLINE, _color2.colorGrayscale.gray600), _color)
39
40
  };
40
- var LinkContainer = /*#__PURE__*/(0, _styledComponents["default"])(_customizedLink["default"]).withConfig({
41
- displayName: "link__LinkContainer",
41
+ var BaseContainer = /*#__PURE__*/(0, _styledComponents["default"])(_customizedLink["default"]).withConfig({
42
+ displayName: "link__BaseContainer",
42
43
  componentId: "g5z7t5-0"
43
- })(["display:flex;align-items:center;text-underline-offset:4px;text-decoration-line:", ";color:", ";", ""], function (props) {
44
+ })(["text-underline-offset:4px;text-decoration-line:", ";color:", ";&:hover{text-decoration-line:underline;}"], function (props) {
44
45
  return style.decoration[props.type];
45
46
  }, function (props) {
46
47
  return style.color[props.type];
47
- }, function (props) {
48
- return props.disabled ? "\n opacity: 0.5;\n cursor: auto;\n -webkit-tap-highlight-color: transparent;\n " : "\n &:hover {\n text-decoration-line: underline;\n }\n ";
49
48
  });
49
+ var LinkContainer = /*#__PURE__*/(0, _styledComponents["default"])(BaseContainer).withConfig({
50
+ displayName: "link__LinkContainer",
51
+ componentId: "g5z7t5-1"
52
+ })(["display:flex;align-items:center;", ""], function (props) {
53
+ return props.disabled ? "\n opacity: 0.5;\n cursor: auto;\n -webkit-tap-highlight-color: transparent;\n " : "\n ";
54
+ });
55
+ var InheritLinkContainer = /*#__PURE__*/(0, _styledComponents["default"])(BaseContainer).withConfig({
56
+ displayName: "link__InheritLinkContainer",
57
+ componentId: "g5z7t5-2"
58
+ })([""]);
50
59
 
51
60
  var LinkButton = function LinkButton(_ref) {
52
61
  var _ref$type = _ref.type,
@@ -86,5 +95,27 @@ LinkButton.propTypes = {
86
95
  };
87
96
  LinkButton.Type = _enums.LinkType;
88
97
  LinkButton.Weight = _paragraph.P1.Weight;
98
+
99
+ var InheritLinkButton = function InheritLinkButton(_ref2) {
100
+ var _ref2$type = _ref2.type,
101
+ type = _ref2$type === void 0 ? _enums.LinkType.DEFAULT : _ref2$type,
102
+ _ref2$link = _ref2.link,
103
+ link = _ref2$link === void 0 ? {} : _ref2$link,
104
+ _ref2$text = _ref2.text,
105
+ text = _ref2$text === void 0 ? '' : _ref2$text,
106
+ props = _objectWithoutProperties(_ref2, _excluded2);
107
+
108
+ return /*#__PURE__*/_react["default"].createElement(InheritLinkContainer, _extends({
109
+ type: type
110
+ }, props), text);
111
+ };
112
+
113
+ exports.InheritLinkButton = InheritLinkButton;
114
+ InheritLinkButton.propTypes = {
115
+ type: _propTypes["default"].oneOf(Object.values(_enums.LinkType)),
116
+ link: _propTypes["default"].object,
117
+ text: _propTypes["default"].string.isRequired
118
+ };
119
+ InheritLinkButton.Type = _enums.LinkType;
89
120
  var _default = LinkButton;
90
121
  exports["default"] = _default;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -15,6 +17,12 @@ Object.defineProperty(exports, "IconWithTextButton", {
15
17
  return _iconWithTextButton["default"];
16
18
  }
17
19
  });
20
+ Object.defineProperty(exports, "InheritLinkButton", {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _link.InheritLinkButton;
24
+ }
25
+ });
18
26
  Object.defineProperty(exports, "LinkButton", {
19
27
  enumerable: true,
20
28
  get: function get() {
@@ -57,10 +65,14 @@ var _textButton = _interopRequireDefault(require("./components/textButton"));
57
65
 
58
66
  var _toggleButton = _interopRequireDefault(require("./components/toggleButton"));
59
67
 
60
- var _link = _interopRequireDefault(require("./components/link"));
68
+ var _link = _interopRequireWildcard(require("./components/link"));
61
69
 
62
70
  var _menuButton = _interopRequireDefault(require("./components/menuButton"));
63
71
 
72
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
73
+
74
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
75
+
64
76
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
65
77
 
66
78
  var _default = {
@@ -70,6 +82,7 @@ var _default = {
70
82
  TextButton: _textButton["default"],
71
83
  ToggleButton: _toggleButton["default"],
72
84
  LinkButton: _link["default"],
85
+ InheritLinkButton: _link.InheritLinkButton,
73
86
  MenuButton: _menuButton["default"]
74
87
  };
75
88
  exports["default"] = _default;
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
- exports.link = exports.disabledLink = exports["default"] = exports.changeTextComponent = void 0;
8
+ exports.linkInParagraph = exports.link = exports.disabledLink = exports["default"] = exports.changeTextComponent = void 0;
7
9
 
8
10
  var _react = _interopRequireDefault(require("react"));
9
11
 
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
10
14
  var _getEnumArg = require("../../storybook/utils/get-enum-arg");
11
15
 
12
- var _link = _interopRequireDefault(require("../components/link"));
16
+ var _link = _interopRequireWildcard(require("../components/link"));
13
17
 
14
18
  var _paragraph = require("../../text/paragraph");
15
19
 
16
20
  var _headline = require("../../text/headline");
17
21
 
22
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
+
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
18
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
27
 
20
28
  var _default = {
@@ -22,6 +30,7 @@ var _default = {
22
30
  component: _link["default"],
23
31
  argTypes: {
24
32
  type: (0, _getEnumArg.getRadioArg)(_link["default"].Type, _link["default"].Type.DEFAULT),
33
+ weight: (0, _getEnumArg.getRadioArg)(_link["default"].Weight, _link["default"].Weight.NORMAL),
25
34
  // textComponent is only for storybook showcase, not real props
26
35
  textComponent: {
27
36
  defaultValue: 'P2',
@@ -29,6 +38,19 @@ var _default = {
29
38
  control: {
30
39
  type: 'radio'
31
40
  }
41
+ },
42
+ // leftWord & rightWord is only for storybook showcase, not real props
43
+ leftWord: {
44
+ defaultValue: '連結左邊的文字',
45
+ control: {
46
+ type: 'text'
47
+ }
48
+ },
49
+ rightWord: {
50
+ defaultValue: '連結左邊的文字',
51
+ control: {
52
+ type: 'text'
53
+ }
32
54
  }
33
55
  }
34
56
  };
@@ -49,7 +71,7 @@ link.args = {
49
71
  };
50
72
  link.parameters = {
51
73
  controls: {
52
- exclude: ['textComponent']
74
+ exclude: ['textComponent', 'leftWord', 'rightWord']
53
75
  }
54
76
  };
55
77
 
@@ -76,7 +98,7 @@ changeTextComponent.args = {
76
98
  };
77
99
  changeTextComponent.parameters = {
78
100
  controls: {
79
- exclude: ['TextComponent']
101
+ exclude: ['TextComponent', 'leftWord', 'rightWord']
80
102
  }
81
103
  };
82
104
  var disabledLink = Template.bind({});
@@ -91,6 +113,28 @@ disabledLink.args = {
91
113
  };
92
114
  disabledLink.parameters = {
93
115
  controls: {
94
- exclude: ['textComponent', 'disabled']
116
+ exclude: ['textComponent', 'disabled', 'leftWord', 'rightWord']
117
+ }
118
+ };
119
+ var StyledP1 = /*#__PURE__*/(0, _styledComponents["default"])(_paragraph.P1).withConfig({
120
+ displayName: "linkstories__StyledP1",
121
+ componentId: "sc-1i9kyc3-0"
122
+ })(["display:unset;"]);
123
+
124
+ var linkInParagraph = function linkInParagraph(args) {
125
+ return /*#__PURE__*/_react["default"].createElement(StyledP1, null, args.leftWord, /*#__PURE__*/_react["default"].createElement(_link.InheritLinkButton, args), args.rightWord);
126
+ };
127
+
128
+ exports.linkInParagraph = linkInParagraph;
129
+ linkInParagraph.args = {
130
+ text: '文字',
131
+ type: _link["default"].Type.DEFAULT,
132
+ link: {
133
+ to: 'https://www.twreporter.org'
134
+ }
135
+ };
136
+ linkInParagraph.parameters = {
137
+ controls: {
138
+ exclude: ['textComponent', 'disabled', 'weight', 'TextComponent']
95
139
  }
96
140
  };
@@ -25,7 +25,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
25
25
 
26
26
  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; }
27
27
 
28
- var defaultContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
28
+ var defaultContainer = /*#__PURE__*/_styledComponents["default"].p.withConfig({
29
29
  displayName: "paragraph__defaultContainer",
30
30
  componentId: "sc-1aejhao-0"
31
31
  })(["font-weight:", ";font-family:", ";line-height:150%;display:flex;align-items:center;"], function (props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twreporter/react-components",
3
- "version": "8.21.0-rc.1",
3
+ "version": "8.21.0-rc.2",
4
4
  "main": "lib/index.js",
5
5
  "repository": "https://github.com/twreporter/twreporter-npm-packages.git",
6
6
  "author": "twreporter <developer@twreporter.org>",
@@ -44,5 +44,5 @@
44
44
  "babel-loader": "^8.2.4",
45
45
  "chromatic": "^6.5.4"
46
46
  },
47
- "gitHead": "aa00452ea5c3557c71865aa121dfa630f84e6a04"
47
+ "gitHead": "c246d988fe96568fd2ebf5cb6f0806e0f4bf924e"
48
48
  }