vireuikit 0.5.0 → 0.6.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/README.md +56 -1
- package/dist/a11y-D3SS74I3.d.cts +25 -0
- package/dist/a11y-D3SS74I3.d.ts +25 -0
- package/dist/chunk-I3BD3XGC.js +392 -0
- package/dist/chunk-I3BD3XGC.js.map +1 -0
- package/dist/index.cjs +236 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +119 -1
- package/dist/index.d.ts +119 -1
- package/dist/index.js +1 -186
- package/dist/index.js.map +1 -1
- package/dist/web.cjs +826 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.cts +27 -0
- package/dist/web.d.ts +27 -0
- package/dist/web.js +567 -0
- package/dist/web.js.map +1 -0
- package/package.json +18 -6
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
var vireglass = require('vireglass');
|
|
4
4
|
|
|
5
|
-
// src/kit/
|
|
5
|
+
// src/kit/a11y.ts
|
|
6
|
+
var A11Y_NONE = {
|
|
7
|
+
reduceTransparency: false,
|
|
8
|
+
increaseContrast: false,
|
|
9
|
+
reduceMotion: false
|
|
10
|
+
};
|
|
11
|
+
function resolveA11y(system, override = {}) {
|
|
12
|
+
return {
|
|
13
|
+
reduceTransparency: override.reduceTransparency ?? system.reduceTransparency,
|
|
14
|
+
increaseContrast: override.increaseContrast ?? system.increaseContrast,
|
|
15
|
+
reduceMotion: override.reduceMotion ?? system.reduceMotion
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function presentationFor(mode, wantsGlass) {
|
|
19
|
+
return {
|
|
20
|
+
glass: wantsGlass,
|
|
21
|
+
frost: wantsGlass && mode.reduceTransparency,
|
|
22
|
+
surface: wantsGlass ? "glass" : "plain",
|
|
23
|
+
contrastBorder: mode.increaseContrast,
|
|
24
|
+
instantSprings: mode.reduceMotion
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function sameA11y(a, b) {
|
|
28
|
+
return a.reduceTransparency === b.reduceTransparency && a.increaseContrast === b.increaseContrast && a.reduceMotion === b.reduceMotion;
|
|
29
|
+
}
|
|
6
30
|
var ATOM_AT_REST = {
|
|
7
31
|
pressed: 0,
|
|
8
32
|
hovered: 0,
|
|
@@ -21,16 +45,118 @@ function atomLift(kind) {
|
|
|
21
45
|
}
|
|
22
46
|
var DISABLED_PRESENCE = 0.25;
|
|
23
47
|
var HOVER_GAIN = 0.35;
|
|
24
|
-
function
|
|
48
|
+
function activation(state) {
|
|
49
|
+
if (state.disabled) return 0;
|
|
25
50
|
const clamp = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
return Math.max(clamp(state.selected), clamp(state.pressed), clamp(state.hovered) * HOVER_GAIN);
|
|
52
|
+
}
|
|
53
|
+
function atomMaterial(base, kind, state = ATOM_AT_REST) {
|
|
54
|
+
const out = vireglass.activeMaterial(base, activation(state));
|
|
28
55
|
if (!state.disabled) return out;
|
|
29
56
|
return { ...out, presence: out.presence * DISABLED_PRESENCE };
|
|
30
57
|
}
|
|
31
58
|
function atomAtRest(state) {
|
|
32
59
|
return state.pressed === 0 && state.hovered === 0 && state.selected === 0 && state.disabled === false;
|
|
33
60
|
}
|
|
61
|
+
var REST_BODY = { alpha: 0.25, white: 0.15, lift: 0.1 };
|
|
62
|
+
var PRESSED_BODY = { alpha: 0.34, white: 0.35, lift: 0 };
|
|
63
|
+
var FROST_LIFT = 0.26;
|
|
64
|
+
function atomBody(base, state = ATOM_AT_REST, frost = false) {
|
|
65
|
+
const on = activation(state);
|
|
66
|
+
const mix2 = (key) => REST_BODY[key] + (PRESSED_BODY[key] - REST_BODY[key]) * on;
|
|
67
|
+
let alpha = mix2("alpha");
|
|
68
|
+
let white = mix2("white");
|
|
69
|
+
let lift = mix2("lift");
|
|
70
|
+
if (state.disabled) alpha *= DISABLED_PRESENCE;
|
|
71
|
+
if (frost) {
|
|
72
|
+
const density = vireglass.applyAccessibility(vireglass.resolveOptics(base), {
|
|
73
|
+
reduceTransparency: true,
|
|
74
|
+
increaseContrast: false,
|
|
75
|
+
reduceMotion: false
|
|
76
|
+
}).bodyDensity;
|
|
77
|
+
alpha = Math.max(alpha, density);
|
|
78
|
+
white = 0;
|
|
79
|
+
lift = FROST_LIFT;
|
|
80
|
+
}
|
|
81
|
+
return { alpha, white, lift };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/kit/behavior/focus.ts
|
|
85
|
+
function stepFocus(event) {
|
|
86
|
+
return event.type === "focus" && event.visible;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/kit/behavior/hover.ts
|
|
90
|
+
function stepHover(event, canHover) {
|
|
91
|
+
return canHover && event.type === "enter";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/kit/behavior/press.ts
|
|
95
|
+
var PRESS_IDLE = { by: null };
|
|
96
|
+
function stepPress(state, event, enabled) {
|
|
97
|
+
switch (event.type) {
|
|
98
|
+
case "down":
|
|
99
|
+
if (!enabled || state.by !== null) return { state, activated: false };
|
|
100
|
+
return { state: { by: event.source }, activated: false };
|
|
101
|
+
case "up":
|
|
102
|
+
if (state.by !== event.source) return { state, activated: false };
|
|
103
|
+
return { state: PRESS_IDLE, activated: enabled };
|
|
104
|
+
case "cancel":
|
|
105
|
+
return { state: PRESS_IDLE, activated: false };
|
|
106
|
+
case "leave":
|
|
107
|
+
return state.by === "pointer" ? { state: PRESS_IDLE, activated: false } : { state, activated: false };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/kit/behavior/control.ts
|
|
112
|
+
var TOUCH_INPUT = { hover: false };
|
|
113
|
+
var POINTER_INPUT = { hover: true };
|
|
114
|
+
var CONTROL_IDLE = {
|
|
115
|
+
press: PRESS_IDLE,
|
|
116
|
+
hovered: false,
|
|
117
|
+
focused: false,
|
|
118
|
+
disabled: false
|
|
119
|
+
};
|
|
120
|
+
function stepControl(state, event, caps) {
|
|
121
|
+
switch (event.type) {
|
|
122
|
+
case "down":
|
|
123
|
+
case "up":
|
|
124
|
+
case "cancel": {
|
|
125
|
+
const next = stepPress(state.press, event, !state.disabled);
|
|
126
|
+
return { state: { ...state, press: next.state }, activated: next.activated };
|
|
127
|
+
}
|
|
128
|
+
case "leave": {
|
|
129
|
+
const next = stepPress(state.press, event, !state.disabled);
|
|
130
|
+
return { state: { ...state, press: next.state, hovered: false }, activated: false };
|
|
131
|
+
}
|
|
132
|
+
case "enter":
|
|
133
|
+
return {
|
|
134
|
+
state: { ...state, hovered: !state.disabled && stepHover(event, caps.hover) },
|
|
135
|
+
activated: false
|
|
136
|
+
};
|
|
137
|
+
case "focus":
|
|
138
|
+
case "blur": {
|
|
139
|
+
const press = event.type === "blur" && state.press.by === "keyboard" ? PRESS_IDLE : state.press;
|
|
140
|
+
return {
|
|
141
|
+
state: { ...state, press, focused: !state.disabled && stepFocus(event) },
|
|
142
|
+
activated: false
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
case "disable":
|
|
146
|
+
return {
|
|
147
|
+
state: event.disabled ? { press: PRESS_IDLE, hovered: false, focused: false, disabled: true } : { ...state, disabled: false },
|
|
148
|
+
activated: false
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function controlTargets(state) {
|
|
153
|
+
return {
|
|
154
|
+
pressed: state.press.by !== null ? 1 : 0,
|
|
155
|
+
hovered: state.hovered ? 1 : 0,
|
|
156
|
+
focus: state.focused ? 1 : 0,
|
|
157
|
+
disabled: state.disabled
|
|
158
|
+
};
|
|
159
|
+
}
|
|
34
160
|
function stepSpring(s, dt, response, damping, instant = false) {
|
|
35
161
|
if (instant) {
|
|
36
162
|
const moved = s.x !== s.target || s.v !== 0;
|
|
@@ -185,17 +311,123 @@ function stepGrowth(state, dt, open, reduceMotion = false, timing = DEFAULT_GROW
|
|
|
185
311
|
return movedShrink || movedGrow;
|
|
186
312
|
}
|
|
187
313
|
|
|
314
|
+
// src/kit/behavior/visual.ts
|
|
315
|
+
var createControlVisual = () => ({
|
|
316
|
+
pressed: { x: 0, v: 0, target: 0 },
|
|
317
|
+
hovered: { x: 0, v: 0, target: 0 },
|
|
318
|
+
focus: { x: 0, v: 0, target: 0 }
|
|
319
|
+
});
|
|
320
|
+
var PRESS = { response: 0.18, damping: 0.78 };
|
|
321
|
+
var HOVER = { response: 0.22, damping: 1 };
|
|
322
|
+
var FOCUS = { response: 0.16, damping: 1 };
|
|
323
|
+
function stepControlVisual(visual, dt, state, instant = false) {
|
|
324
|
+
const t = controlTargets(state);
|
|
325
|
+
visual.pressed.target = t.pressed;
|
|
326
|
+
visual.hovered.target = t.hovered;
|
|
327
|
+
visual.focus.target = t.focus;
|
|
328
|
+
const a = stepSpring(visual.pressed, dt, PRESS.response, PRESS.damping, instant);
|
|
329
|
+
const b = stepSpring(visual.hovered, dt, HOVER.response, HOVER.damping, instant);
|
|
330
|
+
const c = stepSpring(visual.focus, dt, FOCUS.response, FOCUS.damping, instant);
|
|
331
|
+
return a || b || c;
|
|
332
|
+
}
|
|
333
|
+
function visualAtomState(visual, state) {
|
|
334
|
+
return {
|
|
335
|
+
pressed: visual.pressed.x,
|
|
336
|
+
hovered: visual.hovered.x,
|
|
337
|
+
selected: 0,
|
|
338
|
+
disabled: state.disabled
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function settleControlVisual(visual, state) {
|
|
342
|
+
stepControlVisual(visual, 0, state, true);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// src/kit/response.ts
|
|
346
|
+
var LIFTING = { grow: 0.18, defocus: 1.6 };
|
|
347
|
+
var SINKING = { grow: 0.06, defocus: 1 };
|
|
348
|
+
function pressResponse(kind) {
|
|
349
|
+
return atomLift(kind) === 1 ? LIFTING : SINKING;
|
|
350
|
+
}
|
|
351
|
+
var CONTROL_SIZES = ["touch", "small", "medium", "large", "xlarge"];
|
|
352
|
+
var MIN_TOUCH_TARGET_DP = 44;
|
|
353
|
+
var MIN_POINTER_TARGET_DP = 24;
|
|
354
|
+
var capsule = (height, paddingX) => ({
|
|
355
|
+
height,
|
|
356
|
+
paddingX,
|
|
357
|
+
icon: Math.round(height / 2),
|
|
358
|
+
radius: height / 2,
|
|
359
|
+
shape: "capsule"
|
|
360
|
+
});
|
|
361
|
+
var rounded = (height, paddingX) => ({
|
|
362
|
+
height,
|
|
363
|
+
paddingX,
|
|
364
|
+
icon: Math.round(height / 2),
|
|
365
|
+
radius: height / 4,
|
|
366
|
+
shape: "rounded"
|
|
367
|
+
});
|
|
368
|
+
var BUTTON_SIZES = {
|
|
369
|
+
touch: capsule(44, 20),
|
|
370
|
+
small: rounded(24, 10),
|
|
371
|
+
medium: rounded(32, 14),
|
|
372
|
+
large: capsule(40, 18),
|
|
373
|
+
xlarge: capsule(48, 22)
|
|
374
|
+
};
|
|
375
|
+
function iconButtonSize(size) {
|
|
376
|
+
const spec = BUTTON_SIZES[size];
|
|
377
|
+
return { ...spec, width: spec.height, paddingX: 0 };
|
|
378
|
+
}
|
|
379
|
+
function nestedRadius(outerRadius, inset, minimum = 0) {
|
|
380
|
+
return vireglass.concentricRadius(outerRadius, inset, minimum);
|
|
381
|
+
}
|
|
382
|
+
function defaultSize(input) {
|
|
383
|
+
return input.touch ? "touch" : "medium";
|
|
384
|
+
}
|
|
385
|
+
function hitSlop(bodyDp, minTargetDp) {
|
|
386
|
+
return bodyDp >= minTargetDp ? 0 : (minTargetDp - bodyDp) / 2;
|
|
387
|
+
}
|
|
388
|
+
function minTarget(input) {
|
|
389
|
+
return input.touch ? MIN_TOUCH_TARGET_DP : MIN_POINTER_TARGET_DP;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
exports.A11Y_NONE = A11Y_NONE;
|
|
188
393
|
exports.ATOM_AT_REST = ATOM_AT_REST;
|
|
394
|
+
exports.BUTTON_SIZES = BUTTON_SIZES;
|
|
395
|
+
exports.CONTROL_IDLE = CONTROL_IDLE;
|
|
396
|
+
exports.CONTROL_SIZES = CONTROL_SIZES;
|
|
189
397
|
exports.DEFAULT_GROWTH_TIMING = DEFAULT_GROWTH_TIMING;
|
|
398
|
+
exports.MIN_POINTER_TARGET_DP = MIN_POINTER_TARGET_DP;
|
|
399
|
+
exports.MIN_TOUCH_TARGET_DP = MIN_TOUCH_TARGET_DP;
|
|
400
|
+
exports.POINTER_INPUT = POINTER_INPUT;
|
|
401
|
+
exports.PRESS_IDLE = PRESS_IDLE;
|
|
402
|
+
exports.TOUCH_INPUT = TOUCH_INPUT;
|
|
190
403
|
exports.atomAtRest = atomAtRest;
|
|
404
|
+
exports.atomBody = atomBody;
|
|
191
405
|
exports.atomLift = atomLift;
|
|
192
406
|
exports.atomMaterial = atomMaterial;
|
|
407
|
+
exports.controlTargets = controlTargets;
|
|
408
|
+
exports.createControlVisual = createControlVisual;
|
|
193
409
|
exports.createGrowthState = createGrowthState;
|
|
410
|
+
exports.defaultSize = defaultSize;
|
|
194
411
|
exports.growthFrame = growthFrame;
|
|
195
412
|
exports.growthInk = growthInk;
|
|
196
413
|
exports.growthPhase = growthPhase;
|
|
414
|
+
exports.hitSlop = hitSlop;
|
|
415
|
+
exports.iconButtonSize = iconButtonSize;
|
|
416
|
+
exports.minTarget = minTarget;
|
|
417
|
+
exports.nestedRadius = nestedRadius;
|
|
418
|
+
exports.presentationFor = presentationFor;
|
|
419
|
+
exports.pressResponse = pressResponse;
|
|
420
|
+
exports.resolveA11y = resolveA11y;
|
|
421
|
+
exports.sameA11y = sameA11y;
|
|
422
|
+
exports.settleControlVisual = settleControlVisual;
|
|
197
423
|
exports.smoothstep = smoothstep;
|
|
424
|
+
exports.stepControl = stepControl;
|
|
425
|
+
exports.stepControlVisual = stepControlVisual;
|
|
426
|
+
exports.stepFocus = stepFocus;
|
|
198
427
|
exports.stepGrowth = stepGrowth;
|
|
428
|
+
exports.stepHover = stepHover;
|
|
429
|
+
exports.stepPress = stepPress;
|
|
199
430
|
exports.stepSpring = stepSpring;
|
|
431
|
+
exports.visualAtomState = visualAtomState;
|
|
200
432
|
//# sourceMappingURL=index.cjs.map
|
|
201
433
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kit/atom.ts","../src/kit/morph.ts"],"names":["activeMaterial","halfMinDp"],"mappings":";;;;;AAuBO,IAAM,YAAA,GAAmC;AAAA,EAC9C,OAAA,EAAS,CAAA;AAAA,EACT,OAAA,EAAS,CAAA;AAAA,EACT,QAAA,EAAU,CAAA;AAAA,EACV,QAAA,EAAU;AACZ;AASO,SAAS,SAAS,IAAA,EAAiC;AACxD,EAAA,QAAQ,IAAA;AAAM,IACZ,KAAK,YAAA;AAAA,IACL,KAAK,QAAA;AAAA,IACL,KAAK,QAAA;AACH,MAAA,OAAO,CAAA;AAAA,IACT;AACE,MAAA,OAAO,CAAA;AAAA;AAEb;AAIA,IAAM,iBAAA,GAAoB,IAAA;AAE1B,IAAM,UAAA,GAAa,IAAA;AAOZ,SAAS,YAAA,CACd,IAAA,EACA,IAAA,EACA,KAAA,GAA4B,YAAA,EACT;AACnB,EAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAe,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AACtD,EAAA,MAAM,EAAA,GAAK,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,MAAM,QAAQ,CAAA,EAAG,KAAA,CAAM,KAAA,CAAM,OAAO,CAAA,EAAG,KAAA,CAAM,KAAA,CAAM,OAAO,IAAI,UAAU,CAAA;AAClG,EAAA,MAAM,MAAMA,wBAAA,CAAe,IAAA,EAAM,KAAA,CAAM,QAAA,GAAW,IAAI,EAAE,CAAA;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,QAAA,EAAU,OAAO,GAAA;AAC5B,EAAA,OAAO,EAAE,GAAG,GAAA,EAAK,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,cAAA,GAAiB,CAAA;AACvB,IAAM,cAAA,GAAiB,GAAA;AACvB,IAAM,iBAAA,GAAoB,IAAA;AAKnB,SAAS,WACd,KAAA,EACA,EAAA,EACA,MACA,YAAA,GAAe,KAAA,EACf,SAAuB,qBAAA,EACd;AACT,EAAA,MAAM,EAAE,MAAA,EAAQ,IAAA,EAAK,GAAI,KAAA;AACzB,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAA,CAAO,MAAA,GAAS,OAAO,CAAA,GAAI,CAAA;AAC3B,IAAA,IAAA,CAAK,MAAA,GAAS,OAAO,CAAA,GAAI,CAAA;AAAA,EAC3B,WAAW,IAAA,EAAM;AACf,IAAA,MAAA,CAAO,MAAA,GAAS,CAAA;AAChB,IAAA,IAAI,MAAA,CAAO,CAAA,GAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,GAAS,CAAA;AAAA,EAC/C,CAAA,MAAO;AACL,IAAA,IAAA,CAAK,MAAA,GAAS,CAAA;AACd,IAAA,IAAI,IAAA,CAAK,CAAA,GAAI,iBAAA,EAAmB,MAAA,CAAO,MAAA,GAAS,CAAA;AAAA,EAClD;AACA,EAAA,MAAM,WAAA,GAAc,UAAA;AAAA,IAClB,MAAA;AAAA,IACA,EAAA;AAAA,IACA,IAAA,GAAO,MAAA,CAAO,UAAA,GAAa,MAAA,CAAO,WAAA;AAAA,IAClC,cAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,SAAA,GAAY,UAAA;AAAA,IAChB,IAAA;AAAA,IACA,EAAA;AAAA,IACA,IAAA,GAAO,MAAA,CAAO,QAAA,GAAW,MAAA,CAAO,SAAA;AAAA,IAChC,IAAA,GAAO,OAAO,eAAA,GAAkB,kBAAA;AAAA,IAChC;AAAA,GACF;AACA,EAAA,OAAO,WAAA,IAAe,SAAA;AACxB","file":"index.cjs","sourcesContent":["// Atom states — shared across every client: the set of states, what they mean, and what they do\n// to the material. Sizes, layout and per-input idioms are client-specific and live elsewhere.\nimport { activeMaterial, type VireGlassMaterial } from 'vireglass';\n\nexport type VireUIKitAtomKind =\n | 'button'\n | 'iconButton'\n | 'switch'\n | 'slider'\n | 'segment'\n | 'chip'\n | 'field'\n | 'menu';\n\n/** Hover and focus don't exist everywhere: touch has neither. The atom accepts them, but has to\n * look complete at zero too — otherwise a touch client gets an unfinished look. */\nexport type VireUIKitAtomState = {\n pressed: number;\n hovered: number;\n selected: number;\n disabled: boolean;\n};\n\nexport const ATOM_AT_REST: VireUIKitAtomState = {\n pressed: 0,\n hovered: 0,\n selected: 0,\n disabled: false,\n};\n\n/**\n * Whether the piece lifts INTO the glass under press (1) or sinks into the backing (0).\n *\n * Lift isn't decoration: a small target has the finger covering it entirely, and an enlarged\n * transparent lens underneath is the only sign of a hit. A large target stays visible past the\n * finger, so it reads more naturally sinking toward the backing instead.\n */\nexport function atomLift(kind: VireUIKitAtomKind): number {\n switch (kind) {\n case 'iconButton':\n case 'switch':\n case 'slider':\n return 1;\n default:\n return 0;\n }\n}\n\n/** A disabled piece stays glass but stops asserting itself: the legibility requirement is lifted\n * and tint turns off. Hiding it via transparency won't do — the material is already transparent. */\nconst DISABLED_PRESENCE = 0.25;\n/** Hover is halfway to a press: the cursor is already on the target, but nothing is chosen yet. */\nconst HOVER_GAIN = 0.35;\n\n/**\n * The atom's material for a given state. Press and selection go through `activeMaterial` — for\n * glass, state is a change in the MEDIUM itself (denser, thicker, clearer), not a highlight\n * drawn over it.\n */\nexport function atomMaterial(\n base: VireGlassMaterial,\n kind: VireUIKitAtomKind,\n state: VireUIKitAtomState = ATOM_AT_REST,\n): VireGlassMaterial {\n const clamp = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n const on = Math.max(clamp(state.selected), clamp(state.pressed), clamp(state.hovered) * HOVER_GAIN);\n const out = activeMaterial(base, state.disabled ? 0 : on);\n if (!state.disabled) return out;\n return { ...out, presence: out.presence * DISABLED_PRESENCE };\n}\n\n/** Whether every field on the atom matches rest — lets a client skip redraws for states its own\n * input can never produce (hover on touch, focus on Android). */\nexport function atomAtRest(state: VireUIKitAtomState): boolean {\n return (\n state.pressed === 0 && state.hovered === 0 && state.selected === 0 && state.disabled === false\n );\n}\n","// Two-phase \"capsule → drop → target\" growth: atom behavior, not layout. The body contracts into\n// a drop, a neck grows from its side toward the target, the drop grows into the target with a\n// slight overshoot; closing retraces the same path in reverse, because the model holds no\n// direction, only the current phase. Source and target sizes are layout, supplied as parameters.\nimport { halfMinDp, type VireGlassGeometry, type VireGlassMorph } from 'vireglass';\n\n/** A spring with `response`-second settle time; `damping` < 1 overshoots. `instant` skips\n * integration entirely, for reduced motion. */\nexport type Spring = { x: number; v: number; target: number };\n\nexport function stepSpring(\n s: Spring,\n dt: number,\n response: number,\n damping: number,\n instant = false,\n): boolean {\n if (instant) {\n const moved = s.x !== s.target || s.v !== 0;\n s.x = s.target;\n s.v = 0;\n return moved;\n }\n const stiffness = ((2 * Math.PI) / response) ** 2;\n const friction = (4 * Math.PI * damping) / response;\n const h = 1 / 240;\n // Fixed step, but not a fixed frame budget: without this, a rare slow frame hands the spring a\n // huge dt and it diverges.\n for (let left = Math.min(dt, 0.05); left > 0; left -= h) {\n const step = Math.min(left, h);\n s.v += (stiffness * (s.target - s.x) - friction * s.v) * step;\n s.x += s.v * step;\n }\n if (Math.abs(s.target - s.x) < 1e-3 && Math.abs(s.v) < 1e-2) {\n s.x = s.target;\n s.v = 0;\n return false;\n }\n return true;\n}\n\nexport const smoothstep = (e0: number, e1: number, x: number): number => {\n const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);\n return t * t * (3 - 2 * t);\n};\n\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nexport type GrowthPoint = { x: number; y: number };\n\n/** A shape and its position — it has no role of its own; `growthFrame` assigns the role (body, or\n * what the body is merging into). */\nexport type GrowthShape = { geometry: VireGlassGeometry; center: GrowthPoint };\n\n/** `shrink` — capsule → drop, no overshoot. `grow` — drop → target; may exceed 1 for the\n * overshoot. Both are read as-is; `stepGrowth` owns the bounds and the handoff between them. */\nexport type GrowthPhase = { shrink: number; grow: number };\n\nexport type GrowthInk = {\n /** 0…1: how much of the source's ink is still visible (1) vs. already defocused into the drop (0). */\n outgoing: number;\n /** 0…1: how much of the target's ink has come into focus (0 = not yet, 1 = fully). */\n incoming: number;\n};\n\nexport type GrowthFrame = {\n /** The shape worth drawing as glass right now: the larger of the two, which supplies the\n * thickness and the bevel. */\n body: GrowthShape;\n /** The target shape as-is, regardless of role — it drives the response to finger/light while\n * the glass hasn't become it yet (while `body` is still the drop). */\n grown: GrowthShape;\n /** The second merge shape, ready for `toLensProps`/`toSurfaceUniforms`; `undefined` while the\n * neck hasn't grown yet or has already retracted. */\n merge: VireGlassMorph | undefined;\n ink: GrowthInk;\n};\n\n/** The drop's size — a fraction of the source's diameter, with headroom for the neck. */\nconst DROP_DIAMETER = 1.1;\n/** How far the drop travels from the source toward the target, as a fraction of the source's diameter. */\nconst DROP_LIFT = 0.5;\nconst NECK_GAIN = 0.3;\nconst NECK_RAMP = 4;\nconst CORNER_EASE_START = 0.55;\nconst INK_OUT_END = 0.4;\nconst INK_IN_START = 0.45;\nconst INK_IN_END = 0.95;\n\nexport function growthInk(phase: GrowthPhase): GrowthInk {\n const a = Math.min(Math.max(phase.shrink, 0), 1);\n const b = Math.max(phase.grow, 0);\n // Ink leaves and arrives by going out of focus, not by plain transparency — the blur amount is\n // the drawer's job, this only reports the fraction of focus.\n return {\n outgoing: 1 - smoothstep(0, INK_OUT_END, a),\n incoming: smoothstep(INK_IN_START, INK_IN_END, b),\n };\n}\n\n/** The main shape is the larger one by half-size: it supplies the thickness and the bevel, so the\n * roles swap exactly at equal half-sizes, which is invisible on screen. */\nfunction largerOf(a: GrowthShape, b: GrowthShape): { main: GrowthShape; other: GrowthShape } {\n return halfMinDp(a.geometry) >= halfMinDp(b.geometry) ? { main: a, other: b } : { main: b, other: a };\n}\n\n/** `anchor` is the corner shared by source and target: the body pins to it, otherwise the target\n * would grow out of the drop's center instead of the button's corner. */\nexport function growthFrame(\n source: GrowthShape,\n target: GrowthShape,\n anchor: GrowthPoint,\n phase: GrowthPhase,\n): GrowthFrame {\n const dx = target.center.x - source.center.x;\n const dy = target.center.y - source.center.y;\n const len = Math.hypot(dx, dy) || 1;\n const sourceSize = halfMinDp(source.geometry) * 2;\n const lift = DROP_LIFT * sourceSize;\n const drop: GrowthPoint = {\n x: source.center.x + (dx / len) * lift,\n y: source.center.y + (dy / len) * lift,\n };\n\n const a = Math.min(Math.max(phase.shrink, 0), 1);\n const b = Math.max(phase.grow, 0);\n const keep = Math.max(1 - b, 0);\n const d = DROP_DIAMETER * sourceSize;\n\n const shrunkGeometry: VireGlassGeometry = {\n width: mix(source.geometry.width, 0.6 * d, a) * keep,\n height: mix(source.geometry.height, 0.6 * d, a) * keep,\n cornerRadius: 0,\n };\n // The source's radius EASES into the drop's rather than being replaced by it outright —\n // otherwise a field with a partial corner radius at rest would render as a full pill.\n shrunkGeometry.cornerRadius = Math.min(\n mix(source.geometry.cornerRadius, halfMinDp(shrunkGeometry), a),\n halfMinDp(shrunkGeometry),\n );\n const shrunk: GrowthShape = {\n geometry: shrunkGeometry,\n center: { x: mix(source.center.x, drop.x, a), y: mix(source.center.y, drop.y, a) },\n };\n\n const seed = d * Math.sqrt(a);\n // The sign of the corner the body pins to. Zero means the anchor sits on the same axis as the\n // source's center, so growth along that axis centers instead of hugging an edge.\n const cornerX = Math.sign(anchor.x - source.center.x);\n const cornerY = Math.sign(anchor.y - source.center.y);\n const edgeX = mix(drop.x + cornerX * (seed / 2), anchor.x, Math.min(b, 1));\n const edgeY = mix(drop.y + cornerY * (seed / 2), anchor.y, Math.min(b, 1));\n const width = mix(seed, target.geometry.width, b);\n const height = mix(seed, target.geometry.height, b);\n const grownGeometry: VireGlassGeometry = { width, height, cornerRadius: 0 };\n grownGeometry.cornerRadius = Math.min(\n mix(halfMinDp(grownGeometry), target.geometry.cornerRadius, smoothstep(CORNER_EASE_START, 1, b)),\n halfMinDp(grownGeometry),\n );\n const grown: GrowthShape = {\n geometry: grownGeometry,\n center: { x: edgeX - cornerX * (width / 2), y: edgeY - cornerY * (height / 2) },\n };\n\n const { main, other } = largerOf(grown, shrunk);\n const neck = NECK_GAIN * sourceSize * Math.min(a * NECK_RAMP, 1) * keep;\n const united = neck > 0.01 && other.geometry.width > 0.5 && other.geometry.height > 0.5;\n\n return {\n body: main,\n grown,\n merge: united\n ? {\n offsetX: other.center.x - main.center.x,\n offsetY: other.center.y - main.center.y,\n width: other.geometry.width,\n height: other.geometry.height,\n cornerRadius: other.geometry.cornerRadius,\n smoothing: neck,\n }\n : undefined,\n ink: growthInk(phase),\n };\n}\n\nexport type GrowthState = { shrink: Spring; grow: Spring };\n\nexport const createGrowthState = (): GrowthState => ({\n shrink: { x: 0, v: 0, target: 0 },\n grow: { x: 0, v: 0, target: 0 },\n});\n\nexport const growthPhase = (state: GrowthState): GrowthPhase => ({\n shrink: state.shrink.x,\n grow: state.grow.x,\n});\n\n/** Durations are client-specific: this set is tuned for the capsule-to-menu transition, and an\n * atom at a different scale (an icon opening into a sheet) isn't obligated to match it. The\n * shape of the transition is shared regardless. */\nexport type GrowthTiming = {\n shrinkOpen: number;\n shrinkClose: number;\n growOpen: number;\n growClose: number;\n /** < 1 gives the target a slight overshoot on open; closing never overshoots. */\n growDampingOpen: number;\n};\n\nexport const DEFAULT_GROWTH_TIMING: GrowthTiming = {\n shrinkOpen: 0.38,\n shrinkClose: 0.3,\n growOpen: 0.46,\n growClose: 0.4,\n growDampingOpen: 0.72,\n};\n\nconst GROW_DAMPING_CLOSE = 1;\nconst SHRINK_DAMPING = 1;\nconst GROW_STARTS_AT = 0.8;\nconst SHRINK_RETURNS_AT = 0.12;\n\n/** Growth starts once the drop has gathered, and the reverse on close. `reduceMotion` turns off\n * the spring entirely: both phases jump straight to their target in one step, with no overshoot\n * and no defocus phase. */\nexport function stepGrowth(\n state: GrowthState,\n dt: number,\n open: boolean,\n reduceMotion = false,\n timing: GrowthTiming = DEFAULT_GROWTH_TIMING,\n): boolean {\n const { shrink, grow } = state;\n if (reduceMotion) {\n shrink.target = open ? 1 : 0;\n grow.target = open ? 1 : 0;\n } else if (open) {\n shrink.target = 1;\n if (shrink.x > GROW_STARTS_AT) grow.target = 1;\n } else {\n grow.target = 0;\n if (grow.x < SHRINK_RETURNS_AT) shrink.target = 0;\n }\n const movedShrink = stepSpring(\n shrink,\n dt,\n open ? timing.shrinkOpen : timing.shrinkClose,\n SHRINK_DAMPING,\n reduceMotion,\n );\n const movedGrow = stepSpring(\n grow,\n dt,\n open ? timing.growOpen : timing.growClose,\n open ? timing.growDampingOpen : GROW_DAMPING_CLOSE,\n reduceMotion,\n );\n return movedShrink || movedGrow;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/kit/a11y.ts","../src/kit/atom.ts","../src/kit/behavior/focus.ts","../src/kit/behavior/hover.ts","../src/kit/behavior/press.ts","../src/kit/behavior/control.ts","../src/kit/morph.ts","../src/kit/behavior/visual.ts","../src/kit/response.ts","../src/kit/sizes.ts"],"names":["activeMaterial","mix","applyAccessibility","resolveOptics","halfMinDp","concentricRadius"],"mappings":";;;;;AAMO,IAAM,SAAA,GAAsB;AAAA,EACjC,kBAAA,EAAoB,KAAA;AAAA,EACpB,gBAAA,EAAkB,KAAA;AAAA,EAClB,YAAA,EAAc;AAChB;AAKO,SAAS,WAAA,CAAY,MAAA,EAAkB,QAAA,GAAyB,EAAC,EAAa;AACnF,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,QAAA,CAAS,kBAAA,IAAsB,MAAA,CAAO,kBAAA;AAAA,IAC1D,gBAAA,EAAkB,QAAA,CAAS,gBAAA,IAAoB,MAAA,CAAO,gBAAA;AAAA,IACtD,YAAA,EAAc,QAAA,CAAS,YAAA,IAAgB,MAAA,CAAO;AAAA,GAChD;AACF;AAeO,SAAS,eAAA,CAAgB,MAAgB,UAAA,EAAmC;AACjF,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,UAAA;A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O,IAAA,CAAK,MAAA,EAAQ,UAAU,CAAA,EAAE;AACpD;AAEO,SAAS,YAAA,CAAa,WAAA,EAAqB,KAAA,EAAe,OAAA,GAAU,CAAA,EAAW;AACpF,EAAA,OAAOC,0BAAA,CAAiB,WAAA,EAAa,KAAA,EAAO,OAAO,CAAA;AACrD;AAEO,SAAS,YAAY,KAAA,EAAwC;AAClE,EAAA,OAAO,KAAA,CAAM,QAAQ,OAAA,GAAU,QAAA;AACjC;AAEO,SAAS,OAAA,CAAQ,QAAgB,WAAA,EAA6B;AACnE,EAAA,OAAO,MAAA,IAAU,WAAA,GAAc,CAAA,GAAA,CAAK,WAAA,GAAc,MAAA,IAAU,CAAA;AAC9D;AAEO,SAAS,UAAU,KAAA,EAAmC;AAC3D,EAAA,OAAO,KAAA,CAAM,QAAQ,mBAAA,GAAsB,qBAAA;AAC7C","file":"index.cjs","sourcesContent":["export type A11yMode = {\n reduceTransparency: boolean;\n increaseContrast: boolean;\n reduceMotion: boolean;\n};\n\nexport const A11Y_NONE: A11yMode = {\n reduceTransparency: false,\n increaseContrast: false,\n reduceMotion: false,\n};\n\n/** `undefined` follows the system; a boolean overrides it. */\nexport type A11yOverride = { [K in keyof A11yMode]?: boolean | undefined };\n\nexport function resolveA11y(system: A11yMode, override: A11yOverride = {}): A11yMode {\n return {\n reduceTransparency: override.reduceTransparency ?? system.reduceTransparency,\n increaseContrast: override.increaseContrast ?? system.increaseContrast,\n reduceMotion: override.reduceMotion ?? system.reduceMotion,\n };\n}\n\n/** `plain`: no glass was asked for. `frosted`: the stand-in when glass under reduced transparency cannot attach. */\nexport type Surface = 'plain' | 'frosted' | 'glass';\n\nexport type Presentation = {\n glass: boolean;\n /** Reduced transparency: the glass stays and frosts. */\n frost: boolean;\n surface: Surface;\n contrastBorder: boolean;\n instantSprings: boolean;\n};\n\n// Reduced motion stops the springs, not the press response itself.\nexport function presentationFor(mode: A11yMode, wantsGlass: boolean): Presentation {\n return {\n glass: wantsGlass,\n frost: wantsGlass && mode.reduceTransparency,\n surface: wantsGlass ? 'glass' : 'plain',\n contrastBorder: mode.increaseContrast,\n instantSprings: mode.reduceMotion,\n };\n}\n\nexport function sameA11y(a: A11yMode, b: A11yMode): boolean {\n return (\n a.reduceTransparency === b.reduceTransparency &&\n a.increaseContrast === b.increaseContrast &&\n a.reduceMotion === b.reduceMotion\n );\n}\n","// Atom states — shared across every client: the set of states, what they mean, and what they do\n// to the material. Sizes, layout and per-input idioms are client-specific and live elsewhere.\nimport { activeMaterial, applyAccessibility, resolveOptics, type VireGlassMaterial } from 'vireglass';\n\nexport type VireUIKitAtomKind =\n | 'button'\n | 'iconButton'\n | 'switch'\n | 'slider'\n | 'segment'\n | 'chip'\n | 'field'\n | 'menu';\n\n/** Hover and focus don't exist everywhere: touch has neither. The atom accepts them, but has to\n * look complete at zero too — otherwise a touch client gets an unfinished look. */\nexport type VireUIKitAtomState = {\n pressed: number;\n hovered: number;\n selected: number;\n disabled: boolean;\n};\n\nexport const ATOM_AT_REST: VireUIKitAtomState = {\n pressed: 0,\n hovered: 0,\n selected: 0,\n disabled: false,\n};\n\n/**\n * Whether the piece lifts INTO the glass under press (1) or sinks into the backing (0).\n *\n * Lift isn't decoration: a small target has the finger covering it entirely, and an enlarged\n * transparent lens underneath is the only sign of a hit. A large target stays visible past the\n * finger, so it reads more naturally sinking toward the backing instead.\n */\nexport function atomLift(kind: VireUIKitAtomKind): number {\n switch (kind) {\n case 'iconButton':\n case 'switch':\n case 'slider':\n return 1;\n default:\n return 0;\n }\n}\n\n/** A disabled piece stays glass but stops asserting itself: the legibility requirement is lifted\n * and tint turns off. Hiding it via transparency won't do — the material is already transparent. */\nconst DISABLED_PRESENCE = 0.25;\n/** Hover is halfway to a press: the cursor is already on the target, but nothing is chosen yet. */\nconst HOVER_GAIN = 0.35;\n\n/** How far a state is from rest toward the pressed end, 0..1. */\nfunction activation(state: VireUIKitAtomState): number {\n if (state.disabled) return 0;\n const clamp = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n return Math.max(clamp(state.selected), clamp(state.pressed), clamp(state.hovered) * HOVER_GAIN);\n}\n\n/**\n * The atom's material for a given state. Press and selection go through `activeMaterial` — for\n * glass, state is a change in the MEDIUM itself (denser, thicker, clearer), not a highlight\n * drawn over it.\n */\nexport function atomMaterial(\n base: VireGlassMaterial,\n kind: VireUIKitAtomKind,\n state: VireUIKitAtomState = ATOM_AT_REST,\n): VireGlassMaterial {\n const out = activeMaterial(base, activation(state));\n if (!state.disabled) return out;\n return { ...out, presence: out.presence * DISABLED_PRESENCE };\n}\n\n/** Whether every field on the atom matches rest — lets a client skip redraws for states its own\n * input can never produce (hover on touch, focus on Android). */\nexport function atomAtRest(state: VireUIKitAtomState): boolean {\n return (\n state.pressed === 0 && state.hovered === 0 && state.selected === 0 && state.disabled === false\n );\n}\n\n/** The veil over the backdrop: the surroundings' colour, `white` of it swapped for white, lifted by `lift` in OKLab lightness. */\nexport type AtomBody = { alpha: number; white: number; lift: number };\n\nconst REST_BODY: AtomBody = { alpha: 0.25, white: 0.15, lift: 0.1 };\nconst PRESSED_BODY: AtomBody = { alpha: 0.34, white: 0.35, lift: 0 };\nconst FROST_LIFT = 0.26;\n\n/** The body for a state; reduced transparency raises it to the density `vireglass` asks of the glass in that mode. */\nexport function atomBody(\n base: VireGlassMaterial,\n state: VireUIKitAtomState = ATOM_AT_REST,\n frost = false,\n): AtomBody {\n const on = activation(state);\n const mix = (key: keyof AtomBody) => REST_BODY[key] + (PRESSED_BODY[key] - REST_BODY[key]) * on;\n let alpha = mix('alpha');\n let white = mix('white');\n let lift = mix('lift');\n if (state.disabled) alpha *= DISABLED_PRESENCE;\n if (frost) {\n const density = applyAccessibility(resolveOptics(base), {\n reduceTransparency: true,\n increaseContrast: false,\n reduceMotion: false,\n }).bodyDensity;\n alpha = Math.max(alpha, density);\n white = 0;\n lift = FROST_LIFT;\n }\n return { alpha, white, lift };\n}\n","export type FocusChange = { type: 'focus'; visible: boolean } | { type: 'blur' };\n\n// `visible` is the browser's keyboard-modality verdict, so a ring follows a key on any device, and a\n// click, which also focuses a button, shows none.\nexport function stepFocus(event: FocusChange): boolean {\n return event.type === 'focus' && event.visible;\n}\n","export type HoverChange = { type: 'enter' } | { type: 'leave' };\n\nexport function stepHover(event: HoverChange, canHover: boolean): boolean {\n return canHover && event.type === 'enter';\n}\n","export type PressSource = 'pointer' | 'keyboard';\n\nexport type PressState = { by: PressSource | null };\n\nexport type PressEvent =\n | { type: 'down'; source: PressSource }\n | { type: 'up'; source: PressSource }\n | { type: 'cancel' }\n | { type: 'leave' };\n\nexport const PRESS_IDLE: PressState = { by: null };\n\nexport type PressStep = {\n state: PressState;\n activated: boolean;\n};\n\nexport function stepPress(state: PressState, event: PressEvent, enabled: boolean): PressStep {\n switch (event.type) {\n case 'down':\n if (!enabled || state.by !== null) return { state, activated: false };\n return { state: { by: event.source }, activated: false };\n case 'up':\n // A key lifted mid-touch is not a tap.\n if (state.by !== event.source) return { state, activated: false };\n return { state: PRESS_IDLE, activated: enabled };\n case 'cancel':\n return { state: PRESS_IDLE, activated: false };\n case 'leave':\n // A key press has no position, so the pointer leaving cannot cancel it.\n return state.by === 'pointer' ? { state: PRESS_IDLE, activated: false } : { state, activated: false };\n }\n}\n","import { stepFocus, type FocusChange } from './focus';\nimport { stepHover, type HoverChange } from './hover';\nimport { PRESS_IDLE, stepPress, type PressEvent, type PressState } from './press';\n\nexport type InputCaps = { hover: boolean };\n\nexport const TOUCH_INPUT: InputCaps = { hover: false };\nexport const POINTER_INPUT: InputCaps = { hover: true };\n\nexport type ControlState = {\n press: PressState;\n hovered: boolean;\n focused: boolean;\n disabled: boolean;\n};\n\nexport const CONTROL_IDLE: ControlState = {\n press: PRESS_IDLE,\n hovered: false,\n focused: false,\n disabled: false,\n};\n\nexport type ControlEvent = PressEvent | HoverChange | FocusChange | { type: 'disable'; disabled: boolean };\n\nexport type ControlStep = { state: ControlState; activated: boolean };\n\nexport function stepControl(state: ControlState, event: ControlEvent, caps: InputCaps): ControlStep {\n switch (event.type) {\n case 'down':\n case 'up':\n case 'cancel': {\n const next = stepPress(state.press, event, !state.disabled);\n return { state: { ...state, press: next.state }, activated: next.activated };\n }\n case 'leave': {\n const next = stepPress(state.press, event, !state.disabled);\n return { state: { ...state, press: next.state, hovered: false }, activated: false };\n }\n case 'enter':\n return {\n state: { ...state, hovered: !state.disabled && stepHover(event, caps.hover) },\n activated: false,\n };\n case 'focus':\n case 'blur': {\n // Focus moving away takes the key-up with it, so a held key press must not outlive it.\n const press = event.type === 'blur' && state.press.by === 'keyboard' ? PRESS_IDLE : state.press;\n return {\n state: { ...state, press, focused: !state.disabled && stepFocus(event) },\n activated: false,\n };\n }\n case 'disable':\n return {\n state: event.disabled\n ? { press: PRESS_IDLE, hovered: false, focused: false, disabled: true }\n : { ...state, disabled: false },\n activated: false,\n };\n }\n}\n\nexport type ControlTargets = {\n pressed: number;\n hovered: number;\n focus: number;\n disabled: boolean;\n};\n\nexport function controlTargets(state: ControlState): ControlTargets {\n return {\n pressed: state.press.by !== null ? 1 : 0,\n hovered: state.hovered ? 1 : 0,\n focus: state.focused ? 1 : 0,\n disabled: state.disabled,\n };\n}\n","// Two-phase \"capsule → drop → target\" growth: atom behavior, not layout. The body contracts into\n// a drop, a neck grows from its side toward the target, the drop grows into the target with a\n// slight overshoot; closing retraces the same path in reverse, because the model holds no\n// direction, only the current phase. Source and target sizes are layout, supplied as parameters.\nimport { halfMinDp, type VireGlassGeometry, type VireGlassMorph } from 'vireglass';\n\n/** A spring with `response`-second settle time; `damping` < 1 overshoots. `instant` skips\n * integration entirely, for reduced motion. */\nexport type Spring = { x: number; v: number; target: number };\n\nexport function stepSpring(\n s: Spring,\n dt: number,\n response: number,\n damping: number,\n instant = false,\n): boolean {\n if (instant) {\n const moved = s.x !== s.target || s.v !== 0;\n s.x = s.target;\n s.v = 0;\n return moved;\n }\n const stiffness = ((2 * Math.PI) / response) ** 2;\n const friction = (4 * Math.PI * damping) / response;\n const h = 1 / 240;\n // Fixed step, but not a fixed frame budget: without this, a rare slow frame hands the spring a\n // huge dt and it diverges.\n for (let left = Math.min(dt, 0.05); left > 0; left -= h) {\n const step = Math.min(left, h);\n s.v += (stiffness * (s.target - s.x) - friction * s.v) * step;\n s.x += s.v * step;\n }\n if (Math.abs(s.target - s.x) < 1e-3 && Math.abs(s.v) < 1e-2) {\n s.x = s.target;\n s.v = 0;\n return false;\n }\n return true;\n}\n\nexport const smoothstep = (e0: number, e1: number, x: number): number => {\n const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);\n return t * t * (3 - 2 * t);\n};\n\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nexport type GrowthPoint = { x: number; y: number };\n\n/** A shape and its position — it has no role of its own; `growthFrame` assigns the role (body, or\n * what the body is merging into). */\nexport type GrowthShape = { geometry: VireGlassGeometry; center: GrowthPoint };\n\n/** `shrink` — capsule → drop, no overshoot. `grow` — drop → target; may exceed 1 for the\n * overshoot. Both are read as-is; `stepGrowth` owns the bounds and the handoff between them. */\nexport type GrowthPhase = { shrink: number; grow: number };\n\nexport type GrowthInk = {\n /** 0…1: how much of the source's ink is still visible (1) vs. already defocused into the drop (0). */\n outgoing: number;\n /** 0…1: how much of the target's ink has come into focus (0 = not yet, 1 = fully). */\n incoming: number;\n};\n\nexport type GrowthFrame = {\n /** The shape worth drawing as glass right now: the larger of the two, which supplies the\n * thickness and the bevel. */\n body: GrowthShape;\n /** The target shape as-is, regardless of role — it drives the response to finger/light while\n * the glass hasn't become it yet (while `body` is still the drop). */\n grown: GrowthShape;\n /** The second merge shape, ready for `toLensProps`/`toSurfaceUniforms`; `undefined` while the\n * neck hasn't grown yet or has already retracted. */\n merge: VireGlassMorph | undefined;\n ink: GrowthInk;\n};\n\n/** The drop's size — a fraction of the source's diameter, with headroom for the neck. */\nconst DROP_DIAMETER = 1.1;\n/** How far the drop travels from the source toward the target, as a fraction of the source's diameter. */\nconst DROP_LIFT = 0.5;\nconst NECK_GAIN = 0.3;\nconst NECK_RAMP = 4;\nconst CORNER_EASE_START = 0.55;\nconst INK_OUT_END = 0.4;\nconst INK_IN_START = 0.45;\nconst INK_IN_END = 0.95;\n\nexport function growthInk(phase: GrowthPhase): GrowthInk {\n const a = Math.min(Math.max(phase.shrink, 0), 1);\n const b = Math.max(phase.grow, 0);\n // Ink leaves and arrives by going out of focus, not by plain transparency — the blur amount is\n // the drawer's job, this only reports the fraction of focus.\n return {\n outgoing: 1 - smoothstep(0, INK_OUT_END, a),\n incoming: smoothstep(INK_IN_START, INK_IN_END, b),\n };\n}\n\n/** The main shape is the larger one by half-size: it supplies the thickness and the bevel, so the\n * roles swap exactly at equal half-sizes, which is invisible on screen. */\nfunction largerOf(a: GrowthShape, b: GrowthShape): { main: GrowthShape; other: GrowthShape } {\n return halfMinDp(a.geometry) >= halfMinDp(b.geometry) ? { main: a, other: b } : { main: b, other: a };\n}\n\n/** `anchor` is the corner shared by source and target: the body pins to it, otherwise the target\n * would grow out of the drop's center instead of the button's corner. */\nexport function growthFrame(\n source: GrowthShape,\n target: GrowthShape,\n anchor: GrowthPoint,\n phase: GrowthPhase,\n): GrowthFrame {\n const dx = target.center.x - source.center.x;\n const dy = target.center.y - source.center.y;\n const len = Math.hypot(dx, dy) || 1;\n const sourceSize = halfMinDp(source.geometry) * 2;\n const lift = DROP_LIFT * sourceSize;\n const drop: GrowthPoint = {\n x: source.center.x + (dx / len) * lift,\n y: source.center.y + (dy / len) * lift,\n };\n\n const a = Math.min(Math.max(phase.shrink, 0), 1);\n const b = Math.max(phase.grow, 0);\n const keep = Math.max(1 - b, 0);\n const d = DROP_DIAMETER * sourceSize;\n\n const shrunkGeometry: VireGlassGeometry = {\n width: mix(source.geometry.width, 0.6 * d, a) * keep,\n height: mix(source.geometry.height, 0.6 * d, a) * keep,\n cornerRadius: 0,\n };\n // The source's radius EASES into the drop's rather than being replaced by it outright —\n // otherwise a field with a partial corner radius at rest would render as a full pill.\n shrunkGeometry.cornerRadius = Math.min(\n mix(source.geometry.cornerRadius, halfMinDp(shrunkGeometry), a),\n halfMinDp(shrunkGeometry),\n );\n const shrunk: GrowthShape = {\n geometry: shrunkGeometry,\n center: { x: mix(source.center.x, drop.x, a), y: mix(source.center.y, drop.y, a) },\n };\n\n const seed = d * Math.sqrt(a);\n // The sign of the corner the body pins to. Zero means the anchor sits on the same axis as the\n // source's center, so growth along that axis centers instead of hugging an edge.\n const cornerX = Math.sign(anchor.x - source.center.x);\n const cornerY = Math.sign(anchor.y - source.center.y);\n const edgeX = mix(drop.x + cornerX * (seed / 2), anchor.x, Math.min(b, 1));\n const edgeY = mix(drop.y + cornerY * (seed / 2), anchor.y, Math.min(b, 1));\n const width = mix(seed, target.geometry.width, b);\n const height = mix(seed, target.geometry.height, b);\n const grownGeometry: VireGlassGeometry = { width, height, cornerRadius: 0 };\n grownGeometry.cornerRadius = Math.min(\n mix(halfMinDp(grownGeometry), target.geometry.cornerRadius, smoothstep(CORNER_EASE_START, 1, b)),\n halfMinDp(grownGeometry),\n );\n const grown: GrowthShape = {\n geometry: grownGeometry,\n center: { x: edgeX - cornerX * (width / 2), y: edgeY - cornerY * (height / 2) },\n };\n\n const { main, other } = largerOf(grown, shrunk);\n const neck = NECK_GAIN * sourceSize * Math.min(a * NECK_RAMP, 1) * keep;\n const united = neck > 0.01 && other.geometry.width > 0.5 && other.geometry.height > 0.5;\n\n return {\n body: main,\n grown,\n merge: united\n ? {\n offsetX: other.center.x - main.center.x,\n offsetY: other.center.y - main.center.y,\n width: other.geometry.width,\n height: other.geometry.height,\n cornerRadius: other.geometry.cornerRadius,\n smoothing: neck,\n }\n : undefined,\n ink: growthInk(phase),\n };\n}\n\nexport type GrowthState = { shrink: Spring; grow: Spring };\n\nexport const createGrowthState = (): GrowthState => ({\n shrink: { x: 0, v: 0, target: 0 },\n grow: { x: 0, v: 0, target: 0 },\n});\n\nexport const growthPhase = (state: GrowthState): GrowthPhase => ({\n shrink: state.shrink.x,\n grow: state.grow.x,\n});\n\n/** Durations are client-specific: this set is tuned for the capsule-to-menu transition, and an\n * atom at a different scale (an icon opening into a sheet) isn't obligated to match it. The\n * shape of the transition is shared regardless. */\nexport type GrowthTiming = {\n shrinkOpen: number;\n shrinkClose: number;\n growOpen: number;\n growClose: number;\n /** < 1 gives the target a slight overshoot on open; closing never overshoots. */\n growDampingOpen: number;\n};\n\nexport const DEFAULT_GROWTH_TIMING: GrowthTiming = {\n shrinkOpen: 0.38,\n shrinkClose: 0.3,\n growOpen: 0.46,\n growClose: 0.4,\n growDampingOpen: 0.72,\n};\n\nconst GROW_DAMPING_CLOSE = 1;\nconst SHRINK_DAMPING = 1;\nconst GROW_STARTS_AT = 0.8;\nconst SHRINK_RETURNS_AT = 0.12;\n\n/** Growth starts once the drop has gathered, and the reverse on close. `reduceMotion` turns off\n * the spring entirely: both phases jump straight to their target in one step, with no overshoot\n * and no defocus phase. */\nexport function stepGrowth(\n state: GrowthState,\n dt: number,\n open: boolean,\n reduceMotion = false,\n timing: GrowthTiming = DEFAULT_GROWTH_TIMING,\n): boolean {\n const { shrink, grow } = state;\n if (reduceMotion) {\n shrink.target = open ? 1 : 0;\n grow.target = open ? 1 : 0;\n } else if (open) {\n shrink.target = 1;\n if (shrink.x > GROW_STARTS_AT) grow.target = 1;\n } else {\n grow.target = 0;\n if (grow.x < SHRINK_RETURNS_AT) shrink.target = 0;\n }\n const movedShrink = stepSpring(\n shrink,\n dt,\n open ? timing.shrinkOpen : timing.shrinkClose,\n SHRINK_DAMPING,\n reduceMotion,\n );\n const movedGrow = stepSpring(\n grow,\n dt,\n open ? timing.growOpen : timing.growClose,\n open ? timing.growDampingOpen : GROW_DAMPING_CLOSE,\n reduceMotion,\n );\n return movedShrink || movedGrow;\n}\n","import type { VireUIKitAtomState } from '../atom';\nimport { stepSpring, type Spring } from '../morph';\nimport { controlTargets, type ControlState } from './control';\n\nexport type ControlVisual = {\n pressed: Spring;\n hovered: Spring;\n focus: Spring;\n};\n\nexport const createControlVisual = (): ControlVisual => ({\n pressed: { x: 0, v: 0, target: 0 },\n hovered: { x: 0, v: 0, target: 0 },\n focus: { x: 0, v: 0, target: 0 },\n});\n\n// Press attacks fast and settles with a little give; hover and focus just ease.\nconst PRESS = { response: 0.18, damping: 0.78 };\nconst HOVER = { response: 0.22, damping: 1 };\nconst FOCUS = { response: 0.16, damping: 1 };\n\nexport function stepControlVisual(\n visual: ControlVisual,\n dt: number,\n state: ControlState,\n instant = false,\n): boolean {\n const t = controlTargets(state);\n visual.pressed.target = t.pressed;\n visual.hovered.target = t.hovered;\n visual.focus.target = t.focus;\n const a = stepSpring(visual.pressed, dt, PRESS.response, PRESS.damping, instant);\n const b = stepSpring(visual.hovered, dt, HOVER.response, HOVER.damping, instant);\n const c = stepSpring(visual.focus, dt, FOCUS.response, FOCUS.damping, instant);\n return a || b || c;\n}\n\n// The press may overshoot 1; `atomMaterial` clamps, so the raw value is passed through.\nexport function visualAtomState(visual: ControlVisual, state: ControlState): VireUIKitAtomState {\n return {\n pressed: visual.pressed.x,\n hovered: visual.hovered.x,\n selected: 0,\n disabled: state.disabled,\n };\n}\n\nexport function settleControlVisual(visual: ControlVisual, state: ControlState): void {\n stepControlVisual(visual, 0, state, true);\n}\n","import { atomLift, type VireUIKitAtomKind } from './atom';\n\nexport type PressResponse = {\n /** Fraction of its own size the body adds at full press. */\n grow: number;\n /** Glyph blur at full press, px. */\n defocus: number;\n};\n\n// A lifted piece grows more: the finger covers it, so the enlarged lens is the only sign of a hit.\nconst LIFTING: PressResponse = { grow: 0.18, defocus: 1.6 };\nconst SINKING: PressResponse = { grow: 0.06, defocus: 1 };\n\nexport function pressResponse(kind: VireUIKitAtomKind): PressResponse {\n return atomLift(kind) === 1 ? LIFTING : SINKING;\n}\n","import { concentricRadius } from 'vireglass';\n\nexport type ControlSize = 'touch' | 'small' | 'medium' | 'large' | 'xlarge';\n\nexport const CONTROL_SIZES: readonly ControlSize[] = ['touch', 'small', 'medium', 'large', 'xlarge'];\n\nexport type SizeSpec = {\n /** Body height; an icon button is a square of this side. */\n height: number;\n paddingX: number;\n icon: number;\n radius: number;\n shape: 'capsule' | 'rounded';\n};\n\nexport const MIN_TOUCH_TARGET_DP = 44;\nexport const MIN_POINTER_TARGET_DP = 24;\n\nconst capsule = (height: number, paddingX: number): SizeSpec => ({\n height,\n paddingX,\n icon: Math.round(height / 2),\n radius: height / 2,\n shape: 'capsule',\n});\n\nconst rounded = (height: number, paddingX: number): SizeSpec => ({\n height,\n paddingX,\n icon: Math.round(height / 2),\n radius: height / 4,\n shape: 'rounded',\n});\n\n// Where each number comes from: docs/acceptance.md.\nexport const BUTTON_SIZES: Readonly<Record<ControlSize, SizeSpec>> = {\n touch: capsule(44, 20),\n small: rounded(24, 10),\n medium: rounded(32, 14),\n large: capsule(40, 18),\n xlarge: capsule(48, 22),\n};\n\nexport function iconButtonSize(size: ControlSize): SizeSpec & { width: number } {\n const spec = BUTTON_SIZES[size];\n return { ...spec, width: spec.height, paddingX: 0 };\n}\n\nexport function nestedRadius(outerRadius: number, inset: number, minimum = 0): number {\n return concentricRadius(outerRadius, inset, minimum);\n}\n\nexport function defaultSize(input: { touch: boolean }): ControlSize {\n return input.touch ? 'touch' : 'medium';\n}\n\nexport function hitSlop(bodyDp: number, minTargetDp: number): number {\n return bodyDp >= minTargetDp ? 0 : (minTargetDp - bodyDp) / 2;\n}\n\nexport function minTarget(input: { touch: boolean }): number {\n return input.touch ? MIN_TOUCH_TARGET_DP : MIN_POINTER_TARGET_DP;\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { A as A11Y_NONE, a as A11yMode, b as A11yOverride, P as Presentation, S as Surface, p as presentationFor, r as resolveA11y, s as sameA11y } from './a11y-D3SS74I3.cjs';
|
|
1
2
|
import { VireGlassMaterial, VireGlassGeometry, VireGlassMorph } from 'vireglass';
|
|
2
3
|
|
|
3
4
|
type VireUIKitAtomKind = 'button' | 'iconButton' | 'switch' | 'slider' | 'segment' | 'chip' | 'field' | 'menu';
|
|
@@ -27,6 +28,80 @@ declare function atomMaterial(base: VireGlassMaterial, kind: VireUIKitAtomKind,
|
|
|
27
28
|
/** Whether every field on the atom matches rest — lets a client skip redraws for states its own
|
|
28
29
|
* input can never produce (hover on touch, focus on Android). */
|
|
29
30
|
declare function atomAtRest(state: VireUIKitAtomState): boolean;
|
|
31
|
+
/** The veil over the backdrop: the surroundings' colour, `white` of it swapped for white, lifted by `lift` in OKLab lightness. */
|
|
32
|
+
type AtomBody = {
|
|
33
|
+
alpha: number;
|
|
34
|
+
white: number;
|
|
35
|
+
lift: number;
|
|
36
|
+
};
|
|
37
|
+
/** The body for a state; reduced transparency raises it to the density `vireglass` asks of the glass in that mode. */
|
|
38
|
+
declare function atomBody(base: VireGlassMaterial, state?: VireUIKitAtomState, frost?: boolean): AtomBody;
|
|
39
|
+
|
|
40
|
+
type FocusChange = {
|
|
41
|
+
type: 'focus';
|
|
42
|
+
visible: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'blur';
|
|
45
|
+
};
|
|
46
|
+
declare function stepFocus(event: FocusChange): boolean;
|
|
47
|
+
|
|
48
|
+
type HoverChange = {
|
|
49
|
+
type: 'enter';
|
|
50
|
+
} | {
|
|
51
|
+
type: 'leave';
|
|
52
|
+
};
|
|
53
|
+
declare function stepHover(event: HoverChange, canHover: boolean): boolean;
|
|
54
|
+
|
|
55
|
+
type PressSource = 'pointer' | 'keyboard';
|
|
56
|
+
type PressState = {
|
|
57
|
+
by: PressSource | null;
|
|
58
|
+
};
|
|
59
|
+
type PressEvent = {
|
|
60
|
+
type: 'down';
|
|
61
|
+
source: PressSource;
|
|
62
|
+
} | {
|
|
63
|
+
type: 'up';
|
|
64
|
+
source: PressSource;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'cancel';
|
|
67
|
+
} | {
|
|
68
|
+
type: 'leave';
|
|
69
|
+
};
|
|
70
|
+
declare const PRESS_IDLE: PressState;
|
|
71
|
+
type PressStep = {
|
|
72
|
+
state: PressState;
|
|
73
|
+
activated: boolean;
|
|
74
|
+
};
|
|
75
|
+
declare function stepPress(state: PressState, event: PressEvent, enabled: boolean): PressStep;
|
|
76
|
+
|
|
77
|
+
type InputCaps = {
|
|
78
|
+
hover: boolean;
|
|
79
|
+
};
|
|
80
|
+
declare const TOUCH_INPUT: InputCaps;
|
|
81
|
+
declare const POINTER_INPUT: InputCaps;
|
|
82
|
+
type ControlState = {
|
|
83
|
+
press: PressState;
|
|
84
|
+
hovered: boolean;
|
|
85
|
+
focused: boolean;
|
|
86
|
+
disabled: boolean;
|
|
87
|
+
};
|
|
88
|
+
declare const CONTROL_IDLE: ControlState;
|
|
89
|
+
type ControlEvent = PressEvent | HoverChange | FocusChange | {
|
|
90
|
+
type: 'disable';
|
|
91
|
+
disabled: boolean;
|
|
92
|
+
};
|
|
93
|
+
type ControlStep = {
|
|
94
|
+
state: ControlState;
|
|
95
|
+
activated: boolean;
|
|
96
|
+
};
|
|
97
|
+
declare function stepControl(state: ControlState, event: ControlEvent, caps: InputCaps): ControlStep;
|
|
98
|
+
type ControlTargets = {
|
|
99
|
+
pressed: number;
|
|
100
|
+
hovered: number;
|
|
101
|
+
focus: number;
|
|
102
|
+
disabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
declare function controlTargets(state: ControlState): ControlTargets;
|
|
30
105
|
|
|
31
106
|
/** A spring with `response`-second settle time; `damping` < 1 overshoots. `instant` skips
|
|
32
107
|
* integration entirely, for reduced motion. */
|
|
@@ -98,4 +173,47 @@ declare const DEFAULT_GROWTH_TIMING: GrowthTiming;
|
|
|
98
173
|
* and no defocus phase. */
|
|
99
174
|
declare function stepGrowth(state: GrowthState, dt: number, open: boolean, reduceMotion?: boolean, timing?: GrowthTiming): boolean;
|
|
100
175
|
|
|
101
|
-
|
|
176
|
+
type ControlVisual = {
|
|
177
|
+
pressed: Spring;
|
|
178
|
+
hovered: Spring;
|
|
179
|
+
focus: Spring;
|
|
180
|
+
};
|
|
181
|
+
declare const createControlVisual: () => ControlVisual;
|
|
182
|
+
declare function stepControlVisual(visual: ControlVisual, dt: number, state: ControlState, instant?: boolean): boolean;
|
|
183
|
+
declare function visualAtomState(visual: ControlVisual, state: ControlState): VireUIKitAtomState;
|
|
184
|
+
declare function settleControlVisual(visual: ControlVisual, state: ControlState): void;
|
|
185
|
+
|
|
186
|
+
type PressResponse = {
|
|
187
|
+
/** Fraction of its own size the body adds at full press. */
|
|
188
|
+
grow: number;
|
|
189
|
+
/** Glyph blur at full press, px. */
|
|
190
|
+
defocus: number;
|
|
191
|
+
};
|
|
192
|
+
declare function pressResponse(kind: VireUIKitAtomKind): PressResponse;
|
|
193
|
+
|
|
194
|
+
type ControlSize = 'touch' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
195
|
+
declare const CONTROL_SIZES: readonly ControlSize[];
|
|
196
|
+
type SizeSpec = {
|
|
197
|
+
/** Body height; an icon button is a square of this side. */
|
|
198
|
+
height: number;
|
|
199
|
+
paddingX: number;
|
|
200
|
+
icon: number;
|
|
201
|
+
radius: number;
|
|
202
|
+
shape: 'capsule' | 'rounded';
|
|
203
|
+
};
|
|
204
|
+
declare const MIN_TOUCH_TARGET_DP = 44;
|
|
205
|
+
declare const MIN_POINTER_TARGET_DP = 24;
|
|
206
|
+
declare const BUTTON_SIZES: Readonly<Record<ControlSize, SizeSpec>>;
|
|
207
|
+
declare function iconButtonSize(size: ControlSize): SizeSpec & {
|
|
208
|
+
width: number;
|
|
209
|
+
};
|
|
210
|
+
declare function nestedRadius(outerRadius: number, inset: number, minimum?: number): number;
|
|
211
|
+
declare function defaultSize(input: {
|
|
212
|
+
touch: boolean;
|
|
213
|
+
}): ControlSize;
|
|
214
|
+
declare function hitSlop(bodyDp: number, minTargetDp: number): number;
|
|
215
|
+
declare function minTarget(input: {
|
|
216
|
+
touch: boolean;
|
|
217
|
+
}): number;
|
|
218
|
+
|
|
219
|
+
export { ATOM_AT_REST, type AtomBody, BUTTON_SIZES, CONTROL_IDLE, CONTROL_SIZES, type ControlEvent, type ControlSize, type ControlState, type ControlStep, type ControlTargets, type ControlVisual, DEFAULT_GROWTH_TIMING, type FocusChange, type GrowthFrame, type GrowthInk, type GrowthPhase, type GrowthPoint, type GrowthShape, type GrowthState, type GrowthTiming, type HoverChange, type InputCaps, MIN_POINTER_TARGET_DP, MIN_TOUCH_TARGET_DP, POINTER_INPUT, PRESS_IDLE, type PressEvent, type PressResponse, type PressSource, type PressState, type PressStep, type SizeSpec, type Spring, TOUCH_INPUT, type VireUIKitAtomKind, type VireUIKitAtomState, atomAtRest, atomBody, atomLift, atomMaterial, controlTargets, createControlVisual, createGrowthState, defaultSize, growthFrame, growthInk, growthPhase, hitSlop, iconButtonSize, minTarget, nestedRadius, pressResponse, settleControlVisual, smoothstep, stepControl, stepControlVisual, stepFocus, stepGrowth, stepHover, stepPress, stepSpring, visualAtomState };
|