@ternarytech-io/gears-ui 0.5.0 → 0.6.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 +164 -163
- package/package.json +122 -122
- package/src/components/TButtonGroup.vue +48 -0
- package/src/components/TDropdown.vue +5 -35
- package/src/components/TPdfViewer.vue +4 -1
- package/src/components/TSplitButton.vue +54 -0
- package/src/components/TTimeInput.vue +159 -0
- package/src/components/TToaster.vue +38 -7
- package/src/components/internal/DropdownItems.vue +49 -0
- package/src/composables/useToast.ts +26 -4
- package/src/index.ts +249 -243
- package/src/plugins/index.ts +62 -59
- package/src/types.ts +234 -222
package/src/types.ts
CHANGED
|
@@ -1,222 +1,234 @@
|
|
|
1
|
-
// Shared prop types. Colors and sizes use the same names as Nuxt UI, so code moving from it keeps
|
|
2
|
-
// its props; `toTabler` maps a color to the name Tabler's classes use.
|
|
3
|
-
|
|
4
|
-
export type Color = 'primary' | 'neutral' | 'success' | 'warning' | 'error' | 'info'
|
|
5
|
-
export type Size = 'xs' | 'sm' | 'md' | 'lg'
|
|
6
|
-
|
|
7
|
-
const tablerColors: Record<Color, string> = {
|
|
8
|
-
primary: 'primary',
|
|
9
|
-
neutral: 'secondary',
|
|
10
|
-
success: 'success',
|
|
11
|
-
warning: 'warning',
|
|
12
|
-
error: 'danger',
|
|
13
|
-
info: 'info'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function toTabler(color: Color): string {
|
|
17
|
-
return tablerColors[color]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// A route location for RouterLink, or a plain URL.
|
|
21
|
-
export type Target = string | Record<string, unknown>
|
|
22
|
-
|
|
23
|
-
export interface DropdownItem {
|
|
24
|
-
label?: string
|
|
25
|
-
description?: string
|
|
26
|
-
icon?: string
|
|
27
|
-
trailingIcon?: string
|
|
28
|
-
// `label` items are headings; they can't be chosen.
|
|
29
|
-
type?: 'item' | 'label'
|
|
30
|
-
color?: Color
|
|
31
|
-
to?: Target
|
|
32
|
-
href?: string
|
|
33
|
-
disabled?: boolean
|
|
34
|
-
onSelect?: (event: Event) => void
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
export
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
//
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
export interface
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
label
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
export
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
1
|
+
// Shared prop types. Colors and sizes use the same names as Nuxt UI, so code moving from it keeps
|
|
2
|
+
// its props; `toTabler` maps a color to the name Tabler's classes use.
|
|
3
|
+
|
|
4
|
+
export type Color = 'primary' | 'neutral' | 'success' | 'warning' | 'error' | 'info'
|
|
5
|
+
export type Size = 'xs' | 'sm' | 'md' | 'lg'
|
|
6
|
+
|
|
7
|
+
const tablerColors: Record<Color, string> = {
|
|
8
|
+
primary: 'primary',
|
|
9
|
+
neutral: 'secondary',
|
|
10
|
+
success: 'success',
|
|
11
|
+
warning: 'warning',
|
|
12
|
+
error: 'danger',
|
|
13
|
+
info: 'info'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function toTabler(color: Color): string {
|
|
17
|
+
return tablerColors[color]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// A route location for RouterLink, or a plain URL.
|
|
21
|
+
export type Target = string | Record<string, unknown>
|
|
22
|
+
|
|
23
|
+
export interface DropdownItem {
|
|
24
|
+
label?: string
|
|
25
|
+
description?: string
|
|
26
|
+
icon?: string
|
|
27
|
+
trailingIcon?: string
|
|
28
|
+
// `label` items are headings; they can't be chosen.
|
|
29
|
+
type?: 'item' | 'label'
|
|
30
|
+
color?: Color
|
|
31
|
+
to?: Target
|
|
32
|
+
href?: string
|
|
33
|
+
disabled?: boolean
|
|
34
|
+
onSelect?: (event: Event) => void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A button of a TButtonGroup: a label and/or an icon (give an icon-only one a tooltip). */
|
|
38
|
+
export interface ButtonGroupItem {
|
|
39
|
+
label?: string
|
|
40
|
+
icon?: string
|
|
41
|
+
tooltip?: string
|
|
42
|
+
disabled?: boolean
|
|
43
|
+
/** Its own color, instead of the group's. */
|
|
44
|
+
color?: Color
|
|
45
|
+
/** Names it (and keys it): reported with its click. */
|
|
46
|
+
value?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface NavItem {
|
|
50
|
+
label: string
|
|
51
|
+
icon?: string
|
|
52
|
+
to?: Target
|
|
53
|
+
// Active only on this exact route, not on routes under it.
|
|
54
|
+
exact?: boolean
|
|
55
|
+
badge?: string | { label: string; color?: Color }
|
|
56
|
+
children?: NavItem[]
|
|
57
|
+
defaultOpen?: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SelectItem<T = unknown> {
|
|
61
|
+
label: string
|
|
62
|
+
value: T
|
|
63
|
+
description?: string
|
|
64
|
+
disabled?: boolean
|
|
65
|
+
// Items with the same group are listed together under it.
|
|
66
|
+
group?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// An item of TAdvancedSelect: an icon or avatar initials can show beside the label.
|
|
70
|
+
export interface AdvancedSelectItem<T = unknown> extends SelectItem<T> {
|
|
71
|
+
icon?: string
|
|
72
|
+
avatar?: string
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** An item of a TCheckboxTree: a leaf, or a parent with children. */
|
|
76
|
+
export interface TreeItem<T = string> {
|
|
77
|
+
label: string
|
|
78
|
+
value: T
|
|
79
|
+
children?: TreeItem<T>[]
|
|
80
|
+
disabled?: boolean
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface TabItem {
|
|
84
|
+
label: string
|
|
85
|
+
value: string
|
|
86
|
+
icon?: string
|
|
87
|
+
badge?: string | number
|
|
88
|
+
disabled?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface TableColumn<Row = Record<string, unknown>> {
|
|
92
|
+
key: string
|
|
93
|
+
label?: string
|
|
94
|
+
align?: 'start' | 'center' | 'end'
|
|
95
|
+
width?: string
|
|
96
|
+
sortable?: boolean
|
|
97
|
+
// TAdvancedTable: whether the column has a filter (on unless false; columns without a label have none).
|
|
98
|
+
filterable?: boolean
|
|
99
|
+
// Shown when the cell has no slot; defaults to `row[key]`.
|
|
100
|
+
value?: (row: Row) => unknown
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// TChart: what it draws, and a named list of values along its categories.
|
|
104
|
+
export type ChartType = 'line' | 'area' | 'bar' | 'column' | 'pie' | 'donut'
|
|
105
|
+
export interface ChartSeries {
|
|
106
|
+
name: string
|
|
107
|
+
data: (number | null)[]
|
|
108
|
+
// A named color ('success') or any CSS color; by default the theme's next chart color.
|
|
109
|
+
color?: Color | string
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// TEditableTable: a column's kind decides how its cells are written, aligned and edited.
|
|
113
|
+
export type EditableTableColumnType = 'text' | 'number' | 'date' | 'boolean'
|
|
114
|
+
export interface EditableTableColumn<Row = Record<string, unknown>> extends TableColumn<Row> {
|
|
115
|
+
type?: EditableTableColumnType
|
|
116
|
+
// Cells can be edited in place (when the table is editable).
|
|
117
|
+
editable?: boolean
|
|
118
|
+
// Long values are cut to one line, at this width (CSS), with the whole value on hover.
|
|
119
|
+
truncate?: string
|
|
120
|
+
// Writes the cell's value; by default numbers and dates in the browser's format.
|
|
121
|
+
format?: (value: unknown, row: Row) => string
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// A TEditableTable cell edited in place: the row, the column's key and the new value.
|
|
125
|
+
export interface TableEdit<Row = Record<string, unknown>> {
|
|
126
|
+
row: Row
|
|
127
|
+
key: string
|
|
128
|
+
value: unknown
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// TDataGrid: a label and its value, in Tabler's datagrid. `key` names the slot that draws the value
|
|
132
|
+
// (`#{key}`); `copy` adds a button that copies it; an empty value is written as a dash.
|
|
133
|
+
export interface DataGridItem {
|
|
134
|
+
key?: string
|
|
135
|
+
label: string
|
|
136
|
+
value?: string | number | boolean | null
|
|
137
|
+
copy?: boolean
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface TableSort {
|
|
141
|
+
key: string
|
|
142
|
+
direction: 'asc' | 'desc'
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// How a TAdvancedTable column filter compares a cell with its value.
|
|
146
|
+
export type TableFilterOperator = 'equals' | 'notEquals' | 'contains' | 'greaterThan' | 'lessThan' | 'atLeast' | 'atMost'
|
|
147
|
+
|
|
148
|
+
export interface TableFilter {
|
|
149
|
+
operator: TableFilterOperator
|
|
150
|
+
value: string
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface StepItem {
|
|
154
|
+
title: string
|
|
155
|
+
description?: string
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface LogLine {
|
|
159
|
+
id?: string | number
|
|
160
|
+
time?: string
|
|
161
|
+
text: string
|
|
162
|
+
level?: 'error' | 'warning' | 'highlight' | 'muted'
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// A suggestion a TCodeEditor offers while typing.
|
|
166
|
+
export interface CodeCompletion {
|
|
167
|
+
label: string
|
|
168
|
+
kind?: 'keyword' | 'table' | 'field' | 'function' | 'value' | 'snippet'
|
|
169
|
+
// What's inserted; the label when omitted.
|
|
170
|
+
insertText?: string
|
|
171
|
+
detail?: string
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface PanelListItem<T = string> {
|
|
175
|
+
value: T
|
|
176
|
+
label: string
|
|
177
|
+
icon?: string
|
|
178
|
+
// Small text at the item's end, such as a count or a tag.
|
|
179
|
+
trailing?: string
|
|
180
|
+
title?: string
|
|
181
|
+
// Shown in red: something in it needs fixing.
|
|
182
|
+
invalid?: boolean
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// An item of TCommandPalette: a page to go to (`to`) or an action (`onSelect`).
|
|
186
|
+
export interface CommandItem {
|
|
187
|
+
label: string
|
|
188
|
+
icon?: string
|
|
189
|
+
// Shown after the label, smaller; searched too (a project's namespace, a page's section).
|
|
190
|
+
suffix?: string
|
|
191
|
+
// More words that find the item without being shown.
|
|
192
|
+
keywords?: string[]
|
|
193
|
+
to?: Target
|
|
194
|
+
onSelect?: () => void
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface CommandGroup {
|
|
198
|
+
id: string
|
|
199
|
+
label?: string
|
|
200
|
+
items: CommandItem[]
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// An application's theme, as Tabler's theme settings (the data-bs-theme-* attributes) take it.
|
|
204
|
+
export type ThemeFont = 'sans-serif' | 'serif' | 'monospace' | 'comic'
|
|
205
|
+
export type ThemeBase = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'mist'
|
|
206
|
+
export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2' | '2.5'
|
|
207
|
+
// Tabler's named colors, or a custom color as #rrggbb.
|
|
208
|
+
export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'cyan' | (string & {})
|
|
209
|
+
|
|
210
|
+
// An application's layout: where its navigation goes and how it behaves, how much room things
|
|
211
|
+
// get, and whether the page sits in a box.
|
|
212
|
+
export type ThemeNav = 'left' | 'top'
|
|
213
|
+
export type ThemeDensity = 'compact' | 'comfortable' | 'spacious'
|
|
214
|
+
export type ThemeContainer = 'boxed' | 'fluid'
|
|
215
|
+
|
|
216
|
+
export interface ThemeSettings {
|
|
217
|
+
accent?: ThemeAccent
|
|
218
|
+
font?: ThemeFont
|
|
219
|
+
base?: ThemeBase
|
|
220
|
+
radius?: ThemeRadius
|
|
221
|
+
// Light or dark; unset follows the surrounding page.
|
|
222
|
+
mode?: 'light' | 'dark'
|
|
223
|
+
// Padding and gaps (TThemeScope applies it).
|
|
224
|
+
density?: ThemeDensity
|
|
225
|
+
// The rest is layout (TAppLayout applies it).
|
|
226
|
+
nav?: ThemeNav
|
|
227
|
+
// Left navigation: whether it folds to icons.
|
|
228
|
+
navFoldable?: boolean
|
|
229
|
+
// Top navigation: whether it stays at the top while the page scrolls, and whether it floats
|
|
230
|
+
// apart from the page's edges.
|
|
231
|
+
navSticky?: boolean
|
|
232
|
+
navFloating?: boolean
|
|
233
|
+
container?: ThemeContainer
|
|
234
|
+
}
|