@wix/site-service-interactions 1.0.9 → 1.0.10

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.
Files changed (74) hide show
  1. package/cjs/build/implementations/coreInteractions.js +34 -26
  2. package/cjs/build/implementations/coreInteractions.js.map +1 -1
  3. package/cjs/build/implementations/stylesToAdd.d.ts +1 -1
  4. package/cjs/build/implementations/stylesToAdd.js +1 -1
  5. package/cjs/build/implementations/v2/InteractionsScriptElement.d.ts +3 -0
  6. package/cjs/build/implementations/v2/InteractionsScriptElement.js +33 -0
  7. package/cjs/build/implementations/v2/InteractionsScriptElement.js.map +1 -0
  8. package/cjs/build/implementations/v2/cdnUrls.d.ts +2 -0
  9. package/cjs/build/implementations/v2/cdnUrls.js +6 -0
  10. package/cjs/build/implementations/v2/cdnUrls.js.map +1 -0
  11. package/cjs/build/implementations/v2/clickTriggerCss.d.ts +3 -0
  12. package/cjs/build/implementations/v2/clickTriggerCss.js +35 -0
  13. package/cjs/build/implementations/v2/clickTriggerCss.js.map +1 -0
  14. package/cjs/build/implementations/v2/configCss.d.ts +3 -0
  15. package/cjs/build/implementations/v2/configCss.js +15 -0
  16. package/cjs/build/implementations/v2/configCss.js.map +1 -0
  17. package/cjs/build/implementations/v2/configStyleHeadContent.d.ts +1 -0
  18. package/cjs/build/implementations/v2/configStyleHeadContent.js +16 -0
  19. package/cjs/build/implementations/v2/configStyleHeadContent.js.map +1 -0
  20. package/cjs/build/implementations/v2/interactionsScriptContent.d.ts +9 -0
  21. package/cjs/build/implementations/v2/interactionsScriptContent.js +52 -0
  22. package/cjs/build/implementations/v2/interactionsScriptContent.js.map +1 -0
  23. package/cjs/build/implementations/v2/motionPresets.d.ts +13 -0
  24. package/cjs/build/implementations/v2/motionPresets.js +54 -0
  25. package/cjs/build/implementations/v2/motionPresets.js.map +1 -0
  26. package/cjs/build/implementations/v2/namedEffectTypes.d.ts +2 -0
  27. package/cjs/build/implementations/v2/namedEffectTypes.js +42 -0
  28. package/cjs/build/implementations/v2/namedEffectTypes.js.map +1 -0
  29. package/cjs/build/implementations/v2/registerConfigEffects.d.ts +6 -0
  30. package/cjs/build/implementations/v2/registerConfigEffects.js +27 -0
  31. package/cjs/build/implementations/v2/registerConfigEffects.js.map +1 -0
  32. package/dist/implementations/coreInteractions.js +30 -22
  33. package/dist/implementations/coreInteractions.js.map +1 -1
  34. package/dist/implementations/stylesToAdd.d.ts +1 -1
  35. package/dist/implementations/stylesToAdd.js +1 -1
  36. package/dist/implementations/v2/InteractionsScriptElement.d.ts +3 -0
  37. package/dist/implementations/v2/InteractionsScriptElement.js +26 -0
  38. package/dist/implementations/v2/InteractionsScriptElement.js.map +1 -0
  39. package/dist/implementations/v2/cdnUrls.d.ts +2 -0
  40. package/dist/implementations/v2/cdnUrls.js +3 -0
  41. package/dist/implementations/v2/cdnUrls.js.map +1 -0
  42. package/dist/implementations/v2/clickTriggerCss.d.ts +3 -0
  43. package/dist/implementations/v2/clickTriggerCss.js +31 -0
  44. package/dist/implementations/v2/clickTriggerCss.js.map +1 -0
  45. package/dist/implementations/v2/configCss.d.ts +3 -0
  46. package/dist/implementations/v2/configCss.js +11 -0
  47. package/dist/implementations/v2/configCss.js.map +1 -0
  48. package/dist/implementations/v2/configStyleHeadContent.d.ts +1 -0
  49. package/dist/implementations/v2/configStyleHeadContent.js +12 -0
  50. package/dist/implementations/v2/configStyleHeadContent.js.map +1 -0
  51. package/dist/implementations/v2/interactionsScriptContent.d.ts +9 -0
  52. package/dist/implementations/v2/interactionsScriptContent.js +47 -0
  53. package/dist/implementations/v2/interactionsScriptContent.js.map +1 -0
  54. package/dist/implementations/v2/motionPresets.d.ts +13 -0
  55. package/dist/implementations/v2/motionPresets.js +16 -0
  56. package/dist/implementations/v2/motionPresets.js.map +1 -0
  57. package/dist/implementations/v2/namedEffectTypes.d.ts +2 -0
  58. package/dist/implementations/v2/namedEffectTypes.js +38 -0
  59. package/dist/implementations/v2/namedEffectTypes.js.map +1 -0
  60. package/dist/implementations/v2/registerConfigEffects.d.ts +6 -0
  61. package/dist/implementations/v2/registerConfigEffects.js +23 -0
  62. package/dist/implementations/v2/registerConfigEffects.js.map +1 -0
  63. package/package.json +8 -5
  64. package/src/implementations/coreInteractions.ts +36 -25
  65. package/src/implementations/stylesToAdd.ts +1 -1
  66. package/src/implementations/v2/InteractionsScriptElement.tsx +42 -0
  67. package/src/implementations/v2/cdnUrls.ts +4 -0
  68. package/src/implementations/v2/clickTriggerCss.ts +44 -0
  69. package/src/implementations/v2/configCss.ts +13 -0
  70. package/src/implementations/v2/configStyleHeadContent.ts +12 -0
  71. package/src/implementations/v2/interactionsScriptContent.ts +61 -0
  72. package/src/implementations/v2/motionPresets.ts +26 -0
  73. package/src/implementations/v2/namedEffectTypes.ts +52 -0
  74. package/src/implementations/v2/registerConfigEffects.ts +31 -0
