Drag and drop task list items.
Перейти к файлу
Armağan d012adedb4
Merge pull request #56 from github/dependabot/npm_and_yarn/npm_and_yarn-82ad408bf4
Bump the npm_and_yarn group with 2 updates
2024-10-11 15:38:37 +10:00
.devcontainer Add a .devcontainer 2022-02-28 17:08:59 +00:00
.github/workflows Create .github/workflows/publish.yml 2022-03-28 17:01:34 +01:00
examples Combine index and task-lists-element files 2021-04-30 15:27:28 +01:00
src Fix task list drag 2023-02-13 16:27:01 -05:00
test configure karma to use chromium 2022-02-16 23:25:38 +00:00
.eslintrc.json Ignore `filenames/match-regex` for `rollup.config.js` 2021-08-31 09:21:11 +01:00
.gitignore Initial <task-lists> element 2018-04-25 16:58:53 -06:00
CODEOWNERS move AOR to primer 2022-09-23 18:46:13 +01:00
LICENSE Initial <task-lists> element 2018-04-25 16:58:53 -06:00
README.md Combine index and task-lists-element files 2021-04-30 15:27:28 +01:00
package-lock.json Bump the npm_and_yarn group with 2 updates 2024-10-10 20:17:05 +00:00
package.json Bump the npm_and_yarn group group with 1 update 2024-01-24 02:48:05 +00:00
rollup.config.js Combine index and task-lists-element files 2021-04-30 15:27:28 +01:00
tsconfig.json Combine index and task-lists-element files 2021-04-30 15:27:28 +01:00

README.md

<task-lists> element

Drag and drop task list items.

Installation

$ npm install --save @github/task-lists-element

Usage

Script

Import as a module:

import '@github/task-lists-element'

With a script tag:

<script type="module" src="./node_modules/@github/task-lists-element/dist/task-lists-element.js">

Markup

<task-lists sortable>
  <ul class="contains-task-list">
    <li class="task-list-item">
      <input type="checkbox" class="task-list-item-checkbox">
      Hubot
    </li>
    <li class="task-list-item">
      <input type="checkbox" class="task-list-item-checkbox">
      Bender
    </li>
  </ul>

  <ul class="contains-task-list">
    <li class="task-list-item">
      <input type="checkbox" class="task-list-item-checkbox">
      BB-8
    </li>
    <li class="task-list-item">
      <input type="checkbox" class="task-list-item-checkbox">
      WALL-E
    </li>
  </ul>
</task-lists>

Events

const list = document.querySelector('task-lists')

list.addEventListener('task-lists-check', function(event) {
  const {position, checked} = event.detail
  console.log(position, checked)
})

list.addEventListener('task-lists-move', function(event) {
  const {src, dst} = event.detail
  console.log(src, dst)
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.