Skip to content

Commit d41e5d9

Browse files
committed
fix(Input): separates mask and password into tewo different properties
1 parent 627187a commit d41e5d9

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

packages/solid/components/Input/Input.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ const meta: Meta<typeof Input> = {
4747
defaultValue: { summary: 'neutral' }
4848
}
4949
},
50-
password: {
50+
mask: {
5151
description: 'character to use as a mask when password is true',
5252
control: 'text'
53+
},
54+
password: {
55+
description: 'hen true the content will be masked to the user',
56+
control: 'boolean'
5357
}
5458
}
5559
};

packages/solid/components/Input/Input.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ import { View, Text } from '@lightningtv/solid';
2020
import styles from './Input.styles.js';
2121
import type { InputProps } from './Input.types.js';
2222

23-
const getformatTitleText = (props, title) =>
24-
props.password ? props.password.repeat(title.length) : title;
23+
const getformatTitleText = (props, title) =>
24+
props.password ? (props.mask ?? '').repeat(title.length ?? 0) : title;
2525

2626
const Input: Component<InputProps> = props => {
2727
/* eslint-disable solid/reactivity */
2828
const [title, setTitle] = props.titleSignal;
2929
const [position, setPosition] = createSignal(props.position ?? title().length);
3030
const [keyEvent, setKeyEvent] = props.keyEvent;
31-
const formatTitleText = createMemo(() => getformatTitleText(props,title()));
32-
31+
const formatTitleText = createMemo(() => getformatTitleText(props, title()));
3332

3433
const formatInputText = (key: string) => {
3534
if (key === undefined || key === '') {

packages/solid/components/Input/Input.types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ export interface InputProps extends UIComponentProps, InputStyleProperties {
1919
*/
2020
titleSignal: Signal<string>;
2121

22+
/**
23+
* when true the content will be masked to the user
24+
*/
25+
password?: boolean;
26+
2227
/**
2328
* character to use as a mask when password is true
2429
*/
25-
password?: string;
30+
mask?: string;
2631
}
2732

2833
export interface InputStyleProperties {

0 commit comments

Comments
 (0)