superdesk-ui-framework 4.0.33 → 4.0.35

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.
@@ -14,10 +14,12 @@ class DateTimePickerExample extends React.PureComponent<{}, {dateTime: Date | nu
14
14
  render() {
15
15
  return (
16
16
  <DateTimePicker
17
- label={{text: "Planning date"}}
17
+ label="Planning date"
18
+ labelHidden
19
+ inlineLabel
18
20
  value={this.state.dateTime}
19
21
  dateFormat="YYYY-MM-DD"
20
- width="100%"
22
+ fullWidth
21
23
  onChange={(val) => {
22
24
  const parsedVal = val != null ? new Date(val) : null;
23
25
 
@@ -49,11 +51,14 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
49
51
  <h2 className="docs-page__h2">Date picker</h2>
50
52
  <Markup.ReactMarkupCodePreview>{`
51
53
  <DateTimePicker
52
- label="Planning datetime"
53
- value={this.state.date}
54
+ label="Planning date"
55
+ value={this.state.dateTime}
54
56
  dateFormat="YYYY-MM-DD"
55
- onChange={(date) => {
56
- this.setState({date});
57
+ fullWidth
58
+ onChange={(val) => {
59
+ const parsedVal = val != null ? new Date(val) : null;
60
+
61
+ this.setState({dateTime: parsedVal});
57
62
  }}
58
63
  />
59
64
  `}</Markup.ReactMarkupCodePreview>
@@ -65,11 +70,15 @@ export default class DateTimePickerDoc extends React.Component<{}, IState> {
65
70
  </Markup.ReactMarkupPreview>
66
71
  <Markup.ReactMarkupCode>{`
67
72
  <DateTimePicker
68
- value={this.state.date}
69
- onChange={(date) => {
70
- this.setState({date});
71
- }}
73
+ label="Planning date"
74
+ value={this.state.dateTime}
72
75
  dateFormat="YYYY-MM-DD"
76
+ fullWidth
77
+ onChange={(val) => {
78
+ const parsedVal = val != null ? new Date(val) : null;
79
+
80
+ this.setState({dateTime: parsedVal});
81
+ }}
73
82
  />
74
83
  `}</Markup.ReactMarkupCode>
75
84
  </Markup.ReactMarkup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "4.0.33",
3
+ "version": "4.0.35",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -97,7 +97,7 @@
97
97
  "dependencies": {
98
98
  "@popperjs/core": "^2.4.0",
99
99
  "@superdesk/common": "0.0.28",
100
- "@superdesk/primereact": "^5.0.2-12",
100
+ "@superdesk/primereact": "^5.0.2-13",
101
101
  "@superdesk/react-resizable-panels": "0.0.39",
102
102
  "chart.js": "^2.9.3",
103
103
  "date-fns": "2.7.0",
@@ -3,6 +3,7 @@ interface IProps {
3
3
  orientation?: 'horizontal' | 'vertical';
4
4
  children: React.ReactNode;
5
5
  groupLabelledBy?: string;
6
+ 'data-test-id'?: string;
6
7
  }
7
8
  export declare class CheckGroup extends React.PureComponent<IProps> {
8
9
  render(): JSX.Element;
@@ -54,7 +54,7 @@ var CheckGroup = /** @class */ (function (_super) {
54
54
  var classes = (0, classnames_1.default)('sd-check__group-new', (_a = {},
55
55
  _a["sd-check__group-new--vertical"] = this.props.orientation === 'vertical',
56
56
  _a));
57
- return (React.createElement("div", { className: classes, "aria-labelledby": this.props.groupLabelledBy }, this.props.children));
57
+ return (React.createElement("div", { className: classes, "aria-labelledby": this.props.groupLabelledBy, "data-test-id": this.props['data-test-id'] }, this.props.children));
58
58
  };
59
59
  return CheckGroup;
60
60
  }(React.PureComponent));
@@ -1,20 +1,20 @@
1
- import * as React from 'react';
2
- interface IProps {
1
+ import * as React from "react";
2
+ import { InputWrapper } from "./Form";
3
+ import { IInputWrapper } from "./Form/InputWrapper";
4
+ interface IProps extends IInputWrapper {
3
5
  value: Date | null;
4
- label: {
5
- text: string;
6
- hidden?: boolean;
7
- };
8
6
  dateFormat: string;
9
7
  onChange: (value: Date | null) => void;
10
8
  preview?: boolean;
11
9
  fullWidth?: boolean;
12
10
  allowSeconds?: boolean;
13
11
  required?: boolean;
14
- width?: React.CSSProperties['width'];
15
12
  disabled?: boolean;
13
+ ref?: React.LegacyRef<InputWrapper>;
14
+ 'data-test-id'?: string;
16
15
  }
17
16
  export declare class DateTimePicker extends React.PureComponent<IProps> {
17
+ private htmlId;
18
18
  handleTimeChange: (time: string) => void;
19
19
  handleDateChange: (date: Date | null) => void;
20
20
  prepareFormat(unitOfTime: number): string;
@@ -37,6 +37,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  __setModuleDefault(result, mod);
38
38
  return result;
39
39
  };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
40
43
  Object.defineProperty(exports, "__esModule", { value: true });
41
44
  exports.DateTimePicker = void 0;
42
45
  var React = __importStar(require("react"));
@@ -45,13 +48,17 @@ var common_1 = require("@superdesk/common");
45
48
  var lodash_1 = require("lodash");
46
49
  var TimePicker_1 = require("./TimePicker");
47
50
  var IconButton_1 = require("./IconButton");
48
- var MIN_WIDTH = 348;
51
+ var Form_1 = require("./Form");
52
+ var react_id_generator_1 = __importDefault(require("react-id-generator"));
49
53
  var DateTimePicker = /** @class */ (function (_super) {
50
54
  __extends(DateTimePicker, _super);
51
55
  function DateTimePicker() {
52
56
  var _this = _super !== null && _super.apply(this, arguments) || this;
57
+ _this.htmlId = (0, react_id_generator_1.default)();
53
58
  _this.handleTimeChange = function (time) {
54
- var _a = time.split(':').map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _a[0], minutes = _a[1]; // handle NaN value
59
+ var _a = time
60
+ .split(":")
61
+ .map(function (x) { return (0, lodash_1.defaultTo)(parseInt(x, 10), 0); }), hours = _a[0], minutes = _a[1]; // handle NaN value
55
62
  var origDate = _this.props.value ? new Date(_this.props.value) : new Date();
56
63
  origDate.setHours(hours, minutes);
57
64
  _this.props.onChange(origDate);
@@ -70,27 +77,26 @@ var DateTimePicker = /** @class */ (function (_super) {
70
77
  return _this;
71
78
  }
72
79
  DateTimePicker.prototype.prepareFormat = function (unitOfTime) {
73
- return unitOfTime.toString().padStart(2, '0');
80
+ return unitOfTime.toString().padStart(2, "0");
74
81
  };
75
82
  DateTimePicker.prototype.render = function () {
76
83
  var _this = this;
77
- var _a, _b;
78
84
  var convertedTimeValue = this.props.value != null
79
85
  ? "".concat(this.prepareFormat(this.props.value.getHours()), ":").concat(this.prepareFormat(this.props.value.getMinutes()))
80
- : '';
81
- return (React.createElement("div", { style: { width: this.props.width ? this.props.width : MIN_WIDTH } },
82
- React.createElement(common_1.Spacer, { h: true, gap: "8", alignItems: 'end', noWrap: true },
86
+ : "";
87
+ return (React.createElement(Form_1.InputWrapper, { label: this.props.label, error: this.props.error, invalid: this.props.error != null, required: this.props.required, disabled: this.props.disabled, info: this.props.info, inlineLabel: this.props.inlineLabel, labelHidden: this.props.labelHidden, htmlId: this.htmlId, tabindex: this.props.tabindex, fullWidth: this.props.fullWidth, "data-test-id": this.props["data-test-id"], ref: this.props.ref },
88
+ React.createElement(common_1.Spacer, { h: true, gap: "8", alignItems: "end", noWrap: true },
83
89
  React.createElement("div", { style: { flexGrow: 1 } },
84
90
  React.createElement(DatePicker_1.DatePicker, { disabled: this.props.disabled, preview: this.props.preview, required: this.props.required, hideClearButton: true, value: this.props.value, onChange: function (val) {
85
91
  _this.handleDateChange(val);
86
- }, dateFormat: this.props.dateFormat, label: this.props.label.text, inlineLabel: (_a = this.props.label.hidden) !== null && _a !== void 0 ? _a : false, labelHidden: (_b = this.props.label.hidden) !== null && _b !== void 0 ? _b : false, fullWidth: this.props.fullWidth })),
92
+ }, dateFormat: this.props.dateFormat, inlineLabel: true, labelHidden: true, fullWidth: this.props.fullWidth })),
87
93
  React.createElement("div", { style: { flexGrow: 1 } },
88
94
  React.createElement(TimePicker_1.TimePicker, { disabled: this.props.disabled, preview: this.props.preview, value: convertedTimeValue, onChange: function (val) {
89
95
  _this.handleTimeChange(val);
90
96
  }, inlineLabel: true, labelHidden: true, allowSeconds: this.props.allowSeconds, fullWidth: this.props.fullWidth, required: this.props.required })),
91
- this.props.preview !== true && (React.createElement(IconButton_1.IconButton, { disabled: this.props.disabled, icon: 'remove-sign', onClick: function () {
97
+ this.props.preview !== true && (React.createElement(IconButton_1.IconButton, { disabled: this.props.disabled, icon: "remove-sign", onClick: function () {
92
98
  _this.props.onChange(null);
93
- }, ariaValue: 'Clear' })))));
99
+ }, ariaValue: "Clear" })))));
94
100
  };
95
101
  return DateTimePicker;
96
102
  }(React.PureComponent));
@@ -9,6 +9,7 @@ interface IProps {
9
9
  noTransform?: boolean;
10
10
  hexColor?: string;
11
11
  style?: 'filled' | 'hollow' | 'translucent';
12
+ 'data-test-id'?: string;
12
13
  }
13
14
  export declare class Label extends React.PureComponent<IProps> {
14
15
  render(): JSX.Element;
@@ -62,26 +62,26 @@ var Label = /** @class */ (function (_super) {
62
62
  _a));
63
63
  if (this.props.link || this.props.onClick) {
64
64
  if (this.props.style === 'hollow') {
65
- return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { color: this.props.hexColor, borderColor: this.props.hexColor } }, this.props.text));
65
+ return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { color: this.props.hexColor, borderColor: this.props.hexColor }, "data-test-id": this.props['data-test-id'] }, this.props.text));
66
66
  }
67
67
  else if (this.props.style === 'translucent') {
68
- return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { color: this.props.hexColor, backgroundColor: "".concat(this.props.hexColor, "33") } }, this.props.text));
68
+ return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { color: this.props.hexColor, backgroundColor: "".concat(this.props.hexColor, "33") }, "data-test-id": this.props['data-test-id'] }, this.props.text));
69
69
  }