@@ -1 +1 @@
1
- {"version":3,"file":"coreInteractions.js","sourceRoot":"","sources":["../../src/implementations/coreInteractions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,6DAA6D,CAAA;AAE/G,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAA;AAE7E,MAAM,YAAY,GAAG,CAAC,MAAsB,EAAE,eAAwB,EAAE,EAAE;IACtE,QAAQ,CAAC,kBAAkB,GAAG,eAAe,CAAA;IAC7C,QAAQ,CAAC,KAAK,CAAC;QACX,mBAAmB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC;QAC1E,iBA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jF,0FAA0F;QAC1F,iCAAiC;QACjC,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,CAAC,uCAAuC,CAAC,CAAC,CAAA;IACrG,CAAC;SAAM,CAAC;QACJ,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACzC,CAAC;IAED,OAAO;QACH,gBAAgB,EAAE,mBAAmB,CAAC,MAAM,CAAC,YAAY,CAAC;KAC7D,CAAA;AACL,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const wixInteractElementCss = "\n wix-interact-element {\n display: contents;\n }\n ";
1
+ export declare const wixInteractElementCss = "\n interact-element {\n display: contents;\n }\n ";
2
2
  export declare const hasClickTriggerCss = "\n .has-click-trigger {\n cursor: pointer;\n }\n ";
@@ -1,5 +1,5 @@
1
1
  export const wixInteractElementCss = `
2
- wix-interact-element {
2
+ interact-element {
3
3
  display: contents;
4
4
  }
5
5
  `;
@@ -0,0 +1,3 @@
1
+ import type { FunctionComponent } from 'react';
2
+ import type { InteractConfig } from '@wix/interact';
3
+ export declare const createV2InteractionsScriptElement: (config: InteractConfig, isReducedMotion: boolean, pageId: string) => FunctionComponent;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { reviveScriptElement } from '../reviveScriptElement';
3
+ import { getV2InteractionsScriptContent } from './interactionsScriptContent';
4
+ const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML'];
5
+ /**
6
+ * The config is written as raw markup, so a `</script` inside any string value would close the
7
+ * element early. `\u003c` is valid JSON that `JSON.parse` reads back as `<`.
8
+ */
9
+ const serializeConfigForScriptElement = (config) => JSON.stringify(config).replace(/</g, '\\u003c');
10
+ export const createV2InteractionsScriptElement = (config, isReducedMotion, pageId) => () => {
11
+ // This ID is also interpolated into raw module-script text. Percent-encoding removes
12
+ // script delimiters and template-literal syntax while keeping the ID deterministic.
13
+ const safePageId = encodeURIComponent(pageId);
14
+ const configId = `interactions-config-${safePageId}`;
15
+ const interactionsScriptContent = getV2InteractionsScriptContent(config, configId, isReducedMotion);
16
+ const configProps = {
17
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: serializeConfigForScriptElement(config) },
18
+ };
19
+ const loaderProps = {
20
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: interactionsScriptContent },
21
+ };
22
+ return (React.createElement(React.Fragment, null,
23
+ React.createElement("script", { type: "application/json", id: configId, ...configProps }),
24
+ React.createElement("script", { type: "module", id: `interactions-loader-${safePageId}`, ref: reviveScriptElement, ...loaderProps })));
25
+ };
26
+ //# sourceMappingURL=InteractionsScriptElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractionsScriptElement.js","sourceRoot":"","sources":["../../../src/implementations/v2/InteractionsScriptElement.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAA;AAE5E,MAAM,0BAA0B,GAAG,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAE1E;;;GAGG;AACH,MAAM,+BAA+B,GAAG,CAAC,MAAsB,EAAU,EAAE,CACvE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AAEnD,MAAM,CAAC,MAAM,iCAAiC,GAC1C,CAAC,MAAsB,EAAE,eAAwB,EAAE,MAAc,EAAqB,EAAE,CACxF,GAAG,EAAE;IACD,qFAAqF;IACrF,oFAAoF;IACpF,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC7C,MAAM,QAAQ,GAAG,uBAAuB,UAAU,EAAE,CAAA;IACpD,MAAM,yBAAyB,GAAG,8BAA8B,CAAC,MAAM,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAA;IACnG,MAAM,WAAW,GAAG;QAChB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,+BAA+B,CAAC,MAAM,CAAC,EAAE;KAC7F,CAAA;IACD,MAAM,WAAW,GAAG;QAChB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE;KAC/E,CAAA;IAED,OAAO,CACH;QACI,gCAAQ,IAAI,EAAC,kBAAkB,EAAC,EAAE,EAAE,QAAQ,KAAM,WAAW,GAAI;QACjE,gCACI,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,uBAAuB,UAAU,EAAE,EACvC,GAAG,EAAE,mBAAmB,KACpB,WAAW,GACjB,CACH,CACN,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const INTERACT_V2_IMPORT_URL = "https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js";
2
+ export declare const WIX_MOTION_PRESETS_IMPORT_URL = "https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js";
@@ -0,0 +1,3 @@
1
+ export const INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js';
2
+ export const WIX_MOTION_PRESETS_IMPORT_URL = 'https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js';
3
+ //# sourceMappingURL=cdnUrls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdnUrls.js","sourceRoot":"","sources":["../../../src/implementations/v2/cdnUrls.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,iEAAiE,CAAA;AAEvG,MAAM,CAAC,MAAM,6BAA6B,GACtC,+FAA+F,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
3
+ export declare const getClickTriggerCss: (config: InteractConfig) => string;
@@ -0,0 +1,31 @@
1
+ const escapeCssAttr = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
2
+ /**
3
+ * Mirrors `@wix/interact` `getSelector(interaction, { asCombinator: true, useFirstChild: true })`
4
+ * plus the `[data-interact-key="…"]` prefix from `CSSRuleToString`.
5
+ */
6
+ const getInteractionSourceSelector = (interaction) => {
7
+ const { key, selector, listContainer, listItemSelector } = interaction;
8
+ const attrSelector = `[data-interact-key="${escapeCssAttr(key)}"]`;
9
+ if (listContainer) {
10
+ const itemFilter = listItemSelector ? ` > ${listItemSelector}` : '';
11
+ const inner = selector ? `${listContainer}${itemFilter} ${selector}` : `${listContainer}${itemFilter || ' > *'}`;
12
+ return `${attrSelector} ${inner}`;
13
+ }
14
+ if (selector) {
15
+ return `${attrSelector} ${selector}`;
16
+ }
17
+ return `${attrSelector} > :first-child`;
18
+ };
19
+ /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
20
+ export const getClickTriggerCss = (config) => {
21
+ const selectors = [
22
+ ...new Set(config.interactions
23
+ .filter(({ trigger }) => trigger === 'activate' || trigger === 'click')
24
+ .map(getInteractionSourceSelector)),
25
+ ];
26
+ if (!selectors.length) {
27
+ return '';
28
+ }
29
+ return selectors.map(selector => `${selector} {\ncursor: pointer;\n}`).join('\n');
30
+ };
31
+ //# sourceMappingURL=clickTriggerCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clickTriggerCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/clickTriggerCss.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAElG;;;GAGG;AACH,MAAM,4BAA4B,GAAG,CACjC,WAAyF,EACnF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wix/interact';
2
+ /** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
3
+ export declare const getV2ConfigCss: (config: InteractConfig) => string;
@@ -0,0 +1,11 @@
1
+ import { generate } from '@wix/interact';
2
+ import { getClickTriggerCss } from './clickTriggerCss';
3
+ import { registerConfigEffects } from './registerConfigEffects';
4
+ /** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
5
+ export const getV2ConfigCss = (config) => {
6
+ registerConfigEffects(config);
7
+ const animationCss = generate(config, true).trim();
8
+ const clickCss = getClickTriggerCss(config).trim();
9
+ return [animationCss, clickCss].filter(Boolean).join('\n');
10
+ };
11
+ //# sourceMappingURL=configCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configCss.js","sourceRoot":"","sources":["../../../src/implementations/v2/configCss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,iGAAiG;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC7D,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAC7B,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IAClD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAElD,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC9D,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const getV2ConfigStyleHeadContent: (css: string) => string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Head content is a raw HTML string, so anything tag-like in the generated CSS either closes the
3
+ * style element early or trips the head appender's script-tag guard, which throws. Nothing in CSS
4
+ * opens a tag: `<` appears only in media range queries, followed by a space or a digit. Cutting
5
+ * from the first `<` that could start a tag leaves valid CSS untouched.
6
+ */
7
+ const sanitizeCssForStyleElement = (css) => {
8
+ const tagIndex = css.search(/<[a-zA-Z/]/);
9
+ return tagIndex === -1 ? css : css.slice(0, tagIndex);
10
+ };
11
+ export const getV2ConfigStyleHeadContent = (css) => `<style>${sanitizeCssForStyleElement(css)}</style>`;
12
+ //# sourceMappingURL=configStyleHeadContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configStyleHeadContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/configStyleHeadContent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CAAC,GAAW,EAAU,EAAE;IACvD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IACzC,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,UAAU,0BAA0B,CAAC,GAAG,CAAC,UAAU,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /**
3
+ * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
4
+ * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
5
+ * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
6
+ * would download each module twice.
7
+ */
8
+ export declare const getV2ModulePreloadHeadContent: (config: InteractConfig) => string;
9
+ export declare const getV2InteractionsScriptContent: (config: InteractConfig, configId: string, isReducedMotion: boolean) => string;
@@ -0,0 +1,47 @@
1
+ import { INTERACT_V2_IMPORT_URL, WIX_MOTION_PRESETS_IMPORT_URL } from './cdnUrls';
2
+ import { collectNamedEffectTypes } from './namedEffectTypes';
3
+ import { filterKnownPresetTypes } from './motionPresets';
4
+ const getPresetTypes = (config) => filterKnownPresetTypes(collectNamedEffectTypes(config));
5
+ const getModuleUrls = (presetTypes) => presetTypes.length > 0 ? [INTERACT_V2_IMPORT_URL, WIX_MOTION_PRESETS_IMPORT_URL] : [INTERACT_V2_IMPORT_URL];
6
+ /**
7
+ * The loader reaches these modules through dynamic `import()`, which the preload scanner cannot
8
+ * see, so without the links the fetches only start once the loader runs. No `crossorigin`: a bare
9
+ * `modulepreload` fetches with the same credentials mode as a bare `import()`, and a mismatch
10
+ * would download each module twice.
11
+ */
12
+ export const getV2ModulePreloadHeadContent = (config) => getModuleUrls(getPresetTypes(config))
13
+ .map(url => `<link rel="modulepreload" href="${url}">`)
14
+ .join('');
15
+ export const getV2InteractionsScriptContent = (config, configId, isReducedMotion) => {
16
+ const presetTypes = getPresetTypes(config);
17
+ const bindings = ['{ Interact }'];
18
+ const imports = getModuleUrls(presetTypes).map(url => `import(\`${url}\`)`);
19
+ if (presetTypes.length > 0) {
20
+ bindings.push(`{ ${presetTypes.join(', ')} }`);
21
+ }
22
+ const registerEffects = presetTypes.length > 0 ? ` Interact.registerEffects({ ${presetTypes.join(', ')} })` : undefined;
23
+ return [
24
+ `const configElement = document.getElementById(\`${configId}\`)`,
25
+ 'if (configElement) {',
26
+ ' const config = JSON.parse(configElement.textContent)',
27
+ ` const [${bindings.join(', ')}] = await Promise.all([`,
28
+ ...imports.map(importCall => ` ${importCall},`),
29
+ ' ])',
30
+ registerEffects,
31
+ ` Interact.forceReducedMotion = ${isReducedMotion}`,
32
+ ' Interact.setup({',
33
+ ' scrollOptionsGetter: function () {',
34
+ ' return document.getElementById(`site-root`)',
35
+ ' },',
36
+ ' allowA11yTriggers: true,',
37
+ ' viewEnter: {',
38
+ ' useSafeViewEnter: true,',
39
+ ' },',
40
+ ' })',
41
+ ' Interact.create(config)',
42
+ '}',
43
+ ]
44
+ .filter((line) => line !== undefined)
45
+ .join('\n');
46
+ };
47
+ //# sourceMappingURL=interactionsScriptContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactionsScriptContent.js","sourceRoot":"","sources":["../../../src/implementations/v2/interactionsScriptContent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAA;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD,MAAM,cAAc,GAAG,CAAC,MAAsB,EAAY,EAAE,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEpH,MAAM,aAAa,GAAG,CAAC,WAAqB,EAAY,EAAE,CACtD,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,EAAE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAA;AAE/G;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,MAAsB,EAAU,EAAE,CAC5E,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KAChC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAmC,GAAG,IAAI,CAAC;KACtD,IAAI,CAAC,EAAE,CAAC,CAAA;AAEjB,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC1C,MAAsB,EACtB,QAAgB,EAChB,eAAwB,EAClB,EAAE;IACR,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,CAAC,cAAc,CAAC,CAAA;IACjC,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,GAAG,KAAK,CAAC,CAAA;IAE3E,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,eAAe,GACjB,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAEpG,OAAO;QACH,mDAAmD,QAAQ,KAAK;QAChE,sBAAsB;QACtB,wDAAwD;QACxD,YAAY,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB;QACxD,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,UAAU,GAAG,CAAC;QAClD,MAAM;QACN,eAAe;QACf,mCAAmC,eAAe,EAAE;QACpD,oBAAoB;QACpB,wCAAwC;QACxC,mDAAmD;QACnD,QAAQ;QACR,8BAA8B;QAC9B,kBAAkB;QAClB,+BAA+B;QAC/B,QAAQ;QACR,MAAM;QACN,2BAA2B;QAC3B,GAAG;KACN;SACI,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ type EffectModule = {
2
+ web: unknown;
3
+ style?: unknown;
4
+ getNames: unknown;
5
+ };
6
+ export declare const motionPresets: Record<string, EffectModule>;
7
+ export declare const isKnownPresetType: (type: string) => boolean;
8
+ /**
9
+ * Preset names become bare JavaScript identifiers in the client loader. Filtering against the
10
+ * installed package prevents unknown names from creating invalid source or a failed import.
11
+ */
12
+ export declare const filterKnownPresetTypes: (types: string[]) => string[];
13
+ export {};
@@ -0,0 +1,16 @@
1
+ import * as allPresets from '@wix/wix-motion-presets';
2
+ export const motionPresets = allPresets;
3
+ const knownPresetTypes = new Set(Object.keys(motionPresets));
4
+ export const isKnownPresetType = (type) => knownPresetTypes.has(type);
5
+ /**
6
+ * Preset names become bare JavaScript identifiers in the client loader. Filtering against the
7
+ * installed package prevents unknown names from creating invalid source or a failed import.
8
+ */
9
+ export const filterKnownPresetTypes = (types) => {
10
+ const unknown = types.filter(type => !isKnownPresetType(type));
11
+ if (unknown.length > 0) {
12
+ console.warn(`Interactions: skipping unknown Wix motion preset type(s): ${unknown.join(', ')}`);
13
+ }
14
+ return types.filter(isKnownPresetType);
15
+ };
16
+ //# sourceMappingURL=motionPresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motionPresets.js","sourceRoot":"","sources":["../../../src/implementations/v2/motionPresets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAA;AAQrD,MAAM,CAAC,MAAM,aAAa,GAAiC,UAAqD,CAAA;AAEhH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAEtF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAe,EAAY,EAAE;IAChE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,6DAA6D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnG,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAC1C,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ export declare const collectNamedEffectTypes: (config: InteractConfig) => string[];
@@ -0,0 +1,38 @@
1
+ /** Prefer the effects map; fall back to an inline named effect when an effect id misses. */
2
+ const resolveEffect = (config, effect) => {
3
+ if (!effect.effectId) {
4
+ return effect;
5
+ }
6
+ return config.effects?.[effect.effectId] ?? effect;
7
+ };
8
+ const readNamedEffectType = (effect) => {
9
+ if (!('namedEffect' in effect) || !effect.namedEffect) {
10
+ return undefined;
11
+ }
12
+ const { type } = effect.namedEffect;
13
+ return typeof type === 'string' ? type : undefined;
14
+ };
15
+ export const collectNamedEffectTypes = (config) => {
16
+ const types = new Set();
17
+ const collectFromEffects = (effects) => {
18
+ for (const effect of effects) {
19
+ const type = readNamedEffectType(resolveEffect(config, effect));
20
+ if (type) {
21
+ types.add(type);
22
+ }
23
+ }
24
+ };
25
+ for (const interaction of config.interactions) {
26
+ collectFromEffects(interaction.effects ?? []);
27
+ for (const sequence of interaction.sequences ?? []) {
28
+ if ('effects' in sequence) {
29
+ collectFromEffects(sequence.effects);
30
+ continue;
31
+ }
32
+ const referencedSequence = config.sequences?.[sequence.sequenceId];
33
+ collectFromEffects(referencedSequence?.effects ?? []);
34
+ }
35
+ }
36
+ return [...types].sort();
37
+ };
38
+ //# sourceMappingURL=namedEffectTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namedEffectTypes.js","sourceRoot":"","sources":["../../../src/implementations/v2/namedEffectTypes.ts"],"names":[],"mappings":"AAMA,4FAA4F;AAC5F,MAAM,aAAa,GAAG,CAAC,MAAsB,EAAE,MAAoB,EAAsB,EAAE;IACvF,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAA;AACtD,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,MAA0B,EAAsB,EAAE;IAC3E,IAAI,CAAC,CAAC,aAA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,CAAA;AAC5B,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import type { InteractConfig } from '@wix/interact';
2
+ /**
3
+ * A named effect only runs once its preset is registered, so every path that reaches
4
+ * `Interact.create` or `generate` has to register the config's presets first.
5
+ */
6
+ export declare const registerConfigEffects: (config: InteractConfig) => void;
@@ -0,0 +1,23 @@
1
+ import { Interact } from '@wix/interact';
2
+ import { collectNamedEffectTypes } from './namedEffectTypes';
3
+ import { filterKnownPresetTypes, motionPresets } from './motionPresets';
4
+ // Interact's effect registry is process-global, so mirror it across repeated SSR renders.
5
+ const registeredTypes = new Set();
6
+ /**
7
+ * A named effect only runs once its preset is registered, so every path that reaches
8
+ * `Interact.create` or `generate` has to register the config's presets first.
9
+ */
10
+ export const registerConfigEffects = (config) => {
11
+ const presetsToRegister = {};
12
+ for (const type of filterKnownPresetTypes(collectNamedEffectTypes(config))) {
13
+ if (registeredTypes.has(type)) {
14
+ continue;
15
+ }
16
+ presetsToRegister[type] = motionPresets[type];
17
+ }
18
+ if (Object.keys(presetsToRegister).length > 0) {
19
+ Interact.registerEffects(presetsToRegister);
20
+ Object.keys(presetsToRegister).forEach(type => registeredTypes.add(type));
21
+ }
22
+ };
23
+ //# sourceMappingURL=registerConfigEffects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerConfigEffects.js","sourceRoot":"","sources":["../../../src/implementations/v2/registerConfigEffects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAKvE,0FAA0F;AAC1F,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAsB,EAAE,EAAE;IAC5D,MAAM,iBAAiB,GAAmB,EAAE,CAAA;IAE5C,KAAK,MAAM,IAAI,IAAI,sBAAsB,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACzE,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,SAAQ;QACZ,CAAC;QAED,iBAAiB,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,IAAI,CAAiB,CAAA;IACjE,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,QAAQ,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;QAC3C,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7E,CAAC;AACL,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-interactions",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "main": "cjs/build/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -43,19 +43,22 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@wix/interact": "^1.103.0",
46
+ "@wix/interact": "^2.5.8",
47
47
  "@wix/services-manager": "^0.2.20",
