@blobbies/react 0.6.0 → 0.7.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/dist/index.cjs +2 -256
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -10
- package/dist/index.d.ts +20 -10
- package/dist/index.js +2 -256
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { SVGProps, CSSProperties, RefObject, HTMLAttributes, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
3
3
|
import { AvatarOptions, MotionOptions, AvatarAnimate } from 'blobbies';
|
|
4
4
|
export { AvatarAnimate, AvatarColor, AvatarExpression, AvatarOptions, AvatarShape, COLORS, EXPRESSIONS, EXPRESSION_COUNT, EXPRESSION_NAMES, FollowTarget, MotionOptions, PALETTE, SHAPES, SHAPE_COUNT } from 'blobbies';
|
|
5
|
+
import { PickerSnapshot } from 'blobbies/picker';
|
|
5
6
|
|
|
6
7
|
interface AvatarProps extends AvatarOptions, Omit<SVGProps<SVGSVGElement>, 'name' | 'className' | 'color' | 'style'> {
|
|
7
8
|
/** The name to derive the avatar from. */
|
|
@@ -31,18 +32,22 @@ interface UseAvatarMotionOptions extends MotionOptions {
|
|
|
31
32
|
*/
|
|
32
33
|
declare function useAvatarMotion(ref: RefObject<SVGSVGElement | null>, options?: UseAvatarMotionOptions): void;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The Blobbies avatar picker — the Look Map.
|
|
37
|
+
*
|
|
38
|
+
* This file is chrome. The map, the gestures, the lens, the measurement and the
|
|
39
|
+
* value all live in `createPicker` in the core, which is what Vue, Svelte and
|
|
40
|
+
* `<blobbies-picker>` will use too. Nothing about the behaviour is decided here,
|
|
41
|
+
* so nothing here can drift from those.
|
|
42
|
+
*
|
|
43
|
+
* It ships as parts, like Glyph's picker: `AvatarPickerRoot` owns the runtime,
|
|
44
|
+
* the parts are composable, and `AvatarPicker` is the preset.
|
|
45
|
+
*/
|
|
46
|
+
interface AvatarPickerState extends PickerSnapshot {
|
|
40
47
|
nextExpression: () => void;
|
|
41
48
|
previousExpression: () => void;
|
|
42
49
|
toggleBlush: () => void;
|
|
43
|
-
spotlight: boolean;
|
|
44
50
|
toggleSpotlight: () => void;
|
|
45
|
-
palette: readonly string[];
|
|
46
51
|
reset: () => void;
|
|
47
52
|
save: () => void;
|
|
48
53
|
cancel: () => void;
|
|
@@ -70,10 +75,15 @@ interface AvatarPickerRootProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|
|
70
75
|
}
|
|
71
76
|
declare function AvatarPickerRoot(props: AvatarPickerRootProps): react.JSX.Element;
|
|
72
77
|
type AvatarPickerSurfaceProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
78
|
+
/**
|
|
79
|
+
* Where the map goes. The element itself is built by the runtime — 35 cells
|
|
80
|
+
* rewritten every frame during a pan, which is not something a reconciler
|
|
81
|
+
* should be asked to do — so this mounts it and hands over the class name.
|
|
82
|
+
*/
|
|
73
83
|
declare function AvatarPickerSurface(props: AvatarPickerSurfaceProps): react.JSX.Element;
|
|
74
84
|
/**
|
|
75
|
-
* The chosen face, for a layout that wants to show it outside the map. It
|
|
76
|
-
*
|
|
85
|
+
* The chosen face, for a layout that wants to show it outside the map. It reads
|
|
86
|
+
* the picker's current value, so it stays in step with the surface.
|
|
77
87
|
*/
|
|
78
88
|
type AvatarPickerPreviewProps = Omit<AvatarProps, 'name'>;
|
|
79
89
|
declare function AvatarPickerPreview(props: AvatarPickerPreviewProps): react.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { SVGProps, CSSProperties, RefObject, HTMLAttributes, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
3
3
|
import { AvatarOptions, MotionOptions, AvatarAnimate } from 'blobbies';
|
|
4
4
|
export { AvatarAnimate, AvatarColor, AvatarExpression, AvatarOptions, AvatarShape, COLORS, EXPRESSIONS, EXPRESSION_COUNT, EXPRESSION_NAMES, FollowTarget, MotionOptions, PALETTE, SHAPES, SHAPE_COUNT } from 'blobbies';
|
|
5
|
+
import { PickerSnapshot } from 'blobbies/picker';
|
|
5
6
|
|
|
6
7
|
interface AvatarProps extends AvatarOptions, Omit<SVGProps<SVGSVGElement>, 'name' | 'className' | 'color' | 'style'> {
|
|
7
8
|
/** The name to derive the avatar from. */
|
|
@@ -31,18 +32,22 @@ interface UseAvatarMotionOptions extends MotionOptions {
|
|
|
31
32
|
*/
|
|
32
33
|
declare function useAvatarMotion(ref: RefObject<SVGSVGElement | null>, options?: UseAvatarMotionOptions): void;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The Blobbies avatar picker — the Look Map.
|
|
37
|
+
*
|
|
38
|
+
* This file is chrome. The map, the gestures, the lens, the measurement and the
|
|
39
|
+
* value all live in `createPicker` in the core, which is what Vue, Svelte and
|
|
40
|
+
* `<blobbies-picker>` will use too. Nothing about the behaviour is decided here,
|
|
41
|
+
* so nothing here can drift from those.
|
|
42
|
+
*
|
|
43
|
+
* It ships as parts, like Glyph's picker: `AvatarPickerRoot` owns the runtime,
|
|
44
|
+
* the parts are composable, and `AvatarPicker` is the preset.
|
|
45
|
+
*/
|
|
46
|
+
interface AvatarPickerState extends PickerSnapshot {
|
|
40
47
|
nextExpression: () => void;
|
|
41
48
|
previousExpression: () => void;
|
|
42
49
|
toggleBlush: () => void;
|
|
43
|
-
spotlight: boolean;
|
|
44
50
|
toggleSpotlight: () => void;
|
|
45
|
-
palette: readonly string[];
|
|
46
51
|
reset: () => void;
|
|
47
52
|
save: () => void;
|
|
48
53
|
cancel: () => void;
|
|
@@ -70,10 +75,15 @@ interface AvatarPickerRootProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|
|
70
75
|
}
|
|
71
76
|
declare function AvatarPickerRoot(props: AvatarPickerRootProps): react.JSX.Element;
|
|
72
77
|
type AvatarPickerSurfaceProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
78
|
+
/**
|
|
79
|
+
* Where the map goes. The element itself is built by the runtime — 35 cells
|
|
80
|
+
* rewritten every frame during a pan, which is not something a reconciler
|
|
81
|
+
* should be asked to do — so this mounts it and hands over the class name.
|
|
82
|
+
*/
|
|
73
83
|
declare function AvatarPickerSurface(props: AvatarPickerSurfaceProps): react.JSX.Element;
|
|
74
84
|
/**
|
|
75
|
-
* The chosen face, for a layout that wants to show it outside the map. It
|
|
76
|
-
*
|
|
85
|
+
* The chosen face, for a layout that wants to show it outside the map. It reads
|
|
86
|
+
* the picker's current value, so it stays in step with the surface.
|
|
77
87
|
*/
|
|
78
88
|
type AvatarPickerPreviewProps = Omit<AvatarProps, 'name'>;
|
|
79
89
|
declare function AvatarPickerPreview(props: AvatarPickerPreviewProps): react.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -1,257 +1,3 @@
|
|
|
1
|
-
import {createContext,useRef,useEffect,useMemo,useState,useContext,useInsertionEffect
|
|
2
|
-
.
|
|
3
|
-
--bb-picker-panel: #ffffff;
|
|
4
|
-
--bb-picker-ink: #18181b;
|
|
5
|
-
--bb-picker-muted: #71717a;
|
|
6
|
-
--bb-picker-line: #e4e4e7;
|
|
7
|
-
--bb-picker-accent: #18181b;
|
|
8
|
-
--bb-picker-accent-ink: #ffffff;
|
|
9
|
-
--bb-picker-radius: 18px;
|
|
10
|
-
--bb-picker-spring: cubic-bezier(0.3, 1.4, 0.5, 1);
|
|
11
|
-
--bb-picker-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
12
|
-
--bb-picker-fade: 150ms ease;
|
|
13
|
-
--bb-picker-mono: var(--bb-picker-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
|
|
14
|
-
|
|
15
|
-
width: min(460px, 100%);
|
|
16
|
-
display: grid;
|
|
17
|
-
border: 1px solid var(--bb-picker-line);
|
|
18
|
-
border-radius: var(--bb-picker-radius);
|
|
19
|
-
background: var(--bb-picker-panel);
|
|
20
|
-
color: var(--bb-picker-ink);
|
|
21
|
-
overflow: hidden;
|
|
22
|
-
box-shadow: var(--bb-picker-shadow, 0 1px 2px rgb(0 0 0 / 0.06));
|
|
23
|
-
transition: background-color 0.5s ease;
|
|
24
|
-
container-type: inline-size;
|
|
25
|
-
font-size: 14px;
|
|
26
|
-
line-height: 1.5;
|
|
27
|
-
-webkit-tap-highlight-color: transparent;
|
|
28
|
-
}
|
|
29
|
-
.bb-picker * { box-sizing: border-box; }
|
|
30
|
-
.bb-picker button {
|
|
31
|
-
font: inherit;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
touch-action: manipulation;
|
|
34
|
-
user-select: none;
|
|
35
|
-
-webkit-user-select: none;
|
|
36
|
-
-webkit-touch-callout: none;
|
|
37
|
-
}
|
|
38
|
-
.bb-picker h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
|
|
39
|
-
.bb-picker p { margin: 0; }
|
|
40
|
-
|
|
41
|
-
.bb-picker-head { padding: 16px 20px 10px; }
|
|
42
|
-
.bb-picker-head p { margin-top: 3px; color: var(--bb-picker-muted); font-size: 13px; }
|
|
43
|
-
|
|
44
|
-
.bb-picker-surface {
|
|
45
|
-
position: relative;
|
|
46
|
-
justify-self: center;
|
|
47
|
-
background: radial-gradient(70% 70% at 50% 42%, color-mix(in oklab, var(--bb-picker-ink) 6%, transparent), transparent 74%);
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
cursor: grab;
|
|
50
|
-
touch-action: none;
|
|
51
|
-
user-select: none;
|
|
52
|
-
-webkit-user-select: none;
|
|
53
|
-
-webkit-touch-callout: none;
|
|
54
|
-
outline: none;
|
|
55
|
-
}
|
|
56
|
-
.bb-picker-surface[data-dragging] { cursor: grabbing; }
|
|
57
|
-
.bb-picker-surface:not([data-dragging]) .bb-picker-cell { cursor: pointer; }
|
|
58
|
-
.bb-picker-surface:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--bb-picker-ink) 24%, transparent); }
|
|
59
|
-
|
|
60
|
-
.bb-picker-viewport { position: absolute; inset: var(--bb-picker-pad, 8px); overflow: hidden; }
|
|
61
|
-
.bb-picker-world { position: absolute; left: 0; top: 0; will-change: transform; }
|
|
62
|
-
|
|
63
|
-
.bb-picker-cell {
|
|
64
|
-
position: absolute;
|
|
65
|
-
left: 0;
|
|
66
|
-
top: 0;
|
|
67
|
-
display: grid;
|
|
68
|
-
place-items: center;
|
|
69
|
-
transform-origin: center;
|
|
70
|
-
transition: transform 0.3s var(--bb-picker-spring), opacity 0.2s ease, filter 0.18s var(--bb-picker-ease-out);
|
|
71
|
-
}
|
|
72
|
-
.bb-picker-lift { display: block; width: 70%; height: 70%; transition: transform 0.45s var(--bb-picker-spring); }
|
|
73
|
-
.bb-picker-lift svg { display: block; width: 100%; height: 100%; }
|
|
74
|
-
.bb-picker-ring {
|
|
75
|
-
position: absolute;
|
|
76
|
-
inset: 9%;
|
|
77
|
-
border-radius: 50%;
|
|
78
|
-
border: 2px solid var(--bb-picker-ink);
|
|
79
|
-
opacity: 0;
|
|
80
|
-
scale: 0.9;
|
|
81
|
-
transition: opacity var(--bb-picker-fade), scale 0.28s var(--bb-picker-spring);
|
|
82
|
-
pointer-events: none;
|
|
83
|
-
}
|
|
84
|
-
.bb-picker-cell[data-focus] .bb-picker-ring { opacity: 1; scale: 1; }
|
|
85
|
-
|
|
86
|
-
.bb-picker-check {
|
|
87
|
-
position: absolute;
|
|
88
|
-
top: 4%;
|
|
89
|
-
right: 4%;
|
|
90
|
-
display: grid;
|
|
91
|
-
place-items: center;
|
|
92
|
-
width: 18px;
|
|
93
|
-
height: 18px;
|
|
94
|
-
border-radius: 50%;
|
|
95
|
-
background: var(--bb-picker-accent);
|
|
96
|
-
color: var(--bb-picker-accent-ink);
|
|
97
|
-
box-shadow: 0 0 0 3px var(--bb-picker-panel);
|
|
98
|
-
opacity: 0;
|
|
99
|
-
scale: 0.5;
|
|
100
|
-
z-index: 7;
|
|
101
|
-
pointer-events: none;
|
|
102
|
-
transition: opacity var(--bb-picker-fade), scale 0.24s var(--bb-picker-spring);
|
|
103
|
-
}
|
|
104
|
-
.bb-picker-check[data-on] { opacity: 1; scale: 1; }
|
|
105
|
-
|
|
106
|
-
.bb-picker-mood {
|
|
107
|
-
display: flex;
|
|
108
|
-
align-items: center;
|
|
109
|
-
justify-content: center;
|
|
110
|
-
gap: 4px;
|
|
111
|
-
padding: 8px 20px 10px;
|
|
112
|
-
border-top: 1px solid var(--bb-picker-line);
|
|
113
|
-
margin-top: 10px;
|
|
114
|
-
}
|
|
115
|
-
.bb-picker-mood-name {
|
|
116
|
-
width: 12ch;
|
|
117
|
-
text-align: center;
|
|
118
|
-
white-space: nowrap;
|
|
119
|
-
overflow: hidden;
|
|
120
|
-
font: 11px/1 var(--bb-picker-mono);
|
|
121
|
-
letter-spacing: 0.06em;
|
|
122
|
-
text-transform: uppercase;
|
|
123
|
-
color: var(--bb-picker-muted);
|
|
124
|
-
animation: bb-picker-mood-in 0.26s var(--bb-picker-spring);
|
|
125
|
-
}
|
|
126
|
-
.bb-picker-step {
|
|
127
|
-
display: grid;
|
|
128
|
-
place-items: center;
|
|
129
|
-
width: 22px;
|
|
130
|
-
height: 22px;
|
|
131
|
-
padding: 0;
|
|
132
|
-
border: 0;
|
|
133
|
-
border-radius: 50%;
|
|
134
|
-
background: none;
|
|
135
|
-
color: var(--bb-picker-muted);
|
|
136
|
-
transition: background-color var(--bb-picker-fade), color var(--bb-picker-fade), transform 160ms var(--bb-picker-ease-out);
|
|
137
|
-
}
|
|
138
|
-
.bb-picker-step:active { transform: scale(0.94); }
|
|
139
|
-
@media (hover: hover) and (pointer: fine) {
|
|
140
|
-
.bb-picker-step:hover { background: color-mix(in oklab, var(--bb-picker-ink) 8%, transparent); color: var(--bb-picker-ink); }
|
|
141
|
-
}
|
|
142
|
-
.bb-picker-step:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bb-picker-panel), 0 0 0 3.5px var(--bb-picker-ink); }
|
|
143
|
-
|
|
144
|
-
.bb-picker-foot {
|
|
145
|
-
display: flex;
|
|
146
|
-
align-items: center;
|
|
147
|
-
flex-wrap: wrap;
|
|
148
|
-
gap: 8px;
|
|
149
|
-
padding: 12px 16px;
|
|
150
|
-
border-top: 1px solid var(--bb-picker-line);
|
|
151
|
-
}
|
|
152
|
-
.bb-picker-grow { flex: 1; }
|
|
153
|
-
|
|
154
|
-
.bb-picker-btn {
|
|
155
|
-
display: inline-flex;
|
|
156
|
-
align-items: center;
|
|
157
|
-
gap: 7px;
|
|
158
|
-
height: 32px;
|
|
159
|
-
padding: 0 11px;
|
|
160
|
-
border: 0;
|
|
161
|
-
border-radius: 8px;
|
|
162
|
-
background: color-mix(in oklab, var(--bb-picker-ink) 8%, transparent);
|
|
163
|
-
color: var(--bb-picker-ink);
|
|
164
|
-
font-size: 13px;
|
|
165
|
-
font-weight: 500;
|
|
166
|
-
white-space: nowrap;
|
|
167
|
-
transition: background-color var(--bb-picker-fade), transform 160ms var(--bb-picker-ease-out);
|
|
168
|
-
}
|
|
169
|
-
.bb-picker-btn:active { transform: scale(0.97); }
|
|
170
|
-
@media (hover: hover) and (pointer: fine) {
|
|
171
|
-
.bb-picker-btn:hover { background: color-mix(in oklab, var(--bb-picker-ink) 14%, transparent); }
|
|
172
|
-
}
|
|
173
|
-
.bb-picker-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bb-picker-panel), 0 0 0 3.5px var(--bb-picker-ink); }
|
|
174
|
-
.bb-picker-primary { background: var(--bb-picker-accent); color: var(--bb-picker-accent-ink); }
|
|
175
|
-
@media (hover: hover) and (pointer: fine) {
|
|
176
|
-
.bb-picker-primary:hover { background: color-mix(in oklab, var(--bb-picker-accent) 86%, var(--bb-picker-panel)); }
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.bb-picker-reset {
|
|
180
|
-
height: 28px;
|
|
181
|
-
padding: 0 8px;
|
|
182
|
-
border: 0;
|
|
183
|
-
border-radius: 8px;
|
|
184
|
-
background: none;
|
|
185
|
-
color: var(--bb-picker-muted);
|
|
186
|
-
font-size: 12px;
|
|
187
|
-
font-weight: 500;
|
|
188
|
-
transition: transform 160ms var(--bb-picker-ease-out);
|
|
189
|
-
}
|
|
190
|
-
.bb-picker-reset:active { transform: scale(0.97); }
|
|
191
|
-
@media (hover: hover) and (pointer: fine) {
|
|
192
|
-
.bb-picker-reset:hover { color: var(--bb-picker-ink); }
|
|
193
|
-
}
|
|
194
|
-
/* Hidden, not removed: the reset appears on the first change, and taking it
|
|
195
|
-
out of the flow would reflow the footer under the finger that just chose. */
|
|
196
|
-
.bb-picker-reset:disabled { visibility: hidden; pointer-events: none; }
|
|
197
|
-
|
|
198
|
-
.bb-picker-blush,
|
|
199
|
-
.bb-picker-spotlight {
|
|
200
|
-
display: inline-flex;
|
|
201
|
-
align-items: center;
|
|
202
|
-
gap: 7px;
|
|
203
|
-
height: 28px;
|
|
204
|
-
padding: 0 11px;
|
|
205
|
-
border: 1px solid var(--bb-picker-line);
|
|
206
|
-
border-radius: 99px;
|
|
207
|
-
background: none;
|
|
208
|
-
color: var(--bb-picker-muted);
|
|
209
|
-
font-size: 12px;
|
|
210
|
-
font-weight: 500;
|
|
211
|
-
transition: border-color var(--bb-picker-fade), color var(--bb-picker-fade), transform 160ms var(--bb-picker-ease-out);
|
|
212
|
-
}
|
|
213
|
-
.bb-picker-blush:active,
|
|
214
|
-
.bb-picker-spotlight:active { transform: scale(0.97); }
|
|
215
|
-
.bb-picker-blush::before,
|
|
216
|
-
.bb-picker-spotlight::before {
|
|
217
|
-
content: '';
|
|
218
|
-
width: 8px;
|
|
219
|
-
height: 8px;
|
|
220
|
-
border-radius: 50%;
|
|
221
|
-
border: 1.5px solid currentColor;
|
|
222
|
-
transition: background-color var(--bb-picker-fade), border-color var(--bb-picker-fade);
|
|
223
|
-
}
|
|
224
|
-
@media (hover: hover) and (pointer: fine) {
|
|
225
|
-
.bb-picker-blush:hover,
|
|
226
|
-
.bb-picker-spotlight:hover { border-color: var(--bb-picker-muted); color: var(--bb-picker-ink); }
|
|
227
|
-
}
|
|
228
|
-
.bb-picker-blush[data-on],
|
|
229
|
-
.bb-picker-spotlight[data-on] { color: var(--bb-picker-ink); border-color: color-mix(in oklab, var(--bb-picker-ink) 28%, transparent); }
|
|
230
|
-
.bb-picker-blush[data-on]::before,
|
|
231
|
-
.bb-picker-spotlight[data-on]::before { background: currentColor; }
|
|
232
|
-
|
|
233
|
-
@keyframes bb-picker-mood-in { from { opacity: 0; translate: 0 3px; } }
|
|
234
|
-
|
|
235
|
-
@container (max-width: 440px) {
|
|
236
|
-
.bb-picker-head { padding: 14px 14px 8px; }
|
|
237
|
-
.bb-picker-mood { padding: 6px 14px 8px; }
|
|
238
|
-
.bb-picker-foot { padding: 10px 12px; }
|
|
239
|
-
/* The grower becomes a full-width break, so Cancel and Save share the last
|
|
240
|
-
row instead of being pushed past the edge of a phone-sized panel. */
|
|
241
|
-
.bb-picker-foot .bb-picker-grow { flex-basis: 100%; height: 0; }
|
|
242
|
-
.bb-picker-foot .bb-picker-btn { flex: 1 1 0; justify-content: center; }
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
@container (max-width: 360px) {
|
|
246
|
-
.bb-picker-foot { gap: 6px; }
|
|
247
|
-
.bb-picker-blush,
|
|
248
|
-
.bb-picker-spotlight { padding: 0 9px; }
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@media (prefers-reduced-motion: reduce) {
|
|
252
|
-
.bb-picker { transition: none; }
|
|
253
|
-
.bb-picker-world { will-change: auto; }
|
|
254
|
-
.bb-picker-cell, .bb-picker-lift, .bb-picker-ring, .bb-picker-mood-name { transition: none; animation: none; }
|
|
255
|
-
}
|
|
256
|
-
`;function Ze(){useInsertionEffect(()=>{if(typeof document>"u"||document.getElementById(Qe))return;let t=document.createElement("style");t.id=Qe,t.textContent=Hr,document.head.prepend(t);},[]);}var ce=(t,o,i)=>Math.min(i,Math.max(o,t)),Ie=typeof window<"u"?useLayoutEffect:useEffect,nr=createContext(null);function D(){let t=useContext(nr);if(!t)throw new Error("AvatarPicker parts must be used inside <AvatarPickerRoot>.");return t}function qr(){let{map:t,...o}=D();return o}function tr({dir:t}){return jsx("svg",{viewBox:"0 0 12 12",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:t==="l"?"M7.5 2.5 4 6l3.5 3.5":"M4.5 2.5 8 6l-3.5 3.5"})})}function Jr(t){return t.ctrlKey||t.deltaMode!==0?false:t.deltaX!==0||Math.abs(t.deltaY)<40||!Number.isInteger(t.deltaY)}function or(t){let{name:o,defaultValue:i,onChange:p,onSave:u,onCancel:d,palette:b=PALETTE,spotlight:f=true,unstyled:C=false,className:re,style:K,children:H,...q}=t;Ze();let m=useRef({color:(()=>{let e=i?.color?b.indexOf(i.color):CENTER_COLUMN;return e>=0?e:CENTER_COLUMN})(),expression:(()=>{let e=i?.expression?EXPRESSIONS.indexOf(i.expression):CENTER_ROW;return e>=0?e:CENTER_ROW})(),blush:i?.blush??true}),[B,J]=useState({cell:68,gap:MAX_GAP}),[F,Q]=useState(m.current.blush??true),[te,w]=useState(null),[I,k]=useState(f),[g,X]=useState(false),[R,j]=useState(null),[se,z]=useState(false),[ne,le]=useState(false),[pe,ke]=useState(0),{cell:N,gap:oe}=B,Me=N+oe,ze=COLUMNS*N+(COLUMNS-1)*oe,Ye=ROWS*N+(ROWS-1)*oe,br=ze+GRID_PADDING*2,dr=Ye+GRID_PADDING*2,Y=useRef(m.current.color-CENTER_COLUMN),A=useRef(m.current.expression-CENTER_ROW),E=useRef({column:CENTER_COLUMN,row:CENTER_ROW}),n=useRef({x:0,y:0}),M=useRef({x:0,y:0}),v=useRef("idle"),y=useRef(0),L=useRef(0),me=useRef(0),Ge=useRef(0),G=useRef(false),U=useRef(Me);U.current=Me;let Ue=useRef(null),Se=useRef(null),ue=useRef(null),Ce=useRef(new Map),be=useRef({x:0,y:0}),ie=useRef(null),Re=useRef(null),he=useRef({x:0,y:0}),Ne=useRef(0),xe=useRef(typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),Le=useRef(R),Ve=useRef(g),_e=useRef(ne),$e=useRef(N),Oe=useRef(false),ge=useRef(false),We=useRef(I);We.current=I,Le.current=R,Ve.current=g,_e.current=ne,$e.current=N;let V=()=>ke(e=>e+1),Te=()=>{let e=U.current,c=$e.current,r=Le.current&&!Ve.current&&!G.current&&!_e.current?Le.current:null;if(!r){if(!Oe.current&&ge.current)return;Oe.current=false,ge.current=true;for(let[,x]of Ce.current)x.style.transform="",x.style.opacity="1",x.style.filter="";return}Oe.current=true,ge.current=true;let l=r;for(let[x,P]of Ce.current){let[W,S]=x.split(":").map(Number),{dx:ae,dy:de,opacity:Er,blur:Je}=lensEffect({cell:{column:W,row:S},lens:l,pitch:e,size:c,offsetX:n.current.x,offsetY:n.current.y,push:!xe.current,spotlight:We.current});P.style.transform=`translate3d(${ae.toFixed(1)}px, ${de.toFixed(1)}px, 0)`,P.style.opacity=Er.toFixed(3),P.style.filter=Je>.06?`blur(${Je.toFixed(2)}px)`:"";}},Ke=(e,c)=>{let r=ue.current?.getBoundingClientRect();return r?cellAtPoint({x:e-r.left,y:c-r.top,pad:GRID_PADDING,offsetX:n.current.x,offsetY:n.current.y,pitch:U.current,width:ze,height:Ye}):null},fr=e=>{let c=Se.current;c&&(c.style.transform=`translate3d(${n.current.x}px, ${n.current.y+e}px, 0)`),Te();},h=()=>{let e=Se.current;e&&(e.style.transform=`translate3d(${n.current.x}px, ${n.current.y}px, 0)`);let c=U.current,r=lensCell(n.current.x,n.current.y,c);(r.column!==E.current.column||r.row!==E.current.row)&&(E.current=r,V()),Te();},_=()=>{let e=U.current,c=false,r=Math.floor(n.current.x/e),l=Math.floor(n.current.y/e);r!==0&&(Y.current-=r,n.current.x-=r*e,c=true),l!==0&&(A.current-=l,n.current.y-=l*e,c=true),c&&V();},ye=()=>{y.current||(y.current=requestAnimationFrame(function(){y.current=0;let c=U.current;if(v.current==="glide")n.current.x+=M.current.x,n.current.y+=M.current.y,M.current.x*=.9,M.current.y*=.9,Math.abs(M.current.x)<.4&&Math.abs(M.current.y)<.4&&(v.current="snap"),_(),h(),ye();else if(v.current==="snap"){let r=n.current.x<c/2?0:c,l=n.current.y<c/2?0:c;Math.abs(r-n.current.x)<.4&&Math.abs(l-n.current.y)<.4?(n.current={x:r,y:l},_(),h(),v.current="idle",le(false)):(n.current.x+=(r-n.current.x)*.22,n.current.y+=(l-n.current.y)*.22,_(),h(),ye());}}));},Pe=e=>{if(G.current)return;if(w(null),xe.current){A.current+=e,V(),h();return}G.current=true,Ge.current=e,z(true);let c=U.current,r=-e*c,l=performance.now(),x=300,P=W=>{let S=Math.min(1,(W-l)/x),ae=1-Math.pow(1-S,3);me.current=r*ae,fr(me.current),S<1?L.current=requestAnimationFrame(P):(A.current+=e,me.current=0,L.current=0,G.current=false,z(false),V(),h());};L.current=requestAnimationFrame(P);};Ie(()=>{let e=Ue.current;if(!e)return;let c=ue.current?.parentElement??e,r=()=>{let x=getComputedStyle(c),P=(parseFloat(x.paddingLeft)||0)+(parseFloat(x.paddingRight)||0),W=c.clientWidth-P,{cell:S,gap:ae}=gridMetrics(W);J(de=>de.cell===S&&de.gap===ae?de:{cell:S,gap:ae});};if(r(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(r);return l.observe(c),()=>l.disconnect()},[]),Ie(()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0),G.current&&L.current&&(cancelAnimationFrame(L.current),L.current=0,G.current=false),z(false),le(false),v.current="idle",_(),ge.current=false,h();},[N,oe]),Ie(()=>{Te();}),useEffect(()=>{let e=ue.current;if(!e)return;let c=r=>{if(Jr(r)){if(r.preventDefault(),xe.current){r.deltaX&&(Y.current+=r.deltaX>0?1:-1),r.deltaY&&(A.current+=r.deltaY>0?1:-1),V(),h();return}y.current&&(cancelAnimationFrame(y.current),y.current=0),n.current.x+=r.deltaX,n.current.y+=r.deltaY,M.current={x:ce(r.deltaX*.8,-40,40),y:ce(r.deltaY*.8,-40,40)},_(),h(),v.current="glide",ye();}};return e.addEventListener("wheel",c,{passive:false}),()=>e.removeEventListener("wheel",c)},[]);let vr=e=>{if(!(e.button>0)&&ie.current===null){ie.current=e.pointerId;try{ue.current?.setPointerCapture(e.pointerId);}catch{}y.current&&(cancelAnimationFrame(y.current),y.current=0),G.current&&(L.current&&cancelAnimationFrame(L.current),A.current+=Ge.current,me.current=0,L.current=0,G.current=false,z(false),h()),Re.current=Ke(e.clientX,e.clientY),v.current="press",Ne.current=dragSlop(e.pointerType),he.current={x:e.clientX,y:e.clientY},be.current={x:e.clientX,y:e.clientY},M.current={x:0,y:0},j(null);}},kr=e=>{if(v.current==="press"||v.current==="drag"){if(e.pointerId!==ie.current)return;if(v.current==="press"){if(exceedsSlop(he.current,{x:e.clientX,y:e.clientY},Ne.current)){v.current="drag";let x=e.clientX-he.current.x,P=e.clientY-he.current.y,W=Math.hypot(x,P)||1,S=(W-Ne.current)/W;n.current.x+=x*S,n.current.y+=P*S,be.current={x:e.clientX,y:e.clientY},M.current={x:ce(x*.85,-40,40),y:ce(P*.85,-40,40)},_(),h(),w(null),X(true);}return}let r=e.clientX-be.current.x,l=e.clientY-be.current.y;be.current={x:e.clientX,y:e.clientY},n.current.x+=r,n.current.y+=l,M.current={x:ce(r*.85,-40,40),y:ce(l*.85,-40,40)},_(),h();return}if(e.pointerType==="touch")return;let c=Ke(e.clientX,e.clientY);j(r=>c&&r&&r.column===c.column&&r.row===c.row?r:c);},De=(e,c)=>{if(ie.current!==null&&e.pointerId!==ie.current||(ie.current=null,v.current!=="press"&&v.current!=="drag"))return;let r=v.current==="press";if(X(false),r&&c){let l=Re.current;l&&w({color:wrapIndex(Y.current+l.column,b.length),expression:wrapIndex(A.current+l.row,EXPRESSION_COUNT)});}if(j(null),Re.current=null,xe.current){let l=U.current;n.current.x=n.current.x<l/2?0:l,n.current.y=n.current.y<l/2?0:l,_(),h(),v.current="idle";return}v.current="glide",le(true),ye();},mr=e=>{switch(e.key){case "ArrowRight":e.preventDefault(),w(null),Y.current+=1,V(),h();break;case "ArrowLeft":e.preventDefault(),w(null),Y.current-=1,V(),h();break;case "ArrowDown":e.preventDefault(),Pe(1);break;case "ArrowUp":e.preventDefault(),Pe(-1);break;}},qe=useMemo(()=>lookCells(Y.current,A.current,b.length,EXPRESSION_COUNT),[pe,b.length]);R??{column:E.current.column,row:E.current.row};let $=te??{color:wrapIndex(Y.current+E.current.column,b.length),expression:wrapIndex(A.current+E.current.row,EXPRESSION_COUNT)},O={color:b[$.color],expression:EXPRESSIONS[$.expression],blush:F},He=qe.find(e=>e.color===$.color&&e.expression===$.expression),hr=He?{column:He.column,row:He.row}:{column:E.current.column,row:E.current.row},xr=g||se||ne?null:R??hr,gr=$.color!==m.current.color||$.expression!==m.current.expression||F!==m.current.blush,we=useRef(null);useEffect(()=>{let e=`${O.color}.${O.expression}.${O.blush}`;if(we.current===null){we.current=e;return}we.current!==e&&(we.current=e,p?.(O));},[O.color,O.expression,O.blush]);let yr=()=>{w(null),Y.current=(m.current.color??CENTER_COLUMN)-CENTER_COLUMN,A.current=(m.current.expression??CENTER_ROW)-CENTER_ROW,Q(m.current.blush??true),n.current={x:0,y:0},E.current={column:CENTER_COLUMN,row:CENTER_ROW},j(null),V(),h();},Pr={stageRef:ue,worldRef:Se,cellEls:Ce,cell:N,pitch:Me,vw:br,vh:dr,cells:qe,focus:xr,selected:$,dragging:g,moving:g||se||ne,handlers:{onPointerDown:vr,onPointerMove:kr,onPointerUp:e=>De(e,true),onPointerCancel:e=>De(e,false),onLostPointerCapture:e=>De(e,false),onPointerLeave:()=>{v.current==="idle"&&j(null);},onKeyDown:mr}},wr={name:o,value:O,changed:gr,blush:F,expressionName:EXPRESSION_NAMES[R?wrapIndex(A.current+R.row,EXPRESSION_COUNT):$.expression],nextExpression:()=>Pe(1),previousExpression:()=>Pe(-1),toggleBlush:()=>Q(e=>!e),spotlight:I,toggleSpotlight:()=>k(e=>!e),palette:b,reset:yr,save:()=>u?.(O),cancel:()=>d?.(),hasCancel:!!d,map:Pr},Ar=[C?"":"bb-picker",re].filter(Boolean).join(" ");return jsx(nr.Provider,{value:wr,children:jsx("div",{...q,ref:Ue,className:Ar||void 0,"data-part":"root",style:K,children:H})})}function ir(t){let{className:o,...i}=t,{name:p,blush:u,value:d,palette:b,map:f}=D(),{stageRef:C,worldRef:re,cellEls:K,cell:H,pitch:q,cells:m,focus:B,selected:J,dragging:F,moving:Q,handlers:te,vw:w,vh:I}=f;return jsx("div",{...i,...te,ref:C,role:"group",tabIndex:0,"aria-label":"A map of looks. Drag, swipe or use the arrow keys.","data-part":"surface","data-dragging":F?"1":void 0,className:["bb-picker-surface",o].filter(Boolean).join(" "),style:{width:w,height:I},children:jsx("div",{className:"bb-picker-viewport",children:jsx("div",{className:"bb-picker-world",ref:re,children:m.map(k=>{let g=!!B&&k.column===B.column&&k.row===B.row;return jsxs("div",{ref:X=>{X?K.current?.set(k.key,X):K.current?.delete(k.key);},className:"bb-picker-cell","data-focus":g?"1":void 0,style:{left:k.column*q,top:k.row*q,width:H,height:H,zIndex:g?6:1},"aria-hidden":"true",children:[jsx("span",{className:"bb-picker-lift",children:jsx(Ae,{name:p,color:b[k.color],expression:EXPRESSIONS[k.expression],blush:u,size:H,animate:"all",follow:g,blinkInterval:[4e3,1e4]})}),jsx("span",{className:"bb-picker-ring","aria-hidden":"true"}),jsx("span",{className:"bb-picker-check","data-on":!Q&&k.color===J.color&&k.expression===J.expression?"1":void 0,"aria-hidden":"true",children:jsx("svg",{viewBox:"0 0 12 12",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.5"})})})]},k.key)})})})})}function Qr(t){let{name:o,value:i}=D();return jsx(Ae,{name:o,...i,...t,"data-part":"preview"})}function ar(t){let{className:o,...i}=t,{expressionName:p,previousExpression:u,nextExpression:d}=D();return jsxs("div",{...i,className:["bb-picker-mood",o].filter(Boolean).join(" "),"data-part":"mood",children:[jsx("button",{type:"button",className:"bb-picker-step",onClick:u,"aria-label":"Previous expression",children:jsx(tr,{dir:"l"})}),jsx("span",{className:"bb-picker-mood-name","aria-live":"polite",children:p},p),jsx("button",{type:"button",className:"bb-picker-step",onClick:d,"aria-label":"Next expression",children:jsx(tr,{dir:"r"})})]})}function cr(t){let{className:o,children:i,onClick:p,...u}=t,{blush:d,toggleBlush:b}=D();return jsx("button",{type:"button",...u,className:["bb-picker-blush",o].filter(Boolean).join(" "),"data-part":"blush","data-on":d?"1":void 0,"aria-pressed":d,onClick:f=>{p?.(f),f.defaultPrevented||b();},children:i??"Blush"})}function sr(t){let{className:o,children:i,onClick:p,...u}=t,{spotlight:d,toggleSpotlight:b}=D();return jsx("button",{type:"button",...u,className:["bb-picker-spotlight",o].filter(Boolean).join(" "),"data-part":"spotlight","data-on":d?"1":void 0,"aria-pressed":d,onClick:f=>{p?.(f),f.defaultPrevented||b();},children:i??"Spotlight"})}function lr(t){let{className:o,children:i,onClick:p,disabled:u,...d}=t,{changed:b,reset:f}=D();return jsx("button",{type:"button",...d,className:["bb-picker-reset",o].filter(Boolean).join(" "),"data-part":"reset",disabled:u||!b,onClick:C=>{p?.(C),C.defaultPrevented||f();},children:i??"Reset"})}function pr(t){let{className:o,children:i,onClick:p,...u}=t,{save:d}=D();return jsx("button",{type:"button",...u,className:["bb-picker-btn","bb-picker-primary",o].filter(Boolean).join(" "),"data-part":"save",onClick:b=>{p?.(b),b.defaultPrevented||d();},children:i??"Save"})}function ur(t){let{className:o,children:i,onClick:p,...u}=t,{cancel:d,hasCancel:b}=D();return b?jsx("button",{type:"button",...u,className:["bb-picker-btn",o].filter(Boolean).join(" "),"data-part":"cancel",onClick:f=>{p?.(f),f.defaultPrevented||d();},children:i??"Cancel"}):null}function Zr(t){let{title:o="Choose an avatar",description:i="Drag across for colour, down for mood, then keep one.",saveLabel:p="Save",onCancel:u,...d}=t;return jsxs(or,{...d,onCancel:u,children:[(o||i)&&jsxs("div",{className:"bb-picker-head","data-part":"header",children:[o&&jsx("h3",{"data-part":"title",children:o}),i&&jsx("p",{"data-part":"description",children:i})]}),jsx(ir,{}),jsx(ar,{}),jsxs("div",{className:"bb-picker-foot","data-part":"footer",children:[jsx(cr,{}),jsx(sr,{}),jsx(lr,{}),jsx("span",{className:"bb-picker-grow"}),jsx(ur,{}),jsx(pr,{children:p})]})]})}export{Ae as Avatar,Zr as AvatarPicker,cr as AvatarPickerBlush,ur as AvatarPickerCancel,ar as AvatarPickerMood,Qr as AvatarPickerPreview,lr as AvatarPickerReset,or as AvatarPickerRoot,pr as AvatarPickerSave,sr as AvatarPickerSpotlight,ir as AvatarPickerSurface,Be as useAvatarMotion,qr as useAvatarPicker};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {createContext,useRef,useEffect,useMemo,useState,useContext,useInsertionEffect}from'react';import {wantsFollow,renderAvatarBody,PALETTE}from'blobbies';export{COLORS,EXPRESSIONS,EXPRESSION_COUNT,EXPRESSION_NAMES,PALETTE,SHAPES,SHAPE_COUNT}from'blobbies';import {attachAvatarMotion}from'blobbies/motion';import {jsx,jsxs}from'react/jsx-runtime';import {createPicker,staticSnapshot,injectPickerStyles}from'blobbies/picker';function y(o,e={}){let r=useRef({...e});Object.assign(r.current,e);let t=wantsFollow({animate:e.animate,follow:e.follow});useEffect(()=>{let a=o.current;if(!(!t||!a))return attachAvatarMotion(a,r.current)},[t,e.followTarget,o]);}function C(o){let{name:e,size:r,rounded:t,className:a,title:i,palette:s,variant:c,color:d,shape:m,expression:f,blush:P,tilt:b,animate:p,blink:l,blinkInterval:A,follow:k,followRange:h,followTarget:u,smoothing:E,idleTimeout:M,paused:O,respectReducedMotion:w,wink:B,glance:R,surprise:T,style:L,...S}=o,$={size:r,rounded:t,className:a,title:i,palette:s,variant:c,color:d,shape:m,expression:f,blush:P,tilt:b,animate:p,blink:l,blinkInterval:A,follow:k,followRange:h,followTarget:u,smoothing:E,idleTimeout:M,paused:O,respectReducedMotion:w,wink:B,glance:R,surprise:T},q=JSON.stringify([e,p,l,A,s,c,d,m,f,P,b,i,t,r,a]),g=useMemo(()=>renderAvatarBody(e,$),[q]),j=useRef(null);y(j,{animate:p,follow:k,followRange:h,followTarget:u,smoothing:E,idleTimeout:M,paused:O,respectReducedMotion:w,wink:B,glance:R,surprise:T});let Q=["bb",g.prefix,a].filter(Boolean).join(" "),Y=t?{borderRadius:"50%",...L}:L;return jsx("svg",{...S,ref:j,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",role:S.role??"img","aria-label":S["aria-label"]??e,width:r??48,height:r??48,className:Q,style:Y,"data-blobbies":g.letters,dangerouslySetInnerHTML:{__html:g.body}})}function H(){useInsertionEffect(()=>{injectPickerStyles();},[]);}var I=createContext(null);function U(){let o=useContext(I);if(!o)throw new Error("AvatarPicker parts must be used inside <AvatarPickerRoot>.");return o}function v(){return U().state}function V({dir:o}){return jsx("svg",{viewBox:"0 0 12 12",width:"10",height:"10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:o==="l"?"M7.5 2.5 4 6l3.5 3.5":"M4.5 2.5 8 6l-3.5 3.5"})})}function D(o){let{name:e,defaultValue:r,onChange:t,onSave:a,onCancel:i,palette:s=PALETTE,spotlight:c=true,unstyled:d=false,className:m,style:f,children:P,...b}=o;H();let p=useRef({onChange:t,onSave:a,onCancel:i});p.current={onChange:t,onSave:a,onCancel:i};let l=useMemo(()=>createPicker({name:e,defaultValue:r,palette:s,spotlight:c,onChange:u=>p.current.onChange?.(u),onSave:u=>p.current.onSave?.(u),onCancel:()=>p.current.onCancel?.()}),[]),[,A]=useState(0);useEffect(()=>l?.subscribe(()=>A(u=>u+1)),[l]);let k={...l?.getSnapshot()??staticSnapshot({name:e,defaultValue:r,palette:s,spotlight:c}),nextExpression:()=>l?.nextExpression(),previousExpression:()=>l?.previousExpression(),toggleBlush:()=>l?.toggleBlush(),toggleSpotlight:()=>l?.toggleSpotlight(),reset:()=>l?.reset(),save:()=>l?.save(),cancel:()=>l?.cancel(),hasCancel:!!i},h=[d?"":"bb-picker",m].filter(Boolean).join(" ");return jsx(I.Provider,{value:{state:k,runtime:l},children:jsx("div",{...b,className:h||void 0,"data-part":"root",style:f,children:P})})}function _(o){let{className:e,...r}=o,{runtime:t}=U(),a=useRef(null);return useEffect(()=>{let i=a.current;if(!(!i||!t))return i.append(t.surface),t.measure(),()=>{t.surface.remove();}},[t]),useEffect(()=>{!t||!e||(t.surface.className=`bb-picker-surface ${e}`);},[t,e]),jsx("div",{...r,ref:a,"data-part":"surface-host"})}function Pe(o){let{name:e,value:r}=v();return jsx(C,{name:e,...r,...o,"data-part":"preview"})}function X(o){let{className:e,...r}=o,{expressionName:t,previousExpression:a,nextExpression:i}=v();return jsxs("div",{...r,className:["bb-picker-mood",e].filter(Boolean).join(" "),"data-part":"mood",children:[jsx("button",{type:"button",className:"bb-picker-step",onClick:a,"aria-label":"Previous expression",children:jsx(V,{dir:"l"})}),jsx("span",{className:"bb-picker-mood-name","aria-live":"polite",children:t},t),jsx("button",{type:"button",className:"bb-picker-step",onClick:i,"aria-label":"Next expression",children:jsx(V,{dir:"r"})})]})}function F(o){let{className:e,children:r,onClick:t,...a}=o,{blush:i,toggleBlush:s}=v();return jsx("button",{type:"button",...a,className:["bb-picker-blush",e].filter(Boolean).join(" "),"data-part":"blush","data-on":i?"1":void 0,"aria-pressed":i,onClick:c=>{t?.(c),c.defaultPrevented||s();},children:r??"Blush"})}function J(o){let{className:e,children:r,onClick:t,...a}=o,{spotlight:i,toggleSpotlight:s}=v();return jsx("button",{type:"button",...a,className:["bb-picker-spotlight",e].filter(Boolean).join(" "),"data-part":"spotlight","data-on":i?"1":void 0,"aria-pressed":i,onClick:c=>{t?.(c),c.defaultPrevented||s();},children:r??"Spotlight"})}function z(o){let{className:e,children:r,onClick:t,disabled:a,...i}=o,{changed:s,reset:c}=v();return jsx("button",{type:"button",...i,className:["bb-picker-reset",e].filter(Boolean).join(" "),"data-part":"reset",disabled:a||!s,onClick:d=>{t?.(d),d.defaultPrevented||c();},children:r??"Reset"})}function K(o){let{className:e,children:r,onClick:t,...a}=o,{save:i}=v();return jsx("button",{type:"button",...a,className:["bb-picker-btn","bb-picker-primary",e].filter(Boolean).join(" "),"data-part":"save",onClick:s=>{t?.(s),s.defaultPrevented||i();},children:r??"Save"})}function W(o){let{className:e,children:r,onClick:t,...a}=o,{cancel:i,hasCancel:s}=v();return s?jsx("button",{type:"button",...a,className:["bb-picker-btn",e].filter(Boolean).join(" "),"data-part":"cancel",onClick:c=>{t?.(c),c.defaultPrevented||i();},children:r??"Cancel"}):null}function be(o){let{title:e="Choose an avatar",description:r="Drag across for colour, down for mood, then keep one.",saveLabel:t="Save",onCancel:a,...i}=o;return jsxs(D,{...i,onCancel:a,children:[(e||r)&&jsxs("div",{className:"bb-picker-head","data-part":"header",children:[e&&jsx("h3",{"data-part":"title",children:e}),r&&jsx("p",{"data-part":"description",children:r})]}),jsx(_,{}),jsx(X,{}),jsxs("div",{className:"bb-picker-foot","data-part":"footer",children:[jsx(F,{}),jsx(J,{}),jsx(z,{}),jsx("span",{className:"bb-picker-grow"}),jsx(W,{}),jsx(K,{children:t})]})]})}
|
|
2
|
+
export{C as Avatar,be as AvatarPicker,F as AvatarPickerBlush,W as AvatarPickerCancel,X as AvatarPickerMood,Pe as AvatarPickerPreview,z as AvatarPickerReset,D as AvatarPickerRoot,K as AvatarPickerSave,J as AvatarPickerSpotlight,_ as AvatarPickerSurface,y as useAvatarMotion,v as useAvatarPicker};//# sourceMappingURL=index.js.map
|
|
257
3
|
//# sourceMappingURL=index.js.map
|