@hipay/hipay-material-ui 3.7.4 → 3.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,10 @@ var _HiLoader = _interopRequireDefault(require("../HiLoader"));
39
39
 
40
40
  var _helpers = require("../utils/helpers");
41
41
 
42
+ var _ArrowDropDown = _interopRequireDefault(require("@material-ui/icons/ArrowDropDown"));
43
+
44
+ var _ArrowRight = _interopRequireDefault(require("@material-ui/icons/ArrowRight"));
45
+
42
46
  var useItemLabelStyles = (0, _styles.makeStyles)(function (theme) {
43
47
  return {
44
48
  label: {
@@ -57,7 +61,8 @@ function ItemLabel(props) {
57
61
  var color = props.color,
58
62
  label = props.label,
59
63
  labelHighlight = props.labelHighlight,
60
- selected = props.selected;
64
+ selected = props.selected,
65
+ title = props.title;
61
66
  var classes = useItemLabelStyles(props);
62
67
 
63
68
  if (labelHighlight) {
@@ -90,7 +95,7 @@ function ItemLabel(props) {
90
95
 
91
96
  return /*#__PURE__*/_react.default.createElement("div", {
92
97
  className: classes.label,
93
- title: label
98
+ title: title || label
94
99
  }, label);
95
100
  }
96
101
 
@@ -123,16 +128,20 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
123
128
  }
124
129
  },
125
130
  '&:focus': {
126
- '&:not($disabled):not($pinned)': {
131
+ '&:not($disabled):not($pinned):not($collapseHeader)': {
127
132
  backgroundColor: theme.palette.action.hover
128
133
  },
129
134
  outline: 'none'
135
+ },
136
+ '&$collapseHeader': {
137
+ minHeight: 32,
138
+ lineHeight: "32px"
130
139
  }
131
140
  },
132
141
  listItemWithoutSecondaryInline: {},
133
142
  listItemInlineWithInfoWithoutSecondary: {},
134
143
  listItemHover: {
135
- '&:hover:not($disabled):not($pinned)': {
144
+ '&:hover:not($disabled):not($pinned):not($collapseHeader)': {
136
145
  backgroundColor: theme.palette.action.hover,
137
146
  fontWeight: theme.typography.fontWeightMedium
138
147
  }
@@ -154,6 +163,11 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
154
163
  display: 'inherit',
155
164
  backgroundColor: theme.palette.background3
156
165
  },
166
+ collapseHeader: {
167
+ zIndex: 1,
168
+ display: 'inherit',
169
+ backgroundColor: theme.palette.background3
170
+ },
157
171
  thin: {
158
172
  fontWeight: theme.typography.fontWeightLight
159
173
  },
@@ -241,7 +255,12 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
241
255
  },
242
256
  infosInlineWithoutSecondary: {},
243
257
  infosWithSecondaryInline: {},
244
- infosWithoutSecondaryInline: {}
258
+ infosWithoutSecondaryInline: {},
259
+ rightIcon: {
260
+ position: "absolute",
261
+ right: 12,
262
+ top: 8
263
+ }
245
264
  };
246
265
  });
247
266
  /**
@@ -251,6 +270,10 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
251
270
 
252
271
  exports.useStyles = useStyles;
253
272
 
273
+ var _ref = /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, null);
274
+
275
+ var _ref2 = /*#__PURE__*/_react.default.createElement(_ArrowRight.default, null);
276
+
254
277
  function HiSelectableListItem(props) {
255
278
  var _classNames, _classNames3, _classNames4;
256
279
 
@@ -273,22 +296,27 @@ function HiSelectableListItem(props) {
273
296
  labelHighlight = props.labelHighlight,
274
297
  paddingLeft = props.paddingLeft,
275
298
  pinned = props.pinned,
299
+ collapseHeader = props.collapseHeader,
276
300
  secondaryInline = props.secondaryInline,
277
301
  secondaryLabel = props.secondaryLabel,
278
302
  thin = props.thin,
303
+ title = props.title,
279
304
  type = props.type,
280
305
  color = props.color,
281
- item = props.item;
306
+ item = props.item,
307
+ opened = props.opened,
308
+ group = props.group;
282
309
  var classes = useStyles(props);
283
310
  var ref = (0, _react.useRef)(null);
284
311
  var isHovering = !!hoverIcon ? (0, _reactUse.useHoverDirty)(ref) : false;
285
- var onKeyDown = (0, _react.useCallback)(function (_ref) {
286
- var code = _ref.code;
287
-
288
- if (code === 'Space' || code === 'Enter') {
312
+ var onKeyDown = (0, _react.useCallback)(function (event) {
313
+ if (event.code === 'Space' || event.code === 'Enter') {
289
314
  event.preventDefault();
290
315
  event.stopPropagation();
291
- if (item) onSelect(null, item);
316
+
317
+ if (item) {
318
+ onSelect(event, item);
319
+ }
292
320
  }
293
321
  }, [item]);
294
322
  (0, _reactUse.useEvent)('keydown', onKeyDown, ref.current); // Return simple loader list item
@@ -309,7 +337,7 @@ function HiSelectableListItem(props) {
309
337
  displayedIcon = icon;
310
338
  }
311
339
 
312
- var ListItemComponentName = pinned ? _ListSubheader.default : _ListItem.default;
340
+ var ListItemComponentName = pinned || collapseHeader ? _ListSubheader.default : _ListItem.default;
313
341
  var itemIcon;
314
342
 
315
343
  if (displayedIcon) {
@@ -336,14 +364,15 @@ function HiSelectableListItem(props) {
336
364
  classes: {
337
365
  root: classes.root
338
366
  },
339
- className: (0, _classnames.default)(classes.listItem, classes.listItemHover, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.disabled, disabled), (0, _defineProperty2.default)(_classNames, classes.selected, selected), (0, _defineProperty2.default)(_classNames, classes.thin, thin), (0, _defineProperty2.default)(_classNames, classes.pinned, pinned), (0, _defineProperty2.default)(_classNames, classes.inline, secondaryInline), (0, _defineProperty2.default)(_classNames, classes.listItemWithoutSecondaryInline, !secondaryInline), (0, _defineProperty2.default)(_classNames, classes.listItemInlineWithInfoWithoutSecondary, secondaryInline && info && !secondaryLabel), _classNames)),
367
+ className: (0, _classnames.default)(classes.listItem, classes.listItemHover, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.disabled, disabled), (0, _defineProperty2.default)(_classNames, classes.selected, selected), (0, _defineProperty2.default)(_classNames, classes.thin, thin), (0, _defineProperty2.default)(_classNames, classes.pinned, pinned), (0, _defineProperty2.default)(_classNames, classes.collapseHeader, collapseHeader), (0, _defineProperty2.default)(_classNames, classes.inline, secondaryInline), (0, _defineProperty2.default)(_classNames, classes.listItemWithoutSecondaryInline, !secondaryInline), (0, _defineProperty2.default)(_classNames, classes.listItemInlineWithInfoWithoutSecondary, secondaryInline && typeof info !== "undefined" && !secondaryLabel), _classNames)),
340
368
  disabled: disabled,
341
369
  onClick: !disabled ? onSelect : undefined,
342
370
  style: {
343
371
  paddingLeft: "".concat(paddingLeft + level * 32, "px")
344
- }
372
+ },
373
+ "data-group": group
345
374
  }, /*#__PURE__*/_react.default.createElement("div", {
346
- className: (0, _classnames.default)(classes.labelContent, (0, _defineProperty2.default)({}, classes.labelWithoutSecondaryInline, !secondaryInline || !secondaryLabel && !info))
375
+ className: (0, _classnames.default)(classes.labelContent, (0, _defineProperty2.default)({}, classes.labelWithoutSecondaryInline, !secondaryInline || !secondaryLabel && typeof info === "undefined"))
347
376
  }, !hideCheckbox && !pinned && /*#__PURE__*/_react.default.createElement(_HiCheckbox.default, {
348
377
  tabIndex: 0,
349
378
  classes: {
@@ -374,12 +403,15 @@ function HiSelectableListItem(props) {
374
403
  color: color,
375
404
  label: label,
376
405
  labelHighlight: labelHighlight,
377
- selected: selected
378
- }))), /*#__PURE__*/_react.default.createElement("div", {
406
+ selected: selected,
407
+ title: title
408
+ }), collapseHeader && /*#__PURE__*/_react.default.createElement("span", {
409
+ className: classes.rightIcon
410
+ }, opened ? _ref : _ref2))), /*#__PURE__*/_react.default.createElement("div", {
379
411
  className: (0, _classnames.default)(classes.infosContent, (_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, classes.infosWithoutSecondaryInline, !secondaryInline), (0, _defineProperty2.default)(_classNames4, classes.infosWithSecondaryInline, !secondaryInline), (0, _defineProperty2.default)(_classNames4, classes.infosInlineWithoutSecondary, secondaryInline && !secondaryLabel), _classNames4))
380
412
  }, !!secondaryLabel && /*#__PURE__*/_react.default.createElement("div", {
381
413
  className: (0, _classnames.default)(classes.secondaryLabel, (0, _defineProperty2.default)({}, classes.inline, secondaryInline))
382
- }, secondaryLabel), !!info && /*#__PURE__*/_react.default.createElement("span", {
414
+ }, secondaryLabel), typeof info !== "undefined" && /*#__PURE__*/_react.default.createElement("span", {
383
415
  className: (0, _classnames.default)(classes.info)
384
416
  }, info)));
