Skip to content

Commit

Permalink
chore(html): arrange input helpers for prefix/suffix support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhpenkov authored and Juveniel committed Jan 2, 2024
1 parent 5b047d0 commit 426f291
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/html/src/input/index.ts
Expand Up @@ -8,4 +8,6 @@ export * from './input-loading-icon';
export * from './input-validation-icon';
export * from './input-prefix';
export * from './input-suffix';
export * from './input-prefix-text';
export * from './input-suffix-text';
export * from './input-separator';
22 changes: 22 additions & 0 deletions packages/html/src/input/input-prefix-text.tsx
@@ -0,0 +1,22 @@
import { classNames } from '../misc';

const className = `k-input-prefix-text`;

export const InputPrefixText = (props: React.HTMLAttributes<HTMLSpanElement>) => {

const {
children,
...other
} = props;

return (
<span
{...other}
className={classNames(
className,
props.className
)}>
{children}
</span>
);
};
28 changes: 26 additions & 2 deletions packages/html/src/input/input-prefix.tsx
Expand Up @@ -2,14 +2,38 @@ import { classNames } from '../misc';

const className = `k-input-prefix`;

export const InputPrefix = (props: React.HTMLAttributes<HTMLSpanElement>) => {
export type KendoInputPrefixProps = {
direction?: "horizontal" | "vertical";
};

const defaultProps = {
direction: "horizontal"
};

export const InputPrefix = (props:
KendoInputPrefixProps &
React.HTMLAttributes<HTMLSpanElement>
) => {
const {
direction = defaultProps.direction,
...other
} = props;

if (!props.children) {
return <></>;
}

return (
<span className={classNames(className, props.className)}>
<span
{...other}
className={
classNames(
className,
props.className,
{
[`k-input-prefix-${direction}`]: direction,
}
)}>
{props.children}
</span>
);
Expand Down
36 changes: 31 additions & 5 deletions packages/html/src/input/input-separator.tsx
Expand Up @@ -2,8 +2,34 @@ import { classNames } from '../misc';

const className = `k-input-separator`;

export const InputSeparator = (props: React.HTMLAttributes<HTMLSpanElement>) => (
<span
className={classNames(className, props.className)}
/>
);
export type InputSeparatorProps = {
direction?: "horizontal" | "vertical";
};

const defaultProps = {
direction: "vertical"
};

export const InputSeparator = (props:
React.HTMLAttributes<HTMLSpanElement> &
InputSeparatorProps
) => {
const {
direction = defaultProps.direction,
...other
} = props;


return (
<span
{...other}
className={classNames(
className,
props.className,
{
[`${className}-${direction}`]: direction,
}
)}
/>
);
};
22 changes: 22 additions & 0 deletions packages/html/src/input/input-suffix-text.tsx
@@ -0,0 +1,22 @@
import { classNames } from '../misc';

const className = `k-input-suffix-text`;

export const InputSuffixText = (props: React.HTMLAttributes<HTMLSpanElement>) => {

const {
children,
...other
} = props;

return (
<span
{...other}
className={classNames(
className,
props.className
)}>
{children}
</span>
);
};
28 changes: 26 additions & 2 deletions packages/html/src/input/input-suffix.tsx
Expand Up @@ -2,14 +2,38 @@ import { classNames } from '../misc';

const className = `k-input-suffix`;

export const InputSuffix = (props: React.HTMLAttributes<HTMLSpanElement>) => {
export type KendoInputSuffixProps = {
direction?: "horizontal" | "vertical";
};

const defaultProps = {
direction: "horizontal"
};

export const InputSuffix = (props:
KendoInputSuffixProps &
React.HTMLAttributes<HTMLSpanElement>
) => {
const {
direction = defaultProps.direction,
...other
} = props;

if (!props.children) {
return <></>;
}

return (
<span className={classNames(className, props.className)}>
<span
{...other}
className={
classNames(
className,
props.className,
{
[`k-input-suffix-${direction}`]: direction,
}
)}>
{props.children}
</span>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/html/src/input/input-validation-icon.tsx
Expand Up @@ -24,7 +24,7 @@ export const InputValidationIcon = (
disabled,
loading } = props;

const iconName = invalid ? 'exclamation-circle' : 'check';
const iconName = invalid ? 'warning-circle' : 'check-circle';
const renderValidationIcon = Boolean( valid || invalid );

if (disabled || loading || !renderValidationIcon) {
Expand Down

0 comments on commit 426f291

Please sign in to comment.