@commercetools-frontend-extensions/export-resources-modal

中文文档
5.17.0发布于 2026/11/02BSD-3-ClauseESM + CJS近 30 天下载 3867

Shared export modal for exporting resources

原始使用文档
文档目录7 节
  1. Getting started
  2. Description
  3. Usage
  4. Properties
  5. Releasing
  6. Canary releases
  7. i18n

@commercetools-frontend-extensions/export-resources-modal

Package for exporting resources from Merchant Center Applications.

This library takes into account that you are building a Merchant Center Applications which documentation you can find here. The components follow the same principles of the UIKit components.

Getting started

$ npm install --save @commercetools-frontend-extensions/export-resources-modal

// or

$ yarn add @commercetools-frontend-extensions/export-resources-modal

Description

Export Resources Modal is an internal component used to export resources into csv or json files, it's using Exporter Services to create async export Job.

Usage

import ExportResourcesModal from '@commercetools-frontend-extensions/export-resources-modal';

// Use case: Exporting all resources
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    totalResourcesCount={143}
    fieldGroups={[
      {
        groupLabel: 'All general fields',
        groupName: 'general-fields',
        previewGroupLabel: 'general fields',
        fields: [
          {
            name: 'key',
            label: 'Category key',
            isRequired: true,
          },
          {
            name: 'externalId',
            label: 'External id',
          },
          {
            name: 'createdAt',
            label: 'Created at',
            isSelectedByDefault: true,
          },
          {
            name: 'lastModifiedAt',
            label: 'Last modified at',
            isSelectedByDefault: true,
          },
          { name: 'name', label: 'Name', isSelectedByDefault: true },
          {
            name: 'parent',
            label: 'parent',
            isSelectedByDefault: true,
            fields: [
              {
                name: 'parent.name',
                label: 'Parent name',
              },
              {
                name: 'parent.key',
                label: 'Parent key',
              },
            ],
          },
          {
            name: 'id',
            label: 'Id',
            isSelectedByDefault: true,
          },
        ],
      },
      {
        groupLabel: 'All custom fields',
        groupName: 'custom-fields',
        previewGroupLabel: 'custom fields',
        fields: [
          {
            name: 'custom-type-key-and-type-id',
            label: 'Custom type key and type id',
          },
          {
            name: 'general-category-attributes',
            label: 'General category attributes',
            fields: [
              {
                name: 'custom.fields.season',
                label: 'Season',
              },
              {
                name: 'custom.fields.target-audience',
                label: 'Target audience',
              },
            ],
          },
          {
            name: 'book-category-attributes',
            label: 'Book category attributes',
            fields: [
              {
                name: 'custom.fields.genre',
                label: 'Genre',
              },
              {
                name: 'custom.fields.age-group',
                label: 'Age group',
              },
            ],
          },
        ],
      },
    ]}
    fieldOrder={['*', 'custom']}
    onClose={() => {
      ...
    }}
/>


