carbon-react 95.1.2 → 97.0.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/lib/components/multi-action-button/multi-action-button.component.js +2 -2
- package/lib/components/multi-action-button/multi-action-button.config.js +1 -1
- package/lib/components/multi-action-button/multi-action-button.d.ts +4 -1
- package/lib/components/pod/pod.d.ts +3 -1
- package/lib/components/select/filterable-select/filterable-select.component.js +25 -10
- package/lib/components/select/multi-select/multi-select.component.js +13 -16
- package/lib/components/select/simple-select/simple-select.component.js +6 -4
- package/lib/components/select/simple-select/simple-select.d.ts +1 -1
- package/lib/components/select/utils/is-expected-option.js +8 -0
- package/lib/components/show-edit-pod/show-edit-pod-test.stories.js +165 -0
- package/lib/components/show-edit-pod/show-edit-pod.component.js +154 -223
- package/lib/components/show-edit-pod/show-edit-pod.d.ts +3 -1
- package/lib/components/textarea/textarea-test.stories.js +153 -0
- package/lib/components/textarea/textarea.component.js +144 -215
- package/lib/components/textarea/textarea.d.ts +1 -1
- package/package.json +11 -5
- package/scripts/check_carbon_version.js +30 -0
- package/scripts/check_rfcs.js +49 -0
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.OriginalTextarea = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -35,229 +35,167 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
|
35
35
|
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
37
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
|
-
|
|
42
|
-
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); } }
|
|
43
|
-
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
45
|
-
|
|
46
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
|
-
|
|
48
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
-
|
|
50
|
-
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); }; }
|
|
51
|
-
|
|
52
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
53
|
-
|
|
54
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
38
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
55
39
|
|
|
56
|
-
function
|
|
40
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
57
41
|
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
42
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
61
43
|
|
|
62
44
|
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
63
45
|
|
|
64
46
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
65
47
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
48
|
+
const Textarea = ({
|
|
49
|
+
autoFocus,
|
|
50
|
+
fieldHelp,
|
|
51
|
+
label,
|
|
52
|
+
size,
|
|
53
|
+
children,
|
|
54
|
+
characterLimit,
|
|
55
|
+
enforceCharacterLimit = true,
|
|
56
|
+
warnOverLimit = false,
|
|
57
|
+
onChange,
|
|
58
|
+
disabled = false,
|
|
59
|
+
labelInline,
|
|
60
|
+
labelAlign,
|
|
61
|
+
labelHelp,
|
|
62
|
+
labelSpacing,
|
|
63
|
+
inputIcon,
|
|
64
|
+
id: idProp,
|
|
65
|
+
error,
|
|
66
|
+
warning,
|
|
67
|
+
info,
|
|
68
|
+
name,
|
|
69
|
+
readOnly = false,
|
|
70
|
+
placeholder,
|
|
71
|
+
expandable = false,
|
|
72
|
+
rows,
|
|
73
|
+
cols,
|
|
74
|
+
validationOnLabel = false,
|
|
75
|
+
adaptiveLabelBreakpoint,
|
|
76
|
+
inputWidth,
|
|
77
|
+
labelWidth = 30,
|
|
78
|
+
tooltipPosition,
|
|
79
|
+
value,
|
|
80
|
+
"data-component": dataComponent,
|
|
81
|
+
"data-element": dataElement,
|
|
82
|
+
"data-role": dataRole,
|
|
83
|
+
helpAriaLabel,
|
|
84
|
+
...props
|
|
85
|
+
}) => {
|
|
86
|
+
const locale = (0, _react.useContext)(_i18nContext.default);
|
|
87
|
+
const {
|
|
88
|
+
current: id
|
|
89
|
+
} = (0, _react.useRef)(idProp || (0, _guid.default)());
|
|
90
|
+
const inputRef = (0, _react.useRef)();
|
|
91
|
+
const minHeight = (0, _react.useRef)(0);
|
|
92
|
+
|
|
93
|
+
const expandTextarea = () => {
|
|
94
|
+
const textarea = inputRef.current;
|
|
95
|
+
|
|
96
|
+
if (textarea.scrollHeight > minHeight.current) {
|
|
97
|
+
// Reset height to zero - IE specific
|
|
98
|
+
textarea.style.height = "0px"; // Set the height so all content is shown
|
|
99
|
+
|
|
100
|
+
textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_createClass(Textarea, [{
|
|
99
|
-
key: "componentDidMount",
|
|
100
|
-
value:
|
|
101
|
-
/**
|
|
102
|
-
* A lifecycle method that is called after initial render.
|
|
103
|
-
* Allows access to refs and DOM to set expandable variables
|
|
104
|
-
*/
|
|
105
|
-
function componentDidMount() {
|
|
106
|
-
if (this.props.expandable) {
|
|
107
|
-
window.addEventListener("resize", this.expandTextarea); // Set the min height to the initially rendered height.
|
|
108
|
-
// Without minHeight expandable textareas will only have
|
|
109
|
-
// one line when no content is present.
|
|
110
|
-
|
|
111
|
-
this.minHeight = this._input.current.clientHeight;
|
|
112
|
-
this.expandTextarea();
|
|
113
|
-
}
|
|
104
|
+
(0, _react.useEffect)(() => {
|
|
105
|
+
if (expandable) {
|
|
106
|
+
expandTextarea();
|
|
114
107
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
108
|
+
});
|
|
109
|
+
(0, _react.useEffect)(() => {
|
|
110
|
+
if (expandable) {
|
|
111
|
+
window.addEventListener("resize", expandTextarea);
|
|
112
|
+
minHeight.current = inputRef.current.clientHeight;
|
|
121
113
|
}
|
|
122
|
-
}, {
|
|
123
|
-
key: "componentDidUpdate",
|
|
124
|
-
value: function componentDidUpdate() {
|
|
125
|
-
const {
|
|
126
|
-
expandable
|
|
127
|
-
} = this.props;
|
|
128
114
|
|
|
115
|
+
return () => {
|
|
129
116
|
if (expandable) {
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "overLimit",
|
|
135
|
-
get: function () {
|
|
136
|
-
const value = this.props.value || "";
|
|
137
|
-
return value.length > parseInt(this.props.characterLimit, 10);
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
key: "characterCount",
|
|
141
|
-
get: function () {
|
|
142
|
-
const value = this.props.value || "";
|
|
143
|
-
const {
|
|
144
|
-
characterLimit,
|
|
145
|
-
warnOverLimit
|
|
146
|
-
} = this.props;
|
|
147
|
-
|
|
148
|
-
if (!characterLimit) {
|
|
149
|
-
return null;
|
|
117
|
+
window.removeEventListener("resize", expandTextarea);
|
|
150
118
|
}
|
|
119
|
+
};
|
|
120
|
+
}, [expandable]);
|
|
151
121
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}, {
|
|
160
|
-
key: "render",
|
|
161
|
-
value: function render() {
|
|
162
|
-
const {
|
|
163
|
-
autoFocus,
|
|
164
|
-
fieldHelp,
|
|
165
|
-
label,
|
|
166
|
-
size,
|
|
167
|
-
children,
|
|
168
|
-
characterLimit,
|
|
169
|
-
enforceCharacterLimit,
|
|
170
|
-
onChange,
|
|
171
|
-
disabled,
|
|
172
|
-
labelInline,
|
|
173
|
-
labelAlign,
|
|
174
|
-
labelHelp,
|
|
175
|
-
labelSpacing,
|
|
176
|
-
inputIcon,
|
|
177
|
-
error,
|
|
178
|
-
warning,
|
|
179
|
-
info,
|
|
180
|
-
name,
|
|
181
|
-
readOnly,
|
|
182
|
-
placeholder,
|
|
183
|
-
rows,
|
|
184
|
-
cols,
|
|
185
|
-
validationOnLabel,
|
|
186
|
-
adaptiveLabelBreakpoint,
|
|
187
|
-
inputWidth,
|
|
188
|
-
labelWidth,
|
|
189
|
-
tooltipPosition,
|
|
190
|
-
"data-component": dataComponent,
|
|
191
|
-
"data-element": dataElement,
|
|
192
|
-
"data-role": dataRole,
|
|
193
|
-
helpAriaLabel,
|
|
194
|
-
...props
|
|
195
|
-
} = this.props;
|
|
196
|
-
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
197
|
-
helpAriaLabel: helpAriaLabel,
|
|
198
|
-
tooltipPosition: tooltipPosition
|
|
199
|
-
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_textarea.default, _extends({
|
|
200
|
-
labelInline: labelInline,
|
|
201
|
-
"data-component": dataComponent,
|
|
202
|
-
"data-role": dataRole,
|
|
203
|
-
"data-element": dataElement
|
|
204
|
-
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_formField.default, {
|
|
205
|
-
fieldHelp: fieldHelp,
|
|
206
|
-
error: error,
|
|
207
|
-
warning: warning,
|
|
208
|
-
info: info,
|
|
209
|
-
label: label,
|
|
210
|
-
disabled: disabled,
|
|
211
|
-
id: this.id,
|
|
212
|
-
labelInline: labelInline,
|
|
213
|
-
labelAlign: labelAlign,
|
|
214
|
-
labelWidth: labelWidth,
|
|
215
|
-
labelHelp: labelHelp,
|
|
216
|
-
labelSpacing: labelSpacing,
|
|
217
|
-
isRequired: props.required,
|
|
218
|
-
useValidationIcon: validationOnLabel,
|
|
219
|
-
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
|
|
220
|
-
}, /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
|
|
221
|
-
size: size,
|
|
222
|
-
disabled: disabled,
|
|
223
|
-
readOnly: readOnly,
|
|
224
|
-
inputWidth: typeof inputWidth === "number" ? inputWidth : 100 - labelWidth,
|
|
225
|
-
error: error,
|
|
226
|
-
warning: warning,
|
|
227
|
-
info: info
|
|
228
|
-
}, /*#__PURE__*/_react.default.createElement(_input2.default, _extends({
|
|
229
|
-
autoFocus: autoFocus,
|
|
230
|
-
name: name,
|
|
231
|
-
"aria-invalid": !!error,
|
|
232
|
-
ref: this._input,
|
|
233
|
-
maxLength: enforceCharacterLimit && characterLimit ? characterLimit : undefined,
|
|
234
|
-
onChange: onChange,
|
|
235
|
-
disabled: disabled,
|
|
236
|
-
readOnly: readOnly,
|
|
237
|
-
labelInline: labelInline,
|
|
238
|
-
placeholder: disabled ? "" : placeholder,
|
|
239
|
-
rows: rows,
|
|
240
|
-
cols: cols,
|
|
241
|
-
id: this.id,
|
|
242
|
-
as: "textarea"
|
|
243
|
-
}, props)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
|
|
244
|
-
disabled: disabled,
|
|
245
|
-
readOnly: readOnly,
|
|
246
|
-
inputIcon: inputIcon,
|
|
247
|
-
size: size,
|
|
248
|
-
error: error,
|
|
249
|
-
warning: warning,
|
|
250
|
-
info: info,
|
|
251
|
-
useValidationIcon: !validationOnLabel
|
|
252
|
-
}))), this.characterCount)));
|
|
122
|
+
const isOverLimit = () => {
|
|
123
|
+
return (value || "").length > parseInt(characterLimit, 10);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const characterCount = () => {
|
|
127
|
+
if (!characterLimit) {
|
|
128
|
+
return null;
|
|
253
129
|
}
|
|
254
|
-
}]);
|
|
255
130
|
|
|
256
|
-
|
|
257
|
-
|
|
131
|
+
return /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
132
|
+
isOverLimit: isOverLimit() && warnOverLimit,
|
|
133
|
+
value: getFormatNumber((value || "").length, locale.locale()),
|
|
134
|
+
limit: getFormatNumber(characterLimit, locale.locale()),
|
|
135
|
+
"data-element": "character-limit"
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
140
|
+
tooltipPosition: tooltipPosition,
|
|
141
|
+
helpAriaLabel: helpAriaLabel
|
|
142
|
+
}, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_textarea.default, _extends({
|
|
143
|
+
labelInline: labelInline,
|
|
144
|
+
"data-component": dataComponent,
|
|
145
|
+
"data-role": dataRole,
|
|
146
|
+
"data-element": dataElement
|
|
147
|
+
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement(_formField.default, {
|
|
148
|
+
fieldHelp: fieldHelp,
|
|
149
|
+
error: error,
|
|
150
|
+
warning: warning,
|
|
151
|
+
info: info,
|
|
152
|
+
label: label,
|
|
153
|
+
disabled: disabled,
|
|
154
|
+
id: id,
|
|
155
|
+
labelInline: labelInline,
|
|
156
|
+
labelAlign: labelAlign,
|
|
157
|
+
labelWidth: labelWidth,
|
|
158
|
+
labelHelp: labelHelp,
|
|
159
|
+
labelSpacing: labelSpacing,
|
|
160
|
+
isRequired: props.required,
|
|
161
|
+
useValidationIcon: validationOnLabel,
|
|
162
|
+
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
|
|
163
|
+
}, /*#__PURE__*/_react.default.createElement(_input.InputPresentation, {
|
|
164
|
+
size: size,
|
|
165
|
+
disabled: disabled,
|
|
166
|
+
readOnly: readOnly,
|
|
167
|
+
inputWidth: typeof inputWidth === "number" ? inputWidth : 100 - labelWidth,
|
|
168
|
+
error: error,
|
|
169
|
+
warning: warning,
|
|
170
|
+
info: info
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement(_input2.default, _extends({
|
|
172
|
+
autoFocus: autoFocus,
|
|
173
|
+
name: name,
|
|
174
|
+
"aria-invalid": !!error,
|
|
175
|
+
ref: inputRef,
|
|
176
|
+
maxLength: enforceCharacterLimit && characterLimit ? characterLimit : undefined,
|
|
177
|
+
onChange: onChange,
|
|
178
|
+
disabled: disabled,
|
|
179
|
+
readOnly: readOnly,
|
|
180
|
+
labelInline: labelInline,
|
|
181
|
+
placeholder: disabled ? "" : placeholder,
|
|
182
|
+
rows: rows,
|
|
183
|
+
cols: cols,
|
|
184
|
+
id: id,
|
|
185
|
+
as: "textarea"
|
|
186
|
+
}, props)), children, /*#__PURE__*/_react.default.createElement(_inputIconToggle.default, {
|
|
187
|
+
disabled: disabled,
|
|
188
|
+
readOnly: readOnly,
|
|
189
|
+
inputIcon: inputIcon,
|
|
190
|
+
size: size,
|
|
191
|
+
error: error,
|
|
192
|
+
warning: warning,
|
|
193
|
+
info: info,
|
|
194
|
+
useValidationIcon: !validationOnLabel
|
|
195
|
+
}))), characterCount())));
|
|
196
|
+
};
|
|
258
197
|
|
|
259
198
|
exports.OriginalTextarea = Textarea;
|
|
260
|
-
Textarea.contextType = _i18nContext.default;
|
|
261
199
|
Textarea.propTypes = { ...marginPropTypes,
|
|
262
200
|
|
|
263
201
|
/** Automatically focus the input on component mount */
|
|
@@ -381,14 +319,5 @@ Textarea.propTypes = { ...marginPropTypes,
|
|
|
381
319
|
/** Aria label for rendered help component */
|
|
382
320
|
helpAriaLabel: _propTypes.default.string
|
|
383
321
|
};
|
|
384
|
-
Textarea.defaultProps = {
|
|
385
|
-
labelWidth: 30,
|
|
386
|
-
disabled: false,
|
|
387
|
-
expandable: false,
|
|
388
|
-
enforceCharacterLimit: true,
|
|
389
|
-
readOnly: false,
|
|
390
|
-
warnOverLimit: false,
|
|
391
|
-
validationOnLabel: false
|
|
392
|
-
};
|
|
393
322
|
var _default = Textarea;
|
|
394
323
|
exports.default = _default;
|
|
@@ -74,7 +74,7 @@ export interface TextareaProps
|
|
|
74
74
|
helpAriaLabel?: string;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
declare
|
|
77
|
+
declare function Textarea(props: TextareaProps): JSX.Element;
|
|
78
78
|
|
|
79
79
|
export { Textarea as OriginalTextarea };
|
|
80
80
|
export default Textarea;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "97.0.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
"node": ">=14.16.0"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"lib"
|
|
11
|
+
"lib",
|
|
12
|
+
"scripts/check_carbon_version.js",
|
|
13
|
+
"scripts/check_rfcs.js"
|
|
12
14
|
],
|
|
13
15
|
"scripts": {
|
|
14
|
-
"start": "node ./
|
|
16
|
+
"start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -s .assets -c .storybook",
|
|
15
17
|
"start:debug-theme": "cross-env STORYBOOK_DEBUG_THEME=true npm run start",
|
|
16
18
|
"test": "jest --config=./jest.conf.json",
|
|
17
19
|
"test-update": "jest --config=./jest.conf.json --updateSnapshot",
|
|
@@ -22,14 +24,14 @@
|
|
|
22
24
|
"lint": "eslint ./src",
|
|
23
25
|
"precompile": "npm run clean-lib && npm run copy-files && npm run babel",
|
|
24
26
|
"prepublishOnly": "npm run precompile",
|
|
27
|
+
"postinstall": "node ./scripts/check_carbon_version.js && node ./scripts/check_rfcs.js",
|
|
25
28
|
"watch": "npm run clean-lib && npm run copy-files -- --watch & npm run babel -- --watch",
|
|
26
29
|
"build-storybook": "build-storybook -c .storybook -s .assets",
|
|
27
30
|
"start:static": "npx http-server -p 9001 ./storybook-static",
|
|
28
31
|
"babel": "cross-env NODE_ENV=production babel ./src --config-file ./babel.config.js --out-dir ./lib --ignore '**/*/__spec__.js','**/*.spec.js','**/__definition__.js' --quiet",
|
|
29
32
|
"clean-lib": "rimraf ./lib",
|
|
30
33
|
"copy-files": "cpy \"**/\" \"!**/(*.js|*.md|*.mdx|*.stories.*|*.snap)\" ../lib/ --cwd=src --parents",
|
|
31
|
-
"commit": "git-cz"
|
|
32
|
-
"chromatic": "chromatic"
|
|
34
|
+
"commit": "git-cz"
|
|
33
35
|
},
|
|
34
36
|
"repository": {
|
|
35
37
|
"type": "git",
|
|
@@ -86,6 +88,7 @@
|
|
|
86
88
|
"babel-jest": "^26.6.3",
|
|
87
89
|
"browserslist": "^4.16.6",
|
|
88
90
|
"chalk": "^4.1.1",
|
|
91
|
+
"chromatic": "^6.0.5",
|
|
89
92
|
"commitizen": "^4.2.4",
|
|
90
93
|
"conventional-changelog-conventionalcommits": "^4.5.0",
|
|
91
94
|
"core-js": "^3.1.4",
|
|
@@ -132,16 +135,19 @@
|
|
|
132
135
|
"typescript": "^3.9.5"
|
|
133
136
|
},
|
|
134
137
|
"dependencies": {
|
|
138
|
+
"@octokit/rest": "^18.12.0",
|
|
135
139
|
"@popperjs/core": "^2.9.0",
|
|
136
140
|
"@sage/design-tokens": "^1.73.0",
|
|
137
141
|
"@styled-system/prop-types": "^5.1.5",
|
|
138
142
|
"@tippyjs/react": "^4.2.5",
|
|
139
143
|
"classnames": "~2.2.6",
|
|
140
144
|
"crypto-js": "~3.3.0",
|
|
145
|
+
"dotenv": "^10.0.0",
|
|
141
146
|
"immutable": "~3.8.2",
|
|
142
147
|
"invariant": "^2.2.4",
|
|
143
148
|
"lodash": "^4.17.20",
|
|
144
149
|
"moment": "~2.20.1",
|
|
150
|
+
"node-fetch": "^2.6.1",
|
|
145
151
|
"polished": "^4.0.5",
|
|
146
152
|
"prop-types": "^15.7.2",
|
|
147
153
|
"react-day-picker": "~6.1.1",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
const fetch = require("node-fetch");
|
|
3
|
+
const dotenv = require("dotenv");
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const { version } = require("../package.json");
|
|
6
|
+
|
|
7
|
+
dotenv.config();
|
|
8
|
+
const majorVersion = version.split(".")[0];
|
|
9
|
+
|
|
10
|
+
const checkCarbonVersion = () => {
|
|
11
|
+
fetch("https://registry.npmjs.com/carbon-react")
|
|
12
|
+
.then((res) => res.json())
|
|
13
|
+
.then((data) => {
|
|
14
|
+
const { latest } = data["dist-tags"];
|
|
15
|
+
const latestMajor = latest.split(".")[0];
|
|
16
|
+
|
|
17
|
+
const diff = Number(latestMajor) - Number(majorVersion);
|
|
18
|
+
|
|
19
|
+
if (diff > 1) {
|
|
20
|
+
console.log(
|
|
21
|
+
`carbon-react version installed is currently ${chalk.yellow(
|
|
22
|
+
diff
|
|
23
|
+
)} major versions behind the latest.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
.catch((err) => console.log(err));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (!process.env.CARBON_INSTALL) checkCarbonVersion();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
const { Octokit } = require("@octokit/rest");
|
|
3
|
+
const dotenv = require("dotenv");
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
const octokit = new Octokit({
|
|
8
|
+
baseUrl: "https://api.github.com",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const method = "GET";
|
|
12
|
+
const owner = "sage";
|
|
13
|
+
const path = "pulls";
|
|
14
|
+
const repo = "carbon";
|
|
15
|
+
const url = "/repos/{owner}/{repo}/{path}";
|
|
16
|
+
|
|
17
|
+
const getOpenRfcs = async () => {
|
|
18
|
+
const { data } = await octokit.request({
|
|
19
|
+
owner,
|
|
20
|
+
repo,
|
|
21
|
+
url,
|
|
22
|
+
method,
|
|
23
|
+
path,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return data.filter((item) => {
|
|
27
|
+
const labels = item.labels.filter((label) => label.name === "RFC");
|
|
28
|
+
|
|
29
|
+
return labels.length > 0;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getRfcTitle = (rfc) => rfc.title.split(": ")[1];
|
|
34
|
+
|
|
35
|
+
const checkRfcs = async () => {
|
|
36
|
+
const openRfcs = await getOpenRfcs();
|
|
37
|
+
|
|
38
|
+
if (openRfcs.length > 0) {
|
|
39
|
+
console.log("\ncarbon-react currently has open RFCs:");
|
|
40
|
+
|
|
41
|
+
openRfcs.forEach((item) => {
|
|
42
|
+
const title = getRfcTitle(item);
|
|
43
|
+
console.log(`- ${title}: ${chalk.cyan(item.html_url)}`);
|
|
44
|
+
});
|
|
45
|
+
console.log("\n");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (!process.env.CARBON_INSTALL) checkRfcs();
|