# @aurodesignsystem/auro-dialog 中文文档

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

版本：4\.2\.2
npm 元数据更新时间：2026-10-06T17:56:56.069Z
中文译文更新时间：2026-11-07T05:23:20.446Z
软件包许可：Apache-2\.0

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

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

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

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

## 中文简介

auro-dialog HTML 自定义元素

## 安装

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

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

## README

# 对话框

这个 `<auro-dialog>` 组件是一个侵入性的互动组件,而不是被动的。 当有要求时,该组件最好被使用,让用户了解所显示的内容,将焦点从主要内容转移到对话内容.

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

奥罗持有 [尼尔森·诺曼集团](https://www.nngroup.com/articles/modal-nonmodal-dialog/) 对话框和模式使用中的真实性.

## 使用大小写

这个 `<auro-dialog>` 在用户可能:

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

## 安装

[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-dialog/release.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-dialog/actions/workflows/release.yml) [![See it on NPM!](https://img.shields.io/npm/v/@aurodesignsystem/auro-dialog?style=for-the-badge&color=orange)](https://www.npmjs.com/package/@aurodesignsystem/auro-dialog) [![License](https://img.shields.io/npm/l/@aurodesignsystem/auro-dialog?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-dialog
```

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

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

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

### 使用 CDN 软件

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

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

## 基本示例

```html
<div>
  <auro-button id="openBasic">Open default dialog</auro-button>
</div>
<auro-dialog id="defaultDialog">
  <span slot="header">Default Dialog</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-dialog>
```

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

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

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

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

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

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

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

打开默认对话框

默认对话框

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

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

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

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

关闭

见代码

```html
<div>
  <auro-button id="openCustom">Open default dialog</auro-button>
</div>
<custom-dialog id="customDialog">
  <span slot="header">Default Dialog</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-dialog>
```

## 常见问题

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

auro-dialog HTML 自定义元素

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

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

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

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

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

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

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

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

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

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

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

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

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

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

