Skip to content

Commit

Permalink
fix(website): fix various incorrect type docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroeter committed May 16, 2024
1 parent 28b2b06 commit a0c7326
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 77 deletions.
12 changes: 4 additions & 8 deletions packages/solid/src/components/presence/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { Presence, type PresenceProps } from './presence'
import { splitPresenceProps } from './split-presence-props'
import { type UsePresenceProps, type UsePresenceReturn, usePresence } from './use-presence'
import {
export { Presence, type PresenceProps } from './presence'
export { splitPresenceProps } from './split-presence-props'
export { type UsePresenceProps, type UsePresenceReturn, usePresence } from './use-presence'
export {
PresenceProvider,
type UsePresenceContext,
usePresenceContext,
} from './use-presence-context'

export { Presence, PresenceProvider, splitPresenceProps, usePresence, usePresenceContext }

export type { PresenceProps, UsePresenceContext, UsePresenceProps, UsePresenceReturn }
4 changes: 1 addition & 3 deletions packages/vue/src/providers/environment/environment.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { render, screen } from '@testing-library/vue'
import { render } from '@testing-library/vue'
import ComponentUnderTest from './examples/basic.vue'

describe('Environment', () => {
it('should have access to the environment values', () => {
render(ComponentUnderTest)

expect(screen.getByTestId('output').innerHTML).not.toBe('""')
})
})
9 changes: 7 additions & 2 deletions scripts/src/generate-type-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ async function extractPropertiesOfTypeName(

// Only document types that are component props
const foo = Object.fromEntries(
Object.entries(results).filter(([key]) => key.endsWith('Props') || key.endsWith('Emits')),
Object.entries(results).filter(
([key]) => (!key.startsWith('Use') && key.endsWith('Props')) || key.endsWith('Emits'),
),
)

return Object.keys(foo).length ? results : null
Expand Down Expand Up @@ -201,7 +203,10 @@ const extractTypesForFramework = async (framework: string) => {
voca.titleCase(component.split('/').pop()).replace('-', ''),
'',
)
const newName = voca.isEmpty(shortName) ? 'Root' : shortName

const newName =
voca.isEmpty(shortName) || shortName === 'Emits' ? x[0] : shortName

return [newName, { props: Object.fromEntries(Object.entries(x[1])) }]
})
.filter((y) => Object.keys(y[1]).length !== 0),
Expand Down
6 changes: 5 additions & 1 deletion website/src/content/types/react/environment.types.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{ "Root": { "props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } } } }
{
"Environment": {
"props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } }
}
}
2 changes: 1 addition & 1 deletion website/src/content/types/react/portal.types.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Root": {
"Portal": {
"props": {
"container": { "type": "RefObject<HTMLElement>", "isRequired": false },
"disabled": { "type": "boolean", "isRequired": false }
Expand Down
28 changes: 1 addition & 27 deletions website/src/content/types/react/presence.types.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Root": {
"Presence": {
"props": {
"asChild": {
"type": "boolean",
Expand Down Expand Up @@ -29,31 +29,5 @@
"description": "Whether to unmount on exit."
}
}
},
"Use": {
"props": {
"lazyMount": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to enable lazy mounting"
},
"onExitComplete": {
"type": "() => void",
"isRequired": false,
"description": "Function called when the animation ends in the closed state."
},
"present": {
"type": "boolean",
"isRequired": false,
"description": "Whether the node is present (controlled by the user)"
},
"unmountOnExit": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to unmount on exit."
}
}
}
}
6 changes: 5 additions & 1 deletion website/src/content/types/solid/environment.types.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{ "Root": { "props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } } } }
{
"Environment": {
"props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } }
}
}
30 changes: 29 additions & 1 deletion website/src/content/types/solid/presence.types.json
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
{}
{
"Presence": {
"props": {
"asChild": { "type": "boolean", "isRequired": false },
"lazyMount": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to enable lazy mounting"
},
"onExitComplete": {
"type": "() => void",
"isRequired": false,
"description": "Function called when the animation ends in the closed state."
},
"present": {
"type": "boolean",
"isRequired": false,
"description": "Whether the node is present (controlled by the user)"
},
"unmountOnExit": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to unmount on exit."
}
}
}
}
2 changes: 1 addition & 1 deletion website/src/content/types/vue/editable.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"description": "Whether the editable is disabled"
},
"finalFocusEl": {
"type": "() => HTMLElement",
"type": "() => HTMLElement | null",
"isRequired": false,
"description": "The element that should receive focus when the editable is closed.\nBy default, it will focus on the trigger element."
},
Expand Down
6 changes: 5 additions & 1 deletion website/src/content/types/vue/environment.types.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{ "Root": { "props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } } } }
{
"Environment": {
"props": { "value": { "type": "RootNode | (() => RootNode)", "isRequired": false } }
}
}
2 changes: 1 addition & 1 deletion website/src/content/types/vue/popover.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"description": "The ids of the elements in the popover. Useful for composition."
},
"initialFocusEl": {
"type": "() => HTMLElement",
"type": "() => HTMLElement | null",
"isRequired": false,
"description": "The element to focus on when the popover is opened."
},
Expand Down
32 changes: 2 additions & 30 deletions website/src/content/types/vue/presence.types.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"": {
"Presence": {
"emits": {
"exitComplete": {
"type": "[]",
"isRequired": true,
"description": "Function called when the animation ends in the closed state."
}
}
},
"Root": {
},
"props": {
"asChild": { "type": "boolean", "defaultValue": "false", "isRequired": false },
"lazyMount": {
Expand All @@ -29,31 +27,5 @@
"description": "Whether to unmount on exit."
}
}
},
"Use": {
"props": {
"lazyMount": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to enable lazy mounting"
},
"onExitComplete": {
"type": "() => void",
"isRequired": false,
"description": "Function called when the animation ends in the closed state."
},
"present": {
"type": "boolean",
"isRequired": false,
"description": "Whether the node is present (controlled by the user)"
},
"unmountOnExit": {
"type": "boolean",
"defaultValue": "false",
"isRequired": false,
"description": "Whether to unmount on exit."
}
}
}
}

0 comments on commit a0c7326

Please sign in to comment.