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