@tebuto/react-booking-widget 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ target-branch: main
6
+ schedule:
7
+ interval: "monthly"
8
+ assignees:
9
+ - "jonasscholl"
10
+ groups:
11
+ all:
12
+ patterns:
13
+ - "*"
@@ -0,0 +1,70 @@
1
+ name: "Branch"
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ tests:
11
+ name: Tests
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout Repository
15
+ uses: actions/checkout@v4
16
+
17
+ - uses: pnpm/action-setup@v4
18
+ with:
19
+ version: 9
20
+
21
+ - uses: actions/setup-node@v4
22
+ with:
23
+ node-version: '22.x'
24
+ cache: 'pnpm'
25
+ cache-dependency-path: 'pnpm-lock.yaml'
26
+
27
+ - name: Install dependencies
28
+ run: |
29
+ pnpm install --frozen-lockfile
30
+
31
+ - name: Linting
32
+ run: pnpm run lint
33
+
34
+ - name: Tests
35
+ run: pnpm run test
36
+
37
+ scan:
38
+ name: SonarQube Scan
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - name: Checkout Repository
42
+ uses: actions/checkout@v4
43
+ with:
44
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
45
+
46
+ - uses: pnpm/action-setup@v4
47
+ with:
48
+ version: 9
49
+
50
+ - uses: actions/setup-node@v4
51
+ with:
52
+ node-version: '22.x'
53
+ cache: 'pnpm'
54
+
55
+ - name: Install dependencies
56
+ run: |
57
+ pnpm install --frozen-lockfile
58
+
59
+ - name: Scan
60
+ uses: sonarsource/sonarqube-scan-action@v4
61
+ env:
62
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
63
+ SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
64
+
65
+ - name: Quality Gate
66
+ uses: sonarsource/sonarqube-quality-gate-action@v1
67
+ timeout-minutes: 5
68
+ env:
69
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
70
+
@@ -0,0 +1,43 @@
1
+ name: Publish NPM Package
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+
8
+ jobs:
9
+ publish:
10
+ name: Publish to npm
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write # Required for provenance generation
14
+ contents: read
15
+ steps:
16
+ - name: Checkout Repository
17
+ uses: actions/checkout@v4
18
+
19
+ - uses: pnpm/action-setup@v4
20
+ with:
21
+ version: 9
22
+
23
+ - uses: actions/setup-node@v4
24
+ with:
25
+ node-version: '22.x'
26
+ cache: 'pnpm'
27
+ cache-dependency-path: 'pnpm-lock.yaml'
28
+ registry-url: 'https://registry.npmjs.org'
29
+
30
+ - name: Install dependencies
31
+ run: |
32
+ pnpm install --frozen-lockfile
33
+
34
+ - name: Linting
35
+ run: pnpm run lint
36
+
37
+ - name: Tests
38
+ run: pnpm run test
39
+
40
+ - name: Publish to npm
41
+ run: npm publish --provenance --access public
42
+ env:
43
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,2 @@
1
+ npm run format
2
+ npm run lint
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["biomejs.biome", "yzhang.markdown-all-in-one", "firsttris.vscode-jest-runner"]
3
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "editor.defaultFormatter": "biomejs.biome",
3
+ "editor.codeActionsOnSave": {
4
+ "source.organizeImports.biome": "always",
5
+ "quickfix.biome": "always"
6
+ },
7
+ "files.insertFinalNewline": true,
8
+ "[typescript]": {
9
+ "editor.defaultFormatter": "biomejs.biome"
10
+ },
11
+ "[json]": {
12
+ "editor.defaultFormatter": "biomejs.biome"
13
+ },
14
+ "[typescriptreact]": {
15
+ "editor.defaultFormatter": "biomejs.biome"
16
+ }
17
+ }
package/LICENCE ADDED
@@ -0,0 +1,8 @@
1
+ Copyright 2025 Tebuto GmbH
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
8
+
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+
2
+ <div align="center">
3
+ <img alt="Tebuto" src="https://tebuto.de/assets/logo.svg" width="400" />
4
+ </div>
5
+
6
+ <p align="center">A <a href="https://react.dev" target="_blank">React</a> component for integrating the <a href="https://tebuto.de" target="_blank">Tebuto</a> booking widget into your own website.
7
+ <p align="center">
8
+
9
+ <div align="center">
10
+ <a href="https://www.npmjs.com/package/jest"><img alt="NPM Version" src="https://img.shields.io/npm/v/%40tebuto%2Freact-booking-widget"></a>
11
+ <a href="https://github.com/jestjs/jest/blob/main/LICENSE"> <img alt="@tebuto/react-booking-widget is released under a MIT licence" src="https://img.shields.io/npm/l/%40tebuto%2Freact-booking-widget"></a>
12
+ <a href="https://github.com/jestjs/jest/actions/workflows/branch.yaml"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/tebuto/react-booking-widget/.github%2Fworkflows%2Fbranch.yaml?label=CI&logo=GitHub"></a>
13
+ </div>
14
+ <hr />
package/biome.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
3
+ "organizeImports": {
4
+ "enabled": true
5
+ },
6
+ "formatter": {
7
+ "enabled": true,
8
+ "formatWithErrors": false,
9
+ "indentWidth": 4,
10
+ "indentStyle": "space",
11
+ "lineWidth": 120,
12
+ "ignore": ["node_modules/**", "dist/**"]
13
+ },
14
+ "linter": {
15
+ "enabled": true,
16
+ "rules": {
17
+ "recommended": true,
18
+ "style": {
19
+ "useImportType": "off",
20
+ "useNodejsImportProtocol": "off"
21
+ },
22
+ "complexity": {
23
+ "noForEach": "off",
24
+ "noBannedTypes": "off"
25
+ },
26
+ "suspicious": {
27
+ "noExplicitAny": "off",
28
+ "noThenProperty": "off",
29
+ "noArrayIndexKey": "off"
30
+ },
31
+ "a11y": {
32
+ "useKeyWithClickEvents": "off"
33
+ },
34
+ "correctness": {
35
+ "useExhaustiveDependencies": "off"
36
+ }
37
+ },
38
+ "ignore": ["node_modules/**", "dist/**"]
39
+ },
40
+ "javascript": {
41
+ "parser": {
42
+ "unsafeParameterDecoratorsEnabled": true
43
+ },
44
+ "formatter": {
45
+ "enabled": true,
46
+ "indentStyle": "space",
47
+ "indentWidth": 4,
48
+ "lineWidth": 180,
49
+ "arrowParentheses": "asNeeded",
50
+ "trailingCommas": "none",
51
+ "quoteStyle": "single",
52
+ "semicolons": "asNeeded"
53
+ }
54
+ },
55
+ "json": {
56
+ "formatter": {
57
+ "enabled": true,
58
+ "indentStyle": "space",
59
+ "indentWidth": 4,
60
+ "lineWidth": 180
61
+ },
62
+ "parser": {
63
+ "allowComments": true
64
+ }
65
+ }
66
+ }
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@tebuto/react-booking-widget",
3
+ "version": "1.0.0",
4
+ "description": "React Component for the Tebuto Booking Widget",
5
+ "author": "Tebuto GmbH",
6
+ "homepage": "https://tebuto.de",
7
+ "license": "MIT",
8
+ "main": "dist/cjs/index.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "test": "jest",
13
+ "build": "rollup -c --bundleConfigAsCjs",
14
+ "prepare": "husky",
15
+ "lint": "biome lint .",
16
+ "lint:fix": "biome check --write .",
17
+ "format": "biome format --write --error-on-warnings ."
18
+ },
19
+ "peerDependencies": {
20
+ "react": "^19.0.0",
21
+ "react-dom": "^19.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@babel/core": "7.26.0",
25
+ "@babel/preset-env": "7.26.0",
26
+ "@babel/preset-react": "7.26.3",
27
+ "@babel/preset-typescript": "7.26.0",
28
+ "@biomejs/biome": "1.9.4",
29
+ "@rollup/plugin-commonjs": "28.0.2",
30
+ "@rollup/plugin-node-resolve": "16.0.0",
31
+ "@rollup/plugin-terser": "0.4.4",
32
+ "@rollup/plugin-typescript": "12.1.2",
33
+ "@testing-library/react": "16.1.0",
34
+ "@types/jest": "29.5.14",
35
+ "@types/react": "19.0.4",
36
+ "babel-jest": "29.7.0",
37
+ "husky": "9.1.7",
38
+ "jest": "29.7.0",
39
+ "jest-environment-jsdom": "29.7.0",
40
+ "rollup": "4.30.1",
41
+ "rollup-plugin-dts": "6.1.1",
42
+ "rollup-plugin-peer-deps-external": "2.2.4",
43
+ "tslib": "2.8.1",
44
+ "typescript": "5.7.3"
45
+ },
46
+ "jest": {
47
+ "testEnvironment": "jsdom"
48
+ },
49
+ "babel": {
50
+ "presets": [
51
+ "@babel/preset-env",
52
+ "@babel/preset-typescript",
53
+ [
54
+ "@babel/preset-react",
55
+ {
56
+ "runtime": "automatic"
57
+ }
58
+ ]
59
+ ]
60
+ },
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "https://github.com/tebuto/react-booking-widget.git"
64
+ },
65
+ "bugs": {
66
+ "url": "https://github.com/tebuto/react-booking-widget/issues"
67
+ },
68
+ "engines": {
69
+ "node": ">=22"
70
+ },
71
+ "keywords": ["appointment", "booking", "calendar", "react", "tebuto", "widget", "online", "therapist", "psychologist"],
72
+ "publishConfig": {
73
+ "access": "public"
74
+ }
75
+ }
@@ -0,0 +1,33 @@
1
+ import commonjs from '@rollup/plugin-commonjs'
2
+ import resolve from '@rollup/plugin-node-resolve'
3
+ import terser from '@rollup/plugin-terser'
4
+ import typescript from '@rollup/plugin-typescript'
5
+ import dts from 'rollup-plugin-dts'
6
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external'
7
+
8
+ const packageJson = require('./package.json')
9
+
10
+ export default [
11
+ {
12
+ input: 'src/index.ts',
13
+ output: [
14
+ {
15
+ file: packageJson.main,
16
+ format: 'cjs',
17
+ sourcemap: true
18
+ },
19
+ {
20
+ file: packageJson.module,
21
+ format: 'esm',
22
+ sourcemap: true
23
+ }
24
+ ],
25
+ plugins: [peerDepsExternal(), resolve(), commonjs(), typescript({ tsconfig: './tsconfig.json' }), terser()],
26
+ external: ['react', 'react-dom']
27
+ },
28
+ {
29
+ input: 'src/index.ts',
30
+ output: [{ file: 'dist/types.d.ts', format: 'es' }],
31
+ plugins: [dts.default()]
32
+ }
33
+ ]
@@ -0,0 +1,2 @@
1
+ sonar.projectKey=tebuto_react-booking-widget_AZRV_ItoN-5fLbAnu7oy
2
+ sonar.sourceEncoding=UTF-8
@@ -0,0 +1,62 @@
1
+ import { render, screen } from '@testing-library/react'
2
+ import { TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, TEBUTO_BOOKING_WIDGET_SCRIPT_URL } from '../constants'
3
+ import TebutoBookingWidget from './TebutoBookingWidget'
4
+
5
+ describe('TebutoBookingWidget', () => {
6
+ const therapistUUID = '9fddab56-5dd5-4bc4-b1bd-3b1d52eb952f'
7
+
8
+ it('should add a script tag to load the Tebuto Booking Widget to the page head', () => {
9
+ render(<TebutoBookingWidget therapistUUID={therapistUUID} />)
10
+
11
+ const container = screen.getByTestId<HTMLDivElement>('tebuto-booking-widget-container')
12
+
13
+ expect(container).not.toBeNull()
14
+ expect(container.childNodes).toHaveLength(2)
15
+
16
+ // @ts-expect-error ts(2339)
17
+ expect(container.childNodes[0].attributes['data-testid'].value).toBe('tebuto-booking-widget-script')
18
+ // @ts-expect-error ts(2339)
19
+ expect(container.childNodes[1].attributes['data-testid'].value).toBe('tebuto-booking-widget-noscript')
20
+
21
+ const script = screen.getByTestId<HTMLScriptElement>('tebuto-booking-widget-script')
22
+ expect(script).not.toBeNull()
23
+ expect(script.src).toBe(TEBUTO_BOOKING_WIDGET_SCRIPT_URL)
24
+ expect(script.getAttribute('data-therapist-uuid')).toBe(therapistUUID)
25
+
26
+ const noscript = screen.getByTestId('tebuto-booking-widget-noscript')
27
+ expect(noscript).not.toBeNull()
28
+ expect(noscript.textContent).toBe(TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT)
29
+ })
30
+
31
+ it('should set the "data-background-color" attribute of the script tag to the value of the "backgroundColor" prop', () => {
32
+ const backgroundColor = '#ffffff'
33
+ render(<TebutoBookingWidget therapistUUID={therapistUUID} backgroundColor={backgroundColor} />)
34
+
35
+ const script = screen.getByTestId('tebuto-booking-widget-script')
36
+ expect(script.getAttribute('data-background-color')).toBe(backgroundColor)
37
+ })
38
+
39
+ it('should set the "data-border" attribute of the script tag to the value of the "border" prop', () => {
40
+ const border = false
41
+ render(<TebutoBookingWidget therapistUUID={therapistUUID} border={border} />)
42
+
43
+ const script = screen.getByTestId('tebuto-booking-widget-script')
44
+ expect(script.getAttribute('data-border')).toBe(border.toString())
45
+ })
46
+
47
+ it('should set the "data-categories" attribute of the script tag to the value of the "categories" prop', () => {
48
+ const categories = [1, 2, 3]
49
+ render(<TebutoBookingWidget therapistUUID={therapistUUID} categories={categories} />)
50
+
51
+ const script = screen.getByTestId('tebuto-booking-widget-script')
52
+ expect(script.getAttribute('data-categories')).toBe(categories.join(','))
53
+ })
54
+
55
+ it('should set the noscript text to the value of the "noScriptText" prop', () => {
56
+ const noScriptText = 'This is the noscript text'
57
+ render(<TebutoBookingWidget therapistUUID={therapistUUID} noScriptText={noScriptText} />)
58
+
59
+ const noscript = screen.getByTestId('tebuto-booking-widget-noscript')
60
+ expect(noscript.textContent).toBe(noScriptText)
61
+ })
62
+ })
@@ -0,0 +1,29 @@
1
+ import { JSX } from 'react'
2
+ import { TEBUTO_BOOKING_WIDGET_ID, TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, TEBUTO_BOOKING_WIDGET_SCRIPT_URL } from '../constants'
3
+ import { TebutoBookingWidgetConfiguration } from '../types'
4
+
5
+ type TebutoBookingWidgetProps = {
6
+ noScriptText?: string
7
+ } & TebutoBookingWidgetConfiguration
8
+
9
+ export default function TebutoBookingWidget({ noScriptText = TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT, ...config }: TebutoBookingWidgetProps): JSX.Element {
10
+ return (
11
+ <div id={TEBUTO_BOOKING_WIDGET_ID} data-testid="tebuto-booking-widget-container">
12
+ <TebutoBookingWidgetScript config={config} />
13
+ <noscript data-testid="tebuto-booking-widget-noscript">{noScriptText}</noscript>
14
+ </div>
15
+ )
16
+ }
17
+
18
+ function TebutoBookingWidgetScript({ config }: { config: TebutoBookingWidgetConfiguration }): JSX.Element {
19
+ return (
20
+ <script
21
+ src={TEBUTO_BOOKING_WIDGET_SCRIPT_URL}
22
+ data-therapist-uuid={config.therapistUUID}
23
+ {...(config.backgroundColor ? { 'data-background-color': config.backgroundColor } : {})}
24
+ {...(config.categories ? { 'data-categories': config.categories.join(',') } : {})}
25
+ {...(config.border !== undefined ? { 'data-border': config.border ? 'true' : 'false' } : {})}
26
+ data-testid="tebuto-booking-widget-script"
27
+ />
28
+ )
29
+ }
@@ -0,0 +1 @@
1
+ export { default } from './TebutoBookingWidget'
@@ -0,0 +1,3 @@
1
+ export const TEBUTO_BOOKING_WIDGET_SCRIPT_URL = 'https://widget.tebuto.de/booking-widget.js'
2
+ export const TEBUTO_BOOKING_WIDGET_ID = 'tebuto-booking-widget'
3
+ export const TEBUTO_BOOKING_WIDGET_NO_SCRIPT_TEXT = 'Widget konnte nicht geladen werden. Möglicherweise ist Skripting im Browser deaktiviert.'
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components'
2
+ export * from './types'
package/src/types.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type TebutoBookingWidgetConfiguration = {
2
+ therapistUUID: string
3
+ backgroundColor?: string
4
+ categories?: number[]
5
+ border?: boolean
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "target": "es5",
5
+ "moduleResolution": "node",
6
+ "lib": ["dom", "dom.iterable", "esnext"],
7
+ "allowJs": true,
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "strict": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noFallthroughCasesInSwitch": true,
13
+ "resolveJsonModule": true,
14
+ "isolatedModules": true,
15
+ "noEmit": true,
16
+ "jsx": "react-jsx"
17
+ },
18
+ "include": ["src"]
19
+ }