cx 22.7.0 → 22.8.1

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/dist/ui.js CHANGED
@@ -1623,26 +1623,30 @@ function preventFocusOnTouch(e, force) {
1623
1623
 
1624
1624
  if (force || isTouchEvent()) preventFocus(e);
1625
1625
  }
1626
- function unfocusElement(target, forceBlur) {
1626
+ function unfocusElement(target, unfocusParentOverlay) {
1627
1627
  if (target === void 0) {
1628
1628
  target = null;
1629
1629
  }
1630
1630
 
1631
- if (forceBlur === void 0) {
1632
- forceBlur = true;
1631
+ if (unfocusParentOverlay === void 0) {
1632
+ unfocusParentOverlay = true;
1633
1633
  }
1634
1634
 
1635
1635
  var activeElement = getActiveElement();
1636
- if (!target) target = activeElement; //find the closest focusable parent of the target element and focus it instead
1637
-
1638
- var focusableParent =
1639
- (!forceBlur &&
1640
- closestParent(target, function(el) {
1641
- return isFocusable(el);
1642
- })) ||
1643
- document.body;
1644
- if (focusableParent === document.body) activeElement.blur();
1645
- else focusableParent.focus();
1636
+ if (!target) target = activeElement;
1637
+
1638
+ if (unfocusParentOverlay) {
1639
+ var focusableOverlayContainer = closestParent(target, function(el) {
1640
+ return el.dataset.focusableOverlayContainer;
1641
+ });
1642
+ if (focusableOverlayContainer) target = focusableOverlayContainer;
1643
+ } //find the closest focusable parent of the target element and focus it instead
1644
+
1645
+ var focusableParent = closestParent(target, function(el) {
1646
+ return isFocusable(el) && (!unfocusParentOverlay || el.dataset.focusableOverlayContainer);
1647
+ });
1648
+ if (focusableParent && focusableParent !== document.body) focusableParent.focus();
1649
+ else activeElement.blur();
1646
1650
  FocusManager.nudge();
1647
1651
  }
1648
1652
 
package/dist/widgets.css CHANGED
@@ -2406,6 +2406,7 @@ th.cxe-calendar-display {
2406
2406
  height: 18px;
2407
2407
  margin-left: -9px;
2408
2408
  margin-top: -9px;
2409
+ margin-bottom: -9px;
2409
2410
  touch-action: none;
2410
2411
  background-color: #ebebeb;
2411
2412
  border-style: solid;
@@ -2417,8 +2418,7 @@ th.cxe-calendar-display {
2417
2418
  left: 0;
2418
2419
  top: 50%; }
2419
2420
  .cxb-slider.cxs-vertical .cxe-slider-handle {
2420
- left: 50%;
2421
- top: 0; }
2421
+ left: 50%; }
2422
2422
  .cxe-slider-handle:hover {
2423
2423
  box-shadow: 0 0 3px rgba(128, 128, 128, 0.5); }
2424
2424
  .cxe-slider-handle:focus {
package/dist/widgets.js CHANGED
@@ -89,6 +89,7 @@ import {
89
89
  calculateNaturalElementHeight,
90
90
  findFirst,
91
91
  isFocusable,
92
+ closestParent,
92
93
  isNonEmptyArray,
93
94
  tooltipsFlag,
94
95
  shallowEquals,
@@ -2068,7 +2069,7 @@ var Sandbox = /*#__PURE__*/ (function(_PureContainer) {
2068
2069
  _proto.init = function init() {
2069
2070
  if (this.recordAlias) this.recordName = this.recordAlias;
2070
2071
  if (this.accessKey) this.key = this.accessKey;
2071
- this.storageBinding = Binding.get(this.storage.bind);
2072
+ this.storageBinding = Binding.get(this.storage);
2072
2073
 
2073
2074
  _PureContainer.prototype.init.call(this);
2074
2075
  };
@@ -3435,9 +3436,14 @@ var Overlay = /*#__PURE__*/ (function(_Container) {
3435
3436
  if (this.onMouseEnter) instance.invoke("onMouseEnter", instance, component);
3436
3437
  };
3437
3438
 
3439
+ _proto.getOverlayContainer = function getOverlayContainer() {
3440
+ return document.body;
3441
+ };
3442
+
3438
3443
  _proto.containerFactory = function containerFactory() {
3439
3444
  var el = document.createElement("div");
3440
- document.body.appendChild(el);
3445
+ var container = this.getOverlayContainer();
3446
+ container.appendChild(el);
3441
3447
  el.style.position = "absolute";
3442
3448
  if (this.containerStyle) Object.assign(el.style, parseStyle(this.containerStyle));
3443
3449
  return el;
@@ -3565,6 +3571,7 @@ var OverlayContent = /*#__PURE__*/ (function(_VDOM$Component) {
3565
3571
  onMouseEnter: this.props.onMouseEnter,
3566
3572
  onMouseLeave: this.props.onMouseLeave,
3567
3573
  onClick: this.props.onClick,
3574
+ "data-focusable-overlay-container": this.props.focusableOverlayContainer,
3568
3575
  children: this.props.children
3569
3576
  });
3570
3577
  };
@@ -3621,7 +3628,7 @@ var OverlayComponent = /*#__PURE__*/ (function(_VDOM$Component2) {
3621
3628
  _this4.el = el;
3622
3629
  };
3623
3630
 
3624
- var content = /*#__PURE__*/ jsxs(OverlayContent, {
3631
+ var content = /*#__PURE__*/ jsx(OverlayContent, {
3625
3632
  onRef: this.onOverlayRef,
3626
3633
  className: data.classNames,
3627
3634
  style: data.style,
@@ -3639,25 +3646,14 @@ var OverlayComponent = /*#__PURE__*/ (function(_VDOM$Component2) {
3639
3646
  onMouseEnter: this.onMouseEnter.bind(this),
3640
3647
  onClick: this.onClick.bind(this),
3641
3648
  onDidUpdate: this.overlayDidUpdate.bind(this),
3642
- children: [
3643
- widget.modal ||
3644
- (widget.backdrop &&
3645
- /*#__PURE__*/ jsx(
3646
- "div",
3647
- {
3648
- className: CSS.element(baseClass, "modal-backdrop"),
3649
- onClick: this.onBackdropClick.bind(this)
3650
- },
3651
- "backdrop"
3652
- )),
3653
- this.renderOverlayBody()
3654
- ]
3649
+ focusableOverlayContainer: widget.dismissOnFocusOut,
3650
+ children: this.renderOverlayBody()
3655
3651
  });
3656
3652
 
3657
3653
  var result = content;
3658
3654
 
3659
3655
  if (widget.modal || widget.backdrop) {
3660
- result = /*#__PURE__*/ jsx(
3656
+ result = /*#__PURE__*/ jsxs(
3661
3657
  "div",
3662
3658
  {
3663
3659
  ref: function ref(el) {
@@ -3669,7 +3665,18 @@ var OverlayComponent = /*#__PURE__*/ (function(_VDOM$Component2) {
3669
3665
  animate: widget.animate
3670
3666
  }),
3671
3667
  style: parseStyle(data.shadowStyle),
3672
- children: content
3668
+ children: [
3669
+ widget.backdrop &&
3670
+ /*#__PURE__*/ jsx(
3671
+ "div",
3672
+ {
3673
+ className: CSS.element("overlay", "modal-backdrop"),
3674
+ onClick: this.onBackdropClick.bind(this)
3675
+ },
3676
+ "backdrop"
3677
+ ),
3678
+ content
3679
+ ]
3673
3680
  },
3674
3681
  "shadow"
3675
3682
  );
@@ -3740,7 +3747,10 @@ var OverlayComponent = /*#__PURE__*/ (function(_VDOM$Component2) {
3740
3747
  };
3741
3748
 
3742
3749
  _proto3.onMouseDown = function onMouseDown(e) {
3743
- var data = this.props.instance.data;
3750
+ var instance = this.props.instance;
3751
+ var widget = instance.widget,
3752
+ data = instance.data;
3753
+ if (widget.onMouseDown && instance.invoke("onMouseDown", e, instance) === false) return;
3744
3754
  var prefix = this.getResizePrefix(e);
3745
3755
 
3746
3756
  if (prefix) {
@@ -3758,9 +3768,7 @@ var OverlayComponent = /*#__PURE__*/ (function(_VDOM$Component2) {
3758
3768
  captureMouseOrTouch(e, this.onMouseMove.bind(this), null, captureData, prefix + "-resize");
3759
3769
  } else if (data.draggable) {
3760
3770
  ddMouseDown(e);
3761
- }
3762
-
3763
- e.stopPropagation();
3771
+ } //e.stopPropagation();
3764
3772
  };
3765
3773
 
3766
3774
  _proto3.onBackdropClick = function onBackdropClick(e) {
@@ -4691,6 +4699,18 @@ var Dropdown = /*#__PURE__*/ (function(_Overlay) {
4691
4699
  return [beacon, instance.relatedElement && _Overlay.prototype.render.call(this, context, instance, key)];
4692
4700
  };
4693
4701
 
4702
+ _proto.getOverlayContainer = function getOverlayContainer() {
4703
+ // this should be instance.relatedElement
4704
+ if (this.relatedElement) {
4705
+ var container = closestParent(this.relatedElement, function(el) {
4706
+ return el.dataset && el.dataset.focusableOverlayContainer;
4707
+ });
4708
+ if (container) return container;
4709
+ }
4710
+
4711
+ return _Overlay.prototype.getOverlayContainer.call(this);
4712
+ };
4713
+
4694
4714
  return Dropdown;
4695
4715
  })(Overlay);
4696
4716
  Dropdown.prototype.offset = 0;
@@ -6220,6 +6240,7 @@ var MenuItemComponent = /*#__PURE__*/ (function(_VDOM$Component) {
6220
6240
  relatedElement: this.el.parentElement,
6221
6241
  placement: widget.placement,
6222
6242
  onKeyDown: this.onDropdownKeyDown.bind(this),
6243
+ onMouseDown: stopPropagation,
6223
6244
  items: widget.dropdown,
6224
6245
  parentPositionChangeEvent: parentPositionChangeEvent,
6225
6246
  pipeValidateDropdownPosition: function pipeValidateDropdownPosition(cb) {
@@ -6509,7 +6530,7 @@ var MenuItemComponent = /*#__PURE__*/ (function(_VDOM$Component) {
6509
6530
  } else instance.invoke("onClick", e, instance);
6510
6531
  }
6511
6532
  }
6512
- if (widget.autoClose) unfocusElement(this.el);
6533
+ if (widget.autoClose) unfocusElement(this.el, true);
6513
6534
  };
6514
6535
 
6515
6536
  _proto2.onFocus = function onFocus() {
@@ -6652,11 +6673,11 @@ var Menu = /*#__PURE__*/ (function(_HtmlElement) {
6652
6673
  };
6653
6674
 
6654
6675
  _proto.add = function add(item) {
6655
- if (item && item.tag == "a") {
6676
+ if (item && (item.tag == "a" || item.tag == "hr")) {
6656
6677
  var mi = {
6657
6678
  type: MenuItem,
6658
6679
  items: item,
6659
- autoClose: true
6680
+ autoClose: item.tag == "a"
6660
6681
  };
6661
6682
  if (isDefined(item["if"])) mi["if"] = item["if"];
6662
6683
  if (isDefined(item.visible)) mi.visible = item.visible;
@@ -14753,7 +14774,8 @@ var Slider = /*#__PURE__*/ (function(_Field) {
14753
14774
  },
14754
14775
  handleStyle: {
14755
14776
  structured: true
14756
- }
14777
+ },
14778
+ invert: false
14757
14779
  }
14758
14780
  ].concat(Array.prototype.slice.call(arguments))
14759
14781
  );
@@ -14807,6 +14829,7 @@ Slider.prototype.maxValue = 100;
14807
14829
  Slider.prototype.vertical = false;
14808
14830
  Slider.prototype.incrementPercentage = 0.01;
14809
14831
  Slider.prototype.wheel = false;
14832
+ Slider.prototype.invert = false;
14810
14833
  Widget.alias("slider", Slider);
14811
14834
 
14812
14835
  var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
@@ -14848,12 +14871,15 @@ var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
14848
14871
  from = Math.min(maxValue, Math.max(minValue, from));
14849
14872
  to = Math.min(maxValue, Math.max(minValue, to));
14850
14873
  var handleStyle = CSS.parseStyle(data.handleStyle);
14874
+ var anchor = widget.vertical ? (widget.invert ? "top" : "bottom") : "left";
14875
+ var rangeStart = from - minValue;
14876
+ var rangeSize = to - from;
14851
14877
 
14852
14878
  var fromHandleStyle = _objectSpread2(
14853
14879
  _objectSpread2({}, handleStyle),
14854
14880
  {},
14855
14881
  ((_objectSpread2$1 = {}),
14856
- (_objectSpread2$1[widget.vertical ? "top" : "left"] = (100 * (from - minValue)) / (maxValue - minValue) + "%"),
14882
+ (_objectSpread2$1[anchor] = (100 * (from - minValue)) / (maxValue - minValue) + "%"),
14857
14883
  _objectSpread2$1)
14858
14884
  );
14859
14885
 
@@ -14861,19 +14887,16 @@ var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
14861
14887
  _objectSpread2({}, handleStyle),
14862
14888
  {},
14863
14889
  ((_objectSpread3 = {}),
14864
- (_objectSpread3[widget.vertical ? "top" : "left"] = (100 * (to - minValue)) / (maxValue - minValue) + "%"),
14890
+ (_objectSpread3[anchor] = (100 * (to - minValue)) / (maxValue - minValue) + "%"),
14865
14891
  _objectSpread3)
14866
14892
  );
14867
14893
 
14868
- var rangeStart = (from - minValue) / (maxValue - minValue);
14869
- var rangeSize = (to - from) / (maxValue - minValue);
14870
-
14871
14894
  var rangeStyle = _objectSpread2(
14872
14895
  _objectSpread2({}, CSS.parseStyle(data.rangeStyle)),
14873
14896
  {},
14874
14897
  ((_objectSpread4 = {}),
14875
- (_objectSpread4[widget.vertical ? "top" : "left"] = 100 * rangeStart + "%"),
14876
- (_objectSpread4[widget.vertical ? "height" : "width"] = 100 * rangeSize + "%"),
14898
+ (_objectSpread4[anchor] = (100 * rangeStart) / (maxValue - minValue) + "%"),
14899
+ (_objectSpread4[widget.vertical ? "height" : "width"] = (100 * rangeSize) / (maxValue - minValue) + "%"),
14877
14900
  _objectSpread4)
14878
14901
  );
14879
14902
 
@@ -15106,13 +15129,15 @@ var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
15106
15129
  var b = getTopLevelBoundingClientRect(this.dom.range);
15107
15130
  var pos = getCursorPos(e);
15108
15131
  var pct = widget.vertical
15109
- ? Math.max(0, Math.min(1, (pos.clientY - b.top - d) / this.dom.range.offsetHeight))
15132
+ ? widget.invert
15133
+ ? Math.max(0, Math.min(1, (pos.clientY - b.top - d) / this.dom.range.offsetHeight))
15134
+ : Math.max(0, Math.min(1, (b.bottom - pos.clientY + d) / this.dom.range.offsetHeight))
15110
15135
  : Math.max(0, Math.min(1, (pos.clientX - b.left - d) / this.dom.range.offsetWidth));
15111
15136
  var delta = (maxValue - minValue) * pct;
15112
15137
 
15113
15138
  if (data.step) {
15114
15139
  var currentValue = Math.round(delta / data.step) * data.step + minValue;
15115
- var value = this.checkBoundries(currentValue);
15140
+ var value = this.checkBoundaries(currentValue);
15116
15141
  if (maxValue % data.step === 0) delta = Math.round(delta / data.step) * data.step;
15117
15142
  delta = value - minValue;
15118
15143
  }
@@ -15167,13 +15192,13 @@ var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
15167
15192
 
15168
15193
  if (!data.disabled && !data.readOnly) {
15169
15194
  if (widget.showFrom) {
15170
- var value = this.checkBoundries(data.from + increment);
15195
+ var value = this.checkBoundaries(data.from + increment);
15171
15196
  if (instance.set("from", value))
15172
15197
  this.setState({
15173
15198
  from: value
15174
15199
  });
15175
15200
  } else if (widget.showTo) {
15176
- var _value = this.checkBoundries(data.to + increment);
15201
+ var _value = this.checkBoundaries(data.to + increment);
15177
15202
 
15178
15203
  if (instance.set("to", _value))
15179
15204
  this.setState({
@@ -15183,7 +15208,7 @@ var SliderComponent = /*#__PURE__*/ (function(_VDOM$Component) {
15183
15208
  }
15184
15209
  };
15185
15210
 
15186
- _proto2.checkBoundries = function checkBoundries(value) {
15211
+ _proto2.checkBoundaries = function checkBoundaries(value) {
15187
15212
  var data = this.props.instance.data;
15188
15213
  if (value > data.maxValue) value = data.maxValue;
15189
15214
  else if (value < data.minValue) value = data.minValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "22.7.0",
3
+ "version": "22.8.1",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
package/src/core.d.ts CHANGED
@@ -23,6 +23,13 @@ declare namespace Cx {
23
23
 
24
24
  type Selector<T> = (data: any) => T;
25
25
 
26
+ type GetSet<T> = {
27
+ get: Selector<T>;
28
+ set?: (value: T, instance?: any) => boolean;
29
+ throttle?: number;
30
+ debounce?: number;
31
+ };
32
+
26
33
  interface StructuredSelector {
27
34
  [prop: string]: Selector<any>;
28
35
  }
@@ -35,7 +42,7 @@ declare namespace Cx {
35
42
  [prop in keyof M]: AccessorChain<M[prop]>;
36
43
  };
37
44
 
38
- type Prop<T> = T | Binding | Selector<T> | AccessorChain<T>;
45
+ type Prop<T> = T | Binding | Selector<T> | AccessorChain<T> | GetSet<T>;
39
46
 
40
47
  interface Record {
41
48
  [prop: string]: any;
@@ -158,6 +165,7 @@ declare namespace Cx {
158
165
  onTouchMove?: string | ((event: TouchEvent, instance: any) => void);
159
166
  onTouchEnd?: string | ((event: TouchEvent, instance: any) => void);
160
167
  onClick?: string | ((event: MouseEvent, instance: any) => void);
168
+ onContextMenu?: string | ((event: MouseEvent, instance: any) => void);
161
169
  }
162
170
 
163
171
  type SortDirection = "ASC" | "DESC";
@@ -149,15 +149,23 @@ export function preventFocusOnTouch(e, force = false) {
149
149
  if (force || isTouchEvent()) preventFocus(e);
150
150
  }
151
151
 
152
- export function unfocusElement(target = null, forceBlur = true) {
152
+ export function unfocusElement(target = null, unfocusParentOverlay = true) {
153
153
  const activeElement = getActiveElement();
154
154
  if (!target) target = activeElement;
155
155
 
156
+ if (unfocusParentOverlay) {
157
+ let focusableOverlayContainer = closestParent(target, (el) => el.dataset.focusableOverlayContainer);
158
+ if (focusableOverlayContainer) target = focusableOverlayContainer;
159
+ }
160
+
156
161
  //find the closest focusable parent of the target element and focus it instead
157
- let focusableParent = (!forceBlur && closestParent(target, (el) => isFocusable(el))) || document.body;
162
+ let focusableParent = closestParent(
163
+ target,
164
+ (el) => isFocusable(el) && (!unfocusParentOverlay || el.dataset.focusableOverlayContainer)
165
+ );
158
166
 
159
- if (focusableParent === document.body) activeElement.blur();
160
- else focusableParent.focus();
167
+ if (focusableParent && focusableParent !== document.body) focusableParent.focus();
168
+ else activeElement.blur();
161
169
 
162
170
  FocusManager.nudge();
163
171
  }
@@ -39,9 +39,9 @@ export interface ButtonProps extends Cx.HtmlElementProps {
39
39
  * @param e - Event.
40
40
  * @param instance - Cx widget instance that fired the event.
41
41
  */
42
- onClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
42
+ onClick?: string | ((e: MouseEvent, instance: Instance) => void);
43
43
 
44
- onMouseDown?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
44
+ onMouseDown?: string | ((e: MouseEvent, instance: Instance) => void);
45
45
 
46
46
  /** Button type. */
47
47
  type?: "submit" | "button";
@@ -1,18 +1,16 @@
1
- import * as Cx from '../core';
1
+ import * as Cx from "../core";
2
2
 
3
3
  interface SandboxProps extends Cx.PureContainerProps {
4
+ storage: Cx.Prop<Cx.Record>;
4
5
 
5
- storage: Cx.StringProp,
6
+ /* Cx.StringProp doesn't work for unknown reason */
7
+ key?: any;
6
8
 
7
- /* Cx.StringProp doesn't work for unknown reason */
8
- key?: any,
9
+ accessKey?: Cx.StringProp;
9
10
 
10
- accessKey?: Cx.StringProp,
11
-
12
- recordName?: string,
13
- recordAlias?: string,
14
- immutable?: boolean
15
-
11
+ recordName?: string;
12
+ recordAlias?: string;
13
+ immutable?: boolean;
16
14
  }
17
15
 
18
16
  export class Sandbox extends Cx.Widget<SandboxProps> {}
@@ -1,48 +1,51 @@
1
- import {Widget} from '../ui/Widget';
2
- import {PureContainer} from '../ui/PureContainer';
3
- import {Binding} from '../data/Binding';
4
- import {ExposedValueView} from '../data/ExposedValueView';
1
+ import { Widget } from "../ui/Widget";
2
+ import { PureContainer } from "../ui/PureContainer";
3
+ import { Binding } from "../data/Binding";
4
+ import { ExposedValueView } from "../data/ExposedValueView";
5
5
 
6
6
  export class Sandbox extends PureContainer {
7
7
  init() {
8
- if (this.recordAlias)
9
- this.recordName = this.recordAlias;
8
+ if (this.recordAlias) this.recordName = this.recordAlias;
10
9
 
11
- if (this.accessKey)
12
- this.key = this.accessKey;
10
+ if (this.accessKey) this.key = this.accessKey;
11
+
12
+ this.storageBinding = Binding.get(this.storage);
13
13
 
14
- this.storageBinding = Binding.get(this.storage.bind);
15
14
  super.init();
16
15
  }
17
16
 
18
17
  initInstance(context, instance) {
19
18
  instance.store = new ExposedValueView({
20
19
  store: instance.store,
21
- containerBinding: this.storageBinding, key: null,
20
+ containerBinding: this.storageBinding,
21
+ key: null,
22
22
  recordName: this.recordName,
23
- immutable: this.immutable
23
+ immutable: this.immutable,
24
24
  });
25
- instance.setStore = store => {
25
+ instance.setStore = (store) => {
26
26
  instance.store.setStore(store);
27
27
  };
28
28
  }
29
29
 
30
30
  declareData() {
31
- super.declareData({
32
- storage: undefined,
33
- key: undefined
34
- }, ...arguments);
31
+ super.declareData(
32
+ {
33
+ storage: undefined,
34
+ key: undefined,
35
+ },
36
+ ...arguments
37
+ );
35
38
  }
36
39
 
37
40
  prepareData(context, instance) {
38
- var {store, data} = instance;
41
+ var { store, data } = instance;
39
42
  if (store.getKey() !== data.key) {
40
43
  instance.store = new ExposedValueView({
41
44
  store: store,
42
45
  containerBinding: this.storageBinding,
43
46
  key: data.key,
44
47
  recordName: this.recordName,
45
- immutable: this.immutable
48
+ immutable: this.immutable,
46
49
  });
47
50
 
48
51
  //when navigating to a page using the same widget tree as the previous page
@@ -53,7 +56,7 @@ export class Sandbox extends PureContainer {
53
56
  }
54
57
  }
55
58
 
56
- Sandbox.prototype.recordName = '$page';
59
+ Sandbox.prototype.recordName = "$page";
57
60
  Sandbox.prototype.immutable = false;
58
61
 
59
- Widget.alias('sandbox', Sandbox);
62
+ Widget.alias("sandbox", Sandbox);
@@ -34,6 +34,7 @@ export class Slider extends Field {
34
34
  handleStyle: {
35
35
  structured: true,
36
36
  },
37
+ invert: false,
37
38
  },
38
39
  ...arguments
39
40
  );
@@ -86,6 +87,7 @@ Slider.prototype.maxValue = 100;
86
87
  Slider.prototype.vertical = false;
87
88
  Slider.prototype.incrementPercentage = 0.01;
88
89
  Slider.prototype.wheel = false;
90
+ Slider.prototype.invert = false;
89
91
 
90
92
  Widget.alias("slider", Slider);
91
93
 
@@ -111,23 +113,24 @@ class SliderComponent extends VDOM.Component {
111
113
  to = Math.min(maxValue, Math.max(minValue, to));
112
114
 
113
115
  let handleStyle = CSS.parseStyle(data.handleStyle);
116
+ let anchor = widget.vertical ? (widget.invert ? "top" : "bottom") : "left";
117
+ let rangeStart = from - minValue;
118
+ let rangeSize = to - from;
114
119
 
115
120
  let fromHandleStyle = {
116
121
  ...handleStyle,
117
- [widget.vertical ? "top" : "left"]: `${(100 * (from - minValue)) / (maxValue - minValue)}%`,
122
+ [anchor]: `${(100 * (from - minValue)) / (maxValue - minValue)}%`,
118
123
  };
124
+
119
125
  let toHandleStyle = {
120
126
  ...handleStyle,
121
- [widget.vertical ? "top" : "left"]: `${(100 * (to - minValue)) / (maxValue - minValue)}%`,
127
+ [anchor]: `${(100 * (to - minValue)) / (maxValue - minValue)}%`,
122
128
  };
123
129
 
124
- let rangeStart = (from - minValue) / (maxValue - minValue);
125
- let rangeSize = (to - from) / (maxValue - minValue);
126
-
127
130
  let rangeStyle = {
128
131
  ...CSS.parseStyle(data.rangeStyle),
129
- [widget.vertical ? "top" : "left"]: `${100 * rangeStart}%`,
130
- [widget.vertical ? "height" : "width"]: `${100 * rangeSize}%`,
132
+ [anchor]: `${(100 * rangeStart) / (maxValue - minValue)}%`,
133
+ [widget.vertical ? "height" : "width"]: `${(100 * rangeSize) / (maxValue - minValue)}%`,
131
134
  };
132
135
 
133
136
  return (
@@ -267,12 +270,14 @@ class SliderComponent extends VDOM.Component {
267
270
  let b = getTopLevelBoundingClientRect(this.dom.range);
268
271
  let pos = getCursorPos(e);
269
272
  let pct = widget.vertical
270
- ? Math.max(0, Math.min(1, (pos.clientY - b.top - d) / this.dom.range.offsetHeight))
273
+ ? widget.invert
274
+ ? Math.max(0, Math.min(1, (pos.clientY - b.top - d) / this.dom.range.offsetHeight))
275
+ : Math.max(0, Math.min(1, (b.bottom - pos.clientY + d) / this.dom.range.offsetHeight))
271
276
  : Math.max(0, Math.min(1, (pos.clientX - b.left - d) / this.dom.range.offsetWidth));
272
277
  let delta = (maxValue - minValue) * pct;
273
278
  if (data.step) {
274
279
  let currentValue = Math.round(delta / data.step) * data.step + minValue;
275
- let value = this.checkBoundries(currentValue);
280
+ let value = this.checkBoundaries(currentValue);
276
281
 
277
282
  if (maxValue % data.step === 0) delta = Math.round(delta / data.step) * data.step;
278
283
 
@@ -291,6 +296,7 @@ class SliderComponent extends VDOM.Component {
291
296
  if (!data.disabled && !data.readOnly) {
292
297
  let { value } = this.getValues(e);
293
298
  this.props.instance.set("value", value, { immediate: true });
299
+
294
300
  if (widget.showFrom) {
295
301
  this.setState({ from: value });
296
302
  this.props.instance.set("from", value, { immediate: true });
@@ -314,16 +320,16 @@ class SliderComponent extends VDOM.Component {
314
320
 
315
321
  if (!data.disabled && !data.readOnly) {
316
322
  if (widget.showFrom) {
317
- let value = this.checkBoundries(data.from + increment);
323
+ let value = this.checkBoundaries(data.from + increment);
318
324
  if (instance.set("from", value)) this.setState({ from: value });
319
325
  } else if (widget.showTo) {
320
- let value = this.checkBoundries(data.to + increment);
326
+ let value = this.checkBoundaries(data.to + increment);
321
327
  if (instance.set("to", value)) this.setState({ to: value });
322
328
  }
323
329
  }
324
330
  }
325
331
 
326
- checkBoundries(value) {
332
+ checkBoundaries(value) {
327
333
  let { data } = this.props.instance;
328
334
  if (value > data.maxValue) value = data.maxValue;
329
335
  else if (value < data.minValue) value = data.minValue;
@@ -84,6 +84,7 @@
84
84
  height: $size;
85
85
  margin-left: -$size / 2;
86
86
  margin-top: -$size / 2;
87
+ margin-bottom: -$size / 2;
87
88
  touch-action: none;
88
89
 
89
90
  .#{$block}#{$name}.#{$state}horizontal & {
@@ -93,7 +94,6 @@
93
94
 
94
95
  .#{$block}#{$name}.#{$state}vertical & {
95
96
  left: 50%;
96
- top: 0;
97
97
  }
98
98
 
99
99
  @include cx-add-state-rules($styles, default);
@@ -79,11 +79,11 @@ export class Menu extends HtmlElement {
79
79
  }
80
80
 
81
81
  add(item) {
82
- if (item && item.tag == "a") {
82
+ if (item && (item.tag == "a" || item.tag == "hr")) {
83
83
  let mi = {
84
84
  type: MenuItem,
85
85
  items: item,
86
- autoClose: true,
86
+ autoClose: item.tag == "a",
87
87
  };
88
88
 
89
89
  if (isDefined(item.if)) mi.if = item.if;
@@ -152,12 +152,7 @@ class MenuComponent extends VDOM.Component {
152
152
  let key = content && typeof content == "object" && content.key ? content.key : index;
153
153
 
154
154
  if (content && content.spacer) {
155
- return (
156
- widget.horizontal &&
157
- (
158
- <li className={CSS.element(baseClass, "spacer")} key={key} />
159
- )
160
- );
155
+ return widget.horizontal && <li className={CSS.element(baseClass, "spacer")} key={key} />;
161
156
  }
162
157
 
163
158
  return (
@@ -140,6 +140,7 @@ class MenuItemComponent extends VDOM.Component {
140
140
  relatedElement: this.el.parentElement,
141
141
  placement: widget.placement,
142
142
  onKeyDown: this.onDropdownKeyDown.bind(this),
143
+ onMouseDown: stopPropagation,
143
144
  items: widget.dropdown,
144
145
  parentPositionChangeEvent,
145
146
  pipeValidateDropdownPosition: (cb) => {
@@ -398,7 +399,7 @@ class MenuItemComponent extends VDOM.Component {
398
399
  }
399
400
  }
400
401
 
401
- if (widget.autoClose) unfocusElement(this.el);
402
+ if (widget.autoClose) unfocusElement(this.el, true);
402
403
  }
403
404
 
404
405
  onFocus() {