# @aurodesignsystem/auro-drawer 中文文档

规范地址：https://npmcn.com/package/%40aurodesignsystem/auro-drawer/

版本：5\.2\.1
npm 元数据更新时间：2026-10-06T17:53:30.873Z
中文译文更新时间：2026-11-07T05:23:37.159Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aurodesignsystem/auro-drawer
原文对照：https://npmcn.com/package/%40aurodesignsystem/auro-drawer/?lang=original
项目主页：https://github.com/AlaskaAirlines/auro-drawer#readme
源码仓库：https://github.com/AlaskaAirlines/auro-drawer

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1 MB，19 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=20
- 运行依赖：1 个
- 首次发布：2024-01-25T22:39:42.927Z
- 最新版本发布：2026-10-06T17:53:30.543Z
- 近 30 天下载量：4965（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：53（近 12 个月 9 个）

## 中文简介

auro-drawer HTML 自定义元素

## 安装

```sh
npm install @aurodesignsystem/auro-drawer
```

也可以使用：`pnpm add @aurodesignsystem/auro-drawer`、`yarn add @aurodesignsystem/auro-drawer`、`bun add @aurodesignsystem/auro-drawer`

## README

# 绘图器

这个 `<auro-drawer>` 要素是一个侵入性的互动要素,而不是被动的。 在有要求时,该要素最好被使用,使用户了解所显示的内容,将重点从主要内容转移到抽屉内容上.

该元素还支持一种模式(阻塞)状态,用户必须同该元素的内容互动才能继续. 不允许被动辞退内容. 此状态的用户必须添加一个触发器,让用户超越此内容.

## 使用大小写

这个 `auro-drawer` 在用户可能:

-   在做别的事或回去之前 被催促采取行动
-   提示查看内容并选择关闭

## 安装

