Skip to content

Commit b83cbb4

Browse files
committed
Add masking to steps along with primary color type
1 parent 3a82b2e commit b83cbb4

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

client/packages/lowcoder/src/comps/comps/tourComp/tourComp.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ let TourBasicComp = (function() {
5050
description: step.description,
5151
target: target?.current,
5252
arrow: step.arrow || true,
53-
placement: step.placement as PlacementType
53+
placement: step.placement as PlacementType,
54+
mask: step.mask,
55+
type: step.type || "default",
5456
};
5557
});
5658

client/packages/lowcoder/src/comps/controls/codeControl.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import {
3030
toHex,
3131
wrapperToControlItem,
3232
} from "lowcoder-design";
33-
import { lazy, ReactNode, Suspense } from "react";
33+
import { CSSProperties, lazy, ReactNode, Suspense } from "react";
3434
import {
3535
showTransform,
3636
toArrayJSONObject,
37-
toBoolean,
37+
toBoolean, toBooleanOrCss,
3838
toJSONArray,
3939
toJSONObject,
4040
toJSONObjectArray,
@@ -318,6 +318,7 @@ export type CodeControlJSONType = ReturnType<typeof tmpFuncForJson>;
318318
export const StringControl = codeControl<string>(toString);
319319
export const NumberControl = codeControl<number>(toNumber);
320320
export const StringOrNumberControl = codeControl<string | number>(toStringOrNumber);
321+
export const MaskControl = codeControl<boolean | { style?: CSSProperties | undefined; color?: string | undefined; } | undefined>(toBooleanOrCss);
321322

322323
// rangeCheck, don't support Infinity temporarily
323324
export class RangeControl {

client/packages/lowcoder/src/comps/controls/tourStepControl.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
1+
import { BoolCodeControl, MaskControl, StringControl } from "comps/controls/codeControl";
22
import { dropdownControl } from "comps/controls/dropdownControl";
33
import { MultiCompBuilder, withDefault } from "comps/generators";
44
import { list } from "comps/generators/list";
@@ -24,6 +24,7 @@ import { ReactNode, useContext, useEffect, useState } from "react";
2424
import { EditorContext, EditorState } from "@lowcoder-ee/comps/editorState";
2525
// import { PlacementType } from "@rc-component"
2626
export type PlacementType = 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom' | 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'center';
27+
export type TourStepType = 'default' | 'primary';
2728

2829
const OptionTypes = [
2930
{
@@ -281,6 +282,12 @@ const PlacementOptions: {label: string, value: PlacementType}[] = [
281282
];
282283

283284

285+
const TypeOptions: {label: string, value: TourStepType}[] = [
286+
{ label: "Default", value: "default"},
287+
{ label: "Primary", value: "primary"},
288+
];
289+
290+
284291
export function editorStateDropdownControl<T extends OptionsType>(
285292
options: ((editorState: EditorState) => T),
286293
defaultValue: ValueFromOption<T>
@@ -329,7 +336,6 @@ function EditorStateDropdownPropertyView<T extends OptionsType>(props: DropdownP
329336
}
330337
if (!finalOptions?.length) {
331338
setFinalOptions(options(editorState))
332-
//.then((items) => setFinalOptions(items));
333339
}
334340
}, [finalOptions.length, options]);
335341

@@ -402,6 +408,8 @@ let TourStep = new MultiCompBuilder(
402408
description: StringControl,
403409
placement: dropdownControl(PlacementOptions, "bottom"),
404410
hidden: BoolCodeControl,
411+
mask: MaskControl,
412+
type: dropdownControl(TypeOptions, "default"),
405413
},
406414
(props) => props
407415
).build();
@@ -427,9 +435,15 @@ TourStep = class extends TourStep implements TourStepCompProperty {
427435
radioButton: false
428436
})}
429437
{this.children.arrow.propertyView({
430-
label: "Arrow"
438+
label: "Arrow",
431439
})}
432440
{hiddenPropertyView(this.children)}
441+
{this.children.mask.propertyView({
442+
label: "Mask",
443+
})}
444+
{this.children.type.propertyView({
445+
label: "Type",
446+
})}
433447
</>
434448
);
435449
}

client/packages/lowcoder/src/util/convertUtils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { JSONObject, JSONValue } from "util/jsonTypes";
2+
import { CSSProperties } from "react";
23

34
class EvalTypeError extends TypeError {
45
hint?: string;
@@ -245,3 +246,17 @@ export function check(
245246
)
246247
);
247248
}
249+
250+
export function toBooleanOrCss(value: any): boolean | undefined | {
251+
style?: CSSProperties | undefined;
252+
color?: string | undefined;
253+
} {
254+
if (value === undefined || value === null || value === "") {
255+
return undefined;
256+
}
257+
// if (typeof value === "boolean") {
258+
if (value.toLocaleLowerCase() === "true" || value.toLocaleLowerCase() === "false") {
259+
return value.toLocaleLowerCase() === "true";
260+
}
261+
return toJSONObject(value);
262+
}

0 commit comments

Comments
 (0)