@wix/interact 1.76.0 → 1.78.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/cjs/WixInteractElement.js +3 -0
- package/dist/cjs/WixInteractElement.js.map +1 -1
- package/dist/cjs/__tests__/interact.spec.js +87 -18
- package/dist/cjs/__tests__/interact.spec.js.map +1 -1
- package/dist/cjs/core/Interact.js +7 -0
- package/dist/cjs/core/Interact.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/WixInteractElement.js +3 -0
- package/dist/esm/WixInteractElement.js.map +1 -1
- package/dist/esm/__tests__/interact.spec.js +87 -18
- package/dist/esm/__tests__/interact.spec.js.map +1 -1
- package/dist/esm/core/Interact.js +7 -0
- package/dist/esm/core/Interact.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/types/WixInteractElement.d.ts +1 -0
- package/dist/types/core/Interact.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -50,6 +50,13 @@ export class Interact {
|
|
|
50
50
|
instance.init(config);
|
|
51
51
|
return instance;
|
|
52
52
|
}
|
|
53
|
+
static destroy() {
|
|
54
|
+
Interact.elementCache.forEach(element => {
|
|
55
|
+
element.disconnect();
|
|
56
|
+
});
|
|
57
|
+
Interact.instances.length = 0;
|
|
58
|
+
Interact.elementCache.clear();
|
|
59
|
+
}
|
|
53
60
|
static getInstance(key) {
|
|
54
61
|
return Interact.instances.find(instance => instance.has(key));
|
|
55
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getWixInteractElement","generateId","registerWixInteractElement","customElements","get","wixInteractElement","define","Interact","constructor","_defineProperty","dataCache","effects","conditions","interactions","addedInteractions","listInteractionsCache","init","config","window","parseConfig","didRegister","elementCache","forEach","element","key","connect","has","clearInteractionStateForKey","_this$dataCache$inter","interactionIds","interactionId","create","instance","instances","push","getInstance","find","getElement","setElement","set","_Interact","Map","interactionIdCounter","getSelector","d","asCombinator","listContainer","selector","_config$interactions","interaction","_interaction$effects","_interaction$effects2","source","interactionIdx","console","error","triggers","Set","selectors","reverse","add","effect","target","effectId","referencedEffect","rest"],"sources":["../../../src/core/Interact.ts"],"sourcesContent":["import {\n InteractCache,\n IWixInteractElement,\n InteractConfig,\n EffectRef,\n Effect,\n Interaction,\n} from '../types';\nimport { getWixInteractElement } from '../WixInteractElement';\nimport { generateId } from '../utils';\n\nfunction registerWixInteractElement() {\n if (!customElements.get('wix-interact-element')) {\n const wixInteractElement = getWixInteractElement();\n customElements.define('wix-interact-element', wixInteractElement);\n\n return true;\n }\n\n return false;\n}\n\nexport class Interact {\n dataCache: InteractCache;\n addedInteractions: { [interactionId: string]: boolean };\n listInteractionsCache: {\n [listContainer: string]: { [interactionId: string]: boolean };\n };\n static forceReducedMotion: boolean = false;\n static instances: Interact[] = [];\n static elementCache = new Map<string, IWixInteractElement>();\n\n constructor() {\n this.dataCache = { effects: {}, conditions: {}, interactions: {} };\n this.addedInteractions = {};\n this.listInteractionsCache = {};\n }\n\n init(config: InteractConfig): void {\n if (typeof window === 'undefined' || !window.customElements) {\n return;\n }\n\n this.dataCache = parseConfig(config);\n\n const didRegister = registerWixInteractElement();\n\n if (!didRegister) {\n Interact.elementCache.forEach((element: IWixInteractElement, key) =>\n element.connect(key),\n );\n }\n }\n\n has(key: string): boolean {\n return !!this.dataCache.interactions[key];\n }\n\n clearInteractionStateForKey(key: string): void {\n const interactionIds =\n this.dataCache.interactions[key]?.interactionIds || [];\n\n interactionIds.forEach((interactionId) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.addedInteractions[interactionId];\n });\n }\n\n static create(config: InteractConfig): Interact {\n const instance = new Interact();\n Interact.instances.push(instance);\n\n instance.init(config);\n\n return instance;\n }\n\n static getInstance(key: string): Interact | undefined {\n return Interact.instances.find((instance) => instance.has(key));\n }\n\n static getElement(key: string): IWixInteractElement | undefined {\n return Interact.elementCache.get(key);\n }\n\n static setElement(key: string, element: IWixInteractElement): void {\n Interact.elementCache.set(key, element);\n }\n}\n\nlet interactionIdCounter = 0;\n\nexport function getSelector(\n d: Interaction | Effect,\n asCombinator: boolean = false,\n): string {\n if (d.listContainer) {\n if (d.selector) {\n return `${d.listContainer} ${d.selector}`;\n }\n\n return `${d.listContainer} > *`;\n } else if (d.selector) {\n return d.selector;\n }\n\n // TODO: consider moving :scope to be configurable since it may lead to unexpected results in some cases\n return asCombinator ? '> :first-child' : ':scope > :first-child';\n}\n\n/**\n * Parses the config object and caches interactions, effects, and conditions\n */\nfunction parseConfig(config: InteractConfig): InteractCache {\n const conditions = config.conditions || {};\n const interactions: InteractCache['interactions'] = {};\n\n config.interactions?.forEach((interaction) => {\n const source = interaction.key;\n const interactionIdx = ++interactionIdCounter;\n\n if (!source) {\n console.error(\n `Interaction ${interactionIdx} is missing a key for source element.`,\n );\n return;\n }\n\n if (!interactions[source]) {\n interactions[source] = {\n triggers: [],\n effects: {},\n interactionIds: new Set(),\n selectors: new Set(),\n };\n }\n\n /*\n * Cache interaction trigger by source element\n */\n interaction.effects?.reverse(); // reverse to ensure the first effect is the one that will be applied first\n\n interactions[source].triggers.push(interaction);\n interactions[source].selectors.add(getSelector(interaction));\n\n const listContainer = interaction.listContainer;\n\n interaction.effects?.forEach((effect) => {\n /*\n * Target cascade order is the first of:\n * -> Config.interactions.effects.effect.key\n * -> Config.effects.effect.key\n * -> Config.interactions.interaction.key\n */\n let target = effect.key;\n\n if (!target && (effect as EffectRef).effectId) {\n const referencedEffect = config.effects[(effect as EffectRef).effectId];\n\n if (referencedEffect) {\n target = referencedEffect.key;\n }\n }\n\n if (!(effect as EffectRef).effectId) {\n (effect as EffectRef).effectId = generateId();\n }\n\n // if no target is specified, use the source element as the target\n target = target || source;\n effect.key = target;\n const effectId = (effect as EffectRef).effectId;\n\n if (listContainer && effect.listContainer) {\n // we do not support having 2 separate lists for same interaction\n if (target !== source || effect.listContainer !== listContainer) {\n return;\n }\n }\n\n const interactionId = `${target}::${effectId}::${interactionIdx}`;\n effect.interactionId = interactionId;\n interactions[source].interactionIds.add(interactionId);\n\n if (target === source) {\n // if target is the source element, no need to add an interaction to `effects`\n return;\n }\n\n /*\n * Cache interaction effect by target element\n */\n if (!interactions[target]) {\n interactions[target] = {\n triggers: [],\n effects: {\n [interactionId]: [],\n },\n interactionIds: new Set(),\n selectors: new Set(),\n };\n } else if (!interactions[target].effects[interactionId]) {\n interactions[target].effects[interactionId] = [];\n interactions[target].interactionIds.add(interactionId);\n }\n\n const { effects, ...rest } = interaction;\n\n interactions[target].effects[interactionId].push({ ...rest, effect });\n interactions[target].selectors.add(getSelector(effect));\n });\n });\n\n return {\n effects: config.effects || {},\n conditions,\n interactions,\n };\n}\n"],"mappings":";;AAQA,SAASA,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,0BAA0BA,CAAA,EAAG;EACpC,IAAI,CAACC,cAAc,CAACC,GAAG,CAAC,sBAAsB,CAAC,EAAE;IAC/C,MAAMC,kBAAkB,GAAGL,qBAAqB,CAAC,CAAC;IAClDG,cAAc,CAACG,MAAM,CAAC,sBAAsB,EAAED,kBAAkB,CAAC;IAEjE,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd;AAEA,OAAO,MAAME,QAAQ,CAAC;EAUpBC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACZ,IAAI,CAACC,SAAS,GAAG;MAAEC,OAAO,EAAE,CAAC,CAAC;MAAEC,UAAU,EAAE,CAAC,CAAC;MAAEC,YAAY,EAAE,CAAC;IAAE,CAAC;IAClE,IAAI,CAACC,iBAAiB,GAAG,CAAC,CAAC;IAC3B,IAAI,CAACC,qBAAqB,GAAG,CAAC,CAAC;EACjC;EAEAC,IAAIA,CAACC,MAAsB,EAAQ;IACjC,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACf,cAAc,EAAE;MAC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ACiD,MAAM,CAAC,CAACJ,SAAS,CAACE,GAAG,CAACjB,WAAW,CAACkB,MAAM,CAAC,CAAC;IACzD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLlD,OAAO,EAAEM,MAAM,CAACN,OAAO,IAAI,CAAC,CAAC;IAC7BC,UAAU;IACVC;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getWixInteractElement","generateId","registerWixInteractElement","customElements","get","wixInteractElement","define","Interact","constructor","_defineProperty","dataCache","effects","conditions","interactions","addedInteractions","listInteractionsCache","init","config","window","parseConfig","didRegister","elementCache","forEach","element","key","connect","has","clearInteractionStateForKey","_this$dataCache$inter","interactionIds","interactionId","create","instance","instances","push","destroy","disconnect","length","clear","getInstance","find","getElement","setElement","set","_Interact","Map","interactionIdCounter","getSelector","d","asCombinator","listContainer","selector","_config$interactions","interaction","_interaction$effects","_interaction$effects2","source","interactionIdx","console","error","triggers","Set","selectors","reverse","add","effect","target","effectId","referencedEffect","rest"],"sources":["../../../src/core/Interact.ts"],"sourcesContent":["import {\n InteractCache,\n IWixInteractElement,\n InteractConfig,\n EffectRef,\n Effect,\n Interaction,\n} from '../types';\nimport { getWixInteractElement } from '../WixInteractElement';\nimport { generateId } from '../utils';\n\nfunction registerWixInteractElement() {\n if (!customElements.get('wix-interact-element')) {\n const wixInteractElement = getWixInteractElement();\n customElements.define('wix-interact-element', wixInteractElement);\n\n return true;\n }\n\n return false;\n}\n\nexport class Interact {\n dataCache: InteractCache;\n addedInteractions: { [interactionId: string]: boolean };\n listInteractionsCache: {\n [listContainer: string]: { [interactionId: string]: boolean };\n };\n static forceReducedMotion: boolean = false;\n static instances: Interact[] = [];\n static elementCache = new Map<string, IWixInteractElement>();\n\n constructor() {\n this.dataCache = { effects: {}, conditions: {}, interactions: {} };\n this.addedInteractions = {};\n this.listInteractionsCache = {};\n }\n\n init(config: InteractConfig): void {\n if (typeof window === 'undefined' || !window.customElements) {\n return;\n }\n\n this.dataCache = parseConfig(config);\n\n const didRegister = registerWixInteractElement();\n\n if (!didRegister) {\n Interact.elementCache.forEach((element: IWixInteractElement, key) =>\n element.connect(key),\n );\n }\n }\n\n has(key: string): boolean {\n return !!this.dataCache.interactions[key];\n }\n\n clearInteractionStateForKey(key: string): void {\n const interactionIds =\n this.dataCache.interactions[key]?.interactionIds || [];\n\n interactionIds.forEach((interactionId) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.addedInteractions[interactionId];\n });\n }\n\n static create(config: InteractConfig): Interact {\n const instance = new Interact();\n Interact.instances.push(instance);\n\n instance.init(config);\n\n return instance;\n }\n\n static destroy(): void {\n Interact.elementCache.forEach((element: IWixInteractElement) => {\n element.disconnect();\n });\n Interact.instances.length = 0;\n Interact.elementCache.clear();\n }\n\n static getInstance(key: string): Interact | undefined {\n return Interact.instances.find((instance) => instance.has(key));\n }\n\n static getElement(key: string): IWixInteractElement | undefined {\n return Interact.elementCache.get(key);\n }\n\n static setElement(key: string, element: IWixInteractElement): void {\n Interact.elementCache.set(key, element);\n }\n}\n\nlet interactionIdCounter = 0;\n\nexport function getSelector(\n d: Interaction | Effect,\n asCombinator: boolean = false,\n): string {\n if (d.listContainer) {\n if (d.selector) {\n return `${d.listContainer} ${d.selector}`;\n }\n\n return `${d.listContainer} > *`;\n } else if (d.selector) {\n return d.selector;\n }\n\n // TODO: consider moving :scope to be configurable since it may lead to unexpected results in some cases\n return asCombinator ? '> :first-child' : ':scope > :first-child';\n}\n\n/**\n * Parses the config object and caches interactions, effects, and conditions\n */\nfunction parseConfig(config: InteractConfig): InteractCache {\n const conditions = config.conditions || {};\n const interactions: InteractCache['interactions'] = {};\n\n config.interactions?.forEach((interaction) => {\n const source = interaction.key;\n const interactionIdx = ++interactionIdCounter;\n\n if (!source) {\n console.error(\n `Interaction ${interactionIdx} is missing a key for source element.`,\n );\n return;\n }\n\n if (!interactions[source]) {\n interactions[source] = {\n triggers: [],\n effects: {},\n interactionIds: new Set(),\n selectors: new Set(),\n };\n }\n\n /*\n * Cache interaction trigger by source element\n */\n interaction.effects?.reverse(); // reverse to ensure the first effect is the one that will be applied first\n\n interactions[source].triggers.push(interaction);\n interactions[source].selectors.add(getSelector(interaction));\n\n const listContainer = interaction.listContainer;\n\n interaction.effects?.forEach((effect) => {\n /*\n * Target cascade order is the first of:\n * -> Config.interactions.effects.effect.key\n * -> Config.effects.effect.key\n * -> Config.interactions.interaction.key\n */\n let target = effect.key;\n\n if (!target && (effect as EffectRef).effectId) {\n const referencedEffect = config.effects[(effect as EffectRef).effectId];\n\n if (referencedEffect) {\n target = referencedEffect.key;\n }\n }\n\n if (!(effect as EffectRef).effectId) {\n (effect as EffectRef).effectId = generateId();\n }\n\n // if no target is specified, use the source element as the target\n target = target || source;\n effect.key = target;\n const effectId = (effect as EffectRef).effectId;\n\n if (listContainer && effect.listContainer) {\n // we do not support having 2 separate lists for same interaction\n if (target !== source || effect.listContainer !== listContainer) {\n return;\n }\n }\n\n const interactionId = `${target}::${effectId}::${interactionIdx}`;\n effect.interactionId = interactionId;\n interactions[source].interactionIds.add(interactionId);\n\n if (target === source) {\n // if target is the source element, no need to add an interaction to `effects`\n return;\n }\n\n /*\n * Cache interaction effect by target element\n */\n if (!interactions[target]) {\n interactions[target] = {\n triggers: [],\n effects: {\n [interactionId]: [],\n },\n interactionIds: new Set(),\n selectors: new Set(),\n };\n } else if (!interactions[target].effects[interactionId]) {\n interactions[target].effects[interactionId] = [];\n interactions[target].interactionIds.add(interactionId);\n }\n\n const { effects, ...rest } = interaction;\n\n interactions[target].effects[interactionId].push({ ...rest, effect });\n interactions[target].selectors.add(getSelector(effect));\n });\n });\n\n return {\n effects: config.effects || {},\n conditions,\n interactions,\n };\n}\n"],"mappings":";;AAQA,SAASA,qBAAqB,QAAQ,uBAAuB;AAC7D,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,0BAA0BA,CAAA,EAAG;EACpC,IAAI,CAACC,cAAc,CAACC,GAAG,CAAC,sBAA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AAY,CAAC2C,MAAM,CAAC,CAAC3B,cAAc,CAACmC,GAAG,CAAClC,aAAa,CAAC;MAEtD,IAAIoC,MAAM,KAAKV,MAAM,EAAE;QACrB;QACA;MACF;;MAEA;AACN;AACA;MACM,IAAI,CAAC3C,YAAY,CAACqD,MAAM,CAAC,EAAE;QACzBrD,YAAY,CAACqD,MAAM,CAAC,GAAG;UACrBN,QAAQ,EAAE,EAAE;UACZjD,OAAO,EAAE;YACP,CAACmB,aAAa,GAAG;UACnB,CAAC;UACDD,cAAc,EAAE,IAAIgC,GAAG,CAAC,CAAC;UACzBC,SAAS,EAAE,IAAID,GAAG,CAAC;QACrB,CAAC;MACH,CAAC,MAAM,IAAI,CAAChD,YAAY,CAACqD,MAAM,CAAC,CAACvD,OAAO,CAACmB,aAAa,CAAC,EAAE;QACvDjB,YAAY,CAACqD,MAAM,CAAC,CAACvD,OAAO,CAACmB,aAAa,CAAC,GAAG,EAAE;QAChDjB,YAAY,CAACqD,MAAM,CAAC,CAACrC,cAAc,CAACmC,GAAG,CAAClC,aAAa,CAAC;MACxD;MAEA,MAAM;QAAEnB,OAAO;QAAE,GAAG0D;MAAK,CAAC,GAAGhB,WAAW;MAExCxC,YAAY,CAACqD,MAAM,CAAC,CAACvD,OAAO,CAACmB,aAAa,CAAC,CAACI,IAAI,CAAC;QAAE,GAAGmC,IAAI;QAAEJ;MAAO,CAAC,CAAC;MACrEpD,YAAY,CAACqD,MAAM,CAAC,CAACJ,SAAS,CAACE,GAAG,CAACjB,WAAW,CAACkB,MAAM,CAAC,CAAC;IACzD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAO;IACLtD,OAAO,EAAEM,MAAM,CAACN,OAAO,IAAI,CAAC,CAAC;IAC7BC,UAAU;IACVC;EACF,CAAC;AACH","ignoreList":[]}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n NamedEffect,\n CustomEffect,\n RangeOffset,\n ScrubTransitionEasing,\n MotionAnimationOptions,\n} from '@wix/motion';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'wix-interact-element': React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n > & {\n 'data-wix-path'?: string;\n };\n }\n }\n}\n\nexport type TriggerType =\n | 'hover'\n | 'click'\n | 'viewEnter'\n | 'pageVisible'\n | 'animationEnd'\n | 'viewProgress'\n | 'pointerMove';\n\nexport type ViewEnterType = 'once' | 'repeat' | 'alternate';\n\nexport type TransitionMethod = 'add' | 'remove' | 'toggle' | 'clear';\n\nexport type StateParams = {\n method: TransitionMethod;\n};\n\nexport type PointerTriggerParams = {\n type?: ViewEnterType | 'state';\n};\n\nexport type ViewEnterParams = {\n type?: ViewEnterType;\n threshold?: number;\n inset?: string;\n};\n\nexport type PointerMoveParams = {\n hitArea?: 'root' | 'self';\n};\n\nexport type AnimationEndParams = {\n effectId: string;\n};\n\nexport type TriggerParams =\n | StateParams\n | PointerTriggerParams\n | ViewEnterParams\n | PointerMoveParams\n | AnimationEndParams;\n\ntype Fill = 'none' | 'forwards' | 'backwards' | 'both';\n\ntype MotionKeyframeEffect = {\n name: string;\n keyframes: Keyframe[];\n};\n\ntype EffectEffectProperty =\n | {\n keyframeEffect: MotionKeyframeEffect;\n }\n | {\n namedEffect: NamedEffect;\n }\n | {\n customEffect: CustomEffect;\n };\n\nexport type TimeEffect = {\n key?: string;\n duration: number;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n delay?: number;\n effectId?: string;\n} & EffectEffectProperty;\n\nexport type ScrubEffect = {\n key?: string;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n rangeStart?: RangeOffset;\n rangeEnd?: RangeOffset;\n centeredToTarget?: boolean;\n transitionDuration?: number;\n transitionDelay?: number;\n transitionEasing?: ScrubTransitionEasing;\n} & EffectEffectProperty;\n\nexport type TransitionOptions = {\n duration?: number;\n delay?: number;\n easing?: string;\n};\n\nexport type StyleProperty = {\n name: string;\n value: string;\n};\n\nexport type TransitionProperty = StyleProperty & TransitionOptions;\n\nexport type TransitionEffect = {\n key?: string;\n effectId?: string;\n} & {\n transition?: TransitionOptions & {\n styleProperties: StyleProperty[];\n };\n transitionProperties?: TransitionProperty[];\n};\n\nexport type EffectRef = {\n key?: string;\n effectId: string;\n listContainer?: string;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Effect = (TimeEffect | ScrubEffect | TransitionEffect) & {\n listContainer?: string;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Condition = {\n type: 'media' | 'container';\n predicate?: string;\n};\n\nexport type InteractionTrigger = {\n key: string;\n listContainer?: string;\n trigger: TriggerType;\n params?: TriggerParams;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Interaction = InteractionTrigger & {\n effects: ((Effect | EffectRef) & { interactionId?: string })[];\n};\n\nexport type InteractConfig = {\n effects: Record<string, Effect>;\n conditions?: Record<string, Condition>;\n interactions: Interaction[];\n};\n\nexport type AnimationOptions<T extends 'time' | 'scrub'> =\n MotionAnimationOptions<T> & EffectEffectProperty;\n\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n\nexport interface IWixInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n _observers: WeakMap<HTMLElement, MutationObserver>;\n connectedCallback(): void;\n disconnectedCallback(): void;\n connect(path?: string): void;\n renderStyle(cssRules: string[]): void;\n toggleEffect(effectId: string, method: StateParams['method']): void;\n watchChildList(listContainer: string): void;\n}\n\nexport type InteractionParamsTypes = {\n hover: StateParams | PointerTriggerParams;\n click: StateParams | PointerTriggerParams;\n viewEnter: ViewEnterParams;\n pageVisible: ViewEnterParams;\n animationEnd: AnimationEndParams;\n viewProgress: ViewEnterParams;\n pointerMove: PointerMoveParams;\n};\n\nexport type InteractionHandlerModule<T extends TriggerType> = {\n add: (\n source: HTMLElement,\n target: HTMLElement,\n effect: Effect,\n options: InteractionParamsTypes[T],\n reducedMotion?: boolean,\n ) => void;\n remove: (element: HTMLElement) => void;\n};\n\nexport type TriggerHandlerMap<T extends TriggerType> = {\n [K in T]: InteractionHandlerModule<K>;\n};\n\nexport type HandlerObject = {\n source: HTMLElement;\n target: HTMLElement;\n cleanup: () => void;\n handler?: () => void;\n};\n\nexport type HandlerObjectMap = WeakMap<HTMLElement, Set<HandlerObject>>;\n\nexport type InteractCache = {\n effects: {\n [effectId: string]: Effect;\n };\n conditions: {\n [conditionId: string]: Condition;\n };\n interactions: {\n [path: string]: {\n triggers: Interaction[];\n effects: Record<\n string,\n (InteractionTrigger & { effect: Effect | EffectRef })[]\n >;\n interactionIds: Set<string>;\n selectors: Set<string>;\n };\n };\n};\n\nexport type CreateTransitionCSSParams = {\n key: string;\n effectId: string;\n transition?: TransitionEffect['transition'];\n properties?: TransitionProperty[];\n childSelector?: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n NamedEffect,\n CustomEffect,\n RangeOffset,\n ScrubTransitionEasing,\n MotionAnimationOptions,\n} from '@wix/motion';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'wix-interact-element': React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n > & {\n 'data-wix-path'?: string;\n };\n }\n }\n}\n\nexport type TriggerType =\n | 'hover'\n | 'click'\n | 'viewEnter'\n | 'pageVisible'\n | 'animationEnd'\n | 'viewProgress'\n | 'pointerMove';\n\nexport type ViewEnterType = 'once' | 'repeat' | 'alternate';\n\nexport type TransitionMethod = 'add' | 'remove' | 'toggle' | 'clear';\n\nexport type StateParams = {\n method: TransitionMethod;\n};\n\nexport type PointerTriggerParams = {\n type?: ViewEnterType | 'state';\n};\n\nexport type ViewEnterParams = {\n type?: ViewEnterType;\n threshold?: number;\n inset?: string;\n};\n\nexport type PointerMoveParams = {\n hitArea?: 'root' | 'self';\n};\n\nexport type AnimationEndParams = {\n effectId: string;\n};\n\nexport type TriggerParams =\n | StateParams\n | PointerTriggerParams\n | ViewEnterParams\n | PointerMoveParams\n | AnimationEndParams;\n\ntype Fill = 'none' | 'forwards' | 'backwards' | 'both';\n\ntype MotionKeyframeEffect = {\n name: string;\n keyframes: Keyframe[];\n};\n\ntype EffectEffectProperty =\n | {\n keyframeEffect: MotionKeyframeEffect;\n }\n | {\n namedEffect: NamedEffect;\n }\n | {\n customEffect: CustomEffect;\n };\n\nexport type TimeEffect = {\n key?: string;\n duration: number;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n delay?: number;\n effectId?: string;\n} & EffectEffectProperty;\n\nexport type ScrubEffect = {\n key?: string;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n rangeStart?: RangeOffset;\n rangeEnd?: RangeOffset;\n centeredToTarget?: boolean;\n transitionDuration?: number;\n transitionDelay?: number;\n transitionEasing?: ScrubTransitionEasing;\n} & EffectEffectProperty;\n\nexport type TransitionOptions = {\n duration?: number;\n delay?: number;\n easing?: string;\n};\n\nexport type StyleProperty = {\n name: string;\n value: string;\n};\n\nexport type TransitionProperty = StyleProperty & TransitionOptions;\n\nexport type TransitionEffect = {\n key?: string;\n effectId?: string;\n} & {\n transition?: TransitionOptions & {\n styleProperties: StyleProperty[];\n };\n transitionProperties?: TransitionProperty[];\n};\n\nexport type EffectRef = {\n key?: string;\n effectId: string;\n listContainer?: string;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Effect = (TimeEffect | ScrubEffect | TransitionEffect) & {\n listContainer?: string;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Condition = {\n type: 'media' | 'container';\n predicate?: string;\n};\n\nexport type InteractionTrigger = {\n key: string;\n listContainer?: string;\n trigger: TriggerType;\n params?: TriggerParams;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Interaction = InteractionTrigger & {\n effects: ((Effect | EffectRef) & { interactionId?: string })[];\n};\n\nexport type InteractConfig = {\n effects: Record<string, Effect>;\n conditions?: Record<string, Condition>;\n interactions: Interaction[];\n};\n\nexport type AnimationOptions<T extends 'time' | 'scrub'> =\n MotionAnimationOptions<T> & EffectEffectProperty;\n\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n\nexport interface IWixInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n _observers: WeakMap<HTMLElement, MutationObserver>;\n connectedCallback(): void;\n disconnectedCallback(): void;\n connect(path?: string): void;\n disconnect(): void;\n renderStyle(cssRules: string[]): void;\n toggleEffect(effectId: string, method: StateParams['method']): void;\n watchChildList(listContainer: string): void;\n}\n\nexport type InteractionParamsTypes = {\n hover: StateParams | PointerTriggerParams;\n click: StateParams | PointerTriggerParams;\n viewEnter: ViewEnterParams;\n pageVisible: ViewEnterParams;\n animationEnd: AnimationEndParams;\n viewProgress: ViewEnterParams;\n pointerMove: PointerMoveParams;\n};\n\nexport type InteractionHandlerModule<T extends TriggerType> = {\n add: (\n source: HTMLElement,\n target: HTMLElement,\n effect: Effect,\n options: InteractionParamsTypes[T],\n reducedMotion?: boolean,\n ) => void;\n remove: (element: HTMLElement) => void;\n};\n\nexport type TriggerHandlerMap<T extends TriggerType> = {\n [K in T]: InteractionHandlerModule<K>;\n};\n\nexport type HandlerObject = {\n source: HTMLElement;\n target: HTMLElement;\n cleanup: () => void;\n handler?: () => void;\n};\n\nexport type HandlerObjectMap = WeakMap<HTMLElement, Set<HandlerObject>>;\n\nexport type InteractCache = {\n effects: {\n [effectId: string]: Effect;\n };\n conditions: {\n [conditionId: string]: Condition;\n };\n interactions: {\n [path: string]: {\n triggers: Interaction[];\n effects: Record<\n string,\n (InteractionTrigger & { effect: Effect | EffectRef })[]\n >;\n interactionIds: Set<string>;\n selectors: Set<string>;\n };\n };\n};\n\nexport type CreateTransitionCSSParams = {\n key: string;\n effectId: string;\n transition?: TransitionEffect['transition'];\n properties?: TransitionProperty[];\n childSelector?: string;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ export declare function getWixInteractElement(): {
|
|
|
10
10
|
_observers: WeakMap<HTMLElement, MutationObserver>;
|
|
11
11
|
connectedCallback(): void;
|
|
12
12
|
disconnectedCallback(): void;
|
|
13
|
+
disconnect(): void;
|
|
13
14
|
connect(key?: string): void;
|
|
14
15
|
renderStyle(cssRules: string[]): void;
|
|
15
16
|
toggleEffect(effectId: string, method: StateParams['method']): void;
|
|
@@ -17,6 +17,7 @@ export declare class Interact {
|
|
|
17
17
|
has(key: string): boolean;
|
|
18
18
|
clearInteractionStateForKey(key: string): void;
|
|
19
19
|
static create(config: InteractConfig): Interact;
|
|
20
|
+
static destroy(): void;
|
|
20
21
|
static getInstance(key: string): Interact | undefined;
|
|
21
22
|
static getElement(key: string): IWixInteractElement | undefined;
|
|
22
23
|
static setElement(key: string, element: IWixInteractElement): void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export interface IWixInteractElement extends HTMLElement {
|
|
|
131
131
|
connectedCallback(): void;
|
|
132
132
|
disconnectedCallback(): void;
|
|
133
133
|
connect(path?: string): void;
|
|
134
|
+
disconnect(): void;
|
|
134
135
|
renderStyle(cssRules: string[]): void;
|
|
135
136
|
toggleEffect(effectId: string, method: StateParams['method']): void;
|
|
136
137
|
watchChildList(listContainer: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/interact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.78.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "wow!Team",
|
|
6
6
|
"email": "wow-dev@wix.com"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.26.0",
|
|
35
|
-
"@wix/motion": "1.
|
|
35
|
+
"@wix/motion": "1.621.0",
|
|
36
36
|
"fizban": "^0.7.0",
|
|
37
37
|
"kuliso": "^0.4.13"
|
|
38
38
|
},
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"wallaby": {
|
|
69
69
|
"autoDetect": true
|
|
70
70
|
},
|
|
71
|
-
"falconPackageHash": "
|
|
71
|
+
"falconPackageHash": "a18a6f238911251b2f9e4c64c82b5de0b526f4fe6c3bcc9f6b06e528"
|
|
72
72
|
}
|