9.2.0 • Published 2 years ago

@fluent-blocks/schemas v9.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

This package contains the schemas that specify the platform-agnostic API surface for Fluent Blocks.

Using these schemas

There are at least two meaningful ways to use these schemas: (1) direct use in platform-specific components (as-is or by merging/extending), and (2) rendering to JSON schemas.

Direct use

Just import the schema you want to use, and use as you like.

Parsing / validating

import { cardProps } from '@fluentui/blocks-schemas'

const receivedProps = await getUserInput();

const parseResult = cardProps.safeParse(receivedProps)

if(parseResult.success){
  renderCard(parseResult.data)
}else{
  renderError(parseResult.error)
}

Defining platform-specific schemas

import { z } from 'zod'
import { ReactElement } from 'react'
import { textProps as naturalTextProps } from '@fluentui/blocks-schemas'

import Text from './Text.tsx'

const textElement = z.object({ props })
  .catchall(z.any())
  .transform((el) => el as ReactElement<z.infer<typeof naturalTextProps>, Text>)

export const textPropsOrElement = z.union([
  textProps,
  textElement
])

JSON schemas

To use the JSON schemas, they need to be built. Install dependencies before building with pnpm install, then from within this package, run:

$ pnpm render:json-schemas

The JSON schemas will populate in the json directory in this package.

9.3.0-next.17

2 years ago

9.3.0-next.16

2 years ago

9.2.0-next.9

2 years ago

9.3.0-next.10

2 years ago

9.2.0-next.0

2 years ago

9.2.0-next.2

2 years ago

9.2.0-next.3

2 years ago

9.3.0-next.9

2 years ago

9.3.0-next.8

2 years ago

9.3.0-next.15

2 years ago

9.3.0-next.7

2 years ago

9.2.0

2 years ago

9.3.0-next.3

2 years ago

9.3.0-next.2

2 years ago

9.3.0-next.1

2 years ago

9.3.0-next.0

2 years ago

9.1.0-next.3

2 years ago

9.1.0

2 years ago

9.1.0-next.2

2 years ago

9.1.0-next.1

2 years ago

9.0.0

2 years ago

9.0.0-alpha.3

2 years ago

9.0.0-alpha.2

2 years ago

9.0.0-alpha.1

2 years ago