Skip to content

Commit e8ff7aa

Browse files
committed
Remove "string" as possible option for some props
1 parent 07542a7 commit e8ff7aa

File tree

2 files changed

+20
-40
lines changed

2 files changed

+20
-40
lines changed

components/dash-core-components/src/components/Textarea.tsx

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import './css/textarea.css';
66

77
const textAreaProps = [
88
'id',
9+
'cols',
10+
'rows',
11+
'minLength',
12+
'maxLength',
13+
'contentEditable',
14+
'tabIndex',
915
'form',
1016
'name',
1117
'placeholder',
@@ -20,26 +26,6 @@ const textAreaProps = [
2026
'title',
2127
] as const;
2228

23-
const asNumber = (value?: string | number): number | undefined => {
24-
return typeof value === 'string'
25-
? isNaN(parseInt(value, 10))
26-
? undefined
27-
: parseInt(value, 10)
28-
: value;
29-
};
30-
const asBool = (value?: string | boolean): boolean | undefined => {
31-
if (typeof value === 'string') {
32-
if (['true', 'TRUE', 'True'].includes(value)) {
33-
return true;
34-
}
35-
if (['false', 'FALSE', 'False'].includes(value)) {
36-
return false;
37-
}
38-
return undefined;
39-
}
40-
return value;
41-
};
42-
4329
/**
4430
* A basic HTML textarea for entering multiline text.
4531
*
@@ -60,17 +46,11 @@ const Textarea = ({
6046
data-dash-is-loading={isLoading || undefined}
6147
className={'dash-textarea ' + props.className}
6248
value={props.value}
63-
cols={asNumber(props.cols)}
64-
rows={asNumber(props.rows)}
65-
disabled={asBool(props.disabled)}
66-
minLength={asNumber(props.minLength)}
67-
maxLength={asNumber(props.maxLength)}
68-
readOnly={asBool(props.readOnly)}
69-
required={asBool(props.required)}
70-
autoFocus={asBool(props.autoFocus)}
71-
contentEditable={asBool(props.contentEditable)}
72-
hidden={asBool(props.hidden)}
73-
tabIndex={asNumber(props.tabIndex)}
49+
disabled={!!props.disabled}
50+
readOnly={!!props.readOnly}
51+
required={!!props.required}
52+
autoFocus={!!props.autoFocus}
53+
hidden={!!props.hidden}
7454
onChange={e => {
7555
setProps({value: e.target.value});
7656
}}

components/dash-core-components/src/types.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,12 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
533533
/**
534534
* Defines the number of columns in a textarea.
535535
*/
536-
cols?: string | number;
536+
cols?: number;
537537

538538
/**
539539
* Indicates whether the user can interact with the element.
540540
*/
541-
disabled?: string | boolean;
541+
disabled?: boolean | 'disabled' | 'DISABLED';
542542

543543
/**
544544
* Indicates the form that is the owner of the element.
@@ -548,12 +548,12 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
548548
/**
549549
* Defines the maximum number of characters allowed in the element.
550550
*/
551-
maxLength?: string | number;
551+
maxLength?: number;
552552

553553
/**
554554
* Defines the minimum number of characters allowed in the element.
555555
*/
556-
minLength?: string | number;
556+
minLength?: number;
557557

558558
/**
559559
* Name of the element. For example used by the server to identify the fields in form submits.
@@ -584,7 +584,7 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
584584
/**
585585
* Defines the number of rows in a text area.
586586
*/
587-
rows?: string | number;
587+
rows?: number;
588588

589589
/**
590590
* Indicates whether the text should be wrapped.
@@ -599,7 +599,7 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
599599
/**
600600
* Indicates whether the element's content is editable.
601601
*/
602-
contentEditable?: string | boolean;
602+
contentEditable?: boolean;
603603

604604
/**
605605
* Defines the ID of a <menu> element which will serve as the element's context menu.
@@ -614,7 +614,7 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
614614
/**
615615
* Defines whether the element can be dragged.
616616
*/
617-
draggable?: boolean | 'true' | 'false';
617+
draggable?: boolean;
618618

619619
/**
620620
* Prevents rendering of given element, while keeping child elements, e.g. script elements, active.
@@ -629,7 +629,7 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
629629
/**
630630
* Indicates whether spell checking is allowed for the element.
631631
*/
632-
spellCheck?: boolean | 'true' | 'false';
632+
spellCheck?: boolean;
633633

634634
/**
635635
* Defines CSS styles which will override styles previously set.
@@ -639,7 +639,7 @@ export interface TextAreaProps extends BaseComponentProps<TextAreaProps> {
639639
/**
640640
* Overrides the browser's default tab order and follows the one specified instead.
641641
*/
642-
tabIndex?: string | number;
642+
tabIndex?: number;
643643

644644
/**
645645
* Text to be displayed in a tooltip when hovering over the element.

0 commit comments

Comments
 (0)