70
70
  else {
71
- return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { backgroundColor: this.props.hexColor } }, this.props.text));
71
+ return (React.createElement("a", { className: classes, href: this.props.link, onClick: this.props.onClick, style: { backgroundColor: this.props.hexColor }, "data-test-id": this.props['data-test-id'] }, this.props.text));
72
72
  }
73
73
  }
74
74
  else {
75
75
  if (this.props.style === 'hollow') {
76
- return (React.createElement("span", { className: classes, style: { color: this.props.hexColor, borderColor: this.props.hexColor } }, this.props.text));
76
+ return (React.createElement("span", { className: classes, style: { color: this.props.hexColor, borderColor: this.props.hexColor }, "data-test-id": this.props['data-test-id'] }, this.props.text));
77
77
  }
78
78
  else if (this.props.style === 'translucent') {
79
- return (React.createElement("span", { className: classes, style: { color: this.props.hexColor, backgroundColor: "".concat(this.props.hexColor, "33") } }, this.props.text));
79
+ return (React.createElement("span", { className: classes, style: { color: this.props.hexColor, backgroundColor: "".concat(this.props.hexColor, "33") }, "data-test-id": this.props['data-test-id'] }, this.props.text));
80
80
  }
81
81
  else {
82
82
  return (React.createElement("span", { className: classes, style: this.props.hexColor
83
83
  ? { backgroundColor: this.props.hexColor, color: (0, helpers_1.getTextColor)(this.props.hexColor) }
84
- : undefined }, this.props.text));
84
+ : undefined, "data-test-id": this.props['data-test-id'] }, this.props.text));
85
85
  }
