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