Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(combobox, checkbox, input-time-zone, select, text-area): add status property #8304

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
padding-inline: var(--calcite-combobox-item-spacing-unit-l);
}

:host([status="invalid"]) {
& .wrapper {
@apply border-color-danger;
}
& .wrapper:focus {
@apply focus-inset-danger;
}
}

:host(:focus-within) .wrapper,
.wrapper--active {
@apply focus-inset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const single = (): string => html`
max-items="${number("max-items", 0)}"
placeholder="${text("placeholder", "placeholder")}"
scale="${select("scale", ["s", "m", "l"], "m")}"
status="${select("status", ["idle", "invalid", "valid"], "idle")}"
>
<calcite-combobox-item icon="altitude" value="altitude" text-label="Altitude" selected></calcite-combobox-item>
<calcite-combobox-item icon="article" value="article" text-label="Article"></calcite-combobox-item>
Expand Down Expand Up @@ -296,6 +297,7 @@ export const nestedItems = (): string => html`
${boolean("disabled", false)}
${boolean("allow-custom-values", false)}
max-items="${number("max-items", 0)}"
status="${select("status", ["idle", "invalid", "valid"], "idle")}"
>
<calcite-combobox-item value="ITEM-0-0" text-label="Level 1">
<calcite-combobox-item value="ITEM-0-1" text-label="Level 2"></calcite-combobox-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import {
T9nComponent,
updateMessages,
} from "../../utils/t9n";
import { Scale, SelectionMode } from "../interfaces";
import { Scale, SelectionMode, Status } from "../interfaces";
import { ComboboxMessages } from "./assets/combobox/t9n";
import { ComboboxChildElement, SelectionDisplay } from "./interfaces";
import { ComboboxChildSelector, ComboboxItem, ComboboxItemGroup, CSS } from "./resources";
Expand Down Expand Up @@ -224,6 +224,9 @@ export class Combobox
/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: Scale = "m";

/** Specifies the status of the input field, which determines message and icons. */
@Prop({ reflect: true }) status: Status = "idle";

@Watch("selectionMode")
@Watch("scale")
handlePropsChange(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const simple = (): string => html`
<calcite-input-text
scale="${select("scale", ["s", "m", "l"], "m")}"
status="${select("status", ["idle", "valid", "invalid"], "idle")}"
status="${select("status", ["idle", "invalid", "valid"], "idle")}"
alignment="${select("alignment", ["start", "end"], "start")}"
prefix-text="${text("prefix-text", "")}"
suffix-text="${text("suffix-text", "")}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const simple = (): string => html`
${boolean("disabled", false)}
mode="${select("mode", ["offset", "name"], "offset")}"
scale="${select("scale", ["s", "m", "l"], "m")}"
status="${select("status", ["idle", "invalid", "valid"], "idle")}"
></calcite-input-time-zone>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
SupportedLocale,
} from "../../utils/locale";
import { TimeZoneItem, TimeZoneMode } from "./interfaces";
import { Scale } from "../interfaces";
import { Scale, Status } from "../interfaces";
import {
connectMessages,
disconnectMessages,
Expand Down Expand Up @@ -158,6 +158,9 @@ export class InputTimeZone
/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: Scale = "m";

/** Specifies the status of the input field, which determines message and icons. */
@Prop({ reflect: true }) status: Status = "idle";

/**
* The component's value, where the value is the time zone offset or the difference, in minutes, between the selected time zone and UTC.
*
Expand Down Expand Up @@ -378,6 +381,7 @@ export class InputTimeZone
overlayPositioning={this.overlayPositioning}
scale={this.scale}
selectionMode="single-persist"
status={this.status}
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
ref={this.setComboboxRef}
>
Expand Down
8 changes: 8 additions & 0 deletions packages/calcite-components/src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ select:disabled {
@apply border-color-input bg-opacity-100;
}

:host([status="invalid"]) {
select {
@apply border-color-danger;
}
select:focus {
@apply focus-inset-danger;
}
}
.icon-container {
@apply border-color-input
text-color-2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const createOptionAttributes: () => Attributes = () => {
name: "value",
value: text("value", "value", group),
},
{
name: "status",
value: select("status", ["idle", "invalid", "valid"], "idle", group),
},
];
};

Expand Down
8 changes: 5 additions & 3 deletions packages/calcite-components/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
setUpLoadableComponent,
} from "../../utils/loadable";
import { createObserver } from "../../utils/observers";
import { Scale, Width } from "../interfaces";
import { Scale, Status, Width } from "../interfaces";
import { CSS } from "./resources";
import { getIconScale } from "../../utils/component";

Expand Down Expand Up @@ -77,8 +77,7 @@ export class Select
*
* When not set, the component will be associated with its ancestor form element, if any.
*/
@Prop({ reflect: true })
form: string;
@Prop({ reflect: true }) form: string;

/**
* Accessible name for the component.
Expand All @@ -105,6 +104,9 @@ export class Select
*/
@Prop({ reflect: true }) scale: Scale = "m";

/** Specifies the status of the input field, which determines message and icons. */
@Prop({ reflect: true }) status: Status = "idle";

/** The component's `selectedOption` value. */
@Prop({ mutable: true }) value: string = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ textarea {
}
}

:host([status="invalid"]) {
textarea {
@apply border-color-danger;
}
textarea:focus {
@apply focus-inset-danger;
}
}

.readonly {
@apply bg-background font-medium;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
} from "../../utils/interactive";
import { CharacterLengthObj } from "./interfaces";
import { guid } from "../../utils/guid";
import { Status } from "../interfaces";

/**
* @slot - A slot for adding text.
Expand Down Expand Up @@ -176,6 +177,9 @@ export class TextArea
/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: "l" | "m" | "s" = "m";

/** Specifies the status of the input field, which determines message and icons. */
@Prop({ reflect: true }) status: Status = "idle";

/** The component's value. */
@Prop({ mutable: true }) value: string;

Expand Down
Loading