Numerous Bug Fixes
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 8s
This commit is contained in:
parent
02eefdac0e
commit
267d429122
959 changed files with 145571 additions and 221 deletions
21
frontend/node_modules/merge-refs/LICENSE
generated
vendored
Normal file
21
frontend/node_modules/merge-refs/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017–2024 Wojciech Maj
|
||||
|
||||
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.
|
||||
47
frontend/node_modules/merge-refs/README.md
generated
vendored
Normal file
47
frontend/node_modules/merge-refs/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
[](https://www.npmjs.com/package/merge-refs)  [](https://github.com/wojtekmaj/merge-refs/actions)
|
||||
|
||||
# Merge-Refs
|
||||
|
||||
A function that merges React refs into one. Filters out invalid (eg. falsy) refs as well and returns original ref if only one valid ref was given.
|
||||
|
||||
## tl;dr
|
||||
|
||||
- Install by executing `npm install merge-refs` or `yarn add merge-refs`.
|
||||
- Import by adding `import mergeRefs from 'merge-refs'`.
|
||||
- Use it in `ref` like so: `<div ref={mergeRefs(ref, someOtherRef)} />`
|
||||
|
||||
## Accepted refs
|
||||
|
||||
- Refs created using `createRef()`
|
||||
- Refs created using `useRef()`
|
||||
- Functional refs
|
||||
|
||||
## Example
|
||||
|
||||
```tsx
|
||||
function Hello() {
|
||||
const ref1 = useRef<HTMLDivElement>(); // I'm going to be updated!
|
||||
const ref2 = (element: HTMLDivElement) => {
|
||||
// I'm going to be called!
|
||||
};
|
||||
|
||||
return <div ref={mergeRefs(ref1, ref2)} />;
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
The MIT License.
|
||||
|
||||
## Author
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td >
|
||||
<img src="https://avatars.githubusercontent.com/u/5426427?v=4&s=128" width="64" height="64" alt="Wojciech Maj">
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://github.com/wojtekmaj">Wojciech Maj</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
70
frontend/node_modules/merge-refs/package.json
generated
vendored
Normal file
70
frontend/node_modules/merge-refs/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"name": "merge-refs",
|
||||
"version": "2.0.0",
|
||||
"description": "A function that merges React refs into one.",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"main": "./dist/index.js",
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./*": "./*"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.build.json",
|
||||
"clean": "rimraf dist",
|
||||
"format": "biome format",
|
||||
"lint": "biome lint",
|
||||
"prepack": "yarn clean && yarn build",
|
||||
"test": "yarn lint && yarn tsc && yarn format && yarn unit",
|
||||
"tsc": "tsc",
|
||||
"unit": "vitest"
|
||||
},
|
||||
"keywords": [
|
||||
"react",
|
||||
"react ref",
|
||||
"react refs",
|
||||
"merge"
|
||||
],
|
||||
"author": {
|
||||
"name": "Wojciech Maj",
|
||||
"email": "kontakt@wojtekmaj.pl"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.0",
|
||||
"@testing-library/dom": "^10.0.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/react": "*",
|
||||
"happy-dom": "^15.10.2",
|
||||
"husky": "^9.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"rimraf": "^6.0.0",
|
||||
"typescript": "^5.5.2",
|
||||
"vitest": "^3.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"provenance": true
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/wojtekmaj/merge-refs.git"
|
||||
},
|
||||
"funding": "https://github.com/wojtekmaj/merge-refs?sponsor=1",
|
||||
"packageManager": "yarn@4.3.1"
|
||||
}
|
||||
68
frontend/node_modules/merge-refs/src/index.spec.tsx
generated
vendored
Normal file
68
frontend/node_modules/merge-refs/src/index.spec.tsx
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { createRef } from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import mergeRefs from './index.js';
|
||||
|
||||
describe('mergeRefs()', () => {
|
||||
it('returns falsy result given no arguments', () => {
|
||||
const result = mergeRefs();
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns falsy result given falsy arguments', () => {
|
||||
const result = mergeRefs(null, null);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns original ref given only one ref', () => {
|
||||
const ref = vi.fn();
|
||||
|
||||
const result = mergeRefs(ref);
|
||||
|
||||
expect(result).toBe(ref);
|
||||
});
|
||||
|
||||
it('returns original ref given one ref and one falsy argument', () => {
|
||||
const ref = vi.fn();
|
||||
|
||||
const result = mergeRefs(ref, null);
|
||||
|
||||
expect(result).toBe(ref);
|
||||
});
|
||||
|
||||
it('returns merged refs properly', () => {
|
||||
const ref1 = vi.fn();
|
||||
const ref2 = createRef<HTMLDivElement>();
|
||||
|
||||
const result = mergeRefs(ref1, ref2);
|
||||
|
||||
expect(result).not.toBe(ref1);
|
||||
expect(result).toEqual(expect.any(Function));
|
||||
});
|
||||
|
||||
it('handles merged functional refs properly', () => {
|
||||
const ref1 = vi.fn();
|
||||
const ref2 = createRef<HTMLDivElement>();
|
||||
|
||||
const mergedRef = mergeRefs(ref1, ref2);
|
||||
|
||||
const { container } = render(<div ref={mergedRef} />);
|
||||
|
||||
expect(ref1).toHaveBeenCalledTimes(1);
|
||||
expect(ref1).toHaveBeenCalledWith(container.firstElementChild);
|
||||
});
|
||||
|
||||
it('handles merged object refs properly', () => {
|
||||
const ref1 = createRef<HTMLDivElement>();
|
||||
const ref2 = vi.fn();
|
||||
|
||||
const mergedRef = mergeRefs(ref1, ref2);
|
||||
|
||||
const { container } = render(<div ref={mergedRef} />);
|
||||
|
||||
expect(ref1.current).toBe(container.firstElementChild);
|
||||
});
|
||||
});
|
||||
35
frontend/node_modules/merge-refs/src/index.ts
generated
vendored
Normal file
35
frontend/node_modules/merge-refs/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import type * as React from 'react';
|
||||
|
||||
/**
|
||||
* A function that merges React refs into one.
|
||||
* Supports both functions and ref objects created using createRef() and useRef().
|
||||
*
|
||||
* Usage:
|
||||
* ```tsx
|
||||
* <div ref={mergeRefs(ref1, ref2, ref3)} />
|
||||
* ```
|
||||
*
|
||||
* @param {(React.Ref<T> | undefined)[]} inputRefs Array of refs
|
||||
* @returns {React.Ref<T> | React.RefCallback<T>} Merged refs
|
||||
*/
|
||||
export default function mergeRefs<T>(
|
||||
...inputRefs: (React.Ref<T> | undefined)[]
|
||||
): React.Ref<T> | React.RefCallback<T> {
|
||||
const filteredInputRefs = inputRefs.filter(Boolean);
|
||||
|
||||
if (filteredInputRefs.length <= 1) {
|
||||
const firstRef = filteredInputRefs[0];
|
||||
|
||||
return firstRef || null;
|
||||
}
|
||||
|
||||
return function mergedRefs(ref) {
|
||||
for (const inputRef of filteredInputRefs) {
|
||||
if (typeof inputRef === 'function') {
|
||||
inputRef(ref);
|
||||
} else if (inputRef) {
|
||||
(inputRef as React.MutableRefObject<T | null>).current = ref;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in a new issue