// Use case: Exporting filtered resources
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    filters={{
      { 
        filters: [ 'key = "category-key"'], 
        fullText: {
          text: 'category-text',
          locale: 'en'
        } 
      },
      total: 20
    }}
    totalResourcesCount={143}
    fieldGroups={[
      {
        groupLabel: 'All general fields',
        groupName: 'general-fields',
        previewGroupLabel: 'general fields',
        fields: [
          {
            name: 'key',
            label: 'Category key',
            isRequired: true,
          },
          {
            name: 'externalId',
            label: 'External id',
          },
          {
            name: 'createdAt',
            label: 'Created at',
            isSelectedByDefault: true,
          },
          {
            name: 'lastModifiedAt',
            label: 'Last modified at',
            isSelectedByDefault: true,
          },
          { name: 'name', label: 'Name', isSelectedByDefault: true },
          {
            name: 'parent',
            label: 'parent',
            isSelectedByDefault: true,
            fields: [
              {
                name: 'parent.name',
                label: 'Parent name',
              },
              {
                name: 'parent.key',
                label: 'Parent key',
              },
            ],
          },
          {
            name: 'id',
            label: 'Id',
            isSelectedByDefault: true,
          },
        ],
      },
      {
        groupLabel: 'All custom fields',
        groupName: 'custom-fields',
        previewGroupLabel: 'custom fields',
        fields: [
          {
            name: 'custom-type-key-and-type-id',
            label: 'Custom type key and type id',
          },
          {
            name: 'general-category-attributes',
            label: 'General category attributes',
            fields: [
              {
                name: 'custom.fields.season',
                label: 'Season',
              },
              {
                name: 'custom.fields.target-audience',
                label: 'Target audience',
              },
            ],
          },
          {
            name: 'book-category-attributes',
            label: 'Book category attributes',
            fields: [
              {
                name: 'custom.fields.genre',
                label: 'Genre',
              },
              {
                name: 'custom.fields.age-group',
                label: 'Age group',
              },
            ],
          },
        ],
      },
    ]}
    fieldOrder={['*', 'custom']}
    onClose={() => {
      ...
    }}
/>

// Use case: Exporting only selected resources by their IDs
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
    fields={[
      {
          groupLabel: 'All General fields',
          groupName: 'general-fields',
          previewGroupLabel: 'general fields',
          fields:[
            {
              name: 'key',
              label: 'Category key',
              isRequired: true,
              isSelectedByDefault: true,
            },
            {
              name: 'externalId',
              label: 'External id',
            },
            { name: 'createdAt', label: 'Created at', isSelectedByDefault: true, },
            { name: 'lastModifiedAt', label: 'Last modified at', isSelectedByDefault: true, },
            { name: 'name', label: 'Name', isSelectedByDefault: true, },
            {
              name: 'parent',
              isSelectedByDefault: true,
              fields: [
                {
                  name: 'parent.name',
                  label: 'Parent name',
                },
                {
                  name: 'parent.key',
                  label: 'Parent key',
                },
              ],
            },
            {
              name: 'id',
              label: 'Id',
            },
            ]
        },
        {
            groupLabel: 'All custom fields',
            groupName: 'custom-fields',
            previewGroupLabel: 'custom fields',
            fields: [
              {
                name: 'custom-type-key-and-typeid',
                label: 'Custom type key and type id',
                isSelectedByDefault: false,
              },
              {
                name: 'general-category-attributes',
                label: 'General category attributes',
                isSelectedByDefault: false,
                fields: [
                  {
                    name: 'season',
                    label: 'Season',
                  },
                  {
                    name: 'target-audience',
                    label: 'Target audience',
                  },
                ],
              },
              {
                name: 'book-category-attributes',
                label: 'Book category attributes',
                isSelectedByDefault: false,
                fields: [
                  {
                    name: 'genre',
                    label: 'Genre',
                  },
                  {
                    name: 'age-group',
                    label: 'Age group',
                  },
                ],
              },
            ]
        }
    ]}
    onClose={() => {
      ...
    }}
/>

Properties

