diff --git a/README.md b/README.md
index 29331c5..2397482 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ All React utilities, components and hooks are 100% SSR ready.
import { useMatchMedia } from '@krutoo/utils/react';
function App() {
- const isMobile = useMatchMedia('(max-width: 1024px)');
+ const mobile = useMatchMedia('(max-width: 1024px)');
return <>...>;
}
@@ -61,22 +61,12 @@ import * as utils from '@krutoo/utils/rspack';
export default {
entry: './src/index.ts',
plugins: [
- // typescript support (with alias from "paths" of tsconfig and `resolve.alias` extending)
utils.pluginTypeScript(),
-
- // css and css-modules support ("css-loader" must be added to your project)
utils.pluginCSS(),
-
- // html file will be added to bundle
- utils.pluginHTML({ template: './src/index.html' }),
-
- // import file source code by `?raw` query or `with { type: 'text' }`
+ utils.pluginHTML(),
utils.pluginRawImport(),
-
- // "public" folder will be copied to bundle
utils.pluginPublicFiles(),
-
- // ...and other
+ // ...and more
],
};
```
@@ -102,8 +92,6 @@ Repo description and how to work with
Test for module `{path}/{module}.ts` should be placed in `{path}/__test__/{module}.test.ts`.
-By default test environment is just Node.js environment.
-
For write tests with simulating browser environment you need to name test file like `*.web.test.ts`.
### Exports convention
diff --git a/docs/docs/dom/find-ancestor.mdx b/docs/docs/dom/find-ancestor.mdx
deleted file mode 100644
index 2817718..0000000
--- a/docs/docs/dom/find-ancestor.mdx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Callout } from '#components/callout/callout';
-
-export const meta = {
- title: 'findAncestor',
- category: 'DOM',
- menuPriority: 90,
-};
-
-# `findAncestor`
-
-
- Deprecated
-
- Use [findClosest](./?path=/dom/find-closest) with `element.parentElement` instead.
-
-
-
-Finds closest ancestor element that matches condition.
-
-```ts
-import { findAncestor } from '@krutoo/utils';
-
-const element = document.querySelector('#something');
-
-// element or null returns
-const closestTarget = findAncestor(element, parent => parent.classList.contains('target'));
-```
diff --git a/src/dom/__test__/find-ancestor.web.test.ts b/src/dom/__test__/find-ancestor.web.test.ts
deleted file mode 100644
index 3be7ad0..0000000
--- a/src/dom/__test__/find-ancestor.web.test.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { describe, test } from 'node:test';
-import { expect } from '@std/expect';
-import { findAncestor } from '../find-ancestor.ts';
-
-describe('findAncestor', () => {
- test('should find ancestor correctly', () => {
- const main = document.createElement('main');
- const article = document.createElement('article');
- const div = document.createElement('div');
- const p = document.createElement('p');
- const span = document.createElement('span');
-
- article.role = 'custom';
- div.id = 'block';
-
- document.body.append(main);
- main.append(article);
- article.append(div);
- div.append(p);
- p.append(span);
-
- expect(findAncestor(span, el => el.id === 'block')).toBe(div);
- expect(findAncestor(span, el => el.role === 'custom')).toBe(article);
- expect(findAncestor(span, el => el.tagName === 'MAIN')).toBe(main);
-
- expect(findAncestor(span, el => el.id === 'hello')).toBe(null);
- expect(findAncestor(span, el => el.role === 'foobar')).toBe(null);
- });
-});
diff --git a/src/dom/find-ancestor.ts b/src/dom/find-ancestor.ts
deleted file mode 100644
index 51627eb..0000000
--- a/src/dom/find-ancestor.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Finds closest ancestor element that matches condition.
- * @param element Target element to find ancestor.
- * @param predicate Function that check ancestor.
- * @returns Element or null.
- * @deprecated Use `findClosest(element.parentElement)` instead.
- */
-export function findAncestor(
- element: Element,
- predicate: (element: HTMLElement) => boolean,
-): HTMLElement | null {
- let parent: HTMLElement | null = element.parentElement;
-
- while (parent) {
- if (predicate(parent)) {
- return parent;
- }
-
- parent = parent.parentElement;
- }
-
- return parent;
-}
diff --git a/src/dom/mod.ts b/src/dom/mod.ts
index 5eac5f0..7b52955 100644
--- a/src/dom/mod.ts
+++ b/src/dom/mod.ts
@@ -1,4 +1,3 @@
export * from './find-closest.ts';
-export * from './find-ancestor.ts';
export * from './get-positioned-parent-offset.ts';
export * from './is-scrollable.ts';
diff --git a/src/store/create-store.ts b/src/store/create-store.ts
index 88bab70..068079c 100644
--- a/src/store/create-store.ts
+++ b/src/store/create-store.ts
@@ -1,26 +1,26 @@
import type { Store } from './types.ts';
/**
- * Creates "nano store".
+ * Creates "store" - subscribable state container.
* @param initialValue Initial value.
- * @returns Nano store.
+ * @returns Store.
*/
export function createStore(initialValue: T): Store {
const listeners = new Set();
- let currentValue: T = initialValue;
+ let value: T = initialValue;
return {
get(): T {
- return currentValue;
+ return value;
},
set(nextValue: T): void {
- if (Object.is(currentValue, nextValue)) {
+ if (Object.is(value, nextValue)) {
return;
}
- currentValue = nextValue;
+ value = nextValue;
for (const listener of listeners) {
listener();
diff --git a/src/store/types.ts b/src/store/types.ts
index 4e056ea..b000151 100644
--- a/src/store/types.ts
+++ b/src/store/types.ts
@@ -22,6 +22,6 @@ export interface Subscribable {
}
/**
- * "Nano store" - subscribable state container.
+ * "Store" - subscribable state container.
*/
export interface Store extends Subscribable, StateContainer {}
diff --git a/tsconfig.json b/tsconfig.json
index 045a4b2..34eabf8 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,6 +11,7 @@
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"isolatedModules": true,
+ "noUncheckedSideEffectImports": true,
"noUnusedLocals": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,