@ternarytech-io/gears-ui 0.3.3 → 0.4.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 -162
- package/package.json +12 -9
- package/src/components/TChart.vue +225 -188
- package/src/components/TCheckboxTree.vue +82 -0
- package/src/components/TListBox.vue +111 -0
- package/src/index.ts +8 -2
- package/src/plugins/charts.ts +18 -4
- package/src/types.ts +8 -0
package/README.md
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
# Gears UI
|
|
2
|
-
|
|
3
|
-
Vue 3 components on [Tabler](https://docs.tabler.io/ui) (Bootstrap 5 underneath), for the Gears Studio
|
|
4
|
-
and the apps Gears builds, plus a site that previews them.
|
|
5
|
-
|
|
6
|
-
```shell
|
|
7
|
-
npm install
|
|
8
|
-
npm run dev # the preview site at http://localhost:5175
|
|
9
|
-
npm run typecheck
|
|
10
|
-
npm run build # type-checks, then builds the preview site into dist/
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Or run the preview site in Docker, at <http://localhost:5175>:
|
|
14
|
-
|
|
15
|
-
```shell
|
|
16
|
-
docker compose up -d # builds the image every time (pull_policy: build), then serves it with nginx
|
|
17
|
-
docker compose down
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Installing
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
npm install @ternarytech-io/gears-ui vue vue-router
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
The package ships its Vue and TypeScript source, not a build: the app's bundler compiles it. That
|
|
27
|
-
needs Vite (or another bundler) with `@vitejs/plugin-vue`, and in Vite the package left out of
|
|
28
|
-
dependency pre-bundling, so its `.vue` files are compiled with the app's:
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
// vite.config.ts
|
|
32
|
-
export default defineConfig({
|
|
33
|
-
plugins: [vue()],
|
|
34
|
-
optimizeDeps: { exclude: ['@ternarytech-io/gears-ui'] }
|
|
35
|
-
})
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Using it
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
// main.ts
|
|
42
|
-
import '@ternarytech-io/gears-ui/styles.css'
|
|
43
|
-
import { createApp } from 'vue'
|
|
44
|
-
import GearsUI, { useColorMode } from '@ternarytech-io/gears-ui'
|
|
45
|
-
|
|
46
|
-
useColorMode() // applies the saved light/dark choice to <html>
|
|
47
|
-
createApp(App).use(router).use(GearsUI).mount('#app')
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Apps that use the plugin components also import `@ternarytech-io/gears-ui/plugins.css`, after `styles.css`.
|
|
51
|
-
|
|
52
|
-
The plugin registers every component globally (typed for templates). Components can also be imported
|
|
53
|
-
one by one: `import { TButton } from '@ternarytech-io/gears-ui'`. `vue` and `vue-router` are peer dependencies.
|
|
54
|
-
|
|
55
|
-
Components that need an optional library have entry points of their own, so an app installs only what
|
|
56
|
-
it uses:
|
|
57
|
-
|
|
58
|
-
| Entry | Components | Needs |
|
|
59
|
-
| --- | --- | --- |
|
|
60
|
-
| `@ternarytech-io/gears-ui` | Everything else | Nothing more |
|
|
61
|
-
| `@ternarytech-io/gears-ui/code-editor` | `TCodeEditor` (install with `GearsUICodeEditor`) | `monaco-editor` |
|
|
62
|
-
| `@ternarytech-io/gears-ui/plugins` | `TAdvancedSelect`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TRichEditor`, `TSortable`, `TSortableTree` (install with `GearsUIPlugins`) | Each one's library; and `@ternarytech-io/gears-ui/plugins.css` |
|
|
63
|
-
| `@ternarytech-io/gears-ui/components/T….vue` | Any one component on its own | Only that component's library |
|
|
64
|
-
|
|
65
|
-
`GearsUIPlugins` and `plugins.css` need all eight libraries. To use only some plugins, import those
|
|
66
|
-
components directly (`import TSortable from '@ternarytech-io/gears-ui/components/TSortable.vue'`; each loads only its
|
|
67
|
-
own library) and the CSS they need: Tom Select's `tom-select.bootstrap5.min.css`, and
|
|
68
|
-
`@tabler/core/dist/css/tabler-vendors.min.css` after it for the select, color picker, dropzone and slider.
|
|
69
|
-
|
|
70
|
-
From another repo, depend on a pinned commit: `"@ternarytech-io/gears-ui": "github:TernaryTech-io/Gears.UI#<commit>"`. The
|
|
71
|
-
package ships its sources, so the app's Vite compiles them; exclude it from pre-bundling with
|
|
72
|
-
`optimizeDeps: { exclude: ['@ternarytech-io/gears-ui'] }`.
|
|
73
|
-
|
|
74
|
-
The package ships its sources (`exports` points at `src/`), so it's consumed by a Vite app, as the Studio is.
|
|
75
|
-
|
|
76
|
-
## How it's built
|
|
77
|
-
|
|
78
|
-
- **Styles.** `src/styles/gears.css` imports Tabler's CSS and the Tabler Icons webfont (self-hosted: a
|
|
79
|
-
Gears server may have no internet), then sets the Gears palette through Tabler's CSS variables: primary
|
|
80
|
-
#3673d1, darkest black #1c1d1d, pages a shade off white, cards white (#232525 dark). Tabler 1.7 builds its
|
|
81
|
-
shades and dark mode from those variables with `light-dark()`, so there's no SCSS build.
|
|
82
|
-
- **Dark mode.** `data-bs-theme` on `<html>`, set by `useColorMode()` (light, dark or system; remembered).
|
|
83
|
-
The sidebar is dark in both themes.
|
|
84
|
-
- **Interactive components** (tooltip, dropdown, modal, slideover) drive Tabler's bundled Bootstrap JS
|
|
85
|
-
from Vue: created on mount, disposed on unmount, opened and closed through `v-model`.
|
|
86
|
-
- **Props follow Nuxt UI** (`color`, `variant`, `size`, `icon`, `trailingIcon`, `label`, `v-model:open`), so the
|
|
87
|
-
Studio's components move over mostly by renaming. Colors are `primary`, `neutral`, `success`, `warning`,
|
|
88
|
-
`error` and `info`; `toTabler()` maps them to Tabler's names (`neutral` → `secondary`, `error` → `danger`).
|
|
89
|
-
- **Icons** are Tabler Icons by name: `icon="plus"`. Browse them at <https://tabler.io/icons>.
|
|
90
|
-
- Tabler's own classes work alongside the components: the grid, spacing, `btn-list`, `row-cards`,
|
|
91
|
-
`list-group`, `datagrid`, `text-secondary`, …
|
|
92
|
-
|
|
93
|
-
## The preview site
|
|
94
|
-
|
|
95
|
-
`preview/` is a Vite app that uses the library the way an app does. Each component page lists the
|
|
96
|
-
examples in `preview/examples/{slug}/`, in file name order, live with their source under them; the file
|
|
97
|
-
name gives the title (`02-colors.vue` → "Colors") and a leading `<!-- comment -->` the description. To
|
|
98
|
-
add a page, add an entry to `preview/registry.ts` and a folder of examples.
|
|
99
|
-
|
|
100
|
-
## Components
|
|
101
|
-
|
|
102
|
-
| Group | Components |
|
|
103
|
-
| --- | --- |
|
|
104
|
-
| Elements | `TButton`, `TBadge`, `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` |
|
|
105
|
-
| Forms | `TFormField`, `TInput`, `TInputNumber`, `TTextarea`, `TSelect`, `TSelectMenu`, `TInputTags`, `TCheckbox`, `TSwitch`, `TRadioGroup` (list, cards or tiles with a picture), `TFieldGroup`, `TFileUpload`, `TImageUpload` (one image, checked for shape and size), `TIconPicker` (any Tabler icon, by name, with a search; the list is generated by `npm run icons`), `TRating` (stars, hearts or circles; no library), `TCodeEditor` |
|
|
106
|
-
| Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TNavPositionPicker`, `TDensityPicker`, `TContainerPicker` (layout), `TThemeScope` (applies a `ThemeSettings`' look and density to what's inside it); `themeAccents`, `themeFonts`, `themeBases`, `themeRadii`, `themeNavs`, `themeDensities`, `themeContainers` |
|
|
107
|
-
| Overlays | `TModal`, `TSlideover`, `TDropdown`, `TToaster` (with `useToast()`) |
|
|
108
|
-
| Navigation | `TTabs`, `TPagination`, `TSteps`, `TNav`, `TPanelList`, `TCommandPalette`, `TSearchButton` |
|
|
109
|
-
| Data | `TTable` (sorting, `selectable` rows), `TAdvancedTable` (filters by column), `TEditableTable` (editing in place, bulk actions, search, pages, column kinds; client-side or `manual`), `TDataGrid` and `TDataGridItem` (Tabler's datagrid: labels and values for detail panels), `TStatCard` (with a trend and a sparkline), `TSparkline` (Tabler's, no library), `TLogView` |
|
|
110
|
-
| Layout | `TAppLayout` (an application's frame, laid out by its theme, with a menu button on small screens), `TScaledFrame` (a whole screen scaled to fit), `TShell`, `TTopbar`, `TPage`, `TSectionLayout`, `TSplitter`, `TAuthLayout`, `TColorModeButton` |
|
|
111
|
-
| Plugins | `TAdvancedSelect`, `TChart`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TSortableTree`, `TVectorMap`, `TRichEditor` |
|
|
112
|
-
|
|
113
|
-
### Plugins
|
|
114
|
-
|
|
115
|
-
The components for [Tabler's plugins](https://docs.tabler.io/ui/plugins). Each library is an optional peer
|
|
116
|
-
dependency and loads the first time its component is shown (`src/plugins.ts`), so an app installs and
|
|
117
|
-
downloads only what it uses. Their CSS is in `@ternarytech-io/gears-ui/plugins.css`: each library's own styles, then
|
|
118
|
-
Tabler's restyling of them (`tabler-vendors.css`), which must come after.
|
|
119
|
-
|
|
120
|
-
| Component | Library | Notes |
|
|
121
|
-
| --- | --- | --- |
|
|
122
|
-
| `TAdvancedSelect` | Tom Select | One or several (`multiple`, as chips); `create` adds new values; icons and avatars beside labels. Overlaps `TSelectMenu`, which has no dependency. |
|
|
123
|
-
| `TChart` |
|
|
124
|
-
| `TCopyButton` | Tabler's clipboard | Copies `text`, or the field `target` selects. Needs https or localhost. |
|
|
125
|
-
| `TColorPicker` | Coloris | `format`, `alpha`, `swatches`, `swatchesOnly`. The field isn't wrapped by Coloris (Vue owns it); the swatch is ours. |
|
|
126
|
-
| `TDatePicker` | Tabler's date picker, on Vanilla Calendar Pro | `single`, `multiple` or `range`; `inline`; the model is `YYYY-MM-DD`, `format` only changes the display. |
|
|
127
|
-
| `TDropzone` | Dropzone | With `url`, uploads; without, v-model collects the files. |
|
|
128
|
-
| `TInputMask` | Tabler's input mask, on IMask | `mask` like "(000) 000-0000"; `unmasked`; `showMask`. |
|
|
129
|
-
| `TRangeSlider` | noUiSlider | A number, or a range with `[from, to]`. |
|
|
130
|
-
| `TSortable` | Tabler's sortable, on SortableJS | Reorders v-model's array. Lists within one container; dragging between lists isn't wired up yet. |
|
|
131
|
-
| `TVectorMap` | Tabler's vector map | The world map: `values`, `markers`, `lines`, `legend`, `select` with v-model:selected, `zoom`. |
|
|
132
|
-
| `TRichEditor` | HugeRTE (open-source TinyMCE fork) | v-model is HTML. Bundled skins and plugins, nothing fetched; follows the theme by rebuilding the editor. |
|
|
133
|
-
|
|
134
|
-
### From the Studio's components
|
|
135
|
-
|
|
136
|
-
| Studio (Nuxt UI) | Gears UI |
|
|
137
|
-
| --- | --- |
|
|
138
|
-
| `UButton`, `UBadge`, `UAvatar`, `UAlert`, `UCard`, `UIcon`, `UTooltip`, `UEmpty`, `USkeleton`, `USeparator`, `UProgress` | `T…` with the same name. Icons change from `i-lucide-*` to Tabler names. `UCard`'s header slot content moves to `title`/`subtitle`/`#actions`. |
|
|
139
|
-
| `UFormField`, `UInput`, `UTextarea`, `USelect`, `UCheckbox`, `USwitch`, `URadioGroup`, `UFieldGroup` | `TFormField` (`help` → `description`), `TInput`, `TTextarea`, `TSelect`, `TCheckbox`, `TSwitch`, `TRadioGroup`, `TFieldGroup` |
|
|
140
|
-
| `UModal`, `USlideover`, `UDropdownMenu` | `TModal`, `TSlideover`, `TDropdown` (same item groups; `onSelect`, `to`, `type: 'label'`) |
|
|
141
|
-
| `UTabs`, `UPagination`, `UStepper`, `UTable` | `TTabs` (`:content="false"` switches become `variant="segmented"`), `TPagination`, `TSteps`, `TTable` (cell slots get the row itself, not `row.original`; `#cell` draws any cell, `sticky` keeps the header) |
|
|
142
|
-
| `UInputNumber`, `UFileUpload` | `TInputNumber` (Tabler's number input: minus and plus, `min`, `max`, `step`), `TFileUpload` (`accept`, `multiple`; v-model holds the File, nothing uploads) |
|
|
143
|
-
| `UDashboardSearch`, `UDashboardSearchButton` | `TCommandPalette` (`groups` of items with `to` or `onSelect`; Ctrl+K / ⌘K) and `TSearchButton` (`collapsed` for the icon only). They share their open state; `useCommandPalette()` opens it from code |
|
|
144
|
-
| `USelectMenu`, `UInputTags`, `USplitter` | `TSelectMenu` (`multiple`; items take a `group` instead of `type: 'label'` rows; `v-model:search-term` with `ignore-filter` becomes `v-model:search` with `:filter="false"`), `TInputTags`, `TSplitter` (`#start` and `#end` slots, `storageKey`) |
|
|
145
|
-
| `UDashboardGroup` + `UDashboardSidebar` + `UNavigationMenu` | `TShell` with `nav` items (`TNav`) |
|
|
146
|
-
| `UDashboardPanel` + `UDashboardNavbar` | `TTopbar` + `TPage` |
|
|
147
|
-
| `UColorModeButton` | `TColorModeButton` |
|
|
148
|
-
| `useToast()` (with `UApp`) | `useToast()` from `@ternarytech-io/gears-ui`, the same `add({ title, description, color, icon })`, and a `TToaster` in the frame |
|
|
149
|
-
| `StatCard`, `AuthCard`, `SectionLayout` | `TStatCard`, `TAuthLayout` (brand and logo are props), `TSectionLayout` |
|
|
150
|
-
| `BuildLog`, `AppLog` | Their polling stays in the Studio; the display is `TLogView` (`text`, or `lines` with times and levels, and `v-model:follow`) |
|
|
151
|
-
| `CodeEditor` | `TCodeEditor` (same props; `Completion` is `CodeCompletion`; `flush` replaces the border overrides). Monaco's setup moves to `src/monaco.ts`, with themes `gears-light` and `gears-dark` |
|
|
152
|
-
| `CodePanel`, `QueryPanel`, `FilterGroupEditor` | Stay in the Studio (they call its API). Rebuilt on Gears UI in the preview's Studio pages, against mock data in `preview/studio/`: the side-panel lists are `TPanelList`, and the results card is a component of its own instead of VueUse's reusable template |
|
|
153
|
-
| `StudioPage`, `ProjectSwitcher`, user menu | Compositions of `TTopbar`, `TDropdown`, `TAvatar` and `TPage`: see the Top bar and Dropdown pages |
|
|
154
|
-
|
|
155
|
-
### Still to do
|
|
156
|
-
|
|
157
|
-
Every Nuxt UI component the Studio uses now has a Gears UI version. The preview site has no generated
|
|
158
|
-
props tables yet; the examples are the reference.
|
|
159
|
-
|
|
160
|
-
## License
|
|
161
|
-
|
|
162
|
-
[Mozilla Public License 2.0](LICENSE), as Ternary.Data.
|
|
1
|
+
# Gears UI
|
|
2
|
+
|
|
3
|
+
Vue 3 components on [Tabler](https://docs.tabler.io/ui) (Bootstrap 5 underneath), for the Gears Studio
|
|
4
|
+
and the apps Gears builds, plus a site that previews them.
|
|
5
|
+
|
|
6
|
+
```shell
|
|
7
|
+
npm install
|
|
8
|
+
npm run dev # the preview site at http://localhost:5175
|
|
9
|
+
npm run typecheck
|
|
10
|
+
npm run build # type-checks, then builds the preview site into dist/
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or run the preview site in Docker, at <http://localhost:5175>:
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
docker compose up -d # builds the image every time (pull_policy: build), then serves it with nginx
|
|
17
|
+
docker compose down
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Installing
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
npm install @ternarytech-io/gears-ui vue vue-router
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The package ships its Vue and TypeScript source, not a build: the app's bundler compiles it. That
|
|
27
|
+
needs Vite (or another bundler) with `@vitejs/plugin-vue`, and in Vite the package left out of
|
|
28
|
+
dependency pre-bundling, so its `.vue` files are compiled with the app's:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// vite.config.ts
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
plugins: [vue()],
|
|
34
|
+
optimizeDeps: { exclude: ['@ternarytech-io/gears-ui'] }
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Using it
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// main.ts
|
|
42
|
+
import '@ternarytech-io/gears-ui/styles.css'
|
|
43
|
+
import { createApp } from 'vue'
|
|
44
|
+
import GearsUI, { useColorMode } from '@ternarytech-io/gears-ui'
|
|
45
|
+
|
|
46
|
+
useColorMode() // applies the saved light/dark choice to <html>
|
|
47
|
+
createApp(App).use(router).use(GearsUI).mount('#app')
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Apps that use the plugin components also import `@ternarytech-io/gears-ui/plugins.css`, after `styles.css`.
|
|
51
|
+
|
|
52
|
+
The plugin registers every component globally (typed for templates). Components can also be imported
|
|
53
|
+
one by one: `import { TButton } from '@ternarytech-io/gears-ui'`. `vue` and `vue-router` are peer dependencies.
|
|
54
|
+
|
|
55
|
+
Components that need an optional library have entry points of their own, so an app installs only what
|
|
56
|
+
it uses:
|
|
57
|
+
|
|
58
|
+
| Entry | Components | Needs |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `@ternarytech-io/gears-ui` | Everything else | Nothing more |
|
|
61
|
+
| `@ternarytech-io/gears-ui/code-editor` | `TCodeEditor` (install with `GearsUICodeEditor`) | `monaco-editor` |
|
|
62
|
+
| `@ternarytech-io/gears-ui/plugins` | `TAdvancedSelect`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TRichEditor`, `TSortable`, `TSortableTree` (install with `GearsUIPlugins`) | Each one's library; and `@ternarytech-io/gears-ui/plugins.css` |
|
|
63
|
+
| `@ternarytech-io/gears-ui/components/T….vue` | Any one component on its own | Only that component's library |
|
|
64
|
+
|
|
65
|
+
`GearsUIPlugins` and `plugins.css` need all eight libraries. To use only some plugins, import those
|
|
66
|
+
components directly (`import TSortable from '@ternarytech-io/gears-ui/components/TSortable.vue'`; each loads only its
|
|
67
|
+
own library) and the CSS they need: Tom Select's `tom-select.bootstrap5.min.css`, and
|
|
68
|
+
`@tabler/core/dist/css/tabler-vendors.min.css` after it for the select, color picker, dropzone and slider.
|
|
69
|
+
|
|
70
|
+
From another repo, depend on a pinned commit: `"@ternarytech-io/gears-ui": "github:TernaryTech-io/Gears.UI#<commit>"`. The
|
|
71
|
+
package ships its sources, so the app's Vite compiles them; exclude it from pre-bundling with
|
|
72
|
+
`optimizeDeps: { exclude: ['@ternarytech-io/gears-ui'] }`.
|
|
73
|
+
|
|
74
|
+
The package ships its sources (`exports` points at `src/`), so it's consumed by a Vite app, as the Studio is.
|
|
75
|
+
|
|
76
|
+
## How it's built
|
|
77
|
+
|
|
78
|
+
- **Styles.** `src/styles/gears.css` imports Tabler's CSS and the Tabler Icons webfont (self-hosted: a
|
|
79
|
+
Gears server may have no internet), then sets the Gears palette through Tabler's CSS variables: primary
|
|
80
|
+
#3673d1, darkest black #1c1d1d, pages a shade off white, cards white (#232525 dark). Tabler 1.7 builds its
|
|
81
|
+
shades and dark mode from those variables with `light-dark()`, so there's no SCSS build.
|
|
82
|
+
- **Dark mode.** `data-bs-theme` on `<html>`, set by `useColorMode()` (light, dark or system; remembered).
|
|
83
|
+
The sidebar is dark in both themes.
|
|
84
|
+
- **Interactive components** (tooltip, dropdown, modal, slideover) drive Tabler's bundled Bootstrap JS
|
|
85
|
+
from Vue: created on mount, disposed on unmount, opened and closed through `v-model`.
|
|
86
|
+
- **Props follow Nuxt UI** (`color`, `variant`, `size`, `icon`, `trailingIcon`, `label`, `v-model:open`), so the
|
|
87
|
+
Studio's components move over mostly by renaming. Colors are `primary`, `neutral`, `success`, `warning`,
|
|
88
|
+
`error` and `info`; `toTabler()` maps them to Tabler's names (`neutral` → `secondary`, `error` → `danger`).
|
|
89
|
+
- **Icons** are Tabler Icons by name: `icon="plus"`. Browse them at <https://tabler.io/icons>.
|
|
90
|
+
- Tabler's own classes work alongside the components: the grid, spacing, `btn-list`, `row-cards`,
|
|
91
|
+
`list-group`, `datagrid`, `text-secondary`, …
|
|
92
|
+
|
|
93
|
+
## The preview site
|
|
94
|
+
|
|
95
|
+
`preview/` is a Vite app that uses the library the way an app does. Each component page lists the
|
|
96
|
+
examples in `preview/examples/{slug}/`, in file name order, live with their source under them; the file
|
|
97
|
+
name gives the title (`02-colors.vue` → "Colors") and a leading `<!-- comment -->` the description. To
|
|
98
|
+
add a page, add an entry to `preview/registry.ts` and a folder of examples.
|
|
99
|
+
|
|
100
|
+
## Components
|
|
101
|
+
|
|
102
|
+
| Group | Components |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| Elements | `TButton`, `TBadge`, `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` |
|
|
105
|
+
| Forms | `TFormField`, `TInput`, `TInputNumber`, `TTextarea`, `TSelect`, `TSelectMenu`, `TInputTags`, `TCheckbox`, `TSwitch`, `TRadioGroup` (list, cards or tiles with a picture), `TFieldGroup`, `TFileUpload`, `TImageUpload` (one image, checked for shape and size), `TIconPicker` (any Tabler icon, by name, with a search; the list is generated by `npm run icons`), `TRating` (stars, hearts or circles; no library), `TListBox` (always shown; one or several; a search), `TCheckboxTree` (parents check their children; partly checked; folding), `TCodeEditor` |
|
|
106
|
+
| Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TNavPositionPicker`, `TDensityPicker`, `TContainerPicker` (layout), `TThemeScope` (applies a `ThemeSettings`' look and density to what's inside it); `themeAccents`, `themeFonts`, `themeBases`, `themeRadii`, `themeNavs`, `themeDensities`, `themeContainers` |
|
|
107
|
+
| Overlays | `TModal`, `TSlideover`, `TDropdown`, `TToaster` (with `useToast()`) |
|
|
108
|
+
| Navigation | `TTabs`, `TPagination`, `TSteps`, `TNav`, `TPanelList`, `TCommandPalette`, `TSearchButton` |
|
|
109
|
+
| Data | `TTable` (sorting, `selectable` rows), `TAdvancedTable` (filters by column), `TEditableTable` (editing in place, bulk actions, search, pages, column kinds; client-side or `manual`), `TDataGrid` and `TDataGridItem` (Tabler's datagrid: labels and values for detail panels), `TStatCard` (with a trend and a sparkline), `TSparkline` (Tabler's, no library), `TLogView` |
|
|
110
|
+
| Layout | `TAppLayout` (an application's frame, laid out by its theme, with a menu button on small screens), `TScaledFrame` (a whole screen scaled to fit), `TShell`, `TTopbar`, `TPage`, `TSectionLayout`, `TSplitter`, `TAuthLayout`, `TColorModeButton` |
|
|
111
|
+
| Plugins | `TAdvancedSelect`, `TChart`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TSortableTree`, `TVectorMap`, `TRichEditor` |
|
|
112
|
+
|
|
113
|
+
### Plugins
|
|
114
|
+
|
|
115
|
+
The components for [Tabler's plugins](https://docs.tabler.io/ui/plugins). Each library is an optional peer
|
|
116
|
+
dependency and loads the first time its component is shown (`src/plugins.ts`), so an app installs and
|
|
117
|
+
downloads only what it uses. Their CSS is in `@ternarytech-io/gears-ui/plugins.css`: each library's own styles, then
|
|
118
|
+
Tabler's restyling of them (`tabler-vendors.css`), which must come after.
|
|
119
|
+
|
|
120
|
+
| Component | Library | Notes |
|
|
121
|
+
| --- | --- | --- |
|
|
122
|
+
| `TAdvancedSelect` | Tom Select | One or several (`multiple`, as chips); `create` adds new values; icons and avatars beside labels. Overlaps `TSelectMenu`, which has no dependency. |
|
|
123
|
+
| `TChart` | Apache ECharts (Apache-2.0) | `line`, `area`, `bar` (across), `column`, `pie`, `donut`; `series` along `categories`, `stacked`, `format`, `point-click`. Colors follow the theme (and a `TThemeScope`), light or dark; `options` (ECharts options) is merged over everything for anything else. SVG by default, `renderer="canvas"` for very many points; it follows its box's size. Only the charts it uses are bundled. Before 0.4.0 it was ApexCharts, whose license no longer suits apps others use. |
|
|
124
|
+
| `TCopyButton` | Tabler's clipboard | Copies `text`, or the field `target` selects. Needs https or localhost. |
|
|
125
|
+
| `TColorPicker` | Coloris | `format`, `alpha`, `swatches`, `swatchesOnly`. The field isn't wrapped by Coloris (Vue owns it); the swatch is ours. |
|
|
126
|
+
| `TDatePicker` | Tabler's date picker, on Vanilla Calendar Pro | `single`, `multiple` or `range`; `inline`; the model is `YYYY-MM-DD`, `format` only changes the display. |
|
|
127
|
+
| `TDropzone` | Dropzone | With `url`, uploads; without, v-model collects the files. |
|
|
128
|
+
| `TInputMask` | Tabler's input mask, on IMask | `mask` like "(000) 000-0000"; `unmasked`; `showMask`. |
|
|
129
|
+
| `TRangeSlider` | noUiSlider | A number, or a range with `[from, to]`. |
|
|
130
|
+
| `TSortable` | Tabler's sortable, on SortableJS | Reorders v-model's array. Lists within one container; dragging between lists isn't wired up yet. |
|
|
131
|
+
| `TVectorMap` | Tabler's vector map | The world map: `values`, `markers`, `lines`, `legend`, `select` with v-model:selected, `zoom`. |
|
|
132
|
+
| `TRichEditor` | HugeRTE (open-source TinyMCE fork) | v-model is HTML. Bundled skins and plugins, nothing fetched; follows the theme by rebuilding the editor. |
|
|
133
|
+
|
|
134
|
+
### From the Studio's components
|
|
135
|
+
|
|
136
|
+
| Studio (Nuxt UI) | Gears UI |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| `UButton`, `UBadge`, `UAvatar`, `UAlert`, `UCard`, `UIcon`, `UTooltip`, `UEmpty`, `USkeleton`, `USeparator`, `UProgress` | `T…` with the same name. Icons change from `i-lucide-*` to Tabler names. `UCard`'s header slot content moves to `title`/`subtitle`/`#actions`. |
|
|
139
|
+
| `UFormField`, `UInput`, `UTextarea`, `USelect`, `UCheckbox`, `USwitch`, `URadioGroup`, `UFieldGroup` | `TFormField` (`help` → `description`), `TInput`, `TTextarea`, `TSelect`, `TCheckbox`, `TSwitch`, `TRadioGroup`, `TFieldGroup` |
|
|
140
|
+
| `UModal`, `USlideover`, `UDropdownMenu` | `TModal`, `TSlideover`, `TDropdown` (same item groups; `onSelect`, `to`, `type: 'label'`) |
|
|
141
|
+
| `UTabs`, `UPagination`, `UStepper`, `UTable` | `TTabs` (`:content="false"` switches become `variant="segmented"`), `TPagination`, `TSteps`, `TTable` (cell slots get the row itself, not `row.original`; `#cell` draws any cell, `sticky` keeps the header) |
|
|
142
|
+
| `UInputNumber`, `UFileUpload` | `TInputNumber` (Tabler's number input: minus and plus, `min`, `max`, `step`), `TFileUpload` (`accept`, `multiple`; v-model holds the File, nothing uploads) |
|
|
143
|
+
| `UDashboardSearch`, `UDashboardSearchButton` | `TCommandPalette` (`groups` of items with `to` or `onSelect`; Ctrl+K / ⌘K) and `TSearchButton` (`collapsed` for the icon only). They share their open state; `useCommandPalette()` opens it from code |
|
|
144
|
+
| `USelectMenu`, `UInputTags`, `USplitter` | `TSelectMenu` (`multiple`; items take a `group` instead of `type: 'label'` rows; `v-model:search-term` with `ignore-filter` becomes `v-model:search` with `:filter="false"`), `TInputTags`, `TSplitter` (`#start` and `#end` slots, `storageKey`) |
|
|
145
|
+
| `UDashboardGroup` + `UDashboardSidebar` + `UNavigationMenu` | `TShell` with `nav` items (`TNav`) |
|
|
146
|
+
| `UDashboardPanel` + `UDashboardNavbar` | `TTopbar` + `TPage` |
|
|
147
|
+
| `UColorModeButton` | `TColorModeButton` |
|
|
148
|
+
| `useToast()` (with `UApp`) | `useToast()` from `@ternarytech-io/gears-ui`, the same `add({ title, description, color, icon })`, and a `TToaster` in the frame |
|
|
149
|
+
| `StatCard`, `AuthCard`, `SectionLayout` | `TStatCard`, `TAuthLayout` (brand and logo are props), `TSectionLayout` |
|
|
150
|
+
| `BuildLog`, `AppLog` | Their polling stays in the Studio; the display is `TLogView` (`text`, or `lines` with times and levels, and `v-model:follow`) |
|
|
151
|
+
| `CodeEditor` | `TCodeEditor` (same props; `Completion` is `CodeCompletion`; `flush` replaces the border overrides). Monaco's setup moves to `src/monaco.ts`, with themes `gears-light` and `gears-dark` |
|
|
152
|
+
| `CodePanel`, `QueryPanel`, `FilterGroupEditor` | Stay in the Studio (they call its API). Rebuilt on Gears UI in the preview's Studio pages, against mock data in `preview/studio/`: the side-panel lists are `TPanelList`, and the results card is a component of its own instead of VueUse's reusable template |
|
|
153
|
+
| `StudioPage`, `ProjectSwitcher`, user menu | Compositions of `TTopbar`, `TDropdown`, `TAvatar` and `TPage`: see the Top bar and Dropdown pages |
|
|
154
|
+
|
|
155
|
+
### Still to do
|
|
156
|
+
|
|
157
|
+
Every Nuxt UI component the Studio uses now has a Gears UI version. The preview site has no generated
|
|
158
|
+
props tables yet; the examples are the reference.
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
[Mozilla Public License 2.0](LICENSE), as Ternary.Data.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ternarytech-io/gears-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Gears UI: Vue 3 components on Tabler, used by the Gears Studio and the applications it builds.",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"preview": "vite preview"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"monaco-editor": "^0.57.0",
|
|
50
|
-
"vue": "^3.5.0",
|
|
51
|
-
"vue-router": "^4.6.0",
|
|
52
|
-
"tom-select": "^2.6.0",
|
|
53
49
|
"@melloware/coloris": "^0.25.0",
|
|
54
|
-
"vanilla-calendar-pro": "^3.3.2",
|
|
55
50
|
"dropzone": "^6.3.0",
|
|
51
|
+
"echarts": "^6.1.0",
|
|
52
|
+
"hugerte": "^1.0.0",
|
|
56
53
|
"imask": "^7.6.0",
|
|
54
|
+
"monaco-editor": "^0.57.0",
|
|
57
55
|
"nouislider": "^15.8.0",
|
|
58
56
|
"sortablejs": "^1.15.0",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
57
|
+
"tom-select": "^2.6.0",
|
|
58
|
+
"vanilla-calendar-pro": "^3.3.2",
|
|
59
|
+
"vue": "^3.5.0",
|
|
60
|
+
"vue-router": "^4.6.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@tabler/core": "1.7.1",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"@melloware/coloris": "0.25.0",
|
|
68
68
|
"@types/sortablejs": "1.15.9",
|
|
69
69
|
"@vitejs/plugin-vue": "6.0.10",
|
|
70
|
-
"apexcharts": "7.0.0",
|
|
71
70
|
"dropzone": "6.3.5",
|
|
71
|
+
"echarts": "6.1.0",
|
|
72
72
|
"hugerte": "1.0.14",
|
|
73
73
|
"imask": "7.6.1",
|
|
74
74
|
"monaco-editor": "0.57.0",
|
|
@@ -98,6 +98,9 @@
|
|
|
98
98
|
"dropzone": {
|
|
99
99
|
"optional": true
|
|
100
100
|
},
|
|
101
|
+
"echarts": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
101
104
|
"imask": {
|
|
102
105
|
"optional": true
|
|
103
106
|
},
|
|
@@ -1,188 +1,225 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// A chart,
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// merged over everything for whatever else
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
probe.
|
|
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
|
-
const
|
|
88
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
if (!
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A chart, drawn by Apache ECharts: a line, area, bar (across), column (up), pie or donut.
|
|
3
|
+
// `series` are named lists of numbers along `categories` (a pie or donut uses the first series,
|
|
4
|
+
// one slice per category). Colors come from the theme (the accent first), or `colors` (named
|
|
5
|
+
// colors such as 'success', or any CSS color); they follow light and dark mode and a TThemeScope
|
|
6
|
+
// around the chart. `format` writes values on the axis and in tooltips; `options` (ECharts
|
|
7
|
+
// options) is merged over everything for whatever else ECharts does, arrays (such as `series`)
|
|
8
|
+
// replaced. ECharts loads on first use; the chart is SVG unless `renderer` is 'canvas' (better
|
|
9
|
+
// for many thousands of points), and follows its box's size.
|
|
10
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
11
|
+
import type { EChartsOption } from 'echarts'
|
|
12
|
+
import type { EChartsType } from 'echarts/core'
|
|
13
|
+
import { loadECharts } from '../plugins/charts'
|
|
14
|
+
import type { ChartSeries, ChartType, Color } from '../types'
|
|
15
|
+
import { toTabler } from '../types'
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<{
|
|
18
|
+
type?: ChartType
|
|
19
|
+
series: ChartSeries[]
|
|
20
|
+
categories?: (string | number)[]
|
|
21
|
+
height?: number | string
|
|
22
|
+
stacked?: boolean
|
|
23
|
+
// Shown by default with more than one series, and for pies and donuts.
|
|
24
|
+
legend?: boolean
|
|
25
|
+
colors?: (Color | string)[]
|
|
26
|
+
format?: (value: number) => string
|
|
27
|
+
// No axes, grid or legend: a small chart inside a card or a stat.
|
|
28
|
+
sparkline?: boolean
|
|
29
|
+
label?: string
|
|
30
|
+
options?: EChartsOption
|
|
31
|
+
renderer?: 'svg' | 'canvas'
|
|
32
|
+
// Vue makes a missing boolean false; undefined keeps the legend's default.
|
|
33
|
+
}>(), { type: 'line', categories: () => [], height: 240, label: 'Chart', legend: undefined, renderer: 'svg' })
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits<{ 'point-click': [point: { series: number; index: number; category: string | number | undefined }] }>()
|
|
36
|
+
|
|
37
|
+
const el = ref<HTMLElement>()
|
|
38
|
+
let chart: EChartsType | null = null
|
|
39
|
+
|
|
40
|
+
// Tabler's chart colors after the accent: its named colors, in an order that keeps neighbors apart.
|
|
41
|
+
const palette = ['primary', 'green', 'orange', 'purple', 'cyan', 'pink', 'yellow', 'red', 'teal', 'indigo']
|
|
42
|
+
const named = new Set(['primary', 'neutral', 'success', 'warning', 'error', 'info'])
|
|
43
|
+
|
|
44
|
+
const round = computed(() => props.type === 'pie' || props.type === 'donut')
|
|
45
|
+
const bars = computed(() => props.type === 'bar' || props.type === 'column')
|
|
46
|
+
const cssHeight = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height))
|
|
47
|
+
|
|
48
|
+
/** A CSS color as the browser resolves it here, inside any theme scope: `var(--tblr-primary)` → rgb(…). */
|
|
49
|
+
function resolve(color: string): string {
|
|
50
|
+
if (!el.value) return color
|
|
51
|
+
const probe = document.createElement('span')
|
|
52
|
+
probe.style.display = 'none'
|
|
53
|
+
probe.style.color = color
|
|
54
|
+
el.value.appendChild(probe)
|
|
55
|
+
const value = getComputedStyle(probe).color
|
|
56
|
+
probe.remove()
|
|
57
|
+
return value ? rgb(value) : color
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ECharts reads hex, rgb() and hsl() colors (to lighten one on hover), and Tabler's theme colors
|
|
61
|
+
// can come back as oklch(…); painting one pixel gives any color as rgb().
|
|
62
|
+
let pixel: CanvasRenderingContext2D | null = null
|
|
63
|
+
function rgb(color: string): string {
|
|
64
|
+
if (/^(rgb|#)/i.test(color)) return color
|
|
65
|
+
pixel ??= document.createElement('canvas').getContext('2d', { willReadFrequently: true })
|
|
66
|
+
if (!pixel) return color
|
|
67
|
+
pixel.clearRect(0, 0, 1, 1)
|
|
68
|
+
pixel.fillStyle = color
|
|
69
|
+
pixel.fillRect(0, 0, 1, 1)
|
|
70
|
+
const [r, g, b, a] = pixel.getImageData(0, 0, 1, 1).data
|
|
71
|
+
return a === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 100) / 100})`
|
|
72
|
+
}
|
|
73
|
+
const cssColor = (color: string) => named.has(color) ? `var(--tblr-${toTabler(color as Color)})`
|
|
74
|
+
: /^[a-z]+$/.test(color) && palette.includes(color) ? `var(--tblr-${color})` : color
|
|
75
|
+
|
|
76
|
+
function option(): EChartsOption {
|
|
77
|
+
const count = round.value ? props.categories.length : props.series.length
|
|
78
|
+
const colors = Array.from({ length: Math.max(count, 1) }, (_, i) =>
|
|
79
|
+
resolve(cssColor((round.value ? undefined : props.series[i]?.color) ?? props.colors?.[i] ?? palette[i % palette.length]!)))
|
|
80
|
+
const text = resolve('var(--tblr-secondary)')
|
|
81
|
+
const body = resolve('var(--tblr-body-color)')
|
|
82
|
+
const border = resolve('var(--tblr-border-color)')
|
|
83
|
+
const surface = resolve('var(--tblr-bg-surface)')
|
|
84
|
+
const font = el.value ? getComputedStyle(el.value).fontFamily : 'inherit'
|
|
85
|
+
const format = props.format
|
|
86
|
+
const formatter = format ? (value: unknown) => (value == null || value === '' ? '' : format(Number(value))) : undefined
|
|
87
|
+
const spark = props.sparkline ?? false
|
|
88
|
+
const legend = !spark && (props.legend ?? (round.value || props.series.length > 1))
|
|
89
|
+
|
|
90
|
+
const valueAxis = {
|
|
91
|
+
type: 'value' as const,
|
|
92
|
+
show: !spark,
|
|
93
|
+
axisLabel: { color: text, formatter: formatter as never, hideOverlap: true },
|
|
94
|
+
splitLine: { lineStyle: { color: border, type: 'dashed' as const } },
|
|
95
|
+
axisLine: { show: false },
|
|
96
|
+
axisTick: { show: false }
|
|
97
|
+
}
|
|
98
|
+
const categoryAxis = {
|
|
99
|
+
type: 'category' as const,
|
|
100
|
+
show: !spark,
|
|
101
|
+
data: props.categories.map(String),
|
|
102
|
+
boundaryGap: bars.value,
|
|
103
|
+
// Bars across list their first category on top, as a table would.
|
|
104
|
+
inverse: props.type === 'bar',
|
|
105
|
+
axisLabel: { color: text, hideOverlap: true },
|
|
106
|
+
axisLine: { lineStyle: { color: border } },
|
|
107
|
+
axisTick: { show: false }
|
|
108
|
+
}
|
|
109
|
+
const series = round.value
|
|
110
|
+
? [{
|
|
111
|
+
type: 'pie' as const,
|
|
112
|
+
name: props.series[0]?.name,
|
|
113
|
+
radius: props.type === 'donut' ? ['55%', '78%'] : [0, '78%'],
|
|
114
|
+
center: ['50%', legend ? '44%' : '50%'],
|
|
115
|
+
data: props.categories.map((c, i) => ({ name: String(c), value: props.series[0]?.data[i] ?? 0 })),
|
|
116
|
+
label: { show: false },
|
|
117
|
+
itemStyle: { borderColor: surface, borderWidth: 2 },
|
|
118
|
+
emphasis: { scaleSize: 4 }
|
|
119
|
+
}]
|
|
120
|
+
: props.series.map(s => bars.value
|
|
121
|
+
? {
|
|
122
|
+
type: 'bar' as const, name: s.name, data: s.data, stack: props.stacked ? 'total' : undefined,
|
|
123
|
+
barMaxWidth: 32, itemStyle: { borderRadius: props.type === 'bar' ? [0, 2, 2, 0] : [2, 2, 0, 0] }
|
|
124
|
+
}
|
|
125
|
+
: {
|
|
126
|
+
type: 'line' as const, name: s.name, data: s.data, stack: props.stacked ? 'total' : undefined,
|
|
127
|
+
// Smooth, without overshooting a point (a curve never dips below a value it doesn't reach).
|
|
128
|
+
smooth: 0.35, smoothMonotone: 'x' as const, showSymbol: false, symbolSize: 6, lineStyle: { width: 2 }, connectNulls: false,
|
|
129
|
+
areaStyle: props.type === 'area' ? { opacity: 0.16 } : undefined
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const base: EChartsOption = {
|
|
133
|
+
color: colors,
|
|
134
|
+
backgroundColor: 'transparent',
|
|
135
|
+
animation: false,
|
|
136
|
+
textStyle: { fontFamily: font, color: text },
|
|
137
|
+
grid: spark
|
|
138
|
+
? { left: 0, right: 0, top: 2, bottom: 2 }
|
|
139
|
+
: { left: 4, right: 12, top: 12, bottom: legend ? 36 : 4, containLabel: true },
|
|
140
|
+
tooltip: {
|
|
141
|
+
trigger: round.value ? 'item' : 'axis',
|
|
142
|
+
confine: true,
|
|
143
|
+
valueFormatter: formatter as never,
|
|
144
|
+
backgroundColor: surface,
|
|
145
|
+
borderColor: border,
|
|
146
|
+
textStyle: { color: body, fontFamily: font, fontSize: 12 },
|
|
147
|
+
extraCssText: 'box-shadow: var(--tblr-box-shadow-dropdown); border-radius: var(--tblr-border-radius);',
|
|
148
|
+
axisPointer: bars.value
|
|
149
|
+
? { type: 'shadow', shadowStyle: { color: border, opacity: 0.35 } }
|
|
150
|
+
: { type: 'line', lineStyle: { color: border } }
|
|
151
|
+
},
|
|
152
|
+
legend: {
|
|
153
|
+
show: legend, bottom: 0, icon: 'circle', itemWidth: 8, itemHeight: 8, itemGap: 16,
|
|
154
|
+
textStyle: { color: text, fontFamily: font }
|
|
155
|
+
},
|
|
156
|
+
xAxis: round.value ? undefined : props.type === 'bar' ? valueAxis : categoryAxis,
|
|
157
|
+
yAxis: round.value ? undefined : props.type === 'bar' ? categoryAxis : valueAxis,
|
|
158
|
+
series
|
|
159
|
+
}
|
|
160
|
+
return defined(merge(base, props.options ?? {}))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Without keys set to undefined (ECharts takes some of them as values, over its defaults). */
|
|
164
|
+
function defined<T>(value: T): T {
|
|
165
|
+
if (Array.isArray(value)) return value.map(defined) as T
|
|
166
|
+
if (!isObject(value)) return value
|
|
167
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined).map(([k, v]) => [k, defined(v)])) as T
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Objects merged deeply; arrays and values replaced. */
|
|
171
|
+
function merge<T>(target: T, source: unknown): T {
|
|
172
|
+
if (!isObject(target) || !isObject(source)) return (source === undefined ? target : source) as T
|
|
173
|
+
const result: Record<string, unknown> = { ...target }
|
|
174
|
+
for (const [key, value] of Object.entries(source)) {
|
|
175
|
+
if (value === undefined) continue
|
|
176
|
+
result[key] = isObject(value) && isObject(result[key]) ? merge(result[key], value) : value
|
|
177
|
+
}
|
|
178
|
+
return result as T
|
|
179
|
+
}
|
|
180
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
181
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) && typeof value !== 'function'
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const redraw = () => chart?.setOption(option(), { notMerge: true })
|
|
185
|
+
|
|
186
|
+
// The theme can change around the chart: light and dark, or a theme scope's accent and grays.
|
|
187
|
+
let observer: MutationObserver | null = null
|
|
188
|
+
function watchTheme() {
|
|
189
|
+
observer = new MutationObserver(redraw)
|
|
190
|
+
const themedAncestors = new Set<Element>([document.documentElement])
|
|
191
|
+
for (let node = el.value?.parentElement; node; node = node.parentElement)
|
|
192
|
+
if ([...node.attributes].some(a => a.name.startsWith('data-bs-theme') || a.name === 'data-t-density')) themedAncestors.add(node)
|
|
193
|
+
for (const node of themedAncestors) observer.observe(node, { attributes: true, attributeFilter: ['data-bs-theme', 'data-bs-theme-primary', 'data-bs-theme-base', 'style', 'class'] })
|
|
194
|
+
}
|
|
195
|
+
// It follows its box's size.
|
|
196
|
+
let sized: ResizeObserver | null = null
|
|
197
|
+
|
|
198
|
+
let unmounted = false
|
|
199
|
+
onMounted(async () => {
|
|
200
|
+
const echarts = await loadECharts()
|
|
201
|
+
if (!el.value || unmounted) return
|
|
202
|
+
chart = echarts.init(el.value, null, { renderer: props.renderer })
|
|
203
|
+
chart.on('click', params => {
|
|
204
|
+
const index = params.dataIndex ?? 0
|
|
205
|
+
emit('point-click', { series: params.seriesIndex ?? 0, index, category: props.categories[index] })
|
|
206
|
+
})
|
|
207
|
+
redraw()
|
|
208
|
+
watchTheme()
|
|
209
|
+
sized = new ResizeObserver(() => chart?.resize())
|
|
210
|
+
sized.observe(el.value)
|
|
211
|
+
})
|
|
212
|
+
watch(() => [props.type, props.series, props.categories, props.stacked, props.legend, props.colors, props.options, props.sparkline, props.format],
|
|
213
|
+
redraw, { deep: true })
|
|
214
|
+
onBeforeUnmount(() => {
|
|
215
|
+
unmounted = true
|
|
216
|
+
observer?.disconnect()
|
|
217
|
+
sized?.disconnect()
|
|
218
|
+
chart?.dispose()
|
|
219
|
+
chart = null
|
|
220
|
+
})
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<template>
|
|
224
|
+
<div ref="el" class="t-chart" role="img" :aria-label="label" :style="{ height: cssHeight }" />
|
|
225
|
+
</template>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
// Checkboxes in a tree: a parent is checked when all its children are, partly checked (dash) when
|
|
3
|
+
// some are, and checking it checks them all. Parents fold and open with their arrow (`collapsible`,
|
|
4
|
+
// all open at first unless `collapsed`). v-model is the checked leaves' values.
|
|
5
|
+
import { computed, shallowRef } from 'vue'
|
|
6
|
+
import TIcon from './TIcon.vue'
|
|
7
|
+
import type { TreeItem } from '../types'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
items: TreeItem<T>[]
|
|
11
|
+
collapsible?: boolean
|
|
12
|
+
collapsed?: boolean
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
// The tree's accessible name.
|
|
15
|
+
label?: string
|
|
16
|
+
}>(), { collapsible: true, collapsed: false })
|
|
17
|
+
|
|
18
|
+
const model = defineModel<T[]>({ default: () => [] })
|
|
19
|
+
// The parents folded, by value.
|
|
20
|
+
const folded = shallowRef(new Set<T>())
|
|
21
|
+
if (props.collapsed) {
|
|
22
|
+
const walk = (items: TreeItem<T>[]) => items.forEach(i => { if (i.children?.length) { folded.value.add(i.value); walk(i.children) } })
|
|
23
|
+
walk(props.items)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const checked = computed(() => new Set(model.value))
|
|
27
|
+
const leaves = (item: TreeItem<T>): T[] => (item.children?.length ? item.children.flatMap(leaves) : [item.value])
|
|
28
|
+
function state(item: TreeItem<T>): 'on' | 'off' | 'some' {
|
|
29
|
+
const all = leaves(item)
|
|
30
|
+
const on = all.filter(v => checked.value.has(v)).length
|
|
31
|
+
return on === 0 ? 'off' : on === all.length ? 'on' : 'some'
|
|
32
|
+
}
|
|
33
|
+
function toggle(item: TreeItem<T>) {
|
|
34
|
+
if (props.disabled || item.disabled) return
|
|
35
|
+
const all = leaves(item)
|
|
36
|
+
const next = new Set(model.value)
|
|
37
|
+
if (state(item) === 'on') all.forEach(v => next.delete(v))
|
|
38
|
+
else all.forEach(v => next.add(v))
|
|
39
|
+
model.value = [...next]
|
|
40
|
+
}
|
|
41
|
+
function fold(item: TreeItem<T>) {
|
|
42
|
+
const next = new Set(folded.value)
|
|
43
|
+
if (next.has(item.value)) next.delete(item.value)
|
|
44
|
+
else next.add(item.value)
|
|
45
|
+
folded.value = next
|
|
46
|
+
}
|
|
47
|
+
// Rows to show, with their depth: what's under a folded parent is left out.
|
|
48
|
+
const rows = computed(() => {
|
|
49
|
+
const out: { item: TreeItem<T>; depth: number }[] = []
|
|
50
|
+
const walk = (items: TreeItem<T>[], depth: number) => items.forEach(item => {
|
|
51
|
+
out.push({ item, depth })
|
|
52
|
+
if (item.children?.length && !(props.collapsible && folded.value.has(item.value))) walk(item.children, depth + 1)
|
|
53
|
+
})
|
|
54
|
+
walk(props.items, 0)
|
|
55
|
+
return out
|
|
56
|
+
})
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<div class="t-checkbox-tree" role="group" :aria-label="label">
|
|
61
|
+
<div v-for="{ item, depth } in rows" :key="String(item.value)" class="t-checkbox-tree-row" :style="{ paddingInlineStart: `${depth * 1.25}rem` }">
|
|
62
|
+
<button v-if="collapsible && item.children?.length" type="button" class="t-checkbox-tree-fold" :aria-expanded="!folded.has(item.value)"
|
|
63
|
+
:aria-label="`${folded.has(item.value) ? 'Open' : 'Fold'} ${item.label}`" @click="fold(item)">
|
|
64
|
+
<TIcon :name="folded.has(item.value) ? 'chevron-right' : 'chevron-down'" />
|
|
65
|
+
</button>
|
|
66
|
+
<span v-else-if="collapsible" class="t-checkbox-tree-fold" aria-hidden="true" />
|
|
67
|
+
<label class="form-check mb-0">
|
|
68
|
+
<input type="checkbox" class="form-check-input" :checked="state(item) === 'on'" :indeterminate.prop="state(item) === 'some'"
|
|
69
|
+
:aria-checked="state(item) === 'some' ? 'mixed' : state(item) === 'on'" :disabled="disabled || item.disabled" @change="toggle(item)">
|
|
70
|
+
<span class="form-check-label">{{ item.label }}</span>
|
|
71
|
+
</label>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.t-checkbox-tree { display: flex; flex-direction: column; gap: 0.25rem; }
|
|
78
|
+
.t-checkbox-tree-row { display: flex; align-items: center; gap: 0.25rem; }
|
|
79
|
+
.t-checkbox-tree-row .form-check { min-height: 0; }
|
|
80
|
+
.t-checkbox-tree-fold { display: grid; place-items: center; flex-shrink: 0; width: 1.25rem; height: 1.25rem; padding: 0; border: 0; background: none; color: var(--tblr-secondary); }
|
|
81
|
+
button.t-checkbox-tree-fold:hover { color: var(--tblr-body-color); }
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T">
|
|
2
|
+
// A list of choices that's always shown (not a dropdown), to choose one or, with `multiple`,
|
|
3
|
+
// several; `searchable` adds a search above it. It's a listbox for assistive technology: the arrow
|
|
4
|
+
// keys, Home and End move through it, Space or Enter chooses. v-model is the chosen value (null for
|
|
5
|
+
// none), or with `multiple` the chosen values.
|
|
6
|
+
import { computed, ref, useId } from 'vue'
|
|
7
|
+
import TIcon from './TIcon.vue'
|
|
8
|
+
import { useField } from '../composables/useField'
|
|
9
|
+
import type { SelectItem } from '../types'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
items: (T | SelectItem<T>)[]
|
|
13
|
+
multiple?: boolean
|
|
14
|
+
searchable?: boolean
|
|
15
|
+
searchPlaceholder?: string
|
|
16
|
+
// The list's tallest (CSS); it scrolls past that. `none` lets it fill the box it's in (give the
|
|
17
|
+
// TListBox a height, or put it in a flex column).
|
|
18
|
+
height?: string
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
invalid?: boolean
|
|
21
|
+
// The list's accessible name, when no label points at it.
|
|
22
|
+
label?: string
|
|
23
|
+
id?: string
|
|
24
|
+
}>(), { searchPlaceholder: 'Search…', height: '12rem' })
|
|
25
|
+
|
|
26
|
+
const model = defineModel<T | T[] | null | undefined>()
|
|
27
|
+
const field = useField(props)
|
|
28
|
+
const listId = useId()
|
|
29
|
+
const query = ref('')
|
|
30
|
+
const active = ref(0)
|
|
31
|
+
const list = ref<HTMLElement>()
|
|
32
|
+
|
|
33
|
+
const options = computed(() => props.items.map(item => (item !== null && typeof item === 'object' && 'value' in (item as object) && 'label' in (item as object)
|
|
34
|
+
? item as SelectItem<T>
|
|
35
|
+
: { label: String(item), value: item as T })))
|
|
36
|
+
const shown = computed(() => {
|
|
37
|
+
const term = query.value.trim().toLowerCase()
|
|
38
|
+
return term ? options.value.filter(o => o.label.toLowerCase().includes(term) || (o.description ?? '').toLowerCase().includes(term)) : options.value
|
|
39
|
+
})
|
|
40
|
+
const chosen = (value: T) => props.multiple ? Array.isArray(model.value) && model.value.includes(value) : model.value === value
|
|
41
|
+
|
|
42
|
+
function choose(option: SelectItem<T>) {
|
|
43
|
+
if (props.disabled || option.disabled) return
|
|
44
|
+
if (!props.multiple) {
|
|
45
|
+
model.value = option.value
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
const current = Array.isArray(model.value) ? model.value : []
|
|
49
|
+
model.value = current.includes(option.value) ? current.filter(v => v !== option.value) : [...current, option.value]
|
|
50
|
+
}
|
|
51
|
+
function key(event: KeyboardEvent) {
|
|
52
|
+
const last = shown.value.length - 1
|
|
53
|
+
if (last < 0) return
|
|
54
|
+
const moves: Record<string, number> = { ArrowDown: active.value + 1, ArrowUp: active.value - 1, Home: 0, End: last }
|
|
55
|
+
if (event.key in moves) {
|
|
56
|
+
event.preventDefault()
|
|
57
|
+
active.value = Math.max(0, Math.min(last, moves[event.key]!))
|
|
58
|
+
list.value?.querySelector<HTMLElement>(`[data-index="${active.value}"]`)?.scrollIntoView({ block: 'nearest' })
|
|
59
|
+
} else if (event.key === ' ' || event.key === 'Enter') {
|
|
60
|
+
event.preventDefault()
|
|
61
|
+
choose(shown.value[active.value]!)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<div :class="['t-list-box', { 'is-invalid': invalid || field.invalid.value, disabled }]">
|
|
68
|
+
<div v-if="searchable" class="t-list-box-search">
|
|
69
|
+
<input v-model="query" type="search" class="form-control form-control-sm" :placeholder="searchPlaceholder" :aria-label="searchPlaceholder"
|
|
70
|
+
:aria-controls="listId" :disabled="disabled" @input="active = 0">
|
|
71
|
+
</div>
|
|
72
|
+
<div :id="field.id.value === listId ? listId : field.id.value" ref="list" class="t-list-box-list" role="listbox" :tabindex="disabled ? -1 : 0"
|
|
73
|
+
:aria-multiselectable="multiple || undefined" :aria-disabled="disabled || undefined" :aria-label="label"
|
|
74
|
+
:aria-activedescendant="shown.length ? `${listId}-${active}` : undefined" :aria-describedby="field.describedBy.value" :style="{ maxHeight: height }"
|
|
75
|
+
@keydown="key">
|
|
76
|
+
<div v-for="(option, index) in shown" :id="`${listId}-${index}`" :key="index" :data-index="index" role="option"
|
|
77
|
+
:aria-selected="chosen(option.value)" :aria-disabled="option.disabled || undefined"
|
|
78
|
+
:class="['t-list-box-item', { selected: chosen(option.value), active: index === active, disabled: option.disabled }]"
|
|
79
|
+
@click="active = index; choose(option)">
|
|
80
|
+
<span v-if="multiple" class="t-list-box-check" aria-hidden="true"><TIcon v-if="chosen(option.value)" name="check" /></span>
|
|
81
|
+
<span class="min-w-0">
|
|
82
|
+
<span class="d-block text-truncate">{{ option.label }}</span>
|
|
83
|
+
<span v-if="option.description" class="d-block small text-secondary text-truncate">{{ option.description }}</span>
|
|
84
|
+
</span>
|
|
85
|
+
<TIcon v-if="!multiple && chosen(option.value)" name="check" class="ms-auto text-primary" />
|
|
86
|
+
</div>
|
|
87
|
+
<p v-if="!shown.length" class="t-list-box-empty">{{ query ? 'Nothing matches.' : 'Nothing to choose.' }}</p>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
|
|
92
|
+
<style scoped>
|
|
93
|
+
.t-list-box { display: flex; flex-direction: column; min-height: 0; border: var(--tblr-border-width) solid var(--tblr-border-color); border-radius: var(--tblr-border-radius); background: var(--tblr-bg-forms, var(--tblr-bg-surface)); overflow: hidden; }
|
|
94
|
+
.t-list-box.is-invalid { border-color: var(--tblr-danger); }
|
|
95
|
+
.t-list-box.disabled { opacity: 0.65; }
|
|
96
|
+
.t-list-box-search { padding: 0.375rem; border-bottom: var(--tblr-border-width) solid var(--tblr-border-color); }
|
|
97
|
+
.t-list-box-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0.25rem; outline: none; }
|
|
98
|
+
.t-list-box-list:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--tblr-primary) 40%, transparent); }
|
|
99
|
+
.t-list-box-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.5rem; border-radius: var(--tblr-border-radius-sm); cursor: pointer; user-select: none; }
|
|
100
|
+
.t-list-box-item:hover { background: var(--tblr-bg-surface-secondary); }
|
|
101
|
+
.t-list-box-list:focus-visible .t-list-box-item.active { background: var(--tblr-bg-surface-secondary); outline: 1px solid var(--tblr-border-color); }
|
|
102
|
+
.t-list-box-item.selected { background: color-mix(in srgb, var(--tblr-primary) 12%, transparent); }
|
|
103
|
+
.t-list-box-item.disabled { opacity: 0.5; cursor: default; }
|
|
104
|
+
.t-list-box-check {
|
|
105
|
+
display: grid; place-items: center; flex-shrink: 0; width: 1rem; height: 1rem; font-size: 0.75rem;
|
|
106
|
+
border: var(--tblr-border-width) solid var(--tblr-border-color-dark, var(--tblr-border-color)); border-radius: var(--tblr-border-radius-sm);
|
|
107
|
+
}
|
|
108
|
+
.t-list-box-check :deep(.icon) { width: auto; height: auto; font-size: 0.75rem; line-height: 1; vertical-align: 0; }
|
|
109
|
+
.selected > .t-list-box-check { background: var(--tblr-primary); border-color: var(--tblr-primary); color: var(--tblr-primary-fg, #fff); }
|
|
110
|
+
.t-list-box-empty { margin: 0.5rem; color: var(--tblr-secondary); font-size: 0.8125rem; }
|
|
111
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import TBadge from './components/TBadge.vue'
|
|
|
14
14
|
import TButton from './components/TButton.vue'
|
|
15
15
|
import TCard from './components/TCard.vue'
|
|
16
16
|
import TCheckbox from './components/TCheckbox.vue'
|
|
17
|
+
import TCheckboxTree from './components/TCheckboxTree.vue'
|
|
17
18
|
import TColorModeButton from './components/TColorModeButton.vue'
|
|
18
19
|
import TCommandPalette from './components/TCommandPalette.vue'
|
|
19
20
|
import TContainerPicker from './components/TContainerPicker.vue'
|
|
@@ -34,6 +35,7 @@ import TImageUpload from './components/TImageUpload.vue'
|
|
|
34
35
|
import TInput from './components/TInput.vue'
|
|
35
36
|
import TInputNumber from './components/TInputNumber.vue'
|
|
36
37
|
import TInputTags from './components/TInputTags.vue'
|
|
38
|
+
import TListBox from './components/TListBox.vue'
|
|
37
39
|
import TLogView from './components/TLogView.vue'
|
|
38
40
|
import TModal from './components/TModal.vue'
|
|
39
41
|
import TNav from './components/TNav.vue'
|
|
@@ -81,6 +83,7 @@ export {
|
|
|
81
83
|
TButton,
|
|
82
84
|
TCard,
|
|
83
85
|
TCheckbox,
|
|
86
|
+
TCheckboxTree,
|
|
84
87
|
TColorModeButton,
|
|
85
88
|
TCommandPalette,
|
|
86
89
|
TContainerPicker,
|
|
@@ -101,6 +104,7 @@ export {
|
|
|
101
104
|
TInput,
|
|
102
105
|
TInputNumber,
|
|
103
106
|
TInputTags,
|
|
107
|
+
TListBox,
|
|
104
108
|
TLogView,
|
|
105
109
|
TModal,
|
|
106
110
|
TNav,
|
|
@@ -147,9 +151,9 @@ export { useToast, type Toast } from './composables/useToast'
|
|
|
147
151
|
|
|
148
152
|
const components = {
|
|
149
153
|
TAccentPicker, TAdvancedTable, TAlert, TAppLayout, TAuthLayout, TAvatar, TBadge, TButton, TCard,
|
|
150
|
-
TCheckbox, TColorModeButton, TCommandPalette, TContainerPicker, TCopyButton, TDataGrid, TDataGridItem, TDensityPicker,
|
|
154
|
+
TCheckbox, TCheckboxTree, TColorModeButton, TCommandPalette, TContainerPicker, TCopyButton, TDataGrid, TDataGridItem, TDensityPicker,
|
|
151
155
|
TDropdown, TEditableTable, TEmpty, TFieldGroup, TFileUpload, TFontPicker, TFormField, TIcon, TIconPicker, TImageUpload,
|
|
152
|
-
TInput, TInputNumber, TInputTags, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
156
|
+
TInput, TInputNumber, TInputTags, TListBox, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
153
157
|
TPanelList, TProgress, TRadioGroup, TRadiusPicker, TRating, TScaledFrame, TSearchButton, TSectionLayout,
|
|
154
158
|
TSelect, TSelectMenu, TSeparator, TShell, TSkeleton, TSlideover, TSparkline, TSpinner, TSplitter, TStatCard,
|
|
155
159
|
TSteps, TSwitch, TTable, TTabs, TTextarea, TThemeBasePicker, TThemeScope, TToaster, TTooltip,
|
|
@@ -174,6 +178,7 @@ declare module 'vue' {
|
|
|
174
178
|
TButton: typeof TButton
|
|
175
179
|
TCard: typeof TCard
|
|
176
180
|
TCheckbox: typeof TCheckbox
|
|
181
|
+
TCheckboxTree: typeof TCheckboxTree
|
|
177
182
|
TColorModeButton: typeof TColorModeButton
|
|
178
183
|
TCommandPalette: typeof TCommandPalette
|
|
179
184
|
TContainerPicker: typeof TContainerPicker
|
|
@@ -194,6 +199,7 @@ declare module 'vue' {
|
|
|
194
199
|
TInput: typeof TInput
|
|
195
200
|
TInputNumber: typeof TInputNumber
|
|
196
201
|
TInputTags: typeof TInputTags
|
|
202
|
+
TListBox: typeof TListBox
|
|
197
203
|
TLogView: typeof TLogView
|
|
198
204
|
TModal: typeof TModal
|
|
199
205
|
TNav: typeof TNav
|
package/src/plugins/charts.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
// Loads
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// Loads Apache ECharts (Apache-2.0), the first time a TChart is shown: its core, with only the
|
|
2
|
+
// charts, components and renderers TChart uses registered, so the rest isn't bundled.
|
|
3
|
+
import { once } from './once'
|
|
4
|
+
|
|
5
|
+
export const loadECharts = once(async () => {
|
|
6
|
+
const [core, charts, components, renderers] = await Promise.all([
|
|
7
|
+
import('echarts/core'),
|
|
8
|
+
import('echarts/charts'),
|
|
9
|
+
import('echarts/components'),
|
|
10
|
+
import('echarts/renderers')
|
|
11
|
+
])
|
|
12
|
+
core.use([
|
|
13
|
+
charts.LineChart, charts.BarChart, charts.PieChart,
|
|
14
|
+
components.GridComponent, components.TooltipComponent, components.LegendComponent,
|
|
15
|
+
renderers.SVGRenderer, renderers.CanvasRenderer
|
|
16
|
+
])
|
|
17
|
+
return core
|
|
18
|
+
})
|
package/src/types.ts
CHANGED
|
@@ -60,6 +60,14 @@ export interface AdvancedSelectItem<T = unknown> extends SelectItem<T> {
|
|
|
60
60
|
avatar?: string
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** An item of a TCheckboxTree: a leaf, or a parent with children. */
|
|
64
|
+
export interface TreeItem<T = string> {
|
|
65
|
+
label: string
|
|
66
|
+
value: T
|
|
67
|
+
children?: TreeItem<T>[]
|
|
68
|
+
disabled?: boolean
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
export interface TabItem {
|
|
64
72
|
label: string
|
|
65
73
|
value: string
|