Skip to content

Commit

Permalink
chore(deps): upgrade sanitype to 0.6.2 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge authored Nov 26, 2024
1 parent 11f3972 commit 1f1ddc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
14 changes: 4 additions & 10 deletions examples/web/lib/form/inputs/UnionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {EllipsisVerticalIcon, TransferIcon, TrashIcon} from '@sanity/icons'
import {assign, at, set, unset} from '@sanity/mutate'
import {
getInstanceName,
isNeverSchema,
isObjectSchema,
type ObjectUnionFormDef,
pickDeep,
Expand Down Expand Up @@ -40,9 +39,7 @@ export function UnionInput(props: InputProps<SanityObjectUnion>) {
const valueTypeName = value?._type

const currentSchema = valueTypeName
? schema.union.find(
ut => !isNeverSchema(ut) && getInstanceName(ut) === valueTypeName,
)
? schema.union.find(ut => getInstanceName(ut) === valueTypeName)
: undefined

const handlePatch = useCallback(
Expand All @@ -59,7 +56,7 @@ export function UnionInput(props: InputProps<SanityObjectUnion>) {
const handleTurnInto = useCallback(
(nextTypeName: string) => {
const nextSchema = schema.union.find(
ut => !isNeverSchema(ut) && getInstanceName(ut) === nextTypeName,
ut => getInstanceName(ut) === nextTypeName,
)
if (!nextSchema) {
throw new Error(`No valid union type named ${nextTypeName}.`)
Expand All @@ -77,7 +74,7 @@ export function UnionInput(props: InputProps<SanityObjectUnion>) {
const handleSelectType = useCallback(
(nextTypeName: string) => {
const nextSchema = schema.union.find(
ut => !isNeverSchema(ut) && getInstanceName(ut) === nextTypeName,
ut => getInstanceName(ut) === nextTypeName,
)
if (!nextSchema) {
throw new Error(`No valid union type named ${nextTypeName}.`)
Expand All @@ -102,7 +99,7 @@ export function UnionInput(props: InputProps<SanityObjectUnion>) {
<Select onChange={e => handleSelectType(e.currentTarget.value)}>
<option value="">Select type</option>
{schema.union.map(ut => {
const name = !isNeverSchema(ut) && getInstanceName(ut)
const name = getInstanceName(ut)
if (!name || !(name in form.types)) {
throw new Error(`No form definition found for type ${name}`)
}
Expand Down Expand Up @@ -146,9 +143,6 @@ export function UnionInput(props: InputProps<SanityObjectUnion>) {
text="Turn into…"
>
{otherTypes.map(type => {
if (isNeverSchema(type)) {
return null
}
const sharedProperties = intersection(
Object.keys(type.shape),
Object.keys(currentSchema.shape),
Expand Down
2 changes: 1 addition & 1 deletion examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@sanity/client": "^6.21.1",
"@sanity/icons": "^3.3.1",
"@sanity/mutate": "workspace:",
"@sanity/sanitype": "^0.6.1",
"@sanity/sanitype": "^0.6.2",
"@sanity/ui": "^2.8.8",
"dataloader": "^2.2.2",
"groq-js": "^1.12.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1f1ddc0

Please sign in to comment.