@wise/dynamic-flow-client 3.20.2 → 3.21.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.
package/build/main.js
CHANGED
|
@@ -14732,10 +14732,9 @@ var priorities = {
|
|
|
14732
14732
|
positive: "primary",
|
|
14733
14733
|
negative: "primary"
|
|
14734
14734
|
};
|
|
14735
|
-
var getButtonPriority = (
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
|
|
14735
|
+
var getButtonPriority = (control, action) => {
|
|
14736
|
+
const actionType = action ? action.type : void 0;
|
|
14737
|
+
return control != null ? control : actionType ? priorities[actionType] : "secondary";
|
|
14739
14738
|
};
|
|
14740
14739
|
var contextToType = {
|
|
14741
14740
|
positive: "positive",
|
|
@@ -14750,13 +14749,16 @@ var actionTypeToType = {
|
|
|
14750
14749
|
positive: "positive",
|
|
14751
14750
|
negative: "negative"
|
|
14752
14751
|
};
|
|
14753
|
-
var getButtonType = (
|
|
14754
|
-
if (
|
|
14755
|
-
return contextToType[
|
|
14752
|
+
var getButtonType = (context, action) => {
|
|
14753
|
+
if (context) {
|
|
14754
|
+
return contextToType[context];
|
|
14756
14755
|
}
|
|
14757
|
-
const actionType =
|
|
14756
|
+
const actionType = action ? action.type : void 0;
|
|
14758
14757
|
return actionType ? actionTypeToType[actionType] : "accent";
|
|
14759
14758
|
};
|
|
14759
|
+
var getButtonTypeFromContext = (context) => {
|
|
14760
|
+
return context ? contextToType[context] : "accent";
|
|
14761
|
+
};
|
|
14760
14762
|
var getButtonSize = (size) => {
|
|
14761
14763
|
switch (size) {
|
|
14762
14764
|
case "xs":
|
|
@@ -14774,13 +14776,23 @@ var getButtonSize = (size) => {
|
|
|
14774
14776
|
// src/legacy/layout/button/DynamicButton.tsx
|
|
14775
14777
|
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
14776
14778
|
function DynamicButton(props) {
|
|
14777
|
-
|
|
14779
|
+
return props.component.behavior ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DynamicButtonWithBehavior, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DynamicButtonWithoutBehavior, __spreadValues({}, props));
|
|
14780
|
+
}
|
|
14781
|
+
function DynamicButtonWithoutBehavior(props) {
|
|
14782
|
+
var _a, _b;
|
|
14778
14783
|
const { component, onAction } = props;
|
|
14779
14784
|
const componentAction = component.action;
|
|
14780
|
-
const type = getButtonType(component);
|
|
14781
|
-
const priority = getButtonPriority(component);
|
|
14785
|
+
const type = getButtonType(component.context, componentAction);
|
|
14786
|
+
const priority = getButtonPriority(component.control, componentAction);
|
|
14782
14787
|
const { loading } = useDynamicFlow();
|
|
14783
14788
|
const className = getMargin2(component.margin || "md");
|
|
14789
|
+
const disabled = loading || component.disabled || (componentAction == null ? void 0 : componentAction.disabled);
|
|
14790
|
+
const title = (_b = (_a = component.title) != null ? _a : componentAction == null ? void 0 : componentAction.title) != null ? _b : "";
|
|
14791
|
+
const onClick = () => {
|
|
14792
|
+
if (componentAction) {
|
|
14793
|
+
onAction(componentAction);
|
|
14794
|
+
}
|
|
14795
|
+
};
|
|
14784
14796
|
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
14785
14797
|
import_components42.Button,
|
|
14786
14798
|
{
|
|
@@ -14789,9 +14801,41 @@ function DynamicButton(props) {
|
|
|
14789
14801
|
priority,
|
|
14790
14802
|
block: true,
|
|
14791
14803
|
className,
|
|
14792
|
-
disabled
|
|
14793
|
-
onClick
|
|
14794
|
-
children:
|
|
14804
|
+
disabled,
|
|
14805
|
+
onClick,
|
|
14806
|
+
children: title
|
|
14807
|
+
}
|
|
14808
|
+
);
|
|
14809
|
+
}
|
|
14810
|
+
function DynamicButtonWithBehavior(props) {
|
|
14811
|
+
var _a, _b;
|
|
14812
|
+
const { component } = props;
|
|
14813
|
+
const type = getButtonTypeFromContext(component.context);
|
|
14814
|
+
const priority = (_a = component.control) != null ? _a : "secondary";
|
|
14815
|
+
const { loading } = useDynamicFlow();
|
|
14816
|
+
const className = getMargin2(component.margin || "md");
|
|
14817
|
+
const disabled = loading || component.disabled;
|
|
14818
|
+
const title = (_b = component.title) != null ? _b : "";
|
|
14819
|
+
const onClick = () => {
|
|
14820
|
+
const { behavior } = component;
|
|
14821
|
+
if (behavior == null ? void 0 : behavior.action) {
|
|
14822
|
+
props.onAction(behavior.action);
|
|
14823
|
+
}
|
|
14824
|
+
if (behavior == null ? void 0 : behavior.link) {
|
|
14825
|
+
window.open(behavior.link.url, "_blank");
|
|
14826
|
+
}
|
|
14827
|
+
};
|
|
14828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
14829
|
+
import_components42.Button,
|
|
14830
|
+
{
|
|
14831
|
+
size: getButtonSize(component.size),
|
|
14832
|
+
type: priority === "tertiary" ? void 0 : type,
|
|
14833
|
+
priority,
|
|
14834
|
+
block: true,
|
|
14835
|
+
className,
|
|
14836
|
+
disabled,
|
|
14837
|
+
onClick,
|
|
14838
|
+
children: title
|
|
14795
14839
|
}
|
|
14796
14840
|
);
|
|
14797
14841
|
}
|