MyGit

v0.11.0

measuredco/puck

版本发布时间: 2023-11-03 23:55:42

measuredco/puck最新发布版本:v0.16.0(2024-09-17 17:57:25)

v0.11.0 - Categories and dynamic props

Summary

This release introduces new APIs for categories and dynamic prop resolution, and updates the Next.js recipe to render static pages.

Categories API

The categories API enables the user to group their components in the left side bar.

Users can configure categories using the new categories configuration on the Puck config. They can also override this behaviour by using the renderComponentList API, accessible via the Puck root or plugins.

  categories: {
    layout: {
      components: ["Columns", "Flex", "VerticalSpace"],
    },
    typography: {
      components: ["Heading", "Text"],
    },
    interactive: {
      title: "Actions",
      components: ["ButtonGroup"],
    },
  },

Dynamic prop resolution

Dynamic prop resolution is an extremely powerful feature that enables developers to dynamically change props after the user has changed them. Full documentation available in the README.

This can be paired with external fields to query data from a third-party API, and also allows you to set fields as read-only.

const config = {
  components: {
    HeadingBlock: {
      fields: {
        heading: {
          type: "text",
        },
        title: {
          type: "text",
        },
      },
      resolveData: async (props) => {
        return {
          props: {
            title: props.heading, // map `heading` to `title`
          },
          readOnly: {
            title: true, // make `title` read-only
          },
        };
      },
      render: ({ title }) => {
        return <h1>{title}</h1>;
      },
    },
  },
};

Next.js recipe now supports static rendering

The default Next.js recipe has been updated to support static rendering, enabling Puck to generate static pages.

If you’ve already generated from this recipe and want to enable static rendering, we recommend manually updating your code to follow the latest best practices.

Deprecations

This release includes various backwards-compatible deprecations that will be breaking in a future release.

Deprecate use of props under root in Puck data in favour of root.props (7593584)

This affects all existing data payloads that make use of root. This allows us to align the behaviour of root with other components, including the new resolveData API.

Migration

Before

{
  "root": {
    "title": "Hello, world"
  }
}

After

{
  "root": {
    "props": {
      "title": "Hello, world"
    },
  }
}

We may consider making this permanently backwards compatible via the transformers proposal.

Deprecate adaptor in favour of new external field APIs (7f13efc)

The adaptor API on external field types has been removed in favour of keeping them at the root of the field configuration.

Migration

Before

{
  myField: {
    type: "external",
    adaptor: {
      name: "External Source",
      fetchList: () => {}
    }
  }
}

After

{
  myField: {
    type: "external",
    placeholder: "Select from External Source",
    fetchList: () => {}
  }
}

Deprecate magic _data API in favour of resolveData (4ee31e7)

The magic _data field name previously allowed you to spread the result of your adaptor call across your object. This has been replaced in favour of resolveData.

Migration

Before

{
  fields: {
    _data: {
      type: "external",
      adaptor: {
        name: "External Source",
        fetchList: () => {
          return [{ title: "Hello, world" }];
        },
      },
    },
    title: {
      type: "text",
    },
  },
};

After

{
  fields: {
    data: {
      type: "external",
      // Also note adaptor API change
      placeholder: "Load from external Source",
      fetchList: () => {
        return [{ title: "Hello, world" }];
      },
    },
    title: {
      type: "text",
    },
  },
  resolveData: ({ props }) => ({ props: { ...props, ...props.data } }),
};

Features

Bug Fixes

Performance Improvements

New Contributors

Full Changelog: https://github.com/measuredco/puck/compare/v0.10.0...v0.11.0

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-11-03发行的版本