@constructor-io/constructorio-ui-plp

中文文档
1.21.0发布于 2026/10/16MITTypeScriptESM + CJS构建来源已验证近 30 天下载 6565

Constructor PLP UI library for web applications

原始使用文档
文档目录16 节
  1. Introduction
  2. Installation
  3. Usage
  4. Using the React Component
  5. Using the JavaScript Bundle
  6. 🛍️ Shopify-Specific Defaults
  7. Custom Styling
  8. Library Defaults
  9. Troubleshooting
  10. Known Issues
  11. Local Development
  12. Development Scripts
  13. Library Maintenance
  14. Publishing new versions
  15. New Storybook Version
  16. Supporting Docs

Constructor PLP UI Library

npm MIT licensed

Introduction

A UI library that provides React components to manage the fetching and rendering logic for Search & Browse product listing pages powered by Constructor. Typescript support is available.

Our Storybook Docs are the best place to explore the behavior and the available configuration options for this UI library.

Installation

npm i @constructor-io/constructorio-ui-plp

Usage

Using the React Component

The CioPlp component handles state management, data fetching, and rendering logic for the entire PLP.

import CioPlp from '@constructor-io/constructorio-ui-plp';

function YourComponent() {
  return (
    <div>
      <CioPlp apiKey='key_M57QS8SMPdLdLx4x' />
    </div>
  );
}

Using the JavaScript Bundle

This is a framework agnostic method that can be used in any JavaScript project. The CioPlp function provides a simple interface to inject an entire PLP UI into the provided selector.

In addition to PLP component props, this function also accepts selector and includeCSS.

import CioPlp from '@constructor-io/constructorio-ui-plp/constructorio-ui-plp-bundled';

CioPlp({
  selector: '#plp-container',
  includeCSS: true, // Include the default CSS styles - defaults to true
  apiKey: 'key_M57QS8SMPdLdLx4x',
  // ... additional arguments
});

🛍️ Shopify-Specific Defaults

When integrating with Shopify themes, you can use the useShopifyDefaults prop to enable Shopify-specific behavior:

<CioPlp apiKey='your-api-key' useShopifyDefaults={true} />

What it provides:

  • callbacks.onAddToCart: Adds products to the Shopify cart via /cart/add.js API
  • callbacks.onProductCardClick: Navigates to /products/{itemId}
  • urlHelpers.setUrl: Converts /group_id/ URLs to /collections/ for Shopify compatibility

For the JavaScript Bundle:

When using useShopifyDefaults with the bundled version, you can omit the selector parameter and it will default to #cio-plp-ui-container:

CioPlp({
  apiKey: 'your-api-key',
  useShopifyDefaults: true,
  // selector defaults to '#cio-plp-ui-container'
});

Note: Any custom callbacks or urlHelpers you provide will override the Shopify defaults.

Custom Styling

Library Defaults

By default, importing React components from this library does not pull any CSS into your project.

If you wish to use starter styles from this library, add an import statement similar to the example import statement below:

import '@constructor-io/constructorio-ui-plp/styles.css';
  • The starter styles can be used as a foundation to build on top of, or as a reference to be replaced completely.
  • To opt out of all default styling, simply do not import the styles.css stylesheet.
  • All starter styles in this library are scoped within the .cio-plp CSS selector.
  • The starter styles are intended to be extended by layering in your own CSS rules.
  • If the starter styles are imported, CioPlp component will take up the full width and height of the parent container.

Please note the starter styles utilize @container queries and enable responsive styles for our PLPs based on the size of their container element. Since this feature is supported by modern browsers, polyfills have not been included in this library. However, if you want to support older browsers, you can add fallback styles or use a polyfill.

Troubleshooting

Known Issues

Older JavaScript environments

The library provides two different builds: CommonJS (cjs) and ECMAScript Modules (mjs).

For ECMAScript Modules (mjs) build. The JavaScript version is ESNext which might not be supported by your environment. If that's the case and your environment is using an older JavaScript version like ES6 (ES2015), you may get this error:

Module parse failed: Unexpected token (15:32) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file

To solve this you can import the CommonJS (cjs) build which supports ES6 (ES2015) syntax:

import CioPlp from '@constructor-io/constructorio-ui-plp/cjs'

ESLint

There is a known issue with ESLint where it fails to resolve the paths exposed in the exports statement of NPM packages. If you are receiving the following error, you can safely disable ESLint using // eslint-disable-line for that line.

Unable to resolve path to module '@constructor-io/constructorio-ui-plp/styles.css'

Relevant open issues: Issue 1868, Issue 1810

Local Development

Development Scripts

npm ci                  # Install dependencies for local dev
npm run dev             # Start a local dev server for Storybook
npm run lint            # Run lint

Library Maintenance

npm run compile           # Generate lib folder for publishing to npm
npm run build-storybook   # Generate Storybook static bundle for deploy with GitHub Pages

Publishing new versions

Dispatch the Publish workflow in GitHub Actions. You're required to provide two arguments:

  • Version Strategy: major, minor, or patch.
  • Title: A title for the release.

This workflow will automatically:

  1. Bump the library version using the provided strategy.
  2. Create a new git tag.
  3. Create a new GitHub release.
  4. Compile the library.
  5. Publish the new version to NPM.
  6. Deploy the Storybook docs to GitHub Pages.
  7. Report the progress on the relevant Slack channel.

ℹ️ Note: Please don't manually increase the package.json version or create new git tags.

The library version is tracked by releases and git tags. We intentionally keep the package.json version at 0.0.0 to avoid pushing changes to the main branch. This solves many security concerns by avoiding the need for branch-protection rule exceptions.

New Storybook Version

Dispatch the Deploy Storybook workflow in GitHub Actions.

ℹ️ Note: This is already done automatically when publishing a new version.

Supporting Docs

版本与发布记录

@constructor-io/constructorio-ui-plp 共发布 70 个版本,首次发布于 2024/09/07;过去 12 个月发布了 29 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.21.0latest2026/10/1625 天前
1.20.02026/08/053 个月前
1.19.22026/08/053 个月前
1.19.12026/06/244 个月前
1.18.02026/06/234 个月前
1.17.22026/06/164 个月前

关于 @constructor-io/constructorio-ui-plp 的常见问题

@constructor-io/constructorio-ui-plp 是什么?

Constructor PLP UI library for web applications

如何安装 @constructor-io/constructorio-ui-plp?

在项目目录运行 npm install @constructor-io/constructorio-ui-plp,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.12.0)、tslib(^2.4.0)、react-dom(>=16.12.0)、@constructor-io/constructorio-ui-components(^1.6.0)、@constructor-io/constructorio-client-javascript(^2.77.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@constructor-io/constructorio-ui-plp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@constructor-io/constructorio-ui-plp 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@constructor-io/constructorio-ui-plp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@constructor-io/constructorio-ui-plp 可以商用吗?

@constructor-io/constructorio-ui-plp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@constructor-io/constructorio-ui-plp 的下载量有多少?

根据 npm 官方下载统计,@constructor-io/constructorio-ui-plp 在 2026/10/11 – 2026/11/09 这 30 天内被下载 6,565 次,日均约 219 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@constructor-io/constructorio-ui-plp 还在维护吗?

最新版本 1.21.0 发布于 2026/10/16(25 天前);至今共发布 70 个版本,其中过去 12 个月发布了 29 个;首次发布于 2024/09/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。