ywana-core8 0.0.901 → 0.0.902
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/index.cjs +31 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +31 -26
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +31 -26
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/html/button.js +52 -24
package/dist/index.modern.js
CHANGED
@@ -433,40 +433,45 @@ var Button = function Button(_ref) {
|
|
433
433
|
action: click
|
434
434
|
}) : null, /*#__PURE__*/React.createElement(Text, null, label));
|
435
435
|
};
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Action Button
|
439
|
+
*/
|
436
440
|
var ActionButton = function ActionButton(props) {
|
437
|
-
var
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
+
var execute = function execute() {
|
442
|
+
try {
|
443
|
+
var _temp = function () {
|
444
|
+
if (states[_state]) {
|
445
|
+
return Promise.resolve(states[_state].action()).then(function (newState) {
|
446
|
+
if (newState) setState(newState);
|
447
|
+
});
|
448
|
+
}
|
449
|
+
}();
|
450
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
451
|
+
} catch (e) {
|
452
|
+
return Promise.reject(e);
|
453
|
+
}
|
454
|
+
};
|
455
|
+
var states = props.states,
|
456
|
+
state = props.state,
|
441
457
|
className = props.className;
|
442
|
-
var _useState = useState(
|
458
|
+
var _useState = useState(),
|
443
459
|
_state = _useState[0],
|
444
460
|
setState = _useState[1];
|
445
461
|
useEffect(function () {
|
446
462
|
setState(state);
|
447
463
|
}, [state]);
|
448
|
-
function
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
var
|
453
|
-
|
454
|
-
|
455
|
-
actionIcon = icon;
|
456
|
-
break;
|
457
|
-
case "running":
|
458
|
-
actionIcon = "rotate_right";
|
459
|
-
break;
|
460
|
-
case "success":
|
461
|
-
actionIcon = "task_alt";
|
462
|
-
break;
|
463
|
-
case "error":
|
464
|
-
actionIcon = "error";
|
465
|
-
break;
|
466
|
-
}
|
464
|
+
useEffect(function () {
|
465
|
+
if (states[_state] && states[_state].autoexec) execute();
|
466
|
+
}, [_state]);
|
467
|
+
if (!_state) return null;
|
468
|
+
var _states$_state = states[_state],
|
469
|
+
icon = _states$_state.icon,
|
470
|
+
label = _states$_state.label;
|
467
471
|
return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
468
|
-
icon:
|
469
|
-
|
472
|
+
icon: icon,
|
473
|
+
label: label,
|
474
|
+
action: execute,
|
470
475
|
className: className + " action-btn " + _state
|
471
476
|
}));
|
472
477
|
};
|