[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-drawer/release.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-drawer/actions/workflows/release.yml) [![See it on NPM!](https://img.shields.io/npm/v/@aurodesignsystem/auro-drawer?style=for-the-badge&color=orange)](https://www.npmjs.com/package/@aurodesignsystem/auro-drawer) [![License](https://img.shields.io/npm/l/@aurodesignsystem/auro-drawer?color=blue&style=for-the-badge)](https://www.apache.org/licenses/LICENSE-2.0) ![ESM supported](https://img.shields.io/badge/ESM-compatible-FFE900?style=for-the-badge)

```shell
$ npm i @aurodesignsystem/auro-drawer
```

### 定义项目中的依赖性

确定每个项目中的依赖性 `<auro-drawer>` 组件.

```js
import "@aurodesignsystem/auro-drawer";
```

### 使用 CDN 软件

在项目无法处理JS资产的情况下,有预处理后的资产可供使用. IE11等后遗症浏览器不再被支持.

```html
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-drawer@latest/+esm"></script>
```

## 基本示例

```html
<div>
  <auro-button id="openBasic">Open default drawer</auro-button>
</div>
<auro-drawer id="defaultDrawer">
  <span slot="header">Default Drawer</span>
  <div slot="content">
    <p>When traveling on Alaska Airlines flights, Alaska Airlines checked baggage fees may apply. See <auro-hyperlink href="https://www.alaskaair.com/bagrules" target="_blank">alaskaair.com/bagrules</auro-hyperlink> for our rules. For itineraries that include other airlines, their checked baggage fees may apply, as displayed on their websites.</p>
    <p>Baggage rules and fees will be based on the specific itinerary chosen. The applicable first and second bag fees will be displayed after you have added flights to the cart.</p>
    <auro-header level="3" display="500">Before checking your bags, remember to:</auro-header>
    <ul>
      <li>Caerphilly croque monsieur fondue</li>
      <li>Taleggio goat mascarpone cow manchego cheese and wine emmental cheese strings</li>
      <li>Cheddar cheese and biscuits chalk and cheese</li>
      <li>Camembert de normandie stinking bishop bavarian bergkase</li>
    </ul>
  </div>
  <div slot="footer">
    <auro-button secondary id="closeBasic">Close</auro-button>
  </div>
</auro-drawer>
```

## 自定义版本管理组件注册

每个Auro组件有两个关键部分: [类](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) 和自定义元素定义. 类定义了组件的行为,而自定义元素则以特定的名称注册,以便用于HTML.

当您安装您所描述的组件时 `Install` 页面中,该类会自动导入,组件会在全球注册.

然而,如果需要将同一组件的多个版本加载到一页上(例如,当两个工程依赖于不同的版本时),可以手动在自定义元素名下注册类来避免冲突.

您可以仅导入组件类并使用 `register(name)` 唯一名称的方法 :

```js
// Import the class only
import { AuroDrawer } from '@aurodesignsystem/auro-drawer/class';
​
// Register with a custom name if desired
AuroDrawer.register('custom-drawer');
```

这将创建一个新的自定义元素 `<custom-drawer>` 行为就像 `<auro-drawer>`,允许两者在同一页上共存,而互不干涉.

打开自定义抽屉

自定义绘图器

在乘坐阿拉斯加航空公司航班旅行时,阿拉斯加航空公司可以申请托运行李费. 参见 alaskaair.com/bagrules 关于我们的规则。 对于包括其他航空公司在内的行程,其托运行李费可按其网站显示的方式申请.

行李规则和收费将根据所选择的具体行程而定。 申请的第一袋和第二袋费用将在您在车内增加航班后显示.

在检查您的行李之前,请记住:

-   卡尔菲利克·克罗克先生
-   Taleggio山羊 mascarpone 牛 manchego 起司和葡萄酒 emmental起司串
-   切达干酪和饼干粉笔和干酪
-   巴伐利亚主教贝加塞

关闭

见代码

```html
<div>
  <auro-button id="openCustom">Open custom drawer</auro-button>
</div>
<custom-drawer id="customDrawer">
  <span slot="header">Custom Drawer</span>
  <div slot="content">
    <p>When traveling on Alaska Airlines flights, Alaska Airlines checked baggage fees may apply. See <auro-hyperlink href="https://www.alaskaair.com/bagrules" target="_blank">alaskaair.com/bagrules</auro-hyperlink> for our rules. For itineraries that include other airlines, their checked baggage fees may apply, as displayed on their websites.</p>
    <p>Baggage rules and fees will be based on the specific itinerary chosen. The applicable first and second bag fees will be displayed after you have added flights to the cart.</p>
    <auro-header level="3" display="500">Before checking your bags, remember to:</auro-header>
    <ul>
      <li>Caerphilly croque monsieur fondue</li>
      <li>Taleggio goat mascarpone cow manchego cheese and wine emmental cheese strings</li>
      <li>Cheddar cheese and biscuits chalk and cheese</li>
      <li>Camembert de normandie stinking bishop bavarian bergkase</li>
    </ul>
  </div>
  <div slot="footer">
    <auro-button secondary id="closeCustom">Close</auro-button>
  </div>
</custom-drawer>
```

## 常见问题

### @aurodesignsystem/auro-drawer 是什么？

auro-drawer HTML 自定义元素

### 如何安装 @aurodesignsystem/auro-drawer？

在项目目录运行 npm install @aurodesignsystem/auro-drawer，或使用 pnpm add / yarn add / bun add。

### @aurodesignsystem/auro-drawer 支持 TypeScript 吗？

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

### @aurodesignsystem/auro-drawer 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @aurodesignsystem/auro-drawer 需要什么版本的 Node\.js？

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

### @aurodesignsystem/auro-drawer 可以商用吗？

@aurodesignsystem/auro-drawer 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @aurodesignsystem/auro-drawer 的下载量有多少？

根据 npm 官方下载统计，@aurodesignsystem/auro-drawer 在 2026/10/07 – 2026/11/05 这 30 天内被下载 4,965 次，日均约 166 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @aurodesignsystem/auro-drawer 还在维护吗？

最新版本 5\.2\.1 发布于 2026/10/07（1 个月前）；至今共发布 53 个版本，其中过去 12 个月发布了 9 个；首次发布于 2024/01/26。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

