@ever-teams/atoms 0.2.14 → 0.3.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.
Files changed (50) hide show
  1. package/README.md +149 -0
  2. package/dist/index.es.js +14 -14
  3. package/dist/lib/components/forms/auth-forms.d.ts +1 -1
  4. package/dist/lib/components/forms/auth-forms.d.ts.map +1 -1
  5. package/dist/lib/components/forms/teams-token-login-form.d.ts.map +1 -1
  6. package/dist/lib/components/teams-provider/kit-root.d.ts +18 -0
  7. package/dist/lib/components/teams-provider/kit-root.d.ts.map +1 -0
  8. package/dist/lib/components/teams-provider/teams-provider.d.ts +6 -1
  9. package/dist/lib/components/teams-provider/teams-provider.d.ts.map +1 -1
  10. package/dist/lib/components/teams-report/basic-report/teams-basic-report.d.ts.map +1 -1
  11. package/dist/lib/components/teams-report/list-report/base.d.ts.map +1 -1
  12. package/dist/lib/components/teams-theme/theme-toggle.d.ts.map +1 -1
  13. package/dist/lib/components/teams-time-trackers/common/container.d.ts +1 -1
  14. package/dist/lib/components/teams-time-trackers/common/container.d.ts.map +1 -1
  15. package/dist/lib/components/teams-time-trackers/common/timer-description.d.ts +13 -0
  16. package/dist/lib/components/teams-time-trackers/common/timer-description.d.ts.map +1 -0
  17. package/dist/lib/components/teams-time-trackers/common/use-timer-control.d.ts +26 -0
  18. package/dist/lib/components/teams-time-trackers/common/use-timer-control.d.ts.map +1 -0
  19. package/dist/lib/components/teams-time-trackers/teams-basic-timer/index.d.ts.map +1 -1
  20. package/dist/lib/components/teams-time-trackers/teams-basic-timer/timer-button.d.ts.map +1 -1
  21. package/dist/lib/components/teams-time-trackers/teams-basic-timer/timer-time.d.ts.map +1 -1
  22. package/dist/lib/components/teams-time-trackers/teams-custom-timer/index.d.ts.map +1 -1
  23. package/dist/lib/components/teams-time-trackers/teams-essential-timer/index.d.ts.map +1 -1
  24. package/dist/lib/components/teams-time-trackers/teams-extra-timer/index.d.ts.map +1 -1
  25. package/dist/lib/components/teams-time-trackers/teams-modern-timer/index.d.ts.map +1 -1
  26. package/dist/lib/components/teams-ui-components/button/button.d.ts +2 -2
  27. package/dist/lib/components/teams-ui-components/button/button.d.ts.map +1 -1
  28. package/dist/lib/context/teams-timer-status-context.d.ts +24 -0
  29. package/dist/lib/context/teams-timer-status-context.d.ts.map +1 -0
  30. package/dist/lib/context/teams-tracking-context.d.ts +2 -0
  31. package/dist/lib/context/teams-tracking-context.d.ts.map +1 -1
  32. package/dist/lib/hooks/useClearKitSession.d.ts +7 -0
  33. package/dist/lib/hooks/useClearKitSession.d.ts.map +1 -0
  34. package/dist/lib/hooks/useFontSelector.d.ts +8 -1
  35. package/dist/lib/hooks/useFontSelector.d.ts.map +1 -1
  36. package/dist/lib/hooks/useTeamsStopWatch.d.ts.map +1 -1
  37. package/dist/lib/hooks/useTimer.d.ts +1 -0
  38. package/dist/lib/hooks/useTimer.d.ts.map +1 -1
  39. package/dist/lib/hooks/useTimerStatus.d.ts +4 -0
  40. package/dist/lib/hooks/useTimerStatus.d.ts.map +1 -1
  41. package/dist/lib/hooks/useUserPermission.d.ts.map +1 -1
  42. package/dist/lib/stores/kit-preferences.d.ts +15 -0
  43. package/dist/lib/stores/kit-preferences.d.ts.map +1 -0
  44. package/dist/lib/teams-jotai/atoms/teams-atoms.d.ts +2 -2
  45. package/dist/lib/themes/kit-theme-config.d.ts +9 -0
  46. package/dist/lib/themes/kit-theme-config.d.ts.map +1 -0
  47. package/dist/lib/utils/warn-once.d.ts +2 -0
  48. package/dist/lib/utils/warn-once.d.ts.map +1 -0
  49. package/dist/styles.css +1 -0
  50. package/package.json +8 -4
package/README.md CHANGED
@@ -1 +1,150 @@
1
1
  # Atoms
