@ternarytech-io/gears-ui 0.0.0-stage → 0.2.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.
Files changed (98) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +161 -3
  3. package/package.json +111 -6
  4. package/src/code-editor.ts +25 -0
  5. package/src/components/TAccentPicker.vue +41 -0
  6. package/src/components/TAdvancedSelect.vue +128 -0
  7. package/src/components/TAdvancedTable.vue +130 -0
  8. package/src/components/TAlert.vue +41 -0
  9. package/src/components/TAppLayout.vue +76 -0
  10. package/src/components/TAuthLayout.vue +32 -0
  11. package/src/components/TAvatar.vue +28 -0
  12. package/src/components/TBadge.vue +29 -0
  13. package/src/components/TButton.vue +60 -0
  14. package/src/components/TCard.vue +40 -0
  15. package/src/components/TCheckbox.vue +29 -0
  16. package/src/components/TCodeEditor.vue +128 -0
  17. package/src/components/TColorModeButton.vue +14 -0
  18. package/src/components/TColorPicker.vue +61 -0
  19. package/src/components/TCommandPalette.vue +109 -0
  20. package/src/components/TContainerPicker.vue +22 -0
  21. package/src/components/TCopyButton.vue +72 -0
  22. package/src/components/TDatePicker.vue +83 -0
  23. package/src/components/TDensityPicker.vue +19 -0
  24. package/src/components/TDropdown.vue +76 -0
  25. package/src/components/TDropzone.vue +76 -0
  26. package/src/components/TEmpty.vue +21 -0
  27. package/src/components/TFieldGroup.vue +11 -0
  28. package/src/components/TFileUpload.vue +92 -0
  29. package/src/components/TFontPicker.vue +23 -0
  30. package/src/components/TFormField.vue +40 -0
  31. package/src/components/TIcon.vue +12 -0
  32. package/src/components/TImageUpload.vue +131 -0
  33. package/src/components/TInput.vue +52 -0
  34. package/src/components/TInputMask.vue +70 -0
  35. package/src/components/TInputNumber.vue +62 -0
  36. package/src/components/TInputTags.vue +53 -0
  37. package/src/components/TLogView.vue +39 -0
  38. package/src/components/TModal.vue +54 -0
  39. package/src/components/TNav.vue +75 -0
  40. package/src/components/TNavPositionPicker.vue +22 -0
  41. package/src/components/TPage.vue +48 -0
  42. package/src/components/TPagination.vue +44 -0
  43. package/src/components/TPanelList.vue +29 -0
  44. package/src/components/TProgress.vue +18 -0
  45. package/src/components/TRadioGroup.vue +68 -0
  46. package/src/components/TRadiusPicker.vue +21 -0
  47. package/src/components/TRangeSlider.vue +63 -0
  48. package/src/components/TRichEditor.vue +82 -0
  49. package/src/components/TScaledFrame.vue +36 -0
  50. package/src/components/TSearchButton.vue +20 -0
  51. package/src/components/TSectionLayout.vue +37 -0
  52. package/src/components/TSelect.vue +60 -0
  53. package/src/components/TSelectMenu.vue +126 -0
  54. package/src/components/TSeparator.vue +10 -0
  55. package/src/components/TShell.vue +72 -0
  56. package/src/components/TSkeleton.vue +17 -0
  57. package/src/components/TSlideover.vue +47 -0
  58. package/src/components/TSortable.vue +61 -0
  59. package/src/components/TSortableTree.vue +73 -0
  60. package/src/components/TSortableTreeList.vue +60 -0
  61. package/src/components/TSpinner.vue +14 -0
  62. package/src/components/TSplitter.vue +85 -0
  63. package/src/components/TStatCard.vue +26 -0
  64. package/src/components/TSteps.vue +19 -0
  65. package/src/components/TSwitch.vue +18 -0
  66. package/src/components/TTable.vue +134 -0
  67. package/src/components/TTabs.vue +38 -0
  68. package/src/components/TTextarea.vue +42 -0
  69. package/src/components/TThemeBasePicker.vue +22 -0
  70. package/src/components/TThemeScope.vue +23 -0
  71. package/src/components/TToaster.vue +27 -0
  72. package/src/components/TTooltip.vue +33 -0
  73. package/src/components/TTopbar.vue +17 -0
  74. package/src/components/TVectorMap.vue +74 -0
  75. package/src/components/sortableTree.ts +19 -0
  76. package/src/composables/useColorMode.ts +41 -0
  77. package/src/composables/useCommandPalette.ts +11 -0
  78. package/src/composables/useField.ts +26 -0
  79. package/src/composables/useOverlay.ts +55 -0
  80. package/src/composables/useToast.ts +33 -0
  81. package/src/index.ts +215 -0
  82. package/src/monaco.ts +27 -0
  83. package/src/plugins/coloris.ts +8 -0
  84. package/src/plugins/datepicker.ts +7 -0
  85. package/src/plugins/dropzone.ts +5 -0
  86. package/src/plugins/index.ts +52 -0
  87. package/src/plugins/inputMask.ts +7 -0
  88. package/src/plugins/once.ts +8 -0
  89. package/src/plugins/richEditor.ts +37 -0
  90. package/src/plugins/slider.ts +4 -0
  91. package/src/plugins/sortable.ts +7 -0
  92. package/src/plugins/tomSelect.ts +4 -0
  93. package/src/shims.d.ts +17 -0
  94. package/src/styles/gears.css +625 -0
  95. package/src/styles/plugins.css +10 -0
  96. package/src/theme.ts +45 -0
  97. package/src/types.ts +177 -0
  98. package/src/vectorMap.ts +14 -0
