@beautinique/frontend-components 0.0.0-stage → 1.0.1
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.
- package/README.md +100 -2
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/button.d.cts +3 -0
- package/dist/lib/button.d.cts.map +1 -0
- package/dist/lib/button.d.ts +3 -0
- package/dist/lib/button.d.ts.map +1 -0
- package/dist/lib/constants.d.cts +5 -0
- package/dist/lib/constants.d.cts.map +1 -0
- package/dist/lib/constants.d.ts +5 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/tooltip.d.cts +6 -0
- package/dist/lib/tooltip.d.cts.map +1 -0
- package/dist/lib/tooltip.d.ts +6 -0
- package/dist/lib/tooltip.d.ts.map +1 -0
- package/dist/toast/ToastContainer.d.cts +5 -0
- package/dist/toast/ToastContainer.d.cts.map +1 -0
- package/dist/toast/ToastContainer.d.ts +5 -0
- package/dist/toast/ToastContainer.d.ts.map +1 -0
- package/dist/toast/index.cjs +621 -0
- package/dist/toast/index.cjs.map +1 -0
- package/dist/toast/index.d.cts +8 -0
- package/dist/toast/index.d.cts.map +1 -0
- package/dist/toast/index.d.ts +8 -0
- package/dist/toast/index.d.ts.map +1 -0
- package/dist/toast/index.js +606 -0
- package/dist/toast/index.js.map +1 -0
- package/dist/toast/toast-icons.d.cts +10 -0
- package/dist/toast/toast-icons.d.cts.map +1 -0
- package/dist/toast/toast-icons.d.ts +10 -0
- package/dist/toast/toast-icons.d.ts.map +1 -0
- package/dist/toast/toast.store.d.cts +4 -0
- package/dist/toast/toast.store.d.cts.map +1 -0
- package/dist/toast/toast.store.d.ts +4 -0
- package/dist/toast/toast.store.d.ts.map +1 -0
- package/dist/toast/toaster.d.cts +21 -0
- package/dist/toast/toaster.d.cts.map +1 -0
- package/dist/toast/toaster.d.ts +21 -0
- package/dist/toast/toaster.d.ts.map +1 -0
- package/dist/toast/types.d.cts +92 -0
- package/dist/toast/types.d.cts.map +1 -0
- package/dist/toast/types.d.ts +92 -0
- package/dist/toast/types.d.ts.map +1 -0
- package/dist/toast/uploads.d.cts +63 -0
- package/dist/toast/uploads.d.cts.map +1 -0
- package/dist/toast/uploads.d.ts +63 -0
- package/dist/toast/uploads.d.ts.map +1 -0
- package/dist/types/component.d.cts +27 -0
- package/dist/types/component.d.cts.map +1 -0
- package/dist/types/component.d.ts +27 -0
- package/dist/types/component.d.ts.map +1 -0
- package/dist/ui/Button.d.cts +3 -0
- package/dist/ui/Button.d.cts.map +1 -0
- package/dist/ui/Button.d.ts +3 -0
- package/dist/ui/Button.d.ts.map +1 -0
- package/dist/ui/Tooltip.d.cts +3 -0
- package/dist/ui/Tooltip.d.cts.map +1 -0
- package/dist/ui/Tooltip.d.ts +3 -0
- package/dist/ui/Tooltip.d.ts.map +1 -0
- package/dist/ui/index.cjs +205 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +3 -0
- package/dist/ui/index.d.cts.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +202 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +100 -4
- package/source.css +11 -0
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @beautinique/frontend-components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared React UI components for the Beautinique frontends (Vite + React 19 + Tailwind v4).
|
|
4
|
+
|
|
5
|
+
The components are styled with Tailwind classes and with the tokens (colours, shadows, fonts) of
|
|
6
|
+
[`@beautinique/frontend-styles`](../styles/README.md), so an app needs both.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @beautinique/frontend-components @beautinique/frontend-styles @iconify/react
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Peer dependencies: `react`, `react-dom`, `@iconify/react`, `@beautinique/frontend-styles`.
|
|
15
|
+
|
|
16
|
+
## Setup (once per app)
|
|
17
|
+
|
|
18
|
+
In the app's own `index.css`, in this order:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
@import '@beautinique/frontend-styles';
|
|
22
|
+
@import '@beautinique/frontend-components/source.css';
|
|
23
|
+
@import './app.css';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`source.css` is not optional. Tailwind v4 does not look for class names inside `node_modules`, so
|
|
27
|
+
without it the classes the components use (`rounded-lg`, `shadow-primary-btn`, ...) are never
|
|
28
|
+
generated and the components come out unstyled. (The playground has a page that shows exactly that.)
|
|
29
|
+
|
|
30
|
+
## Import paths
|
|
31
|
+
|
|
32
|
+
Components that most screens use live in `/ui` (and, later, `/layout`). Components that few screens
|
|
33
|
+
use have a path of their own, so an app only bundles what it imports.
|
|
34
|
+
|
|
35
|
+
| Import path | What it gives |
|
|
36
|
+
| --------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
37
|
+
| `@beautinique/frontend-components` | Types only (`IButton`, `ITooltip`, ...) |
|
|
38
|
+
| `@beautinique/frontend-components/ui` | `Button`, `Tooltip` |
|
|
39
|
+
| `@beautinique/frontend-components/toast` | `ToastContainer`, `toaster`, the toast store, and the helpers for toasts that follow uploads |
|
|
40
|
+
| `@beautinique/frontend-components/source.css` | The `@source` line of the setup above |
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Button, Tooltip } from '@beautinique/frontend-components/ui';
|
|
44
|
+
import { ToastContainer, toaster } from '@beautinique/frontend-components/toast';
|
|
45
|
+
|
|
46
|
+
const App = () => (
|
|
47
|
+
<>
|
|
48
|
+
<ToastContainer /> {/* once, near the root of the app */}
|
|
49
|
+
<Tooltip title="Save" description="Ctrl + S">
|
|
50
|
+
<Button
|
|
51
|
+
pattern="primary"
|
|
52
|
+
content="Save"
|
|
53
|
+
buttonProps={{ onClick: () => toaster.success({ title: 'Saved' }) }}
|
|
54
|
+
/>
|
|
55
|
+
</Tooltip>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Toasts
|
|
61
|
+
|
|
62
|
+
`toaster` works from anywhere (an API client, a store), not only from components:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
toaster.success({ title: 'Saved', description: 'Your changes were saved.' });
|
|
66
|
+
toaster.error({ title: 'Failed' });
|
|
67
|
+
toaster.warning({ title: 'Careful' });
|
|
68
|
+
toaster.loading({ title: 'Working' });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Toasts that follow uploads (`withProgressToast` for one request, `createUploadsToast`,
|
|
72
|
+
`withUploadsToast` and `runUploadsInToast` for several) are described in `src/toast/uploads.ts`.
|
|
73
|
+
`runUploadsInToast` shows one toast for the uploads of several fields: the overall progress on the
|
|
74
|
+
left and a row (waiting, uploading, done or failed) for each field that has files.
|
|
75
|
+
|
|
76
|
+
The icons of the toasts are bundled, so a toast shows its icon without a network.
|
|
77
|
+
|
|
78
|
+
## Rules for the code of this package
|
|
79
|
+
|
|
80
|
+
- **State lives in exactly one import path.** The toast store is part of `/toast` only. A component
|
|
81
|
+
of another path that needs it must import it from `@beautinique/frontend-components/toast`, never
|
|
82
|
+
copy it: every entry is built as one file, so a copy would be a second store, and a toast shown
|
|
83
|
+
through it would never reach the `ToastContainer`.
|
|
84
|
+
- **A component's own css lives next to the component** and is imported by it, not by the styles
|
|
85
|
+
package. It uses the variables of the styles package (`var(--smoke-eerie)`, ...) and does not
|
|
86
|
+
import them again: importing them a second time, after the app's own css, would undo the app's
|
|
87
|
+
overrides.
|
|
88
|
+
- **No imports from an app.** What a component needs from its app comes in through props.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm run build # dist (needed by the playground and by the type check of the playground)
|
|
94
|
+
npm run playground # http://localhost:4200 - the components, in a real browser
|
|
95
|
+
npm test
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
After a rebuild of `dist` restart the playground (or touch `playground/index.css`): Tailwind looks for class names in `dist` when the css is processed, so a class that is new in `dist` is not generated until then. An app that installs the package from npm does not have this, it builds with the package as it is.
|
|
99
|
+
|
|
100
|
+
The playground (`playground/`) is a small Vite page that uses the package through its public import
|
|
101
|
+
paths, the way an app does. It is not published (`files` in `package.json` leaves it out).
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IButton } from '../types/component.js';
|
|
2
|
+
export declare const getButtonCss: (pattern: IButton["pattern"]) => "text-white bg-sky-blue-burst shadow-primary-btn hover:shadow-primary-btn-hover" | "text-secondary-invert bg-secondary shadow-secondary-btn hover:shadow-secondary-btn-hover" | "text-tertiary-invert bg-tertiary shadow-tertiary-btn hover:shadow-tertiary-btn-hover" | "text-primary border border-primary shadow-outline-btn hover:shadow-outline-btn-hover" | "bg-transparent border border-primary/30 text-secondary";
|
|
3
|
+
//# sourceMappingURL=button.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.cts","sourceRoot":"","sources":["../../src/lib/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,CAAC,SAAS,CAAC,+ZAcvD,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IButton } from '../types/component.js';
|
|
2
|
+
export declare const getButtonCss: (pattern: IButton["pattern"]) => "text-white bg-sky-blue-burst shadow-primary-btn hover:shadow-primary-btn-hover" | "text-secondary-invert bg-secondary shadow-secondary-btn hover:shadow-secondary-btn-hover" | "text-tertiary-invert bg-tertiary shadow-tertiary-btn hover:shadow-tertiary-btn-hover" | "text-primary border border-primary shadow-outline-btn hover:shadow-outline-btn-hover" | "bg-transparent border border-primary/30 text-secondary";
|
|
3
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/lib/button.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,CAAC,SAAS,CAAC,+ZAcvD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOOLTIP_GAP: 15;
|
|
2
|
+
export declare const TOOLTIP_ANIMATION_DURATION: 400;
|
|
3
|
+
export declare const TOAST_TYPES: readonly ["success", "error", "warning", "progress", "uploads", "loading", "default", "custom"];
|
|
4
|
+
export declare const TOAST_TYPE: { [K in (typeof TOAST_TYPES)[number]]: K; };
|
|
5
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAG,EAAW,CAAC;AACvC,eAAO,MAAM,0BAA0B,EAAG,GAAY,CAAC;AAEvD,eAAO,MAAM,WAAW,iGASd,CAAC;AAEX,eAAO,MAAM,UAAU,EAAkE,GACtF,CAAC,IAAI,CAAC,OAAO,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,GACvC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOOLTIP_GAP: 15;
|
|
2
|
+
export declare const TOOLTIP_ANIMATION_DURATION: 400;
|
|
3
|
+
export declare const TOAST_TYPES: readonly ["success", "error", "warning", "progress", "uploads", "loading", "default", "custom"];
|
|
4
|
+
export declare const TOAST_TYPE: { [K in (typeof TOAST_TYPES)[number]]: K; };
|
|
5
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAG,EAAW,CAAC;AACvC,eAAO,MAAM,0BAA0B,EAAG,GAAY,CAAC;AAEvD,eAAO,MAAM,WAAW,iGASd,CAAC;AAEX,eAAO,MAAM,UAAU,EAAkE,GACtF,CAAC,IAAI,CAAC,OAAO,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,GACvC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { ITooltip } from '../types/component.js';
|
|
3
|
+
export declare const getTooltipPosition: (rect: DOMRect, placement: NonNullable<ITooltip["placement"]>) => CSSProperties;
|
|
4
|
+
export declare const getTooltipTransform: (placement: NonNullable<ITooltip["placement"]>, isVisible: boolean) => string;
|
|
5
|
+
export declare const getTooltipArrowCss: (placement: NonNullable<ITooltip["placement"]>) => "after:bottom-full after:left-1/2 after:-translate-x-1/2 after:border-b-silver-jet-2" | "after:top-1/2 after:right-full after:-translate-y-1/2 after:border-r-silver-jet-2" | "after:top-1/2 after:left-full after:-translate-y-1/2 after:border-l-silver-jet-2" | "after:top-full after:left-1/2 after:-translate-x-1/2 after:border-t-silver-jet-2";
|
|
6
|
+
//# sourceMappingURL=tooltip.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.cts","sourceRoot":"","sources":["../../src/lib/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,eAAO,MAAM,kBAAkB,GAC7B,MAAM,OAAO,EACb,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAC5C,aAYF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAC7C,WAAW,OAAO,WAenB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,0VAY/E,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { ITooltip } from '../types/component.js';
|
|
3
|
+
export declare const getTooltipPosition: (rect: DOMRect, placement: NonNullable<ITooltip["placement"]>) => CSSProperties;
|
|
4
|
+
export declare const getTooltipTransform: (placement: NonNullable<ITooltip["placement"]>, isVisible: boolean) => string;
|
|
5
|
+
export declare const getTooltipArrowCss: (placement: NonNullable<ITooltip["placement"]>) => "after:bottom-full after:left-1/2 after:-translate-x-1/2 after:border-b-silver-jet-2" | "after:top-1/2 after:right-full after:-translate-y-1/2 after:border-r-silver-jet-2" | "after:top-1/2 after:left-full after:-translate-y-1/2 after:border-l-silver-jet-2" | "after:top-full after:left-1/2 after:-translate-x-1/2 after:border-t-silver-jet-2";
|
|
6
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/lib/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,eAAO,MAAM,kBAAkB,GAC7B,MAAM,OAAO,EACb,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAC5C,aAYF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAC7C,WAAW,OAAO,WAenB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,WAAW,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,0VAY/E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IClassName } from '../types/component.js';
|
|
2
|
+
import type { TToastItem } from './types.js';
|
|
3
|
+
export declare const Toaster: (props: TToastItem & IClassName) => import("react").JSX.Element | null;
|
|
4
|
+
export declare const ToastContainer: () => import("react").JSX.Element | null;
|
|
5
|
+
//# sourceMappingURL=ToastContainer.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastContainer.d.cts","sourceRoot":"","sources":["../../src/toast/ToastContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,KAAK,EAAuB,UAAU,EAAqB,MAAM,YAAY,CAAC;AAkLrF,eAAO,MAAM,OAAO,GAAI,OAAO,UAAU,GAAG,UAAU,uCAmJrD,CAAC;AAEF,eAAO,MAAM,cAAc,0CAY1B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IClassName } from '../types/component.js';
|
|
2
|
+
import type { TToastItem } from './types.js';
|
|
3
|
+
export declare const Toaster: (props: TToastItem & IClassName) => import("react").JSX.Element | null;
|
|
4
|
+
export declare const ToastContainer: () => import("react").JSX.Element | null;
|
|
5
|
+
//# sourceMappingURL=ToastContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastContainer.d.ts","sourceRoot":"","sources":["../../src/toast/ToastContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,KAAK,EAAuB,UAAU,EAAqB,MAAM,YAAY,CAAC;AAkLrF,eAAO,MAAM,OAAO,GAAI,OAAO,UAAU,GAAG,UAAU,uCAmJrD,CAAC;AAEF,eAAO,MAAM,cAAc,0CAY1B,CAAC"}
|