pebble-web 2.20.0-alpha.1 → 2.21.0-alpha.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.
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
- import { SwitchProps, SwitchState } from "./typings/Switch";
3
- export default class Switch extends React.PureComponent<SwitchProps, SwitchState> {
4
- state: {
5
- value: boolean;
2
+ import { SwitchProps } from "./typings/Switch";
3
+ export default class Switch extends React.PureComponent<SwitchProps> {
4
+ static defaultProps: {
5
+ checked: boolean;
6
6
  };
7
7
  render(): JSX.Element;
8
8
  }
@@ -1,10 +1,8 @@
1
+ /// <reference types="react" />
1
2
  export interface SwitchProps {
2
- initialValue?: boolean;
3
- onChange?: (value: boolean) => void;
3
+ checked?: boolean;
4
+ onChange?: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>) => void;
4
5
  className?: string;
5
6
  label?: string;
6
7
  disabled?: boolean;
7
8
  }
8
- export interface SwitchState {
9
- value: boolean;
10
- }
@@ -4113,52 +4113,50 @@ var Switch = /*#__PURE__*/function (_React$PureComponent) {
4113
4113
  _inherits(Switch, _React$PureComponent);
4114
4114
  var _super = _createSuper$o(Switch);
4115
4115
  function Switch() {
4116
- var _this;
4117
4116
  _classCallCheck(this, Switch);
4118
- _this = _super.apply(this, arguments);
4119
- _this.state = {
4120
- value: _this.props.initialValue || false
4121
- };
4122
- return _this;
4117
+ return _super.apply(this, arguments);
4123
4118
  }
4124
4119
  _createClass(Switch, [{
4125
4120
  key: "render",
4126
4121
  value: function render() {
4127
4122
  var _cx3,
4128
- _this2 = this,
4123
+ _this = this,
4129
4124
  _cx4;
4130
4125
  var _this$props = this.props,
4126
+ checked = _this$props.checked,
4131
4127
  _onChange = _this$props.onChange,
4132
4128
  className = _this$props.className,
4133
4129
  label = _this$props.label,
4134
4130
  disabled = _this$props.disabled;
4135
- var value = this.state.value;
4136
4131
  return /*#__PURE__*/React.createElement("label", {
4137
4132
  className: emotion.cx(className, fixedLabelStyle, _defineProperty({}, disabledStyle$1, !!disabled))
4138
4133
  }, /*#__PURE__*/React.createElement("span", {
4139
4134
  className: labelTextStyle
4140
4135
  }, label), /*#__PURE__*/React.createElement("div", {
4141
- className: emotion.cx(labelStyle$1, (_cx3 = {}, _defineProperty(_cx3, selectedLabel, value), _defineProperty(_cx3, disabledStyle$1, !!disabled), _cx3))
4136
+ className: emotion.cx(labelStyle$1, (_cx3 = {}, _defineProperty(_cx3, selectedLabel, checked), _defineProperty(_cx3, disabledStyle$1, !!disabled), _cx3))
4142
4137
  }, /*#__PURE__*/React.createElement("input", {
4143
4138
  type: "checkbox",
4144
- checked: value,
4139
+ checked: checked,
4145
4140
  className: inputStyle$3,
4146
- onChange: function onChange() {
4147
- _this2.setState({
4148
- value: !value
4141
+ onChange: function onChange(e) {
4142
+ _this.setState({
4143
+ value: !checked
4149
4144
  });
4150
4145
  if (_onChange) {
4151
- _onChange(!value);
4146
+ _onChange(!checked, e);
4152
4147
  }
4153
4148
  },
4154
4149
  disabled: disabled
4155
4150
  }), /*#__PURE__*/React.createElement("span", {
4156
- className: emotion.cx((_cx4 = {}, _defineProperty(_cx4, switchStyle, true), _defineProperty(_cx4, selectedSwitch, value), _cx4))
4151
+ className: emotion.cx((_cx4 = {}, _defineProperty(_cx4, switchStyle, true), _defineProperty(_cx4, selectedSwitch, checked), _cx4))
4157
4152
  })));
4158
4153
  }
4159
4154
  }]);
4160
4155
  return Switch;
4161
4156
  }(React.PureComponent);
4157
+ Switch.defaultProps = {
4158
+ checked: false
4159
+ };
4162
4160
 
4163
4161
  function ownKeys$r(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4164
4162
  function _objectSpread$r(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$r(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$r(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }