diff --git a/bin/components/Button.js b/bin/components/Button.js index 433b478..b5ddc02 100644 --- a/bin/components/Button.js +++ b/bin/components/Button.js @@ -61,14 +61,14 @@ var Button = function (_DesktopComponent) { Button.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, - onClicked: _propTypes2.default.func, + onClick: _propTypes2.default.func, children: _propTypes2.default.string }, _DesktopComponent2.universalPropTypes); Button.defaultProps = _extends({ enabled: true, visible: true, - onClicked: function onClicked() {}, + onClick: function onClick() {}, children: '' }, _DesktopComponent2.universalDefaultProps); diff --git a/bin/components/Checkbox.js b/bin/components/Checkbox.js index 5d2ca34..8582ee9 100644 --- a/bin/components/Checkbox.js +++ b/bin/components/Checkbox.js @@ -62,7 +62,7 @@ Checkbox.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, checked: _propTypes2.default.bool, - onToggled: _propTypes2.default.func, + onToggle: _propTypes2.default.func, children: _propTypes2.default.string }, _DesktopComponent2.universalPropTypes); @@ -70,7 +70,7 @@ Checkbox.defaultProps = _extends({ enabled: true, visible: true, checked: false, - onToggled: function onToggled() {}, + onToggle: function onToggle() {}, children: '' }, _DesktopComponent2.universalDefaultProps); diff --git a/bin/components/ColorButton.js b/bin/components/ColorButton.js index 3f7794b..aaac564 100644 --- a/bin/components/ColorButton.js +++ b/bin/components/ColorButton.js @@ -142,12 +142,12 @@ var ColorButton = function (_DesktopComponent) { ColorButton.PropTypes = _extends({ color: _propTypes2.default.string, - onChanged: _propTypes2.default.func + onChange: _propTypes2.default.func }, _DesktopComponent2.universalPropTypes); ColorButton.defaultProps = _extends({ color: 'black', - onChanged: function onChanged() {} + onChange: function onChange() {} }, _DesktopComponent2.universalDefaultProps); exports.default = ColorButton; \ No newline at end of file diff --git a/bin/components/Combobox.js b/bin/components/Combobox.js index 2b6cfbd..c9d2e79 100644 --- a/bin/components/Combobox.js +++ b/bin/components/Combobox.js @@ -62,14 +62,14 @@ Combobox.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, selected: _propTypes2.default.number, - onSelected: _propTypes2.default.func + onSelect: _propTypes2.default.func }, _DesktopComponent3.universalPropTypes); Combobox.defaultProps = _extends({ enabled: true, visible: true, selected: -1, - onSelected: function onSelected() {} + onSelect: function onSelect() {} }, _DesktopComponent3.universalDefaultProps); Combobox.Item = function (_DesktopComponent2) { diff --git a/bin/components/DesktopComponent.js b/bin/components/DesktopComponent.js index 226a6f4..cbc68ca 100644 --- a/bin/components/DesktopComponent.js +++ b/bin/components/DesktopComponent.js @@ -21,6 +21,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +var functionMappings = { + onChange: 'onChanged', + onClose: 'onClosing', + onClick: 'onClicked', + onToggle: 'onToggled', + onSelect: 'onSelected', + onContentSizeChange: 'onContentSizeChanged', + onPositionChange: 'onPositionChanged' +}; + var DesktopComponent = function () { function DesktopComponent(root, props) { _classCallCheck(this, DesktopComponent); @@ -132,17 +142,18 @@ var DesktopComponent = function () { // normal props if (oldProps[prop] !== newProps[prop]) { if (typeof newProps[prop] === 'function') { - if (typeof _this.eventParameter[prop] === 'function') { - // if we don't have a property, then we use a function, so handle that - _this.element[prop](function () { - return newProps[prop](_this.eventParameter[prop]()); + var translatedProp = functionMappings[prop]; // translate React function names in libui names + if (typeof _this.eventParameter[translatedProp] === 'function') { + // if we don't have a translatedProperty, then we use a function, so handle that + _this.element[translatedProp](function () { + return newProps[prop](_this.eventParameter[translatedProp]()); }); - } else if (_this.eventParameter[prop] !== '') { - _this.element[prop](function () { - return newProps[prop](_this.element[_this.eventParameter[prop]]); + } else if (_this.eventParameter[translatedProp] !== '') { + _this.element[translatedProp](function () { + return newProps[prop](_this.element[_this.eventParameter[translatedProp]]); }); } else { - _this.element[prop](newProps[prop]); + _this.element[translatedProp](newProps[prop]); } } else if (prop == 'children') { if (_this.exists(_this.childName)) { @@ -170,17 +181,18 @@ var DesktopComponent = function () { var _loop2 = function _loop2(prop) { // normal props if (typeof props[prop] === 'function') { - if (typeof _this2.eventParameter[prop] === 'function') { + var translatedProp = functionMappings[prop]; // translate React function names in libui names + if (typeof _this2.eventParameter[translatedProp] === 'function') { // if we don't have a property, then we use a function, so handle that - _this2.element[prop](function () { - return props[prop](_this2.eventParameter[prop]()); + _this2.element[translatedProp](function () { + return props[prop](_this2.eventParameter[translatedProp]()); }); - } else if (_this2.eventParameter[prop] !== '') { - _this2.element[prop](function () { - return props[prop](_this2.element[_this2.eventParameter[prop]]); + } else if (_this2.eventParameter[translatedProp] !== '') { + _this2.element[translatedProp](function () { + return props[prop](_this2.element[_this2.eventParameter[translatedProp]]); }); } else { - _this2.element[prop](props[prop]); + _this2.element[translatedProp](props[prop]); } } else if (prop == 'children') { if (_this2.exists(_this2.childName)) { diff --git a/bin/components/EditableCombobox.js b/bin/components/EditableCombobox.js index 443760a..84c5d87 100644 --- a/bin/components/EditableCombobox.js +++ b/bin/components/EditableCombobox.js @@ -62,14 +62,14 @@ EditableCombobox.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, text: _propTypes2.default.string, - onChanged: _propTypes2.default.func + onChange: _propTypes2.default.func }, _DesktopComponent3.universalPropTypes); EditableCombobox.defaultProps = _extends({ enabled: true, visible: true, text: '', - onChanged: function onChanged() {} + onChange: function onChange() {} }, _DesktopComponent3.universalDefaultProps); EditableCombobox.Item = function (_DesktopComponent2) { diff --git a/bin/components/Entry.js b/bin/components/Entry.js index ef49d77..72348e0 100644 --- a/bin/components/Entry.js +++ b/bin/components/Entry.js @@ -62,7 +62,7 @@ Entry.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, readOnly: _propTypes2.default.bool, - onChanged: _propTypes2.default.func, + onChange: _propTypes2.default.func, children: _propTypes2.default.string }, _DesktopComponent2.universalPropTypes); @@ -70,7 +70,7 @@ Entry.defaultProps = _extends({ enabled: true, visible: true, readOnly: false, - onChanged: function onChanged() {}, + onChange: function onChange() {}, children: '' }, _DesktopComponent2.universalDefaultProps); diff --git a/bin/components/FontButton.js b/bin/components/FontButton.js index fb99155..25e28ba 100644 --- a/bin/components/FontButton.js +++ b/bin/components/FontButton.js @@ -60,11 +60,11 @@ var FontButton = function (_DesktopComponent) { }(_DesktopComponent3.default); FontButton.PropTypes = _extends({ - onChanged: _propTypes2.default.func + onChange: _propTypes2.default.func }, _DesktopComponent2.universalPropTypes); FontButton.defaultProps = _extends({ - onChanged: function onChanged() {} + onChange: function onChange() {} }, _DesktopComponent2.universalDefaultProps); exports.default = FontButton; \ No newline at end of file diff --git a/bin/components/MenuBar.js b/bin/components/MenuBar.js index 29f1b22..54e53b5 100644 --- a/bin/components/MenuBar.js +++ b/bin/components/MenuBar.js @@ -102,14 +102,14 @@ MenuBar.Item.PropTypes = _extends({ children: _propTypes2.default.string, checked: _propTypes2.default.bool, type: _propTypes2.default.oneOf(['Check', 'Quit', 'About', 'Preferences', 'Separator', 'Item']), - onClicked: _propTypes2.default.func + onClick: _propTypes2.default.func }, _DesktopComponent3.universalPropTypes); MenuBar.Item.defaultProps = _extends({ children: '', checked: false, type: 'Item', - onClicked: function onClicked() {} + onClick: function onClick() {} }, _DesktopComponent3.universalDefaultProps); exports.default = MenuBar; \ No newline at end of file diff --git a/bin/components/MultilineEntry.js b/bin/components/MultilineEntry.js index e40ab23..f90ffd2 100644 --- a/bin/components/MultilineEntry.js +++ b/bin/components/MultilineEntry.js @@ -62,7 +62,7 @@ MultilineEntry.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, readOnly: _propTypes2.default.bool, - onChanged: _propTypes2.default.func, + onChange: _propTypes2.default.func, children: _propTypes2.default.string }, _DesktopComponent2.universalPropTypes); @@ -70,7 +70,7 @@ MultilineEntry.defaultProps = _extends({ enabled: true, visible: true, readOnly: false, - onChanged: function onChanged() {}, + onChange: function onChange() {}, children: '' }, _DesktopComponent2.universalDefaultProps); diff --git a/bin/components/PasswordEntry.js b/bin/components/PasswordEntry.js index 6b0737d..901efa5 100644 --- a/bin/components/PasswordEntry.js +++ b/bin/components/PasswordEntry.js @@ -62,7 +62,7 @@ PasswordEntry.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, readOnly: _propTypes2.default.bool, - onChanged: _propTypes2.default.func, + onChange: _propTypes2.default.func, children: _propTypes2.default.string }, _DesktopComponent2.universalPropTypes); @@ -70,7 +70,7 @@ PasswordEntry.defaultProps = _extends({ enabled: true, visible: true, readOnly: false, - onChanged: function onChanged() {}, + onChange: function onChange() {}, children: '' }, _DesktopComponent2.universalDefaultProps); diff --git a/bin/components/RadioButton.js b/bin/components/RadioButton.js index dc1176f..407396a 100644 --- a/bin/components/RadioButton.js +++ b/bin/components/RadioButton.js @@ -62,14 +62,14 @@ RadioButton.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, selected: _propTypes2.default.number, - onSelected: _propTypes2.default.func + onSelect: _propTypes2.default.func }, _DesktopComponent3.universalPropTypes); RadioButton.defaultProps = _extends({ enabled: true, visible: true, selected: -1, - onSelected: function onSelected() {} + onSelect: function onSelect() {} }, _DesktopComponent3.universalDefaultProps); RadioButton.Item = function (_DesktopComponent2) { diff --git a/bin/components/Slider.js b/bin/components/Slider.js index 118e46a..e8d556a 100644 --- a/bin/components/Slider.js +++ b/bin/components/Slider.js @@ -61,14 +61,14 @@ Slider.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, value: _propTypes2.default.number, - onChanged: _propTypes2.default.func + onChange: _propTypes2.default.func }, _DesktopComponent2.universalPropTypes); Slider.defaultProps = _extends({ enabled: true, visible: true, value: 0, - onChanged: function onChanged() {} + onChange: function onChange() {} }, _DesktopComponent2.universalDefaultProps); exports.default = Slider; \ No newline at end of file diff --git a/bin/components/Spinbox.js b/bin/components/Spinbox.js index 6966b5a..9a6e13d 100644 --- a/bin/components/Spinbox.js +++ b/bin/components/Spinbox.js @@ -61,14 +61,14 @@ Spinbox.PropTypes = _extends({ enabled: _propTypes2.default.bool, visible: _propTypes2.default.bool, value: _propTypes2.default.number, - onChanged: _propTypes2.default.func + onChange: _propTypes2.default.func }, _DesktopComponent2.universalPropTypes); Spinbox.defaultProps = _extends({ enabled: true, visible: true, value: 0, - onChanged: function onChanged() {} + onChange: function onChange() {} }, _DesktopComponent2.universalDefaultProps); exports.default = Spinbox; \ No newline at end of file diff --git a/bin/components/Window.js b/bin/components/Window.js index 248a96f..9c0e16d 100644 --- a/bin/components/Window.js +++ b/bin/components/Window.js @@ -52,7 +52,8 @@ var Window = function (_DesktopComponent) { _createClass(Window, [{ key: 'update', value: function update(oldProps, newProps) { - if (!this.exists(this.element)) // if we haven't defined it yet, don't set props + if (!this.exists(this.element)) + // if we haven't defined it yet, don't set props return; if (newProps.title !== oldProps.title) { this.element.title = newProps.title; @@ -94,7 +95,7 @@ var Window = function (_DesktopComponent) { // we need to create a window here so that menu can go first this.element = new _libuiNode2.default.UiWindow(this.props.title, this.props.size.w, this.props.size.h, this.props.menuBar); this.element.onClosing(function () { - _this2.props.onClosing(); + _this2.props.onClose(); _this2.element.close(); if (_this2.props.lastWindow) { (0, _eventLoop.stop)(); @@ -111,13 +112,13 @@ var Window = function (_DesktopComponent) { } this.element.onPositionChanged(function () { - _this2.props.onPositionChanged({ + _this2.props.onPositionChange({ x: _this2.element.position.x, y: _this2.element.position.y }); }); this.element.onContentSizeChanged(function () { - _this2.props.onContentSizeChanged({ + _this2.props.onContentSizeChange({ h: _this2.element.position.h, w: _this2.element.position.w }); @@ -149,9 +150,9 @@ Window.PropTypes = { //centered: PropTypes.bool, lastWindow: _propTypes2.default.bool, closed: _propTypes2.default.bool, - onClosing: _propTypes2.default.func, - onPositionChanged: _propTypes2.default.func, - onContentSizeChanged: _propTypes2.default.func + onClose: _propTypes2.default.func, + onPositionChange: _propTypes2.default.func, + onContentSizeChange: _propTypes2.default.func }; Window.defaultProps = { @@ -171,9 +172,9 @@ Window.defaultProps = { //centered: true, lastWindow: true, closed: false, - onClosing: function onClosing() {}, - onPositionChanged: function onPositionChanged() {}, - onContentSizeChanged: function onContentSizeChanged() {} + onClose: function onClose() {}, + onPositionChange: function onPositionChange() {}, + onContentSizeChange: function onContentSizeChange() {} }; exports.default = Window; \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index b313f79..7c98e69 100644 --- a/docs/README.md +++ b/docs/README.md @@ -67,7 +67,7 @@ class Example extends Component { return ( - diff --git a/docs/component_APIs/button.md b/docs/component_APIs/button.md index 47f6419..ad9bdfc 100644 --- a/docs/component_APIs/button.md +++ b/docs/component_APIs/button.md @@ -29,7 +29,7 @@ render(); - [children](#children) - [enabled](#enabled) - [visible](#visible) -- [onClicked](#onClicked) +- [onClick](#onClick) ## Reference @@ -57,7 +57,7 @@ Whether the button can be seen. | --- | --- | | bool | No | -### onClicked +### onClick Called when the button is clicked. diff --git a/docs/component_APIs/checkbox.md b/docs/component_APIs/checkbox.md index 7418365..624e643 100644 --- a/docs/component_APIs/checkbox.md +++ b/docs/component_APIs/checkbox.md @@ -28,7 +28,7 @@ render(); - [enabled](#enabled) - [visible](#visible) - [checked](#checked) -- [onToggled](#onToggled) +- [onToggle](#onToggle) ## Reference @@ -64,7 +64,7 @@ Whether the checkbox is checked or not. | --- | --- | | bool | No | -### onToggled +### onToggle Called when the checkbox is clicked. The current checkbox state is passed as an argument. diff --git a/docs/component_APIs/color_button.md b/docs/component_APIs/color_button.md index aca5e01..5e4e0fc 100644 --- a/docs/component_APIs/color_button.md +++ b/docs/component_APIs/color_button.md @@ -25,7 +25,7 @@ render(); ## Props - [color](#color) -- [onChanged](#onChanged) +- [onChange](#onChange) ## Reference @@ -44,7 +44,7 @@ A full list of names can be found [here](https://www.w3schools.com/colors/colors | --- | --- | | string | No | -### onClicked +### onClick Called when the color is changed for the ColorButton. The current color is passed as an object of RGBA. diff --git a/docs/component_APIs/menu_item.md b/docs/component_APIs/menu_item.md index 7661ce3..1470437 100644 --- a/docs/component_APIs/menu_item.md +++ b/docs/component_APIs/menu_item.md @@ -28,7 +28,7 @@ render(); - [type](#type) - [children](#children) - [checked](#checked) -- [onClicked](#onClicked) +- [onClick](#onClick) ## Reference @@ -63,7 +63,7 @@ If the type is `Check`, then set whether it is checked or not. | --- | --- | | bool | No | -### onClicked +### onClick Called when the menu item is clicked. If the type is `Check`, then it passes whether it is checked as an argument. diff --git a/docs/component_APIs/picker.md b/docs/component_APIs/picker.md index 9758231..d50d2c6 100644 --- a/docs/component_APIs/picker.md +++ b/docs/component_APIs/picker.md @@ -76,7 +76,7 @@ What text is selected/typed if the picker *is* editable. | --- | --- | --- | | bool | No | Yes | -### onSelected +### onSelect When a *non-editable* Picker is changed. The current selection is passed as an argument. @@ -84,7 +84,7 @@ When a *non-editable* Picker is changed. The current selection is passed as an a | --- | --- | --- | | function(selection) | No | No | -### onChanged +### onChange When an *editable* Picker is changed. The current text is passed as an argument. diff --git a/docs/component_APIs/radio_buttons.md b/docs/component_APIs/radio_buttons.md index 4923d69..cc05650 100644 --- a/docs/component_APIs/radio_buttons.md +++ b/docs/component_APIs/radio_buttons.md @@ -32,7 +32,7 @@ render(); - [enabled](#enabled) - [visible](#visible) - [selected](#selected) -- [onSelected](#onSelected) +- [onSelect](#onSelect) ## Reference @@ -60,7 +60,7 @@ What RadioButton is selected, zero-indexed. -1 means nothing is selected. | --- | --- | | number | No | -### onSelected +### onSelect Called when a RadioButton is selected. The number selected is passed as an argument. diff --git a/docs/component_APIs/slider.md b/docs/component_APIs/slider.md index b3aefd9..abc89a8 100644 --- a/docs/component_APIs/slider.md +++ b/docs/component_APIs/slider.md @@ -27,7 +27,7 @@ render(); - [enabled](#enabled) - [visible](#visible) - [value](#value) -- [onChanged](#onChanged) +- [onChange](#onChange) ## Reference @@ -55,7 +55,7 @@ The current value of the Slider (0-100). | --- | --- | | number | No | -### onChanged +### onChange Called when the value of the slider is changed. The current value is passed as an argument. diff --git a/docs/component_APIs/spinbox.md b/docs/component_APIs/spinbox.md index b410d95..572362f 100644 --- a/docs/component_APIs/spinbox.md +++ b/docs/component_APIs/spinbox.md @@ -27,7 +27,7 @@ render(); - [enabled](#enabled) - [visible](#visible) - [value](#value) -- [onChanged](#onChanged) +- [onChange](#onChange) ## Reference @@ -55,7 +55,7 @@ What the value of the Spinbox is set to. | --- | --- | | number | No | -### onChanged +### onChange When the Spinbox value is changed. The current value is passed as a parameter. diff --git a/docs/component_APIs/textinput.md b/docs/component_APIs/textinput.md index 3a3cdf6..745bdf3 100644 --- a/docs/component_APIs/textinput.md +++ b/docs/component_APIs/textinput.md @@ -30,7 +30,7 @@ render(); - [readOnly](#readOnly) - [secure](#secure) - [multiline](#multiline) -- [onChanged](#onChanged) +- [onChange](#onChange) ## Reference @@ -82,7 +82,7 @@ Whether multiple lines can be inputted into the TextInput. | --- | --- | | bool | No | -### onChanged +### onChange Called when the TextInput text is changed. The new text is passed as an argument. diff --git a/docs/component_APIs/window.md b/docs/component_APIs/window.md index 15d1724..b887c38 100644 --- a/docs/component_APIs/window.md +++ b/docs/component_APIs/window.md @@ -33,9 +33,9 @@ render(); - [borderless](#borderless) - [lastWindow](#lastWindow) - [closed](#closed) -- [onClosing](#onClosing) -- [onPositionChanged](#onPositionChanged) -- [onContentSizeChanged](#onContentSizeChanged) +- [onClose](#onClose) +- [onPositionChange](#onPositionChange) +- [onContentSizeChange](#onContentSizeChange) ## Reference @@ -111,7 +111,7 @@ Whether the window is closed. If set to closed, then the window will be closed. | --- | --- | | bool | No | -### onClosing +### onClose Called when the window is closed. @@ -119,7 +119,7 @@ Called when the window is closed. | --- | --- | | function() | No | -### onPositionChanged +### onPositionChange Called when the window position is changed. The new position is passed as an argument, in an object. @@ -127,7 +127,7 @@ Called when the window position is changed. The new position is passed as an arg | --- | --- | | function({x: number, y: number}) | No | -## onContentSizeChanged +## onContentSizeChange Called when the window size is changed by the user. The new size is passed as an argument, in an object. diff --git a/docs/js_example.js b/docs/js_example.js index 96c95ac..da17c59 100644 --- a/docs/js_example.js +++ b/docs/js_example.js @@ -7,7 +7,7 @@ class Example extends Component { return ( - diff --git a/docs/methods/dialog.md b/docs/methods/dialog.md index f5baca5..f999c0f 100644 --- a/docs/methods/dialog.md +++ b/docs/methods/dialog.md @@ -12,7 +12,7 @@ class Example extends Component { return ( -             Dialog('Error', {title: "Message"})}/> +             Dialog('Error', {title: "Message"})}/> ); diff --git a/package.json b/package.json index a84d7fe..18afd50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "proton-native", - "version": "1.0.11", + "version": "1.0.12", "description": "React Native for the desktop, cross compatible", "main": "bin/index.js", "scripts": { diff --git a/src/components/Button.js b/src/components/Button.js index 6329a80..0bb625d 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -27,7 +27,7 @@ class Button extends DesktopComponent { Button.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, - onClicked: PropTypes.func, + onClick: PropTypes.func, children: PropTypes.string, ...universalPropTypes, }; @@ -35,7 +35,7 @@ Button.PropTypes = { Button.defaultProps = { enabled: true, visible: true, - onClicked: () => {}, + onClick: () => {}, children: '', ...universalDefaultProps, }; diff --git a/src/components/Checkbox.js b/src/components/Checkbox.js index c0c9415..e4931d6 100644 --- a/src/components/Checkbox.js +++ b/src/components/Checkbox.js @@ -28,7 +28,7 @@ Checkbox.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, checked: PropTypes.bool, - onToggled: PropTypes.func, + onToggle: PropTypes.func, children: PropTypes.string, ...universalPropTypes, }; @@ -37,7 +37,7 @@ Checkbox.defaultProps = { enabled: true, visible: true, checked: false, - onToggled: () => {}, + onToggle: () => {}, children: '', ...universalDefaultProps, }; diff --git a/src/components/ColorButton.js b/src/components/ColorButton.js index 6285d9a..a7f9101 100644 --- a/src/components/ColorButton.js +++ b/src/components/ColorButton.js @@ -91,13 +91,13 @@ class ColorButton extends DesktopComponent { ColorButton.PropTypes = { color: PropTypes.string, - onChanged: PropTypes.func, + onChange: PropTypes.func, ...universalPropTypes, }; ColorButton.defaultProps = { color: 'black', - onChanged: () => {}, + onChange: () => {}, ...universalDefaultProps, }; diff --git a/src/components/Combobox.js b/src/components/Combobox.js index 65ffca1..8f824a1 100644 --- a/src/components/Combobox.js +++ b/src/components/Combobox.js @@ -28,7 +28,7 @@ Combobox.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, selected: PropTypes.number, - onSelected: PropTypes.func, + onSelect: PropTypes.func, ...universalPropTypes, }; @@ -36,7 +36,7 @@ Combobox.defaultProps = { enabled: true, visible: true, selected: -1, - onSelected: () => {}, + onSelect: () => {}, ...universalDefaultProps, }; diff --git a/src/components/DesktopComponent.js b/src/components/DesktopComponent.js index a7cef53..61221cd 100644 --- a/src/components/DesktopComponent.js +++ b/src/components/DesktopComponent.js @@ -10,6 +10,16 @@ import { import { Menu } from '../'; import PropTypes from 'prop-types'; +const functionMappings = { + onChange: 'onChanged', + onClose: 'onClosing', + onClick: 'onClicked', + onToggle: 'onToggled', + onSelect: 'onSelected', + onContentSizeChange: 'onContentSizeChanged', + onPositionChange: 'onPositionChanged', +}; + class DesktopComponent { constructor(root, props) { this.children = []; @@ -131,17 +141,18 @@ class DesktopComponent { // normal props if (oldProps[prop] !== newProps[prop]) { if (typeof newProps[prop] === 'function') { - if (typeof this.eventParameter[prop] === 'function') { - // if we don't have a property, then we use a function, so handle that - this.element[prop](() => - newProps[prop](this.eventParameter[prop]()) + const translatedProp = functionMappings[prop]; // translate React function names in libui names + if (typeof this.eventParameter[translatedProp] === 'function') { + // if we don't have a translatedProperty, then we use a function, so handle that + this.element[translatedProp](() => + newProps[prop](this.eventParameter[translatedProp]()) ); - } else if (this.eventParameter[prop] !== '') { - this.element[prop](() => - newProps[prop](this.element[this.eventParameter[prop]]) + } else if (this.eventParameter[translatedProp] !== '') { + this.element[translatedProp](() => + newProps[prop](this.element[this.eventParameter[translatedProp]]) ); } else { - this.element[prop](newProps[prop]); + this.element[translatedProp](newProps[prop]); } } else if (prop == 'children') { if (this.exists(this.childName)) { @@ -162,15 +173,18 @@ class DesktopComponent { for (let prop in props) { // normal props if (typeof props[prop] === 'function') { - if (typeof this.eventParameter[prop] === 'function') { + const translatedProp = functionMappings[prop]; // translate React function names in libui names + if (typeof this.eventParameter[translatedProp] === 'function') { // if we don't have a property, then we use a function, so handle that - this.element[prop](() => props[prop](this.eventParameter[prop]())); - } else if (this.eventParameter[prop] !== '') { - this.element[prop](() => - props[prop](this.element[this.eventParameter[prop]]) + this.element[translatedProp](() => + props[prop](this.eventParameter[translatedProp]()) + ); + } else if (this.eventParameter[translatedProp] !== '') { + this.element[translatedProp](() => + props[prop](this.element[this.eventParameter[translatedProp]]) ); } else { - this.element[prop](props[prop]); + this.element[translatedProp](props[prop]); } } else if (prop == 'children') { if (this.exists(this.childName)) { diff --git a/src/components/EditableCombobox.js b/src/components/EditableCombobox.js index e28b963..655bcb4 100644 --- a/src/components/EditableCombobox.js +++ b/src/components/EditableCombobox.js @@ -28,7 +28,7 @@ EditableCombobox.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, text: PropTypes.string, - onChanged: PropTypes.func, + onChange: PropTypes.func, ...universalPropTypes, }; @@ -36,7 +36,7 @@ EditableCombobox.defaultProps = { enabled: true, visible: true, text: '', - onChanged: () => {}, + onChange: () => {}, ...universalDefaultProps, }; diff --git a/src/components/Entry.js b/src/components/Entry.js index 007de12..245796b 100644 --- a/src/components/Entry.js +++ b/src/components/Entry.js @@ -28,7 +28,7 @@ Entry.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, readOnly: PropTypes.bool, - onChanged: PropTypes.func, + onChange: PropTypes.func, children: PropTypes.string, ...universalPropTypes, }; @@ -37,7 +37,7 @@ Entry.defaultProps = { enabled: true, visible: true, readOnly: false, - onChanged: () => {}, + onChange: () => {}, children: '', ...universalDefaultProps, }; diff --git a/src/components/FontButton.js b/src/components/FontButton.js index 51b619b..5346ed3 100644 --- a/src/components/FontButton.js +++ b/src/components/FontButton.js @@ -24,12 +24,12 @@ class FontButton extends DesktopComponent { } FontButton.PropTypes = { - onChanged: PropTypes.func, + onChange: PropTypes.func, ...universalPropTypes, }; FontButton.defaultProps = { - onChanged: () => {}, + onChange: () => {}, ...universalDefaultProps, }; diff --git a/src/components/MenuBar.js b/src/components/MenuBar.js index dcc07d0..fda16bf 100644 --- a/src/components/MenuBar.js +++ b/src/components/MenuBar.js @@ -64,7 +64,7 @@ MenuBar.Item.PropTypes = { 'Separator', 'Item', ]), - onClicked: PropTypes.func, + onClick: PropTypes.func, ...universalPropTypes, }; @@ -72,7 +72,7 @@ MenuBar.Item.defaultProps = { children: '', checked: false, type: 'Item', - onClicked: () => {}, + onClick: () => {}, ...universalDefaultProps, }; diff --git a/src/components/MultilineEntry.js b/src/components/MultilineEntry.js index fe3caf9..234a144 100644 --- a/src/components/MultilineEntry.js +++ b/src/components/MultilineEntry.js @@ -28,7 +28,7 @@ MultilineEntry.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, readOnly: PropTypes.bool, - onChanged: PropTypes.func, + onChange: PropTypes.func, children: PropTypes.string, ...universalPropTypes, }; @@ -37,7 +37,7 @@ MultilineEntry.defaultProps = { enabled: true, visible: true, readOnly: false, - onChanged: () => {}, + onChange: () => {}, children: '', ...universalDefaultProps, }; diff --git a/src/components/PasswordEntry.js b/src/components/PasswordEntry.js index e697754..da33648 100644 --- a/src/components/PasswordEntry.js +++ b/src/components/PasswordEntry.js @@ -28,7 +28,7 @@ PasswordEntry.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, readOnly: PropTypes.bool, - onChanged: PropTypes.func, + onChange: PropTypes.func, children: PropTypes.string, ...universalPropTypes, }; @@ -37,7 +37,7 @@ PasswordEntry.defaultProps = { enabled: true, visible: true, readOnly: false, - onChanged: () => {}, + onChange: () => {}, children: '', ...universalDefaultProps, }; diff --git a/src/components/RadioButton.js b/src/components/RadioButton.js index 944d8ca..2b10441 100644 --- a/src/components/RadioButton.js +++ b/src/components/RadioButton.js @@ -28,7 +28,7 @@ RadioButton.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, selected: PropTypes.number, - onSelected: PropTypes.func, + onSelect: PropTypes.func, ...universalPropTypes, }; @@ -36,7 +36,7 @@ RadioButton.defaultProps = { enabled: true, visible: true, selected: -1, - onSelected: () => {}, + onSelect: () => {}, ...universalDefaultProps, }; diff --git a/src/components/Slider.js b/src/components/Slider.js index 75e0776..eb1f688 100644 --- a/src/components/Slider.js +++ b/src/components/Slider.js @@ -27,7 +27,7 @@ Slider.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, value: PropTypes.number, - onChanged: PropTypes.func, + onChange: PropTypes.func, ...universalPropTypes, }; @@ -35,7 +35,7 @@ Slider.defaultProps = { enabled: true, visible: true, value: 0, - onChanged: () => {}, + onChange: () => {}, ...universalDefaultProps, }; diff --git a/src/components/Spinbox.js b/src/components/Spinbox.js index 1daa13a..7d6c988 100644 --- a/src/components/Spinbox.js +++ b/src/components/Spinbox.js @@ -27,7 +27,7 @@ Spinbox.PropTypes = { enabled: PropTypes.bool, visible: PropTypes.bool, value: PropTypes.number, - onChanged: PropTypes.func, + onChange: PropTypes.func, ...universalPropTypes, }; @@ -35,7 +35,7 @@ Spinbox.defaultProps = { enabled: true, visible: true, value: 0, - onChanged: () => {}, + onChange: () => {}, ...universalDefaultProps, }; diff --git a/src/components/Window.js b/src/components/Window.js index 06d058d..ee4844e 100644 --- a/src/components/Window.js +++ b/src/components/Window.js @@ -64,7 +64,7 @@ class Window extends DesktopComponent { this.props.menuBar ); this.element.onClosing(() => { - this.props.onClosing(); + this.props.onClose(); this.element.close(); if (this.props.lastWindow) { stop(); @@ -81,13 +81,13 @@ class Window extends DesktopComponent { } this.element.onPositionChanged(() => { - this.props.onPositionChanged({ + this.props.onPositionChange({ x: this.element.position.x, y: this.element.position.y, }); }); this.element.onContentSizeChanged(() => { - this.props.onContentSizeChanged({ + this.props.onContentSizeChange({ h: this.element.position.h, w: this.element.position.w, }); @@ -116,9 +116,9 @@ Window.PropTypes = { //centered: PropTypes.bool, lastWindow: PropTypes.bool, closed: PropTypes.bool, - onClosing: PropTypes.func, - onPositionChanged: PropTypes.func, - onContentSizeChanged: PropTypes.func, + onClose: PropTypes.func, + onPositionChange: PropTypes.func, + onContentSizeChange: PropTypes.func, }; Window.defaultProps = { @@ -138,9 +138,9 @@ Window.defaultProps = { //centered: true, lastWindow: true, closed: false, - onClosing: () => {}, - onPositionChanged: () => {}, - onContentSizeChanged: () => {}, + onClose: () => {}, + onPositionChange: () => {}, + onContentSizeChange: () => {}, }; export default Window;