2
+
3
+ `@ever-teams/atoms` puts a live Ever Teams timer, and the reports around it, inside your own React product. The
4
+ timer is the same one your team uses in the Ever Teams web, desktop and mobile apps: start it here, see it running
5
+ there. The time is recorded as embedded time (`source: 'EMBED'`), so reports tell it apart; on an API too old to know
6
+ that source, the kit records it as `TEAMS`. MIT licensed.
7
+
8
+ Components to browse: [storybook.ever.team](https://storybook.ever.team). Example apps:
9
+ [packages/toolkit/examples](https://github.com/ever-co/ever-teams/tree/develop/packages/toolkit/examples).
10
+
11
+ ## Quick start
12
+
13
+ You need a React app (tested with React 19) and an Ever Teams API: the cloud (`https://api.ever.team/api`) or your
14
+ own server (its address ending with `/api`).
15
+
16
+ ```bash
17
+ npm install @ever-teams/atoms
18
+ ```
19
+
20
+ ```tsx
21
+ 'use client';
22
+ import '@ever-teams/atoms/styles.css';
23
+ import { TeamsProvider, TeamsLoginDialog, TeamsBasicTimer } from '@ever-teams/atoms';
24
+
25
+ export function EverTeamsTimer() {
26
+ return (
27
+ <TeamsProvider config={{ apiUrl: 'https://api.ever.team/api' }} scopedStyles>
28
+ <TeamsLoginDialog />
29
+ <TeamsBasicTimer />
30
+ </TeamsProvider>
31
+ );
32
+ }
33
+ ```
34
+
35
+ `@ever-teams/atoms/styles.css` holds the components' styles, compiled and scoped under the kit root that
36
+ `scopedStyles` renders: your app needs no Tailwind, and the stylesheet changes nothing outside the kit. It ships from
37
+ the first release after 0.2.14; on 0.2.14, style the kit with your own Tailwind (below).
38
+
39
+ ### With your own Tailwind CSS 4
40
+
41
+ If your app compiles Tailwind CSS 4 already, you can leave out the `styles.css` import and `scopedStyles`, and let
42
+ your Tailwind see the kit's class names instead, in the CSS file that has `@import "tailwindcss";` (paths are
43
+ relative to that file):
44
+
45
+ ```css
46
+ @import 'tailwindcss';
47
+ @source "../node_modules/@ever-teams/atoms/dist";
48
+ @source "../node_modules/@ever-teams/toolkit-ui/dist";
49
+ ```
50
+
51
+ The `../` paths fit `app/globals.css` in Next.js and `src/index.css` in Vite; with a Next.js `src/` directory the file
52
+ is `src/app/globals.css` and the paths start with `../../`.
53
+
54
+ These lines only let Tailwind generate the kit's classes. Their colors come from tokens your theme must then define:
55
+ the kit's colors (`primary`, `secondary`, ...), the CSS variables they read (`--background`, `--primary-foreground`,
56
+ ...) and the `tailwindcss-animate` plugin, as the kit's own [`kit.css`](https://github.com/ever-co/ever-teams/blob/develop/packages/toolkit/atoms/src/styles/kit.css) declares them. The kit publishes no
57
+ Tailwind preset for this, so without that setup those components lose their colors: unless you need your own
58
+ Tailwind to compile the kit, use `styles.css`.
59
+
60
+ ## Next.js (App Router)
61
+
62
+ 1. `npx create-next-app@latest my-app` (TypeScript, App Router), then `cd my-app` and
63
+ `npm install @ever-teams/atoms`.
64
+ 2. Create `app/ever-teams-timer.tsx` (`src/app/ever-teams-timer.tsx` with a `src/` directory) with the component of
65
+ the quick start. The `'use client'` line is required: the provider uses state and the browser.
66
+ 3. Use it in a page:
67
+
68
+ ```tsx
69
+ // app/page.tsx
70
+ import { EverTeamsTimer } from './ever-teams-timer';
71
+
72
+ export default function Page() {
73
+ return <EverTeamsTimer />;
74
+ }
75
+ ```
76
+
77
+ ## Vite + React
78
+
79
+ 1. `npm create vite@latest my-app -- --template react-ts`, then `cd my-app` and `npm install @ever-teams/atoms`.
80
+ 2. Replace `src/App.tsx` (`src/main.tsx` imports it as the default export):
81
+
82
+ ```tsx
83
+ import '@ever-teams/atoms/styles.css';
84
+ import { TeamsProvider, TeamsLoginDialog, TeamsBasicTimer } from '@ever-teams/atoms';
85
+
86
+ export default function App() {
87
+ return (
88
+ <TeamsProvider config={{ apiUrl: 'https://api.ever.team/api' }} scopedStyles>
89
+ <TeamsLoginDialog />
90
+ <TeamsBasicTimer />
91
+ </TeamsProvider>
92
+ );
93
+ }
94
+ ```
95
+
96
+ ## Configuration
97
+
98
+ | Prop of `TeamsProvider` | Default | What it does |
99
+ | ----------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
100
+ | `config.apiUrl` | `https://api.ever.team/api` | The Ever Teams API every request goes to, with the token in the `Authorization` header. Always set it. With your own server, give its address ending with `/api`. |
101
+ | `lang` | `'en'` | Language of the components: `'en'` or `'fr'`. A language chosen earlier in the language switch, kept in `localStorage`, wins. |
102
+ | `theme` | `defaultTheme` | A theme object: `defaultTheme` and `theme1` to `theme14` are exported. |
103
+ | `scopedStyles` | `false` | Renders the kit root that `@ever-teams/atoms/styles.css` is scoped under, and a container in `document.body` for the kit's dialogs, popovers, menus and selects. Set it with the stylesheet; leave it off when your own Tailwind compiles the kit's classes. |
104
+ | `colorScheme` | `'system'` | The widgets' color scheme inside the kit root (`scopedStyles`): `'light'`, `'dark'` or `'system'` (follows the system's). Nothing is written on `<html>`. |
105
+ | `loadGoogleFonts` | `false` | Lets the font toggle (`TeamsFontToggle`) load the font a person picks from Google Fonts. Off: no request to a third party, and the widgets keep your page's font until a person picks one. |
106
+ | `onSignOut` | none | Called after a person signs out from the kit's user menu. Without it, the page stays where it is with `scopedStyles`; without `scopedStyles`, the kit sends the browser to `/`. |
107
+
108
+ `config.apiUrl` is one setting for the whole page: every `TeamsProvider` of a page writes it to the same
109
+ `apiConfigManager`, and every request uses the address set last. Give all the providers of a page the same `apiUrl`.
110
+
111
+ The API must accept your site's origin: on a self-hosted Gauzy API, add it to `ALLOWED_ORIGINS` (comma-separated)
112
+ and restart the API.
113
+
114
+ ## Security: where tokens live today, and what is planned
115
+
116
+ Today:
117
+
118
+ - The sign-in dialog (`TeamsLoginDialog`) takes the user's email and password inside your page and sends them to
119
+ `{apiUrl}/auth/login`. A "Token" tab also accepts a pasted access token.
120
+ - The access token and the user record are kept in `localStorage['_teams-store']`, readable by every script of your
121
+ page. Each time the kit saves them (at every page load once signed in) it sets their expiry 24 hours later;
122
+ it removes them only when it next reads them after that expiry, so until then an expired token stays readable
123
+ there.
124
+ - The user menu shows the token, with a copy button.
125
+ - What leaves your page: requests to `config.apiUrl` (`https://api.ever.team/api` when it is not set), with the token
126
+ in their `Authorization` header. Fonts are requested from Google Fonts only with `loadGoogleFonts`. Tracking
127
+ sessions are read only while a component that shows them (filter, insights, heatmap, replay) is on the page.
128
+ - Published versions up to 0.2.14 sent the signed-in user's token to the demo Gauzy API when `config.apiUrl` was not
129
+ set ([ever-co/ever-teams#5406](https://github.com/ever-co/ever-teams/issues/5406)): on 0.2.x, upgrade, and always
130
+ set `apiUrl`.
131
+
132
+ Planned ([ever-co/ever-teams#5405](https://github.com/ever-co/ever-teams/issues/5405)): your backend hands the
133
+ widget a short-lived token, limited to the timer and to one person, kept in memory only; the workspace lists the
134
+ sites allowed to embed it and can revoke them.
135
+
136
+ ## Troubleshooting
137
+
138
+ | You see | Cause and fix |
139
+ | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
140
+ | The widget is unstyled (digits one under the other, a large coloured block) | Import `@ever-teams/atoms/styles.css` and set `scopedStyles`; with your own Tailwind, add the two `@source` lines instead. |
141
+ | A network or CORS error in the console, sign-in does nothing | The API does not allow your origin: add it to the API's `ALLOWED_ORIGINS`. |
142
+ | 404 on every request | `apiUrl` must end with `/api` (`https://api.example.com/api`). |
143
+ | "useState only works in Client Components" (Next.js) | Add `'use client'` at the top of the file that renders `TeamsProvider`. |
144
+
145
+ ## Links
146
+
147
+ - Components and their props: [storybook.ever.team](https://storybook.ever.team)
148
+ - Example apps (Next.js, Vite, Remix, SaaS starter): [packages/toolkit/examples](https://github.com/ever-co/ever-teams/tree/develop/packages/toolkit/examples)
149
+ - API reference: [docs.ever.team/api-reference](https://docs.ever.team/api-reference/)
150
+ - Licence: MIT