package/src/types.ts ADDED
@@ -0,0 +1,177 @@
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
+ export interface NavItem {
38
+ label: string
39
+ icon?: string
40
+ to?: Target
41
+ // Active only on this exact route, not on routes under it.
42
+ exact?: boolean
43
+ badge?: string | { label: string; color?: Color }
44
+ children?: NavItem[]
45
+ defaultOpen?: boolean
46
+ }
47
+
48
+ export interface SelectItem<T = unknown> {
49
+ label: string
50
+ value: T
51
+ description?: string
52
+ disabled?: boolean
53
+ // Items with the same group are listed together under it.
54
+ group?: string
55
+ }
56
+
57
+ // An item of TAdvancedSelect: an icon or avatar initials can show beside the label.
58
+ export interface AdvancedSelectItem<T = unknown> extends SelectItem<T> {
59
+ icon?: string
60
+ avatar?: string
61
+ }
62
+
63
+ export interface TabItem {
64
+ label: string
65
+ value: string
66
+ icon?: string
67
+ badge?: string | number
68
+ disabled?: boolean
69
+ }
70
+
71
+ export interface TableColumn<Row = Record<string, unknown>> {
72
+ key: string
73
+ label?: string
74
+ align?: 'start' | 'center' | 'end'
75
+ width?: string
76
+ sortable?: boolean
77
+ // TAdvancedTable: whether the column has a filter (on unless false; columns without a label have none).
78
+ filterable?: boolean
79
+ // Shown when the cell has no slot; defaults to `row[key]`.
80
+ value?: (row: Row) => unknown
81
+ }
82
+
83
+ export interface TableSort {
84
+ key: string
85
+ direction: 'asc' | 'desc'
86
+ }
87
+
88
+ // How a TAdvancedTable column filter compares a cell with its value.
89
+ export type TableFilterOperator = 'equals' | 'notEquals' | 'contains' | 'greaterThan' | 'lessThan' | 'atLeast' | 'atMost'
90
+
91
+ export interface TableFilter {
92
+ operator: TableFilterOperator
93
+ value: string
94
+ }
95
+
96
+ export interface StepItem {
97
+ title: string
98
+ description?: string
99
+ }
100
+
101
+ export interface LogLine {
102
+ id?: string | number
103
+ time?: string
104
+ text: string
105
+ level?: 'error' | 'warning' | 'highlight' | 'muted'
106
+ }
107
+
108
+ // A suggestion a TCodeEditor offers while typing.
109
+ export interface CodeCompletion {
110
+ label: string
111
+ kind?: 'keyword' | 'table' | 'field' | 'function' | 'value' | 'snippet'
112
+ // What's inserted; the label when omitted.
113
+ insertText?: string
114
+ detail?: string
115
+ }
116
+
117
+ export interface PanelListItem<T = string> {
118
+ value: T
119
+ label: string
120
+ icon?: string
121
+ // Small text at the item's end, such as a count or a tag.
122
+ trailing?: string
123
+ title?: string
124
+ // Shown in red: something in it needs fixing.
125
+ invalid?: boolean
126
+ }
127
+
128
+ // An item of TCommandPalette: a page to go to (`to`) or an action (`onSelect`).
129
+ export interface CommandItem {
130
+ label: string
131
+ icon?: string
132
+ // Shown after the label, smaller; searched too (a project's namespace, a page's section).
133
+ suffix?: string
134
+ // More words that find the item without being shown.
135
+ keywords?: string[]
136
+ to?: Target
137
+ onSelect?: () => void
138
+ }
139
+
140
+ export interface CommandGroup {
141
+ id: string
142
+ label?: string
143
+ items: CommandItem[]
144
+ }
145
+
146
+ // An application's theme, as Tabler's theme settings (the data-bs-theme-* attributes) take it.
147
+ export type ThemeFont = 'sans-serif' | 'serif' | 'monospace' | 'comic'
148
+ export type ThemeBase = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'mist'
149
+ export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2'
150
+ // Tabler's named colors, or a custom color as #rrggbb.
151
+ export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'cyan' | (string & {})
152
+
153
+ // An application's layout: where its navigation goes and how it behaves, how much room things
154
+ // get, and whether the page sits in a box.
155
+ export type ThemeNav = 'left' | 'top'
156
+ export type ThemeDensity = 'compact' | 'comfortable' | 'spacious'
157
+ export type ThemeContainer = 'boxed' | 'fluid'
158
+
159
+ export interface ThemeSettings {
160
+ accent?: ThemeAccent
161
+ font?: ThemeFont
162
+ base?: ThemeBase
163
+ radius?: ThemeRadius
164
+ // Light or dark; unset follows the surrounding page.
165
+ mode?: 'light' | 'dark'
166
+ // Padding and gaps (TThemeScope applies it).
167
+ density?: ThemeDensity
168
+ // The rest is layout (TAppLayout applies it).
169
+ nav?: ThemeNav
170
+ // Left navigation: whether it folds to icons.
171
+ navFoldable?: boolean
172
+ // Top navigation: whether it stays at the top while the page scrolls, and whether it floats
173
+ // apart from the page's edges.
174
+ navSticky?: boolean
175
+ navFloating?: boolean
176
+ container?: ThemeContainer
177
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference path="./shims.d.ts" />
2
+ // Loads Tabler's vector map and the world map data the first time a TVectorMap is shown. Both ship
3
+ // with @tabler/core, so this needs no optional library.
4
+ let promise: Promise<typeof import('@tabler/core/dist/js/tabler-vector-map.esm.js').VectorMap> | undefined
5
+
6
+ export function loadVectorMap() {
7
+ return promise ??= Promise.all([
8
+ import('@tabler/core/dist/js/tabler-vector-map.esm.js'),
9
+ import('@tabler/core/dist/js/maps/world.esm.js')
10
+ ]).then(([{ VectorMap }, { world }]) => {
11
+ VectorMap.addMap('world', world)
12
+ return VectorMap
13
+ })
14
+ }