@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.mjs
CHANGED
|
@@ -14714,10 +14714,9 @@ var priorities = {
|
|
|
14714
14714
|
positive: "primary",
|
|
14715
14715
|
negative: "primary"
|
|
14716
14716
|
};
|
|
14717
|
-
var getButtonPriority = (
|
|
14718
|
-
|
|
14719
|
-
|
|
14720
|
-
return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
|
|
14717
|
+
var getButtonPriority = (control, action) => {
|
|
14718
|
+
const actionType = action ? action.type : void 0;
|
|
14719
|
+
return control != null ? control : actionType ? priorities[actionType] : "secondary";
|
|
14721
14720
|
};
|
|
14722
14721
|
var contextToType = {
|
|
14723
14722
|
positive: "positive",
|
|
@@ -14732,13 +14731,16 @@ var actionTypeToType = {
|
|
|
14732
14731
|
positive: "positive",
|
|
14733
14732
|
negative: "negative"
|
|
14734
14733
|
};
|
|
14735
|
-
var getButtonType = (
|
|
14736
|
-
if (
|
|
14737
|
-
return contextToType[
|
|
14734
|
+
var getButtonType = (context, action) => {
|
|
14735
|
+
if (context) {
|
|
14736
|
+
return contextToType[context];
|
|
14738
14737
|
}
|
|
14739
|
-
const actionType =
|
|
14738
|
+
const actionType = action ? action.type : void 0;
|
|
14740
14739
|
return actionType ? actionTypeToType[actionType] : "accent";
|
|
14741
14740
|
};
|
|
14741
|
+
var getButtonTypeFromContext = (context) => {
|
|
14742
|
+
return context ? contextToType[context] : "accent";
|
|
14743
|
+
};
|
|
14742
14744
|
var getButtonSize = (size) => {
|
|
14743
14745
|
switch (size) {
|
|
14744
14746
|
case "xs":
|
|
@@ -14756,13 +14758,23 @@ var getButtonSize = (size) => {
|
|
|
14756
14758
|
// src/legacy/layout/button/DynamicButton.tsx
|
|
14757
14759
|
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
14758
14760
|
function DynamicButton(props) {
|
|
14759
|
-
|
|
14761
|
+
return props.component.behavior ? /* @__PURE__ */ jsx72(DynamicButtonWithBehavior, __spreadValues({}, props)) : /* @__PURE__ */ jsx72(DynamicButtonWithoutBehavior, __spreadValues({}, props));
|
|
14762
|
+
}
|
|
14763
|
+
function DynamicButtonWithoutBehavior(props) {
|
|
14764
|
+
var _a, _b;
|
|
14760
14765
|
const { component, onAction } = props;
|
|
14761
14766
|
const componentAction = component.action;
|
|
14762
|
-
const type = getButtonType(component);
|
|
14763
|
-
const priority = getButtonPriority(component);
|
|
14767
|
+
const type = getButtonType(component.context, componentAction);
|
|
14768
|
+
const priority = getButtonPriority(component.control, componentAction);
|
|
14764
14769
|
const { loading } = useDynamicFlow();
|
|
14765
14770
|
const className = getMargin2(component.margin || "md");
|
|
14771
|
+
const disabled = loading || component.disabled || (componentAction == null ? void 0 : componentAction.disabled);
|
|
14772
|
+
const title = (_b = (_a = component.title) != null ? _a : componentAction == null ? void 0 : componentAction.title) != null ? _b : "";
|
|
14773
|
+
const onClick = () => {
|
|
14774
|
+
if (componentAction) {
|
|
14775
|
+
onAction(componentAction);
|
|
14776
|
+
}
|
|
14777
|
+
};
|
|
14766
14778
|
return /* @__PURE__ */ jsx72(
|
|
14767
14779
|
Button6,
|
|
14768
14780
|
{
|
|
@@ -14771,9 +14783,41 @@ function DynamicButton(props) {
|
|
|
14771
14783
|
priority,
|
|
14772
14784
|
block: true,
|
|
14773
14785
|
className,
|
|
14774
|
-
disabled
|
|
14775
|
-
onClick
|
|
14776
|
-
children:
|
|
14786
|
+
disabled,
|
|
14787
|
+
onClick,
|
|
14788
|
+
children: title
|
|
14789
|
+
}
|
|
14790
|
+
);
|
|
14791
|
+
}
|
|
14792
|
+
function DynamicButtonWithBehavior(props) {
|
|
14793
|
+
var _a, _b;
|
|
14794
|
+
const { component } = props;
|
|
14795
|
+
const type = getButtonTypeFromContext(component.context);
|
|
14796
|
+
const priority = (_a = component.control) != null ? _a : "secondary";
|
|
14797
|
+
const { loading } = useDynamicFlow();
|
|
14798
|
+
const className = getMargin2(component.margin || "md");
|
|
14799
|
+
const disabled = loading || component.disabled;
|
|
14800
|
+
const title = (_b = component.title) != null ? _b : "";
|
|
14801
|
+
const onClick = () => {
|
|
14802
|
+
const { behavior } = component;
|
|
14803
|
+
if (behavior == null ? void 0 : behavior.action) {
|
|
14804
|
+
props.onAction(behavior.action);
|
|
14805
|
+
}
|
|
14806
|
+
if (behavior == null ? void 0 : behavior.link) {
|
|
14807
|
+
window.open(behavior.link.url, "_blank");
|
|
14808
|
+
}
|
|
14809
|
+
};
|
|
14810
|
+
return /* @__PURE__ */ jsx72(
|
|
14811
|
+
Button6,
|
|
14812
|
+
{
|
|
14813
|
+
size: getButtonSize(component.size),
|
|
14814
|
+
type: priority === "tertiary" ? void 0 : type,
|
|
14815
|
+
priority,
|
|
14816
|
+
block: true,
|
|
14817
|
+
className,
|
|
14818
|
+
disabled,
|
|
14819
|
+
onClick,
|
|
14820
|
+
children: title
|
|
14777
14821
|
}
|
|
14778
14822
|
);
|
|
14779
14823
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ButtonLayout } from '@wise/dynamic-flow-types';
|
|
1
|
+
import type { Behavior, ButtonLayout } from '@wise/dynamic-flow-types';
|
|
2
2
|
import type { CommonLayoutProps } from '../DynamicLayout';
|
|
3
3
|
type Props = Omit<CommonLayoutProps, 'submitted' | 'onModelChange' | 'onPersistAsync'> & {
|
|
4
|
-
component: ButtonLayout
|
|
4
|
+
component: ButtonLayout & {
|
|
5
|
+
behavior?: Behavior;
|
|
6
|
+
};
|
|
5
7
|
};
|
|
6
8
|
declare function DynamicButton(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export default DynamicButton;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getButtonPriority: (
|
|
3
|
-
export declare const getButtonType: (
|
|
1
|
+
import type { Action, Size } from '@wise/dynamic-flow-types';
|
|
2
|
+
export declare const getButtonPriority: (control: "primary" | "secondary" | "tertiary" | undefined, action: Action | undefined) => "primary" | "secondary" | "tertiary";
|
|
3
|
+
export declare const getButtonType: (context: "positive" | "negative" | "neutral" | undefined, action: Action | undefined) => "positive" | "negative" | "accent";
|
|
4
|
+
export declare const getButtonTypeFromContext: (context: "positive" | "negative" | "neutral" | undefined) => "positive" | "negative" | "accent";
|
|
4
5
|
export declare const getButtonSize: (size: Size | undefined) => "sm" | "md" | "lg";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"nanoid": "5.0.7",
|
|
104
104
|
"react-webcam": "^7.2.0",
|
|
105
105
|
"screenfull": "^5.2.0",
|
|
106
|
-
"@wise/dynamic-flow-types": "2.23.
|
|
106
|
+
"@wise/dynamic-flow-types": "2.23.1"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|