385
417
  }
@@ -396,7 +428,8 @@ HiSelectableListItem.defaultProps = {
396
428
  pinned: false,
397
429
  secondaryInline: true,
398
430
  selected: false,
399
- thin: false
431
+ thin: false,
432
+ opened: false
400
433
  };
401
434
  var _default = HiSelectableListItem;
402
435
  exports.default = _default;
@@ -21,6 +21,8 @@ var _SwitchBase = _interopRequireDefault(require("@material-ui/core/internal/Swi
21
21
 
22
22
  var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
23
23
 
24
+ var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
25
+
24
26
  var _helpers = require("../utils/helpers");
25
27
 
26
28
  var _styles = require("@material-ui/core/styles");
@@ -83,6 +85,9 @@ var styles = function styles(theme) {
83
85
  opacity: theme.palette.type === 'light' ? 0.12 : 0.1
84
86
  }
85
87
  },
88
+ iconNotChecked: {
89
+ color: "#CBCBCB"
90
+ },
86
91
  iconChecked: {},
87
92
  iconCheckedPrimary: {
88
93
  backgroundColor: theme.palette.primary.main,
@@ -165,9 +170,13 @@ function HiSwitch(props) {
165
170
  disabled = props.disabled,
166
171
  other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "checked", "color", "disabled"]);
167
172
  var isHiColor = ['primary', 'secondary', 'positive', 'negative', 'middle', 'neutral'].includes(color);
168
- var iconClass = (0, _classnames.default)(classes.icon, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.iconChecked, checked), (0, _defineProperty2.default)(_classNames, classes.iconCheckedNeutral, !disabled && checked && !isHiColor), (0, _defineProperty2.default)(_classNames, classes["iconChecked".concat((0, _helpers.capitalize)(color))], !disabled && checked && isHiColor), (0, _defineProperty2.default)(_classNames, classes.iconDisabled, disabled), _classNames));
173
+ var iconClass = (0, _classnames.default)(classes.icon, (_classNames = {}, (0, _defineProperty2.default)(_classNames, classes.iconNotChecked, !checked), (0, _defineProperty2.default)(_classNames, classes.iconChecked, checked), (0, _defineProperty2.default)(_classNames, classes.iconCheckedNeutral, !disabled && checked && !isHiColor), (0, _defineProperty2.default)(_classNames, classes["iconChecked".concat((0, _helpers.capitalize)(color))], !disabled && checked && isHiColor), (0, _defineProperty2.default)(_classNames, classes.iconDisabled, disabled), _classNames));
174
+
175
+ var icon = /*#__PURE__*/_react.default.createElement(_Close.default, {
176
+ className: iconClass
177
+ });
169
178
 
