Skip to content

Commit

Permalink
finos#1073 move DateTimeColumnDescriptor to vuu-table-types package
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidzm13 committed Dec 27, 2023
1 parent 768ed50 commit 85ee783
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import React, { useCallback } from "react";
import { FormattingSettingsProps } from "./types";
import { Dropdown, SingleSelectionHandler } from "@finos/vuu-ui-controls";
import {
DateTimeColumnDescriptor,
DateTimePattern,
defaultDateTimePatterns,
getTypeFormattingFromColumn,
isTypeDescriptor,
supportedDateTimePatterns,
} from "@finos/vuu-utils";
import { FormField, FormFieldLabel } from "@salt-ds/core";
import { DateTimeColumnTypeSimple } from "packages/vuu-table-types";
import {
DateTimeColumnDescriptor,
DateTimeColumnTypeSimple,
} from "@finos/vuu-table-types";

import { FormattingSettingsProps } from "./types";

export const DateTimeFormattingSettings: React.FC<
FormattingSettingsProps<DateTimeColumnDescriptor>
Expand Down
12 changes: 12 additions & 0 deletions vuu-ui/packages/vuu-table-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ export interface ValueListRenderer {
}

export declare type DateTimeColumnTypeSimple = "date" | "time";

type DateTimeColumnType =
| DateTimeColumnTypeSimple
| (Omit<ColumnTypeDescriptor, "name"> & { name: DateTimeColumnTypeSimple });

export declare type DateTimeColumnDescriptor = Omit<
ColumnDescriptor,
"type"
> & {
type: DateTimeColumnType;
};

export declare type ColumnTypeSimple =
| "string"
| "number"
Expand Down
10 changes: 1 addition & 9 deletions vuu-ui/packages/vuu-utils/src/column-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import type {
ColumnTypeFormatting,
ColumnTypeRendering,
ColumnTypeWithValidationRules,
DateTimeColumnTypeSimple,
DefaultColumnConfiguration,
GroupColumnDescriptor,
LookupRenderer,
Expand All @@ -32,6 +31,7 @@ import type {
TableHeading,
TableHeadings,
ValueListRenderer,
DateTimeColumnDescriptor,
} from "@finos/vuu-table-types";
import type { CSSProperties } from "react";
import { moveItem } from "./array-utils";
Expand Down Expand Up @@ -131,14 +131,6 @@ export const isNumericColumn = ({ serverDataType, type }: ColumnDescriptor) => {
return false;
};

type DateTimeColumnType =
| DateTimeColumnTypeSimple
| (Omit<ColumnTypeDescriptor, "name"> & { name: DateTimeColumnTypeSimple });

export type DateTimeColumnDescriptor = Omit<ColumnDescriptor, "type"> & {
type: DateTimeColumnType;
};

export const isDateColumn = ({ type }: ColumnDescriptor) =>
(isTypeDescriptor(type) ? type.name : type) === "date";
export const isTimeColumn = ({ type }: ColumnDescriptor) =>
Expand Down
7 changes: 5 additions & 2 deletions vuu-ui/packages/vuu-utils/src/date/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { DateTimeColumnTypeSimple } from "@finos/vuu-table-types";
import { DateTimeColumnDescriptor, isTypeDescriptor } from "../column-utils";
import {
DateTimeColumnTypeSimple,
DateTimeColumnDescriptor,
} from "@finos/vuu-table-types";
import { isTypeDescriptor } from "../column-utils";
import { DateTimePattern, isDateTimePattern } from "./types";

export const defaultDateTimePatterns: Record<
Expand Down

0 comments on commit 85ee783

Please sign in to comment.