use-scroll-animate 2.4.0 → 2.5.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/CHANGELOG.md +15 -0
- package/README.md +1 -0
- package/README_ja.md +1 -0
- package/README_zh.md +1 -0
- package/dist/components/click.cjs +985 -0
- package/dist/components/click.cjs.map +1 -0
- package/dist/components/click.css +9 -0
- package/dist/components/click.d.cts +250 -0
- package/dist/components/click.d.ts +250 -0
- package/dist/components/click.js +967 -0
- package/dist/components/click.js.map +1 -0
- package/dist/components.cjs +19 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +7 -0
- package/dist/components.d.cts +214 -2
- package/dist/components.d.ts +214 -2
- package/dist/components.js +5 -1
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/components.md +13 -0
- package/package.json +13 -2
package/dist/components.d.ts
CHANGED
|
@@ -1001,6 +1001,217 @@ declare global {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
|
+
declare const CLICK_EFFECTS: readonly ["ripple", "burst", "confetti", "squish", "press-spring", "shake"];
|
|
1005
|
+
type ClickEffect = (typeof CLICK_EFFECTS)[number];
|
|
1006
|
+
/**
|
|
1007
|
+
* `<usa-click>` — click / tap effects on whatever it wraps (combinable:
|
|
1008
|
+
* `effect="press-spring burst"`).
|
|
1009
|
+
*
|
|
1010
|
+
* - `ripple` — an ink wave from the pointer (enhanced: `color`, soft edge);
|
|
1011
|
+
* - `burst` — particles radiating from the pointer (`shape`: circle, square, star, heart, emoji);
|
|
1012
|
+
* - `confetti` — a confetti cannon from the click point;
|
|
1013
|
+
* - `squish` — squash on press, stretch on release (spring);
|
|
1014
|
+
* - `press-spring` — dips while pressed, springs back with overshoot;
|
|
1015
|
+
* - `shake` — horizontal error shake; plays on `invalid` events from a form
|
|
1016
|
+
* inside, on `shake()`, or on click when `trigger="click"`.
|
|
1017
|
+
*
|
|
1018
|
+
* Attributes: `effect`, `color`, `shape`, `count`, `haptic` (vibrate ms,
|
|
1019
|
+
* where supported), `disabled`. Keyboard (Space/Enter) triggers the effects
|
|
1020
|
+
* from the centre. Reduced motion: no particles or movement; press dims.
|
|
1021
|
+
*/
|
|
1022
|
+
interface UsaClickElement extends UsaElement {
|
|
1023
|
+
readonly effects: string[];
|
|
1024
|
+
play(x?: number, y?: number): void;
|
|
1025
|
+
shake(): void;
|
|
1026
|
+
}
|
|
1027
|
+
declare function defineClick(tag?: string): CustomElementConstructor | undefined;
|
|
1028
|
+
|
|
1029
|
+
declare const BUTTON_DEFORMS: readonly ["squash", "wobble", "gooey", "dent"];
|
|
1030
|
+
type ButtonDeform = (typeof BUTTON_DEFORMS)[number];
|
|
1031
|
+
type ButtonShape = 'pill' | 'circle' | 'icon';
|
|
1032
|
+
type ButtonState = 'idle' | 'loading' | 'success' | 'error';
|
|
1033
|
+
/**
|
|
1034
|
+
* `<usa-button>` — **button click deformation** (按钮点击形变) around a
|
|
1035
|
+
* native `<button>` (or `<a>`) child — or the element itself becomes a button.
|
|
1036
|
+
*
|
|
1037
|
+
* `deform` (combinable, e.g. `deform="squash wobble"`):
|
|
1038
|
+
* - `squash` — squash on press, stretch-and-settle on release (spring);
|
|
1039
|
+
* - `wobble` — elastic border-radius wobble after a click;
|
|
1040
|
+
* - `gooey` — liquid blob: droplets squeeze out from the press point and
|
|
1041
|
+
* merge back (SVG goo filter);
|
|
1042
|
+
* - `dent` — the surface dents toward the pressed point (3D tilt + inner shade).
|
|
1043
|
+
*
|
|
1044
|
+
* `shape="pill | circle | icon"` morphs the outline with a spring (label =
|
|
1045
|
+
* `[data-label]`, icon = `[data-icon]` children); `morphTo(shape)`.
|
|
1046
|
+
*
|
|
1047
|
+
* `morph="submit"` — click → `loading` (shrinks to a circle with a spinner,
|
|
1048
|
+
* `aria-busy`), then `success` (check) or `error` (shake + cross), and back
|
|
1049
|
+
* to `idle` after `reset` ms (1800). Drive it with `state="…"` / `.state`, or
|
|
1050
|
+
* call `event.detail.done(ok)` from a `usa:submit` listener.
|
|
1051
|
+
*
|
|
1052
|
+
* Attributes: `deform`, `shape`, `morph`, `state`, `reset`, `haptic`,
|
|
1053
|
+
* `disabled`. Events: `usa:submit`, `usa:state`. Reduced motion: no
|
|
1054
|
+
* deformation; shape and state changes are instant; status still announced.
|
|
1055
|
+
*/
|
|
1056
|
+
interface UsaButtonElement extends UsaElement {
|
|
1057
|
+
readonly target: HTMLElement;
|
|
1058
|
+
shape: ButtonShape;
|
|
1059
|
+
state: ButtonState;
|
|
1060
|
+
morphTo(shape: ButtonShape): Promise<void>;
|
|
1061
|
+
}
|
|
1062
|
+
declare function defineButton(tag?: string): CustomElementConstructor | undefined;
|
|
1063
|
+
|
|
1064
|
+
type Pt = [number, number];
|
|
1065
|
+
type Quad = [Pt, Pt, Pt, Pt];
|
|
1066
|
+
/**
|
|
1067
|
+
* Morphable icons: every icon is three quads (four points each) on a 24×24
|
|
1068
|
+
* grid, so any icon can morph into any other by interpolating points.
|
|
1069
|
+
*/
|
|
1070
|
+
declare const MORPH_ICONS: Record<string, [Quad, Quad, Quad]>;
|
|
1071
|
+
/** SVG path data for an icon, or for the interpolation `t` (0–1) between two. */
|
|
1072
|
+
declare function morphPath(from: string, to?: string, t?: number): string;
|
|
1073
|
+
/**
|
|
1074
|
+
* `<usa-icon-morph>` — an icon that morphs between shapes with a spring:
|
|
1075
|
+
* play ↔ pause, menu ↔ close, plus ↔ minus, check, arrow-right…
|
|
1076
|
+
*
|
|
1077
|
+
* Attributes: `icons` (comma list, cycled; default `play,pause`), `index`
|
|
1078
|
+
* (current, 0), `size` (px, 24), `toggle` (makes it a button that cycles
|
|
1079
|
+
* on click / Enter / Space), `labels` (comma list of accessible names per
|
|
1080
|
+
* icon, e.g. `Play,Pause`), `preset` (spring, `wobbly`). Methods:
|
|
1081
|
+
* `next()`, `show(nameOrIndex)`. Events: `usa:change` (`{ index, icon }`).
|
|
1082
|
+
* Inside a `<usa-button>` or `<button>` it is decorative. Reduced motion:
|
|
1083
|
+
* the icon switches instantly.
|
|
1084
|
+
*/
|
|
1085
|
+
interface UsaIconMorphElement extends UsaElement {
|
|
1086
|
+
index: number;
|
|
1087
|
+
readonly icon: string;
|
|
1088
|
+
next(): void;
|
|
1089
|
+
show(icon: string | number): void;
|
|
1090
|
+
}
|
|
1091
|
+
declare function defineIconMorph(tag?: string): CustomElementConstructor | undefined;
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* `<usa-like>` — a like / favourite toggle: the heart pops with a spring and
|
|
1095
|
+
* bursts into particles when liked. `role="button"` + `aria-pressed`.
|
|
1096
|
+
*
|
|
1097
|
+
* Attributes: `liked`, `count` (shown next to the heart, updated ±1),
|
|
1098
|
+
* `label` (accessible name, default "Like"), `color`, `size` (px, 24),
|
|
1099
|
+
* `haptic`, `disabled`. Events: `change`, `usa:change` (`{ liked, count }`).
|
|
1100
|
+
* Reduced motion: colour change only.
|
|
1101
|
+
*/
|
|
1102
|
+
interface UsaLikeElement extends UsaElement {
|
|
1103
|
+
liked: boolean;
|
|
1104
|
+
count: number | null;
|
|
1105
|
+
toggle(force?: boolean): void;
|
|
1106
|
+
}
|
|
1107
|
+
declare function defineLike(tag?: string): CustomElementConstructor | undefined;
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* `<usa-hold>` — hold-to-confirm: press and hold (pointer, Space or Enter)
|
|
1111
|
+
* while a progress ring fills; releasing early rewinds it. Good for
|
|
1112
|
+
* destructive actions.
|
|
1113
|
+
*
|
|
1114
|
+
* Attributes: `duration` (ms, 1200), `label` (accessible name), `color`,
|
|
1115
|
+
* `disabled`. CSS variable `--usa-hold` (0–1). Events: `usa:progress`,
|
|
1116
|
+
* `usa:confirm`, `usa:cancel`. Reduced motion: same timing, the ring fills
|
|
1117
|
+
* without the scale pulse.
|
|
1118
|
+
*/
|
|
1119
|
+
interface UsaHoldElement extends UsaElement {
|
|
1120
|
+
readonly progress: number;
|
|
1121
|
+
cancel(): void;
|
|
1122
|
+
}
|
|
1123
|
+
declare function defineHold(tag?: string): CustomElementConstructor | undefined;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* `<usa-double-tap>` — detects a double tap / double click on its content
|
|
1127
|
+
* (photos, posts) and pops a heart (or `icon`) at the tap point.
|
|
1128
|
+
*
|
|
1129
|
+
* Attributes: `icon` (text / emoji, default ♥), `color`, `delay` (max ms
|
|
1130
|
+
* between taps, 300), `haptic`, `disabled`. Events: `usa:double-tap`
|
|
1131
|
+
* (`{ x, y }`, element-relative). Keyboard users: press `L` while focused.
|
|
1132
|
+
* Reduced motion: the icon fades in and out without scaling or particles.
|
|
1133
|
+
*/
|
|
1134
|
+
interface UsaDoubleTapElement extends UsaElement {
|
|
1135
|
+
pop(x?: number, y?: number): void;
|
|
1136
|
+
}
|
|
1137
|
+
declare function defineDoubleTap(tag?: string): CustomElementConstructor | undefined;
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* `<usa-checkbox>` — an animated, form-associated checkbox: the box springs
|
|
1141
|
+
* and the check mark draws itself. `role="checkbox"` + `aria-checked`
|
|
1142
|
+
* (`mixed` with `indeterminate`).
|
|
1143
|
+
*
|
|
1144
|
+
* Attributes: `checked`, `indeterminate`, `disabled`, `name`, `value`
|
|
1145
|
+
* (`on`), `label`, `shape` (`square` default, `circle`). Events: `change`,
|
|
1146
|
+
* `usa:change` (`{ checked }`). Reduced motion: no spring or drawing.
|
|
1147
|
+
*/
|
|
1148
|
+
interface UsaCheckboxElement extends UsaElement {
|
|
1149
|
+
checked: boolean;
|
|
1150
|
+
indeterminate: boolean;
|
|
1151
|
+
toggle(force?: boolean): void;
|
|
1152
|
+
}
|
|
1153
|
+
declare function defineCheckbox(tag?: string): CustomElementConstructor | undefined;
|
|
1154
|
+
|
|
1155
|
+
interface BurstOptions {
|
|
1156
|
+
/** Number of particles (default 12). */
|
|
1157
|
+
count?: number;
|
|
1158
|
+
/** Colours to pick from (default: accent palette). */
|
|
1159
|
+
colors?: string[];
|
|
1160
|
+
/** Travel distance in px (default 48). */
|
|
1161
|
+
distance?: number;
|
|
1162
|
+
/** Particle size in px (default 6). */
|
|
1163
|
+
size?: number;
|
|
1164
|
+
/** `circle` (default), `square`, `star`, `heart` or any text / emoji. */
|
|
1165
|
+
shape?: 'circle' | 'square' | 'star' | 'heart' | string;
|
|
1166
|
+
/** Duration in ms (default 600). */
|
|
1167
|
+
duration?: number;
|
|
1168
|
+
}
|
|
1169
|
+
/** Particles radiating from client point (x, y). Returns the number spawned. */
|
|
1170
|
+
declare function burst(x: number, y: number, options?: BurstOptions): number;
|
|
1171
|
+
interface ConfettiOptions {
|
|
1172
|
+
/** Origin in client px (default: centre-bottom third of the viewport). */
|
|
1173
|
+
x?: number;
|
|
1174
|
+
y?: number;
|
|
1175
|
+
/** Pieces (default 80). */
|
|
1176
|
+
count?: number;
|
|
1177
|
+
/** Spread angle in degrees (default 70). */
|
|
1178
|
+
spread?: number;
|
|
1179
|
+
/** Launch speed multiplier (default 1). */
|
|
1180
|
+
velocity?: number;
|
|
1181
|
+
colors?: string[];
|
|
1182
|
+
/** Duration in ms (default 1600). */
|
|
1183
|
+
duration?: number;
|
|
1184
|
+
}
|
|
1185
|
+
/** A confetti cannon (paper pieces with gravity, drift and spin). */
|
|
1186
|
+
declare function confetti(options?: ConfettiOptions): number;
|
|
1187
|
+
/** Horizontal error shake (`intensity` px, default 8). Reduced motion: a red outline flash. */
|
|
1188
|
+
declare function shake(el: Element, intensity?: number, duration?: number): Animation | null;
|
|
1189
|
+
/** `navigator.vibrate()` where supported (Android Chrome, some WebViews). Returns whether it ran. */
|
|
1190
|
+
declare function haptic(pattern?: number | number[]): boolean;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* use-scroll-animate/components/click — click & tap effects (v2.5).
|
|
1194
|
+
* `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
|
|
1195
|
+
* `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
|
|
1196
|
+
* shape morph; submit → loading → success), `<usa-icon-morph>`,
|
|
1197
|
+
* `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
|
|
1198
|
+
* `burst()`, `confetti()`, `shake()` and `haptic()`.
|
|
1199
|
+
*/
|
|
1200
|
+
|
|
1201
|
+
/** Register every component of this category under its default tag. */
|
|
1202
|
+
declare function defineClickComponents(): void;
|
|
1203
|
+
declare global {
|
|
1204
|
+
interface HTMLElementTagNameMap {
|
|
1205
|
+
'usa-click': UsaClickElement;
|
|
1206
|
+
'usa-button': UsaButtonElement;
|
|
1207
|
+
'usa-icon-morph': UsaIconMorphElement;
|
|
1208
|
+
'usa-like': UsaLikeElement;
|
|
1209
|
+
'usa-hold': UsaHoldElement;
|
|
1210
|
+
'usa-double-tap': UsaDoubleTapElement;
|
|
1211
|
+
'usa-checkbox': UsaCheckboxElement;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1004
1215
|
/** The component categories and their default tags. */
|
|
1005
1216
|
declare const COMPONENT_CATEGORIES: {
|
|
1006
1217
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1011,6 +1222,7 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1011
1222
|
readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-flip-list", "usa-view-switch"];
|
|
1012
1223
|
readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
|
|
1013
1224
|
readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
|
|
1225
|
+
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
1014
1226
|
};
|
|
1015
1227
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1016
1228
|
/**
|
|
@@ -1019,5 +1231,5 @@ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
|
1019
1231
|
*/
|
|
1020
1232
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
1021
1233
|
|
|
1022
|
-
export { CARD_EFFECTS, COMPONENT_CATEGORIES, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAurora, defineBackgroundComponents, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineComponents, defineCounter, defineDialog, defineDraggable, defineFeedbackComponents, defineFlipList, defineGrain, defineInteractionComponents, defineMagnetic, defineMarquee, defineOverscroll, defineParticles, definePhysicsComponents, definePress, defineProgress, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSpinner, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTransitionComponents, defineTypewriter, defineViewSwitch, easeOutExpo, flip, linearEasing, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, revealKeyframes, rubberBand, scrambleFrame, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, toast, viewTransition };
|
|
1023
|
-
export type { CardEffect, ComponentCategory, ComponentsConfig, ConnectedOptions, DialogVariant, FlipOptions, RevealEffect, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAuroraElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCounterElement, UsaDialogElement, UsaDraggableElement, UsaElement, UsaFlipListElement, UsaGrainElement, UsaMagneticElement, UsaMarqueeElement, UsaOverscrollElement, UsaParticlesElement, UsaPressElement, UsaProgressElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSpinnerElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTypewriterElement, UsaViewSwitchElement, ViewTransitionOptions };
|
|
1234
|
+
export { BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, MORPH_ICONS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAurora, defineBackgroundComponents, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineDialog, defineDoubleTap, defineDraggable, defineFeedbackComponents, defineFlipList, defineGrain, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineMagnetic, defineMarquee, defineOverscroll, defineParticles, definePhysicsComponents, definePress, defineProgress, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSpinner, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTransitionComponents, defineTypewriter, defineViewSwitch, easeOutExpo, flip, haptic, linearEasing, morphPath, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, revealKeyframes, rubberBand, scrambleFrame, shake, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, toast, viewTransition };
|
|
1235
|
+
export type { BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, DialogVariant, FlipOptions, RevealEffect, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAuroraElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaDialogElement, UsaDoubleTapElement, UsaDraggableElement, UsaElement, UsaFlipListElement, UsaGrainElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaMagneticElement, UsaMarqueeElement, UsaOverscrollElement, UsaParticlesElement, UsaPressElement, UsaProgressElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSpinnerElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTypewriterElement, UsaViewSwitchElement, ViewTransitionOptions };
|
package/dist/components.js
CHANGED
|
@@ -14,6 +14,8 @@ import { definePhysicsComponents } from './components/physics.js';
|
|
|
14
14
|
export { SPRING_EFFECTS, defineDraggable, defineOverscroll, defineSpring, springEffectKeyframes } from './components/physics.js';
|
|
15
15
|
import { defineCardComponents } from './components/cards.js';
|
|
16
16
|
export { CARD_EFFECTS, defineCard, defineCardStack, defineCarousel3d, defineStickyStack } from './components/cards.js';
|
|
17
|
+
import { defineClickComponents } from './components/click.js';
|
|
18
|
+
export { BUTTON_DEFORMS, CLICK_EFFECTS, MORPH_ICONS, burst, confetti, defineButton, defineCheckbox, defineClick, defineDoubleTap, defineHold, defineIconMorph, defineLike, haptic, morphPath, shake } from './components/click.js';
|
|
17
19
|
export { S as SPRING_PRESETS, c as createSpring, l as linearEasing, p as projectInertia, r as resolveSpring, a as rubberBand, s as snapTo, b as spring, d as springEasing, e as springSamples, f as stepSpring, g as supportsLinearEasing } from './chunks/spring-BKUU7-Xm.js';
|
|
18
20
|
export { c as configureComponents, p as prefersReducedMotion } from './chunks/base-CuvCgqLy.js';
|
|
19
21
|
|
|
@@ -47,6 +49,7 @@ const COMPONENT_CATEGORIES = {
|
|
|
47
49
|
transitions: ['usa-dialog', 'usa-accordion', 'usa-flip-list', 'usa-view-switch'],
|
|
48
50
|
physics: ['usa-spring', 'usa-draggable', 'usa-overscroll'],
|
|
49
51
|
cards: ['usa-card', 'usa-card-stack', 'usa-sticky-stack', 'usa-carousel-3d'],
|
|
52
|
+
click: ['usa-click', 'usa-button', 'usa-icon-morph', 'usa-like', 'usa-hold', 'usa-double-tap', 'usa-checkbox'],
|
|
50
53
|
};
|
|
51
54
|
const BY_CATEGORY = {
|
|
52
55
|
reveal: defineRevealComponents,
|
|
@@ -57,6 +60,7 @@ const BY_CATEGORY = {
|
|
|
57
60
|
transitions: defineTransitionComponents,
|
|
58
61
|
physics: definePhysicsComponents,
|
|
59
62
|
cards: defineCardComponents,
|
|
63
|
+
click: defineClickComponents,
|
|
60
64
|
};
|
|
61
65
|
/**
|
|
62
66
|
* Register every `<usa-*>` component (or only the given categories).
|
|
@@ -66,5 +70,5 @@ function defineComponents(categories) {
|
|
|
66
70
|
(categories || Object.keys(BY_CATEGORY)).forEach((c) => BY_CATEGORY[c]?.());
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
export { COMPONENT_CATEGORIES, defineBackgroundComponents, defineCardComponents, defineComponents, defineFeedbackComponents, defineInteractionComponents, definePhysicsComponents, defineRevealComponents, defineTextComponents, defineTransitionComponents };
|
|
73
|
+
export { COMPONENT_CATEGORIES, defineBackgroundComponents, defineCardComponents, defineClickComponents, defineComponents, defineFeedbackComponents, defineInteractionComponents, definePhysicsComponents, defineRevealComponents, defineTextComponents, defineTransitionComponents };
|
|
70
74
|
//# sourceMappingURL=components.js.map
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\n\n/** The component categories and their default tags. */\nexport const COMPONENT_CATEGORIES = {\n reveal: ['usa-reveal', 'usa-stagger', 'usa-scroll-progress', 'usa-scrolly'],\n text: ['usa-typewriter', 'usa-split-text', 'usa-scramble', 'usa-counter', 'usa-shimmer-text', 'usa-text-rotate'],\n interaction: ['usa-ripple', 'usa-magnetic', 'usa-tilt', 'usa-spotlight', 'usa-press', 'usa-toggle'],\n feedback: ['usa-spinner', 'usa-skeleton', 'usa-progress', 'usa-toaster', 'usa-check'],\n background: ['usa-aurora', 'usa-particles', 'usa-grain', 'usa-marquee', 'usa-acrylic'],\n transitions: ['usa-dialog', 'usa-accordion', 'usa-flip-list', 'usa-view-switch'],\n physics: ['usa-spring', 'usa-draggable', 'usa-overscroll'],\n cards: ['usa-card', 'usa-card-stack', 'usa-sticky-stack', 'usa-carousel-3d'],\n} as const;\n\nexport type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\n\n/** The component categories and their default tags. */\nexport const COMPONENT_CATEGORIES = {\n reveal: ['usa-reveal', 'usa-stagger', 'usa-scroll-progress', 'usa-scrolly'],\n text: ['usa-typewriter', 'usa-split-text', 'usa-scramble', 'usa-counter', 'usa-shimmer-text', 'usa-text-rotate'],\n interaction: ['usa-ripple', 'usa-magnetic', 'usa-tilt', 'usa-spotlight', 'usa-press', 'usa-toggle'],\n feedback: ['usa-spinner', 'usa-skeleton', 'usa-progress', 'usa-toaster', 'usa-check'],\n background: ['usa-aurora', 'usa-particles', 'usa-grain', 'usa-marquee', 'usa-acrylic'],\n transitions: ['usa-dialog', 'usa-accordion', 'usa-flip-list', 'usa-view-switch'],\n physics: ['usa-spring', 'usa-draggable', 'usa-overscroll'],\n cards: ['usa-card', 'usa-card-stack', 'usa-sticky-stack', 'usa-carousel-3d'],\n click: ['usa-click', 'usa-button', 'usa-icon-morph', 'usa-like', 'usa-hold', 'usa-double-tap', 'usa-checkbox'],\n} as const;\n\nexport type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAqBH;AACO,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,aAAa,CAAC;AAC3E,IAAA,IAAI,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;AAChH,IAAA,WAAW,EAAE,CAAC,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,CAAC;IACnG,QAAQ,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,CAAC;IACrF,UAAU,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,CAAC;IACtF,WAAW,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,CAAC;AAChF,IAAA,OAAO,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,gBAAgB,CAAC;IAC1D,KAAK,EAAE,CAAC,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;AAC5E,IAAA,KAAK,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,CAAC;;AAKhH,MAAM,WAAW,GAA0C;AACzD,IAAA,MAAM,EAAE,sBAAsB;AAC9B,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,WAAW,EAAE,2BAA2B;AACxC,IAAA,QAAQ,EAAE,wBAAwB;AAClC,IAAA,UAAU,EAAE,0BAA0B;AACtC,IAAA,WAAW,EAAE,0BAA0B;AACvC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,KAAK,EAAE,oBAAoB;AAC3B,IAAA,KAAK,EAAE,qBAAqB;CAC7B;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,UAAgC,EAAA;IAC/D,CAAC,UAAU,IAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAyB,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACtG;;;;"}
|