86
86
  }
87
87
  };
@@ -13,7 +13,7 @@ interface IProps {
13
13
  maximizable?: boolean;
14
14
  headerTemplate?: JSX.Element | string;
15
15
  footerTemplate?: JSX.Element | string;
16
- ['data-test-id']?: string;
16
+ 'data-test-id'?: string;
17
17
  onShow?(): void;
18
18
  onHide?(): void;
19
19
  }
@@ -64,8 +64,8 @@ var Modal = /** @class */ (function (_super) {
64
64
  _a['p-dialog-content--padding-small'] = this.props.contentPadding === undefined,
65
65
  _a["p-dialog-content--padding-".concat(this.props.contentPadding)] = this.props.contentPadding,
66
66
  _a), this.props.className);
67
- return (React.createElement("div", { style: { display: 'content' }, "data-theme": this.props.theme !== 'dark' ? null : 'dark-ui', "data-test-id": this.props['data-test-id'] },
68
- React.createElement(dialog_1.Dialog, { id: this.props.id, visible: this.props.visible, header: this.props.headerTemplate, footer: this.props.footerTemplate, closeOnEscape: this.props.closeOnEscape, maximized: this.props.maximized, maximizable: this.props.maximizable, contentClassName: classes, onShow: this.props.onShow, onHide: (_b = this.props.onHide) !== null && _b !== void 0 ? _b : lodash_1.noop, zIndex: this.zIndex, position: this.props.position, closable: this.props.onHide != null ? true : false }, this.props.children)));
67
+ return (React.createElement("div", { style: { display: 'content' }, "data-theme": this.props.theme !== 'dark' ? null : 'dark-ui' },
68
+ React.createElement(dialog_1.Dialog, { id: this.props.id, visible: this.props.visible, header: this.props.headerTemplate, footer: this.props.footerTemplate, closeOnEscape: this.props.closeOnEscape, maximized: this.props.maximized, maximizable: this.props.maximizable, contentClassName: classes, onShow: this.props.onShow, onHide: (_b = this.props.onHide) !== null && _b !== void 0 ? _b : lodash_1.noop, zIndex: this.zIndex, position: this.props.position, closable: this.props.onHide != null ? true : false, "data-test-id": this.props['data-test-id'] }, this.props.children)));
69
69
  };
