Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit 88a75a1

Browse files
authored
Merge pull request #102 from kamo88/develop
develop → master
2 parents fa1e155 + 0cdc639 commit 88a75a1

File tree

13 files changed

+543
-435
lines changed

13 files changed

+543
-435
lines changed

.github/actions/install/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ description: install node_modules
33
runs:
44
using: composite
55
steps:
6-
- uses: actions/checkout@v3
76
- uses: actions/setup-node@v3
87
with:
98
node-version-file: 'package.json'

.github/workflows/assign-author.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: assign-author-to-PR-&-chore/workflowISSUE
1+
name: assign author to PR
22
on:
33
pull_request:
44
types: [opened]

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI-for-pull-request
1+
name: CI for pull request
22
on: pull_request
33
jobs:
44
install:
@@ -16,7 +16,7 @@ jobs:
1616
- uses: ./.github/actions/install
1717
- run: npm run lint:all
1818
test:
19-
name: test
19+
name: test & coverage
2020
runs-on: ubuntu-latest
2121
needs: install
2222
steps:

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: package-publish-to-npm
1+
name: package publish to npm
22
on:
33
release:
44
types: [published]

.github/workflows/storybook-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: deploy-storybook-to-github-pages
1+
name: deploy storybook to github pages
22

33
on:
44
push:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
![NPM](https://img.shields.io/npm/l/%40kamo88%2Freact-dialog-hooks)
1+
![license](https://img.shields.io/npm/l/%40kamo88%2Freact-dialog-hooks)
22
![npm (scoped)](https://img.shields.io/npm/v/%40kamo88/react-dialog-hooks)
3-
[![pages-build-deployment](https://github.com/kamo88/react-dialog/actions/workflows/pages/pages-build-deployment/badge.svg?branch=main)](https://github.com/kamo88/react-dialog/actions/workflows/pages/pages-build-deployment)
4-
[![package-publish-to-npm](https://github.com/kamo88/react-dialog/actions/workflows/publish.yml/badge.svg?branch=main)](https://github.com/kamo88/react-dialog/actions/workflows/publish.yml)
3+
[![codecov](https://codecov.io/gh/kamo88/react-dialog-hooks/graph/badge.svg?token=W77V28C2TY)](https://codecov.io/gh/kamo88/react-dialog-hooks)
4+
[![pages-build-deployment](https://github.com/kamo88/react-dialog-hooks/actions/workflows/pages/pages-build-deployment/badge.svg?branch=gh-pages)](https://github.com/kamo88/react-dialog-hooks/actions/workflows/pages/pages-build-deployment)
55

66
```
77
npm i @kamo88/react-dialog-hooks

package-lock.json

Lines changed: 422 additions & 418 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kamo88/react-dialog-hooks",
3-
"version": "0.9.4",
3+
"version": "0.9.5",
44
"type": "module",
55
"description": "react use dialog hooks & dialog component",
66
"main": "./dist/umd/index.js",
@@ -74,15 +74,15 @@
7474
"lint-staged": "^14.0.1",
7575
"npm-run-all": "^4.1.5",
7676
"postcss": "^8.4.28",
77-
"prettier": "3.0.2",
77+
"prettier": "3.0.3",
7878
"prettier-plugin-tailwindcss": "^0.5.3",
7979
"react": "^17 || ^18",
8080
"react-dom": "^17 || ^18",
8181
"rollup-plugin-license": "^3.0.1",
8282
"rollup-plugin-visualizer": "^5.9.2",
8383
"storybook": "^7.3.2",
8484
"tailwindcss": "^3.3.3",
85-
"typescript": "~5.1",
85+
"typescript": "~5.2.0",
8686
"vite": "^4.4.5",
8787
"vite-plugin-dts": "^3.5.2",
8888
"vite-tsconfig-paths": "^4.2.0",
@@ -112,7 +112,7 @@
112112
},
113113
"homepage": "https://github.com/kamo88/react-dialog-hooks#readme",
114114
"volta": {
115-
"node": "18.17.0"
115+
"node": "18.17.1"
116116
},
117117
"engines": {
118118
"node": "^18",

renovate.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base",
5+
":timezone(Asia/Tokyo)",
6+
":automergePatch",
7+
"schedule:earlyMondays"
8+
],
9+
"enabledManagers": ["npm"],
10+
"ignoreDeps": ["npm"],
11+
"prHourlyLimit": 0,
12+
"packageRules": [
13+
{
14+
"extends": "packages:linters",
15+
"groupName": "linters",
16+
"packagePatterns": ["^@typescript-eslint/", "^prettier"]
17+
},
18+
{
19+
"matchPackageNames": [
20+
"react",
21+
"@types/react",
22+
"react-dom",
23+
"@types/react-dom"
24+
],
25+
"groupName": "react"
26+
}
27+
]
28+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { expect, test, describe } from 'vitest';
2+
3+
import { getIsDialogChild } from './getIsDialogChild';
4+
5+
describe('hooks/getIsDialogChild ※no use logic', () => {
6+
test('dialog: null', () => {
7+
const touchingContent = document.createElement('div');
8+
const isDialogChild = getIsDialogChild(touchingContent, null);
9+
expect(isDialogChild).toBe(false);
10+
});
11+
12+
test('touching dialog', () => {
13+
const dialog = document.createElement('dialog');
14+
const isDialogChild = getIsDialogChild(dialog, dialog);
15+
expect(isDialogChild).toBe(false);
16+
});
17+
18+
test('not child touchingContent no parent', () => {
19+
const touchingContent = document.createElement('div');
20+
const dialog = document.createElement('dialog');
21+
const isDialogChild = getIsDialogChild(touchingContent, dialog);
22+
expect(isDialogChild).toBe(false);
23+
});
24+
25+
test('not child touchingContent parent body', () => {
26+
const touchingContent = document.createElement('div');
27+
document.body.appendChild(touchingContent);
28+
const dialog = document.createElement('dialog');
29+
const isDialogChild = getIsDialogChild(touchingContent, dialog);
30+
expect(isDialogChild).toBe(false);
31+
});
32+
33+
test('is dialog`s grandchild element', () => {
34+
const touchingContentContainer = document.createElement('div');
35+
const touchingContent = document.createElement('div');
36+
touchingContentContainer.appendChild(touchingContent);
37+
const dialog = document.createElement('dialog');
38+
dialog.appendChild(touchingContentContainer);
39+
const isDialogChild = getIsDialogChild(touchingContent, dialog);
40+
expect(isDialogChild).toBe(true);
41+
});
42+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export type GetIsDialogChild = (
2+
el: HTMLElement | Element,
3+
dialog: HTMLDialogElement | null,
4+
) => boolean;
5+
6+
/**
7+
* on body-scroll-lock` s disableBodyScroll option allowTouchMove,
8+
* One accurate determination process.
9+
* Since there seems to be no problem without it, only the method is implemented for now.
10+
*/
11+
export const getIsDialogChild: GetIsDialogChild = (el, dialog) => {
12+
if (!dialog) return false;
13+
if (el === dialog) return false;
14+
15+
let { parentElement } = el;
16+
17+
while (parentElement && parentElement !== document.body) {
18+
if (parentElement === dialog) return true;
19+
parentElement = parentElement.parentElement;
20+
}
21+
return false;
22+
};

src/components/Dialog/hooks/useDialogPromise.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export const useDialogPromise = () => {
4242
* The dialog should appear on the entire screen.
4343
* The only touchable elements other than the dialog should be the dialog's child elements.
4444
*/
45-
disableBodyScroll(ref.current, { allowTouchMove: () => true });
45+
disableBodyScroll(ref.current, {
46+
allowTouchMove: () => true,
47+
});
4648
}
4749
promiseState.current = new Promise<DialogResponseState>((resolve) => {
4850
resolveState.current = resolve;

vite.config.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default defineConfig(({ mode }) => {
1111
const isAnalyze = mode === 'analyze';
1212
return {
1313
resolve: {
14+
/**
15+
* The combination of vite-tsconfig-paths and vite-plugin-dts does not resolve ailias when the d.ts file is created.
16+
* However, with other plugins,
17+
* it looked like the file creation was running twice, so I left it set to this configuration for the time being.
18+
*/
1419
alias: {
1520
'@': path.resolve(__dirname, 'src'),
1621
},
@@ -22,6 +27,10 @@ export default defineConfig(({ mode }) => {
2227
lib: {
2328
entry: path.resolve(__dirname, 'src/index.ts'),
2429
name: 'Kamo88Dialog', // When you build with umd, it is set in the window with this variable name.
30+
/**
31+
* By default, umd format is built in .cjs.
32+
* In unpkg, .cjs would be provided in text/plain format.(2023/9/2)
33+
*/
2534
fileName: (format) => `${format}/index.js`,
2635
formats: ['es', 'umd'],
2736
},
@@ -44,7 +53,11 @@ export default defineConfig(({ mode }) => {
4453
path.resolve(__dirname, 'src/**/*.test.*'),
4554
path.resolve(__dirname, 'src/**/*.stories.*'),
4655
path.resolve(__dirname, 'src/**/*.example.*'),
47-
path.resolve(__dirname, 'src/components/Dialog/DialogContainer.tsx'),
56+
path.resolve(
57+
__dirname,
58+
'src/components/Dialog/hooks/getIsDialogChild.ts',
59+
),
60+
path.resolve(__dirname, 'src/components/Dialog/DialogContainer.tsx'), // including Dialog
4861
],
4962
include: [
5063
path.resolve(__dirname, 'src/index.ts'),
@@ -54,10 +67,8 @@ export default defineConfig(({ mode }) => {
5467
}),
5568
license({
5669
thirdParty: {
57-
includePrivate: true, // Default is false.
5870
output: {
5971
file: path.join(__dirname, 'dist', 'dependencies.txt'),
60-
encoding: 'utf-8', // Default is utf-8.
6172
},
6273
},
6374
}),

0 commit comments

Comments
 (0)