debut des details de la page. Vu que c'est le troisieme (euh quatrieme?) composant, c'etait un peu plus rapide, mais heureusement que claude est la pour repasser derriere mes erreurs prcq en solo je n'y arriverais pas du tout!

This commit is contained in:
camille
2026-03-27 17:49:26 +01:00
parent 24e85c4471
commit 43589e583e
92 changed files with 12959 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Gianluca Guarini
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+83
View File
@@ -0,0 +1,83 @@
# bianco.events
[![Build Status][ci-image]][ci-url]
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]
Modern DOM events helpers written in es2015
This script will not be transpiled and it is only thought to be part of your build chain.
## Usage
```js
import { add, remove, once } from 'bianco.events'
add(node/s, 'click mouseenter', function(e) {
console.log('tadaaa!')
})
```
[ci-image]:https://img.shields.io/github/workflow/status/biancojs/events/test?style=flat-square
[ci-url]:https://github.com/biancojs/events/actions
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
[license-url]: LICENSE.txt
[npm-version-image]: http://img.shields.io/npm/v/bianco.events.svg?style=flat-square
[npm-downloads-image]: http://img.shields.io/npm/dm/bianco.events.svg?style=flat-square
[npm-url]: https://npmjs.org/package/bianco.events
## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
#### Table of Contents
- [add](#add)
- [Parameters](#parameters)
- [once](#once)
- [Parameters](#parameters-1)
- [remove](#remove)
- [Parameters](#parameters-2)
### add
Set a listener for all the events received separated by spaces
#### Parameters
- `els` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node/s where the listeners will be bound
- `evList` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** list of events we want to bind space separated
- `cb` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** listeners callback
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** event options (capture, once and passive)
Returns **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [NodeList](https://developer.mozilla.org/docs/Web/API/NodeList) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node/s and first argument of the function
### once
Set a listener using from a list of events triggering the callback only once
#### Parameters
- `els` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node where the listeners will be bound
- `evList` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** list of events we want to bind space separated
- `cb` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** listeners callback
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** event options (capture, once and passive)
Returns **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [NodeList](https://developer.mozilla.org/docs/Web/API/NodeList) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node/s and first argument of the function
### remove
Remove all the listeners for the events received separated by spaces
#### Parameters
- `els` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node/s where the events will be unbind
- `evList` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** list of events we want unbind space separated
- `cb` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** listeners callback
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** event options (capture, once and passive)
Returns **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [NodeList](https://developer.mozilla.org/docs/Web/API/NodeList) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** DOM node/s and first argument of the function
+29
View File
@@ -0,0 +1,29 @@
export function add<
Target extends EventTarget,
Callback extends EventListenerOrEventListenerObject,
>(
el: Target | Target[],
eventName: string,
callback: Callback,
options?: AddEventListenerOptions | boolean,
): Target
export function once<
Target extends EventTarget,
Callback extends EventListenerOrEventListenerObject,
>(
el: Target | Target[],
eventName: string,
callback: Callback,
options?: AddEventListenerOptions | boolean,
): Target
export function remove<
Target extends EventTarget,
Callback extends EventListenerOrEventListenerObject,
>(
el: Target | Target[],
eventName: string,
callback: Callback,
options?: EventListenerOptions | boolean,
): Target
+85
View File
@@ -0,0 +1,85 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var domToArray = require('bianco.dom-to-array');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var domToArray__default = /*#__PURE__*/_interopDefaultLegacy(domToArray);
/**
* Split a string into several items separed by spaces
* @param { string } l - events list
* @returns { Array } all the events detected
* @private
*/
const split = l => l.split(/\s/);
/**
* Set a listener for all the events received separated by spaces
* @param { HTMLElement|NodeList|Array } els - DOM node/s where the listeners will be bound
* @param { string } evList - list of events we want to bind or unbind space separated
* @param { Function } cb - listeners callback
* @param { string } method - either 'addEventListener' or 'removeEventListener'
* @param { Object } options - event options (capture, once and passive)
* @returns { undefined }
* @private
*/
function manageEvents(els, evList, cb, method, options) {
els = domToArray__default["default"](els);
split(evList).forEach((e) => {
els.forEach(el => el[method](e, cb, options || false));
});
}
/**
* Set a listener for all the events received separated by spaces
* @param { HTMLElement|Array } els - DOM node/s where the listeners will be bound
* @param { string } evList - list of events we want to bind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
function add(els, evList, cb, options) {
manageEvents(els, evList, cb, 'addEventListener', options);
return els
}
/**
* Set a listener using from a list of events triggering the callback only once
* @param { HTMLElement|Array } els - DOM node where the listeners will be bound
* @param { string } evList - list of events we want to bind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
function once(els, evList, cb, options) {
manageEvents(els, evList, cb, 'addEventListener', Object.assign(options || {}, { once: true }));
return els
}
/**
* Remove all the listeners for the events received separated by spaces
* @param { HTMLElement|Array } els - DOM node/s where the events will be unbind
* @param { string } evList - list of events we want unbind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
function remove(els, evList, cb, options) {
manageEvents(els, evList, cb, 'removeEventListener', options);
return els
}
var index_next = {
add,
once,
remove
};
exports.add = add;
exports["default"] = index_next;
exports.once = once;
exports.remove = remove;
+73
View File
@@ -0,0 +1,73 @@
import domToArray from 'bianco.dom-to-array'
/**
* Split a string into several items separed by spaces
* @param { string } l - events list
* @returns { Array } all the events detected
* @private
*/
const split = l => l.split(/\s/)
/**
* Set a listener for all the events received separated by spaces
* @param { HTMLElement|NodeList|Array } els - DOM node/s where the listeners will be bound
* @param { string } evList - list of events we want to bind or unbind space separated
* @param { Function } cb - listeners callback
* @param { string } method - either 'addEventListener' or 'removeEventListener'
* @param { Object } options - event options (capture, once and passive)
* @returns { undefined }
* @private
*/
function manageEvents(els, evList, cb, method, options) {
els = domToArray(els)
split(evList).forEach((e) => {
els.forEach(el => el[method](e, cb, options || false))
})
}
/**
* Set a listener for all the events received separated by spaces
* @param { HTMLElement|Array } els - DOM node/s where the listeners will be bound
* @param { string } evList - list of events we want to bind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
export function add(els, evList, cb, options) {
manageEvents(els, evList, cb, 'addEventListener', options)
return els
}
/**
* Set a listener using from a list of events triggering the callback only once
* @param { HTMLElement|Array } els - DOM node where the listeners will be bound
* @param { string } evList - list of events we want to bind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
export function once(els, evList, cb, options) {
manageEvents(els, evList, cb, 'addEventListener', Object.assign(options || {}, { once: true }))
return els
}
/**
* Remove all the listeners for the events received separated by spaces
* @param { HTMLElement|Array } els - DOM node/s where the events will be unbind
* @param { string } evList - list of events we want unbind space separated
* @param { Function } cb - listeners callback
* @param { Object } options - event options (capture, once and passive)
* @returns { HTMLElement|NodeList|Array } DOM node/s and first argument of the function
*/
export function remove(els, evList, cb, options) {
manageEvents(els, evList, cb, 'removeEventListener', options)
return els
}
export default {
add,
once,
remove
}
+50
View File
@@ -0,0 +1,50 @@
{
"name": "bianco.events",
"version": "1.1.1",
"description": "Modern DOM events helpers written in es2015",
"main": "index.js",
"jsnext:main": "index.next.js",
"module": "index.next.js",
"types": "index.d.ts",
"scripts": {
"prepare": "npm run build && npm test",
"lint": "eslint index.next.js test.js rollup.config.js",
"build": "rollup -c",
"doc": "documentation readme index.next.js -s API",
"test": "npm run lint && mocha test.js"
},
"files": [
"index.js",
"index.next.js",
"index.d.ts"
],
"repository": {
"type": "git",
"url": "git+https://github.com/biancojs/events.git"
},
"keywords": [
"es6",
"es2015",
"addEventListener",
"removeEventListener",
"DOM"
],
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/biancojs/events/issues"
},
"homepage": "https://github.com/biancojs/events#readme",
"devDependencies": {
"@gianlucaguarini/eslint-config": "^2.0.0",
"eslint": "^8.10.0",
"jsdom": "19.0.0",
"jsdom-global": "3.0.2",
"mocha": "^9.2.1",
"rollup": "^2.70.0",
"rollup-plugin-node-resolve": "^3.4.0"
},
"dependencies": {
"bianco.dom-to-array": "^1.1.0"
}
}