@ternarytech-io/gears-ui 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -161
- package/package.json +4 -2
- package/src/components/TChart.vue +188 -0
- package/src/components/TDataGrid.vue +41 -0
- package/src/components/TDataGridItem.vue +23 -0
- package/src/components/TEditableTable.vue +203 -0
- package/src/components/TRadiusPicker.vue +21 -21
- package/src/components/TSparkline.vue +34 -0
- package/src/components/TStatCard.vue +36 -6
- package/src/components/TTable.vue +138 -134
- package/src/index.ts +16 -4
- package/src/plugins/charts.ts +4 -0
- package/src/plugins/index.ts +55 -52
- package/src/styles/gears.css +660 -625
- package/src/theme.ts +50 -45
- package/src/types.ts +38 -1
package/src/theme.ts
CHANGED
|
@@ -1,45 +1,50 @@
|
|
|
1
|
-
// The choices an application's theme offers, with their labels: Tabler's theme settings
|
|
2
|
-
// (tabler-themes.css) in the order its own theme settings list them, then layout.
|
|
3
|
-
import type { SelectItem, ThemeBase, ThemeContainer, ThemeDensity, ThemeFont, ThemeNav, ThemeRadius } from './types'
|
|
4
|
-
|
|
5
|
-
export const themeAccents = [
|
|
6
|
-
'blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan'
|
|
7
|
-
] as const
|
|
8
|
-
|
|
9
|
-
export const themeFonts: SelectItem<ThemeFont>[] = [
|
|
10
|
-
{ label: 'Sans-serif', value: 'sans-serif' },
|
|
11
|
-
{ label: 'Serif', value: 'serif' },
|
|
12
|
-
{ label: 'Monospace', value: 'monospace' },
|
|
13
|
-
{ label: 'Comic', value: 'comic' }
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
export const themeBases: SelectItem<ThemeBase>[] = [
|
|
17
|
-
{ label: 'Slate', value: 'slate' },
|
|
18
|
-
{ label: 'Gray', value: 'gray' },
|
|
19
|
-
{ label: 'Zinc', value: 'zinc' },
|
|
20
|
-
{ label: 'Neutral', value: 'neutral' },
|
|
21
|
-
{ label: 'Stone', value: 'stone' },
|
|
22
|
-
{ label: 'Mist', value: 'mist' }
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{ label:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export const
|
|
34
|
-
{ label: '
|
|
35
|
-
{ label: '
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{ label: '
|
|
41
|
-
{ label: '
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
// The choices an application's theme offers, with their labels: Tabler's theme settings
|
|
2
|
+
// (tabler-themes.css) in the order its own theme settings list them, then layout.
|
|
3
|
+
import type { SelectItem, ThemeBase, ThemeContainer, ThemeDensity, ThemeFont, ThemeNav, ThemeRadius } from './types'
|
|
4
|
+
|
|
5
|
+
export const themeAccents = [
|
|
6
|
+
'blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan'
|
|
7
|
+
] as const
|
|
8
|
+
|
|
9
|
+
export const themeFonts: SelectItem<ThemeFont>[] = [
|
|
10
|
+
{ label: 'Sans-serif', value: 'sans-serif' },
|
|
11
|
+
{ label: 'Serif', value: 'serif' },
|
|
12
|
+
{ label: 'Monospace', value: 'monospace' },
|
|
13
|
+
{ label: 'Comic', value: 'comic' }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export const themeBases: SelectItem<ThemeBase>[] = [
|
|
17
|
+
{ label: 'Slate', value: 'slate' },
|
|
18
|
+
{ label: 'Gray', value: 'gray' },
|
|
19
|
+
{ label: 'Zinc', value: 'zinc' },
|
|
20
|
+
{ label: 'Neutral', value: 'neutral' },
|
|
21
|
+
{ label: 'Stone', value: 'stone' },
|
|
22
|
+
{ label: 'Mist', value: 'mist' }
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
// The corner radius: the theme's base radius is one of Tabler's sizes (0, xs, sm, md, lg, xl), and
|
|
26
|
+
// the other corners follow in proportion. 1.5 (md, 6px) is Tabler's own.
|
|
27
|
+
export const themeRadiusSizes: Record<ThemeRadius, string> = { '0': '0px', '0.5': '2px', '1': '4px', '1.5': '6px', '2': '8px', '2.5': '16px' }
|
|
28
|
+
const radiusNames: Record<ThemeRadius, string> = { '0': 'None', '0.5': 'Extra small', '1': 'Small', '1.5': 'Medium', '2': 'Large', '2.5': 'Extra large' }
|
|
29
|
+
export const themeRadii: SelectItem<ThemeRadius>[] = (['0', '0.5', '1', '1.5', '2', '2.5'] as ThemeRadius[])
|
|
30
|
+
.map(r => ({ label: r, value: r, description: `${radiusNames[r]}, ${themeRadiusSizes[r]}` }))
|
|
31
|
+
|
|
32
|
+
// Layout choices (not Tabler theme settings; TThemeScope and TAppLayout apply them).
|
|
33
|
+
export const themeNavs: SelectItem<ThemeNav>[] = [
|
|
34
|
+
{ label: 'Left', value: 'left' },
|
|
35
|
+
{ label: 'Top', value: 'top' }
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export const themeDensities: SelectItem<ThemeDensity>[] = [
|
|
39
|
+
{ label: 'Compact', value: 'compact' },
|
|
40
|
+
{ label: 'Comfortable', value: 'comfortable' },
|
|
41
|
+
{ label: 'Spacious', value: 'spacious' }
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
export const themeContainers: SelectItem<ThemeContainer>[] = [
|
|
45
|
+
{ label: 'Boxed', value: 'boxed' },
|
|
46
|
+
{ label: 'Fluid', value: 'fluid' }
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
/** Whether an accent is a custom color (#rrggbb) rather than one of Tabler's named colors. */
|
|
50
|
+
export const isCustomAccent = (accent: string | undefined) => !!accent && accent.startsWith('#')
|
package/src/types.ts
CHANGED
|
@@ -80,6 +80,43 @@ export interface TableColumn<Row = Record<string, unknown>> {
|
|
|
80
80
|
value?: (row: Row) => unknown
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// TChart: what it draws, and a named list of values along its categories.
|
|
84
|
+
export type ChartType = 'line' | 'area' | 'bar' | 'column' | 'pie' | 'donut'
|
|
85
|
+
export interface ChartSeries {
|
|
86
|
+
name: string
|
|
87
|
+
data: (number | null)[]
|
|
88
|
+
// A named color ('success') or any CSS color; by default the theme's next chart color.
|
|
89
|
+
color?: Color | string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// TEditableTable: a column's kind decides how its cells are written, aligned and edited.
|
|
93
|
+
export type EditableTableColumnType = 'text' | 'number' | 'date' | 'boolean'
|
|
94
|
+
export interface EditableTableColumn<Row = Record<string, unknown>> extends TableColumn<Row> {
|
|
95
|
+
type?: EditableTableColumnType
|
|
96
|
+
// Cells can be edited in place (when the table is editable).
|
|
97
|
+
editable?: boolean
|
|
98
|
+
// Long values are cut to one line, at this width (CSS), with the whole value on hover.
|
|
99
|
+
truncate?: string
|
|
100
|
+
// Writes the cell's value; by default numbers and dates in the browser's format.
|
|
101
|
+
format?: (value: unknown, row: Row) => string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// A TEditableTable cell edited in place: the row, the column's key and the new value.
|
|
105
|
+
export interface TableEdit<Row = Record<string, unknown>> {
|
|
106
|
+
row: Row
|
|
107
|
+
key: string
|
|
108
|
+
value: unknown
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// TDataGrid: a label and its value, in Tabler's datagrid. `key` names the slot that draws the value
|
|
112
|
+
// (`#{key}`); `copy` adds a button that copies it; an empty value is written as a dash.
|
|
113
|
+
export interface DataGridItem {
|
|
114
|
+
key?: string
|
|
115
|
+
label: string
|
|
116
|
+
value?: string | number | boolean | null
|
|
117
|
+
copy?: boolean
|
|
118
|
+
}
|
|
119
|
+
|
|
83
120
|
export interface TableSort {
|
|
84
121
|
key: string
|
|
85
122
|
direction: 'asc' | 'desc'
|
|
@@ -146,7 +183,7 @@ export interface CommandGroup {
|
|
|
146
183
|
// An application's theme, as Tabler's theme settings (the data-bs-theme-* attributes) take it.
|
|
147
184
|
export type ThemeFont = 'sans-serif' | 'serif' | 'monospace' | 'comic'
|
|
148
185
|
export type ThemeBase = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'mist'
|
|
149
|
-
export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2'
|
|
186
|
+
export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2' | '2.5'
|
|
150
187
|
// Tabler's named colors, or a custom color as #rrggbb.
|
|
151
188
|
export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'cyan' | (string & {})
|
|
152
189
|
|