├── .eslintrc.json
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── add-my-logo.yml
│ ├── bug-report.yml
│ ├── config.yml
│ └── feature-request.yml
├── PULL_REQUEST_TEMPLATE
│ ├── bug-fix.md
│ ├── documentation-update.md
│ └── new-feature.md
└── workflows
│ └── tests.yml
├── .gitignore
├── .idea
├── .gitignore
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── modules.xml
├── react-idle-timer.iml
├── runConfigurations
│ └── All_Tests.xml
└── vcs.xml
├── .npmignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── docs
├── configs
│ ├── docs.sidebar.json
│ └── site.config.ts
├── contentlayer.config.ts
├── layouts
│ ├── index.tsx
│ └── mdx.tsx
├── next-env.d.ts
├── next.config.js
├── next.i18n.config.js
├── next.redirect.js
├── package-lock.json
├── package.json
├── pages
│ ├── 404.tsx
│ ├── _app.tsx
│ ├── _document.tsx
│ ├── demo.tsx
│ ├── docs
│ │ ├── [[...slug]].tsx
│ │ ├── about
│ │ │ ├── changelog.mdx
│ │ │ ├── contributing.mdx
│ │ │ └── license.mdx
│ │ ├── api
│ │ │ ├── idle-timer-provider.mdx
│ │ │ ├── methods.mdx
│ │ │ ├── props.mdx
│ │ │ ├── types.mdx
│ │ │ ├── use-idle-timer.mdx
│ │ │ └── with-idle-timer.mdx
│ │ ├── features
│ │ │ ├── activity-detection.mdx
│ │ │ ├── confirm-prompt.mdx
│ │ │ ├── cross-tab.mdx
│ │ │ └── idle-detection.mdx
│ │ └── getting-started
│ │ │ ├── installation.mdx
│ │ │ ├── new.mdx
│ │ │ └── testing.mdx
│ └── index.tsx
├── public
│ ├── favicon.png
│ ├── fonts
│ │ └── Inter.woff2
│ ├── locales
│ │ └── en
│ │ │ └── common.json
│ ├── logos
│ │ └── edgemesh-logo.png
│ ├── og-image.png
│ ├── robots.txt
│ ├── square-logo.png
│ └── twitter-og-image.png
├── sponsors.json
├── src
│ ├── components
│ │ ├── Announcer.tsx
│ │ ├── ChakraNextImage.tsx
│ │ ├── Container.tsx
│ │ ├── ControlDrawer.tsx
│ │ ├── Demo.tsx
│ │ ├── DiscordBar.tsx
│ │ ├── EditPageButton.tsx
│ │ ├── Features.tsx
│ │ ├── FontFace.tsx
│ │ ├── Footer.tsx
│ │ ├── Header.tsx
│ │ ├── HeaderIconButtons.tsx
│ │ ├── Hero.tsx
│ │ ├── Logo.tsx
│ │ ├── MobileNav.tsx
│ │ ├── PageContainer.tsx
│ │ ├── PageTransition.tsx
│ │ ├── Pagination.tsx
│ │ ├── SEO.tsx
│ │ ├── Sidebar.tsx
│ │ ├── SidebarCategory.tsx
│ │ ├── SidebarLink.tsx
│ │ ├── SponsorButton.tsx
│ │ ├── Sponsors.tsx
│ │ ├── Stats.tsx
│ │ ├── TableOfContents.tsx
│ │ ├── UsedBy.tsx
│ │ ├── Window.tsx
│ │ └── mdx
│ │ │ ├── Anchor.tsx
│ │ │ ├── CodeBlock.tsx
│ │ │ ├── CodeBlockStyles.ts
│ │ │ ├── CodeContainer.tsx
│ │ │ ├── CodeSandbox.tsx
│ │ │ ├── CodeSandboxButton.tsx
│ │ │ ├── ComponentLinks.tsx
│ │ │ ├── CopyButton.tsx
│ │ │ ├── Highlight.tsx
│ │ │ ├── InlineCode.tsx
│ │ │ ├── LinkedHeading.tsx
│ │ │ ├── Pre.tsx
│ │ │ ├── Property.tsx
│ │ │ ├── Table.tsx
│ │ │ └── index.tsx
│ ├── hooks
│ │ ├── useRouteChanged.ts
│ │ └── useScrollSpy.ts
│ ├── theme
│ │ ├── config.ts
│ │ ├── index.ts
│ │ ├── mdx.ts
│ │ └── textStyles.ts
│ └── utils
│ │ ├── convertBackticks.tsx
│ │ ├── debounce.ts
│ │ ├── findRouteByPath.ts
│ │ ├── ga.ts
│ │ ├── getCodeQuality.ts
│ │ ├── getDiscordMembers.ts
│ │ ├── getGithubStars.ts
│ │ ├── getNpmDownloads.ts
│ │ ├── getRouteContext.ts
│ │ ├── getSponsors.ts
│ │ ├── getTestCoverage.ts
│ │ ├── getUsedBy.ts
│ │ ├── i18n.ts
│ │ ├── mdx.ts
│ │ ├── numberFormatter.ts
│ │ ├── rehype.ts
│ │ └── seo.ts
├── tsconfig.json
└── usedby.json
├── jest.config.mjs
├── logo.svg
├── package-lock.json
├── package-scripts.js
├── package.json
├── scripts
└── build.js
├── src
├── IdleTimerContext.tsx
├── TabManager
│ ├── BroadcastChannel.ts
│ ├── LeaderElector.ts
│ └── index.ts
├── index.ts
├── types
│ ├── EventType.ts
│ ├── EventsType.ts
│ ├── FnType.ts
│ ├── IEventHandler.ts
│ ├── IIdleTimer.ts
│ ├── IIdleTimerContext.ts
│ ├── IIdleTimerProps.ts
│ ├── IMessageHandler.ts
│ ├── IPresenceChangeHandler.ts
│ ├── ITimers.ts
│ ├── MessageActionType.ts
│ ├── MessageType.ts
│ └── PresenceType.ts
├── useIdleTimer.tsx
├── utils
│ ├── debounce.ts
│ ├── defaults.ts
│ ├── isBrowser.ts
│ ├── now.ts
│ ├── sleep.ts
│ ├── throttle.ts
│ ├── timers.ts
│ └── token.ts
└── withIdleTimer.tsx
├── tests
├── BroadcastChannel.test.ts
├── IdleTimerProvider.test.tsx
├── LeaderElector.test.ts
├── SSR.test.tsx
├── TabManager.test.ts
├── bundle.test.tsx
├── index.d.ts
├── test.setup.ts
├── test.utils.ts
├── useIdleTimer.test.ts
└── withIdleTimer.test.tsx
├── tsconfig.base.json
├── tsconfig.build.json
└── tsconfig.json
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es2021": true,
5 | "jest/globals": true
6 | },
7 | "extends": [
8 | "plugin:react/recommended",
9 | "plugin:@next/next/recommended",
10 | "standard"
11 | ],
12 | "settings": {
13 | "react": {
14 | "version": "latest"
15 | }
16 | },
17 | "parser": "@typescript-eslint/parser",
18 | "parserOptions": {
19 | "ecmaFeatures": {
20 | "jsx": true
21 | },
22 | "ecmaVersion": "latest",
23 | "sourceType": "module"
24 | },
25 | "plugins": [
26 | "jest",
27 | "react",
28 | "@typescript-eslint"
29 | ],
30 | "rules": {
31 | "no-unused-vars": "off",
32 | "@typescript-eslint/no-unused-vars": "error",
33 | "react/react-in-jsx-scope": "off",
34 | "jest/no-disabled-tests": "warn",
35 | "jest/no-focused-tests": "warn",
36 | "jest/no-identical-title": "error",
37 | "jest/prefer-to-have-length": "warn",
38 | "jest/valid-expect": "error"
39 | },
40 | "ignorePatterns": [
41 | "**/dist/**",
42 | "**/out/**"
43 | ]
44 | }
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: SupremeTechnopriest
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/add-my-logo.yml:
--------------------------------------------------------------------------------
1 | name: 🎨 Add My Logo
2 | description: Add your logo to the Documentation Site.
3 | title: "🎨 "
4 | labels: ["triage", "docs"]
5 | assignees:
6 | - supremetechnopriest
7 | body:
8 | - type: markdown
9 | attributes:
10 | value: |
11 | Thank you for adding your logo to the Documentation Site!
12 | - type: input
13 | id: name
14 | attributes:
15 | label: What is your company name?
16 | description: "Your company name will be used for the tooltip when you hover over your logo."
17 | placeholder: "My Company"
18 | validations:
19 | required: true
20 | - type: input
21 | id: link
22 | attributes:
23 | label: What is your website?
24 | description: "Your website will be used as the href when your logo is clicked."
25 | placeholder: "https://my.co"
26 | value: "https://"
27 | validations:
28 | required: true
29 | - type: textarea
30 | id: logo
31 | attributes:
32 | label: Upload your logo.
33 | description: Your logo should be exactly 100px high.
34 | validations:
35 | required: true
36 | - type: checkboxes
37 | id: verified
38 | attributes:
39 | label: Sponsorship
40 | description: No worries if you are not. This is used for positioning of your logo.
41 | options:
42 | - label: Are you a sponsor of Idle Timer?
43 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.yml:
--------------------------------------------------------------------------------
1 | name: 🐞 Bug Report
2 | description: Report a bug found in IdleTimer.
3 | title: "🐞 "
4 | labels: ["triage", "bug"]
5 | assignees:
6 | - supremetechnopriest
7 | body:
8 | - type: markdown
9 | attributes:
10 | value: |
11 | Thank you for taking the time to fill out this bug report!
12 | - type: textarea
13 | id: what-happened
14 | attributes:
15 | label: What happened?
16 | description: Also tell us, what did you expect to happen?
17 | placeholder: Tell us what you see!
18 | validations:
19 | required: true
20 | - type: textarea
21 | id: reproduction
22 | attributes:
23 | label: Reproduction Steps
24 | description: "How do you trigger this bug? Please walk us through it step by step."
25 | value: |
26 | 1.
27 | 2.
28 | 3.
29 | ...
30 | render: bash
31 | validations:
32 | required: true
33 | - type: textarea
34 | id: logs
35 | attributes:
36 | label: Relevant log output
37 | description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
38 | render: bash
39 | - type: textarea
40 | id: context
41 | attributes:
42 | label: Screenshots or Additional Context
43 | description: Add any screenshots or provide additional context that may be helpful in resolving the issue.
44 | - type: dropdown
45 | id: version
46 | attributes:
47 | label: Module Version
48 | description: Select the version you are running.
49 | options:
50 | - 5.7.2
51 | - 5.7.1
52 | - 5.7.0
53 | - 5.6.2
54 | - 5.6.1
55 | - 5.6.0
56 | - 5.5.3
57 | - 5.5.2
58 | - 5.5.1
59 | - 5.5.0
60 | - 5.4.2
61 | - 5.4.1
62 | - 5.4.0
63 | - 5.3.0
64 | - 5.2.0
65 | - 5.1.3
66 | - 5.1.2
67 | - 5.1.1
68 | - 5.1.0
69 | - 5.0.0
70 | - 4.*.*
71 | - 3.*.*
72 | - 2.*.*
73 | - 1.*.*
74 | - 0.*.*
75 | validations:
76 | required: true
77 | - type: dropdown
78 | id: browsers
79 | attributes:
80 | label: What browsers are you seeing the problem on? Select all that apply.
81 | multiple: true
82 | options:
83 | - Firefox
84 | - Chrome
85 | - Safari
86 | - Microsoft Edge
87 | - Other
88 | - type: dropdown
89 | id: devices
90 | attributes:
91 | label: What devices are you seeing the problem on?
92 | multiple: true
93 | options:
94 | - Desktop
95 | - Mobile
96 | - Tablet
97 | - Wearable
98 | - Other
99 | - type: checkboxes
100 | id: verify
101 | attributes:
102 | label: Verification
103 | description: Please check closed issues and discussions before opening a new issue.
104 | options:
105 | - label: I have checked for existing closed issues and discussions.
106 | required: true
107 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: ❓ Question or Other
4 | url: https://github.com/SupremeTechnopriest/react-idle-timer/discussions/new/choose
5 | about: Ask a question or start a discussion.
6 | - name: 📖 Documentation
7 | url: https://idletimer.dev/
8 | about: Explore detailed documentation and examples.
9 | - name: 💬 Join the Community
10 | url: https://discord.gg/YPuxNdWA4D
11 | about: Join our discord community for announcements and support.
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request.yml:
--------------------------------------------------------------------------------
1 | name: ⚡️ Feature Request
2 | description: Suggest a feature you would like to see supported in IdleTimer.
3 | title: "⚡️ "
4 | labels: ["triage", "enhancement"]
5 | assignees:
6 | - supremetechnopriest
7 | body:
8 | - type: markdown
9 | attributes:
10 | value: |
11 | Thank you for taking the time to suggest this feature!
12 | - type: textarea
13 | id: problem
14 | attributes:
15 | label: What problem does your feature request solve?
16 | description: A clear and concise description of what the problem is.
17 | placeholder: Tell us the problem!
18 | validations:
19 | required: true
20 | - type: textarea
21 | id: solution
22 | attributes:
23 | label: Describe the solution you are proposing.
24 | description: A clear and concise description of what you would like to see implemented.
25 | placeholder: Tell us the solution!
26 | validations:
27 | required: true
28 | - type: textarea
29 | id: alternatives
30 | attributes:
31 | label: Describe alternatives you have considered.
32 | description: A clear and concise description of any alternative solutions or features you have considered.
33 | placeholder: Tell us about any alternatives!
34 | - type: dropdown
35 | id: importance
36 | attributes:
37 | label: Importance
38 | description: How important is this feature to you?
39 | options:
40 | - I Need It
41 | - Nice to Have
42 | - Could Live Without
43 | validations:
44 | required: true
45 | - type: checkboxes
46 | id: context
47 | attributes:
48 | label: Additional Context
49 | description: Help us understand the severity of this missing feature. Check all that apply.
50 | options:
51 | - label: This missing feature presents as a bug.
52 | - label: This missing feature is forcing me to consider alternatives.
53 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/bug-fix.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🐞 Bug Fix
3 | labels: triage, bug
4 | about: Fix a bug in the IdleTimer Source or Documentation.
5 | ---
6 |
7 | ## Pre Submission Checklist
8 |
9 |
10 |
11 | ### Type of Change
12 | - [x] Bug fix.
13 | - [ ] New feature.
14 | - [ ] Documentation update.
15 |
16 | ### Requirements
17 | - [ ] I have read the [**CONTRIBUTING**](CONTRIBUTING.md) document.
18 | - [ ] I have followed the [**Commit Message Guidelines**](CONTRIBUTING.md#git-commit-messages).
19 | - [ ] My code passes the eslint style.
20 |
21 | ### Documentation
22 | - [ ] My change requires a change to the documentation.
23 | - [ ] I have updated the documentation accordingly.
24 |
25 | ### Automated Tests
26 | - [ ] My change does not require any additional tests to maintain full coverage.
27 | - [ ] I have added tests to cover any critical components of my change.
28 | - [ ] The test suite is passing.
29 |
30 | ## Issues this Pull Request Resolves
31 |
32 |
33 |
34 | ## Additional Context
35 |
36 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/documentation-update.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 📝 Documentation Update
3 | labels: triage, docs
4 | about: Update to Documentation or Examples.
5 | ---
6 |
7 | ## Pre Submission Checklist
8 |
9 |
10 |
11 | ### Type of Change
12 | - [ ] Bug fix.
13 | - [ ] New feature.
14 | - [x] Documentation update.
15 |
16 | ### Requirements
17 | - [ ] I have read the [**CONTRIBUTING**](CONTRIBUTING.md) document.
18 | - [ ] I have followed the [**Commit Message Guidelines**](CONTRIBUTING.md#git-commit-messages).
19 | - [ ] My code passes the eslint style.
20 |
21 | ### Documentation
22 | - [x] My change requires a change to the documentation.
23 | - [x] I have updated the documentation accordingly.
24 |
25 | ### Automated Tests
26 | - [x] My change does not require any additional tests to maintain full coverage.
27 | - [ ] I have added tests to cover any critical components of my change.
28 | - [x] The test suite is passing.
29 |
30 | ## Issues this Pull Request Resolves
31 |
32 |
33 |
34 | ## Additional Context
35 |
36 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/new-feature.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: ⚡️ New Feature
3 | labels: triage, enhancement
4 | about: Implement a New Feature.
5 | ---
6 |
7 | ## Pre Submission Checklist
8 |
9 |
10 |
11 | ### Type of Change
12 | - [ ] Bug fix.
13 | - [x] New feature.
14 | - [ ] Documentation update.
15 |
16 | ### Requirements
17 | - [ ] I have read the [**CONTRIBUTING**](CONTRIBUTING.md) document.
18 | - [ ] I have followed the [**Commit Message Guidelines**](CONTRIBUTING.md#git-commit-messages).
19 | - [ ] My code passes the eslint style.
20 |
21 | ### Documentation
22 | - [ ] My change requires a change to the documentation.
23 | - [ ] I have updated the documentation accordingly.
24 |
25 | ### Automated Tests
26 | - [ ] My change does not require any additional tests to maintain full coverage.
27 | - [ ] I have added tests to cover any critical components of my change.
28 | - [ ] The test suite is passing.
29 |
30 | ## Issues this Pull Request Resolves
31 |
32 |
33 |
34 | ## Additional Context
35 |
36 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | name: tests
2 | on:
3 | push:
4 | branches:
5 | - master
6 | tags:
7 | - '!*'
8 | paths:
9 | - .github/workflows/*
10 | - src/**
11 | - '*.json'
12 | - '!*.MD'
13 | - '!docs/**'
14 | pull_request:
15 | paths:
16 | - .github/workflows/*
17 | - src/**
18 | - '*.json'
19 | - '!*.MD'
20 | - '!docs/**'
21 | jobs:
22 | test:
23 | name: Test
24 | runs-on: ubuntu-latest
25 | steps:
26 | - uses: actions/checkout@master
27 | - uses: actions/setup-node@master
28 | with:
29 | node-version: '18'
30 | - name: Install Modules
31 | run: npm i
32 | - name: Build Package
33 | run: npm run build
34 | - name: Run Tests
35 | run: npm t
36 | - name: Upload Coverage
37 | uses: paambaati/codeclimate-action@v3.2.0
38 | env:
39 | CC_TEST_REPORTER_ID: fff55059c877f2d5091c8a89cb5bebd3bcf12811355ce9e109e35f78c4bef96c
40 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Node
6 | #
7 | node_modules
8 | npm-debug.log*
9 |
10 | # Next
11 | #
12 | .next
13 | .contentlayer
14 |
15 | # Application
16 | #
17 | dist
18 | out
19 | worker
20 | coverage
21 |
22 | # Environments
23 | #
24 | .env.local
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
55 |
56 |
57 |
58 |
56 | {tokens.map((line, i) => { 57 | const lineProps = getLineProps({ line, key: i }) 58 | return ( 59 |77 |65 | {showLines && ( 66 | 74 | ) 75 | })} 76 |67 | {i + 1} 68 | 69 | )} 70 | {line.map((token, key) => ( 71 | 72 | ))} 73 |
{convertBackticks(props.description)}
48 |extends Component
{ 41 | /** 42 | * Function to call when the users presence state changes. 43 | */ 44 | onPresenceChange? (presence: PresenceType): void 45 | /** 46 | * When promptTimeout is set, this function is called after the user becomes 47 | * idle. This is useful for displaying a confirm prompt. If the prompt timeout 48 | * is reached, onIdle is then called. 49 | */ 50 | onPrompt? (): void 51 | /** 52 | * Function to call when user is idle. 53 | */ 54 | onIdle? (): void 55 | /** 56 | * Function to call when user becomes active. 57 | */ 58 | onActive? (event: Event): void 59 | /** 60 | * Function to call on user activity. Can be throttled or debounced using the 61 | * `throttle` and `debounce` props. 62 | */ 63 | onAction? (event: Event): void 64 | /** 65 | * Function to call when message is has been emitted. 66 | */ 67 | onMessage? (data: any): void 68 | } 69 | 70 | export class IdleTimerComponent
extends IIdleTimerComponent
{
71 | constructor (props: P & IIdleTimerComponentProps) {
72 | super(props)
73 | if (this.onPresenceChange) props.setOnPresenceChange(this.onPresenceChange.bind(this))
74 | if (this.onPrompt) props.setOnPrompt(this.onPrompt.bind(this))
75 | if (this.onIdle) props.setOnIdle(this.onIdle.bind(this))
76 | if (this.onActive) props.setOnActive(this.onActive.bind(this))
77 | if (this.onAction) props.setOnAction(this.onAction.bind(this))
78 | if (this.onMessage) props.setOnMessage(this.onMessage.bind(this))
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/tests/IdleTimerProvider.test.tsx:
--------------------------------------------------------------------------------
1 | import { Component, ContextType } from 'react'
2 | import { render, screen } from '@testing-library/react'
3 | import '@testing-library/jest-dom'
4 |
5 | import {
6 | IIdleTimerContext,
7 | IdleTimerContext,
8 | IdleTimerProvider,
9 | IdleTimerConsumer,
10 | useIdleTimerContext
11 | } from '../src'
12 |
13 | describe('IdleTimerProvider', () => {
14 | it('Should expose the API to nested class components', () => {
15 | class Child extends Component<{}, {}> {
16 | static contextType = IdleTimerContext
17 | declare context: ContextType