Skip to content

Commit

Permalink
fix(Input): separates mask and password into tewo different properties
Browse files Browse the repository at this point in the history
  • Loading branch information
slhay28 committed Jun 18, 2024
1 parent 627187a commit d41e5d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/solid/components/Input/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ const meta: Meta<typeof Input> = {
defaultValue: { summary: 'neutral' }
}
},
password: {
mask: {
description: 'character to use as a mask when password is true',
control: 'text'
},
password: {
description: 'hen true the content will be masked to the user',
control: 'boolean'
}
}
};
Expand Down
7 changes: 3 additions & 4 deletions packages/solid/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ import { View, Text } from '@lightningtv/solid';
import styles from './Input.styles.js';
import type { InputProps } from './Input.types.js';

const getformatTitleText = (props, title) =>
props.password ? props.password.repeat(title.length) : title;
const getformatTitleText = (props, title) =>
props.password ? (props.mask ?? '').repeat(title.length ?? 0) : title;

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

const formatTitleText = createMemo(() => getformatTitleText(props, title()));

const formatInputText = (key: string) => {
if (key === undefined || key === '') {
Expand Down
7 changes: 6 additions & 1 deletion packages/solid/components/Input/Input.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ export interface InputProps extends UIComponentProps, InputStyleProperties {
*/
titleSignal: Signal<string>;

/**
* when true the content will be masked to the user
*/
password?: boolean;

/**
* character to use as a mask when password is true
*/
password?: string;
mask?: string;
}

export interface InputStyleProperties {
Expand Down

0 comments on commit d41e5d9

Please sign in to comment.