@anypoint-web-components/anypoint-checkbox

中文文档
1.2.5发布于 2023/06/17Apache-2.0ESM + CJS近 30 天下载 3315

任意点和材料 DS 样式复选框

中文使用文档
文档目录10 节
  1. 使用表格
  2. 形式相关自定义要素
  3. 使用量
  4. 安装
  5. 在 HTML 文档中
  6. 在一个LitElement中
  7. 使用自定义表格
  8. 发展
  9. 本地运行演示
  10. 运行测试

折旧

此组件已移至 anypoint-web-components/awc。 。 。 .

====

任意点和材料 DS 样式复选框.

Published on NPM

tests

使用表格

在元素发布时,允许自定义元素被 <form> 要素(形式相关自定义要素正在开展工作. 自定义窗体元素必须与需要以格式注册的自定义元素一起使用. 我们建议使用 铁制。 。 。 .

形式相关自定义要素

此元素支持形式关联自定义元素 spec, 允许使用自定义元素 <form> 财务报告和审定财务报表 <fieldset> 要素。 浏览器可能尚未支持此特性 . 如果启用了 API, 那么窗体元素返回 anypoint-checkbox 实值 form.elements 列出并收集控件的值.

使用量

复选框应使用表格来选择可用的选项之一。 与切换动作选择控件并立即执行系统相关动作的切换按钮不同,一个复选框状态的改变,除了选择一个选项外,不会携带任何其他相关动作. 换句话说,当控制状态的改变会触发UI中的变化时,应该使用开关按钮而不是复选框.

安装

npm i --save @anypoint-web-components/anypoint-checkbox

在 HTML 文档中

<html>
  <head>
    <script type="module">
      import '@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js';
    </script>
  </head>
  <body>
    <anypoint-checkbox>Regular checkbox</anypoint-checkbox>
    <anypoint-checkbox checked>Checked checkbox</anypoint-checkbox>
    <anypoint-checkbox indeterminate>Indeterminate checkbox</anypoint-checkbox>
    <anypoint-checkbox required>Required checkbox</anypoint-checkbox>
    <anypoint-checkbox disabled>Disabled checkbox</anypoint-checkbox>
  </body>
</html>

在一个LitElement中

import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js';

class SimpleElement extends ControlStateMixin(ButtonStateMixin(LitElement)) {
  render() {
    return html`
    <anypoint-checkbox>Regular checkbox</anypoint-checkbox>
    <anypoint-checkbox checked>Checked checkbox</anypoint-checkbox>
    <anypoint-checkbox indeterminate>Indeterminate checkbox</anypoint-checkbox>
    <anypoint-checkbox required>Required checkbox</anypoint-checkbox>
    <anypoint-checkbox disabled>Disabled checkbox</anypoint-checkbox>
    `;
  }
}
window.customElements.define('simple-element', SimpleElement);

使用自定义表格

npm i --save @polymer/iron-form
<script type="module" src="node_modules/@polymer/iron-form/iron-form.js"></script>
<script type="module" src="node_modules/@anypoint-web-components/anypoint-checkbox/anypoint-checkbox.js"></script>
<script type="module" src="node_modules/@anypoint-web-components/anypoint-button/anypoint-button.js"></script>
<iron-form>
  <form>
   <anypoint-checkbox name="subscribe" value="newsletter">Subscribe to our newsletter</anypoint-checkbox>
   <anypoint-checkbox name="terms" value="accepted" checked required>Agree to terms and conditions</anypoint-checkbox>
   <anypoint-checkbox name="disabled" value="noop" disabled>This is never included</anypoint-checkbox>
  </form>
  <anypoint-button id="submit"></anypoint-button>
</iron-form>
<script>
  document.getElementById('submit').addEventListener('click', () => {
    const values = document.querySelector('iron-form').serializeForm();
    console.log(values);
  });
</script>

发展

git clone https://github.com/anypoint-web-components/anypoint-checkbox
cd anypoint-checkbox
npm install

本地运行演示

npm start

运行测试

npm test

版本与发布记录

@anypoint-web-components/anypoint-checkbox 共发布 14 个版本,首次发布于 2019/06/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.5latest2023/06/173 年前
1.2.42021/11/204 年前
1.2.32021/10/155 年前
1.2.22021/08/255 年前
1.2.12021/05/315 年前
1.2.02021/05/115 年前

关于 @anypoint-web-components/anypoint-checkbox 的常见问题

@anypoint-web-components/anypoint-checkbox 是什么?

任意点和材料 DS 样式复选框

如何安装 @anypoint-web-components/anypoint-checkbox?

在项目目录运行 npm install @anypoint-web-components/anypoint-checkbox,或使用 pnpm add / yarn add / bun add。

@anypoint-web-components/anypoint-checkbox 支持 TypeScript 吗?

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

@anypoint-web-components/anypoint-checkbox 支持 ESM 还是 CommonJS?

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

@anypoint-web-components/anypoint-checkbox 可以商用吗?

@anypoint-web-components/anypoint-checkbox 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anypoint-web-components/anypoint-checkbox 的下载量有多少?

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

@anypoint-web-components/anypoint-checkbox 还在维护吗?

最新版本 1.2.5 发布于 2023/06/17(3 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/06/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。