70
70
  return Modal;
71
71
  }(React.Component));
@@ -80,7 +80,7 @@ var RadioButtonGroup = /** @class */ (function (_super) {
80
80
  !((_j = this.props.group) === null || _j === void 0 ? void 0 : _j.groupLabel) ?
81
81
  React.createElement("div", { role: "radiogroup", className: classes, "aria-labelledby": (_k = this.props.group) === null || _k === void 0 ? void 0 : _k.groupLabelledBy, "data-test-id": this.props['data-test-id'], "data-test-value": selectedOption == null ? undefined : selectedOption.label }, this.props.options.map(function (item, index) { return (React.createElement("span", { className: "sd-check-button sd-check-button--native", key: index, tabIndex: _this.props.tabindex === undefined ? undefined : -1 },
82
82
  React.createElement("input", { type: "radio", className: "sd-check-button__input", id: _this.htmlId + index, tabIndex: _this.props.tabindex, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: _this.props.disabled || item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
83
- React.createElement("label", { className: "sd-check-button__text-label", htmlFor: _this.htmlId + index, "aria-label": item.labelHidden ? item.label : undefined, "data-test-id": "item" },
83
+ React.createElement("label", { className: "sd-check-button__text-label", htmlFor: _this.htmlId + index, "aria-label": item.labelHidden ? item.label : undefined, "data-test-id": "item", "data-test-value": item.label },
84
84
  item.icon ? React.createElement("i", { className: "icon-".concat(item.icon), "aria-hidden": "true" }) : null,
85
85
  !item.labelHidden || !item.icon ?
86
86
  React.createElement("span", { className: "sd-check-button__text-label-inner" }, item.label) : null))); }))
@@ -88,7 +88,7 @@ var TreeSelectItem = /** @class */ (function (_super) {
88
88
  ? this.props.optionTemplate(this.props.option.value)
89
89
  : this.props.getLabel(this.props.option.value)),
90
90
  this.props.option.children
91
- && React.createElement("span", { className: "suggestion-item__icon", "aria-hidden": "true" },
91
+ && React.createElement("span", { className: "suggestion-item__icon", "aria-hidden": "true", "data-test-id": "children-indicator" },
92
92
  React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
93
93
  };
94
94
  return TreeSelectItem;