@akinon/pz-basket-gift-pack

中文文档
2.0.164发布于 2026/11/09MITCommonJS零依赖近 30 天下载 1.5万

安装方法

中文使用文档
文档目录4 节
  1. 安装方法
  2. 道具
  3. 自定义礼品包
  4. 自定义礼品注释表单

@akinon/pz-basket-gift- pack

安装方法

您可以使用以下命令安装最新插件的扩展:


npx @akinon/projectzero@latest --plugins

道具

属性类型说明
篮子项目object产品信息.
使用模式boolean此道具决定礼物包表是否在模式内显示 。 当设置为真时, 窗体会在模式内打开 .
模式分类Namestring这种道具用于自定义模式的整体风格.
模式string此道具设定模式的标题 .
模式分类Namestring这种道具用于自定义模式内容的样式.
自定义UIRenderReact.ReactNode可选功能可以完全定制礼品包渲染. 接收者有GiftPack,有Note,Note, textReacount,在AddGiftPack,在RemoveGiftPack,在AddNote,在RemoveNote,形成Content和翻译道具.
自定义 GiftNoteFormUI渲染器React.ReactNode完全自定义窗体渲染的可选功能 。 接收寄存器、出错、注解、文本区域查询,在Submit上,删除Note并处理Submit道具.

自定义礼品包

import PluginModule, { Component } from '@akinon/next/components/plugin-module';

<PluginModule
  component={Component.BasketGiftPack}
  props={{
    basketItem,
    customUIRender: ({
      hasGiftPack,
      hasNote,
      onAddGiftPack,
      onRemoveGiftPack,
      onAddNote,
      formContent,
      translations
    }) => (
      <>
        <div className="flex gap-4">
          <div className="flex items-center gap-2">
            <Icon
              name="giftbox"
              size={15}
              className={clsx(
                hasGiftPack ? 'text-[#e85150]' : 'text-[#000000]'
              )}
            />
            {hasGiftPack ? (
              <span className="text-[0.75rem]">
                {translations.giftPackAdded}
              </span>
            ) : (
              <Button
                appearance="ghost"
                className="text-[#000000] cursor-pointer underline border-0 px-0 py-0 text-[0.75rem] h-auto hover:bg-transparent hover:text-[#000000]"
                onClick={onAddGiftPack}
                data-testid="add-basket-gift-pack"
              >
                {translations.addGiftPack}
              </Button>
            )}
          </div>

          {hasGiftPack && (
            <>
              <Button
                appearance="ghost"
                className="text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] select-none underline h-auto hover:bg-transparent hover:text-[#000000]"
                onClick={onAddNote}
                data-testid="add-basket-gift-pack-note"
              >
                {hasNote.title}
              </Button>
              <Button
                appearance="ghost"
                className={clsx(
                  'text-[#000000] cursor-pointer border-0 px-0 py-0 text-[0.75rem] underline h-auto hover:bg-transparent hover:text-[#000000]',
                  {
                    hidden: !hasGiftPack
                  }
                )}
                onClick={onRemoveGiftPack}
                data-testid="remove-basket-gift-pack"
              >
                {translations.removeGiftPack}
              </Button>
            </>
          )}
        </div>

        <div className="w-full">
          {hasNote.state ? <div className="mt-4">{formContent}</div> : null}
        </div>
      </>
    )
  }}
/>;

自定义礼品注释表单

import PluginModule, { Component } from '@akinon/next/components/plugin-module';

<PluginModule
  component={Component.BasketGiftPack}
  props={{
    basketItem,
    customGiftNoteFormUIRender: ({
      register,
      errors,
      note,
      textAreaCount,
      onSubmit,
      removeNote,
      handleSubmit
    }) => (
      <div className="bg-gray-100 p-4 rounded-md shadow-lg">
        <h4 className="text-lg font-semibold mb-2">🎁 Add Your Note</h4>
        <form onSubmit={handleSubmit(onSubmit)}>
          <textarea
            className="w-full border border-gray-300 p-2"
            {...register('message')}
            placeholder="Mesajını yaz..."
            rows={5}
            value={note}
          />
          {errors.message && (
            <p className="text-red-500 text-sm">{errors.message.message}</p>
          )}
          <div className="flex justify-between items-center mt-2">
            <span className="text-sm text-gray-500">
              {textAreaCount}/ 160 characters
            </span>
            <div className="flex gap-2">
              <button
                type="button"
                onClick={removeNote}
                className="text-sm underline"
              >
                Delete Note
              </button>
              <button
                type="submit"
                className="bg-black text-white px-3 py-1 text-sm rounded"
              >
                Save
              </button>
            </div>
          </div>
        </form>
      </div>
    )
  }}
/>;

版本与发布记录

@akinon/pz-basket-gift-pack 共发布 1,246 个版本,首次发布于 2024/05/30;过去 12 个月发布了 742 个版本。

版本发布日期距今
2.0.164latest2026/11/09今天
1.126.29-v1-rc.36v1-rc2026/11/09今天
2.0.164-rc.1rc2026/11/09今天
2.0.164-beta.0beta2026/11/09今天
2.0.164-rc.02026/11/09今天
2.0.1632026/11/09今天

其他发布通道:snapshot → 1.126.4-snapshot-ZERO-5318-occasion-20261019202720,v1-latest → 1.126.28,beta → 2.0.164-beta.0,rc → 2.0.164-rc.1,v1-rc → 1.126.29-v1-rc.36。

关于 @akinon/pz-basket-gift-pack 的常见问题

@akinon/pz-basket-gift-pack 是什么?

安装方法

如何安装 @akinon/pz-basket-gift-pack?

在项目目录运行 npm install @akinon/pz-basket-gift-pack,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@akinon/pz-basket-gift-pack 支持 TypeScript 吗?

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

@akinon/pz-basket-gift-pack 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@akinon/pz-basket-gift-pack 可以商用吗?

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

@akinon/pz-basket-gift-pack 的下载量有多少?

根据 npm 官方下载统计,@akinon/pz-basket-gift-pack 在 2026/10/06 – 2026/11/04 这 30 天内被下载 14,756 次,日均约 492 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@akinon/pz-basket-gift-pack 还在维护吗?

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