48
48
  "@wix/services-manager-react": "^0.1.26",
49
49
  "@wix/site-service-device-info": "1.0.2",
50
50
  "@wix/site-service-experiments": "1.0.3",
51
+ "@wix/site-service-head-appender": "1.0.1",
51
52
  "@wix/site-service-pages": "1.1.0",
52
53
  "@wix/site-service-provide-css": "1.0.1",
53
- "@wix/site-service-rendering-context": "1.0.1",
54
- "@wix/static-service": "1.0.19"
54
+ "@wix/static-service": "1.0.19",
55
+ "@wix/wix-motion-presets": "^1.0.0"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/react": "^18.3.1",
59
+ "@types/react-dom": "^18.3.1",
58
60
  "react": "^18.3.1",
61
+ "react-dom": "^18.3.1",
59
62
  "typescript": "^5.3.3",
60
63
  "vitest": "4.1.0"
61
64
  },
@@ -90,5 +93,5 @@
90
93
  ]
91
94
  }
92
95
  },
93
- "falconPackageHash": "629f3f89a2fc1e079366d274ab06644e0a74eba7c695c37d6f234e61"
96
+ "falconPackageHash": "6a5a4c22b50ccbb6b82b1bbe1aa5a588d4987df274e1b605bc05d9b6"
94
97
  }