PropsTypeRequiredDefaultDescription
isOpenbooleanfalseControls whether the export modal is open or closed
outputFormatstring
Possible values: csv, json
csvThe file format to export
onExportSuccessfunctionCallback function that is called when the export operation is successful
onClosefunctionCallback function invoked when the modal is requested to close (on overlay click, close button click or ESC press). This function is also called after an export operation regardless of its success or failure
resourceTypestring✅The type of the resource, example: category, product...
filtersFiltersFilters can be set as filters object with a query property or array of strings. It can also be set as a simple string for the where property. Lastly, another option is to set Filters as fulltext object with text and locale string properties.
baseFiltersPick<Filters, 'where'>These filters are always forwarded to the API (merged with filters prop if exists) and cannot be bypassed by users.
totalResourcesCountnumber✅The count of all resources of identified resourceType
selectedResourceIdsarrayArray of Ids of the selected resources
fieldGroupsarray✅Array of the grouped fields to export.
fieldGroups[].groupLabelstring✅The label of the field group to be shown in the field selection UI
fieldGroups[].previewGroupLabelstring✅The label used to display the group name in the preview screen
fieldGroups[].groupNamestring✅The name of the field group used to determine the state of expanded groups
fieldGroups[].isExpandedstringfalseThis property used to control the default state of each expandable group section in the UI. If isExpanded is set to true, then the corresponding group will be expanded when the component loads. The default value is false which means unless explicitly set to true, the group will be collapsed on initial load
fieldGroups[].fieldsarray✅Array of the fields to export. The fields must align with the commercetools API schema. Field can have nested fields array.
fieldGroups[].fields[].namestring✅A string that represents the unique identifier for each field. The leaf fields must align with the commercetools HTTP API fields, while parent fields can be developer-specific and created for grouping purposes.
fieldGroups[].fields[].labelstring✅The label of the field to be shown in the export modal
fieldGroups[].fields[].isRequiredbooleanfalseisRequired field indicates whether a field is required for the export process. If true the field will be selected by default and cannot be deselected by the user. This is useful for fields that are essential for the export process. Fields marked as required will have a * appended to their label in the UI
fieldGroups[].fields[].extendedFieldNamesarrayAn array of additional field names that should be included along with the main field name when exporting data.
fieldGroups[].fields[].dependentGroupNamesarrayThe array of group names provided determines the state of the checkbox. If any of the groups mentioned in the dependentGroupNames has at least one checkbox selected, then the field is automatically selected. Optionally, dependentFieldNames can be used to specify particular fields within the group.
Note: The field will be readonly if it has dependencies.
fieldGroups[].fields[].dependentFieldNamesarrayThe array of field names of specific fields within the group to determine the state of the checkbox. If any of the specified fields in the dependentFieldNames are checked, the field is automatically selected.
fieldGroups[].fields[].isSelectedByDefaultbooleanfalseThis field is a part of the fields array is used to control the default state of the corresponding checkbox in the UI. If isSelectedByDefault is set to true, the checkbox for that particular field will be checked by default when the component loads.
fieldGroups[].fields[].isExpandablebooleanfalseisExpandable property indicates if the field can be expanded/collapsed on the UI. If the isExpandable is passed as true, then a expand/collapse button is displayed on the UI to control
fieldGroups[].fields[].isExpandedbooleanfalseThis property is used along with fieldGroups[].fields[].isExpandable to control the default state of each expandable fields in the UI. If fieldGroups[].fields[].isExpanded is set to true, then the corresponding field will be expanded when the component loads. The default value is false which means unless explicitly set to true, the field will be collapsed on initial load
fieldOrderstring[]The field names are sorted based on the order passed. The value * can be passed to denote any fields and for example fieldOrder=['*', 'custom'] will push all the fields that starts with custom to the last in the list and any other fields will be at the beginning of the list
storesArray<{ key: string; name: string }>When provided (and the resourceType defines an exportScopeSpecificStore message), renders an additional "Specific store" scope option with a store-selection dropdown. Selecting a store sets where=store(key="<key>") on the export request.
selectedScopeQueryPredicateBuilder(selectedResourceIds: string[]) => stringOverrides the where predicate produced for the SELECTED scope. Useful when selectedResourceIds reference a related resource — e.g. tailoring exports where IDs are product IDs, so the predicate must be product(id in (...)) instead of the default id in (...).

Releasing

This package uses changesets in order to do releases to NPM.

