From 4d53346c8048599d07bc7c078d7fa6654e147ce7 Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Mon, 2 Oct 2023 16:50:12 -0700 Subject: [PATCH] feat(input-date-picker, input-time-picker): add status property (#7915) **Related Issues:** #5723, #4276 ## Summary Add `status` property to `calcite-input-date-picker` and `calcite-input-time-picker`. Validation messages will be added in a second pass to ensure consistency with the messages displayed for components with invalid values on form submission. --- .../input-date-picker.stories.ts | 8 ++ .../input-date-picker/input-date-picker.tsx | 6 ++ .../input-number/input-number.stories.ts | 4 +- .../input-time-picker.stories.ts | 86 +++---------------- .../input-time-picker/input-time-picker.tsx | 6 +- 5 files changed, 34 insertions(+), 76 deletions(-) diff --git a/packages/calcite-components/src/components/input-date-picker/input-date-picker.stories.ts b/packages/calcite-components/src/components/input-date-picker/input-date-picker.stories.ts index 3383705be8..77b1b739e2 100644 --- a/packages/calcite-components/src/components/input-date-picker/input-date-picker.stories.ts +++ b/packages/calcite-components/src/components/input-date-picker/input-date-picker.stories.ts @@ -18,6 +18,7 @@ export const simple = (): string => html`
html`
html`
`; +export const invalidStatus_TestOnly = (): string => html` +
+ +
+`; + export const darkModeRTL_TestOnly = (): string => html`
html`
html``; + +export const invalidStatus_TestOnly = (): string => + html``; diff --git a/packages/calcite-components/src/components/input-time-picker/input-time-picker.stories.ts b/packages/calcite-components/src/components/input-time-picker/input-time-picker.stories.ts index 2d462c6f2f..7b02d22bde 100644 --- a/packages/calcite-components/src/components/input-time-picker/input-time-picker.stories.ts +++ b/packages/calcite-components/src/components/input-time-picker/input-time-picker.stories.ts @@ -20,6 +20,7 @@ export const simple = (): string => html` name="${text("name", "simple")}" placement="${select("placement", menuPlacements, defaultMenuPlacement)}" scale="${select("scale", ["s", "m", "l"], "m")}" + status="${select("status", ["idle", "invalid", "valid"], "idle")}" step="${number("step", 1)}" value="${text("value", "10:37")}" > @@ -27,106 +28,43 @@ export const simple = (): string => html` `; export const deciSeconds_TestOnly = (): string => html` - - + `; export const centiseconds_TestOnly = (): string => html` - - + `; export const milliseconds_TestOnly = (): string => html` - - + `; export const disabled_TestOnly = (): string => html``; export const darkModeRTL_TestOnly = (): string => html` - - + `; darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault }; export const open_TestOnly = (): string => html` - - + `; export const koreanLocale_TestOnly = (): string => html` - - + `; export const arabicLocaleNumberingSystem_TestOnly = (): string => html` - + `; export const readOnlyHasNoDropdownAffordance_TestOnly = (): string => html` `; + +export const invalidStatus_TestOnly = (): string => html` + +`; diff --git a/packages/calcite-components/src/components/input-time-picker/input-time-picker.tsx b/packages/calcite-components/src/components/input-time-picker/input-time-picker.tsx index 3a47a4485d..558ab833a5 100644 --- a/packages/calcite-components/src/components/input-time-picker/input-time-picker.tsx +++ b/packages/calcite-components/src/components/input-time-picker/input-time-picker.tsx @@ -57,7 +57,7 @@ import { localizeTimeString, toISOTimeString, } from "../../utils/time"; -import { Scale } from "../interfaces"; +import { Scale, Status } from "../interfaces"; import { TimePickerMessages } from "../time-picker/assets/time-picker/t9n"; import { connectMessages, disconnectMessages, setUpMessages, T9nComponent } from "../../utils/t9n"; import { InputTimePickerMessages } from "./assets/input-time-picker/t9n"; @@ -272,6 +272,9 @@ export class InputTimePicker /** 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"; + /** * Determines the type of positioning to use for the overlaid content. * @@ -980,6 +983,7 @@ export class InputTimePicker readOnly={readOnly} role="combobox" scale={this.scale} + status={this.status} step={this.step} // 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.setInputAndTransitionEl}