bubble-toolbar 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +194 -2
- package/dist/index.d.mts +188 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.js +487 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +441 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +125 -0
- package/package.json +55 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 el_jijuna
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,195 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🫧 Bubble Toolbar
|
|
2
|
+
|
|
3
|
+
> Componente de barra flotante responsiva con efecto **blurred glass** (glassmorphism) para **React 18 y 19** con **TypeScript**, organizado por grupos y con morfología adaptativa inteligente (círculo ↔ cápsula).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ✨ Características
|
|
10
|
+
|
|
11
|
+
- ⚛️ **Compatibilidad Total**: Diseñado y probado con **React 18** y **React 19** usando `forwardRef` y tipado estricto en TypeScript.
|
|
12
|
+
- 🔮 **Definición por Grupos**: Define la barra pasando arreglos de nodos o mediante sintaxis de componentes compuestos (`BubbleToolbar.Group`).
|
|
13
|
+
- 🔘 **Morfología Adaptativa Dinámica**:
|
|
14
|
+
- **1 solo nodo** $\rightarrow$ se renderiza como un **círculo** perfecto (`aspect-ratio: 1/1`).
|
|
15
|
+
- **Más de 1 nodo** $\rightarrow$ se convierte en un **rectángulo redondeado (cápsula / pill)**, respetando la curvatura en los extremos para mantener el equilibrio visual exacto con las burbujas circulares.
|
|
16
|
+
- 🪟 **Blurred Glass (Frosted Glassmorphism)**: Efecto translúcido con desenfoque de fondo (`backdrop-filter: blur(16px)`), bordes frosted, sombras suaves y soporte para temas claro, oscuro o automático.
|
|
17
|
+
- 📱 **Flotante y Responsivo**: Posicionamiento fijo o relativo, centrado automático y desplazamiento horizontal suave sin barras de scroll invasivas en pantallas móviles.
|
|
18
|
+
- 🧪 **100% Testeado con Jest**: Suite integral de pruebas unitarias y de integración con `@testing-library/react`.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 📦 Instalación
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install bubble-toolbar
|
|
26
|
+
# o con yarn / pnpm / bun
|
|
27
|
+
pnpm add bubble-toolbar
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Uso Rápido
|
|
33
|
+
|
|
34
|
+
### Ejemplo con definición por grupos (prop `groups`)
|
|
35
|
+
|
|
36
|
+
Tal como en tu especificación:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import { BubbleToolbar, BubbleIconButton, BubbleArea } from 'bubble-toolbar';
|
|
41
|
+
import 'bubble-toolbar/styles.css'; // Opcional, los estilos inline glass ya vienen incluidos
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<BubbleToolbar
|
|
46
|
+
position="bottom"
|
|
47
|
+
theme="glass"
|
|
48
|
+
groups={[
|
|
49
|
+
// Grupo 1: 1 solo nodo => Círculo
|
|
50
|
+
[<Logo key="logo" />],
|
|
51
|
+
|
|
52
|
+
// Grupo 2: Múltiples nodos => Rectángulo redondeado (Pill)
|
|
53
|
+
[
|
|
54
|
+
<BubbleIconButton key="search" name="search" />,
|
|
55
|
+
<BubbleArea key="area">
|
|
56
|
+
<input placeholder="Buscar o escribir /" />
|
|
57
|
+
</BubbleArea>,
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
// Grupos 3, 4 y 5: 1 solo nodo cada uno => Círculos
|
|
61
|
+
[<BubbleIconButton key="theme" name="theme" />],
|
|
62
|
+
[<BubbleIconButton key="chat" name="chat" />],
|
|
63
|
+
[<BubbleIconButton key="notif" name="notifications" badge={3} />],
|
|
64
|
+
]}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Ejemplo con Componentes Compuestos (`BubbleToolbar.Group`)
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { BubbleToolbar, BubbleIconButton, BubbleArea } from 'bubble-toolbar';
|
|
74
|
+
|
|
75
|
+
function FloatingMenu() {
|
|
76
|
+
return (
|
|
77
|
+
<BubbleToolbar position="bottom" theme="glass">
|
|
78
|
+
{/* 1 nodo: Círculo */}
|
|
79
|
+
<BubbleToolbar.Group>
|
|
80
|
+
<Logo />
|
|
81
|
+
</BubbleToolbar.Group>
|
|
82
|
+
|
|
83
|
+
{/* 2 nodos: Rectángulo redondeado (Cápsula) */}
|
|
84
|
+
<BubbleToolbar.Group>
|
|
85
|
+
<BubbleIconButton name="search" />
|
|
86
|
+
<BubbleArea>
|
|
87
|
+
<input placeholder="Buscar..." />
|
|
88
|
+
</BubbleArea>
|
|
89
|
+
</BubbleToolbar.Group>
|
|
90
|
+
|
|
91
|
+
{/* 1 nodo: Círculo */}
|
|
92
|
+
<BubbleToolbar.Group>
|
|
93
|
+
<BubbleIconButton name="theme" />
|
|
94
|
+
</BubbleToolbar.Group>
|
|
95
|
+
</BubbleToolbar>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 📐 Morfología Visual
|
|
103
|
+
|
|
104
|
+
| Contenido del Grupo | Forma Resultante | Comportamiento |
|
|
105
|
+
| :--- | :---: | :--- |
|
|
106
|
+
| **1 Nodo** (`[<Logo />]`) | 🟡 **Círculo** | Ancho y alto fijados a `--bubble-size` (por defecto `48px`). `aspect-ratio: 1 / 1`. Contenido centrado. |
|
|
107
|
+
| **> 1 Nodo** (`[<Search />, <Area />]`) | 💊 **Cápsula / Pill** | Altura fijada a `--bubble-size`, ancho dinámico según contenido con padding lateral. Los extremos redondeados coinciden exactamente con el diámetro de las burbujas circulares adyacentes para una armonía visual simétrica. |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 🛠️ API Reference
|
|
112
|
+
|
|
113
|
+
### `<BubbleToolbar />`
|
|
114
|
+
|
|
115
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
116
|
+
| :--- | :--- | :---: | :--- |
|
|
117
|
+
| `groups` | `ReactNode[][]` | `undefined` | Arreglo de arreglos con los nodos agrupados. |
|
|
118
|
+
| `children` | `ReactNode` | `undefined` | Elementos JSX hijos (ej. `<BubbleToolbar.Group>`). |
|
|
119
|
+
| `position` | `'bottom' \| 'top' \| 'static' \| 'custom'` | `'bottom'` | Posicionamiento de la barra en pantalla. |
|
|
120
|
+
| `theme` | `'glass' \| 'light' \| 'dark' \| 'auto'` | `'glass'` | Estilo visual y translucidez. |
|
|
121
|
+
| `size` | `'sm' \| 'md' \| 'lg' \| number` | `'md'` | Altura de la barra / diámetro de los círculos (40px, 48px, 56px o px numérico). |
|
|
122
|
+
| `blurred` | `boolean` | `true` | Activa el efecto frosted glass (`backdrop-filter: blur`). |
|
|
123
|
+
| `blurAmount`| `number \| string` | `16` | Cantidad de desenfoque en píxeles. |
|
|
124
|
+
| `groupGap` | `number \| string` | `8` | Espacio entre cada burbuja/grupo. |
|
|
125
|
+
| `itemGap` | `number \| string` | `8` | Espacio entre elementos dentro de un grupo cápsula. |
|
|
126
|
+
| `bordered` | `boolean` | `true` | Muestra bordes sutiles con brillo frosted. |
|
|
127
|
+
| `shadow` | `boolean \| string` | `true` | Sombra flotante proyectada. |
|
|
128
|
+
|
|
129
|
+
### `<BubbleGroup />` (o `<BubbleToolbar.Group />`)
|
|
130
|
+
|
|
131
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
132
|
+
| :--- | :--- | :---: | :--- |
|
|
133
|
+
| `children` | `ReactNode` | `undefined` | Nodos que contiene el grupo. |
|
|
134
|
+
| `shape` | `'circle' \| 'pill'` | Automático | Fuerza una forma específica omitiendo el cálculo automático por cantidad de nodos. |
|
|
135
|
+
| `size` | `'sm' \| 'md' \| 'lg' \| number` | Heredado | Permite sobrescribir el tamaño para este grupo. |
|
|
136
|
+
| `itemGap` | `number \| string` | Heredado | Espaciado entre elementos del grupo. |
|
|
137
|
+
|
|
138
|
+
### `<BubbleIconButton />`
|
|
139
|
+
|
|
140
|
+
| Prop | Tipo | Por defecto | Descripción |
|
|
141
|
+
| :--- | :--- | :---: | :--- |
|
|
142
|
+
| `name` | `'search' \| 'theme' \| 'chat' \| 'notifications' \| 'logo' \| 'close'` | `undefined` | Nombre del icono vectorial SVG pre-integrado. |
|
|
143
|
+
| `icon` | `ReactNode` | `undefined` | Icono SVG personalizado. |
|
|
144
|
+
| `badge` | `ReactNode \| number \| string` | `undefined` | Indicador o contador de notificación. |
|
|
145
|
+
| `active` | `boolean` | `false` | Estado activo / seleccionado. |
|
|
146
|
+
| `tooltip` | `string` | `undefined` | Texto emergente y accesible. |
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 🧪 Pruebas con Jest
|
|
151
|
+
|
|
152
|
+
Ejecutar la suite completa de pruebas:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm test
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Ejecutar con reporte de cobertura de código:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm run test:coverage
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Ejecutar chequeo de tipos en TypeScript:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm run typecheck
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Ejecutar Storybook en local
|
|
171
|
+
|
|
172
|
+
Para explorar visualmente los componentes, probar el cambio dinámico de formas y los temas:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm run storybook
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Compilar Storybook estático:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run build-storybook
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Compilar la librería para distribución (ESM, CJS y `.d.ts`):
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 📄 Licencia
|
|
193
|
+
|
|
194
|
+
MIT © ElJijuna
|
|
2
195
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { HTMLAttributes, ReactNode, CSSProperties, ButtonHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type BubbleToolbarTheme = 'light' | 'dark' | 'auto' | 'glass';
|
|
5
|
+
type BubbleToolbarPosition = 'bottom' | 'top' | 'static' | 'custom';
|
|
6
|
+
type BubbleToolbarSize = 'sm' | 'md' | 'lg' | number;
|
|
7
|
+
type BubbleShape = 'circle' | 'pill';
|
|
8
|
+
interface BubbleToolbarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
/**
|
|
10
|
+
* Definition of items by groups.
|
|
11
|
+
* Example:
|
|
12
|
+
* [
|
|
13
|
+
* [<Logo />],
|
|
14
|
+
* [<IconButton name="search" />, <ToolbarArea />],
|
|
15
|
+
* [<IconButton name="theme" />],
|
|
16
|
+
* [<IconButton name="chat" />],
|
|
17
|
+
* [<IconButton name="notifications" />]
|
|
18
|
+
* ]
|
|
19
|
+
*/
|
|
20
|
+
groups?: ReactNode[][];
|
|
21
|
+
/**
|
|
22
|
+
* Alternatively, declarative composition using BubbleToolbar.Group children.
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Placement on the screen.
|
|
27
|
+
* @default 'bottom'
|
|
28
|
+
*/
|
|
29
|
+
position?: BubbleToolbarPosition;
|
|
30
|
+
/**
|
|
31
|
+
* Visual theme styling.
|
|
32
|
+
* @default 'glass'
|
|
33
|
+
*/
|
|
34
|
+
theme?: BubbleToolbarTheme;
|
|
35
|
+
/**
|
|
36
|
+
* Toolbar height / bubble diameter.
|
|
37
|
+
* Preset 'sm' (40px), 'md' (48px), 'lg' (56px) or numeric pixels.
|
|
38
|
+
* @default 'md'
|
|
39
|
+
*/
|
|
40
|
+
size?: BubbleToolbarSize;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to apply the blurred frosted glass effect (backdrop-filter: blur).
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
blurred?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Amount of backdrop blur in pixels or CSS string.
|
|
48
|
+
* @default 16
|
|
49
|
+
*/
|
|
50
|
+
blurAmount?: number | string;
|
|
51
|
+
/**
|
|
52
|
+
* Spacing between bubble groups.
|
|
53
|
+
* @default 8
|
|
54
|
+
*/
|
|
55
|
+
groupGap?: number | string;
|
|
56
|
+
/**
|
|
57
|
+
* Spacing between elements inside a multi-node pill group.
|
|
58
|
+
* @default 8
|
|
59
|
+
*/
|
|
60
|
+
itemGap?: number | string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to display subtle borders around bubbles.
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
bordered?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to render floating shadow, or custom shadow CSS string.
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
shadow?: boolean | string;
|
|
71
|
+
/**
|
|
72
|
+
* Custom CSS class name for toolbar container.
|
|
73
|
+
*/
|
|
74
|
+
className?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Inline CSS styles for toolbar container.
|
|
77
|
+
*/
|
|
78
|
+
style?: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* Accessible ARIA label for toolbar.
|
|
81
|
+
* @default 'Toolbar'
|
|
82
|
+
*/
|
|
83
|
+
ariaLabel?: string;
|
|
84
|
+
}
|
|
85
|
+
interface BubbleGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
86
|
+
/**
|
|
87
|
+
* Elements inside this group.
|
|
88
|
+
* 1 node renders as a circle.
|
|
89
|
+
* More than 1 node renders as a pill / rounded rectangle.
|
|
90
|
+
*/
|
|
91
|
+
children?: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Force shape instead of auto-calculating from children count.
|
|
94
|
+
*/
|
|
95
|
+
shape?: BubbleShape;
|
|
96
|
+
/**
|
|
97
|
+
* Override bubble size / height for this specific group.
|
|
98
|
+
*/
|
|
99
|
+
size?: BubbleToolbarSize;
|
|
100
|
+
/**
|
|
101
|
+
* Gap between items in this group.
|
|
102
|
+
*/
|
|
103
|
+
itemGap?: number | string;
|
|
104
|
+
/**
|
|
105
|
+
* Custom CSS class name.
|
|
106
|
+
*/
|
|
107
|
+
className?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Inline CSS styles.
|
|
110
|
+
*/
|
|
111
|
+
style?: CSSProperties;
|
|
112
|
+
}
|
|
113
|
+
interface BubbleIconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
114
|
+
/**
|
|
115
|
+
* Icon identifier or label for standard icons.
|
|
116
|
+
*/
|
|
117
|
+
name?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Custom icon element or SVG.
|
|
120
|
+
*/
|
|
121
|
+
icon?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Active or toggled state.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
active?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Optional badge count or indicator.
|
|
129
|
+
*/
|
|
130
|
+
badge?: ReactNode | number | string;
|
|
131
|
+
/**
|
|
132
|
+
* Tooltip text.
|
|
133
|
+
*/
|
|
134
|
+
tooltip?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Explicit accessible label.
|
|
137
|
+
*/
|
|
138
|
+
ariaLabel?: string;
|
|
139
|
+
}
|
|
140
|
+
interface BubbleAreaProps extends HTMLAttributes<HTMLDivElement> {
|
|
141
|
+
/**
|
|
142
|
+
* Content inside the toolbar area (e.g. search input, label, sliders).
|
|
143
|
+
*/
|
|
144
|
+
children?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Minimum width for the area.
|
|
147
|
+
*/
|
|
148
|
+
minWidth?: number | string;
|
|
149
|
+
/**
|
|
150
|
+
* Maximum width for the area.
|
|
151
|
+
*/
|
|
152
|
+
maxWidth?: number | string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare const BubbleGroup: React__default.ForwardRefExoticComponent<BubbleGroupProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
156
|
+
|
|
157
|
+
interface BubbleToolbarComponent extends React__default.ForwardRefExoticComponent<BubbleToolbarProps & React__default.RefAttributes<HTMLDivElement>> {
|
|
158
|
+
Group: typeof BubbleGroup;
|
|
159
|
+
}
|
|
160
|
+
declare const BubbleToolbar: BubbleToolbarComponent;
|
|
161
|
+
|
|
162
|
+
declare const BubbleIconButton: React__default.ForwardRefExoticComponent<BubbleIconButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
163
|
+
|
|
164
|
+
declare const BubbleArea: React__default.ForwardRefExoticComponent<BubbleAreaProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
165
|
+
|
|
166
|
+
interface BubbleToolbarContextValue {
|
|
167
|
+
size: BubbleToolbarSize;
|
|
168
|
+
theme: BubbleToolbarTheme;
|
|
169
|
+
blurred: boolean;
|
|
170
|
+
blurAmount: number | string;
|
|
171
|
+
itemGap: number | string;
|
|
172
|
+
bordered: boolean;
|
|
173
|
+
shadow: boolean | string;
|
|
174
|
+
}
|
|
175
|
+
declare const BubbleToolbarContext: React.Context<BubbleToolbarContextValue>;
|
|
176
|
+
declare const useBubbleToolbar: () => BubbleToolbarContextValue;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Returns an array of non-null, non-undefined, non-boolean child elements.
|
|
180
|
+
* Unpacks React.Fragment if encountered at the top level.
|
|
181
|
+
*/
|
|
182
|
+
declare function getValidChildren(children: ReactNode): ReactNode[];
|
|
183
|
+
|
|
184
|
+
declare function resolveSize(size: BubbleToolbarSize): number;
|
|
185
|
+
declare function formatPx(val: number | string): string;
|
|
186
|
+
declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string, bordered: boolean, shadow: boolean | string): CSSProperties;
|
|
187
|
+
|
|
188
|
+
export { BubbleArea, type BubbleAreaProps, BubbleGroup, type BubbleGroupProps, BubbleIconButton, type BubbleIconButtonProps, type BubbleShape, BubbleToolbar, type BubbleToolbarComponent, BubbleToolbarContext, type BubbleToolbarPosition, type BubbleToolbarProps, type BubbleToolbarSize, type BubbleToolbarTheme, formatPx, getGlassStyles, getValidChildren, resolveSize, useBubbleToolbar };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { HTMLAttributes, ReactNode, CSSProperties, ButtonHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type BubbleToolbarTheme = 'light' | 'dark' | 'auto' | 'glass';
|
|
5
|
+
type BubbleToolbarPosition = 'bottom' | 'top' | 'static' | 'custom';
|
|
6
|
+
type BubbleToolbarSize = 'sm' | 'md' | 'lg' | number;
|
|
7
|
+
type BubbleShape = 'circle' | 'pill';
|
|
8
|
+
interface BubbleToolbarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
9
|
+
/**
|
|
10
|
+
* Definition of items by groups.
|
|
11
|
+
* Example:
|
|
12
|
+
* [
|
|
13
|
+
* [<Logo />],
|
|
14
|
+
* [<IconButton name="search" />, <ToolbarArea />],
|
|
15
|
+
* [<IconButton name="theme" />],
|
|
16
|
+
* [<IconButton name="chat" />],
|
|
17
|
+
* [<IconButton name="notifications" />]
|
|
18
|
+
* ]
|
|
19
|
+
*/
|
|
20
|
+
groups?: ReactNode[][];
|
|
21
|
+
/**
|
|
22
|
+
* Alternatively, declarative composition using BubbleToolbar.Group children.
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Placement on the screen.
|
|
27
|
+
* @default 'bottom'
|
|
28
|
+
*/
|
|
29
|
+
position?: BubbleToolbarPosition;
|
|
30
|
+
/**
|
|
31
|
+
* Visual theme styling.
|
|
32
|
+
* @default 'glass'
|
|
33
|
+
*/
|
|
34
|
+
theme?: BubbleToolbarTheme;
|
|
35
|
+
/**
|
|
36
|
+
* Toolbar height / bubble diameter.
|
|
37
|
+
* Preset 'sm' (40px), 'md' (48px), 'lg' (56px) or numeric pixels.
|
|
38
|
+
* @default 'md'
|
|
39
|
+
*/
|
|
40
|
+
size?: BubbleToolbarSize;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to apply the blurred frosted glass effect (backdrop-filter: blur).
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
blurred?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Amount of backdrop blur in pixels or CSS string.
|
|
48
|
+
* @default 16
|
|
49
|
+
*/
|
|
50
|
+
blurAmount?: number | string;
|
|
51
|
+
/**
|
|
52
|
+
* Spacing between bubble groups.
|
|
53
|
+
* @default 8
|
|
54
|
+
*/
|
|
55
|
+
groupGap?: number | string;
|
|
56
|
+
/**
|
|
57
|
+
* Spacing between elements inside a multi-node pill group.
|
|
58
|
+
* @default 8
|
|
59
|
+
*/
|
|
60
|
+
itemGap?: number | string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to display subtle borders around bubbles.
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
bordered?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether to render floating shadow, or custom shadow CSS string.
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
shadow?: boolean | string;
|
|
71
|
+
/**
|
|
72
|
+
* Custom CSS class name for toolbar container.
|
|
73
|
+
*/
|
|
74
|
+
className?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Inline CSS styles for toolbar container.
|
|
77
|
+
*/
|
|
78
|
+
style?: CSSProperties;
|
|
79
|
+
/**
|
|
80
|
+
* Accessible ARIA label for toolbar.
|
|
81
|
+
* @default 'Toolbar'
|
|
82
|
+
*/
|
|
83
|
+
ariaLabel?: string;
|
|
84
|
+
}
|
|
85
|
+
interface BubbleGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
86
|
+
/**
|
|
87
|
+
* Elements inside this group.
|
|
88
|
+
* 1 node renders as a circle.
|
|
89
|
+
* More than 1 node renders as a pill / rounded rectangle.
|
|
90
|
+
*/
|
|
91
|
+
children?: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Force shape instead of auto-calculating from children count.
|
|
94
|
+
*/
|
|
95
|
+
shape?: BubbleShape;
|
|
96
|
+
/**
|
|
97
|
+
* Override bubble size / height for this specific group.
|
|
98
|
+
*/
|
|
99
|
+
size?: BubbleToolbarSize;
|
|
100
|
+
/**
|
|
101
|
+
* Gap between items in this group.
|
|
102
|
+
*/
|
|
103
|
+
itemGap?: number | string;
|
|
104
|
+
/**
|
|
105
|
+
* Custom CSS class name.
|
|
106
|
+
*/
|
|
107
|
+
className?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Inline CSS styles.
|
|
110
|
+
*/
|
|
111
|
+
style?: CSSProperties;
|
|
112
|
+
}
|
|
113
|
+
interface BubbleIconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
114
|
+
/**
|
|
115
|
+
* Icon identifier or label for standard icons.
|
|
116
|
+
*/
|
|
117
|
+
name?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Custom icon element or SVG.
|
|
120
|
+
*/
|
|
121
|
+
icon?: ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Active or toggled state.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
active?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Optional badge count or indicator.
|
|
129
|
+
*/
|
|
130
|
+
badge?: ReactNode | number | string;
|
|
131
|
+
/**
|
|
132
|
+
* Tooltip text.
|
|
133
|
+
*/
|
|
134
|
+
tooltip?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Explicit accessible label.
|
|
137
|
+
*/
|
|
138
|
+
ariaLabel?: string;
|
|
139
|
+
}
|
|
140
|
+
interface BubbleAreaProps extends HTMLAttributes<HTMLDivElement> {
|
|
141
|
+
/**
|
|
142
|
+
* Content inside the toolbar area (e.g. search input, label, sliders).
|
|
143
|
+
*/
|
|
144
|
+
children?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Minimum width for the area.
|
|
147
|
+
*/
|
|
148
|
+
minWidth?: number | string;
|
|
149
|
+
/**
|
|
150
|
+
* Maximum width for the area.
|
|
151
|
+
*/
|
|
152
|
+
maxWidth?: number | string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
declare const BubbleGroup: React__default.ForwardRefExoticComponent<BubbleGroupProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
156
|
+
|
|
157
|
+
interface BubbleToolbarComponent extends React__default.ForwardRefExoticComponent<BubbleToolbarProps & React__default.RefAttributes<HTMLDivElement>> {
|
|
158
|
+
Group: typeof BubbleGroup;
|
|
159
|
+
}
|
|
160
|
+
declare const BubbleToolbar: BubbleToolbarComponent;
|
|
161
|
+
|
|
162
|
+
declare const BubbleIconButton: React__default.ForwardRefExoticComponent<BubbleIconButtonProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
163
|
+
|
|
164
|
+
declare const BubbleArea: React__default.ForwardRefExoticComponent<BubbleAreaProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
165
|
+
|
|
166
|
+
interface BubbleToolbarContextValue {
|
|
167
|
+
size: BubbleToolbarSize;
|
|
168
|
+
theme: BubbleToolbarTheme;
|
|
169
|
+
blurred: boolean;
|
|
170
|
+
blurAmount: number | string;
|
|
171
|
+
itemGap: number | string;
|
|
172
|
+
bordered: boolean;
|
|
173
|
+
shadow: boolean | string;
|
|
174
|
+
}
|
|
175
|
+
declare const BubbleToolbarContext: React.Context<BubbleToolbarContextValue>;
|
|
176
|
+
declare const useBubbleToolbar: () => BubbleToolbarContextValue;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Returns an array of non-null, non-undefined, non-boolean child elements.
|
|
180
|
+
* Unpacks React.Fragment if encountered at the top level.
|
|
181
|
+
*/
|
|
182
|
+
declare function getValidChildren(children: ReactNode): ReactNode[];
|
|
183
|
+
|
|
184
|
+
declare function resolveSize(size: BubbleToolbarSize): number;
|
|
185
|
+
declare function formatPx(val: number | string): string;
|
|
186
|
+
declare function getGlassStyles(theme: BubbleToolbarTheme, blurred: boolean, blurAmount: number | string, bordered: boolean, shadow: boolean | string): CSSProperties;
|
|
187
|
+
|
|
188
|
+
export { BubbleArea, type BubbleAreaProps, BubbleGroup, type BubbleGroupProps, BubbleIconButton, type BubbleIconButtonProps, type BubbleShape, BubbleToolbar, type BubbleToolbarComponent, BubbleToolbarContext, type BubbleToolbarPosition, type BubbleToolbarProps, type BubbleToolbarSize, type BubbleToolbarTheme, formatPx, getGlassStyles, getValidChildren, resolveSize, useBubbleToolbar };
|