@blobbies/react 0.5.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 rr(){useInsertionEffect(()=>{if(typeof document>"u"||document.getElementById(er))return;let t=document.createElement("style");t.id=er,t.textContent=Hr,document.head.prepend(t);},[]);}var Xe=typeof window<"u"?useLayoutEffect:useEffect,ir=createContext(null);function D(){let t=useContext(ir);if(!t)throw new Error("AvatarPicker parts must be used inside <AvatarPickerRoot>.");return t}function Qr(){let{map:t,...i}=D();return i}function or({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 Zr(t){return t.ctrlKey||t.deltaMode!==0?false:t.deltaX!==0||Math.abs(t.deltaY)<40||!Number.isInteger(t.deltaY)}function ar(t){let{name:i,defaultValue:a,onChange:p,onSave:u,onCancel:d,palette:b=PALETTE,spotlight:f=true,unstyled:C=false,className:ne,style:q,children:H,...J}=t;rr();let m=useRef({color:(()=>{let e=a?.color?b.indexOf(a.color):CENTER_I;return e>=0?e:CENTER_I})(),expression:(()=>{let e=a?.expression?EXPRESSIONS.indexOf(a.expression):CENTER_J;return e>=0?e:CENTER_J})(),blush:a?.blush??true}),[B,Q]=useState({cell:68,gap:MAX_GAP}),[F,Z]=useState(m.current.blush??true),[oe,A]=useState(null),[I,k]=useState(f),[g,X]=useState(false),[R,z]=useState(null),[se,Y]=useState(false),[ie,le]=useState(false),[pe,ke]=useState(0),{cell:L,gap:ae}=B,Re=L+ae,_e=COLS*L+(COLS-1)*ae,Ve=ROWS*L+(ROWS-1)*ae,fr=_e+PAD*2,vr=Ve+PAD*2,_=useRef(m.current.color-CENTER_I),w=useRef(m.current.expression-CENTER_J),E=useRef({i:CENTER_I,j:CENTER_J}),n=useRef({x:0,y:0}),M=useRef({x:0,y:0}),v=useRef("idle"),y=useRef(0),N=useRef(0),me=useRef(0),Ge=useRef(0),V=useRef(false),G=useRef(Re);G.current=Re;let Ue=useRef(null),Le=useRef(null),ue=useRef(null),Ne=useRef(new Map),be=useRef({x:0,y:0}),ce=useRef(null),Oe=useRef(null),he=useRef({x:0,y:0}),Te=useRef(0),xe=useRef(typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:false),je=useRef(R),$e=useRef(g),We=useRef(ie),Ke=useRef(L),De=useRef(false),ge=useRef(false),qe=useRef(I);qe.current=I,je.current=R,$e.current=g,We.current=ie,Ke.current=L;let U=()=>ke(e=>e+1),He=()=>{let e=G.current,c=Ke.current,r=je.current&&!$e.current&&!V.current&&!We.current?je.current:null;if(!r){if(!De.current&&ge.current)return;De.current=false,ge.current=true;for(let[,x]of Ne.current)x.style.transform="",x.style.opacity="1",x.style.filter="";return}De.current=true,ge.current=true;let l=r;for(let[x,P]of Ne.current){let[S,T]=x.split(":").map(Number),{dx:ee,dy:we,opacity:de,blur:Ze}=lensEffect({cell:{i:S,j:T},lens:l,pitch:e,size:c,offsetX:n.current.x,offsetY:n.current.y,push:!xe.current,spotlight:qe.current});P.style.transform=`translate3d(${ee.toFixed(1)}px, ${we.toFixed(1)}px, 0)`,P.style.opacity=de.toFixed(3),P.style.filter=Ze>.06?`blur(${Ze.toFixed(2)}px)`:"";}},Je=(e,c)=>{let r=ue.current?.getBoundingClientRect();return r?cellAtPoint({x:e-r.left,y:c-r.top,pad:PAD,offsetX:n.current.x,offsetY:n.current.y,pitch:G.current,width:_e,height:Ve}):null},kr=e=>{let c=Le.current;c&&(c.style.transform=`translate3d(${n.current.x}px, ${n.current.y+e}px, 0)`),He();},h=()=>{let e=Le.current;e&&(e.style.transform=`translate3d(${n.current.x}px, ${n.current.y}px, 0)`);let c=G.current,r=centeredCell(n.current.x,n.current.y,c);(r.i!==E.current.i||r.j!==E.current.j)&&(E.current=r,U()),He();},$=()=>{let e=G.current,c=false,r=Math.floor(n.current.x/e),l=Math.floor(n.current.y/e);r!==0&&(_.current-=r,n.current.x-=r*e,c=true),l!==0&&(w.current-=l,n.current.y-=l*e,c=true),c&&U();},ye=()=>{y.current||(y.current=requestAnimationFrame(function(){y.current=0;let c=G.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(V.current)return;if(A(null),xe.current){w.current+=e,U(),h();return}V.current=true,Ge.current=e,Y(true);let c=G.current,r=-e*c,l=performance.now(),x=300,P=S=>{let T=Math.min(1,(S-l)/x),ee=1-Math.pow(1-T,3);me.current=r*ee,kr(me.current),T<1?N.current=requestAnimationFrame(P):(w.current+=e,me.current=0,N.current=0,V.current=false,Y(false),U(),h());};N.current=requestAnimationFrame(P);};Xe(()=>{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),S=c.clientWidth-P,T=Math.min(16,Math.max(6,Math.round(S*.03))),ee=clamp(Math.round(S*.02),MIN_GAP,MAX_GAP),we=clamp(Math.floor((S-T*2-PAD*2-(COLS-1)*ee)/COLS),MIN_CELL,MAX_CELL);Q(de=>de.cell===we&&de.gap===ee?de:{cell:we,gap:ee});};if(r(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(r);return l.observe(c),()=>l.disconnect()},[]),Xe(()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0),V.current&&N.current&&(cancelAnimationFrame(N.current),N.current=0,V.current=false),Y(false),le(false),v.current="idle",$(),ge.current=false,h();},[L,ae]),Xe(()=>{He();}),useEffect(()=>{let e=ue.current;if(!e)return;let c=r=>{if(Zr(r)){if(r.preventDefault(),xe.current){r.deltaX&&(_.current+=r.deltaX>0?1:-1),r.deltaY&&(w.current+=r.deltaY>0?1:-1),U(),h();return}y.current&&(cancelAnimationFrame(y.current),y.current=0),n.current.x+=r.deltaX,n.current.y+=r.deltaY,M.current={x:clamp(r.deltaX*.8,-40,40),y:clamp(r.deltaY*.8,-40,40)},$(),h(),v.current="glide",ye();}};return e.addEventListener("wheel",c,{passive:false}),()=>e.removeEventListener("wheel",c)},[]);let mr=e=>{if(!(e.button>0)&&ce.current===null){ce.current=e.pointerId;try{ue.current?.setPointerCapture(e.pointerId);}catch{}y.current&&(cancelAnimationFrame(y.current),y.current=0),V.current&&(N.current&&cancelAnimationFrame(N.current),w.current+=Ge.current,me.current=0,N.current=0,V.current=false,Y(false),h()),Oe.current=Je(e.clientX,e.clientY),v.current="press",Te.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},z(null);}},hr=e=>{if(v.current==="press"||v.current==="drag"){if(e.pointerId!==ce.current)return;if(v.current==="press"){if(exceedsSlop(he.current,{x:e.clientX,y:e.clientY},Te.current)){v.current="drag";let x=e.clientX-he.current.x,P=e.clientY-he.current.y,S=Math.hypot(x,P)||1,T=(S-Te.current)/S;n.current.x+=x*T,n.current.y+=P*T,be.current={x:e.clientX,y:e.clientY},M.current={x:clamp(x*.85,-40,40),y:clamp(P*.85,-40,40)},$(),h(),A(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:clamp(r*.85,-40,40),y:clamp(l*.85,-40,40)},$(),h();return}if(e.pointerType==="touch")return;let c=Je(e.clientX,e.clientY);z(r=>c&&r&&r.i===c.i&&r.j===c.j?r:c);},Be=(e,c)=>{if(ce.current!==null&&e.pointerId!==ce.current||(ce.current=null,v.current!=="press"&&v.current!=="drag"))return;let r=v.current==="press";if(X(false),r&&c){let l=Oe.current;l&&A({color:mod(_.current+l.i,b.length),expression:mod(w.current+l.j,EXPRESSION_COUNT)});}if(z(null),Oe.current=null,xe.current){let l=G.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();},xr=e=>{switch(e.key){case "ArrowRight":e.preventDefault(),A(null),_.current+=1,U(),h();break;case "ArrowLeft":e.preventDefault(),A(null),_.current-=1,U(),h();break;case "ArrowDown":e.preventDefault(),Pe(1);break;case "ArrowUp":e.preventDefault(),Pe(-1);break;}},Qe=useMemo(()=>lookCells(_.current,w.current,b.length,EXPRESSION_COUNT),[pe,b.length]);R??{i:E.current.i,j:E.current.j};let W=oe??{color:mod(_.current+E.current.i,b.length),expression:mod(w.current+E.current.j,EXPRESSION_COUNT)},O={color:b[W.color],expression:EXPRESSIONS[W.expression],blush:F},Fe=Qe.find(e=>e.color===W.color&&e.expression===W.expression),gr=Fe?{i:Fe.i,j:Fe.j}:{i:E.current.i,j:E.current.j},yr=g||se||ie?null:R??gr,Pr=W.color!==m.current.color||W.expression!==m.current.expression||F!==m.current.blush,Ae=useRef(null);useEffect(()=>{let e=`${O.color}.${O.expression}.${O.blush}`;if(Ae.current===null){Ae.current=e;return}Ae.current!==e&&(Ae.current=e,p?.(O));},[O.color,O.expression,O.blush]);let Ar=()=>{A(null),_.current=(m.current.color??CENTER_I)-CENTER_I,w.current=(m.current.expression??CENTER_J)-CENTER_J,Z(m.current.blush??true),n.current={x:0,y:0},E.current={i:CENTER_I,j:CENTER_J},z(null),U(),h();},wr={stageRef:ue,worldRef:Le,cellEls:Ne,cell:L,pitch:Re,vw:fr,vh:vr,cells:Qe,focus:yr,selected:W,dragging:g,moving:g||se||ie,handlers:{onPointerDown:mr,onPointerMove:hr,onPointerUp:e=>Be(e,true),onPointerCancel:e=>Be(e,false),onLostPointerCapture:e=>Be(e,false),onPointerLeave:()=>{v.current==="idle"&&z(null);},onKeyDown:xr}},Er={name:i,value:O,changed:Pr,blush:F,expressionName:EXPRESSION_NAMES[R?mod(w.current+R.j,EXPRESSION_COUNT):W.expression],nextExpression:()=>Pe(1),previousExpression:()=>Pe(-1),toggleBlush:()=>Z(e=>!e),spotlight:I,toggleSpotlight:()=>k(e=>!e),palette:b,reset:Ar,save:()=>u?.(O),cancel:()=>d?.(),hasCancel:!!d,map:wr},Mr=[C?"":"bb-picker",ne].filter(Boolean).join(" ");return jsx(ir.Provider,{value:Er,children:jsx("div",{...J,ref:Ue,className:Mr||void 0,"data-part":"root",style:q,children:H})})}function cr(t){let{className:i,...a}=t,{name:p,blush:u,value:d,palette:b,map:f}=D(),{stageRef:C,worldRef:ne,cellEls:q,cell:H,pitch:J,cells:m,focus:B,selected:Q,dragging:F,moving:Z,handlers:oe,vw:A,vh:I}=f;return jsx("div",{...a,...oe,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",i].filter(Boolean).join(" "),style:{width:A,height:I},children:jsx("div",{className:"bb-picker-viewport",children:jsx("div",{className:"bb-picker-world",ref:ne,children:m.map(k=>{let g=!!B&&k.i===B.i&&k.j===B.j;return jsxs("div",{ref:X=>{X?q.current?.set(k.key,X):q.current?.delete(k.key);},className:"bb-picker-cell","data-focus":g?"1":void 0,style:{left:k.i*J,top:k.j*J,width:H,height:H,zIndex:g?6:1},"aria-hidden":"true",children:[jsx("span",{className:"bb-picker-lift",children:jsx(Ee,{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":!Z&&k.color===Q.color&&k.expression===Q.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 et(t){let{name:i,value:a}=D();return jsx(Ee,{name:i,...a,...t,"data-part":"preview"})}function sr(t){let{className:i,...a}=t,{expressionName:p,previousExpression:u,nextExpression:d}=D();return jsxs("div",{...a,className:["bb-picker-mood",i].filter(Boolean).join(" "),"data-part":"mood",children:[jsx("button",{type:"button",className:"bb-picker-step",onClick:u,"aria-label":"Previous expression",children:jsx(or,{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(or,{dir:"r"})})]})}function lr(t){let{className:i,children:a,onClick:p,...u}=t,{blush:d,toggleBlush:b}=D();return jsx("button",{type:"button",...u,className:["bb-picker-blush",i].filter(Boolean).join(" "),"data-part":"blush","data-on":d?"1":void 0,"aria-pressed":d,onClick:f=>{p?.(f),f.defaultPrevented||b();},children:a??"Blush"})}function pr(t){let{className:i,children:a,onClick:p,...u}=t,{spotlight:d,toggleSpotlight:b}=D();return jsx("button",{type:"button",...u,className:["bb-picker-spotlight",i].filter(Boolean).join(" "),"data-part":"spotlight","data-on":d?"1":void 0,"aria-pressed":d,onClick:f=>{p?.(f),f.defaultPrevented||b();},children:a??"Spotlight"})}function ur(t){let{className:i,children:a,onClick:p,disabled:u,...d}=t,{changed:b,reset:f}=D();return jsx("button",{type:"button",...d,className:["bb-picker-reset",i].filter(Boolean).join(" "),"data-part":"reset",disabled:u||!b,onClick:C=>{p?.(C),C.defaultPrevented||f();},children:a??"Reset"})}function br(t){let{className:i,children:a,onClick:p,...u}=t,{save:d}=D();return jsx("button",{type:"button",...u,className:["bb-picker-btn","bb-picker-primary",i].filter(Boolean).join(" "),"data-part":"save",onClick:b=>{p?.(b),b.defaultPrevented||d();},children:a??"Save"})}function dr(t){let{className:i,children:a,onClick:p,...u}=t,{cancel:d,hasCancel:b}=D();return b?jsx("button",{type:"button",...u,className:["bb-picker-btn",i].filter(Boolean).join(" "),"data-part":"cancel",onClick:f=>{p?.(f),f.defaultPrevented||d();},children:a??"Cancel"}):null}function rt(t){let{title:i="Choose an avatar",description:a="Drag across for colour, down for mood, then keep one.",saveLabel:p="Save",onCancel:u,...d}=t;return jsxs(ar,{...d,onCancel:u,children:[(i||a)&&jsxs("div",{className:"bb-picker-head","data-part":"header",children:[i&&jsx("h3",{"data-part":"title",children:i}),a&&jsx("p",{"data-part":"description",children:a})]}),jsx(cr,{}),jsx(sr,{}),jsxs("div",{className:"bb-picker-foot","data-part":"footer",children:[jsx(lr,{}),jsx(pr,{}),jsx(ur,{}),jsx("span",{className:"bb-picker-grow"}),jsx(dr,{}),jsx(br,{children:p})]})]})}export{Ee as Avatar,rt as AvatarPicker,lr as AvatarPickerBlush,dr as AvatarPickerCancel,sr as AvatarPickerMood,et as AvatarPickerPreview,ur as AvatarPickerReset,ar as AvatarPickerRoot,br as AvatarPickerSave,pr as AvatarPickerSpotlight,cr as AvatarPickerSurface,Ie 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
|