Skip to content

Commit

Permalink
Support Date and Datetime inputs on actions (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
pattra authored Nov 27, 2024
1 parent da4d785 commit 4d0e723
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/spectral/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prismatic-io/spectral",
"version": "10.2.3",
"version": "10.3.0",
"description": "Utility library for building Prismatic components and code-native integrations",
"keywords": ["prismatic"],
"main": "dist/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], InputType> = {
},
dynamicObjectSelection: "string",
dynamicFieldSelection: "string",
date: "string",
timestamp: "string",
};

const getInputValueType = (input: ServerTypeInput): ValueType => {
Expand Down
24 changes: 23 additions & 1 deletion packages/spectral/src/types/Inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const InputFieldDefaultMap: Record<InputFieldType, string | undefined> =
jsonForm: undefined,
dynamicObjectSelection: "",
dynamicFieldSelection: "",
date: "",
timestamp: "",
};

export type Inputs = Record<string, InputFieldDefinition>;
Expand Down Expand Up @@ -117,7 +119,9 @@ export type InputFieldDefinition =
| ObjectFieldMapInputField
| JSONFormInputField
| DynamicObjectSelectionInputField
| DynamicFieldSelectionInputField;
| DynamicFieldSelectionInputField
| DateInputField
| DateTimeInputField;

export type InputCleanFunction<TValue, TResult = TValue> = (value: TValue) => TResult;

Expand Down Expand Up @@ -325,6 +329,24 @@ export interface DynamicFieldSelectionInputField extends BaseInputField {
clean?: InputCleanFunction<this["default"]>;
}

export type DateInputField = BaseInputField & {
/** Data type the InputField will collect. */
type: "date";
/** Dictates possible choices for the input. */
model?: InputFieldChoice[];
/** Clean function */
clean?: InputCleanFunction<unknown>;
} & CollectionOptions<string>;

export type DateTimeInputField = BaseInputField & {
/** Data type the InputField will collect. */
type: "timestamp";
/** Dictates possible choices for the input. */
model?: InputFieldChoice[];
/** Clean function */
clean?: InputCleanFunction<unknown>;
} & CollectionOptions<string>;

/** Defines a single Choice option for a InputField. */
export interface InputFieldChoice {
/** Label to display for this Choice. */
Expand Down

0 comments on commit 4d0e723

Please sign in to comment.