@ternarytech-io/gears-ui 0.4.0 → 0.5.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 +163 -162
- package/package.json +6 -1
- package/src/components/TLightbox.vue +101 -0
- package/src/components/TPdfViewer.vue +252 -0
- package/src/components/TSeparator.vue +37 -5
- package/src/components/TStatCard.vue +69 -56
- package/src/index.ts +5 -1
- package/src/plugins/index.ts +5 -1
- package/src/plugins/pdf.ts +12 -0
- package/src/styles/gears.css +5 -0
package/README.md
CHANGED
|
@@ -1,162 +1,163 @@
|
|
|
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
|
-
| `
|
|
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
|
-
|
|
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` (a label at the start, center or end; color, style, thickness) |
|
|
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()`), `TLightbox` (images shown large: previous and next, arrow keys, swipes, captions) |
|
|
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; `loading`, `clickable`), `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`, `TPdfViewer`, `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
|
+
| `TPdfViewer` | PDF.js (Mozilla, Apache-2.0) | A PDF's pages, drawn as they scroll into view; `zoom` (fit width, fit page, a percent), `v-model:page`, a toolbar with download and open in a new tab; `setPage`, `download`. Its worker is loaded with Vite's `?url`. |
|
|
125
|
+
| `TCopyButton` | Tabler's clipboard | Copies `text`, or the field `target` selects. Needs https or localhost. |
|
|
126
|
+
| `TColorPicker` | Coloris | `format`, `alpha`, `swatches`, `swatchesOnly`. The field isn't wrapped by Coloris (Vue owns it); the swatch is ours. |
|
|
127
|
+
| `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. |
|
|
128
|
+
| `TDropzone` | Dropzone | With `url`, uploads; without, v-model collects the files. |
|
|
129
|
+
| `TInputMask` | Tabler's input mask, on IMask | `mask` like "(000) 000-0000"; `unmasked`; `showMask`. |
|
|
130
|
+
| `TRangeSlider` | noUiSlider | A number, or a range with `[from, to]`. |
|
|
131
|
+
| `TSortable` | Tabler's sortable, on SortableJS | Reorders v-model's array. Lists within one container; dragging between lists isn't wired up yet. |
|
|
132
|
+
| `TVectorMap` | Tabler's vector map | The world map: `values`, `markers`, `lines`, `legend`, `select` with v-model:selected, `zoom`. |
|
|
133
|
+
| `TRichEditor` | HugeRTE (open-source TinyMCE fork) | v-model is HTML. Bundled skins and plugins, nothing fetched; follows the theme by rebuilding the editor. |
|
|
134
|
+
|
|
135
|
+
### From the Studio's components
|
|
136
|
+
|
|
137
|
+
| Studio (Nuxt UI) | Gears UI |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `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`. |
|
|
140
|
+
| `UFormField`, `UInput`, `UTextarea`, `USelect`, `UCheckbox`, `USwitch`, `URadioGroup`, `UFieldGroup` | `TFormField` (`help` → `description`), `TInput`, `TTextarea`, `TSelect`, `TCheckbox`, `TSwitch`, `TRadioGroup`, `TFieldGroup` |
|
|
141
|
+
| `UModal`, `USlideover`, `UDropdownMenu` | `TModal`, `TSlideover`, `TDropdown` (same item groups; `onSelect`, `to`, `type: 'label'`) |
|
|
142
|
+
| `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) |
|
|
143
|
+
| `UInputNumber`, `UFileUpload` | `TInputNumber` (Tabler's number input: minus and plus, `min`, `max`, `step`), `TFileUpload` (`accept`, `multiple`; v-model holds the File, nothing uploads) |
|
|
144
|
+
| `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 |
|
|
145
|
+
| `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`) |
|
|
146
|
+
| `UDashboardGroup` + `UDashboardSidebar` + `UNavigationMenu` | `TShell` with `nav` items (`TNav`) |
|
|
147
|
+
| `UDashboardPanel` + `UDashboardNavbar` | `TTopbar` + `TPage` |
|
|
148
|
+
| `UColorModeButton` | `TColorModeButton` |
|
|
149
|
+
| `useToast()` (with `UApp`) | `useToast()` from `@ternarytech-io/gears-ui`, the same `add({ title, description, color, icon })`, and a `TToaster` in the frame |
|
|
150
|
+
| `StatCard`, `AuthCard`, `SectionLayout` | `TStatCard`, `TAuthLayout` (brand and logo are props), `TSectionLayout` |
|
|
151
|
+
| `BuildLog`, `AppLog` | Their polling stays in the Studio; the display is `TLogView` (`text`, or `lines` with times and levels, and `v-model:follow`) |
|
|
152
|
+
| `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` |
|
|
153
|
+
| `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 |
|
|
154
|
+
| `StudioPage`, `ProjectSwitcher`, user menu | Compositions of `TTopbar`, `TDropdown`, `TAvatar` and `TPage`: see the Top bar and Dropdown pages |
|
|
155
|
+
|
|
156
|
+
### Still to do
|
|
157
|
+
|
|
158
|
+
Every Nuxt UI component the Studio uses now has a Gears UI version. The preview site has no generated
|
|
159
|
+
props tables yet; the examples are the reference.
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
[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.5.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",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"imask": "^7.6.0",
|
|
54
54
|
"monaco-editor": "^0.57.0",
|
|
55
55
|
"nouislider": "^15.8.0",
|
|
56
|
+
"pdfjs-dist": "^6.4.0",
|
|
56
57
|
"sortablejs": "^1.15.0",
|
|
57
58
|
"tom-select": "^2.6.0",
|
|
58
59
|
"vanilla-calendar-pro": "^3.3.2",
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"imask": "7.6.1",
|
|
74
75
|
"monaco-editor": "0.57.0",
|
|
75
76
|
"nouislider": "15.8.1",
|
|
77
|
+
"pdfjs-dist": "6.4.299",
|
|
76
78
|
"sortablejs": "1.15.7",
|
|
77
79
|
"tom-select": "2.6.2",
|
|
78
80
|
"typescript": "5.9.3",
|
|
@@ -107,6 +109,9 @@
|
|
|
107
109
|
"nouislider": {
|
|
108
110
|
"optional": true
|
|
109
111
|
},
|
|
112
|
+
"pdfjs-dist": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
110
115
|
"sortablejs": {
|
|
111
116
|
"optional": true
|
|
112
117
|
},
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Images shown large over the page, one at a time: v-model is the one shown (its index; null when
|
|
3
|
+
// closed). Previous and next (buttons, the arrow keys, or a swipe), a counter, its caption, and
|
|
4
|
+
// close (the button, Escape, or a click beside the image). Focus moves to it while it's open and
|
|
5
|
+
// back to where it was after.
|
|
6
|
+
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
7
|
+
import TIcon from './TIcon.vue'
|
|
8
|
+
|
|
9
|
+
export interface LightboxImage { src: string; alt?: string; caption?: string }
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{ images: LightboxImage[]; loop?: boolean }>(), { loop: true })
|
|
12
|
+
const index = defineModel<number | null>({ default: null })
|
|
13
|
+
|
|
14
|
+
const open = computed(() => index.value != null && index.value >= 0 && index.value < props.images.length)
|
|
15
|
+
const image = computed(() => (open.value ? props.images[index.value!] : null))
|
|
16
|
+
const many = computed(() => props.images.length > 1)
|
|
17
|
+
|
|
18
|
+
function step(by: 1 | -1) {
|
|
19
|
+
if (index.value == null || !many.value) return
|
|
20
|
+
const next = index.value + by
|
|
21
|
+
index.value = props.loop ? (next + props.images.length) % props.images.length : Math.min(Math.max(next, 0), props.images.length - 1)
|
|
22
|
+
}
|
|
23
|
+
const close = () => { index.value = null }
|
|
24
|
+
|
|
25
|
+
function key(event: KeyboardEvent) {
|
|
26
|
+
if (!open.value) return
|
|
27
|
+
if (event.key === 'Escape') close()
|
|
28
|
+
else if (event.key === 'ArrowRight') step(1)
|
|
29
|
+
else if (event.key === 'ArrowLeft') step(-1)
|
|
30
|
+
else return
|
|
31
|
+
event.preventDefault()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A swipe across moves to the next or previous.
|
|
35
|
+
let startX: number | null = null
|
|
36
|
+
function touchStart(event: TouchEvent) { startX = event.touches[0]?.clientX ?? null }
|
|
37
|
+
function touchEnd(event: TouchEvent) {
|
|
38
|
+
const endX = event.changedTouches[0]?.clientX
|
|
39
|
+
if (startX != null && endX != null && Math.abs(endX - startX) > 50) step(endX < startX ? 1 : -1)
|
|
40
|
+
startX = null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dialog = ref<HTMLElement>()
|
|
44
|
+
let before: Element | null = null
|
|
45
|
+
watch(open, async now => {
|
|
46
|
+
if (now) {
|
|
47
|
+
before = document.activeElement
|
|
48
|
+
document.addEventListener('keydown', key)
|
|
49
|
+
await nextTick()
|
|
50
|
+
dialog.value?.focus()
|
|
51
|
+
} else {
|
|
52
|
+
document.removeEventListener('keydown', key)
|
|
53
|
+
if (before instanceof HTMLElement) before.focus()
|
|
54
|
+
}
|
|
55
|
+
}, { immediate: true })
|
|
56
|
+
onBeforeUnmount(() => document.removeEventListener('keydown', key))
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<Teleport to="body">
|
|
61
|
+
<div v-if="open && image" ref="dialog" class="t-lightbox" role="dialog" aria-modal="true" :aria-label="image.alt || image.caption || 'Image'" tabindex="-1"
|
|
62
|
+
@click.self="close" @touchstart.passive="touchStart" @touchend="touchEnd">
|
|
63
|
+
<button type="button" class="t-lightbox-close" aria-label="Close" @click="close"><TIcon name="x" /></button>
|
|
64
|
+
<button v-if="many" type="button" class="t-lightbox-step start" aria-label="Previous image" @click="step(-1)"><TIcon name="chevron-left" /></button>
|
|
65
|
+
<figure class="t-lightbox-figure" @click.self="close">
|
|
66
|
+
<img :key="image.src" :src="image.src" :alt="image.alt ?? ''">
|
|
67
|
+
<figcaption v-if="image.caption || many">
|
|
68
|
+
<span v-if="many" class="t-lightbox-count">{{ index! + 1 }} / {{ images.length }}</span>
|
|
69
|
+
<span v-if="image.caption">{{ image.caption }}</span>
|
|
70
|
+
</figcaption>
|
|
71
|
+
</figure>
|
|
72
|
+
<button v-if="many" type="button" class="t-lightbox-step end" aria-label="Next image" @click="step(1)"><TIcon name="chevron-right" /></button>
|
|
73
|
+
</div>
|
|
74
|
+
</Teleport>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<style scoped>
|
|
78
|
+
.t-lightbox {
|
|
79
|
+
position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
|
|
80
|
+
background: rgba(10, 12, 16, 0.88); outline: none; animation: t-lightbox-in 0.15s ease-out;
|
|
81
|
+
}
|
|
82
|
+
@keyframes t-lightbox-in { from { opacity: 0; } }
|
|
83
|
+
.t-lightbox-figure { margin: 0; max-width: calc(100vw - 8rem); max-height: calc(100vh - 6rem); display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
|
|
84
|
+
.t-lightbox-figure img { max-width: 100%; max-height: calc(100vh - 9rem); object-fit: contain; border-radius: var(--tblr-border-radius); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
|
|
85
|
+
.t-lightbox-figure figcaption { display: flex; gap: 0.75rem; align-items: baseline; color: #e6e7e9; font-size: 0.875rem; text-align: center; }
|
|
86
|
+
.t-lightbox-count { color: #9aa0ac; font-variant-numeric: tabular-nums; }
|
|
87
|
+
.t-lightbox-close, .t-lightbox-step {
|
|
88
|
+
position: absolute; display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%;
|
|
89
|
+
background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 1.25rem; cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
.t-lightbox-close:hover, .t-lightbox-step:hover { background: rgba(255, 255, 255, 0.2); }
|
|
92
|
+
.t-lightbox-close:focus-visible, .t-lightbox-step:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
|
93
|
+
.t-lightbox-close { top: 1rem; right: 1rem; }
|
|
94
|
+
.t-lightbox-step { top: 50%; transform: translateY(-50%); }
|
|
95
|
+
.t-lightbox-step.start { left: 1rem; }
|
|
96
|
+
.t-lightbox-step.end { right: 1rem; }
|
|
97
|
+
@media (max-width: 576px) {
|
|
98
|
+
.t-lightbox-figure { max-width: 100vw; }
|
|
99
|
+
.t-lightbox-step { top: auto; bottom: 1rem; transform: none; }
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A PDF, drawn by PDF.js (loaded on first use): its pages one under another, each drawn when it
|
|
3
|
+
// scrolls into view, at a zoom that fits the width (default), fits a whole page, or a percent.
|
|
4
|
+
// The toolbar has the page (v-model:page; typing one goes there), previous and next, zoom, and
|
|
5
|
+
// download and open in a new tab. A PDF that can't be read says so, with a link to download it.
|
|
6
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
|
|
7
|
+
import type { PDFDocumentProxy, PDFPageProxy, RenderTask } from 'pdfjs-dist'
|
|
8
|
+
import { loadPdfJs } from '../plugins/pdf'
|
|
9
|
+
import TIcon from './TIcon.vue'
|
|
10
|
+
|
|
11
|
+
export type PdfZoom = 'width' | 'page' | number
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<{
|
|
14
|
+
src: string
|
|
15
|
+
// Fit the width, fit a page, or a percent (100 is the PDF's own size).
|
|
16
|
+
zoom?: PdfZoom
|
|
17
|
+
toolbar?: boolean
|
|
18
|
+
download?: boolean
|
|
19
|
+
// The downloaded file's name; by default the address's last part.
|
|
20
|
+
fileName?: string
|
|
21
|
+
height?: number | string
|
|
22
|
+
label?: string
|
|
23
|
+
}>(), { zoom: 'width', toolbar: true, download: true, height: 480, label: 'PDF document' })
|
|
24
|
+
|
|
25
|
+
const page = defineModel<number>('page', { default: 1 })
|
|
26
|
+
const emit = defineEmits<{ load: [info: { pages: number }]; error: [message: string] }>()
|
|
27
|
+
|
|
28
|
+
const scroller = ref<HTMLElement>()
|
|
29
|
+
const doc = shallowRef<PDFDocumentProxy | null>(null)
|
|
30
|
+
const pages = shallowRef<PDFPageProxy[]>([])
|
|
31
|
+
const loading = ref(true)
|
|
32
|
+
const problem = ref('')
|
|
33
|
+
const zoom = ref<PdfZoom>(props.zoom)
|
|
34
|
+
const scale = ref(1)
|
|
35
|
+
watch(() => props.zoom, z => { zoom.value = z })
|
|
36
|
+
|
|
37
|
+
const cssHeight = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height))
|
|
38
|
+
const name = computed(() => props.fileName || decodeURIComponent(props.src.split(/[?#]/)[0]!.split('/').pop() || 'document.pdf'))
|
|
39
|
+
const count = computed(() => pages.value.length)
|
|
40
|
+
|
|
41
|
+
// ---- Loading ----
|
|
42
|
+
let loadingTask: { destroy: () => Promise<void> } | null = null
|
|
43
|
+
async function open() {
|
|
44
|
+
close()
|
|
45
|
+
loading.value = true
|
|
46
|
+
problem.value = ''
|
|
47
|
+
try {
|
|
48
|
+
const pdfjs = await loadPdfJs()
|
|
49
|
+
const task = pdfjs.getDocument({ url: props.src })
|
|
50
|
+
loadingTask = task
|
|
51
|
+
const opened = await task.promise
|
|
52
|
+
doc.value = opened
|
|
53
|
+
pages.value = await Promise.all(Array.from({ length: opened.numPages }, (_, i) => opened.getPage(i + 1)))
|
|
54
|
+
fit()
|
|
55
|
+
loading.value = false
|
|
56
|
+
emit('load', { pages: opened.numPages })
|
|
57
|
+
await nextTick()
|
|
58
|
+
observe()
|
|
59
|
+
if (page.value > 1) goTo(page.value)
|
|
60
|
+
} catch (e) {
|
|
61
|
+
loading.value = false
|
|
62
|
+
problem.value = e instanceof Error && /password/i.test(e.message) ? 'This PDF needs a password.' : 'This PDF couldn\'t be shown.'
|
|
63
|
+
emit('error', e instanceof Error ? e.message : problem.value)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function close() {
|
|
67
|
+
for (const task of tasks.values()) task.cancel()
|
|
68
|
+
tasks.clear()
|
|
69
|
+
drawn.clear()
|
|
70
|
+
observer?.disconnect()
|
|
71
|
+
void loadingTask?.destroy()
|
|
72
|
+
loadingTask = null
|
|
73
|
+
doc.value = null
|
|
74
|
+
pages.value = []
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ---- Zoom ----
|
|
78
|
+
const sizes = computed(() => pages.value.map(p => p.getViewport({ scale: scale.value })))
|
|
79
|
+
/** The zoom as a scale: a fit works it out from the box and the first page. */
|
|
80
|
+
function fit() {
|
|
81
|
+
const first = pages.value[0]
|
|
82
|
+
const box = scroller.value
|
|
83
|
+
if (!first || !box) return
|
|
84
|
+
const natural = first.getViewport({ scale: 1 })
|
|
85
|
+
const width = (box.clientWidth - 32) / natural.width
|
|
86
|
+
const whole = Math.min(width, (box.clientHeight - 32) / natural.height)
|
|
87
|
+
scale.value = Math.max(0.1, zoom.value === 'width' ? width : zoom.value === 'page' ? whole : zoom.value / 100)
|
|
88
|
+
}
|
|
89
|
+
watch(zoom, () => { fit(); redraw() })
|
|
90
|
+
const steps = [50, 75, 100, 125, 150, 200, 300]
|
|
91
|
+
function zoomBy(direction: 1 | -1) {
|
|
92
|
+
const now = Math.round(scale.value * 100)
|
|
93
|
+
const next = direction > 0 ? steps.find(s => s > now) ?? 400 : [...steps].reverse().find(s => s < now) ?? 25
|
|
94
|
+
zoom.value = next
|
|
95
|
+
}
|
|
96
|
+
const zoomItems = [{ label: 'Fit width', value: 'width' }, { label: 'Fit page', value: 'page' }, ...steps.map(s => ({ label: `${s}%`, value: String(s) }))]
|
|
97
|
+
const zoomChoice = computed({
|
|
98
|
+
get: () => (typeof zoom.value === 'number' ? String(zoom.value) : zoom.value),
|
|
99
|
+
set: (v: string) => { zoom.value = v === 'width' || v === 'page' ? v : Number(v) }
|
|
100
|
+
})
|
|
101
|
+
const zoomShown = computed(() => (typeof zoom.value === 'number' || !zoomItems.some(z => z.value === zoomChoice.value) ? `${Math.round(scale.value * 100)}%` : ''))
|
|
102
|
+
|
|
103
|
+
// ---- Drawing pages as they come into view ----
|
|
104
|
+
const canvases = ref<HTMLCanvasElement[]>([])
|
|
105
|
+
const tasks = new Map<number, RenderTask>()
|
|
106
|
+
const drawn = new Map<number, number>()
|
|
107
|
+
let observer: IntersectionObserver | null = null
|
|
108
|
+
function observe() {
|
|
109
|
+
observer?.disconnect()
|
|
110
|
+
observer = new IntersectionObserver(entries => {
|
|
111
|
+
for (const e of entries) if (e.isIntersecting) void draw(Number((e.target as HTMLElement).dataset.page))
|
|
112
|
+
}, { root: scroller.value, rootMargin: '400px 0px' })
|
|
113
|
+
scroller.value?.querySelectorAll('.t-pdf-page').forEach(el => observer!.observe(el))
|
|
114
|
+
}
|
|
115
|
+
async function draw(index: number) {
|
|
116
|
+
const p = pages.value[index]
|
|
117
|
+
const canvas = canvases.value[index]
|
|
118
|
+
if (!p || !canvas || drawn.get(index) === scale.value) return
|
|
119
|
+
tasks.get(index)?.cancel()
|
|
120
|
+
const ratio = window.devicePixelRatio || 1
|
|
121
|
+
const viewport = p.getViewport({ scale: scale.value * ratio })
|
|
122
|
+
canvas.width = Math.floor(viewport.width)
|
|
123
|
+
canvas.height = Math.floor(viewport.height)
|
|
124
|
+
const task = p.render({ canvas, viewport })
|
|
125
|
+
tasks.set(index, task)
|
|
126
|
+
try {
|
|
127
|
+
await task.promise
|
|
128
|
+
drawn.set(index, scale.value)
|
|
129
|
+
} catch {
|
|
130
|
+
// Cancelled by a newer drawing.
|
|
131
|
+
} finally {
|
|
132
|
+
if (tasks.get(index) === task) tasks.delete(index)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function redraw() {
|
|
136
|
+
drawn.clear()
|
|
137
|
+
void nextTick(() => observe())
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---- Pages ----
|
|
141
|
+
function goTo(n: number) {
|
|
142
|
+
const target = Math.min(Math.max(1, Math.round(n) || 1), Math.max(1, count.value))
|
|
143
|
+
page.value = target
|
|
144
|
+
const el = scroller.value?.querySelector<HTMLElement>(`[data-page="${target - 1}"]`)
|
|
145
|
+
if (el && scroller.value) scroller.value.scrollTop = el.offsetTop - 12
|
|
146
|
+
}
|
|
147
|
+
// The page shown is the one nearest the top as it scrolls.
|
|
148
|
+
function scrolled() {
|
|
149
|
+
const box = scroller.value
|
|
150
|
+
if (!box) return
|
|
151
|
+
const els = [...box.querySelectorAll<HTMLElement>('.t-pdf-page')]
|
|
152
|
+
const top = box.scrollTop + box.clientHeight * 0.25
|
|
153
|
+
let current = 1
|
|
154
|
+
for (const el of els) if (el.offsetTop <= top) current = Number(el.dataset.page) + 1
|
|
155
|
+
if (current !== page.value) page.value = current
|
|
156
|
+
}
|
|
157
|
+
const typed = ref('')
|
|
158
|
+
watch(page, p => { typed.value = String(p) }, { immediate: true })
|
|
159
|
+
watch(page, p => {
|
|
160
|
+
const box = scroller.value
|
|
161
|
+
const el = box?.querySelector<HTMLElement>(`[data-page="${p - 1}"]`)
|
|
162
|
+
if (!box || !el) return
|
|
163
|
+
// Changed from outside (not by scrolling): go there.
|
|
164
|
+
if (el.offsetTop > box.scrollTop + box.clientHeight * 0.25 || el.offsetTop + el.offsetHeight < box.scrollTop) box.scrollTop = el.offsetTop - 12
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
function downloadFile() {
|
|
168
|
+
const a = document.createElement('a')
|
|
169
|
+
a.href = props.src
|
|
170
|
+
a.download = name.value
|
|
171
|
+
document.body.appendChild(a)
|
|
172
|
+
a.click()
|
|
173
|
+
a.remove()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let sized: ResizeObserver | null = null
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
void open()
|
|
179
|
+
sized = new ResizeObserver(() => {
|
|
180
|
+
if (zoom.value === 'width' || zoom.value === 'page') {
|
|
181
|
+
const before = scale.value
|
|
182
|
+
fit()
|
|
183
|
+
if (Math.abs(before - scale.value) > 0.01) redraw()
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
if (scroller.value) sized.observe(scroller.value)
|
|
187
|
+
})
|
|
188
|
+
watch(() => props.src, () => void open())
|
|
189
|
+
onBeforeUnmount(() => {
|
|
190
|
+
sized?.disconnect()
|
|
191
|
+
close()
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
defineExpose({ setPage: goTo, download: downloadFile })
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<div class="t-pdf card" :style="{ height: cssHeight }" role="document" :aria-label="label">
|
|
199
|
+
<div v-if="toolbar" class="t-pdf-toolbar">
|
|
200
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="page <= 1 || !count" aria-label="Previous page" @click="goTo(page - 1)">
|
|
201
|
+
<TIcon name="chevron-up" />
|
|
202
|
+
</button>
|
|
203
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="page >= count || !count" aria-label="Next page" @click="goTo(page + 1)">
|
|
204
|
+
<TIcon name="chevron-down" />
|
|
205
|
+
</button>
|
|
206
|
+
<label class="t-pdf-page-number">
|
|
207
|
+
<input v-model="typed" class="form-control form-control-sm" inputmode="numeric" aria-label="Page" :disabled="!count"
|
|
208
|
+
@keydown.enter="goTo(Number(typed))" @blur="goTo(Number(typed))">
|
|
209
|
+
<span class="text-secondary small text-nowrap">of {{ count || '…' }}</span>
|
|
210
|
+
</label>
|
|
211
|
+
<span class="ms-auto" />
|
|
212
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="!count" aria-label="Zoom out" @click="zoomBy(-1)"><TIcon name="zoom-out" /></button>
|
|
213
|
+
<select v-model="zoomChoice" class="form-select form-select-sm t-pdf-zoom" aria-label="Zoom" :disabled="!count">
|
|
214
|
+
<option v-if="zoomShown" :value="zoomChoice" hidden>{{ zoomShown }}</option>
|
|
215
|
+
<option v-for="z in zoomItems" :key="z.value" :value="z.value">{{ z.label }}</option>
|
|
216
|
+
</select>
|
|
217
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="!count" aria-label="Zoom in" @click="zoomBy(1)"><TIcon name="zoom-in" /></button>
|
|
218
|
+
<template v-if="download">
|
|
219
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" aria-label="Download" title="Download" @click="downloadFile"><TIcon name="download" /></button>
|
|
220
|
+
<a class="btn btn-sm btn-ghost-secondary btn-icon" :href="src" target="_blank" rel="noopener" aria-label="Open in a new tab" title="Open in a new tab">
|
|
221
|
+
<TIcon name="external-link" />
|
|
222
|
+
</a>
|
|
223
|
+
</template>
|
|
224
|
+
</div>
|
|
225
|
+
<div ref="scroller" class="t-pdf-pages" @scroll.passive="scrolled">
|
|
226
|
+
<div v-if="loading" class="t-pdf-note"><span class="spinner-border spinner-border-sm" role="status" /> Loading the PDF…</div>
|
|
227
|
+
<div v-else-if="problem" class="t-pdf-note flex-column">
|
|
228
|
+
<TIcon name="file-alert" class="text-secondary" />
|
|
229
|
+
<span>{{ problem }}</span>
|
|
230
|
+
<a v-if="download" :href="src" :download="name">Download it</a>
|
|
231
|
+
</div>
|
|
232
|
+
<template v-else>
|
|
233
|
+
<div v-for="(size, i) in sizes" :key="i" class="t-pdf-page" :data-page="i" :style="{ width: `${size.width}px`, height: `${size.height}px` }">
|
|
234
|
+
<canvas :ref="el => { canvases[i] = el as HTMLCanvasElement }" :style="{ width: `${size.width}px`, height: `${size.height}px` }"
|
|
235
|
+
:aria-label="`Page ${i + 1}`" role="img" />
|
|
236
|
+
</div>
|
|
237
|
+
</template>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</template>
|
|
241
|
+
|
|
242
|
+
<style scoped>
|
|
243
|
+
.t-pdf { display: flex; flex-direction: column; overflow: hidden; margin: 0; }
|
|
244
|
+
.t-pdf-toolbar { display: flex; align-items: center; gap: 0.25rem; padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--tblr-border-color); }
|
|
245
|
+
.t-pdf-page-number { display: inline-flex; align-items: center; gap: 0.375rem; margin: 0 0 0 0.25rem; }
|
|
246
|
+
.t-pdf-page-number input { width: 3.25rem; text-align: center; }
|
|
247
|
+
.t-pdf-zoom { width: 7rem; }
|
|
248
|
+
.t-pdf-pages { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 16px; background: var(--tblr-bg-surface-secondary); }
|
|
249
|
+
.t-pdf-page { margin: 0 auto 12px; background: #fff; box-shadow: var(--tblr-box-shadow-card, 0 1px 3px rgba(0, 0, 0, 0.15)); }
|
|
250
|
+
.t-pdf-page canvas { display: block; }
|
|
251
|
+
.t-pdf-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.5rem; color: var(--tblr-secondary); font-size: 0.875rem; }
|
|
252
|
+
</style>
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
// A
|
|
3
|
-
|
|
2
|
+
// A line between things: across (with an optional label at the start, center or end), or upright
|
|
3
|
+
// inside a row. Its color is the border color unless given (a named color such as 'primary', one
|
|
4
|
+
// of Tabler's, or any CSS color), with a style (solid, dashed, dotted) and a thickness in pixels.
|
|
5
|
+
// `spacing` 'none' drops the space above and below.
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { toTabler, type Color } from '../types'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
label?: string
|
|
11
|
+
orientation?: 'horizontal' | 'vertical'
|
|
12
|
+
position?: 'start' | 'center' | 'end'
|
|
13
|
+
color?: Color | string
|
|
14
|
+
variant?: 'solid' | 'dashed' | 'dotted'
|
|
15
|
+
thickness?: number
|
|
16
|
+
spacing?: 'normal' | 'none'
|
|
17
|
+
}>(), { orientation: 'horizontal', position: 'center', variant: 'solid', thickness: 1, spacing: 'normal' })
|
|
18
|
+
|
|
19
|
+
const named = new Set(['primary', 'neutral', 'success', 'warning', 'error', 'info'])
|
|
20
|
+
const tabler = new Set(['blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan', 'secondary', 'muted'])
|
|
21
|
+
const line = computed(() => {
|
|
22
|
+
const c = props.color
|
|
23
|
+
const color = !c ? 'var(--tblr-border-color)' : named.has(c) ? `var(--tblr-${toTabler(c as Color)})` : tabler.has(c) ? `var(--tblr-${c})` : c
|
|
24
|
+
return { '--t-separator-color': color, '--t-separator-style': props.variant, '--t-separator-width': `${Math.max(1, Math.min(props.thickness, 12))}px` }
|
|
25
|
+
})
|
|
4
26
|
</script>
|
|
5
27
|
|
|
6
28
|
<template>
|
|
7
|
-
<div v-if="orientation === 'vertical'" class="
|
|
8
|
-
<div v-else-if="label" class="hr-text
|
|
9
|
-
|
|
29
|
+
<div v-if="orientation === 'vertical'" class="t-separator t-separator-vertical" role="separator" aria-orientation="vertical" :style="line" />
|
|
30
|
+
<div v-else-if="label" :class="['t-separator hr-text', { 'hr-text-start': position === 'start', 'hr-text-end': position === 'end', 't-separator-flush': spacing === 'none' }]"
|
|
31
|
+
role="separator" :style="line"><span>{{ label }}</span></div>
|
|
32
|
+
<hr v-else :class="['t-separator', spacing === 'none' ? 'my-0' : 'my-3']" :style="line">
|
|
10
33
|
</template>
|
|
34
|
+
|
|
35
|
+
<style scoped>
|
|
36
|
+
hr.t-separator { border: 0; border-top: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color); opacity: 1; }
|
|
37
|
+
.t-separator.hr-text::before, .t-separator.hr-text::after {
|
|
38
|
+
height: 0; background: none; border-top: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color);
|
|
39
|
+
}
|
|
40
|
+
.t-separator-flush { margin: 0.5rem 0; }
|
|
41
|
+
.t-separator-vertical { align-self: stretch; width: 0; min-height: 1em; border-inline-start: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color); }
|
|
42
|
+
</style>
|
|
@@ -1,56 +1,69 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// A figure on an overview page: label, value, a line under it, and an icon in a tinted square. A
|
|
3
|
-
// `trend` (the change, in percent) shows beside the value, green when it's good: up, unless
|
|
4
|
-
// `trendGood` is 'down' (costs, errors). `sparkline` draws the recent values under it.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A figure on an overview page: label, value, a line under it, and an icon in a tinted square. A
|
|
3
|
+
// `trend` (the change, in percent) shows beside the value, green when it's good: up, unless
|
|
4
|
+
// `trendGood` is 'down' (costs, errors). `sparkline` draws the recent values under it. `loading`
|
|
5
|
+
// holds placeholders where the value and trend go; `clickable` makes the card a button that emits
|
|
6
|
+
// `click` (Enter and Space too).
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import TIcon from './TIcon.vue'
|
|
9
|
+
import TSparkline from './TSparkline.vue'
|
|
10
|
+
import { toTabler, type Color } from '../types'
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<{
|
|
13
|
+
label: string
|
|
14
|
+
value: string | number
|
|
15
|
+
detail?: string
|
|
16
|
+
icon?: string
|
|
17
|
+
color?: Color
|
|
18
|
+
trend?: number | null
|
|
19
|
+
trendLabel?: string
|
|
20
|
+
trendGood?: 'up' | 'down'
|
|
21
|
+
sparkline?: number[]
|
|
22
|
+
sparklineType?: 'line' | 'bar'
|
|
23
|
+
loading?: boolean
|
|
24
|
+
clickable?: boolean
|
|
25
|
+
}>(), { color: 'primary', trendGood: 'up', sparklineType: 'line' })
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{ click: [event: MouseEvent | KeyboardEvent] }>()
|
|
28
|
+
function press(event: MouseEvent | KeyboardEvent) {
|
|
29
|
+
if (props.clickable) emit('click', event)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const trendText = computed(() => props.trend == null ? '' : `${Math.abs(Math.round(props.trend * 10) / 10)}%`)
|
|
33
|
+
const trendClass = computed(() => {
|
|
34
|
+
if (props.trend == null || props.trend === 0) return 'text-secondary'
|
|
35
|
+
return (props.trend > 0) === (props.trendGood === 'up') ? 'text-success' : 'text-danger'
|
|
36
|
+
})
|
|
37
|
+
const trendIcon = computed(() => !props.trend ? 'minus' : props.trend > 0 ? 'trending-up' : 'trending-down')
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div :class="['card', { 't-stat-clickable': clickable }]" :role="clickable ? 'button' : undefined" :tabindex="clickable ? 0 : undefined"
|
|
42
|
+
:aria-busy="loading || undefined" @click="press" @keydown.enter.prevent="press" @keydown.space.prevent="press">
|
|
43
|
+
<div class="card-body">
|
|
44
|
+
<div class="d-flex align-items-start justify-content-between gap-3">
|
|
45
|
+
<div class="min-w-0">
|
|
46
|
+
<div class="subheader">{{ label }}</div>
|
|
47
|
+
<div v-if="loading" class="mt-2 placeholder-glow" aria-label="Loading">
|
|
48
|
+
<span class="placeholder col-7 t-stat-placeholder" />
|
|
49
|
+
</div>
|
|
50
|
+
<div v-else class="d-flex align-items-baseline gap-2 mt-2">
|
|
51
|
+
<div class="h1 mb-0">{{ value }}</div>
|
|
52
|
+
<span v-if="trend != null" :class="['d-inline-flex align-items-center gap-1 lh-1 small fw-medium', trendClass]"
|
|
53
|
+
:title="trendLabel">
|
|
54
|
+
{{ trendText }}<TIcon :name="trendIcon" />
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
<div v-if="detail || trendLabel || $slots.detail" class="text-secondary small mt-1">
|
|
58
|
+
<slot name="detail">{{ detail ?? trendLabel }}</slot>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<div v-if="icon" :class="['t-stat-icon', `bg-${toTabler(color)}-lt`]">
|
|
62
|
+
<TIcon :name="icon" />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<TSparkline v-if="sparkline?.length && !loading" :values="sparkline" :type="sparklineType" :color="color" :width="240" :height="36"
|
|
66
|
+
class="t-stat-sparkline mt-3" :label="`${label}: recent values`" />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
package/src/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ import TIcon from './components/TIcon.vue'
|
|
|
33
33
|
import TIconPicker from './components/TIconPicker.vue'
|
|
34
34
|
import TImageUpload from './components/TImageUpload.vue'
|
|
35
35
|
import TInput from './components/TInput.vue'
|
|
36
|
+
import TLightbox from './components/TLightbox.vue'
|
|
36
37
|
import TInputNumber from './components/TInputNumber.vue'
|
|
37
38
|
import TInputTags from './components/TInputTags.vue'
|
|
38
39
|
import TListBox from './components/TListBox.vue'
|
|
@@ -103,6 +104,7 @@ export {
|
|
|
103
104
|
TImageUpload,
|
|
104
105
|
TInput,
|
|
105
106
|
TInputNumber,
|
|
107
|
+
TLightbox,
|
|
106
108
|
TInputTags,
|
|
107
109
|
TListBox,
|
|
108
110
|
TLogView,
|
|
@@ -143,6 +145,7 @@ export {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
export * from './types'
|
|
148
|
+
export type { LightboxImage } from './components/TLightbox.vue'
|
|
146
149
|
export { isCustomAccent, themeAccents, themeBases, themeContainers, themeDensities, themeFonts, themeNavs, themeRadii, themeRadiusSizes } from './theme'
|
|
147
150
|
export { useColorMode, type ColorMode } from './composables/useColorMode'
|
|
148
151
|
export { useCommandPalette } from './composables/useCommandPalette'
|
|
@@ -153,7 +156,7 @@ const components = {
|
|
|
153
156
|
TAccentPicker, TAdvancedTable, TAlert, TAppLayout, TAuthLayout, TAvatar, TBadge, TButton, TCard,
|
|
154
157
|
TCheckbox, TCheckboxTree, TColorModeButton, TCommandPalette, TContainerPicker, TCopyButton, TDataGrid, TDataGridItem, TDensityPicker,
|
|
155
158
|
TDropdown, TEditableTable, TEmpty, TFieldGroup, TFileUpload, TFontPicker, TFormField, TIcon, TIconPicker, TImageUpload,
|
|
156
|
-
TInput, TInputNumber, TInputTags, TListBox, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
159
|
+
TInput, TInputNumber, TInputTags, TLightbox, TListBox, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
157
160
|
TPanelList, TProgress, TRadioGroup, TRadiusPicker, TRating, TScaledFrame, TSearchButton, TSectionLayout,
|
|
158
161
|
TSelect, TSelectMenu, TSeparator, TShell, TSkeleton, TSlideover, TSparkline, TSpinner, TSplitter, TStatCard,
|
|
159
162
|
TSteps, TSwitch, TTable, TTabs, TTextarea, TThemeBasePicker, TThemeScope, TToaster, TTooltip,
|
|
@@ -197,6 +200,7 @@ declare module 'vue' {
|
|
|
197
200
|
TIconPicker: typeof TIconPicker
|
|
198
201
|
TImageUpload: typeof TImageUpload
|
|
199
202
|
TInput: typeof TInput
|
|
203
|
+
TLightbox: typeof TLightbox
|
|
200
204
|
TInputNumber: typeof TInputNumber
|
|
201
205
|
TInputTags: typeof TInputTags
|
|
202
206
|
TListBox: typeof TListBox
|
package/src/plugins/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import TColorPicker from '../components/TColorPicker.vue'
|
|
|
8
8
|
import TDatePicker from '../components/TDatePicker.vue'
|
|
9
9
|
import TDropzone from '../components/TDropzone.vue'
|
|
10
10
|
import TInputMask from '../components/TInputMask.vue'
|
|
11
|
+
import TPdfViewer from '../components/TPdfViewer.vue'
|
|
11
12
|
import TRangeSlider from '../components/TRangeSlider.vue'
|
|
12
13
|
import TRichEditor from '../components/TRichEditor.vue'
|
|
13
14
|
import TSortable from '../components/TSortable.vue'
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
TDatePicker,
|
|
21
22
|
TDropzone,
|
|
22
23
|
TInputMask,
|
|
24
|
+
TPdfViewer,
|
|
23
25
|
TRangeSlider,
|
|
24
26
|
TRichEditor,
|
|
25
27
|
TSortable,
|
|
@@ -27,9 +29,10 @@ export {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export type { RichEditorPlugin } from './richEditor'
|
|
32
|
+
export type { PdfZoom } from '../components/TPdfViewer.vue'
|
|
30
33
|
|
|
31
34
|
const components = {
|
|
32
|
-
TAdvancedSelect, TChart, TColorPicker, TDatePicker, TDropzone, TInputMask, TRangeSlider, TRichEditor,
|
|
35
|
+
TAdvancedSelect, TChart, TColorPicker, TDatePicker, TDropzone, TInputMask, TPdfViewer, TRangeSlider, TRichEditor,
|
|
33
36
|
TSortable, TSortableTree
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -47,6 +50,7 @@ declare module 'vue' {
|
|
|
47
50
|
TDatePicker: typeof TDatePicker
|
|
48
51
|
TDropzone: typeof TDropzone
|
|
49
52
|
TInputMask: typeof TInputMask
|
|
53
|
+
TPdfViewer: typeof TPdfViewer
|
|
50
54
|
TRangeSlider: typeof TRangeSlider
|
|
51
55
|
TRichEditor: typeof TRichEditor
|
|
52
56
|
TSortable: typeof TSortable
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Loads PDF.js (Mozilla, Apache-2.0) the first time a TPdfViewer is shown, with its worker (which
|
|
2
|
+
// reads the PDF off the page's thread). The worker's address comes from the bundler (Vite's `?url`).
|
|
3
|
+
import { once } from './once'
|
|
4
|
+
|
|
5
|
+
export const loadPdfJs = once(async () => {
|
|
6
|
+
const [pdfjs, worker] = await Promise.all([
|
|
7
|
+
import('pdfjs-dist'),
|
|
8
|
+
import('pdfjs-dist/build/pdf.worker.min.mjs?url')
|
|
9
|
+
])
|
|
10
|
+
pdfjs.GlobalWorkerOptions.workerSrc = worker.default
|
|
11
|
+
return pdfjs
|
|
12
|
+
})
|
package/src/styles/gears.css
CHANGED
|
@@ -667,3 +667,8 @@
|
|
|
667
667
|
.t-chart { min-height: 1px; }
|
|
668
668
|
.t-stat-sparkline { display: block; width: 100%; }
|
|
669
669
|
.t-stat-sparkline svg { width: 100%; height: 2.25rem; }
|
|
670
|
+
/* A stat card that's a button: it lifts on hover and shows focus. */
|
|
671
|
+
.t-stat-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
|
|
672
|
+
.t-stat-clickable:hover { border-color: var(--tblr-primary); }
|
|
673
|
+
.t-stat-clickable:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: 2px; }
|
|
674
|
+
.t-stat-placeholder { height: 2rem; border-radius: var(--tblr-border-radius); }
|