Skip to content

Commit e8f55b9

Browse files
committed
added isPassword property to input shape
1 parent 50f1378 commit e8f55b9

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
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,11 @@ 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+
6167
return (
6268
<Group {...commonGroupProps} {...shapeProps}>
6369
<Rect
@@ -75,7 +81,7 @@ export const InputShape = forwardRef<any, ShapeProps>((props, ref) => {
7581
x={INPUT_SHAPE.DEFAULT_PADDING}
7682
y={INPUT_SHAPE.DEFAULT_PADDING + 1}
7783
width={width - INPUT_SHAPE.DEFAULT_PADDING * 2}
78-
text={text}
84+
text={isPassword ? maskPassword(text) : text}
7985
fontFamily={INPUT_SHAPE.DEFAULT_FONT_FAMILY}
8086
fontSize={INPUT_SHAPE.DEFAULT_FONT_SIZE}
8187
lineHeight={INPUT_SHAPE.DEFAULT_LINE_HEIGHT}

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/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export interface OtherProps {
188188
textAlignment?: 'left' | 'center' | 'right';
189189
disabled?: boolean;
190190
isPlaceholder?: boolean;
191+
isPassword?: boolean;
191192
}
192193

193194
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)