@cassida/plugin-hover-fix 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FSS contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CassPlugin } from '@cassida/compiler';
|
|
2
|
+
export interface HoverFixOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Media query body to wrap matching scopes in. Defaults to
|
|
5
|
+
* `(hover: hover)`. Override only if you have specific Houdini
|
|
6
|
+
* needs (e.g. `'(hover: hover) and (pointer: fine)'`).
|
|
7
|
+
*/
|
|
8
|
+
readonly query?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Pseudo selectors that should be gated by the media query. By
|
|
11
|
+
* default we wrap every `:hover` (and `&:hover`-compound forms);
|
|
12
|
+
* pass a custom set if you also want to gate `:focus-visible` etc.
|
|
13
|
+
*/
|
|
14
|
+
readonly selectors?: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds an FSS plugin that wraps any matching pseudo scope inside a
|
|
18
|
+
* media-query gate. The default targets the iOS Safari "sticky hover"
|
|
19
|
+
* problem: a hover style remains "stuck" on a touched element until
|
|
20
|
+
* the user taps elsewhere, because the device reports `:hover` on tap
|
|
21
|
+
* even though it has no real cursor.
|
|
22
|
+
*
|
|
23
|
+
* Example:
|
|
24
|
+
* cas().hover(c => c.color('red'))
|
|
25
|
+
*
|
|
26
|
+
* Without plugin → `.fss-X:hover { color: red }`
|
|
27
|
+
* → on iOS, color stays red after tap until next tap
|
|
28
|
+
*
|
|
29
|
+
* With plugin → `@media (hover: hover) { .fss-X:hover { color: red } }`
|
|
30
|
+
* → on iOS (which reports `(hover: none)`), the rule never applies
|
|
31
|
+
* → on desktop, identical behavior to the unfixed version
|
|
32
|
+
*
|
|
33
|
+
* The hash changes when this plugin is enabled (different ScopeBag
|
|
34
|
+
* tree → different canonical key), so caches are invalidated cleanly
|
|
35
|
+
* when toggling the plugin.
|
|
36
|
+
*/
|
|
37
|
+
export default function hoverFix(options?: HoverFixOptions): CassPlugin;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAKD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,UAAU,CAqB1E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { mapScopeBag, wrapInMediaScope, } from '@cassida/compiler';
|
|
2
|
+
const DEFAULT_QUERY = '(hover: hover)';
|
|
3
|
+
const DEFAULT_SELECTORS = [':hover'];
|
|
4
|
+
/**
|
|
5
|
+
* Builds an FSS plugin that wraps any matching pseudo scope inside a
|
|
6
|
+
* media-query gate. The default targets the iOS Safari "sticky hover"
|
|
7
|
+
* problem: a hover style remains "stuck" on a touched element until
|
|
8
|
+
* the user taps elsewhere, because the device reports `:hover` on tap
|
|
9
|
+
* even though it has no real cursor.
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
* cas().hover(c => c.color('red'))
|
|
13
|
+
*
|
|
14
|
+
* Without plugin → `.fss-X:hover { color: red }`
|
|
15
|
+
* → on iOS, color stays red after tap until next tap
|
|
16
|
+
*
|
|
17
|
+
* With plugin → `@media (hover: hover) { .fss-X:hover { color: red } }`
|
|
18
|
+
* → on iOS (which reports `(hover: none)`), the rule never applies
|
|
19
|
+
* → on desktop, identical behavior to the unfixed version
|
|
20
|
+
*
|
|
21
|
+
* The hash changes when this plugin is enabled (different ScopeBag
|
|
22
|
+
* tree → different canonical key), so caches are invalidated cleanly
|
|
23
|
+
* when toggling the plugin.
|
|
24
|
+
*/
|
|
25
|
+
export default function hoverFix(options = {}) {
|
|
26
|
+
const query = options.query ?? DEFAULT_QUERY;
|
|
27
|
+
const selectors = new Set(options.selectors ?? DEFAULT_SELECTORS);
|
|
28
|
+
return {
|
|
29
|
+
name: '@cassida/plugin-hover-fix',
|
|
30
|
+
transform(tree) {
|
|
31
|
+
return mapScopeBag(tree, (node) => {
|
|
32
|
+
const scope = node.scope;
|
|
33
|
+
if (scope === null)
|
|
34
|
+
return null; // root — never wrap
|
|
35
|
+
if (scope.kind !== 'pseudo')
|
|
36
|
+
return null;
|
|
37
|
+
if (!selectors.has(scope.selector))
|
|
38
|
+
return null;
|
|
39
|
+
// Don't double-wrap: if this :hover is already inside a
|
|
40
|
+
// (hover: hover) gate (hand-authored or earlier plugin
|
|
41
|
+
// pass), skip. We can't see ancestors from here, but the
|
|
42
|
+
// plugin runs once per compileOps, and recursion is
|
|
43
|
+
// bottom-up so the same node is visited only once.
|
|
44
|
+
return wrapInMediaScope(node, query);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAiB3B,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,iBAAiB,GAAsB,CAAC,QAAQ,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,UAA2B,EAAE;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC;IAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,iBAAiB,CAAC,CAAC;IAElE,OAAO;QACL,IAAI,EAAE,2BAA2B;QACjC,SAAS,CAAC,IAAc;YACtB,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBACzB,IAAI,KAAK,KAAK,IAAI;oBAAE,OAAO,IAAI,CAAC,CAAC,oBAAoB;gBACrD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;oBAAE,OAAO,IAAI,CAAC;gBACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC;oBAAE,OAAO,IAAI,CAAC;gBAChD,wDAAwD;gBACxD,uDAAuD;gBACvD,yDAAyD;gBACzD,oDAAoD;gBACpD,mDAAmD;gBACnD,OAAO,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cassida/plugin-hover-fix",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cassida plugin: wraps :hover scopes in @media (hover: hover) to neutralize iOS Safari's sticky-hover artifact on touch devices.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@cassida/compiler": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.9.0",
|
|
23
|
+
"typescript": "^5.6.3",
|
|
24
|
+
"vitest": "^2.1.4"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/pishio/cassida.git",
|
|
29
|
+
"directory": "packages/plugin-hover-fix"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/pishio/cassida/tree/main/packages/plugin-hover-fix#readme",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/pishio/cassida/issues"
|
|
34
|
+
},
|
|
35
|
+
"author": "pishio",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"cassida",
|
|
38
|
+
"css-in-js",
|
|
39
|
+
"compile-time",
|
|
40
|
+
"single-class",
|
|
41
|
+
"react"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc -p tsconfig.json",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|