170
- var icon = /*#__PURE__*/_react.default.createElement(_Check.default, {
179
+ var checkedIcon = /*#__PURE__*/_react.default.createElement(_Check.default, {
171
180
  className: iconClass
172
181
  });
173
182
 
@@ -181,7 +190,7 @@ function HiSwitch(props) {
181
190
  checked: isHiColor && !disabled ? classes["checked".concat((0, _helpers.capitalize)(color))] : classes.checkedNeutral,
182
191
  disabled: classes.disabled
183
192
  },
184
- checkedIcon: icon,
193
+ checkedIcon: checkedIcon,
185
194
  checked: checked,
186
195
  disabled: disabled,
187
196
  inputProps: {
@@ -163,6 +163,7 @@ var HiCellBuilder = /*#__PURE__*/function (_React$PureComponent) {
163
163
  });
164
164
 
165
165
  case cst.TYPE_DATE:
166
+ case cst.TYPE_MONTH:
166
167
  return /*#__PURE__*/_react.default.createElement(_CellDate.default, {
167
168
  date: datacell.date,
168
169
  displayTime: datacell.displayTime,
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.ALIGN_RIGHT_TYPES = exports.DEFAULT_PADDING = exports.DEFAULT_VIEWS = exports.DEFAULT_WIDTHS = exports.FRAUD_RESULT_ASK_AUTHENTICATE = exports.FRAUD_RESULT_FORCE_AUTHENTICATE = exports.FRAUD_RESULT_PENDING = exports.FRAUD_RESULT_CHALLENGED = exports.FRAUD_RESULT_BLOCKED = exports.FRAUD_RESULT_ACCEPTED = exports.ELLIPSIS_RIGHT = exports.ELLIPSIS_NAME = exports.ELLIPSIS_MIDDLE = exports.ELLIPSIS_LEFT = exports.ELLIPSIS_AFTER_FIRST_WORD = exports.NO_EVOLUTION = exports.EVOLUTION_DOWN = exports.EVOLUTION_UP = exports.VIEWS = exports.TYPE_PIN_TO_ACTION = exports.TYPE_THIRD_PARTY_SECURITY = exports.TYPE_TEXT = exports.TYPE_COUNTRY = exports.TYPE_STATUS = exports.TYPE_SCORE = exports.TYPE_SENTINEL = exports.TYPE_RATE = exports.TYPE_NUMERIC = exports.TYPE_IMAGE = exports.TYPE_ICON = exports.TYPE_DATE = exports.TYPE_CHECKBOX = exports.TYPE_ADDRESS = exports.TYPE_CUSTOMER_ACCOUNT_NUMBER = exports.TYPE_AMOUNT = exports.TYPE_ACCOUNT_NUMBER = exports.TYPE_ACCOUNT = exports.CELL_HEADER_HEIGHT_DENSE = exports.CELL_HEADER_HEIGHT = exports.CELL_HEIGHT_DENSE = exports.CELL_HEIGHT = exports.NB_ROWS_BACK_TO_TOP = exports.MAX_ROWS = void 0;
8
+ exports.ALIGN_RIGHT_TYPES = exports.DEFAULT_PADDING = exports.DEFAULT_VIEWS = exports.DEFAULT_WIDTHS = exports.FRAUD_RESULT_ASK_AUTHENTICATE = exports.FRAUD_RESULT_FORCE_AUTHENTICATE = exports.FRAUD_RESULT_PENDING = exports.FRAUD_RESULT_CHALLENGED = exports.FRAUD_RESULT_BLOCKED = exports.FRAUD_RESULT_ACCEPTED = exports.ELLIPSIS_RIGHT = exports.ELLIPSIS_NAME = exports.ELLIPSIS_MIDDLE = exports.ELLIPSIS_LEFT = exports.ELLIPSIS_AFTER_FIRST_WORD = exports.NO_EVOLUTION = exports.EVOLUTION_DOWN = exports.EVOLUTION_UP = exports.VIEWS = exports.TYPE_PIN_TO_ACTION = exports.TYPE_THIRD_PARTY_SECURITY = exports.TYPE_TEXT = exports.TYPE_COUNTRY = exports.TYPE_STATUS = exports.TYPE_SCORE = exports.TYPE_SENTINEL = exports.TYPE_RATE = exports.TYPE_NUMERIC = exports.TYPE_MONTH = exports.TYPE_IMAGE = exports.TYPE_ICON = exports.TYPE_DATE = exports.TYPE_CHECKBOX = exports.TYPE_ADDRESS = exports.TYPE_CUSTOMER_ACCOUNT_NUMBER = exports.TYPE_AMOUNT = exports.TYPE_ACCOUNT_NUMBER = exports.TYPE_ACCOUNT = exports.CELL_HEADER_HEIGHT_DENSE = exports.CELL_HEADER_HEIGHT = exports.CELL_HEIGHT_DENSE = exports.CELL_HEIGHT = exports.NB_ROWS_BACK_TO_TOP = exports.MAX_ROWS = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
11
11
 
@@ -53,6 +53,8 @@ var TYPE_ICON = 'icon';
53
53
  exports.TYPE_ICON = TYPE_ICON;
54
54
  var TYPE_IMAGE = 'image';
55
55
  exports.TYPE_IMAGE = TYPE_IMAGE;
56
+ var TYPE_MONTH = 'month';
57
+ exports.TYPE_MONTH = TYPE_MONTH;
56
58
  var TYPE_NUMERIC = 'numeric';
57
59
  exports.TYPE_NUMERIC = TYPE_NUMERIC;
58
60
  var TYPE_RATE = 'rate';
package/README.md CHANGED
@@ -203,27 +203,7 @@ prettier --write src/HiForm/HiInput.js
203
203
  ## Publish
204
204
  Le projet est publié sur un repo privé npm : https://www.npmjs.com/package/@hipay/hipay-material-ui
205
205
 
206
- #### Publier une nouvelle version
207
-
208
- Avoir installé [conventional-changelog-cli](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-cli) pour générer le CHANGELOG à partir des commits git.
209
- ```sh
210
- npm install -g conventional-changelog-cli
211
- npm install -g cz-conventional-changelog
212
- ```
213
-
214
- 1. Changer la version dans package.json et dans packages/hipay-material-ui/package.json
215
- 2. Générer le fichier HI-CHANGELOG.md : ```npm run changelog```
216
- 3. Commiter la release : ```git ci -am "chore(release): VERSION DATE (YYYY-mm-dd)```
217
- 4. Build : ```cd packages/hipay-material-ui/ && npm run build```
218
- 5. Publish :
219
-
220
- ```sh
221
- cd build
222
- npm login
223
- # Username: hipay
224
- # Password: (voir avec la tribu PSYCHE)
225
- npm publish
226
- ```
206
+ Un script de déploiement automatique est disponible dans gitlab CI.
227
207
 
228
208
  #### [Semantic Versioning](https://semver.org/)
229
209
 
@@ -263,7 +263,8 @@ var HiDatePicker = /*#__PURE__*/function (_React$Component) {
263
263
  translations = _this$props.translations,
264
264
  value = _this$props.value,
265
265
  hideOnDayClick = _this$props.hideOnDayClick,
266
- props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "format", "locale", "minimumDate", "onReset", "translations", "value", "hideOnDayClick"]);
266
+ HiInputProps = _this$props.HiInputProps,
267
+ props = (0, _objectWithoutProperties2.default)(_this$props, ["classes", "disabledDays", "disablePastDays", "disableFutureDays", "enableTime", "format", "locale", "minimumDate", "onReset", "translations", "value", "hideOnDayClick", "HiInputProps"]);
267
268
  var currentMonth = this.state.currentMonth;
268
269
  var today = (0, _momentTimezone.default)();
269
270
  var effectiveDisabledDays = (0, _objectSpread2.default)({}, disablePastDays && {
@@ -312,6 +313,11 @@ var HiDatePicker = /*#__PURE__*/function (_React$Component) {
312
313
  onSubmit: this.props.onSubmit
313
314
  }
314
315
  });
316
+
317
+ if (typeof HiInputProps !== "undefined") {
318
+ inputProps.HiInputProps = (0, _objectSpread2.default)({}, inputProps.HiInputProps, {}, HiInputProps);
319
+ }
320
+
315
321
  return /*#__PURE__*/_react.default.createElement("div", {
316
322
  className: classes.root,
317
323
  onKeyDown: this.handleKeyDown()
@@ -48,6 +48,8 @@ var _Calendar = _interopRequireDefault(require("mdi-material-ui/Calendar"));
48
48
 
49
49
  var _CalendarBlank = _interopRequireDefault(require("mdi-material-ui/CalendarBlank"));
50
50
 
51
+ var _CalendarArrowRight = _interopRequireDefault(require("mdi-material-ui/CalendarArrowRight"));
52
+
51
53
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
52
54
 
53
55
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
@@ -104,12 +106,23 @@ function buildDateRangeInfo(t, from, to, format) {
104
106
  prefix = _options$prefix === void 0 ? null : _options$prefix,
105
107
  _options$toNow = options.toNow,
106
108
  toNow = _options$toNow === void 0 ? false : _options$toNow,
109
+ _options$toToday = options.toToday,
110
+ toToday = _options$toToday === void 0 ? false : _options$toToday,
107
111
  _options$displayDays = options.displayDays,
108
- displayDays = _options$displayDays === void 0 ? true : _options$displayDays; // From
112
+ displayDays = _options$displayDays === void 0 ? true : _options$displayDays,
113
+ _options$displayDayNa = options.displayDayName,
114
+ displayDayName = _options$displayDayNa === void 0 ? false : _options$displayDayNa; // From
115
+
116
+ var info = "".concat(t.from, " ").concat(from.format(format), " "); // Display day name
117
+
118
+ if (displayDayName) {
119
+ info = "".concat(t.from, " ").concat(from.format('dddd'), " ").concat(from.format(format), " ");
120
+ } // To
109
121
 
110
- var info = "".concat(t.from, " ").concat(from.format(format), " "); // To
111
122
 
112
- if (toNow) {
123
+ if (toToday) {
124
+ info += "".concat(t.to_today);
125
+ } else if (toNow) {
113
126
  info += "".concat(t.to_now);
114
127
  } else {
115
128
  info += "".concat(t.to, " ").concat(to.format(format));
@@ -132,7 +145,7 @@ function buildDateRangeInfo(t, from, to, format) {
132
145
 
133
146
  if (displayDays) {
134
147
  var days = Math.ceil(to.diff(from, 'days', true));
135
- info = "".concat(days, " ").concat(t.days, ", ").concat(info);
148
+ info = "".concat(days, " ").concat(days === 1 ? t.day : t.days, ", ").concat(info);
136
149
  }
137
150
 
138
151
  return info;
@@ -143,6 +156,7 @@ function buildDateRangeOptionByKey(key, t, format) {
143
156
  var label;
144
157
  var info;
145
158
  var to;
159
+ var days;
146
160
 
147
161
  switch (key) {
148
162
  case 'custom':
@@ -203,7 +217,8 @@ function buildDateRangeOptionByKey(key, t, format) {
203
217
  label = t.previous_month;
204
218
  from = (0, _momentTimezone.default)().subtract(1, 'month').startOf('month');
205
219
  to = (0, _momentTimezone.default)().subtract(1, 'month').endOf('month');
206
- info = "".concat(from.daysInMonth(), " ").concat(t.days, ", ").concat(yearAndMonth(format, from));
220
+ days = from.daysInMonth();
221
+ info = "".concat(days, " ").concat(days === 1 ? t.day : t.days, ", ").concat(yearAndMonth(format, from));
207
222
  break;
208
223
 
209
224
  case 'cq':
@@ -239,18 +254,27 @@ function buildDateRangeOptionByKey(key, t, format) {
239
254
  });
240
255
  break;
241
256
 
242
- case 'yy':
243
- label = t.year_on_year;
244
- from = (0, _momentTimezone.default)().subtract(1, 'years');
257
+ case "1":
258
+ label = "24h";
259
+ from = (0, _momentTimezone.default)().subtract(1, 'day');
245
260
  to = (0, _momentTimezone.default)();
246
- info = buildDateRangeInfo(t, from, to, format, {
247
- prefix: null,
248
- toNow: true,
249
- displayDays: true
250
- });
261
+ info = "".concat(t.from, " ").concat(from.format("HH:mm"), " ").concat(t.yesterday.toLowerCase(), " ").concat(t.to_now);
251
262
  break;
252
263
 
253
264
  default:
265
+ if (parseInt(key) > 0) {
266
+ label = "".concat(key, " ").concat(key === 1 ? t.day : t.days);
267
+ from = (0, _momentTimezone.default)().subtract(parseInt(key), 'day');
268
+ to = (0, _momentTimezone.default)();
269
+ info = buildDateRangeInfo(t, from, to, format, {
270
+ prefix: null,
271
+ toNow: true,
272
+ toToday: key === 1,
273
+ displayDays: false,
274
+ displayDayName: true
275
+ });
276
+ }
277
+
254
278
  break;
255
279
  }
256
280
 
@@ -307,12 +331,15 @@ var styles = function styles(theme) {
307
331
  };
308
332
 
309
333
  exports.styles = styles;
310
- var PRESET_PERIOD_LIST = ['cd', 'pd', 'cw', 'pw', 'cm', 'pm', 'cq', 'pq', 'cy', 'yy'];
334
+ var PRESET_PERIOD_LIST = ['cd', 'pd', 'cw', 'pw', 'cm', 'pm', 'cq', 'pq', 'cy'];
335
+ var SLIDING_PERIOD_LIST = ['1', '7', '30', '365'];
311
336
  var CUSTOM_PERIOD_LIST = ['custom'];
312
337
 
313
338
  var _ref2 = /*#__PURE__*/_react.default.createElement(_Calendar.default, null);
314
339
 
315
- var _ref3 = /*#__PURE__*/_react.default.createElement(_CalendarBlank.default, null);
340
+ var _ref3 = /*#__PURE__*/_react.default.createElement(_CalendarArrowRight.default, null);
341
+
342
+ var _ref4 = /*#__PURE__*/_react.default.createElement(_CalendarBlank.default, null);
316
343
 
317
344
  var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
318
345
  (0, _inherits2.default)(HiDateRangeSelector, _React$Component);
@@ -395,8 +422,6 @@ var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
395
422
  }, {
396
423
  key: "buildOptions",
397
424
  value: function buildOptions() {
398
- var _this2 = this;
399
-
400
425
  var _this$props = this.props,
401
426
  availableOptionKeys = _this$props.availableOptionKeys,
402
427
  translations = _this$props.translations;
@@ -405,39 +430,49 @@ var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
405
430
  var presetOptionsAvailable = availableOptionKeys.filter(function (option) {
406
431
  return PRESET_PERIOD_LIST.includes(option);
407
432
  });
433
+ var slidingOptionsAvailable = availableOptionKeys.filter(function (option) {
434
+ return SLIDING_PERIOD_LIST.includes(option);
435
+ });
408
436
  var customOptionsAvailable = availableOptionKeys.filter(function (option) {
409
437
  return CUSTOM_PERIOD_LIST.includes(option);
410
438
  });
411
439
 
412
- if (presetOptionsAvailable) {
440
+ if (presetOptionsAvailable.length) {
413
441
  options.push({
414
442
  id: "preset_periods_subheader",
415
443
  type: PRESET_PERIOD_LIST.includes(selectedPreset) ? "primary-highlight" : "highlight",
416
- pinned: true,
417
444
  icon: _ref2,
418
445
  label: translations.preset_periods,
419
- selectable: false
446
+ children: this.options.filter(function (o) {
447
+ return presetOptionsAvailable.includes(o.id);
448
+ }),
449
+ collapseParent: true
420
450
  });
421
- presetOptionsAvailable.forEach(function (option) {
422
- options.push(_this2.options.find(function (_option) {
423
- return _option.id === option;
424
- }));
451
+ }
452
+
453
+ if (slidingOptionsAvailable.length) {
454
+ options.push({
455
+ id: "sliding_periods_subheader",
456
+ type: SLIDING_PERIOD_LIST.includes(selectedPreset) ? "primary-highlight" : "highlight",
457
+ icon: _ref3,
458
+ label: translations.sliding_periods,
459
+ children: this.options.filter(function (o) {
460
+ return slidingOptionsAvailable.includes(o.id);
461
+ }),
462
+ collapseParent: true
425
463
  });
426
464
  }
427
465
 
428
- if (customOptionsAvailable) {
466
+ if (customOptionsAvailable.length) {
429
467
  options.push({
430
468
  id: "custom_periods_subheader",
431
469
  type: CUSTOM_PERIOD_LIST.includes(selectedPreset) ? "primary-highlight" : "highlight",
432
- pinned: true,
433
- icon: _ref3,
470
+ icon: _ref4,
434
471
  label: translations.custom_periods,
435
- selectable: false
436
- });
437
- customOptionsAvailable.forEach(function (option) {
438
- options.push(_this2.options.find(function (_option) {
439
- return _option.id === option;
440
- }));
472
+ children: this.options.filter(function (o) {
473
+ return customOptionsAvailable.includes(o.id);
474
+ }),
475
+ collapseParent: true
441
476
  });
442
477
  }
443
478
 
@@ -446,7 +481,7 @@ var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
446
481
  }, {
447
482
  key: "render",
448
483
  value: function render() {
449
- var _this3 = this;
484
+ var _this2 = this;
450
485
 
451
486
  var _this$props2 = this.props,
452
487
  availableOptionKeys = _this$props2.availableOptionKeys,
@@ -477,7 +512,9 @@ var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
477
512
  var hiSelectableListProps = {
478
513
  secondaryInline: false,
479
514
  hideCheckbox: true,
480
- lazy: false
515
+ lazy: false,
516
+ collapseParent: true,
517
+ noPadding: true
481
518
  };
482
519
  var options = this.buildOptions();
483
520
  return /*#__PURE__*/_react.default.createElement(_HiFormControl.default, {
@@ -497,7 +534,7 @@ var HiDateRangeSelector = /*#__PURE__*/function (_React$Component) {
497
534
  flexDirection: 'column'
498
535
  } : {},
499
536
  ref: function ref(container) {
500
- _this3.container = container;
537
+ _this2.container = container;
501
538
  }
502
539
  }, /*#__PURE__*/_react.default.createElement("div", {
503
540
  className: classes.select,
@@ -584,12 +621,14 @@ HiDateRangeSelector.defaultProps = {
584
621
  yearAndMonth: 'YYYY[-]MM',
585
622
  yearAndQuarter: 'YYYY[-Q]Q',
586
623
  year: 'Year',
624
+ day: 'day',
587
625
  days: 'days',
588
626
  custom_period: 'Custom Period',
589
627
  yesterday: 'Yesterday',
590
628
  from: 'from',
591
629
  to: 'to',
592
630
  to_now: 'to now',
631
+ to_today: 'to today',
593
632
  current_week: 'Current Week',
594
633
  previous_week: 'Previous Week',
595
634
  current_month: 'Current Month',
@@ -606,7 +645,8 @@ HiDateRangeSelector.defaultProps = {
606
645
  missing_date_to: 'Missing date to',
607
646
  preset_periods: 'Preset periods',
608
647
  custom_periods: 'Custom periods',
609
- custom_period_info: "Select a custom period"
648
+ custom_period_info: "Select a custom period",
649
+ sliding_periods: 'Sliding periods'
610
650
  }
611
651
  };
612
652
 
@@ -52,7 +52,8 @@ var HiDialog = function HiDialog(props) {
52
52
  id = props.id,
53
53
  onClose = props.onClose,
54
54
  open = props.open,
55
- title = props.title;
55
+ title = props.title,
56
+ closeBtn = props.closeBtn;
56
57
  var classes = useStyles(props);
57
58
  var handleClose = (0, _react.useCallback)(function () {
58
59
  if (onClose) {
@@ -68,9 +69,9 @@ var HiDialog = function HiDialog(props) {
68
69
  open: open
69
70
  }, /*#__PURE__*/_react.default.createElement("div", {
70
71
  className: classes.header
71
- }, /*#__PURE__*/_react.default.createElement("p", {
72
+ }, typeof title === "string" ? /*#__PURE__*/_react.default.createElement("p", {
72
73
  className: classes.title
73
- }, title), /*#__PURE__*/_react.default.createElement("div", {
74
+ }, title) : title, closeBtn !== false && /*#__PURE__*/_react.default.createElement("div", {
74
75
  className: classes.closeDiv
75
76
  }, /*#__PURE__*/_react.default.createElement(_HiIconButton.default, {
76
77
  id: "close-dialog-btn",