In case you want to publish a new version with the latest changes you need to:

  1. Add a changeset with pnpm changeset and select @commercetools-frontend-extensions/export-resources-modal as the modified package.
  2. Some options would be appear in order to do the release:
    • patch: use this release for fixes or small changes
    • minor: use this release for depenency upgrades or medium changes
    • major: use this release for breaking changes
  3. After selecting the option you will need to add a comment for the release notes. We recommend to use the same format as for the commits.
    • e.g: feat(utils): add utils for dates
  4. Push the changeset to your branch and GitHub actions will detect that the PR contains changes that affect the published library.
  5. After the PR gets merged, another PR will be created called Version Packages which is the one that will be detected, again by GitHub Actions, to do a release to NPM.
  6. Make sure that everything is correct and then merge Version Packages PR.
  7. Wait until the new version is available in NPM and then deploy the custom in CircleCI.

Canary releases

Canary releases are automatically published to the distribution channel via CI following a successful build and merge to the main branch.

i18n

The repo is configured with an integration with Transifex. The process for i18n is the same as the Merchant Center uses.

pnpm i18n:build for adding the new keys to transifex.

Once the PR gets merged to main transifex will receive a notification with new keys that need to be translated (that's why is important that description and defaultMessage are descriptive enough).

Whenever the translators finish translations and mark them as done, the repo will receive a PR (per language) for adding translated messages.

Once we review that translated keys are correct and add a changeset we can merge the PR. (Don't forget to deploy the custom app)

版本与发布记录

@commercetools-frontend-extensions/export-resources-modal 共发布 440 个版本,首次发布于 2022/09/17;过去 12 个月发布了 148 个版本。

版本发布日期距今
5.17.0latest2026/11/028 天前
5.16.192026/10/2120 天前
5.16.182026/10/1922 天前
5.16.172026/10/021 个月前
5.16.162026/09/301 个月前
5.16.152026/09/291 个月前

其他发布通道:next → 3.5.0-next.4,bw-test-preview-deploy → 0.0.0-bw-test-preview-deploy-20250115163227,fec-202-react19 → 0.0.0-fec-202-react19-20250307142208,canary → 0.0.0-canary-20260918105445。

关于 @commercetools-frontend-extensions/export-resources-modal 的常见问题

@commercetools-frontend-extensions/export-resources-modal 是什么?

Shared export modal for exporting resources

如何安装 @commercetools-frontend-extensions/export-resources-modal?

在项目目录运行 npm install @commercetools-frontend-extensions/export-resources-modal,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(17.x || 19.x)、redux(4.x || 5.x)、react-intl(6.x || 7.x)、react-redux(7.x || 9.x)、@commercetools-uikit/icons(19.x || 20.x)、@commercetools-frontend/sdk(24.x || 25.x || 27.x)、@commercetools-frontend/i18n(24.x || 25.x || 27.x)、@commercetools-frontend/l10n(24.x || 25.x || 27.x)、@commercetools-frontend/sentry(24.x || 25.x || 27.x)、@commercetools-frontend/ui-kit(19.x || 20.x)、@commercetools-frontend/constants(24.x || 25.x || 27.x)、@commercetools-frontend/fullstory(2.x || 3.x || 4.x)、@commercetools-uikit/design-system(19.x || 20.x)、@commercetools-frontend/actions-global(24.x || 25.x || 27.x)、@commercetools-frontend/application-shell(24.x || 25.x || 27.x)、@commercetools-frontend/jest-preset-mc-app(24.x || 25.x || 27.x)、@commercetools-frontend/application-components(24.x || 25.x || 27.x)、@commercetools-frontend/application-shell-connectors(24.x || 25.x || 27.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@commercetools-frontend-extensions/export-resources-modal 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/commercetools-frontend-extensions__export-resources-modal 是否存在。

@commercetools-frontend-extensions/export-resources-modal 支持 ESM 还是 CommonJS?

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

@commercetools-frontend-extensions/export-resources-modal 可以商用吗?

@commercetools-frontend-extensions/export-resources-modal 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@commercetools-frontend-extensions/export-resources-modal 的下载量有多少?

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

@commercetools-frontend-extensions/export-resources-modal 还在维护吗?

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