Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tree #976

Merged
merged 30 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
560562e
chore: wip
zernonia May 1, 2024
189317d
Merge remote-tracking branch 'origin/main' into draggable-sortable-tree
zernonia May 17, 2024
6a58198
Merge remote-tracking branch 'origin/main' into draggable-sortable-tree
zernonia May 28, 2024
674d002
chore: wip (very crude impl)
zernonia May 28, 2024
a8fce9c
chore: another crude wip
zernonia May 29, 2024
a8383fd
fix: improve typing
zernonia May 29, 2024
8948aa1
chore: move constants to shared
zernonia Jun 3, 2024
9ea531f
refactor: tree item, add virtualizer
zernonia Jun 3, 2024
3a0b7bd
refactor: roving focus to use new collection
zernonia Jun 4, 2024
77ad770
feat: virtualizer
zernonia Jun 4, 2024
f95dbf6
refactor: improve tree
zernonia Jun 5, 2024
3cf222f
fix: build
zernonia Jun 5, 2024
cbe69fd
fix: missing value for comboboxitem
zernonia Jun 5, 2024
f44da94
feat: export component, run docsgen
zernonia Jun 5, 2024
02ee9c5
docs: tree, demo
zernonia Jun 5, 2024
28bd410
docs: fix wrong demo
zernonia Jun 5, 2024
5d155f4
chore: expose more internal slot
zernonia Jun 6, 2024
a9f4ec6
test: add test for tree componetn
zernonia Jun 6, 2024
65c6ba0
fix: missing aria condition
zernonia Jun 6, 2024
d612e11
refactor: expose more function, cater for checkbox
zernonia Jun 11, 2024
6e72d0c
chore: add dnd example
zernonia Jun 12, 2024
8419dcd
chore: cleanup dnd, add stackblitz docs
zernonia Jun 12, 2024
48f38b0
docs: update sb link
zernonia Jun 12, 2024
ffe1fbe
Merge remote-tracking branch 'origin/1.9' into draggable-sortable-tree
zernonia Jun 29, 2024
30b8b84
chore: lint
zernonia Jun 29, 2024
2a56e89
chore: improve story styling
zernonia Jun 29, 2024
fdab116
feat: cater for async mode
zernonia Jun 29, 2024
7ab9639
chore: add story for nested dom case
zernonia Jul 1, 2024
43ef887
chore: update docs
zernonia Jul 1, 2024
50a7766
fix: direction
zernonia Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default defineConfig({
{ text: 'Toggle Group', link: '/components/toggle-group' },
{ text: 'Toolbar', link: '/components/toolbar' },
{ text: 'Tooltip', link: '/components/tooltip' },
{ text: `Tree ${BadgeHTML('Alpha')}`, link: '/components/tree' },
],
},
{
Expand Down
4 changes: 4 additions & 0 deletions docs/components/Demos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import ToggleDemo from './demo/Toggle/tailwind/index.vue'
import ToggleGroupDemo from './demo/ToggleGroup/tailwind/index.vue'
import ToolbarDemo from './demo/Toolbar/tailwind/index.vue'
import TooltipDemo from './demo/Tooltip/tailwind/index.vue'
import TreeDemo from './demo/Tree/tailwind/index.vue'

import DemoContainer from './DemoContainer.vue'
</script>
Expand Down Expand Up @@ -171,5 +172,8 @@ import DemoContainer from './DemoContainer.vue'
<DemoContainer title="tooltip">
<TooltipDemo />
</DemoContainer>
<DemoContainer title="tree">
<TreeDemo />
</DemoContainer>
</div>
</template>
8 changes: 4 additions & 4 deletions docs/components/demo/CalendarYearIncrement/css/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import { Icon } from '@iconify/vue'
import { CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNext, CalendarPrev, CalendarRoot, type CalendarRootProps } from 'radix-vue'
import './styles.css'
import type { DateValue } from '@internationalized/date';
import type { DateValue } from '@internationalized/date'

const isDateUnavailable: CalendarRootProps['isDateUnavailable'] = (date) => {
return date.day === 17 || date.day === 18
}

const pagingFunc = (date: DateValue, sign: -1 | 1) => {
function pagingFunc(date: DateValue, sign: -1 | 1) {
if (sign === -1)
return date.subtract({ years: 1})
return date.add({ years: 1})
return date.subtract({ years: 1 })
return date.add({ years: 1 })
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions docs/components/demo/CalendarYearIncrement/tailwind/index.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script setup lang="ts">
import { Icon } from '@iconify/vue'
import type { DateValue } from '@internationalized/date';
import type { DateValue } from '@internationalized/date'
import { CalendarCell, CalendarCellTrigger, CalendarGrid, CalendarGridBody, CalendarGridHead, CalendarGridRow, CalendarHeadCell, CalendarHeader, CalendarHeading, CalendarNext, CalendarPrev, CalendarRoot, type CalendarRootProps } from 'radix-vue'

const isDateUnavailable: CalendarRootProps['isDateUnavailable'] = (date) => {
return date.day === 17 || date.day === 18
}

const pagingFunc = (date: DateValue, sign: -1 | 1) => {
function pagingFunc(date: DateValue, sign: -1 | 1) {
if (sign === -1)
return date.subtract({ years: 1})
return date.add({ years: 1})
return date.subtract({ years: 1 })
return date.add({ years: 1 })
}
</script>

Expand Down
61 changes: 61 additions & 0 deletions docs/components/demo/Tree/css/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script setup lang="ts">
import { TreeItem, TreeRoot } from 'radix-vue'
import { Icon } from '@iconify/vue'

const items = [
{
title: 'composables',
icon: 'lucide:folder',
children: [
{ title: 'useAuth.ts', icon: 'vscode-icons:file-type-typescript' },
{ title: 'useUser.ts', icon: 'vscode-icons:file-type-typescript' },
],
},
{
title: 'components',
icon: 'lucide:folder',
children: [
{
title: 'Home',
icon: 'lucide:folder',
children: [
{ title: 'Card.vue', icon: 'vscode-icons:file-type-vue' },
{ title: 'Button.vue', icon: 'vscode-icons:file-type-vue' },
],
},
],
},
{ title: 'app.vue', icon: 'vscode-icons:file-type-vue' },
{ title: 'nuxt.config.ts', icon: 'vscode-icons:file-type-nuxt' },
]
</script>

<template>
<TreeRoot
v-slot="{ flattenItems }"
class="list-none select-none w-56 bg-white text-blackA11 rounded-lg p-2 text-sm font-medium" :items="items"
:get-key="(item) => item.title"
:default-expanded="['components']"
>
<h2 class="font-semibold !text-base text-blackA11 px-2 pt-1">
Directory Structure
</h2>
<TreeItem
v-for="item in flattenItems"
v-slot="{ isExpanded }"
:key="item._id"
:style="{ 'padding-left': `${item.level + 0.5}rem` }"
v-bind="item.bind"
class="flex items-center py-1 px-2 my-0.5 rounded outline-none focus:ring-grass8 focus:ring-2 data-[selected]:bg-grass4"
>
<template v-if="item.hasChildren">
<Icon v-if="!isExpanded" icon="lucide:folder" class="h-4 w-4" />
<Icon v-else icon="lucide:folder-open" class="h-4 w-4" />
</template>
<Icon v-else :icon="item.value.icon || 'lucide:file'" class="h-4 w-4" />
<div class="pl-2">
{{ item.value.title }}
</div>
</TreeItem>
</TreeRoot>
</template>
74 changes: 74 additions & 0 deletions docs/components/demo/Tree/tailwind/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script setup lang="ts">
import { TreeItem, TreeRoot } from 'radix-vue'
import { Icon } from '@iconify/vue'

const items = [
{
title: 'composables',
icon: 'lucide:folder',
children: [
{ title: 'useAuth.ts', icon: 'vscode-icons:file-type-typescript' },
{ title: 'useUser.ts', icon: 'vscode-icons:file-type-typescript' },
],
},
{
title: 'components',
icon: 'lucide:folder',
children: [
{
title: 'Home',
icon: 'lucide:folder',
children: [
{ title: 'Card.vue', icon: 'vscode-icons:file-type-vue' },
{ title: 'Button.vue', icon: 'vscode-icons:file-type-vue' },
],
},
],
},
{ title: 'app.vue', icon: 'vscode-icons:file-type-vue' },
{ title: 'nuxt.config.ts', icon: 'vscode-icons:file-type-nuxt' },
]
</script>

<template>
<TreeRoot
v-slot="{ flattenItems }"
class="list-none select-none w-56 bg-white text-blackA11 rounded-lg p-2 text-sm font-medium"
:items="items"
:get-key="(item) => item.title"
:default-expanded="['components']"
>
<h2 class="font-semibold !text-base text-blackA11 px-2 pt-1">
Directory Structure
</h2>
<TreeItem
v-for="item in flattenItems"
v-slot="{ isExpanded }"
:key="item._id"
:style="{ 'padding-left': `${item.level - 0.5}rem` }"
v-bind="item.bind"
class="flex items-center py-1 px-2 my-0.5 rounded outline-none focus:ring-grass8 focus:ring-2 data-[selected]:bg-grass4"
>
<template v-if="item.hasChildren">
<Icon
v-if="!isExpanded"
icon="lucide:folder"
class="h-4 w-4"
/>
<Icon
v-else
icon="lucide:folder-open"
class="h-4 w-4"
/>
</template>
<Icon
v-else
:icon="item.value.icon || 'lucide:file'"
class="h-4 w-4"
/>
<div class="pl-2">
{{ item.value.title }}
</div>
</TreeItem>
</TreeRoot>
</template>
15 changes: 15 additions & 0 deletions docs/components/demo/Tree/tailwind/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { green, grass } = require('@radix-ui/colors')

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./**/*.vue'],
theme: {
extend: {
colors: {
...green,
...grass,
},
},
},
plugins: [],
}
2 changes: 2 additions & 0 deletions docs/content/components/number-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ aria: https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton

# Number Field

<Badge>Alpha</Badge>

<Description>
A number field allows a user to enter a number and increment or decrement the value using stepper buttons.
</Description>
Expand Down
Loading
Loading