@@ -1,14 +1,22 @@
1
- import { Interact } from '@wix/interact'
1
+ import { Interact } from '@wix/interact/web'
2
2
  import type { InteractConfig } from '@wix/interact'
3
3
  import { DeviceInfoDefinition } from '@wix/site-service-device-info/definition'
4
4
  import { ExperimentsDefinition } from '@wix/site-service-experiments/definition'
5
- import { RenderingContextDefinition } from '@wix/site-service-rendering-context/definition'
6
5
  import { PagesDefinition } from '@wix/site-service-pages/definition'
6
+ import { HeadAppenderDefinition } from '@wix/site-service-head-appender/definition'
7
7
  import { ProvideComponentServiceDefinition } from '@wix/services-manager-react/core-services/provide-component'
8
8
  import type { ServicesManager } from '@wix/services-manager/types'
9
9
  import { createInteractionsScriptElement } from './InteractionsScriptElement'
10
+ import { createV2InteractionsScriptElement } from './v2/InteractionsScriptElement'
11
+ import { getV2ConfigCss } from './v2/configCss'
12
+ import { getV2ConfigStyleHeadContent } from './v2/configStyleHeadContent'
13
+ import { getV2ModulePreloadHeadContent } from './v2/interactionsScriptContent'
14
+ import { registerConfigEffects } from './v2/registerConfigEffects'
10
15
 
