Skip to content

Commit 6f596f1

Browse files
authored
Merge branch 'dev' into feature/#567-create-a-circular-progress-shape-under-rich-components
2 parents 368b92d + a6f0b61 commit 6f596f1

File tree

6 files changed

+40
-31
lines changed

6 files changed

+40
-31
lines changed

src/common/components/mock-components/front-components/input-shape.tsx

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
4949
borderRadius,
5050
disabled,
5151
isPlaceholder,
52+
isPassword,
5253
} = useShapeProps(otherProps, INPUT_SHAPE);
5354

5455
const commonGroupProps = useGroupShapeProps(
@@ -58,6 +59,13 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
5859
ref
5960
);
6061

62+
const maskPassword = (text: string) => {
63+
const maskSymbol = '●';
64+
return maskSymbol.repeat(text.length);
65+
};
66+
67+
const finalText = isPassword && !isPlaceholder ? maskPassword(text) : text;
68+
6169
return (
6270
<Group {...commonGroupProps} {...shapeProps}>
6371
<Rect
@@ -75,7 +83,7 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
7583
x={INPUT_SHAPE.DEFAULT_PADDING}
7684
y={INPUT_SHAPE.DEFAULT_PADDING + 1}
7785
width={width - INPUT_SHAPE.DEFAULT_PADDING * 2}
78-
text={text}
86+
text={finalText}
7987
fontFamily={INPUT_SHAPE.DEFAULT_FONT_FAMILY}
8088
fontSize={INPUT_SHAPE.DEFAULT_FONT_SIZE}
8189
lineHeight={INPUT_SHAPE.DEFAULT_LINE_HEIGHT}
@@ -93,33 +101,3 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
93101
</Group>
94102
);
95103
});
96-
97-
/*
98-
<Group {...commonGroupProps} {...shapeProps}>
99-
<Rect
100-
x={0}
101-
y={0}
102-
width={restrictedWidth}
103-
height={restrictedHeight}
104-
cornerRadius={borderRadius}
105-
stroke={stroke}
106-
dash={strokeStyle}
107-
strokeWidth={INPUT_SHAPE.DEFAULT_STROKE_WIDTH}
108-
fill={fill}
109-
/>
110-
<Text
111-
x={INPUT_SHAPE.DEFAULT_PADDING}
112-
y={INPUT_SHAPE.DEFAULT_PADDING + 1}
113-
width={width - INPUT_SHAPE.DEFAULT_PADDING * 2}
114-
text={text}
115-
fontFamily={INPUT_SHAPE.DEFAULT_FONT_FAMILY}
116-
fontSize={INPUT_SHAPE.DEFAULT_FONT_SIZE}
117-
lineHeight={INPUT_SHAPE.DEFAULT_LINE_HEIGHT}
118-
fill={textColor}
119-
align="left"
120-
ellipsis={true}
121-
wrap="none"
122-
/>
123-
</Group>
124-
125-
*/

src/common/components/shapes/use-shape-props.hook.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export const useShapeProps = (
2727
[otherProps?.isPlaceholder]
2828
);
2929

30+
const isPassword = useMemo(
31+
() => otherProps?.isPassword ?? true,
32+
[otherProps?.isPassword]
33+
);
34+
3035
const fontVariant = useMemo(
3136
() => otherProps?.fontVariant ?? defaultStyleShape.DEFAULT_FONT_VARIANT,
3237
[otherProps?.fontVariant]
@@ -99,5 +104,6 @@ export const useShapeProps = (
99104
textAlignment,
100105
disabled,
101106
isPlaceholder,
107+
isPassword,
102108
};
103109
};

src/core/local-disk/shapes-to-document.mapper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const AddDefaultValuesForInputPropsPlaceHolderAndPassword = (
5252
...shape,
5353
otherProps: {
5454
...shape.otherProps,
55+
isPassword:
56+
shape.otherProps?.isPassword !== undefined
57+
? shape.otherProps?.isPassword
58+
: false,
5559
isPlaceholder:
5660
// Small update no need to go for 0_3, but input placeHolder needs to have default value
5761
// if undefined

src/core/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export interface OtherProps {
190190
textAlignment?: 'left' | 'center' | 'right';
191191
disabled?: boolean;
192192
isPlaceholder?: boolean;
193+
isPassword?: boolean;
193194
}
194195

195196
export const BASE_ICONS_URL = '/icons/';

src/pods/canvas/model/shape-other-props.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const generateDefaultOtherProps = (
1616
backgroundColor: INPUT_SHAPE.DEFAULT_FILL_BACKGROUND,
1717
textColor: INPUT_SHAPE.DEFAULT_FILL_TEXT,
1818
isPlaceholder: true,
19+
isPassword: false,
1920
strokeStyle: [],
2021
borderRadius: `${INPUT_SHAPE.DEFAULT_CORNER_RADIUS}`,
2122
disabled: INPUT_SHAPE.DEFAULT_DISABLED,

src/pods/properties/properties.pod.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { extractMultiplePropsInCommon } from './properties.business';
1919
import { ShowProp } from './components/show-prop';
2020
import { iconCollection } from './components/icon-selector/modal/icons';
2121
import { Placeholder } from './components/placeholder';
22+
import { Password } from './components/password';
2223

2324
export const PropertiesPod = () => {
2425
const { selectionInfo, fullDocument } = useCanvasContext();
@@ -212,6 +213,24 @@ export const PropertiesPod = () => {
212213
}
213214
/>
214215
</ShowProp>
216+
<ShowProp
217+
singleSelection={isSingleSelection}
218+
multipleSelectionPropsInCommon={multipleSelectionPropsInCommon}
219+
propKey="isPassword"
220+
propValue={selectedShapeData?.otherProps?.isPassword}
221+
>
222+
<Password
223+
label="Password"
224+
isPassword={selectedShapeData?.otherProps?.isPassword ?? false}
225+
onChange={isPassword =>
226+
updateOtherPropsOnSelected(
227+
'isPassword',
228+
isPassword,
229+
isMultipleSelection
230+
)
231+
}
232+
/>
233+
</ShowProp>
215234
<ShowProp
216235
singleSelection={isSingleSelection}
217236
multipleSelectionPropsInCommon={multipleSelectionPropsInCommon}

0 commit comments

Comments
 (0)