Skip to content

Commit 546f193

Browse files
committed
Move type to type/ui
1 parent fc76f57 commit 546f193

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

packages/frontend-core/src/components/grid/stores/columns.ts

+11-29
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
11
import { derived, get, Readable, Writable, writable } from "svelte/store"
22
import { DefaultColumnWidth, GutterWidth } from "../lib/constants"
3-
import { CalculationType, FieldSchema, FieldType } from "@budibase/types"
3+
import { UIColumn } from "@budibase/types"
44
import { Store as StoreContext } from "."
55

66
interface ColumnStore {
7-
columns: Writable<Column[]>
7+
columns: Writable<UIColumn[]>
88
}
99

1010
interface DerivedColumnStore {
11-
tableColumns: Readable<Column[]>
12-
displayColumn: Readable<Column | undefined>
13-
columnLookupMap: Readable<Record<string, Column>>
14-
visibleColumns: Readable<Column[]>
15-
scrollableColumns: Readable<Column[]>
11+
tableColumns: Readable<UIColumn[]>
12+
displayColumn: Readable<UIColumn | undefined>
13+
columnLookupMap: Readable<Record<string, UIColumn>>
14+
visibleColumns: Readable<UIColumn[]>
15+
scrollableColumns: Readable<UIColumn[]>
1616
hasNonAutoColumn: Readable<boolean>
1717
}
1818

1919
export type Store = ColumnStore & DerivedColumnStore
2020

21-
type Column = FieldSchema & {
22-
label: string
23-
readonly: boolean
24-
conditions: any
25-
related?: {
26-
field: string
27-
subField: string
28-
}
29-
primaryDisplay?: boolean
30-
schema?: {
31-
disabled: boolean
32-
type: FieldType
33-
readonly: boolean
34-
autocolumn: boolean
35-
}
36-
calculationType: CalculationType
37-
}
38-
3921
export const createStores = (): ColumnStore => {
40-
const columns = writable<Column[]>([])
22+
const columns = writable<UIColumn[]>([])
4123

4224
// Enrich columns with metadata about their display position
4325
const enrichedColumns = derived(columns, $columns => {
@@ -70,7 +52,7 @@ export const deriveStores = (context: StoreContext): DerivedColumnStore => {
7052

7153
// Derive a lookup map for all columns by name
7254
const columnLookupMap = derived(columns, $columns => {
73-
let map: Record<string, Column> = {}
55+
let map: Record<string, UIColumn> = {}
7456
$columns.forEach(column => {
7557
map[column.name] = column
7658
})
@@ -136,7 +118,7 @@ export const createActions = (context: StoreContext) => {
136118
}
137119

138120
// Checks if a column is readonly
139-
const isReadonly = (column: Column) => {
121+
const isReadonly = (column: UIColumn) => {
140122
if (!column?.schema) {
141123
return false
142124
}
@@ -186,7 +168,7 @@ export const initialise = (context: StoreContext) => {
186168
.map(field => {
187169
const fieldSchema = $enrichedSchema[field]
188170
const oldColumn = $columns?.find(col => col.name === field)
189-
const column: Column = {
171+
const column: UIColumn = {
190172
type: fieldSchema.type,
191173
name: field,
192174
label: fieldSchema.displayName || field,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { CalculationType, FieldSchema, FieldType } from "@budibase/types"
2+
3+
export type UIColumn = FieldSchema & {
4+
label: string
5+
readonly: boolean
6+
conditions: any
7+
related?: {
8+
field: string
9+
subField: string
10+
}
11+
primaryDisplay?: boolean
12+
schema?: {
13+
disabled: boolean
14+
type: FieldType
15+
readonly: boolean
16+
autocolumn: boolean
17+
}
18+
calculationType: CalculationType
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./columns"

packages/types/src/ui/stores/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./integration"
2+
export * from "./grid"

0 commit comments

Comments
 (0)