Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion webapp/src/coretsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ export class CoreDialog extends React.Component<core.PromptOptions, CoreDialogSt
<>
<p>Type '{options.confirmationText}' to confirm:</p>
<sui.Input ref="confirmationInput" id="confirmationInput"
ariaLabel={lf("Type your name to confirm")} autoComplete={false}
label={lf("Type your name to confirm")} visuallyHiddenLabel
autoComplete={false}
value={this.state.confirmationText || ''} onChange={this.handleConfirmationTextChange}
selectOnMount={!mobile} autoFocus={!mobile} />
</>
Expand Down
6 changes: 2 additions & 4 deletions webapp/src/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1641,10 +1641,9 @@ export class ExitAndSaveDialog extends data.Component<ISettingsProps, ExitAndSav
closeOnDimmerClick closeOnDocumentClick closeOnEscape
>
<div>
<p>{prompt}</p>
<div className="ui form">
<sui.Input ref="filenameinput" id={"projectNameInput"}
ariaLabel={prompt} autoComplete={false}
label={prompt} labelWrapper="p" autoComplete={false}
value={projectName || ''} onChange={this.handleChange} onEnter={this.save}
selectOnMount={!mobile} autoFocus={!mobile} />
</div>
Expand Down Expand Up @@ -1779,10 +1778,9 @@ export class NewProjectDialog extends data.Component<ISettingsProps, NewProjectD
closeOnDimmerClick closeOnDocumentClick closeOnEscape
>
<div>
<p>{prompt}</p>
<div className="ui form">
<sui.Input ref="filenameinput" id={"projectNameInput"}
ariaLabel={prompt} autoComplete={false}
label={prompt} labelWrapper="p" autoComplete={false}
value={name || ''} onChange={this.handleTextChange} onEnter={this.save}
selectOnMount={!mobile} autoFocus={!mobile} />
</div>
Expand Down
27 changes: 20 additions & 7 deletions webapp/src/sui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as ReactTooltip from 'react-tooltip';
import * as data from "./data";
import * as core from "./core";
import { fireClickOnEnter } from "./util";
import { focusLastActive } from "../../react-common/components/util";
import { classList, focusLastActive } from "../../react-common/components/util";
import { ThemeManager } from "../../react-common/components/theming/themeManager";

export const appElement = document.getElementById('content');
Expand Down Expand Up @@ -618,28 +618,42 @@ export function helpIconLink(url: string, title: string) {

export class Field extends data.Component<{
label?: string;
labelWrapper?: React.ElementType;
visuallyHidden?: boolean;
children?: any;
ariaLabel?: string;
htmlFor?: string;
}, {}> {
renderCore() {
return (
<div className="field">
{this.props.label ? <label htmlFor={!this.props.ariaLabel ? this.props.htmlFor : undefined}>{this.props.label}</label> : null}
{this.props.ariaLabel && this.props.htmlFor ? (<label htmlFor={this.props.htmlFor} className="accessible-hidden">{this.props.ariaLabel}</label>) : ""}
<LabelWrapper
wrapperType={this.props.labelWrapper}
>
{this.props.label && this.props.htmlFor && (<label className={classList(this.props.visuallyHidden ? "accessible-hidden" : "")} htmlFor={this.props.htmlFor}>{this.props.label}</label>)}
</LabelWrapper>
{this.props.children}
</div>
);
}
}

const LabelWrapper = ({wrapperType, children}: {wrapperType?: React.ElementType, children: React.ReactNode}) => {
if (wrapperType) {
const Wrapper = wrapperType;
return <Wrapper>{children}</Wrapper>
}
return <>{children}</>
}

///////////////////////////////////////////////////////////
//////////// Input /////////////
///////////////////////////////////////////////////////////

export interface InputProps {
label?: string;
labelWrapper?: React.ElementType
inputLabel?: string;
visuallyHiddenLabel?: boolean;
class?: string;
value?: string;
error?: string;
Expand All @@ -653,7 +667,6 @@ export interface InputProps {
copy?: boolean;
selectOnClick?: boolean;
id?: string;
ariaLabel?: string;
autoFocus?: boolean;
autoComplete?: boolean;
selectOnMount?: boolean;
Expand Down Expand Up @@ -746,14 +759,14 @@ export class Input extends data.Component<InputProps, InputState> {

renderCore() {
const p = this.props;
const { copy, error, ariaLabel, id, label, inputLabel, lines, autoFocus, placeholder, readOnly, autoComplete } = p;
const { copy, error, id, label, labelWrapper, inputLabel, lines, autoFocus, placeholder, readOnly, autoComplete, visuallyHiddenLabel } = p;
const { value, copied } = this.state;
const copyBtn = copy && document.queryCommandSupported('copy')
? <Button className={`ui right labeled ${copied ? "green" : "primary"} icon button`} text={copied ? lf("Copied!") : lf("Copy")} icon="copy" onClick={this.copy} />
: null;

return (
<Field ariaLabel={ariaLabel} htmlFor={id} label={label}>
<Field htmlFor={id} label={label} visuallyHidden={visuallyHiddenLabel} labelWrapper={labelWrapper}>
<div className={"ui input" + (p.inputLabel ? " labelled" : "") + (copy ? " action fluid" : "") + (p.disabled ? " disabled" : "")}>
{inputLabel ? (<div className="ui label">{inputLabel}</div>) : ""}
{!lines || lines == 1 ? <input
Expand Down
Loading