@ternarytech-io/gears-ui 0.1.0 → 0.2.1

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 CHANGED
@@ -59,7 +59,7 @@ it uses:
59
59
  | --- | --- | --- |
60
60
  | `@ternarytech-io/gears-ui` | Everything else | Nothing more |
61
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` (install with `GearsUIPlugins`) | Each one's library; and `@ternarytech-io/gears-ui/plugins.css` |
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
63
  | `@ternarytech-io/gears-ui/components/T….vue` | Any one component on its own | Only that component's library |
64
64
 
65
65
  `GearsUIPlugins` and `plugins.css` need all eight libraries. To use only some plugins, import those
@@ -103,12 +103,12 @@ add a page, add an entry to `preview/registry.ts` and a folder of examples.
103
103
  | --- | --- |
104
104
  | Elements | `TButton`, `TBadge`, `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` |
105
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), `TCodeEditor` |
106
- | Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TThemeScope` (applies a `ThemeSettings` to what's inside it); `themeAccents`, `themeFonts`, `themeBases`, `themeRadii` |
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
107
  | Overlays | `TModal`, `TSlideover`, `TDropdown`, `TToaster` (with `useToast()`) |
108
108
  | Navigation | `TTabs`, `TPagination`, `TSteps`, `TNav`, `TPanelList`, `TCommandPalette`, `TSearchButton` |
109
109
  | Data | `TTable` (sorting, `selectable` rows), `TAdvancedTable` (filters by column), `TStatCard`, `TLogView` |
110
- | Layout | `TShell`, `TTopbar`, `TPage`, `TSectionLayout`, `TSplitter`, `TAuthLayout`, `TColorModeButton` |
111
- | Plugins | `TAdvancedSelect`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TVectorMap`, `TRichEditor` |
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`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TSortableTree`, `TVectorMap`, `TRichEditor` |
112
112
 
113
113
  ### Plugins
114
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ternarytech-io/gears-ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
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",
@@ -11,7 +11,14 @@
11
11
  "url": "git+https://github.com/TernaryTech-io/Gears.UI.git"
12
12
  },
13
13
  "bugs": "https://github.com/TernaryTech-io/Gears.UI/issues",
14
- "keywords": ["vue", "vue3", "tabler", "components", "ui", "gears"],
14
+ "keywords": [
15
+ "vue",
16
+ "vue3",
17
+ "tabler",
18
+ "components",
19
+ "ui",
20
+ "gears"
21
+ ],
15
22
  "files": [
16
23
  "src",
17
24
  "README.md",
@@ -0,0 +1,88 @@
1
+ <script setup lang="ts">
2
+ // An application's frame, laid out by a theme's layout settings (`theme`): the navigation down the
3
+ // left (it can fold to icons) or across the top (it can stay at the top as the page scrolls, and
4
+ // float apart from the edges), and the page boxed (centered, the background around it) or fluid.
5
+ // The brand is the logo and name, or the `brand` slot; the links are `items` (TNav), or the `nav`
6
+ // slot for links of your own. `actions` go at the top bar's end, or at the foot of the sidebar.
7
+ // Tabler's page, navbar and layout-boxed classes do the work, so it looks like Tabler's layouts.
8
+ // On small screens the links fold away behind a menu button, and close again on navigating.
9
+ import { computed, ref, watch } from 'vue'
10
+ import { useRoute } from 'vue-router'
11
+ import TIcon from './TIcon.vue'
12
+ import TNav from './TNav.vue'
13
+ import type { NavItem, ThemeSettings } from '../types'
14
+
15
+ const props = withDefaults(defineProps<{
16
+ theme?: ThemeSettings
17
+ items?: NavItem[]
18
+ brand?: string
19
+ logo?: string
20
+ }>(), { theme: () => ({}), items: () => [] })
21
+
22
+ const folded = defineModel<boolean>('folded', { default: false })
23
+
24
+ const top = computed(() => props.theme.nav === 'top')
25
+ const boxed = computed(() => props.theme.container === 'boxed')
26
+ const foldable = computed(() => !top.value && props.theme.navFoldable === true)
27
+ const container = computed(() => boxed.value ? 'container-xl' : 'container-fluid')
28
+
29
+ const menuOpen = ref(false)
30
+ const route = useRoute()
31
+ watch(() => route.fullPath, () => { menuOpen.value = false })
32
+ </script>
33
+
34
+ <template>
35
+ <div :class="['t-app', { 'layout-boxed': boxed }]">
36
+ <div class="page">
37
+ <aside v-if="!top" :class="['navbar navbar-vertical navbar-expand-lg t-app-sidebar', { 'navbar-folded': foldable && folded }]">
38
+ <div class="container-fluid">
39
+ <button type="button" class="navbar-toggler" :aria-expanded="menuOpen" aria-label="Menu" @click="menuOpen = !menuOpen">
40
+ <span class="navbar-toggler-icon" />
41
+ </button>
42
+ <div class="navbar-brand">
43
+ <slot name="brand" :folded="foldable && folded">
44
+ <img v-if="logo" :src="logo" alt="" class="t-app-logo">
45
+ <span v-if="brand && !(foldable && folded)" class="text-truncate">{{ brand }}</span>
46
+ </slot>
47
+ </div>
48
+ <button v-if="foldable" type="button" class="t-fold-toggle d-none d-lg-grid" :aria-label="folded ? 'Expand the menu' : 'Fold the menu'"
49
+ @click="folded = !folded">
50
+ <TIcon :name="folded ? 'chevron-right' : 'chevron-left'" />
51
+ </button>
52
+ <div :class="['collapse navbar-collapse', { show: menuOpen }]">
53
+ <slot name="nav" orientation="vertical" :folded="foldable && folded">
54
+ <TNav :items="items" :folded="foldable && folded" class="pt-lg-3" />
55
+ </slot>
56
+ <div v-if="$slots.actions" class="navbar-footer"><slot name="actions" /></div>
57
+ </div>
58
+ </div>
59
+ </aside>
60
+ <header v-else :class="['navbar navbar-expand-md t-app-topbar', { 'sticky-top': theme.navSticky, 't-app-floating': theme.navFloating }]">
61
+ <div :class="[container, 'gap-3']">
62
+ <button type="button" class="navbar-toggler" :aria-expanded="menuOpen" aria-label="Menu" @click="menuOpen = !menuOpen">
63
+ <span class="navbar-toggler-icon" />
64
+ </button>
65
+ <div class="navbar-brand">
66
+ <slot name="brand" :folded="false">
67
+ <img v-if="logo" :src="logo" alt="" class="t-app-logo">
68
+ <span v-if="brand" class="text-truncate">{{ brand }}</span>
69
+ </slot>
70
+ </div>
71
+ <div :class="['collapse navbar-collapse', { show: menuOpen }]">
72
+ <slot name="nav" orientation="horizontal" :folded="false">
73
+ <TNav :items="items" />
74
+ </slot>
75
+ </div>
76
+ <div v-if="$slots.actions" class="ms-auto d-flex align-items-center gap-2"><slot name="actions" /></div>
77
+ </div>
78
+ </header>
79
+ <div class="page-wrapper">
80
+ <div class="page-body">
81
+ <div :class="container">
82
+ <slot />
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ // Whether an application's page sits in a box, centered on wide screens with the background
3
+ // around it, or fills the width. Each tile is a sketch of the page.
4
+ import TRadioGroup from './TRadioGroup.vue'
5
+ import { themeContainers } from '../theme'
6
+ import type { ThemeContainer } from '../types'
7
+
8
+ defineProps<{ disabled?: boolean; legend?: string }>()
9
+
10
+ const model = defineModel<ThemeContainer | null | undefined>()
11
+ </script>
12
+
13
+ <template>
14
+ <TRadioGroup v-model="model" :items="themeContainers" variant="tiles" tile-width="8rem" :disabled="disabled" :legend="legend">
15
+ <template #preview="{ item }">
16
+ <span :class="['t-sketch t-sketch-left', { 't-sketch-boxed': item.value === 'boxed' }]">
17
+ <span class="t-sketch-nav" />
18
+ <span class="t-sketch-page"><span /><span /><span /></span>
19
+ </span>
20
+ </template>
21
+ </TRadioGroup>
22
+ </template>
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ // How much room an application's content gets: padding inside cards, tables, buttons and fields,
3
+ // and the gaps between them. Each tile shows rows at that spacing.
4
+ import TRadioGroup from './TRadioGroup.vue'
5
+ import { themeDensities } from '../theme'
6
+ import type { ThemeDensity } from '../types'
7
+
8
+ defineProps<{ disabled?: boolean; legend?: string }>()
9
+
10
+ const model = defineModel<ThemeDensity | null | undefined>()
11
+ </script>
12
+
13
+ <template>
14
+ <TRadioGroup v-model="model" :items="themeDensities" variant="tiles" tile-width="8rem" :disabled="disabled" :legend="legend">
15
+ <template #preview="{ item }">
16
+ <span :class="['t-sketch-rows', `t-sketch-${item.value}`]"><span /><span /><span /><span /></span>
17
+ </template>
18
+ </TRadioGroup>
19
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ // Where an application's navigation goes: down the left side or across the top. Each tile is a
3
+ // sketch of the page.
4
+ import TRadioGroup from './TRadioGroup.vue'
5
+ import { themeNavs } from '../theme'
6
+ import type { ThemeNav } from '../types'
7
+
8
+ defineProps<{ disabled?: boolean; legend?: string }>()
9
+
10
+ const model = defineModel<ThemeNav | null | undefined>()
11
+ </script>
12
+
13
+ <template>
14
+ <TRadioGroup v-model="model" :items="themeNavs" variant="tiles" tile-width="8rem" :disabled="disabled" :legend="legend">
15
+ <template #preview="{ item }">
16
+ <span :class="['t-sketch', item.value === 'top' ? 't-sketch-top' : 't-sketch-left']">
17
+ <span class="t-sketch-nav" />
18
+ <span class="t-sketch-page"><span /><span /><span /></span>
19
+ </span>
20
+ </template>
21
+ </TRadioGroup>
22
+ </template>
@@ -0,0 +1,36 @@
1
+ <script setup lang="ts">
2
+ // Shows its content at a screen's width (`width`, in pixels), scaled down to fit: a preview of a
3
+ // whole page, such as an application's layout, in a smaller space. It fills its parent's height;
4
+ // the content scrolls inside it, and fixed or sticky parts stay inside the frame.
5
+ import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
6
+
7
+ const props = withDefaults(defineProps<{ width?: number }>(), { width: 1440 })
8
+
9
+ const frame = ref<HTMLElement>()
10
+ const size = ref({ width: 0, height: 0 })
11
+ let observer: ResizeObserver | undefined
12
+
13
+ onMounted(() => {
14
+ observer = new ResizeObserver(([entry]) => { size.value = { width: entry.contentRect.width, height: entry.contentRect.height } })
15
+ observer.observe(frame.value!)
16
+ })
17
+ onBeforeUnmount(() => observer?.disconnect())
18
+
19
+ // Never larger than life.
20
+ const scale = computed(() => size.value.width ? Math.min(1, size.value.width / props.width) : 1)
21
+ const screen = computed(() => ({
22
+ width: `${props.width}px`,
23
+ height: `${size.value.height / scale.value}px`,
24
+ transform: `scale(${scale.value})`
25
+ }))
26
+ </script>
27
+
28
+ <template>
29
+ <div ref="frame" class="t-scaled-frame">
30
+ <div class="t-scaled-screen" :style="screen">
31
+ <div class="t-scaled-scroll">
32
+ <slot :scale="scale" />
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </template>
@@ -0,0 +1,73 @@
1
+ <script setup lang="ts" generic="T extends object">
2
+ // A tree whose items can be dragged into a new order, and into or out of each other, with
3
+ // SortableJS: a menu of pages and sub-pages, say. v-model is the top level; each item keeps its
4
+ // children in `childrenKey` ("children"). The `item` slot draws an item's row (it gets the item,
5
+ // its depth from 1, and its parent). `maxDepth` limits how deep the tree goes (2: items and their
6
+ // children); a drop that would go deeper is refused. With `handle`, rows drag only by an element
7
+ // with the `sortable-handle` class. `move` reports each move. SortableJS loads on first use.
8
+ import { provide, ref, useId } from 'vue'
9
+ import TSortableTreeList from './TSortableTreeList.vue'
10
+ import { treeKey, type TreeContext } from './sortableTree'
11
+
12
+ const props = withDefaults(defineProps<{
13
+ itemKey: string | ((item: T) => string | number)
14
+ childrenKey?: string
15
+ maxDepth?: number
16
+ handle?: boolean
17
+ disabled?: boolean
18
+ }>(), { childrenKey: 'children', maxDepth: 2 })
19
+
20
+ const model = defineModel<T[]>({ default: () => [] })
21
+ const emit = defineEmits<{ move: [move: { item: T; from: { parent: T | null; index: number }; to: { parent: T | null; index: number } }] }>()
22
+ const slots = defineSlots<{ item?(scope: { item: T; depth: number; parent: T | null }): unknown }>()
23
+ const dragging = ref(false)
24
+
25
+ const keyOf = (item: T) => String(typeof props.itemKey === 'function' ? props.itemKey(item) : (item as Record<string, unknown>)[props.itemKey])
26
+ const childrenOf = (item: T): T[] => ((item as Record<string, unknown>)[props.childrenKey] as T[] | undefined) ?? []
27
+
28
+ function find(key: string, items: T[] = model.value): T | null {
29
+ for (const item of items) {
30
+ if (keyOf(item) === key) return item
31
+ const found = find(key, childrenOf(item))
32
+ if (found) return found
33
+ }
34
+ return null
35
+ }
36
+
37
+ // The list a parent's children are in, made when it has none yet.
38
+ function listOf(parent: T | null): T[] {
39
+ if (!parent) return model.value
40
+ const record = parent as Record<string, unknown>
41
+ if (!Array.isArray(record[props.childrenKey])) record[props.childrenKey] = []
42
+ return record[props.childrenKey] as T[]
43
+ }
44
+
45
+ function move(fromKey: string, oldIndex: number, toKey: string, newIndex: number) {
46
+ const from = fromKey ? find(fromKey) : null
47
+ const to = toKey ? find(toKey) : null
48
+ const [item] = listOf(from).splice(oldIndex, 1)
49
+ if (!item) return
50
+ listOf(to).splice(newIndex, 0, item)
51
+ model.value = [...model.value]
52
+ emit('move', { item, from: { parent: from, index: oldIndex }, to: { parent: to, index: newIndex } })
53
+ }
54
+
55
+ const context: TreeContext<T> = {
56
+ group: useId(),
57
+ get handle() { return props.handle },
58
+ get disabled() { return props.disabled },
59
+ get maxDepth() { return props.maxDepth },
60
+ dragging,
61
+ keyOf,
62
+ childrenOf,
63
+ move,
64
+ render: scope => slots.item?.(scope as { item: T; depth: number; parent: T | null }) as ReturnType<TreeContext<T>['render']>
65
+ }
66
+ provide(treeKey, context as unknown as TreeContext<object>)
67
+ </script>
68
+
69
+ <template>
70
+ <div :class="['t-tree', { 't-tree-dragging': dragging, 't-sortable-handles': handle }]">
71
+ <TSortableTreeList :items="model" :parent="null" :depth="1" />
72
+ </div>
73
+ </template>
@@ -0,0 +1,60 @@
1
+ <script setup lang="ts">
2
+ // One level of a TSortableTree: its items, each with a list for its children under it (empty
3
+ // ones open up while something is dragged, to drop into). Not used on its own.
4
+ import { inject, onBeforeUnmount, onMounted, ref, watch, type FunctionalComponent } from 'vue'
5
+ import type Sortable from 'sortablejs'
6
+ import { treeKey, type TreeItemScope } from './sortableTree'
7
+
8
+ defineOptions({ name: 'TSortableTreeList' })
9
+
10
+ const props = defineProps<{ items: object[]; parent: object | null; depth: number }>()
11
+ const tree = inject(treeKey)!
12
+
13
+ const list = ref<HTMLElement>()
14
+ let sortable: Sortable | null = null
15
+
16
+ // An item's height: 1, plus its deepest child's.
17
+ const heightOf = (item: object): number => 1 + Math.max(0, ...tree.childrenOf(item).map(heightOf))
18
+
19
+ const Row: FunctionalComponent<TreeItemScope<object>> = scope => tree.render(scope)
20
+
21
+ onMounted(async () => {
22
+ const SortableClass = (await import('sortablejs')).default
23
+ if (!list.value) return
24
+ sortable = new SortableClass(list.value, {
25
+ group: tree.group,
26
+ animation: 150,
27
+ draggable: '.t-tree-node',
28
+ handle: tree.handle ? '.sortable-handle' : undefined,
29
+ disabled: tree.disabled,
30
+ // SortableJS's own dragging (not the browser's): the same in every browser and on touch screens.
31
+ forceFallback: true,
32
+ fallbackOnBody: true,
33
+ swapThreshold: 0.65,
34
+ onStart: () => { tree.dragging.value = true },
35
+ // A drop may not take the item's deepest child past the tree's depth.
36
+ onMove: event => Number(event.to.dataset.depth) - 1 + Number(event.dragged.dataset.height) <= tree.maxDepth,
37
+ onEnd: ({ oldIndex, newIndex, item, from, to }) => {
38
+ tree.dragging.value = false
39
+ if (oldIndex == null || newIndex == null || (from === to && oldIndex === newIndex)) return
40
+ // SortableJS moved the element; put it back and let Vue move it, so the lists stay right.
41
+ to.removeChild(item)
42
+ from.insertBefore(item, from.children[oldIndex] ?? null)
43
+ tree.move(from.dataset.parent ?? '', oldIndex, to.dataset.parent ?? '', newIndex)
44
+ }
45
+ })
46
+ })
47
+
48
+ watch(() => tree.disabled, disabled => sortable?.option('disabled', !!disabled))
49
+ onBeforeUnmount(() => sortable?.destroy())
50
+ </script>
51
+
52
+ <template>
53
+ <div ref="list" :class="['t-tree-list', { 't-tree-children': depth > 1, 't-tree-empty': !items.length }]"
54
+ :data-parent="parent ? tree.keyOf(parent) : ''" :data-depth="depth">
55
+ <div v-for="item in items" :key="tree.keyOf(item)" class="t-tree-node" :data-height="heightOf(item)">
56
+ <Row :item="item" :depth="depth" :parent="parent" />
57
+ <TSortableTreeList v-if="depth < tree.maxDepth" :items="tree.childrenOf(item)" :parent="item" :depth="depth + 1" />
58
+ </div>
59
+ </div>
60
+ </template>
@@ -1,22 +1,23 @@
1
- <script setup lang="ts">
2
- // Tabler's theme settings for part of a page: what's inside takes the theme's accent color, font,
3
- // base grays, corner radius and light or dark mode, whatever the page around it uses. For previews
4
- // of an application's theme. A custom accent (#rrggbb) is set as the primary color directly.
5
- import { computed } from 'vue'
6
- import { useColorMode } from '../composables/useColorMode'
7
- import { isCustomAccent } from '../theme'
8
- import type { ThemeSettings } from '../types'
9
-
10
- const props = defineProps<{ theme: ThemeSettings }>()
11
- const { resolved } = useColorMode()
12
-
13
- const custom = computed(() => isCustomAccent(props.theme.accent))
14
- </script>
15
-
16
- <template>
17
- <div class="t-theme-scope" :data-bs-theme="theme.mode ?? resolved" :data-bs-theme-base="theme.base"
18
- :data-bs-theme-font="theme.font" :data-bs-theme-radius="theme.radius"
19
- :data-bs-theme-primary="custom ? undefined : theme.accent" :style="custom ? { '--tblr-primary': theme.accent } : undefined">
20
- <slot />
21
- </div>
22
- </template>
1
+ <script setup lang="ts">
2
+ // Tabler's theme settings for part of a page: what's inside takes the theme's accent color, font,
3
+ // base grays, corner radius, density and light or dark mode, whatever the page around it uses. For
4
+ // previews of an application's theme. A custom accent (#rrggbb) is set as the primary color
5
+ // directly. Layout (navigation, container) is TAppLayout's.
6
+ import { computed } from 'vue'
7
+ import { useColorMode } from '../composables/useColorMode'
8
+ import { isCustomAccent } from '../theme'
9
+ import type { ThemeSettings } from '../types'
10
+
11
+ const props = defineProps<{ theme: ThemeSettings }>()
12
+ const { resolved } = useColorMode()
13
+
14
+ const custom = computed(() => isCustomAccent(props.theme.accent))
15
+ </script>
16
+
17
+ <template>
18
+ <div class="t-theme-scope" :data-bs-theme="theme.mode ?? resolved" :data-bs-theme-base="theme.base"
19
+ :data-bs-theme-font="theme.font" :data-bs-theme-radius="theme.radius" :data-t-density="theme.density"
20
+ :data-bs-theme-primary="custom ? undefined : theme.accent" :style="custom ? { '--tblr-primary': theme.accent } : undefined">
21
+ <slot />
22
+ </div>
23
+ </template>
@@ -0,0 +1,19 @@
1
+ // What TSortableTree shares with its lists (TSortableTreeList), one per level.
2
+ import type { InjectionKey, Ref, VNode } from 'vue'
3
+
4
+ export interface TreeItemScope<T> { item: T; depth: number; parent: T | null }
5
+
6
+ export interface TreeContext<T> {
7
+ // The SortableJS group: items move between this tree's lists, and no other's.
8
+ group: string
9
+ handle?: boolean
10
+ disabled?: boolean
11
+ maxDepth: number
12
+ dragging: Ref<boolean>
13
+ keyOf(item: T): string
14
+ childrenOf(item: T): T[]
15
+ move(fromKey: string, oldIndex: number, toKey: string, newIndex: number): void
16
+ render(scope: TreeItemScope<T>): VNode[] | undefined
17
+ }
18
+
19
+ export const treeKey: InjectionKey<TreeContext<object>> = Symbol('t-sortable-tree')
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import type { App } from 'vue'
7
7
  import TAccentPicker from './components/TAccentPicker.vue'
8
8
  import TAdvancedTable from './components/TAdvancedTable.vue'
9
9
  import TAlert from './components/TAlert.vue'
10
+ import TAppLayout from './components/TAppLayout.vue'
10
11
  import TAuthLayout from './components/TAuthLayout.vue'
11
12
  import TAvatar from './components/TAvatar.vue'
12
13
  import TBadge from './components/TBadge.vue'
@@ -15,7 +16,9 @@ import TCard from './components/TCard.vue'
15
16
  import TCheckbox from './components/TCheckbox.vue'
16
17
  import TColorModeButton from './components/TColorModeButton.vue'
17
18
  import TCommandPalette from './components/TCommandPalette.vue'
19
+ import TContainerPicker from './components/TContainerPicker.vue'
18
20
  import TCopyButton from './components/TCopyButton.vue'
21
+ import TDensityPicker from './components/TDensityPicker.vue'
19
22
  import TDropdown from './components/TDropdown.vue'
20
23
  import TEmpty from './components/TEmpty.vue'
21
24
  import TFieldGroup from './components/TFieldGroup.vue'
@@ -30,12 +33,14 @@ import TInputTags from './components/TInputTags.vue'
30
33
  import TLogView from './components/TLogView.vue'
31
34
  import TModal from './components/TModal.vue'
32
35
  import TNav from './components/TNav.vue'
36
+ import TNavPositionPicker from './components/TNavPositionPicker.vue'
33
37
  import TPage from './components/TPage.vue'
34
38
  import TPagination from './components/TPagination.vue'
35
39
  import TPanelList from './components/TPanelList.vue'
36
40
  import TProgress from './components/TProgress.vue'
37
41
  import TRadioGroup from './components/TRadioGroup.vue'
38
42
  import TRadiusPicker from './components/TRadiusPicker.vue'
43
+ import TScaledFrame from './components/TScaledFrame.vue'
39
44
  import TSearchButton from './components/TSearchButton.vue'
40
45
  import TSectionLayout from './components/TSectionLayout.vue'
41
46
  import TSelect from './components/TSelect.vue'
@@ -63,6 +68,7 @@ export {
63
68
  TAccentPicker,
64
69
  TAdvancedTable,
65
70
  TAlert,
71
+ TAppLayout,
66
72
  TAuthLayout,
67
73
  TAvatar,
68
74
  TBadge,
@@ -71,7 +77,9 @@ export {
71
77
  TCheckbox,
72
78
  TColorModeButton,
73
79
  TCommandPalette,
80
+ TContainerPicker,
74
81
  TCopyButton,
82
+ TDensityPicker,
75
83
  TDropdown,
76
84
  TEmpty,
77
85
  TFieldGroup,
@@ -86,12 +94,14 @@ export {
86
94
  TLogView,
87
95
  TModal,
88
96
  TNav,
97
+ TNavPositionPicker,
89
98
  TPage,
90
99
  TPagination,
91
100
  TPanelList,
92
101
  TProgress,
93
102
  TRadioGroup,
94
103
  TRadiusPicker,
104
+ TScaledFrame,
95
105
  TSearchButton,
96
106
  TSectionLayout,
97
107
  TSelect,
@@ -117,20 +127,21 @@ export {
117
127
  }
118
128
 
119
129
  export * from './types'
120
- export { isCustomAccent, themeAccents, themeBases, themeFonts, themeRadii } from './theme'
130
+ export { isCustomAccent, themeAccents, themeBases, themeContainers, themeDensities, themeFonts, themeNavs, themeRadii } from './theme'
121
131
  export { useColorMode, type ColorMode } from './composables/useColorMode'
122
132
  export { useCommandPalette } from './composables/useCommandPalette'
123
133
  export { useField } from './composables/useField'
124
134
  export { useToast, type Toast } from './composables/useToast'
125
135
 
126
136
  const components = {
127
- TAccentPicker, TAdvancedTable, TAlert, TAuthLayout, TAvatar, TBadge, TButton, TCard, TCheckbox,
128
- TColorModeButton, TCommandPalette, TCopyButton, TDropdown, TEmpty, TFieldGroup, TFileUpload,
129
- TFontPicker, TFormField, TIcon, TImageUpload, TInput, TInputNumber, TInputTags, TLogView, TModal,
130
- TNav, TPage, TPagination, TPanelList, TProgress, TRadioGroup, TRadiusPicker, TSearchButton,
131
- TSectionLayout, TSelect, TSelectMenu, TSeparator, TShell, TSkeleton, TSlideover, TSpinner,
132
- TSplitter, TStatCard, TSteps, TSwitch, TTable, TTabs, TTextarea, TThemeBasePicker, TThemeScope,
133
- TToaster, TTooltip, TTopbar, TVectorMap
137
+ TAccentPicker, TAdvancedTable, TAlert, TAppLayout, TAuthLayout, TAvatar, TBadge, TButton, TCard,
138
+ TCheckbox, TColorModeButton, TCommandPalette, TContainerPicker, TCopyButton, TDensityPicker,
139
+ TDropdown, TEmpty, TFieldGroup, TFileUpload, TFontPicker, TFormField, TIcon, TImageUpload,
140
+ TInput, TInputNumber, TInputTags, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
141
+ TPanelList, TProgress, TRadioGroup, TRadiusPicker, TScaledFrame, TSearchButton, TSectionLayout,
142
+ TSelect, TSelectMenu, TSeparator, TShell, TSkeleton, TSlideover, TSpinner, TSplitter, TStatCard,
143
+ TSteps, TSwitch, TTable, TTabs, TTextarea, TThemeBasePicker, TThemeScope, TToaster, TTooltip,
144
+ TTopbar, TVectorMap
134
145
  }
135
146
 
136
147
  export default {
@@ -144,6 +155,7 @@ declare module 'vue' {
144
155
  TAccentPicker: typeof TAccentPicker
145
156
  TAdvancedTable: typeof TAdvancedTable
146
157
  TAlert: typeof TAlert
158
+ TAppLayout: typeof TAppLayout
147
159
  TAuthLayout: typeof TAuthLayout
148
160
  TAvatar: typeof TAvatar
149
161
  TBadge: typeof TBadge
@@ -152,7 +164,9 @@ declare module 'vue' {
152
164
  TCheckbox: typeof TCheckbox
153
165
  TColorModeButton: typeof TColorModeButton
154
166
  TCommandPalette: typeof TCommandPalette
167
+ TContainerPicker: typeof TContainerPicker
155
168
  TCopyButton: typeof TCopyButton
169
+ TDensityPicker: typeof TDensityPicker
156
170
  TDropdown: typeof TDropdown
157
171
  TEmpty: typeof TEmpty
158
172
  TFieldGroup: typeof TFieldGroup
@@ -167,12 +181,14 @@ declare module 'vue' {
167
181
  TLogView: typeof TLogView
168
182
  TModal: typeof TModal
169
183
  TNav: typeof TNav
184
+ TNavPositionPicker: typeof TNavPositionPicker
170
185
  TPage: typeof TPage
171
186
  TPagination: typeof TPagination
172
187
  TPanelList: typeof TPanelList
173
188
  TProgress: typeof TProgress
174
189
  TRadioGroup: typeof TRadioGroup
175
190
  TRadiusPicker: typeof TRadiusPicker
191
+ TScaledFrame: typeof TScaledFrame
176
192
  TSearchButton: typeof TSearchButton
177
193
  TSectionLayout: typeof TSectionLayout
178
194
  TSelect: typeof TSelect
@@ -10,6 +10,7 @@ import TInputMask from '../components/TInputMask.vue'
10
10
  import TRangeSlider from '../components/TRangeSlider.vue'
11
11
  import TRichEditor from '../components/TRichEditor.vue'
12
12
  import TSortable from '../components/TSortable.vue'
13
+ import TSortableTree from '../components/TSortableTree.vue'
13
14
 
14
15
  export {
15
16
  TAdvancedSelect,
@@ -19,14 +20,15 @@ export {
19
20
  TInputMask,
20
21
  TRangeSlider,
21
22
  TRichEditor,
22
- TSortable
23
+ TSortable,
24
+ TSortableTree
23
25
  }
24
26
 
25
27
  export type { RichEditorPlugin } from './richEditor'
26
28
 
27
29
  const components = {
28
30
  TAdvancedSelect, TColorPicker, TDatePicker, TDropzone, TInputMask, TRangeSlider, TRichEditor,
29
- TSortable
31
+ TSortable, TSortableTree
30
32
  }
31
33
 
32
34
  export const GearsUIPlugins = {
@@ -45,5 +47,6 @@ declare module 'vue' {
45
47
  TRangeSlider: typeof TRangeSlider
46
48
  TRichEditor: typeof TRichEditor
47
49
  TSortable: typeof TSortable
50
+ TSortableTree: typeof TSortableTree
48
51
  }
49
52
  }
@@ -64,7 +64,8 @@
64
64
  .ti-spin { animation: t-spin 1s linear infinite; }
65
65
  @keyframes t-spin { to { transform: rotate(360deg); } }
66
66
 
67
- /* The sidebar's fold toggle: a small black circle with a light grey outline, on the sidebar's edge. */
67
+ /* The sidebar's fold toggle: a small circle on the sidebar's edge, in the sidebar's colors (its
68
+ background, its border, and its menu icons' color), so it suits a dark sidebar or a light one. */
68
69
  .t-fold-toggle {
69
70
  position: absolute;
70
71
  top: 1.375rem;
@@ -74,13 +75,13 @@
74
75
  width: 24px;
75
76
  height: 24px;
76
77
  padding: 0;
77
- color: #fff;
78
- background: #1c1d1d;
79
- border: 1px solid var(--tblr-navbar-border-color, #2f3232);
78
+ color: color-mix(in oklab, var(--tblr-navbar-color, var(--tblr-body-color)) 70%, transparent);
79
+ background: var(--tblr-navbar-bg, var(--tblr-bg-surface));
80
+ border: 1px solid var(--tblr-navbar-border-color, var(--tblr-border-color));
80
81
  border-radius: 50%;
81
82
  cursor: pointer;
82
83
  }
83
- .t-fold-toggle:hover { border-color: #5d6470; }
84
+ .t-fold-toggle:hover { color: var(--tblr-navbar-hover-color, var(--tblr-body-color)); border-color: color-mix(in oklab, var(--tblr-navbar-color, var(--tblr-body-color)) 45%, transparent); }
84
85
  .t-fold-toggle:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: 2px; }
85
86
  .t-fold-toggle .ti { font-size: 14px; width: 14px; height: 14px; line-height: 14px; vertical-align: 0; }
86
87
 
@@ -558,3 +559,67 @@
558
559
  border-radius: var(--tblr-border-radius);
559
560
  }
560
561
  .t-image-upload-preview img { width: 100%; height: 100%; object-fit: contain; }
562
+
563
+ /* Density (TThemeScope's theme.density, or data-t-density on any element): the padding inside
564
+ cards, tables, buttons and fields, and the page's gaps (--t-gap, for layouts to use).
565
+ Comfortable is Tabler's own spacing. */
566
+ [data-t-density] { --t-gap: 1rem; }
567
+ [data-t-density=compact] { --t-gap: 0.625rem; --tblr-page-padding-y: 0.75rem; }
568
+ [data-t-density=spacious] { --t-gap: 1.5rem; --tblr-page-padding-y: 2rem; }
569
+ [data-t-density=compact] .card { --tblr-card-spacer-y: 0.75rem; --tblr-card-spacer-x: 0.875rem; --tblr-card-cap-padding-y: 0.625rem; --tblr-card-cap-padding-x: 0.875rem; --tblr-card-title-spacer-y: 0.625rem; }
570
+ [data-t-density=spacious] .card { --tblr-card-spacer-y: 1.75rem; --tblr-card-spacer-x: 1.75rem; --tblr-card-cap-padding-y: 1.5rem; --tblr-card-cap-padding-x: 1.75rem; --tblr-card-title-spacer-y: 1.5rem; }
571
+ [data-t-density=compact] .table:not(.table-sm) > :not(caption) > * > * { padding: 0.375rem 0.625rem; }
572
+ [data-t-density=spacious] .table:not(.table-sm) > :not(caption) > * > * { padding: 1rem 1.25rem; }
573
+ [data-t-density=compact] .btn:not(.btn-sm, .btn-lg, .btn-xs, .btn-icon) { --tblr-btn-padding-y: 0.3125rem; --tblr-btn-padding-x: 0.75rem; }
574
+ [data-t-density=spacious] .btn:not(.btn-sm, .btn-lg, .btn-xs, .btn-icon) { --tblr-btn-padding-y: 0.75rem; --tblr-btn-padding-x: 1.375rem; }
575
+ [data-t-density=compact] :is(.form-control, .form-select):not(.form-control-sm, .form-select-sm, .form-control-lg, .form-select-lg) { --tblr-control-padding-y: 0.3125rem; --tblr-control-padding-x: 0.625rem; }
576
+ [data-t-density=spacious] :is(.form-control, .form-select):not(.form-control-sm, .form-select-sm, .form-control-lg, .form-select-lg) { --tblr-control-padding-y: 0.75rem; --tblr-control-padding-x: 1.125rem; }
577
+ [data-t-density=compact] .navbar-vertical .nav-link { padding-block: 0.3125rem; }
578
+ [data-t-density=spacious] .navbar-vertical .nav-link { padding-block: 0.75rem; }
579
+
580
+ /* Layout sketches (TNavPositionPicker, TContainerPicker, TDensityPicker): a page drawn in a tile. */
581
+ .t-sketch { display: flex; gap: 3px; width: 5.5rem; height: 3.5rem; padding: 3px; border-radius: 4px; }
582
+ .t-sketch-top { flex-direction: column; }
583
+ .t-sketch-nav { flex-shrink: 0; border-radius: 2px; background: color-mix(in oklab, var(--tblr-body-color) 35%, transparent); }
584
+ .t-sketch-left .t-sketch-nav { width: 0.875rem; }
585
+ .t-sketch-top .t-sketch-nav { height: 0.5rem; }
586
+ .t-sketch-page { display: flex; flex: 1; flex-direction: column; gap: 3px; padding: 3px; border-radius: 2px; background: var(--tblr-bg-surface); }
587
+ .t-sketch-page span { height: 0.375rem; border-radius: 1px; background: color-mix(in oklab, var(--tblr-body-color) 15%, transparent); }
588
+ .t-sketch-page span:first-child { width: 60%; background: var(--tblr-primary); opacity: 0.7; }
589
+ .t-sketch-boxed { padding: 3px 0.75rem; background: color-mix(in oklab, var(--tblr-body-color) 18%, transparent); }
590
+ .t-sketch-rows { display: flex; flex-direction: column; justify-content: center; width: 5.5rem; height: 3.5rem; }
591
+ .t-sketch-rows span { height: 0.3125rem; border-radius: 1px; background: color-mix(in oklab, var(--tblr-body-color) 25%, transparent); }
592
+ .t-sketch-compact { gap: 2px; }
593
+ .t-sketch-comfortable { gap: 5px; }
594
+ .t-sketch-spacious { gap: 9px; }
595
+ .t-sketch-rows span:first-child { background: var(--tblr-primary); opacity: 0.7; }
596
+
597
+ /* An application's frame (TAppLayout). The sidebar follows the theme (the Studio's is always
598
+ dark); a floating top bar sits apart from the page's edges, rounded, with a shadow. */
599
+ .t-app { min-height: 100%; display: flex; flex-direction: column; }
600
+ .t-app > .page { flex: 1; width: 100%; }
601
+ .t-app-logo { width: 2rem; height: 2rem; object-fit: contain; border-radius: var(--tblr-border-radius-sm); }
602
+ .t-app .navbar-brand { display: flex; align-items: center; gap: 0.5rem; min-width: 0; font-weight: var(--tblr-font-weight-bold); }
603
+ /* Tabler spreads a vertical navbar's brand across it; keep the name beside the logo. */
604
+ .t-app .t-app-sidebar.navbar-vertical .navbar-brand { justify-content: flex-start; }
605
+ .t-app-floating { margin: var(--t-gap, 1rem) var(--t-gap, 1rem) 0; border: var(--tblr-border-width) solid var(--tblr-border-color); border-radius: var(--tblr-border-radius-lg); box-shadow: var(--tblr-shadow-card, 0 4px 16px rgba(0, 0, 0, 0.08)); }
606
+ .t-app-floating.sticky-top { top: var(--t-gap, 1rem); }
607
+ .layout-boxed .t-app-floating { margin-inline: 0; }
608
+
609
+ /* A scaled frame (TScaledFrame): a whole screen, scaled down to fit. The screen is the containing
610
+ block for fixed parts, so a fixed sidebar stays in the frame. */
611
+ .t-scaled-frame { position: relative; height: 100%; min-height: 0; overflow: hidden; }
612
+ .t-scaled-screen { position: absolute; top: 0; left: 0; overflow: hidden; transform-origin: top left; }
613
+ .t-scaled-scroll { height: 100%; overflow: auto; }
614
+
615
+ /* A sortable tree (TSortableTree): children indented under their item. While something is dragged,
616
+ each empty child list opens to a dashed slot, to drop into. */
617
+ .t-tree-children { margin-inline-start: 1.75rem; }
618
+ .t-tree-dragging .t-tree-children.t-tree-empty {
619
+ min-height: 0.875rem;
620
+ margin-block: 2px;
621
+ border: 1px dashed color-mix(in oklab, var(--tblr-primary) 45%, var(--tblr-border-color));
622
+ border-radius: var(--tblr-border-radius-sm);
623
+ }
624
+ .t-tree .sortable-ghost { opacity: 0.4; }
625
+ .t-tree .sortable-chosen > :first-child { background: color-mix(in oklab, var(--tblr-primary) 6%, transparent); }
package/src/theme.ts CHANGED
@@ -1,6 +1,6 @@
1
- // The choices Tabler's theme settings offer (tabler-themes.css), with their labels, in the order its
2
- // own theme settings list them.
3
- import type { SelectItem, ThemeBase, ThemeFont, ThemeRadius } from './types'
1
+ // The choices an application's theme offers, with their labels: Tabler's theme settings
2
+ // (tabler-themes.css) in the order its own theme settings list them, then layout.
3
+ import type { SelectItem, ThemeBase, ThemeContainer, ThemeDensity, ThemeFont, ThemeNav, ThemeRadius } from './types'
4
4
 
5
5
  export const themeAccents = [
6
6
  'blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan'
@@ -24,5 +24,22 @@ export const themeBases: SelectItem<ThemeBase>[] = [
24
24
 
25
25
  export const themeRadii: SelectItem<ThemeRadius>[] = ['0', '0.5', '1', '1.5', '2'].map(r => ({ label: r, value: r as ThemeRadius }))
26
26
 
27
+ // Layout choices (not Tabler theme settings; TThemeScope and TAppLayout apply them).
28
+ export const themeNavs: SelectItem<ThemeNav>[] = [
29
+ { label: 'Left', value: 'left' },
30
+ { label: 'Top', value: 'top' }
31
+ ]
32
+
33
+ export const themeDensities: SelectItem<ThemeDensity>[] = [
34
+ { label: 'Compact', value: 'compact' },
35
+ { label: 'Comfortable', value: 'comfortable' },
36
+ { label: 'Spacious', value: 'spacious' }
37
+ ]
38
+
39
+ export const themeContainers: SelectItem<ThemeContainer>[] = [
40
+ { label: 'Boxed', value: 'boxed' },
41
+ { label: 'Fluid', value: 'fluid' }
42
+ ]
43
+
27
44
  /** Whether an accent is a custom color (#rrggbb) rather than one of Tabler's named colors. */
28
45
  export const isCustomAccent = (accent: string | undefined) => !!accent && accent.startsWith('#')
package/src/types.ts CHANGED
@@ -1,160 +1,177 @@
1
- // Shared prop types. Colors and sizes use the same names as Nuxt UI, so code moving from it keeps
2
- // its props; `toTabler` maps a color to the name Tabler's classes use.
3
-
4
- export type Color = 'primary' | 'neutral' | 'success' | 'warning' | 'error' | 'info'
5
- export type Size = 'xs' | 'sm' | 'md' | 'lg'
6
-
7
- const tablerColors: Record<Color, string> = {
8
- primary: 'primary',
9
- neutral: 'secondary',
10
- success: 'success',
11
- warning: 'warning',
12
- error: 'danger',
13
- info: 'info'
14
- }
15
-
16
- export function toTabler(color: Color): string {
17
- return tablerColors[color]
18
- }
19
-
20
- // A route location for RouterLink, or a plain URL.
21
- export type Target = string | Record<string, unknown>
22
-
23
- export interface DropdownItem {
24
- label?: string
25
- description?: string
26
- icon?: string
27
- trailingIcon?: string
28
- // `label` items are headings; they can't be chosen.
29
- type?: 'item' | 'label'
30
- color?: Color
31
- to?: Target
32
- href?: string
33
- disabled?: boolean
34
- onSelect?: (event: Event) => void
35
- }
36
-
37
- export interface NavItem {
38
- label: string
39
- icon?: string
40
- to?: Target
41
- // Active only on this exact route, not on routes under it.
42
- exact?: boolean
43
- badge?: string | { label: string; color?: Color }
44
- children?: NavItem[]
45
- defaultOpen?: boolean
46
- }
47
-
48
- export interface SelectItem<T = unknown> {
49
- label: string
50
- value: T
51
- description?: string
52
- disabled?: boolean
53
- // Items with the same group are listed together under it.
54
- group?: string
55
- }
56
-
57
- // An item of TAdvancedSelect: an icon or avatar initials can show beside the label.
58
- export interface AdvancedSelectItem<T = unknown> extends SelectItem<T> {
59
- icon?: string
60
- avatar?: string
61
- }
62
-
63
- export interface TabItem {
64
- label: string
65
- value: string
66
- icon?: string
67
- badge?: string | number
68
- disabled?: boolean
69
- }
70
-
71
- export interface TableColumn<Row = Record<string, unknown>> {
72
- key: string
73
- label?: string
74
- align?: 'start' | 'center' | 'end'
75
- width?: string
76
- sortable?: boolean
77
- // TAdvancedTable: whether the column has a filter (on unless false; columns without a label have none).
78
- filterable?: boolean
79
- // Shown when the cell has no slot; defaults to `row[key]`.
80
- value?: (row: Row) => unknown
81
- }
82
-
83
- export interface TableSort {
84
- key: string
85
- direction: 'asc' | 'desc'
86
- }
87
-
88
- // How a TAdvancedTable column filter compares a cell with its value.
89
- export type TableFilterOperator = 'equals' | 'notEquals' | 'contains' | 'greaterThan' | 'lessThan' | 'atLeast' | 'atMost'
90
-
91
- export interface TableFilter {
92
- operator: TableFilterOperator
93
- value: string
94
- }
95
-
96
- export interface StepItem {
97
- title: string
98
- description?: string
99
- }
100
-
101
- export interface LogLine {
102
- id?: string | number
103
- time?: string
104
- text: string
105
- level?: 'error' | 'warning' | 'highlight' | 'muted'
106
- }
107
-
108
- // A suggestion a TCodeEditor offers while typing.
109
- export interface CodeCompletion {
110
- label: string
111
- kind?: 'keyword' | 'table' | 'field' | 'function' | 'value' | 'snippet'
112
- // What's inserted; the label when omitted.
113
- insertText?: string
114
- detail?: string
115
- }
116
-
117
- export interface PanelListItem<T = string> {
118
- value: T
119
- label: string
120
- icon?: string
121
- // Small text at the item's end, such as a count or a tag.
122
- trailing?: string
123
- title?: string
124
- // Shown in red: something in it needs fixing.
125
- invalid?: boolean
126
- }
127
-
128
- // An item of TCommandPalette: a page to go to (`to`) or an action (`onSelect`).
129
- export interface CommandItem {
130
- label: string
131
- icon?: string
132
- // Shown after the label, smaller; searched too (a project's namespace, a page's section).
133
- suffix?: string
134
- // More words that find the item without being shown.
135
- keywords?: string[]
136
- to?: Target
137
- onSelect?: () => void
138
- }
139
-
140
- export interface CommandGroup {
141
- id: string
142
- label?: string
143
- items: CommandItem[]
144
- }
145
-
146
- // An application's theme, as Tabler's theme settings (the data-bs-theme-* attributes) take it.
147
- export type ThemeFont = 'sans-serif' | 'serif' | 'monospace' | 'comic'
148
- export type ThemeBase = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'mist'
149
- export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2'
150
- // Tabler's named colors, or a custom color as #rrggbb.
151
- export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'cyan' | (string & {})
152
-
153
- export interface ThemeSettings {
154
- accent?: ThemeAccent
155
- font?: ThemeFont
156
- base?: ThemeBase
157
- radius?: ThemeRadius
158
- // Light or dark; unset follows the surrounding page.
159
- mode?: 'light' | 'dark'
160
- }
1
+ // Shared prop types. Colors and sizes use the same names as Nuxt UI, so code moving from it keeps
2
+ // its props; `toTabler` maps a color to the name Tabler's classes use.
3
+
4
+ export type Color = 'primary' | 'neutral' | 'success' | 'warning' | 'error' | 'info'
5
+ export type Size = 'xs' | 'sm' | 'md' | 'lg'
6
+
7
+ const tablerColors: Record<Color, string> = {
8
+ primary: 'primary',
9
+ neutral: 'secondary',
10
+ success: 'success',
11
+ warning: 'warning',
12
+ error: 'danger',
13
+ info: 'info'
14
+ }
15
+
16
+ export function toTabler(color: Color): string {
17
+ return tablerColors[color]
18
+ }
19
+
20
+ // A route location for RouterLink, or a plain URL.
21
+ export type Target = string | Record<string, unknown>
22
+
23
+ export interface DropdownItem {
24
+ label?: string
25
+ description?: string
26
+ icon?: string
27
+ trailingIcon?: string
28
+ // `label` items are headings; they can't be chosen.
29
+ type?: 'item' | 'label'
30
+ color?: Color
31
+ to?: Target
32
+ href?: string
33
+ disabled?: boolean
34
+ onSelect?: (event: Event) => void
35
+ }
36
+
37
+ export interface NavItem {
38
+ label: string
39
+ icon?: string
40
+ to?: Target
41
+ // Active only on this exact route, not on routes under it.
42
+ exact?: boolean
43
+ badge?: string | { label: string; color?: Color }
44
+ children?: NavItem[]
45
+ defaultOpen?: boolean
46
+ }
47
+
48
+ export interface SelectItem<T = unknown> {
49
+ label: string
50
+ value: T
51
+ description?: string
52
+ disabled?: boolean
53
+ // Items with the same group are listed together under it.
54
+ group?: string
55
+ }
56
+
57
+ // An item of TAdvancedSelect: an icon or avatar initials can show beside the label.
58
+ export interface AdvancedSelectItem<T = unknown> extends SelectItem<T> {
59
+ icon?: string
60
+ avatar?: string
61
+ }
62
+
63
+ export interface TabItem {
64
+ label: string
65
+ value: string
66
+ icon?: string
67
+ badge?: string | number
68
+ disabled?: boolean
69
+ }
70
+
71
+ export interface TableColumn<Row = Record<string, unknown>> {
72
+ key: string
73
+ label?: string
74
+ align?: 'start' | 'center' | 'end'
75
+ width?: string
76
+ sortable?: boolean
77
+ // TAdvancedTable: whether the column has a filter (on unless false; columns without a label have none).
78
+ filterable?: boolean
79
+ // Shown when the cell has no slot; defaults to `row[key]`.
80
+ value?: (row: Row) => unknown
81
+ }
82
+
83
+ export interface TableSort {
84
+ key: string
85
+ direction: 'asc' | 'desc'
86
+ }
87
+
88
+ // How a TAdvancedTable column filter compares a cell with its value.
89
+ export type TableFilterOperator = 'equals' | 'notEquals' | 'contains' | 'greaterThan' | 'lessThan' | 'atLeast' | 'atMost'
90
+
91
+ export interface TableFilter {
92
+ operator: TableFilterOperator
93
+ value: string
94
+ }
95
+
96
+ export interface StepItem {
97
+ title: string
98
+ description?: string
99
+ }
100
+
101
+ export interface LogLine {
102
+ id?: string | number
103
+ time?: string
104
+ text: string
105
+ level?: 'error' | 'warning' | 'highlight' | 'muted'
106
+ }
107
+
108
+ // A suggestion a TCodeEditor offers while typing.
109
+ export interface CodeCompletion {
110
+ label: string
111
+ kind?: 'keyword' | 'table' | 'field' | 'function' | 'value' | 'snippet'
112
+ // What's inserted; the label when omitted.
113
+ insertText?: string
114
+ detail?: string
115
+ }
116
+
117
+ export interface PanelListItem<T = string> {
118
+ value: T
119
+ label: string
120
+ icon?: string
121
+ // Small text at the item's end, such as a count or a tag.
122
+ trailing?: string
123
+ title?: string
124
+ // Shown in red: something in it needs fixing.
125
+ invalid?: boolean
126
+ }
127
+
128
+ // An item of TCommandPalette: a page to go to (`to`) or an action (`onSelect`).
129
+ export interface CommandItem {
130
+ label: string
131
+ icon?: string
132
+ // Shown after the label, smaller; searched too (a project's namespace, a page's section).
133
+ suffix?: string
134
+ // More words that find the item without being shown.
135
+ keywords?: string[]
136
+ to?: Target
137
+ onSelect?: () => void
138
+ }
139
+
140
+ export interface CommandGroup {
141
+ id: string
142
+ label?: string
143
+ items: CommandItem[]
144
+ }
145
+
146
+ // An application's theme, as Tabler's theme settings (the data-bs-theme-* attributes) take it.
147
+ export type ThemeFont = 'sans-serif' | 'serif' | 'monospace' | 'comic'
148
+ export type ThemeBase = 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'mist'
149
+ export type ThemeRadius = '0' | '0.5' | '1' | '1.5' | '2'
150
+ // Tabler's named colors, or a custom color as #rrggbb.
151
+ export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow' | 'lime' | 'green' | 'teal' | 'cyan' | (string & {})
152
+
153
+ // An application's layout: where its navigation goes and how it behaves, how much room things
154
+ // get, and whether the page sits in a box.
155
+ export type ThemeNav = 'left' | 'top'
156
+ export type ThemeDensity = 'compact' | 'comfortable' | 'spacious'
157
+ export type ThemeContainer = 'boxed' | 'fluid'
158
+
159
+ export interface ThemeSettings {
160
+ accent?: ThemeAccent
161
+ font?: ThemeFont
162
+ base?: ThemeBase
163
+ radius?: ThemeRadius
164
+ // Light or dark; unset follows the surrounding page.
165
+ mode?: 'light' | 'dark'
166
+ // Padding and gaps (TThemeScope applies it).
167
+ density?: ThemeDensity
168
+ // The rest is layout (TAppLayout applies it).
169
+ nav?: ThemeNav
170
+ // Left navigation: whether it folds to icons.
171
+ navFoldable?: boolean
172
+ // Top navigation: whether it stays at the top while the page scrolls, and whether it floats
173
+ // apart from the page's edges.
174
+ navSticky?: boolean
175
+ navFloating?: boolean
176
+ container?: ThemeContainer
177
+ }