@commercetools-uikit/calendar-utils 15.2.4 → 15.3.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.
@@ -22,11 +22,11 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
22
22
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
23
23
  require('prop-types');
24
24
  var react$1 = require('react');
25
- var react = require('@emotion/react');
26
25
  var icons = require('@commercetools-uikit/icons');
27
26
  var Inline = require('@commercetools-uikit/spacings-inline');
28
27
  var hooks = require('@commercetools-uikit/hooks');
29
28
  var AccessibleButton = require('@commercetools-uikit/accessible-button');
29
+ var react = require('@emotion/react');
30
30
  var designSystem = require('@commercetools-uikit/design-system');
31
31
  var inputUtils = require('@commercetools-uikit/input-utils');
32
32
  var jsxRuntime = require('@emotion/react/jsx-runtime');
@@ -188,118 +188,108 @@ var getExampleDateStrings = function getExampleDateStrings() {
188
188
  };
189
189
  };
190
190
 
191
- function ownKeys$3(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
192
-
193
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
194
-
195
191
  // NOTE: order is important here
196
192
  // * a disabled-field currently does not display warning/error-states so it takes precedence
197
193
  // * a readonly-field cannot be changed, but it might be relevant for validation, so error and warning are checked first
198
194
  // how you can interact with the field is controlled separately by the props, this only influences visuals
199
- var getClearSectionStyles = function getClearSectionStyles(theme) {
200
- var vars = _objectSpread$3(_objectSpread$3({}, designSystem.customProperties), theme);
201
-
202
- return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;display:flex;margin-right:", vars.spacingXs, ";cursor:pointer;transition:color ", vars.transitionStandard, ",border-color ", vars.transitionStandard, ";&:hover svg *{fill:", vars.colorWarning, ";}" + ("" ), "" );
195
+ var getClearSectionStyles = function getClearSectionStyles() {
196
+ return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;display:flex;margin-right:", designSystem.designTokens.spacingXs, ";cursor:pointer;transition:color ", designSystem.designTokens.transitionStandard, ",border-color ", designSystem.designTokens.transitionStandard, ";&:hover svg *{fill:", designSystem.designTokens.colorWarning, ";}" + ("" ), "" );
203
197
  };
204
198
 
205
- var getIconBorderColor = function getIconBorderColor(vars, props, state) {
199
+ var getIconBorderColor = function getIconBorderColor(props, state) {
206
200
  if (props.isDisabled) {
207
- return vars.borderColorForInputWhenDisabled;
201
+ return designSystem.designTokens.borderColorForInputWhenDisabled;
208
202
  }
209
203
 
210
204
  if (props.hasError) {
211
- return vars.borderColorForInputWhenError;
205
+ return designSystem.designTokens.borderColorForInputWhenError;
212
206
  }
213
207
 
214
208
  if (props.hasWarning) {
215
- return vars.borderColorForInputWhenWarning;
209
+ return designSystem.designTokens.borderColorForInputWhenWarning;
216
210
  }
217
211
 
218
212
  if (props.isReadOnly) {
219
- return vars.borderColorForInputWhenReadonly;
213
+ return designSystem.designTokens.borderColorForInputWhenReadonly;
220
214
  }
221
215
 
222
216
  if (props.isOpen || state.isFocused) {
223
- return vars.borderColorForInputWhenFocused;
217
+ return designSystem.designTokens.borderColorForInputWhenFocused;
224
218
  }
225
219
 
226
- return vars.borderColorForInput;
220
+ return designSystem.designTokens.borderColorForInput;
227
221
  };
228
222
 
229
- var getIconFontColor = function getIconFontColor(vars, props) {
223
+ var getIconFontColor = function getIconFontColor(props) {
230
224
  if (props.isDisabled) {
231
- return vars.fontColorForInputWhenDisabled;
225
+ return designSystem.designTokens.fontColorForInputWhenDisabled;
232
226
  }
233
227
 
234
228
  if (props.hasError) {
235
- return vars.fontColorForInputWhenError;
229
+ return designSystem.designTokens.fontColorForInputWhenError;
236
230
  }
237
231
 
238
232
  if (props.hasWarning) {
239
- return vars.fontColorForInputWhenWarning;
233
+ return designSystem.designTokens.fontColorForInputWhenWarning;
240
234
  }
241
235
 
242
236
  if (props.isReadOnly) {
243
- return vars.fontColorForInputWhenReadonly;
237
+ return designSystem.designTokens.fontColorForInputWhenReadonly;
244
238
  }
245
239
 
246
240
  return 'initial';
247
241
  };
248
242
 
249
- var getCalendarIconContainerStyles = function getCalendarIconContainerStyles(props, state, theme) {
250
- var vars = _objectSpread$3(_objectSpread$3({}, designSystem.customProperties), theme);
251
-
252
- return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;background:none;border:0;border-left:1px solid ", vars.borderColorForInput, ";border-top-right-radius:", vars.borderRadiusForInput, ";border-bottom-right-radius:", vars.borderRadiusForInput, ";border-color:", getIconBorderColor(vars, props, state), ";color:", getIconFontColor(vars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";height:100%;display:flex;padding:", vars.spacingXs, ";outline:0;transition:color ", vars.transitionStandard, ",border-color ", vars.transitionStandard, ";&:active,&:hover:not(:disabled)&:not(:read-only),&:focus{border-color:", vars.borderColorForInputWhenFocused, ";}" + ("" ), "" );
243
+ var getCalendarIconContainerStyles = function getCalendarIconContainerStyles(props, state) {
244
+ return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;background:none;border:0;border-left:1px solid ", designSystem.designTokens.borderColorForInput, ";border-top-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-bottom-right-radius:", designSystem.designTokens.borderRadiusForInput, ";border-color:", getIconBorderColor(props, state), ";color:", getIconFontColor(props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";height:100%;display:flex;padding:", designSystem.designTokens.spacingXs, ";outline:0;transition:color ", designSystem.designTokens.transitionStandard, ",border-color ", designSystem.designTokens.transitionStandard, ";&:active,&:hover:not(:disabled)&:not(:read-only),&:focus{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" );
253
245
  };
254
246
 
255
- var getInputBorderColor = function getInputBorderColor(vars, props, state) {
247
+ var getInputBorderColor = function getInputBorderColor(props, state) {
256
248
  if (props.isDisabled) {
257
- return vars.borderColorForInputWhenDisabled;
249
+ return designSystem.designTokens.borderColorForInputWhenDisabled;
258
250
  }
259
251
 
260
252
  if (props.hasError) {
261
- return vars.borderColorForInputWhenError;
253
+ return designSystem.designTokens.borderColorForInputWhenError;
262
254
  }
263
255
 
264
256
  if (props.hasWarning) {
265
- return vars.borderColorForInputWhenWarning;
257
+ return designSystem.designTokens.borderColorForInputWhenWarning;
266
258
  }
267
259
 
268
260
  if (props.isReadOnly) {
269
- return vars.borderColorForInputWhenReadonly;
261
+ return designSystem.designTokens.borderColorForInputWhenReadonly;
270
262
  }
271
263
 
272
264
  if ((props.isOpen || state.isFocused) && !props.isReadOnly) {
273
- return vars.borderColorForInputWhenFocused;
265
+ return designSystem.designTokens.borderColorForInputWhenFocused;
274
266
  }
275
267
 
276
- return vars.borderColorForInput;
268
+ return designSystem.designTokens.borderColorForInput;
277
269
  };
278
270
 
279
- var getInputFontColor = function getInputFontColor(vars, props) {
271
+ var getInputFontColor = function getInputFontColor(props) {
280
272
  if (props.isDisabled) {
281
- return vars.fontColorForInputWhenDisabled;
273
+ return designSystem.designTokens.fontColorForInputWhenDisabled;
282
274
  }
283
275
 
284
276
  if (props.hasError) {
285
- return vars.fontColorForInputWhenError;
277
+ return designSystem.designTokens.fontColorForInputWhenError;
286
278
  }
287
279
 
288
280
  if (props.hasWarning) {
289
- return vars.fontColorForInputWhenWarning;
281
+ return designSystem.designTokens.fontColorForInputWhenWarning;
290
282
  }
291
283
 
292
284
  if (props.isReadOnly) {
293
- return vars.fontColorForInputWhenReadonly;
285
+ return designSystem.designTokens.fontColorForInputWhenReadonly;
294
286
  }
295
287
 
296
- return vars.fontColorForInput;
288
+ return designSystem.designTokens.fontColorForInput;
297
289
  };
298
290
 
299
- var getInputContainerStyles = function getInputContainerStyles(props, state, theme) {
300
- var vars = _objectSpread$3(_objectSpread$3({}, designSystem.customProperties), theme);
301
-
302
- return /*#__PURE__*/react.css("appearance:none;background-color:", props.isDisabled ? vars.backgroundColorForInputWhenDisabled : vars.backgroundColorForInput, ";border:1px solid ", getInputBorderColor(vars, props, state), ";border-radius:", vars.borderRadiusForInput, ";box-sizing:border-box;color:", getInputFontColor(vars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";width:100%;height:", vars.sizeHeightInput, ";align-items:center;display:flex;font-size:", vars.fontSizeDefault, ";font-family:inherit;min-width:", vars.constraint5, ";transition:border-color ", vars.transitionStandard, ",box-shadow ", vars.transitionStandard, ";&:focus-within{border-color:", vars.borderColorForInputWhenFocused, ";box-shadow:inset 0 0 0 2px ", vars.borderColorForInputWhenFocused, ";}&:focus,&:hover{border-color:", props.isDisabled || props.hasError || props.hasWarning || props.isReadOnly || (props.isOpen || state.isFocused) && !props.isReadOnly ? '' : vars.borderColorForInputWhenFocused, ";}" + ("" ), "" );
291
+ var getInputContainerStyles = function getInputContainerStyles(props, state) {
292
+ return /*#__PURE__*/react.css("appearance:none;background-color:", props.isDisabled ? designSystem.designTokens.backgroundColorForInputWhenDisabled : designSystem.designTokens.backgroundColorForInput, ";border:1px solid ", getInputBorderColor(props, state), ";border-radius:", designSystem.designTokens.borderRadiusForInput, ";box-sizing:border-box;color:", getInputFontColor(props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";width:100%;height:", designSystem.designTokens.sizeHeightInput, ";align-items:center;display:flex;font-size:", designSystem.designTokens.fontSizeDefault, ";font-family:inherit;min-width:", designSystem.designTokens.constraint5, ";transition:border-color ", designSystem.designTokens.transitionStandard, ",box-shadow ", designSystem.designTokens.transitionStandard, ";&:focus-within{border-color:", designSystem.designTokens.borderColorForInputWhenFocused, ";box-shadow:inset 0 0 0 2px ", designSystem.designTokens.borderColorForInputWhenFocused, ";}&:focus,&:hover{border-color:", props.isDisabled || props.hasError || props.hasWarning || props.isReadOnly || (props.isOpen || state.isFocused) && !props.isReadOnly ? '' : designSystem.designTokens.borderColorForInputWhenFocused, ";}" + ("" ), "" );
303
293
  };
304
294
 
305
295
  var _ref$2 = {
@@ -307,8 +297,8 @@ var _ref$2 = {
307
297
  styles: "border:none;background:none;&:focus{box-shadow:none;}"
308
298
  } ;
309
299
 
310
- var getDateTimeInputStyles = function getDateTimeInputStyles(props, theme) {
311
- var baseStyles = [inputUtils.getInputStyles(props, theme), _ref$2];
300
+ var getDateTimeInputStyles = function getDateTimeInputStyles(props) {
301
+ var baseStyles = [inputUtils.getInputStyles(props), _ref$2];
312
302
  return baseStyles;
313
303
  };
314
304
 
@@ -316,9 +306,8 @@ function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["d
316
306
 
317
307
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
318
308
  var ClearSection = function ClearSection(props) {
319
- var theme = react.useTheme();
320
309
  return jsxRuntime.jsx(AccessibleButton__default["default"], {
321
- css: getClearSectionStyles(theme),
310
+ css: getClearSectionStyles(),
322
311
  label: "clear",
323
312
  onClick: props.onClear,
324
313
  "aria-label": "clear",
@@ -341,7 +330,6 @@ var CalendarBody = function CalendarBody(props) {
341
330
  isFocused = _useToggleState2[0],
342
331
  toggleIsFocused = _useToggleState2[1];
343
332
 
344
- var theme = react.useTheme();
345
333
  var onInputFocus = (_props$inputProps = props.inputProps) === null || _props$inputProps === void 0 ? void 0 : _props$inputProps.onFocus;
346
334
  var handleInputFocus = react$1.useCallback(function (event) {
347
335
  toggleIsFocused(true);
@@ -368,13 +356,13 @@ var CalendarBody = function CalendarBody(props) {
368
356
  children: jsxRuntime.jsxs("div", {
369
357
  css: getInputContainerStyles(props, {
370
358
  isFocused: isFocused
371
- }, theme),
359
+ }),
372
360
  children: [jsxRuntime.jsx("input", _objectSpread$2(_objectSpread$2({
373
361
  ref: props.inputRef
374
362
  }, props.inputProps), {}, {
375
363
  disabled: props.isDisabled,
376
364
  readOnly: props.isReadOnly,
377
- css: getDateTimeInputStyles(props, theme),
365
+ css: getDateTimeInputStyles(props),
378
366
  onFocus: handleInputFocus,
379
367
  onBlur: handleInputBlur,
380
368
  "aria-readonly": props.isReadOnly
@@ -388,7 +376,7 @@ var CalendarBody = function CalendarBody(props) {
388
376
  type: "button",
389
377
  css: getCalendarIconContainerStyles(props, {
390
378
  isFocused: isFocused
391
- }, theme)
379
+ })
392
380
  }, props.toggleButtonProps), {}, {
393
381
  onFocus: handleToggleFocus,
394
382
  onBlur: handleToggleBlur,
@@ -432,35 +420,35 @@ var getStyles = function getStyles(props) {
432
420
  var styles = [];
433
421
 
434
422
  if (!_includesInstanceProperty__default["default"](_context = ['heading', 'spacing']).call(_context, props.type || '')) {
435
- styles.push( /*#__PURE__*/react.css("text-align:center;padding:", designSystem.customProperties.spacingS, " 0;cursor:default;border-radius:", designSystem.customProperties.borderRadius4, ";" + ("" ), "" ));
423
+ styles.push( /*#__PURE__*/react.css("text-align:center;padding:", designSystem.designTokens.spacingS, " 0;cursor:default;border-radius:", designSystem.designTokens.borderRadius4, ";" + ("" ), "" ));
436
424
  }
437
425
 
438
426
  if (_includesInstanceProperty__default["default"](_context2 = ['heading', 'spacing']).call(_context2, props.type || '')) {
439
- styles.push( /*#__PURE__*/react.css("text-align:center;padding:", designSystem.customProperties.spacingS, " 0;cursor:default;color:", designSystem.customProperties.colorNeutral60, ";" + ("" ), "" ));
427
+ styles.push( /*#__PURE__*/react.css("text-align:center;padding:", designSystem.designTokens.spacingS, " 0;cursor:default;color:", designSystem.designTokens.colorNeutral60, ";" + ("" ), "" ));
440
428
  }
441
429
 
442
430
  if (props.isHighlighted) {
443
- styles.push( /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorNeutral90, ";" + ("" ), "" ));
431
+ styles.push( /*#__PURE__*/react.css("background-color:", designSystem.designTokens.colorNeutral90, ";" + ("" ), "" ));
444
432
  }
445
433
 
446
434
  if (props.isSelected) {
447
- styles.push( /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorPrimary, ";color:", designSystem.customProperties.colorSurface, ";" + ("" ), "" ));
435
+ styles.push( /*#__PURE__*/react.css("background-color:", designSystem.designTokens.colorPrimary, ";color:", designSystem.designTokens.colorSurface, ";" + ("" ), "" ));
448
436
  }
449
437
 
450
438
  if (props.isRangeStart || props.isRangeEnd) {
451
- styles.push( /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorPrimary40, ";color:", designSystem.customProperties.colorSurface, ";" + ("" ), "" ));
439
+ styles.push( /*#__PURE__*/react.css("background-color:", designSystem.designTokens.colorPrimary40, ";color:", designSystem.designTokens.colorSurface, ";" + ("" ), "" ));
452
440
  }
453
441
 
454
442
  if (props.isRangeBetween) {
455
- styles.push( /*#__PURE__*/react.css("background-color:", designSystem.customProperties.colorNeutral90, ";color:", designSystem.customProperties.fontColorForInput, ";" + ("" ), "" ));
443
+ styles.push( /*#__PURE__*/react.css("background-color:", designSystem.designTokens.colorNeutral90, ";color:", designSystem.designTokens.fontColorForInput, ";" + ("" ), "" ));
456
444
  }
457
445
 
458
446
  if (!props.isSelected && !props.isRangeStart && !props.isRangeEnd && props.isToday) {
459
- styles.push( /*#__PURE__*/react.css("color:", designSystem.customProperties.colorInfo, ";font-weight:bold;" + ("" ), "" ));
447
+ styles.push( /*#__PURE__*/react.css("color:", designSystem.designTokens.colorInfo, ";font-weight:bold;" + ("" ), "" ));
460
448
  }
461
449
 
462
450
  if (props.disabled) {
463
- styles.push( /*#__PURE__*/react.css("color:", designSystem.customProperties.fontColorForInputWhenDisabled, ";cursor:not-allowed;" + ("" ), "" ));
451
+ styles.push( /*#__PURE__*/react.css("color:", designSystem.designTokens.fontColorForInputWhenDisabled, ";cursor:not-allowed;" + ("" ), "" ));
464
452
  }
465
453
 
466
454
  return styles;
@@ -537,7 +525,7 @@ var CalendarHeader = function CalendarHeader(props) {
537
525
  }, []);
538
526
  return jsxRuntime.jsxs("div", {
539
527
  onMouseDown: onMouseDown,
540
- css: /*#__PURE__*/react.css("display:flex;padding:10px 2% 6px;margin-bottom:", designSystem.customProperties.spacingXs, ";justify-content:space-between;border-bottom:1px solid ", designSystem.customProperties.colorNeutral90, ";" + ("" ), "" ),
528
+ css: /*#__PURE__*/react.css("display:flex;padding:10px 2% 6px;margin-bottom:", designSystem.designTokens.spacingXs, ";justify-content:space-between;border-bottom:1px solid ", designSystem.designTokens.colorNeutral90, ";" + ("" ), "" ),
541
529
  children: [jsxRuntime.jsxs(Inline__default["default"], {
542
530
  scale: "xs",
543
531
  alignItems: "center",
@@ -657,7 +645,7 @@ var CalendarMenu = /*#__PURE__*/function (_Component) {
657
645
  rest = _objectWithoutProperties(_this$props, _excluded);
658
646
 
659
647
  return jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, rest), {}, {
660
- css: [/*#__PURE__*/react.css("overflow-y:scroll;color:", designSystem.customProperties.colorSolid, ";font-family:inherit;border:1px solid ", designSystem.customProperties.borderColorForInputWhenFocused, ";border-radius:", designSystem.customProperties.borderRadiusForInput, ";margin-top:", designSystem.customProperties.spacingXs, ";font-size:", designSystem.customProperties.fontSizeDefault, ";position:absolute;box-sizing:border-box;width:100%;background-color:", designSystem.customProperties.colorSurface, ";min-width:", designSystem.customProperties.constraint5, ";z-index:99999;" + ("" ), "" ), !hasFooter && _ref, hasError && /*#__PURE__*/react.css("border-color:", designSystem.customProperties.borderColorForInputWhenError, ";" + ("" ), "" ), hasWarning && /*#__PURE__*/react.css("border-color:", designSystem.customProperties.borderColorForInputWhenWarning, ";" + ("" ), "" ), "" , "" ],
648
+ css: [/*#__PURE__*/react.css("overflow-y:scroll;color:", designSystem.designTokens.colorSolid, ";font-family:inherit;border:1px solid ", designSystem.designTokens.borderColorForInputWhenFocused, ";border-radius:", designSystem.designTokens.borderRadiusForInput, ";margin-top:", designSystem.designTokens.spacingXs, ";font-size:", designSystem.designTokens.fontSizeDefault, ";position:absolute;box-sizing:border-box;width:100%;background-color:", designSystem.designTokens.colorSurface, ";min-width:", designSystem.designTokens.constraint5, ";z-index:99999;" + ("" ), "" ), !hasFooter && _ref, hasError && /*#__PURE__*/react.css("border-color:", designSystem.designTokens.borderColorForInputWhenError, ";" + ("" ), "" ), hasWarning && /*#__PURE__*/react.css("border-color:", designSystem.designTokens.borderColorForInputWhenWarning, ";" + ("" ), "" ), "" , "" ],
661
649
  children: [this.props.children, this.props.footer]
662
650
  }));
663
651
  }
@@ -670,7 +658,7 @@ CalendarMenu.displayName = 'CalendarMenu';
670
658
  CalendarMenu.propTypes = {};
671
659
 
672
660
  // NOTE: This string will be replaced on build time with the package version.
673
- var version = "15.2.4";
661
+ var version = "15.3.0";
674
662
 
675
663
  exports.CalendarBody = CalendarBody$1;
676
664
  exports.CalendarContent = CalendarContent$1;