11
16
  const initInteract = (config: InteractConfig, isReducedMotion: boolean) => {
17
+ // The bundled runtime is v2, where named effects come from a separate package the loader
18
+ // script imports on the SSR path. Here they have to be registered before create().
19
+ registerConfigEffects(config)
12
20
  Interact.forceReducedMotion = isReducedMotion
13
21
  Interact.setup({
14
22
  scrollOptionsGetter: () => globalThis.document.getElementById('site-root'),
@@ -20,28 +28,37 @@ const initInteract = (config: InteractConfig, isReducedMotion: boolean) => {
20
28
  Interact.create(config)
21
29
  }
22
30
 
23
- const tryInitInteractInSsr = (
31
+ const initRuntime = (
24
32
  config: InteractConfig,
25
33
  isReducedMotion: boolean,
26
- getService: ServicesManager['getService']
34
+ getService: ServicesManager['getService'],
35
+ useV2: boolean
27
36
  ) => {
28
- const hasInteractions = config.interactions?.length > 0
29
- if (!hasInteractions) {
30
- return false
37
+ if (!config.interactions?.length) {
38
+ return
31
39
  }
32
40
 
33
- const { currentPage } = getService(PagesDefinition)
34
- const pageId = currentPage?.id
35
-
41
+ const pageId = getService(PagesDefinition).currentPage?.id
36
42
  if (!pageId) {
37
- return false
43
+ return
38
44
  }
39
45
 
40
46
  const { addTopComponent } = getService(ProvideComponentServiceDefinition)
41
- const ssrScriptElement = createInteractionsScriptElement(config, isReducedMotion, pageId)
42
- addTopComponent(ssrScriptElement)
43
47
 
44
- return true
48
+ if (!useV2) {
49
+ addTopComponent(createInteractionsScriptElement(config, isReducedMotion, pageId))
50
+ return
51
+ }
52
+
53
+ // Both belong in the head: the preload links only help while the document is still parsing,
54
+ // and the generated CSS hides elements before their entrance effect, so it has to apply
55
+ // before the body renders.
56
+ const css = getV2ConfigCss(config).trim()
57
+ getService(HeadAppenderDefinition).setHead(
58
+ getV2ModulePreloadHeadContent(config) + (css ? getV2ConfigStyleHeadContent(css) : '')
59
+ )
60
+
61
+ addTopComponent(createV2InteractionsScriptElement(config, isReducedMotion, pageId))
45
62
  }
46
63
 
47
64
  const getInteractiveComps = (interactions: InteractConfig['interactions']) =>
@@ -50,7 +67,7 @@ const getInteractiveComps = (interactions: InteractConfig['interactions']) =>
50
67
  acc.add(key)
51
68
  // add reaction comps
52
69
  // there must be a key
53
- effects.forEach(({ key }) => acc.add(key!))
70
+ effects?.forEach(({ key }) => acc.add(key!))
54
71
 
55
72
  return acc
56
73
  }, new Set<string>())
@@ -58,21 +75,15 @@ const getInteractiveComps = (interactions: InteractConfig['interactions']) =>
58
75
  export const coreInteractions = (config: InteractConfig, getService: ServicesManager['getService']) => {
59
76
  const { reducedMotion: isReducedMotion } = getService(DeviceInfoDefinition)
60
77
  const { isOpen } = getService(ExperimentsDefinition)
61
- const { SSR } = getService(RenderingContextDefinition)
62
78
 
63
- const isSSRExperimentOpen = isOpen('specs.thunderbolt.interactionsInSsr')
64
- if (isSSRExperimentOpen) {
79
+ if (isOpen('specs.thunderbolt.interactionsInSsr')) {
65
80
  // Emits the config and loader scripts. Works in both environments: SSR serves markup the
66
81
  // parser executes, and on the client the loader's ref revives it into a script that runs —
67
82
  // which is what pages rendered only on the client (password-protected / members-only,
68
83
  // client-side navigation) need, since they never get a server-rendered document.
69
- const didInitInteractInSsr = tryInitInteractInSsr(config, isReducedMotion, getService)
70
-
71
- // Fall back to direct init on the client if the script element could not be set up
72
- // (e.g. no pageId or no interactions).
73
- if (!didInitInteractInSsr && !SSR) {
74
- initInteract(config, isReducedMotion)
75
- }
84
+ // v2 is only reachable from here: it ships as a loader script plus generated CSS, both of
85
+ // which exist only on this path.
86
+ initRuntime(config, isReducedMotion, getService, isOpen('specs.thunderbolt.vsm_interactions_v2'))
76
87
  } else {
77
88
  initInteract(config, isReducedMotion)
78
89
  }
@@ -1,5 +1,5 @@
1
1
  export const wixInteractElementCss = `
2
- wix-interact-element {
2
+ interact-element {
3
3
  display: contents;
4
4
  }
5
5
  `
@@ -0,0 +1,42 @@
1
+ import React from 'react'
2
+ import type { FunctionComponent } from 'react'
3
+ import type { InteractConfig } from '@wix/interact'
4
+ import { reviveScriptElement } from '../reviveScriptElement'
5
+ import { getV2InteractionsScriptContent } from './interactionsScriptContent'
6
+
7
+ const DANGEROUSLY_SET_INNER_HTML = ['dangerously', 'Set', 'Inner', 'HTML']
8
+
9
+ /**
10
+ * The config is written as raw markup, so a `</script` inside any string value would close the
11
+ * element early. `\u003c` is valid JSON that `JSON.parse` reads back as `<`.
12
+ */
13
+ const serializeConfigForScriptElement = (config: InteractConfig): string =>
14
+ JSON.stringify(config).replace(/</g, '\\u003c')
15
+
16
+ export const createV2InteractionsScriptElement =
17
+ (config: InteractConfig, isReducedMotion: boolean, pageId: string): FunctionComponent =>
18
+ () => {
19
+ // This ID is also interpolated into raw module-script text. Percent-encoding removes
20
+ // script delimiters and template-literal syntax while keeping the ID deterministic.
21
+ const safePageId = encodeURIComponent(pageId)
22
+ const configId = `interactions-config-${safePageId}`
23
+ const interactionsScriptContent = getV2InteractionsScriptContent(config, configId, isReducedMotion)
24
+ const configProps = {
25
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: serializeConfigForScriptElement(config) },
26
+ }
27
+ const loaderProps = {
28
+ [DANGEROUSLY_SET_INNER_HTML.join('')]: { __html: interactionsScriptContent },
29
+ }
30
+
31
+ return (
32
+ <>
33
+ <script type="application/json" id={configId} {...configProps} />
34
+ <script
35
+ type="module"
36
+ id={`interactions-loader-${safePageId}`}
37
+ ref={reviveScriptElement}
38
+ {...loaderProps}
39
+ />
40
+ </>
41
+ )
42
+ }
@@ -0,0 +1,4 @@
1
+ export const INTERACT_V2_IMPORT_URL = 'https://cdn.jsdelivr.net/npm/@wix/interact@2/dist/es/web.min.js'
2
+
3
+ export const WIX_MOTION_PRESETS_IMPORT_URL =
4
+ 'https://static.parastorage.com/services/wix-motion-presets/dist/wix-motion-presets.esm.min.js'
@@ -0,0 +1,44 @@
1
+ import type { InteractConfig, Interaction } from '@wix/interact'
2
+
3
+ const escapeCssAttr = (value: string): string => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
4
+
5
+ /**
6
+ * Mirrors `@wix/interact` `getSelector(interaction, { asCombinator: true, useFirstChild: true })`
7
+ * plus the `[data-interact-key="…"]` prefix from `CSSRuleToString`.
8
+ */
9
+ const getInteractionSourceSelector = (
10
+ interaction: Pick<Interaction, 'key' | 'selector' | 'listContainer' | 'listItemSelector'>
11
+ ): string => {
12
+ const { key, selector, listContainer, listItemSelector } = interaction
13
+ const attrSelector = `[data-interact-key="${escapeCssAttr(key)}"]`
14
+
15
+ if (listContainer) {
16
+ const itemFilter = listItemSelector ? ` > ${listItemSelector}` : ''
17
+ const inner = selector ? `${listContainer}${itemFilter} ${selector}` : `${listContainer}${itemFilter || ' > *'}`
18
+
19
+ return `${attrSelector} ${inner}`
20
+ }
21
+
22
+ if (selector) {
23
+ return `${attrSelector} ${selector}`
24
+ }
25
+
26
+ return `${attrSelector} > :first-child`
27
+ }
28
+
29
+ /** Emits `cursor: pointer` for click interaction triggers (`'activate' || 'click'`), one rule per unique source selector. */
30
+ export const getClickTriggerCss = (config: InteractConfig): string => {
31
+ const selectors = [
32
+ ...new Set(
33
+ config.interactions
34
+ .filter(({ trigger }) => trigger === 'activate' || trigger === 'click')
35
+ .map(getInteractionSourceSelector)
36
+ ),
37
+ ]
38
+
39
+ if (!selectors.length) {
40
+ return ''
41
+ }
42
+
43
+ return selectors.map(selector => `${selector} {\ncursor: pointer;\n}`).join('\n')
44
+ }
@@ -0,0 +1,13 @@
1
+ import { generate } from '@wix/interact'
2
+ import type { InteractConfig } from '@wix/interact'
3
+ import { getClickTriggerCss } from './clickTriggerCss'
4
+ import { registerConfigEffects } from './registerConfigEffects'
5
+
6
+ /** Register config-used presets, then emit animation FOUC CSS and click-trigger cursor rules. */
7
+ export const getV2ConfigCss = (config: InteractConfig): string => {
8
+ registerConfigEffects(config)
9
+ const animationCss = generate(config, true).trim()
10
+ const clickCss = getClickTriggerCss(config).trim()
11
+
12
+ return [animationCss, clickCss].filter(Boolean).join('\n')
13
+ }