Skip to content
Snippets Groups Projects
Commit bd0e895f authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] more types in dome/frames

parent a2479aca
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
/* */ /* */
/* ************************************************************************ */ /* ************************************************************************ */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- ToolBars // --- ToolBars
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -52,7 +50,7 @@ export interface ToolBarProps { ...@@ -52,7 +50,7 @@ export interface ToolBarProps {
@class @class
@summary Container for toolbar items. @summary Container for toolbar items.
*/ */
export function ToolBar(props: ToolBarProps) { export function ToolBar(props: ToolBarProps): JSX.Element | null {
const { children } = props; const { children } = props;
const n = React.Children.count(children); const n = React.Children.count(children);
if (n === 0) return null; if (n === 0) return null;
...@@ -75,16 +73,22 @@ export function ToolBar(props: ToolBarProps) { ...@@ -75,16 +73,22 @@ export function ToolBar(props: ToolBarProps) {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** Fixed (tiny) space. */ /** Fixed (tiny) space. */
export const Inset = (() => <div className="dome-xToolBar-inset" />); export const Inset = (): JSX.Element => (
<div className="dome-xToolBar-inset" />
);
/** Fixed space. */ /** Fixed space. */
export const Space = (() => <div className="dome-xToolBar-space" />); export const Space = (): JSX.Element => (
<div className="dome-xToolBar-space" />
);
/** Auto-extensible space. */ /** Auto-extensible space. */
export const Filler = (() => <div className="dome-xToolBar-filler" />); export const Filler = (): JSX.Element => (
<div className="dome-xToolBar-filler" />
);
/** Fixed space with vertical rule. */ /** Fixed space with vertical rule. */
export const Separator = () => ( export const Separator = (): JSX.Element => (
<div className="dome-xToolBar-separator"> <div className="dome-xToolBar-separator">
<div className="dome-xToolBar-vrule" /> <div className="dome-xToolBar-vrule" />
</div> </div>
...@@ -92,7 +96,7 @@ export const Separator = () => ( ...@@ -92,7 +96,7 @@ export const Separator = () => (
const SELECT = 'dome-xToolBar-control dome-selected'; const SELECT = 'dome-xToolBar-control dome-selected';
const BUTTON = 'dome-xToolBar-control dome-color-frame'; const BUTTON = 'dome-xToolBar-control dome-color-frame';
const KIND = (kind: undefined | string) => ( const KIND = (kind: undefined | string): string => (
kind ? ` dome-xToolBar-${kind}` : '' kind ? ` dome-xToolBar-${kind}` : ''
); );
...@@ -129,7 +133,9 @@ export interface ButtonProps<A> { ...@@ -129,7 +133,9 @@ export interface ButtonProps<A> {
} }
/** Toolbar Button. */ /** Toolbar Button. */
export function Button<A = undefined>(props: ButtonProps<A>) { export function Button<A = undefined>(
props: ButtonProps<A>
): JSX.Element | null {
const { visible = true, hidden = false } = props; const { visible = true, hidden = false } = props;
if (!visible || hidden) return null; if (!visible || hidden) return null;
const { enabled = true, disabled = false } = props; const { enabled = true, disabled = false } = props;
...@@ -170,7 +176,7 @@ export interface SwitchProps { ...@@ -170,7 +176,7 @@ export interface SwitchProps {
} }
/** Toolbar Left/Right Switch. */ /** Toolbar Left/Right Switch. */
export function Switch(props: SwitchProps) { export function Switch(props: SwitchProps): JSX.Element | null {
const { position, onChange } = props; const { position, onChange } = props;
const checked = position === 'right'; const checked = position === 'right';
const { title, className, style } = props; const { title, className, style } = props;
...@@ -217,7 +223,7 @@ export interface ButtonGroupProps<A> extends SelectionProps<A> { ...@@ -217,7 +223,7 @@ export interface ButtonGroupProps<A> extends SelectionProps<A> {
Properties of the button group are passed down the buttons of the group Properties of the button group are passed down the buttons of the group
as appropriate defaults. as appropriate defaults.
*/ */
export function ButtonGroup<A>(props: ButtonGroupProps<A>) { export function ButtonGroup<A>(props: ButtonGroupProps<A>): JSX.Element {
const { children, value, onChange, enabled, disabled } = props; const { children, value, onChange, enabled, disabled } = props;
const baseProps: ButtonProps<A> = { const baseProps: ButtonProps<A> = {
enabled, enabled,
...@@ -247,11 +253,12 @@ export function ButtonGroup<A>(props: ButtonGroupProps<A>) { ...@@ -247,11 +253,12 @@ export function ButtonGroup<A>(props: ButtonGroupProps<A>) {
The list of options shall be given with standard The list of options shall be given with standard
`<option value={...} label={...}>` elements. `<option value={...} label={...}>` elements.
*/ */
export function Select(props: SelectionProps<string>) { export function Select(props: SelectionProps<string>): JSX.Element {
const { enabled = true, disabled = false, onChange } = props; const { enabled = true, disabled = false, onChange } = props;
const callback = (evt: React.ChangeEvent<HTMLSelectElement>) => { const callback =
if (onChange) onChange(evt.target.value); (evt: React.ChangeEvent<HTMLSelectElement>): void => {
}; if (onChange) onChange(evt.target.value);
};
return ( return (
<select <select
className="dome-xToolBar-control dome-color-frame" className="dome-xToolBar-control dome-color-frame"
...@@ -413,6 +420,10 @@ function Suggestions(props: SuggestionsProps) { ...@@ -413,6 +420,10 @@ function Suggestions(props: SuggestionsProps) {
); );
} }
interface Searching {
pattern?: string;
timer?: NodeJS.Timeout | undefined;
onSearch?: ((p: string) => void);
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- ModalActionField input field component // --- ModalActionField input field component
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment